I have Stupid questions about the vblank signal off the DMG's lcd

Discussion of programming and development for the original Game Boy and Game Boy Color.
Post Reply
spaceharrier
Posts: 40
Joined: Wed Jan 19, 2022 9:52 am

I have Stupid questions about the vblank signal off the DMG's lcd

Post by spaceharrier »

I am working on a mechanism to capture the lcd data signals from a DMG-01 and drive it through a tmds serializer.

I realize this has been done before, but I am challenging myself to get something that synchronizes the HDMI output with the gameboy at the same frequency to prevent tearing.

By luck, I am able to obtain an oscillator that is a multiple of the 2^22 MHZ frequency supplied by the Gameboy, and I would like to use the actual vblank signal coming off of the gameboy itself as part of my synchronizer, which I think is possible, with acceptable jitter, for most modern monitors to capture.

If the vblank is disabled in the gameboy's LCD Status register, or the display is completely disabled in the gameboy's LCD Control register, does this stop the vertical blank signal to the LCD, or does it simply disable interrupt routing from the ppu to the cpu?
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: I have Stupid questions about the vblank signal off the DMG's lcd

Post by lidnariq »

spaceharrier wrote: Wed Jan 25, 2023 10:08 am If the vblank is disabled in the gameboy's LCD Status register, or the display is completely disabled in the gameboy's LCD Control register, does this stop the vertical blank signal to the LCD, or does it simply disable interrupt routing from the ppu to the cpu?
Everything stops.

When you restart, it begins at the scanline just below the one where the vsync signal is asserted.

There's basically no way to handle this without tearing, variable latency, or a monitor that supports Freesync or GSync
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: I have Stupid questions about the vblank signal off the DMG's lcd

Post by tepples »

I agree that FreeSync aka VESA Adaptive Sync is probably the least bad way to accommodate this timing quirk of the Game Boy LCD. Then as a fallback for monitors without FreeSync, you could implement a full frame buffer and display "For less lag, use a FreeSync monitor" on the upscaler's OSD during the boot ROM.
spaceharrier
Posts: 40
Joined: Wed Jan 19, 2022 9:52 am

Re: I have Stupid questions about the vblank signal off the DMG's lcd

Post by spaceharrier »

At just $3700 to upgrade my copy of Quartus from "Poor People Edition" to one with an adaptive sync core, this might not be easily doable.

Someone did make a FOSS implementation of HDMI 1.4b (not just DVI tmds) that might drive a display at 120 hz, which could reasonably work without tearing or rejecting locked frames (and ~8ms delay is not terrible) This requires a beefier FPGA, but the cost is nowhere near as bad as upgrading Quartus.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: I have Stupid questions about the vblank signal off the DMG's lcd

Post by lidnariq »

Can you do 640x480@120 instead? It's not like the DMG emits all that many pixels...
spaceharrier
Posts: 40
Joined: Wed Jan 19, 2022 9:52 am

Re: I have Stupid questions about the vblank signal off the DMG's lcd

Post by spaceharrier »

lidnariq wrote: Wed Jan 25, 2023 3:53 pm Can you do 640x480@120 instead? It's not like the DMG emits all that many pixels...
My TFP410 board has the bandwidth for that. I don't know if that would work, but it would be a cheap solution if so. I'll run a test later.
nitro2k01
Posts: 252
Joined: Sat Aug 28, 2010 9:01 am

Re: I have Stupid questions about the vblank signal off the DMG's lcd

Post by nitro2k01 »

lidnariq wrote: Wed Jan 25, 2023 10:20 am
spaceharrier wrote: Wed Jan 25, 2023 10:08 am If the vblank is disabled in the gameboy's LCD Status register, or the display is completely disabled in the gameboy's LCD Control register, does this stop the vertical blank signal to the LCD, or does it simply disable interrupt routing from the ppu to the cpu?
Everything stops.

When you restart, it begins at the scanline just below the one where the vsync signal is asserted.

There's basically no way to handle this without tearing, variable latency, or a monitor that supports Freesync or GSync
Just to add to lidnariq's answer for completeness. The answer is correct for the question of the Gameboy's LCD control register. However, disabling VBlank in the status register does something very different. That doesn't affect anything about the actual operation of the graphics output. Instead, it controls whether an LCD interrupt (int vector $0048) is triggered when VBlank happens. This is one of those superfluous bits of the GB hardware, since there's already a separate VBlank interrupt that's not affected by this bit, and the LCD interrupt is usually used for triggering on a specific LCD line, or on HBlank.
spaceharrier
Posts: 40
Joined: Wed Jan 19, 2022 9:52 am

Re: I have Stupid questions about the vblank signal off the DMG's lcd

Post by spaceharrier »

front panel of the costume is fully assembled, minus some top bezel decal work that I don't really care about right now, ready for halloween, and running games off of a dmg-01 motherboard. I'm finishing up an RS 485 based driver for extending the length of the multi-layer link between two of these.

hopefully by early next year I'll have the cartridge mux working and the back panel made for shoving giant RFID based foam cartridges in and changing the game.

One thing I've noticed when testing my VGA driver was that if I tried some very early-made games, such as the Castlevania adventure, a massive amount of screen tearing occurred. I did not notice it in later games such as super Mario Land 2, and when I tested on a real game boy screen, I observed screen tearing on that as well. I'm guessing some of these early games were very poorly programmed took advantage and of the screens blurry nature to mask the problem.

Another thing I noticed was that the built-in amplifier (to which I could find absolutely no data sheets) of the game boy produces a lot of fuzz. I ended up tapping into the audio by soldering straight onto the dual channel potentiometer of the motherboard. even then if I turn the sound amplifier up I can still hear an unavoidable ringing that I'm guessing is adjust intrinsic to the design the hardware, but it did sound cleaner.
IMG_20231023_120848.jpg
Post Reply