Detecting VBL on 800 in 700-mode

Jo Even
Site Admin
Posts: 152
Joined: Wed Jan 17, 2018 9:28 pm

Detecting VBL on 800 in 700-mode

Post 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?
hlide
Posts: 681
Joined: Thu Jan 25, 2018 9:31 pm

Re: Detecting VBL on 800 in 700-mode

Post 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).
hlide
Posts: 681
Joined: Thu Jan 25, 2018 9:31 pm

Re: Detecting VBL on 800 in 700-mode

Post by hlide »

Are you sure the issue is not with the emulator?
Jo Even
Site Admin
Posts: 152
Joined: Wed Jan 17, 2018 9:28 pm

Re: Detecting VBL on 800 in 700-mode

Post 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.
hlide
Posts: 681
Joined: Thu Jan 25, 2018 9:31 pm

Re: Detecting VBL on 800 in 700-mode

Post 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.
Jo Even
Site Admin
Posts: 152
Joined: Wed Jan 17, 2018 9:28 pm

Re: Detecting VBL on 800 in 700-mode

Post 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.
hlide
Posts: 681
Joined: Thu Jan 25, 2018 9:31 pm

Re: Detecting VBL on 800 in 700-mode

Post 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?
Jo Even
Site Admin
Posts: 152
Joined: Wed Jan 17, 2018 9:28 pm

Re: Detecting VBL on 800 in 700-mode

Post 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.
hlide
Posts: 681
Joined: Thu Jan 25, 2018 9:31 pm

Re: Detecting VBL on 800 in 700-mode

Post 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?
hlide
Posts: 681
Joined: Thu Jan 25, 2018 9:31 pm

Re: Detecting VBL on 800 in 700-mode

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