cearp wrote:What's the default base address? (I assume 0x80000000)
Yep, 0x80000000 is the default base address (GC main memory address range: 0x80000000 to 0x817FFFFF).
cearp wrote:Any reason you don't set the base and pointer at the top, is it maybe just to save a line?
The code handler already did it (base address (ba) = 0x80000000, pointer (po) = 0x80000000).
cearp wrote:Wouldn't setting the addresses at the end change them only for the next code?
Yes. If you modify the ba/po you should always reset it to its original values at the end of code.
cearp wrote:Also, is there a reason you set the pointer address to 0x8000000? I don't believe it is being used.
The code don't use the po. Anyway, it has a terminator code line and so we should also reset the pointer (using a "E2000001 80000000" or "E2000001 00000000" code line makes no sense).
cearp wrote:Anyway, comparing memory dumps, the USA equivalent of 384C94 is 383DC4.
Below is all info you need to port the widescreen code to NTSC-U region.
Code: Select all
PAL
80384C94: FC200818 frsp f1,f1 ; f1: fovy
80384C98: FC40E890 fmr f2,f29 ; f2: aspect ratio (hook)
80384C9C: FC60F090 fmr f3,f30 ; f3: positive distance to near clipping plane
80384CA0: FC80F890 fmr f4,f31 ; f4: positive distance to far clipping plane
80384CA4: 4BF9AACD bl 0x8031f770 ; SDK MTXPerspective function call
80384CA8: 3C608054 lis r3,-32684
80384CAC: 3863C910 subi r3,r3,14064
80384CB0: 38800000 li r4,0
80384CB4: 4BFB38A9 bl 0x8033855c
80384CB8: 38000000 li r0,0
80384CBC: 3C608054 lis r3,-32684
80384CC0: 3883C910 subi r4,r3,14064
80384CC4: 90040040 stw r0,64(r4)
80384CC8: D3C40044 stfs f30,68(r4)
80384CCC: D3E40048 stfs f31,72(r4)
80384CD0: D3A4004C stfs f29,76(r4)
80384CD4: C042DEE0 lfs f2,-8480(r2)
80384CD8: 806DCE14 lwz r3,-12780(r13)
80384CDC: A0030006 lhz r0,6(r3)
80384CE0: C822DEF8 lfd f1,-8456(r2)
80384CE4: 9001002C stw r0,44(r1)
80384CE8: 3C004330 lis r0,17200
80384CEC: 90010028 stw r0,40(r1)
80384CF0: C8010028 lfd f0,40(r1)
80384CF4: EC200828 fsubs f1,f0,f1
80384CF8: C0040014 lfs f0,20(r4)
80384CFC: EC010032 fmuls f0,f1,f0
80384D00: EC420032 fmuls f2,f2,f0
80384D04: D0440050 stfs f2,80(r4)
80384D08: C062DEE4 lfs f3,-8476(r2)
80384D0C: EC031024 fdivs f0,f3,f2
80384D10: D0040054 stfs f0,84(r4)
80384D14: 3C608054 lis r3,-32684
80384D18: 3863D3A8 subi r3,r3,11352
80384D1C: D0430018 stfs f2,24(r3)
80384D20: C002DEE8 lfs f0,-8472(r2) ; f0: 1.3333 (_SDA2_BASE_ (rtoc) FP constant)
16:9 aspect ratio patch
80000088: C042DEE8 lfs f2,-8472(r2) ; f2: 1.3333 (_SDA2_BASE_ (rtoc) FP constant)
8000008C: EFBD00B2 fmuls f29,f29,f2 ; f29: new aspect ratio = old aspect ratio * 1.3333
80000090: FC40E890 fmr f2,f29 ; f2: aspect ratio (for MTXPerspective function)
80000094: 48384C08 b 0x80384C9C
80384C98: 4BC7B3F0 b 0x80000088
Stuff that must be ported:
- Conditional & hook addresses (0x80384C94 & 0x80384C98)
- 1.3333 FP constant offset (0xDEE8)
- Branch instruction offsets (0x00384C08 & 0xFFC7B3F0)
US version
Conditional address: 0x80383DC4
Hook address: 0x80383DC8
FP constant offset: 0x???? (there's a chance, that the US version uses the same offset as the PAL version)
Branch instruction offsets calculation
0x80383DCC - 0x80000094 = 0x00383D38 -> branch instruction: 48383D38
0x80000088 - 0x80383DC8 = 0xFFC7C2C0 -> branch instruction: 4BC7C2C0
16:9 Aspect Ratio (Widescreen) code
20383DC4 FC200818
06000088 00000010
C042???? EFBD00B2
FC40E890 48383D38
04384C98 4BC7C2C0
E2000001 80008000
cearp wrote:Is there a tool you use for converting instructions to hex?
An assembler (and disassembler) tool is part of the WiiRD package:
"powerpc-gekko-as.exe"
"powerpc-gekko-objcopy.exe"
"vdappc.exe"
PPC assembler example (asm.s = source file, asm.bin = binary file):
powerpc-gekko-as.exe -mgekko -mregnames -o asm.o asm.s
powerpc-gekko-objcopy.exe -O binary asm.o asm.bin