development:csdk:2.0:codebanks
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| development:csdk:2.0:codebanks [2024/11/22 10:10] – clyde | development:csdk:2.0:codebanks [2026/02/23 19:05] (current) – clyde | ||
|---|---|---|---|
| Line 35: | Line 35: | ||
| #include " | #include " | ||
| + | //main is assumed to be in the boot bank | ||
| + | void main() { | ||
| + | //If you only ever use one alternate code bank, you can just call change_rom_bank once. | ||
| + | //SDK functions (should) all restore the active bank if they change banks internally | ||
| + | change_rom_bank(BANK_PROG0); | ||
| + | | ||
| + | while(1) { | ||
| + | mySprawlingPlayerUpdateFunction(); | ||
| + | | ||
| + | //then the usual... | ||
| + | await_vsync(1); | ||
| + | flip_pages(); | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ===== A warning ===== | ||
| + | |||
| + | You really don't want to call '' | ||
| + | |||
| + | <code C> | ||
| + | #include " | ||
| + | #include " | ||
| + | |||
| + | //" | ||
| //no pragmas around this, it should live in the default code bank | //no pragmas around this, it should live in the default code bank | ||
| void mySprawlingPlayerUpdateFunction_wrapper() { | void mySprawlingPlayerUpdateFunction_wrapper() { | ||
| + | //Banking API provides a stack for storing the active bank | ||
| push_rom_bank(); | push_rom_bank(); | ||
| | | ||
| Line 44: | Line 70: | ||
| mySprawlingPlayerUpdateFunction(); | mySprawlingPlayerUpdateFunction(); | ||
| | | ||
| + | //Pop the stack before returning from code that changes banks | ||
| pop_rom_bank(); | pop_rom_bank(); | ||
| } | } | ||
| </ | </ | ||
development/csdk/2.0/codebanks.1732270233.txt.gz · Last modified: 2024/11/22 10:10 by clyde
