Getting The Data
So, having decided on using Unity to create the data (levels, sprites, definitions. etc.).. how to get it in to the game?
A common way when using assembler is to dump out binary files and #incbin them in to the code base. This always had the advantage of being quick to assemble, as all the assembler needs to do is to copy the binary contents of a file to a particular location.
The downside is that it's not so easy to debug.
Now that my PC is probably 100000x quicker than anything I used in the 90s, assembler time isn't an issue at all. Assembling the entire project takes way less than a second!
So instead, I opted for the other common technique, which is to export files with asm code and data in them.
All data is now exported as labels, tables, and declarations in source. This has the wonderful advantage of being much easier to debug.
Here's an example of exported level data:
As all the assets are given labels inside the editor, the labels get recursed during export to come up with unique names for everything. This example shows two level character sets being exported, with pointers to their addresses.. and the _biscuits label shows the definition of a character set. (Number of cells followed by the cell data)
Here's an example of 'spawn data' - that is, positions and data for each different GameObject in a level.
Notice that different types of object have different numbers of parameters. This is a very easy thing to do in assembler, but would require more messy setup in C, for instance.
Next is an example of Sprite definitions. (Sprites are organised in to SpriteGroups, with varying numbers of frames for each one. It's a handy way to organise the data)
This one is odd in that it has some filler bytes at the end. This is because the data is organised in such a way as to make the code which uses it much faster than it would otherwise be. And 6 bytes are added there at the end to make make the lookup quicker. This sort of thing I am sure to re-visit during production when more optimization is needed, either for speed or space!
Comments
Post a Comment