Anyone know of an ASM friendly lookup table generator?

A place for your artistic side. Discuss techniques and tools for pixel art on the NES, GBC, or similar platforms.

Moderator: Moderators

Post Reply
lazerbeat
Posts: 64
Joined: Tue Jul 09, 2013 7:13 am

Anyone know of an ASM friendly lookup table generator?

Post by lazerbeat »

I am working on learning how to use sprites so I am making a lot of edits to long lists like this

Code: Select all

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!
User avatar
Drew Sebastino
Formerly Espozo
Posts: 3496
Joined: Mon Sep 15, 2014 4:35 pm
Location: Richmond, Virginia

Re: Anyone know of an ASM friendly lookup table generator?

Post by Drew Sebastino »

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.)
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Anyone know of an ASM friendly lookup table generator?

Post by tokumaru »

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.
User avatar
Bregalad
Posts: 8056
Joined: Fri Nov 12, 2004 2:49 pm
Location: Divonne-les-bains, France

Re: Anyone know of an ASM friendly lookup table generator?

Post by Bregalad »

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.
User avatar
Movax12
Posts: 541
Joined: Sun Jan 02, 2011 11:50 am

Re: Anyone know of an ASM friendly lookup table generator?

Post by Movax12 »

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.
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Anyone know of an ASM friendly lookup table generator?

Post by rainwarrior »

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++.
User avatar
koitsu
Posts: 4201
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: Anyone know of an ASM friendly lookup table generator?

Post by koitsu »

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.
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Anyone know of an ASM friendly lookup table generator?

Post by tokumaru »

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.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Anyone know of an ASM friendly lookup table generator?

Post by tepples »

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?
User avatar
Bregalad
Posts: 8056
Joined: Fri Nov 12, 2004 2:49 pm
Location: Divonne-les-bains, France

Re: Anyone know of an ASM friendly lookup table generator?

Post by Bregalad »

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.
User avatar
koitsu
Posts: 4201
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: Anyone know of an ASM friendly lookup table generator?

Post by koitsu »

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.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Anyone know of an ASM friendly lookup table generator?

Post by tepples »

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.
[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.
User avatar
koitsu
Posts: 4201
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: Anyone know of an ASM friendly lookup table generator?

Post by koitsu »

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.
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.
zzo38
Posts: 1096
Joined: Mon Feb 07, 2011 12:46 pm

Re: Anyone know of an ASM friendly lookup table generator?

Post by zzo38 »

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.
(Free Hero Mesh - FOSS puzzle game engine)
User avatar
mikejmoffitt
Posts: 1353
Joined: Sun May 27, 2012 8:43 pm

Re: Anyone know of an ASM friendly lookup table generator?

Post by mikejmoffitt »

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.
Post Reply