Gameboy Development Forum

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.

Ads

#1 2013-01-28 17:02:17

Volvagia
New member
From: Austria
Registered: 2013-01-28
Posts: 4

Understanding the Ldcd Y

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

 

#2 2013-01-28 23:50:57

paulc
Member
Registered: 2012-10-23
Posts: 27

Re: Understanding the Ldcd Y

Are you saying that VBlank is starting before line 145 is drawn?

Offline

 

#3 2013-01-29 03:36:25

nitro2k01
Administrator
Registered: 2008-02-22
Posts: 242

Re: Understanding the Ldcd Y

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.


Blog: Gameboy Genius
"A journey of a thousand miles begins with one small step"
Old Chinese Proverb

Offline

 

#4 2013-01-29 09:07:19

Volvagia
New member
From: Austria
Registered: 2013-01-28
Posts: 4

Re: Understanding the Ldcd Y

Thanks. smile

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

 

#5 2013-01-29 09:39:56

nitro2k01
Administrator
Registered: 2008-02-22
Posts: 242

Re: Understanding the Ldcd Y

What do you mean by stepping? Does the ROM stop sometimes, even when you don't tell it to?
Which game are you using?


Blog: Gameboy Genius
"A journey of a thousand miles begins with one small step"
Old Chinese Proverb

Offline

 

#6 2013-01-29 10:16:04

Volvagia
New member
From: Austria
Registered: 2013-01-28
Posts: 4

Re: Understanding the Ldcd Y

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

 

#7 2013-02-07 15:50:40

Volvagia
New member
From: Austria
Registered: 2013-01-28
Posts: 4

Re: Understanding the Ldcd Y

I have an other small question and don't want create a new thread for this.

In Alleway ROM appears following: (All Hex)

Code:

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

Last edited by Volvagia (2013-02-07 15:50:54)

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson