Polling for splitline

Door norakomi

Paragon (1086)

afbeelding van norakomi

08-06-2020, 20:01

Hi.
I have made an animation scene that works on emulator, but unfortunately crashes on a real machine.
I use 3 splitlines and on my splitlines I change R#18 and the display page.
I think the msx crashes because of my polling code, can anyone see if there is an issue here ?
The scene is in screen 5, and this is how I poll for a splitline:

PollForLine:	;in b-> splitline
	ld	  a,1			            ;set S#1
  di
	out	  ($99),a
	ld	  a,15+128
	out	  ($99),a

  ld    a,b
  out   ($99),a
  ld    a,19+128
  out   ($99),a
  nop             ; don’t access too fast
  nop             ; don’t access too fast
.Poll:
  in    a,($99)      ; poll until line reached, also clears FH bit
  rra
  jp    nc,.Poll

	xor	  a			              ;set S#0
	out	  ($99),a
	ld	  a,15+128
	ei
	out	  ($99),a
  ret
Aangemeld of registreer om reacties te plaatsen

Van Grauw

Ascended (9156)

afbeelding van Grauw

08-06-2020, 20:55

You can’t poll the interrupt flags F, FH and FL. On a real machine the CPU sometimes misses them. The only time you should read the interrupt flags is in an interrupt handler.

This happens because the VDP resets the flag when it is read. When the CPU polls and the VDP raises the flag at exactly the same time, the CPU will read the value without the flag bit set but the VDP will think it’s been read and clear it.

If you want to wait in a split for a few lines later, poll the HR flag in status register 2 and count the lines. If you do not know exactly what line you’re on and you need to wait for a specific line, you’ll have to implement an interrupt handler.

Van norakomi

Paragon (1086)

afbeelding van norakomi

08-06-2020, 21:57

oh. lol... that explains a lot ^__^
thats really good to know, thanx so much for this info !