development:csdk:2.0:codebanks
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| development:csdk:2.0:codebanks [2024/11/22 09:55] – created clyde | development:csdk:2.0:codebanks [2024/11/22 10:16] (current) – clyde | ||
|---|---|---|---|
| Line 4: | Line 4: | ||
| Functions and const variables have different markers in the form of Compiler Pragmas that should be wrapped around their definitions. See the [[https:// | Functions and const variables have different markers in the form of Compiler Pragmas that should be wrapped around their definitions. See the [[https:// | ||
| + | |||
| + | First, an example: | ||
| + | |||
| + | <code C> | ||
| + | #pragma rodata-name (push, " | ||
| + | |||
| + | const char longWindedDialogueText[] = " | ||
| + | |||
| + | #pragma rodata-name (pop) | ||
| + | |||
| + | #pragma code-name (push, " | ||
| + | |||
| + | void mySprawlingPlayerUpdateFunction() { | ||
| + | // absolutely massive switch block | ||
| + | // good lord so many if-statements | ||
| + | // did you really need to fully implement A-star | ||
| + | } | ||
| + | |||
| + | #pragma code-name (pop) | ||
| + | </ | ||
| + | |||
| + | Here we can see that '' | ||
| + | |||
| + | Now, if you simply call this function or access that data without any preparation you're gonna encounter unexpected behavior or crash. | ||
| + | |||
| + | To correctly access this data you'll need to use the [[development: | ||
| + | |||
| + | <code C> | ||
| + | #include " | ||
| + | #include " | ||
| + | |||
| + | //no pragmas around this, it should live in the default code bank | ||
| + | void mySprawlingPlayerUpdateFunction_wrapper() { | ||
| + | |||
| + | push_rom_bank(); | ||
| + | | ||
| + | change_rom_bank(BANK_PROG0); | ||
| + | | ||
| + | mySprawlingPlayerUpdateFunction(); | ||
| + | | ||
| + | pop_rom_bank(); | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ===== A warning ===== | ||
| + | |||
| + | You really don't want to call '' | ||
development/csdk/2.0/codebanks.1732269344.txt.gz · Last modified: 2024/11/22 09:55 by clyde
