From 5faf0c949468cf72d1dfd0e52369ab2d26760fd7 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Mon, 26 Apr 2021 15:37:02 -0400 Subject: Initial POC of in-game help --- Makefile | 11 +-- gamehelp.s | 156 ++++++++++++++++++++++++++++++++++++++++++ gamehelp.txt | 76 +++++++++++++++++++++ helpmsgs.c | 197 +++++++++++++++++++++++++++++++++++++++++++++++++++++ helpmsgs.h | 14 ++++ helpmsgs.msg | 38 +++++++++++ messages.msg | 168 ++++++++++++++++++++++++++++++++++++++++++++++ messages.pl | 212 ++++++++-------------------------------------------------- taipan.c | 10 +++ timed_getch.s | 8 +++ 10 files changed, 703 insertions(+), 187 deletions(-) create mode 100644 gamehelp.s create mode 100644 gamehelp.txt create mode 100644 helpmsgs.c create mode 100644 helpmsgs.h create mode 100644 helpmsgs.msg create mode 100644 messages.msg diff --git a/Makefile b/Makefile index e43624e..801b6a1 100644 --- a/Makefile +++ b/Makefile @@ -314,8 +314,11 @@ textdecomp.s: msg.inc msg.inc: messages.c # messages.c is a generated file -messages.c: messages.pl textcomp - perl messages.pl > messages.c +messages.c: messages.pl messages.msg textcomp + perl messages.pl < messages.msg > messages.c + +helpmsgs.c: messages.pl helpmsgs.msg textcomp + perl messages.pl -n < helpmsgs.msg > helpmsgs.c ### Cartridge-related targets. The way I'm doing this isn't 'proper': I should # be using cc65's linker with a fancy config script to do the bank layout @@ -335,8 +338,8 @@ cartbank2.cfg: cartbank2.cfg.old cartbank2.cfg.new cartbank2.sh # using a custom crt0 to get rid of the extra RTS cc65 puts there for # SpartaDOS compatibility (which has no effect on a cartridge image, # except to waste 1 byte). -romable_taimain.raw: cartbank2.cfg $(TAIMAIN_C_SRC) $(TAIMAIN_ASM_SRC) $(TAIMAIN_HDRS) $(BIGNUM_SRC) $(BIGNUM_HDRS) $(TAIMAIN_LIBS) crt0_cart.s messages.c - $(CC) --config cartbank2.cfg -m taipan.map -t atari -T -I. -L. -DFONT_ADDR=0x9c00 --start-addr 0x400 -Wl -D__STACKSIZE__=0x200 -O -Wl -D__SYSTEM_CHECK__=1 -Wl -D__AUTOSTART__=1 -Wl -D__EXEHDR__=1 -DCART_TARGET=1 --asm-define CART_TARGET=1 -DBIGNUM=BIGFLOAT -o romable_taimain.raw $(TAIMAIN_C_SRC) $(TAIMAIN_ASM_SRC) $(BIGNUM_SRC) $(TAIMAIN_LIBS) crt0_cart.s +romable_taimain.raw: cartbank2.cfg $(TAIMAIN_C_SRC) $(TAIMAIN_ASM_SRC) $(TAIMAIN_HDRS) $(BIGNUM_SRC) $(BIGNUM_HDRS) $(TAIMAIN_LIBS) crt0_cart.s messages.c helpmsgs.c + $(CC) --config cartbank2.cfg -m taipan.map -t atari -T -I. -L. -DFONT_ADDR=0x9c00 --start-addr 0x400 -Wl -D__STACKSIZE__=0x200 -O -Wl -D__SYSTEM_CHECK__=1 -Wl -D__AUTOSTART__=1 -Wl -D__EXEHDR__=1 --asm-define GAME_HELP=1 -DGAME_HELP -DCART_TARGET=1 --asm-define CART_TARGET=1 -DBIGNUM=BIGFLOAT -o romable_taimain.raw $(TAIMAIN_C_SRC) $(TAIMAIN_ASM_SRC) $(BIGNUM_SRC) $(TAIMAIN_LIBS) crt0_cart.s gamehelp.s # 8192 bytes of $ff filler, for unused banks. Possibly these will be # used for something like an interactive game manual/tutorial. diff --git a/gamehelp.s b/gamehelp.s new file mode 100644 index 0000000..092e256 --- /dev/null +++ b/gamehelp.s @@ -0,0 +1,156 @@ + .include "atari.inc" + + .import _print_msg, _clrtoeol + + .import _M_help_avail_hk + .import _M_help_avail_hk_retire + .import _M_help_buy_sell + .import _M_help_change_orders + .import _M_help_doesnt_affect + .import _M_help_each_gun + .import _M_help_enter_firm + .import _M_help_fight + .import _M_help_for_fun + .import _M_help_ftr_any + .import _M_help_if_debt + .import _M_help_loan_shark + .import _M_help_may_loan + .import _M_help_million + .import _M_help_only_if_total + .import _M_help_press_a + .import _M_help_press_m + .import _M_help_press_k + .import _M_help_press_ret_done + .import _M_help_quit_trading + .import _M_help_press_ret_alone + .import _M_help_run + .import _M_help_throw + .import _M_help_to_sail_to + .import _M_help_transferred_to + .import _M_help_turbo + .import _M_help_type_amount + .import _M_help_type_letter + .import _M_help_type_number + .import _M_help_under_attack + .import _M_help_wh_bank_only + .import _M_help_y_or_n + + .export _print_game_help, _game_help + .export _get_amount_help, _port_choices_help, _port_stat_help_nonhk + .export _port_stat_help_hk, _name_firm_help, _sea_battle_help + .export _wu_help, _new_gun_help, _new_ship_help + + ;;; use temps that won't get stepped on by print_msg, cputs, cputc, etc. + tblptr = FR1+2 ; and +3 + ystash = FR1+4 + + .ifdef CART_TARGET + .segment "HIGHCODE" + .else + .code + .endif + +;;; extern void __fastcall__ print_game_help(const char *entry); +; +; Print entire help screen. Caller must ensure the screen gets refreshed +; afterwards (e.g. by calling port_stats()). + + .import _cprintuint + +_print_game_help: + ldx _game_help+1 + beq @ldone + lda _game_help + sta tblptr + stx tblptr+1 + lda #0 + sta ROWCRS + sta COLCRS + sta ystash +@loop: + jsr _clrtoeol + ldy ystash + lda (tblptr),y ; high byte! + beq @ldone + tax + iny + lda (tblptr),y + iny + sty ystash + jsr _print_msg + jmp @loop +@ldone: +rts + +; extern char *game_help; +; set to one of the __help addresses below, or NULL +; if there's no help for the current screen. + .data +_game_help: .res 2 + + .rodata + +_get_amount_help: + .dbyt _M_help_type_amount + .dbyt _M_help_press_a + .dbyt _M_help_press_k + .dbyt _M_help_press_m + .dbyt _M_help_press_ret_alone + .byte $00 + +_port_choices_help: + .dbyt _M_help_type_number + .dbyt _M_help_to_sail_to + .byte $00 + +_port_stat_help_nonhk: + .dbyt _M_help_type_letter + .dbyt _M_help_buy_sell + .dbyt _M_help_quit_trading + .dbyt _M_help_wh_bank_only + .dbyt _M_help_avail_hk + .byte $00 + +_port_stat_help_hk: + .dbyt _M_help_type_letter + .dbyt _M_help_buy_sell + .dbyt _M_help_quit_trading + .dbyt _M_help_wh_bank_only + .dbyt _M_help_avail_hk_retire + .dbyt _M_help_only_if_total + .dbyt _M_help_million + .byte $00 + +_name_firm_help: + .dbyt _M_help_enter_firm + .dbyt _M_help_doesnt_affect + .dbyt _M_help_for_fun + .dbyt _M_help_press_ret_done + .byte $00 + +_sea_battle_help: + .dbyt _M_help_under_attack + .dbyt _M_help_fight + .dbyt _M_help_throw + .dbyt _M_help_run + .dbyt _M_help_turbo + .dbyt _M_help_ftr_any + .dbyt _M_help_change_orders + .byte $00 + +_wu_help: + .dbyt _M_help_loan_shark + .dbyt _M_help_if_debt + .dbyt _M_help_may_loan + .byte $00 + +_new_gun_help: + .dbyt _M_help_y_or_n + .dbyt _M_help_each_gun + .byte $00 + +_new_ship_help: + .dbyt _M_help_y_or_n + .dbyt _M_help_transferred_to + .byte $00 + diff --git a/gamehelp.txt b/gamehelp.txt new file mode 100644 index 0000000..3842c2b --- /dev/null +++ b/gamehelp.txt @@ -0,0 +1,76 @@ +####################################### +# buy() +# sell() +# transfer(), to whouse +# transfer(), from whouse +# visit_bank(), deposit +# visit_bank(), withdraw +# elder_brother_wu() repay +# elder_brother_wu() borrow +# mchenry() amount +Type the amount, then press Return. +Press A for 'All'. +Press K to insert three zeroes, or +M for six zeroes. +Press Return alone to abort +######################################## +# port_choices() +Type the number of the port you wish +to sail to, or press Return to abort. +######################################## +# port status menu (non-hongkong) +Type the letter of your choice: +B: Buy cargo, S: Sell cargo. +Q: Quit trading: End this turn and sail + to another port. +The warehouse and bank are only +available at Hong Kong. +######################################## +# port status menu (hongkong) +Type the letter of your choice: +B: Buy cargo, S: Sell cargo. +Q: Quit trading: End this turn and sail + to another port. +V: Visit bank (deposit,withdraw). +T: Transfer cargo to,from warehouse. +R: Retire: End the game and receive + your final score and rank. +The warehouse and bank are only +available at Hong Kong. You may retire +only if your cash and bank account total +a million or more. +######################################## +# name_firm() +Enter the name of your trading firm. +This doesn't affect gameplay: it's just +for fun. Use backspace to correct typos. +Press Return when you're done. +######################################## +# sea_battle() +You're under attack! Your choices: +F: Fight. Requires at least one gun. +T: Throw cargo. You must have cargo. +R: Run. You can always try to run. +Press Shift F or Shift R for 'turbo'. +You can press F,T,R at any time, to +change your orders. +######################################## +# elder_brother_wu() +Elder Brother Wu is the loan shark. +If you have debt, you can pay it now. He +may also loan you money. +######################################## +# li_yuen_extortion(): not really needed +######################################## +# cash_or_guns(): not really needed +######################################## +# mchenry() y/n: not really needed +######################################## +# new_gun() +Press Y for yes or N for no. +Each gun takes up ten cargo hold units. +######################################## +# new_ship() +Press Y for yes or N for no. +All your cargo and guns will be +transferred to the new ship. diff --git a/helpmsgs.c b/helpmsgs.c new file mode 100644 index 0000000..336b4c4 --- /dev/null +++ b/helpmsgs.c @@ -0,0 +1,197 @@ +// do not edit, contents are generated by messages.pl + +const char M_help_to_another_port[] = { + // " to another port.\n" + 0xd7, 0x5d, 0x10, 0x04, 0xe3, 0xf4, 0xa1, 0x2d, 0x50, 0x3d, 0x25, 0x39, 0xfc, 0x00 +}; // dictionary used + +const char M_help_your_final[] = { + // " your final score and rank.\n" + 0xd7, 0x5d, 0x74, 0xac, 0x62, 0x4e, 0x04, 0xcd, 0x53, 0x0c, 0xf4, 0x85, 0xd7, 0x45, 0x35, 0x48, 0x13, 0x8b, 0xe7, 0xf0, 0x00 +}; // dictionary used + +const char M_help_all_your[] = { + // "All your cargo and guns will be\n" + 0x6c, 0xc3, 0x35, 0xd2, 0xb0, 0xf4, 0x27, 0x5d, 0x14, 0xd4, 0x75, 0x4e, 0x4f, 0x5d, 0x0e, 0xd4, 0x21, 0x7f, 0x00 +}; // dictionary used + +const char M_help_buy_sell[] = { + // "B: Buy cargo, S: Sell cargo.\n" + 0x73, 0xbd, 0x5c, 0x55, 0x9d, 0x43, 0xd0, 0x9e, 0x35, 0xb7, 0xbd, 0x6d, 0x14, 0xc3, 0x35, 0x0f, 0x42, 0x79, 0xfc, 0x00 +}; // dictionary used + +const char M_help_each_gun[] = { + // "Each gun takes up ten cargo hold units.\n" + 0x7c, 0x10, 0xc8, 0xd4, 0x75, 0x4e, 0xd5, 0x40, 0x4b, 0x15, 0x3d, 0x55, 0x43, 0x55, 0x05, 0x3b, 0x50, 0xf4, 0x27, 0x52, 0x0f, 0x30, 0x4d, 0x55, 0x38, 0x95, 0x13, 0xe7, 0xf0, 0x00 +}; // dictionary used + +const char M_help_loan_shark[] = { + // "Elder Brother Wu is the loan shark.\n" + 0xd0, 0x2d, 0x71, 0x57, 0x52, 0x53, 0xd0, 0xcd, 0x4c, 0x3c, 0x13, 0xb5, 0x4c, 0x80, 0x52, 0x2f, 0x9f, 0xc0 +}; // dictionary used + +const char M_help_enter_firm[] = { + // "Enter the name of your trading firm.\n" + 0x7c, 0xe5, 0x05, 0x4b, 0x43, 0x35, 0x38, 0x13, 0x45, 0xd0, 0xdd, 0x74, 0xad, 0x44, 0x81, 0x10, 0x93, 0x87, 0xd4, 0x62, 0x52, 0x37, 0x9f, 0xc0 +}; // dictionary used + +const char M_help_fight[] = { + // "F: Fight. Requires at least one gun.\n" + 0x83, 0xbd, 0x60, 0x24, 0x72, 0x14, 0xe7, 0x5b, 0x05, 0x45, 0x52, 0x52, 0x15, 0x3d, 0x41, 0x53, 0x53, 0x05, 0x05, 0x35, 0x35, 0x3c, 0xe1, 0x75, 0x1d, 0x53, 0xb9, 0xfc, 0x00 +}; + +const char M_help_if_debt[] = { + // "If you have debt, you can pay it now. He\n" + 0x8c, 0x6d, 0x74, 0x0f, 0x41, 0xb5, 0xd2, 0x7e, 0x35, 0xd0, 0x3d, 0x43, 0x04, 0xed, 0x50, 0x05, 0x9d, 0x49, 0x53, 0x49, 0x57, 0xe7, 0x58, 0x85, 0xfc, 0x00 +}; // dictionary used + +const char M_help_press_m[] = { + // "Press M for six zeroes.\n" + 0xa9, 0x21, 0x53, 0x4f, 0x59, 0xf5, 0xd1, 0x24, 0xc9, 0x63, 0x56, 0x85, 0x48, 0xf1, 0x53, 0xe7, 0xf0, 0x00 +}; // dictionary used + +const char M_help_press_a[] = { + // "Press A for All.\n" + 0xa9, 0x21, 0x53, 0x4f, 0x56, 0xf5, 0xd1, 0x26, 0xcc, 0x33, 0x9f, 0xc0 +}; // dictionary used + +const char M_help_press_k[] = { + // "Press K to insert three zeroes\n" + 0xa9, 0x21, 0x53, 0x4f, 0x59, 0x74, 0x40, 0x93, 0x93, 0x15, 0x25, 0x35, 0x50, 0x84, 0x85, 0x17, 0x56, 0x85, 0x48, 0xf1, 0x53, 0xfc, 0x00 +}; // dictionary used + +const char M_help_press_ret_alone[] = { + // "Press Return alone to abort.\n" + 0xa9, 0x21, 0x53, 0x4f, 0x5b, 0x05, 0x51, 0x54, 0x8e, 0xd4, 0x13, 0x0f, 0x38, 0x5d, 0x10, 0x04, 0x23, 0xd2, 0x53, 0x9f, 0xc0 +}; // dictionary used + +const char M_help_press_ret_done[] = { + // "Press Return when you're done.\n" + 0xa9, 0x21, 0x53, 0x4f, 0x5b, 0x05, 0x51, 0x54, 0x8e, 0xd5, 0x72, 0x05, 0x3b, 0x5d, 0x03, 0xf1, 0x21, 0x75, 0x10, 0xf3, 0x85, 0xe7, 0xf0, 0x00 +}; // dictionary used + +const char M_help_turbo[] = { + // "Press Shift F or Shift R for 'turbo'.\n" + 0xa9, 0x21, 0x53, 0x4f, 0x5b, 0x48, 0x24, 0x65, 0x35, 0x83, 0x53, 0xd2, 0xd6, 0xd2, 0x09, 0x19, 0x4d, 0x6c, 0xd7, 0x44, 0xbc, 0x51, 0x54, 0x82, 0x3f, 0xce, 0x7f, 0x00 +}; // dictionary used + +const char M_help_y_or_n[] = { + // "Press Y for yes or N for no.\n" + 0xa9, 0x21, 0x53, 0x4f, 0x5c, 0xf5, 0xd1, 0x26, 0x45, 0x4f, 0x53, 0xd2, 0xd6, 0x8d, 0x74, 0x48, 0xe3, 0xf9, 0xfc, 0x00 +}; // dictionary used + +const char M_help_quit_trading[] = { + // "Q: Quit trading: End this turn and sail\n" + 0xaf, 0xbd, 0x6b, 0x54, 0x95, 0x35, 0x51, 0x20, 0x44, 0x24, 0xe1, 0xfb, 0xd5, 0xf3, 0x84, 0xd5, 0x42, 0x34, 0x4d, 0x45, 0x52, 0x3b, 0x5d, 0x14, 0xd5, 0x30, 0x49, 0x33, 0xf0, 0x00 +}; // dictionary used + +const char M_help_retire[] = { + // "R: Retire: End the game and receive\n" + 0xb3, 0xbd, 0x6c, 0x15, 0x42, 0x52, 0x17, 0xbd, 0x5f, 0x38, 0x4d, 0x0c, 0xd4, 0x70, 0x4d, 0x17, 0x5d, 0x14, 0xd5, 0x21, 0x43, 0x14, 0x95, 0x85, 0xfc, 0x00 +}; // dictionary used + +const char M_help_run[] = { + // "R: Run. You can always try to run.\n" + 0xb3, 0xbd, 0x6c, 0x54, 0xee, 0x75, 0xd0, 0x5d, 0x43, 0x04, 0xed, 0x41, 0x31, 0x70, 0x59, 0x4f, 0x55, 0x12, 0x67, 0x44, 0x12, 0x54, 0xee, 0x7f, 0x00 +}; // dictionary used + +const char M_help_throw[] = { + // "T: Throw cargo. You must have cargo.\n" + 0xbb, 0xbd, 0x6e, 0x21, 0x23, 0xd7, 0xd4, 0x3d, 0x09, 0xe7, 0x5d, 0x05, 0xd4, 0xd5, 0x53, 0x53, 0x41, 0xb5, 0x0f, 0x42, 0x79, 0xfc, 0x00 +}; // dictionary used + +const char M_help_transfer[] = { + // "T: Transfer cargo to,from warehouse.\n" + 0xbb, 0xbd, 0x6e, 0x48, 0x13, 0x93, 0x18, 0x54, 0xb5, 0x0f, 0x42, 0x75, 0x50, 0xfe, 0x06, 0x48, 0xf3, 0x74, 0x2f, 0x9f, 0xc0 +}; // dictionary used + +const char M_help_wh_bank_only[] = { + // "The warehouse and bank are only\n" + 0xb8, 0x81, 0x74, 0x2f, 0x5d, 0x14, 0xd4, 0x20, 0x4e, 0x2f, 0x50, 0x52, 0x17, 0x53, 0xce, 0x31, 0x9f, 0xc0 +}; // dictionary used + +const char M_help_doesnt_affect[] = { + // "This doesn't affect gameplay: it's just\n" + 0xb8, 0x8d, 0x13, 0x10, 0xf1, 0x53, 0x3b, 0xc5, 0x35, 0x04, 0x61, 0x85, 0x0d, 0x4d, 0x47, 0x04, 0xd1, 0x50, 0x30, 0x16, 0x7b, 0xd4, 0x95, 0x3c, 0x4f, 0x52, 0x95, 0x4d, 0x4f, 0xc0 +}; // dictionary used + +const char M_help_type_amount[] = { + // "Type the amount, then press Return.\n" + 0xb9, 0x94, 0x05, 0xd0, 0xcd, 0x41, 0x34, 0xf5, 0x4e, 0x53, 0x8d, 0x0c, 0x3b, 0x54, 0x12, 0x15, 0x34, 0xf5, 0xb0, 0x55, 0x15, 0x48, 0xee, 0x7f, 0x00 +}; // dictionary used + +const char M_help_type_letter[] = { + // "Type the letter of your choice:\n" + 0xb9, 0x94, 0x05, 0xd0, 0xcd, 0x4c, 0x15, 0x45, 0x05, 0x4b, 0x43, 0x75, 0xd2, 0xb0, 0xc8, 0x3c, 0x90, 0xc5, 0xef, 0xf0, 0x00 +}; // dictionary used + +const char M_help_type_number[] = { + // "Type the number of the port you wish\n" + 0xb9, 0x94, 0x05, 0xd0, 0xcd, 0x4e, 0x54, 0xd0, 0x85, 0x4b, 0x43, 0x74, 0x33, 0x54, 0x0f, 0x49, 0x4d, 0x74, 0x0f, 0x49, 0xbf, 0x00 +}; // dictionary used + +const char M_help_visit_bank[] = { + // "V: Visit bank (deposit,withdraw).\n" + 0xc3, 0xbd, 0x70, 0x25, 0x32, 0x54, 0xd4, 0x20, 0x4e, 0x2f, 0x5f, 0x44, 0x15, 0x03, 0xd3, 0x25, 0x4e, 0x17, 0x25, 0x42, 0x04, 0x48, 0x15, 0xfe, 0xe7, 0xf0, 0x00 +}; + +const char M_help_ftr_any[] = { + // "You can press F,T,R at any time, to\n" + 0xd0, 0x5d, 0x43, 0x04, 0xed, 0x50, 0x48, 0x54, 0xd3, 0xd6, 0x0e, 0x2e, 0xe2, 0xcd, 0x41, 0x53, 0x50, 0x4e, 0x67, 0x55, 0x09, 0x34, 0x5e, 0x35, 0x50, 0xff, 0xc0 +}; // dictionary used + +const char M_help_under_attack[] = { + // "You're under attack! Your choices:\n" + 0xd0, 0x5f, 0x12, 0x17, 0x55, 0x4e, 0x10, 0x54, 0xb5, 0x05, 0x45, 0x01, 0x0c, 0xbd, 0xb5, 0xd0, 0x54, 0xb5, 0x0c, 0x83, 0xc9, 0x0c, 0x54, 0xfb, 0xfc, 0x00 +}; // dictionary used + +const char M_help_million[] = { + // "a million or more.\n" + 0x07, 0x53, 0x49, 0x30, 0xc2, 0x4f, 0x3b, 0x53, 0xd2, 0xd4, 0xd3, 0xd2, 0x17, 0x9f, 0xc0 +}; + +const char M_help_avail_hk[] = { + // "available at Hong Kong.\n" + 0x05, 0x60, 0x49, 0x30, 0x10, 0x8c, 0x17, 0x50, 0x54, 0xd6, 0x23, 0xce, 0x1f, 0x59, 0x4f, 0x38, 0x7e, 0x7f, 0x00 +}; + +const char M_help_avail_hk_retire[] = { + // "available at Hong Kong. You may retire\n" + 0x05, 0x60, 0x49, 0x30, 0x10, 0x8c, 0x17, 0x50, 0x54, 0xd6, 0x23, 0xce, 0x1f, 0x59, 0x4f, 0x38, 0x7e, 0x75, 0xd0, 0x5d, 0x4d, 0x05, 0x9d, 0x52, 0x15, 0x42, 0x52, 0x17, 0xf0, 0x00 +}; // dictionary used + +const char M_help_change_orders[] = { + // "change your orders.\n" + 0x0c, 0x80, 0x4e, 0x1c, 0x5d, 0x74, 0xac, 0xf4, 0x84, 0x15, 0x24, 0xf9, 0xfc, 0x00 +}; // dictionary used + +const char M_help_for_fun[] = { + // "for fun. Use backspace to correct typos.\n" + 0xd1, 0x21, 0x95, 0x3b, 0x9d, 0x6f, 0x4c, 0x5d, 0x42, 0x04, 0x32, 0xd3, 0x40, 0x10, 0xc5, 0xd1, 0x00, 0xcf, 0x49, 0x21, 0x43, 0x53, 0x55, 0x19, 0x40, 0xf4, 0xf9, 0xfc, 0x00 +}; // dictionary used + +const char M_help_may_loan[] = { + // "may also loan you money.\n" + 0x34, 0x16, 0x75, 0x04, 0xc4, 0xcf, 0xd4, 0xc3, 0xc1, 0x3b, 0x5d, 0x03, 0xd4, 0xd3, 0xce, 0x15, 0x9e, 0x7f, 0x00 +}; // dictionary used + +const char M_help_only_if_total[] = { + // "only if your cash and bank account total\n" + 0x3c, 0xe3, 0x19, 0xd4, 0x91, 0xb5, 0xd0, 0x34, 0xb4, 0x57, 0x5d, 0x14, 0xd4, 0x20, 0x4e, 0x2f, 0x50, 0x43, 0x0c, 0xf5, 0x4e, 0x53, 0x55, 0x0f, 0x50, 0x13, 0x3f, 0x00 +}; // dictionary used + +const char M_help_to_sail_to[] = { + // "to sail to, or press Return to abort.\n" + 0x50, 0xfd, 0x53, 0x04, 0x93, 0x35, 0x50, 0xfe, 0x35, 0x3d, 0x2d, 0x50, 0x48, 0x54, 0xd3, 0xd6, 0xc1, 0x54, 0x55, 0x23, 0xb4, 0x40, 0x10, 0x8f, 0x49, 0x4e, 0x7f, 0x00 +}; // dictionary used + +const char M_help_transferred_to[] = { + // "transferred to the new ship.\n" + 0x51, 0x20, 0x4e, 0x4c, 0x61, 0x52, 0x48, 0x51, 0x34, 0x43, 0x4a, 0x35, 0x38, 0x55, 0xf5, 0xd0, 0xae, 0x7f, 0x00 +}; // dictionary used + +// messages: 38 +// total input size: 1282 +// total output size: 869 +// compression: 413 +// ratio: 67.8% diff --git a/helpmsgs.h b/helpmsgs.h new file mode 100644 index 0000000..0df1d6d --- /dev/null +++ b/helpmsgs.h @@ -0,0 +1,14 @@ +extern void __fastcall__ print_game_help(void); + +extern const char *game_help; + +extern const char get_amount_help[]; +extern const char port_choices_help[]; +extern const char name_firm_help[]; +extern const char sea_battle_help[]; +extern const char wu_help[]; +extern const char new_gun_help[]; +extern const char new_ship_help[]; + +#define SET_HELP(x) (game_help = x) +#define CLEAR_HELP (game_help = (void *)0) diff --git a/helpmsgs.msg b/helpmsgs.msg new file mode 100644 index 0000000..3ab57e2 --- /dev/null +++ b/helpmsgs.msg @@ -0,0 +1,38 @@ +help_to_another_port " to another port.\n" +help_your_final " your final score and rank.\n" +help_all_your "All your cargo and guns will be\n" +help_buy_sell "B: Buy cargo, S: Sell cargo.\n" +help_each_gun "Each gun takes up ten cargo hold units.\n" +help_loan_shark "Elder Brother Wu is the loan shark.\n" +help_enter_firm "Enter the name of your trading firm.\n" +help_fight "F: Fight. Requires at least one gun.\n" +help_if_debt "If you have debt, you can pay it now. He\n" +help_press_m "Press M for six zeroes.\n" +help_press_a "Press A for All.\n" +help_press_k "Press K to insert three zeroes\n" +help_press_ret_alone "Press Return alone to abort.\n" +help_press_ret_done "Press Return when you're done.\n" +help_turbo "Press Shift F or Shift R for 'turbo'.\n" +help_y_or_n "Press Y for yes or N for no.\n" +help_quit_trading "Q: Quit trading: End this turn and sail\n" +help_retire "R: Retire: End the game and receive\n" +help_run "R: Run. You can always try to run.\n" +help_throw "T: Throw cargo. You must have cargo.\n" +help_transfer "T: Transfer cargo to,from warehouse.\n" +help_wh_bank_only "The warehouse and bank are only\n" +help_doesnt_affect "This doesn't affect gameplay: it's just\n" +help_type_amount "Type the amount, then press Return.\n" +help_type_letter "Type the letter of your choice:\n" +help_type_number "Type the number of the port you wish\n" +help_visit_bank "V: Visit bank (deposit,withdraw).\n" +help_ftr_any "You can press F,T,R at any time, to\n" +help_under_attack "You're under attack! Your choices:\n" +help_million "a million or more.\n" +help_avail_hk "available at Hong Kong.\n" +help_avail_hk_retire "available at Hong Kong. You may retire\n" +help_change_orders "change your orders.\n" +help_for_fun "for fun. Use backspace to correct typos.\n" +help_may_loan "may also loan you money.\n" +help_only_if_total "only if your cash and bank account total\n" +help_to_sail_to "to sail to, or press Return to abort.\n" +help_transferred_to "transferred to the new ship.\n" diff --git a/messages.msg b/messages.msg new file mode 100644 index 0000000..222cbc9 --- /dev/null +++ b/messages.msg @@ -0,0 +1,168 @@ +guns "guns" +fight "Fight" +throw "Throw Cargo" +opium "Opium" +silk "Silk" +arms "Arms" +gen_cargo "General Cargo" +ellipsis "..." +at_sea " At sea " +hong_kong "Hong Kong" +shanghai "Shanghai" +nagasaki "Nagasaki" +saigon "Saigon" +manila "Manila" +singapore "Singapore" +batavia "Batavia" +will_you "will you " +bad_joss "Bad Joss!!\r\n" +crlf "\n" +taipan "Taipan" +do_you_wish "do you wish " +elder_brother_wu "Elder Brother Wu " +li_yuen "Li Yuen" +do_you_want "Do you want " +firm_colon "Firm:" +compradors_report "Comprador's Report\r\n\n" +captains_report " Captain's Report\r\n\n" +overloaded "Your ship is overloaded" +wish_to_trade "Do you wish to trade in your " +ship_for_one "\r\nship for one with " +more_capacity " more capacity by\r\npaying an additional " +gun_offer "Do you wish to buy a ship's gun\r\nfor " +space_ship " ship" +space_attacking " attacking" +your_orders_are "Your orders are: " +we_have " We have" +cur_seaworth "Current seaworthiness: " +what_shall_we_do "what shall we do??\r\n(Fight, Run, Throw cargo)" +aye_fight "Aye, we'll fight 'em" +were_firing "We're firing on 'em" +sunk "Sunk " +of_the_buggers " of the buggers" +didnt_sink "Hit 'em, but didn't sink 'em" +ran_away " ran away" +we_have_no_guns "We have no guns" +you_have_on_board "You have the following on board" +what_shall_i_throw "What shall I throw overboard" +how_much "How much" +hope_we_lose_em "Let's hope we lose 'em" +nothing_there "There's nothing there" +aye_run "Aye, we'll run" +we_got_away "We got away from 'em" +couldnt_lose_em "Couldn't lose 'em." +but_we_escaped "But we escaped from " +of_em " of 'em!" +theyre_firing "They're firing on us" +weve_been_hit "We've been hit" +buggers_hit_gun "The buggers hit a gun" +we_got_em_all "We got 'em all" +to_start "to start . . .\r\n\n" +with_cash ") With cash (and a debt)\r\n\n" +with_5_guns ") With five guns and no cash\r\n" +but_no_debt "(But no debt!)" +mchenry_has_arrived "Mc Henry from the Hong Kong\r\nShipyards has arrived!! He says, 'I see\r\nye've a wee bit of damage to yer ship.'\r\nWill ye be wanting repairs? " +tis_a_pity "Och, 'tis a pity to be " +percent_damaged "% damaged.\r\nWe can fix yer whole ship for " +or_partial_repairs "\r\nor make partial repairs if you wish.\r\n" +will_ye_spend "will ye spend? " +illionaire " I L L I O N A I R E !" +youre_a " Y o u ' r e a" +your_final_status "Your final status:\r\n\nNet cash: " +ship_size "\r\nShip size: " +units_with " units with " +you_traded_for " guns\r\n\nYou traded for " +spc_year " year" +spc_and_spc " and " +spc_month " month" +your_score_is "Your score is " +land_based_job "Have you considered a land based job?\r\n\n\n" +stay_on_shore "The crew has requested that you stay on\r\nshore for their safety!!\r\n\n" +3_nls "\n\n\n" +your_rating "Your Rating:\r\n" +ma_tsu "Ma Tsu" +master_taipan "Master Taipan" +compradore "Compradore" +galley_hand "Galley Hand" +play_again "Play again? " +you_have_only "You have only " +you_have_no_cargo "You have no cargo" +move_to_whouse " shall I move\r\nto the warehouse" +whouse_only_hold "Your warehouse will only hold an\r\nadditional " +whouse_full "Your warehouse is full" +move_aboard " shall I move\r\naboard ship" +me_to_go_to "me to go to:\r\n" +already_here "\r\n\nYou're already here" +hostile_ship " hostile ship" +approaching " approaching" +fleet_drove_off "Li Yuen's fleet drove them off!" +s_pirates "Li Yuen's pirates" +they_let_us_be "Good joss!! They let us be!!\r\n" +ships_of_fleet " ships of Li Yuen's pirate\r\nfleet" +captured_some_booty "We captured some booty.\r\nIt's worth " +we_made_it "We made it!" +buggers_got_us "The buggers got us" +all_over_now "!\r\nIt's all over, now!!!" +storm "Storm" +think_going_down " I think we're going down!!\r\n\n" +were_going_down "We're going down" +storm_we_made_it " We made it!!\r\n\n" +blown_off_course "We've been blown off course\r\nto " +arriving_at "Arriving at " +asks "Li Yuen asks " +in_donation " in donation\r\nto the temple of Tin Hau, the Sea\r\nGoddess. Will you pay? " +not_enough_cash "you do not have enough cash!!\r\n\n" +make_up_difference "to make up\r\nthe difference for you? " +given_the_diff "has given Li Yuen the\r\ndifference between what he wanted and\r\nyour cash on hand and added the same\r\namount to your debt.\r\n" +very_well "Very well. " +will_not_pay "will not pay\r\nLi Yuen the difference. I would be very\r\nwary of pirates if I were you." +you_only_have "you only have " +nl_in_spc "\nin " +the_bank "the bank.\n" +cash "cash.\n" +do_you_have_biz_with_wu "Do you have business with Elder Brother\r\nWu, the moneylender? " +aware_of_your_plight "Elder Brother is aware of your plight,\r\nTaipan. He is willing to loan you an\r\nadditional " +if_you_will_pay_back " if you will pay back\r\n" +are_you_willing ". Are you willing" +game_is_over "Very well, Taipan, the game is over!\r\n" +very_well_good_joss "Very well, Taipan. Good joss!!\r\n" +to_repay_him "to repay\r\nhim? " +to_borrow "to \r\nborrow? " +wont_loan "\r\n\nHe won't loan you so much" +bodyguards_killed " of your bodyguards have been killed\r\nby cutthroats and you have been robbed\r\nof all of your cash" +the_price_of "Taipan!! The price of " +nl_has_spc "\n has " +risen "risen" +dropped "dropped" +spc_to_spc " to " +bang_bang_nl "!!\n" +prices_here_are "present prices per unit here are" +general_shortname "General" +shall_i_buy_sell "Shall I Buy, Sell, " +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 " +i_buy "I buy, " +shall_i_sell " shall\r\nI sell, " +too_much_cash "\r\nYou cannot carry so much cash" +ship_would_sink "\r\nYour ship would sink under the weight\r\nof your riches.\r\n" +deposit "deposit? " +withdraw "withdraw? " +assassinated_1 "you have been assassinated!" +assassinated_2 "As the masked figure plunges the blade\r\ninto your heart, he says:\r\n" +assassinated_3 "regrets to inform you\r\nthat your account has been terminated\r\nwith extreme prejudice." +has_sent "has sent " +braves_to_escort " braves\r\nto escort you to the Wu mansion" +wu_warn_1 "reminds you of the\r\nConfucian ideal of personal worthiness,\r\nand how this applies to paying one's\r\ndebts.\r\n" +wu_warn_2 "He is reminded of a fabled barbarian\r\nwho came to a bad end, after not caring\r\nfor his obligations.\r\n\nHe hopes no such fate awaits you, his\r\nfriend" +siezed_opium "The local authorities have seized your\r\nOpium cargo and have also fined you\r\n" +whouse_theft "Messenger reports large theft\r\nfrom warehouse" +has_sent_lieutenant "Li Yuen has sent a Lieutenant,\r\nTaipan. He says his admiral wishes\r\nto see you in Hong Kong, posthaste!\r\n" +beaten_robbed "You've been beaten up and\r\nrobbed of " +in_cash " in cash" diff --git a/messages.pl b/messages.pl index 574d439..d00d9d5 100644 --- a/messages.pl +++ b/messages.pl @@ -1,12 +1,23 @@ #!/usr/bin/perl -w # compresses messages for taipan.c. -# messages are listed at the end of this file after __END__ marker. -# Run with no arguments to encode all messages, in which case the -# output of this script should be redirected to messages.c. -# With an argument, encoding is not done: instead, the strings -# to be encoded are dumped to stdout, *after* dictionary -# substitution is done. + +# Reads lines from stdin of the form: +# label "message text" +# writes C code to stdout. +# by default, an asm include file "asm.inc" is created, containing +# definitions of messages which exactly match a dictionary entry. +# with -n, "asm.inc" is not created. +# with -d, dumps messages to be encoded, after dictionary replacement. + +if(@ARGV) { + if($ARGV[0] eq '-n') { + $skip_msg_inc++; + } elsif($ARGV[0] eq '-d') { + $dump++; + $skip_msg_inc++; + } +} # make dictionary from textdecomp.s comments open my $t, "msg.inc" or die $!; -print ASMINC "; do not edit, contents are generated by messages.pl\n\n"; +if(!$skip_msg_inc) { + open ASMINC, ">msg.inc" or die $!; + print ASMINC "; do not edit, contents are generated by messages.pl\n\n"; +} + print "// do not edit, contents are generated by messages.pl\n\n"; -while() { +while() { chomp; $msgcount++; /^(\w+)\s/; @@ -43,7 +57,7 @@ while() { s/^\w+\s+//; my $orig = $_; - print " input: $_\n" if @ARGV; + print " input: $_\n" if $dump; s/"//g; s/\\r//g; s/\\n/\n/g; @@ -59,13 +73,13 @@ while() { # if a string turns out to be exactly a dict entry, no need to include # the compressed version in messages.c. - if(/^Z.$/) { + if(!$skip_msg_inc && /^Z.$/) { print "\nextern const char M_$label\[\]; // dictionary used, $dictlabels{$_}\n\n"; print ASMINC " _M_$label = $dictlabels{$_}\n .export _M_$label\n\n"; next; } - if(@ARGV) { + if($dump) { my $w = $_; $w =~ s/\n/\\n/g; print "output: \"$w\"\n\n"; @@ -84,11 +98,13 @@ while() { print join(", ", @got); $total_out += @got; } + close $result; die "failed to compress $orig\n" unless $readbytes; print "\n};" . ($dict_used ? " // dictionary used" : "") . "\n\n"; } -exit 0 if @ARGV; +close ASMINC unless $skip_msg_inc; +exit 0 if $dump; print "// messages: $msgcount\n"; print "// total input size: $total_in\n"; @@ -103,173 +119,3 @@ fine "fine" run "Run" # too short to be worth compression how_much_spc "How much " =cut - -__END__ -guns "guns" -fight "Fight" -throw "Throw Cargo" -opium "Opium" -silk "Silk" -arms "Arms" -gen_cargo "General Cargo" -ellipsis "..." -at_sea " At sea " -hong_kong "Hong Kong" -shanghai "Shanghai" -nagasaki "Nagasaki" -saigon "Saigon" -manila "Manila" -singapore "Singapore" -batavia "Batavia" -will_you "will you " -bad_joss "Bad Joss!!\r\n" -crlf "\n" -taipan "Taipan" -do_you_wish "do you wish " -elder_brother_wu "Elder Brother Wu " -li_yuen "Li Yuen" -do_you_want "Do you want " -firm_colon "Firm:" -compradors_report "Comprador's Report\r\n\n" -captains_report " Captain's Report\r\n\n" -overloaded "Your ship is overloaded" -wish_to_trade "Do you wish to trade in your " -ship_for_one "\r\nship for one with " -more_capacity " more capacity by\r\npaying an additional " -gun_offer "Do you wish to buy a ship's gun\r\nfor " -space_ship " ship" -space_attacking " attacking" -your_orders_are "Your orders are: " -we_have " We have" -cur_seaworth "Current seaworthiness: " -what_shall_we_do "what shall we do??\r\n(Fight, Run, Throw cargo)" -aye_fight "Aye, we'll fight 'em" -were_firing "We're firing on 'em" -sunk "Sunk " -of_the_buggers " of the buggers" -didnt_sink "Hit 'em, but didn't sink 'em" -ran_away " ran away" -we_have_no_guns "We have no guns" -you_have_on_board "You have the following on board" -what_shall_i_throw "What shall I throw overboard" -how_much "How much" -hope_we_lose_em "Let's hope we lose 'em" -nothing_there "There's nothing there" -aye_run "Aye, we'll run" -we_got_away "We got away from 'em" -couldnt_lose_em "Couldn't lose 'em." -but_we_escaped "But we escaped from " -of_em " of 'em!" -theyre_firing "They're firing on us" -weve_been_hit "We've been hit" -buggers_hit_gun "The buggers hit a gun" -we_got_em_all "We got 'em all" -to_start "to start . . .\r\n\n" -with_cash ") With cash (and a debt)\r\n\n" -with_5_guns ") With five guns and no cash\r\n" -but_no_debt "(But no debt!)" -mchenry_has_arrived "Mc Henry from the Hong Kong\r\nShipyards has arrived!! He says, 'I see\r\nye've a wee bit of damage to yer ship.'\r\nWill ye be wanting repairs? " -tis_a_pity "Och, 'tis a pity to be " -percent_damaged "% damaged.\r\nWe can fix yer whole ship for " -or_partial_repairs "\r\nor make partial repairs if you wish.\r\n" -will_ye_spend "will ye spend? " -illionaire " I L L I O N A I R E !" -youre_a " Y o u ' r e a" -your_final_status "Your final status:\r\n\nNet cash: " -ship_size "\r\nShip size: " -units_with " units with " -you_traded_for " guns\r\n\nYou traded for " -spc_year " year" -spc_and_spc " and " -spc_month " month" -your_score_is "Your score is " -land_based_job "Have you considered a land based job?\r\n\n\n" -stay_on_shore "The crew has requested that you stay on\r\nshore for their safety!!\r\n\n" -3_nls "\n\n\n" -your_rating "Your Rating:\r\n" -ma_tsu "Ma Tsu" -master_taipan "Master Taipan" -compradore "Compradore" -galley_hand "Galley Hand" -play_again "Play again? " -you_have_only "You have only " -you_have_no_cargo "You have no cargo" -move_to_whouse " shall I move\r\nto the warehouse" -whouse_only_hold "Your warehouse will only hold an\r\nadditional " -whouse_full "Your warehouse is full" -move_aboard " shall I move\r\naboard ship" -me_to_go_to "me to go to:\r\n" -already_here "\r\n\nYou're already here" -hostile_ship " hostile ship" -approaching " approaching" -fleet_drove_off "Li Yuen's fleet drove them off!" -s_pirates "Li Yuen's pirates" -they_let_us_be "Good joss!! They let us be!!\r\n" -ships_of_fleet " ships of Li Yuen's pirate\r\nfleet" -captured_some_booty "We captured some booty.\r\nIt's worth " -we_made_it "We made it!" -buggers_got_us "The buggers got us" -all_over_now "!\r\nIt's all over, now!!!" -storm "Storm" -think_going_down " I think we're going down!!\r\n\n" -were_going_down "We're going down" -storm_we_made_it " We made it!!\r\n\n" -blown_off_course "We've been blown off course\r\nto " -arriving_at "Arriving at " -asks "Li Yuen asks " -in_donation " in donation\r\nto the temple of Tin Hau, the Sea\r\nGoddess. Will you pay? " -not_enough_cash "you do not have enough cash!!\r\n\n" -make_up_difference "to make up\r\nthe difference for you? " -given_the_diff "has given Li Yuen the\r\ndifference between what he wanted and\r\nyour cash on hand and added the same\r\namount to your debt.\r\n" -very_well "Very well. " -will_not_pay "will not pay\r\nLi Yuen the difference. I would be very\r\nwary of pirates if I were you." -you_only_have "you only have " -nl_in_spc "\nin " -the_bank "the bank.\n" -cash "cash.\n" -do_you_have_biz_with_wu "Do you have business with Elder Brother\r\nWu, the moneylender? " -aware_of_your_plight "Elder Brother is aware of your plight,\r\nTaipan. He is willing to loan you an\r\nadditional " -if_you_will_pay_back " if you will pay back\r\n" -are_you_willing ". Are you willing" -game_is_over "Very well, Taipan, the game is over!\r\n" -very_well_good_joss "Very well, Taipan. Good joss!!\r\n" -to_repay_him "to repay\r\nhim? " -to_borrow "to \r\nborrow? " -wont_loan "\r\n\nHe won't loan you so much" -bodyguards_killed " of your bodyguards have been killed\r\nby cutthroats and you have been robbed\r\nof all of your cash" -the_price_of "Taipan!! The price of " -nl_has_spc "\n has " -risen "risen" -dropped "dropped" -spc_to_spc " to " -bang_bang_nl "!!\n" -prices_here_are "present prices per unit here are" -general_shortname "General" -shall_i_buy_sell "Shall I Buy, Sell, " -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 " -i_buy "I buy, " -shall_i_sell " shall\r\nI sell, " -too_much_cash "\r\nYou cannot carry so much cash" -ship_would_sink "\r\nYour ship would sink under the weight\r\nof your riches.\r\n" -deposit "deposit? " -withdraw "withdraw? " -assassinated_1 "you have been assassinated!" -assassinated_2 "As the masked figure plunges the blade\r\ninto your heart, he says:\r\n" -assassinated_3 "regrets to inform you\r\nthat your account has been terminated\r\nwith extreme prejudice." -has_sent "has sent " -braves_to_escort " braves\r\nto escort you to the Wu mansion" -wu_warn_1 "reminds you of the\r\nConfucian ideal of personal worthiness,\r\nand how this applies to paying one's\r\ndebts.\r\n" -wu_warn_2 "He is reminded of a fabled barbarian\r\nwho came to a bad end, after not caring\r\nfor his obligations.\r\n\nHe hopes no such fate awaits you, his\r\nfriend" -siezed_opium "The local authorities have seized your\r\nOpium cargo and have also fined you\r\n" -whouse_theft "Messenger reports large theft\r\nfrom warehouse" -has_sent_lieutenant "Li Yuen has sent a Lieutenant,\r\nTaipan. He says his admiral wishes\r\nto see you in Hong Kong, posthaste!\r\n" -beaten_robbed "You've been beaten up and\r\nrobbed of " -in_cash " in cash" diff --git a/taipan.c b/taipan.c index fbdf6ff..616a928 100644 --- a/taipan.c +++ b/taipan.c @@ -200,6 +200,14 @@ extern void redraw_port_stat(void); /* messages.c is generated by messages.pl */ #include "messages.c" +#ifdef GAME_HELP +# include "helpmsgs.h" +# include "helpmsgs.c" +#else +# define SET_HELP(x) +# define CLEAR_HELP +#endif + extern void __fastcall__ print_msg(const char *msg); /* old version of this used to just 'return randl()%clamp'. @@ -1549,6 +1557,7 @@ unsigned long get_num(void) { unsigned char count = 0; char input; + SET_HELP(get_amount_help); while((input = numgetc()) != '\n') { if(input == BKSP) { if(!count) continue; @@ -1575,6 +1584,7 @@ unsigned long get_num(void) { } } + CLEAR_HELP; num_buf[count] = '\0'; return strtonum(num_buf); } diff --git a/timed_getch.s b/timed_getch.s index 6ea1bff..f4c8431 100644 --- a/timed_getch.s +++ b/timed_getch.s @@ -101,6 +101,14 @@ finish_agetc: @nr: pla + .ifdef GAME_HELP + .import _print_game_help + cmp #'?' + bne notquestion + jmp _print_game_help +notquestion: + .endif + ; special cases cmp #$9b ; enter key, return as-is beq ok -- cgit v1.2.3