Discussion about software development for the old-school Gameboys, ranging from the "Gray brick" to Gameboy Color
(Launched in 2008)
You are not logged in.
Good Day,
I try to understand the Gameboy architecture. The Ldcd Y on $FF44 say, which line is current drawing. I found infos, that say a rendering time for the visible area of lcdc is (456 * 144 Lines) 65.664 clocks. Mostly games start with a loop the waiting for the VBlank period, e. g.
---
100 NOP (4 Cycles)
101 JP 150 (12 Cycles)
---
150 LD a, FF44 (12 Cycles)
152 CP a, 91 (= 145d) (8 Cycles)
154 JR nz, 150 (8 Cycles)
---
But thats are only 44 Cycles. If i debug a game, he get at this point always $91 from $FF44. But why enter the Debugger so fast the VBlank period? Please can anyone this explain me?
Thanks
Last edited by Volvagia (2013-01-28 17:18:11)
Offline
Are you saying that VBlank is starting before line 145 is drawn?
Offline
I am not sure what you mean, but I will try to answer. On a real Gameboy, there is an internal boot ROM that will run before the game. This is what shows the Nintendo logo and plays the startup sound. So the value of LY depends on how long the boot ROM takes to run. For example, on a DMG (old Gameboy) LY is 0 when the boot ROM ends. On a Gameboy Color with a GBC game, the value is 90 (hex). On a Gameboy Color with an old game, it's 93 or 94 (hex). This depends on if you pressed buttons during startup to change the palette. Maybe different emulators will also have different values.
So the value on startup may vary, and a game should always wait until VBlank if it needs to turn off the LCD.
Offline
Thanks.
I know my english isn't good. x.x
I have try to find out why the Emulator/Debugger (I use bgb) reach a so great value after so less instructions. I'm try to understand what the Emulator is doing stepping through the ROM, using the PAN Document and the gbdev Wiki as reference.
Offline
What do you mean by stepping? Does the ROM stop sometimes, even when you don't tell it to?
Which game are you using?
Offline
bgb support to stop ROM execution and execute the next opcode on key press. So it's possible to compare the registers and RAMs content with the excepted values.
I tried several ROMs, e. g. Tetris, R-Type, Yoshi's Cookie and Alleyway. I think that are the simplest ROMs for original GB.
Offline
I have an other small question and don't want create a new thread for this.
In Alleway ROM appears following: (All Hex)
Offset OPCode ASM 56C 3E C8 LD A, C8 56E E0 CC LD (FF00 + CC), A
This write C8 into (FFCC).
After this, from one moment to the next, the VRAM in bgb is filled with data.
But i dont understand how this work. The VRAM isn't switchable, and FFCC is a not significant Byte in the Zero Page, isn't it?
Thanks.
Last edited by Volvagia (2013-02-07 15:50:54)
Offline