It is currently Thu Oct 19, 2017 4:13 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 15 posts ] 
Author Message
PostPosted: Wed Jan 28, 2015 11:19 pm 
Offline

Joined: Tue Jul 09, 2013 7:13 am
Posts: 58
I am working on learning how to use sprites so I am making a lot of edits to long lists like this

Code:
sprites:
   ;vert tile attr horiz
.db $08, $00, $00, $a4
.db $08, $01, $00, $c9
.db $08, $02, $00, $84
.db $10, $03, $00, $88


with 64 entries

Does anyone happen to know of a tool to generate tables like this or to modify existing ones is for example, I want to change the tile number of every sprite but keep everything else the same or put in 64 random values between X and Y into the first column without having to manually edit all 64 lines of code?

If not how are you guys generating your tables?

Thanks!


Top
 Profile  
 
PostPosted: Wed Jan 28, 2015 11:33 pm 
Offline
User avatar

Joined: Mon Sep 15, 2014 4:35 pm
Posts: 3071
Location: Nacogdoches, Texas
You're asking if you could highlight one thing and make the word processor replace all the parts in the document that have that string of text with what you replaced with what you highlighted? (If that makes sense.) Also, about a magic table editor, I don't think (or at least I've never seen one) they exist.

Oh, about generating tables, I currently just write them manually. Thinking about it, (and I'm not being sarcastic) Microsoft Excel might be good at creating tables. I obviously know it creates different type of table, but you can use math functions and it works in a grid. (It also does what I said earlier, if I remember correctly.)


Top
 Profile  
 
PostPosted: Thu Jan 29, 2015 8:04 am 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10057
Location: Rio de Janeiro - Brazil
You could maybe use regular expressions when searching and replacing in Notepad++, as well as vertical selection.

Or you could use your assembler's loop and conditional structures and expressions to build up the tables programatically, instead of manually typing each value.


Top
 Profile  
 
PostPosted: Thu Jan 29, 2015 8:21 am 
Online
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7230
Location: Chexbres, VD, Switzerland
If something is too annoying or repetitive to do by hand, then definitely you'd want to make a program or a script that generates it for you. Anything can be used for that depending on your experience : Perl, Python, C, Java, or even plain old shell / batch if you are a skillful user.


Top
 Profile  
 
PostPosted: Thu Jan 29, 2015 9:43 am 
Offline
User avatar

Joined: Sun Jan 02, 2011 11:50 am
Posts: 522
You could do this with the assembler if the macro language is powerful enough (ca65), but you won't have the nice tables to look at in your source.


Top
 Profile  
 
PostPosted: Thu Jan 29, 2015 11:26 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5718
Location: Canada
Part of most game projects is making appropriate tools to build the game with. This includes writing scripts/programs to generate tables and other data for you. I often use Python for small things like this. For larger, interactive tools I'd probably make them in C++.


Top
 Profile  
 
PostPosted: Thu Jan 29, 2015 12:17 pm 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 3192
Location: Mountain View, CA, USA
Back in the day (90s), we used "whatever came with the system". Installing more crap on the system was highly discouraged. For example, doing table generation on the Apple IIGS, we'd just use Applesoft BASIC to generate all the .db statements and put them in a file. On x86 systems, we'd use QBASIC or Turbo Pascal (if we had it installed) for the same task.

On present-day Windows systems, you could use JScript or VBScript (both come wth the base OS, so no installation needed, both usable via cscript.exe) which should be enough (IMO) to do simple/complex math and generate all the stuff you need. It's remarkable how these two things often get neglected/forgotten. :(

On UNIX/Linux systems, a simple programming language of your choice would likely be necessary. Many Linux distros include Perl or Python by default, and you could even do it in bash (albeit painfully, depending on how complex the math is) if needed.


Top
 Profile  
 
PostPosted: Thu Jan 29, 2015 1:26 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10057
Location: Rio de Janeiro - Brazil
I've been using JavaScript to generate data lately. Every computer you can find nowadays has a web browser that runs JavaScript, even phones, so it doesn't get more compatible than that. There's even a new HTML5 FileReader API that will allow you to read binary files, so you can even do more advanced stuff than was possible before.


Top
 Profile  
 
PostPosted: Thu Jan 29, 2015 2:36 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19099
Location: NE Indiana, USA (NTSC)
But can a build process re-run these lookup table generators if needed without needing to install Node? Koitsu is already complaining about how heavy the dependencies of my build process are on Windows (including MSYS, Python, and PIL). Or should I make a polyfill that abstracts over the differences between cscript and Node, use cscript on Windows, and require Node only on Linux and Mac?


Top
 Profile  
 
PostPosted: Thu Jan 29, 2015 3:03 pm 
Online
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7230
Location: Chexbres, VD, Switzerland
koitsu wrote:
Back in the day (90s), we used "whatever came with the system". Installing more crap on the system was highly discouraged. For example, doing table generation on the Apple IIGS, we'd just use Applesoft BASIC to generate all the .db statements and put them in a file. On x86 systems, we'd use QBASIC or Turbo Pascal (if we had it installed) for the same task.

On present-day Windows systems, you could use JScript or VBScript (both come wth the base OS, so no installation needed, both usable via cscript.exe) which should be enough (IMO) to do simple/complex math and generate all the stuff you need. It's remarkable how these two things often get neglected/forgotten. :(

On UNIX/Linux systems, a simple programming language of your choice would likely be necessary. Many Linux distros include Perl or Python by default, and you could even do it in bash (albeit painfully, depending on how complex the math is) if needed.

While I agree with you ideally, I think it's ultimately better to use something you know well (even if it needs an install) rather than using some obscure language just because it is here with the system.

For instance if someone is extremely familiar with Python, I understand why they'd want to loose 1 minute to download and install python instead of using one hour to figure out how to generate .db statements in a file using JScript or VBScript.

Personally I use C all the time at work so that is the major language I'd use for everything. I know it is a terrible language, especially for this particular application, and there is many more adapted languages out there, but in the end I'd save time doing it in C just because I am so used to using it. Even if I wanted to use the C++ extensions I'd loose time because I'd have to look up for how you use std::cout, because I don't remember, so I end up using C anyways.

When I was a student I used to using java, now I'd never want to code in this language ever again, because it is absolutely awful and even worse than C in all aspects, cumulating C's problems with other problems made up especially for it. The only great thing about java is that it detects the buffer overflows problem instead of crashing or making segfaults. Other scripting languages such as Perl looks awesome, but I only used those a couple of times to try something, and it'd take forever to remember how to use Perl to do some basic operation. I had no idea JScript and VScript even existed. I though Java Script was only for web pages, I am surprised you could do a non-web application with it. Although if you use Java Script so often at work, I pefectly understand why you'd want to use this for an application where JavaScript was not supposed to be adapted, just to win time.

Sorry to have gotten completely off-topic.


Top
 Profile  
 
PostPosted: Thu Jan 29, 2015 5:38 pm 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 3192
Location: Mountain View, CA, USA
tepples wrote:
But can a build process re-run these lookup table generators if needed without needing to install Node? Koitsu is already complaining about how heavy the dependencies of my build process are on Windows (including MSYS, Python, and PIL). Or should I make a polyfill that abstracts over the differences between cscript and Node, use cscript on Windows, and require Node only on Linux and Mac?

What does Node.js have to do with what I said? (There's no other mention of it in this thread until now). For what I listed off, you don't need to install anything -- VBScript and JScript (as well as WScript) all come with Windows natively.

Re-focus: all the person is trying to do is generate single bytes of data to make a gigantic data table of pre-calculated data (to avoid having to do slow CPU-cycle-sucking math on 6502/65816). WITH THAT SPECIFIC TASK IN MIND: This can be done in any language, but I just happen to prefer to use ones that are already available on the system and don't require me to install something.

If the source data (that needs to be read/used to generate the table) is in a highly complex format, it's very likely one will need a PL (C, Python, Perl, whatever) to read that data, massage it in some way, and then output the .db statements.

Just like with everything in programming: there is no universal answer/solution because the situations all differ, and people's needs/requirements differ as well.


Top
 Profile  
 
PostPosted: Thu Jan 29, 2015 5:52 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19099
Location: NE Indiana, USA (NTSC)
koitsu wrote:
What does Node.js have to do with what I said? (There's no other mention of it in this thread until now). For what I listed off, you don't need to install anything -- VBScript and JScript (as well as WScript) all come with Windows natively.

WScript isn't on a FreeBSD PC. The closest thing I'm aware of is Node.

Quote:
[Generating lookup tables and converting data] can be done in any language, but I just happen to prefer to use ones that are already available on the system

I agree. I'm just not aware of any language that's already on both Windows and FreeBSD.


Top
 Profile  
 
PostPosted: Thu Jan 29, 2015 6:04 pm 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 3192
Location: Mountain View, CA, USA
tepples wrote:
WScript isn't on a FreeBSD PC. The closest thing I'm aware of is Node.

I already listed off available options on UNIX/Linux systems. I forgot another one though: awk/gawk.

Quote:
I agree. I'm just not aware of any language that's already on both Windows and FreeBSD.

There aren't any. That's why I listed off solutions for both in separate paragraphs.

Bottom line: there really isn't anything "common" between base/native Windows and base/native UNIX/Linux, and that's very disappointing for a lot of reasons.


Top
 Profile  
 
PostPosted: Sat Jan 31, 2015 10:37 pm 
Offline
User avatar

Joined: Mon Feb 07, 2011 12:46 pm
Posts: 919
Depending on the assembler of course you could generate lookup tables using the assembly language; how it is done depends on the assembler. I know Unofficial-MagicKit can do a lot and apparently ca65 can also it (but I don't know how); for other assemblers I don't know but you can try to look at the documentation to see if it explains such things.

Using features of text editor is also possible but that depends on what text editor you are using. Same with other programs, although it certainly can be done too. Maybe even SQLite could be usable for such purpose.

tepples wrote:
Or should I make a polyfill that abstracts over the differences between cscript and Node, use cscript on Windows, and require Node only on Linux and Mac?
It seems like that might help, so you might see if that can be done easily enough.

_________________
.


Top
 Profile  
 
PostPosted: Mon Feb 09, 2015 12:15 am 
Offline
User avatar

Joined: Sun May 27, 2012 8:43 pm
Posts: 1305
I've written a few tools in C here and there, and other than needing to set up mingw32 / some other compatible C toolchain on Windows, portability has been as simple as expected.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group