aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2016-02-29 05:42:13 -0500
committerB. Watson <yalhcru@gmail.com>2016-02-29 05:42:13 -0500
commit3cbd137bfaa17bfabbe988c9760b315f865378ca (patch)
treee0a5092abb84aaa96ff3ff886789616ca3ddafa5
parentbe6706ab0b2df53bc1cc9e8492a84698e1fd0f1c (diff)
downloadtaipan-3cbd137bfaa17bfabbe988c9760b315f865378ca.tar.gz
8051 bytes free, we can now run with BASIC present (only 40K required)
-rw-r--r--checkmem.s76
-rw-r--r--console.s64
-rw-r--r--messages.pl4
-rw-r--r--taipan.c122
4 files changed, 154 insertions, 112 deletions
diff --git a/checkmem.s b/checkmem.s
index fedbc25..63f9ed6 100644
--- a/checkmem.s
+++ b/checkmem.s
@@ -1,18 +1,12 @@
; Memcheck needs to do this:
-;1. If RAMTOP is >=$C0, go to step 6.
-;2. Attempt to disable BASIC.
-;3. Write some data to $A000, read it back (do twice with 2 different values)
-;4. If we couldn't read back what we wrote, that means there really is a
-; cartridge plugged in. Go to step 8.
-;5. Set RAMTOP to $C0.
-;6. Do a GRAPHICS 0.
-;7. Exit via RTS, so the rest of the game will load.
-;8. Do a GRAPHICS 0.
-;9. Print a "remove cartridge" message
-;10. Wait for a keypress
-;11. Exit to DOS (without loading the rest of the file)
+;1. Do a GRAPHICS 0
+;2. If RAMTOP >=$A0, go to step 6
+;3. Print "need 40K message"
+;4. Wait for a keypress
+;5. Exit to DOS (without loading the rest of the file)
+;6. Exit via RTS, so the rest of the game will load.
;At no point do we look at RAMSIZ, since it can't be trusted under SDX.
@@ -22,6 +16,7 @@
; cl65 -o checkmem.xex -t none checkmem.s
.include "atari.inc"
+ .macpack atari
start = $0600 ; use page 6 for now
@@ -32,55 +27,26 @@ start = $0600 ; use page 6 for now
.org start
-; message is "Need 48K, remove cartridge" in screen codes.
msg:
- .byte $2e, $65, $65, $64, $00, $14, $18, $2b
- .byte $0c, $00, $72, $65, $6d, $6f, $76, $65
- .byte $00, $63, $61, $72, $74, $72, $69, $64
- .byte $67, $65
+ scrcode "Need at least 40K"
msglen = * - msg - 1
S: .byte "S:",0
init:
-;1. If RAMTOP is >=$C0, go to step 6.
- lda RAMTOP
- cmp #$c0
- bcs ramtop_ok
-
-;2. Attempt to disable BASIC.
-; set bit 1 of PORTB. No effect on 400/800/1200XL. Don't
-; touch any other bits in PORTB!
- lda PORTB
- ora #$02
- sta PORTB
-
-;3. Write some data to $A000, read it back (do twice with 2 different values)
-;4. If we couldn't read back what we wrote, that means there really is a
-; cartridge plugged in. Go to step 8.
- lda #$AA
- sta $A000
- cmp $A000
- bne rom_present
- lsr
- sta $A000
- cmp $A000
- bne rom_present
-
-;5. Set RAMTOP to $C0.
- lda #$c0
- sta RAMTOP
-
-;6. Do a GRAPHICS 0.
-;7. Exit via RTS, so the rest of the game will load.
-ramtop_ok:
- jmp gr_0
-
-;8. Do a GRAPHICS 0.
-rom_present:
+;1. Do a GRAPHICS 0
jsr gr_0
-;9. Print a "remove cartridge" message
+;2. If RAMTOP is >=$A0, go to step 5.
+ lda RAMTOP
+ cmp #$a0
+ bcc memerr
+
+;5. Exit via RTS, so the rest of the game will load.
+ rts
+
+;3. Print a "need 40K" message
+memerr:
lda #<msg
sta FR0
lda #>msg
@@ -93,7 +59,7 @@ msgloop:
dey
bpl msgloop
-;10. Wait for a keypress
+;4. Wait for a keypress
sty CH ; y == $ff at this point, clear keyboard
; ...wait for a keystroke...
wait4key:
@@ -101,7 +67,7 @@ wait4key:
beq wait4key
sty CH ; clear the key so DOS menu won't see it.
-;11. Exit to DOS (without loading the rest of the file)
+;5. Exit to DOS (without loading the rest of the file)
jmp (DOSVEC)
gr_0:
diff --git a/console.s b/console.s
index 05445bd..f8d1c8d 100644
--- a/console.s
+++ b/console.s
@@ -1,7 +1,7 @@
.include "atari.inc"
- .export _clrtobot, _clrtoeol, _clr_screen, _clrtoline, _cspaces, _cblank, _backspace, _cprint_pipe, _cprint_bang, _cspace, _cputc_s, _comma_space, _cprint_colon_space, _cprint_question_space, _cprint_period, _cprint_taipan_prompt, _crlf
+ .export _clrtobot, _clrtoeol, _clr_screen, _clrtoline, _cspaces, _cblank, _backspace, _cprint_pipe, _cprint_bang, _cspace, _cputc_s, _comma_space, _cprint_colon_space, _cprint_question_space, _cprint_period, _cprint_taipan_prompt, _crlf, _plus_or_space, _gotox0y, _cputc0, _set_orders
.export _rvs_on, _rvs_off
.import mul40 ; from cc65's runtime
@@ -10,7 +10,7 @@
.import bump_destptr ; these two are
.importzp destptr ; from draw_lorcha.s
.importzp sreg
- .import _cprintulong, _cputc, _cprint_taipan
+ .import _cprintulong, _cputc, _cprint_taipan, _timed_getch, _orders
.ifdef CART_TARGET
.segment "HIGHCODE"
@@ -195,6 +195,9 @@ _comma_space:
_cspace:
lda #' '
.byte $2c
+_cputc0:
+ lda #'0'
+ .byte $2c
_cprint_pipe:
lda #'|'
.byte $2c
@@ -210,3 +213,60 @@ _cprint_bang:
_crlf:
lda #$9b
jmp _cputc
+
+; extern void plus_or_space(unsigned char b);
+_plus_or_space:
+ tax
+ beq @spc
+ lda #'+' + 128 ; inverse plus
+ .byte $2c
+@spc:
+ lda #' '
+ ldx #39
+ stx COLCRS
+ lda #15
+ stx ROWCRS
+ jmp _cputc
+
+; extern void gotox0y(char y);
+ _gotox0y:
+ sta ROWCRS
+ lda #0
+ sta COLCRS
+ rts
+
+; extern void set_orders(void);
+;_set_orders:
+; jsr _timed_getch
+; ldx _orders
+; cmp #'f'
+; bne @notf
+; ldx #1
+;@notf:
+; cmp #'r'
+; bne @notr
+; ldx #2
+;@notr:
+; cmp #'t'
+; bne @nott
+; ldx #3
+;@nott:
+; stx _orders
+; rts
+
+; extern void set_orders(void);
+_set_orders:
+ jsr _timed_getch
+ ldx #3
+@solp:
+ cmp orders_tbl-1,x
+ beq @returnx
+ dex
+ bne @solp
+ rts
+@returnx:
+ stx _orders
+ rts
+
+ .rodata
+orders_tbl: .byte "frt"
diff --git a/messages.pl b/messages.pl
index 3067eb1..5c7638f 100644
--- a/messages.pl
+++ b/messages.pl
@@ -113,7 +113,7 @@ silk "Silk"
arms "Arms"
gen_cargo "General Cargo"
ellipsis "..."
-at_sea "At sea"
+at_sea " At sea "
hong_kong "Hong Kong"
shanghai "Shanghai"
nagasaki "Nagasaki"
@@ -250,6 +250,8 @@ bank_transfer "Visit bank, Transfer\r\ncargo, "
quit_traging "Quit trading"
or_retire ", or Retire"
what_will_you_name_firm " What will you name your"
+what "What "
+me_to "me to "
spc_you_can_spc " You can "
spc_shall " shall"
spc_afford " afford "
diff --git a/taipan.c b/taipan.c
index 50344f9..2ba23b9 100644
--- a/taipan.c
+++ b/taipan.c
@@ -117,6 +117,10 @@ extern void clrtoeol(void);
/* print 'count' spaces: */
extern void __fastcall__ cspaces(unsigned char count);
+/* same as gotoxy(0, y). replacing all the gotoxy(0, foo) with
+ this saves 208 bytes! */
+extern void __fastcall__ gotox0y(char y);
+
/* each prints one specific character */
extern void crlf(void);
extern void cspace(void);
@@ -124,6 +128,7 @@ extern void cputc_s(void);
extern void cprint_bang(void);
extern void cprint_pipe(void);
extern void cprint_period(void);
+extern void cputc0(void);
/* each print 2 characters */
extern void comma_space(void);
@@ -647,7 +652,7 @@ void cprintfancy_big(bignump b) {
if(rightdigits) {
// cputc('.');
cprint_period();
- if(leading0) cputc('0');
+ if(leading0) cputc0();
// cprintulong((unsigned long)rightdigits);
cprintuchar(rightdigits);
}
@@ -678,20 +683,20 @@ void cprintulong(unsigned long ul) {
void at_sea(void) {
gotoxy(30, 6);
- cspace();
+ // cspace();
rvs_on();
// cputs(location[0]);
print_msg(M_at_sea);
rvs_off();
- cspaces(3);
+ 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) {
- gotoxy(0, 16);
+ gotox0y(16);
clrtobot();
}
@@ -708,7 +713,7 @@ void captains_report(void) {
}
void clear_msg_window(void) {
- gotoxy(0, 18);
+ gotox0y(18);
clrtobot();
}
@@ -724,11 +729,11 @@ void overload(void) {
unsigned int gunamt(void) {
return randi()%(1000 * (get_time() + 5) / 6);
}
+
#ifdef CART_TARGET
# pragma code-name (pop)
#endif
-
void new_ship(void) {
unsigned long amount;
@@ -890,7 +895,7 @@ void cprintfancy(unsigned long num) {
if(tmp) {
// cputc('.');
cprint_period();
- if(tmp < 10L) cputc('0');
+ if(tmp < 10L) cputc0();
cprintulong(tmp);
}
} else {
@@ -919,6 +924,7 @@ void justify_int(unsigned int num) {
if(num < 10) cspace();
cprintuint(num);
}
+
void update_guns() {
rvs_on();
gotoxy(31, 1);
@@ -928,7 +934,7 @@ void update_guns() {
}
void fight_stats(int ships, int orders) {
- gotoxy(0, 0);
+ gotox0y(0);
justify_int(ships);
// cputs(" ship");
@@ -959,13 +965,18 @@ void fight_stats(int ships, int orders) {
/* print an inverse video plus if there are offscreen ships,
or clear it to a space if not. */
+extern void plus_or_space(unsigned char b);
+/*
void plus_or_space(unsigned char b) {
gotoxy(39, 15);
cputc(b ? 0xab : ' ');
// hide_cursor();
}
+*/
char orders = 0;
+extern void set_orders(void);
+/*
void set_orders(void) {
switch(timed_getch()) {
case 'f': orders = 1; break;
@@ -974,6 +985,7 @@ void set_orders(void) {
default: break;
}
}
+*/
#ifdef CART_TARGET
# pragma code-name (pop)
@@ -1042,7 +1054,7 @@ char sea_battle(char id, int num_ships) {
*/
// flushinp();
- gotoxy(0, 3);
+ gotox0y(3);
clrtoeol();
// cputs("Current seaworthiness: ");
@@ -1051,7 +1063,7 @@ char sea_battle(char id, int num_ships) {
cputs(" (");
cprintuchar(status);
cputs("%)");
- gotoxy(0, 4);
+ gotox0y(4);
for(i = 0; i <= 9; i++) {
if (num_ships > num_on_screen) {
@@ -1066,7 +1078,7 @@ char sea_battle(char id, int num_ships) {
plus_or_space(num_ships > num_on_screen);
- gotoxy(0, 16);
+ gotox0y(16);
// cputs("\n");
crlf();
@@ -1075,7 +1087,7 @@ char sea_battle(char id, int num_ships) {
if(orders == 0) {
set_orders();
if(!orders) {
- gotoxy(0, 3);
+ gotox0y(3);
clrtoeol();
cprint_taipan_comma();
// cputs("what shall we do??\n(Fight, Run, Throw cargo)");
@@ -1084,9 +1096,9 @@ char sea_battle(char id, int num_ships) {
while(!orders) set_orders();
- gotoxy(0, 3);
+ gotox0y(3);
clrtoeol();
- gotoxy(0, 4);
+ gotox0y(4);
clrtoeol();
}
}
@@ -1098,14 +1110,14 @@ char sea_battle(char id, int num_ships) {
ok = 3;
ik = 1;
- gotoxy(0, 3);
+ gotox0y(3);
clrtoeol();
// cputs("Aye, we'll fight 'em");
print_msg(M_aye_fight);
cprint_taipan_period();
set_orders();
- gotoxy(0, 3);
+ gotox0y(3);
clrtoeol();
// cputs("We're firing on 'em");
print_msg(M_were_firing);
@@ -1134,7 +1146,7 @@ char sea_battle(char id, int num_ships) {
plus_or_space(num_ships > num_on_screen);
- gotoxy(0, 16);
+ gotox0y(16);
crlf();
do {
@@ -1172,7 +1184,7 @@ char sea_battle(char id, int num_ships) {
jsleep(10);
}
}
- gotoxy(0, 3);
+ gotox0y(3);
clrtoeol();
if(sk > 0) {
// cputs("Sunk ");
@@ -1197,7 +1209,7 @@ char sea_battle(char id, int num_ships) {
num_ships -= ran;
fight_stats(num_ships, orders);
- gotoxy(0, 3);
+ gotox0y(3);
clrtoeol();
cprintuint(ran);
// cputs(" ran away");
@@ -1220,12 +1232,12 @@ char sea_battle(char id, int num_ships) {
}
}
- gotoxy(0, 16);
+ gotox0y(16);
set_orders();
}
} else if ((orders == 1) && (guns == 0)) {
- gotoxy(0, 3);
+ gotox0y(3);
clrtoeol();
// cputs("We have no guns");
print_msg(M_we_have_no_guns);
@@ -1236,7 +1248,7 @@ char sea_battle(char id, int num_ships) {
amount = 0;
total = 0;
- gotoxy(0, 3);
+ gotox0y(3);
// cputs("You have the following on board");
print_msg(M_you_have_on_board);
cprint_taipan_colon();
@@ -1265,7 +1277,7 @@ char sea_battle(char id, int num_ships) {
cprint_colon_space();
cprintulong(hold_[3]);
- gotoxy(0, 6);
+ gotox0y(6);
clrtoeol();
// cputs("What shall I throw overboard");
print_msg(M_what_shall_i_throw);
@@ -1274,7 +1286,7 @@ char sea_battle(char id, int num_ships) {
choice = get_item(1);
if(choice < 4) {
- gotoxy(0, 6);
+ gotox0y(6);
clrtoeol();
// cputs("How much");
print_msg(M_how_much);
@@ -1290,15 +1302,15 @@ char sea_battle(char id, int num_ships) {
total = hold_[0] + hold_[1] + hold_[2] + hold_[3];
}
- gotoxy(0, 4);
+ gotox0y(4);
clrtoeol();
- gotoxy(0, 5);
+ gotox0y(5);
clrtoeol();
- gotoxy(0, 6);
+ gotox0y(6);
clrtoeol();
if(total > 0) {
- gotoxy(0, 3);
+ gotox0y(3);
clrtoeol();
// cputs("Let's hope we lose 'em");
print_msg(M_hope_we_lose_em);
@@ -1319,7 +1331,7 @@ char sea_battle(char id, int num_ships) {
set_orders();
} else {
- gotoxy(0, 3);
+ gotox0y(3);
clrtoeol();
// cputs("There's nothing there");
print_msg(M_nothing_there);
@@ -1332,7 +1344,7 @@ char sea_battle(char id, int num_ships) {
if((orders == 2) || (orders == 3)) {
if(orders == 2) {
- gotoxy(0, 3);
+ gotox0y(3);
clrtoeol();
// cputs("Aye, we'll run");
print_msg(M_aye_run);
@@ -1342,7 +1354,7 @@ char sea_battle(char id, int num_ships) {
ok += ik++;
if(randi()%ok > randi()%num_ships) {
- gotoxy(0, 3);
+ gotox0y(3);
clrtoeol();
// cputs("We got away from 'em");
print_msg(M_we_got_away);
@@ -1351,7 +1363,7 @@ char sea_battle(char id, int num_ships) {
set_orders();
num_ships = 0;
} else {
- gotoxy(0, 3);
+ gotox0y(3);
clrtoeol();
// cputs("Couldn't lose 'em.");
print_msg(M_couldnt_lose_em);
@@ -1363,7 +1375,7 @@ char sea_battle(char id, int num_ships) {
num_ships -= lost;
fight_stats(num_ships, orders);
- gotoxy(0, 3);
+ gotox0y(3);
clrtoeol();
// cputs("But we escaped from ");
print_msg(M_but_we_escaped);
@@ -1384,7 +1396,7 @@ char sea_battle(char id, int num_ships) {
plus_or_space(num_ships > num_on_screen);
}
- gotoxy(0, 16);
+ gotox0y(16);
set_orders();
}
@@ -1392,7 +1404,7 @@ char sea_battle(char id, int num_ships) {
}
if(num_ships > 0) {
- gotoxy(0, 3);
+ gotox0y(3);
clrtoeol();
// cputs("They're firing on us");
print_msg(M_theyre_firing);
@@ -1404,7 +1416,7 @@ char sea_battle(char id, int num_ships) {
fight_stats(num_ships, orders);
plus_or_space(num_ships > num_on_screen);
- gotoxy(0, 3);
+ gotox0y(3);
clrtoeol();
// cputs("We've been hit");
print_msg(M_weve_been_hit);
@@ -1426,7 +1438,7 @@ char sea_battle(char id, int num_ships) {
guns--;
hold += 10;
fight_stats(num_ships, orders);
- gotoxy(0, 3);
+ gotox0y(3);
clrtoeol();
// cputs("The buggers hit a gun");
print_msg(M_buggers_hit_gun);
@@ -1469,7 +1481,7 @@ char sea_battle(char id, int num_ships) {
if(damage == capacity) return 4;
#ifdef DAMAGE_TEST
- gotoxy(0, 23);
+ gotox0y(23);
clrtoeol();
cprintulong(ed);
cspace();
@@ -1491,7 +1503,7 @@ char sea_battle(char id, int num_ships) {
if(orders == 1) {
fight_stats(num_ships, orders);
- gotoxy(0, 3);
+ gotox0y(3);
clrtoeol();
// cputs("We got 'em all");
print_msg(M_we_got_em_all);
@@ -2085,7 +2097,7 @@ void final_stats(void)
chline(31);
cputc(3); // lower right corner
- gotoxy(0, 22);
+ gotox0y(22);
// cputs("Play again? ");
print_msg(M_play_again);
choice = yngetc(0);
@@ -2166,7 +2178,7 @@ void transfer(void) {
unsigned long amount = 0;
if(have_no_cargo()) {
- gotoxy(0, 22);
+ gotox0y(22);
clrtobot();
// cputs("You have no cargo");
print_msg(M_you_have_no_cargo);
@@ -2200,13 +2212,13 @@ void transfer(void) {
hold += amount;
break;
} else if(in_use == 10000) {
- gotoxy(0, 21);
+ gotox0y(21);
// cputs("Your warehouse is full");
print_msg(M_whouse_full);
cprint_taipan_bang();
good_joss_timed_getch();
} else {
- gotoxy(0, 21);
+ gotox0y(21);
// cputs("Your warehouse will only hold an\nadditional ");
print_msg(M_whouse_only_hold);
cprintuint(10000 - in_use);
@@ -2215,7 +2227,7 @@ void transfer(void) {
}
} else {
clear_msg_window();
- // gotoxy(0, 18);
+ // gotox0y(18);
// clrtobot();
you_have_only();
cprintulong(hold_[i]);
@@ -2248,7 +2260,7 @@ void transfer(void) {
break;
} else {
clear_msg_window();
- // gotoxy(0, 18);
+ // gotox0y(18);
// clrtobot();
you_have_only();
cprintuint(hkw_[i]);
@@ -2338,7 +2350,7 @@ void quit(void)
under_attack_timed_getch();
result = sea_battle(GENERIC, num_ships);
- gotoxy(0,23); /* to avoid disappearing U in "In use" */
+ // gotoxy(0,23); /* to avoid disappearing U in "In use" */
}
if(result == 2) {
@@ -2651,7 +2663,7 @@ void you_only_have(unsigned char in_bank) {
#else
void you_only_have(unsigned char in_bank) {
clear_msg_window();
- // gotoxy(0, 18);
+ // gotox0y(18);
// clrtobot();
cprint_taipan_comma();
@@ -2903,7 +2915,7 @@ int port_choices(void) {
cprintulong(price[3]);
*/
- gotoxy(0, 22);
+ gotox0y(22);
clrtobot();
#ifdef BIGNUM
@@ -3072,11 +3084,13 @@ void name_firm(void) {
# pragma code-name (push, "HIGHCODE")
#endif
char what_do_you_wish_me_to(char buy_or_sell) {
- gotoxy(0, 22);
+ gotox0y(22);
clrtobot();
- cputs("What ");
+ // cputs("What ");
+ print_msg(M_what);
do_you_wish();
- cputs("me to ");
+ // cputs("me to ");
+ print_msg(M_me_to);
cputs(buy_or_sell ? "buy" : "sell");
cprint_taipan_prompt();
return get_item(0);
@@ -3100,7 +3114,7 @@ void buy(void) {
// cputs(" You can ");
print_msg(M_spc_you_can_spc);
rvs_off();
- gotoxy(0, 22);
+ gotox0y(22);
how_much();
// cputs(item[choice]);
print_msg(item[choice]);
@@ -3123,7 +3137,7 @@ void buy(void) {
cprintulong(afford);
rvs_off();
- gotoxy(0, 23);
+ gotox0y(23);
// cputs("I buy, ");
print_msg(M_i_buy);
cprint_taipan_colon();
@@ -3151,7 +3165,7 @@ void sell(void) {
choice = what_do_you_wish_me_to(0);
for (;;) {
- gotoxy(0, 22);
+ gotox0y(22);
clrtobot();
how_much();