23-03-2016, 11:09 PM
|
Posts: 13
Threads: 6
Joined: Mar 2016
|
(22-03-2016, 11:32 PM)queueRAM Wrote: (22-03-2016, 03:58 PM)blitzmaster5000 Wrote:
I am currently trying to modify some physics in NFL Blitz 2000. I know the subroutine that handles gravity (there is a LUI/ORI MTC1 command that uses a floating point as a "gravity constant). I could simply modify the values being loaded into COP1, but instead, I would like to try and jump out of that subroutine to a new one and modify it there by perhaps adding a modifier or some other arithemetic operations. However, any attempts I've made at trying to jump out of it to somewhere else haven't worked.
I would replace a command that is not vital and JAL to some random place in the rom w/ lots of NOPs, such as 0x00071770. Problem is, even if I just do that and then add a JR RA to jump right back, it gives me an error. I think the problem is I'm not using the JAL opcode correctly... I saw in your simple cajeASM tutorial that you jump to address 802d66c0. How did you find out you can jump to this address? This is a ram, address correct? How would I be able to find a RAM address I could jump to in order to add my new code?
For efficiency reasons, the code in N64 games are first copied from ROM to RAM and then are executed from RAM. The boot code automatically copies 1MB of code starting at ROM offset 0x1000 to the address set at offset 0x8 in the ROM header (in NFL Blitz 2000, this is 0x80000400). Often more code is needed later on while running so this code often copies other code from ROM to RAM and jumps to it at run time. These are almost always done with DMA. The MIPS CPU core uses virtual addresses which are then translated to physical addresses by the hardware. 0x80000000 is the base virtual address of KSEG0 (direct mapped, cached RAM).
I ran a quick test on NFL Blitz 2000 and found the following DMA accesses for code. There may be more as I didn't actually get too far into the game.
ROM Offset RAM Addr. LENGTH
0x80000400 0x001000 0x100000 (might be smaller)
0x80248E00 0x02FB00 0x064200
To use this to convert a ROM offset to RAM virtual address (e.g. for a JAL), find the range it falls in the table above and compute:
ram = rom - (ROM Offset) + (RAM Addr.)
I found the address 0x00071800 in the ROM has NOPs, so I think I can stick my code in here, but I'm confused on some of the parts you mentioned. Are your labels backward? in your table, the ROM offset's look like they should be the 0x001000 and 0x02fb00 values, rather than the 0x80000400 and 0x80248e00 values.
|