diff options
-rw-r--r-- | backends/fs/ds/ds-fs-factory.cpp | 2 | ||||
-rw-r--r-- | backends/fs/ds/ds-fs.cpp | 46 | ||||
-rw-r--r-- | backends/platform/ds/arm9/source/dsmain.cpp | 18 | ||||
-rw-r--r-- | backends/platform/ds/arm9/source/dsmain.h | 2 | ||||
-rw-r--r-- | backends/platform/ds/arm9/source/osystem_ds.cpp | 6 | ||||
-rw-r--r-- | backends/platform/ds/arm9/source/osystem_ds.h | 8 | ||||
-rw-r--r-- | backends/platform/ds/arm9/source/touchkeyboard.cpp | 156 | ||||
-rw-r--r-- | backends/platform/ds/arm9/source/touchkeyboard.h | 8 |
8 files changed, 118 insertions, 128 deletions
diff --git a/backends/fs/ds/ds-fs-factory.cpp b/backends/fs/ds/ds-fs-factory.cpp index 0dfa70b716..4919c04174 100644 --- a/backends/fs/ds/ds-fs-factory.cpp +++ b/backends/fs/ds/ds-fs-factory.cpp @@ -27,7 +27,7 @@ #include "backends/fs/ds/ds-fs.h" #include "dsmain.h" //for the isGBAMPAvailable() function -DECLARE_SINGLETON(DSFilesystemFactory); +DECLARE_SINGLETON(DSFilesystemFactory) AbstractFSNode *DSFilesystemFactory::makeRootFileNode() const { if (DS::isGBAMPAvailable()) { diff --git a/backends/fs/ds/ds-fs.cpp b/backends/fs/ds/ds-fs.cpp index 6fc2894925..39eaf39ec0 100644 --- a/backends/fs/ds/ds-fs.cpp +++ b/backends/fs/ds/ds-fs.cpp @@ -451,9 +451,8 @@ uint32 DSFileStream::write(const void *ptr, uint32 len) { if (_writeBufferPos + len < WRITE_BUFFER_SIZE) { memcpy(_writeBuffer + _writeBufferPos, ptr, len); _writeBufferPos += len; - } - else - { + return len; + } else { if (_writeBufferPos > 0) { flush(); } @@ -483,15 +482,17 @@ DSFileStream *DSFileStream::makeFromPath(const Common::String &path, bool writeM // Stdio replacements -#define MAX_FILE_HANDLES 32 +enum { + MAX_FILE_HANDLES = 32 +}; -bool inited = false; -DS::fileHandle handle[MAX_FILE_HANDLES]; +static bool inited = false; +static DS::fileHandle s_handle[MAX_FILE_HANDLES]; FILE* std_fopen(const char* name, const char* mode) { if (!inited) { for (int r = 0; r < MAX_FILE_HANDLES; r++) { - handle[r].used = false; + s_handle[r].used = false; } inited = true; currentDir[0] = '\0'; @@ -538,7 +539,7 @@ FILE* std_fopen(const char* name, const char* mode) { // Allocate a file handle int r = 0; - while (handle[r].used) { + while (s_handle[r].used) { r++; assert(r < MAX_FILE_HANDLES); } @@ -546,20 +547,20 @@ FILE* std_fopen(const char* name, const char* mode) { #ifdef GBA_SRAM_SAVE if (strchr(mode, 'w')) { // consolePrintf("Writing %s\n", realName); - handle[r].sramFile = (DSSaveFile *) DSSaveFileManager::instance()->openSavefile(realName, true); + s_handle[r].sramFile = (DSSaveFile *) DSSaveFileManager::instance()->openSavefile(realName, true); } else { // consolePrintf("Reading %s\n", realName); - handle[r].sramFile = (DSSaveFile *) DSSaveFileManager::instance()->openSavefile(realName, false); + s_handle[r].sramFile = (DSSaveFile *) DSSaveFileManager::instance()->openSavefile(realName, false); } #endif - if (handle[r].sramFile) { - handle[r].used = true; - handle[r].pos = 0; - handle[r].data = NULL; - handle[r].size = handle[r].sramFile->getSize(); + if (s_handle[r].sramFile) { + s_handle[r].used = true; + s_handle[r].pos = 0; + s_handle[r].data = NULL; + s_handle[r].size = s_handle[r].sramFile->getSize(); // consolePrintf("Found it"); - return &handle[r]; + return &s_handle[r]; } // consolePrintf("Not in SRAM!"); @@ -590,16 +591,17 @@ FILE* std_fopen(const char* name, const char* mode) { // Allocate a file handle int r = 0; - while (handle[r].used) r++; + while (s_handle[r].used) + r++; - handle[r].used = true; - handle[r].pos = 0; - handle[r].data = data; - handle[r].size = zip->getFileSize(); + s_handle[r].used = true; + s_handle[r].pos = 0; + s_handle[r].data = data; + s_handle[r].size = zip->getFileSize(); // consolePrintf("Opened file %d: %s (%s) ", r, realName, name); - return &handle[r]; + return &s_handle[r]; } else { zip->setAllFilesVisible(false); // consolePrintf("Not found: %s (%s) ", realName, name); diff --git a/backends/platform/ds/arm9/source/dsmain.cpp b/backends/platform/ds/arm9/source/dsmain.cpp index 556cfc3f43..4ba0b35472 100644 --- a/backends/platform/ds/arm9/source/dsmain.cpp +++ b/backends/platform/ds/arm9/source/dsmain.cpp @@ -194,9 +194,6 @@ enum MouseMode { #define SCUMM_GAME_HEIGHT 142 #define SCUMM_GAME_WIDTH 227 -static int textureID; -static u16* texture; - static int frameCount; static int currentTimeMillis; @@ -235,7 +232,6 @@ static bool indyFightState; static bool indyFightRight; static OSystem_DS::SoundProc soundCallback; -static void *soundParam; static int lastCallbackFrame; static bool bufferFirstHalf; static bool bufferSecondHalf; @@ -1450,7 +1446,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); @@ -1464,7 +1459,6 @@ void doButtonSelectMode(OSystem_DS* system) } else { // If we're playing sam and max, click and release the right mouse // button to change verb - Common::Event event; if (s_currentGame->control == CONT_FUTURE_WARS) { event.mouse = Common::Point(320 - 128, 200 - 128); @@ -1579,8 +1573,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; @@ -1658,8 +1651,6 @@ void addEventsToQueue() { updateStatus(); - Common::Event event; - if ((tapScreenClicks) && (getIsDisplayMode8Bit())) { if ((!keyboardEnable) || (!isInsideKeyboard(penDownX, penDownY))) { @@ -1713,8 +1704,6 @@ void addEventsToQueue() { 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; @@ -1732,8 +1721,6 @@ void addEventsToQueue() { 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 = '.'; @@ -2371,7 +2358,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); @@ -3361,7 +3348,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); diff --git a/backends/platform/ds/arm9/source/dsmain.h b/backends/platform/ds/arm9/source/dsmain.h index 88a7ca2b22..5669f7feaf 100644 --- a/backends/platform/ds/arm9/source/dsmain.h +++ b/backends/platform/ds/arm9/source/dsmain.h @@ -38,7 +38,7 @@ enum controlType { CONT_FUTURE_WARS, CONT_AGI, CONT_GOBLINS, - CONT_NIPPON, + CONT_NIPPON }; struct gameListType { diff --git a/backends/platform/ds/arm9/source/osystem_ds.cpp b/backends/platform/ds/arm9/source/osystem_ds.cpp index 9171151fde..5e21a7d78f 100644 --- a/backends/platform/ds/arm9/source/osystem_ds.cpp +++ b/backends/platform/ds/arm9/source/osystem_ds.cpp @@ -310,7 +310,7 @@ void OSystem_DS::copyRectToScreen(const byte *buf, int pitch, int x, int y, int for (int dy = y; dy < y + h; dy++) { u8* dest = ((u8 *) (bg)) + (dy * stride) + x; - u8* src = (u8 *) buf + (pitch * by); + const u8* src = (const u8 *) buf + (pitch * by); u32 dx; @@ -362,7 +362,7 @@ void OSystem_DS::copyRectToScreen(const byte *buf, int pitch, int x, int y, int for (int dy = y; dy < y + h; dy++) { u8* dest = ((u8 *) (bg)) + (dy * stride) + x; u8* destSub = ((u8 *) (bgSub)) + (dy * 512) + x; - u8* src = (u8 *) buf + (pitch * by); + const u8* src = (const u8 *) buf + (pitch * by); u32 dx; @@ -591,7 +591,7 @@ void OSystem_DS::refreshCursor() { DS::setCursorIcon(_cursorImage, _cursorW, _cursorH, _cursorKey, _cursorHotX, _cursorHotY); } -void OSystem_DS::addEvent(Common::Event& e) { +void OSystem_DS::addEvent(const Common::Event& e) { eventQueue[queuePos++] = e; } diff --git a/backends/platform/ds/arm9/source/osystem_ds.h b/backends/platform/ds/arm9/source/osystem_ds.h index 10b4c87f66..dc8b65a1c8 100644 --- a/backends/platform/ds/arm9/source/osystem_ds.h +++ b/backends/platform/ds/arm9/source/osystem_ds.h @@ -136,8 +136,8 @@ public: virtual Common::SaveFileManager *getSavefileManager(); - void addEvent(Common::Event& e); - bool isEventQueueEmpty() { return queuePos == 0; } + void addEvent(const Common::Event& e); + bool isEventQueueEmpty() const { return queuePos == 0; } virtual bool grabRawScreen(Graphics::Surface* surf); @@ -161,8 +161,8 @@ 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]; } + u16 getDSPaletteEntry(u32 entry) const { return _palette[entry]; } + u16 getDSCursorPaletteEntry(u32 entry) const { return !_disableCursorPalette? _cursorPalette[entry]: _palette[entry]; } virtual void setCursorPalette(const byte *colors, uint start, uint num); diff --git a/backends/platform/ds/arm9/source/touchkeyboard.cpp b/backends/platform/ds/arm9/source/touchkeyboard.cpp index 88bf0ae991..ef931899be 100644 --- a/backends/platform/ds/arm9/source/touchkeyboard.cpp +++ b/backends/platform/ds/arm9/source/touchkeyboard.cpp @@ -47,100 +47,100 @@ key_data keys[DS_NUM_KEYS] = { // Key number x y character // Numbers - {28, 3, 0, '1'}, - {29, 5, 0, '2'}, - {30, 7, 0, '3'}, - {31, 9, 0, '4'}, - {32, 11, 0, '5'}, - {33, 13, 0, '6'}, - {34, 15, 0, '7'}, - {35, 17, 0, '8'}, - {36, 19, 0, '9'}, - {27, 21, 0, '0'}, - {45, 23, 0, Common::KEYCODE_MINUS}, - {50, 25, 0, Common::KEYCODE_EQUALS}, - {52, 27, 0, Common::KEYCODE_BACKSPACE}, + {28, 3, 0, '1', false}, + {29, 5, 0, '2', false}, + {30, 7, 0, '3', false}, + {31, 9, 0, '4', false}, + {32, 11, 0, '5', false}, + {33, 13, 0, '6', false}, + {34, 15, 0, '7', false}, + {35, 17, 0, '8', false}, + {36, 19, 0, '9', false}, + {27, 21, 0, '0', false}, + {45, 23, 0, Common::KEYCODE_MINUS, false}, + {50, 25, 0, Common::KEYCODE_EQUALS, false}, + {52, 27, 0, Common::KEYCODE_BACKSPACE, false}, // Top row - {'Q'-'A' + 1, 4, 2, 'Q'}, - {'W'-'A' + 1, 6, 2, 'W'}, - {'E'-'A' + 1, 8, 2, 'E'}, - {'R'-'A' + 1, 10, 2, 'R'}, - {'T'-'A' + 1, 12, 2, 'T'}, - {'Y'-'A' + 1, 14, 2, 'Y'}, - {'U'-'A' + 1, 16, 2, 'U'}, - {'I'-'A' + 1, 18, 2, 'I'}, - {'O'-'A' + 1, 20, 2, 'O'}, - {'P'-'A' + 1, 22, 2, 'P'}, - {43, 24, 2, Common::KEYCODE_LEFTBRACKET}, - {44, 26, 2, Common::KEYCODE_RIGHTBRACKET}, + {'Q'-'A' + 1, 4, 2, 'Q', false}, + {'W'-'A' + 1, 6, 2, 'W', false}, + {'E'-'A' + 1, 8, 2, 'E', false}, + {'R'-'A' + 1, 10, 2, 'R', false}, + {'T'-'A' + 1, 12, 2, 'T', false}, + {'Y'-'A' + 1, 14, 2, 'Y', false}, + {'U'-'A' + 1, 16, 2, 'U', false}, + {'I'-'A' + 1, 18, 2, 'I', false}, + {'O'-'A' + 1, 20, 2, 'O', false}, + {'P'-'A' + 1, 22, 2, 'P', false}, + {43, 24, 2, Common::KEYCODE_LEFTBRACKET, false}, + {44, 26, 2, Common::KEYCODE_RIGHTBRACKET, false}, // Middle row - {55, 3, 4, DS_CAPSLOCK}, - {'A'-'A' + 1, 5, 4, 'A'}, - {'S'-'A' + 1, 7, 4, 'S'}, - {'D'-'A' + 1, 9, 4, 'D'}, - {'F'-'A' + 1, 11, 4, 'F'}, - {'G'-'A' + 1, 13, 4, 'G'}, - {'H'-'A' + 1, 15, 4, 'H'}, - {'J'-'A' + 1, 17, 4, 'J'}, - {'K'-'A' + 1, 19, 4, 'K'}, - {'L'-'A' + 1, 21, 4, 'L'}, - {42, 23, 4, Common::KEYCODE_SEMICOLON}, - {41, 25, 4, Common::KEYCODE_QUOTE}, - {46, 27, 4, Common::KEYCODE_RETURN}, + {55, 3, 4, DS_CAPSLOCK, false}, + {'A'-'A' + 1, 5, 4, 'A', false}, + {'S'-'A' + 1, 7, 4, 'S', false}, + {'D'-'A' + 1, 9, 4, 'D', false}, + {'F'-'A' + 1, 11, 4, 'F', false}, + {'G'-'A' + 1, 13, 4, 'G', false}, + {'H'-'A' + 1, 15, 4, 'H', false}, + {'J'-'A' + 1, 17, 4, 'J', false}, + {'K'-'A' + 1, 19, 4, 'K', false}, + {'L'-'A' + 1, 21, 4, 'L', false}, + {42, 23, 4, Common::KEYCODE_SEMICOLON, false}, + {41, 25, 4, Common::KEYCODE_QUOTE, false}, + {46, 27, 4, Common::KEYCODE_RETURN, false}, // Bottom row - {51, 4, 6, DS_SHIFT}, - {'Z'-'A' + 1, 6, 6, 'Z'}, - {'X'-'A' + 1, 8, 6, 'X'}, - {'C'-'A' + 1, 10, 6, 'C'}, - {'V'-'A' + 1, 12, 6, 'V'}, - {'B'-'A' + 1, 14, 6, 'B'}, - {'N'-'A' + 1, 16, 6, 'N'}, - {'M'-'A' + 1, 18, 6, 'M'}, - {38, 20, 6, Common::KEYCODE_COMMA}, - {39, 22, 6, Common::KEYCODE_PERIOD}, - {40, 24, 6, Common::KEYCODE_SLASH}, + {51, 4, 6, DS_SHIFT, false}, + {'Z'-'A' + 1, 6, 6, 'Z', false}, + {'X'-'A' + 1, 8, 6, 'X', false}, + {'C'-'A' + 1, 10, 6, 'C', false}, + {'V'-'A' + 1, 12, 6, 'V', false}, + {'B'-'A' + 1, 14, 6, 'B', false}, + {'N'-'A' + 1, 16, 6, 'N', false}, + {'M'-'A' + 1, 18, 6, 'M', false}, + {38, 20, 6, Common::KEYCODE_COMMA, false}, + {39, 22, 6, Common::KEYCODE_PERIOD, false}, + {40, 24, 6, Common::KEYCODE_SLASH, false}, // Space bar - {47, 9, 8, Common::KEYCODE_SPACE}, - {48, 11, 8, Common::KEYCODE_SPACE}, - {48, 13, 8, Common::KEYCODE_SPACE}, - {48, 15, 8, Common::KEYCODE_SPACE}, - {48, 17, 8, Common::KEYCODE_SPACE}, - {49, 19, 8, Common::KEYCODE_SPACE}, + {47, 9, 8, Common::KEYCODE_SPACE, false}, + {48, 11, 8, Common::KEYCODE_SPACE, false}, + {48, 13, 8, Common::KEYCODE_SPACE, false}, + {48, 15, 8, Common::KEYCODE_SPACE, false}, + {48, 17, 8, Common::KEYCODE_SPACE, false}, + {49, 19, 8, Common::KEYCODE_SPACE, false}, // Cursor arrows - {52, 27, 8, Common::KEYCODE_LEFT}, - {54, 29, 8, Common::KEYCODE_DOWN}, - {53, 31, 8, Common::KEYCODE_RIGHT}, - {51, 29, 6, Common::KEYCODE_UP}, + {52, 27, 8, Common::KEYCODE_LEFT, false}, + {54, 29, 8, Common::KEYCODE_DOWN, false}, + {53, 31, 8, Common::KEYCODE_RIGHT, false}, + {51, 29, 6, Common::KEYCODE_UP, false}, // Close button - {56, 30, 0, Common::KEYCODE_INVALID}, + {56, 30, 0, Common::KEYCODE_INVALID, false}, // Function keys (needed for AGI) - {57, 4, -2, Common::KEYCODE_F1}, - {58, 6, -2, Common::KEYCODE_F2}, - {59, 8, -2, Common::KEYCODE_F3}, - {60, 10, -2, Common::KEYCODE_F4}, - {61, 14, -2, Common::KEYCODE_F5}, - {62, 16, -2, Common::KEYCODE_F6}, - {63, 18, -2, Common::KEYCODE_F7}, - {64, 20, -2, Common::KEYCODE_F8}, - {65, 24, -2, Common::KEYCODE_F9}, - {66, 26, -2, Common::KEYCODE_F10}, - {67, 28, -2, Common::KEYCODE_F11}, - {68, 30, -2, Common::KEYCODE_F12}, + {57, 4, -2, Common::KEYCODE_F1, false}, + {58, 6, -2, Common::KEYCODE_F2, false}, + {59, 8, -2, Common::KEYCODE_F3, false}, + {60, 10, -2, Common::KEYCODE_F4, false}, + {61, 14, -2, Common::KEYCODE_F5, false}, + {62, 16, -2, Common::KEYCODE_F6, false}, + {63, 18, -2, Common::KEYCODE_F7, false}, + {64, 20, -2, Common::KEYCODE_F8, false}, + {65, 24, -2, Common::KEYCODE_F9, false}, + {66, 26, -2, Common::KEYCODE_F10, false}, + {67, 28, -2, Common::KEYCODE_F11, false}, + {68, 30, -2, Common::KEYCODE_F12, false}, }; int keyboardX; int keyboardY; -int mapBase; -int tileBase; +static int s_mapBase; +static int s_tileBase; u16* baseAddress; @@ -212,7 +212,7 @@ void drawKeyboard(int tileBase, int mapBase, u16* saveSpace) { for (int tile = 0; tile < 94; tile++) { u16* tileAddr = (u16 *) (CHAR_BASE_BLOCK_SUB(tileBase) + ((KEYBOARD_DATA_SIZE) + (tile * 32))); - u8* src = ((u8 *) (::_8x8font_tga_raw)) + 18 + tile * 8; + const u8* src = ((const u8 *) (::_8x8font_tga_raw)) + 18 + tile * 8; for (int y = 0 ; y < 8; y++) { for (int x = 0; x < 2; x++) { @@ -247,8 +247,8 @@ void drawKeyboard(int tileBase, int mapBase, u16* saveSpace) { keyboardX = -2; keyboardY = 2; - DS::mapBase = mapBase; - DS::tileBase = tileBase; + DS::s_mapBase = mapBase; + DS::s_tileBase = tileBase; shiftState = false; capsLockState = false; @@ -314,7 +314,7 @@ bool getKeyboardClosed() { } void setKeyHighlight(int key, bool highlight) { - u16* base = ((u16 *) SCREEN_BASE_BLOCK_SUB(DS::mapBase)); + u16* base = ((u16 *) SCREEN_BASE_BLOCK_SUB(DS::s_mapBase)); if (highlight) { base[(keyboardY + keys[key].y) * 32 + keyboardX + keys[key].x] |= 0x1000; diff --git a/backends/platform/ds/arm9/source/touchkeyboard.h b/backends/platform/ds/arm9/source/touchkeyboard.h index 6ceb83bfc7..33dab253a9 100644 --- a/backends/platform/ds/arm9/source/touchkeyboard.h +++ b/backends/platform/ds/arm9/source/touchkeyboard.h @@ -27,9 +27,11 @@ namespace DS { -static const int NUM_WORDS = 12; -static const int KEYBOARD_DATA_SIZE = 4736 * 2; -static const int KEYBOARD_BOTTOM_Y = 105; +enum { + NUM_WORDS = 12, + KEYBOARD_DATA_SIZE = 4736 * 2, + KEYBOARD_BOTTOM_Y = 105 +}; void createKeyEvent(int keyNum, Common::Event& event); |