diff options
Diffstat (limited to 'backends/platform/dingux')
-rw-r--r-- | backends/platform/dingux/README.DINGUX | 68 | ||||
-rw-r--r-- | backends/platform/dingux/dingux-events.cpp | 215 | ||||
-rw-r--r-- | backends/platform/dingux/dingux-graphics.cpp | 468 | ||||
-rw-r--r-- | backends/platform/dingux/dingux.cpp | 58 | ||||
-rw-r--r-- | backends/platform/dingux/dingux.h | 69 | ||||
-rw-r--r-- | backends/platform/dingux/dingux.mk | 30 | ||||
-rw-r--r-- | backends/platform/dingux/main.cpp | 53 | ||||
-rw-r--r-- | backends/platform/dingux/module.mk | 13 | ||||
-rw-r--r-- | backends/platform/dingux/scummvm.gpe | 5 |
9 files changed, 979 insertions, 0 deletions
diff --git a/backends/platform/dingux/README.DINGUX b/backends/platform/dingux/README.DINGUX new file mode 100644 index 0000000000..d867e02f03 --- /dev/null +++ b/backends/platform/dingux/README.DINGUX @@ -0,0 +1,68 @@ +ScummVM-DINGUX README +============================================================================== + +Requirements +============ +- Dingoo A320/A330 +- Dingux installed on SD card +- Fixed Tremor libs in dingux rootfs (see below) + +Controls +============ +- Dpad: move mouse cursor +- Y: left mouse button click +- A: '0' key +- B: right mouse button click +- X: '.' key (skips dialogue line in some engines) +- Left Trigger: open global menu +- Right Trigger: ESC button, scene skip in some engines +- Select: opens virtual keyboard +- Start: F5 key, game menu in some engines + +Installation from binaries +============================== +Mount your dingux SD card in your pc, then copy the directory "scummvm" found in +the release package to a directory inside /pathtosdcard/local/dirofyourchoice +(on windows it would be SDLETTER:\local\dirofyourchoice). +At this point is sufficient to point your launcher (eg. gmenu2x) to scummvm.gpe +file included into the scummvm directory you copied to the SD card, and then launch it. + +Building from binaries +============================== +* ToDO * + +Kernel and rootfs WARNINGS +============================== +All the dingux root images (rootfs) i found floating on the net have +broken tremor libraries, which make scummvm crash in a bad way. +One solution is to replace the libraries in your rootfs by injecting these fixed ones: +http://hkzlab.ipv7.net/files/misc/dingux/dingux_fixed_tremor_libs.zip +After having added these libs, scummvm should work on your standard dingux kernel, +but this doesn't mean it will work perfectly: +non-opendingux kernels doesn't have lcd double buffering leading to a lot of annoying +tearing on screen. + +The best way to address all the problems in one shot, is to use an opendingux kernel for +your dingoo, which has some interesting advantages: +- The kernel gets updated and kept in sync with main linux tree +- Double buffering and centering of screen image +- Support for swap on compressed ram +I have prepared a rootfs image with fixed libs and swap-on-zram to use together with opendingux kernels: +http://hkzlab.ipv7.net/files/misc/dingux/opendingux/opendingux_kernel_rootfs.zip +The kernel and rootfs images in the zip file is what i use for developing scummvm on dingux. + +BTW, i have built images for the A330 and A320 with ILI9325 controllers too, +but these version aren't tested (i have an A320 with ILI9331, but if someone wants to +donate an A330 to a poor scummvm developer so i can try the port there too... :P) + +If you need a launcher with opendingux cpu frequency scaler support, you can find gmenu2x here: +http://www.treewalker.org/dingux/cpufreq.html + +I've also prepared a rootfs image for use on normal dingux kernels (non-opendingux ones). +It's based on elta's rootfs image with just the fixed libs replaced. +http://hkzlab.ipv7.net/files/misc/dingux/normal_dingux/rootfs_elta_fixtremor.zip +I still raccomand the use of opendingux kernel + rootfs, but if you don't, this roofs +image plus another kernel (eg. SiENcE's one) should be do the job. + +Enjoy + diff --git a/backends/platform/dingux/dingux-events.cpp b/backends/platform/dingux/dingux-events.cpp new file mode 100644 index 0000000000..f9b519623d --- /dev/null +++ b/backends/platform/dingux/dingux-events.cpp @@ -0,0 +1,215 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "backends/platform/dingux/dingux.h" + +#include "graphics/scaler/aspect.h" // for aspect2Real + +#if defined (DINGUX) + +#define PAD_UP SDLK_UP +#define PAD_DOWN SDLK_DOWN +#define PAD_LEFT SDLK_LEFT +#define PAD_RIGHT SDLK_RIGHT +#define BUT_A SDLK_LCTRL +#define BUT_B SDLK_LALT +#define BUT_X SDLK_SPACE +#define BUT_Y SDLK_LSHIFT +#define BUT_SELECT SDLK_ESCAPE +#define BUT_START SDLK_RETURN +#define TRIG_L SDLK_TAB +#define TRIG_R SDLK_BACKSPACE + +static int mapKey(SDLKey key, SDLMod mod, Uint16 unicode) { + if (key >= SDLK_F1 && key <= SDLK_F9) { + return key - SDLK_F1 + Common::ASCII_F1; + } else if (key >= SDLK_KP0 && key <= SDLK_KP9) { + return key - SDLK_KP0 + '0'; + } else if (key >= SDLK_UP && key <= SDLK_PAGEDOWN) { + return key; + } else if (unicode) { + return unicode; + } else if (key >= 'a' && key <= 'z' && (mod & KMOD_SHIFT)) { + return key & ~0x20; + } else if (key >= SDLK_NUMLOCK && key <= SDLK_EURO) { + return 0; + } + return key; +} + +bool OSystem_SDL_Dingux::remapKey(SDL_Event &ev, Common::Event &event) { + if (ev.key.keysym.sym == PAD_UP) { + if (ev.type == SDL_KEYDOWN) { + _km.y_vel = -1; + _km.y_down_count = 1; + } else { + _km.y_vel = 0; + _km.y_down_count = 0; + } + + event.type = Common::EVENT_MOUSEMOVE; + fillMouseEvent(event, _km.x, _km.y); + + return true; + } else if (ev.key.keysym.sym == PAD_DOWN) { + if (ev.type == SDL_KEYDOWN) { + _km.y_vel = 1; + _km.y_down_count = 1; + } else { + _km.y_vel = 0; + _km.y_down_count = 0; + } + + event.type = Common::EVENT_MOUSEMOVE; + fillMouseEvent(event, _km.x, _km.y); + + return true; + } else if (ev.key.keysym.sym == PAD_LEFT) { + if (ev.type == SDL_KEYDOWN) { + _km.x_vel = -1; + _km.x_down_count = 1; + } else { + _km.x_vel = 0; + _km.x_down_count = 0; + } + + event.type = Common::EVENT_MOUSEMOVE; + fillMouseEvent(event, _km.x, _km.y); + + return true; + } else if (ev.key.keysym.sym == PAD_RIGHT) { + if (ev.type == SDL_KEYDOWN) { + _km.x_vel = 1; + _km.x_down_count = 1; + } else { + _km.x_vel = 0; + _km.x_down_count = 0; + } + + event.type = Common::EVENT_MOUSEMOVE; + fillMouseEvent(event, _km.x, _km.y); + + return true; + } else if (ev.key.keysym.sym == BUT_Y) { // left mouse button + if (ev.type == SDL_KEYDOWN) { + event.type = Common::EVENT_LBUTTONDOWN; + } else { + event.type = Common::EVENT_LBUTTONUP; + } + + fillMouseEvent(event, _km.x, _km.y); + + return true; + } else if (ev.key.keysym.sym == BUT_B) { // right mouse button + if (ev.type == SDL_KEYDOWN) { + event.type = Common::EVENT_RBUTTONDOWN; + } else { + event.type = Common::EVENT_RBUTTONUP; + } + + fillMouseEvent(event, _km.x, _km.y); + + return true; + } else if (ev.key.keysym.sym == BUT_X) { // '.' skip dialogue + ev.key.keysym.sym = SDLK_PERIOD; + ev.key.keysym.mod = (SDLMod)0; + ev.key.keysym.unicode = '.'; + } else if (ev.key.keysym.sym == TRIG_L) { // global menu + ev.key.keysym.sym = SDLK_F5; + event.kbd.keycode = Common::KEYCODE_F5; + event.kbd.ascii = Common::ASCII_F5; + event.kbd.flags = Common::KBD_CTRL; + + if (ev.type == SDL_KEYDOWN) { + event.type = Common::EVENT_KEYDOWN; + } else { + event.type = Common::EVENT_KEYUP; + } + + return true; + } else if (ev.key.keysym.sym == BUT_A) { // key '0' + ev.key.keysym.sym = SDLK_0; + + event.kbd.keycode = Common::KEYCODE_0; + event.kbd.ascii = '0'; + event.kbd.flags = 0; + + if (ev.type == SDL_KEYDOWN) { + event.type = Common::EVENT_KEYDOWN; + } else { + event.type = Common::EVENT_KEYUP; + } + + return true; + } else if (ev.key.keysym.sym == BUT_SELECT) { // virtual keyboard + ev.key.keysym.sym = SDLK_F7; + + } else if (ev.key.keysym.sym == BUT_START) { // F5, menu in some games + ev.key.keysym.sym = SDLK_F5; + + } else if (ev.key.keysym.sym == TRIG_R) { // ESC + ev.key.keysym.sym = SDLK_ESCAPE; + } else { + event.kbd.keycode = (Common::KeyCode)ev.key.keysym.sym; + event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode); + } + + return false; +} + +void OSystem_SDL_Dingux::fillMouseEvent(Common::Event &event, int x, int y) { + if (_videoMode.mode == GFX_HALF && !_overlayVisible) { + event.mouse.x = x * 2; + event.mouse.y = y * 2; + } else { + event.mouse.x = x; + event.mouse.y = y; + } + + // Update the "keyboard mouse" coords + _km.x = x; + _km.y = y; + + // Adjust for the screen scaling + if (!_overlayVisible) { + event.mouse.x /= _videoMode.scaleFactor; + event.mouse.y /= _videoMode.scaleFactor; + if (_videoMode.aspectRatioCorrection) + event.mouse.y = aspect2Real(event.mouse.y); + } +} + +void OSystem_SDL_Dingux::warpMouse(int x, int y) { + if (_mouseCurState.x != x || _mouseCurState.y != y) { + if (_videoMode.mode == GFX_HALF && !_overlayVisible) { + x = x / 2; + y = y / 2; + } + } + OSystem_SDL::warpMouse(x, y); +} + +#endif + diff --git a/backends/platform/dingux/dingux-graphics.cpp b/backends/platform/dingux/dingux-graphics.cpp new file mode 100644 index 0000000000..bbd4a58636 --- /dev/null +++ b/backends/platform/dingux/dingux-graphics.cpp @@ -0,0 +1,468 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "backends/platform/dingux/dingux.h" + +#include "common/mutex.h" +#include "graphics/scaler.h" +#include "graphics/scaler/aspect.h" +#include "graphics/scaler/downscaler.h" +#include "graphics/surface.h" + +#if defined (DINGUX) + +static const OSystem::GraphicsMode s_supportedGraphicsModes[] = { + {"1x", "Standard", GFX_NORMAL}, + {0, 0, 0} +}; + +int OSystem_SDL_Dingux::getDefaultGraphicsMode() const { + return GFX_NORMAL; +} + +const OSystem::GraphicsMode *OSystem_SDL_Dingux::getSupportedGraphicsModes() const { + return s_supportedGraphicsModes; +} + +bool OSystem_SDL_Dingux::setGraphicsMode(int mode) { + Common::StackLock lock(_graphicsMutex); + + assert(_transactionMode == kTransactionActive); + + if (_oldVideoMode.setup && _oldVideoMode.mode == mode) + return true; + + int newScaleFactor = 1; + + switch (mode) { + case GFX_NORMAL: + newScaleFactor = 1; + break; + case GFX_HALF: + newScaleFactor = 1; + break; + default: + warning("unknown gfx mode %d", mode); + return false; + } + + _transactionDetails.normal1xScaler = (mode == GFX_NORMAL); + if (_oldVideoMode.setup && _oldVideoMode.scaleFactor != newScaleFactor) + _transactionDetails.needHotswap = true; + + _transactionDetails.needUpdatescreen = true; + + _videoMode.mode = mode; + _videoMode.scaleFactor = newScaleFactor; + + return true; +} + +void OSystem_SDL_Dingux::setGraphicsModeIntern() { + Common::StackLock lock(_graphicsMutex); + ScalerProc *newScalerProc = 0; + + switch (_videoMode.mode) { + case GFX_NORMAL: + newScalerProc = Normal1x; + break; + case GFX_HALF: + newScalerProc = DownscaleAllByHalf; + break; + + default: + error("Unknown gfx mode %d", _videoMode.mode); + } + + _scalerProc = newScalerProc; + + if (!_screen || !_hwscreen) + return; + + // Blit everything to the screen + _forceFull = true; + + // Even if the old and new scale factors are the same, we may have a + // different scaler for the cursor now. + blitCursor(); +} + +void OSystem_SDL_Dingux::initSize(uint w, uint h) { + assert(_transactionMode == kTransactionActive); + + // Avoid redundant res changes + if ((int)w == _videoMode.screenWidth && (int)h == _videoMode.screenHeight) + return; + + _videoMode.screenWidth = w; + _videoMode.screenHeight = h; + if (w > 320 || h > 240) { + setGraphicsMode(GFX_HALF); + setGraphicsModeIntern(); + toggleMouseGrab(); + } + + _transactionDetails.sizeChanged = true; +} + +void OSystem_SDL_Dingux::drawMouse() { + if (!_mouseVisible || !_mouseSurface) { + _mouseBackup.x = _mouseBackup.y = _mouseBackup.w = _mouseBackup.h = 0; + return; + } + + SDL_Rect dst; + int scale; + int hotX, hotY; + + if (_videoMode.mode == GFX_HALF && !_overlayVisible) { + dst.x = _mouseCurState.x / 2; + dst.y = _mouseCurState.y / 2; + } else { + dst.x = _mouseCurState.x; + dst.y = _mouseCurState.y; + } + + if (!_overlayVisible) { + scale = _videoMode.scaleFactor; + dst.w = _mouseCurState.vW; + dst.h = _mouseCurState.vH; + hotX = _mouseCurState.vHotX; + hotY = _mouseCurState.vHotY; + } else { + scale = 1; + dst.w = _mouseCurState.rW; + dst.h = _mouseCurState.rH; + hotX = _mouseCurState.rHotX; + hotY = _mouseCurState.rHotY; + } + + // The mouse is undrawn using virtual coordinates, i.e. they may be + // scaled and aspect-ratio corrected. + + _mouseBackup.x = dst.x - hotX; + _mouseBackup.y = dst.y - hotY; + _mouseBackup.w = dst.w; + _mouseBackup.h = dst.h; + + // We draw the pre-scaled cursor image, so now we need to adjust for + // scaling, shake position and aspect ratio correction manually. + + if (!_overlayVisible) { + dst.y += _currentShakePos; + } + + if (_videoMode.aspectRatioCorrection && !_overlayVisible) + dst.y = real2Aspect(dst.y); + + dst.x = scale * dst.x - _mouseCurState.rHotX; + dst.y = scale * dst.y - _mouseCurState.rHotY; + dst.w = _mouseCurState.rW; + dst.h = _mouseCurState.rH; + + // Note that SDL_BlitSurface() and addDirtyRect() will both perform any + // clipping necessary + + if (SDL_BlitSurface(_mouseSurface, NULL, _hwscreen, &dst) != 0) + error("SDL_BlitSurface failed: %s", SDL_GetError()); + + // The screen will be updated using real surface coordinates, i.e. + // they will not be scaled or aspect-ratio corrected. + addDirtyRect(dst.x, dst.y, dst.w, dst.h, true); +} + +void OSystem_SDL_Dingux::undrawMouse() { + const int x = _mouseBackup.x; + const int y = _mouseBackup.y; + + // When we switch bigger overlay off mouse jumps. Argh! + // This is intended to prevent undrawing offscreen mouse + if (!_overlayVisible && (x >= _videoMode.screenWidth || y >= _videoMode.screenHeight)) + return; + + if (_mouseBackup.w != 0 && _mouseBackup.h != 0) { + if (_videoMode.mode == GFX_HALF && !_overlayVisible) { + addDirtyRect(x*2, y*2, _mouseBackup.w*2, _mouseBackup.h*2); + } else { + addDirtyRect(x, y, _mouseBackup.w, _mouseBackup.h); + } + } +} + +void OSystem_SDL_Dingux::internUpdateScreen() { + SDL_Surface *srcSurf, *origSurf; + int height, width; + ScalerProc *scalerProc; + int scale1; + +#if defined (DEBUG) && ! defined(_WIN32_WCE) // definitions not available for non-DEBUG here. (needed this to compile in SYMBIAN32 & linux?) + assert(_hwscreen != NULL); + assert(_hwscreen->map->sw_data != NULL); +#endif + + // If the shake position changed, fill the dirty area with blackness + if (_currentShakePos != _newShakePos) { + SDL_Rect blackrect = {0, 0, _videoMode.screenWidth * _videoMode.scaleFactor, _newShakePos * _videoMode.scaleFactor}; + + if (_videoMode.aspectRatioCorrection && !_overlayVisible) + blackrect.h = real2Aspect(blackrect.h - 1) + 1; + + SDL_FillRect(_hwscreen, &blackrect, 0); + + _currentShakePos = _newShakePos; + + _forceFull = true; + } + + // Check whether the palette was changed in the meantime and update the + // screen surface accordingly. + if (_screen && _paletteDirtyEnd != 0) { + SDL_SetColors(_screen, _currentPalette + _paletteDirtyStart, + _paletteDirtyStart, + _paletteDirtyEnd - _paletteDirtyStart); + + _paletteDirtyEnd = 0; + + _forceFull = true; + } + +#ifdef USE_OSD + // OSD visible (i.e. non-transparent)? + if (_osdAlpha != SDL_ALPHA_TRANSPARENT) { + // Updated alpha value + const int diff = SDL_GetTicks() - _osdFadeStartTime; + if (diff > 0) { + if (diff >= kOSDFadeOutDuration) { + // Back to full transparency + _osdAlpha = SDL_ALPHA_TRANSPARENT; + } else { + // Do a linear fade out... + const int startAlpha = SDL_ALPHA_TRANSPARENT + kOSDInitialAlpha * (SDL_ALPHA_OPAQUE - SDL_ALPHA_TRANSPARENT) / 100; + _osdAlpha = startAlpha + diff * (SDL_ALPHA_TRANSPARENT - startAlpha) / kOSDFadeOutDuration; + } + SDL_SetAlpha(_osdSurface, SDL_RLEACCEL | SDL_SRCCOLORKEY | SDL_SRCALPHA, _osdAlpha); + _forceFull = true; + } + } +#endif + + if (!_overlayVisible) { + origSurf = _screen; + srcSurf = _tmpscreen; + width = _videoMode.screenWidth; + height = _videoMode.screenHeight; + scalerProc = _scalerProc; + scale1 = _videoMode.scaleFactor; + } else { + origSurf = _overlayscreen; + srcSurf = _tmpscreen2; + width = _videoMode.overlayWidth; + height = _videoMode.overlayHeight; + scalerProc = Normal1x; + scale1 = 1; + } + + // Add the area covered by the mouse cursor to the list of dirty rects if + // we have to redraw the mouse. + if (_mouseNeedsRedraw) + undrawMouse(); + + // Force a full redraw if requested + if (_forceFull) { + _numDirtyRects = 1; + _dirtyRectList[0].x = 0; + _dirtyRectList[0].y = 0; + _dirtyRectList[0].w = width; + _dirtyRectList[0].h = height; + } + + // Only draw anything if necessary + if (_numDirtyRects > 0 || _mouseNeedsRedraw) { + SDL_Rect *r; + SDL_Rect dst; + uint32 srcPitch, dstPitch; + SDL_Rect *lastRect = _dirtyRectList + _numDirtyRects; + + for (r = _dirtyRectList; r != lastRect; ++r) { + dst = *r; + dst.x++; // Shift rect by one since 2xSai needs to access the data around + dst.y++; // any pixel to scale it, and we want to avoid mem access crashes. + + if (SDL_BlitSurface(origSurf, r, srcSurf, &dst) != 0) + error("SDL_BlitSurface failed: %s", SDL_GetError()); + } + + SDL_LockSurface(srcSurf); + SDL_LockSurface(_hwscreen); + + srcPitch = srcSurf->pitch; + dstPitch = _hwscreen->pitch; + + for (r = _dirtyRectList; r != lastRect; ++r) { + register int dst_y = r->y + _currentShakePos; + register int dst_h = 0; + register int dst_w = r->w; + register int orig_dst_y = 0; + register int dst_x = r->x; + register int src_y; + register int src_x; + + if (dst_y < height) { + dst_h = r->h; + if (dst_h > height - dst_y) + dst_h = height - dst_y; + + orig_dst_y = dst_y; + src_x = dst_x; + src_y = dst_y; + + if (_videoMode.aspectRatioCorrection && !_overlayVisible) + dst_y = real2Aspect(dst_y); + + assert(scalerProc != NULL); + + if ((_videoMode.mode == GFX_HALF) && (scalerProc == DownscaleAllByHalf)) { + if (dst_x % 2 == 1) { + dst_x--; + dst_w++; + } + if (dst_y % 2 == 1) { + dst_y--; + dst_h++; + } + src_x = dst_x; + src_y = dst_y; + dst_x = dst_x / 2; + dst_y = dst_y / 2; + + scalerProc((byte *)srcSurf->pixels + (src_x * 2 + 2) + (src_y + 1) * srcPitch, srcPitch, + (byte *)_hwscreen->pixels + dst_x * 2 + dst_y * dstPitch, dstPitch, dst_w, dst_h); + + } else { + scalerProc((byte *)srcSurf->pixels + (r->x * 2 + 2) + (r->y + 1) * srcPitch, srcPitch, + (byte *)_hwscreen->pixels + r->x * 2 + dst_y * dstPitch, dstPitch, r->w, dst_h); + } + } + + if (_videoMode.mode == GFX_HALF && scalerProc == DownscaleAllByHalf) { + r->w = r->w / 2; + r->h = dst_h / 2; + } else { + r->w = r->w; + r->h = dst_h; + } + + r->x = dst_x; + r->y = dst_y; + + +#ifdef USE_SCALERS + if (_videoMode.aspectRatioCorrection && orig_dst_y < height && !_overlayVisible) + r->h = stretch200To240((uint8 *) _hwscreen->pixels, dstPitch, r->w, r->h, r->x, r->y, orig_dst_y * scale1); +#endif + } + SDL_UnlockSurface(srcSurf); + SDL_UnlockSurface(_hwscreen); + + // Readjust the dirty rect list in case we are doing a full update. + // This is necessary if shaking is active. + if (_forceFull) { + _dirtyRectList[0].y = 0; + _dirtyRectList[0].h = (_videoMode.mode == GFX_HALF) ? effectiveScreenHeight() / 2 : effectiveScreenHeight(); + } + + drawMouse(); + +#ifdef USE_OSD + if (_osdAlpha != SDL_ALPHA_TRANSPARENT) { + SDL_BlitSurface(_osdSurface, 0, _hwscreen, 0); + } +#endif + // Finally, blit all our changes to the screen + SDL_UpdateRects(_hwscreen, _numDirtyRects, _dirtyRectList); + } + + _numDirtyRects = 0; + _forceFull = false; + _mouseNeedsRedraw = false; +} + +void OSystem_SDL_Dingux::showOverlay() { + if (_videoMode.mode == GFX_HALF) { + _mouseCurState.x = _mouseCurState.x / 2; + _mouseCurState.y = _mouseCurState.y / 2; + } + OSystem_SDL::showOverlay(); +} + +void OSystem_SDL_Dingux::hideOverlay() { + if (_videoMode.mode == GFX_HALF) { + _mouseCurState.x = _mouseCurState.x * 2; + _mouseCurState.y = _mouseCurState.y * 2; + } + OSystem_SDL::hideOverlay(); +} + +bool OSystem_SDL_Dingux::loadGFXMode() { + + // Forcefully disable aspect ratio correction for games + // which starts with a native 240px height resolution. + // This fixes games with weird resolutions, like MM Nes (256x240) + if(_videoMode.screenHeight == 240) { + _videoMode.aspectRatioCorrection = false; + } + + fprintf(stdout, "Game ScreenMode = %d*%d\n", _videoMode.screenWidth, _videoMode.screenHeight); + if (_videoMode.screenWidth > 320 || _videoMode.screenHeight > 240) { + _videoMode.aspectRatioCorrection = false; + setGraphicsMode(GFX_HALF); + fprintf(stdout, "GraphicsMode set to HALF\n"); + } else { + setGraphicsMode(GFX_NORMAL); + fprintf(stdout, "GraphicsMode set to NORMAL\n"); + } + + if ((_videoMode.mode == GFX_HALF) && !_overlayVisible) { + _videoMode.overlayWidth = _videoMode.screenWidth / 2; + _videoMode.overlayHeight = _videoMode.screenHeight / 2; + _videoMode.fullscreen = true; + } else { + + _videoMode.overlayWidth = _videoMode.screenWidth * _videoMode.scaleFactor; + _videoMode.overlayHeight = _videoMode.screenHeight * _videoMode.scaleFactor; + + if (_videoMode.aspectRatioCorrection) + _videoMode.overlayHeight = real2Aspect(_videoMode.overlayHeight); + + _videoMode.hardwareWidth = _videoMode.screenWidth * _videoMode.scaleFactor; + _videoMode.hardwareHeight = effectiveScreenHeight(); + } + + + return OSystem_SDL::loadGFXMode(); +} + +#endif + diff --git a/backends/platform/dingux/dingux.cpp b/backends/platform/dingux/dingux.cpp new file mode 100644 index 0000000000..cdf10600ce --- /dev/null +++ b/backends/platform/dingux/dingux.cpp @@ -0,0 +1,58 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "backends/platform/dingux/dingux.h" + +#if defined(DINGUX) + +bool OSystem_SDL_Dingux::hasFeature(Feature f) { + return + (f == kFeatureAspectRatioCorrection) || + (f == kFeatureCursorHasPalette); +} + +void OSystem_SDL_Dingux::setFeatureState(Feature f, bool enable) { + switch (f) { + case kFeatureAspectRatioCorrection: + setAspectRatioCorrection(enable); + break; + default: + break; + } +} + +bool OSystem_SDL_Dingux::getFeatureState(Feature f) { + assert(_transactionMode == kTransactionNone); + + switch (f) { + case kFeatureAspectRatioCorrection: + return _videoMode.aspectRatioCorrection; + default: + return false; + } +} + +#endif + diff --git a/backends/platform/dingux/dingux.h b/backends/platform/dingux/dingux.h new file mode 100644 index 0000000000..846ad3faf9 --- /dev/null +++ b/backends/platform/dingux/dingux.h @@ -0,0 +1,69 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#ifndef SDL_DINGUX_COMMON_H +#define SDL_DINGUX_COMMON_H + +#include <SDL.h> + +#include "backends/base-backend.h" +#include "backends/platform/sdl/sdl.h" + +#if defined(DINGUX) + +enum { + GFX_HALF = 12 +}; + +class OSystem_SDL_Dingux : public OSystem_SDL { +public: + virtual bool hasFeature(Feature f); + virtual void setFeatureState(Feature f, bool enable); + virtual bool getFeatureState(Feature f); + virtual int getDefaultGraphicsMode() const; + + void initSize(uint w, uint h); + const OSystem::GraphicsMode *getSupportedGraphicsModes() const; + bool setGraphicsMode(const char *name); + bool setGraphicsMode(int mode); + void setGraphicsModeIntern(); + void internUpdateScreen(); + void showOverlay(); + void hideOverlay(); + bool loadGFXMode(); + void drawMouse(); + void undrawMouse(); + void warpMouse(int, int); + void fillMouseEvent(Common::Event&, int, int); + +protected: + virtual bool remapKey(SDL_Event &ev, Common::Event &event); +}; + + +#endif + +#endif + diff --git a/backends/platform/dingux/dingux.mk b/backends/platform/dingux/dingux.mk new file mode 100644 index 0000000000..882078fe46 --- /dev/null +++ b/backends/platform/dingux/dingux.mk @@ -0,0 +1,30 @@ +DINGUX_EXE_STRIPPED := scummvm_stripped$(EXEEXT) + +bundle_name = dingux-dist/scummvm + +all: $(DINGUX_EXE_STRIPPED) + +$(DINGUX_EXE_STRIPPED): $(EXECUTABLE) + $(STRIP) $< -o $@ + +dingux-distclean: + rm -rf $(bundle_name) + rm $(DINGUX_EXE_STRIPPED) + +dingux-dist: all + $(MKDIR) $(bundle_name) + $(MKDIR) $(bundle_name)/saves + $(STRIP) $(EXECUTABLE) -o $(bundle_name)/scummvm.elf + $(CP) $(DIST_FILES_THEMES) $(bundle_name)/ +ifdef DIST_FILES_ENGINEDATA + $(CP) $(DIST_FILES_ENGINEDATA) $(bundle_name)/ +endif + $(CP) $(DIST_FILES_DOCS) $(bundle_name)/ +ifdef DYNAMIC_MODULES + $(MKDIR) $(bundle_name)/plugins + $(CP) $(PLUGINS) $(bundle_name)/plugins + $(STRIP) $(bundle_name)/plugins/* +endif + $(CP) $(srcdir)/backends/vkeybd/packs/vkeybd_default.zip $(bundle_name)/ + $(CP) $(srcdir)/backends/platform/dingux/scummvm.gpe $(bundle_name)/ + $(CP) $(srcdir)/backends/platform/dingux/README.DINGUX $(bundle_name)/ diff --git a/backends/platform/dingux/main.cpp b/backends/platform/dingux/main.cpp new file mode 100644 index 0000000000..7b02151c1a --- /dev/null +++ b/backends/platform/dingux/main.cpp @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "backends/platform/dingux/dingux.h" +#include "backends/plugins/sdl/sdl-provider.h" +//#include "backends/plugins/posix/posix-provider.h" +#include "base/main.h" + +#if defined(DINGUX) + +#include <unistd.h> + +int main(int argc, char* argv[]) { + + g_system = new OSystem_SDL_Dingux(); + assert(g_system); + +#ifdef DYNAMIC_MODULES + PluginManager::instance().addPluginProvider(new SDLPluginProvider()); +// PluginManager::instance().addPluginProvider(new POSIXPluginProvider()); +#endif + + // Invoke the actual ScummVM main entry point: + int res = scummvm_main(argc, argv); + ((OSystem_SDL *)g_system)->deinit(); + return res; + +} + +#endif + diff --git a/backends/platform/dingux/module.mk b/backends/platform/dingux/module.mk new file mode 100644 index 0000000000..309fb94442 --- /dev/null +++ b/backends/platform/dingux/module.mk @@ -0,0 +1,13 @@ +MODULE := backends/platform/dingux + +MODULE_OBJS := \ + main.o \ + dingux.o \ + dingux-events.o \ + dingux-graphics.o \ + +MODULE_DIRS += \ + backends/platform/dingux/ + +# We don't use the rules.mk here on purpose +OBJS := $(addprefix $(MODULE)/, $(MODULE_OBJS)) $(OBJS) diff --git a/backends/platform/dingux/scummvm.gpe b/backends/platform/dingux/scummvm.gpe new file mode 100644 index 0000000000..84ab0c6b95 --- /dev/null +++ b/backends/platform/dingux/scummvm.gpe @@ -0,0 +1,5 @@ +#!/bin/sh + +HOME=`pwd` +$HOME/scummvm.elf + |