English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 30 June 2011, 19:43   #1
Djay
breakpointUK.com

Djay's Avatar
 
Join Date: May 2001
Location: Founders System
Age: 42
Posts: 3,089
Send a message via MSN to Djay
AMOS timer/clock?

Fairly noob question i am sure but...

can you create a timer outside of a main loop so for example...

your loop is waiting for joystick inputs (or such like), if the joystick input is positive then some actions occur on screen, however how do you create a counter/clock that isnt effected by the main loop going off a doing something else... i am able to read the timer from the main loop and reset if needed

to put it another way a clock which is running in the background and is not effected by other actions which would slow the counter down?

i hope this makes sense to someone!
Djay is offline  
AdSense AdSense  
Old 30 June 2011, 20:38   #2
Samurai_Crow
Total Chaos forever!

Samurai_Crow's Avatar
 
Join Date: Aug 2007
Location: Ft. Collins, CO USA
Age: 43
Posts: 942
Send a message via Yahoo to Samurai_Crow
I don't see anything in the manual about it but you could always try 'Exec "wait 5 secs" ' to use the AmigaDOS wait command from the CLI. Otherwise, you'll have to directly use timer.device from the 'Dev Open' and 'Dev Close' devices command along with the other devices commands listed in the manual. Using the AmigaDOS wait command would be much easier though.
Samurai_Crow is offline  
Old 30 June 2011, 20:58   #3
Djay
breakpointUK.com

Djay's Avatar
 
Join Date: May 2001
Location: Founders System
Age: 42
Posts: 3,089
Send a message via MSN to Djay
if i wait 5 secs, then that also means i can not detect if the joystick has been moved for 5 seconds

for a really good example of what i mean check out this youtube clip...
[ Show youtube player ]

as you can see there is a counter which ticks down, it is not effected by what is being updated on the screen

now if i am detecting joystick position and updating, lets say some sprites on the screen, then that would effect the count of the clock which would (i imagine) be updated during the main loop?
Djay is offline  
Old 30 June 2011, 23:11   #4
pmc
rebooting...
pmc's Avatar
 
Join Date: Apr 2007
Location: Elsewhere
Posts: 1,595
I know nothing about AMOS or its capabilities so I'm not sure something similar is possible but I used this approach to fade in and fade out vector objects in an intro I did in assembler...

Say your main loop is executed once a frame (ie. once every 50th of a second on a PAL machine) at vertical blank and everything that gets executed by your main loop (checking the joystick, updating the screen, incrememting or decrementing your clock counter etc.) can be completed during the vertical blanking period.

In that case you would be sure that your clock counter would get updated 50 times for every second that passed. You can use that to count time.

That would be one way to wait a set number of seconds without everything else slowing down - just check your counter as part of your main loop and quit or do an action when the counter hits the right value for the amount of time you want to wait.
pmc is offline  
Old 30 June 2011, 23:41   #5
Djay
breakpointUK.com

Djay's Avatar
 
Join Date: May 2001
Location: Founders System
Age: 42
Posts: 3,089
Send a message via MSN to Djay
so lets say... i need to update everything on every loop frame by frame, including the clock (timer)... i just need to get the frame (loop) to hold (wait) for one second


the kinda makes sense


awesome... just tried it out and it works great! i never thought before of treating each loop as a frame before... i would normally pack loads of stuff into a single set of instructions outside of the mainloop and the waits would be screwed

Last edited by Djay; 30 June 2011 at 23:57.
Djay is offline  
Old 29 December 2011, 22:24   #6
Retro1234
Bo Bo

Retro1234's Avatar
 
Join Date: Jun 2006
Location: 5150
Posts: 3,814
Quote:
Originally Posted by Samurai_Crow View Post
Otherwise, you'll have to directly use timer.device from the 'Dev Open' and 'Dev Close' devices command along with the other devices commands listed in the manual.
Do you realy think this possible? What about a smaller measurment like milliseconds?

Last edited by Retro1234; 30 December 2011 at 01:57.
Retro1234 is offline  
Old 30 December 2011, 19:50   #7
Samurai_Crow
Total Chaos forever!

Samurai_Crow's Avatar
 
Join Date: Aug 2007
Location: Ft. Collins, CO USA
Age: 43
Posts: 942
Send a message via Yahoo to Samurai_Crow
I think Timer.device's granularity was the same as the screen blank interrupts so just using Wait VBL repeatedly should do the job just as well.
Samurai_Crow is offline  
Old 30 December 2011, 21:51   #8
Anakirob
Unregistered User
Anakirob's Avatar
 
Join Date: Nov 2005
Location: Tasmania
Age: 35
Posts: 858
Djay:I don't think treating each loop as a frame is such a good idea at all, as this will only work if the code within the mainloop takes less than one frame.

And using the timer device would be a good idea for an application, or turn based game. But if timing is critical then it could be a bit slow.

Sounds to me like you want to attach your timer to the vertical blank interrupt (interrupt 5), so this piece of code is executed whenever the system performs a vertical blank.Take a look at this thread where a similar concept is discussed.

And you could surely put some joystick polling routines in the code attached to the interrupt too if you want to be sure that any joystick movments are registered even if the mainloop is not up to the point in the code where movements are of signifigance. Just remember to reset them in your mainloop once you're done with them.

Last edited by Anakirob; 30 December 2011 at 21:58.
Anakirob is offline  
AdSense AdSense  
 


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
f/s Amiga Amos Programming books / Disks / Easy Amos & other Books *mega collection!* fitzsteve MarketPlace 4 23 May 2012 05:35
Using timer.device in C (VBCC) DBAlex Coders. General 2 28 June 2011 23:10
First timer with Win UAE-how to get ROMS? RMK support.WinUAE 6 28 January 2011 22:44
Old timer, new member ! cyberknight Member Introductions 14 23 May 2009 12:07
Where's the amos.library on the 3-disk AMOS set? andreas support.Apps 0 15 November 2001 17:04

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 17:34.


Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Page generated in 0.15146 seconds with 12 queries