This commit is contained in:
Vince Weaver 2001-10-29 01:18:00 -05:00
parent ecb5d89bc8
commit ecb266f70f
17 changed files with 2032 additions and 982 deletions

View File

@ -1,3 +1,7 @@
28 October 2001
+ Debugged over a few days 32bpp solaris support, with lots of help
from G. Low <unix@macrosscity.com>
2 June 2001
+ Made a super fancy level2 level editor. it's in the ./tools directory.
+ Verified that tb1 will in fact compile and run under windows with

View File

@ -5,8 +5,14 @@ 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 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)
tb1: tb1.o ./svmwgraph/libsvmwgraph.a about.o credits.o graphic_tools.o \
help.o hiscore.o level_1.o level2_engine.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 level2_engine.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
@ -31,9 +37,12 @@ hiscore.o: hiscore.c
level_1.o: level_1.c
$(CC) -c level_1.c $(INCLUDE)
level_2.o: level_2.c
$(CC) -c level_2.c $(INCLUDE)
level2_engine.o: level2_engine.c
$(CC) -c level2_engine.c $(INCLUDE)
#level_2.o: level_2.c
# $(CC) -c level_2.c $(INCLUDE)
level_3.o: level_3.c
$(CC) -c level_3.c $(INCLUDE)

177
cutscenes.c Normal file
View File

@ -0,0 +1,177 @@
/*
* Level 2 Engine Code for Tom Bombem
* */
/* The Includes */
#include <stdio.h>
#include <sys/time.h>
#include <unistd.h>
#include <stdlib.h>
#include "svmwgraph/svmwgraph.h"
#include "tb1_state.h"
#include "levels.h"
#include "tblib.h"
#include "sound.h"
#include "sidebar.h"
#include "help.h"
#include "loadsave.h"
#include "graphic_tools.h"
void level2_end(tb1_state *game_state) {
vmwClearKeyboardBuffer();
pauseawhile(5);
vmwLoadPicPacked(0,0,game_state->virtual_3,0,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,79,58,37,
game_state->virtual_1,10,10);
vmwClearKeyboardBuffer();
vmwSmallTextXY("UNIDENTIFIED SPACECRAFT!",70,10,2,0,1,tb1_font,game_state->virtual_1);
vmwSmallTextXY("DO YOU WISH TO DEACTIVATE ",70,20,2,0,1,tb1_font,game_state->virtual_1);
vmwSmallTextXY("THIS SHIP'S SECURITY SYSTEMS? (Y/N)",70,30,2,0,1,tb1_font,game_state->virtual_1);
vmwBlitMemToDisplay(game_state->graph_state,virtual_1);
vmwClearKeyboardBuffer();
ch='!';
while ((ch!='Y') && (ch!='y') && (ch!='N') && (ch!='n')) {
while(!(ch=vmwGetInput())) usleep(1000);
}
if ((ch=='N') || (ch=='n')) {
vmwArbitraryCrossBlit(game_state->virtual_3,0,79,58,37,
game_state->virtual_1,10,50);
vmwSmallTextXY("NO? AFFIRMATIVE. ",70,50,9,0,1,tb1_font,game_state->virtual_1);
vmwSmallTextXY("ARMING REMOTE DESTRUCTION RAY.",70,60,9,0,1,tb1_font,game_state->virtual_1);
vmwSmallTextXY("GOOD-BYE.",70,70,9,0,1,tb1_font,game_state->virtual_1);
vmwBlitMemToDisplay(game_state->graph_state,virtual_1);
pauseawhile(4);
}
if ((ch=='Y') || (ch=='y')) {
vmwArbitraryCrossBlit(game_state->virtual_3,0,79,58,37,
game_state->virtual_1,10,50);
vmwSmallTextXY("'Y'=CORRECT PASSWORD. ",70,50,2,0,1,tb1_font,game_state->virtual_1);
vmwSmallTextXY("WELCOME SUPREME TENTACLEE COMMANDER.",70,60,2,0,1,tb1_font,game_state->virtual_1);
vmwSmallTextXY("INITIATING TRACTOR BEAM AND AUTOMATIC",70,70,2,0,1,tb1_font,game_state->virtual_1);
vmwSmallTextXY("LANDING PROCEDURE.",70,80,2,0,1,tb1_font,game_state->virtual_1);
vmwSmallTextXY("WE WILL BE DEPARTING FOR THE PLANET",70,90,2,0,1,tb1_font,game_state->virtual_1);
vmwSmallTextXY("EERM IN THREE MICROCYCLE UNITS.",70,100,2,0,1,tb1_font,game_state->virtual_1);
vmwBlitMemToDisplay(game_state->graph_state,virtual_1);
pauseawhile(5);
game_state->level=3;
vmwClearKeyboardBuffer();
vmwArbitraryCrossBlit(game_state->virtual_3,0,42,58,37,
game_state->virtual_1,10,110);
vmwSmallTextXY("Wha? Wait!",70,110,9,0,1,tb1_font,game_state->virtual_1);
vmwSmallTextXY("What's happening?",70,120,9,0,1,tb1_font,game_state->virtual_1);
vmwBlitMemToDisplay(game_state->graph_state,virtual_1);
pauseawhile(6);
}
vmwLoadPicPacked(0,0,game_state->virtual_3,0,1,
tb1_data_file("level3/tbtract.tb1",game_state->path_to_data),
game_state->graph_state);
vmwArbitraryCrossBlit(game_state->virtual_3,0,0,240,50,
game_state->virtual_2,0,0);
vmwClearScreen(game_state->virtual_1,0);
setupsidebar(game_state,virtual_1);
for(howmuchscroll=50;howmuchscroll>0;howmuchscroll--) {
vmwArbitraryCrossBlit(virtual_2,0,howmuchscroll,240,200,virtual_1,0,0);
usleep(30000);
vmwPutSprite(ship_shape[0],shipx,165,virtual_1);
vmwBlitMemToDisplay(game_state->graph_state,virtual_1);
}
if ((ch=='N') || (ch=='n')) {
vmwClearKeyboardBuffer();
vmwLine(7,6,shipx+10,180,4,virtual_1);
vmwLine(shipx+37,180,231,6,4,virtual_1);
vmwBlitMemToDisplay(game_state->graph_state,virtual_1);
pauseawhile(1);
vmwClearKeyboardBuffer();
for(i=shipx;i<shipx+48;i++) {
vmwDrawVLine(i,165,30,4,virtual_1);
}
vmwBlitMemToDisplay(game_state->graph_state,virtual_1);
pauseawhile(2);
vmwArbitraryCrossBlit(virtual_2,0,howmuchscroll,240,200,virtual_1,0,0);
vmwBlitMemToDisplay(game_state->graph_state,virtual_1);
pauseawhile(2);
}
else {
if (shipx-95==0) shipadd=0;
if (shipx-95>0) shipadd=1;
if (shipx-95<0) shipadd=-1;
shipy=165;
while ((shipx!=95) || (shipy>10)) {
if (shipx!=95) shipx-=shipadd;
if (shipy>10) shipy--;
vmwArbitraryCrossBlit(virtual_2,0,howmuchscroll,240,200,virtual_1,0,0);
vmwLine(7,6,shipx+12,shipy+15,2,virtual_1);
vmwLine(shipx+37,shipy+15,231,6,2,virtual_1);
vmwPutSprite(ship_shape[0],shipx,shipy,virtual_1);
vmwBlitMemToDisplay(game_state->graph_state,virtual_1);
usleep(30000);
}
vmwClearKeyboardBuffer();
pauseawhile(8);
vmwClearScreen(virtual_1,0);
}
/*
while keypressed do ch:=readkey;
if level=4 then begin
vmwSmallTextXY('THE PLANET EERM?',20,20,10,0,1,tb1_font,game_state->virtual_1);
vmwSmallTextXY('XENOCIDE FLEET?',20,30,10,0,1,tb1_font,game_state->virtual_1);
vmwSmallTextXY('WHAT'S GOING ON?',20,40,10,0,1,tb1_font,game_state->virtual_1);
vmwSmallTextXY('A MAJOR GOVERNMENT CONSPIRACY? MASS HALUCINATIONS?',20,50,10,0,1,tb1_font,game_state->virtual_1);
vmwSmallTextXY('WATCH FOR TOM BOMBEM LEVEL 3 (CURRENTLY IN THE DESIGN PHASE).',10,70,12,0,1,tb1_font,game_state->virtual_1);
vmwSmallTextXY('ALL THESE QUESTIONS WILL BE ANSWERED!',10,80,12,0,1,tb1_font,game_state->virtual_1);
vmwSmallTextXY('ALSO MORE FEATURES WILL BE ADDED:',10,90,12,0,1,tb1_font,game_state->virtual_1);
vmwSmallTextXY(' BETTER GRAPHICS, SOUND AND SPEED.',10,100,12,0,1,tb1_font,game_state->virtual_1);
vmwSmallTextXY('TO HASTEN COMPLETION, SEND QUESTIONS/COMMENTS/DONATIONS TO ',9,120,9,0,1,tb1_font,game_state->virtual_1);
vmwSmallTextXY('THE AUTHOR (SEE THE REGISTER MESSAGE FOR RELEVANT ADDRESSES).',9,130,9,0,1,tb1_font,game_state->virtual_1);
vmwSmallTextXY('THANK YOU FOR PLAYING TOM BOMBEM',80,150,14,0,1,tb1_font,game_state->virtual_1);
unfade;
pauseawhile(1800);
end; */
levelover=1;
}
}
}
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),
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,
game_state->graph_state->default_font,game_state->virtual_1);
vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1);
pauseawhile(13);
vmwDrawBox(0,0,319,199,0,game_state->virtual_1);
}

View File

@ -1,202 +1,290 @@
31 31 31 31 31 31 31 31 31 31 31 31
5 7 5 5 5 5 5 5 5 5 7 5
5 5 3 5 30 30 30 30 5 3 5 5
5 5 5 5 4 4 4 4 5 5 5 5
15 15 15 15 31 31 31 31 15 15 15 15
17 17 17 17 16 16 16 16 17 17 17 17
9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9
7 9 9 9 9 9 9 9 9 9 9 7
9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9
12 9 9 9 12 9 9 12 9 9 9 12
9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9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 0 0 0 0 0
15 5 5 5 5 5 5 5 5 5 5 15
15 10 0 0 0 0 0 0 0 0 10 15
15 0 0 10 3 3 3 3 10 0 0 15
15 0 0 0 10 10 10 10 0 0 0 15
15 0 10 0 10 4 4 10 0 10 0 15
30 30 30 30 30 30 30 30 30 30 30 30
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
# Level 2 data
%SPRITEFILE tbaship.tb1
%SPRITEXSIZE 20
%SPRITEYSIZE 10
%SPRITEROWS 4
%SPRITECOLS 10
# NUM TYPE
%SPRITE 0 BACKGROUND
%SPRITE 1 BACKGROUND
%SPRITE 2 BACKGROUND
%SPRITE 3 BACKGROUND
%SPRITE 4 BACKGROUND
%SPRITE 5 BACKGROUND
%SPIRTE 6 BACKGROUND
%SPRITE 7 BACKGROUND
%SPRITE 8 BACKGROUND
%SPRITE 9 BACKGROUND
# Shoots ExplodesTo
%SPRITE 10 ENEMY_REFLECT 21 34
%SPRITE 11 ENEMY_SHOOT 26 34
%SPRITE 12 ENEMY_SHOOT 25 34
%SPRITE 13 ENEMY_SHOOT 25 34
%SPRITE 14 ENEMY_SHOOT 25 34
%SPRITE 15 OBSTRUCTION 34
%SPRITE 16 OBSTRUCTION 34
%SPRITE 17 OBSTRUCTION 34
%SPRITE 18 OBSTRUCTION 34
%SPRITE 19 OBSTRUCTION 34
%SPRITE 20 WEAPON 0
%SPRITE 21 ENEMY_WEAPON
%SPRITE 22
%SPRITE 23
%SPRITE 24
%SPRITE 25 ENEMY_WEAPON
%SPRITE 26 ENEMY_WEAPON
%SPRITE 27
%SPRITE 28
%SPRITE 29 BACKGROUND
%SPRITE 30 BACKGROUND
%SPRITE 31 BACKGROUND
%SPRITE 32 BACKGROUND
%SPRITE 33 BACKGROUND
# exploded, but same as backgroud
%SPRITE 34 BACKGROUND
%SPRITE 35 EXPLOSION 0
%SPRITE 36 EXPLOSION 1
%SPRITE 37 EXPLOSION 2
%SPRITE 38 EXPLOSION 3
%SPRITE 39 EXPLOSION 4
%DATALENGTH 222
%DATAWIDTH 12
%DATABEGIN
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 1 0 1 0 4 0 0 0 4 0 0
0 1 0 1 0 4 0 0 0 4 0 0
0 1 0 1 0 4 0 4 0 4 0 0
0 0 1 0 0 0 4 0 4 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
30 30 30 30 30 30 30 30 30 30 30 30
15 0 10 0 10 4 4 10 0 10 0 15
15 0 0 0 10 10 10 10 0 0 0 15
15 0 0 10 3 3 3 3 10 0 0 15
15 10 0 0 0 0 0 0 0 0 10 15
15 5 5 5 5 5 5 5 5 5 5 15
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
16 13 16 16 16 16 16 16 16 16 13 16
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
11 0 0 0 0 0 0 0 0 0 0 11
0 0 0 0 0 0 10 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 10 0
0 0 0 0 0 0 0 0 13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 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 12 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 13 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 11 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 10 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 18 0 0 0 0 0 0 0
0 0 0 0 0 0 0 19 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
2 2 18 19 0 0 0 0 19 18 2 2
0 0 0 0 0 0 0 0 0 0 0 0
30 30 30 30 30 30 30 30 30 30 30 30
9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9
12 9 9 9 12 9 9 12 9 9 9 12
9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9
7 9 9 9 9 9 9 9 9 9 9 7
9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9
17 17 17 17 16 16 16 16 17 17 17 17
15 15 15 15 31 31 31 31 15 15 15 15
5 5 5 5 4 4 4 4 5 5 5 5
5 5 3 5 30 30 30 30 5 3 5 5
5 7 5 5 5 5 5 5 5 5 7 5
31 31 31 31 31 31 31 31 31 31 31 31
29 29 29 29 29 29 29 29 29 29 29 29
29 29 29 33 29 29 29 29 29 29 29 29
29 29 29 29 29 29 29 29 29 32 29 29
32 29 29 29 29 29 29 29 29 29 29 29
29 29 29 29 29 29 33 29 29 29 29 29
29 29 29 29 29 29 29 29 33 29 29 29
29 29 33 29 29 29 29 29 29 29 29 32
29 29 29 29 29 29 29 29 29 29 29 29
29 29 29 29 29 29 29 29 29 32 29 29
29 29 29 29 29 29 29 29 29 29 29 29
29 29 29 29 33 29 29 29 29 29 29 29
29 29 32 29 29 29 29 33 29 29 29 29
29 29 29 29 29 29 29 29 29 29 29 29
29 29 29 29 29 29 29 29 29 29 29 29
29 29 29 29 29 29 29 29 32 29 29 29
29 33 29 29 29 29 29 29 29 29 29 29
29 29 29 29 29 29 29 29 29 29 29 32
29 29 29 29 29 32 29 29 29 29 29 29
29 29 32 29 29 29 29 29 29 29 29 29
29 29 29 29 29 29 29 29 33 29 29 29
%DATAEND
31 31 31 31 31 31 31 31 31 31
%DATAEND

View File

@ -1,273 +0,0 @@
# Level 2 data
%SPRITEFILE tbaship.tb1
%SPRITEXSIZE 20
%SPRITEYSIZE 10
%SPRITEROWS 4
%SPRITECOLS 10
# NUM TYPE
%SPRITE 0 BACKGROUND
%SPRITE 1 BACKGROUND
%SPRITE 2 BACKGROUND
%SPRITE 3 BACKGROUND
%SPRITE 4 BACKGROUND
%SPRITE 5 BACKGROUND
%SPIRTE 6 BACKGROUND
%SPRITE 7 BACKGROUND
%SPRITE 8 BACKGROUND
%SPRITE 9 BACKGROUND
# Shoots ExplodesTo
%SPRITE 10 ENEMY_REFLECT 21 34
%SPRITE 11 ENEMY_SHOOT 26 34
%SPRITE 12 ENEMY_SHOOT 25 34
%SPRITE 13 ENEMY_SHOOT 25 34
%SPRITE 14 ENEMY_SHOOT 25 34
%SPRITE 15 OBSTRUCTION 34
%SPRITE 16 OBSTRUCTION 34
%SPRITE 17 OBSTRUCTION 34
%SPRITE 18 OBSTRUCTION 34
%SPRITE 19 OBSTRUCTION 34
%SPRITE 20 WEAPON 0
%SPRITE 21 ENEMY_WEAPON
%SPRITE 22
%SPRITE 23
%SPRITE 24
%SPRITE 25 ENEMY_WEAPON
%SPRITE 26 ENEMY_WEAPON
%SPRITE 27
%SPRITE 28
%SPRITE 29 BACKGROUND
%SPRITE 30 BACKGROUND
%SPRITE 31 BACKGROUND
%SPRITE 32 BACKGROUND
%SPRITE 33 BACKGROUND
# exploded, but same as backgroud
%SPRITE 34 BACKGROUND
%SPRITE 35 EXPLOSION 0
%SPRITE 36 EXPLOSION 1
%SPRITE 37 EXPLOSION 2
%SPRITE 38 EXPLOSION 3
%SPRITE 39 EXPLOSION 4
%DATALENGTH 202
%DATAWIDTH 12
%DATABEGIN
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 1 0 1 0 4 0 0 0 4 0 0
0 1 0 1 0 4 0 0 0 4 0 0
0 1 0 1 0 4 0 4 0 4 0 0
0 0 1 0 0 0 4 0 4 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
30 30 30 30 30 30 30 30 30 30 30 30
15 0 10 0 10 4 4 10 0 10 0 15
15 0 0 0 10 10 10 10 0 0 0 15
15 0 0 10 3 3 3 3 10 0 0 15
15 10 0 0 0 0 0 0 0 0 10 15
15 5 5 5 5 5 5 5 5 5 5 15
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
16 13 16 16 16 16 16 16 16 16 13 16
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0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DATAEND
5 5 5 5 4 4 4 4 5 5 5 5
5 5 3 5 30 30 30 30 5 3 5 5
5 7 5 5 5 5 5 5 5 5 7 5
31 31 31 31 31 31 31 31 31 31 31 31
%DATAEND

202
data/level2/level2.dat.old Normal file
View File

@ -0,0 +1,202 @@
31 31 31 31 31 31 31 31 31 31 31 31
5 7 5 5 5 5 5 5 5 5 7 5
5 5 3 5 30 30 30 30 5 3 5 5
5 5 5 5 4 4 4 4 5 5 5 5
15 15 15 15 31 31 31 31 15 15 15 15
17 17 17 17 16 16 16 16 17 17 17 17
9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9
7 9 9 9 9 9 9 9 9 9 9 7
9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9
12 9 9 9 12 9 9 12 9 9 9 12
9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9
30 30 30 30 30 30 30 30 30 30 30 30
0 0 0 0 0 0 0 0 0 0 0 0
2 2 18 19 0 0 0 0 19 18 2 2
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 19 0 0 0 0
0 0 0 0 18 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 10 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 11 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 13 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 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0 0 0 0 0
0 14 0 0 0 0 0 0 0 0 14 0
0 0 0 0 0 0 0 0 13 0 0 0
0 0 0 0 0 0 0 0 0 0 10 0
0 0 0 0 0 0 10 0 0 0 0 0
11 0 0 0 0 0 0 0 0 0 0 11
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
16 13 16 16 16 16 16 16 16 16 13 16
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
15 5 5 5 5 5 5 5 5 5 5 15
15 10 0 0 0 0 0 0 0 0 10 15
15 0 0 10 3 3 3 3 10 0 0 15
15 0 0 0 10 10 10 10 0 0 0 15
15 0 10 0 10 4 4 10 0 10 0 15
30 30 30 30 30 30 30 30 30 30 30 30
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0

View File

@ -1,22 +1,229 @@
/*
* Level 2 Engine Code for Tom Bombem
* */
/* The Includes */
#include <stdio.h>
#include <sys/time.h>
#include <unistd.h>
#include <stdlib.h>
#include "svmwgraph/svmwgraph.h"
#include "tb1_state.h"
#include "levels.h"
#include "tblib.h"
#include "sound.h"
#include <string.h> /* strncmp */
#include <unistd.h> /* usleep */
#include <stdlib.h> /* free */
#include <sys/time.h> /* gettimeofday */
#include "./svmwgraph/svmwgraph.h"
#include "tb1_state.h"
#include "tblib.h"
#include "graphic_tools.h"
#include "sidebar.h"
#include "sound.h"
#include "help.h"
#include "loadsave.h"
#include "graphic_tools.h"
#define ROW_WIDTH 12
#define COL_HEIGHT 20
/* #define DEBUG 1 */
struct sprite_type {
int initialized;
int type;
int shoots;
int explodes;
vmwSprite *data;
};
struct level2_data {
int xsize,ysize,rows,cols;
int numsprites;
struct sprite_type **sprites;
int level_length,level_width;
unsigned char **level_data;
};
#define SPRITE_BACKGROUND 0
#define SPRITE_ENEMY_SHOOT 1
#define SPRITE_ENEMY_REFLECT 2
#define SPRITE_ENEMY_WEAPON 3
#define SPRITE_OBSTRUCTION 4
#define SPRITE_EXPLOSION 5
#define SPRITE_WEAPON 6
#define SPRITE_POWERUP 7
struct text_mapping_type {
char name[30];
int size;
int type;
} text_mapping[] = { {"BACKGROUND", 10, SPRITE_BACKGROUND},
{"ENEMY_SHOOT", 11, SPRITE_ENEMY_SHOOT},
{"ENEMY_REFLECT", 13, SPRITE_ENEMY_REFLECT},
{"ENEMY_WEAPON", 12, SPRITE_ENEMY_WEAPON},
{"OBSTRUCTION", 11, SPRITE_OBSTRUCTION},
{"EXPLOSION", 9, SPRITE_EXPLOSION},
{"WEAPON", 6, SPRITE_WEAPON},
{"POWERUP", 7, SPRITE_POWERUP},
{"DONE", 4, 0xff},
{ }
};
int belongs_on_map(int type) {
switch (type) {
case SPRITE_BACKGROUND:
case SPRITE_ENEMY_SHOOT:
case SPRITE_ENEMY_REFLECT:
case SPRITE_OBSTRUCTION: return 1;
default: return 0;
}
return 0;
}
int map_string_to_type(char *string) {
int i=0;
while(text_mapping[i].type!=0xff) {
if (!strncmp(text_mapping[i].name,string,text_mapping[i].size)) {
printf("%s %i\n",string,text_mapping[i].type);
return text_mapping[i].type;
}
i++;
}
return -1;
}
struct level2_data *parse_data_file(char *filename) {
FILE *fff;
char tempst[255],sprite_file[255],throwaway[255];
char type[255];
int number,shoots,explodes,count,i,numsprites,tempint;
struct level2_data *data;
fff=fopen(filename,"r");
if (fff==NULL) {
printf("Cannot open %s\n",filename);
return NULL;
}
data=(struct level2_data *)malloc(sizeof(struct level2_data));
/* Pass 1 */
do {
fgets(tempst,254,fff);
switch (tempst[0]) {
case '%':
if (!strncmp(tempst,"%SPRITEFILE",11)) {
sscanf(tempst,"%s %s",throwaway,sprite_file);
}
if (!strncmp(tempst,"%SPRITEXSIZE",11)) {
sscanf(tempst,"%s %d",throwaway,&data->xsize);
}
if (!strncmp(tempst,"%SPRITEYSIZE",11)) {
sscanf(tempst,"%s %d",throwaway,&data->ysize);
}
if (!strncmp(tempst,"%SPRITEROWS",11)) {
sscanf(tempst,"%s %d",throwaway,&data->rows);
}
if (!strncmp(tempst,"%SPRITECOLS",11)) {
sscanf(tempst,"%s %d",throwaway,&data->cols);
}
}
} while (!feof(fff));
/* Pass 2 */
numsprites=(data->rows) * (data->cols);
data->numsprites=numsprites;
data->sprites=calloc( numsprites, sizeof(struct sprite_type*));
for (i=0; i< numsprites;i++) {
data->sprites[i]=calloc(1,sizeof(struct sprite_type));
data->sprites[i]->initialized=0;
}
rewind(fff);
do {
fgets(tempst,254,fff);
switch(tempst[0]) {
case '%': if (!strncmp(tempst,"%SPRITE ",8)) {
count=sscanf(tempst,"%s %d %s %d %d",
throwaway,&number,type,&shoots,&explodes);
if (count > 2) {
data->sprites[number]->type=map_string_to_type(type);
data->sprites[number]->initialized=1;
}
if (count > 3) {
data->sprites[number]->shoots=shoots;
}
if (count > 4) {
data->sprites[number]->explodes=explodes;
}
}
if (!strncmp(tempst,"%DATALENGTH",10)) {
sscanf(tempst,"%s %d",throwaway,&data->level_length);
}
if (!strncmp(tempst,"%DATAWIDTH",9)) {
sscanf(tempst,"%s %d",throwaway,&data->level_width);
}
break;
}
} while (!feof(fff));
/* Pass 3 */
data->level_data=calloc(data->level_length, sizeof(char *));
data->level_data[0]=calloc(data->level_length * data->level_width,sizeof(char));
for(i=1;i<data->level_length;i++) {
data->level_data[i]=data->level_data[0]+ (i*data->level_width*sizeof(char));
}
rewind(fff);
do {
fgets(tempst,254,fff);
} while (strncmp(tempst,"%DATABEGIN",10));
i=0;
while(i<data->level_length*data->level_width) {
/* Grrrrr */
// fscanf(fff,"%d",(int *)data->level_data[0]);
fscanf(fff,"%d",&tempint);
*(data->level_data[0]+i)=(char)tempint;
i++;
}
#ifdef DEBUG
print_level(data);
printf("Sprite File: %s\n",sprite_file);
printf("Sprite size: %ix%i\n",data->xsize,data->ysize);
printf("Sprite array: %ix%i\n",data->rows,data->cols);
printf("Level length: %i\n",data->level_length);
#endif
fclose(fff);
return data;
}
int free_level2_data(struct level2_data *data) {
/* IMPLEMENT THIS */
return 0;
}
/* Define this to get a frames per second readout */
/* #define DEBUG_ON */
@ -42,48 +249,62 @@ struct enemyinfo {
int hitsneeded;
};
struct bulletinfo {
int out,x,y;
struct bullet_info_type {
int out,type,x,y;
struct bullet_info_type *next,*prev;
};
struct obstruction {
struct bullet_root_type {
int howmany,allowed;
struct bullet_info_type *head,*tail;
};
struct obstruction_type {
int x,y;
int shooting,dead,exploding;
int explodeprogress;
int type;
int exploding;
int howmanyhits;
int kind,lastshot;
int lastshot;
struct obstruction_type *next;
};
void leveltwoengine(tb1_state *game_state)
#define BULLETS_MAX 3
void leveltwoengine(tb1_state *game_state, char *shipfile, char *levelfile,
char *spritefile,char *level_num, char *level_desc,
void *close_function)
{
int ch,i;
char tempst[BUFSIZ];
int k,game_paused=0,speed_factor=1;
int shipx=36,shipy;
int whatdelay=1;
FILE *f=NULL;
int levelover=0,j,backrow=0;
int background[201][13];
struct enemyinfo enemy[10];
struct bulletinfo bullet[4];
int levelover=0,j,offscreen_row=0;
struct enemyinfo *enemy;
struct bullet_root_type *bullet_root;
struct bullet_info_type **bullet_info;
struct bullet_info_type *temp_bullet=NULL;
struct timeval timing_info;
struct timezone dontcare;
long oldsec,oldusec,time_spent;
int howmuchscroll=0;
struct obstruction passive[50];
int howmuchscroll=200; /* there is a reason for this */
struct obstruction_type obstruction_heap[20][12];
int shipadd=0,shipframe=1;
int our_row,our_shape,rows_goneby=0;
int grapherror;
int done_waiting,type;
vmwFont *tb1_font;
vmwVisual *virtual_1;
vmwVisual *virtual_2;
vmwSprite *ship_shape[3];
vmwSprite *shape_table[40];
int enemies_drawn[200];
struct level2_data *data;
/* For convenience */
tb1_font=game_state->graph_state->default_font;
virtual_1=game_state->virtual_1;
@ -93,9 +314,9 @@ void leveltwoengine(tb1_state *game_state)
game_state->begin_score=game_state->score;
game_state->begin_shields=game_state->shields;
/* Load Sprites */
/* Load Sprite Data */
grapherror=vmwLoadPicPacked(0,0,virtual_1,1,1,
tb1_data_file("level1/ships.tb1",
tb1_data_file(shipfile,
game_state->path_to_data),
game_state->graph_state);
@ -104,53 +325,56 @@ void leveltwoengine(tb1_state *game_state)
ship_shape[2]=vmwGetSprite(0,64,48,30,virtual_1);
if (game_state->level==2) vmwLoadPicPacked(0,0,virtual_1,1,1,
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),
/* Load Level Data */
data=parse_data_file(tb1_data_file(levelfile,game_state->path_to_data));
vmwLoadPicPacked(0,0,virtual_1,1,1,
tb1_data_file(spritefile,game_state->path_to_data),
game_state->graph_state);
for(j=0;j<4;j++)
for(i=0;i<10;i++)
shape_table[j*10+i]=vmwGetSprite(1+i*21,1+j*11,20,10,virtual_1);
for(j=0;j<data->rows;j++)
for(i=0;i<data->cols;i++)
data->sprites[j*10+i]->data=vmwGetSprite(1+i*21,1+j*11,20,10,virtual_1);
/* Load Background Data */
if (game_state->level==2)
f=fopen(tb1_data_file("level2/level2.dat",game_state->path_to_data),"r");
if (game_state->level==4)
f=fopen(tb1_data_file("level4/level4.dat",game_state->path_to_data),"r");
if (f==NULL)
printf("ERROR! Could't open level %d data!\n",game_state->level);
for(j=0;j<200;j++)
for(i=0;i<12;i++) fscanf(f,"%d",&background[j][i]);
fclose(f);
/* Initialize Structures for enemy, bullets, and background */
for(i=0;i<50;i++) {
passive[i].dead=1;
passive[i].exploding=0;
/* Initialize Structures for background */
bullet_info=calloc(5,sizeof(struct bullet_info_type *));
bullet_info[0]=calloc(5,sizeof(struct bullet_info_type));
for (i=1;i<5;i++) bullet_info[i]=bullet_info[0]+i*sizeof(struct bullet_info_type);
bullet_root=malloc(sizeof(struct bullet_root_type));
bullet_root->howmany=0;
bullet_root->allowed=5;
bullet_root->head=NULL;
bullet_root->tail=NULL;
for(i=0;i<bullet_root->allowed;i++) {
bullet_info[i]->out=0;
}
for(i=0;i<10;i++) enemy[i].out=0;
for(i=0;i<3;i++) {
bullet[i].out=0;
bullet[i].x=0;
bullet[i].y=0;
}
for(i=0;i<200;i++) enemies_drawn[i]=0;
/* Initialize structures for obstructions */
/* Waste lots of RAM in name of speed. */
/* Never would have done this on the original Pascal DOS version */
// obstruction_heap=calloc(20*12,sizeof(struct obstruction_type));
// for(i=0;i<20;i++) {
// obstructions[i]=obstruction_heap+(i*12*sizeof(struct obstruction_type));
// }
for(j=0;j<20;j++) {
for(i=0;i<12;i++) {
// obstructions[j][i].next=NULL;
}
}
/* Announce the Start of the Level */
vmwDrawBox(0,0,320,200,0,virtual_1);
coolbox(70,85,240,120,1,virtual_1);
if (game_state->level==2) {
vmwTextXY(" LEVEL TWO:",84,95,4,7,0,tb1_font,virtual_1);
vmwTextXY("THE \"PEACE ENVOY\"",84,105,4,7,0,tb1_font,virtual_1);
}
if (game_state->level==4) {
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);
}
vmwTextXY(level_num,84,95,4,7,0,tb1_font,virtual_1);
vmwTextXY(level_desc,84,105,4,7,0,tb1_font,virtual_1);
vmwBlitMemToDisplay(game_state->graph_state,virtual_1);
vmwClearKeyboardBuffer();
pauseawhile(5);
@ -162,45 +386,114 @@ void leveltwoengine(tb1_state *game_state)
vmwDrawBox(251,52,63,7,0,virtual_2);
vmwTextXY(tempst,307,51,12,0,0,tb1_font,virtual_2);
/* 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,virtual_2);
vmwPutSprite(shape_table[33],rand()%238,rand()%150,virtual_2);
}
change_shields(game_state);
/* Ready the timing loop */
gettimeofday(&timing_info,&dontcare);
oldsec=timing_info.tv_sec; oldusec=timing_info.tv_usec;
/* Get the initial background ready */
offscreen_row=data->level_length-(COL_HEIGHT*2);
for(i=0;i<ROW_WIDTH;i++) {
for(j=0;j<40;j++) {
vmwPutSpriteNonTransparent(data->sprites[(int) *(data->level_data[offscreen_row+j]+i)]->data,
i*20,j*10,virtual_2);
}
}
offscreen_row-=20;
/* Get the initial obstructions ready */
our_row=data->level_length-20;
for(j=0;j<20;j++) {
for(i=0;i<12;i++) {
type=data->sprites[*(data->level_data[our_row]+i)]->type;
if ((type==SPRITE_OBSTRUCTION) ||
(type==SPRITE_ENEMY_SHOOT) ||
(type==SPRITE_ENEMY_REFLECT)) {
k=0;
// temp_obstruct=obstructions[j];
// while(temp_obstruct->next!=NULL) temp_obstruct=temp_obstruct->next;
// temp_obstruct->next=temp_obstruct+1;
// temp_obstruct=temp_obstruct->next;
// temp_obstruct->x=i*20;
// temp_obstruct->y=j*20;
// temp_obstruct->type=type;
// temp_obstruct->exploding=0;
// temp_obstruct->lastshot=0;
// temp_obstruct->next=NULL;
}
}
}
vmwArbitraryCrossBlit(virtual_2,0,0+howmuchscroll,240,200,
virtual_1,0,0);
/**** GAME LOOP ****/
while (!levelover) {
ch=0;
/* Scroll the Background */
if (speed_factor>1) howmuchscroll-=speed_factor;
else howmuchscroll--;
/* If used up all the buffered background, draw some more */
if (howmuchscroll<0) {
howmuchscroll=200+howmuchscroll;
/* Copy half of old downward */
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];
// printf("Shape : %i\n",our_shape);
vmwPutSprite(shape_table[our_shape],
/* Load 20 rows of data preceding it */
for(i=0;i<12;i++) {
for(j=0;j<20;j++) {
vmwPutSprite(data->sprites[(int) *(data->level_data[offscreen_row+j]+i)]->data,
i*20,j*10,virtual_2);
}
backrow+=20;
}
offscreen_row-=20;
}
/* Setup Obstructions */
our_row=rows_goneby/10;
if (rows_goneby%10==0) {
/* move all rows down by one, dropping old off end */
// memmove(obstructions[1],obstructions[0],19*20*sizeof(struct obstruction_type));
// obstructions[0]->next=NULL;
our_row--;
printf("ROW %i\n",our_row);
// temp_obstruct=obstructions[0];
for(i=0;i<12;i++) {
type=data->sprites[*(data->level_data[our_row]+i)]->type;
printf("%3i ",type);
if ((type==SPRITE_OBSTRUCTION) ||
(type==SPRITE_ENEMY_SHOOT) ||
(type==SPRITE_ENEMY_REFLECT)) {
printf("*");
// printf("Enemy %i on row %i\n",type,our_row);
// fflush(stdout);
// while(temp_obstruct->next!=NULL) temp_obstruct=temp_obstruct->next;
// temp_obstruct->next=temp_obstruct+1;
// temp_obstruct=temp_obstruct+1;
// temp_obstruct->x=i*20;
// temp_obstruct->y=j*20;
// temp_obstruct->type=type;
// temp_obstruct->exploding=0;
// temp_obstruct->lastshot=0;
// temp_obstruct->next=NULL;
}
}
printf("\n"); fflush(stdout);
}
#if 0
if (!enemies_drawn[our_row]) {
enemies_drawn[our_row]=1;
for(i=0;i<12;i++) {
our_shape=background[our_row][i];
// our_shape=background[our_row][i];
if ((our_shape>9)&&(our_shape<20)) {
k=0;
while ((!passive[k].dead) && (k<40)) k++;
@ -216,14 +509,33 @@ void leveltwoengine(tb1_state *game_state)
}
}
}
#endif
/* Flip the far background to vaddr */
/* Flip the far background to regular background */
vmwArbitraryCrossBlit(virtual_2,0,0+howmuchscroll,240,200,
virtual_1,0,0);
/***Collision Check***/
for(i=0;j<bullet_root->howmany;j++) {
// temp_obstruct=obstructions[ (bullet_info[i]->y)/10];
// printf("%p %p\n",temp_obstruct,temp_obstruct->next);
printf("Row %i\n",(bullet_info[i]->y)/10); fflush(stdout);
// while (temp_obstruct->next!=NULL) {
// temp_obstruct=temp_obstruct->next;
// if ( ( (bullet_info[i]->x-3) >= temp_obstruct->x) &&
// ( bullet_info[i]->x <= (temp_obstruct->x+20))) {
// printf("BOOM\n"); fflush(stdout);
// }
// }
}
#if 0
for(i=0;i<40;i++)
if ((!passive[i].dead) && (!passive[i].exploding)) {
for(j=0;j<3;j++) {
@ -263,9 +575,9 @@ void leveltwoengine(tb1_state *game_state)
passive[i].dead=1;
game_state->shields--;
if(game_state->shields<0) levelover=1;
vmwPutSprite(shape_table[34],
passive[i].x,passive[i].y+howmuchscroll,
virtual_1);
// vmwPutSprite(shape_table[34],
// passive[i].x,passive[i].y+howmuchscroll,
// virtual_1);
change_shields(game_state);
}
}
@ -288,30 +600,58 @@ void leveltwoengine(tb1_state *game_state)
for(i=0;i<40;i++)
if (passive[i].exploding) {
passive[i].explodeprogress++;
vmwPutSprite(shape_table[35+passive[i].explodeprogress],
passive[i].x,passive[i].y+howmuchscroll,
virtual_2);
// vmwPutSprite(shape_table[35+passive[i].explodeprogress],
// passive[i].x,passive[i].y+howmuchscroll,
// 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,
virtual_2);
// vmwPutSprite(shape_table[34],
// passive[i].x,passive[i].y+howmuchscroll,
// virtual_2);
}
}
/***MOVE BULLET***/
for(i=0;i<3;i++) {
if (bullet[i].out) {
if (speed_factor>1) bullet[i].y-=(5*speed_factor);
else bullet[i].y-=5;
if (bullet[i].y<5) bullet[i].out=0;
else vmwPutSprite(shape_table[20],
bullet[i].x,bullet[i].y,
virtual_1);
}
#endif
/***MOVE BULLETS***/
temp_bullet=bullet_root->head;
while(temp_bullet!=NULL) {
if (speed_factor>1) temp_bullet->y-=(5*speed_factor);
else temp_bullet->y-=5;
if (temp_bullet->y<5) {
temp_bullet->out=0;
bullet_root->howmany--;
/* Remove bullet from linked list */
if (bullet_root->head==temp_bullet) {
bullet_root->head=temp_bullet->next;
}
if (bullet_root->tail==temp_bullet) {
bullet_root->tail=temp_bullet->prev;
}
if (temp_bullet->prev!=NULL) {
if (temp_bullet->next!=NULL)
temp_bullet->prev->next=temp_bullet->next;
else temp_bullet->prev->next=NULL;
}
if (temp_bullet->next!=NULL) {
if (temp_bullet->prev!=NULL)
temp_bullet->next->prev=temp_bullet->prev;
else temp_bullet->next->prev=NULL;
}
}
else vmwPutSprite(data->sprites[temp_bullet->type]->data,
temp_bullet->x,temp_bullet->y,virtual_1);
temp_bullet=temp_bullet->next;
}
#if 0
/***MOVE ENEMIES***/
for(j=0;j<40;j++) {
if (!passive[j].dead) {
@ -338,15 +678,16 @@ void leveltwoengine(tb1_state *game_state)
for(j=0;j<10;j++) {
if (enemy[j].out) {
vmwPutSprite(shape_table[enemy[j].kind],
enemy[j].x,enemy[j].y,
virtual_1);
// vmwPutSprite(shape_table[enemy[j].kind],
// enemy[j].x,enemy[j].y,
// 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;
}
}
#endif
/***READ KEYBOARD***/
if ((ch=vmwGetInput())!=0) {
switch(ch) {
@ -368,31 +709,53 @@ void leveltwoengine(tb1_state *game_state)
case VMW_F2: game_paused=1;
savegame(game_state);
break;
case ' ': for(j=0;j<3;j++)
if (!bullet[j].out) {
if ((game_state->sound_possible)&&(game_state->sound_enabled))
playGameFX(SND_CC);
bullet[j].out=1;
bullet[j].x=shipx+21;
bullet[j].y=165;
vmwPutSprite(shape_table[20],
bullet[j].x,bullet[j].y,virtual_1);
j=4;
case ' ': if (bullet_root->howmany<BULLETS_MAX) {
/* Find empty slot */
for (j=0;j<bullet_root->allowed;j++) {
if (!bullet_info[j]->out) {
temp_bullet=bullet_info[j];
break;
}
}
bullet_root->howmany++;
temp_bullet->out=1;
temp_bullet->type=20; /* FIXME */
if ((game_state->sound_possible)&&(game_state->sound_enabled))
playGameFX(SND_CC);
temp_bullet->x=shipx+21;
temp_bullet->y=165;
temp_bullet->next=NULL;
/* Insert in linked list */
if (bullet_root->head==NULL) {
bullet_root->head=temp_bullet;
bullet_root->tail=temp_bullet;
temp_bullet->prev=NULL;
}
else {
temp_bullet->prev=bullet_root->tail;
bullet_root->tail->next=temp_bullet;
bullet_root->tail=temp_bullet;
}
/* Draw Bullet */
vmwPutSprite(data->sprites[temp_bullet->type]->data,
temp_bullet->x,temp_bullet->y,virtual_1);
}
}
}
/***MOVE SHIP***/
if (speed_factor>1) {
shipx+=(shipadd*speed_factor);
rows_goneby+=(speed_factor);
}
else {
// if (speed_factor>1) {
// shipx+=(shipadd*speed_factor);
// rows_goneby+=(speed_factor);
// }
// else {
shipx+=shipadd;
rows_goneby++;
}
// }
if (shipx<1) shipx=1;
if (shipx>190) shipx=190;
switch(shipframe) {
@ -410,34 +773,32 @@ void leveltwoengine(tb1_state *game_state)
/* Flip Pages */
vmwBlitMemToDisplay(game_state->graph_state,virtual_1);
/* Calculate how much time has passed */
gettimeofday(&timing_info,&dontcare);
time_spent=timing_info.tv_usec-oldusec;
if (timing_info.tv_sec-oldsec) time_spent+=1000000;
#ifdef DEBUG_ON
printf("%f\n",1000000/(float)time_spent);
#endif
/* If time passed was too little, wait a bit */
while (time_spent<33000){
gettimeofday(&timing_info,&dontcare);
usleep(5);
time_spent=timing_info.tv_usec-oldusec;
if (timing_info.tv_sec-oldsec) time_spent+=1000000;
}
/* It game is paused, don't keep track of time */
/* If time passed was too little, wait a bit */
/* 33,333 would frame rate to 30Hz */
/* Linux w 100Hz scheduling only gives +- 10000 accuracy */
done_waiting=0;
while (!done_waiting) {
gettimeofday(&timing_info,&dontcare);
time_spent=timing_info.tv_usec-oldusec;
/* Assume we don't lag more than a second */
/* Seriously, if we lag more than 10ms we are screwed anyway */
if (time_spent<0) time_spent+=1000000;
if (time_spent<30000) usleep(100);
else (done_waiting=1);
}
oldusec=timing_info.tv_usec;
oldsec=timing_info.tv_sec;
/* If game is paused, don't keep track of time */
if (game_paused) {
gettimeofday(&timing_info,&dontcare);
oldusec=timing_info.tv_usec;
oldsec=timing_info.tv_sec;
game_paused=0;
speed_factor=1;
}
else {
speed_factor=(time_spent/30000);
oldusec=timing_info.tv_usec;
oldsec=timing_info.tv_sec;
}

3
level2_engine.h Normal file
View File

@ -0,0 +1,3 @@
void leveltwoengine(tb1_state *game_state, char *shipfile, char *levelfile,
char *spritefile,char *level_num, char *level_desc,
void *close_function);

View File

@ -771,7 +771,7 @@ void LevelOneEngine(tb1_state *game_state) {
oldusec=timing_info.tv_usec;
oldsec=timing_info.tv_sec;
/* It game is paused, don't keep track of time */
/* If game is paused, don't keep track of time */
if (game_paused) {
gettimeofday(&timing_info,&dontcare);

View File

@ -1,6 +1,5 @@
void LevelOneEngine(tb1_state *game_state);
void LevelOneLittleOpener(tb1_state *game_state);
void leveltwoengine(tb1_state *game_state);
void littleopener2(tb1_state *game_state);
void LevelThreeEngine(tb1_state *game_state);
void LevelThreeLittleOpener(tb1_state *game_state);

View File

@ -7,6 +7,7 @@
#include "graphic_tools.h"
#include "levels.h"
#include "level2_engine.h"
#include "hiscore.h"
void playthegame(tb1_state *game_state)
@ -26,7 +27,9 @@ void playthegame(tb1_state *game_state)
if (game_state->level==2) littleopener2(game_state);
}
if (game_state->level==2) {
leveltwoengine(game_state);
leveltwoengine(game_state,"level1/ships.tb1","level2/level2.dat",
"level2/tbaship.tb1"," LEVEL TWO:",
"THE \"PEASE ENVOY\"",NULL);
if (game_state->level==3) LevelThreeLittleOpener(game_state);
}
if (game_state->level==3) {
@ -34,7 +37,9 @@ void playthegame(tb1_state *game_state)
}
if (game_state->level==4) {
leveltwoengine(game_state);
leveltwoengine(game_state,"level1/ships.tb1","level4/level4.dat",
"level4/tbeerm.tb1"," LEVEL FOUR:"," THE PLANET EERM",
NULL);
}
coolbox(70,85,170,110,1,game_state->virtual_1);
vmwTextXY("GAME OVER",84,95,4,7,0,

View File

@ -1,11 +1,8 @@
/* The OpenGL hooks for the Super VMW graphics library */
/* based on the "glxheads.c" file from the Mesa 3.4 demos distribution */
#include <SDL/SDL.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glx.h>
#include "svmwgraph.h"
#include <stdlib.h> /* For atexit() */
@ -15,7 +12,11 @@ static float rotation=0.0;
unsigned char palette[256][4];
#define TEXTURE_SIZE 32
#define TEXTURE_SIZE 64
int texture_grid[5][4];
GLubyte *texture_data[5][4];
typedef struct {
GLubyte *texture_data;
@ -23,111 +24,104 @@ typedef struct {
GLfloat x1,y1,x2,y2;
} texture_block;
texture_block *texture_grid;
texture_block *current_texture;
GLuint temp_texture_name;
int texnumx,texnumy;
static Display *display;
static Window win;
static GLXContext ctx;
void reshape(int w,int h) {
glViewport(0,0,(GLsizei)w,(GLsizei)h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0,(GLfloat)w/(GLfloat)h,1.0,100.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//glTranslatef(0.0,0.0,-3.6);
}
/* Setup the Graphics */
/* Pass '0' to auto-detect bpp */
void *openGL_setupGraphics(int *xsize,int *ysize,int *bpp,
int fullscreen,int verbose) {
int scrnum,x,y;
XSetWindowAttributes attr;
Window root;
XVisualInfo *visinfo;
unsigned long mask;
XSizeHints sizehints;
int attrib[] = { GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_DOUBLEBUFFER,
None };
display=XOpenDisplay(NULL);
if (display==NULL) {
printf("Unable to open X display!\n");
return NULL;
}
scrnum=DefaultScreen(display);
root=RootWindow(display,scrnum);
visinfo=glXChooseVisual(display,scrnum,attrib);
if (visinfo==NULL) {
printf("Unable to make RGB double-buffered visual\n");
return NULL;
}
/* Window Attributes */
attr.background_pixel=0;
attr.border_pixel=0;
attr.colormap=XCreateColormap(display,root,visinfo->visual,AllocNone);
attr.event_mask=StructureNotifyMask | ExposureMask | KeyPressMask;
mask =CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
win = XCreateWindow(display,root,0,0,640,400,
0,visinfo->depth,InputOutput,visinfo->visual,mask,
&attr);
if (!win) {
printf("Could not create X-window!\n");
return NULL;
}
sizehints.x=10;
sizehints.y=10;
sizehints.width=640;
sizehints.height=400;
sizehints.flags=USSize | USPosition;
XSetNormalHints(display,win,&sizehints);
XSetStandardProperties(display,win,NULL,NULL,
None,(char **)NULL,0,&sizehints);
ctx=glXCreateContext(display,visinfo,NULL,True);
if (ctx==NULL) {
printf("Can't create GLX context!\n");
return NULL;
}
XMapWindow(display,win);
if (!glXMakeCurrent(display,win,ctx)) {
printf("glXMakeCurrent failed!\n");
return NULL;
}
printf(" GL_VERSION: %s\n", glGetString(GL_VERSION));
printf(" GL_VENDOR: %s\n", glGetString(GL_VENDOR));
printf(" GL_RENDERER: %s\n", glGetString(GL_RENDERER));
glClearColor(0.0,0.0,0.0,0.0);
glShadeModel(GL_FLAT);
// glShadeModel(GL_SMOOTH);
// glEnable(GL_POLYGON_SMOOTH);
// glEnable(GL_BLEND);
// glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
// for (i=0;i<NUM_TEXTURES;i++) {
// for (x=0;x<TEXTURE_SIZE;x++) {
// for (y=0;y<TEXTURE_SIZE;y++) {
// textureBlock[i][x][y][3]=255;
// }
// }
// }
printf("Init!\n"); fflush(stdout);
SDL_Surface *sdl_screen=NULL;
SDL_Joystick *joy;
int mode,x,y;
/* Initialize SDL */
if ( SDL_Init(SDL_INIT_VIDEO|SDL_INIT_JOYSTICK)<0) {
printf("Error trying to init SDL: %s\n",SDL_GetError());
return NULL;
}
if (fullscreen) mode=SDL_OPENGL | SDL_FULLSCREEN;
else mode=SDL_OPENGL;
/* Create the OpenGL screen */
if ( (sdl_screen=SDL_SetVideoMode(*xsize, *ysize, 0, mode)) == NULL ) {
printf("Unable to create OpenGL screen: %s\n", SDL_GetError());
SDL_Quit();
return NULL;
}
atexit(SDL_Quit);
SDL_WM_SetCaption("Tom Bombem...",NULL);
/* Try to init Joysticks */
if (SDL_NumJoysticks()>0){
/* Open joystick */
joy=SDL_JoystickOpen(0);
if (joy) {
printf("Opened Joystick 0\n");
printf("Name: %s\n", SDL_JoystickName(0));
SDL_JoystickEventState(SDL_ENABLE);
}
}
printf(" GL_VERSION: %s\n", glGetString(GL_VERSION));
printf(" GL_VENDOR: %s\n", glGetString(GL_VENDOR));
printf(" GL_RENDERER: %s\n", glGetString(GL_RENDERER));
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
glClearColor(0.0,0.0,0.0,0.0);
glClearDepth(1.0);
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glLoadIdentity();
reshape(*xsize,*ysize);
printf("Init!\n"); fflush(stdout);
// Initializing Textures!!
//
for(x=0;x<5;x++) {
for(y=0;y<4;y++) {
texture_data[x][y]=calloc(64*64,sizeof(char)*4);
glBindTexture(GL_TEXTURE_2D,texture_grid[x][y]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 64,
64 ,0,GL_RGBA,GL_UNSIGNED_BYTE,texture_data[x][y]);
}
}
#if 0
texnumx=320/TEXTURE_SIZE;
if (320%TEXTURE_SIZE) texnumx++;
texnumy=200/TEXTURE_SIZE;
@ -169,8 +163,9 @@ void *openGL_setupGraphics(int *xsize,int *ysize,int *bpp,
glOrtho(-20,340,-20,220,-100,100);
// gluPerspective(60,1.6,-10,10);
return (char *)(1);
#endif
return sdl_screen;
}
@ -193,18 +188,105 @@ void openGL_BlitMem(vmwSVMWGraphState *target_p, vmwVisual *source) {
int x=0,y=0,temp_col,i,j,ending_j,ending_i;
unsigned char *s_pointer;
GLubyte temp_data[64*64*4];
GLubyte *t_pointer;
GLubyte *t_pointer;
GLfloat light_position[]={0.0,0.0,25.0,0.0};
GLfloat light_ambient[]={0.65,0.65,0.65,1.0};
GLfloat lmodel_ambient[]={0.4,0.4,0.4,1.0};
GLfloat white_light[]={1.0,1.0,1.0,1.0};
if (!glXMakeCurrent(display,win,ctx)) {
printf("Error getting context!\n");
return;
}
glLoadIdentity();
gluLookAt(0.0,0.0,20.0,
0.0,0.0,0.0,
0.0,1.0,1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glLightfv(GL_LIGHT0, GL_DIFFUSE, white_light);
glLightfv(GL_LIGHT0, GL_SPECULAR,white_light);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(1,0,0);
{
GLfloat default_a[]={0.6,0.6,0.6,1.0
};
GLfloat default_d[]={ 0.8,0.8,0.8,1.0
};
GLfloat default_s[]={0.0,0.0,0.0,1.0
};
GLfloat default_e[]={0.0,0.0,0.0,1.0
};
glMaterialfv(GL_FRONT,GL_AMBIENT,default_a);
glMaterialfv(GL_FRONT,GL_DIFFUSE,default_d);
glMaterialfv(GL_FRONT,GL_SPECULAR,default_s);
glMaterialfv(GL_FRONT,GL_EMISSION,default_e);
}
#if 0
for (x=0;x<source->xsize;x++)
for (y=0;y<source->ysize;y++) {
*((Uint16 *)(t_pointer))=target_p->palette[*(s_pointer)];
s_pointer++; t_pointer+=2;
}
#endif
glRotatef(rotation,160,100,0);
glRotatef(rotation,1,1,1);
rotation+=1.0;
glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_REPLACE);
for(i=0;i<5;i++) {
for(j=0;j<3;j++) { /* make it 4, but fix so no out of bounds */
s_pointer=(source->memory)+(((j*64*320)+(i*64)));
for(y=0;y<64;y++) {
for(x=0;x<64;x++) {
temp_data[ ((y*64)+x)*4] =palette[*(s_pointer)][0];
temp_data[ ((y*64)+x)*4+1] =palette[*(s_pointer)][1];
temp_data[ ((y*64)+x)*4+2] =palette[*(s_pointer)][2];
temp_data[ ((y*64)+x)*4+3] =palette[*(s_pointer)][3];
s_pointer++;
}
s_pointer+=(320-64);
}
glBindTexture(GL_TEXTURE_2D,texture_grid[i][j]);
glTexSubImage2D(GL_TEXTURE_2D,0,0,0,64,64,GL_RGBA,GL_UNSIGNED_BYTE,
&temp_data);
glPushMatrix();
glTranslatef( i*4,-(j*4),0);
glBegin(GL_QUADS);
glNormal3f(0.0,0.0,1.0);
glTexCoord2f(0,0);
glVertex3f(-2,2,0);
glTexCoord2f(1,0);
glVertex3f(2,2,0);
glTexCoord2f(1,1);
glVertex3f(2,-2,0);
glTexCoord2f(0,1);
glVertex3f(-2,-2,0);
glEnd();
glPopMatrix();
}
}
glDisable(GL_TEXTURE_2D);
#if 0
// glEnable(GL_DEPTH_TEST);
glEnable(GL_TEXTURE_2D);
@ -259,150 +341,12 @@ void openGL_BlitMem(vmwSVMWGraphState *target_p, vmwVisual *source) {
glDisable(GL_TEXTURE_2D);
glDisable(GL_DEPTH_TEST);
glPopMatrix();
glXSwapBuffers(display,win);
/*
int x,y;
unsigned char *s_pointer;
s_pointer=source->memory;
for (x=0;x<source->xsize;x++)
for (y=0;y<source->ysize;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++;
}
*/
}
void openGL_clearKeyboardBuffer() {
/* SDL_Event event;
while (SDL_PollEvent(&event)) {
*/
}
void reshape(int w,int h) {
glViewport(0,0,(GLsizei)w,(GLsizei)h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if (w<=h)
glOrtho(-30,30,-30*(GLfloat)h/(GLfloat)w,
30*(GLfloat)h/(GLfloat)w,-30,30);
else
glOrtho(-20,340,-20,
220,-100,100);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
#endif
glFlush();
SDL_GL_SwapBuffers();
glDisable(GL_LIGHTING);
}
int openGL_getInput() {
static int keydown=0;
KeySym keysym;
XEvent E;
char keyname[18];
while (XPending(display) > 0) {
XNextEvent(display, &E);
if (E.xany.window == win) {
switch (E.type) {
case Expose:
//Redraw();
break;
case ConfigureNotify:
reshape(E.xconfigure.width, E.xconfigure.height);
break;
case KeyPress:
keydown=1;
case KeyRelease:
/* get bare keysym, for the scancode */
keysym = XLookupKeysym ((XKeyEvent *) &E, 0);
/* get key name, using modifiers for the unicode */
XLookupString ((XKeyEvent *) &E, keyname, 16, NULL, NULL);
// fprintf(stderr, "Keyevent keycode: %04X, keysym: %04X, unicode: %02X\n",
// E.xkey.keycode, (unsigned int)keysym, (unsigned int)keyname[0]);
/* look which table should be used */
// if ( (keysym & ~0x1ff) == 0xfe00 )
// event.scancode = extended_code_table[keysym & 0x01ff];
// else if (keysym < 0xff)
// event.scancode = code_table[keysym & 0x00ff];
// else
// event.scancode = 0;
//
// event.unicode = keyname[0];
// keyboard_register_event(&event);
switch(E.xkey.keycode) {
case 0x09: return VMW_ESCAPE;
case 0x24: return VMW_ENTER;
case 0x62: return VMW_UP;
case 0x68: return VMW_DOWN;
case 0x66: return VMW_RIGHT;
case 0x64: return VMW_LEFT;
case 0x41: return ' ';
case 0x43: return VMW_F1;
case 0x44: return VMW_F2;
case 0x63: return VMW_PGUP;
case 0x69: return VMW_PGDN;
case 0x4A: /* F8 */
rotation+=10.0;
printf("Rotation now=%f\n",rotation);
return 0;
}
break;
default:
/*no-op*/ ;
}
}
}
/* 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() {
}

View File

@ -93,102 +93,101 @@ void SDL_flushPalette(vmwSVMWGraphState *state) {
}
void SDL_NoScale32bpp_BlitMem(vmwSVMWGraphState *target_p, vmwVisual *source) {
int x,y,color;
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;
}
int x,y,color;
s_pointer=source->memory;
t_pointer=((Uint8 *)target->pixels);
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);
// printf("%i %i\n",source->xsize,source->ysize);
for (x=0;x<source->xsize;x++)
for (x=0;x<source->xsize;x++)
for (y=0;y<source->ysize;y++) {
color=SDL_MapRGB(target->format,target_p->actual_pal[*(s_pointer)].r,
target_p->actual_pal[*(s_pointer)].g,
target_p->actual_pal[*(s_pointer)].b);
color=SDL_MapRGB(target->format,target_p->actual_pal[*(s_pointer)].r,
target_p->actual_pal[*(s_pointer)].g,
target_p->actual_pal[*(s_pointer)].b);
*((Uint32 *)(t_pointer))=color;
s_pointer++; t_pointer+=4;
}
/* 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);
/* 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);
}
/* I should make this generic, but it makes it really slow */
void SDL_Double32bpp_BlitMem(vmwSVMWGraphState *target_p, vmwVisual *source) {
int x,y,scale,color;
unsigned char *s_pointer,*t_pointer;
SDL_Surface *target;
target=(SDL_Surface *)target_p->output_screen;
scale=target_p->scale;
if ( SDL_MUSTLOCK(target) ) {
if ( SDL_LockSurface(target) < 0 )
return;
}
s_pointer=source->memory;
t_pointer=((Uint8 *)target->pixels);
for (y=0;y<source->ysize;y++) {
void SDL_Double32bpp_BlitMem(vmwSVMWGraphState *target_p, vmwVisual *source) {
int x,y,scale,color;
unsigned char *s_pointer,*t_pointer;
SDL_Surface *target;
target=(SDL_Surface *)target_p->output_screen;
scale=target_p->scale;
if ( SDL_MUSTLOCK(target) ) {
if ( SDL_LockSurface(target) < 0 )
return;
}
s_pointer=source->memory;
t_pointer=((Uint8 *)target->pixels);
for (y=0;y<source->ysize;y++) {
for (x=0;x<source->xsize;x++) {
color=SDL_MapRGB(target->format,target_p->actual_pal[*(s_pointer)].r,
target_p->actual_pal[*(s_pointer)].g,
target_p->actual_pal[*(s_pointer)].b);
/* i=0, j=0 */
*((Uint32 *) ( (t_pointer)))=color;
/* i=1, j=0 */
*((Uint32 *) ( (t_pointer+(2*target_p->xsize) )))=color;
/* i=0, j=1 */
*((Uint32 *) ( (t_pointer+4) ))=color;
/* i=1 j=1 */
*((Uint32 *) ( (t_pointer+4+(2*target_p->xsize) )))=color;
s_pointer++; t_pointer+=8;
color=SDL_MapRGB(target->format,target_p->actual_pal[*(s_pointer)].r,
target_p->actual_pal[*(s_pointer)].g,
target_p->actual_pal[*(s_pointer)].b);
/* i=0, j=0 */
*((Uint32 *) ( (t_pointer)))=color;
/* i=1, j=0 */
*((Uint32 *) ( (t_pointer+(2*target_p->xsize) )))=color;
/* i=0, j=1 */
*((Uint32 *) ( (t_pointer+4) ))=color;
/* i=1 j=1 */
*((Uint32 *) ( (t_pointer+4+(2*target_p->xsize) )))=color;
s_pointer++; t_pointer+=8;
}
t_pointer+=2*target_p->xsize;
}
/* Update the display */
if ( SDL_MUSTLOCK(target) ) {
SDL_UnlockSurface(target);
}
/* Write this out to the screen */
SDL_UpdateRect(target, 0, 0, target_p->xsize, target_p->ysize);
}
/* Update the display */
if ( SDL_MUSTLOCK(target) ) {
SDL_UnlockSurface(target);
}
/* Write this out to the screen */
SDL_UpdateRect(target, 0, 0, target_p->xsize, target_p->ysize);
}
void SDL_NoScale16bpp_BlitMem(vmwSVMWGraphState *target_p, vmwVisual *source) {
int x,y;

View File

@ -21,7 +21,7 @@ int vmwLoadPCX(int x1,int y1,vmwVisual *target,
{
int pcx_fd,x,y,i,r,g,b,numacross;
int pcx_fd,x,y,i,r,g,b,numacross,xsize,ysize;
unsigned char pcx_header[128];
unsigned char temp_byte;
@ -34,6 +34,10 @@ int vmwLoadPCX(int x1,int y1,vmwVisual *target,
}
read(pcx_fd,&pcx_header,128);
xsize=(pcx_header[9]<<8)+pcx_header[8];
ysize=(pcx_header[11]<<8)+pcx_header[10];
printf("Loading %ix%i pcx file\n",xsize,ysize);
/* Possibly add some sanity checking in the header at some point... */
/* Or actually even get the proper VALUES from the header. Some day... */
@ -42,7 +46,7 @@ int vmwLoadPCX(int x1,int y1,vmwVisual *target,
x=0; y=0;
while (y<200) {
while (y<ysize) {
read(pcx_fd,&temp_byte,1);
if ((temp_byte>=192) && (temp_byte<=255)) {
numacross=temp_byte-192;
@ -54,7 +58,7 @@ int vmwLoadPCX(int x1,int y1,vmwVisual *target,
vmwPutPixel(x,y,temp_byte,target);
x++;
}
if (x>319) {
if (x>xsize) {
x=0;
y++;
}

View File

@ -88,9 +88,9 @@ vmwSVMWGraphState *vmwSetupSVMWGraph(int display_type,int xsize,int ysize,
case VMW_OPENGLTARGET:
#ifdef OPENGL_TARGET
vmwFlushPalette=openGL_flushPalette;
vmwClearKeyboardBuffer=openGL_clearKeyboardBuffer;
vmwClearKeyboardBuffer=SDL_clearKeyboardBuffer;
vmwBlitMemToDisplay=openGL_BlitMem;
vmwGetInput=openGL_getInput;
vmwGetInput=SDL_getInput;
vmwCloseGraphics=openGL_closeGraphics;
#endif
break;
@ -122,19 +122,19 @@ vmwSVMWGraphState *vmwSetupSVMWGraph(int display_type,int xsize,int ysize,
if (temp_state->bpp==24) {
printf("ERROR! 24bpp not supported!\n");
if (scale==1) {
vmwBlitMemToDisplay=SDL_NoScale16bpp_BlitMem;
} else {
vmwBlitMemToDisplay=SDL_Double16bpp_BlitMem;
vmwBlitMemToDisplay=SDL_NoScale16bpp_BlitMem;
} else {
vmwBlitMemToDisplay=SDL_Double16bpp_BlitMem;
}
}
if (temp_state->bpp>=32) {
if (scale==1) {
vmwBlitMemToDisplay=SDL_NoScale32bpp_BlitMem;
} else {
vmwBlitMemToDisplay=SDL_Double32bpp_BlitMem;
}
}
if (temp_state->bpp>=32) {
if (scale==1) {
vmwBlitMemToDisplay=SDL_NoScale32bpp_BlitMem;
} else {
vmwBlitMemToDisplay=SDL_Double32bpp_BlitMem;
}
}
vmwFlushPalette=SDL_flushPalette;
vmwClearKeyboardBuffer=SDL_clearKeyboardBuffer;
vmwGetInput=SDL_getInput;

5
tb1.c
View File

@ -1,6 +1,6 @@
/****************************************************************\
\* TOM BOMBEM AND THE INVASION OF THE INANIMATE_OBJECTS */
/* version 2.9.14 3 June 2001 *\
/* version 2.9.15 28 October 2001 *\
\* by Vince Weaver vince@deater.net */
/* *\
\* Originally written in Pascal and x86 assembly for DOS */
@ -10,12 +10,13 @@
\* This source is released under the GPL */
/****************************************************************/
#define TB1_VERSION "2.9.14"
#define TB1_VERSION "2.9.15"
#include <stdio.h>
#include <stdlib.h> /* for calloc */
#include <string.h> /* for strncpy */
#include <unistd.h>
#include <time.h>
#include <sys/time.h>
#include "svmwgraph/svmwgraph.h"

527
tools/paintpro.c Normal file
View File

@ -0,0 +1,527 @@
/* ppp.c GIMP plug-in for loading & saving ppp files */
/* by Vince Weaver <vince@deater.net> */
/* This code is based in parts on code by Francisco Bustamante,
and Nick Lamb njl195@zepler.org.uk */
/* To compile, copy into the gimp source directory and do a */
/* gimptool --build paintpro.c */
/* Then copy the resulting paintpro file into ~/.gimp-1.2/plug-ins */
/*#define DEBUG 1 */
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
#include "libgimp/stdplugins-intl.h"
/* Declare plug-in functions. */
static void query (void);
static void run (gchar *name,
gint nparams,
GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
#if G_BYTE_ORDER == G_BIG_ENDIAN
#define qtohl(x) \
((unsigned long int)((((unsigned long int)(x) & 0x000000ffU) << 24) | \
(((unsigned long int)(x) & 0x0000ff00U) << 8) | \
(((unsigned long int)(x) & 0x00ff0000U) >> 8) | \
(((unsigned long int)(x) & 0xff000000U) >> 24)))
#define qtohs(x) \
((unsigned short int)((((unsigned short int)(x) & 0x00ff) << 8) | \
(((unsigned short int)(x) & 0xff00) >> 8)))
#else
#define qtohl(x) (x)
#define qtohs(x) (x)
#endif
#define htoql(x) qtohl(x)
#define htoqs(x) qtohs(x)
GimpPlugInInfo PLUG_IN_INFO =
{
NULL, /* init_proc */
NULL, /* quit_proc */
query, /* query_proc */
run, /* run_proc */
};
MAIN ()
static void
query (void)
{
static GimpParamDef load_args[] =
{
{ GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive" },
{ GIMP_PDB_STRING, "filename", "The name of the file to load" },
{ GIMP_PDB_STRING, "raw_filename", "The name entered" }
};
static GimpParamDef load_return_vals[] =
{
{ GIMP_PDB_IMAGE, "image", "Output image" }
};
static gint nload_args = sizeof (load_args) / sizeof (load_args[0]);
static gint nload_return_vals = (sizeof (load_return_vals) /
sizeof (load_return_vals[0]));
static GimpParamDef save_args[] =
{
{ GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive" },
{ GIMP_PDB_IMAGE, "image", "Input image" },
{ GIMP_PDB_DRAWABLE, "drawable", "Drawable to save" },
{ GIMP_PDB_STRING, "filename", "The name of the file to save the image in" },
{ GIMP_PDB_STRING, "raw_filename", "The name entered" }
};
static gint nsave_args = sizeof (save_args) / sizeof (save_args[0]);
gimp_install_procedure ("file_ppp_load",
"Loads files in VMW Paintpro file format",
"Paintpro",
"Vince Weaver",
"vince@deater.net",
"2001",
"<Load>/PPP",
NULL,
GIMP_PLUGIN,
nload_args, nload_return_vals,
load_args, load_return_vals);
gimp_install_procedure ("file_ppp_save",
"Saves files in VMW Paintprofile format",
"Paintpro",
"Vince Weaver",
"vince@deater.net",
"2001",
"<Save>/PPP",
"INDEXED, RGB, GRAY",
GIMP_PLUGIN,
nsave_args, 0,
save_args, NULL);
gimp_register_magic_load_handler ("file_ppp_load",
"ppp,amg",
"",
"0,string,PAINTPROV");
gimp_register_save_handler ("file_ppp_save",
"ppp,amg",
"");
}
/* Declare internal functions. */
static gint32 load_image (gchar *filename);
static void load_8 (FILE *fp,
gint width,
gint height,
gchar *buffer);
static gint save_image (gchar *filename,
gint32 image,
gint32 layer);
static void save_8 (FILE *fp,
gint width,
gint height,
guchar *buffer);
/* Take a 24bit value [3 bytes] and split the top and bottom */
/* 12 bits into 2 integers */
#define THREE_BYTES_INT1(a,b) ( ( ( (int)(a))<<4)+ ((b)>>4) )
#define THREE_BYTES_INT2(b,c) ( ( ( ( (int)(b))&0x0f)<<8)+ (c))
/* Plug-in implementation */
static void
run (gchar *name,
gint nparams,
GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals)
{
static GimpParam values[2];
GimpRunModeType run_mode;
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
gint32 image_ID;
gint32 drawable_ID;
GimpExportReturnType export = GIMP_EXPORT_CANCEL;
run_mode = param[0].data.d_int32;
*nreturn_vals = 1;
*return_vals = values;
values[0].type = GIMP_PDB_STATUS;
values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
if (strcmp (name, "file_ppp_load") == 0)
{
INIT_I18N();
image_ID = load_image (param[1].data.d_string);
if (image_ID != -1)
{
*nreturn_vals = 2;
values[1].type = GIMP_PDB_IMAGE;
values[1].data.d_image = image_ID;
}
else
{
status = GIMP_PDB_EXECUTION_ERROR;
}
}
else if (strcmp (name, "file_ppp_save") == 0)
{
image_ID = param[1].data.d_int32;
drawable_ID = param[2].data.d_int32;
/* eventually export the image */
switch (run_mode)
{
case GIMP_RUN_INTERACTIVE:
case GIMP_RUN_WITH_LAST_VALS:
INIT_I18N_UI();
gimp_ui_init ("ppp", FALSE);
export = gimp_export_image (&image_ID, &drawable_ID, "ppp",
(GIMP_EXPORT_CAN_HANDLE_RGB |
GIMP_EXPORT_CAN_HANDLE_GRAY |
GIMP_EXPORT_CAN_HANDLE_INDEXED));
if (export == GIMP_EXPORT_CANCEL)
{
values[0].data.d_status = GIMP_PDB_CANCEL;
return;
}
break;
default:
INIT_I18N();
break;
}
switch (run_mode)
{
case GIMP_RUN_INTERACTIVE:
break;
case GIMP_RUN_NONINTERACTIVE:
if (nparams != 5)
status = GIMP_PDB_CALLING_ERROR;
break;
case GIMP_RUN_WITH_LAST_VALS:
break;
default:
break;
}
if (status == GIMP_PDB_SUCCESS)
{
if (! save_image (param[3].data.d_string, image_ID, drawable_ID))
{
status = GIMP_PDB_EXECUTION_ERROR;
}
}
if (export == GIMP_EXPORT_EXPORT)
gimp_image_delete (image_ID);
}
else
{
status = GIMP_PDB_CALLING_ERROR;
}
values[0].data.d_status = status;
}
guchar mono[6]= { 0, 0, 0, 255, 255, 255 };
static gint32 load_image (gchar *filename) {
FILE *fd;
GimpDrawable *drawable;
GimpPixelRgn pixel_rgn;
gchar *message;
gint offset_x, offset_y, height, width;
gint32 image, layer;
guchar *dest, cmap[768];
unsigned char buffer[18];
int num_colors,i;
message = g_strdup_printf (_("Loading %s:"), filename);
gimp_progress_init (message);
g_free (message);
fd = fopen (filename, "rb");
if (!fd) {
g_message ("ppp: Can't open\n%s", filename);
return -1;
}
if (fread (buffer,1,18, fd) != 18) {
g_message ("ppp: Can't read header from\n%s", filename);
return -1;
}
#ifdef DEBUG
for(i=0;i<11;i++) putchar(buffer[i]);
putchar('\n');
#endif
offset_x=0;
offset_y=0;
width = THREE_BYTES_INT1(buffer[12],buffer[13]);
height = THREE_BYTES_INT2(buffer[13],buffer[14]);
num_colors=THREE_BYTES_INT1(buffer[15],buffer[16]);
#ifdef DEBUG
printf("Loading %ix%i file with %i colors\n",width,height,num_colors);
#endif
if (num_colors>256) {
g_message("ppp: only <=256 color ppp images supported!\n");
return FALSE;
}
image= gimp_image_new (width, height, GIMP_INDEXED);
layer= gimp_layer_new (image, _("Background"), width, height,
GIMP_INDEXED_IMAGE, 100, GIMP_NORMAL_MODE);
gimp_image_set_filename (image, filename);
gimp_image_add_layer (image, layer, 0);
gimp_layer_set_offsets (layer, offset_x, offset_y);
drawable = gimp_drawable_get (layer);
/* load color map */
for(i=0;i<num_colors;i++) {
fread(&cmap[i*3],3,1,fd);
}
gimp_image_set_cmap (image, cmap, num_colors);
/* load picture */
dest = (guchar *) g_malloc (width * height);
load_8(fd, width, height, dest);
gimp_pixel_rgn_init (&pixel_rgn, drawable, 0, 0, width, height, TRUE, FALSE);
gimp_pixel_rgn_set_rect (&pixel_rgn, dest, 0, 0, width, height);
g_free (dest);
gimp_drawable_flush (drawable);
gimp_drawable_detach (drawable);
return image;
}
static void load_8 (FILE *fp, gint width, gint height, gchar *buffer) {
int x=0,y=0;
unsigned char three_bytes[3];
int color,numacross,i;
while (y<height) {
fread(three_bytes,3,1,fp);
color=THREE_BYTES_INT1(three_bytes[0],three_bytes[1]);
numacross=THREE_BYTES_INT2(three_bytes[1],three_bytes[2]);
#ifdef DEBUG
printf("%i %i\t",color,numacross); fflush(stdout);
#endif
if (color>2047) {
buffer[y*width+x]=(unsigned char) (color-2048);
x++;
if (x>=width) {
x=0; y++;
}
buffer[y*width+x]=(unsigned char) (numacross-2048);
x++;
if (x>=width) {
x=0; y++;
}
}
else {
while ((x+numacross)>=(width)) {
for(i=x;i<width;i++) {
buffer[y*width+i]=(unsigned char)color;
}
numacross=numacross-(width-x);
x=0;
y++;
}
if (numacross!=0) {
if (y>=height) {
printf("trying to draw past end of buffer\n");
}
if (numacross > width) {
printf("x too big\n");
}
for(i=0;i<numacross;i++) {
buffer[y*width+x+i]=(unsigned char)color;
}
x+=numacross;
}
}
}
}
#define TWO_INTS_THREE_BYTES(a,b) \
three_bytes[0]=((unsigned char)(((a)>>4)&0xff)); \
three_bytes[1]=((unsigned char) ( (((a)&0x0f)<<4)+(((b)>>8)&0x0f))); \
three_bytes[2]=((unsigned char)((b)&0xff));
static gint save_image (gchar *filename, gint32 image, gint32 layer) {
FILE *fp;
GimpPixelRgn pixel_rgn;
GimpDrawable *drawable;
GimpImageType drawable_type;
guchar *cmap= 0, *pixels;
gint offset_x, offset_y, width, height;
gchar *message;
int colors;
unsigned char three_bytes[3];
char ppro_string[]="PAINTPRO";
char ppro_version[]="V6.1";
drawable = gimp_drawable_get (layer);
drawable_type = gimp_drawable_type (layer);
gimp_drawable_offsets (layer, &offset_x, &offset_y);
width = drawable->width;
height = drawable->height;
gimp_pixel_rgn_init (&pixel_rgn, drawable, 0, 0, width, height, FALSE, FALSE);
message = g_strdup_printf (_("Saving %s:"), filename);
gimp_progress_init (message);
g_free (message);
switch (drawable_type) {
case GIMP_INDEXED_IMAGE:
cmap = gimp_image_get_cmap (image, &colors);
#ifdef DEBUG
printf("Saving picture %ix%i with %i colors\n",width,height,colors);
#endif
break;
default:
g_message ("ppp Can't save this image type\nFlatten your image");
return FALSE;
break;
}
if ((fp = fopen(filename, "wb")) == NULL) {
g_message ("ppp Can't open \n%s", filename);
return FALSE;
}
fwrite(ppro_string,8,1,fp);
fwrite(ppro_version,4,1,fp);
pixels = (guchar *) g_malloc (width * height);
gimp_pixel_rgn_get_rect (&pixel_rgn, pixels, 0, 0, width, height);
TWO_INTS_THREE_BYTES(width,height);
fwrite(three_bytes,3,1,fp);
TWO_INTS_THREE_BYTES(colors,0);
fwrite(three_bytes,3,1,fp);
switch (drawable_type) {
case GIMP_INDEXED_IMAGE:
fwrite (cmap, colors, 3, fp);
save_8 (fp, width, height, pixels);
break;
default:
g_message ("Can't save this image as ppp\nFlatten your image");
return FALSE;
break;
}
gimp_drawable_detach (drawable);
g_free (pixels);
fclose (fp);
return TRUE;
}
static void save_8 (FILE *fp, gint width, gint height, guchar *buffer) {
int oldcolor,x=0,y=0,color=0,numacross=0;
int already_have_single_pixel=0;
unsigned char three_bytes[3],save_pixel=0;
oldcolor=buffer[0];
while(y<height) {
color=buffer[y*width+x];
if ((color==oldcolor)&&(numacross<2046)) numacross++;
else {
if (numacross==1) {
if (!already_have_single_pixel) {
save_pixel=oldcolor;
already_have_single_pixel=1;
}
else {
TWO_INTS_THREE_BYTES(save_pixel+2048,oldcolor+2048);
fwrite(three_bytes,3,1,fp);
already_have_single_pixel=0;
}
}
else {
if (already_have_single_pixel) {
TWO_INTS_THREE_BYTES(save_pixel,1);
fwrite(three_bytes,3,1,fp);
already_have_single_pixel=0;
}
TWO_INTS_THREE_BYTES(oldcolor,numacross);
fwrite(three_bytes,3,1,fp);
}
oldcolor=color;
numacross=1;
}
x++;
if (x>=width) {
x=0;
y++;
}
}
if (already_have_single_pixel) {
TWO_INTS_THREE_BYTES(save_pixel,1);
fwrite(three_bytes,3,1,fp);
}
TWO_INTS_THREE_BYTES(color,numacross);
fwrite(three_bytes,3,1,fp);
}