Version 2.9.6

This commit is contained in:
Vince Weaver 2000-09-22 00:38:00 -04:00
parent 486148bc84
commit e5d1aad604
14 changed files with 280 additions and 154 deletions

19
TB1.FAQ
View File

@ -7,7 +7,7 @@ A1). Tom Bombem runs by default in a 320x200x16bpp display. It may
not work if you have an 8, 24, or 32bpp display. This can
be fixed, it just hasn't yet.
Q2.) Why is the picture 320x200 anyway?
Q2.) Why is the default resolution 320x200 anyway?
A2). Tom Bombem is internally rendered at 320x200 and 256colors.
This is because the original game was for dos VGA Bios mode
@ -33,3 +33,20 @@ A3). No. A long time ago I made my own graphics program. I called it
the internet and the GPL.
See http://..... for more info.
Q4). The music for TB1 is (great/awful). (Are you/You call yourself)
a musician?
A4). No. I just play around with MOD trackers sometimes. The results
aren't always pretty.
Q5). Can I get TB1 for Windows(tm)?
A5). You can get the old DOS version off my website, it will run on
win31/win95/win98. I don't know about NT.
In theory, since it is in standard C and SDL, this program
can be compiled on a windows machine. I don't have nor want
a windows box to try this on. If someone does happen to
compile up a version, let me know.

View File

@ -21,9 +21,10 @@ void about(tb1_state *game_state)
vmwClearScreen(target1,0);
vmwLoadPicPacked(0,0,target2,1,1,
tb1_data_file("./about/register.tb1",game_state->path_to_data));
vmwLoadPicPacked(0,0,target1,1,0, /* Load Palette */
tb1_data_file("./about/register.tb1",game_state->path_to_data));
tb1_data_file("./about/register.tb1",game_state->path_to_data),
game_state->graph_state);
// vmwLoadPicPacked(0,0,target1,1,0, /* Load Palette */
// tb1_data_file("./about/register.tb1",game_state->path_to_data));
while ((ch!=VMW_ESCAPE)&&(ch!='q')){
while(( (ch=vmwGetInput())==0) && (firstime));

View File

@ -113,7 +113,8 @@ void credits(tb1_state *game_state)
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));
tb1_data_file("tbomb1.tb1",game_state->path_to_data),
game_state->graph_state);
if (keypressed) {
vmwDrawBox(0,0,320,200,0,game_state->virtual_2);

View File

@ -78,8 +78,9 @@ void beforeboss(tb1_state *game_state)
{
vmwClearKeyboardBuffer();
vmwLoadPicPacked(0,0,game_state->virtual_3,0,1,
tb1_data_file("level1/viewscr.tb1",game_state->path_to_data));
vmwLoadPicPacked(0,0,game_state->virtual_3,1,1,
tb1_data_file("level1/viewscr.tb1",game_state->path_to_data),
game_state->graph_state);
vmwClearScreen(game_state->virtual_1,0);
vmwArbitraryCrossBlit(game_state->virtual_3,0,5,58,37,
game_state->virtual_1,10,10);
@ -129,8 +130,9 @@ void afterboss(tb1_state *game_state)
tb1_font=game_state->graph_state->default_font;
vmwLoadPicPacked(0,0,game_state->virtual_3,0,1,
tb1_data_file("level1/viewscr.tb1",game_state->path_to_data));
vmwLoadPicPacked(0,0,game_state->virtual_3,1,1,
tb1_data_file("level1/viewscr.tb1",game_state->path_to_data),
game_state->graph_state);
vmwDrawBox(0,0,320,200,0,game_state->virtual_1);
vmwArbitraryCrossBlit(game_state->virtual_3,0,42,58,37,
game_state->virtual_1,10,10);
@ -362,14 +364,16 @@ void levelone(tb1_state *game_state) {
/* Load Sprites */
grapherror=vmwLoadPicPacked(0,0,virtual_1,1,1,
tb1_data_file("level1/ships.tb1",game_state->path_to_data));
tb1_data_file("level1/ships.tb1",game_state->path_to_data),
game_state->graph_state);
bigship1=vmwGetSprite(0,0,48,30,virtual_1);
bigship2=vmwGetSprite(0,32,48,30,virtual_1);
bigship3=vmwGetSprite(0,64,48,30,virtual_1);
grapherror=vmwLoadPicPacked(0,0,virtual_1,1,1,
tb1_data_file("level1/tbshapes.tb1",game_state->path_to_data));
grapherror=vmwLoadPicPacked(0,0,virtual_1,0,1,
tb1_data_file("level1/tbshapes.tb1",game_state->path_to_data),
game_state->graph_state);
for(j=0;j<2;j++)
for(i=0;i<10;i++)
@ -641,9 +645,10 @@ void littleopener(tb1_state *game_state)
vmwClearScreen(game_state->virtual_2,0);
vmwLoadPicPacked(0,0,game_state->virtual_2,1,1,
tb1_data_file("level1/moon2.tb1",game_state->path_to_data));
vmwLoadPicPacked(0,0,game_state->virtual_1,1,0, /* Load palette */
tb1_data_file("level1/moon2.tb1",game_state->path_to_data));
tb1_data_file("level1/moon2.tb1",game_state->path_to_data),
game_state->graph_state);
// vmwLoadPicPacked(0,0,game_state->virtual_1,1,0, /* Load palette */
// tb1_data_file("level1/moon2.tb1",game_state->path_to_data));
ship1=vmwGetSprite(9,178,15,18,game_state->virtual_2);
ship2=vmwGetSprite(30,178,15,18,game_state->virtual_2);
@ -679,6 +684,7 @@ void littleopener(tb1_state *game_state)
vmwDrawBox(0,0,320,200,0,game_state->virtual_1);
vmwLoadPicPacked(0,0,game_state->virtual_1,1,0, /* Restore Palette */
tb1_data_file("tbomb1.tb1",game_state->path_to_data));
tb1_data_file("tbomb1.tb1",game_state->path_to_data),
game_state->graph_state);
}

View File

@ -96,7 +96,8 @@ void leveltwoengine(tb1_state *game_state)
/* Load Sprites */
grapherror=vmwLoadPicPacked(0,0,virtual_1,1,1,
tb1_data_file("level1/ships.tb1",
game_state->path_to_data));
game_state->path_to_data),
game_state->graph_state);
ship_shape[0]=vmwGetSprite(0,0,48,30,virtual_1);
ship_shape[1]=vmwGetSprite(0,32,48,30,virtual_1);
@ -104,9 +105,11 @@ void leveltwoengine(tb1_state *game_state)
if (game_state->level==2) vmwLoadPicPacked(0,0,virtual_1,1,1,
tb1_data_file("level2/tbaship.tb1",game_state->path_to_data));
tb1_data_file("level2/tbaship.tb1",game_state->path_to_data),
game_state->graph_state);
if (game_state->level==4) vmwLoadPicPacked(0,0,virtual_1,1,1,
tb1_data_file("level4/tbeerm.tb1",game_state->path_to_data));
tb1_data_file("level4/tbeerm.tb1",game_state->path_to_data),
game_state->graph_state);
for(j=0;j<4;j++)
for(i=0;i<10;i++)
@ -567,7 +570,8 @@ void littleopener2(tb1_state *game_state) {
vmwDrawBox(0,0,319,199,0,game_state->virtual_1);
vmwLoadPicPacked(0,0,game_state->virtual_1,1,1,
tb1_data_file("level2/tbl2ship.tb1",game_state->path_to_data));
tb1_data_file("level2/tbl2ship.tb1",game_state->path_to_data),
game_state->graph_state);
vmwTextXY("Hmmmm... ",10,10,4,0,0,game_state->graph_state->default_font,
game_state->virtual_1);
vmwTextXY("This Might Be Harder Than I Thought.",10,20,4,0,0,

View File

@ -15,7 +15,8 @@ int change_shields(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;
// game_state->virtual_1->palette[254]=(game_state->shields)*0x1000;
vmwLoadPalette(game_state->graph_state,game_state->shields*16,0,0,254);
vmwDrawBox(250,71,64,8,0,game_state->virtual_1);
for(itemp=0;itemp<(game_state->shields)*4;itemp+=4)

37
story.c
View File

@ -55,7 +55,8 @@ void story(tb1_state *game_state)
vmwLoadPicPacked(0,0,game_state->virtual_2,1,1,
tb1_data_file("story/tbsobj.tb1",game_state->path_to_data));
tb1_data_file("story/tbsobj.tb1",game_state->path_to_data),
game_state->graph_state);
/* Load up the sprites! */
bigFlame1=vmwGetSprite(0,2,26,18,game_state->virtual_2);
@ -80,7 +81,8 @@ void story(tb1_state *game_state)
vmwClearScreen(game_state->virtual_1,0);
vmwLoadPicPacked(0,0,game_state->virtual_2,1,1,
tb1_data_file("story/tbcobj.tb1",game_state->path_to_data));
tb1_data_file("story/tbcobj.tb1",game_state->path_to_data),
game_state->graph_state);
vmwArbitraryCrossBlit(game_state->virtual_2,129,56,49,132,
game_state->virtual_1,10,10);
@ -121,7 +123,8 @@ void story(tb1_state *game_state)
pauseawhile(12);
vmwLoadPicPacked(0,0,game_state->virtual_1,1,1,
tb1_data_file("story/tbchief.tb1",game_state->path_to_data));
tb1_data_file("story/tbchief.tb1",game_state->path_to_data),
game_state->graph_state);
/* Save the area where the error will go */
vmwArbitraryCrossBlit(game_state->virtual_1,115,55,91,59,
@ -168,7 +171,8 @@ void story(tb1_state *game_state)
vmwClearScreen(game_state->virtual_2,0);
vmwLoadPicPacked(0,0,game_state->virtual_2,1,1,
tb1_data_file("story/tbma1.tb1",game_state->path_to_data));
tb1_data_file("story/tbma1.tb1",game_state->path_to_data),
game_state->graph_state);
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);
@ -240,7 +244,7 @@ void story(tb1_state *game_state)
0,319,0,199);
}
usleep(50000);
game_state->virtual_1->palette[250]=thrustcol*0x1000;
vmwLoadPalette(game_state->graph_state,thrustcol*4,0,0,250);
ytemp=ytemp-(int)thrust;
vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1);
}
@ -251,9 +255,11 @@ void story(tb1_state *game_state)
/****SECOND CHIEF*******/
vmwLoadPicPacked(0,0,game_state->virtual_2,1,1,
tb1_data_file("story/tbcobj.tb1",game_state->path_to_data));
tb1_data_file("story/tbcobj.tb1",game_state->path_to_data),
game_state->graph_state);
vmwLoadPicPacked(0,0,game_state->virtual_1,1,1,
tb1_data_file("story/tbchief.tb1",game_state->path_to_data));
tb1_data_file("story/tbchief.tb1",game_state->path_to_data),
game_state->graph_state);
vmwArbitraryCrossBlit(game_state->virtual_2,7,104,90,21,
game_state->virtual_1,6,174);
vmwTextXY("You might wonder why this is important.",
@ -284,10 +290,10 @@ void story(tb1_state *game_state)
// game_state->path_to_data));
vmwLoadPicPacked(0,0,game_state->virtual_1,1,1,
tb1_data_file("story/tbcrash.tb1",
game_state->path_to_data));
game_state->path_to_data),game_state->graph_state);
vmwLoadPicPacked(0,0,game_state->virtual_1,1,0,
tb1_data_file("tbomb1.tb1",
game_state->path_to_data));
game_state->path_to_data),game_state->graph_state);
vmwFlipVirtual(game_state->virtual_2,game_state->virtual_1,320,200);
@ -308,10 +314,10 @@ void story(tb1_state *game_state)
}
vmwArbitraryCrossBlit(game_state->virtual_2,xtemp,ytemp,30,30,
game_state->virtual_1,xtemp,ytemp);
game_state->virtual_1->palette[0]=0xffffff;
vmwLoadPalette(game_state->graph_state,0xff,0xff,0xff,0);
vmwPutSprite(explosion1,160,118,game_state->virtual_1);
vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1);
game_state->virtual_1->palette[0]=0;
vmwLoadPalette(game_state->graph_state,0,0,0,0);
usleep(80000);
vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1);
@ -341,7 +347,8 @@ void story(tb1_state *game_state)
/****ALIEN MESSAGE*****/
vmwLoadPicPacked(0,0,game_state->virtual_1,1,1,
tb1_data_file("story/tbgorg.tb1",game_state->path_to_data));
tb1_data_file("story/tbgorg.tb1",game_state->path_to_data),
game_state->graph_state);
vmwTextXY("GREETINGS EARTHLINGS.",0,162,12,0,0,tb1_font,game_state->virtual_1);
vmwTextXY("I AM GORGONZOLA THE REPULSIVE.",0,171,12,0,0,tb1_font,game_state->virtual_1);
vmwTextXY("YOU HAVE MADE A BIG MISTAKE.",0,180,12,0,0,tb1_font,game_state->virtual_1);
@ -362,9 +369,11 @@ void story(tb1_state *game_state)
/****** THIRD CHIEF *******/
vmwLoadPicPacked(0,0,game_state->virtual_2,1,1,
tb1_data_file("story/tbcobj.tb1",game_state->path_to_data));
tb1_data_file("story/tbcobj.tb1",game_state->path_to_data),
game_state->graph_state);
vmwLoadPicPacked(0,0,game_state->virtual_1,1,1,
tb1_data_file("story/tbchief.tb1",game_state->path_to_data));
tb1_data_file("story/tbchief.tb1",game_state->path_to_data),
game_state->graph_state);
vmwArbitraryCrossBlit(game_state->virtual_2,7,127,90,21,
game_state->virtual_1,6,174);

View File

@ -4,18 +4,26 @@
#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 */
void *SDL_setupGraphics(int xsize,int ysize,int bpp,int scale,
/* Pass '0' to auto-detect bpp */
void *SDL_setupGraphics(int *xsize,int *ysize,int *bpp,
int fullscreen,int verbose)
{
SDL_Surface *sdl_screen;
int mode;
SDL_Surface *sdl_screen=NULL;
int mode,i=0;
mode=SDL_SWSURFACE;
if (fullscreen) mode|=SDL_FULLSCREEN;
/* Initialize the SDL library */
if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
fprintf(stderr,
@ -26,25 +34,56 @@ void *SDL_setupGraphics(int xsize,int ysize,int bpp,int scale,
/* Clean up on exit */
atexit(SDL_Quit);
/* Initialize the display */
sdl_screen = SDL_SetVideoMode(xsize, ysize, 16, mode);
if ( sdl_screen == NULL ) {
fprintf(stderr, "Couldn't set %dx%dx%d video mode: %s\n",
xsize*scale,ysize*scale,bpp,SDL_GetError());
exit(1);
if (*bpp!=0) {
/* Initialize the display */
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);
}
}
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 (verbose) {
printf(" + SDL Graphics Initialization successful...\n");
printf(" + Using %dx%dx%dbpp Visual...\n",xsize,ysize,bpp);
printf(" + Using %dx%dx%dbpp Visual...\n",*xsize,*ysize,*bpp);
}
return sdl_screen;
}
void SDL_WritePaletteColor(vmwSVMWGraphState *state,
unsigned char r,
unsigned char g,
unsigned char b,
int color) {
SDL_Surface *target;
SDL_Color temp_col;
temp_col.r=r;
temp_col.g=g;
temp_col.b=b;
target=(SDL_Surface *)state->output_screen;
SDL_SetColors(target,&temp_col,color,1);
}
void SDL_NoScale16bpp_BlitMem(vmwSVMWGraphState *target_p, vmwVisual *source) {
int x,y,Bpp;
int x,y;
unsigned char *s_pointer,*t_pointer;
@ -57,8 +96,6 @@ void SDL_NoScale16bpp_BlitMem(vmwSVMWGraphState *target_p, vmwVisual *source) {
return;
}
Bpp=target->format->BytesPerPixel;
s_pointer=source->memory;
t_pointer=((Uint8 *)target->pixels);
@ -66,7 +103,7 @@ void SDL_NoScale16bpp_BlitMem(vmwSVMWGraphState *target_p, vmwVisual *source) {
for (x=0;x<source->xsize;x++)
for (y=0;y<source->ysize;y++) {
*((Uint16 *)(t_pointer))=source->palette[*(s_pointer)];
*((Uint16 *)(t_pointer))=target_p->palette[*(s_pointer)];
s_pointer++; t_pointer+=2;
}
@ -84,7 +121,7 @@ void SDL_NoScale16bpp_BlitMem(vmwSVMWGraphState *target_p, vmwVisual *source) {
/* I should make this generic, but it makes it really slow */
void SDL_Double16bpp_BlitMem(vmwSVMWGraphState *target_p, vmwVisual *source) {
int x,y,Bpp,scale;
int x,y,scale;
unsigned char *s_pointer,*t_pointer;
@ -99,8 +136,6 @@ void SDL_Double16bpp_BlitMem(vmwSVMWGraphState *target_p, vmwVisual *source) {
return;
}
Bpp=target->format->BytesPerPixel;
s_pointer=source->memory;
t_pointer=((Uint8 *)target->pixels);
@ -109,18 +144,18 @@ void SDL_Double16bpp_BlitMem(vmwSVMWGraphState *target_p, vmwVisual *source) {
/* i=0, j=0 */
*((Uint16 *) ( (t_pointer)))=
source->palette[*(s_pointer)];
target_p->palette[*(s_pointer)];
/* i=1, j=0 */
*((Uint16 *) ( (t_pointer+(2*target_p->xsize) )))=
source->palette[*(s_pointer)];
target_p->palette[*(s_pointer)];
/* i=0, j=1 */
*((Uint16 *) ( (t_pointer+2) ))=
source->palette[*(s_pointer)];
target_p->palette[*(s_pointer)];
/* i=1 j=1 */
*((Uint16 *) ( (t_pointer+2+(2*target_p->xsize) )))=
source->palette[*(s_pointer)];
target_p->palette[*(s_pointer)];
s_pointer++; t_pointer+=4;
@ -139,6 +174,41 @@ void SDL_Double16bpp_BlitMem(vmwSVMWGraphState *target_p, vmwVisual *source) {
}
void SDL_NoScale8bpp_BlitMem(vmwSVMWGraphState *target_p, vmwVisual *source) {
int x,y;
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;
}
s_pointer=source->memory;
t_pointer=((Uint8 *)target->pixels);
for (x=0;x<source->xsize;x++)
for (y=0;y<source->ysize;y++) {
*((Uint8 *)(t_pointer))=*(s_pointer);
s_pointer++; t_pointer++;
}
/* Update the display */
if ( SDL_MUSTLOCK(target) ) {
SDL_UnlockSurface(target);
}
/* Write this out to the screen */
SDL_UpdateRect(target, 0, 0, source->xsize, source->ysize);
}
void SDL_clearKeyboardBuffer() {
SDL_Event event;

View File

@ -2,9 +2,12 @@
#include <SDL.h>
void *SDL_setupGraphics(int xsize,int ysize,int bpp,int scale,int fullscreen,
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_NoScale16bpp_BlitMem(vmwSVMWGraphState *target, vmwVisual *source);
void SDL_Double16bpp_BlitMem(vmwSVMWGraphState *target_p, vmwVisual *source);
void SDL_NoScale8bpp_BlitMem(vmwSVMWGraphState *target, vmwVisual *source);
void SDL_clearKeyboardBuffer();
int SDL_getInput();

View File

@ -7,8 +7,6 @@ typedef struct {
int xsize;
int ysize;
unsigned char *memory;
int *palette;
int palette_size;
} vmwVisual;
typedef struct {
@ -30,6 +28,8 @@ typedef struct {
int ysize;
int bpp;
int scale;
int *palette;
int palette_size;
void *output_screen;
vmwFont *default_font;
} vmwSVMWGraphState;
@ -93,30 +93,33 @@ void vmwSmallTextXY(char *st,int x,int y,int col,int background,int overwrite,
/* From vmw_paintpro.c */
int vmwLoadPicPacked(int x1,int y1,vmwVisual *target,
int LoadPal,int LoadPic,char *FileName);
int LoadPal,int LoadPic,char *FileName,
vmwSVMWGraphState *graph_state);
int vmwSavePicPacked(int x1,int y1,int xsize,int ysize,
vmwVisual *source,char *FileName);
/* From vmw_palette.c */
int vmwPack3Bytes(int r, int g, int b);
void vmwLoadCustomPalette(vmwVisual *source, int pal[256]);
void vmwLoadPalette(vmwSVMWGraphState *state,unsigned char r,
unsigned char g,unsigned char b,int color);
void vmwFadeToBlack(vmwVisual *source);
void vmwUnFade(vmwVisual *source);
/* From vmw_setup.c */
extern void *(*vmwSetupGraphics)(int xsize,int ysize, int bpp, int scale,
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 (*vmwClearKeyboardBuffer)(void);
extern int (*vmwGetInput)(void);
vmwSVMWGraphState *vmwSetupSVMWGraph(int display_type,int xsize,int ysize,
int bpp,int scale,int fullscreen,
int verbose);
vmwVisual *vmwSetupVisual(int xsize,int ysize,int palette_size);
vmwVisual *vmwSetupVisual(int xsize,int ysize);
/* From vmw_sprite.c */

View File

@ -12,7 +12,8 @@
\*---------------------------------------------------------------*/
int vmwLoadPicPacked(int x1,int y1,vmwVisual *target,
int LoadPal,int LoadPic,char *FileName)
int LoadPal,int LoadPic,char *FileName,
vmwSVMWGraphState *graph_state)
/* Retro comments */
/*{ Loads a paintpro image, filename, at location x1,y1 *\
@ -33,7 +34,6 @@ int vmwLoadPicPacked(int x1,int y1,vmwVisual *target,
int ysize;
int numcolors;
int col,numacross;
int temp_palette[256];
/* Open the file */
fff=fopen(FileName,"rb"); /* Windows chokes if no "b" */
@ -98,9 +98,11 @@ int vmwLoadPicPacked(int x1,int y1,vmwVisual *target,
/* 565 packed 16bit RGB */
for(i=0;i<256;i++) {
temp_palette[i]= vmwPack3Bytes(buffer[buffpointer],
buffer[buffpointer+1],
buffer[buffpointer+2]);
if (LoadPal)
vmwLoadPalette(graph_state,
buffer[buffpointer],
buffer[buffpointer+1],
buffer[buffpointer+2],i);
buffpointer+=3;
if (buffpointer>=errorlev) {
if (errorlev==300) {
@ -112,12 +114,7 @@ int vmwLoadPicPacked(int x1,int y1,vmwVisual *target,
}
}
}
if (LoadPal) {
for (i=0;i<256;i++) target->palette[i]=temp_palette[i];
}
x=x1;
y=y1;

View File

@ -2,21 +2,23 @@
#include "svmwgraph.h"
/* The "packing" method used by the 16 bit palette */
int vmwPack3Bytes(int r, int g, int b) {
void vmwLoadPalette(vmwSVMWGraphState *state,unsigned char r,
unsigned char g,
unsigned char b,int color) {
if (state->bpp==8) {
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++) {
source->palette[i]=pal[i];
}
if (state->bpp==16) {
/* 565 color cube */
/* which can be LESS colorful than 8bpp. Imagine that */
state->palette[color]= ( ((int)(r>>3)) <<11)+
( ((int)(g>>2)) <<5)+
(b>>3);
}
vmwWritePaletteColor(state,r,g,b,color);
}

View File

@ -6,9 +6,12 @@
#include <stdio.h> /* For printf */
#include <stdlib.h> /* For Memory Allocation */
void *(*vmwSetupGraphics)(int xsize,int ysize, int bpp,
int scale, int fullscreen,int verbose);
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 (*vmwClearKeyboardBuffer)(void);
int (*vmwGetInput)(void);
@ -16,40 +19,65 @@ vmwSVMWGraphState *vmwSetupSVMWGraph(int display_type,int xsize,int ysize,
int bpp,int scale,int fullscreen,
int verbose) {
vmwSVMWGraphState *temp_state;
vmwSVMWGraphState *temp_state;
if ( (temp_state=calloc(1,sizeof(vmwSVMWGraphState)) )==NULL) {
printf("Error allocating memory!\n");
return NULL;
}
if ( (temp_state=calloc(1,sizeof(vmwSVMWGraphState)) )==NULL) {
printf("Error allocating memory!\n");
return NULL;
}
/* Setup Setup routines */
switch (display_type) {
case VMW_SDLTARGET: vmwSetupGraphics=SDL_setupGraphics;
break;
default: printf("ERROR! Unknown Display Target %i.\n",display_type);
return NULL;
}
switch (display_type) {
case VMW_SDLTARGET: vmwSetupGraphics=SDL_setupGraphics;
if (scale==1)
vmwBlitMemToDisplay=SDL_NoScale16bpp_BlitMem;
else
vmwBlitMemToDisplay=SDL_Double16bpp_BlitMem;
vmwClearKeyboardBuffer=SDL_clearKeyboardBuffer;
vmwGetInput=SDL_getInput;
temp_state->output_screen=
vmwSetupGraphics(xsize,ysize,bpp,scale,
fullscreen,verbose);
break;
temp_state->bpp=bpp;
temp_state->xsize=xsize;
temp_state->ysize=ysize;
temp_state->scale=scale;
temp_state->default_font=NULL;
temp_state->palette_size=256;
if ( (temp_state->palette=calloc(temp_state->palette_size,sizeof(int)) )==NULL) {
printf("Error allocating palette of size %i!\n",temp_state->palette_size);
return NULL;
}
/* Attempt to get desired graphics state */
temp_state->output_screen=vmwSetupGraphics(&temp_state->xsize,
&temp_state->ysize,
&temp_state->bpp,
fullscreen,verbose);
/* Setup proper blitter and others*/
switch (display_type) {
case VMW_SDLTARGET:
if (temp_state->bpp==8) {
vmwBlitMemToDisplay=SDL_NoScale8bpp_BlitMem;
}
if (temp_state->bpp>=16) {
if (scale==1) {
vmwBlitMemToDisplay=SDL_NoScale16bpp_BlitMem;
} else {
vmwBlitMemToDisplay=SDL_Double16bpp_BlitMem;
}
}
vmwWritePaletteColor=SDL_WritePaletteColor;
vmwClearKeyboardBuffer=SDL_clearKeyboardBuffer;
vmwGetInput=SDL_getInput;
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->scale=scale;
temp_state->default_font=NULL;
return temp_state;
}
vmwVisual *vmwSetupVisual(int xsize,int ysize,int palette_size) {
vmwVisual *vmwSetupVisual(int xsize,int ysize) {
vmwVisual *temp_visual;
@ -59,18 +87,12 @@ vmwVisual *vmwSetupVisual(int xsize,int ysize,int palette_size) {
}
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;
}

52
tb1.c
View File

@ -54,7 +54,6 @@ int command_line_help(int show_version,char *runas)
int main(int argc,char **argv)
{
int i,grapherror,reloadpic=0;
int custom_palette[256];
int ch,x,barpos,time_sec;
int scale=1,fullscreen=0;
FILE *fff;
@ -166,38 +165,28 @@ int main(int argc,char **argv)
/* Setup Graphics */
if (scale==1) {
if ( (game_state->graph_state=vmwSetupSVMWGraph(VMW_SDLTARGET,
320,200,
16,scale,fullscreen,1))==NULL) {
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,
16,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=
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) {
if ((game_state->virtual_1=vmwSetupVisual(320,200))==NULL) {
fprintf(stderr,"ERROR: Couldn't get RAM for virtual screen 1!\n");
return VMW_ERROR_MEM;
}
if ((game_state->virtual_2=vmwSetupVisual(320,400,256))==NULL) {
if ((game_state->virtual_2=vmwSetupVisual(320,400))==NULL) {
fprintf(stderr,"ERROR: Couldn't get RAM for virtual screen 2!\n");
return VMW_ERROR_MEM;
}
if ((game_state->virtual_3=vmwSetupVisual(320,200,256))==NULL) {
if ((game_state->virtual_3=vmwSetupVisual(320,200))==NULL) {
fprintf(stderr,"ERROR: Couldn't get RAM for virtual screen 3!\n");
return VMW_ERROR_MEM;
}
@ -210,20 +199,17 @@ int main(int argc,char **argv)
virtual_3=game_state->virtual_3;
tb1_font=game_state->graph_state->default_font;
for (x=0;x<256;x++) custom_palette[x]=vmwPack3Bytes(0,0,0); /* 0=black */
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++) {
custom_palette[100+x]=vmwPack3Bytes( ((x+20)*4),0,0);
custom_palette[141+x]=vmwPack3Bytes(0,0, ( (x+20)*4 ));
custom_palette[182+x]=vmwPack3Bytes(0, ( (x+20)*4),0);
vmwLoadPalette(game_state->graph_state, ((x+20)*4),0,0,100+x);
vmwLoadPalette(game_state->graph_state,0,0, ( (x+20)*4 ),141+x);
vmwLoadPalette(game_state->graph_state,0, ( (x+20)*4),0,182+x);
}
/* Set the white color */
custom_palette[15]=vmwPack3Bytes(0xff,0xff,0xff);
/* Finalize Pallette Stuff */
vmwLoadCustomPalette(virtual_1,custom_palette);
vmwLoadPalette(game_state->graph_state,0xff,0xff,0xff,15);
/* Actually draw the stylized VMW */
for(x=0;x<=40;x++){
@ -257,15 +243,18 @@ int main(int argc,char **argv)
vmwClearScreen(virtual_1,0);
/* Load the title screen */
/* this is a bit of overkill. vmwflip() ? */
grapherror=vmwLoadPicPacked(0,0,virtual_1,1,1,
tb1_data_file("tbomb1.tb1",game_state->path_to_data));
tb1_data_file("tbomb1.tb1",game_state->path_to_data),
game_state->graph_state);
/* Set up palettes */
grapherror=vmwLoadPicPacked(0,0,virtual_2,1,1,
tb1_data_file("tbomb1.tb1",game_state->path_to_data));
tb1_data_file("tbomb1.tb1",game_state->path_to_data),
game_state->graph_state);
grapherror=vmwLoadPicPacked(0,0,game_state->virtual_3,1,1,
tb1_data_file("tbomb1.tb1",game_state->path_to_data));
tb1_data_file("tbomb1.tb1",game_state->path_to_data),
game_state->graph_state);
vmwBlitMemToDisplay(game_state->graph_state,virtual_1);
@ -273,9 +262,10 @@ int main(int argc,char **argv)
while (1) {
if (reloadpic) {
grapherror=vmwLoadPicPacked(0,0,virtual_3,1,1,
tb1_data_file("tbomb1.tb1",game_state->path_to_data));
grapherror=vmwLoadPicPacked(0,0,virtual_1,1,0,
tb1_data_file("tbomb1.tb1",game_state->path_to_data));
tb1_data_file("tbomb1.tb1",game_state->path_to_data),
game_state->graph_state);
// grapherror=vmwLoadPicPacked(0,0,virtual_1,1,0,
// tb1_data_file("tbomb1.tb1",game_state->path_to_data));
reloadpic=0;
}