Commit 30bfea2a authored by alistert's avatar alistert

Added #defines for 320 and 200. Changed some #defines to enums. Simplified panel data loading.

parent 93c4b9c1
......@@ -110,12 +110,6 @@
// Standard string length
#define STRING_LENGTH 32
// Loop return type
#define NORMAL_LOOP 0
#define TYPING_LOOP 1
#define SET_KEY_LOOP 2
#define SET_JOYSTICK_LOOP 3
// Return values
#define E_DATA -14
#define E_VERSION -13
......@@ -151,6 +145,15 @@
#define DIV(x, y) (((x) << 10) / (y))
// Enum
enum LoopType {
NORMAL_LOOP, TYPING_LOOP, SET_KEY_LOOP, SET_JOYSTICK_LOOP
};
// Datatype
typedef int fixed;
......@@ -164,7 +167,7 @@ EXTERN unsigned int globalTicks;
// Functions in main.cpp
EXTERN int loop (int type);
EXTERN int loop (LoopType type);
// Functions in util.cpp
......
......@@ -40,7 +40,8 @@ ClientGame::ClientGame (char *address) {
unsigned char buffer[BUFFER_LENGTH];
unsigned int timeout;
int count, ret, mode;
int count, ret;
GameModeType mode;
sock = net->join(address);
......@@ -108,7 +109,7 @@ ClientGame::ClientGame (char *address) {
printf("Connected to server (version %d).\n", buffer[2]);
// Copy game parameters
mode = buffer[3];
mode = GameModeType(buffer[3]);
difficulty = buffer[4];
maxPlayers = buffer[5];
nPlayers = buffer[6];
......
......@@ -26,6 +26,8 @@
#define _GAME_H
#include "gamemode.h"
#include "io/network.h"
......@@ -124,7 +126,7 @@ class ServerGame : public Game {
int sock;
public:
ServerGame (int mode, char *firstLevel, int gameDifficulty);
ServerGame (GameModeType mode, char *firstLevel, int gameDifficulty);
~ServerGame ();
int setLevel (char *fileName);
......
......@@ -8,7 +8,7 @@
* Part of the OpenJazz project
*
*
* Copyright (c) 2005-2009 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
* OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0
......@@ -147,7 +147,7 @@ void TeamGameMode::drawScore () {
}
int CoopGameMode::getMode () {
GameModeType CoopGameMode::getMode () {
return M_COOP;
......@@ -166,21 +166,21 @@ bool CoopGameMode::endOfLevel (Player *player, unsigned char gridX,
}
int BattleGameMode::getMode () {
GameModeType BattleGameMode::getMode () {
return M_BATTLE;
}
int TeamBattleGameMode::getMode () {
GameModeType TeamBattleGameMode::getMode () {
return M_TEAMBATTLE;
}
int RaceGameMode::getMode () {
GameModeType RaceGameMode::getMode () {
return M_RACE;
......@@ -206,10 +206,14 @@ bool RaceGameMode::endOfLevel (Player *player, unsigned char gridX,
}
GameMode * createGameMode (int mode) {
GameMode * createGameMode (GameModeType mode) {
switch (mode) {
case M_SINGLE:
return NULL;
case M_COOP:
return new CoopGameMode();
......
......@@ -8,7 +8,7 @@
* Part of the OpenJazz project
*
*
* Copyright (c) 2005-2009 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
* OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0
......@@ -29,16 +29,18 @@
// Constants
// Game modes
#define M_SINGLE 0
#define M_COOP 1
#define M_BATTLE 2
#define M_TEAMBATTLE 3
#define M_RACE 4
#define MAX_PLAYERS (MAX_CLIENTS + 1)
// Enum
enum GameModeType {
M_SINGLE = 0, M_COOP = 1, M_BATTLE = 2, M_TEAMBATTLE = 3, M_RACE = 4
};
// Classes
class Player;
......@@ -46,13 +48,12 @@ class Player;
class GameMode {
public:
virtual int getMode () = 0;
virtual GameModeType getMode () = 0;
virtual unsigned char chooseTeam () = 0;
virtual void drawScore () = 0;
virtual bool hit (Player *source, Player *victim);
virtual bool kill (Player *source, Player *victim);
virtual bool endOfLevel (Player *player, unsigned char gridX,
unsigned char gridY);
virtual bool endOfLevel (Player *player, unsigned char gridX, unsigned char gridY);
virtual void outOfTime ();
};
......@@ -84,9 +85,8 @@ class TeamGameMode : public GameMode {
class CoopGameMode : public CooperativeGameMode {
public:
int getMode ();
bool endOfLevel (Player *player, unsigned char gridX,
unsigned char gridY);
GameModeType getMode ();
bool endOfLevel (Player *player, unsigned char gridX, unsigned char gridY);
};
......@@ -96,7 +96,7 @@ class BattleGameMode : public FreeForAllGameMode {
int targetKills;
public:
int getMode ();
GameModeType getMode ();
};
......@@ -106,7 +106,7 @@ class TeamBattleGameMode : public TeamGameMode {
int targetKills;
public:
int getMode ();
GameModeType getMode ();
};
......@@ -116,13 +116,13 @@ class RaceGameMode : public FreeForAllGameMode {
int targetLaps;
public:
int getMode ();
GameModeType getMode ();
bool hit (Player *source, Player *victim);
bool endOfLevel (Player *player, unsigned char gridX,
unsigned char gridY);
bool endOfLevel (Player *player, unsigned char gridX, unsigned char gridY);
};
// Variable
EXTERN GameMode *gameMode; // NULL for single-player games
......@@ -130,7 +130,7 @@ EXTERN GameMode *gameMode; // NULL for single-player games
// Function
GameMode * createGameMode (int mode);
GameMode * createGameMode (GameModeType mode);
#endif
......
......@@ -9,7 +9,7 @@
* Part of the OpenJazz project
*
*
* Copyright (c) 2005-2009 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
* OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0
......@@ -35,7 +35,7 @@
#include <string.h>
ServerGame::ServerGame (int mode, char *firstLevel, int gameDifficulty) {
ServerGame::ServerGame (GameModeType mode, char *firstLevel, int gameDifficulty) {
int count;
......
......@@ -150,101 +150,56 @@ Font::Font (const char * fileName) {
}
Font::Font (File *file, bool big) {
Font::Font (unsigned char *pixels, bool big) {
unsigned char *pixels;
int rle, pos, index, count;
// Load font from panel.000
unsigned char *chrPixels;
int count, y;
if (big) lineHeight = 8;
else lineHeight = 7;
pixels = new unsigned char[320 * lineHeight];
if (big) {
// Load the large panel font
// Starts at 4691 and goes 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-:.
chrPixels = new unsigned char[8 * lineHeight];
pixels[0] = BLACK;
pos = 1;
file->seek(4691, true);
} else {
for (count = 0; count < 40; count++) {
// Load the small panel font
// Starts at 6975 and goes 0123456789oo (where oo = infinity)
for (y = 0; y < lineHeight; y++)
memcpy(chrPixels + (y * 8), pixels + (count * 8) + (y * SW), 8);
pos = 0;
file->seek(6975, true);
characters[count] = createSurface(chrPixels, 8, lineHeight);
}
// RLE decompression and horizontal to vertical character rearrangement
while (pos < 320 * lineHeight) {
rle = file->loadChar();
if (rle >= 128) {
index = file->loadChar();
for (count = 0; count < (rle & 127); count++) {
pixels[(pos & 7) + ((pos / 320) * 8) +
(((pos % 320)>>3) * 8 * lineHeight)] = index;
pos++;
}
} else if (rle > 0) {
for (count = 0; count < rle; count++) {
pixels[(pos & 7) + ((pos / 320) * 8) +
(((pos % 320)>>3) * 8 * lineHeight)] = file->loadChar();
pos++;
}
} else break;
}
for (count = 0; count < 40; count++)
characters[count] = createSurface(pixels + (count * 8 * lineHeight), 8, lineHeight);
nCharacters= 40;
delete[] pixels;
delete[] chrPixels;
if (big) {
// Goes " 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-:."
// Create ASCII->font map
for (count = 0; count < 45; count++) map[count] = 39;
map[45] = 36;
map[46] = 38;
for (count = 47; count < 48; count++) map[count] = 39;
for (; count < 58; count++) map[count] = count - 48;
map[58] = 37;
for (count = 59; count < 65; count++) map[count] = 39;
for (; count < 91; count++) map[count] = count - 55;
for (; count < 97; count++) map[count] = 39;
for (; count < 123; count++) map[count] = count - 87;
for (; count < 128; count++) map[count] = 39;
for (count = 0; count < 45; count++) map[count] = 0;
map[45] = 37;
map[46] = 39;
for (count = 47; count < 48; count++) map[count] = 0;
for (; count < 58; count++) map[count] = count - 47;
map[58] = 38;
for (count = 59; count < 65; count++) map[count] = 0;
for (; count < 91; count++) map[count] = count - 54;
for (; count < 97; count++) map[count] = 0;
for (; count < 123; count++) map[count] = count - 86;
for (; count < 128; count++) map[count] = 0;
} else {
// Goes " 0123456789oo" (where oo = infinity)
// Create ASCII->font map
for (count = 0; count < 48; count++) map[count] = 12;
for (count = 0; count < 48; count++) map[count] = 0;
// Use :; to represent the infinity symbol
for (; count < 60; count++) map[count] = count - 48;
for (; count < 128; count++) map[count] = 12;
for (; count < 60; count++) map[count] = count - 47;
for (; count < 128; count++) map[count] = 0;
}
......
......@@ -43,7 +43,7 @@ class Font {
public:
Font (const char *fileName);
Font (File *file, bool big);
Font (unsigned char *pixels, bool big);
~Font ();
int showString (const char *s, int x, int y);
......
......@@ -387,7 +387,7 @@ void SkyPaletteEffect::apply (SDL_Color *shownPalette, bool direct, int mspf) {
position = viewY + (viewH << 9) - F4;
if (canvasW > 320) y = ((canvasH - 1) / 100) + 1;
if (canvasW > SW) y = ((canvasH - 1) / 100) + 1;
else y = ((canvasH - 34) / 100) + 1;
count = (((position * speed) / y) >> 20) % 255;
......
......@@ -67,18 +67,18 @@ void createScreen () {
#endif
#if defined(WIZ) || defined(GP2X)
screen = SDL_SetVideoMode(320, 240, 8, V_FULLSCREEN);
screen = SDL_SetVideoMode(320, 240, 8, FULLSCREEN_FLAGS);
#else
#ifdef FULLSCREEN_ONLY
screen = SDL_SetVideoMode(screenW, screenH, 8, V_FULLSCREEN);
screen = SDL_SetVideoMode(screenW, screenH, 8, FULLSCREEN_FLAGS);
#else
screen = SDL_SetVideoMode(screenW, screenH, 8, fullscreen? V_FULLSCREEN: V_WINDOWED);
screen = SDL_SetVideoMode(screenW, screenH, 8, fullscreen? FULLSCREEN_FLAGS: WINDOWED_FLAGS);
#endif
#endif
#ifdef SCALE
// Check that the scale will fit in the current resolution
while ( ((screenW/320 < scaleFactor) || (screenH/200 < scaleFactor)) && (scaleFactor > 1) ) {
while ( ((screenW/SW < scaleFactor) || (screenH/SH < scaleFactor)) && (scaleFactor > 1) ) {
scaleFactor--;
......
......@@ -20,8 +20,8 @@
*
*/
#ifndef _GRAPHICS_H
#define _GRAPHICS_H
#ifndef _VIDEO_H
#define _VIDEO_H
#include "OpenJazz.h"
......@@ -31,12 +31,16 @@
// Constants
#define V_WINDOWED (SDL_RESIZABLE | SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_HWPALETTE)
// Original screen dimensions
#define SW 320
#define SH 200
#define WINDOWED_FLAGS (SDL_RESIZABLE | SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_HWPALETTE)
#if defined(WIZ) || defined(GP2X)
#define V_FULLSCREEN (SDL_FULLSCREEN | SDL_SWSURFACE | SDL_HWPALETTE)
#define FULLSCREEN_FLAGS (SDL_FULLSCREEN | SDL_SWSURFACE | SDL_HWPALETTE)
#else
#define V_FULLSCREEN (SDL_FULLSCREEN | SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_HWPALETTE)
#define FULLSCREEN_FLAGS (SDL_FULLSCREEN | SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_HWPALETTE)
#endif
#ifdef SCALE
......
......@@ -434,7 +434,7 @@ void Level::playSound (int sound) {
}
void Level::setStage (int newStage) {
void Level::setStage (LevelStage newStage) {
unsigned char buffer[MTL_L_STAGE];
......@@ -456,7 +456,7 @@ void Level::setStage (int newStage) {
}
int Level::getStage () {
LevelStage Level::getStage () {
return stage;
......@@ -508,7 +508,7 @@ void Level::receive (unsigned char *buffer) {
case MT_L_STAGE:
stage = buffer[2];
stage = LevelStage(buffer[2]);
break;
......
......@@ -52,16 +52,20 @@
#define PATHS 16
#define TKEY 127 /* Tileset colour key */
// Stages
#define LS_NORMAL 0
#define LS_SUDDENDEATH 1
#define LS_END 2
// Fade delays
#define T_START 500
#define T_END 1000
// Enum
enum LevelStage {
LS_NORMAL = 0, LS_SUDDENDEATH = 1, LS_END = 2
};
// Datatypes
typedef struct {
......@@ -115,7 +119,7 @@ class Level : public BaseLevel {
fixed waterLevelTarget;
fixed waterLevelSpeed;
fixed energyBar;
int stage;
LevelStage stage;
int loadSprites (char *fileName);
int loadTiles (char *fileName);
......@@ -153,8 +157,8 @@ class Level : public BaseLevel {
void setWaterLevel (unsigned char gridY);
fixed getWaterLevel ();
void playSound (int sound);
void setStage (int stage);
int getStage ();
void setStage (LevelStage stage);
LevelStage getStage ();
Scene * createScene ();
void receive (unsigned char *buffer);
virtual int play ();
......
......@@ -364,7 +364,7 @@ void Level::draw () {
dst.x = 0;
dst.y = canvasH - 33;
SDL_BlitSurface(panel, NULL, canvas, &dst);
drawRect(0, canvasH - 1, 320, 1, BLACK);
drawRect(0, canvasH - 1, SW, 1, BLACK);
// Show panel data
......@@ -400,10 +400,12 @@ void Level::draw () {
panelSmallFont->showNumber(levelNum + 1, 196, canvasH - 13);
// Show ammo
if (localPlayer->getAmmo(false) == -1)
panelSmallFont->showString(":;", 225, canvasH - 13);
else panelSmallFont->showNumber(localPlayer->getAmmo(true), 245,
canvasH - 13);
if (localPlayer->getAmmo(false) == -1) {
panelSmallFont->showString(":", 225, canvasH - 13);
panelSmallFont->showString(";", 233, canvasH - 13);
} else panelSmallFont->showNumber(localPlayer->getAmmo(true), 245, canvasH - 13);
// Draw the health bar
......
......@@ -158,8 +158,8 @@ int loadMain (int argc, char *argv[]) {
// Default settings
// Video settings
screenW = 320;
screenH = 200;
screenW = SW;
screenH = SH;
#ifndef FULLSCREEN_ONLY
fullscreen = false;
#endif
......@@ -327,87 +327,73 @@ int loadMain (int argc, char *argv[]) {
}
// Load the panel background
panel = file->loadSurface(320, 32);
pixels = file->loadRLE(46272);
delete file;
// Load the panel's ammo graphics
sorted = new unsigned char[64 * 27];
// Create the panel background
panel = createSurface(pixels, SW, 32);
file->seek(7537, true);
pixels = file->loadRLE(64 * 27);
// De-scramble the panel's ammo graphics
sorted = new unsigned char[64 * 27];
for (y = 0; y < 27; y++) {
for (x = 0; x < 64; x++)
sorted[(y * 64) + x] = pixels[(y * 64) + (x >> 2) + ((x & 3) << 4)];
sorted[(y * 64) + x] = pixels[(y * 64) + (x >> 2) + ((x & 3) << 4) + (55 * 320)];
}
panelAmmo[0] = createSurface(sorted, 64, 27);
delete[] pixels;
file->seek(8264, true);
pixels = file->loadRLE(64 * 27);
for (y = 0; y < 27; y++) {
for (x = 0; x < 64; x++)
sorted[(y * 64) + x] = pixels[(y * 64) + (x >> 2) + ((x & 3) << 4)];
sorted[(y * 64) + x] = pixels[(y * 64) + (x >> 2) + ((x & 3) << 4) + (61 * 320)];
}
panelAmmo[1] = createSurface(sorted, 64, 27);
delete[] pixels;
file->seek(9550, true);
pixels = file->loadRLE(64 * 27);
for (y = 0; y < 27; y++) {
for (x = 0; x < 64; x++)
sorted[(y * 64) + x] = pixels[(y * 64) + (x >> 2) + ((x & 3) << 4)];
sorted[(y * 64) + x] = pixels[(y * 64) + (x >> 2) + ((x & 3) << 4) + (68 * 320)];
}
panelAmmo[2] = createSurface(sorted, 64, 27);
delete[] pixels;
file->seek(11060, true);
pixels = file->loadRLE(64 * 27);
for (y = 0; y < 27; y++) {
for (x = 0; x < 64; x++)
sorted[(y * 64) + x] = pixels[(y * 64) + (x >> 2) + ((x & 3) << 4)];
sorted[(y * 64) + x] = pixels[(y * 64) + (x >> 2) + ((x & 3) << 4) + (74 * 320)];
}
panelAmmo[3] = createSurface(sorted, 64, 27);
delete[] pixels;
file->seek(12258, true);
pixels = file->loadRLE(64 * 27);
for (y = 0; y < 27; y++) {
for (x = 0; x < 64; x++)
sorted[(y * 64) + x] = pixels[(y * 64) + (x >> 2) + ((x & 3) << 4)];
sorted[(y * 64) + x] = pixels[(y * 64) + (x >> 2) + ((x & 3) << 4) + (86 * 320)];
}
panelAmmo[4] = createSurface(sorted, 64, 27);
delete[] pixels;
delete[] sorted;
// Load fonts
panelBigFont = NULL;
panelSmallFont = NULL;
font2 = NULL;
......@@ -417,8 +403,8 @@ int loadMain (int argc, char *argv[]) {
try {
panelBigFont = new Font(file, true);
panelSmallFont = new Font(file, false);
panelBigFont = new Font(pixels + (40 * 320), true);
panelSmallFont = new Font(pixels + (48 * 320), false);
font2 = new Font("font2.0fn");
fontbig = new Font("fontbig.0fn");
fontiny = new Font("fontiny.0fn");
......@@ -434,6 +420,8 @@ int loadMain (int argc, char *argv[]) {
if (fontiny) delete fontiny;
if (fontmn1) delete fontmn1;
delete[] pixels;
SDL_FreeSurface(panel);
SDL_FreeSurface(panelAmmo[0]);
SDL_FreeSurface(panelAmmo[1]);
......@@ -447,14 +435,11 @@ int loadMain (int argc, char *argv[]) {
delete firstPath;
delete file;
return e;
}
delete file;
delete[] pixels;
// Establish arbitrary timing
......@@ -578,7 +563,7 @@ void freeMain () {
}
int loop (int type) {
int loop (LoopType type) {
SDL_Color shownPalette[256];
SDL_Event event;
......
......@@ -36,7 +36,7 @@
#include "io/sound.h"
int Menu::newGameDifficulty (int mode, int levelNum, int worldNum) {
int Menu::newGameDifficulty (GameModeType mode, int levelNum, int worldNum) {
const char *options[4] = {"easy", "medium", "hard", "turbo"};
char *firstLevel;
......@@ -153,7 +153,7 @@ int Menu::newGameDifficulty (int mode, int levelNum, int worldNum) {
}
int Menu::newGameLevel (int mode) {
int Menu::newGameLevel (GameModeType mode) {
int option, worldNum, levelNum;
......@@ -220,7 +220,7 @@ int Menu::newGameLevel (int mode) {
}
int Menu::newGameEpisode (int mode) {
int Menu::newGameEpisode (GameModeType mode) {
const char *options[12] = {"episode 1", "episode 2", "episode 3",
"episode 4", "episode 5", "episode 6", "episode a", "episode b",
......
......@@ -89,8 +89,7 @@ int Menu::main () {
} else {
if (newGameEpisode(suboption) == E_QUIT)
return E_QUIT;
if (newGameEpisode(GameModeType(suboption)) == E_QUIT) return E_QUIT;
}
......@@ -237,8 +236,8 @@ int Menu::main () {
dst.y = canvasH - (canvasH >> 2);
SDL_BlitSurface(screens[14], NULL, canvas, &dst);
dst.x = (canvasW - 320) >> 1;
dst.y = (canvasH - 200) >> 1;
dst.x = (canvasW - SW) >> 1;
dst.y = (canvasH - SH) >> 1;
SDL_BlitSurface(screens[0], NULL, canvas, &dst);
switch (option) {
......@@ -299,8 +298,8 @@ int Menu::main () {
}
dst.x = ((canvasW - 320) >> 1) + src.x;
dst.y = ((canvasH - 200) >> 1) + src.y;
dst.x = ((canvasW - SW) >> 1) + src.x;
dst.y = ((canvasH - SH) >> 1) + src.y;
SDL_BlitSurface(screens[1], &src, canvas, &dst);
}
......
......@@ -84,8 +84,8 @@ Menu::Menu () {
// Load the main menu graphics
file->loadPalette(palettes[0]);
screens[0] = file->loadSurface(320, 200);
screens[1] = file->loadSurface(320, 200);
screens[0] = file->loadSurface(SW, SH);
screens[1] = file->loadSurface(SW, SH);
if (file->getSize() > 200000) {
......@@ -98,8 +98,8 @@ Menu::Menu () {
SDL_FreeSurface(screens[0]);
SDL_FreeSurface(screens[1]);
file->loadPalette(palettes[0]);
screens[0] = file->loadSurface(320, 200);
screens[1] = file->loadSurface(320, 200);
screens[0] = file->loadSurface(SW, SH);
screens[1] = file->loadSurface(SW, SH);
} else {
......@@ -117,7 +117,7 @@ Menu::Menu () {
// Load the difficulty graphics
file->loadPalette(palettes[1]);
screens[2] = file->loadSurface(320, 200);
screens[2] = file->loadSurface(SW, SH);
SDL_SetColorKey(screens[2], SDL_SRCCOLORKEY, 0);
// Default difficulty setting
......
......@@ -8,7 +8,7 @@
* Part of the OpenJazz project
*
*
* Copyright (c) 2005-2009 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
* OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0
......@@ -24,6 +24,8 @@
#define _MENU_H
#include "game/gamemode.h"
#include "OpenJazz.h"
#include <SDL/SDL.h>
......@@ -46,9 +48,9 @@ class Menu {
int message (const char *text);
int generic (const char **optionNames, int options, int *chosen);
int textInput (const char *request, char **text);
int newGameDifficulty (int mode, int levelNum, int worldNum);
int newGameLevel (int mode);
int newGameEpisode (int mode);
int newGameDifficulty (GameModeType mode, int levelNum, int worldNum);
int newGameLevel (GameModeType mode);
int newGameEpisode (GameModeType mode);
int joinGame ();
int loadGame ();
int setupKeyboard ();
......
......@@ -267,10 +267,10 @@ int Menu::setupResolution () {
#ifndef FULLSCREEN_ONLY
if (!fullscreen)
resolutions = SDL_ListModes(NULL, V_WINDOWED);
resolutions = SDL_ListModes(NULL, WINDOWED_FLAGS);
else
#endif
resolutions = SDL_ListModes(NULL, V_FULLSCREEN);
resolutions = SDL_ListModes(NULL, FULLSCREEN_FLAGS);
#if defined(WIZ) || defined(GP2X)
......@@ -283,8 +283,9 @@ int Menu::setupResolution () {
maxH = 1200;
} else {
maxW = 320;
maxH = 200;
maxW = SW;
maxH = SH;
for (count = 0; resolutions[count] != NULL; count++) {
......@@ -360,7 +361,7 @@ int Menu::setupResolution () {
if (controls.release(C_DOWN)) {
if ((!dimension) && (screenW > 320)) {
if ((!dimension) && (screenW > SW)) {
count = 13;
......@@ -371,7 +372,7 @@ int Menu::setupResolution () {
}
if (dimension && (screenH > 200)) {
if (dimension && (screenH > SH)) {
count = 16;
......
......@@ -870,9 +870,9 @@ void Player::receive (unsigned char *buffer) {
}
int Player::reacted (unsigned int ticks) {
PlayerReaction Player::reacted (unsigned int ticks) {
int oldReaction;
PlayerReaction oldReaction;
if ((reaction != PR_NONE) && (reactionTime < ticks)) {
......
......@@ -77,16 +77,6 @@
#define PA_RSPRING 36
#define PA_LSPRING 37 /* Surely these are the wrong way round? */
// Player facing
#define PF_LEFT 0
#define PF_RIGHT 1
// Player reactions
#define PR_NONE 0
#define PR_HURT 1
#define PR_KILLED 2
#define PR_INVINCIBLE 3
// Player reaction times
#define PRT_HURT 1000
#define PRT_HURTANIM 200
......@@ -159,6 +149,15 @@
#define PCONTROLS 8 /* Number of player controls. */
// Enum
enum PlayerReaction {
PR_NONE, PR_HURT, PR_KILLED, PR_INVINCIBLE
};
// Classes
class Anim;
......@@ -187,7 +186,7 @@ class Player : public Movable {
unsigned char eventY; /* Position of an event (spring, platform, bridge) */
int event; /* 0 = none, 1 = spring, 2 = float up, 3 = platform, 4 = bridge */
int lookTime; /* Negative if looking up, positive if looking down, 0 if neither */
int reaction;
PlayerReaction reaction;
unsigned int reactionTime;
int fireSpeed;
unsigned int fireTime;
......@@ -241,7 +240,7 @@ class Player : public Movable {
void bonusStep (unsigned int ticks, int msps);
void view (unsigned int ticks, int mspf);
void draw (unsigned int ticks, int change);
int reacted (unsigned int ticks);
PlayerReaction reacted (unsigned int ticks);
};
......
......@@ -195,7 +195,7 @@ int Scene::play () {
unsigned int lastTicks = globalTicks;
int newpage = true;
int fadein = false;
SDL_Rect textRect = {0,0,320,200};
SDL_Rect textRect = {0, 0, SW, SH};
while (true) {
......@@ -230,8 +230,8 @@ int Scene::play () {
textRect.x = 0;
textRect.y = 0;
textRect.w = 320;
textRect.h = 200;
textRect.w = SW;
textRect.h = SH;
ScenePalette *palette = palettes;
while (palette && (palette->id != pages[sceneIndex].paletteIndex)) palette = palette->next;
......@@ -260,8 +260,8 @@ int Scene::play () {
if (image) {
dst.x = (pages[sceneIndex].bgPos[bg] & 65535)*2 + (canvasW - 320) >> 1;
dst.y = ((pages[sceneIndex].bgPos[bg] & (~65535))>>16)*2 + (canvasH - 200) >> 1;
dst.x = (pages[sceneIndex].bgPos[bg] & 65535)*2 + (canvasW - SW) >> 1;
dst.y = ((pages[sceneIndex].bgPos[bg] & (~65535))>>16)*2 + (canvasH - SH) >> 1;
SDL_BlitSurface(image->image, NULL, canvas, &dst);
}
......@@ -315,8 +315,8 @@ int Scene::play () {
}
xOffset = ((canvasW - 320) >> 1) + textRect.x + x;
yOffset = ((canvasH - 200) >> 1) + textRect.y + y;
xOffset = ((canvasW - SW) >> 1) + textRect.x + x;
yOffset = ((canvasH - SH) >> 1) + textRect.y + y;
switch (text->alignment) {
......
......@@ -116,7 +116,7 @@ void Scene::loadAni (File *f, int dataIndex) {
// Skip back size header, this is read by the surface reader
f->seek(-2, false);
SDL_Surface *image = f->loadSurface(320, 200);
SDL_Surface *image = f->loadSurface(SW, SH);
SDL_BlitSurface(image, NULL, canvas, NULL);
SDL_FreeSurface(image);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment