Kuribo64
Views: 19,856,523 Home | Forums | Uploader | Wiki | Object databases | IRC
Rules/FAQ | Memberlist | Calendar | Stats | Online users | Last posts | Search
03-29-24 12:16 PM
Guest:

0 users reading Expanding the game's code | 1 bot

Main - Archived forums - General SMG hacking - Expanding the game's code Hide post layouts | New reply


Arisotura
Posted on 06-17-13 10:04 PM (rev. 2 of 06-17-13 10:04 PM) Link | #25871
The safest way to add code, besides putting some in the slot at 0x80001800, is to take space from the game's heap space.

The main memory is basically laid out like this: Game code, then stack, then game heap. The code takes the size specified in the .dol. The stack is 64K. The game heap basically takes the remaining space.

The issue is that the offsets for the stack and the heap are hardcoded. The offsets are the following for PAL:

Game code: 0x80004000 - (end specified in .dol-- shouldn't overlap the stack!)
Stack: 0x807E8888 - 0x807F8888
Heap: 0x807F8888 - whatever

For PAL again, here are the addresses of the instructions to patch to modify those offsets: (the instructions are lis/addi couples or derivates)

0x807E8888: 0x805BC5B0/0x805BC5BC
0x807F8888: 0x80004284/0x80004288, 0x805B38E0/0x805B38E4, 0x805B3968/0x805B396C, 0x805BC5AC/0x805BC5B4


That has been tested and so far caused no issues.


Patching the lis/addi couples and such

So far there are two possibilities: lis/addi and lis/ori.

lis/addi: val = (val_lis << 16) + val_addi
lis/ori: val = (val_lis << 16) | val_ori

It is worth noting that the 16bit values are signed. In the case of lis/ori, this isn't a problem. However, for lis/addi, if val_addi is above 0x7FFF, you must add one to val_lis.

____________________
NSMBHD - Kafuka - Jul
melonDS the most fruity DS emulator there is

zafkflzdasd

NWPlayer123
Posted on 11-01-14 11:03 PM Link | #50585
Same addresses in NTSC, only the stack goes to 0x807F3188, not 0x807F8888.

____________________
"I hate playing musical chats" ~ Quote of the month


Main - Archived forums - General SMG hacking - Expanding the game's code Hide post layouts | New reply

Page rendered in 0.018 seconds. (2048KB of memory used)
MySQL - queries: 27, rows: 197/197, time: 0.009 seconds.
[powered by Acmlm] Acmlmboard 2.064 (2018-07-20)
© 2005-2008 Acmlm, Xkeeper, blackhole89 et al.