+  RHDN Forum Archive
|-+  Romhacking
| |-+  ROM Hacking Discussion
| | |-+  Gameboy rom expansion blues
Pages: [1]
Author Topic: Gameboy rom expansion blues  (Read 554 times)
lifeinanalog
Guest
« on: January 07, 2007, 12:07:35 pm »

I've got some text that would be better in a newly expanded area of the ROM. It's not that I'm having problems expanding the ROM. I'm having difficulties getting the original pointer tables to point the the newly expanded areas. The expanded area starts at x20000 and I've tried to calculate accurate pointers for the text I've added there and they have failed every time. Does anyone know how to get the pointers for a newly expanded section of a ROM?

The pointers in the ROM seem to be two bytes. For example, if the text exists at xBO5E the pointer would be 5E70.   However, if the text exists at x1CA93 the pointer would be 934A.

Thanks!
Skuizaan
Guest
« Reply #1 on: January 07, 2007, 12:52:50 pm »

It seems to me, that you need to edit the pointer table to read 24bit instead of 16bit.  In my exploration of roms, any 16bit pointer will (for the most part) land you within the x0000-FFFF range that they are in.
by increasing the tables by another 8bit hex character, it allows the pointers increased range of x000000 to xFFFFFF.  giving you the ability to turn the pointer for "5E70" to 00 5E 70 letting you know it is near the front of the rom at x00B05E, or maybe making it 02 5E 70 or x02B05E. (where all your open space is in.)

It might be complicated a bit, I know there are some pointer hacking documents on this site, but I'm not sure if any of them properly cover how to convert pointer tables from 2byte to 3byte, and I don't know if I'm competent enough to explain how to do it.  Perhaps one of the gurus here could help more...
RedComet
Guest
« Reply #2 on: January 07, 2007, 01:15:43 pm »

I think Gid made a fairly lengthy post in a thread a while back about this very thing. I'll see if I can find it.

EDIT: Hope it helps.
« Last Edit: January 07, 2007, 01:21:04 pm by RedComet »
Ryusui
Guest
« Reply #3 on: January 07, 2007, 03:23:02 pm »

Thank God the Sylvanian Families games already have support for this...>_>
KingMike
Guest
« Reply #4 on: January 07, 2007, 05:26:57 pm »

Except that the GB CPU can't handle 24-bit pointers.
So you'd have to do an ASM hack to make it bankswap, read a value, bankswap back.
You'd have to get the bank (highest 8 bits) and the address (lower 16-bits, GB banks are always 16KB and loaded into $4000 to $7FFF).
(You'd probably have to write the routine in the first 16KB of ROM, since that area is never swapped, and always loaded into $0 to $3FFF)

IIRC Star Ocean:Blue Sphere did something like:
load the address (16-bits) into one register (can't say for sure, but probably HL, since that gets used as a pointer alot), load the bank into another register (let's say B), save the current bank # to RAM,
call a subroutine that: swaps in the bank # in register B, read HL, stores the value to another register (say A), swaps the original bank back in, and returns to the original code.
Tauwasser
Guest
« Reply #5 on: January 07, 2007, 05:40:33 pm »

Quote from: KingMike
(lower 16-bits, GB banks are always 16KB and loaded into $4000 to $7FFF).

Not always. MBC1 and 2 handle things differently I hear.
Most games do have code that get's 1 byte out of another rombank. It goes something like this:

Code:
ld b,$80
ld hl,$4123
call $0FB4

So that would give the resulting byte in a. The actual code at fb4 might differ a lot, however, many games use rst $10 and rst $18 as swap banks and reverse (respectively), just look for these kinda things in some code you know has to access widely different data. Or, you could just write one such call your own Smiley

cYa,

Tauwasser
Pages: [1]  


Powered by SMF 1.1.4 | SMF © 2006-2007, Simple Machines LLC