From 2df833b73723c287507d8530622b520d4f9d8c17 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Thu, 28 Jun 2018 20:44:32 -0400 Subject: [PATCH 1/2] tfv: add magic points --- gr-sim/tfv/tfv.c | 3 +- gr-sim/tfv/tfv_battle.c | 67 +++++++++++++++++++++++++++++++++++- gr-sim/tfv/tfv_info.c | 5 ++- gr-sim/tfv/tfv_zp.h | 75 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 147 insertions(+), 3 deletions(-) create mode 100644 gr-sim/tfv/tfv_zp.h diff --git a/gr-sim/tfv/tfv.c b/gr-sim/tfv/tfv.c index 89e4e158..45927466 100644 --- a/gr-sim/tfv/tfv.c +++ b/gr-sim/tfv/tfv.c @@ -12,7 +12,8 @@ /* stats */ unsigned char level=0; -unsigned char hp=50,max_hp=100; +unsigned char hp=100,max_hp=100; +unsigned char mp=50,max_mp=50; unsigned char limit=2; unsigned char money=0,experience=0; unsigned char time_hours=0,time_minutes=0; diff --git a/gr-sim/tfv/tfv_battle.c b/gr-sim/tfv/tfv_battle.c index dce1e7de..0bb116a1 100644 --- a/gr-sim/tfv/tfv_battle.c +++ b/gr-sim/tfv/tfv_battle.c @@ -23,7 +23,7 @@ Plain Fish BUBBLE FIRE ICE Evil Tree RND-16 LEAVE FIRE ICE - Wood Elf SING MALAISE FIRE + Wood Elf SING MALAISE BOLT Giant Bee RND-64 BUZZSAW ICE NONE Procrastinon RND-32 PUTOFF NONE MALAISE @@ -42,6 +42,7 @@ Forest? Grassland? Artic? Ocean? SUMMONS -> METROCAT MAGIC -> HEAL FIRE ICE MALAISE + BOLT LIMIT -> SLICE ZAP DROP @@ -75,6 +76,7 @@ List hits #define MAGIC_FIRE 1 #define MAGIC_ICE 2 #define MAGIC_MALAISE 4 +#define MAGIC_BOLT 8 struct enemy_type { char *name; @@ -94,6 +96,69 @@ static struct enemy_type enemies[8]={ .resist=MAGIC_FIRE, .sprite=killer_crab, }, + [1]= { + .name="Plain Fish", + .hp_base=10, + .hp_mask=0x1f, + .attack_name="Bubble", + .weakness=MAGIC_FIRE, + .resist=MAGIC_ICE, + .sprite=killer_crab, + }, + [2]= { + .name="Evil Tree", + .hp_base=10, + .hp_mask=0x1f, + .attack_name="Leaves", + .weakness=MAGIC_FIRE, + .resist=MAGIC_ICE, + .sprite=killer_crab, + }, + [3]= { + .name="Wood Elf", + .hp_base=10, + .hp_mask=0x1f, + .attack_name="Song", + .weakness=MAGIC_MALAISE, + .resist=MAGIC_BOLT, + .sprite=killer_crab, + }, + [4]= { + .name="Giant Bee", + .hp_base=10, + .hp_mask=0x1f, + .attack_name="Buzzsaw", + .weakness=MAGIC_ICE, + .resist=MAGIC_NONE, + .sprite=killer_crab, + }, + [5]= { + .name="Procrastinon", + .hp_base=10, + .hp_mask=0x1f, + .attack_name="Putoff", + .weakness=MAGIC_NONE, + .resist=MAGIC_MALAISE, + .sprite=killer_crab, + }, + [6]= { + .name="Ice Fish", + .hp_base=10, + .hp_mask=0x1f, + .attack_name="Auger", + .weakness=MAGIC_FIRE, + .resist=MAGIC_ICE, + .sprite=killer_crab, + }, + [7]= { + .name="Evil Penguin", + .hp_base=10, + .hp_mask=0x1f, + .attack_name="Waddle", + .weakness=MAGIC_FIRE, + .resist=MAGIC_ICE, + .sprite=killer_crab, + }, }; diff --git a/gr-sim/tfv/tfv_info.c b/gr-sim/tfv/tfv_info.c index f5073e33..075bb786 100644 --- a/gr-sim/tfv/tfv_info.c +++ b/gr-sim/tfv/tfv_info.c @@ -121,7 +121,10 @@ void print_info(void) { basic_htab(23); basic_vtab(7); - basic_print("MP: 0/0"); + basic_print("MP: "); + print_u8(mp); + basic_print("/"); + print_u8(max_mp); basic_htab(23); basic_vtab(9); diff --git a/gr-sim/tfv/tfv_zp.h b/gr-sim/tfv/tfv_zp.h new file mode 100644 index 00000000..b4e4898d --- /dev/null +++ b/gr-sim/tfv/tfv_zp.h @@ -0,0 +1,75 @@ +/* Page Zero */ + +#define COLOR1 0x00 +#define COLOR2 0x01 +#define MATCH 0x02 +#define XX 0x03 +#define YY 0x04 +#define YADD 0x05 +#define LOOP 0x06 +#define MEMPTRL 0x07 +#define MEMPTRH 0x08 +#define DISP_PAGE 0x09 +#define DRAW_PAGE 0x0a +#define TEMPY 0xfb +#define OUTL 0xfe +#define OUTH 0xff + +/* Zero page addresses */ +#define WNDLFT 0x20 +#define WNDWDTH 0x21 +#define WNDTOP 0x22 +#define WNDBTM 0x23 +#define CH 0x24 +#define CV 0x25 +#define GBASL 0x26 +#define GBASH 0x27 +#define BASL 0x28 +#define BASH 0x29 +#define BAS2L 0x2A +#define BAS2H 0x2B +#define H2 0x2C +#define V2 0x2D +#define MASK 0x2E +#define COLOR 0x30 +#define INVFLG 0x32 +#define YSAV 0x34 +#define YSAV1 0x35 +#define CSWL 0x36 +#define CSWH 0x37 + + + +/* stats */ +extern unsigned char level; +extern unsigned char hp,max_hp; +extern unsigned char mp,max_mp; +extern unsigned char limit; +extern unsigned char money,experience; +extern unsigned char time_hours,time_minutes; +extern unsigned char items1,items2; +extern unsigned char steps; + + +struct fixed_type { + char i; + unsigned char f; +}; + +int opening(void); +int title(void); +int flying(void); + +void game_over(void); +void show_map(void); +void print_info(void); +void print_help(void); + +int name_screen(void); + +int do_battle(void); + +int world_map(void); + +int city_map(void); + From 0ab2dd2627cfed92eb880926d8ea2fd8ebd371c8 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Fri, 29 Jun 2018 00:02:40 -0400 Subject: [PATCH 2/2] tfv: can be attacked now --- gr-sim/tfv/tfv_battle.c | 119 +++++++++++++++++++++++++++++++--------- 1 file changed, 94 insertions(+), 25 deletions(-) diff --git a/gr-sim/tfv/tfv_battle.c b/gr-sim/tfv/tfv_battle.c index 0bb116a1..441a745f 100644 --- a/gr-sim/tfv/tfv_battle.c +++ b/gr-sim/tfv/tfv_battle.c @@ -77,6 +77,7 @@ List hits #define MAGIC_ICE 2 #define MAGIC_MALAISE 4 #define MAGIC_BOLT 8 +#define MAGIC_HEAL 16 struct enemy_type { char *name; @@ -120,7 +121,7 @@ static struct enemy_type enemies[8]={ .hp_mask=0x1f, .attack_name="Song", .weakness=MAGIC_MALAISE, - .resist=MAGIC_BOLT, + .resist=MAGIC_BOLT|MAGIC_HEAL, .sprite=killer_crab, }, [4]= { @@ -190,6 +191,42 @@ static int attack(int enemy_x,int enemy_type) { return 10; } +static int enemy_attack(int enemy_x,int enemy_type,int tfv_x) { + + int ax=enemy_x; + + while(ax<30) { + + // put attack name on + // occasionally attack with that enemy's power? + // occasionally heal self? + + gr_copy_to_current(0xc00); + + // draw first so behind enemy + grsim_put_sprite(tfv_stand_left,tfv_x,20); + grsim_put_sprite(tfv_led_sword,tfv_x-5,20); + + if (ax&1) { + grsim_put_sprite(enemies[enemy_type].sprite,ax,20); + } + else { + grsim_put_sprite(enemies[enemy_type].sprite,ax,20); + } + + + + + page_flip(); + + ax+=1; + + usleep(20000); + } + + return 10; +} + static int victory_dance(void) { @@ -237,26 +274,9 @@ static int victory_dance(void) { return 0; } -int do_battle(void) { +static int draw_battle_bottom(int enemy_type) { - int i,ch; - - int enemy_x=2; - int enemy_type=0; - int saved_drawpage; - int enemy_hp=0; - - int ax=34; - - /* Setup Enemy */ - // enemy_type=X - // ranom, with weight toward proper terrain - - /* Setup Enemy HP */ - enemy_hp=enemies[enemy_type].hp_base+ - (rand()&enemies[enemy_type].hp_mask); - - saved_drawpage=ram[DRAW_PAGE]; + int i; clear_bottom(); @@ -301,6 +321,36 @@ int do_battle(void) { hlin_double(ram[DRAW_PAGE],12,12,i); } + return 0; +} + + + +int do_battle(void) { + + int i,ch; + + int enemy_x=2; + int enemy_type=0; + int saved_drawpage; + int enemy_hp=0; + + int ax=34; + int battle_count=50; + int enemy_count=30; + + /* Setup Enemy */ + // enemy_type=X + // random, with weight toward proper terrain + + /* Setup Enemy HP */ + enemy_hp=enemies[enemy_type].hp_base+ + (rand()&enemies[enemy_type].hp_mask); + + + saved_drawpage=ram[DRAW_PAGE]; + + draw_battle_bottom(enemy_type); /* Draw background */ @@ -330,17 +380,36 @@ int do_battle(void) { page_flip(); - ch=grsim_input(); - if (ch=='q') break; - - if (ch==' ') enemy_hp-=attack(enemy_x,enemy_type); - usleep(100000); + ch=grsim_input(); + if (ch=='q') return 0; + + if (enemy_count==0) { + hp-=enemy_attack(enemy_x,enemy_type,ax); + // decrement HP + // update limit count + // redraw bottom + enemy_count=50; + } + else { + enemy_count--; + } + + if (battle_count==0) { + if (ch==' ') { + enemy_hp-=attack(enemy_x,enemy_type); + battle_count=50; + } + } else { + battle_count--; + } + if (enemy_hp<0) { victory_dance(); break; } + } ram[DRAW_PAGE]=PAGE0;