Page 1 of 1

VBLANK

Posted: Tue Nov 02, 2021 9:44 am
by mz-80a
Hi,

Something that's always confused me. Is it better to do this:

Code: Select all

LOOP: LD A,($0E002)
RLA
JR C,LOOP
Or:

Code: Select all

LOOP1: LD A,($E002)
RLA
JR NC,LOOP
LOOP2: LD A,($E002)
RLA
JR C,LOOP2
Before drawing to the screen (for stable graphics) ?

Re: VBLANK

Posted: Tue Nov 02, 2021 5:49 pm
by hlide
The first waits for /VBLK (a BLANK signal, not a SYNC!) to be active to exit the loop.

The second not only waits for /VBLK to be active but it then waits for /VBLK to be deactivated. A vertical blank period is very long. So you're loosing a lot of opportunity to do something during that very long blank.

The first is enough if you're sure that your frame will always end before the next /VBLK. The second will help to fit the next frame every vertical blank ending. It could also be needed when you need to grab the first /BLNK of the visible line to do graphics tricks (only MZ-700 or later).

On MZ-700, a vertical blank lasts 7,1738ms!
VsyncChecker.jpg

Re: VBLANK

Posted: Thu Nov 04, 2021 10:00 am
by mz-80a
Thanks! Ok, so the 1st option is enough to create flicker-free sprite graphics (even on MZ-80) ?

Re: VBLANK

Posted: Thu Nov 04, 2021 3:32 pm
by hlide
It should be.

Re: VBLANK

Posted: Thu Nov 04, 2021 6:22 pm
by mz-80a
Excellent. With that check, you are then in the period of time when the beam is travelling from the bottom of the screen back up to the top. That's also correct? So that small amount of time is the time you have to push new data to VRAM.

Re: VBLANK

Posted: Thu Nov 04, 2021 6:27 pm
by mz-80a
Also, it's interesting that the MZ-80K Monitor has this:
vblank_80k.png

Re: VBLANK

Posted: Thu Nov 04, 2021 6:56 pm
by hlide
In the case of MZ-700, you have 312 lines: 200 are visible, 112 are black (ironically they are called blank). If I'm not wrong the /SYN pulse will indicate the frame change (and probably the same period as /SYN for the beam to get back to left top), so you'll get a part of last lines in the previous frame to be blank and the rest of blank lines in the next frame because the first visible line don't start at very first line of the screen: you'll get a visible area more or less centered in the screen and a black border.

For MZ-80 K or A, I don't have all the information but it would be similar.