aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/PalmOS
diff options
context:
space:
mode:
authorChris Apers2007-01-20 18:20:36 +0000
committerChris Apers2007-01-20 18:20:36 +0000
commit0e36e6b50097ffe89cae449e7098d0dbf4ce18d2 (patch)
tree7134065f2e2c0ddea6adb25c43e0635d006b5a41 /backends/platform/PalmOS
parentecf5b465bb3a742fdfad6941bfb0814408f1b2db (diff)
downloadscummvm-rg350-0e36e6b50097ffe89cae449e7098d0dbf4ce18d2.tar.gz
scummvm-rg350-0e36e6b50097ffe89cae449e7098d0dbf4ce18d2.tar.bz2
scummvm-rg350-0e36e6b50097ffe89cae449e7098d0dbf4ce18d2.zip
Added support fir hi-res games to standard PalmOS 5 devices (BS, TOuche, ...)
Added aspect ratio selection too svn-id: r25131
Diffstat (limited to 'backends/platform/PalmOS')
-rw-r--r--backends/platform/PalmOS/Src/be_os5.cpp56
-rw-r--r--backends/platform/PalmOS/Src/be_os5.h20
-rw-r--r--backends/platform/PalmOS/Src/be_zodiac.h10
-rw-r--r--backends/platform/PalmOS/Src/os5_event.cpp33
-rw-r--r--backends/platform/PalmOS/Src/os5_gfx.cpp130
-rw-r--r--backends/platform/PalmOS/Src/os5_renderer.cpp99
6 files changed, 163 insertions, 185 deletions
diff --git a/backends/platform/PalmOS/Src/be_os5.cpp b/backends/platform/PalmOS/Src/be_os5.cpp
index 975f394b64..cddea55568 100644
--- a/backends/platform/PalmOS/Src/be_os5.cpp
+++ b/backends/platform/PalmOS/Src/be_os5.cpp
@@ -43,6 +43,40 @@ OSystem_PalmOS5::OSystem_PalmOS5() : OSystem_PalmBase() {
_soundEx.sound = &_sound;
}
+void OSystem_PalmOS5::calc_scale() {
+ for (int y = 0; y < _screenDest.h; y++) {
+ int ys = y * _screenHeight / _screenDest.h;
+ _scaleTableY[y] = ys * _screenWidth;
+ }
+
+ for (int x = 0; x < _screenDest.w; x++) {
+ int xs = x * _screenWidth / _screenDest.w;
+ _scaleTableX[x] = xs;
+ }
+}
+
+void OSystem_PalmOS5::calc_rect(Boolean fullscreen) {
+ Int32 w, h;
+
+ if (fullscreen) {
+ w = (_ratio.adjustAspect == kRatioWidth) ? _ratio.width : gVars->screenFullWidth;
+ h = (_ratio.adjustAspect == kRatioHeight) ? _ratio.height : gVars->screenFullHeight;
+
+ _screenOffset.x = (_ratio.adjustAspect == kRatioWidth) ? (gVars->screenFullWidth - _ratio.width) / 2 : 0;
+ _screenOffset.y = (_ratio.adjustAspect == kRatioHeight) ? (gVars->screenFullHeight - _ratio.height) / 2 : 0;
+
+ } else {
+ w = gVars->screenWidth;
+ h = gVars->screenHeight - MIN_OFFSET * 2;
+
+ _screenOffset.x = 0;
+ _screenOffset.y = MIN_OFFSET;
+ }
+
+ _screenDest.w = w;
+ _screenDest.h = h;
+}
+
void OSystem_PalmOS5::int_initBackend() {
if (OPTIONS_TST(kOpt5WayNavigatorV1)) {
_keyMouse.bitUp = keyBitPageUp;
@@ -71,6 +105,28 @@ bool OSystem_PalmOS5::hasFeature(Feature f) {
return false;
}
+void OSystem_PalmOS5::setFeatureState(Feature f, bool enable) {
+ switch (f) {
+/* case kFeatureFullscreenMode:
+ if (_gfxLoaded)
+ if (OPTIONS_TST(kOptModeWide) && _initMode != GFX_WIDE) {
+ _fullscreen = enable;
+ hotswap_gfx_mode(_mode);
+ }
+ break;
+*/
+ case kFeatureAspectRatioCorrection:
+ if (_mode == GFX_WIDE) {
+ _ratio.adjustAspect = (_ratio.adjustAspect + 1) % 3;
+ //calc_rect(true);
+ hotswap_gfx_mode(_mode);
+// TwGfxSetClip(_palmScreenP, &_dstRect);
+ clearScreen();
+ }
+ break;
+ }
+}
+
void OSystem_PalmOS5::setWindowCaption(const char *caption) {
Err e;
Char buf[64];
diff --git a/backends/platform/PalmOS/Src/be_os5.h b/backends/platform/PalmOS/Src/be_os5.h
index a5ee11d6e0..b585ad3fba 100644
--- a/backends/platform/PalmOS/Src/be_os5.h
+++ b/backends/platform/PalmOS/Src/be_os5.h
@@ -27,6 +27,8 @@
#include "be_base.h"
+#define MIN_OFFSET 20
+
#if !defined(SYSTEM_CALLBACK) || defined(PALMOS_68K)
# define SYSTEM_CALLBACK
# ifdef PALMOS_ARM
@@ -100,6 +102,9 @@ extern SoundExType _soundEx;
class OSystem_PalmOS5 : public OSystem_PalmBase {
private:
+ uint16 _scaleTableX[512];
+ uint32 _scaleTableY[512];
+
typedef void (OSystem_PalmOS5::*RendererProc)(RectangleType &r, PointType &p);
RendererProc _render;
@@ -123,7 +128,10 @@ private:
virtual void get_coordinates(EventPtr ev, Coord &x, Coord &y);
virtual bool check_event(Event &event, EventPtr ev);
virtual void extras_palette(uint8 index, uint8 r, uint8 g, uint8 b);
+ void calc_rect(Boolean fullscreen);
+ void calc_scale();
+ void render_landscapeAny(RectangleType &r, PointType &p);
void render_landscape(RectangleType &r, PointType &p);
void render_portrait(RectangleType &r, PointType &p);
void render_1x(RectangleType &r, PointType &p);
@@ -139,11 +147,23 @@ protected:
UInt16 _sysOldCoord, _sysOldOrientation;
Boolean _stretched, _cursorPaletteDisabled;
+ enum {
+ kRatioNone = 0,
+ kRatioHeight,
+ kRatioWidth
+ };
+ struct {
+ UInt8 adjustAspect;
+ Coord width; // (width x 320)
+ Coord height; // (480 x height)
+ } _ratio;
+
public:
OSystem_PalmOS5();
static OSystem *create();
bool hasFeature(Feature f);
+ void setFeatureState(Feature f, bool enable);
void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h);
void clearScreen();
diff --git a/backends/platform/PalmOS/Src/be_zodiac.h b/backends/platform/PalmOS/Src/be_zodiac.h
index 42abf7bfa9..54b5cd55a7 100644
--- a/backends/platform/PalmOS/Src/be_zodiac.h
+++ b/backends/platform/PalmOS/Src/be_zodiac.h
@@ -32,16 +32,6 @@
class OSystem_PalmZodiac : public OSystem_PalmOS5Ex {
private:
- enum {
- kRatioNone = 0,
- kRatioHeight,
- kRatioWidth
- };
- struct {
- UInt8 adjustAspect;
- Coord width; // (width x 320)
- Coord height; // (480 x height)
- } _ratio;
TwGfxType *_gfxH;
TwGfxSurfaceType *_palmScreenP, *_tmpScreenP;
diff --git a/backends/platform/PalmOS/Src/os5_event.cpp b/backends/platform/PalmOS/Src/os5_event.cpp
index ee0464f8f8..915da4ba4f 100644
--- a/backends/platform/PalmOS/Src/os5_event.cpp
+++ b/backends/platform/PalmOS/Src/os5_event.cpp
@@ -30,14 +30,23 @@ void OSystem_PalmOS5::get_coordinates(EventPtr ev, Coord &x, Coord &y) {
x = (ev->screenX - _screenOffset.x);
y = (ev->screenY - _screenOffset.y);
-
+
if (_stretched) {
- if (OPTIONS_TST(kOptModeLandscape)) {
- x = (x * 2 / 3);
- y = (y * 2 / 3);
+ Int32 w, h;
+
+ if (_mode == GFX_NORMAL) {
+
+ h = gVars->screenHeight - MIN_OFFSET * 2;
+ w = gVars->screenWidth;
+ x = (_screenWidth * x) / w;
+ y = (_screenHeight * y) / h;
+
} else {
- y = ((ev->screenX - _screenOffset.y) * 2) / 3;
- x = 320 - ((ev->screenY - _screenOffset.x) * 2) / 3 - 1;
+
+ h = (_ratio.adjustAspect == kRatioHeight ? _ratio.height : gVars->screenFullHeight);
+ w = (_ratio.adjustAspect == kRatioWidth ? _ratio.width : gVars->screenFullWidth);
+ x = (_screenWidth * x) / w;
+ y = (_screenHeight * y) / h;
}
}
}
@@ -56,21 +65,17 @@ bool OSystem_PalmOS5::check_event(Event &event, EventPtr ev) {
if (_keyMouse.hasMore) {
switch (ev->data.keyDown.chr) {
// hot swap gfx
- case 0x1B04:
+// case 0x1B04:
case vchrHard1:
printf("swap\n");
if (OPTIONS_TST(kOptCollapsible))
hotswap_gfx_mode(_mode == GFX_WIDE ? GFX_NORMAL: GFX_WIDE);
return false; // not a key
- // ESC key
+// case 0x1B05:
case vchrHard2:
- _lastKey = kKeyNone;
- event.type = EVENT_KEYDOWN;
- event.kbd.keycode = 27;
- event.kbd.ascii = 27;
- event.kbd.flags = 0;
- return true;
+ setFeatureState(kFeatureAspectRatioCorrection, 0);
+ return false; // not a key
// F5 = menu
case vchrHard3:
diff --git a/backends/platform/PalmOS/Src/os5_gfx.cpp b/backends/platform/PalmOS/Src/os5_gfx.cpp
index d9076bc201..c8ca289b5d 100644
--- a/backends/platform/PalmOS/Src/os5_gfx.cpp
+++ b/backends/platform/PalmOS/Src/os5_gfx.cpp
@@ -24,6 +24,7 @@
#include "be_os5.h"
#include "graphics/surface.h"
+#include "common/config-manager.h"
#include <PenInputMgr.h>
#include <palmOneResources.h>
@@ -54,11 +55,22 @@ void OSystem_PalmOS5::load_gfx_mode() {
return;
_gfxLoaded = true;
+ // get command line config
+// _fullscreen = ConfMan.getBool("fullscreen"); // TODO : (NORMAL mode)
+ _ratio.adjustAspect = ConfMan.getBool("aspect_ratio") ? kRatioHeight : kRatioNone;
+
+ // precalc ratio (WIDE mode)
+ _ratio.width = (gVars->screenFullHeight * _screenWidth / _screenHeight);
+ _ratio.height = (gVars->screenFullWidth * _screenHeight / _screenWidth);
_mouseBackupP = (byte *)MemPtrNew(MAX_MOUSE_W * MAX_MOUSE_H * 2); // *2 if 16bit
_mouseDataP = (byte *)MemPtrNew(MAX_MOUSE_W * MAX_MOUSE_H);
_offScreenP = (byte *)malloc(_screenWidth * _screenHeight);
+ MemSet(_offScreenP, _screenWidth * _screenHeight, 0);
+ MemSet(_nativePal, sizeof(_nativePal), 0);
+ MemSet(_currentPalette, sizeof(_currentPalette), 0);
+
UInt32 depth = 16;
WinScreenMode(winScreenModeSet, NULL, NULL, &depth, NULL);
clearScreen();
@@ -67,17 +79,13 @@ void OSystem_PalmOS5::load_gfx_mode() {
gVars->indicator.off = RGBToColor(0,0,0);
_overlayH = alloc_screen(_screenWidth, _screenHeight);
- _screenH = WinGetDisplayWindow();
-
_overlayP = (OverlayColor *)(BmpGetBits(WinGetBitmap(_overlayH)));
- _screenP = (byte *)(BmpGetBits(WinGetBitmap(_screenH)));
- MemSet(_offScreenP, _screenWidth * _screenHeight, 0);
- MemSet(_nativePal, sizeof(_nativePal), 0);
- MemSet(_currentPalette, sizeof(_currentPalette), 0);
+ _screenH = WinGetDisplayWindow();
+ _screenP = (byte *)(BmpGetBits(WinGetBitmap(_screenH)));
- _isSwitchable = (_screenWidth == 320 && _screenHeight == 200 && OPTIONS_TST(kOptCollapsible));
- if (_screenWidth > 320 || _screenHeight > 200 || !_isSwitchable)
+ _isSwitchable = OPTIONS_TST(kOptModeLandscape) && OPTIONS_TST(kOptCollapsible);
+ if (!_isSwitchable)
_mode = GFX_NORMAL;
hotswap_gfx_mode(_mode);
@@ -85,62 +93,53 @@ void OSystem_PalmOS5::load_gfx_mode() {
void OSystem_PalmOS5::hotswap_gfx_mode(int mode) {
Err e;
- UInt32 device;
if (_mode != GFX_NORMAL && !_isSwitchable)
return;
- if (_workScreenH)
- WinDeleteWindow(_workScreenH, false);
- _workScreenH = NULL;
-
#ifdef PALMOS_ARM
+ UInt32 device;
Boolean isT3 = false;
if (!FtrGet(sysFileCSystem, sysFtrNumOEMDeviceID, &device))
isT3 = (device == kPalmOneDeviceIDTungstenT3);
#endif
+ if (_workScreenH)
+ WinDeleteWindow(_workScreenH, false);
+ _workScreenH = NULL;
+
+ _screenDest.w = _screenWidth;
+ _screenDest.h = _screenHeight;
+
// prevent bad DIA redraw (Stat part)
- if (mode == GFX_NORMAL) {
- // only if this API is available
- if (_stretched && OPTIONS_TST(kOptCollapsible)) {
+ if (mode == GFX_NORMAL) {
+ _redawOSD = true;
+ _stretched = (_screenWidth > gVars->screenWidth);
+
#ifdef PALMOS_ARM
- if (isT3) {
- //AiaSetInputAreaState(aiaInputAreaShow);
- StatShow_68k();
- PINSetInputAreaState_68k(pinInputAreaOpen);
- } else
+ if (isT3) {
+ //AiaSetInputAreaState(aiaInputAreaShow);
+ StatShow_68k();
+ PINSetInputAreaState_68k(pinInputAreaOpen);
+ } else
#endif
- {
- StatShow();
- PINSetInputAreaState(pinInputAreaOpen);
- }
+ {
+ StatShow();
+ PINSetInputAreaState(pinInputAreaOpen);
}
- _redawOSD = true;
- _stretched = false;
- OPTIONS_RST(kOptDisableOnScrDisp);
- _screenDest.w = _screenWidth;
- _screenDest.h = _screenHeight;
-
- if (_wasRotated) {
- // restore controls rotation
- SWAP(_keyMouse.bitLeft, _keyMouse.bitRight);
- SWAP(_keyMouse.bitRight, _keyMouse.bitDown);
- SWAP(_keyMouse.bitLeft, _keyMouse.bitUp);
- _wasRotated = false;
+ if (_stretched) {
+ calc_rect(false);
+ } else {
+ // offsets
+ _screenOffset.x = (gVars->screenWidth - _screenWidth) / 2;
+ _screenOffset.y = (gVars->screenHeight - _screenHeight) / 2;
}
- _workScreenH = alloc_screen(_screenWidth, _screenHeight);
- _workScreenP = (int16 *)(BmpGetBits(WinGetBitmap(_workScreenH)));
- MemSet(_workScreenP, _screenWidth * _screenHeight * 2, 0);
-
- _screenOffset.x = (gVars->screenWidth - _screenWidth) / 2;
- _screenOffset.y = (gVars->screenHeight - _screenHeight) / 2;
-
- _render = &OSystem_PalmOS5::render_1x;
-
} else {
+ _redawOSD = false;
+ _stretched = true;
+
#ifdef PALMOS_ARM
// T3 DIA library is 68k base, there is no possible native call
if (isT3) {
@@ -154,35 +153,22 @@ void OSystem_PalmOS5::hotswap_gfx_mode(int mode) {
StatHide();
}
- _redawOSD = false;
- _stretched = true;
- OPTIONS_SET(kOptDisableOnScrDisp);
-
- if (OPTIONS_TST(kOptModeLandscape)) {
- _screenDest.w = 480;
- _screenDest.h = 300;
- _workScreenH = alloc_screen(480, 300);
- _render = &OSystem_PalmOS5::render_landscape;
-
- } else {
- _screenDest.w = 300;
- _screenDest.h = 480;
- _workScreenH = alloc_screen(300, 480);
- _render = &OSystem_PalmOS5::render_portrait;
- // This mode need a controls rotation
- SWAP(_keyMouse.bitLeft, _keyMouse.bitUp);
- SWAP(_keyMouse.bitRight, _keyMouse.bitDown);
- SWAP(_keyMouse.bitLeft, _keyMouse.bitRight);
- _wasRotated = true;
- }
-
- _workScreenP = (int16 *)(BmpGetBits(WinGetBitmap(_workScreenH)));
- MemSet(_workScreenP, 480 * 300 * 2, 0);
+ calc_rect(true);
+ }
- _screenOffset.x = 0;
- _screenOffset.y = 10;
+ if (_stretched) {
+ calc_scale();
+ OPTIONS_SET(kOptDisableOnScrDisp);
+ _render = &OSystem_PalmOS5::render_landscapeAny;
+ } else {
+ OPTIONS_RST(kOptDisableOnScrDisp);
+ _render = &OSystem_PalmOS5::render_1x;
}
+ _workScreenH = alloc_screen(_screenDest.w, _screenDest.h);
+ _workScreenP = (int16 *)(BmpGetBits(WinGetBitmap(_workScreenH)));
+ MemSet(_workScreenP, _screenDest.w * _screenDest.h * 2, 0);
+
_mode = mode;
clearScreen();
}
diff --git a/backends/platform/PalmOS/Src/os5_renderer.cpp b/backends/platform/PalmOS/Src/os5_renderer.cpp
index ff692ae863..066e0f1523 100644
--- a/backends/platform/PalmOS/Src/os5_renderer.cpp
+++ b/backends/platform/PalmOS/Src/os5_renderer.cpp
@@ -48,109 +48,30 @@ void OSystem_PalmOS5::render_1x(RectangleType &r, PointType &p) {
RctSetRectangle(&r, 0, 0, _screenWidth, _screenHeight - o);
}
-void OSystem_PalmOS5::render_landscape(RectangleType &r, PointType &p) {
+void OSystem_PalmOS5::render_landscapeAny(RectangleType &r, PointType &p) {
Coord x, y, o = 0;
int16 *dst = _workScreenP;
if (_overlayVisible) {
- int16 *src = _overlayP;
-
- for (y = 0; y < 100; y++) {
- // draw 2 lines
- for (x = 0; x < 320; x++) {
- *dst++ = *src++;
- *dst++ = *src;
- *dst++ = *src++;
+ for (y = 0; y < _screenDest.h; y++) {
+ int16 *src = _overlayP + *(_scaleTableY + y);
+ for (x = 0; x < _screenDest.w; x++) {
+ *dst++ = *(src + *(_scaleTableX + x));
}
- // copy the second to the next line
- MemMove(dst, dst - 480, 480 * 2);
- dst += 480;
}
} else {
- byte *src = _offScreenP;
o = _current_shake_pos;
- for (y = 0; y < 100; y++) {
- // draw 2 lines
- for (x = 0; x < 320; x++) {
- *dst++ = _nativePal[*src++];
- *dst++ = _nativePal[*src];
- *dst++ = _nativePal[*src++];
+ for (y = 0; y < _screenDest.h; y++) {
+ byte *src = _offScreenP + *(_scaleTableY + y);
+ for (x = 0; x < _screenDest.w; x++) {
+ *dst++ = *(_nativePal + *(src + *(_scaleTableX + x)));
}
- // copy the second to the next line
- MemMove(dst, dst - 480, 480 * 2);
- dst += 480;
}
}
p.x = _screenOffset.x;
p.y = _screenOffset.y + o;
- RctSetRectangle(&r, 0, 0, 480, 300 - o);
+ RctSetRectangle(&r, 0, 0, _screenDest.w, _screenDest.h - o);
}
-
-void OSystem_PalmOS5::render_portrait(RectangleType &r, PointType &p) {
- Coord x, y, o = 0;
- int16 *dst = _workScreenP;
-
- if (_overlayVisible) {
- int16 *src = _overlayP + 320 - 1;
- int16 *src2 = src;
-
- for (x = 0; x < 160; x++) {
- for (y = 0; y < 100; y++) {
- *dst++ = *src;
- src += 320;
- *dst++ = *src;
- *dst++ = *src;
- src += 320;
- }
- src = --src2;
-
- for (y = 0; y < 100; y++) {
- *dst++ = *src;
- src += 320;
- *dst++ = *src;
- *dst++ = *src;
- src += 320;
- }
- src = --src2;
-
- MemMove(dst, dst - 300, 300 * 2); // 300 = 200 x 1.5
- dst += 300;
- }
-
- } else {
- byte *src = _offScreenP + 320 - 1;
- byte *src2 = src;
- o = _current_shake_pos;
-
- for (x = 0; x < 160; x++) {
- for (y = 0; y < 100; y++) {
- *dst++ = _nativePal[*src];
- src += 320;
- *dst++ = _nativePal[*src];
- *dst++ = _nativePal[*src];
- src += 320;
- }
- src = --src2;
-
- for (y = 0; y < 100; y++) {
- *dst++ = _nativePal[*src];
- src += 320;
- *dst++ = _nativePal[*src];
- *dst++ = _nativePal[*src];
- src += 320;
- }
- src = --src2;
-
- MemMove(dst, dst - 300, 300 * 2); // 300 = 200 x 1.5
- dst += 300;
- }
- }
-
- p.y = _screenOffset.x;
- p.x = _screenOffset.y + o;
- RctSetRectangle(&r, 0, 0, 300 - o, 480);
-}
-