So I've run into an issue where the pointer table is located after the text it points to. I would like to be able to expand the text as needed, which means I need to be able to move the pointer table. But to do that, of course, I need to find and alter the commands that indicate the pointer table offset.
I've partially traced what's happening in the disassembler using pSX debugger and PCSXTrace:
800161c8 00041400: SLL 00000014 (v0), 140000fe (a0), 10 (16) -> this 140000fe is used to calculated several different offsets
800164b4 8e030008: LW 00000014 (v1), 0008 (800bc070 (s0)) [800bc078] -> load base address
800164b8 00021383: SRA 00fe0000 (v0), 00fe0000 (v0), 0e (14) -> calculate relative offset of pointer table
800164bc 00621821: ADDU 801a6d3c (v1), 801a6d3c (v1), 000003f8 (v0) -> add offset to base address to get pointer table location
800164c0 00081080: SLL 000003f8 (v0), 00000000 (t0), 02 (2)
800164c4 00431021: ADDU 00000000 (v0), 00000000 (v0), 801a7134 (v1)
800164c8 8c420000: LW 801a7134 (v0), 0000 (801a7134 (v0)) [801a7134] -> load first word at pointer table location
800164cc 00000000: NOP
800164d0 00021080: SLL ffffff6f (v0), ffffff6f (v0), 02 (2) -> pointer
I think what I need to do is change that 0x03f8 to the new relative offset of the relocated pointer table, but since it's calculated by a bit shift, there isn't really any flexibility. Plus, I have no idea how to find where in the disc image that command is stored into memory from.
I'm at a total loss right now. Does anyone have any experience with moving pointer tables? Is this something that can be done on PSX?