header_2.gif (908 Byte) logo_v1.gif (3356 Byte) header_1.gif (905 Byte)
Pages
TI92
TI89
HowTo
Linking
MXM Programs

Powered by

[ticalc.org]
[levante.de]
[xoom.com]
[listbot.com]
[fastcounter.com]

Page design by DMnow!

In this section we offer some articles, how to program some specific parts of a game or the TI92!
We will add articles, so revisit this section!

How to use the timer in own programs

To use the timer, you first have to set a defined frequency (You don't know the current frequency). I suggest - you have - to set the frequency to $d1 - 30 Hz (30 ticks per second), use port $600016. Now you can use the AutoInt 5 with a counter. There you should use an internal counter, and when this counter is 30, then a second is over. It sounds difficult, but look at the code, it is easy...

;********* VARIABLES
oldTimer       dc.l 0
Time           dc.w 0         ; Your time!
InternCounter  dc.w 0         ; Internal counter
; InstallTimer
; Installs your timer interrupt and sets the right frequency.
InstallTimer:
   move.l  $64+(5-1)*4,oldTimer
   clr.w   InternCounter
   move.l  #TimerInterrupt,$64+(5-1)*4    ; Timer installed!
   move.w  #$d1,($600016)                 ; Set frequency
   rts

; DeinstallTimer
; Removes your timer interrupt, you should call this routine at the end!
DeinstallTimer:
   move.l  oldTimer,$64+(5-1)*4
   rts

TimerInterrupt:
   add.w   #1,InternCounter
   cmp.w   #29,InternCounter              ; Since we start with 0
   beq     ResetInternCounter
   rte
ResetInternCounter:
   ; +1 or -1 of the time
   sub.w   #1,Time
   ;add.w   #1,Time
   clr.w   InternCounter
   rte


So, this was, how you can use the timer.
header_3.gif (882 Byte)
[Back to the top] [Back to the index] [Other HOWTO's]
header_4.gif (881 Byte)