English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. Blitz Basic

 
 
Thread Tools
Old 27 March 2019, 10:09   #1
bloodline
Registered User
 
bloodline's Avatar
 
Join Date: Jan 2017
Location: London, UK
Posts: 433
VWait

Odd question, but does anyone know how VWait works?

If I use it in AMIGA mode, then it works perfectly fine.
If I use it in BLITZ mode, it never returns and the machine remains in a wait state.

-edit- for clarification, this is not a problem with Blitz Basic. It is a problem with my machine, I'm wondering if Blitz uses some kind of copper list hack to wait for the VBL rather installing an IRQ handler or something.

Last edited by bloodline; 27 March 2019 at 10:14.
bloodline is offline  
Old 28 March 2019, 22:01   #2
bloodline
Registered User
 
bloodline's Avatar
 
Join Date: Jan 2017
Location: London, UK
Posts: 433
it seems the offending code is:

Code:
E ce8e0c: 0839 0000 00df f005 : btst    #$0, $dff005.l
E ce8e14: 6700 fff6                  : beq     ce8e0c
Now to figure out how to handle it

-edit- actually quite simple, 0xDFF005 is the low byte of vposr, so Blitz is waiting for the vpos to reset, not entirely sure why it does that.

Last edited by bloodline; 29 March 2019 at 01:35.
bloodline is offline  
Old 07 April 2019, 12:05   #3
earok
Registered User
 
Join Date: Dec 2013
Location: Auckland
Posts: 3,543
With SetInt 5 you can define your own custom VBlank handler, I'm assuming Blitz doesn't use an Interrupt handler for VWait since it may interfere with whatever you've put in SetInt 5.

It's also possible to do this

Code:
SetInt 5
 Interrupted = true
Endif

While Interrupted=false
Wend
earok is offline  
Old 07 April 2019, 12:43   #4
bloodline
Registered User
 
bloodline's Avatar
 
Join Date: Jan 2017
Location: London, UK
Posts: 433
Quote:
Originally Posted by earok View Post
With SetInt 5 you can define your own custom VBlank handler, I'm assuming Blitz doesn't use an Interrupt handler for VWait since it may interfere with whatever you've put in SetInt 5.

It's also possible to do this

Code:
SetInt 5
 Interrupted = true
Endif

While Interrupted=false
Wend
Hey there! Thanks for replying.

This is a pretty nice idea, but I needed to know what the command was doing as it was highlighting a bug in the Amiga Emulator I’m writing.

As you can see, I found that Vwait actually busy waits for the vposr register to clear the lowest bit. I’m not 100% sure why it does that (I can think of a few reasons, but none compelling), but upon fixing my Emulator to ensure the bit is cleared properly with each new frame, vwait works as it should.
bloodline is offline  
Old 07 April 2019, 12:52   #5
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,368
I wonder if it uses different code for Blitz mode and Amiga mode maybe? The manual states that VWait should be used differently between the two modes. If so, busy waiting in Blitz mode is probably the simplest implementation, though I don't know why an interrupt-driven solution wouldn't be used for both.
Daedalus is offline  
Old 07 April 2019, 13:05   #6
bloodline
Registered User
 
bloodline's Avatar
 
Join Date: Jan 2017
Location: London, UK
Posts: 433
Quote:
Originally Posted by Daedalus View Post
I wonder if it uses different code for Blitz mode and Amiga mode maybe? The manual states that VWait should be used differently between the two modes. If so, busy waiting in Blitz mode is probably the simplest implementation, though I don't know why an interrupt-driven solution wouldn't be used for both.
At a guess, Amiga Mode uses graphics.library waitTOF() to ensure multitasking friendliness
bloodline is offline  
Old 07 April 2019, 13:07   #7
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,368
Yeah, probably. In Blitz mode, there's no multitasking to care about so busy-looping is "acceptable".
Daedalus is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 13:52.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.10058 seconds with 14 queries