aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/ds/arm9/source
diff options
context:
space:
mode:
authorTony Puccinelli2010-07-28 00:08:32 +0000
committerTony Puccinelli2010-07-28 00:08:32 +0000
commite8fc5f207093e8a0518dca5d815233e912945e2d (patch)
tree629bc92fa3cb6fcd8ee8853d6dffe08eb5b84a46 /backends/platform/ds/arm9/source
parent58f3e81f0073f55a892802b562081300345ca23d (diff)
downloadscummvm-rg350-e8fc5f207093e8a0518dca5d815233e912945e2d.tar.gz
scummvm-rg350-e8fc5f207093e8a0518dca5d815233e912945e2d.tar.bz2
scummvm-rg350-e8fc5f207093e8a0518dca5d815233e912945e2d.zip
various manual tweaks to get ds port compiling from branch again after earlier merge from trunk
svn-id: r51398
Diffstat (limited to 'backends/platform/ds/arm9/source')
-rw-r--r--backends/platform/ds/arm9/source/dsmain.cpp427
1 files changed, 192 insertions, 235 deletions
diff --git a/backends/platform/ds/arm9/source/dsmain.cpp b/backends/platform/ds/arm9/source/dsmain.cpp
index 8b1ed32c67..1f3a67d818 100644
--- a/backends/platform/ds/arm9/source/dsmain.cpp
+++ b/backends/platform/ds/arm9/source/dsmain.cpp
@@ -8,15 +8,18 @@
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
*
*/
@@ -80,8 +83,10 @@
//#include <ARM9/console.h> //basic print funcionality
#include <stdlib.h>
+#include <string.h>
+
+#include "NDS/scummvm_ipc.h"
#include "dsmain.h"
-#include "string.h"
#include "osystem_ds.h"
#include "icons_raw.h"
#include "fat/gba_nds_fat.h"
@@ -97,17 +102,23 @@
#endif
#include "ramsave.h"
#include "blitters.h"
-#include "cartreset_nolibfat.h"
+#include "libcartreset/cartreset_nolibfat.h"
#include "keys.h"
#ifdef USE_PROFILER
#include "profiler/cyg-profile.h"
#endif
-#include "backends/fs/ds/ds-fs.h"
#include "base/version.h"
#include "engine.h"
+
+#include "backends/plugins/ds/ds-provider.h"
+
+#include "backends/fs/ds/ds-fs.h"
+#include "base/version.h"
+#include "common/util.h"
+
extern "C" void OurIntrMain(void);
-extern "C" u32 getExceptionAddress( u32 opcodeAddress, u32 thumbState);
+extern "C" u32 getExceptionAddress(u32 opcodeAddress, u32 thumbState);
extern const char __itcm_start[];
static const char *registerNames[] =
@@ -116,22 +127,20 @@ static const char *registerNames[] =
#ifdef WRAP_MALLOC
-extern "C" void* __real_malloc(size_t size);
+extern "C" void *__real_malloc(size_t size);
-int total = 0;
+static int s_total_malloc = 0;
-void* operator new (size_t size)
-{
+void *operator new (size_t size) {
register unsigned int reg asm("lr");
volatile unsigned int poo = reg;
- void* res = __real_malloc(size);
- total += size;
+ void *res = __real_malloc(size);
+ s_total_malloc += size;
- if (!res)
- {
+ if (!res) {
// *((u8 *) NULL) = 0;
- consolePrintf("Failed alloc (new) %d (%d)\n", size, total);
+ consolePrintf("Failed alloc (new) %d (%d)\n", size, s_total_malloc);
return NULL;
}
@@ -139,7 +148,7 @@ void* operator new (size_t size)
}
-extern "C" void* __wrap_malloc(size_t size) {
+extern "C" void *__wrap_malloc(size_t size) {
/* u32 addr;
asm("mov %0, lr"
@@ -151,23 +160,22 @@ extern "C" void* __wrap_malloc(size_t size) {
volatile unsigned int poo = reg;
- if (size == 0)
- {
+ if (size == 0) {
static int zeroSize = 0;
consolePrintf("0 size malloc (%d)", zeroSize++);
}
- void* res = __real_malloc(size);
+ void *res = __real_malloc(size);
if (res) {
if (size > 50 * 1024) {
consolePrintf("Allocated %d (%x)\n", size, poo);
}
- total += size;
+ s_total_malloc += size;
return res;
} else {
// *((u8 *) NULL) = 0;
- consolePrintf("Failed alloc %d (%d)\n", size, total);
+ consolePrintf("Failed alloc %d (%d)\n", size, s_total_malloc);
return NULL;
}
}
@@ -193,112 +201,109 @@ enum MouseMode {
#define SCUMM_GAME_HEIGHT 142
#define SCUMM_GAME_WIDTH 227
-int textureID;
-u16* texture;
-
-int frameCount;
-int currentTimeMillis;
+static int frameCount;
+static int currentTimeMillis;
// Timer Callback
-int callbackInterval;
-int callbackTimer;
-OSystem_DS::TimerProc callback;
+static int callbackInterval;
+static int callbackTimer;
+static OSystem_DS::TimerProc callback;
// Scaled
-bool scaledMode;
-int scX;
-int scY;
+static bool scaledMode;
+static int scX;
+static int scY;
-int subScX;
-int subScY;
-int subScTargetX;
-int subScTargetY;
-int subScreenWidth = SCUMM_GAME_WIDTH;
-int subScreenHeight = SCUMM_GAME_HEIGHT;
-int subScreenScale = 256;
+static int subScX;
+static int subScY;
+static int subScTargetX;
+static int subScTargetY;
+static int subScreenWidth = SCUMM_GAME_WIDTH;
+static int subScreenHeight = SCUMM_GAME_HEIGHT;
+static int subScreenScale = 256;
// Sound
-int bufferSize;
-s16* soundBuffer;
-int bufferFrame;
-int bufferRate;
-int bufferSamples;
-bool soundHiPart;
-int soundFrequency;
+static int bufferSize;
+static s16 *soundBuffer;
+static int bufferFrame;
+static int bufferRate;
+static int bufferSamples;
+static bool soundHiPart;
+static int soundFrequency;
// Events
-int lastEventFrame;
-bool indyFightState;
-bool indyFightRight;
+static int lastEventFrame;
+static bool indyFightState;
+static bool indyFightRight;
-OSystem_DS::SoundProc soundCallback;
-void* soundParam;
-int lastCallbackFrame;
-bool bufferFirstHalf;
-bool bufferSecondHalf;
+static OSystem_DS::SoundProc soundCallback;
+static int lastCallbackFrame;
+static bool bufferFirstHalf;
+static bool bufferSecondHalf;
// Saved buffers
-bool highBuffer;
-bool displayModeIs8Bit = false;
+static bool highBuffer;
+static bool displayModeIs8Bit = false;
// Game id
-u8 gameID;
+static u8 gameID;
-bool snapToBorder = false;
-bool consoleEnable = false;
-bool gameScreenSwap = false;
+static bool snapToBorder = false;
+static bool consoleEnable = false;
+static bool gameScreenSwap = false;
bool isCpuScalerEnabled();
//#define HEAVY_LOGGING
-MouseMode mouseMode = MOUSE_LEFT;
+static MouseMode mouseMode = MOUSE_LEFT;
-int storedMouseX = 0;
-int storedMouseY = 0;
+static int storedMouseX = 0;
+static int storedMouseY = 0;
// Sprites
-SpriteEntry sprites[128];
-SpriteEntry spritesMain[128];
-int tweak;
+static SpriteEntry sprites[128];
+static SpriteEntry spritesMain[128];
+static int tweak;
// Shake
-int shakePos = 0;
+static int s_shakePos = 0;
// Keyboard
-bool keyboardEnable = false;
-bool leftHandedMode = false;
-bool keyboardIcon = false;
+static bool keyboardEnable = false;
+static bool leftHandedMode = false;
+static bool keyboardIcon = false;
// Touch
-int touchScX, touchScY, touchX, touchY;
-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;
+static int touchScX, touchScY, touchX, touchY;
+static int mouseHotspotX, mouseHotspotY;
+static bool cursorEnable = false;
+static bool mouseCursorVisible = true;
+static bool leftButtonDown = false;
+static bool rightButtonDown = false;
+static bool touchPadStyle = false;
+static int touchPadSensitivity = 8;
+static bool tapScreenClicks = true;
+
+static int tapCount = 0;
+static int tapTimeout = 0;
+static int tapComplete = 0;
// Dragging
-int dragStartX, dragStartY;
-bool dragging = false;
-int dragScX, dragScY;
+static int dragStartX, dragStartY;
+static bool dragging = false;
+static int dragScX, dragScY;
// Interface styles
-char gameName[32];
+static char gameName[32];
// 8-bit surface size
-int gameWidth = 320;
-int gameHeight = 200;
+static int gameWidth = 320;
+static int gameHeight = 200;
// Scale
-bool twoHundredPercentFixedScale = false;
-bool cpuScalerEnable = false;
+static bool twoHundredPercentFixedScale = false;
+static bool cpuScalerEnable = false;
// 100 256
// 150 192
@@ -309,14 +314,14 @@ bool cpuScalerEnable = false;
#ifdef USE_PROFILER
-int hBlankCount = 0;
+static int hBlankCount = 0;
#endif
-u8* scalerBackBuffer = NULL;
+static u8 *scalerBackBuffer = NULL;
#define NUM_SUPPORTED_GAMES 21
-gameListType gameList[NUM_SUPPORTED_GAMES] = {
+static const gameListType gameList[NUM_SUPPORTED_GAMES] = {
// Unknown game - use normal SCUMM controls
{"unknown", CONT_SCUMM_ORIGINAL},
@@ -345,31 +350,29 @@ gameListType gameList[NUM_SUPPORTED_GAMES] = {
{"parallaction", CONT_NIPPON},
};
-gameListType* currentGame = NULL;
+static const gameListType *s_currentGame = NULL;
// Stylus
-#define ABS(x) ((x)>0?(x):-(x))
-
-bool penDown = FALSE;
-bool penHeld = FALSE;
-bool penReleased = FALSE;
-bool penDownLastFrame = FALSE;
-s32 penX = 0, penY = 0;
-s32 penDownX = 0, penDownY = 0;
-int keysDownSaved = 0;
-int keysReleasedSaved = 0;
-int keysChangedSaved = 0;
+static bool penDown = FALSE;
+static bool penHeld = FALSE;
+static bool penReleased = FALSE;
+static bool penDownLastFrame = FALSE;
+static s32 penX = 0, penY = 0;
+static s32 penDownX = 0, penDownY = 0;
+static int keysDownSaved = 0;
+static int keysReleasedSaved = 0;
+static int keysChangedSaved = 0;
-bool penDownSaved = FALSE;
-bool penReleasedSaved = FALSE;
-int penDownFrames = 0;
-int touchXOffset = 0;
-int touchYOffset = 0;
+static bool penDownSaved = FALSE;
+static bool penReleasedSaved = FALSE;
+static int penDownFrames = 0;
+static int touchXOffset = 0;
+static int touchYOffset = 0;
-int triggeredIcon = 0;
-int triggeredIconTimeout = 0;
+static int triggeredIcon = 0;
+static int triggeredIconTimeout = 0;
-u16 savedPalEntry255 = RGB15(31, 31, 31);
+static u16 savedPalEntry255 = RGB15(31, 31, 31);
extern "C" int scummvm_main(int argc, char *argv[]);
@@ -382,7 +385,7 @@ void setIcon(int num, int x, int y, int imageNum, int flags, bool enable);
void setIconMain(int num, int x, int y, int imageNum, int flags, bool enable);
void uploadSpriteGfx();
-TransferSound soundControl;
+static TransferSound soundControl;
bool isCpuScalerEnabled() {
@@ -430,12 +433,12 @@ void setTopScreenZoom(int percentage) {
// return (ConfMan.hasKey("cpu_scaler", "ds") && ConfMan.getBool("cpu_scaler", "ds"));
controlType getControlType() {
- return currentGame->control;
+ return s_currentGame->control;
}
//plays an 8 bit mono sample at 11025Hz
-void playSound(const void* data, u32 length, bool loop, bool adpcm, int rate) {
+void playSound(const void *data, u32 length, bool loop, bool adpcm, int rate) {
if (!IPC->soundData) {
soundControl.count = 0;
@@ -551,21 +554,8 @@ int getSoundFrequency() {
return soundFrequency;
}
-void setControls(char* gameName) {
-
- for (int r = 0; r < NUM_SUPPORTED_GAMES; r++) {
- if (!stricmp(gameName, gameList[r].gameId)) {
- currentGame = &gameList[r];
- consolePrintf("Current game set to: %s\n", gameName);
- return;
- }
- }
-
- consolePrintf("Failed to set current game to: %s\n", gameName);
-}
-
void exitGame() {
- currentGame = NULL;
+ s_currentGame = NULL;
}
void initGame() {
@@ -580,17 +570,17 @@ void initGame() {
setOptions();
//strcpy(gameName, ConfMan.getActiveDomain().c_str());
- if (currentGame == NULL) {
+ if (s_currentGame == NULL) {
strcpy(gameName, ConfMan.get("gameid").c_str());
// consolePrintf("\n\n\n\nCurrent game: '%s' %d\n", gameName, gameName[0]);
- currentGame = &gameList[0]; // Default game
+ s_currentGame = &gameList[0]; // Default game
for (int r = 0; r < NUM_SUPPORTED_GAMES; r++) {
if (!stricmp(gameName, gameList[r].gameId)) {
- currentGame = &gameList[r];
- // consolePrintf("Game list num: %d\n", currentGame);
+ s_currentGame = &gameList[r];
+ // consolePrintf("Game list num: %d\n", s_currentGame);
}
}
}
@@ -785,7 +775,7 @@ void checkSleepMode() {
}
void setShowCursor(bool enable) {
- if ((currentGame) && (currentGame->control == CONT_SCUMM_SAMNMAX)) {
+ if ((s_currentGame) && (s_currentGame->control == CONT_SCUMM_SAMNMAX)) {
if (cursorEnable) {
sprites[1].attribute[0] = ATTR0_BMP | 150;
} else {
@@ -801,7 +791,7 @@ void setMouseCursorVisible(bool enable) {
mouseCursorVisible = enable;
}
-void setCursorIcon(const u8* icon, uint w, uint h, byte keycolor, int hotspotX, int hotspotY) {
+void setCursorIcon(const u8 *icon, uint w, uint h, byte keycolor, int hotspotX, int hotspotY) {
int off;
@@ -833,7 +823,7 @@ void setCursorIcon(const u8* icon, uint w, uint h, byte keycolor, int hotspotX,
}
}
- if (currentGame->control != CONT_SCUMM_SAMNMAX)
+ if (s_currentGame->control != CONT_SCUMM_SAMNMAX)
return;
uint16 border = RGB15(24,24,24) | 0x8000;
@@ -982,7 +972,7 @@ void displayMode16BitFlipBuffer() {
consolePrintf("Flip %s...", displayModeIs8Bit ? "8bpp" : "16bpp");
#endif
if (!displayModeIs8Bit) {
- u16* back = get16BitBackBuffer();
+ u16 *back = get16BitBackBuffer();
// highBuffer = !highBuffer;
// BG3_CR = BG_BMP16_512x256 | BG_BMP_RAM(highBuffer? 1: 0);
@@ -1001,8 +991,8 @@ void displayMode16BitFlipBuffer() {
TIMER1_CR = TIMER_ENABLE | TIMER_DIV_1024;
u16 t0 = TIMER1_DATA;
#endif
- const u8* back = (const u8*)get8BitBackBuffer();
- u16* base = BG_GFX + 0x10000;
+ const u8 *back = (const u8*)get8BitBackBuffer();
+ u16 *base = BG_GFX + 0x10000;
Rescale_320x256xPAL8_To_256x256x1555(
base,
back,
@@ -1031,17 +1021,18 @@ void displayMode16BitFlipBuffer() {
}
void setShakePos(int shakePos) {
- shakePos = shakePos;
+ s_shakePos = shakePos;
}
-u16* get16BitBackBuffer() {
+u16 *get16BitBackBuffer() {
return BG_GFX + 0x20000;
}
s32 get8BitBackBufferStride() {
- // When the CPU scaler is enabled, the back buffer is in system RAM and is 320 pixels wide
- // When the CPU scaler is disabled, the back buffer is in video memory and therefore must have a 512 pixel stride
+ // When the CPU scaler is enabled, the back buffer is in system RAM and is
+ // 320 pixels wide. When the CPU scaler is disabled, the back buffer is in
+ // video memory and therefore must have a 512 pixel stride.
if (isCpuScalerEnabled()){
return 320;
@@ -1050,11 +1041,11 @@ s32 get8BitBackBufferStride() {
}
}
-u16* getScalerBuffer() {
+u16 *getScalerBuffer() {
return (u16 *) scalerBackBuffer;
}
-u16* get8BitBackBuffer() {
+u16 *get8BitBackBuffer() {
if (isCpuScalerEnabled())
return (u16 *) scalerBackBuffer;
else
@@ -1124,7 +1115,7 @@ void soundUpdate() {
void memoryReport() {
int r = 0;
- int* p;
+ int *p;
do {
p = (int *) malloc(r * 8192);
free(p);
@@ -1132,7 +1123,7 @@ void memoryReport() {
} while ((p) && (r < 512));
int t = -1;
- void* block[1024];
+ void *block[1024];
do {
t++;
block[t] = (int *) malloc(4096);
@@ -1147,7 +1138,7 @@ void memoryReport() {
void addIndyFightingKeys() {
- OSystem_DS* system = OSystem_DS::instance();
+ OSystem_DS *system = OSystem_DS::instance();
Common::Event event;
event.type = Common::EVENT_KEYDOWN;
@@ -1247,7 +1238,7 @@ void addIndyFightingKeys() {
void setKeyboardEnable(bool en) {
if (en == keyboardEnable) return;
keyboardEnable = en;
- u16* backupBank = (u16 *) 0x6040000;
+ u16 *backupBank = (u16 *) 0x6040000;
if (keyboardEnable) {
@@ -1283,7 +1274,7 @@ void setKeyboardEnable(bool en) {
if (displayModeIs8Bit) {
// Copy the sub screen VRAM from the top screen - they should always be
// the same.
- u16* buffer = get8BitBackBuffer();
+ u16 *buffer = get8BitBackBuffer();
s32 stride = get8BitBackBufferStride();
for (int y = 0; y < gameHeight; y++) {
@@ -1319,8 +1310,7 @@ bool getIsDisplayMode8Bit() {
return displayModeIs8Bit;
}
-void doScreenTapMode(OSystem_DS* system)
-{
+void doScreenTapMode(OSystem_DS *system) {
Common::Event event;
static bool left = false, right = false;
@@ -1386,8 +1376,7 @@ void doScreenTapMode(OSystem_DS* system)
system->addEvent(event);
}
-void doButtonSelectMode(OSystem_DS* system)
-{
+void doButtonSelectMode(OSystem_DS *system) {
Common::Event event;
@@ -1398,9 +1387,6 @@ void doButtonSelectMode(OSystem_DS* system)
//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;
@@ -1467,7 +1453,6 @@ void doButtonSelectMode(OSystem_DS* system)
}
if (rightButtonDown) {
- Common::Event event;
event.mouse = Common::Point(getPenX(), getPenY());
event.type = Common::EVENT_RBUTTONUP;
system->addEvent(event);
@@ -1476,14 +1461,13 @@ void doButtonSelectMode(OSystem_DS* system)
if (getKeysDown() & KEY_RIGHT) {
- if ((currentGame->control != CONT_SCUMM_SAMNMAX) && (currentGame->control != CONT_FUTURE_WARS) && (currentGame->control != CONT_GOBLINS)) {
+ if ((s_currentGame->control != CONT_SCUMM_SAMNMAX) && (s_currentGame->control != CONT_FUTURE_WARS) && (s_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) {
+ if (s_currentGame->control == CONT_FUTURE_WARS) {
event.mouse = Common::Point(320 - 128, 200 - 128);
event.type = Common::EVENT_MOUSEMOVE;
system->addEvent(event);
@@ -1515,7 +1499,7 @@ void addEventsToQueue() {
#ifdef HEAVY_LOGGING
consolePrintf("addEventsToQueue\n");
#endif
- OSystem_DS* system = OSystem_DS::instance();
+ OSystem_DS *system = OSystem_DS::instance();
Common::Event event;
#ifdef USE_PROFILER
@@ -1558,7 +1542,7 @@ void addEventsToQueue() {
if (!indyFightState) {
if ((!(getKeysHeld() & KEY_L)) && (!(getKeysHeld() & KEY_R)) && (getKeysDown() & KEY_B)) {
- if (currentGame->control == CONT_AGI) {
+ if (s_currentGame->control == CONT_AGI) {
event.kbd.keycode = Common::KEYCODE_RETURN;
event.kbd.ascii = 13;
event.kbd.flags = 0;
@@ -1596,8 +1580,7 @@ void addEventsToQueue() {
bool release = getKeysReleased() & (KEY_LEFT | KEY_RIGHT | KEY_UP | KEY_DOWN);
bool shoulders = getKeysHeld() & (KEY_L | KEY_R);
- if ( (down && (!shoulders)) || release)
- {
+ if ( (down && (!shoulders)) || release) {
if (getKeysChanged() & KEY_LEFT) {
event.kbd.keycode = Common::KEYCODE_LEFT;
@@ -1675,8 +1658,6 @@ void addEventsToQueue() {
updateStatus();
- Common::Event event;
-
if ((tapScreenClicks) && (getIsDisplayMode8Bit())) {
if ((!keyboardEnable) || (!isInsideKeyboard(penDownX, penDownY))) {
@@ -1693,13 +1674,10 @@ void addEventsToQueue() {
if (!keyboardEnable) {
-
if (((!(getKeysHeld() & KEY_L)) && (!(getKeysHeld() & KEY_R)) || (indyFightState)) && (displayModeIs8Bit)) {
// Controls specific to the control method
-
-
- if (currentGame->control == CONT_SKY) {
+ if (s_currentGame->control == CONT_SKY) {
// Extra controls for Beneath a Steel Sky
if ((getKeysDown() & KEY_DOWN)) {
penY = 0;
@@ -1707,9 +1685,8 @@ void addEventsToQueue() {
}
}
- if (currentGame->control == CONT_AGI) {
+ if (s_currentGame->control == CONT_AGI) {
// Extra controls for Leisure Suit Larry and KQ4
-
if ((getKeysHeld() & KEY_UP) && (getKeysHeld() & KEY_START)
/*&& (!strcmp(gameName, "LLLLL"))*/) {
consolePrintf("Cheat key!\n");
@@ -1722,16 +1699,11 @@ void addEventsToQueue() {
event.type = Common::EVENT_KEYUP;
system->addEvent(event);
}
-
}
-
-
- if (currentGame->control == CONT_SIMON) {
+ if (s_currentGame->control == CONT_SIMON) {
// Extra controls for Simon the Sorcerer
if ((getKeysDown() & KEY_DOWN)) {
- Common::Event event;
-
event.type = Common::EVENT_KEYDOWN;
event.kbd.keycode = Common::KEYCODE_F10; // F10 or # - show hotspots
event.kbd.ascii = Common::ASCII_F10;
@@ -1744,13 +1716,9 @@ void addEventsToQueue() {
}
}
-
-
- if (currentGame->control == CONT_SCUMM_ORIGINAL) {
+ if (s_currentGame->control == CONT_SCUMM_ORIGINAL) {
// Extra controls for Scumm v1-5 games
if ((getKeysDown() & KEY_DOWN)) {
- Common::Event event;
-
event.type = Common::EVENT_KEYDOWN;
event.kbd.keycode = Common::KEYCODE_PERIOD; // Full stop - skips current dialogue line
event.kbd.ascii = '.';
@@ -1806,14 +1774,14 @@ void addEventsToQueue() {
if ((getKeysChanged() & KEY_START)) {
event.kbd.flags = 0;
event.type = getKeyEvent(KEY_START);
- if (currentGame->control == CONT_FUTURE_WARS) {
+ if (s_currentGame->control == CONT_FUTURE_WARS) {
event.kbd.keycode = Common::KEYCODE_F10;
event.kbd.ascii = Common::ASCII_F10;
- } else if (currentGame->control == CONT_GOBLINS) {
+ } else if (s_currentGame->control == CONT_GOBLINS) {
event.kbd.keycode = Common::KEYCODE_F1;
event.kbd.ascii = Common::ASCII_F1;
// consolePrintf("!!!!!F1!!!!!");
- } else if (currentGame->control == CONT_AGI) {
+ } else if (s_currentGame->control == CONT_AGI) {
event.kbd.keycode = Common::KEYCODE_ESCAPE;
event.kbd.ascii = 27;
} else {
@@ -1830,9 +1798,7 @@ void addEventsToQueue() {
}
consumeKeys();
-
consumePenEvents();
-
}
}
@@ -1862,23 +1828,19 @@ void updateStatus() {
if (displayModeIs8Bit) {
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;
- }
+ 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);
@@ -1962,15 +1924,12 @@ void setMainScreenScale(int x, int y) {
SUB_BG3_YDX = 0;
SUB_BG3_YDY = y;
} else*/ {
- if (isCpuScalerEnabled() && (x==320))
- {
+ if (isCpuScalerEnabled() && (x==320)) {
BG3_XDX = 256;
BG3_XDY = 0;
BG3_YDX = 0;
BG3_YDY = y;
- }
- else
- {
+ } else {
BG3_XDX = x;
BG3_XDY = 0;
BG3_YDX = 0;
@@ -2057,11 +2016,9 @@ void VBlankHandler(void) {
soundUpdate();
-
-
if ((!gameScreenSwap) && (!(getKeysHeld() & KEY_L) && !(getKeysHeld() & KEY_R))) {
- if (currentGame) {
- if (currentGame->control != CONT_SCUMM_SAMNMAX) {
+ if (s_currentGame) {
+ if (s_currentGame->control != CONT_SCUMM_SAMNMAX) {
if (getPenHeld() && (getPenY() < SCUMM_GAME_HEIGHT)) {
setTopScreenTarget(getPenX(), getPenY());
}
@@ -2144,7 +2101,7 @@ void VBlankHandler(void) {
SUB_BG3_CX = subScX + 64;
}
- SUB_BG3_CY = subScY + (shakePos << 8);*/
+ SUB_BG3_CY = subScY + (s_shakePos << 8);*/
/*SUB_BG3_XDX = (int) (subScreenWidth / 256.0f * 256);
SUB_BG3_XDY = 0;
@@ -2284,7 +2241,7 @@ void VBlankHandler(void) {
setZoomedScreenScale(subScreenWidth, ((subScreenHeight * (256 << 8)) / 192) >> 8);
- setMainScreenScroll(scX << 8, (scY << 8) + (shakePos << 8));
+ setMainScreenScroll(scX << 8, (scY << 8) + (s_shakePos << 8));
setMainScreenScale(256, 256); // 1:1 scale
} else {
@@ -2300,7 +2257,7 @@ void VBlankHandler(void) {
setZoomedScreenScroll(subScX, subScY, (subScreenWidth != 256) && (subScreenWidth != 128));
setZoomedScreenScale(subScreenWidth, ((subScreenHeight * (256 << 8)) / 192) >> 8);
- setMainScreenScroll(64, (scY << 8) + (shakePos << 8));
+ setMainScreenScroll(64, (scY << 8) + (s_shakePos << 8));
setMainScreenScale(320, 256); // 1:1 scale
}
@@ -2388,7 +2345,7 @@ void uploadSpriteGfx() {
vramSetBankE(VRAM_E_MAIN_SPRITE);
// Convert texture from 24bit 888 to 16bit 1555, remembering to set top bit!
- u8* srcTex = (u8 *) ::icons_raw;
+ const u8 *srcTex = (const u8 *) ::icons_raw;
for (int r = 32 * 256 ; r >= 0; r--) {
SPRITE_GFX_SUB[r] = 0x8000 | (srcTex[r * 3] >> 3) | ((srcTex[r * 3 + 1] >> 3) << 5) | ((srcTex[r * 3 + 2] >> 3) << 10);
SPRITE_GFX[r] = 0x8000 | (srcTex[r * 3] >> 3) | ((srcTex[r * 3 + 1] >> 3) << 5) | ((srcTex[r * 3 + 2] >> 3) << 10);
@@ -2634,9 +2591,6 @@ void penUpdate() {
}
}
- else
- {
- }
} else {
penDown = true;
@@ -2856,20 +2810,18 @@ bool getIndyFightState() {
return indyFightState;
}
-gameListType* getCurrentGame() {
- return currentGame;
-}
-
///////////////////
// Fast Ram
///////////////////
#define FAST_RAM_SIZE (24000)
-u8* fastRamPointer;
+#define ITCM_DATA __attribute__((section(".itcm")))
+
+u8 *fastRamPointer;
u8 fastRamData[FAST_RAM_SIZE] ITCM_DATA;
-void* fastRamAlloc(int size) {
- void* result = (void *) fastRamPointer;
+void *fastRamAlloc(int size) {
+ void *result = (void *) fastRamPointer;
fastRamPointer += size;
if(fastRamPointer > fastRamData + FAST_RAM_SIZE) {
consolePrintf("FastRam (ITCM) allocation failed!\n");
@@ -2926,7 +2878,7 @@ void initDebugger() {
// Ensure the function is processed with C linkage
-extern "C" void debug_print_stub(char* string);
+extern "C" void debug_print_stub(char *string);
void debug_print_stub(char *string) {
consolePrintf(string);
@@ -3286,7 +3238,7 @@ int main(void) {
*/
// Create a file system node to force search for a zip file in GBA rom space
- DSFileSystemNode* node = new DSFileSystemNode();
+ DSFileSystemNode *node = new DSFileSystemNode();
if (!node->getZip() || (!node->getZip()->isReady())) {
// If not found, init CF/SD driver
initGBAMP(mode);
@@ -3344,6 +3296,11 @@ int main(void) {
const char *argv[] = {"/scummvmds", "--config=scummvmj.ini"};
#elif defined(DS_BUILD_K)
const char *argv[] = {"/scummvmds", "--config=scummvmk.ini"};
+#else
+ // Use the default config file if no build was specified. This currently
+ // only happens with builds made using the regular ScummVM build system (as
+ // opposed to the nds specific build system).
+ const char *argv[] = {"/scummvmds"};
#endif
#ifdef DYNAMIC_MODULES
@@ -3359,7 +3316,8 @@ int main(void) {
return 0;
}
-}
+} // End of namespace DS
+
int main() {
DS::main();
@@ -3380,7 +3338,6 @@ extern "C" void consolePrintf(char * format, ...) __attribute__ ((no_instrument_
extern "C" void consolePrintf(const char * format, ...) {
- char buffer[256];
va_list args;
va_start(args, format);
viprintf(format, args);