atrtimer.s, vic20timer.s: use decimal mode in interrupt handler

Using decimal mode (SED/CLD) reduces the memory footprint and execution time
of the interrupt routine. Some comments were added or fixed, too.
This commit is contained in:
Christian Groessler 2017-09-24 02:26:40 +02:00
parent 2685d01fe5
commit 7652194703
2 changed files with 18 additions and 44 deletions

View File

@ -83,7 +83,7 @@ timer_read:
ldax current_time_value
rts
; tick over the current timer value - should be called 60 times per second
; tick over the current timer value - should be called 50 or 60 times per second, depending on the TV system
; inputs: none
; outputs: none (all registers preserved, but carry flag can be modified)
timer_vbl_handler:
@ -97,28 +97,15 @@ timer_vbl_handler:
: inc current_jiffies
lda current_jiffies
cmp timer_freq ; full second?
bne @done
lda #0
bne @done ; no, we're done
lda #0 ; yes, increment "seconds" counter
sta current_jiffies
inc current_seconds
; we don't want to mess around with decimal mode in an IRQ handler
lda current_seconds
cmp #$0a
bne :+
lda #$10
: cmp #$1a
bne :+
lda #$20
: cmp #$2a
bne :+
lda #$30
: cmp #$3a
bne :+
lda #$40
: cmp #$4a
bne :+
lda #$50
: cmp #$5a
sed
clc
lda #$01
adc current_seconds
cld
cmp #$60
bne :+
lda #$00
: sta current_seconds

View File

@ -68,29 +68,16 @@ timer_vbl_handler:
inc current_time_value+1
: inc current_jiffies
lda current_jiffies
cmp #60
bne @done
lda #0
cmp #60 ; full second?
bne @done ; no, we're done
lda #0 ; yes, increment "seconds" counter
sta current_jiffies
inc current_seconds
; we don't want to mess around with decimal mode in an IRQ handler
lda current_seconds
cmp #$0a
bne :+
lda #$10
: cmp #$1a
bne :+
lda #$20
: cmp #$2a
bne :+
lda #$30
: cmp #$3a
bne :+
lda #$40
: cmp #$4a
bne :+
lda #$50
: cmp #$5a
sed
clc
lda #$01
adc current_seconds
cld
cmp #$60
bne :+
lda #$00
: sta current_seconds