mirror of
https://github.com/deater/tb1.git
synced 2025-04-11 13:39:58 +00:00
Version 2.9.2
This commit is contained in:
parent
6314d373e4
commit
d00b5521b8
9
Makefile
9
Makefile
@ -5,8 +5,8 @@ LIBS= -lSDL -lSDL_mixer -L/usr/X11R6/lib -lX11 -lpthread
|
||||
|
||||
all: tb1
|
||||
|
||||
tb1: tb1.o sdl_svmwgraph.o vmw_sprite.o tblib.o level_1.o sound.o
|
||||
gcc -o tb1 tb1.o sdl_svmwgraph.o vmw_sprite.o tblib.o level_1.o sound.o $(LIBS)
|
||||
tb1: tb1.o sdl_svmwgraph.o vmw_sprite.o tblib.o level_1.o level_2.o sound.o
|
||||
gcc -o tb1 tb1.o sdl_svmwgraph.o vmw_sprite.o tblib.o level_1.o level_2.o sound.o $(LIBS)
|
||||
|
||||
tb1.o: tb1.c
|
||||
gcc -c tb1.c $(INCLUDE)
|
||||
@ -22,7 +22,10 @@ vmw_sprite.o: vmw_sprite.c
|
||||
|
||||
level_1.o: level_1.c
|
||||
gcc -c level_1.c $(INCLUDE)
|
||||
|
||||
|
||||
level_2.o: level_2.c
|
||||
gcc -c level_2.c $(INCLUDE)
|
||||
|
||||
sound.o: sound.c
|
||||
gcc -c sound.c $(INCLUDE)
|
||||
|
||||
|
@ -1,49 +0,0 @@
|
||||
##############################################################
|
||||
# Makefile for TbLevelEdit -- by Vince Weaver #
|
||||
# #
|
||||
# Written on Linux 2.1.35 #
|
||||
# #
|
||||
# To modify for your configuration, add or remove the # #
|
||||
# #
|
||||
##############################################################
|
||||
|
||||
#Your compiler. If gcc doesn't work, try CC
|
||||
CC = gcc
|
||||
#CC = cc
|
||||
|
||||
#On Linux, uncomment the following
|
||||
#
|
||||
PLATFORM = Linux
|
||||
C_OPTS = -O2 -Wall -DHAVE_LINUX_SOUND
|
||||
L_OPTS = -lggi
|
||||
|
||||
######################################################################
|
||||
# THERE IS NO NEED TO EDIT ANYTHING BELOW THIS LINE #
|
||||
######################################################################
|
||||
|
||||
all: lev2edit view_ppro
|
||||
|
||||
clean:
|
||||
rm -f *.o
|
||||
rm -f lev2edit
|
||||
rm -f *~
|
||||
|
||||
lev2edit: lev2edit.o ../svmwgrap.o
|
||||
$(CC) $(C_OPTS) -o lev2edit lev2edit.o ../svmwgrap.o ../gtblib.o $(L_OPTS)
|
||||
@strip lev2edit
|
||||
|
||||
view_ppro: view_ppro.o ../svmwgrap.o
|
||||
$(CC) $(C_OPTS) -o view_ppro view_ppro.o ../svmwgrap.o $(L_OPTS)
|
||||
@strip view_ppro
|
||||
|
||||
view_ppro.o: view_ppro.c
|
||||
$(CC) $(C_OPTS) -c view_ppro.c
|
||||
|
||||
lev2edit.o: lev2edit.c
|
||||
$(CC) $(C_OPTS) -c lev2edit.c
|
||||
|
||||
../svmwgrap.o: ../svmwgrap.c
|
||||
$(CC) $(C_OPTS) -c ../svmwgrap.c
|
||||
|
||||
../gtblib.o: ../gtblib.c
|
||||
$(CC) $(C_OPTS) -c ../gtblib.c
|
@ -1,25 +0,0 @@
|
||||
#include <stdio.h>
|
||||
|
||||
/* Converts SMIX (ethan brodsky) sound samples back to standard
|
||||
* raw audio format
|
||||
*/
|
||||
|
||||
|
||||
int main(int argc,char **argv)
|
||||
{
|
||||
FILE *fff;
|
||||
int ch;
|
||||
|
||||
fff=fopen(argv[1],"r");
|
||||
if(fff==NULL) {
|
||||
printf("\n\nUsage '%s filename'\n\n",argv[0]);
|
||||
return 1;
|
||||
}
|
||||
while(!feof(fff)) {
|
||||
ch=fgetc(fff);
|
||||
printf("%c",(ch+128));
|
||||
}
|
||||
fclose(fff);
|
||||
|
||||
}
|
||||
|
590
level_2.c
Normal file
590
level_2.c
Normal file
@ -0,0 +1,590 @@
|
||||
/*
|
||||
* Level 2 Engine Code for Tom Bombem
|
||||
* */
|
||||
|
||||
/* The Includes */
|
||||
#include <stdio.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include "SDL.h"
|
||||
#include "sdl_svmwgraph.h"
|
||||
#include "tb1_state.h"
|
||||
#include "levels.h"
|
||||
#include "tblib.h"
|
||||
#include "vmw_sprite.h"
|
||||
#include "tb_keypress.h"
|
||||
#include "sound.h"
|
||||
|
||||
/* Define this to get a frames per second readout */
|
||||
/* #define DEBUG_ON */
|
||||
|
||||
/* The sounds */
|
||||
|
||||
#define NUM_SAMPLES 8
|
||||
#define SND_AHH 0
|
||||
#define SND_CC 1
|
||||
#define SND_KAPOW 2
|
||||
#define SND_SCREAM 3
|
||||
#define SND_BONK 4
|
||||
#define SND_CLICK 5
|
||||
#define SND_OW 6
|
||||
#define SND_ZRRP 7
|
||||
|
||||
struct enemyinfo {
|
||||
int x,y;
|
||||
int kind;
|
||||
int out,exploding,boundarycheck,dead;
|
||||
int explodeprogress;
|
||||
int minx,maxx,xspeed,yspeed;
|
||||
int hitsneeded;
|
||||
};
|
||||
|
||||
struct bulletinfo {
|
||||
int out,x,y;
|
||||
};
|
||||
|
||||
struct obstruction {
|
||||
int x,y;
|
||||
int shooting,dead,exploding;
|
||||
int explodeprogress;
|
||||
int howmanyhits;
|
||||
int kind,lastshot;
|
||||
};
|
||||
|
||||
void leveltwoengine(struct tb1_state *game_state)
|
||||
{
|
||||
int ch,i;
|
||||
char tempst[300];
|
||||
int k,game_paused=0,speed_factor=1;
|
||||
int shipx=36;
|
||||
int whatdelay=1,beginscore,beginshield;
|
||||
FILE *f=NULL;
|
||||
int levelover=0,j,backrow=0;
|
||||
int background[201][13];
|
||||
struct enemyinfo enemy[10];
|
||||
struct bulletinfo bullet[4];
|
||||
struct timeval timing_info;
|
||||
struct timezone dontcare;
|
||||
|
||||
long oldsec,oldusec,time_spent;
|
||||
int howmuchscroll=0;
|
||||
struct obstruction passive[50];
|
||||
int shipadd=0,shipframe=1;
|
||||
int our_row,our_shape,rows_goneby=0;
|
||||
int grapherror;
|
||||
|
||||
vmw_font *tb1_font;
|
||||
unsigned char *virtual_1;
|
||||
unsigned char *virtual_2;
|
||||
|
||||
struct vmwSprite *ship_shape[3];
|
||||
struct vmwSprite *shape_table[40];
|
||||
int enemies_drawn[200];
|
||||
|
||||
/* For convenience */
|
||||
tb1_font=game_state->tb1_font;
|
||||
virtual_1=game_state->virtual_1;
|
||||
virtual_2=game_state->virtual_2;
|
||||
|
||||
/* Set this up for Save Game */
|
||||
beginscore=game_state->score;
|
||||
beginshield=game_state->shields;
|
||||
|
||||
printf("Starting level 2\n"); fflush(stdout);
|
||||
|
||||
|
||||
/* Load Sprites */
|
||||
grapherror=vmwLoadPicPacked(0,0,virtual_1,1,1,
|
||||
tb1_data_file("ships.tb1",
|
||||
game_state->path_to_data));
|
||||
|
||||
ship_shape[1]=vmwGetSprite(0,0,48,30,virtual_1);
|
||||
ship_shape[2]=vmwGetSprite(0,32,48,30,virtual_1);
|
||||
ship_shape[3]=vmwGetSprite(0,64,48,30,virtual_1);
|
||||
|
||||
|
||||
if (game_state->level==2) vmwLoadPicPacked(0,0,virtual_1,1,1,
|
||||
tb1_data_file("tbaship.tb1",game_state->path_to_data));
|
||||
if (game_state->level==4) vmwLoadPicPacked(0,0,virtual_1,1,1,
|
||||
tb1_data_file("tbeerm.tb1",game_state->path_to_data));
|
||||
|
||||
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);
|
||||
|
||||
printf("Sprites Loaded\n"); fflush(stdout);
|
||||
|
||||
/* Load Background Data */
|
||||
if (game_state->level==2)
|
||||
f=fopen(tb1_data_file("level2.dat",game_state->path_to_data),"r");
|
||||
if (game_state->level==4)
|
||||
f=fopen(tb1_data_file("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;
|
||||
}
|
||||
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;
|
||||
|
||||
/* 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);
|
||||
}
|
||||
vmwBlitMemToSDL(game_state->sdl_screen,virtual_1);
|
||||
clear_keyboard_buffer();
|
||||
pauseawhile(5);
|
||||
|
||||
/* Setup and draw the sidebar */
|
||||
setupsidebar(game_state);
|
||||
vmwFlipVirtual(virtual_1,virtual_2);
|
||||
sprintf(tempst,"%d",game_state->level);
|
||||
vmwDrawBox(251,52,63,7,0,virtual_2);
|
||||
vmwTextXY(tempst,307,51,12,0,0,tb1_font,virtual_2);
|
||||
|
||||
printf("Sidebar Drawn %i\n",sizeof(*virtual_2)); fflush(stdout);
|
||||
|
||||
/* Clear the screen and draw the stars */
|
||||
vmwDrawBox(0,0,320,400,0,virtual_2);
|
||||
for(i=0;i<100;i++) {
|
||||
// printf("%i\n",i); fflush(stdout);
|
||||
// vmwPutSprite(shape_table[32],rand()%238,rand()%150,0,virtual_2);
|
||||
// vmwPutSprite(shape_table[33],rand()%238,rand()%150,0,virtual_2);
|
||||
}
|
||||
|
||||
|
||||
printf("Stars Drawn\n"); fflush(stdout);
|
||||
change_shields(game_state);
|
||||
|
||||
|
||||
gettimeofday(&timing_info,&dontcare);
|
||||
oldsec=timing_info.tv_sec; oldusec=timing_info.tv_usec;
|
||||
|
||||
printf("Entering game loop\n"); fflush(stdout);
|
||||
|
||||
/**** GAME LOOP ****/
|
||||
while (!levelover) {
|
||||
ch=0;
|
||||
printf("Scrolling Background\n"); fflush(stdout);
|
||||
/* Scroll the Background */
|
||||
if (speed_factor>1) howmuchscroll-=speed_factor;
|
||||
else howmuchscroll--;
|
||||
if (howmuchscroll<0) {
|
||||
howmuchscroll=200+howmuchscroll;
|
||||
// vmwArbitraryCrossBlit(virtual_2,0,0,240,200,virtual_2,0,200);
|
||||
/*ggiCopyBox(vaddr2,0,0,240,200,0,200);*/
|
||||
for(i=0;i<12;i++)
|
||||
for(j=19;j>=0;j--) {
|
||||
our_shape=background[backrow+(19-j)][i];
|
||||
vmwPutSprite(shape_table[our_shape],
|
||||
i*20,j*10,0,virtual_1);
|
||||
}
|
||||
backrow+=20;
|
||||
}
|
||||
printf("Setting Obsrtuctions\n"); fflush(stdout);
|
||||
|
||||
/* Setup Obstructions */
|
||||
our_row=rows_goneby/10;
|
||||
if (!enemies_drawn[our_row]) {
|
||||
enemies_drawn[our_row]=1;
|
||||
for(i=0;i<12;i++) {
|
||||
our_shape=background[our_row][i];
|
||||
if ((our_shape>9)&&(our_shape<20)) {
|
||||
k=0;
|
||||
while ((!passive[k].dead) && (k<40)) k++;
|
||||
passive[k].dead=0;
|
||||
passive[k].kind=our_shape;
|
||||
if ((our_shape>10) && (our_shape<15)) passive[k].shooting=1;
|
||||
else passive[k].shooting=0;
|
||||
passive[k].exploding=0;
|
||||
passive[k].x=i*20;
|
||||
passive[k].y=(rows_goneby%10)-9;
|
||||
passive[k].howmanyhits=1;
|
||||
passive[k].lastshot=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
printf("Flipping\n"); fflush(stdout);
|
||||
|
||||
/* Flip the far background to vaddr */
|
||||
vmwArbitraryCrossBlit(virtual_2,0,0+howmuchscroll,240,200,
|
||||
virtual_1,0,0);
|
||||
|
||||
printf("Collision Check\n"); fflush(stdout);
|
||||
|
||||
/***Collision Check***/
|
||||
for(i=0;i<40;i++)
|
||||
if ((!passive[i].dead) && (!passive[i].exploding)) {
|
||||
for(j=0;j<3;j++) {
|
||||
if ((bullet[j].out) &&
|
||||
(collision(bullet[j].x,bullet[j].y,3,4,passive[i].x,
|
||||
passive[i].y,10,5))){
|
||||
if (passive[i].kind!=10) {
|
||||
if (game_state->sound_enabled)
|
||||
playGameFX(SND_KAPOW);
|
||||
passive[i].exploding=1;
|
||||
passive[i].explodeprogress=0;
|
||||
bullet[j].out=0;
|
||||
game_state->score+=10;
|
||||
changescore(game_state);
|
||||
}
|
||||
else {
|
||||
bullet[j].out=0;
|
||||
k=0;
|
||||
while ((!enemy[k].out) && (k<10)) k++;
|
||||
if (k<9) {
|
||||
enemy[k].out=1;
|
||||
enemy[k].y=bullet[j].y;
|
||||
enemy[k].x=bullet[j].x;
|
||||
enemy[k].yspeed=7;
|
||||
enemy[k].kind=21;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* See if ship is hitting any Obstructions*/
|
||||
if ((passive[i].y>155) && (passive[i].kind!=10)) {
|
||||
if ((collision(passive[i].x,passive[i].y,10,5,shipx+16,165,5,5))||
|
||||
(collision(passive[i].x,passive[i].y,10,5,shipx+6,175,18,8))) {
|
||||
if (game_state->sound_enabled) playGameFX(SND_BONK);
|
||||
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,
|
||||
0,virtual_1);
|
||||
change_shields(game_state);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* See if hit by lasers */
|
||||
for (i=0;i<10;i++)
|
||||
if (enemy[i].out) {
|
||||
if ((collision(enemy[i].x,enemy[i].y,2,5,shipx+16,165,5,5)) ||
|
||||
(collision(enemy[i].x,enemy[i].y,2,5,shipx+6,175,18,8))) {
|
||||
if (game_state->sound_enabled) playGameFX(SND_BONK);
|
||||
enemy[i].out=0;
|
||||
game_state->shields--;
|
||||
if (game_state->shields<0) levelover=1;
|
||||
change_shields(game_state);
|
||||
}
|
||||
}
|
||||
|
||||
/***DO EXPLOSIONS***/
|
||||
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,
|
||||
0,virtual_1);
|
||||
if (passive[i].explodeprogress>4) {
|
||||
passive[i].dead=1;
|
||||
passive[i].exploding=0;
|
||||
vmwPutSprite(shape_table[34],
|
||||
passive[i].x,passive[i].y+howmuchscroll,
|
||||
0,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,
|
||||
0,virtual_1);
|
||||
}
|
||||
}
|
||||
|
||||
/***MOVE ENEMIES***/
|
||||
for(j=0;j<40;j++) {
|
||||
if (!passive[j].dead) {
|
||||
if (speed_factor==1) passive[j].y++;
|
||||
else passive[j].y+=speed_factor;
|
||||
if (passive[j].y>190) passive[j].dead=1;
|
||||
}
|
||||
if (passive[j].lastshot>0) passive[j].lastshot--;
|
||||
if ((!passive[j].dead) && (passive[j].shooting)
|
||||
&& (!passive[j].lastshot) && (passive[j].y>0)) {
|
||||
k=0;
|
||||
while ((enemy[k].out) && (k<10)) k++;
|
||||
if (k<9) {
|
||||
passive[j].lastshot=30;
|
||||
enemy[k].out=1;
|
||||
enemy[k].y=passive[j].y;
|
||||
enemy[k].x=passive[j].x+5;
|
||||
enemy[k].yspeed=5;
|
||||
enemy[k].kind=25;
|
||||
if (passive[j].kind==11) enemy[k].kind=26;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(j=0;j<10;j++) {
|
||||
if (enemy[j].out) {
|
||||
vmwPutSprite(shape_table[enemy[j].kind],
|
||||
enemy[j].x,enemy[j].y,
|
||||
0,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;
|
||||
}
|
||||
}
|
||||
|
||||
/***READ KEYBOARD***/
|
||||
if ((ch=vmwGetInput())!=0) {
|
||||
switch(ch) {
|
||||
case TB_ESCAPE: levelover=1; break;
|
||||
case TB_RIGHT: if (shipadd>=0) shipadd+=3; else shipadd=0; break;
|
||||
case TB_LEFT: if (shipadd<=0) shipadd-=3; else shipadd=0; break;
|
||||
case TB_F1: game_paused=1; help(); break;
|
||||
case '+': whatdelay++; break;
|
||||
case 'P': case 'p': game_paused=1;
|
||||
coolbox(65,85,175,110,1,virtual_1);
|
||||
vmwTextXY("GAME PAUSED",79,95,4,7,
|
||||
0,tb1_font,virtual_1);
|
||||
vmwBlitMemToSDL(game_state->sdl_screen,virtual_1);
|
||||
while (vmwGetInput()==0) usleep(30000);
|
||||
break;
|
||||
case '-': whatdelay--; break;
|
||||
case 'S':
|
||||
case 's': game_state->sound_enabled=!(game_state->sound_enabled); break;
|
||||
case TB_F2: game_paused=1; /*savegame(*level,beginscore,beginshield);*/
|
||||
break;
|
||||
case ' ': for(j=0;j<3;j++)
|
||||
if (!bullet[j].out) {
|
||||
if (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,0,virtual_1);
|
||||
j=4;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***MOVE SHIP***/
|
||||
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) {
|
||||
case 1: vmwPutSprite(ship_shape[0],
|
||||
shipx,165,0,virtual_1); break;
|
||||
case 3: vmwPutSprite(ship_shape[1],
|
||||
shipx,165,0,virtual_1); break;
|
||||
case 2:
|
||||
case 4: vmwPutSprite(ship_shape[2],
|
||||
shipx,165,0,virtual_1); break;
|
||||
}
|
||||
shipframe++;
|
||||
if (shipframe==5) shipframe=1;
|
||||
|
||||
/* Flip Pages */
|
||||
vmwBlitMemToSDL(game_state->sdl_screen,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 (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;
|
||||
}
|
||||
|
||||
|
||||
/*printf("%i\n",rows_goneby);*/
|
||||
if (rows_goneby>1950) {
|
||||
printf("%i\n",rows_goneby);
|
||||
/*
|
||||
clearkeyboardbuffer;
|
||||
pauseawhile(200);
|
||||
fade;
|
||||
grapherror:=Mode13LoadPicPacked(0,0,vaddr,false,true,'viewscr.tb1');
|
||||
cls(0,vga);
|
||||
blockmove(0,79,58,116,vaddr,10,10,vga);
|
||||
clearkeyboardbuffer;
|
||||
outsmalltextxy('UNIDENTIFIED SPACECRAFT!',70,10,2,0,vga,true);
|
||||
outsmalltextxy('DO YOU WISH TO DEACTIVATE ',70,20,2,0,vga,true);
|
||||
outsmalltextxy('THIS SHIP''S SECURITY SYSTEMS? (Y/N)',70,30,2,0,vga,true);
|
||||
unfade;
|
||||
clearkeyboardbuffer;
|
||||
ch:='!';
|
||||
repeat
|
||||
if keypressed then ch:=readkey;
|
||||
until (upcase(ch)='Y') or (upcase(ch)='N');
|
||||
|
||||
if upcase(ch)='N' then begin
|
||||
blockmove(0,79,58,116,vaddr,10,50,vga);
|
||||
outsmalltextxy('NO? AFFIRMATIVE. ',70,50,9,0,vga,true);
|
||||
outsmalltextxy('ARMING REMOTE DESTRUCTION RAY.',70,60,9,0,vga,true);
|
||||
outsmalltextxy('GOOD-BYE.',70,70,9,0,vga,true);
|
||||
pauseawhile(400);
|
||||
fade;
|
||||
end;
|
||||
|
||||
if upcase(ch)='Y' then begin
|
||||
blockmove(0,79,58,116,vaddr,10,50,vga);
|
||||
outsmalltextxy('"Y"=CORRECT PASSWORD. ',70,50,2,0,vga,true);
|
||||
outsmalltextxy('WELCOME SUPREME TENTACLEE COMMANDER.',70,60,2,0,vga,true);
|
||||
outsmalltextxy('INITIATING TRACTOR BEAM AND AUTOMATIC',70,70,2,0,vga,true);
|
||||
outsmalltextxy('LANDING PROCEDURE.',70,80,2,0,vga,true);
|
||||
outsmalltextxy('WE WILL BE DEPARTING FOR THE PLANET',70,90,2,0,vga,true);
|
||||
outsmalltextxy('EERM IN THREE MICROCYCLE UNITS.',70,100,2,0,vga,true);
|
||||
pauseawhile(550);
|
||||
level:=3;
|
||||
clearkeyboardbuffer;
|
||||
blockmove(0,42,58,79,vaddr,10,110,vga);
|
||||
outsmalltextxy('Wha? Wait!',70,110,9,0,vga,true);
|
||||
outsmalltextxy('What''s happening?',70,120,9,0,vga,true);
|
||||
pauseawhile(550);
|
||||
fade;
|
||||
end;
|
||||
|
||||
grapherror:=Mode13LoadPicPacked(0,0,vaddr,false,true,'tbtract.tb1');
|
||||
for i:=0 to 239 do
|
||||
for j:=0 to 49 do
|
||||
putpixel240(i,j,getpixel(i,j,vaddr),vaddr2);
|
||||
cls(0,vga);
|
||||
unfade;
|
||||
for howmuchscroll:=50 downto 1 do begin
|
||||
flipd240(howmuchscroll,vaddr,vaddr2);
|
||||
putshape (bigship3off,vaddr,43,30,shipx,165);
|
||||
waitretrace;
|
||||
flipd320(vaddr,vga);
|
||||
end;
|
||||
|
||||
if upcase(ch)='N' then begin
|
||||
clearkeyboardbuffer;
|
||||
line(7,6,shipx+10,180,4,vga);
|
||||
line(shipx+37,180,231,6,4,vga);
|
||||
pauseawhile(50);
|
||||
clearkeyboardbuffer;
|
||||
for i:=shipx to shipx+48 do
|
||||
verticalline(165,195,i,4,vga);
|
||||
pauseawhile(200);
|
||||
flipd240(howmuchscroll,vaddr,vaddr2);
|
||||
flipd320(vaddr,vga);
|
||||
pauseawhile(150);
|
||||
end;
|
||||
|
||||
|
||||
if upcase(ch)='Y' then begin;
|
||||
shipadd:=sgn(shipx-95);
|
||||
shipy:=165;
|
||||
repeat
|
||||
if shipx<>95 then shipx:=shipx-shipadd;
|
||||
if shipy>9 then dec(shipy);
|
||||
flipd240(howmuchscroll,vaddr,vaddr2);
|
||||
line(7,6,shipx+10,shipy+15,2,vaddr);
|
||||
line(shipx+37,shipy+15,231,6,2,vaddr);
|
||||
putshape (bigship3off,vaddr,43,30,shipx,shipy);
|
||||
waitretrace;
|
||||
flipd320(vaddr,vga);
|
||||
until (shipx=95) and (shipy=9);
|
||||
clearkeyboardbuffer;
|
||||
pauseawhile(850);
|
||||
fade;
|
||||
cls(0,vga);
|
||||
|
||||
|
||||
while keypressed do ch:=readkey;
|
||||
if level=4 then begin
|
||||
outsmalltextxy('THE PLANET EERM?',20,20,10,0,vga,true);
|
||||
outsmalltextxy('XENOCIDE FLEET?',20,30,10,0,vga,true);
|
||||
outsmalltextxy('WHAT''S GOING ON?',20,40,10,0,vga,true);
|
||||
outsmalltextxy('A MAJOR GOVERNMENT CONSPIRACY? MASS HALUCINATIONS?',20,50,10,0,vga,true);
|
||||
|
||||
outsmalltextxy('WATCH FOR TOM BOMBEM LEVEL 3 (CURRENTLY IN THE DESIGN PHASE).',10,70,12,0,vga,true);
|
||||
outsmalltextxy('ALL THESE QUESTIONS WILL BE ANSWERED!',10,80,12,0,vga,true);
|
||||
outsmalltextxy('ALSO MORE FEATURES WILL BE ADDED:',10,90,12,0,vga,true);
|
||||
outsmalltextxy(' BETTER GRAPHICS, SOUND AND SPEED.',10,100,12,0,vga,true);
|
||||
|
||||
outsmalltextxy('TO HASTEN COMPLETION, SEND QUESTIONS/COMMENTS/DONATIONS TO ',9,120,9,0,vga,true);
|
||||
outsmalltextxy('THE AUTHOR (SEE THE REGISTER MESSAGE FOR RELEVANT ADDRESSES).',9,130,9,0,vga,true);
|
||||
|
||||
outsmalltextxy('THANK YOU FOR PLAYING TOM BOMBEM',80,150,14,0,vga,true);
|
||||
unfade;
|
||||
pauseawhile(1800);
|
||||
end; */
|
||||
levelover=1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void littleopener2()
|
||||
{
|
||||
char tempst[300];
|
||||
/*
|
||||
ggiSetGCForeground(vis,tb1_pal[0]);
|
||||
ggiDrawBox(vis,0,0,320,200);
|
||||
ggiSetGCForeground(vaddr,tb1_pal[0]);
|
||||
ggiDrawBox(vaddr,0,0,320,200);
|
||||
GGILoadPicPacked(0,0,vis,1,1,
|
||||
tb1_data_file("tbl2ship.tb1",(char *)tempst),
|
||||
(ggi_color *)&eight_bit_pal,
|
||||
(ggi_pixel *)&tb1_pal,color_depth);
|
||||
VMWtextxy("Hmmmm... ",10,10,tb1_pal[4],tb1_pal[0],0,tb1_font,vis);
|
||||
VMWtextxy("This Might Be Harder Than I Thought.",10,20,tb1_pal[4],tb1_pal[0],0,tb1_font,vis);
|
||||
pauseawhile(13);
|
||||
ggiSetGCForeground(vis,tb1_pal[0]);
|
||||
ggiDrawBox(vis,0,0,320,200);
|
||||
*/
|
||||
}
|
2
levels.h
2
levels.h
@ -1,4 +1,4 @@
|
||||
void levelone(struct tb1_state *game_state);
|
||||
void littleopener();
|
||||
void leveltwoengine(int *level, int *shields, int *score);
|
||||
void leveltwoengine(struct tb1_state *game_state);
|
||||
void littleopener2();
|
||||
|
30
svmwgraph/Makefile
Normal file
30
svmwgraph/Makefile
Normal file
@ -0,0 +1,30 @@
|
||||
|
||||
|
||||
INCLUDE= -Wall -O2
|
||||
LIBS= -lSDL -lSDL_mixer -L/usr/X11R6/lib -lX11 -lpthread
|
||||
|
||||
all: svmwgraph.a
|
||||
|
||||
svmwgraph.a: vmw_core.o vmw_flip.o vmw_font.o vmw_paintpro.o vmw_palette.o vmw_sprite.o
|
||||
echo "hello"
|
||||
|
||||
vmw_core.o: vmw_core.c
|
||||
gcc $(INCLUDE) -c vmw_core.c
|
||||
|
||||
vmw_flip.o: vmw_flip.c
|
||||
gcc $(INCLUDE) -c vmw_flip.c
|
||||
|
||||
vmw_font.o: vmw_font.c
|
||||
gcc $(INCLUDE) -c vmw_font.c
|
||||
|
||||
vmw_paintpro.o: vmw_paintpro.c
|
||||
gcc $(INCLUDE) -c vmw_paintpro.c
|
||||
|
||||
vmw_palette.o: vmw_palette.c
|
||||
gcc $(INCLUDE) -c vmw_palette.c
|
||||
|
||||
vmw_sprite.o: vmw_sprite.c
|
||||
gcc $(INCLUDE) -c vmw_sprite.c
|
||||
|
||||
clean:
|
||||
rm -f svmwgraph.a *.o *~
|
84
svmwgraph/sdl_svmwgraph.c
Normal file
84
svmwgraph/sdl_svmwgraph.c
Normal file
@ -0,0 +1,84 @@
|
||||
/* I will finish this game!!! */
|
||||
/* This is the SDL implementation of the Super VMW graphics library */
|
||||
/* Which was originally a lot of Turbo-Pascal w inline assembly */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include "SDL.h"
|
||||
#include "tb_keypress.h"
|
||||
|
||||
|
||||
void vmwBlitMemToSDL(SDL_Surface *target, unsigned char *source) {
|
||||
|
||||
int x,y,Bpp;
|
||||
|
||||
unsigned char *s_pointer,*t_pointer;
|
||||
|
||||
|
||||
if ( SDL_MUSTLOCK(target) ) {
|
||||
if ( SDL_LockSurface(target) < 0 )
|
||||
return;
|
||||
}
|
||||
|
||||
Bpp= target->format->BytesPerPixel;
|
||||
|
||||
s_pointer=source;
|
||||
t_pointer=((Uint8 *)target->pixels);
|
||||
|
||||
for (x=0;x<320;x++)
|
||||
for (y=0;y<200;y++) {
|
||||
*((Uint16 *)(t_pointer))=*((Uint16 *)(s_pointer));
|
||||
s_pointer+=2; t_pointer+=2;
|
||||
}
|
||||
|
||||
|
||||
/* Update the display */
|
||||
if ( SDL_MUSTLOCK(target) ) {
|
||||
SDL_UnlockSurface(target);
|
||||
}
|
||||
|
||||
/* Write this out to the screen */
|
||||
SDL_UpdateRect(target, 0, 0, 320, 200);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void vmwClearKeyboardBuffer() {
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event)) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
int vmwGetInput() {
|
||||
|
||||
SDL_Event event;
|
||||
int keypressed;
|
||||
|
||||
while ( SDL_PollEvent(&event)) {
|
||||
|
||||
switch(event.type) {
|
||||
case SDL_KEYDOWN:
|
||||
keypressed=event.key.keysym.sym;
|
||||
switch (keypressed) {
|
||||
case SDLK_BACKSPACE: return TB_BACKSPACE;
|
||||
case SDLK_ESCAPE : return TB_ESCAPE;
|
||||
case SDLK_RETURN : return TB_ENTER;
|
||||
case SDLK_UP : return TB_UP;
|
||||
case SDLK_DOWN : return TB_DOWN;
|
||||
case SDLK_RIGHT : return TB_RIGHT;
|
||||
case SDLK_LEFT : return TB_LEFT;
|
||||
case SDLK_F1 : return TB_F1;
|
||||
case SDLK_F2 : return TB_F2;
|
||||
case SDLK_PAGEUP : return TB_PGUP;
|
||||
case SDLK_PAGEDOWN : return TB_PGDN;
|
||||
default: return keypressed;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
511
svmwgraph/svmwgraph.c
Normal file
511
svmwgraph/svmwgraph.c
Normal file
@ -0,0 +1,511 @@
|
||||
/* I will finish this game!!! */
|
||||
/* This is an implementation of the Super VMW graphics library */
|
||||
/* Which was originally a lot of Turbo-Pascal w inline assembly */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include "tb_keypress.h"
|
||||
|
||||
/* For now, sort of hard-coded in */
|
||||
#include "SDL_svmwgraph.h"
|
||||
|
||||
//#define DEBUG 1 /* Until we get to Beta */
|
||||
|
||||
int vmwPack3Bytes(int r, int g, int b) {
|
||||
|
||||
return ( ( ( (r>>3)&0x1f) <<11)+
|
||||
( ( (g>>2)&0x3f) <<5)+
|
||||
( ( (b>>3)&0x1f) ) );
|
||||
}
|
||||
|
||||
void vmwLoadCustomPalette(vmwGraphState *state, int pal[256]) {
|
||||
int i;
|
||||
for (i=0;i<256;i++) {
|
||||
state->palette[i]=pal[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------*\
|
||||
| vmwPutPixel |
|
||||
\*---------------------------------------------------------------*/
|
||||
|
||||
void vmwPutPixel(int x,int y,int color,vmwVisual *target) {
|
||||
|
||||
#ifdef DEBUG
|
||||
if ( (y> (target->ysize-1) ) || (x> (target->xsize-1) ) ) {
|
||||
printf("Out of bounds with PutPixel %i,%i\n",x,y);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
target->memory[(y*target->xsize)+x]=color;
|
||||
|
||||
}
|
||||
|
||||
unsigned char vmwGetPixel(int x,int y,vmwVisual *source) {
|
||||
|
||||
return source->memory[(y*source->xsize)+x];
|
||||
|
||||
}
|
||||
|
||||
|
||||
void vmwClearScreen(vmwVisual *target, int color) {
|
||||
|
||||
memset(target->memory,color,target->xsize*target->ysize);
|
||||
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------*\
|
||||
| vmwDrawHLine |
|
||||
| This is really begging to be optimized. I am sure some |
|
||||
| targets can do this in hardware |
|
||||
\*---------------------------------------------------------------*/
|
||||
|
||||
void vmwDrawHLine(int xstart,int ystart,int how_long,int color,
|
||||
vmwVisual *target) {
|
||||
|
||||
unsigned char *temp_pointer;
|
||||
int i;
|
||||
|
||||
temp_pointer=target->memory+(ysart*target->xsize)+xstart;
|
||||
|
||||
for(i=0;i<how_long;i++) {
|
||||
*temp_pointer=color;
|
||||
temp_pointer++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void vmwDrawVLine(int xstart,int ystart,int how_long,int color,
|
||||
vmwVisual *target) {
|
||||
|
||||
unsigned char *temp_pointer;
|
||||
int i;
|
||||
|
||||
temp_pointer=target_memory+(ystart*target->xsize)+xstart;
|
||||
|
||||
for(i=0;i<how_long;i++) {
|
||||
*temp_pointer=color;
|
||||
temp_pointer+=target->xsize;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------*\
|
||||
| vmwLoadPicPacked |
|
||||
| There is so much history in this function, I won't get into |
|
||||
| it here. |
|
||||
\*---------------------------------------------------------------*/
|
||||
|
||||
int vmwLoadPicPacked(int x1,int y1,vmwVisual *target,
|
||||
int LoadPal,int LoadPic,char *FileName)
|
||||
|
||||
/* Retro comments */
|
||||
/*{ Loads a paintpro image, filename, at location x1,y1 *\
|
||||
\* to offset where (vga=$A000) and loadspal if LOADPAL=true */
|
||||
/* Loadsapicture if Loadpic=true and returns error} */
|
||||
|
||||
{
|
||||
unsigned char temp1,temp2,temp3;
|
||||
int errorlev;
|
||||
int int1,int2,i,x,y;
|
||||
char buffer[300];
|
||||
int lastread=0;
|
||||
int buffpointer=0;
|
||||
int picwidth,picheight;
|
||||
FILE *fff;
|
||||
char header[10];
|
||||
int xsize;
|
||||
int ysize;
|
||||
int numcolors;
|
||||
int col,numacross;
|
||||
int temp_palette[256];
|
||||
|
||||
/* Open the file */
|
||||
fff=fopen(FileName,"rb"); /* Windows chokes if no "b" */
|
||||
if (fff==NULL){
|
||||
printf("PPRO error... File \"%s\" not found.\n",FileName);
|
||||
return 1;
|
||||
}
|
||||
|
||||
errorlev=fread(buffer,1,300,fff);
|
||||
/* Check to see if its really a Paintpro File */
|
||||
for (i=0;i<9;i++) {
|
||||
header[i]=buffer[i];
|
||||
}
|
||||
header[9]='\0';
|
||||
if (strncmp(header,"PAINTPROV",9)) {
|
||||
printf("PPRO error... %s is NOT a paintpro file!\n",FileName);
|
||||
return 2;
|
||||
}
|
||||
|
||||
/* Check to see if it is the proper version (currently 6.0) */
|
||||
header[0]=buffer[9];
|
||||
header[1]=buffer[10];
|
||||
header[2]=buffer[11];
|
||||
header[3]='\0';
|
||||
if (strncmp(header,"6.0",3)) {
|
||||
printf("PPRO error... Version %s unsupported, must be >6\n",header);
|
||||
return 3;
|
||||
}
|
||||
|
||||
buffpointer=12;
|
||||
/* Read X and Y sizes */
|
||||
temp1=buffer[buffpointer];
|
||||
temp2=buffer[buffpointer+1];
|
||||
temp3=buffer[buffpointer+2];
|
||||
buffpointer+=3;
|
||||
if (buffpointer>=errorlev) {
|
||||
printf("PPRO error... Early end of file.\n");
|
||||
return 4;
|
||||
}
|
||||
|
||||
/* Split 48 bits into two 32 bit values */
|
||||
xsize=(temp2>>4)+(temp1<<4);
|
||||
ysize=((temp2-((temp2>>4)<<4))<<16)+temp3;
|
||||
|
||||
temp1=buffer[buffpointer];
|
||||
temp2=buffer[buffpointer+1];
|
||||
temp3=buffer[buffpointer+2];
|
||||
buffpointer+=3;
|
||||
if (buffpointer>=errorlev) {
|
||||
printf("PPRO error... Early end of file.\n");
|
||||
return 4;
|
||||
}
|
||||
|
||||
numcolors=(temp2>>4)+(temp1<<4);
|
||||
|
||||
picwidth=xsize+1;
|
||||
picheight=ysize+1;
|
||||
/*Load Palette*/
|
||||
if (numcolors!=256) printf("%d colors is not supported yet.\n",numcolors);
|
||||
|
||||
/* Fun and games to convert the 24 bit color in paintpro to */
|
||||
/* 565 packed 16bit RGB */
|
||||
|
||||
for(i=0;i<256;i++) {
|
||||
temp_palette[i]=vmwPack3Bytes(buffer[buffpointer],
|
||||
buffer[buffpointer+1],
|
||||
buffer[buffpointer+2]);
|
||||
buffpointer+=3;
|
||||
if (buffpointer>=errorlev) {
|
||||
if (errorlev==300) {
|
||||
errorlev=fread(buffer,1,300,fff);
|
||||
buffpointer=0;
|
||||
}
|
||||
else {
|
||||
lastread=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (LoadPal) {
|
||||
for (i=0;i<256;i++) global_palette[i]=temp_palette[i];
|
||||
}
|
||||
|
||||
|
||||
x=x1;
|
||||
y=y1;
|
||||
|
||||
while ((!lastread)&&(LoadPic)&&(y<y1+ysize)) {
|
||||
temp1=buffer[buffpointer];
|
||||
temp2=buffer[buffpointer+1];
|
||||
temp3=buffer[buffpointer+2];
|
||||
buffpointer+=3;
|
||||
if (buffpointer>=errorlev) {
|
||||
if (errorlev==300) {
|
||||
errorlev=fread(buffer,1,300,fff);
|
||||
buffpointer=0;
|
||||
}
|
||||
else lastread=1;
|
||||
}
|
||||
|
||||
int1=(temp2>>4)+(temp1<<4);
|
||||
int2=((temp2-((temp2>>4)<<4))*256)+temp3;
|
||||
|
||||
/* If greater than 2047, we have two single pixels */
|
||||
/* of color int1-2048 and int2-2048 */
|
||||
if (int1>2047) {
|
||||
vmwPutPixel(x,y,int1-2048,target);
|
||||
x++;
|
||||
if (x>xsize+x1) {
|
||||
x=x1; y++;
|
||||
// if (y>ysize-1) {
|
||||
// printf("Blargh 1\n"); y--;
|
||||
// }
|
||||
}
|
||||
vmwPutPixel(x,y,int2-2048,target);
|
||||
x++;
|
||||
if (x>xsize+x1){
|
||||
x=x1;y++;
|
||||
// if (y>ysize) {
|
||||
// printf("Blargh 2\n");
|
||||
// y--;
|
||||
// }
|
||||
}
|
||||
}
|
||||
else { /* Standard paintpro format */
|
||||
col=int1;
|
||||
numacross=int2;
|
||||
while ((x+numacross)>(xsize+x1)) {
|
||||
vmwDrawHLine(x,y,((xsize+x1)-x),col,target);
|
||||
numacross=numacross-((xsize+1)-x);
|
||||
x=x1;
|
||||
y++;
|
||||
if (y>y1+ysize-1) {
|
||||
printf("Blrgh 3\n");
|
||||
}
|
||||
}
|
||||
if ((numacross!=0) && (y<y1+ysize)) {
|
||||
if (numacross+x>xsize+x-1) numacross--; /* Stupid x overflow */
|
||||
vmwDrawHLine(x,y,numacross,col,target);
|
||||
}
|
||||
x=x+numacross;
|
||||
}
|
||||
}
|
||||
|
||||
if (fff!=NULL) fclose(fff);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void vmwFlipVirtual(vmwVisual *destination,
|
||||
vmwVisual *source) {
|
||||
|
||||
memcpy(destination,source,source->xsize*source->ysize);
|
||||
|
||||
}
|
||||
|
||||
int vmwCrossBlit(char *dest,char *src,int stride,int ysize)
|
||||
{
|
||||
/*
|
||||
*
|
||||
int y;
|
||||
|
||||
for (y = 0; y < ysize; y++) {
|
||||
memcpy (dest, src, stride);
|
||||
src += stride;
|
||||
dest += stride;
|
||||
}
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
int vmwCrossBlit240(char *dest,char *src,int stride,int stride_factor,
|
||||
int ysize)
|
||||
{
|
||||
/*
|
||||
int y;
|
||||
|
||||
for (y = 0; y < ysize; y++) {
|
||||
memcpy (dest, src, (240*stride_factor));
|
||||
src += stride;
|
||||
dest += stride;
|
||||
}
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
int vmwArbitraryCrossBlit(vmwVisual *src,int x1,int y1,int w,int h,
|
||||
vmwVisual *dest,int x2,int y2)
|
||||
{
|
||||
|
||||
int y;
|
||||
unsigned char *source,*destination;
|
||||
|
||||
|
||||
source=src+(320*2*y1);
|
||||
destination=dest+(320*2*y2);
|
||||
|
||||
for(y=0;y<h;y++) {
|
||||
memcpy ((destination+x2*2),(source+x1*2),(w*2));
|
||||
source+=320*2;
|
||||
destination+=320*2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
vmw_font *vmwLoadFont(char *namest,int xsize,int ysize,int numchars)
|
||||
{
|
||||
unsigned char buff[16];
|
||||
FILE *f;
|
||||
int i,fonty,numloop;
|
||||
vmw_font *font;
|
||||
char *data;
|
||||
|
||||
font=(vmw_font *)malloc(sizeof(vmw_font));
|
||||
data=(char *)calloc(numchars*ysize,(sizeof(char)));
|
||||
|
||||
f=fopen(namest,"r");
|
||||
if (f==NULL) {
|
||||
printf("ERROR loading font file %s.\n",namest);
|
||||
return NULL;
|
||||
}
|
||||
numloop=(numchars*ysize);
|
||||
|
||||
font->width=xsize;
|
||||
font->height=ysize;
|
||||
font->numchars=numchars;
|
||||
font->font_data=data;
|
||||
fonty=0;
|
||||
while ( (!feof(f))&&(fonty<numloop)) {
|
||||
fread(buff,1,16,f);
|
||||
for(i=0;i<16;i++) font->font_data[fonty+i]=buff[i];
|
||||
fonty+=16;
|
||||
}
|
||||
fclose(f);
|
||||
return font;
|
||||
}
|
||||
|
||||
/*int bit(unsigned char mree,int whichbit)
|
||||
{
|
||||
return mree&(128>>whichbit);
|
||||
}
|
||||
*/
|
||||
|
||||
void vmwTextLineOver(char *st,int x,int y,int col,int background,int line,
|
||||
vmw_font *font,vmwVisual *target)
|
||||
{
|
||||
int i,xx,len;
|
||||
len=strlen(st);
|
||||
for(i=0;i<len;i++)
|
||||
for(xx=0;xx<8;xx++){
|
||||
if ( (font->font_data[(st[i]*font->height)+line])&(128>>xx) )
|
||||
vmwPutPixel((x+(i*8)+xx),y,col,target);
|
||||
else
|
||||
vmwPutPixel((x+(i*8)+xx),y,background,target);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void vmwTextLine(char *st,int x,int y,int col,int background,int line,
|
||||
vmw_font *font,vmwVisual *target)
|
||||
{
|
||||
int i,len,xx;
|
||||
len=strlen(st);
|
||||
for(i=0;i<len;i++)
|
||||
for(xx=0;xx<8;xx++)
|
||||
if( ((unsigned char) (font->font_data[(st[i]*16)+line]))
|
||||
&(128>>xx) ) {
|
||||
vmwPutPixel(x+(i*8)+xx,y,col,target);
|
||||
}
|
||||
}
|
||||
|
||||
void vmwTextXY(char *st,int x,int y,int col,int background,int overwrite,
|
||||
vmw_font *font,vmwVisual *target)
|
||||
{
|
||||
int lineon,i,xx,len;
|
||||
|
||||
len=strlen(st);
|
||||
for(lineon=0;lineon<8;lineon++){
|
||||
for(i=0;i<len;i++)
|
||||
for(xx=0;xx<8;xx++){
|
||||
if ( (font->font_data[(st[i]*font->height)+lineon])&(128>>xx) )
|
||||
vmwPutPixel((x+(i*8)+xx),y+lineon,col,target);
|
||||
else
|
||||
if(overwrite) vmwPutPixel((x+(i*8)+xx),y+lineon,background,target);
|
||||
}
|
||||
}
|
||||
/*VMWtextlineover(st,x,y+lineon,col,background,lineon,font,vis);*/
|
||||
/* VMWtextline(st,x,y+lineon,col,background,lineon,font,vis);*/
|
||||
}
|
||||
|
||||
|
||||
void vmwSmallTextXY(char *st,int x,int y,int col,int background,int overwrite,
|
||||
vmw_font *font,vmwVisual *target)
|
||||
{
|
||||
int lineon,i,xx,len;
|
||||
|
||||
/* This will print out a small 4x5 font located in chars */
|
||||
/* 128-255 in a normal VGA font. These are custom made */
|
||||
/* fonts they are non-standard */
|
||||
|
||||
len=strlen(st);
|
||||
for(lineon=0;lineon<5;lineon++) {
|
||||
for(i=0;i<len;i++)
|
||||
for(xx=0;xx<5;xx++) {
|
||||
if ( (font->font_data[((st[i]+128)*font->height)+lineon])&(128>>xx) )
|
||||
vmwPutPixel((x+(i*5)+xx),y+lineon,col,target);
|
||||
else
|
||||
if(overwrite) vmwPutPixel((x+(i*5)+xx),y+lineon,background,target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void vmwLine(int x1, int y1, int x2, int y2, int color, vmwVisual *destination) {
|
||||
|
||||
/*function sgn(a:real):integer;
|
||||
begin
|
||||
if a>0 then sgn:=+1;
|
||||
if a<0 then sgn:=-1;
|
||||
if a=0 then sgn:=0;
|
||||
end;
|
||||
|
||||
procedure line(a,b,c,d,col:integer;where:word);
|
||||
var u,s,v,d1x,d1y,d2x,d2y,m,n:real;
|
||||
i:integer;
|
||||
begin
|
||||
u:= c - a;
|
||||
v:= d - b;
|
||||
d1x:= SGN(u);
|
||||
d1y:= SGN(v);
|
||||
d2x:= SGN(u);
|
||||
d2y:= 0;
|
||||
m:= ABS(u);
|
||||
n := ABS(v);
|
||||
IF NOT (M>N) then
|
||||
BEGIN
|
||||
d2x := 0 ;
|
||||
d2y := SGN(v);
|
||||
m := ABS(v);
|
||||
n := ABS(u);
|
||||
END;
|
||||
s := INT(m / 2);
|
||||
FOR i := 0 TO round(m) DO
|
||||
BEGIN
|
||||
putpixel(a,b,col,where);
|
||||
s := s + n;
|
||||
IF not (s<m) THEN
|
||||
BEGIN
|
||||
s := s - m;
|
||||
a:= a +round(d1x);
|
||||
b := b + round(d1y);
|
||||
END
|
||||
ELSE
|
||||
BEGIN
|
||||
a := a + round(d2x);
|
||||
b := b + round(d2y);
|
||||
END;
|
||||
end;
|
||||
END;
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
void vmwFadeToBlack(vmwVisual *source) {
|
||||
int temp_pal[256];
|
||||
// temp_pal=real_pal
|
||||
// for (i=0;i<256;i++) {
|
||||
// temp_pal[i]--;
|
||||
// vmwBlitMemToDisplay()
|
||||
// pauseawhile()
|
||||
//
|
||||
}
|
||||
|
||||
void vmwUnFade(vmwVisual *source) {
|
||||
}
|
||||
|
||||
void vmwDrawBox(int x1,int y1,int xsize,int ysize,int col, vmwVisual *where) {
|
||||
int i;
|
||||
|
||||
for(i=0;i<ysize;i++) {
|
||||
vmwDrawHLine(x1,y1+i,xsize,col,where);
|
||||
}
|
||||
}
|
83
svmwgraph/svmwgraph.h
Normal file
83
svmwgraph/svmwgraph.h
Normal file
@ -0,0 +1,83 @@
|
||||
/* Defines for the Super VMW Graphics Library */
|
||||
|
||||
typedef struct {
|
||||
int xsize;
|
||||
int ysize;
|
||||
unsigned char *memory;
|
||||
int palette[256];
|
||||
} vmwVisual;
|
||||
|
||||
typedef struct {
|
||||
char *font_data;
|
||||
int width;
|
||||
int height;
|
||||
int numchars;
|
||||
} vmwFont;
|
||||
|
||||
typedef struct {
|
||||
int xsize;
|
||||
int ysize;
|
||||
unsigned char *spritedata;
|
||||
} vmwSprite;
|
||||
|
||||
/* Function declarations */
|
||||
|
||||
/* From vmw_core.c */
|
||||
void vmwPutPixel(int x,int y,int color,vmwVisual *target);
|
||||
unsigned char vmwGetPixel(int x,int y,vmwVisual *source);
|
||||
void vmwClearScreen(vmwVisual *target, int color);
|
||||
void vmwDrawHLine(int xstart,int ystart,int how_long,int color,
|
||||
vmwVisual *target);
|
||||
void vmwDrawVLine(int xstart,int ystart,int how_long,int color,
|
||||
vmwVisual *target);
|
||||
void vmwLine(int x1, int y1, int x2, int y2, int color,
|
||||
vmwVisual *destination);
|
||||
void vmwDrawBox(int x1,int y1,int xsize,int ysize,int col, vmwVisual *where);
|
||||
|
||||
/* From vmw_flip.c */
|
||||
void vmwFlipVirtual(vmwVisual *destination,
|
||||
vmwVisual *source);
|
||||
int vmwArbitraryCrossBlit(vmwVisual *src,int x1,int y1,int w,int h,
|
||||
vmwVisual *dest,int x2,int y2);
|
||||
|
||||
/* From vmw_font.c */
|
||||
|
||||
vmwFont *vmwLoadFont(char *namest,int xsize,int ysize,int numchars);
|
||||
void vmwTextLine(char *st,int x,int y,int col,int background,int line,
|
||||
int transparent,vmwFont *font,vmwVisual *target);
|
||||
void vmwTextXY(char *st,int x,int y,int col,int background,int overwrite,
|
||||
vmwFont *font,vmwVisual *target);
|
||||
void vmwSmallTextXY(char *st,int x,int y,int col,int background,int overwrite,
|
||||
vmwFont *font,vmwVisual *target);
|
||||
|
||||
/* From vmw_paintpro.c */
|
||||
|
||||
int vmwLoadPicPacked(int x1,int y1,vmwVisual *target,
|
||||
int LoadPal,int LoadPic,char *FileName);
|
||||
|
||||
int vmwSavePicPacked(int x1,int y1,int xsize,int ysize,
|
||||
vmwVisual *source,char *FileName);
|
||||
|
||||
|
||||
/* From vmw_palette.c */
|
||||
void vmwLoadCustomPalette(vmwVisual *source, int pal[256]);
|
||||
void vmwFadeToBlack(vmwVisual *source);
|
||||
void vmwUnFade(vmwVisual *source);
|
||||
|
||||
|
||||
/* From vmw_sprite.c */
|
||||
|
||||
vmwSprite *vmwGetSprite(int x, int y,
|
||||
int xsize, int ysize,vmwVisual *screen);
|
||||
|
||||
void vmwPutSprite(vmwSprite *sprite,int x,int y,int shield_color,
|
||||
vmwVisual *screen);
|
||||
|
||||
void vmwPutPartialSprite(vmwVisual *destination,
|
||||
vmwSprite *sprite,
|
||||
int x_start,int y_start,
|
||||
int x_stop, int y_stop);
|
||||
|
||||
|
||||
|
||||
|
129
svmwgraph/vmw_core.c
Normal file
129
svmwgraph/vmw_core.c
Normal file
@ -0,0 +1,129 @@
|
||||
/* Core Graphics routines for the Super VMW Graphics Library */
|
||||
|
||||
#include "svmwgraph.h"
|
||||
|
||||
// #define DEBUG 1
|
||||
|
||||
/*---------------------------------------------------------------*\
|
||||
| vmwPutPixel |
|
||||
\*---------------------------------------------------------------*/
|
||||
|
||||
void vmwPutPixel(int x,int y,int color,vmwVisual *target) {
|
||||
|
||||
#ifdef DEBUG
|
||||
if ( (y> (target->ysize-1) ) || (x> (target->xsize-1) ) ) {
|
||||
printf("Out of bounds with PutPixel %i,%i\n",x,y);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
target->memory[(y*target->xsize)+x]=color;
|
||||
|
||||
}
|
||||
|
||||
unsigned char vmwGetPixel(int x,int y,vmwVisual *source) {
|
||||
|
||||
return source->memory[(y*source->xsize)+x];
|
||||
|
||||
}
|
||||
|
||||
|
||||
void vmwClearScreen(vmwVisual *target, int color) {
|
||||
|
||||
memset(target->memory,color,target->xsize*target->ysize);
|
||||
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------*\
|
||||
| vmwDrawHLine |
|
||||
| This is really begging to be optimized. I am sure some |
|
||||
| targets can do this in hardware |
|
||||
\*---------------------------------------------------------------*/
|
||||
|
||||
void vmwDrawHLine(int xstart,int ystart,int how_long,int color,
|
||||
vmwVisual *target) {
|
||||
|
||||
unsigned char *temp_pointer;
|
||||
int i;
|
||||
|
||||
temp_pointer=target->memory+(ystart*target->xsize)+xstart;
|
||||
|
||||
for(i=0;i<how_long;i++) {
|
||||
*temp_pointer=color;
|
||||
temp_pointer++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void vmwDrawVLine(int xstart,int ystart,int how_long,int color,
|
||||
vmwVisual *target) {
|
||||
|
||||
unsigned char *temp_pointer;
|
||||
int i;
|
||||
|
||||
temp_pointer=target->memory+(ystart*target->xsize)+xstart;
|
||||
|
||||
for(i=0;i<how_long;i++) {
|
||||
*temp_pointer=color;
|
||||
temp_pointer+=target->xsize;
|
||||
}
|
||||
}
|
||||
|
||||
void vmwLine(int x1, int y1, int x2, int y2, int color,
|
||||
vmwVisual *destination) {
|
||||
|
||||
/*function sgn(a:real):integer;
|
||||
begin
|
||||
if a>0 then sgn:=+1;
|
||||
if a<0 then sgn:=-1;
|
||||
if a=0 then sgn:=0;
|
||||
end;
|
||||
|
||||
procedure line(a,b,c,d,col:integer;where:word);
|
||||
var u,s,v,d1x,d1y,d2x,d2y,m,n:real;
|
||||
i:integer;
|
||||
begin
|
||||
u:= c - a;
|
||||
v:= d - b;
|
||||
d1x:= SGN(u);
|
||||
d1y:= SGN(v);
|
||||
d2x:= SGN(u);
|
||||
d2y:= 0;
|
||||
m:= ABS(u);
|
||||
n := ABS(v);
|
||||
IF NOT (M>N) then
|
||||
BEGIN
|
||||
d2x := 0 ;
|
||||
d2y := SGN(v);
|
||||
m := ABS(v);
|
||||
n := ABS(u);
|
||||
END;
|
||||
s := INT(m / 2);
|
||||
FOR i := 0 TO round(m) DO
|
||||
BEGIN
|
||||
putpixel(a,b,col,where);
|
||||
s := s + n;
|
||||
IF not (s<m) THEN
|
||||
BEGIN
|
||||
s := s - m;
|
||||
a:= a +round(d1x);
|
||||
b := b + round(d1y);
|
||||
END
|
||||
ELSE
|
||||
BEGIN
|
||||
a := a + round(d2x);
|
||||
b := b + round(d2y);
|
||||
END;
|
||||
end;
|
||||
END;
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
void vmwDrawBox(int x1,int y1,int xsize,int ysize,int col, vmwVisual *where) {
|
||||
int i;
|
||||
|
||||
for(i=0;i<ysize;i++) {
|
||||
vmwDrawHLine(x1,y1+i,xsize,col,where);
|
||||
}
|
||||
}
|
34
svmwgraph/vmw_flip.c
Normal file
34
svmwgraph/vmw_flip.c
Normal file
@ -0,0 +1,34 @@
|
||||
/* Page Flipping Routines for the Super VMW Graphics Library */
|
||||
|
||||
#include "svmwgraph.h"
|
||||
|
||||
#include <string.h> /* For memcpy() */
|
||||
|
||||
void vmwFlipVirtual(vmwVisual *destination,
|
||||
vmwVisual *source) {
|
||||
|
||||
memcpy(destination,source,source->xsize*source->ysize);
|
||||
|
||||
}
|
||||
|
||||
|
||||
int vmwArbitraryCrossBlit(vmwVisual *src,int x1,int y1,int w,int h,
|
||||
vmwVisual *dest,int x2,int y2)
|
||||
{
|
||||
|
||||
int y;
|
||||
unsigned char *source,*destination;
|
||||
|
||||
source=src->memory+(src->xsize*y1);
|
||||
destination=dest->memory+(dest->xsize*y2);
|
||||
|
||||
for(y=0;y<h;y++) {
|
||||
memcpy ((destination+x2),(source+x1),w);
|
||||
source+=src->xsize;
|
||||
destination+=dest->ysize;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
108
svmwgraph/vmw_font.c
Normal file
108
svmwgraph/vmw_font.c
Normal file
@ -0,0 +1,108 @@
|
||||
/* Implements the font handling of the Super VMW Graph Library */
|
||||
|
||||
#include "svmwgraph.h"
|
||||
|
||||
#include <stdio.h> /* For File I/O */
|
||||
#include <stdlib.h> /* For malloc/calloc */
|
||||
|
||||
/* The font used is a standard VGA font. */
|
||||
/* To use the "smallText" functions, the VGA font */
|
||||
/* has to have a smaller (4x5) version of the */
|
||||
/* font from chars 0-127 mirrored at 128-255 */
|
||||
|
||||
|
||||
vmwFont *vmwLoadFont(char *namest,int xsize,int ysize,int numchars)
|
||||
{
|
||||
unsigned char buff[16];
|
||||
FILE *f;
|
||||
int i,fonty,numloop;
|
||||
vmwFont *font;
|
||||
char *data;
|
||||
|
||||
font=(vmwFont *)malloc(sizeof(vmwFont));
|
||||
data=(char *)calloc(numchars*ysize,(sizeof(char)));
|
||||
|
||||
f=fopen(namest,"r");
|
||||
if (f==NULL) {
|
||||
printf("ERROR loading font file %s.\n",namest);
|
||||
return NULL;
|
||||
}
|
||||
numloop=(numchars*ysize);
|
||||
|
||||
font->width=xsize;
|
||||
font->height=ysize;
|
||||
font->numchars=numchars;
|
||||
font->font_data=data;
|
||||
fonty=0;
|
||||
while ( (!feof(f))&&(fonty<numloop)) {
|
||||
fread(buff,1,16,f);
|
||||
for(i=0;i<16;i++) font->font_data[fonty+i]=buff[i];
|
||||
fonty+=16;
|
||||
}
|
||||
fclose(f);
|
||||
return font;
|
||||
}
|
||||
|
||||
/* Write a one-pixel cross section from location 'line' */
|
||||
/* of text at location x,y */
|
||||
/* using color 'col' and background 'col' */
|
||||
/* using 'background' as a background color if */
|
||||
/* 'transprent' not set. */
|
||||
void vmwTextLine(char *st,int x,int y,int col,int background,int line,
|
||||
int transparent,vmwFont *font,vmwVisual *target)
|
||||
{
|
||||
int i,xx,len;
|
||||
len=strlen(st);
|
||||
for(i=0;i<len;i++)
|
||||
for(xx=0;xx<8;xx++){
|
||||
if ( (font->font_data[(st[i]*font->height)+line])&(128>>xx) )
|
||||
vmwPutPixel((x+(i*8)+xx),y,col,target);
|
||||
else
|
||||
if (!transparent) vmwPutPixel((x+(i*8)+xx),y,background,target);
|
||||
}
|
||||
}
|
||||
|
||||
/* Output a string at location x,y */
|
||||
void vmwTextXY(char *st,int x,int y,int col,int background,int overwrite,
|
||||
vmwFont *font,vmwVisual *target)
|
||||
{
|
||||
int lineon,i,xx,len;
|
||||
|
||||
len=strlen(st);
|
||||
for(lineon=0;lineon<8;lineon++){
|
||||
for(i=0;i<len;i++)
|
||||
for(xx=0;xx<8;xx++){
|
||||
if ( (font->font_data[(st[i]*font->height)+lineon])&(128>>xx) )
|
||||
vmwPutPixel((x+(i*8)+xx),y+lineon,col,target);
|
||||
else
|
||||
if (overwrite)
|
||||
vmwPutPixel((x+(i*8)+xx),y+lineon,background,target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Assume this is a special font with a "small" font at locations */
|
||||
/* 128-255 and display the string */
|
||||
void vmwSmallTextXY(char *st,int x,int y,int col,int background,int overwrite,
|
||||
vmwFont *font,vmwVisual *target)
|
||||
{
|
||||
int lineon,i,xx,len;
|
||||
|
||||
/* This will print out a small 4x5 font located in chars */
|
||||
/* 128-255 in a normal VGA font. These are custom made */
|
||||
/* fonts; they are non-standard */
|
||||
|
||||
len=strlen(st);
|
||||
for(lineon=0;lineon<5;lineon++) {
|
||||
for(i=0;i<len;i++)
|
||||
for(xx=0;xx<5;xx++) {
|
||||
if ( (font->font_data[((st[i]+128)*font->height)+lineon])
|
||||
&(128>>xx) )
|
||||
vmwPutPixel((x+(i*5)+xx),y+lineon,col,target);
|
||||
else
|
||||
if (overwrite)
|
||||
vmwPutPixel((x+(i*5)+xx),y+lineon,background,target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
200
svmwgraph/vmw_paintpro.c
Normal file
200
svmwgraph/vmw_paintpro.c
Normal file
@ -0,0 +1,200 @@
|
||||
/* An implementation of my own legacy "PaintPro[gram] graphics format */
|
||||
|
||||
#include "svmwgraph.h"
|
||||
|
||||
#include <stdio.h> /* For FILE I/O */
|
||||
#include <string.h> /* For strncmp */
|
||||
|
||||
|
||||
/* The "packing" method used by paintpro files */
|
||||
int vmwPack3Bytes(int r, int g, int b) {
|
||||
|
||||
return ( ( ( (r>>3)&0x1f) <<11)+
|
||||
( ( (g>>2)&0x3f) <<5)+
|
||||
( ( (b>>3)&0x1f) ) );
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------*\
|
||||
| vmwLoadPicPacked |
|
||||
| There is so much history in this function, I won't get into |
|
||||
| it here. See the paintpro documentation found elsewhere |
|
||||
\*---------------------------------------------------------------*/
|
||||
|
||||
int vmwLoadPicPacked(int x1,int y1,vmwVisual *target,
|
||||
int LoadPal,int LoadPic,char *FileName)
|
||||
|
||||
/* Retro comments */
|
||||
/*{ Loads a paintpro image, filename, at location x1,y1 *\
|
||||
\* to offset where (vga=$A000) and loadspal if LOADPAL=true */
|
||||
/* Loadsapicture if Loadpic=true and returns error} */
|
||||
|
||||
{
|
||||
unsigned char temp1,temp2,temp3;
|
||||
int errorlev;
|
||||
int int1,int2,i,x,y;
|
||||
char buffer[300];
|
||||
int lastread=0;
|
||||
int buffpointer=0;
|
||||
int picwidth,picheight;
|
||||
FILE *fff;
|
||||
char header[10];
|
||||
int xsize;
|
||||
int ysize;
|
||||
int numcolors;
|
||||
int col,numacross;
|
||||
int temp_palette[256];
|
||||
|
||||
/* Open the file */
|
||||
fff=fopen(FileName,"rb"); /* Windows chokes if no "b" */
|
||||
if (fff==NULL){
|
||||
printf("PPRO error... File \"%s\" not found.\n",FileName);
|
||||
return 1;
|
||||
}
|
||||
|
||||
errorlev=fread(buffer,1,300,fff);
|
||||
/* Check to see if its really a Paintpro File */
|
||||
for (i=0;i<9;i++) {
|
||||
header[i]=buffer[i];
|
||||
}
|
||||
header[9]='\0';
|
||||
if (strncmp(header,"PAINTPROV",9)) {
|
||||
printf("PPRO error... %s is NOT a paintpro file!\n",FileName);
|
||||
return 2;
|
||||
}
|
||||
|
||||
/* Check to see if it is the proper version (currently 6.0) */
|
||||
header[0]=buffer[9];
|
||||
header[1]=buffer[10];
|
||||
header[2]=buffer[11];
|
||||
header[3]='\0';
|
||||
if (strncmp(header,"6.0",3)) {
|
||||
printf("PPRO error... Version %s unsupported, must be >6\n",header);
|
||||
return 3;
|
||||
}
|
||||
|
||||
buffpointer=12;
|
||||
/* Read X and Y sizes */
|
||||
temp1=buffer[buffpointer];
|
||||
temp2=buffer[buffpointer+1];
|
||||
temp3=buffer[buffpointer+2];
|
||||
buffpointer+=3;
|
||||
if (buffpointer>=errorlev) {
|
||||
printf("PPRO error... Early end of file.\n");
|
||||
return 4;
|
||||
}
|
||||
|
||||
/* Split 48 bits into two 32 bit values */
|
||||
xsize=(temp2>>4)+(temp1<<4);
|
||||
ysize=((temp2-((temp2>>4)<<4))<<16)+temp3;
|
||||
|
||||
temp1=buffer[buffpointer];
|
||||
temp2=buffer[buffpointer+1];
|
||||
temp3=buffer[buffpointer+2];
|
||||
buffpointer+=3;
|
||||
if (buffpointer>=errorlev) {
|
||||
printf("PPRO error... Early end of file.\n");
|
||||
return 4;
|
||||
}
|
||||
|
||||
numcolors=(temp2>>4)+(temp1<<4);
|
||||
|
||||
picwidth=xsize+1;
|
||||
picheight=ysize+1;
|
||||
/*Load Palette*/
|
||||
if (numcolors!=256) printf("%d colors is not supported yet.\n",numcolors);
|
||||
|
||||
/* Fun and games to convert the 24 bit color in paintpro to */
|
||||
/* 565 packed 16bit RGB */
|
||||
|
||||
for(i=0;i<256;i++) {
|
||||
temp_palette[i]= vmwPack3Bytes(buffer[buffpointer],
|
||||
buffer[buffpointer+1],
|
||||
buffer[buffpointer+2]);
|
||||
buffpointer+=3;
|
||||
if (buffpointer>=errorlev) {
|
||||
if (errorlev==300) {
|
||||
errorlev=fread(buffer,1,300,fff);
|
||||
buffpointer=0;
|
||||
}
|
||||
else {
|
||||
lastread=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (LoadPal) {
|
||||
for (i=0;i<256;i++) target->palette[i]=temp_palette[i];
|
||||
}
|
||||
|
||||
|
||||
x=x1;
|
||||
y=y1;
|
||||
|
||||
while ((!lastread)&&(LoadPic)&&(y<y1+ysize)) {
|
||||
temp1=buffer[buffpointer];
|
||||
temp2=buffer[buffpointer+1];
|
||||
temp3=buffer[buffpointer+2];
|
||||
buffpointer+=3;
|
||||
if (buffpointer>=errorlev) {
|
||||
if (errorlev==300) {
|
||||
errorlev=fread(buffer,1,300,fff);
|
||||
buffpointer=0;
|
||||
}
|
||||
else lastread=1;
|
||||
}
|
||||
|
||||
int1=(temp2>>4)+(temp1<<4);
|
||||
int2=((temp2-((temp2>>4)<<4))*256)+temp3;
|
||||
|
||||
/* If greater than 2047, we have two single pixels */
|
||||
/* of color int1-2048 and int2-2048 */
|
||||
if (int1>2047) {
|
||||
vmwPutPixel(x,y,int1-2048,target);
|
||||
x++;
|
||||
if (x>xsize+x1) {
|
||||
x=x1; y++;
|
||||
// if (y>ysize-1) {
|
||||
// printf("Blargh 1\n"); y--;
|
||||
// }
|
||||
}
|
||||
vmwPutPixel(x,y,int2-2048,target);
|
||||
x++;
|
||||
if (x>xsize+x1){
|
||||
x=x1;y++;
|
||||
// if (y>ysize) {
|
||||
// printf("Blargh 2\n");
|
||||
// y--;
|
||||
// }
|
||||
}
|
||||
}
|
||||
else { /* Standard paintpro format */
|
||||
col=int1;
|
||||
numacross=int2;
|
||||
while ((x+numacross)>(xsize+x1)) {
|
||||
vmwDrawHLine(x,y,((xsize+x1)-x),col,target);
|
||||
numacross=numacross-((xsize+1)-x);
|
||||
x=x1;
|
||||
y++;
|
||||
if (y>y1+ysize-1) {
|
||||
printf("Blrgh 3\n");
|
||||
}
|
||||
}
|
||||
if ((numacross!=0) && (y<y1+ysize)) {
|
||||
if (numacross+x>xsize+x-1) numacross--; /* Stupid x overflow */
|
||||
vmwDrawHLine(x,y,numacross,col,target);
|
||||
}
|
||||
x=x+numacross;
|
||||
}
|
||||
}
|
||||
|
||||
if (fff!=NULL) fclose(fff);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int vmwSavePicPacked(int x1,int y1,int xsize,int ysize,
|
||||
vmwVisual *source,char *FileName) {
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
25
svmwgraph/vmw_palette.c
Normal file
25
svmwgraph/vmw_palette.c
Normal file
@ -0,0 +1,25 @@
|
||||
/* Palette handling part of the Super VMW Graphics Library */
|
||||
|
||||
#include "svmwgraph.h"
|
||||
|
||||
|
||||
void vmwLoadCustomPalette(vmwVisual *source, int pal[256]) {
|
||||
int i;
|
||||
for (i=0;i<256;i++) {
|
||||
source->palette[i]=pal[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void vmwFadeToBlack(vmwVisual *source) {
|
||||
// int temp_pal[256];
|
||||
// temp_pal=real_pal
|
||||
// for (i=0;i<256;i++) {
|
||||
// temp_pal[i]--;
|
||||
// vmwBlitMemToDisplay()
|
||||
// pauseawhile()
|
||||
//
|
||||
}
|
||||
|
||||
void vmwUnFade(vmwVisual *source) {
|
||||
}
|
11
svmwgraph/vmw_setup.c
Normal file
11
svmwgraph/vmw_setup.c
Normal file
@ -0,0 +1,11 @@
|
||||
|
||||
|
||||
|
||||
int vmwSetup() {
|
||||
// malloc structs
|
||||
// point to SDL
|
||||
}
|
||||
|
||||
int vmwSetupVisual() {
|
||||
// malloc stuff
|
||||
}
|
68
svmwgraph/vmw_sprite.c
Normal file
68
svmwgraph/vmw_sprite.c
Normal file
@ -0,0 +1,68 @@
|
||||
/* Sprite implementation for the Super VMW graphics library */
|
||||
|
||||
#include "svmwgraph.h"
|
||||
#include <stdlib.h> /* for calloc/malloc */
|
||||
|
||||
vmwSprite *vmwGetSprite(int x, int y,
|
||||
int xsize, int ysize,vmwVisual *screen) {
|
||||
|
||||
vmwSprite *temp_sprite;
|
||||
int xtemp,ytemp;
|
||||
|
||||
temp_sprite=calloc(1,sizeof(vmwSprite));
|
||||
temp_sprite->spritedata=calloc(1,xsize*ysize);
|
||||
temp_sprite->xsize=xsize;
|
||||
temp_sprite->ysize=ysize;
|
||||
|
||||
/* The following is very slow and can be easily optimized */
|
||||
|
||||
for(ytemp=0;ytemp<ysize;ytemp++)
|
||||
for(xtemp=0;xtemp<xsize;xtemp++)
|
||||
*((temp_sprite->spritedata)+ytemp*xsize+xtemp)=
|
||||
vmwGetPixel(xtemp+x,ytemp+y,screen);
|
||||
|
||||
return temp_sprite;
|
||||
}
|
||||
|
||||
void vmwPutSprite(vmwSprite *sprite,int x,int y,int shield_color,
|
||||
vmwVisual *screen) {
|
||||
|
||||
unsigned char *temp_source,*temp_destination;
|
||||
int xx,yy;
|
||||
|
||||
temp_source=sprite->spritedata;
|
||||
temp_destination= (unsigned char *)(screen)+(y*320+x);
|
||||
|
||||
for (yy=0;yy<sprite->ysize;yy++) {
|
||||
for (xx=0;xx<sprite->xsize;xx++) {
|
||||
|
||||
if (*temp_source!=0) {
|
||||
*(temp_destination)=*(temp_source);
|
||||
}
|
||||
temp_source++;
|
||||
temp_destination++;
|
||||
}
|
||||
temp_destination+=((screen->xsize-sprite->xsize));
|
||||
}
|
||||
}
|
||||
|
||||
void vmwPutPartialSprite(vmwVisual *destination,
|
||||
vmwSprite *sprite,
|
||||
int x_start,int y_start,
|
||||
int x_stop, int y_stop)
|
||||
{ /* x_start/stop not implemented yet */
|
||||
// int xx,yy;
|
||||
/*
|
||||
* dest+=(dest_stride*y);
|
||||
* for(yy=0;yy<h;yy++){
|
||||
* for(xx=0;xx<w;xx++)
|
||||
* if ((*(src+xx)) && ((yy>=y_start) && (yy<=y_stop)) )
|
||||
* memcpy(dest+(stride_factor*(xx+x)),(src+xx),stride_factor);
|
||||
* // **(dest+xx+x)=15;
|
||||
* src+=w;
|
||||
* dest+=dest_stride;
|
||||
* }
|
||||
* */
|
||||
return;
|
||||
|
||||
}
|
16
tb1-2.9.0.lsm
Normal file
16
tb1-2.9.0.lsm
Normal file
@ -0,0 +1,16 @@
|
||||
Begin3
|
||||
Title: tb1
|
||||
Version: 2.9.0
|
||||
Entered-date: 28FEB98
|
||||
Description: A really cool arcade game.
|
||||
Shoot the aliens, save the world.
|
||||
Keywords: tom bombem alien game arcade ggi
|
||||
Author: weave@eng.umd.edu (Vince Weaver)
|
||||
Maintained-by: weave@eng.umd.edu (Vince Weaver)
|
||||
Primary-site: sunsite.unc.edu /pub/Linux/games/arcade
|
||||
100kB tb1-2.9.0.tar.gz
|
||||
Alternate-site: http://www.glue.umd.edu/~weave/tb1
|
||||
Original-site:
|
||||
Platforms: Any that have gcc and support ggi
|
||||
Copying-policy: GPL
|
||||
End
|
23
tblib.c
23
tblib.c
@ -14,6 +14,25 @@
|
||||
#include "string.h"
|
||||
#include "sound.h"
|
||||
|
||||
|
||||
void pauseawhile(int howlong) {
|
||||
|
||||
struct timeval bob;
|
||||
struct timezone mree;
|
||||
long begin_s,begin_u;
|
||||
|
||||
vmwClearKeyboardBuffer();
|
||||
gettimeofday(&bob,&mree);
|
||||
begin_s=bob.tv_sec; begin_u=bob.tv_usec;
|
||||
while ((bob.tv_sec-begin_s)<howlong) {
|
||||
if (vmwGetInput()) return;
|
||||
usleep(30);
|
||||
gettimeofday(&bob,&mree);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Convenience Function */
|
||||
int change_shields(struct tb1_state *game_state)
|
||||
{
|
||||
@ -1194,7 +1213,9 @@ void playthegame(struct tb1_state *game_state)
|
||||
}
|
||||
|
||||
if (game_state->level==1) {
|
||||
levelone(game_state);
|
||||
game_state->level=2;
|
||||
leveltwoengine(game_state);
|
||||
// levelone(game_state);
|
||||
// if(level==2) littleopener2();
|
||||
}
|
||||
if (game_state->level==2) {
|
||||
|
@ -19,8 +19,8 @@
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <ggi/libggi.h>
|
||||
#include "../svmwgrap.h"
|
||||
#include "../gtblib.h"
|
||||
#include "svmwgrap.h"
|
||||
#include "tblib.h"
|
||||
|
||||
/* Exported Global Variables */
|
||||
ggi_visual_t vis,vaddr,vaddr2;
|
||||
@ -38,13 +38,6 @@ char path_to_data[256];
|
||||
struct timeval time_info;
|
||||
struct timezone dontcare;
|
||||
|
||||
/*----------------*/
|
||||
|
||||
int game_map[12][200];
|
||||
int max_x,max_y,u_x,u_y,x_pos=0,y_pos=0,x,y;
|
||||
char tempst[40];
|
||||
|
||||
|
||||
/* Setup the Graphics */
|
||||
int setup_graphics(int force_8bpp)
|
||||
{
|
||||
@ -195,7 +188,7 @@ int main(int argc,char **argv)
|
||||
srandom(time(NULL));
|
||||
|
||||
/* Load the tom bombem font */
|
||||
tb1_font=LoadVMWFont("../data/tbfont.tb1",8,16,256);
|
||||
tb1_font=LoadVMWFont(tb1_data_file("tbfont.tb1",(char *)tempst),8,16,256);
|
||||
|
||||
/* Setup Graphics */
|
||||
if (setup_graphics(force_8bpp)==2) {
|
||||
@ -217,36 +210,58 @@ int main(int argc,char **argv)
|
||||
|
||||
Load the title screen */
|
||||
grapherror=GGILoadPicPacked(0,0,vis,1,1,
|
||||
"../data/tbomb1.tb1",
|
||||
tb1_data_file("tbomb1.tb1",(char *)tempst),
|
||||
(ggi_color *)&eight_bit_pal,
|
||||
(ggi_pixel *)&tb1_pal,color_depth);
|
||||
grapherror=GGILoadPicPacked(0,0,vaddr2,1,1,
|
||||
"../data/tbomb1.tb1",
|
||||
tb1_data_file("tbomb1.tb1",(char *)tempst),
|
||||
(ggi_color *)&eight_bit_pal,
|
||||
(ggi_pixel *)&tb1_pal,color_depth);
|
||||
ggiFlush(vis);
|
||||
ggiFlush(vaddr2);
|
||||
pauseawhile(5);
|
||||
|
||||
max_x=12;max_y=200;
|
||||
x_pos=0; y_pos=0;
|
||||
|
||||
for(x=0;x<max_x;x++)
|
||||
for(y=0;y<max_y;y++)
|
||||
game_map[x][y]=(rand()%26)+65;
|
||||
|
||||
/* Main Menu Loop */
|
||||
while (1) {
|
||||
|
||||
vmwCrossBlit(plb_vis->write,plb_vaddr->read,plb_vis->stride,200);
|
||||
vmwCrossBlit(plb_vis->write,plb_vaddr2->read,plb_vis->stride,200);
|
||||
ggiFlush(vis);
|
||||
|
||||
barpos=0;
|
||||
|
||||
VMWtextxy("F1 HELP",0,190,tb1_pal[9],tb1_pal[7],0,tb1_font,vis);
|
||||
coolbox(117,61,199,140,1,vis);
|
||||
ggiFlush(vis);
|
||||
ch=0;
|
||||
|
||||
|
||||
while(ch!=TB_ENTER){
|
||||
if (barpos==0) VMWtextxy("NEW GAME",123,67,
|
||||
tb1_pal[32],tb1_pal[0],1,tb1_font,vis);
|
||||
else VMWtextxy("NEW GAME",123,67,
|
||||
tb1_pal[32],tb1_pal[7],1,tb1_font,vis);
|
||||
if (barpos==1) VMWtextxy("OPTIONS",123,77,
|
||||
tb1_pal[32],tb1_pal[0],1,tb1_font,vis);
|
||||
else VMWtextxy("OPTIONS",123,77,
|
||||
tb1_pal[32],tb1_pal[7],1,tb1_font,vis);
|
||||
if (barpos==2) VMWtextxy("ABOUT",123,87,
|
||||
tb1_pal[32],tb1_pal[0],1,tb1_font,vis);
|
||||
else VMWtextxy("ABOUT",123,87,
|
||||
tb1_pal[32],tb1_pal[7],1,tb1_font,vis);
|
||||
if (barpos==3) VMWtextxy("LOAD GAME",123,97,
|
||||
tb1_pal[32],tb1_pal[0],1,tb1_font,vis);
|
||||
else VMWtextxy("LOAD GAME",123,97,
|
||||
tb1_pal[32],tb1_pal[7],1,tb1_font,vis);
|
||||
if (barpos==4) VMWtextxy("STORY",123,107,
|
||||
tb1_pal[32],tb1_pal[0],1,tb1_font,vis);
|
||||
else VMWtextxy("STORY",123,107,
|
||||
tb1_pal[32],tb1_pal[7],1,tb1_font,vis);
|
||||
if (barpos==5) VMWtextxy("CREDITS",123,117,
|
||||
tb1_pal[32],tb1_pal[0],1,tb1_font,vis);
|
||||
else VMWtextxy("CREDITS",123,117,
|
||||
tb1_pal[32],tb1_pal[7],1,tb1_font,vis);
|
||||
if (barpos==6) VMWtextxy("QUIT",123,127,
|
||||
tb1_pal[32],tb1_pal[0],1,tb1_font,vis);
|
||||
else VMWtextxy("QUIT",123,127,
|
||||
tb1_pal[32],tb1_pal[7],1,tb1_font,vis);
|
||||
ggiFlush(vis);
|
||||
|
||||
while( ((ch=get_input())==0)) {
|
||||
usleep(10);
|
||||
@ -254,26 +269,15 @@ int main(int argc,char **argv)
|
||||
|
||||
/* Change menu position based on key pressed */
|
||||
ch2=toupper(ch);
|
||||
if (ch==TB_DOWN) y_pos++;
|
||||
if (ch==TB_RIGHT) x_pos++;
|
||||
if (ch==TB_UP) y_pos--;
|
||||
if (ch==TB_LEFT) x_pos--;
|
||||
if (y_pos<0) y_pos=0; if(x_pos<0) x_pos=0;
|
||||
if (y_pos>(max_y-20)) y_pos=max_y-20;
|
||||
if (x_pos>(max_x)) x_pos=max_x;
|
||||
|
||||
ggiSetGCForeground(vaddr,tb1_pal[0]);
|
||||
ggiFillscreen(vaddr);
|
||||
|
||||
|
||||
for(x=0;x<max_x;x++)
|
||||
for(y=y_pos;y<(y_pos+20);y++) {
|
||||
sprintf(tempst,"%c",game_map[x][y]);
|
||||
VMWtextxy(tempst,x*20,(y-y_pos)*10,
|
||||
tb1_pal[32],tb1_pal[0],1,tb1_font,vaddr);
|
||||
|
||||
}
|
||||
|
||||
if ((ch==TB_DOWN)||(ch==TB_RIGHT)) barpos++;
|
||||
if ((ch==TB_UP) || (ch==TB_LEFT)) barpos--;
|
||||
if (ch==TB_F1) {barpos=10; ch=TB_ENTER;} /*F1*/
|
||||
if (ch2=='N') barpos=0; /*N*/
|
||||
if (ch2=='O') barpos=1; /*O*/
|
||||
if (ch2=='A') barpos=2; /*A*/
|
||||
if (ch2=='L') barpos=3; /*L*/
|
||||
if (ch2=='S') barpos=4; /*S*/
|
||||
if (ch2=='C') barpos=5; /*C*/
|
||||
if (ch2=='Q') barpos=6; /*Q*/
|
||||
if (ch==27){ /* escape */
|
||||
barpos=6;
|
||||
@ -281,8 +285,8 @@ int main(int argc,char **argv)
|
||||
}
|
||||
if(barpos==7) barpos=0;
|
||||
if(barpos<0) barpos=6;
|
||||
|
||||
}
|
||||
/* Run whatever it was that the person pressed */
|
||||
if(barpos==6) quit();
|
||||
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ggi/libggi.h>
|
||||
#include "../svmwgrap.h"
|
||||
#include "svmwgrap.h"
|
||||
|
||||
ggi_visual_t vis,vaddr;
|
||||
uint white;
|
52
vmw_sprite.c
52
vmw_sprite.c
@ -1,52 +0,0 @@
|
||||
#include "SDL.h"
|
||||
#include "sdl_svmwgraph.h"
|
||||
#include "vmw_sprite.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
extern unsigned int global_palette[256];
|
||||
|
||||
|
||||
struct vmwSprite *vmwGetSprite(int x, int y,
|
||||
int xsize, int ysize,unsigned char *screen) {
|
||||
|
||||
struct vmwSprite *temp_sprite;
|
||||
int xtemp,ytemp;
|
||||
|
||||
temp_sprite=calloc(1,sizeof(struct vmwSprite));
|
||||
temp_sprite->spritedata=calloc(1,xsize*ysize);
|
||||
temp_sprite->xsize=xsize;
|
||||
temp_sprite->ysize=ysize;
|
||||
|
||||
/* The following is very slow and can be easily optimized */
|
||||
|
||||
for(ytemp=0;ytemp<ysize;ytemp++)
|
||||
for(xtemp=0;xtemp<xsize;xtemp++)
|
||||
*((temp_sprite->spritedata)+ytemp*xsize+xtemp)=
|
||||
vmwGetPixel(xtemp+x,ytemp+y,screen);
|
||||
|
||||
return temp_sprite;
|
||||
}
|
||||
|
||||
void vmwPutSprite(struct vmwSprite *sprite,int x,int y,int shield_color,
|
||||
unsigned char *screen) {
|
||||
|
||||
unsigned char *temp_source,*temp_destination;
|
||||
int i=0,xx,yy;
|
||||
|
||||
temp_source=sprite->spritedata;
|
||||
temp_destination= ((Uint8 *)screen)+(y*320+x)*2;
|
||||
|
||||
for (yy=0;yy<sprite->ysize;yy++) {
|
||||
for (xx=0;xx<sprite->xsize;xx++) {
|
||||
|
||||
if (*temp_source!=0) {
|
||||
*((Uint16 *)(temp_destination))=global_palette[*(temp_source)];
|
||||
}
|
||||
temp_source++;
|
||||
temp_destination+=2;
|
||||
}
|
||||
temp_destination+=((320-sprite->xsize)*2);
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user