From 207e081b840992239d955d82b0ac01b8c86af543 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Sun, 13 Aug 2017 15:38:49 -0400 Subject: [PATCH] tfv: more file split up --- gr-sim/Makefile | 16 +- gr-sim/tfv.c | 371 +------------------------------------------ gr-sim/tfv_battle.c | 131 +++++++++++++++ gr-sim/tfv_flying.c | 67 ++++++++ gr-sim/tfv_info.c | 208 ++++++++++++++++++++++++ gr-sim/tfv_sprites.c | 176 ++++++++++++++++++++ gr-sim/tfv_sprites.h | 191 ++-------------------- gr-sim/tfv_zp.h | 11 ++ 8 files changed, 623 insertions(+), 548 deletions(-) create mode 100644 gr-sim/tfv_battle.c create mode 100644 gr-sim/tfv_flying.c create mode 100644 gr-sim/tfv_info.c create mode 100644 gr-sim/tfv_sprites.c diff --git a/gr-sim/Makefile b/gr-sim/Makefile index 5157130c..3f078f9b 100644 --- a/gr-sim/Makefile +++ b/gr-sim/Makefile @@ -31,9 +31,21 @@ text.o: text.c tfv_backgrounds.o: tfv_backgrounds.c tfv_backgrounds.h $(CC) $(CFLAGS) -c tfv_backgrounds.c +tfv_battle.o: tfv_battle.c + $(CC) $(CFLAGS) -c tfv_battle.c + +tfv_flying.o: tfv_flying.c + $(CC) $(CFLAGS) -c tfv_flying.c + +tfv_info.o: tfv_info.c + $(CC) $(CFLAGS) -c tfv_info.c + tfv_opener.o: tfv_opener.c tfv_utils.h $(CC) $(CFLAGS) -c tfv_opener.c +tfv_sprites.o: tfv_sprites.c tfv_sprites.c + $(CC) $(CFLAGS) -c tfv_sprites.c + tfv_title.o: tfv_title.c tfv_utils.h tfv_backgrounds.h $(CC) $(CFLAGS) -c tfv_title.c @@ -43,8 +55,8 @@ tfv_utils.o: tfv_utils.c tfv_utils.h tfv.o: tfv.c gr-sim.h tfv_backgrounds.h tfv_sprites.h $(CC) $(CFLAGS) -c tfv.c -tfv: tfv.o tfv_backgrounds.o tfv_opener.o tfv_title.o tfv_utils.o gr-sim.o - $(CC) $(LFLAGS) $(SDL_LIBS) -o tfv tfv.o tfv_backgrounds.o tfv_opener.o tfv_title.o tfv_utils.o gr-sim.o +tfv: tfv.o tfv_backgrounds.o tfv_battle.o tfv_flying.o tfv_info.o tfv_opener.o tfv_sprites.o tfv_title.o tfv_utils.o gr-sim.o + $(CC) $(LFLAGS) $(SDL_LIBS) -o tfv tfv.o tfv_backgrounds.o tfv_battle.o tfv_flying.o tfv_info.o tfv_opener.o tfv_sprites.o tfv_title.o tfv_utils.o gr-sim.o ### diff --git a/gr-sim/tfv.c b/gr-sim/tfv.c index cc1fdb78..7ba66c53 100644 --- a/gr-sim/tfv.c +++ b/gr-sim/tfv.c @@ -24,7 +24,7 @@ unsigned char map_x=5; char tfv_x=15,tfv_y=19; unsigned char ground_color; -static char nameo[9]; +char nameo[9]; static int name_screen(void) { @@ -195,375 +195,6 @@ static int name_screen(void) { return 0; } -static int flying(void) { - - int i; - unsigned char ch; - int xx,yy; - int direction; - - /************************************************/ - /* Flying */ - /************************************************/ - - gr(); - xx=17; yy=30; - color_equals(COLOR_BLACK); - - direction=0; - - color_equals(COLOR_MEDIUMBLUE); - - for(i=0;i<20;i++) { - hlin(1, 0, 40, i); - } - - color_equals(COLOR_DARKBLUE); - for(i=20;i<48;i++) { - hlin(1, 0, 40, i); - } - - while(1) { - ch=grsim_input(); - - if ((ch=='q') || (ch==27)) break; - if ((ch=='i') || (ch==APPLE_UP)) if (yy>20) yy-=2; - if ((ch=='m') || (ch==APPLE_DOWN)) if (yy<39) yy+=2; - if ((ch=='j') || (ch==APPLE_LEFT)) { - direction--; - if (direction<-1) direction=-1; - } - if ((ch=='k') || (ch==APPLE_RIGHT)) { - direction++; - if (direction>1) direction=1; - } - - gr_copy(0x800,0x400); - - if (direction==0) grsim_put_sprite(0,ship_forward,xx,yy); - if (direction==-1) grsim_put_sprite(0,ship_left,xx,yy); - if (direction==1) grsim_put_sprite(0,ship_right,xx,yy); - - grsim_update(); - - usleep(10000); - } - return 0; -} - - -static void game_over(void) { - - text(); - home(); - - /* Make a box around it? */ - - basic_htab(15); - basic_vtab(12); - basic_print("GAME OVER"); - - /* play the GROAN sound? */ - - grsim_update(); - - repeat_until_keypressed(); -} - -static void print_help(void) { - text(); - home(); - - basic_htab(1); - basic_vtab(1); - - basic_print("ARROW KEYS AND WASD MOVE\n"); - basic_print("SPACE BAR ACTION\n"); - basic_print("I INVENTORY\n"); - basic_print("M MAP\n"); - basic_print("Q QUITS\n"); - grsim_update(); - - repeat_until_keypressed(); - - gr(); -} - -static void show_map(void) { - gr(); - home(); - - grsim_unrle(worldmap_rle,0x800); - gr_copy(0x800,0x400); - - color_equals(COLOR_RED); - basic_plot(8+((map_x&0x3)*6)+(tfv_x/6),8+(((map_x&0xc)>>2)*6)+(tfv_y/6)); - - grsim_update(); - repeat_until_keypressed(); -} - - -/* - 1 2 3 4 -01234567890123456789012345678901234567890 -**************************************** 1 -* DEATER * LEVEL 1 * 2 -**************************************** 3 -* INVENTORY * STATS * 4 -**************************************** 5 -* * HP: 50/100 * 6 -* * MP: 0/0 * 7 -* * * 8 -* * EXPERIENCE: 0 * 9 -* * NEXT LEVEL: 16 * 10 -* * * 11 -* * MONEY: $1 * 12 0-256 -* * TIME: 00:00 * 13 -* * * 14 -* * * 15 -* * * 16 -* * * 17 -* * * 18 -* * * 19 -* * * 20 -* * * 21 -* * * 22 -* * * 23 -**************************************** 24 - -EXPERIENCE = 0...255 -LEVEL = EXPERIENCE / = 0...63 -NEXT LEVEL = -MONEY = 0...255 -MAX_HP = 32+EXPERIENCE (maxing at 255) -*/ - - -static char item_names1[8][15]={ - "CUPCAKE", // cafeteria lady - "CARROT", // capabara - "SMARTPASS", // metro worker - "ELF RUNES", // mree - "LIZBETH STAR", // Lizbeth - "KARTE SPIEL", // Frau - "GLAMDRING", // Gus - "VEGEMITE", // Nicole -}; - -static char item_names2[8][15]={ - "BLUE LED", // bird - "RED LED", // - "1K RESISTOR", // brown black red, Elaine - "4.7K RESISTOR", // yellow purple red, Tater - "9V BATTERY", // Cindy - "1.5V BATTERY", // Oscar - "LINUX CD", // john - "ARMY KNIFE", // Steve -}; - -static void print_info(void) { - int i; - - text(); - home(); - - /* Inverse Space */ - /* 0x30=COLOR */ - ram[0x30]=0x20; - - /* Draw boxes */ - hlin_double(0,0,40,0); - hlin_double(0,0,40,4); - hlin_double(0,0,40,8); - hlin_double(0,0,40,46); - - basic_vlin(0,48,0); - basic_vlin(0,48,20); - basic_vlin(0,48,39); - - basic_htab(3); - basic_vtab(2); - basic_print(nameo); - - basic_htab(23); - basic_print("LEVEL "); - print_u8(level); - - basic_htab(3); - basic_vtab(4); - basic_print("INVENTORY"); - basic_htab(23); - basic_print("STATS"); - - - for(i=0;i<8;i++) { - basic_htab(4); - basic_vtab(6+i); - if (items1&(1< FIGHT/LIMIT 21 -KILLER CRAB | DEATER 128/255 128 | ZAP 22 - | | REST 23 - | | RUN AWAY 24 - -Sound effects? - -List hits - -****** ** **** **** ** ** ****** **** ****** ****** ****** -** ** **** ** ** ** ** ** ** ** ** ** ** ** -** ** ** **** **** ****** **** ****** ** ****** ****** -** ** ** ** ** ** ** ** ** ** ** ** ** -****** ****** ****** **** ** **** ****** ** ****** ** - -*/ - -/* Enemies: */ -/* Killer Crab, Tree, Big Fish, Procrastinon */ - -/* Background depend on map location? */ -/* Room for guinea pig in party? */ - -/* Attacks -> HIT, ZAP, HEAL, RUNAWAY */ - - -static int do_battle(void) { - - int i,ch; - - int enemy_x=2; - //int enemy_hp=20; - - int tfv_x=34; - - home(); - gr(); - - basic_htab(1); - basic_vtab(22); - basic_normal(); - basic_print("KILLER CRAB"); - - basic_htab(27); - basic_vtab(21); - basic_print("HP"); - - basic_htab(34); - basic_vtab(21); - basic_print("LIMIT"); - - basic_htab(15); - basic_vtab(22); - basic_print("DEATER"); - - basic_htab(24); - basic_vtab(22); - print_byte(hp); - basic_print("/"); - print_byte(max_hp); - - basic_htab(34); - basic_vtab(22); - basic_inverse(); - for(i=0;i +#include +#include +#include + +#include "gr-sim.h" +#include "tfv_utils.h" +#include "tfv_zp.h" + +#include "tfv_sprites.h" +#include "tfv_backgrounds.h" + + +/* Do Battle */ + +/* Battle. +Forest? Grassland? Artic? Ocean? + + + + 1 2 3 +0123456789012345678901234567890123456789| +----------------------------------------| + | HP LIMIT | -> FIGHT/LIMIT 21 +KILLER CRAB | DEATER 128/255 128 | ZAP 22 + | | REST 23 + | | RUN AWAY 24 + +Sound effects? + +List hits + +****** ** **** **** ** ** ****** **** ****** ****** ****** +** ** **** ** ** ** ** ** ** ** ** ** ** ** +** ** ** **** **** ****** **** ****** ** ****** ****** +** ** ** ** ** ** ** ** ** ** ** ** ** +****** ****** ****** **** ** **** ****** ** ****** ** + +*/ + +/* Enemies: */ +/* Killer Crab, Tree, Big Fish, Procrastinon */ + +/* Background depend on map location? */ +/* Room for guinea pig in party? */ + +/* Attacks -> HIT, ZAP, HEAL, RUNAWAY */ + + +int do_battle(void) { + + int i,ch; + + int enemy_x=2; + //int enemy_hp=20; + + int tfv_x=34; + + home(); + gr(); + + basic_htab(1); + basic_vtab(22); + basic_normal(); + basic_print("KILLER CRAB"); + + basic_htab(27); + basic_vtab(21); + basic_print("HP"); + + basic_htab(34); + basic_vtab(21); + basic_print("LIMIT"); + + basic_htab(15); + basic_vtab(22); + basic_print("DEATER"); + + basic_htab(24); + basic_vtab(22); + print_byte(hp); + basic_print("/"); + print_byte(max_hp); + + basic_htab(34); + basic_vtab(22); + basic_inverse(); + for(i=0;i +#include +#include +#include + +#include "gr-sim.h" +#include "tfv_utils.h" +#include "tfv_zp.h" + +#include "tfv_sprites.h" + +int flying(void) { + + int i; + unsigned char ch; + int xx,yy; + int direction; + + /************************************************/ + /* Flying */ + /************************************************/ + + gr(); + xx=17; yy=30; + color_equals(COLOR_BLACK); + + direction=0; + + color_equals(COLOR_MEDIUMBLUE); + + for(i=0;i<20;i++) { + hlin(1, 0, 40, i); + } + + color_equals(COLOR_DARKBLUE); + for(i=20;i<48;i++) { + hlin(1, 0, 40, i); + } + + while(1) { + ch=grsim_input(); + + if ((ch=='q') || (ch==27)) break; + if ((ch=='i') || (ch==APPLE_UP)) if (yy>20) yy-=2; + if ((ch=='m') || (ch==APPLE_DOWN)) if (yy<39) yy+=2; + if ((ch=='j') || (ch==APPLE_LEFT)) { + direction--; + if (direction<-1) direction=-1; + } + if ((ch=='k') || (ch==APPLE_RIGHT)) { + direction++; + if (direction>1) direction=1; + } + + gr_copy(0x800,0x400); + + if (direction==0) grsim_put_sprite(0,ship_forward,xx,yy); + if (direction==-1) grsim_put_sprite(0,ship_left,xx,yy); + if (direction==1) grsim_put_sprite(0,ship_right,xx,yy); + + grsim_update(); + + usleep(10000); + } + return 0; +} + diff --git a/gr-sim/tfv_info.c b/gr-sim/tfv_info.c new file mode 100644 index 00000000..b854c0a6 --- /dev/null +++ b/gr-sim/tfv_info.c @@ -0,0 +1,208 @@ +#include +#include +#include +#include + +#include "gr-sim.h" +#include "tfv_utils.h" +#include "tfv_zp.h" + +#include "tfv_backgrounds.h" + +void game_over(void) { + + text(); + home(); + + /* Make a box around it? */ + + basic_htab(15); + basic_vtab(12); + basic_print("GAME OVER"); + + /* play the GROAN sound? */ + + grsim_update(); + + repeat_until_keypressed(); +} + +void print_help(void) { + text(); + home(); + + basic_htab(1); + basic_vtab(1); + + basic_print("ARROW KEYS AND WASD MOVE\n"); + basic_print("SPACE BAR ACTION\n"); + basic_print("I INVENTORY\n"); + basic_print("M MAP\n"); + basic_print("Q QUITS\n"); + grsim_update(); + + repeat_until_keypressed(); + + gr(); +} + +void show_map(void) { + + gr(); + home(); + + grsim_unrle(worldmap_rle,0x800); + gr_copy(0x800,0x400); + + color_equals(COLOR_RED); + basic_plot(8+((map_x&0x3)*6)+(tfv_x/6),8+(((map_x&0xc)>>2)*6)+(tfv_y/6)); + + grsim_update(); + repeat_until_keypressed(); +} + + +/* + 1 2 3 4 +01234567890123456789012345678901234567890 +**************************************** 1 +* DEATER * LEVEL 1 * 2 +**************************************** 3 +* INVENTORY * STATS * 4 +**************************************** 5 +* * HP: 50/100 * 6 +* * MP: 0/0 * 7 +* * * 8 +* * EXPERIENCE: 0 * 9 +* * NEXT LEVEL: 16 * 10 +* * * 11 +* * MONEY: $1 * 12 0-256 +* * TIME: 00:00 * 13 +* * * 14 +* * * 15 +* * * 16 +* * * 17 +* * * 18 +* * * 19 +* * * 20 +* * * 21 +* * * 22 +* * * 23 +**************************************** 24 + +EXPERIENCE = 0...255 +LEVEL = EXPERIENCE / = 0...63 +NEXT LEVEL = +MONEY = 0...255 +MAX_HP = 32+EXPERIENCE (maxing at 255) +*/ + + +static char item_names1[8][15]={ + "CUPCAKE", // cafeteria lady + "CARROT", // capabara + "SMARTPASS", // metro worker + "ELF RUNES", // mree + "LIZBETH STAR", // Lizbeth + "KARTE SPIEL", // Frau + "GLAMDRING", // Gus + "VEGEMITE", // Nicole +}; + +static char item_names2[8][15]={ + "BLUE LED", // bird + "RED LED", // + "1K RESISTOR", // brown black red, Elaine + "4.7K RESISTOR", // yellow purple red, Tater + "9V BATTERY", // Cindy + "1.5V BATTERY", // Oscar + "LINUX CD", // john + "ARMY KNIFE", // Steve +}; + +void print_info(void) { + int i; + + text(); + home(); + + /* Inverse Space */ + /* 0x30=COLOR */ + ram[0x30]=0x20; + + /* Draw boxes */ + hlin_double(0,0,40,0); + hlin_double(0,0,40,4); + hlin_double(0,0,40,8); + hlin_double(0,0,40,46); + + basic_vlin(0,48,0); + basic_vlin(0,48,20); + basic_vlin(0,48,39); + + basic_htab(3); + basic_vtab(2); + basic_print(nameo); + + basic_htab(23); + basic_print("LEVEL "); + print_u8(level); + + basic_htab(3); + basic_vtab(4); + basic_print("INVENTORY"); + basic_htab(23); + basic_print("STATS"); + + + for(i=0;i<8;i++) { + basic_htab(4); + basic_vtab(6+i); + if (items1&(1<