From 38fbe6b269192f151aeb9f171a895520d0fd6479 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Sat, 3 Apr 2021 18:14:50 -0400 Subject: Turbo fight mode, initial implementation --- console.s | 22 ++++++++++++++++++++++ taipan.c | 28 ++++++++++++++++++++-------- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/console.s b/console.s index 8ca93c2..af044d2 100644 --- a/console.s +++ b/console.s @@ -11,6 +11,7 @@ .importzp destptr ; from draw_lorcha.s .importzp sreg .import _cprintulong, _cputc, _cprint_taipan, _timed_getch, _orders + .import _turbo .ifdef CART_TARGET .segment "HIGHCODE" @@ -256,13 +257,34 @@ _plus_or_space: ; extern void set_orders(void); _set_orders: + lda _turbo ; in turbo fight mode? + beq @sowait ; no, so wait like usual + lda CH ; turbo = yes, did user hit a key? + cmp #$ff + bne @sowait ; yes, wait like usual + rts +@sowait: + lda #0 + sta _turbo jsr _timed_getch + ;cmp #$46 ; is it capital F? + ;beq @soturbo + ;cmp #$52 ; or capital R? + ;bne @sonoturbo + cmp #$60 ; capital letter? + bcs @sonoturbo ; nope, disable turbo +@soturbo: + ora #$20 ; convert to lowercase + sta _turbo ; enable turbo + ;;; sta COLOR4 ; for debugging +@sonoturbo: ldx #3 @solp: cmp orders_tbl-1,x beq @returnx dex bne @solp + stx _turbo ; invalid order, disable turbo rts @returnx: stx _orders diff --git a/taipan.c b/taipan.c index 8ee33c8..92c3d80 100644 --- a/taipan.c +++ b/taipan.c @@ -112,6 +112,11 @@ extern const char *port_stat_screen; port_stat_screen into screen RAM) */ char port_stat_dirty = 1; +/* boolean, turbo fighting mode. cleared on entry to sea_battle(), set + when user enters turbo mode. must be cleared by the caller, when + sea_battle() returns. */ +unsigned char turbo; + /* asm curses/conio funcs from console.s. Old C versions moved to oldcurses.c for reference. */ extern void clrtobot(void); @@ -1020,6 +1025,7 @@ char sea_battle(char id, int num_ships) { char choice, flashctr, num_on_screen, status; unsigned long amount, total; + turbo = 0; port_stat_dirty = 1; orders = 0; @@ -1082,7 +1088,7 @@ char sea_battle(char id, int num_ships) { for(i = 0; i <= 9; i++) { if (num_ships > num_on_screen) { if (ships_on_screen[i] == 0) { - jsleep(5); + if(!turbo) jsleep(5); ships_on_screen[i] = (randi() % ec) + 20; draw_lorcha(i); num_on_screen++; @@ -1101,6 +1107,7 @@ char sea_battle(char id, int num_ships) { if(orders == 0) { set_orders(); if(!orders) { + turbo = 0; gotox0y(3); clrtoeol(); cprint_taipan_comma(); @@ -1169,7 +1176,7 @@ char sea_battle(char id, int num_ships) { /* flash_lorcha must be called an even number of times to leave the lorcha in an unflashed state after. */ - for(flashctr = 0; flashctr < 6; flashctr++) { + if(!turbo) for(flashctr = 0; flashctr < 6; flashctr++) { flash_lorcha(targeted); jsleep(2); } @@ -1185,7 +1192,10 @@ char sea_battle(char id, int num_ships) { ships_on_screen[targeted] = 0; bad_joss_sound(); /* not sure this should be here */ - sink_lorcha(targeted); + if(turbo) + clear_lorcha(targeted); + else + sink_lorcha(targeted); plus_or_space(num_ships > num_on_screen); @@ -1195,7 +1205,7 @@ char sea_battle(char id, int num_ships) { if(num_ships == 0) { i += guns; } else { - jsleep(10); + if(!turbo) jsleep(10); } } gotox0y(3); @@ -1207,7 +1217,7 @@ char sea_battle(char id, int num_ships) { // cputs(" of the buggers"); print_msg(M_of_the_buggers); cprint_taipan_bang(); - bad_joss_sound(); + if(!turbo) bad_joss_sound(); } else { // cputs("Hit 'em, but didn't sink 'em"); print_msg(M_didnt_sink); @@ -1238,7 +1248,7 @@ char sea_battle(char id, int num_ships) { num_on_screen--; clear_lorcha(i); - jsleep(5); + if(!turbo) jsleep(5); } } if(num_ships == num_on_screen) { @@ -1257,10 +1267,12 @@ char sea_battle(char id, int num_ships) { print_msg(M_we_have_no_guns); cprint_taipan_bangbang(); set_orders(); + turbo = 0; } else if (orders == 3) { choice = 0; amount = 0; total = 0; + turbo = 0; gotox0y(3); // cputs("You have the following on board"); @@ -1425,7 +1437,7 @@ char sea_battle(char id, int num_ships) { cprint_taipan_bang(); set_orders(); - explosion(); + if(!turbo) explosion(); fight_stats(num_ships, orders); plus_or_space(num_ships > num_on_screen); @@ -1457,7 +1469,7 @@ char sea_battle(char id, int num_ships) { // cputs("The buggers hit a gun"); print_msg(M_buggers_hit_gun); cprint_taipan_bangbang(); - under_attack_sound(); + if(!turbo) under_attack_sound(); fight_stats(num_ships, orders); update_guns(); -- cgit v1.2.3