Commit 79356e2e authored by Steven Fuller's avatar Steven Fuller

Fixed map loading bug when you died (instead of returning the resource

itself, return a copy of the resource).

Updated res.c to do more work by making copies of resources and freeing the
copies when released.

Removed a few lines of unused code, etc

TODO: find where/why GameShapes (and/or the memory it is pointing to) is
getting trashed.
parent aa014f57
...@@ -642,24 +642,6 @@ void KillAResource(Word RezNum) ...@@ -642,24 +642,6 @@ void KillAResource(Word RezNum)
KillAResource2(RezNum, BRGR); KillAResource2(RezNum, BRGR);
} }
void SaveJunk(void *AckPtr,Word Length)
{
static Word Count=1;
FILE *fp;
char SaveName[40];
sprintf(SaveName,"SprRec%d",Count);
fp = fopen(SaveName,"wb");
fwrite(AckPtr,1,Length,fp);
fclose(fp);
++Count;
}
/**********************************
Kill a global resource
**********************************/
unsigned short SwapUShort(unsigned short Val) unsigned short SwapUShort(unsigned short Val)
{ {
return ((Val<<8) | (Val>>8)); return ((Val<<8) | (Val>>8));
...@@ -690,6 +672,7 @@ void DLZSS(Byte *Dest,Byte *Src,LongWord Length) ...@@ -690,6 +672,7 @@ void DLZSS(Byte *Dest,Byte *Src,LongWord Length)
++Dest; ++Dest;
--Length; --Length;
} else { } else {
/* TODO - sounds have this line the other way around */
RunCount = (Word) Src[0] | ((Word) Src[1]<<8); RunCount = (Word) Src[0] | ((Word) Src[1]<<8);
Fun = 0x1000-(RunCount&0xfff); Fun = 0x1000-(RunCount&0xfff);
BackPtr = Dest-Fun; BackPtr = Dest-Fun;
...@@ -720,9 +703,9 @@ void DLZSS(Byte *Dest,Byte *Src,LongWord Length) ...@@ -720,9 +703,9 @@ void DLZSS(Byte *Dest,Byte *Src,LongWord Length)
**********************************/ **********************************/
/* TODO */ /* TODO - cheap way to find MSB problems */
#include <sys/types.h> #include <sys/types.h>
#include <signal.h> #include <signal.h>
void *AllocSomeMem(LongWord Size) void *AllocSomeMem(LongWord Size)
{ {
...@@ -732,33 +715,6 @@ void *AllocSomeMem(LongWord Size) ...@@ -732,33 +715,6 @@ void *AllocSomeMem(LongWord Size)
return (void *)malloc(Size); return (void *)malloc(Size);
} }
/**********************************
Allocate some memory
**********************************/
static Word FreeStage(Word Stage,LongWord Size)
{
switch (Stage) {
case 1:
PurgeAllSounds(Size); /* Kill off sounds until I can get memory */
break;
case 2:
PlaySound(0); /* Shut down all sounds... */
PurgeAllSounds(Size); /* Purge them */
break;
case 3:
PlaySong(0); /* Kill music */
FreeSong(); /* Purge it */
PurgeAllSounds(Size); /* Make SURE it's gone! */
break;
case 4:
return 0;
}
return Stage+1;
}
/********************************** /**********************************
Release some memory Release some memory
......
...@@ -73,7 +73,6 @@ Byte *rw_texture; ...@@ -73,7 +73,6 @@ Byte *rw_texture;
LongWord rw_scale; LongWord rw_scale;
Byte *ArtData[64]; Byte *ArtData[64];
void *SpriteArray[S_LASTONE]; void *SpriteArray[S_LASTONE];
Word MacVidSize = -1;
Word SlowDown = 1; /* Force the game to 15 hz */ Word SlowDown = 1; /* Force the game to 15 hz */
Word MouseEnabled = 0; /* Allow mouse control */ Word MouseEnabled = 0; /* Allow mouse control */
Word GameViewSize = 0; /* Size of the game screen */ Word GameViewSize = 0; /* Size of the game screen */
...@@ -81,7 +80,6 @@ Word NoWeaponDraw=1; /* Flag to not draw the weapon on the screen */ ...@@ -81,7 +80,6 @@ Word NoWeaponDraw=1; /* Flag to not draw the weapon on the screen */
maplist_t *MapListPtr; /* Pointer to map info record */ maplist_t *MapListPtr; /* Pointer to map info record */
unsigned short *SongListPtr; /* Pointer to song list record */ unsigned short *SongListPtr; /* Pointer to song list record */
unsigned short *WallListPtr; /* Pointer to wall list record */ unsigned short *WallListPtr; /* Pointer to wall list record */
Word MaxScaler = 1; /* Maximum number of VALID scalers */
Boolean ShowPush; /* Cheat for pushwalls */ Boolean ShowPush; /* Cheat for pushwalls */
Byte textures[MAPSIZE*2+5][MAPSIZE]; /* Texture indexes */ Byte textures[MAPSIZE*2+5][MAPSIZE]; /* Texture indexes */
Word NaziSound[] = {SND_ESEE,SND_ESEE2,SND_ESEE3,SND_ESEE4}; Word NaziSound[] = {SND_ESEE,SND_ESEE2,SND_ESEE3,SND_ESEE4};
......
...@@ -281,10 +281,14 @@ void SpawnStand(Word x,Word y,class_t which) ...@@ -281,10 +281,14 @@ void SpawnStand(Word x,Word y,class_t which)
Word *TilePtr; Word *TilePtr;
Word tile; Word tile;
if (numactors >= MAXACTORS) {
fprintf("SpawnStand DEBUG (%d, %d)\n", numactors, MAXACTORS);
}
if (numactors==MAXACTORS) { /* Too many actors already? */ if (numactors==MAXACTORS) { /* Too many actors already? */
return; /* Exit */ return; /* Exit */
} }
EnemyHits[which] = 1; EnemyHits[which] = 1;
info = &classinfo[which]; /* Get the pointer to the basic info */ info = &classinfo[which]; /* Get the pointer to the basic info */
state = info->standstate; /* Get the state logic value */ state = info->standstate; /* Get the state logic value */
...@@ -324,6 +328,10 @@ void SpawnAmbush(Word x,Word y,class_t which) ...@@ -324,6 +328,10 @@ void SpawnAmbush(Word x,Word y,class_t which)
{ {
actor_t *ActorPtr; actor_t *ActorPtr;
if (numactors >= MAXACTORS) {
fprintf("SpawnAmbush DEBUG (%d, %d)\n", numactors, MAXACTORS);
}
ActorPtr = &actors[numactors]; /* Get the pointer to the new actor entry */ ActorPtr = &actors[numactors]; /* Get the pointer to the new actor entry */
SpawnStand(x,y,which); /* Fill in all the entries */ SpawnStand(x,y,which); /* Fill in all the entries */
ActorPtr->flags |= FL_AMBUSH; /* Set the ambush flag */ ActorPtr->flags |= FL_AMBUSH; /* Set the ambush flag */
...@@ -458,16 +466,19 @@ void SpawnThings(void) ...@@ -458,16 +466,19 @@ void SpawnThings(void)
Word *EnemyPtr; Word *EnemyPtr;
memset(EnemyHits,0,sizeof(EnemyHits)); memset(EnemyHits,0,sizeof(EnemyHits));
spawn_p = (Byte *)MapPtr+MapPtr->spawnlistofs; /* Point to the spawn table */ spawn_p = (Byte *)MapPtr+MapPtr->spawnlistofs; /* Point to the spawn table */
Count = MapPtr->numspawn; /* How many items to spawn? */ Count = MapPtr->numspawn; /* How many items to spawn? */
if (!Count) { if (!Count) {
return; return;
} }
do { do {
x = spawn_p[0]; /* Get the X */ x = spawn_p[0]; /* Get the X */
y = spawn_p[1]; /* Get the y */ y = spawn_p[1]; /* Get the y */
type = spawn_p[2]; /* Get the type */ type = spawn_p[2]; /* Get the type */
spawn_p+=3; /* Index past the record */ spawn_p+=3; /* Index past the record */
if (type<19) { if (type<19) {
continue; continue;
} else if (type<23) { /* 19-22 */ } else if (type<23) { /* 19-22 */
......
...@@ -4,8 +4,8 @@ CC = gcc ...@@ -4,8 +4,8 @@ CC = gcc
#CFLAGS = -g -Wall -O6 -fomit-frame-pointer -ffast-math -funroll-loops -mpentiumpro -mcpu=pentiumpro -march=pentiumpro #CFLAGS = -g -Wall -O6 -fomit-frame-pointer -ffast-math -funroll-loops -mpentiumpro -mcpu=pentiumpro -march=pentiumpro
#CFLAGS = -g -Wall #CFLAGS = -g -Wall
#CFLAGS = -g -DNOVGA #CFLAGS = -g -DNOVGA
CFLAGS = -g #CFLAGS = -g
#CFLAGS = -Os -g CFLAGS = -Os -g
#CFLAGS = -g -Wall -I/home/relnev/cvs/oal/include #CFLAGS = -g -Wall -I/home/relnev/cvs/oal/include
OBJS = Data.o Doors.o EnMove.o EnThink.o Intro.o Level.o \ OBJS = Data.o Doors.o EnMove.o EnThink.o Intro.o Level.o \
......
* remove NOVGA when other ports are added. NOVGA is a hack for using * remove NOVGA when other ports are added. NOVGA is a hack for using
ElectricFence (since svgalib doesn't work too well with it) ElectricFence (since svgalib doesn't work too well with it)
* fix return value of DoEvents
* when you die, where do all the sprites go?
* drawing seems like its imprecise, stationary sprites move back and forth, * drawing seems like its imprecise, stationary sprites move back and forth,
and walls 'swim' when you move around, or sprites pop into different sizes and walls 'swim' when you move around, or sprites pop into different sizes
when are far enough and get closer/farther away when are far enough and get closer/farther away
* Word is 16bit damnit, wonder why in the MAC version its 32bits?! * Word is 16bit damnit, wonder why in the MAC version its 32bits?!
* How about adding red/white shifts (from PC wolf3d)? * How about adding red/white shifts (from PC wolf3d)?
* it crashes somewhere, no reason why... * it crashes somewhere, no reason why...
#0 0x804fa55 in DrawXMShape (x=128, y=96, ShapePtr=0x8c8c8c8c) at
Burger.c:198
But what is trashing GameShapes's memory?
I don't think GameShapes itself is being ran over, just the memory allocated
to it...
* Pause key * Pause key
* menu type stuff in svgalib version (would use the Fx keys to save game
etc, text menus for options?)
* when saving/loading games, run them through htons/etc.
...@@ -296,7 +296,7 @@ void PrepPlayLoop (void) ...@@ -296,7 +296,7 @@ void PrepPlayLoop (void)
Again: Again:
ReleaseMap(); /* Oh oh... */ ReleaseMap(); /* Oh oh... */
if (!GameViewSize) { /* Smallest screen? */ if (!GameViewSize) { /* Smallest screen? */
BailOut(); /* Leave... */ Quit("PrepPlayLoop failed"); /* Leave... */
} }
--GameViewSize; /* Smaller screen size */ --GameViewSize; /* Smaller screen size */
GameViewSize = NewGameWindow(GameViewSize); GameViewSize = NewGameWindow(GameViewSize);
...@@ -424,6 +424,7 @@ skipbrief: ...@@ -424,6 +424,7 @@ skipbrief:
ShowGetPsyched(); ShowGetPsyched();
PrepPlayLoop(); /* Init internal variables */ PrepPlayLoop(); /* Init internal variables */
EndGetPsyched(); EndGetPsyched();
FlushKeys();
PlayLoop(); /* Play the game */ PlayLoop(); /* Play the game */
if (playstate == EX_DIED) { /* Did you die? */ if (playstate == EX_DIED) { /* Did you die? */
--gamestate.lives; /* Remove a life */ --gamestate.lives; /* Remove a life */
......
...@@ -93,4 +93,3 @@ void KillAResource(Word RezNum); ...@@ -93,4 +93,3 @@ void KillAResource(Word RezNum);
void *LoadAResource2(Word RezNum,LongWord Type); void *LoadAResource2(Word RezNum,LongWord Type);
void ReleaseAResource2(Word RezNum,LongWord Type); void ReleaseAResource2(Word RezNum,LongWord Type);
void KillAResource2(Word RezNum,LongWord Type); void KillAResource2(Word RezNum,LongWord Type);
void SaveJunk(void *AckPtr,Word Length);
...@@ -9,6 +9,9 @@ typedef struct ResItem_t ...@@ -9,6 +9,9 @@ typedef struct ResItem_t
Word item; Word item;
Byte *dat; Byte *dat;
int size;
Byte *buf;
struct ResItem_t *next; struct ResItem_t *next;
} ResItem; } ResItem;
...@@ -76,6 +79,8 @@ int InitResources(char *name) ...@@ -76,6 +79,8 @@ int InitResources(char *name)
t->dat = (Byte *)malloc(datalen); t->dat = (Byte *)malloc(datalen);
fread(t->dat, datalen, 1, fp); fread(t->dat, datalen, 1, fp);
t->size = datalen;
t->buf = NULL;
*cur = t; *cur = t;
...@@ -97,12 +102,27 @@ void *LoadAResource2(Word RezNum, LongWord Type) ...@@ -97,12 +102,27 @@ void *LoadAResource2(Word RezNum, LongWord Type)
ResItem *c = lr; ResItem *c = lr;
while (c != NULL) { while (c != NULL) {
if ( (c->type == Type) && (c->item == RezNum) ) if ( (c->type == Type) && (c->item == RezNum) ) {
return c->dat; if (c->buf == NULL) {
c->buf = malloc(c->size);
memcpy(c->buf, c->dat, c->size);
} else {
/* DEBUG: we want a fresh copy... */
printf("DEBUG: Item %d/%d already loaded!\n", Type, RezNum);
free(c->buf);
c->buf = malloc(c->size);
memcpy(c->buf, c->dat, c->size);
}
if (c->buf == NULL)
Quit("MALLOC FAILED?");
return c->buf;
}
c = c->next; c = c->next;
} }
fprintf(stderr, "ERROR: %ld/%d was not found!\n", Type, RezNum); fprintf(stderr, "ERROR (LoadAResource2): %ld/%d was not found!\n", Type, RezNum);
AllocSomeMem(666666666); /* TODO: hack! */ AllocSomeMem(666666666); /* TODO: hack! */
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
...@@ -112,17 +132,22 @@ void ReleaseAResource2(Word RezNum, LongWord Type) ...@@ -112,17 +132,22 @@ void ReleaseAResource2(Word RezNum, LongWord Type)
ResItem *c = lr; ResItem *c = lr;
while (c != NULL) { while (c != NULL) {
if ( (c->type == Type) && (c->item == RezNum) ) {
if (c->buf)
free(c->buf);
c->buf = NULL;
return;
}
c = c->next; c = c->next;
} }
fprintf(stderr, "ERROR (ReleaseAResource2): %ld/%d was not found!\n", Type, RezNum);
AllocSomeMem(666666666); /* TODO: hack! */
exit(EXIT_FAILURE);
} }
void KillAResource2(Word RezNum, LongWord Type) void KillAResource2(Word RezNum, LongWord Type)
{ {
ResItem *c = lr; ReleaseAResource2(RezNum, Type);
while (c != NULL) {
c = c->next;
}
} }
void FreeResources() void FreeResources()
...@@ -135,6 +160,9 @@ void FreeResources() ...@@ -135,6 +160,9 @@ void FreeResources()
if (c->dat) if (c->dat)
free(c->dat); free(c->dat);
if (c->buf)
free(c->buf);
c = c->next; c = c->next;
free(t); free(t);
......
...@@ -100,21 +100,25 @@ void DrawSmall(Word x,Word y,Word tile) ...@@ -100,21 +100,25 @@ void DrawSmall(Word x,Word y,Word tile)
} while (++Height<16); } while (++Height<16);
} }
LongWord PsyTime;
void ShowGetPsyched(void) void ShowGetPsyched(void)
{ {
LongWord *PackPtr; LongWord *PackPtr;
Byte *ShapePtr; Byte *ShapePtr;
LongWord PackLength; LongWord PackLength;
Word X,Y; Word X,Y;
PsyTime = ReadTick() + 60*2;
ClearTheScreen(BLACK); ClearTheScreen(BLACK);
BlastScreen(); BlastScreen();
PackPtr = LoadAResource(rGetPsychPic); PackPtr = LoadAResource(rGetPsychPic);
PackLength = lMSB(PackPtr[0]); PackLength = lMSB(PackPtr[0]);
ShapePtr = AllocSomeMem(PackLength); ShapePtr = AllocSomeMem(PackLength);
DLZSS(ShapePtr,(Byte *) &PackPtr[1],PackLength); DLZSS(ShapePtr,(Byte *) &PackPtr[1],PackLength);
X = 10; /* TODO */ X = (VidWidth-224)/2;
Y = 100; Y = (ViewHeight-56)/2;
DrawShape(X,Y,ShapePtr); DrawShape(X,Y,ShapePtr);
FreeSomeMem(ShapePtr); FreeSomeMem(ShapePtr);
ReleaseAResource(rGetPsychPic); ReleaseAResource(rGetPsychPic);
...@@ -130,6 +134,8 @@ void DrawPsyched(Word Index) ...@@ -130,6 +134,8 @@ void DrawPsyched(Word Index)
void EndGetPsyched(void) void EndGetPsyched(void)
{ {
while (PsyTime > ReadTick()) ;
SetAPalette(rBlackPal); SetAPalette(rBlackPal);
} }
...@@ -242,12 +248,6 @@ void PurgeAllSounds(unsigned long minMemory) ...@@ -242,12 +248,6 @@ void PurgeAllSounds(unsigned long minMemory)
{ {
} }
void BailOut()
{
printf("BailOut()\n");
exit(1);
}
Word ChooseGameDiff(void) Word ChooseGameDiff(void)
{ {
/* 0 = easy, 1 = normal, 2 = hard, 3 = death incarnate */ /* 0 = easy, 1 = normal, 2 = hard, 3 = death incarnate */
......
...@@ -106,11 +106,14 @@ void BlastScreen() ...@@ -106,11 +106,14 @@ void BlastScreen()
int i; int i;
#ifndef NOVGA #ifndef NOVGA
for (i = 0; i < 200; i++) { for (i = 0; i < 200; i++) {
memcpy(ptrd, ptrs, 320); memcpy(ptrd, ptrs, 320);
ptrs += w; ptrs += w;
ptrd += 320; ptrd += 320;
} }
/* memcpy(ptrd, ptrs, w * h); */
#endif #endif
} }
...@@ -120,6 +123,7 @@ Word VidVs[] = {160,320,320,400}; ...@@ -120,6 +123,7 @@ Word VidVs[] = {160,320,320,400};
Word VidPics[] = {rFaceShapes,rFace512,rFace640,rFace640}; Word VidPics[] = {rFaceShapes,rFace512,rFace640,rFace640};
Word VidSize = -1; Word VidSize = -1;
int VidModes[] = { G320x200x256, G512x384x256, G640x400x256, G640x480x256 };
Word ScaleX(Word x) Word ScaleX(Word x)
{ {
switch(VidSize) { switch(VidSize) {
...@@ -174,8 +178,15 @@ Word NewGameWindow(Word NewVidSize) ...@@ -174,8 +178,15 @@ Word NewGameWindow(Word NewVidSize)
free(gfxbuf); free(gfxbuf);
gfxbuf = (Byte *)malloc(w * h); gfxbuf = (Byte *)malloc(w * h);
#ifndef NOVGA #ifndef NOVGA
/*
if (!vga_hasmode(VidModes[NewVidSize]))
Quit("SVGAlib does not support this mode");
vga_setmode(VidModes[NewVidSize]);
vga_setlinearaddressing();
*/
vga_setmode(G320x200x256); vga_setmode(G320x200x256);
#endif #endif
...@@ -187,26 +198,24 @@ Word NewGameWindow(Word NewVidSize) ...@@ -187,26 +198,24 @@ Word NewGameWindow(Word NewVidSize)
BlastScreen(); BlastScreen();
LongPtr = (LongWord *) LoadAResource(VidPics[NewVidSize]); LongPtr = (LongWord *) LoadAResource(VidPics[NewVidSize]);
if (GameShapes) if (GameShapes)
FreeSomeMem(GameShapes); FreeSomeMem(GameShapes);
GameShapes = (Byte **) AllocSomeMem(lMSB(LongPtr[0])); GameShapes = (Byte **)AllocSomeMem(lMSB(LongPtr[0]));
DLZSS((Byte *)GameShapes,(Byte *) &LongPtr[1],lMSB(LongPtr[0])); DLZSS((Byte *)GameShapes, (Byte *)&LongPtr[1], lMSB(LongPtr[0]));
ReleaseAResource(rFaceShapes); ReleaseAResource(VidPics[NewVidSize]);
LongPtr = (LongWord *)GameShapes; LongPtr = (LongWord *)GameShapes;
DestPtr = (Byte *)GameShapes; DestPtr = (Byte *)GameShapes;
for (i = 0; i < ((NewVidSize == 1) ? 57 : 47); i++) for (i = 0; i < ((NewVidSize == 1) ? 57 : 47); i++)
GameShapes[i] = DestPtr + lMSB(LongPtr[i]); GameShapes[i] = DestPtr + lMSB(LongPtr[i]);
VidSize = NewVidSize; VidSize = NewVidSize;
return VidSize; return VidSize;
} }
LongWord ScaleDiv[2048];
void ScaledDraw(Byte *gfx, Word scale, Byte *vid, LongWord TheFrac, Word TheInt, Word Width, LongWord Delta) void ScaledDraw(Byte *gfx, Word scale, Byte *vid, LongWord TheFrac, Word TheInt, Word Width, LongWord Delta)
{ {
LongWord OldDelta; LongWord OldDelta;
...@@ -246,7 +255,7 @@ void IO_ScaleWallColumn(Word x, Word scale, Word tile, Word column) ...@@ -246,7 +255,7 @@ void IO_ScaleWallColumn(Word x, Word scale, Word tile, Word column)
} }
y = (scale-VIEWHEIGHT)/2; y = (scale-VIEWHEIGHT)/2;
y = y*TheFrac; y *= TheFrac;
TheInt = TheFrac>>24; TheInt = TheFrac>>24;
TheFrac <<= 8; TheFrac <<= 8;
...@@ -279,8 +288,10 @@ void IO_ScaleMaskedColumn(Word x,Word scale, unsigned short *CharPtr,Word column ...@@ -279,8 +288,10 @@ void IO_ScaleMaskedColumn(Word x,Word scale, unsigned short *CharPtr,Word column
return; return;
CharPtr2 = (Byte *) CharPtr; CharPtr2 = (Byte *) CharPtr;
TheFrac = ScaleDiv[scale];
RunPtr = (SpriteRun *) &CharPtr[sMSB(CharPtr[column+1])/2]; TheFrac = 0x40000000/scale;
RunPtr = (SpriteRun *)&CharPtr[sMSB(CharPtr[column+1])/2];
Screenad = &VideoPointer[x]; Screenad = &VideoPointer[x];
TFrac = TheFrac<<8; TFrac = TheFrac<<8;
TInt = TheFrac>>24; TInt = TheFrac>>24;
...@@ -288,14 +299,14 @@ void IO_ScaleMaskedColumn(Word x,Word scale, unsigned short *CharPtr,Word column ...@@ -288,14 +299,14 @@ void IO_ScaleMaskedColumn(Word x,Word scale, unsigned short *CharPtr,Word column
while (RunPtr->Topy != 0xFFFF) { while (RunPtr->Topy != 0xFFFF) {
Y1 = scale*(LongWord)sMSB(RunPtr->Topy)/128+TopY; Y1 = scale*(LongWord)sMSB(RunPtr->Topy)/128+TopY;
if (Y1<(int)VIEWHEIGHT) { if (Y1 < VIEWHEIGHT) {
Y2 = scale*(LongWord)sMSB(RunPtr->Boty)/128+TopY; Y2 = scale*(LongWord)sMSB(RunPtr->Boty)/128+TopY;
if (Y2>0) { if (Y2 > 0) {
if (Y2>(int)VIEWHEIGHT) if (Y2 > VIEWHEIGHT)
Y2 = VIEWHEIGHT; Y2 = VIEWHEIGHT;
Index = sMSB(RunPtr->Shape)+sMSB(RunPtr->Topy)/2; Index = sMSB(RunPtr->Shape)+sMSB(RunPtr->Topy)/2;
Delta = 0; Delta = 0;
if (Y1<0) { if (Y1 < 0) {
Delta = (0-(LongWord)Y1)*TheFrac; Delta = (0-(LongWord)Y1)*TheFrac;
Index += (Delta>>24); Index += (Delta>>24);
Delta <<= 8; Delta <<= 8;
...@@ -311,17 +322,8 @@ void IO_ScaleMaskedColumn(Word x,Word scale, unsigned short *CharPtr,Word column ...@@ -311,17 +322,8 @@ void IO_ScaleMaskedColumn(Word x,Word scale, unsigned short *CharPtr,Word column
} }
} }
Boolean SetupScalers(void) Boolean SetupScalers()
{ {
Word i;
if (!ScaleDiv[1]) {
i = 1;
do {
ScaleDiv[i] = 0x40000000/i;
} while (++i<2048);
MaxScaler = 2048;
}
return 1;
} }
void ReleaseScalers() void ReleaseScalers()
...@@ -330,12 +332,14 @@ void ReleaseScalers() ...@@ -330,12 +332,14 @@ void ReleaseScalers()
/* Keyboard Hack */ /* Keyboard Hack */
static int RSJ; static int RSJ;
static int keys[128]; static int keys[128];
void FlushKeys() void FlushKeys()
{ {
while (keyboard_update()) ; while (keyboard_update()) ;
joystick1 = 0;
memset(keys, 0, sizeof(keys)); memset(keys, 0, sizeof(keys));
} }
...@@ -364,9 +368,9 @@ void keyboard_handler(int key, int press) ...@@ -364,9 +368,9 @@ void keyboard_handler(int key, int press)
if (key == SCANCODE_ESCAPE) if (key == SCANCODE_ESCAPE)
Quit(0); Quit(0);
if (RSJ) { keys[key] = press;
keys[key] = press;
if (RSJ) {
if (press == 0) { if (press == 0) {
for (i = 0; i < CheatCount; i++) { for (i = 0; i < CheatCount; i++) {
if (CheatCodes[i].code[CheatIndex] == key) { if (CheatCodes[i].code[CheatIndex] == key) {
...@@ -512,24 +516,19 @@ void keyboard_handler(int key, int press) ...@@ -512,24 +516,19 @@ void keyboard_handler(int key, int press)
void ReadSystemJoystick(void) void ReadSystemJoystick(void)
{ {
RSJ = 1; RSJ = 1;
//#ifndef NOVGA /* keyboard_update(); */
keyboard_update(); while (keyboard_update()) ;
//#endif
} }
/*
Handle events, and return:
last keypress (if any) in ascii
mouse button events == 1
zero means none of the above
*/
int DoEvents() int DoEvents()
{ {
RSJ = 0; RSJ = 0;
//#ifndef NOVGA if (keyboard_update()) {
keyboard_update(); while (keyboard_update()) ;
//#endif if (keys[SCANCODE_B]) {
/* TODO: hack */ return 'B';
return 'B'; }
return 1;
}
return 0;
} }
...@@ -59,7 +59,6 @@ typedef unsigned short ufixed_t; /* 8.8 unsigned fixed point number */ ...@@ -59,7 +59,6 @@ typedef unsigned short ufixed_t; /* 8.8 unsigned fixed point number */
#define NUMBUTTONS 10 /* Number of control buttons */ #define NUMBUTTONS 10 /* Number of control buttons */
#define WALLHEIGHT 128 /* Height,width of walls */ #define WALLHEIGHT 128 /* Height,width of walls */
#define SPRITEHEIGHT 64 /* Height,width of a sprite */ #define SPRITEHEIGHT 64 /* Height,width of a sprite */
#define MAXSCALER 960 /* Number of scalers to create */
#define PLAYERSIZE 88 /* radius of player in 8.8 fixed point */ #define PLAYERSIZE 88 /* radius of player in 8.8 fixed point */
#define PROJECTIONSCALE (SCREENWIDTH/2)*0x90l #define PROJECTIONSCALE (SCREENWIDTH/2)*0x90l
...@@ -223,19 +222,6 @@ typedef enum { /* actor class info*/ ...@@ -223,19 +222,6 @@ typedef enum { /* actor class info*/
enum {BSPTOP,BSPBOTTOM,BSPLEFT,BSPRIGHT}; /* BSP quadrants */ enum {BSPTOP,BSPBOTTOM,BSPLEFT,BSPRIGHT}; /* BSP quadrants */
/**********************************
Compiled scaler
**********************************/
typedef struct {
unsigned short codeofs[WALLHEIGHT+1]; /* Entry to the code for sprites */
Byte FixA1[WALLHEIGHT+1]; /* A1 adjust for the screen */
Byte Pad[1]; /* Long word align it... */
Byte code[1]; /* Scaler code */
} t_compscale;
/********************************** /**********************************
Status of the game (Save game record) Status of the game (Save game record)
...@@ -543,12 +529,8 @@ extern Boolean rw_downside; /* True for dir_east and dir_south*/ ...@@ -543,12 +529,8 @@ extern Boolean rw_downside; /* True for dir_east and dir_south*/
extern Byte *ArtData[64]; extern Byte *ArtData[64];
extern Byte textures[MAPSIZE*2+5][MAPSIZE]; /* 0-63 is horizontal, 64-127 is vertical*/ extern Byte textures[MAPSIZE*2+5][MAPSIZE]; /* 0-63 is horizontal, 64-127 is vertical*/
extern void InitTools(void);
extern void BlastScreen(void); extern void BlastScreen(void);
extern void BlastScreen2(Rect *BlastRect); extern void BlastScreen2(Rect *BlastRect);
extern void DoMacEvents(void);
extern void BailOut(void);
extern void GoodBye(void);
extern void ReadSystemJoystick(void); extern void ReadSystemJoystick(void);
extern Word NewGameWindow(Word NewVidSize); extern Word NewGameWindow(Word NewVidSize);
extern void ShowGetPsyched(void); extern void ShowGetPsyched(void);
...@@ -818,7 +800,6 @@ extern Word nummissiles; /* Number of active missiles */ ...@@ -818,7 +800,6 @@ extern Word nummissiles; /* Number of active missiles */
extern missile_t missiles[MAXMISSILES]; /* Data for the missile items */ extern missile_t missiles[MAXMISSILES]; /* Data for the missile items */
extern Word numactors; /* Number of active actors */ extern Word numactors; /* Number of active actors */
extern actor_t actors[MAXACTORS]; /* Data for the actors */ extern actor_t actors[MAXACTORS]; /* Data for the actors */
extern t_compscale *AllScalers[MAXSCALER]; /* Pointers to all the compiled scalers */
extern Byte **GameShapes; /* Pointer to the game shape array */ extern Byte **GameShapes; /* Pointer to the game shape array */
extern Word difficulty; /* 0 = easy, 1= normal, 2=hard*/ extern Word difficulty; /* 0 = easy, 1= normal, 2=hard*/
extern gametype_t gamestate; /* Status of the game (Save game) */ extern gametype_t gamestate; /* Status of the game (Save game) */
...@@ -863,7 +844,6 @@ extern Boolean areavis[MAXAREAS]; /* Area visible */ ...@@ -863,7 +844,6 @@ extern Boolean areavis[MAXAREAS]; /* Area visible */
extern Word bspcoord[4]; /* Rect for the BSP search */ extern Word bspcoord[4]; /* Rect for the BSP search */
extern Word TicCount; /* Ticks since last screen draw */ extern Word TicCount; /* Ticks since last screen draw */
extern Word LastTicCount; /* Tick value at start of render */ extern Word LastTicCount; /* Tick value at start of render */
extern Word MacVidSize; /* Current 0 = 320, 1 = 512, 2 = 640 */
extern Word SlowDown; /* If true, then limit game to 30hz */ extern Word SlowDown; /* If true, then limit game to 30hz */
extern Word MouseEnabled; /* Allow mouse control */ extern Word MouseEnabled; /* Allow mouse control */
extern Word GameViewSize; /* Size of the game screen */ extern Word GameViewSize; /* Size of the game screen */
...@@ -872,7 +852,6 @@ extern Word NoWeaponDraw; /* Flag to not draw the weapon on the screen */ ...@@ -872,7 +852,6 @@ extern Word NoWeaponDraw; /* Flag to not draw the weapon on the screen */
extern maplist_t *MapListPtr; /* Pointer to map info record */ extern maplist_t *MapListPtr; /* Pointer to map info record */
extern unsigned short *SongListPtr; /* Pointer to song list record */ extern unsigned short *SongListPtr; /* Pointer to song list record */
extern unsigned short *WallListPtr; /* Pointer to wall list record */ extern unsigned short *WallListPtr; /* Pointer to wall list record */
extern Word MaxScaler; /* Maximum number of VALID scalers */
extern Word NaziSound[]; /* Sounds for nazis starting */ extern Word NaziSound[]; /* Sounds for nazis starting */
extern Boolean ShowPush; /* Cheat for showing pushwalls on automap */ extern Boolean ShowPush; /* Cheat for showing pushwalls on automap */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment