Ultimate Amiga

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Timing in miliseconds  (Read 3351 times)

0 Members and 1 Guest are viewing this topic.

Yarc

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 4
Timing in miliseconds
« on: September 06, 2013, 05:07:10 PM »

Hi, after many years I have got myself an A1200 and tinkering with AMOS Pro.  It's a great diversion from my current job as a C# developer.  I am very rusty with AMOS after such a long time, and to be honest never an expert with AMOS.  I would like to create a timing routine that can measure in milliseconds but struggling to see how this can be done.  I know I need to use the Dev Open command to open the "timer.device" and make use of the Struc and probably Equ commands.  I have looked through the AMOSPro_System_Equates file and found references to various timer entries such as UNIT_MICROHZ, TR_GETSYSTIME, but don't fully understand how I need to use these.  Can anybody shed some light?  Thanks.
 
Logged

SamuraiCrow

  • compile-time wierdo
  • Forum Mod
  • A1200
  • *****
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 946
  • Compile-time wierdo
Re: Timing in miliseconds
« Reply #1 on: September 06, 2013, 08:52:48 PM »

It actually doesn't matter because regardless of the settings you put into Timer.device, it always syncs to the screen refresh rate.

If you really need advanced timing routines, you'll have to use a complex interface adapter chip (CIA) which has much more precise timing.  As for how you'd do it with AmosPro?  I'm not sure, apart from writing inline Assembly code.
Logged

Yarc

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 4
Re: Timing in miliseconds
« Reply #2 on: September 07, 2013, 09:59:14 AM »

Thanks SamuraiCrow for your reply.  I have seen a small C program which accesses the timer.device to count in milliseconds and it looks like I should be able to replicate the code with Dev open command etc., but maybe as you say, this just isn't possible with Amos basic pro.  Thanks anyway.
Logged

SamuraiCrow

  • compile-time wierdo
  • Forum Mod
  • A1200
  • *****
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 946
  • Compile-time wierdo
Re: Timing in miliseconds
« Reply #3 on: September 07, 2013, 04:58:38 PM »

If you use an NTSC version of the Amiga, the milliseconds count will always be an even multiple of 1/60th of a second.  Otherwise (PAL or SECAM) it will be 1/50th of a second.  Those are the only 2 native video scan rates supported by the Timer.device code as a time base on a Classic Amiga.
Logged

Yarc

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 4
Re: Timing in miliseconds
« Reply #4 on: September 07, 2013, 08:01:46 PM »

I understand that this would be the timing for updating graphics, but what if I just want to time routines for testing performance of code?
Logged

SamuraiCrow

  • compile-time wierdo
  • Forum Mod
  • A1200
  • *****
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 946
  • Compile-time wierdo
Re: Timing in miliseconds
« Reply #5 on: September 09, 2013, 02:41:07 PM »

On a Classic Amiga, you'll get much better timing resolution from a CIA timer.  Follow this link for documentation on its register layout.
Logged

Yarc

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 4
Re: Timing in miliseconds
« Reply #6 on: September 12, 2013, 06:22:32 PM »

Hi SamuraiCrow,  thanks for the link!  I'll take a look.
Logged
Pages: [1]   Go Up
 

TinyPortal 2.2.2 © 2005-2022