Implementing GBS playback in an emulator

Discussion of programming and development for the original Game Boy and Game Boy Color.
Post Reply
drpavelleer
Posts: 1
Joined: Fri Aug 26, 2016 7:22 am

Implementing GBS playback in an emulator

Post by drpavelleer »

So I already have an emulator that can emulate GB/GBC games fully, but I would like to add the ability to play GBS files.

I've had a look around documentation of the format and source code of already existing players, but I'm left confused.
Most notably the GBS spec document confuses me the most, as it is very vague in where I should start reading GB instructions (Is it at 0x70 or at the load address? The example in ROM-bank switching didn't clear anything up)
The only thing I've gotten working is offsetting the RST positions to the load address but even then I don't know if I'm doing it correctly because I'm overwriting instructions that are already there and that doesn't seem right (right at the very start of the file).

So, to make this easier on myself, from the perspective of an existing emulator, what do I need to add/modify to get it playing GBS files?
mic_
Posts: 922
Joined: Thu Oct 05, 2006 6:29 am

Re: Implementing GBS playback in an emulator

Post by mic_ »

I set things up like this:

Code: Select all

    musicFile.read((char*)&mFileHeader, 0x70);

    numBanks = ((fileSize + mFileHeader.loadAddress - 0x70) + 0x3fff) >> 14;

    rom = new unsigned char[(uint32_t)numBanks << 14];

    memset(rom, 0, (uint32_t)numBanks << 14);
    musicFile.read((char*)rom + mFileHeader.loadAddress, fileSize-0x70);
Post Reply