Commit 6a0cbf3f authored by alistert's avatar alistert

Reverted to stdio.h due to portability issues. Created Video class. Refactored linked lists.

parent 4bca7986
......@@ -93,7 +93,7 @@ void BaseLevel::timeCalcs () {
}
void BaseLevel::drawStats (int stats) {
void BaseLevel::drawStats (int stats, unsigned char bg) {
int count, width;
......@@ -102,20 +102,20 @@ void BaseLevel::drawStats (int stats) {
if (stats & S_SCREEN) {
#ifdef SCALE
if (scaleFactor > 1)
drawRect(canvasW - 84, 11, 80, 37, BLACK);
if (video.getScaleFactor() > 1)
drawRect(canvasW - 84, 11, 80, 37, bg);
else
#endif
drawRect(canvasW - 84, 11, 80, 25, BLACK);
drawRect(canvasW - 84, 11, 80, 25, bg);
panelBigFont->showNumber(screenW, canvasW - 52, 14);
panelBigFont->showNumber(video.getWidth(), canvasW - 52, 14);
panelBigFont->showString("x", canvasW - 48, 14);
panelBigFont->showNumber(screenH, canvasW - 12, 14);
panelBigFont->showNumber(video.getHeight(), canvasW - 12, 14);
panelBigFont->showString("fps", canvasW - 76, 26);
panelBigFont->showNumber((int)smoothfps, canvasW - 12, 26);
#ifdef SCALE
if (scaleFactor > 1) {
if (video.getScaleFactor() > 1) {
panelBigFont->showNumber(canvasW, canvasW - 52, 38);
panelBigFont->showString("x", canvasW - 48, 39);
......@@ -136,7 +136,7 @@ void BaseLevel::drawStats (int stats) {
if (panelBigFont->getStringWidth(players[count].getName()) > width)
width = panelBigFont->getStringWidth(players[count].getName());
drawRect((canvasW >> 1) - 48, 11, width + 57, (nPlayers * 12) + 1, BLACK);
drawRect((canvasW >> 1) - 48, 11, width + 57, (nPlayers * 12) + 1, bg);
for (count = 0; count < nPlayers; count++) {
......
......@@ -68,7 +68,7 @@ class BaseLevel {
LevelStage stage;
void timeCalcs ();
void drawStats (int stats);
void drawStats (int stats, unsigned char bg);
public:
BaseLevel ();
......
......@@ -197,16 +197,16 @@ Bonus::Bonus (char * fileName, unsigned char diff) {
// Palette animations
// Free any existing palette effects
if (firstPE) delete firstPE;
if (paletteEffects) delete paletteEffects;
// Spinny whirly thing
firstPE = new RotatePaletteEffect(112, 16, F32, NULL);
paletteEffects = new RotatePaletteEffect(112, 16, F32, NULL);
// Track sides
firstPE = new RotatePaletteEffect(192, 16, F32, firstPE);
paletteEffects = new RotatePaletteEffect(192, 16, F32, paletteEffects);
// Bouncy things
firstPE = new RotatePaletteEffect(240, 16, -F32, firstPE);
paletteEffects = new RotatePaletteEffect(240, 16, -F32, paletteEffects);
// Adjust fontsFont to use bonus level palette
......@@ -221,10 +221,10 @@ Bonus::Bonus (char * fileName, unsigned char diff) {
Bonus::~Bonus () {
// Free the palette effects
if (firstPE) {
if (paletteEffects) {
delete firstPE;
firstPE = NULL;
delete paletteEffects;
paletteEffects = NULL;
}
......@@ -457,7 +457,7 @@ int Bonus::play () {
returnTime = 0;
usePalette(palette);
video.setPalette(palette);
while (true) {
......@@ -502,16 +502,16 @@ int Bonus::play () {
if (!gameMode) {
// Don't want palette effects in setup menu
levelPE = firstPE;
firstPE = NULL;
levelPE = paletteEffects;
paletteEffects = NULL;
if (menu->setup() == E_QUIT) return E_QUIT;
// Restore level palette
usePalette(palette);
video.setPalette(palette);
// Restore palette effects
firstPE = levelPE;
paletteEffects = levelPE;
}
......@@ -552,7 +552,7 @@ int Bonus::play () {
else if (count) {
stage = LS_END;
firstPE = new WhiteOutPaletteEffect(T_BONUS_END, firstPE);
paletteEffects = new WhiteOutPaletteEffect(T_BONUS_END, paletteEffects);
returnTime = ticks + T_BONUS_END;
}
......@@ -570,7 +570,7 @@ int Bonus::play () {
fontsFont->showString("pause", (canvasW >> 1) - 44, 32);
// Draw statistics
drawStats(stats);
drawStats(stats, 0);
// Draw the menu
if (pmenu) {
......
......@@ -33,7 +33,6 @@
#include "menu/menu.h"
#include "player/player.h"
#include <iostream>
#include <string.h>
......@@ -107,7 +106,7 @@ ClientGame::ClientGame (char* address) {
}
std::cout << "Connected to server (version " << int(buffer[2]) << ").\n";
printf("Connected to server (version %d).\n", buffer[2]);
// Copy game parameters
mode = GameModeType(buffer[3]);
......@@ -116,8 +115,7 @@ ClientGame::ClientGame (char* address) {
nPlayers = buffer[6];
clientID = buffer[7];
std::cout << "Game mode " << mode << ", difficulty " << difficulty << ", " <<
nPlayers << " of " << maxPlayers << " players.\n";
printf("Game mode %d, difficulty %d, %d of %d players.\n", mode, difficulty, nPlayers, maxPlayers);
if (nPlayers > maxPlayers) {
......@@ -249,14 +247,14 @@ int ClientGame::setLevel (char* fileName) {
int ret;
// Free the palette effects
if (firstPE) {
if (paletteEffects) {
delete firstPE;
firstPE = NULL;
delete paletteEffects;
paletteEffects = NULL;
}
usePalette(menu->palettes[1]);
video.setPalette(menu->palettes[1]);
// Wait for level data to start arriving
while (!file && levelFile) {
......@@ -398,7 +396,7 @@ int ClientGame::step (unsigned int ticks) {
if ((recvBuffer[1] == MT_G_PJOIN) &&
(recvBuffer[3] < maxPlayers)) {
std::cout << "Player " << int(recvBuffer[3]) << " joined the game.\n";
printf("Player %d joined the game.\n", recvBuffer[3]);
// Add the new player, and any that have been missed
......@@ -408,8 +406,7 @@ int ClientGame::step (unsigned int ticks) {
recvBuffer + 5, recvBuffer[4]);
resetPlayer(players + count, false);
std::cout << "Player " << count << " joined team " <<
recvBuffer[4] << ".\n";
printf("Player %d joined team %d.\n", count, recvBuffer[4]);
}
......@@ -423,7 +420,7 @@ int ClientGame::step (unsigned int ticks) {
if ((recvBuffer[1] == MT_G_PQUIT) &&
(recvBuffer[2] < nPlayers)) {
std::cout << "Player " << int(recvBuffer[2]) << " left the game.\n";
printf("Player %d left the game.\n", recvBuffer[2]);
// Remove the player
......
......@@ -32,7 +32,6 @@
#include "level/level.h"
#include "player/player.h"
#include <iostream>
#include <string.h>
......@@ -248,8 +247,7 @@ int ServerGame::step (unsigned int ticks) {
if ((recvBuffers[count][1] == MT_G_PJOIN) &&
(clientPlayer[count] == -1)) {
std::cout << "Player " << nPlayers << " (client " <<
count <<") joined the game.\n";
printf("Player %d (client %d) joined the game.\n", nPlayers, count);
// Set up the new player
......@@ -261,8 +259,7 @@ int ServerGame::step (unsigned int ticks) {
recvBuffers[count][4]);
players[nPlayers].reset();
std::cout << "Player " << nPlayers << " joined team " <<
recvBuffers[count][4] << ".\n";
printf("Player %d joined team %d.\n", nPlayers, recvBuffers[count][4]);
recvBuffers[count][3] = clientPlayer[count] =
nPlayers;
......@@ -330,7 +327,7 @@ int ServerGame::step (unsigned int ticks) {
if (clientSock[count] != -1) {
std::cout << "Client " << count << " connected.\n";
printf("Client %d connected.\n", count);
clientPlayer[count] = -1;
received[count] = 0;
......@@ -385,8 +382,7 @@ int ServerGame::step (unsigned int ticks) {
if (!(net->isConnected(clientSock[count]))) {
std::cout << "Client " << count << " disconnected (code: " <<
net->getError() << ").\n";
printf("Client %d disconnected (code: %d).\n", count, net->getError());
// Disconnect client
net->close(clientSock[count]);
......@@ -396,8 +392,7 @@ int ServerGame::step (unsigned int ticks) {
// Remove the client's player
std::cout << "Player " << clientPlayer[count] <<
" (client " << count << ") left the game.\n";
printf("Player %d (client %d) left the game.\n", clientPlayer[count], count);
nPlayers--;
......
......@@ -49,7 +49,7 @@ File::File (const char* name, bool write) {
File::~File () {
stream.close();
fclose(file);
#ifdef VERBOSE
log("Closed file", filePath);
......@@ -68,10 +68,9 @@ bool File::open (const char* path, const char* name, bool write) {
filePath = createString(path, name);
// Open the file from the path
stream.clear();
stream.open(filePath, (write ? std::ios::out: std::ios::in) | std::ios::binary);
file = fopen(filePath, write ? "wb": "rb");
if (stream.is_open() && stream.good()) {
if (file) {
#ifdef VERBOSE
log("Opened file", filePath);
......@@ -89,30 +88,30 @@ bool File::open (const char* path, const char* name, bool write) {
int File::getSize () {
int pos, size;
pos = stream.tellg();
stream.seekg(0, std::ios::end);
size = stream.tellg();
stream.seekg(pos, std::ios::beg);
int pos, size;
pos = ftell(file);
fseek(file, 0, SEEK_END);
size = ftell(file);
fseek(file, pos, SEEK_SET);
return size;
return size;
}
int File::tell () {
return stream.tellg();
return ftell(file);
}
void File::seek (int offset, bool reset) {
stream.seekg(offset, reset ? std::ios::beg: std::ios::cur);
fseek(file, offset, reset ? SEEK_SET: SEEK_CUR);
return;
......@@ -120,14 +119,14 @@ void File::seek (int offset, bool reset) {
unsigned char File::loadChar () {
return stream.get();
return fgetc(file);
}
void File::storeChar (unsigned char val) {
stream.put(val);
fputc(val, file);
return;
......@@ -138,8 +137,8 @@ unsigned short int File::loadShort () {
unsigned short int val;
val = stream.get();
val += stream.get() << 8;
val = fgetc(file);
val += fgetc(file) << 8;
return val;
......@@ -148,22 +147,22 @@ unsigned short int File::loadShort () {
void File::storeShort (unsigned short int val) {
stream.put(val & 255);
stream.put(val >> 8);
return;
}
signed long int File::loadInt () {
unsigned long int val;
val = stream.get();
val += stream.get() << 8;
val += stream.get() << 16;
val += stream.get() << 24;
fputc(val & 255, file);
fputc(val >> 8, file);
return;
}
signed long int File::loadInt () {
unsigned long int val;
val = fgetc(file);
val += fgetc(file) << 8;
val += fgetc(file) << 16;
val += fgetc(file) << 24;
return *((signed long int *)&val);
......@@ -176,23 +175,23 @@ void File::storeInt (signed long int val) {
uval = *((unsigned long int *)&val);
stream.put(uval & 255);
stream.put((uval >> 8) & 255);
stream.put((uval >> 16) & 255);
stream.put(uval >> 24);
return;
}
unsigned char* File::loadBlock (int length) {
unsigned char *buffer;
buffer = new unsigned char[length];
stream.read((char *)buffer, length);
fputc(uval & 255, file);
fputc((uval >> 8) & 255, file);
fputc((uval >> 16) & 255, file);
fputc(uval >> 24, file);
return;
}
unsigned char * File::loadBlock (int length) {
unsigned char *buffer;
buffer = new unsigned char[length];
fread(buffer, 1, length, file);
return buffer;
......@@ -205,9 +204,9 @@ unsigned char* File::loadRLE (int length) {
int rle, pos, byte, count, next;
// Determine the offset that follows the block
next = stream.get();
next += stream.get() << 8;
next += stream.tellg();
next = fgetc(file);
next += fgetc(file) << 8;
next += ftell(file);
buffer = new unsigned char[length];
......@@ -215,11 +214,11 @@ unsigned char* File::loadRLE (int length) {
while (pos < length) {
rle = stream.get();
rle = fgetc(file);
if (rle & 128) {
byte = stream.get();
byte = fgetc(file);
for (count = 0; count < (rle & 127); count++) {
......@@ -232,16 +231,16 @@ unsigned char* File::loadRLE (int length) {
for (count = 0; count < rle; count++) {
buffer[pos++] = stream.get();
buffer[pos++] = fgetc(file);
if (pos >= length) break;
}
} else buffer[pos++] = stream.get();
} else buffer[pos++] = fgetc(file);
}
stream.seekg(next, std::ios::beg);
fseek(file, next, SEEK_SET);
return buffer;
......@@ -252,42 +251,42 @@ void File::skipRLE () {
int next;
next = stream.get();
next += stream.get() << 8;
stream.seekg(next, std::ios::cur);
return;
}
char* File::loadString () {
char* string;
int length, count;
length = stream.get();
if (length) {
string = new char[length + 1];
stream.read(string, length);
} else {
// If the length is not given, assume it is an 8.3 file name
string = new char[13];
next = fgetc(file);
next += fgetc(file) << 8;
for (count = 0; count < 9; count++) {
string[count] = stream.get();
fseek(file, next, SEEK_CUR);
return;
}
char * File::loadString () {
char *string;
int length, count;
length = fgetc(file);
if (length) {
string = new char[length + 1];
fread(string, 1, length, file);
} else {
// If the length is not given, assume it is an 8.3 file name
string = new char[13];
for (count = 0; count < 9; count++) {
string[count] = fgetc(file);
if (string[count] == '.') {
string[++count] = stream.get();
string[++count] = stream.get();
string[++count] = stream.get();
string[++count] = fgetc(file);
string[++count] = fgetc(file);
string[++count] = fgetc(file);
count++;
break;
......
......@@ -27,7 +27,7 @@
#include "OpenJazz.h"
#include <SDL/SDL.h>
#include <fstream>
#include <stdio.h>
// Classes
......@@ -35,8 +35,8 @@
class File {
private:
std::fstream stream;
char* filePath;
FILE* file;
char* filePath;
bool open (const char* path, const char* name, bool write);
......
......@@ -478,7 +478,7 @@ void Font::restorePalette () {
int count;
for (count = 0; count < nCharacters; count++)
::restorePalette(characters[count]);
video.restoreSurfacePalette(characters[count]);
return;
......
This diff is collapsed.
......@@ -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
......@@ -49,13 +49,13 @@
class PaletteEffect {
protected:
PaletteEffect *next; // Next effect to use
PaletteEffect* next; // Next effect to use
public:
PaletteEffect (PaletteEffect * nextPE);
PaletteEffect (PaletteEffect* nextPE);
virtual ~PaletteEffect ();
virtual void apply (SDL_Color *shownPalette, bool direct, int mspf);
virtual void apply (SDL_Color* shownPalette, bool direct, int mspf);
};
......@@ -67,9 +67,9 @@ class WhiteInPaletteEffect : public PaletteEffect {
fixed whiteness;
public:
WhiteInPaletteEffect (int newDuration, PaletteEffect * nextPE);
WhiteInPaletteEffect (int newDuration, PaletteEffect* nextPE);
void apply (SDL_Color *shownPalette, bool direct, int mspf);
void apply (SDL_Color* shownPalette, bool direct, int mspf);
};
......@@ -81,9 +81,9 @@ class FadeInPaletteEffect : public PaletteEffect {
fixed blackness;
public:
FadeInPaletteEffect (int newDuration, PaletteEffect * nextPE);
FadeInPaletteEffect (int newDuration, PaletteEffect* nextPE);
void apply (SDL_Color *shownPalette, bool direct, int mspf);
void apply (SDL_Color* shownPalette, bool direct, int mspf);
};
......@@ -95,9 +95,9 @@ class WhiteOutPaletteEffect : public PaletteEffect {
fixed whiteness;
public:
WhiteOutPaletteEffect (int newDuration, PaletteEffect * nextPE);
WhiteOutPaletteEffect (int newDuration, PaletteEffect* nextPE);
void apply (SDL_Color *shownPalette, bool direct, int mspf);
void apply (SDL_Color* shownPalette, bool direct, int mspf);
};
......@@ -109,9 +109,9 @@ class FadeOutPaletteEffect : public PaletteEffect {
fixed blackness;
public:
FadeOutPaletteEffect (int newDuration, PaletteEffect * nextPE);
FadeOutPaletteEffect (int newDuration, PaletteEffect* nextPE);
void apply (SDL_Color *shownPalette, bool direct, int mspf);
void apply (SDL_Color* shownPalette, bool direct, int mspf);
};
......@@ -125,9 +125,9 @@ class FlashPaletteEffect : public PaletteEffect {
public:
FlashPaletteEffect (unsigned char newRed, unsigned char newGreen,
unsigned char newBlue, int newDuration, PaletteEffect * nextPE);
unsigned char newBlue, int newDuration, PaletteEffect* nextPE);
void apply (SDL_Color *shownPalette, bool direct, int mspf);
void apply (SDL_Color* shownPalette, bool direct, int mspf);
};
......@@ -135,18 +135,16 @@ class FlashPaletteEffect : public PaletteEffect {
class RotatePaletteEffect : public PaletteEffect {
private:
unsigned char first; /* The first palette index affected by the
effect */
int amount; /* The number of (consecutive) palette indices
affected by the effect */
unsigned char first; /* The first palette index affected */
int amount; /* The number of (consecutive) palette indices affected */
fixed speed; // Rotations per second
fixed position;
public:
RotatePaletteEffect (unsigned char newFirst, int newAmount,
fixed newSpeed, PaletteEffect * nextPE);
fixed newSpeed, PaletteEffect* nextPE);
void apply (SDL_Color *shownPalette, bool direct, int mspf);
void apply (SDL_Color* shownPalette, bool direct, int mspf);
};
......@@ -155,17 +153,15 @@ class SkyPaletteEffect : public PaletteEffect {
private:
SDL_Color *skyPalette;
unsigned char first; /* The first palette index affected by the
effect */
int amount; /* The number of (consecutive) palette
indices affected by the effect */
unsigned char first; /* The first palette index affected */
int amount; /* The number of (consecutive) palette indices affected */
fixed speed; // Relative Y speed - as in Jazz 2
public:
SkyPaletteEffect (unsigned char newFirst, int newAmount,
fixed newSpeed, SDL_Color *newSkyPalette, PaletteEffect * nextPE);
fixed newSpeed, SDL_Color* newSkyPalette, PaletteEffect* nextPE);
void apply (SDL_Color *shownPalette, bool direct, int mspf);
void apply (SDL_Color* shownPalette, bool direct, int mspf);
};
......@@ -173,17 +169,15 @@ class SkyPaletteEffect : public PaletteEffect {
class P2DPaletteEffect : public PaletteEffect {
private:
unsigned char first; /* The first palette index affected by the
effect */
int amount; /* The number of (consecutive) palette indices
affected by the effect */
unsigned char first; /* The first palette index affected */
int amount; /* The number of (consecutive) palette indices affected */
fixed speed; // Relative X & Y speed - as in Jazz 2
public:
P2DPaletteEffect (unsigned char newFirst, int newAmount,
fixed newSpeed, PaletteEffect * nextPE);
fixed newSpeed, PaletteEffect* nextPE);
void apply (SDL_Color *shownPalette, bool direct, int mspf);
void apply (SDL_Color* shownPalette, bool direct, int mspf);
};
......@@ -191,17 +185,15 @@ class P2DPaletteEffect : public PaletteEffect {
class P1DPaletteEffect : public PaletteEffect {
private:
unsigned char first; /* The first palette index affected by the
effect */
int amount; /* The number of (consecutive) palette indices
affected by the effect */
unsigned char first; /* The first palette index affected */
int amount; /* The number of (consecutive) palette indices affected */
fixed speed; // Relative X & Y speed - as in Jazz 2
public:
P1DPaletteEffect (unsigned char newFirst, int newAmount,
fixed newSpeed, PaletteEffect * nextPE);
fixed newSpeed, PaletteEffect* nextPE);
void apply (SDL_Color *shownPalette, bool direct, int mspf);
void apply (SDL_Color* shownPalette, bool direct, int mspf);
};
......@@ -209,20 +201,19 @@ class P1DPaletteEffect : public PaletteEffect {
class WaterPaletteEffect : public PaletteEffect {
private:
fixed depth; /* Number of pixels between water surface and total
darkness */
fixed depth; /* Number of pixels between water surface and total darkness */
public:
WaterPaletteEffect (fixed newDepth, PaletteEffect * nextPE);
WaterPaletteEffect (fixed newDepth, PaletteEffect* nextPE);
void apply (SDL_Color *shownPalette, bool direct, int mspf);
void apply (SDL_Color* shownPalette, bool direct, int mspf);
};
// Variable
EXTERN PaletteEffect *firstPE;
EXTERN PaletteEffect* paletteEffects;
#endif
......
......@@ -118,7 +118,7 @@ void Sprite::flashPalette (int index) {
void Sprite::restorePalette () {
::restorePalette(pixels);
video.restoreSurfacePalette(pixels);
return;
......
......@@ -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
......@@ -30,7 +30,7 @@
// Constant
#define SKEY 254 /* Sprite colour key */
#define SKEY 254 /* Sprite colour key */
// Class
......@@ -38,7 +38,7 @@
class Sprite {
private:
SDL_Surface *pixels;
SDL_Surface* pixels;
public:
unsigned char xOffset;
......@@ -48,11 +48,11 @@ class Sprite {
~Sprite ();
void clearPixels ();
void setPixels (unsigned char *data, int width, int height);
void setPixels (unsigned char* data, int width, int height);
int getWidth ();
int getHeight ();
void draw (int x, int y);
void setPalette (SDL_Color *palette, int start, int amount);
void setPalette (SDL_Color* palette, int start, int amount);
void flashPalette (int index);
void restorePalette ();
......
......@@ -26,11 +26,16 @@
*/
#include "paletteeffects.h"
#include "video.h"
#ifdef SCALE
#include "io/gfx/scale2x/scalebit.h"
#endif
#include <string.h>
unsigned char * sortPixels (unsigned char * pixels, int length) {
unsigned char *sorted;
......@@ -50,7 +55,7 @@ unsigned char * sortPixels (unsigned char * pixels, int length) {
}
SDL_Surface * createSurface (unsigned char * pixels, int width, int height) {
SDL_Surface* createSurface (unsigned char * pixels, int width, int height) {
SDL_Surface *ret;
int y;
......@@ -59,7 +64,7 @@ SDL_Surface * createSurface (unsigned char * pixels, int width, int height) {
ret = SDL_CreateRGBSurface(SDL_HWSURFACE, width, height, 8, 0, 0, 0, 0);
// Set the surface's palette
SDL_SetPalette(ret, SDL_LOGPAL, logicalPalette, 0, 256);
video.restoreSurfacePalette(ret);
if (pixels) {
......@@ -78,8 +83,38 @@ SDL_Surface * createSurface (unsigned char * pixels, int width, int height) {
}
void createScreen () {
Video::Video () {
int count;
screen = NULL;
screenW = SW;
screenH = SH;
#ifdef SCALE
scaleFactor = 1;
#endif
#ifndef FULLSCREEN_ONLY
fullscreen = false;
#endif
// Generate the logical palette
for (count = 0; count < 256; count++)
logicalPalette[count].r = logicalPalette[count].g =
logicalPalette[count].b = count;
currentPalette = logicalPalette;
return;
}
bool Video::create (int width, int height) {
screenW = width;
screenH = height;
#ifdef SCALE
if (canvas != screen) SDL_FreeSurface(canvas);
......@@ -94,6 +129,9 @@ void createScreen () {
screen = SDL_SetVideoMode(screenW, screenH, 8, fullscreen? FULLSCREEN_FLAGS: WINDOWED_FLAGS);
#endif
#endif
if (!screen) return false;
#ifdef SCALE
// Check that the scale will fit in the current resolution
......@@ -121,8 +159,7 @@ void createScreen () {
#endif
#if !(defined(WIZ) || defined(GP2X))
SDL_SetPalette(screen, SDL_LOGPAL, logicalPalette, 0, 256);
SDL_SetPalette(screen, SDL_PHYSPAL, currentPalette, 0, 256);
expose();
#endif
......@@ -137,12 +174,12 @@ void createScreen () {
// TODO: Find a better way
fakePalette = true;
return;
return true;
}
void usePalette (SDL_Color *palette) {
void Video::setPalette (SDL_Color *palette) {
// Make palette changes invisible until the next draw. Hopefully.
clearScreen(SDL_MapRGB(screen->format, 0, 0, 0));
......@@ -156,22 +193,152 @@ void usePalette (SDL_Color *palette) {
return;
}
SDL_Color* Video::getPalette () {
return currentPalette;
}
void Video::changePalette (SDL_Color *palette, unsigned char first, unsigned char amount) {
SDL_SetPalette(screen, SDL_PHYSPAL, palette, first, amount);
return;
}
void restorePalette (SDL_Surface *surface) {
SDL_SetPalette(surface, SDL_LOGPAL, logicalPalette, 0, 256);
return;
void Video::restoreSurfacePalette (SDL_Surface* surface) {
SDL_SetPalette(surface, SDL_LOGPAL, logicalPalette, 0, 256);
return;
}
int Video::getWidth () {
return screenW;
}
int Video::getHeight () {
return screenH;
}
int Video::getScaleFactor () {
return scaleFactor;
}
void Video::setScaleFactor (int newScaleFactor) {
scaleFactor = newScaleFactor;
if (screen) create(screenW, screenH);
return;
}
#ifndef FULLSCREEN_ONLY
bool Video::isFullscreen () {
return fullscreen;
}
#endif
#ifndef FULLSCREEN_ONLY
void Video::flipFullscreen () {
fullscreen = !fullscreen;
SDL_ShowCursor(fullscreen? SDL_DISABLE: SDL_ENABLE);
if (screen) create(screenW, screenH);
return;
}
#endif
void Video::expose () {
SDL_SetPalette(screen, SDL_LOGPAL, logicalPalette, 0, 256);
SDL_SetPalette(screen, SDL_PHYSPAL, currentPalette, 0, 256);
return;
}
void Video::flip (int mspf) {
SDL_Color shownPalette[256];
#ifdef SCALE
if (canvas != screen) {
// Copy everything that has been drawn so far
scale(scaleFactor,
screen->pixels, screen->pitch,
canvas->pixels, canvas->pitch,
screen->format->BytesPerPixel, canvas->w, canvas->h);
}
#endif
// Apply palette effects
if (paletteEffects) {
/* If the palette is being emulated, compile all palette changes and
apply them all at once.
If the palette is being used directly, apply all palette effects
directly. */
if (fakePalette) {
memcpy(shownPalette, currentPalette, sizeof(SDL_Color) * 256);
paletteEffects->apply(shownPalette, false, mspf);
SDL_SetPalette(screen, SDL_PHYSPAL, shownPalette, 0, 256);
} else {
paletteEffects->apply(shownPalette, true, mspf);
}
}
// Show what has been drawn
SDL_Flip(screen);
return;
}
void clearScreen (int index) {
#if defined(WIZ) || defined(GP2X)
// always 240 lines cleared to black
memset(screen->pixels, index, 320*240);
memset(video->pixels, index, 320*240);
#else
SDL_FillRect(canvas, NULL, index);
#endif
......@@ -195,3 +362,4 @@ void drawRect (int x, int y, int width, int height, int index) {
return;
}
......@@ -48,41 +48,73 @@
#define MAX_SCALE 4
#endif
// Black palette index
#define BLACK 31
// Class
class Video {
private:
SDL_Surface* screen;
// Palettes
SDL_Color* currentPalette;
SDL_Color logicalPalette[256];
bool fakePalette;
int screenW, screenH;
#ifdef SCALE
int scaleFactor;
#endif
#ifndef FULLSCREEN_ONLY
bool fullscreen;
#endif
public:
Video ();
bool create (int width, int height);
void setPalette (SDL_Color *palette);
SDL_Color* getPalette ();
void changePalette (SDL_Color *palette, unsigned char first, unsigned char amount);
void restoreSurfacePalette (SDL_Surface *surface);
int getWidth ();
int getHeight ();
#ifdef SCALE
int getScaleFactor ();
void setScaleFactor (int newScaleFactor);
#endif
#ifndef FULLSCREEN_ONLY
bool isFullscreen ();
void flipFullscreen ();
#endif
void expose ();
void flip (int mspf);
};
// Variables
EXTERN SDL_Surface *screen, *canvas;
EXTERN int viewH, canvasW, canvasH, screenW, screenH;
EXTERN SDL_Surface* canvas;
EXTERN int viewH, canvasW, canvasH;
#define viewW canvasW
#ifdef SCALE
EXTERN int scaleFactor;
#endif
#ifndef FULLSCREEN_ONLY
EXTERN bool fullscreen;
#endif
EXTERN bool fakePalette;
// Palettes
EXTERN SDL_Color *currentPalette;
EXTERN SDL_Color logicalPalette[256];
// Panel
EXTERN SDL_Surface *panel;
EXTERN SDL_Surface *panelAmmo[5];
EXTERN SDL_Surface* panel;
EXTERN SDL_Surface* panelAmmo[5];
EXTERN Video video;
// Functions
EXTERN unsigned char * sortPixels (unsigned char *pixels, int length);
EXTERN SDL_Surface * createSurface (unsigned char *pixels, int width, int height);
EXTERN void createScreen ();
EXTERN void usePalette (SDL_Color *palette);
EXTERN void restorePalette (SDL_Surface *surface);
EXTERN void clearScreen (int index);
EXTERN void drawRect (int x, int y, int width, int height, int index);
EXTERN unsigned char* sortPixels (unsigned char* pixels, int length);
EXTERN SDL_Surface* createSurface (unsigned char* pixels, int width, int height);
EXTERN void clearScreen (int index);
EXTERN void drawRect (int x, int y, int width, int height, int index);
#endif
......
......@@ -32,9 +32,9 @@
#include "player/player.h"
Bullet::Bullet (Player *sourcePlayer, bool lower, unsigned int ticks) {
Bullet::Bullet (Player* sourcePlayer, bool lower, unsigned int ticks) {
Anim *anim;
Anim* anim;
// Properties based on the player
......@@ -48,7 +48,7 @@ Bullet::Bullet (Player *sourcePlayer, bool lower, unsigned int ticks) {
} else {
next = level->firstBullet;
next = level->bullets;
}
......@@ -66,7 +66,7 @@ Bullet::Bullet (Player *sourcePlayer, bool lower, unsigned int ticks) {
time = ticks + T_TNT;
// Red flash
firstPE = new FlashPaletteEffect(255, 0, 0, T_TNT, firstPE);
paletteEffects = new FlashPaletteEffect(255, 0, 0, T_TNT, paletteEffects);
} else {
......@@ -88,13 +88,13 @@ Bullet::Bullet (Player *sourcePlayer, bool lower, unsigned int ticks) {
}
Bullet::Bullet (Event *sourceEvent, bool facing, unsigned int ticks) {
Bullet::Bullet (Event* sourceEvent, bool facing, unsigned int ticks) {
Anim *anim;
Anim* anim;
// Properties based on the event
next = level->firstBullet;
next = level->bullets;
source = NULL;
type = sourceEvent->getProperty(E_BULLET);
direction = facing? 1: 0;
......@@ -114,7 +114,7 @@ Bullet::Bullet (Event *sourceEvent, bool facing, unsigned int ticks) {
}
Bullet::Bullet (Bird *sourceBird, bool lower, unsigned int ticks) {
Bullet::Bullet (Bird* sourceBird, bool lower, unsigned int ticks) {
// Properties based on the bird and its player
......@@ -127,7 +127,7 @@ Bullet::Bullet (Bird *sourceBird, bool lower, unsigned int ticks) {
} else {
next = level->firstBullet;
next = level->bullets;
}
......@@ -149,55 +149,42 @@ Bullet::Bullet (Bird *sourceBird, bool lower, unsigned int ticks) {
Bullet::~Bullet () {
if (next) delete next;
return;
}
Bullet * Bullet::getNext () {
return next;
}
void Bullet::removeNext () {
Bullet *newNext;
if (next) {
newNext = next->getNext();
delete next;
next = newNext;
}
return;
}
Player * Bullet::getSource () {
Bullet* Bullet::remove () {
Bullet* oldNext;
oldNext = next;
next = NULL;
delete this;
return oldNext;
}
Player* Bullet::getSource () {
return source;
}
bool Bullet::step (unsigned int ticks, int msps) {
Bullet* Bullet::step (unsigned int ticks, int msps) {
signed char *set;
Event *event;
signed char* set;
Event* event;
int count;
// Process the next bullet
if (next) {
if (next->step(ticks, msps)) removeNext();
}
if (next) next = next->step(ticks, msps);
if (level->getStage() != LS_END) {
......@@ -209,7 +196,7 @@ bool Bullet::step (unsigned int ticks, int msps) {
// If the bullet is TNT, hit all destructible events nearby twice
if (type == -1) {
event = level->firstEvent;
event = level->events;
while (event) {
......@@ -228,13 +215,13 @@ bool Bullet::step (unsigned int ticks, int msps) {
}
// Destroy the bullet
return true;
return remove();
}
// If this is TNT, don't need to do anything else
if (type == -1) return false;
if (type == -1) return this;
// Check if a player has been hit
......@@ -244,7 +231,7 @@ bool Bullet::step (unsigned int ticks, int msps) {
ITOF(sprite->getWidth()), ITOF(sprite->getHeight()))) {
// If the hit was successful, destroy the bullet
if (players[count].hit(source, ticks)) return true;
if (players[count].hit(source, ticks)) return remove();
}
......@@ -255,7 +242,7 @@ bool Bullet::step (unsigned int ticks, int msps) {
// Check if an event has been hit
event = level->firstEvent;
event = level->events;
while (event) {
......@@ -264,7 +251,7 @@ bool Bullet::step (unsigned int ticks, int msps) {
ITOF(sprite->getWidth()), ITOF(sprite->getHeight()))) {
// If the event is hittable, hit it and destroy the bullet
if (event->hit(source, ticks)) return true;
if (event->hit(source, ticks)) return remove();
}
......@@ -285,7 +272,7 @@ bool Bullet::step (unsigned int ticks, int msps) {
level->playSound(set[B_FINISHSOUND]);
return true;
return remove();
}
......@@ -309,7 +296,7 @@ bool Bullet::step (unsigned int ticks, int msps) {
// Do not destroy the bullet
return false;
return this;
}
......
......@@ -56,24 +56,24 @@ class Sprite;
class Bullet : public Movable {
private:
Bullet *next;
Player *source; // If NULL, was fired by an event
Sprite *sprite;
Bullet* next;
Player* source; // If NULL, was fired by an event
Sprite* sprite;
int type; // -1 is TNT, otherwise indexes the bullet set
int direction; // 0: Left, 1: Right, 2: L (lower), 3: R (lower)
unsigned int time; // Time at which the bullet will self-destruct
Bullet* remove ();
public:
Bullet (Player *sourcePlayer, bool lower, unsigned int ticks);
Bullet (Event *sourceEvent, bool facing, unsigned int ticks);
Bullet (Bird *sourceBird, bool lower, unsigned int ticks);
~Bullet ();
Bullet * getNext ();
void removeNext ();
Player * getSource ();
bool step (unsigned int ticks, int msps);
void draw (int change);
Bullet (Player* sourcePlayer, bool lower, unsigned int ticks);
Bullet (Event* sourceEvent, bool facing, unsigned int ticks);
Bullet (Bird* sourceBird, bool lower, unsigned int ticks);
~Bullet ();
Player* getSource ();
Bullet* step (unsigned int ticks, int msps);
void draw (int change);
};
......
......@@ -103,7 +103,7 @@ int DemoLevel::play () {
stats = 0;
usePalette(palette);
video.setPalette(palette);
while (true) {
......@@ -170,7 +170,7 @@ int DemoLevel::play () {
// Draw the graphics
draw();
drawStats(stats);
drawStats(stats, BLACK);
fontsFont->showString("demo", (canvasW >> 1) - 36, 32);
......
......@@ -31,9 +31,9 @@
#include "player/player.h"
Bridge::Bridge (unsigned char gX, unsigned char gY, Event *nextEvent) {
Bridge::Bridge (unsigned char gX, unsigned char gY) {
signed char *set;
signed char* set;
set = level->getEvent(gX, gY);
......@@ -42,7 +42,7 @@ Bridge::Bridge (unsigned char gX, unsigned char gY, Event *nextEvent) {
dx = 0;
dy = 0;
next = nextEvent;
next = level->events;
gridX = gX;
gridY = gY;
animType = E_LEFTANIM;
......@@ -58,16 +58,16 @@ Bridge::Bridge (unsigned char gX, unsigned char gY, Event *nextEvent) {
}
bool Bridge::step (unsigned int ticks, int msps) {
Event* Bridge::step (unsigned int ticks, int msps) {
signed char *set;
signed char* set;
int count;
fixed bridgeLength, playerDipX, playerDipY;
set = prepareStep(ticks, msps);
if (!set) return true;
if (!set) return remove();
bridgeLength = set[E_MULTIPURPOSE] * set[E_BRIDGELENGTH] * F4;
......@@ -105,7 +105,7 @@ bool Bridge::step (unsigned int ticks, int msps) {
}
return false;
return this;
}
......@@ -118,6 +118,9 @@ void Bridge::draw (unsigned int ticks, int change) {
fixed bridgeLength, leftDipY, rightDipY;
if (next) next->draw(ticks, change);
// Get the event properties
set = level->getEvent(gridX, gridY);
......
......@@ -50,14 +50,14 @@ Event::Event () {
}
Event::Event (unsigned char gX, unsigned char gY, Event *nextEvent) {
Event::Event (unsigned char gX, unsigned char gY) {
x = TTOF(gX);
y = TTOF(gY + 1);
dx = 0;
dy = 0;
next = nextEvent;
next = level->events;
gridX = gX;
gridY = gY;
flashTime = 0;
......@@ -93,7 +93,29 @@ Event::Event (unsigned char gX, unsigned char gY, Event *nextEvent) {
}
Event::~Event () {
if (next) delete next;
return;
}
Event* Event::remove () {
Event *oldNext;
oldNext = next;
next = NULL;
delete this;
return oldNext;
}
Event * Event::getNext () {
return next;
......@@ -101,23 +123,6 @@ Event * Event::getNext () {
}
void Event::removeNext () {
Event *newNext;
if (next) {
newNext = next->getNext();
delete next;
next = newNext;
}
return;
}
void Event::destroy (unsigned int ticks) {
level->setEventTime(gridX, gridY, ticks + T_FINISH);
......
......@@ -80,31 +80,32 @@ class Player;
class Event : public Movable {
protected:
Event *next;
unsigned char gridX, gridY; // Grid position of the event
unsigned char animType; // E_LEFTANIM, etc, or 0
unsigned char frame;
unsigned int flashTime;
Event* next;
unsigned char gridX, gridY; // Grid position of the event
unsigned char animType; // E_LEFTANIM, etc, or 0
unsigned char frame;
unsigned int flashTime;
Event ();
Event ();
void destroy (unsigned int ticks);
fixed getWidth ();
fixed getHeight ();
signed char * prepareStep (unsigned int ticks, int msps);
Event* remove ();
void destroy (unsigned int ticks);
fixed getWidth ();
fixed getHeight ();
signed char* prepareStep (unsigned int ticks, int msps);
public:
Event (unsigned char gX, unsigned char gY, Event *nextEvent);
Event * getNext ();
void removeNext ();
bool hit (Player *source, unsigned int ticks);
bool isEnemy ();
bool isFrom (unsigned char gX, unsigned char gY);
virtual bool overlap (fixed left, fixed top, fixed width, fixed height);
signed char getProperty (unsigned char property);
virtual bool step (unsigned int ticks, int msps);
virtual void draw (unsigned int ticks, int change);
Event (unsigned char gX, unsigned char gY);
virtual ~Event ();
Event* getNext ();
bool hit (Player *source, unsigned int ticks);
bool isEnemy ();
bool isFrom (unsigned char gX, unsigned char gY);
virtual bool overlap (fixed left, fixed top, fixed width, fixed height);
signed char getProperty (unsigned char property);
virtual Event* step (unsigned int ticks, int msps);
virtual void draw (unsigned int ticks, int change);
};
......@@ -115,10 +116,10 @@ class Bridge : public Event {
fixed rightDipX;
public:
Bridge (unsigned char gX, unsigned char gY, Event *nextEvent);
Bridge (unsigned char gX, unsigned char gY);
bool step (unsigned int ticks, int msps);
void draw (unsigned int ticks, int change);
Event* step (unsigned int ticks, int msps);
void draw (unsigned int ticks, int change);
};
......
......@@ -38,16 +38,12 @@
#include <math.h>
signed char * Event::prepareStep (unsigned int ticks, int msps) {
signed char* Event::prepareStep (unsigned int ticks, int msps) {
signed char *set;
signed char* set;
// Process the next event
if (next) {
if (next->step(ticks, msps)) removeNext();
}
if (next) next = next->step(ticks, msps);
// Get the event properties
......@@ -85,10 +81,10 @@ signed char * Event::prepareStep (unsigned int ticks, int msps) {
}
bool Event::step (unsigned int ticks, int msps) {
Event* Event::step (unsigned int ticks, int msps) {
fixed width, height;
signed char *set;
signed char* set;
int count;
fixed offset;
float angle;
......@@ -96,7 +92,7 @@ bool Event::step (unsigned int ticks, int msps) {
set = prepareStep(ticks, msps);
if (!set) return true;
if (!set) return remove();
// Find dimensions
......@@ -696,7 +692,7 @@ bool Event::step (unsigned int ticks, int msps) {
animType = E_LEFTANIM;
}
break;
case 32:
......@@ -845,13 +841,13 @@ bool Event::step (unsigned int ticks, int msps) {
// The event has been destroyed, so remove it
level->clearEvent(gridX, gridY);
return true;
return remove();
} else if (animType == E_LSHOOTANIM) {
if ((set[E_BULLET] < 32) &&
(level->getBullet(set[E_BULLET])[B_SPRITE] != 0))
level->firstBullet = new Bullet(this, false, ticks);
level->bullets = new Bullet(this, false, ticks);
animType = E_LEFTANIM;
......@@ -859,7 +855,7 @@ bool Event::step (unsigned int ticks, int msps) {
if ((set[E_BULLET] < 32) &&
(level->getBullet(set[E_BULLET])[B_SPRITE + 1] != 0))
level->firstBullet = new Bullet(this, true, ticks);
level->bullets = new Bullet(this, true, ticks);
animType = E_RIGHTANIM;
......@@ -872,43 +868,41 @@ bool Event::step (unsigned int ticks, int msps) {
}
if (level->getStage() == LS_END) return false;
if (level->getStage() == LS_END) return this;
if ((animType == E_LFINISHANIM) || (animType == E_RFINISHANIM)) return this;
// Handle contact with player
if ((animType != E_LFINISHANIM) && (animType != E_RFINISHANIM)) {
for (count = 0; count < nPlayers; count++) {
for (count = 0; count < nPlayers; count++) {
// Check if the player is touching the event
if (set[E_MODIFIER] == 6) {
if (width && height &&
players[count].overlap(x, y - height, width - F8, F8) &&
(players[count].getY() <= F8 + ((PYS_FALL * msps) >> 10) + y - height) &&
!level->checkMaskDown(players[count].getX() + PXO_MID, PYO_TOP + y - height)) {
// Check if the player is touching the event
if (set[E_MODIFIER] == 6) {
// Player is on a platform
if (width && height &&
players[count].overlap(x, y - height, width - F8, F8) &&
(players[count].getY() <= F8 + ((PYS_FALL * msps) >> 10) + y - height) &&
!level->checkMaskDown(players[count].getX() + PXO_MID, PYO_TOP + y - height)) {
players[count].setEvent(gridX, gridY);
players[count].setPosition(
players[count].getX() + ((dx * msps) >> 10),
F4 + y - height);
// Player is on a platform
} else players[count].clearEvent(gridX, gridY);
players[count].setEvent(gridX, gridY);
players[count].setPosition(
players[count].getX() + ((dx * msps) >> 10),
F4 + y - height);
} else {
} else players[count].clearEvent(gridX, gridY);
// Check if the player is touching the event
if (width && height &&
players[count].overlap(x, y - height, width, height)) {
} else {
// If the player picks up the event, destroy it
if (players[count].touchEvent(gridX, gridY, ticks, msps))
destroy(ticks);
// Check if the player is touching the event
if (width && height &&
players[count].overlap(x, y - height, width, height)) {
}
// If the player picks up the event, destroy it
if (players[count].touchEvent(gridX, gridY, ticks, msps))
destroy(ticks);
}
......@@ -917,18 +911,21 @@ bool Event::step (unsigned int ticks, int msps) {
}
return false;
return this;
}
void Event::draw (unsigned int ticks, int change) {
Anim *anim;
signed char *set;
Anim* anim;
signed char* set;
int count;
if (next) next->draw(ticks, change);
// Uncomment the following to see the area of the event
/*drawRect(FTOI(getDrawX(change) - viewX),
FTOI(getDrawY(change) - (viewY + getHeight())), FTOI(getWidth()),
......
......@@ -32,14 +32,14 @@
#include "player/player.h"
DeckGuardian::DeckGuardian (unsigned char gX, unsigned char gY, Event *nextEvent) {
DeckGuardian::DeckGuardian (unsigned char gX, unsigned char gY) {
x = TTOF(gX);
y = TTOF(gY + 1);
dx = 0;
dy = 0;
next = nextEvent;
next = level->events;
gridX = gX;
gridY = gY;
flashTime = 0;
......@@ -70,15 +70,15 @@ bool DeckGuardian::overlap (fixed left, fixed top, fixed width, fixed height) {
}
bool DeckGuardian::step (unsigned int ticks, int msps) {
Event* DeckGuardian::step (unsigned int ticks, int msps) {
signed char *set;
signed char* set;
int count;
set = prepareStep(ticks, msps);
if (!set) return true;
if (!set) return remove();
// Handle behaviour
......@@ -111,7 +111,7 @@ bool DeckGuardian::step (unsigned int ticks, int msps) {
// The event has been destroyed, so remove it
level->clearEvent(gridX, gridY);
return true;
return remove();
} else {
......@@ -122,21 +122,21 @@ bool DeckGuardian::step (unsigned int ticks, int msps) {
}
if (level->getStage() == LS_END) return false;
return false;
return this;
}
void DeckGuardian::draw (unsigned int ticks, int change) {
Anim *anim;
signed char *set;
Anim* anim;
signed char* set;
int count;
if (next) next->draw(ticks, change);
// Get the event properties
set = level->getEvent(gridX, gridY);
......
......@@ -35,11 +35,11 @@ class DeckGuardian : public Event {
int stage;
public:
DeckGuardian (unsigned char gX, unsigned char gY, Event *nextEvent);
DeckGuardian (unsigned char gX, unsigned char gY);
bool overlap (fixed left, fixed top, fixed width, fixed height);
bool step (unsigned int ticks, int msps);
void draw (unsigned int ticks, int change);
bool overlap (fixed left, fixed top, fixed width, fixed height);
Event* step (unsigned int ticks, int msps);
void draw (unsigned int ticks, int change);
};
......
......@@ -92,32 +92,18 @@ Level::~Level () {
stopMusic();
// Free the palette effects
if (firstPE) {
if (paletteEffects) {
delete firstPE;
firstPE = NULL;
delete paletteEffects;
paletteEffects = NULL;
}
// Free events
if (firstEvent) {
while (firstEvent->getNext()) firstEvent->removeNext();
delete firstEvent;
firstEvent = NULL;
}
if (events) delete events;
// Free bullets
if (firstBullet) {
while (firstBullet->getNext()) firstBullet->removeNext();
delete firstBullet;
firstBullet = NULL;
}
if (bullets) delete bullets;
for (count = 0; count < PATHS; count++) {
......@@ -527,7 +513,7 @@ int Level::play () {
timeBonus = -1;
perfect = 0;
usePalette(palette);
video.setPalette(palette);
while (true) {
......@@ -580,16 +566,16 @@ int Level::play () {
if (!gameMode) {
// Don't want palette effects in setup menu
levelPE = firstPE;
firstPE = NULL;
levelPE = paletteEffects;
paletteEffects = NULL;
if (menu->setup() == E_QUIT) return E_QUIT;
// Restore level palette
usePalette(palette);
video.setPalette(palette);
// Restore palette effects
firstPE = levelPE;
paletteEffects = levelPE;
}
......@@ -659,7 +645,7 @@ int Level::play () {
// Draw statistics
drawStats(stats);
drawStats(stats, BLACK);
if (stage == LS_END) {
......@@ -697,7 +683,7 @@ int Level::play () {
if (timeBonus == 0) {
returnTime = ticks + T_END;
firstPE = new WhiteOutPaletteEffect(T_END, firstPE);
paletteEffects = new WhiteOutPaletteEffect(T_END, paletteEffects);
::playSound(S_UPLOOP);
}
......
......@@ -52,6 +52,9 @@
#define PATHS 16
#define TKEY 127 /* Tileset colour key */
// Black palette index
#define BLACK 31
// Fade delays
#define T_START 500
#define T_END 1000
......@@ -72,10 +75,10 @@ typedef struct {
typedef struct {
short int *x;
short int *y;
unsigned char length;
unsigned char node;
short int* x;
short int* y;
unsigned char length;
unsigned char node;
} EventPath;
......@@ -90,42 +93,42 @@ class Scene;
class Level : public BaseLevel {
private:
char *sceneFile;
Sprite *spriteSet; // 208 of which are usually in mainchar.000
Anim animSet[ANIMS];
char miscAnims[4];
signed char bulletSet[BULLETS][BLENGTH];
signed char eventSet[EVENTS][ELENGTH];
char mask[240][64]; // At most 240 tiles, all with 8 * 8 masks
GridElement grid[LH][LW]; // All levels are the same size
int soundMap[32];
SDL_Color skyPalette[256];
bool sky;
unsigned char skyOrb;
int sprites;
int levelNum, worldNum, nextLevelNum, nextWorldNum;
unsigned char difficulty;
int enemies;
fixed waterLevel;
fixed waterLevelTarget;
fixed waterLevelSpeed;
fixed energyBar;
int loadSprites (char *fileName);
int loadTiles (char *fileName);
char* sceneFile;
Sprite* spriteSet; // 208 of which are usually in mainchar.000
Anim animSet[ANIMS];
char miscAnims[4];
signed char bulletSet[BULLETS][BLENGTH];
signed char eventSet[EVENTS][ELENGTH];
char mask[240][64]; // At most 240 tiles, all with 8 * 8 masks
GridElement grid[LH][LW]; // All levels are the same size
int soundMap[32];
SDL_Color skyPalette[256];
bool sky;
unsigned char skyOrb;
int sprites;
int levelNum, worldNum, nextLevelNum, nextWorldNum;
unsigned char difficulty;
int enemies;
fixed waterLevel;
fixed waterLevelTarget;
fixed waterLevelSpeed;
fixed energyBar;
int loadSprites (char* fileName);
int loadTiles (char* fileName);
protected:
int load (char *fileName, unsigned char diff, bool checkpoint);
int load (char* fileName, unsigned char diff, bool checkpoint);
int step ();
void draw ();
public:
Event *firstEvent;
Bullet *firstBullet;
EventPath path[PATHS];
Event* events;
Bullet* bullets;
EventPath path[PATHS];
Level ();
Level (char *fileName, unsigned char diff, bool checkpoint);
Level (char* fileName, unsigned char diff, bool checkpoint);
virtual ~Level ();
bool checkMask (fixed x, fixed y);
......@@ -133,23 +136,23 @@ class Level : public BaseLevel {
bool checkSpikes (fixed x, fixed y);
void setNext (int nextLevel, int nextWorld);
void setTile (unsigned char gridX, unsigned char gridY, unsigned char tile);
signed char * getEvent (unsigned char gridX, unsigned char gridY);
signed char* getEvent (unsigned char gridX, unsigned char gridY);
unsigned char getEventHits (unsigned char gridX, unsigned char gridY);
unsigned int getEventTime (unsigned char gridX, unsigned char gridY);
void clearEvent (unsigned char gridX, unsigned char gridY);
int hitEvent (unsigned char gridX, unsigned char gridY, Player *source);
int hitEvent (unsigned char gridX, unsigned char gridY, Player* source);
void setEventTime (unsigned char gridX, unsigned char gridY, unsigned int time);
signed char * getBullet (unsigned char bullet);
Sprite * getSprite (unsigned char sprite);
Anim * getAnim (unsigned char anim);
Anim * getMiscAnim (unsigned char anim);
signed char* getBullet (unsigned char bullet);
Sprite* getSprite (unsigned char sprite);
Anim* getAnim (unsigned char anim);
Anim* getMiscAnim (unsigned char anim);
void setWaterLevel (unsigned char gridY);
fixed getWaterLevel ();
void playSound (int sound);
void setStage (LevelStage stage);
LevelStage getStage ();
Scene * createScene ();
void receive (unsigned char *buffer);
Scene* createScene ();
void receive (unsigned char* buffer);
virtual int play ();
};
......@@ -158,10 +161,10 @@ class Level : public BaseLevel {
class DemoLevel : public Level {
private:
unsigned char *macro;
unsigned char* macro;
public:
DemoLevel (const char *fileName);
DemoLevel (const char* fileName);
~DemoLevel ();
int play ();
......@@ -171,7 +174,7 @@ class DemoLevel : public Level {
// Variables
EXTERN Level *level;
EXTERN Level* level;
EXTERN fixed viewX, viewY;
#endif
......
......@@ -42,8 +42,7 @@
int Level::step () {
Bullet *nextBullet;
Event *nextEvent;
Event *event;
int x, y;
int msps;
......@@ -62,37 +61,37 @@ int Level::step () {
if ((x >= 0) && (y >= 0) && (x < LW) && (y < LH) &&
grid[y][x].event && (grid[y][x].event < 121)) {
nextEvent = firstEvent;
event = events;
while (nextEvent) {
while (event) {
// If the event has been found, stop searching
if (nextEvent->isFrom(x, y)) break;
if (event->isFrom(x, y)) break;
nextEvent = nextEvent->getNext();
event = event->getNext();
}
// If the event wasn't found, create it
if (!nextEvent) {
if (!event) {
switch (getEvent(x, y)[E_BEHAVIOUR]) {
case 28:
firstEvent = new Bridge(x, y, firstEvent);
events = new Bridge(x, y);
break;
case 60:
firstEvent = new DeckGuardian(x, y, firstEvent);
events = new DeckGuardian(x, y);
break;
default:
firstEvent = new Event(x, y, firstEvent);
events = new Event(x, y);
break;
......@@ -115,32 +114,12 @@ int Level::step () {
for (x = 0; x < PATHS; x++) path[x].node = (ticks >> 5) % path[x].length;
if (firstEvent) {
if (firstEvent->step(ticks, msps)) {
nextEvent = firstEvent->getNext();
delete firstEvent;
firstEvent = nextEvent;
}
}
if (events) events = events->step(ticks, msps);
// Process bullets
if (firstBullet) {
if (firstBullet->step(ticks, msps)) {
nextBullet = firstBullet->getNext();
delete firstBullet;
firstBullet = nextBullet;
}
}
if (bullets) bullets = bullets->step(ticks, msps);
// Apply as much of those trajectories as possible, without going into the
......@@ -193,8 +172,6 @@ int Level::step () {
void Level::draw () {
GridElement *ge;
Event *event;
Bullet *bullet;
SDL_Rect src, dst;
int vX, vY;
int x, y, bgScale;
......@@ -294,14 +271,7 @@ void Level::draw () {
// Show active events
event = firstEvent;
while (event) {
event->draw(ticks, change);
event = event->getNext();
}
if (events) events->draw(ticks, change);
// Show the players
......@@ -310,14 +280,7 @@ void Level::draw () {
// Show bullets
bullet = firstBullet;
while (bullet) {
bullet->draw(change);
bullet = bullet->getNext();
}
if (bullets) bullets->draw(change);
......
......@@ -472,7 +472,7 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) {
}
usePalette(menu->palettes[1]);
video.setPalette(menu->palettes[1]);
clearScreen(0);
......@@ -909,7 +909,7 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) {
sky = false;
// Free any existing palette effects
if (firstPE) delete firstPE;
if (paletteEffects) delete paletteEffects;
switch (type) {
......@@ -918,35 +918,35 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) {
sky = true;
// Sky background effect
firstPE = new SkyPaletteEffect(156, 100, FH, skyPalette, NULL);
paletteEffects = new SkyPaletteEffect(156, 100, FH, skyPalette, NULL);
break;
case 8:
// Parallaxing background effect
firstPE = new P2DPaletteEffect(128, 64, FE, NULL);
paletteEffects = new P2DPaletteEffect(128, 64, FE, NULL);
break;
case 9:
// Diagonal stripes "parallaxing" background effect
firstPE = new P1DPaletteEffect(128, 32, FH, NULL);
paletteEffects = new P1DPaletteEffect(128, 32, FH, NULL);
break;
case 11:
// The deeper below water, the darker it gets
firstPE = new WaterPaletteEffect(TTOF(32), NULL);
paletteEffects = new WaterPaletteEffect(TTOF(32), NULL);
break;
default:
// No effect
firstPE = NULL;
paletteEffects = NULL;
break;
......@@ -958,31 +958,31 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) {
// be
// In Diamondus: The red/yellow palette animation
firstPE = new RotatePaletteEffect(112, 4, F32, firstPE);
paletteEffects = new RotatePaletteEffect(112, 4, F32, paletteEffects);
// In Diamondus: The waterfall palette animation
firstPE = new RotatePaletteEffect(116, 8, F16, firstPE);
paletteEffects = new RotatePaletteEffect(116, 8, F16, paletteEffects);
// The following were discoverd by Unknown/Violet
firstPE = new RotatePaletteEffect(124, 3, F16, firstPE);
paletteEffects = new RotatePaletteEffect(124, 3, F16, paletteEffects);
if ((type != PE_1D) && (type != PE_2D))
firstPE = new RotatePaletteEffect(132, 8, F16, firstPE);
paletteEffects = new RotatePaletteEffect(132, 8, F16, paletteEffects);
if ((type != PE_SKY) && (type != PE_2D))
firstPE = new RotatePaletteEffect(160, 32, -F16, firstPE);
paletteEffects = new RotatePaletteEffect(160, 32, -F16, paletteEffects);
if (type != PE_SKY) {
firstPE = new RotatePaletteEffect(192, 32, -F32, firstPE);
firstPE = new RotatePaletteEffect(224, 16, F16, firstPE);
paletteEffects = new RotatePaletteEffect(192, 32, -F32, paletteEffects);
paletteEffects = new RotatePaletteEffect(224, 16, F16, paletteEffects);
}
// Level fade-in/white-in effect
if (checkpoint) firstPE = new FadeInPaletteEffect(T_START, firstPE);
else firstPE = new WhiteInPaletteEffect(T_START, firstPE);
if (checkpoint) paletteEffects = new FadeInPaletteEffect(T_START, paletteEffects);
else paletteEffects = new WhiteInPaletteEffect(T_START, paletteEffects);
file->seek(1, false);
......@@ -1000,8 +1000,8 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) {
endTime = (5 - difficulty) * 2 * 60 * 1000;
firstBullet = NULL;
firstEvent = NULL;
events = NULL;
bullets = NULL;
energyBar = 0;
......
......@@ -55,17 +55,16 @@
extern char KOpenJazzPath[256];
#endif
#ifdef SCALE
#include "io/gfx/scale2x/scalebit.h"
#endif
int loadMain (int argc, char *argv[]) {
File *file;
unsigned char *pixels, *sorted;
int count, x, y;
#ifndef SCALE
int scaleFactor;
int count, x, y;
int screenW, screenH;
int scaleFactor;
#ifndef FULLSCREEN_ONLY
bool fullscreen;
#endif
......@@ -156,14 +155,17 @@ int loadMain (int argc, char *argv[]) {
// Default settings
// Video settings
screenW = SW;
screenH = SH;
// Video settings
screenW = SW;
screenH = SH;
#ifdef SCALE
scaleFactor = 1;
#endif
#ifndef FULLSCREEN_ONLY
fullscreen = false;
#endif
// Sound settings
#if defined(WIZ) || defined(GP2X)
volume = 40;
......@@ -208,8 +210,10 @@ int loadMain (int argc, char *argv[]) {
#ifndef FULLSCREEN_ONLY
fullscreen = scaleFactor & 1;
#endif
#ifdef SCALE
scaleFactor >>= 1;
if (scaleFactor > 4) scaleFactor = 1;
if (scaleFactor > 4) scaleFactor = 1;
#endif
// Read controls
......@@ -263,25 +267,21 @@ int loadMain (int argc, char *argv[]) {
#endif
// Generate the logical palette
for (count = 0; count < 256; count++)
logicalPalette[count].r = logicalPalette[count].g =
logicalPalette[count].b = count;
// Create the game's window
currentPalette = logicalPalette;
canvas = screen = NULL;
#ifndef FULLSCREEN_ONLY
if (fullscreen)
#endif
SDL_ShowCursor(SDL_DISABLE);
canvas = NULL;
createScreen();
if (!screen) {
#ifdef SCALE
video.setScaleFactor(scaleFactor);
#endif
#ifdef FULLSCREEN_ONLY
SDL_ShowCursor(SDL_DISABLE);
#else
if (fullscreen) video.flipFullscreen();
#endif
if (!video.create(screenW, screenH)) {
logError("Could not set video mode", SDL_GetError());
......@@ -299,9 +299,7 @@ int loadMain (int argc, char *argv[]) {
if (SDL_NumJoysticks() > 0) SDL_JoystickOpen(0);
restorePalette(screen);
firstPE = NULL;
paletteEffects = NULL;
// Set up audio
......@@ -461,9 +459,7 @@ void freeMain () {
File *file;
int count;
#ifndef SCALE
int scaleFactor = 1;
#endif
int scaleFactor;
delete net;
......@@ -482,10 +478,14 @@ void freeMain () {
SDL_FreeSurface(panelAmmo[3]);
SDL_FreeSurface(panelAmmo[4]);
#ifdef SCALE
if (canvas != screen) SDL_FreeSurface(canvas);
#endif
#ifdef SCALE
scaleFactor = video.getScaleFactor();
if (scaleFactor > 1) SDL_FreeSurface(canvas);
#else
scaleFactor = 1;
#endif
closeAudio();
......@@ -507,11 +507,11 @@ void freeMain () {
file->storeChar(2);
// Write video settings
file->storeShort(screenW);
file->storeShort(screenH);
file->storeShort(video.getWidth());
file->storeShort(video.getHeight());
scaleFactor <<= 1;
#ifndef FULLSCREEN_ONLY
scaleFactor |= fullscreen? 1: 0;
scaleFactor |= video.isFullscreen()? 1: 0;
#endif
file->storeChar(scaleFactor);
......@@ -567,53 +567,16 @@ void freeMain () {
int loop (LoopType type) {
SDL_Color shownPalette[256];
SDL_Event event;
int prevTicks, ret;
#ifdef SCALE
if (canvas != screen) {
// Copy everything that has been drawn so far
scale(scaleFactor,
screen->pixels, screen->pitch,
canvas->pixels, canvas->pitch,
screen->format->BytesPerPixel, canvas->w, canvas->h);
}
#endif
// Update tick count
prevTicks = globalTicks;
globalTicks = SDL_GetTicks();
// Apply palette effects
if (firstPE) {
/* If the palette is being emulated, compile all palette changes and
apply them all at once.
If the palette is being used directly, apply all palette effects
directly. */
if (fakePalette) {
memcpy(shownPalette, currentPalette, sizeof(SDL_Color) * 256);
firstPE->apply(shownPalette, false, globalTicks - prevTicks);
SDL_SetPalette(screen, SDL_PHYSPAL, shownPalette, 0, 256);
} else {
firstPE->apply(shownPalette, true, globalTicks - prevTicks);
}
}
// Show what has been drawn
SDL_Flip(screen);
video.flip(globalTicks - prevTicks);
// Process system events
......@@ -628,10 +591,7 @@ int loop (LoopType type) {
if ((event.key.keysym.sym == SDLK_RETURN) &&
(event.key.keysym.mod & KMOD_ALT)) {
fullscreen = !fullscreen;
SDL_ShowCursor(fullscreen? SDL_DISABLE: SDL_ENABLE);
createScreen();
video.flipFullscreen();
}
#endif
......@@ -668,17 +628,13 @@ int loop (LoopType type) {
#ifndef FULLSCREEN_ONLY
case SDL_VIDEORESIZE:
screenW = event.resize.w;
screenH = event.resize.h;
createScreen();
video.create(event.resize.w, event.resize.h);
break;
case SDL_VIDEOEXPOSE:
SDL_SetPalette(screen, SDL_LOGPAL, logicalPalette, 0, 256);
SDL_SetPalette(screen, SDL_PHYSPAL, currentPalette, 0, 256);
video.expose();
break;
#endif
......
......@@ -43,7 +43,7 @@ int Menu::newGameDifficulty (GameModeType mode, int levelNum, int worldNum) {
SDL_Rect src, dst;
int count;
usePalette(palettes[1]);
video.setPalette(palettes[1]);
while (true) {
......@@ -159,7 +159,7 @@ int Menu::newGameLevel (GameModeType mode) {
worldNum = levelNum = option = 0;
usePalette(palettes[1]);
video.setPalette(palettes[1]);
while (true) {
......@@ -209,7 +209,7 @@ int Menu::newGameLevel (GameModeType mode) {
if (newGameDifficulty(mode, levelNum, worldNum) == E_QUIT)
return E_QUIT;
usePalette(palettes[1]);
video.setPalette(palettes[1]);
}
......@@ -230,7 +230,7 @@ int Menu::newGameEpisode (GameModeType mode) {
SDL_Rect dst;
int episode, count, worldNum;
usePalette(palettes[2]);
video.setPalette(palettes[2]);
for (count = 0; count < 10; count++) {
......@@ -242,7 +242,7 @@ int Menu::newGameEpisode (GameModeType mode) {
exists[count] = fileExists(check);
delete[] check;
if (exists[count]) restorePalette(screens[count + 3]);
if (exists[count]) video.restoreSurfacePalette(screens[count + 3]);
else
SDL_SetPalette(screens[count + 3], SDL_LOGPAL, palettes[3], 0, 256);
......@@ -327,7 +327,7 @@ int Menu::newGameEpisode (GameModeType mode) {
}
usePalette(palettes[2]);
video.setPalette(palettes[2]);
}
......
......@@ -52,7 +52,7 @@ int Menu::main () {
option = suboption = 0;
usePalette(palettes[0]);
video.setPalette(palettes[0]);
// Demo timeout
idleTime = globalTicks + T_DEMO;
......@@ -171,7 +171,7 @@ int Menu::main () {
}
// Restore the main menu palette
usePalette(palettes[0]);
video.setPalette(palettes[0]);
// New demo timeout
idleTime = globalTicks + T_DEMO;
......@@ -222,7 +222,7 @@ int Menu::main () {
playMusic("menusng.psm");
// Restore the main menu palette
usePalette(palettes[0]);
video.setPalette(palettes[0]);
idleTime = globalTicks + T_DEMO;
......
......@@ -39,7 +39,7 @@ int Menu::message (const char* text) {
// Display a message to the user
usePalette(palettes[1]);
video.setPalette(palettes[1]);
while (true) {
......@@ -68,7 +68,7 @@ int Menu::generic (const char** optionNames, int options, int& chosen) {
int count;
usePalette(palettes[1]);
video.setPalette(palettes[1]);
if (chosen >= options) chosen = 0;
......
......@@ -260,13 +260,16 @@ int Menu::setupResolution () {
int heightOptions[] = {200, 240, 300, 384, 400, 480, 576, 600, 720, 768,
800, 864, 900, 960, 1024, 1080, 1200};
SDL_Rect **resolutions;
int count, maxW, maxH;
int count, screenW, screenH, maxW, maxH;
bool dimension;
screenW = video.getWidth();
screenH = video.getHeight();
dimension = false;
#ifndef FULLSCREEN_ONLY
if (!fullscreen)
if (!video.isFullscreen())
resolutions = SDL_ListModes(NULL, WINDOWED_FLAGS);
else
#endif
......@@ -389,7 +392,7 @@ int Menu::setupResolution () {
if (count) {
playSound(S_ORB);
createScreen();
video.create(screenW, screenH);
}
......@@ -403,8 +406,10 @@ int Menu::setupResolution () {
#ifdef SCALE
int Menu::setupScaling () {
int oldScaleFactor;
int scaleFactor;
scaleFactor = video.getScaleFactor();
if ( scaleFactor < MIN_SCALE || scaleFactor > MAX_SCALE )
scaleFactor = 1;
......@@ -432,7 +437,7 @@ int Menu::setupScaling () {
fontmn2->mapPalette(240, 8, 114, 16);
// Scale
fontmn2->showNumber(scaleFactor, (canvasW >> 2) + 32, canvasH >> 1);
fontmn2->showNumber(video.getScaleFactor(), (canvasW >> 2) + 32, canvasH >> 1);
// X
fontmn2->showString("x", (canvasW >> 2) + 40, canvasH >> 1);
......@@ -440,17 +445,15 @@ int Menu::setupScaling () {
fontmn2->restorePalette();
oldScaleFactor = scaleFactor;
if ((controls.release(C_DOWN) || controls.release(C_LEFT)) && (scaleFactor > MIN_SCALE)) scaleFactor--;
if ((controls.release(C_UP) || controls.release(C_RIGHT)) && (scaleFactor < MAX_SCALE)) scaleFactor++;
// Check for a scaling change
if (scaleFactor != oldScaleFactor) {
if (scaleFactor != video.getScaleFactor()) {
playSound(S_ORB);
createScreen();
playSound(S_ORB);
video.setScaleFactor(scaleFactor);
}
......
......@@ -80,7 +80,7 @@ void Bird::hit () {
bool Bird::step (unsigned int ticks, int msps) {
Event *nextEvent;
Event *event;
bool target;
if (fleeing) {
......@@ -156,25 +156,25 @@ bool Bird::step (unsigned int ticks, int msps) {
// Check for nearby targets
target = false;
nextEvent = level->firstEvent;
event = level->events;
if (player->getFacing()) {
while (nextEvent && !target) {
while (event && !target) {
target = nextEvent->isEnemy() && nextEvent->overlap(x, y, F160, F100);
target = event->isEnemy() && event->overlap(x, y, F160, F100);
nextEvent = nextEvent->getNext();
event = event->getNext();
}
} else {
while (nextEvent && !target) {
while (event && !target) {
target = nextEvent->isEnemy() && nextEvent->overlap(x - F160, y, F160, F100);
target = event->isEnemy() && event->overlap(x - F160, y, F160, F100);
nextEvent = nextEvent->getNext();
event = event->getNext();
}
......@@ -183,7 +183,7 @@ bool Bird::step (unsigned int ticks, int msps) {
// If there is a target in the vicinity, generate bullets
if (target) {
level->firstBullet = new Bullet(this, false, ticks);
level->bullets = new Bullet(this, false, ticks);
fireTime = ticks + T_BIRD_FIRE;
......
......@@ -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
......@@ -45,19 +45,19 @@ class Player;
class Bird : public Movable {
private:
Player *player;
bool fleeing;
unsigned int fireTime;
Player* player;
bool fleeing;
unsigned int fireTime;
public:
Bird (Player *player, unsigned char gX, unsigned char gY);
~Bird ();
void reset ();
Player * getPlayer ();
void hit ();
bool step (unsigned int ticks, int msps);
void draw (unsigned int ticks, int change);
Bird (Player* player, unsigned char gX, unsigned char gY);
~Bird ();
void reset ();
Player* getPlayer ();
void hit ();
bool step (unsigned int ticks, int msps);
void draw (unsigned int ticks, int change);
};
......
......@@ -407,7 +407,7 @@ bool Player::takeEvent (unsigned char gridX, unsigned char gridY, unsigned int t
if (game) game->setBonus(0);
// Yellow flash
firstPE = new FlashPaletteEffect(255, 255, 0, 320, firstPE);
paletteEffects = new FlashPaletteEffect(255, 255, 0, 320, paletteEffects);
break;
......@@ -459,8 +459,7 @@ bool Player::touchEvent (unsigned char gridX, unsigned char gridY, unsigned int
warpTime = ticks + T_WARP;
// White flash
firstPE =
new FlashPaletteEffect(255, 255, 255, T_WARP, firstPE);
paletteEffects = new FlashPaletteEffect(255, 255, 255, T_WARP, paletteEffects);
}
......@@ -595,7 +594,7 @@ void Player::kill (Player *source, unsigned int ticks) {
}
if (!gameMode) firstPE = new FadeOutPaletteEffect(T_END, firstPE);
if (!gameMode) paletteEffects = new FadeOutPaletteEffect(T_END, paletteEffects);
return;
......
......@@ -309,7 +309,7 @@ void Player::control (unsigned int ticks, int msps) {
if (platform) animType = facing? PA_RSHOOT: PA_LSHOOT;
// Create new bullet
level->firstBullet = new Bullet(this, false, ticks);
level->bullets = new Bullet(this, false, ticks);
// Set when the next bullet can be fired
if (fireSpeed) fireTime = ticks + (1000 / fireSpeed);
......
......@@ -230,7 +230,7 @@ int Scene::play () {
if (newpage) {
//firstPE = new FadeOutPaletteEffect(250, firstPE);
//paletteEffects = new FadeOutPaletteEffect(250, paletteEffects);
textRect.x = 0;
textRect.y = 0;
......@@ -242,12 +242,12 @@ int Scene::play () {
if (palette) {
usePalette(palette->palette);
video.setPalette(palette->palette);
// Fade in from black
firstPE = new FadeInPaletteEffect(250, firstPE);
paletteEffects = new FadeInPaletteEffect(250, paletteEffects);
} else restorePalette(screen);
}
newpage = 0;
......
......@@ -117,7 +117,7 @@ void Scene::loadAni (File *f, int dataIndex) {
if (!background) background = f->loadSurface(SW, SH);
// Use the most recently loaded palette
usePalette(palettes->palette);
video.setPalette(palettes->palette);
break;
......
......@@ -31,7 +31,6 @@
#include "io/file.h"
#include <iostream>
#include <string.h>
......@@ -40,7 +39,7 @@ bool fileExists (const char * fileName) {
File *file;
#ifdef VERBOSE
std::cout << "Check: ";
printf("Check: ");
#endif
try {
......@@ -152,39 +151,39 @@ char * createEditableString (const char *string) {
}
void log (const char *message) {
std::cout << message << std::endl;
return;
}
void log (const char *message, const char *detail) {
std::cout << message << ": " << detail << std::endl;
return;
}
void log (const char *message, int number) {
std::cout << message << ": " << number << std::endl;
return;
}
void logError (const char *message, const char *detail) {
std::cerr << message << ": " << detail << std::endl;
return;
}
void log (const char *message) {
printf("%s\n", message);
return;
}
void log (const char *message, const char *detail) {
printf("%s: %s\n", message, detail);
return;
}
void log (const char *message, int number) {
printf("%s: %d\n", message, number);
return;
}
void logError (const char *message, const char *detail) {
fprintf(stderr, "%s: %s\n", message, detail);
return;
}
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