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.


#1 2019-03-19 17:13:08

New member
From: Canada
Registered: 2019-03-19
Posts: 3

Does the screen gets updated line by line?

Reading the references (gbdev wiki and gb programming manual) it's not clear to me when the screen gets updated.

My current understanding is this:

The screen rendering mimics the old CRT screen way - it goes line by line, after every line there is a horizontal blank, and after the last line there is a vertical blank. The video memory can be accessed (I assume read and write from CPU) mostly during these blank periods -> this leaves me think that when rendering the 1..144 lines, each line can read the vmem+oam for that line specifically. So this would mean that in line 2 there might be different tiles/sprites will be printed than in line 1.
Also - on a line print - as far as I understand - all 3 part are printed at the same line scan (background + window + sprites).

Is this accurate?



#2 2019-03-19 19:40:44

Registered: 2017-03-21
Posts: 45

Re: Does the screen gets updated line by line?

I think for the most part, the answer is yes to your question.

There is some added complexity at the line level though. For example there are some games and demoscene demos that modify the state mid line.

A couple of good examples are:
Prehistorik Man -
Toggling palette mid scanline during the intro to draw the large scrolling text.
Demotronic 1000000 boys -
Changing the background positions mid line to do horizontal line effects.

I think this thread has a lot of good information on the really deep details on gameboy LCD. … mp;t=16612



#3 2019-03-19 20:57:50

From: Somewhere in Echo RAM
Registered: 2017-04-18
Posts: 160

Re: Does the screen gets updated line by line?

The screen does render in a CRT way. The way it works at its deepest is using a pixel FIFO (a queue, if you prefer). The FIFO is filled every time it's needed (once every 8 pixels, also when sprites need to be taken into account, and so on).
Each scanline is rendered in the following way:

During Mode 2, OAM is searched to pick the 10 sprites that will be rendered on this scanline.
During Mode 3, the FIFO is first filled with BG tiles, then shifted according to the lower 3 bits of SCX ("fine scrolling"). Then, pixels are shifted out, and once the FIFO has only 8 pixels remaining, a tile row is fetched to fill 8 more pixels. The process repeats, and may be interrupted by the window, which more or less restarts the whole process but fetching WIN tiles instead. The palette is applied to each pixel when it's shifted out.
Mode 0 is the time left until the following Mode 2 starts - different things during Mode 3 (initial SCX shifting, sprites, and the window) can cause the FIFO to stall while something else completes, so that extra time is taken from Mode 0.

Parameters are sampled at different times and in different ways: for example, BGP (and OBP0 and OBP1) are sampled each time a pixel is pushed; SCY and LCDC are sampled each time a tile is fetched, SCX is sampled in a complex way.
You can reliably change anything between scanlines and it'll work intuitively (except maybe OAM DMA), but there are also things you can change mid-scanline to produce complex effects. I can provide further information if you're interested.

The French Lord Of Laziness.
Legend of Zelda and Undertale fan, I also tend to break Pokémon R/B/Y a little too much.

Twitter | Me on GCL | Discord : ISSOtm#9015 | Skype : (I don't login anymore)



#4 2019-03-23 21:08:53

New member
From: Canada
Registered: 2019-03-19
Posts: 3

Re: Does the screen gets updated line by line?

That helps thanks so much @ISSOtm! And thanks for the references @ssjason123!



Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson