aboutsummaryrefslogtreecommitdiff
path: root/console.s
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2021-05-21 03:03:33 -0400
committerB. Watson <yalhcru@gmail.com>2021-05-21 03:03:33 -0400
commit8c8c219d3e5bf4f2c0af74528de21ebe7783743b (patch)
tree38c1f88330b631c676f121af3b8972fadab1464b /console.s
parentc3674c25db53023c65864894bd1b9488e070e1f4 (diff)
downloadtaipan-8c8c219d3e5bf4f2c0af74528de21ebe7783743b.tar.gz
Save 5 bytes, now 8974
Diffstat (limited to 'console.s')
-rw-r--r--console.s34
1 files changed, 26 insertions, 8 deletions
diff --git a/console.s b/console.s
index 70cffe3..3d43dc1 100644
--- a/console.s
+++ b/console.s
@@ -353,7 +353,7 @@ _set_orders:
done1:
rts
-; extern void __fastcall__ print_score_msg(long *scoreptr)
+; extern void __fastcall__ print_score_msg(long score)
; asm replacement for this C code:
@@ -363,13 +363,31 @@ done1:
; else if(score < 100)
; print_msg(M_land_based_job);
-; This turns out to actually waste 3 bytes: my code is the same
-; length as what cc65 generates, plus 3 bytes for the jsr to this
-; function. Ugh.
-
-;; .import _M_stay_on_shore, _M_land_based_job
-;; .export _print_score_msg
-;;_print_score_msg:
+ .import _M_stay_on_shore, _M_land_based_job
+ .export _print_score_msg
+_print_score_msg:
+ sta FR0
+ lda sreg+1 ; is MSB sign bit set?
+ bpl @notneg
+ lda #<_M_stay_on_shore ; if so, print this message
+ ldx #>_M_stay_on_shore
+@pm:
+ jmp _print_msg
+@notneg: ; else MSB is positive. Is it non-zero?
+ bne done1 ; if non-zero, score is at least 2^24+1, no message
+ txa ; check bits 8-15...
+ ora sreg ; ...and 16-23
+ bne done1 ; if either middle byte is non-zero, score>=256, no message
+ lda FR0 ; here, the top 3 bytes are zero, so check the LSB.
+ cmp #99 ; is it < 100?
+ bcs done1 ; if not, no message. or,
+ lda #<_M_land_based_job ; if so, print this message
+ ldx #>_M_land_based_job
+ bne @pm ; branch always (since message is not in zero page)
+
+;;
+;;
+;;
;; sta FR0
;; stx FR0+1
;; ldy #3