18-02-2018, 02:08 AM
|
Posts: 5
Threads: 2
Joined: Feb 2018
|
(18-02-2018, 01:36 AM)queueRAM Wrote: Code on the N64 runs from RAM, so the code must be first copied from ROM to RAM. The boot code automatically copies 1MB of ROM starting at offset 0x1000 at startup to RAM address defined by the word at offset 8 in the N64 ROM header (0x80246000 in the case of SM64). There are two more sections of ROM code in SM64 that are copied to RAM by code. These are enumerated in the table below. If you want to add new code, the easiest way is to overwrite unused functions as you have found. If you need more space, you'll need to find an unused portion of RAM and DMA the code from ROM to that area manually before calling it.
There are many unused functions in ROM that you can overwrite if you want. 0x80246050-0x8024616F (ROM 0x001050-0x00116F) and the one immediately after it are pretty good. If you need more space, then the usual route is to start using an unused portion of ROM (like 0x7CC6C0 as you have found) and use DMA to copy it to expansion RAM.
Code:
RAM start, RAM end, RAM-to-ROM, ROM start, ROM end, length
0x8016F000, 0x801B99DF, 0x7FF4FB40, 0x21F4C0, 0x269E9F, 0x4A9E0
0x80246000, 0x8033A57F, 0x80245000, 0x001000, 0x0F557F, 0xF4580
0x80378800, 0x8038BC8F, 0x80283280, 0x0F5580, 0x108A0F, 0x13490
I see. Thank you for the detailed information. I'll do my best to follow your advice. Would you be able to point me towards any examples which copy custom code from ROM to expansion RAM? I'm not sure how I would go about that.
|