emailler/ip65/timer.s

61 lines
1.6 KiB
ArmAsm
Raw Normal View History

2013-12-13 21:24:03 +00:00
; timer routines
;
; the timer should be a 16-bit counter that's incremented by about
; 1000 units per second. it doesn't have to be particularly accurate,
; if you're working with e.g. a 60 Hz VBLANK IRQ, adding 17 to the
; counter every frame would be just fine.
;
; this is generic timer routines, machine specific code goes in drivers/<machinename>timer.s
.include "../inc/common.inc"
2013-12-13 21:24:03 +00:00
.export timer_timeout
.import timer_read
2013-12-13 21:24:03 +00:00
.bss
2013-12-13 21:24:03 +00:00
time: .res 2
2013-12-13 21:24:03 +00:00
.code
; check if specified period of time has passed yet
; inputs: AX - maximum number of milliseconds we are willing to wait for
; outputs: carry flag clear if timeout occured, set otherwise
2013-12-13 21:24:03 +00:00
timer_timeout:
pha
2013-12-13 21:24:03 +00:00
txa
pha
jsr timer_read
stax time
pla
tax
pla
sec ; subtract current value
sbc time
txa
sbc time + 1
rts ; clc = timeout, sec = no timeout
2013-12-13 21:24:03 +00:00
; -- LICENSE FOR timer.s --
2013-12-13 21:24:03 +00:00
; The contents of this file are subject to the Mozilla Public License
; Version 1.1 (the "License"); you may not use this file except in
; compliance with the License. You may obtain a copy of the License at
; http://www.mozilla.org/MPL/
;
2013-12-13 21:24:03 +00:00
; Software distributed under the License is distributed on an "AS IS"
; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
; License for the specific language governing rights and limitations
; under the License.
;
2013-12-13 21:24:03 +00:00
; The Original Code is ip65.
;
2013-12-13 21:24:03 +00:00
; The Initial Developer of the Original Code is Jonno Downes,
; jonno@jamtronix.com.
; Portions created by the Initial Developer are Copyright (C) 2009
; Jonno Downes. All Rights Reserved.
2013-12-13 21:24:03 +00:00
; -- LICENSE END --