Code segmentation guide: Difference between revisions

Added a note about which SDK will be used by the documentation
m (Minor grammar fixing)
(Added a note about which SDK will be used by the documentation)
 
(3 intermediate revisions by 2 users not shown)
Line 1:
[[File:So_your_code_segment_is_over_1MB.png]]
 
You've been working hard on your Homebrew title, slowly adding in more content, when suddenly you realize that the game's having weird hanging issues related to any new assets that you've just added to your ROM. What gives?
 
== Why does the Code segment size matter? ==
Line 7:
When the console boots, the [[Initial Program Load]] which is contained in every ROM '''copies the first megabyte (1,048,576 bytes) of code to RAM and executes it'''. This means that if you've been linking your assets directly into your code segment, you can very quickly go past this 1MB limit.
 
Code by itself usually has a very small memory footprint (Butbut not negligible footprint, as we'll see later!), therefore, depending on how your engine is set up, you might only be required to split your assets from the main code and not have to worry about anything else.
 
== Where to go from here? ==
 
These pages are aimed at providing users who are new to embedded systems programming to work around this limitation. It is expected that you have '''a strong understanding of C'''. TheyThe code for the example ROMs provided in these pages should hopefullyall providebe youavailable with[https://github.com/n64brew/N64-Codesplit-Tutorial usefulin techniquesthis andrepository]. The sample code tois aidwritten infor your[[libultra]], homebrewusing development,the makefile and itspec isfile recommendedformat thatexpected theyfrom the library. The knowledge can be readeasily intransferred theto providedother SDKs or build systems. order:
 
Before you do anything, have a brief look over the code of the [https://github.com/n64brew/N64-Codesplit-Tutorial/tree/main/original original sample], as this is our "bad" starting ROM which we will improve upon. As soon as you've done that, look through the following pages (preferably in order):
* [[Splitting assets from code]]
* [[Data compression and filesystems]]
 
* [[Splitting assetsAssets from codeCode]]
Once you have read through those two pages, it is also recommended you look into techniques to split your code. It is preferable that you write your game to support at least one of these methods '''before''' you start adding too much to it, as it might become more challenging to modify such an intricate part of your engine after the fact:
* [[Filesystems]]
* [[Data Compression]]
 
OnceAfter you have read through those twothree pages (and more importantly, '''understood them'''), it is also recommended you look into techniques to split your code. It is preferable that you write your game to support at least one of these methods '''before''' you start adding too much to it, as it might become more challenging to modify such an intricate part of your engine after the fact:
 
* [[Overlays]]