2000-07-25 20:06:34 +00:00
|
|
|
;
|
2001-11-05 23:52:19 +00:00
|
|
|
; Piotr Fusik, 04.11.2001
|
|
|
|
; originally by Ullrich von Bassewitz and Sidney Cadot
|
2000-07-25 20:06:34 +00:00
|
|
|
;
|
|
|
|
; clock_t clock (void);
|
|
|
|
; unsigned _clocks_per_sec (void);
|
|
|
|
;
|
|
|
|
|
2001-11-05 23:52:19 +00:00
|
|
|
.export _clock, __clocks_per_sec
|
2000-07-25 20:06:34 +00:00
|
|
|
.importzp sreg
|
|
|
|
|
|
|
|
.include "atari.inc"
|
|
|
|
|
|
|
|
|
|
|
|
.proc _clock
|
|
|
|
|
2001-11-05 23:52:19 +00:00
|
|
|
ldx #5 ; Synchronize with Antic, so the interrupt won't change RTCLOK
|
|
|
|
stx WSYNC ; while we're reading it. The synchronization is done same as
|
|
|
|
@L1: dex ; in SETVBLV function in Atari OS.
|
|
|
|
bne @L1
|
|
|
|
stx sreg+1 ; Byte 3 is always zero
|
|
|
|
lda RTCLOK+2
|
2000-07-25 20:06:34 +00:00
|
|
|
ldx RTCLOK+1
|
2001-11-05 23:52:19 +00:00
|
|
|
ldy RTCLOK
|
|
|
|
sty sreg
|
2000-07-25 20:06:34 +00:00
|
|
|
rts
|
|
|
|
|
|
|
|
.endproc
|
|
|
|
|
|
|
|
|
|
|
|
.proc __clocks_per_sec
|
|
|
|
|
2001-11-05 23:52:19 +00:00
|
|
|
lda PAL ; use hw register, PALNTS is only supported on XL/XE ROM
|
|
|
|
and #$0e
|
|
|
|
bne @NTSC
|
|
|
|
tax
|
|
|
|
lda #50
|
|
|
|
rts
|
|
|
|
@NTSC: ldx #0
|
2000-07-25 20:06:34 +00:00
|
|
|
lda #60
|
2001-11-05 23:52:19 +00:00
|
|
|
rts
|
2000-07-25 20:06:34 +00:00
|
|
|
|
|
|
|
.endproc
|