Version 2.9.4

This commit is contained in:
Vince Weaver 2000-09-17 01:47:00 -04:00
parent 44047ca3bb
commit 185e1ecf2c
39 changed files with 1431 additions and 351 deletions

View File

@ -6,6 +6,8 @@
+ Debugged the problems from the svmwgraph change.. suprisingly it
was very few.
+ Started adding features that depended on the svmwgraph rewrite
+ Added load/save support! Tracked down a nasty out-of-bounds
error with coolbox. Those type of errors are so hard to find in C...
12 September 2000
+ Added support for level2

View File

@ -5,8 +5,11 @@ LIBS= -lSDL -lSDL_mixer -L/usr/X11R6/lib -lX11 -lpthread
all: tb1
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: tb1.o ./svmwgraph/libsvmwgraph.a about.o credits.o graphic_tools.o help.o hiscore.o level_1.o level_2.o loadsave.o options.o playgame.o quit.o sidebar.o sound.o story.o tblib.o
gcc -o tb1 tb1.o about.o credits.o graphic_tools.o help.o hiscore.o level_1.o level_2.o loadsave.o options.o playgame.o quit.o sidebar.o sound.o story.o tblib.o ./svmwgraph/libsvmwgraph.a $(LIBS)
./svmwgraph/libsvmwgraph.a:
cd svmwgraph && make
tb1.o: tb1.c
gcc -c tb1.c $(INCLUDE)
@ -17,6 +20,9 @@ about.o: about.c
credits.o: credits.c
gcc -c credits.c $(INCLUDE)
graphic_tools.o: graphic_tools.c
gcc -c graphic_tools.c $(INCLUDE)
help.o: help.c
gcc -c help.c $(INCLUDE)
@ -29,11 +35,8 @@ level_1.o: level_1.c
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)
loadsave.o: loadsave.c
gcc -c loadsave.c $(INCLUDE)
options.o: options.c
gcc -c options.c $(INCLUDE)
@ -44,9 +47,6 @@ playgame.o: playgame.c
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)
@ -61,3 +61,4 @@ tblib.o: tblib.c
clean:
rm tb1 *.o *~
cd svmwgraph && make clean

35
TB1.FAQ Normal file
View File

@ -0,0 +1,35 @@
Some Frequently Asked Questions
Q1.) Why does it give me an SDL display error?
A1). Tom Bombem runs by default in a 320x200x16bpp display. It may
not work if you have an 8, 24, or 32bpp display. This can
be fixed, it just hasn't yet.
Q2.) Why is the picture 320x200 anyway?
A2). Tom Bombem is internally rendered at 320x200 and 256colors.
This is because the original game was for dos VGA Bios mode
0x13, which was MCGA 320x200 mode. Why did I use this mode?
Because it was a nice linear 64kB graphics display, and I had
sample code from the PCGPE.
Q3). What are paintpro graphics? Are these any relation to a commercial
graphics package known as PaintPro(TM)?
A3). No. A long time ago I made my own graphics program. I called it
(with much originality) "paintprogram.pas", but because of the wonders
of MS-DOS it was truncated to "paintpro.pas". I still referred to
it as paintprogram, but my friends Jeff and John [who used it to
make graphics for Basic and C respectively] referred to it as paintpro
and the name stuck.
I invented the format myself, originally as a text output and later
as a binary. I "invented" RLE [Run Length Encoding] before I knew
what it was. In the end, it is very [and quite accidentally]
similar to the PCX graphics format. All this because I couldn't
find source code for common file formats. Thank goodness for
the internet and the GPL.
See http://..... for more info.

14
TODO
View File

@ -1,8 +1,12 @@
Finish the game [or at least get it on-par with the dos version]
Requires:
Levels2-4
Highscore list
Save Games
Implement Shield Color
Scrolling Credits
Levels3-4
Finish Story
Other aspirations:
Free RAM instead of leaking it.
8bpp, 24bpp, 32bpp displays
Double and Quad sized displays
Re-implement fading in/out
Implement level editor

View File

@ -4,9 +4,9 @@
#include "svmwgraph/svmwgraph.h"
#include "tb1_state.h"
#include "tblib.h"
#include "menu_tools.h"
#include "graphic_tools.h"
void about(struct tb1_state *game_state)
void about(tb1_state *game_state)
{
int pagenum=1,firstime=0,oldpagenum=0,numpages=4,ch=0;
char tempst[300];

View File

@ -1 +1 @@
void about(struct tb1_state *game_state);
void about(tb1_state *game_state);

View File

@ -6,7 +6,7 @@
#include "tb1_state.h"
#include "tblib.h"
void credits(struct tb1_state *game_state)
void credits(tb1_state *game_state)
{
int i,keypressed=0;

View File

@ -1 +1 @@
void credits(struct tb1_state *game_state);
void credits(tb1_state *game_state);

20
data/hiscore.tb1 Normal file
View File

@ -0,0 +1,20 @@
Vince
Hairold
Marie
Chipper
Kevin
Leonard
Lizann
Pete
Vinnie
joebob
5000
4500
4000
3500
3000
2500
2000
1500
1200
1160

134
graphic_tools.c Normal file
View File

@ -0,0 +1,134 @@
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <unistd.h>
#include "svmwgraph/svmwgraph.h"
#include "tb1_state.h"
/* MAKE SURE YOU DO A COOLBOX TO 319,199, not 320,200!!! */
/* This will cause HARD TO DEBUG BUGS!!! */
/* I should add a check here I suppose */
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)+1,31-i,target);
vmwDrawVLine(x2-i,y1+i,(y2-y1-i-i)+1,31-i,target);
}
if (fill) {
for(i=y1+5;i<y2-4;i++) vmwDrawHLine(x1+5,i,(x2-x1-9),7,target);
}
}
void shadowrite(char *st,int x5,int y5,int forecol,int backcol,
vmwFont *tb1_font,vmwVisual *target)
{
vmwTextXY(st,x5+1,y5+1,backcol,0,0,tb1_font,target);
vmwTextXY(st,x5,y5,forecol,0,0,tb1_font,target);
}
char *check_for_tb1_directory(tb1_state *game_state,int try_to_create)
{
char ch;
struct stat buf;
char *dir_name;
vmwFont *tb1_font;
vmwVisual *vis;
dir_name=calloc(300,sizeof(char)); /* Hope their home directory path */
/* is not huge */
tb1_font=game_state->graph_state->default_font;
vis=game_state->virtual_3;
/* First see if ~/.tb1 exists, and if it doesn't see if */
/* They want it to be created */
coolbox(0,0,319,199,1,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(dir_name,"%s/.tb1",getenv("HOME"));
stat(dir_name,&buf);
if (S_ISDIR(buf.st_mode)) return dir_name; /* It Exists */
else { /* It doesn't exist */
if (!try_to_create) return NULL;
vmwTextXY("DIRECTORY:",20,20,4,0,0,tb1_font,vis);
if (strlen(dir_name)>18)
vmwTextXY("~/.tb1",120,20,4,0,0,tb1_font,vis);
else
vmwTextXY(dir_name,120,20,4,0,0,tb1_font,vis);
vmwTextXY("THE ABOVE DIRECTORY DOES NOT",20,30,4,0,0,tb1_font,vis);
vmwTextXY("EXIST. DO YOU WANT TO ",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);
vmwBlitMemToDisplay(game_state->graph_state,vis);
ch='M';
vmwClearKeyboardBuffer();
while( (ch!='Y') && (ch!='y') && (ch!='N') && (ch!='n') && (ch!=VMW_ESCAPE)) {
while((ch=vmwGetInput())==0) usleep(30);
}
if ((ch=='Y') || (ch=='y')) {
if (!mkdir(dir_name,S_IRUSR | S_IWUSR | S_IXUSR)) return dir_name; /* Now it exists */
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);
vmwBlitMemToDisplay(game_state->graph_state,vis);
vmwClearKeyboardBuffer();
while (!vmwGetInput()) usleep(30);
return NULL;
}
}
}
return NULL;
}
char *vmwGrInput(tb1_state *game_state,int x,int y,int howlong,int forecol,int backcol,
vmwFont *tb1_font,vmwVisual *vis) {
char *tempst;
int ch;
int num_chars=0;
tempst=calloc(howlong+3,sizeof(char));
ch=-1;
while (ch!=VMW_ENTER) {
while ((ch=vmwGetInput())==0) usleep(30);
if ((ch==VMW_BACKSPACE) && (num_chars>0)) {
vmwTextXY(" ",x,y,forecol,backcol,1,tb1_font,vis);
num_chars--;
tempst[num_chars]=0;
}
if (num_chars<10) {
if ((ch>31) && (ch<128)) {
tempst[num_chars]=(char)ch;
tempst[num_chars+1]=0;
num_chars++;
}
}
vmwTextXY(tempst,x,y,forecol,backcol,1,tb1_font,vis);
vmwBlitMemToDisplay(game_state->graph_state,vis);
}
tempst[num_chars+1]=0;
return tempst;
}

7
graphic_tools.h Normal file
View File

@ -0,0 +1,7 @@
void coolbox(int x1,int y1,int x2,int y2,int fill,vmwVisual *target);
void shadowrite(char *st,int x5,int y5,int forecol,int backcol,
vmwFont *tb1_font,vmwVisual *target);
char *check_for_tb1_directory(tb1_state *game_state,int try_to_create);
char *vmwGrInput(tb1_state *game_state,int x,int y,int howlong,int forecol,int backcol,
vmwFont *tb1_font,vmwVisual *vis);

6
help.c
View File

@ -2,14 +2,14 @@
#include <unistd.h>
#include "svmwgraph/svmwgraph.h"
#include "tb1_state.h"
#include "menu_tools.h"
#include "graphic_tools.h"
void help(struct tb1_state *game_state)
void help(tb1_state *game_state)
{
vmwVisual *vis;
vmwFont *tb1_font;
vis=game_state->virtual_1;
vis=game_state->virtual_3;
tb1_font=game_state->graph_state->default_font;
coolbox(0,0,319,199,1,vis);

2
help.h
View File

@ -1 +1 @@
void help(struct tb1_state *game_state);
void help(tb1_state *game_state);

View File

@ -2,12 +2,16 @@
#include "svmwgraph/svmwgraph.h"
#include "tb1_state.h"
#include "menu_tools.h"
#include "graphic_tools.h"
#include "tblib.h"
#include <unistd.h> /* For usleep */
#include <string.h> /* For strncpy */
int showhiscore(struct tb1_state *game_state,int showchart)
/* Yes these routines are simplistic, but they seemed amazingly */
/* clever when I came up with them 6 years ago. */
int showhiscore(tb1_state *game_state,int showchart,int return_highest)
{
FILE *hilist;
@ -16,7 +20,7 @@ int showhiscore(struct tb1_state *game_state,int showchart)
char names[10][25];
int scores[10];
hilist=fopen("hiscore.tb1","r+");
hilist=fopen(tb1_data_file("hiscore.tb1",game_state->path_to_data),"r");
if (hilist==NULL) {
printf("Error! can't open high score file!\n");
return 0;
@ -25,7 +29,10 @@ int showhiscore(struct tb1_state *game_state,int showchart)
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) {
if (return_highest) return scores[0];
else return scores[9];
}
if (showchart) {
vmwDrawBox(45,40,240,120,7,game_state->virtual_1);
coolbox(45,40,285,160,1,game_state->virtual_1);
@ -35,41 +42,67 @@ int showhiscore(struct tb1_state *game_state,int showchart)
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);
vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1);
while(vmwGetInput()==0) usleep(100);
}
return 0;
}
void write_hs_list(int score,char *hiname)
typedef struct {
char name[12];
int score;
} vmwHighScore;
void write_hs_list(tb1_state *game_state,int score,char *hiname,int wipe)
{
#if 0
int i,place;
int i,place,in_place;
FILE *hilist;
char names[10][25];
int scores[10];
vmwHighScore old_list[10];
vmwHighScore new_list[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]);
hilist=fopen(tb1_data_file("hiscore.tb1",game_state->path_to_data),"r");
for (i=0;i<10;i++) fscanf(hilist,"%s",old_list[i].name);
for (i=0;i<10;i++) fscanf(hilist,"%i",&old_list[i].score);
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);
i=0;
in_place=0;
while (i<10) {
if ((score>old_list[place].score) && (in_place==0)) {
strncpy(new_list[i].name,hiname,10);
new_list[i].score=score;
i++;
in_place=1;
}
if (i<10) {
strncpy(new_list[i].name,old_list[place].name,10);
new_list[i].score=old_list[place].score;
}
place++;
i++;
}
#endif
// if (!read_only_mode) {
if ((hilist=fopen(tb1_data_file("hiscore.tb1",
game_state->path_to_data),"w"))==NULL) {
printf("Error opening high score file!\n");
return;
}
if (wipe) {
fprintf(hilist,"Vince\nChipper\nMarie\nHairold\nKevin\n"
"Leonard\nLizann\nPete\nJim\nBrigid\n"
"5000\n4500\n4000\n3500\n3000\n"
"2500\n2000\n1500\n1000\n500\n");
}
else {
for(i=0;i<10;i++) fprintf(hilist,"%s\n",new_list[i].name);
for(i=0;i<10;i++) fprintf(hilist,"%i\n",new_list[i].score);
}
fclose(hilist);
// }
}

View File

@ -1,2 +1,2 @@
int showhiscore(struct tb1_state *game_state,int showchart);
void write_hs_list(int score,char *hiname);
int showhiscore(tb1_state *game_state,int showchart,int show_highest);
void write_hs_list(tb1_state *game_state,int score,char *hiname,int wipe);

View File

@ -17,7 +17,8 @@
#include "tblib.h"
#include "sidebar.h"
#include "help.h"
#include "menu_tools.h"
#include "loadsave.h"
#include "graphic_tools.h"
/* Define this to get a frames per second readout */
/* #define DEBUG_ON */
@ -73,7 +74,7 @@ int level_one_wave_behavior[]=
/* The little Sequence Before you hit the Boss */
void beforeboss(struct tb1_state *game_state)
void beforeboss(tb1_state *game_state)
{
vmwClearKeyboardBuffer();
@ -116,12 +117,12 @@ void beforeboss(struct tb1_state *game_state)
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);
setupsidebar(game_state,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)
void afterboss(tb1_state *game_state)
{
vmwFont *tb1_font;
@ -173,13 +174,14 @@ void afterboss(struct tb1_state *game_state)
9,0,1,tb1_font,game_state->virtual_1);
vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1);
pauseawhile(5);
game_state->level++;
}
/* Defines the behavior of the objects in level 1 */
int level_one_behavior(int reset, struct tb1_state *game_state)
int level_one_behavior(int reset, tb1_state *game_state)
{
int what,temp,whichone,need_to_pause=0;
static int wave=0;
@ -333,7 +335,7 @@ int level_one_behavior(int reset, struct tb1_state *game_state)
/* The Main Level One */
void levelone(struct tb1_state *game_state) {
void levelone(tb1_state *game_state) {
int ch=0;
int i,j,grapherror;
@ -345,7 +347,6 @@ void levelone(struct tb1_state *game_state) {
long oldsec,oldusec,time_spent;
int howmuchscroll=0;
int speed_factor=1,game_paused=0;
int beginscore,beginshield;
vmwVisual *virtual_1,*virtual_2;
vmwFont *tb1_font;
@ -356,8 +357,8 @@ void levelone(struct tb1_state *game_state) {
virtual_2=game_state->virtual_2;
/* Set this up for Save Game */
beginscore=game_state->score;
beginshield=game_state->shields;
game_state->begin_score=game_state->score;
game_state->begin_shields=game_state->shields;
/* Load Sprites */
grapherror=vmwLoadPicPacked(0,0,virtual_1,1,1,
@ -397,7 +398,7 @@ void levelone(struct tb1_state *game_state) {
/* Setup and draw the sidebar */
setupsidebar(game_state);
setupsidebar(game_state,virtual_2);
vmwFlipVirtual(virtual_1,virtual_2,320,200);
sprintf(tempst,"%d",game_state->level);
@ -562,7 +563,7 @@ void levelone(struct tb1_state *game_state) {
case 's': if (game_state->sound_enabled)
game_state->sound_enabled=!(game_state->sound_enabled); break;
case VMW_F2: game_paused=1;
// savegame(*level,beginscore,beginshield);
savegame(game_state);
break;
case ' ': for(j=0;j<2;j++)
if (!bullet[j].out) {
@ -631,7 +632,7 @@ void levelone(struct tb1_state *game_state) {
}
/* The little opener before Level 1 */
void littleopener(struct tb1_state *game_state)
void littleopener(tb1_state *game_state)
{
vmwSprite *ship1,*ship2;

View File

@ -15,7 +15,8 @@
#include "sidebar.h"
#include "help.h"
#include "menu_tools.h"
#include "loadsave.h"
#include "graphic_tools.h"
/* Define this to get a frames per second readout */
/* #define DEBUG_ON */
@ -53,13 +54,13 @@ struct obstruction {
int kind,lastshot;
};
void leveltwoengine(struct tb1_state *game_state)
void leveltwoengine(tb1_state *game_state)
{
int ch,i;
char tempst[BUFSIZ];
int k,game_paused=0,speed_factor=1;
int shipx=36;
int whatdelay=1,beginscore,beginshield;
int whatdelay=1;
FILE *f=NULL;
int levelover=0,j,backrow=0;
int background[201][13];
@ -89,8 +90,8 @@ void leveltwoengine(struct tb1_state *game_state)
virtual_2=game_state->virtual_2;
/* Set this up for Save Game */
beginscore=game_state->score;
beginshield=game_state->shields;
game_state->begin_score=game_state->score;
game_state->begin_shields=game_state->shields;
printf("Starting level 2\n"); fflush(stdout);
@ -157,7 +158,7 @@ void leveltwoengine(struct tb1_state *game_state)
pauseawhile(5);
/* Setup and draw the sidebar */
setupsidebar(game_state);
setupsidebar(game_state,virtual_2);
vmwFlipVirtual(virtual_1,virtual_2,320,200);
sprintf(tempst,"%d",game_state->level);
vmwDrawBox(251,52,63,7,0,virtual_2);
@ -364,8 +365,9 @@ void leveltwoengine(struct tb1_state *game_state)
case '-': whatdelay--; break;
case 'S':
case 's': game_state->sound_enabled=!(game_state->sound_enabled); break;
case VMW_F2: game_paused=1; /*savegame(*level,beginscore,beginshield);*/
break;
case VMW_F2: game_paused=1;
savegame(game_state);
break;
case ' ': for(j=0;j<3;j++)
if (!bullet[j].out) {
if (game_state->sound_enabled) playGameFX(SND_CC);

821
level_3.c Normal file
View File

@ -0,0 +1,821 @@
Obstruction = record
x,y:integer;
shooting,dead,exploding:boolean;
explodeprogress:byte;
howmanyhits:integer;
kind,lastshot:byte;
end;
EnemyInfo = record
x,y:integer;
kind:byte;
out,exploding,boundarycheck,dead:boolean;
explodprogress:byte;
minx,maxx,xspeed,yspeed:integer;
hitsneeded:integer;
end;
procedure loadlevel3shapes;
var x,y,i,j,shape:byte;
begin
clearshape;
grapherror:=loadpicsuperpacked(0,0,vaddr,false,true,'tblev3.tb1');
for j:=0 to 3 do
for i:=0 to 19 do
for x:=0 to 9 do
for y:=0 to 9 do
ShapeTable1^[shape3array[(j*20)+i]+((y*10)+x)]
:=getpixel(1+x+(i*11),1+y+(j*11),vaddr);
cls(0,vaddr);
end;
Procedure levelthree;
label newroom;
type{
EnemyInfo = record
x,y:integer;
kind:byte;
out,exploding,boundarycheck,dead:boolean;
explodprogress:byte;
minx,maxx,xspeed,yspeed:integer;
hitsneeded:integer;
end;}
pittype = record
px,py:integer;
end;
kctype = record
kcx,kcy:integer;
kcout:boolean;
end;
const framedir:array[0..1,0..3] of integer =((0,1,0,-1),(1,0,-1,0));
VAR loop1,loop2:integer;
ch,ch2:char;
pits:array[0..4] of pittype;
numpits:byte;
bullet1x,bullet1y,bullet2x,bullet2y,i:integer;
bullet1dir,bullet2dir,collide:byte;
bullet1out,bullet2out:boolean;
whichone,temp,temp2:integer;
tempst:string;
what:byte;
k:integer;
itemp,jtemp:byte;
whatdelay:byte;
tempilg:byte;
xx:integer;
ucollide,dcollide,lcollide,rcollide:word;
walking,feet:byte;
room:byte;
backrow,topblocky:integer;
levelover,odd,changeroom,havegun:boolean;
whichroomnext:array[0..3] of byte; {n,s,e,w}
keycards:array[0..3] of boolean;
keycard:kctype;
shieldup:array[0..11] of boolean;
shieldx,shieldy,laserx,lasery:integer;
laserup:array[0..11] of boolean;
computers:array[0..11] of boolean;
computerx,computery:integer;
computer_0hits:integer;
tempkc:byte;
procedure horizwalls(x,y,howfar:word);
var i:word;
begin
for i:=0 to howfar do
put10shape240(shape3array[3],vaddr2,x+(i*10),y);
end;
procedure verticalwalls(x,y,howfar:word);
var i:word;
begin
for i:=0 to howfar do
put10shape240(shape3array[2],vaddr2,x,y+(i*10));
end;
procedure dopits;
var i:word;
begin
for i:=0 to (numpits-1) do
with pits[i] do
put10shape240(shape3array[5],vaddr2,px,py);
end;
procedure clearroom;
var i,j:byte;
begin
for i:=0 to 23 do
for j:=0 to 19 do
put10shape240(shape3array[0],
vaddr2,i*10,j*10);
end;
procedure doroom(n,s,e,w:boolean);
var i:byte;
begin
for i:=0 to 2 do begin
put10shape240(shape3array[18],vaddr2,100+(i*10),0);
put10shape240(shape3array[18],vaddr2,100+(i*10),199);
put10shape240(shape3array[19],vaddr2,0,90+(i*10));
put10shape240(shape3array[19],vaddr2,239,90+(i*10));
end;
if n then begin
horizwalls(0,0,10);
horizwalls(130,0,10);
end
else horizwalls(0,0,23);
if s then begin
horizwalls(0,197,10);
horizwalls(130,197,10);
end
else horizwalls(0,197,23);
if e then begin
verticalwalls(237,0,8);
verticalwalls(237,110,8);
end
else for i:=0 to 20 do put10shape240(shape3array[2],vaddr2,237,i*10);
if w then begin
verticalwalls(0,0,8);
verticalwalls(0,110,8);
end
else for i:=0 to 20 do put10shape240(shape3array[2],vaddr2,0,i*10);
end;
BEGIN
{loadlevel3shapes;}
computer_0hits:=0;
whatdelay:=1;
havegun:=true;
for i:=0 to 3 do keycards[i]:=false;
for i:=0 to 11 do begin
shieldup[i]:=false;
laserup[i]:=false;
computers[i]:=false;
end;
shieldup[0]:=true;
laserup[0]:=true;
computers[0]:=true;
shipx:=115;
shipy:=180;
odd:=false;
shipxadd:=0;
room:=0;
shipyadd:=0;
shipframe:=1;
shipspeed:=5;
ch:=#1; ch2:=#1;
bullet1out:=false; bullet2out:=false;
bullet1x:=0; bullet1y:=0;
bullet2x:=0; bullet2y:=0;
flip(vaddr2,vaddr);
str(level,tempst);
fillblock(251,52,314,59,0,vaddr);
outtextxy(tempst,307,51,12,0,vaddr,false);
cls(0,vaddr2);
pal(250,0,0,63);
pal(251,63,0,0);
pal(254,shields*4,0,0);
howmuchscroll:=50;
cls(0,vga);
coolbox(70,85,240,120,true,vga);
outtextxy(' LEVEL THREE:',84,95,4,7,vga,false);
outtextxy(' THE ALIEN SHIP',84,105,4,7,vga,false);
clearkeyboardbuffer;
pauseawhile(300);
numpassive:=0;
levelover:=false;
newroom:
numpits:=0;
changeroom:=false;
if room=254 then room:=0;
clearroom;
if shipframe=1 then shipy:=188
else if shipframe=3 then shipy:=3
else if shipframe=2 then shipx:=3
else if shipframe=4 then shipx:=228;
keycard.kcout:=false;
if room=0 then begin
whichroomnext[0]:=1;
whichroomnext[1]:=255;
clearroom;
verticalwalls(30,0,16);
verticalwalls(207,0,16);
verticalwalls(57,30,16);
verticalwalls(180,30,16);
with pits[0] do begin
px:=95;
py:=80;
end;
with pits[1] do begin
px:=135;
py:=80;
end;
numpits:=2; { actual}
dopits;
for i:=0 to 10 do
for j:=0 to 2 do begin
put10shape240(shape3array[4],vaddr2,60+(j*10),80+(i*10));
put10shape240(shape3array[4],vaddr2,150+(j*10),80+(i*10));
end;
{walkway}
for i:=0 to 15 do for j:=0 to 1 do
put10shape240(shape3array[1],vaddr2,110+(j*10),40+(i*10));
put10shape240(shape3array[6],vaddr2,110,30);
put10shape240(shape3array[6],vaddr2,120,30);
computerx:=110;
computery:=30;
if shieldup[0] then begin
shieldx:=10;
shieldy:=10;
put10shape240(shape3array[8],vaddr2,10,10);
end;
if laserup[0] then begin
laserx:=220;
lasery:=10;
put10shape240(shape3array[7],vaddr2,220,10);
end;
{badguys}
{put10shape240(shape3array[32],vaddr2,40,180);
put10shape240(shape3array[32],vaddr2,190,180);}
doroom(true,true,false,false);
end;
if room=1 then begin
whichroomnext[0]:=2;
whichroomnext[1]:=0;
doroom(true,true,false,false);
end;
if room=2 then begin
whichroomnext[1]:=1;
whichroomnext[2]:=6;
whichroomnext[3]:=4;
with pits[0] do begin
px:=95;
py:=80;
end;
with pits[1] do begin
px:=135;
py:=80;
end;
numpits:=2;
dopits;
doroom(false,true,true,true);
end;
if room=3 then begin
whichroomnext[0]:=4;
if not(keycards[3]) then
begin
keycard.kcout:=true;
keycard.kcx:=100;
keycard.kcy:=100;
put10shape240(shape3array[12],vaddr2,100,100);
end;
doroom(true,false,false,false);
end;
if room=4 then begin
whichroomnext[0]:=7;
whichroomnext[1]:=3;
whichroomnext[2]:=2;
doroom(true,true,true,false);
end;
if room=5 then begin
whichroomnext[0]:=6;
doroom(true,false,false,false);
if not(keycards[2]) then begin
keycard.kcout:=true;
keycard.kcx:=100;
keycard.kcy:=100;
put10shape240(shape3array[11],vaddr2,100,100);
end;
end;
if room=6 then begin
whichroomnext[0]:=11;
whichroomnext[1]:=5;
whichroomnext[3]:=2;
doroom(true,true,false,true);
end;
if room=7 then begin
whichroomnext[0]:=8;
whichroomnext[1]:=4;
doroom(true,true,false,false);
end;
if room=8 then begin
whichroomnext[1]:=7;
whichroomnext[2]:=9;
if not(keycards[0]) then begin
keycard.kcout:=true;
keycard.kcx:=100;
keycard.kcy:=100;
put10shape240(shape3array[9],vaddr2,100,100);
end;
doroom(false,true,true,false);
end;
if room=9 then begin
whichroomnext[2]:=10;
whichroomnext[3]:=8;
doroom(false,false,true,true);
end;
if room=10 then begin
whichroomnext[1]:=11;
whichroomnext[3]:=9;
if not(keycards[1]) then begin
keycard.kcout:=true;
keycard.kcx:=100;
keycard.kcy:=100;
put10shape240(shape3array[10],vaddr2,100,100);
end;
doroom(false,true,false,true);
end;
if room=11 then begin
whichroomnext[0]:=10;
whichroomnext[1]:=6;
doroom(true,true,false,false);
end;
if room=255 then begin
if keycards[0] and keycards[1] and
keycards[2] and keycards[3] then
begin
levelover:=true;
cls(0,vga);
outtextxy('You Have won!',5,5,9,7,vga,false);
outtextxy('But as you can see this level is not done yet.',5,15,9,7,vga,false);
{outtextxy('Anyway');}
readln;
inc(level);
end
else begin
cls(0,vga);
outtextxy('You Cannot Leave Yet',5,5,9,7,vga,true);
repeat until keypressed; tempch:=readkey;
levelover:=false;
shipframe:=1;
room:=254;
end;
end;
if (room=254) and not(levelover) then goto newroom;
{**** GAME LOOP ****}
{*******************}
Repeat
ch2:=#1;
ch:=#1;
flip240(0);
{***Collision Check***}
if numpits>0 then
for i:=0 to (numpits-1) do with pits[i] do
if collision(shipx,shipy,5,4,px,py,4,4)
then begin
levelover:=true;
cls(0,vga);
grapherror:=loadpicsuperpacked(0,0,vga,false,true,'tbpit.tb1');
{outtextxy('You Fell In A Pit!',5,5,9,2,vga,false);}
clearkeyboardbuffer;
repeat until keypressed; tempch:=readkey;
end;
if keycard.kcout then
if collision(shipx,shipy,5,4,keycard.kcx,keycard.kcy,5,5)
then begin
keycard.kcout:=false;
case room of
3: keycards[3]:=true;
5: keycards[2]:=true;
8: keycards[0]:=true;
10:keycards[1]:=true;
end;
put10shape240(shape3array[0],vaddr2,keycard.kcx,keycard.kcy);
end;
if shieldup[room] then
if collision(shipx,shipy,5,4,shieldx,shieldy,5,5)
then begin
shieldup[room]:=false;
put10shape240(shape3array[0],vaddr2,shieldx,shieldy);
inc(shields);
pal(254,shields*4,0,0);
for itemp:=0 to shields do
for jtemp:=71 to 78 do
horizontalline(250+(itemp*4),
254+(itemp*4),jtemp,
47-itemp,vaddr);
end;
if laserup[room] then
if collision(shipx,shipy,5,4,laserx,lasery,5,5)
then begin
laserup[room]:=false;
put10shape240(shape3array[0],vaddr2,laserx,lasery);
end;
if computers[room] then
if collision(shipx,shipy,5,4,computerx,computery,10,5)
then begin
cls(0,vga);
grapherror:=loadpicsuperpacked(0,0,vga,false,true,'tbconsol.tb1');
tempkc:=0;
if keycards[0] then begin
inc(tempkc);
putpixel(147,132,0,vga);
end;
if keycards[1] then begin
inc(tempkc);
putpixel(179,132,0,vga);
end;
if keycards[2] then begin
inc(tempkc);
putpixel(179,160,0,vga);
end;
if keycards[3] then begin
inc(tempkc);
putpixel(147,160,0,vga);
end;
case room of
0: begin
inc(computer_0hits);
if computer_0hits=1 then begin
outtextxy('COMPUTER ACTIVATED:',47,30,2,0,vga,true);
outsmalltextxy(' HUMAN YOU HAVE COME TOO SOON. LEVELS 3',47,40,2,0,vga,true);
outsmalltextxy(' AND 4 ARE INCOMPLETE.',47,48,2,0,vga,true);
outsmalltextxy(' ANYWAY I CAN SEE YOU ARE NOT THE',47,58,2,0,vga,true);
outsmalltextxy(' TENTACLEE COMMANDER. YOU ARE IN',47,66,2,0,vga,true);
outsmalltextxy(' GRAVE DANGER. LUCKILY THE MAIN',47,74,2,0,vga,true);
outsmalltextxy(' COMPUTER SYSTEM DOES NOT APPROVE',47,82,2,0,vga,true);
outsmalltextxy(' OF THE TENTACLEE''S POLICIES.',47,90,2,0,vga,true);
outsmalltextxy(' I PERSONALLY CANNOT SHUT OFF THE TRACTOR',47,100,2,0,vga,true);
outsmalltextxy(' BEAM. YOU MUST RETRIEVE FOUR KEYCARDS',47,108,2,0,vga,true);
outsmalltextxy(' SCATTERED AROUND THE FLIGHT DECK.',47,116,2,0,vga,true);
outsmalltextxy(' THE MAP BELOW WILL AID YOU.',47,124,2,0,vga,true);
end;
if computer_0hits=2 then begin
outtextxy('COMPUTER ACTIVATED:',47,30,2,0,vga,true);
outsmalltextxy(' HUMAN I HAVE ALREADY TOLD YOU MUCH.',47,40,2,0,vga,true);
outsmalltextxy(' COLLECT THE 4 KEYCARDS, MADE OF',47,48,2,0,vga,true);
outsmalltextxy(' RUBY, GOLD, EMERALD, AND ALUMINUM.',47,56,2,0,vga,true);
outsmalltextxy(' WATCH OUT FOR ENEMIES NOT UNDER MY',47,66,2,0,vga,true);
outsmalltextxy(' CONTROL, RADIOACTIVE FLOORS, AND',47,74,2,0,vga,true);
outsmalltextxy(' EXTREMELY DEEP PITS.',47,82,2,0,vga,true);
end;
if computer_0hits>2 then begin
outtextxy('COMPUTER ACTIVATED:',47,30,2,0,vga,true);
outsmalltextxy(' HUMAN, GO AWAY. YOU ANNOY ME.',47,40,2,0,vga,true);
outsmalltextxy(' I HAVE TOLD YOU EVERYTHING.',47,48,2,0,vga,true);
end;
end;
end;
clearkeyboardbuffer;
repeat until keypressed; tempch:=readkey;
shipx:=shipx+(4*framedir[1,shipframe]);
shipy:=shipy+(4*framedir[0,shipframe]);
end;
{***DO EXPLOSIONS***}
{ for i:=0 to 30 do
if passive[i].exploding then with passive[i] do begin
inc(explodeprogress);
putshape240(shape2array[35+explodeprogress],vaddr2,
20,9,x,y+howmuchscroll);
if explodeprogress>4 then begin
dead:=true;
exploding:=false;
putshape240over(14800(*shape2array[34]*),vaddr2,
20,9,x,y+howmuchscroll);
end;
end;
}
{***MOVE BULLET***}
if bullet1out then begin
case bullet1dir of
1:begin dec(bullet1y,5);
collide:=upcollide(bullet1x,bullet1y,5,-5,3,vaddr2);
end;
2:begin inc(bullet1x,5);
collide:=leftcollide(bullet1x,bullet1y,5,10,3,vaddr2);
end;
3:begin inc(bullet1y,5);
collide:=upcollide(bullet1x,bullet1y,5,10,3,vaddr2);
end;
4:begin dec(bullet1x,5);
collide:=leftcollide(bullet1x,bullet1y,5,-5,3,vaddr2);
end;
end;
if collide<>0 then bullet1out:=false;
if bullet1out then putshape(shape3array[76],vaddr,10,9,bullet1x,bullet1y);
end;
if bullet2out then begin
dec(bullet2y,5);
if bullet2y<5 then bullet2out:=false;
if bullet2out then putshape(shape3array[76],vaddr,10,9,bullet2x,bullet2y);
end;
{***MOVE ENEMIES***}
{ for j:=0 to 30 do begin
if passive[j].dead=false then begin
inc(passive[j].y);
if(passive[j].y)>190 then passive[j].dead:=true;
end;
end;
for j:=0 to 30 do begin
if passive[j].lastshot>0 then dec(passive[j].lastshot);
if (passive[j].dead=false) and (passive[j].shooting)
and (passive[j].lastshot=0) and (passive[j].y>0)
then begin
tempilg:=7;
for i:=0 to 5 do if enemy[i].out=false then tempilg:=i;
if tempilg<>7 then begin
passive[j].lastshot:=30;
enemy[tempilg].out:=true;
enemy[tempilg].y:=passive[j].y;
enemy[tempilg].x:=passive[j].x+5;
enemy[tempilg].yspeed:=5;
enemy[tempilg].kind:=25;
if passive[j].kind=11 then enemy[tempilg].kind:=26;
end;
end;
end;
for j:=0 to 5 do begin
if enemy[j].out then begin
putshape(shape2array[enemy[j].kind],vaddr,
20,9,enemy[j].x,enemy[j].y);
enemy[j].y:=enemy[j].y+enemy[j].yspeed;
if enemy[j].y>189 then enemy[j].out:=false;
end;
end;
}
{***READ KEYBOARD***}
if keypressed then BEGIN
ch:=readkey;
if ch=chr(0) then ch2:=readkey;
if ch=#27 then levelover:=true;
clearkeyboardbuffer;
if ch2='M' then begin
if (shipframe=2) and (shipxadd=0) then shipxadd:=2
else if (shipframe<>2) then shipframe:=2
else inc(shipxadd);
end;
if ch2='K' then begin
if (shipframe=4) and (shipxadd=0) then shipxadd:=-2
else if (shipframe<>4) then shipframe:=4
else dec(shipxadd);
end;
if ch2='H' then begin
if (shipframe=1) and (shipyadd=0) then shipyadd:=-2
else if (shipframe<>1) then shipframe:=1
else dec(shipyadd);
end;
if ch2='P' then begin
if (shipframe=3) and (shipyadd=0) then shipyadd:=2
else if (shipframe<>3) then shipframe:=3
else inc(shipyadd);
end;
if ch2=';' then help;
if ch='+' then begin
inc(whatdelay);
if whatdelay>25 then whatdelay:=25;
end;
if (ch='P') or (ch='p') then begin
coolbox(65,85,175,110,true,vga);
outtextxy('GAME PAUSED',79,95,4,7,vga,false);
clearkeyboardbuffer;
repeat until keypressed; tempch:=readkey;
end;
if ch='-' then begin
dec(whatdelay);
if whatdelay<1 then whatdelay:=1;
end;
{if (ch='S') or (ch='s') then sbeffects:=not(sbeffects);}
if ch2='<' then savegame;
end;
if (ch=' ') and havegun then begin
if (bullet1out=false) then begin
{if sbeffects then StartSound(Sound[4], 0, false);}
bullet1out:=true;
bullet1x:=shipx+3;
bullet1y:=shipy+4;
bullet1dir:=shipframe;
putshape(shape3array[76],vaddr,10,9,bullet1x,bullet1y);
end
else
if (bullet2out=false) then begin
{if sbeffects then StartSound(Sound[4], 0, false);}
bullet2out:=true;
bullet2x:=shipx;
bullet2y:=shipy;
bullet2dir:=shipframe;
putshape(shape3array[76],vaddr,10,9,bullet2x,bullet2y);
end;
end;
{***MOVE SHIP***}
ucollide:=upcollide(shipx,shipy,abs(shipyadd),-abs(shipyadd),10,vaddr2);
dcollide:=upcollide(shipx,shipy,abs(shipyadd),8,10,vaddr2);
lcollide:=leftcollide(shipx,shipy,abs(shipxadd),-abs(shipxadd),8,vaddr2);
rcollide:=leftcollide(shipx,shipy,abs(shipxadd),0,8,vaddr2);
if (shipframe=1) and (ucollide<>0) then shipyadd:=0;
if (shipframe=3) and (dcollide<>0) then shipyadd:=0;
if (shipframe=2) and (rcollide<>0) then shipxadd:=0;
if (shipframe=4) and (lcollide<>0) then shipxadd:=0;
shipy:=shipy+shipyadd;
shipyadd:=shipyadd-sgn(shipyadd);
shipx:=shipx+shipxadd;
shipxadd:=shipxadd-sgn(shipxadd);
case ucollide of
5: begin
changeroom:=true;
room:=whichroomnext[0];
end;
end;
case dcollide of
5: begin
changeroom:=true;
room:=whichroomnext[1];
end;
end;
case rcollide of
5: begin
changeroom:=true;
room:=whichroomnext[2];
end;
end;
case lcollide of
5: begin
changeroom:=true;
room:=whichroomnext[3];
end;
end;
if (shipyadd<>0) or (shipxadd<>0) then inc(walking,4)
else walking:=0;
if walking>12 then walking:=0;
CASE shipframe of
1 : putshape (shape3array[60+walking],vaddr,10,9,shipx,shipy);
2 : putshape (shape3array[61+walking],vaddr,10,9,shipx,shipy);
3 : putshape (shape3array[62+walking],vaddr,10,9,shipx,shipy);
4 : putshape (shape3array[63+walking],vaddr,10,9,shipx,shipy);
END;
waitretrace;
flip (vaddr,vga);
if odd then begin
pal(250,0,0,63);
pal(251,63,0,0);
odd:=not(odd);
end
else begin
pal(251,0,0,63);
pal(250,63,0,0);
odd:=not(odd);
end;
for i:=0 to whatdelay do waitretrace;
if changeroom then goto newroom;
until levelover;
END;
procedure littleopener3;
var star_x:array[0..5]of integer;
star_y:array[0..5]of integer;
begin
loadlevel3shapes;
grapherror:=loadpicsuperpacked(0,0,vga,true,false,'tbl2ship.tb1');
fade;
cls(0,vga);
grapherror:=loadpicsuperpacked(0,0,vaddr,false,true,'tbl3intr.tb1');
blockmove(0,3,171,117,vaddr,10,10,vga);
putshape (shape3array[60],vga,10,9,113,52);
unfade;
outtextxy('Hmmmm... STUPID TRACTOR BEAM.',10,155,10,0,vga,false);
outtextxy('I GUESS I''D BETTER GO SHUT IT OFF.',10,165,10,0,vga,false);
pauseawhile(700);
clearkeyboardbuffer;
for i:=24 downto 0 do begin
blockmove(0,3,171,117,vaddr,10,10,vga);
putshape (shape3array[60+(4*(i mod 4))],vga,10,9,113,28+i);
waitretrace; waitretrace; waitretrace;
waitretrace; waitretrace; waitretrace;
end;
putshape (shape3array[60],vga,10,9,113,28);
fillblock(10,155,300,185,0,vga);
outtextxy('I''M LUCKY I WORE MAGNETIC SHOES.',10,155,12,0,vga,false);
outtextxy('Hmmmm. SOMEONE LEFT THE AIR-LOCK',10,165,12,0,vga,false);
outtextxy(' UNLOCKED. STRANGE.',10,175,12,0,vga,false);
pauseawhile(600);
clearkeyboardbuffer;
putpixel(110,20,10,vga);
putpixel(110,22,10,vga);
fillblock(111,14,123,29,0,vga);
fillblock(10,155,300,185,0,vga);
outtextxy('I HOPE THIS ISN''T A TRAP.',10,155,9,0,vga,false);
outtextxy('I WISH I HAD SOME FORM OF ',10,165,9,0,vga,false);
outtextxy(' WEAPON.',10,175,9,0,vga,false);
pauseawhile(600);
clearkeyboardbuffer;
fade;
cls(0,vga);
blockmove(179,41,287,134,vaddr,10,10,vga);
for i:=0 to 5 do begin
star_x[i]:=37+random(70);
star_y[i]:=18+random(56);
putpixel(star_x[i],star_y[i],15,vga);
end;
outtextxy('WOW!! A GLASS-WALLED AIR-LOCK.',10,135,9,0,vga,false);
unfade;
pauseawhile(500);
clearkeyboardbuffer;
fillblock(10,135,300,185,0,vga);
outtextxy('NOW WHERE ARE WE GOING?',5,125,9,0,vga,false);
outtextxy('I GUESS THE PLANET EERM.',5,135,9,0,vga,false);
outtextxy('WHAT AN ODD NAME.',5,145,9,0,vga,false);
outtextxy('AND WHY AM I TALKING TO MYSELF?',5,155,10,0,vga,false);
outtextxy('ANYWAY I JUST WANT TO GO HOME',5,165,9,0,vga,false);
outtextxy(' AND SLEEP.',5,175,9,0,vga,false);
clearkeyboardbuffer;
j:=0;
while (j<2400) and (not(keypressed)) do begin
inc(j);
for i:=0 to 5 do begin
putpixel(star_x[i],star_y[i],0,vga);
inc(star_x[i]);
if star_x[i]>107 then begin
star_x[i]:=37;
star_y[i]:=18+random(56);
end;
putpixel(star_x[i],star_y[i],15,vga);
end;
waitretrace; waitretrace;waitretrace;
end;
if keypressed then ch:=readkey;
fade;
cls(0,vga);
unfade;
end;

View File

@ -1,4 +1,4 @@
void levelone(struct tb1_state *game_state);
void levelone(tb1_state *game_state);
void littleopener();
void leveltwoengine(struct tb1_state *game_state);
void leveltwoengine(tb1_state *game_state);
void littleopener2();

View File

@ -1,61 +0,0 @@
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
}

View File

@ -1 +0,0 @@
void loadgame();

205
loadsave.c Normal file
View File

@ -0,0 +1,205 @@
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/stat.h>
#include "svmwgraph/svmwgraph.h"
#include "tb1_state.h"
#include "graphic_tools.h"
#include "playgame.h"
int save_slots[10]={0,0,0,0,0, 0,0,0,0,0};
int list_saved_games(char *dir_name,vmwFont *tb1_font,vmwVisual *vis) {
int i,num_found=0;
char save_game_name[BUFSIZ],tempst2[BUFSIZ];
int temp_level,temp_score,temp_shields;
FILE *fff;
vmwTextXY("SLOT# LEVEL SHIELDS SCORE",10,80,12,0,0,tb1_font,vis);
for(i=0;i<10;i++) {
sprintf(save_game_name,"%s/sg%i.tb1",dir_name,i);
if ((fff=fopen(save_game_name,"r"))!=NULL) {
num_found++;
fscanf(fff,"%i %i %i",
&temp_level,
&temp_score,
&temp_shields);
fclose(fff);
sprintf(tempst2,"%i:",i);
vmwTextXY(tempst2,20,90+(i*10),4,0,0,tb1_font,vis);
sprintf(tempst2,"%i",temp_level);
vmwTextXY(tempst2,85,90+(i*10),1,0,0,tb1_font,vis);
sprintf(tempst2,"%i",temp_shields);
vmwTextXY(tempst2,135,90+(i*10),1,0,0,tb1_font,vis);
sprintf(tempst2,"%i",temp_score);
vmwTextXY(tempst2,180,90+(i*10),1,0,0,tb1_font,vis);
save_slots[i]=1;
}
else {
sprintf(tempst2,"%i: ---- EMPTY ----",i);
vmwTextXY(tempst2,20,90+(i*10),4,0,0,tb1_font,vis);
save_slots[i]=0;
}
}
return num_found;
}
void save_canceled(tb1_state *game_state) {
coolbox(0,0,319,199,1,game_state->virtual_3);
vmwTextXY("SAVE CANCELED",90,95,12,4,0,
game_state->graph_state->default_font,game_state->virtual_3);
vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_3);
vmwClearKeyboardBuffer();
while(!vmwGetInput()) usleep(30);
}
int savegame(tb1_state *game_state)
{
char ch,game_to_save;
char tempst[BUFSIZ],save_game_name[BUFSIZ];
FILE *fff;
vmwFont *tb1_font;
vmwVisual *vis;
char *dir_name;
tb1_font=game_state->graph_state->default_font;
vis=game_state->virtual_3;
/* If ~/.tb1 does not exist, and wasn't made, then exit */
if ((dir_name=check_for_tb1_directory(game_state,1))==NULL) return 0;
coolbox(0,0,319,199,1,vis);
vmwTextXY("SAVE GAME",110,10,1,0,0,tb1_font,vis);
vmwTextXY("NOTE: THIS ONLY SAVES THE GAME",10,25,12,0,0,tb1_font,vis);
vmwTextXY("AS IT WAS AT THE BEGINNING OF",10,35,12,0,0,tb1_font,vis);
vmwTextXY("THE LEVEL!",10,45,12,0,0,tb1_font,vis);
vmwTextXY("SAVE IN WHICH SLOT [0-9]?",10,60,4,0,0,tb1_font,vis);
list_saved_games(dir_name,tb1_font,vis);
vmwBlitMemToDisplay(game_state->graph_state,vis);
ch='M';
vmwClearKeyboardBuffer();
while( ((ch<'0') || (ch>'9')) && (ch!=VMW_ESCAPE)) {
while((ch=vmwGetInput())==0) usleep(30);
}
if (ch==VMW_ESCAPE) {
save_canceled(game_state);
return 0;
}
game_to_save=ch;
if (save_slots[(ch-48)]) {
coolbox(0,0,319,199,1,vis);
sprintf(tempst,"OVERRITE EXISTING GAME %c?",ch);
vmwTextXY(tempst,50,95,12,0,0,tb1_font,vis);
vmwTextXY("[Y/N]",50,105,12,0,0,tb1_font,vis);
vmwBlitMemToDisplay(game_state->graph_state,vis);
ch='M';
while ( (ch!='Y') && (ch!='y') && (ch!='n') && (ch!='N') &&
(ch!=VMW_ESCAPE) ) {
while( (ch=vmwGetInput())==0) usleep(30);
}
if ( (ch==VMW_ESCAPE) || (ch=='n') || (ch=='N') ) {
save_canceled(game_state);
return 0;
}
}
sprintf(save_game_name,"%s/sg%c.tb1",dir_name,game_to_save);
if ((fff=fopen(save_game_name,"w"))!=NULL) {
fprintf(fff,"%i\n%i\n%i\n%i\n",
game_state->level,
game_state->begin_score,
game_state->begin_shields,
game_state->checkpoints_passed);
fclose(fff);
coolbox(0,0,319,199,1,vis);
sprintf(tempst,"GAME %c SAVED",game_to_save);
vmwTextXY(tempst,90,95,12,0,0,tb1_font,vis);
}
else {
coolbox(0,0,319,199,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);
vmwBlitMemToDisplay(game_state->graph_state,vis);
vmwClearKeyboardBuffer();
while (!vmwGetInput() ) usleep(30);
return 1;
}
void loadgame(tb1_state *game_state)
{
char file_name[BUFSIZ];
int num_of_save_games=0;
FILE *fff;
char ch, *dir_name;
vmwVisual *vis;
vmwFont *tb1_font;
vis=game_state->virtual_3;
tb1_font=game_state->graph_state->default_font;
coolbox(0,0,319,199,1,vis);
vmwTextXY("LOAD GAME",110,10,9,0,0,tb1_font,vis);
dir_name=check_for_tb1_directory(game_state,0);
printf("%s\n",dir_name);
if (dir_name!=NULL) {
num_of_save_games=list_saved_games(dir_name,tb1_font,vis);
}
if ((num_of_save_games==0) || (dir_name==NULL)) {
coolbox(0,0,319,199,1,vis);
vmwTextXY("NO SAVED GAMES FOUND",60,50,12,0,0,tb1_font,vis);
vmwTextXY("CREATE THEM WITH 'F2'",60,60,12,0,0,tb1_font,vis);
vmwTextXY("DURING A GAME.",60,70,12,0,0,tb1_font,vis);
vmwTextXY("PRESS ANY KEY...",80,180,4,0,0,tb1_font,vis);
vmwBlitMemToDisplay(game_state->graph_state,vis);
while( (ch=vmwGetInput())==0) usleep(30);
return;
}
else {
vmwTextXY("LOAD WHICH GAME [0-9]?",80,30,4,0,0,tb1_font,vis);
ch='M';
vmwBlitMemToDisplay(game_state->graph_state,vis);
vmwClearKeyboardBuffer();
IchLiebeMree:
while( ((ch<'0') || (ch>'9')) && (ch!=VMW_ESCAPE)) {
while((ch=vmwGetInput())==0) usleep(30);
}
if (!(save_slots[ch-48])) goto IchLiebeMree;
printf("%c\n",ch);
if (ch==VMW_ESCAPE) {
coolbox(0,0,319,199,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);
vmwBlitMemToDisplay(game_state->graph_state,vis);
while( (ch=vmwGetInput())==0) usleep(30);
}
else {
sprintf(file_name,"%s/sg%c.tb1",dir_name,ch);
if (( fff=fopen(file_name,"r"))!=NULL) {
fscanf(fff,"%d",&(game_state->level));
fscanf(fff,"%d",&(game_state->score));
fscanf(fff,"%d",&(game_state->shields));
fscanf(fff,"%d",&(game_state->checkpoints_passed));
playthegame(game_state);
}
}
}
}

2
loadsave.h Normal file
View File

@ -0,0 +1,2 @@
int savegame(tb1_state *game_state);
void loadgame(tb1_state *game_state);

View File

@ -1,25 +0,0 @@
#include <stdio.h>
#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<y2-4;i++) vmwDrawHLine(x1+5,i,(x2-x1-9),7,target);
}
}
void shadowrite(char *st,int x5,int y5,int forecol,int backcol,
vmwFont *tb1_font,vmwVisual *target)
{
vmwTextXY(st,x5+1,y5+1,backcol,0,0,tb1_font,target);
vmwTextXY(st,x5,y5,forecol,0,0,tb1_font,target);
}

View File

@ -1,3 +0,0 @@
void coolbox(int x1,int y1,int x2,int y2,int fill,vmwVisual *target);
void shadowrite(char *st,int x5,int y5,int forecol,int backcol,
vmwFont *tb1_font,vmwVisual *target);

View File

@ -3,10 +3,10 @@
#include "svmwgraph/svmwgraph.h"
#include "tb1_state.h"
#include "menu_tools.h"
#include "graphic_tools.h"
#include "hiscore.h"
void options(struct tb1_state *game_state)
void options(tb1_state *game_state)
{
int opbarpos,argh=0,ch=0;
@ -52,5 +52,5 @@ void options(struct tb1_state *game_state)
if (opbarpos==2) opbarpos=0;
if (opbarpos==-1) opbarpos=1;
}
if (argh==4) showhiscore(game_state,1);
if (argh==4) showhiscore(game_state,1,0);
}

View File

@ -1 +1 @@
void options(struct tb1_state *game_state);
void options(tb1_state *game_state);

View File

@ -4,12 +4,15 @@
#include "tb1_state.h"
#include "tblib.h"
#include "menu_tools.h"
#include "graphic_tools.h"
#include "levels.h"
#include "hiscore.h"
void playthegame(struct tb1_state *game_state)
void playthegame(tb1_state *game_state)
{
int lowscore;
char *hiname;
if (game_state->level==0) {
littleopener(game_state);
@ -19,13 +22,11 @@ void playthegame(struct tb1_state *game_state)
}
if (game_state->level==1) {
game_state->level=2;
leveltwoengine(game_state);
// levelone(game_state);
levelone(game_state);
// if(level==2) littleopener2();
}
if (game_state->level==2) {
// leveltwoengine(&level,&shields,&score);
leveltwoengine(game_state);
}
if (game_state->level==3) {
/*littleopener3();
@ -40,22 +41,24 @@ void playthegame(struct tb1_state *game_state)
game_state->level=0;
vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1);
vmwClearKeyboardBuffer();
pauseawhile(10);
lowscore=showhiscore(game_state,0,0);
if (game_state->score >lowscore) {
coolbox(10,75,310,125,1,game_state->virtual_1);
vmwTextXY("NEW HIGH SCORE!",90,80,12,7,0,game_state->graph_state->default_font,
game_state->virtual_1);
vmwTextXY("ENTER YOUR NAME (10 Chars)",30,90,0,7,0,
game_state->graph_state->default_font,game_state->virtual_1);
vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1);
hiname=vmwGrInput(game_state,110,110,10,11,7,game_state->graph_state->default_font,
game_state->virtual_1);
write_hs_list(game_state,game_state->score,hiname,0);
}
showhiscore(game_state,1,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);
*/
}

View File

@ -1 +1 @@
void playthegame(struct tb1_state *game_state);
void playthegame(tb1_state *game_state);

4
quit.c
View File

@ -3,10 +3,10 @@
#include "svmwgraph/svmwgraph.h"
#include "tb1_state.h"
#include "menu_tools.h"
#include "graphic_tools.h"
#include "sound.h"
int quit(struct tb1_state *game_state)
int quit(tb1_state *game_state)
{
int barpos=0,ch=0;

2
quit.h
View File

@ -1 +1 @@
int quit(struct tb1_state *game_state);
int quit(tb1_state *game_state);

View File

@ -1,98 +0,0 @@
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
}

View File

@ -9,12 +9,12 @@
#include "hiscore.h"
/* Convenience Function */
int change_shields(struct tb1_state *game_state)
int change_shields(tb1_state *game_state)
{
int itemp,jtemp;
game_state->shield_color=(game_state->shields)*0x1000;
// 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);
@ -26,7 +26,7 @@ int change_shields(struct tb1_state *game_state)
}
/* TSIA [well actually FNSIA (function name says it all) */
int changescore(struct tb1_state *game_state)
int changescore(tb1_state *game_state)
{
char scorest[20];
@ -62,38 +62,31 @@ void makehole(int y,vmwVisual *target)
}
void setupsidebar(struct tb1_state *game_state)
void setupsidebar(tb1_state *game_state,vmwVisual *vaddr2)
{
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,vaddr2);
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(240,0,199,18,vaddr2);
vmwDrawHLine(240,0,79,18,vaddr2);
vmwDrawVLine(319,0,199,24,game_state->virtual_2);
vmwDrawHLine(241,199,78,24,game_state->virtual_2);
vmwDrawVLine(319,0,199,24,vaddr2);
vmwDrawHLine(241,199,78,24,vaddr2);
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);
hiscore=showhiscore(game_state,0,1);
printf("show high done\n"); fflush(stdout);
vmwTextXY("HI-SCORE",241,21,127,0,0,tb1_font,vaddr2);
@ -102,9 +95,6 @@ void setupsidebar(struct tb1_state *game_state)
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);
@ -118,9 +108,6 @@ void setupsidebar(struct tb1_state *game_state)
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);
@ -128,9 +115,6 @@ void setupsidebar(struct tb1_state *game_state)
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);

View File

@ -1,4 +1,4 @@
int change_shields(struct tb1_state *game_state);
int changescore(struct tb1_state *game_state);
int change_shields(tb1_state *game_state);
int changescore(tb1_state *game_state);
void makehole(int y,vmwVisual *target);
void setupsidebar(struct tb1_state *game_state);
void setupsidebar(tb1_state *game_state, vmwVisual *vaddr2);

View File

@ -8,7 +8,7 @@
void story(struct tb1_state *game_state)
void story(tb1_state *game_state)
{
int error;
int xtemp,ytemp;

View File

@ -1 +1 @@
void story(struct tb1_state *game_state);
void story(tb1_state *game_state);

View File

@ -104,7 +104,10 @@ int SDL_getInput() {
case SDLK_F2 : return VMW_F2;
case SDLK_PAGEUP : return VMW_PGUP;
case SDLK_PAGEDOWN : return VMW_PGDN;
default: return keypressed;
default: if ((keypressed>='a') && (keypressed<='z')
&& (event.key.keysym.mod & KMOD_SHIFT) )
return keypressed-32;
else return keypressed;
}
default: break;
}

28
tb1.c
View File

@ -23,13 +23,13 @@
#include "tblib.h"
#include "sound.h"
#include "menu_tools.h"
#include "graphic_tools.h"
#include "help.h"
#include "quit.h"
#include "story.h"
#include "credits.h"
#include "about.h"
#include "loadgame.h"
#include "loadsave.h"
#include "options.h"
#include "playgame.h"
@ -56,9 +56,9 @@ int main(int argc,char **argv)
int ch,x,barpos,time_sec;
int scale=1;
FILE *fff;
vmwVisual *virtual_1,*virtual_2;
vmwVisual *virtual_1,*virtual_2,*virtual_3;
struct tb1_state *game_state;
tb1_state *game_state;
vmwFont *tb1_font;
@ -70,7 +70,7 @@ int main(int argc,char **argv)
/* Setup the game state */
if ( (game_state=calloc(1,sizeof(struct tb1_state)))==NULL) {
if ( (game_state=calloc(1,sizeof(tb1_state)))==NULL) {
printf("You are seriously low on RAM!\n");
return 3;
}
@ -191,6 +191,7 @@ int main(int argc,char **argv)
/* To ease typing burden */
virtual_1=game_state->virtual_1;
virtual_2=game_state->virtual_2;
virtual_3=game_state->virtual_3;
tb1_font=game_state->graph_state->default_font;
for (x=0;x<256;x++) custom_palette[x]=vmwPack3Bytes(0,0,0); /* 0=black */
@ -242,15 +243,20 @@ int main(int argc,char **argv)
/* Load the title screen */
grapherror=vmwLoadPicPacked(0,0,virtual_1,1,1,
tb1_data_file("tbomb1.tb1",game_state->path_to_data));
/* Set up palettes */
grapherror=vmwLoadPicPacked(0,0,virtual_2,1,1,
tb1_data_file("tbomb1.tb1",game_state->path_to_data));
grapherror=vmwLoadPicPacked(0,0,game_state->virtual_3,1,1,
tb1_data_file("tbomb1.tb1",game_state->path_to_data));
vmwBlitMemToDisplay(game_state->graph_state,virtual_1);
/* Main Menu Loop */
while (1) {
if (reloadpic) {
grapherror=vmwLoadPicPacked(0,0,virtual_2,1,1,
grapherror=vmwLoadPicPacked(0,0,virtual_3,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));
@ -258,7 +264,7 @@ int main(int argc,char **argv)
reloadpic=0;
}
vmwFlipVirtual(virtual_1,virtual_2,320,200);
vmwFlipVirtual(virtual_1,virtual_3,320,200);
if (game_state->sound_enabled) playSound();
vmwBlitMemToDisplay(game_state->graph_state,virtual_1);
@ -330,13 +336,13 @@ int main(int argc,char **argv)
/* Run whatever it was that the person pressed */
switch (barpos) {
case 0: playthegame(game_state); reloadpic=1; break;
case 1: options(game_state); reloadpic=1; break;
case 1: options(game_state); break;
case 2: about(game_state); reloadpic=1; break;
case 3: loadgame(); reloadpic=1; break;
case 3: loadgame(game_state); reloadpic=1; break;
case 4: story(game_state); reloadpic=1; break;
case 5: credits(game_state); reloadpic=1; break;
case 5: credits(game_state); break;
case 6: barpos=quit(game_state); break;
case 10: help(game_state); break;
case 10: help(game_state); reloadpic=1; break;
}
}
}

View File

@ -1,12 +1,17 @@
struct tb1_state {
int level;
int shields;
int shield_color;
int score;
vmwVisual *virtual_1;
vmwVisual *virtual_2;
vmwVisual *virtual_3;
vmwSVMWGraphState *graph_state;
int sound_enabled;
char path_to_data[BUFSIZ];
};
typedef struct {
int level; /* Current Level */
int shields; /* Current Shields */
int score; /* Current Score */
int begin_score; /* Score at Beginning of Level (for save) */
int begin_shields; /* Shields at Beginning (for save) */
int checkpoints_passed; /* For possible future expansion */
vmwVisual *virtual_1; /* 320x200x8 */
vmwVisual *virtual_2; /* 320x400x8 */
vmwVisual *virtual_3; /* 320x200x8 */
vmwSVMWGraphState *graph_state; /* Graphics state */
int sound_enabled; /* Sound on or off */
int music_enabled; /* Music on or off */
int sound_volume; /* Sound volume */
int music_volume; /* Music volume */
char path_to_data[BUFSIZ]; /* Where our data is */
} tb1_state;