From 8c8c219d3e5bf4f2c0af74528de21ebe7783743b Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Fri, 21 May 2021 03:03:33 -0400 Subject: Save 5 bytes, now 8974 --- console.s | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) (limited to 'console.s') 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 -- cgit v1.2.3