aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/ds/arm9/source
diff options
context:
space:
mode:
authorMax Horn2009-09-27 22:42:21 +0000
committerMax Horn2009-09-27 22:42:21 +0000
commit8f609497ee7417d9c9e7766a3125f355bf7e1662 (patch)
treebd08308c5c05d9b08f122afe510dabadf90bef9b /backends/platform/ds/arm9/source
parentbec07b42a0ce4462c5649818de68683b52ae7f67 (diff)
downloadscummvm-rg350-8f609497ee7417d9c9e7766a3125f355bf7e1662.tar.gz
scummvm-rg350-8f609497ee7417d9c9e7766a3125f355bf7e1662.tar.bz2
scummvm-rg350-8f609497ee7417d9c9e7766a3125f355bf7e1662.zip
Backported NDS changes from 1.0.0 branch to trunk
svn-id: r44426
Diffstat (limited to 'backends/platform/ds/arm9/source')
-rw-r--r--backends/platform/ds/arm9/source/dsmain.cpp176
-rw-r--r--backends/platform/ds/arm9/source/dsmain.h1
-rw-r--r--backends/platform/ds/arm9/source/dsoptions.cpp26
-rw-r--r--backends/platform/ds/arm9/source/dsoptions.h1
-rw-r--r--backends/platform/ds/arm9/source/osystem_ds.cpp214
-rw-r--r--backends/platform/ds/arm9/source/osystem_ds.h10
-rw-r--r--backends/platform/ds/arm9/source/portdefs.h17
-rw-r--r--backends/platform/ds/arm9/source/wordcompletion.cpp5
-rw-r--r--backends/platform/ds/arm9/source/wordcompletion.h1
9 files changed, 338 insertions, 113 deletions
diff --git a/backends/platform/ds/arm9/source/dsmain.cpp b/backends/platform/ds/arm9/source/dsmain.cpp
index 6ba19cc053..f959074d49 100644
--- a/backends/platform/ds/arm9/source/dsmain.cpp
+++ b/backends/platform/ds/arm9/source/dsmain.cpp
@@ -61,6 +61,14 @@
// - Make save/restore game screen use scaler buffer
+// 1.0.0!
+// - Fix text on tabs on config screen
+// - Remove ini file debug msg
+// - Memory size for ite
+// - Try discworld?
+
+
+
//#define USE_LIBCARTRESET
@@ -103,22 +111,63 @@ extern "C" u32 getExceptionAddress( u32 opcodeAddress, u32 thumbState);
extern const char __itcm_start[];
static const char *registerNames[] =
{ "r0","r1","r2","r3","r4","r5","r6","r7",
- "r8 ","r9 ","r10","r11","r12","sp ","lr ","pc " };
+ "r8 ","r9 ","r10","r11","r12","sp ","lr ","pc" };
+
+#ifdef WRAP_MALLOC
-/*
extern "C" void* __real_malloc(size_t size);
+void* operator new (size_t size)
+{
+ register unsigned int reg asm("lr");
+ volatile unsigned int poo = reg;
+
+ void* res = __real_malloc(size);
+
+ if (!res)
+ {
+// *((u8 *) NULL) = 0;
+ consolePrintf("Failed alloc (new) %d (%x)\n", size, poo);
+ return NULL;
+ }
+
+ return res;
+}
+
+
extern "C" void* __wrap_malloc(size_t size) {
+/* u32 addr;
+
+ asm("mov %0, lr"
+ : "=r" (addr)
+ :
+ : );*/
+
+ register unsigned int reg asm("lr");
+ volatile unsigned int poo = reg;
+
+
+ if (size == 0)
+ {
+ static int zeroSize = 0;
+ consolePrintf("0 size malloc (%d)", zeroSize++);
+ }
+
void* res = __real_malloc(size);
if (res) {
+ if (size > 100 * 1024) {
+ consolePrintf("Allocated %d (%d)\n", size, poo);
+ }
return res;
} else {
- consolePrintf("Failed alloc %d\n", size);
+
+// *((u8 *) NULL) = 0;
+ consolePrintf("Failed alloc %d (%x)\n", size, poo);
return NULL;
}
}
-*/
+#endif
namespace DS {
@@ -197,7 +246,7 @@ bool gameScreenSwap = false;
bool isCpuScalerEnabled();
//#define HEAVY_LOGGING
-MouseMode mouseMode;
+MouseMode mouseMode = MOUSE_LEFT;
int storedMouseX = 0;
int storedMouseY = 0;
@@ -355,6 +404,10 @@ void setSensitivity(int sensitivity) {
touchPadSensitivity = sensitivity;
}
+void setGamma(int gamma) {
+ OSystem_DS::instance()->setGammaValue(gamma);
+}
+
void setTopScreenZoom(int percentage) {
// 100 256
// 150 192
@@ -426,18 +479,18 @@ int getGameHeight() {
void initSprites() {
for (int i = 0; i < 128; i++) {
- sprites[i].attribute[0] = ATTR0_DISABLED;
- sprites[i].attribute[1] = 0;
- sprites[i].attribute[2] = 0;
- sprites[i].filler = 0;
- }
+ sprites[i].attribute[0] = ATTR0_DISABLED;
+ sprites[i].attribute[1] = 0;
+ sprites[i].attribute[2] = 0;
+ sprites[i].filler = 0;
+ }
for (int i = 0; i < 128; i++) {
- spritesMain[i].attribute[0] = ATTR0_DISABLED;
- spritesMain[i].attribute[1] = 0;
- spritesMain[i].attribute[2] = 0;
- spritesMain[i].filler = 0;
- }
+ spritesMain[i].attribute[0] = ATTR0_DISABLED;
+ spritesMain[i].attribute[1] = 0;
+ spritesMain[i].attribute[2] = 0;
+ spritesMain[i].filler = 0;
+ }
updateOAM();
}
@@ -502,7 +555,6 @@ void initGame() {
// static bool firstTime = true;
-
setOptions();
//strcpy(gameName, ConfMan.getActiveDomain().c_str());
@@ -592,9 +644,9 @@ void displayMode8Bit() {
BG3_CR = BG_BMP16_256x256 | BG_BMP_BASE(8);
BG3_XDX = 256;
- BG3_XDY = 0;
- BG3_YDX = 0;
- BG3_YDY = (int) ((200.0f / 192.0f) * 256);
+ BG3_XDY = 0;
+ BG3_YDX = 0;
+ 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);
@@ -611,9 +663,9 @@ void displayMode8Bit() {
BG3_CR = BG_BMP8_512x256 | BG_BMP_BASE(8);
BG3_XDX = (int) (((float) (gameWidth) / 256.0f) * 256);
- BG3_XDY = 0;
- BG3_YDX = 0;
- BG3_YDY = (int) ((200.0f / 192.0f) * 256);
+ BG3_XDY = 0;
+ BG3_YDX = 0;
+ BG3_YDY = (int) ((200.0f / 192.0f) * 256);
}
SUB_BG3_CR = BG_BMP8_512x256;
@@ -625,11 +677,13 @@ void displayMode8Bit() {
- if (consoleEnable) {
- consoleInit(NULL, 0, BgType_Text4bpp, BgSize_T_256x256, 2, 0, true);
- // Move the cursor to the bottom of the screen using ANSI escape code
- consolePrintf("\033[23;0f");
- }
+ consoleInit(NULL, 0, BgType_Text4bpp, BgSize_T_256x256, 2, 0, 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);
+
+ // Move the cursor to the bottom of the screen using ANSI escape code
+ consolePrintf("\033[23;0f");
for (int r = 0; r < 32 * 32; r++) {
@@ -638,7 +692,9 @@ void displayMode8Bit() {
}
// ConsoleInit destroys the hardware palette :-(
- OSystem_DS::instance()->restoreHardwarePalette();
+ if (OSystem_DS::instance()) {
+ OSystem_DS::instance()->restoreHardwarePalette();
+ }
// BG_PALETTE_SUB[255] = RGB15(31,31,31);//by default font will be rendered with color 255
@@ -912,12 +968,12 @@ void displayMode16BitFlipBuffer() {
}
}
} else if (isCpuScalerEnabled()) {
- //#define SCALER_PROFILE
+ //#define SCALER_PROFILE
- #ifdef SCALER_PROFILE
- TIMER1_CR = TIMER_ENABLE | TIMER_DIV_1024;
- u16 t0 = TIMER1_DATA;
- #endif
+ #ifdef SCALER_PROFILE
+ TIMER1_CR = TIMER_ENABLE | TIMER_DIV_1024;
+ u16 t0 = TIMER1_DATA;
+ #endif
const u8* back = (const u8*)get8BitBackBuffer();
u16* base = BG_GFX + 0x10000;
Rescale_320x256xPAL8_To_256x256x1555(
@@ -928,19 +984,19 @@ void displayMode16BitFlipBuffer() {
BG_PALETTE,
getGameHeight() );
- #ifdef SCALER_PROFILE
- // 10 pixels : 1ms
- u16 t1 = TIMER1_DATA;
- TIMER1_CR &= ~TIMER_ENABLE;
- u32 dt = t1 - t0;
- u32 dt_us = (dt * 10240) / 334;
- u32 dt_10ms = dt_us / 100;
- int i;
- for(i=0; i<dt_10ms; ++i)
- base[i] = ((i/10)&1) ? 0xFFFF : 0x801F;
- for(; i<256; ++i)
- base[i] = 0x8000;
- #endif
+ #ifdef SCALER_PROFILE
+ // 10 pixels : 1ms
+ u16 t1 = TIMER1_DATA;
+ TIMER1_CR &= ~TIMER_ENABLE;
+ u32 dt = t1 - t0;
+ u32 dt_us = (dt * 10240) / 334;
+ u32 dt_10ms = dt_us / 100;
+ int i;
+ for(i=0; i<dt_10ms; ++i)
+ base[i] = ((i/10)&1) ? 0xFFFF : 0x801F;
+ for(; i<256; ++i)
+ base[i] = 0x8000;
+ #endif
}
#ifdef HEAVY_LOGGING
consolePrintf("done\n");
@@ -1209,9 +1265,9 @@ void setKeyboardEnable(bool en) {
}
}
/*
- for (int r = 0; r < (512 * 256) >> 1; r++)
- BG_GFX_SUB[r] = buffer[r];
- */
+ for (int r = 0; r < (512 * 256) >> 1; r++)
+ BG_GFX_SUB[r] = buffer[r];
+*/
SUB_DISPLAY_CR &= ~DISPLAY_BG1_ACTIVE; // Turn off keyboard layer
SUB_DISPLAY_CR |= DISPLAY_BG3_ACTIVE; // Turn on game layer
} else {
@@ -1597,7 +1653,7 @@ void addEventsToQueue() {
doButtonSelectMode(system);
}
- if (((!(getKeysHeld() & KEY_L)) && (!(getKeysHeld() & KEY_R)) || (indyFightState)) && (displayModeIs8Bit)) {
+ if (((!(getKeysHeld() & KEY_L)) && (!(getKeysHeld() & KEY_R)) || (indyFightState)) && (displayModeIs8Bit)) {
// Controls specific to the control method
@@ -2031,9 +2087,9 @@ void VBlankHandler(void) {
SUB_BG3_CY = subScY + (shakePos << 8);*/
/*SUB_BG3_XDX = (int) (subScreenWidth / 256.0f * 256);
- SUB_BG3_XDY = 0;
- SUB_BG3_YDX = 0;
- SUB_BG3_YDY = (int) (subScreenHeight / 192.0f * 256);*/
+ SUB_BG3_XDY = 0;
+ SUB_BG3_YDX = 0;
+ SUB_BG3_YDY = (int) (subScreenHeight / 192.0f * 256);*/
static int ratio = (320 << 8) / SCUMM_GAME_WIDTH;
@@ -2886,7 +2942,6 @@ void powerOff() {
void dsExceptionHandler() {
consolePrintf("Blue screen of death");
setExceptionHandler(NULL);
- while(1);
u32 currentMode = getCPSR() & 0x1f;
u32 thumbState = ((*(u32*)0x027FFD90) & 0x20);
@@ -2918,7 +2973,7 @@ void dsExceptionHandler() {
int i;
for ( i=0; i < 8; i++ ) {
- consolePrintf( " %s: %08X %s: %08X\n",
+ consolePrintf(" %s: %08X %s: %08X\n",
registerNames[i], exceptionRegisters[i],
registerNames[i+8],exceptionRegisters[i+8]);
}
@@ -3025,7 +3080,7 @@ int main(void) {
consolePrintf("-------------------------------\n");
consolePrintf("ScummVM DS\n");
consolePrintf("Ported by Neil Millstone\n");
- consolePrintf("Version 0.13.1 beta1 ");
+ consolePrintf("Version 1.0.0 RC1 ");
#if defined(DS_BUILD_A)
consolePrintf("build A\n");
consolePrintf("Lucasarts SCUMM games (SCUMM)\n");
@@ -3219,3 +3274,12 @@ int cygprofile_getHBlanks() {
return DS::hBlankCount;
}
#endif
+
+
+extern "C" void consolePrintf(const char * format, ...) {
+ char buffer[256];
+ va_list args;
+ va_start(args, format);
+ viprintf(format, args);
+ va_end(args);
+}
diff --git a/backends/platform/ds/arm9/source/dsmain.h b/backends/platform/ds/arm9/source/dsmain.h
index 49501a1fdf..223221d80e 100644
--- a/backends/platform/ds/arm9/source/dsmain.h
+++ b/backends/platform/ds/arm9/source/dsmain.h
@@ -85,6 +85,7 @@ void setTalkPos(int x, int y);
void setTopScreenTarget(int x, int y);
void set200PercentFixedScale(bool on);
void setTopScreenZoom(int percentage);
+void setGamma(int gamma);
// Timers
void setTimerCallback(OSystem_DS::TimerProc proc, int interval); // Setup a callback function at a regular interval
diff --git a/backends/platform/ds/arm9/source/dsoptions.cpp b/backends/platform/ds/arm9/source/dsoptions.cpp
index 90f371e0a8..9937e81e61 100644
--- a/backends/platform/ds/arm9/source/dsoptions.cpp
+++ b/backends/platform/ds/arm9/source/dsoptions.cpp
@@ -94,11 +94,11 @@ DSOptionsDialog::DSOptionsDialog() : GUI::Dialog(0, 0, 320 - 10, 230 - 40) {
_tab->addTab("Graphics");
- new GUI::StaticTextWidget(_tab, 5, 70, 180, 15, "Initial top screen scale:", Graphics::kTextAlignLeft);
+ new GUI::StaticTextWidget(_tab, 5, 67, 180, 15, "Initial top screen scale:", Graphics::kTextAlignLeft);
- _100PercentCheckbox = new GUI::CheckboxWidget(_tab, 5, 85, 230, 20, "100%", 0x30000001, 'T');
- _150PercentCheckbox = new GUI::CheckboxWidget(_tab, 5, 100, 230, 20, "150%", 0x30000002, 'T');
- _200PercentCheckbox = new GUI::CheckboxWidget(_tab, 5, 115, 230, 20, "200%", 0x30000003, 'T');
+ _100PercentCheckbox = new GUI::CheckboxWidget(_tab, 5, 82, 80, 20, "100%", 0x30000001, 'T');
+ _150PercentCheckbox = new GUI::CheckboxWidget(_tab, 5, 97, 80, 20, "150%", 0x30000002, 'T');
+ _200PercentCheckbox = new GUI::CheckboxWidget(_tab, 5, 112, 80, 20, "200%", 0x30000003, 'T');
new GUI::StaticTextWidget(_tab, 5, 5, 180, 15, "Main screen scaling:", Graphics::kTextAlignLeft);
@@ -106,6 +106,14 @@ DSOptionsDialog::DSOptionsDialog() : GUI::Dialog(0, 0, 320 - 10, 230 - 40) {
_cpuScaler = new GUI::CheckboxWidget(_tab, 5, 35, 270, 20, "Software scale (good quality, but slower)", 0x10000002, 'S');
_unscaledCheckbox = new GUI::CheckboxWidget(_tab, 5, 50, 270, 20, "Unscaled (you must scroll left and right)", 0x10000003, 'S');
+ new GUI::StaticTextWidget(_tab, 5, 125, 110, 15, "Brightness:", Graphics::kTextAlignLeft);
+ _gammaCorrection = new GUI::SliderWidget(_tab, 130, 120, 130, 12, 1);
+ _gammaCorrection->setMinValue(0);
+ _gammaCorrection->setMaxValue(8);
+ _gammaCorrection->setValue(0);
+
+
+
_tab->addTab("General");
_highQualityAudioCheckbox = new GUI::CheckboxWidget(_tab, 5, 5, 250, 20, "High quality audio (slower) (reboot)", 0, 'T');
@@ -170,6 +178,12 @@ DSOptionsDialog::DSOptionsDialog() : GUI::Dialog(0, 0, 320 - 10, 230 - 40) {
_150PercentCheckbox->setState(true);
}
+ if (ConfMan.hasKey("gamma", "ds")) {
+ _gammaCorrection->setValue(ConfMan.getInt("gamma", "ds"));
+ } else {
+ _gammaCorrection->setValue(0);
+ }
+
_highQualityAudioCheckbox->setState(confGetBool("22khzaudio", false));
_disablePowerOff->setState(confGetBool("disablepoweroff", false));
@@ -219,6 +233,7 @@ void DSOptionsDialog::updateConfigManager() {
ConfMan.setBool("touchpad", _touchPadStyle->getState(), "ds");
ConfMan.setBool("screentaps", _screenTaps->getState(), "ds");
ConfMan.setInt("sensitivity", _sensitivity->getValue(), "ds");
+ ConfMan.setInt("gamma", _gammaCorrection->getValue(), "ds");
u32 zoomLevel = 150;
@@ -395,6 +410,9 @@ void setOptions() {
DS::setTapScreenClicksEnable(confGetBool("screentaps", false));
+ DS::setGamma(confGetInt("gamma", 0));
+
+
if (ConfMan.hasKey("touchpad", "ds")) {
bool enable = ConfMan.getBool("touchpad", "ds");
diff --git a/backends/platform/ds/arm9/source/dsoptions.h b/backends/platform/ds/arm9/source/dsoptions.h
index d29dd9d8ac..4b3ac36d45 100644
--- a/backends/platform/ds/arm9/source/dsoptions.h
+++ b/backends/platform/ds/arm9/source/dsoptions.h
@@ -53,6 +53,7 @@ protected:
GUI::SliderWidget* _touchX;
GUI::SliderWidget* _touchY;
GUI::SliderWidget* _sensitivity;
+ GUI::SliderWidget* _gammaCorrection;
GUI::CheckboxWidget* _leftHandedCheckbox;
GUI::CheckboxWidget* _unscaledCheckbox;
GUI::CheckboxWidget* _100PercentCheckbox;
diff --git a/backends/platform/ds/arm9/source/osystem_ds.cpp b/backends/platform/ds/arm9/source/osystem_ds.cpp
index 5c5663f872..1654bb31e7 100644
--- a/backends/platform/ds/arm9/source/osystem_ds.cpp
+++ b/backends/platform/ds/arm9/source/osystem_ds.cpp
@@ -38,14 +38,35 @@
#include "touchkeyboard.h"
#include "backends/fs/ds/ds-fs-factory.h"
+#ifdef ENABLE_AGI
+#include "wordcompletion.h"
+#endif
+
#include <time.h>
+#if defined(DS_BUILD_A)
+#define DEFAULT_CONFIG_FILE "scummvm.ini"
+#elif defined(DS_BUILD_B)
+#define DEFAULT_CONFIG_FILE "scummvmb.ini"
+#elif defined(DS_BUILD_C)
+#define DEFAULT_CONFIG_FILE "scummvmc.ini"
+#elif defined(DS_BUILD_D)
+#define DEFAULT_CONFIG_FILE "scummvmd.ini"
+#elif defined(DS_BUILD_E)
+#define DEFAULT_CONFIG_FILE "scummvme.ini"
+#elif defined(DS_BUILD_F)
+#define DEFAULT_CONFIG_FILE "scummvmf.ini"
+#elif defined(DS_BUILD_G)
+#define DEFAULT_CONFIG_FILE "scummvmg.ini"
+#elif defined(DS_BUILD_H)
+#define DEFAULT_CONFIG_FILE "scummvmh.ini"
+#endif
OSystem_DS* OSystem_DS::_instance = NULL;
OSystem_DS::OSystem_DS()
: eventNum(0), lastPenFrame(0), queuePos(0), _mixer(NULL), _timer(NULL), _frameBufferExists(false),
- _disableCursorPalette(true), _graphicsEnable(true)
+ _disableCursorPalette(true), _graphicsEnable(true), _gammaValue(0)
{
// eventNum = 0;
// lastPenFrame = 0;
@@ -161,9 +182,11 @@ void OSystem_DS::setPalette(const byte *colors, uint start, uint num) {
u16 paletteValue = red | (green << 5) | (blue << 10);
if (DS::getIsDisplayMode8Bit()) {
- BG_PALETTE[r] = paletteValue;
+ int col = applyGamma(paletteValue);
+ BG_PALETTE[r] = col;
+
if (!DS::getKeyboardEnable()) {
- BG_PALETTE_SUB[r] = paletteValue;
+ BG_PALETTE_SUB[r] = col;
}
}
@@ -180,10 +203,10 @@ void OSystem_DS::restoreHardwarePalette()
// Set the hardware palette up based on the stored palette
for (int r = 0; r < 255; r++) {
- BG_PALETTE[r] = _palette[r];
-
+ int col = applyGamma(_palette[r]);
+ BG_PALETTE[r] = col;
if (!DS::getKeyboardEnable()) {
- BG_PALETTE_SUB[r] = _palette[r];
+ BG_PALETTE_SUB[r] = col;
}
}
}
@@ -207,6 +230,7 @@ void OSystem_DS::setCursorPalette(const byte *colors, uint start, uint num) {
}
_disableCursorPalette = false;
+ refreshCursor();
}
bool OSystem_DS::grabRawScreen(Graphics::Surface* surf) {
@@ -271,65 +295,113 @@ void OSystem_DS::copyRectToScreen(const byte *buf, int pitch, int x, int y, int
if (DS::getKeyboardEnable()) {
// When they keyboard is on screen, we don't update the subscreen because
- // the keyboard image uses the same VRAM addresses. In order to do this,
- // I'm going to update the main screen twice. This avoids putting a compare
- // in the loop and slowing down the common case.
- bgSub = bg;
- }
+ // the keyboard image uses the same VRAM addresses.
+
+ for (int dy = y; dy < y + h; dy++) {
+ u8* dest = ((u8 *) (bg)) + (dy * stride) + x;
+ u8* src = (u8 *) buf + (pitch * by);
- for (int dy = y; dy < y + h; dy++) {
- u8* dest = ((u8 *) (bg)) + (dy * stride) + x;
- u8* destSub = ((u8 *) (bgSub)) + (dy * 512) + x;
- u8* src = (u8 *) buf + (pitch * by);
+ u32 dx;
- u32 dx;
+ u32 pixelsLeft = w;
- u32 pixelsLeft = w;
+ if (MISALIGNED16(dest)) {
+ // Read modify write
- if (MISALIGNED16(dest)) {
- // Read modify write
+ dest--;
+ u16 mix = *((u16 *) dest);
- dest--;
- u16 mix = *((u16 *) dest);
+ mix = (mix & 0x00FF) | (*src++ << 8);
- mix = (mix & 0x00FF) | (*src++ << 8);
+ *dest = mix;
- *dest = mix;
- *destSub = mix;
+ dest += 2;
+ pixelsLeft--;
+ }
- dest += 2;
- destSub += 2;
- pixelsLeft--;
- }
+ // We can now assume dest is aligned
+ u16* dest16 = (u16 *) dest;
- // We can now assume dest is aligned
- u16* dest16 = (u16 *) dest;
- u16* destSub16 = (u16 *) destSub;
+ for (dx = 0; dx < pixelsLeft; dx+=2) {
+ u16 mix;
- for (dx = 0; dx < pixelsLeft; dx+=2) {
- u16 mix;
+ mix = *src + (*(src + 1) << 8);
+ *dest16++ = mix;
+ src += 2;
+ }
- mix = *src + (*(src + 1) << 8);
- *dest16++ = mix;
- *destSub16++ = mix;
- src += 2;
- }
+ pixelsLeft -= dx;
- pixelsLeft -= dx;
+ // At the end we may have one pixel left over
- // At the end we may have one pixel left over
+ if (pixelsLeft != 0) {
+ u16 mix = *dest16;
- if (pixelsLeft != 0) {
- u16 mix = *dest16;
+ mix = (mix & 0x00FF) | ((*src++) << 8);
- mix = (mix & 0x00FF) | ((*src++) << 8);
+ *dest16 = mix;
+ }
- *dest16 = mix;
- *destSub16 = mix;
+ by++;
}
- by++;
+ } else {
+ // When they keyboard is not on screen, update both vram copies
+
+ for (int dy = y; dy < y + h; dy++) {
+ u8* dest = ((u8 *) (bg)) + (dy * stride) + x;
+ u8* destSub = ((u8 *) (bgSub)) + (dy * 512) + x;
+ u8* src = (u8 *) buf + (pitch * by);
+
+ u32 dx;
+
+ u32 pixelsLeft = w;
+
+ if (MISALIGNED16(dest)) {
+ // Read modify write
+
+ dest--;
+ u16 mix = *((u16 *) dest);
+
+ mix = (mix & 0x00FF) | (*src++ << 8);
+
+ *dest = mix;
+ *destSub = mix;
+
+ dest += 2;
+ destSub += 2;
+ pixelsLeft--;
+ }
+
+ // We can now assume dest is aligned
+ u16* dest16 = (u16 *) dest;
+ u16* destSub16 = (u16 *) destSub;
+
+ for (dx = 0; dx < pixelsLeft; dx+=2) {
+ u16 mix;
+
+ mix = *src + (*(src + 1) << 8);
+ *dest16++ = mix;
+ *destSub16++ = mix;
+ src += 2;
+ }
+ pixelsLeft -= dx;
+
+ // At the end we may have one pixel left over
+
+ if (pixelsLeft != 0) {
+ u16 mix = *dest16;
+
+ mix = (mix & 0x00FF) | ((*src++) << 8);
+
+ *dest16 = mix;
+ *destSub16 = mix;
+ }
+
+ by++;
+
+ }
}
// consolePrintf("Slow method used!\n");
@@ -763,3 +835,53 @@ void OSystem_DS::clearAutoComplete() {
void OSystem_DS::setCharactersEntered(int count) {
DS::setCharactersEntered(count);
}
+
+Common::SeekableReadStream* OSystem_DS::createConfigReadStream() {
+ Common::FSNode file(DEFAULT_CONFIG_FILE);
+// consolePrintf("R %s", DEFAULT_CONFIG_FILE);
+ return file.createReadStream();
+}
+
+Common::WriteStream* OSystem_DS::createConfigWriteStream() {
+ Common::FSNode file(DEFAULT_CONFIG_FILE);
+// consolePrintf("W %s", DEFAULT_CONFIG_FILE);
+ return file.createWriteStream();
+}
+
+u16 OSystem_DS::applyGamma(u16 colour) {
+ // Attempt to do gamma correction (or something like it) to palette entries
+ // to improve the contrast of the image on the original DS screen.
+
+ // Split the colour into it's component channels
+ int r = colour & 0x001F;
+ int g = (colour & 0x03E0) >> 5;
+ int b = (colour & 0x7C00) >> 10;
+
+ // Caluclate the scaling factor for this colour based on it's brightness
+ int scale = ((23 - ((r + g + b) >> 2)) * _gammaValue) >> 3;
+
+ // Scale the three components by the scaling factor, with clamping
+ r = r + ((r * scale) >> 4);
+ if (r > 31) r = 31;
+
+ g = g + ((g * scale) >> 4);
+ if (g > 31) g = 31;
+
+ b = b + ((b * scale) >> 4);
+ if (b > 31) b = 31;
+
+ // Stick them back together into a 555 colour value
+ return 0x8000 | r | (g << 5) | (b << 10);
+}
+
+void OSystem_DS::engineDone() {
+ // Scumm games appear not to stop their CD audio, so I stop the CD here.
+ stopCD();
+
+#ifdef ENABLE_AGI
+ DS::clearAutoCompleteWordList();
+#endif
+
+}
+
+
diff --git a/backends/platform/ds/arm9/source/osystem_ds.h b/backends/platform/ds/arm9/source/osystem_ds.h
index 760872b0d9..ce55ec2740 100644
--- a/backends/platform/ds/arm9/source/osystem_ds.h
+++ b/backends/platform/ds/arm9/source/osystem_ds.h
@@ -71,6 +71,8 @@ protected:
Graphics::Surface* createTempFrameBuffer();
bool _disableCursorPalette;
+ int _gammaValue;
+
public:
typedef void (*SoundProc)(byte *buf, int len);
typedef int (*TimerProc)(int interval);
@@ -171,6 +173,14 @@ public:
FilesystemFactory *getFilesystemFactory();
void refreshCursor();
+
+ Common::WriteStream* createConfigWriteStream();
+ Common::SeekableReadStream* createConfigReadStream();
+
+ u16 applyGamma(u16 colour);
+ void setGammaValue(int gamma) { _gammaValue = gamma; }
+
+ void engineDone();
};
static const OSystem::GraphicsMode s_supportedGraphicsModes[] = {
diff --git a/backends/platform/ds/arm9/source/portdefs.h b/backends/platform/ds/arm9/source/portdefs.h
index 560bd8ab4b..5472b711b8 100644
--- a/backends/platform/ds/arm9/source/portdefs.h
+++ b/backends/platform/ds/arm9/source/portdefs.h
@@ -55,19 +55,22 @@ typedef signed int s32;
#define DISABLE_TEXT_CONSOLE
#define DISABLE_COMMAND_LINE
+#define STREAM_AUDIO_FROM_DISK
+
+//#undef assert
+//#define assert(expr) consolePrintf("Asserted!")
+#define NO_DEBUG_MSGS
+
+
+// This is defined in dsmain.cpp
#ifdef __cplusplus
extern "C" {
#endif
-int consolePrintf(const char* s, ...);
+void consolePrintf(const char *format, ...);
#ifdef __cplusplus
}
#endif
-//#undef assert
-//#define assert(expr) consolePrintf("Asserted!")
-#define NO_DEBUG_MSGS
-
-#define consolePrintf iprintf
#ifdef assert
#undef assert
@@ -82,7 +85,7 @@ int consolePrintf(const char* s, ...);
#define ITCM_DATA __attribute__((section(".itcm")))
-// Since I can't change the engine at the moment (post lockdown) this define can go here.
+// FIXME: Since I can't change the engine at the moment (post lockdown) this define can go here.
// This define changes the mouse-relative motion which doesn't make sense on a touch screen to
// a more conventional form of input where the menus can be clicked on.
#define LURE_CLICKABLE_MENUS
diff --git a/backends/platform/ds/arm9/source/wordcompletion.cpp b/backends/platform/ds/arm9/source/wordcompletion.cpp
index c66286d64d..035f6a631d 100644
--- a/backends/platform/ds/arm9/source/wordcompletion.cpp
+++ b/backends/platform/ds/arm9/source/wordcompletion.cpp
@@ -60,6 +60,11 @@ int stringCompare(const void* a, const void* b) {
return scumm_stricmp(*as, *bs);
}
+void clearAutoCompleteWordList() {
+ wordBufferPtrPos = 0;
+ wordBufferPos = 0;
+}
+
void sortAutoCompleteWordList() {
// Sort the whole word list into alphabetical order
qsort((void *)wordBufferPtr, wordBufferPtrPos, 4, stringCompare);
diff --git a/backends/platform/ds/arm9/source/wordcompletion.h b/backends/platform/ds/arm9/source/wordcompletion.h
index aa689ae8ec..e50bade37b 100644
--- a/backends/platform/ds/arm9/source/wordcompletion.h
+++ b/backends/platform/ds/arm9/source/wordcompletion.h
@@ -1,5 +1,6 @@
namespace DS {
+extern void clearAutoCompleteWordList();
extern bool findWordCompletions(const char *input);
extern void addAutoCompleteLine(const char *line);
extern void sortAutoCompleteWordList();