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;
......
This diff is collapsed.
......@@ -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