VBLANK

Post Reply
User avatar
mz-80a
Posts: 295
Joined: Thu Jan 25, 2018 10:46 am
Location: Devon, UK
Contact:

VBLANK

Post 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) ?
MZ-80A Secrets
https://mz-80a.com/

Sharpworks (Sharp MZ homebrew)
http://mz-sharpworks.co.uk/
hlide
Posts: 602
Joined: Thu Jan 25, 2018 9:31 pm

Re: VBLANK

Post 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
User avatar
mz-80a
Posts: 295
Joined: Thu Jan 25, 2018 10:46 am
Location: Devon, UK
Contact:

Re: VBLANK

Post by mz-80a »

Thanks! Ok, so the 1st option is enough to create flicker-free sprite graphics (even on MZ-80) ?
MZ-80A Secrets
https://mz-80a.com/

Sharpworks (Sharp MZ homebrew)
http://mz-sharpworks.co.uk/
hlide
Posts: 602
Joined: Thu Jan 25, 2018 9:31 pm

Re: VBLANK

Post by hlide »

It should be.
User avatar
mz-80a
Posts: 295
Joined: Thu Jan 25, 2018 10:46 am
Location: Devon, UK
Contact:

Re: VBLANK

Post 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.
MZ-80A Secrets
https://mz-80a.com/

Sharpworks (Sharp MZ homebrew)
http://mz-sharpworks.co.uk/
User avatar
mz-80a
Posts: 295
Joined: Thu Jan 25, 2018 10:46 am
Location: Devon, UK
Contact:

Re: VBLANK

Post by mz-80a »

Also, it's interesting that the MZ-80K Monitor has this:
vblank_80k.png
MZ-80A Secrets
https://mz-80a.com/

Sharpworks (Sharp MZ homebrew)
http://mz-sharpworks.co.uk/
hlide
Posts: 602
Joined: Thu Jan 25, 2018 9:31 pm

Re: VBLANK

Post 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.
Post Reply