From b2f7604ac51db075201ea0aa40d002d3d5e7e071 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Tue, 16 Feb 2016 07:04:56 -0500 Subject: shrink code, 5599 bytes free, move some code so it runs straight from bank 3 in cartridge --- bank2.s | 7 +++++++ bigfloat.s | 6 +++++- cartbank3.cfg | 4 +++- console.s | 7 +++++++ draw_lorcha.s | 7 +++++++ explosion.s | 6 ++++++ portstat.s | 6 +++++- rand.s | 6 ++++++ soundasm.s | 6 ++++++ taipan.c | 56 +++++++++++++++++++++++++------------------------------- timed_getch.s | 6 ++++++ ultostr.s | 6 +++++- 12 files changed, 88 insertions(+), 35 deletions(-) diff --git a/bank2.s b/bank2.s index d700fc5..6f36b38 100644 --- a/bank2.s +++ b/bank2.s @@ -3,4 +3,11 @@ start = $8000 end = $9fff .org start .incbin "splitrom.raw.2" + + .if * > end + .fatal "bank2 code too large" + .else + .out .sprintf("=> %d bytes free in bank 2", end - *) + .endif + .res end-*+1, $ff diff --git a/bigfloat.s b/bigfloat.s index 529de1a..5acbecf 100644 --- a/bigfloat.s +++ b/bigfloat.s @@ -23,7 +23,11 @@ BIG_64K: ; 65535 (2**16-1) in float format. ;BIG_ULONG_MAX: ;.byte $44, $42, $94, $96, $72, $95 - .code + .ifdef CART_TARGET + .segment "HIGHCODE" + .else + .code + .endif ; It seems like fr0_to_fptemp and friends should be using the OS ; FLD* and FST* routines, doesn't it? But look: diff --git a/cartbank3.cfg b/cartbank3.cfg index e50d755..1e6e5cc 100644 --- a/cartbank3.cfg +++ b/cartbank3.cfg @@ -28,8 +28,9 @@ MEMORY { RAM: file = %O, define = yes, start = %S, size = $BC20 - __STACKSIZE__ - __RESERVED_MEMORY__ - %S; TRAILER: file = %O, start = $0000, size = $0006; -# read-only data goes in a cart bank +# read-only data (and some code) goes in a cart bank HIGHDATA: file = "rodata.8000" start = $8000, size = $2000; + } SEGMENTS { EXEHDR: load = HEADER, type = ro; @@ -42,6 +43,7 @@ SEGMENTS { INIT: load = RAM, type = ro, optional = yes; CODE: load = RAM, type = ro, define = yes; RODATA: load = HIGHDATA, type = ro; + HIGHCODE: load = HIGHDATA, type = ro; DATA: load = RAM, type = rw; INITBSS: load = RAM, type = bss, optional = yes; BSS: load = RAM, type = bss, define = yes; diff --git a/console.s b/console.s index 2bbdb04..7be2fb3 100644 --- a/console.s +++ b/console.s @@ -9,6 +9,13 @@ .importzp destptr ; from draw_lorcha.s .import _cspace + .ifdef CART_TARGET + .segment "HIGHCODE" + .else + .code + .endif + + ; void clrtobot(void); ; void clrtoeol(void); ; void clrtoline(unsigned char line); diff --git a/draw_lorcha.s b/draw_lorcha.s index ae82bd2..3cd56ec 100644 --- a/draw_lorcha.s +++ b/draw_lorcha.s @@ -9,6 +9,7 @@ ; libsrc/atari/mul40.s, which is getting linked anyway ; because conio uses it. + .rodata ; offset from start of screen for each ship position (0-9) lorcha_pos_lo: .byte <320, <328, <336, <344, <352 @@ -42,6 +43,12 @@ lorcha_data: damaged_data: .incbin "DAMAGED.DAT" + .ifdef CART_TARGET + .segment "HIGHCODE" + .else + .code + .endif + ; void __fastcall__ flash_lorcha(int which); _flash_lorcha: ldx #$80 diff --git a/explosion.s b/explosion.s index 678e2c0..64747eb 100644 --- a/explosion.s +++ b/explosion.s @@ -32,6 +32,12 @@ .importzp tmp1, tmp2 .import _jsleep + .ifdef CART_TARGET + .segment "HIGHCODE" + .else + .code + .endif + ; how many times the screen will appear to flash. flashes = 3 diff --git a/portstat.s b/portstat.s index a3dab60..fa68b9f 100644 --- a/portstat.s +++ b/portstat.s @@ -19,7 +19,11 @@ screenlen = * - _port_stat_screen screenpages = >screenlen partial = = 1000) return; - // time = ((year - 1860) * 12) + month; - time = get_time(); - amount = randi()%(1000 * (time + 5) / 6) + 500; + amount = gunamt() + 500; if((cash < amount) || (hold < 10)) { return; } - // fancy_numbers(amount, fancy_num); - compradores_report(); cputs("Do you wish to buy a ship's gun\r\nfor "); - // cputs(fancy_num); cprintfancy(amount); cprint_taipan_prompt(); - choice = yngetc(0); - if(choice == 'y') { + if(yngetc(0) == 'y') { cash -= amount; hold -= 10; guns += 1; @@ -876,7 +869,8 @@ int sea_battle(int id, int num_ships) { while(num_ships > 0) { if(damage >= capacity) return 4; - status = 100L - ((damage * 100L / capacity)); + // status = 100L - ((damage * 100L / capacity)); + status = get_ship_status(); /* // I think this is a problem: if(status <= 0) { return 4; @@ -1466,8 +1460,8 @@ unsigned int warehouse_in_use() { void port_stats(void) { - int i, in_use, - status = 100 - ((damage * 100L) / capacity); + int i, in_use, status = get_ship_status(); + // status = 100 - ((damage * 100L) / capacity); /* all the static text that used to be in port_stats() has been moved to mkportstats.c, which creates a .xex file which @@ -2401,7 +2395,7 @@ void li_yuen_extortion(void) { unsigned int i = 2, j = 0; if(time > 12) { - j = randi() % (1000 * time) + (1000 * time); + j = randi() % (2 * (1000 * time)); i = 1; } @@ -3176,7 +3170,7 @@ int main(void) { if(one_chance_in(4)) { if(one_chance_in(2)) new_ship(); - else if (guns < 1000) + else new_gun(); } diff --git a/timed_getch.s b/timed_getch.s index 41b9ecb..510c885 100644 --- a/timed_getch.s +++ b/timed_getch.s @@ -5,6 +5,12 @@ .include "atari.inc" + .ifdef CART_TARGET + .segment "HIGHCODE" + .else + .code + .endif + ; keyboard and timer functions for taipan. ; sleep for j jiffies. diff --git a/ultostr.s b/ultostr.s index 29420e4..e63fd3e 100644 --- a/ultostr.s +++ b/ultostr.s @@ -18,7 +18,11 @@ radix = 10 -.code + .ifdef CART_TARGET + .segment "HIGHCODE" + .else + .code + .endif _ultostr: ; pop the arguments -- cgit v1.2.3