Version 2.9.7

This commit is contained in:
Vince Weaver 2000-09-22 02:13:00 -04:00
parent e5d1aad604
commit 74c314d01c
13 changed files with 87 additions and 70 deletions

View File

@ -451,7 +451,7 @@ void levelone(tb1_state *game_state) {
if (bullet[itemp].out)
if (collision(bullet[itemp].x,bullet[itemp].y,10,10,
enemy[i].x,enemy[i].y,9,9)) {
if (game_state->sound_enabled)
if ((game_state->sound_possible)&&(game_state->sound_enabled))
playGameFX(SND_KAPOW);
enemy[i].hitsneeded--;
if (enemy[i].hitsneeded<1) enemy[i].dead=1;
@ -524,7 +524,7 @@ void levelone(tb1_state *game_state) {
}
if (enemy[i].y>140) {
if (collision(shipx,165,24,15,enemy[i].x,enemy[i].y,9,9)) {
if (game_state->sound_enabled)
if ((game_state->sound_possible)&&(game_state->sound_enabled))
playGameFX(SND_BONK);
enemy[i].hitsneeded--;
if (enemy[i].hitsneeded==0) enemy[i].dead=1;
@ -571,7 +571,7 @@ void levelone(tb1_state *game_state) {
break;
case ' ': for(j=0;j<2;j++)
if (!bullet[j].out) {
if (game_state->sound_enabled)
if ((game_state->sound_possible)&&(game_state->sound_enabled))
playGameFX(SND_CC);
bullet[j].out=1;
bullet[j].x=shipx+15;

View File

@ -231,7 +231,7 @@ void leveltwoengine(tb1_state *game_state)
(collision(bullet[j].x,bullet[j].y,3,4,passive[i].x,
passive[i].y,10,5))){
if (passive[i].kind!=10) {
if (game_state->sound_enabled)
if ((game_state->sound_possible)&&(game_state->sound_enabled))
playGameFX(SND_KAPOW);
passive[i].exploding=1;
passive[i].explodeprogress=0;
@ -258,7 +258,8 @@ void leveltwoengine(tb1_state *game_state)
if ((passive[i].y>155) && (passive[i].kind!=10)) {
if ((collision(passive[i].x,passive[i].y,10,5,shipx+16,165,5,5))||
(collision(passive[i].x,passive[i].y,10,5,shipx+6,175,18,8))) {
if (game_state->sound_enabled) playGameFX(SND_BONK);
if ((game_state->sound_possible)&&(game_state->sound_enabled))
playGameFX(SND_BONK);
passive[i].dead=1;
game_state->shields--;
if(game_state->shields<0) levelover=1;
@ -274,7 +275,8 @@ void leveltwoengine(tb1_state *game_state)
if (enemy[i].out) {
if ((collision(enemy[i].x,enemy[i].y,2,5,shipx+16,165,5,5)) ||
(collision(enemy[i].x,enemy[i].y,2,5,shipx+6,175,18,8))) {
if (game_state->sound_enabled) playGameFX(SND_BONK);
if ((game_state->sound_possible)&&(game_state->sound_enabled))
playGameFX(SND_BONK);
enemy[i].out=0;
game_state->shields--;
if (game_state->shields<0) levelover=1;
@ -368,7 +370,8 @@ void leveltwoengine(tb1_state *game_state)
break;
case ' ': for(j=0;j<3;j++)
if (!bullet[j].out) {
if (game_state->sound_enabled) playGameFX(SND_CC);
if ((game_state->sound_possible)&&(game_state->sound_enabled))
playGameFX(SND_CC);
bullet[j].out=1;
bullet[j].x=shipx+21;
bullet[j].y=165;

View File

@ -41,7 +41,7 @@ int changescore(tb1_state *game_state)
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)
if ((game_state->sound_possible)&&(game_state->sound_enabled))
playGameFX(/*SND_ZRRP*/7);
game_state->shields++;
change_shields(game_state);

View File

@ -41,7 +41,7 @@ int initSound(char *path_to_data) {
/* open the audio device */
if(Mix_OpenAudio(22050, AUDIO_U16, 1, 1024) < 0) {
fprintf(stderr, "can't open audio: %s\n", SDL_GetError());
exit(2);
return -1;
}
loadFX(path_to_data);
return 0;

13
story.c
View File

@ -134,10 +134,15 @@ void story(tb1_state *game_state)
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);
if ((game_state->sound_possible) && (game_state->sound_enabled))
playGameFX(0);
pauseawhile(6);
if (game_state->sound_enabled) playGameFX(2);
if ((game_state->sound_possible) && (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);
@ -321,7 +326,9 @@ void story(tb1_state *game_state)
usleep(80000);
vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1);
if (game_state->sound_enabled) playGameFX(2);
if ((game_state->sound_possible) && (game_state->sound_enabled))
playGameFX(2);
for(xtemp=0;xtemp<10;xtemp++) {
vmwPutSprite(explosion2,160,118,game_state->virtual_1);
doflames(game_state);

View File

@ -4,24 +4,15 @@
#include "svmwgraph.h"
#include <stdlib.h> /* For atexit() */
#define BPP_NUM_TO_TRY 2
/* Should this be the following instead?
int bpp_to_try[]={32,24,16,15,8
};
*/
int bpp_to_try[]={16,8
};
/* Setup the Graphics */
/* Pass '0' to auto-detect bpp */
void *SDL_setupGraphics(int *xsize,int *ysize,int *bpp,
int fullscreen,int verbose)
{
SDL_Surface *sdl_screen=NULL;
int mode,i=0;
int mode;
mode=SDL_SWSURFACE;
mode=SDL_SWSURFACE|SDL_HWPALETTE|SDL_HWSURFACE;
if (fullscreen) mode|=SDL_FULLSCREEN;
/* Initialize the SDL library */
@ -40,19 +31,17 @@ void *SDL_setupGraphics(int *xsize,int *ysize,int *bpp,
sdl_screen = SDL_SetVideoMode(*xsize, *ysize, *bpp, mode);
}
else {
i=0;
while ((i<BPP_NUM_TO_TRY)&&(sdl_screen==NULL)) {
i++;
sdl_screen=SDL_SetVideoMode(*xsize,*ysize,bpp_to_try[i-1],mode);
}
sdl_screen=SDL_SetVideoMode(*xsize,*ysize,0,mode);
}
if ( sdl_screen == NULL ) {
fprintf(stderr, "ERROR! Couldn't set %dx%d video mode: %s\n",
*xsize,*ysize,SDL_GetError());
return NULL;
}
if (*bpp==0) *bpp=bpp_to_try[i-1];
if (*bpp==0) *bpp=sdl_screen->format->BytesPerPixel*8;
if (verbose) {
printf(" + SDL Graphics Initialization successful...\n");
printf(" + Using %dx%dx%dbpp Visual...\n",*xsize,*ysize,*bpp);
@ -61,23 +50,23 @@ void *SDL_setupGraphics(int *xsize,int *ysize,int *bpp,
}
void SDL_WritePaletteColor(vmwSVMWGraphState *state,
unsigned char r,
unsigned char g,
unsigned char b,
int color) {
void SDL_FlushPalette(vmwSVMWGraphState *state) {
SDL_Surface *target;
SDL_Color temp_col;
SDL_Color temp_col[256];
int i;
temp_col.r=r;
temp_col.g=g;
temp_col.b=b;
if (state->bpp==8) {
for(i=0;i<256;i++) {
temp_col[i].r=(state->palette[i]>>11)<<3;
temp_col[i].g=((state->palette[i]>>5)&0x3f)<<2;
temp_col[i].b=(state->palette[i]&0x1f)<<3;
}
target=(SDL_Surface *)state->output_screen;
SDL_SetColors(target,&temp_col,color,1);
target=(SDL_Surface *)state->output_screen;
SDL_SetColors(target,temp_col,0,256);
}
}

View File

@ -4,8 +4,7 @@
void *SDL_setupGraphics(int *xsize,int *ysize,int *bpp,int fullscreen,
int verbose);
void SDL_WritePaletteColor(vmwSVMWGraphState *state,unsigned char r,
unsigned char g,unsigned char b,int color);
void SDL_FlushPalette(vmwSVMWGraphState *state);
void SDL_NoScale16bpp_BlitMem(vmwSVMWGraphState *target, vmwVisual *source);
void SDL_Double16bpp_BlitMem(vmwSVMWGraphState *target_p, vmwVisual *source);
void SDL_NoScale8bpp_BlitMem(vmwSVMWGraphState *target, vmwVisual *source);

View File

@ -112,8 +112,7 @@ void vmwUnFade(vmwVisual *source);
extern void *(*vmwSetupGraphics)(int *xsize,int *ysize, int *bpp,
int fullscreen,int verbose);
extern void (*vmwBlitMemToDisplay)(vmwSVMWGraphState *display, vmwVisual *source);
extern void (*vmwWritePaletteColor)(vmwSVMWGraphState *state,
unsigned char r,unsigned char g,unsigned char b,int color);
extern void (*vmwFlushPalette)(vmwSVMWGraphState *state);
extern void (*vmwClearKeyboardBuffer)(void);
extern int (*vmwGetInput)(void);
vmwSVMWGraphState *vmwSetupSVMWGraph(int display_type,int xsize,int ysize,

View File

@ -98,7 +98,7 @@ int vmwLoadPicPacked(int x1,int y1,vmwVisual *target,
/* 565 packed 16bit RGB */
for(i=0;i<256;i++) {
if (LoadPal)
if (LoadPal)
vmwLoadPalette(graph_state,
buffer[buffpointer],
buffer[buffpointer+1],
@ -114,6 +114,8 @@ int vmwLoadPicPacked(int x1,int y1,vmwVisual *target,
}
}
}
if (LoadPal) vmwFlushPalette(graph_state);
x=x1;
y=y1;

View File

@ -6,19 +6,16 @@ void vmwLoadPalette(vmwSVMWGraphState *state,unsigned char r,
unsigned char g,
unsigned char b,int color) {
if (state->bpp==8) {
}
if (state->bpp==16) {
/* 565 color cube */
/* which can be LESS colorful than 8bpp. Imagine that */
state->palette[color]= ( ((int)(r>>3)) <<11)+
state->palette[color]= ( ((int)(r>>3)) <<11)+
( ((int)(g>>2)) <<5)+
(b>>3);
}
vmwWritePaletteColor(state,r,g,b,color);
}

View File

@ -9,8 +9,7 @@
void *(*vmwSetupGraphics)(int *xsize,int *ysize, int *bpp,
int fullscreen,int verbose);
void (*vmwBlitMemToDisplay)(vmwSVMWGraphState *display, vmwVisual *source);
void (*vmwWritePaletteColor)(vmwSVMWGraphState *state,
unsigned char r,unsigned char g,unsigned char b,int color);
void (*vmwFlushPalette)(vmwSVMWGraphState *state);
void (*vmwClearKeyboardBuffer)(void);
int (*vmwGetInput)(void);
@ -64,7 +63,7 @@ vmwSVMWGraphState *vmwSetupSVMWGraph(int display_type,int xsize,int ysize,
vmwBlitMemToDisplay=SDL_Double16bpp_BlitMem;
}
}
vmwWritePaletteColor=SDL_WritePaletteColor;
vmwFlushPalette=SDL_FlushPalette;
vmwClearKeyboardBuffer=SDL_clearKeyboardBuffer;
vmwGetInput=SDL_getInput;
break;

47
tb1.c
View File

@ -10,7 +10,7 @@
\* This source is released under the GPL */
/****************************************************************/
#define TB1_VERSION "2.9.5"
#define TB1_VERSION "2.9.7"
#include <stdio.h>
#include <stdlib.h> /* for calloc */
@ -82,6 +82,8 @@ int main(int argc,char **argv)
game_state->virtual_1=NULL;
game_state->virtual_2=NULL;
game_state->virtual_3=NULL;
game_state->sound_possible=1;
game_state->music_enabled=1;
game_state->sound_enabled=1;
/* Parse Command Line Arguments */
@ -158,19 +160,33 @@ int main(int argc,char **argv)
printf(" + Seeding random number generator...\n");
/* Load sounds */
initSound(game_state->path_to_data);
loadSound(tb1_data_file("music/vmwfan.mod",game_state->path_to_data));
if (initSound(game_state->path_to_data)<0) game_state->sound_possible=0;
if (game_state->sound_possible) {
loadSound(tb1_data_file("music/vmwfan.mod",game_state->path_to_data));
}
printf(" + Loaded sounds...\n");
/* Setup Graphics */
if (scale==1) {
if ( (game_state->graph_state=vmwSetupSVMWGraph(VMW_SDLTARGET,
320,200,
0,scale,fullscreen,1))==NULL) {
fprintf(stderr,"ERROR: Couldn't get display set up properly.\n");
return VMW_ERROR_DISPLAY;
}
}
else {
if ( (game_state->graph_state=vmwSetupSVMWGraph(VMW_SDLTARGET,
640,480,
0,scale,fullscreen,1))==NULL) {
fprintf(stderr,"ERROR: Couldn't get display set up properly.\n");
return VMW_ERROR_DISPLAY;
}
}
/* Load the tom bombem font */
game_state->graph_state->default_font=
@ -200,7 +216,7 @@ int main(int argc,char **argv)
tb1_font=game_state->graph_state->default_font;
for (x=0;x<256;x++) vmwLoadPalette(game_state->graph_state,0,0,0,x); /* 0=black */
/* Do the VMW Software Production Logo */
for(x=0;x<=40;x++) {
vmwLoadPalette(game_state->graph_state, ((x+20)*4),0,0,100+x);
@ -211,6 +227,8 @@ int main(int argc,char **argv)
/* Set the white color */
vmwLoadPalette(game_state->graph_state,0xff,0xff,0xff,15);
vmwFlushPalette(game_state->graph_state);
/* Actually draw the stylized VMW */
for(x=0;x<=40;x++){
vmwDrawVLine(x+40,45,2*x,100+x,virtual_1);
@ -230,14 +248,16 @@ int main(int argc,char **argv)
vmwTextXY("A VMW SOFTWARE PRODUCTION",60,140,
15,15,0,tb1_font,virtual_1);
if (game_state->sound_enabled) playSound();
if ((game_state->sound_possible) && (game_state->music_enabled))
playSound();
vmwBlitMemToDisplay(game_state->graph_state,virtual_1);
pauseawhile(5);
stopSound();
loadSound(tb1_data_file("music/weave1.mod",game_state->path_to_data));
if (game_state->sound_possible) {
stopSound();
loadSound(tb1_data_file("music/weave1.mod",game_state->path_to_data));
}
/* Clear the Screen and get ready for the Menu */
vmwClearScreen(virtual_1,0);
@ -271,7 +291,8 @@ int main(int argc,char **argv)
}
vmwFlipVirtual(virtual_1,virtual_3,320,200);
if (game_state->sound_enabled) playSound();
if ((game_state->sound_possible) &&(game_state->music_enabled))
playSound();
vmwBlitMemToDisplay(game_state->graph_state,virtual_1);
while (!vmwGetInput()) usleep(300);
@ -309,7 +330,7 @@ int main(int argc,char **argv)
usleep(10);
gettimeofday(&time_info,&dontcare);
if (time_info.tv_sec-time_sec>40) {
stopSound();
if (game_state->sound_possible) stopSound();
credits(game_state);
ch=VMW_ENTER;
barpos=9;
@ -337,7 +358,7 @@ int main(int argc,char **argv)
if(barpos==7) barpos=0;
if(barpos<0) barpos=6;
}
stopSound();
if (game_state->sound_possible) stopSound();
/* Run whatever it was that the person pressed */
switch (barpos) {

View File

@ -9,6 +9,7 @@ typedef struct {
vmwVisual *virtual_2; /* 320x400x8 */
vmwVisual *virtual_3; /* 320x200x8 */
vmwSVMWGraphState *graph_state; /* Graphics state */
int sound_possible; /* Sound even possible? */
int sound_enabled; /* Sound on or off */
int music_enabled; /* Music on or off */
int sound_volume; /* Sound volume */