Wisdom Tree compatibility (and here's how)
I did a search and couldn't find anything about this, save for a post that says it would be hard to reverse-engineer. Anyways...
Â
In case you didn't know, there are a handful of unlicensed game boy games made by a company Wisdom Tree. These roms are all over the internet, but unfortunately there aren't any emulators that support them. The problem is that they use a unique form of bank switching, unlike any of the official games.
Â
A few months back I made a game boy emulator for the mac, just for a side project. (
<div><iframe width="459" height="344" src="https://www.youtube.com/embed/7saYr4au9 ... ure=oembed" frameborder="0" allowfullscreen="true"></iframe></div>, download). Having played one of these games myself, I found an old forum post somewhere that actually described how to emulate them. If you click the video link above, you can see emulation of one of these games in action.Â
To add Wisdom Tree compatibility, all you need are 3 things:
- Way to detect wisdom tree carts. Since they do not follow the same header format of official games.
- ROM read function, due to unique bank switching
- ROM write function
Â
- The way I used in my emulator, was to check if it was an invalid header. If so, then check if the ROM data contains the text WISDOM(0x20)TREE or WISDOM(0x00)TREE - using those two different bytes for the space. If so, then you've got it. All 6 games contain one of those strings.
Â
- For these cartridges, a rom read function would work like so (I took this straight from my emulator, you could port it to C++ without any trouble). The big difference is that whereas official game boy games will only change the second rom bank (0x4000-0x7999) while leaving the first static (0x0000-0x3999), the wisdom tree carts change both of them.
Â
Code: Select all
- (uint8_t)readRomAtAddress :( uint16_t)address {
if (headerType == HEADERTYPE_WISDOM_TREE)
{
uint8_t *bytePtr = rom;
return *(bytePtr + address + romBankOffset);
}
else {
// support for official mappers would go here
}
}
}
Â
Â
A rom write function would look like this. Note that it moves the pointer around in increments of 0x8000. Whereas official game boy games use the value to determine which bank, Wisdom Tree carts use the write address itself, ignoring the value. So, writing to ROM address 0x02 would set the offset to 0x8000 * 2.
Â
Code: Select all
- (void)writeRomValue :( uint8_t)value atAddress :( uint16_t)address {
if (headerType == HEADERTYPE_WISDOM_TREE)
{
switch (address>>12) {
case 0:
case 1:
case 2:
case 3: {
romBankNumber = address;
romBankOffset = (address)*(0x8000);
//NSLog(@"Switching to romBankOffset %i", romBankOffset);
return;
}
default:
return;
}
}
else { // official gb games
...
}
}
}
I hope you guys can make possibly incorporate this into a windows emulator. I got a message this afternoon by a guy who said he'd like to see it, and after finding this project, maybe you can make it happen.