From 44047ca3bbbef0cf7bdc96cd3634f807448a0ac2 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Sat, 16 Sep 2000 19:23:00 -0400 Subject: [PATCH] version 2.9.3 --- CHANGES | 12 + Makefile | 52 +- about.c | 106 ++++ about.h | 1 + credits.c | 136 +++++ credits.h | 1 + help.c | 50 ++ help.h | 1 + hiscore.c | 75 +++ hiscore.h | 2 + level_1.c | 139 ++--- level_2.c | 95 ++- loadgame.c | 61 ++ loadgame.h | 1 + menu_tools.c | 25 + menu_tools.h | 3 + options.c | 56 ++ options.h | 1 + playgame.c | 61 ++ playgame.h | 1 + quit.c | 44 ++ quit.h | 1 + savegame.c | 98 +++ sdl_svmwgraph.c | 662 -------------------- sdl_svmwgraph.h | 68 --- sidebar.c | 148 +++++ sidebar.h | 4 + sound.c | 5 +- story.c | 389 ++++++++++++ story.h | 1 + svmwgraph/Makefile | 19 +- svmwgraph/sdl_svmwgraph.c | 93 ++- svmwgraph/sdl_svmwgraph.h | 8 + svmwgraph/svmwgraph.c | 511 ---------------- svmwgraph/svmwgraph.h | 59 +- svmwgraph/vmw_core.c | 9 +- svmwgraph/vmw_flip.c | 6 +- svmwgraph/vmw_paintpro.c | 9 - svmwgraph/vmw_palette.c | 9 + svmwgraph/vmw_setup.c | 67 +- svmwgraph/vmw_sprite.c | 4 +- tb1.c | 137 ++--- tb1_state.h | 9 +- tb_keypress.h | 11 - tblib.c | 1220 +------------------------------------ tblib.h | 24 +- tbomb1.tb1 | Bin 28650 -> 0 bytes vmw_sprite.h | 10 - 48 files changed, 1725 insertions(+), 2779 deletions(-) create mode 100644 about.c create mode 100644 about.h create mode 100644 credits.c create mode 100644 credits.h create mode 100644 help.c create mode 100644 help.h create mode 100644 hiscore.c create mode 100644 hiscore.h create mode 100644 loadgame.c create mode 100644 loadgame.h create mode 100644 menu_tools.c create mode 100644 menu_tools.h create mode 100644 options.c create mode 100644 options.h create mode 100644 playgame.c create mode 100644 playgame.h create mode 100644 quit.c create mode 100644 quit.h create mode 100644 savegame.c delete mode 100644 sdl_svmwgraph.c delete mode 100644 sdl_svmwgraph.h create mode 100644 sidebar.c create mode 100644 sidebar.h create mode 100644 story.c create mode 100644 story.h create mode 100644 svmwgraph/sdl_svmwgraph.h delete mode 100644 svmwgraph/svmwgraph.c delete mode 100644 tb_keypress.h delete mode 100644 tbomb1.tb1 delete mode 100644 vmw_sprite.h diff --git a/CHANGES b/CHANGES index 2bb8a38..61d0af7 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,15 @@ +16 September 2000 ++ Re-wrote completely libsvmwgraph... making it an actual lib, + removing all sdl dependencies, added hooks so that any arbitrary + graphics platform can be used. This was lots of fun. ++ Split "tblib.c" up into about 20 component functions ++ Debugged the problems from the svmwgraph change.. suprisingly it + was very few. ++ Started adding features that depended on the svmwgraph rewrite + +12 September 2000 ++ Added support for level2 + 4 September 2000 + Have about 90% of the game running now on SDL. What a fun way to spend labor day weekend. diff --git a/Makefile b/Makefile index 9571e79..077eeee 100644 --- a/Makefile +++ b/Makefile @@ -1,33 +1,63 @@ -INCLUDE= -Wall -I/usr/local/include/SDL -I/usr/local/include +INCLUDE= -O2 -Wall -I/usr/local/include/SDL -I/usr/local/include LIBS= -lSDL -lSDL_mixer -L/usr/X11R6/lib -lX11 -lpthread all: tb1 -tb1: tb1.o sdl_svmwgraph.o vmw_sprite.o tblib.o level_1.o level_2.o sound.o - gcc -o tb1 tb1.o sdl_svmwgraph.o vmw_sprite.o tblib.o level_1.o level_2.o sound.o $(LIBS) - +tb1: tb1.o ./svmwgraph/libsvmwgraph.a about.o credits.o help.o hiscore.o level_1.o level_2.o loadgame.o menu_tools.o options.o playgame.o quit.o savegame.o sidebar.o sound.o story.o tblib.o + gcc -o tb1 tb1.o about.o credits.o help.o hiscore.o level_1.o level_2.o loadgame.o menu_tools.o options.o playgame.o quit.o savegame.o sidebar.o sound.o story.o tblib.o ./svmwgraph/libsvmwgraph.a $(LIBS) + tb1.o: tb1.c gcc -c tb1.c $(INCLUDE) -tblib.o: tblib.c - gcc -c tblib.c $(INCLUDE) +about.o: about.c + gcc -c about.c $(INCLUDE) + +credits.o: credits.c + gcc -c credits.c $(INCLUDE) -sdl_svmwgraph.o: sdl_svmwgraph.c - gcc -c sdl_svmwgraph.c $(INCLUDE) +help.o: help.c + gcc -c help.c $(INCLUDE) -vmw_sprite.o: vmw_sprite.c - gcc -c vmw_sprite.c $(INCLUDE) +hiscore.o: hiscore.c + gcc -c hiscore.c $(INCLUDE) level_1.o: level_1.c gcc -c level_1.c $(INCLUDE) level_2.o: level_2.c gcc -c level_2.c $(INCLUDE) - + +loadgame.o: loadgame.c + gcc -c loadgame.c $(INCLUDE) + +menu_tools.o: menu_tools.c + gcc -c menu_tools.c $(INCLUDE) + +options.o: options.c + gcc -c options.c $(INCLUDE) + +playgame.o: playgame.c + gcc -c playgame.c $(INCLUDE) + +quit.o: quit.c + gcc -c quit.c $(INCLUDE) + +savegame.o: savegame.c + gcc -c savegame.c $(INCLUDE) + +sidebar.o: sidebar.c + gcc -c sidebar.c $(INCLUDE) + sound.o: sound.c gcc -c sound.c $(INCLUDE) +story.o: story.c + gcc -c story.c $(INCLUDE) + +tblib.o: tblib.c + gcc -c tblib.c $(INCLUDE) + clean: rm tb1 *.o *~ diff --git a/about.c b/about.c new file mode 100644 index 0000000..db91a9b --- /dev/null +++ b/about.c @@ -0,0 +1,106 @@ + +#include + +#include "svmwgraph/svmwgraph.h" +#include "tb1_state.h" +#include "tblib.h" +#include "menu_tools.h" + +void about(struct tb1_state *game_state) +{ + int pagenum=1,firstime=0,oldpagenum=0,numpages=4,ch=0; + char tempst[300]; + + vmwFont *tb1_font; + vmwVisual *target1,*target2; + + tb1_font=game_state->graph_state->default_font; + target1=game_state->virtual_1; + target2=game_state->virtual_2; + + vmwClearScreen(target1,0); + + vmwLoadPicPacked(0,0,target2,1,1, + tb1_data_file("register.tb1",game_state->path_to_data)); + vmwLoadPicPacked(0,0,target1,1,0, /* Load Palette */ + tb1_data_file("register.tb1",game_state->path_to_data)); + + while ((ch!=VMW_ESCAPE)&&(ch!='q')){ + while(( (ch=vmwGetInput())==0) && (firstime)); + if(!firstime) firstime=1; + if ((ch==' ') || (ch==VMW_ENTER)) pagenum++; + if ((ch==VMW_RIGHT) || (ch==VMW_DOWN) || (ch==VMW_PGDN)) pagenum++; + if ((ch==VMW_LEFT) || (ch==VMW_UP) || (ch==VMW_PGUP)) pagenum--; + if (pagenum>4) pagenum=1; + if (pagenum<1) pagenum=4; + if (oldpagenum!=pagenum){ + if (pagenum==1) { + vmwFlipVirtual(target1,target2,320,200); + coolbox(0,0,319,199,0,target1); + shadowrite(" INFORMATION",10,10,9,1,tb1_font,target1); + shadowrite("I STARTED THIS GAME IN LATE",70,30,9,1,tb1_font,target1); + shadowrite(" 1994, WHEN I WAS 16.",70,40,9,1,tb1_font,target1); + shadowrite("I WROTE THIS GAME ENTIRELY IN",75,50,9,1,tb1_font,target1); + shadowrite(" MY FREE TIME.",74,60,9,1,tb1_font,target1); + shadowrite(" ^(AUTHOR 1N 1995)",10,70,10,2,tb1_font,target1); + shadowrite("ORIGINALLY THIS GAME WAS CODED IN",10,90,12,4,tb1_font,target1); + shadowrite(" TURBO PASCAL AND IN-LINE ASSEMBLY",10,100,12,4,tb1_font,target1); + shadowrite(" OPTIMIZED TO RUN ON A 386. NOW I",10,110,12,4,tb1_font,target1); + shadowrite(" HAVE PORTED IT TO LINUX AND SDL.",10,120,12,4,tb1_font,target1); + shadowrite(" IN THAT SPIRIT I HAVE NOW GPL'ED",10,130,12,4,tb1_font,target1); + shadowrite(" THE CODE.",10,140,12,4,tb1_font,target1); + } else coolbox(0,0,319,199,1,target1); + + if (pagenum==2){ + shadowrite("MY NAME IS VINCE WEAVER",10,10,10,2,tb1_font,target1); + shadowrite(" VISIT MY TALKER",10,20,10,2,tb1_font,target1); + shadowrite(" DERANGED.STUDENT.UMD.EDU 7000",10,30,10,2,tb1_font,target1); + shadowrite(" UP WHENEVER SCHOOL IS IN SESSION",10,40,10,2,tb1_font,target1); + shadowrite("UNTIL DECEMBER OF 2000 I WILL BE",10,60,13,5,tb1_font,target1); + shadowrite(" ATTENDING COLLEGE, AT THE UNIVERSITY",10,70,13,5,tb1_font,target1); + shadowrite(" OF MARYLAND, COLLEGE PARK.",10,80,13,5,tb1_font,target1); + shadowrite("GET THE NEWEST VERSION OF TB1 AT",10,100,11,3,tb1_font,target1); + shadowrite(" THE OFFICIAL TB1 WEB SITE:",10,110,11,3,tb1_font,target1); + shadowrite(" http://www.glue.umd.edu/~weave/tb1/",10,120,11,3,tb1_font,target1); + shadowrite("I CAN BE CONTACTED VIA E-MAIL AT:",10,140,12,4,tb1_font,target1); + shadowrite(" WEAVE@ENG.UMD.EDU",10,150,9,1,tb1_font,target1); + shadowrite("FEEL FREE TO SEND COMMENTS.",10,160,12,4,tb1_font,target1); + } + + if (pagenum==3){ + shadowrite("OTHER VMW SOFTWARE PRODUCTIONS:",10,10,15,7,tb1_font,target1); + shadowrite(" PAINTPRO:",10,30,13,5,tb1_font,target1); + shadowrite(" LOAD AND SAVE GRAPHICS PICTURES",10,40,13,5,tb1_font,target1); + shadowrite(" LINUX_LOGO",10,50,11,3,tb1_font,target1); + shadowrite(" A USERLAND ANSI LOGIN DISPLAY",10,60,11,3,tb1_font,target1); + shadowrite(" SPACEWAR III:",10,70,9,1,tb1_font,target1); + shadowrite(" NEVER COMPLETED GAME",10,80,9,1,tb1_font,target1); + shadowrite(" AITAS: (ADVENTURES IN TIME AND SPACE)",10,90,12,4,tb1_font,target1); + shadowrite(" A GAME I'VE BEEN WANTING TO WRITE",10,100,12,4,tb1_font,target1); + shadowrite(" FOR 5 YEARS. [INCOMPLETE]",10,110,12,4,tb1_font,target1); + shadowrite(" FONT_PRINT",10,120,9,1,tb1_font,target1); + shadowrite(" PRINT VGA FONTS IN DOS AND LINUX",10,130,9,1,tb1_font,target1); + shadowrite(" SEABATTLE:",10,140,13,5,tb1_font,target1); + shadowrite(" A BATTLESHIP CLONE CODED IN C",10,150,13,5,tb1_font,target1); + } + + if (pagenum==4){ + shadowrite("DISCLAIMER:",10,10,12,14,tb1_font,target1); + shadowrite("* MY PROGRAMS SHOULD NOT DAMAGE YOUR *",8,30,12,4,tb1_font,target1); + shadowrite("* COMPUTER IN ANY WAY. PLEASE DON'T *",8,40,12,4,tb1_font,target1); + shadowrite("* USE MY SOFTWARE IN CRITICAL *",8,50,12,4,tb1_font,target1); + shadowrite("* APPLICATIONS LIKE LIFE-SUPPORT *",8,60,12,4,tb1_font,target1); + shadowrite("* EQUIPMENT, DEFLECTOR SHIELDS, OR *",8,70,12,4,tb1_font,target1); + shadowrite("* AUTOMOBILE ENGINES. *",8,80,12,4,tb1_font,target1); + shadowrite("* LINUX FOREVER! THE OS FOR EVERYONE *",8,90,12,4,tb1_font,target1); + shadowrite("% WARRANTY ESPECIALLY VOID IF USED %",8,110,11,3,tb1_font,target1); + shadowrite("% ON ANY MICROSOFT(tm) OS (YUCK) %",8,120,11,3,tb1_font,target1); + } + sprintf(tempst,"Page %d of %d: ESC QUITS",pagenum,numpages); + shadowrite(tempst,50,180,15,7,tb1_font,target1); + vmwBlitMemToDisplay(game_state->graph_state,target1); + oldpagenum=pagenum; + } + } +} + diff --git a/about.h b/about.h new file mode 100644 index 0000000..855a892 --- /dev/null +++ b/about.h @@ -0,0 +1 @@ +void about(struct tb1_state *game_state); diff --git a/credits.c b/credits.c new file mode 100644 index 0000000..321a406 --- /dev/null +++ b/credits.c @@ -0,0 +1,136 @@ + +#include +#include + +#include "svmwgraph/svmwgraph.h" +#include "tb1_state.h" +#include "tblib.h" + +void credits(struct tb1_state *game_state) +{ + + int i,keypressed=0; + + vmwFont *tb1_font; + + tb1_font=game_state->graph_state->default_font; + + vmwDrawBox(0,0,320,400,0,game_state->virtual_2); + + vmwTextXY(" TOM BOMBEM",0,210,4,0,1,tb1_font,game_state->virtual_2); + vmwTextXY(" INVASION OF THE INANIMATE OBJECTS",0,220,4,0,1,tb1_font,game_state->virtual_2); + vmwTextXY(" PROGRAMMING",0,240,9,0,1,tb1_font,game_state->virtual_2); + vmwTextXY(" VINCENT M WEAVER",0,260,9,0,1,tb1_font,game_state->virtual_2); + vmwTextXY(" GRAPHICS",0,290,10,0,1,tb1_font,game_state->virtual_2); + vmwTextXY(" VINCENT M WEAVER",0,310,10,0,1,tb1_font,game_state->virtual_2); + vmwTextXY(" SOUND EFFECTS",0,340,11,0,1,tb1_font,game_state->virtual_2); + vmwTextXY(" VINCENT M WEAVER",0,360,11,0,1,tb1_font,game_state->virtual_2); + vmwTextXY(" GRAPHICS INSPIRATION",0,390,12,0,1,tb1_font,game_state->virtual_2); + + for(i=0;i<200;i++){ + vmwArbitraryCrossBlit(game_state->virtual_2,0,i,320,200, + game_state->virtual_1,0,0); + vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1); + usleep(30000); + if (vmwGetInput()) { + keypressed=1; break; + } + } + + vmwArbitraryCrossBlit(game_state->virtual_2,0,200,320,200, + game_state->virtual_1,0,0); + vmwArbitraryCrossBlit(game_state->virtual_1,0,0,320,200, + game_state->virtual_2,0,0); + vmwDrawBox(0,200,320,200,0,game_state->virtual_2); + + vmwTextXY(" JEFF WARWICK",0,210,12,0,1,tb1_font,game_state->virtual_2); + vmwTextXY(" GENERAL HELP",0,240,13,0,1,tb1_font,game_state->virtual_2); + vmwTextXY(" JOHN CLEMENS",0,260,13,0,1,tb1_font,game_state->virtual_2); + vmwTextXY(" JASON GRIMM",0,280,13,0,1,tb1_font,game_state->virtual_2); + vmwTextXY(" PCGPE AUTHORS, esp",0,310,14,0,1,tb1_font,game_state->virtual_2); + vmwTextXY(" GRANT SMITH",0,330,14,0,1,tb1_font,game_state->virtual_2); + vmwTextXY(" DOS SOUND BLASTER CODE",0,360,15,0,1,tb1_font,game_state->virtual_2); + vmwTextXY(" ETHAN BRODSKY",0,380,15,0,1,tb1_font,game_state->virtual_2); + + if (!keypressed) for(i=0;i<200;i++){ + vmwArbitraryCrossBlit(game_state->virtual_2,0,i,320,200, + game_state->virtual_1,0,0); + vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1); + usleep(30000); + if (vmwGetInput()) { + keypressed=1; break; + } + } + + vmwArbitraryCrossBlit(game_state->virtual_2,0,200,320,200, + game_state->virtual_2,0,0); + + vmwDrawBox(0,200,320,200,0,game_state->virtual_2); + + vmwTextXY(" GLTRON SOUND CODE",0,210,12,0,1,tb1_font,game_state->virtual_2); + vmwTextXY(" ANDREAS UMBACH",0,230,12,0,1,tb1_font,game_state->virtual_2); + vmwTextXY(" THANKS TO ALL THE DEVELOPERS",0,260,13,0,1,tb1_font,game_state->virtual_2); + vmwTextXY(" OF LINUX, ESPECIALLY",0,280,13,0,1,tb1_font,game_state->virtual_2); + vmwTextXY(" LINUS TORVALDS",0,300,13,0,1,tb1_font,game_state->virtual_2); + vmwTextXY(" ALSO SPECIAL THANKS TO",0,330,14,0,1,tb1_font,game_state->virtual_2); + vmwTextXY(" THE SDL DEVELOPMENT TEAM",0,350,14,0,1,tb1_font,game_state->virtual_2); + + if (!keypressed) for(i=0;i<200;i++){ + vmwArbitraryCrossBlit(game_state->virtual_2,0,i,320,200, + game_state->virtual_1,0,0); + vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1); + usleep(30000); + if (vmwGetInput()) { + keypressed=1; break; + } + } + + vmwArbitraryCrossBlit(game_state->virtual_2,0,200,320,200, + game_state->virtual_2,0,0); + + vmwDrawBox(0,200,320,200,0,game_state->virtual_2); + + vmwTextXY(" INSPIRATION",0,210,9,0,1,tb1_font,game_state->virtual_2); + vmwTextXY(" DOUGLAS ADAMS",0,230,9,0,1,tb1_font,game_state->virtual_2); + vmwTextXY(" CLIFF STOLL",0,250,9,0,1,tb1_font,game_state->virtual_2); + vmwTextXY(" ARTHUR C CLARKE",0,270,9,0,1,tb1_font,game_state->virtual_2); + vmwTextXY(" ISAAC ASIMOV",0,290,9,0,1,tb1_font,game_state->virtual_2); + vmwTextXY(" GORDON KORMAN",0,310,9,0,1,tb1_font,game_state->virtual_2); + vmwTextXY(" THANKS TO ALL THE AGENTS",0,340,10,0,1,tb1_font,game_state->virtual_2); + vmwTextXY(" B,D,JL,L,N,P,S,W,PM,E,G,TK",0,360,10,0,1,tb1_font,game_state->virtual_2); + vmwTextXY(" AND ESPECIALLY MP",0,380,10,0,1,tb1_font,game_state->virtual_2); + + if (!keypressed) for(i=0;i<200;i++){ + vmwArbitraryCrossBlit(game_state->virtual_2,0,i,320,200, + game_state->virtual_1,0,0); + vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1); + usleep(30000); + if (vmwGetInput()) { + keypressed=1; break; + } + } + vmwArbitraryCrossBlit(game_state->virtual_2,0,200,320,200, + game_state->virtual_2,0,0); + + vmwLoadPicPacked(0,200,game_state->virtual_2,1,1, + tb1_data_file("tbomb1.tb1",game_state->path_to_data)); + + if (keypressed) { + vmwDrawBox(0,0,320,200,0,game_state->virtual_2); + } + + for(i=0;i<200;i++){ + vmwArbitraryCrossBlit(game_state->virtual_2,0,i,320,200, + game_state->virtual_1,0,0); + vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1); + usleep(30000); + if (vmwGetInput()) { + break; + } + } + vmwArbitraryCrossBlit(game_state->virtual_2,0,200,320,200, + game_state->virtual_1,0,0); + + vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1); + +} diff --git a/credits.h b/credits.h new file mode 100644 index 0000000..3a45715 --- /dev/null +++ b/credits.h @@ -0,0 +1 @@ +void credits(struct tb1_state *game_state); diff --git a/help.c b/help.c new file mode 100644 index 0000000..4fa6205 --- /dev/null +++ b/help.c @@ -0,0 +1,50 @@ +#include +#include +#include "svmwgraph/svmwgraph.h" +#include "tb1_state.h" +#include "menu_tools.h" + +void help(struct tb1_state *game_state) +{ + vmwVisual *vis; + vmwFont *tb1_font; + + vis=game_state->virtual_1; + tb1_font=game_state->graph_state->default_font; + + coolbox(0,0,319,199,1,vis); + vmwTextXY("HELP",144,10,4,0,0,tb1_font,vis); + vmwTextXY("--------------------------------------",10,20, + 12,0,0,tb1_font,vis); + vmwTextXY("IN THE GAME:",10,30,4,0,0,tb1_font,vis); + vmwTextXY(" ARROWS MANUEVER",10,40, + 4,0,0,tb1_font,vis); + vmwTextXY(" SPACE BAR FIRES MISSILES",10,50, + 4,0,0,tb1_font,vis); + vmwTextXY(" F2 SAVES GAME",10,60, + 4,0,0,tb1_font,vis); + vmwTextXY(" P=PAUSE S=TOGGLE SOUND ESC=QUIT",10,70, + 4,0,0,tb1_font,vis); + vmwTextXY("--------------------------------------",10,80, + 12,0,0,tb1_font,vis); + vmwTextXY("MISSION: SHOOT THE INANIMATE OBJECTS",10,90, + 4,0,0,tb1_font,vis); + vmwTextXY(" WHY? WATCH THE STORY!",10,100, + 4,0,0,tb1_font,vis); + vmwTextXY("--------------------------------------",10,110, + 12,0,0,tb1_font,vis); + vmwTextXY("THE SPACE BAR SPEEDS UP MOVIE SCENES",10,120, + 4,0,0,tb1_font,vis); + vmwTextXY("ESC QUITS THEM",10,130, + 4,0,0,tb1_font,vis); + vmwTextXY("--------------------------------------",10,140, + 12,0,0,tb1_font,vis); + vmwTextXY(" SEE \"README\" FOR MORE HELP/INFO",10,150, + 4,0,0,tb1_font,vis); + vmwTextXY("--------------------------------------",10,160, + 12,0,0,tb1_font,vis); + vmwTextXY("PRESS ANY KEY TO CONTINUE",64,185, + 4,0,0,tb1_font,vis); + vmwBlitMemToDisplay(game_state->graph_state,vis); + while(!vmwGetInput()) usleep(30); +} diff --git a/help.h b/help.h new file mode 100644 index 0000000..6de52e2 --- /dev/null +++ b/help.h @@ -0,0 +1 @@ +void help(struct tb1_state *game_state); diff --git a/hiscore.c b/hiscore.c new file mode 100644 index 0000000..b52d05b --- /dev/null +++ b/hiscore.c @@ -0,0 +1,75 @@ +#include + +#include "svmwgraph/svmwgraph.h" +#include "tb1_state.h" +#include "menu_tools.h" + + +#include /* For usleep */ + +int showhiscore(struct tb1_state *game_state,int showchart) +{ + + FILE *hilist; + char tempstr[10]; + int i; + char names[10][25]; + int scores[10]; + + hilist=fopen("hiscore.tb1","r+"); + if (hilist==NULL) { + printf("Error! can't open high score file!\n"); + return 0; + } + + for (i=0;i<10;i++) fscanf(hilist,"%s",names[i]); + for (i=0;i<10;i++) fscanf(hilist,"%i",&scores[i]); + fclose(hilist); + if (!showchart) return scores[0]; + if (showchart) { + vmwDrawBox(45,40,240,120,7,game_state->virtual_1); + coolbox(45,40,285,160,1,game_state->virtual_1); + for(i=0;i<10;i++) + vmwTextXY(names[i],51,46+(i*10),9,7,1,game_state->graph_state->default_font,game_state->virtual_1); + for(i=0;i<10;i++){ + sprintf(tempstr,"%i",scores[i]); + vmwTextXY(tempstr,181,46+(i*10),9,7,1,game_state->graph_state->default_font,game_state->virtual_1); + } + vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1); + while(vmwGetInput()==0) usleep(100); + } + return 0; +} + +void write_hs_list(int score,char *hiname) +{ +#if 0 + int i,place; + FILE *hilist; + char names[10][25]; + int scores[10]; + + hilist=fopen("hiscore.tb1","r+"); + for (i=0;i<10;i++) fscanf(hilist,"%s",names[i]); + for (i=0;i<10;i++) fscanf(hilist,"%i",&scores[i]); + fclose(hilist); + + place=0; + for(i=0;i<9;i++) + if (score>scores[i]) place++; + place=10-place; + for(i=9;i>place;i--) + scores[i]=scores[i-1]; + for(i=9;i>place;i--) + strcpy(names[i-1],names[i]); + scores[place]=score; + strcpy(hiname,names[place]); + if (!read_only_mode) { + hilist=fopen("hiscore.tb1","w"); + for(i=0;i<9;i++) fprintf(hilist,"%s\n",names[i]); + for(i=0;i<9;i++) fprintf(hilist,"%i\n",scores[i]); + fclose(hilist); + } +#endif +} + diff --git a/hiscore.h b/hiscore.h new file mode 100644 index 0000000..8093bf7 --- /dev/null +++ b/hiscore.h @@ -0,0 +1,2 @@ +int showhiscore(struct tb1_state *game_state,int showchart); +void write_hs_list(int score,char *hiname); diff --git a/level_1.c b/level_1.c index d7a172a..04ba7f5 100644 --- a/level_1.c +++ b/level_1.c @@ -7,15 +7,18 @@ #include #include #include -#include "SDL.h" -#include "sdl_svmwgraph.h" + +#include "svmwgraph/svmwgraph.h" #include "tb1_state.h" #include "levels.h" -#include "tblib.h" -#include "vmw_sprite.h" -#include "tb_keypress.h" + #include "sound.h" +#include "tblib.h" +#include "sidebar.h" +#include "help.h" +#include "menu_tools.h" + /* Define this to get a frames per second readout */ /* #define DEBUG_ON */ @@ -73,57 +76,57 @@ int level_one_wave_behavior[]= void beforeboss(struct tb1_state *game_state) { - clear_keyboard_buffer(); + vmwClearKeyboardBuffer(); vmwLoadPicPacked(0,0,game_state->virtual_3,0,1, tb1_data_file("viewscr.tb1",game_state->path_to_data)); vmwClearScreen(game_state->virtual_1,0); vmwArbitraryCrossBlit(game_state->virtual_3,0,5,58,37, game_state->virtual_1,10,10); - vmwSmallTextXY("HUMAN!",70,10,2,0,1,game_state->tb1_font,game_state->virtual_1); + vmwSmallTextXY("HUMAN!",70,10,2,0,1,game_state->graph_state->default_font,game_state->virtual_1); vmwSmallTextXY("WHAT ARE YOU DOING?!",70,20,2, - 0,1,game_state->tb1_font,game_state->virtual_1); + 0,1,game_state->graph_state->default_font,game_state->virtual_1); vmwSmallTextXY("YOUR SPECIES MUST BE TERMINATED!",70,30,2, - 0,1,game_state->tb1_font,game_state->virtual_1); - vmwBlitMemToSDL(game_state->sdl_screen,game_state->virtual_1); + 0,1,game_state->graph_state->default_font,game_state->virtual_1); + vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1); pauseawhile(5); vmwArbitraryCrossBlit(game_state->virtual_3,0,42,58,37, game_state->virtual_1,10,50); - vmwSmallTextXY("I'M SORRY.",70,50,9,0,1,game_state->tb1_font,game_state->virtual_1); + vmwSmallTextXY("I'M SORRY.",70,50,9,0,1,game_state->graph_state->default_font,game_state->virtual_1); vmwSmallTextXY("WE DIDN'T MEAN TO DESTROY YOUR ENVOY.",70,60,9, - 0,1,game_state->tb1_font,game_state->virtual_1); + 0,1,game_state->graph_state->default_font,game_state->virtual_1); vmwSmallTextXY("WILL YOU FORGIVE US AND TRY PEACE?",70,70,9, - 0,1,game_state->tb1_font,game_state->virtual_1); - vmwBlitMemToSDL(game_state->sdl_screen,game_state->virtual_1); + 0,1,game_state->graph_state->default_font,game_state->virtual_1); + vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1); pauseawhile(5); vmwArbitraryCrossBlit(game_state->virtual_3,0,5,58,37, game_state->virtual_1,10,90); vmwSmallTextXY("NO! YOU MUST BE DESTROYED!",70,90,2, - 0,1,game_state->tb1_font,game_state->virtual_1); + 0,1,game_state->graph_state->default_font,game_state->virtual_1); vmwSmallTextXY("OUR FUNDING ... OUR ENVOY WAS DAMAGED BY",70,100, - 2,0,1,game_state->tb1_font,game_state->virtual_1); + 2,0,1,game_state->graph_state->default_font,game_state->virtual_1); vmwSmallTextXY("YOU! VENGEANCE WILL BE OURS! YOUR PUNY",70,110, - 2,0,1,game_state->tb1_font,game_state->virtual_1); + 2,0,1,game_state->graph_state->default_font,game_state->virtual_1); vmwSmallTextXY("PRIMITIVE SPACECRAFT WITH ITS INFERIOR",70,120, - 2,0,1,game_state->tb1_font,game_state->virtual_1); + 2,0,1,game_state->graph_state->default_font,game_state->virtual_1); vmwSmallTextXY("WEAPONS WOULD HAVE TO SCORE 9 DIRECT HITS",70,130, - 2,0,1,game_state->tb1_font,game_state->virtual_1); + 2,0,1,game_state->graph_state->default_font,game_state->virtual_1); vmwSmallTextXY("TO DESTROY MY SHIP! DIE EARTH SCUM!!!!",70,140, - 2,0,1,game_state->tb1_font,game_state->virtual_1); - vmwBlitMemToSDL(game_state->sdl_screen,game_state->virtual_1); + 2,0,1,game_state->graph_state->default_font,game_state->virtual_1); + vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1); pauseawhile(5); setupsidebar(game_state); - vmwFlipVirtual(game_state->virtual_1,game_state->virtual_2); + vmwFlipVirtual(game_state->virtual_1,game_state->virtual_2,320,200); } /* The Sequence After You Defeat (hopefully) the Boss */ void afterboss(struct tb1_state *game_state) { - vmw_font *tb1_font; + vmwFont *tb1_font; - tb1_font=game_state->tb1_font; + tb1_font=game_state->graph_state->default_font; vmwLoadPicPacked(0,0,game_state->virtual_3,0,1, tb1_data_file("viewscr.tb1",game_state->path_to_data)); @@ -136,7 +139,7 @@ void afterboss(struct tb1_state *game_state) 9,0,1,tb1_font,game_state->virtual_1); vmwSmallTextXY("I GUESS I CAN GO HOME NOW.",70,30, 9,0,1,tb1_font,game_state->virtual_1); - vmwBlitMemToSDL(game_state->sdl_screen,game_state->virtual_1); + vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1); pauseawhile(5); vmwArbitraryCrossBlit(game_state->virtual_3,0,5,58,37, @@ -155,7 +158,7 @@ void afterboss(struct tb1_state *game_state) 2,0,1,tb1_font,game_state->virtual_1); vmwSmallTextXY("NICE TRY PUNY EARTHLING!",70,110,2, 0,1,tb1_font,game_state->virtual_1); - vmwBlitMemToSDL(game_state->sdl_screen,game_state->virtual_1); + vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1); pauseawhile(7); vmwArbitraryCrossBlit(game_state->virtual_3,0,42,58,37, @@ -168,7 +171,7 @@ void afterboss(struct tb1_state *game_state) 9,0,1,tb1_font,game_state->virtual_1); vmwSmallTextXY("WELL AT LEAST I HAVE SOME SMALLER SPARES.",70,160, 9,0,1,tb1_font,game_state->virtual_1); - vmwBlitMemToSDL(game_state->sdl_screen,game_state->virtual_1); + vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1); pauseawhile(5); } @@ -332,23 +335,23 @@ int level_one_behavior(int reset, struct tb1_state *game_state) /* The Main Level One */ void levelone(struct tb1_state *game_state) { - int ch=0,shield_color=0; + int ch=0; int i,j,grapherror; char tempst[300]; int itemp,whatdelay=1,levelover=0; int shipx=36,shipadd=0,shipframe=1; - struct vmwSprite *bigship1,*bigship2,*bigship3; - struct vmwSprite *shapetable[20]; + vmwSprite *bigship1,*bigship2,*bigship3; + vmwSprite *shapetable[20]; long oldsec,oldusec,time_spent; int howmuchscroll=0; int speed_factor=1,game_paused=0; int beginscore,beginshield; - unsigned char *virtual_1,*virtual_2; - vmw_font *tb1_font; + vmwVisual *virtual_1,*virtual_2; + vmwFont *tb1_font; /* For convenience */ - tb1_font=game_state->tb1_font; + tb1_font=game_state->graph_state->default_font; virtual_1=game_state->virtual_1; virtual_2=game_state->virtual_2; @@ -390,13 +393,13 @@ void levelone(struct tb1_state *game_state) { coolbox(70,85,240,120,1,virtual_1); vmwTextXY(" LEVEL ONE:",84,95,4,7,0,tb1_font,virtual_1); vmwTextXY("INANIMATE OBJECTS",84,105,4,7,0,tb1_font,virtual_1); - vmwBlitMemToSDL(game_state->sdl_screen, virtual_1); + vmwBlitMemToDisplay(game_state->graph_state, virtual_1); /* Setup and draw the sidebar */ setupsidebar(game_state); - vmwFlipVirtual(virtual_1,virtual_2); + vmwFlipVirtual(virtual_1,virtual_2,320,200); sprintf(tempst,"%d",game_state->level); vmwDrawBox(251,52,63,7,0,virtual_2); vmwTextXY(tempst,307,51,12,0,0,tb1_font,virtual_2); @@ -404,8 +407,8 @@ void levelone(struct tb1_state *game_state) { /* Clear the screen and draw the stars */ vmwDrawBox(0,0,320,400,0,virtual_2); for(i=0;i<100;i++) { - vmwPutSprite(shapetable[11],rand()%238,rand()%380,0,virtual_2); - vmwPutSprite(shapetable[12],rand()%238,rand()%380,0,virtual_2); + vmwPutSprite(shapetable[11],rand()%238,rand()%380,virtual_2); + vmwPutSprite(shapetable[12],rand()%238,rand()%380,virtual_2); } change_shields(game_state); @@ -464,7 +467,7 @@ void levelone(struct tb1_state *game_state) { enemy[i].explodeprogress++; if (enemy[i].explodeprogress<=5) vmwPutSprite(shapetable[enemy[i].explodeprogress+14], - enemy[i].x,enemy[i].y,0, + enemy[i].x,enemy[i].y, virtual_1); else if (enemy[i].dead) { enemy[i].out=0; @@ -481,7 +484,7 @@ void levelone(struct tb1_state *game_state) { else bullet[i].y-=5; if (bullet[i].y<5) bullet[i].out=0; else vmwPutSprite(shapetable[0], - bullet[i].x,bullet[i].y,0, + bullet[i].x,bullet[i].y, virtual_1); } } @@ -491,7 +494,7 @@ void levelone(struct tb1_state *game_state) { if ((enemy[i].out) && (!enemy[i].dead)) { vmwPutSprite(shapetable[enemy[i].kind-1], enemy[i].x,enemy[i].y, - 0,virtual_1); + virtual_1); if (speed_factor==1) enemy[i].x+=enemy[i].xspeed; else enemy[i].x+=(enemy[i].xspeed*speed_factor); /* Check Position */ @@ -540,16 +543,16 @@ void levelone(struct tb1_state *game_state) { /* **READ KEYBOARD** */ if ( (ch=vmwGetInput())!=0) { switch(ch){ - case TB_ESCAPE: levelover=1; break; - case TB_RIGHT: if (shipadd>=0) shipadd+=3; else shipadd=0; break; - case TB_LEFT: if (shipadd<=0) shipadd-=3; else shipadd=0; break; - case TB_F1: game_paused=1; help(); break; + case VMW_ESCAPE: levelover=1; break; + case VMW_RIGHT: if (shipadd>=0) shipadd+=3; else shipadd=0; break; + case VMW_LEFT: if (shipadd<=0) shipadd-=3; else shipadd=0; break; + case VMW_F1: game_paused=1; help(game_state); break; case '+': whatdelay++; if (whatdelay>25) whatdelay=25; break; case 'P': case 'p': game_paused=1; coolbox(65,85,175,110,1,virtual_1); vmwTextXY("GAME PAUSED",79,95,4,7, 0,tb1_font,virtual_1); - vmwBlitMemToSDL(game_state->sdl_screen,virtual_1); + vmwBlitMemToDisplay(game_state->graph_state,virtual_1); while (vmwGetInput()==0) { usleep(30000); } @@ -558,7 +561,7 @@ void levelone(struct tb1_state *game_state) { case 'S': case 's': if (game_state->sound_enabled) game_state->sound_enabled=!(game_state->sound_enabled); break; - case TB_F2: game_paused=1; + case VMW_F2: game_paused=1; // savegame(*level,beginscore,beginshield); break; case ' ': for(j=0;j<2;j++) @@ -570,7 +573,7 @@ void levelone(struct tb1_state *game_state) { bullet[j].y=165; vmwPutSprite(shapetable[0], bullet[j].x, - bullet[j].y,0,virtual_1); + bullet[j].y,virtual_1); j=3; } } @@ -583,12 +586,12 @@ void levelone(struct tb1_state *game_state) { if (shipx>190) shipx=190; switch(shipframe) { - case 1: vmwPutSprite(bigship1,shipx,165,shield_color,virtual_1); + case 1: vmwPutSprite(bigship1,shipx,165,virtual_1); break; - case 3: vmwPutSprite(bigship2,shipx,165,shield_color,virtual_1); + case 3: vmwPutSprite(bigship2,shipx,165,virtual_1); break; case 2: - case 4: vmwPutSprite(bigship3,shipx,165,shield_color,virtual_1); + case 4: vmwPutSprite(bigship3,shipx,165,virtual_1); break; } shipframe++; @@ -596,7 +599,7 @@ void levelone(struct tb1_state *game_state) { /* Flip Pages */ - vmwBlitMemToSDL(game_state->sdl_screen,virtual_1); + vmwBlitMemToDisplay(game_state->graph_state,virtual_1); /* Calculate how much time has passed */ @@ -631,14 +634,14 @@ void levelone(struct tb1_state *game_state) { void littleopener(struct tb1_state *game_state) { - struct vmwSprite *ship1,*ship2; + vmwSprite *ship1,*ship2; int i; vmwClearScreen(game_state->virtual_2,0); vmwLoadPicPacked(0,0,game_state->virtual_2,1,1, tb1_data_file("moon2.tb1",game_state->path_to_data)); - vmwLoadPicPacked(0,0,game_state->virtual_2,1,0, + vmwLoadPicPacked(0,0,game_state->virtual_1,1,0, /* Load palette */ tb1_data_file("moon2.tb1",game_state->path_to_data)); ship1=vmwGetSprite(9,178,15,18,game_state->virtual_2); @@ -646,35 +649,35 @@ void littleopener(struct tb1_state *game_state) vmwDrawBox(0,178,319,21,0,game_state->virtual_2); for(i=100;i>0;i--) { - vmwFlipVirtual(game_state->virtual_1,game_state->virtual_2); - vmwPutSprite(ship2,i*2,100,0,game_state->virtual_1); - vmwBlitMemToSDL(game_state->sdl_screen,game_state->virtual_1); + vmwFlipVirtual(game_state->virtual_1,game_state->virtual_2,320,200); + vmwPutSprite(ship2,i*2,100,game_state->virtual_1); + vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1); usleep(30000); if (vmwGetInput()) break; } - vmwFlipVirtual(game_state->virtual_1,game_state->virtual_2); - vmwBlitMemToSDL(game_state->sdl_screen,game_state->virtual_1); + vmwFlipVirtual(game_state->virtual_1,game_state->virtual_2,320,200); + vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1); vmwTextXY(">KCHK< TOM! WHERE ARE YOU GOING?",5,180,15,0,1, - game_state->tb1_font,game_state->virtual_1); - vmwBlitMemToSDL(game_state->sdl_screen,game_state->virtual_1); + game_state->graph_state->default_font,game_state->virtual_1); + vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1); pauseawhile(3); vmwDrawBox(0,178,319,21,0,game_state->virtual_1); - vmwTextXY("Ooops. ",5,180,24,0,1,game_state->tb1_font,game_state->virtual_1); - vmwBlitMemToSDL(game_state->sdl_screen,game_state->virtual_1); + vmwTextXY("Ooops. ",5,180,24,0,1,game_state->graph_state->default_font,game_state->virtual_1); + vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1); pauseawhile(3); for(i=0;i<151;i++) { - vmwFlipVirtual(game_state->virtual_1,game_state->virtual_2); - vmwPutSprite(ship1,i*2,100,0,game_state->virtual_1); - vmwBlitMemToSDL(game_state->sdl_screen,game_state->virtual_1); + vmwFlipVirtual(game_state->virtual_1,game_state->virtual_2,320,200); + vmwPutSprite(ship1,i*2,100,game_state->virtual_1); + vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1); usleep(15000); if (vmwGetInput()) break; } - vmwFlipVirtual(game_state->virtual_1,game_state->virtual_2); - vmwBlitMemToSDL(game_state->sdl_screen,game_state->virtual_1); + vmwFlipVirtual(game_state->virtual_1,game_state->virtual_2,320,200); + vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1); vmwDrawBox(0,0,320,200,0,game_state->virtual_1); - vmwLoadPicPacked(0,0,game_state->virtual_1,1,0, + vmwLoadPicPacked(0,0,game_state->virtual_1,1,0, /* Restore Palette */ tb1_data_file("tbgorg.tb1",game_state->path_to_data)); } diff --git a/level_2.c b/level_2.c index 2c864ef..3933f0f 100644 --- a/level_2.c +++ b/level_2.c @@ -7,15 +7,16 @@ #include #include #include -#include "SDL.h" -#include "sdl_svmwgraph.h" +#include "svmwgraph/svmwgraph.h" #include "tb1_state.h" #include "levels.h" #include "tblib.h" -#include "vmw_sprite.h" -#include "tb_keypress.h" #include "sound.h" +#include "sidebar.h" +#include "help.h" +#include "menu_tools.h" + /* Define this to get a frames per second readout */ /* #define DEBUG_ON */ @@ -55,7 +56,7 @@ struct obstruction { void leveltwoengine(struct tb1_state *game_state) { int ch,i; - char tempst[300]; + char tempst[BUFSIZ]; int k,game_paused=0,speed_factor=1; int shipx=36; int whatdelay=1,beginscore,beginshield; @@ -74,16 +75,16 @@ void leveltwoengine(struct tb1_state *game_state) int our_row,our_shape,rows_goneby=0; int grapherror; - vmw_font *tb1_font; - unsigned char *virtual_1; - unsigned char *virtual_2; + vmwFont *tb1_font; + vmwVisual *virtual_1; + vmwVisual *virtual_2; - struct vmwSprite *ship_shape[3]; - struct vmwSprite *shape_table[40]; + vmwSprite *ship_shape[3]; + vmwSprite *shape_table[40]; int enemies_drawn[200]; /* For convenience */ - tb1_font=game_state->tb1_font; + tb1_font=game_state->graph_state->default_font; virtual_1=game_state->virtual_1; virtual_2=game_state->virtual_2; @@ -99,9 +100,9 @@ void leveltwoengine(struct tb1_state *game_state) tb1_data_file("ships.tb1", game_state->path_to_data)); - ship_shape[1]=vmwGetSprite(0,0,48,30,virtual_1); - ship_shape[2]=vmwGetSprite(0,32,48,30,virtual_1); - ship_shape[3]=vmwGetSprite(0,64,48,30,virtual_1); + ship_shape[0]=vmwGetSprite(0,0,48,30,virtual_1); + ship_shape[1]=vmwGetSprite(0,32,48,30,virtual_1); + ship_shape[2]=vmwGetSprite(0,64,48,30,virtual_1); if (game_state->level==2) vmwLoadPicPacked(0,0,virtual_1,1,1, @@ -151,57 +152,49 @@ void leveltwoengine(struct tb1_state *game_state) vmwTextXY(" LEVEL FOUR:",84,95,4,7,0,tb1_font,virtual_1); vmwTextXY(" THE PLANET EERM",84,105,4,7,0,tb1_font,virtual_1); } - vmwBlitMemToSDL(game_state->sdl_screen,virtual_1); - clear_keyboard_buffer(); + vmwBlitMemToDisplay(game_state->graph_state,virtual_1); + vmwClearKeyboardBuffer(); pauseawhile(5); /* Setup and draw the sidebar */ setupsidebar(game_state); - vmwFlipVirtual(virtual_1,virtual_2); + vmwFlipVirtual(virtual_1,virtual_2,320,200); sprintf(tempst,"%d",game_state->level); vmwDrawBox(251,52,63,7,0,virtual_2); vmwTextXY(tempst,307,51,12,0,0,tb1_font,virtual_2); - printf("Sidebar Drawn %i\n",sizeof(*virtual_2)); fflush(stdout); - /* Clear the screen and draw the stars */ vmwDrawBox(0,0,320,400,0,virtual_2); for(i=0;i<100;i++) { // printf("%i\n",i); fflush(stdout); -// vmwPutSprite(shape_table[32],rand()%238,rand()%150,0,virtual_2); -// vmwPutSprite(shape_table[33],rand()%238,rand()%150,0,virtual_2); + vmwPutSprite(shape_table[32],rand()%238,rand()%150,virtual_2); + vmwPutSprite(shape_table[33],rand()%238,rand()%150,virtual_2); } - - printf("Stars Drawn\n"); fflush(stdout); change_shields(game_state); - gettimeofday(&timing_info,&dontcare); oldsec=timing_info.tv_sec; oldusec=timing_info.tv_usec; - printf("Entering game loop\n"); fflush(stdout); - /**** GAME LOOP ****/ while (!levelover) { ch=0; - printf("Scrolling Background\n"); fflush(stdout); /* Scroll the Background */ if (speed_factor>1) howmuchscroll-=speed_factor; else howmuchscroll--; if (howmuchscroll<0) { howmuchscroll=200+howmuchscroll; -// vmwArbitraryCrossBlit(virtual_2,0,0,240,200,virtual_2,0,200); + vmwArbitraryCrossBlit(virtual_2,0,0,240,200,virtual_2,0,200); /*ggiCopyBox(vaddr2,0,0,240,200,0,200);*/ for(i=0;i<12;i++) for(j=19;j>=0;j--) { our_shape=background[backrow+(19-j)][i]; - vmwPutSprite(shape_table[our_shape], - i*20,j*10,0,virtual_1); +// printf("Shape : %i\n",our_shape); + vmwPutSprite(shape_table[our_shape], + i*20,j*10,virtual_2); } backrow+=20; } - printf("Setting Obsrtuctions\n"); fflush(stdout); /* Setup Obstructions */ our_row=rows_goneby/10; @@ -225,13 +218,11 @@ void leveltwoengine(struct tb1_state *game_state) } } - printf("Flipping\n"); fflush(stdout); /* Flip the far background to vaddr */ vmwArbitraryCrossBlit(virtual_2,0,0+howmuchscroll,240,200, virtual_1,0,0); - printf("Collision Check\n"); fflush(stdout); /***Collision Check***/ for(i=0;i<40;i++) @@ -274,7 +265,7 @@ void leveltwoengine(struct tb1_state *game_state) if(game_state->shields<0) levelover=1; vmwPutSprite(shape_table[34], passive[i].x,passive[i].y+howmuchscroll, - 0,virtual_1); + virtual_1); change_shields(game_state); } } @@ -298,13 +289,13 @@ void leveltwoengine(struct tb1_state *game_state) passive[i].explodeprogress++; vmwPutSprite(shape_table[35+passive[i].explodeprogress], passive[i].x,passive[i].y+howmuchscroll, - 0,virtual_1); - if (passive[i].explodeprogress>4) { + virtual_2); + if (passive[i].explodeprogress>3) { passive[i].dead=1; passive[i].exploding=0; vmwPutSprite(shape_table[34], passive[i].x,passive[i].y+howmuchscroll, - 0,virtual_2); + virtual_2); } } @@ -316,7 +307,7 @@ void leveltwoengine(struct tb1_state *game_state) if (bullet[i].y<5) bullet[i].out=0; else vmwPutSprite(shape_table[20], bullet[i].x,bullet[i].y, - 0,virtual_1); + virtual_1); } } @@ -348,7 +339,7 @@ void leveltwoengine(struct tb1_state *game_state) if (enemy[j].out) { vmwPutSprite(shape_table[enemy[j].kind], enemy[j].x,enemy[j].y, - 0,virtual_1); + virtual_1); if (speed_factor==1) enemy[j].y+=enemy[j].yspeed; else enemy[j].y+=(enemy[j].yspeed*speed_factor); if (enemy[j].y>189) enemy[j].out=0; @@ -358,22 +349,22 @@ void leveltwoengine(struct tb1_state *game_state) /***READ KEYBOARD***/ if ((ch=vmwGetInput())!=0) { switch(ch) { - case TB_ESCAPE: levelover=1; break; - case TB_RIGHT: if (shipadd>=0) shipadd+=3; else shipadd=0; break; - case TB_LEFT: if (shipadd<=0) shipadd-=3; else shipadd=0; break; - case TB_F1: game_paused=1; help(); break; + case VMW_ESCAPE: levelover=1; break; + case VMW_RIGHT: if (shipadd>=0) shipadd+=3; else shipadd=0; break; + case VMW_LEFT: if (shipadd<=0) shipadd-=3; else shipadd=0; break; + case VMW_F1: game_paused=1; help(game_state); break; case '+': whatdelay++; break; case 'P': case 'p': game_paused=1; coolbox(65,85,175,110,1,virtual_1); vmwTextXY("GAME PAUSED",79,95,4,7, 0,tb1_font,virtual_1); - vmwBlitMemToSDL(game_state->sdl_screen,virtual_1); + vmwBlitMemToDisplay(game_state->graph_state,virtual_1); while (vmwGetInput()==0) usleep(30000); break; case '-': whatdelay--; break; case 'S': case 's': game_state->sound_enabled=!(game_state->sound_enabled); break; - case TB_F2: game_paused=1; /*savegame(*level,beginscore,beginshield);*/ + case VMW_F2: game_paused=1; /*savegame(*level,beginscore,beginshield);*/ break; case ' ': for(j=0;j<3;j++) if (!bullet[j].out) { @@ -382,14 +373,14 @@ void leveltwoengine(struct tb1_state *game_state) bullet[j].x=shipx+21; bullet[j].y=165; vmwPutSprite(shape_table[20], - bullet[j].x,bullet[j].y,0,virtual_1); + bullet[j].x,bullet[j].y,virtual_1); j=4; } } } - + /***MOVE SHIP***/ if (speed_factor>1) { shipx+=(shipadd*speed_factor); @@ -403,18 +394,18 @@ void leveltwoengine(struct tb1_state *game_state) if (shipx>190) shipx=190; switch(shipframe) { case 1: vmwPutSprite(ship_shape[0], - shipx,165,0,virtual_1); break; + shipx,165,virtual_1); break; case 3: vmwPutSprite(ship_shape[1], - shipx,165,0,virtual_1); break; + shipx,165,virtual_1); break; case 2: case 4: vmwPutSprite(ship_shape[2], - shipx,165,0,virtual_1); break; + shipx,165,virtual_1); break; } shipframe++; if (shipframe==5) shipframe=1; /* Flip Pages */ - vmwBlitMemToSDL(game_state->sdl_screen,virtual_1); + vmwBlitMemToDisplay(game_state->graph_state,virtual_1); /* Calculate how much time has passed */ gettimeofday(&timing_info,&dontcare); @@ -571,7 +562,7 @@ void leveltwoengine(struct tb1_state *game_state) void littleopener2() { - char tempst[300]; +// char tempst[300]; /* ggiSetGCForeground(vis,tb1_pal[0]); ggiDrawBox(vis,0,0,320,200); diff --git a/loadgame.c b/loadgame.c new file mode 100644 index 0000000..1d23e1e --- /dev/null +++ b/loadgame.c @@ -0,0 +1,61 @@ + +void loadgame() +{ +#if 0 + char tempst[300],tempst2[5],file_name[320]; + int i,j; + FILE *fff; + int game_exist[10]={0,0,0,0,0, 0,0,0,0,0}; + char ch; + int level,score,shields; + + coolbox(0,0,320,200,1,vis); + vmwTextXY("LOAD GAME",110,10,9],0],0,tb1_font,vis); + + sprintf(tempst,"%s/.tb1",getenv("HOME")); + + j=0; + for(i=0;i<10;i++) { + sprintf(file_name,"%s/sg%i.tb1",tempst,i); + if ((fff=fopen(file_name,"r"))!=NULL) { + sprintf(tempst2,"%i",i); + vmwTextXY(tempst2,50+j*20,50,12],0],0,tb1_font,vis); + fclose(fff); + game_exist[i]=1; + j++; + } + } + if (j==0) { + vmwTextXY("NO SAVED GAMES FOUND",60,50,12],0],0,tb1_font,vis); + vmwTextXY("PRESS ANY KEY...",80,180,4],0],0,tb1_font,vis); + while( (ch=get_input())==0) usleep(30); + } + else { + vmwTextXY("LOAD WHICH GAME?",80,30,4],0],0,tb1_font,vis); + vmwTextXY("THE FOLLOWING EXIST:",40,40,4],0],0,tb1_font,vis); + vmwTextXY("PRESS A NUMBER. (ESC CANCELS)",20,60,4],0],0,tb1_font,vis); + ch='M'; + clear_keyboard_buffer(); + IchLiebeMree: + while( ((ch<'0') || (ch>'9')) && (ch!=VMW_ESC)) { + while((ch=get_input())==0) usleep(30); + } + if (!(game_exist[ch-48])) goto IchLiebeMree; + if(ch==VMW_ESC) { + coolbox(0,0,320,200,1,vis); + vmwTextXY("LOAD CANCELED",90,95,12],0],0,tb1_font,vis); + vmwTextXY("PRESS ANY KEY...",80,180,4],0],0,tb1_font,vis); + while( (ch=get_input())==0) usleep(30); + } + else { + sprintf(file_name,"%s/sg%c.tb1",tempst,ch); + if (( fff=fopen(file_name,"r"))!=NULL) { + fscanf(fff,"%d",&level); + fscanf(fff,"%d",&score); + fscanf(fff,"%d",&shields); + playthegame(level,score,shields); + } + } + } +#endif +} diff --git a/loadgame.h b/loadgame.h new file mode 100644 index 0000000..cdfee3c --- /dev/null +++ b/loadgame.h @@ -0,0 +1 @@ +void loadgame(); diff --git a/menu_tools.c b/menu_tools.c new file mode 100644 index 0000000..0122e86 --- /dev/null +++ b/menu_tools.c @@ -0,0 +1,25 @@ +#include + +#include "svmwgraph/svmwgraph.h" + +void coolbox(int x1,int y1,int x2,int y2,int fill,vmwVisual *target) +{ + int i; + + for(i=0;i<5;i++) { + vmwDrawHLine(x1+i,y1+i,(x2-x1-i-i),31-i,target); + vmwDrawHLine(x1+i,y2-i,(x2-x1-i-i),31-i,target); + vmwDrawVLine(x1+i,y1+i,(y2-y1-i-i),31-i,target); + vmwDrawVLine(x2-i,y1+i,(y2-y1-i-i),31-i,target); + } + if (fill) { + for(i=y1+5;i +#include + +#include "svmwgraph/svmwgraph.h" +#include "tb1_state.h" +#include "menu_tools.h" +#include "hiscore.h" + +void options(struct tb1_state *game_state) +{ + + int opbarpos,argh=0,ch=0; + vmwFont *tb1_font; + + tb1_font=game_state->graph_state->default_font; + + vmwClearScreen(game_state->virtual_1,8); + coolbox(0,0,319,199,0,game_state->virtual_1); + vmwTextXY("ESC QUITS",120,175,32,0,1,tb1_font,game_state->virtual_1); + opbarpos=0; + while(ch!=VMW_ESCAPE) { + if (game_state->sound_enabled) { + if (opbarpos==0) vmwTextXY("SOUND ON ",30,30,32, + 7,1,tb1_font,game_state->virtual_1); + else vmwTextXY("SOUND ON ",30,30,32, + 0,1,tb1_font,game_state->virtual_1); + } + else { + if (opbarpos==0) vmwTextXY("NO SOUND ",30,30,32, + 7,1,tb1_font,game_state->virtual_1); + else vmwTextXY("NO SOUND ",30,30,32, + 0,1,tb1_font,game_state->virtual_1); + } + if (opbarpos==1) vmwTextXY("VIEW HIGH SCORES",30,40,32, + 7,1,tb1_font,game_state->virtual_1); + else vmwTextXY("VIEW HIGH SCORES",30,40,32, + 0,1,tb1_font,game_state->virtual_1); + + vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1); + + while(!(ch=vmwGetInput()) ) usleep(30); + + if ((ch==VMW_RIGHT) || (ch==VMW_DOWN)) opbarpos++; + if ((ch==VMW_LEFT) || (ch==VMW_UP)) opbarpos--; + if ((ch=='M')||(ch=='m')) opbarpos=0; + if ((ch=='V')||(ch=='v')) opbarpos=1; + if ((ch==VMW_ENTER) && (opbarpos==0)) game_state->sound_enabled=!game_state->sound_enabled; + if ((ch==VMW_ENTER) && (opbarpos==1)){ + ch=VMW_ESCAPE; + argh=4; + } + if (opbarpos==2) opbarpos=0; + if (opbarpos==-1) opbarpos=1; + } + if (argh==4) showhiscore(game_state,1); +} diff --git a/options.h b/options.h new file mode 100644 index 0000000..e35f902 --- /dev/null +++ b/options.h @@ -0,0 +1 @@ +void options(struct tb1_state *game_state); diff --git a/playgame.c b/playgame.c new file mode 100644 index 0000000..a062ea2 --- /dev/null +++ b/playgame.c @@ -0,0 +1,61 @@ +#include + +#include "svmwgraph/svmwgraph.h" +#include "tb1_state.h" + +#include "tblib.h" +#include "menu_tools.h" + +#include "levels.h" + +void playthegame(struct tb1_state *game_state) +{ + + if (game_state->level==0) { + littleopener(game_state); + game_state->shields=12; + game_state->score=0; + game_state->level++; + } + + if (game_state->level==1) { + game_state->level=2; + leveltwoengine(game_state); +// levelone(game_state); +// if(level==2) littleopener2(); + } + if (game_state->level==2) { +// leveltwoengine(&level,&shields,&score); + } + if (game_state->level==3) { + /*littleopener3(); + levelthree();*/ + } + if (game_state->level==4) { +// leveltwoengine(&level,&shields,&score); + } + coolbox(70,85,170,110,1,game_state->virtual_1); + vmwTextXY("GAME OVER",84,95,4,7,0, + game_state->graph_state->default_font,game_state->virtual_1); + game_state->level=0; + vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1); + vmwClearKeyboardBuffer(); + pauseawhile(20); + + + + /* hiscore:=showhiscore(false,false); + if score>lowscore then begin + coolbox(10,75,310,125,true,vga); + outtextxy('NEW HIGH SCORE!',90,80,12,7,vga,false); + outtextxy('ENTER YOUR NAME (10 Chars)',30,90,0,7,vga,false); + hiname:=grinput(110,110,10,11,7); + hiscore:=showhiscore(false,true); + end; + hiscore:=showhiscore(true,false); + fade; + cls(0,vga); +*/ + +} + diff --git a/playgame.h b/playgame.h new file mode 100644 index 0000000..641ae66 --- /dev/null +++ b/playgame.h @@ -0,0 +1 @@ +void playthegame(struct tb1_state *game_state); diff --git a/quit.c b/quit.c new file mode 100644 index 0000000..5cee576 --- /dev/null +++ b/quit.c @@ -0,0 +1,44 @@ +#include +#include + +#include "svmwgraph/svmwgraph.h" +#include "tb1_state.h" +#include "menu_tools.h" +#include "sound.h" + +int quit(struct tb1_state *game_state) +{ + + int barpos=0,ch=0; + vmwFont *tb1_font; + vmwVisual *target; + + tb1_font=game_state->graph_state->default_font; + target=game_state->virtual_1; + + coolbox(90,75,230,125,1,target); + vmwTextXY("QUIT??? ARE YOU",97,82,9,7,0,tb1_font,target); + vmwTextXY("ABSOLUTELY SURE?",97,90,9,7,0,tb1_font,target); + + while (ch!=VMW_ENTER){ + if (barpos==0) vmwTextXY("YES-RIGHT NOW!",97,98,150,0,1,tb1_font,target); + else vmwTextXY("YES-RIGHT NOW!",97,98,150,7,1,tb1_font,target); + if (barpos==1) vmwTextXY("NO--NOT YET.",97,106,150,0,1,tb1_font,target); + else vmwTextXY("NO--NOT YET.",97,106,150,7,1,tb1_font,target); + vmwBlitMemToDisplay(game_state->graph_state,target); + + while ( !(ch=vmwGetInput()) ) { + usleep(30); + } + if ((ch==VMW_UP)||(ch==VMW_DOWN)||(ch==VMW_LEFT)||(ch==VMW_RIGHT)) barpos++; + if (ch=='y') barpos=0; + if (ch=='n') barpos=1; + if (barpos==2) barpos=0; + } + if (barpos==0){ + shutdownSound(); + exit(1); + } + else return 6; + +} diff --git a/quit.h b/quit.h new file mode 100644 index 0000000..a9d0fa0 --- /dev/null +++ b/quit.h @@ -0,0 +1 @@ +int quit(struct tb1_state *game_state); diff --git a/savegame.c b/savegame.c new file mode 100644 index 0000000..b5c925d --- /dev/null +++ b/savegame.c @@ -0,0 +1,98 @@ +void savegame(int level,int begin_score,int begin_shields) +{ + +#if 0 + char ch; + struct stat buf; + char tempst[300],save_game_name[320],tempst2[5]; + FILE *fff; + int dot_tb1_exists=0; + + int i,j; + + coolbox(0,0,319,199,1,vis); + vmwTextXY("SAVE GAME",110,10,9],0],0,tb1_font,vis); + if (read_only_mode) { + vmwTextXY("SORRY! CANNOT SAVE GAME",40,40,4],0],0,tb1_font,vis); + vmwTextXY("WHEN IN READ ONLY MODE",50,50,4],0],0,tb1_font,vis); + } + else { + sprintf(tempst,"%s/.tb1",getenv("HOME")); + stat(tempst,&buf); + if (!S_ISDIR(buf.st_mode)) { + vmwTextXY("DIRECTORY:",20,20,4],0],0,tb1_font,vis); + if (strlen(tempst)>18) + vmwTextXY("$HOME/.tb1",120,20,4],0],0,tb1_font,vis); + else + vmwTextXY(tempst,120,20,4],0],0,tb1_font,vis); + vmwTextXY("WHERE TB1 STORES SAVED GAMES",20,30,4],0],0,tb1_font,vis); + vmwTextXY("DOES NOT EXIST. DO YOU WANT",20,40,4],0],0,tb1_font,vis); + vmwTextXY("TO CREATE THIS DIRECTORY?",20,50,4],0],0,tb1_font,vis); + vmwTextXY(" PLEASE ANSWER [Y or N]",20,60,4],0],0,tb1_font,vis); + vmwTextXY("NOTE IF YOU ANSWER \"N\" YOU",20,80,12],0],0,tb1_font,vis); + vmwTextXY("WILL NOT BE ABLE TO SAVE",20,90,12],0],0,tb1_font,vis); + vmwTextXY("GAMES",20,100,12],0],0,tb1_font,vis); + ch='M'; + clear_keyboard_buffer(); + while( (ch!='Y') && (ch!='y') && (ch!='N') && (ch!='n')) { + while((ch=get_input())==0) usleep(30); + } + if (toupper(ch)=='Y') + if (!mkdir(tempst,744)) dot_tb1_exists=1; + else { + coolbox(0,0,319,199,1,vis); + vmwTextXY("WARNING! COULD NOT CREATE",30,30,4],0],0,tb1_font,vis); + vmwTextXY("DIRECTORY! ABANDONING SAVE!",20,40,4],0],0,tb1_font,vis); + } + + } + else dot_tb1_exists=1; + } + if (dot_tb1_exists) { + coolbox(0,0,319,199,1,vis); + vmwTextXY("SAVE GAME",110,20,9],0],0,tb1_font,vis); + vmwTextXY("NOTE: THIS ONLY SAVES THE GAME",10,40,4],0],0,tb1_font,vis); + vmwTextXY("AT THE BEGINNING OF THE LEVEL!",10,50,4],0],0,tb1_font,vis); + vmwTextXY("ALREADY EXISTING GAMES",10,70,4],0],0,tb1_font,vis); + j=0; + for(i=0;i<10;i++) { + sprintf(save_game_name,"%s/sg%i.tb1",tempst,i); + if ((fff=fopen(save_game_name,"r"))!=NULL) { + sprintf(tempst2,"%i",i); + vmwTextXY(tempst2,50+j*20,80,12],0],0,tb1_font,vis); + fclose(fff); + j++; + } + } + if (j==0) vmwTextXY("NONE",140,90,12],0],0,tb1_font,vis); + vmwTextXY("PRESS NUMBER OF GAME TO SAVE",20,110,4],0],0,tb1_font,vis); + vmwTextXY("(0-9) [ESC CANCELS]",60,120,4],0],0,tb1_font,vis); + ch='M'; + clear_keyboard_buffer(); + while( ((ch<'0') || (ch>='9')) && (ch!=VMW_ESC)) { + while((ch=get_input())==0) usleep(30); + } + if (ch==VMW_ESC) { + coolbox(0,0,320,200,1,vis); + vmwTextXY("SAVE CANCELED",90,95,12],4],0,tb1_font,vis); + } + else { + sprintf(save_game_name,"%s/sg%c.tb1",tempst,ch); + if ((fff=fopen(save_game_name,"w"))!=NULL) { + fprintf(fff,"%i\n%i\n%i\n",level,begin_score,begin_shields); + fclose(fff); + coolbox(0,0,320,200,1,vis); + sprintf(tempst,"GAME %c SAVED",ch); + vmwTextXY(tempst,90,95,12],0],0,tb1_font,vis); + } + else { + coolbox(0,0,320,200,1,vis); + vmwTextXY("ERROR SAVING FILE!",70,90,12],0],0,tb1_font,vis); + vmwTextXY("GAME NOT SAVED!",80,100,12],0],0,tb1_font,vis); + } + } + } + vmwTextXY("PRESS ANY KEY...",80,180,4],0],0,tb1_font,vis); + while( (ch=get_input())==0) usleep(30); +#endif +} diff --git a/sdl_svmwgraph.c b/sdl_svmwgraph.c deleted file mode 100644 index 102778d..0000000 --- a/sdl_svmwgraph.c +++ /dev/null @@ -1,662 +0,0 @@ -/* I will finish this game!!! */ -/* This is the SDL implementation of the Super VMW graphics library */ -/* Which was originally a lot of Turbo-Pascal w inline assembly */ - -#include -#include -#include -#include -#include -#include "SDL.h" -#include "tb_keypress.h" - - -/* hard coded for now */ -#define X_WIDTH 320 -#define Y_HEIGHT 200 -#define BPP 2 /* Bytes Per Pixel, ie 16bpp */ - -//#define DEBUG 1 /* Until we get to Beta */ - -unsigned int global_palette[256]; - - -int vmwPack3Bytes(int r, int g, int b) { - - return ( ( ( (r>>3)&0x1f) <<11)+ - ( ( (g>>2)&0x3f) <<5)+ - ( ( (b>>3)&0x1f) ) ); -} - -void vmwLoadCustomPalette(int pal[256]) { - int i; - for (i=0;i<256;i++) { - global_palette[i]=pal[i]; - - } -} - - -void vmwBlitMemToSDL(SDL_Surface *target, unsigned char *source) { - - int x,y,Bpp; - - unsigned char *s_pointer,*t_pointer; - - - if ( SDL_MUSTLOCK(target) ) { - if ( SDL_LockSurface(target) < 0 ) - return; - } - - Bpp= target->format->BytesPerPixel; - - s_pointer=source; - t_pointer=((Uint8 *)target->pixels); - - for (x=0;x<320;x++) - for (y=0;y<200;y++) { - *((Uint16 *)(t_pointer))=*((Uint16 *)(s_pointer)); - s_pointer+=2; t_pointer+=2; - } - - - /* Update the display */ - if ( SDL_MUSTLOCK(target) ) { - SDL_UnlockSurface(target); - } - - /* Write this out to the screen */ - SDL_UpdateRect(target, 0, 0, 320, 200); - -} - - - - /*---------------------------------------------------------------*\ - | vmwPutPixel | - \*---------------------------------------------------------------*/ - -void vmwPutPixel(int x,int y,int color, unsigned char *target) { - Uint8 *bits; - -#ifdef DEBUG - if ( (y> (Y_HEIGHT-1) ) || (x> (X_WIDTH-1) ) ) { - printf("Out of bounds with PutPixel %i,%i\n",x,y); - return; - } -#endif - - /* Really Ugly SDL Framebuffer stuff */ - bits = ((Uint8 *)target)+(y*320+x)*2; - *((Uint16 *)(bits)) = global_palette[color]; - -} - -unsigned char vmwGetPixel(int x,int y, unsigned char *source) { - /* This is really hacked together, based on the old */ - /* 256 color palette model used by paintPro graphics */ - /* and the old pascal version of this game. I may try */ - /* to improve this in the future */ - - unsigned char i; - - for (i=0;i<255;i++) { - if (*(Uint16* )(((Uint8 *)source)+(y*320+x)*2)==global_palette[i]) - return i; - } - printf("Unknown color! This shouldn't happen!\n"); - return 0; - -} - - -void vmwClearScreen(unsigned char *target, int color) { - - int x,y; - - if (color==0) memset(target,0,320*200*2); - - else { /* Super in-efficient */ - for (x=0;x<320;x++) - for (y=0;y<200;y++) - vmwPutPixel(x,y,color,target); - } - -} - - /*---------------------------------------------------------------*\ - | vmwDrawHLine | - | This is really begging to be optimized. I am sure some | - | targets can do this in hardware | - \*---------------------------------------------------------------*/ - -void vmwDrawHLine(int xstart,int ystart,int how_long,int color, - unsigned char *target) { - - int i; - - for(i=0;i6\n",header); - return 3; - } - - buffpointer=12; - /* Read X and Y sizes */ - temp1=buffer[buffpointer]; - temp2=buffer[buffpointer+1]; - temp3=buffer[buffpointer+2]; - buffpointer+=3; - if (buffpointer>=errorlev) { - printf("PPRO error... Early end of file.\n"); - return 4; - } - - /* Split 48 bits into two 32 bit values */ - xsize=(temp2>>4)+(temp1<<4); - ysize=((temp2-((temp2>>4)<<4))<<16)+temp3; - - temp1=buffer[buffpointer]; - temp2=buffer[buffpointer+1]; - temp3=buffer[buffpointer+2]; - buffpointer+=3; - if (buffpointer>=errorlev) { - printf("PPRO error... Early end of file.\n"); - return 4; - } - - numcolors=(temp2>>4)+(temp1<<4); - - picwidth=xsize+1; - picheight=ysize+1; - /*Load Palette*/ - if (numcolors!=256) printf("%d colors is not supported yet.\n",numcolors); - - /* Fun and games to convert the 24 bit color in paintpro to */ - /* 565 packed 16bit RGB */ - - for(i=0;i<256;i++) { - temp_palette[i]=vmwPack3Bytes(buffer[buffpointer], - buffer[buffpointer+1], - buffer[buffpointer+2]); - buffpointer+=3; - if (buffpointer>=errorlev) { - if (errorlev==300) { - errorlev=fread(buffer,1,300,fff); - buffpointer=0; - } - else { - lastread=1; - } - } - } - - if (LoadPal) { - for (i=0;i<256;i++) global_palette[i]=temp_palette[i]; - } - - - x=x1; - y=y1; - - while ((!lastread)&&(LoadPic)&&(y=errorlev) { - if (errorlev==300) { - errorlev=fread(buffer,1,300,fff); - buffpointer=0; - } - else lastread=1; - } - - int1=(temp2>>4)+(temp1<<4); - int2=((temp2-((temp2>>4)<<4))*256)+temp3; - - /* If greater than 2047, we have two single pixels */ - /* of color int1-2048 and int2-2048 */ - if (int1>2047) { - vmwPutPixel(x,y,int1-2048,target); - x++; - if (x>xsize+x1) { - x=x1; y++; -// if (y>ysize-1) { -// printf("Blargh 1\n"); y--; -// } - } - vmwPutPixel(x,y,int2-2048,target); - x++; - if (x>xsize+x1){ - x=x1;y++; -// if (y>ysize) { -// printf("Blargh 2\n"); -// y--; -// } - } - } - else { /* Standard paintpro format */ - col=int1; - numacross=int2; - while ((x+numacross)>(xsize+x1)) { - vmwDrawHLine(x,y,((xsize+x1)-x),col,target); - numacross=numacross-((xsize+1)-x); - x=x1; - y++; - if (y>y1+ysize-1) { - printf("Blrgh 3\n"); - } - } - if ((numacross!=0) && (yxsize+x-1) numacross--; /* Stupid x overflow */ - vmwDrawHLine(x,y,numacross,col,target); - } - x=x+numacross; - } - } - - if (fff!=NULL) fclose(fff); - return 0; -} - - -void clear_keyboard_buffer() { - SDL_Event event; - while (SDL_PollEvent(&event)) { - - } -} - -void pauseawhile(int howlong) { - - struct timeval bob; - struct timezone mree; - long begin_s,begin_u; - - SDL_Event event; - - clear_keyboard_buffer(); - gettimeofday(&bob,&mree); - begin_s=bob.tv_sec; begin_u=bob.tv_usec; - while ((bob.tv_sec-begin_s)=y_start) && (yy<=y_stop)) ) - memcpy(dest+(stride_factor*(xx+x)),(src+xx),stride_factor); - // **(dest+xx+x)=15; - src+=w; - dest+=dest_stride; - } - */ - return 0; - -} - - - -vmw_font *vmwLoadFont(char *namest,int xsize,int ysize,int numchars) -{ - unsigned char buff[16]; - FILE *f; - int i,fonty,numloop; - vmw_font *font; - char *data; - - font=(vmw_font *)malloc(sizeof(vmw_font)); - data=(char *)calloc(numchars*ysize,(sizeof(char))); - - f=fopen(namest,"r"); - if (f==NULL) { - printf("ERROR loading font file %s.\n",namest); - return NULL; - } - numloop=(numchars*ysize); - - font->width=xsize; - font->height=ysize; - font->numchars=numchars; - font->font_data=data; - fonty=0; - while ( (!feof(f))&&(fontyfont_data[fonty+i]=buff[i]; - fonty+=16; - } - fclose(f); - return font; -} - -/*int bit(unsigned char mree,int whichbit) -{ - return mree&(128>>whichbit); -} - */ - -void vmwTextLineOver(char *st,int x,int y,int col,int background,int line, - vmw_font *font,unsigned char *target) -{ - int i,xx,len; - len=strlen(st); - for(i=0;ifont_data[(st[i]*font->height)+line])&(128>>xx) ) - vmwPutPixel((x+(i*8)+xx),y,col,target); - else - vmwPutPixel((x+(i*8)+xx),y,background,target); - } -} - - -void vmwTextLine(char *st,int x,int y,int col,int background,int line, - vmw_font *font,unsigned char *target) -{ - int i,len,xx; - len=strlen(st); - for(i=0;ifont_data[(st[i]*16)+line])) - &(128>>xx) ) { - vmwPutPixel(x+(i*8)+xx,y,col,target); - } -} - -void vmwTextXY(char *st,int x,int y,int col,int background,int overwrite, - vmw_font *font,unsigned char *target) -{ - int lineon,i,xx,len; - - len=strlen(st); - for(lineon=0;lineon<8;lineon++){ - for(i=0;ifont_data[(st[i]*font->height)+lineon])&(128>>xx) ) - vmwPutPixel((x+(i*8)+xx),y+lineon,col,target); - else - if(overwrite) vmwPutPixel((x+(i*8)+xx),y+lineon,background,target); - } - } - /*VMWtextlineover(st,x,y+lineon,col,background,lineon,font,vis);*/ - /* VMWtextline(st,x,y+lineon,col,background,lineon,font,vis);*/ -} - - -void vmwSmallTextXY(char *st,int x,int y,int col,int background,int overwrite, - vmw_font *font,unsigned char *target) -{ - int lineon,i,xx,len; - - /* This will print out a small 4x5 font located in chars */ - /* 128-255 in a normal VGA font. These are custom made */ - /* fonts they are non-standard */ - - len=strlen(st); - for(lineon=0;lineon<5;lineon++) { - for(i=0;ifont_data[((st[i]+128)*font->height)+lineon])&(128>>xx) ) - vmwPutPixel((x+(i*5)+xx),y+lineon,col,target); - else - if(overwrite) vmwPutPixel((x+(i*5)+xx),y+lineon,background,target); - } - } -} - -/* - -procedure outsmalltextxy(st:string;x,y,col,background:integer;where:word;overwrite:boolean); -label l0105; -var l,len,i,xadd,yadd,lineon:integer; - n,k,o,min,max,qwerty:byte; -begin - for lineon:=0 to 4 do - if overwrite then - outsmalltextlineover(st,x,y+lineon,col,background,lineon,where) - else - outsmalltextline(st,x,y+lineon,col,background,lineon,where); - -end; - - - -function sgn(a:real):integer; -begin - if a>0 then sgn:=+1; - if a<0 then sgn:=-1; - if a=0 then sgn:=0; -end; - -procedure line(a,b,c,d,col:integer;where:word); -var u,s,v,d1x,d1y,d2x,d2y,m,n:real; - i:integer; -begin - u:= c - a; - v:= d - b; - d1x:= SGN(u); - d1y:= SGN(v); - d2x:= SGN(u); - d2y:= 0; - m:= ABS(u); - n := ABS(v); - IF NOT (M>N) then - BEGIN - d2x := 0 ; - d2y := SGN(v); - m := ABS(v); - n := ABS(u); - END; - s := INT(m / 2); - FOR i := 0 TO round(m) DO - BEGIN - putpixel(a,b,col,where); - s := s + n; - IF not (s + +#include "svmwgraph/svmwgraph.h" +#include "tb1_state.h" +#include "sound.h" + +#include "hiscore.h" + + /* Convenience Function */ +int change_shields(struct tb1_state *game_state) +{ + + int itemp,jtemp; + + game_state->shield_color=(game_state->shields)*0x1000; + game_state->virtual_1->palette[254]=(game_state->shields)*0x1000; + + vmwDrawBox(250,71,64,8,0,game_state->virtual_1); + for(itemp=0;itemp<(game_state->shields)*4;itemp+=4) + for(jtemp=71;jtemp<79;jtemp++) { + vmwDrawHLine(250+itemp,jtemp,4,(47-(itemp/4)),game_state->virtual_1); + } + return 0; +} + + /* TSIA [well actually FNSIA (function name says it all) */ +int changescore(struct tb1_state *game_state) +{ + + char scorest[20]; + vmwVisual *vaddr; + vmwFont *tb1_font; + + tb1_font=game_state->graph_state->default_font; + vaddr=game_state->virtual_1; + + sprintf(scorest,"%d",game_state->score); + vmwTextXY(scorest,317-(strlen(scorest)*9),11, + 12,0,1,tb1_font,vaddr); + if ( ((game_state->score % 400)==0) && (game_state->shields<16) ) { + if (game_state->sound_enabled) + playGameFX(/*SND_ZRRP*/7); + game_state->shields++; + change_shields(game_state); + } + return 0; +} + + + + +void makehole(int y,vmwVisual *target) +{ + + vmwDrawBox(249,y,64,9,0,target); + vmwDrawHLine(249,y,65,24,target); + vmwDrawVLine(249,y,9,24,target); + vmwDrawHLine(249,y+10,64,18,target); + vmwDrawVLine(314,y+1,9,18,target); + +} + +void setupsidebar(struct tb1_state *game_state) +{ + + int i,hiscore; + char it[50]; + + vmwVisual *vaddr2; + vmwFont *tb1_font; + + tb1_font=game_state->graph_state->default_font; + vaddr2=game_state->virtual_2; + + vmwDrawBox(240,0,80,199,19,game_state->virtual_2); + + vmwDrawVLine(240,0,199,18,game_state->virtual_2); + vmwDrawHLine(240,0,79,18,game_state->virtual_2); + + vmwDrawVLine(319,0,199,24,game_state->virtual_2); + vmwDrawHLine(241,199,78,24,game_state->virtual_2); + + printf("1\n"); fflush(stdout); + + vmwTextXY("SCORE",241,1,127,0,0,tb1_font,vaddr2); + vmwTextXY("SCORE",242,2,143,0,0,tb1_font,vaddr2); + makehole(10,vaddr2); + sprintf(it,"%d",game_state->score); + vmwTextXY(it,250+(8*(8-strlen(it))),11,12,0,1,tb1_font,vaddr2); + + printf("2\n"); fflush(stdout); + + + hiscore=showhiscore(game_state,0); + printf("show high done\n"); fflush(stdout); + + vmwTextXY("HI-SCORE",241,21,127,0,0,tb1_font,vaddr2); + vmwTextXY("HI-SCORE",242,22,143,0,0,tb1_font,vaddr2); + sprintf(it,"%d",hiscore); + makehole(30,vaddr2); + vmwTextXY(it,250+(8*(8-strlen(it))),31,12,0,1,tb1_font,vaddr2); + + printf("3\n"); fflush(stdout); + + + vmwTextXY("LEVEL",241,41,127,0,0,tb1_font,vaddr2); + vmwTextXY("LEVEL",242,42,143,0,0,tb1_font,vaddr2); + makehole(50,vaddr2); + vmwTextXY("SHIELDS",241,61,127,0,0,tb1_font,vaddr2); + vmwTextXY("SHIELDS",242,62,143,0,0,tb1_font,vaddr2); + makehole(70,vaddr2); + for(i=0;i<(4*game_state->shields);i++) { + vmwDrawVLine(250+i,71,8,(47-(i/4)),vaddr2); + } + vmwTextXY("WEAPONS",241,81,127,0,0,tb1_font,vaddr2); + vmwTextXY("WEAPONS",242,82,143,0,0,tb1_font,vaddr2); + makehole(90,vaddr2); + + printf("4\n"); fflush(stdout); + + + vmwDrawBox(249,111,65,78,0,vaddr2); + + vmwDrawVLine(249,111,78,24,vaddr2); + vmwDrawHLine(249,111,66,24,vaddr2); + vmwDrawVLine(315,111,78,18,vaddr2); + vmwDrawHLine(249,189,66,18,vaddr2); + + printf("5\n"); fflush(stdout); + + + vmwTextXY(" TB1 ",250,114,2,0,0,tb1_font,vaddr2); + vmwTextXY(" TB1 ",251,115,10,0,0,tb1_font,vaddr2); + vmwTextXY("F1-HELP ",250,124,2,0,0,tb1_font,vaddr2); + vmwTextXY("F1-HELP ",251,125,10,0,0,tb1_font,vaddr2); + vmwTextXY("F2-SAVES",250,134,2,0,0,tb1_font,vaddr2); + vmwTextXY("F2-SAVES",251,135,10,0,0,tb1_font,vaddr2); + vmwTextXY("ESC-QUIT",250,144,2,0,0,tb1_font,vaddr2); + vmwTextXY("ESC-QUIT",251,145,10,0,0,tb1_font,vaddr2); + vmwTextXY("P-PAUSES",250,154,2,0,0,tb1_font,vaddr2); + vmwTextXY("P-PAUSES",251,155,10,0,0,tb1_font,vaddr2); + vmwTextXY("S-SOUND ",250,164,2,0,0,tb1_font,vaddr2); + vmwTextXY("S-SOUND ",251,165,10,0,0,tb1_font,vaddr2); + +} + diff --git a/sidebar.h b/sidebar.h new file mode 100644 index 0000000..26cdd34 --- /dev/null +++ b/sidebar.h @@ -0,0 +1,4 @@ +int change_shields(struct tb1_state *game_state); +int changescore(struct tb1_state *game_state); +void makehole(int y,vmwVisual *target); +void setupsidebar(struct tb1_state *game_state); diff --git a/sound.c b/sound.c index 5061f76..6790d5d 100644 --- a/sound.c +++ b/sound.c @@ -1,11 +1,8 @@ /* "borrowed" from gltron */ #include "sound.h" -#include "SDL.h" -#include "sdl_svmwgraph.h" -#include "tb1_state.h" -#include "tblib.h" #include +#include "tblib.h" /* linux only, at the moment */ diff --git a/story.c b/story.c new file mode 100644 index 0000000..fd59b32 --- /dev/null +++ b/story.c @@ -0,0 +1,389 @@ +#include + +#include "svmwgraph/svmwgraph.h" +#include "tb1_state.h" + +#include "tblib.h" +#include "sound.h" + + + +void story(struct tb1_state *game_state) +{ + int error; + int xtemp,ytemp; + int thrustcol; + float thrust; + char tempch; + int alienchar; + int cycles; + + vmwFont *tb1_font; + + tb1_font=game_state->graph_state->default_font; + +/* +procedure doflames; +begin + + if flames=true then begin + putshape(bigflame1off,vaddr,27,17,213,100); + putshapeover(sflame2off,vaddr,4,4,105,90); + putshapeover(sflame1off,vaddr,4,4,151,71); + putshapeover(sflame2off,vaddr,4,4,218,72); + end + else + begin + putshape(bigflame2off,vaddr,27,17,213,100); + putshapeover(sflame1off,vaddr,4,4,105,90); + putshapeover(sflame2off,vaddr,4,4,151,71); + putshapeover(sflame1off,vaddr,4,4,218,72); + outtextxy(chr(alienchar),10,10,12,0,vaddr,true); + inc(alienchar); + if alienchar>44 then alienchar:=34; + end; + flipd320(vaddr,vga); + vdelay(5); + flames:=not(flames); +end; + +procedure puttruck(xp,yp,frame:integer;where:word); +var xtemp,into,ytemp:integer; + col:byte; +begin + for into:=0 to 7 do begin + if(into+yp>=172) then + if frame=0 then putshapeline(truck1off,where,6,8,xp,yp,into) + else putshapeline(truck2off,where,6,8,xp,yp,into); + end; +end; +*/ + + vmwLoadPicPacked(0,0,game_state->virtual_2,1,1, + tb1_data_file("tbsobj.tb1",game_state->path_to_data)); + /* + for ytemp:=0 to 18 do + for xtemp:=0 to 26 do begin + ShapeTable1^[((ytemp*27)+xtemp)+bigflame1off]:=getpixel(xtemp,ytemp+2,vaddr); + ShapeTable1^[((ytemp*27)+xtemp)+bigflame2off]:=getpixel(xtemp,ytemp+21,vaddr); + end; + for ytemp:=0 to 18 do + for xtemp:=0 to 15 do begin + ShapeTable1^[((ytemp*16)+xtemp)+explo1off]:=getpixel(127+xtemp,ytemp+100,vaddr); + ShapeTable1^[((ytemp*16)+xtemp)+explo2off]:=getpixel(148+xtemp,ytemp+100,vaddr); + end; + for ytemp:=0 to 6 do + for xtemp:=0 to 15 do + ShapeTable1^[((ytemp*16)+xtemp)+rent1off]:=getpixel(168+xtemp,ytemp+100,vaddr); + + for ytemp:=0 to 4 do + for xtemp:=0 to 3 do begin + ShapeTable1^[((ytemp*4)+xtemp)+sflame1off]:=getpixel(xtemp,ytemp+43,vaddr); + ShapeTable1^[((ytemp*4)+xtemp)+sflame2off]:=getpixel(xtemp,ytemp+47,vaddr); + end; + + for ytemp:=0 to 18 do + for xtemp:=0 to 15 do + ShapeTable1^[((ytemp*16)+xtemp)+bargeoff]:=getpixel(xtemp+65,ytemp+100,vaddr); + + for ytemp:=0 to 8 do + for xtemp:=0 to 5 do begin + ShapeTable1^[((ytemp*6)+xtemp)+truck1off]:=getpixel(xtemp+85,ytemp+100,vaddr); + ShapeTable1^[((ytemp*6)+xtemp)+truck2off]:=getpixel(xtemp+95,ytemp+100,vaddr); + end; +*/ + + /******FIRST MESSAGE********/ + vmwClearScreen(game_state->virtual_1,0); + vmwTextXY("THE STORY SO FAR...",20,20,4,0,0,tb1_font,game_state->virtual_1); + vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1); + pauseawhile(7); + + vmwClearScreen(game_state->virtual_1,0); + + vmwLoadPicPacked(0,0,game_state->virtual_2,1,1, + tb1_data_file("tbcobj.tb1",game_state->path_to_data)); + + vmwArbitraryCrossBlit(game_state->virtual_2,129,56,49,132, + game_state->virtual_1,10,10); + vmwTextXY("YOU ARE TOM BOMBEM, A STRANGE",80,10,1,0,0,tb1_font,game_state->virtual_1); + vmwTextXY(" BUT EFFICIENT MEMBER OF",80,20,1,0,0,tb1_font,game_state->virtual_1); + vmwTextXY(" THE LUNAR SPACE FORCE.",80,30,1,0,0,tb1_font,game_state->virtual_1); + vmwTextXY("YOU NEVER SAY MUCH AND YOU ARE",80,50,4,0,0,tb1_font,game_state->virtual_1); + vmwTextXY(" RARELY SEEN OUTSIDE OF",80,60,4,0,0,tb1_font,game_state->virtual_1); + vmwTextXY(" YOUR BLUE SPACESUIT.",80,70,4,0,0,tb1_font,game_state->virtual_1); + vmwTextXY("YOU OFTEN GET YOURSELF IN ",80,90,2,0,0,tb1_font,game_state->virtual_1); + vmwTextXY(" TROUBLE BY SCRATCHING",80,100,2,0,0,tb1_font,game_state->virtual_1); + vmwTextXY(" YOUR HEAD AT INAPPROPRIATE",80,110,2,0,0,tb1_font,game_state->virtual_1); + vmwTextXY(" TIMES.",80,120,2,0,0,tb1_font,game_state->virtual_1); + vmwTextXY("PRESS ANY KEY....",96,185,15,0,0,tb1_font,game_state->virtual_1); + vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1); + pauseawhile(15); + + vmwClearScreen(game_state->virtual_1,0); + + vmwArbitraryCrossBlit(game_state->virtual_2,129,56,49,132, + game_state->virtual_1,260,10); + vmwArbitraryCrossBlit(game_state->virtual_2,99,104,29,81, + game_state->virtual_1,287,13); + + vmwTextXY("IT IS THE YEAR 2028.",10,10,1,0,0,tb1_font,game_state->virtual_1); + vmwTextXY("YOU HAVE BEEN SUMMONED BY",10,30,3,0,0,tb1_font,game_state->virtual_1); + vmwTextXY(" LUNAR DICTATOR-IN-CHIEF",10,40,3,0,0,tb1_font,game_state->virtual_1); + vmwTextXY(" VINCENT WEAVER ABOUT A",10,50,3,0,0,tb1_font,game_state->virtual_1); + vmwTextXY(" TOP SECRET THREAT TO ",10,60,3,0,0,tb1_font,game_state->virtual_1); + vmwTextXY(" INTERPLANETARY SECURITY.",10,70,3,0,0,tb1_font,game_state->virtual_1); + vmwTextXY("YOU ATTEND THE BRIEFING WITH",10,90,5,0,0,tb1_font,game_state->virtual_1); + vmwTextXY(" YOUR USUAL CONFUSED",10,100,5,0,0,tb1_font,game_state->virtual_1); + vmwTextXY(" QUIETNESS. YOU STILL DO",10,110,5,0,0,tb1_font,game_state->virtual_1); + vmwTextXY(" NOT UNDERSTAND YOUR OWN",10,120,5,0,0,tb1_font,game_state->virtual_1); + vmwTextXY(" SUCCESSFULNESS.",10,130,5,0,0,tb1_font,game_state->virtual_1); + vmwTextXY("PRESS ANY KEY....",96,185,15,0,0,tb1_font,game_state->virtual_1); + vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1); + pauseawhile(12); + + vmwLoadPicPacked(0,0,game_state->virtual_1,1,1, + tb1_data_file("tbchief.tb1",game_state->path_to_data)); + + /* Save the area where the error will go */ + vmwArbitraryCrossBlit(game_state->virtual_1,115,55,91,59, + game_state->virtual_2,115,255); + vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1); + pauseawhile(6); + + vmwTextXY("Ahhh.... Mr. Bombem.... ",1,1,15,0,0,tb1_font,game_state->virtual_1); + vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1); + if (game_state->sound_enabled) playGameFX(0); + pauseawhile(2); + + if (game_state->sound_enabled) playGameFX(2); + /* Show fake error message */ + vmwArbitraryCrossBlit(game_state->virtual_2,188,14,91,59, + game_state->virtual_1,115,55); + + vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1); + pauseawhile(6); + + /* Restore background where error was */ + vmwArbitraryCrossBlit(game_state->virtual_2,115,255,91,59, + game_state->virtual_1,115,55); + + vmwTextXY("I'll be brief. ",1,1,15,0,1,tb1_font,game_state->virtual_1); + vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1); + pauseawhile(5); + + vmwTextXY("Do you know how this base was founded?",1,1,15,0,1,tb1_font,game_state->virtual_1); + vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1); + pauseawhile(5); + + vmwTextXY("No? Well watch the screen. ",1,1,15,0,1,tb1_font,game_state->virtual_1); + vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1); + pauseawhile(5); + + /* Put picture on screen */ + vmwArbitraryCrossBlit(game_state->virtual_2,210,75,85,60, + game_state->virtual_1,210,136); + vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1); + pauseawhile(4); + + /******BARGE TAKING OFF***********/ + + vmwLoadPicPacked(0,0,game_state->virtual_2,1,1, + tb1_data_file("tbma1.tb1",game_state->path_to_data)); + + vmwSmallTextXY("MY WIFE AND I FOUNDED",212,3,14,0,0,tb1_font,game_state->virtual_2); + vmwSmallTextXY("THIS BASE IN 2008.",212,9,14,0,0,tb1_font,game_state->virtual_2); + vmwSmallTextXY("THE ONLY WAY TO ",212,16,13,0,0,tb1_font,game_state->virtual_2); + vmwSmallTextXY("FINANCE IT WAS TO",212,22,13,0,0,tb1_font,game_state->virtual_2); + vmwSmallTextXY("ENGAGE IN A DUBIOUS",212,28,13,0,0,tb1_font,game_state->virtual_2); + vmwSmallTextXY("BUSINESS.",212,34,13,0,0,tb1_font,game_state->virtual_2); + vmwSmallTextXY("WE LAUNCHED EARTH'S",212,41,12,0,0,tb1_font,game_state->virtual_2); + vmwSmallTextXY("TRASH INTO SPACE",212,47,12,0,0,tb1_font,game_state->virtual_2); + vmwSmallTextXY("FOR A PROFIT.",212,53,12,0,0,tb1_font,game_state->virtual_2); + vmwSmallTextXY("HERE IS FOOTAGE FROM",212,60,11,0,0,tb1_font,game_state->virtual_2); + vmwSmallTextXY("THE LAST LAUNCH EIGHT",212,66,11,0,0,tb1_font,game_state->virtual_2); + vmwSmallTextXY("YEARS AGO.",212,72,11,0,0,tb1_font,game_state->virtual_2); + + vmwFlipVirtual(game_state->virtual_1,game_state->virtual_2,320,200); + +/* putshape(bargeoff,vaddr,16,18,141,157);*/ + + /* vmwCrossBlit(plb_vis->write,plb_vaddr->read,plb_vis->stride,200);*/ + vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1); + pauseawhile(7); + +#if 0 +/* + + + for ytemp:=191 downto 164 do begin + if ytemp>=172 then blockmove(145,ytemp,152,ytemp+10,vaddr2,145,ytemp,vaddr) + else blockmove(145,172,152,182,vaddr2,145,172,vaddr); + puttruck(145,ytemp,ytemp mod 2,vaddr); + pauseawhile(7); + if keypressed then if readkey=#27 then exit; + flipd320(vaddr,vga); + end; + + pauseawhile(20); + flipd320(vaddr2,vaddr); + putshape(bargeoff,vaddr,16,18,141,157); + thrustcol:=0; + ytemp:=157; + thrust:=0; + while ytemp>-25 do begin + thrust:=thrust+0.05; + if thrustcol<63 then inc(thrustcol); + blockmove(141,ytemp,171,ytemp+30,vaddr2,141,ytemp,vaddr); + for i:=1 to 17 do + if ytemp+i>=0 then + putshapeline(bargeoff,vaddr,16,18,141,ytemp,i); + pauseawhile(5); + if keypressed then if readkey=#27 then exit; + pal(250,thrustcol,0,0); + flipd320(vaddr,vga); + ytemp:=ytemp-round(thrust); + end; +*/ + pauseawhile(5); + + + /****SECOND CHIEF*******/ + ggiSetGCForeground(vis,0]); + ggiDrawBox(vis,0,0,320,200); + GGILoadPicPacked(0,0,vaddr2,1,1, + tb1_data_file("tbcobj.tb1",(char *)tempst), + (ggi_color *)&eight_bit_pal, + (ggi_pixel *)&tb1_pal,color_depth); + GGILoadPicPacked(0,0,vis,1,1, + tb1_data_file("tbchief.tb1",(char *)tempst), + (ggi_color *)&eight_bit_pal, + (ggi_pixel *)&tb1_pal,color_depth); +/* vmwArbitraryCrossBlit(plb_vaddr2->read,7,104,90,21, + plb_vis->write,6,174,plb_vis->stride, + stride_factor); + */ + vmwTextXY("You might wonder why this is important.",1,1,15],0],1,tb1_font,virtual_1); + pauseawhile(6); + vmwTextXY("Last week we received a message. ",1,1,15],0],1,tb1_font,virtual_1); + pauseawhile(6); + vmwTextXY("It is of extra-terrestrial origin. ",1,1,15],0],1,tb1_font,virtual_1); + pauseawhile(6); + vmwTextXY("Watch the screen. ",1,1,15],0],1,tb1_font,virtual_1); + + /*vmwArbitraryCrossBlit(plb_vaddr2->read,210,136,85,59, + plb_vis->write,210,136,plb_vis->stride, + stride_factor);*/ + pauseawhile(4); + + /******ALIEN DELEGATION*****/ + GGILoadPicPacked(0,0,vaddr2,1,1, + tb1_data_file("tbcrash.tb1",(char *)tempst), + (ggi_color *)&eight_bit_pal, + (ggi_pixel *)&tb1_pal,color_depth); + + /*alienchar:=34; + flipd320(vaddr2,vaddr); + flipd320(vaddr,vga); + putshape(bargeoff,vaddr,16,18,97,180); + unfade; + xtemp:=97; + ytemp:=181; + flames:=true; + while ytemp>118 do begin + blockmove(xtemp,ytemp,xtemp+20,ytemp+20,vaddr2,xtemp,ytemp,vaddr); + putshape(bargeoff,vaddr,16,18,xtemp,ytemp); + doflames; + dec(ytemp); + inc(xtemp); + pauseawhile(1); + if keypressed then if readkey=#27 then exit; + end; + blockmove(xtemp,ytemp,xtemp+30,ytemp+30,vaddr2,xtemp,ytemp,vaddr); + pal(0,63,63,63); + putshape(explo1off,vga,16,18,160,118); + pauseawhile(5); + if keypressed then if readkey=#27 then exit; + pal(0,0,0,0); + if sbeffects then startsound(sound[3],0,false); + for xtemp:=0 to 10 do begin + putshapeover(explo2off,vaddr,16,18,160,118); + doflames; + putshapeover(explo1off,vaddr,16,18,160,118); + doflames; + end; + blockmove(159,114,189,144,vaddr2,159,114,vaddr); + putshapeover(rent1off,vaddr,16,6,160,115); + flipd320(vaddr,vga); + cycles:=0; + repeat + doflames; + inc(cycles); + until ((keypressed) or (cycles>60)); + if keypressed then if readkey=#27 then exit; + */ + + /****ALIEN MESSAGE*****/ + GGILoadPicPacked(0,0,vis,1,1, + tb1_data_file("tbgorg.tb1",(char *)tempst), + (ggi_color *)&eight_bit_pal, + (ggi_pixel *)&tb1_pal,color_depth); + vmwTextXY("GREETINGS EARTHLINGS.",0,162,12],0],0,tb1_font,virtual_1); + vmwTextXY("I AM GORGONZOLA THE REPULSIVE.",0,171,12],0],0,tb1_font,virtual_1); + vmwTextXY("YOU HAVE MADE A BIG MISTAKE.",0,180,12],0],0,tb1_font,virtual_1); + pauseawhile(7); + vmwTextXY("YOUR SHIP FULL OF REFUSE HAS",0,162,12],0],1,tb1_font,virtual_1); + vmwTextXY("DAMAGED OUR OFFICIAL PEACE ",0,171,12],0],1,tb1_font,virtual_1); + vmwTextXY("ENVOY. IT WAS ON ITS WAY TO ",0,180,12],0],1,tb1_font,virtual_1); + vmwTextXY("YOUR PLANET. ",0,189,12],0],1,tb1_font,virtual_1); + pauseawhile(7); + vmwTextXY("IN AN IRONIC FORM OF RETALLIATION",0,162,12],0],1,tb1_font,virtual_1); + vmwTextXY("WE HAVE MADE YOUR TRASH EVIL AND",0,171,12],0],1,tb1_font,virtual_1); + vmwTextXY("TURNED IT AGAINST YOU. ",0,180,12],0],1,tb1_font,virtual_1); + vmwTextXY(" DIE EARTH SCUM! ",0,189,12],0],1,tb1_font,virtual_1); + pauseawhile(7); + + /****** THIRD CHIEF *******/ + GGILoadPicPacked(0,0,vaddr2,1,1, + tb1_data_file("tbcobj.tb1",(char *)tempst), + (ggi_color *)&eight_bit_pal, + (ggi_pixel *)&tb1_pal,color_depth); + GGILoadPicPacked(0,0,virtual_1,1,1, + tb1_data_file("tbchief.tb1",(char *)tempst), + (ggi_color *)&eight_bit_pal, + (ggi_pixel *)&tb1_pal,color_depth); + vmwArbitraryCrossBlit(plb_vaddr2->read,7,127,90,21, + plb_vis->write,6,174,plb_vis->stride, + stride_factor); + + vmwTextXY("Tom, our radar detects approaching ",1,1,15],0],1,tb1_font,virtual_1); + pauseawhile(6); + vmwTextXY("objects. They are inside the ",1,1,15],0],1,tb1_font,virtual_1); + pauseawhile(6); + vmwTextXY("orbit of Jupiter. ",1,1,15],0],1,tb1_font,virtual_1); + pauseawhile(6); + vmwTextXY("You are our only hope! ",1,1,15],0],1,tb1_font,virtual_1); + pauseawhile(6); + vmwTextXY("Will you fly our only spaceship ",1,1,15],0],1,tb1_font,virtual_1); + pauseawhile(6); + vmwTextXY("and save the human race? ",1,1,15],0],1,tb1_font,virtual_1); + pauseawhile(6); + vmwArbitraryCrossBlit(plb_vaddr2->read,5,16,39,82, + plb_vis->write,146,59,plb_vis->stride, + stride_factor); + pauseawhile(1); + vmwArbitraryCrossBlit(plb_vaddr2->read,46,16,39,82, + plb_vis->write,146,59,plb_vis->stride, + stride_factor); + pauseawhile(1); + vmwArbitraryCrossBlit(plb_vaddr2->read,87,16,39,82, + plb_vis->write,146,59,plb_vis->stride, + stride_factor); + vmwTextXY("Scratch. Scratch. ",1,1,9],0],1,tb1_font,virtual_1); + pauseawhile(5); + vmwTextXY("I knew you'd do it. Good Luck! ",1,1,15],0],1,tb1_font,virtual_1); + pauseawhile(6); + vmwTextXY(" ",1,1,9],0],1,tb1_font,virtual_1); + pauseawhile(10); +#endif +} diff --git a/story.h b/story.h new file mode 100644 index 0000000..e3ab10a --- /dev/null +++ b/story.h @@ -0,0 +1 @@ +void story(struct tb1_state *game_state); diff --git a/svmwgraph/Makefile b/svmwgraph/Makefile index 138afce..cffbec6 100644 --- a/svmwgraph/Makefile +++ b/svmwgraph/Makefile @@ -1,12 +1,13 @@ -INCLUDE= -Wall -O2 +INCLUDE= -Wall -O2 -I/usr/local/include/SDL LIBS= -lSDL -lSDL_mixer -L/usr/X11R6/lib -lX11 -lpthread -all: svmwgraph.a +all: libsvmwgraph.a -svmwgraph.a: vmw_core.o vmw_flip.o vmw_font.o vmw_paintpro.o vmw_palette.o vmw_sprite.o - echo "hello" +libsvmwgraph.a: vmw_core.o vmw_flip.o vmw_font.o vmw_paintpro.o vmw_palette.o vmw_setup.o vmw_sprite.o sdl_svmwgraph.o + ar cru libsvmwgraph.a vmw_core.o vmw_flip.o vmw_font.o vmw_paintpro.o vmw_palette.o vmw_setup.o vmw_sprite.o sdl_svmwgraph.o + ranlib libsvmwgraph.a vmw_core.o: vmw_core.c gcc $(INCLUDE) -c vmw_core.c @@ -23,8 +24,14 @@ vmw_paintpro.o: vmw_paintpro.c vmw_palette.o: vmw_palette.c gcc $(INCLUDE) -c vmw_palette.c +vmw_setup.o: vmw_setup.c + gcc $(INCLUDE) -c vmw_setup.c + vmw_sprite.o: vmw_sprite.c gcc $(INCLUDE) -c vmw_sprite.c - + +sdl_svmwgraph.o: sdl_svmwgraph.c + gcc $(INCLUDE) -c sdl_svmwgraph.c + clean: - rm -f svmwgraph.a *.o *~ + rm -f libsvmwgraph.a *.o *~ diff --git a/svmwgraph/sdl_svmwgraph.c b/svmwgraph/sdl_svmwgraph.c index 5be268b..a2986c7 100644 --- a/svmwgraph/sdl_svmwgraph.c +++ b/svmwgraph/sdl_svmwgraph.c @@ -1,37 +1,66 @@ -/* I will finish this game!!! */ -/* This is the SDL implementation of the Super VMW graphics library */ -/* Which was originally a lot of Turbo-Pascal w inline assembly */ +/* The SDL hooks for the Super VMW graphics library */ -#include -#include -#include -#include -#include -#include "SDL.h" -#include "tb_keypress.h" +#include +#include "svmwgraph.h" +#include /* For atexit() */ + + /* Setup the Graphics */ +void *SDL_setupGraphics(int xsize,int ysize,int bpp,int verbose) +{ + SDL_Surface *sdl_screen; + + /* Initialize the SDL library */ + if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) { + fprintf(stderr, + "Couldn't initialize SDL: %s\n", SDL_GetError()); + return NULL; + } + + /* Clean up on exit */ + atexit(SDL_Quit); + + /* Initialize the display */ + sdl_screen = SDL_SetVideoMode(xsize, ysize, 16, SDL_SWSURFACE); + if ( sdl_screen == NULL ) { + fprintf(stderr, "Couldn't set %dx%dx%d video mode: %s\n", + xsize,ysize,bpp,SDL_GetError()); + exit(1); + } + if (verbose) { + printf(" + SDL Graphics Initialization successful...\n"); + printf(" + Using %dx%dx%dbpp Visual...\n",xsize,ysize,bpp); + } + return sdl_screen; +} -void vmwBlitMemToSDL(SDL_Surface *target, unsigned char *source) { + +void SDL_NoScale16bpp_BlitMem(vmwSVMWGraphState *target_p, vmwVisual *source) { int x,y,Bpp; unsigned char *s_pointer,*t_pointer; - + SDL_Surface *target; + + target=(SDL_Surface *)target_p->output_screen; + if ( SDL_MUSTLOCK(target) ) { if ( SDL_LockSurface(target) < 0 ) return; } - Bpp= target->format->BytesPerPixel; + Bpp=target->format->BytesPerPixel; - s_pointer=source; + s_pointer=source->memory; t_pointer=((Uint8 *)target->pixels); + +// printf("%i %i\n",source->xsize,source->ysize); - for (x=0;x<320;x++) - for (y=0;y<200;y++) { - *((Uint16 *)(t_pointer))=*((Uint16 *)(s_pointer)); - s_pointer+=2; t_pointer+=2; + for (x=0;xxsize;x++) + for (y=0;yysize;y++) { + *((Uint16 *)(t_pointer))=source->palette[*(s_pointer)]; + s_pointer++; t_pointer+=2; } @@ -41,19 +70,19 @@ void vmwBlitMemToSDL(SDL_Surface *target, unsigned char *source) { } /* Write this out to the screen */ - SDL_UpdateRect(target, 0, 0, 320, 200); + SDL_UpdateRect(target, 0, 0, source->xsize, source->ysize); } -void vmwClearKeyboardBuffer() { +void SDL_clearKeyboardBuffer() { SDL_Event event; while (SDL_PollEvent(&event)) { } } -int vmwGetInput() { +int SDL_getInput() { SDL_Event event; int keypressed; @@ -64,17 +93,17 @@ int vmwGetInput() { case SDL_KEYDOWN: keypressed=event.key.keysym.sym; switch (keypressed) { - case SDLK_BACKSPACE: return TB_BACKSPACE; - case SDLK_ESCAPE : return TB_ESCAPE; - case SDLK_RETURN : return TB_ENTER; - case SDLK_UP : return TB_UP; - case SDLK_DOWN : return TB_DOWN; - case SDLK_RIGHT : return TB_RIGHT; - case SDLK_LEFT : return TB_LEFT; - case SDLK_F1 : return TB_F1; - case SDLK_F2 : return TB_F2; - case SDLK_PAGEUP : return TB_PGUP; - case SDLK_PAGEDOWN : return TB_PGDN; + case SDLK_BACKSPACE: return VMW_BACKSPACE; + case SDLK_ESCAPE : return VMW_ESCAPE; + case SDLK_RETURN : return VMW_ENTER; + case SDLK_UP : return VMW_UP; + case SDLK_DOWN : return VMW_DOWN; + case SDLK_RIGHT : return VMW_RIGHT; + case SDLK_LEFT : return VMW_LEFT; + case SDLK_F1 : return VMW_F1; + case SDLK_F2 : return VMW_F2; + case SDLK_PAGEUP : return VMW_PGUP; + case SDLK_PAGEDOWN : return VMW_PGDN; default: return keypressed; } default: break; diff --git a/svmwgraph/sdl_svmwgraph.h b/svmwgraph/sdl_svmwgraph.h new file mode 100644 index 0000000..f85842f --- /dev/null +++ b/svmwgraph/sdl_svmwgraph.h @@ -0,0 +1,8 @@ +/* The SDL hooks for the Super VMW graphics library */ + +#include + +void *SDL_setupGraphics(int xsize,int ysize,int bpp,int verbose); +void SDL_NoScale16bpp_BlitMem(vmwSVMWGraphState *target, vmwVisual *source); +void SDL_clearKeyboardBuffer(); +int SDL_getInput(); diff --git a/svmwgraph/svmwgraph.c b/svmwgraph/svmwgraph.c deleted file mode 100644 index 2db01c0..0000000 --- a/svmwgraph/svmwgraph.c +++ /dev/null @@ -1,511 +0,0 @@ -/* I will finish this game!!! */ -/* This is an implementation of the Super VMW graphics library */ -/* Which was originally a lot of Turbo-Pascal w inline assembly */ - -#include -#include -#include -#include -#include -#include "tb_keypress.h" - -/* For now, sort of hard-coded in */ -#include "SDL_svmwgraph.h" - -//#define DEBUG 1 /* Until we get to Beta */ - -int vmwPack3Bytes(int r, int g, int b) { - - return ( ( ( (r>>3)&0x1f) <<11)+ - ( ( (g>>2)&0x3f) <<5)+ - ( ( (b>>3)&0x1f) ) ); -} - -void vmwLoadCustomPalette(vmwGraphState *state, int pal[256]) { - int i; - for (i=0;i<256;i++) { - state->palette[i]=pal[i]; - } -} - - - /*---------------------------------------------------------------*\ - | vmwPutPixel | - \*---------------------------------------------------------------*/ - -void vmwPutPixel(int x,int y,int color,vmwVisual *target) { - -#ifdef DEBUG - if ( (y> (target->ysize-1) ) || (x> (target->xsize-1) ) ) { - printf("Out of bounds with PutPixel %i,%i\n",x,y); - return; - } -#endif - - target->memory[(y*target->xsize)+x]=color; - -} - -unsigned char vmwGetPixel(int x,int y,vmwVisual *source) { - - return source->memory[(y*source->xsize)+x]; - -} - - -void vmwClearScreen(vmwVisual *target, int color) { - - memset(target->memory,color,target->xsize*target->ysize); - -} - - /*---------------------------------------------------------------*\ - | vmwDrawHLine | - | This is really begging to be optimized. I am sure some | - | targets can do this in hardware | - \*---------------------------------------------------------------*/ - -void vmwDrawHLine(int xstart,int ystart,int how_long,int color, - vmwVisual *target) { - - unsigned char *temp_pointer; - int i; - - temp_pointer=target->memory+(ysart*target->xsize)+xstart; - - for(i=0;ixsize)+xstart; - - for(i=0;ixsize; - } -} - - - /*---------------------------------------------------------------*\ - | vmwLoadPicPacked | - | There is so much history in this function, I won't get into | - | it here. | - \*---------------------------------------------------------------*/ - -int vmwLoadPicPacked(int x1,int y1,vmwVisual *target, - int LoadPal,int LoadPic,char *FileName) - - /* Retro comments */ -/*{ Loads a paintpro image, filename, at location x1,y1 *\ -\* to offset where (vga=$A000) and loadspal if LOADPAL=true */ -/* Loadsapicture if Loadpic=true and returns error} */ - -{ - unsigned char temp1,temp2,temp3; - int errorlev; - int int1,int2,i,x,y; - char buffer[300]; - int lastread=0; - int buffpointer=0; - int picwidth,picheight; - FILE *fff; - char header[10]; - int xsize; - int ysize; - int numcolors; - int col,numacross; - int temp_palette[256]; - - /* Open the file */ - fff=fopen(FileName,"rb"); /* Windows chokes if no "b" */ - if (fff==NULL){ - printf("PPRO error... File \"%s\" not found.\n",FileName); - return 1; - } - - errorlev=fread(buffer,1,300,fff); - /* Check to see if its really a Paintpro File */ - for (i=0;i<9;i++) { - header[i]=buffer[i]; - } - header[9]='\0'; - if (strncmp(header,"PAINTPROV",9)) { - printf("PPRO error... %s is NOT a paintpro file!\n",FileName); - return 2; - } - - /* Check to see if it is the proper version (currently 6.0) */ - header[0]=buffer[9]; - header[1]=buffer[10]; - header[2]=buffer[11]; - header[3]='\0'; - if (strncmp(header,"6.0",3)) { - printf("PPRO error... Version %s unsupported, must be >6\n",header); - return 3; - } - - buffpointer=12; - /* Read X and Y sizes */ - temp1=buffer[buffpointer]; - temp2=buffer[buffpointer+1]; - temp3=buffer[buffpointer+2]; - buffpointer+=3; - if (buffpointer>=errorlev) { - printf("PPRO error... Early end of file.\n"); - return 4; - } - - /* Split 48 bits into two 32 bit values */ - xsize=(temp2>>4)+(temp1<<4); - ysize=((temp2-((temp2>>4)<<4))<<16)+temp3; - - temp1=buffer[buffpointer]; - temp2=buffer[buffpointer+1]; - temp3=buffer[buffpointer+2]; - buffpointer+=3; - if (buffpointer>=errorlev) { - printf("PPRO error... Early end of file.\n"); - return 4; - } - - numcolors=(temp2>>4)+(temp1<<4); - - picwidth=xsize+1; - picheight=ysize+1; - /*Load Palette*/ - if (numcolors!=256) printf("%d colors is not supported yet.\n",numcolors); - - /* Fun and games to convert the 24 bit color in paintpro to */ - /* 565 packed 16bit RGB */ - - for(i=0;i<256;i++) { - temp_palette[i]=vmwPack3Bytes(buffer[buffpointer], - buffer[buffpointer+1], - buffer[buffpointer+2]); - buffpointer+=3; - if (buffpointer>=errorlev) { - if (errorlev==300) { - errorlev=fread(buffer,1,300,fff); - buffpointer=0; - } - else { - lastread=1; - } - } - } - - if (LoadPal) { - for (i=0;i<256;i++) global_palette[i]=temp_palette[i]; - } - - - x=x1; - y=y1; - - while ((!lastread)&&(LoadPic)&&(y=errorlev) { - if (errorlev==300) { - errorlev=fread(buffer,1,300,fff); - buffpointer=0; - } - else lastread=1; - } - - int1=(temp2>>4)+(temp1<<4); - int2=((temp2-((temp2>>4)<<4))*256)+temp3; - - /* If greater than 2047, we have two single pixels */ - /* of color int1-2048 and int2-2048 */ - if (int1>2047) { - vmwPutPixel(x,y,int1-2048,target); - x++; - if (x>xsize+x1) { - x=x1; y++; -// if (y>ysize-1) { -// printf("Blargh 1\n"); y--; -// } - } - vmwPutPixel(x,y,int2-2048,target); - x++; - if (x>xsize+x1){ - x=x1;y++; -// if (y>ysize) { -// printf("Blargh 2\n"); -// y--; -// } - } - } - else { /* Standard paintpro format */ - col=int1; - numacross=int2; - while ((x+numacross)>(xsize+x1)) { - vmwDrawHLine(x,y,((xsize+x1)-x),col,target); - numacross=numacross-((xsize+1)-x); - x=x1; - y++; - if (y>y1+ysize-1) { - printf("Blrgh 3\n"); - } - } - if ((numacross!=0) && (yxsize+x-1) numacross--; /* Stupid x overflow */ - vmwDrawHLine(x,y,numacross,col,target); - } - x=x+numacross; - } - } - - if (fff!=NULL) fclose(fff); - return 0; -} - -void vmwFlipVirtual(vmwVisual *destination, - vmwVisual *source) { - - memcpy(destination,source,source->xsize*source->ysize); - -} - -int vmwCrossBlit(char *dest,char *src,int stride,int ysize) -{ - /* - * - int y; - - for (y = 0; y < ysize; y++) { - memcpy (dest, src, stride); - src += stride; - dest += stride; - } - */ - return 0; -} - -int vmwCrossBlit240(char *dest,char *src,int stride,int stride_factor, - int ysize) -{ - /* - int y; - - for (y = 0; y < ysize; y++) { - memcpy (dest, src, (240*stride_factor)); - src += stride; - dest += stride; - } - */ - return 0; -} - -int vmwArbitraryCrossBlit(vmwVisual *src,int x1,int y1,int w,int h, - vmwVisual *dest,int x2,int y2) -{ - - int y; - unsigned char *source,*destination; - - - source=src+(320*2*y1); - destination=dest+(320*2*y2); - - for(y=0;ywidth=xsize; - font->height=ysize; - font->numchars=numchars; - font->font_data=data; - fonty=0; - while ( (!feof(f))&&(fontyfont_data[fonty+i]=buff[i]; - fonty+=16; - } - fclose(f); - return font; -} - -/*int bit(unsigned char mree,int whichbit) -{ - return mree&(128>>whichbit); -} - */ - -void vmwTextLineOver(char *st,int x,int y,int col,int background,int line, - vmw_font *font,vmwVisual *target) -{ - int i,xx,len; - len=strlen(st); - for(i=0;ifont_data[(st[i]*font->height)+line])&(128>>xx) ) - vmwPutPixel((x+(i*8)+xx),y,col,target); - else - vmwPutPixel((x+(i*8)+xx),y,background,target); - } -} - - -void vmwTextLine(char *st,int x,int y,int col,int background,int line, - vmw_font *font,vmwVisual *target) -{ - int i,len,xx; - len=strlen(st); - for(i=0;ifont_data[(st[i]*16)+line])) - &(128>>xx) ) { - vmwPutPixel(x+(i*8)+xx,y,col,target); - } -} - -void vmwTextXY(char *st,int x,int y,int col,int background,int overwrite, - vmw_font *font,vmwVisual *target) -{ - int lineon,i,xx,len; - - len=strlen(st); - for(lineon=0;lineon<8;lineon++){ - for(i=0;ifont_data[(st[i]*font->height)+lineon])&(128>>xx) ) - vmwPutPixel((x+(i*8)+xx),y+lineon,col,target); - else - if(overwrite) vmwPutPixel((x+(i*8)+xx),y+lineon,background,target); - } - } - /*VMWtextlineover(st,x,y+lineon,col,background,lineon,font,vis);*/ - /* VMWtextline(st,x,y+lineon,col,background,lineon,font,vis);*/ -} - - -void vmwSmallTextXY(char *st,int x,int y,int col,int background,int overwrite, - vmw_font *font,vmwVisual *target) -{ - int lineon,i,xx,len; - - /* This will print out a small 4x5 font located in chars */ - /* 128-255 in a normal VGA font. These are custom made */ - /* fonts they are non-standard */ - - len=strlen(st); - for(lineon=0;lineon<5;lineon++) { - for(i=0;ifont_data[((st[i]+128)*font->height)+lineon])&(128>>xx) ) - vmwPutPixel((x+(i*5)+xx),y+lineon,col,target); - else - if(overwrite) vmwPutPixel((x+(i*5)+xx),y+lineon,background,target); - } - } -} - - -void vmwLine(int x1, int y1, int x2, int y2, int color, vmwVisual *destination) { - -/*function sgn(a:real):integer; -begin - if a>0 then sgn:=+1; - if a<0 then sgn:=-1; - if a=0 then sgn:=0; -end; - -procedure line(a,b,c,d,col:integer;where:word); -var u,s,v,d1x,d1y,d2x,d2y,m,n:real; - i:integer; -begin - u:= c - a; - v:= d - b; - d1x:= SGN(u); - d1y:= SGN(v); - d2x:= SGN(u); - d2y:= 0; - m:= ABS(u); - n := ABS(v); - IF NOT (M>N) then - BEGIN - d2x := 0 ; - d2y := SGN(v); - m := ABS(v); - n := ABS(u); - END; - s := INT(m / 2); - FOR i := 0 TO round(m) DO - BEGIN - putpixel(a,b,col,where); - s := s + n; - IF not (s -// #define DEBUG 1 +#define DEBUG 1 /*---------------------------------------------------------------*\ | vmwPutPixel | @@ -51,6 +52,12 @@ void vmwDrawHLine(int xstart,int ystart,int how_long,int color, for(i=0;itarget->xsize-1) { + printf("Out of bounds!\n"); + return; + } +#endif } } diff --git a/svmwgraph/vmw_flip.c b/svmwgraph/vmw_flip.c index 6680822..632073f 100644 --- a/svmwgraph/vmw_flip.c +++ b/svmwgraph/vmw_flip.c @@ -5,9 +5,9 @@ #include /* For memcpy() */ void vmwFlipVirtual(vmwVisual *destination, - vmwVisual *source) { + vmwVisual *source, int xsize,int ysize) { - memcpy(destination,source,source->xsize*source->ysize); + memcpy(destination->memory,source->memory,xsize*ysize); } @@ -25,7 +25,7 @@ int vmwArbitraryCrossBlit(vmwVisual *src,int x1,int y1,int w,int h, for(y=0;yxsize; - destination+=dest->ysize; + destination+=dest->xsize; } return 0; diff --git a/svmwgraph/vmw_paintpro.c b/svmwgraph/vmw_paintpro.c index 18191b5..cc2d963 100644 --- a/svmwgraph/vmw_paintpro.c +++ b/svmwgraph/vmw_paintpro.c @@ -5,15 +5,6 @@ #include /* For FILE I/O */ #include /* For strncmp */ - - /* The "packing" method used by paintpro files */ -int vmwPack3Bytes(int r, int g, int b) { - - return ( ( ( (r>>3)&0x1f) <<11)+ - ( ( (g>>2)&0x3f) <<5)+ - ( ( (b>>3)&0x1f) ) ); -} - /*---------------------------------------------------------------*\ | vmwLoadPicPacked | | There is so much history in this function, I won't get into | diff --git a/svmwgraph/vmw_palette.c b/svmwgraph/vmw_palette.c index 8ef0eb0..5d95172 100644 --- a/svmwgraph/vmw_palette.c +++ b/svmwgraph/vmw_palette.c @@ -3,6 +3,15 @@ #include "svmwgraph.h" + /* The "packing" method used by the 16 bit palette */ +int vmwPack3Bytes(int r, int g, int b) { + + return ( ( ( (r>>3)&0x1f) <<11)+ + ( ( (g>>2)&0x3f) <<5)+ + ( ( (b>>3)&0x1f) ) ); +} + + void vmwLoadCustomPalette(vmwVisual *source, int pal[256]) { int i; for (i=0;i<256;i++) { diff --git a/svmwgraph/vmw_setup.c b/svmwgraph/vmw_setup.c index 2582d00..b09b1af 100644 --- a/svmwgraph/vmw_setup.c +++ b/svmwgraph/vmw_setup.c @@ -1,11 +1,68 @@ +/* Routines for setting up structures for the Super VMW graphics library */ +#include "svmwgraph.h" +#include "sdl_svmwgraph.h" /* Make this dynamic somehow? */ +#include /* For printf */ +#include /* For Memory Allocation */ -int vmwSetup() { - // malloc structs - // point to SDL +void *(*vmwSetupGraphics)(int xsize,int ysize, int bpp, int verbose); +void (*vmwBlitMemToDisplay)(vmwSVMWGraphState *display, vmwVisual *source); +void (*vmwClearKeyboardBuffer)(void); +int (*vmwGetInput)(void); + +vmwSVMWGraphState *vmwSetupSVMWGraph(int display_type,int xsize,int ysize, + int bpp,int verbose) { + + vmwSVMWGraphState *temp_state; + + if ( (temp_state=calloc(1,sizeof(vmwSVMWGraphState)) )==NULL) { + printf("Error allocating memory!\n"); + return NULL; + } + + switch (display_type) { + case VMW_SDLTARGET: vmwSetupGraphics=SDL_setupGraphics; + vmwBlitMemToDisplay=SDL_NoScale16bpp_BlitMem; + vmwClearKeyboardBuffer=SDL_clearKeyboardBuffer; + vmwGetInput=SDL_getInput; + temp_state->output_screen= + vmwSetupGraphics(xsize,ysize,bpp,verbose); + break; + default: printf("ERROR! Unknown Display Target %i.\n",display_type); + return NULL; + } + + temp_state->xsize=xsize; + temp_state->ysize=ysize; + temp_state->bpp=bpp; + temp_state->default_font=NULL; + + return temp_state; } -int vmwSetupVisual() { - // malloc stuff +vmwVisual *vmwSetupVisual(int xsize,int ysize,int palette_size) { + + vmwVisual *temp_visual; + + if ( (temp_visual=calloc(1,sizeof(vmwVisual)) )==NULL) { + printf("Error allocating memory for visual!\n"); + return NULL; + } + temp_visual->xsize=xsize; + temp_visual->ysize=ysize; + temp_visual->palette_size=palette_size; + + if ( (temp_visual->memory= + calloc(xsize*ysize,sizeof(unsigned char)) )==NULL) { + printf("Error allocating %i x %i visual memory!\n",xsize,ysize); + return NULL; + } + if ( (temp_visual->palette= + calloc(palette_size,sizeof(int)) )==NULL) { + printf("Error allocating palette of size %i!\n",palette_size); + return NULL; + } + return temp_visual; + } diff --git a/svmwgraph/vmw_sprite.c b/svmwgraph/vmw_sprite.c index 299f753..e1b6425 100644 --- a/svmwgraph/vmw_sprite.c +++ b/svmwgraph/vmw_sprite.c @@ -24,14 +24,14 @@ vmwSprite *vmwGetSprite(int x, int y, return temp_sprite; } -void vmwPutSprite(vmwSprite *sprite,int x,int y,int shield_color, +void vmwPutSprite(vmwSprite *sprite,int x,int y, vmwVisual *screen) { unsigned char *temp_source,*temp_destination; int xx,yy; temp_source=sprite->spritedata; - temp_destination= (unsigned char *)(screen)+(y*320+x); + temp_destination= (unsigned char *)(screen->memory)+(y*screen->xsize+x); for (yy=0;yyysize;yy++) { for (xx=0;xxxsize;xx++) { diff --git a/tb1.c b/tb1.c index c713279..b140b15 100644 --- a/tb1.c +++ b/tb1.c @@ -1,6 +1,6 @@ /****************************************************************\ \* TOM BOMBEM AND THE INVASION OF THE INANIMATE_OBJECTS */ -/* version 2.9.1 5 August 2000 *\ +/* version 2.9.2 15 September 2000 *\ \* by Vince Weaver weave@eng.umd.edu */ /* *\ \* Originally written in Pascal and x86 assembly for DOS */ @@ -10,49 +10,28 @@ \* This source is released under the GPL */ /****************************************************************/ -#define TB1_VERSION "2.9.1" +#define TB1_VERSION "2.9.2" -#include #include -#include -#include -#include +#include /* for calloc */ +#include /* for strncpy */ #include #include -#include "SDL.h" -#include "sdl_svmwgraph.h" +#include "svmwgraph/svmwgraph.h" #include "tb1_state.h" #include "tblib.h" -#include "tb_keypress.h" #include "sound.h" - /* Setup the Graphics */ -int setup_graphics(struct tb1_state *state) -{ - - /* Initialize the SDL library */ - if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) { - fprintf(stderr, - "Couldn't initialize SDL: %s\n", SDL_GetError()); - exit(1); - } - - /* Clean up on exit */ - atexit(SDL_Quit); - - /* Initialize the display in a 640x480 8-bit palettized mode */ - state->sdl_screen = SDL_SetVideoMode(320, 200, 16, SDL_SWSURFACE); - if ( state->sdl_screen == NULL ) { - fprintf(stderr, "Couldn't set 320x200x8 video mode: %s\n", - SDL_GetError()); - exit(1); - } - - printf(" + SDL Graphics Initialization successful...\n"); - printf(" + Running TB1 in %dbpp Mode...\n",16); - return 0; -} +#include "menu_tools.h" +#include "help.h" +#include "quit.h" +#include "story.h" +#include "credits.h" +#include "about.h" +#include "loadgame.h" +#include "options.h" +#include "playgame.h" int command_line_help(int show_version,char *runas) { @@ -75,12 +54,13 @@ int main(int argc,char **argv) int i,grapherror,reloadpic=0; int custom_palette[256]; int ch,x,barpos,time_sec; + int scale=1; FILE *fff; - unsigned char *virtual_1,*virtual_2; + vmwVisual *virtual_1,*virtual_2; struct tb1_state *game_state; - vmw_font *tb1_font; + vmwFont *tb1_font; struct timeval time_info; struct timezone dontcare; @@ -101,9 +81,7 @@ int main(int argc,char **argv) game_state->virtual_1=NULL; game_state->virtual_2=NULL; game_state->virtual_3=NULL; - game_state->sdl_screen=NULL; game_state->sound_enabled=1; - game_state->tb1_font=NULL; /* Parse Command Line Arguments */ i=1; @@ -117,7 +95,6 @@ int main(int argc,char **argv) case 'n': game_state->sound_enabled=0; -// sound_possible=0; printf(" + Sound totally disabled\n"); break; case 'r': @@ -182,28 +159,31 @@ int main(int argc,char **argv) printf(" + Loaded sounds...\n"); - /* Load the tom bombem font */ - game_state->tb1_font=vmwLoadFont(tb1_data_file("tbfont.tb1",game_state->path_to_data),8,16,256); - printf(" + Loaded tb1 font...\n"); - /* Setup Graphics */ - if (setup_graphics(game_state)) { + if ( (game_state->graph_state=vmwSetupSVMWGraph(VMW_SDLTARGET, + 320*scale,200*scale, + 16,1))==NULL) { fprintf(stderr,"ERROR: Couldn't get display set up properly.\n"); - return 2; + return VMW_ERROR_DISPLAY; } - - - if ((game_state->virtual_1=calloc(320*200,2))==NULL) { + + /* Load the tom bombem font */ + game_state->graph_state->default_font= + vmwLoadFont(tb1_data_file("tbfont.tb1", + game_state->path_to_data),8,16,256); + printf(" + Loaded tb1 font...\n"); + + if ((game_state->virtual_1=vmwSetupVisual(320,200,256))==NULL) { fprintf(stderr,"ERROR: Couldn't get RAM for virtual screen 1!\n"); - return 3; + return VMW_ERROR_MEM; } - if ((game_state->virtual_2=calloc(320*400,2))==NULL) { + if ((game_state->virtual_2=vmwSetupVisual(320,400,256))==NULL) { fprintf(stderr,"ERROR: Couldn't get RAM for virtual screen 2!\n"); - return 3; + return VMW_ERROR_MEM; } - if ((game_state->virtual_3=calloc(320*200,2))==NULL) { + if ((game_state->virtual_3=vmwSetupVisual(320,200,256))==NULL) { fprintf(stderr,"ERROR: Couldn't get RAM for virtual screen 3!\n"); - return 3; + return VMW_ERROR_MEM; } printf(" + Allocated virtual screens...\n"); @@ -211,7 +191,9 @@ int main(int argc,char **argv) /* To ease typing burden */ virtual_1=game_state->virtual_1; virtual_2=game_state->virtual_2; - tb1_font=game_state->tb1_font; + tb1_font=game_state->graph_state->default_font; + + for (x=0;x<256;x++) custom_palette[x]=vmwPack3Bytes(0,0,0); /* 0=black */ /* Do the VMW Software Production Logo */ for(x=0;x<=40;x++) { @@ -224,10 +206,8 @@ int main(int argc,char **argv) custom_palette[15]=vmwPack3Bytes(0xff,0xff,0xff); /* Finalize Pallette Stuff */ - vmwLoadCustomPalette(custom_palette); - SDL_UpdateRect(game_state->sdl_screen, 0, 0, 0, 0); - - + vmwLoadCustomPalette(virtual_1,custom_palette); + /* Actually draw the stylized VMW */ for(x=0;x<=40;x++){ vmwDrawVLine(x+40,45,2*x,100+x,virtual_1); @@ -245,11 +225,11 @@ int main(int argc,char **argv) } vmwTextXY("A VMW SOFTWARE PRODUCTION",60,140, - 15,15,0,game_state->tb1_font,virtual_1); + 15,15,0,tb1_font,virtual_1); - playSound(); + if (game_state->sound_enabled) playSound(); - vmwBlitMemToSDL(game_state->sdl_screen,virtual_1); + vmwBlitMemToDisplay(game_state->graph_state,virtual_1); pauseawhile(5); stopSound(); @@ -265,28 +245,33 @@ int main(int argc,char **argv) grapherror=vmwLoadPicPacked(0,0,virtual_2,1,1, tb1_data_file("tbomb1.tb1",game_state->path_to_data)); - vmwBlitMemToSDL(game_state->sdl_screen,virtual_1); + vmwBlitMemToDisplay(game_state->graph_state,virtual_1); - /* Main Menu Loop */ while (1) { if (reloadpic) { grapherror=vmwLoadPicPacked(0,0,virtual_2,1,1, tb1_data_file("tbomb1.tb1",game_state->path_to_data)); + grapherror=vmwLoadPicPacked(0,0,virtual_1,1,0, + tb1_data_file("tbomb1.tb1",game_state->path_to_data)); + reloadpic=0; } - vmwFlipVirtual(virtual_1,virtual_2); - playSound(); + vmwFlipVirtual(virtual_1,virtual_2,320,200); + if (game_state->sound_enabled) playSound(); + vmwBlitMemToDisplay(game_state->graph_state,virtual_1); + while (!vmwGetInput()) usleep(300); - + barpos=0; vmwTextXY("F1 HELP",0,190,9,7,0,tb1_font,virtual_1); coolbox(117,61,199,140,1,virtual_1); - vmwBlitMemToSDL(game_state->sdl_screen,virtual_1); + + vmwBlitMemToDisplay(game_state->graph_state,virtual_1); ch=0; - while(ch!=TB_ENTER){ + while(ch!=VMW_ENTER){ if (barpos==0) vmwTextXY("NEW GAME",123,67,32,0,1,tb1_font,virtual_1); else vmwTextXY("NEW GAME",123,67,32,7,1,tb1_font,virtual_1); if (barpos==1) vmwTextXY("OPTIONS",123,77,32,0,1,tb1_font,virtual_1); @@ -302,7 +287,7 @@ int main(int argc,char **argv) if (barpos==6) vmwTextXY("QUIT",123,127,32,0,1,tb1_font,virtual_1); else vmwTextXY("QUIT",123,127,32,7,1,tb1_font,virtual_1); - vmwBlitMemToSDL(game_state->sdl_screen,virtual_1); + vmwBlitMemToDisplay(game_state->graph_state,virtual_1); /* If at title screen too long, run credits */ gettimeofday(&time_info,&dontcare); @@ -314,7 +299,7 @@ int main(int argc,char **argv) if (time_info.tv_sec-time_sec>40) { stopSound(); credits(game_state); - ch=TB_ENTER; + ch=VMW_ENTER; barpos=9; reloadpic=1; gettimeofday(&time_info,&dontcare); @@ -323,9 +308,9 @@ int main(int argc,char **argv) } /* Change menu position based on key pressed */ - if ((ch==TB_DOWN)||(ch==TB_RIGHT)) barpos++; - if ((ch==TB_UP) || (ch==TB_LEFT)) barpos--; - if (ch==TB_F1) {barpos=10; ch=TB_ENTER;} /*F1*/ + if ((ch==VMW_DOWN)||(ch==VMW_RIGHT)) barpos++; + if ((ch==VMW_UP) || (ch==VMW_LEFT)) barpos--; + if (ch==VMW_F1) {barpos=10; ch=VMW_ENTER;} /*F1*/ if (ch=='n') barpos=0; /*N*/ if (ch=='o') barpos=1; /*O*/ if (ch=='a') barpos=2; /*A*/ @@ -333,9 +318,9 @@ int main(int argc,char **argv) if (ch=='s') barpos=4; /*S*/ if (ch=='c') barpos=5; /*C*/ if (ch=='q') barpos=6; /*Q*/ - if (ch==TB_ESCAPE){ /* escape */ + if (ch==VMW_ESCAPE){ /* escape */ barpos=6; - ch=TB_ENTER; + ch=VMW_ENTER; } if(barpos==7) barpos=0; if(barpos<0) barpos=6; diff --git a/tb1_state.h b/tb1_state.h index d80a0e9..ada405d 100644 --- a/tb1_state.h +++ b/tb1_state.h @@ -3,11 +3,10 @@ struct tb1_state { int shields; int shield_color; int score; - unsigned char *virtual_1; - unsigned char *virtual_2; - unsigned char *virtual_3; - SDL_Surface *sdl_screen; + vmwVisual *virtual_1; + vmwVisual *virtual_2; + vmwVisual *virtual_3; + vmwSVMWGraphState *graph_state; int sound_enabled; - vmw_font *tb1_font; char path_to_data[BUFSIZ]; }; diff --git a/tb_keypress.h b/tb_keypress.h deleted file mode 100644 index 6221685..0000000 --- a/tb_keypress.h +++ /dev/null @@ -1,11 +0,0 @@ -#define TB_BACKSPACE 1024 -#define TB_ESCAPE 27 -#define TB_ENTER 1025 -#define TB_UP 1026 -#define TB_DOWN 1027 -#define TB_RIGHT 1028 -#define TB_LEFT 1029 -#define TB_F1 1030 -#define TB_F2 1031 -#define TB_PGUP 1032 -#define TB_PGDN 1033 diff --git a/tblib.c b/tblib.c index c9cae77..f7883d0 100644 --- a/tblib.c +++ b/tblib.c @@ -1,19 +1,8 @@ -#include #include #include #include -#include -#include -#include -#include - -#include "sdl_svmwgraph.h" -#include "tb1_state.h" -#include "levels.h" -#include "tb_keypress.h" -#include "string.h" -#include "sound.h" - +#include +#include "svmwgraph/svmwgraph.h" void pauseawhile(int howlong) { @@ -32,49 +21,10 @@ void pauseawhile(int howlong) { } - - /* Convenience Function */ -int change_shields(struct tb1_state *game_state) -{ - - int itemp,jtemp; - - game_state->shield_color=(game_state->shields)*0x1000; - - vmwDrawBox(250,71,64,8,0,game_state->virtual_1); - for(itemp=0;itemp<(game_state->shields)*4;itemp+=4) - for(jtemp=71;jtemp<79;jtemp++) { - vmwDrawHLine(250+itemp,jtemp,4,(47-(itemp/4)),game_state->virtual_1); - } - return 0; -} - - /* TSIA [well actually FNSIA (function name says it all) */ -int changescore(struct tb1_state *game_state) -{ - - char scorest[20]; - unsigned char *vaddr; - vmw_font *tb1_font; - - tb1_font=game_state->tb1_font; - vaddr=game_state->virtual_1; - - sprintf(scorest,"%d",game_state->score); - vmwTextXY(scorest,317-(strlen(scorest)*9),11, - 12,0,1,tb1_font,vaddr); - if ( ((game_state->score % 400)==0) && (game_state->shields<16) ) { - if (game_state->sound_enabled) - playGameFX(/*SND_ZRRP*/7); - game_state->shields++; - change_shields(game_state); - } - return 0; -} - /* The collision detection routine. Optimize? */ /* Detects if x1,y1 is within x2,y2 */ -int collision(x1,y1,xsize,ysize,x2,y2,x2size,y2size) +int collision(int x1,int y1,int xsize,int ysize, + int x2,int y2,int x2size,int y2size) { if (abs((y1+ysize)-(y2+y2size))<(ysize+y2size)){ if (abs((x1+xsize)-(x2+x2size))<(xsize+x2size)) return 1; @@ -90,1165 +40,3 @@ char *tb1_data_file(char *name,char *path) sprintf(tempst,"%s/%s",path,name); return strdup(tempst); } - -void coolbox(int x1,int y1,int x2,int y2,int fill,unsigned char *target) -{ - int i; - - for(i=0;i<5;i++) { - vmwDrawHLine(x1+i,y1+i,(x2-x1-i-i),31-i,target); - vmwDrawHLine(x1+i,y2-i,(x2-x1-i-i),31-i,target); - vmwDrawVLine(x1+i,y1+i,(y2-y1-i-i),31-i,target); - vmwDrawVLine(x2-i,y1+i,(y2-y1-i-i),31-i,target); - } - if (fill) { - for(i=y1+5;itb1_font; - target=game_state->virtual_1; - sdl_screen=game_state->sdl_screen; - - coolbox(90,75,230,125,1,target); - vmwTextXY("QUIT??? ARE YOU",97,82,9,7,0,tb1_font,target); - vmwTextXY("ABSOLUTELY SURE?",97,90,9,7,0,tb1_font,target); - - while (ch!=TB_ENTER){ - if (barpos==0) vmwTextXY("YES-RIGHT NOW!",97,98,150,0,1,tb1_font,target); - else vmwTextXY("YES-RIGHT NOW!",97,98,150,7,1,tb1_font,target); - if (barpos==1) vmwTextXY("NO--NOT YET.",97,106,150,0,1,tb1_font,target); - else vmwTextXY("NO--NOT YET.",97,106,150,7,1,tb1_font,target); - vmwBlitMemToSDL(sdl_screen,target); - - while ( !(ch=vmwGetInput()) ) { - usleep(30); - } - if ((ch==TB_UP)||(ch==TB_DOWN)||(ch==TB_LEFT)||(ch==TB_RIGHT)) barpos++; - if (ch=='y') barpos=0; - if (ch=='n') barpos=1; - if (barpos==2) barpos=0; - } - if (barpos==0){ - shutdownSound(); - close_graphics(); - exit(1); - } - else return 6; - -} - - -int showhiscore(struct tb1_state *game_state,int showchart) -{ - - FILE *hilist; - char tempstr[10]; - int i; - char names[10][25]; - int scores[10]; - - hilist=fopen("hiscore.tb1","r+"); - if (hilist==NULL) { - printf("Error! can't open high score file!\n"); - return 0; - } - - for (i=0;i<10;i++) fscanf(hilist,"%s",names[i]); - for (i=0;i<10;i++) fscanf(hilist,"%i",&scores[i]); - fclose(hilist); - if (!showchart) return scores[0]; - if (showchart) { - vmwDrawBox(45,40,240,120,7,game_state->virtual_1); - coolbox(45,40,285,160,1,game_state->virtual_1); - for(i=0;i<10;i++) - vmwTextXY(names[i],51,46+(i*10),9,7,1,game_state->tb1_font,game_state->virtual_1); - for(i=0;i<10;i++){ - sprintf(tempstr,"%i",scores[i]); - vmwTextXY(tempstr,181,46+(i*10),9,7,1,game_state->tb1_font,game_state->virtual_1); - } - vmwBlitMemToSDL(game_state->sdl_screen,game_state->virtual_1); - while(vmwGetInput()==0) usleep(100); - } - return 0; -} - -void write_hs_list(int score,char *hiname) -{ -#if 0 - int i,place; - FILE *hilist; - char names[10][25]; - int scores[10]; - - hilist=fopen("hiscore.tb1","r+"); - for (i=0;i<10;i++) fscanf(hilist,"%s",names[i]); - for (i=0;i<10;i++) fscanf(hilist,"%i",&scores[i]); - fclose(hilist); - - place=0; - for(i=0;i<9;i++) - if (score>scores[i]) place++; - place=10-place; - for(i=9;i>place;i--) - scores[i]=scores[i-1]; - for(i=9;i>place;i--) - strcpy(names[i-1],names[i]); - scores[place]=score; - strcpy(hiname,names[place]); - if (!read_only_mode) { - hilist=fopen("hiscore.tb1","w"); - for(i=0;i<9;i++) fprintf(hilist,"%s\n",names[i]); - for(i=0;i<9;i++) fprintf(hilist,"%i\n",scores[i]); - fclose(hilist); - } -#endif -} - - - -void help(struct tb1_state *game_state) -{ - unsigned char *vis; - vmw_font *tb1_font; - - vis=game_state->virtual_1; - tb1_font=game_state->tb1_font; - - coolbox(0,0,319,199,1,vis); - vmwTextXY("HELP",144,10,4,0,0,tb1_font,vis); - vmwTextXY("--------------------------------------",10,20, - 12,0,0,tb1_font,vis); - vmwTextXY("IN THE GAME:",10,30,4,0,0,tb1_font,vis); - vmwTextXY(" ARROWS MANUEVER",10,40, - 4,0,0,tb1_font,vis); - vmwTextXY(" SPACE BAR FIRES MISSILES",10,50, - 4,0,0,tb1_font,vis); - vmwTextXY(" F2 SAVES GAME",10,60, - 4,0,0,tb1_font,vis); - vmwTextXY(" P=PAUSE S=TOGGLE SOUND ESC=QUIT",10,70, - 4,0,0,tb1_font,vis); - vmwTextXY("--------------------------------------",10,80, - 12,0,0,tb1_font,vis); - vmwTextXY("MISSION: SHOOT THE INANIMATE OBJECTS",10,90, - 4,0,0,tb1_font,vis); - vmwTextXY(" WHY? WATCH THE STORY!",10,100, - 4,0,0,tb1_font,vis); - vmwTextXY("--------------------------------------",10,110, - 12,0,0,tb1_font,vis); - vmwTextXY("THE SPACE BAR SPEEDS UP MOVIE SCENES",10,120, - 4,0,0,tb1_font,vis); - vmwTextXY("ESC QUITS THEM",10,130, - 4,0,0,tb1_font,vis); - vmwTextXY("--------------------------------------",10,140, - 12,0,0,tb1_font,vis); - vmwTextXY(" SEE \"README\" FOR MORE HELP/INFO",10,150, - 4,0,0,tb1_font,vis); - vmwTextXY("--------------------------------------",10,160, - 12,0,0,tb1_font,vis); - vmwTextXY("PRESS ANY KEY TO CONTINUE",64,185, - 4,0,0,tb1_font,vis); - vmwBlitMemToSDL(game_state->sdl_screen,vis); - while(!vmwGetInput()) usleep(30); -} - - -void makehole(int y,unsigned char *target) -{ - - vmwDrawBox(249,y,64,9,0,target); - vmwDrawHLine(249,y,65,24,target); - vmwDrawVLine(249,y,9,24,target); - vmwDrawHLine(249,y+10,64,18,target); - vmwDrawVLine(314,y+1,9,18,target); - -} - -void setupsidebar(struct tb1_state *game_state) -{ - - int i,hiscore; - char it[50]; - - unsigned char *vaddr2; - vmw_font *tb1_font; - - tb1_font=game_state->tb1_font; - vaddr2=game_state->virtual_2; - - vmwDrawBox(240,0,80,199,19,game_state->virtual_2); - - vmwDrawVLine(240,0,199,18,game_state->virtual_2); - vmwDrawHLine(240,0,79,18,game_state->virtual_2); - - vmwDrawVLine(319,0,199,24,game_state->virtual_2); - vmwDrawHLine(241,199,78,24,game_state->virtual_2); - - printf("1\n"); fflush(stdout); - - vmwTextXY("SCORE",241,1,127,0,0,tb1_font,vaddr2); - vmwTextXY("SCORE",242,2,143,0,0,tb1_font,vaddr2); - makehole(10,vaddr2); - sprintf(it,"%d",game_state->score); - vmwTextXY(it,250+(8*(8-strlen(it))),11,12,0,1,tb1_font,vaddr2); - - printf("2\n"); fflush(stdout); - - - hiscore=showhiscore(game_state,0); - printf("show high done\n"); fflush(stdout); - - vmwTextXY("HI-SCORE",241,21,127,0,0,tb1_font,vaddr2); - vmwTextXY("HI-SCORE",242,22,143,0,0,tb1_font,vaddr2); - sprintf(it,"%d",hiscore); - makehole(30,vaddr2); - vmwTextXY(it,250+(8*(8-strlen(it))),31,12,0,1,tb1_font,vaddr2); - - printf("3\n"); fflush(stdout); - - - vmwTextXY("LEVEL",241,41,127,0,0,tb1_font,vaddr2); - vmwTextXY("LEVEL",242,42,143,0,0,tb1_font,vaddr2); - makehole(50,vaddr2); - vmwTextXY("SHIELDS",241,61,127,0,0,tb1_font,vaddr2); - vmwTextXY("SHIELDS",242,62,143,0,0,tb1_font,vaddr2); - makehole(70,vaddr2); - for(i=0;i<(4*game_state->shields);i++) { - vmwDrawVLine(250+i,71,8,(47-(i/4)),vaddr2); - } - vmwTextXY("WEAPONS",241,81,127,0,0,tb1_font,vaddr2); - vmwTextXY("WEAPONS",242,82,143,0,0,tb1_font,vaddr2); - makehole(90,vaddr2); - - printf("4\n"); fflush(stdout); - - - vmwDrawBox(249,111,65,78,0,vaddr2); - - vmwDrawVLine(249,111,78,24,vaddr2); - vmwDrawHLine(249,111,66,24,vaddr2); - vmwDrawVLine(315,111,78,18,vaddr2); - vmwDrawHLine(249,189,66,18,vaddr2); - - printf("5\n"); fflush(stdout); - - - vmwTextXY(" TB1 ",250,114,2,0,0,tb1_font,vaddr2); - vmwTextXY(" TB1 ",251,115,10,0,0,tb1_font,vaddr2); - vmwTextXY("F1-HELP ",250,124,2,0,0,tb1_font,vaddr2); - vmwTextXY("F1-HELP ",251,125,10,0,0,tb1_font,vaddr2); - vmwTextXY("F2-SAVES",250,134,2,0,0,tb1_font,vaddr2); - vmwTextXY("F2-SAVES",251,135,10,0,0,tb1_font,vaddr2); - vmwTextXY("ESC-QUIT",250,144,2,0,0,tb1_font,vaddr2); - vmwTextXY("ESC-QUIT",251,145,10,0,0,tb1_font,vaddr2); - vmwTextXY("P-PAUSES",250,154,2,0,0,tb1_font,vaddr2); - vmwTextXY("P-PAUSES",251,155,10,0,0,tb1_font,vaddr2); - vmwTextXY("S-SOUND ",250,164,2,0,0,tb1_font,vaddr2); - vmwTextXY("S-SOUND ",251,165,10,0,0,tb1_font,vaddr2); - -} - - - - -void savegame(int level,int begin_score,int begin_shields) -{ - -#if 0 - char ch; - struct stat buf; - char tempst[300],save_game_name[320],tempst2[5]; - FILE *fff; - int dot_tb1_exists=0; - - int i,j; - - coolbox(0,0,319,199,1,vis); - vmwTextXY("SAVE GAME",110,10,9],0],0,tb1_font,vis); - if (read_only_mode) { - vmwTextXY("SORRY! CANNOT SAVE GAME",40,40,4],0],0,tb1_font,vis); - vmwTextXY("WHEN IN READ ONLY MODE",50,50,4],0],0,tb1_font,vis); - } - else { - sprintf(tempst,"%s/.tb1",getenv("HOME")); - stat(tempst,&buf); - if (!S_ISDIR(buf.st_mode)) { - vmwTextXY("DIRECTORY:",20,20,4],0],0,tb1_font,vis); - if (strlen(tempst)>18) - vmwTextXY("$HOME/.tb1",120,20,4],0],0,tb1_font,vis); - else - vmwTextXY(tempst,120,20,4],0],0,tb1_font,vis); - vmwTextXY("WHERE TB1 STORES SAVED GAMES",20,30,4],0],0,tb1_font,vis); - vmwTextXY("DOES NOT EXIST. DO YOU WANT",20,40,4],0],0,tb1_font,vis); - vmwTextXY("TO CREATE THIS DIRECTORY?",20,50,4],0],0,tb1_font,vis); - vmwTextXY(" PLEASE ANSWER [Y or N]",20,60,4],0],0,tb1_font,vis); - vmwTextXY("NOTE IF YOU ANSWER \"N\" YOU",20,80,12],0],0,tb1_font,vis); - vmwTextXY("WILL NOT BE ABLE TO SAVE",20,90,12],0],0,tb1_font,vis); - vmwTextXY("GAMES",20,100,12],0],0,tb1_font,vis); - ch='M'; - clear_keyboard_buffer(); - while( (ch!='Y') && (ch!='y') && (ch!='N') && (ch!='n')) { - while((ch=get_input())==0) usleep(30); - } - if (toupper(ch)=='Y') - if (!mkdir(tempst,744)) dot_tb1_exists=1; - else { - coolbox(0,0,319,199,1,vis); - vmwTextXY("WARNING! COULD NOT CREATE",30,30,4],0],0,tb1_font,vis); - vmwTextXY("DIRECTORY! ABANDONING SAVE!",20,40,4],0],0,tb1_font,vis); - } - - } - else dot_tb1_exists=1; - } - if (dot_tb1_exists) { - coolbox(0,0,319,199,1,vis); - vmwTextXY("SAVE GAME",110,20,9],0],0,tb1_font,vis); - vmwTextXY("NOTE: THIS ONLY SAVES THE GAME",10,40,4],0],0,tb1_font,vis); - vmwTextXY("AT THE BEGINNING OF THE LEVEL!",10,50,4],0],0,tb1_font,vis); - vmwTextXY("ALREADY EXISTING GAMES",10,70,4],0],0,tb1_font,vis); - j=0; - for(i=0;i<10;i++) { - sprintf(save_game_name,"%s/sg%i.tb1",tempst,i); - if ((fff=fopen(save_game_name,"r"))!=NULL) { - sprintf(tempst2,"%i",i); - vmwTextXY(tempst2,50+j*20,80,12],0],0,tb1_font,vis); - fclose(fff); - j++; - } - } - if (j==0) vmwTextXY("NONE",140,90,12],0],0,tb1_font,vis); - vmwTextXY("PRESS NUMBER OF GAME TO SAVE",20,110,4],0],0,tb1_font,vis); - vmwTextXY("(0-9) [ESC CANCELS]",60,120,4],0],0,tb1_font,vis); - ch='M'; - clear_keyboard_buffer(); - while( ((ch<'0') || (ch>='9')) && (ch!=TB_ESC)) { - while((ch=get_input())==0) usleep(30); - } - if (ch==TB_ESC) { - coolbox(0,0,320,200,1,vis); - vmwTextXY("SAVE CANCELED",90,95,12],4],0,tb1_font,vis); - } - else { - sprintf(save_game_name,"%s/sg%c.tb1",tempst,ch); - if ((fff=fopen(save_game_name,"w"))!=NULL) { - fprintf(fff,"%i\n%i\n%i\n",level,begin_score,begin_shields); - fclose(fff); - coolbox(0,0,320,200,1,vis); - sprintf(tempst,"GAME %c SAVED",ch); - vmwTextXY(tempst,90,95,12],0],0,tb1_font,vis); - } - else { - coolbox(0,0,320,200,1,vis); - vmwTextXY("ERROR SAVING FILE!",70,90,12],0],0,tb1_font,vis); - vmwTextXY("GAME NOT SAVED!",80,100,12],0],0,tb1_font,vis); - } - } - } - vmwTextXY("PRESS ANY KEY...",80,180,4],0],0,tb1_font,vis); - while( (ch=get_input())==0) usleep(30); -#endif -} - -void shadowrite(char *st,int x5,int y5,int forecol,int backcol, - vmw_font *tb1_font,unsigned char *target) -{ - vmwTextXY(st,x5+1,y5+1,backcol,0,0,tb1_font,target); - vmwTextXY(st,x5,y5,forecol,0,0,tb1_font,target); -} - -void options(struct tb1_state *game_state) -{ - - int opbarpos,argh=0,ch=0; - vmw_font *tb1_font; - - tb1_font=game_state->tb1_font; - - vmwClearScreen(game_state->virtual_1,8); - coolbox(0,0,319,199,0,game_state->virtual_1); - vmwTextXY("ESC QUITS",120,175,32,0,1,tb1_font,game_state->virtual_1); - opbarpos=0; - while(ch!=TB_ESCAPE) { - if (game_state->sound_enabled) { - if (opbarpos==0) vmwTextXY("SOUND ON ",30,30,32, - 7,1,tb1_font,game_state->virtual_1); - else vmwTextXY("SOUND ON ",30,30,32, - 0,1,tb1_font,game_state->virtual_1); - } - else { - if (opbarpos==0) vmwTextXY("NO SOUND ",30,30,32, - 7,1,tb1_font,game_state->virtual_1); - else vmwTextXY("NO SOUND ",30,30,32, - 0,1,tb1_font,game_state->virtual_1); - } - if (opbarpos==1) vmwTextXY("VIEW HIGH SCORES",30,40,32, - 7,1,tb1_font,game_state->virtual_1); - else vmwTextXY("VIEW HIGH SCORES",30,40,32, - 0,1,tb1_font,game_state->virtual_1); - - vmwBlitMemToSDL(game_state->sdl_screen,game_state->virtual_1); - - while(!(ch=vmwGetInput()) ) usleep(30); - - if ((ch==TB_RIGHT) || (ch==TB_DOWN)) opbarpos++; - if ((ch==TB_LEFT) || (ch==TB_UP)) opbarpos--; - if ((ch=='M')||(ch=='m')) opbarpos=0; - if ((ch=='V')||(ch=='v')) opbarpos=1; - if ((ch==TB_ENTER) && (opbarpos==0)) game_state->sound_enabled=!game_state->sound_enabled; - if ((ch==TB_ENTER) && (opbarpos==1)){ - ch=TB_ESCAPE; - argh=4; - } - if (opbarpos==2) opbarpos=0; - if (opbarpos==-1) opbarpos=1; - } - if (argh==4) showhiscore(game_state,1); -} - -void loadgame() -{ -#if 0 - char tempst[300],tempst2[5],file_name[320]; - int i,j; - FILE *fff; - int game_exist[10]={0,0,0,0,0, 0,0,0,0,0}; - char ch; - int level,score,shields; - - coolbox(0,0,320,200,1,vis); - vmwTextXY("LOAD GAME",110,10,9],0],0,tb1_font,vis); - - sprintf(tempst,"%s/.tb1",getenv("HOME")); - - j=0; - for(i=0;i<10;i++) { - sprintf(file_name,"%s/sg%i.tb1",tempst,i); - if ((fff=fopen(file_name,"r"))!=NULL) { - sprintf(tempst2,"%i",i); - vmwTextXY(tempst2,50+j*20,50,12],0],0,tb1_font,vis); - fclose(fff); - game_exist[i]=1; - j++; - } - } - if (j==0) { - vmwTextXY("NO SAVED GAMES FOUND",60,50,12],0],0,tb1_font,vis); - vmwTextXY("PRESS ANY KEY...",80,180,4],0],0,tb1_font,vis); - while( (ch=get_input())==0) usleep(30); - } - else { - vmwTextXY("LOAD WHICH GAME?",80,30,4],0],0,tb1_font,vis); - vmwTextXY("THE FOLLOWING EXIST:",40,40,4],0],0,tb1_font,vis); - vmwTextXY("PRESS A NUMBER. (ESC CANCELS)",20,60,4],0],0,tb1_font,vis); - ch='M'; - clear_keyboard_buffer(); - IchLiebeMree: - while( ((ch<'0') || (ch>'9')) && (ch!=TB_ESC)) { - while((ch=get_input())==0) usleep(30); - } - if (!(game_exist[ch-48])) goto IchLiebeMree; - if(ch==TB_ESC) { - coolbox(0,0,320,200,1,vis); - vmwTextXY("LOAD CANCELED",90,95,12],0],0,tb1_font,vis); - vmwTextXY("PRESS ANY KEY...",80,180,4],0],0,tb1_font,vis); - while( (ch=get_input())==0) usleep(30); - } - else { - sprintf(file_name,"%s/sg%c.tb1",tempst,ch); - if (( fff=fopen(file_name,"r"))!=NULL) { - fscanf(fff,"%d",&level); - fscanf(fff,"%d",&score); - fscanf(fff,"%d",&shields); - playthegame(level,score,shields); - } - } - } -#endif -} - -void story(struct tb1_state *game_state) -{ - int error; - int xtemp,ytemp; - int thrustcol; - float thrust; - char tempch; - int alienchar; - int cycles; - - vmw_font *tb1_font; - - tb1_font=game_state->tb1_font; - -/* -procedure doflames; -begin - - if flames=true then begin - putshape(bigflame1off,vaddr,27,17,213,100); - putshapeover(sflame2off,vaddr,4,4,105,90); - putshapeover(sflame1off,vaddr,4,4,151,71); - putshapeover(sflame2off,vaddr,4,4,218,72); - end - else - begin - putshape(bigflame2off,vaddr,27,17,213,100); - putshapeover(sflame1off,vaddr,4,4,105,90); - putshapeover(sflame2off,vaddr,4,4,151,71); - putshapeover(sflame1off,vaddr,4,4,218,72); - outtextxy(chr(alienchar),10,10,12,0,vaddr,true); - inc(alienchar); - if alienchar>44 then alienchar:=34; - end; - flipd320(vaddr,vga); - vdelay(5); - flames:=not(flames); -end; - -procedure puttruck(xp,yp,frame:integer;where:word); -var xtemp,into,ytemp:integer; - col:byte; -begin - for into:=0 to 7 do begin - if(into+yp>=172) then - if frame=0 then putshapeline(truck1off,where,6,8,xp,yp,into) - else putshapeline(truck2off,where,6,8,xp,yp,into); - end; -end; -*/ - - vmwLoadPicPacked(0,0,game_state->virtual_2,1,1, - tb1_data_file("tbsobj.tb1",game_state->path_to_data)); - /* - for ytemp:=0 to 18 do - for xtemp:=0 to 26 do begin - ShapeTable1^[((ytemp*27)+xtemp)+bigflame1off]:=getpixel(xtemp,ytemp+2,vaddr); - ShapeTable1^[((ytemp*27)+xtemp)+bigflame2off]:=getpixel(xtemp,ytemp+21,vaddr); - end; - for ytemp:=0 to 18 do - for xtemp:=0 to 15 do begin - ShapeTable1^[((ytemp*16)+xtemp)+explo1off]:=getpixel(127+xtemp,ytemp+100,vaddr); - ShapeTable1^[((ytemp*16)+xtemp)+explo2off]:=getpixel(148+xtemp,ytemp+100,vaddr); - end; - for ytemp:=0 to 6 do - for xtemp:=0 to 15 do - ShapeTable1^[((ytemp*16)+xtemp)+rent1off]:=getpixel(168+xtemp,ytemp+100,vaddr); - - for ytemp:=0 to 4 do - for xtemp:=0 to 3 do begin - ShapeTable1^[((ytemp*4)+xtemp)+sflame1off]:=getpixel(xtemp,ytemp+43,vaddr); - ShapeTable1^[((ytemp*4)+xtemp)+sflame2off]:=getpixel(xtemp,ytemp+47,vaddr); - end; - - for ytemp:=0 to 18 do - for xtemp:=0 to 15 do - ShapeTable1^[((ytemp*16)+xtemp)+bargeoff]:=getpixel(xtemp+65,ytemp+100,vaddr); - - for ytemp:=0 to 8 do - for xtemp:=0 to 5 do begin - ShapeTable1^[((ytemp*6)+xtemp)+truck1off]:=getpixel(xtemp+85,ytemp+100,vaddr); - ShapeTable1^[((ytemp*6)+xtemp)+truck2off]:=getpixel(xtemp+95,ytemp+100,vaddr); - end; -*/ - - /******FIRST MESSAGE********/ - vmwClearScreen(game_state->virtual_1,0); - vmwTextXY("THE STORY SO FAR...",20,20,4,0,0,tb1_font,game_state->virtual_1); - vmwBlitMemToSDL(game_state->sdl_screen,game_state->virtual_1); - pauseawhile(7); - - vmwClearScreen(game_state->virtual_1,0); - - vmwLoadPicPacked(0,0,game_state->virtual_2,1,1, - tb1_data_file("tbcobj.tb1",game_state->path_to_data)); - - vmwArbitraryCrossBlit(game_state->virtual_2,129,56,49,132, - game_state->virtual_1,10,10); - vmwTextXY("YOU ARE TOM BOMBEM, A STRANGE",80,10,1,0,0,tb1_font,game_state->virtual_1); - vmwTextXY(" BUT EFFICIENT MEMBER OF",80,20,1,0,0,tb1_font,game_state->virtual_1); - vmwTextXY(" THE LUNAR SPACE FORCE.",80,30,1,0,0,tb1_font,game_state->virtual_1); - vmwTextXY("YOU NEVER SAY MUCH AND YOU ARE",80,50,4,0,0,tb1_font,game_state->virtual_1); - vmwTextXY(" RARELY SEEN OUTSIDE OF",80,60,4,0,0,tb1_font,game_state->virtual_1); - vmwTextXY(" YOUR BLUE SPACESUIT.",80,70,4,0,0,tb1_font,game_state->virtual_1); - vmwTextXY("YOU OFTEN GET YOURSELF IN ",80,90,2,0,0,tb1_font,game_state->virtual_1); - vmwTextXY(" TROUBLE BY SCRATCHING",80,100,2,0,0,tb1_font,game_state->virtual_1); - vmwTextXY(" YOUR HEAD AT INAPPROPRIATE",80,110,2,0,0,tb1_font,game_state->virtual_1); - vmwTextXY(" TIMES.",80,120,2,0,0,tb1_font,game_state->virtual_1); - vmwTextXY("PRESS ANY KEY....",96,185,15,0,0,tb1_font,game_state->virtual_1); - vmwBlitMemToSDL(game_state->sdl_screen,game_state->virtual_1); - pauseawhile(15); - - vmwClearScreen(game_state->virtual_1,0); - - vmwArbitraryCrossBlit(game_state->virtual_2,129,56,49,132, - game_state->virtual_1,260,10); - vmwArbitraryCrossBlit(game_state->virtual_2,99,104,29,81, - game_state->virtual_1,287,13); - - vmwTextXY("IT IS THE YEAR 2028.",10,10,1,0,0,tb1_font,game_state->virtual_1); - vmwTextXY("YOU HAVE BEEN SUMMONED BY",10,30,3,0,0,tb1_font,game_state->virtual_1); - vmwTextXY(" LUNAR DICTATOR-IN-CHIEF",10,40,3,0,0,tb1_font,game_state->virtual_1); - vmwTextXY(" VINCENT WEAVER ABOUT A",10,50,3,0,0,tb1_font,game_state->virtual_1); - vmwTextXY(" TOP SECRET THREAT TO ",10,60,3,0,0,tb1_font,game_state->virtual_1); - vmwTextXY(" INTERPLANETARY SECURITY.",10,70,3,0,0,tb1_font,game_state->virtual_1); - vmwTextXY("YOU ATTEND THE BRIEFING WITH",10,90,5,0,0,tb1_font,game_state->virtual_1); - vmwTextXY(" YOUR USUAL CONFUSED",10,100,5,0,0,tb1_font,game_state->virtual_1); - vmwTextXY(" QUIETNESS. YOU STILL DO",10,110,5,0,0,tb1_font,game_state->virtual_1); - vmwTextXY(" NOT UNDERSTAND YOUR OWN",10,120,5,0,0,tb1_font,game_state->virtual_1); - vmwTextXY(" SUCCESSFULNESS.",10,130,5,0,0,tb1_font,game_state->virtual_1); - vmwTextXY("PRESS ANY KEY....",96,185,15,0,0,tb1_font,game_state->virtual_1); - vmwBlitMemToSDL(game_state->sdl_screen,game_state->virtual_1); - pauseawhile(12); - - vmwLoadPicPacked(0,0,game_state->virtual_1,1,1, - tb1_data_file("tbchief.tb1",game_state->path_to_data)); - - /* Save the area where the error will go */ - vmwArbitraryCrossBlit(game_state->virtual_1,115,55,91,59, - game_state->virtual_2,115,255); - vmwBlitMemToSDL(game_state->sdl_screen,game_state->virtual_1); - pauseawhile(6); - - vmwTextXY("Ahhh.... Mr. Bombem.... ",1,1,15,0,0,tb1_font,game_state->virtual_1); - vmwBlitMemToSDL(game_state->sdl_screen,game_state->virtual_1); - if (game_state->sound_enabled) playGameFX(0); - pauseawhile(2); - - if (game_state->sound_enabled) playGameFX(2); - /* Show fake error message */ - vmwArbitraryCrossBlit(game_state->virtual_2,188,14,91,59, - game_state->virtual_1,115,55); - - vmwBlitMemToSDL(game_state->sdl_screen,game_state->virtual_1); - pauseawhile(6); - - /* Restore background where error was */ - vmwArbitraryCrossBlit(game_state->virtual_2,115,255,91,59, - game_state->virtual_1,115,55); - - vmwTextXY("I'll be brief. ",1,1,15,0,1,tb1_font,game_state->virtual_1); - vmwBlitMemToSDL(game_state->sdl_screen,game_state->virtual_1); - pauseawhile(5); - - vmwTextXY("Do you know how this base was founded?",1,1,15,0,1,tb1_font,game_state->virtual_1); - vmwBlitMemToSDL(game_state->sdl_screen,game_state->virtual_1); - pauseawhile(5); - - vmwTextXY("No? Well watch the screen. ",1,1,15,0,1,tb1_font,game_state->virtual_1); - vmwBlitMemToSDL(game_state->sdl_screen,game_state->virtual_1); - pauseawhile(5); - - /* Put picture on screen */ - vmwArbitraryCrossBlit(game_state->virtual_2,210,75,85,60, - game_state->virtual_1,210,136); - vmwBlitMemToSDL(game_state->sdl_screen,game_state->virtual_1); - pauseawhile(4); - - /******BARGE TAKING OFF***********/ - - vmwLoadPicPacked(0,0,game_state->virtual_2,1,1, - tb1_data_file("tbma1.tb1",game_state->path_to_data)); - - vmwSmallTextXY("MY WIFE AND I FOUNDED",212,3,14,0,0,tb1_font,game_state->virtual_2); - vmwSmallTextXY("THIS BASE IN 2008.",212,9,14,0,0,tb1_font,game_state->virtual_2); - vmwSmallTextXY("THE ONLY WAY TO ",212,16,13,0,0,tb1_font,game_state->virtual_2); - vmwSmallTextXY("FINANCE IT WAS TO",212,22,13,0,0,tb1_font,game_state->virtual_2); - vmwSmallTextXY("ENGAGE IN A DUBIOUS",212,28,13,0,0,tb1_font,game_state->virtual_2); - vmwSmallTextXY("BUSINESS.",212,34,13,0,0,tb1_font,game_state->virtual_2); - vmwSmallTextXY("WE LAUNCHED EARTH'S",212,41,12,0,0,tb1_font,game_state->virtual_2); - vmwSmallTextXY("TRASH INTO SPACE",212,47,12,0,0,tb1_font,game_state->virtual_2); - vmwSmallTextXY("FOR A PROFIT.",212,53,12,0,0,tb1_font,game_state->virtual_2); - vmwSmallTextXY("HERE IS FOOTAGE FROM",212,60,11,0,0,tb1_font,game_state->virtual_2); - vmwSmallTextXY("THE LAST LAUNCH EIGHT",212,66,11,0,0,tb1_font,game_state->virtual_2); - vmwSmallTextXY("YEARS AGO.",212,72,11,0,0,tb1_font,game_state->virtual_2); - - vmwFlipVirtual(game_state->virtual_1,game_state->virtual_2); - -/* putshape(bargeoff,vaddr,16,18,141,157);*/ - - /* vmwCrossBlit(plb_vis->write,plb_vaddr->read,plb_vis->stride,200);*/ - vmwBlitMemToSDL(game_state->sdl_screen,game_state->virtual_1); - pauseawhile(7); - -#if 0 -/* - - - for ytemp:=191 downto 164 do begin - if ytemp>=172 then blockmove(145,ytemp,152,ytemp+10,vaddr2,145,ytemp,vaddr) - else blockmove(145,172,152,182,vaddr2,145,172,vaddr); - puttruck(145,ytemp,ytemp mod 2,vaddr); - pauseawhile(7); - if keypressed then if readkey=#27 then exit; - flipd320(vaddr,vga); - end; - - pauseawhile(20); - flipd320(vaddr2,vaddr); - putshape(bargeoff,vaddr,16,18,141,157); - thrustcol:=0; - ytemp:=157; - thrust:=0; - while ytemp>-25 do begin - thrust:=thrust+0.05; - if thrustcol<63 then inc(thrustcol); - blockmove(141,ytemp,171,ytemp+30,vaddr2,141,ytemp,vaddr); - for i:=1 to 17 do - if ytemp+i>=0 then - putshapeline(bargeoff,vaddr,16,18,141,ytemp,i); - pauseawhile(5); - if keypressed then if readkey=#27 then exit; - pal(250,thrustcol,0,0); - flipd320(vaddr,vga); - ytemp:=ytemp-round(thrust); - end; -*/ - pauseawhile(5); - - - /****SECOND CHIEF*******/ - ggiSetGCForeground(vis,0]); - ggiDrawBox(vis,0,0,320,200); - GGILoadPicPacked(0,0,vaddr2,1,1, - tb1_data_file("tbcobj.tb1",(char *)tempst), - (ggi_color *)&eight_bit_pal, - (ggi_pixel *)&tb1_pal,color_depth); - GGILoadPicPacked(0,0,vis,1,1, - tb1_data_file("tbchief.tb1",(char *)tempst), - (ggi_color *)&eight_bit_pal, - (ggi_pixel *)&tb1_pal,color_depth); -/* vmwArbitraryCrossBlit(plb_vaddr2->read,7,104,90,21, - plb_vis->write,6,174,plb_vis->stride, - stride_factor); - */ - vmwTextXY("You might wonder why this is important.",1,1,15],0],1,tb1_font,virtual_1); - pauseawhile(6); - vmwTextXY("Last week we received a message. ",1,1,15],0],1,tb1_font,virtual_1); - pauseawhile(6); - vmwTextXY("It is of extra-terrestrial origin. ",1,1,15],0],1,tb1_font,virtual_1); - pauseawhile(6); - vmwTextXY("Watch the screen. ",1,1,15],0],1,tb1_font,virtual_1); - - /*vmwArbitraryCrossBlit(plb_vaddr2->read,210,136,85,59, - plb_vis->write,210,136,plb_vis->stride, - stride_factor);*/ - pauseawhile(4); - - /******ALIEN DELEGATION*****/ - GGILoadPicPacked(0,0,vaddr2,1,1, - tb1_data_file("tbcrash.tb1",(char *)tempst), - (ggi_color *)&eight_bit_pal, - (ggi_pixel *)&tb1_pal,color_depth); - - /*alienchar:=34; - flipd320(vaddr2,vaddr); - flipd320(vaddr,vga); - putshape(bargeoff,vaddr,16,18,97,180); - unfade; - xtemp:=97; - ytemp:=181; - flames:=true; - while ytemp>118 do begin - blockmove(xtemp,ytemp,xtemp+20,ytemp+20,vaddr2,xtemp,ytemp,vaddr); - putshape(bargeoff,vaddr,16,18,xtemp,ytemp); - doflames; - dec(ytemp); - inc(xtemp); - pauseawhile(1); - if keypressed then if readkey=#27 then exit; - end; - blockmove(xtemp,ytemp,xtemp+30,ytemp+30,vaddr2,xtemp,ytemp,vaddr); - pal(0,63,63,63); - putshape(explo1off,vga,16,18,160,118); - pauseawhile(5); - if keypressed then if readkey=#27 then exit; - pal(0,0,0,0); - if sbeffects then startsound(sound[3],0,false); - for xtemp:=0 to 10 do begin - putshapeover(explo2off,vaddr,16,18,160,118); - doflames; - putshapeover(explo1off,vaddr,16,18,160,118); - doflames; - end; - blockmove(159,114,189,144,vaddr2,159,114,vaddr); - putshapeover(rent1off,vaddr,16,6,160,115); - flipd320(vaddr,vga); - cycles:=0; - repeat - doflames; - inc(cycles); - until ((keypressed) or (cycles>60)); - if keypressed then if readkey=#27 then exit; - */ - - /****ALIEN MESSAGE*****/ - GGILoadPicPacked(0,0,vis,1,1, - tb1_data_file("tbgorg.tb1",(char *)tempst), - (ggi_color *)&eight_bit_pal, - (ggi_pixel *)&tb1_pal,color_depth); - vmwTextXY("GREETINGS EARTHLINGS.",0,162,12],0],0,tb1_font,virtual_1); - vmwTextXY("I AM GORGONZOLA THE REPULSIVE.",0,171,12],0],0,tb1_font,virtual_1); - vmwTextXY("YOU HAVE MADE A BIG MISTAKE.",0,180,12],0],0,tb1_font,virtual_1); - pauseawhile(7); - vmwTextXY("YOUR SHIP FULL OF REFUSE HAS",0,162,12],0],1,tb1_font,virtual_1); - vmwTextXY("DAMAGED OUR OFFICIAL PEACE ",0,171,12],0],1,tb1_font,virtual_1); - vmwTextXY("ENVOY. IT WAS ON ITS WAY TO ",0,180,12],0],1,tb1_font,virtual_1); - vmwTextXY("YOUR PLANET. ",0,189,12],0],1,tb1_font,virtual_1); - pauseawhile(7); - vmwTextXY("IN AN IRONIC FORM OF RETALLIATION",0,162,12],0],1,tb1_font,virtual_1); - vmwTextXY("WE HAVE MADE YOUR TRASH EVIL AND",0,171,12],0],1,tb1_font,virtual_1); - vmwTextXY("TURNED IT AGAINST YOU. ",0,180,12],0],1,tb1_font,virtual_1); - vmwTextXY(" DIE EARTH SCUM! ",0,189,12],0],1,tb1_font,virtual_1); - pauseawhile(7); - - /****** THIRD CHIEF *******/ - GGILoadPicPacked(0,0,vaddr2,1,1, - tb1_data_file("tbcobj.tb1",(char *)tempst), - (ggi_color *)&eight_bit_pal, - (ggi_pixel *)&tb1_pal,color_depth); - GGILoadPicPacked(0,0,virtual_1,1,1, - tb1_data_file("tbchief.tb1",(char *)tempst), - (ggi_color *)&eight_bit_pal, - (ggi_pixel *)&tb1_pal,color_depth); - vmwArbitraryCrossBlit(plb_vaddr2->read,7,127,90,21, - plb_vis->write,6,174,plb_vis->stride, - stride_factor); - - vmwTextXY("Tom, our radar detects approaching ",1,1,15],0],1,tb1_font,virtual_1); - pauseawhile(6); - vmwTextXY("objects. They are inside the ",1,1,15],0],1,tb1_font,virtual_1); - pauseawhile(6); - vmwTextXY("orbit of Jupiter. ",1,1,15],0],1,tb1_font,virtual_1); - pauseawhile(6); - vmwTextXY("You are our only hope! ",1,1,15],0],1,tb1_font,virtual_1); - pauseawhile(6); - vmwTextXY("Will you fly our only spaceship ",1,1,15],0],1,tb1_font,virtual_1); - pauseawhile(6); - vmwTextXY("and save the human race? ",1,1,15],0],1,tb1_font,virtual_1); - pauseawhile(6); - vmwArbitraryCrossBlit(plb_vaddr2->read,5,16,39,82, - plb_vis->write,146,59,plb_vis->stride, - stride_factor); - pauseawhile(1); - vmwArbitraryCrossBlit(plb_vaddr2->read,46,16,39,82, - plb_vis->write,146,59,plb_vis->stride, - stride_factor); - pauseawhile(1); - vmwArbitraryCrossBlit(plb_vaddr2->read,87,16,39,82, - plb_vis->write,146,59,plb_vis->stride, - stride_factor); - vmwTextXY("Scratch. Scratch. ",1,1,9],0],1,tb1_font,virtual_1); - pauseawhile(5); - vmwTextXY("I knew you'd do it. Good Luck! ",1,1,15],0],1,tb1_font,virtual_1); - pauseawhile(6); - vmwTextXY(" ",1,1,9],0],1,tb1_font,virtual_1); - pauseawhile(10); -#endif -} - -void credits(struct tb1_state *game_state) -{ - - int i,keypressed=0; - - vmw_font *tb1_font; - - tb1_font=game_state->tb1_font; - - vmwDrawBox(0,0,320,400,0,game_state->virtual_2); - - vmwTextXY(" TOM BOMBEM",0,210,4,0,1,tb1_font,game_state->virtual_2); - vmwTextXY(" INVASION OF THE INANIMATE OBJECTS",0,220,4,0,1,tb1_font,game_state->virtual_2); - vmwTextXY(" PROGRAMMING",0,240,9,0,1,tb1_font,game_state->virtual_2); - vmwTextXY(" VINCENT M WEAVER",0,260,9,0,1,tb1_font,game_state->virtual_2); - vmwTextXY(" GRAPHICS",0,290,10,0,1,tb1_font,game_state->virtual_2); - vmwTextXY(" VINCENT M WEAVER",0,310,10,0,1,tb1_font,game_state->virtual_2); - vmwTextXY(" SOUND EFFECTS",0,340,11,0,1,tb1_font,game_state->virtual_2); - vmwTextXY(" VINCENT M WEAVER",0,360,11,0,1,tb1_font,game_state->virtual_2); - vmwTextXY(" GRAPHICS INSPIRATION",0,390,12,0,1,tb1_font,game_state->virtual_2); - - for(i=0;i<200;i++){ - vmwArbitraryCrossBlit(game_state->virtual_2,0,i,320,200, - game_state->virtual_1,0,0); - vmwBlitMemToSDL(game_state->sdl_screen,game_state->virtual_1); - usleep(30000); - if (vmwGetInput()) { - keypressed=1; break; - } - } - - vmwArbitraryCrossBlit(game_state->virtual_2,0,200,320,200, - game_state->virtual_1,0,0); - vmwArbitraryCrossBlit(game_state->virtual_1,0,0,320,200, - game_state->virtual_2,0,0); - vmwDrawBox(0,200,320,200,0,game_state->virtual_2); - - vmwTextXY(" JEFF WARWICK",0,210,12,0,1,tb1_font,game_state->virtual_2); - vmwTextXY(" GENERAL HELP",0,240,13,0,1,tb1_font,game_state->virtual_2); - vmwTextXY(" JOHN CLEMENS",0,260,13,0,1,tb1_font,game_state->virtual_2); - vmwTextXY(" JASON GRIMM",0,280,13,0,1,tb1_font,game_state->virtual_2); - vmwTextXY(" PCGPE AUTHORS, esp",0,310,14,0,1,tb1_font,game_state->virtual_2); - vmwTextXY(" GRANT SMITH",0,330,14,0,1,tb1_font,game_state->virtual_2); - vmwTextXY(" DOS SOUND BLASTER CODE",0,360,15,0,1,tb1_font,game_state->virtual_2); - vmwTextXY(" ETHAN BRODSKY",0,380,15,0,1,tb1_font,game_state->virtual_2); - - if (!keypressed) for(i=0;i<200;i++){ - vmwArbitraryCrossBlit(game_state->virtual_2,0,i,320,200, - game_state->virtual_1,0,0); - vmwBlitMemToSDL(game_state->sdl_screen,game_state->virtual_1); - usleep(30000); - if (vmwGetInput()) { - keypressed=1; break; - } - } - - vmwArbitraryCrossBlit(game_state->virtual_2,0,200,320,200, - game_state->virtual_2,0,0); - - vmwDrawBox(0,200,320,200,0,game_state->virtual_2); - - vmwTextXY(" GLTRON SOUND CODE",0,210,12,0,1,tb1_font,game_state->virtual_2); - vmwTextXY(" ANDREAS UMBACH",0,230,12,0,1,tb1_font,game_state->virtual_2); - vmwTextXY(" THANKS TO ALL THE DEVELOPERS",0,260,13,0,1,tb1_font,game_state->virtual_2); - vmwTextXY(" OF LINUX, ESPECIALLY",0,280,13,0,1,tb1_font,game_state->virtual_2); - vmwTextXY(" LINUS TORVALDS",0,300,13,0,1,tb1_font,game_state->virtual_2); - vmwTextXY(" ALSO SPECIAL THANKS TO",0,330,14,0,1,tb1_font,game_state->virtual_2); - vmwTextXY(" THE SDL DEVELOPMENT TEAM",0,350,14,0,1,tb1_font,game_state->virtual_2); - - if (!keypressed) for(i=0;i<200;i++){ - vmwArbitraryCrossBlit(game_state->virtual_2,0,i,320,200, - game_state->virtual_1,0,0); - vmwBlitMemToSDL(game_state->sdl_screen,game_state->virtual_1); - usleep(30000); - if (vmwGetInput()) { - keypressed=1; break; - } - } - - vmwArbitraryCrossBlit(game_state->virtual_2,0,200,320,200, - game_state->virtual_2,0,0); - - vmwDrawBox(0,200,320,200,0,game_state->virtual_2); - - vmwTextXY(" INSPIRATION",0,210,9,0,1,tb1_font,game_state->virtual_2); - vmwTextXY(" DOUGLAS ADAMS",0,230,9,0,1,tb1_font,game_state->virtual_2); - vmwTextXY(" CLIFF STOLL",0,250,9,0,1,tb1_font,game_state->virtual_2); - vmwTextXY(" ARTHUR C CLARKE",0,270,9,0,1,tb1_font,game_state->virtual_2); - vmwTextXY(" ISAAC ASIMOV",0,290,9,0,1,tb1_font,game_state->virtual_2); - vmwTextXY(" GORDON KORMAN",0,310,9,0,1,tb1_font,game_state->virtual_2); - vmwTextXY(" THANKS TO ALL THE AGENTS",0,340,10,0,1,tb1_font,game_state->virtual_2); - vmwTextXY(" B,D,JL,L,N,P,S,W,PM,E,G,TK",0,360,10,0,1,tb1_font,game_state->virtual_2); - vmwTextXY(" AND ESPECIALLY MP",0,380,10,0,1,tb1_font,game_state->virtual_2); - - if (!keypressed) for(i=0;i<200;i++){ - vmwArbitraryCrossBlit(game_state->virtual_2,0,i,320,200, - game_state->virtual_1,0,0); - vmwBlitMemToSDL(game_state->sdl_screen,game_state->virtual_1); - usleep(30000); - if (vmwGetInput()) { - keypressed=1; break; - } - } - vmwArbitraryCrossBlit(game_state->virtual_2,0,200,320,200, - game_state->virtual_2,0,0); - - vmwLoadPicPacked(0,200,game_state->virtual_2,1,1, - tb1_data_file("tbomb1.tb1",game_state->path_to_data)); - - if (keypressed) { - vmwDrawBox(0,0,320,200,0,game_state->virtual_2); - } - - for(i=0;i<200;i++){ - vmwArbitraryCrossBlit(game_state->virtual_2,0,i,320,200, - game_state->virtual_1,0,0); - vmwBlitMemToSDL(game_state->sdl_screen,game_state->virtual_1); - usleep(30000); - if (vmwGetInput()) { - break; - } - } - vmwArbitraryCrossBlit(game_state->virtual_2,0,200,320,200, - game_state->virtual_1,0,0); - - vmwBlitMemToSDL(game_state->sdl_screen,game_state->virtual_1); - -} - -void about(struct tb1_state *game_state) -{ - int pagenum=1,firstime=0,oldpagenum=0,numpages=4,ch=0; - char tempst[300]; - - vmw_font *tb1_font; - unsigned char *target1,*target2; - SDL_Surface *sdl_screen; - - tb1_font=game_state->tb1_font; - target1=game_state->virtual_1; - target2=game_state->virtual_2; - sdl_screen=game_state->sdl_screen; - - vmwClearScreen(target1,0); - - vmwLoadPicPacked(0,0,target2,1,1, - tb1_data_file("register.tb1",game_state->path_to_data)); - - while ((ch!=TB_ESCAPE)&&(ch!='q')){ - while(( (ch=vmwGetInput())==0) && (firstime)); - if(!firstime) firstime=1; - if ((ch==' ') || (ch==TB_ENTER)) pagenum++; - if ((ch==TB_RIGHT) || (ch==TB_DOWN) || (ch==TB_PGDN)) pagenum++; - if ((ch==TB_LEFT) || (ch==TB_UP) || (ch==TB_PGUP)) pagenum--; - if (pagenum>4) pagenum=1; - if (pagenum<1) pagenum=4; - if (oldpagenum!=pagenum){ - if (pagenum==1) { - vmwFlipVirtual(target1,target2); - coolbox(0,0,319,199,0,target1); - shadowrite(" INFORMATION",10,10,9,1,tb1_font,target1); - shadowrite("I STARTED THIS GAME IN LATE",70,30,9,1,tb1_font,target1); - shadowrite(" 1994, WHEN I WAS 16.",70,40,9,1,tb1_font,target1); - shadowrite("I WROTE THIS GAME ENTIRELY IN",75,50,9,1,tb1_font,target1); - shadowrite(" MY FREE TIME.",74,60,9,1,tb1_font,target1); - shadowrite(" ^(AUTHOR 1N 1995)",10,70,10,2,tb1_font,target1); - shadowrite("ORIGINALLY THIS GAME WAS CODED IN",10,90,12,4,tb1_font,target1); - shadowrite(" TURBO PASCAL AND IN-LINE ASSEMBLY",10,100,12,4,tb1_font,target1); - shadowrite(" OPTIMIZED TO RUN ON A 386. NOW I",10,110,12,4,tb1_font,target1); - shadowrite(" HAVE PORTED IT TO LINUX AND SDL.",10,120,12,4,tb1_font,target1); - shadowrite(" IN THAT SPIRIT I HAVE NOW GPL'ED",10,130,12,4,tb1_font,target1); - shadowrite(" THE CODE.",10,140,12,4,tb1_font,target1); - } else coolbox(0,0,319,199,1,target1); - - if (pagenum==2){ - shadowrite("MY NAME IS VINCE WEAVER",10,10,10,2,tb1_font,target1); - shadowrite(" VISIT MY TALKER",10,20,10,2,tb1_font,target1); - shadowrite(" DERANGED.STUDENT.UMD.EDU 7000",10,30,10,2,tb1_font,target1); - shadowrite(" UP WHENEVER SCHOOL IS IN SESSION",10,40,10,2,tb1_font,target1); - shadowrite("UNTIL DECEMBER OF 2000 I WILL BE",10,60,13,5,tb1_font,target1); - shadowrite(" ATTENDING COLLEGE, AT THE UNIVERSITY",10,70,13,5,tb1_font,target1); - shadowrite(" OF MARYLAND, COLLEGE PARK.",10,80,13,5,tb1_font,target1); - shadowrite("GET THE NEWEST VERSION OF TB1 AT",10,100,11,3,tb1_font,target1); - shadowrite(" THE OFFICIAL TB1 WEB SITE:",10,110,11,3,tb1_font,target1); - shadowrite(" http://www.glue.umd.edu/~weave/tb1/",10,120,11,3,tb1_font,target1); - shadowrite("I CAN BE CONTACTED VIA E-MAIL AT:",10,140,12,4,tb1_font,target1); - shadowrite(" WEAVE@ENG.UMD.EDU",10,150,9,1,tb1_font,target1); - shadowrite("FEEL FREE TO SEND COMMENTS.",10,160,12,4,tb1_font,target1); - } - - if (pagenum==3){ - shadowrite("OTHER VMW SOFTWARE PRODUCTIONS:",10,10,15,7,tb1_font,target1); - shadowrite(" PAINTPRO:",10,30,13,5,tb1_font,target1); - shadowrite(" LOAD AND SAVE GRAPHICS PICTURES",10,40,13,5,tb1_font,target1); - shadowrite(" LINUX_LOGO",10,50,11,3,tb1_font,target1); - shadowrite(" A USERLAND ANSI LOGIN DISPLAY",10,60,11,3,tb1_font,target1); - shadowrite(" SPACEWAR III:",10,70,9,1,tb1_font,target1); - shadowrite(" NEVER COMPLETED GAME",10,80,9,1,tb1_font,target1); - shadowrite(" AITAS: (ADVENTURES IN TIME AND SPACE)",10,90,12,4,tb1_font,target1); - shadowrite(" A GAME I'VE BEEN WANTING TO WRITE",10,100,12,4,tb1_font,target1); - shadowrite(" FOR 5 YEARS. [INCOMPLETE]",10,110,12,4,tb1_font,target1); - shadowrite(" FONT_PRINT",10,120,9,1,tb1_font,target1); - shadowrite(" PRINT VGA FONTS IN DOS AND LINUX",10,130,9,1,tb1_font,target1); - shadowrite(" SEABATTLE:",10,140,13,5,tb1_font,target1); - shadowrite(" A BATTLESHIP CLONE CODED IN C",10,150,13,5,tb1_font,target1); - } - - if (pagenum==4){ - shadowrite("DISCLAIMER:",10,10,12,14,tb1_font,target1); - shadowrite("* MY PROGRAMS SHOULD NOT DAMAGE YOUR *",8,30,12,4,tb1_font,target1); - shadowrite("* COMPUTER IN ANY WAY. PLEASE DON'T *",8,40,12,4,tb1_font,target1); - shadowrite("* USE MY SOFTWARE IN CRITICAL *",8,50,12,4,tb1_font,target1); - shadowrite("* APPLICATIONS LIKE LIFE-SUPPORT *",8,60,12,4,tb1_font,target1); - shadowrite("* EQUIPMENT, DEFLECTOR SHIELDS, OR *",8,70,12,4,tb1_font,target1); - shadowrite("* AUTOMOBILE ENGINES. *",8,80,12,4,tb1_font,target1); - shadowrite("* LINUX FOREVER! THE OS FOR EVERYONE *",8,90,12,4,tb1_font,target1); - shadowrite("% WARRANTY ESPECIALLY VOID IF USED %",8,110,11,3,tb1_font,target1); - shadowrite("% ON ANY MICROSOFT(tm) OS (YUCK) %",8,120,11,3,tb1_font,target1); - } - sprintf(tempst,"Page %d of %d: ESC QUITS",pagenum,numpages); - shadowrite(tempst,50,180,15,7,tb1_font,target1); - vmwBlitMemToSDL(sdl_screen,target1); - oldpagenum=pagenum; - } - } -} - - -void playthegame(struct tb1_state *game_state) -{ - - if (game_state->level==0) { - littleopener(game_state); - game_state->shields=12; - game_state->score=0; - game_state->level++; - } - - if (game_state->level==1) { - game_state->level=2; - leveltwoengine(game_state); -// levelone(game_state); -// if(level==2) littleopener2(); - } - if (game_state->level==2) { -// leveltwoengine(&level,&shields,&score); - } - if (game_state->level==3) { - /*littleopener3(); - levelthree();*/ - } - if (game_state->level==4) { -// leveltwoengine(&level,&shields,&score); - } - coolbox(70,85,170,110,1,game_state->virtual_1); - vmwTextXY("GAME OVER",84,95,4,7,0,game_state->tb1_font,game_state->virtual_1); - game_state->level=0; - vmwBlitMemToSDL(game_state->sdl_screen,game_state->virtual_1); - clear_keyboard_buffer(); - pauseawhile(20); - - - - /* hiscore:=showhiscore(false,false); - if score>lowscore then begin - coolbox(10,75,310,125,true,vga); - outtextxy('NEW HIGH SCORE!',90,80,12,7,vga,false); - outtextxy('ENTER YOUR NAME (10 Chars)',30,90,0,7,vga,false); - hiname:=grinput(110,110,10,11,7); - hiscore:=showhiscore(false,true); - end; - hiscore:=showhiscore(true,false); - fade; - cls(0,vga); -*/ - -} - diff --git a/tblib.h b/tblib.h index dc6e33d..37bfd94 100644 --- a/tblib.h +++ b/tblib.h @@ -1,22 +1,4 @@ -int change_shields(struct tb1_state *game_state); -int changescore(struct tb1_state *game_state); -int collision(int x1,int y1,int xsize,int ysize,int x2,int y2,int x2size,int y2size); -char *tb1_data_file(char *name,char *path); -int get_input(); -void coolbox(int x1,int y1,int x2,int y2,int fill,unsigned char *target); -int close_graphics(); -int quit(struct tb1_state *game_state); -void ReadConfigFile(int CDROMmode); -int showhiscore(struct tb1_state *game_state,int showchart); -void write_hs_list(int score,char *hiname); -void help(); -void setupsidebar(struct tb1_state *game_state); -void shadowrite(char *st,int x,int y,int forecol,int backcol,vmw_font *tb1_font,unsigned char *target); void pauseawhile(int howlong); -void options(); -void savegame(int level,int begin_score,int begin_shields); -void loadgame(); -void story(); -void credits(); -void about(struct tb1_state *game_state); -void playthegame(struct tb1_state *game_state); +int collision(int x1,int y1,int xsize,int ysize, + int x2,int y2,int x2size,int y2size); +char *tb1_data_file(char *name,char *path); diff --git a/tbomb1.tb1 b/tbomb1.tb1 deleted file mode 100644 index a459058efdf1fa582e4bff9a369bbaedfa0844ce..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 28650 zcmeHQU2J4$dH&ANoS8G;+4cTqce9&hLepp<+r*+FxJe2VSb`%q#n4qTt)))MhHU<) zWdT=O!c1@`o{+5u5{L;VSTsnc3Sg-gvf5SURz`Kj7R?1xEs?5IX)k<{3tw>Ii*wQE zec$=M`OcXcdv-S{L0zy8XU}}!`#$gU{(fh?%lLf{{K={DPk-{y?z(;CfLa??@}C8@ zpwz+wUGP7r==K!-C&GVEMG;;2e{lQOTW`Jj=9|rCb7f^^X=w>7XJ=<$eDTF|=gyVO z<sdGw|l{&4|giGNuSd(v(cD~g?p!oE85N5W3yBscquF9KlaHpjMRj&b zmFCoXw0k_J>(6B7V5c_At;M)`$E%|+_POX}Q3^~92zoFf`8 zFb$Pxvcxpp5-C3pXaGhx*P~0z(fVA}JQuA^Mi+|FQa)Nx(X6^uQ5VmurIMN(SJNj{ z`A#)aP(_>0XfiSewA7_Fb#X~8&8fL*HT{GtPpF9^)^EHSwVKiTYV@lM(Z$7R_4Vk& zT(sPX7Aw)~%%8gV*x2ad;>h9A;|B`)T@s+(*VRH{^<-i7Y+-e-u)129TP>VjEu5sM zBZbw;!s<+6b*ZqhS~#~_7+*bJSe+=WP8U`eY3&=Uh01E-6xJf1Gv%zi`SDCSbT@}G z zD|<6z&!$`HxC(=lBOn*mVqS$Mu853$-qhNs7`fp-Xgmacqh8SMz1$gLjujPv(u$RDTcG;@ULn=os-)y%5n`Mc;2jg2rqYZnnkO|@GR@n1i zB)BV{TPBT$SZhm1sr9e}nD^%J5sQ*qA-WP9_cMT9maZ#+N@e--K^_|zp2)uj>>6WI ziYd-@?j+*5lTaM_*BE;jGKO-E%GSPKQR%QHP;ncq%GtXlgsz~Zm>L_P{aMw!%`+is zccN5$K_W7{<#Y_`DTE(NbLrlDmFA!`0xghBHy3HfA~b#9>hSdYa85Do zk?uEaZ*72TM{qU*#KJ%{{8hh03E+NL2cB$0fPk4u`O;Yuh8^YOPGcQg-;X?25m^56elp%k+ z>l;6mq9H_?aNwB*Q%@r85}B_X<~6 zY)&UyF8_RIyQyP><-5e_E=N&&*ER6MKsyooQ`d1*SAtw)9lohx4HH^UhLhTd24YeXsw5&u}eayR9Y(&+wDHvsk-Ub zj^OP#=gBBCy|wE#c)wjXRIITvf^Bz>WeOy_&~B?0@1+{^Q0eb&gY4J3d4K+6;fv7E(0hCh8TUvZDU z_w)Uy^%HCT|K4qVhyE4SNT*wlYT!+XUzvTzx{>GIS6ZnWu<;p7&NJyv7P5(tJe=Sv zvtK1qd>YmFkS`B|=QrdAi?K$Yw|AvmU$Mk?gs6s(W3QF~?YK8e>F{oSls2l(4S(8} z&|d`s#+K(d!soYy3ew2@r1>MT;Tf6c#;BIPY;`{?Tu8=xEf#+a!A9E!Oa<=Kn<-x4 z8WrY7bXh|BDq{V_1tt+E=85Ps9D-!Imk2S-Y~gS& z#U9H6a!8Y_&-XqU&&L!tmXzBlBDyZB+ZQls5S+r#U(u_DC_ z+&%*3Q?l`GwIa((hx#aeyR2}tt&E1fqaor)@+mu)_GVXv;UK%>Wm_phn{7$(h+nWQ zt(PGr+8Q}>vT^J1QTvHV$RZs&Vj*9mbQ@0v!1la`XW?|RoA~Gr{e+gGs`qjk1)F>% z(W@;b30?Pqgy$*ic~(awZ0UTY^~%FG64bXY^RXpsN!!Eswidb1CCUQJF(J{L1h&i0 zwH-*%G*VOuBqKq*X{V>1ijzr z1Mv)%tjyTR6DH^|Ku&pFmndcs3>-YN-A=vVEjIF22DP(>`aYFkSA5rx4Z|4oK!jM% zwH+-KQ4%FYT}^DT(!Ldvkz8(Z=t+gC4?SYr1co+^tnSZ4PA}_Jm~9wf13PVkE$SqW zFey#BXL*$EvW)i*QXa3I0aho46uIE)qHWh*e&XImYaz8e@2mZmS zFw-(YwYlm?g47MYvJ(tucd7@J0|rc;f1Yd zSR>}`XG~XO*V7TKkNF6&9g3vctBX>n8c1AmjJ3yUUL4Dd?B;GO{B|ax>rl{50t$$I z;Ozu6*ATXy-!BbF0%QK|&C9TnUOb!Z@ zMuINRSIfB z6y6RJe%Q`UWFP-ALsx4`=ZE%tC&-KiUjJTstXEVd%;xe9qW4zOYa`ri8?(h(>?pw+?eyJc_Qm$E@o!B2V)EaFnx~wPNYiQ`w?T@~*(BD4LF1^>j7YUtjE?^h$lJ6blntY<=*n7Lbn}96`7(az~ zmcDBSp6mFEdpyBcPPpQW9%$dgdLOW!>^EZ){YCPd@0Gt!p1JQsnZN#s3V!A&N2yQc zN=I`|+}^@Bu2P?I#_{|Y`j1aLMf@?SX7*Pn4pnDwaPXC!I^yJU{UTov=1RwMO>8{m z4CCSZdHegSnZ4D~gVi(Gal5>8A{eZt>_kQ58KfrU(fAZOThMjRujI&%ac5tya{ zGgZwTu5KtmQp(l94&_SwrZYyY&tktM0%3k!pbHY5rd!>(NvS&^S*bsE%D9Hr%z^6E z(dyRsmGZP?Fu&iD?6Kr84eye`wmHO;=Ngzdt5x7^o66C;@Bu5<4CFctyr|@!p;@kD9 z@6;C{>b1D2JzCTqaG6r~?02(9ud3z7tIZednNkgbv6aXdOHpHYuC$9|`!-ml z6vZCvO0lkhb^Xx*x==BYM2Q@SB9AL)kZT}=z|URmBZLGbLmk2oM!}qWIV!d(;}3vX zB%ocF>RTwJDVBdA*T|7@I0e3d32piA`QeY1k!_A4HxqQ7MfINPgiL10=X#41MDEPk9Y)GUp457ypw(=|4QZe&WToU%t52 zJU{xY^ArDde)iYr*Z%wbmYN=WP^l5Ov7Z_)A>S{6mHK6$Ehl{H|-PTs*zHM z1;0{%hZrDo3fz&oj8~`7QXQw^RTt3Zk8)o|ZG^5{6Do2I%A@n^|Kk@O)^eNMz^@R) z%tIR0vkBoOS-Hq`?i#*R@|}wB%=^xY@3h)lym7}b?qPuiw}HQl3VIJ}zz4WWJjFTd z^VK6!BWU72Rl<^2ojQyk;OABj$yD3Xe7XPrJ_&E`gDosMQ0jn&`kct5>4iEtq%-*aVl`DYtf}g zwYDQDY*5VM3-n)R%-43o>34&@XU`m0>J?O~>crvd!ZAbz^i~h=!(d5Kly_+qB6L++BVIHd~VQbONDEx_}JIS&Sr}4P!UnFpQGYBPQ5Qv^Bs2OS}%Mf;YY(WQC;yx zJ0}i>B3nn3aM&UMN~J_Q^meIshKgA5gHX9phcZPS|L`}%5w~6#w(YgKrEIE@Pfg@V z{3EBdQpBDQrAXW9_4_NC51`JlXHyQ9(+|PkbkUs|TT<%pnO;B4`>gb(u-K+rmk9B! zFF^&pTy}ipRwi8X!U*N}7=1^p(*{(G$8hidXQu9WGxfkx#7!ya1% zqaF@QUQqFac@L^<>-c$!wL8dy`V@sCn}3><1)s9*^KJ8WE|B+8`anAZ0JERpL~k8s z7{WYiDg6Er#t9U82H*ogkavTkTN^zcjQh1SkKl)pH2h%Ett~trtoQ)Kc)YM2$1@6F zJWf8E_lSo+co3F;(VG`yqK4+Tk(_k$5XDEfdAl>DIVw_(f! zi7zmMrd!*1I%v7J()#k8_5uiTIQ-;_V1Qnqd+0EVr&4=|N_aACx#k|H3=EH5B?euQ z1VBpS5HBmF7chW)y5X_ydn}K9lE>E*=ybrw7?50l1&`DYe=Znt$veFWq46V|vkLY~Ueh`Q=B0;Hk|%7Bo0cBx@F3fB`D< z5pFigUj#;@VxkyZlcSe%ma%Pe`J&c&i(hg5d52LEB+FSp!YMKs7K(aD3q`C(!u&W) z&XYmQ2{!#MBq=K3?b0E|oLULc-nbwCzMT*ah4REp3XuzQM2o?L`8-v zLMq*)QAzNa8RI?D?6}~Z<3{5IKuBB}Y?SF#ZAxx!>I{A;kf{7pzDsN)ilp*T^_zGU zPVDkvqW-sQpoVvYU-6hUz$4Pqc(>f1{oV+b&vS?iCkDe*39WRaUV!?8@TLgY^`~71 zD;Py6miQf4N+)b6iL*h@(rf^UOh?ij?a72t>59~Lne+%l4xB~)YWY-_8y+)bMm4@c z@SrHIpiy$x$0$O^ftCYY30;$McsDLwWr`jcQ|hPv5n^HykUqK?{Y-owKh!}QKB8T^ z*ww+iF7824hkxo8v-CF^_6?zG_jit{R5(KK@nooz62U&jnBj1Dlj!n-hC@E>bXXeg zggu@%Q`UfCs->BDQK0tQ4n>`;WYAK<)j@9Y-yIB<9cfNb0V*$;cO(bJt!OI@3*Q3pONu9OxBe$<6}0QrRX2)h@g!Xctl> zqhx_p^%3Un5qV1><1qm1nXP?HGoG!F4l+IR3<e^Y!@*(%=(Nx z3*@`d9Cd0~#6Io}!?fGu$dS=<(&;d4VMZu=LD>x|u8f`BD4*te8<=U*qxwcyoO(0p?EXQj-5@KE;vCUCf|BV{y`0KAto8WTIcf}n8CbCl-ku-xT(^fIEcc7~f5P0JX2 zFlpcn%X52~{muitFd2txhP32FM0`R>i>~}OLs+G9&BL=z>9RggwO=N1E4gg6wan*g zqYu|+9;+=siSM2+8*PhDUJMw-dK|8TcCVh_fSkUXRI0>X50S|oCrRwfJa(evIKc=G zWnNH{YKac$Q88b`4|R`4hyk2Oo~M%j&+k5X7|ZQ4^&lsE zPRQKR`-t0G=4l#o@;F|3+!;~iF-v$rxDN-jMDA@R|ksG{nFPp_QX0dp8HR5Ubw;@tde|ybi)kFu#2Wr8hq~3p;pE!oz@v=nYmJ)B&D3Wg73qfSJkl z$;G^{1D~c+VF(wf0YmkyO7(A-i<1gIxE=0(o5VPq{5A;@JI`^eWA$=z&WtJeU015r z{_d9HGZl{0YgO}B4R2QKQzf27aZp8+;#ChiEVV5@+Q^I6o(ScbY#)|;GMN^4gHPa8 z>gQL6kPnH3kYCD4`ePz>+2bx%{@yeW2of=AIzCF%zYpSTc{iIN6Pdz?M{ZRdoB^IR zcz&j18czb`^vfzu?hEUxSMEH>XX-=z!s=68{D-d+xtvPc$EAwLvld``R0Q-py}`<< z!AyrWYnnR2n5X-PLA!)@2P!H&_biX!Ou9S<@UYszp~-qfi%8(IzfJMfe7X{xGh;G~ z4)NQG)A)WCQ!9P{PH#;e>*^|efjIA|hQ6vhuiTJfdPl_FLAT%vhYELLo@dNg8$DV; zeQO$4ApNZxh5ySHq}U@)3o-2R)ph8bh@0#m)M15huIKR&lIW}Yz#w5mBmZZC5klBcu%8z+{_Q0Ip|VuFrgzziWFa z;hnZcNh|2zXhlxpTFKl22`;7B2j2~*eVwL#8Tc`%03^2+9GBr>l$lHv>7Xj_r21oB99UH{tGMH?>Lr9kDTlhWLZ}YFM0>+Qj3jCXTVOeDt c!H=6=q(J3Ay3bAFp_eL8@7erts{HW(0m>i3=Kufz diff --git a/vmw_sprite.h b/vmw_sprite.h deleted file mode 100644 index fd82e8f..0000000 --- a/vmw_sprite.h +++ /dev/null @@ -1,10 +0,0 @@ -struct vmwSprite { - int xsize; - int ysize; - unsigned char *spritedata; -}; - -struct vmwSprite *vmwGetSprite(int x, int y, int xsize, int ysize, unsigned char *source); -void vmwPutSprite(struct vmwSprite *sprite,int x,int y,int shield_color, - unsigned char *screen); -