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 @@ ...@@ -8,7 +8,7 @@
* Part of the OpenJazz project * Part of the OpenJazz project
* *
* *
* Copyright (c) 2005-2009 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0 * the GNU General Public License, version 2.0
...@@ -74,8 +74,7 @@ ClientGame::ClientGame (char *address) { ...@@ -74,8 +74,7 @@ ClientGame::ClientGame (char *address) {
SDL_Delay(T_FRAME); SDL_Delay(T_FRAME);
clearScreen(0); clearScreen(0);
fontmn2->showString("WAITING FOR REPLY", screenW >> 2, fontmn2->showString("WAITING FOR REPLY", canvasW >> 2, (canvasH >> 1) - 16);
(screenH >> 1) - 16);
ret = net->recv(sock, buffer + count, MTL_G_PROPS - count); ret = net->recv(sock, buffer + count, MTL_G_PROPS - count);
...@@ -207,7 +206,7 @@ ClientGame::ClientGame (char *address) { ...@@ -207,7 +206,7 @@ ClientGame::ClientGame (char *address) {
} }
clearScreen(0); clearScreen(0);
fontmn2->showString("JOINING GAME", screenW >> 2, (screenH >> 1) - 16); fontmn2->showString("JOINING GAME", canvasW >> 2, (canvasH >> 1) - 16);
ret = step(0); ret = step(0);
...@@ -267,8 +266,7 @@ int ClientGame::setLevel (char *fileName) { ...@@ -267,8 +266,7 @@ int ClientGame::setLevel (char *fileName) {
SDL_Delay(T_FRAME); SDL_Delay(T_FRAME);
clearScreen(0); clearScreen(0);
fontmn2->showString("WAITING FOR SERVER", screenW >> 2, fontmn2->showString("WAITING FOR SERVER", canvasW >> 2, (canvasH >> 1) - 16);
(screenH >> 1) - 16);
ret = step(0); ret = step(0);
...@@ -286,9 +284,9 @@ int ClientGame::setLevel (char *fileName) { ...@@ -286,9 +284,9 @@ int ClientGame::setLevel (char *fileName) {
SDL_Delay(T_FRAME); SDL_Delay(T_FRAME);
clearScreen(0); clearScreen(0);
fontmn2->showString("downloaded", screenW >> 2, (screenH >> 1) - 16); fontmn2->showString("downloaded", canvasW >> 2, (canvasH >> 1) - 16);
fontmn2->showNumber(file->tell(), (screenW >> 2) + 56, screenH >> 1); fontmn2->showNumber(file->tell(), (canvasW >> 2) + 56, canvasH >> 1);
fontmn2->showString("bytes", (screenW >> 2) + 64, screenH >> 1); fontmn2->showString("bytes", (canvasW >> 2) + 64, canvasH >> 1);
ret = step(0); ret = step(0);
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* Part of the OpenJazz project * Part of the OpenJazz project
* *
* *
* Copyright (c) 2005-2009 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0 * the GNU General Public License, version 2.0
...@@ -340,10 +340,8 @@ int Font::showString (const char * s, int x, int y) { ...@@ -340,10 +340,8 @@ int Font::showString (const char * s, int x, int y) {
// Determine the character's position on the screen // Determine the character's position on the screen
src.w = w[(int)(map[(int)(s[count])])]; src.w = w[(int)(map[(int)(s[count])])];
if(s[count] == 32) { if(s[count] == 32) src.w >>= 1;
src.w = src.w /2;
}
dst.y = yOffset; dst.y = yOffset;
dst.x = xOffset; dst.x = xOffset;
...@@ -352,8 +350,8 @@ int Font::showString (const char * s, int x, int y) { ...@@ -352,8 +350,8 @@ int Font::showString (const char * s, int x, int y) {
else src.y = 0; else src.y = 0;
// Draw the character to the screen // Draw the character to the screen
SDL_BlitSurface(surface, &src, screen, &dst); SDL_BlitSurface(surface, &src, canvas, &dst);
xOffset += src.w-1; xOffset += src.w-1;
} }
...@@ -379,15 +377,15 @@ void Font::showNumber (int n, int x, int y) { ...@@ -379,15 +377,15 @@ void Font::showNumber (int n, int x, int y) {
if (!n) { if (!n) {
// Determine 0's position on the screen // Determine 0's position on the screen
src.w = w[(int)(map['0'])]; src.w = w[(int)(map[(int)'0'])];
dst.y = y; dst.y = y;
dst.x = x - src.w; dst.x = x - src.w;
// Determine 0's position in the font // Determine 0's position in the font
src.y = map['0'] * h; src.y = map[(int)'0'] * h;
// Draw 0 to the screen // Draw 0 to the screen
SDL_BlitSurface(surface, &src, screen, &dst); SDL_BlitSurface(surface, &src, canvas, &dst);
return; return;
...@@ -412,7 +410,7 @@ void Font::showNumber (int n, int x, int y) { ...@@ -412,7 +410,7 @@ void Font::showNumber (int n, int x, int y) {
src.y = map['0' + (count % 10)] * h; src.y = map['0' + (count % 10)] * h;
// Draw the digit to the screen // Draw the digit to the screen
SDL_BlitSurface(surface, &src, screen, &dst); SDL_BlitSurface(surface, &src, canvas, &dst);
count /= 10; count /= 10;
...@@ -422,15 +420,15 @@ void Font::showNumber (int n, int x, int y) { ...@@ -422,15 +420,15 @@ void Font::showNumber (int n, int x, int y) {
if (n < 0) { if (n < 0) {
// Determine the negative sign's position on the screen // Determine the negative sign's position on the screen
src.w = w[(int)(map['-'])]; src.w = w[(int)(map[(int)'-'])];
dst.y = y; dst.y = y;
dst.x = offset - src.w; dst.x = offset - src.w;
// Determine the negative sign's position on the screen // 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 // 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) { ...@@ -387,8 +387,8 @@ void SkyPaletteEffect::apply (SDL_Color *shownPalette, bool direct, int mspf) {
position = viewY + (viewH << 9) - F4; position = viewY + (viewH << 9) - F4;
if (screenW > 320) y = ((screenH - 1) / 100) + 1; if (canvasW > 320) y = ((canvasH - 1) / 100) + 1;
else y = ((screenH - 34) / 100) + 1; else y = ((canvasH - 34) / 100) + 1;
count = (((position * speed) / y) >> 20) % 255; 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 @@ ...@@ -9,7 +9,7 @@
* Part of the OpenJazz project * Part of the OpenJazz project
* *
* *
* Copyright (c) 2005-2009 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0 * the GNU General Public License, version 2.0
...@@ -127,7 +127,7 @@ void Sprite::draw (int x, int y) { ...@@ -127,7 +127,7 @@ void Sprite::draw (int x, int y) {
dst.x = x + xOffset; dst.x = x + xOffset;
dst.y = y + yOffset; dst.y = y + yOffset;
SDL_BlitSurface(pixels, NULL, screen, &dst); SDL_BlitSurface(pixels, NULL, canvas, &dst);
return; return;
......
...@@ -42,8 +42,8 @@ SDL_Surface * createSurface (unsigned char * pixels, int width, int height) { ...@@ -42,8 +42,8 @@ SDL_Surface * createSurface (unsigned char * pixels, int width, int height) {
// Set the surface's palette // Set the surface's palette
SDL_SetPalette(ret, SDL_LOGPAL, logicalPalette, 0, 256); SDL_SetPalette(ret, SDL_LOGPAL, logicalPalette, 0, 256);
if (pixels != NULL ) if (pixels != NULL) {
{
// Upload pixel data to the surface // Upload pixel data to the surface
if (SDL_MUSTLOCK(ret)) SDL_LockSurface(ret); if (SDL_MUSTLOCK(ret)) SDL_LockSurface(ret);
...@@ -55,6 +55,7 @@ SDL_Surface * createSurface (unsigned char * pixels, int width, int height) { ...@@ -55,6 +55,7 @@ SDL_Surface * createSurface (unsigned char * pixels, int width, int height) {
// Free redundant pixel data // Free redundant pixel data
delete[] pixels; delete[] pixels;
} }
return ret; return ret;
...@@ -63,33 +64,39 @@ SDL_Surface * createSurface (unsigned char * pixels, int width, int height) { ...@@ -63,33 +64,39 @@ SDL_Surface * createSurface (unsigned char * pixels, int width, int height) {
void createFullscreen () { void createFullscreen () {
#ifdef SCALE
if (canvas != screen) SDL_FreeSurface(canvas);
#endif
#if defined(WIZ) || defined(GP2X) #if defined(WIZ) || defined(GP2X)
screen = SDL_SetVideoMode(320, 240, 8, screen = SDL_SetVideoMode(320, 240, 8, V_FULLSCREEN);
SDL_FULLSCREEN | SDL_SWSURFACE | SDL_HWPALETTE);
#else #else
screen = SDL_SetVideoMode(screenW, screenH, 8, V_FULLSCREEN);
#endif
#ifdef SCALE #ifdef SCALE
screen_scaled = SDL_SetVideoMode(screenW*scalar, screenH*scalar, 8, if (scaleFactor > 1) {
SDL_FULLSCREEN | SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_HWPALETTE);
if (screen)
SDL_FreeSurface(screen);
screen = createSurface( NULL, screenW, screenH ); canvasW = screenW / scaleFactor;
canvasH = screenH / scaleFactor;
canvas = createSurface(NULL, canvasW, canvasH);
SDL_SetPalette(screen_scaled, SDL_LOGPAL, logicalPalette, 0, 256); } else {
SDL_SetPalette(screen_scaled, SDL_PHYSPAL, currentPalette, 0, 256);
#else
screen = SDL_SetVideoMode(screenW, screenH, 8,
SDL_FULLSCREEN | SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_HWPALETTE);
SDL_SetPalette(screen, SDL_LOGPAL, logicalPalette, 0, 256);
SDL_SetPalette(screen, SDL_PHYSPAL, currentPalette, 0, 256);
#endif #endif
canvasW = screenW;
canvasH = screenH;
canvas = screen;
#ifdef SCALE
}
#endif #endif
SDL_ShowCursor(SDL_DISABLE);
#if !(defined(WIZ) || defined(GP2X))
SDL_SetPalette(screen, SDL_LOGPAL, logicalPalette, 0, 256);
SDL_SetPalette(screen, SDL_PHYSPAL, currentPalette, 0, 256);
#endif
/* A real 8-bit display is quite likely if the user has the right video /* A real 8-bit display is quite likely if the user has the right video
...@@ -109,26 +116,34 @@ void createFullscreen () { ...@@ -109,26 +116,34 @@ void createFullscreen () {
#ifndef FULLSCREEN_ONLY #ifndef FULLSCREEN_ONLY
void createWindow () { void createWindow () {
#ifdef SCALE
screen_scaled = SDL_SetVideoMode(screenW*scalar, screenH*scalar, 8,
SDL_RESIZABLE | SDL_DOUBLEBUF | SDL_HWSURFACE);
if (screen) #ifdef SCALE
SDL_FreeSurface(screen); if (canvas != screen) SDL_FreeSurface(canvas);
#endif
screen = SDL_SetVideoMode(screenW, screenH, 8, V_WINDOWED);
#ifdef SCALE
if (scaleFactor > 1) {
canvasW = screenW / scaleFactor;
canvasH = screenH / scaleFactor;
canvas = createSurface(NULL, canvasW, canvasH);
} else {
#endif
canvasW = screenW;
canvasH = screenH;
canvas = screen;
#ifdef SCALE
}
#endif
screen = createSurface( NULL, screenW, screenH );
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);
SDL_SetPalette(screen, SDL_LOGPAL, logicalPalette, 0, 256); SDL_SetPalette(screen, SDL_LOGPAL, logicalPalette, 0, 256);
SDL_SetPalette(screen, SDL_PHYSPAL, currentPalette, 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. /* Assume that in windowed mode the palette is being emulated.
This is extremely likely. */ This is extremely likely. */
...@@ -150,9 +165,6 @@ void usePalette (SDL_Color *palette) { ...@@ -150,9 +165,6 @@ void usePalette (SDL_Color *palette) {
#endif #endif
SDL_SetPalette(screen, SDL_PHYSPAL, palette, 0, 256); SDL_SetPalette(screen, SDL_PHYSPAL, palette, 0, 256);
#ifdef SCALE
SDL_SetPalette(screen_scaled, SDL_PHYSPAL, palette, 0, 256);
#endif
currentPalette = palette; currentPalette = palette;
return; return;
...@@ -171,12 +183,13 @@ void restorePalette (SDL_Surface *surface) { ...@@ -171,12 +183,13 @@ void restorePalette (SDL_Surface *surface) {
void clearScreen (int index) { void clearScreen (int index) {
#if defined(WIZ) || defined(GP2X) #if defined(WIZ) || defined(GP2X)
// always 240 lines cleared to black // always 240 lines cleared to black
memset(screen->pixels, index, 320*240); memset(screen->pixels, index, 320*240);
#else #else
SDL_FillRect(screen, NULL, index); SDL_FillRect(canvas, NULL, index);
#endif #endif
return; return;
} }
...@@ -191,7 +204,7 @@ void drawRect (int x, int y, int width, int height, int index) { ...@@ -191,7 +204,7 @@ void drawRect (int x, int y, int width, int height, int index) {
dst.w = width; dst.w = width;
dst.h = height; dst.h = height;
SDL_FillRect(screen, &dst, index); SDL_FillRect(canvas, &dst, index);
return; return;
......
...@@ -31,17 +31,24 @@ ...@@ -31,17 +31,24 @@
// Constants // 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 // Black palette index
#define BLACK 31 #define BLACK 31
// Variables // Variables
EXTERN SDL_Surface *screen; EXTERN SDL_Surface *screen, *canvas;
EXTERN int viewW, viewH, screenW, screenH; EXTERN int viewW, viewH, canvasW, canvasH, screenW, screenH;
EXTERN int scalar;
#ifdef SCALE #ifdef SCALE
EXTERN SDL_Surface *screen_scaled; EXTERN int scaleFactor;
#endif #endif
#ifndef FULLSCREEN_ONLY #ifndef FULLSCREEN_ONLY
EXTERN bool fullscreen; EXTERN bool fullscreen;
...@@ -68,8 +75,7 @@ EXTERN void createWindow (); ...@@ -68,8 +75,7 @@ EXTERN void createWindow ();
EXTERN void usePalette (SDL_Color *palette); EXTERN void usePalette (SDL_Color *palette);
EXTERN void restorePalette (SDL_Surface *surface); EXTERN void restorePalette (SDL_Surface *surface);
EXTERN void clearScreen (int index); EXTERN void clearScreen (int index);
EXTERN void drawRect (int x, int y, int width, int height, EXTERN void drawRect (int x, int y, int width, int height, int index);
int index);
#endif #endif
......
...@@ -126,7 +126,7 @@ int Network::host () { ...@@ -126,7 +126,7 @@ int Network::host () {
return sock; return sock;
#elif defined USE_SDL_NET #elif defined USE_SDL_NET
ipAddress.port = NET_PORT; ipAddress.port = NET_PORT;
ipAddress.host = 0; ipAddress.host = 0;
socket = SDLNet_TCP_Open(&ipAddress); socket = SDLNet_TCP_Open(&ipAddress);
if (socket == NULL) return E_N_SOCKET; if (socket == NULL) return E_N_SOCKET;
...@@ -142,7 +142,7 @@ int Network::join (char *address) { ...@@ -142,7 +142,7 @@ int Network::join (char *address) {
#ifdef USE_SOCKETS #ifdef USE_SOCKETS
sockaddr_in sockAddr; sockaddr_in sockAddr;
fd_set writefds; fd_set writefds;
timeval timeouttv; timeval timeouttv;
unsigned int timeout; unsigned int timeout;
int sock, con; int sock, con;
...@@ -181,7 +181,7 @@ int Network::join (char *address) { ...@@ -181,7 +181,7 @@ int Network::join (char *address) {
con = 0; con = 0;
timeout = globalTicks + T_TIMEOUT; timeout = globalTicks + T_TIMEOUT;
while (!con) { while (!con) {
if (loop(NORMAL_LOOP) == E_QUIT) { if (loop(NORMAL_LOOP) == E_QUIT) {
...@@ -201,8 +201,7 @@ int Network::join (char *address) { ...@@ -201,8 +201,7 @@ int Network::join (char *address) {
} }
clearScreen(0); clearScreen(0);
fontmn2->showString("CONNECTING TO SERVER", screenW >> 2, fontmn2->showString("CONNECTING TO SERVER", canvasW >> 2, (canvasH >> 1) - 16);
(screenH >> 1) - 16);
FD_ZERO(&writefds); FD_ZERO(&writefds);
FD_SET(sock, &writefds); FD_SET(sock, &writefds);
...@@ -233,11 +232,10 @@ int Network::join (char *address) { ...@@ -233,11 +232,10 @@ int Network::join (char *address) {
return sock; return sock;
#elif defined USE_SDL_NET #elif defined USE_SDL_NET
clearScreen(0); clearScreen(0);
fontmn2->showString("CONNECTING TO SERVER", screenW >> 2, fontmn2->showString("CONNECTING TO SERVER", canvasW >> 2, (canvasH >> 1) - 16);
(screenH >> 1) - 16);
loop(NORMAL_LOOP); loop(NORMAL_LOOP);
ipAddress.port = NET_PORT; ipAddress.port = NET_PORT;
ipAddress.host = inet_addr(address); ipAddress.host = inet_addr(address);
socket = SDLNet_TCP_Open(&ipAddress); socket = SDLNet_TCP_Open(&ipAddress);
if (socket == NULL) return -1; if (socket == NULL) return -1;
...@@ -301,7 +299,7 @@ int Network::send (int sock, unsigned char *buffer) { ...@@ -301,7 +299,7 @@ int Network::send (int sock, unsigned char *buffer) {
#ifdef USE_SOCKETS #ifdef USE_SOCKETS
return ::send(sock, (char *)buffer, buffer[0], MSG_NOSIGNAL); return ::send(sock, (char *)buffer, buffer[0], MSG_NOSIGNAL);
#elif defined USE_SDL_NET #elif defined USE_SDL_NET
return SDLNet_TCP_Send((TCPsocket)sock, (char *)buffer, buffer[0]); return SDLNet_TCP_Send((TCPsocket)sock, (char *)buffer, buffer[0]);
#else #else
return 0; return 0;
#endif #endif
......
...@@ -173,7 +173,7 @@ int DemoLevel::play () { ...@@ -173,7 +173,7 @@ int DemoLevel::play () {
draw(); draw();
fontmn1->showString("DEMO", (screenW >> 1) - 36, 32); fontmn1->showString("DEMO", (canvasW >> 1) - 36, 32);
// Draw graphics statistics // Draw graphics statistics
...@@ -182,9 +182,9 @@ int DemoLevel::play () { ...@@ -182,9 +182,9 @@ int DemoLevel::play () {
drawRect(236, 9, 80, 32, BLACK); drawRect(236, 9, 80, 32, BLACK);
panelBigFont->showNumber(screenW, 268, 15); panelBigFont->showNumber(canvasW, 268, 15);
panelBigFont->showString("x", 272, 15); panelBigFont->showString("x", 272, 15);
panelBigFont->showNumber(screenH, 308, 15); panelBigFont->showNumber(canvasH, 308, 15);
panelBigFont->showString("fps", 244, 27); panelBigFont->showString("fps", 244, 27);
panelBigFont->showNumber((int)smoothfps, 308, 27); panelBigFont->showNumber((int)smoothfps, 308, 27);
......
...@@ -524,7 +524,7 @@ void Level::timeCalcs (bool paused) { ...@@ -524,7 +524,7 @@ void Level::timeCalcs (bool paused) {
where c = (1 / fps) where c = (1 / fps)
and fps = 1000 / (ticks - prevTicks) and fps = 1000 / (ticks - prevTicks)
In other words, the response of smoothFPS to changes in FPS decreases as the In other words, the response of smoothFPS to changes in FPS decreases as the
framerate increases framerate increases
The following version is for c = (1 / smoothfps) The following version is for c = (1 / smoothfps)
*/ */
// smoothfps = (fps / smoothfps) + smoothfps - 1; // smoothfps = (fps / smoothfps) + smoothfps - 1;
...@@ -733,7 +733,7 @@ int Level::play () { ...@@ -733,7 +733,7 @@ int Level::play () {
// If paused, draw "PAUSE" // If paused, draw "PAUSE"
if (paused && !pmenu) 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 // If this is a competitive game, draw the score
...@@ -772,9 +772,9 @@ int Level::play () { ...@@ -772,9 +772,9 @@ int Level::play () {
drawRect(viewW - 84, 11, 80, 25, BLACK); 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->showString("x", viewW - 48, 14);
panelBigFont->showNumber(screenH, viewW - 12, 14); panelBigFont->showNumber(canvasH, viewW - 12, 14);
panelBigFont->showString("fps", viewW - 76, 26); panelBigFont->showString("fps", viewW - 76, 26);
panelBigFont->showNumber((int)smoothfps, viewW - 12, 26); panelBigFont->showNumber((int)smoothfps, viewW - 12, 26);
...@@ -826,38 +826,28 @@ int Level::play () { ...@@ -826,38 +826,28 @@ int Level::play () {
// Display statistics & bonuses // Display statistics & bonuses
// TODO: Display percentage symbol // TODO: Display percentage symbol
fontmn1->showString("TIME", (screenW >> 1) - 152, fontmn1->showString("TIME", (canvasW >> 1) - 152, (canvasH >> 1) - 60);
(screenH >> 1) - 60); fontmn1->showNumber(timeBonus, (canvasW >> 1) + 124, (canvasH >> 1) - 60);
fontmn1->showNumber(timeBonus, (screenW >> 1) + 124,
(screenH >> 1) - 60);
fontmn1->showString("ENEMIES", (screenW >> 1) - 152, fontmn1->showString("ENEMIES", (canvasW >> 1) - 152, (canvasH >> 1) - 40);
(screenH >> 1) - 40);
if (enemies) if (enemies)
fontmn1->showNumber((localPlayer->getEnemies() * 100) / enemies, fontmn1->showNumber((localPlayer->getEnemies() * 100) / enemies, (canvasW >> 1) + 124, (canvasH >> 1) - 40);
(screenW >> 1) + 124, (screenH >> 1) - 40);
else else
fontmn1->showNumber(0, (screenW >> 1) + 124, fontmn1->showNumber(0, (canvasW >> 1) + 124, (canvasH >> 1) - 40);
(screenH >> 1) - 40);
fontmn1->showString("ITEMS", (screenW >> 1) - 152, fontmn1->showString("ITEMS", (canvasW >> 1) - 152, (canvasH >> 1) - 20);
(screenH >> 1) - 20);
if (items) if (items)
fontmn1->showNumber((localPlayer->getItems() * 100) / items, fontmn1->showNumber((localPlayer->getItems() * 100) / items, (canvasW >> 1) + 124, (canvasH >> 1) - 20);
(screenW >> 1) + 124, (screenH >> 1) - 20);
else else
fontmn1->showNumber(0, (screenW >> 1) + 124, fontmn1->showNumber(0, (canvasW >> 1) + 124, (canvasH >> 1) - 20);
(screenH >> 1) - 20);
fontmn1->showString("PERFECT", (screenW >> 1) - 152, screenH >> 1); fontmn1->showString("PERFECT", (canvasW >> 1) - 152, canvasH >> 1);
fontmn1->showNumber(perfect, (screenW >> 1) + 124, screenH >> 1); fontmn1->showNumber(perfect, (canvasW >> 1) + 124, canvasH >> 1);
fontmn1->showString("SCORE", (screenW >> 1) - 152, fontmn1->showString("SCORE", (canvasW >> 1) - 152, (canvasH >> 1) + 40);
(screenH >> 1) + 40); fontmn1->showNumber(localPlayer->getScore(), (canvasW >> 1) + 124, (canvasH >> 1) + 40);
fontmn1->showNumber(localPlayer->getScore(), (screenW >> 1) + 124,
(screenH >> 1) + 40);
} }
...@@ -866,15 +856,14 @@ int Level::play () { ...@@ -866,15 +856,14 @@ int Level::play () {
// Draw the menu // 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++) { for (count = 0; count < 5; count++) {
if (count == option) fontmn2->mapPalette(240, 8, 47, -16); if (count == option) fontmn2->mapPalette(240, 8, 47, -16);
else fontmn2->mapPalette(240, 8, 15, -16); else fontmn2->mapPalette(240, 8, 15, -16);
fontmn2->showString(options[count], screenW >> 2, fontmn2->showString(options[count], canvasW >> 2, (canvasH >> 1) + (count << 4) - 38);
(screenH >> 1) + (count << 4) - 38);
} }
......
...@@ -206,20 +206,20 @@ void Level::draw () { ...@@ -206,20 +206,20 @@ void Level::draw () {
vY = FTOI(viewY); vY = FTOI(viewY);
dst.w = viewW; dst.w = viewW;
dst.h = viewH; 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 there is a sky, draw it
if (sky) { if (sky) {
// Background scale // Background scale
if (screenW > 320) bgScale = ((screenH - 1) / 100) + 1; if (canvasW > 320) bgScale = ((canvasH - 1) / 100) + 1;
else bgScale = ((screenH - 34) / 100) + 1; else bgScale = ((canvasH - 34) / 100) + 1;
for (y = 0; y < viewH; y += bgScale) 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. // Show sun / moon / etc.
...@@ -228,7 +228,7 @@ void Level::draw () { ...@@ -228,7 +228,7 @@ void Level::draw () {
dst.x = (viewW * 4) / 5; dst.x = (viewW * 4) / 5;
dst.y = (viewH * 3) / 25; dst.y = (viewH * 3) / 25;
src.y = TTOI(skyOrb); src.y = TTOI(skyOrb);
SDL_BlitSurface(tileSet, &src, screen, &dst); SDL_BlitSurface(tileSet, &src, canvas, &dst);
} }
...@@ -264,7 +264,7 @@ void Level::draw () { ...@@ -264,7 +264,7 @@ void Level::draw () {
dst.x = TTOI(x) - (vX & 31); dst.x = TTOI(x) - (vX & 31);
dst.y = TTOI(y) - (vY & 31); dst.y = TTOI(y) - (vY & 31);
src.y = TTOI(ge->tile); src.y = TTOI(ge->tile);
SDL_BlitSurface(tileSet, &src, screen, &dst); SDL_BlitSurface(tileSet, &src, canvas, &dst);
} }
...@@ -317,7 +317,7 @@ void Level::draw () { ...@@ -317,7 +317,7 @@ void Level::draw () {
dst.y = TTOI(y) - (vY & 31); dst.y = TTOI(y) - (vY & 31);
if (ticks & 64) src.y = TTOI(eventSet[ge->event][E_YAXIS]); if (ticks & 64) src.y = TTOI(eventSet[ge->event][E_YAXIS]);
else src.y = TTOI(eventSet[ge->event][E_MULTIPURPOSE]); 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 () { ...@@ -328,7 +328,7 @@ void Level::draw () {
dst.x = TTOI(x) - (vX & 31); dst.x = TTOI(x) - (vX & 31);
dst.y = TTOI(y) - (vY & 31); dst.y = TTOI(y) - (vY & 31);
src.y = TTOI(ge->tile); src.y = TTOI(ge->tile);
SDL_BlitSurface(tileSet, &src, screen, &dst); SDL_BlitSurface(tileSet, &src, canvas, &dst);
} }
...@@ -337,13 +337,13 @@ void Level::draw () { ...@@ -337,13 +337,13 @@ void Level::draw () {
} }
// Temporary lines showing the water level // Temporary lines showing the water level
drawRect(0, FTOI(waterLevel - viewY), screenW, 2, 24); drawRect(0, FTOI(waterLevel - viewY), canvasW, 2, 24);
drawRect(0, FTOI(waterLevel - viewY) + 3, screenW, 1, 24); drawRect(0, FTOI(waterLevel - viewY) + 3, canvasW, 1, 24);
drawRect(0, FTOI(waterLevel - viewY) + 6, screenW, 1, 24); drawRect(0, FTOI(waterLevel - viewY) + 6, canvasW, 1, 24);
drawRect(0, FTOI(waterLevel - viewY) + 10, screenW, 1, 24); drawRect(0, FTOI(waterLevel - viewY) + 10, canvasW, 1, 24);
SDL_SetClipRect(screen, NULL); SDL_SetClipRect(canvas, NULL);
// Show panel // Show panel
...@@ -355,48 +355,48 @@ void Level::draw () { ...@@ -355,48 +355,48 @@ void Level::draw () {
&dst); &dst);
dst.x = 0; dst.x = 0;
dst.y = screenH - 33; dst.y = canvasH - 33;
SDL_BlitSurface(panel, NULL, screen, &dst); SDL_BlitSurface(panel, NULL, canvas, &dst);
drawRect(0, screenH - 1, 320, 1, BLACK); drawRect(0, canvasH - 1, 320, 1, BLACK);
// Show panel data // Show panel data
// Show score // Show score
panelSmallFont->showNumber(localPlayer->getScore(), 84, screenH - 27); panelSmallFont->showNumber(localPlayer->getScore(), 84, canvasH - 27);
// Show time remaining // Show time remaining
if (endTime > ticks) x = endTime - ticks; if (endTime > ticks) x = endTime - ticks;
else x = 0; else x = 0;
y = x / (60 * 1000); y = x / (60 * 1000);
panelSmallFont->showNumber(y, 116, screenH - 27); panelSmallFont->showNumber(y, 116, canvasH - 27);
x -= (y * 60 * 1000); x -= (y * 60 * 1000);
y = x / 1000; y = x / 1000;
panelSmallFont->showNumber(y, 136, screenH - 27); panelSmallFont->showNumber(y, 136, canvasH - 27);
x -= (y * 1000); x -= (y * 1000);
y = x / 100; y = x / 100;
panelSmallFont->showNumber(y, 148, screenH - 27); panelSmallFont->showNumber(y, 148, canvasH - 27);
// Show lives // Show lives
panelSmallFont->showNumber(localPlayer->getLives(), 124, screenH - 13); panelSmallFont->showNumber(localPlayer->getLives(), 124, canvasH - 13);
// Show planet number // Show planet number
if (worldNum <= 41) // Main game levels 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 else if ((worldNum >= 50) && (worldNum <= 52)) // Christmas levels
panelSmallFont->showNumber(worldNum - 49, 184, screenH - 13); panelSmallFont->showNumber(worldNum - 49, 184, canvasH - 13);
else panelSmallFont->showNumber(worldNum, 184, screenH - 13); else panelSmallFont->showNumber(worldNum, 184, canvasH - 13);
// Show level number // Show level number
panelSmallFont->showNumber(levelNum + 1, 196, screenH - 13); panelSmallFont->showNumber(levelNum + 1, 196, canvasH - 13);
// Show ammo // Show ammo
if (localPlayer->getAmmo(false) == -1) if (localPlayer->getAmmo(false) == -1)
panelSmallFont->showString(":;", 225, screenH - 13); panelSmallFont->showString(":;", 225, canvasH - 13);
else panelSmallFont->showNumber(localPlayer->getAmmo(true), 245, else panelSmallFont->showNumber(localPlayer->getAmmo(true), 245,
screenH - 13); canvasH - 13);
// Draw the health bar // Draw the health bar
...@@ -428,7 +428,7 @@ void Level::draw () { ...@@ -428,7 +428,7 @@ void Level::draw () {
else if (x <= 1) x = 32 + (((ticks / 75) * 4) & 15); else if (x <= 1) x = 32 + (((ticks / 75) * 4) & 15);
// Draw energy bar // 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.x += dst.w;
dst.w = 64 - dst.w; dst.w = 64 - dst.w;
...@@ -437,7 +437,7 @@ void Level::draw () { ...@@ -437,7 +437,7 @@ void Level::draw () {
// Fill in remaining energy bar space with black // 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; return;
......
...@@ -490,10 +490,10 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) { ...@@ -490,10 +490,10 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) {
clearScreen(0); clearScreen(0);
x = (screenW >> 1) - ((strlen(string) + strlen(ext)) << 2); x = (canvasW >> 1) - ((strlen(string) + strlen(ext)) << 2);
x = fontmn2->showString("LOADING ", x - 60, (screenH >> 1) - 16); x = fontmn2->showString("LOADING ", x - 60, (canvasH >> 1) - 16);
x = fontmn2->showString(string, x, (screenH >> 1) - 16); x = fontmn2->showString(string, x, (canvasH >> 1) - 16);
fontmn2->showString(ext, x, (screenH >> 1) - 16); fontmn2->showString(ext, x, (canvasH >> 1) - 16);
delete[] string; delete[] string;
......
...@@ -58,7 +58,7 @@ extern char KOpenJazzPath[256]; ...@@ -58,7 +58,7 @@ extern char KOpenJazzPath[256];
#endif #endif
#ifdef SCALE #ifdef SCALE
#include "scale2x/scalebit.h" #include "io/gfx/scale2x/scalebit.h"
#endif #endif
int loadMain (int argc, char *argv[]) { int loadMain (int argc, char *argv[]) {
...@@ -66,6 +66,9 @@ int loadMain (int argc, char *argv[]) { ...@@ -66,6 +66,9 @@ int loadMain (int argc, char *argv[]) {
File *file; File *file;
unsigned char *pixels, *sorted; unsigned char *pixels, *sorted;
int count, x, y; int count, x, y;
#ifndef SCALE
int scaleFactor;
#endif
// Determine paths // Determine paths
...@@ -195,18 +198,14 @@ int loadMain (int argc, char *argv[]) { ...@@ -195,18 +198,14 @@ int loadMain (int argc, char *argv[]) {
// Read video settings // Read video settings
screenW = file->loadShort(); screenW = file->loadShort();
screenH = file->loadShort(); screenH = file->loadShort();
#ifdef SCALE
scalar = file->loadChar();
#else
scalar = 1;
file->loadChar();
#endif
#ifdef FULLSCREEN_ONLY scaleFactor = file->loadChar();
file->loadChar(); #ifndef FULLSCREEN_ONLY
#else fullscreen = scaleFactor & 1;
fullscreen = file->loadChar();
#endif #endif
scaleFactor >>= 1;
if (scaleFactor > 4) scaleFactor = 1;
// Read controls // Read controls
for (count = 0; count < CONTROLS - 4; count++) for (count = 0; count < CONTROLS - 4; count++)
...@@ -255,22 +254,31 @@ int loadMain (int argc, char *argv[]) { ...@@ -255,22 +254,31 @@ int loadMain (int argc, char *argv[]) {
#endif #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 // Create the game's window
currentPalette = logicalPalette; currentPalette = logicalPalette;
canvas = screen = NULL;
#ifdef FULLSCREEN_ONLY #ifndef FULLSCREEN_ONLY
createFullscreen(); if (!fullscreen) createWindow();
#else else {
if (fullscreen) createFullscreen();
else createWindow();
#endif #endif
#ifdef SCALE SDL_ShowCursor(SDL_DISABLE);
if (!screen_scaled) { createFullscreen();
#else
if (!screen) { #ifndef FULLSCREEN_ONLY
}
#endif #endif
if (!screen) {
logError("Could not set video mode", SDL_GetError()); logError("Could not set video mode", SDL_GetError());
delete characterName; delete characterName;
...@@ -287,15 +295,7 @@ int loadMain (int argc, char *argv[]) { ...@@ -287,15 +295,7 @@ int loadMain (int argc, char *argv[]) {
if (SDL_NumJoysticks() > 0) SDL_JoystickOpen(0); 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); restorePalette(screen);
#ifdef SCALE
restorePalette(screen_scaled);
#endif
firstPE = NULL; firstPE = NULL;
...@@ -464,6 +464,9 @@ void freeMain () { ...@@ -464,6 +464,9 @@ void freeMain () {
File *file; File *file;
int count; int count;
#ifndef SCALE
int scaleFactor = 1;
#endif
delete net; delete net;
...@@ -483,7 +486,7 @@ void freeMain () { ...@@ -483,7 +486,7 @@ void freeMain () {
SDL_FreeSurface(panelAmmo[4]); SDL_FreeSurface(panelAmmo[4]);
#ifdef SCALE #ifdef SCALE
SDL_FreeSurface(screen); if (canvas != screen) SDL_FreeSurface(canvas);
#endif #endif
closeAudio(); closeAudio();
...@@ -509,17 +512,12 @@ void freeMain () { ...@@ -509,17 +512,12 @@ void freeMain () {
// Write video settings // Write video settings
file->storeShort(screenW); file->storeShort(screenW);
file->storeShort(screenH); file->storeShort(screenH);
#ifdef SCALE scaleFactor <<= 1;
file->storeChar(scalar); #ifndef FULLSCREEN_ONLY
#else scaleFactor |= fullscreen? 1: 0;
file->storeChar(1);
#endif
#ifdef FULLSCREEN_ONLY
file->storeChar(1);
#else
file->storeChar(fullscreen? ~0: 0);
#endif #endif
file->storeChar(scaleFactor);
// Write controls // Write controls
for (count = 0; count < CONTROLS - 4; count++) for (count = 0; count < CONTROLS - 4; count++)
...@@ -572,25 +570,18 @@ int loop (int type) { ...@@ -572,25 +570,18 @@ int loop (int type) {
// Show everything that has been drawn so far // Show everything that has been drawn so far
#ifdef SCALE #ifdef SCALE
if (scalar>1) { if (canvas != screen) {
int depth = screen_scaled->format->BytesPerPixel;
scale(scaleFactor,
scale(scalar, screen_scaled->pixels, screen->w*depth*scalar, screen->pixels, screen->w*depth, screen->pixels, screen->pitch,
depth, screen->w, screen->h ); 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);
} }
SDL_Flip(screen_scaled);
#else
SDL_Flip(screen);
#endif #endif
SDL_Flip(screen);
prevTicks = globalTicks; prevTicks = globalTicks;
globalTicks = SDL_GetTicks(); globalTicks = SDL_GetTicks();
...@@ -609,8 +600,17 @@ int loop (int type) { ...@@ -609,8 +600,17 @@ int loop (int type) {
fullscreen = !fullscreen; fullscreen = !fullscreen;
if (fullscreen) createFullscreen(); if (fullscreen) {
else createWindow();
SDL_ShowCursor(SDL_DISABLE);
createFullscreen();
} else {
createWindow();
SDL_ShowCursor(SDL_ENABLE);
}
} }
#endif #endif
...@@ -649,31 +649,15 @@ int loop (int type) { ...@@ -649,31 +649,15 @@ int loop (int type) {
screenW = event.resize.w; screenW = event.resize.w;
screenH = event.resize.h; 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);
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 createWindow();
break;
case SDL_VIDEOEXPOSE: case SDL_VIDEOEXPOSE:
SDL_SetPalette(screen, SDL_LOGPAL, logicalPalette, 0, 256); SDL_SetPalette(screen, SDL_LOGPAL, logicalPalette, 0, 256);
SDL_SetPalette(screen, SDL_PHYSPAL, currentPalette, 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; break;
#endif #endif
...@@ -705,10 +689,6 @@ int loop (int type) { ...@@ -705,10 +689,6 @@ int loop (int type) {
firstPE->apply(shownPalette, false, globalTicks - prevTicks); firstPE->apply(shownPalette, false, globalTicks - prevTicks);
SDL_SetPalette(screen, SDL_PHYSPAL, shownPalette, 0, 256); SDL_SetPalette(screen, SDL_PHYSPAL, shownPalette, 0, 256);
#ifdef SCALE
SDL_SetPalette(screen_scaled, SDL_PHYSPAL, shownPalette, 0, 256);
#endif
} else { } else {
...@@ -732,7 +712,7 @@ int main(int argc, char *argv[]) { ...@@ -732,7 +712,7 @@ int main(int argc, char *argv[]) {
Scene *scene = NULL; Scene *scene = NULL;
int scene_result = E_NONE; int scene_result = E_NONE;
// Initialise SDL // Initialise SDL
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK | if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK |
...@@ -771,11 +751,11 @@ int main(int argc, char *argv[]) { ...@@ -771,11 +751,11 @@ int main(int argc, char *argv[]) {
} }
scene_result = scene->play(); scene_result = scene->play();
delete scene; delete scene;
scene = NULL;*/ scene = NULL;*/
if (scene_result != E_QUIT) { if (scene_result != E_QUIT) {
// Load the menu // Load the menu
try { try {
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* Part of the OpenJazz project * Part of the OpenJazz project
* *
* *
* Copyright (c) 2005-2009 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0 * the GNU General Public License, version 2.0
...@@ -59,8 +59,8 @@ int Menu::newGameDifficulty (int mode, int levelNum, int worldNum) { ...@@ -59,8 +59,8 @@ int Menu::newGameDifficulty (int mode, int levelNum, int worldNum) {
if (count == difficulty) fontmn2->mapPalette(240, 8, 114, 16); if (count == difficulty) fontmn2->mapPalette(240, 8, 114, 16);
fontmn2->showString(options[count], screenW >> 2, fontmn2->showString(options[count], canvasW >> 2,
(screenH >> 1) + (count << 4) - 32); (canvasH >> 1) + (count << 4) - 32);
if (count == difficulty) fontmn2->restorePalette(); if (count == difficulty) fontmn2->restorePalette();
...@@ -70,9 +70,9 @@ int Menu::newGameDifficulty (int mode, int levelNum, int worldNum) { ...@@ -70,9 +70,9 @@ int Menu::newGameDifficulty (int mode, int levelNum, int worldNum) {
src.y = (difficulty & 2) * 50; src.y = (difficulty & 2) * 50;
src.w = 160; src.w = 160;
src.h = 100; src.h = 100;
dst.x = (screenW >> 1) - 40; dst.x = (canvasW >> 1) - 40;
dst.y = (screenH >> 1) - 50; dst.y = (canvasH >> 1) - 50;
SDL_BlitSurface(screens[2], &src, screen, &dst); SDL_BlitSurface(screens[2], &src, canvas, &dst);
if (controls.release(C_UP)) difficulty = (difficulty + 3) % 4; if (controls.release(C_UP)) difficulty = (difficulty + 3) % 4;
...@@ -171,14 +171,14 @@ int Menu::newGameLevel (int mode) { ...@@ -171,14 +171,14 @@ int Menu::newGameLevel (int mode) {
clearScreen(15); clearScreen(15);
if (option == 0) fontmn2->mapPalette(240, 8, 114, 16); if (option == 0) fontmn2->mapPalette(240, 8, 114, 16);
fontmn2->showString("choose world:", 32, screenH / 3); fontmn2->showString("choose world:", 32, canvasH / 3);
fontmn2->showNumber(worldNum, 208, screenH / 3); fontmn2->showNumber(worldNum, 208, canvasH / 3);
if (option == 0) fontmn2->restorePalette(); if (option == 0) fontmn2->restorePalette();
else fontmn2->mapPalette(240, 8, 114, 16); else fontmn2->mapPalette(240, 8, 114, 16);
fontmn2->showString("choose level:", 32, (screenH << 1) / 3); fontmn2->showString("choose level:", 32, (canvasH << 1) / 3);
fontmn2->showNumber(levelNum, 208, (screenH << 1) / 3); fontmn2->showNumber(levelNum, 208, (canvasH << 1) / 3);
if (option != 0) fontmn2->restorePalette(); if (option != 0) fontmn2->restorePalette();
...@@ -263,15 +263,15 @@ int Menu::newGameEpisode (int mode) { ...@@ -263,15 +263,15 @@ int Menu::newGameEpisode (int mode) {
if ((episode < episodes - 1) || (episode < 6)) { if ((episode < episodes - 1) || (episode < 6)) {
dst.x = screenW - 150; dst.x = canvasW - 150;
dst.y = (screenH - 110) >> 1; dst.y = (canvasH - 110) >> 1;
SDL_BlitSurface(screens[episode + 3], NULL, screen, &dst); SDL_BlitSurface(screens[episode + 3], NULL, canvas, &dst);
} else if ((episode == 10) && (episodes > 6)) { } else if ((episode == 10) && (episodes > 6)) {
dst.x = screenW - 160; dst.x = canvasW - 160;
dst.y = (screenH - 110) >> 1; dst.y = (canvasH - 110) >> 1;
SDL_BlitSurface(screens[episodes + 2], NULL, screen, &dst); SDL_BlitSurface(screens[episodes + 2], NULL, canvas, &dst);
} }
...@@ -280,14 +280,14 @@ int Menu::newGameEpisode (int mode) { ...@@ -280,14 +280,14 @@ int Menu::newGameEpisode (int mode) {
if (count == episode) { if (count == episode) {
fontmn2->mapPalette(240, 8, 79, -80); 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); 136, 15, 79);
} else if (!exists[count]) } else if (!exists[count])
fontmn2->mapPalette(240, 8, 94, -16); fontmn2->mapPalette(240, 8, 94, -16);
fontmn2->showString(options[count], screenW >> 3, fontmn2->showString(options[count], canvasW >> 3,
(screenH >> 1) + (count << 4) - 92); (canvasH >> 1) + (count << 4) - 92);
if ((count == episode) || (!exists[count])) if ((count == episode) || (!exists[count]))
fontmn2->mapPalette(240, 8, 9, 80); fontmn2->mapPalette(240, 8, 9, 80);
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* Part of the OpenJazz project * Part of the OpenJazz project
* *
* *
* Copyright (c) 2005-2009 Alister Thomson * Copyright (c) 2005-2010 Alister Thomson
* *
* OpenJazz is distributed under the terms of * OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0 * the GNU General Public License, version 2.0
...@@ -233,13 +233,13 @@ int Menu::main () { ...@@ -233,13 +233,13 @@ int Menu::main () {
clearScreen(28); clearScreen(28);
dst.x = (screenW >> 2) - 72; dst.x = (canvasW >> 2) - 72;
dst.y = screenH - (screenH >> 2); dst.y = canvasH - (canvasH >> 2);
SDL_BlitSurface(screens[14], NULL, screen, &dst); SDL_BlitSurface(screens[14], NULL, canvas, &dst);
dst.x = (screenW - 320) >> 1; dst.x = (canvasW - 320) >> 1;
dst.y = (screenH - 200) >> 1; dst.y = (canvasH - 200) >> 1;
SDL_BlitSurface(screens[0], NULL, screen, &dst); SDL_BlitSurface(screens[0], NULL, canvas, &dst);
switch (option) { switch (option) {
...@@ -299,9 +299,9 @@ int Menu::main () { ...@@ -299,9 +299,9 @@ int Menu::main () {
} }
dst.x = ((screenW - 320) >> 1) + src.x; dst.x = ((canvasW - 320) >> 1) + src.x;
dst.y = ((screenH - 200) >> 1) + src.y; dst.y = ((canvasH - 200) >> 1) + src.y;
SDL_BlitSurface(screens[1], &src, screen, &dst); SDL_BlitSurface(screens[1], &src, canvas, &dst);
} }
......
...@@ -53,7 +53,7 @@ int Menu::message (const char *text) { ...@@ -53,7 +53,7 @@ int Menu::message (const char *text) {
clearScreen(15); clearScreen(15);
// Draw the message // 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) { ...@@ -86,8 +86,8 @@ int Menu::generic (const char **optionNames, int options, int *chosen) {
if (count == *chosen) fontmn2->mapPalette(240, 8, 114, 16); if (count == *chosen) fontmn2->mapPalette(240, 8, 114, 16);
fontmn2->showString(optionNames[count], screenW >> 2, fontmn2->showString(optionNames[count], canvasW >> 2,
(screenH >> 1) + (count << 4) - (options << 3)); (canvasH >> 1) + (count << 4) - (options << 3));
if (count == *chosen) fontmn2->restorePalette(); if (count == *chosen) fontmn2->restorePalette();
...@@ -192,20 +192,20 @@ int Menu::textInput (const char *request, char **text) { ...@@ -192,20 +192,20 @@ int Menu::textInput (const char *request, char **text) {
clearScreen(15); clearScreen(15);
// Draw the prompt // 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 // Draw the section of the text before the cursor
fontmn2->mapPalette(240, 8, 114, 16); fontmn2->mapPalette(240, 8, 114, 16);
terminate = input[cursor]; terminate = input[cursor];
input[cursor] = 0; input[cursor] = 0;
x = fontmn2->showString(input, (screenW >> 2) + 8, screenH >> 1); x = fontmn2->showString(input, (canvasW >> 2) + 8, canvasH >> 1);
// Draw the cursor // 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 // Draw the section of text after the cursor
input[cursor] = terminate; input[cursor] = terminate;
fontmn2->showString(input + cursor, x, screenH >> 1); fontmn2->showString(input + cursor, x, canvasH >> 1);
fontmn2->restorePalette(); fontmn2->restorePalette();
......
...@@ -88,18 +88,18 @@ int Menu::setupKeyboard () { ...@@ -88,18 +88,18 @@ int Menu::setupKeyboard () {
for (count = 0; count < PCONTROLS; count++) { for (count = 0; count < PCONTROLS; count++) {
if (count < progress) if (count < progress)
fontmn2->showString("okay", (screenW >> 2) + 176, fontmn2->showString("okay", (canvasW >> 2) + 176,
(screenH >> 1) + (count << 4) - 56); (canvasH >> 1) + (count << 4) - 56);
else if (count == progress) fontmn2->mapPalette(240, 8, 114, 16); else if (count == progress) fontmn2->mapPalette(240, 8, 114, 16);
fontmn2->showString(options[count], screenW >> 2, fontmn2->showString(options[count], canvasW >> 2,
(screenH >> 1) + (count << 4) - 56); (canvasH >> 1) + (count << 4) - 56);
if (count == progress) { if (count == progress) {
fontmn2->showString("press key", (screenW >> 2) + 112, fontmn2->showString("press key", (canvasW >> 2) + 112,
(screenH >> 1) + (count << 4) - 56); (canvasH >> 1) + (count << 4) - 56);
fontmn2->restorePalette(); fontmn2->restorePalette();
...@@ -230,18 +230,15 @@ int Menu::setupJoystick () { ...@@ -230,18 +230,15 @@ int Menu::setupJoystick () {
for (count = 0; count < 7; count++) { for (count = 0; count < 7; count++) {
if (count < progress) if (count < progress)
fontmn2->showString("okay", (screenW >> 2) + 176, fontmn2->showString("okay", (canvasW >> 2) + 176, (canvasH >> 1) + (count << 4) - 56);
(screenH >> 1) + (count << 4) - 56);
else if (count == progress) fontmn2->mapPalette(240, 8, 114, 16); else if (count == progress) fontmn2->mapPalette(240, 8, 114, 16);
fontmn2->showString(options[count], screenW >> 2, fontmn2->showString(options[count], canvasW >> 2, (canvasH >> 1) + (count << 4) - 56);
(screenH >> 1) + (count << 4) - 56);
if (count == progress) { if (count == progress) {
fontmn2->showString("press control", (screenW >> 2) + 112, fontmn2->showString("press control", (canvasW >> 2) + 112, (canvasH >> 1) + (count << 4) - 56);
(screenH >> 1) + (count << 4) - 56);
fontmn2->restorePalette(); fontmn2->restorePalette();
...@@ -266,28 +263,24 @@ int Menu::setupResolution () { ...@@ -266,28 +263,24 @@ int Menu::setupResolution () {
int dimension, count, maxW, maxH; int dimension, count, maxW, maxH;
#ifdef SCALE #ifdef SCALE
int minS = 1; #define DIMENSIONS 3
int maxS = 4; #define minS 1
#define minD 0 #define maxS 4
#define maxD 2
if ( scaleFactor < minS || scaleFactor > maxS )
if ( scalar < minS || scalar > maxS ) scaleFactor = 1;
scalar = 1;
#else #else
#define minD 0 #define DIMENSIONS 2
#define maxD 1
#endif #endif
dimension = 0; dimension = 0;
#ifndef FULLSCREEN_ONLY #ifndef FULLSCREEN_ONLY
if (!fullscreen) if (!fullscreen)
resolutions = SDL_ListModes(NULL, resolutions = SDL_ListModes(NULL, V_WINDOWED);
SDL_RESIZABLE | SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_HWPALETTE); else
else #endif
#endif resolutions = SDL_ListModes(NULL, V_FULLSCREEN);
resolutions = SDL_ListModes(NULL,
SDL_FULLSCREEN | SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_HWPALETTE);
#if defined(WIZ) || defined(GP2X) #if defined(WIZ) || defined(GP2X)
...@@ -327,84 +320,67 @@ int Menu::setupResolution () { ...@@ -327,84 +320,67 @@ int Menu::setupResolution () {
// Show screen corners // Show screen corners
drawRect(0, 0, 32, 32, 79); drawRect(0, 0, 32, 32, 79);
drawRect(screenW - 32, 0, 32, 32, 79); drawRect(canvasW - 32, 0, 32, 32, 79);
drawRect(screenW - 32, screenH - 32, 32, 32, 79); drawRect(canvasW - 32, canvasH - 32, 32, 32, 79);
drawRect(0, screenH - 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 // Width
if (dimension == 0) fontmn2->mapPalette(240, 8, 114, 16); if (dimension == 0) fontmn2->mapPalette(240, 8, 114, 16);
fontmn2->showNumber(screenW, (canvasW >> 2) + 32, canvasH >> 1);
fontmn2->showNumber(screenW, (screenW >> 2) + 32, screenH >> 1); if (dimension == 0) fontmn2->restorePalette();
// Height // X
if (dimension == 0 || dimension == 2) fontmn2->restorePalette(); fontmn2->showString("x", (canvasW >> 2) + 40, canvasH >> 1);
else fontmn2->mapPalette(240, 8, 114, 16);
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);
if (dimension != 0) fontmn2->restorePalette(); // Height
if (dimension == 1) fontmn2->mapPalette(240, 8, 114, 16);
fontmn2->showNumber(screenH, (canvasW >> 2) + 104, canvasH >> 1);
if (dimension == 1) fontmn2->restorePalette();
#ifdef SCALE
// X 2
fontmn2->showString("x", (canvasW >> 2) + 112, canvasH >> 1);
count = 0; // Scale
if (dimension == 2) fontmn2->mapPalette(240, 8, 114, 16);
fontmn2->showNumber(scaleFactor, (canvasW >> 2) + 150, canvasH >> 1);
if (dimension == 2) fontmn2->restorePalette();
#endif
if (controls.release(C_LEFT)) {
dimension--;
if(dimension<minD) count = 0;
dimension = minD;
}
if (controls.release(C_RIGHT)) { if (controls.release(C_LEFT))
dimension = (dimension + DIMENSIONS - 1) % DIMENSIONS;
dimension++;
if(dimension>maxD) if (controls.release(C_RIGHT))
dimension = maxD; dimension = (dimension + 1) % DIMENSIONS;
}
if (controls.release(C_UP)) { 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) while (screenW >= widthOptions[count]) count++;
count--;
screenW = widthOptions[count]; screenW = widthOptions[count];
} }
if ((dimension == 1) && (screenH*scalar < maxH)) { if ((dimension == 1) && (screenH < maxH)) {
while (screenH >= heightOptions[count]) count++; while (screenH >= heightOptions[count]) count++;
if ((heightOptions[count]*scalar) > maxH)
count--;
screenH = heightOptions[count]; screenH = heightOptions[count];
} }
#ifdef SCALE #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; count = 1;
} }
...@@ -437,9 +413,9 @@ int Menu::setupResolution () { ...@@ -437,9 +413,9 @@ int Menu::setupResolution () {
} }
#ifdef SCALE #ifdef SCALE
if ((dimension == 2) && (scalar > minS)) { if ((dimension == 2) && (scaleFactor > minS)) {
scalar--; scaleFactor--;
count = 1; count = 1;
} }
...@@ -453,14 +429,11 @@ int Menu::setupResolution () { ...@@ -453,14 +429,11 @@ int Menu::setupResolution () {
playSound(S_ORB); playSound(S_ORB);
#ifndef FULLSCREEN_ONLY #ifndef FULLSCREEN_ONLY
if (!fullscreen) if (!fullscreen) createWindow();
{
createWindow();
}
else else
#endif #endif
createFullscreen(); createFullscreen();
} }
} }
......
...@@ -632,9 +632,9 @@ void Player::view (unsigned int ticks, int mspf) { ...@@ -632,9 +632,9 @@ void Player::view (unsigned int ticks, int mspf) {
oldViewY = viewY; oldViewY = viewY;
// Can we see below the panel? // Can we see below the panel?
viewW = screenW; viewW = canvasW;
if (viewW > panel->w) viewH = screenH; if (viewW > panel->w) viewH = canvasH;
else viewH = screenH - 33; else viewH = canvasH - 33;
// Find new position // Find new position
......
This diff is collapsed.
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