aboutsummaryrefslogtreecommitdiff
path: root/dla.s
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2022-10-25 02:29:09 -0400
committerB. Watson <urchlay@slackware.uk>2022-10-25 02:29:09 -0400
commitf1c630523239c550dc920eb14ab4652da7ca4343 (patch)
tree28a5fe7038bff3a06040350c3fc5e485df95ff1c /dla.s
parentaea79e6aaf2cf9790c8cc07c7d8aba3c85aa7819 (diff)
downloaddla-asm-f1c630523239c550dc920eb14ab4652da7ca4343.tar.gz
Fix PAL/NTSC divisor
Diffstat (limited to 'dla.s')
-rw-r--r--dla.s39
1 files changed, 24 insertions, 15 deletions
diff --git a/dla.s b/dla.s
index a031fe4..94cd4f1 100644
--- a/dla.s
+++ b/dla.s
@@ -239,11 +239,11 @@ main_done:
; print menu
ldx #menulen
-blloop:
+menuloop:
lda menumsg,x
sta textbuf,x
dex
- bpl blloop
+ bpl menuloop
; calculate and print elapsed time in minutes. our only use of
; the floating point ROM routines.
@@ -268,28 +268,40 @@ blloop:
sta FR0
jsr IFP ; ...ok, now:
jsr FADD ; add the high bytes in jiffies, result in FR0 again
+
; we now have the 3-byte jiffy count in FR0.
- ; 3600 NTSC jiffies = 1 minute, so divide.
- ldx #<fp3600
- ldy #>fp3600
- jsr FLD1R ; FR1 = 3600.0
- lda PAL ; are we on a PAL Atari?
+ ; 3600 NTSC jiffies or 3000 PAL jiffies = 1 minute, so divide.
+ ; floating point constants:
+ ; 3600.0 is $41,$36,$00,$00,$00,$00
+ ; 3000.0 is $41,$30,$00,$00,$00,$00
+ lda #$41 ; excess-64 base-100 exponent and sign (bit 7 = 0 means positive)
+ sta FR1
+ ldx #$36 ; NTSC
+ lda PAL
and #$0e
- bne ntsc ; no, use constant as-is
- lda #$30 ; yes, adjust (3000 PAL jiffies/sec)
- sta FR0+1
+ bne ntsc
+ ldx #$30 ; PAL
ntsc:
+ stx FR1+1
+ lda #0
+ sta FR1+2
+ sta FR1+3
+ sta FR1+4
+ sta FR1+5
jsr FDIV ; FR0 = FR0 / FR1
jsr FASC ; render as ASCII
+ ; Now clean up the output from FASC and copy it to our menu line.
; FASC puts its results at LBUFF ($0580, aka linebuf).
; Unfortunately it can have a leading zero, and the last
; digit has the high bit set (as a terminator). We want only
; 6 characters including the decimal point, which could be e.g.
- ; 1.2345 12.345 123.45 1234.5
+ ; 0.1234 (the 0 will show as a space) or 1.2345 12.345 123.45 1234.5
+ ; Really elegant software would print this as minutes and seconds,
+ ; with tenths of seconds, e.g. 1:23.4. Not that worried about it though.
ldx #$ff
lda linebuf
- cmp #'0' ; skip the leading zero if present
+ cmp #'0' ; skip the leading zero if present (a space will be seen in its place)
bne ascloop
inx
ascloop:
@@ -346,9 +358,6 @@ hang: jmp hang
; TODO: code to save image goes here.
;;; End of main()
- ; floating point constant 3600.0
-fp3600: .byte $41,$36,$00,$00,$00,$00
-
; screen codes for menu
menumsg:
.byte $00,$00,$00 ; 3 digits of minutes