From 2ff01881f4b7f0842a10e3c5ab7991c81f60861d Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Thu, 6 May 2021 12:45:19 -0400 Subject: Save 3 bytes, now 8672 --- console.s | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'console.s') diff --git a/console.s b/console.s index 554b03d..0eb4ab1 100644 --- a/console.s +++ b/console.s @@ -291,17 +291,17 @@ _pluralize: ; the st[] array has elements 0 to 5. 5 is "Perfect" and only ; used when status == 100. _print_status_desc: - lsr - lsr ; now 0-25 - ldx #$ff + lsr ; arg /= 2; // was 0..100, now 0..50 + ldy #$fe ; y = -2; sec -@div5loop: - inx - sbc #5 - bcs @div5loop - txa - asl - tay +@div10loop: ; do { + iny + iny ; y += 2; + sbc #$0a ; arg -= 10; + bcs @div10loop ; } while(arg >= 0); + ; y is now (arg / 20) * 2, one of: 0 2 4 6 8 10 + ; which is exactly what we need to index an array of six + ; 16-bit pointers. lda _st,y ldx _st+1,y jmp _cputs -- cgit v1.2.3