From b8225aed5d2d620405134073ae204d36a58c518f Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Fri, 27 Oct 2000 22:09:00 -0400 Subject: [PATCH] v.2.9.11 --- CHANGES | 23 +++ Makefile | 47 +++--- Makefile.inc | 55 +++++++ README | 10 +- TB1.FAQ | 7 + TODO | 4 + data/hiscore.tb1 | 8 +- graphic_tools.c | 2 +- hiscore.c | 15 +- level_2.c | 2 +- level_3.c | 230 +++++++++++++++-------------- options.c | 4 +- sound.c | 31 +++- sound.h | 3 - svmwgraph/Makefile | 37 ++--- svmwgraph/curses_svmwgraph.c | 9 +- svmwgraph/null_svmwgraph.c | 3 +- svmwgraph/opengl_svmwgraph.c | 129 ++++++++++++++++ svmwgraph/opengl_svmwgraph.h | 7 + svmwgraph/sdl_svmwgraph.h | 2 - svmwgraph/svmwgraph.h | 1 + svmwgraph/vmw_core.c | 89 ++++++----- svmwgraph/vmw_setup.c | 33 ++++- svmwgraph/vmw_sprite.c | 246 ++++++++++++++++++++++++------- tb1-2.9.10.lsm => tb1-2.9.11.lsm | 6 +- tb1.c | 9 +- tools/Makefile | 14 +- tools/benchmark.c | 85 +++++++++++ tools/benchmark_blit | 23 +++ tools/pcx2ppp.c | 2 +- tools/ppro_view.c | 17 ++- 31 files changed, 854 insertions(+), 299 deletions(-) create mode 100644 Makefile.inc create mode 100644 svmwgraph/opengl_svmwgraph.c create mode 100644 svmwgraph/opengl_svmwgraph.h rename tb1-2.9.10.lsm => tb1-2.9.11.lsm (84%) create mode 100644 tools/benchmark.c create mode 100644 tools/benchmark_blit diff --git a/CHANGES b/CHANGES index 023ddd2..867579a 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,26 @@ +27 October 2000 ++ Started writing an opengl target. Was hoping for a cool tb1 rotating + on the side of a cube type deal. Had some fights with glut and decided + to put that off for a while. ++ Modularized the makefiles. Now just edit Makefile.inc.... and you + can compile without SDL_mixer/curses/SDL, etc... though you sacrifice + functionality ++ TB1 works over an ssh connection in curses [BSD-Curses] on a VT102 terminal + on a Solaris Ultrasparc machine! I can even get to level2! + + +19 October 2000 ++ Fixed some other minor bugs. ++ Added "vmwLine" to svmwgraph. Really it's just a port of the PCGPE line + routine. I should write one of my own. + +18 October 2000 ++ No e-mails from freshmeat submission, so I suppose that means all is well. ++ Fixed bug where ppro_view only ran in curses mode ++ Fixed bug where double/fullscreen were reversed on options menu ++ Fixed bug where "to be continued" displayed improperly. ++ Fix bug in handling of spaces in names in high score list + 16 October 2000 + Finished options menu. + Fix up documentation, hopefully do a freshmeat release. diff --git a/Makefile b/Makefile index e89ac8e..490906d 100644 --- a/Makefile +++ b/Makefile @@ -1,64 +1,67 @@ +include Makefile.inc - -INCLUDE= -O2 -Wall -I/usr/local/include/SDL -I/usr/local/include -LIBS= -lSDL -lSDL_mixer -L/usr/X11R6/lib -lX11 -lpthread -lncurses +INCLUDE= $(INCLUDE_GLOBAL) +LIBS= $(LIBS_GLOBAL) all: tb1 -tb1: tb1.o ./svmwgraph/libsvmwgraph.a about.o credits.o graphic_tools.o help.o hiscore.o level_1.o level_2.o loadsave.o options.o playgame.o quit.o sidebar.o sound.o story.o tblib.o - gcc -o tb1 tb1.o about.o credits.o graphic_tools.o help.o hiscore.o level_1.o level_2.o loadsave.o options.o playgame.o quit.o sidebar.o sound.o story.o tblib.o ./svmwgraph/libsvmwgraph.a $(LIBS) +tb1: tb1.o ./svmwgraph/libsvmwgraph.a about.o credits.o graphic_tools.o help.o hiscore.o level_1.o level_2.o level_3.o loadsave.o options.o playgame.o quit.o sidebar.o sound.o story.o tblib.o + $(CC) -o tb1 tb1.o about.o credits.o graphic_tools.o help.o hiscore.o level_1.o level_2.o level_3.o loadsave.o options.o playgame.o quit.o sidebar.o sound.o story.o tblib.o ./svmwgraph/libsvmwgraph.a $(LIBS) ./svmwgraph/libsvmwgraph.a: cd svmwgraph && make tb1.o: tb1.c - gcc -c tb1.c $(INCLUDE) + $(CC) -c tb1.c $(INCLUDE) about.o: about.c - gcc -c about.c $(INCLUDE) + $(CC) -c about.c $(INCLUDE) credits.o: credits.c - gcc -c credits.c $(INCLUDE) + $(CC) -c credits.c $(INCLUDE) graphic_tools.o: graphic_tools.c - gcc -c graphic_tools.c $(INCLUDE) + $(CC) -c graphic_tools.c $(INCLUDE) help.o: help.c - gcc -c help.c $(INCLUDE) + $(CC) -c help.c $(INCLUDE) hiscore.o: hiscore.c - gcc -c hiscore.c $(INCLUDE) + $(CC) -c hiscore.c $(INCLUDE) level_1.o: level_1.c - gcc -c level_1.c $(INCLUDE) + $(CC) -c level_1.c $(INCLUDE) level_2.o: level_2.c - gcc -c level_2.c $(INCLUDE) + $(CC) -c level_2.c $(INCLUDE) + +level_3.o: level_3.c + $(CC) -c level_3.c $(INCLUDE) loadsave.o: loadsave.c - gcc -c loadsave.c $(INCLUDE) + $(CC) -c loadsave.c $(INCLUDE) options.o: options.c - gcc -c options.c $(INCLUDE) + $(CC) -c options.c $(INCLUDE) playgame.o: playgame.c - gcc -c playgame.c $(INCLUDE) + $(CC) -c playgame.c $(INCLUDE) quit.o: quit.c - gcc -c quit.c $(INCLUDE) + $(CC) -c quit.c $(INCLUDE) sidebar.o: sidebar.c - gcc -c sidebar.c $(INCLUDE) + $(CC) -c sidebar.c $(INCLUDE) sound.o: sound.c - gcc -c sound.c $(INCLUDE) + $(CC) -c sound.c $(INCLUDE) $(SDL_MIXER_FLAGS) story.o: story.c - gcc -c story.c $(INCLUDE) + $(CC) -c story.c $(INCLUDE) tblib.o: tblib.c - gcc -c tblib.c $(INCLUDE) + $(CC) -c tblib.c $(INCLUDE) clean: - rm tb1 *.o *~ + rm -f tb1 *.o *~ cd svmwgraph && make clean diff --git a/Makefile.inc b/Makefile.inc new file mode 100644 index 0000000..3a0c804 --- /dev/null +++ b/Makefile.inc @@ -0,0 +1,55 @@ +# +# Edit the below to fit your configuration. I should automate this +# (maybe with a configure file?) One of these days. + + +# +# Compiler to use +# +CC= gcc + +# +# Uncomment the following for SDL_mixer sound +# + +SDL_MIXER_FLAGS= -DSDL_MIXER_SOUND +SDL_MIXER_LIBS= -lSDL_mixer + +# +# Uncomment the following for SDL +# +SDL_TARGET= sdl_svmwgraph.o +SDL_LIBS= -lSDL -L/usr/X11R6/lib -lX11 -lpthread +SDL_FLAGS= -DSDL_TARGET +SDL_INCLUDE= -I/usr/local/include/SDL + +# +# Uncomment the following for ncurses +# +CURSES_TARGET= curses_svmwgraph.o +CURSES_FLAGS= -DCURSES_TARGET=1 +CURSES_LIBS= -lncurses + +# +# On machines w/ curses instead of ncurses [i.e. solaris, Irix, etc] +# You'll want to use the following instead +# +#CURSES_TARGET= curses_svmwgraph.o +#CURSES_FLAGS= -DCURSES_TARGET=2 +#CURSES_LIBS= -lcurses + + +# +# Uncomment the following for opengGL +# +#OPENGL_TARGET= opengl_svmwgraph.o +#OPENGL_FLAGS=-DOPENGL_TARGET +#OPENGL_LIBS= -L/usr/X11R6/lib -lX11 -lICE -lXmu -lGL -lGLU -lglut + + +############################## +# DO NOT EDIT BELOW THIS LINE +############################## + +INCLUDE_GLOBAL= -Wall -O2 $(SDL_INCLUDE) +LIBS_GLOBAL= -lm $(SDL_MIXER_LIBS) $(SDL_LIBS) $(CURSES_LIBS) $(OPENGL_LIBS) diff --git a/README b/README index c0bee20..c9f3b72 100644 --- a/README +++ b/README @@ -11,7 +11,7 @@ Vince Weaver -Version 2.9.10 +Version 2.9.11 --------------------------------------------------------------------- Contents @@ -32,9 +32,9 @@ Contents Sorry, there is no "configure" file as of yet. -If you have SDL or ncurses in non-standard places, you'll - have to edit the Makefiles. - +If you have a non-standard (ie non-Linux, or Linux w/o SDL/curses/SDL_mixer) + you will have to edit the "Makefile.inc" file to match your config. + You need the SDL game development library, 1.1.4 or newer: http://www.libsdl.org/download-1.1.html @@ -267,7 +267,7 @@ ___________________________________________________________________ Remember: Watch for the newest version of Tom Bombem... and have fun. - Vince Weaver 16 October 2000 23:05:59 EDT + Vince Weaver 27 October 2000 20:05:59 EDT diff --git a/TB1.FAQ b/TB1.FAQ index 561bce7..9d9ae26 100644 --- a/TB1.FAQ +++ b/TB1.FAQ @@ -54,3 +54,10 @@ A5). You can get the old DOS version off my website, it will run on Q6). A curses target? Were you insane? A6). No, just very very tired. + +Q7). Your "Tentaclee" aliens look like aliens from Commander Keen. Did + you steal them? + +A7). I've been drawing aliens like that from before Commander Keen was + published, and I can produce sketches to show it. It is just some + weird co-incidence. diff --git a/TODO b/TODO index c54a6eb..4093efc 100644 --- a/TODO +++ b/TODO @@ -12,4 +12,8 @@ Other aspirations: SVMWGraph todo: Color Averaging in the curses target? Implement non 320x200x8 PCX loading? + Make sprite code RLE? +Known Bugs: + 8bpp palette switching not as smooth as it could be. + Volume controls on option menu don't do anything yet diff --git a/data/hiscore.tb1 b/data/hiscore.tb1 index c9fc859..c64d1b7 100644 --- a/data/hiscore.tb1 +++ b/data/hiscore.tb1 @@ -5,9 +5,9 @@ Hairold Kevin Leonard Lizann +ZURGTROYD +Bon Pete -Jim -Brigid 5000 4500 4000 @@ -15,6 +15,6 @@ Brigid 3000 2500 2000 +1670 +1520 1500 -1000 -500 diff --git a/graphic_tools.c b/graphic_tools.c index 91f9875..51f9e8f 100644 --- a/graphic_tools.c +++ b/graphic_tools.c @@ -125,7 +125,7 @@ char *vmwGrInput(tb1_state *game_state,int x,int y,int howlong,int forecol,int b num_chars--; tempst[num_chars]=0; } - if (num_chars<10) { + else if (num_chars<10) { if ((ch>31) && (ch<128)) { tempst[num_chars]=(char)ch; tempst[num_chars+1]=0; diff --git a/hiscore.c b/hiscore.c index 74a2096..0b66aea 100644 --- a/hiscore.c +++ b/hiscore.c @@ -26,7 +26,11 @@ int showhiscore(tb1_state *game_state,int showchart,int return_highest) return 0; } - for (i=0;i<10;i++) fscanf(hilist,"%s",names[i]); + for(i=0;i<10;i++) { + fgets(names[i],11,hilist); + /* There has to be a cleaner way of getting rid of that '\n' */ + names[i][strlen(names[i])-1]='\0'; + } for (i=0;i<10;i++) fscanf(hilist,"%i",&scores[i]); fclose(hilist); if (!showchart) { @@ -59,11 +63,14 @@ void write_hs_list(tb1_state *game_state,int score,char *hiname,int wipe) int i,place,in_place; FILE *hilist; - vmwHighScore old_list[10]; - vmwHighScore new_list[10]; + vmwHighScore old_list[12]; + vmwHighScore new_list[12]; hilist=fopen(tb1_data_file("hiscore.tb1",game_state->path_to_data),"r"); - for (i=0;i<10;i++) fscanf(hilist,"%s",old_list[i].name); + for(i=0;i<10;i++) { + fgets(old_list[i].name,12,hilist); + old_list[i].name[strlen(old_list[i].name)-1]='\0'; + } for (i=0;i<10;i++) fscanf(hilist,"%i",&old_list[i].score); fclose(hilist); diff --git a/level_2.c b/level_2.c index ec8418f..8b0d52b 100644 --- a/level_2.c +++ b/level_2.c @@ -445,7 +445,7 @@ void leveltwoengine(tb1_state *game_state) if (rows_goneby>1950) { // printf("%i\n",rows_goneby); coolbox(35,85,215,110,1,virtual_1); - vmwTextXY("TO BE CONTINUED...",55,85,4,7,0,tb1_font,virtual_1); + vmwTextXY("TO BE CONTINUED...",55,95,4,7,0,tb1_font,virtual_1); vmwBlitMemToDisplay(game_state->graph_state,virtual_1); pauseawhile(10); diff --git a/level_3.c b/level_3.c index ae91490..2df2f64 100644 --- a/level_3.c +++ b/level_3.c @@ -1,23 +1,21 @@ +#include +#include - Obstruction = record - x,y:integer; - shooting,dead,exploding:boolean; - explodeprogress:byte; - howmanyhits:integer; - kind,lastshot:byte; - end; +#include "./svmwgraph/svmwgraph.h" +#include "tb1_state.h" + +#include "help.h" +#include "loadsave.h" +#include "graphic_tools.h" + +#define NORTH 0 +#define SOUTH 1 +#define EAST 2 +#define WEST 3 - EnemyInfo = record - x,y:integer; - kind:byte; - out,exploding,boundarycheck,dead:boolean; - explodprogress:byte; - minx,maxx,xspeed,yspeed:integer; - hitsneeded:integer; - end; - -procedure loadlevel3shapes; +void loadlevel3shapes() { + /* var x,y,i,j,shape:byte; begin clearshape; @@ -31,8 +29,10 @@ begin :=getpixel(1+x+(i*11),1+y+(j*11),vaddr); cls(0,vaddr); end; +*/ +} - +/* Procedure levelthree; label newroom; type{ @@ -151,8 +151,23 @@ begin else for i:=0 to 20 do put10shape240(shape3array[2],vaddr2,0,i*10); end; +*/ +void LevelThreeEngine(tb1_state *game_state) { + int level_over=0; + int ch,direction=NORTH; + int x_add,y_add; + int game_paused=0; + + vmwVisual *virtual_1,*virtual_2; + vmwFont *tb1_font; + + virtual_1=game_state->virtual_1; + virtual_2=game_state->virtual_2; + tb1_font=game_state->graph_state->default_font; + +/* BEGIN {loadlevel3shapes;} @@ -388,20 +403,18 @@ newroom: end; if (room=254) and not(levelover) then goto newroom; +*/ +/**** GAME LOOP ****/ +/*******************/ + + while (!level_over) { -{**** GAME LOOP ****} -{*******************} - Repeat - ch2:=#1; - ch:=#1; - - flip240(0); -{***Collision Check***} - if numpits>0 then + /***Collision Check***/ +/* if numpits>0 then for i:=0 to (numpits-1) do with pits[i] do if collision(shipx,shipy,5,4,px,py,4,4) then begin @@ -511,10 +524,10 @@ newroom: shipx:=shipx+(4*framedir[1,shipframe]); shipy:=shipy+(4*framedir[0,shipframe]); end; +*/ - -{***DO EXPLOSIONS***} -{ for i:=0 to 30 do + /***DO EXPLOSIONS***/ +/*{ for i:=0 to 30 do if passive[i].exploding then with passive[i] do begin inc(explodeprogress); putshape240(shape2array[35+explodeprogress],vaddr2, @@ -526,10 +539,10 @@ newroom: 20,9,x,y+howmuchscroll); end; end; - - } -{***MOVE BULLET***} - if bullet1out then begin +*/ + + /***MOVE BULLETS***/ +/* if bullet1out then begin case bullet1dir of 1:begin dec(bullet1y,5); collide:=upcollide(bullet1x,bullet1y,5,-5,3,vaddr2); @@ -553,8 +566,9 @@ newroom: if bullet2y<5 then bullet2out:=false; if bullet2out then putshape(shape3array[76],vaddr,10,9,bullet2x,bullet2y); end; -{***MOVE ENEMIES***} - { for j:=0 to 30 do begin + */ + /***MOVE ENEMIES***/ +/* { for j:=0 to 30 do begin if passive[j].dead=false then begin inc(passive[j].y); if(passive[j].y)>190 then passive[j].dead:=true; @@ -587,57 +601,57 @@ newroom: end; end; } - -{***READ KEYBOARD***} - - if keypressed then BEGIN - ch:=readkey; - if ch=chr(0) then ch2:=readkey; - if ch=#27 then levelover:=true; - clearkeyboardbuffer; - - if ch2='M' then begin +*/ + + /***READ KEYBOARD***/ + if ( (ch=vmwGetInput())!=0) { + switch(ch){ + case VMW_ESCAPE: level_over=1; + break; + case VMW_RIGHT: if (direction==EAST) x_add=2; + else direction=EAST; + break; + /* if (shipframe=2) and (shipxadd=0) then shipxadd:=2 else if (shipframe<>2) then shipframe:=2 else inc(shipxadd); - end; - if ch2='K' then begin - if (shipframe=4) and (shipxadd=0) then shipxadd:=-2 - else if (shipframe<>4) then shipframe:=4 - else dec(shipxadd); - end; - if ch2='H' then begin - if (shipframe=1) and (shipyadd=0) then shipyadd:=-2 - else if (shipframe<>1) then shipframe:=1 - else dec(shipyadd); - - end; - if ch2='P' then begin - if (shipframe=3) and (shipyadd=0) then shipyadd:=2 - else if (shipframe<>3) then shipframe:=3 - else inc(shipyadd); - - end; - if ch2=';' then help; - if ch='+' then begin - inc(whatdelay); - if whatdelay>25 then whatdelay:=25; - end; - if (ch='P') or (ch='p') then begin - coolbox(65,85,175,110,true,vga); - outtextxy('GAME PAUSED',79,95,4,7,vga,false); - clearkeyboardbuffer; - repeat until keypressed; tempch:=readkey; - end; - if ch='-' then begin - dec(whatdelay); - if whatdelay<1 then whatdelay:=1; - end; - {if (ch='S') or (ch='s') then sbeffects:=not(sbeffects);} - - if ch2='<' then savegame; - - end; + */ + case VMW_LEFT: if (direction==WEST) x_add=-2; + else direction=WEST; + break; + case VMW_UP: if (direction==NORTH) y_add=-2; + else direction=NORTH; + break; + case VMW_DOWN: if (direction==SOUTH) y_add=2; + else direction=SOUTH; + break; + case VMW_F1: game_paused=1; + help(game_state); + break; + + case 'P': + case 'p': game_paused=1; + coolbox(65,85,175,110,1,virtual_1); + vmwTextXY("GAME PAUSED",79,95,4,7,0, + game_state->graph_state->default_font, + virtual_1); + vmwClearKeyboardBuffer(); + vmwBlitMemToDisplay(game_state->graph_state, + virtual_1); + while (vmwGetInput()==0) usleep(30000); + break; + case 'S': + case 's': if (game_state->sound_possible) + game_state->sound_enabled=!(game_state->sound_enabled); + break; + + case VMW_F2: game_paused=1; + savegame(game_state); + break; + case ' ': /* shoot */ + break; + /* + if (ch=' ') and havegun then begin if (bullet1out=false) then begin {if sbeffects then StartSound(Sound[4], 0, false);} @@ -657,15 +671,19 @@ newroom: putshape(shape3array[76],vaddr,10,9,bullet2x,bullet2y); end; end; - -{***MOVE SHIP***} +*/ + } + } + + /***MOVE TOM***/ - ucollide:=upcollide(shipx,shipy,abs(shipyadd),-abs(shipyadd),10,vaddr2); + /* ucollide:=upcollide(shipx,shipy,abs(shipyadd),-abs(shipyadd),10,vaddr2); dcollide:=upcollide(shipx,shipy,abs(shipyadd),8,10,vaddr2); lcollide:=leftcollide(shipx,shipy,abs(shipxadd),-abs(shipxadd),8,vaddr2); - rcollide:=leftcollide(shipx,shipy,abs(shipxadd),0,8,vaddr2); - if (shipframe=1) and (ucollide<>0) then shipyadd:=0; + rcollide:=leftcollide(shipx,shipy,abs(shipxadd),0,8,vaddr2);*/ + + /* if (shipframe=1) and (ucollide<>0) then shipyadd:=0; if (shipframe=3) and (dcollide<>0) then shipyadd:=0; if (shipframe=2) and (rcollide<>0) then shipxadd:=0; if (shipframe=4) and (lcollide<>0) then shipxadd:=0; @@ -701,39 +719,21 @@ newroom: if (shipyadd<>0) or (shipxadd<>0) then inc(walking,4) else walking:=0; if walking>12 then walking:=0; - - CASE shipframe of +*/ + /* CASE shipframe of 1 : putshape (shape3array[60+walking],vaddr,10,9,shipx,shipy); 2 : putshape (shape3array[61+walking],vaddr,10,9,shipx,shipy); 3 : putshape (shape3array[62+walking],vaddr,10,9,shipx,shipy); 4 : putshape (shape3array[63+walking],vaddr,10,9,shipx,shipy); END; - waitretrace; - flip (vaddr,vga); - if odd then begin - pal(250,0,0,63); - pal(251,63,0,0); - odd:=not(odd); - end - else begin - pal(251,0,0,63); - pal(250,63,0,0); - odd:=not(odd); - end; - - - for i:=0 to whatdelay do waitretrace; - - if changeroom then goto newroom; - - until levelover; -END; + */ + } +} - - -procedure littleopener3; +void littleopener3() { + /* var star_x:array[0..5]of integer; star_y:array[0..5]of integer; begin @@ -818,4 +818,6 @@ begin cls(0,vga); unfade; end; + */ +} diff --git a/options.c b/options.c index 51569f1..3ee0721 100644 --- a/options.c +++ b/options.c @@ -89,10 +89,10 @@ void options(tb1_state *game_state) put_string("WIPE LIST",(opbarpos==5),40,80,tb1_font,game_state->virtual_1); vmwTextXY("DEFAULT DISPLAY OPTIONS:",10,90,9,8,1,tb1_font,game_state->virtual_1); - vmwTextXY("RUN FULLSCREEN:",40,100,10,8,1,tb1_font,game_state->virtual_1); + vmwTextXY("RUN DOUBLESIZE:",40,100,10,8,1,tb1_font,game_state->virtual_1); put_yes_no(game_state->default_double_size,(opbarpos==6),180,100, tb1_font,game_state->virtual_1); - vmwTextXY("RUN DOUBLESIZE:",40,110,10,8,1,tb1_font,game_state->virtual_1); + vmwTextXY("RUN FULLSCREEN:",40,110,10,8,1,tb1_font,game_state->virtual_1); put_yes_no(game_state->default_fullscreen,(opbarpos==7),180,110, tb1_font,game_state->virtual_1); diff --git a/sound.c b/sound.c index 49667ec..8c97657 100644 --- a/sound.c +++ b/sound.c @@ -1,20 +1,27 @@ /* "borrowed" from gltron */ +#ifdef SDL_MIXER_SOUND +#include +#include +#endif + #include "sound.h" #include /* Function definition */ char *tb1_data_file(char *name,char *path); - /* linux only, at the moment */ -static Mix_Music *music; - #define NUM_GAME_FX 8 +#ifdef SDL_MIXER_SOUND +static Mix_Music *music; + static Mix_Chunk *game_fx[NUM_GAME_FX]; +#endif + static char *game_fx_names[] = { "sound/tb_ahh.wav", "sound/tb_cc.wav", @@ -27,6 +34,7 @@ static char *game_fx_names[] = { }; void loadFX(char *path_to_data) { +#ifdef SDL_MIXER_SOUND int i; char *path; @@ -36,41 +44,52 @@ void loadFX(char *path_to_data) { game_fx[i] = Mix_LoadWAV(path); } } +#endif } int initSound(char *path_to_data) { /* open the audio device */ +#ifdef SDL_MIXER_SOUND if(Mix_OpenAudio(22050, AUDIO_U16, 1, 1024) < 0) { fprintf(stderr, "can't open audio: %s\n", SDL_GetError()); return -1; } loadFX(path_to_data); +#endif return 0; } void shutdownSound() { +#ifdef SDL_MIXER_SOUND Mix_CloseAudio(); +#endif } int loadSound(char *name) { +#ifdef SDL_MIXER_SOUND music = Mix_LoadMUS(name); +#endif return 0; } int playSound() { +#ifdef SDL_MIXER_SOUND if( ! Mix_PlayingMusic() ) Mix_PlayMusic(music, -1); /* todo: remove the following once the bug in SDL_mixer is fixed */ /* we don't want too many references to game objects here */ // setMusicVolume(game->settings->musicVolume); +#endif return 0; } int stopSound() { +#ifdef SDL_MIXER_SOUND if( Mix_PlayingMusic() ) Mix_HaltMusic(); +#endif return 0; } @@ -80,21 +99,27 @@ void soundIdle() { } void playGameFX(int fx) { +#ifdef SDL_MIXER_SOUND Mix_PlayChannel(-1, game_fx[fx], 0); // fprintf(stderr, "fx on channel %d\n", Mix_PlayChannel(-1, game_fx[fx], 0)); +#endif } void setMusicVolume(float volume) { +#ifdef SDL_MIXER_SOUND if(volume > 1) volume = 1; if(volume < 0) volume = 0; Mix_VolumeMusic((int)(volume * 128)); +#endif } void setFxVolume(float volume) { +#ifdef SDL_MIXER_SOUND if(volume > 1) volume = 1; if(volume < 0) volume = 0; Mix_Volume(-1, (int)(volume * 128)); +#endif } diff --git a/sound.h b/sound.h index 90e4a67..ecc9b37 100644 --- a/sound.h +++ b/sound.h @@ -1,9 +1,6 @@ #ifndef SOUND_H #define SOUND_H -#include -#include - int initSound(); void shutdownSound(); diff --git a/svmwgraph/Makefile b/svmwgraph/Makefile index bbc7bd8..f552fc5 100644 --- a/svmwgraph/Makefile +++ b/svmwgraph/Makefile @@ -1,46 +1,49 @@ +include ../Makefile.inc - -INCLUDE= -Wall -O2 -I/usr/local/include/SDL -LIBS= -lSDL -lSDL_mixer -L/usr/X11R6/lib -lX11 -lpthread +INCLUDE= $(INCLUDE_GLOBAL) +LIBS= $(LIBS_GLOBAL) all: libsvmwgraph.a -libsvmwgraph.a: vmw_core.o vmw_flip.o vmw_font.o vmw_paintpro.o vmw_palette.o vmw_pcx.o vmw_setup.o vmw_sprite.o curses_svmwgraph.o null_svmwgraph.o sdl_svmwgraph.o - ar cru libsvmwgraph.a vmw_core.o vmw_flip.o vmw_font.o vmw_paintpro.o vmw_palette.o vmw_pcx.o vmw_setup.o vmw_sprite.o curses_svmwgraph.o null_svmwgraph.o sdl_svmwgraph.o +libsvmwgraph.a: vmw_core.o vmw_flip.o vmw_font.o vmw_paintpro.o vmw_palette.o vmw_pcx.o vmw_setup.o vmw_sprite.o $(CURSES_TARGET) null_svmwgraph.o $(OPENGL_TARGET) $(SDL_TARGET) + ar cru libsvmwgraph.a vmw_core.o vmw_flip.o vmw_font.o vmw_paintpro.o vmw_palette.o vmw_pcx.o vmw_setup.o vmw_sprite.o $(CURSES_TARGET) null_svmwgraph.o $(OPENGL_TARGET) $(SDL_TARGET) ranlib libsvmwgraph.a vmw_core.o: vmw_core.c - gcc $(INCLUDE) -c vmw_core.c + $(CC) $(INCLUDE) -c vmw_core.c vmw_flip.o: vmw_flip.c - gcc $(INCLUDE) -c vmw_flip.c + $(CC) $(INCLUDE) -c vmw_flip.c vmw_font.o: vmw_font.c - gcc $(INCLUDE) -c vmw_font.c + $(CC) $(INCLUDE) -c vmw_font.c vmw_paintpro.o: vmw_paintpro.c - gcc $(INCLUDE) -c vmw_paintpro.c + $(CC) $(INCLUDE) -c vmw_paintpro.c vmw_palette.o: vmw_palette.c - gcc $(INCLUDE) -c vmw_palette.c + $(CC) $(INCLUDE) -c vmw_palette.c vmw_pcx.o: vmw_pcx.c - gcc $(INCLUDE) -c vmw_pcx.c + $(CC) $(INCLUDE) -c vmw_pcx.c vmw_setup.o: vmw_setup.c - gcc $(INCLUDE) -c vmw_setup.c + $(CC) $(INCLUDE) $(SDL_FLAGS) $(CURSES_FLAGS) $(OPENGL_FLAGS) -c vmw_setup.c vmw_sprite.o: vmw_sprite.c - gcc $(INCLUDE) -c vmw_sprite.c + $(CC) $(INCLUDE) -c vmw_sprite.c -curses_svmwgraph.o: curses_svmwgraph.c - gcc $(INCLUDE) -c curses_svmwgraph.c +curses_svmwgraph.o: curses_svmwgraph.c + $(CC) $(INCLUDE) -c curses_svmwgraph.c $(CURSES_FLAGS) null_svmwgraph.o: null_svmwgraph.c - gcc $(INCLUDE) -c null_svmwgraph.c + $(CC) $(INCLUDE) -c null_svmwgraph.c + +opengl_svmwgraph.o: opengl_svmwgraph.c + $(CC) $(INCLUDE) -c opengl_svmwgraph.c sdl_svmwgraph.o: sdl_svmwgraph.c - gcc $(INCLUDE) -c sdl_svmwgraph.c + $(CC) $(INCLUDE) -c sdl_svmwgraph.c clean: rm -f libsvmwgraph.a *.o *~ diff --git a/svmwgraph/curses_svmwgraph.c b/svmwgraph/curses_svmwgraph.c index f547012..8d5f5a9 100644 --- a/svmwgraph/curses_svmwgraph.c +++ b/svmwgraph/curses_svmwgraph.c @@ -3,7 +3,13 @@ #include #include #include + +#if (CURSES_TARGET==2) +#include "curses.h" +#else #include "ncurses.h" +#endif + #include "svmwgraph.h" #include /* For atexit() */ @@ -76,7 +82,8 @@ void *curses_setupGraphics(int *xsize,int *ysize,int *bpp, int fullscreen,int ve our_COLS=(320/our_cols_stride); } - return NULL; + /* Returning NULL would be an error */ + return &our_colors; } diff --git a/svmwgraph/null_svmwgraph.c b/svmwgraph/null_svmwgraph.c index 2af60f7..0e89863 100644 --- a/svmwgraph/null_svmwgraph.c +++ b/svmwgraph/null_svmwgraph.c @@ -6,7 +6,8 @@ void *null_setupGraphics(int *xsize,int *ysize,int *bpp, int fullscreen,int verbose) { - return NULL; + /* Returning NULL is considered an error */ + return (void *)1; } diff --git a/svmwgraph/opengl_svmwgraph.c b/svmwgraph/opengl_svmwgraph.c new file mode 100644 index 0000000..48b75d5 --- /dev/null +++ b/svmwgraph/opengl_svmwgraph.c @@ -0,0 +1,129 @@ +/* The OpenGL hooks for the Super VMW graphics library */ + + +#include +#include +#include +#include "svmwgraph.h" +#include /* For atexit() */ +#include + +float palette[256][3]; + + + /* Setup the Graphics */ + /* Pass '0' to auto-detect bpp */ +void *openGL_setupGraphics(int *xsize,int *ysize,int *bpp, + int fullscreen,int verbose) +{ + + + /* ^^*&^$%*&$^*&%^$ I am too stubborn to pass the real argc and */ + /* argv through.. and I can't get this to work otherwise. */ + /* I am tired of screwing with it though, so this is known broken */ + int argc2=3,i; + char argv2[3][10]; + + strcpy(argv2[0],"vmw"); + strcpy(argv2[1],"mlp"); + strcpy(argv2[2],"amg"); + + for(i=0;ipalette[i]>>11)<<3))/256.0; + palette[i][1]=((float) ( ((state->palette[i]>>5)&0x3f)<<2))/256.0; + palette[i][2]=((float) ((state->palette[i]&0x1f)<<3))/256.0; + } + +} + + +void openGL_BlitMem(vmwSVMWGraphState *target_p, vmwVisual *source) { + + int x,y; + + unsigned char *s_pointer; + + s_pointer=source->memory; + + for (x=0;xxsize;x++) + for (y=0;yysize;y++) { + glColor3f(palette[*s_pointer][0],palette[*s_pointer][1],palette[*s_pointer][2]); + glRectf(x,y,x+1,y+1); + +// *((Uint16 *)(t_pointer))=target_p->palette[*(s_pointer)]; + s_pointer++; + } + glFlush(); +} + +void openGL_clearKeyboardBuffer() { +/* SDL_Event event; + while (SDL_PollEvent(&event)) { +*/ + +} + +int openGL_getInput() { + +/* 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 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: if ((keypressed>='a') && (keypressed<='z') + && (event.key.keysym.mod & KMOD_SHIFT) ) + return keypressed-32; + else return keypressed; + } + default: break; + } + } + */ + return 0; +} + +void openGL_closeGraphics() { +} diff --git a/svmwgraph/opengl_svmwgraph.h b/svmwgraph/opengl_svmwgraph.h new file mode 100644 index 0000000..a24690e --- /dev/null +++ b/svmwgraph/opengl_svmwgraph.h @@ -0,0 +1,7 @@ +void *openGL_setupGraphics(int *xsize,int *ysize,int *bpp, + int fullscreen,int verbose); +void openGL_flushPalette(vmwSVMWGraphState *state); +void openGL_BlitMem(vmwSVMWGraphState *target_p, vmwVisual *source); +void openGL_clearKeyboardBuffer(); +int openGL_getInput(); +void openGL_closeGraphics(); diff --git a/svmwgraph/sdl_svmwgraph.h b/svmwgraph/sdl_svmwgraph.h index 25bb2d7..1e45cb4 100644 --- a/svmwgraph/sdl_svmwgraph.h +++ b/svmwgraph/sdl_svmwgraph.h @@ -1,7 +1,5 @@ /* The SDL hooks for the Super VMW graphics library */ -#include - void *SDL_setupGraphics(int *xsize,int *ysize,int *bpp,int fullscreen, int verbose); void SDL_flushPalette(vmwSVMWGraphState *state); diff --git a/svmwgraph/svmwgraph.h b/svmwgraph/svmwgraph.h index 6b1cab5..0074627 100644 --- a/svmwgraph/svmwgraph.h +++ b/svmwgraph/svmwgraph.h @@ -52,6 +52,7 @@ typedef struct { #define VMW_NULLTARGET 0 #define VMW_SDLTARGET 1 #define VMW_CURSESTARGET 2 /* Yes I am insane */ +#define VMW_OPENGLTARGET 3 /* Even Moreso */ /* Error Constants */ diff --git a/svmwgraph/vmw_core.c b/svmwgraph/vmw_core.c index 471bc96..6ffb101 100644 --- a/svmwgraph/vmw_core.c +++ b/svmwgraph/vmw_core.c @@ -2,6 +2,7 @@ #include "svmwgraph.h" #include +#include #define DEBUG 1 @@ -76,55 +77,51 @@ void vmwDrawVLine(int xstart,int ystart,int how_long,int color, } } -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; +int sgn(float a) { + if (a>0) return 1; + if (a<0) return -1; + return 0; +} -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 (sn)) { + d2x=0; + d2y=sgn(dy); + m=fabs(dy); + n=fabs(dx); + } + s=rint(m / 2); + for (i= 0;i< (int)m;i++) { + vmwPutPixel(x1,y1,color,destination); + s+=n; + if (!(s /* For printf */ #include /* For Memory Allocation */ @@ -29,11 +30,23 @@ vmwSVMWGraphState *vmwSetupSVMWGraph(int display_type,int xsize,int ysize, } /* Setup Setup routines */ switch (display_type) { - case VMW_NULLTARGET: vmwSetupGraphics=null_setupGraphics; + case VMW_NULLTARGET: + vmwSetupGraphics=null_setupGraphics; break; - case VMW_CURSESTARGET: vmwSetupGraphics=curses_setupGraphics; + case VMW_CURSESTARGET: +#ifdef CURSES_TARGET + vmwSetupGraphics=curses_setupGraphics; +#endif break; - case VMW_SDLTARGET: vmwSetupGraphics=SDL_setupGraphics; + case VMW_OPENGLTARGET: +#ifdef OPENGL_TARGET + vmwSetupGraphics=openGL_setupGraphics; +#endif + break; + case VMW_SDLTARGET: +#ifdef SDL_TARGET + vmwSetupGraphics=SDL_setupGraphics; +#endif break; default: printf("ERROR! Unknown Display Target %i.\n",display_type); return NULL; @@ -62,6 +75,7 @@ vmwSVMWGraphState *vmwSetupSVMWGraph(int display_type,int xsize,int ysize, &temp_state->ysize, &temp_state->bpp, fullscreen,verbose); + if (temp_state->output_screen==NULL) return NULL; /* Setup proper blitter and others*/ switch (display_type) { case VMW_NULLTARGET: @@ -71,14 +85,26 @@ vmwSVMWGraphState *vmwSetupSVMWGraph(int display_type,int xsize,int ysize, vmwGetInput=null_getInput; vmwCloseGraphics=null_closeGraphics; break; + case VMW_OPENGLTARGET: +#ifdef OPENGL_TARGET + vmwFlushPalette=openGL_flushPalette; + vmwClearKeyboardBuffer=openGL_clearKeyboardBuffer; + vmwBlitMemToDisplay=openGL_BlitMem; + vmwGetInput=openGL_getInput; + vmwCloseGraphics=openGL_closeGraphics; +#endif + break; case VMW_CURSESTARGET: +#ifdef CURSES_TARGET vmwFlushPalette=curses_flushPalette; vmwClearKeyboardBuffer=curses_clearKeyboardBuffer; vmwBlitMemToDisplay=curses_BlitMem; vmwGetInput=curses_getInput; vmwCloseGraphics=curses_closeGraphics; +#endif break; case VMW_SDLTARGET: +#ifdef SDL_TARGET if (temp_state->bpp==8) { if (scale==1) { vmwBlitMemToDisplay=SDL_NoScale8bpp_BlitMem; @@ -97,6 +123,7 @@ vmwSVMWGraphState *vmwSetupSVMWGraph(int display_type,int xsize,int ysize, vmwClearKeyboardBuffer=SDL_clearKeyboardBuffer; vmwGetInput=SDL_getInput; vmwCloseGraphics=SDL_closeGraphics; +#endif break; default: printf("ERROR! Unknown Display Target %i.\n",display_type); return NULL; diff --git a/svmwgraph/vmw_sprite.c b/svmwgraph/vmw_sprite.c index c03721f..73df42a 100644 --- a/svmwgraph/vmw_sprite.c +++ b/svmwgraph/vmw_sprite.c @@ -3,46 +3,133 @@ #include "svmwgraph.h" #include /* for calloc/malloc */ + + /* Doesn't matter if this is semi-slow */ + /* It is used both to get size of the sprite, then to actually get it */ +int fakeGetSprite(int x,int y,int xsize,int ysize, + vmwVisual *screen,int capture, + char *spritedata) { + + int oldcolor,xtemp,ytemp=0,color,numacross,pointer=0; + + oldcolor=vmwGetPixel(x,y,screen); + xtemp=0; + numacross=0; + + while (ytempxsize) { + xtemp=0; + numacross=0; + ytemp++; + oldcolor=vmwGetPixel(x,y+ytemp,screen); + } + } + return pointer; +} + + + /* Sprites are now RLE encoded for speed and size reasons */ vmwSprite *vmwGetSprite(int x, int y, int xsize, int ysize,vmwVisual *screen) { - vmwSprite *temp_sprite; - int xtemp,ytemp; + vmwSprite *temp_sprite; + + int sprite_size=0; - temp_sprite=calloc(1,sizeof(vmwSprite)); - temp_sprite->spritedata=calloc(1,xsize*ysize); - temp_sprite->xsize=xsize; - temp_sprite->ysize=ysize; + sprite_size=fakeGetSprite(x,y,xsize,ysize, + screen,0,NULL); + + temp_sprite=calloc(1,sizeof(vmwSprite)); + temp_sprite->spritedata=calloc(1,sprite_size); + temp_sprite->xsize=xsize; + temp_sprite->ysize=ysize; - /* The following is very slow and can be easily optimized */ - - for(ytemp=0;ytempspritedata)+ytemp*xsize+xtemp)= - vmwGetPixel(xtemp+x,ytemp+y,screen); - - return temp_sprite; + fakeGetSprite(x,y,xsize,ysize,screen,1,temp_sprite->spritedata); + + /* Original non-RLE sprite code */ +/* for(ytemp=0;ytempspritedata)+ytemp*xsize+xtemp)= + vmwGetPixel(xtemp+x,ytemp+y,screen); +*/ + return temp_sprite; } void vmwFreeSprite(vmwSprite *sprite) { - free(sprite->spritedata); - free(sprite); + free(sprite->spritedata); + free(sprite); } + /* Sprites are now RLE-encoded for size and speed reasons */ void vmwPutSprite(vmwSprite *sprite,int x,int y, vmwVisual *screen) { - unsigned char *temp_source,*temp_destination; - int xx,yy; + unsigned char *temp_source,*temp_destination; + int xx=0,yy=0,run_length,i; - temp_source=sprite->spritedata; - temp_destination= (unsigned char *)(screen->memory)+(y*screen->xsize+x); - - for (yy=0;yyysize;yy++) { - for (xx=0;xxxsize;xx++) { + temp_source=sprite->spritedata; + temp_destination= (unsigned char *)(screen->memory)+(y*screen->xsize+x); + + while (yyysize) { + if ( (*temp_source) <128) { /* Single Pixel */ + if (*temp_source!=0) { + *(temp_destination)=*(temp_source); + } + xx++; + temp_source++; + temp_destination++; + } + + else { /* Run */ + run_length=(*temp_source)-128; + temp_source++; + /* Non-transparent */ + if (*temp_source) { + for (i=0;i=sprite->xsize) { + temp_destination+=((screen->xsize-sprite->xsize)); + yy++; + xx=0; + } + } + + /* The old non-RLE sprite code */ +/* for (yy=0;yyysize;yy++) { + for (xx=0;xxxsize;xx++) { if (*temp_source!=0) { *(temp_destination)=*(temp_source); } @@ -50,26 +137,51 @@ void vmwPutSprite(vmwSprite *sprite,int x,int y, temp_destination++; } temp_destination+=((screen->xsize-sprite->xsize)); - } +*/ } void vmwPutSpriteNonTransparent(vmwSprite *sprite,int x,int y, vmwVisual *screen) { - unsigned char *temp_source,*temp_destination; - int xx,yy; + unsigned char *temp_source,*temp_destination; + int xx,yy,run_length,i; - temp_source=sprite->spritedata; - temp_destination= (unsigned char *)(screen->memory)+(y*screen->xsize+x); - - for (yy=0;yyysize;yy++) { - for (xx=0;xxxsize;xx++) { - *(temp_destination)=*(temp_source); - temp_source++; - temp_destination++; + temp_source=sprite->spritedata; + temp_destination= (unsigned char *)(screen->memory)+(y*screen->xsize+x); + + yy=0; + xx=0; + + while (yyysize) { + + if ( (*temp_source) <128) { /* Single Pixel */ + *(temp_destination)=*(temp_source); + xx++; + temp_source++; + temp_destination++; } - temp_destination+=((screen->xsize-sprite->xsize)); - } + + else { /* Run */ + run_length=(*temp_source)-128; + temp_source++; + + for (i=0;i=sprite->xsize) { + temp_destination+=((screen->xsize-sprite->xsize)); + yy++; + xx=0; + } + } + } void vmwPutPartialSprite(vmwVisual *destination, @@ -79,26 +191,56 @@ void vmwPutPartialSprite(vmwVisual *destination, { unsigned char *temp_source,*temp_destination; - int xx,yy; + int xx,yy,run_length,i; temp_source=sprite->spritedata; temp_destination=(unsigned char *)(destination->memory)+(y*destination->xsize+x); - for (yy=0;yyysize;yy++) { - for (xx=0;xxxsize;xx++) { - /* Only draw if in bounds */ - if ( (yy+y>=y_start) && (yy+y<=y_stop) && - (xx+x>=x_start) && (xx+x<=x_stop) ) { - - if (*temp_source!=0) { - *(temp_destination)=*(temp_source); - } - } - temp_source++; - temp_destination++; + yy=0; + xx=0; + + while (yyysize) { + + if ( (*temp_source) <128) { /* Single Pixel */ + if (*temp_source!=0) { + if ( (yy+y>=y_start) && (yy+y<=y_stop) && + (xx+x>=x_start) && (xx+x<=x_stop) ) + *(temp_destination)=*(temp_source); + } + xx++; + temp_source++; + temp_destination++; } - temp_destination+=((destination->xsize-sprite->xsize)); - } - return; + + else { /* Run */ + run_length=(*temp_source)-128; + temp_source++; + /* Non-transparent */ + if (*temp_source) { + for (i=0;i=y_start) && (yy+y<=y_stop) && + (xx+x>=x_start) && (xx+x<=x_stop) ) + *(temp_destination)=*(temp_source); + temp_destination++; + } + } + + else { /* transparent */ + temp_destination+=run_length; + } + + xx+=run_length; + temp_source++; + } + + /* See if we are done this line */ + if (xx>=sprite->xsize) { + temp_destination+=((destination->xsize-sprite->xsize)); + yy++; + xx=0; + } + } + + return; } diff --git a/tb1-2.9.10.lsm b/tb1-2.9.11.lsm similarity index 84% rename from tb1-2.9.10.lsm rename to tb1-2.9.11.lsm index 2f85579..bee3e1e 100644 --- a/tb1-2.9.10.lsm +++ b/tb1-2.9.11.lsm @@ -1,14 +1,14 @@ Begin3 Title: tb1 -Version: 2.9.10 -Entered-date: 16OCT00 +Version: 2.9.11 +Entered-date: 27OCT00 Description: A 2d, sci-fi arcade game. Shoot the aliens, save the world. Keywords: tom bombem alien game arcade SDL curses Author: weave@eng.umd.edu (Vince Weaver) Maintained-by: weave@eng.umd.edu (Vince Weaver) Primary-site: metalab.unc.edu /pub/Linux/games/arcade - 350kB tb1-2.9.10.tar.gz + 350kB tb1-2.9.11.tar.gz Alternate-site: http://www.glue.umd.edu/~weave/tb1 Original-site: Platforms: Linux diff --git a/tb1.c b/tb1.c index 504cc0f..d0194dd 100644 --- a/tb1.c +++ b/tb1.c @@ -1,6 +1,6 @@ /****************************************************************\ \* TOM BOMBEM AND THE INVASION OF THE INANIMATE_OBJECTS */ -/* version 2.9.9 23 September 2000 *\ +/* version 2.9.11 20 October 2000 *\ \* by Vince Weaver weave@eng.umd.edu */ /* *\ \* Originally written in Pascal and x86 assembly for DOS */ @@ -10,7 +10,7 @@ \* This source is released under the GPL */ /****************************************************************/ -#define TB1_VERSION "2.9.9" +#define TB1_VERSION "2.9.11" #include #include /* for calloc */ @@ -130,6 +130,8 @@ int main(int argc,char **argv) game_state->sound_possible=1; game_state->music_enabled=1; game_state->sound_enabled=1; + game_state->sound_volume=5; + game_state->music_volume=5; game_state->default_double_size=0; game_state->default_fullscreen=0; @@ -215,9 +217,6 @@ int main(int argc,char **argv) } } printf(" + Found tb1 data in %s\n",game_state->path_to_data); - - /* FIXME -- read in options */ - /* LEGACY OPERATION BOTTLECAP STUFF---> *\ \* --> You are not meant to understand this <-- */ diff --git a/tools/Makefile b/tools/Makefile index c61d8a2..b522aa7 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -1,10 +1,13 @@ +include ../Makefile.inc - -INCLUDE= -O2 -Wall -I/usr/local/include/SDL -I/usr/local/include -I.. -LIBS= -lSDL -L/usr/X11R6/lib -lX11 -lpthread -lncurses +INCLUDE= $(INCLUDE_GLOBAL) -I../svmwgraph +LIBS= $(LIBS_GLOBAL) all: ppro_view pcx2ppp +benchmark: benchmark.o ../svmwgraph/libsvmwgraph.a + gcc -o benchmark benchmark.o ../svmwgraph/libsvmwgraph.a $(LIBS) + ppro_view: ppro_view.o ../svmwgraph/libsvmwgraph.a gcc -o ppro_view ppro_view.o ../svmwgraph/libsvmwgraph.a $(LIBS) @@ -14,6 +17,9 @@ pcx2ppp: pcx2ppp.o ../svmwgraph/libsvmwgraph.a ../svmwgraph/libsvmwgraph.a: cd ../svmwgraph && make +benchmark.o: benchmark.c + gcc -c benchmark.c $(INCLUDE) + pcx2ppp.o: pcx2ppp.c gcc -c pcx2ppp.c $(INCLUDE) @@ -21,4 +27,4 @@ ppro_view.o: ppro_view.c gcc -c ppro_view.c $(INCLUDE) clean: - rm -f ppro_view pcx2ppp *.o *~ + rm -f ppro_view pcx2ppp benchmark *.o *~ diff --git a/tools/benchmark.c b/tools/benchmark.c new file mode 100644 index 0000000..616649c --- /dev/null +++ b/tools/benchmark.c @@ -0,0 +1,85 @@ +/* Views paintpro files */ +/* Also will re-save them */ + +#include +#include +#include +#include +#include "svmwgraph/svmwgraph.h" +#include /* for strdup */ +#include /* for usleep() */ + +int main(int argc,char **argv) +{ + int grapherror,i; + int scale=1,fullscreen=0; + vmwVisual *virtual_1; + vmwSVMWGraphState *graph_state; + vmwSprite *temp_sprite; + + struct timeval our_tv; + struct timezone our_tz; + + int start_sec,start_usec,total_sec,total_usec; + + int size; + + int size_to_try[]={5,10,20,50,75,-1 + }; + + srand(time(NULL)); + + /* Setup Graphics */ + if ( (graph_state=vmwSetupSVMWGraph(VMW_NULLTARGET, + 320, + 200, + 0,scale,fullscreen,1))==NULL) { + fprintf(stderr,"ERROR: Couldn't get display set up properly.\n"); + return VMW_ERROR_DISPLAY; + } + + /* Allocate Virtual screen */ + if ((virtual_1=vmwSetupVisual(320, + 200))==NULL) { + fprintf(stderr,"ERROR: Couldn't get RAM for virtual screen 1!\n"); + return VMW_ERROR_MEM; + } + + /* Load palette */ + + size=0; + while (size_to_try[size]!=-1) { + + + grapherror=vmwLoadPicPacked(0,0,virtual_1,1,1, + "../data/tbomb1.tb1", + graph_state); + + + temp_sprite=vmwGetSprite(0,100,size_to_try[size], + size_to_try[size],virtual_1); + + gettimeofday(&our_tv,NULL); + start_sec=our_tv.tv_sec; + start_usec=our_tv.tv_usec; + + for(i=0;i<100000;i++) { + vmwPutSprite(temp_sprite,rand()%220,rand()%100,virtual_1); + } + gettimeofday(&our_tv,NULL); + total_usec=our_tv.tv_usec-start_usec; + total_sec=our_tv.tv_sec-start_sec; + if (total_usec<0) { + total_usec=-total_usec; + total_sec--; + } + + + printf("Blitting %i %ix%i blocks took %is %ius\n",i,size_to_try[size], + size_to_try[size], + total_sec,total_usec); + fflush(stdout); + size++; + } + return 0; +} diff --git a/tools/benchmark_blit b/tools/benchmark_blit new file mode 100644 index 0000000..9a62227 --- /dev/null +++ b/tools/benchmark_blit @@ -0,0 +1,23 @@ +0,0 +RLE_BLIT +Blitting 100000 5x5 blocks took 0s 374448us +Blitting 100000 10x10 blocks took 0s 390829us +Blitting 100000 20x20 blocks took 1s 454441us +Blitting 100000 50x50 blocks took 7s 43651us +Blitting 100000 75x75 blocks took 14s 687811us + +0,100 +MEMSET +Blitting 100000 5x5 blocks took 0s 275407us +Blitting 100000 10x10 blocks took 0s 700047us +Blitting 100000 20x20 blocks took 0s 761301us +Blitting 100000 50x50 blocks took 2s 352337us +Blitting 100000 75x75 blocks took 7s 337732us + +0,100 +RLE_BLIT +Blitting 100000 5x5 blocks took 0s 277307us +Blitting 100000 10x10 blocks took 0s 310614us +Blitting 100000 20x20 blocks took 0s 281589us +Blitting 100000 50x50 blocks took 2s 364685us +Blitting 100000 75x75 blocks took 6s 762143us diff --git a/tools/pcx2ppp.c b/tools/pcx2ppp.c index adfce1b..42613af 100644 --- a/tools/pcx2ppp.c +++ b/tools/pcx2ppp.c @@ -2,7 +2,7 @@ /* Also will re-save them */ #include -#include "svmwgraph/svmwgraph.h" +#include "svmwgraph.h" #include /* for strdup */ #include /* for usleep() */ diff --git a/tools/ppro_view.c b/tools/ppro_view.c index 4392df6..b59660e 100644 --- a/tools/ppro_view.c +++ b/tools/ppro_view.c @@ -2,7 +2,7 @@ /* Also will re-save them */ #include -#include "svmwgraph/svmwgraph.h" +#include "svmwgraph.h" #include /* for strdup */ #include /* for usleep() */ @@ -17,16 +17,23 @@ int main(int argc,char **argv) char save_string[BUFSIZ]; char *extension,*temp_string1,*temp_string2; int xsize,ysize; - int is_pcx=0; + int is_pcx=0,target=VMW_SDLTARGET; vmwSVMWGraphState *graph_state; + printf("HI %i\n\n",argc); + + if (argc<2) { - printf("\nUsage: %s filename\n\n",argv[0]); + printf("\nUsage: [-curses] %s filename\n\n",argv[0]); return -1; } - filename=strdup(argv[1]); + filename=strdup(argv[argc-1]); + + if (!strncmp(argv[1],"-curses",10)) { + target=VMW_CURSESTARGET; + } /* Hacky way to grab the extension. I am sure this is a cleaner way */ temp_string1=strdup(filename); @@ -69,7 +76,7 @@ int main(int argc,char **argv) /* Setup Graphics */ - if ( (graph_state=vmwSetupSVMWGraph(VMW_CURSESTARGET, + if ( (graph_state=vmwSetupSVMWGraph(target, xsize, ysize, 0,scale,fullscreen,1))==NULL) {