Commit 2bb81bfd authored by anotherguest's avatar anotherguest

Added #ifdef SCALE for set scale factor in video.cpp(was missing)

parent 6a0cbf3f
......@@ -26,35 +26,35 @@
*/
#include "paletteeffects.h"
#include "paletteeffects.h"
#include "video.h"
#ifdef SCALE
#include "io/gfx/scale2x/scalebit.h"
#endif
#ifdef SCALE
#include "io/gfx/scale2x/scalebit.h"
#endif
#include <string.h>
unsigned char * sortPixels (unsigned char * pixels, int length) {
unsigned char *sorted;
int count;
sorted = new unsigned char[length];
// Rearrange pixels in correct order
for (count = 0; count < length; count++) {
sorted[count] = pixels[(count >> 2) + ((count & 3) * (length >> 2))];
}
return sorted;
}
unsigned char * sortPixels (unsigned char * pixels, int length) {
unsigned char *sorted;
int count;
sorted = new unsigned char[length];
// Rearrange pixels in correct order
for (count = 0; count < length; count++) {
sorted[count] = pixels[(count >> 2) + ((count & 3) * (length >> 2))];
}
return sorted;
}
SDL_Surface* createSurface (unsigned char * pixels, int width, int height) {
SDL_Surface *ret;
......@@ -83,38 +83,38 @@ SDL_Surface* createSurface (unsigned char * pixels, int width, int height) {
}
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;
}
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;
screenW = width;
screenH = height;
#ifdef SCALE
if (canvas != screen) SDL_FreeSurface(canvas);
......@@ -129,9 +129,9 @@ bool Video::create (int width, int height) {
screen = SDL_SetVideoMode(screenW, screenH, 8, fullscreen? FULLSCREEN_FLAGS: WINDOWED_FLAGS);
#endif
#endif
if (!screen) return false;
if (!screen) return false;
#ifdef SCALE
// Check that the scale will fit in the current resolution
......@@ -178,7 +178,7 @@ bool Video::create (int width, int height) {
}
void Video::setPalette (SDL_Color *palette) {
// Make palette changes invisible until the next draw. Hopefully.
......@@ -193,146 +193,146 @@ void Video::setPalette (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 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;
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 Video::restoreSurfacePalette (SDL_Surface* surface) {
SDL_SetPalette(surface, SDL_LOGPAL, logicalPalette, 0, 256);
return;
}
int Video::getWidth () {
return screenW;
}
int Video::getHeight () {
return screenH;
}
#ifdef SCALE
int Video::getScaleFactor () {
return scaleFactor;
}
void Video::setScaleFactor (int newScaleFactor) {
scaleFactor = newScaleFactor;
if (screen) create(screenW, screenH);
return;
}
#endif
#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) {
......@@ -362,4 +362,4 @@ void drawRect (int x, int y, int width, int height, int index) {
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