aboutsummaryrefslogtreecommitdiff
path: root/backends/platform
diff options
context:
space:
mode:
Diffstat (limited to 'backends/platform')
-rw-r--r--backends/platform/androidsdl/androidsdl-sdl.cpp8
-rw-r--r--backends/platform/dc/dc-fs.cpp2
-rw-r--r--backends/platform/dc/selector.cpp21
-rw-r--r--backends/platform/ds/arm7/source/main.cpp694
-rw-r--r--backends/platform/ds/arm9/source/cdaudio.cpp2
-rw-r--r--backends/platform/ds/arm9/source/dsmain.cpp53
-rw-r--r--backends/platform/ds/arm9/source/dsmain.h2
-rw-r--r--backends/platform/ds/arm9/source/dsoptions.cpp2
-rw-r--r--backends/platform/ds/arm9/source/fat/disc_io.c2
-rw-r--r--backends/platform/ds/arm9/source/osystem_ds.cpp3
-rw-r--r--backends/platform/ds/arm9/source/osystem_ds.h4
-rw-r--r--backends/platform/ds/arm9/source/wordcompletion.cpp2
-rw-r--r--backends/platform/ds/arm9/source/zipreader.cpp3
-rw-r--r--backends/platform/ds/ds.mk23
-rw-r--r--backends/platform/ios7/README.md127
-rw-r--r--backends/platform/ios7/ios7_osys_main.h2
-rw-r--r--backends/platform/n64/osys_n64_base.cpp2
-rw-r--r--backends/platform/n64/portdefs.h15
-rw-r--r--backends/platform/psp/display_manager.cpp2
-rw-r--r--backends/platform/psp/input.cpp2
-rw-r--r--backends/platform/sdl/macosx/macosx.cpp4
-rw-r--r--backends/platform/sdl/macosx/macosx.h1
-rw-r--r--backends/platform/sdl/macosx/macosx_wrapper.h1
-rw-r--r--backends/platform/sdl/macosx/macosx_wrapper.mm32
-rw-r--r--backends/platform/sdl/psp2/psp2-main.cpp4
-rw-r--r--backends/platform/sdl/psp2/psp2.cpp8
-rw-r--r--backends/platform/sdl/riscos/riscos-main.cpp2
-rw-r--r--backends/platform/sdl/riscos/riscos.cpp2
-rw-r--r--backends/platform/sdl/riscos/riscos.mk3
-rw-r--r--backends/platform/sdl/sdl.cpp34
-rw-r--r--backends/platform/sdl/sdl.h1
-rw-r--r--backends/platform/wii/osystem_events.cpp2
32 files changed, 471 insertions, 594 deletions
diff --git a/backends/platform/androidsdl/androidsdl-sdl.cpp b/backends/platform/androidsdl/androidsdl-sdl.cpp
index 697acca4d6..2ed644ecb2 100644
--- a/backends/platform/androidsdl/androidsdl-sdl.cpp
+++ b/backends/platform/androidsdl/androidsdl-sdl.cpp
@@ -44,18 +44,18 @@ void OSystem_ANDROIDSDL::initBackend() {
if (!ConfMan.hasKey("gfx_mode"))
ConfMan.set("gfx_mode", "2x");
-
+
if (!ConfMan.hasKey("swap_menu_and_back_buttons"))
ConfMan.setBool("swap_menu_and_back_buttons", true);
else
swapMenuAndBackButtons(ConfMan.getBool("swap_menu_and_back_buttons"));
-
+
if (!ConfMan.hasKey("touchpad_mouse_mode")) {
const bool enable = SDL_ANDROID_GetMouseEmulationMode();
ConfMan.setBool("touchpad_mouse_mode", enable);
} else
touchpadMode(ConfMan.getBool("touchpad_mouse_mode"));
-
+
if (!ConfMan.hasKey("onscreen_control")) {
const bool enable = SDL_ANDROID_GetScreenKeyboardShown();
ConfMan.setBool("onscreen_control", enable);
@@ -115,7 +115,7 @@ void OSystem_ANDROIDSDL::setFeatureState(Feature f, bool enable) {
swapMenuAndBackButtons(enable);
break;
}
-
+
OSystem_POSIX::setFeatureState(f, enable);
}
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/dc/selector.cpp b/backends/platform/dc/selector.cpp
index 6717ca494b..914d683334 100644
--- a/backends/platform/dc/selector.cpp
+++ b/backends/platform/dc/selector.cpp
@@ -155,11 +155,7 @@ static Game the_game;
static bool isIcon(const Common::FSNode &entry)
{
- int l = entry.getDisplayName().size();
- if (l>4 && !strcasecmp(entry.getDisplayName().c_str()+l-4, ".ICO"))
- return true;
- else
- return false;
+ return entry.getDisplayName().hasSuffixIgnoreCase(".ICO");
}
static bool loadIcon(Game &game, Dir *dirs, int num_dirs)
@@ -203,7 +199,7 @@ static bool uniqueGame(const char *base, const char *dir,
this is a workaround for the detector bug in toon... */
sameOrSubdir(dir, games->dir) &&
/*!strcmp(dir, games->dir) &&*/
- !stricmp(base, games->filename_base) &&
+ !scumm_stricmp(base, games->filename_base) &&
lang == games->language &&
plf == games->platform)
return false;
@@ -275,21 +271,22 @@ static int findGames(Game *games, int max, bool use_ini)
}
if (!use_ini) {
- GameList candidates = EngineMan.detectGames(files);
+ DetectionResults detectionResults = EngineMan.detectGames(files);
+ DetectedGames candidates = detectionResults.listRecognizedGames();
- for (GameList::const_iterator ge = candidates.begin();
+ for (DetectedGames::const_iterator ge = candidates.begin();
ge != candidates.end(); ++ge)
if (curr_game < max) {
- strcpy(games[curr_game].filename_base, ge->gameid().c_str());
+ strcpy(games[curr_game].filename_base, ge->gameId.c_str());
strcpy(games[curr_game].dir, dirs[curr_dir-1].name);
- games[curr_game].language = ge->language();
- games[curr_game].platform = ge->platform();
+ games[curr_game].language = ge->language;
+ games[curr_game].platform = ge->platform;
if (uniqueGame(games[curr_game].filename_base,
games[curr_game].dir,
games[curr_game].language,
games[curr_game].platform, games, curr_game)) {
- strcpy(games[curr_game].text, ge->description().c_str());
+ strcpy(games[curr_game].text, ge->description.c_str());
#if 0
printf("Registered game <%s> (l:%d p:%d) in <%s> <%s> because of <%s> <*>\n",
games[curr_game].text,
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..041892aed6 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);
@@ -2164,19 +2165,11 @@ void VBlankHandler(void) {
}
- subScTargetX = xCenter - ((subScreenWidth >> 1) << 8);
+ subScTargetX = xCenter - ((subScreenWidth >> 1) << 8);
subScTargetY = yCenter - ((subScreenHeight >> 1) << 8);
-
-
-
- if (subScTargetX < 0) subScTargetX = 0;
- if (subScTargetX > (gameWidth - subScreenWidth) << 8) subScTargetX = (gameWidth - subScreenWidth) << 8;
-
- if (subScTargetY < 0) subScTargetY = 0;
- if (subScTargetY > (gameHeight - subScreenHeight) << 8) subScTargetY = (gameHeight - subScreenHeight) << 8;
-
-
+ subScTargetX = CLIP(subScTargetX, 0, (gameWidth - subScreenWidth) << 8);
+ subScTargetY = CLIP(subScTargetY, 0, (gameHeight - subScreenHeight) << 8);
subScX += (subScTargetX - subScX) >> 2;
subScY += (subScTargetY - subScY) >> 2;
@@ -2499,7 +2492,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 +2619,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 +2641,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/ios7/README.md b/backends/platform/ios7/README.md
index f7d828ee94..48a3d3e830 100644
--- a/backends/platform/ios7/README.md
+++ b/backends/platform/ios7/README.md
@@ -6,132 +6,7 @@ I tried to use all the latest iOS features to replace the old code. For instance
## Compilation ##
-First, clone the repository:
-```
-$ git clone https://github.com/scummvm/scummvm.git
-```
-
-### Compilation from Xcode ###
-
-This is the recommended way to compile ScummVM, and the only one which makes it possible to run ScummVM on a non-jailbroken device!
-
-The next step is to compile the **create_project** tool. Open the Xcode project you'll found in the **devtools/create\_project/xcode/** directory. Once compiled, copy the binary somewhere in your *PATH*, and create a **build** directory somewhere on your harddisk. It is recommended to create this directory next to the cloned repository (they share the same parent).
-
-Execute the following commands in a terminal:
-```
-$ cd path_to_the_build_directory
-$ create_project path_to_scummvm_repository --xcode --enable-fluidsynth --disable-jpeg --disable-bink --disable-16bit --disable-mt32emu --disable-nasm --disable-opengl --disable-theora --disable-taskbar
-```
-
-This will create an Xcode project for ScummVM, for both the OS X, and the iOS target.
-
-Now, download the external libraries from http://bsr43.free.fr/scummvm/ScummVM-iOS-libraries.zip. Unzip the archive in your **build** directory. Please make sure that the **lib**, and **include** directories are at the root of the **build** directory, not in a subdirectory.
-
-Now, your **build** directory should contain:
-* a generated **engines** directory,
-* a generated **scummvm.xcodeproj** project,
-* an **include** directory,
-* a **lib** directory.
-
-You are ready to compile ScummVM: open the **scummvm.xcodeproj** project, and build it.
-
-### Compilation from command line ###
-
-For jailbroken devices, it is also possible to compile the project from command line. You'll need a working toolchain, and some tools, like **ldid**, to fake the code signature.
-
-Here is a script to download, and compile all the required tools. This script has been wrote for Debian 8.2, and should be run as root.
-
-```
-#!/bin/bash
-
-if [ $UID -ne 0 ]; then
- echo "This script should be run by the root user"
- exit 1
-fi
-
-# Install the Clang compiler
-apt-get install -y clang-3.4 libclang-3.4-dev llvm-3.4 libtool bison flex automake subversion git pkg-config wget libssl-dev uuid-dev libxml2-dev || exit 1
-
-# Add LLVM to the linker library path
-echo /usr/lib/llvm-3.4/lib > /etc/ld.so.conf.d/libllvm-3.4.conf
-ldconfig
-
-# Add symlinks for the LLVM headers
-ln -s /usr/lib/llvm-3.4/bin/llvm-config /usr/bin/llvm-config || exit 1
-ln -s /usr/include/llvm-3.4/llvm /usr/include/llvm || exit 1
-ln -s /usr/include/llvm-c-3.4/llvm-c /usr/include/llvm-c || exit 1
-ln -s /usr/bin/clang-3.4 /usr/bin/clang || exit 1
-ln -s /usr/bin/clang++-3.4 /usr/bin/clang++ || exit 1
-
-# Build the linker
-svn checkout http://ios-toolchain-based-on-clang-for-linux.googlecode.com/svn/trunk/cctools-porting || exit 1
-cd cctools-porting
-sed -i'' 's/proz -k=20 --no-curses/wget/g' cctools-ld64.sh
-./cctools-ld64.sh || exit 1
-
-cd cctools-855-ld64-236.3
-./autogen.sh || exit 1
-./configure --prefix=/usr/local --target=arm-apple-darwin11 || exit 1
-make || exit 1
-make install || exit 1
-cd ../..
-
-# Install ios-tools
-wget https://ios-toolchain-based-on-clang-for-linux.googlecode.com/files/iphonesdk-utils-2.0.tar.gz || exit 1
-tar xzf iphonesdk-utils-2.0.tar.gz
-cd iphonesdk-utils-2.0
-patch -p0 <<_EOF
-*** genLocalization2/getLocalizedStringFromFile.cpp 2015-04-02 04:45:39.309837816 +0530
---- genLocalization2/getLocalizedStringFromFile.cpp 2015-04-02 04:45:11.525700021 +0530
-***************
-*** 113,115 ****
- clang::HeaderSearch headerSearch(headerSearchOptions,
-- fileManager,
- *pDiagnosticsEngine,
---- 113,115 ----
- clang::HeaderSearch headerSearch(headerSearchOptions,
-+ sourceManager,
- *pDiagnosticsEngine,
-***************
-*** 129,134 ****
- false);
-- clang::HeaderSearch headerSearch(fileManager,
- *pDiagnosticsEngine,
- languageOptions,
-- pTargetInfo);
- ApplyHeaderSearchOptions(headerSearch, headerSearchOptions, languageOptions, pTargetInfo->getTriple());
---- 129,134 ----
- false);
-+ clang::HeaderSearch headerSearch(fileManager);/*,
- *pDiagnosticsEngine,
- languageOptions,
-+ pTargetInfo);*/
- ApplyHeaderSearchOptions(headerSearch, headerSearchOptions, languageOptio
-_EOF
-
-./autogen.sh || exit 1
-CC=clang CXX=clang++ ./configure --prefix=/usr/local || exit 1
-make || exit 1
-make install || exit 1
-
-# Install the iOS SDK 8.1
-mkdir -p /usr/share/ios-sdk
-cd /usr/share/ios-sdk
-wget http://iphone.howett.net/sdks/dl/iPhoneOS8.1.sdk.tbz2 || exit 1
-tar xjf iPhoneOS8.1.sdk.tbz2
-rm iPhoneOS8.1.sdk.tbz2
-```
-
-Now, in order to compile ScummVM, execute the following commands:
-```
-$ export SDKROOT=/usr/share/ios-sdk/iPhoneOS8.1.sdk
-$ export CC=ios-clang
-$ export CXX=ios-clang++
-$ ./configure --host=ios7 --disable-mt32emu --enable-release
-$ make ios7bundle
-```
-
-At the end of the compilation, you'll find a **ScummVM.app** application: copy it over SSH, and reboot your device.
+See http://wiki.scummvm.org/index.php/Compiling_ScummVM/iPhone
## Usage ##
diff --git a/backends/platform/ios7/ios7_osys_main.h b/backends/platform/ios7/ios7_osys_main.h
index e0ac599b1d..9b9d2bdee0 100644
--- a/backends/platform/ios7/ios7_osys_main.h
+++ b/backends/platform/ios7/ios7_osys_main.h
@@ -123,7 +123,7 @@ public:
static OSystem_iOS7 *sharedInstance();
virtual void initBackend();
-
+
virtual void engineInit();
virtual void engineDone();
diff --git a/backends/platform/n64/osys_n64_base.cpp b/backends/platform/n64/osys_n64_base.cpp
index 1282b16d47..2bde28dd62 100644
--- a/backends/platform/n64/osys_n64_base.cpp
+++ b/backends/platform/n64/osys_n64_base.cpp
@@ -227,7 +227,7 @@ int OSystem_N64::getDefaultGraphicsMode() const {
bool OSystem_N64::setGraphicsMode(const char *mode) {
int i = 0;
while (s_supportedGraphicsModes[i].name) {
- if (!strcmpi(s_supportedGraphicsModes[i].name, mode)) {
+ if (!scumm_stricmp(s_supportedGraphicsModes[i].name, mode)) {
_graphicMode = s_supportedGraphicsModes[i].id;
switchGraphicModeId(_graphicMode);
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/psp/display_manager.cpp b/backends/platform/psp/display_manager.cpp
index 33bf190d70..54ad0d3223 100644
--- a/backends/platform/psp/display_manager.cpp
+++ b/backends/platform/psp/display_manager.cpp
@@ -332,7 +332,7 @@ bool DisplayManager::setGraphicsMode(const char *name) {
int i = 0;
while (_supportedModes[i].name) {
- if (!strcmpi(_supportedModes[i].name, name)) {
+ if (!scumm_stricmp(_supportedModes[i].name, name)) {
setGraphicsMode(_supportedModes[i].id);
return true;
}
diff --git a/backends/platform/psp/input.cpp b/backends/platform/psp/input.cpp
index 7a2047f28e..8e5f170a7d 100644
--- a/backends/platform/psp/input.cpp
+++ b/backends/platform/psp/input.cpp
@@ -336,7 +336,7 @@ bool Nub::getEvent(Common::Event &event, PspEvent &pspEvent, SceCtrlData &pad) {
// keep track of remainder for true sub-pixel cursor position
_hiresX %= 1024;
_hiresY %= 1024;
-
+
int32 oldX = _cursor->getX();
int32 oldY = _cursor->getY();
diff --git a/backends/platform/sdl/macosx/macosx.cpp b/backends/platform/sdl/macosx/macosx.cpp
index 8ecbe7306c..62037200ea 100644
--- a/backends/platform/sdl/macosx/macosx.cpp
+++ b/backends/platform/sdl/macosx/macosx.cpp
@@ -124,6 +124,10 @@ Common::String OSystem_MacOSX::getTextFromClipboard() {
return getTextFromClipboardMacOSX();
}
+bool OSystem_MacOSX::setTextInClipboard(const Common::String &text) {
+ return setTextInClipboardMacOSX(text);
+}
+
bool OSystem_MacOSX::openUrl(const Common::String &url) {
CFURLRef urlRef = CFURLCreateWithBytes (NULL, (UInt8*)url.c_str(), url.size(), kCFStringEncodingASCII, NULL);
OSStatus err = LSOpenCFURLRef(urlRef, NULL);
diff --git a/backends/platform/sdl/macosx/macosx.h b/backends/platform/sdl/macosx/macosx.h
index ba07364681..5ef30baa64 100644
--- a/backends/platform/sdl/macosx/macosx.h
+++ b/backends/platform/sdl/macosx/macosx.h
@@ -35,6 +35,7 @@ public:
virtual bool hasTextInClipboard();
virtual Common::String getTextFromClipboard();
+ virtual bool setTextInClipboard(const Common::String &text);
virtual bool openUrl(const Common::String &url);
diff --git a/backends/platform/sdl/macosx/macosx_wrapper.h b/backends/platform/sdl/macosx/macosx_wrapper.h
index 84f0c1b2ba..ca4e433890 100644
--- a/backends/platform/sdl/macosx/macosx_wrapper.h
+++ b/backends/platform/sdl/macosx/macosx_wrapper.h
@@ -27,6 +27,7 @@
bool hasTextInClipboardMacOSX();
Common::String getTextFromClipboardMacOSX();
+bool setTextInClipboardMacOSX(const Common::String &text);
Common::String getDesktopPathMacOSX();
#endif
diff --git a/backends/platform/sdl/macosx/macosx_wrapper.mm b/backends/platform/sdl/macosx/macosx_wrapper.mm
index 02516e5ffe..32dfa040cc 100644
--- a/backends/platform/sdl/macosx/macosx_wrapper.mm
+++ b/backends/platform/sdl/macosx/macosx_wrapper.mm
@@ -24,11 +24,13 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL
#include "backends/platform/sdl/macosx/macosx_wrapper.h"
+#include "common/translation.h"
#include <AppKit/NSPasteboard.h>
#include <Foundation/NSArray.h>
#include <Foundation/NSPathUtilities.h>
#include <AvailabilityMacros.h>
+#include <CoreFoundation/CFString.h>
bool hasTextInClipboardMacOSX() {
return [[NSPasteboard generalPasteboard] availableTypeFromArray:[NSArray arrayWithObject:NSStringPboardType]] != nil;
@@ -40,13 +42,33 @@ Common::String getTextFromClipboardMacOSX() {
// Note: on OS X 10.6 and above it is recommanded to use NSPasteboardTypeString rather than NSStringPboardType.
// But since we still target older version use NSStringPboardType.
NSPasteboard *pb = [NSPasteboard generalPasteboard];
- NSString* str = [pb stringForType:NSStringPboardType];
+ NSString *str = [pb stringForType:NSStringPboardType];
if (str == nil)
return Common::String();
- // If the string cannot be represented using the requested encoding we get a null pointer below.
- // This is fine as ScummVM would not know what to do with non-ASCII characters (although maybe
- // we should use NSISOLatin1StringEncoding?).
- return Common::String([str cStringUsingEncoding:NSASCIIStringEncoding]);
+
+ // If translations are supported, use the current TranslationManager charset and otherwise
+ // use ASCII. If the string cannot be represented using the requested encoding we get a null
+ // pointer below, which is fine as ScummVM would not know what to do with the string anyway.
+#ifdef USE_TRANSLATION
+ NSString* encStr = [NSString stringWithCString:TransMan.getCurrentCharset().c_str() encoding:NSASCIIStringEncoding];
+ NSStringEncoding encoding = CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding((CFStringRef)encStr));
+#else
+ NSStringEncoding encoding = NSISOLatin1StringEncoding;
+#endif
+ return Common::String([str cStringUsingEncoding:encoding]);
+}
+
+bool setTextInClipboardMacOSX(const Common::String &text) {
+ NSPasteboard *pb = [NSPasteboard generalPasteboard];
+ [pb declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil];
+
+#ifdef USE_TRANSLATION
+ NSString* encStr = [NSString stringWithCString:TransMan.getCurrentCharset().c_str() encoding:NSASCIIStringEncoding];
+ NSStringEncoding encoding = CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding((CFStringRef)encStr));
+#else
+ NSStringEncoding encoding = NSISOLatin1StringEncoding;
+#endif
+ return [pb setString:[NSString stringWithCString:text.c_str() encoding:encoding] forType:NSStringPboardType];
}
Common::String getDesktopPathMacOSX() {
diff --git a/backends/platform/sdl/psp2/psp2-main.cpp b/backends/platform/sdl/psp2/psp2-main.cpp
index 0bdf0b34bc..70cc52388e 100644
--- a/backends/platform/sdl/psp2/psp2-main.cpp
+++ b/backends/platform/sdl/psp2/psp2-main.cpp
@@ -40,7 +40,7 @@ int main(int argc, char *argv[]) {
scePowerSetBusClockFrequency(222);
scePowerSetGpuClockFrequency(222);
scePowerSetGpuXbarClockFrequency(166);
-
+
// Create our OSystem instance
g_system = new OSystem_PSP2();
assert(g_system);
@@ -57,7 +57,7 @@ int main(int argc, char *argv[]) {
// Free OSystem
delete (OSystem_PSP2 *)g_system;
-
+
#ifdef __PSP2_DEBUG__
psp2shell_exit();
#endif
diff --git a/backends/platform/sdl/psp2/psp2.cpp b/backends/platform/sdl/psp2/psp2.cpp
index 3034b6d886..80604a69d5 100644
--- a/backends/platform/sdl/psp2/psp2.cpp
+++ b/backends/platform/sdl/psp2/psp2.cpp
@@ -55,11 +55,11 @@ OSystem_PSP2::OSystem_PSP2(Common::String baseConfigName)
}
void OSystem_PSP2::init() {
-
+
#if __PSP2_DEBUG__
gDebugLevel = 3;
#endif
-
+
// Initialze File System Factory
sceIoMkdir("ux0:data", 0755);
sceIoMkdir("ux0:data/scummvm", 0755);
@@ -71,7 +71,7 @@ void OSystem_PSP2::init() {
}
void OSystem_PSP2::initBackend() {
-
+
ConfMan.set("joystick_num", 0);
ConfMan.registerDefault("fullscreen", true);
ConfMan.registerDefault("aspect_ratio", false);
@@ -105,7 +105,7 @@ void OSystem_PSP2::initBackend() {
ConfMan.setBool("frontpanel_touchpad_mode", false);
}
-
+
// Create the savefile manager
if (_savefileManager == 0)
_savefileManager = new DefaultSaveFileManager("ux0:data/scummvm/saves");
diff --git a/backends/platform/sdl/riscos/riscos-main.cpp b/backends/platform/sdl/riscos/riscos-main.cpp
index 2ff8294c1a..3f7058e3b8 100644
--- a/backends/platform/sdl/riscos/riscos-main.cpp
+++ b/backends/platform/sdl/riscos/riscos-main.cpp
@@ -29,7 +29,7 @@
#include "base/main.h"
int main(int argc, char *argv[]) {
-
+
// Create our OSystem instance
g_system = new OSystem_RISCOS();
assert(g_system);
diff --git a/backends/platform/sdl/riscos/riscos.cpp b/backends/platform/sdl/riscos/riscos.cpp
index 0cdbceb902..73c0fdae03 100644
--- a/backends/platform/sdl/riscos/riscos.cpp
+++ b/backends/platform/sdl/riscos/riscos.cpp
@@ -101,4 +101,4 @@ Common::WriteStream *OSystem_RISCOS::createLogFile() {
}
#endif
-
+
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/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index 3082a69ebf..72af6d592a 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -33,6 +33,7 @@
#include "gui/EventRecorder.h"
#include "common/taskbar.h"
#include "common/textconsole.h"
+#include "common/translation.h"
#include "backends/saves/default/default-saves.h"
@@ -502,17 +503,46 @@ Common::String OSystem_SDL::getTextFromClipboard() {
#if SDL_VERSION_ATLEAST(2, 0, 0)
char *text = SDL_GetClipboardText();
+ // The string returned by SDL is in UTF-8. Convert to the
+ // current TranslationManager encoding or ISO-8859-1.
+#ifdef USE_TRANSLATION
+ char *conv_text = SDL_iconv_string(TransMan.getCurrentCharset().c_str(), "UTF-8", text, SDL_strlen(text) + 1);
+#else
+ char *conv_text = SDL_iconv_string("ISO-8859-1", "UTF-8", text, SDL_strlen(text) + 1);
+#endif
+ if (conv_text) {
+ SDL_free(text);
+ text = conv_text;
+ }
Common::String strText = text;
SDL_free(text);
- // FIXME: The string returned by SDL is in UTF-8, it is not clear
- // what encoding should be used for the returned string.
return strText;
#else
return "";
#endif
}
+bool OSystem_SDL::setTextInClipboard(const Common::String &text) {
+#if SDL_VERSION_ATLEAST(2, 0, 0)
+ // The encoding we need to use is UTF-8. Assume we currently have the
+ // current TranslationManager encoding or ISO-8859-1.
+#ifdef USE_TRANSLATION
+ char *utf8_text = SDL_iconv_string("UTF-8", TransMan.getCurrentCharset().c_str(), text.c_str(), text.size() + 1);
+#else
+ char *utf8_text = SDL_iconv_string("UTF-8", "ISO-8859-1", text.c_str(), text.size() + 1);
+#endif
+ if (utf8_text) {
+ int status = SDL_SetClipboardText(utf8_text);
+ SDL_free(utf8_text);
+ return status == 0;
+ }
+ return SDL_SetClipboardText(text.c_str()) == 0;
+#else
+ return false;
+#endif
+}
+
uint32 OSystem_SDL::getMillis(bool skipRecord) {
uint32 millis = SDL_GetTicks();
diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h
index 61513fa65f..c746d2d2dd 100644
--- a/backends/platform/sdl/sdl.h
+++ b/backends/platform/sdl/sdl.h
@@ -72,6 +72,7 @@ public:
// Clipboard
virtual bool hasTextInClipboard();
virtual Common::String getTextFromClipboard();
+ virtual bool setTextInClipboard(const Common::String &text);
virtual void setWindowCaption(const char *caption);
virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0);
diff --git a/backends/platform/wii/osystem_events.cpp b/backends/platform/wii/osystem_events.cpp
index 2499300a56..ae9c27f03b 100644
--- a/backends/platform/wii/osystem_events.cpp
+++ b/backends/platform/wii/osystem_events.cpp
@@ -228,7 +228,7 @@ bool OSystem_Wii::pollKeyboard(Common::Event &event) {
keyboard_event kbdEvent;
s32 res = KEYBOARD_GetEvent(&kbdEvent);
-
+
if (!res)
return false;