Splitting Assets from Code: Difference between revisions

Finished Specfile section
(Added a bit more to the "Moving our assets" chapter)
(Finished Specfile section)
Line 15:
 
<tabber>
SPECSpec file =
Your Spec file, before adding the assets to it, would look something like this:<br>
TODO
<pre>
beginseg
name "code"
flags BOOT OBJECT
entry nuBoot
address NU_SPEC_BOOT_ADDR
stack NU_SPEC_BOOT_STACK
include "codesegment.o"
// Microcode includes here
endseg
 
// Wave's aren't used for anything in the PC SDK, they're just for visual reference
beginwave
name "original"
include "code"
endwave
</pre>
Adding in new raw assets is as simple as creating a new segment and specifying the <code>RAW</code> flag. For instance, having the data from <code>spr_bear.c</code> converted into binary form (with the name <code>spr_bear.bin</code>) and linking it to our ROM is as simple as:
<pre>
beginseg
name "spr_bear" // This name is important, and should be unique
flags RAW // Specify that this segment is raw data (and not code)
after "code" // Specify to put this data in ROM, right after our code segment (Although you can omit this line if you want)
include "spr_bear.bin" // The file to link
endseg
</pre>
Do this for all the assets, and you're almost done. The next step is to open a C header file (or better yet, create a new one) and to create some <code>extern</code> calls for your new segments:
<pre>
extern u8 _spr_bearSegmentRomStart[];
extern u8 _spr_bearSegmentRomEnd[];
</pre>
Remember that segment name I told you that was important and had to be unique? Whatever you set your segment name to, it needs to match the <code>extern</code>'s. Meaning, if you called your segment <code>NAME</code>, then you would need to define the <code>extern</code>'s as <code>_NAMESegmentRomStart</code> and <code>_NAMESegmentRomStart</code> respectively.
 
If you want to know more about Spec files, the online manuals do not contain a lot of information about them. Instead, it is highly recommended that you check out the '''Specfile Format''' chapter of the ''N64 EXEGCC Compiler User Guide'' for more information.
|-|
Linker script =
Line 22 ⟶ 56:
</tabber>
 
Now that our assets are in ROM, we need to DMA them to be able to use them in our game. There's two main ways to do this:
==Having a buffer in the codesegment==
 
== Having a buffer in the codesegment ==
TODO
 
== Having a buffer somewhere in RAM ==
TODO