Page 1 of 1

Wisdom Tree compatibility (and here's how)

Posted: Tue Sep 11, 2012 10:23 pm
by Carrin

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:

  1. Way to detect wisdom tree carts. Since they do not follow the same header format of official games.
  1. ROM read function, due to unique bank switching
  1. ROM write function

 

  1. 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.

 

  1. 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.


Wisdom Tree compatibility (and here's how)

Posted: Wed Sep 12, 2012 6:35 am
by Squall Leonhart

none of the official MBC chips so far are detected by a header, so theres no particular reason why this custom MBC would require it,

 

The bank controller should be detectable just by determining which registers are set when the rom is started and setting the appropriate bank/mapper addresses.


Wisdom Tree compatibility (and here's how)

Posted: Tue Oct 23, 2012 11:49 pm
by neca

Is emulating these games something the VBA-M team will look into? I'd also be really interested on seeing the Wisdom Tree games emulated. Like the OP said there is currently not a single emulator (windows at least) that can emulate these games.


Wisdom Tree compatibility (and here's how)

Posted: Sat Nov 17, 2012 10:42 am
by Iconoclast

Well, if the header is "invalid," but it loads on an actual GBA anyway, maybe the header should be almost ignored by an accurate emulator, or the header is just not thoroughly documented enough to understand the functionality of all of the bits? I know there is a bare minimum of which bits need to be set in an N64 header for games to boot there.