Navigation

Extended Memory support



Used in "The Missing Stars" hack and to be inplemented in Toad's Tool 0.6.


Loader function (RAM = 0x80384e04, in ROM = 0x101B84)
[updated 04/13]

ADDIU  SP, SP,0xFFE8
SW     RA, 0x0014($sp)

LUI    A0, 0x8040
LUI    A1, 0x807F
ORI    A1, A1, 0xFFFC

Loop:
SW     R0, 0x0000 (A0)
ADDIU  A0, A0, 0x0004
BNE    A0, A1, Loop
NOP

LUI    A0, 0x8040
ORI    A0, A0, 0x0000     ; RAM destination (0x80400000)
LUI    A1, 0x0120
ORI    A1, A1, 0x0000
LUI    A2, 0x0130
JAL    0x80278504           ; DmaCopy (0x80400000, 0x01200000, 0x01300000)
ORI    A2, A2,0x0000

LW RA, 0x0014 ($sp)
JR RA
ADDIU SP, SP, 0x0018



write

27BDFFE8
AFBF0014
3C048040
3C05807F
34A5FFFC
AC800000
24840004
14A4FFFD
24000000
3C048040
34840000
3C050120
34A50000
3C060130
0C09E141
34C60000
8FBF0014
03E00008
27BD0018


at 0x101B84


Loader function hook (hooked at 0x802789FC, in the end of the 0x80278974 (CopyScriptInterpreter) function)

; Hook

.ORG 0x802789FC
jal 0x80384e04    ; Calls loader function, which replaces UNUSED behavior command 0x12 (0x80384e04 = 0x101b84 in ROM)
NOP

in ROM = write 0x0C0E1381 at 0x339FC.

patch for Level Script Function Table:
in ROM = write 0x804A0000 at 0x108678


0x10 Command (0x804A0000 in RAM, in ROM = 0x12A0000)

[10] [10] [00] [07] [80 50 00 00] [01 21 00 00] [01 2E 00 00]
00. Command
01. Lenght
02. Unused
03. Target segment
04-07: RAM Address Target
08-11: ROM Block start
12-16: ROM Block end


ADDIU SP, SP, 0xFFE8
SW RA, 0x0014 (SP)

LUI T6, 0x8039
LW T6, 0xBE28 (T6)     ; Pointer to command

LW A0, 0x0004 (T6)     ; RAM Target
LW A1, 0x0008 (T6)     ; Segment start in ROM
JAL 0x80278504         ; DmaCopy (u32 dst, u32 bottom, u32 top)
LW A2, 0x000C (T6)     ; Segment end in ROM

LUI T6, 0x8039
LW T6, 0xBE28 (T6)
LW A0, 0x0004 (T6)     ; Get RAM Target again
LUI T7, 0x8000
XOR A0, A0, T7         ; Convert virtual to machine address

LBU A3, 0x0003 (T6)    ; Target segment
SLL A3, A3, 0x2        ; segment * 4
LUI T4, 0x8033
ORI T4, T4, 0xB400    
ADDU T4, T4, A3        
SW A0, 0x0000 (T4)     ; segment_table[segment] = address;

LUI T7, 0x8039
LW T7, 0xBE28 (T7)
LBU A3, 0x0001 (T7)    ; lenght byte
ADDU T9, T7, A3
LUI AT, 0x8039
SW T9, 0xBE28 (AT)     ; pointer += lenght_byte;

LW RA, 0x0014 (SP)
JR RA
ADDIU SP, SP, 0x0018

Write

27BDFFE8
AFBF0014
3C0E8039
8DCEBE28
8DC40004
8DC50008
0C09E141
8DC6000C
3C0E8039
8DCEBE28
8DC40004
3C0F8000
008F2026
91C70003
00073880
3C0C8033
358CB400
01876021
AD840000
3C0F8039
8DEFBE28
91E70001
01E7C821
3C018039
AC39BE28
8FBF0014
03E00008
27BD0018

at 0x012A0000
Comments