(Link to AcmlmWiki) Offline: thank ||bass
Register | Login
Views: 13,040,846
Main | Memberlist | Active users | Calendar | Chat | Online users
Ranks | FAQ | ACS | Stats | Color Chart | Search | Photo album
04-23-23 09:57 AM
0 users currently in ROM Hacking.
Acmlm's Board - I3 Archive - ROM Hacking - [GB/GBC] ROM and Banks... New poll | |
Add to favorites | Next newer thread | Next older thread
User Post
neotransotaku

Sledge Brother
Liberated from school...until MLK day








Since: 11-17-05
From: In Hearst Field Annex...

Last post: 5910 days
Last view: 5907 days
Posted on 02-28-06 05:13 PM Link | Quote
I was wondering if someone could explain to me the relationship between banks and the breakdown of memory addresses in a GB/GBC game...
HyperHacker

Star Mario
Finally being paid to code in VB! If only I still enjoyed that. <_<
Wii #7182 6487 4198 1828


 





Since: 11-18-05
From: Canada, w00t!
My computer's specs, if anyone gives a damn.
STOP TRUNCATING THIS >8^(

Last post: 5908 days
Last view: 5908 days
Posted on 03-02-06 11:29 PM Link | Quote
On a GB/GBC, ROM is mapped into addresses 0000-7FFF. This means only 32K is accessible at a time. Games get around this by using some hardware in the cartridge that allows them to chnage which parts of the ROM are mapped. Most games divide the ROM into 16K banks; bank 0 (ROM addresses 0-3FFF) is always mapped to 0000-3FFF, and any other bank can be mapped to 4000-7FFF.

Some code to convert raw ROM addresses to CPU bank/address and back:

/*
Converts a GB pointer to a file address
Inputs:
-Bank = ROM bank
-Addr = ROM address
Returns: file address
*/
int GBToFileAddr(int Bank, int Addr)
{
if(Bank <= 0) return Addr;
return (Bank * 0x4000) + ((Addr & 0x7FFF) - 0x4000);
}


/*
Converts a file address to a GB ROM bank
Inputs:
-Addr = file address
Returns: Bank
*/
int GetGBBank(int Addr)
{
if(Addr < 0x4000) return 0;
return ((Addr / 0x4000) & 0xFF);
}


/*
Converts a file address to a GB ROM address
Inputs:
-Addr = file address
Returns: Bank
*/
int GetGBAddr(int Addr)
{
if(Addr < 0x4000) return Addr;
return (Addr & 0x3FFF) + 0x4000;
}
Dan

Purple Leever


 





Since: 11-18-05

Last post: 5916 days
Last view: 5907 days
Posted on 03-03-06 04:47 AM Link | Quote
Completely off-topic question, but while we are talking about GB, but how do palettes work for the GB? Can every tile just use four colours, or are there different shades that can be used?
HyperHacker

Star Mario
Finally being paid to code in VB! If only I still enjoyed that. <_<
Wii #7182 6487 4198 1828


 





Since: 11-18-05
From: Canada, w00t!
My computer's specs, if anyone gives a damn.
STOP TRUNCATING THIS >8^(

Last post: 5908 days
Last view: 5908 days
Posted on 03-03-06 05:08 AM Link | Quote
The screen can display a whopping 4 different colours. Each pixel has a value from 0 to 3. There are three I/O registers that allows you to select which colour each value corresponds to; one for backgrounds, and two for sprites. (Sprites have an attribute bit that selects which to use.) This is also how GBC and SuperGB colourize games; they assign various colours to each pixel value.
Add to favorites | Next newer thread | Next older thread
Acmlm's Board - I3 Archive - ROM Hacking - [GB/GBC] ROM and Banks... |


ABII

Acmlmboard 1.92.999, 9/17/2006
©2000-2006 Acmlm, Emuz, Blades, Xkeeper

Page rendered in 0.015 seconds; used 361.59 kB (max 432.55 kB)