18 July 2020, 00:40 | #1 |
Registered User
Join Date: Mar 2010
Location: Napoli, Italia
Posts: 76
|
Busy wait for screen lines
Hello, consider this code (adapted from an exercise I'm doing - I can provide the real source if needed):
Code:
; Wait for line 100 loop1: move.l $dff004,D0 lsr.l #8,D0 and.w #%111111111,D0 cmp.w #100,D0 bne.s loop1 ; Wait for line 310 loop2: move.l $dff004,D0 lsr.l #8,D0 and.w #%111111111,D0 cmp.w #310,D0 bne.s loop2 ; Do something and repeat forever bsr do_something bra loop1 Why is this? |
18 July 2020, 00:58 | #2 | |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 54
Posts: 4,491
|
Quote:
If it is a very fast routine it can also be performed twice in the same video line. |
|
18 July 2020, 09:21 | #3 | |
Registered User
Join Date: Oct 2017
Location: Sunderland, England
Posts: 2,702
|
Quote:
This is something that can trip you up if you don't understand the video beam properly. I would suggest you watch the first 4 minutes of the video below: [ Show youtube player ] The Amiga can track the 312 vertical PAL lines but you also have the horizontal time it takes to get from one line to the next. As Ross says your routine is probably executing twice on the same line because your loop is checking if it present on the same line. If you want to fix it, then check you have reached a line (which you have), then you can either wait for the beam to reach a horizontal position on the line or wait until you reach a VPOS that is different to the one you are currently on. This tripped me up on one Bomb Jack Beer Edition where the round start sequence moved faster on AGA machines. Geezer |
|
18 July 2020, 11:21 | #4 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 54
Posts: 4,491
|
There is also another reason why I ALWAYS advise against doing such a single check.
Nobody assures you that your code can be executed on that line! Okay, no problem in a test program, but when does the program get complex? When do you have IRQs arriving at unpredictable moments (like a CIA timed IRQ) and it use all the line time? You risk failing because, for your check code, this line is never existed and, for the frame, code is skipped... So always do a cross check and not for Z but for different conditions. |
18 July 2020, 11:28 | #5 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,355
|
I would personnally never do an equality check for a scan line, but a check for greater than. This alone can eliminate a lot of troubles.
|
18 July 2020, 12:17 | #6 |
Registered User
Join Date: Mar 2010
Location: Napoli, Italia
Posts: 76
|
Thanks for all your advice. I know that the code I posted is blasphemy, but I had to understand.
The BNE was the problem! |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Upgraded WHD load, now black screen with white lines?! | dabbler | project.WHDLoad | 12 | 14 February 2020 22:33 |
Repeating vertical lines on screen on A2000 with ScanPlus ECS scandoubler | 5kb | support.Hardware | 3 | 03 January 2020 03:55 |
Busy Waiting or avoiding it | Nightshft | Coders. Blitz Basic | 7 | 03 November 2019 19:21 |
Drawing lines off the screen | h0ffman | Coders. Asm / Hardware | 7 | 23 August 2014 01:22 |
stingray being busy | extralife | request.Demos | 30 | 08 January 2013 16:44 |
|
|