Splitting Assets from Code

From N64brew Wiki
Revision as of 15:41, 26 September 2021 by Buu342 (talk | contribs) (Added a bit more to the "Moving our assets" chapter)
Jump to navigation Jump to search

This first page will cover the important aspect of keeping your game assets separate from the game code (where assets are things like textures, models, sounds, etc...). Depending on how you've structured your project, or more importantly how far you are into it currently, this can be a relatively simple or relatively difficult task.

Start by looking at the original sample, before any modifications. It is a simple ROM with two rooms that can be switched between by pressing the A button, with a texture that is displayed in the middle.

If you take a look at the makefile, you will see that our textures (spr_bear and spr_burger) are being compiled as C code and then being linked into the codesegment. It's not a big concern for this small project, but due to the 1MB IPL limit, this will become a problem as the project gets bigger. The idea here is that we want to have the assets elsewhere in the ROM, and we load them from the cartridge only as we need them.

So first and foremost, lets move our assets over to ROM.

Moving our assets to ROM

For simplification reasons, we're going to convert our textures to binary data, instead of keeping their current form as C arrays. You should be able to do this for pretty much any sort of assets your game will need, such as static display lists. The process of actually converting your data to binary form will not be covered here, as there are plenty of tools to do that for you already.

Once your assets are in a binary format, you must remove the original code files from your makefile (as they're redundant) as well as any #include's relating to them. You can leave the array pointers in the code for the time being, as they'll be substituted later.

The actual process of putting your assets in ROM depends on your SDK setup:

TODO

TODO

Having a buffer in the codesegment

TODO

Having a buffer somewhere in RAM

TODO