diff options
Diffstat (limited to 'backends')
21 files changed, 432 insertions, 425 deletions
diff --git a/backends/events/sdl/sdl-events.cpp b/backends/events/sdl/sdl-events.cpp index 1ea97a6350..6c4774554c 100644 --- a/backends/events/sdl/sdl-events.cpp +++ b/backends/events/sdl/sdl-events.cpp @@ -29,6 +29,7 @@ #include "backends/graphics/graphics.h" #include "common/config-manager.h" #include "common/textconsole.h" +#include "common/fs.h" // FIXME move joystick defines out and replace with confile file options // we should really allow users to map any key to a joystick button @@ -43,8 +44,14 @@ #define JOY_BUT_PERIOD 1 #define JOY_BUT_SPACE 4 #define JOY_BUT_F5 5 +#ifdef ENABLE_VKEYBD +#define JOY_BUT_VKEYBOARD 7 +#endif + #if SDL_VERSION_ATLEAST(2, 0, 0) +#define GAMECONTROLLERDB_FILE "gamecontrollerdb.txt" + static uint32 convUTF8ToUTF32(const char *src) { uint32 utf32 = 0; @@ -63,6 +70,32 @@ static uint32 convUTF8ToUTF32(const char *src) { return utf32; } + +void SdlEventSource::loadGameControllerMappingFile() { + bool loaded = false; + if (ConfMan.hasKey("controller_map_db")) { + Common::FSNode file = Common::FSNode(ConfMan.get("controller_map_db")); + if (file.exists()) { + if (SDL_GameControllerAddMappingsFromFile(file.getPath().c_str()) < 0) + error("File %s not valid: %s", file.getPath().c_str(), SDL_GetError()); + else { + loaded = true; + debug("Game controller DB file loaded: %s", file.getPath().c_str()); + } + } else + warning("Game controller DB file not found: %s", file.getPath().c_str()); + } + if (!loaded && ConfMan.hasKey("extrapath")) { + Common::FSNode dir = Common::FSNode(ConfMan.get("extrapath")); + Common::FSNode file = dir.getChild(GAMECONTROLLERDB_FILE); + if (file.exists()) { + if (SDL_GameControllerAddMappingsFromFile(file.getPath().c_str()) < 0) + error("File %s not valid: %s", file.getPath().c_str(), SDL_GetError()); + else + debug("Game controller DB file loaded: %s", file.getPath().c_str()); + } + } +} #endif SdlEventSource::SdlEventSource() @@ -85,6 +118,7 @@ SdlEventSource::SdlEventSource() if (SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER) == -1) { error("Could not initialize SDL: %s", SDL_GetError()); } + loadGameControllerMappingFile(); #endif openJoystick(joystick_num); @@ -876,6 +910,11 @@ bool SdlEventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) { event.kbd.keycode = Common::KEYCODE_F5; event.kbd.ascii = mapKey(SDLK_F5, (SDLMod)ev.key.keysym.mod, 0); break; +#ifdef ENABLE_VKEYBD + case JOY_BUT_VKEYBOARD: // Toggles virtual keyboard + event.type = Common::EVENT_VIRTUAL_KEYBOARD; + break; +#endif } return true; } @@ -907,6 +946,11 @@ bool SdlEventSource::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) { event.kbd.keycode = Common::KEYCODE_F5; event.kbd.ascii = mapKey(SDLK_F5, (SDLMod)ev.key.keysym.mod, 0); break; +#ifdef ENABLE_VKEYBD + case JOY_BUT_VKEYBOARD: // Toggles virtual keyboard + // Handled in key down + break; +#endif } return true; } diff --git a/backends/events/sdl/sdl-events.h b/backends/events/sdl/sdl-events.h index 2899b584af..b26d4cc6bd 100644 --- a/backends/events/sdl/sdl-events.h +++ b/backends/events/sdl/sdl-events.h @@ -94,6 +94,11 @@ protected: SdlGraphicsManager *_graphicsManager; /** + * Search for a game controller db file and load it. + */ + void loadGameControllerMappingFile(); + + /** * Open the SDL joystick with the specified index * * After this function completes successfully, SDL sends events for the device. diff --git a/backends/fs/amigaos4/amigaos4-fs.cpp b/backends/fs/amigaos4/amigaos4-fs.cpp index 09ba3a1c83..134193a65b 100644 --- a/backends/fs/amigaos4/amigaos4-fs.cpp +++ b/backends/fs/amigaos4/amigaos4-fs.cpp @@ -266,7 +266,7 @@ bool AmigaOSFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, b if (context) { struct ExamineData * pExd = NULL; // NB: No need to free the value after usage, everything will be dealt with by the DirContext release - AmigaOSFilesystemNode *entry ; + AmigaOSFilesystemNode *entry; while ( (pExd = IDOS->ExamineDir(context)) ) { if ( (EXD_IS_FILE(pExd) && ( Common::FSNode::kListFilesOnly == mode )) || (EXD_IS_DIRECTORY(pExd) && ( Common::FSNode::kListDirectoriesOnly == mode )) diff --git a/backends/fs/ds/ds-fs-factory.cpp b/backends/fs/ds/ds-fs-factory.cpp index 98c522f1d6..3ec4a40bd8 100644 --- a/backends/fs/ds/ds-fs-factory.cpp +++ b/backends/fs/ds/ds-fs-factory.cpp @@ -24,9 +24,9 @@ #define FORBIDDEN_SYMBOL_EXCEPTION_FILE #if defined(__DS__) +#include "dsmain.h" //for the isGBAMPAvailable() function #include "backends/fs/ds/ds-fs-factory.h" #include "backends/fs/ds/ds-fs.h" -#include "dsmain.h" //for the isGBAMPAvailable() function namespace Common { DECLARE_SINGLETON(DSFilesystemFactory); diff --git a/backends/fs/ds/ds-fs.cpp b/backends/fs/ds/ds-fs.cpp index 035178dbb4..1df54a983d 100644 --- a/backends/fs/ds/ds-fs.cpp +++ b/backends/fs/ds/ds-fs.cpp @@ -23,12 +23,12 @@ // Disable symbol overrides for FILE as that is used in FLAC headers #define FORBIDDEN_SYMBOL_EXCEPTION_FILE +#include "dsmain.h" #include "common/str.h" #include "common/util.h" //#include <NDS/ARM9/console.h> //basic print funcionality #include "backends/fs/ds/ds-fs.h" #include "backends/fs/stdiostream.h" -#include "dsmain.h" #include "fat/gba_nds_fat.h" #include "common/bufferedstream.h" diff --git a/backends/platform/dc/dc-fs.cpp b/backends/platform/dc/dc-fs.cpp index 1cc7b56710..a4d2675080 100644 --- a/backends/platform/dc/dc-fs.cpp +++ b/backends/platform/dc/dc-fs.cpp @@ -167,5 +167,5 @@ AbstractFSNode *OSystem_Dreamcast::makeCurrentDirectoryFileNode() const { AbstractFSNode *OSystem_Dreamcast::makeFileNodePath(const Common::String &path) const { AbstractFSNode *node = RoninCDFileNode::makeFileNodePath(path); - return (node? node : new RoninCDNonexistingNode(path)); + return (node ? node : new RoninCDNonexistingNode(path)); } diff --git a/backends/platform/ds/arm7/source/main.cpp b/backends/platform/ds/arm7/source/main.cpp index c4a22b8f68..617a1edc87 100644 --- a/backends/platform/ds/arm7/source/main.cpp +++ b/backends/platform/ds/arm7/source/main.cpp @@ -26,7 +26,7 @@ // -- modified by Darkain and others ////////////////////////////////////////////////////////////////////// -//#define USE_LIBCARTRESET +// #define USE_LIBCARTRESET #include <nds.h> @@ -37,7 +37,7 @@ #include <system.h> #include <stdlib.h> #include <string.h> -#include <registers_alt.h> // Needed for SOUND_CR +#include <registers_alt.h> // Needed for SOUND_CR #include <NDS/scummvm_ipc.h> ////////////////////////////////////////////////////////////////////// #ifdef USE_DEBUGGER @@ -54,8 +54,8 @@ #define SCREEN_HEIGHT 192 s32 TOUCH_WIDTH = TOUCH_CAL_X2 - TOUCH_CAL_X1; s32 TOUCH_HEIGHT = TOUCH_CAL_Y2 - TOUCH_CAL_Y1; -s32 TOUCH_OFFSET_X = ( ((SCREEN_WIDTH -60) * TOUCH_CAL_X1) / TOUCH_WIDTH ) - 28; -s32 TOUCH_OFFSET_Y = ( ((SCREEN_HEIGHT-60) * TOUCH_CAL_Y1) / TOUCH_HEIGHT ) - 28; +s32 TOUCH_OFFSET_X = ( ((SCREEN_WIDTH - 60) * TOUCH_CAL_X1) / TOUCH_WIDTH ) - 28; +s32 TOUCH_OFFSET_Y = ( ((SCREEN_HEIGHT - 60) * TOUCH_CAL_Y1) / TOUCH_HEIGHT ) - 28; vu8 *soundData; @@ -71,163 +71,157 @@ int temp; int adpcmBufferNum = 0; // those are pixel positions of the two points you click when calibrating -#define TOUCH_CNTRL_X1 (*(vu8 *)0x027FFCDC) -#define TOUCH_CNTRL_Y1 (*(vu8 *)0x027FFCDD) -#define TOUCH_CNTRL_X2 (*(vu8 *)0x027FFCE2) -#define TOUCH_CNTRL_Y2 (*(vu8 *)0x027FFCE3) - - -////////////////////////////////////////////////////////////////////// +#define TOUCH_CNTRL_X1 (*(vu8 *)0x027FFCDC) +#define TOUCH_CNTRL_Y1 (*(vu8 *)0x027FFCDD) +#define TOUCH_CNTRL_X2 (*(vu8 *)0x027FFCE2) +#define TOUCH_CNTRL_Y2 (*(vu8 *)0x027FFCE3) /* -void startSound(int sampleRate, const void *data, uint32 bytes, u8 channel=0, u8 vol=0x7F, u8 pan=63, u8 format=0) { - SCHANNEL_TIMER(channel) = SOUND_FREQ(sampleRate); - SCHANNEL_SOURCE(channel) = (uint32)data; - SCHANNEL_LENGTH(channel) = bytes; - SCHANNEL_CR(channel) = SOUND_ENABLE | SOUND_ONE_SHOT | SOUND_VOL(vol) | SOUND_PAN(pan) | (format==1?SOUND_8BIT:SOUND_16BIT); +void startSound(int sampleRate, const void *data, uint32 bytes, u8 channel = 0, u8 vol = 0x7F, u8 pan = 63, u8 format = 0) { + SCHANNEL_TIMER(channel) = SOUND_FREQ(sampleRate); + SCHANNEL_SOURCE(channel) = (uint32)data; + SCHANNEL_LENGTH(channel) = bytes; + SCHANNEL_CR(channel) = SOUND_ENABLE | SOUND_ONE_SHOT | SOUND_VOL(vol) | SOUND_PAN(pan) | (format==1?SOUND_8BIT:SOUND_16BIT); } - s8 getFreeSoundChannel() { - for (int i=0; i<16; i++) { - if ( (SCHANNEL_CR(i) & SOUND_ENABLE) == 0 ) return i; - } - return -1; + for (int i = 0; i < 16; i++) { + if ( (SCHANNEL_CR(i) & SOUND_ENABLE) == 0 ) + return i; + } + return -1; } */ - s8 getFreeSoundChannel() { -// return 0; - for (int i=0; i<16; i++) { - if ( (SCHANNEL_CR(i) & SCHANNEL_ENABLE) == 0 ) return i; - } - return -1; + // return 0; + for (int i = 0; i < 16; i++) { + if ( (SCHANNEL_CR(i) & SCHANNEL_ENABLE) == 0 ) + return i; + } + return -1; } -void startSound(int sampleRate, const void *data, uint32 bytes, u8 channel=0, u8 vol=0x7F, u8 pan=63, u8 format=0) { -// REG_IME = IME_DISABLE; +void startSound(int sampleRate, const void *data, uint32 bytes, u8 channel = 0, u8 vol = 0x7F, u8 pan = 63, u8 format = 0) { + // REG_IME = IME_DISABLE; - channel = getFreeSoundChannel(); -/* if (format == 2) { - channel = 1; - } else { - channel = 0; - }*/ + channel = getFreeSoundChannel(); + /* + if (format == 2) { + channel = 1; + } else { + channel = 0; + } + */ - if (channel > 1) channel = 1; + if (channel > 1) + channel = 1; - bytes &= ~7; // Multiple of 4 bytes! -// bytes += 4; + bytes &= ~7; // Multiple of 4 bytes! + // bytes += 4; - SCHANNEL_CR(channel) = 0; - SCHANNEL_TIMER(channel) = SOUND_FREQ(sampleRate); - SCHANNEL_SOURCE(channel) = ((uint32) (data)); - SCHANNEL_LENGTH(channel) = ((bytes & 0x7FFFFFFF) >> 2); - SCHANNEL_REPEAT_POINT(channel) = 0; + SCHANNEL_CR(channel) = 0; + SCHANNEL_TIMER(channel) = SOUND_FREQ(sampleRate); + SCHANNEL_SOURCE(channel) = (uint32)data; + SCHANNEL_LENGTH(channel) = (bytes & 0x7FFFFFFF) >> 2; + SCHANNEL_REPEAT_POINT(channel) = 0; - SCHANNEL_CR(channel + 2) = 0; - SCHANNEL_TIMER(channel + 2) = SOUND_FREQ(sampleRate); - SCHANNEL_SOURCE(channel + 2) = ((uint32) (data)); - SCHANNEL_LENGTH(channel + 2) = ((bytes & 0x7FFFFFFF) >> 2); - SCHANNEL_REPEAT_POINT(channel + 2) = 0; + SCHANNEL_CR(channel + 2) = 0; + SCHANNEL_TIMER(channel + 2) = SOUND_FREQ(sampleRate); + SCHANNEL_SOURCE(channel + 2) = (uint32)data; + SCHANNEL_LENGTH(channel + 2) = (bytes & 0x7FFFFFFF) >> 2; + SCHANNEL_REPEAT_POINT(channel + 2) = 0; - uint32 flags = SCHANNEL_ENABLE | SOUND_VOL(vol) | SOUND_PAN(pan); + uint32 flags = SCHANNEL_ENABLE | SOUND_VOL(vol) | SOUND_PAN(pan); - switch (format) { + switch (format) { case 1: { flags |= SOUND_FORMAT_8BIT; - flags |= SOUND_REPEAT;// | (1 << 15); + flags |= SOUND_REPEAT; // | (1 << 15); break; } case 0: { flags |= SOUND_FORMAT_16BIT; - flags |= SOUND_REPEAT;// | (1 << 15); + flags |= SOUND_REPEAT; // | (1 << 15); break; } case 2: { flags |= SOUND_FORMAT_ADPCM; - flags |= SOUND_ONE_SHOT;// | (1 << 15); + flags |= SOUND_ONE_SHOT; // | (1 << 15); - SCHANNEL_SOURCE(channel) = (unsigned int) IPC->adpcm.buffer[0]; - //bytes += 32; - SCHANNEL_LENGTH(channel) = (((bytes + 4) & 0x7FFFFFFF) >> 2); + SCHANNEL_SOURCE(channel) = (unsigned int)IPC->adpcm.buffer[0]; + // bytes += 32; + SCHANNEL_LENGTH(channel) = ((bytes + 4) & 0x7FFFFFFF) >> 2; SCHANNEL_CR(channel + 1) = 0; - SCHANNEL_SOURCE(channel + 1) = (unsigned int) IPC->adpcm.buffer[0]; - SCHANNEL_LENGTH(channel + 1) = (((bytes + 4) & 0x7FFFFFFF) >> 2); - SCHANNEL_TIMER(channel + 1) = SOUND_FREQ(sampleRate); + SCHANNEL_SOURCE(channel + 1) = (unsigned int)IPC->adpcm.buffer[0]; + SCHANNEL_LENGTH(channel + 1) = ((bytes + 4) & 0x7FFFFFFF) >> 2; + SCHANNEL_TIMER(channel + 1) = SOUND_FREQ(sampleRate); SCHANNEL_REPEAT_POINT(channel + 1) = 0; SCHANNEL_CR(channel + 1) = flags; temp = bytes; adpcmBufferNum = 0; break; } - } - - -// if (bytes & 0x80000000) { -// flags |= SOUND_REPEAT; -// } else { -// } - - - + } - soundData = (vu8 *) data; + /* + if (bytes & 0x80000000) { + flags |= SOUND_REPEAT; + } else { + } + */ - SCHANNEL_CR(channel) = flags; - SCHANNEL_CR(channel + 2) = flags; + soundData = (vu8 *)data; + SCHANNEL_CR(channel) = flags; + SCHANNEL_CR(channel + 2) = flags; + if (channel == 0) { + for (volatile int i = 0; i < 16384 * 2; i++) { + // Delay loop - this makes everything stay in sync! + } - if (channel == 0) { - for (volatile int i = 0; i < 16384 * 2; i++) { - // Delay loop - this makes everything stay in sync! - } + TIMER0_CR = 0; + TIMER0_DATA = SOUND_FREQ(sampleRate) * 2; + TIMER0_CR = TIMER_ENABLE | TIMER_DIV_1; - TIMER0_CR = 0; - TIMER0_DATA = SOUND_FREQ(sampleRate) * 2; - TIMER0_CR = TIMER_ENABLE | TIMER_DIV_1; + TIMER1_CR = 0; + TIMER1_DATA = 65536 - ((bytes & 0x7FFFFFFF) >> 3); // Trigger four times during the length of the buffer + TIMER1_CR = TIMER_ENABLE | TIMER_IRQ_REQ | TIMER_CASCADE; - TIMER1_CR = 0; - TIMER1_DATA = 65536 - ((bytes & 0x7FFFFFFF) >> 3); // Trigger four times during the length of the buffer - TIMER1_CR = TIMER_ENABLE | TIMER_IRQ_REQ | TIMER_CASCADE; + playingSection = 0; + } else { + for (volatile int i = 0; i < 16384 * 2; i++) { + // Delay loop - this makes everything stay in sync! + } - playingSection = 0; - } else { - for (volatile int i = 0; i < 16384 * 2; i++) { - // Delay loop - this makes everything stay in sync! - } + TIMER2_CR = 0; + TIMER2_DATA = SOUND_FREQ(sampleRate) * 2; + TIMER2_CR = TIMER_ENABLE | TIMER_DIV_1; - TIMER2_CR = 0; - TIMER2_DATA = SOUND_FREQ(sampleRate) * 2; - TIMER2_CR = TIMER_ENABLE | TIMER_DIV_1; + TIMER3_CR = 0; + TIMER3_DATA = 65536 - ((bytes & 0x7FFFFFFF) >> 3); // Trigger four times during the length of the buffer + TIMER3_CR = TIMER_ENABLE | TIMER_IRQ_REQ | TIMER_CASCADE; - TIMER3_CR = 0; - TIMER3_DATA = 65536 - ((bytes & 0x7FFFFFFF) >> 3); // Trigger four times during the length of the buffer - TIMER3_CR = TIMER_ENABLE | TIMER_IRQ_REQ | TIMER_CASCADE; + for (int r = 0; r < 4; r++) { + // IPC->streamFillNeeded[r] = true; + } - for (int r = 0; r < 4; r++) { -// IPC->streamFillNeeded[r] = true; + IPC->streamPlayingSection = 0; } - IPC->streamPlayingSection = 0; - } - - - -// IPC->fillSoundFirstHalf = true; -// IPC->fillSoundSecondHalf = true; -// soundFirstHalf = true; + // IPC->fillSoundFirstHalf = true; + // IPC->fillSoundSecondHalf = true; + // soundFirstHalf = true; -// REG_IME = IME_ENABLE; + // REG_IME = IME_ENABLE; } void stopSound(int chan) { - SCHANNEL_CR(chan) = 0; + SCHANNEL_CR(chan) = 0; } void DummyHandler() { @@ -235,146 +229,132 @@ void DummyHandler() { } void powerManagerWrite(uint32 command, u32 data, bool enable) { - - uint16 result; - SerialWaitBusy(); - - // Write the command and wait for it to complete - REG_SPICNT = SPI_ENABLE | SPI_BAUD_1MHz | (1 << 11); - REG_SPIDATA = command | 0x80; - SerialWaitBusy(); - - // Write the second command and clock in the data - REG_SPICNT = SPI_ENABLE | SPI_BAUD_1MHz; - REG_SPIDATA = 0; - SerialWaitBusy(); - - result = REG_SPIDATA & 0xFF; - - - - // Write the command and wait for it to complete - REG_SPICNT = SPI_ENABLE | SPI_BAUD_1MHz | (1 << 11); - REG_SPIDATA = command; - SerialWaitBusy(); - - // Write the second command and clock in the data - REG_SPICNT = SPI_ENABLE | SPI_BAUD_1MHz; - REG_SPIDATA = enable? (result | data): (result & ~data); - SerialWaitBusy(); + uint16 result; + SerialWaitBusy(); + + // Write the command and wait for it to complete + REG_SPICNT = SPI_ENABLE | SPI_BAUD_1MHz | (1 << 11); + REG_SPIDATA = command | 0x80; + SerialWaitBusy(); + + // Write the second command and clock in the data + REG_SPICNT = SPI_ENABLE | SPI_BAUD_1MHz; + REG_SPIDATA = 0; + SerialWaitBusy(); + + result = REG_SPIDATA & 0xFF; + + // Write the command and wait for it to complete + REG_SPICNT = SPI_ENABLE | SPI_BAUD_1MHz | (1 << 11); + REG_SPIDATA = command; + SerialWaitBusy(); + + // Write the second command and clock in the data + REG_SPICNT = SPI_ENABLE | SPI_BAUD_1MHz; + REG_SPIDATA = enable ? (result | data) : (result & ~data); + SerialWaitBusy(); } /* void performSleep() { + powerManagerWrite(0, 0x30, true); - powerManagerWrite(0, 0x30, true); - - // Here, I set up a dummy interrupt handler, then trigger all interrupts. - // These are just aknowledged by the handler without doing anything else. - // Why? Because without it the sleep mode will only happen once, and then - // never again. I got the idea from reading the MoonShell source. - IME = 0; - u32 irq = (u32) IRQ_HANDLER; - IRQ_HANDLER = DummyHandler; - IF = ~0; - IME = 1; + // Here, I set up a dummy interrupt handler, then trigger all interrupts. + // These are just aknowledged by the handler without doing anything else. + // Why? Because without it the sleep mode will only happen once, and then + // never again. I got the idea from reading the MoonShell source. + IME = 0; + u32 irq = (u32)IRQ_HANDLER; + IRQ_HANDLER = DummyHandler; + IF = ~0; + IME = 1; + // Now save which interrupts are enabled, then set only the screens unfolding + // interrupt to be enabled, so that the first interrupt that happens is the + // one I want. + int saveInts = IE; - // Now save which interrupts are enabled, then set only the screens unfolding - // interrupt to be enabled, so that the first interrupt that happens is the - // one I want. - int saveInts = IE; + IE = IRQ_TIMER0; // Screens unfolding interrupt + // Now call the sleep function in the bios + bool b; + do { + TIMER0_CR = 0; + TIMER0_DATA = TIMER_FREQ(20); + TIMER0_CR = TIMER_ENABLE | TIMER_DIV_64; + swiDelay(100); - IE = IRQ_TIMER0; // Screens unfolding interrupt + swiSleep(); - // Now call the sleep function in the bios - bool b; - do { - TIMER0_CR = 0; - TIMER0_DATA = TIMER_FREQ(20); - TIMER0_CR = TIMER_ENABLE | TIMER_DIV_64; + swiDelay(100); - swiDelay(100); - - swiSleep(); - - swiDelay(100); - - powerManagerWrite(0, 0x30, b = !b); - } while (!(TIMER0_CR & TIMER_ENABLE)); - - TIMER0_CR = 0; - - // We're back from sleep, now restore the interrupt state and IRQ handler - IRQ_HANDLER = (void (*)()) irq; - IE = saveInts; - IF = ~0; - IME = 1; + powerManagerWrite(0, 0x30, b = !b); + } while (!(TIMER0_CR & TIMER_ENABLE)); + TIMER0_CR = 0; + // We're back from sleep, now restore the interrupt state and IRQ handler + IRQ_HANDLER = (void (*)())irq; + IE = saveInts; + IF = ~0; + IME = 1; - powerManagerWrite(0, 0x30, false); + powerManagerWrite(0, 0x30, false); } - */ -void performSleep() { - powerManagerWrite(0, 0x30, true); - IPC->performArm9SleepMode = true; // Tell ARM9 to sleep +void performSleep() { + powerManagerWrite(0, 0x30, true); -// u32 irq = (u32) IRQ_HANDLER; -// IRQ_HANDLER = DummyHandler; -// POWER_CR &= ~POWER_SOUND; + IPC->performArm9SleepMode = true; // Tell ARM9 to sleep -// int saveInts = REG_IE; -// REG_IE = (1 << 22) | IRQ_VBLANK; // Lid open -// *((u32 *) (0x0380FFF8)) = *((u32 *) (0x0380FFF8)) | (REG_IE & REG_IF); -// VBLANK_INTR_WAIT_FLAGS = IRQ_VBLANK; + // u32 irq = (u32)IRQ_HANDLER; + // IRQ_HANDLER = DummyHandler; + // POWER_CR &= ~POWER_SOUND; + // int saveInts = REG_IE; + // REG_IE = (1 << 22) | IRQ_VBLANK; // Lid open + // *((u32 *)(0x0380FFF8)) = *((u32 *)(0x0380FFF8)) | (REG_IE & REG_IF); + // VBLANK_INTR_WAIT_FLAGS = IRQ_VBLANK; - int r = 0; - while ((REG_KEYXY & (1 << 7))) { // Wait for lid to open - swiDelay(1000000); - r++; - } + int r = 0; + while ((REG_KEYXY & (1 << 7))) { // Wait for lid to open + swiDelay(1000000); + r++; + } -// IRQ_HANDLER = (void (*)()) irq; - IPC->performArm9SleepMode = false; // Tell ARM9 to wake up -// REG_IE = saveInts; + // IRQ_HANDLER = (void (*)())irq; + IPC->performArm9SleepMode = false; // Tell ARM9 to wake up + // REG_IE = saveInts; -// POWER_CR |= POWER_SOUND; + // POWER_CR |= POWER_SOUND; - powerManagerWrite(0, 0x30, false); + powerManagerWrite(0, 0x30, false); } void powerOff() { powerManagerWrite(0, 0x40, true); } -////////////////////////////////////////////////////////////////////// - - void InterruptTimer1() { - IPC->fillNeeded[playingSection] = true; soundFilled[playingSection] = false; if (playingSection == 3) { -// IME = IME_DISABLED; + // IME = IME_DISABLED; - // while (SCHANNEL_CR(0) & SCHANNEL_ENABLE) { - // } -// SCHANNEL_CR(0) &= ~SCHANNEL_ENABLE; + // while (SCHANNEL_CR(0) & SCHANNEL_ENABLE) { + // } + // SCHANNEL_CR(0) &= ~SCHANNEL_ENABLE; -// SCHANNEL_CR(0) |= SCHANNEL_ENABLE; -// TIMER1_CR = 0; -// TIMER1_CR = TIMER_ENABLE | TIMER_IRQ_REQ | TIMER_CASCADE; + // SCHANNEL_CR(0) |= SCHANNEL_ENABLE; + // TIMER1_CR = 0; + // TIMER1_CR = TIMER_ENABLE | TIMER_IRQ_REQ | TIMER_CASCADE; playingSection = 0; -// IME = IME_ENABLED; + // IME = IME_ENABLED; } else { playingSection++; } @@ -395,8 +375,8 @@ void InterruptTimer1() { } void InterruptTimer3() { - while (IPC->adpcm.semaphore); // Wait for buffer to become free if needed - IPC->adpcm.semaphore = true; // Lock the buffer structure to prevent clashing with the ARM7 + while (IPC->adpcm.semaphore); // Wait for buffer to become free if needed + IPC->adpcm.semaphore = true; // Lock the buffer structure to prevent clashing with the ARM7 IPC->streamFillNeeded[IPC->streamPlayingSection] = true; @@ -406,153 +386,145 @@ void InterruptTimer3() { IPC->streamPlayingSection++; } - IPC->adpcm.semaphore = false; } -// IPC->performArm9SleepMode = false; - - // precalculate some values -// static int16 TOUCH_WIDTH = TOUCH_CAL_X2 - TOUCH_CAL_X1; -// static int16 TOUCH_HEIGHT = TOUCH_CAL_Y2 - TOUCH_CAL_Y1; -// static int16 CNTRL_WIDTH = TOUCH_CNTRL_X2 - (TOUCH_CNTRL_X1 - 8); -// static int16 CNTRL_HEIGHT = TOUCH_CNTRL_Y2 - (TOUCH_CNTRL_Y1 - 8); - - +// IPC->performArm9SleepMode = false; +// precalculate some values +// static int16 TOUCH_WIDTH = TOUCH_CAL_X2 - TOUCH_CAL_X1; +// static int16 TOUCH_HEIGHT = TOUCH_CAL_Y2 - TOUCH_CAL_Y1; +// static int16 CNTRL_WIDTH = TOUCH_CNTRL_X2 - (TOUCH_CNTRL_X1 - 8); +// static int16 CNTRL_HEIGHT = TOUCH_CNTRL_Y2 - (TOUCH_CNTRL_Y1 - 8); void InterruptVBlank() { - uint16 but=0, x=0, y=0, xpx=0, ypx=0, z1=0, z2=0, batt=0, aux=0; - int t1=0, t2=0; - uint32 temp=0; - uint8 ct[sizeof(IPC->curtime)]; + uint16 but = 0, x = 0, y = 0, xpx = 0, ypx = 0, z1 = 0, z2 = 0, batt = 0, aux = 0; + int t1 = 0, t2 = 0; + uint32 temp = 0; + uint8 ct[sizeof(IPC->curtime)]; static int heartbeat = 0; - // Update the heartbeat - heartbeat++; - - // Read the X/Y buttons and the /PENIRQ line - but = REG_KEYXY; - if (!(but & 0x40)) { - // Read the touch screen - touchPosition p; - touchReadXY(&p); - -// x = touchRead(TSC_MEASURE_X); - // y = touchRead(TSC_MEASURE_Y); + // Update the heartbeat + heartbeat++; - x = p.rawx; - y = p.rawy; + // Read the X/Y buttons and the /PENIRQ line + but = REG_KEYXY; + if (!(but & 0x40)) { + // Read the touch screen + touchPosition p; + touchReadXY(&p); - xpx = p.px; - ypx = p.py; + // x = touchRead(TSC_MEASURE_X); + // y = touchRead(TSC_MEASURE_Y); -// xpx = ( ((SCREEN_WIDTH -60) * x) / TOUCH_WIDTH ) - TOUCH_OFFSET_X; - // ypx = ( ((SCREEN_HEIGHT-60) * y) / TOUCH_HEIGHT ) - TOUCH_OFFSET_Y; + x = p.rawx; + y = p.rawy; -// xpx = (IPC->touchX - (int16) TOUCH_CAL_X1) * CNTRL_WIDTH / TOUCH_WIDTH + (int16) (TOUCH_CNTRL_X1 - 8); - // ypx = (IPC->touchY - (int16) TOUCH_CAL_Y1) * CNTRL_HEIGHT / TOUCH_HEIGHT + (int16) (TOUCH_CNTRL_Y1 - 8); + // xpx = p.px; + // ypx = p.py; + xpx = ( ((SCREEN_WIDTH - 60) * x) / TOUCH_WIDTH ) - TOUCH_OFFSET_X; + ypx = ( ((SCREEN_HEIGHT - 60) * y) / TOUCH_HEIGHT ) - TOUCH_OFFSET_Y; - z1 = touchRead(TSC_MEASURE_Z1); - z2 = touchRead(TSC_MEASURE_Z2); - } + // xpx = (IPC->touchX - (int16) TOUCH_CAL_X1) * CNTRL_WIDTH / TOUCH_WIDTH + (int16) (TOUCH_CNTRL_X1 - 8); + // ypx = (IPC->touchY - (int16) TOUCH_CAL_Y1) * CNTRL_HEIGHT / TOUCH_HEIGHT + (int16) (TOUCH_CNTRL_Y1 - 8); - if (but & (1 << 7)) { // Check if screen is folded - needSleep = true; + z1 = touchRead(TSC_MEASURE_Z1); + z2 = touchRead(TSC_MEASURE_Z2); } + // Check if screen is folded + if (but & (1 << 7)) { + needSleep = true; + } - batt = touchRead(TSC_MEASURE_BATTERY); - aux = touchRead(TSC_MEASURE_AUX); - - // Read the time - rtcGetTime((uint8 *)ct); - BCDToInteger((uint8 *)&(ct[1]), 7); - - // Read the temperature - temp = touchReadTemperature(&t1, &t2); - - - // Update the IPC struct - IPC->heartbeat = heartbeat; - IPC->buttons = but; - IPC->touchX = x; - IPC->touchY = y; - IPC->touchXpx = xpx; - IPC->touchYpx = ypx; - IPC->touchZ1 = z1; - IPC->touchZ2 = z2; - IPC->battery = batt; - IPC->aux = aux; - - for (u32 i=0; i<sizeof(ct); i++) { - IPC->curtime[i] = ct[i]; - } - - IPC->temperature = temp; - IPC->tdiode1 = t1; - IPC->tdiode2 = t2; - - + batt = touchRead(TSC_MEASURE_BATTERY); + aux = touchRead(TSC_MEASURE_AUX); + + // Read the time + rtcGetTime((uint8 *)ct); + BCDToInteger((uint8 *)&(ct[1]), 7); + + // Read the temperature + temp = touchReadTemperature(&t1, &t2); + + // Update the IPC struct + IPC->heartbeat = heartbeat; + IPC->buttons = but; + IPC->touchX = x; + IPC->touchY = y; + IPC->touchXpx = xpx; + IPC->touchYpx = ypx; + IPC->touchZ1 = z1; + IPC->touchZ2 = z2; + IPC->battery = batt; + IPC->aux = aux; + + for (u32 i = 0; i < sizeof(ct); i++) { + IPC->curtime[i] = ct[i]; + } - //sound code :) - TransferSound *snd = IPC->soundData; - IPC->soundData = 0; - if (snd) { - for (int i=0; i<snd->count; i++) { - s8 chan = getFreeSoundChannel(); - if (snd->data[i].rate > 0) { - if (chan >= 0) { - startSound(snd->data[i].rate, snd->data[i].data, snd->data[i].len, chan, snd->data[i].vol, snd->data[i].pan, snd->data[i].format); + IPC->temperature = temp; + IPC->tdiode1 = t1; + IPC->tdiode2 = t2; + + // sound code :) + TransferSound *snd = IPC->soundData; + IPC->soundData = 0; + if (snd) { + for (int i = 0; i < snd->count; i++) { + s8 chan = getFreeSoundChannel(); + if (snd->data[i].rate > 0) { + if (chan >= 0) { + startSound(snd->data[i].rate, snd->data[i].data, snd->data[i].len, chan, snd->data[i].vol, snd->data[i].pan, snd->data[i].format); + } + } else { + stopSound(-snd->data[i].rate); } - } else { - stopSound(-snd->data[i].rate); } - } - } - + } - #ifdef USE_DEBUGGER - Wifi_Update(); // update wireless in vblank - #endif +#ifdef USE_DEBUGGER + Wifi_Update(); // update wireless in vblank +#endif } -////////////////////////////////////////////////////////////////////// - - #ifdef USE_DEBUGGER - // callback to allow wifi library to notify arm9 void arm7_synctoarm9() { // send fifo message - REG_IPC_FIFO_TX = 0x87654321; + REG_IPC_FIFO_TX = 0x87654321; } + // interrupt handler to allow incoming notifications from arm9 void arm7_fifo() { // check incoming fifo messages - u32 msg = REG_IPC_FIFO_RX; - if (msg==0x87654321) Wifi_Sync(); + u32 msg = REG_IPC_FIFO_RX; + if (msg == 0x87654321) + Wifi_Sync(); } - - void initDebugger() { - // set up the wifi irq irqSet(IRQ_WIFI, Wifi_Interrupt); // set up wifi interrupt irqEnable(IRQ_WIFI); - //get them talking together + // get them talking together // sync with arm9 and init wifi u32 fifo_temp; while (1) { // wait for magic number - while (REG_IPC_FIFO_CR&IPC_FIFO_RECV_EMPTY) swiWaitForVBlank(); - fifo_temp=REG_IPC_FIFO_RX; - if (fifo_temp==0x12345678) break; + while (REG_IPC_FIFO_CR & IPC_FIFO_RECV_EMPTY) + swiWaitForVBlank(); + + fifo_temp = REG_IPC_FIFO_RX; + + if (fifo_temp == 0x12345678) + break; } - while (REG_IPC_FIFO_CR&IPC_FIFO_RECV_EMPTY) swiWaitForVBlank(); - fifo_temp=REG_IPC_FIFO_RX; // give next value to wifi_init + while (REG_IPC_FIFO_CR & IPC_FIFO_RECV_EMPTY) + swiWaitForVBlank(); + + fifo_temp = REG_IPC_FIFO_RX; // give next value to wifi_init Wifi_Init(fifo_temp); irqSet(IRQ_FIFO_NOT_EMPTY,arm7_fifo); // set up fifo irq @@ -561,7 +533,6 @@ void initDebugger() { Wifi_SetSyncHandler(arm7_synctoarm9); // allow wifi lib to notify arm9 // arm7 wifi init complete - } #endif @@ -571,82 +542,75 @@ void reboot() { } #endif - int main(int argc, char ** argv) { - - #ifdef USE_DEBUGGER - REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR; + REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR; #endif - // Reset the clock if needed - rtcReset(); - - //enable sound -// powerOn(POWER_SOUND); - SOUND_CR = SOUND_ENABLE | SOUND_VOL(0x7F); - IPC->soundData = 0; - IPC->reset = false; - - - //fifoInit(); + // Reset the clock if needed + rtcReset(); - for (int r = 0; r < 8; r++) { - IPC->adpcm.arm7Buffer[r] = (u8 *) malloc(512); - } + // enable sound + // powerOn(POWER_SOUND); + SOUND_CR = SOUND_ENABLE | SOUND_VOL(0x7F); + IPC->soundData = 0; + IPC->reset = false; - for (int r = 0; r < 4; r++) { - soundFilled[r] = false; - } + // fifoInit(); + for (int r = 0; r < 8; r++) { + IPC->adpcm.arm7Buffer[r] = (u8 *)malloc(512); + } - // Set up the interrupt handler + for (int r = 0; r < 4; r++) { + soundFilled[r] = false; + } - irqInit(); + // Set up the interrupt handler - irqSet(IRQ_VBLANK, InterruptVBlank); - irqEnable(IRQ_VBLANK); + irqInit(); - irqSet(IRQ_TIMER1, InterruptTimer1); - irqEnable(IRQ_TIMER1); + irqSet(IRQ_VBLANK, InterruptVBlank); + irqEnable(IRQ_VBLANK); - irqSet(IRQ_TIMER3, InterruptTimer3); - irqEnable(IRQ_TIMER3); + irqSet(IRQ_TIMER1, InterruptTimer1); + irqEnable(IRQ_TIMER1); -/* REG_IME = 0; - IRQ_HANDLER = &InterruptHandler; - REG_IE = IRQ_VBLANK | IRQ_TIMER1 | IRQ_TIMER3; - REG_IF = ~0; - DISP_SR = DISP_VBLANK_IRQ; - REG_IME = 1; - */ + irqSet(IRQ_TIMER3, InterruptTimer3); + irqEnable(IRQ_TIMER3); + /* + REG_IME = 0; + IRQ_HANDLER = &InterruptHandler; + REG_IE = IRQ_VBLANK | IRQ_TIMER1 | IRQ_TIMER3; + REG_IF = ~0; + DISP_SR = DISP_VBLANK_IRQ; + REG_IME = 1; + */ #ifdef USE_DEBUGGER - initDebugger(); + initDebugger(); #endif - // Keep the ARM7 out of main RAM - while ((1)) { - if (needSleep) { - performSleep(); - needSleep = false; - } + // Keep the ARM7 out of main RAM + while ((1)) { + if (needSleep) { + performSleep(); + needSleep = false; + } #ifdef USE_LIBCARTRESET - if (passmeloopQuery()) { - reboot(); - } + if (passmeloopQuery()) { + reboot(); + } #endif - if (IPC->reset) { - powerOff(); + if (IPC->reset) { + powerOff(); + } + + swiWaitForVBlank(); } - swiWaitForVBlank(); - } - return 0; + return 0; } - - -////////////////////////////////////////////////////////////////////// diff --git a/backends/platform/ds/arm9/source/cdaudio.cpp b/backends/platform/ds/arm9/source/cdaudio.cpp index c963f4d8bd..3952eeb6ab 100644 --- a/backends/platform/ds/arm9/source/cdaudio.cpp +++ b/backends/platform/ds/arm9/source/cdaudio.cpp @@ -23,10 +23,10 @@ // Disable symbol overrides for FILE as that is used in FLAC headers #define FORBIDDEN_SYMBOL_EXCEPTION_FILE +#include "dsmain.h" #include "cdaudio.h" #include "backends/fs/ds/ds-fs.h" #include "common/config-manager.h" -#include "dsmain.h" #include "NDS/scummvm_ipc.h" #define WAV_FORMAT_IMA_ADPCM 0x14 diff --git a/backends/platform/ds/arm9/source/dsmain.cpp b/backends/platform/ds/arm9/source/dsmain.cpp index b7c9c108a6..c6d7d62f22 100644 --- a/backends/platform/ds/arm9/source/dsmain.cpp +++ b/backends/platform/ds/arm9/source/dsmain.cpp @@ -68,8 +68,9 @@ // - Try discworld? -#define FORBIDDEN_SYMBOL_ALLOW_ALL - +// Allow use of stuff in <nds.h> +#define FORBIDDEN_SYMBOL_EXCEPTION_printf +#define FORBIDDEN_SYMBOL_EXCEPTION_unistd_h #include <nds.h> @@ -439,12 +440,12 @@ void playSound(const void *data, u32 length, bool loop, bool adpcm, int rate) { soundControl.count = 0; } - soundControl.data[soundControl.count].data = data; - soundControl.data[soundControl.count].len = length | (loop? 0x80000000: 0x00000000); - soundControl.data[soundControl.count].rate = rate; // 367 samples per frame - soundControl.data[soundControl.count].pan = 64; - soundControl.data[soundControl.count].vol = 127; - soundControl.data[soundControl.count].format = adpcm? 2: 0; + soundControl.data[soundControl.count].data = data; + soundControl.data[soundControl.count].len = length | (loop ? 0x80000000 : 0x00000000); + soundControl.data[soundControl.count].rate = rate; // 367 samples per frame + soundControl.data[soundControl.count].pan = 64; + soundControl.data[soundControl.count].vol = 127; + soundControl.data[soundControl.count].format = adpcm ? 2 : 0; soundControl.count++; @@ -573,7 +574,7 @@ void initGame() { s_currentGame = &gameList[0]; // Default game for (int r = 0; r < NUM_SUPPORTED_GAMES; r++) { - if (!stricmp(gameName, gameList[r].gameId)) { + if (!scumm_stricmp(gameName, gameList[r].gameId)) { s_currentGame = &gameList[r]; // consolePrintf("Game list num: %d\n", r); } @@ -640,7 +641,7 @@ void displayMode8Bit() { displayModeIs8Bit = true; if (isCpuScalerEnabled()) { - videoSetMode(MODE_5_2D | (consoleEnable? DISPLAY_BG0_ACTIVE: 0) | DISPLAY_BG3_ACTIVE | DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D | DISPLAY_SPR_1D_BMP); + videoSetMode(MODE_5_2D | (consoleEnable ? DISPLAY_BG0_ACTIVE : 0) | DISPLAY_BG3_ACTIVE | DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D | DISPLAY_SPR_1D_BMP); videoSetModeSub(MODE_3_2D /*| DISPLAY_BG0_ACTIVE*/ | DISPLAY_BG3_ACTIVE | DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D | DISPLAY_SPR_1D_BMP); //sub bg 0 will be used to print text vramSetBankA(VRAM_A_MAIN_BG_0x06000000); @@ -659,7 +660,7 @@ void displayMode8Bit() { BG3_YDY = (int) ((200.0f / 192.0f) * 256); } else { - videoSetMode(MODE_5_2D | (consoleEnable? DISPLAY_BG0_ACTIVE: 0) | DISPLAY_BG3_ACTIVE | DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D | DISPLAY_SPR_1D_BMP); + videoSetMode(MODE_5_2D | (consoleEnable ? DISPLAY_BG0_ACTIVE : 0) | DISPLAY_BG3_ACTIVE | DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D | DISPLAY_SPR_1D_BMP); videoSetModeSub(MODE_3_2D /*| DISPLAY_BG0_ACTIVE*/ | DISPLAY_BG3_ACTIVE | DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D | DISPLAY_SPR_1D_BMP); //sub bg 0 will be used to print text vramSetBankA(VRAM_A_MAIN_BG_0x06000000); @@ -690,7 +691,7 @@ void displayMode8Bit() { consoleInit(NULL, 0, BgType_Text4bpp, BgSize_T_256x256, 2, 0, true, true); // Set this again because consoleinit resets it - videoSetMode(MODE_5_2D | (consoleEnable? DISPLAY_BG0_ACTIVE: 0) | DISPLAY_BG3_ACTIVE | DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D | DISPLAY_SPR_1D_BMP); + videoSetMode(MODE_5_2D | (consoleEnable ? DISPLAY_BG0_ACTIVE : 0) | DISPLAY_BG3_ACTIVE | DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D | DISPLAY_SPR_1D_BMP); // Move the cursor to the bottom of the screen using ANSI escape code consolePrintf("\033[23;0f"); @@ -970,7 +971,7 @@ void displayMode16BitFlipBuffer() { u16 *back = get16BitBackBuffer(); // highBuffer = !highBuffer; -// BG3_CR = BG_BMP16_512x256 | BG_BMP_RAM(highBuffer? 1: 0); +// BG3_CR = BG_BMP16_512x256 | BG_BMP_RAM(highBuffer ? 1 : 0); if (isCpuScalerEnabled()) { Rescale_320x256x1555_To_256x256x1555(BG_GFX, back, 512, 512); @@ -1805,13 +1806,13 @@ 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 & 0xFF): 192) | (!enable? ATTR0_DISABLED: 0); + 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); } void setIconMain(int num, int x, int y, int imageNum, int flags, bool enable) { - spritesMain[num].attribute[0] = ATTR0_BMP | (y & 0xFF) | (!enable? ATTR0_DISABLED: 0); + spritesMain[num].attribute[0] = ATTR0_BMP | (y & 0xFF) | (!enable ? ATTR0_DISABLED : 0); spritesMain[num].attribute[1] = ATTR1_SIZE_32 | (x & 0x1FF) | flags; spritesMain[num].attribute[2] = ATTR2_ALPHA(1)| (imageNum * 16); } @@ -1841,7 +1842,7 @@ void updateStatus() { } if (indyFightState) { - setIcon(1, (190 - 32), 150, 3, (indyFightRight? 0: ATTR1_FLIP_X), true); + setIcon(1, (190 - 32), 150, 3, (indyFightRight ? 0 : ATTR1_FLIP_X), true); // consolePrintf("%d\n", indyFightRight); } else { // setIcon(1, 0, 0, 0, 0, false); @@ -2499,7 +2500,7 @@ void penUpdate() { // if (getKeysHeld() & KEY_L) consolePrintf("%d, %d penX=%d, penY=%d tz=%d\n", IPC->touchXpx, IPC->touchYpx, penX, penY, IPC->touchZ1); - bool penDownThisFrame = (IPC->touchZ1 > 0) && (IPC->touchXpx > 0) && (IPC->touchYpx > 0); + bool penDownThisFrame = (!(IPC->buttons & 0x40)) && (IPC->touchXpx > 0) && (IPC->touchYpx > 0); static bool moved = false; if (( (tapScreenClicks) || getKeyboardEnable() ) && (getIsDisplayMode8Bit())) { @@ -2626,7 +2627,7 @@ void penUpdate() { penDownSaved = true; } - if ((IPC->touchZ1 > 0) && (IPC->touchXpx > 0) && (IPC->touchYpx > 0)) { + if ((!(IPC->buttons & 0x40)) && (IPC->touchXpx > 0) && (IPC->touchYpx > 0)) { penX = IPC->touchXpx + touchXOffset; penY = IPC->touchYpx + touchYOffset; moved = true; @@ -2648,7 +2649,7 @@ void penUpdate() { - if ((IPC->touchZ1 > 0) || ((penDownFrames == 2)) ) { + if ((!(IPC->buttons & 0x40)) || ((penDownFrames == 2)) ) { penDownLastFrame = true; penDownFrames++; } else { diff --git a/backends/platform/ds/arm9/source/dsmain.h b/backends/platform/ds/arm9/source/dsmain.h index fec97d878e..7345fc2ceb 100644 --- a/backends/platform/ds/arm9/source/dsmain.h +++ b/backends/platform/ds/arm9/source/dsmain.h @@ -23,6 +23,8 @@ #ifndef _DSMAIN_H #define _DSMAIN_H +#define FORBIDDEN_SYMBOL_ALLOW_ALL + #include <nds.h> #include "osystem_ds.h" diff --git a/backends/platform/ds/arm9/source/dsoptions.cpp b/backends/platform/ds/arm9/source/dsoptions.cpp index 733592e958..562038166b 100644 --- a/backends/platform/ds/arm9/source/dsoptions.cpp +++ b/backends/platform/ds/arm9/source/dsoptions.cpp @@ -20,8 +20,8 @@ * */ -#include "dsoptions.h" #include "dsmain.h" +#include "dsoptions.h" #include "gui/dialog.h" #include "gui/gui-manager.h" #include "gui/widgets/list.h" diff --git a/backends/platform/ds/arm9/source/fat/disc_io.c b/backends/platform/ds/arm9/source/fat/disc_io.c index 5896cbb750..74fc8fb09b 100644 --- a/backends/platform/ds/arm9/source/fat/disc_io.c +++ b/backends/platform/ds/arm9/source/fat/disc_io.c @@ -367,7 +367,7 @@ bool disc_setDsSlotInterface (void) active_interface = DLDI_GetInterface(); - if (stricmp((char *)(&_dldi_driver_name), "Default (No interface)")) { + if (strcasecmp((char *)(&_dldi_driver_name), "Default (No interface)")) { char name[48]; memcpy(name, &_dldi_driver_name, 48); name[47] = '\0'; diff --git a/backends/platform/ds/arm9/source/osystem_ds.cpp b/backends/platform/ds/arm9/source/osystem_ds.cpp index 861ee2e0c5..c35433d3fc 100644 --- a/backends/platform/ds/arm9/source/osystem_ds.cpp +++ b/backends/platform/ds/arm9/source/osystem_ds.cpp @@ -23,6 +23,9 @@ // Allow use of stuff in <time.h> #define FORBIDDEN_SYMBOL_EXCEPTION_time_h +// Allow use of stuff in <nds.h> +#define FORBIDDEN_SYMBOL_EXCEPTION_printf +#define FORBIDDEN_SYMBOL_EXCEPTION_unistd_h #include "common/scummsys.h" #include "common/system.h" diff --git a/backends/platform/ds/arm9/source/osystem_ds.h b/backends/platform/ds/arm9/source/osystem_ds.h index f883bd14d1..c8698ca418 100644 --- a/backends/platform/ds/arm9/source/osystem_ds.h +++ b/backends/platform/ds/arm9/source/osystem_ds.h @@ -24,6 +24,10 @@ #ifndef _OSYSTEM_DS_H_ #define _OSYSTEM_DS_H_ +// Allow use of stuff in <nds.h> +#define FORBIDDEN_SYMBOL_EXCEPTION_printf +#define FORBIDDEN_SYMBOL_EXCEPTION_unistd_h + #include "backends/base-backend.h" #include "common/events.h" #include "nds.h" diff --git a/backends/platform/ds/arm9/source/wordcompletion.cpp b/backends/platform/ds/arm9/source/wordcompletion.cpp index 36fa31247c..2257c49005 100644 --- a/backends/platform/ds/arm9/source/wordcompletion.cpp +++ b/backends/platform/ds/arm9/source/wordcompletion.cpp @@ -20,8 +20,8 @@ * */ -#include "wordcompletion.h" #include "osystem_ds.h" +#include "wordcompletion.h" #include "engines/agi/agi.h" // Caution for #define for NUM_CHANNELS, causes problems in mixer_intern.h #ifdef ENABLE_AGI diff --git a/backends/platform/ds/arm9/source/zipreader.cpp b/backends/platform/ds/arm9/source/zipreader.cpp index 0de2b0c981..2ad0a39ed2 100644 --- a/backends/platform/ds/arm9/source/zipreader.cpp +++ b/backends/platform/ds/arm9/source/zipreader.cpp @@ -23,6 +23,7 @@ #define FORBIDDEN_SYMBOL_ALLOW_ALL #include "common/scummsys.h" +#include "common/str.h" #include "zipreader.h" ZipFile::ZipFile() { @@ -193,7 +194,7 @@ bool ZipFile::findFile(const char *search) { } - if (!stricmp(name, searchName)) { + if (!scumm_stricmp(name, searchName)) { // consolePrintf("'%s'=='%s'\n", name, searchName); return true; // Got it! } else { diff --git a/backends/platform/ds/ds.mk b/backends/platform/ds/ds.mk index 78216cb9a2..18feea00c2 100644 --- a/backends/platform/ds/ds.mk +++ b/backends/platform/ds/ds.mk @@ -75,7 +75,7 @@ endif # Compiler options for files which should be optimised for speed -OPT_SPEED := -O3 -mno-thumb +OPT_SPEED := -O3 -marm # Compiler options for files which should be optimised for space OPT_SIZE := -Os -mthumb @@ -134,7 +134,8 @@ engines/teenagent/actor.o: CXXFLAGS:=$(CXXFLAGS) $(OPT_SPEED) # ############################################################################# -all: scummvm.nds scummvm.ds.gba +# FIXME: Newer versions of devkitARM don't include dsbuild, which is needed to create scummvm.ds.gba +all: scummvm.nds # scummvm.ds.gba clean: dsclean @@ -145,11 +146,8 @@ dsclean: # TODO: Add a 'dsdist' target ? -%.bin: %.elf - $(OBJCOPY) -S -O binary $< $@ - -%.nds: %.bin $(ndsdir)/arm7/arm7.bin - ndstool -c $@ -9 $< -7 $(ndsdir)/arm7/arm7.bin -b $(srcdir)/$(ndsdir)/$(LOGO) "$(@F);ScummVM $(VERSION);DS Port" +%.nds: %.elf $(ndsdir)/arm7/arm7.elf + ndstool -c $@ -9 $< -7 $(ndsdir)/arm7/arm7.elf -b $(srcdir)/$(ndsdir)/$(LOGO) "$(@F);ScummVM $(VERSION);DS Port" %.ds.gba: %.nds dsbuild $< -o $@ -l $(srcdir)/$(ndsdir)/arm9/ndsloader.bin @@ -170,10 +168,7 @@ dsclean: # HACK/FIXME: C compiler, for cartreset.c -- we should switch this to use CXX # as soon as possible. -CC := $(DEVKITPRO)/devkitARM/bin/arm-eabi-gcc - -# HACK/TODO: Pointer to objcopy. This should really be set by configure -OBJCOPY := $(DEVKITPRO)/devkitARM/bin/arm-eabi-objcopy +CC := $(DEVKITPRO)/devkitARM/bin/arm-none-eabi-gcc # # Set various flags @@ -194,7 +189,7 @@ ARM7_CFLAGS := -g -Wall -O2\ ARM7_CXXFLAGS := $(ARM7_CFLAGS) -fno-exceptions -fno-rtti -ARM7_LDFLAGS := -g $(ARM7_ARCH) -mno-fpu +ARM7_LDFLAGS := -g $(ARM7_ARCH) -mfloat-abi=soft # HACK/FIXME: Define a custom build rule for cartreset.c. # We do this because it is a .c file, not a .cpp file and so is outside our @@ -218,10 +213,6 @@ $(ndsdir)/arm7/arm7.elf: \ $(ndsdir)/arm7/source/main.o $(CXX) $(ARM7_LDFLAGS) -specs=ds_arm7.specs $+ -L$(DEVKITPRO)/libnds/lib -lnds7 -o $@ -# Rule for creating ARM7 .bin files from .elf files -$(ndsdir)/arm7/arm7.bin: $(ndsdir)/arm7/arm7.elf - $(OBJCOPY) -O binary $< $@ - diff --git a/backends/platform/n64/portdefs.h b/backends/platform/n64/portdefs.h index 63ec989a8d..364520803b 100644 --- a/backends/platform/n64/portdefs.h +++ b/backends/platform/n64/portdefs.h @@ -36,17 +36,4 @@ #undef assert #define assert(x) ((x) ? 0 : (print_error("ASSERT TRIGGERED:\n\n("#x")\n%s\nline: %d", __FILE__, __LINE__))) -// Typedef basic data types in a way that is compatible with the N64 SDK. -typedef unsigned char byte; -typedef unsigned char uint8; -typedef signed char int8; -typedef unsigned short int uint16; -typedef signed short int int16; -typedef unsigned int uint32; -typedef signed int int32; - -// Define SCUMMVM_DONT_DEFINE_TYPES to prevent scummsys.h from trying to -// re-define those data types. -#define SCUMMVM_DONT_DEFINE_TYPES - -#endif +#endif // __N64_PORTDEFS__ diff --git a/backends/platform/sdl/riscos/riscos.mk b/backends/platform/sdl/riscos/riscos.mk index 534b7aeb52..0a3061fd3a 100644 --- a/backends/platform/sdl/riscos/riscos.mk +++ b/backends/platform/sdl/riscos/riscos.mk @@ -21,4 +21,5 @@ ifdef DYNAMIC_MODULES endif mkdir -p !ScummVM/docs cp ${srcdir}/dists/riscos/!Help,feb !ScummVM/!Help,feb - cp $(DIST_FILES_DOCS) !ScummVM/docs
\ No newline at end of file + cp $(DIST_FILES_DOCS) !ScummVM/docs + cp -r ${srcdir}/doc/* !ScummVM/docs diff --git a/backends/plugins/ds/ds-provider.cpp b/backends/plugins/ds/ds-provider.cpp index 1c9744518e..c5419a989a 100644 --- a/backends/plugins/ds/ds-provider.cpp +++ b/backends/plugins/ds/ds-provider.cpp @@ -20,6 +20,10 @@ * */ +// Allow use of stuff in <nds.h> +#define FORBIDDEN_SYMBOL_EXCEPTION_printf +#define FORBIDDEN_SYMBOL_EXCEPTION_unistd_h + #include "common/scummsys.h" #if defined(DYNAMIC_MODULES) && defined(__DS__) diff --git a/backends/plugins/elf/version.cpp b/backends/plugins/elf/version.cpp index ac999e1d7c..e91ec6b172 100644 --- a/backends/plugins/elf/version.cpp +++ b/backends/plugins/elf/version.cpp @@ -27,6 +27,6 @@ const char *gScummVMPluginBuildDate = "Git Master"; /* ScummVM Git Master */ #else const char *gScummVMPluginBuildDate __attribute__((visibility("hidden"))) = - __DATE__ " " __TIME__ ; + __DATE__ " " __TIME__; #endif #endif |