aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/ds/arm9/source
diff options
context:
space:
mode:
authorMax Horn2008-09-15 22:43:20 +0000
committerMax Horn2008-09-15 22:43:20 +0000
commit05d78c26b442bccc1d1e773591900ad0d2087278 (patch)
tree8c44d59eef4897d8409ab216a5e9760ab4160038 /backends/platform/ds/arm9/source
parent880bc085b160c642e360332546fe90f47a5ea852 (diff)
downloadscummvm-rg350-05d78c26b442bccc1d1e773591900ad0d2087278.tar.gz
scummvm-rg350-05d78c26b442bccc1d1e773591900ad0d2087278.tar.bz2
scummvm-rg350-05d78c26b442bccc1d1e773591900ad0d2087278.zip
DS: Backported 0.12 changes to trunk
svn-id: r34568
Diffstat (limited to 'backends/platform/ds/arm9/source')
-rw-r--r--backends/platform/ds/arm9/source/cdaudio.h2
-rw-r--r--backends/platform/ds/arm9/source/dsmain.cpp706
-rw-r--r--backends/platform/ds/arm9/source/dsmain.h13
-rw-r--r--backends/platform/ds/arm9/source/dsoptions.cpp283
-rw-r--r--backends/platform/ds/arm9/source/dsoptions.h13
-rw-r--r--backends/platform/ds/arm9/source/gbampsave.cpp4
-rw-r--r--backends/platform/ds/arm9/source/osystem_ds.cpp232
-rw-r--r--backends/platform/ds/arm9/source/osystem_ds.h26
-rw-r--r--backends/platform/ds/arm9/source/portdefs.h5
-rw-r--r--backends/platform/ds/arm9/source/ramsave.cpp10
-rw-r--r--backends/platform/ds/arm9/source/ramsave.h4
-rw-r--r--backends/platform/ds/arm9/source/touchkeyboard.cpp30
-rw-r--r--backends/platform/ds/arm9/source/touchkeyboard.h1
13 files changed, 1040 insertions, 289 deletions
diff --git a/backends/platform/ds/arm9/source/cdaudio.h b/backends/platform/ds/arm9/source/cdaudio.h
index d237569bb7..d1897d3e5d 100644
--- a/backends/platform/ds/arm9/source/cdaudio.h
+++ b/backends/platform/ds/arm9/source/cdaudio.h
@@ -20,7 +20,7 @@
*
*/
- #ifndef _CDAUDIO_H_
+#ifndef _CDAUDIO_H_
#define _CDAUDIO_H_
namespace DS {
diff --git a/backends/platform/ds/arm9/source/dsmain.cpp b/backends/platform/ds/arm9/source/dsmain.cpp
index ce22ac8e71..872a196e9b 100644
--- a/backends/platform/ds/arm9/source/dsmain.cpp
+++ b/backends/platform/ds/arm9/source/dsmain.cpp
@@ -66,6 +66,7 @@
#include <nds.h>
#include <nds/registers_alt.h>
+#include <nds/arm9/exceptions.h>
//#include <ARM9/console.h> //basic print funcionality
@@ -76,7 +77,6 @@
#include "icons_raw.h"
#include "fat/gba_nds_fat.h"
#include "fat/disc_io.h"
-//#include "common/config-manager.h"
#include "keyboard_raw.h"
#include "keyboard_pal_raw.h"
#define V16(a, b) ((a << 12) | b)
@@ -95,6 +95,26 @@
#endif
#include "backends/fs/ds/ds-fs.h"
+extern "C" u32 getExceptionAddress( u32 opcodeAddress, u32 thumbState);
+extern const char __itcm_start[];
+static const char *registerNames[] =
+ { "r0","r1","r2","r3","r4","r5","r6","r7",
+ "r8 ","r9 ","r10","r11","r12","sp ","lr ","pc " };
+
+/*
+extern "C" void* __real_malloc(size_t size);
+
+extern "C" void* __wrap_malloc(size_t size) {
+ void* res = __real_malloc(size);
+ if (res) {
+ return res;
+ } else {
+ consolePrintf("Failed alloc %d\n", size);
+ return NULL;
+ }
+}
+*/
+
namespace DS {
// From console.c in NDSLib
@@ -167,7 +187,7 @@ bool displayModeIs8Bit = false;
u8 gameID;
bool snapToBorder = false;
-bool consoleEnable = true;
+bool consoleEnable = false;
bool gameScreenSwap = false;
bool isCpuScalerEnabled();
//#define HEAVY_LOGGING
@@ -196,6 +216,13 @@ int mouseHotspotX, mouseHotspotY;
bool cursorEnable = false;
bool mouseCursorVisible = true;
bool rightButtonDown = false;
+bool touchPadStyle = false;
+int touchPadSensitivity = 8;
+bool tapScreenClicks = true;
+
+int tapCount = 0;
+int tapTimeout = 0;
+int tapComplete = 0;
// Dragging
int dragStartX, dragStartY;
@@ -212,7 +239,14 @@ int gameHeight = 200;
// Scale
bool twoHundredPercentFixedScale = false;
bool cpuScalerEnable = false;
-#define NUM_SUPPORTED_GAMES 20
+
+ // 100 256
+ // 150 192
+ // 200 128
+
+ // (256 << 8) / scale
+
+
#ifdef USE_PROFILER
int hBlankCount = 0;
@@ -220,6 +254,7 @@ int hBlankCount = 0;
u8* scalerBackBuffer = NULL;
+#define NUM_SUPPORTED_GAMES 21
gameListType gameList[NUM_SUPPORTED_GAMES] = {
// Unknown game - use normal SCUMM controls
@@ -247,6 +282,7 @@ gameListType gameList[NUM_SUPPORTED_GAMES] = {
{"elvira2", CONT_SIMON},
{"elvira1", CONT_SIMON},
{"waxworks", CONT_SIMON},
+ {"parallaction", CONT_NIPPON},
};
gameListType* currentGame = NULL;
@@ -259,6 +295,7 @@ bool penHeld;
bool penReleased;
bool penDownLastFrame;
s32 penX, penY;
+s32 penDownX, penDownY;
int keysDownSaved;
int keysReleasedSaved;
int keysChangedSaved;
@@ -298,9 +335,41 @@ void setCpuScalerEnable(bool enable) {
cpuScalerEnable = enable;
}
+void setTrackPadStyleEnable(bool enable) {
+ touchPadStyle = enable;
+}
+
+void setTapScreenClicksEnable(bool enable) {
+ tapScreenClicks = enable;
+}
+
+void setGameScreenSwap(bool enable) {
+ gameScreenSwap = enable;
+}
+
+void setSensitivity(int sensitivity) {
+ touchPadSensitivity = sensitivity;
+}
+
+void setTopScreenZoom(int percentage) {
+ // 100 256
+ // 150 192
+ // 200 128
+
+ // (256 << 8) / scale
+
+ s32 scale = (percentage << 8) / 100;
+ subScreenScale = (256 * 256) / scale;
+
+// consolePrintf("Scale is %d %%\n", percentage);
+}
// return (ConfMan.hasKey("cpu_scaler", "ds") && ConfMan.getBool("cpu_scaler", "ds"));
+controlType getControlType() {
+ return currentGame->control;
+}
+
//plays an 8 bit mono sample at 11025Hz
void playSound(const void* data, u32 length, bool loop, bool adpcm, int rate)
@@ -428,14 +497,14 @@ void initGame() {
consolePrintf("initing game...");
#endif
- static bool firstTime = true;
+// static bool firstTime = true;
setOptions();
//strcpy(gameName, ConfMan.getActiveDomain().c_str());
strcpy(gameName, ConfMan.get("gameid").c_str());
- consolePrintf("\n\n\n\nCurrent game: '%s' %d\n", gameName, gameName[0]);
+// consolePrintf("\n\n\n\nCurrent game: '%s' %d\n", gameName, gameName[0]);
currentGame = &gameList[0]; // Default game
@@ -446,16 +515,12 @@ void initGame() {
}
}
- if (firstTime) {
+/* if (firstTime) {
firstTime = false;
- if (ConfMan.hasKey("22khzaudio", "ds") && ConfMan.getBool("22khzaudio", "ds")) {
- startSound(22050, 8192);
- } else {
- startSound(11025, 4096);
- }
}
+*/
#ifdef HEAVY_LOGGING
consolePrintf("done\n");
#endif
@@ -630,7 +695,7 @@ void checkSleepMode() {
void setShowCursor(bool enable)
{
- if (currentGame->control == CONT_SCUMM_SAMNMAX)
+ if ((currentGame) && (currentGame->control == CONT_SCUMM_SAMNMAX))
{
if (cursorEnable) {
sprites[1].attribute[0] = ATTR0_BMP | 150;
@@ -653,23 +718,28 @@ void setCursorIcon(const u8* icon, uint w, uint h, byte keycolor, int hotspotX,
mouseHotspotX = hotspotX;
mouseHotspotY = hotspotY;
+ //consolePrintf("Set cursor icon %d, %d\n", w, h);
+
{
int off = 128*64;
memset(SPRITE_GFX + off, 0, 32 * 32 * 2);
memset(SPRITE_GFX_SUB + off, 0, 32 * 32 * 2);
+
for (uint y=0; y<h; y++) {
for (uint x=0; x<w; x++) {
int color = icon[y*w+x];
+
+ //consolePrintf("%d:%d ", color, OSystem_DS::instance()->getDSPaletteEntry(color));
if (color == keycolor) {
SPRITE_GFX[off+(y)*32+x] = 0x0000; // black background
SPRITE_GFX_SUB[off+(y)*32+x] = 0x0000; // black background
} else {
- SPRITE_GFX[off+(y)*32+x] = BG_PALETTE[color] | 0x8000;
- SPRITE_GFX_SUB[off+(y)*32+x] = BG_PALETTE[color] | 0x8000;
+ SPRITE_GFX[off+(y)*32+x] = OSystem_DS::instance()->getDSCursorPaletteEntry(color) | 0x8000;
+ SPRITE_GFX_SUB[off+(y)*32+x] = OSystem_DS::instance()->getDSCursorPaletteEntry(color) | 0x8000;
}
}
}
@@ -732,6 +802,7 @@ void setCursorIcon(const u8* icon, uint w, uint h, byte keycolor, int hotspotX,
sprites[1].attribute[1] = ATTR1_SIZE_64 | pos;
sprites[1].attribute[2] = ATTR2_ALPHA(1) | 176;
}
+
}
@@ -744,6 +815,7 @@ void displayMode16Bit() {
u16 buffer[32 * 32 * 2];
+ releaseAllKeys();
if (displayModeIs8Bit) {
// static int test = 0;
@@ -1108,7 +1180,7 @@ void setKeyboardEnable(bool en) {
} else {
-
+ DS::releaseAllKeys();
// Restore the palette that the keyboard has used
for (int r = 0; r < 256; r++) {
BG_PALETTE_SUB[r] = BG_PALETTE[r];
@@ -1156,6 +1228,194 @@ bool getIsDisplayMode8Bit() {
return displayModeIs8Bit;
}
+void doScreenTapMode(OSystem_DS* system)
+{
+ Common::Event event;
+ static bool left = false, right = false;
+
+ if (left) {
+ event.type = Common::EVENT_LBUTTONUP;
+ event.mouse = Common::Point(getPenX(), getPenY());
+ system->addEvent(event);
+ left = false;
+ }
+
+ if (right) {
+ event.type = Common::EVENT_RBUTTONUP;
+ event.mouse = Common::Point(getPenX(), getPenY());
+ system->addEvent(event);
+ right = false;
+ }
+
+
+ if (tapComplete == 1) {
+ event.type = Common::EVENT_LBUTTONDOWN;
+ event.mouse = Common::Point(getPenX(), getPenY());
+ system->addEvent(event);
+ tapComplete = 0;
+ left = true;
+ } else if (tapComplete == 2) {
+ event.type = Common::EVENT_RBUTTONDOWN;
+ event.mouse = Common::Point(getPenX(), getPenY());
+ system->addEvent(event);
+ tapComplete = 0;
+ right = true;
+ }
+
+
+ if (getKeysDown() & KEY_LEFT) {
+ event.type = Common::EVENT_LBUTTONDOWN;
+ event.mouse = Common::Point(getPenX(), getPenY());
+ system->addEvent(event);
+ }
+
+ if (getKeysReleased() & KEY_LEFT) {
+ event.type = Common::EVENT_LBUTTONUP;
+ event.mouse = Common::Point(getPenX(), getPenY());
+ system->addEvent(event);
+ }
+
+
+ if (getKeysDown() & KEY_RIGHT) {
+ event.type = Common::EVENT_RBUTTONDOWN;
+ event.mouse = Common::Point(getPenX(), getPenY());
+ system->addEvent(event);
+ }
+
+ if (getKeysReleased() & KEY_RIGHT) {
+ event.type = Common::EVENT_RBUTTONUP;
+ event.mouse = Common::Point(getPenX(), getPenY());
+ system->addEvent(event);
+ }
+
+ event.type = Common::EVENT_MOUSEMOVE;
+ event.mouse = Common::Point(getPenX(), getPenY());
+ system->addEvent(event);
+}
+
+void doButtonSelectMode(OSystem_DS* system)
+{
+ Common::Event event;
+
+
+ if ((!(getKeysHeld() & KEY_L)) && (!(getKeysHeld() & KEY_R))) {
+ event.type = Common::EVENT_MOUSEMOVE;
+ event.mouse = Common::Point(getPenX(), getPenY());
+ system->addEvent(event);
+ //consolePrintf("x=%d y=%d \n", getPenX(), getPenY());
+ }
+
+ static bool leftButtonDown = false;
+ static bool rightButtonDown = false;
+
+ if (getPenReleased() && (leftButtonDown || rightButtonDown)) {
+ if (leftButtonDown) {
+ event.type = Common::EVENT_LBUTTONUP;
+ } else {
+ event.type = Common::EVENT_RBUTTONUP;
+ }
+
+ event.mouse = Common::Point(getPenX(), getPenY());
+ system->addEvent(event);
+ }
+
+
+ if ((mouseMode != MOUSE_HOVER) || (!displayModeIs8Bit)) {
+ if (getPenDown() && (!(getKeysHeld() & KEY_L)) && (!(getKeysHeld() & KEY_R))) {
+ if ((mouseMode == MOUSE_LEFT) || (!displayModeIs8Bit)) {
+ event.type = Common::EVENT_LBUTTONDOWN;
+ leftButtonDown = true;
+ } else {
+ event.type = Common::EVENT_RBUTTONDOWN;
+ rightButtonDown = true;
+ }
+
+ event.mouse = Common::Point(getPenX(), getPenY());
+ system->addEvent(event);
+ }
+
+ } else {
+ // In hover mode, D-pad left and right click the mouse when the pen is on the screen
+
+ if (getPenHeld()) {
+ if (getKeysDown() & KEY_LEFT) {
+ event.type = Common::EVENT_LBUTTONDOWN;
+ event.mouse = Common::Point(getPenX(), getPenY());
+ system->addEvent(event);
+ }
+ if (getKeysReleased() & KEY_LEFT) {
+ event.type = Common::EVENT_LBUTTONUP;
+ event.mouse = Common::Point(getPenX(), getPenY());
+ system->addEvent(event);
+ }
+
+
+ if (getKeysDown() & KEY_RIGHT) {
+ event.type = Common::EVENT_RBUTTONDOWN;
+ event.mouse = Common::Point(getPenX(), getPenY());
+ system->addEvent(event);
+ }
+ if (getKeysReleased() & KEY_RIGHT) {
+ event.type = Common::EVENT_RBUTTONUP;
+ event.mouse = Common::Point(getPenX(), getPenY());
+ system->addEvent(event);
+ }
+ }
+ }
+
+ if (!((getKeysHeld() & KEY_L) || (getKeysHeld() & KEY_R)) && (!getIndyFightState()) && (!getKeyboardEnable())) {
+
+ if (!getPenHeld() || (mouseMode != MOUSE_HOVER)) {
+ if (getKeysDown() & KEY_LEFT) {
+ mouseMode = MOUSE_LEFT;
+ }
+
+ if (rightButtonDown)
+ {
+ Common::Event event;
+ event.mouse = Common::Point(getPenX(), getPenY());
+ event.type = Common::EVENT_RBUTTONUP;
+ system->addEvent(event);
+ rightButtonDown = false;
+ }
+
+
+ if (getKeysDown() & KEY_RIGHT) {
+ if ((currentGame->control != CONT_SCUMM_SAMNMAX) && (currentGame->control != CONT_FUTURE_WARS) && (currentGame->control != CONT_GOBLINS)) {
+ mouseMode = MOUSE_RIGHT;
+ } else {
+ // If we're playing sam and max, click and release the right mouse
+ // button to change verb
+ Common::Event event;
+
+ if (currentGame->control == CONT_FUTURE_WARS) {
+ event.mouse = Common::Point(320 - 128, 200 - 128);
+ event.type = Common::EVENT_MOUSEMOVE;
+ system->addEvent(event);
+ } else {
+ event.mouse = Common::Point(getPenX(), getPenY());
+ }
+
+ rightButtonDown = true;
+
+
+ event.type = Common::EVENT_RBUTTONDOWN;
+ system->addEvent(event);
+
+ //event.type = Common::EVENT_RBUTTONUP;
+ //system->addEvent(event);
+ }
+ }
+
+
+
+ if (getKeysDown() & KEY_UP) {
+ mouseMode = MOUSE_HOVER;
+ }
+ }
+ }
+}
+
void addEventsToQueue() {
#ifdef HEAVY_LOGGING
consolePrintf("addEventsToQueue\n");
@@ -1285,54 +1545,6 @@ void addEventsToQueue() {
}
- if (!getPenHeld() || (mouseMode != MOUSE_HOVER)) {
- if (getKeysDown() & KEY_LEFT) {
- mouseMode = MOUSE_LEFT;
- }
-
- if (rightButtonDown)
- {
- Common::Event event;
- event.mouse = Common::Point(getPenX(), getPenY());
- event.type = Common::EVENT_RBUTTONUP;
- system->addEvent(event);
- rightButtonDown = false;
- }
-
-
- if (getKeysDown() & KEY_RIGHT) {
- if ((currentGame->control != CONT_SCUMM_SAMNMAX) && (currentGame->control != CONT_FUTURE_WARS) && (currentGame->control != CONT_GOBLINS)) {
- mouseMode = MOUSE_RIGHT;
- } else {
- // If we're playing sam and max, click and release the right mouse
- // button to change verb
- Common::Event event;
-
- if (currentGame->control == CONT_FUTURE_WARS) {
- event.mouse = Common::Point(320 - 128, 200 - 128);
- event.type = Common::EVENT_MOUSEMOVE;
- system->addEvent(event);
- } else {
- event.mouse = Common::Point(getPenX(), getPenY());
- }
-
- rightButtonDown = true;
-
-
- event.type = Common::EVENT_RBUTTONDOWN;
- system->addEvent(event);
-
- //event.type = Common::EVENT_RBUTTONUP;
- //system->addEvent(event);
- }
- }
-
-
-
- if (getKeysDown() & KEY_UP) {
- mouseMode = MOUSE_HOVER;
- }
- }
@@ -1358,52 +1570,13 @@ void addEventsToQueue() {
if (!keyboardEnable) {
- if ((!(getKeysHeld() & KEY_L)) && (!(getKeysHeld() & KEY_R))) {
- event.type = Common::EVENT_MOUSEMOVE;
- event.mouse = Common::Point(getPenX(), getPenY());
- system->addEvent(event);
- //consolePrintf("x=%d y=%d \n", getPenX(), getPenY());
+ if ((tapScreenClicks) && (getIsDisplayMode8Bit()))
+ {
+ doScreenTapMode(system);
}
-
- if ((mouseMode != MOUSE_HOVER) || (!displayModeIs8Bit)) {
- if (getPenDown() && (!(getKeysHeld() & KEY_L)) && (!(getKeysHeld() & KEY_R))) {
- event.type = ((mouseMode == MOUSE_LEFT) || (!displayModeIs8Bit))? Common::EVENT_LBUTTONDOWN: Common::EVENT_RBUTTONDOWN;
- event.mouse = Common::Point(getPenX(), getPenY());
- system->addEvent(event);
- }
-
- if (getPenReleased()) {
- event.type = mouseMode == MOUSE_LEFT? Common::EVENT_LBUTTONUP: Common::EVENT_RBUTTONUP;
- event.mouse = Common::Point(getPenX(), getPenY());
- system->addEvent(event);
- }
- } else {
- // In hover mode, D-pad left and right click the mouse when the pen is on the screen
-
- if (getPenHeld()) {
- if (getKeysDown() & KEY_LEFT) {
- event.type = Common::EVENT_LBUTTONDOWN;
- event.mouse = Common::Point(getPenX(), getPenY());
- system->addEvent(event);
- }
- if (getKeysReleased() & KEY_LEFT) {
- event.type = Common::EVENT_LBUTTONUP;
- event.mouse = Common::Point(getPenX(), getPenY());
- system->addEvent(event);
- }
-
-
- if (getKeysDown() & KEY_RIGHT) {
- event.type = Common::EVENT_RBUTTONDOWN;
- event.mouse = Common::Point(getPenX(), getPenY());
- system->addEvent(event);
- }
- if (getKeysReleased() & KEY_RIGHT) {
- event.type = Common::EVENT_RBUTTONUP;
- event.mouse = Common::Point(getPenX(), getPenY());
- system->addEvent(event);
- }
- }
+ else
+ {
+ doButtonSelectMode(system);
}
if (((!(getKeysHeld() & KEY_L)) && (!(getKeysHeld() & KEY_R)) || (indyFightState)) && (displayModeIs8Bit)) {
@@ -1536,8 +1709,8 @@ void triggerIcon(int imageNum) {
void setIcon(int num, int x, int y, int imageNum, int flags, bool enable) {
- sprites[num].attribute[0] = ATTR0_BMP | (enable? y: 192) | (!enable? ATTR0_DISABLED: 0);
- sprites[num].attribute[1] = ATTR1_SIZE_32 | x | flags;
+ sprites[num].attribute[0] = ATTR0_BMP | (enable? (y & 0xFF): 192) | (!enable? ATTR0_DISABLED: 0);
+ sprites[num].attribute[1] = ATTR1_SIZE_32 | (x & 0x1FF) | flags;
sprites[num].attribute[2] = ATTR2_ALPHA(1)| (imageNum * 16);
}
@@ -1551,28 +1724,30 @@ void updateStatus() {
int offs;
if (displayModeIs8Bit) {
- switch (mouseMode) {
- case MOUSE_LEFT: {
- offs = 1;
- break;
- }
- case MOUSE_RIGHT: {
- offs = 2;
- break;
- }
- case MOUSE_HOVER: {
- offs = 0;
- break;
- }
- default: {
- // Nothing!
- offs = 0;
- break;
+ if (!tapScreenClicks) {
+ switch (mouseMode) {
+ case MOUSE_LEFT: {
+ offs = 1;
+ break;
+ }
+ case MOUSE_RIGHT: {
+ offs = 2;
+ break;
+ }
+ case MOUSE_HOVER: {
+ offs = 0;
+ break;
+ }
+ default: {
+ // Nothing!
+ offs = 0;
+ break;
+ }
}
+
+ setIcon(0, 208, 150, offs, 0, true);
}
- setIcon(0, 208, 150, offs, 0, true);
-
if (indyFightState) {
setIcon(1, (190 - 32), 150, 3, (indyFightRight? 0: ATTR1_FLIP_X), true);
// consolePrintf("%d\n", indyFightRight);
@@ -1630,7 +1805,7 @@ void setMainScreenScroll(int x, int y) {
BG3_CX = x + (((frameCount & 1) == 0)? 64: 0);
BG3_CY = y;
- if (!gameScreenSwap) {
+ if ((!gameScreenSwap) || (touchPadStyle)) {
touchX = x >> 8;
touchY = y >> 8;
}
@@ -1659,7 +1834,7 @@ void setMainScreenScale(int x, int y) {
BG3_YDY = y;
}
- if (!gameScreenSwap) {
+ if ((!gameScreenSwap) || (touchPadStyle)) {
touchScX = x;
touchScY = y;
}
@@ -1675,7 +1850,7 @@ void setZoomedScreenScroll(int x, int y, bool shake) {
touchY = y >> 8;
} else */{
- if (gameScreenSwap) {
+ if ((gameScreenSwap) && (!touchPadStyle)) {
touchX = x >> 8;
touchY = y >> 8;
}
@@ -1695,7 +1870,7 @@ void setZoomedScreenScale(int x, int y) {
} else */{
- if (gameScreenSwap) {
+ if ((gameScreenSwap) && (!touchPadStyle)) {
touchScX = x;
touchScY = y;
}
@@ -1756,18 +1931,22 @@ void VBlankHandler(void) {
frameCount++;
- if ((cursorEnable) && (mouseCursorVisible))
- {
+ if ((cursorEnable) && (mouseCursorVisible)) {
if (!keyboardEnable) {
storedMouseX = penX;
storedMouseY = penY;
}
- setIconMain(3, storedMouseX - mouseHotspotX, storedMouseY - mouseHotspotY, 8, 0, true);
- }
- else
- {
+ if (gameScreenSwap) {
+ setIcon(3, storedMouseX - mouseHotspotX, storedMouseY - mouseHotspotY, 8, 0, true);
+ setIconMain(3, 0, 0, 0, 0, false);
+ } else {
+ setIconMain(3, storedMouseX - mouseHotspotX, storedMouseY - mouseHotspotY, 8, 0, true);
+ setIcon(3, 0, 0, 0, 0, false);
+ }
+ } else {
setIconMain(3, 0, 0, 0, 0, false);
+ setIcon(3, 0, 0, 0, 0, false);
}
@@ -1825,7 +2004,7 @@ void VBlankHandler(void) {
SUB_BG3_YDX = 0;
SUB_BG3_YDY = (int) (subScreenHeight / 192.0f * 256);*/
- static int ratio = ( 320 << 8) / SCUMM_GAME_WIDTH;
+ static int ratio = (320 << 8) / SCUMM_GAME_WIDTH;
bool zooming = false;
@@ -1850,8 +2029,12 @@ void VBlankHandler(void) {
subScreenWidth = 256 >> 1;
subScreenHeight = 192 >> 1;
} else {
- subScreenWidth = (((SCUMM_GAME_HEIGHT * 256) / 192) * subScreenScale) >> 8;
- subScreenHeight = SCUMM_GAME_HEIGHT * subScreenScale >> 8;
+// subScreenWidth = (((SCUMM_GAME_HEIGHT * 256) / 192) * subScreenScale) >> 8;
+// subScreenHeight = SCUMM_GAME_HEIGHT * subScreenScale >> 8;
+
+
+ subScreenWidth = (256 * subScreenScale) >> 8;
+ subScreenHeight = (192 * subScreenScale) >> 8;
if ( ((subScreenWidth) > 256 - 8) && ((subScreenWidth) < 256 + 8) ) {
subScreenWidth = 256;
@@ -2214,43 +2397,141 @@ void penUpdate() {
// if (getKeysHeld() & KEY_L) consolePrintf("%d, %d penX=%d, penY=%d tz=%d\n", IPC->touchXpx, IPC->touchYpx, penX, penY, IPC->touchZ1);
- if ((penDownFrames > 1)) { // Is this right? Dunno, but it works for me.
+ bool penDownThisFrame = (IPC->touchZ1 > 0) && (IPC->touchXpx > 0) && (IPC->touchYpx > 0);
+ bool firstFrame = penDownFrames == 2;
+ static bool moved = false;
- if ((penHeld)) {
- penHeld = true;
- penDown = false;
+ if ((tapScreenClicks) && (!getKeyboardEnable()) && (getIsDisplayMode8Bit())) {
- if ((IPC->touchZ1 > 0) && (IPC->touchXpx > 0) && (IPC->touchYpx > 0)) {
- penX = IPC->touchXpx + touchXOffset;
- penY = IPC->touchYpx + touchYOffset;
+ if ((tapTimeout >= 0)) {
+ tapTimeout++;
+
+ if (((tapTimeout > 15) || (tapCount == 2)) && (tapCount > 0)) {
+ tapComplete = tapCount;
+ tapCount = 0;
+// consolePrintf("Taps: %d\n", tapComplete);
}
+ }
- } else {
- penDown = true;
- penHeld = true;
- penDownSaved = true;
+
- //if ( (ABS(penX - IPC->touchXpx) < 10) && (ABS(penY - IPC->touchYpx) < 10) ) {
- if ((IPC->touchZ1 > 0) && (IPC->touchXpx > 0) && (IPC->touchYpx > 0)) {
- penX = IPC->touchXpx;
- penY = IPC->touchYpx;
+ if ((penHeld) && (!penDownThisFrame)) {
+ if ((touchPadStyle) || (moved) || (tapCount == 1)) {
+ if ((penDownFrames > 0) && (penDownFrames < 6) && ((tapTimeout == -1) || (tapTimeout > 2))) {
+ tapCount++;
+ tapTimeout = 0;
+// consolePrintf("Tap! %d\n", penDownFrames);
+ moved = false;
+ }
}
- //}
}
+ }
- } else {
- if (penHeld) {
- penReleased = true;
- penReleasedSaved = true;
+
+
+ if ((touchPadStyle) && (getIsDisplayMode8Bit())) {
+
+ if ((penDownFrames > 0)) {
+
+
+ if ((penHeld)) {
+
+ if (penDownThisFrame)
+ {
+ if (penDownFrames >= 2) {
+ int diffX = IPC->touchXpx - penDownX;
+ int diffY = IPC->touchYpx - penDownY;
+
+ int speed = ABS(diffX) + ABS(diffY);
+
+ if ((ABS(diffX) < 35) && (ABS(diffY) < 35))
+ {
+
+ if (speed >= 8)
+ {
+ diffX *= ((speed >> 3) * touchPadSensitivity) >> 3;
+ diffY *= ((speed >> 3) * touchPadSensitivity) >> 3;
+ }
+
+ penX += diffX;
+ penY += diffY;
+ if (penX > 255) penX = 255;
+ if (penX < 0) penX = 0;
+ if (penY > 191) penY = 191;
+ if (penY < 0) penY = 0;
+ }
+
+// consolePrintf("x: %d y: %d\n", IPC->touchYpx - penDownY, IPC->touchYpx - penDownY);
+ penDownX = IPC->touchXpx;
+ penDownY = IPC->touchYpx;
+
+ }
+ }
+ else
+ {
+ }
+
+
+ } else {
+ penDown = true;
+ penHeld = true;
+ penDownSaved = true;
+
+ // First frame, so save pen positions
+ if (penDownThisFrame) {
+ penDownX = IPC->touchXpx;
+ penDownY = IPC->touchYpx;
+ }
+ }
+
} else {
- penReleased = false;
+ if (penHeld) {
+ penReleased = true;
+ penReleasedSaved = true;
+ } else {
+ penReleased = false;
+ }
+
+ penDown = false;
+ penHeld = false;
}
+ } else {
+ if ((penDownFrames > 1)) { // Is this right? Dunno, but it works for me.
+
+ if ((penHeld)) {
+ penHeld = true;
+ penDown = false;
+ } else {
+ penDown = true;
+ penHeld = true;
+ penDownSaved = true;
+ }
+
+ if ((IPC->touchZ1 > 0) && (IPC->touchXpx > 0) && (IPC->touchYpx > 0)) {
+ penX = IPC->touchXpx + touchXOffset;
+ penY = IPC->touchYpx + touchYOffset;
+ moved = true;
+ }
+
- penDown = false;
- penHeld = false;
+
+ } else {
+ if (penHeld) {
+ penReleased = true;
+ penReleasedSaved = true;
+ } else {
+ penReleased = false;
+ }
+
+ penDown = false;
+ penHeld = false;
+ }
+
+
}
+
if ((IPC->touchZ1 > 0) || ((penDownFrames == 2)) ) {
penDownLastFrame = true;
penDownFrames++;
@@ -2258,7 +2539,6 @@ void penUpdate() {
penDownLastFrame = false;
penDownFrames = 0;
}
-
}
int leftHandedSwap(int keys) {
@@ -2345,8 +2625,7 @@ int getPenX() {
int x = ((penX * touchScX) >> 8) + touchX;
x = x < 0? 0: (x > gameWidth - 1? gameWidth - 1: x);
- if (snapToBorder)
- {
+ if (snapToBorder) {
if (x < 8) x = 0;
if (x > gameWidth - 8) x = gameWidth - 1;
}
@@ -2358,8 +2637,7 @@ int getPenY() {
int y = ((penY * touchScY) >> 8) + touchY;
y = y < 0? 0: (y > gameHeight - 1? gameHeight - 1: y);
- if (snapToBorder)
- {
+ if (snapToBorder) {
if (y < 8) y = 0;
if (y > gameHeight - 8) y = gameHeight - 1;
}
@@ -2376,6 +2654,8 @@ GLvector getPenPos() {
return v;
}
+#ifdef GBA_SRAM_SAVE
+
void formatSramOption() {
consolePrintf("The following files are present in save RAM:\n");
DSSaveFileManager::instance()->listFiles();
@@ -2397,7 +2677,7 @@ void formatSramOption() {
}
}
}
-
+#endif
void setIndyFightState(bool st) {
indyFightState = st;
@@ -2495,8 +2775,6 @@ struct cardTranslate {
char dldiId[5];
};
-#define NUM_CARD_READERS 7
-
cardTranslate cardReaderTable[] = {
{DEVICE_TYPE_M3SD, DEVICE_M3SD, "M3SD"},
{DEVICE_TYPE_M3CF, DEVICE_M3CF, "M3CF"},
@@ -2518,13 +2796,13 @@ void reboot() {
consolePrintf("DLDI Device ID: %s\n", id);
- for (int r = 0; r < NUM_CARD_READERS; r++) {
+ for (int r = 0; r < ARRAYSIZE(cardReaderTable); r++) {
if (!stricmp(id, cardReaderTable[r].dldiId)) {
deviceType = cardReaderTable[r].cartResetId;
}
}
} else {
- for (int r = 0; r < NUM_CARD_READERS; r++) {
+ for (int r = 0; r < ARRAYSIZE(cardReaderTable); r++) {
if (disc_getDeviceId() == cardReaderTable[r].svmId) {
deviceType = cardReaderTable[r].cartResetId;
}
@@ -2572,13 +2850,66 @@ void powerOff() {
/////////////////
-int main(void)
-{
+
+void dsExceptionHandler() {
+ consolePrintf("Blue screen of death");
+ setExceptionHandler(NULL);
+
+
+ u32 currentMode = getCPSR() & 0x1f;
+ u32 thumbState = ((*(u32*)0x027FFD90) & 0x20);
+
+ u32 codeAddress, exceptionAddress = 0;
+
+ int offset = 8;
+
+ if ( currentMode == 0x17 ) {
+ consolePrintf("\x1b[10Cdata abort!\n\n");
+ codeAddress = exceptionRegisters[15] - offset;
+ if ( (codeAddress > 0x02000000 && codeAddress < 0x02400000) ||
+ (codeAddress > (u32)__itcm_start && codeAddress < (u32)(__itcm_start + 32768)) )
+ exceptionAddress = getExceptionAddress( codeAddress, thumbState);
+ else
+ exceptionAddress = codeAddress;
+
+ } else {
+ if (thumbState)
+ offset = 2;
+ else
+ offset = 4;
+ consolePrintf("\x1b[5Cundefined instruction!\n\n");
+ codeAddress = exceptionRegisters[15] - offset;
+ exceptionAddress = codeAddress;
+ }
+
+ consolePrintf(" pc: %08X addr: %08X\n\n",codeAddress,exceptionAddress);
+
+ int i;
+ for ( i=0; i < 8; i++ ) {
+ consolePrintf( " %s: %08X %s: %08X\n",
+ registerNames[i], exceptionRegisters[i],
+ registerNames[i+8],exceptionRegisters[i+8]);
+ }
+// u32 *stack = (u32 *)exceptionRegisters[13];
+// for ( i=0; i<10; i++ ) {
+// consolePrintf( "\x1b[%d;2H%08X: %08X %08X", i + 14, (u32)&stack[i*2],stack[i*2], stack[(i*2)+1] );
+// }
+
+ memoryReport();
+
+ while(1);
+}
+
+
+
+
+int main(void) {
soundCallback = NULL;
initHardware();
+ setExceptionHandler(dsExceptionHandler);
#ifdef USE_DEBUGGER
for (int r = 0; r < 150; r++) {
@@ -2662,36 +2993,33 @@ int main(void)
consolePrintf("-------------------------------\n");
consolePrintf("ScummVM DS\n");
consolePrintf("Ported by Neil Millstone\n");
- consolePrintf("Version 0.11.1 beta2");
+ consolePrintf("Version 0.13.0 SVN ");
#if defined(DS_BUILD_A)
consolePrintf("build A\n");
consolePrintf("Lucasarts SCUMM games (SCUMM)\n");
- consolePrintf("-------------------------------\n");
#elif defined(DS_BUILD_B)
consolePrintf("build B\n");
consolePrintf("BASS, QUEEN\n");
- consolePrintf("-------------------------------\n");
#elif defined(DS_BUILD_C)
consolePrintf("build C\n");
consolePrintf("Simon/Elvira/Waxworks (AGOS)\n");
- consolePrintf("-------------------------------\n");
#elif defined(DS_BUILD_D)
consolePrintf("build D\n");
consolePrintf("AGI, CINE, GOB\n");
- consolePrintf("-------------------------------\n");
#elif defined(DS_BUILD_E)
consolePrintf("build E\n");
consolePrintf("Inherit the Earth (SAGA)\n");
- consolePrintf("-------------------------------\n");
#elif defined(DS_BUILD_F)
consolePrintf("build F\n");
consolePrintf("The Legend of Kyrandia (KYRA)\n");
- consolePrintf("-------------------------------\n");
#elif defined(DS_BUILD_G)
- consolePrintf("build F\n");
- consolePrintf("Lure of the Temptress (LURE)\n");
- consolePrintf("-------------------------------\n");
+ consolePrintf("build G\n");
+ consolePrintf("Lure of the Tempress (LURE)\n");
+#elif defined(DS_BUILD_H)
+ consolePrintf("build H\n");
+ consolePrintf("Nippon Safes (PARALLATION)\n");
#endif
+ consolePrintf("-------------------------------\n");
consolePrintf("L/R + D-pad/pen: Scroll view\n");
consolePrintf("D-pad left: Left mouse button\n");
consolePrintf("D-pad right: Right mouse button\n");
@@ -2807,9 +3135,11 @@ int main(void)
g_system = new OSystem_DS();
assert(g_system);
+#ifdef GBA_SRAM_SAVE
if ((keysHeld() & KEY_L) && (keysHeld() & KEY_R)) {
formatSramOption();
}
+#endif
IPC->adpcm.semaphore = false;
@@ -2830,6 +3160,8 @@ int main(void)
const char *argv[] = {"/scummvmds", "--config=scummvmf.ini"};
#elif defined(DS_BUILD_G)
const char *argv[] = {"/scummvmds", "--config=scummvmg.ini"};
+#elif defined(DS_BUILD_H)
+ const char *argv[] = {"/scummvmds", "--config=scummvmh.ini"};
#endif
while (1) {
diff --git a/backends/platform/ds/arm9/source/dsmain.h b/backends/platform/ds/arm9/source/dsmain.h
index 43258b5c5d..ab74554917 100644
--- a/backends/platform/ds/arm9/source/dsmain.h
+++ b/backends/platform/ds/arm9/source/dsmain.h
@@ -38,7 +38,8 @@ enum controlType {
CONT_SIMON,
CONT_FUTURE_WARS,
CONT_AGI,
- CONT_GOBLINS
+ CONT_GOBLINS,
+ CONT_NIPPON,
};
struct gameListType {
@@ -56,6 +57,7 @@ int getPenX();
int getPenY();
GLvector getPenPos();
void consumePenEvents();
+controlType getControlType();
// Pad reading
int getKeysHeld();
@@ -64,6 +66,8 @@ int getKeysDown();
int getKeysReleased();
void consumeKeys();
int leftHandedSwap(int keys);
+void setGameScreenSwap(bool enable);
+void setSensitivity(int sensitivity);
// Video
void displayMode8Bit(); // Switch to 8-bit mode5
@@ -81,6 +85,7 @@ u16* getScalerBuffer();
void setTalkPos(int x, int y);
void setTopScreenTarget(int x, int y);
void set200PercentFixedScale(bool on);
+void setTopScreenZoom(int percentage);
// Timers
void setTimerCallback(OSystem_DS::TimerProc proc, int interval); // Setup a callback function at a regular interval
@@ -88,7 +93,9 @@ int getMillis(); // Return the current runtime in milliseconds
void doTimerCallback(); // Call callback function if required
// Sound
-void doSoundCallback(); // Call function if sound buffers need more data
+void doSoundCallback();
+void startSound(int freq, int buffer); // Start sound hardware
+// Call function if sound buffers need more data
void playSound(const void* data, u32 length, bool loop, bool adpcm = false, int rate = 22050); // Start a sound
void stopSound(int channel);
int getSoundFrequency();
@@ -131,6 +138,8 @@ void setIndyFightState(bool st);
bool getIndyFightState();
bool isCpuScalerEnabled();
void setCpuScalerEnable(bool enable);
+void setTrackPadStyleEnable(bool enable);
+void setTapScreenClicksEnable(bool enable);
// Display
bool getIsDisplayMode8Bit();
diff --git a/backends/platform/ds/arm9/source/dsoptions.cpp b/backends/platform/ds/arm9/source/dsoptions.cpp
index edb9c70580..2dbc4b842b 100644
--- a/backends/platform/ds/arm9/source/dsoptions.cpp
+++ b/backends/platform/ds/arm9/source/dsoptions.cpp
@@ -25,6 +25,7 @@
#include "gui/dialog.h"
#include "gui/newgui.h"
#include "gui/ListWidget.h"
+#include "gui/TabWidget.h"
#include "osystem_ds.h"
#include "engines/scumm/scumm.h"
#include "touchkeyboard.h"
@@ -41,8 +42,67 @@ namespace Scumm {
namespace DS {
-DSOptionsDialog::DSOptionsDialog() : GUI::Dialog(5, 0, 320 - 5, 230 - 20) {
- addButton(this, 10, 175, "Close", GUI::kCloseCmd, 'C');
+DSOptionsDialog::DSOptionsDialog() : GUI::Dialog(0, 0, 320 - 10, 230 - 40) {
+
+ addButton(this, 10, 170, "Close", GUI::kCloseCmd, 'C');
+ _tab = new GUI::TabWidget(this, 5, 5, 300, 230 - 20 - 40 - 10);
+
+ _tab->addTab("Controls");
+
+ _leftHandedCheckbox = new GUI::CheckboxWidget(_tab, 5, 5, 130, 20, "Left handed mode", 0, 'L');
+ _indyFightCheckbox = new GUI::CheckboxWidget(_tab, 5, 20, 140, 20, "Indy fight controls", 0, 'I');
+ _showCursorCheckbox = new GUI::CheckboxWidget(_tab, 150, 5, 130, 20, "Show mouse cursor", 0, 'T');
+ _snapToBorderCheckbox = new GUI::CheckboxWidget(_tab, 150, 20, 130, 20, "Snap to edges", 0, 'T');
+
+ new GUI::StaticTextWidget(_tab, 20, 35, 100, 15, "Touch X Offset", GUI::kTextAlignLeft);
+ _touchX = new GUI::SliderWidget(_tab, 130, 35, 130, 12, 1);
+ _touchX->setMinValue(-8);
+ _touchX->setMaxValue(+8);
+ _touchX->setValue(0);
+ _touchX->setFlags(GUI::WIDGET_CLEARBG);
+
+ new GUI::StaticTextWidget(_tab, 20, 50, 100, 15, "Touch Y Offset", GUI::kTextAlignLeft);
+ _touchY = new GUI::SliderWidget(_tab, 130, 50, 130, 12, 2);
+ _touchY->setMinValue(-8);
+ _touchY->setMaxValue(+8);
+ _touchY->setValue(0);
+ _touchY->setFlags(GUI::WIDGET_CLEARBG);
+
+ new GUI::StaticTextWidget(_tab, 130 + 65 - 10, 65, 20, 15, "0", GUI::kTextAlignCenter);
+ new GUI::StaticTextWidget(_tab, 130 + 130 - 10, 65, 20, 15, "8", GUI::kTextAlignCenter);
+ new GUI::StaticTextWidget(_tab, 130 - 20, 65, 20, 15, "-8", GUI::kTextAlignCenter);
+
+
+ _touchPadStyle = new GUI::CheckboxWidget(_tab, 5, 80, 270, 20, "Use laptop trackpad-style cursor control", 0x20000001, 'T');
+ _screenTaps = new GUI::CheckboxWidget(_tab, 5, 95, 285, 20, "Tap for left click, double tap right click", 0x20000002, 'T');
+
+ _sensitivityLabel = new GUI::StaticTextWidget(_tab, 20, 110, 110, 15, "Sensitivity", GUI::kTextAlignLeft);
+ _sensitivity = new GUI::SliderWidget(_tab, 130, 110, 130, 12, 1);
+ _sensitivity->setMinValue(4);
+ _sensitivity->setMaxValue(16);
+ _sensitivity->setValue(8);
+ _sensitivity->setFlags(GUI::WIDGET_CLEARBG);
+
+ _tab->addTab("Graphics");
+
+ new GUI::StaticTextWidget(_tab, 5, 70, 180, 15, "Initial top screen scale:", GUI::kTextAlignLeft);
+
+ _100PercentCheckbox = new GUI::CheckboxWidget(_tab, 5, 85, 230, 20, "100%", 0x30000001, 'T');
+ _150PercentCheckbox = new GUI::CheckboxWidget(_tab, 5, 100, 230, 20, "150%", 0x30000002, 'T');
+ _200PercentCheckbox = new GUI::CheckboxWidget(_tab, 5, 115, 230, 20, "200%", 0x30000003, 'T');
+
+ new GUI::StaticTextWidget(_tab, 5, 5, 180, 15, "Main screen scaling:", GUI::kTextAlignLeft);
+
+ _hardScaler = new GUI::CheckboxWidget(_tab, 5, 20, 270, 20, "Hardware scale (fast, but low quality)", 0x10000001, 'T');
+ _cpuScaler = new GUI::CheckboxWidget(_tab, 5, 35, 270, 20, "Software scale (good quality, but slower)", 0x10000002, 'S');
+ _unscaledCheckbox = new GUI::CheckboxWidget(_tab, 5, 50, 270, 20, "Unscaled (you must scroll left and right)", 0x10000003, 'S');
+
+ _tab->addTab("General");
+
+ _highQualityAudioCheckbox = new GUI::CheckboxWidget(_tab, 5, 5, 250, 20, "High quality audio (slower) (reboot)", 0, 'T');
+ _disablePowerOff = new GUI::CheckboxWidget(_tab, 5, 20, 200, 20, "Disable power off", 0, 'T');
+
+ _tab->setActiveTab(0);
_radioButtonMode = false;
@@ -52,46 +112,17 @@ DSOptionsDialog::DSOptionsDialog() : GUI::Dialog(5, 0, 320 - 5, 230 - 20) {
}
#endif
- new GUI::StaticTextWidget(this, 90, 10, 130, 15, "ScummVM DS Options", GUI::kTextAlignCenter);
+// new GUI::StaticTextWidget(this, 90, 10, 130, 15, "ScummVM DS Options", GUI::kTextAlignCenter);
- _leftHandedCheckbox = new GUI::CheckboxWidget(this, 5, 70, 130, 20, "Left handed mode", 0, 'L');
- _indyFightCheckbox = new GUI::CheckboxWidget(this, 5, 40, 200, 20, "Indy fighting controls", 0, 'I');
- _twoHundredPercentCheckbox = new GUI::CheckboxWidget(this, 5, 55, 230, 20, "Zoomed screen at fixed 200% zoom", 0, 'T');
- _highQualityAudioCheckbox = new GUI::CheckboxWidget(this, 5, 25, 250, 20, "High quality audio (slower) (reboot)", 0, 'T');
- _disablePowerOff = new GUI::CheckboxWidget(this, 5, 85, 130, 20, "Disable power off", 0, 'T');
- _showCursorCheckbox = new GUI::CheckboxWidget(this, 5, 100, 130, 20, "Show mouse cursor", 0, 'T');
//#ifdef ALLOW_CPU_SCALER
// _cpuScaler = new GUI::CheckboxWidget(this, 160, 115, 90, 20, "CPU scaler", 0, 'T');
//#endif
- new GUI::StaticTextWidget(this, 180, 70, 130, 15, "Main screen:", GUI::kTextAlignLeft);
-
- _hardScaler = new GUI::CheckboxWidget(this, 140, 85, 170, 20, "Hardware scale (fast)", 0x10000001, 'T');
- _cpuScaler = new GUI::CheckboxWidget(this, 140, 100, 170, 20, "Software scale (quality)", 0x10000002, 'S');
- _unscaledCheckbox = new GUI::CheckboxWidget(this, 140, 115, 170, 20, "Unscaled", 0x10000003, 'S');
- _snapToBorderCheckbox = new GUI::CheckboxWidget(this, 5, 115, 120, 20, "Snap to border", 0, 'T');
- new GUI::StaticTextWidget(this, 20, 145, 110, 15, "Touch X Offset", GUI::kTextAlignLeft);
- _touchX = new GUI::SliderWidget(this, 130, 145, 130, 12, 1);
- _touchX->setMinValue(-8);
- _touchX->setMaxValue(+8);
- _touchX->setValue(0);
- _touchX->setFlags(GUI::WIDGET_CLEARBG);
-
- new GUI::StaticTextWidget(this, 20, 160, 110, 15, "Touch Y Offset", GUI::kTextAlignLeft);
- _touchY = new GUI::SliderWidget(this, 130, 160, 130, 12, 2);
- _touchY->setMinValue(-8);
- _touchY->setMaxValue(+8);
- _touchY->setValue(0);
- _touchY->setFlags(GUI::WIDGET_CLEARBG);
-
- new GUI::StaticTextWidget(this, 130 + 65 - 10, 175, 20, 15, "0", GUI::kTextAlignCenter);
- new GUI::StaticTextWidget(this, 130 + 130 - 10, 175, 20, 15, "8", GUI::kTextAlignCenter);
- new GUI::StaticTextWidget(this, 130 - 10, 175, 20, 15, "-8", GUI::kTextAlignCenter);
#ifdef DS_SCUMM_BUILD
_delDialog = new Scumm::SaveLoadChooser("Delete game:", "Delete", false, Scumm::g_scumm);
@@ -125,10 +156,36 @@ DSOptionsDialog::DSOptionsDialog() : GUI::Dialog(5, 0, 320 - 5, 230 - 20) {
_unscaledCheckbox->setState(false);
}
- if (ConfMan.hasKey("twohundredpercent", "ds")) {
- _twoHundredPercentCheckbox->setState(ConfMan.getBool("twohundredpercent", "ds"));
+
+ if (ConfMan.hasKey("topscreenzoom", "ds")) {
+
+ _100PercentCheckbox->setState(false);
+ _150PercentCheckbox->setState(false);
+ _200PercentCheckbox->setState(false);
+
+ switch (ConfMan.getInt("topscreenzoom", "ds"))
+ {
+ case 100: {
+ _100PercentCheckbox->setState(true);
+ break;
+ }
+
+ case 150: {
+ _150PercentCheckbox->setState(true);
+ break;
+ }
+
+ case 200: {
+ _200PercentCheckbox->setState(true);
+ break;
+ }
+ }
+
+ } else if (ConfMan.hasKey("twohundredpercent", "ds")) {
+ _200PercentCheckbox->setState(ConfMan.getBool("twohundredpercent", "ds"));
} else {
- _twoHundredPercentCheckbox->setState(false);
+ // No setting
+ _150PercentCheckbox->setState(true);
}
if (ConfMan.hasKey("22khzaudio", "ds")) {
@@ -165,6 +222,29 @@ DSOptionsDialog::DSOptionsDialog() : GUI::Dialog(5, 0, 320 - 5, 230 - 20) {
_touchY->setValue(0);
}
+ if (ConfMan.hasKey("sensitivity", "ds")) {
+ _sensitivity->setValue(ConfMan.getInt("sensitivity", "ds"));
+ } else {
+ _sensitivity->setValue(8);
+ }
+
+ if (ConfMan.hasKey("touchpad", "ds")) {
+ _touchPadStyle->setState(ConfMan.getBool("touchpad", "ds"));
+ } else {
+ _touchPadStyle->setState(0);
+ }
+
+ if (ConfMan.hasKey("screentaps", "ds")) {
+ _screenTaps->setState(ConfMan.getBool("screentaps", "ds"));
+ } else {
+ _screenTaps->setState(0);
+ }
+
+ _screenTaps->setEnabled(!_touchPadStyle->getState());
+ _sensitivity->setEnabled(_touchPadStyle->getState());
+ _sensitivityLabel->setEnabled(_touchPadStyle->getState());
+ _sensitivityLabel->draw();
+
if (!_cpuScaler->getState() && !_unscaledCheckbox->getState()) {
_hardScaler->setState(true);
}
@@ -180,7 +260,7 @@ DSOptionsDialog::~DSOptionsDialog() {
void DSOptionsDialog::updateConfigManager() {
ConfMan.setBool("lefthanded", _leftHandedCheckbox->getState(), "ds");
ConfMan.setBool("unscaled", _unscaledCheckbox->getState(), "ds");
- ConfMan.setBool("twohundredpercent", _twoHundredPercentCheckbox->getState(), "ds");
+// ConfMan.setBool("twohundredpercent", _twoHundredPercentCheckbox->getState(), "ds");
ConfMan.setBool("22khzaudio", _highQualityAudioCheckbox->getState(), "ds");
ConfMan.setBool("disablepoweroff", _disablePowerOff->getState(), "ds");
#ifdef ALLOW_CPU_SCALER
@@ -190,6 +270,24 @@ void DSOptionsDialog::updateConfigManager() {
ConfMan.setInt("yoffset", _touchY->getValue(), "ds");
ConfMan.setBool("showcursor", _showCursorCheckbox->getState(), "ds");
ConfMan.setBool("snaptoborder", _snapToBorderCheckbox->getState(), "ds");
+ ConfMan.setBool("touchpad", _touchPadStyle->getState(), "ds");
+ ConfMan.setBool("screentaps", _screenTaps->getState(), "ds");
+ ConfMan.setInt("sensitivity", _sensitivity->getValue(), "ds");
+
+ u32 zoomLevel = 150;
+
+ if (_100PercentCheckbox->getState()) {
+ zoomLevel = 100;
+ } else if (_150PercentCheckbox->getState()) {
+ zoomLevel = 150;
+ } else if (_200PercentCheckbox->getState()) {
+ zoomLevel = 200;
+ }
+
+ consolePrintf("Saved zoom: %d\n", zoomLevel);
+
+ ConfMan.setInt("topscreenzoom", zoomLevel, "ds");
+
DS::setOptions();
}
@@ -227,6 +325,70 @@ void DSOptionsDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint
}
+ if ((!guard) && (_radioButtonMode))
+ {
+ guard = true;
+
+ if ((sender == _touchPadStyle) && (cmd == 0x20000001)) {
+
+ if (_touchPadStyle->getState()) {
+ // Swap screens when turning on trackpad style, it feels
+ // much more natural!
+ DS::setGameScreenSwap(true);
+
+ _screenTaps->setState(true);
+ _screenTaps->setEnabled(false);
+ _screenTaps->draw();
+ _sensitivity->setEnabled(true);
+ _sensitivityLabel->setEnabled(true);
+ _sensitivityLabel->draw();
+ _sensitivity->draw();
+ } else {
+ DS::setGameScreenSwap(false);
+
+ _screenTaps->setEnabled(true);
+ _screenTaps->setState(false);
+ _screenTaps->draw();
+ _sensitivity->setEnabled(false);
+ _sensitivityLabel->setEnabled(false);
+ _sensitivityLabel->draw();
+ _sensitivity->draw();
+ }
+ }
+
+ guard = false;
+ }
+
+ if ((!guard) && (_radioButtonMode)) {
+
+ guard = true;
+
+ if (cmd == 0x30000001) {
+ _100PercentCheckbox->setState(true);
+ _150PercentCheckbox->setState(false);
+ _200PercentCheckbox->setState(false);
+ DS::setTopScreenZoom(100);
+ }
+
+ if (cmd == 0x30000002) {
+ _100PercentCheckbox->setState(false);
+ _150PercentCheckbox->setState(true);
+ _200PercentCheckbox->setState(false);
+ DS::setTopScreenZoom(150);
+ }
+
+ if (cmd == 0x30000003) {
+ _100PercentCheckbox->setState(false);
+ _150PercentCheckbox->setState(false);
+ _200PercentCheckbox->setState(true);
+ DS::setTopScreenZoom(200);
+ }
+
+ guard = false;
+
+ }
+
+
if (cmd == GUI::kCloseCmd) {
updateConfigManager();
close();
@@ -297,6 +459,8 @@ void showOptionsDialog() {
}
void setOptions() {
+ static bool firstLoad = true;
+
ConfMan.addGameDomain("ds");
if (ConfMan.hasKey("lefthanded", "ds")) {
@@ -327,10 +491,16 @@ void setOptions() {
DS::setUnscaledMode(false);
}
- if (ConfMan.hasKey("twohundredpercent", "ds")) {
- DS::set200PercentFixedScale(ConfMan.getBool("twohundredpercent", "ds"));
- } else {
- DS::set200PercentFixedScale(false);
+ if (firstLoad) {
+ if (ConfMan.hasKey("topscreenzoom", "ds")) {
+ DS::setTopScreenZoom(ConfMan.getInt("topscreenzoom", "ds"));
+ } else {
+ if (ConfMan.hasKey("twohundredpercent", "ds")) {
+ DS::setTopScreenZoom(200);
+ } else {
+ DS::setTopScreenZoom(150);
+ }
+ }
}
if (ConfMan.hasKey("xoffset", "ds")) {
@@ -345,6 +515,12 @@ void setOptions() {
DS::setTouchXOffset(0);
}
+ if (ConfMan.hasKey("sensitivity", "ds")) {
+ DS::setSensitivity(ConfMan.getInt("sensitivity", "ds"));
+ } else {
+ DS::setSensitivity(8);
+ }
+
#ifdef ALLOW_CPU_SCALER
if (ConfMan.hasKey("cpu_scaler", "ds")) {
DS::setCpuScalerEnable(ConfMan.getBool("cpu_scaler", "ds"));
@@ -353,6 +529,33 @@ void setOptions() {
}
#endif
+ if (ConfMan.hasKey("screentaps", "ds")) {
+ DS::setTapScreenClicksEnable(ConfMan.getBool("screentaps", "ds"));
+ } else {
+ DS::setTapScreenClicksEnable(false);
+ }
+
+ if (ConfMan.hasKey("touchpad", "ds")) {
+ bool enable = ConfMan.getBool("touchpad", "ds");
+
+ DS::setTrackPadStyleEnable(enable);
+
+ if ((enable) and (firstLoad)) {
+ // If we've just booted up, want to swap screens when trackpad mode is in use
+ // but not every time we enter the options dialog.
+ DS::setGameScreenSwap(true);
+ }
+
+ if (enable) {
+ DS::setTapScreenClicksEnable(true);
+ }
+
+ } else {
+ DS::setTrackPadStyleEnable(false);
+ }
+
+
+ firstLoad = false;
}
}
diff --git a/backends/platform/ds/arm9/source/dsoptions.h b/backends/platform/ds/arm9/source/dsoptions.h
index 9cfa785ca8..e3ab2f55e0 100644
--- a/backends/platform/ds/arm9/source/dsoptions.h
+++ b/backends/platform/ds/arm9/source/dsoptions.h
@@ -30,6 +30,7 @@
#include "gui/object.h"
#include "gui/widget.h"
#include "gui/dialog.h"
+#include "gui/TabWidget.h"
#include "scumm/dialogs.h"
namespace DS {
@@ -45,11 +46,18 @@ protected:
void togglePause();
void updateConfigManager();
+ GUI::TabWidget* _tab;
+
+ GUI::StaticTextWidget* _sensitivityLabel;
+
GUI::SliderWidget* _touchX;
GUI::SliderWidget* _touchY;
+ GUI::SliderWidget* _sensitivity;
GUI::CheckboxWidget* _leftHandedCheckbox;
GUI::CheckboxWidget* _unscaledCheckbox;
- GUI::CheckboxWidget* _twoHundredPercentCheckbox;
+ GUI::CheckboxWidget* _100PercentCheckbox;
+ GUI::CheckboxWidget* _150PercentCheckbox;
+ GUI::CheckboxWidget* _200PercentCheckbox;
GUI::CheckboxWidget* _indyFightCheckbox;
GUI::CheckboxWidget* _highQualityAudioCheckbox;
GUI::CheckboxWidget* _disablePowerOff;
@@ -59,6 +67,9 @@ protected:
GUI::CheckboxWidget* _hardScaler;
GUI::CheckboxWidget* _cpuScaler;
+ GUI::CheckboxWidget* _touchPadStyle;
+ GUI::CheckboxWidget* _screenTaps;
+
#ifdef DS_SCUMM_BUILD
Scumm::SaveLoadChooser* _delDialog;
#endif
diff --git a/backends/platform/ds/arm9/source/gbampsave.cpp b/backends/platform/ds/arm9/source/gbampsave.cpp
index ed45d02b1e..068d996e92 100644
--- a/backends/platform/ds/arm9/source/gbampsave.cpp
+++ b/backends/platform/ds/arm9/source/gbampsave.cpp
@@ -155,11 +155,13 @@ GBAMPSaveFile* GBAMPSaveFileManager::openSavefile(char const* name, bool saveOrL
sprintf(fileSpec, "%s/%s", getSavePath(), name);
}
-// consolePrintf(fileSpec);
+// consolePrintf("Opening the file: %s\n", fileSpec);
GBAMPSaveFile* sf = new GBAMPSaveFile(fileSpec, saveOrLoad);
if (sf->isOpen()) {
+// consolePrintf("Ok");
return sf;
} else {
+// consolePrintf("Fail");
delete sf;
return NULL;
}
diff --git a/backends/platform/ds/arm9/source/osystem_ds.cpp b/backends/platform/ds/arm9/source/osystem_ds.cpp
index 79b0c5390b..5ddcb50b15 100644
--- a/backends/platform/ds/arm9/source/osystem_ds.cpp
+++ b/backends/platform/ds/arm9/source/osystem_ds.cpp
@@ -41,7 +41,8 @@
OSystem_DS* OSystem_DS::_instance = NULL;
OSystem_DS::OSystem_DS()
- : eventNum(0), lastPenFrame(0), queuePos(0), _mixer(NULL), _timer(NULL), _frameBufferExists(false)
+ : eventNum(0), lastPenFrame(0), queuePos(0), _mixer(NULL), _timer(NULL), _frameBufferExists(false),
+ _disableCursorPalette(true), _graphicsEnable(true)
{
// eventNum = 0;
// lastPenFrame = 0;
@@ -71,7 +72,13 @@ void OSystem_DS::initBackend() {
_timer = new DSTimerManager();
DS::setTimerCallback(&OSystem_DS::timerHandler, 10);
- _mixer->setOutputRate(11025 /*DS::getSoundFrequency()*/);
+ if (ConfMan.hasKey("22khzaudio", "ds") && ConfMan.getBool("22khzaudio", "ds")) {
+ DS::startSound(22050, 8192);
+ } else {
+ DS::startSound(11025, 4096);
+ }
+
+ _mixer->setOutputRate(DS::getSoundFrequency());
_mixer->setReady(true);
OSystem::initBackend();
@@ -79,7 +86,7 @@ void OSystem_DS::initBackend() {
bool OSystem_DS::hasFeature(Feature f) {
// consolePrintf("hasfeature\n");
- return (f == kFeatureVirtualKeyboard);
+ return (f == kFeatureVirtualKeyboard) || (f == kFeatureCursorHasPalette);
}
void OSystem_DS::setFeatureState(Feature f, bool enable) {
@@ -107,7 +114,7 @@ bool OSystem_DS::setGraphicsMode(int mode) {
}
bool OSystem_DS::setGraphicsMode(const char *name) {
-// consolePrintf("Set gfx mode %s\n", name);
+ consolePrintf("Set gfx mode %s\n", name);
return true;
}
@@ -116,8 +123,15 @@ int OSystem_DS::getGraphicsMode() const {
}
void OSystem_DS::initSize(uint width, uint height) {
-// consolePrintf("Set gfx mode %d x %d\n", width, height);
- DS::setGameSize(width, height);
+ // For Lost in Time, the title screen is displayed in 640x400.
+ // In order to support this game, the screen mode is set, but
+ // all draw calls are ignored until the game switches to 320x200.
+ if ((width == 640) && (height == 400)) {
+ _graphicsEnable = false;
+ } else {
+ _graphicsEnable = true;
+ DS::setGameSize(width, height);
+ }
}
int16 OSystem_DS::getHeight() {
@@ -129,9 +143,8 @@ int16 OSystem_DS::getWidth() {
}
void OSystem_DS::setPalette(const byte *colors, uint start, uint num) {
-// consolePrintf("Set palette %d, %d colours\n", start, num);
-//return;
- if (!DS::getIsDisplayMode8Bit()) return;
+// consolePrintf("Setpal %d, %d\n", start, num);
+
for (unsigned int r = start; r < start + num; r++) {
int red = *colors;
int green = *(colors + 1);
@@ -141,17 +154,44 @@ void OSystem_DS::setPalette(const byte *colors, uint start, uint num) {
green >>= 3;
blue >>= 3;
- if (r != 255)
+// if (r != 255)
{
- BG_PALETTE[r] = red | (green << 5) | (blue << 10);
- if (!DS::getKeyboardEnable()) {
- BG_PALETTE_SUB[r] = red | (green << 5) | (blue << 10);
+ u16 paletteValue = red | (green << 5) | (blue << 10);
+
+ if (DS::getIsDisplayMode8Bit()) {
+ BG_PALETTE[r] = paletteValue;
+ if (!DS::getKeyboardEnable()) {
+ BG_PALETTE_SUB[r] = paletteValue;
+ }
}
+
+ _palette[r] = paletteValue;
}
-// if (num == 16) consolePrintf("pal:%d r:%d g:%d b:%d\n", r, red, green, blue);
+ // if (num == 255) consolePrintf("pal:%d r:%d g:%d b:%d\n", r, red, green, blue);
+
+ colors += 4;
+ }
+}
+
+void OSystem_DS::setCursorPalette(const byte *colors, uint start, uint num) {
+
+// consolePrintf("Cursor palette set: start: %d, cols: %d\n", start, num);
+ for (unsigned int r = start; r < start + num; r++) {
+ int red = *colors;
+ int green = *(colors + 1);
+ int blue = *(colors + 2);
+
+ red >>= 3;
+ green >>= 3;
+ blue >>= 3;
+ u16 paletteValue = red | (green << 5) | (blue << 10);
+ _cursorPalette[r] = paletteValue;
+
colors += 4;
}
+
+ _disableCursorPalette = false;
}
bool OSystem_DS::grabRawScreen(Graphics::Surface* surf) {
@@ -184,9 +224,11 @@ void OSystem_DS::grabPalette(unsigned char *colors, uint start, uint num) {
}
+#define MISALIGNED16(ptr) (((u32) (ptr) & 1) != 0)
+
void OSystem_DS::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) {
-// consolePrintf("Copy rect %d, %d %d, %d ", x, y, w, h);
-
+ //consolePrintf("Copy rect %d, %d %d, %d ", x, y, w, h);
+ if (!_graphicsEnable) return;
if (w <= 1) return;
if (h < 0) return;
if (!DS::getIsDisplayMode8Bit()) return;
@@ -195,6 +237,9 @@ void OSystem_DS::copyRectToScreen(const byte *buf, int pitch, int x, int y, int
s32 stride;
u16* bgSub = (u16 *) BG_GFX_SUB;
+ // The DS video RAM doesn't support 8-bit writes because Nintendo wanted
+ // to save a few pennies/euro cents on the hardware.
+
if (_frameBufferExists) {
bg = (u16 *) _framebuffer.pixels;
stride = _framebuffer.pitch;
@@ -203,46 +248,117 @@ void OSystem_DS::copyRectToScreen(const byte *buf, int pitch, int x, int y, int
stride = DS::get8BitBackBufferStride();
}
- u16* src = (u16 *) buf;
-
- if (DS::getKeyboardEnable()) {
-
+ if (((pitch & 1) != 0) || ((w & 1) != 0) || (((int) (buf) & 1) != 0)) {
+
+ // Something is misaligned, so we have to use the slow but sure method
+
+ int by = 0;
+
for (int dy = y; dy < y + h; dy++) {
- u16* dest = bg + (dy * (stride >> 1)) + (x >> 1);
-
- DC_FlushRange(src, w << 1);
- DC_FlushRange(dest, w << 1);
- dmaCopyHalfWords(3, src, dest, w);
-
- src += pitch >> 1;
+ u8* dest = ((u8 *) (bg)) + (dy * stride) + x;
+ u8* destSub = ((u8 *) (bgSub)) + (dy * 512) + x;
+ u8* src = (u8 *) buf + (pitch * by);
+
+ u32 dx;
+
+ u32 pixelsLeft = w;
+
+ if (MISALIGNED16(dest)) {
+ // Read modify write
+
+ dest--;
+ u16 mix = *((u16 *) dest);
+
+ mix = (mix & 0x00FF) | (*src++ << 8);
+
+ *dest = mix;
+ *destSub = mix;
+
+ dest += 2;
+ destSub += 2;
+ pixelsLeft--;
+ }
+
+ // We can now assume dest is aligned
+ u16* dest16 = (u16 *) dest;
+ u16* destSub16 = (u16 *) destSub;
+
+ for (dx = 0; dx < pixelsLeft; dx+=2) {
+ u16 mix;
+
+ mix = *src + (*(src + 1) << 8);
+ *dest16++ = mix;
+ *destSub16++ = mix;
+ src += 2;
+ }
+
+ pixelsLeft -= dx;
+
+ // At the end we may have one pixel left over
+
+ if (pixelsLeft != 0) {
+ u16 mix = *dest16;
+
+ mix = (mix & 0x00FF) | ((*src++) << 8);
+
+ *dest16 = mix;
+ *destSub16 = mix;
+ }
+
+ by++;
+
}
-
+
+// consolePrintf("Slow method used!\n");
+
+
} else {
- for (int dy = y; dy < y + h; dy++) {
- u16* dest1 = bg + (dy * (stride >> 1)) + (x >> 1);
- u16* dest2 = bgSub + (dy << 8) + (x >> 1);
+
+ // Stuff is aligned to 16-bit boundaries, so it's safe to do DMA.
+
+ u16* src = (u16 *) buf;
+
+ if (DS::getKeyboardEnable()) {
+
+ for (int dy = y; dy < y + h; dy++) {
+ u16* dest = bg + (dy * (stride >> 1)) + (x >> 1);
- DC_FlushRange(src, w << 1);
- DC_FlushRange(dest1, w << 1);
- DC_FlushRange(dest2, w << 1);
-
- dmaCopyHalfWords(3, src, dest1, w);
- dmaCopyHalfWords(3, src, dest2, w);
-
- src += pitch >> 1;
- }
- }
+ DC_FlushRange(src, w << 1);
+ DC_FlushRange(dest, w << 1);
+ dmaCopyHalfWords(3, src, dest, w);
-// consolePrintf("Done\n");
+ while (dmaBusy(3));
+
+ src += pitch >> 1;
+ }
+
+ } else {
+ for (int dy = y; dy < y + h; dy++) {
+ u16* dest1 = bg + (dy * (stride >> 1)) + (x >> 1);
+ u16* dest2 = bgSub + (dy << 8) + (x >> 1);
+
+ DC_FlushRange(src, w << 1);
+ DC_FlushRange(dest1, w << 1);
+ DC_FlushRange(dest2, w << 1);
+
+ dmaCopyHalfWords(3, src, dest1, w);
-
+ if ((!_frameBufferExists) || (buf == _framebuffer.pixels)) {
+ dmaCopyHalfWords(2, src, dest2, w);
+ }
+ while (dmaBusy(2) || dmaBusy(3));
+
+ src += pitch >> 1;
+ }
+ }
+ }
+// consolePrintf("Done\n");
}
void OSystem_DS::updateScreen() {
- if ((_frameBufferExists) && (DS::getIsDisplayMode8Bit()))
- {
+ if ((_frameBufferExists) && (DS::getIsDisplayMode8Bit())) {
_frameBufferExists = false;
// Copy temp framebuffer back to screen
@@ -253,6 +369,12 @@ void OSystem_DS::updateScreen() {
DS::doSoundCallback();
// DS::doTimerCallback();
DS::addEventsToQueue();
+
+ // Force back buffer usage for Nippon Safes, as it doesn't double buffer it's output
+ if (DS::getControlType() == DS::CONT_NIPPON) {
+ OSystem_DS::instance()->lockScreen();
+ OSystem_DS::instance()->unlockScreen();
+ }
}
void OSystem_DS::setShakePos(int shakeOffset) {
@@ -334,7 +456,21 @@ void OSystem_DS::warpMouse(int x, int y) {
}
void OSystem_DS::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int targetCursorScale) {
- DS::setCursorIcon(buf, w, h, keycolor, hotspotX, hotspotY);
+ if ((w > 0) && (w < 64) && (h > 0) && (h < 64))
+ {
+ memcpy(_cursorImage, buf, w * h);
+ _cursorW = w;
+ _cursorH = h;
+ _cursorHotX = hotspotX;
+ _cursorHotY = hotspotY;
+ _cursorKey = keycolor;
+ _cursorScale = targetCursorScale;
+ refreshCursor();
+ }
+}
+
+void OSystem_DS::refreshCursor() {
+ DS::setCursorIcon(_cursorImage, _cursorW, _cursorH, _cursorKey, _cursorHotX, _cursorHotY);
}
void OSystem_DS::addEvent(Common::Event& e) {
@@ -489,7 +625,11 @@ Common::SaveFileManager* OSystem_DS::getSavefileManager() {
if (DS::isGBAMPAvailable() && (!forceSram)) {
return &mpSaveManager;
} else {
+#ifdef GBA_SRAM_SAVE
return &saveManager;
+#else
+ return NULL;
+#endif
}
}
diff --git a/backends/platform/ds/arm9/source/osystem_ds.h b/backends/platform/ds/arm9/source/osystem_ds.h
index 8c8d661ad8..16c8f41491 100644
--- a/backends/platform/ds/arm9/source/osystem_ds.h
+++ b/backends/platform/ds/arm9/source/osystem_ds.h
@@ -52,17 +52,32 @@ protected:
Common::Event eventQueue[96];
int queuePos;
+#ifdef GBA_SRAM_SAVE
DSSaveFileManager saveManager;
+#endif
GBAMPSaveFileManager mpSaveManager;
DSAudioMixer* _mixer;
DSTimerManager* _timer;
Graphics::Surface _framebuffer;
bool _frameBufferExists;
-
+ bool _graphicsEnable;
static OSystem_DS* _instance;
+
+ u16 _palette[256];
+ u16 _cursorPalette[256];
+
+ u8 _cursorImage[64 * 64];
+ uint _cursorW;
+ uint _cursorH;
+ int _cursorHotX;
+ int _cursorHotY;
+ byte _cursorKey;
+ int _cursorScale;
+
Graphics::Surface* createTempFrameBuffer();
+ bool _disableCursorPalette;
public:
typedef void (*SoundProc)(byte *buf, int len);
@@ -159,7 +174,16 @@ public:
virtual void clearAutoComplete();
virtual void setCharactersEntered(int count);
+ u16 getDSPaletteEntry(u32 entry) { return _palette[entry]; }
+ u16 getDSCursorPaletteEntry(u32 entry) { return !_disableCursorPalette? _cursorPalette[entry]: _palette[entry]; }
+
+ virtual void setCursorPalette(const byte *colors, uint start, uint num);
+
+ virtual void disableCursorPalette(bool dis) { _disableCursorPalette = dis; refreshCursor(); }
+
FilesystemFactory *getFilesystemFactory();
+
+ void refreshCursor();
};
static const OSystem::GraphicsMode s_supportedGraphicsModes[] = {
diff --git a/backends/platform/ds/arm9/source/portdefs.h b/backends/platform/ds/arm9/source/portdefs.h
index de7a5795f5..16f3d8cc9b 100644
--- a/backends/platform/ds/arm9/source/portdefs.h
+++ b/backends/platform/ds/arm9/source/portdefs.h
@@ -81,7 +81,10 @@ void consolePrintf(const char* s, ...);
#define ITCM_DATA __attribute__((section(".itcm")))
-
+// Since I can't change the engine at the moment (post lockdown) this define can go here.
+// This define changes the mouse-relative motion which doesn't make sense on a touch screen to
+// a more conventional form of input where the menus can be clicked on.
+#define LURE_CLICKABLE_MENUS
//#include "common/array.h"
//#include "common/str.h"
diff --git a/backends/platform/ds/arm9/source/ramsave.cpp b/backends/platform/ds/arm9/source/ramsave.cpp
index 30c3a06721..a9f4e3d2fc 100644
--- a/backends/platform/ds/arm9/source/ramsave.cpp
+++ b/backends/platform/ds/arm9/source/ramsave.cpp
@@ -19,7 +19,9 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
- // Save in order 1,2,3,4,larger 2,5
+#ifdef GBA_SRAM_SAVE
+
+
#include "ramsave.h"
#include "nds.h"
#include "compressor/lz.h"
@@ -237,7 +239,7 @@ uint32 DSSaveFile::write(const void *buf, uint32 size) {
return size;
}
-bool DSSaveFile::matches(char* prefix, int num) {
+bool DSSaveFile::matches(const char *prefix, int num) {
char str[16];
if (isValid()) {
sprintf(str, "%s%02d", prefix, num);
@@ -251,7 +253,7 @@ bool DSSaveFile::matches(char* prefix, int num) {
}
}
-bool DSSaveFile::matches(char* filename) {
+bool DSSaveFile::matches(const char *filename) {
if (isValid()) {
return !strcmp(save.name, filename);
} else {
@@ -532,3 +534,5 @@ int DSSaveFileManager::getExtraData() {
return 0;
}
}
+
+#endif
diff --git a/backends/platform/ds/arm9/source/ramsave.h b/backends/platform/ds/arm9/source/ramsave.h
index 98430b9d11..034e957b7f 100644
--- a/backends/platform/ds/arm9/source/ramsave.h
+++ b/backends/platform/ds/arm9/source/ramsave.h
@@ -78,8 +78,8 @@ public:
bool isValid() { return save.isValid; }
bool isTemp() { return isTempFile; }
- bool matches(char* prefix, int num);
- bool matches(char* filename);
+ bool matches(const char *prefix, int num);
+ bool matches(const char *filename);
void clearData();
void compress();
diff --git a/backends/platform/ds/arm9/source/touchkeyboard.cpp b/backends/platform/ds/arm9/source/touchkeyboard.cpp
index 11832f4e3a..85f80fac92 100644
--- a/backends/platform/ds/arm9/source/touchkeyboard.cpp
+++ b/backends/platform/ds/arm9/source/touchkeyboard.cpp
@@ -402,6 +402,23 @@ void createKeyEvent(int keyNum, Common::Event& event)
}
}
+void releaseAllKeys() {
+ for (int r = 0; r < DS_NUM_KEYS; r++) {
+ if (keys[r].pressed) {
+ DS::setKeyHighlight(r, false);
+
+ OSystem_DS* system = OSystem_DS::instance();
+
+ Common::Event event;
+ createKeyEvent(r, event);
+ event.type = Common::EVENT_KEYUP;
+ system->addEvent(event);
+
+ keys[r].pressed = false;
+ }
+ }
+}
+
void addKeyboardEvents() {
bool resetShift = false;
@@ -446,7 +463,7 @@ void addKeyboardEvents() {
// consolePrintf("Key: %d\n", r);
if ((keys[r].character == Common::KEYCODE_INVALID)) {
// Close button
- DS::closed = true;
+ //DS::closed = true;
} else {
createKeyEvent(r, event);
}
@@ -492,9 +509,14 @@ void addKeyboardEvents() {
OSystem_DS* system = OSystem_DS::instance();
Common::Event event;
- createKeyEvent(r, event);
- event.type = Common::EVENT_KEYUP;
- system->addEvent(event);
+ if ((keys[r].character == Common::KEYCODE_INVALID)) {
+ // Close button
+ DS::closed = true;
+ } else {
+ createKeyEvent(r, event);
+ event.type = Common::EVENT_KEYUP;
+ system->addEvent(event);
+ }
keys[r].pressed = false;
diff --git a/backends/platform/ds/arm9/source/touchkeyboard.h b/backends/platform/ds/arm9/source/touchkeyboard.h
index 8a5fc728ce..91efbc1e9a 100644
--- a/backends/platform/ds/arm9/source/touchkeyboard.h
+++ b/backends/platform/ds/arm9/source/touchkeyboard.h
@@ -40,6 +40,7 @@ bool getKeyboardClosed();
void addAutoComplete(char* word);
void clearAutoComplete();
void setCharactersEntered(int count);
+void releaseAllKeys();
}