3

I'm currently programming a GameBoy Classis Emulator. Here is the GitHub-repo (https://github.com/FelixWeichselgartner/GameBoy-Classic-Emulator).

The CPU instructions seem to be working fine. I compared the instructions with the ones of this gameboy debugger (http://bgb.bircd.org/). For Tetris im executing the same instructions.

My question is about the graphics. I have implemented a function that fetches the tiles from the correct address (depending on which tiles set is used). However I don't know how to initialise the Video Ram (@ adress 0x8000). I copied the 32kB Tetris rom in my memory from adress 0x0000 to 0x7FFF. Therefore everything from 0x8000 is not initialised here. Neither in the Debugging tool, nor in my code is something written to the vram (from the cpu opcode instructions).

Therefore I expected I will have to initialise the VRAM. However I could not find any resources online, when something is written to VRAM.

So my question: Which instance of a gameboy emulator is responsible for copying tiles in the VRAM.

What I have already tried:

Debugging with another emulator -> this showed me that no cpu instructions copy to VRAM.

Looking at various gameboy emulators on Github -> could'nt find anyone initialising the VRAM

I someone was able to help me I would be very thankful.

Greetings schnauzbartS

1 Answers1

3

On Gameboy Classic there's only one way to initialize VRAM - manually copy data with CPU instructions. It's game's responsibility. You can see this, for example, in bootstrap ROM:

XOR A                   ; $0003  Zero the memory from $8000-$9FFF (VRAM)
    LD HL,$9fff         ; $0004
Addr_0007:
    LD (HL-),A          ; $0007
    BIT 7,H             ; $0008
    JR NZ, Addr_0007    ; $000a

On Gameboy Color there's another way to write to VRAM - DMA. But, again, game has to explicitly trigger it. Gameboy doesn't do anything on its own.

creker
  • 9,400
  • 1
  • 30
  • 47