ref: 9538380d9692843641ba01a43222f67d9fc3545f
parent: ed4eeab77001fee4b5c7c2f95211aa671f85a653
parent: 88e27aeb0d9f472c0bb36a13e503e60dc9d9ec67
author: LTCHIPS <ltchips994@gmail.com>
date: Sun Mar 11 18:07:03 EDT 2018
Merge branch 'master' into bats4blitzguards modified: ../Compiled files/commerical/rott.exe modified: ../Compiled files/shareware/rott.exe modified: ../Compiled files/site license/rott.exe new file: ../MOUSEFIX WIN10 CREATORS UPDATE/SDL.dll modified: ../README.txt modified: Makefile modified: WinRott.h modified: _z_zone.h modified: audiolib/multivoc.c modified: engine.c modified: engine.h modified: modexlib.c modified: modexlib.h new file: queue.c new file: queue.h modified: rt_actor.c modified: rt_actor.h modified: rt_cfg.c modified: rt_debug.c modified: rt_draw.c modified: rt_floor.c modified: rt_game.c modified: rt_main.c modified: rt_menu.c modified: rt_menu.h modified: rt_playr.c modified: rt_table.h modified: rt_ted.c modified: rt_util.c modified: rt_view.c modified: rt_view.h deleted: stdout.txt modified: watcom.c modified: winrott.c
binary files a/Compiled files/commerical/rott.exe b/Compiled files/commerical/rott.exe differ
binary files a/Compiled files/shareware/rott.exe b/Compiled files/shareware/rott.exe differ
binary files a/Compiled files/site license/rott.exe b/Compiled files/site license/rott.exe differ
binary files /dev/null b/MOUSEFIX WIN10 CREATORS UPDATE/SDL.dll differ
--- a/README.txt
+++ b/README.txt
@@ -2,6 +2,9 @@
This source port of Rise of the Triad features the following:
+Support for resolutions from 320x200 all the way to 3840x2160
+Adaptive HUD positioning (no more status bar being off to the side)
+
New gameplay options including the following
Blitzguards being outfitted with anything from the missile arsenal!
You can now pick up ammo from dropped missile weapons!
@@ -10,13 +13,9 @@
Auto Aim for Missile Weapons
...and more
-Top Bar of the status bar isn't off to the side anymore!
-
And all of the improvements made in the icculus source port...
-
-
To run the game you'll need the following things:
SDL.dll (https://www.libsdl.org/download-1.2.php)
@@ -23,11 +22,8 @@
SDL_mixer.dll (https://www.libsdl.org/projects/SDL_mixer/release-1.2.html)
-And Either:
+And the files:
-DARKWAR.RTC
-DARKWAR.RTL
-DARKWAR.WAD
DEMO1_3.DMO
DEMO2_3.DMO
DEMO3_3.DMO
@@ -34,16 +30,17 @@
DEMO4_3.DMO
REMOTE1.RTS
+And
+
+DARKWAR.RTC
+DARKWAR.RTL
+DARKWAR.WAD
+
Or
HUNTBGIN.RTC
HUNTBGIN.RTL
HUNTBGIN.WAD
-DEMO1_3.DMO
-DEMO2_3.DMO
-DEMO3_3.DMO
-DEMO4_3.DMO
-REMOTE1.RTS
Place all those files in the same directory as rott.exe.
@@ -58,4 +55,26 @@
libsdl1.2-dev
libsdl-mixer1.2-dev
+Before running make on the project, double check the first few lines of the Makefile and make sure you build the right version.
+
I used MinGW with gcc to build the project.
+
+
+CUSTOM RESOLUTIONS:
+
+If your preferred screen resolution doesn't show up in the screen resolution menu,
+launch the game with argument "resolution *x*", and enter your screen resolution dimensions in the fields marked by *.
+
+ISSUES WITH HIGHER RESOLUTIONS:
+
+ROTTEXPR is capable of running at higher resolutions than the original release of ROTT, however this comes with a few issues.
+
+1. Being able to see through walls when up against them.
+ For this issue, visit "ADJUST FOCAL WIDTH" under "VISUAL OPTIONS", and raise the value until the issue disappears.
+
+2. The fullscreen toggle (ALT-ENTER) nor the FULLSCREEN option in EXT USER OPTIONS works.
+ This feature is currently nonfunctional in Windows OSes. It currently functions under Linux OSes. If you wish to run ROTTEXPR in a window, run rott.exe with the "window" argument.
+ If you wish to run ROTTEXPR in fullscreen, run rott.exe with the "fullscreen" argument.
+
+3. The game refuses to run at anything higher than 4k.
+ 4k resolution is currently the limit set in code.
--- a/rott/Makefile
+++ b/rott/Makefile
@@ -82,6 +82,7 @@
OBJS += byteordr.o
OBJS += dukemusc.o
OBJS += winrott.o
+OBJS += queue.o
AUDIOLIB := audiolib/audiolib.a
@@ -99,4 +100,4 @@
$(RM) $(OBJS) $(ROTT) $(ROTT).exe
clean: tidy
- $(MAKE) -C audiolib $@
\ No newline at end of file
+ $(MAKE) -C audiolib $@
--- a/rott/WinRott.h
+++ b/rott/WinRott.h
@@ -5,6 +5,10 @@
//husk at rette i winrott.c
+#define MAXSCREENWIDTH 3840
+#define MAXSCREENHEIGHT 2160 //max res is set to be 4k
+
+
extern int iGLOBAL_SCREENWIDTH;//bna val 800
extern int iGLOBAL_SCREENHEIGHT;//bna val 600
@@ -23,7 +27,7 @@
void EnableScreenStretch(void);
void DisableScreenStretch(void);
-
+void WriteNewResolution(void);
/*
double dYZANGLELIMIT;
--- a/rott/_z_zone.h
+++ b/rott/_z_zone.h
@@ -24,7 +24,7 @@
#define MINFRAGMENT 64
#define DPMI_INT 0x31
-#define MAXMEMORYSIZE 9000000
+#define MAXMEMORYSIZE 900000000
#define LEVELZONESIZE 250000
--- a/rott/audiolib/multivoc.c
+++ b/rott/audiolib/multivoc.c
@@ -537,6 +537,16 @@
// SetBorderColor(backcolor++);
// break;
// }
+
+ if(NULL == voice->GetSound)
+ {
+ #ifdef _DEBUG
+ printf("MV_ServiceVoc() voice->GetSound == NULL, break;\n");
+ #endif
+
+ // This sound is null, early out, or face a nasty crash.
+ break;
+ }
MV_BufferEmpty[ MV_MixPage ] = FALSE;
--- a/rott/engine.c
+++ b/rott/engine.c
@@ -39,7 +39,7 @@
=============================================================================
*/
//wallcast_t posts[642];//bna++
-wallcast_t posts[800+2];//bna++
+wallcast_t posts[MAXSCREENWIDTH+4];//bna++
//wallcast_t posts[321];
int lasttilex;
int lasttiley;
--- a/rott/engine.h
+++ b/rott/engine.h
@@ -38,7 +38,7 @@
int posttype;
int alttile;
} wallcast_t;
-extern wallcast_t posts[800+2];//bna++ JUST MAKE IT MAX RES
+extern wallcast_t posts[MAXSCREENWIDTH+4];//bna++ JUST MAKE IT MAX RES
//extern wallcast_t posts[642];//bna++
//extern wallcast_t posts[321];
--- a/rott/modexlib.c
+++ b/rott/modexlib.c
@@ -53,7 +53,7 @@
int linewidth;
//int ylookup[MAXSCREENHEIGHT];
-int ylookup[600];//just set to max res
+int ylookup[MAXSCREENHEIGHT];//just set to max res
byte *page1start;
byte *page2start;
byte *page3start;
@@ -434,9 +434,9 @@
#if defined(PLATFORM_WIN32) || defined(PLATFORM_MACOSX)
// FIXME: remove this. --ryan.
flags = SDL_FULLSCREEN;
- SDL_WM_GrabInput(SDL_GRAB_ON);
+
#endif
-
+ SDL_WM_GrabInput(SDL_GRAB_ON);
SDL_WM_SetCaption ("Rise of the Triad", "ROTT");
SDL_ShowCursor (0);
// sdl_surface = SDL_SetVideoMode (320, 200, 8, flags);
--- a/rott/modexlib.h
+++ b/rott/modexlib.h
@@ -108,10 +108,10 @@
#define PEL_DATA 0x3c9
#endif
-extern boolean StretchScreen;//bn�++
+extern boolean StretchScreen;//bn�++
//extern int ylookup[MAXSCREENHEIGHT]; // Table of row offsets
-extern int ylookup[600]; // just set to max res
+extern int ylookup[MAXSCREENHEIGHT]; // just set to max res
extern int linewidth;
extern byte *page1start;
extern byte *page2start;
--- /dev/null
+++ b/rott/queue.c
@@ -1,0 +1,102 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "Queue.h"
+
+//Fetched from https://codereview.stackexchange.com/questions/141238/implementing-a-generic-queue-in-c
+
+
+void queueInit(Queue *q, size_t memSize)
+{
+ q->sizeOfQueue = 0;
+ q->memSize = memSize;
+ q->head = q->tail = NULL;
+}
+
+int enqueue(Queue *q, const void *data)
+{
+ node *newNode = (node *)malloc(sizeof(node));
+
+ if(newNode == NULL)
+ {
+ return -1;
+ }
+
+ newNode->data = malloc(q->memSize);
+
+ if(newNode->data == NULL)
+ {
+ free(newNode);
+ return -1;
+ }
+
+ newNode->next = NULL;
+
+ memcpy(newNode->data, data, q->memSize);
+
+ if(q->sizeOfQueue == 0)
+ {
+ q->head = q->tail = newNode;
+ }
+ else
+ {
+ q->tail->next = newNode;
+ q->tail = newNode;
+ }
+
+ q->sizeOfQueue++;
+ return 0;
+}
+
+void dequeue(Queue *q, void *data)
+{
+ if(q->sizeOfQueue > 0)
+ {
+ node *temp = q->head;
+ memcpy(data, temp->data, q->memSize);
+
+ if(q->sizeOfQueue > 1)
+ {
+ q->head = q->head->next;
+ }
+ else
+ {
+ q->head = NULL;
+ q->tail = NULL;
+ }
+
+ q->sizeOfQueue--;
+ free(temp->data);
+ free(temp);
+ }
+}
+
+void queuePeek(Queue *q, void *data)
+{
+ if(q->sizeOfQueue > 0)
+ {
+ node *temp = q->head;
+ memcpy(data, temp->data, q->memSize);
+ }
+}
+
+void clearQueue(Queue *q)
+{
+ node *temp;
+
+ while(q->sizeOfQueue > 0)
+ {
+ temp = q->head;
+ q->head = temp->next;
+ free(temp->data);
+ free(temp);
+ q->sizeOfQueue--;
+ }
+
+ q->head = q->tail = NULL;
+}
+
+int getQueueSize(Queue *q)
+{
+ return q->sizeOfQueue;
+}
\ No newline at end of file
--- /dev/null
+++ b/rott/queue.h
@@ -1,0 +1,28 @@
+#ifndef QUEUE_H_INCLUDED
+#define QUEUE_H_INCLUDED
+
+//Fetched from https://codereview.stackexchange.com/questions/141238/implementing-a-generic-queue-in-c
+
+
+typedef struct Node
+{
+ void *data;
+ struct Node *next;
+}node;
+
+typedef struct QueueList
+{
+ int sizeOfQueue;
+ size_t memSize;
+ node *head;
+ node *tail;
+}Queue;
+
+void queueInit(Queue *q, size_t memSize);
+int enqueue(Queue *, const void *);
+void dequeue(Queue *, void *);
+void queuePeek(Queue *, void *);
+void clearQueue(Queue *);
+int getQueueSize(Queue *);
+
+#endif /* QUEUE_H_INCLUDED */
\ No newline at end of file
--- a/rott/rt_actor.c
+++ b/rott/rt_actor.c
@@ -58,6 +58,7 @@
#include "fx_man.h"
//MED
#include "memcheck.h"
+#include "queue.h"
@@ -1632,9 +1633,6 @@
ob->temp3 = stat_kes;
ob->temp2 = 3;
}
- //TODO: Figure out a way to allow biltzguards to attack with excalibat w/o crashing the game
-
- //TODO: Figure out a way to allow blitzguards to attack effectively with split missiles (like actually split them)
#endif
else
@@ -3767,24 +3765,98 @@
}
}
-extern objtype* enemiesToRes;
-extern unsigned int freeSlot;
-void AddEnemyToResurrectList(objtype * ob)
+int DetermineTimeUntilEnemyIsResurrected(classtype obclass)
{
- SetReverseDeathState(ob);
- enemiesToRes[freeSlot] = *ob;
- freeSlot++;
+ switch(obclass)
+ {
+ case lowguardobj:
+ return gamestate.TimeCount/VBLCOUNTER + 60;
+ break;
+ case highguardobj:
+ return gamestate.TimeCount/VBLCOUNTER + 90;
+ break;
+
+ case strikeguardobj:
+ return gamestate.TimeCount/VBLCOUNTER + 65;
+ break;
+ case blitzguardobj:
+ return gamestate.TimeCount/VBLCOUNTER + 60;
+ break;
+ case triadenforcerobj:
+ return gamestate.TimeCount/VBLCOUNTER + 200;
+ break;
+ #if (SHAREWARE == 0)
+ case overpatrolobj:
+ return gamestate.TimeCount/VBLCOUNTER + 75;
+ break;
+ case deathmonkobj:
+ return gamestate.TimeCount/VBLCOUNTER + 150;
+ break;
+ case dfiremonkobj:
+ return gamestate.TimeCount/VBLCOUNTER + 175;
+ break;
+ #endif
+ default:
+ return -1; //TODO: Return -1 for every entry that isn't any of the above
+ break;
+ }
+
}
-void CleanUpResurrectList()
+extern Queue * enemiesToRes[8];
+
+void AddEnemyToResurrectList(objtype * ob)
{
- memset(enemiesToRes, 0, sizeof(*enemiesToRes));
- freeSlot = 0;
+ ob->resurrectAtTime = DetermineTimeUntilEnemyIsResurrected(ob->obclass);
+ if (ob->resurrectAtTime == -1)
+ {
+ free(ob);
+ return;
+ }
+ SetReverseDeathState(ob);
+ switch(ob->obclass)
+ {
+ case lowguardobj:
+ enqueue(enemiesToRes[0], ob);
+ break;
+ case highguardobj:
+ enqueue(enemiesToRes[1], ob);
+ break;
+
+ case strikeguardobj:
+ enqueue(enemiesToRes[2], ob);
+ break;
+ case blitzguardobj:
+ enqueue(enemiesToRes[3], ob);
+ break;
+ case triadenforcerobj:
+ enqueue(enemiesToRes[4], ob);
+ break;
+ #if (SHAREWARE == 0)
+ case overpatrolobj:
+ enqueue(enemiesToRes[5], ob);
+ break;
+ case deathmonkobj:
+ enqueue(enemiesToRes[6], ob);
+ break;
+ case dfiremonkobj:
+ enqueue(enemiesToRes[7], ob);
+ break;
+ #endif
+ default:
+ Error("Unknown organic enemy type detected in AddEnemyToResurrectList");
+ break;
+ }
+ //enqueue(&enemiesToRes, ob);
}
void FreeUpResurrectList()
{
- free(enemiesToRes);
+ int x = 0;
+ for (x = 0; x < 8; x++)
+ {
+ clearQueue(enemiesToRes[x]);
+ }
}
void SetAfterResurrectState(objtype * actor, statetype * doWhat)
@@ -3843,66 +3915,32 @@
ConnectAreas();
}
+
void ResurrectEnemies()
{
objtype * actor;
- for (actor = &enemiesToRes[0]; actor < &enemiesToRes[freeSlot]; actor++)
- {
- SD_PlaySoundRTP(SD_PLAYERSPAWNSND, actor->x, actor->y);
- SpawnDuringGameWithState (actor->obclass,actor->tilex,actor->tiley,actor->dir, 1, actor->state);
- }
+ int currTime = gamestate.TimeCount/VBLCOUNTER;
- CleanUpResurrectList();
+ int index;
-}
-
-/*
-void SetStandAfterResurrect(objtype * actor)
-{
- switch(actor->obclass)
+ for (index = 0; index < 8; index++)
{
- case lowguardobj:
- SetAfterResurrectState(actor, &s_lowgrdstand);
- //actor->state = &s_lowgrdchase1;
- break;
- case highguardobj:
- SetAfterResurrectState(actor, &s_highgrdstand);
- //actor->state = &s_highgrdchase1;
- break;
- case strikeguardobj:
- SetAfterResurrectState(actor, &s_strikestand);
- //actor->state = &s_strikechase1;
- break;
- case blitzguardobj:
- SetAfterResurrectState(actor, &s_blitzstand);
- //actor->state = &s_blitzchase1;
- break;
- case triadenforcerobj:
- SetAfterResurrectState(actor, &s_enforcerstand);
- //actor->state = &s_enforcerchase1;
- break;
- case overpatrolobj:
- SetAfterResurrectState(actor, &s_opstand);
- //actor->state = &s_opchase1;
- break;
- case deathmonkobj:
- SetAfterResurrectState(actor, &s_dmonkstand);
- //actor->state = &s_dmonkchase1;
- break;
- case dfiremonkobj:
- SetAfterResurrectState(actor, &s_firemonkstand);
- //actor->state = &s_firemonkchase1;
- break;
- default:
- Error("SetStandAfterResurrect was called with something that can't be handled!");
- break;
+ if (enemiesToRes[index]->sizeOfQueue == 0)
+ {
+ continue;
+ }
+ actor = enemiesToRes[index]->head->data;
+ if (currTime >= actor->resurrectAtTime)
+ {
+ SD_PlaySoundRTP(SD_PLAYERSPAWNSND, actor->x, actor->y);
+ SpawnDuringGameWithState (actor->obclass,actor->tilex,actor->tiley,actor->dir, 1, actor->state);
+ dequeue(enemiesToRes[index], actor);
+ gamestate.killcount--;
+ }
}
}
-*/
-
-
void SpawnDuringGame (classtype which, int tilex, int tiley, int dir, int ambush)
{
statetype *temp;
@@ -3950,19 +3988,6 @@
ConnectAreas();
}
-void SaveResurrectList(byte ** buffer, int *size)
-{
- byte*tptr;
-
- *size = sizeof(enemiesToRes);
- *buffer = (byte*)SafeMalloc(*size);
- tptr = *buffer;
-
- memcpy(tptr, enemiesToRes, sizeof(*enemiesToRes));
- tptr += sizeof(enemiesToRes);
-
-}
-
/*
========================
=
@@ -4073,7 +4098,6 @@
playertype *pstate;
M_LINKSTATE(ob,pstate);
-
ob->flags &= ~(FL_ELASTO|FL_GODMODE|FL_DOGMODE|FL_NOFRICTION|FL_RIDING);
ob->flags |= FL_DYING;
@@ -5493,7 +5517,7 @@
return false; \
}
-extern boolean ricochetingRocketsEnabled = 0;
+extern boolean ricochetingRocketsEnabled;
boolean MissileTryMove(objtype*ob,int tryx,int tryy,int tryz)
{
--- a/rott/rt_actor.h
+++ b/rott/rt_actor.h
@@ -27,6 +27,7 @@
//***************************************************************************
#include "states.h"
+#include "queue.h"
#define FL_SYNCED 0x400
@@ -256,12 +257,10 @@
struct objstruct *next, *prev;
struct objstruct *nextactive, *prevactive;
struct objstruct *nextinarea, *previnarea;
-
+ int resurrectAtTime;
} objtype;
-
-
typedef struct b_struct
{ int NMErotate;
int NMEdirstried;
@@ -298,6 +297,7 @@
} misc_stuff;
+
extern boolean ludicrousgibs;
extern objtype* PLAYER0MISSILE;
extern byte deathshapeoffset[8];
@@ -435,4 +435,4 @@
void ResurrectEnemies();
-#endif
+#endif
\ No newline at end of file
--- a/rott/rt_cfg.c
+++ b/rott/rt_cfg.c
@@ -1,2239 +1,2277 @@
-/*
-Copyright (C) 1994-1995 Apogee Software, Ltd.
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
-See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-*/
-//****************************************************************************
-//
-// RT_CFG.C
-//
-//****************************************************************************
-
-#define _ROTT_
-
-#ifdef DOS
-#include <io.h>
-#include <bios.h>
-#include <conio.h>
-#include <process.h>
-#else
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <errno.h>
-#endif
-
-#include <stdlib.h>
-#include <fcntl.h>
-#include <string.h>
-#include <ctype.h>
-
-#ifdef _ROTT_
-#include "rt_def.h"
-#else
-#include "st_def.h"
-#endif
-
-#include "rt_cfg.h"
-#include "version.h"
-
-#ifdef _ROTT_
-
-#include "scriplib.h"
-#include "rt_playr.h"
-#include "rt_menu.h"
-#include "rt_game.h"
-#include "rt_in.h"
-#include "z_zone.h"
-#include "w_wad.h"
-#include "rt_crc.h"
-#include "rt_sound.h"
-#include "rt_util.h"
-#include "rt_main.h"
-#include "rt_view.h"
-#include "rt_msg.h"
-#include "rt_battl.h"
-#include "rt_net.h"
-#include "isr.h"
-#include "fx_man.h"
-#include "develop.h"
-
-#else
-
-#include "st_def.h"
-#include "rt_cfg.h"
-#include "scriplib.h"
-#include "rt_sound.h"
-#include "st_util.h"
-
-#endif
-//MED
-#include "memcheck.h"
-
-
-//******************************************************************************
-//
-// GLOBALS
-//
-//******************************************************************************
-
-extern int G_weaponscale;
-extern boolean iG_aimCross;
-
-boolean WriteSoundFile = true;
-
-int FXMode = 0;
-int MusicMode = 0;
-
-int MUvolume = 196;
-int FXvolume = 196;
-
-#ifdef DOS
-fx_blaster_config SBSettings =
-{
- 0x220, fx_SB, 7, 1, 5, 0x330, 0x620
-};
-#endif
-
-boolean mouseenabled = 1;
-boolean usemouselook = 0;
-int inverse_mouse = 1; //set to -1 to invert mouse
-boolean usejump = 0;
-boolean sdl_fullscreen = 1;
-
-boolean allowBlitzMoreMissileWeps = 0;
-boolean enableAmmoPickups = 0;
-boolean autoAimMissileWeps = 0;
-boolean autoAim = 1;
-
-boolean joystickenabled = 0;
-boolean joypadenabled = 0;
-int joystickport = 0;
-int mouseadjustment = 5;
-int threshold = 1;
-int NumVoices = 4;
-int NumChannels = 1;
-int NumBits = 8;
-#ifdef DOS
-int MidiAddress = 0x330;
-#endif
-boolean cybermanenabled = false;
-boolean assassinenabled = false;
-boolean spaceballenabled = false;
-boolean AutoDetailOn = true;
-int DoubleClickSpeed = 20;
-boolean BobbinOn = true;
-int Menuflipspeed = 15;
-int DetailLevel = 2; //HI DETAIL
-int fandc = 1;
-int blanktime = (2*60*VBLCOUNTER);
-boolean ConfigLoaded = false;
-boolean stereoreversed = false;
-
-int DefaultDifficulty = 2;
-int DefaultPlayerCharacter = 0;
-int DefaultPlayerColor = 0;
-byte passwordstring[20];
-
-#ifndef _ROTT_
-
-int fulllight = 0;
-int viewsize = 7;
-
-#endif
-MacroList CommbatMacros[MAXMACROS];
-
-#ifdef DOS
-char *ApogeePath = "APOGEECD";
-#else
-char ApogeePath[256];
-#endif
-
-//******************************************************************************
-//
-// LOCALS
-//
-//******************************************************************************
-
-static char SoundName[13] = "sound.rot";
-
-#ifdef _ROTT_
-
-static char *ConfigName = "config.rot";
-static char *ScoresName = "scores.rot";
-static char *ROTT = "rott.rot";
-static char *CONFIG = "setup.rot";
-static char *BattleName = "battle.rot";
-
-AlternateInformation RemoteSounds;
-//AlternateInformation PlayerGraphics;
-AlternateInformation GameLevels;
-AlternateInformation BattleLevels;
-char CodeName[MAXCODENAMELENGTH];
-
-#endif
-
-
-#ifdef _ROTT_
-
-//******************************************************************************
-//
-// ReadScores ()
-//
-//******************************************************************************
-
-void ReadScores (void)
-{
- int file;
- char filename[ 128 ];
-
- GetPathFromEnvironment( filename, ApogeePath, ScoresName );
- if (access (filename, F_OK) == 0)
- {
- file = SafeOpenRead (filename);
- SafeRead (file, &Scores, sizeof (Scores));
- close(file);
- }
- else
- gamestate.violence = 0;
-}
-
-#endif
-
-//******************************************************************************
-//
-// ReadInt
-//
-//******************************************************************************
-
-void ReadInt (const char * s1, int * val)
-{
- GetToken (true);
- if (!strcmpi (token,s1))
- {
- if (TokenAvailable()==true)
- {
- GetToken(false);
- *val=ParseNum(token);
- }
- }
-}
-
-//******************************************************************************
-//
-// ReadBoolean
-//
-//******************************************************************************
-
-void ReadBoolean (const char * s1, boolean * val)
-{
- int temp;
-
- temp = (int)(*val);
- ReadInt (s1,&temp);
- *val = (boolean) temp;
-}
-
-//******************************************************************************
-//
-// ReadUnsigned
-//
-//******************************************************************************
-
-void ReadUnsigned (const char * s1, unsigned long * val)
-{
- int temp;
-
- temp = (int)(*val);
- ReadInt (s1,&temp);
- *val = (unsigned) temp;
-}
-
-//******************************************************************************
-//
-// ParseSoundFile ()
-//
-//******************************************************************************
-
-boolean ParseSoundFile (void)
-{
- boolean retval = true;
- int version = 0;
-
- ReadInt("Version",&version);
-
- if (version == ROTTVERSION)
- {
- // Read in Music Mode
-
- ReadInt ("MusicMode",&MusicMode);
-
- // Read in FX Mode
-
- ReadInt ("FXMode",&FXMode);
-
- // Read in Music Volume
-
- ReadInt ("MusicVolume", &MUvolume);
-
- // Read in FX Volume
-
- ReadInt ("FXVolume", &FXvolume);
-
- // Read in numvoices
-
- ReadInt ("NumVoices",&NumVoices);
-
- // Read in numchannels
-
- ReadInt ("NumChannels",&NumChannels);
-
- // Read in numbits
-
- ReadInt ("NumBits",&NumBits);
-
-#ifdef DOS
- // Read in Midi Address
-
- ReadInt ("MidiAddress",&MidiAddress);
-#endif
-
- // Read in stereo reversal
-
- ReadBoolean ("StereoReverse",&stereoreversed);
-
-#ifdef DOS
- // Read in Sound Blaster info
- ReadUnsigned ("SBType", &SBSettings.Type );
- ReadUnsigned ("SBPort", &SBSettings.Address );
- ReadUnsigned ("SBIrq", &SBSettings.Interrupt );
- ReadUnsigned ("SBDma8", &SBSettings.Dma8 );
- ReadUnsigned ("SBDma16", &SBSettings.Dma16 );
- ReadUnsigned ("SBMidi", &SBSettings.Midi );
- ReadUnsigned ("SBEmu", &SBSettings.Emu );
-#endif
- }
- else
- retval = false;
-
- return (retval);
-}
-
-
-
-//******************************************************************************
-//
-// SetSoundDefaultValues ()
-//
-//******************************************************************************
-void SetSoundDefaultValues
-(
- void
-)
-
-{
-#ifdef DOS
- fx_blaster_config blaster;
-#endif
- int status;
-
- //
- // no config file, so select default values
- //
-#if !defined(PLATFORM_DOS)
- // icculus' SDL_mixer driver looks like a soundscape to us
- MusicMode = 6;
- FXMode = 6;
- NumVoices = 8;
- NumChannels = 2;
- NumBits = 16;
- stereoreversed = false;
-#else
- MusicMode = 0;
- FXMode = 0;
- NumVoices = 4;
- NumChannels = 1;
- NumBits = 8;
- MidiAddress = 0x330;
- stereoreversed = false;
-
- status = FX_GetBlasterSettings( &blaster );
- if ( status == FX_Ok )
- {
- SBSettings.Type = blaster.Type;
- SBSettings.Address = blaster.Address;
- SBSettings.Interrupt = blaster.Interrupt;
- SBSettings.Dma8 = blaster.Dma8;
- SBSettings.Dma16 = blaster.Dma16;
- SBSettings.Midi = blaster.Midi;
- SBSettings.Emu = blaster.Emu;
- }
-#endif
-}
-
-
-#ifdef _ROTT_
-
-extern char pword[ 13 ];
-//******************************************************************************
-//
-// ConvertStringToPasswordString ()
-//
-//******************************************************************************
-
-#define PASSWORDENCRYPTER "7d7e4a2d3b6a0319554654231f6d2a"
-
-void ConvertStringToPasswordString ( char * string )
-{
- int i;
- unsigned int j;
- char temp[3];
-
- memset(temp,0,sizeof(temp));
-
- for (i=0; i<13; i++)
- {
- memcpy(&temp[0],&string[i<<1],2);
- sscanf(&temp[0],"%x",&j);
- passwordstring[i+0] = j & 0xff;
- j >>= 8;
- passwordstring[i+1] = j & 0xff;
- j >>= 8;
- passwordstring[i+2] = j & 0xff;
- j >>= 8;
- passwordstring[i+3] = j & 0xff;
- }
-}
-
-//******************************************************************************
-//
-// ConvertPasswordStringToPassword ()
-//
-//******************************************************************************
-
-void ConvertPasswordStringToPassword ( void )
-{
- int i;
- int x;
- char temp[3];
- char key[40];
-
- memset(temp,0,sizeof(temp));
- strcpy(&key[0],PASSWORDENCRYPTER);
-
- for (i=0; i<12; i++)
- {
- memcpy(&temp[0],&key[i<<1],2);
- sscanf(&temp[0],"%x",&x);
- pword[i]=passwordstring[i]^x;
- }
- memcpy(&temp[0],&key[i<<1],2);
- sscanf(&temp[0],"%x",&x);
- gamestate.violence=passwordstring[i]^x;
- if (
- (gamestate.violence<0) ||
- (gamestate.violence>3)
- )
- gamestate.violence=0;
-}
-
-//******************************************************************************
-//
-// ConvertPasswordStringToString ()
-//
-//******************************************************************************
-
-void ConvertPasswordStringToString ( char * string )
-{
- int i;
- char temp[8];
-
- memset(temp,0,sizeof(temp));
-
- for (i=0; i<13; i++)
- {
- itoa((passwordstring[i]>>4),&temp[0],16);
- string[(i<<1)+0]=temp[0];
- itoa((passwordstring[i]&0xf),&temp[0],16);
- string[(i<<1)+1]=temp[0];
- }
-}
-
-//******************************************************************************
-//
-// ConvertPasswordToPasswordString ()
-//
-//******************************************************************************
-
-void ConvertPasswordToPasswordString ( void )
-{
- int i;
- int x;
- char temp[3];
- char key[40];
-
- memset(temp,0,sizeof(temp));
- strcpy(&key[0],PASSWORDENCRYPTER);
-
- for (i=0; i<12; i++)
- {
- memcpy(&temp[0],&key[i<<1],2);
- sscanf(&temp[0],"%x",&x);
- passwordstring[i]=pword[i]^x;
- }
- memcpy(&temp[0],&key[i<<1],2);
- sscanf(&temp[0],"%x",&x);
- passwordstring[i]=gamestate.violence^x;
-}
-
-//******************************************************************************
-//
-// ParseConfigFile ()
-//
-//******************************************************************************
-
-boolean ParseConfigFile (void)
-{
-// int temp;
- boolean retval = true;
- int version = 0;
-
- ReadInt("Version",&version);
-
- if (version == ROTTVERSION)
- {
- //Read in allowBlitzguardMoreMissileWeps
-
- ReadBoolean("AllowBlitzguardMoreMissileWeps", &allowBlitzMoreMissileWeps);
-
- //Read in enableAmmoPickups
-
- ReadBoolean("EnableAmmoPickups", &enableAmmoPickups);
-
- //Read in AutoAim
-
- ReadBoolean("AutoAim", &autoAim);
-
- //Read in AutoAimMissileWeps
-
- ReadBoolean("AutoAimMissileWeps", &autoAimMissileWeps);
-
- // Read in MouseEnabled
- ReadBoolean("MouseEnabled",&mouseenabled);
-
- // Read in UseMouseLook
- ReadBoolean("UseMouseLook",&usemouselook);
-
- ReadInt("InverseMouse",&inverse_mouse);
-
- // Read in UseJump
- ReadBoolean("UseJump",&usejump);
-
- // Read in CrossHair
- ReadBoolean("CrossHair",&iG_aimCross);
-
- // Read in JoystickEnabled
- ReadBoolean("JoystickEnabled",&joystickenabled);
-
- // Read in JoypadEnabled
- ReadBoolean("JoypadEnabled",&joypadenabled);
-
- // Read in JoystickPort
-
- ReadInt("JoystickPort",&joystickport);
-
- // Read in fullscreen
- ReadBoolean("FullScreen", &sdl_fullscreen);
-
- // Read in resolution
- ReadInt("ScreenWidth", &iGLOBAL_SCREENWIDTH);
- ReadInt("ScreenHeight", &iGLOBAL_SCREENHEIGHT);
-
- // Read in ViewSize
-
- ReadInt("ViewSize",&viewsize);
-
- // Read in Weaponscale
-
- ReadInt("Weaponscale",&G_weaponscale);//bna added
- if ((G_weaponscale <150)||(G_weaponscale>600)) {
- if (iGLOBAL_SCREENWIDTH == 320) {
- G_weaponscale=168;
- } else if (iGLOBAL_SCREENWIDTH == 640) {
- G_weaponscale=299;
- } else if (iGLOBAL_SCREENWIDTH == 800) {
- G_weaponscale=376;
- }
- }
-
- // Read in MouseAdjustment
-
- ReadInt("MouseAdjustment",&mouseadjustment);
-
- // Read in threshold
-
- ReadInt("Threshold",&threshold);
-
- // Read in Auto Detail
-
- ReadBoolean ("AutoDetail", &AutoDetailOn);
-
- // Read in Light Dim
-
- ReadInt ("LightDim", &fulllight);
-
- // Read in Bobbin' On
-
- ReadBoolean ("BobbingOn", &BobbinOn);
-
- // Read in Double Click Speed
-
- ReadInt ("DoubleClickSpeed", &DoubleClickSpeed);
-
- // Read in Menu Flip Speed
-
- ReadInt ("MenuFlipSpeed", &Menuflipspeed);
-
- // Read in Detail Level
-
- ReadInt ("DetailLevel", &DetailLevel);
-
- // Read in Floor and Ceiling
-
- ReadInt ("FloorCeiling", &fandc);
-
- // Read in MessagesEnabled
-
- ReadBoolean ("Messages", &MessagesEnabled );
-
- // Read in Autorun
-
- ReadInt ("AutoRun", &gamestate.autorun );
-
- // Read in GammaIndex
-
- ReadInt ("GammaIndex", &gammaindex);
-
- // Read screen blanking time
-
- ReadInt ("BlankTime", &blanktime);
-
- blanktime=blanktime*60*VBLCOUNTER;
-
- // Read keys
-
- ReadInt ("Fire", &buttonscan[0]);
- ReadInt ("Strafe", &buttonscan[1]);
- ReadInt ("Run", &buttonscan[2]);
- ReadInt ("Use", &buttonscan[3]);
- ReadInt ("LookUp", &buttonscan[4]);
- ReadInt ("LookDn", &buttonscan[5]);
- ReadInt ("Swap", &buttonscan[6]);
- ReadInt ("Drop", &buttonscan[7]);
- ReadInt ("TargetUp", &buttonscan[8]);
- ReadInt ("TargetDn", &buttonscan[9]);
- ReadInt ("SelPistol", &buttonscan[10]);
- ReadInt ("SelDualPistol",&buttonscan[11]);
- ReadInt ("SelMP40", &buttonscan[12]);
- ReadInt ("SelMissile", &buttonscan[13]);
- ReadInt ("AutoRun", &buttonscan[14]);
- ReadInt ("LiveRemRid", &buttonscan[15]);
- ReadInt ("StrafeLeft", &buttonscan[16]);
- ReadInt ("StrafeRight", &buttonscan[17]);
- ReadInt ("VolteFace", &buttonscan[18]);
- ReadInt ("Aim", &buttonscan[19]);
- ReadInt ("Forward", &buttonscan[20]);
- ReadInt ("Right", &buttonscan[21]);
- ReadInt ("Backward", &buttonscan[22]);
- ReadInt ("Left", &buttonscan[23]);
- ReadInt ("Map", &buttonscan[24]);
- ReadInt ("SendMessage", &buttonscan[25]);
- ReadInt ("DirectMessage",&buttonscan[26]);
-
- ReadInt ("MouseButton0",&buttonmouse[0]);
- ReadInt ("MouseButton1",&buttonmouse[1]);
- ReadInt ("MouseButton2",&buttonmouse[2]);
- ReadInt ("DblClickB0", &buttonmouse[3]);
- ReadInt ("DblClickB1", &buttonmouse[4]);
- ReadInt ("DblClickB2", &buttonmouse[5]);
-
- ReadInt ("JoyButton0", &buttonjoy[0]);
- ReadInt ("JoyButton1", &buttonjoy[1]);
- ReadInt ("JoyButton2", &buttonjoy[2]);
- ReadInt ("JoyButton3", &buttonjoy[3]);
- ReadInt ("DblClickJB0", &buttonjoy[4]);
- ReadInt ("DblClickJB1", &buttonjoy[5]);
- ReadInt ("DblClickJB2", &buttonjoy[6]);
- ReadInt ("DblClickJB3", &buttonjoy[7]);
-
- ReadInt ("JoyMaxX", &joyxmax);
- ReadInt ("JoyMaxY", &joyymax);
- ReadInt ("JoyMinX", &joyxmin);
- ReadInt ("JoyMinY", &joyymin);
-
- ReadInt( "DefaultDifficulty", &DefaultDifficulty );
- ReadInt( "DefaultPlayerCharacter", &DefaultPlayerCharacter );
- ReadInt( "DefaultPlayerColor", &DefaultPlayerColor );
-
- // Get Password string
- GetToken (true);
- if (!stricmp (token, "SecretPassword"))
- {
- GetTokenEOL (false);
- ConvertStringToPasswordString ( &name[0] );
- }
-
- if (!CybermanPresent)
- cybermanenabled = false;
-
- if (!AssassinPresent)
- assassinenabled = false;
-
- if (!SpaceBallPresent)
- spaceballenabled = false;
-
- if (!MousePresent)
- mouseenabled = false;
-
- if (!JoysPresent[joystickport])
- joystickenabled = false;
-
- // precaution
-
- if (!joyxmin || !joyxmax || !joyymin || !joyymax)
- joystickenabled = false;
-
- if (joystickenabled)
- IN_SetupJoy (joystickport, joyxmin, joyxmax, joyymin, joyymax);
- }
- else
- retval = false;
-
- return (retval);
-}
-
-
-//******************************************************************************
-//
-// ParseBattleFile ()
-//
-//******************************************************************************
-boolean ParseBattleFile (void)
-{
- boolean retval = true;
- int version = 0;
- int index;
- int temp;
- extern specials BattleSpecialsTimes;
-
- ReadInt("Version",&version);
- if (version != ROTTVERSION)
- retval = false;
- else
- {
- ReadBoolean( "ShowKillCount", &BATTLE_ShowKillCount );
-
- ReadInt( "GodModeTime", &BattleSpecialsTimes.GodModeTime );
- ReadInt( "DogModeTime", &BattleSpecialsTimes.DogModeTime );
- ReadInt( "ShroomsModeTime", &BattleSpecialsTimes.ShroomsModeTime );
- ReadInt( "ElastoModeTime", &BattleSpecialsTimes.ElastoModeTime );
- ReadInt( "AsbestosVestTime", &BattleSpecialsTimes.AsbestosVestTime );
- ReadInt( "BulletProofVestTime", &BattleSpecialsTimes.BulletProofVestTime );
- ReadInt( "GasMaskTime", &BattleSpecialsTimes.GasMaskTime );
- ReadInt( "MercuryModeTime", &BattleSpecialsTimes.MercuryModeTime );
- ReadInt( "GodModeRespawnTime", &BattleSpecialsTimes.GodModeRespawnTime );
- ReadInt( "DogModeRespawnTime", &BattleSpecialsTimes.DogModeRespawnTime );
- ReadInt( "ShroomsModeRespawnTime", &BattleSpecialsTimes.ShroomsModeRespawnTime );
- ReadInt( "ElastoModeRespawnTime", &BattleSpecialsTimes.ElastoModeRespawnTime );
- ReadInt( "AsbestosVestRespawnTime", &BattleSpecialsTimes.AsbestosVestRespawnTime );
- ReadInt( "BulletProofVestRespawnTime", &BattleSpecialsTimes.BulletProofVestRespawnTime );
- ReadInt( "GasMaskRespawnTime", &BattleSpecialsTimes.GasMaskRespawnTime );
- ReadInt( "MercuryModeRespawnTime", &BattleSpecialsTimes.MercuryModeRespawnTime );
-
- ReadBoolean( "EKG", &battlegibs );
-
- for( index = battle_Normal; index < battle_NumBattleModes; index++ )
- {
- // Read Gravity
- temp = BATTLE_Options[ index ].Gravity;
- ReadInt( "Gravity", &temp );
- BATTLE_Options[ index ].Gravity = temp;
-
- // Read Speed
- temp = bo_normal_speed;
- ReadInt( "Speed", &temp );
- if ( ( temp >= bo_normal_speed ) &&
- ( temp <= bo_fast_speed ) )
- {
- BATTLE_Options[ index ].Speed = temp;
- }
-
- if ( ( index != battle_Collector ) && ( index != battle_Tag ) &&
- ( index != battle_Eluder ) )
- {
- // Read Ammo
- temp = bo_normal_shots;
- BATTLE_Options[ index ].Ammo = bo_normal_shots;
- ReadInt( "Ammo", &temp );
- if ( ( temp >= bo_one_shot ) &&
- ( temp <= bo_infinite_shots ) )
- {
- BATTLE_Options[ index ].Ammo = temp;
- }
- }
-
- if ( index != battle_Eluder )
- {
- // Read Hitpoints
- temp = BATTLE_Options[ index ].HitPoints;
- ReadInt( "Hitpoints", &temp );
- BATTLE_Options[ index ].HitPoints = temp;
- }
-
- // Read Spawn Dangers
- temp = 1;
- ReadInt( "SpawnDangers", &temp );
- BATTLE_Options[ index ].SpawnDangers = temp;
-
- if ( index != battle_Eluder )
- {
- // Read Spawn Health
- temp = 1;
- ReadInt( "SpawnHealth", &temp );
- BATTLE_Options[ index ].SpawnHealth = temp;
-
- // Read Spawn Mines
- temp = 0;
- ReadInt( "SpawnMines", &temp );
- BATTLE_Options[ index ].SpawnMines = temp;
- }
-
- if ( ( index != battle_Collector ) && ( index != battle_Tag ) &&
- ( index != battle_Eluder ) )
- {
- // Read Spawn Weapons
- temp = 1;
- ReadInt( "SpawnWeapons", &temp );
- BATTLE_Options[ index ].SpawnWeapons = temp;
-
- // Read Random Weapons
- temp = 0;
- ReadInt( "RandomWeapons", &temp );
- BATTLE_Options[ index ].RandomWeapons = temp;
-
- // Read Weapon Persistence
- temp = 0;
- ReadInt( "WeaponPersistence", &temp );
- BATTLE_Options[ index ].WeaponPersistence = temp;
- }
-
- if ( ( index == battle_Normal ) || ( index == battle_ScoreMore ) ||
- ( index == battle_Hunter ) || ( index == battle_Tag ) )
- {
- // Read Friendly Fire
- temp = 1;
- ReadInt( "FriendlyFire", &temp );
- BATTLE_Options[ index ].FriendlyFire = temp;
- }
-
- if ( index != battle_Eluder )
- {
- // Read Respawn Items
- temp = 1;
- ReadInt( "RespawnItems", &temp );
- BATTLE_Options[ index ].RespawnItems = temp;
- }
-
- // Read Light Level
- temp = bo_light_normal;
- ReadInt( "LightLevel", &temp );
- if ( ( temp >= bo_light_dark ) &&
- ( temp <= bo_light_lightning ) )
- {
- BATTLE_Options[ index ].LightLevel = temp;
- }
-
- if ( ( index != battle_Collector ) && ( index != battle_Scavenger ) )
- {
- // Read Point Goal
- temp = bo_kills_default;
- ReadInt( "PointGoal", &temp );
- BATTLE_Options[ index ].Kills = temp;
- if ( temp < bo_kills_random )
- {
- BATTLE_Options[ index ].Kills = bo_kills_default;
- }
- }
-
- if ( index != battle_Eluder )
- {
- // Read Danger Damage
- temp = bo_danger_normal;
- ReadInt( "DangerDamage", &temp );
- BATTLE_Options[ index ].DangerDamage = temp;
- }
-
- // Read Time Limit
- temp = bo_time_infinite;
- ReadInt( "TimeLimit", &temp );
- if ( ( index == battle_Hunter ) && ( temp == bo_time_infinite ) )
- {
- temp = 99;
- }
- BATTLE_Options[ index ].TimeLimit = temp;
-
- // Read Respawn time
- temp = bo_normal_respawn_time;
- ReadInt( "RespawnTime", &temp );
- BATTLE_Options[ index ].RespawnTime = temp;
- }
- }
-
- return (retval);
-}
-
-//******************************************************************************
-//
-// SetBattleDefaultValues ()
-//
-//******************************************************************************
-
-void SetBattleDefaultValues (void)
-{
- int index;
-
- //
- // no config file, so select default values
- //
- for( index = battle_StandAloneGame; index < battle_NumBattleModes;
- index++ )
- {
- BATTLE_Options[ index ].Gravity = NORMAL_GRAVITY;
- BATTLE_Options[ index ].Speed = bo_normal_speed;
- BATTLE_Options[ index ].Ammo = bo_normal_shots;
- BATTLE_Options[ index ].HitPoints = bo_default_hitpoints;
- BATTLE_Options[ index ].SpawnDangers = 1;
- BATTLE_Options[ index ].SpawnHealth = 1;
- BATTLE_Options[ index ].SpawnMines = 0;
- BATTLE_Options[ index ].SpawnWeapons = 1;
- BATTLE_Options[ index ].RespawnItems = 1;
- BATTLE_Options[ index ].RandomWeapons = 0;
- BATTLE_Options[ index ].WeaponPersistence = 0;
- BATTLE_Options[ index ].FriendlyFire = 1;
- BATTLE_Options[ index ].LightLevel = bo_light_normal;
- BATTLE_Options[ index ].Kills = bo_kills_default;
- BATTLE_Options[ index ].DangerDamage = bo_danger_normal;
- BATTLE_Options[ index ].TimeLimit = bo_time_infinite;
- BATTLE_Options[ index ].RespawnTime = bo_normal_respawn_time;
- }
-
- BATTLE_Options[ battle_CaptureTheTriad ].Kills = 1;
- BATTLE_Options[ battle_Hunter ].TimeLimit = 1;
- BATTLE_Options[ battle_Eluder ].SpawnHealth = 0;
- BATTLE_Options[ battle_Eluder ].RespawnItems = 0;
- BATTLE_Options[ battle_Eluder ].SpawnWeapons = 0;
- BATTLE_Options[ battle_Eluder ].FriendlyFire = 0;
- BATTLE_Options[ battle_Collector ].SpawnWeapons = 0;
- BATTLE_Options[ battle_Collector ].FriendlyFire = 0;
- BATTLE_Options[ battle_Tag ].SpawnWeapons = 0;
- battlegibs=false;
- BATTLE_ShowKillCount = true;
-}
-
-//******************************************************************************
-//
-// SetConfigDefaultValues ()
-//
-//******************************************************************************
-
-void SetConfigDefaultValues (void)
-{
- //
- // no config file, so select default values
- //
- if (MousePresent)
- mouseenabled = true;
-
- joystickenabled = false;
- joypadenabled = false;
- joystickport = 0;
- viewsize = 7;
- mouseadjustment = 5;
- gammaindex = 0;
- gamestate.violence = 3;
- passwordstring[0]=0x7d;
- passwordstring[1]=0x7e;
- passwordstring[2]=0x4a;
- passwordstring[3]=0x2d;
- passwordstring[4]=0x3b;
- passwordstring[5]=0x6a;
- passwordstring[6]=0x03;
- passwordstring[7]=0x19;
- passwordstring[8]=0x55;
- passwordstring[9]=0x46;
- passwordstring[10]=0x54;
- passwordstring[11]=0x23;
- passwordstring[12]=0x1c;
-}
-#endif
-
-//******************************************************************************
-//
-// DeleteSoundFile ()
-//
-//******************************************************************************
-void DeleteSoundFile ( void )
-{
- char filename[ 128 ];
-
- GetPathFromEnvironment( filename, ApogeePath, SoundName );
- unlink (filename); // Delete SOUND.ROT
-}
-
-//******************************************************************************
-//
-// ReadConfig ()
-//
-//******************************************************************************
-
-
-void ReadConfig (void)
-{
- char filename[ 128 ];
-
- GetPathFromEnvironment( filename, ApogeePath, SoundName );
- SetSoundDefaultValues ();
-
- if (access (filename, F_OK) == 0)
- {
- LoadScriptFile (filename);
-
- if (ParseSoundFile () == false)
- {
- DeleteSoundFile();
- }
-
- Z_Free (scriptbuffer);
- }
-#ifdef DOS
- else if ( !SOUNDSETUP )
- {
- Error( "Could not find SOUND.ROT. Please run SNDSETUP to configure "
- "your sound hardware." );
- }
-#endif
-
-
-#ifdef _ROTT_
- ReadScores();
-
- GetPathFromEnvironment( filename, ApogeePath, ConfigName );
- SetConfigDefaultValues ();
- if (access(filename,F_OK)==0)
- {
- LoadScriptFile(filename);
-
- if (ParseConfigFile () == false)
- {
- unlink (filename); // Delete CONFIG.ROT
- }
-
- Z_Free(scriptbuffer);
- }
-
- GetPathFromEnvironment( filename, ApogeePath, BattleName );
- SetBattleDefaultValues ();
- if (access(filename,F_OK)==0)
- {
- LoadScriptFile(filename);
-
- if (ParseBattleFile() == false)
- {
- unlink (filename); // Delete BATTLE.ROT
- }
-
- Z_Free(scriptbuffer);
- }
-#endif
- ConfigLoaded = true;
-}
-
-//******************************************************************************
-//
-// CheckVendor ()
-//
-//******************************************************************************
-
-#if (SHAREWARE==1)
-#define VENDORDOC ("VENDOR.DOC")
-#define VENDORLUMP ("VENDOR")
-#else
-#define VENDORDOC ("LICENSE.DOC")
-#define VENDORLUMP ("LICENSE")
-#endif
-
-void CheckVendor (void)
-{
- boolean saveout=false;
- int wadcrc;
- int filecrc;
- int size;
- int lump;
- byte * vendor;
- char filename[ 128 ];
-
- GetPathFromEnvironment( filename, ApogeePath, VENDORDOC );
- if (access (filename, F_OK) == 0)
- {
- size = LoadFile(filename,(void **)&vendor);
- filecrc = CalculateCRC (vendor, size);
- SafeFree(vendor);
- lump=W_GetNumForName(VENDORLUMP);
- vendor = W_CacheLumpNum(lump,PU_CACHE, CvtNull, 1);
- size=W_LumpLength(lump);
- wadcrc = CalculateCRC (vendor, size);
- if (wadcrc != filecrc)
- saveout=true;
- }
- else
- saveout=true;
-
- if (saveout==true)
- {
- lump=W_GetNumForName(VENDORLUMP);
- vendor = W_CacheLumpNum(lump,PU_CACHE, CvtNull, 1);
- size = W_LumpLength(lump);
- SaveFile (filename,vendor,size);
- }
-}
-
-//******************************************************************************
-//
-// WriteParameter
-//
-//******************************************************************************
-
-void WriteParameter (int file, const char * s1, int val)
-{
- char s[50];
-
- // Write out Header
- SafeWriteString (file, (char *)s1);
-
- // Write out space character
- strcpy (&s[0],(const char *)" ");
- SafeWriteString (file, &s[0]);
-
- // Write out value
- itoa(val,&s[0],10);
- SafeWriteString (file, &s[0]);
-
- // Write out EOL character
- strcpy (&s[0],(const char *)"\n");
- SafeWriteString (file, &s[0]);
-}
-
-
-//******************************************************************************
-//
-// WriteParameterHex
-//
-//******************************************************************************
-
-void WriteParameterHex (int file, const char * s1, int val)
-{
- char s[50];
-
- // Write out Header
- SafeWriteString (file, (char *)s1);
-
- // Write out space character
- strcpy (&s[0],(const char *)" $");
- SafeWriteString (file, &s[0]);
-
- // Write out value
- itoa(val,&s[0],16);
- SafeWriteString (file, &s[0]);
-
- // Write out EOL character
- strcpy (&s[0],(const char *)"\n");
- SafeWriteString (file, &s[0]);
-}
-
-
-
-#ifdef _ROTT_
-
-//******************************************************************************
-//
-// WriteScores ()
-//
-//******************************************************************************
-
-void WriteScores (void)
-{
- int file;
- char filename[ 128 ];
-
- GetPathFromEnvironment( filename, ApogeePath, ScoresName );
- file=SafeOpenWrite( filename );
- SafeWrite (file, &Scores, sizeof (Scores));
- close(file);
-}
-
-
-//******************************************************************************
-//
-// WriteBattleConfig ()
-//
-//******************************************************************************
-
-void WriteBattleConfig
-(
- void
-)
-
-{
- int file;
- int index;
- char filename[ 128 ];
- extern specials BattleSpecialsTimes;
-
- // Write Battle File
- GetPathFromEnvironment( filename, ApogeePath, BattleName );
- file = open( filename, O_RDWR | O_TEXT | O_CREAT | O_TRUNC,
- S_IREAD | S_IWRITE );
-
- if ( file == -1 )
- {
- Error( "Error opening %s: %s", filename, strerror( errno ) );
- }
-
- // Write out BATTLECONFIG header
- SafeWriteString( file,
- ";Rise of the Triad Battle Configuration File\n"
- "; (c) 1995\n"
- ";\n"
- ";You may change these options at you own risk. Using any values\n"
- ";other than the ones documented may make the game unplayable.\n"
- ";If this happens, you may delete this file (BATTLE.ROT) and ROTT\n"
- ";will recreate it with the default values selected.\n"
- ";\n"
- ";With that in mind, have fun!\n"
- ";\n"
- "\n" );
-
- // Write out Version
- WriteParameter( file, "Version ", ROTTVERSION );
-
- // Write out BATTLE_ShowKillPics
- SafeWriteString(file, "\n;\n");
- WriteParameter( file, "; Yes - ", 1 );
- WriteParameter( file, "; No - ", 0 );
- WriteParameter( file, "ShowKillCount ", BATTLE_ShowKillCount );
-
- // Write out specials' times
- SafeWriteString(file, "\n;\n"
- "; These are the time in seconds of the various powerups.\n"
- "; You could modify these to give you infinite Mercury mode,\n"
- "; stronger vests, or to make them persistent.\n;\n" );
-
- WriteParameter( file, "GodModeTime ", BattleSpecialsTimes.GodModeTime );
- WriteParameter( file, "DogModeTime ", BattleSpecialsTimes.DogModeTime );
- WriteParameter( file, "ShroomsModeTime ", BattleSpecialsTimes.ShroomsModeTime );
- WriteParameter( file, "ElastoModeTime ", BattleSpecialsTimes.ElastoModeTime );
- WriteParameter( file, "AsbestosVestTime ", BattleSpecialsTimes.AsbestosVestTime );
- WriteParameter( file, "BulletProofVestTime ", BattleSpecialsTimes.BulletProofVestTime );
- WriteParameter( file, "GasMaskTime ", BattleSpecialsTimes.GasMaskTime );
- WriteParameter( file, "MercuryModeTime ", BattleSpecialsTimes.MercuryModeTime );
- WriteParameter( file, "GodModeRespawnTime ", BattleSpecialsTimes.GodModeRespawnTime );
- WriteParameter( file, "DogModeRespawnTime ", BattleSpecialsTimes.DogModeRespawnTime );
- WriteParameter( file, "ShroomsModeRespawnTime ", BattleSpecialsTimes.ShroomsModeRespawnTime );
- WriteParameter( file, "ElastoModeRespawnTime ", BattleSpecialsTimes.ElastoModeRespawnTime );
- WriteParameter( file, "AsbestosVestRespawnTime ", BattleSpecialsTimes.AsbestosVestRespawnTime );
- WriteParameter( file, "BulletProofVestRespawnTime ", BattleSpecialsTimes.BulletProofVestRespawnTime );
- WriteParameter( file, "GasMaskRespawnTime ", BattleSpecialsTimes.GasMaskRespawnTime );
- WriteParameter( file, "MercuryModeRespawnTime ", BattleSpecialsTimes.MercuryModeRespawnTime );
-
- // Write out battlegibs
- SafeWriteString(file, "\n;\n");
- WriteParameter( file, "; Yes - ", 1 );
- WriteParameter( file, "; No - ", 0 );
- WriteParameter( file, "EKG ", battlegibs );
-
- // Describe options
-
- // Write out Gravity
- SafeWriteString(file, "\n"
- ";\n"
- "; Here is a description of the possible values for"
- " each option:\n"
- ";\n"
- "; Gravity options:\n" );
- WriteParameter( file, "; Low Gravity - ", LOW_GRAVITY );
- WriteParameter( file, "; Normal Gravity - ", NORMAL_GRAVITY );
- WriteParameter( file, "; High Gravity - ", HIGH_GRAVITY );
-
- // Write out Speed
- SafeWriteString(file, ";\n"
- "; Speed options:\n" );
- WriteParameter( file, "; Normal Speed - ", bo_normal_speed );
- WriteParameter( file, "; Fast Speed - ", bo_fast_speed );
-
- // Write out Ammo
- SafeWriteString(file, ";\n"
- "; Ammo options:\n" );
- WriteParameter( file, "; One Shot - ", bo_one_shot );
- WriteParameter( file, "; Normal Shots - ", bo_normal_shots );
- WriteParameter( file, "; Infinite Shots - ", bo_infinite_shots );
-
- // Write out Hit Points
- SafeWriteString(file, ";\n"
- "; Hitpoint options:\n" );
- WriteParameter( file, "; Character Hitpoints - ", bo_character_hitpoints );
- WriteParameter( file, "; 1 Hitpoint - ", 1 );
- WriteParameter( file, "; 25 Hitpoints - ", 25 );
- WriteParameter( file, "; 100 Hitpoints - ", 100 );
- WriteParameter( file, "; 500 Hitpoints - ", 500 );
- WriteParameter( file, "; 250 Hitpoints - ", 250 );
- WriteParameter( file, "; 4000 Hitpoints - ", 4000 );
-
- // Write out Danger Spawning
- SafeWriteString(file, ";\n"
- "; SpawnDangers options:\n"
- "; Spawn Dangers - 1\n"
- "; Don't Spawn Dangers - 0\n" );
-
- // Write out Health Spawning
- SafeWriteString(file, ";\n"
- "; SpawnHealth options:\n"
- "; Spawn Health - 1\n"
- "; Don't Spawn Health - 0\n" );
-
- // Write out Mine Spawning
- SafeWriteString(file, ";\n"
- "; SpawnMines options:\n"
- "; Spawn Mines - 1\n"
- "; Don't Spawn Mines - 0\n" );
-
- // Write out Weapon Spawning
- SafeWriteString(file, ";\n"
- "; SpawnWeapons options:\n"
- "; Spawn Weapons - 1\n"
- "; Don't Spawn Weapons - 0\n" );
-
- // Write out Random Weapons
- SafeWriteString(file, ";\n"
- "; RandomWeapons options:\n"
- "; Randomize Weapons - 1\n"
- "; Don't Randomize Weapons - 0\n" );
-
- // Write out Weapon Persistence
- SafeWriteString(file, ";\n"
- "; WeaponPersistence options:\n"
- "; Weapons Persist - 1\n"
- "; Weapons don't Persist - 0\n" );
-
- // Write out Friendly Fire
- SafeWriteString(file, ";\n"
- "; FriendlyFire options:\n"
- "; Penalize Friendly Fire - 1\n"
- "; No penalty - 0\n" );
-
- // Write out Respawn Items
- SafeWriteString(file, ";\n"
- "; RespawnItems options:\n"
- "; Respawn Items - 1\n"
- "; Don't Respawn Items - 0\n" );
-
- // Write out Light Level
- SafeWriteString(file, ";\n"
- "; LightLevel options:\n" );
- WriteParameter( file, "; Dark - ", bo_light_dark );
- WriteParameter( file, "; Normal Light Levels - ", bo_light_normal );
- WriteParameter( file, "; Bright - ", bo_light_bright );
- WriteParameter( file, "; Fog - ", bo_light_fog );
- WriteParameter( file, "; Periodic light - ", bo_light_periodic );
- WriteParameter( file, "; Lightning - ", bo_light_lightning );
-
- // Write out Point Goal
- SafeWriteString(file, ";\n"
- "; PointGoal options:\n" );
- WriteParameter( file, "; 1 Point - ", 1 );
- WriteParameter( file, "; 5 Points - ", 5 );
- WriteParameter( file, "; 11 Points - ", 11 );
- WriteParameter( file, "; 21 Points - ", 21 );
- WriteParameter( file, "; 50 Points - ", 50 );
- WriteParameter( file, "; 100 Points - ", 100 );
- WriteParameter( file, "; Random Points - ", bo_kills_random );
- WriteParameter( file, "; Blind Points - ", bo_kills_blind );
- WriteParameter( file, "; Infinite Points - ", bo_kills_infinite );
-
- // Write out Danger Damage
- SafeWriteString(file, ";\n"
- "; DangerDamage options:\n" );
- WriteParameter( file, "; Normal Damage - ", bo_danger_normal );
- WriteParameter( file, "; Low Damage - ", bo_danger_low );
- WriteParameter( file, "; Kill - ", bo_danger_kill );
-
- // Write out TimeLimit
- SafeWriteString(file, ";\n"
- "; TimeLimit options:\n" );
- WriteParameter( file, "; 1 minute - ", 1 );
- WriteParameter( file, "; 2 minute - ", 2 );
- WriteParameter( file, "; 5 minutes - ", 5 );
- WriteParameter( file, "; 10 minutes - ", 10 );
- WriteParameter( file, "; 21 minutes - ", 21 );
- WriteParameter( file, "; 30 minutes - ", 30 );
- WriteParameter( file, "; 99 minutes - ", 99 );
- WriteParameter( file, "; No limit - ", bo_time_infinite );
-
- // Write out RespawnTime
- SafeWriteString(file, ";\n"
- "; RespawnTime options:\n" );
- WriteParameter( file, "; 1 second - ", 1 );
- WriteParameter( file, "; 1 minute - ", 60 );
- WriteParameter( file, "; 2 minutes - ", 120 );
- WriteParameter( file, "; normal - ", bo_normal_respawn_time );
-
- for( index = battle_Normal; index < battle_NumBattleModes; index++ )
- {
- SafeWriteString(file, "\n;\n");
- switch( index )
- {
- case battle_Normal :
- SafeWriteString( file, "; Standard battle options\n;\n" );
- break;
-
- case battle_ScoreMore :
- SafeWriteString( file, "; Score More battle options\n;\n" );
- break;
-
- case battle_Collector :
- SafeWriteString( file, "; Collector battle options\n;\n" );
- break;
-
- case battle_Scavenger :
- SafeWriteString( file, "; Scavenger battle options\n;\n" );
- break;
-
- case battle_Hunter :
- SafeWriteString( file, "; Hunter battle options\n;\n" );
- break;
-
- case battle_Tag :
- SafeWriteString( file, "; Tag battle options\n;\n" );
- break;
-
- case battle_Eluder :
- SafeWriteString( file, "; Eluder battle options\n;\n" );
- break;
-
- case battle_Deluder :
- SafeWriteString( file, "; Deluder battle options\n;\n" );
- break;
-
- case battle_CaptureTheTriad :
- SafeWriteString( file, "; Capture the Triad battle options\n;\n" );
- break;
- }
-
- // Write out Gravity
- WriteParameter( file, "Gravity ",
- BATTLE_Options[ index ].Gravity );
-
- // Write out Speed
- WriteParameter( file, "Speed ",
- BATTLE_Options[ index ].Speed );
-
- if ( ( index != battle_Collector ) && ( index != battle_Tag ) &&
- ( index != battle_Eluder ) )
- {
- // Write out Ammo
- WriteParameter( file, "Ammo ",
- BATTLE_Options[ index ].Ammo );
- }
-
- if ( index != battle_Eluder )
- {
- // Write out Hit Points
- WriteParameter( file, "Hitpoints ",
- BATTLE_Options[ index ].HitPoints );
- }
-
- // Write out Danger Spawning
- WriteParameter( file, "SpawnDangers ",
- BATTLE_Options[ index ].SpawnDangers );
-
- if ( index != battle_Eluder )
- {
- // Write out Health Spawning
- WriteParameter( file, "SpawnHealth ",
- BATTLE_Options[ index ].SpawnHealth );
-
- // Write out Mine Spawning
- WriteParameter( file, "SpawnMines ",
- BATTLE_Options[ index ].SpawnMines );
- }
-
- if ( ( index != battle_Collector ) && ( index != battle_Tag ) &&
- ( index != battle_Eluder ) )
- {
- // Write out Weapon Spawning
- WriteParameter( file, "SpawnWeapons ",
- BATTLE_Options[ index ].SpawnWeapons );
-
- // Write out Random Weapons
- WriteParameter( file, "RandomWeapons ",
- BATTLE_Options[ index ].RandomWeapons );
-
- // Write out Weapon Persistence
- WriteParameter( file, "WeaponPersistence",
- BATTLE_Options[ index ].WeaponPersistence );
- }
-
- if ( ( index == battle_Normal ) || ( index == battle_ScoreMore ) ||
- ( index == battle_Hunter ) || ( index == battle_Tag ) )
- {
- // Write out Friendly Fire
- WriteParameter( file, "FriendlyFire ",
- BATTLE_Options[ index ].FriendlyFire );
- }
-
- if ( index != battle_Eluder )
- {
- // Write out Respawn Items
- WriteParameter( file, "RespawnItems ",
- BATTLE_Options[ index ].RespawnItems );
- }
-
- // Write out Light Level
- WriteParameter( file, "LightLevel ",
- BATTLE_Options[ index ].LightLevel );
-
- if ( ( index != battle_Collector ) && ( index != battle_Scavenger ) )
- {
- // Write out Point Goal
- WriteParameter( file, "PointGoal ",
- BATTLE_Options[ index ].Kills );
- }
-
- if ( index != battle_Eluder )
- {
- // Write out Danger Damage
- WriteParameter( file, "DangerDamage ",
- BATTLE_Options[ index ].DangerDamage );
- }
-
- // Write out TimeLimit
- WriteParameter( file, "TimeLimit ",
- BATTLE_Options[ index ].TimeLimit );
-
- // Write out RespawnTime
- WriteParameter( file, "RespawnTime ",
- BATTLE_Options[ index ].RespawnTime );
- }
-
- close( file );
-}
-
-#endif
-
-//******************************************************************************
-//
-// WriteSoundConfig ()
-//
-//******************************************************************************
-
-void WriteSoundConfig
-(
- void
-)
-
-{
- int file;
- char filename[ 128 ];
-
- if ( !WriteSoundFile )
- {
- return;
- }
-
- GetPathFromEnvironment( filename, ApogeePath, SoundName );
- file = open ( filename, O_RDWR | O_TEXT | O_CREAT | O_TRUNC,
- S_IREAD | S_IWRITE);
-
- if (file == -1)
- Error ("Error opening %s: %s", filename, strerror(errno));
-
- // Write out ROTTSOUND header
-
- SafeWriteString (file, ";Rise of the Triad Sound File\n");
- SafeWriteString (file, "; (c) 1995\n\n");
-
- // Write out Version
-
- WriteParameter(file,"Version ",ROTTVERSION);
-
- // Write out Music Mode
-
- SafeWriteString(file,"\n;\n");
- SafeWriteString(file,"; Music Modes\n");
- SafeWriteString(file,"; 0 - Off\n");
-#ifdef DOS
- SafeWriteString(file,"; 1 - UltraSound\n");
- SafeWriteString(file,"; 2 - Sound Blaster\n");
- SafeWriteString(file,"; 3 - Sound Man 16\n");
- SafeWriteString(file,"; 4 - Pro Audio Spectrum\n");
- SafeWriteString(file,"; 5 - Awe32\n");
- SafeWriteString(file,"; 6 - SoundScape\n");
- SafeWriteString(file,"; 7 - Wave Blaster\n");
- SafeWriteString(file,"; 8 - General Midi\n");
- SafeWriteString(file,"; 9 - Sound Canvas\n");
- SafeWriteString(file,"; 10 - Adlib\n");
-#else
- SafeWriteString(file,"; 6 - On\n");
-#endif
- WriteParameter(file,"MusicMode ",MusicMode);
-
- // Write out FX Mode
-
- SafeWriteString(file,"\n;\n");
- SafeWriteString(file,"; FX Modes\n");
- SafeWriteString(file,"; 0 - Off\n");
-#ifdef DOS
- SafeWriteString(file,"; 1 - UltraSound\n");
- SafeWriteString(file,"; 2 - Sound Blaster\n");
- SafeWriteString(file,"; 3 - Sound Man 16\n");
- SafeWriteString(file,"; 4 - Pro Audio Spectrum\n");
- SafeWriteString(file,"; 5 - Awe32\n");
- SafeWriteString(file,"; 6 - SoundScape\n");
- SafeWriteString(file,"; 7 - Adlib\n");
- SafeWriteString(file,"; 8 - Disney Sound Source\n");
- SafeWriteString(file,"; 9 - Tandy Sound Source\n");
- SafeWriteString(file,"; 10 - PC Speaker\n");
-#else
- SafeWriteString(file,"; 6 - On\n");
-#endif
- WriteParameter(file,"FXMode ",FXMode);
-
- // Write in Music Volume
-
- SafeWriteString(file,"\n;\n");
- SafeWriteString(file,"; Music Volume\n");
- SafeWriteString(file,"; (low) 0 - 255 (high)\n");
- WriteParameter (file, "MusicVolume ", MUvolume);
-
- // Write in FX Volume
-
- SafeWriteString(file,"\n;\n");
- SafeWriteString(file,"; FX Volume\n");
- SafeWriteString(file,"; (low) 0 - 255 (high)\n");
- WriteParameter (file, "FXVolume ", FXvolume);
-
- // Write out numvoices
-
- SafeWriteString(file,"\n;\n");
- SafeWriteString(file,"; Number of Voices\n");
- SafeWriteString(file,"; 1 - 8\n");
- WriteParameter(file,"NumVoices ",NumVoices);
-
- // Write out numchannels
-
- SafeWriteString(file,"\n;\n");
- SafeWriteString(file,"; Stereo or Mono\n");
- SafeWriteString(file,"; 1 - Mono\n");
- SafeWriteString(file,"; 2 - Stereo\n");
- WriteParameter(file,"NumChannels ",NumChannels);
-
- // Write out numbits
-
- SafeWriteString(file,"\n;\n");
- SafeWriteString(file,"; Resolution\n");
- SafeWriteString(file,"; 8 bit\n");
- SafeWriteString(file,"; 16 bit\n");
- WriteParameter(file,"NumBits ",NumBits);
-
-#ifdef DOS
- // Write out Midi Address
-
- SafeWriteString(file,"\n;\n");
- SafeWriteString(file,"; Midi Addresses\n");
- SafeWriteString(file,"; $300\n");
- SafeWriteString(file,"; $310\n");
- SafeWriteString(file,"; $320\n");
- SafeWriteString(file,"; $330\n");
- SafeWriteString(file,"; $340\n");
- SafeWriteString(file,"; $350\n");
- SafeWriteString(file,"; $360\n");
- SafeWriteString(file,"; $370\n");
- SafeWriteString(file,"; $380\n");
- WriteParameterHex(file,"MidiAddress ",MidiAddress);
-#endif
-
- // Write out stereo reversal
-
- SafeWriteString(file,"\n;\n");
- SafeWriteString(file,"; ReverseStereo\n");
- SafeWriteString(file,"; 0 no reversal\n");
- SafeWriteString(file,"; 1 reverse stereo\n");
- WriteParameter (file,"StereoReverse ",stereoreversed);
-
-#ifdef DOS
- // Write out Sound Blaster info
-
- SafeWriteString(file,"\n;\n");
- SafeWriteString(file,"; Sound Blaster Settings\n");
- WriteParameter(file, "SBType ", SBSettings.Type );
- WriteParameterHex(file, "SBPort ", SBSettings.Address );
- WriteParameter(file, "SBIrq ", SBSettings.Interrupt );
- WriteParameter(file, "SBDma8 ", SBSettings.Dma8 );
- WriteParameter(file, "SBDma16 ", SBSettings.Dma16 );
- WriteParameterHex(file, "SBMidi ", SBSettings.Midi );
- WriteParameterHex(file, "SBEmu ", SBSettings.Emu );
-#endif
-
- close (file);
-}
-
-
-//******************************************************************************
-//
-// WriteConfig ()
-//
-//******************************************************************************
-
-void WriteConfig (void)
-{
- int file;
- char filename[ 128 ];
- char passwordtemp[50];
- static int inconfig = 0;
-
- if (inconfig > 0)
- return;
-
- inconfig++ ;
-
- if ( !ConfigLoaded )
- {
- return;
- }
-
- // Write Sound File
- WriteSoundConfig();
-
- // Write Config, Battle and Score files
-#ifdef _ROTT_
- WriteScores();
- WriteBattleConfig();
-
- GetPathFromEnvironment( filename, ApogeePath, ConfigName );
- file = open( filename,O_RDWR | O_TEXT | O_CREAT | O_TRUNC
- , S_IREAD | S_IWRITE);
-
- if (file == -1)
- Error ("Error opening %s: %s",filename,strerror(errno));
-
- // Write out ROTTCONFIG header
-
- SafeWriteString (file, ";Rise of the Triad Configuration File\n");
- SafeWriteString (file, "; (c) 1995\n\n");
-
- // Write out Version
-
- WriteParameter(file,"Version ",ROTTVERSION);
-
- //Write out AllowBlitzguardMoreMissileWeps
-
- SafeWriteString(file,"\n;\n");
- SafeWriteString(file, "; 1 - Allows Blitzguards to have Random Missile weapons\n");
- SafeWriteString(file, "; 0 - Disallows the above (ROTT Default)\n");
- WriteParameter(file, "AllowBlitzguardMoreMissileWeps ", allowBlitzMoreMissileWeps);
-
- //Write out enableAmmoPickups
-
- SafeWriteString(file,"\n;\n");
- SafeWriteString(file, "; 1 - Allows players to refill their missile weapons by running over one a matching one on the ground\n");
- SafeWriteString(file, "; 0 - Disables the above (ROTT default)\n");
- WriteParameter(file, "EnableAmmoPickups ", enableAmmoPickups);
-
- //Write out autoAim
-
- SafeWriteString(file, "\n;\n");
- SafeWriteString(file, "; 1 - Bullet weapons will automatically target enemies. (ROTT default)\n");
- SafeWriteString(file, "; 0 - Disables the above.\n");
- WriteParameter(file, "AutoAim ", autoAim);
-
- //Write out autoAimMissileWeps
-
- SafeWriteString(file, "\n;\n");
- SafeWriteString(file, "; 1 - Missile weapons will be automatically aimed at targets like bullet weapons.\n");
- SafeWriteString(file, "; 0 - Missile weapons are not automatically aimed at targets. (ROTT default)\n");
- WriteParameter(file, "AutoAimMissileWeps ", autoAimMissileWeps);
-
- // Write out MouseEnabled
-
- SafeWriteString(file,"\n;\n");
- SafeWriteString(file,"; 1 - Mouse Enabled\n");
- SafeWriteString(file,"; 0 - Mouse Disabled\n");
- WriteParameter(file,"MouseEnabled ",mouseenabled);
-
- // Write out UseMouseLook
- SafeWriteString(file,"\n;\n");
- SafeWriteString(file,"; 1 - UseMouseLook Enabled\n");
- SafeWriteString(file,"; 0 - UseMouseLook Disabled\n");
- WriteParameter(file,"UseMouseLook ",usemouselook);
-
- // Write out InverseMouse
- SafeWriteString(file,"\n;\n");
- SafeWriteString(file,"; 1 - Normal Mouse Enabled\n");
- SafeWriteString(file,"; -1 - Inverse Mouse Enabled\n");
- WriteParameter(file,"InverseMouse ",inverse_mouse);
-
- // Write out UseJump
- SafeWriteString(file,"\n;\n");
- SafeWriteString(file,"; 1 - usejump Enabled\n");
- SafeWriteString(file,"; 0 - usejump Disabled\n");
- WriteParameter(file,"UseJump ",usejump);
-
- // Write out CrossHair
- SafeWriteString(file,"\n;\n");
- SafeWriteString(file,"; 1 - CrossHair Enabled\n");
- SafeWriteString(file,"; 0 - CrossHair Disabled\n");
- WriteParameter(file,"CrossHair ", iG_aimCross);
-
- // Write out JoystickEnabled
-
- SafeWriteString(file,"\n;\n");
- SafeWriteString(file,"; 1 - Joystick Enabled\n");
- SafeWriteString(file,"; 0 - Joystick Disabled\n");
- WriteParameter(file,"JoystickEnabled ",joystickenabled);
-
- // Write out JoypadEnabled
-
- SafeWriteString(file,"\n;\n");
- SafeWriteString(file,"; 1 - Joypad Enabled\n");
- SafeWriteString(file,"; 0 - Joypad Disabled\n");
- WriteParameter(file,"JoypadEnabled ",joypadenabled);
-
- // Write out JoystickPort
-
- SafeWriteString(file,"\n;\n");
- SafeWriteString(file,"; 0 - Use Joystick Port 1\n");
- SafeWriteString(file,"; 1 - Use Joystick Port 2\n");
- WriteParameter(file,"JoystickPort ",joystickport);
-
- // Write out fullscreen
- SafeWriteString(file,"\n;\n");
- SafeWriteString(file,"; 0 - Start in windowed mode\n");
- SafeWriteString(file,"; 1 - Start in fullscreen mode\n");
- WriteParameter(file,"FullScreen ",sdl_fullscreen);
-
- // Write out resolution
- SafeWriteString(file,"\n;\n");
- SafeWriteString(file,"; Screen Resolution, supported resolutions: \n");
- SafeWriteString(file,"; 320x200, 640x480 and 800x600\n");
- WriteParameter(file,"ScreenWidth ",iGLOBAL_SCREENWIDTH);
- WriteParameter(file,"ScreenHeight ",iGLOBAL_SCREENHEIGHT);
-
- // Write out ViewSize
-
- SafeWriteString(file,"\n;\n");
- SafeWriteString(file,"; Size of View port.\n");
- SafeWriteString(file,"; (smallest) 0 - 10 (largest)\n");
- WriteParameter(file,"ViewSize ",viewsize);
-
- // Write out WEAPONSCALE bna added
-
- SafeWriteString(file,"\n;\n");
- SafeWriteString(file,"; Size of Weaponscale.\n");
- SafeWriteString(file,"; (smallest) 150 - 600 (largest)\n");
- G_weaponscale = (weaponscale * 168 )/65536;
-
- if ((G_weaponscale <150)||(G_weaponscale>600)) {
- if (iGLOBAL_SCREENWIDTH == 320) {
- G_weaponscale=168;
- } else if (iGLOBAL_SCREENWIDTH == 640) {
- G_weaponscale=299;
- } else if (iGLOBAL_SCREENWIDTH == 800) {
- G_weaponscale=376;
- }
- }
- WriteParameter(file,"Weaponscale ",G_weaponscale);
-
-
- // Write out MouseAdjustment
-
- SafeWriteString(file,"\n;\n");
- SafeWriteString(file,"; Sensitivity of Mouse\n");
- SafeWriteString(file,"; (lowest) 0 - 11 (highest)\n");
- WriteParameter(file,"MouseAdjustment ",mouseadjustment);
-
- // Write out threshold
-
- SafeWriteString(file,"\n;\n");
- SafeWriteString(file,"; Threshold of Mouse and Joystick\n");
- SafeWriteString(file,"; (smallest) 1 - 15 (largest)\n");
- WriteParameter(file,"Threshold ",threshold);
-
- // Write in Cyberman Enabled
-
-// SafeWriteString(file,"\n;\n");
-// SafeWriteString(file,"; 1 - Cyberman Enabled\n");
-// SafeWriteString(file,"; 0 - Cyberman Disabled\n");
-// WriteParameter(file,"CybermanEnabled ",cybermanenabled);
-
- // Write in Spaceball Enabled
-
-// SafeWriteString(file,"\n;\n");
-// SafeWriteString(file,"; 1 - Spaceball Enabled\n");
-// SafeWriteString(file,"; 0 - Spaceball Disabled\n");
-// WriteParameter(file,"SpaceballEnabled ",spaceballenabled);
-
- // Write in Auto Detail
-
- SafeWriteString(file,"\n;\n");
- SafeWriteString(file,"; 1 - Auto Detail on\n");
- SafeWriteString(file,"; 0 - Auto Detail off\n");
- WriteParameter (file,"AutoDetail ", AutoDetailOn);
-
- // Write in Light Dim
-
- SafeWriteString(file,"\n;\n");
- SafeWriteString(file,"; 1 - Light Diminishing on\n");
- SafeWriteString(file,"; 0 - Light Diminishing off\n");
- WriteParameter (file,"LightDim ", fulllight);
-
- // Write in Bobbin' On
-
- SafeWriteString(file,"\n;\n");
- SafeWriteString(file,"; 1 - Bobbing on\n");
- SafeWriteString(file,"; 0 - Bobbing off\n");
- WriteParameter (file,"BobbingOn ", BobbinOn);
-
- // Write in Double Click Speed
-
- SafeWriteString(file,"\n;\n");
- SafeWriteString(file,"; (slowest) 50 - 5 (fastest)\n");
- WriteParameter (file,"DoubleClickSpeed ", DoubleClickSpeed);
-
- // Write in Menu Flip Speed
-
- SafeWriteString(file,"\n;\n");
- SafeWriteString(file,"; Menu Flip Speed\n");
- SafeWriteString(file,"; (slowest) 100 - 5 (fastest)\n");
- WriteParameter (file,"MenuFlipSpeed ", Menuflipspeed);
-
- // Write in Detail Level
-
- SafeWriteString(file,"\n;\n");
- SafeWriteString(file,"; 0 - Detail Level Low\n");
- SafeWriteString(file,"; 1 - Detail Level Medium\n");
- SafeWriteString(file,"; 2 - Detail Level High\n");
- WriteParameter (file,"DetailLevel ", DetailLevel);
-
- // Write in Floor and Ceiling
-
- SafeWriteString(file,"\n;\n");
- SafeWriteString(file,"; 1 - Floor and Ceiling on\n");
- SafeWriteString(file,"; 0 - Floor and Ceiling off\n");
- WriteParameter (file,"FloorCeiling ", fandc);
-
- // Write in DisableMessages
-
- SafeWriteString(file,"\n;\n");
- SafeWriteString(file,"; 1 - Messages on\n");
- SafeWriteString(file,"; 0 - Messages off\n");
- WriteParameter (file,"Messages ", MessagesEnabled );
-
- // Write in AutoRun
-
- SafeWriteString(file,"\n;\n");
- SafeWriteString(file,"; 1 - AutoRun on\n");
- SafeWriteString(file,"; 0 - AutoRun off\n");
- WriteParameter (file,"AutoRun ", gamestate.autorun );
-
- // Write in GammaIndex
-
- SafeWriteString(file,"\n;\n");
- SafeWriteString(file,"; 0 - Gamma Correction level 1\n");
- SafeWriteString(file,"; 1 - Gamma Correction level 2\n");
- SafeWriteString(file,"; 2 - Gamma Correction level 3\n");
- SafeWriteString(file,"; 3 - Gamma Correction level 4\n");
- SafeWriteString(file,"; 4 - Gamma Correction level 5\n");
- WriteParameter (file,"GammaIndex ", gammaindex);
-
- // Write out screen saver time
- SafeWriteString(file,"\n;\n");
- SafeWriteString(file,"; Minutes before screen blanking\n");
- WriteParameter (file,"BlankTime ", blanktime/(VBLCOUNTER*60));
-
-
- // Write out keys
-
- SafeWriteString(file,"\n;\n");
- SafeWriteString(file,"; Scan codes for keyboard buttons\n");
- WriteParameter (file,"Fire ", buttonscan[0]);
- WriteParameter (file,"Strafe ", buttonscan[1]);
- WriteParameter (file,"Run ", buttonscan[2]);
- WriteParameter (file,"Use ", buttonscan[3]);
- WriteParameter (file,"LookUp ", buttonscan[4]);
- WriteParameter (file,"LookDn ", buttonscan[5]);
- WriteParameter (file,"Swap ", buttonscan[6]);
- WriteParameter (file,"Drop ", buttonscan[7]);
- WriteParameter (file,"TargetUp ", buttonscan[8]);
- WriteParameter (file,"TargetDn ", buttonscan[9]);
- WriteParameter (file,"SelPistol ", buttonscan[10]);
- WriteParameter (file,"SelDualPistol ", buttonscan[11]);
- WriteParameter (file,"SelMP40 ", buttonscan[12]);
- WriteParameter (file,"SelMissile ", buttonscan[13]);
- WriteParameter (file,"AutoRun ", buttonscan[14]);
- WriteParameter (file,"LiveRemRid ", buttonscan[15]);
- WriteParameter (file,"StrafeLeft ", buttonscan[16]);
- WriteParameter (file,"StrafeRight ", buttonscan[17]);
- WriteParameter (file,"VolteFace ", buttonscan[18]);
- WriteParameter (file,"Aim ", buttonscan[19]);
- WriteParameter (file,"Forward ", buttonscan[20]);
- WriteParameter (file,"Right ", buttonscan[21]);
- WriteParameter (file,"Backward ", buttonscan[22]);
- WriteParameter (file,"Left ", buttonscan[23]);
- WriteParameter (file,"Map ", buttonscan[24]);
- WriteParameter (file,"SendMessage ", buttonscan[25]);
- WriteParameter (file,"DirectMessage ", buttonscan[26]);
-
- SafeWriteString(file,"\n;\n");
- SafeWriteString(file,"; Mouse buttons\n");
-
- WriteParameter (file,"MouseButton0 ", buttonmouse[0]);
- WriteParameter (file,"MouseButton1 ", buttonmouse[1]);
- WriteParameter (file,"MouseButton2 ", buttonmouse[2]);
- WriteParameter (file,"DblClickB0 ", buttonmouse[3]);
- WriteParameter (file,"DblClickB1 ", buttonmouse[4]);
- WriteParameter (file,"DblClickB2 ", buttonmouse[5]);
-
- SafeWriteString(file,"\n;\n");
- SafeWriteString(file,"; Joystick buttons\n");
-
- WriteParameter (file,"JoyButton0 ", buttonjoy[0]);
- WriteParameter (file,"JoyButton1 ", buttonjoy[1]);
- WriteParameter (file,"JoyButton2 ", buttonjoy[2]);
- WriteParameter (file,"JoyButton3 ", buttonjoy[3]);
- WriteParameter (file,"DblClickJB0 ", buttonjoy[4]);
- WriteParameter (file,"DblClickJB1 ", buttonjoy[5]);
- WriteParameter (file,"DblClickJB2 ", buttonjoy[6]);
- WriteParameter (file,"DblClickJB3 ", buttonjoy[7]);
-
- SafeWriteString(file,"\n;\n");
- SafeWriteString(file,"; Joystick calibration coordinates\n");
-
- WriteParameter (file,"JoyMaxX ", joyxmax);
- WriteParameter (file,"JoyMaxY ", joyymax);
- WriteParameter (file,"JoyMinX ", joyxmin);
- WriteParameter (file,"JoyMinY ", joyymin);
-
- // Write out DefaultDifficulty
- SafeWriteString(file,"\n;\n");
- WriteParameter(file,"; Easy - ", gd_baby );
- WriteParameter(file,"; Medium - ", gd_easy );
- WriteParameter(file,"; Hard - ", gd_medium );
- WriteParameter(file,"; Crezzy - ", gd_hard );
- WriteParameter(file,"DefaultDifficulty ", DefaultDifficulty );
-
- // Write out DefaultPlayerCharacter
- SafeWriteString(file,"\n;\n");
- WriteParameter(file,"; Taradino Cassatt - ", 0 );
- WriteParameter(file,"; Thi Barrett - ", 1 );
- WriteParameter(file,"; Doug Wendt - ", 2 );
- WriteParameter(file,"; Lorelei Ni - ", 3 );
- WriteParameter(file,"; Ian Paul Freeley - ", 4 );
- WriteParameter(file,"DefaultPlayerCharacter ", DefaultPlayerCharacter );
-
- // Write out DefaultPlayerColor
- SafeWriteString(file,"\n;\n");
- WriteParameter(file,"; Gray - ", 0 );
- WriteParameter(file,"; Brown - ", 1 );
- WriteParameter(file,"; Black - ", 2 );
- WriteParameter(file,"; Tan - ", 3 );
- WriteParameter(file,"; Red - ", 4 );
- WriteParameter(file,"; Olive - ", 5 );
- WriteParameter(file,"; Blue - ", 6 );
- WriteParameter(file,"; White - ", 7 );
- WriteParameter(file,"; Green - ", 8 );
- WriteParameter(file,"; Purple - ", 9 );
- WriteParameter(file,"; Orange - ", 10 );
- WriteParameter(file,"DefaultPlayerColor ", DefaultPlayerColor );
-
- // Writeout password Password string
- SafeWriteString(file,"\n;\nSecretPassword ");
- memset(passwordtemp,0,sizeof(passwordtemp));
- ConvertPasswordStringToString ( &passwordtemp[0] );
- SafeWriteString(file,&passwordtemp[0]);
-
- close (file);
-#endif
- inconfig--;
-}
-
-#ifdef _ROTT_
-
-
-//****************************************************************************
-//
-// GetAlternatePath ()
-//
-//****************************************************************************
-
-void GetAlternatePath (char * tokenstr, AlternateInformation *info)
-{
- strcpy (&info->path[0], ".\0");
- GetToken (true);
- if (!stricmp (token, tokenstr))
- {
- GetTokenEOL (false);
- memset (&info->path[0], 0, sizeof (info->path));
- strcpy (&info->path[0], &name[0]);
- }
-}
-
-
-//****************************************************************************
-//
-// GetAlternateFile ()
-//
-//****************************************************************************
-
-void GetAlternateFile (char * tokenstr, AlternateInformation *info)
-{
- // Read in remote sound file
- //
- strcpy (&info->file[0], "foo.foo\0");
- GetToken (true);
- if (!stricmp (token, tokenstr))
- {
- if (TokenAvailable()==true)
- {
- GetToken (false);
- if (stricmp (token, "~"))
- {
-#if (SHAREWARE == 0)
- info->avail = true;
- memset (&info->file[0], 0, sizeof (info->file));
- strcpy (&info->file[0], &token[0]);
-#else
- printf("Alternate file %s ignored.\n",token);
- memset (&info->file[0], 0, sizeof (info->file));
-#endif
- }
- }
- }
-}
-
-
-//****************************************************************************
-//
-// ReadSETUPFiles ()
-//
-//****************************************************************************
-
-void ReadSETUPFiles (void)
-{
- char filename[ 128 ];
- int i;
-
- RemoteSounds.avail = false;
-// PlayerGraphics.avail = false;
- GameLevels.avail = false;
- BattleLevels.avail = false;
-
- GetPathFromEnvironment( filename, ApogeePath, CONFIG );
- if (access (filename, F_OK) == 0)
- {
- LoadScriptFile (filename);
-
- GetTokenEOL (true); //MODEMNAME
- GetTokenEOL (true); //MODEMINITSTR
- GetTokenEOL (true); //MODEMHANGUP
- GetTokenEOL (true); //RATE
- GetTokenEOL (true); //COMPORT
- GetTokenEOL (true); //IRQ
- GetTokenEOL (true); //UART
- GetTokenEOL (true); //PULSE
- GetTokenEOL (true); //AUTOMATICDIALOUT
-
- GetAlternatePath ("REMOTESOUNDPATH", &RemoteSounds);
-// GetAlternatePath ("PLAYERGRAPHICSPATH", &PlayerGraphics);
- GetAlternatePath ("GAMELEVELPATH", &GameLevels);
- GetAlternatePath ("BATTLELEVELPATH", &BattleLevels);
-
- // Get CodeName
- GetToken (true);
- if (stricmp (token, "CODENAME"))
- Error ("Can't find %s token.\n", "CODENAME");
-
- GetTokenEOL (false);
- memset (&CodeName[0], 0, sizeof (CodeName));
- if (stricmp (name, "~"))
- {
-
- // Get First (MAXCODENAMELENGTH-1) characters
- for (i=0; i<MAXCODENAMELENGTH-1; i++)
- CodeName[i]=name[i];
- }
- GetTokenEOL (true); //NUMPLAYERS
- GetTokenEOL (true); //NETWORKSOCKET
- GetTokenEOL (true); //DEFAULT
- for (i=0; i<14; i++)
- GetTokenEOL (true); //NUMBERLIST
-
- memset (CommbatMacros, 0, sizeof(CommbatMacros) );
-
- for (i=0; i<MAXMACROS; i++)
- {
- GetToken (true);
-
- GetTokenEOL (true);
-
- if (name[0] != '~')
- {
- memcpy (&CommbatMacros[i].macro[0], &name[0], strlen (name));
- CommbatMacros[i].avail = 1;
- }
- }
-
- Z_Free (scriptbuffer);
- }
-
- GetPathFromEnvironment( filename, ApogeePath, ROTT );
- if (access (filename, F_OK) == 0)
- {
- LoadScriptFile (filename);
-
- GetTokenEOL (true); //PHONENUMBER
-
- GetAlternateFile ("REMOTESOUNDFILE", &RemoteSounds);
-// GetAlternateFile ("PLAYERGRAPHICSFILE", &PlayerGraphics);
- GetAlternateFile ("GAMELEVELFILE", &GameLevels);
- GetAlternateFile ("COMMBATLEVELFILE", &BattleLevels);
-
- Z_Free (scriptbuffer);
-
- unlink (filename); // Delete ROTT.ROT
- }
-}
-
-#endif
-
+/*
+Copyright (C) 1994-1995 Apogee Software, Ltd.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+//****************************************************************************
+//
+// RT_CFG.C
+//
+//****************************************************************************
+
+#define _ROTT_
+
+#ifdef DOS
+#include <io.h>
+#include <bios.h>
+#include <conio.h>
+#include <process.h>
+#else
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+#endif
+
+#include <stdlib.h>
+#include <fcntl.h>
+#include <string.h>
+#include <ctype.h>
+
+#ifdef _ROTT_
+#include "rt_def.h"
+#else
+#include "st_def.h"
+#endif
+
+#include "rt_cfg.h"
+#include "version.h"
+
+#ifdef _ROTT_
+
+#include "scriplib.h"
+#include "rt_playr.h"
+#include "rt_menu.h"
+#include "rt_game.h"
+#include "rt_in.h"
+#include "z_zone.h"
+#include "w_wad.h"
+#include "rt_crc.h"
+#include "rt_sound.h"
+#include "rt_util.h"
+#include "rt_main.h"
+#include "rt_view.h"
+#include "rt_msg.h"
+#include "rt_battl.h"
+#include "rt_net.h"
+#include "isr.h"
+#include "fx_man.h"
+#include "develop.h"
+
+#else
+
+#include "st_def.h"
+#include "rt_cfg.h"
+#include "scriplib.h"
+#include "rt_sound.h"
+#include "st_util.h"
+
+#endif
+//MED
+#include "memcheck.h"
+
+
+//******************************************************************************
+//
+// GLOBALS
+//
+//******************************************************************************
+
+extern int G_weaponscale;
+extern boolean iG_aimCross;
+
+boolean WriteSoundFile = true;
+
+int FXMode = 0;
+int MusicMode = 0;
+
+int MUvolume = 196;
+int FXvolume = 196;
+
+#ifdef DOS
+fx_blaster_config SBSettings =
+{
+ 0x220, fx_SB, 7, 1, 5, 0x330, 0x620
+};
+#endif
+
+boolean mouseenabled = 1;
+boolean usemouselook = 0;
+int inverse_mouse = 1; //set to -1 to invert mouse
+boolean usejump = 0;
+boolean sdl_fullscreen = 1;
+
+boolean allowBlitzMoreMissileWeps = 0;
+boolean enableAmmoPickups = 0;
+boolean autoAimMissileWeps = 0;
+boolean autoAim = 1;
+boolean enableExtraPistolDrops = 0;
+boolean allowMovementWithMouseYAxis = 1;
+int FocalWidthOffset = 0;
+int ScreenHeightToWriteToCfg = 0;
+
+int ScreenWidthToWriteToCfg = 0;
+boolean writeNewResIntoCfg = false;
+
+
+boolean joystickenabled = 0;
+boolean joypadenabled = 0;
+int joystickport = 0;
+int mouseadjustment = 5;
+int threshold = 1;
+int NumVoices = 4;
+int NumChannels = 1;
+int NumBits = 8;
+#ifdef DOS
+int MidiAddress = 0x330;
+#endif
+boolean cybermanenabled = false;
+boolean assassinenabled = false;
+boolean spaceballenabled = false;
+boolean AutoDetailOn = true;
+int DoubleClickSpeed = 20;
+boolean BobbinOn = true;
+int Menuflipspeed = 15;
+int DetailLevel = 2; //HI DETAIL
+int fandc = 1;
+int blanktime = (2*60*VBLCOUNTER);
+boolean ConfigLoaded = false;
+boolean stereoreversed = false;
+
+int DefaultDifficulty = 2;
+int DefaultPlayerCharacter = 0;
+int DefaultPlayerColor = 0;
+byte passwordstring[20];
+
+#ifndef _ROTT_
+
+int fulllight = 0;
+int viewsize = 7;
+
+#endif
+MacroList CommbatMacros[MAXMACROS];
+
+#ifdef DOS
+char *ApogeePath = "APOGEECD";
+#else
+char ApogeePath[256];
+#endif
+
+//******************************************************************************
+//
+// LOCALS
+//
+//******************************************************************************
+
+static char SoundName[13] = "sound.rot";
+
+#ifdef _ROTT_
+
+static char *ConfigName = "config.rot";
+static char *ScoresName = "scores.rot";
+static char *ROTT = "rott.rot";
+static char *CONFIG = "setup.rot";
+static char *BattleName = "battle.rot";
+
+AlternateInformation RemoteSounds;
+//AlternateInformation PlayerGraphics;
+AlternateInformation GameLevels;
+AlternateInformation BattleLevels;
+char CodeName[MAXCODENAMELENGTH];
+
+#endif
+
+
+#ifdef _ROTT_
+
+//******************************************************************************
+//
+// ReadScores ()
+//
+//******************************************************************************
+
+void ReadScores (void)
+{
+ int file;
+ char filename[ 128 ];
+
+ GetPathFromEnvironment( filename, ApogeePath, ScoresName );
+ if (access (filename, F_OK) == 0)
+ {
+ file = SafeOpenRead (filename);
+ SafeRead (file, &Scores, sizeof (Scores));
+ close(file);
+ }
+ else
+ gamestate.violence = 0;
+}
+
+#endif
+
+//******************************************************************************
+//
+// ReadInt
+//
+//******************************************************************************
+
+void ReadInt (const char * s1, int * val)
+{
+ GetToken (true);
+ if (!strcmpi (token,s1))
+ {
+ if (TokenAvailable()==true)
+ {
+ GetToken(false);
+ *val=ParseNum(token);
+ }
+ }
+}
+
+//******************************************************************************
+//
+// ReadBoolean
+//
+//******************************************************************************
+
+void ReadBoolean (const char * s1, boolean * val)
+{
+ int temp;
+
+ temp = (int)(*val);
+ ReadInt (s1,&temp);
+ *val = (boolean) temp;
+}
+
+//******************************************************************************
+//
+// ReadUnsigned
+//
+//******************************************************************************
+
+void ReadUnsigned (const char * s1, unsigned long * val)
+{
+ int temp;
+
+ temp = (int)(*val);
+ ReadInt (s1,&temp);
+ *val = (unsigned) temp;
+}
+
+//******************************************************************************
+//
+// ParseSoundFile ()
+//
+//******************************************************************************
+
+boolean ParseSoundFile (void)
+{
+ boolean retval = true;
+ int version = 0;
+
+ ReadInt("Version",&version);
+
+ if (version == ROTTVERSION)
+ {
+ // Read in Music Mode
+
+ ReadInt ("MusicMode",&MusicMode);
+
+ // Read in FX Mode
+
+ ReadInt ("FXMode",&FXMode);
+
+ // Read in Music Volume
+
+ ReadInt ("MusicVolume", &MUvolume);
+
+ // Read in FX Volume
+
+ ReadInt ("FXVolume", &FXvolume);
+
+ // Read in numvoices
+
+ ReadInt ("NumVoices",&NumVoices);
+
+ // Read in numchannels
+
+ ReadInt ("NumChannels",&NumChannels);
+
+ // Read in numbits
+
+ ReadInt ("NumBits",&NumBits);
+
+#ifdef DOS
+ // Read in Midi Address
+
+ ReadInt ("MidiAddress",&MidiAddress);
+#endif
+
+ // Read in stereo reversal
+
+ ReadBoolean ("StereoReverse",&stereoreversed);
+
+#ifdef DOS
+ // Read in Sound Blaster info
+ ReadUnsigned ("SBType", &SBSettings.Type );
+ ReadUnsigned ("SBPort", &SBSettings.Address );
+ ReadUnsigned ("SBIrq", &SBSettings.Interrupt );
+ ReadUnsigned ("SBDma8", &SBSettings.Dma8 );
+ ReadUnsigned ("SBDma16", &SBSettings.Dma16 );
+ ReadUnsigned ("SBMidi", &SBSettings.Midi );
+ ReadUnsigned ("SBEmu", &SBSettings.Emu );
+#endif
+ }
+ else
+ retval = false;
+
+ return (retval);
+}
+
+
+
+//******************************************************************************
+//
+// SetSoundDefaultValues ()
+//
+//******************************************************************************
+void SetSoundDefaultValues
+(
+ void
+)
+
+{
+#ifdef DOS
+ fx_blaster_config blaster;
+#endif
+ int status;
+
+ //
+ // no config file, so select default values
+ //
+#if !defined(PLATFORM_DOS)
+ // icculus' SDL_mixer driver looks like a soundscape to us
+ MusicMode = 6;
+ FXMode = 6;
+ NumVoices = 8;
+ NumChannels = 2;
+ NumBits = 16;
+ stereoreversed = false;
+#else
+ MusicMode = 0;
+ FXMode = 0;
+ NumVoices = 4;
+ NumChannels = 1;
+ NumBits = 8;
+ MidiAddress = 0x330;
+ stereoreversed = false;
+
+ status = FX_GetBlasterSettings( &blaster );
+ if ( status == FX_Ok )
+ {
+ SBSettings.Type = blaster.Type;
+ SBSettings.Address = blaster.Address;
+ SBSettings.Interrupt = blaster.Interrupt;
+ SBSettings.Dma8 = blaster.Dma8;
+ SBSettings.Dma16 = blaster.Dma16;
+ SBSettings.Midi = blaster.Midi;
+ SBSettings.Emu = blaster.Emu;
+ }
+#endif
+}
+
+
+#ifdef _ROTT_
+
+extern char pword[ 13 ];
+//******************************************************************************
+//
+// ConvertStringToPasswordString ()
+//
+//******************************************************************************
+
+#define PASSWORDENCRYPTER "7d7e4a2d3b6a0319554654231f6d2a"
+
+void ConvertStringToPasswordString ( char * string )
+{
+ int i;
+ unsigned int j;
+ char temp[3];
+
+ memset(temp,0,sizeof(temp));
+
+ for (i=0; i<13; i++)
+ {
+ memcpy(&temp[0],&string[i<<1],2);
+ sscanf(&temp[0],"%x",&j);
+ passwordstring[i+0] = j & 0xff;
+ j >>= 8;
+ passwordstring[i+1] = j & 0xff;
+ j >>= 8;
+ passwordstring[i+2] = j & 0xff;
+ j >>= 8;
+ passwordstring[i+3] = j & 0xff;
+ }
+}
+
+//******************************************************************************
+//
+// ConvertPasswordStringToPassword ()
+//
+//******************************************************************************
+
+void ConvertPasswordStringToPassword ( void )
+{
+ int i;
+ int x;
+ char temp[3];
+ char key[40];
+
+ memset(temp,0,sizeof(temp));
+ strcpy(&key[0],PASSWORDENCRYPTER);
+
+ for (i=0; i<12; i++)
+ {
+ memcpy(&temp[0],&key[i<<1],2);
+ sscanf(&temp[0],"%x",&x);
+ pword[i]=passwordstring[i]^x;
+ }
+ memcpy(&temp[0],&key[i<<1],2);
+ sscanf(&temp[0],"%x",&x);
+ gamestate.violence=passwordstring[i]^x;
+ if (
+ (gamestate.violence<0) ||
+ (gamestate.violence>3)
+ )
+ gamestate.violence=0;
+}
+
+//******************************************************************************
+//
+// ConvertPasswordStringToString ()
+//
+//******************************************************************************
+
+void ConvertPasswordStringToString ( char * string )
+{
+ int i;
+ char temp[8];
+
+ memset(temp,0,sizeof(temp));
+
+ for (i=0; i<13; i++)
+ {
+ itoa((passwordstring[i]>>4),&temp[0],16);
+ string[(i<<1)+0]=temp[0];
+ itoa((passwordstring[i]&0xf),&temp[0],16);
+ string[(i<<1)+1]=temp[0];
+ }
+}
+
+//******************************************************************************
+//
+// ConvertPasswordToPasswordString ()
+//
+//******************************************************************************
+
+void ConvertPasswordToPasswordString ( void )
+{
+ int i;
+ int x;
+ char temp[3];
+ char key[40];
+
+ memset(temp,0,sizeof(temp));
+ strcpy(&key[0],PASSWORDENCRYPTER);
+
+ for (i=0; i<12; i++)
+ {
+ memcpy(&temp[0],&key[i<<1],2);
+ sscanf(&temp[0],"%x",&x);
+ passwordstring[i]=pword[i]^x;
+ }
+ memcpy(&temp[0],&key[i<<1],2);
+ sscanf(&temp[0],"%x",&x);
+ passwordstring[i]=gamestate.violence^x;
+}
+
+//******************************************************************************
+//
+// ParseConfigFile ()
+//
+//******************************************************************************
+
+boolean ParseConfigFile (void)
+{
+// int temp;
+ boolean retval = true;
+ int version = 0;
+
+ ReadInt("Version",&version);
+
+ if (version == ROTTVERSION)
+ {
+ //Read in allowBlitzguardMoreMissileWeps
+ ReadBoolean("AllowBlitzguardMoreMissileWeps", &allowBlitzMoreMissileWeps);
+
+ //Read in enableAmmoPickups
+ ReadBoolean("EnableAmmoPickups", &enableAmmoPickups);
+
+ //Read in AutoAim
+ ReadBoolean("AutoAim", &autoAim);
+
+ //Read in AutoAimMissileWeps
+ ReadBoolean("AutoAimMissileWeps", &autoAimMissileWeps);
+
+ //Read in EnableExtraPistolDrops
+ ReadBoolean("EnableExtraPistolDrops", &enableExtraPistolDrops);
+
+ //Read in scaleOffset
+
+ ReadInt("FocalWidthOffset", &FocalWidthOffset);
+
+ // Read in MouseEnabled
+ ReadBoolean("MouseEnabled",&mouseenabled);
+
+ // Read in UseMouseLook
+ ReadBoolean("UseMouseLook",&usemouselook);
+
+ ReadInt("InverseMouse",&inverse_mouse);
+
+ ReadBoolean("AllowMovementWithMouseYAxis", &allowMovementWithMouseYAxis);
+
+ // Read in UseJump
+ ReadBoolean("UseJump",&usejump);
+
+ // Read in CrossHair
+ ReadBoolean("CrossHair",&iG_aimCross);
+
+ // Read in JoystickEnabled
+ ReadBoolean("JoystickEnabled",&joystickenabled);
+
+ // Read in JoypadEnabled
+ ReadBoolean("JoypadEnabled",&joypadenabled);
+
+ // Read in JoystickPort
+ ReadInt("JoystickPort",&joystickport);
+
+ // Read in fullscreen
+ ReadBoolean("FullScreen", &sdl_fullscreen);
+
+ // Read in resolution
+ ReadInt("ScreenWidth", &iGLOBAL_SCREENWIDTH);
+ ReadInt("ScreenHeight", &iGLOBAL_SCREENHEIGHT);
+
+ // Read in ViewSize
+
+ ReadInt("ViewSize",&viewsize);
+
+ // Read in Weaponscale
+ ReadInt("Weaponscale",&G_weaponscale);//bna added
+ if ((G_weaponscale <150)||(G_weaponscale>600)) {
+ if (iGLOBAL_SCREENWIDTH == 320) {
+ G_weaponscale=168;
+ } else if (iGLOBAL_SCREENWIDTH == 640) {
+ G_weaponscale=299;
+ } else if (iGLOBAL_SCREENWIDTH == 800) {
+ G_weaponscale=376;
+ }
+ else if (iGLOBAL_SCREENWIDTH == 1024) {
+ G_weaponscale=512;
+ }
+ }
+
+ // Read in MouseAdjustment
+ ReadInt("MouseAdjustment",&mouseadjustment);
+
+ // Read in threshold
+ ReadInt("Threshold",&threshold);
+
+ // Read in Auto Detail
+ ReadBoolean ("AutoDetail", &AutoDetailOn);
+
+ // Read in Light Dim
+ ReadInt ("LightDim", &fulllight);
+
+ // Read in Bobbin' On
+ ReadBoolean ("BobbingOn", &BobbinOn);
+
+ // Read in Double Click Speed
+ ReadInt ("DoubleClickSpeed", &DoubleClickSpeed);
+
+ // Read in Menu Flip Speed
+ ReadInt ("MenuFlipSpeed", &Menuflipspeed);
+
+ // Read in Detail Level
+ ReadInt ("DetailLevel", &DetailLevel);
+
+ // Read in Floor and Ceiling
+ ReadInt ("FloorCeiling", &fandc);
+
+ // Read in MessagesEnabled
+ ReadBoolean ("Messages", &MessagesEnabled );
+
+ // Read in Autorun
+ ReadInt ("AutoRun", &gamestate.autorun );
+
+ // Read in GammaIndex
+ ReadInt ("GammaIndex", &gammaindex);
+
+ // Read screen blanking time
+ ReadInt ("BlankTime", &blanktime);
+
+ blanktime=blanktime*60*VBLCOUNTER;
+
+ // Read keys
+ ReadInt ("Fire", &buttonscan[0]);
+ ReadInt ("Strafe", &buttonscan[1]);
+ ReadInt ("Run", &buttonscan[2]);
+ ReadInt ("Use", &buttonscan[3]);
+ ReadInt ("LookUp", &buttonscan[4]);
+ ReadInt ("LookDn", &buttonscan[5]);
+ ReadInt ("Swap", &buttonscan[6]);
+ ReadInt ("Drop", &buttonscan[7]);
+ ReadInt ("TargetUp", &buttonscan[8]);
+ ReadInt ("TargetDn", &buttonscan[9]);
+ ReadInt ("SelPistol", &buttonscan[10]);
+ ReadInt ("SelDualPistol",&buttonscan[11]);
+ ReadInt ("SelMP40", &buttonscan[12]);
+ ReadInt ("SelMissile", &buttonscan[13]);
+ ReadInt ("AutoRun", &buttonscan[14]);
+ ReadInt ("LiveRemRid", &buttonscan[15]);
+ ReadInt ("StrafeLeft", &buttonscan[16]);
+ ReadInt ("StrafeRight", &buttonscan[17]);
+ ReadInt ("VolteFace", &buttonscan[18]);
+ ReadInt ("Aim", &buttonscan[19]);
+ ReadInt ("Forward", &buttonscan[20]);
+ ReadInt ("Right", &buttonscan[21]);
+ ReadInt ("Backward", &buttonscan[22]);
+ ReadInt ("Left", &buttonscan[23]);
+ ReadInt ("Map", &buttonscan[24]);
+ ReadInt ("SendMessage", &buttonscan[25]);
+ ReadInt ("DirectMessage",&buttonscan[26]);
+
+ ReadInt ("MouseButton0",&buttonmouse[0]);
+ ReadInt ("MouseButton1",&buttonmouse[1]);
+ ReadInt ("MouseButton2",&buttonmouse[2]);
+ ReadInt ("DblClickB0", &buttonmouse[3]);
+ ReadInt ("DblClickB1", &buttonmouse[4]);
+ ReadInt ("DblClickB2", &buttonmouse[5]);
+
+ ReadInt ("JoyButton0", &buttonjoy[0]);
+ ReadInt ("JoyButton1", &buttonjoy[1]);
+ ReadInt ("JoyButton2", &buttonjoy[2]);
+ ReadInt ("JoyButton3", &buttonjoy[3]);
+ ReadInt ("DblClickJB0", &buttonjoy[4]);
+ ReadInt ("DblClickJB1", &buttonjoy[5]);
+ ReadInt ("DblClickJB2", &buttonjoy[6]);
+ ReadInt ("DblClickJB3", &buttonjoy[7]);
+
+ ReadInt ("JoyMaxX", &joyxmax);
+ ReadInt ("JoyMaxY", &joyymax);
+ ReadInt ("JoyMinX", &joyxmin);
+ ReadInt ("JoyMinY", &joyymin);
+
+ ReadInt( "DefaultDifficulty", &DefaultDifficulty );
+ ReadInt( "DefaultPlayerCharacter", &DefaultPlayerCharacter );
+ ReadInt( "DefaultPlayerColor", &DefaultPlayerColor );
+
+ // Get Password string
+ GetToken (true);
+ if (!stricmp (token, "SecretPassword"))
+ {
+ GetTokenEOL (false);
+ ConvertStringToPasswordString ( &name[0] );
+ }
+
+ if (!CybermanPresent)
+ cybermanenabled = false;
+
+ if (!AssassinPresent)
+ assassinenabled = false;
+
+ if (!SpaceBallPresent)
+ spaceballenabled = false;
+
+ if (!MousePresent)
+ mouseenabled = false;
+
+ if (!JoysPresent[joystickport])
+ joystickenabled = false;
+
+ // precaution
+
+ if (!joyxmin || !joyxmax || !joyymin || !joyymax)
+ joystickenabled = false;
+
+ if (joystickenabled)
+ IN_SetupJoy (joystickport, joyxmin, joyxmax, joyymin, joyymax);
+ }
+ else
+ retval = false;
+
+ return (retval);
+}
+
+
+//******************************************************************************
+//
+// ParseBattleFile ()
+//
+//******************************************************************************
+boolean ParseBattleFile (void)
+{
+ boolean retval = true;
+ int version = 0;
+ int index;
+ int temp;
+ extern specials BattleSpecialsTimes;
+
+ ReadInt("Version",&version);
+ if (version != ROTTVERSION)
+ retval = false;
+ else
+ {
+ ReadBoolean( "ShowKillCount", &BATTLE_ShowKillCount );
+
+ ReadInt( "GodModeTime", &BattleSpecialsTimes.GodModeTime );
+ ReadInt( "DogModeTime", &BattleSpecialsTimes.DogModeTime );
+ ReadInt( "ShroomsModeTime", &BattleSpecialsTimes.ShroomsModeTime );
+ ReadInt( "ElastoModeTime", &BattleSpecialsTimes.ElastoModeTime );
+ ReadInt( "AsbestosVestTime", &BattleSpecialsTimes.AsbestosVestTime );
+ ReadInt( "BulletProofVestTime", &BattleSpecialsTimes.BulletProofVestTime );
+ ReadInt( "GasMaskTime", &BattleSpecialsTimes.GasMaskTime );
+ ReadInt( "MercuryModeTime", &BattleSpecialsTimes.MercuryModeTime );
+ ReadInt( "GodModeRespawnTime", &BattleSpecialsTimes.GodModeRespawnTime );
+ ReadInt( "DogModeRespawnTime", &BattleSpecialsTimes.DogModeRespawnTime );
+ ReadInt( "ShroomsModeRespawnTime", &BattleSpecialsTimes.ShroomsModeRespawnTime );
+ ReadInt( "ElastoModeRespawnTime", &BattleSpecialsTimes.ElastoModeRespawnTime );
+ ReadInt( "AsbestosVestRespawnTime", &BattleSpecialsTimes.AsbestosVestRespawnTime );
+ ReadInt( "BulletProofVestRespawnTime", &BattleSpecialsTimes.BulletProofVestRespawnTime );
+ ReadInt( "GasMaskRespawnTime", &BattleSpecialsTimes.GasMaskRespawnTime );
+ ReadInt( "MercuryModeRespawnTime", &BattleSpecialsTimes.MercuryModeRespawnTime );
+
+ ReadBoolean( "EKG", &battlegibs );
+
+ for( index = battle_Normal; index < battle_NumBattleModes; index++ )
+ {
+ // Read Gravity
+ temp = BATTLE_Options[ index ].Gravity;
+ ReadInt( "Gravity", &temp );
+ BATTLE_Options[ index ].Gravity = temp;
+
+ // Read Speed
+ temp = bo_normal_speed;
+ ReadInt( "Speed", &temp );
+ if ( ( temp >= bo_normal_speed ) &&
+ ( temp <= bo_fast_speed ) )
+ {
+ BATTLE_Options[ index ].Speed = temp;
+ }
+
+ if ( ( index != battle_Collector ) && ( index != battle_Tag ) &&
+ ( index != battle_Eluder ) )
+ {
+ // Read Ammo
+ temp = bo_normal_shots;
+ BATTLE_Options[ index ].Ammo = bo_normal_shots;
+ ReadInt( "Ammo", &temp );
+ if ( ( temp >= bo_one_shot ) &&
+ ( temp <= bo_infinite_shots ) )
+ {
+ BATTLE_Options[ index ].Ammo = temp;
+ }
+ }
+
+ if ( index != battle_Eluder )
+ {
+ // Read Hitpoints
+ temp = BATTLE_Options[ index ].HitPoints;
+ ReadInt( "Hitpoints", &temp );
+ BATTLE_Options[ index ].HitPoints = temp;
+ }
+
+ // Read Spawn Dangers
+ temp = 1;
+ ReadInt( "SpawnDangers", &temp );
+ BATTLE_Options[ index ].SpawnDangers = temp;
+
+ if ( index != battle_Eluder )
+ {
+ // Read Spawn Health
+ temp = 1;
+ ReadInt( "SpawnHealth", &temp );
+ BATTLE_Options[ index ].SpawnHealth = temp;
+
+ // Read Spawn Mines
+ temp = 0;
+ ReadInt( "SpawnMines", &temp );
+ BATTLE_Options[ index ].SpawnMines = temp;
+ }
+
+ if ( ( index != battle_Collector ) && ( index != battle_Tag ) &&
+ ( index != battle_Eluder ) )
+ {
+ // Read Spawn Weapons
+ temp = 1;
+ ReadInt( "SpawnWeapons", &temp );
+ BATTLE_Options[ index ].SpawnWeapons = temp;
+
+ // Read Random Weapons
+ temp = 0;
+ ReadInt( "RandomWeapons", &temp );
+ BATTLE_Options[ index ].RandomWeapons = temp;
+
+ // Read Weapon Persistence
+ temp = 0;
+ ReadInt( "WeaponPersistence", &temp );
+ BATTLE_Options[ index ].WeaponPersistence = temp;
+ }
+
+ if ( ( index == battle_Normal ) || ( index == battle_ScoreMore ) ||
+ ( index == battle_Hunter ) || ( index == battle_Tag ) )
+ {
+ // Read Friendly Fire
+ temp = 1;
+ ReadInt( "FriendlyFire", &temp );
+ BATTLE_Options[ index ].FriendlyFire = temp;
+ }
+
+ if ( index != battle_Eluder )
+ {
+ // Read Respawn Items
+ temp = 1;
+ ReadInt( "RespawnItems", &temp );
+ BATTLE_Options[ index ].RespawnItems = temp;
+ }
+
+ // Read Light Level
+ temp = bo_light_normal;
+ ReadInt( "LightLevel", &temp );
+ if ( ( temp >= bo_light_dark ) &&
+ ( temp <= bo_light_lightning ) )
+ {
+ BATTLE_Options[ index ].LightLevel = temp;
+ }
+
+ if ( ( index != battle_Collector ) && ( index != battle_Scavenger ) )
+ {
+ // Read Point Goal
+ temp = bo_kills_default;
+ ReadInt( "PointGoal", &temp );
+ BATTLE_Options[ index ].Kills = temp;
+ if ( temp < bo_kills_random )
+ {
+ BATTLE_Options[ index ].Kills = bo_kills_default;
+ }
+ }
+
+ if ( index != battle_Eluder )
+ {
+ // Read Danger Damage
+ temp = bo_danger_normal;
+ ReadInt( "DangerDamage", &temp );
+ BATTLE_Options[ index ].DangerDamage = temp;
+ }
+
+ // Read Time Limit
+ temp = bo_time_infinite;
+ ReadInt( "TimeLimit", &temp );
+ if ( ( index == battle_Hunter ) && ( temp == bo_time_infinite ) )
+ {
+ temp = 99;
+ }
+ BATTLE_Options[ index ].TimeLimit = temp;
+
+ // Read Respawn time
+ temp = bo_normal_respawn_time;
+ ReadInt( "RespawnTime", &temp );
+ BATTLE_Options[ index ].RespawnTime = temp;
+ }
+ }
+
+ return (retval);
+}
+
+//******************************************************************************
+//
+// SetBattleDefaultValues ()
+//
+//******************************************************************************
+
+void SetBattleDefaultValues (void)
+{
+ int index;
+
+ //
+ // no config file, so select default values
+ //
+ for( index = battle_StandAloneGame; index < battle_NumBattleModes;
+ index++ )
+ {
+ BATTLE_Options[ index ].Gravity = NORMAL_GRAVITY;
+ BATTLE_Options[ index ].Speed = bo_normal_speed;
+ BATTLE_Options[ index ].Ammo = bo_normal_shots;
+ BATTLE_Options[ index ].HitPoints = bo_default_hitpoints;
+ BATTLE_Options[ index ].SpawnDangers = 1;
+ BATTLE_Options[ index ].SpawnHealth = 1;
+ BATTLE_Options[ index ].SpawnMines = 0;
+ BATTLE_Options[ index ].SpawnWeapons = 1;
+ BATTLE_Options[ index ].RespawnItems = 1;
+ BATTLE_Options[ index ].RandomWeapons = 0;
+ BATTLE_Options[ index ].WeaponPersistence = 0;
+ BATTLE_Options[ index ].FriendlyFire = 1;
+ BATTLE_Options[ index ].LightLevel = bo_light_normal;
+ BATTLE_Options[ index ].Kills = bo_kills_default;
+ BATTLE_Options[ index ].DangerDamage = bo_danger_normal;
+ BATTLE_Options[ index ].TimeLimit = bo_time_infinite;
+ BATTLE_Options[ index ].RespawnTime = bo_normal_respawn_time;
+ }
+
+ BATTLE_Options[ battle_CaptureTheTriad ].Kills = 1;
+ BATTLE_Options[ battle_Hunter ].TimeLimit = 1;
+ BATTLE_Options[ battle_Eluder ].SpawnHealth = 0;
+ BATTLE_Options[ battle_Eluder ].RespawnItems = 0;
+ BATTLE_Options[ battle_Eluder ].SpawnWeapons = 0;
+ BATTLE_Options[ battle_Eluder ].FriendlyFire = 0;
+ BATTLE_Options[ battle_Collector ].SpawnWeapons = 0;
+ BATTLE_Options[ battle_Collector ].FriendlyFire = 0;
+ BATTLE_Options[ battle_Tag ].SpawnWeapons = 0;
+ battlegibs=false;
+ BATTLE_ShowKillCount = true;
+}
+
+//******************************************************************************
+//
+// SetConfigDefaultValues ()
+//
+//******************************************************************************
+
+void SetConfigDefaultValues (void)
+{
+ //
+ // no config file, so select default values
+ //
+ if (MousePresent)
+ mouseenabled = true;
+
+ joystickenabled = false;
+ joypadenabled = false;
+ joystickport = 0;
+ viewsize = 7;
+ mouseadjustment = 5;
+ gammaindex = 0;
+ gamestate.violence = 3;
+ passwordstring[0]=0x7d;
+ passwordstring[1]=0x7e;
+ passwordstring[2]=0x4a;
+ passwordstring[3]=0x2d;
+ passwordstring[4]=0x3b;
+ passwordstring[5]=0x6a;
+ passwordstring[6]=0x03;
+ passwordstring[7]=0x19;
+ passwordstring[8]=0x55;
+ passwordstring[9]=0x46;
+ passwordstring[10]=0x54;
+ passwordstring[11]=0x23;
+ passwordstring[12]=0x1c;
+}
+#endif
+
+//******************************************************************************
+//
+// DeleteSoundFile ()
+//
+//******************************************************************************
+void DeleteSoundFile ( void )
+{
+ char filename[ 128 ];
+
+ GetPathFromEnvironment( filename, ApogeePath, SoundName );
+ unlink (filename); // Delete SOUND.ROT
+}
+
+//******************************************************************************
+//
+// ReadConfig ()
+//
+//******************************************************************************
+
+
+void ReadConfig (void)
+{
+ char filename[ 128 ];
+
+ GetPathFromEnvironment( filename, ApogeePath, SoundName );
+ SetSoundDefaultValues ();
+
+ if (access (filename, F_OK) == 0)
+ {
+ LoadScriptFile (filename);
+
+ if (ParseSoundFile () == false)
+ {
+ DeleteSoundFile();
+ }
+
+ Z_Free (scriptbuffer);
+ }
+#ifdef DOS
+ else if ( !SOUNDSETUP )
+ {
+ Error( "Could not find SOUND.ROT. Please run SNDSETUP to configure "
+ "your sound hardware." );
+ }
+#endif
+
+
+#ifdef _ROTT_
+ ReadScores();
+
+ GetPathFromEnvironment( filename, ApogeePath, ConfigName );
+ SetConfigDefaultValues ();
+ if (access(filename,F_OK)==0)
+ {
+ LoadScriptFile(filename);
+
+ if (ParseConfigFile () == false)
+ {
+ unlink (filename); // Delete CONFIG.ROT
+ }
+
+ Z_Free(scriptbuffer);
+ }
+
+ GetPathFromEnvironment( filename, ApogeePath, BattleName );
+ SetBattleDefaultValues ();
+ if (access(filename,F_OK)==0)
+ {
+ LoadScriptFile(filename);
+
+ if (ParseBattleFile() == false)
+ {
+ unlink (filename); // Delete BATTLE.ROT
+ }
+
+ Z_Free(scriptbuffer);
+ }
+#endif
+ ConfigLoaded = true;
+}
+
+//******************************************************************************
+//
+// CheckVendor ()
+//
+//******************************************************************************
+
+#if (SHAREWARE==1)
+#define VENDORDOC ("VENDOR.DOC")
+#define VENDORLUMP ("VENDOR")
+#else
+#define VENDORDOC ("LICENSE.DOC")
+#define VENDORLUMP ("LICENSE")
+#endif
+
+void CheckVendor (void)
+{
+ boolean saveout=false;
+ int wadcrc;
+ int filecrc;
+ int size;
+ int lump;
+ byte * vendor;
+ char filename[ 128 ];
+
+ GetPathFromEnvironment( filename, ApogeePath, VENDORDOC );
+ if (access (filename, F_OK) == 0)
+ {
+ size = LoadFile(filename,(void **)&vendor);
+ filecrc = CalculateCRC (vendor, size);
+ SafeFree(vendor);
+ lump=W_GetNumForName(VENDORLUMP);
+ vendor = W_CacheLumpNum(lump,PU_CACHE, CvtNull, 1);
+ size=W_LumpLength(lump);
+ wadcrc = CalculateCRC (vendor, size);
+ if (wadcrc != filecrc)
+ saveout=true;
+ }
+ else
+ saveout=true;
+
+ if (saveout==true)
+ {
+ lump=W_GetNumForName(VENDORLUMP);
+ vendor = W_CacheLumpNum(lump,PU_CACHE, CvtNull, 1);
+ size = W_LumpLength(lump);
+ SaveFile (filename,vendor,size);
+ }
+}
+
+//******************************************************************************
+//
+// WriteParameter
+//
+//******************************************************************************
+
+void WriteParameter (int file, const char * s1, int val)
+{
+ char s[50];
+
+ // Write out Header
+ SafeWriteString (file, (char *)s1);
+
+ // Write out space character
+ strcpy (&s[0],(const char *)" ");
+ SafeWriteString (file, &s[0]);
+
+ // Write out value
+ itoa(val,&s[0],10);
+ SafeWriteString (file, &s[0]);
+
+ // Write out EOL character
+ strcpy (&s[0],(const char *)"\n");
+ SafeWriteString (file, &s[0]);
+}
+
+
+//******************************************************************************
+//
+// WriteParameterHex
+//
+//******************************************************************************
+
+void WriteParameterHex (int file, const char * s1, int val)
+{
+ char s[50];
+
+ // Write out Header
+ SafeWriteString (file, (char *)s1);
+
+ // Write out space character
+ strcpy (&s[0],(const char *)" $");
+ SafeWriteString (file, &s[0]);
+
+ // Write out value
+ itoa(val,&s[0],16);
+ SafeWriteString (file, &s[0]);
+
+ // Write out EOL character
+ strcpy (&s[0],(const char *)"\n");
+ SafeWriteString (file, &s[0]);
+}
+
+
+
+#ifdef _ROTT_
+
+//******************************************************************************
+//
+// WriteScores ()
+//
+//******************************************************************************
+
+void WriteScores (void)
+{
+ int file;
+ char filename[ 128 ];
+
+ GetPathFromEnvironment( filename, ApogeePath, ScoresName );
+ file=SafeOpenWrite( filename );
+ SafeWrite (file, &Scores, sizeof (Scores));
+ close(file);
+}
+
+
+//******************************************************************************
+//
+// WriteBattleConfig ()
+//
+//******************************************************************************
+
+void WriteBattleConfig
+(
+ void
+)
+
+{
+ int file;
+ int index;
+ char filename[ 128 ];
+ extern specials BattleSpecialsTimes;
+
+ // Write Battle File
+ GetPathFromEnvironment( filename, ApogeePath, BattleName );
+ file = open( filename, O_RDWR | O_TEXT | O_CREAT | O_TRUNC,
+ S_IREAD | S_IWRITE );
+
+ if ( file == -1 )
+ {
+ Error( "Error opening %s: %s", filename, strerror( errno ) );
+ }
+
+ // Write out BATTLECONFIG header
+ SafeWriteString( file,
+ ";Rise of the Triad Battle Configuration File\n"
+ "; (c) 1995\n"
+ ";\n"
+ ";You may change these options at you own risk. Using any values\n"
+ ";other than the ones documented may make the game unplayable.\n"
+ ";If this happens, you may delete this file (BATTLE.ROT) and ROTT\n"
+ ";will recreate it with the default values selected.\n"
+ ";\n"
+ ";With that in mind, have fun!\n"
+ ";\n"
+ "\n" );
+
+ // Write out Version
+ WriteParameter( file, "Version ", ROTTVERSION );
+
+ // Write out BATTLE_ShowKillPics
+ SafeWriteString(file, "\n;\n");
+ WriteParameter( file, "; Yes - ", 1 );
+ WriteParameter( file, "; No - ", 0 );
+ WriteParameter( file, "ShowKillCount ", BATTLE_ShowKillCount );
+
+ // Write out specials' times
+ SafeWriteString(file, "\n;\n"
+ "; These are the time in seconds of the various powerups.\n"
+ "; You could modify these to give you infinite Mercury mode,\n"
+ "; stronger vests, or to make them persistent.\n;\n" );
+
+ WriteParameter( file, "GodModeTime ", BattleSpecialsTimes.GodModeTime );
+ WriteParameter( file, "DogModeTime ", BattleSpecialsTimes.DogModeTime );
+ WriteParameter( file, "ShroomsModeTime ", BattleSpecialsTimes.ShroomsModeTime );
+ WriteParameter( file, "ElastoModeTime ", BattleSpecialsTimes.ElastoModeTime );
+ WriteParameter( file, "AsbestosVestTime ", BattleSpecialsTimes.AsbestosVestTime );
+ WriteParameter( file, "BulletProofVestTime ", BattleSpecialsTimes.BulletProofVestTime );
+ WriteParameter( file, "GasMaskTime ", BattleSpecialsTimes.GasMaskTime );
+ WriteParameter( file, "MercuryModeTime ", BattleSpecialsTimes.MercuryModeTime );
+ WriteParameter( file, "GodModeRespawnTime ", BattleSpecialsTimes.GodModeRespawnTime );
+ WriteParameter( file, "DogModeRespawnTime ", BattleSpecialsTimes.DogModeRespawnTime );
+ WriteParameter( file, "ShroomsModeRespawnTime ", BattleSpecialsTimes.ShroomsModeRespawnTime );
+ WriteParameter( file, "ElastoModeRespawnTime ", BattleSpecialsTimes.ElastoModeRespawnTime );
+ WriteParameter( file, "AsbestosVestRespawnTime ", BattleSpecialsTimes.AsbestosVestRespawnTime );
+ WriteParameter( file, "BulletProofVestRespawnTime ", BattleSpecialsTimes.BulletProofVestRespawnTime );
+ WriteParameter( file, "GasMaskRespawnTime ", BattleSpecialsTimes.GasMaskRespawnTime );
+ WriteParameter( file, "MercuryModeRespawnTime ", BattleSpecialsTimes.MercuryModeRespawnTime );
+
+ // Write out battlegibs
+ SafeWriteString(file, "\n;\n");
+ WriteParameter( file, "; Yes - ", 1 );
+ WriteParameter( file, "; No - ", 0 );
+ WriteParameter( file, "EKG ", battlegibs );
+
+ // Describe options
+
+ // Write out Gravity
+ SafeWriteString(file, "\n"
+ ";\n"
+ "; Here is a description of the possible values for"
+ " each option:\n"
+ ";\n"
+ "; Gravity options:\n" );
+ WriteParameter( file, "; Low Gravity - ", LOW_GRAVITY );
+ WriteParameter( file, "; Normal Gravity - ", NORMAL_GRAVITY );
+ WriteParameter( file, "; High Gravity - ", HIGH_GRAVITY );
+
+ // Write out Speed
+ SafeWriteString(file, ";\n"
+ "; Speed options:\n" );
+ WriteParameter( file, "; Normal Speed - ", bo_normal_speed );
+ WriteParameter( file, "; Fast Speed - ", bo_fast_speed );
+
+ // Write out Ammo
+ SafeWriteString(file, ";\n"
+ "; Ammo options:\n" );
+ WriteParameter( file, "; One Shot - ", bo_one_shot );
+ WriteParameter( file, "; Normal Shots - ", bo_normal_shots );
+ WriteParameter( file, "; Infinite Shots - ", bo_infinite_shots );
+
+ // Write out Hit Points
+ SafeWriteString(file, ";\n"
+ "; Hitpoint options:\n" );
+ WriteParameter( file, "; Character Hitpoints - ", bo_character_hitpoints );
+ WriteParameter( file, "; 1 Hitpoint - ", 1 );
+ WriteParameter( file, "; 25 Hitpoints - ", 25 );
+ WriteParameter( file, "; 100 Hitpoints - ", 100 );
+ WriteParameter( file, "; 500 Hitpoints - ", 500 );
+ WriteParameter( file, "; 250 Hitpoints - ", 250 );
+ WriteParameter( file, "; 4000 Hitpoints - ", 4000 );
+
+ // Write out Danger Spawning
+ SafeWriteString(file, ";\n"
+ "; SpawnDangers options:\n"
+ "; Spawn Dangers - 1\n"
+ "; Don't Spawn Dangers - 0\n" );
+
+ // Write out Health Spawning
+ SafeWriteString(file, ";\n"
+ "; SpawnHealth options:\n"
+ "; Spawn Health - 1\n"
+ "; Don't Spawn Health - 0\n" );
+
+ // Write out Mine Spawning
+ SafeWriteString(file, ";\n"
+ "; SpawnMines options:\n"
+ "; Spawn Mines - 1\n"
+ "; Don't Spawn Mines - 0\n" );
+
+ // Write out Weapon Spawning
+ SafeWriteString(file, ";\n"
+ "; SpawnWeapons options:\n"
+ "; Spawn Weapons - 1\n"
+ "; Don't Spawn Weapons - 0\n" );
+
+ // Write out Random Weapons
+ SafeWriteString(file, ";\n"
+ "; RandomWeapons options:\n"
+ "; Randomize Weapons - 1\n"
+ "; Don't Randomize Weapons - 0\n" );
+
+ // Write out Weapon Persistence
+ SafeWriteString(file, ";\n"
+ "; WeaponPersistence options:\n"
+ "; Weapons Persist - 1\n"
+ "; Weapons don't Persist - 0\n" );
+
+ // Write out Friendly Fire
+ SafeWriteString(file, ";\n"
+ "; FriendlyFire options:\n"
+ "; Penalize Friendly Fire - 1\n"
+ "; No penalty - 0\n" );
+
+ // Write out Respawn Items
+ SafeWriteString(file, ";\n"
+ "; RespawnItems options:\n"
+ "; Respawn Items - 1\n"
+ "; Don't Respawn Items - 0\n" );
+
+ // Write out Light Level
+ SafeWriteString(file, ";\n"
+ "; LightLevel options:\n" );
+ WriteParameter( file, "; Dark - ", bo_light_dark );
+ WriteParameter( file, "; Normal Light Levels - ", bo_light_normal );
+ WriteParameter( file, "; Bright - ", bo_light_bright );
+ WriteParameter( file, "; Fog - ", bo_light_fog );
+ WriteParameter( file, "; Periodic light - ", bo_light_periodic );
+ WriteParameter( file, "; Lightning - ", bo_light_lightning );
+
+ // Write out Point Goal
+ SafeWriteString(file, ";\n"
+ "; PointGoal options:\n" );
+ WriteParameter( file, "; 1 Point - ", 1 );
+ WriteParameter( file, "; 5 Points - ", 5 );
+ WriteParameter( file, "; 11 Points - ", 11 );
+ WriteParameter( file, "; 21 Points - ", 21 );
+ WriteParameter( file, "; 50 Points - ", 50 );
+ WriteParameter( file, "; 100 Points - ", 100 );
+ WriteParameter( file, "; Random Points - ", bo_kills_random );
+ WriteParameter( file, "; Blind Points - ", bo_kills_blind );
+ WriteParameter( file, "; Infinite Points - ", bo_kills_infinite );
+
+ // Write out Danger Damage
+ SafeWriteString(file, ";\n"
+ "; DangerDamage options:\n" );
+ WriteParameter( file, "; Normal Damage - ", bo_danger_normal );
+ WriteParameter( file, "; Low Damage - ", bo_danger_low );
+ WriteParameter( file, "; Kill - ", bo_danger_kill );
+
+ // Write out TimeLimit
+ SafeWriteString(file, ";\n"
+ "; TimeLimit options:\n" );
+ WriteParameter( file, "; 1 minute - ", 1 );
+ WriteParameter( file, "; 2 minute - ", 2 );
+ WriteParameter( file, "; 5 minutes - ", 5 );
+ WriteParameter( file, "; 10 minutes - ", 10 );
+ WriteParameter( file, "; 21 minutes - ", 21 );
+ WriteParameter( file, "; 30 minutes - ", 30 );
+ WriteParameter( file, "; 99 minutes - ", 99 );
+ WriteParameter( file, "; No limit - ", bo_time_infinite );
+
+ // Write out RespawnTime
+ SafeWriteString(file, ";\n"
+ "; RespawnTime options:\n" );
+ WriteParameter( file, "; 1 second - ", 1 );
+ WriteParameter( file, "; 1 minute - ", 60 );
+ WriteParameter( file, "; 2 minutes - ", 120 );
+ WriteParameter( file, "; normal - ", bo_normal_respawn_time );
+
+ for( index = battle_Normal; index < battle_NumBattleModes; index++ )
+ {
+ SafeWriteString(file, "\n;\n");
+ switch( index )
+ {
+ case battle_Normal :
+ SafeWriteString( file, "; Standard battle options\n;\n" );
+ break;
+
+ case battle_ScoreMore :
+ SafeWriteString( file, "; Score More battle options\n;\n" );
+ break;
+
+ case battle_Collector :
+ SafeWriteString( file, "; Collector battle options\n;\n" );
+ break;
+
+ case battle_Scavenger :
+ SafeWriteString( file, "; Scavenger battle options\n;\n" );
+ break;
+
+ case battle_Hunter :
+ SafeWriteString( file, "; Hunter battle options\n;\n" );
+ break;
+
+ case battle_Tag :
+ SafeWriteString( file, "; Tag battle options\n;\n" );
+ break;
+
+ case battle_Eluder :
+ SafeWriteString( file, "; Eluder battle options\n;\n" );
+ break;
+
+ case battle_Deluder :
+ SafeWriteString( file, "; Deluder battle options\n;\n" );
+ break;
+
+ case battle_CaptureTheTriad :
+ SafeWriteString( file, "; Capture the Triad battle options\n;\n" );
+ break;
+ }
+
+ // Write out Gravity
+ WriteParameter( file, "Gravity ",
+ BATTLE_Options[ index ].Gravity );
+
+ // Write out Speed
+ WriteParameter( file, "Speed ",
+ BATTLE_Options[ index ].Speed );
+
+ if ( ( index != battle_Collector ) && ( index != battle_Tag ) &&
+ ( index != battle_Eluder ) )
+ {
+ // Write out Ammo
+ WriteParameter( file, "Ammo ",
+ BATTLE_Options[ index ].Ammo );
+ }
+
+ if ( index != battle_Eluder )
+ {
+ // Write out Hit Points
+ WriteParameter( file, "Hitpoints ",
+ BATTLE_Options[ index ].HitPoints );
+ }
+
+ // Write out Danger Spawning
+ WriteParameter( file, "SpawnDangers ",
+ BATTLE_Options[ index ].SpawnDangers );
+
+ if ( index != battle_Eluder )
+ {
+ // Write out Health Spawning
+ WriteParameter( file, "SpawnHealth ",
+ BATTLE_Options[ index ].SpawnHealth );
+
+ // Write out Mine Spawning
+ WriteParameter( file, "SpawnMines ",
+ BATTLE_Options[ index ].SpawnMines );
+ }
+
+ if ( ( index != battle_Collector ) && ( index != battle_Tag ) &&
+ ( index != battle_Eluder ) )
+ {
+ // Write out Weapon Spawning
+ WriteParameter( file, "SpawnWeapons ",
+ BATTLE_Options[ index ].SpawnWeapons );
+
+ // Write out Random Weapons
+ WriteParameter( file, "RandomWeapons ",
+ BATTLE_Options[ index ].RandomWeapons );
+
+ // Write out Weapon Persistence
+ WriteParameter( file, "WeaponPersistence",
+ BATTLE_Options[ index ].WeaponPersistence );
+ }
+
+ if ( ( index == battle_Normal ) || ( index == battle_ScoreMore ) ||
+ ( index == battle_Hunter ) || ( index == battle_Tag ) )
+ {
+ // Write out Friendly Fire
+ WriteParameter( file, "FriendlyFire ",
+ BATTLE_Options[ index ].FriendlyFire );
+ }
+
+ if ( index != battle_Eluder )
+ {
+ // Write out Respawn Items
+ WriteParameter( file, "RespawnItems ",
+ BATTLE_Options[ index ].RespawnItems );
+ }
+
+ // Write out Light Level
+ WriteParameter( file, "LightLevel ",
+ BATTLE_Options[ index ].LightLevel );
+
+ if ( ( index != battle_Collector ) && ( index != battle_Scavenger ) )
+ {
+ // Write out Point Goal
+ WriteParameter( file, "PointGoal ",
+ BATTLE_Options[ index ].Kills );
+ }
+
+ if ( index != battle_Eluder )
+ {
+ // Write out Danger Damage
+ WriteParameter( file, "DangerDamage ",
+ BATTLE_Options[ index ].DangerDamage );
+ }
+
+ // Write out TimeLimit
+ WriteParameter( file, "TimeLimit ",
+ BATTLE_Options[ index ].TimeLimit );
+
+ // Write out RespawnTime
+ WriteParameter( file, "RespawnTime ",
+ BATTLE_Options[ index ].RespawnTime );
+ }
+
+ close( file );
+}
+
+#endif
+
+//******************************************************************************
+//
+// WriteSoundConfig ()
+//
+//******************************************************************************
+
+void WriteSoundConfig
+(
+ void
+)
+
+{
+ int file;
+ char filename[ 128 ];
+
+ if ( !WriteSoundFile )
+ {
+ return;
+ }
+
+ GetPathFromEnvironment( filename, ApogeePath, SoundName );
+ file = open ( filename, O_RDWR | O_TEXT | O_CREAT | O_TRUNC,
+ S_IREAD | S_IWRITE);
+
+ if (file == -1)
+ Error ("Error opening %s: %s", filename, strerror(errno));
+
+ // Write out ROTTSOUND header
+
+ SafeWriteString (file, ";Rise of the Triad Sound File\n");
+ SafeWriteString (file, "; (c) 1995\n\n");
+
+ // Write out Version
+
+ WriteParameter(file,"Version ",ROTTVERSION);
+
+ // Write out Music Mode
+
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file,"; Music Modes\n");
+ SafeWriteString(file,"; 0 - Off\n");
+#ifdef DOS
+ SafeWriteString(file,"; 1 - UltraSound\n");
+ SafeWriteString(file,"; 2 - Sound Blaster\n");
+ SafeWriteString(file,"; 3 - Sound Man 16\n");
+ SafeWriteString(file,"; 4 - Pro Audio Spectrum\n");
+ SafeWriteString(file,"; 5 - Awe32\n");
+ SafeWriteString(file,"; 6 - SoundScape\n");
+ SafeWriteString(file,"; 7 - Wave Blaster\n");
+ SafeWriteString(file,"; 8 - General Midi\n");
+ SafeWriteString(file,"; 9 - Sound Canvas\n");
+ SafeWriteString(file,"; 10 - Adlib\n");
+#else
+ SafeWriteString(file,"; 6 - On\n");
+#endif
+ WriteParameter(file,"MusicMode ",MusicMode);
+
+ // Write out FX Mode
+
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file,"; FX Modes\n");
+ SafeWriteString(file,"; 0 - Off\n");
+#ifdef DOS
+ SafeWriteString(file,"; 1 - UltraSound\n");
+ SafeWriteString(file,"; 2 - Sound Blaster\n");
+ SafeWriteString(file,"; 3 - Sound Man 16\n");
+ SafeWriteString(file,"; 4 - Pro Audio Spectrum\n");
+ SafeWriteString(file,"; 5 - Awe32\n");
+ SafeWriteString(file,"; 6 - SoundScape\n");
+ SafeWriteString(file,"; 7 - Adlib\n");
+ SafeWriteString(file,"; 8 - Disney Sound Source\n");
+ SafeWriteString(file,"; 9 - Tandy Sound Source\n");
+ SafeWriteString(file,"; 10 - PC Speaker\n");
+#else
+ SafeWriteString(file,"; 6 - On\n");
+#endif
+ WriteParameter(file,"FXMode ",FXMode);
+
+ // Write in Music Volume
+
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file,"; Music Volume\n");
+ SafeWriteString(file,"; (low) 0 - 255 (high)\n");
+ WriteParameter (file, "MusicVolume ", MUvolume);
+
+ // Write in FX Volume
+
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file,"; FX Volume\n");
+ SafeWriteString(file,"; (low) 0 - 255 (high)\n");
+ WriteParameter (file, "FXVolume ", FXvolume);
+
+ // Write out numvoices
+
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file,"; Number of Voices\n");
+ SafeWriteString(file,"; 1 - 8\n");
+ WriteParameter(file,"NumVoices ",NumVoices);
+
+ // Write out numchannels
+
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file,"; Stereo or Mono\n");
+ SafeWriteString(file,"; 1 - Mono\n");
+ SafeWriteString(file,"; 2 - Stereo\n");
+ WriteParameter(file,"NumChannels ",NumChannels);
+
+ // Write out numbits
+
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file,"; Resolution\n");
+ SafeWriteString(file,"; 8 bit\n");
+ SafeWriteString(file,"; 16 bit\n");
+ WriteParameter(file,"NumBits ",NumBits);
+
+#ifdef DOS
+ // Write out Midi Address
+
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file,"; Midi Addresses\n");
+ SafeWriteString(file,"; $300\n");
+ SafeWriteString(file,"; $310\n");
+ SafeWriteString(file,"; $320\n");
+ SafeWriteString(file,"; $330\n");
+ SafeWriteString(file,"; $340\n");
+ SafeWriteString(file,"; $350\n");
+ SafeWriteString(file,"; $360\n");
+ SafeWriteString(file,"; $370\n");
+ SafeWriteString(file,"; $380\n");
+ WriteParameterHex(file,"MidiAddress ",MidiAddress);
+#endif
+
+ // Write out stereo reversal
+
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file,"; ReverseStereo\n");
+ SafeWriteString(file,"; 0 no reversal\n");
+ SafeWriteString(file,"; 1 reverse stereo\n");
+ WriteParameter (file,"StereoReverse ",stereoreversed);
+
+#ifdef DOS
+ // Write out Sound Blaster info
+
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file,"; Sound Blaster Settings\n");
+ WriteParameter(file, "SBType ", SBSettings.Type );
+ WriteParameterHex(file, "SBPort ", SBSettings.Address );
+ WriteParameter(file, "SBIrq ", SBSettings.Interrupt );
+ WriteParameter(file, "SBDma8 ", SBSettings.Dma8 );
+ WriteParameter(file, "SBDma16 ", SBSettings.Dma16 );
+ WriteParameterHex(file, "SBMidi ", SBSettings.Midi );
+ WriteParameterHex(file, "SBEmu ", SBSettings.Emu );
+#endif
+
+ close (file);
+}
+
+
+//******************************************************************************
+//
+// WriteConfig ()
+//
+//******************************************************************************
+
+extern boolean writeNewResIntoCfg;
+extern int ScreenWidthToWriteToCfg;
+extern int ScreenHeightToWriteToCfg;
+
+void WriteConfig (void)
+{
+ int file;
+ char filename[ 128 ];
+ char passwordtemp[50];
+ static int inconfig = 0;
+
+ if (inconfig > 0)
+ return;
+
+ inconfig++ ;
+
+ if ( !ConfigLoaded )
+ {
+ return;
+ }
+
+ // Write Sound File
+ WriteSoundConfig();
+
+ // Write Config, Battle and Score files
+#ifdef _ROTT_
+ WriteScores();
+ WriteBattleConfig();
+
+ GetPathFromEnvironment( filename, ApogeePath, ConfigName );
+ file = open( filename,O_RDWR | O_TEXT | O_CREAT | O_TRUNC
+ , S_IREAD | S_IWRITE);
+
+ if (file == -1)
+ Error ("Error opening %s: %s",filename,strerror(errno));
+
+ // Write out ROTTCONFIG header
+
+ SafeWriteString (file, ";Rise of the Triad Configuration File\n");
+ SafeWriteString (file, "; (c) 1995\n\n");
+
+ // Write out Version
+
+ WriteParameter(file,"Version ",ROTTVERSION);
+
+ //Write out AllowBlitzguardMoreMissileWeps
+
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file, "; 1 - Allows Blitzguards to have Random Missile weapons\n");
+ SafeWriteString(file, "; 0 - Disallows the above (ROTT Default)\n");
+ WriteParameter(file, "AllowBlitzguardMoreMissileWeps ", allowBlitzMoreMissileWeps);
+
+ //Write out enableAmmoPickups
+
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file, "; 1 - Allows players to refill their missile weapons by running over one a matching one on the ground\n");
+ SafeWriteString(file, "; 0 - Disables the above (ROTT default)\n");
+ WriteParameter(file, "EnableAmmoPickups ", enableAmmoPickups);
+
+ //Write out autoAim
+
+ SafeWriteString(file, "\n;\n");
+ SafeWriteString(file, "; 1 - Bullet weapons will automatically target enemies. (ROTT default)\n");
+ SafeWriteString(file, "; 0 - Disables the above.\n");
+ WriteParameter(file, "AutoAim ", autoAim);
+
+ //Write out autoAimMissileWeps
+
+ SafeWriteString(file, "\n;\n");
+ SafeWriteString(file, "; 1 - Missile weapons will be automatically aimed at targets like bullet weapons.\n");
+ SafeWriteString(file, "; 0 - Missile weapons are not automatically aimed at targets. (ROTT default)\n");
+ WriteParameter(file, "AutoAimMissileWeps ", autoAimMissileWeps);
+
+ //Write out enableExtraPistolDrops
+
+ SafeWriteString(file, "\n;\n");
+ SafeWriteString(file, "; 1 - Enemies equipped with pistols have a chance of dropping an extra pistol when killed.\n");
+ SafeWriteString(file, "; 0 - Enemies will not drop extra pistols at all. (Default)\n");
+ WriteParameter(file, "EnableExtraPistolDrops ", enableExtraPistolDrops);
+
+ //Write out scaleOffset
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file,"; Field Of View offset\n");
+ WriteParameter(file,"FocalWidthOffset ",FocalWidthOffset);
+
+ // Write out MouseEnabled
+
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file,"; 1 - Mouse Enabled\n");
+ SafeWriteString(file,"; 0 - Mouse Disabled\n");
+ WriteParameter(file,"MouseEnabled ",mouseenabled);
+
+ // Write out UseMouseLook
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file,"; 1 - UseMouseLook Enabled\n");
+ SafeWriteString(file,"; 0 - UseMouseLook Disabled\n");
+ WriteParameter(file,"UseMouseLook ",usemouselook);
+
+ // Write out InverseMouse
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file,"; 1 - Normal Mouse Enabled\n");
+ SafeWriteString(file,"; -1 - Inverse Mouse Enabled\n");
+ WriteParameter(file,"InverseMouse ",inverse_mouse);
+
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file,"; 1 - Allows X and Y movement with Mouse. (Default)\n");
+ SafeWriteString(file,"; 0 - Allow only X movement with Mouse.\n");
+ WriteParameter(file,"allowMovementWithMouseYAxis ",allowMovementWithMouseYAxis);
+
+ // Write out UseJump
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file,"; 1 - usejump Enabled\n");
+ SafeWriteString(file,"; 0 - usejump Disabled\n");
+ WriteParameter(file,"UseJump ",usejump);
+
+ // Write out CrossHair
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file,"; 1 - CrossHair Enabled\n");
+ SafeWriteString(file,"; 0 - CrossHair Disabled\n");
+ WriteParameter(file,"CrossHair ", iG_aimCross);
+
+ // Write out JoystickEnabled
+
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file,"; 1 - Joystick Enabled\n");
+ SafeWriteString(file,"; 0 - Joystick Disabled\n");
+ WriteParameter(file,"JoystickEnabled ",joystickenabled);
+
+ // Write out JoypadEnabled
+
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file,"; 1 - Joypad Enabled\n");
+ SafeWriteString(file,"; 0 - Joypad Disabled\n");
+ WriteParameter(file,"JoypadEnabled ",joypadenabled);
+
+ // Write out JoystickPort
+
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file,"; 0 - Use Joystick Port 1\n");
+ SafeWriteString(file,"; 1 - Use Joystick Port 2\n");
+ WriteParameter(file,"JoystickPort ",joystickport);
+
+ // Write out fullscreen
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file,"; 0 - Start in windowed mode\n");
+ SafeWriteString(file,"; 1 - Start in fullscreen mode\n");
+ WriteParameter(file,"FullScreen ",sdl_fullscreen);
+
+ // Write out resolution
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file,"; Screen Resolution, supported resolutions: \n");
+ SafeWriteString(file,"; 320x200, 640x480 and 800x600\n");
+
+ //WriteParameter(file,"ScreenWidth ",iGLOBAL_SCREENWIDTH);
+ //WriteParameter(file,"ScreenHeight ",iGLOBAL_SCREENHEIGHT);
+
+ if (writeNewResIntoCfg)
+ {
+ WriteParameter(file,"ScreenWidth ",ScreenWidthToWriteToCfg);
+ WriteParameter(file,"ScreenHeight ",ScreenHeightToWriteToCfg);
+ }
+ else
+ {
+ WriteParameter(file,"ScreenWidth ",iGLOBAL_SCREENWIDTH);
+ WriteParameter(file,"ScreenHeight ",iGLOBAL_SCREENHEIGHT);
+ }
+
+
+ // Write out ViewSize
+
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file,"; Size of View port.\n");
+ SafeWriteString(file,"; (smallest) 0 - 10 (largest)\n");
+ WriteParameter(file,"ViewSize ",viewsize);
+
+ // Write out WEAPONSCALE bna added
+
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file,"; Size of Weaponscale.\n");
+ SafeWriteString(file,"; (smallest) 150 - 600 (largest)\n");
+ G_weaponscale = (weaponscale * 168 )/65536;
+
+ if ((G_weaponscale <150)||(G_weaponscale>600)) {
+ if (iGLOBAL_SCREENWIDTH == 320) {
+ G_weaponscale=168;
+ } else if (iGLOBAL_SCREENWIDTH == 640) {
+ G_weaponscale=299;
+ } else if (iGLOBAL_SCREENWIDTH == 800) {
+ G_weaponscale=376;
+ }
+ else if (iGLOBAL_SCREENWIDTH == 1024)
+ {
+ G_weaponscale=512;
+ }
+ }
+ WriteParameter(file,"Weaponscale ",G_weaponscale);
+
+
+ // Write out MouseAdjustment
+
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file,"; Sensitivity of Mouse\n");
+ SafeWriteString(file,"; (lowest) 0 - 11 (highest)\n");
+ WriteParameter(file,"MouseAdjustment ",mouseadjustment);
+
+ // Write out threshold
+
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file,"; Threshold of Mouse and Joystick\n");
+ SafeWriteString(file,"; (smallest) 1 - 15 (largest)\n");
+ WriteParameter(file,"Threshold ",threshold);
+
+ // Write in Cyberman Enabled
+
+// SafeWriteString(file,"\n;\n");
+// SafeWriteString(file,"; 1 - Cyberman Enabled\n");
+// SafeWriteString(file,"; 0 - Cyberman Disabled\n");
+// WriteParameter(file,"CybermanEnabled ",cybermanenabled);
+
+ // Write in Spaceball Enabled
+
+// SafeWriteString(file,"\n;\n");
+// SafeWriteString(file,"; 1 - Spaceball Enabled\n");
+// SafeWriteString(file,"; 0 - Spaceball Disabled\n");
+// WriteParameter(file,"SpaceballEnabled ",spaceballenabled);
+
+ // Write in Auto Detail
+
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file,"; 1 - Auto Detail on\n");
+ SafeWriteString(file,"; 0 - Auto Detail off\n");
+ WriteParameter (file,"AutoDetail ", AutoDetailOn);
+
+ // Write in Light Dim
+
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file,"; 1 - Light Diminishing on\n");
+ SafeWriteString(file,"; 0 - Light Diminishing off\n");
+ WriteParameter (file,"LightDim ", fulllight);
+
+ // Write in Bobbin' On
+
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file,"; 1 - Bobbing on\n");
+ SafeWriteString(file,"; 0 - Bobbing off\n");
+ WriteParameter (file,"BobbingOn ", BobbinOn);
+
+ // Write in Double Click Speed
+
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file,"; (slowest) 50 - 5 (fastest)\n");
+ WriteParameter (file,"DoubleClickSpeed ", DoubleClickSpeed);
+
+ // Write in Menu Flip Speed
+
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file,"; Menu Flip Speed\n");
+ SafeWriteString(file,"; (slowest) 100 - 5 (fastest)\n");
+ WriteParameter (file,"MenuFlipSpeed ", Menuflipspeed);
+
+ // Write in Detail Level
+
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file,"; 0 - Detail Level Low\n");
+ SafeWriteString(file,"; 1 - Detail Level Medium\n");
+ SafeWriteString(file,"; 2 - Detail Level High\n");
+ WriteParameter (file,"DetailLevel ", DetailLevel);
+
+ // Write in Floor and Ceiling
+
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file,"; 1 - Floor and Ceiling on\n");
+ SafeWriteString(file,"; 0 - Floor and Ceiling off\n");
+ WriteParameter (file,"FloorCeiling ", fandc);
+
+ // Write in DisableMessages
+
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file,"; 1 - Messages on\n");
+ SafeWriteString(file,"; 0 - Messages off\n");
+ WriteParameter (file,"Messages ", MessagesEnabled );
+
+ // Write in AutoRun
+
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file,"; 1 - AutoRun on\n");
+ SafeWriteString(file,"; 0 - AutoRun off\n");
+ WriteParameter (file,"AutoRun ", gamestate.autorun );
+
+ // Write in GammaIndex
+
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file,"; 0 - Gamma Correction level 1\n");
+ SafeWriteString(file,"; 1 - Gamma Correction level 2\n");
+ SafeWriteString(file,"; 2 - Gamma Correction level 3\n");
+ SafeWriteString(file,"; 3 - Gamma Correction level 4\n");
+ SafeWriteString(file,"; 4 - Gamma Correction level 5\n");
+ WriteParameter (file,"GammaIndex ", gammaindex);
+
+ // Write out screen saver time
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file,"; Minutes before screen blanking\n");
+ WriteParameter (file,"BlankTime ", blanktime/(VBLCOUNTER*60));
+
+
+ // Write out keys
+
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file,"; Scan codes for keyboard buttons\n");
+ WriteParameter (file,"Fire ", buttonscan[0]);
+ WriteParameter (file,"Strafe ", buttonscan[1]);
+ WriteParameter (file,"Run ", buttonscan[2]);
+ WriteParameter (file,"Use ", buttonscan[3]);
+ WriteParameter (file,"LookUp ", buttonscan[4]);
+ WriteParameter (file,"LookDn ", buttonscan[5]);
+ WriteParameter (file,"Swap ", buttonscan[6]);
+ WriteParameter (file,"Drop ", buttonscan[7]);
+ WriteParameter (file,"TargetUp ", buttonscan[8]);
+ WriteParameter (file,"TargetDn ", buttonscan[9]);
+ WriteParameter (file,"SelPistol ", buttonscan[10]);
+ WriteParameter (file,"SelDualPistol ", buttonscan[11]);
+ WriteParameter (file,"SelMP40 ", buttonscan[12]);
+ WriteParameter (file,"SelMissile ", buttonscan[13]);
+ WriteParameter (file,"AutoRun ", buttonscan[14]);
+ WriteParameter (file,"LiveRemRid ", buttonscan[15]);
+ WriteParameter (file,"StrafeLeft ", buttonscan[16]);
+ WriteParameter (file,"StrafeRight ", buttonscan[17]);
+ WriteParameter (file,"VolteFace ", buttonscan[18]);
+ WriteParameter (file,"Aim ", buttonscan[19]);
+ WriteParameter (file,"Forward ", buttonscan[20]);
+ WriteParameter (file,"Right ", buttonscan[21]);
+ WriteParameter (file,"Backward ", buttonscan[22]);
+ WriteParameter (file,"Left ", buttonscan[23]);
+ WriteParameter (file,"Map ", buttonscan[24]);
+ WriteParameter (file,"SendMessage ", buttonscan[25]);
+ WriteParameter (file,"DirectMessage ", buttonscan[26]);
+
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file,"; Mouse buttons\n");
+
+ WriteParameter (file,"MouseButton0 ", buttonmouse[0]);
+ WriteParameter (file,"MouseButton1 ", buttonmouse[1]);
+ WriteParameter (file,"MouseButton2 ", buttonmouse[2]);
+ WriteParameter (file,"DblClickB0 ", buttonmouse[3]);
+ WriteParameter (file,"DblClickB1 ", buttonmouse[4]);
+ WriteParameter (file,"DblClickB2 ", buttonmouse[5]);
+
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file,"; Joystick buttons\n");
+
+ WriteParameter (file,"JoyButton0 ", buttonjoy[0]);
+ WriteParameter (file,"JoyButton1 ", buttonjoy[1]);
+ WriteParameter (file,"JoyButton2 ", buttonjoy[2]);
+ WriteParameter (file,"JoyButton3 ", buttonjoy[3]);
+ WriteParameter (file,"DblClickJB0 ", buttonjoy[4]);
+ WriteParameter (file,"DblClickJB1 ", buttonjoy[5]);
+ WriteParameter (file,"DblClickJB2 ", buttonjoy[6]);
+ WriteParameter (file,"DblClickJB3 ", buttonjoy[7]);
+
+ SafeWriteString(file,"\n;\n");
+ SafeWriteString(file,"; Joystick calibration coordinates\n");
+
+ WriteParameter (file,"JoyMaxX ", joyxmax);
+ WriteParameter (file,"JoyMaxY ", joyymax);
+ WriteParameter (file,"JoyMinX ", joyxmin);
+ WriteParameter (file,"JoyMinY ", joyymin);
+
+ // Write out DefaultDifficulty
+ SafeWriteString(file,"\n;\n");
+ WriteParameter(file,"; Easy - ", gd_baby );
+ WriteParameter(file,"; Medium - ", gd_easy );
+ WriteParameter(file,"; Hard - ", gd_medium );
+ WriteParameter(file,"; Crezzy - ", gd_hard );
+ WriteParameter(file,"DefaultDifficulty ", DefaultDifficulty );
+
+ // Write out DefaultPlayerCharacter
+ SafeWriteString(file,"\n;\n");
+ WriteParameter(file,"; Taradino Cassatt - ", 0 );
+ WriteParameter(file,"; Thi Barrett - ", 1 );
+ WriteParameter(file,"; Doug Wendt - ", 2 );
+ WriteParameter(file,"; Lorelei Ni - ", 3 );
+ WriteParameter(file,"; Ian Paul Freeley - ", 4 );
+ WriteParameter(file,"DefaultPlayerCharacter ", DefaultPlayerCharacter );
+
+ // Write out DefaultPlayerColor
+ SafeWriteString(file,"\n;\n");
+ WriteParameter(file,"; Gray - ", 0 );
+ WriteParameter(file,"; Brown - ", 1 );
+ WriteParameter(file,"; Black - ", 2 );
+ WriteParameter(file,"; Tan - ", 3 );
+ WriteParameter(file,"; Red - ", 4 );
+ WriteParameter(file,"; Olive - ", 5 );
+ WriteParameter(file,"; Blue - ", 6 );
+ WriteParameter(file,"; White - ", 7 );
+ WriteParameter(file,"; Green - ", 8 );
+ WriteParameter(file,"; Purple - ", 9 );
+ WriteParameter(file,"; Orange - ", 10 );
+ WriteParameter(file,"DefaultPlayerColor ", DefaultPlayerColor );
+
+ // Writeout password Password string
+ SafeWriteString(file,"\n;\nSecretPassword ");
+ memset(passwordtemp,0,sizeof(passwordtemp));
+ ConvertPasswordStringToString ( &passwordtemp[0] );
+ SafeWriteString(file,&passwordtemp[0]);
+
+ close (file);
+#endif
+ inconfig--;
+}
+
+#ifdef _ROTT_
+
+
+//****************************************************************************
+//
+// GetAlternatePath ()
+//
+//****************************************************************************
+
+void GetAlternatePath (char * tokenstr, AlternateInformation *info)
+{
+ strcpy (&info->path[0], ".\0");
+ GetToken (true);
+ if (!stricmp (token, tokenstr))
+ {
+ GetTokenEOL (false);
+ memset (&info->path[0], 0, sizeof (info->path));
+ strcpy (&info->path[0], &name[0]);
+ }
+}
+
+
+//****************************************************************************
+//
+// GetAlternateFile ()
+//
+//****************************************************************************
+
+void GetAlternateFile (char * tokenstr, AlternateInformation *info)
+{
+ // Read in remote sound file
+ //
+ strcpy (&info->file[0], "foo.foo\0");
+ GetToken (true);
+ if (!stricmp (token, tokenstr))
+ {
+ if (TokenAvailable()==true)
+ {
+ GetToken (false);
+ if (stricmp (token, "~"))
+ {
+#if (SHAREWARE == 0)
+ info->avail = true;
+ memset (&info->file[0], 0, sizeof (info->file));
+ strcpy (&info->file[0], &token[0]);
+#else
+ printf("Alternate file %s ignored.\n",token);
+ memset (&info->file[0], 0, sizeof (info->file));
+#endif
+ }
+ }
+ }
+}
+
+
+//****************************************************************************
+//
+// ReadSETUPFiles ()
+//
+//****************************************************************************
+
+void ReadSETUPFiles (void)
+{
+ char filename[ 128 ];
+ int i;
+
+ RemoteSounds.avail = false;
+// PlayerGraphics.avail = false;
+ GameLevels.avail = false;
+ BattleLevels.avail = false;
+
+ GetPathFromEnvironment( filename, ApogeePath, CONFIG );
+ if (access (filename, F_OK) == 0)
+ {
+ LoadScriptFile (filename);
+
+ GetTokenEOL (true); //MODEMNAME
+ GetTokenEOL (true); //MODEMINITSTR
+ GetTokenEOL (true); //MODEMHANGUP
+ GetTokenEOL (true); //RATE
+ GetTokenEOL (true); //COMPORT
+ GetTokenEOL (true); //IRQ
+ GetTokenEOL (true); //UART
+ GetTokenEOL (true); //PULSE
+ GetTokenEOL (true); //AUTOMATICDIALOUT
+
+ GetAlternatePath ("REMOTESOUNDPATH", &RemoteSounds);
+// GetAlternatePath ("PLAYERGRAPHICSPATH", &PlayerGraphics);
+ GetAlternatePath ("GAMELEVELPATH", &GameLevels);
+ GetAlternatePath ("BATTLELEVELPATH", &BattleLevels);
+
+ // Get CodeName
+ GetToken (true);
+ if (stricmp (token, "CODENAME"))
+ Error ("Can't find %s token.\n", "CODENAME");
+
+ GetTokenEOL (false);
+ memset (&CodeName[0], 0, sizeof (CodeName));
+ if (stricmp (name, "~"))
+ {
+
+ // Get First (MAXCODENAMELENGTH-1) characters
+ for (i=0; i<MAXCODENAMELENGTH-1; i++)
+ CodeName[i]=name[i];
+ }
+ GetTokenEOL (true); //NUMPLAYERS
+ GetTokenEOL (true); //NETWORKSOCKET
+ GetTokenEOL (true); //DEFAULT
+ for (i=0; i<14; i++)
+ GetTokenEOL (true); //NUMBERLIST
+
+ memset (CommbatMacros, 0, sizeof(CommbatMacros) );
+
+ for (i=0; i<MAXMACROS; i++)
+ {
+ GetToken (true);
+
+ GetTokenEOL (true);
+
+ if (name[0] != '~')
+ {
+ memcpy (&CommbatMacros[i].macro[0], &name[0], strlen (name));
+ CommbatMacros[i].avail = 1;
+ }
+ }
+
+ Z_Free (scriptbuffer);
+ }
+
+ GetPathFromEnvironment( filename, ApogeePath, ROTT );
+ if (access (filename, F_OK) == 0)
+ {
+ LoadScriptFile (filename);
+
+ GetTokenEOL (true); //PHONENUMBER
+
+ GetAlternateFile ("REMOTESOUNDFILE", &RemoteSounds);
+// GetAlternateFile ("PLAYERGRAPHICSFILE", &PlayerGraphics);
+ GetAlternateFile ("GAMELEVELFILE", &GameLevels);
+ GetAlternateFile ("COMMBATLEVELFILE", &BattleLevels);
+
+ Z_Free (scriptbuffer);
+
+ unlink (filename); // Delete ROTT.ROT
+ }
+}
+
+#endif
+
--- a/rott/rt_debug.c
+++ b/rott/rt_debug.c
@@ -49,6 +49,8 @@
extern int iDemoNames;
extern boolean iG_aimCross;
+boolean ricochetingRocketsEnabled = false;
+
extern void DisplayMessage (int num,int position);
--- a/rott/rt_draw.c
+++ b/rott/rt_draw.c
@@ -3041,8 +3041,7 @@
dy=(-y)/time;
ds=-((s-0x1000000)/time);
- destscreen=SafeMalloc(64000*8);//bna fixme
-
+ destscreen=SafeMalloc(iGLOBAL_SCREENWIDTH*iGLOBAL_SCREENHEIGHT);
SetupScreen(false);
ThreeDRefresh();
@@ -3094,8 +3093,8 @@
// int Xres = 320;//org
// int Yres = 200;//org
- int Xres = iGLOBAL_SCREENWIDTH;//bna val 800
- int Yres = iGLOBAL_SCREENHEIGHT;//bna val 600
+ int Xres = iGLOBAL_SCREENWIDTH;
+ int Yres = iGLOBAL_SCREENHEIGHT;
iG_masked = masked;
@@ -3107,6 +3106,13 @@
// RotatedImage=SafeMalloc(131072);org
//RotatedImage=SafeMalloc(131072*8);
+
+
+ int amountToAlloc = ((iGLOBAL_SCREENWIDTH * iGLOBAL_SCREENHEIGHT)*2) + 3072; //this replaces 131072
+
+ RotatedImage = SafeMalloc(amountToAlloc);
+
+/*
if (iGLOBAL_SCREENWIDTH == 320) {
RotatedImage=SafeMalloc(131072);
} else if (iGLOBAL_SCREENWIDTH == 640) {
@@ -3114,9 +3120,30 @@
} else if (iGLOBAL_SCREENWIDTH == 800) {
RotatedImage=SafeMalloc(131072*8);
}
+ else if (iGLOBAL_SCREENWIDTH == 1024)
+ {
+ RotatedImage=SafeMalloc(131072*14);
+ }
+ else if (iGLOBAL_SCREENWIDTH == 1280)
+ {
+ RotatedImage=SafeMalloc(131072*20);
+ }
+ else if (iGLOBAL_SCREENWIDTH == 1400)
+ {
+ RotatedImage=SafeMalloc(131072*20);
+ }
+ else if (iGLOBAL_SCREENWIDTH == 1920)
+ {
+ RotatedImage=SafeMalloc(131072*50);
+ }
+*/
//SetupScreen(false);//used these 2 to test screen size
//VW_UpdateScreen ();
- if (masked==0) {
+ if (masked==0)
+ memset(RotatedImage, 0, amountToAlloc);
+ else
+ memset(RotatedImage, 0xff, amountToAlloc);
+/*
if (iGLOBAL_SCREENWIDTH == 320) {
memset(RotatedImage,0,131072);
} else if (iGLOBAL_SCREENWIDTH == 640) {
@@ -3124,7 +3151,21 @@
} else if (iGLOBAL_SCREENWIDTH == 800) {
//memset(RotatedImage,0,131072);//org
memset(RotatedImage,0,131072*8);
+ }else if (iGLOBAL_SCREENWIDTH == 1024) {
+ memset(RotatedImage,0,131072*14);
}
+ else if (iGLOBAL_SCREENWIDTH == 1280)
+ {
+ memset(RotatedImage, 0, 131072*20);
+ }
+ else if (iGLOBAL_SCREENWIDTH == 1400)
+ {
+ memset(RotatedImage, 0, 131072*20);
+ }
+ else if (iGLOBAL_SCREENWIDTH == 1920)
+ {
+ memset(RotatedImage, 0, 131072*50);
+ }
} else {
if (iGLOBAL_SCREENWIDTH == 320) {
memset(RotatedImage,0xff,131072);
@@ -3133,11 +3174,27 @@
} else if (iGLOBAL_SCREENWIDTH == 800) {
memset(RotatedImage,0xff,131072*8);
}
- }
+ else if (iGLOBAL_SCREENWIDTH == 1024) {
+ memset(RotatedImage,0xff,131072*14);
+ }
+ else if (iGLOBAL_SCREENWIDTH == 1280)
+ {
+ memset(RotatedImage, 0xff, 131072*20);
+ }
+ else if (iGLOBAL_SCREENWIDTH == 1400)
+ {
+ memset(RotatedImage, 0xff, 131072*20);
+ }
+ else if (iGLOBAL_SCREENWIDTH == 1920)
+ {
+ memset(RotatedImage, 0xff, 131072*50);
+ }
+*/
+
//memset(RotatedImage,0xff,131072);//org
//memset(RotatedImage,0xff,131072*8);
- if ((masked == false)&&(iGLOBAL_SCREENWIDTH == 800)) {
+ if ((masked == false)&&(iGLOBAL_SCREENWIDTH >= 800)) {
DisableScreenStretch();
// SetTextMode ( );
@@ -3266,8 +3323,10 @@
//
//******************************************************************************
+extern boolean skipRotate;
+
void RotateBuffer (int startangle, int endangle, int startscale, int endscale, int time)
-{
+{
int savetics;
//save off fastcounter
@@ -3323,12 +3382,16 @@
xst = (((-cx)*s)+((328)<<16))-(cy*c);
xct = (((-cx)*c)+((397)<<16)+(1<<18)-(1<<16))+(cy*s);
}//328 397
+ else if ((iGLOBAL_SCREENWIDTH >= 1024 )&&(masked == false)) {
+ xst = (((-cx)*s)+((410)<<16))-(cy*c);// 1024/768=1.3333
+ xct = (((-cx)*c)+((500)<<16)+(1<<18)-(1<<16))+(cy*s);
+ }//388 397
mr_xstep=s;
mr_ystep=c;
- if ((iGLOBAL_SCREENWIDTH == 800)&&(masked==0)) {
+ if ((iGLOBAL_SCREENWIDTH >= 800)&&(masked==0)) {
screen=destscreen+iGLOBAL_SCREENWIDTH;//bna aaaa fix
} else {
screen=destscreen;
@@ -5942,9 +6005,6 @@
ecx += mr_ystep;
}
} else if (iGLOBAL_SCREENWIDTH == 800) {
-
-
-
srctmp = src;
desttmp = dest;
@@ -5984,6 +6044,57 @@
ecx += mr_ystep;
}
+ }
+ else if (iGLOBAL_SCREENWIDTH >= 1024) {
+ srctmp = src;
+ desttmp = dest;
+
+ desttmp -= (iGLOBAL_SCREENWIDTH*1);
+
+/*
+ ecx = mr_yfrac;
+ edx = mr_xfrac;
+*/
+ while (count--) {
+ eax = edx >> 16;
+ if (eax < (256*3.1) && (ecx >> 16) < (512*2.0)) {
+ eax = (eax << 10) | ((ecx << 6) >> (32-10));
+ } else {
+ eax = 0;
+ }
+
+ *desttmp++ = srctmp[eax];
+
+ edx += mr_xstep;
+ ecx += mr_ystep;
+ }
+ }
+ else
+ {
+ srctmp = src;
+ desttmp = dest;
+
+ desttmp -= (iGLOBAL_SCREENWIDTH*1);
+
+/*
+ ecx = mr_yfrac;
+ edx = mr_xfrac;
+*/
+ while (count--) {
+ eax = edx >> 16;
+ if (eax < (256*(iGLOBAL_SCREENWIDTH/320)) && (ecx >> 16) < (512*((iGLOBAL_SCREENWIDTH/320 + iGLOBAL_SCREENHEIGHT/200)<<1))) {
+ eax = (eax << 10) | ((ecx << 6) >> (32-10));
+ } else {
+ eax = 0;
+ }
+
+ *desttmp++ = srctmp[eax];
+
+ edx += mr_xstep;
+ ecx += mr_ystep;
+ }
+
+
}
}
--- a/rott/rt_floor.c
+++ b/rott/rt_floor.c
@@ -76,7 +76,7 @@
static byte *floor;
static byte *ceiling;
//static int xstarts[MAXVIEWHEIGHT];
-static int xstarts[600];//set to max hight res
+static int xstarts[MAXSCREENHEIGHT];//set to max hight res
static byte * skysegs[MAXSKYSEGS];
static byte * skydata[MAXSKYDATA];
static int horizonheight;
@@ -274,7 +274,7 @@
byte * ptr;
int c;
- temp=SafeMalloc(256*800);
+ temp=SafeMalloc(256*1024);
ptr=temp;
--- a/rott/rt_game.c
+++ b/rott/rt_game.c
@@ -1,5729 +1,5746 @@
-/*
-Copyright (C) 1994-1995 Apogee Software, Ltd.
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
-See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-*/
-
-#ifdef DOS
-#include <dos.h>
-#include <io.h>
-#include <conio.h>
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <ctype.h>
-
-#include "rt_def.h"
-#include "rt_main.h"
-#include "rt_game.h"
-#include "_rt_game.h"
-#include "rt_menu.h"
-#include "z_zone.h"
-#include "w_wad.h"
-#include "lumpy.h"
-#include "rt_playr.h"
-#include "rt_util.h"
-#include "rt_ted.h"
-#include "rt_draw.h"
-#include "rt_view.h"
-#include "rt_vid.h"
-#include "rt_door.h"
-#include "rt_in.h"
-#include "rt_str.h"
-#include "isr.h"
-#include "rt_build.h"
-#include "rt_rand.h"
-#include "rt_cfg.h"
-#include "rt_sound.h"
-#include "version.h"
-#include "rt_crc.h"
-#include "modexlib.h"
-#include "engine.h"
-#include "gmove.h"
-#include "rt_com.h"
-#include "rt_net.h"
-#include "watcom.h"
-#include "rt_floor.h"
-#include "rt_msg.h"
-#include "rt_scale.h"
-#include "develop.h"
-//MED
-#include "memcheck.h"
-
-#if (SHAREWARE == 1)
-#define NUMAMMOGRAPHICS 10
-#else
-#define NUMAMMOGRAPHICS 20
-#endif
-
-//******************************************************************************
-//
-// GLOBALS
-//
-//******************************************************************************
-
-int PlayerSnds[5] = {SD_PLAYERTCSND, SD_PLAYERTBSND, SD_PLAYERDWSND,
- SD_PLAYERLNSND, SD_PLAYERIPFSND
- };
-
-
-unsigned short SHAKETICS = 0xFFFF;//bna++
-//int SHAKETICS = 0xFFFF;
-int damagecount = 0;
-HighScore Scores[MaxScores] =
-{
- {"Tom",70000,7,1},
- {"Chuck",60000,6,1},
- {"Mark",50000,5,1},
- {"The Joes",40000,4,1},
- {"William",30000,3,1},
- {"Jim",20000,2,1},
- {"Steve",10000,1,1},
-};
-
-//******************************************************************************
-//
-// LOCALS
-//
-//******************************************************************************
-
-static int KeyX[4] = {KEY1_X, KEY2_X, KEY3_X, KEY4_X};
-
-static const char *Names[ 5 ] =
-{
- "Taradino", "Thi", "Doug", "Lorelei", "Ian Paul"
-};
-
-static const char *LastNames[ 5 ] =
-{
- "Cassatt", "Barrett", "Wendt", "Ni", "Freeley"
-};
-
-static STR ScoreStr;
-static STR LivesStr;
-static STR TriadStr;
-static STR KillStr;
-
-static pic_t *lifeptnums[10];
-static pic_t *lifenums[10];
-static pic_t *timenums[10];
-static pic_t *scorenums[10];
-static pic_t *keys[4];
-static pic_t *men[5];
-
-static pic_t *health[6];
-static pic_t *ammo[26];
-static pic_t *erase;
-static pic_t *eraseb;
-static pic_t *fragpic[ 5 ];
-static pic_t *frag100pic[ 5 ];
-static pic_t *negfragpic[ 5 ];
-static pic_t *menneg[ 5 ];
-static pic_t *blankfragpic;
-
-static int powerpics;
-static int poweradjust;
-
-static int poweruptime;
-static int powerupheight;
-static int protectiontime;
-static int protectionheight;
-
-
-static boolean EndLevelStuff = false;
-static boolean borderset = false;
-static int oldsec = -1;
-
-static pic_t *BkPic;
-int SaveTime = 0;
-int oldhealth;
-
-static int oldplayerhealth;
-static int oldpercenthealth;
-
-static int playeruniformcolor;
-
-#define NUMBONUSES 11
-#define BONUSBONUS 100000
-
-
-extern void VL_MemToScreenClipped (byte *source, int width, int height, int x, int y);
-void DrawPPic (int xpos, int ypos, int width, int height, byte *src, int num, boolean up, boolean bufferofsonly);
-extern void MoveScreenUpLeft();
-extern void MoveScreenUpRight();
-extern void MoveScreenDownLeft();
-extern void MoveScreenDownRight();
-//******************************************************************************
-//
-// V_ReDrawBkgnd ()
-//
-//******************************************************************************
-
-void V_ReDrawBkgnd (int x, int y, int width, int height, boolean shade)
-{
- byte *src;
- byte *dest;
- byte *origdest;
- int j,
- k,
- planes,
- mask,
- m;
-
- m = (x&3);
- mask = (1 << m);
-
-#ifdef DOS
- origdest = (byte *)(bufferofs+ylookup[y]+(x>>2));
-#else
- origdest = (byte *)(bufferofs+ylookup[y]+x);
-#endif
-
- if (VW_MarkUpdateBlock (x, y, x+width-1, y+height-1))
- {
- for (planes = 0; planes < 4; planes++)
- {
- src = (&(BkPic->data)+((80*200)*m)+(80*y)+(x>>2));
- dest = origdest;
-
-#ifdef DOS
- VGAMAPMASK (mask);
-#else
- dest += planes;
-#endif
-
- for (j = 0; j < height; j++)
- {
- for (k = 0; k < (width/4); k++) {
- if (shade) {
- *dest = *(colormap + ((MENUSHADELEVEL>>2)<<8) + *src++);
- } else {
- *dest = *src++;
- }
-#ifdef DOS
- dest++;
-#else
- dest += 4;
-#endif
- }
-
-#ifndef DOS
- // draw the remainder. did the DOS version even bother? - SBF
- if ((width & 3) > planes) {
- if (shade) {
- *dest = *(colormap + ((MENUSHADELEVEL>>2)<<8) + *src);
- } else {
- *dest = *src;
- }
- }
-#endif
-
- src += (80-(width/4));
-#ifdef DOS
- dest += (linewidth-(width/4));
-#else
- dest += (linewidth-(width&~3));
-#endif
- }
-
- m++;
-
- mask <<= 1;
-
- if (mask == 16)
- {
- x+=4;
- mask = 1;
- m = 0;
-#ifdef DOS
- origdest++;
-#endif
- }
- }
- }
-}
-
-
-//******************************************************************************
-//
-// CacheLumpGroup ()
-//
-//******************************************************************************
-void CacheLumpGroup
-(
- char *startlump,
- pic_t **lumparray,
- int numberoflumps
-)
-
-{
- int lumpnum;
- int i;
-
- lumpnum = W_GetNumForName( startlump );
-
- for( i = 0; i < numberoflumps; i++ )
- {
- lumparray[ i ] = ( pic_t * )W_CacheLumpNum( lumpnum + i, PU_LEVEL, Cvt_pic_t, 1 );
- }
-}
-
-//******************************************************************************
-//
-// SetupPlayScreen ()
-//
-//******************************************************************************
-void SetupPlayScreen
-(
- void
-)
-
-{
- int i;
- int j;
- int num;
-
- erase = ( pic_t * )W_CacheLumpName( "erase", PU_LEVEL, Cvt_pic_t, 1 );
- eraseb = ( pic_t * )W_CacheLumpName( "eraseb", PU_LEVEL, Cvt_pic_t, 1 );
-
- CacheLumpGroup( "tmnum0", timenums, 10 );
- CacheLumpGroup( "lfnum0", lifeptnums, 10 );
- CacheLumpGroup( "lvnum0", lifenums, 10 );
- CacheLumpGroup( "health1b", health, 6 );
- CacheLumpGroup( "key1", keys, 4 );
-
- if ( !BATTLEMODE )
- {
- CacheLumpGroup( "scnum0", scorenums, 10 );
-
- num = locplayerstate->player;
- men[ num ] = ( pic_t * )W_CacheLumpNum( W_GetNumForName( "MAN1" ) +
- num, PU_LEVEL, Cvt_pic_t, 1 );
- }
- else
- {
- int man;
- int num100;
- int negnum;
- int negman;
-
- CacheLumpGroup( "kilnum0", scorenums, 10 );
-
- negnum = W_GetNumForName( "botnpic1" );
- num = W_GetNumForName( "botpic0" );
- num100 = W_GetNumForName( "botopic1" );
- negman = W_GetNumForName( "negman1" );
- man = W_GetNumForName( "man1" );
-
- blankfragpic = ( pic_t * )W_CacheLumpNum( num, PU_LEVEL, Cvt_pic_t, 1 );
- num++;
-
- for( i = 0; i < numplayers; i++ )
- {
- j = PLAYERSTATE[ i ].player;
- if ( !gamestate.teamplay )
- {
- fragpic[ j ] = ( pic_t * )W_CacheLumpNum( num + j, PU_LEVEL, Cvt_pic_t, 1 );
- frag100pic[ j ] = ( pic_t * )W_CacheLumpNum( num100 + j, PU_LEVEL, Cvt_pic_t, 1 );
- negfragpic[ j ] = ( pic_t * )W_CacheLumpNum( negnum + j, PU_LEVEL, Cvt_pic_t, 1 );
- }
- else
- {
- negfragpic[ j ] = ( pic_t * )W_CacheLumpName( "teamnpic", PU_LEVEL, Cvt_pic_t, 1 );
- fragpic[ j ] = ( pic_t * )W_CacheLumpName( "teampic", PU_LEVEL, Cvt_pic_t, 1 );
- frag100pic[ j ] = fragpic[ j ];
- }
-
- menneg[ j ] = ( pic_t * )W_CacheLumpNum( negman + j, PU_LEVEL, Cvt_pic_t, 1 );
- men[ j ] = ( pic_t * )W_CacheLumpNum( man + j, PU_LEVEL, Cvt_pic_t, 1 );
- }
- }
-
- powerpics = W_GetNumForName( "GDMODEP" );
- poweradjust = POWERUPTICS / 16;
-
- num = W_GetNumForName( "INF_B" );
-
- // bullet weapons
- ammo[0] = ( pic_t * )W_CacheLumpNum( num, PU_LEVEL, Cvt_pic_t, 1 );
- ammo[1] = ( pic_t * )W_CacheLumpNum( num, PU_LEVEL, Cvt_pic_t, 1 );
- ammo[2] = ( pic_t * )W_CacheLumpNum( num++, PU_LEVEL, Cvt_pic_t, 1 );
-
-
- for(i=3; i < 13; i++ )
- {
- ammo[ i ] = ( pic_t * )W_CacheLumpNum( num++, PU_LEVEL, Cvt_pic_t, 1 );
- }
-
- ammo[13] = ( pic_t * )W_CacheLumpNum( num, PU_LEVEL, Cvt_pic_t, 1 );
- ammo[14] = ( pic_t * )W_CacheLumpNum( num, PU_LEVEL, Cvt_pic_t, 1 );
- ammo[15] = ( pic_t * )W_CacheLumpNum( num++, PU_LEVEL, Cvt_pic_t, 1 );
-
-
- for(i=16; i < 26; i++ )
- {
- ammo[ i ] = ( pic_t * )W_CacheLumpNum( num++, PU_LEVEL, Cvt_pic_t, 1 );
- }
-
-
- oldplayerhealth = -1;
- oldpercenthealth = -1;
-}
-
-
-
-//******************************************************************************
-//
-// GameMemToScreen()
-//
-//******************************************************************************
-
-void GameMemToScreen(pic_t *source, int x, int y, int bufferofsonly)
-{
- if ( bufferofsonly )
- {
- VL_MemToScreen( ( byte * )&source->data, source->width,
- source->height, x, y );
- }
- else
- {
- GM_MemToScreen( ( byte * )&source->data, source->width,
- source->height, x, y );
- }
-}
-int topBarCenterOffsetX;
-
-//******************************************************************************
-//
-// DrawPlayScreen ()
-//
-//******************************************************************************
-void DrawPlayScreen (boolean bufferofsonly)
-{
- pic_t *shape;
- int shapenum;
- int ShowKillsYoffset = 0;//bna++
-
- //figure out where the middle point of the status bar should be for top bar
- topBarCenterOffsetX = (iGLOBAL_SCREENWIDTH - 320) >> 1;
-
- if ( SHOW_TOP_STATUS_BAR() )
- {
- if (iGLOBAL_SCREENWIDTH == 640)
- {
- shape = ( pic_t * )W_CacheLumpName( "backtile", PU_CACHE, Cvt_pic_t, 1 );
-
- DrawTiledRegion( 0, 0, iGLOBAL_SCREENWIDTH, 16, 0,16, shape );
-
- shape = ( pic_t * )W_CacheLumpName( "stat_bar", PU_CACHE, Cvt_pic_t, 1 );
- GameMemToScreen( shape, topBarCenterOffsetX, 0, bufferofsonly );
- }
- else if (iGLOBAL_SCREENWIDTH == 800)
- {
- shape = ( pic_t * )W_CacheLumpName( "backtile", PU_CACHE, Cvt_pic_t, 1 );
-
- DrawTiledRegion( 0, 0, iGLOBAL_SCREENWIDTH, 16, 0,16, shape );
-
- shape = ( pic_t * )W_CacheLumpName( "stat_bar", PU_CACHE, Cvt_pic_t, 1 );
- GameMemToScreen( shape, topBarCenterOffsetX, 0, bufferofsonly );
-
- }
- else if (iGLOBAL_SCREENWIDTH == 320)
- {
- shape = ( pic_t * )W_CacheLumpName( "stat_bar", PU_CACHE, Cvt_pic_t, 1 );
- GameMemToScreen( shape, 0, 0, bufferofsonly );
- }
- }
-
- if ( BATTLEMODE )
- {
- DrawKills( bufferofsonly );
- }
-
- if ( SHOW_BOTTOM_STATUS_BAR() )
- {
- shape = ( pic_t * ) W_CacheLumpName( "bottbar", PU_CACHE, Cvt_pic_t, 1 );
-
- if ( SHOW_KILLS() )
- {
- ShowKillsYoffset = KILLS_HEIGHT;
- }
-
- if (iGLOBAL_SCREENWIDTH == 640) {
- //bna fix - not to good? but no one has 286 any more
- //statusbar dosent cover hole screen, because its a lump picture width max 320
- //first write dummy shape and next over it
- GameMemToScreen( shape, 320, (224*2)+16-ShowKillsYoffset, bufferofsonly );
- //copy next shape to mem
- GameMemToScreen( shape, 0, (224*2)+16-ShowKillsYoffset, bufferofsonly );
- // delete bullet in middle of shape picture
- DrawPPic( 310, (224*2)+17-ShowKillsYoffset, 8 >> 2, 16,
- ( byte * )&erase->data, 2, true, bufferofsonly );
- // delete hart in middle of shape picture
- DrawPPic( 324, (224*2)+17-ShowKillsYoffset, 8 >> 2, 16,
- ( byte * )&erase->data, 2, true, bufferofsonly );
-
- } else if (iGLOBAL_SCREENWIDTH == 800) {
- GameMemToScreen( shape, 800-320, 584-ShowKillsYoffset, bufferofsonly );
- //copy next shape to mem
- GameMemToScreen( shape, 300, 584-ShowKillsYoffset, bufferofsonly );
- //copy next shape to mem
- GameMemToScreen( shape, 0, 584-ShowKillsYoffset, bufferofsonly );
- // delete 2 bullets in middle of shape picture
- DrawPPic( 305, 584+1-ShowKillsYoffset, 8 >> 2, 16,
- ( byte * )&erase->data, 2, true, bufferofsonly );
- // delete hart in middle of shape picture
- DrawPPic( 610, 584+1-ShowKillsYoffset, 8 >> 2, 16,
- ( byte * )&erase->data, 2, true, bufferofsonly );
-
- } else {
- GameMemToScreen( shape, 0, 184, bufferofsonly );
- }
- //}
-
- DrawBarAmmo( bufferofsonly );
- DrawBarHealth( bufferofsonly );
-
- if ( demoplayback )
- {
- shape = ( pic_t * )W_CacheLumpName( "demo", PU_CACHE, Cvt_pic_t, 1 );
- if (iGLOBAL_SCREENWIDTH == 640) {
- DrawPPic( 148*2, 465, shape->width, shape->height,
- ( byte * )&shape->data, 1, true, bufferofsonly );
- } else if (iGLOBAL_SCREENWIDTH == 800) {
- DrawPPic( 380, 585, shape->width, shape->height,
- ( byte * )&shape->data, 1, true, bufferofsonly );
- } else {
- DrawPPic( 148, 185, shape->width, shape->height,
- ( byte * )&shape->data, 1, true, bufferofsonly );
- }
- }
- }
-
- if ( !SHOW_TOP_STATUS_BAR() )
- {
- return;
- }
-
-//draws small player picture and name in topbar
- oldsec = -1;
-
- //DrawTime( bufferofsonly );
-
- if ( !BATTLEMODE )
- {
- int character;
- int width;
- int height;
-
- character = locplayerstate->player;
- GameMemToScreen( men[ character ], MEN_X + topBarCenterOffsetX, MEN_Y,bufferofsonly );
-
- CurrentFont = tinyfont;
-
- // Draw player's name
-
- if (iGLOBAL_SCREENWIDTH == 800)
- {
- DrawGameString ( MEN_X + 3 + topBarCenterOffsetX, MEN_Y + 2, Names[ character ], bufferofsonly );
- VW_MeasurePropString( LastNames[ character ], &width, &height );
- DrawGameString ( MEN_X + 44 - width + topBarCenterOffsetX, MEN_Y + 8,
- LastNames[ character ], bufferofsonly );
- }
- else
- {
- DrawGameString ( MEN_X + 3 + topBarCenterOffsetX, MEN_Y + 2, Names[ character ], bufferofsonly );
- VW_MeasurePropString( LastNames[ character ], &width, &height );
- DrawGameString ( MEN_X + 44 - width + topBarCenterOffsetX, MEN_Y + 8,
- LastNames[ character ], bufferofsonly );
-
- }
- UpdateLives( locplayerstate->lives );
- UpdateScore( gamestate.score );
- DrawTriads( bufferofsonly );
- DrawLives( bufferofsonly );
- DrawScore( bufferofsonly );
- }
-
- DrawKeys( bufferofsonly );
-
- if ( locplayerstate->poweruptime )
- {
- if ( player->flags & FL_GODMODE )
- {
- shapenum = powerpics;
- }
- else if ( player->flags & FL_DOGMODE )
- {
- shapenum = powerpics + 1;
- }
- else if ( player->flags & FL_FLEET )
- {
- shapenum = powerpics + 2;
- }
- else if ( player->flags & FL_ELASTO )
- {
- shapenum = powerpics + 3;
- }
- else if ( player->flags & FL_SHROOMS )
- {
- shapenum = powerpics + 4;
- }
-
- shape = ( pic_t * )W_CacheLumpNum ( shapenum, PU_CACHE, Cvt_pic_t, 1 );
-
- GameMemToScreen( eraseb, POWERUP1X + topBarCenterOffsetX, POWERUPY, bufferofsonly );
-
- DrawMPPic( POWERUP1X + topBarCenterOffsetX, POWERUPY + powerupheight, shape->width,
- shape->height - powerupheight, powerupheight,
- ( byte * )&shape->data, bufferofsonly );
- }
-
-
- if ( locplayerstate->protectiontime )
- {
- if ( player->flags & FL_BPV )
- {
- shapenum = powerpics + 6;
- }
- else if ( player->flags & FL_GASMASK )
- {
- shapenum = powerpics + 5;
- }
- else if ( player->flags & FL_AV )
- {
- shapenum = powerpics + 7;
- }
-
- shape = ( pic_t * )W_CacheLumpNum( shapenum, PU_CACHE, Cvt_pic_t, 1 );
-
- GameMemToScreen( eraseb, POWERUP2X + topBarCenterOffsetX, POWERUPY, bufferofsonly );
-
- DrawMPPic( POWERUP2X + topBarCenterOffsetX, POWERUPY + protectionheight, shape->width,
- shape->height - protectionheight, protectionheight,
- ( byte * )&shape->data, bufferofsonly );
- }
-}
-
-
-//******************************************************************************
-//
-// ShortenCodeName()
-//
-//******************************************************************************
-void GetShortCodeName
-(
- char *dest,
- char *source,
- int maxwidth
-)
-
-{
- int width;
- int height;
- int length;
-
- strcpy( dest, source );
-
- // Shorten name to fit
- length = strlen( dest );
- VW_MeasurePropString( dest, &width, &height );
- while( width > maxwidth )
- {
- dest[ length ] = 0;
- length--;
- VW_MeasurePropString( dest, &width, &height );
- }
-}
-
-
-//******************************************************************************
-//
-// DrawKills ()
-//
-//******************************************************************************
-void DrawKills
-(
- boolean bufferofsonly
-)
-{
- int rank;
- int xpos;
- char codename[ MAXCODENAMELENGTH ];
- int width;
- int playernum;
- int playerimage;
- int temp;
- int iKILLS_Y;
- pic_t *pic;
-
- CurrentFont = tinyfont;
-
- if ( SHOW_TOP_STATUS_BAR() )
- {
- playernum = BATTLE_Team[ consoleplayer ];
- playerimage = BATTLE_TeamLeader[ playernum ];
-
- // Set uniformcolor
- playeruniformcolor = PLAYERSTATE[ playerimage ].uniformcolor;
-
- // Draw player's point box
- pic = men[ PLAYERSTATE[ playerimage ].player ];
- if ( ( gamestate.ShowScores ) && ( BATTLE_Points[ playernum ] < 0 ) )
- {
- pic = menneg[ PLAYERSTATE[ playerimage ].player ];
- }
-
- DrawPPic( MEN_X, MEN_Y, pic->width, pic->height,
- ( byte * )&pic->data, 1, true, bufferofsonly );
-
- // Draw player's name
- if ( gamestate.teamplay )
- {
- GetShortCodeName( codename, colorname[ playeruniformcolor ],
- 42 );
- }
- else
- {
- GetShortCodeName( codename, PLAYERSTATE[ playerimage ].codename,
- 42 );
- }
-
- DrawGameString ( MEN_X + 2, MEN_Y + 2, codename, bufferofsonly );
- // Draw "It" if player is 'it'
- if ( ( ( gamestate.battlemode == battle_Tag ) ||
- ( gamestate.battlemode == battle_Hunter ) ) &&
- ( BATTLE_It == BATTLE_Team[ consoleplayer ] ) )
- {
- DrawGameString ( MEN_X + 22, MEN_Y + 8,
- "It", bufferofsonly);
- }
-
- // Draw triad if player is 'it' or has caught a triad
- if ( PLAYER[ consoleplayer ]->flags & FL_DESIGNATED )
- {
- pic = W_CacheLumpName( "smalltri", PU_CACHE, Cvt_pic_t, 1 );
- DrawPPic( TRIAD_X - 1, TRIAD_Y - 2, pic->width, pic->height,
- ( byte * )&pic->data, 1, true, bufferofsonly );
- }
- else if ( ( gamestate.ShowScores ) &&
- ( DisplayPoints != bo_kills_infinite ) )
- {
- // Draw Kill goal
- if ( ( gamestate.battlemode == battle_Collector ) ||
- ( gamestate.battlemode == battle_StandAloneGame ) )
- {
- temp = BATTLE_NumCollectorItems;
- }
- else
- {
- temp = DisplayPoints;
- }
-
- ltoa ( temp % 1000, KillStr.str, 10);
- KillStr.length = strlen (KillStr.str);
- DrawNumber (TRIAD_X - 6, TRIAD_Y, 3, 5, bufferofsonly);
- }
-
- // Set uniformcolor
- playeruniformcolor = PLAYERSTATE[ consoleplayer ].uniformcolor;
-
- if ( gamestate.ShowScores )
- {
- // Draw local player's points
- temp = BATTLE_Points[ playernum ] % 1000;
- if ( temp < 0 )
- {
- temp = -temp;
- }
- ltoa ( temp, KillStr.str, 10);
- KillStr.length = strlen (KillStr.str);
-
- DrawNumber( LIVES_X - 12, LIVES_Y, 3, 4, bufferofsonly);
- }
- else
- {
- pic = W_CacheLumpName( "minus", PU_CACHE, Cvt_pic_t, 1 );
- StatusDrawColoredPic( LIVES_X - 12, LIVES_Y, pic, bufferofsonly, playeruniformcolor );
- StatusDrawColoredPic( LIVES_X - 4, LIVES_Y, pic, bufferofsonly, playeruniformcolor );
- }
-
- // Draw whoever is 'It'
- playernum = BATTLE_It;
- playerimage = BATTLE_TeamLeader[ playernum ];
-
- // Set uniformcolor
- playeruniformcolor = PLAYERSTATE[ playerimage ].uniformcolor;
-
- // Draw player's point box
- pic = men[ PLAYERSTATE[ playerimage ].player ];
- if ( ( gamestate.ShowScores ) && ( BATTLE_Points[ playernum ] < 0 ) )
- {
- pic = menneg[ PLAYERSTATE[ playerimage ].player ];
- }
-
- DrawPPic( LEADER_X, LEADER_Y, pic->width, pic->height,
- (byte *)&pic->data, 1, true, bufferofsonly );
-
- if ( ( gamestate.battlemode == battle_Tag ) ||
- ( gamestate.battlemode == battle_Hunter ) )
- {
- DrawGameString ( LEADER_X + 22, LEADER_Y + 8,
- "It", bufferofsonly);
- }
-
- if ( gamestate.ShowScores )
- {
- // Draw number of points
- temp = BATTLE_Points[ playernum ] % 1000;
- if ( temp < 0 )
- {
- temp = -temp;
- }
- ltoa ( temp, KillStr.str, 10);
- KillStr.length = strlen (KillStr.str);
- DrawNumber ( LEADER_NUM_X, LEADER_NUM_Y, 3, 4, bufferofsonly);
- }
- else
- {
- pic = W_CacheLumpName( "minus", PU_CACHE, Cvt_pic_t, 1 );
- StatusDrawColoredPic( LEADER_NUM_X, LEADER_NUM_Y, pic, bufferofsonly, playeruniformcolor );
- StatusDrawColoredPic( LEADER_NUM_X + 8, LEADER_NUM_Y, pic, bufferofsonly, playeruniformcolor );
- }
-
- // Draw name
- if ( gamestate.teamplay )
- {
- DrawGameString ( LEADER_NAME_X, LEADER_NAME_Y - 1,
- colorname[ playeruniformcolor ], bufferofsonly);
- }
- else
- {
- GetShortCodeName( codename, PLAYERSTATE[ playerimage ].codename,
- 42 );
- DrawGameString ( LEADER_NAME_X - 1, LEADER_NAME_Y,
- codename, bufferofsonly);
- }
- }
-
- // Only draw the rest of the rifraff when the kill count is selected
-
- if ( !SHOW_KILLS() )
- {
- return;
- }
-// SetTextMode ( );
- // Draw all the other losers
- //#define KILLS_Y 176
- iKILLS_Y = iGLOBAL_SCREENHEIGHT - 24;
- //draw blank status pic->width = 8;pic->height = 24
- pic = blankfragpic;
- for (temp = iGLOBAL_SCREENWIDTH-pic->width-24; temp > pic->width; temp -= pic->width) {
- DrawPPic( temp, iKILLS_Y, pic->width, pic->height,
- (byte *)&pic->data, 1, true, bufferofsonly );
-
- }
-
- xpos = KILLS_X;
- for( rank = 0; rank < BATTLE_NumberOfTeams; rank++ )
- {
- playernum = BATTLE_PlayerOrder[ rank ];
- playerimage = BATTLE_TeamLeader[ playernum ];
-
- if ( ( playernum == BATTLE_It ) && SHOW_TOP_STATUS_BAR() )
- {
- continue;
- }
-
- // Set uniformcolor
- playeruniformcolor = PLAYERSTATE[ playerimage ].uniformcolor;
-
- // Draw player's point box
- pic = fragpic[ PLAYERSTATE[ playerimage ].player ];
- if ( gamestate.ShowScores )
- {
- if ( BATTLE_Points[ playernum ] < 0 )
- {
- pic = negfragpic[ PLAYERSTATE[ playerimage ].player ];
- }
- else if ( BATTLE_Points[ playernum ] >= 100 )
- {
- pic = frag100pic[ PLAYERSTATE[ playerimage ].player ];
- }
- }
- DrawPPic( xpos, iKILLS_Y, pic->width, pic->height,
- (byte *)&pic->data, 1, true, bufferofsonly );
-
- // Draw number of points
- if ( gamestate.ShowScores )
- {
- temp = BATTLE_Points[ playernum ] % 1000;
- if ( temp < 0 )
- {
- temp = -temp;
- }
- ltoa ( temp, KillStr.str, 10);
- KillStr.length = strlen (KillStr.str);
- width = 2;
- if ( temp > 99 )
- {
- width = 3;
- }
- DrawNumber( xpos + KILLS_OFFSET + 16 - ( 8 * width ), iKILLS_Y, width, 4, bufferofsonly);
- }
- else
- {
- pic = ( pic_t * )W_CacheLumpName( "minus", PU_CACHE, Cvt_pic_t, 1 );
- StatusDrawColoredPic( ( xpos + KILLS_OFFSET ), iKILLS_Y, pic, bufferofsonly, playeruniformcolor );
- StatusDrawColoredPic( ( xpos + KILLS_OFFSET + 8 ), iKILLS_Y, pic, bufferofsonly, playeruniformcolor );
- }
-
- // Get codename
- if ( gamestate.teamplay )
- {
- GetShortCodeName( codename, colorname[ playeruniformcolor ],
- KILLS_WIDTH - 2 );
- }
- else
- {
- GetShortCodeName( codename, PLAYERSTATE[ playerimage ].codename,
- KILLS_WIDTH - 2 );
- }
-
- // Draw name
- DrawGameString (xpos + 1, KILLS_NAME_Y, codename, bufferofsonly);
-
- // Advance to next position
- xpos += KILLS_WIDTH;
-
- if ( xpos >= iGLOBAL_SCREENWIDTH )
- {
- break;
- }
- }
-
- for( rank = BATTLE_NumberOfTeams; rank <= MAXKILLBOXES; rank++ )
- {
- if ( xpos >= iGLOBAL_SCREENWIDTH )
- {
- break;
- }
-
- pic = blankfragpic;
- DrawPPic( xpos, iKILLS_Y, pic->width, pic->height,
- (byte *)&pic->data, 1, true, bufferofsonly );
-
- // Advance to next position
- xpos += KILLS_WIDTH;
- }
-}
-
-
-//******************************************************************************
-//
-// DrawPlayers ()
-//
-//******************************************************************************
-void DrawPlayers
-(
- void
-)
-
-{
- int num;
- int xpos;
- char codename[ MAXCODENAMELENGTH ];
- int length;
- int width;
- int height;
- int team;
- int player;
- int character;
- pic_t *pic;
- pic_t *enemy;
- pic_t *friend;
-
- num = W_GetNumForName( "botpic1" );
-
- scorenums[ 0 ]= ( pic_t * )W_CacheLumpName( "kilnum0", PU_CACHE, Cvt_pic_t, 1 );
- friend = ( pic_t * )W_CacheLumpName( "t_friend", PU_CACHE, Cvt_pic_t, 1 );
- enemy = ( pic_t * )W_CacheLumpName( "t_enemy", PU_CACHE, Cvt_pic_t, 1 );
-
- // Draw all the losers
- CurrentFont = tinyfont;
-
- xpos = (iGLOBAL_SCREENWIDTH - min( numplayers, MAXKILLBOXES ) * KILLS_WIDTH ) / 2;
-//SetTextMode ( );//PLAYERSTATE
- for( team = 0; team < BATTLE_NumberOfTeams; team++ )
- {
- for( player = 0; player < numplayers; player++ )
- {
- if ( BATTLE_Team[ player ] == team )
- {
- character = PLAYERSTATE[ player ].player;
-
- fragpic[ character ] = ( pic_t * )W_CacheLumpNum( num +
- character, PU_CACHE, Cvt_pic_t, 1 );
-
- if ( ( numplayers <= MAXKILLBOXES ) ||
- ( player != consoleplayer ) )
- {
- // Set uniformcolor
- playeruniformcolor = PLAYERSTATE[ player ].uniformcolor;
-
- // Draw player's point box
- pic = fragpic[ PLAYERSTATE[ player ].player ];
-
- VWB_DrawPic ( xpos, PLAYERS_Y, pic );
- if ( gamestate.teamplay )
- {
- if ( BATTLE_Team[ player ] == BATTLE_Team[ consoleplayer ] )
- {
- VWB_DrawPic ( xpos, PLAYERS_TEAM_Y, friend );
- }
- else
- {
- VWB_DrawPic ( xpos, PLAYERS_TEAM_Y, enemy );
- }
- }
-
- strcpy( KillStr.str, "00" );
- KillStr.length = strlen ( KillStr.str );
- DrawNumber( xpos + KILLS_OFFSET, PLAYERS_Y, 2, 4, true );
-
- // Get codename
- strcpy( codename, PLAYERSTATE[ player ].codename );
-
- // Shorten name to fit into point count
- length = strlen( codename );
- US_MeasureStr( &width, &height, "%s", codename );
- while( width > KILLS_WIDTH )
- {
- codename[ length ] = 0;
- length--;
- US_MeasureStr( &width, &height, "%s", codename );
- }
-
- // Draw name
- PrintX = xpos;
- PrintY = PLAYERS_NAME_Y;
- US_Print( codename );
-
- // Advance to next position
- xpos += KILLS_WIDTH;
- }
- }
- if ( xpos >= iGLOBAL_SCREENWIDTH )
- {
- break;
- }
- }
- if ( xpos >= iGLOBAL_SCREENWIDTH )
- {
- break;
- }
- }
-}
-
-//******************************************************************************
-//
-// StatusDrawPic ()
-//
-//******************************************************************************
-
-void StatusDrawPic (unsigned x, unsigned y, pic_t *nums, boolean bufferofsonly)
-{
- DrawMPPic (x, y, nums->width, nums->height, 0,
- (byte *)&nums->data, bufferofsonly);
-}
-
-//******************************************************************************
-//
-// StatusDrawColoredPic ()
-//
-//******************************************************************************
-
-void StatusDrawColoredPic (unsigned x, unsigned y, pic_t *nums, boolean bufferofsonly, int color)
-{
- DrawColoredMPPic (x, y, nums->width, nums->height, 0,
- (byte *)&nums->data, bufferofsonly, color);
-}
-
-//******************************************************************************
-//
-// DrawGameString ()
-//
-// draw string to game screen at x,y
-//
-//******************************************************************************
-
-void DrawGameString (int x, int y, const char * str, boolean bufferofsonly)
-{
- byte *tempbuf;
-
- px=x;
- py=y;
-
- if (bufferofsonly==true)
- VW_DrawPropString (str);
- else
- {
- tempbuf=bufferofs;
- bufferofs=page1start;
- VW_DrawPropString (str);
-#ifdef DOS
- px=x;
- py=y;
- bufferofs=page2start;
- VW_DrawPropString (str);
- px=x;
- py=y;
- bufferofs=page3start;
- VW_DrawPropString (str);
-#endif
- bufferofs=tempbuf;
- }
-}
-
-
-//******************************************************************************
-//
-// DrawNumber ()
-//
-// right justifies and pads with zeros
-//
-//******************************************************************************
-
-void DrawNumber (int x, int y, int width, int which, boolean bufferofsonly)
-{
- unsigned length,c;
- char *str;
- byte z;
-
- switch (which)
- {
- case 1:
- str = ScoreStr.str;
- length = ScoreStr.length;
- break;
-
- case 2:
- str = LivesStr.str;
- length = LivesStr.length;
- break;
-
- case 3:
- str = TriadStr.str;
- length = TriadStr.length;
- break;
-
- case 4:
- case 5:
- case 6:
- str = KillStr.str;
- length = KillStr.length;
- break;
- }
-
- z = width - length; // Num zeros
-
- while (z)
- {
- switch (which)
- {
- case 1:
- StatusDrawPic (x, y, scorenums[0], bufferofsonly);
- x+=8;
- break;
- case 2:
- StatusDrawPic (x, y, lifenums[0], bufferofsonly);
- x+=8;
- break;
- case 3:
- StatusDrawPic (x, y, lifeptnums[0], bufferofsonly);
- x+=6;
- break;
- case 4:
- StatusDrawColoredPic (x, y, scorenums[0], bufferofsonly, playeruniformcolor);
- x+=8;
- break;
- case 5:
- StatusDrawPic (x, y, lifeptnums[0], bufferofsonly);
- x+=6;
- break;
- case 6:
- StatusDrawPic (x, y, lifenums[0], bufferofsonly);
- x+=8;
- break;
- }
- z--;
- }
-
- c = length <= (unsigned)width ? 0 : length-width;
- while (c < length)
- {
- switch (which)
- {
- case 1:
- StatusDrawPic (x, y, scorenums[str[c]-'0'], bufferofsonly);
- x+=8;
- break;
- case 2:
- StatusDrawPic (x, y, lifenums[str[c]-'0'], bufferofsonly);
- x+=8;
- break;
- case 3:
- StatusDrawPic (x, y, lifeptnums[str[c]-'0'], bufferofsonly);
- x+=6;
- break;
- case 4:
- StatusDrawColoredPic (x, y, scorenums[str[c]-'0'], bufferofsonly, playeruniformcolor);
- x+=8;
- break;
- case 5:
- StatusDrawPic (x, y, lifeptnums[str[c]-'0'], bufferofsonly);
- x+=6;
- break;
- case 6:
- StatusDrawPic (x, y, lifenums[str[c]-'0'], bufferofsonly);
- x+=8;
- break;
- }
- c++;
- }
-}
-
-
-
-//******************************************************************************
-//
-// HealPlayer ()
-//
-//******************************************************************************
-
-void HealPlayer
-(
- int points,
- objtype *ob
-)
-
-{
- playertype *pstate;
- int maxhitpoints;
-
- M_LINKSTATE( ob, pstate );
-
- pstate->health += points;
- maxhitpoints = MaxHitpointsForCharacter( pstate );
- if ( pstate->health > maxhitpoints )
- {
- pstate->health = maxhitpoints;
- }
-
- if ( ( SHOW_BOTTOM_STATUS_BAR() ) && ( ob == player ) )
- {
- DrawBarHealth( false );
- }
-}
-
-//******************************************************************************
-//
-// DrawLives ()
-//
-//******************************************************************************
-
-void DrawLives
-(
- boolean bufferofsonly
-)
-
-{
- if ( !SHOW_TOP_STATUS_BAR() )
- {
- return;
- }
-
- if ( !EndLevelStuff )
- {
- DrawNumber( LIVES_X + topBarCenterOffsetX, LIVES_Y, 2, 2, bufferofsonly );
- }
-}
-
-
-//******************************************************************************
-//
-// GiveExtraMan ()
-//
-//******************************************************************************
-
-void GiveExtraMan (void)
-{
- if (locplayerstate->lives < 99)
- locplayerstate->lives++;
- UpdateLives (locplayerstate->lives);
- DrawLives (false);
-// SD_PlaySound (BONUS1UPSND);
-}
-
-
-
-//******************************************************************************
-//
-// DrawScore ()
-//
-//******************************************************************************
-
-void DrawScore
-(
- boolean bufferofsonly
-)
-
-{
- if ( !SHOW_TOP_STATUS_BAR() )
- {
- return;
- }
-
- if ( !BATTLEMODE )
- {
- DrawNumber( SCORE_X + topBarCenterOffsetX, SCORE_Y, 10, 1, bufferofsonly );
- }
-}
-
-
-//******************************************************************************
-//
-// GivePoints ()
-//
-//******************************************************************************
-
-void GivePoints (long points)
-{
- gamestate.score += points;
-
- UpdateScore (gamestate.score);
-
- if (!EndLevelStuff)
- DrawScore (false);
-}
-
-
-//******************************************************************************
-//
-// GiveKey ()
-//
-//******************************************************************************
-
-void GiveKey (int key)
-{
- locplayerstate->keys |= (1<<key);
- DrawKeys (false);
-}
-
-
-//******************************************************************************
-//
-// GiveLives ()
-//
-//******************************************************************************
-
-void GiveLives (int newlives)
-{
- if ((locplayerstate->lives + newlives) <= 99)
- locplayerstate->lives += newlives;
- else
- locplayerstate->lives = 99;
- UpdateLives (locplayerstate->lives);
- DrawLives (false);
-}
-
-
-#define EnableOldWeapon(pstate) \
- { \
- LASTSTAT->flags |= FL_ABP; \
- LASTSTAT->flags &= ~FL_RESPAWN; \
- MakeStatActive(LASTSTAT); \
- pstate->weaponx = ob->tilex; \
- pstate->weapony = ob->tiley; \
- }
-
-
-//******************************************************************************
-//
-// GiveWeapon ()
-//
-//******************************************************************************
-
-void GiveWeapon
-(
- objtype *ob,
- int weapon
-)
-
-{
- playertype *pstate;
-
- M_LINKSTATE( ob, pstate );
-
- if ( pstate->weapon == weapon )
- {
- return;
- }
-
- pstate->HASBULLETWEAPON[ weapon ] = 1;
- if ( ( pstate->weapon == pstate->bulletweapon ) &&
- ( pstate->weapon < weapon ) )
- {
- pstate->new_weapon = weapon;
- pstate->weapondowntics = WEAPONS[ pstate->weapon ].screenheight / GMOVE;
- if ( ( ob == player ) && ( SHOW_BOTTOM_STATUS_BAR() ) )
- {
- DrawBarAmmo( false );
- }
- }
-
- if ( gamestate.BattleOptions.WeaponPersistence )
- {
- SpawnStatic(ob->tilex,ob->tiley,GetItemForWeapon(weapon),9);
- EnableOldWeapon(pstate);
- }
-
- if ( weapon > pstate->bulletweapon )
- {
- pstate->bulletweapon = weapon;
- }
-}
-
-//LT added
-//******************************************************************************
-//
-// GivePlayerAmmo ()
-//
-//******************************************************************************
-
-
-void GivePlayerAmmo(objtype *ob, statobj_t *item_pickup, int which)
-{
- playertype * pstate;
-
- M_LINKSTATE(ob, pstate);
-
- signed char * playerCurrentAmmo = pstate->ammo;
- signed char * ammoInItem = item_pickup->ammo;
- signed char * maxAmmoInWeapon = stats[item_pickup->itemnumber].ammo;
- signed char newAmmoAmount = (signed char)((int)ammoInItem + (int)playerCurrentAmmo);
-
- if (newAmmoAmount > maxAmmoInWeapon)
- {
- ammoInItem = (signed char)((int)newAmmoAmount - (int)maxAmmoInWeapon);
- if (ammoInItem < 0)
- {
- Error("Ammo in item cannot be set to a negative number!");
- }
- item_pickup->ammo = ammoInItem;
- newAmmoAmount = maxAmmoInWeapon;
- }
- else
- {
- ammoInItem = 0;
- }
- pstate->ammo = newAmmoAmount;
-
- //if (!gamestate.BattleOptions.WeaponPersistence)
- //{
- if (pstate->ammo &&
- (pstate->missileweapon != -1) &&
- (!(WEAPON_IS_MAGICAL(which))) &&
- (!(WEAPON_IS_MAGICAL(pstate->missileweapon))))
- {
- int nx,ny;
-
-
- nx = ob->tilex;
- ny = ob->tiley;
-
- //If the missile weapon still has ammo in it after taking ammo from it, spawn it on the ground
- if (ammoInItem)
- {
- if (IsPlatform(nx,ny))
- SpawnStatic(nx,ny,GetItemForWeapon(pstate->missileweapon),9);
- else
- {
- int newz = sprites[ob->tilex][ob->tiley]->z;
- SpawnStatic(nx,ny,GetItemForWeapon(pstate->missileweapon),-1);
- LASTSTAT->z = newz;
- }
-
- //update ammo count on missile weapon on ground
- LASTSTAT->ammo = ammoInItem;
- EnableOldWeapon(pstate);
- }
-
-
- }
- //}
-}
-
-//******************************************************************************
-//
-// GiveMissileWeapon ()
-//
-//******************************************************************************
-
-void GiveMissileWeapon(objtype * ob, int which)
-{
- playertype * pstate;
-
-
- //pstate = (ob==player)?(&playerstate):(&remoteplayerstate);
- M_LINKSTATE(ob,pstate);
-
- if (!gamestate.BattleOptions.WeaponPersistence)
- {
- if (pstate->ammo &&
- (pstate->missileweapon != -1) &&
- (!(WEAPON_IS_MAGICAL(which))) &&
- (!(WEAPON_IS_MAGICAL(pstate->missileweapon)))
- )
- {
- int nx,ny;
-
-
- nx = ob->tilex;
- ny = ob->tiley;
- //FindEmptyTile(&nx,&ny);
-
- if (IsPlatform(nx,ny))
- SpawnStatic(nx,ny,GetItemForWeapon(pstate->missileweapon),9);
- else
- {
- int newz = sprites[ob->tilex][ob->tiley]->z;
- SpawnStatic(nx,ny,GetItemForWeapon(pstate->missileweapon),-1);
- LASTSTAT->z = newz;
- }
- LASTSTAT->ammo = pstate->ammo;
- EnableOldWeapon(pstate);
-
- }
- }
-
- else if (!WEAPON_IS_MAGICAL(which))
- {
- int newz = sprites[ob->tilex][ob->tiley]->z;
- SpawnStatic(ob->tilex,ob->tiley,GetItemForWeapon(which),9);
- LASTSTAT->z = newz;
- EnableOldWeapon(pstate);
-
- }
- pstate->new_weapon = pstate->missileweapon = which;
- pstate->weapondowntics = WEAPONS[pstate->weapon].screenheight/GMOVE;
-
-
-}
-
-
-//******************************************************************************
-//
-// DrawKeys ()
-//
-//******************************************************************************
-
-void DrawKeys(boolean bufferofsonly)
-{
- if ( !SHOW_TOP_STATUS_BAR() )
- {
- return;
- }
-
- if ( locplayerstate->keys & 1 )
- {
- GameMemToScreen( keys[ 0 ], KeyX[ 0 ] + topBarCenterOffsetX, KEY_Y, bufferofsonly );
- }
-
- if ( locplayerstate->keys & 2 )
- {
- GameMemToScreen( keys[ 1 ], KeyX[ 1 ] + topBarCenterOffsetX, KEY_Y, bufferofsonly );
- }
-
- if ( locplayerstate->keys & 4 )
- {
- GameMemToScreen( keys[ 2 ], KeyX[ 2 ] + topBarCenterOffsetX, KEY_Y, bufferofsonly );
- }
-
- if ( locplayerstate->keys & 8 )
- {
- GameMemToScreen( keys[ 3 ], KeyX[ 3 ] + topBarCenterOffsetX, KEY_Y, bufferofsonly );
- }
-}
-
-
-//******************************************************************************
-//
-// StatusDrawTime ()
-//
-//******************************************************************************
-
-void StatusDrawTime
-(
- unsigned x,
- unsigned y,
- unsigned num,
- boolean bufferofsonly
-)
-
-{
- DrawMPPic( x, y, timenums[ num ]->width, timenums[ num ]->height, 0,
- ( byte * )&timenums[ num ]->data, bufferofsonly );
-}
-
-
-//******************************************************************************
-//
-// DrawTimeNumber ()
-//
-// right justifies and pads with blanks
-//
-//******************************************************************************
-
-void DrawTimeNumber (int x, int y, int number, boolean seconds, boolean bufferofsonly)
-{
- char str[20];
-
- ltoa (number,str,10);
-
- if (seconds)
- {
- if (number < 10)
- {
- StatusDrawTime (x, y, 0, bufferofsonly);
- StatusDrawTime (x+8, y, str[0]-'0', bufferofsonly);
- }
- else
- {
- StatusDrawTime (x, y, str[0]-'0', bufferofsonly);
- StatusDrawTime (x+8, y, str[1]-'0', bufferofsonly);
- }
- }
- else
- {
- if (number < 10)
- StatusDrawTime (x+8, y, str[0]-'0', bufferofsonly);
- else
- {
- StatusDrawTime (x, y, str[0]-'0', bufferofsonly);
- StatusDrawTime (x+8, y, str[1]-'0', bufferofsonly);
- }
- }
-}
-
-
-//******************************************************************************
-//
-// DrawTimeXY ()
-//
-//******************************************************************************
-
-void DrawTimeXY
-(
- int x,
- int y,
- int sec,
- boolean bufferofsonly
-)
-
-{
- int min;
- int hour;
-
- while (sec > ( ( 9 * 3600 ) + 3599 ) )
- {
- sec -= ( ( 9 * 3600 ) + 3599 );
- }
-
- hour = sec / 3600;
- min = ( sec / 60 ) - ( hour * 60 );
- sec %= 60;
-
- DrawTimeNumber ( x + HOUR_X, y, hour, false, bufferofsonly );
- DrawTimeNumber ( x + MIN_X, y, min, true, bufferofsonly );
- DrawTimeNumber ( x + SEC_X, y, sec, true, bufferofsonly );
-}
-
-
-//******************************************************************************
-//
-// DrawTime ()
-//
-//******************************************************************************
-
-void DrawTime
-(
- boolean bufferofsonly
-)
-
-{
- int sec;
-
- if ( !SHOW_TOP_STATUS_BAR() )
- {
- return;
- }
-
- if (timelimitenabled == true)
- {
- sec = (timelimit-gamestate.TimeCount) / VBLCOUNTER;
- }
- else
- {
- sec = gamestate.TimeCount / VBLCOUNTER;
- }
-
- if ( oldsec != sec )
- {
- oldsec = sec;
- DrawTimeXY( GAMETIME_X + topBarCenterOffsetX, GAMETIME_Y, sec, bufferofsonly) ;
- }
-}
-
-
-//******************************************************************************
-//
-// DrawMPPic ()
-//
-// Purpose
-// Draws a masked, planer pic at xpos, ypos.
-//
-// Parms
-// xpos - x position.
-// ypos - y position.
-// width - width of pic : should be << 2.
-// height - height of pic.
-// src - data to draw.
-//
-// Returns
-// Nothing.
-//
-//******************************************************************************
-
-void DrawMPPic (int xpos, int ypos, int width, int height, int heightmod, byte *src, boolean bufferofsonly)
-{
- int olddest;
- int dest;
- int x;
- int y;
- int planes;
- byte mask;
- byte pixel;
-
- mask = 1 << (xpos&3);
-
-#ifdef DOS
- olddest = ylookup[ypos] + (xpos>>2);
-#else
- olddest = ylookup[ypos] + xpos;
-#endif
-
- for (planes = 0; planes < 4; planes++)
- {
- VGAMAPMASK (mask);
-
- dest = olddest;
-
-#ifndef DOS
- dest += planes;
-#endif
-
- for (y = 0; y < height; y++)
- {
- for (x = 0; x < width; x++)
- {
- pixel = *src++;
-
- if (pixel != 255)
- {
- if (bufferofsonly)
- *(dest+bufferofs) = pixel;
- else
- {
- *(dest+page1start) = pixel;
- *(dest+page2start) = pixel;
- *(dest+page3start) = pixel;
- }
- }
-
-#ifdef DOS
- dest++;
-#else
- dest += 4;
-#endif
- }
-
-#ifdef DOS
- dest += (linewidth-width);
-#else
- dest += (linewidth-width*4);
-#endif
- }
-
- if (heightmod)
- src += (heightmod*width);
-
-#ifdef DOS
- mask <<= 1;
- if (mask == 16)
- {
- mask = 1;
- olddest++;
- }
-#endif
- }
-}
-
-
-//******************************************************************************
-//
-// DrawColoredMPPic ()
-//
-// Purpose
-// Draws a masked, planer pic at xpos, ypos.
-//
-// Parms
-// xpos - x position.
-// ypos - y position.
-// width - width of pic : should be << 2.
-// height - height of pic.
-// src - data to draw.
-//
-// Returns
-// Nothing.
-//
-//******************************************************************************
-
-void DrawColoredMPPic (int xpos, int ypos, int width, int height, int heightmod, byte *src, boolean bufferofsonly, int color)
-{
- int olddest;
- int dest;
- int x;
- int y;
- int planes;
- byte mask;
- byte pixel;
- byte * cmap;
-
- cmap=playermaps[color]+(1<<12);
-
- mask = 1 << (xpos&3);
-
-#ifdef DOS
- olddest = ylookup[ypos] + (xpos>>2);
-#else
- olddest = ylookup[ypos] + xpos;
-#endif
-
- for (planes = 0; planes < 4; planes++)
- {
- VGAMAPMASK (mask);
-
- dest = olddest;
-
-#ifndef DOS
- dest += planes;
-#endif
-
- for (y = 0; y < height; y++)
- {
- for (x = 0; x < width; x++)
- {
- pixel = *src++;
-
- pixel = *(cmap+pixel);
-
- if (pixel != 255)
- {
- if (bufferofsonly)
- *(dest+bufferofs) = pixel;
- else
- {
- *(dest+page1start) = pixel;
- *(dest+page2start) = pixel;
- *(dest+page3start) = pixel;
- }
- }
-
-#ifdef DOS
- dest++;
-#else
- dest += 4;
-#endif
- }
-
-#ifdef DOS
- dest += (linewidth-width);
-#else
- dest += (linewidth-width*4);
-#endif
- }
-
- if (heightmod)
- src += (heightmod*width);
-
-#ifdef DOS
- mask <<= 1;
- if (mask == 16)
- {
- mask = 1;
- olddest++;
- }
-#endif
- }
-}
-
-
-//******************************************************************************
-//
-// UpdateScore ()
-//
-//******************************************************************************
-
-void UpdateScore (unsigned int num)
-{
- if (num > 999999999)
- {
- num = 999999999;
- gamestate.score = 999999999;
- }
-
- ltoa (num, ScoreStr.str, 10);
- ScoreStr.length = strlen (ScoreStr.str);
-}
-
-
-//******************************************************************************
-//
-// UpdateLives ()
-//
-//******************************************************************************
-
-void UpdateLives (int num)
-{
- ltoa (num, LivesStr.str, 10);
- LivesStr.length = strlen (LivesStr.str);
-}
-
-//****************************************************************************
-//
-// ClearTriads ()
-//
-//****************************************************************************
-void ClearTriads (playertype * pstate)
-{
- pstate->triads = 0;
- ltoa (pstate->triads, TriadStr.str, 10);
- TriadStr.length = strlen (TriadStr.str);
-}
-
-//****************************************************************************
-//
-// UpdateTriads ()
-//
-//****************************************************************************
-
-void UpdateTriads (objtype * ob, int num)
-{
- playertype * pstate;
-
- M_LINKSTATE(ob,pstate);
-
- pstate->triads += num;
-
- if (pstate->triads >= 100)
- {
- GiveLives(1);
- if (ob==player)
- {
- AddMessage("100 Life Item Points! Extra Life!",MSG_BONUS);
- SD_PlaySoundRTP (SD_GET1UPSND, player->x, player->y);
- }
- pstate->triads -= 100;
- }
-
- if (ob==player)
- {
- ltoa (pstate->triads, TriadStr.str, 10);
- TriadStr.length = strlen (TriadStr.str);
- }
-}
-
-//****************************************************************************
-//
-// DrawTriads ()
-//
-//****************************************************************************
-
-void DrawTriads(boolean bufferofsonly)
-
-{
- if ( !SHOW_TOP_STATUS_BAR() )
- {
- return;
- }
-
- if ( !EndLevelStuff )
- {
- DrawNumber( TRIAD_X + topBarCenterOffsetX, TRIAD_Y, 2, 3, bufferofsonly );
- }
-}
-
-
-//******************************************************************************
-//
-// DrawPPic ()
-//
-//******************************************************************************
-
-void DrawPPic (int xpos, int ypos, int width, int height, byte *src, int num, boolean up, boolean bufferofsonly)
-{
- int olddest;
- int dest;
- int x;
- int y;
- int planes;
- byte mask;
- byte pixel;
- int k;
- int amt;
-
-#ifdef DOS
- if (up)
- amt = 2;
- else
- amt = -2;
-#else
- if (up)
- amt = 8;
- else
- amt = -8;
-#endif
-
- mask = 1;
-
-#ifdef DOS
- olddest = ylookup[ypos] + (xpos>>2);
-#else
- olddest = ylookup[ypos] + xpos;
-#endif
-
- for (planes = 0; planes < 4; planes++)
- {
- VGAMAPMASK (mask);
-
- dest = olddest;
-
-#ifndef DOS
- dest += planes;
-#endif
-
- for (y = 0; y < height; y++)
- {
- for (x = 0; x < width; x++)
- {
- pixel = *src++;
-
- if (pixel != 255)
- {
- for (k = 0; k < num; k++)
- {
- if (bufferofsonly)
- *(dest+bufferofs+(amt*k)) = pixel;
- else
- {
- *(dest+page1start+(amt*k)) = pixel;
- *(dest+page2start+(amt*k)) = pixel;
- *(dest+page3start+(amt*k)) = pixel;
- }
- }
- }
-
-#ifdef DOS
- dest++;
-#else
- dest += 4;
-#endif
- }
-
-#ifdef DOS
- dest += (linewidth-width);
-#else
- dest += (linewidth-width*4);
-#endif
- }
-
- mask <<= 1;
- }
-}
-
-
-//****************************************************************************
-//
-// DrawBarHealth ()
-//
-//****************************************************************************
-
-void DrawBarHealth
-(
- boolean bufferofsonly
-)
-
-{
- int percenthealth;
- int health_y;
-
- if ( !SHOW_BOTTOM_STATUS_BAR() )
- {
- return;
- }
-
- health_y = iGLOBAL_HEALTH_Y;
- if ( SHOW_KILLS() )
- {
- health_y -= KILLS_HEIGHT;
- }
-
- percenthealth = ( locplayerstate->health * 10 ) /
- MaxHitpointsForCharacter( locplayerstate );
-
- oldpercenthealth = percenthealth + 1;
-
- if ( playstate == ex_died )
- {
- DrawPPic( iGLOBAL_HEALTH_X, health_y, 8 >> 2, 16, ( byte * )&erase->data,
- 10, true, bufferofsonly );
-
- return;
- }
-
- if ( locplayerstate->health <= 0 )
- {
- oldpercenthealth = 0;
- }
-
- if ( oldpercenthealth >= 11 )
- {
- oldpercenthealth = 10;
- }
-
- if ( oldpercenthealth < 4 )
- {
- DrawPPic( iGLOBAL_HEALTH_X, health_y, 8 >> 2, 16,
- ( byte * )&health[ 0 ]->data, oldpercenthealth,
- true, bufferofsonly );
- }
- else if ( oldpercenthealth < 5 )
- {
- DrawPPic( iGLOBAL_HEALTH_X, health_y, 8 >> 2, 16,
- (byte *)&health[ 1 ]->data, oldpercenthealth,
- true, bufferofsonly );
- }
- else
- {
- DrawPPic( iGLOBAL_HEALTH_X, health_y, 8 >> 2, 16,
- ( byte * )&health[ 2 ]->data, oldpercenthealth,
- true, bufferofsonly );
- }
-
- if ( oldpercenthealth < 10 )
- {
- DrawPPic( iGLOBAL_HEALTH_X + ( 8 * oldpercenthealth ), health_y,
- 8 >> 2, 16, ( byte * )&erase->data, 10 - oldpercenthealth,
- true, bufferofsonly );
- }
-}
-
-
-//****************************************************************************
-//
-// DrawBarAmmo ()
-//
-//****************************************************************************
-
-void DrawBarAmmo(boolean bufferofsonly)
-{
- int ammo_y;
-
- if ( ( !SHOW_BOTTOM_STATUS_BAR() ) || ( playstate == ex_died ) )
- {
- return;
- }
-
- ammo_y = iGLOBAL_AMMO_Y;
- if ( SHOW_KILLS() )
- {
- ammo_y -= KILLS_HEIGHT;
- }
-
- DrawPPic ( iGLOBAL_AMMO_X, ammo_y + 1, 8 >> 2, 16, ( byte * )&erase->data,
- 10, false, bufferofsonly );
-
- if ( !ARMED( player->dirchoosetime ) )
- {
- return;
- }
- if ((locplayerstate->new_weapon < wp_bazooka) ||
- (locplayerstate->new_weapon == wp_godhand) ||
- ( gamestate.BattleOptions.Ammo == bo_infinite_shots )
- )
- {
- DrawPPic( iGLOBAL_AMMO_X - 16, ammo_y, 24 >> 2, 16,
- ( byte * )&ammo[ 0 ]->data, 1, true, bufferofsonly);
-
- DrawPPic( iGLOBAL_AMMO_X - 32, ammo_y + 1, 8 >> 2, 16,
- ( byte * )&erase->data, 2, true, bufferofsonly );
- }
-#if (SHAREWARE == 0)
- else if ( locplayerstate->new_weapon == wp_dog )
- {
- DrawPPic( iGLOBAL_AMMO_X - 16, ammo_y, 24 >> 2, 16,
- ( byte * )&ammo[12]->data, 1, true, bufferofsonly );
-
- DrawPPic( iGLOBAL_AMMO_X - 32, ammo_y + 1, 8 >> 2, 16,
- ( byte * )&erase->data, 2, true, bufferofsonly );
- }
-#endif
- else
- {
- DrawPPic( iGLOBAL_AMMO_X, ammo_y + 1, 8 >> 2, 16,
- ( byte * )&ammo[ locplayerstate->new_weapon]->data,
- locplayerstate->ammo, false, bufferofsonly );
- }
-}
-
-
-//******************************************************************************
-//
-// SingleDrawPPic ()
-//
-//******************************************************************************
-
-void SingleDrawPPic (int xpos, int ypos, int width, int height, byte *src, int num, boolean up)
-{
- byte *olddest;
- byte *dest;
- int x;
- int y;
- int planes;
- byte mask;
- byte pixel;
- int k;
- int amt;
-
-#ifdef DOS
- if (up)
- amt = 2;
- else
- amt = -2;
-#else
- if (up)
- amt = 8;
- else
- amt = -8;
-#endif
-
- mask = 1;
-
-#ifdef DOS
- olddest = (byte *)(bufferofs - screenofs + ylookup[ypos] + (xpos>>2));
-#else
- olddest = (byte *)(bufferofs - screenofs + ylookup[ypos] + xpos);
-#endif
-
- for (planes = 0; planes < 4; planes++)
- {
- VGAMAPMASK (mask);
-
- dest = olddest;
-
-#ifndef DOS
- dest += planes;
-#endif
-
- for (y = 0; y < height; y++)
- {
- for (x = 0; x < width; x++)
- {
- pixel = *src++;
-
- if (pixel != 255)
- {
- for (k = 0; k < num; k++)
- {
- *(dest+(amt*k)) = pixel;
- }
- }
-
-#ifdef DOS
- dest++;
-#else
- dest += 4;
-#endif
- }
-
-#ifdef DOS
- dest += (linewidth-width);
-#else
- dest += (linewidth-width*4);
-#endif
- }
-
- mask <<= 1;
- }
-}
-
-
-
-//****************************************************************************
-//
-// DrawStats ()
-//
-//****************************************************************************
-
-void DrawStats
-(
- void
-)
-
-{
- int percenthealth;
- int health_y;
- int ammo_y;
-
- if ( ( !SHOW_PLAYER_STATS() ) || ( playstate == ex_died ) ||
- ( locplayerstate->health <= 0 ) )
- {
- return;
- }
-
-// Uncomment this if we want transparent health only on sizes < 16
-// if ( viewsize < 16 )
-// {
-// pic_t *shape;
-//
-// shape = W_CacheLumpName( "backtile", PU_CACHE );
-// DrawTiledRegion( 0, 160, 320, 24, shape );
-// }
-
- health_y = iGLOBAL_HEALTH_Y;
- ammo_y = iGLOBAL_AMMO_Y;
-
- if ( SHOW_KILLS() )
- {
- health_y -= KILLS_HEIGHT;
- ammo_y -= KILLS_HEIGHT;
- }
-
- if ( oldplayerhealth != locplayerstate->health )
- {
- oldplayerhealth = locplayerstate->health;
-
- percenthealth = ( locplayerstate->health * 10 ) /
- MaxHitpointsForCharacter( locplayerstate );
-
- oldpercenthealth = percenthealth + 1;
- }
-
- if ( oldpercenthealth > 10 )
- {
- oldpercenthealth = 10;
- }
-
- if ( oldpercenthealth < 4 )
- {
- SingleDrawPPic( iGLOBAL_HEALTH_X - 16, health_y, 8 >> 2, 16,
- ( byte * )&health[ 3 ]->data, oldpercenthealth, true);
- }
- else if ( oldpercenthealth < 5 )
- {
- SingleDrawPPic( iGLOBAL_HEALTH_X - 16, health_y, 8 >> 2, 16,
- ( byte * )&health[ 4 ]->data, oldpercenthealth, true );
- }
- else
- {
- SingleDrawPPic( iGLOBAL_HEALTH_X - 16, health_y, 8 >> 2, 16,
- ( byte * )&health[ 5 ]->data, oldpercenthealth, true );
- }
-
- if ( ARMED( consoleplayer ) )
- {
- if ((locplayerstate->new_weapon < wp_bazooka) ||
- (locplayerstate->new_weapon == wp_godhand) ||
- (gamestate.BattleOptions.Ammo == bo_infinite_shots )
- )
-
- {
- SingleDrawPPic( iGLOBAL_AMMO_X - 16, ammo_y, 24 >> 2, 16,
- ( byte * )&ammo[13]->data, 1, true );
- }
-#if (SHAREWARE == 0)
- else if ( locplayerstate->new_weapon == wp_dog )
- {
- SingleDrawPPic( iGLOBAL_AMMO_X - 16, ammo_y + 1, 24 >> 2, 16,
- ( byte * )&ammo[25]->data, 1, true );
- }
-#endif
- else
- {
- SingleDrawPPic( iGLOBAL_AMMO_X, ammo_y + 1, 8 >> 2, 16,
- ( byte * )&ammo[13 + locplayerstate->new_weapon]->data,
- locplayerstate->ammo, false );
- }
- }
-}
-
-
-//****************************************************************************
-//
-// DrawPauseXY ()
-//
-//****************************************************************************
-
-void DrawPauseXY (int x, int y)
-{
- pic_t *p;
- byte *buftmp;
-
- buftmp = bufferofs;
-
- if (GamePaused == true)
- {
- p = (pic_t *) W_CacheLumpNum (W_GetNumForName ("paused"), PU_CACHE, Cvt_pic_t, 1);
- VL_MemToScreen ((byte *)&p->data, p->width, p->height,x, y);
- //VWB_DrawPic (x, y, p);
- bufferofs = buftmp;
- DrawEpisodeLevel (x,y);
- //VL_MemToScreen ((byte *)&p->data, p->width, p->height,x, y);
-
- }
- else
- {
- p = (pic_t *) W_CacheLumpNum (W_GetNumForName ("wait"), PU_CACHE, Cvt_pic_t, 1);
- VL_MemToScreen ((byte *)&p->data, p->width, p->height,x, y);
- //VWB_DrawPic (x, y, p);
- }
- bufferofs = buftmp;
-}
-
-//****************************************************************************
-//
-// DrawPause ()
-//
-//****************************************************************************
-
-void DrawPause (void)
-{
- pic_t *p;
- byte *bufftemp = bufferofs;
-
- bufferofs -= screenofs;
-
- if (GamePaused == true)
- {
- bufferofs = bufftemp;
- p = (pic_t *) W_CacheLumpNum (W_GetNumForName ("paused"), PU_CACHE, Cvt_pic_t, 1);
- DrawPauseXY( (iGLOBAL_SCREENWIDTH-(p->width<<2) ) >>1, (iGLOBAL_SCREENHEIGHT-p->height)>>1);//bna++
- //DrawPauseXY( (320-(p->width<<2) ) >>1, (200-p->height)>>1);
- /*
- //buf = (byte *) SafeMalloc (64000);
- w = p->width;
- h = p->height;
- x = (iGLOBAL_SCREENWIDTH-((p->width)<<2) ) >>1;
- y = (iGLOBAL_SCREENHEIGHT-(p->height))>>1;
-
- x1 = (iGLOBAL_SCREENWIDTH-((p->width*2)<<2) ) >>1;
- y1 = (iGLOBAL_SCREENHEIGHT-(p->height*2))>>1;
-
- source = bufferofs + (iGLOBAL_SCREENWIDTH*y)+x;
- target = bufferofs + (iGLOBAL_SCREENWIDTH*y1)+x1;
-
- // memcpy(tmpPICbuf,bufftemp,iGLOBAL_SCREENWIDTH*iGLOBAL_SCREENHEIGHT);
-
- bufferofs = bufftemp;//(byte *)tmpPICbuf;//buf;//write picture in tmpbuf
- VL_MemToScreen ((byte *)&p->data, p->width, p->height,x, y);
- bufferofs = bufftemp;
- DrawEpisodeLevel (x,y);
-
-
- //VL_MemStrechedToScreen ((byte *)&p->data, p->width, p->height,(iGLOBAL_SCREENWIDTH-((p->width*2)<<2) ) >>1, (iGLOBAL_SCREENHEIGHT-(p->height*2))>>1);
- //DrawEpisodeLevel (x,y);
-
- //VL_MemToScreen ((byte *)&p->data, p->width, p->height,0, 0);
- //bufferofs = bufftemp;//move ptr back
- //write it back to bufferofs while streching
-
- //buf = bufftemp;
- //b = tmpPICbuf ;
-
- source = bufferofs + (iGLOBAL_SCREENWIDTH*y)+x+(w*4);
- target = bufferofs + (iGLOBAL_SCREENWIDTH*y1)+x+(2*w*4);
-
- //first strech lines in x direction
- for (y=0;y<h;y++){
- c=target;t2=source;
- for (x=0;x<w*4;x++){
- *target-- = *source;
- *target-- = *source--;
- }
- target=c;source=t2;
- target += iGLOBAL_SCREENWIDTH;
- source += iGLOBAL_SCREENWIDTH;
- }
- //strech then lines in y direction
- source -= ((iGLOBAL_SCREENWIDTH*(y/2))+(w*4));//bufferofs + (iGLOBAL_SCREENWIDTH*y)+x+(iGLOBAL_SCREENWIDTH*(y));
- target = (source+(iGLOBAL_SCREENWIDTH*(y))+1);//bufferofs + (iGLOBAL_SCREENWIDTH*y)+x+(iGLOBAL_SCREENWIDTH*(y1));
-
- for (y=0;y<h;y++){
- memcpy(target,source,(w*4*2));
- memcpy(target+iGLOBAL_SCREENWIDTH,source,(w*4*2));
-
- target -= iGLOBAL_SCREENWIDTH*2;
- source -= iGLOBAL_SCREENWIDTH;
- }
-
- / *
- for (y=0;y<h;y++){
- c=target;t2=source;
- for (x=0;x<w*4;x++){
- *target = *source;
- *(target+++iGLOBAL_SCREENWIDTH) = *source;
- *target = *source;
- *(target+++iGLOBAL_SCREENWIDTH) = *source;
- source++;
- }
- target=c;source=t2;
- target += iGLOBAL_SCREENWIDTH*2;
- source += iGLOBAL_SCREENWIDTH;
- }
- */
-
-// memcpy( bufftemp,tmpPICbuf,iGLOBAL_SCREENWIDTH*iGLOBAL_SCREENHEIGHT);
-
- }
- else
- {
- p = (pic_t *) W_CacheLumpNum (W_GetNumForName ("wait"), PU_CACHE, Cvt_pic_t, 1);
- DrawPauseXY( (iGLOBAL_SCREENWIDTH-(p->width<<2) ) >>1, (iGLOBAL_SCREENHEIGHT-p->height)>>1);//bna++
- //DrawPauseXY( (320-(p->width<<2) ) >>1, (200-p->height)>>1);
- }
-// VH_UpdateScreen () ;
-
- bufferofs = bufftemp;
-}
-
-//****************************************************************************
-//
-// GM_DrawBonus ()
-//
-//****************************************************************************
-
-void GM_DrawBonus
-(
- int which
-)
-
-{
- int x;
-
- if ( which < stat_gasmask )
- {
- x = POWERUP1X;
- poweruptime = GetBonusTimeForItem(which);
- poweradjust = (poweruptime >> 4);
- powerupheight = 0;
- GM_UpdateBonus(poweruptime-poweradjust - 1,true);
-
- }
- else
- {
- x = POWERUP2X;
- protectiontime = GetBonusTimeForItem(which);
- poweradjust = (protectiontime >> 4);
- protectionheight = 0;
- GM_UpdateBonus(protectiontime-poweradjust-1,false);
-
- }
-
-}
-
-
-//******************************************************************************
-//
-// GM_UpdateBonus ()
-//
-//******************************************************************************
-
-void GM_UpdateBonus
-(
- int time,
- int powerup
-)
-
-{
- pic_t *shape;
- int shapenum;
-
- if ( powerup )
- {
- if ( time < ( poweruptime - poweradjust ) )
- {
- powerupheight++;
- if ( !SHOW_TOP_STATUS_BAR() )
- {
- poweruptime = time;
- }
- }
- }
- else
- {
- if ( time < ( protectiontime - poweradjust ) )
- {
- protectionheight++;
- if ( !SHOW_TOP_STATUS_BAR() )
- {
- protectiontime = time;
- }
- }
- }
-
-
- if ( !SHOW_TOP_STATUS_BAR() )
- {
- return;
- }
-
- if ( !time )
- {
- if ( powerup == 1 )
- {
- shapenum = POWERUP1X;
- }
- else
- {
- shapenum = POWERUP2X;
- }
-
- GM_MemToScreen( ( byte * )&eraseb->data, eraseb->width,
- eraseb->height, shapenum + topBarCenterOffsetX, POWERUPY );
-
- return;
- }
-
- if ( powerup )
- {
- if ( time < ( poweruptime - poweradjust ) )
- {
- if ( player->flags & FL_GODMODE )
- {
- shapenum = powerpics;
- }
- else if ( player->flags & FL_DOGMODE )
- {
- shapenum = powerpics + 1;
- }
- else if ( player->flags & FL_FLEET )
- {
- shapenum = powerpics + 2;
- }
- else if ( player->flags & FL_ELASTO )
- {
- shapenum = powerpics + 3;
- }
- else if ( player->flags & FL_SHROOMS )
- {
- shapenum = powerpics + 4;
- }
- else
- {
- GM_MemToScreen( ( byte * )&eraseb->data,
- eraseb->width, eraseb->height, POWERUP1X + topBarCenterOffsetX, POWERUPY );
-
- return;
- }
-
- poweruptime = time;
-
- shape = ( pic_t * )W_CacheLumpNum( shapenum, PU_CACHE, Cvt_pic_t, 1 );
-
- GM_MemToScreen( ( byte * )&eraseb->data, eraseb->width,
- eraseb->height, POWERUP1X + topBarCenterOffsetX, POWERUPY );
-
- DrawMPPic( POWERUP1X + topBarCenterOffsetX, POWERUPY + powerupheight, shape->width,
- shape->height - powerupheight, powerupheight,
- ( byte * )&shape->data, false );
- }
- }
- else
- {
- if ( time < ( protectiontime - poweradjust ) )
- {
- if ( player->flags & FL_BPV )
- {
- shapenum = powerpics + 6;
- }
- else if ( player->flags & FL_GASMASK )
- {
- shapenum = powerpics + 5;
- }
- else if ( player->flags & FL_AV )
- {
- shapenum = powerpics + 7;
- }
-
- protectiontime = time;
-
- shape = ( pic_t * )W_CacheLumpNum( shapenum, PU_CACHE, Cvt_pic_t, 1 );
-
- GM_MemToScreen( ( byte * )&eraseb->data, eraseb->width,
- eraseb->height, POWERUP2X + topBarCenterOffsetX, POWERUPY );
-
- DrawMPPic( POWERUP2X + topBarCenterOffsetX, POWERUPY + protectionheight,
- shape->width, shape->height - protectionheight,
- protectionheight, ( byte * )&shape->data, false );
- }
- }
-}
-
-
-//******************************************************************************
-//
-// Drawpic ()
-//
-// Purpose
-// Draws a masked, planer pic at xpos, ypos.
-//
-// Parms
-// xpos - x position.
-// ypos - y position.
-// width - width of pic : should be << 2.
-// height - height of pic.
-// src - data to draw.
-//
-// Returns
-// Nothing.
-//
-//******************************************************************************
-
-void Drawpic (int xpos, int ypos, int width, int height, byte *src)
-{
- byte *olddest;
- byte *dest;
- int x;
- int y;
- int planes;
- byte mask;
- byte pixel;
-
-
- mask = 1 << (xpos&3);
-
-#ifdef DOS
- olddest = (byte *)(bufferofs + ylookup[ypos] + (xpos>>2));
-#else
- olddest = (byte *)(bufferofs + ylookup[ypos] + xpos);
-#endif
- for (planes = 0; planes < 4; planes++)
- {
- VGAMAPMASK (mask);
-
- dest = olddest;
-
-#ifdef DOS
- dest += planes;
-#endif
-
- for (y = 0; y < height; y++)
- {
- for (x = 0; x < width; x++)
- {
- pixel = *src++;
-
- if (pixel != 255)
- *(dest) = pixel;
-
-#ifdef DOS
- dest++;
-#else
- dest += 4;
-#endif
- }
-
-#ifdef DOS
- dest += (linewidth-width);
-#else
- dest += (linewidth-width*4);
-#endif
- }
-
-#ifdef DOS
- mask <<= 1;
- if (mask == 16)
- {
- mask = 1;
- olddest++;
- }
-#endif
- }
-}
-
-
-//******************************************************************************
-//
-// DrawEpisodeLevel ()
-//
-// right justifies and pads with blanks
-//
-//******************************************************************************
-
-void DrawEpisodeLevel (int x, int y)
-{
- int level;
- char str[20];
- pic_t *p;
-
- if (!BATTLEMODE)
- {
- ltoa (gamestate.episode, str, 10);
-
- //bna-- Drawpic (x+29, y+16, 8>>2, 16, (byte *)&timenums[str[0]-'0']->data);
- VL_MemToScreenClipped ((byte *)&timenums[str[0]-'0']->data, 8>>2, 16, x+29, y+16);
-
- if ((gamestate.mapon == 6) || (gamestate.mapon == 14) ||
- (gamestate.mapon == 22) || (gamestate.mapon == 32) ||
- (gamestate.mapon == 33))
- {
- p = (pic_t *) W_CacheLumpName ("tnumb", PU_CACHE, Cvt_pic_t, 1);
- //Drawpic (x+40, y+16, 8>>2, 16, (byte *)&p->data);
- VL_MemToScreenClipped ((byte *)&p->data, 8>>2, 16, x+40, y+16);
-
- if (gamestate.mapon == 6)
- level = 1;
- else if (gamestate.mapon == 14)
- level = 2;
- else if (gamestate.mapon == 22)
- level = 3;
- else if (gamestate.mapon == 32)
- level = 4;
- else
- level = 5;
- }
- else
- level = GetLevel (gamestate.episode, gamestate.mapon);
-
- level = abs(level);
- ltoa (level, str, 10);
-
- if (level < 10) {
- //Drawpic (x+49, y+16, 8>>2, 16, (byte *)&timenums[str[0]-'0']->data);
- VL_MemToScreenClipped ((byte *)&timenums[str[0]-'0']->data, 8>>2, 16, x+49, y+16);
- } else {
- //Drawpic (x+49, y+16, 8>>2, 16, (byte *)&timenums[str[0]-'0']->data);
- VL_MemToScreenClipped ((byte *)&timenums[str[0]-'0']->data, 8>>2, 16, x+49, y+16);
- //Drawpic (x+57, y+16, 8>>2, 16, (byte *)&timenums[str[1]-'0']->data);
- VL_MemToScreenClipped ((byte *)&timenums[str[1]-'0']->data, 8>>2, 16, x+57, y+16);
-
- }
- }
- else
- {
- p = (pic_t *) W_CacheLumpName ("battp", PU_CACHE, Cvt_pic_t, 1);
- //Drawpic (x+16, y+15, 32>>2, 16, (byte *)&p->data);
- VL_MemToScreenClipped ((byte *)&p->data, 32>>2, 16, x+16, y+15);
-
- level = abs(gamestate.mapon + 1);
- ltoa (level, str, 10);
-
- if (level < 10) {
- //Drawpic (x+49, y+16, 8>>2, 16, (byte *)&timenums[str[0]-'0']->data);
- VL_MemToScreenClipped ((byte *)&timenums[str[0]-'0']->data, 8>>2, 16, x+49, y+16);
- } else {
- //Drawpic (x+49, y+16, 8>>2, 16, (byte *)&timenums[str[0]-'0']->data);
- VL_MemToScreenClipped ((byte *)&timenums[str[0]-'0']->data, 8>>2, 16, x+49, y+16);
- //Drawpic (x+57, y+16, 8>>2, 16, (byte *)&timenums[str[1]-'0']->data);
- VL_MemToScreenClipped ((byte *)&timenums[str[1]-'0']->data, 8>>2, 16, x+57, y+16);
- }
- }
-}
-
-
-//******************************************************************************
-//
-// GM_MemToScreen ()
-//
-//******************************************************************************
-
-void GM_MemToScreen (byte *source, int width, int height, int x, int y)
-{
- int dest;
- byte *dest1, *dest2, *dest3, mask;
- byte *screen1, *screen2, *screen3;
- int plane;
- int w;
-
-#ifdef DOS
- dest = ylookup[y]+(x>>2);
-#else
- dest = ylookup[y]+x;
-#endif
- mask = 1 << (x&3);
-
- dest1 = (byte *)(dest+page1start);
- dest2 = (byte *)(dest+page2start);
- dest3 = (byte *)(dest+page3start);
-
- for (plane = 0; plane<4; plane++)
- {
- VGAMAPMASK (mask);
-
- screen1 = dest1;
- screen2 = dest2;
- screen3 = dest3;
- for (y = 0; y < height; y++, screen1 += linewidth,
- screen2 += linewidth,
- screen3 += linewidth, source+=width)
- {
-#ifdef DOS
- memcpy (screen1, source, width);
- memcpy (screen2, source, width);
- memcpy (screen3, source, width);
-#else
- for (x = 0; x < width; x++) {
- screen1[x*4+plane] = source[x];
- screen2[x*4+plane] = source[x];
- screen3[x*4+plane] = source[x];
- }
-#endif
- }
-
-#ifdef DOS
- mask <<= 1;
-
- if (mask == 16)
- {
- mask = 1;
- dest1++;
- dest2++;
- dest3++;
- }
-#endif
- }
-}
-
-
-//==========================================================================
-
-/*
-==================
-=
-= ScreenShake
-=
-==================
-*/
-
-void ScreenShake (void)
-{
- static int which = 0;
-// SetTextMode ( );
- if (SHAKETICS != 0xFFFF)
- {
- SHAKETICS -= tics;
- if (SHAKETICS >= 0xFF00) {
- SHAKETICS = 0xFFFF; //bna safety val check
- }
-
- which = (RandomNumber ("ScreenShake",0) & 3);
-
- switch (which)
- {
- case 0:
- displayofs += 1;
- MoveScreenUpLeft();//SetTextMode ( );
- DrawPlayScreen(true);//repaint ammo and life stat
- break;
-
- case 1:
- displayofs -= 1;
- MoveScreenUpRight();
- DrawPlayScreen(true);//repaint ammo and life stat
- break;
-
- case 2:
- displayofs += 3*iGLOBAL_SCREENBWIDE;
- MoveScreenDownLeft();
- DrawPlayScreen(true);//repaint ammo and life stat
- break;
-
- case 3:
- displayofs -= 3*iGLOBAL_SCREENBWIDE;
- MoveScreenDownRight();
- DrawPlayScreen(true);//repaint ammo and life stat
- break;
- }
-
- }
-}
-
-//******************************************************************************
-//
-// DoBorderShifts ()
-//
-//******************************************************************************
-
-void DoBorderShifts (void)
-{
- if (damagecount)
- {
- if (damagecount > 100)
- damagecount = 100;
-
- damagecount -= 6;
-
- if (damagecount < 0)
- damagecount = 0;
-
- SetBorderColor (*(colormap+(((100-damagecount)>>2)<<8)+48));
-
- borderset = true;
- }
- else if (borderset)
- {
- SetBorderColor (0);
- borderset = false;
- }
-}
-
-
-//******************************************************************************
-//
-// DrawHighScores ()
-//
-//******************************************************************************
-
-void DrawHighScores (void)
-{
- char buffer[16];
-#if (SHAREWARE == 0)
- char buffer1[5];
-#endif
- int i,
- w,
- h;
- HighScore *s;
-
- for (i = 0, s = Scores; i < MaxScores; i++, s++)
- {
- PrintY = 25 + (16 * i);
-
- //
- // name
- //
- PrintX = 3*8;
- DrawMenuBufPropString (PrintX, PrintY, s->name);
-
- //
- // level
- //
- ultoa (s->completed, buffer, 10);
-
- PrintX = (17 * 8)-10;
-#if (SHAREWARE == 0)
- itoa (s->episode, buffer1, 10);
-
- DrawMenuBufPropString (PrintX, PrintY, buffer1);
-#else
- DrawMenuBufPropString (PrintX, PrintY, "S");
-#endif
-
- DrawMenuBufPropString (PrintX, PrintY, "-");
-
-#if (SHAREWARE == 0)
- if (s->completed == 7)
- DrawMenuBufPropString (PrintX, PrintY, "B");
- else if (s->completed == 8)
- DrawMenuBufPropString (PrintX, PrintY, "S");
- else if (s->completed == 9)
- DrawMenuBufPropString (PrintX, PrintY, "C");
- else if (s->completed == 10)
- DrawMenuBufPropString (PrintX, PrintY, "D");
- else
- DrawMenuBufPropString (PrintX, PrintY, buffer);
-#else
- DrawMenuBufPropString (PrintX, PrintY, buffer);
-#endif
-
- //
- // score
- //
- ultoa(s->score,buffer,10);
-
- VW_MeasurePropString (buffer, &w, &h);
- PrintX = (33 * 8) - w;
- DrawMenuBufPropString (PrintX, PrintY, buffer);
- }
-}
-
-
-
-//******************************************************************************
-//
-// CheckHighScore ()
-//
-//******************************************************************************
-
-void CheckHighScore (long score, word other, boolean INMENU)
-{
- word i,j;
- int n;
- HighScore myscore;
- int level;
-
- MenuFadeIn();
- if (!INMENU)
- SetupMenuBuf ();
-
- strcpy (myscore.name,"");
- myscore.score = score;
-
- level = GetLevel (gamestate.episode, other-1);
-
- myscore.episode = gamestate.episode;
- myscore.completed = level;
-
- CurrentFont = smallfont;
-
- for (i = 0, n = -1; i < MaxScores; i++)
- {
- if ((myscore.score > Scores[i].score) ||
- ((myscore.score == Scores[i].score) &&
- (myscore.completed > Scores[i].completed)))
- {
- for (j = MaxScores; --j > i;)
- Scores[j] = Scores[j - 1];
- Scores[i] = myscore;
- n = i;
- break;
- }
- }
-
- if (INMENU)
- {
- SetAlternateMenuBuf();
- SetMenuTitle ("High Scores");
- ClearMenuBuf();
- DrawHighScores ();
- if (n != -1)
- DisplayInfo (6);
- else
- DisplayInfo (5);
- FlipMenuBuf ();
- }
- else
- {
- ClearMenuBuf ();
- SetMenuTitle ("High Scores");
- DrawHighScores ();
- if (n != -1)
- DisplayInfo (6);
- else
- DisplayInfo (5);
- RefreshMenuBuf (0);
- }
-
- if (n != -1)
- {
- PrintY = 25 + (16 * n);
- PrintX = 3*8;
- US_LineInput (PrintX, PrintY, Scores[n].name, NULL,
- true, 10, 98, 0);
- }
- else
- {
- IN_ClearKeysDown ();
- if ( INMENU )
- {
- while( !IN_CheckAck () )
- {
- RefreshMenuBuf (0);
- }
- }
- else
- {
- for( i = 0; i <= 150; i += tics )
- {
- RefreshMenuBuf (0);
- if (IN_CheckAck ())
- {
- break;
- }
- }
- }
- }
-
- if (INMENU)
- {
- SD_Play (SD_ESCPRESSEDSND);
- }
- else
- {
- ShutdownMenuBuf ();
- }
-}
-
-
-//===========================================================================
-
-//#define HEADERX 140
-//#define BONERNAMEX 170
-#define HEADERX 152
-#define BONERNAMEX 166
-
-
-/*
-==================
-=
-= DrawEOLHeader ()
-=
-==================
-*/
-void DrawEOLHeader
-(
- int playstate
-)
-
-{
- int health;
- char tempstr[ 15 ];
- char *string;
- int level;
- int w;
- int h;
-
- VWB_TBar( 30, 5, 250, 75 );
-
- switch( playstate )
- {
- case ex_skiplevel :
- if ( ( gamestate.violence >= vl_high ) &&
- ( gamestate.difficulty >= gd_hard ) )
- {
- string = "LEVEL WUSSED OUT ON!";
- }
- else
- {
- string = "LEVEL SKIPPED.";
- }
- break;
-
- case ex_secretdone :
- string = "SECRET LEVEL COMPLETED!";
- break;
-
- case ex_secretlevel :
- string = "SECRET EXIT TAKEN!";
- break;
-
- case ex_gameover :
- string = "GAME COMPLETED!";
- break;
-
- case ex_bossdied :
- string = "BOSS DEFEATED!";
- break;
-
- default :
- string = "LEVEL COMPLETED!";
- break;
- }
-
- VW_MeasurePropString( string, &w, &h );
-
- px = ( 320 - w ) / 2;
- py = 10;
- VWB_DrawPropString( string );
-
- // draw episode number
- string = "EPISODE";
- VW_MeasurePropString( string, &w, &h );
- px = HEADERX - w;
- py = 25;
- VWB_DrawPropString( string );
-
- itoa( gamestate.episode, tempstr, 10 );
- px = BONERNAMEX;
- VWB_DrawPropString( tempstr );
-
- // draw area number
- level = GetLevel( gamestate.episode, gamestate.mapon );
- itoa( level, tempstr, 10 );
-
- py = 35;
-
- if ( playstate == ex_secretdone )
- {
- string = "SECRET AREA";
- }
- else if ( playstate == ex_bossdied )
- {
- string = "BOSS AREA";
- }
- else if ( gamestate.mapon == 32 )
- {
- string = "CHASE AREA";
- }
- else
- {
- string = "AREA";
- }
-
- VW_MeasurePropString( string, &w, &h);
- px = HEADERX - w;
- VWB_DrawPropString( string );
-
- if ( gamestate.mapon != 33 )
- {
- px = BONERNAMEX;
- VWB_DrawPropString( tempstr );
- }
-
- string = "SCORE";
- VW_MeasurePropString( string, &w, &h);
- px = HEADERX - w;
- py = 45;
- VWB_DrawPropString( string );
-
- px = BONERNAMEX;
- itoa( gamestate.score, tempstr, 10 );
- VWB_DrawPropString( tempstr );
-
- string = "HEALTH";
- VW_MeasurePropString( string, &w, &h );
- px = HEADERX - w;
- py = 55;
- VWB_DrawPropString( string );
-
- px = BONERNAMEX;
- health = ( ( locplayerstate->health * 100 ) /
- MaxHitpointsForCharacter( locplayerstate ) );
-
- itoa( health, tempstr, 10 );
- VWB_DrawPropString( tempstr );
- VWB_DrawPropString( "%" );
-
- //
- // Secret count
- //
-
- {
- char str1[10];
- char str2[10];
-
- itoa(gamestate.secretcount,&(str1[0]),10);
- strcat(str1," / ");
- itoa(gamestate.secrettotal,&(str2[0]),10);
- strcat(str1,str2);
- string = "SECRET WALLS";
- VW_MeasurePropString( string, &w, &h );
- px = HEADERX - w;
- py = 65;
- VWB_DrawPropString( string );
-
- px = BONERNAMEX;
- VWB_DrawPropString( str1 );
- }
-
- VW_UpdateScreen ();
-}
-
-boolean EndBonusFirst;
-boolean EndBonusSkip;
-int EndBonusNumBonuses;
-int EndBonusVoice;
-int EndBonusStartY;
-
-void DrawEndBonus
-(
- char *string,
- char *bonusstring,
- int type
-)
-
-{
- int w;
- int h;
- int health;
- char tempstr[ 15 ];
-
- if ( EndBonusFirst )
- {
- VWB_TBar( 5, EndBonusStartY - 2, 310, 4 );
- EndBonusFirst = false;
- }
-
- VWB_TBar( 5, EndBonusStartY + 2, 310, 10 );
- VW_MeasurePropString( string, &w, &h );
-
- py = EndBonusStartY;
- if ( bonusstring == NULL )
- {
- px = ( 320 - w ) / 2;
- VWB_DrawPropString( string );
- }
- else
- {
- px = BONERNAMEX - w;
- VWB_DrawPropString( string );
-
- EndBonusNumBonuses++;
- VW_MeasurePropString( bonusstring, &w, &h );
- px = 310 - w;
- py = EndBonusStartY;
- VWB_DrawPropString( bonusstring );
- }
-
- // Update Score
- py = 45;
- px = BONERNAMEX;
- V_ReDrawBkgnd( px, py, 107, 11, false );
- VWB_TBar( px, py, 107, 11 );
- itoa( gamestate.score, tempstr, 10 );
- VWB_DrawPropString( tempstr );
-
- // Update Health
- py = 55;
- px = BONERNAMEX;
- V_ReDrawBkgnd( px, py, 107, 11, false );
- VWB_TBar( px, py, 107, 11 );
- health = ( ( locplayerstate->health * 100 ) /
- MaxHitpointsForCharacter( locplayerstate ) );
- itoa( health, tempstr, 10 );
- VWB_DrawPropString( tempstr );
- VWB_DrawPropString( "%" );
-
- switch( type )
- {
- case 0 :
- EndBonusVoice = SD_Play( SD_ENDBONUS1SND );
- break;
-
- case 1 :
- EndBonusVoice = SD_Play( SD_NOBONUSSND );
- break;
-
- case 2 :
- VL_FillPalette(255,255,255);
- //bna--VW_UpdateScreen();
- VL_FadeIn(0,255,origpal,10);
- EndBonusVoice = SD_Play( SD_LIGHTNINGSND );
- break;
- }
-
- EndBonusStartY += 10;
-
- //bna--VW_UpdateScreen();
- while( SD_SoundActive( EndBonusVoice ) && !EndBonusSkip )
- {
- if ( IN_CheckAck() )
- {
- EndBonusSkip = true;
- }
- }
-}
-
-
-
-/*
-==================
-=
-= LevelCompleted
-=
-= Exit with the screen faded out
-=
-==================
-*/
-
-extern int OLDLMWEAPON;
-extern int OLDLWEAPON;
-
-void LevelCompleted
-(
- exit_t playstate
-)
-
-{
- objtype *obj;
- boolean dobonus;
- int i;
- int kr;
- int sr;
- int tr;
- int missileratio;
- int superratio;
- int healthratio;
- int democraticratio;
- int plantratio;
- int cnt;
-
- pic_t *tmpPic;
-// byte *picbuf;
-
- EndBonusNumBonuses = 0;
- EndBonusFirst = true;
- EndBonusSkip = false;
- EndBonusStartY = 90;
-
- EnableScreenStretch();
- tmpPic = ( pic_t * )W_CacheLumpName( "mmbk", PU_CACHE, Cvt_pic_t, 1 );
- VWB_DrawPic( 0, 0, tmpPic );
- VW_UpdateScreen();
-// DisableScreenStretch();
-
- IN_StartAck();
- EndBonusVoice = 0;
-
-
- if ( playstate != ex_bossdied )
- {
- EndBonusVoice = SD_Play( SD_LEVELDONESND );
- VL_FillPalette( 255, 255, 255 );
- VL_FadeIn( 0, 255, origpal, 10 );
- if ( player->flags & FL_DOGMODE )
- {
- MU_StartSong( song_dogend );
- }
- else
- {
- MU_StartSong( song_endlevel );
- }
- }
-
- BkPic = ( pic_t * )W_CacheLumpName( "mmbk", PU_CACHE, Cvt_pic_t, 1 );
- VWB_DrawPic( 0, 0, BkPic );
-
- CheckHolidays();
- CurrentFont = smallfont;
-
- // Kill powerups
- if ( player->flags & FL_ELASTO )
- {
- player->flags &= ~FL_NOFRICTION;
- }
-
- player->flags &= ~( FL_FLEET | FL_SHROOMS | FL_ELASTO | FL_GODMODE |
- FL_DOGMODE | FL_BPV | FL_AV | FL_GASMASK );
-
- // Turn off quickload for next level
- pickquick = false;
-
- //
- // FIGURE RATIOS OUT BEFOREHAND
- //
- kr = 0;
- tr = 0;
- tr = 0;
- superratio = 0;
- missileratio = 0;
- healthratio = 0;
- democraticratio = 0;
- plantratio = 0;
-
- if ( gamestate.killtotal )
- {
- kr = ( int )( ( ( int )gamestate.killcount ) * 100 ) /
- ( ( int )gamestate.killtotal );
- }
-
- if ( gamestate.secrettotal )
- {
- sr = ( int )( ( ( int )gamestate.secretcount ) * 100 ) /
- ( ( int )gamestate.secrettotal );
- }
-
- if ( gamestate.treasuretotal )
- {
- tr = ( int )( ( ( int )gamestate.treasurecount ) * 100 ) /
- ( ( int )gamestate.treasuretotal );
- }
-
- if ( gamestate.supertotal )
- {
- superratio = ( int )( ( ( int )gamestate.supercount ) * 100 ) /
- ( ( int )gamestate.supertotal );
- }
-
- if ( gamestate.missiletotal )
- {
- missileratio = ( int )( ( ( int )gamestate.missilecount ) * 100 ) /
- ( ( int )gamestate.missiletotal );
- }
-
- if ( gamestate.healthtotal )
- {
- healthratio = ( int )( ( ( int )gamestate.healthcount ) * 100 ) /
- ( ( int )gamestate.healthtotal );
- }
-
- if ( gamestate.democratictotal )
- {
- democraticratio = ( int )( ( ( int )gamestate.democraticcount ) *
- 100 ) / ( ( int )gamestate.democratictotal );
- }
-
- if ( gamestate.planttotal )
- {
- plantratio = ( int )( ( ( int )gamestate.plantcount ) * 100 ) /
- ( ( int )gamestate.planttotal );
- }
-
- DrawEOLHeader( playstate );
- /*
- //bna section store picture because its written on again
- // store screen first
- picbuf = (byte *)SafeMalloc (64000);
- memcpy(picbuf ,bufferofs ,64000);
-
- EnableScreenStretch();
- VW_UpdateScreen();//tmpPICbuf is destroyed here
- DisableScreenStretch();
- //copy it back
-
- memcpy(bufferofs ,picbuf , 64000);
- //bna section end
- */
-
- EndBonusSkip = true;
-
- while( SD_SoundActive( EndBonusVoice ) && !EndBonusSkip )
- {
-
- //bna--VW_UpdateScreen();
-
- if ( IN_CheckAck() )
- {
- EndBonusSkip = true;
- }
- }
-// tmpPic = ( pic_t * )W_CacheLumpName( "mmbk", PU_CACHE, Cvt_pic_t, 1 );
-// VWB_DrawPic( 0, 0, tmpPic );
-
- if ( GetNextMap(player->tilex,player->tiley) == -1)
- {
- if ( gamestate.dipballs == 3 )
- {
- gamestate.score += 100000;
- DrawEndBonus( "DIP BONUS", "100000 POINTS", 0 );
- EndBonusStartY += 10;
- }
-
- if ( locplayerstate->lives > 0 )
- {
- char str[20];
- char str2[60];
-
- DrawEndBonus( "EXTRA LIVES BONUS", "\0", 0 );
- itoa(locplayerstate->lives,str,10);
- strcpy(str2,str);
- strcat(str2," EXTRA LIVES =");
- DrawEndBonus( "\0", str2, 0 );
- itoa(locplayerstate->lives,str,10);
- strcpy(str2,str);
- strcat(str2," X 10000 = ");
- itoa(locplayerstate->lives*10000,str,10);
- strcat(str2,str);
- strcat(str2," POINTS");
- gamestate.score += 10000*locplayerstate->lives;
- DrawEndBonus( "\0", str2, 0 );
- }
- }
- else
- {
- //
- // Check for SKIN OF YO TEETH
- //
- if ( locplayerstate->health <= 10 )
- {
- locplayerstate->health = MaxHitpointsForCharacter( locplayerstate );
- DrawEndBonus( "SKIN OF YOUR TEETH", "100% HEALTH", 0 );
- }
-
- // BULL IN CHINA SHOP BONUS
- if ( tr == 100 )
- {
- gamestate.score += 10000;
- DrawEndBonus( "BULL IN CHINA SHOP", "10000 POINTS", 0 );
- }
-
- // SUPERCHARE BONUS
- if ( superratio == 100 )
- {
- gamestate.score += 10000;
- DrawEndBonus( "SUPERCHARGE BONUS", "10000 POINTS", 0 );
- }
-
- // BLEEDER BONUS
- if ( healthratio == 100 )
- {
- gamestate.score += 10000;
- DrawEndBonus( "BLEEDER BONUS", "10000 POINTS", 0 );
- }
-
- // ADRENALINE BONUS
- if ( kr == 100 )
- {
- gamestate.score += 10000;
- DrawEndBonus( "ADRENALINE BONUS", "10000 POINTS", 0 );
- }
-
- // CURIOSITY BONUS
- dobonus = true;
-
- //
- // Check switches
- cnt = lastswitch - &switches[ 0 ];
- if ( cnt != 0 )
- {
- for ( i = 0; i < cnt; i++ )
- {
- if ( ( switches[ i ].flags & FL_S_FLIPPED ) == 0 )
- {
- dobonus = false;
- break;
- }
- }
- }
-
- //
- // Check pillars
- for ( obj = FIRSTACTOR; obj != NULL; obj = obj->next )
- {
- if ( ( obj->obclass == pillarobj ) &&
- ( ( obj->flags & FL_FLIPPED ) == 0 ) )
- {
- dobonus = false;
- }
- }
-
- if ( ( gamestate.secrettotal ) && ( sr != 100 ) )
- {
- dobonus = false;
- }
-
- if ( dobonus )
- {
- gamestate.score += 10000;
- DrawEndBonus( "CURIOSITY BONUS", "10000 POINTS", 0 );
- }
-
- // GROUND ZERO BONUS
- if ( gamestate.DOGROUNDZEROBONUS )
- {
- gamestate.score += 10000;
- DrawEndBonus( "GROUND ZERO BONUS", "10000 POINTS", 0 );
- }
-
- // REPUBLICAN BONUS 1
- if ( missileratio == 100 )
- {
- gamestate.score += 5000;
- DrawEndBonus( "REPUBLICAN BONUS 1", " 5000 POINTS", 0 );
- }
-
- // REPUBLICAN BONUS 2
- if (plantratio == 100)
- {
- gamestate.score += 5000;
- DrawEndBonus( "REPUBLICAN BONUS 2", " 5000 POINTS", 0 );
- }
-
- // DEMOCRATIC BONUS 1
- if ( gamestate.DODEMOCRATICBONUS1 )
- {
- gamestate.score += 5000;
- DrawEndBonus( "DEMOCRATIC BONUS 1", " 5000 POINTS", 0 );
- }
-
- // DEMOCRATIC BONUS 2
- if (democraticratio == 100)
- {
- gamestate.score += 5000;
- DrawEndBonus( "DEMOCRATIC BONUS 2", " 5000 POINTS", 0 );
- }
- }
-
- if ( EndBonusNumBonuses == 0 )
- {
- DrawEndBonus( "NO BONUS!", NULL, 1 );
- }
-
- if ( ( EndBonusNumBonuses != 0 ) || ( playstate == ex_gameover ) )
- {
- SD_Play( PlayerSnds[ locplayerstate->player ] );
-
- // DO BONUS BONUS
- if ( EndBonusNumBonuses == NUMBONUSES )
- {
- IN_StartAck();
- while( !IN_CheckAck() )
- {
- ;
- }
-
- BkPic = ( pic_t * )W_CacheLumpName( "mmbk", PU_CACHE, Cvt_pic_t, 1 );
- VWB_DrawPic( 0, 0, BkPic );
-
- gamestate.score += BONUSBONUS;
- DrawEOLHeader( playstate );
- EndBonusFirst = true;
- EndBonusStartY = 110;
- EndBonusSkip = true;
- DrawEndBonus( "BONUS BONUS! 1,000,000 POINTS!", NULL, 2 );
- }
- else if ( ( kr == 100 ) && ( dobonus ) )
- {
- IN_StartAck();
- while( !IN_CheckAck() )
- {
- ;
- }
-
- BkPic = ( pic_t * )W_CacheLumpName( "mmbk", PU_CACHE, Cvt_pic_t, 1 );
- VWB_DrawPic( 0, 0, BkPic );
-
- DrawEOLHeader( playstate );
- EndBonusFirst = true;
- EndBonusStartY = 110;
- DrawEndBonus( "You have done well.", NULL, 3 );
-
-#if (SHAREWARE==1)
- EndBonusVoice = SD_Play( SD_RICOCHET3SND );
-#else
- EndBonusVoice = SD_Play( SD_PERCENT100SND );
-#endif
-
- EndBonusSkip = false;
- DrawEndBonus( "This level is toast.", NULL, 3 );
-
- }
- }
-
-
-
- //bna section
-// EnableScreenStretch();//bna++
- VW_UpdateScreen();//bna++
-// DisableScreenStretch();//bna++
- //bna section end
-
-
- IN_StartAck();
- while( !IN_CheckAck() )
- {
- ;
- }
-
- EndLevelStuff = false;
- CurrentFont = smallfont;
-}
-
-
-void DrawTallyHeader
-(
- int which
-)
-
-{
- pic_t *Name;
- pic_t *KillCount;
- pic_t *TimesYouKilledPerson;
- pic_t *TimesPersonKilledYou;
- pic_t *Suicides;
- pic_t *Score;
- pic_t *Blank;
- pic_t *TopBar;
-
- Name = ( pic_t * )W_CacheLumpName( "t_name", PU_CACHE, Cvt_pic_t, 1 );
- Blank = ( pic_t * )W_CacheLumpName( "t_blnk", PU_CACHE, Cvt_pic_t, 1 );
- KillCount = ( pic_t * )W_CacheLumpName( "t_kcount", PU_CACHE, Cvt_pic_t, 1 );
- TimesYouKilledPerson = ( pic_t * )W_CacheLumpName( "t_kilper", PU_CACHE, Cvt_pic_t, 1 );
- TimesPersonKilledYou = ( pic_t * )W_CacheLumpName( "t_perkil", PU_CACHE, Cvt_pic_t, 1 );
- Suicides = ( pic_t * )W_CacheLumpName( "t_suicid", PU_CACHE, Cvt_pic_t, 1 );
- Score = ( pic_t * )W_CacheLumpName( "t_score", PU_CACHE, Cvt_pic_t, 1 );
- TopBar = ( pic_t * )W_CacheLumpName( "t_bar", PU_CACHE, Cvt_pic_t, 1 );
-
- IFont = ( cfont_t * )W_CacheLumpName( "sifont", PU_CACHE, Cvt_cfont_t, 1 );
-
- switch( which )
- {
- case 0 :
- VWB_DrawPic ( 8, 8, TopBar );
- DrawIntensityString( 12, 11, "FINAL SCORE", 20 );
- VWB_DrawPic ( 8, 24, Name );
- VWB_DrawPic ( 136, 24, KillCount );
- VWB_DrawPic ( 184, 24, Suicides );
- VWB_DrawPic ( 272, 24, Score );
- break;
-
- case 1 :
- VWB_DrawPic ( 8, 8, TopBar );
- DrawIntensityString( 12, 11, "FINAL SCORE", 20 );
- VWB_DrawPic ( 8, 24, Name );
- VWB_DrawPic ( 136, 24, Blank );
- VWB_DrawPic ( 272, 24, Score );
- break;
-
- case 2 :
- VWB_DrawPic ( 8, 8, TopBar );
- DrawIntensityString( 12, 11, "YOUR KILLS", 20 );
- VWB_DrawPic ( 8, 24, Name );
- VWB_DrawPic ( 136, 24, KillCount );
- VWB_DrawPic ( 184, 24, TimesYouKilledPerson );
- break;
-
- case 3 :
- VWB_DrawPic ( 8, 8, TopBar );
- DrawIntensityString( 12, 11, "YOUR DEATHS", 20 );
- VWB_DrawPic ( 8, 24, Name );
- VWB_DrawPic ( 136, 24, TimesPersonKilledYou );
- break;
-//bna added
- case 4 :
- VWB_DrawPic ( 198+48, 8, Blank );
- VWB_DrawPic ( 8, 8, TopBar );
- DrawIntensityString( 12, 11, "FINAL SCORE", 20 );
- VWB_DrawPic ( 8, 24, TopBar );//used to blank
- VWB_DrawPic ( 8, 24, Name );
- VWB_DrawPic ( 136, 24, KillCount);
- VWB_DrawPic ( 198, 24, TimesPersonKilledYou);
- VWB_DrawPic ( 198+48, 24, Blank );
- VWB_DrawPic ( 272, 24, Score );
- break;
-//bna added end
- }
-
- DrawTimeXY( TALLYTIME_X, TALLYTIME_Y, gamestate.TimeCount / VBLCOUNTER,
- true );
-}
-
-
-#define BT_RANK_X 23
-#define BT_PLAYER_X 30
-#define BT_KILLS_X ( 139 + ( ( 40 + 20 ) / 2 ) )
-#define BT_DEATHS_X ( 193 + ( ( 56 + 20 ) / 2 ) )
-//#define BT_SCORE_X ( 263 + ( ( 46 + 20 ) / 2 ) )
-#define BT_SCORE_X ( 273 + ( ( 46 + 20 ) / 2 ) )
-
-
-void ShowKills( int localplayer )
-{
- int w;
- int h;
- int i;
- int j;
- int temp;
- int rank;
- int player;
- int killer;
- int victim;
- int color;
- char tempstr[15];
- int KillCount[ MAXPLAYERS ];
- int Order[ MAXPLAYERS ];
- int NumPlayers;
-
- // show at the most 11 players
- NumPlayers = min( numplayers, 11 );
-
- // Count kills
- for( killer = 0; killer < NumPlayers; killer++ )
- {
- Order[ killer ] = killer;
- KillCount[ killer ] = 0;
- for( victim = 0; victim < NumPlayers; victim++ )
- {
- if ( BATTLE_Team[ victim ] != BATTLE_Team[ killer ] )
- {
- KillCount[ killer ] += WhoKilledWho[ killer ][ victim ];
- }
- }
- }
-
- for( i = 0; i < NumPlayers - 1; i++ )
- {
- for( j = i + 1; j < NumPlayers; j++ )
- {
- if ( KillCount[ Order[ i ] ] < KillCount[ Order[ j ] ] )
- {
- temp = Order[ i ];
- Order[ i ] = Order[ j ];
- Order[ j ] = temp;
- }
- }
- }
-
- DrawTallyHeader( 2 );
-
- IFont = (cfont_t * )W_CacheLumpNum (W_GetNumForName ("sifont"), PU_CACHE, Cvt_cfont_t, 1);
- CurrentFont = smallfont;
- py = 43;
-
- for( rank = 0; rank < NumPlayers; rank++ )
- {
- player = Order[ rank ];
-
- color = 21;
-
- // Highlight the your score
- if ( player == localplayer )
- {
- // Change to Intensity
- color = 241;
- }
-
- // Draw rank if not tied with previous rank
- if ( ( rank == 0 ) || ( KillCount[ player ] !=
- KillCount[ Order[ rank - 1 ] ] ) )
- {
- itoa( rank + 1, tempstr, 10 );
- }
- else
- {
- strcpy( tempstr, "Tie" );
- }
-
- VW_MeasureIntensityPropString ( tempstr, &w, &h);
- DrawIntensityString( BT_RANK_X - w, py, tempstr, color );
-
- // Draw name
- DrawIntensityString( BT_PLAYER_X, py, PLAYERSTATE[ player ].codename, color );
-
- // Draw kills
- itoa( KillCount[ player ], tempstr, 10 );
- VW_MeasureIntensityPropString ( tempstr, &w, &h);
- DrawIntensityString( BT_KILLS_X - w, py, tempstr, color );
-
- // Draw times you killed that person
- if ( player != localplayer )
- {
- itoa( WhoKilledWho[ localplayer ][ player ], tempstr, 10 );
- }
- else
- {
- strcpy( tempstr, "-" );
- }
-
- VW_MeasureIntensityPropString ( tempstr, &w, &h);
- DrawIntensityString( BT_DEATHS_X - w, py, tempstr, color );
-
- if ( gamestate.teamplay )
- {
- DrawIntensityString( BT_DEATHS_X + 16, py,
- colorname[ PLAYERSTATE[ player ].uniformcolor ], color );
- }
-
- py += h;
- }
-}
-
-
-void ShowDeaths( int localplayer )
-{
- int w;
- int h;
- int i;
- int j;
- int temp;
- int rank;
- int player;
- int killer;
- int victim;
- int color;
- char tempstr[15];
- int DeathCount[ MAXPLAYERS ];
- int Order[ MAXPLAYERS ];
- int NumPlayers;
-
- // show at the most 11 players
- NumPlayers = min( numplayers, 11 );
-
- // Count Deaths
- for( victim = 0; victim < NumPlayers; victim++ )
- {
- Order[ victim ] = victim;
- DeathCount[ victim ] = 0;
- for( killer = 0; killer < NumPlayers; killer++ )
- {
- DeathCount[ victim ] += WhoKilledWho[ killer ][ victim ];
- }
- }
-
- for( i = 0; i < NumPlayers - 1; i++ )
- {
- for( j = i + 1; j < NumPlayers; j++ )
- {
- if ( DeathCount[ Order[ i ] ] < DeathCount[ Order[ j ] ] )
- {
- temp = Order[ i ];
- Order[ i ] = Order[ j ];
- Order[ j ] = temp;
- }
- }
- }
-
- DrawTallyHeader( 3 );
-
- IFont = (cfont_t * )W_CacheLumpNum (W_GetNumForName ("sifont"), PU_CACHE, Cvt_cfont_t, 1);
- CurrentFont = smallfont;
- py = 43;
-
- for( rank = 0; rank < NumPlayers; rank++ )
- {
- player = Order[ rank ];
- color = 21;
-
- // Highlight the your score
- if ( player == localplayer )
- {
- // Change to Intensity
- color = 241;
- }
-
- // Draw rank if not tied with previous rank
- if ( ( rank == 0 ) || ( DeathCount[ player ] !=
- DeathCount[ Order[ rank - 1 ] ] ) )
- {
- itoa( rank + 1, tempstr, 10 );
- }
- else
- {
- strcpy( tempstr, "Tie" );
- }
-
- VW_MeasureIntensityPropString ( tempstr, &w, &h);
- DrawIntensityString( BT_RANK_X - w, py, tempstr, color );
-
- // Draw name
- DrawIntensityString( BT_PLAYER_X, py, PLAYERSTATE[ player ].codename, color );
-
- // Draw deaths
- itoa( DeathCount[ player ], tempstr, 10 );
- VW_MeasureIntensityPropString ( tempstr, &w, &h);
- DrawIntensityString( BT_KILLS_X - w, py, tempstr, color );
-
- // Draw times you were killed by that person
- itoa( WhoKilledWho[ player ][ localplayer ], tempstr, 10 );
- VW_MeasureIntensityPropString ( tempstr, &w, &h);
- DrawIntensityString( BT_DEATHS_X - w, py, tempstr, color );
-
- if ( gamestate.teamplay )
- {
- DrawIntensityString( BT_DEATHS_X + 16, py,
- colorname[ PLAYERSTATE[ player ].uniformcolor ], color );
- }
-
- py += h;
- }
-}
-
-
-void ShowEndScore( int localplayer )
-{
- int w;
- int h;
- int rank;
- int leader;
- int team;
- int color;
- int killer;
- int victim;
- int killcount;
- int suicidecount;
- char tempstr[15];
- boolean dofullstats;
- int NumPlayers;
-
- // show at the most 11 players
- NumPlayers = min( numplayers, 11 );
-
- dofullstats = false;
- switch( gamestate.battlemode )
- {
- case battle_Normal :
- case battle_ScoreMore :
- case battle_Hunter :
- dofullstats = true;
- DrawTallyHeader( 0 );
- break;
-
- case battle_Collector :
- case battle_Scavenger :
- case battle_Tag :
- case battle_Eluder :
- case battle_Deluder :
- case battle_CaptureTheTriad :
- dofullstats = false;
- DrawTallyHeader( 1 );
- break;
- }
-
- IFont = (cfont_t * )W_CacheLumpNum (W_GetNumForName ("sifont"), PU_CACHE, Cvt_cfont_t, 1);
- CurrentFont = smallfont;
- py = 43;
-
- for( rank = 0; rank < BATTLE_NumberOfTeams; rank++ )
- {
- team = BATTLE_PlayerOrder[ rank ];
-
- color = 21;
- if ( team == BATTLE_Team[ localplayer ] )
- {
- // Change to Intensity
- color = 241;
- }
-
- // Draw rank if not tied with previous rank
- if ( ( rank == 0 ) || ( BATTLE_Points[ team ] !=
- BATTLE_Points[ BATTLE_PlayerOrder[ rank - 1 ] ] ) )
- {
- itoa( rank + 1, tempstr, 10 );
- }
- else
- {
- strcpy( tempstr, "Tie" );
- }
-
- VW_MeasureIntensityPropString ( tempstr, &w, &h);
- DrawIntensityString( BT_RANK_X - w, py, tempstr, color );
-
- // Draw name of team leader
- leader = BATTLE_TeamLeader[ team ];
- if ( gamestate.teamplay )
- {
- DrawIntensityString( BT_PLAYER_X, py,
- colorname[ PLAYERSTATE[ leader ].uniformcolor ], color );
- }
- else
- {
- DrawIntensityString( BT_PLAYER_X, py,
- PLAYERSTATE[ leader ].codename, color );
- }
-
- if ( dofullstats )
- {
- // Count how many kills each person on the team got
- killcount = 0;
- suicidecount = 0;
- for( killer = 0; killer < NumPlayers; killer++ )
- {
- if ( BATTLE_Team[ killer ] == team )
- {
- for( victim = 0; victim < NumPlayers; victim++ )
- {
- if ( BATTLE_Team[ victim ] != team )
- {
- killcount += WhoKilledWho[ killer ][ victim ];
- }
- else
- {
- suicidecount += WhoKilledWho[ killer ][ victim ];
- }
- }
- }
- }
-
- // Draw kills
- itoa( killcount, tempstr, 10 );
- VW_MeasureIntensityPropString ( tempstr, &w, &h);
- DrawIntensityString( BT_KILLS_X - w, py, tempstr, color );
-
- // Draw suicides
- itoa( suicidecount, tempstr, 10 );
- VW_MeasureIntensityPropString ( tempstr, &w, &h);
- DrawIntensityString( BT_DEATHS_X - w, py, tempstr, color );
- }
-
- // Draw Score
- itoa( BATTLE_Points[ team ], tempstr, 10 );
- VW_MeasureIntensityPropString ( tempstr, &w, &h);
- DrawIntensityString( BT_SCORE_X - w, py, tempstr, color );
-
- py += h;
- }
-}
-
-
-void BattleLevelCompleted ( int localplayer )
-{
- ControlInfo ci;
- int w;
- int h;
- int key;
- int Screen;
- int LastScreen;
- int Player;
- char text[80];
-
- EnableScreenStretch();
-
- IN_ClearKeysDown ();
-
- Player = localplayer;
- Screen = 1;
- LastScreen = 0;
- key = -1;
- while( 1 )
- {
- if ( Screen != LastScreen )
- {
- VL_DrawPostPic (W_GetNumForName("trilogo"));
-
- switch( Screen )
- {
- case 1 :
- ShowEndScore( Player );
- break;
-
- case 2 :
- ShowKills( Player );
- break;
-
- case 3 :
- ShowDeaths( Player );
- break;
- }
-
- CurrentFont = tinyfont;
-
- sprintf ( text, "Page %d of 3. Use arrows to switch stats. "
- "Press Esc to quit.", Screen );
- VW_MeasurePropString ( text, &w, &h);
- py = 192;
- px = ( 320 - w ) / 2;
- VWB_DrawPropString ( text );
- VW_UpdateScreen ();
-
- do
- {
- ReadAnyControl (&ci);
- }
- while( ci.dir == (dirtype)key );
- }
-
- LastScreen = Screen;
- ReadAnyControl ( &ci );
- key = ci.dir;
- if ( ( Screen > 1 ) && ( key == dir_West ) )
- {
- Screen--;
- MN_PlayMenuSnd (SD_MOVECURSORSND);
- }
- else if ( ( Screen < 3 ) && ( key == dir_East ) )
- {
- Screen++;
- MN_PlayMenuSnd (SD_MOVECURSORSND);
- }
- // Allow us to select which player to view
- if ( Keyboard[ sc_RShift ] && ( key == dir_South ) )
- {
- Player++;
- if ( Player >= numplayers )
- {
- Player = 0;
- }
- LastScreen = 0;
- MN_PlayMenuSnd (SD_SELECTSND);
- }
-
- if ( Keyboard[ sc_RShift ] && ( key == dir_North ) )
- {
- Player--;
- if ( Player < 0 )
- {
- Player = numplayers - 1;
- }
- LastScreen = 0;
- MN_PlayMenuSnd (SD_SELECTSND);
- }
-
- if ( Keyboard[sc_Escape] )
- {
- break;
- }
- }
-
- while ( Keyboard[sc_Escape] )
- {
- IN_UpdateKeyboard ();
- }
-
- MN_PlayMenuSnd (SD_ESCPRESSEDSND);
-
- CurrentFont = smallfont;
-}
-
-//==========================================================================
-
-/*
-==================
-=
-= FindAngleToWindow
-=
-==================
-*/
-int FindAngleToWindow ( int tx, int ty )
-{
- if (!IsWindow(tx+1,ty))
- return ANG180;
- else if (!IsWindow(tx-1,ty))
- return 0;
- else if (!IsWindow(tx,ty+1))
- return ANG90;
- else
- return ANG270;
-}
-
-#define STARTRADIUS (0xa000)
-#define STOPRADIUS (0x14000)
-#define DEATHRADIUS (STOPRADIUS-STARTRADIUS)
-#define ROTRATE (5)
-#define TOTALDEATHROT (FINEANGLES<<1)
-#define RADIUSINC ((DEATHRADIUS)/(TOTALDEATHROT))
-
-/*
-==================
-=
-= ZoomDeathOkay
-=
-==================
-*/
-boolean ZoomDeathOkay ( void )
-{
- int x,y;
- int radius;
-
- if (
- !(
- (player->state==&s_ashwait) ||
- ((player->flags & FL_HBM) && (gamestate.violence >= vl_high))
- )
- )
- return false;
-
- radius=STOPRADIUS;
- x=player->x;
- y=player->y;
- while (radius>0)
- {
- if (tilemap[x>>16][(y+radius)>>16])
- return false;
- if (tilemap[x>>16][(y-radius)>>16])
- return false;
- if (tilemap[(x-radius)>>16][y>>16])
- return false;
- if (tilemap[(x+radius)>>16][y>>16])
- return false;
- if (tilemap[(x+radius)>>16][(y+radius)>>16])
- return false;
- if (tilemap[(x+radius)>>16][(y-radius)>>16])
- return false;
- if (tilemap[(x-radius)>>16][(y+radius)>>16])
- return false;
- if (tilemap[(x-radius)>>16][(y-radius)>>16])
- return false;
- radius-=0x10000;
- }
- return true;
-}
-
-/*
-==================
-=
-= Died
-=
-==================
-*/
-
-#define DEATHROTATE 6
-
-extern boolean dopefish;
-void Died (void)
-{
- long dx,dy;
- int iangle,curangle,clockwise,change;
- int da;
- int rate;
- lbm_t *LBM;
- int slowrate;
- playertype *pstate;
- objtype * killerobj=(objtype *)player->target;
- player->yzangle=0;
-
- if (killerobj == NULL)
- killerobj = player;
-
- if (CheckParm("slowdeath"))
- slowrate=3;
- else
- slowrate=0;
-
- M_LINKSTATE (player, pstate);
-
- if ( (ZoomDeathOkay()==true) && (pstate->falling==false))
- {
- int x,y,z,radius,heightoffset;
- int endangle,startangle,killangle;
- boolean deadflagset;
- objtype * dummy;
-
- x=player->x;
- y=player->y;
- z=player->z;
- dummy=player;
- SpawnPlayerobj (x>>16, y>>16, 0, 0);
- player=dummy;
- dummy=new;
- dummy->x=x;
- dummy->drawx=x;
- dummy->y=y;
- dummy->z=z;
- dummy->drawy=y;
- dummy->flags=player->flags;
- player->momentumx=0;
- player->momentumy=0;
- player->speed=0;
- radius=STARTRADIUS;
- heightoffset=pstate->heightoffset;
- deadflagset=false;
- startangle=(player->angle+ANG180)&(FINEANGLES-1);
- endangle=startangle+TOTALDEATHROT;
- killangle=startangle+(TOTALDEATHROT>>1);
- if (dopefish==true)
- {
- AddMessage("Dopefish Death Cam",MSG_SYSTEM);
- }
- for (iangle=startangle;;)
- {
- if ( iangle > killangle )
- {
- if ( deadflagset==false )
- {
- dummy->hitpoints=0;
- pstate->health=0;
- dummy->flags &= ~FL_DYING;
- dummy->flags |= FL_SHOOTABLE;
- if (player->state==&s_ashwait)
- dummy->flags |= FL_SKELETON;
- Collision(dummy,(objtype*)NULL,0,0);
- deadflagset=true;
- if ( ( killerobj==player ) && ( gamestate.violence >=
- vl_high ) && ( gamestate.difficulty >= gd_hard ) )
- {
- SD_Play( SD_YOUSUCKSND );
- }
- else
- {
- SD_Play (SD_PLAYERTCDEATHSND+(pstate->player));
- }
- }
- }
- else
- {
- dummy->flags &= ~FL_DYING;
- }
- if (dopefish==true)
- {
- dummy->momentumx+=(RandomNumber("Died",0)<<6)-(256<<5);
- dummy->momentumy+=(RandomNumber("Died",0)<<6)-(256<<5);
- }
- player->x=x+FixedMul(radius,costable[iangle&(FINEANGLES-1)]);
- player->y=y-FixedMul(radius,sintable[iangle&(FINEANGLES-1)]);
- player->z=dummy->z;
- player->angle=(iangle+ANG180)&(FINEANGLES-1);
- if (dopefish==true)
- {
- int dx,dy;
-
- dx = dummy->x - player->x;
- dy = player->y - dummy->y;
-
- if (dx && dy)
- player->angle = atan2_appx (dx,dy);
- }
- pstate->heightoffset=heightoffset;
- player->yzangle=0;
- UpdateGameObjects();
- player->momentumx=0;
- player->momentumy=0;
- player->speed=0;
- ThreeDRefresh ();
- AnimateWalls();
- DoSprites();
- DoAnimatedMaskedWalls();
- UpdatePlayers();
- UpdateLightLevel(player->areanumber);
-
- if (iangle<endangle)
- {
- iangle+=(tics<<ROTRATE);
- radius+=tics*(RADIUSINC<<ROTRATE);
- }
- if ( (dummy->state==dummy->state->next) && (iangle>=endangle) )
- break;
- }
- }
- else if (pstate->falling==false)
- {
-
- //
- // swing around to face attacker
- //
-
- rate=DEATHROTATE-slowrate;
- {
- if (killerobj==player)
- {
- iangle=player->angle;
- if ( ( gamestate.violence >= vl_high ) &&
- ( gamestate.difficulty >= gd_hard ) )
- {
- SD_Play( SD_YOUSUCKSND );
- }
- }
- else
- {
- SD_Play (SD_PLAYERTCDEATHSND+(pstate->player));
- if (killerobj->which==PWALL)
- {
- dx = ((pwallobj_t *)killerobj)->x - player->x;
- dy = player->y - ((pwallobj_t *)killerobj)->y;
- }
- else
- {
- dx = killerobj->x - player->x;
- dy = player->y - killerobj->y;
- }
-
- iangle = atan2_appx (dx,dy); // returns -pi to pi
- }
- }
-
- da = iangle-player->angle;
-
- if (da>0)
- clockwise=1;
- else
- clockwise=0;
- da=abs(da);
- if (da>ANG180)
- {
- clockwise^=1;
- da=ANGLES-da;
- }
-
- curangle = player->angle;
-
- do
- {
- DoBorderShifts ();
- change = tics<<rate;
- if (clockwise==1)
- curangle+=change;
- else
- curangle-=change;
- da-=change;
- if (curangle >= ANGLES)
- curangle -= ANGLES;
- if (curangle < 0)
- curangle += ANGLES;
- player->angle = (curangle & (FINEANGLES-1));
- ThreeDRefresh ();
- CalcTics ();
- } while (da>0);
- }
- else
- {
- DrawFullSky();
- FlipPage();
- }
-
- while (damagecount)
- DoBorderShifts ();
- DoBorderShifts ();
-
- locplayerstate->weapon = -1; // take away weapon
-
- if (
- (tedlevel == false) && // SO'S YA DON'T GET KILLED WHILE LAUNCHING!
- (timelimitenabled == false)
- )
- locplayerstate->lives--;
-
- if (pstate->falling==false)
- {
- ThreeDRefresh ();
- }
-
- FlipPage();
- FlipPage();
-
- if (locplayerstate->lives > -1)
- {
- int rng;
-
- rng = RandomNumber ("Died",0);
-
- if (pstate->falling==true)
- {
- RotateBuffer (0, 0, (FINEANGLES), (FINEANGLES>>6), (VBLCOUNTER*(1+slowrate)));
- SD_Play (SD_PLAYERTCDEATHSND+(pstate->player));
- pstate->falling=false;
- }
-
- else if (rng < 64)
- RotateBuffer (0, 0, (FINEANGLES), (FINEANGLES*64), (VBLCOUNTER*(2+slowrate)));
- else if (rng < 128)
- {
- RotateBuffer (0, 0, (FINEANGLES), (FINEANGLES>>6), (VBLCOUNTER*(1+slowrate)));
- }
- else if (rng < 192)
- RotateBuffer(0, (FINEANGLES*4), (FINEANGLES), (FINEANGLES*64), (VBLCOUNTER*(3+slowrate)));
- else
- VL_FadeToColor (VBLCOUNTER*2, 100, 0, 0);
-
- screenfaded=false;
-
- VL_FadeOut (0, 255, 0,0,0,VBLCOUNTER>>1);
- gamestate.episode = 1;
- player->flags &= ~FL_DONE;
-
- InitializeWeapons (locplayerstate);
- ResetPlayerstate(locplayerstate);
-
- UpdateLives (locplayerstate->lives);
- UpdateScore (gamestate.score);
-
- DrawTriads(true);
- DrawLives (true);
- DrawKeys (true);
- DrawScore (true);
- }
- else
- {
- int rng;
-
- SD_Play (SD_GAMEOVERSND);
- rng=RandomNumber("Died",0);
- if (rng<64)
- RotateBuffer(0,(FINEANGLES>>1),(FINEANGLES),(FINEANGLES*64),(VBLCOUNTER*(3+slowrate)));
- else if (rng<128)
- VL_FadeToColor (VBLCOUNTER*3, 255, 255, 255);
- else if (rng<192)
- RotateBuffer(0,(FINEANGLES*2),(FINEANGLES),(FINEANGLES*64),(VBLCOUNTER*(3+slowrate)));
- else
- RotateBuffer(0,(FINEANGLES*2),(FINEANGLES),(FINEANGLES*64),(VBLCOUNTER*(3+slowrate)));
-
- screenfaded=false;
-
- VL_FadeOut (0, 255, 0,0,0,VBLCOUNTER>>1);
-
- MU_StartSong(song_gameover);
-
-#if (SHAREWARE==0)
- if (gamestate.violence==vl_excessive)
- LBM = (lbm_t *) W_CacheLumpNum (W_GetNumForName ("bootblod"), PU_CACHE, Cvt_lbm_t, 1);
- else
- LBM = (lbm_t *) W_CacheLumpNum (W_GetNumForName ("bootnorm"), PU_CACHE, Cvt_lbm_t, 1);
-#else
- LBM = (lbm_t *) W_CacheLumpNum (W_GetNumForName ("bootblod"), PU_CACHE, Cvt_lbm_t, 1);
-#endif
- VL_DecompressLBM (LBM,true);
-
- StopWind();
-
- IN_UserInput (VBLCOUNTER*60);
-
- MainMenu[savegame].active = 0;
- MainMenu[viewscores].routine = (void *)CP_ViewScores;
- MainMenu[viewscores].texture[6] = '7';
- MainMenu[viewscores].texture[7] = '\0';
- MainMenu[viewscores].letter = 'V';
- }
- ClearGraphicsScreen();
-
- VL_FadeIn (0, 255, origpal, 15);
-}
-
-
-//******************************************************************************
-//
-// DoLoadGameAction ()
-//
-//******************************************************************************
-
-static byte whichstr = 0;
-
-void DoLoadGameAction (void)
-{
- if ((SaveTime+1) < GetTicCount())
- {
- byte *temp = bufferofs;
-
- bufferofs = displayofs;
- SaveTime = GetTicCount();
-
- CurrentFont=tinyfont;
-
- px = 92;
- py = 152;
- if (whichstr)
- {
-// VW_DrawPropString ("�");
- VW_DrawPropString (".");
- whichstr = 0;
- }
- else
- {
-// VW_DrawPropString ("�");
- VW_DrawPropString (".");
- whichstr = 1;
- }
- bufferofs = temp;
- }
-}
-
-//******************************************************************************
-//
-// DoCheckSum ()
-//
-//******************************************************************************
-
-long DoCheckSum (byte *source, int size, long csum)
-{
- int i;
- long checksum;
-
- checksum = csum;
-
- for (i = 0; i < size; i++)
- checksum=updatecrc(checksum,*(source+i));
-
- return checksum;
-}
-
-//******************************************************************************
-//
-// CaculateSaveGameCheckSum ()
-//
-//******************************************************************************
-
-#define SAVECHECKSUMSIZE (10000)
-long CalculateSaveGameCheckSum (char * filename)
-{
- int handle;
- int lengthleft;
- int length;
- byte * altbuffer;
- long checksum;
-
- altbuffer=SafeMalloc(SAVECHECKSUMSIZE);
-
- checksum = 0;
-
- // Open the savegame file
-
- handle = SafeOpenRead (filename);
- lengthleft = filelength (handle);
-
- while (lengthleft>0)
- {
- length=SAVECHECKSUMSIZE;
- if (length>lengthleft)
- length=lengthleft;
-
- SafeRead(handle,altbuffer,length);
- checksum = DoCheckSum (altbuffer, length, checksum);
-
- lengthleft-=length;
- }
-
- SafeFree(altbuffer);
-
- close (handle);
-
- return checksum;
-}
-
-//******************************************************************************
-//
-// StoreBuffer
-//
-//******************************************************************************
-void StoreBuffer (int handle, byte * src, int size)
-{
- SafeWrite(handle,&size,sizeof(size));
- SafeWrite(handle,src,size);
-}
-
-//******************************************************************************
-//
-// SaveTag
-//
-//******************************************************************************
-void SaveTag (int handle, char * tag, int size)
-{
- SafeWrite(handle,tag,size);
-}
-
-
-//******************************************************************************
-//
-// SaveTheGame ()
-//
-// Expects game to be premalloced
-//
-//******************************************************************************
-
-extern boolean enableZomROTT;
-extern boolean allowBlitzMoreMissileWeps;
-extern boolean enableAmmoPickups;
-
-boolean SaveTheGame (int num, gamestorage_t * game)
-{
- char loadname[MAX_PATH]="rottgam0.rot";
- char filename[MAX_PATH];
- byte * altbuffer;
- int size;
- int avail;
- int savehandle;
- int crc;
- int i;
- char letter;
- int myticcount;
-
- if (num > 15 || num < 0)
- Error("Illegal Saved game value=%d\n",num);
-
- //
- // Save Alternate Game Level information for reloading game
- //
- memset (&game->info, 0, sizeof (game->info));
- if (GameLevels.avail == true)
- {
- game->info.path = GameLevels.path;
- game->info.file = GameLevels.file;
- game->info.avail = true;
- }
-
- game->mapcrc=GetMapCRC (gamestate.mapon);
-
- // Create the proper file name
-
- itoa(num,&loadname[7],16);
- loadname[8]='.';
-
-
- GetPathFromEnvironment( filename, ApogeePath, loadname );
-
-#if PLATFORM_DOS
- {
- struct diskfree_t dfree;
- // Determine available disk space
- letter = toupper(filename[0]);
- if (
- (letter >= 'A') &&
- (letter <= 'Q')
- )
- {
- if (_dos_getdiskfree ((letter-'A'+1), &dfree))
- Error ("Error in _dos_getdiskfree call\n");
- }
- else
- {
- if (_dos_getdiskfree (0, &dfree))
- Error ("Error in _dos_getdiskfree call\n");
- }
-
- avail = (int) dfree.avail_clusters *
- dfree.bytes_per_sector *
- dfree.sectors_per_cluster;
- avail -= 8192;
-
- // Check to see if we have enough
-
- if (avail < MAXSAVEDGAMESIZE)
- {
- CP_DisplayMsg ("There is not enough\nspace on your disk\nto Save Game!\nPress any key to continue", 13);
- return (false);
- }
- }
-#endif
-
- // Open the savegame file
-
- savehandle = SafeOpenWrite (filename);
-
- // Save out file tag
-
- size=4;
- SaveTag(savehandle,"ROTT",size);
-
- // Save out header
-
- size=sizeof(*game);
-
- SafeWrite(savehandle,game,size);
-
-/////////////////////////////////////////////////////////////////////////////
-// Save out rest of save game file beyond this point
-/////////////////////////////////////////////////////////////////////////////
-
- // Door Tag
-
- size=4;
- SaveTag(savehandle,"DOOR",size);
-
- // Doors
-
- SaveDoors(&altbuffer,&size);
- StoreBuffer(savehandle,altbuffer,size);
- SafeFree(altbuffer);
-
- // Elevator Tag
-
- size = 9;
- SaveTag(savehandle,"ELEVATORS",size);
-
- // Elevators
-
- SaveElevators(&altbuffer,&size);
- StoreBuffer(savehandle,altbuffer,size);
- SafeFree(altbuffer);
-
- // Pushwall Tag
-
- size=5;
- SaveTag(savehandle,"PWALL",size);
-
- // PushWalls
-
- SavePushWalls(&altbuffer,&size);
- StoreBuffer(savehandle,altbuffer,size);
- SafeFree(altbuffer);
-
- // MaskedWalls Tag
-
- size=5;
- SaveTag(savehandle,"MWALL",size);
-
- // Masked Walls
-
- SaveMaskedWalls(&altbuffer,&size);
- StoreBuffer(savehandle,altbuffer,size);
- SafeFree(altbuffer);
-
- // Switches Tag
-
- size=6;
- SaveTag(savehandle,"SWITCH",size);
-
- // Switches
-
- SaveSwitches(&altbuffer,&size);
- StoreBuffer(savehandle,altbuffer,size);
- SafeFree(altbuffer);
-
- // Statics Tag
-
- size=6;
- SaveTag(savehandle,"STATIC",size);
-
- // Statics
-
- SaveStatics(&altbuffer,&size);
- StoreBuffer(savehandle,altbuffer,size);
- SafeFree(altbuffer);
-
- // Actors Tag
-
- size=5;
- SaveTag(savehandle,"ACTOR",size);
-
- // Actors
-
- SaveActors(&altbuffer,&size);
- StoreBuffer(savehandle,altbuffer,size);
- SafeFree(altbuffer);
-
- // TouchPlates Tag
-
- size=5;
- SaveTag(savehandle,"TOUCH",size);
-
- // TouchPlates
-
- SaveTouchPlates(&altbuffer,&size);
- StoreBuffer(savehandle,altbuffer,size);
- SafeFree(altbuffer);
-
- // GameState Tag
-
- size=9;
- SaveTag(savehandle,"GAMESTATE",size);
-
- // GameState
-
- size=sizeof(gamestate);
- SafeWrite(savehandle,&gamestate,size);
-
- // PlayerState Tag
-
- size=12;
- SaveTag(savehandle,"PLAYERSTATES",size);
-
- // PlayerStates
- size=sizeof(playertype);
- for(i=0; i<numplayers; i++)
- {
- SafeWrite(savehandle,&PLAYERSTATE[i],size);
- }
-
- // Mapseen Tag
-
- size=7;
- SaveTag(savehandle,"MAPSEEN",size);
-
- // MapSeen
-
- size=sizeof(mapseen);
- SafeWrite(savehandle,&mapseen,size);
-
- // Song Tag
-
- size=4;
- SaveTag(savehandle,"SONG",size);
-
- // Song info
-
- MU_SaveMusic(&altbuffer,&size);
- StoreBuffer(savehandle,altbuffer,size);
- SafeFree(altbuffer);
-
- // Misc Tag
-
- size=4;
- SaveTag(savehandle,"MISC",size);
-
- // Misc
-
- // ticcount
- myticcount = GetTicCount();
- size=sizeof(myticcount);
- SafeWrite(savehandle,&myticcount,size);
-
- // shaketics
- size=sizeof(SHAKETICS);
- SafeWrite(savehandle,&SHAKETICS,size);
-
- // damagecount
- size=sizeof(damagecount);
- SafeWrite(savehandle,&damagecount,size);
-
- // viewsize
- size=sizeof(viewsize);
- SafeWrite(savehandle,&viewsize,size);
-
- // poweruptimes
- size = sizeof (poweruptime);
- SafeWrite(savehandle,&poweruptime,size);
-
- size = sizeof (protectiontime);
- SafeWrite(savehandle,&protectiontime,size);
-
- size = sizeof (powerupheight);
- SafeWrite(savehandle,&powerupheight,size);
-
- size = sizeof (protectionheight);
- SafeWrite(savehandle,&protectionheight,size);
-
- size = sizeof (poweradjust);
- SafeWrite(savehandle,&poweradjust,size);
-
- size = sizeof (allowBlitzMoreMissileWeps);
- SafeWrite(savehandle, &allowBlitzMoreMissileWeps, size);
-
- size = sizeof (enableAmmoPickups);
- SafeWrite(savehandle, &enableAmmoPickups, size);
-
- size = sizeof(enableZomROTT);
- SafeWrite(savehandle, &enableZomROTT, size);
-
- //ZomROTT Stuff
- if(enableZomROTT)
- {
- SaveResurrectList(&altbuffer, &size);
- StoreBuffer(savehandle,altbuffer,size);
- SafeFree(altbuffer);
- }
-
- close (savehandle);
-
- // Calculate CRC
-
- crc = CalculateSaveGameCheckSum (filename);
-
- // Append the crc
-
- savehandle = SafeOpenAppend (filename);
-
- size=sizeof(crc);
- SafeWrite(savehandle,&crc,size);
-
- close (savehandle);
-
- pickquick = true;
- return (true);
-}
-
-
-//******************************************************************************
-//
-// LoadTag
-//
-//******************************************************************************
-
-void LoadTag (byte ** src, char * tag, int size)
-{
- if (StringsNotEqual((char *)*src,(char *)tag,size)==true)
- Error("Could not locate %s header in saved game file\n",tag);
- *src+=size;
-}
-
-//******************************************************************************
-//
-// LoadBuffer
-//
-//******************************************************************************
-int LoadBuffer (byte ** dest, byte ** src)
-{
- int size;
-
- memcpy(&size,*src,sizeof(size));
- *src+=sizeof(size);
- *dest=SafeMalloc(size);
- memcpy(*dest,*src,size);
- *src+=size;
- return size;
-}
-
-
-//******************************************************************************
-//
-// LoadTheGame ()
-//
-// Expects game to be premalloced
-//
-//******************************************************************************
-
-extern objtype* enemiesToRes;
-extern unsigned int freeSlot;
-
-boolean LoadTheGame (int num, gamestorage_t * game)
-{
- char loadname[45]="rottgam0.rot";
- char filename[128];
- byte * loadbuffer;
- byte * bufptr;
- byte * altbuffer;
- int size;
- int totalsize;
- int checksum;
- int savedchecksum;
- int i;
- word mapcrc;
- int myticcount;
-
- if (num>15 || num<0)
- Error("Illegal Load game value=%d\n",num);
-
- // Create the proper file name
-
- itoa(num,&loadname[7],16);
- loadname[8]='.';
-
- GetPathFromEnvironment( filename, ApogeePath, loadname );
-
- // Load the file
-
- totalsize=LoadFile(filename,(void **)&loadbuffer);
- bufptr=loadbuffer;
-
- // Calculate checksum
-
- checksum = DoCheckSum (loadbuffer, totalsize-sizeof(checksum), 0);
-
- // Retrieve saved checksum
-
- memcpy (&savedchecksum,loadbuffer+(totalsize-sizeof(savedchecksum)),sizeof(savedchecksum));
-
- // Compare the two checksums;
-
- if (checksum!=savedchecksum)
- {
- if (CP_DisplayMsg ("Your Saved Game file is\n"
- "shall we say, \"corrupted\".\n"
- "Would you like to\n"
- "continue anyway (Y/N)?\n", 12)==false)
- {
- return false;
- }
- }
-
- // Load in file tag
-
- size=4;
- LoadTag(&bufptr,"ROTT",size);
-
- // Load in header
-
- size=sizeof(*game);
- memcpy(game,bufptr,size);
- bufptr+=size;
-
- if (game->version!=ROTTVERSION)
- return false;
-
- memcpy (&GameLevels, &game->info, sizeof (GameLevels));
-
- gamestate.episode=game->episode;
- gamestate.mapon=game->area;
-
- mapcrc=GetMapCRC (gamestate.mapon);
-
- if (mapcrc!=game->mapcrc)
- return false;
-
-/////////////////////////////////////////////////////////////////////////////
-// Load in rest of saved game file beyond this point
-/////////////////////////////////////////////////////////////////////////////
-
- // Free up the current level
- Z_FreeTags (PU_LEVELSTRUCT, PU_LEVELEND); // Free current level
-
- gamestate.battlemode = battle_StandAloneGame;
- BATTLE_SetOptions( &BATTLE_Options[ battle_StandAloneGame ] );
- BATTLE_Init( gamestate.battlemode, 1 );
-
- DoLoadGameAction ();
- SetupGameLevel();
-
- // This prevents a nasty glitch when loading some saved games
- PreCacheGroup(W_GetNumForName("BULLETHO"),W_GetNumForName("ALTBHO"),cache_transpatch_t);
-
- // Door Tag
-
- size=4;
- LoadTag(&bufptr,"DOOR",size);
-
- // Doors
-
- DoLoadGameAction ();
- size=LoadBuffer(&altbuffer,&bufptr);
- LoadDoors(altbuffer,size);
- SafeFree(altbuffer);
-
- // Elevator Tag
-
- size = 9;
- LoadTag(&bufptr,"ELEVATORS",size);
-
-
- // Elevators
-
- DoLoadGameAction ();
- size=LoadBuffer(&altbuffer,&bufptr);
- LoadElevators(altbuffer,size);
- SafeFree(altbuffer);
-
- // Pushwall Tag
-
- size=5;
- LoadTag(&bufptr,"PWALL",size);
-
- // PushWalls
-
- DoLoadGameAction ();
- size=LoadBuffer(&altbuffer,&bufptr);
- LoadPushWalls(altbuffer,size);
- SafeFree(altbuffer);
-#if 0
- // Animated Walls Tag
-
- size=5;
- LoadTag(&bufptr,"AWALL",size);
-
- // Animated Walls
- size=LoadBuffer(&altbuffer,&bufptr);
- LoadAnimWalls(altbuffer,size);
- SafeFree(altbuffer);
-#endif
-
- // MaskedWalls Tag
-
- size=5;
- LoadTag(&bufptr,"MWALL",size);
-
- // Masked Walls
-
- DoLoadGameAction ();
- size=LoadBuffer(&altbuffer,&bufptr);
- LoadMaskedWalls(altbuffer,size);
- SafeFree(altbuffer);
-
- // Switches Tag
-
- size=6;
- LoadTag(&bufptr,"SWITCH",size);
-
- // Switches
-
- DoLoadGameAction ();
- size=LoadBuffer(&altbuffer,&bufptr);
- LoadSwitches(altbuffer,size);
- SafeFree(altbuffer);
-
-
- // Statics Tag
-
- size=6;
- LoadTag(&bufptr,"STATIC",size);
-
- // Statics
-
- DoLoadGameAction ();
- size=LoadBuffer(&altbuffer,&bufptr);
- LoadStatics(altbuffer,size);
- SafeFree(altbuffer);
-
- // Actors Tag
-
- size=5;
- LoadTag(&bufptr,"ACTOR",size);
-
- // Actors
-
- DoLoadGameAction ();
- size=LoadBuffer(&altbuffer,&bufptr);
- LoadActors(altbuffer,size);
- SafeFree(altbuffer);
-
- // TouchPlates Tag
-
- size=5;
- LoadTag(&bufptr,"TOUCH",size);
-
- // TouchPlates
-
- DoLoadGameAction ();
- size=LoadBuffer(&altbuffer,&bufptr);
- LoadTouchPlates(altbuffer,size);
- SafeFree(altbuffer);
-
- // SetupWindows
-
- SetupWindows();
-
- // GameState Tag
-
- size=9;
- LoadTag(&bufptr,"GAMESTATE",size);
-
- // GameState
-
- DoLoadGameAction ();
- size=sizeof(gamestate);
- memcpy(&gamestate,bufptr,size);
- bufptr+=size;
-
- // PlayerState Tag
-
- size=12;
- LoadTag(&bufptr,"PLAYERSTATES",size);
-
- // PlayerState
-
- DoLoadGameAction ();
- size=sizeof(playertype);
- for(i=0; i<numplayers; i++)
- { memcpy(&PLAYERSTATE[i],bufptr,size);
- bufptr+=size;
- }
-
- // Zero out player targets
-
- locplayerstate->guntarget=0;
- locplayerstate->targettime=0;
-
- // Mapseen Tag
-
- size=7;
- LoadTag(&bufptr,"MAPSEEN",size);
-
- // MapSeen
-
- DoLoadGameAction ();
- size=sizeof(mapseen);
- memcpy(&mapseen,bufptr,size);
- bufptr+=size;
-
- // Song Tag
-
- size=4;
- LoadTag(&bufptr,"SONG",size);
-
- // Song info
-
- DoLoadGameAction ();
- size=LoadBuffer(&altbuffer,&bufptr);
- MU_LoadMusic(altbuffer,size);
- SafeFree(altbuffer);
-
- // Misc Tag
-
- size=4;
- LoadTag(&bufptr,"MISC",size);
-
- // Misc
-
- // ticcount
- DoLoadGameAction ();
- size=sizeof(myticcount);
- memcpy((void *)&myticcount,bufptr,size);
- bufptr+=size;
- SaveTime = myticcount;
- ISR_SetTime(myticcount);
-
- // shaketics
- DoLoadGameAction ();
- size=sizeof(SHAKETICS);
- memcpy(&SHAKETICS,bufptr,size);
- bufptr+=size;
-
- // damagecount
- DoLoadGameAction ();
- size=sizeof(damagecount);
- memcpy(&damagecount,bufptr,size);
- bufptr+=size;
-
- // viewsize
- DoLoadGameAction ();
- size=sizeof(viewsize);
- memcpy(&viewsize,bufptr,size);
- bufptr+=size;
-
- // powerup times
- DoLoadGameAction ();
- size = sizeof (poweruptime);
- memcpy (&poweruptime, bufptr, size);
- bufptr += size;
- size = sizeof (protectiontime);
- memcpy (&protectiontime, bufptr, size);
- bufptr += size;
- size = sizeof (powerupheight);
- memcpy (&powerupheight, bufptr, size);
- bufptr += size;
- size = sizeof (protectionheight);
- memcpy (&protectionheight, bufptr, size);
- bufptr += size;
- size = sizeof (poweradjust);
- memcpy (&poweradjust, bufptr, size);
- bufptr += size;
-
- size = sizeof(allowBlitzMoreMissileWeps);
- memcpy (&allowBlitzMoreMissileWeps, bufptr, size);
- bufptr += size;
-
- size = sizeof(enableAmmoPickups);
- memcpy (&enableAmmoPickups, bufptr, size);
- bufptr += size;
-
- size = sizeof(enableZomROTT);
- memcpy(&enableZomROTT, bufptr, size);
- bufptr += size;
-
-
- //ZomROTT Stuff
- if(enableZomROTT)
- {
- enemiesToRes = calloc(sizeof(objtype), gamestate.killtotal);
- memset(enemiesToRes, 0, sizeof(enemiesToRes));
- size = sizeof(enemiesToRes);
- memcpy(enemiesToRes, bufptr, size);
- bufptr += size;
-
- objtype * findFreeSlotPtr;
- //find index of free
- for (findFreeSlotPtr = &enemiesToRes[0]; findFreeSlotPtr != 0; findFreeSlotPtr++)
- {
- freeSlot++;
- }
- }
-
- // Set the viewsize
-
- SetViewSize(viewsize);
- DoLoadGameAction ();
-
- // Connect areas
-
- ConnectAreas ();
- DoLoadGameAction ();
-
- // Free up the loadbuffer
-
- SafeFree (loadbuffer);
- DoLoadGameAction ();
-
- Illuminate();
-
- IN_UpdateKeyboard ();
- LoadPlayer ();
- DoLoadGameAction ();
- SetupPlayScreen();
- UpdateScore (gamestate.score);
- UpdateLives (locplayerstate->lives);
- UpdateTriads (player, 0);
- PreCache ();
- InitializeMessages();
-
- for (i=0; i<100; i++)
- UpdateLightLevel(player->areanumber);
-
- CalcTics();
- CalcTics();
-
- pickquick = true;
-
- return (true);
-}
-
-
-//******************************************************************************
-//
-// GetSavedMessage ()
-//
-// Expects message to be premalloced
-//
-//******************************************************************************
-
-void GetSavedMessage (int num, char * message)
-{
- gamestorage_t game;
- char loadname[45]="rottgam0.rot";
- char filename[128];
- byte * loadbuffer;
- byte * bufptr;
- int size;
-
- if (num>15 || num<0)
- Error("Illegal Load game value=%d\n",num);
-
- // Create the proper file name
-
- itoa(num,&loadname[7],16);
- loadname[8]='.';
-
- GetPathFromEnvironment( filename, ApogeePath, loadname );
-
- // Load the file
-
- size=LoadFile(filename,(void **)&loadbuffer);
- bufptr=loadbuffer;
-
- size=4;
- LoadTag(&bufptr,"ROTT",size);
-
- // Load in header
-
- size=sizeof(game);
- memcpy(&game,bufptr,size);
- strcpy(message,game.message);
- SafeFree(loadbuffer);
-}
-
-//******************************************************************************
-//
-// GetSavedHeader ()
-//
-// Expects game to be premalloced
-//
-//******************************************************************************
-
-void GetSavedHeader (int num, gamestorage_t * game)
-{
- char loadname[45]="rottgam0.rot";
- char filename[128];
- byte * loadbuffer;
- byte * bufptr;
- int size;
-
- if (num>15 || num<0)
- Error("Illegal Load game value=%d\n",num);
-
- // Create the proper file name
-
- itoa(num,&loadname[7],16);
- loadname[8]='.';
-
- GetPathFromEnvironment( filename, ApogeePath, loadname );
-
- // Load the file
-
- size=LoadFile(filename, (void **)&loadbuffer);
- bufptr=loadbuffer;
-
- size=4;
- LoadTag(&bufptr,"ROTT",size);
-
- // Load in header
-
- size=sizeof(*game);
- memcpy(game,bufptr,size);
- SafeFree(loadbuffer);
-}
-
-
-
-//******************************************************************************
-//
-// GetLevel ()
-//
-//******************************************************************************
-
-int GetLevel (int episode, int mapon)
-{
- int level;
-
- level = (mapon+1) - ((episode-1) << 3);
-
- return (level);
-}
+/*
+Copyright (C) 1994-1995 Apogee Software, Ltd.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+
+#ifdef DOS
+#include <dos.h>
+#include <io.h>
+#include <conio.h>
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <ctype.h>
+
+#include "rt_def.h"
+#include "rt_main.h"
+#include "rt_game.h"
+#include "_rt_game.h"
+#include "rt_menu.h"
+#include "z_zone.h"
+#include "w_wad.h"
+#include "lumpy.h"
+#include "rt_playr.h"
+#include "rt_util.h"
+#include "rt_ted.h"
+#include "rt_draw.h"
+#include "rt_view.h"
+#include "rt_vid.h"
+#include "rt_door.h"
+#include "rt_in.h"
+#include "rt_str.h"
+#include "isr.h"
+#include "rt_build.h"
+#include "rt_rand.h"
+#include "rt_cfg.h"
+#include "rt_sound.h"
+#include "version.h"
+#include "rt_crc.h"
+#include "modexlib.h"
+#include "engine.h"
+#include "gmove.h"
+#include "rt_com.h"
+#include "rt_net.h"
+#include "watcom.h"
+#include "rt_floor.h"
+#include "rt_msg.h"
+#include "rt_scale.h"
+#include "develop.h"
+//MED
+#include "memcheck.h"
+#include "queue.h"
+
+#if (SHAREWARE == 1)
+#define NUMAMMOGRAPHICS 10
+#else
+#define NUMAMMOGRAPHICS 20
+#endif
+
+//******************************************************************************
+//
+// GLOBALS
+//
+//******************************************************************************
+
+int PlayerSnds[5] = {SD_PLAYERTCSND, SD_PLAYERTBSND, SD_PLAYERDWSND,
+ SD_PLAYERLNSND, SD_PLAYERIPFSND
+ };
+
+
+unsigned short SHAKETICS = 0xFFFF;//bna++
+//int SHAKETICS = 0xFFFF;
+int damagecount = 0;
+HighScore Scores[MaxScores] =
+{
+ {"Tom",70000,7,1},
+ {"Chuck",60000,6,1},
+ {"Mark",50000,5,1},
+ {"The Joes",40000,4,1},
+ {"William",30000,3,1},
+ {"Jim",20000,2,1},
+ {"Steve",10000,1,1},
+};
+
+//******************************************************************************
+//
+// LOCALS
+//
+//******************************************************************************
+
+static int KeyX[4] = {KEY1_X, KEY2_X, KEY3_X, KEY4_X};
+
+static const char *Names[ 5 ] =
+{
+ "Taradino", "Thi", "Doug", "Lorelei", "Ian Paul"
+};
+
+static const char *LastNames[ 5 ] =
+{
+ "Cassatt", "Barrett", "Wendt", "Ni", "Freeley"
+};
+
+static STR ScoreStr;
+static STR LivesStr;
+static STR TriadStr;
+static STR KillStr;
+
+static pic_t *lifeptnums[10];
+static pic_t *lifenums[10];
+static pic_t *timenums[10];
+static pic_t *scorenums[10];
+static pic_t *keys[4];
+static pic_t *men[5];
+
+static pic_t *health[6];
+static pic_t *ammo[26];
+static pic_t *erase;
+static pic_t *eraseb;
+static pic_t *fragpic[ 5 ];
+static pic_t *frag100pic[ 5 ];
+static pic_t *negfragpic[ 5 ];
+static pic_t *menneg[ 5 ];
+static pic_t *blankfragpic;
+
+static int powerpics;
+static int poweradjust;
+
+static int poweruptime;
+static int powerupheight;
+static int protectiontime;
+static int protectionheight;
+
+
+static boolean EndLevelStuff = false;
+static boolean borderset = false;
+static int oldsec = -1;
+
+static pic_t *BkPic;
+int SaveTime = 0;
+int oldhealth;
+
+static int oldplayerhealth;
+static int oldpercenthealth;
+
+static int playeruniformcolor;
+
+#define NUMBONUSES 11
+#define BONUSBONUS 100000
+
+
+extern void VL_MemToScreenClipped (byte *source, int width, int height, int x, int y);
+void DrawPPic (int xpos, int ypos, int width, int height, byte *src, int num, boolean up, boolean bufferofsonly);
+extern void MoveScreenUpLeft();
+extern void MoveScreenUpRight();
+extern void MoveScreenDownLeft();
+extern void MoveScreenDownRight();
+//******************************************************************************
+//
+// V_ReDrawBkgnd ()
+//
+//******************************************************************************
+
+void V_ReDrawBkgnd (int x, int y, int width, int height, boolean shade)
+{
+ byte *src;
+ byte *dest;
+ byte *origdest;
+ int j,
+ k,
+ planes,
+ mask,
+ m;
+
+ m = (x&3);
+ mask = (1 << m);
+
+#ifdef DOS
+ origdest = (byte *)(bufferofs+ylookup[y]+(x>>2));
+#else
+ origdest = (byte *)(bufferofs+ylookup[y]+x);
+#endif
+
+ if (VW_MarkUpdateBlock (x, y, x+width-1, y+height-1))
+ {
+ for (planes = 0; planes < 4; planes++)
+ {
+ src = (&(BkPic->data)+((80*200)*m)+(80*y)+(x>>2));
+ dest = origdest;
+
+#ifdef DOS
+ VGAMAPMASK (mask);
+#else
+ dest += planes;
+#endif
+
+ for (j = 0; j < height; j++)
+ {
+ for (k = 0; k < (width/4); k++) {
+ if (shade) {
+ *dest = *(colormap + ((MENUSHADELEVEL>>2)<<8) + *src++);
+ } else {
+ *dest = *src++;
+ }
+#ifdef DOS
+ dest++;
+#else
+ dest += 4;
+#endif
+ }
+
+#ifndef DOS
+ // draw the remainder. did the DOS version even bother? - SBF
+ if ((width & 3) > planes) {
+ if (shade) {
+ *dest = *(colormap + ((MENUSHADELEVEL>>2)<<8) + *src);
+ } else {
+ *dest = *src;
+ }
+ }
+#endif
+
+ src += (80-(width/4));
+#ifdef DOS
+ dest += (linewidth-(width/4));
+#else
+ dest += (linewidth-(width&~3));
+#endif
+ }
+
+ m++;
+
+ mask <<= 1;
+
+ if (mask == 16)
+ {
+ x+=4;
+ mask = 1;
+ m = 0;
+#ifdef DOS
+ origdest++;
+#endif
+ }
+ }
+ }
+}
+
+
+//******************************************************************************
+//
+// CacheLumpGroup ()
+//
+//******************************************************************************
+void CacheLumpGroup
+(
+ char *startlump,
+ pic_t **lumparray,
+ int numberoflumps
+)
+
+{
+ int lumpnum;
+ int i;
+
+ lumpnum = W_GetNumForName( startlump );
+
+ for( i = 0; i < numberoflumps; i++ )
+ {
+ lumparray[ i ] = ( pic_t * )W_CacheLumpNum( lumpnum + i, PU_LEVEL, Cvt_pic_t, 1 );
+ }
+}
+
+//******************************************************************************
+//
+// SetupPlayScreen ()
+//
+//******************************************************************************
+void SetupPlayScreen
+(
+ void
+)
+
+{
+ int i;
+ int j;
+ int num;
+
+ erase = ( pic_t * )W_CacheLumpName( "erase", PU_LEVEL, Cvt_pic_t, 1 );
+ eraseb = ( pic_t * )W_CacheLumpName( "eraseb", PU_LEVEL, Cvt_pic_t, 1 );
+
+ CacheLumpGroup( "tmnum0", timenums, 10 );
+ CacheLumpGroup( "lfnum0", lifeptnums, 10 );
+ CacheLumpGroup( "lvnum0", lifenums, 10 );
+ CacheLumpGroup( "health1b", health, 6 );
+ CacheLumpGroup( "key1", keys, 4 );
+
+ if ( !BATTLEMODE )
+ {
+ CacheLumpGroup( "scnum0", scorenums, 10 );
+
+ num = locplayerstate->player;
+ men[ num ] = ( pic_t * )W_CacheLumpNum( W_GetNumForName( "MAN1" ) +
+ num, PU_LEVEL, Cvt_pic_t, 1 );
+ }
+ else
+ {
+ int man;
+ int num100;
+ int negnum;
+ int negman;
+
+ CacheLumpGroup( "kilnum0", scorenums, 10 );
+
+ negnum = W_GetNumForName( "botnpic1" );
+ num = W_GetNumForName( "botpic0" );
+ num100 = W_GetNumForName( "botopic1" );
+ negman = W_GetNumForName( "negman1" );
+ man = W_GetNumForName( "man1" );
+
+ blankfragpic = ( pic_t * )W_CacheLumpNum( num, PU_LEVEL, Cvt_pic_t, 1 );
+ num++;
+
+ for( i = 0; i < numplayers; i++ )
+ {
+ j = PLAYERSTATE[ i ].player;
+ if ( !gamestate.teamplay )
+ {
+ fragpic[ j ] = ( pic_t * )W_CacheLumpNum( num + j, PU_LEVEL, Cvt_pic_t, 1 );
+ frag100pic[ j ] = ( pic_t * )W_CacheLumpNum( num100 + j, PU_LEVEL, Cvt_pic_t, 1 );
+ negfragpic[ j ] = ( pic_t * )W_CacheLumpNum( negnum + j, PU_LEVEL, Cvt_pic_t, 1 );
+ }
+ else
+ {
+ negfragpic[ j ] = ( pic_t * )W_CacheLumpName( "teamnpic", PU_LEVEL, Cvt_pic_t, 1 );
+ fragpic[ j ] = ( pic_t * )W_CacheLumpName( "teampic", PU_LEVEL, Cvt_pic_t, 1 );
+ frag100pic[ j ] = fragpic[ j ];
+ }
+
+ menneg[ j ] = ( pic_t * )W_CacheLumpNum( negman + j, PU_LEVEL, Cvt_pic_t, 1 );
+ men[ j ] = ( pic_t * )W_CacheLumpNum( man + j, PU_LEVEL, Cvt_pic_t, 1 );
+ }
+ }
+
+ powerpics = W_GetNumForName( "GDMODEP" );
+ poweradjust = POWERUPTICS / 16;
+
+ num = W_GetNumForName( "INF_B" );
+
+ // bullet weapons
+ ammo[0] = ( pic_t * )W_CacheLumpNum( num, PU_LEVEL, Cvt_pic_t, 1 );
+ ammo[1] = ( pic_t * )W_CacheLumpNum( num, PU_LEVEL, Cvt_pic_t, 1 );
+ ammo[2] = ( pic_t * )W_CacheLumpNum( num++, PU_LEVEL, Cvt_pic_t, 1 );
+
+
+ for(i=3; i < 13; i++ )
+ {
+ ammo[ i ] = ( pic_t * )W_CacheLumpNum( num++, PU_LEVEL, Cvt_pic_t, 1 );
+ }
+
+ ammo[13] = ( pic_t * )W_CacheLumpNum( num, PU_LEVEL, Cvt_pic_t, 1 );
+ ammo[14] = ( pic_t * )W_CacheLumpNum( num, PU_LEVEL, Cvt_pic_t, 1 );
+ ammo[15] = ( pic_t * )W_CacheLumpNum( num++, PU_LEVEL, Cvt_pic_t, 1 );
+
+
+ for(i=16; i < 26; i++ )
+ {
+ ammo[ i ] = ( pic_t * )W_CacheLumpNum( num++, PU_LEVEL, Cvt_pic_t, 1 );
+ }
+
+
+ oldplayerhealth = -1;
+ oldpercenthealth = -1;
+}
+
+
+
+//******************************************************************************
+//
+// GameMemToScreen()
+//
+//******************************************************************************
+
+void GameMemToScreen(pic_t *source, int x, int y, int bufferofsonly)
+{
+ if ( bufferofsonly )
+ {
+ VL_MemToScreen( ( byte * )&source->data, source->width,
+ source->height, x, y );
+ }
+ else
+ {
+ GM_MemToScreen( ( byte * )&source->data, source->width,
+ source->height, x, y );
+ }
+}
+int topBarCenterOffsetX;
+
+//******************************************************************************
+//
+// DrawPlayScreen ()
+//
+//******************************************************************************
+void DrawPlayScreen (boolean bufferofsonly)
+{
+ pic_t *shape;
+
+ int shapenum;
+ int ShowKillsYoffset = 0;//bna++
+
+ //figure out where the middle point of the status bar should be for top bar
+ topBarCenterOffsetX = (iGLOBAL_SCREENWIDTH - 320) >> 1;
+
+ if ( SHOW_TOP_STATUS_BAR() )
+ {
+ if (iGLOBAL_SCREENWIDTH > 320 || iGLOBAL_SCREENHEIGHT > 200)
+ {
+ shape = ( pic_t * )W_CacheLumpName( "backtile", PU_CACHE, Cvt_pic_t, 1 );
+
+ DrawTiledRegion( 0, 0, iGLOBAL_SCREENWIDTH, 16, 0,16, shape );
+ }
+ shape = ( pic_t * )W_CacheLumpName( "stat_bar", PU_CACHE, Cvt_pic_t, 1 );
+ GameMemToScreen( shape, topBarCenterOffsetX, 0, bufferofsonly );
+ }
+
+ if ( BATTLEMODE )
+ {
+ DrawKills( bufferofsonly );
+ }
+
+ if ( SHOW_BOTTOM_STATUS_BAR() )
+ {
+ shape = ( pic_t * ) W_CacheLumpName( "bottbar", PU_CACHE, Cvt_pic_t, 1 );
+
+ if ( SHOW_KILLS() )
+ {
+ ShowKillsYoffset = KILLS_HEIGHT;
+ }
+ if (iGLOBAL_SCREENWIDTH > 320 || iGLOBAL_SCREENHEIGHT > 200)
+ {
+ shape = ( pic_t * )W_CacheLumpName( "backtile", PU_CACHE, Cvt_pic_t, 1 );
+
+ //this causes a seg fault when MUSIC_StopSong calls Mix_HaltMusic for some odd reason when player pauses the game...
+ //DrawTiledRegion( 0, iGLOBAL_SCREENHEIGHT - 16, iGLOBAL_SCREENWIDTH, 16, 34,32, shape );
+
+ //...yet if we do this...no seg fault
+ DrawTiledRegion( 0, iGLOBAL_SCREENHEIGHT - 16, iGLOBAL_SCREENWIDTH, 13, 10,10, shape );
+ DrawTiledRegion( 0, iGLOBAL_SCREENHEIGHT - 29, iGLOBAL_SCREENWIDTH, 3, 10,10, shape ); //fill in remaining spots
+
+
+ shape = ( pic_t * ) W_CacheLumpName( "bottbar", PU_CACHE, Cvt_pic_t, 1 );
+
+ //GameMemToScreen( shape, topBarCenterOffsetX, iGLOBAL_SCREENHEIGHT - 16, bufferofsonly ); //using topBarCenterOffsetX since bottbar dims == statbar dims
+
+
+
+ }
+
+ GameMemToScreen( shape, topBarCenterOffsetX, iGLOBAL_SCREENHEIGHT - 16, bufferofsonly ); //using topBarCenterOffsetX since bottbar dims == statbar dims
+
+ //}
+
+ DrawBarAmmo( bufferofsonly );
+ DrawBarHealth( bufferofsonly );
+
+ if ( demoplayback )
+ {
+ shape = ( pic_t * )W_CacheLumpName( "demo", PU_CACHE, Cvt_pic_t, 1 );
+ if (iGLOBAL_SCREENWIDTH == 640) {
+ DrawPPic( 148*2, 465, shape->width, shape->height,
+ ( byte * )&shape->data, 1, true, bufferofsonly );
+ } else if (iGLOBAL_SCREENWIDTH == 800) {
+ DrawPPic( 380, 585, shape->width, shape->height,
+ ( byte * )&shape->data, 1, true, bufferofsonly );
+ } else {
+ DrawPPic( 148, 185, shape->width, shape->height,
+ ( byte * )&shape->data, 1, true, bufferofsonly );
+ }
+ }
+ }
+
+ if ( !SHOW_TOP_STATUS_BAR() )
+ {
+ return;
+ }
+
+//draws small player picture and name in topbar
+ oldsec = -1;
+
+ //DrawTime( bufferofsonly );
+
+ if ( !BATTLEMODE )
+ {
+ int character;
+ int width;
+ int height;
+
+ character = locplayerstate->player;
+ GameMemToScreen( men[ character ], MEN_X + topBarCenterOffsetX, MEN_Y,bufferofsonly );
+
+ CurrentFont = tinyfont;
+
+ // Draw player's name
+
+ if (iGLOBAL_SCREENWIDTH == 800)
+ {
+ DrawGameString ( MEN_X + 3 + topBarCenterOffsetX, MEN_Y + 2, Names[ character ], bufferofsonly );
+ VW_MeasurePropString( LastNames[ character ], &width, &height );
+ DrawGameString ( MEN_X + 44 - width + topBarCenterOffsetX, MEN_Y + 8,
+ LastNames[ character ], bufferofsonly );
+ }
+ else
+ {
+ DrawGameString ( MEN_X + 3 + topBarCenterOffsetX, MEN_Y + 2, Names[ character ], bufferofsonly );
+ VW_MeasurePropString( LastNames[ character ], &width, &height );
+ DrawGameString ( MEN_X + 44 - width + topBarCenterOffsetX, MEN_Y + 8,
+ LastNames[ character ], bufferofsonly );
+
+ }
+ UpdateLives( locplayerstate->lives );
+ UpdateScore( gamestate.score );
+ DrawTriads( bufferofsonly );
+ DrawLives( bufferofsonly );
+ DrawScore( bufferofsonly );
+ }
+
+ DrawKeys( bufferofsonly );
+
+ if ( locplayerstate->poweruptime )
+ {
+ if ( player->flags & FL_GODMODE )
+ {
+ shapenum = powerpics;
+ }
+ else if ( player->flags & FL_DOGMODE )
+ {
+ shapenum = powerpics + 1;
+ }
+ else if ( player->flags & FL_FLEET )
+ {
+ shapenum = powerpics + 2;
+ }
+ else if ( player->flags & FL_ELASTO )
+ {
+ shapenum = powerpics + 3;
+ }
+ else if ( player->flags & FL_SHROOMS )
+ {
+ shapenum = powerpics + 4;
+ }
+
+ shape = ( pic_t * )W_CacheLumpNum ( shapenum, PU_CACHE, Cvt_pic_t, 1 );
+
+ GameMemToScreen( eraseb, POWERUP1X + topBarCenterOffsetX, POWERUPY, bufferofsonly );
+
+ DrawMPPic( POWERUP1X + topBarCenterOffsetX, POWERUPY + powerupheight, shape->width,
+ shape->height - powerupheight, powerupheight,
+ ( byte * )&shape->data, bufferofsonly );
+ }
+
+
+ if ( locplayerstate->protectiontime )
+ {
+ if ( player->flags & FL_BPV )
+ {
+ shapenum = powerpics + 6;
+ }
+ else if ( player->flags & FL_GASMASK )
+ {
+ shapenum = powerpics + 5;
+ }
+ else if ( player->flags & FL_AV )
+ {
+ shapenum = powerpics + 7;
+ }
+
+ shape = ( pic_t * )W_CacheLumpNum( shapenum, PU_CACHE, Cvt_pic_t, 1 );
+
+ GameMemToScreen( eraseb, POWERUP2X + topBarCenterOffsetX, POWERUPY, bufferofsonly );
+
+ DrawMPPic( POWERUP2X + topBarCenterOffsetX, POWERUPY + protectionheight, shape->width,
+ shape->height - protectionheight, protectionheight,
+ ( byte * )&shape->data, bufferofsonly );
+ }
+}
+
+
+//******************************************************************************
+//
+// ShortenCodeName()
+//
+//******************************************************************************
+void GetShortCodeName
+(
+ char *dest,
+ char *source,
+ int maxwidth
+)
+
+{
+ int width;
+ int height;
+ int length;
+
+ strcpy( dest, source );
+
+ // Shorten name to fit
+ length = strlen( dest );
+ VW_MeasurePropString( dest, &width, &height );
+ while( width > maxwidth )
+ {
+ dest[ length ] = 0;
+ length--;
+ VW_MeasurePropString( dest, &width, &height );
+ }
+}
+
+
+//******************************************************************************
+//
+// DrawKills ()
+//
+//******************************************************************************
+void DrawKills
+(
+ boolean bufferofsonly
+)
+{
+ int rank;
+ int xpos;
+ char codename[ MAXCODENAMELENGTH ];
+ int width;
+ int playernum;
+ int playerimage;
+ int temp;
+ int iKILLS_Y;
+ pic_t *pic;
+
+ CurrentFont = tinyfont;
+
+ if ( SHOW_TOP_STATUS_BAR() )
+ {
+ playernum = BATTLE_Team[ consoleplayer ];
+ playerimage = BATTLE_TeamLeader[ playernum ];
+
+ // Set uniformcolor
+ playeruniformcolor = PLAYERSTATE[ playerimage ].uniformcolor;
+
+ // Draw player's point box
+ pic = men[ PLAYERSTATE[ playerimage ].player ];
+ if ( ( gamestate.ShowScores ) && ( BATTLE_Points[ playernum ] < 0 ) )
+ {
+ pic = menneg[ PLAYERSTATE[ playerimage ].player ];
+ }
+
+ DrawPPic( MEN_X, MEN_Y, pic->width, pic->height,
+ ( byte * )&pic->data, 1, true, bufferofsonly );
+
+ // Draw player's name
+ if ( gamestate.teamplay )
+ {
+ GetShortCodeName( codename, colorname[ playeruniformcolor ],
+ 42 );
+ }
+ else
+ {
+ GetShortCodeName( codename, PLAYERSTATE[ playerimage ].codename,
+ 42 );
+ }
+
+ DrawGameString ( MEN_X + 2, MEN_Y + 2, codename, bufferofsonly );
+ // Draw "It" if player is 'it'
+ if ( ( ( gamestate.battlemode == battle_Tag ) ||
+ ( gamestate.battlemode == battle_Hunter ) ) &&
+ ( BATTLE_It == BATTLE_Team[ consoleplayer ] ) )
+ {
+ DrawGameString ( MEN_X + 22, MEN_Y + 8,
+ "It", bufferofsonly);
+ }
+
+ // Draw triad if player is 'it' or has caught a triad
+ if ( PLAYER[ consoleplayer ]->flags & FL_DESIGNATED )
+ {
+ pic = W_CacheLumpName( "smalltri", PU_CACHE, Cvt_pic_t, 1 );
+ DrawPPic( TRIAD_X - 1, TRIAD_Y - 2, pic->width, pic->height,
+ ( byte * )&pic->data, 1, true, bufferofsonly );
+ }
+ else if ( ( gamestate.ShowScores ) &&
+ ( DisplayPoints != bo_kills_infinite ) )
+ {
+ // Draw Kill goal
+ if ( ( gamestate.battlemode == battle_Collector ) ||
+ ( gamestate.battlemode == battle_StandAloneGame ) )
+ {
+ temp = BATTLE_NumCollectorItems;
+ }
+ else
+ {
+ temp = DisplayPoints;
+ }
+
+ ltoa ( temp % 1000, KillStr.str, 10);
+ KillStr.length = strlen (KillStr.str);
+ DrawNumber (TRIAD_X - 6, TRIAD_Y, 3, 5, bufferofsonly);
+ }
+
+ // Set uniformcolor
+ playeruniformcolor = PLAYERSTATE[ consoleplayer ].uniformcolor;
+
+ if ( gamestate.ShowScores )
+ {
+ // Draw local player's points
+ temp = BATTLE_Points[ playernum ] % 1000;
+ if ( temp < 0 )
+ {
+ temp = -temp;
+ }
+ ltoa ( temp, KillStr.str, 10);
+ KillStr.length = strlen (KillStr.str);
+
+ DrawNumber( LIVES_X - 12, LIVES_Y, 3, 4, bufferofsonly);
+ }
+ else
+ {
+ pic = W_CacheLumpName( "minus", PU_CACHE, Cvt_pic_t, 1 );
+ StatusDrawColoredPic( LIVES_X - 12, LIVES_Y, pic, bufferofsonly, playeruniformcolor );
+ StatusDrawColoredPic( LIVES_X - 4, LIVES_Y, pic, bufferofsonly, playeruniformcolor );
+ }
+
+ // Draw whoever is 'It'
+ playernum = BATTLE_It;
+ playerimage = BATTLE_TeamLeader[ playernum ];
+
+ // Set uniformcolor
+ playeruniformcolor = PLAYERSTATE[ playerimage ].uniformcolor;
+
+ // Draw player's point box
+ pic = men[ PLAYERSTATE[ playerimage ].player ];
+ if ( ( gamestate.ShowScores ) && ( BATTLE_Points[ playernum ] < 0 ) )
+ {
+ pic = menneg[ PLAYERSTATE[ playerimage ].player ];
+ }
+
+ DrawPPic( LEADER_X, LEADER_Y, pic->width, pic->height,
+ (byte *)&pic->data, 1, true, bufferofsonly );
+
+ if ( ( gamestate.battlemode == battle_Tag ) ||
+ ( gamestate.battlemode == battle_Hunter ) )
+ {
+ DrawGameString ( LEADER_X + 22, LEADER_Y + 8,
+ "It", bufferofsonly);
+ }
+
+ if ( gamestate.ShowScores )
+ {
+ // Draw number of points
+ temp = BATTLE_Points[ playernum ] % 1000;
+ if ( temp < 0 )
+ {
+ temp = -temp;
+ }
+ ltoa ( temp, KillStr.str, 10);
+ KillStr.length = strlen (KillStr.str);
+ DrawNumber ( LEADER_NUM_X, LEADER_NUM_Y, 3, 4, bufferofsonly);
+ }
+ else
+ {
+ pic = W_CacheLumpName( "minus", PU_CACHE, Cvt_pic_t, 1 );
+ StatusDrawColoredPic( LEADER_NUM_X, LEADER_NUM_Y, pic, bufferofsonly, playeruniformcolor );
+ StatusDrawColoredPic( LEADER_NUM_X + 8, LEADER_NUM_Y, pic, bufferofsonly, playeruniformcolor );
+ }
+
+ // Draw name
+ if ( gamestate.teamplay )
+ {
+ DrawGameString ( LEADER_NAME_X, LEADER_NAME_Y - 1,
+ colorname[ playeruniformcolor ], bufferofsonly);
+ }
+ else
+ {
+ GetShortCodeName( codename, PLAYERSTATE[ playerimage ].codename,
+ 42 );
+ DrawGameString ( LEADER_NAME_X - 1, LEADER_NAME_Y,
+ codename, bufferofsonly);
+ }
+ }
+
+ // Only draw the rest of the rifraff when the kill count is selected
+
+ if ( !SHOW_KILLS() )
+ {
+ return;
+ }
+// SetTextMode ( );
+ // Draw all the other losers
+ //#define KILLS_Y 176
+ iKILLS_Y = iGLOBAL_SCREENHEIGHT - 24;
+ //draw blank status pic->width = 8;pic->height = 24
+ pic = blankfragpic;
+ for (temp = iGLOBAL_SCREENWIDTH-pic->width-24; temp > pic->width; temp -= pic->width) {
+ DrawPPic( temp, iKILLS_Y, pic->width, pic->height,
+ (byte *)&pic->data, 1, true, bufferofsonly );
+
+ }
+
+ xpos = KILLS_X;
+ for( rank = 0; rank < BATTLE_NumberOfTeams; rank++ )
+ {
+ playernum = BATTLE_PlayerOrder[ rank ];
+ playerimage = BATTLE_TeamLeader[ playernum ];
+
+ if ( ( playernum == BATTLE_It ) && SHOW_TOP_STATUS_BAR() )
+ {
+ continue;
+ }
+
+ // Set uniformcolor
+ playeruniformcolor = PLAYERSTATE[ playerimage ].uniformcolor;
+
+ // Draw player's point box
+ pic = fragpic[ PLAYERSTATE[ playerimage ].player ];
+ if ( gamestate.ShowScores )
+ {
+ if ( BATTLE_Points[ playernum ] < 0 )
+ {
+ pic = negfragpic[ PLAYERSTATE[ playerimage ].player ];
+ }
+ else if ( BATTLE_Points[ playernum ] >= 100 )
+ {
+ pic = frag100pic[ PLAYERSTATE[ playerimage ].player ];
+ }
+ }
+ DrawPPic( xpos, iKILLS_Y, pic->width, pic->height,
+ (byte *)&pic->data, 1, true, bufferofsonly );
+
+ // Draw number of points
+ if ( gamestate.ShowScores )
+ {
+ temp = BATTLE_Points[ playernum ] % 1000;
+ if ( temp < 0 )
+ {
+ temp = -temp;
+ }
+ ltoa ( temp, KillStr.str, 10);
+ KillStr.length = strlen (KillStr.str);
+ width = 2;
+ if ( temp > 99 )
+ {
+ width = 3;
+ }
+ DrawNumber( xpos + KILLS_OFFSET + 16 - ( 8 * width ), iKILLS_Y, width, 4, bufferofsonly);
+ }
+ else
+ {
+ pic = ( pic_t * )W_CacheLumpName( "minus", PU_CACHE, Cvt_pic_t, 1 );
+ StatusDrawColoredPic( ( xpos + KILLS_OFFSET ), iKILLS_Y, pic, bufferofsonly, playeruniformcolor );
+ StatusDrawColoredPic( ( xpos + KILLS_OFFSET + 8 ), iKILLS_Y, pic, bufferofsonly, playeruniformcolor );
+ }
+
+ // Get codename
+ if ( gamestate.teamplay )
+ {
+ GetShortCodeName( codename, colorname[ playeruniformcolor ],
+ KILLS_WIDTH - 2 );
+ }
+ else
+ {
+ GetShortCodeName( codename, PLAYERSTATE[ playerimage ].codename,
+ KILLS_WIDTH - 2 );
+ }
+
+ // Draw name
+ DrawGameString (xpos + 1, KILLS_NAME_Y, codename, bufferofsonly);
+
+ // Advance to next position
+ xpos += KILLS_WIDTH;
+
+ if ( xpos >= iGLOBAL_SCREENWIDTH )
+ {
+ break;
+ }
+ }
+
+ for( rank = BATTLE_NumberOfTeams; rank <= MAXKILLBOXES; rank++ )
+ {
+ if ( xpos >= iGLOBAL_SCREENWIDTH )
+ {
+ break;
+ }
+
+ pic = blankfragpic;
+ DrawPPic( xpos, iKILLS_Y, pic->width, pic->height,
+ (byte *)&pic->data, 1, true, bufferofsonly );
+
+ // Advance to next position
+ xpos += KILLS_WIDTH;
+ }
+}
+
+
+//******************************************************************************
+//
+// DrawPlayers ()
+//
+//******************************************************************************
+void DrawPlayers
+(
+ void
+)
+
+{
+ int num;
+ int xpos;
+ char codename[ MAXCODENAMELENGTH ];
+ int length;
+ int width;
+ int height;
+ int team;
+ int player;
+ int character;
+ pic_t *pic;
+ pic_t *enemy;
+ pic_t *friend;
+
+ num = W_GetNumForName( "botpic1" );
+
+ scorenums[ 0 ]= ( pic_t * )W_CacheLumpName( "kilnum0", PU_CACHE, Cvt_pic_t, 1 );
+ friend = ( pic_t * )W_CacheLumpName( "t_friend", PU_CACHE, Cvt_pic_t, 1 );
+ enemy = ( pic_t * )W_CacheLumpName( "t_enemy", PU_CACHE, Cvt_pic_t, 1 );
+
+ // Draw all the losers
+ CurrentFont = tinyfont;
+
+ xpos = (iGLOBAL_SCREENWIDTH - min( numplayers, MAXKILLBOXES ) * KILLS_WIDTH ) / 2;
+//SetTextMode ( );//PLAYERSTATE
+ for( team = 0; team < BATTLE_NumberOfTeams; team++ )
+ {
+ for( player = 0; player < numplayers; player++ )
+ {
+ if ( BATTLE_Team[ player ] == team )
+ {
+ character = PLAYERSTATE[ player ].player;
+
+ fragpic[ character ] = ( pic_t * )W_CacheLumpNum( num +
+ character, PU_CACHE, Cvt_pic_t, 1 );
+
+ if ( ( numplayers <= MAXKILLBOXES ) ||
+ ( player != consoleplayer ) )
+ {
+ // Set uniformcolor
+ playeruniformcolor = PLAYERSTATE[ player ].uniformcolor;
+
+ // Draw player's point box
+ pic = fragpic[ PLAYERSTATE[ player ].player ];
+
+ VWB_DrawPic ( xpos, PLAYERS_Y, pic );
+ if ( gamestate.teamplay )
+ {
+ if ( BATTLE_Team[ player ] == BATTLE_Team[ consoleplayer ] )
+ {
+ VWB_DrawPic ( xpos, PLAYERS_TEAM_Y, friend );
+ }
+ else
+ {
+ VWB_DrawPic ( xpos, PLAYERS_TEAM_Y, enemy );
+ }
+ }
+
+ strcpy( KillStr.str, "00" );
+ KillStr.length = strlen ( KillStr.str );
+ DrawNumber( xpos + KILLS_OFFSET, PLAYERS_Y, 2, 4, true );
+
+ // Get codename
+ strcpy( codename, PLAYERSTATE[ player ].codename );
+
+ // Shorten name to fit into point count
+ length = strlen( codename );
+ US_MeasureStr( &width, &height, "%s", codename );
+ while( width > KILLS_WIDTH )
+ {
+ codename[ length ] = 0;
+ length--;
+ US_MeasureStr( &width, &height, "%s", codename );
+ }
+
+ // Draw name
+ PrintX = xpos;
+ PrintY = PLAYERS_NAME_Y;
+ US_Print( codename );
+
+ // Advance to next position
+ xpos += KILLS_WIDTH;
+ }
+ }
+ if ( xpos >= iGLOBAL_SCREENWIDTH )
+ {
+ break;
+ }
+ }
+ if ( xpos >= iGLOBAL_SCREENWIDTH )
+ {
+ break;
+ }
+ }
+}
+
+//******************************************************************************
+//
+// StatusDrawPic ()
+//
+//******************************************************************************
+
+void StatusDrawPic (unsigned x, unsigned y, pic_t *nums, boolean bufferofsonly)
+{
+ DrawMPPic (x, y, nums->width, nums->height, 0,
+ (byte *)&nums->data, bufferofsonly);
+}
+
+//******************************************************************************
+//
+// StatusDrawColoredPic ()
+//
+//******************************************************************************
+
+void StatusDrawColoredPic (unsigned x, unsigned y, pic_t *nums, boolean bufferofsonly, int color)
+{
+ DrawColoredMPPic (x, y, nums->width, nums->height, 0,
+ (byte *)&nums->data, bufferofsonly, color);
+}
+
+//******************************************************************************
+//
+// DrawGameString ()
+//
+// draw string to game screen at x,y
+//
+//******************************************************************************
+
+void DrawGameString (int x, int y, const char * str, boolean bufferofsonly)
+{
+ byte *tempbuf;
+
+ px=x;
+ py=y;
+
+ if (bufferofsonly==true)
+ VW_DrawPropString (str);
+ else
+ {
+ tempbuf=bufferofs;
+ bufferofs=page1start;
+ VW_DrawPropString (str);
+#ifdef DOS
+ px=x;
+ py=y;
+ bufferofs=page2start;
+ VW_DrawPropString (str);
+ px=x;
+ py=y;
+ bufferofs=page3start;
+ VW_DrawPropString (str);
+#endif
+ bufferofs=tempbuf;
+ }
+}
+
+
+//******************************************************************************
+//
+// DrawNumber ()
+//
+// right justifies and pads with zeros
+//
+//******************************************************************************
+
+void DrawNumber (int x, int y, int width, int which, boolean bufferofsonly)
+{
+ unsigned length,c;
+ char *str;
+ byte z;
+
+ switch (which)
+ {
+ case 1:
+ str = ScoreStr.str;
+ length = ScoreStr.length;
+ break;
+
+ case 2:
+ str = LivesStr.str;
+ length = LivesStr.length;
+ break;
+
+ case 3:
+ str = TriadStr.str;
+ length = TriadStr.length;
+ break;
+
+ case 4:
+ case 5:
+ case 6:
+ str = KillStr.str;
+ length = KillStr.length;
+ break;
+ }
+
+ z = width - length; // Num zeros
+
+ while (z)
+ {
+ switch (which)
+ {
+ case 1:
+ StatusDrawPic (x, y, scorenums[0], bufferofsonly);
+ x+=8;
+ break;
+ case 2:
+ StatusDrawPic (x, y, lifenums[0], bufferofsonly);
+ x+=8;
+ break;
+ case 3:
+ StatusDrawPic (x, y, lifeptnums[0], bufferofsonly);
+ x+=6;
+ break;
+ case 4:
+ StatusDrawColoredPic (x, y, scorenums[0], bufferofsonly, playeruniformcolor);
+ x+=8;
+ break;
+ case 5:
+ StatusDrawPic (x, y, lifeptnums[0], bufferofsonly);
+ x+=6;
+ break;
+ case 6:
+ StatusDrawPic (x, y, lifenums[0], bufferofsonly);
+ x+=8;
+ break;
+ }
+ z--;
+ }
+
+ c = length <= (unsigned)width ? 0 : length-width;
+ while (c < length)
+ {
+ switch (which)
+ {
+ case 1:
+ StatusDrawPic (x, y, scorenums[str[c]-'0'], bufferofsonly);
+ x+=8;
+ break;
+ case 2:
+ StatusDrawPic (x, y, lifenums[str[c]-'0'], bufferofsonly);
+ x+=8;
+ break;
+ case 3:
+ StatusDrawPic (x, y, lifeptnums[str[c]-'0'], bufferofsonly);
+ x+=6;
+ break;
+ case 4:
+ StatusDrawColoredPic (x, y, scorenums[str[c]-'0'], bufferofsonly, playeruniformcolor);
+ x+=8;
+ break;
+ case 5:
+ StatusDrawPic (x, y, lifeptnums[str[c]-'0'], bufferofsonly);
+ x+=6;
+ break;
+ case 6:
+ StatusDrawPic (x, y, lifenums[str[c]-'0'], bufferofsonly);
+ x+=8;
+ break;
+ }
+ c++;
+ }
+}
+
+
+
+//******************************************************************************
+//
+// HealPlayer ()
+//
+//******************************************************************************
+
+void HealPlayer
+(
+ int points,
+ objtype *ob
+)
+
+{
+ playertype *pstate;
+ int maxhitpoints;
+
+ M_LINKSTATE( ob, pstate );
+
+ pstate->health += points;
+ maxhitpoints = MaxHitpointsForCharacter( pstate );
+ if ( pstate->health > maxhitpoints )
+ {
+ pstate->health = maxhitpoints;
+ }
+
+ if ( ( SHOW_BOTTOM_STATUS_BAR() ) && ( ob == player ) )
+ {
+ DrawBarHealth( false );
+ }
+}
+
+//******************************************************************************
+//
+// DrawLives ()
+//
+//******************************************************************************
+
+void DrawLives
+(
+ boolean bufferofsonly
+)
+
+{
+ if ( !SHOW_TOP_STATUS_BAR() )
+ {
+ return;
+ }
+
+ if ( !EndLevelStuff )
+ {
+ DrawNumber( LIVES_X + topBarCenterOffsetX, LIVES_Y, 2, 2, bufferofsonly );
+ }
+}
+
+
+//******************************************************************************
+//
+// GiveExtraMan ()
+//
+//******************************************************************************
+
+void GiveExtraMan (void)
+{
+ if (locplayerstate->lives < 99)
+ locplayerstate->lives++;
+ UpdateLives (locplayerstate->lives);
+ DrawLives (false);
+// SD_PlaySound (BONUS1UPSND);
+}
+
+
+
+//******************************************************************************
+//
+// DrawScore ()
+//
+//******************************************************************************
+
+void DrawScore
+(
+ boolean bufferofsonly
+)
+
+{
+ if ( !SHOW_TOP_STATUS_BAR() )
+ {
+ return;
+ }
+
+ if ( !BATTLEMODE )
+ {
+ DrawNumber( SCORE_X + topBarCenterOffsetX, SCORE_Y, 10, 1, bufferofsonly );
+ }
+}
+
+
+//******************************************************************************
+//
+// GivePoints ()
+//
+//******************************************************************************
+
+void GivePoints (long points)
+{
+ gamestate.score += points;
+
+ UpdateScore (gamestate.score);
+
+ if (!EndLevelStuff)
+ DrawScore (false);
+}
+
+
+//******************************************************************************
+//
+// GiveKey ()
+//
+//******************************************************************************
+
+void GiveKey (int key)
+{
+ locplayerstate->keys |= (1<<key);
+ DrawKeys (false);
+}
+
+
+//******************************************************************************
+//
+// GiveLives ()
+//
+//******************************************************************************
+
+void GiveLives (int newlives)
+{
+ if ((locplayerstate->lives + newlives) <= 99)
+ locplayerstate->lives += newlives;
+ else
+ locplayerstate->lives = 99;
+ UpdateLives (locplayerstate->lives);
+ DrawLives (false);
+}
+
+
+#define EnableOldWeapon(pstate) \
+ { \
+ LASTSTAT->flags |= FL_ABP; \
+ LASTSTAT->flags &= ~FL_RESPAWN; \
+ MakeStatActive(LASTSTAT); \
+ pstate->weaponx = ob->tilex; \
+ pstate->weapony = ob->tiley; \
+ }
+
+
+//******************************************************************************
+//
+// GiveWeapon ()
+//
+//******************************************************************************
+
+void GiveWeapon
+(
+ objtype *ob,
+ int weapon
+)
+
+{
+ playertype *pstate;
+
+ M_LINKSTATE( ob, pstate );
+
+ if ( pstate->weapon == weapon )
+ {
+ return;
+ }
+
+ pstate->HASBULLETWEAPON[ weapon ] = 1;
+ if ( ( pstate->weapon == pstate->bulletweapon ) &&
+ ( pstate->weapon < weapon ) )
+ {
+ pstate->new_weapon = weapon;
+ pstate->weapondowntics = WEAPONS[ pstate->weapon ].screenheight / GMOVE;
+ if ( ( ob == player ) && ( SHOW_BOTTOM_STATUS_BAR() ) )
+ {
+ DrawBarAmmo( false );
+ }
+ }
+
+ if ( gamestate.BattleOptions.WeaponPersistence )
+ {
+ SpawnStatic(ob->tilex,ob->tiley,GetItemForWeapon(weapon),9);
+ EnableOldWeapon(pstate);
+ }
+
+ if ( weapon > pstate->bulletweapon )
+ {
+ pstate->bulletweapon = weapon;
+ }
+}
+
+//LT added
+//******************************************************************************
+//
+// GivePlayerAmmo ()
+//
+//******************************************************************************
+
+
+void GivePlayerAmmo(objtype *ob, statobj_t *item_pickup, int which)
+{
+ playertype * pstate;
+
+ M_LINKSTATE(ob, pstate);
+
+ signed char * playerCurrentAmmo = (signed char *) (int)pstate->ammo;
+ signed char * ammoInItem = (signed char *) (int)item_pickup->ammo;
+ signed char * maxAmmoInWeapon = (signed char *) (int)stats[item_pickup->itemnumber].ammo;
+ signed char * newAmmoAmount = (signed char *)((int)ammoInItem + (int)playerCurrentAmmo);
+
+ if (newAmmoAmount > maxAmmoInWeapon)
+ {
+ ammoInItem = (signed char *)((int)newAmmoAmount - (int)maxAmmoInWeapon);
+ if (ammoInItem < 0)
+ {
+ Error("Ammo in item cannot be set to a negative number!");
+ }
+ item_pickup->ammo = (int) ammoInItem;
+ newAmmoAmount = maxAmmoInWeapon;
+ }
+ else
+ {
+ ammoInItem = 0;
+ }
+ pstate->ammo = (int)newAmmoAmount;
+
+ if (pstate->ammo &&
+ (pstate->missileweapon != -1) &&
+ (!(WEAPON_IS_MAGICAL(which))) &&
+ (!(WEAPON_IS_MAGICAL(pstate->missileweapon))))
+ {
+ int nx,ny;
+
+
+ nx = ob->tilex;
+ ny = ob->tiley;
+
+ //If the missile weapon still has ammo in it after taking ammo from it, spawn it on the ground
+ if (ammoInItem)
+ {
+ if (IsPlatform(nx,ny))
+ SpawnStatic(nx,ny,GetItemForWeapon(pstate->missileweapon),9);
+ else
+ {
+ int newz = sprites[ob->tilex][ob->tiley]->z;
+ SpawnStatic(nx,ny,GetItemForWeapon(pstate->missileweapon),-1);
+ LASTSTAT->z = newz;
+ }
+
+ //update ammo count on missile weapon on ground
+ LASTSTAT->ammo = (int)ammoInItem;
+ EnableOldWeapon(pstate);
+ }
+ }
+}
+
+//******************************************************************************
+//
+// GiveMissileWeapon ()
+//
+//******************************************************************************
+
+void GiveMissileWeapon(objtype * ob, int which)
+{
+ playertype * pstate;
+
+
+ //pstate = (ob==player)?(&playerstate):(&remoteplayerstate);
+ M_LINKSTATE(ob,pstate);
+
+ if (!gamestate.BattleOptions.WeaponPersistence)
+ {
+ if (pstate->ammo &&
+ (pstate->missileweapon != -1) &&
+ (!(WEAPON_IS_MAGICAL(which))) &&
+ (!(WEAPON_IS_MAGICAL(pstate->missileweapon)))
+ )
+ {
+ int nx,ny;
+
+
+ nx = ob->tilex;
+ ny = ob->tiley;
+ //FindEmptyTile(&nx,&ny);
+
+ if (IsPlatform(nx,ny))
+ SpawnStatic(nx,ny,GetItemForWeapon(pstate->missileweapon),9);
+ else
+ {
+ int newz = sprites[ob->tilex][ob->tiley]->z;
+ SpawnStatic(nx,ny,GetItemForWeapon(pstate->missileweapon),-1);
+ LASTSTAT->z = newz;
+ }
+ LASTSTAT->ammo = pstate->ammo;
+ EnableOldWeapon(pstate);
+
+ }
+ }
+
+ else if (!WEAPON_IS_MAGICAL(which))
+ {
+ int newz = sprites[ob->tilex][ob->tiley]->z;
+ SpawnStatic(ob->tilex,ob->tiley,GetItemForWeapon(which),9);
+ LASTSTAT->z = newz;
+ EnableOldWeapon(pstate);
+
+ }
+ pstate->new_weapon = pstate->missileweapon = which;
+ pstate->weapondowntics = WEAPONS[pstate->weapon].screenheight/GMOVE;
+
+
+}
+
+
+//******************************************************************************
+//
+// DrawKeys ()
+//
+//******************************************************************************
+
+void DrawKeys(boolean bufferofsonly)
+{
+ if ( !SHOW_TOP_STATUS_BAR() )
+ {
+ return;
+ }
+
+ if ( locplayerstate->keys & 1 )
+ {
+ GameMemToScreen( keys[ 0 ], KeyX[ 0 ] + topBarCenterOffsetX, KEY_Y, bufferofsonly );
+ }
+
+ if ( locplayerstate->keys & 2 )
+ {
+ GameMemToScreen( keys[ 1 ], KeyX[ 1 ] + topBarCenterOffsetX, KEY_Y, bufferofsonly );
+ }
+
+ if ( locplayerstate->keys & 4 )
+ {
+ GameMemToScreen( keys[ 2 ], KeyX[ 2 ] + topBarCenterOffsetX, KEY_Y, bufferofsonly );
+ }
+
+ if ( locplayerstate->keys & 8 )
+ {
+ GameMemToScreen( keys[ 3 ], KeyX[ 3 ] + topBarCenterOffsetX, KEY_Y, bufferofsonly );
+ }
+}
+
+
+//******************************************************************************
+//
+// StatusDrawTime ()
+//
+//******************************************************************************
+
+void StatusDrawTime
+(
+ unsigned x,
+ unsigned y,
+ unsigned num,
+ boolean bufferofsonly
+)
+
+{
+ DrawMPPic( x, y, timenums[ num ]->width, timenums[ num ]->height, 0,
+ ( byte * )&timenums[ num ]->data, bufferofsonly );
+}
+
+
+//******************************************************************************
+//
+// DrawTimeNumber ()
+//
+// right justifies and pads with blanks
+//
+//******************************************************************************
+
+void DrawTimeNumber (int x, int y, int number, boolean seconds, boolean bufferofsonly)
+{
+ char str[20];
+
+ ltoa (number,str,10);
+
+ if (seconds)
+ {
+ if (number < 10)
+ {
+ StatusDrawTime (x, y, 0, bufferofsonly);
+ StatusDrawTime (x+8, y, str[0]-'0', bufferofsonly);
+ }
+ else
+ {
+ StatusDrawTime (x, y, str[0]-'0', bufferofsonly);
+ StatusDrawTime (x+8, y, str[1]-'0', bufferofsonly);
+ }
+ }
+ else
+ {
+ if (number < 10)
+ StatusDrawTime (x+8, y, str[0]-'0', bufferofsonly);
+ else
+ {
+ StatusDrawTime (x, y, str[0]-'0', bufferofsonly);
+ StatusDrawTime (x+8, y, str[1]-'0', bufferofsonly);
+ }
+ }
+}
+
+
+//******************************************************************************
+//
+// DrawTimeXY ()
+//
+//******************************************************************************
+
+void DrawTimeXY
+(
+ int x,
+ int y,
+ int sec,
+ boolean bufferofsonly
+)
+
+{
+ int min;
+ int hour;
+
+ while (sec > ( ( 9 * 3600 ) + 3599 ) )
+ {
+ sec -= ( ( 9 * 3600 ) + 3599 );
+ }
+
+ hour = sec / 3600;
+ min = ( sec / 60 ) - ( hour * 60 );
+ sec %= 60;
+
+ DrawTimeNumber ( x + HOUR_X, y, hour, false, bufferofsonly );
+ DrawTimeNumber ( x + MIN_X, y, min, true, bufferofsonly );
+ DrawTimeNumber ( x + SEC_X, y, sec, true, bufferofsonly );
+}
+
+
+//******************************************************************************
+//
+// DrawTime ()
+//
+//******************************************************************************
+
+void DrawTime
+(
+ boolean bufferofsonly
+)
+
+{
+ int sec;
+
+ if ( !SHOW_TOP_STATUS_BAR() )
+ {
+ return;
+ }
+
+ if (timelimitenabled == true)
+ {
+ sec = (timelimit-gamestate.TimeCount) / VBLCOUNTER;
+ }
+ else
+ {
+ sec = gamestate.TimeCount / VBLCOUNTER;
+ }
+
+ if ( oldsec != sec )
+ {
+ oldsec = sec;
+ DrawTimeXY( GAMETIME_X + topBarCenterOffsetX, GAMETIME_Y, sec, bufferofsonly) ;
+ }
+}
+
+
+//******************************************************************************
+//
+// DrawMPPic ()
+//
+// Purpose
+// Draws a masked, planer pic at xpos, ypos.
+//
+// Parms
+// xpos - x position.
+// ypos - y position.
+// width - width of pic : should be << 2.
+// height - height of pic.
+// src - data to draw.
+//
+// Returns
+// Nothing.
+//
+//******************************************************************************
+
+void DrawMPPic (int xpos, int ypos, int width, int height, int heightmod, byte *src, boolean bufferofsonly)
+{
+ int olddest;
+ int dest;
+ int x;
+ int y;
+ int planes;
+ byte mask;
+ byte pixel;
+
+ mask = 1 << (xpos&3);
+
+#ifdef DOS
+ olddest = ylookup[ypos] + (xpos>>2);
+#else
+ olddest = ylookup[ypos] + xpos;
+#endif
+
+ for (planes = 0; planes < 4; planes++)
+ {
+ VGAMAPMASK (mask);
+
+ dest = olddest;
+
+#ifndef DOS
+ dest += planes;
+#endif
+
+ for (y = 0; y < height; y++)
+ {
+ for (x = 0; x < width; x++)
+ {
+ pixel = *src++;
+
+ if (pixel != 255)
+ {
+ if (bufferofsonly)
+ *(dest+bufferofs) = pixel;
+ else
+ {
+ *(dest+page1start) = pixel;
+ *(dest+page2start) = pixel;
+ *(dest+page3start) = pixel;
+ }
+ }
+
+#ifdef DOS
+ dest++;
+#else
+ dest += 4;
+#endif
+ }
+
+#ifdef DOS
+ dest += (linewidth-width);
+#else
+ dest += (linewidth-width*4);
+#endif
+ }
+
+ if (heightmod)
+ src += (heightmod*width);
+
+#ifdef DOS
+ mask <<= 1;
+ if (mask == 16)
+ {
+ mask = 1;
+ olddest++;
+ }
+#endif
+ }
+}
+
+
+//******************************************************************************
+//
+// DrawColoredMPPic ()
+//
+// Purpose
+// Draws a masked, planer pic at xpos, ypos.
+//
+// Parms
+// xpos - x position.
+// ypos - y position.
+// width - width of pic : should be << 2.
+// height - height of pic.
+// src - data to draw.
+//
+// Returns
+// Nothing.
+//
+//******************************************************************************
+
+void DrawColoredMPPic (int xpos, int ypos, int width, int height, int heightmod, byte *src, boolean bufferofsonly, int color)
+{
+ int olddest;
+ int dest;
+ int x;
+ int y;
+ int planes;
+ byte mask;
+ byte pixel;
+ byte * cmap;
+
+ cmap=playermaps[color]+(1<<12);
+
+ mask = 1 << (xpos&3);
+
+#ifdef DOS
+ olddest = ylookup[ypos] + (xpos>>2);
+#else
+ olddest = ylookup[ypos] + xpos;
+#endif
+
+ for (planes = 0; planes < 4; planes++)
+ {
+ VGAMAPMASK (mask);
+
+ dest = olddest;
+
+#ifndef DOS
+ dest += planes;
+#endif
+
+ for (y = 0; y < height; y++)
+ {
+ for (x = 0; x < width; x++)
+ {
+ pixel = *src++;
+
+ pixel = *(cmap+pixel);
+
+ if (pixel != 255)
+ {
+ if (bufferofsonly)
+ *(dest+bufferofs) = pixel;
+ else
+ {
+ *(dest+page1start) = pixel;
+ *(dest+page2start) = pixel;
+ *(dest+page3start) = pixel;
+ }
+ }
+
+#ifdef DOS
+ dest++;
+#else
+ dest += 4;
+#endif
+ }
+
+#ifdef DOS
+ dest += (linewidth-width);
+#else
+ dest += (linewidth-width*4);
+#endif
+ }
+
+ if (heightmod)
+ src += (heightmod*width);
+
+#ifdef DOS
+ mask <<= 1;
+ if (mask == 16)
+ {
+ mask = 1;
+ olddest++;
+ }
+#endif
+ }
+}
+
+
+//******************************************************************************
+//
+// UpdateScore ()
+//
+//******************************************************************************
+
+void UpdateScore (unsigned int num)
+{
+ if (num > 999999999)
+ {
+ num = 999999999;
+ gamestate.score = 999999999;
+ }
+
+ ltoa (num, ScoreStr.str, 10);
+ ScoreStr.length = strlen (ScoreStr.str);
+}
+
+
+//******************************************************************************
+//
+// UpdateLives ()
+//
+//******************************************************************************
+
+void UpdateLives (int num)
+{
+ ltoa (num, LivesStr.str, 10);
+ LivesStr.length = strlen (LivesStr.str);
+}
+
+//****************************************************************************
+//
+// ClearTriads ()
+//
+//****************************************************************************
+void ClearTriads (playertype * pstate)
+{
+ pstate->triads = 0;
+ ltoa (pstate->triads, TriadStr.str, 10);
+ TriadStr.length = strlen (TriadStr.str);
+}
+
+//****************************************************************************
+//
+// UpdateTriads ()
+//
+//****************************************************************************
+
+void UpdateTriads (objtype * ob, int num)
+{
+ playertype * pstate;
+
+ M_LINKSTATE(ob,pstate);
+
+ pstate->triads += num;
+
+ if (pstate->triads >= 100)
+ {
+ GiveLives(1);
+ if (ob==player)
+ {
+ AddMessage("100 Life Item Points! Extra Life!",MSG_BONUS);
+ SD_PlaySoundRTP (SD_GET1UPSND, player->x, player->y);
+ }
+ pstate->triads -= 100;
+ }
+
+ if (ob==player)
+ {
+ ltoa (pstate->triads, TriadStr.str, 10);
+ TriadStr.length = strlen (TriadStr.str);
+ }
+}
+
+//****************************************************************************
+//
+// DrawTriads ()
+//
+//****************************************************************************
+
+void DrawTriads(boolean bufferofsonly)
+
+{
+ if ( !SHOW_TOP_STATUS_BAR() )
+ {
+ return;
+ }
+
+ if ( !EndLevelStuff )
+ {
+ DrawNumber( TRIAD_X + topBarCenterOffsetX, TRIAD_Y, 2, 3, bufferofsonly );
+ }
+}
+
+
+//******************************************************************************
+//
+// DrawPPic ()
+//
+//******************************************************************************
+
+void DrawPPic (int xpos, int ypos, int width, int height, byte *src, int num, boolean up, boolean bufferofsonly)
+{
+ int olddest;
+ int dest;
+ int x;
+ int y;
+ int planes;
+ byte mask;
+ byte pixel;
+ int k;
+ int amt;
+
+#ifdef DOS
+ if (up)
+ amt = 2;
+ else
+ amt = -2;
+#else
+ if (up)
+ amt = 8;
+ else
+ amt = -8;
+#endif
+
+ mask = 1;
+
+#ifdef DOS
+ olddest = ylookup[ypos] + (xpos>>2);
+#else
+ olddest = ylookup[ypos] + xpos;
+#endif
+
+ for (planes = 0; planes < 4; planes++)
+ {
+ VGAMAPMASK (mask);
+
+ dest = olddest;
+
+#ifndef DOS
+ dest += planes;
+#endif
+
+ for (y = 0; y < height; y++)
+ {
+ for (x = 0; x < width; x++)
+ {
+ pixel = *src++;
+
+ if (pixel != 255)
+ {
+ for (k = 0; k < num; k++)
+ {
+ if (bufferofsonly)
+ *(dest+bufferofs+(amt*k)) = pixel;
+ else
+ {
+ *(dest+page1start+(amt*k)) = pixel;
+ *(dest+page2start+(amt*k)) = pixel;
+ *(dest+page3start+(amt*k)) = pixel;
+ }
+ }
+ }
+
+#ifdef DOS
+ dest++;
+#else
+ dest += 4;
+#endif
+ }
+
+#ifdef DOS
+ dest += (linewidth-width);
+#else
+ dest += (linewidth-width*4);
+#endif
+ }
+
+ mask <<= 1;
+ }
+}
+
+
+//****************************************************************************
+//
+// DrawBarHealth ()
+//
+//****************************************************************************
+
+void DrawBarHealth
+(
+ boolean bufferofsonly
+)
+
+{
+ int percenthealth;
+ int health_y;
+
+ if ( !SHOW_BOTTOM_STATUS_BAR() )
+ {
+ return;
+ }
+
+ health_y = iGLOBAL_HEALTH_Y;
+ if ( SHOW_KILLS() )
+ {
+ health_y -= KILLS_HEIGHT;
+ }
+
+ percenthealth = ( locplayerstate->health * 10 ) /
+ MaxHitpointsForCharacter( locplayerstate );
+
+ oldpercenthealth = percenthealth + 1;
+
+ if ( playstate == ex_died )
+ {
+ DrawPPic( iGLOBAL_HEALTH_X, health_y, 8 >> 2, 16, ( byte * )&erase->data,
+ 10, true, bufferofsonly );
+
+ return;
+ }
+
+ if ( locplayerstate->health <= 0 )
+ {
+ oldpercenthealth = 0;
+ }
+
+ if ( oldpercenthealth >= 11 )
+ {
+ oldpercenthealth = 10;
+ }
+
+ if ( oldpercenthealth < 4 )
+ {
+ DrawPPic( iGLOBAL_HEALTH_X, health_y, 8 >> 2, 16,
+ ( byte * )&health[ 0 ]->data, oldpercenthealth,
+ true, bufferofsonly );
+ }
+ else if ( oldpercenthealth < 5 )
+ {
+ DrawPPic( iGLOBAL_HEALTH_X, health_y, 8 >> 2, 16,
+ (byte *)&health[ 1 ]->data, oldpercenthealth,
+ true, bufferofsonly );
+ }
+ else
+ {
+ DrawPPic( iGLOBAL_HEALTH_X, health_y, 8 >> 2, 16,
+ ( byte * )&health[ 2 ]->data, oldpercenthealth,
+ true, bufferofsonly );
+ }
+
+ if ( oldpercenthealth < 10 )
+ {
+ DrawPPic( iGLOBAL_HEALTH_X + ( 8 * oldpercenthealth ), health_y,
+ 8 >> 2, 16, ( byte * )&erase->data, 10 - oldpercenthealth,
+ true, bufferofsonly );
+ }
+}
+
+
+//****************************************************************************
+//
+// DrawBarAmmo ()
+//
+//****************************************************************************
+
+void DrawBarAmmo(boolean bufferofsonly)
+{
+ int ammo_y;
+
+ if ( ( !SHOW_BOTTOM_STATUS_BAR() ) || ( playstate == ex_died ) )
+ {
+ return;
+ }
+
+ ammo_y = iGLOBAL_AMMO_Y;
+ if ( SHOW_KILLS() )
+ {
+ ammo_y -= KILLS_HEIGHT;
+ }
+
+ DrawPPic ( iGLOBAL_AMMO_X, ammo_y + 1, 8 >> 2, 16, ( byte * )&erase->data,
+ 10, false, bufferofsonly );
+
+ if ( !ARMED( player->dirchoosetime ) )
+ {
+ return;
+ }
+ if ((locplayerstate->new_weapon < wp_bazooka) ||
+ (locplayerstate->new_weapon == wp_godhand) ||
+ ( gamestate.BattleOptions.Ammo == bo_infinite_shots )
+ )
+ {
+ DrawPPic( iGLOBAL_AMMO_X - 16, ammo_y, 24 >> 2, 16,
+ ( byte * )&ammo[ 0 ]->data, 1, true, bufferofsonly);
+
+ DrawPPic( iGLOBAL_AMMO_X - 32, ammo_y + 1, 8 >> 2, 16,
+ ( byte * )&erase->data, 2, true, bufferofsonly );
+ }
+#if (SHAREWARE == 0)
+ else if ( locplayerstate->new_weapon == wp_dog )
+ {
+ DrawPPic( iGLOBAL_AMMO_X - 16, ammo_y, 24 >> 2, 16,
+ ( byte * )&ammo[12]->data, 1, true, bufferofsonly );
+
+ DrawPPic( iGLOBAL_AMMO_X - 32, ammo_y + 1, 8 >> 2, 16,
+ ( byte * )&erase->data, 2, true, bufferofsonly );
+ }
+#endif
+ else
+ {
+ DrawPPic( iGLOBAL_AMMO_X, ammo_y + 1, 8 >> 2, 16,
+ ( byte * )&ammo[ locplayerstate->new_weapon]->data,
+ locplayerstate->ammo, false, bufferofsonly );
+ }
+}
+
+
+//******************************************************************************
+//
+// SingleDrawPPic ()
+//
+//******************************************************************************
+
+void SingleDrawPPic (int xpos, int ypos, int width, int height, byte *src, int num, boolean up)
+{
+ byte *olddest;
+ byte *dest;
+ int x;
+ int y;
+ int planes;
+ byte mask;
+ byte pixel;
+ int k;
+ int amt;
+
+#ifdef DOS
+ if (up)
+ amt = 2;
+ else
+ amt = -2;
+#else
+ if (up)
+ amt = 8;
+ else
+ amt = -8;
+#endif
+
+ mask = 1;
+
+#ifdef DOS
+ olddest = (byte *)(bufferofs - screenofs + ylookup[ypos] + (xpos>>2));
+#else
+ olddest = (byte *)(bufferofs - screenofs + ylookup[ypos] + xpos);
+#endif
+
+ for (planes = 0; planes < 4; planes++)
+ {
+ VGAMAPMASK (mask);
+
+ dest = olddest;
+
+#ifndef DOS
+ dest += planes;
+#endif
+
+ for (y = 0; y < height; y++)
+ {
+ for (x = 0; x < width; x++)
+ {
+ pixel = *src++;
+
+ if (pixel != 255)
+ {
+ for (k = 0; k < num; k++)
+ {
+ *(dest+(amt*k)) = pixel;
+ }
+ }
+
+#ifdef DOS
+ dest++;
+#else
+ dest += 4;
+#endif
+ }
+
+#ifdef DOS
+ dest += (linewidth-width);
+#else
+ dest += (linewidth-width*4);
+#endif
+ }
+
+ mask <<= 1;
+ }
+}
+
+
+
+//****************************************************************************
+//
+// DrawStats ()
+//
+//****************************************************************************
+
+void DrawStats
+(
+ void
+)
+
+{
+ int percenthealth;
+ int health_y;
+ int ammo_y;
+
+ if ( ( !SHOW_PLAYER_STATS() ) || ( playstate == ex_died ) ||
+ ( locplayerstate->health <= 0 ) )
+ {
+ return;
+ }
+
+// Uncomment this if we want transparent health only on sizes < 16
+// if ( viewsize < 16 )
+// {
+// pic_t *shape;
+//
+// shape = W_CacheLumpName( "backtile", PU_CACHE );
+// DrawTiledRegion( 0, 160, 320, 24, shape );
+// }
+
+ health_y = iGLOBAL_HEALTH_Y;
+ ammo_y = iGLOBAL_AMMO_Y;
+
+ if ( SHOW_KILLS() )
+ {
+ health_y -= KILLS_HEIGHT;
+ ammo_y -= KILLS_HEIGHT;
+ }
+
+ if ( oldplayerhealth != locplayerstate->health )
+ {
+ oldplayerhealth = locplayerstate->health;
+
+ percenthealth = ( locplayerstate->health * 10 ) /
+ MaxHitpointsForCharacter( locplayerstate );
+
+ oldpercenthealth = percenthealth + 1;
+ }
+
+ if ( oldpercenthealth > 10 )
+ {
+ oldpercenthealth = 10;
+ }
+
+ if ( oldpercenthealth < 4 )
+ {
+ SingleDrawPPic( iGLOBAL_HEALTH_X - 16, health_y, 8 >> 2, 16,
+ ( byte * )&health[ 3 ]->data, oldpercenthealth, true);
+ }
+ else if ( oldpercenthealth < 5 )
+ {
+ SingleDrawPPic( iGLOBAL_HEALTH_X - 16, health_y, 8 >> 2, 16,
+ ( byte * )&health[ 4 ]->data, oldpercenthealth, true );
+ }
+ else
+ {
+ SingleDrawPPic( iGLOBAL_HEALTH_X - 16, health_y, 8 >> 2, 16,
+ ( byte * )&health[ 5 ]->data, oldpercenthealth, true );
+ }
+
+ if ( ARMED( consoleplayer ) )
+ {
+ if ((locplayerstate->new_weapon < wp_bazooka) ||
+ (locplayerstate->new_weapon == wp_godhand) ||
+ (gamestate.BattleOptions.Ammo == bo_infinite_shots )
+ )
+
+ {
+ SingleDrawPPic( iGLOBAL_AMMO_X - 16, ammo_y, 24 >> 2, 16,
+ ( byte * )&ammo[13]->data, 1, true );
+ }
+#if (SHAREWARE == 0)
+ else if ( locplayerstate->new_weapon == wp_dog )
+ {
+ SingleDrawPPic( iGLOBAL_AMMO_X - 16, ammo_y + 1, 24 >> 2, 16,
+ ( byte * )&ammo[25]->data, 1, true );
+ }
+#endif
+ else
+ {
+ SingleDrawPPic( iGLOBAL_AMMO_X, ammo_y + 1, 8 >> 2, 16,
+ ( byte * )&ammo[13 + locplayerstate->new_weapon]->data,
+ locplayerstate->ammo, false );
+ }
+ }
+}
+
+
+//****************************************************************************
+//
+// DrawPauseXY ()
+//
+//****************************************************************************
+
+void DrawPauseXY (int x, int y)
+{
+ pic_t *p;
+ byte *buftmp;
+
+ buftmp = bufferofs;
+
+ if (GamePaused == true)
+ {
+ p = (pic_t *) W_CacheLumpNum (W_GetNumForName ("paused"), PU_CACHE, Cvt_pic_t, 1);
+ VL_MemToScreen ((byte *)&p->data, p->width, p->height,x, y);
+ //VWB_DrawPic (x, y, p);
+ bufferofs = buftmp;
+ DrawEpisodeLevel (x,y);
+ //VL_MemToScreen ((byte *)&p->data, p->width, p->height,x, y);
+
+ }
+ else
+ {
+ p = (pic_t *) W_CacheLumpNum (W_GetNumForName ("wait"), PU_CACHE, Cvt_pic_t, 1);
+ VL_MemToScreen ((byte *)&p->data, p->width, p->height,x, y);
+ //VWB_DrawPic (x, y, p);
+ }
+ bufferofs = buftmp;
+}
+
+//****************************************************************************
+//
+// DrawPause ()
+//
+//****************************************************************************
+
+void DrawPause (void)
+{
+ pic_t *p;
+ byte *bufftemp = bufferofs;
+
+ bufferofs -= screenofs;
+
+ if (GamePaused == true)
+ {
+ bufferofs = bufftemp;
+ p = (pic_t *) W_CacheLumpNum (W_GetNumForName ("paused"), PU_CACHE, Cvt_pic_t, 1);
+ DrawPauseXY( (iGLOBAL_SCREENWIDTH-(p->width<<2) ) >>1, (iGLOBAL_SCREENHEIGHT-p->height)>>1);//bna++
+ //DrawPauseXY( (320-(p->width<<2) ) >>1, (200-p->height)>>1);
+ /*
+ //buf = (byte *) SafeMalloc (64000);
+ w = p->width;
+ h = p->height;
+ x = (iGLOBAL_SCREENWIDTH-((p->width)<<2) ) >>1;
+ y = (iGLOBAL_SCREENHEIGHT-(p->height))>>1;
+
+ x1 = (iGLOBAL_SCREENWIDTH-((p->width*2)<<2) ) >>1;
+ y1 = (iGLOBAL_SCREENHEIGHT-(p->height*2))>>1;
+
+ source = bufferofs + (iGLOBAL_SCREENWIDTH*y)+x;
+ target = bufferofs + (iGLOBAL_SCREENWIDTH*y1)+x1;
+
+ // memcpy(tmpPICbuf,bufftemp,iGLOBAL_SCREENWIDTH*iGLOBAL_SCREENHEIGHT);
+
+ bufferofs = bufftemp;//(byte *)tmpPICbuf;//buf;//write picture in tmpbuf
+ VL_MemToScreen ((byte *)&p->data, p->width, p->height,x, y);
+ bufferofs = bufftemp;
+ DrawEpisodeLevel (x,y);
+
+
+ //VL_MemStrechedToScreen ((byte *)&p->data, p->width, p->height,(iGLOBAL_SCREENWIDTH-((p->width*2)<<2) ) >>1, (iGLOBAL_SCREENHEIGHT-(p->height*2))>>1);
+ //DrawEpisodeLevel (x,y);
+
+ //VL_MemToScreen ((byte *)&p->data, p->width, p->height,0, 0);
+ //bufferofs = bufftemp;//move ptr back
+ //write it back to bufferofs while streching
+
+ //buf = bufftemp;
+ //b = tmpPICbuf ;
+
+ source = bufferofs + (iGLOBAL_SCREENWIDTH*y)+x+(w*4);
+ target = bufferofs + (iGLOBAL_SCREENWIDTH*y1)+x+(2*w*4);
+
+ //first strech lines in x direction
+ for (y=0;y<h;y++){
+ c=target;t2=source;
+ for (x=0;x<w*4;x++){
+ *target-- = *source;
+ *target-- = *source--;
+ }
+ target=c;source=t2;
+ target += iGLOBAL_SCREENWIDTH;
+ source += iGLOBAL_SCREENWIDTH;
+ }
+ //strech then lines in y direction
+ source -= ((iGLOBAL_SCREENWIDTH*(y/2))+(w*4));//bufferofs + (iGLOBAL_SCREENWIDTH*y)+x+(iGLOBAL_SCREENWIDTH*(y));
+ target = (source+(iGLOBAL_SCREENWIDTH*(y))+1);//bufferofs + (iGLOBAL_SCREENWIDTH*y)+x+(iGLOBAL_SCREENWIDTH*(y1));
+
+ for (y=0;y<h;y++){
+ memcpy(target,source,(w*4*2));
+ memcpy(target+iGLOBAL_SCREENWIDTH,source,(w*4*2));
+
+ target -= iGLOBAL_SCREENWIDTH*2;
+ source -= iGLOBAL_SCREENWIDTH;
+ }
+
+ / *
+ for (y=0;y<h;y++){
+ c=target;t2=source;
+ for (x=0;x<w*4;x++){
+ *target = *source;
+ *(target+++iGLOBAL_SCREENWIDTH) = *source;
+ *target = *source;
+ *(target+++iGLOBAL_SCREENWIDTH) = *source;
+ source++;
+ }
+ target=c;source=t2;
+ target += iGLOBAL_SCREENWIDTH*2;
+ source += iGLOBAL_SCREENWIDTH;
+ }
+ */
+
+// memcpy( bufftemp,tmpPICbuf,iGLOBAL_SCREENWIDTH*iGLOBAL_SCREENHEIGHT);
+
+ }
+ else
+ {
+ p = (pic_t *) W_CacheLumpNum (W_GetNumForName ("wait"), PU_CACHE, Cvt_pic_t, 1);
+ DrawPauseXY( (iGLOBAL_SCREENWIDTH-(p->width<<2) ) >>1, (iGLOBAL_SCREENHEIGHT-p->height)>>1);//bna++
+ //DrawPauseXY( (320-(p->width<<2) ) >>1, (200-p->height)>>1);
+ }
+// VH_UpdateScreen () ;
+
+ bufferofs = bufftemp;
+}
+
+//****************************************************************************
+//
+// GM_DrawBonus ()
+//
+//****************************************************************************
+
+void GM_DrawBonus
+(
+ int which
+)
+
+{
+ int x;
+
+ if ( which < stat_gasmask )
+ {
+ x = POWERUP1X;
+ poweruptime = GetBonusTimeForItem(which);
+ poweradjust = (poweruptime >> 4);
+ powerupheight = 0;
+ GM_UpdateBonus(poweruptime-poweradjust - 1,true);
+
+ }
+ else
+ {
+ x = POWERUP2X;
+ protectiontime = GetBonusTimeForItem(which);
+ poweradjust = (protectiontime >> 4);
+ protectionheight = 0;
+ GM_UpdateBonus(protectiontime-poweradjust-1,false);
+
+ }
+
+}
+
+
+//******************************************************************************
+//
+// GM_UpdateBonus ()
+//
+//******************************************************************************
+
+void GM_UpdateBonus
+(
+ int time,
+ int powerup
+)
+
+{
+ pic_t *shape;
+ int shapenum;
+
+ if ( powerup )
+ {
+ if ( time < ( poweruptime - poweradjust ) )
+ {
+ powerupheight++;
+ if ( !SHOW_TOP_STATUS_BAR() )
+ {
+ poweruptime = time;
+ }
+ }
+ }
+ else
+ {
+ if ( time < ( protectiontime - poweradjust ) )
+ {
+ protectionheight++;
+ if ( !SHOW_TOP_STATUS_BAR() )
+ {
+ protectiontime = time;
+ }
+ }
+ }
+
+
+ if ( !SHOW_TOP_STATUS_BAR() )
+ {
+ return;
+ }
+
+ if ( !time )
+ {
+ if ( powerup == 1 )
+ {
+ shapenum = POWERUP1X;
+ }
+ else
+ {
+ shapenum = POWERUP2X;
+ }
+
+ GM_MemToScreen( ( byte * )&eraseb->data, eraseb->width,
+ eraseb->height, shapenum + topBarCenterOffsetX, POWERUPY );
+
+ return;
+ }
+
+ if ( powerup )
+ {
+ if ( time < ( poweruptime - poweradjust ) )
+ {
+ if ( player->flags & FL_GODMODE )
+ {
+ shapenum = powerpics;
+ }
+ else if ( player->flags & FL_DOGMODE )
+ {
+ shapenum = powerpics + 1;
+ }
+ else if ( player->flags & FL_FLEET )
+ {
+ shapenum = powerpics + 2;
+ }
+ else if ( player->flags & FL_ELASTO )
+ {
+ shapenum = powerpics + 3;
+ }
+ else if ( player->flags & FL_SHROOMS )
+ {
+ shapenum = powerpics + 4;
+ }
+ else
+ {
+ GM_MemToScreen( ( byte * )&eraseb->data,
+ eraseb->width, eraseb->height, POWERUP1X + topBarCenterOffsetX, POWERUPY );
+
+ return;
+ }
+
+ poweruptime = time;
+
+ shape = ( pic_t * )W_CacheLumpNum( shapenum, PU_CACHE, Cvt_pic_t, 1 );
+
+ GM_MemToScreen( ( byte * )&eraseb->data, eraseb->width,
+ eraseb->height, POWERUP1X + topBarCenterOffsetX, POWERUPY );
+
+ DrawMPPic( POWERUP1X + topBarCenterOffsetX, POWERUPY + powerupheight, shape->width,
+ shape->height - powerupheight, powerupheight,
+ ( byte * )&shape->data, false );
+ }
+ }
+ else
+ {
+ if ( time < ( protectiontime - poweradjust ) )
+ {
+ if ( player->flags & FL_BPV )
+ {
+ shapenum = powerpics + 6;
+ }
+ else if ( player->flags & FL_GASMASK )
+ {
+ shapenum = powerpics + 5;
+ }
+ else if ( player->flags & FL_AV )
+ {
+ shapenum = powerpics + 7;
+ }
+
+ protectiontime = time;
+
+ shape = ( pic_t * )W_CacheLumpNum( shapenum, PU_CACHE, Cvt_pic_t, 1 );
+
+ GM_MemToScreen( ( byte * )&eraseb->data, eraseb->width,
+ eraseb->height, POWERUP2X + topBarCenterOffsetX, POWERUPY );
+
+ DrawMPPic( POWERUP2X + topBarCenterOffsetX, POWERUPY + protectionheight,
+ shape->width, shape->height - protectionheight,
+ protectionheight, ( byte * )&shape->data, false );
+ }
+ }
+}
+
+
+//******************************************************************************
+//
+// Drawpic ()
+//
+// Purpose
+// Draws a masked, planer pic at xpos, ypos.
+//
+// Parms
+// xpos - x position.
+// ypos - y position.
+// width - width of pic : should be << 2.
+// height - height of pic.
+// src - data to draw.
+//
+// Returns
+// Nothing.
+//
+//******************************************************************************
+
+void Drawpic (int xpos, int ypos, int width, int height, byte *src)
+{
+ byte *olddest;
+ byte *dest;
+ int x;
+ int y;
+ int planes;
+ byte mask;
+ byte pixel;
+
+
+ mask = 1 << (xpos&3);
+
+#ifdef DOS
+ olddest = (byte *)(bufferofs + ylookup[ypos] + (xpos>>2));
+#else
+ olddest = (byte *)(bufferofs + ylookup[ypos] + xpos);
+#endif
+ for (planes = 0; planes < 4; planes++)
+ {
+ VGAMAPMASK (mask);
+
+ dest = olddest;
+
+#ifdef DOS
+ dest += planes;
+#endif
+
+ for (y = 0; y < height; y++)
+ {
+ for (x = 0; x < width; x++)
+ {
+ pixel = *src++;
+
+ if (pixel != 255)
+ *(dest) = pixel;
+
+#ifdef DOS
+ dest++;
+#else
+ dest += 4;
+#endif
+ }
+
+#ifdef DOS
+ dest += (linewidth-width);
+#else
+ dest += (linewidth-width*4);
+#endif
+ }
+
+#ifdef DOS
+ mask <<= 1;
+ if (mask == 16)
+ {
+ mask = 1;
+ olddest++;
+ }
+#endif
+ }
+}
+
+
+//******************************************************************************
+//
+// DrawEpisodeLevel ()
+//
+// right justifies and pads with blanks
+//
+//******************************************************************************
+
+void DrawEpisodeLevel (int x, int y)
+{
+ int level;
+ char str[20];
+ pic_t *p;
+
+ if (!BATTLEMODE)
+ {
+ ltoa (gamestate.episode, str, 10);
+
+ //bna-- Drawpic (x+29, y+16, 8>>2, 16, (byte *)&timenums[str[0]-'0']->data);
+ VL_MemToScreenClipped ((byte *)&timenums[str[0]-'0']->data, 8>>2, 16, x+29, y+16);
+
+ if ((gamestate.mapon == 6) || (gamestate.mapon == 14) ||
+ (gamestate.mapon == 22) || (gamestate.mapon == 32) ||
+ (gamestate.mapon == 33))
+ {
+ p = (pic_t *) W_CacheLumpName ("tnumb", PU_CACHE, Cvt_pic_t, 1);
+ //Drawpic (x+40, y+16, 8>>2, 16, (byte *)&p->data);
+ VL_MemToScreenClipped ((byte *)&p->data, 8>>2, 16, x+40, y+16);
+
+ if (gamestate.mapon == 6)
+ level = 1;
+ else if (gamestate.mapon == 14)
+ level = 2;
+ else if (gamestate.mapon == 22)
+ level = 3;
+ else if (gamestate.mapon == 32)
+ level = 4;
+ else
+ level = 5;
+ }
+ else
+ level = GetLevel (gamestate.episode, gamestate.mapon);
+
+ level = abs(level);
+ ltoa (level, str, 10);
+
+ if (level < 10) {
+ //Drawpic (x+49, y+16, 8>>2, 16, (byte *)&timenums[str[0]-'0']->data);
+ VL_MemToScreenClipped ((byte *)&timenums[str[0]-'0']->data, 8>>2, 16, x+49, y+16);
+ } else {
+ //Drawpic (x+49, y+16, 8>>2, 16, (byte *)&timenums[str[0]-'0']->data);
+ VL_MemToScreenClipped ((byte *)&timenums[str[0]-'0']->data, 8>>2, 16, x+49, y+16);
+ //Drawpic (x+57, y+16, 8>>2, 16, (byte *)&timenums[str[1]-'0']->data);
+ VL_MemToScreenClipped ((byte *)&timenums[str[1]-'0']->data, 8>>2, 16, x+57, y+16);
+
+ }
+ }
+ else
+ {
+ p = (pic_t *) W_CacheLumpName ("battp", PU_CACHE, Cvt_pic_t, 1);
+ //Drawpic (x+16, y+15, 32>>2, 16, (byte *)&p->data);
+ VL_MemToScreenClipped ((byte *)&p->data, 32>>2, 16, x+16, y+15);
+
+ level = abs(gamestate.mapon + 1);
+ ltoa (level, str, 10);
+
+ if (level < 10) {
+ //Drawpic (x+49, y+16, 8>>2, 16, (byte *)&timenums[str[0]-'0']->data);
+ VL_MemToScreenClipped ((byte *)&timenums[str[0]-'0']->data, 8>>2, 16, x+49, y+16);
+ } else {
+ //Drawpic (x+49, y+16, 8>>2, 16, (byte *)&timenums[str[0]-'0']->data);
+ VL_MemToScreenClipped ((byte *)&timenums[str[0]-'0']->data, 8>>2, 16, x+49, y+16);
+ //Drawpic (x+57, y+16, 8>>2, 16, (byte *)&timenums[str[1]-'0']->data);
+ VL_MemToScreenClipped ((byte *)&timenums[str[1]-'0']->data, 8>>2, 16, x+57, y+16);
+ }
+ }
+}
+
+
+//******************************************************************************
+//
+// GM_MemToScreen ()
+//
+//******************************************************************************
+
+void GM_MemToScreen (byte *source, int width, int height, int x, int y)
+{
+ int dest;
+ byte *dest1, *dest2, *dest3, mask;
+ byte *screen1, *screen2, *screen3;
+ int plane;
+ int w;
+
+#ifdef DOS
+ dest = ylookup[y]+(x>>2);
+#else
+ dest = ylookup[y]+x;
+#endif
+ mask = 1 << (x&3);
+
+ dest1 = (byte *)(dest+page1start);
+ dest2 = (byte *)(dest+page2start);
+ dest3 = (byte *)(dest+page3start);
+
+ for (plane = 0; plane<4; plane++)
+ {
+ VGAMAPMASK (mask);
+
+ screen1 = dest1;
+ screen2 = dest2;
+ screen3 = dest3;
+ for (y = 0; y < height; y++, screen1 += linewidth,
+ screen2 += linewidth,
+ screen3 += linewidth, source+=width)
+ {
+#ifdef DOS
+ memcpy (screen1, source, width);
+ memcpy (screen2, source, width);
+ memcpy (screen3, source, width);
+#else
+ for (x = 0; x < width; x++) {
+ screen1[x*4+plane] = source[x];
+ screen2[x*4+plane] = source[x];
+ screen3[x*4+plane] = source[x];
+ }
+#endif
+ }
+
+#ifdef DOS
+ mask <<= 1;
+
+ if (mask == 16)
+ {
+ mask = 1;
+ dest1++;
+ dest2++;
+ dest3++;
+ }
+#endif
+ }
+}
+
+
+//==========================================================================
+
+/*
+==================
+=
+= ScreenShake
+=
+==================
+*/
+
+void ScreenShake (void)
+{
+ static int which = 0;
+// SetTextMode ( );
+ if (SHAKETICS != 0xFFFF)
+ {
+ SHAKETICS -= tics;
+ if (SHAKETICS >= 0xFF00) {
+ SHAKETICS = 0xFFFF; //bna safety val check
+ }
+
+ which = (RandomNumber ("ScreenShake",0) & 3);
+
+ switch (which)
+ {
+ case 0:
+ displayofs += 1;
+ MoveScreenUpLeft();//SetTextMode ( );
+ //DrawPlayScreen(true);//repaint ammo and life stat
+ break;
+
+ case 1:
+ displayofs -= 1;
+ MoveScreenUpRight();
+ //DrawPlayScreen(true);//repaint ammo and life stat
+ break;
+
+ case 2:
+ displayofs += 3*iGLOBAL_SCREENBWIDE;
+ MoveScreenDownLeft();
+ //DrawPlayScreen(true);//repaint ammo and life stat
+ break;
+
+ case 3:
+ displayofs -= 3*iGLOBAL_SCREENBWIDE;
+ MoveScreenDownRight();
+ //DrawPlayScreen(true);//repaint ammo and life stat
+ break;
+ }
+ //fix for play screen accidentally being drawn during transmitter explosion cinematic
+ if (playstate != ex_gameover)
+ DrawPlayScreen(true);//repaint ammo and life stat
+
+ }
+}
+
+//******************************************************************************
+//
+// DoBorderShifts ()
+//
+//******************************************************************************
+
+void DoBorderShifts (void)
+{
+ if (damagecount)
+ {
+ if (damagecount > 100)
+ damagecount = 100;
+
+ damagecount -= 6;
+
+ if (damagecount < 0)
+ damagecount = 0;
+
+ SetBorderColor (*(colormap+(((100-damagecount)>>2)<<8)+48));
+
+ borderset = true;
+ }
+ else if (borderset)
+ {
+ SetBorderColor (0);
+ borderset = false;
+ }
+}
+
+
+//******************************************************************************
+//
+// DrawHighScores ()
+//
+//******************************************************************************
+
+void DrawHighScores (void)
+{
+ char buffer[16];
+#if (SHAREWARE == 0)
+ char buffer1[5];
+#endif
+ int i,
+ w,
+ h;
+ HighScore *s;
+
+ for (i = 0, s = Scores; i < MaxScores; i++, s++)
+ {
+ PrintY = 25 + (16 * i);
+
+ //
+ // name
+ //
+ PrintX = 3*8;
+ DrawMenuBufPropString (PrintX, PrintY, s->name);
+
+ //
+ // level
+ //
+ ultoa (s->completed, buffer, 10);
+
+ PrintX = (17 * 8)-10;
+#if (SHAREWARE == 0)
+ itoa (s->episode, buffer1, 10);
+
+ DrawMenuBufPropString (PrintX, PrintY, buffer1);
+#else
+ DrawMenuBufPropString (PrintX, PrintY, "S");
+#endif
+
+ DrawMenuBufPropString (PrintX, PrintY, "-");
+
+#if (SHAREWARE == 0)
+ if (s->completed == 7)
+ DrawMenuBufPropString (PrintX, PrintY, "B");
+ else if (s->completed == 8)
+ DrawMenuBufPropString (PrintX, PrintY, "S");
+ else if (s->completed == 9)
+ DrawMenuBufPropString (PrintX, PrintY, "C");
+ else if (s->completed == 10)
+ DrawMenuBufPropString (PrintX, PrintY, "D");
+ else
+ DrawMenuBufPropString (PrintX, PrintY, buffer);
+#else
+ DrawMenuBufPropString (PrintX, PrintY, buffer);
+#endif
+
+ //
+ // score
+ //
+ ultoa(s->score,buffer,10);
+
+ VW_MeasurePropString (buffer, &w, &h);
+ PrintX = (33 * 8) - w;
+ DrawMenuBufPropString (PrintX, PrintY, buffer);
+ }
+}
+
+
+
+//******************************************************************************
+//
+// CheckHighScore ()
+//
+//******************************************************************************
+
+void CheckHighScore (long score, word other, boolean INMENU)
+{
+ word i,j;
+ int n;
+ HighScore myscore;
+ int level;
+
+ MenuFadeIn();
+ if (!INMENU)
+ SetupMenuBuf ();
+
+ strcpy (myscore.name,"");
+ myscore.score = score;
+
+ level = GetLevel (gamestate.episode, other-1);
+
+ myscore.episode = gamestate.episode;
+ myscore.completed = level;
+
+ CurrentFont = smallfont;
+
+ for (i = 0, n = -1; i < MaxScores; i++)
+ {
+ if ((myscore.score > Scores[i].score) ||
+ ((myscore.score == Scores[i].score) &&
+ (myscore.completed > Scores[i].completed)))
+ {
+ for (j = MaxScores; --j > i;)
+ Scores[j] = Scores[j - 1];
+ Scores[i] = myscore;
+ n = i;
+ break;
+ }
+ }
+
+ if (INMENU)
+ {
+ SetAlternateMenuBuf();
+ SetMenuTitle ("High Scores");
+ ClearMenuBuf();
+ DrawHighScores ();
+ if (n != -1)
+ DisplayInfo (6);
+ else
+ DisplayInfo (5);
+ FlipMenuBuf ();
+ }
+ else
+ {
+ ClearMenuBuf ();
+ SetMenuTitle ("High Scores");
+ DrawHighScores ();
+ if (n != -1)
+ DisplayInfo (6);
+ else
+ DisplayInfo (5);
+ RefreshMenuBuf (0);
+ }
+
+ if (n != -1)
+ {
+ PrintY = 25 + (16 * n);
+ PrintX = 3*8;
+ US_LineInput (PrintX, PrintY, Scores[n].name, NULL,
+ true, 10, 98, 0);
+ }
+ else
+ {
+ IN_ClearKeysDown ();
+ if ( INMENU )
+ {
+ while( !IN_CheckAck () )
+ {
+ RefreshMenuBuf (0);
+ }
+ }
+ else
+ {
+ for( i = 0; i <= 150; i += tics )
+ {
+ RefreshMenuBuf (0);
+ if (IN_CheckAck ())
+ {
+ break;
+ }
+ }
+ }
+ }
+
+ if (INMENU)
+ {
+ SD_Play (SD_ESCPRESSEDSND);
+ }
+ else
+ {
+ ShutdownMenuBuf ();
+ }
+}
+
+
+//===========================================================================
+
+//#define HEADERX 140
+//#define BONERNAMEX 170
+#define HEADERX 152
+#define BONERNAMEX 166
+
+
+/*
+==================
+=
+= DrawEOLHeader ()
+=
+==================
+*/
+void DrawEOLHeader
+(
+ int playstate
+)
+
+{
+ int health;
+ char tempstr[ 15 ];
+ char *string;
+ int level;
+ int w;
+ int h;
+
+ VWB_TBar( 30, 5, 250, 75 );
+
+ switch( playstate )
+ {
+ case ex_skiplevel :
+ if ( ( gamestate.violence >= vl_high ) &&
+ ( gamestate.difficulty >= gd_hard ) )
+ {
+ string = "LEVEL WUSSED OUT ON!";
+ }
+ else
+ {
+ string = "LEVEL SKIPPED.";
+ }
+ break;
+
+ case ex_secretdone :
+ string = "SECRET LEVEL COMPLETED!";
+ break;
+
+ case ex_secretlevel :
+ string = "SECRET EXIT TAKEN!";
+ break;
+
+ case ex_gameover :
+ string = "GAME COMPLETED!";
+ break;
+
+ case ex_bossdied :
+ string = "BOSS DEFEATED!";
+ break;
+
+ default :
+ string = "LEVEL COMPLETED!";
+ break;
+ }
+
+ VW_MeasurePropString( string, &w, &h );
+
+ px = ( 320 - w ) / 2;
+ py = 10;
+ VWB_DrawPropString( string );
+
+ // draw episode number
+ string = "EPISODE";
+ VW_MeasurePropString( string, &w, &h );
+ px = HEADERX - w;
+ py = 25;
+ VWB_DrawPropString( string );
+
+ itoa( gamestate.episode, tempstr, 10 );
+ px = BONERNAMEX;
+ VWB_DrawPropString( tempstr );
+
+ // draw area number
+ level = GetLevel( gamestate.episode, gamestate.mapon );
+ itoa( level, tempstr, 10 );
+
+ py = 35;
+
+ if ( playstate == ex_secretdone )
+ {
+ string = "SECRET AREA";
+ }
+ else if ( playstate == ex_bossdied )
+ {
+ string = "BOSS AREA";
+ }
+ else if ( gamestate.mapon == 32 )
+ {
+ string = "CHASE AREA";
+ }
+ else
+ {
+ string = "AREA";
+ }
+
+ VW_MeasurePropString( string, &w, &h);
+ px = HEADERX - w;
+ VWB_DrawPropString( string );
+
+ if ( gamestate.mapon != 33 )
+ {
+ px = BONERNAMEX;
+ VWB_DrawPropString( tempstr );
+ }
+
+ string = "SCORE";
+ VW_MeasurePropString( string, &w, &h);
+ px = HEADERX - w;
+ py = 45;
+ VWB_DrawPropString( string );
+
+ px = BONERNAMEX;
+ itoa( gamestate.score, tempstr, 10 );
+ VWB_DrawPropString( tempstr );
+
+ string = "HEALTH";
+ VW_MeasurePropString( string, &w, &h );
+ px = HEADERX - w;
+ py = 55;
+ VWB_DrawPropString( string );
+
+ px = BONERNAMEX;
+ health = ( ( locplayerstate->health * 100 ) /
+ MaxHitpointsForCharacter( locplayerstate ) );
+
+ itoa( health, tempstr, 10 );
+ VWB_DrawPropString( tempstr );
+ VWB_DrawPropString( "%" );
+
+ //
+ // Secret count
+ //
+
+ {
+ char str1[10];
+ char str2[10];
+
+ itoa(gamestate.secretcount,&(str1[0]),10);
+ strcat(str1," / ");
+ itoa(gamestate.secrettotal,&(str2[0]),10);
+ strcat(str1,str2);
+ string = "SECRET WALLS";
+ VW_MeasurePropString( string, &w, &h );
+ px = HEADERX - w;
+ py = 65;
+ VWB_DrawPropString( string );
+
+ px = BONERNAMEX;
+ VWB_DrawPropString( str1 );
+ }
+
+ VW_UpdateScreen ();
+}
+
+boolean EndBonusFirst;
+boolean EndBonusSkip;
+int EndBonusNumBonuses;
+int EndBonusVoice;
+int EndBonusStartY;
+
+void DrawEndBonus
+(
+ char *string,
+ char *bonusstring,
+ int type
+)
+
+{
+ int w;
+ int h;
+ int health;
+ char tempstr[ 15 ];
+
+ if ( EndBonusFirst )
+ {
+ VWB_TBar( 5, EndBonusStartY - 2, 310, 4 );
+ EndBonusFirst = false;
+ }
+
+ VWB_TBar( 5, EndBonusStartY + 2, 310, 10 );
+ VW_MeasurePropString( string, &w, &h );
+
+ py = EndBonusStartY;
+ if ( bonusstring == NULL )
+ {
+ px = ( 320 - w ) / 2;
+ VWB_DrawPropString( string );
+ }
+ else
+ {
+ px = BONERNAMEX - w;
+ VWB_DrawPropString( string );
+
+ EndBonusNumBonuses++;
+ VW_MeasurePropString( bonusstring, &w, &h );
+ px = 310 - w;
+ py = EndBonusStartY;
+ VWB_DrawPropString( bonusstring );
+ }
+
+ // Update Score
+ py = 45;
+ px = BONERNAMEX;
+ V_ReDrawBkgnd( px, py, 107, 11, false );
+ VWB_TBar( px, py, 107, 11 );
+ itoa( gamestate.score, tempstr, 10 );
+ VWB_DrawPropString( tempstr );
+
+ // Update Health
+ py = 55;
+ px = BONERNAMEX;
+ V_ReDrawBkgnd( px, py, 107, 11, false );
+ VWB_TBar( px, py, 107, 11 );
+ health = ( ( locplayerstate->health * 100 ) /
+ MaxHitpointsForCharacter( locplayerstate ) );
+ itoa( health, tempstr, 10 );
+ VWB_DrawPropString( tempstr );
+ VWB_DrawPropString( "%" );
+
+ switch( type )
+ {
+ case 0 :
+ EndBonusVoice = SD_Play( SD_ENDBONUS1SND );
+ break;
+
+ case 1 :
+ EndBonusVoice = SD_Play( SD_NOBONUSSND );
+ break;
+
+ case 2 :
+ VL_FillPalette(255,255,255);
+ //bna--VW_UpdateScreen();
+ VL_FadeIn(0,255,origpal,10);
+ EndBonusVoice = SD_Play( SD_LIGHTNINGSND );
+ break;
+ }
+
+ EndBonusStartY += 10;
+
+ //bna--VW_UpdateScreen();
+ while( SD_SoundActive( EndBonusVoice ) && !EndBonusSkip )
+ {
+ if ( IN_CheckAck() )
+ {
+ EndBonusSkip = true;
+ }
+ }
+}
+
+
+
+/*
+==================
+=
+= LevelCompleted
+=
+= Exit with the screen faded out
+=
+==================
+*/
+
+extern int OLDLMWEAPON;
+extern int OLDLWEAPON;
+
+void LevelCompleted
+(
+ exit_t playstate
+)
+
+{
+ objtype *obj;
+ boolean dobonus;
+ int i;
+ int kr;
+ int sr;
+ int tr;
+ int missileratio;
+ int superratio;
+ int healthratio;
+ int democraticratio;
+ int plantratio;
+ int cnt;
+
+ pic_t *tmpPic;
+// byte *picbuf;
+
+ EndBonusNumBonuses = 0;
+ EndBonusFirst = true;
+ EndBonusSkip = false;
+ EndBonusStartY = 90;
+
+ EnableScreenStretch();
+ tmpPic = ( pic_t * )W_CacheLumpName( "mmbk", PU_CACHE, Cvt_pic_t, 1 );
+ VWB_DrawPic( 0, 0, tmpPic );
+ VW_UpdateScreen();
+// DisableScreenStretch();
+
+ IN_StartAck();
+ EndBonusVoice = 0;
+
+
+ if ( playstate != ex_bossdied )
+ {
+ EndBonusVoice = SD_Play( SD_LEVELDONESND );
+ VL_FillPalette( 255, 255, 255 );
+ VL_FadeIn( 0, 255, origpal, 10 );
+ if ( player->flags & FL_DOGMODE )
+ {
+ MU_StartSong( song_dogend );
+ }
+ else
+ {
+ MU_StartSong( song_endlevel );
+ }
+ }
+
+ BkPic = ( pic_t * )W_CacheLumpName( "mmbk", PU_CACHE, Cvt_pic_t, 1 );
+ VWB_DrawPic( 0, 0, BkPic );
+
+ CheckHolidays();
+ CurrentFont = smallfont;
+
+ // Kill powerups
+ if ( player->flags & FL_ELASTO )
+ {
+ player->flags &= ~FL_NOFRICTION;
+ }
+
+ player->flags &= ~( FL_FLEET | FL_SHROOMS | FL_ELASTO | FL_GODMODE |
+ FL_DOGMODE | FL_BPV | FL_AV | FL_GASMASK );
+
+ // Turn off quickload for next level
+ pickquick = false;
+
+ //
+ // FIGURE RATIOS OUT BEFOREHAND
+ //
+ kr = 0;
+ tr = 0;
+ tr = 0;
+ superratio = 0;
+ missileratio = 0;
+ healthratio = 0;
+ democraticratio = 0;
+ plantratio = 0;
+
+ if ( gamestate.killtotal )
+ {
+ kr = ( int )( ( ( int )gamestate.killcount ) * 100 ) /
+ ( ( int )gamestate.killtotal );
+ }
+
+ if ( gamestate.secrettotal )
+ {
+ sr = ( int )( ( ( int )gamestate.secretcount ) * 100 ) /
+ ( ( int )gamestate.secrettotal );
+ }
+
+ if ( gamestate.treasuretotal )
+ {
+ tr = ( int )( ( ( int )gamestate.treasurecount ) * 100 ) /
+ ( ( int )gamestate.treasuretotal );
+ }
+
+ if ( gamestate.supertotal )
+ {
+ superratio = ( int )( ( ( int )gamestate.supercount ) * 100 ) /
+ ( ( int )gamestate.supertotal );
+ }
+
+ if ( gamestate.missiletotal )
+ {
+ missileratio = ( int )( ( ( int )gamestate.missilecount ) * 100 ) /
+ ( ( int )gamestate.missiletotal );
+ }
+
+ if ( gamestate.healthtotal )
+ {
+ healthratio = ( int )( ( ( int )gamestate.healthcount ) * 100 ) /
+ ( ( int )gamestate.healthtotal );
+ }
+
+ if ( gamestate.democratictotal )
+ {
+ democraticratio = ( int )( ( ( int )gamestate.democraticcount ) *
+ 100 ) / ( ( int )gamestate.democratictotal );
+ }
+
+ if ( gamestate.planttotal )
+ {
+ plantratio = ( int )( ( ( int )gamestate.plantcount ) * 100 ) /
+ ( ( int )gamestate.planttotal );
+ }
+
+ DrawEOLHeader( playstate );
+ /*
+ //bna section store picture because its written on again
+ // store screen first
+ picbuf = (byte *)SafeMalloc (64000);
+ memcpy(picbuf ,bufferofs ,64000);
+
+ EnableScreenStretch();
+ VW_UpdateScreen();//tmpPICbuf is destroyed here
+ DisableScreenStretch();
+ //copy it back
+
+ memcpy(bufferofs ,picbuf , 64000);
+ //bna section end
+ */
+
+ EndBonusSkip = true;
+
+ while( SD_SoundActive( EndBonusVoice ) && !EndBonusSkip )
+ {
+
+ //bna--VW_UpdateScreen();
+
+ if ( IN_CheckAck() )
+ {
+ EndBonusSkip = true;
+ }
+ }
+// tmpPic = ( pic_t * )W_CacheLumpName( "mmbk", PU_CACHE, Cvt_pic_t, 1 );
+// VWB_DrawPic( 0, 0, tmpPic );
+
+ if ( GetNextMap(player->tilex,player->tiley) == -1)
+ {
+ if ( gamestate.dipballs == 3 )
+ {
+ gamestate.score += 100000;
+ DrawEndBonus( "DIP BONUS", "100000 POINTS", 0 );
+ EndBonusStartY += 10;
+ }
+
+ if ( locplayerstate->lives > 0 )
+ {
+ char str[20];
+ char str2[60];
+
+ DrawEndBonus( "EXTRA LIVES BONUS", "\0", 0 );
+ itoa(locplayerstate->lives,str,10);
+ strcpy(str2,str);
+ strcat(str2," EXTRA LIVES =");
+ DrawEndBonus( "\0", str2, 0 );
+ itoa(locplayerstate->lives,str,10);
+ strcpy(str2,str);
+ strcat(str2," X 10000 = ");
+ itoa(locplayerstate->lives*10000,str,10);
+ strcat(str2,str);
+ strcat(str2," POINTS");
+ gamestate.score += 10000*locplayerstate->lives;
+ DrawEndBonus( "\0", str2, 0 );
+ }
+ }
+ else
+ {
+ //
+ // Check for SKIN OF YO TEETH
+ //
+ if ( locplayerstate->health <= 10 )
+ {
+ locplayerstate->health = MaxHitpointsForCharacter( locplayerstate );
+ DrawEndBonus( "SKIN OF YOUR TEETH", "100% HEALTH", 0 );
+ }
+
+ // BULL IN CHINA SHOP BONUS
+ if ( tr == 100 )
+ {
+ gamestate.score += 10000;
+ DrawEndBonus( "BULL IN CHINA SHOP", "10000 POINTS", 0 );
+ }
+
+ // SUPERCHARE BONUS
+ if ( superratio == 100 )
+ {
+ gamestate.score += 10000;
+ DrawEndBonus( "SUPERCHARGE BONUS", "10000 POINTS", 0 );
+ }
+
+ // BLEEDER BONUS
+ if ( healthratio == 100 )
+ {
+ gamestate.score += 10000;
+ DrawEndBonus( "BLEEDER BONUS", "10000 POINTS", 0 );
+ }
+
+ // ADRENALINE BONUS
+ if ( kr == 100 )
+ {
+ gamestate.score += 10000;
+ DrawEndBonus( "ADRENALINE BONUS", "10000 POINTS", 0 );
+ }
+
+ // CURIOSITY BONUS
+ dobonus = true;
+
+ //
+ // Check switches
+ cnt = lastswitch - &switches[ 0 ];
+ if ( cnt != 0 )
+ {
+ for ( i = 0; i < cnt; i++ )
+ {
+ if ( ( switches[ i ].flags & FL_S_FLIPPED ) == 0 )
+ {
+ dobonus = false;
+ break;
+ }
+ }
+ }
+
+ //
+ // Check pillars
+ for ( obj = FIRSTACTOR; obj != NULL; obj = obj->next )
+ {
+ if ( ( obj->obclass == pillarobj ) &&
+ ( ( obj->flags & FL_FLIPPED ) == 0 ) )
+ {
+ dobonus = false;
+ }
+ }
+
+ if ( ( gamestate.secrettotal ) && ( sr != 100 ) )
+ {
+ dobonus = false;
+ }
+
+ if ( dobonus )
+ {
+ gamestate.score += 10000;
+ DrawEndBonus( "CURIOSITY BONUS", "10000 POINTS", 0 );
+ }
+
+ // GROUND ZERO BONUS
+ if ( gamestate.DOGROUNDZEROBONUS )
+ {
+ gamestate.score += 10000;
+ DrawEndBonus( "GROUND ZERO BONUS", "10000 POINTS", 0 );
+ }
+
+ // REPUBLICAN BONUS 1
+ if ( missileratio == 100 )
+ {
+ gamestate.score += 5000;
+ DrawEndBonus( "REPUBLICAN BONUS 1", " 5000 POINTS", 0 );
+ }
+
+ // REPUBLICAN BONUS 2
+ if (plantratio == 100)
+ {
+ gamestate.score += 5000;
+ DrawEndBonus( "REPUBLICAN BONUS 2", " 5000 POINTS", 0 );
+ }
+
+ // DEMOCRATIC BONUS 1
+ if ( gamestate.DODEMOCRATICBONUS1 )
+ {
+ gamestate.score += 5000;
+ DrawEndBonus( "DEMOCRATIC BONUS 1", " 5000 POINTS", 0 );
+ }
+
+ // DEMOCRATIC BONUS 2
+ if (democraticratio == 100)
+ {
+ gamestate.score += 5000;
+ DrawEndBonus( "DEMOCRATIC BONUS 2", " 5000 POINTS", 0 );
+ }
+ }
+
+ if ( EndBonusNumBonuses == 0 )
+ {
+ DrawEndBonus( "NO BONUS!", NULL, 1 );
+ }
+
+ if ( ( EndBonusNumBonuses != 0 ) || ( playstate == ex_gameover ) )
+ {
+ SD_Play( PlayerSnds[ locplayerstate->player ] );
+
+ // DO BONUS BONUS
+ if ( EndBonusNumBonuses == NUMBONUSES )
+ {
+ IN_StartAck();
+ while( !IN_CheckAck() )
+ {
+ ;
+ }
+
+ BkPic = ( pic_t * )W_CacheLumpName( "mmbk", PU_CACHE, Cvt_pic_t, 1 );
+ VWB_DrawPic( 0, 0, BkPic );
+
+ gamestate.score += BONUSBONUS;
+ DrawEOLHeader( playstate );
+ EndBonusFirst = true;
+ EndBonusStartY = 110;
+ EndBonusSkip = true;
+ DrawEndBonus( "BONUS BONUS! 1,000,000 POINTS!", NULL, 2 );
+ }
+ else if ( ( kr == 100 ) && ( dobonus ) )
+ {
+ IN_StartAck();
+ while( !IN_CheckAck() )
+ {
+ ;
+ }
+
+ BkPic = ( pic_t * )W_CacheLumpName( "mmbk", PU_CACHE, Cvt_pic_t, 1 );
+ VWB_DrawPic( 0, 0, BkPic );
+
+ DrawEOLHeader( playstate );
+ EndBonusFirst = true;
+ EndBonusStartY = 110;
+ DrawEndBonus( "You have done well.", NULL, 3 );
+
+#if (SHAREWARE==1)
+ EndBonusVoice = SD_Play( SD_RICOCHET3SND );
+#else
+ EndBonusVoice = SD_Play( SD_PERCENT100SND );
+#endif
+
+ EndBonusSkip = false;
+ DrawEndBonus( "This level is toast.", NULL, 3 );
+
+ }
+ }
+
+
+
+ //bna section
+// EnableScreenStretch();//bna++
+ VW_UpdateScreen();//bna++
+// DisableScreenStretch();//bna++
+ //bna section end
+
+
+ IN_StartAck();
+ while( !IN_CheckAck() )
+ {
+ ;
+ }
+
+ EndLevelStuff = false;
+ CurrentFont = smallfont;
+}
+
+
+void DrawTallyHeader
+(
+ int which
+)
+
+{
+ pic_t *Name;
+ pic_t *KillCount;
+ pic_t *TimesYouKilledPerson;
+ pic_t *TimesPersonKilledYou;
+ pic_t *Suicides;
+ pic_t *Score;
+ pic_t *Blank;
+ pic_t *TopBar;
+
+ Name = ( pic_t * )W_CacheLumpName( "t_name", PU_CACHE, Cvt_pic_t, 1 );
+ Blank = ( pic_t * )W_CacheLumpName( "t_blnk", PU_CACHE, Cvt_pic_t, 1 );
+ KillCount = ( pic_t * )W_CacheLumpName( "t_kcount", PU_CACHE, Cvt_pic_t, 1 );
+ TimesYouKilledPerson = ( pic_t * )W_CacheLumpName( "t_kilper", PU_CACHE, Cvt_pic_t, 1 );
+ TimesPersonKilledYou = ( pic_t * )W_CacheLumpName( "t_perkil", PU_CACHE, Cvt_pic_t, 1 );
+ Suicides = ( pic_t * )W_CacheLumpName( "t_suicid", PU_CACHE, Cvt_pic_t, 1 );
+ Score = ( pic_t * )W_CacheLumpName( "t_score", PU_CACHE, Cvt_pic_t, 1 );
+ TopBar = ( pic_t * )W_CacheLumpName( "t_bar", PU_CACHE, Cvt_pic_t, 1 );
+
+ IFont = ( cfont_t * )W_CacheLumpName( "sifont", PU_CACHE, Cvt_cfont_t, 1 );
+
+ switch( which )
+ {
+ case 0 :
+ VWB_DrawPic ( 8, 8, TopBar );
+ DrawIntensityString( 12, 11, "FINAL SCORE", 20 );
+ VWB_DrawPic ( 8, 24, Name );
+ VWB_DrawPic ( 136, 24, KillCount );
+ VWB_DrawPic ( 184, 24, Suicides );
+ VWB_DrawPic ( 272, 24, Score );
+ break;
+
+ case 1 :
+ VWB_DrawPic ( 8, 8, TopBar );
+ DrawIntensityString( 12, 11, "FINAL SCORE", 20 );
+ VWB_DrawPic ( 8, 24, Name );
+ VWB_DrawPic ( 136, 24, Blank );
+ VWB_DrawPic ( 272, 24, Score );
+ break;
+
+ case 2 :
+ VWB_DrawPic ( 8, 8, TopBar );
+ DrawIntensityString( 12, 11, "YOUR KILLS", 20 );
+ VWB_DrawPic ( 8, 24, Name );
+ VWB_DrawPic ( 136, 24, KillCount );
+ VWB_DrawPic ( 184, 24, TimesYouKilledPerson );
+ break;
+
+ case 3 :
+ VWB_DrawPic ( 8, 8, TopBar );
+ DrawIntensityString( 12, 11, "YOUR DEATHS", 20 );
+ VWB_DrawPic ( 8, 24, Name );
+ VWB_DrawPic ( 136, 24, TimesPersonKilledYou );
+ break;
+//bna added
+ case 4 :
+ VWB_DrawPic ( 198+48, 8, Blank );
+ VWB_DrawPic ( 8, 8, TopBar );
+ DrawIntensityString( 12, 11, "FINAL SCORE", 20 );
+ VWB_DrawPic ( 8, 24, TopBar );//used to blank
+ VWB_DrawPic ( 8, 24, Name );
+ VWB_DrawPic ( 136, 24, KillCount);
+ VWB_DrawPic ( 198, 24, TimesPersonKilledYou);
+ VWB_DrawPic ( 198+48, 24, Blank );
+ VWB_DrawPic ( 272, 24, Score );
+ break;
+//bna added end
+ }
+
+ DrawTimeXY( TALLYTIME_X, TALLYTIME_Y, gamestate.TimeCount / VBLCOUNTER,
+ true );
+}
+
+
+#define BT_RANK_X 23
+#define BT_PLAYER_X 30
+#define BT_KILLS_X ( 139 + ( ( 40 + 20 ) / 2 ) )
+#define BT_DEATHS_X ( 193 + ( ( 56 + 20 ) / 2 ) )
+//#define BT_SCORE_X ( 263 + ( ( 46 + 20 ) / 2 ) )
+#define BT_SCORE_X ( 273 + ( ( 46 + 20 ) / 2 ) )
+
+
+void ShowKills( int localplayer )
+{
+ int w;
+ int h;
+ int i;
+ int j;
+ int temp;
+ int rank;
+ int player;
+ int killer;
+ int victim;
+ int color;
+ char tempstr[15];
+ int KillCount[ MAXPLAYERS ];
+ int Order[ MAXPLAYERS ];
+ int NumPlayers;
+
+ // show at the most 11 players
+ NumPlayers = min( numplayers, 11 );
+
+ // Count kills
+ for( killer = 0; killer < NumPlayers; killer++ )
+ {
+ Order[ killer ] = killer;
+ KillCount[ killer ] = 0;
+ for( victim = 0; victim < NumPlayers; victim++ )
+ {
+ if ( BATTLE_Team[ victim ] != BATTLE_Team[ killer ] )
+ {
+ KillCount[ killer ] += WhoKilledWho[ killer ][ victim ];
+ }
+ }
+ }
+
+ for( i = 0; i < NumPlayers - 1; i++ )
+ {
+ for( j = i + 1; j < NumPlayers; j++ )
+ {
+ if ( KillCount[ Order[ i ] ] < KillCount[ Order[ j ] ] )
+ {
+ temp = Order[ i ];
+ Order[ i ] = Order[ j ];
+ Order[ j ] = temp;
+ }
+ }
+ }
+
+ DrawTallyHeader( 2 );
+
+ IFont = (cfont_t * )W_CacheLumpNum (W_GetNumForName ("sifont"), PU_CACHE, Cvt_cfont_t, 1);
+ CurrentFont = smallfont;
+ py = 43;
+
+ for( rank = 0; rank < NumPlayers; rank++ )
+ {
+ player = Order[ rank ];
+
+ color = 21;
+
+ // Highlight the your score
+ if ( player == localplayer )
+ {
+ // Change to Intensity
+ color = 241;
+ }
+
+ // Draw rank if not tied with previous rank
+ if ( ( rank == 0 ) || ( KillCount[ player ] !=
+ KillCount[ Order[ rank - 1 ] ] ) )
+ {
+ itoa( rank + 1, tempstr, 10 );
+ }
+ else
+ {
+ strcpy( tempstr, "Tie" );
+ }
+
+ VW_MeasureIntensityPropString ( tempstr, &w, &h);
+ DrawIntensityString( BT_RANK_X - w, py, tempstr, color );
+
+ // Draw name
+ DrawIntensityString( BT_PLAYER_X, py, PLAYERSTATE[ player ].codename, color );
+
+ // Draw kills
+ itoa( KillCount[ player ], tempstr, 10 );
+ VW_MeasureIntensityPropString ( tempstr, &w, &h);
+ DrawIntensityString( BT_KILLS_X - w, py, tempstr, color );
+
+ // Draw times you killed that person
+ if ( player != localplayer )
+ {
+ itoa( WhoKilledWho[ localplayer ][ player ], tempstr, 10 );
+ }
+ else
+ {
+ strcpy( tempstr, "-" );
+ }
+
+ VW_MeasureIntensityPropString ( tempstr, &w, &h);
+ DrawIntensityString( BT_DEATHS_X - w, py, tempstr, color );
+
+ if ( gamestate.teamplay )
+ {
+ DrawIntensityString( BT_DEATHS_X + 16, py,
+ colorname[ PLAYERSTATE[ player ].uniformcolor ], color );
+ }
+
+ py += h;
+ }
+}
+
+
+void ShowDeaths( int localplayer )
+{
+ int w;
+ int h;
+ int i;
+ int j;
+ int temp;
+ int rank;
+ int player;
+ int killer;
+ int victim;
+ int color;
+ char tempstr[15];
+ int DeathCount[ MAXPLAYERS ];
+ int Order[ MAXPLAYERS ];
+ int NumPlayers;
+
+ // show at the most 11 players
+ NumPlayers = min( numplayers, 11 );
+
+ // Count Deaths
+ for( victim = 0; victim < NumPlayers; victim++ )
+ {
+ Order[ victim ] = victim;
+ DeathCount[ victim ] = 0;
+ for( killer = 0; killer < NumPlayers; killer++ )
+ {
+ DeathCount[ victim ] += WhoKilledWho[ killer ][ victim ];
+ }
+ }
+
+ for( i = 0; i < NumPlayers - 1; i++ )
+ {
+ for( j = i + 1; j < NumPlayers; j++ )
+ {
+ if ( DeathCount[ Order[ i ] ] < DeathCount[ Order[ j ] ] )
+ {
+ temp = Order[ i ];
+ Order[ i ] = Order[ j ];
+ Order[ j ] = temp;
+ }
+ }
+ }
+
+ DrawTallyHeader( 3 );
+
+ IFont = (cfont_t * )W_CacheLumpNum (W_GetNumForName ("sifont"), PU_CACHE, Cvt_cfont_t, 1);
+ CurrentFont = smallfont;
+ py = 43;
+
+ for( rank = 0; rank < NumPlayers; rank++ )
+ {
+ player = Order[ rank ];
+ color = 21;
+
+ // Highlight the your score
+ if ( player == localplayer )
+ {
+ // Change to Intensity
+ color = 241;
+ }
+
+ // Draw rank if not tied with previous rank
+ if ( ( rank == 0 ) || ( DeathCount[ player ] !=
+ DeathCount[ Order[ rank - 1 ] ] ) )
+ {
+ itoa( rank + 1, tempstr, 10 );
+ }
+ else
+ {
+ strcpy( tempstr, "Tie" );
+ }
+
+ VW_MeasureIntensityPropString ( tempstr, &w, &h);
+ DrawIntensityString( BT_RANK_X - w, py, tempstr, color );
+
+ // Draw name
+ DrawIntensityString( BT_PLAYER_X, py, PLAYERSTATE[ player ].codename, color );
+
+ // Draw deaths
+ itoa( DeathCount[ player ], tempstr, 10 );
+ VW_MeasureIntensityPropString ( tempstr, &w, &h);
+ DrawIntensityString( BT_KILLS_X - w, py, tempstr, color );
+
+ // Draw times you were killed by that person
+ itoa( WhoKilledWho[ player ][ localplayer ], tempstr, 10 );
+ VW_MeasureIntensityPropString ( tempstr, &w, &h);
+ DrawIntensityString( BT_DEATHS_X - w, py, tempstr, color );
+
+ if ( gamestate.teamplay )
+ {
+ DrawIntensityString( BT_DEATHS_X + 16, py,
+ colorname[ PLAYERSTATE[ player ].uniformcolor ], color );
+ }
+
+ py += h;
+ }
+}
+
+
+void ShowEndScore( int localplayer )
+{
+ int w;
+ int h;
+ int rank;
+ int leader;
+ int team;
+ int color;
+ int killer;
+ int victim;
+ int killcount;
+ int suicidecount;
+ char tempstr[15];
+ boolean dofullstats;
+ int NumPlayers;
+
+ // show at the most 11 players
+ NumPlayers = min( numplayers, 11 );
+
+ dofullstats = false;
+ switch( gamestate.battlemode )
+ {
+ case battle_Normal :
+ case battle_ScoreMore :
+ case battle_Hunter :
+ dofullstats = true;
+ DrawTallyHeader( 0 );
+ break;
+
+ case battle_Collector :
+ case battle_Scavenger :
+ case battle_Tag :
+ case battle_Eluder :
+ case battle_Deluder :
+ case battle_CaptureTheTriad :
+ dofullstats = false;
+ DrawTallyHeader( 1 );
+ break;
+ }
+
+ IFont = (cfont_t * )W_CacheLumpNum (W_GetNumForName ("sifont"), PU_CACHE, Cvt_cfont_t, 1);
+ CurrentFont = smallfont;
+ py = 43;
+
+ for( rank = 0; rank < BATTLE_NumberOfTeams; rank++ )
+ {
+ team = BATTLE_PlayerOrder[ rank ];
+
+ color = 21;
+ if ( team == BATTLE_Team[ localplayer ] )
+ {
+ // Change to Intensity
+ color = 241;
+ }
+
+ // Draw rank if not tied with previous rank
+ if ( ( rank == 0 ) || ( BATTLE_Points[ team ] !=
+ BATTLE_Points[ BATTLE_PlayerOrder[ rank - 1 ] ] ) )
+ {
+ itoa( rank + 1, tempstr, 10 );
+ }
+ else
+ {
+ strcpy( tempstr, "Tie" );
+ }
+
+ VW_MeasureIntensityPropString ( tempstr, &w, &h);
+ DrawIntensityString( BT_RANK_X - w, py, tempstr, color );
+
+ // Draw name of team leader
+ leader = BATTLE_TeamLeader[ team ];
+ if ( gamestate.teamplay )
+ {
+ DrawIntensityString( BT_PLAYER_X, py,
+ colorname[ PLAYERSTATE[ leader ].uniformcolor ], color );
+ }
+ else
+ {
+ DrawIntensityString( BT_PLAYER_X, py,
+ PLAYERSTATE[ leader ].codename, color );
+ }
+
+ if ( dofullstats )
+ {
+ // Count how many kills each person on the team got
+ killcount = 0;
+ suicidecount = 0;
+ for( killer = 0; killer < NumPlayers; killer++ )
+ {
+ if ( BATTLE_Team[ killer ] == team )
+ {
+ for( victim = 0; victim < NumPlayers; victim++ )
+ {
+ if ( BATTLE_Team[ victim ] != team )
+ {
+ killcount += WhoKilledWho[ killer ][ victim ];
+ }
+ else
+ {
+ suicidecount += WhoKilledWho[ killer ][ victim ];
+ }
+ }
+ }
+ }
+
+ // Draw kills
+ itoa( killcount, tempstr, 10 );
+ VW_MeasureIntensityPropString ( tempstr, &w, &h);
+ DrawIntensityString( BT_KILLS_X - w, py, tempstr, color );
+
+ // Draw suicides
+ itoa( suicidecount, tempstr, 10 );
+ VW_MeasureIntensityPropString ( tempstr, &w, &h);
+ DrawIntensityString( BT_DEATHS_X - w, py, tempstr, color );
+ }
+
+ // Draw Score
+ itoa( BATTLE_Points[ team ], tempstr, 10 );
+ VW_MeasureIntensityPropString ( tempstr, &w, &h);
+ DrawIntensityString( BT_SCORE_X - w, py, tempstr, color );
+
+ py += h;
+ }
+}
+
+
+void BattleLevelCompleted ( int localplayer )
+{
+ ControlInfo ci;
+ int w;
+ int h;
+ int key;
+ int Screen;
+ int LastScreen;
+ int Player;
+ char text[80];
+
+ EnableScreenStretch();
+
+ IN_ClearKeysDown ();
+
+ Player = localplayer;
+ Screen = 1;
+ LastScreen = 0;
+ key = -1;
+ while( 1 )
+ {
+ if ( Screen != LastScreen )
+ {
+ VL_DrawPostPic (W_GetNumForName("trilogo"));
+
+ switch( Screen )
+ {
+ case 1 :
+ ShowEndScore( Player );
+ break;
+
+ case 2 :
+ ShowKills( Player );
+ break;
+
+ case 3 :
+ ShowDeaths( Player );
+ break;
+ }
+
+ CurrentFont = tinyfont;
+
+ sprintf ( text, "Page %d of 3. Use arrows to switch stats. "
+ "Press Esc to quit.", Screen );
+ VW_MeasurePropString ( text, &w, &h);
+ py = 192;
+ px = ( 320 - w ) / 2;
+ VWB_DrawPropString ( text );
+ VW_UpdateScreen ();
+
+ do
+ {
+ ReadAnyControl (&ci);
+ }
+ while( ci.dir == (dirtype)key );
+ }
+
+ LastScreen = Screen;
+ ReadAnyControl ( &ci );
+ key = ci.dir;
+ if ( ( Screen > 1 ) && ( key == dir_West ) )
+ {
+ Screen--;
+ MN_PlayMenuSnd (SD_MOVECURSORSND);
+ }
+ else if ( ( Screen < 3 ) && ( key == dir_East ) )
+ {
+ Screen++;
+ MN_PlayMenuSnd (SD_MOVECURSORSND);
+ }
+ // Allow us to select which player to view
+ if ( Keyboard[ sc_RShift ] && ( key == dir_South ) )
+ {
+ Player++;
+ if ( Player >= numplayers )
+ {
+ Player = 0;
+ }
+ LastScreen = 0;
+ MN_PlayMenuSnd (SD_SELECTSND);
+ }
+
+ if ( Keyboard[ sc_RShift ] && ( key == dir_North ) )
+ {
+ Player--;
+ if ( Player < 0 )
+ {
+ Player = numplayers - 1;
+ }
+ LastScreen = 0;
+ MN_PlayMenuSnd (SD_SELECTSND);
+ }
+
+ if ( Keyboard[sc_Escape] )
+ {
+ break;
+ }
+ }
+
+ while ( Keyboard[sc_Escape] )
+ {
+ IN_UpdateKeyboard ();
+ }
+
+ MN_PlayMenuSnd (SD_ESCPRESSEDSND);
+
+ CurrentFont = smallfont;
+}
+
+//==========================================================================
+
+/*
+==================
+=
+= FindAngleToWindow
+=
+==================
+*/
+int FindAngleToWindow ( int tx, int ty )
+{
+ if (!IsWindow(tx+1,ty))
+ return ANG180;
+ else if (!IsWindow(tx-1,ty))
+ return 0;
+ else if (!IsWindow(tx,ty+1))
+ return ANG90;
+ else
+ return ANG270;
+}
+
+#define STARTRADIUS (0xa000)
+#define STOPRADIUS (0x14000)
+#define DEATHRADIUS (STOPRADIUS-STARTRADIUS)
+#define ROTRATE (5)
+#define TOTALDEATHROT (FINEANGLES<<1)
+#define RADIUSINC ((DEATHRADIUS)/(TOTALDEATHROT))
+
+/*
+==================
+=
+= ZoomDeathOkay
+=
+==================
+*/
+boolean ZoomDeathOkay ( void )
+{
+ int x,y;
+ int radius;
+
+ if (
+ !(
+ (player->state==&s_ashwait) ||
+ ((player->flags & FL_HBM) && (gamestate.violence >= vl_high))
+ )
+ )
+ return false;
+
+ radius=STOPRADIUS;
+ x=player->x;
+ y=player->y;
+ while (radius>0)
+ {
+ if (tilemap[x>>16][(y+radius)>>16])
+ return false;
+ if (tilemap[x>>16][(y-radius)>>16])
+ return false;
+ if (tilemap[(x-radius)>>16][y>>16])
+ return false;
+ if (tilemap[(x+radius)>>16][y>>16])
+ return false;
+ if (tilemap[(x+radius)>>16][(y+radius)>>16])
+ return false;
+ if (tilemap[(x+radius)>>16][(y-radius)>>16])
+ return false;
+ if (tilemap[(x-radius)>>16][(y+radius)>>16])
+ return false;
+ if (tilemap[(x-radius)>>16][(y-radius)>>16])
+ return false;
+ radius-=0x10000;
+ }
+ return true;
+}
+
+/*
+==================
+=
+= Died
+=
+==================
+*/
+
+#define DEATHROTATE 6
+
+extern boolean dopefish;
+void Died (void)
+{
+ long dx,dy;
+ int iangle,curangle,clockwise,change;
+ int da;
+ int rate;
+ lbm_t *LBM;
+ int slowrate;
+ playertype *pstate;
+ objtype * killerobj=(objtype *)player->target;
+ player->yzangle=0;
+
+ if (killerobj == NULL)
+ killerobj = player;
+
+ if (CheckParm("slowdeath"))
+ slowrate=3;
+ else
+ slowrate=0;
+
+ M_LINKSTATE (player, pstate);
+
+ if ( (ZoomDeathOkay()==true) && (pstate->falling==false))
+ {
+ int x,y,z,radius,heightoffset;
+ int endangle,startangle,killangle;
+ boolean deadflagset;
+ objtype * dummy;
+
+ x=player->x;
+ y=player->y;
+ z=player->z;
+ dummy=player;
+ SpawnPlayerobj (x>>16, y>>16, 0, 0);
+ player=dummy;
+ dummy=new;
+ dummy->x=x;
+ dummy->drawx=x;
+ dummy->y=y;
+ dummy->z=z;
+ dummy->drawy=y;
+ dummy->flags=player->flags;
+ player->momentumx=0;
+ player->momentumy=0;
+ player->speed=0;
+ radius=STARTRADIUS;
+ heightoffset=pstate->heightoffset;
+ deadflagset=false;
+ startangle=(player->angle+ANG180)&(FINEANGLES-1);
+ endangle=startangle+TOTALDEATHROT;
+ killangle=startangle+(TOTALDEATHROT>>1);
+ if (dopefish==true)
+ {
+ AddMessage("Dopefish Death Cam",MSG_SYSTEM);
+ }
+ for (iangle=startangle;;)
+ {
+ if ( iangle > killangle )
+ {
+ if ( deadflagset==false )
+ {
+ dummy->hitpoints=0;
+ pstate->health=0;
+ dummy->flags &= ~FL_DYING;
+ dummy->flags |= FL_SHOOTABLE;
+ if (player->state==&s_ashwait)
+ dummy->flags |= FL_SKELETON;
+ Collision(dummy,(objtype*)NULL,0,0);
+ deadflagset=true;
+ if ( ( killerobj==player ) && ( gamestate.violence >=
+ vl_high ) && ( gamestate.difficulty >= gd_hard ) )
+ {
+ SD_Play( SD_YOUSUCKSND );
+ }
+ else
+ {
+ SD_Play (SD_PLAYERTCDEATHSND+(pstate->player));
+ }
+ }
+ }
+ else
+ {
+ dummy->flags &= ~FL_DYING;
+ }
+ if (dopefish==true)
+ {
+ dummy->momentumx+=(RandomNumber("Died",0)<<6)-(256<<5);
+ dummy->momentumy+=(RandomNumber("Died",0)<<6)-(256<<5);
+ }
+ player->x=x+FixedMul(radius,costable[iangle&(FINEANGLES-1)]);
+ player->y=y-FixedMul(radius,sintable[iangle&(FINEANGLES-1)]);
+ player->z=dummy->z;
+ player->angle=(iangle+ANG180)&(FINEANGLES-1);
+ if (dopefish==true)
+ {
+ int dx,dy;
+
+ dx = dummy->x - player->x;
+ dy = player->y - dummy->y;
+
+ if (dx && dy)
+ player->angle = atan2_appx (dx,dy);
+ }
+ pstate->heightoffset=heightoffset;
+ player->yzangle=0;
+ UpdateGameObjects();
+ player->momentumx=0;
+ player->momentumy=0;
+ player->speed=0;
+ ThreeDRefresh ();
+ AnimateWalls();
+ DoSprites();
+ DoAnimatedMaskedWalls();
+ UpdatePlayers();
+ UpdateLightLevel(player->areanumber);
+
+ if (iangle<endangle)
+ {
+ iangle+=(tics<<ROTRATE);
+ radius+=tics*(RADIUSINC<<ROTRATE);
+ }
+ if ( (dummy->state==dummy->state->next) && (iangle>=endangle) )
+ break;
+ }
+ }
+ else if (pstate->falling==false)
+ {
+
+ //
+ // swing around to face attacker
+ //
+
+ rate=DEATHROTATE-slowrate;
+ {
+ if (killerobj==player)
+ {
+ iangle=player->angle;
+ if ( ( gamestate.violence >= vl_high ) &&
+ ( gamestate.difficulty >= gd_hard ) )
+ {
+ SD_Play( SD_YOUSUCKSND );
+ }
+ }
+ else
+ {
+ SD_Play (SD_PLAYERTCDEATHSND+(pstate->player));
+ if (killerobj->which==PWALL)
+ {
+ dx = ((pwallobj_t *)killerobj)->x - player->x;
+ dy = player->y - ((pwallobj_t *)killerobj)->y;
+ }
+ else
+ {
+ dx = killerobj->x - player->x;
+ dy = player->y - killerobj->y;
+ }
+
+ iangle = atan2_appx (dx,dy); // returns -pi to pi
+ }
+ }
+
+ da = iangle-player->angle;
+
+ if (da>0)
+ clockwise=1;
+ else
+ clockwise=0;
+ da=abs(da);
+ if (da>ANG180)
+ {
+ clockwise^=1;
+ da=ANGLES-da;
+ }
+
+ curangle = player->angle;
+
+ do
+ {
+ DoBorderShifts ();
+ change = tics<<rate;
+ if (clockwise==1)
+ curangle+=change;
+ else
+ curangle-=change;
+ da-=change;
+ if (curangle >= ANGLES)
+ curangle -= ANGLES;
+ if (curangle < 0)
+ curangle += ANGLES;
+ player->angle = (curangle & (FINEANGLES-1));
+ ThreeDRefresh ();
+ CalcTics ();
+ } while (da>0);
+ }
+ else
+ {
+ DrawFullSky();
+ FlipPage();
+ }
+
+ while (damagecount)
+ DoBorderShifts ();
+ DoBorderShifts ();
+
+ locplayerstate->weapon = -1; // take away weapon
+
+ if (
+ (tedlevel == false) && // SO'S YA DON'T GET KILLED WHILE LAUNCHING!
+ (timelimitenabled == false)
+ )
+ locplayerstate->lives--;
+
+ if (pstate->falling==false)
+ {
+ ThreeDRefresh ();
+ }
+
+ FlipPage();
+ FlipPage();
+
+ if (locplayerstate->lives > -1)
+ {
+ int rng;
+
+ rng = RandomNumber ("Died",0);
+
+ if (pstate->falling==true)
+ {
+ RotateBuffer (0, 0, (FINEANGLES), (FINEANGLES>>6), (VBLCOUNTER*(1+slowrate)));
+ SD_Play (SD_PLAYERTCDEATHSND+(pstate->player));
+ pstate->falling=false;
+ }
+
+ else if (rng < 64)
+ RotateBuffer (0, 0, (FINEANGLES), (FINEANGLES*64), (VBLCOUNTER*(2+slowrate)));
+ else if (rng < 128)
+ {
+ RotateBuffer (0, 0, (FINEANGLES), (FINEANGLES>>6), (VBLCOUNTER*(1+slowrate)));
+ }
+ else if (rng < 192)
+ RotateBuffer(0, (FINEANGLES*4), (FINEANGLES), (FINEANGLES*64), (VBLCOUNTER*(3+slowrate)));
+ else
+ VL_FadeToColor (VBLCOUNTER*2, 100, 0, 0);
+
+ screenfaded=false;
+
+ VL_FadeOut (0, 255, 0,0,0,VBLCOUNTER>>1);
+ gamestate.episode = 1;
+ player->flags &= ~FL_DONE;
+
+ InitializeWeapons (locplayerstate);
+ ResetPlayerstate(locplayerstate);
+
+ UpdateLives (locplayerstate->lives);
+ UpdateScore (gamestate.score);
+
+ DrawTriads(true);
+ DrawLives (true);
+ DrawKeys (true);
+ DrawScore (true);
+ }
+ else
+ {
+ int rng;
+
+ SD_Play (SD_GAMEOVERSND);
+ rng=RandomNumber("Died",0);
+ if (rng<64)
+ RotateBuffer(0,(FINEANGLES>>1),(FINEANGLES),(FINEANGLES*64),(VBLCOUNTER*(3+slowrate)));
+ else if (rng<128)
+ VL_FadeToColor (VBLCOUNTER*3, 255, 255, 255);
+ else if (rng<192)
+ RotateBuffer(0,(FINEANGLES*2),(FINEANGLES),(FINEANGLES*64),(VBLCOUNTER*(3+slowrate)));
+ else
+ RotateBuffer(0,(FINEANGLES*2),(FINEANGLES),(FINEANGLES*64),(VBLCOUNTER*(3+slowrate)));
+
+ screenfaded=false;
+
+ VL_FadeOut (0, 255, 0,0,0,VBLCOUNTER>>1);
+
+ MU_StartSong(song_gameover);
+
+#if (SHAREWARE==0)
+ if (gamestate.violence==vl_excessive)
+ LBM = (lbm_t *) W_CacheLumpNum (W_GetNumForName ("bootblod"), PU_CACHE, Cvt_lbm_t, 1);
+ else
+ LBM = (lbm_t *) W_CacheLumpNum (W_GetNumForName ("bootnorm"), PU_CACHE, Cvt_lbm_t, 1);
+#else
+ LBM = (lbm_t *) W_CacheLumpNum (W_GetNumForName ("bootblod"), PU_CACHE, Cvt_lbm_t, 1);
+#endif
+ VL_DecompressLBM (LBM,true);
+
+ StopWind();
+
+ IN_UserInput (VBLCOUNTER*60);
+
+ MainMenu[savegame].active = 0;
+ MainMenu[viewscores].routine = (void *)CP_ViewScores;
+ MainMenu[viewscores].texture[6] = '7';
+ MainMenu[viewscores].texture[7] = '\0';
+ MainMenu[viewscores].letter = 'V';
+ }
+ ClearGraphicsScreen();
+
+ VL_FadeIn (0, 255, origpal, 15);
+}
+
+
+//******************************************************************************
+//
+// DoLoadGameAction ()
+//
+//******************************************************************************
+
+static byte whichstr = 0;
+
+void DoLoadGameAction (void)
+{
+ if ((SaveTime+1) < GetTicCount())
+ {
+ byte *temp = bufferofs;
+
+ bufferofs = displayofs;
+ SaveTime = GetTicCount();
+
+ CurrentFont=tinyfont;
+
+ px = 92;
+ py = 152;
+ if (whichstr)
+ {
+// VW_DrawPropString ("�");
+ VW_DrawPropString (".");
+ whichstr = 0;
+ }
+ else
+ {
+// VW_DrawPropString ("�");
+ VW_DrawPropString (".");
+ whichstr = 1;
+ }
+ bufferofs = temp;
+ }
+}
+
+//******************************************************************************
+//
+// DoCheckSum ()
+//
+//******************************************************************************
+
+long DoCheckSum (byte *source, int size, long csum)
+{
+ int i;
+ long checksum;
+
+ checksum = csum;
+
+ for (i = 0; i < size; i++)
+ checksum=updatecrc(checksum,*(source+i));
+
+ return checksum;
+}
+
+//******************************************************************************
+//
+// CaculateSaveGameCheckSum ()
+//
+//******************************************************************************
+
+#define SAVECHECKSUMSIZE (10000)
+long CalculateSaveGameCheckSum (char * filename)
+{
+ int handle;
+ int lengthleft;
+ int length;
+ byte * altbuffer;
+ long checksum;
+
+ altbuffer=SafeMalloc(SAVECHECKSUMSIZE);
+
+ checksum = 0;
+
+ // Open the savegame file
+
+ handle = SafeOpenRead (filename);
+ lengthleft = filelength (handle);
+
+ while (lengthleft>0)
+ {
+ length=SAVECHECKSUMSIZE;
+ if (length>lengthleft)
+ length=lengthleft;
+
+ SafeRead(handle,altbuffer,length);
+ checksum = DoCheckSum (altbuffer, length, checksum);
+
+ lengthleft-=length;
+ }
+
+ SafeFree(altbuffer);
+
+ close (handle);
+
+ return checksum;
+}
+
+//******************************************************************************
+//
+// StoreBuffer
+//
+//******************************************************************************
+void StoreBuffer (int handle, byte * src, int size)
+{
+ SafeWrite(handle,&size,sizeof(size));
+ SafeWrite(handle,src,size);
+}
+
+//******************************************************************************
+//
+// SaveTag
+//
+//******************************************************************************
+void SaveTag (int handle, char * tag, int size)
+{
+ SafeWrite(handle,tag,size);
+}
+
+
+//******************************************************************************
+//
+// SaveTheGame ()
+//
+// Expects game to be premalloced
+//
+//******************************************************************************
+
+extern boolean enableZomROTT;
+extern boolean allowBlitzMoreMissileWeps;
+extern boolean enableAmmoPickups;
+extern Queue * enemiesToRes[8];
+
+boolean SaveTheGame (int num, gamestorage_t * game)
+{
+ char loadname[MAX_PATH]="rottgam0.rot";
+ char filename[MAX_PATH];
+ byte * altbuffer;
+ int size;
+ int avail;
+ int savehandle;
+ int crc;
+ int i;
+ char letter;
+ int myticcount;
+
+ if (num > 15 || num < 0)
+ Error("Illegal Saved game value=%d\n",num);
+
+ //
+ // Save Alternate Game Level information for reloading game
+ //
+ memset (&game->info, 0, sizeof (game->info));
+ if (GameLevels.avail == true)
+ {
+ game->info.path = GameLevels.path;
+ game->info.file = GameLevels.file;
+ game->info.avail = true;
+ }
+
+ game->mapcrc=GetMapCRC (gamestate.mapon);
+
+ // Create the proper file name
+
+ itoa(num,&loadname[7],16);
+ loadname[8]='.';
+
+
+ GetPathFromEnvironment( filename, ApogeePath, loadname );
+
+#if PLATFORM_DOS
+ {
+ struct diskfree_t dfree;
+ // Determine available disk space
+ letter = toupper(filename[0]);
+ if (
+ (letter >= 'A') &&
+ (letter <= 'Q')
+ )
+ {
+ if (_dos_getdiskfree ((letter-'A'+1), &dfree))
+ Error ("Error in _dos_getdiskfree call\n");
+ }
+ else
+ {
+ if (_dos_getdiskfree (0, &dfree))
+ Error ("Error in _dos_getdiskfree call\n");
+ }
+
+ avail = (int) dfree.avail_clusters *
+ dfree.bytes_per_sector *
+ dfree.sectors_per_cluster;
+ avail -= 8192;
+
+ // Check to see if we have enough
+
+ if (avail < MAXSAVEDGAMESIZE)
+ {
+ CP_DisplayMsg ("There is not enough\nspace on your disk\nto Save Game!\nPress any key to continue", 13);
+ return (false);
+ }
+ }
+#endif
+
+ // Open the savegame file
+
+ savehandle = SafeOpenWrite (filename);
+
+ // Save out file tag
+
+ size=4;
+ SaveTag(savehandle,"ROTT",size);
+
+ // Save out header
+
+ size=sizeof(*game);
+
+ SafeWrite(savehandle,game,size);
+
+/////////////////////////////////////////////////////////////////////////////
+// Save out rest of save game file beyond this point
+/////////////////////////////////////////////////////////////////////////////
+
+ // Door Tag
+
+ size=4;
+ SaveTag(savehandle,"DOOR",size);
+
+ // Doors
+
+ SaveDoors(&altbuffer,&size);
+ StoreBuffer(savehandle,altbuffer,size);
+ SafeFree(altbuffer);
+
+ // Elevator Tag
+
+ size = 9;
+ SaveTag(savehandle,"ELEVATORS",size);
+
+ // Elevators
+
+ SaveElevators(&altbuffer,&size);
+ StoreBuffer(savehandle,altbuffer,size);
+ SafeFree(altbuffer);
+
+ // Pushwall Tag
+
+ size=5;
+ SaveTag(savehandle,"PWALL",size);
+
+ // PushWalls
+
+ SavePushWalls(&altbuffer,&size);
+ StoreBuffer(savehandle,altbuffer,size);
+ SafeFree(altbuffer);
+
+ // MaskedWalls Tag
+
+ size=5;
+ SaveTag(savehandle,"MWALL",size);
+
+ // Masked Walls
+
+ SaveMaskedWalls(&altbuffer,&size);
+ StoreBuffer(savehandle,altbuffer,size);
+ SafeFree(altbuffer);
+
+ // Switches Tag
+
+ size=6;
+ SaveTag(savehandle,"SWITCH",size);
+
+ // Switches
+
+ SaveSwitches(&altbuffer,&size);
+ StoreBuffer(savehandle,altbuffer,size);
+ SafeFree(altbuffer);
+
+ // Statics Tag
+
+ size=6;
+ SaveTag(savehandle,"STATIC",size);
+
+ // Statics
+
+ SaveStatics(&altbuffer,&size);
+ StoreBuffer(savehandle,altbuffer,size);
+ SafeFree(altbuffer);
+
+ // Actors Tag
+
+ size=5;
+ SaveTag(savehandle,"ACTOR",size);
+
+ // Actors
+
+ SaveActors(&altbuffer,&size);
+ StoreBuffer(savehandle,altbuffer,size);
+ SafeFree(altbuffer);
+
+ // TouchPlates Tag
+
+ size=5;
+ SaveTag(savehandle,"TOUCH",size);
+
+ // TouchPlates
+
+ SaveTouchPlates(&altbuffer,&size);
+ StoreBuffer(savehandle,altbuffer,size);
+ SafeFree(altbuffer);
+
+ // GameState Tag
+
+ size=9;
+ SaveTag(savehandle,"GAMESTATE",size);
+
+ // GameState
+
+ size=sizeof(gamestate);
+ SafeWrite(savehandle,&gamestate,size);
+
+ // PlayerState Tag
+
+ size=12;
+ SaveTag(savehandle,"PLAYERSTATES",size);
+
+ // PlayerStates
+ size=sizeof(playertype);
+ for(i=0; i<numplayers; i++)
+ {
+ SafeWrite(savehandle,&PLAYERSTATE[i],size);
+ }
+
+ // Mapseen Tag
+
+ size=7;
+ SaveTag(savehandle,"MAPSEEN",size);
+
+ // MapSeen
+
+ size=sizeof(mapseen);
+ SafeWrite(savehandle,&mapseen,size);
+
+ // Song Tag
+
+ size=4;
+ SaveTag(savehandle,"SONG",size);
+
+ // Song info
+
+ MU_SaveMusic(&altbuffer,&size);
+ StoreBuffer(savehandle,altbuffer,size);
+ SafeFree(altbuffer);
+
+ // Misc Tag
+
+ size=4;
+ SaveTag(savehandle,"MISC",size);
+
+ // Misc
+
+ // ticcount
+ myticcount = GetTicCount();
+ size=sizeof(myticcount);
+ SafeWrite(savehandle,&myticcount,size);
+
+ // shaketics
+ size=sizeof(SHAKETICS);
+ SafeWrite(savehandle,&SHAKETICS,size);
+
+ // damagecount
+ size=sizeof(damagecount);
+ SafeWrite(savehandle,&damagecount,size);
+
+ // viewsize
+ size=sizeof(viewsize);
+ SafeWrite(savehandle,&viewsize,size);
+
+ // poweruptimes
+ size = sizeof (poweruptime);
+ SafeWrite(savehandle,&poweruptime,size);
+
+ size = sizeof (protectiontime);
+ SafeWrite(savehandle,&protectiontime,size);
+
+ size = sizeof (powerupheight);
+ SafeWrite(savehandle,&powerupheight,size);
+
+ size = sizeof (protectionheight);
+ SafeWrite(savehandle,&protectionheight,size);
+
+ size = sizeof (poweradjust);
+ SafeWrite(savehandle,&poweradjust,size);
+
+ size = sizeof (allowBlitzMoreMissileWeps);
+ SafeWrite(savehandle, &allowBlitzMoreMissileWeps, size);
+
+ size = sizeof (enableAmmoPickups);
+ SafeWrite(savehandle, &enableAmmoPickups, size);
+
+ size = sizeof(enableZomROTT);
+ SafeWrite(savehandle, &enableZomROTT, size);
+
+ //ZomROTT Stuff
+ if(enableZomROTT)
+ {
+ int z;
+ for (z = 0; z < 8; z++)
+ {
+ size = sizeof(int);
+ SafeWrite(savehandle,&enemiesToRes[z]->sizeOfQueue, size);
+ if (enemiesToRes[z]->sizeOfQueue == 0)
+ {
+ continue;
+ }
+
+ int x;
+ node * thingToSave = enemiesToRes[z]->head;
+ size = sizeof(objtype);
+ for (x = 0; x < enemiesToRes[z]->sizeOfQueue; x++)
+ {
+ SafeWrite(savehandle, (objtype *) thingToSave->data, size);
+ thingToSave = thingToSave->next;
+ }
+ }
+ }
+
+ close (savehandle);
+
+ // Calculate CRC
+
+ crc = CalculateSaveGameCheckSum (filename);
+
+ // Append the crc
+
+ savehandle = SafeOpenAppend (filename);
+
+ size=sizeof(crc);
+ SafeWrite(savehandle,&crc,size);
+
+ close (savehandle);
+
+ pickquick = true;
+ return (true);
+}
+
+
+//******************************************************************************
+//
+// LoadTag
+//
+//******************************************************************************
+
+void LoadTag (byte ** src, char * tag, int size)
+{
+ if (StringsNotEqual((char *)*src,(char *)tag,size)==true)
+ Error("Could not locate %s header in saved game file\n",tag);
+ *src+=size;
+}
+
+//******************************************************************************
+//
+// LoadBuffer
+//
+//******************************************************************************
+int LoadBuffer (byte ** dest, byte ** src)
+{
+ int size;
+
+ memcpy(&size,*src,sizeof(size));
+ *src+=sizeof(size);
+ *dest=SafeMalloc(size);
+ memcpy(*dest,*src,size);
+ *src+=size;
+ return size;
+}
+
+
+//******************************************************************************
+//
+// LoadTheGame ()
+//
+// Expects game to be premalloced
+//
+//******************************************************************************
+
+
+extern unsigned int freeSlot;
+
+boolean LoadTheGame (int num, gamestorage_t * game)
+{
+ char loadname[45]="rottgam0.rot";
+ char filename[128];
+ byte * loadbuffer;
+ byte * bufptr;
+ byte * altbuffer;
+ int size;
+ int totalsize;
+ int checksum;
+ int savedchecksum;
+ int i;
+ word mapcrc;
+ int myticcount;
+
+ if (num>15 || num<0)
+ Error("Illegal Load game value=%d\n",num);
+
+ // Create the proper file name
+
+ itoa(num,&loadname[7],16);
+ loadname[8]='.';
+
+ GetPathFromEnvironment( filename, ApogeePath, loadname );
+
+ // Load the file
+
+ totalsize=LoadFile(filename,(void **)&loadbuffer);
+ bufptr=loadbuffer;
+
+ // Calculate checksum
+
+ checksum = DoCheckSum (loadbuffer, totalsize-sizeof(checksum), 0);
+
+ // Retrieve saved checksum
+
+ memcpy (&savedchecksum,loadbuffer+(totalsize-sizeof(savedchecksum)),sizeof(savedchecksum));
+
+ // Compare the two checksums;
+
+ if (checksum!=savedchecksum)
+ {
+ if (CP_DisplayMsg ("Your Saved Game file is\n"
+ "shall we say, \"corrupted\".\n"
+ "Would you like to\n"
+ "continue anyway (Y/N)?\n", 12)==false)
+ {
+ return false;
+ }
+ }
+
+ // Load in file tag
+
+ size=4;
+ LoadTag(&bufptr,"ROTT",size);
+
+ // Load in header
+
+ size=sizeof(*game);
+ memcpy(game,bufptr,size);
+ bufptr+=size;
+
+ if (game->version!=ROTTVERSION)
+ return false;
+
+ memcpy (&GameLevels, &game->info, sizeof (GameLevels));
+
+ gamestate.episode=game->episode;
+ gamestate.mapon=game->area;
+
+ mapcrc=GetMapCRC (gamestate.mapon);
+
+ if (mapcrc!=game->mapcrc)
+ return false;
+
+/////////////////////////////////////////////////////////////////////////////
+// Load in rest of saved game file beyond this point
+/////////////////////////////////////////////////////////////////////////////
+
+ // Free up the current level
+ Z_FreeTags (PU_LEVELSTRUCT, PU_LEVELEND); // Free current level
+
+ gamestate.battlemode = battle_StandAloneGame;
+ BATTLE_SetOptions( &BATTLE_Options[ battle_StandAloneGame ] );
+ BATTLE_Init( gamestate.battlemode, 1 );
+
+ DoLoadGameAction ();
+ SetupGameLevel();
+
+ // This prevents a nasty glitch when loading some saved games
+ PreCacheGroup(W_GetNumForName("BULLETHO"),W_GetNumForName("ALTBHO"),cache_transpatch_t);
+
+ // Door Tag
+
+ size=4;
+ LoadTag(&bufptr,"DOOR",size);
+
+ // Doors
+
+ DoLoadGameAction ();
+ size=LoadBuffer(&altbuffer,&bufptr);
+ LoadDoors(altbuffer,size);
+ SafeFree(altbuffer);
+
+ // Elevator Tag
+
+ size = 9;
+ LoadTag(&bufptr,"ELEVATORS",size);
+
+
+ // Elevators
+
+ DoLoadGameAction ();
+ size=LoadBuffer(&altbuffer,&bufptr);
+ LoadElevators(altbuffer,size);
+ SafeFree(altbuffer);
+
+ // Pushwall Tag
+
+ size=5;
+ LoadTag(&bufptr,"PWALL",size);
+
+ // PushWalls
+
+ DoLoadGameAction ();
+ size=LoadBuffer(&altbuffer,&bufptr);
+ LoadPushWalls(altbuffer,size);
+ SafeFree(altbuffer);
+#if 0
+ // Animated Walls Tag
+
+ size=5;
+ LoadTag(&bufptr,"AWALL",size);
+
+ // Animated Walls
+ size=LoadBuffer(&altbuffer,&bufptr);
+ LoadAnimWalls(altbuffer,size);
+ SafeFree(altbuffer);
+#endif
+
+ // MaskedWalls Tag
+
+ size=5;
+ LoadTag(&bufptr,"MWALL",size);
+
+ // Masked Walls
+
+ DoLoadGameAction ();
+ size=LoadBuffer(&altbuffer,&bufptr);
+ LoadMaskedWalls(altbuffer,size);
+ SafeFree(altbuffer);
+
+ // Switches Tag
+
+ size=6;
+ LoadTag(&bufptr,"SWITCH",size);
+
+ // Switches
+
+ DoLoadGameAction ();
+ size=LoadBuffer(&altbuffer,&bufptr);
+ LoadSwitches(altbuffer,size);
+ SafeFree(altbuffer);
+
+
+ // Statics Tag
+
+ size=6;
+ LoadTag(&bufptr,"STATIC",size);
+
+ // Statics
+
+ DoLoadGameAction ();
+ size=LoadBuffer(&altbuffer,&bufptr);
+ LoadStatics(altbuffer,size);
+ SafeFree(altbuffer);
+
+ // Actors Tag
+
+ size=5;
+ LoadTag(&bufptr,"ACTOR",size);
+
+ // Actors
+
+ DoLoadGameAction ();
+ size=LoadBuffer(&altbuffer,&bufptr);
+ LoadActors(altbuffer,size);
+ SafeFree(altbuffer);
+
+ // TouchPlates Tag
+
+ size=5;
+ LoadTag(&bufptr,"TOUCH",size);
+
+ // TouchPlates
+
+ DoLoadGameAction ();
+ size=LoadBuffer(&altbuffer,&bufptr);
+ LoadTouchPlates(altbuffer,size);
+ SafeFree(altbuffer);
+
+ // SetupWindows
+
+ SetupWindows();
+
+ // GameState Tag
+
+ size=9;
+ LoadTag(&bufptr,"GAMESTATE",size);
+
+ // GameState
+
+ DoLoadGameAction ();
+ size=sizeof(gamestate);
+ memcpy(&gamestate,bufptr,size);
+ bufptr+=size;
+
+ // PlayerState Tag
+
+ size=12;
+ LoadTag(&bufptr,"PLAYERSTATES",size);
+
+ // PlayerState
+
+ DoLoadGameAction ();
+ size=sizeof(playertype);
+ for(i=0; i<numplayers; i++)
+ { memcpy(&PLAYERSTATE[i],bufptr,size);
+ bufptr+=size;
+ }
+
+ // Zero out player targets
+
+ locplayerstate->guntarget=0;
+ locplayerstate->targettime=0;
+
+ // Mapseen Tag
+
+ size=7;
+ LoadTag(&bufptr,"MAPSEEN",size);
+
+ // MapSeen
+
+ DoLoadGameAction ();
+ size=sizeof(mapseen);
+ memcpy(&mapseen,bufptr,size);
+ bufptr+=size;
+
+ // Song Tag
+
+ size=4;
+ LoadTag(&bufptr,"SONG",size);
+
+ // Song info
+
+ DoLoadGameAction ();
+ size=LoadBuffer(&altbuffer,&bufptr);
+ MU_LoadMusic(altbuffer,size);
+ SafeFree(altbuffer);
+
+ // Misc Tag
+
+ size=4;
+ LoadTag(&bufptr,"MISC",size);
+
+ // Misc
+
+ // ticcount
+ DoLoadGameAction ();
+ size=sizeof(myticcount);
+ memcpy((void *)&myticcount,bufptr,size);
+ bufptr+=size;
+ SaveTime = myticcount;
+ ISR_SetTime(myticcount);
+
+ // shaketics
+ DoLoadGameAction ();
+ size=sizeof(SHAKETICS);
+ memcpy(&SHAKETICS,bufptr,size);
+ bufptr+=size;
+
+ // damagecount
+ DoLoadGameAction ();
+ size=sizeof(damagecount);
+ memcpy(&damagecount,bufptr,size);
+ bufptr+=size;
+
+ // viewsize
+ DoLoadGameAction ();
+ size=sizeof(viewsize);
+ memcpy(&viewsize,bufptr,size);
+ bufptr+=size;
+
+ // powerup times
+ DoLoadGameAction ();
+ size = sizeof (poweruptime);
+ memcpy (&poweruptime, bufptr, size);
+ bufptr += size;
+ size = sizeof (protectiontime);
+ memcpy (&protectiontime, bufptr, size);
+ bufptr += size;
+ size = sizeof (powerupheight);
+ memcpy (&powerupheight, bufptr, size);
+ bufptr += size;
+ size = sizeof (protectionheight);
+ memcpy (&protectionheight, bufptr, size);
+ bufptr += size;
+ size = sizeof (poweradjust);
+ memcpy (&poweradjust, bufptr, size);
+ bufptr += size;
+
+ size = sizeof(allowBlitzMoreMissileWeps);
+ memcpy (&allowBlitzMoreMissileWeps, bufptr, size);
+ bufptr += size;
+
+ size = sizeof(enableAmmoPickups);
+ memcpy (&enableAmmoPickups, bufptr, size);
+ bufptr += size;
+
+ size = sizeof(enableZomROTT);
+ memcpy(&enableZomROTT, bufptr, size);
+ bufptr += size;
+
+
+ //ZomROTT Stuff
+ if(enableZomROTT)
+ {
+ int z;
+ for (z = 0; z < 8; z++)
+ {
+ size = sizeof(int);
+
+ int origQueueSize = 0;
+ Queue * enemyQueue;
+
+ origQueueSize = 0;
+
+ enemyQueue = malloc(sizeof(Queue));
+ queueInit(enemyQueue, sizeof(objtype));
+
+ memcpy(&origQueueSize, bufptr, size);
+ bufptr+=size;
+ enemiesToRes[z] = enemyQueue;
+
+ //memcpy(&origQueueSize, bufptr, size);
+ //bufptr+=size;
+
+ size = sizeof(objtype);
+
+ int x = 0;
+
+ while(x < origQueueSize)
+ {
+ objtype * item = (objtype *) malloc(sizeof(objtype));
+
+ memcpy(item, bufptr, size);
+
+ enqueue(enemyQueue, item);
+
+ bufptr+=size;
+
+ x++;
+ }
+ }
+ }
+
+ // Set the viewsize
+
+ SetViewSize(viewsize);
+ DoLoadGameAction ();
+
+ // Connect areas
+
+ ConnectAreas ();
+ DoLoadGameAction ();
+
+ // Free up the loadbuffer
+
+ SafeFree (loadbuffer);
+ DoLoadGameAction ();
+
+ Illuminate();
+
+ IN_UpdateKeyboard ();
+ LoadPlayer ();
+ DoLoadGameAction ();
+ SetupPlayScreen();
+ UpdateScore (gamestate.score);
+ UpdateLives (locplayerstate->lives);
+ UpdateTriads (player, 0);
+ PreCache ();
+ InitializeMessages();
+
+ for (i=0; i<100; i++)
+ UpdateLightLevel(player->areanumber);
+
+ CalcTics();
+ CalcTics();
+
+ pickquick = true;
+
+ return (true);
+}
+
+
+//******************************************************************************
+//
+// GetSavedMessage ()
+//
+// Expects message to be premalloced
+//
+//******************************************************************************
+
+void GetSavedMessage (int num, char * message)
+{
+ gamestorage_t game;
+ char loadname[45]="rottgam0.rot";
+ char filename[128];
+ byte * loadbuffer;
+ byte * bufptr;
+ int size;
+
+ if (num>15 || num<0)
+ Error("Illegal Load game value=%d\n",num);
+
+ // Create the proper file name
+
+ itoa(num,&loadname[7],16);
+ loadname[8]='.';
+
+ GetPathFromEnvironment( filename, ApogeePath, loadname );
+
+ // Load the file
+
+ size=LoadFile(filename,(void **)&loadbuffer);
+ bufptr=loadbuffer;
+
+ size=4;
+ LoadTag(&bufptr,"ROTT",size);
+
+ // Load in header
+
+ size=sizeof(game);
+ memcpy(&game,bufptr,size);
+ strcpy(message,game.message);
+ SafeFree(loadbuffer);
+}
+
+//******************************************************************************
+//
+// GetSavedHeader ()
+//
+// Expects game to be premalloced
+//
+//******************************************************************************
+
+void GetSavedHeader (int num, gamestorage_t * game)
+{
+ char loadname[45]="rottgam0.rot";
+ char filename[128];
+ byte * loadbuffer;
+ byte * bufptr;
+ int size;
+
+ if (num>15 || num<0)
+ Error("Illegal Load game value=%d\n",num);
+
+ // Create the proper file name
+
+ itoa(num,&loadname[7],16);
+ loadname[8]='.';
+
+ GetPathFromEnvironment( filename, ApogeePath, loadname );
+
+ // Load the file
+
+ size=LoadFile(filename, (void **)&loadbuffer);
+ bufptr=loadbuffer;
+
+ size=4;
+ LoadTag(&bufptr,"ROTT",size);
+
+ // Load in header
+
+ size=sizeof(*game);
+ memcpy(game,bufptr,size);
+ SafeFree(loadbuffer);
+}
+
+
+
+//******************************************************************************
+//
+// GetLevel ()
+//
+//******************************************************************************
+
+int GetLevel (int episode, int mapon)
+{
+ int level;
+
+ level = (mapon+1) - ((episode-1) << 3);
+
+ return (level);
+}
--- a/rott/rt_main.c
+++ b/rott/rt_main.c
@@ -255,7 +255,7 @@
// Start up Memory manager with a certain amount of reserved memory
- Z_Init(50000,1000000);
+ Z_Init(50000,10000000);
IN_Startup ();
@@ -456,7 +456,7 @@
}
#endif
}
-
+ //SDL_WM_GrabInput( SDL_GRAB_ON );
GameLoop();
@@ -866,16 +866,16 @@
if (i < _argc)
{
int width, height;
- if ( (sscanf(_argv[i], "%dx%d", &width, &height) == 2) &&
- ( ( (width == 320) && (height == 200) ) ||
- ( (width == 640) && (height == 480) ) ||
- ( (width == 800) && (height == 600) ) ) )
+ unsigned int numResParams = sscanf(_argv[i], "%dx%d", &width, &height);
+ if ( numResParams == 2)
{
iGLOBAL_SCREENWIDTH = width;
iGLOBAL_SCREENHEIGHT = height;
}
+/*
else
printf("Invalid resolution parameter: %s\n", _argv[i]);
+*/
}
else
printf("Missing resolution parameter\n");
@@ -1145,6 +1145,7 @@
while (1)
{
+ SDL_WarpMouse(iGLOBAL_SCREENWIDTH<<1, iGLOBAL_SCREENHEIGHT<<1);
if ( playstate == ex_battledone )
{
while( damagecount > 0 )
@@ -1892,7 +1893,7 @@
UpdateLightning ();
TriggerStuff();
CheckCriticalStatics();
- if (((gamestate.TimeCount/VBLCOUNTER) % 60 == 0) && gamestate.TimeCount/VBLCOUNTER >= 60 && enableZomROTT)
+ if (enableZomROTT && gamestate.killcount > 0)
{
ResurrectEnemies();
}
@@ -3546,4 +3547,4 @@
break;
#endif
}
-}
+}
\ No newline at end of file
--- a/rott/rt_menu.c
+++ b/rott/rt_menu.c
@@ -714,6 +714,7 @@
CP_MenuNames ControlMMenuNames[] =
{
+ "VISUAL OPTIONS",
"CONTROLS",
"USER OPTIONS",
"EXT USER OPTIONS",//bna added
@@ -722,11 +723,12 @@
"SOUND FX VOLUME"
};
-CP_iteminfo ControlMItems = {32, 48-8, 6, 0, 32, ControlMMenuNames, mn_largefont };//bna added
+CP_iteminfo ControlMItems = {32, 48-8, 7, 0, 32, ControlMMenuNames, mn_largefont };//bna added
//CP_iteminfo ControlMItems = {32, 48, 4, 0, 32, ControlMMenuNames, mn_largefont };
-
+void CP_VisualsMenu(void);
CP_itemtype ControlMMenu[] =
{
+ {1, "adjfwid\0", 'W', (menuptr)CP_VisualsMenu},
{2, "cntl\0", 'C', (menuptr)CP_Control},
{1, "uopt\0", 'U', (menuptr)CP_OptionsMenu},
{1, "euopt\0", 'E', (menuptr)CP_ExtOptionsMenu},//bna added
@@ -733,7 +735,6 @@
{1, "eaopt\0", 'A', (menuptr)CP_ExtGameOptionsMenu},
{1, "muvolumn\0", 'M', (menuptr)MusicVolume},
{1, "fxvolumn\0", 'S', (menuptr)FXVolume}
-
};
CP_MenuNames OptionsNames[] =
@@ -753,6 +754,7 @@
{
"MOUSELOOK",
"INVERSE MOUSE",
+ "ALLOW Y AXIS MOUSE",
"CROSS HAIR",
"JUMPING",
"FULLSCREEN",
@@ -768,19 +770,84 @@
"ENABLE ZOMROTT"
}; //LT added
-CP_iteminfo ExtOptionsItems = { 20, MENU_Y, 7, 0, 43, ExtOptionsNames, mn_largefont };
+CP_MenuNames VisualOptionsNames[] =
+{
+ "SCREEN RESOLUTION",
+ "ADJUST FOCAL WIDTH"
+};
+CP_MenuNames ScreenResolutions[] =
+{
+ "320x200",
+ "640x400",
+ "640x480",
+ "800x600",
+ "1024x768",
+ "1152x864",
+ "1280x720",
+ "1280x768",
+ "1280x800",
+ "1280x960",
+ "1280x1024",
+ //"1366x768",
+ "1400x1050",
+ "1440x900",
+ "1600x900",
+ "1680x1050",
+ "1920x1080",
+ "2560x1080",
+ "2560x1440",
+ "3840x2160"
+};
+CP_itemtype ScreenResolutionMenu[] = {
+ {1, "", ' ',NULL},
+ {1, "", ' ',NULL},
+ {1, "", ' ',NULL},
+ {1, "", ' ',NULL},
+ {1, "", ' ',NULL},
+ {1, "", ' ',NULL},
+ {1, "", ' ',NULL},
+ {1, "", ' ',NULL},
+ {1, "", ' ',NULL},
+ {1, "", ' ',NULL},
+ {1, "", ' ',NULL},
+ //{1, "", ' ',NULL},
+ {1, "", ' ',NULL},
+ {1, "", ' ',NULL},
+ {1, "", ' ',NULL},
+ {1, "", ' ',NULL},
+ {1, "", ' ',NULL},
+ {1, "", ' ',NULL},
+ {1, "", ' ',NULL},
+ {1, "", ' ',NULL},
+};
+
+CP_iteminfo VisualOptionsItems = { 20, MENU_Y, 2, 0, 43, VisualOptionsNames, mn_largefont };
+
+CP_iteminfo ScreenResolutionItems = {NORMALKEY_X, 17, 19, 0, 16, ScreenResolutions, mn_tinyfont};
+
+CP_iteminfo ExtOptionsItems = { 20, MENU_Y, 8, 0, 43, ExtOptionsNames, mn_largefont };
+
CP_iteminfo ExtGameOptionsItems = { 20, MENU_Y, 4, 0, 43, ExtGameOptionsNames, mn_largefont }; //LT added
+void CP_ScreenResolution(void);
+
+CP_itemtype VisualsOptionsMenu[] =
+{
+ {1, "", 'S', (menuptr)CP_ScreenResolution},
+ {1, "", 'F', (menuptr)DoAdjustFocalWidth}
+};
+
CP_itemtype ExtOptionsMenu[] =
{
{1, "", 'M', NULL},
{1, "", 'I', NULL},
+ {1, "", 'D', NULL},
{1, "", 'C', NULL},
{1, "", 'J', NULL},
{1, "", 'F', NULL},
{1, "", 'A', NULL},
- {1, "", 'U', NULL}
+ {1, "", 'U', NULL},
};
CP_itemtype ExtGameMenu[] =
@@ -1697,6 +1764,10 @@
FreeSavedScreenPtr ();
WriteConfig ();
+
+ //change the focal width if modified
+
+ RecalculateFocalWidth();
INL_GetJoyDelta (joystickport, &joyx, &joyy);
@@ -4903,8 +4974,6 @@
mouseactive = 1;
}
-#else
-#error please define your platform. /* or maybe just nuke the DOS section? */
#endif
buttons = IN_GetMouseButtons();
@@ -5333,6 +5402,7 @@
+
//****************************************************************************
//
// DrawOptionsMenu ()
@@ -5353,6 +5423,206 @@
DisplayInfo (0);
FlipMenuBuf();
}
+
+void DrawVisualsMenu (void)
+{
+ MenuNum = 1;
+ SetAlternateMenuBuf();
+ ClearMenuBuf();
+ SetMenuTitle ("Visuals Menu");
+
+ MN_GetCursorLocation( &VisualOptionsItems, &VisualsOptionsMenu[ 0 ] );
+ DrawMenu (&VisualOptionsItems, &VisualsOptionsMenu[0]);
+ DrawMenuBufItem (VisualOptionsItems.x, ((VisualOptionsItems.curpos*14)+(VisualOptionsItems.y-2)),
+ W_GetNumForName( LargeCursor ) + CursorFrame[ CursorNum ] );
+ DisplayInfo (0);
+ FlipMenuBuf();
+
+}
+
+void CP_VisualsMenu(void)
+{
+ int which;
+ DrawVisualsMenu();
+
+ do
+ {
+ which = HandleMenu (&VisualOptionsItems, &VisualsOptionsMenu[0], NULL);
+ } while (which >= 0);
+
+ DrawControlMenu();
+}
+
+
+extern int FocalWidthOffset;
+
+void DoAdjustFocalWidth (void)
+{
+ SliderMenu (&FocalWidthOffset, 200, 0, 44, 81, 194, 1, "block2", NULL,
+ "Adjust Focal Width", "Default", "You Crazy" );
+ DrawVisualsMenu ();
+}
+
+void DrawScreenResolutionMenu(void)
+{
+ MenuNum = 1;
+ SetAlternateMenuBuf();
+ ClearMenuBuf();
+ SetMenuTitle ("Screen Resolution");
+
+ MN_GetCursorLocation( &ScreenResolutionItems, &ScreenResolutionMenu[ 0 ] );
+ DrawMenu (&ScreenResolutionItems, &ScreenResolutionMenu[0]);
+
+ DisplayInfo (0);
+ FlipMenuBuf();
+
+}
+
+void CP_RestartProgramMessage
+(
+ void
+)
+
+{
+ CP_ErrorMsg( "Note:",
+ "Changes will not be applied until the application is restarted. "
+ "Hit any key to continue.",
+ mn_smallfont );
+}
+
+extern int ScreenWidthToWriteToCfg;
+extern int ScreenHeightToWriteToCfg;
+extern boolean writeNewResIntoCfg;
+
+void CP_ScreenResolution(void)
+{
+ int which;
+
+ //CP_RestartProgramMessage();
+
+ DrawScreenResolutionMenu();
+
+ do
+ {
+ which = HandleMenu (&ScreenResolutionItems, &ScreenResolutionMenu[0], NULL);
+ switch(which)
+ {
+ case 0:
+ ScreenWidthToWriteToCfg = 320;
+ ScreenHeightToWriteToCfg = 200;
+ writeNewResIntoCfg = true;
+ break;
+ case 1:
+ ScreenWidthToWriteToCfg = 640;
+ ScreenHeightToWriteToCfg = 400;
+ writeNewResIntoCfg = true;
+ break;
+ case 2:
+ ScreenWidthToWriteToCfg = 640;
+ ScreenHeightToWriteToCfg = 480;
+ writeNewResIntoCfg = true;
+ break;
+ case 3:
+ ScreenWidthToWriteToCfg = 800;
+ ScreenHeightToWriteToCfg = 600;
+ writeNewResIntoCfg = true;
+ break;
+ case 4:
+ ScreenWidthToWriteToCfg = 1024;
+ ScreenHeightToWriteToCfg = 768;
+ writeNewResIntoCfg = true;
+ break;
+ case 5:
+ ScreenWidthToWriteToCfg = 1152;
+ ScreenHeightToWriteToCfg = 864;
+ writeNewResIntoCfg = true;
+ break;
+ case 6:
+ ScreenWidthToWriteToCfg = 1280;
+ ScreenHeightToWriteToCfg = 720;
+ writeNewResIntoCfg = true;
+ break;
+ case 7:
+ ScreenWidthToWriteToCfg = 1280;
+ ScreenHeightToWriteToCfg = 768;
+ writeNewResIntoCfg = true;
+ break;
+ case 8:
+ ScreenWidthToWriteToCfg = 1280;
+ ScreenHeightToWriteToCfg = 800;
+ writeNewResIntoCfg = true;
+ break;
+ case 9:
+ ScreenWidthToWriteToCfg = 1280;
+ ScreenHeightToWriteToCfg = 960;
+ writeNewResIntoCfg = true;
+ break;
+ case 10:
+ ScreenWidthToWriteToCfg = 1280;
+ ScreenHeightToWriteToCfg = 1024;
+ writeNewResIntoCfg = true;
+ break;
+/* buggy af mode
+ case 11:
+ ScreenWidthToWriteToCfg = 1366;
+ ScreenHeightToWriteToCfg = 768;
+ writeNewResIntoCfg = true;
+ break;
+*/
+ case 11:
+ ScreenWidthToWriteToCfg = 1400;
+ ScreenHeightToWriteToCfg = 1050;
+ writeNewResIntoCfg = true;
+ break;
+ case 12:
+ ScreenWidthToWriteToCfg = 1440;
+ ScreenHeightToWriteToCfg = 900;
+ writeNewResIntoCfg = true;
+ break;
+ case 13:
+ ScreenWidthToWriteToCfg = 1600;
+ ScreenHeightToWriteToCfg = 900;
+ writeNewResIntoCfg = true;
+ break;
+ case 14:
+ ScreenWidthToWriteToCfg = 1680;
+ ScreenHeightToWriteToCfg = 1050;
+ writeNewResIntoCfg = true;
+ break;
+ case 15:
+ ScreenWidthToWriteToCfg = 1920;
+ ScreenHeightToWriteToCfg = 1080;
+ writeNewResIntoCfg = true;
+ break;
+ case 16:
+ ScreenWidthToWriteToCfg = 2560;
+ ScreenHeightToWriteToCfg = 1080;
+ writeNewResIntoCfg = true;
+ break;
+ case 17:
+ ScreenWidthToWriteToCfg = 2560;
+ ScreenHeightToWriteToCfg = 1440;
+ writeNewResIntoCfg = true;
+ break;
+ case 18:
+ ScreenWidthToWriteToCfg = 3840;
+ ScreenHeightToWriteToCfg = 2160;
+ writeNewResIntoCfg = true;
+ break;
+ default:
+ break;
+ }
+
+
+ } while (which >= 0);
+
+ if (writeNewResIntoCfg)
+ CP_RestartProgramMessage();
+
+ DrawVisualsMenu();
+}
+
+
//****************************************************************************
//
// DrawExtOptionsMenu () () bna added
@@ -5370,10 +5640,47 @@
MN_GetCursorLocation( &ExtOptionsItems, &ExtOptionsMenu[ 0 ] );
DrawMenu (&ExtOptionsItems, &ExtOptionsMenu[0]);
DrawExtOptionsButtons ();
+
DisplayInfo (0);
FlipMenuBuf();
}
+
+static char * ExtOptionsDesc[8] = {
+ "Allow mouse look.",
+ "Invert the mouse.",
+ "Move forward and backward using mouse.",
+ "Enable Crosshairs.",
+ "Allow Jumping (may completely break levels)",
+ "Toggle Fullscreen",
+ "Missile weapons are auto aimed after 1st shot.",
+ "Allow auto aim"
+
+};
+
+void DrawExtOptionDescription (int w)
+{
+
+ int width;
+ int height;
+ char *string;
+ font_t *temp;
+
+ EraseMenuBufRegion (25, 4, 287 - 25, 10 );
+
+ temp = CurrentFont;
+ CurrentFont = tinyfont;
+
+ string = ExtOptionsDesc[ w ];
+
+ VW_MeasurePropString ( string, &width, &height );
+ DrawMenuBufPropString ( ( 288 - width ) / 2, 4, string );
+
+ CurrentFont = temp;
+
+
+}
+
extern int inverse_mouse;
extern boolean usemouselook;
extern boolean iG_aimCross;
@@ -5381,7 +5688,10 @@
extern boolean sdl_fullscreen;
extern boolean autoAimMissileWeps;
extern boolean autoAim;
+extern boolean allowMovementWithMouseYAxis;
+
+
void CP_ExtOptionsMenu (void)
{
int which;
@@ -5390,7 +5700,7 @@
do
{
- which = HandleMenu (&ExtOptionsItems, &ExtOptionsMenu[0], NULL);
+ which = HandleMenu (&ExtOptionsItems, &ExtOptionsMenu[0], DrawExtOptionDescription);
switch (which)
{
@@ -5407,14 +5717,18 @@
DrawExtOptionsButtons ();
break;
case 2:
- iG_aimCross ^= 1;
+ allowMovementWithMouseYAxis ^= 1;
DrawExtOptionsButtons ();
break;
case 3:
- usejump ^= 1;
+ iG_aimCross ^= 1;
DrawExtOptionsButtons ();
break;
case 4:
+ usejump ^= 1;
+ DrawExtOptionsButtons ();
+ break;
+ case 5:
if (SDL_WM_ToggleFullScreen(SDL_GetVideoSurface()))
{
sdl_fullscreen ^= 1;
@@ -5421,11 +5735,11 @@
DrawExtOptionsButtons ();
}
break;
- case 5:
+ case 6:
autoAimMissileWeps ^= 1;
DrawExtOptionsButtons();
break;
- case 6:
+ case 7:
autoAim ^= 1;
DrawExtOptionsButtons();
break;
@@ -5435,6 +5749,7 @@
DrawControlMenu();
}
+
void DrawExtOptionsButtons (void)
{
int i,
@@ -5463,18 +5778,21 @@
if (inverse_mouse == -1)on = 1;
break;
case 2:
- if (iG_aimCross == 1) on = 1;
+ if (allowMovementWithMouseYAxis == 1) on = 1;
break;
case 3:
- if (usejump == 1) on = 1;
+ if (iG_aimCross == 1) on = 1;
break;
case 4:
- if (sdl_fullscreen== 1) on = 1;
+ if (usejump == 1) on = 1;
break;
case 5:
- if (autoAimMissileWeps == 1) on = 1;
+ if (sdl_fullscreen== 1) on = 1;
break;
case 6:
+ if (autoAimMissileWeps == 1) on = 1;
+ break;
+ case 7:
if (autoAim == 1) on = 1;
break;
}
@@ -5488,7 +5806,14 @@
extern boolean allowBlitzMoreMissileWeps;
extern boolean enableAmmoPickups;
extern boolean enableZomROTT = 0;
-extern boolean enableExtraPistolDrops = 0;
+extern boolean enableExtraPistolDrops;
+static char *ExtGameOptionsDesc[ sizeof(ExtGameOptionsItems)] =
+{
+ "Allow Blitzguards to be randomly given any missile weapon.",
+ "Take ammo from dropped missile weapons upon touching them.",
+ "Guards with pistols drop their pistol when killed.",
+ "If enabled, guards will respawn UNLESS if GIBBED."
+};
void DrawExtGameOptionsButtons (void)
{
@@ -5512,16 +5837,36 @@
switch (i)
{
case 0:
- if (allowBlitzMoreMissileWeps == 1) on = 1;
+ if (allowBlitzMoreMissileWeps == 1){
+ on = 1;
+ }
break;
case 1:
- if (enableAmmoPickups == 1) on = 1;
+ if (enableAmmoPickups == 1) {
+/*
+ EraseMenuBufRegion (25, 4, 287 - 25, 10 );
+ DrawOptionDescription( ExtGameOptionsDesc, 1);
+*/
+ on = 1;
+ }
break;
case 2:
- if (enableExtraPistolDrops == 1) on = 1;
+ if (enableExtraPistolDrops == 1){
+/*
+ EraseMenuBufRegion (25, 4, 287 - 25, 10 );
+ DrawOptionDescription( ExtGameOptionsDesc, 2 );
+*/
+ on = 1;
+ }
break;
case 3:
- if (enableZomROTT == 1) on = 1;
+ if (enableZomROTT == 1) {
+/*
+ EraseMenuBufRegion (25, 4, 287 - 25, 10 );
+ DrawOptionDescription( ExtGameOptionsDesc, 3 );
+*/
+ on = 1;
+ }
break;
}
@@ -5534,9 +5879,6 @@
}
-
-
-
void DrawExtGameMenu (void)
{
MenuNum = 1;
@@ -5555,6 +5897,31 @@
FlipMenuBuf();
}
+
+void DrawExtGameOptionDescription (int w)
+{
+
+ int width;
+ int height;
+ char *string;
+ font_t *temp;
+
+ EraseMenuBufRegion (25, 4, 287 - 25, 10 );
+
+ temp = CurrentFont;
+ CurrentFont = tinyfont;
+
+ string = ExtGameOptionsDesc[ w ];
+
+ VW_MeasurePropString ( string, &width, &height );
+ DrawMenuBufPropString ( ( 288 - width ) / 2, 4, string );
+
+ CurrentFont = temp;
+
+
+}
+
+
//****************************************************************************
//
// DrawExtGameOptionsMenu () () LT added
@@ -5569,8 +5936,13 @@
do
{
- which = HandleMenu (&ExtGameOptionsItems, &ExtGameMenu[0], NULL);
+ //EraseMenuBufRegion (25, 4, 287 - 25, 10 );
+ //DrawOptionDescription( ExtGameOptionsDesc, w );
+ which = HandleMenu (&ExtGameOptionsItems, &ExtGameMenu[0], DrawExtGameOptionDescription);
+ //EraseMenuBufRegion (25, 4, 287 - 25, 10 );
+ //DrawOptionDescription( ExtGameOptionsDesc, which);
+
switch (which)
{
case 0:
--- a/rott/rt_menu.h
+++ b/rott/rt_menu.h
@@ -213,5 +213,6 @@
void CP_CaptureTheTriadError( void );
void CP_TeamPlayErrorMessage( void );
void CP_ExtGameOptionsMenu( void );
+void DoAdjustFocalWidth (void);
#endif
--- a/rott/rt_playr.c
+++ b/rott/rt_playr.c
@@ -2480,6 +2480,8 @@
//******************************************************************************
boolean aimbuttonpressed=false;
+extern boolean allowMovementWithMouseYAxis;
+
void PollMove (void)
{
int angle;
@@ -2487,6 +2489,7 @@
x = KX + MX + JX + CX + VX;
+
y = KY + MY + JY + CY + VY;
if (buttonpoll[bt_aimbutton])
@@ -2513,6 +2516,16 @@
{
aimbuttonpressed=false;
}
+
+ if (!allowMovementWithMouseYAxis)
+ {
+ y = KY + JY + CY + VY;
+ }
+ //kill any movement
+ if (aimbuttonpressed)
+ {
+ y = 0;
+ }
if (player->flags & FL_FLEET)
y += y>>1;
@@ -2910,8 +2923,8 @@
controlbuf[0] = controlbuf[1] = controlbuf[2] = 0;
CYBERLOOKUP = CYBERLOOKDOWN = false;
- if (gamestate.autorun==1)
- buttonpoll[bt_run] = true;
+ //if (gamestate.autorun==1)
+ //buttonpoll[bt_run] = true;
//
@@ -2918,6 +2931,19 @@
// get button states
//
PollKeyboardButtons ();
+
+ if (gamestate.autorun == 1)
+ {
+ if (buttonpoll[bt_run])
+ {
+ buttonpoll[bt_run] = false;
+ }
+ else
+ {
+ buttonpoll[bt_run] = true;
+
+ }
+ }
if (mouseenabled && !cybermanenabled)
PollMouseButtons ();
--- a/rott/rt_table.h
+++ b/rott/rt_table.h
@@ -44,6 +44,10 @@
&s_lowgrddie3 ,
&s_lowgrddie2 ,
&s_lowgrddie1 ,
+ &s_lowgrddie1rev,
+ &s_lowgrddie2rev,
+ &s_lowgrddie3rev,
+ &s_lowgrddie4rev,
&s_lowgrdcrushed2 ,
&s_lowgrdcrushed1 ,
&s_sneakydown,
@@ -72,6 +76,11 @@
&s_highgrddie3 ,
&s_highgrddie2 ,
&s_highgrddie1 ,
+ &s_highgrddie1rev ,
+ &s_highgrddie2rev ,
+ &s_highgrddie3rev,
+ &s_highgrddie4rev,
+ &s_highgrddie5rev,
&s_highgrdcrushed2 ,
&s_highgrdcrushed1 ,
&s_strikestand ,
@@ -109,6 +118,10 @@
&s_strikedie3 ,
&s_strikedie2 ,
&s_strikedie1 ,
+ &s_strikedie1rev ,
+ &s_strikedie2rev ,
+ &s_strikedie3rev ,
+ &s_strikedie4rev ,
&s_strikecrushed2 ,
&s_strikecrushed1 ,
&s_blitzstand,
@@ -139,6 +152,10 @@
&s_blitzdie3 ,
&s_blitzdie2 ,
&s_blitzdie1 ,
+ &s_blitzdie1rev,
+ &s_blitzdie2rev,
+ &s_blitzdie3rev,
+ &s_blitzdie4rev,
&s_blitzcrushed2 ,
&s_blitzcrushed1 ,
&s_blitzplead1,
@@ -207,6 +224,10 @@
&s_enforcerdie3 ,
&s_enforcerdie2 ,
&s_enforcerdie1 ,
+ &s_enforcerdie1rev,
+ &s_enforcerdie2rev,
+ &s_enforcerdie3rev,
+ &s_enforcerdie4rev,
&s_enforcercrushed2 ,
&s_enforcercrushed1 ,
@@ -727,6 +748,11 @@
&s_opdie3 ,
&s_opdie2 ,
&s_opdie1 ,
+ &s_opdie1rev,
+ &s_opdie2rev,
+ &s_opdie3rev,
+ &s_opdie4rev,
+ &s_opdie5rev,
&s_opcrushed2 ,
&s_opcrushed1 ,
@@ -754,6 +780,10 @@
&s_dmonkdie3 ,
&s_dmonkdie2 ,
&s_dmonkdie1 ,
+ &s_dmonkdie1rev,
+ &s_dmonkdie2rev,
+ &s_dmonkdie3rev,
+ &s_dmonkdie4rev,
&s_dmonkcrushed2 ,
&s_dmonkcrushed1 ,
&s_firemonkstand ,
@@ -792,6 +822,10 @@
&s_firemonkdie3 ,
&s_firemonkdie2 ,
&s_firemonkdie1 ,
+ &s_firemonkdie1rev,
+ &s_firemonkdie2rev,
+ &s_firemonkdie3rev,
+ &s_firemonkdie4rev,
&s_firemonkcrushed2 ,
&s_firemonkcrushed1 ,
--- a/rott/rt_ted.c
+++ b/rott/rt_ted.c
@@ -66,6 +66,7 @@
#include "rt_net.h"
//MED
#include "memcheck.h"
+#include "queue.h"
@@ -1175,7 +1176,23 @@
MiscPreCache();
SortPreCache();
-
+
+ double ratioNewToOldWidth = ((double)iGLOBAL_SCREENWIDTH)/320.0;
+
+ double ratioNewToOldHeight = ((double)iGLOBAL_SCREENHEIGHT)/200.0;
+
+ double newPrecacheBarX = ratioNewToOldWidth * 28.0; //PRECACHEBARX = 28
+
+ double newPrecacheBarY = ratioNewToOldHeight * 178.0; //PRECACHEBARY = 178
+
+ double newPrecacheBar1LedX = ratioNewToOldWidth * (double)9.0; //PRECACHEBAR1LEDX = 9
+
+ double newPrecacheBar1LedY = ratioNewToOldHeight * (double)8.0; //PRECACHEBAR1LEDY = 8
+
+ double newPrecacheBar2LedX = newPrecacheBar1LedX; //PRECACHEBAR2LEDX = PRECACHEBAR1LEDX
+
+ double newPrecacheBar2LedY = ratioNewToOldHeight * (double)12.0; //PRECACHEBAR2LEDY = 12
+
if (loadedgame==false)
{
maxheapsize=Z_HeapSize();
@@ -1192,15 +1209,45 @@
currentmem=(newheap*MAXLEDS)/maxheapsize;
while (lastmem<=currentmem)
{ //SetTextMode ( );
+ //Note: This isn't drawing 4 LED thingys... its just drawing one big one (made up of 4 of the LED thingys)
+
+ DrawNormalSprite ((int)(newPrecacheBarX + newPrecacheBar1LedX+(Gs*(lastmem<<2))),
+ (int)(newPrecacheBarY + newPrecacheBar1LedY),W_GetNumForName ("led1"));//led1 progressbar
+
+ DrawNormalSprite ((int)(newPrecacheBarX + newPrecacheBar1LedX+(Gs*(lastmem<<2))),
+ (int)(newPrecacheBarY + newPrecacheBar1LedY + 3),W_GetNumForName ("led1"));//led1 progressbar
+
+ DrawNormalSprite ((int)(newPrecacheBarX + newPrecacheBar1LedX+(Gs*(lastmem<<2)) + 3),
+ (int)(newPrecacheBarY + newPrecacheBar1LedY),W_GetNumForName ("led1"));//led1 progressbar
+
+ DrawNormalSprite ((int)(newPrecacheBarX + newPrecacheBar1LedX+(Gs*(lastmem<<2)) + 3),
+ (int)(newPrecacheBarY + newPrecacheBar1LedY + 3),W_GetNumForName ("led1"));//led1 progressbar
+
+/*
if ( iGLOBAL_SCREENWIDTH == 320) {
DrawNormalSprite (PRECACHEBARX+PRECACHELED1X+(lastmem<<2),
PRECACHEBARY+PRECACHELED1Y,
W_GetNumForName ("led1"));//led1 progressbar
} else if ( iGLOBAL_SCREENWIDTH == 640) {
- DrawNormalSprite (72+(Gs*(lastmem<<2)),446,W_GetNumForName ("led1"));//led1 progressbar
- DrawNormalSprite (72+(Gs*(lastmem<<2)),446+3,W_GetNumForName ("led1"));//led1 progressbar
- DrawNormalSprite (72+3+(Gs*(lastmem<<2)),446,W_GetNumForName ("led1"));//led1 progressbar
- DrawNormalSprite (72+3+(Gs*(lastmem<<2)),446+3,W_GetNumForName ("led1"));//led1 progressbar
+ if (iGLOBAL_SCREENHEIGHT == 400)
+ {
+ DrawNormalSprite ((int)(newPrecacheBarX+newPrecacheBar1LedX+(Gs*(lastmem<<2))),
+ (int)(newPrecacheBarY + newPrecacheBar1LedY),W_GetNumForName ("led1"));//led1 progressbar
+ DrawNormalSprite ((int)(newPrecacheBarX+newPrecacheBar1LedX+(Gs*(lastmem<<2))),
+ (int)(newPrecacheBarY + newPrecacheBar1LedY + 3),W_GetNumForName ("led1"));//led1 progressbar
+ DrawNormalSprite ((int)(newPrecacheBarX+newPrecacheBar1LedX+(Gs*(lastmem<<2)) + 3),
+ (int)(newPrecacheBarY + newPrecacheBar1LedY),W_GetNumForName ("led1"));//led1 progressbar
+ DrawNormalSprite ((int)(newPrecacheBarX+newPrecacheBar1LedX+(Gs*(lastmem<<2)) + 3),
+ (int)(newPrecacheBarY + newPrecacheBar1LedY + 3),W_GetNumForName ("led1"));//led1 progressbar
+ }
+ else
+ {
+ DrawNormalSprite (72+(Gs*(lastmem<<2)),446,W_GetNumForName ("led1"));//led1 progressbar
+ DrawNormalSprite (72+(Gs*(lastmem<<2)),446+3,W_GetNumForName ("led1"));//led1 progressbar
+ DrawNormalSprite (72+3+(Gs*(lastmem<<2)),446,W_GetNumForName ("led1"));//led1 progressbar
+ DrawNormalSprite (72+3+(Gs*(lastmem<<2)),446+3,W_GetNumForName ("led1"));//led1 progressbar
+ }
+
} else if ( iGLOBAL_SCREENWIDTH == 800) {
DrawNormalSprite (91+(Gs*(lastmem<<2)),559,W_GetNumForName ("led1"));//led1 progressbar
DrawNormalSprite (91+(Gs*(lastmem<<2)),559+3,W_GetNumForName ("led1"));//led1 progressbar
@@ -1207,6 +1254,7 @@
DrawNormalSprite (91+3+(Gs*(lastmem<<2)),559,W_GetNumForName ("led1"));//led1 progressbar
DrawNormalSprite (91+3+(Gs*(lastmem<<2)),559+3,W_GetNumForName ("led1"));//led1 progressbar
}
+*/
lastmem++;
VW_UpdateScreen (); // was missing, fixed
@@ -1214,16 +1262,39 @@
currentcache=(i*MAXLEDS)/(cacheindex+1);
while (lastcache<=currentcache)
{
-
+ DrawNormalSprite ((int)(newPrecacheBarX+newPrecacheBar2LedX+(Gs*(lastcache<<2))),
+ (int)(newPrecacheBarY + newPrecacheBar2LedY),W_GetNumForName ("led2"));//led2 progressbar
+ DrawNormalSprite ((int)(newPrecacheBarX+newPrecacheBar2LedX+(Gs*(lastcache<<2))),
+ (int)(newPrecacheBarY + newPrecacheBar2LedY + 3),W_GetNumForName ("led2"));//led2 progressbar
+ DrawNormalSprite ((int)(newPrecacheBarX+newPrecacheBar2LedX+(Gs*(lastcache<<2)) + 3),
+ (int)(newPrecacheBarY + newPrecacheBar2LedY),W_GetNumForName ("led2"));//led2 progressbar
+ DrawNormalSprite ((int)(newPrecacheBarX+newPrecacheBar2LedX+(Gs*(lastcache<<2)) + 3),
+ (int)(newPrecacheBarY + newPrecacheBar2LedY + 3),W_GetNumForName ("led2"));//led2 progressbar
+/*
if ( iGLOBAL_SCREENWIDTH == 320) {
DrawNormalSprite (PRECACHEBARX+PRECACHELED2X+(lastcache<<2),
PRECACHEBARY+PRECACHELED2Y,
W_GetNumForName ("led2"));//led2 progressbar
- } else if ( iGLOBAL_SCREENWIDTH == 640) {
- DrawNormalSprite (72+(Gs*(lastcache<<2)),458,W_GetNumForName ("led2"));//led2 progressbar
- DrawNormalSprite (72+(Gs*(lastcache<<2)),458+3,W_GetNumForName ("led2"));//led2 progressbar
- DrawNormalSprite (72+3+(Gs*(lastcache<<2)),458,W_GetNumForName ("led2"));//led2 progressbar
- DrawNormalSprite (72+3+(Gs*(lastcache<<2)),458+3,W_GetNumForName ("led2"));//led2 progressbar
+ }
+ else if ( iGLOBAL_SCREENWIDTH == 640) {
+ if (iGLOBAL_SCREENHEIGHT == 400)
+ {
+ DrawNormalSprite ((int)(newPrecacheBarX+newPrecacheBar2LedX+(Gs*(lastcache<<2))),
+ (int)(newPrecacheBarY + newPrecacheBar2LedY),W_GetNumForName ("led2"));//led2 progressbar
+ DrawNormalSprite ((int)(newPrecacheBarX+newPrecacheBar2LedX+(Gs*(lastcache<<2))),
+ (int)(newPrecacheBarY + newPrecacheBar2LedY + 3),W_GetNumForName ("led2"));//led2 progressbar
+ DrawNormalSprite ((int)(newPrecacheBarX+newPrecacheBar2LedX+(Gs*(lastcache<<2)) + 3),
+ (int)(newPrecacheBarY + newPrecacheBar2LedY),W_GetNumForName ("led2"));//led2 progressbar
+ DrawNormalSprite ((int)(newPrecacheBarX+newPrecacheBar2LedX+(Gs*(lastcache<<2)) + 3),
+ (int)(newPrecacheBarY + newPrecacheBar2LedY + 3),W_GetNumForName ("led2"));//led2 progressbar
+ }
+ else
+ {
+ DrawNormalSprite (72+(Gs*(lastcache<<2)),458,W_GetNumForName ("led2"));//led2 progressbar
+ DrawNormalSprite (72+(Gs*(lastcache<<2)),458+3,W_GetNumForName ("led2"));//led2 progressbar
+ DrawNormalSprite (72+3+(Gs*(lastcache<<2)),458,W_GetNumForName ("led2"));//led2 progressbar
+ DrawNormalSprite (72+3+(Gs*(lastcache<<2)),458+3,W_GetNumForName ("led2"));//led2 progressbar
+ }
} else if ( iGLOBAL_SCREENWIDTH == 800) {
DrawNormalSprite (91+(Gs*(lastcache<<2)),573,W_GetNumForName ("led2"));//led2 progressbar
@@ -1231,6 +1302,7 @@
DrawNormalSprite (91+3+(Gs*(lastcache<<2)),573,W_GetNumForName ("led2"));//led2 progressbar
DrawNormalSprite (91+3+(Gs*(lastcache<<2)),573+3,W_GetNumForName ("led2"));//led2 progressbar
}
+*/
DisableScreenStretch();//bna++
VW_UpdateScreen ();//bna++
lastcache++;
@@ -5666,18 +5738,23 @@
DoLowMemoryConversionIconPlane ();
}
-extern objtype * enemiesToRes = NULL;
-extern int freeSlot = 0;
+//int freeSlot = 0;
+//Queue enemiesToRes;
+Queue * enemiesToRes[8]; //8 "Organic enemy Types"
+
void SetupZomROTTStuff()
-{
- if (enemiesToRes)
+{
+ int x;
+ for (x = 0; x < 8; x++)
{
- FreeUpResurrectList();
+ //if (enemiesToRes[x]->head != NULL && enemiesToRes[x]->tail != NULL)
+ //{
+ //clearQueue(enemiesToRes[x]);
+ //}
+ Queue * enemyQueue = malloc(sizeof(Queue));
+ queueInit(enemyQueue, sizeof(objtype));
+ enemiesToRes[x] = enemyQueue;
}
- enemiesToRes = calloc(sizeof(objtype), gamestate.killtotal);
- memset(enemiesToRes, 0, sizeof(enemiesToRes));
-
- freeSlot = 0;
}
/*
@@ -7086,4 +7163,3 @@
}
}
}
-
--- a/rott/rt_util.c
+++ b/rott/rt_util.c
@@ -357,7 +357,7 @@
px = ERRORVERSIONCOL;
py = ERRORVERSIONROW;
#if (BETA == 1)
- UL_printf ("�");
+ UL_printf ("�");
#else
UL_printf (itoa(ROTTMAJORVERSION,&buf[0],10));
#endif
@@ -1574,7 +1574,7 @@
px = ERRORVERSIONCOL;
py = ERRORVERSIONROW;
#if (BETA == 1)
- UL_printf ("�");
+ UL_printf ("�");
#else
UL_printf (itoa(ROTTMAJORVERSION,&buf[0],10));
#endif
--- a/rott/rt_view.c
+++ b/rott/rt_view.c
@@ -87,7 +87,7 @@
byte * greenmap;
byte * playermaps[MAXPLAYERCOLORS];
//short pixelangle[MAXVIEWWIDTH];
-short pixelangle[800];
+short pixelangle[MAXSCREENWIDTH];
byte gammatable[GAMMAENTRIES];
int gammaindex;
int focalwidth=160;
@@ -212,7 +212,7 @@
scale = (centerx*focalwidth)/(160);
} else if ( iGLOBAL_SCREENWIDTH == 640) {
scale = (centerx*focalwidth)/(160);
- } else if ( iGLOBAL_SCREENWIDTH == 800) {
+ } else if ( iGLOBAL_SCREENWIDTH >= 800) {
scale = (centerx*focalwidth)/(160);
}
//
@@ -309,53 +309,294 @@
*/
if ( iGLOBAL_SCREENWIDTH == 640) {
- height = 0;//we use height as dummy cnt
- viewsizes[height++]= 380;
- viewsizes[height++]= 336;
- viewsizes[height++]= 428;
- viewsizes[height++]= 352;
- viewsizes[height++]= 460;
- viewsizes[height++]= 368;
- viewsizes[height++]= 492;
- viewsizes[height++]= 384;
- viewsizes[height++]= 524;
- viewsizes[height++]= 400;
- viewsizes[height++]= 556;
- viewsizes[height++]= 416;
- viewsizes[height++]= 588;
- viewsizes[height++]= 432;
- viewsizes[height++]= 640;
- viewsizes[height++]= 448;
- viewsizes[height++]= 640;
- viewsizes[height++]= 464;
- viewsizes[height++]= 640;
- viewsizes[height++]= 480;
- viewsizes[height++]= 640;
- viewsizes[height++]= 480;
+ if (iGLOBAL_SCREENHEIGHT == 400)
+ {
+ height = 0;//we use height as dummy cnt
+ viewsizes[height++]= 640;
+ viewsizes[height++]= 400 - 32;
+
+ viewsizes[height++]= 640;
+ viewsizes[height++]= 400 - 32;
+
+ viewsizes[height++]= 640;
+ viewsizes[height++]= 400 - 32;
+
+ viewsizes[height++]= 640;
+ viewsizes[height++]= 400 - 32;
+
+ viewsizes[height++]= 640;
+ viewsizes[height++]= 400 - 32;
+
+ viewsizes[height++]= 640;
+ viewsizes[height++]= 400 - 32;
+
+ viewsizes[height++]= 640;
+ viewsizes[height++]= 400 - 32;
+
+ viewsizes[height++]= 640;
+ viewsizes[height++]= 400 - 32;
+
+ viewsizes[height++]= 640;
+ viewsizes[height++]= 400 - 16;
+
+ viewsizes[height++]= 640;
+ viewsizes[height++]= 400;
+
+ viewsizes[height++]= 640;
+ viewsizes[height++]= 400;
+
+ }
+ else{
+ height = 0;//we use height as dummy cnt
+ viewsizes[height++]= 380;
+ viewsizes[height++]= 336;
+ viewsizes[height++]= 428;
+ viewsizes[height++]= 352;
+ viewsizes[height++]= 460;
+ viewsizes[height++]= 368;
+ viewsizes[height++]= 492;
+ viewsizes[height++]= 384;
+ viewsizes[height++]= 524;
+ viewsizes[height++]= 400;
+ viewsizes[height++]= 556;
+ viewsizes[height++]= 416;
+ viewsizes[height++]= 588;
+ viewsizes[height++]= 432;
+ viewsizes[height++]= 640;
+ viewsizes[height++]= 448;
+ viewsizes[height++]= 640;
+ viewsizes[height++]= 464;
+ viewsizes[height++]= 640;
+ viewsizes[height++]= 480;
+ viewsizes[height++]= 640;
+ viewsizes[height++]= 480;
+ }
+
} else if ( iGLOBAL_SCREENWIDTH == 800) {
height = 0;
viewsizes[height++]= 556;
viewsizes[height++]= 488;
+
viewsizes[height++]= 588;
viewsizes[height++]= 504;
+
viewsizes[height++]= 620;
viewsizes[height++]= 520;
+
viewsizes[height++]= 652;
viewsizes[height++]= 536;
+
viewsizes[height++]= 684;
viewsizes[height++]= 552;
+
viewsizes[height++]= 716;
viewsizes[height++]= 568;
+
viewsizes[height++]= 748;
viewsizes[height++]= 584;
+
viewsizes[height++]= 800;
viewsizes[height++]= 600;
+
viewsizes[height++]= 800;
viewsizes[height++]= 600;
+
viewsizes[height++]= 800;
viewsizes[height++]= 600;
+
viewsizes[height++]= 800;
viewsizes[height++]= 600;
+
+ }
+ else if ( iGLOBAL_SCREENWIDTH == 1024) {
+ height = 0;
+ viewsizes[height++]= 556;
+ viewsizes[height++]= 488;
+
+ viewsizes[height++]= 588;
+ viewsizes[height++]= 504;
+
+ viewsizes[height++]= 620;
+ viewsizes[height++]= 520;
+
+ viewsizes[height++]= 816;
+ viewsizes[height++]= 704;
+
+ viewsizes[height++]= 868;
+ viewsizes[height++]= 720;
+
+ viewsizes[height++]= 920;
+ viewsizes[height++]= 736;
+
+ viewsizes[height++]= 972;
+ viewsizes[height++]= 752;
+
+ viewsizes[height++]= 1024;
+ viewsizes[height++]= 768;
+
+ viewsizes[height++]= 1024;
+ viewsizes[height++]= 768;
+
+ viewsizes[height++]= 1024;
+ viewsizes[height++]= 768;
+
+ viewsizes[height++]= 1024;
+ viewsizes[height++]= 768;
+ }
+ else if ( iGLOBAL_SCREENWIDTH == 1280)
+ {
+ height = 0;
+ viewsizes[height++]= 1280;
+ viewsizes[height++]= 1024;
+
+ viewsizes[height++]= 1280;
+ viewsizes[height++]= 1024;
+
+ viewsizes[height++]= 1280;
+ viewsizes[height++]= 1024;
+
+ viewsizes[height++]= 1280;
+ viewsizes[height++]= 1024;
+
+ viewsizes[height++]= 1280;
+ viewsizes[height++]= 1024;
+
+ viewsizes[height++]= 1280;
+ viewsizes[height++]= 1024;
+
+ viewsizes[height++]= 1280;
+ viewsizes[height++]= 1024;
+
+ viewsizes[height++]= 1280;
+ viewsizes[height++]= 1024;
+
+ viewsizes[height++]= 1280;
+ viewsizes[height++]= 1024;
+
+ viewsizes[height++]= 1280;
+ viewsizes[height++]= 1024;
+
+ viewsizes[height++]= 1280;
+ viewsizes[height++]= 1024;
+ }
+ else if ( iGLOBAL_SCREENWIDTH == 1400)
+ {
+ height = 0;
+ viewsizes[height++]= 1400;
+ viewsizes[height++]= 1050;
+
+ viewsizes[height++]= 1400;
+ viewsizes[height++]= 1050;
+
+ viewsizes[height++]= 1400;
+ viewsizes[height++]= 1050;
+
+ viewsizes[height++]= 1400;
+ viewsizes[height++]= 1050;
+
+ viewsizes[height++]= 1400;
+ viewsizes[height++]= 1050;
+
+ viewsizes[height++]= 1400;
+ viewsizes[height++]= 1050;
+
+ viewsizes[height++]= 1400;
+ viewsizes[height++]= 1050;
+
+ viewsizes[height++]= 1400;
+ viewsizes[height++]= 1050;
+
+ viewsizes[height++]= 1400;
+ viewsizes[height++]= 1050;
+
+ viewsizes[height++]= 1400;
+ viewsizes[height++]= 1050;
+
+ viewsizes[height++]= 1400;
+ viewsizes[height++]= 1050;
+ }
+ else if ( iGLOBAL_SCREENWIDTH == 1920)
+ {
+ height = 0;
+ viewsizes[height++]= 1920;
+ viewsizes[height++]= 1080;
+
+ viewsizes[height++]= 1920;
+ viewsizes[height++]= 1080;
+
+ viewsizes[height++]= 1920;
+ viewsizes[height++]= 1080;
+
+ viewsizes[height++]= 1920;
+ viewsizes[height++]= 1080;
+
+ viewsizes[height++]= 1920;
+ viewsizes[height++]= 1080;
+
+ viewsizes[height++]= 1920;
+ viewsizes[height++]= 1080;
+
+ viewsizes[height++]= 1920;
+ viewsizes[height++]= 1080;
+
+ viewsizes[height++]= 1920;
+ viewsizes[height++]= 1080;
+
+ viewsizes[height++]= 1920;
+ viewsizes[height++]= 1080;
+
+ viewsizes[height++]= 1920;
+ viewsizes[height++]= 1080;
+
+ viewsizes[height++]= 1920;
+ viewsizes[height++]= 1080;
+ }
+ else if ( iGLOBAL_SCREENWIDTH == 3840)
+ {
+ height = 0;
+ viewsizes[height++]= 3840;
+ viewsizes[height++]= 2160;
+
+ viewsizes[height++]= 3840;
+ viewsizes[height++]= 2160;
+
+ viewsizes[height++]= 3840;
+ viewsizes[height++]= 2160;
+
+ viewsizes[height++]= 3840;
+ viewsizes[height++]= 2160;
+
+ viewsizes[height++]= 3840;
+ viewsizes[height++]= 2160;
+
+ viewsizes[height++]= 3840;
+ viewsizes[height++]= 2160;
+
+ viewsizes[height++]= 3840;
+ viewsizes[height++]= 2160;
+
+ viewsizes[height++]= 3840;
+ viewsizes[height++]= 2160;
+
+ viewsizes[height++]= 3840;
+ viewsizes[height++]= 2160;
+
+ viewsizes[height++]= 3840;
+ viewsizes[height++]= 2160;
+
+ viewsizes[height++]= 3840;
+ viewsizes[height++]= 2160;
+ }
+ else
+ {
+ height = 0;
+ for (height = 0; height < 21;)
+ {
+ viewsizes[height++] = iGLOBAL_SCREENWIDTH;
+ viewsizes[height++] = iGLOBAL_SCREENHEIGHT;
+ }
+
+
}
--- a/rott/rt_view.h
+++ b/rott/rt_view.h
@@ -76,7 +76,7 @@
extern byte * playermaps[MAXPLAYERCOLORS];
//extern short pixelangle[MAXVIEWWIDTH];
-extern short pixelangle[800];
+extern short pixelangle[MAXSCREENWIDTH];
extern byte gammatable[GAMMAENTRIES];
extern int gammaindex;
extern byte uniformcolors[MAXPLAYERCOLORS];
--- a/rott/stdout.txt
+++ /dev/null
@@ -1,14 +1,0 @@
-Rise of the Triad Startup Version 1.4
- Commercial Version
-Z_INIT: 8950000 bytes
-IN_Startup: Mouse Present
- Adding DARKWAR.WAD.
- Adding REMOTE1.RTS.
-W_Wad: Wad Manager Started NUMLUMPS=3904
-RT_DRAW: Tables Initialized
-MU_Startup:
-SD_SetupFXCard: Fx ok.
-SD_Startup: Fx ok.
-RT_MAIN: Fonts Initialized
-RT_MSG: Message System Started
-RT_VIEW: Colormaps Initialized
--- a/rott/watcom.c
+++ b/rott/watcom.c
@@ -33,6 +33,7 @@
fixed FixedScale(fixed orig, fixed factor, fixed divisor)
{
+/*
__int64 x = orig;
__int64 y = factor;
__int64 z = divisor;
@@ -40,4 +41,7 @@
__int64 w = (x * y) / z;
return (w) & 0xffffffff;
+*/
+ //changed to this because arithmetic errors occurred with resolutions > 800x600
+ return (float)orig * factor / divisor;
}
--- a/rott/winrott.c
+++ b/rott/winrott.c
@@ -30,22 +30,44 @@
extern int viewheight;
extern int viewwidth;
-
+extern int FocalWidthOffset;
//----------------------------------------------------------------------
#define FINEANGLES 2048
+
+void RecalculateFocalWidth(void)
+{
+ iGLOBAL_FOCALWIDTH = 160 - FocalWidthOffset;
+ dGLOBAL_FPFOCALWIDTH = 160.0 - FocalWidthOffset;
+}
+
void SetRottScreenRes (int Width, int Height)
{
iGLOBAL_SCREENWIDTH = Width;
iGLOBAL_SCREENHEIGHT = Height;
+
+ iGLOBAL_FOCALWIDTH = 160 - FocalWidthOffset;
+ dGLOBAL_FPFOCALWIDTH = (double) iGLOBAL_FOCALWIDTH;
+ int middleWidth = Width / 2;
+
+ iGLOBAL_AMMO_X = middleWidth + 160 - 20;
+
+ iGLOBAL_AMMO_Y = iGLOBAL_SCREENHEIGHT - 16;
+
+ iGLOBAL_HEALTH_X = middleWidth - 160 + 20;
+
+ iGLOBAL_HEALTH_Y = iGLOBAL_AMMO_Y;
iGLOBAL_SCREENBWIDE = iGLOBAL_SCREENWIDTH*(96/320);
iG_SCREENWIDTH = iGLOBAL_SCREENWIDTH*(96/320);;// default screen width in bytes
+
+ dTopYZANGLELIMIT = (44*FINEANGLES/360);;
+/*
if (iGLOBAL_SCREENWIDTH == 320) {
- iGLOBAL_FOCALWIDTH = 160;
- dGLOBAL_FPFOCALWIDTH = 160.0;
+ iGLOBAL_FOCALWIDTH = 160 - FocalWidthOffset;
+ dGLOBAL_FPFOCALWIDTH = 160.0 - FocalWidthOffset;
iGLOBAL_HEALTH_X = 20;
iGLOBAL_HEALTH_Y = 185;
iGLOBAL_AMMO_X = 300;
@@ -54,18 +76,35 @@
dTopYZANGLELIMIT = (44*FINEANGLES/360);;
}
if (iGLOBAL_SCREENWIDTH == 640) {
- iGLOBAL_FOCALWIDTH = 180;
- dGLOBAL_FPFOCALWIDTH = 180.0 ;
- iGLOBAL_HEALTH_X = 40;//20*2;
- iGLOBAL_HEALTH_Y = 466;//(185*2)+16;
- iGLOBAL_AMMO_X = 600;//300*2;
- iGLOBAL_AMMO_Y = 464;//480-16;
+ if (iGLOBAL_SCREENHEIGHT == 400)
+ {
+ iGLOBAL_FOCALWIDTH = 180 - FocalWidthOffset;
+ dGLOBAL_FPFOCALWIDTH = 180.0 - FocalWidthOffset ;
+ iGLOBAL_HEALTH_X = 180;
+ iGLOBAL_HEALTH_Y = 400 - 16;
+ iGLOBAL_AMMO_X = 460;
+ iGLOBAL_AMMO_Y = 400 - 16;
- dTopYZANGLELIMIT = (42*FINEANGLES/360);;
+ dTopYZANGLELIMIT = (42*FINEANGLES/360);;
+
+ }
+ else
+ {
+ iGLOBAL_FOCALWIDTH = 180 - FocalWidthOffset;
+ dGLOBAL_FPFOCALWIDTH = 180.0 - FocalWidthOffset ;
+ iGLOBAL_HEALTH_X = 40;//20*2;
+ iGLOBAL_HEALTH_Y = 466;//(185*2)+16;
+ iGLOBAL_AMMO_X = 600;//300*2;
+ iGLOBAL_AMMO_Y = 464;//480-16;
+
+ dTopYZANGLELIMIT = (42*FINEANGLES/360);;
+
+ }
+
}
if (iGLOBAL_SCREENWIDTH == 800) {
- iGLOBAL_FOCALWIDTH = 200;
- dGLOBAL_FPFOCALWIDTH = 200.0 ;
+ iGLOBAL_FOCALWIDTH = 200 - FocalWidthOffset;
+ dGLOBAL_FPFOCALWIDTH = 200.0 - FocalWidthOffset;
iGLOBAL_HEALTH_X = 40;//20*2;
iGLOBAL_HEALTH_Y = 585;//(185/200)*600;
iGLOBAL_AMMO_X = 750;//(300/320)*800;
@@ -73,6 +112,7 @@
dTopYZANGLELIMIT = (90*FINEANGLES/360);;
}
+*/
//dYZANGLELIMIT = (12*FINEANGLES/360);
//#define YZANGLELIMIT (12*FINEANGLES/360)//bna--(30*FINEANGLES/360)
@@ -165,6 +205,4 @@
for (Ycnt=b+((viewheight-startY-1)*iGLOBAL_SCREENWIDTH); Ycnt>b; Ycnt-=iGLOBAL_SCREENWIDTH) {
memcpy(Ycnt+startoffset,Ycnt,viewwidth-startX);
}
-}
-
-
+}
\ No newline at end of file