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