What's new

A simple question about GB

ziofu

New member
Hi there!

I was planning to write a GameBoy emulator, so I'm documenting a lot thanks to this forum. I've already made a Chip8 emulator with success, but the gap beetween that and a GB is huge.

Although all good docs I found, I didn't find the answer to one question (seems a pretty dumb one probably):
Where are located all the graphics of a game?

For what I know a 32kB cartridge loads into the first 32kB of memory (from 0x0000 to 0x7FFF) . Since the VRAM starts from 0x8000, I can't understand where to find the graphics informations...
Am I missing something important?

Thank you!
 

Exophase

Emulator Developer
I haven't done a GB emulator but I know a bit about it, please wait for some more experienced people to back up anything I say though. Well, of course I'm just citing the Pan docs anyway.

The first important thing to understand is that some parts of memory are ROM, and some parts are RAM. The ROM parts map directly into the cartridge, so things aren't "loaded" into those locations per se, more like you're reading straight off the cartridge when you read from those places.

With a setup like this the hardware won't usually be loading anything into RAM, either normal RAM or VRAM (or any other kind of RAM like OAM). It's the job of the program code running to load things into it. So the graphics aren't going to just be there, but the game will be responsible for loading things from the cartridge to VRAM. So if you are properly emulating CPU, memory, and DMA (as far as I can tell the original Gameboy doesn't have cartridge->VRAM DMA anyway) then you should be fine.

Now correctly interpreting that data in VRAM (for when you render graphics) is another story..
 
OP
Z

ziofu

New member
Thanks for answering and thanks for clarifing the ROM-RAM thing. I was (quite) aware about it, but practically speaking I think that the cartridge will be saved in an array or something like that... hence the term "load".

Anyway, let me see if I got this straight.
Basically, are the "instructions" in the cartridge that "load" data into VRAM? So tile informations are part of the cartridge itself...
 

Exophase

Emulator Developer
Thanks for answering and thanks for clarifing the ROM-RAM thing. I was (quite) aware about it, but practically speaking I think that the cartridge will be saved in an array or something like that... hence the term "load".

Anyway, let me see if I got this straight.
Basically, are the "instructions" in the cartridge that "load" data into VRAM? So tile informations are part of the cartridge itself...

Usually the raw tile/map data will be in the cartridge, but it could be represented in a different format than what will be stored in VRAM, or it could be generated dynamically by the game. The VRAM won't ever hold all of the graphics the game has (unless the game is very simple), rather, it'll hold a current map and tile set.

One way or another the game will be responsible for setting up the data in VRAM. What you have to do is make sure that memory stores from the CPU to VRAM work correctly.
 
OP
Z

ziofu

New member
That makes sense now... thank you again. I'll problably post again if I decide to go through it. :)
 
Last edited:

Top