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