Commit d331fdbc authored by Steven Fuller's avatar Steven Fuller

id_ca.c: more endian fixes. only one more PACKED struct to go (other than

adlib stuff).

id_vh.c, wl_menu.c: moved the font stuff from wl_menu.c's Message into
id_vh.c

wl_play.c, foreign.h: moved some text strings to foreign.h

rest: formatting cleanups
parent 3dadef2b
#define NUMSOUNDS 81
#define NUMSNDCHUNKS 267
//
// Sound names & indexes
//
/* Sound names & indexes */
typedef enum {
HITWALLSND, // 0
MISSILEHITSND, // 1
......@@ -89,16 +87,12 @@ typedef enum {
LASTSOUND
} soundnames;
//
// Base offsets
//
/* Base offsets */
#define STARTPCSOUNDS 0
#define STARTADLIBSOUNDS 81
#define STARTMUSIC 243
//
// Music names & indexes
//
/* Music names & indexes */
typedef enum {
XFUNKIE_MUS, // 0
DUNGEON_MUS, // 1
......
......@@ -92,11 +92,19 @@
#define STR_DEFEATED "defeated!"
#define STR_CHEATER1 "You now have 100% Health,"
#define STR_CHEATER2 "99 Ammo and both Keys!"
#define STR_CHEATER3 "Note that you have basically"
#define STR_CHEATER4 "eliminated your chances of"
#define STR_CHEATER5 "getting a high score!"
#define STR_CHEATER "You now have 100% Health,\n"\
"99 Ammo and both Keys!\n\n"\
"Note that you have basically\n"\
"eliminated your chances of\n"\
"getting a high score!"
#define STR_KEEN "Commander Keen is also\n"\
"available from Apogee, but\n"\
"then, you already know\n"\
"that - right, Cheatmeister?!"
#define STR_DEBUG "Debugging keys are\n"\
"now available!"
#define STR_NOSPACE1 "There is not enough space"
#define STR_NOSPACE2 "on your disk to Save Game!"
......
#include "wl_def.h"
#define PACKED __attribute__((packed))
typedef struct pcx_header_type
{
char manufacturer;
......
......@@ -14,7 +14,7 @@ typedef struct
=============================================================================
*/
unsigned int RLEWtag;
word RLEWtag;
int mapon;
word *mapsegs[MAPPLANES];
......@@ -62,47 +62,25 @@ static void CA_CannotOpen(char *string)
/*
==========================
=
= CA_FarRead
= CA_WriteFile
=
= Read from a file to a pointer
= Writes a file from a memory buffer
=
==========================
*/
boolean CA_FarRead(int handle, byte *dest, long length)
boolean CA_WriteFile(char *filename, void *ptr, long length)
{
ssize_t l;
int handle;
l = read(handle, dest, length);
handle = open(filename, O_CREAT | O_BINARY | O_WRONLY,
S_IREAD | S_IWRITE | S_IFREG);
if (l == -1) {
perror("CA_FarRead");
return false;
} else if (l == 0) {
fprintf(stderr, "CA_FarRead hit EOF?\n");
return false;
} else if (l != length) {
fprintf(stderr, "CA_FarRead only read %d out of %ld\n", l, length);
if (handle == -1)
return false;
}
return true;
}
/*
==========================
=
= CA_FarWrite
=
= Write from a file to a pointer
=
==========================
*/
boolean CA_FarWrite(int handle, byte *source, long length)
{
ssize_t l;
l = write(handle, source, length);
l = write(handle, ptr, length);
if (l == -1) {
perror("CA_FarWrite");
return false;
......@@ -113,33 +91,6 @@ boolean CA_FarWrite(int handle, byte *source, long length)
fprintf(stderr, "CA_FarWrite only wrote %d out of %ld\n", l, length);
return false;
}
return true;
}
/*
==========================
=
= CA_WriteFile
=
= Writes a file from a memory buffer
=
==========================
*/
boolean CA_WriteFile(char *filename, void *ptr, long length)
{
int handle;
handle = open(filename, O_CREAT | O_BINARY | O_WRONLY,
S_IREAD | S_IWRITE | S_IFREG);
if (handle == -1)
return false;
if (!CA_FarWrite(handle, ptr, length)) {
close(handle);
return false;
}
close(handle);
return true;
......@@ -158,18 +109,28 @@ boolean CA_WriteFile(char *filename, void *ptr, long length)
boolean CA_LoadFile(char *filename, memptr *ptr)
{
int handle;
ssize_t l;
long size;
if ((handle = open(filename, O_RDONLY | O_BINARY)) == -1)
return false;
size = filelength(handle);
MM_GetPtr (ptr,size);
if (!CA_FarRead(handle,*ptr,size))
{
close (handle);
MM_GetPtr(ptr, size);
l = read(handle, ptr, size);
if (l == -1) {
perror("CA_FarRead");
return false;
} else if (l == 0) {
fprintf(stderr, "CA_FarRead hit EOF?\n");
return false;
} else if (l != size) {
fprintf(stderr, "CA_FarRead only read %d out of %ld\n", l, size);
return false;
}
close(handle);
return true;
}
......@@ -233,7 +194,7 @@ void CAL_HuffExpand(byte *source, byte *dest, long length, huffnode *htable)
#define NEARTAG 0xa7
#define FARTAG 0xa8
void CAL_CarmackExpand(word *source, word *dest, word length)
void CAL_CarmackExpand(byte *source, word *dest, word length)
{
unsigned int offset;
word *copyptr, *outptr;
......@@ -241,7 +202,7 @@ void CAL_CarmackExpand(word *source, word *dest, word length)
length /= 2;
inptr = (byte *)source;
inptr = source;
outptr = dest;
while (length) {
......@@ -308,10 +269,10 @@ void CA_RLEWexpand(word *source, word *dest, long length, word rlewtag)
if (value != rlewtag)
/* uncompressed */
*dest++=value;
*dest++ = value;
else {
/* compressed string */
count = *source++;
count = SwapInt16L(*source); source++;
value = *source++;
for (i = 1; i <= count; i++)
*dest++ = value;
......@@ -344,10 +305,7 @@ static void CAL_SetupGrFile()
byte *grtemp;
int i;
//
// load vgadict.ext (huffman dictionary for graphics files)
//
/* load vgadict.ext (huffman dictionary for graphics files) */
strcpy(fname, gdictname);
strcat(fname, extension);
......@@ -362,9 +320,7 @@ static void CAL_SetupGrFile()
CloseRead(handle);
//
// load the data offsets from vgahead.ext
//
/* load the data offsets from vgahead.ext */
MM_GetPtr((memptr)&grstarts, (NUMCHUNKS+1)*4);
MM_GetPtr((memptr)&grtemp, (NUMCHUNKS+1)*3);
......@@ -384,9 +340,7 @@ static void CAL_SetupGrFile()
CloseRead(handle);
//
// Open the graphics file, leaving it open until the game is finished
//
/* Open the graphics file, leaving it open until the game is finished */
strcpy(fname, gfilename);
strcat(fname, extension);
......@@ -394,10 +348,7 @@ static void CAL_SetupGrFile()
if (grhandle == -1)
CA_CannotOpen(fname);
//
// load the pic headers into pictable
//
MM_GetPtr((memptr)&pictable, NUMPICS*sizeof(pictabletype));
/* load the pic headers into pictable */
chunkcomplen = grstarts[STRUCTPIC+1] - grstarts[STRUCTPIC];
ReadSeek(grhandle, grstarts[STRUCTPIC], SEEK_SET);
......@@ -405,11 +356,20 @@ static void CAL_SetupGrFile()
ReadBytes(grhandle, compseg, chunkcomplen);
CAL_HuffExpand((byte *)compseg+4, (byte *)pictable, NUMPICS*sizeof(pictabletype), grhuffman);
/* pictable is word width, height */
MM_GetPtr((memptr)&grtemp, NUMPICS*4);
CAL_HuffExpand((byte *)compseg+4, (byte *)grtemp, NUMPICS*4, grhuffman);
MM_FreePtr(&compseg);
for (i = 0; i < NUMPICS; i++) {
pictable[i].width = grtemp[i*4+0] | (grtemp[i*4+1] << 8);
pictable[i].height = grtemp[i*4+2] | (grtemp[i*4+3] << 8);
}
MM_FreePtr((memptr)&grtemp);
}
//==========================================================================
/* ======================================================================== */
/*
......@@ -434,7 +394,8 @@ static void CAL_SetupMapFile()
if (handle == -1)
CA_CannotOpen(fname);
RLEWtag = ReadInt16(handle);
/* RLEWtag = ReadInt16(handle); */
ReadBytes(handle, (byte *)&RLEWtag, 2); /* RLEWtag = word */
/* open the data file */
strcpy(fname, gmapsname);
......@@ -444,9 +405,7 @@ static void CAL_SetupMapFile()
if (maphandle == -1)
CA_CannotOpen(fname);
//
// load all map header
//
/* load all map header */
for (i = 0; i < NUMMAPS; i++)
{
pos = ReadInt32(handle);
......@@ -470,13 +429,11 @@ static void CAL_SetupMapFile()
mapheaderseg[i]->width = ReadInt16(maphandle);
mapheaderseg[i]->height = ReadInt16(maphandle);
ReadBytes(maphandle, (byte *)mapheaderseg[i]->name, 16);
}
CloseRead(handle);
//
// allocate space for 2 64*64 planes
//
/* allocate space for 2 64*64 planes */
for (i = 0;i < MAPPLANES; i++) {
MM_GetPtr((memptr)&mapsegs[i], 64*64*2);
MM_SetLock((memptr)&mapsegs[i], true);
......@@ -565,7 +522,7 @@ void CA_Shutdown()
CloseRead(audiohandle);
}
//===========================================================================
/* ======================================================================== */
/*
======================
......@@ -577,16 +534,11 @@ void CA_Shutdown()
void CA_CacheAudioChunk(int chunk)
{
long pos, length;
int pos, length;
if (audiosegs[chunk]) {
if (audiosegs[chunk])
return;
}
//
// load the chunk into a buffer, either the miscbuffer if it fits, or allocate
// a larger buffer
//
pos = audiostarts[chunk];
length = audiostarts[chunk+1]-pos;
......@@ -624,8 +576,7 @@ void CA_LoadAllSounds()
CA_CacheAudioChunk(start);
}
//===========================================================================
/* ======================================================================== */
/*
======================
......@@ -646,29 +597,23 @@ static void CAL_ExpandGrChunk(int chunk, byte *source)
if (chunk >= STARTTILE8 && chunk < STARTEXTERNS)
{
//
// expanded sizes of tile8 are implicit
//
expanded = (8*8)*NUMTILE8;
/* expanded sizes of tile8 are implicit */
expanded = 8*8*NUMTILE8;
width = 8;
height = 8;
tilecount = NUMTILE8;
} else if (chunk >= STARTPICS && chunk < STARTTILE8) {
width = pictable[chunk - STARTPICS].width;
height = pictable[chunk - STARTPICS].height;
expanded = *((long *)source);
expanded = source[0]|(source[1]<<8)|(source[2]<<16)|(source[3]<<24);
source += 4;
} else {
//
// everything else has an explicit size longword
//
expanded = *((long *)source);
/* everything else has an explicit size longword */
expanded = source[0]|(source[1]<<8)|(source[2]<<16)|(source[3]<<24);
source += 4;
}
//
// allocate final space and decompress it
//
/* allocate final space and decompress it */
MM_GetPtr((void *)&grsegs[chunk], expanded);
CAL_HuffExpand(source, grsegs[chunk], expanded, grhuffman);
if (width && height) {
......@@ -695,7 +640,6 @@ void CA_CacheGrChunk(int chunk)
long pos, compressed;
byte *source;
/* this is due to Quit() wanting to cache the error screen before this has been set up! */
if (grhandle == -1)
return;
......@@ -703,9 +647,7 @@ void CA_CacheGrChunk(int chunk)
return;
}
//
// load the chunk into a buffer
//
/* load the chunk into a buffer */
pos = grstarts[chunk];
compressed = grstarts[chunk+1]-pos;
......@@ -729,7 +671,7 @@ void CA_UnCacheGrChunk(int chunk)
MM_FreePtr((memptr)&grsegs[chunk]);
grsegs[chunk] = 0;
grsegs[chunk] = NULL;
}
/* ======================================================================== */
......@@ -746,46 +688,39 @@ void CA_CacheMap(int mapnum)
{
long pos,compressed;
int plane;
memptr *dest,bigbufferseg;
word size;
word *source;
byte *source;
memptr buffer2seg;
long expanded;
int i;
mapon = mapnum;
//
// load the planes into the allready allocated buffers
//
size = 64*64*2;
/* load the planes into the already allocated buffers */
for (plane = 0; plane < MAPPLANES; plane++)
{
pos = mapheaderseg[mapnum]->planestart[plane];
compressed = mapheaderseg[mapnum]->planelength[plane];
dest = (memptr)&mapsegs[plane];
lseek(maphandle,pos,SEEK_SET);
MM_GetPtr(&bigbufferseg,compressed);
MM_SetLock (&bigbufferseg,true);
source = bigbufferseg;
CA_FarRead(maphandle,(byte *)source,compressed);
/*
unhuffman, then unRLEW
The huffman'd chunk has a two byte expanded length first
The resulting RLEW chunk also does, even though it's not really
needed
*/
expanded = *source;
source++;
ReadSeek(maphandle, pos, SEEK_SET);
MM_GetPtr((void *)&source, compressed);
ReadBytes(maphandle, (byte *)source, compressed);
expanded = source[0] | (source[1] << 8);
MM_GetPtr(&buffer2seg, expanded);
CAL_CarmackExpand(source, (word *)buffer2seg,expanded);
CA_RLEWexpand(((word *)buffer2seg)+1,*dest,size, RLEWtag);
CAL_CarmackExpand(source+2, (word *)buffer2seg, expanded);
MM_FreePtr((void *)&source);
expanded = 64*64*2;
CA_RLEWexpand(((word *)buffer2seg)+1, mapsegs[plane], expanded, RLEWtag);
MM_FreePtr(&buffer2seg);
MM_FreePtr(&bigbufferseg);
/* swap for big-endian */
for (i = 0; i < 64*64; i++)
mapsegs[plane][i] = SwapInt16L(mapsegs[plane][i]);
}
}
......@@ -838,9 +773,6 @@ int ChunksInFile, PMSpriteStart, PMSoundStart;
PageListStruct *PMPages;
//
// PML_ReadFromFile() - Reads some data in from the page file
//
static void PML_ReadFromFile(byte *buf, long offset, word length)
{
if (!buf)
......@@ -853,9 +785,6 @@ static void PML_ReadFromFile(byte *buf, long offset, word length)
Quit("PML_ReadFromFile: Read failed");
}
//
// PML_OpenPageFile() - Opens the page file and sets up the page info
//
static void PML_OpenPageFile()
{
int i;
......@@ -869,29 +798,26 @@ static void PML_OpenPageFile()
if (PageFile == -1)
Quit("PML_OpenPageFile: Unable to open page file");
// Read in header variables
/* Read in header variables */
ChunksInFile = ReadInt16(PageFile);
PMSpriteStart = ReadInt16(PageFile);
PMSoundStart = ReadInt16(PageFile);
// Allocate and clear the page list
/* Allocate and clear the page list */
MM_GetPtr((memptr)&PMPages, sizeof(PageListStruct) * ChunksInFile);
MM_SetLock((memptr)&PMPages, true);
memset(PMPages, 0, sizeof(PageListStruct) * ChunksInFile);
// Read in the chunk offsets
/* Read in the chunk offsets */
for (i = 0, page = PMPages; i < ChunksInFile; i++, page++)
page->offset = ReadInt32(PageFile);
// Read in the chunk lengths
/* Read in the chunk lengths */
for (i = 0, page = PMPages; i < ChunksInFile; i++, page++)
page->length = ReadInt16(PageFile);
}
//
// PML_ClosePageFile() - Closes the page file
//
static void PML_ClosePageFile()
{
if (PageFile != -1)
......@@ -903,9 +829,6 @@ static void PML_ClosePageFile()
}
}
//
// PM_GetPage() - Returns the address of the page, loading it if necessary
//
memptr PM_GetPage(int pagenum)
{
PageListStruct *page;
......@@ -921,11 +844,6 @@ memptr PM_GetPage(int pagenum)
return page->addr;
}
//
// PM_Preload() - Loads as many pages as possible into all types of memory.
// Calls the update function after each load, indicating the current
// page, and the total pages that need to be loaded (for thermometer).
//
void PM_Preload(boolean (*update)(int current, int total))
{
int i;
......@@ -935,9 +853,6 @@ void PM_Preload(boolean (*update)(int current, int total))
update(50, 50);
}
//
// PM_Startup() - Start up the Page Mgr
//
void PM_Startup()
{
if (PMStarted)
......@@ -948,9 +863,6 @@ void PM_Startup()
PMStarted = true;
}
//
// PM_Shutdown() - Shut down the Page Mgr
//
void PM_Shutdown()
{
if (!PMStarted)
......
......@@ -61,8 +61,8 @@ void MM_SortMem();
#define PMPageSize 4096
typedef struct {
longword offset; // Offset of chunk into file
int length; // Length of the chunk
int offset; /* Offset of chunk into file */
int length; /* Length of the chunk */
memptr addr;
} PageListStruct;
......
......@@ -21,9 +21,6 @@ typedef bool boolean;
#define true TRUE
#endif
#define PACKED
#pragma pack(1)
#define ssize_t SSIZE_T
#else
......@@ -34,8 +31,6 @@ typedef bool boolean;
#include <values.h>
#include <glob.h>
#define PACKED __attribute__((packed))
#ifdef __cplusplus
typedef bool boolean;
#else
......@@ -88,10 +83,10 @@ typedef enum { false, true } boolean;
/* ---------------- */
typedef unsigned char byte;
typedef unsigned short int word;
typedef unsigned int longword;
typedef unsigned long dword;
typedef uint8_t byte;
typedef uint16_t word;
typedef uint32_t longword;
typedef uint32_t dword;
typedef long fixed;
......
......@@ -117,10 +117,9 @@ void US_PrintUnsigned(longword n)
///////////////////////////////////////////////////////////////////////////
void USL_PrintInCenter(char *s, Rect r)
{
word w,h,
rw,rh;
word w, h, rw, rh;
USL_MeasureString(s,&w,&h);
USL_MeasureString(s, &w, &h);
rw = r.lr.x - r.ul.x;
rh = r.lr.y - r.ul.y;
......@@ -154,9 +153,9 @@ void US_PrintCentered(char *s)
///////////////////////////////////////////////////////////////////////////
void US_CPrintLine(char *s)
{
word w,h;
word w, h;
USL_MeasureString(s,&w,&h);
USL_MeasureString(s, &w, &h);
if (w > WindowW)
Quit("US_CPrintLine() - String exceeds width");
......
#include "wl_def.h"
pictabletype *pictable;
pictabletype pictable[NUMPICS];
int px, py;
byte fontcolor, backcolor;
......@@ -327,10 +327,26 @@ void VW_DrawPropString(char *string)
void VWL_MeasureString(char *string, word *width, word *height, fontstruct *font)
{
/* proportional width */
int w, mw;
w = 0;
mw = 0;
*height = font->height;
for (*width = 0; *string; string++)
*width += font->width[*((byte *)string)];
for (;*string; string++) {
if (*string == '\n') {
if (mw < w)
mw = w;
w = 0;
*height += font->height;
} else {
w += font->width[*((byte *)string)];
}
}
if (mw < w)
mw = w;
*width = mw;
}
void VW_MeasurePropString(char *string, word *width, word *height)
......
......@@ -8,19 +8,19 @@
typedef struct
{
word width, height;
} PACKED pictabletype;
int width, height;
} pictabletype;
typedef struct
{
word height;
word location[256];
char width[256];
} PACKED fontstruct;
byte width[256];
} __attribute__((packed)) fontstruct;
/* ======================================================================== */
extern pictabletype *pictable;
extern pictabletype pictable[NUMPICS];
extern byte fontcolor;
extern int fontnumber;
......
......@@ -199,7 +199,7 @@ void DisplayTextSplash(byte *text, int l)
/* ** */
static int16_t SwapInt16L(int16_t i)
uint16_t SwapInt16L(uint16_t i)
{
#if __BYTE_ORDER == __BIG_ENDIAN
return ((uint16_t)i >> 8) | ((uint16_t)i << 8);
......@@ -208,7 +208,7 @@ static int16_t SwapInt16L(int16_t i)
#endif
}
static int32_t SwapInt32L(int32_t i)
uint32_t SwapInt32L(uint32_t i)
{
#if __BYTE_ORDER == __BIG_ENDIAN
return ((uint32_t)(i & 0xFF000000) >> 24) |
......
......@@ -24,6 +24,9 @@ char *ultoa(unsigned long value, char *string, int radix);
#endif /* DOSISM */
uint16_t SwapInt16L(uint16_t i);
uint32_t SwapInt32L(uint32_t i);
extern int OpenWrite(char *fn);
extern int OpenWriteAppend(char *fn);
extern void CloseWrite(int fp);
......
#ifndef __SD_COMM_H__
#define __SD_COMM_H__
#define PACKED __attribute__((packed))
#define TickBase 70 // 70Hz per tick
typedef enum {
......
......@@ -229,5 +229,7 @@ int DebugKeys()
return 1;
}
DrawPlayBorder();
return 0;
}
......@@ -563,11 +563,9 @@ void DrawPlanes()
int x;
if ((viewheight>>1) != halfheight)
SetPlaneViewSize(); // screen size has changed
SetPlaneViewSize(); /* screen size has changed */
//
// loop over all columns
//
/* loop over all columns */
lastheight = halfheight;
for (x = 0; x < viewwidth; x++)
......@@ -636,21 +634,18 @@ static void ClearScreen()
*/
#ifndef DRAWCEIL
//#define DRAWCEIL
/* #define DRAWCEIL */
#endif
void ThreeDRefresh()
{
//
// clear out the traced array
//
/* clear out the traced array */
memset(spotvis, 0, sizeof(spotvis));
//
// follow the walls from there to the right, drawwing as we go
//
DrawPlayBorder();
/* follow the walls from there to the right, drawing as we go */
/* DrawPlayBorder(); */
#ifndef DRAWCEIL
ClearScreen();
#endif
......@@ -659,15 +654,12 @@ void ThreeDRefresh()
#ifdef DRAWCEIL
DrawPlanes(); /* silly floor/ceiling drawing */
#endif
//
// draw all the scaled images
//
/* draw all the scaled images */
DrawScaleds(); /* draw scaled stuff */
DrawPlayerWeapon(); /* draw player's hands */
//
// show screen and time last cycle
//
/* show screen and time last cycle */
if (fizzlein)
{
FizzleFade(xoffset, yoffset, viewwidth, viewheight, 20, false);
......
......@@ -441,7 +441,7 @@ void ScanInfoPlane()
}
}
//==========================================================================
/* ======================================================================== */
/*
==================
......@@ -471,22 +471,17 @@ void SetupGameLevel()
else
US_InitRndT(true);
//
// load the level
//
/* load the level */
CA_CacheMap(gamestate.mapon+10*gamestate.episode);
mapon -= gamestate.episode*10;
if ((mapheaderseg[mapon]->width != 64) || (mapheaderseg[mapon]->height != 64))
Quit("Map not 64*64!");
//
// copy the wall data to a data segment array
//
memset(tilemap, 0, sizeof(tilemap));
memset(actorat, 0, sizeof(actorat));
/* copy the wall data to a data segment array */
map = mapsegs[0];
for (y = 0; y < mapheight; y++)
for (x = 0; x < mapwidth; x++) {
......@@ -500,13 +495,11 @@ void SetupGameLevel()
}
}
//
// spawn doors
//
InitActorList(); /* start spawning things with a clean slate */
InitDoorList();
InitStaticList();
/* spawn doors */
map = mapsegs[0];
for (y=0;y<mapheight;y++)
for (x=0;x<mapwidth;x++)
......@@ -514,8 +507,8 @@ void SetupGameLevel()
tile = *map++;
if (tile >= 90 && tile <= 101)
{
// door
switch (tile)
/* door */
switch(tile)
{
case 90:
case 92:
......@@ -523,7 +516,7 @@ void SetupGameLevel()
case 96:
case 98:
case 100:
SpawnDoor (x,y,1,(tile-90)/2);
SpawnDoor(x, y, 1, (tile-90)/2);
break;
case 91:
case 93:
......@@ -531,20 +524,16 @@ void SetupGameLevel()
case 97:
case 99:
case 101:
SpawnDoor (x,y,0,(tile-91)/2);
SpawnDoor(x, y, 0,(tile-91)/2);
break;
}
}
}
//
// spawn actors
//
/* spawn actors */
ScanInfoPlane();
//
// take out the ambush markers
//
/* take out the ambush markers */
map = mapsegs[0];
for (y=0;y<mapheight;y++)
for (x=0;x<mapwidth;x++)
......@@ -572,9 +561,7 @@ void SetupGameLevel()
CA_LoadAllSounds();
}
//==========================================================================
/* ======================================================================== */
/*
===================
......@@ -667,7 +654,7 @@ void DrawPlayScreen()
DrawStatusBar();
}
//==========================================================================
/* ======================================================================= */
/*
==================
......@@ -820,10 +807,10 @@ void PlayDemo(int demonumber)
CA_CacheGrChunk(dems[demonumber]);
demoptr = grsegs[dems[demonumber]];
NewGame (1,0);
NewGame(1, 0);
gamestate.mapon = *demoptr++;
gamestate.difficulty = gd_hard;
length = demoptr[0] | (demoptr[1] << 8); // *((word *)demoptr)++;
length = demoptr[0] | (demoptr[1] << 8);
demoptr += 3;
lastdemoptr = demoptr-4+length;
......@@ -838,7 +825,7 @@ void PlayDemo(int demonumber)
startgame = false;
demoplayback = true;
SetupGameLevel ();
SetupGameLevel();
StartMusic();
fizzlein = true;
......@@ -869,7 +856,7 @@ int PlayDemoFromFile(char *demoname)
NewGame(1,0);
gamestate.mapon = *demoptr++;
gamestate.difficulty = gd_hard;
length = demoptr[0] | (demoptr[1] << 8); // *((word *)demoptr)++;
length = demoptr[0] | (demoptr[1] << 8);
demoptr += 3;
lastdemoptr = demoptr-4+length;
......
......@@ -554,11 +554,11 @@ int CP_CheckQuick(unsigned scancode)
CA_CacheGrChunk(C_SAVEGAMEPIC);
CA_CacheGrChunk(C_MOUSELBACKPIC);
#else
CacheLump (BACKDROP_LUMP_START,BACKDROP_LUMP_END);
CacheLump(BACKDROP_LUMP_START,BACKDROP_LUMP_END);
CA_CacheGrChunk(C_CURSOR1PIC);
#endif
VW_FadeOut ();
VW_FadeOut();
StartCPMusic(MENUSONG);
pickquick=CP_SaveGame(0);
......@@ -577,8 +577,6 @@ int CP_CheckQuick(unsigned scancode)
playstate = ex_abort;
lasttimecount = get_TimeCount();
#ifndef SPEAR
CA_UnCacheGrChunk(C_CURSOR1PIC);
CA_UnCacheGrChunk(C_CURSOR2PIC);
......@@ -592,15 +590,12 @@ int CP_CheckQuick(unsigned scancode)
}
return 1;
//
// QUICKLOAD
//
/* QUICKLOAD */
case sc_F9:
if (SaveGamesAvail[LSItems.curpos] && pickquick)
{
char string[100]=STR_LGC;
CA_CacheGrChunk(STARTFONT+1);
fontnumber = 1;
......@@ -2476,7 +2471,7 @@ void DrawChangeView(int view)
// QUIT THIS INFERNAL GAME!
//
////////////////////////////////////////////////////////////////////
void CP_Quit(void)
void CP_Quit()
{
if (Confirm(endStrings[(US_RndT()&0x7)+(US_RndT()&1)]))
{
......@@ -3109,7 +3104,6 @@ int Confirm(char *string)
{
int xit=0,x,y,tick=0,whichsnd[2]={ESCPRESSEDSND,SHOOTSND};
Message(string);
IN_ClearKeysDown();
......@@ -3164,27 +3158,13 @@ int Confirm(char *string)
////////////////////////////////////////////////////////////////////
void Message(char *string)
{
int h=0,w=0,mw=0,i;
fontstruct *font;
word h=0, mw=0;
CA_CacheGrChunk (STARTFONT+1);
CA_CacheGrChunk(STARTFONT+1);
fontnumber=1;
font= (fontstruct *)grsegs[STARTFONT+fontnumber];
h=font->height;
for (i=0;i<strlen(string);i++)
if (string[i]=='\n')
{
if (w>mw)
mw=w;
w=0;
h+=font->height;
}
else
w+=font->width[(int)string[i]];
if (w+10>mw)
mw=w+10;
VW_MeasurePropString(string, &mw, &h);
mw += 4;
PrintY=(WindowH/2)-h/2;
PrintX=WindowX=160-mw/2;
......
......@@ -558,21 +558,17 @@ void CheckKeys()
DrawAmmo();
DrawScore();
ClearMemory ();
CA_CacheGrChunk (STARTFONT+1);
ClearSplitVWB ();
ClearMemory();
CA_CacheGrChunk(STARTFONT+1);
ClearSplitVWB();
Message(STR_CHEATER1"\n"
STR_CHEATER2"\n\n"
STR_CHEATER3"\n"
STR_CHEATER4"\n"
STR_CHEATER5);
Message(STR_CHEATER);
CA_UnCacheGrChunk(STARTFONT+1);
IN_ClearKeysDown();
IN_Ack();
DrawPlayBorder ();
DrawPlayBorder();
}
//
......@@ -581,15 +577,16 @@ void CheckKeys()
if (IN_KeyDown(sc_BackSpace) && IN_KeyDown(sc_LShift) &&
IN_KeyDown(sc_Alt) && MS_CheckParm("debugmode")) {
ClearMemory();
CA_CacheGrChunk (STARTFONT+1);
ClearSplitVWB ();
CA_CacheGrChunk(STARTFONT+1);
ClearSplitVWB();
Message(STR_DEBUG);
Message("Debugging keys are\nnow available!");
CA_UnCacheGrChunk(STARTFONT+1);
IN_ClearKeysDown();
IN_Ack();
DrawPlayBorderSides ();
DrawPlayBorderSides();
DebugOk=1;
}
......@@ -601,10 +598,7 @@ void CheckKeys()
CA_CacheGrChunk(STARTFONT+1);
ClearSplitVWB();
Message("Commander Keen is also\n"
"available from Apogee, but\n"
"then, you already know\n"
"that - right, Cheatmeister?!");
Message(STR_KEEN);
CA_UnCacheGrChunk(STARTFONT+1);
IN_ClearKeysDown();
......
......@@ -364,10 +364,8 @@ void HandleWord()
}
words[wordindex] = 0; // stick a null at end for C
//
// see if it fits on this line
//
VW_MeasurePropString (words, &wwidth, &wheight);
/* see if it fits on this line */
VW_MeasurePropString(words, &wwidth, &wheight);
while (px+wwidth > rightmargin[rowon])
{
......@@ -380,7 +378,7 @@ void HandleWord()
// print it
//
newpos = px+wwidth;
VW_DrawPropString (words);
VW_DrawPropString(words);
px = newpos;
//
......
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