version 2.9.3

This commit is contained in:
Vince Weaver 2000-09-16 19:23:00 -04:00
parent d00b5521b8
commit 44047ca3bb
48 changed files with 1725 additions and 2779 deletions

12
CHANGES
View File

@ -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.

View File

@ -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 *~

106
about.c Normal file
View File

@ -0,0 +1,106 @@
#include <stdio.h>
#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;
}
}
}

1
about.h Normal file
View File

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

136
credits.c Normal file
View File

@ -0,0 +1,136 @@
#include <stdio.h>
#include <unistd.h>
#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);
}

1
credits.h Normal file
View File

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

50
help.c Normal file
View File

@ -0,0 +1,50 @@
#include <stdio.h>
#include <unistd.h>
#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);
}

1
help.h Normal file
View File

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

75
hiscore.c Normal file
View File

@ -0,0 +1,75 @@
#include <stdio.h>
#include "svmwgraph/svmwgraph.h"
#include "tb1_state.h"
#include "menu_tools.h"
#include <unistd.h> /* 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
}

2
hiscore.h Normal file
View File

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

139
level_1.c
View File

@ -7,15 +7,18 @@
#include <sys/time.h>
#include <unistd.h>
#include <stdlib.h>
#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));
}

View File

@ -7,15 +7,16 @@
#include <sys/time.h>
#include <unistd.h>
#include <stdlib.h>
#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);

61
loadgame.c Normal file
View File

@ -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
}

1
loadgame.h Normal file
View File

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

25
menu_tools.c Normal file
View File

@ -0,0 +1,25 @@
#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);
}

3
menu_tools.h Normal file
View File

@ -0,0 +1,3 @@
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);

56
options.c Normal file
View File

@ -0,0 +1,56 @@
#include <stdio.h>
#include <unistd.h>
#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);
}

1
options.h Normal file
View File

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

61
playgame.c Normal file
View File

@ -0,0 +1,61 @@
#include <stdio.h>
#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);
*/
}

1
playgame.h Normal file
View File

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

44
quit.c Normal file
View File

@ -0,0 +1,44 @@
#include <stdio.h>
#include <unistd.h>
#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;
}

1
quit.h Normal file
View File

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

98
savegame.c Normal file
View File

@ -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
}

View File

@ -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 <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <unistd.h>
#include <string.h>
#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;i<how_long;i++) {
vmwPutPixel(xstart+i,ystart,color,target);
}
}
void vmwDrawVLine(int xstart,int ystart,int how_long,int color, unsigned char *target) {
int i;
for(i=0;i<how_long;i++) {
vmwPutPixel(xstart,ystart+i,color,target);
}
}
/*---------------------------------------------------------------*\
| vmwLoadPicPacked |
| There is so much history in this function, I won't get into |
| it here. |
\*---------------------------------------------------------------*/
int vmwLoadPicPacked(int x1,int y1,unsigned char *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<y1+ysize)) {
temp1=buffer[buffpointer];
temp2=buffer[buffpointer+1];
temp3=buffer[buffpointer+2];
buffpointer+=3;
if (buffpointer>=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) && (y<y1+ysize)) {
if (numacross+x>xsize+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)<howlong) {
if (SDL_PollEvent(&event)) {
if (event.type==SDL_KEYDOWN) return;
}
usleep(30);
gettimeofday(&bob,&mree);
}
}
typedef struct {
char *font_data;
int width;
int height;
int numchars;
} vmw_font;
void vmwFlipVirtual(unsigned char *destination,
unsigned char *source) {
memcpy(destination,source,320*200*2);
}
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(unsigned char *src,int x1,int y1,int w,int h,
unsigned char *dest,int x2,int y2)
{
int y;
unsigned char *source,*destination;
source=src+(320*2*y1);
destination=dest+(320*2*y2);
for(y=0;y<h;y++) {
memcpy ((destination+x2*2),(source+x1*2),(w*2));
source+=320*2;
destination+=320*2;
}
return 0;
}
int vmwPutPartialSprite(int *src,int w,int h,int stride_factor,
char *dest,int x,int y,int dest_stride,
int x_start,int x_stop,int y_start,int y_stop)
{ /* x_start/stop not implemented yet */
int xx,yy;
/*
dest+=(dest_stride*y);
for(yy=0;yy<h;yy++){
for(xx=0;xx<w;xx++)
if ((*(src+xx)) && ((yy>=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))&&(fonty<numloop)) {
fread(buff,1,16,f);
for(i=0;i<16;i++) font->font_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;i<len;i++)
for(xx=0;xx<8;xx++){
if ( (font->font_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;i<len;i++)
for(xx=0;xx<8;xx++)
if( ((unsigned char) (font->font_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;i<len;i++)
for(xx=0;xx<8;xx++){
if ( (font->font_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;i<len;i++)
for(xx=0;xx<5;xx++) {
if ( (font->font_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<m) THEN
BEGIN
s := s - m;
a:= a +round(d1x);
b := b + round(d1y);
END
ELSE
BEGIN
a := a + round(d2x);
b := b + round(d2y);
END;
end;
END;
*/
void vmwFadeToBlack(void) {
}
void vmwUnFade(void) {
}
void vmwDrawBox(int x1,int y1,int xsize,int ysize,int col, unsigned char *where) {
int i;
for(i=0;i<ysize;i++) {
vmwDrawHLine(x1,y1+i,xsize,col,where);
}
}
int vmwGetInput() {
SDL_Event event;
int keypressed;
while ( SDL_PollEvent(&event)) {
switch(event.type) {
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;
default: return keypressed;
}
default: break;
}
}
return 0;
}

View File

@ -1,68 +0,0 @@
/* These are more or less the functions you need to implement one of my */
/* games. This has been done before in SDL, GGI, and Turbo Pascal */
/* so it should be easy to do for other targets... */
typedef struct {
char *font_data;
int width;
int height;
int numchars;
} vmw_font;
int vmwPack3Bytes(int r, int g, int b);
int vmwLoadCustomPalette(int pal[256]);
void vmwBlitMemToSDL(SDL_Surface *target, unsigned char *source);
void vmwClearScreen(unsigned char *target, int color);
void vmwPutPixel(int x,int y,int color, unsigned char *target);
unsigned char vmwGetPixel(int x,int y, unsigned char *source);
void vmwDrawHLine(int xstart,int ystart,int how_long,int color,
unsigned char *target);
void vmwDrawVLine(int xstart,int ystart,int how_long,int color, unsigned char *target);
int vmwLoadPicPacked(int x1,int y1,unsigned char *target,
int LoadPal,int LoadPic,char *FileName);
void vmwFlipVirtual(unsigned char *destination, unsigned char *source);
int vmwCrossBlit(char *dest,char *src,int stride,int ysize);
int vmwCrossBlit240(char *dest,char *src,int stride,int stride_factor,
int ysize);
int vmwArbitraryCrossBlit(unsigned char *src,int x1,int y1,int w,int h,
unsigned char *dest,int x2,int y2);
int vmwPutPartialSprite(int *src,int w,int h,int stride_factor,
char *dest,int x,int y,int dest_stride,
int x_start,int x_stop,int y_start,int y_stop);
vmw_font *vmwLoadFont(char *namest,int xsize,int ysize,int numchars);
void vmwTextLineOver(char *st,int x,int y,int col,int background,int line,
vmw_font *font,unsigned char *target);
void vmwTextLine(char *st,int x,int y,int col,int background,int line,
vmw_font *font,unsigned char *target);
void vmwTextXY(char *st,int x,int y,int col,int background,int overwrite,
vmw_font *font,unsigned char *target);
void vmwSmallTextXY(char *st,int x,int y,int col,int background,int overwrite,
vmw_font *font,unsigned char *target);
void line(int a,int b,int c,int d,int col,char *where);
void vmwFadeToBlack(void);
void vmwUnFade(void);
void vmwDrawBox(int x1,int y1,int x2,int y2,int col,unsigned char *where);
int vmwGetInput();
void clear_keyboard_buffer();
void pauseawhile(int howlong);

148
sidebar.c Normal file
View File

@ -0,0 +1,148 @@
/* Routines for drawing the sidebar */
#include <stdio.h>
#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);
}

4
sidebar.h Normal file
View File

@ -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);

View File

@ -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 <stdlib.h>
#include "tblib.h"
/* linux only, at the moment */

389
story.c Normal file
View File

@ -0,0 +1,389 @@
#include <stdio.h>
#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. <Ow that itches>",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("<Huh?> ",1,1,9],0],1,tb1_font,virtual_1);
pauseawhile(10);
#endif
}

1
story.h Normal file
View File

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

View File

@ -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 *~

View File

@ -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 <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <unistd.h>
#include <string.h>
#include "SDL.h"
#include "tb_keypress.h"
#include <SDL.h>
#include "svmwgraph.h"
#include <stdlib.h> /* 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;x<source->xsize;x++)
for (y=0;y<source->ysize;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;

View File

@ -0,0 +1,8 @@
/* The SDL hooks for the Super VMW graphics library */
#include <SDL.h>
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();

View File

@ -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 <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <unistd.h>
#include <string.h>
#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;i<how_long;i++) {
*temp_pointer=color;
temp_pointer++;
}
}
void vmwDrawVLine(int xstart,int ystart,int how_long,int color,
vmwVisual *target) {
unsigned char *temp_pointer;
int i;
temp_pointer=target_memory+(ystart*target->xsize)+xstart;
for(i=0;i<how_long;i++) {
*temp_pointer=color;
temp_pointer+=target->xsize;
}
}
/*---------------------------------------------------------------*\
| 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<y1+ysize)) {
temp1=buffer[buffpointer];
temp2=buffer[buffpointer+1];
temp3=buffer[buffpointer+2];
buffpointer+=3;
if (buffpointer>=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) && (y<y1+ysize)) {
if (numacross+x>xsize+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;y<h;y++) {
memcpy ((destination+x2*2),(source+x1*2),(w*2));
source+=320*2;
destination+=320*2;
}
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))&&(fonty<numloop)) {
fread(buff,1,16,f);
for(i=0;i<16;i++) font->font_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;i<len;i++)
for(xx=0;xx<8;xx++){
if ( (font->font_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;i<len;i++)
for(xx=0;xx<8;xx++)
if( ((unsigned char) (font->font_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;i<len;i++)
for(xx=0;xx<8;xx++){
if ( (font->font_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;i<len;i++)
for(xx=0;xx<5;xx++) {
if ( (font->font_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<m) THEN
BEGIN
s := s - m;
a:= a +round(d1x);
b := b + round(d1y);
END
ELSE
BEGIN
a := a + round(d2x);
b := b + round(d2y);
END;
end;
END;
*/
}
void vmwFadeToBlack(vmwVisual *source) {
int temp_pal[256];
// temp_pal=real_pal
// for (i=0;i<256;i++) {
// temp_pal[i]--;
// vmwBlitMemToDisplay()
// pauseawhile()
//
}
void vmwUnFade(vmwVisual *source) {
}
void vmwDrawBox(int x1,int y1,int xsize,int ysize,int col, vmwVisual *where) {
int i;
for(i=0;i<ysize;i++) {
vmwDrawHLine(x1,y1+i,xsize,col,where);
}
}

View File

@ -1,10 +1,14 @@
/* Defines for the Super VMW Graphics Library */
/* Structures */
typedef struct {
int xsize;
int ysize;
unsigned char *memory;
int palette[256];
int *palette;
int palette_size;
} vmwVisual;
typedef struct {
@ -20,6 +24,41 @@ typedef struct {
unsigned char *spritedata;
} vmwSprite;
typedef struct {
int xsize;
int ysize;
int bpp;
void *output_screen;
vmwFont *default_font;
} vmwSVMWGraphState;
/* Constants */
/* Display Target Constants */
#define VMW_SDLTARGET 1
/* Error Constants */
#define VMW_ERROR_DISPLAY 1
#define VMW_ERROR_FILE 2
#define VMW_ERROR_SIZE 3
#define VMW_ERROR_MEM 4
/* Keypress Constants */
#define VMW_BACKSPACE 1024
#define VMW_ESCAPE 27
#define VMW_ENTER 1025
#define VMW_UP 1026
#define VMW_DOWN 1027
#define VMW_RIGHT 1028
#define VMW_LEFT 1029
#define VMW_F1 1030
#define VMW_F2 1031
#define VMW_PGUP 1032
#define VMW_PGDN 1033
/* Function declarations */
/* From vmw_core.c */
@ -36,7 +75,7 @@ void vmwDrawBox(int x1,int y1,int xsize,int ysize,int col, vmwVisual *where);
/* From vmw_flip.c */
void vmwFlipVirtual(vmwVisual *destination,
vmwVisual *source);
vmwVisual *source,int xsize, int ysize);
int vmwArbitraryCrossBlit(vmwVisual *src,int x1,int y1,int w,int h,
vmwVisual *dest,int x2,int y2);
@ -60,17 +99,28 @@ int vmwSavePicPacked(int x1,int y1,int xsize,int ysize,
/* From vmw_palette.c */
int vmwPack3Bytes(int r, int g, int b);
void vmwLoadCustomPalette(vmwVisual *source, int pal[256]);
void vmwFadeToBlack(vmwVisual *source);
void vmwUnFade(vmwVisual *source);
/* From vmw_setup.c */
extern void *(*vmwSetupGraphics)(int xsize,int ysize, int bpp, int verbose);
extern void (*vmwBlitMemToDisplay)(vmwSVMWGraphState *display, vmwVisual *source);
extern void (*vmwClearKeyboardBuffer)(void);
extern int (*vmwGetInput)(void);
vmwSVMWGraphState *vmwSetupSVMWGraph(int display_type,int xsize,int ysize,
int bpp,int verbose);
vmwVisual *vmwSetupVisual(int xsize,int ysize,int palette_size);
/* From vmw_sprite.c */
vmwSprite *vmwGetSprite(int x, int y,
int xsize, int ysize,vmwVisual *screen);
void vmwPutSprite(vmwSprite *sprite,int x,int y,int shield_color,
void vmwPutSprite(vmwSprite *sprite,int x,int y,
vmwVisual *screen);
void vmwPutPartialSprite(vmwVisual *destination,
@ -78,6 +128,3 @@ void vmwPutPartialSprite(vmwVisual *destination,
int x_start,int y_start,
int x_stop, int y_stop);

View File

@ -1,8 +1,9 @@
/* Core Graphics routines for the Super VMW Graphics Library */
#include "svmwgraph.h"
#include <stdio.h>
// #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;i<how_long;i++) {
*temp_pointer=color;
temp_pointer++;
#ifdef DEBUG
if (xstart+i>target->xsize-1) {
printf("Out of bounds!\n");
return;
}
#endif
}
}

View File

@ -5,9 +5,9 @@
#include <string.h> /* 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;y<h;y++) {
memcpy ((destination+x2),(source+x1),w);
source+=src->xsize;
destination+=dest->ysize;
destination+=dest->xsize;
}
return 0;

View File

@ -5,15 +5,6 @@
#include <stdio.h> /* For FILE I/O */
#include <string.h> /* 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 |

View File

@ -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++) {

View File

@ -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 <stdio.h> /* For printf */
#include <stdlib.h> /* 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;
}

View File

@ -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;yy<sprite->ysize;yy++) {
for (xx=0;xx<sprite->xsize;xx++) {

137
tb1.c
View File

@ -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 <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <stdlib.h> /* for calloc */
#include <string.h> /* for strncpy */
#include <unistd.h>
#include <sys/time.h>
#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;

View File

@ -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];
};

View File

@ -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

1220
tblib.c

File diff suppressed because it is too large Load Diff

24
tblib.h
View File

@ -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);

Binary file not shown.

View File

@ -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);