From bd3b540db943c2ffdd246d88af212cfe41511d0f Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Mon, 19 Apr 2021 13:48:30 -0400 Subject: Save 3 bytes --- conio/chline.s | 23 ++++++++++------------- conio/cputc.s | 4 ++-- console.s | 30 ++++++++++++++++++++---------- taipan.c | 15 +++------------ 4 files changed, 35 insertions(+), 37 deletions(-) diff --git a/conio/chline.s b/conio/chline.s index 81cf2e9..5b7ce6c 100644 --- a/conio/chline.s +++ b/conio/chline.s @@ -1,5 +1,5 @@ ; modified for taipan: -; - commented out _chlinexy as taipan never uses it. +; - removed _chlinexy as taipan never uses it. ; - get rid of the check for a 0 argument. taipan only calls chline() ; with constant non-zero args. ; @@ -9,9 +9,9 @@ ; void chline (unsigned char length); ; - .export _chline - .import popa, _gotoxy, cputdirect - .importzp tmp1 + .export _chline, _cspaces + .import cputdirect + .importzp tmp1, tmp2 .ifdef __ATARI5200__ CHRCODE = 14 @@ -19,17 +19,14 @@ CHRCODE = 14 CHRCODE = $12+64 .endif -;_chlinexy: -; pha ; Save the length -; jsr popa ; Get y -; jsr _gotoxy ; Call this one, will pop params -; pla ; Restore the length - +_cspaces: + ldx #0 + .byte $2c _chline: -; cmp #0 ; Is the length zero? -; beq L9 ; Jump if done + ldx #CHRCODE + stx tmp2 sta tmp1 -L1: lda #CHRCODE ; Horizontal line, screen code +L1: lda tmp2 jsr cputdirect ; Direct output dec tmp1 bne L1 diff --git a/conio/cputc.s b/conio/cputc.s index 4e29482..a34217f 100644 --- a/conio/cputc.s +++ b/conio/cputc.s @@ -60,8 +60,8 @@ cputdirect: ; accepts screen code lda COLCRS cmp #40 bcc plot - lda #0 - sta COLCRS + ;lda #0 + ;sta COLCRS .export newline _crlf: diff --git a/console.s b/console.s index 87514a7..d080fe8 100644 --- a/console.s +++ b/console.s @@ -2,8 +2,16 @@ .include "atari.inc" .include "conio/mul40.s" - .export _clrtobot, _clrtoeol, _clr_screen, _clrtoline, _cspaces, _cblank, _cblankto, _backspace, _cprint_pipe, _cprint_bang, _cspace, _cputc_s, _comma_space, _cprint_colon_space, _cprint_question_space, _cprint_period, _cprint_taipan_prompt, _plus_or_space, _gotox0y22, _gotox0y3, _gotox0y, _gotox0y3_clrtoeol,_cputc0, _set_orders, _pluralize, _print_combat_msg + + .export _clrtobot, _clrtoeol, _clr_screen, _clrtoline + .export _cblank, _cblankto, _backspace, _cprint_pipe + .export _cprint_bang, _cspace, _cputc_s, _comma_space + .export _cprint_colon_space, _cprint_question_space + .export _cprint_period, _cprint_taipan_prompt, _plus_or_space + .export _gotox0y22, _gotox0y3, _gotox0y, _gotox0y3_clrtoeol + .export _cputc0, _set_orders, _pluralize, _print_combat_msg .export _rvs_on, _rvs_off + .export _prepare_report, _clear_msg_window .importzp tmp3 ; ditto .import _revflag ; conio/revers.s @@ -12,7 +20,7 @@ .importzp sreg .import _cprintulong, _cputc, _cprint_taipan, _timed_getch, _orders .import _turbo - .import _print_msg + .import _print_msg, _cspaces .ifdef CART_TARGET .segment "HIGHCODE" @@ -94,14 +102,6 @@ _cblankto: bcs _cblank rts -_cspaces: - sta tmp3 -@lp: - jsr _cspace - dec tmp3 - bne @lp - rts - _backspace: dec COLCRS lda #1 @@ -264,6 +264,16 @@ _print_combat_msg: jmp _clrtoeol +; extern void clear_msg_window(void) +; extern void prepare_report(void) +_clear_msg_window: + lda #$12 + .byte $2c +_prepare_report: + lda #$10 + jsr _gotox0y + jmp _clrtobot + ; extern void __fastcall__ pluralize(int num); _pluralize: cmp #1 diff --git a/taipan.c b/taipan.c index 69a7a84..933fd2f 100644 --- a/taipan.c +++ b/taipan.c @@ -731,13 +731,9 @@ void at_sea(void) { cspaces(2); } -/* this bit of code was duplicated a *bunch* of times, - making it a function makes the binary 2K smaller. */ - -void prepare_report(void) { - gotox0y(16); - clrtobot(); -} +/* these were rewritten in asm to save 5 bytes, they live in console.s */ +extern void prepare_report(void); +extern void clear_msg_window(void); void compradores_report(void) { prepare_report(); @@ -751,11 +747,6 @@ void captains_report(void) { print_msg(M_captains_report); } -void clear_msg_window(void) { - gotox0y(18); - clrtobot(); -} - void overload(void) { compradores_report(); // cputs("Your ship is overloaded"); -- cgit v1.2.3