Page 1 of 3

Detecting VBL on 800 in 700-mode

Posted: Fri Sep 13, 2019 7:24 am
by Jo Even
I have written a small program on the 700 that detects VBL by waiting for bit 7 on $e002 (8255 port C) to go low. This works well on the 700, but when I test this on an 800 emulator in 700-mode the code always returns immediately. How do I properly detect VBL on the 800?

Re: Detecting VBL on 800 in 700-mode

Posted: Fri Sep 13, 2019 11:52 am
by hlide
From the service manual, 4D.PC7 (8255) is connected to /VBLN but it is also connected to 8C.A5 (LH0081A - PIO). I suppose there is two ways to read the /VBLN state: from 8255 or from PIO (the one also dealing with printer port).

Re: Detecting VBL on 800 in 700-mode

Posted: Fri Sep 13, 2019 11:54 am
by hlide
Are you sure the issue is not with the emulator?

Re: Detecting VBL on 800 in 700-mode

Posted: Fri Sep 13, 2019 12:34 pm
by Jo Even
I guess it could be an emulator issue, but I find it strange if such an obvious bug has slipped through... I'm using this emulator: https://sourceforge.net/projects/mz800emu/

Edit: Had a (very) quick look at the emulator source, and it's possible that the polarity of the vbl signal has been reversed. I'll test this tonight if time allows.

Re: Detecting VBL on 800 in 700-mode

Posted: Fri Sep 13, 2019 9:58 pm
by hlide
I have the same feeling unless the macro is really active when it gives 0. But that inversion may explain the strange behavior but that would be weird that such a bug exists.

Re: Detecting VBL on 800 in 700-mode

Posted: Sat Sep 14, 2019 9:30 am
by Jo Even
Just tested this, and the problem is not the polarity. The code always returns immediately both when I wait for 0 and 1... Very strange. I'll ask Geir to test it on his real 800.

Re: Detecting VBL on 800 in 700-mode

Posted: Sat Sep 14, 2019 3:25 pm
by hlide
Would it be an issue that you may miss the /VBL even between two polling because the emulator is not running Z80 instructions with the exact timing!? you know, some emulator may run a batch of instructions then pause then resume so the average of cycles is close to 3.5 MHz?

Re: Detecting VBL on 800 in 700-mode

Posted: Sat Sep 14, 2019 7:57 pm
by Jo Even
Well, in that case the code should wait "forever" when I wait for bit 7 to become 1? But it returns immediately regardless of which state I wait for.

Re: Detecting VBL on 800 in 700-mode

Posted: Sat Sep 14, 2019 9:43 pm
by hlide
Huh. VBLN means /VBL which means VBL is active when it is 0, so I supposed you were getting always 1 and never 0. Am I wrong?

Re: Detecting VBL on 800 in 700-mode

Posted: Sun Sep 15, 2019 8:43 am
by hlide
So basically, either your condition jump nor its inverse are taken to loop? The way you say it implies a bad instruction emulation.