ASM: Wait for Vertical Blank
I'm looking for best/accurate wait vb routine. Any examples are welcome :)
|
I do it like this:
Code:
.loop move.l $dff004,d0 |
what does the << in the cmp.l line do?
|
#303<<8 should be a shift 8 bits to the left
303 == $12f, so #$12f<<8 becomes #$12f00 given the initial and.l #$1ff00,d0 basically the comparison is only for bits 33-16 of the value initially read in d0 why this works is a mystery to me, but I assume StingRay knows what he's doing :D By the way, just this morning I was playing around with the exec routines to add my handler to the vertical blank interrupt, is there a lot of difference in performance? I took and modified the code from the HRM, something on the lines of Code:
|
Quote:
Worst you can do is to poll INTREQR VBLANK bit when VBLANK interrupt is enabled. Very unreliable. |
Quote:
Quote:
|
I find
Code:
wait_vb |
Looks perfectly fine to me, and it's both safe for all displays up to 512 scanlines and guaranteed to only run once per frame, as opposed to a single wait that might run several times if the other code in the loop finishes in less than 1 scanline.
I use this, works with any operand like WaitLine D3, #$FF, (A0)+ etc. Code:
WaitLine macro |
Quote:
Code:
.loop move.l $dff004,d0 |
No there's not a whole lot of code that will run in less than 1 scanline, BUT there are a few very good examples that will, and many more things run under WinUAE with JIT and immediate blitter or on a faster system might as well.
Try something like a simple fade to black of a 16 color screen in 12-bit RGB on an 060 and you'll be looking at 1 scanline or less. I'm just saying the check for the MSB switch from 1 to 0 is safe, short, and works for all programmed displays. If people wrote solid code to begin with they wouldn't have to sit in sorry hindsight when their code freaks out on faster systems, and people like you wouldn't have to sit and WHD-fix poor games that won't run on A1200 :) |
Quote:
|
@Leffmann, StingRay - thanks a lot.
Is there any difference between Code:
wait_vb_1 Code:
wait_vb_2 And second ( stupid :) ) question. Is legal to do btst on odd address _custom+vposr+1 ? |
@ Asman - btst when used with mem locations is btst.b so yes, testing bytes at odd mem locations is legal.
I used a btst to an odd mem address (intreqr+1) in my trackloader. |
Quote:
Quote:
Byte writes to custom registers may not work properly with all accelerator models (Blizzard 1260 for example, only to odd or even bytes, if I remember correctly) |
I would avoid waiting for a fixed raster line number. Because if there are interrupts like sound via cia interrupt or also a keyboard handler which uses direct wait for ack, it may tigger not in the following frame or several frames later.
|
Quote:
There is no 100% safe way to wait for vblank if "random" interrupts are enabled. |
Quote:
Quote:
|
Quote:
|
Quote:
|
Quote:
Quote:
Maybe a better way would be to set a flag in the VBI and poll that flag in the mainloop? Disadvantage is that you need a vertical blank interrupt though. |
All times are GMT +2. The time now is 00:08. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.