Commit 9d436013 authored by alistert's avatar alistert

Separated concepts of the "screen" that is drawn to (now the "canvas"), and...

Separated concepts of the "screen" that is drawn to (now the "canvas"), and the "screen" that is actually displayed. Setting the resolution now works properly with scaling.
parent 7cacfd05
......@@ -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
......@@ -74,8 +74,7 @@ ClientGame::ClientGame (char *address) {
SDL_Delay(T_FRAME);
clearScreen(0);
fontmn2->showString("WAITING FOR REPLY", screenW >> 2,
(screenH >> 1) - 16);
fontmn2->showString("WAITING FOR REPLY", canvasW >> 2, (canvasH >> 1) - 16);
ret = net->recv(sock, buffer + count, MTL_G_PROPS - count);
......@@ -207,7 +206,7 @@ ClientGame::ClientGame (char *address) {
}
clearScreen(0);
fontmn2->showString("JOINING GAME", screenW >> 2, (screenH >> 1) - 16);
fontmn2->showString("JOINING GAME", canvasW >> 2, (canvasH >> 1) - 16);
ret = step(0);
......@@ -267,8 +266,7 @@ int ClientGame::setLevel (char *fileName) {
SDL_Delay(T_FRAME);
clearScreen(0);
fontmn2->showString("WAITING FOR SERVER", screenW >> 2,
(screenH >> 1) - 16);
fontmn2->showString("WAITING FOR SERVER", canvasW >> 2, (canvasH >> 1) - 16);
ret = step(0);
......@@ -286,9 +284,9 @@ int ClientGame::setLevel (char *fileName) {
SDL_Delay(T_FRAME);
clearScreen(0);
fontmn2->showString("downloaded", screenW >> 2, (screenH >> 1) - 16);
fontmn2->showNumber(file->tell(), (screenW >> 2) + 56, screenH >> 1);
fontmn2->showString("bytes", (screenW >> 2) + 64, screenH >> 1);
fontmn2->showString("downloaded", canvasW >> 2, (canvasH >> 1) - 16);
fontmn2->showNumber(file->tell(), (canvasW >> 2) + 56, canvasH >> 1);
fontmn2->showString("bytes", (canvasW >> 2) + 64, canvasH >> 1);
ret = step(0);
......
......@@ -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
......@@ -340,9 +340,7 @@ int Font::showString (const char * s, int x, int y) {
// Determine the character's position on the screen
src.w = w[(int)(map[(int)(s[count])])];
if(s[count] == 32) {
src.w = src.w /2;
}
if(s[count] == 32) src.w >>= 1;
dst.y = yOffset;
dst.x = xOffset;
......@@ -352,7 +350,7 @@ int Font::showString (const char * s, int x, int y) {
else src.y = 0;
// Draw the character to the screen
SDL_BlitSurface(surface, &src, screen, &dst);
SDL_BlitSurface(surface, &src, canvas, &dst);
xOffset += src.w-1;
}
......@@ -379,15 +377,15 @@ void Font::showNumber (int n, int x, int y) {
if (!n) {
// Determine 0's position on the screen
src.w = w[(int)(map['0'])];
src.w = w[(int)(map[(int)'0'])];
dst.y = y;
dst.x = x - src.w;
// Determine 0's position in the font
src.y = map['0'] * h;
src.y = map[(int)'0'] * h;
// Draw 0 to the screen
SDL_BlitSurface(surface, &src, screen, &dst);
SDL_BlitSurface(surface, &src, canvas, &dst);
return;
......@@ -412,7 +410,7 @@ void Font::showNumber (int n, int x, int y) {
src.y = map['0' + (count % 10)] * h;
// Draw the digit to the screen
SDL_BlitSurface(surface, &src, screen, &dst);
SDL_BlitSurface(surface, &src, canvas, &dst);
count /= 10;
......@@ -422,15 +420,15 @@ void Font::showNumber (int n, int x, int y) {
if (n < 0) {
// Determine the negative sign's position on the screen
src.w = w[(int)(map['-'])];
src.w = w[(int)(map[(int)'-'])];
dst.y = y;
dst.x = offset - src.w;
// Determine the negative sign's position on the screen
src.y = map['-'] * h;
src.y = map[(int)'-'] * h;
// Draw the negative sign to the screen
SDL_BlitSurface(surface, &src, screen, &dst);
SDL_BlitSurface(surface, &src, canvas, &dst);
}
......
......@@ -387,8 +387,8 @@ void SkyPaletteEffect::apply (SDL_Color *shownPalette, bool direct, int mspf) {
position = viewY + (viewH << 9) - F4;
if (screenW > 320) y = ((screenH - 1) / 100) + 1;
else y = ((screenH - 34) / 100) + 1;
if (canvasW > 320) y = ((canvasH - 1) / 100) + 1;
else y = ((canvasH - 34) / 100) + 1;
count = (((position * speed) / y) >> 20) % 255;
......
/*
* This file is part of the Advance project.
*
* Copyright (C) 2002 Andrea Mazzoleni
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#if HAVE_CONFIG_H
#include <config.h>
#endif
#if !HAVE_GETOPT
/* This source is extracted from the DJGPP LIBC library */
#define unconst(var, type) ((type)(var))
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <string.h>
#include <stdio.h>
int opterr = 1, optind = 1, optopt = 0;
char *optarg = 0;
#define BADCH (int)'?'
#define EMSG ""
int getopt(int nargc, char *const nargv[], char *ostr)
{
static const char *place = EMSG; /* option letter processing */
char *oli; /* option letter list index */
char *p;
if (!*place)
{
if (optind >= nargc || *(place = nargv[optind]) != '-')
{
place = EMSG;
return(EOF);
}
if (place[1] && *++place == '-')
{
++optind;
place = EMSG;
return(EOF);
}
}
if ((optopt = (int)*place++) == (int)':'
|| !(oli = strchr(ostr, optopt)))
{
/*
* if the user didn't specify '-' as an option,
* assume it means EOF.
*/
if (optopt == (int)'-')
return EOF;
if (!*place)
++optind;
if (opterr)
{
if (!(p = strrchr(*nargv, '/')))
p = *nargv;
else
++p;
fprintf(stderr, "%s: illegal option -- %c\n", p, optopt);
}
return BADCH;
}
if (*++oli != ':')
{ /* don't need argument */
optarg = NULL;
if (!*place)
++optind;
}
else
{ /* need an argument */
if (*place) /* no white space */
optarg = unconst(place, char *);
else if (nargc <= ++optind)
{ /* no arg */
place = EMSG;
if (!(p = strrchr(*nargv, '/')))
p = *nargv;
else
++p;
if (opterr)
fprintf(stderr, "%s: option requires an argument -- %c\n", p, optopt);
return BADCH;
}
else /* white space */
optarg = nargv[optind];
place = EMSG;
++optind;
}
return optopt; /* dump back option letter */
}
#endif
/*
* This file is part of the Scale2x project.
*
* Copyright (C) 2003 Andrea Mazzoleni
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "pixel.h"
pixel_t pixel_get(int x, int y, const unsigned char* pix, unsigned slice, unsigned pixel, unsigned dx, unsigned dy, int opt_tes)
{
const unsigned char* p;
unsigned i;
pixel_t v;
if (opt_tes) {
if (x < 0)
x += dx;
if (x >= dx)
x -= dx;
if (y < 0)
y += dy;
if (y >= dy)
y -= dy;
} else {
if (x < 0)
x = 0;
if (x >= dx)
x = dx - 1;
if (y < 0)
y = 0;
if (y >= dy)
y = dy - 1;
}
p = pix + (y * slice) + (x * pixel);
v = 0;
for(i=0;i<pixel;++i)
v |= ((pixel_t)p[i]) << (i*8);
return v;
}
void pixel_put(int x, int y, unsigned char* pix, unsigned slice, unsigned pixel, unsigned dx, unsigned dy, pixel_t v)
{
unsigned char* p;
unsigned i;
p = pix + (y * slice) + (x * pixel);
for(i=0;i<pixel;++i) {
p[i] = v >> (i*8);
}
}
/*
* This file is part of the Scale2x project.
*
* Copyright (C) 2003 Andrea Mazzoleni
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __PIXEL_H
#define __PIXEL_H
typedef unsigned long long pixel_t;
pixel_t pixel_get(int x, int y, const unsigned char* pix, unsigned slice, unsigned pixel, unsigned dx, unsigned dy, int opt_tes);
void pixel_put(int x, int y, unsigned char* pix, unsigned slice, unsigned pixel, unsigned dx, unsigned dy, pixel_t v);
#endif
/*
* This file is part of the Scale2x project.
*
* Copyright (C) 2001, 2002, 2003 Andrea Mazzoleni
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __PORTABLE_H
#define __PORTABLE_H
#if HAVE_CONFIG_H
#include <config.h>
#endif
/* ------------------------------------------------------------------------ */
/* getopt */
#if HAVE_GETOPT_H
#include <getopt.h>
#endif
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#if !HAVE_GETOPT
int getopt(int argc, char * const *argv, const char *options);
extern char *optarg;
extern int optind, opterr, optopt;
#endif
#endif
This diff is collapsed.
/*
* This file is part of the Scale2x project.
*
* Copyright (C) 2001, 2002, 2003, 2004 Andrea Mazzoleni
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __SCALE2X_H
#define __SCALE2X_H
#define restrict
typedef unsigned char scale2x_uint8;
typedef unsigned short scale2x_uint16;
typedef unsigned scale2x_uint32;
void scale2x_8_def(scale2x_uint8* dst0, scale2x_uint8* dst1, const scale2x_uint8* src0, const scale2x_uint8* src1, const scale2x_uint8* src2, unsigned count);
void scale2x_16_def(scale2x_uint16* dst0, scale2x_uint16* dst1, const scale2x_uint16* src0, const scale2x_uint16* src1, const scale2x_uint16* src2, unsigned count);
void scale2x_32_def(scale2x_uint32* dst0, scale2x_uint32* dst1, const scale2x_uint32* src0, const scale2x_uint32* src1, const scale2x_uint32* src2, unsigned count);
void scale2x3_8_def(scale2x_uint8* dst0, scale2x_uint8* dst1, scale2x_uint8* dst2, const scale2x_uint8* src0, const scale2x_uint8* src1, const scale2x_uint8* src2, unsigned count);
void scale2x3_16_def(scale2x_uint16* dst0, scale2x_uint16* dst1, scale2x_uint16* dst2, const scale2x_uint16* src0, const scale2x_uint16* src1, const scale2x_uint16* src2, unsigned count);
void scale2x3_32_def(scale2x_uint32* dst0, scale2x_uint32* dst1, scale2x_uint32* dst2, const scale2x_uint32* src0, const scale2x_uint32* src1, const scale2x_uint32* src2, unsigned count);
void scale2x4_8_def(scale2x_uint8* dst0, scale2x_uint8* dst1, scale2x_uint8* dst2, scale2x_uint8* dst3, const scale2x_uint8* src0, const scale2x_uint8* src1, const scale2x_uint8* src2, unsigned count);
void scale2x4_16_def(scale2x_uint16* dst0, scale2x_uint16* dst1, scale2x_uint16* dst2, scale2x_uint16* dst3, const scale2x_uint16* src0, const scale2x_uint16* src1, const scale2x_uint16* src2, unsigned count);
void scale2x4_32_def(scale2x_uint32* dst0, scale2x_uint32* dst1, scale2x_uint32* dst2, scale2x_uint32* dst3, const scale2x_uint32* src0, const scale2x_uint32* src1, const scale2x_uint32* src2, unsigned count);
#if defined(__GNUC__) && defined(__i386__)
void scale2x_8_mmx(scale2x_uint8* dst0, scale2x_uint8* dst1, const scale2x_uint8* src0, const scale2x_uint8* src1, const scale2x_uint8* src2, unsigned count);
void scale2x_16_mmx(scale2x_uint16* dst0, scale2x_uint16* dst1, const scale2x_uint16* src0, const scale2x_uint16* src1, const scale2x_uint16* src2, unsigned count);
void scale2x_32_mmx(scale2x_uint32* dst0, scale2x_uint32* dst1, const scale2x_uint32* src0, const scale2x_uint32* src1, const scale2x_uint32* src2, unsigned count);
void scale2x3_8_mmx(scale2x_uint8* dst0, scale2x_uint8* dst1, scale2x_uint8* dst2, const scale2x_uint8* src0, const scale2x_uint8* src1, const scale2x_uint8* src2, unsigned count);
void scale2x3_16_mmx(scale2x_uint16* dst0, scale2x_uint16* dst1, scale2x_uint16* dst2, const scale2x_uint16* src0, const scale2x_uint16* src1, const scale2x_uint16* src2, unsigned count);
void scale2x3_32_mmx(scale2x_uint32* dst0, scale2x_uint32* dst1, scale2x_uint32* dst2, const scale2x_uint32* src0, const scale2x_uint32* src1, const scale2x_uint32* src2, unsigned count);
void scale2x4_8_mmx(scale2x_uint8* dst0, scale2x_uint8* dst1, scale2x_uint8* dst2, scale2x_uint8* dst3, const scale2x_uint8* src0, const scale2x_uint8* src1, const scale2x_uint8* src2, unsigned count);
void scale2x4_16_mmx(scale2x_uint16* dst0, scale2x_uint16* dst1, scale2x_uint16* dst2, scale2x_uint16* dst3, const scale2x_uint16* src0, const scale2x_uint16* src1, const scale2x_uint16* src2, unsigned count);
void scale2x4_32_mmx(scale2x_uint32* dst0, scale2x_uint32* dst1, scale2x_uint32* dst2, scale2x_uint32* dst3, const scale2x_uint32* src0, const scale2x_uint32* src1, const scale2x_uint32* src2, unsigned count);
/**
* End the use of the MMX instructions.
* This function must be called before using any floating-point operations.
*/
static inline void scale2x_mmx_emms(void)
{
__asm__ __volatile__ (
"emms"
);
}
#endif
#endif
This diff is collapsed.
/*
* This file is part of the Scale2x project.
*
* Copyright (C) 2001, 2002, 2003, 2004 Andrea Mazzoleni
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __SCALE3X_H
#define __SCALE3X_H
#define restrict
typedef unsigned char scale3x_uint8;
typedef unsigned short scale3x_uint16;
typedef unsigned scale3x_uint32;
void scale3x_8_def(scale3x_uint8* dst0, scale3x_uint8* dst1, scale3x_uint8* dst2, const scale3x_uint8* src0, const scale3x_uint8* src1, const scale3x_uint8* src2, unsigned count);
void scale3x_16_def(scale3x_uint16* dst0, scale3x_uint16* dst1, scale3x_uint16* dst2, const scale3x_uint16* src0, const scale3x_uint16* src1, const scale3x_uint16* src2, unsigned count);
void scale3x_32_def(scale3x_uint32* dst0, scale3x_uint32* dst1, scale3x_uint32* dst2, const scale3x_uint32* src0, const scale3x_uint32* src1, const scale3x_uint32* src2, unsigned count);
#endif
This diff is collapsed.
/*
* This file is part of the Scale2x project.
*
* Copyright (C) 2003 Andrea Mazzoleni
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* This file contains an example implementation of the Scale effect
* applyed to a generic bitmap.
*
* You can find an high level description of the effect at :
*
* http://scale2x.sourceforge.net/
*
* Alternatively at the previous license terms, you are allowed to use this
* code in your program with these conditions:
* - the program is not used in commercial activities.
* - the whole source code of the program is released with the binary.
* - derivative works of the program are allowed.
*/
#ifndef __SCALEBIT_H
#define __SCALEBIT_H
int scale_precondition(unsigned scale, unsigned pixel, unsigned width, unsigned height);
void scale(unsigned scale, void* void_dst, unsigned dst_slice, const void* void_src, unsigned src_slice, unsigned pixel, unsigned width, unsigned height);
void Simple2x(unsigned char *srcPtr, unsigned int srcPitch, unsigned char *deltaPtr, unsigned char *dstPtr, unsigned int dstPitch, int width, int height);
#endif
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA development team
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or(at your option)
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
/*
* Code adapted To openjazz by Pickle (from Openbor adapted by SX
* simple2x.c - Trying to scale 2x.
*
*
*/
#include "scalebit.h"
void Simple2x(unsigned char *srcPtr, unsigned int srcPitch, unsigned char *deltaPtr, unsigned char *dstPtr, unsigned int dstPitch, int width, int height)
{
unsigned char *nextLine, *finish;
nextLine = dstPtr + dstPitch;
do
{
unsigned char *bP = (unsigned char *) srcPtr;
unsigned char *dP = (unsigned char *) dstPtr;
unsigned char *nL = (unsigned char *) nextLine;
unsigned char currentPixel;
finish = (unsigned char *) bP + ((width+2) << 1);
currentPixel = *bP++;
do
{
#ifdef BIG_ENDIAN
unsigned char color = currentPixel >> 16;
#else
unsigned char color = currentPixel & 0xffff;
#endif
color = color | (color << 16);
*(dP) = color;
*(nL) = color;
//#ifdef BIG_ENDIAN
// color = currentPixel & 0xffff;
//#else
// color = currentPixel >> 16;
//#endif
color = color| (color << 16);
*(dP + 1) = color;
*(nL + 1) = color;
currentPixel = *bP++;
dP += 2;
nL += 2;
}
while ((unsigned char *) bP < finish);
srcPtr += srcPitch;
dstPtr += dstPitch << 1;
nextLine += dstPitch << 1;
}
while (--height);
}
void Simple2x32(unsigned char *srcPtr, unsigned int srcPitch, unsigned char *deltaPtr, unsigned char *dstPtr, unsigned int dstPitch, int width, int height)
{
unsigned char *nextLine, *finish;
nextLine = dstPtr + dstPitch;
do
{
unsigned int *bP = (unsigned int *) srcPtr;
unsigned int *dP = (unsigned int *) dstPtr;
unsigned int *nL = (unsigned int *) nextLine;
unsigned int currentPixel;
finish = (unsigned char *) bP + ((width+1) << 2);
currentPixel = *bP++;
do
{
unsigned int color = currentPixel;
*(dP) = color;
*(dP+1) = color;
*(nL) = color;
*(nL + 1) = color;
currentPixel = *bP++;
dP += 2;
nL += 2;
}
while ((unsigned char *) bP < finish);
srcPtr += srcPitch;
dstPtr += dstPitch << 1;
nextLine += dstPitch << 1;
}
while (--height);
}
......@@ -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
......@@ -127,7 +127,7 @@ void Sprite::draw (int x, int y) {
dst.x = x + xOffset;
dst.y = y + yOffset;
SDL_BlitSurface(pixels, NULL, screen, &dst);
SDL_BlitSurface(pixels, NULL, canvas, &dst);
return;
......
......@@ -42,8 +42,8 @@ SDL_Surface * createSurface (unsigned char * pixels, int width, int height) {
// Set the surface's palette
SDL_SetPalette(ret, SDL_LOGPAL, logicalPalette, 0, 256);
if (pixels != NULL )
{
if (pixels != NULL) {
// Upload pixel data to the surface
if (SDL_MUSTLOCK(ret)) SDL_LockSurface(ret);
......@@ -55,6 +55,7 @@ SDL_Surface * createSurface (unsigned char * pixels, int width, int height) {
// Free redundant pixel data
delete[] pixels;
}
return ret;
......@@ -64,32 +65,38 @@ SDL_Surface * createSurface (unsigned char * pixels, int width, int height) {
void createFullscreen () {
#ifdef SCALE
if (canvas != screen) SDL_FreeSurface(canvas);
#endif
#if defined(WIZ) || defined(GP2X)
screen = SDL_SetVideoMode(320, 240, 8,
SDL_FULLSCREEN | SDL_SWSURFACE | SDL_HWPALETTE);
screen = SDL_SetVideoMode(320, 240, 8, V_FULLSCREEN);
#else
screen = SDL_SetVideoMode(screenW, screenH, 8, V_FULLSCREEN);
#endif
#ifdef SCALE
screen_scaled = SDL_SetVideoMode(screenW*scalar, screenH*scalar, 8,
SDL_FULLSCREEN | SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_HWPALETTE);
if (scaleFactor > 1) {
if (screen)
SDL_FreeSurface(screen);
canvasW = screenW / scaleFactor;
canvasH = screenH / scaleFactor;
canvas = createSurface(NULL, canvasW, canvasH);
screen = createSurface( NULL, screenW, screenH );
} else {
#endif
SDL_SetPalette(screen_scaled, SDL_LOGPAL, logicalPalette, 0, 256);
SDL_SetPalette(screen_scaled, SDL_PHYSPAL, currentPalette, 0, 256);
#else
screen = SDL_SetVideoMode(screenW, screenH, 8,
SDL_FULLSCREEN | SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_HWPALETTE);
canvasW = screenW;
canvasH = screenH;
canvas = screen;
#ifdef SCALE
}
#endif
#if !(defined(WIZ) || defined(GP2X))
SDL_SetPalette(screen, SDL_LOGPAL, logicalPalette, 0, 256);
SDL_SetPalette(screen, SDL_PHYSPAL, currentPalette, 0, 256);
#endif
#endif
SDL_ShowCursor(SDL_DISABLE);
/* A real 8-bit display is quite likely if the user has the right video
......@@ -110,25 +117,33 @@ void createFullscreen () {
#ifndef FULLSCREEN_ONLY
void createWindow () {
#ifdef SCALE
screen_scaled = SDL_SetVideoMode(screenW*scalar, screenH*scalar, 8,
SDL_RESIZABLE | SDL_DOUBLEBUF | SDL_HWSURFACE);
#ifdef SCALE
if (canvas != screen) SDL_FreeSurface(canvas);
#endif
if (screen)
SDL_FreeSurface(screen);
screen = SDL_SetVideoMode(screenW, screenH, 8, V_WINDOWED);
screen = createSurface( NULL, screenW, screenH );
#ifdef SCALE
if (scaleFactor > 1) {
SDL_SetPalette(screen_scaled, SDL_LOGPAL, logicalPalette, 0, 256);
SDL_SetPalette(screen_scaled, SDL_PHYSPAL, currentPalette, 0, 256);
#else
screen = SDL_SetVideoMode(screenW, screenH, 8,
SDL_RESIZABLE | SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_HWPALETTE);
canvasW = screenW / scaleFactor;
canvasH = screenH / scaleFactor;
canvas = createSurface(NULL, canvasW, canvasH);
} else {
#endif
canvasW = screenW;
canvasH = screenH;
canvas = screen;
#ifdef SCALE
}
#endif
SDL_SetPalette(screen, SDL_LOGPAL, logicalPalette, 0, 256);
SDL_SetPalette(screen, SDL_PHYSPAL, currentPalette, 0, 256);
#endif
SDL_ShowCursor(SDL_ENABLE);
/* Assume that in windowed mode the palette is being emulated.
This is extremely likely. */
......@@ -150,9 +165,6 @@ void usePalette (SDL_Color *palette) {
#endif
SDL_SetPalette(screen, SDL_PHYSPAL, palette, 0, 256);
#ifdef SCALE
SDL_SetPalette(screen_scaled, SDL_PHYSPAL, palette, 0, 256);
#endif
currentPalette = palette;
return;
......@@ -175,8 +187,9 @@ void clearScreen (int index) {
// always 240 lines cleared to black
memset(screen->pixels, index, 320*240);
#else
SDL_FillRect(screen, NULL, index);
SDL_FillRect(canvas, NULL, index);
#endif
return;
}
......@@ -191,7 +204,7 @@ void drawRect (int x, int y, int width, int height, int index) {
dst.w = width;
dst.h = height;
SDL_FillRect(screen, &dst, index);
SDL_FillRect(canvas, &dst, index);
return;
......
......@@ -31,17 +31,24 @@
// Constants
#define V_WINDOWED (SDL_RESIZABLE | SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_HWPALETTE)
#if defined(WIZ) || defined(GP2X)
#define V_FULLSCREEN (SDL_FULLSCREEN | SDL_SWSURFACE | SDL_HWPALETTE)
#else
#define V_FULLSCREEN (SDL_FULLSCREEN | SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_HWPALETTE)
#endif
// Black palette index
#define BLACK 31
// Variables
EXTERN SDL_Surface *screen;
EXTERN int viewW, viewH, screenW, screenH;
EXTERN int scalar;
EXTERN SDL_Surface *screen, *canvas;
EXTERN int viewW, viewH, canvasW, canvasH, screenW, screenH;
#ifdef SCALE
EXTERN SDL_Surface *screen_scaled;
EXTERN int scaleFactor;
#endif
#ifndef FULLSCREEN_ONLY
EXTERN bool fullscreen;
......@@ -68,8 +75,7 @@ EXTERN void createWindow ();
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 void drawRect (int x, int y, int width, int height, int index);
#endif
......
......@@ -201,8 +201,7 @@ int Network::join (char *address) {
}
clearScreen(0);
fontmn2->showString("CONNECTING TO SERVER", screenW >> 2,
(screenH >> 1) - 16);
fontmn2->showString("CONNECTING TO SERVER", canvasW >> 2, (canvasH >> 1) - 16);
FD_ZERO(&writefds);
FD_SET(sock, &writefds);
......@@ -233,8 +232,7 @@ int Network::join (char *address) {
return sock;
#elif defined USE_SDL_NET
clearScreen(0);
fontmn2->showString("CONNECTING TO SERVER", screenW >> 2,
(screenH >> 1) - 16);
fontmn2->showString("CONNECTING TO SERVER", canvasW >> 2, (canvasH >> 1) - 16);
loop(NORMAL_LOOP);
ipAddress.port = NET_PORT;
ipAddress.host = inet_addr(address);
......
......@@ -173,7 +173,7 @@ int DemoLevel::play () {
draw();
fontmn1->showString("DEMO", (screenW >> 1) - 36, 32);
fontmn1->showString("DEMO", (canvasW >> 1) - 36, 32);
// Draw graphics statistics
......@@ -182,9 +182,9 @@ int DemoLevel::play () {
drawRect(236, 9, 80, 32, BLACK);
panelBigFont->showNumber(screenW, 268, 15);
panelBigFont->showNumber(canvasW, 268, 15);
panelBigFont->showString("x", 272, 15);
panelBigFont->showNumber(screenH, 308, 15);
panelBigFont->showNumber(canvasH, 308, 15);
panelBigFont->showString("fps", 244, 27);
panelBigFont->showNumber((int)smoothfps, 308, 27);
......
......@@ -733,7 +733,7 @@ int Level::play () {
// If paused, draw "PAUSE"
if (paused && !pmenu)
fontmn1->showString("PAUSE", (screenW >> 1) - 44, 32);
fontmn1->showString("PAUSE", (canvasW >> 1) - 44, 32);
// If this is a competitive game, draw the score
......@@ -772,9 +772,9 @@ int Level::play () {
drawRect(viewW - 84, 11, 80, 25, BLACK);
panelBigFont->showNumber(screenW, viewW - 52, 14);
panelBigFont->showNumber(canvasW, viewW - 52, 14);
panelBigFont->showString("x", viewW - 48, 14);
panelBigFont->showNumber(screenH, viewW - 12, 14);
panelBigFont->showNumber(canvasH, viewW - 12, 14);
panelBigFont->showString("fps", viewW - 76, 26);
panelBigFont->showNumber((int)smoothfps, viewW - 12, 26);
......@@ -826,38 +826,28 @@ int Level::play () {
// Display statistics & bonuses
// TODO: Display percentage symbol
fontmn1->showString("TIME", (screenW >> 1) - 152,
(screenH >> 1) - 60);
fontmn1->showNumber(timeBonus, (screenW >> 1) + 124,
(screenH >> 1) - 60);
fontmn1->showString("TIME", (canvasW >> 1) - 152, (canvasH >> 1) - 60);
fontmn1->showNumber(timeBonus, (canvasW >> 1) + 124, (canvasH >> 1) - 60);
fontmn1->showString("ENEMIES", (screenW >> 1) - 152,
(screenH >> 1) - 40);
fontmn1->showString("ENEMIES", (canvasW >> 1) - 152, (canvasH >> 1) - 40);
if (enemies)
fontmn1->showNumber((localPlayer->getEnemies() * 100) / enemies,
(screenW >> 1) + 124, (screenH >> 1) - 40);
fontmn1->showNumber((localPlayer->getEnemies() * 100) / enemies, (canvasW >> 1) + 124, (canvasH >> 1) - 40);
else
fontmn1->showNumber(0, (screenW >> 1) + 124,
(screenH >> 1) - 40);
fontmn1->showNumber(0, (canvasW >> 1) + 124, (canvasH >> 1) - 40);
fontmn1->showString("ITEMS", (screenW >> 1) - 152,
(screenH >> 1) - 20);
fontmn1->showString("ITEMS", (canvasW >> 1) - 152, (canvasH >> 1) - 20);
if (items)
fontmn1->showNumber((localPlayer->getItems() * 100) / items,
(screenW >> 1) + 124, (screenH >> 1) - 20);
fontmn1->showNumber((localPlayer->getItems() * 100) / items, (canvasW >> 1) + 124, (canvasH >> 1) - 20);
else
fontmn1->showNumber(0, (screenW >> 1) + 124,
(screenH >> 1) - 20);
fontmn1->showNumber(0, (canvasW >> 1) + 124, (canvasH >> 1) - 20);
fontmn1->showString("PERFECT", (screenW >> 1) - 152, screenH >> 1);
fontmn1->showNumber(perfect, (screenW >> 1) + 124, screenH >> 1);
fontmn1->showString("PERFECT", (canvasW >> 1) - 152, canvasH >> 1);
fontmn1->showNumber(perfect, (canvasW >> 1) + 124, canvasH >> 1);
fontmn1->showString("SCORE", (screenW >> 1) - 152,
(screenH >> 1) + 40);
fontmn1->showNumber(localPlayer->getScore(), (screenW >> 1) + 124,
(screenH >> 1) + 40);
fontmn1->showString("SCORE", (canvasW >> 1) - 152, (canvasH >> 1) + 40);
fontmn1->showNumber(localPlayer->getScore(), (canvasW >> 1) + 124, (canvasH >> 1) + 40);
}
......@@ -866,15 +856,14 @@ int Level::play () {
// Draw the menu
drawRect((screenW >> 2) - 8, (screenH >> 1) - 46, 144, 92, BLACK);
drawRect((canvasW >> 2) - 8, (canvasH >> 1) - 46, 144, 92, BLACK);
for (count = 0; count < 5; count++) {
if (count == option) fontmn2->mapPalette(240, 8, 47, -16);
else fontmn2->mapPalette(240, 8, 15, -16);
fontmn2->showString(options[count], screenW >> 2,
(screenH >> 1) + (count << 4) - 38);
fontmn2->showString(options[count], canvasW >> 2, (canvasH >> 1) + (count << 4) - 38);
}
......
......@@ -206,20 +206,20 @@ void Level::draw () {
vY = FTOI(viewY);
dst.w = viewW;
dst.h = viewH;
SDL_SetClipRect(screen, &dst);
SDL_SetClipRect(canvas, &dst);
if ((viewW < screenW) || (viewH < screenH)) clearScreen(15);
if ((viewW < canvasW) || (viewH < canvasH)) clearScreen(15);
// If there is a sky, draw it
if (sky) {
// Background scale
if (screenW > 320) bgScale = ((screenH - 1) / 100) + 1;
else bgScale = ((screenH - 34) / 100) + 1;
if (canvasW > 320) bgScale = ((canvasH - 1) / 100) + 1;
else bgScale = ((canvasH - 34) / 100) + 1;
for (y = 0; y < viewH; y += bgScale)
drawRect(0, y, screenW, bgScale, 156 + (y / bgScale));
drawRect(0, y, canvasW, bgScale, 156 + (y / bgScale));
// Show sun / moon / etc.
......@@ -228,7 +228,7 @@ void Level::draw () {
dst.x = (viewW * 4) / 5;
dst.y = (viewH * 3) / 25;
src.y = TTOI(skyOrb);
SDL_BlitSurface(tileSet, &src, screen, &dst);
SDL_BlitSurface(tileSet, &src, canvas, &dst);
}
......@@ -264,7 +264,7 @@ void Level::draw () {
dst.x = TTOI(x) - (vX & 31);
dst.y = TTOI(y) - (vY & 31);
src.y = TTOI(ge->tile);
SDL_BlitSurface(tileSet, &src, screen, &dst);
SDL_BlitSurface(tileSet, &src, canvas, &dst);
}
......@@ -317,7 +317,7 @@ void Level::draw () {
dst.y = TTOI(y) - (vY & 31);
if (ticks & 64) src.y = TTOI(eventSet[ge->event][E_YAXIS]);
else src.y = TTOI(eventSet[ge->event][E_MULTIPURPOSE]);
SDL_BlitSurface(tileSet, &src, screen, &dst);
SDL_BlitSurface(tileSet, &src, canvas, &dst);
}
......@@ -328,7 +328,7 @@ void Level::draw () {
dst.x = TTOI(x) - (vX & 31);
dst.y = TTOI(y) - (vY & 31);
src.y = TTOI(ge->tile);
SDL_BlitSurface(tileSet, &src, screen, &dst);
SDL_BlitSurface(tileSet, &src, canvas, &dst);
}
......@@ -337,13 +337,13 @@ void Level::draw () {
}
// Temporary lines showing the water level
drawRect(0, FTOI(waterLevel - viewY), screenW, 2, 24);
drawRect(0, FTOI(waterLevel - viewY) + 3, screenW, 1, 24);
drawRect(0, FTOI(waterLevel - viewY) + 6, screenW, 1, 24);
drawRect(0, FTOI(waterLevel - viewY) + 10, screenW, 1, 24);
drawRect(0, FTOI(waterLevel - viewY), canvasW, 2, 24);
drawRect(0, FTOI(waterLevel - viewY) + 3, canvasW, 1, 24);
drawRect(0, FTOI(waterLevel - viewY) + 6, canvasW, 1, 24);
drawRect(0, FTOI(waterLevel - viewY) + 10, canvasW, 1, 24);
SDL_SetClipRect(screen, NULL);
SDL_SetClipRect(canvas, NULL);
// Show panel
......@@ -355,48 +355,48 @@ void Level::draw () {
&dst);
dst.x = 0;
dst.y = screenH - 33;
SDL_BlitSurface(panel, NULL, screen, &dst);
drawRect(0, screenH - 1, 320, 1, BLACK);
dst.y = canvasH - 33;
SDL_BlitSurface(panel, NULL, canvas, &dst);
drawRect(0, canvasH - 1, 320, 1, BLACK);
// Show panel data
// Show score
panelSmallFont->showNumber(localPlayer->getScore(), 84, screenH - 27);
panelSmallFont->showNumber(localPlayer->getScore(), 84, canvasH - 27);
// Show time remaining
if (endTime > ticks) x = endTime - ticks;
else x = 0;
y = x / (60 * 1000);
panelSmallFont->showNumber(y, 116, screenH - 27);
panelSmallFont->showNumber(y, 116, canvasH - 27);
x -= (y * 60 * 1000);
y = x / 1000;
panelSmallFont->showNumber(y, 136, screenH - 27);
panelSmallFont->showNumber(y, 136, canvasH - 27);
x -= (y * 1000);
y = x / 100;
panelSmallFont->showNumber(y, 148, screenH - 27);
panelSmallFont->showNumber(y, 148, canvasH - 27);
// Show lives
panelSmallFont->showNumber(localPlayer->getLives(), 124, screenH - 13);
panelSmallFont->showNumber(localPlayer->getLives(), 124, canvasH - 13);
// Show planet number
if (worldNum <= 41) // Main game levels
panelSmallFont->showNumber((worldNum % 3) + 1, 184, screenH - 13);
panelSmallFont->showNumber((worldNum % 3) + 1, 184, canvasH - 13);
else if ((worldNum >= 50) && (worldNum <= 52)) // Christmas levels
panelSmallFont->showNumber(worldNum - 49, 184, screenH - 13);
else panelSmallFont->showNumber(worldNum, 184, screenH - 13);
panelSmallFont->showNumber(worldNum - 49, 184, canvasH - 13);
else panelSmallFont->showNumber(worldNum, 184, canvasH - 13);
// Show level number
panelSmallFont->showNumber(levelNum + 1, 196, screenH - 13);
panelSmallFont->showNumber(levelNum + 1, 196, canvasH - 13);
// Show ammo
if (localPlayer->getAmmo(false) == -1)
panelSmallFont->showString(":;", 225, screenH - 13);
panelSmallFont->showString(":;", 225, canvasH - 13);
else panelSmallFont->showNumber(localPlayer->getAmmo(true), 245,
screenH - 13);
canvasH - 13);
// Draw the health bar
......@@ -428,7 +428,7 @@ void Level::draw () {
else if (x <= 1) x = 32 + (((ticks / 75) * 4) & 15);
// Draw energy bar
drawRect(dst.x, screenH - 13, dst.w, 7, x);
drawRect(dst.x, canvasH - 13, dst.w, 7, x);
dst.x += dst.w;
dst.w = 64 - dst.w;
......@@ -437,7 +437,7 @@ void Level::draw () {
// Fill in remaining energy bar space with black
drawRect(dst.x, screenH - 13, dst.w, 7, BLACK);
drawRect(dst.x, canvasH - 13, dst.w, 7, BLACK);
return;
......
......@@ -490,10 +490,10 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) {
clearScreen(0);
x = (screenW >> 1) - ((strlen(string) + strlen(ext)) << 2);
x = fontmn2->showString("LOADING ", x - 60, (screenH >> 1) - 16);
x = fontmn2->showString(string, x, (screenH >> 1) - 16);
fontmn2->showString(ext, x, (screenH >> 1) - 16);
x = (canvasW >> 1) - ((strlen(string) + strlen(ext)) << 2);
x = fontmn2->showString("LOADING ", x - 60, (canvasH >> 1) - 16);
x = fontmn2->showString(string, x, (canvasH >> 1) - 16);
fontmn2->showString(ext, x, (canvasH >> 1) - 16);
delete[] string;
......
......@@ -58,7 +58,7 @@ extern char KOpenJazzPath[256];
#endif
#ifdef SCALE
#include "scale2x/scalebit.h"
#include "io/gfx/scale2x/scalebit.h"
#endif
int loadMain (int argc, char *argv[]) {
......@@ -66,6 +66,9 @@ int loadMain (int argc, char *argv[]) {
File *file;
unsigned char *pixels, *sorted;
int count, x, y;
#ifndef SCALE
int scaleFactor;
#endif
// Determine paths
......@@ -195,18 +198,14 @@ int loadMain (int argc, char *argv[]) {
// Read video settings
screenW = file->loadShort();
screenH = file->loadShort();
#ifdef SCALE
scalar = file->loadChar();
#else
scalar = 1;
file->loadChar();
#endif
#ifdef FULLSCREEN_ONLY
file->loadChar();
#else
fullscreen = file->loadChar();
scaleFactor = file->loadChar();
#ifndef FULLSCREEN_ONLY
fullscreen = scaleFactor & 1;
#endif
scaleFactor >>= 1;
if (scaleFactor > 4) scaleFactor = 1;
// Read controls
for (count = 0; count < CONTROLS - 4; count++)
......@@ -255,22 +254,31 @@ 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) createWindow();
else {
#endif
#ifdef FULLSCREEN_ONLY
SDL_ShowCursor(SDL_DISABLE);
createFullscreen();
#else
if (fullscreen) createFullscreen();
else createWindow();
#ifndef FULLSCREEN_ONLY
}
#endif
#ifdef SCALE
if (!screen_scaled) {
#else
if (!screen) {
#endif
logError("Could not set video mode", SDL_GetError());
delete characterName;
......@@ -287,15 +295,7 @@ int loadMain (int argc, char *argv[]) {
if (SDL_NumJoysticks() > 0) SDL_JoystickOpen(0);
// Generate the logical palette
for (count = 0; count < 256; count++)
logicalPalette[count].r = logicalPalette[count].g =
logicalPalette[count].b = count;
restorePalette(screen);
#ifdef SCALE
restorePalette(screen_scaled);
#endif
firstPE = NULL;
......@@ -464,6 +464,9 @@ void freeMain () {
File *file;
int count;
#ifndef SCALE
int scaleFactor = 1;
#endif
delete net;
......@@ -483,7 +486,7 @@ void freeMain () {
SDL_FreeSurface(panelAmmo[4]);
#ifdef SCALE
SDL_FreeSurface(screen);
if (canvas != screen) SDL_FreeSurface(canvas);
#endif
closeAudio();
......@@ -509,17 +512,12 @@ void freeMain () {
// Write video settings
file->storeShort(screenW);
file->storeShort(screenH);
#ifdef SCALE
file->storeChar(scalar);
#else
file->storeChar(1);
scaleFactor <<= 1;
#ifndef FULLSCREEN_ONLY
scaleFactor |= fullscreen? 1: 0;
#endif
file->storeChar(scaleFactor);
#ifdef FULLSCREEN_ONLY
file->storeChar(1);
#else
file->storeChar(fullscreen? ~0: 0);
#endif
// Write controls
for (count = 0; count < CONTROLS - 4; count++)
......@@ -572,24 +570,17 @@ int loop (int type) {
// Show everything that has been drawn so far
#ifdef SCALE
if (scalar>1) {
int depth = screen_scaled->format->BytesPerPixel;
if (canvas != screen) {
scale(scalar, screen_scaled->pixels, screen->w*depth*scalar, screen->pixels, screen->w*depth,
depth, screen->w, screen->h );
scale(scaleFactor,
screen->pixels, screen->pitch,
canvas->pixels, canvas->pitch,
screen->format->BytesPerPixel, canvas->w, canvas->h);
//Simple2x((unsigned char*)screen->pixels, screen->w*depth, 0, (unsigned char*)screen_scaled->pixels, screen->w*depth*2,
// screen->w, screen->h );
}
else
{
SDL_BlitSurface(screen, NULL, screen_scaled, NULL);
}
#endif
SDL_Flip(screen_scaled);
#else
SDL_Flip(screen);
#endif
prevTicks = globalTicks;
......@@ -609,8 +600,17 @@ int loop (int type) {
fullscreen = !fullscreen;
if (fullscreen) createFullscreen();
else createWindow();
if (fullscreen) {
SDL_ShowCursor(SDL_DISABLE);
createFullscreen();
} else {
createWindow();
SDL_ShowCursor(SDL_ENABLE);
}
}
#endif
......@@ -649,31 +649,15 @@ int loop (int type) {
screenW = event.resize.w;
screenH = event.resize.h;
#ifdef SCALE
screen_scaled = SDL_SetVideoMode(screenW*scalar, screenH*scalar, 8,
SDL_RESIZABLE | SDL_DOUBLEBUF | SDL_HWSURFACE |
SDL_HWPALETTE);
if (screen)
SDL_FreeSurface(screen);
createWindow();
screen = SDL_CreateRGBSurface(SDL_HWSURFACE, screenW, screenH, 8, 0, 0, 0, 0);
#else
screen = SDL_SetVideoMode(screenW, screenH, 8,
SDL_RESIZABLE | SDL_DOUBLEBUF | SDL_HWSURFACE |
SDL_HWPALETTE);
#endif
// The absence of a break statement is intentional
break;
case SDL_VIDEOEXPOSE:
SDL_SetPalette(screen, SDL_LOGPAL, logicalPalette, 0, 256);
SDL_SetPalette(screen, SDL_PHYSPAL, currentPalette, 0, 256);
#ifdef SCALE
SDL_SetPalette(screen_scaled, SDL_LOGPAL, logicalPalette, 0, 256);
SDL_SetPalette(screen_scaled, SDL_PHYSPAL, currentPalette, 0, 256);
#endif
break;
#endif
......@@ -706,10 +690,6 @@ int loop (int type) {
SDL_SetPalette(screen, SDL_PHYSPAL, shownPalette, 0, 256);
#ifdef SCALE
SDL_SetPalette(screen_scaled, SDL_PHYSPAL, shownPalette, 0, 256);
#endif
} else {
firstPE->apply(shownPalette, true, globalTicks - prevTicks);
......
......@@ -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
......@@ -59,8 +59,8 @@ int Menu::newGameDifficulty (int mode, int levelNum, int worldNum) {
if (count == difficulty) fontmn2->mapPalette(240, 8, 114, 16);
fontmn2->showString(options[count], screenW >> 2,
(screenH >> 1) + (count << 4) - 32);
fontmn2->showString(options[count], canvasW >> 2,
(canvasH >> 1) + (count << 4) - 32);
if (count == difficulty) fontmn2->restorePalette();
......@@ -70,9 +70,9 @@ int Menu::newGameDifficulty (int mode, int levelNum, int worldNum) {
src.y = (difficulty & 2) * 50;
src.w = 160;
src.h = 100;
dst.x = (screenW >> 1) - 40;
dst.y = (screenH >> 1) - 50;
SDL_BlitSurface(screens[2], &src, screen, &dst);
dst.x = (canvasW >> 1) - 40;
dst.y = (canvasH >> 1) - 50;
SDL_BlitSurface(screens[2], &src, canvas, &dst);
if (controls.release(C_UP)) difficulty = (difficulty + 3) % 4;
......@@ -171,14 +171,14 @@ int Menu::newGameLevel (int mode) {
clearScreen(15);
if (option == 0) fontmn2->mapPalette(240, 8, 114, 16);
fontmn2->showString("choose world:", 32, screenH / 3);
fontmn2->showNumber(worldNum, 208, screenH / 3);
fontmn2->showString("choose world:", 32, canvasH / 3);
fontmn2->showNumber(worldNum, 208, canvasH / 3);
if (option == 0) fontmn2->restorePalette();
else fontmn2->mapPalette(240, 8, 114, 16);
fontmn2->showString("choose level:", 32, (screenH << 1) / 3);
fontmn2->showNumber(levelNum, 208, (screenH << 1) / 3);
fontmn2->showString("choose level:", 32, (canvasH << 1) / 3);
fontmn2->showNumber(levelNum, 208, (canvasH << 1) / 3);
if (option != 0) fontmn2->restorePalette();
......@@ -263,15 +263,15 @@ int Menu::newGameEpisode (int mode) {
if ((episode < episodes - 1) || (episode < 6)) {
dst.x = screenW - 150;
dst.y = (screenH - 110) >> 1;
SDL_BlitSurface(screens[episode + 3], NULL, screen, &dst);
dst.x = canvasW - 150;
dst.y = (canvasH - 110) >> 1;
SDL_BlitSurface(screens[episode + 3], NULL, canvas, &dst);
} else if ((episode == 10) && (episodes > 6)) {
dst.x = screenW - 160;
dst.y = (screenH - 110) >> 1;
SDL_BlitSurface(screens[episodes + 2], NULL, screen, &dst);
dst.x = canvasW - 160;
dst.y = (canvasH - 110) >> 1;
SDL_BlitSurface(screens[episodes + 2], NULL, canvas, &dst);
}
......@@ -280,14 +280,14 @@ int Menu::newGameEpisode (int mode) {
if (count == episode) {
fontmn2->mapPalette(240, 8, 79, -80);
drawRect((screenW >> 3) - 4, (screenH >> 1) + (count << 4) - 94,
drawRect((canvasW >> 3) - 4, (canvasH >> 1) + (count << 4) - 94,
136, 15, 79);
} else if (!exists[count])
fontmn2->mapPalette(240, 8, 94, -16);
fontmn2->showString(options[count], screenW >> 3,
(screenH >> 1) + (count << 4) - 92);
fontmn2->showString(options[count], canvasW >> 3,
(canvasH >> 1) + (count << 4) - 92);
if ((count == episode) || (!exists[count]))
fontmn2->mapPalette(240, 8, 9, 80);
......
......@@ -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
......@@ -233,13 +233,13 @@ int Menu::main () {
clearScreen(28);
dst.x = (screenW >> 2) - 72;
dst.y = screenH - (screenH >> 2);
SDL_BlitSurface(screens[14], NULL, screen, &dst);
dst.x = (canvasW >> 2) - 72;
dst.y = canvasH - (canvasH >> 2);
SDL_BlitSurface(screens[14], NULL, canvas, &dst);
dst.x = (screenW - 320) >> 1;
dst.y = (screenH - 200) >> 1;
SDL_BlitSurface(screens[0], NULL, screen, &dst);
dst.x = (canvasW - 320) >> 1;
dst.y = (canvasH - 200) >> 1;
SDL_BlitSurface(screens[0], NULL, canvas, &dst);
switch (option) {
......@@ -299,9 +299,9 @@ int Menu::main () {
}
dst.x = ((screenW - 320) >> 1) + src.x;
dst.y = ((screenH - 200) >> 1) + src.y;
SDL_BlitSurface(screens[1], &src, screen, &dst);
dst.x = ((canvasW - 320) >> 1) + src.x;
dst.y = ((canvasH - 200) >> 1) + src.y;
SDL_BlitSurface(screens[1], &src, canvas, &dst);
}
......
......@@ -53,7 +53,7 @@ int Menu::message (const char *text) {
clearScreen(15);
// Draw the message
fontmn2->showString(text, screenW >> 2, (screenH >> 1) - 16);
fontmn2->showString(text, canvasW >> 2, (canvasH >> 1) - 16);
}
......@@ -86,8 +86,8 @@ int Menu::generic (const char **optionNames, int options, int *chosen) {
if (count == *chosen) fontmn2->mapPalette(240, 8, 114, 16);
fontmn2->showString(optionNames[count], screenW >> 2,
(screenH >> 1) + (count << 4) - (options << 3));
fontmn2->showString(optionNames[count], canvasW >> 2,
(canvasH >> 1) + (count << 4) - (options << 3));
if (count == *chosen) fontmn2->restorePalette();
......@@ -192,20 +192,20 @@ int Menu::textInput (const char *request, char **text) {
clearScreen(15);
// Draw the prompt
fontmn2->showString(request, screenW >> 2, (screenH >> 1) - 16);
fontmn2->showString(request, canvasW >> 2, (canvasH >> 1) - 16);
// Draw the section of the text before the cursor
fontmn2->mapPalette(240, 8, 114, 16);
terminate = input[cursor];
input[cursor] = 0;
x = fontmn2->showString(input, (screenW >> 2) + 8, screenH >> 1);
x = fontmn2->showString(input, (canvasW >> 2) + 8, canvasH >> 1);
// Draw the cursor
drawRect(x, (screenH >> 1) + 10, 8, 2, 79);
drawRect(x, (canvasH >> 1) + 10, 8, 2, 79);
// Draw the section of text after the cursor
input[cursor] = terminate;
fontmn2->showString(input + cursor, x, screenH >> 1);
fontmn2->showString(input + cursor, x, canvasH >> 1);
fontmn2->restorePalette();
......
......@@ -88,18 +88,18 @@ int Menu::setupKeyboard () {
for (count = 0; count < PCONTROLS; count++) {
if (count < progress)
fontmn2->showString("okay", (screenW >> 2) + 176,
(screenH >> 1) + (count << 4) - 56);
fontmn2->showString("okay", (canvasW >> 2) + 176,
(canvasH >> 1) + (count << 4) - 56);
else if (count == progress) fontmn2->mapPalette(240, 8, 114, 16);
fontmn2->showString(options[count], screenW >> 2,
(screenH >> 1) + (count << 4) - 56);
fontmn2->showString(options[count], canvasW >> 2,
(canvasH >> 1) + (count << 4) - 56);
if (count == progress) {
fontmn2->showString("press key", (screenW >> 2) + 112,
(screenH >> 1) + (count << 4) - 56);
fontmn2->showString("press key", (canvasW >> 2) + 112,
(canvasH >> 1) + (count << 4) - 56);
fontmn2->restorePalette();
......@@ -230,18 +230,15 @@ int Menu::setupJoystick () {
for (count = 0; count < 7; count++) {
if (count < progress)
fontmn2->showString("okay", (screenW >> 2) + 176,
(screenH >> 1) + (count << 4) - 56);
fontmn2->showString("okay", (canvasW >> 2) + 176, (canvasH >> 1) + (count << 4) - 56);
else if (count == progress) fontmn2->mapPalette(240, 8, 114, 16);
fontmn2->showString(options[count], screenW >> 2,
(screenH >> 1) + (count << 4) - 56);
fontmn2->showString(options[count], canvasW >> 2, (canvasH >> 1) + (count << 4) - 56);
if (count == progress) {
fontmn2->showString("press control", (screenW >> 2) + 112,
(screenH >> 1) + (count << 4) - 56);
fontmn2->showString("press control", (canvasW >> 2) + 112, (canvasH >> 1) + (count << 4) - 56);
fontmn2->restorePalette();
......@@ -266,28 +263,24 @@ int Menu::setupResolution () {
int dimension, count, maxW, maxH;
#ifdef SCALE
int minS = 1;
int maxS = 4;
#define minD 0
#define maxD 2
#define DIMENSIONS 3
#define minS 1
#define maxS 4
if ( scalar < minS || scalar > maxS )
scalar = 1;
if ( scaleFactor < minS || scaleFactor > maxS )
scaleFactor = 1;
#else
#define minD 0
#define maxD 1
#define DIMENSIONS 2
#endif
dimension = 0;
#ifndef FULLSCREEN_ONLY
if (!fullscreen)
resolutions = SDL_ListModes(NULL,
SDL_RESIZABLE | SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_HWPALETTE);
resolutions = SDL_ListModes(NULL, V_WINDOWED);
else
#endif
resolutions = SDL_ListModes(NULL,
SDL_FULLSCREEN | SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_HWPALETTE);
resolutions = SDL_ListModes(NULL, V_FULLSCREEN);
#if defined(WIZ) || defined(GP2X)
......@@ -327,84 +320,67 @@ int Menu::setupResolution () {
// Show screen corners
drawRect(0, 0, 32, 32, 79);
drawRect(screenW - 32, 0, 32, 32, 79);
drawRect(screenW - 32, screenH - 32, 32, 32, 79);
drawRect(0, screenH - 32, 32, 32, 79);
drawRect(canvasW - 32, 0, 32, 32, 79);
drawRect(canvasW - 32, canvasH - 32, 32, 32, 79);
drawRect(0, canvasH - 32, 32, 32, 79);
// X 1
fontmn2->showString("x", (screenW >> 2) + 40, screenH >> 1);
// X 2
fontmn2->showString("x", (screenW >> 2) + 112, screenH >> 1);
// Width
if (dimension == 0) fontmn2->mapPalette(240, 8, 114, 16);
fontmn2->showNumber(screenW, (canvasW >> 2) + 32, canvasH >> 1);
if (dimension == 0) fontmn2->restorePalette();
fontmn2->showNumber(screenW, (screenW >> 2) + 32, screenH >> 1);
// X
fontmn2->showString("x", (canvasW >> 2) + 40, canvasH >> 1);
// Height
if (dimension == 0 || dimension == 2) fontmn2->restorePalette();
else fontmn2->mapPalette(240, 8, 114, 16);
if (dimension == 1) fontmn2->mapPalette(240, 8, 114, 16);
fontmn2->showNumber(screenH, (canvasW >> 2) + 104, canvasH >> 1);
if (dimension == 1) fontmn2->restorePalette();
fontmn2->showNumber(screenH, (screenW >> 2) + 104, screenH >> 1);
// Scalar
if (dimension == 0 || dimension == 1) fontmn2->restorePalette();
else fontmn2->mapPalette(240, 8, 114, 16);
fontmn2->showNumber(scalar, (screenW >> 2) + 150, screenH >> 1);
#ifdef SCALE
// X 2
fontmn2->showString("x", (canvasW >> 2) + 112, canvasH >> 1);
if (dimension != 0) fontmn2->restorePalette();
// Scale
if (dimension == 2) fontmn2->mapPalette(240, 8, 114, 16);
fontmn2->showNumber(scaleFactor, (canvasW >> 2) + 150, canvasH >> 1);
if (dimension == 2) fontmn2->restorePalette();
#endif
count = 0;
if (controls.release(C_LEFT)) {
dimension--;
if(dimension<minD)
dimension = minD;
}
if (controls.release(C_RIGHT)) {
dimension++;
if (controls.release(C_LEFT))
dimension = (dimension + DIMENSIONS - 1) % DIMENSIONS;
if(dimension>maxD)
dimension = maxD;
}
if (controls.release(C_RIGHT))
dimension = (dimension + 1) % DIMENSIONS;
if (controls.release(C_UP)) {
if ((dimension == 0) && (screenW*scalar < maxW)) {
if ((dimension == 0) && (screenW < maxW)) {
while (screenW >= widthOptions[count] && (screenW*scalar)<maxW) count++;
if ((widthOptions[count]*scalar) > maxW)
count--;
while (screenW >= widthOptions[count]) count++;
screenW = widthOptions[count];
}
if ((dimension == 1) && (screenH*scalar < maxH)) {
if ((dimension == 1) && (screenH < maxH)) {
while (screenH >= heightOptions[count]) count++;
if ((heightOptions[count]*scalar) > maxH)
count--;
screenH = heightOptions[count];
}
#ifdef SCALE
if ((dimension == 2) && (scalar < maxS)) {
if ((dimension == 2) && (scaleFactor < maxS)) {
if ( screenH*(scalar+1) <= maxH && screenW*(scalar+1) <= maxW )
if ( canvasH*(scaleFactor+1) <= maxH && canvasW*(scaleFactor+1) <= maxW )
{
scalar++;
scaleFactor++;
count = 1;
}
......@@ -437,9 +413,9 @@ int Menu::setupResolution () {
}
#ifdef SCALE
if ((dimension == 2) && (scalar > minS)) {
if ((dimension == 2) && (scaleFactor > minS)) {
scalar--;
scaleFactor--;
count = 1;
}
......@@ -453,14 +429,11 @@ int Menu::setupResolution () {
playSound(S_ORB);
#ifndef FULLSCREEN_ONLY
if (!fullscreen)
{
createWindow();
}
if (!fullscreen) createWindow();
else
#endif
createFullscreen();
}
}
......
......@@ -632,9 +632,9 @@ void Player::view (unsigned int ticks, int mspf) {
oldViewY = viewY;
// Can we see below the panel?
viewW = screenW;
if (viewW > panel->w) viewH = screenH;
else viewH = screenH - 33;
viewW = canvasW;
if (viewW > panel->w) viewH = canvasH;
else viewH = canvasH - 33;
// Find new position
......
......@@ -189,7 +189,7 @@ void Scene::ParseAni(File* f, int dataIndex) {
SDL_Rect dst;
dst.x = 0;
dst.y = 0;
SDL_BlitSurface(image, NULL, screen, &dst);
SDL_BlitSurface(image, NULL, canvas, &dst);
SDL_SetPalette(screen, SDL_PHYSPAL, paletteInfos[paletteIndex-1].palette, 0, 256);
currentPalette = paletteInfos[paletteIndex-1].palette;
}break;
......@@ -832,9 +832,9 @@ int Scene::play () {
for(int bg = 0;bg<scriptPages[sceneIndex].backgrounds;bg++) {
imageInfo = FindImage(scriptPages[sceneIndex].bgIndex[bg]);
if(imageInfo != NULL) {
dst.x = (scriptPages[sceneIndex].bgPos[bg] & 65535)*2+(screenW - 320) >> 1;
dst.y = ((scriptPages[sceneIndex].bgPos[bg] & (~65535))>>16)*2+(screenH - 200) >> 1;
SDL_BlitSurface(imageInfo->image, NULL, screen, &dst);
dst.x = (scriptPages[sceneIndex].bgPos[bg] & 65535)*2+(canvasW - 320) >> 1;
dst.y = ((scriptPages[sceneIndex].bgPos[bg] & (~65535))>>16)*2+(canvasH - 200) >> 1;
SDL_BlitSurface(imageInfo->image, NULL, canvas, &dst);
}
}
} else {
......@@ -917,8 +917,8 @@ int Scene::play () {
}
xOffset = ((screenW - 320) >> 1) + textRect.x;
yOffset = ((screenH - 200) >> 1) + textRect.y + y;
xOffset = ((canvasW - 320) >> 1) + textRect.x;
yOffset = ((canvasH - 200) >> 1) + textRect.y + y;
switch (scriptPages[sceneIndex].scriptTexts[text].alignment) {
......
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