|
Subject: [stella] Short BCD time routine From: Jim Nitchals <jimn8@xxxxxxxxxx> Date: Fri, 3 Oct 1997 10:58:47 -0700 (PDT) |
If the adds/subtracts and compares are wound into a loop, it's shorter.
Slower? Yes, but it'd be done in vblank time anyway.
ldx #5 ; years, months, days, hours, minutes, seconds for example
; yes, months are fixed at 30 days apiece.
sed
loop:
lda time,x
clc
adc #1
sta time,x
sec
sbc time_max,x
bne loop_end
sta time,x
dex
bpl loop
loop_end:
cld
and the table:
time_max:
dc.b $99,$12,$30,$24,$60,$60 ; max. years, months, etc.
If you prefer a decrementing time count, just rewrite a little:
ldx #5
sed
loop:
lda time,x
sec
sbc #1
sta time,x
bcs loop_end
lda time_max,x
sta time,x
dex
bpl loop
loop_end:
cld
and the table changes to:
time_max:
dc.b $99,$11,$29,$23,$59,$59
as the values cycle downward from time_max to 0.
--
Archives updated once/day at http://www.biglist.com/lists/stella/archives/
Unsubscribing and other info at http://www.biglist.com/lists/stella/stella.html
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [stella] Who can we contact?, Omar Thameen | Thread | [stella] 2600 Digital Clock (Demo 1, CRACKERS |
| Re: [stella] Does this look right? , Erik Mooney | Date | [stella] 2600 Digital Clock (Demo 1, CRACKERS |
| Month |