aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorMax Horn2009-03-19 09:51:40 +0000
committerMax Horn2009-03-19 09:51:40 +0000
commitb5bcc1a23af73761f6ff40f79db0a5beb8ae82f1 (patch)
tree6ddd0d5b8e01a63fdcbc1b1c9d1a1a0739a1966d /backends
parent8dc12da206cc850b3bd2bd456e4607ded695704d (diff)
downloadscummvm-rg350-b5bcc1a23af73761f6ff40f79db0a5beb8ae82f1.tar.gz
scummvm-rg350-b5bcc1a23af73761f6ff40f79db0a5beb8ae82f1.tar.bz2
scummvm-rg350-b5bcc1a23af73761f6ff40f79db0a5beb8ae82f1.zip
Merged Neil's NDS changes into trunk
svn-id: r39526
Diffstat (limited to 'backends')
-rw-r--r--backends/fs/ds/ds-fs.cpp114
-rw-r--r--backends/fs/ds/ds-fs.h36
-rw-r--r--backends/platform/ds/arm7/source/main.cpp17
-rw-r--r--backends/platform/ds/arm9/makefile61
-rw-r--r--backends/platform/ds/arm9/source/blitters_arm.s10
-rw-r--r--backends/platform/ds/arm9/source/cdaudio.cpp1
-rw-r--r--backends/platform/ds/arm9/source/console2.h124
-rw-r--r--backends/platform/ds/arm9/source/dsmain.cpp187
-rw-r--r--backends/platform/ds/arm9/source/dsmain.h1
-rw-r--r--backends/platform/ds/arm9/source/dsoptions.cpp32
-rw-r--r--backends/platform/ds/arm9/source/dsoptions.h1
-rw-r--r--backends/platform/ds/arm9/source/fat/disc_io.c1
-rw-r--r--backends/platform/ds/arm9/source/interrupt.s154
-rw-r--r--backends/platform/ds/arm9/source/osystem_ds.cpp48
-rw-r--r--backends/platform/ds/arm9/source/osystem_ds.h1
-rw-r--r--backends/platform/ds/arm9/source/portdefs.h5
-rw-r--r--backends/platform/ds/arm9/source/scummconsole.c568
-rw-r--r--backends/platform/ds/arm9/source/scummconsole.h67
-rw-r--r--backends/platform/ds/arm9/source/scummhelp.cpp13
-rw-r--r--backends/platform/ds/commoninclude/NDS/scummvm_ipc.h12
20 files changed, 551 insertions, 902 deletions
diff --git a/backends/fs/ds/ds-fs.cpp b/backends/fs/ds/ds-fs.cpp
index 79f10fdb62..92bdba0650 100644
--- a/backends/fs/ds/ds-fs.cpp
+++ b/backends/fs/ds/ds-fs.cpp
@@ -197,11 +197,11 @@ AbstractFSNode* DSFileSystemNode::getParent() const {
}
Common::SeekableReadStream *DSFileSystemNode::createReadStream() {
- return StdioStream::makeFromPath(getPath().c_str(), false);
+ return DSFileStream::makeFromPath(getPath().c_str(), false);
}
Common::WriteStream *DSFileSystemNode::createWriteStream() {
- return StdioStream::makeFromPath(getPath().c_str(), true);
+ return DSFileStream::makeFromPath(getPath().c_str(), true);
}
//////////////////////////////////////////////////////////////////////////
@@ -211,9 +211,8 @@ Common::WriteStream *DSFileSystemNode::createWriteStream() {
GBAMPFileSystemNode::GBAMPFileSystemNode() {
_displayName = "mp:/";
_path = "mp:/";
- _isValid = true;
+ _isValid = false;
_isDirectory = true;
- _path = "mp:/";
}
GBAMPFileSystemNode::GBAMPFileSystemNode(const Common::String& path) {
@@ -283,9 +282,9 @@ GBAMPFileSystemNode::GBAMPFileSystemNode(const GBAMPFileSystemNode* node) {
AbstractFSNode *GBAMPFileSystemNode::getChild(const Common::String& n) const {
if (_path.lastChar() == '\\') {
- return new DSFileSystemNode(_path + n);
+ return new GBAMPFileSystemNode(_path + n);
} else {
- return new DSFileSystemNode(_path + "\\" + n);
+ return new GBAMPFileSystemNode(_path + "\\" + n);
}
return NULL;
@@ -376,16 +375,113 @@ Common::SeekableReadStream *GBAMPFileSystemNode::createReadStream() {
// consolePrintf("Opening: %s\n", getPath().c_str());
if (!strncmp(getPath().c_str(), "mp:/", 4)) {
- return StdioStream::makeFromPath(getPath().c_str() + 3, false);
+ return DSFileStream::makeFromPath(getPath().c_str() + 3, false);
} else {
- return StdioStream::makeFromPath(getPath().c_str(), false);
+ return DSFileStream::makeFromPath(getPath().c_str(), false);
}
}
Common::WriteStream *GBAMPFileSystemNode::createWriteStream() {
- return StdioStream::makeFromPath(getPath().c_str(), true);
+ return DSFileStream::makeFromPath(getPath().c_str(), true);
+}
+
+
+
+
+DSFileStream::DSFileStream(void *handle) : _handle(handle) {
+ assert(handle);
+ _writeBufferPos = 0;
+}
+
+DSFileStream::~DSFileStream() {
+ if (_writeBufferPos > 0) {
+ flush();
+ }
+ std_fclose((FILE *)_handle);
+}
+
+bool DSFileStream::err() const {
+ return std_ferror((FILE *)_handle) != 0;
+}
+
+void DSFileStream::clearErr() {
+ std_clearerr((FILE *)_handle);
+}
+
+bool DSFileStream::eos() const {
+ return std_feof((FILE *)_handle) != 0;
+}
+
+int32 DSFileStream::pos() const {
+ if (_writeBufferPos > 0) {
+ // Discard constness. Bad, but I can't see another way.
+ ((DSFileStream *) (this))->flush();
+ }
+ return std_ftell((FILE *)_handle);
+}
+
+int32 DSFileStream::size() const {
+ if (_writeBufferPos > 0) {
+ // Discard constness. Bad, but I can't see another way.
+ ((DSFileStream *) (this))->flush();
+ }
+ int32 oldPos = std_ftell((FILE *)_handle);
+ std_fseek((FILE *)_handle, 0, SEEK_END);
+ int32 length = std_ftell((FILE *)_handle);
+ std_fseek((FILE *)_handle, oldPos, SEEK_SET);
+
+ return length;
+}
+
+bool DSFileStream::seek(int32 offs, int whence) {
+ if (_writeBufferPos > 0) {
+ flush();
+ }
+ return std_fseek((FILE *)_handle, offs, whence) == 0;
+}
+
+uint32 DSFileStream::read(void *ptr, uint32 len) {
+ if (_writeBufferPos > 0) {
+ flush();
+ }
+ return std_fread((byte *)ptr, 1, len, (FILE *)_handle);
+}
+
+uint32 DSFileStream::write(const void *ptr, uint32 len) {
+ if (_writeBufferPos + len < WRITE_BUFFER_SIZE) {
+ memcpy(_writeBuffer + _writeBufferPos, ptr, len);
+ _writeBufferPos += len;
+ }
+ else
+ {
+ if (_writeBufferPos > 0) {
+ flush();
+ }
+ return std_fwrite(ptr, 1, len, (FILE *)_handle);
+ }
}
+bool DSFileStream::flush() {
+
+ if (_writeBufferPos > 0) {
+ std_fwrite(_writeBuffer, 1, _writeBufferPos, (FILE *) _handle);
+ _writeBufferPos = 0;
+ }
+
+ return std_fflush((FILE *)_handle) == 0;
+}
+
+DSFileStream *DSFileStream::makeFromPath(const Common::String &path, bool writeMode) {
+ FILE *handle = std_fopen(path.c_str(), writeMode ? "wb" : "rb");
+
+ if (handle)
+ return new DSFileStream(handle);
+ return 0;
+}
+
+
+
+
// Stdio replacements
#define MAX_FILE_HANDLES 32
diff --git a/backends/fs/ds/ds-fs.h b/backends/fs/ds/ds-fs.h
index beea422a14..c8bf7d6cf2 100644
--- a/backends/fs/ds/ds-fs.h
+++ b/backends/fs/ds/ds-fs.h
@@ -27,7 +27,6 @@
#include "common/fs.h"
#include "zipreader.h"
#include "ramsave.h"
-#include "scummconsole.h"
#include "fat/gba_nds_fat.h"
#include "backends/fs/abstract-fs.h"
@@ -168,6 +167,41 @@ struct fileHandle {
DSSaveFile* sramFile;
};
+
+class DSFileStream : public Common::SeekableReadStream, public Common::WriteStream, public Common::NonCopyable {
+protected:
+ static const int WRITE_BUFFER_SIZE = 512;
+
+ /** File handle to the actual file. */
+ void *_handle;
+
+ char _writeBuffer[WRITE_BUFFER_SIZE];
+ int _writeBufferPos;
+
+public:
+ /**
+ * Given a path, invokes fopen on that path and wrap the result in a
+ * StdioStream instance.
+ */
+ static DSFileStream *makeFromPath(const Common::String &path, bool writeMode);
+
+ DSFileStream(void *handle);
+ virtual ~DSFileStream();
+
+ bool err() const;
+ void clearErr();
+ bool eos() const;
+
+ virtual uint32 write(const void *dataPtr, uint32 dataSize);
+ virtual bool flush();
+
+ virtual int32 pos() const;
+ virtual int32 size() const;
+ bool seek(int32 offs, int whence = SEEK_SET);
+ uint32 read(void *dataPtr, uint32 dataSize);
+};
+
+
#undef stderr
#undef stdout
#undef stdin
diff --git a/backends/platform/ds/arm7/source/main.cpp b/backends/platform/ds/arm7/source/main.cpp
index d252ed44de..7029d96405 100644
--- a/backends/platform/ds/arm7/source/main.cpp
+++ b/backends/platform/ds/arm7/source/main.cpp
@@ -34,6 +34,8 @@
#include <bios.h>
#include <arm7/touch.h>
#include <arm7/clock.h>
+#include <arm7/audio.h>
+#include <system.h>
#include <stdlib.h>
#include <string.h>
//#include <registers_alt.h> // not needed in current libnds
@@ -135,13 +137,13 @@ void startSound(int sampleRate, const void* data, uint32 bytes, u8 channel=0, u8
switch (format) {
case 1: {
- flags |= SOUND_8BIT;
+ flags |= SOUND_FORMAT_8BIT;
flags |= SOUND_REPEAT;// | (1 << 15);
break;
}
case 0: {
- flags |= SOUND_16BIT;
+ flags |= SOUND_FORMAT_16BIT;
flags |= SOUND_REPEAT;// | (1 << 15);
break;
}
@@ -433,13 +435,14 @@ void InterruptTimer3() {
but = REG_KEYXY;
if (!(but & 0x40)) {
// Read the touch screen
- touchPosition p = touchReadXY();
+ touchPosition p;
+ touchReadXY(&p);
// x = touchRead(TSC_MEASURE_X);
// y = touchRead(TSC_MEASURE_Y);
- x = p.x;
- y = p.y;
+ x = p.rawx;
+ y = p.rawy;
xpx = p.px;
ypx = p.py;
@@ -581,13 +584,13 @@ int main(int argc, char ** argv) {
rtcReset();
//enable sound
- powerON(POWER_SOUND);
+// powerOn(POWER_SOUND);
SOUND_CR = SOUND_ENABLE | SOUND_VOL(0x7F);
IPC->soundData = 0;
IPC->reset = false;
-
+ fifoInit();
for (int r = 0; r < 8; r++) {
IPC->adpcm.arm7Buffer[r] = (u8 *) malloc(512);
diff --git a/backends/platform/ds/arm9/makefile b/backends/platform/ds/arm9/makefile
index 8f191d1f7e..09359f3ccd 100644
--- a/backends/platform/ds/arm9/makefile
+++ b/backends/platform/ds/arm9/makefile
@@ -8,36 +8,39 @@ libndsdir = $(DEVKITPRO)/libnds
# Select the build by setting SCUMM_BUILD to a,b,c,d,e,f or g.
# Anything else gets build a.
-ifeq ($(SCUMM_BUILD),h)
- DS_BUILD_H = 1
- else
- ifeq ($(SCUMM_BUILD),g)
- DS_BUILD_G = 1
- else
- ifeq ($(SCUMM_BUILD),f)
- DS_BUILD_F = 1
+ifeq ($(SCUMM_BUILD),i)
+ DS_BUILD_I = 1
+else
+ ifeq ($(SCUMM_BUILD),h)
+ DS_BUILD_H = 1
else
- ifeq ($(SCUMM_BUILD),e)
- DS_BUILD_E = 1
+ ifeq ($(SCUMM_BUILD),g)
+ DS_BUILD_G = 1
else
- ifeq ($(SCUMM_BUILD),d)
- DS_BUILD_D = 1
+ ifeq ($(SCUMM_BUILD),f)
+ DS_BUILD_F = 1
else
- ifeq ($(SCUMM_BUILD),c)
- DS_BUILD_C = 1
+ ifeq ($(SCUMM_BUILD),e)
+ DS_BUILD_E = 1
else
- ifeq ($(SCUMM_BUILD),b)
- DS_BUILD_B = 1
+ ifeq ($(SCUMM_BUILD),d)
+ DS_BUILD_D = 1
else
- DS_BUILD_A = 1
+ ifeq ($(SCUMM_BUILD),c)
+ DS_BUILD_C = 1
+ else
+ ifeq ($(SCUMM_BUILD),b)
+ DS_BUILD_B = 1
+ else
+ DS_BUILD_A = 1
+ endif
+ endif
endif
endif
endif
endif
endif
endif
-endif
-
# To do:
# - FAT cache?
@@ -151,6 +154,12 @@ ifdef DS_BUILD_H
BUILD=scummvm-H
endif
+ifdef DS_BUILD_I
+ DEFINES = -DDS_NON_SCUMM_BUILD -DDS_BUILD_H
+ LOGO = logog.bmp
+ ENABLE_TUCKER = STATIC_PLUGIN
+ BUILD=scummvm-H
+endif
ARM7BIN := -7 $(CURDIR)/../../arm7/arm7.bin
ICON := -b ../../../logo.bmp "ScummVM;By Neil Millstone;"
@@ -196,9 +205,12 @@ ifdef USE_MAD
DEFINES += -DUSE_MAD
endif
-DEFINES += -DDISABLE_TEXT_CONSOLE -DDISABLE_COMMAND_LINE -DREDUCE_MEMORY_USAGE
+DEFINES += -DREDUCE_MEMORY_USAGE
+
+# Removed, as these are done in portdefs.h
+# -DDISABLE_TEXT_CONSOLE -DDISABLE_COMMAND_LINE
-LDFLAGS = -specs=ds_arm9.specs -mthumb-interwork -Wl,--wrap,time -mno-fpu -Wl,-Map,map.txt -Wl,--gc-sections
+LDFLAGS = -specs=ds_arm9.specs -mthumb-interwork -mno-fpu -Wl,-Map,map.txt -Wl,--gc-sections
INCLUDES= -I$(portdir)/$(BUILD) -I$(srcdir) -I$(srcdir)/engines \
-I$(portdir)/data -I$(portdir)/../commoninclude \
@@ -239,8 +251,9 @@ endif
PORT_OBJS := $(portdir)/source/blitters_arm.o $(portdir)/source/cdaudio.o $(portdir)/source/dsmain.o \
$(portdir)/../../../fs/ds/ds-fs.o $(portdir)/source/gbampsave.o $(portdir)/source/scummhelp.o\
$(portdir)/source/osystem_ds.o $(portdir)/source/portdefs.o $(portdir)/source/ramsave.o\
- $(portdir)/source/scummconsole.o $(portdir)/source/touchkeyboard.o $(portdir)/source/zipreader.o\
- $(portdir)/source/dsoptions.o $(portdir)/source/keys.o $(portdir)/source/wordcompletion.o
+ $(portdir)/source/touchkeyboard.o $(portdir)/source/zipreader.o\
+ $(portdir)/source/dsoptions.o $(portdir)/source/keys.o $(portdir)/source/wordcompletion.o\
+ $(portdir)/source/interrupt.o
ifdef USE_PROFILER
PORT_OBJS += $(portdir)/source/profiler/cyg-profile.o
@@ -281,7 +294,7 @@ OPTLIST := actor.cpp ds_main.cpp osystem_ds.cpp blitters.cpp fmopl.cpp rate.cpp
OPT_SPEED := -O3
# Compiler options for files which should be optimised for space
-OPT_SIZE := -Os
+OPT_SIZE := -Os -mthumb
#-mthumb -fno-gcse -fno-schedule-insns2
diff --git a/backends/platform/ds/arm9/source/blitters_arm.s b/backends/platform/ds/arm9/source/blitters_arm.s
index 48ec316675..4f18639dec 100644
--- a/backends/platform/ds/arm9/source/blitters_arm.s
+++ b/backends/platform/ds/arm9/source/blitters_arm.s
@@ -20,9 +20,17 @@
@
@ @author Robin Watts (robin@wss.co.uk)
+@ .global timerTickHandler
+@ .align 2
+@ .code 32
+
+@timerTickHandler:
+@ bx lr
+
+
.global Rescale_320x256xPAL8_To_256x256x1555
.global Rescale_320x256x1555_To_256x256x1555
- .section .itcm,"ax", %progbits
+@ .section .itcm,"ax", %progbits
.align 2
.code 32
diff --git a/backends/platform/ds/arm9/source/cdaudio.cpp b/backends/platform/ds/arm9/source/cdaudio.cpp
index 4f66401b53..140c709a8c 100644
--- a/backends/platform/ds/arm9/source/cdaudio.cpp
+++ b/backends/platform/ds/arm9/source/cdaudio.cpp
@@ -25,7 +25,6 @@
#include "common/config-manager.h"
#include "dsmain.h"
#include "NDS/scummvm_ipc.h"
-#include "console2.h"
#define WAV_FORMAT_IMA_ADPCM 0x14
#define BUFFER_SIZE 8192
diff --git a/backends/platform/ds/arm9/source/console2.h b/backends/platform/ds/arm9/source/console2.h
deleted file mode 100644
index 86434dcb93..0000000000
--- a/backends/platform/ds/arm9/source/console2.h
+++ /dev/null
@@ -1,124 +0,0 @@
-//////////////////////////////////////////////////////////////////////
-//
-// consol.h --provides basic consol type print functionality
-//
-// version 0.1, February 14, 2005
-//
-// Copyright (C) 2005 Michael Noland (joat) and Jason Rogers (dovoto)
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any
-// damages arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any
-// purpose, including commercial applications, and to alter it and
-// redistribute it freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you
-// must not claim that you wrote the original software. If you use
-// this software in a product, an acknowledgment in the product
-// documentation would be appreciated but is not required.
-// 2. Altered source versions must be plainly marked as such, and
-// must not be misrepresented as being the original software.
-// 3. This notice may not be removed or altered from any source
-// distribution.
-//
-// Changelog:
-// 0.1: First version
-// 0.2: Fixed sprite mapping bug. 1D mapping should work now.
-// Changed some register defines for consistency.
-//
-//////////////////////////////////////////////////////////////////////
-#ifndef CONSOLE_H2
-#define CONSOLE_H2
-
-#define CONSOLE_USE_COLOR255 16
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void consoleInit(u16* font, u16* charBase, u16 numCharacters, u8 charStart, u16* map, u8 pal, u8 bitDepth);
-void consoleInitDefault(u16* map, u16* charBase, u8 bitDepth);
-
-void consolePrintf(const char* s, ...);
-
-void consolePrintSet(int x, int y);
-
-void consolePrintChar(char c);
-
-void consolePutString(int x, int y, char* s);
-void consolePutInt(int x, int y, int d);
-void consolePutX(int x, int y, int d);
-void consolePutChar(int x, int y, char c);
-void consolePutBin(int x, int y, int b);
-
-void consoleClear(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-//////////////////////////////////////////////////////////////////////
-//
-// consol.h --provides basic consol type print functionality
-//
-// version 0.1, February 14, 2005
-//
-// Copyright (C) 2005 Michael Noland (joat) and Jason Rogers (dovoto)
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any
-// damages arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any
-// purpose, including commercial applications, and to alter it and
-// redistribute it freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you
-// must not claim that you wrote the original software. If you use
-// this software in a product, an acknowledgment in the product
-// documentation would be appreciated but is not required.
-// 2. Altered source versions must be plainly marked as such, and
-// must not be misrepresented as being the original software.
-// 3. This notice may not be removed or altered from any source
-// distribution.
-//
-// Changelog:
-// 0.1: First version
-// 0.2: Fixed sprite mapping bug. 1D mapping should work now.
-// Changed some register defines for consistency.
-//
-//////////////////////////////////////////////////////////////////////
-#ifndef CONSOLE_H2
-#define CONSOLE_H2
-
-#define CONSOLE_USE_COLOR255 16
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void consoleInit(u16* font, u16* charBase, u16 numCharacters, u8 charStart, u16* map, u8 pal, u8 bitDepth);
-void consoleInitDefault(u16* map, u16* charBase, u8 bitDepth);
-
-void consolePrintf(const char* s, ...);
-
-void consolePrintSet(int x, int y);
-
-void consolePrintChar(char c);
-
-void consolePutString(int x, int y, char* s);
-void consolePutInt(int x, int y, int d);
-void consolePutX(int x, int y, int d);
-void consolePutChar(int x, int y, char c);
-void consolePutBin(int x, int y, int b);
-
-void consoleClear(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/backends/platform/ds/arm9/source/dsmain.cpp b/backends/platform/ds/arm9/source/dsmain.cpp
index 297e2c6037..621a2af082 100644
--- a/backends/platform/ds/arm9/source/dsmain.cpp
+++ b/backends/platform/ds/arm9/source/dsmain.cpp
@@ -67,6 +67,7 @@
#include <nds.h>
#include <nds/registers_alt.h>
#include <nds/arm9/exceptions.h>
+#include <nds/arm9/console.h>
//#include <ARM9/console.h> //basic print funcionality
@@ -94,8 +95,11 @@
#include "profiler/cyg-profile.h"
#endif
#include "backends/fs/ds/ds-fs.h"
+#include "engine.h"
+extern "C" void OurIntrMain(void);
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",
@@ -115,6 +119,7 @@ extern "C" void* __wrap_malloc(size_t size) {
}
*/
+
namespace DS {
// From console.c in NDSLib
@@ -556,22 +561,18 @@ void displayMode8Bit() {
#endif
u16 buffer[32 * 32];
+ initGame();
+
setKeyboardEnable(false);
if (!displayModeIs8Bit) {
for (int r = 0; r < 32 * 32; r++) {
buffer[r] = ((u16 *) SCREEN_BASE_BLOCK_SUB(4))[r];
}
- }
-
- consoleInitDefault((u16*)SCREEN_BASE_BLOCK(2), (u16*)CHAR_BASE_BLOCK(0), 16);
- consolePrintSet(0, 23);
-
- if (!displayModeIs8Bit) {
+ } else {
for (int r = 0; r < 32 * 32; r++) {
- ((u16 *) SCREEN_BASE_BLOCK(2))[r] = buffer[r];
+ buffer[r] = ((u16 *) SCREEN_BASE_BLOCK(2))[r];
}
-// dmaCopyHalfWords(3, (u16 *) SCREEN_BASE_BLOCK(0), buffer, 32 * 32 * 2);
}
displayModeIs8Bit = true;
@@ -618,16 +619,42 @@ void displayMode8Bit() {
SUB_BG3_CR = BG_BMP8_512x256;
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);
+
+
+
+ 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");
+ }
+// consoleInitDefault((u16*)SCREEN_BASE_BLOCK(2), (u16*)CHAR_BASE_BLOCK(0), 16);
+// consoleSetWindow(NULL, 0, 0, 32, 24);
+// consolePrintSet(0, 23);
+/* while (1) {
+ printf("Hello world");
+ }*/
+ for (int r = 0; r < 32 * 32; r++) {
+ ((u16 *) SCREEN_BASE_BLOCK(2))[r] = buffer[r];
+// dmaCopyHalfWords(3, (u16 *) SCREEN_BASE_BLOCK(0), buffer, 32 * 32 * 2);
+ }
+
+ // ConsoleInit destroys the hardware palette :-(
+ OSystem_DS::instance()->restoreHardwarePalette();
+
+// BG_PALETTE_SUB[255] = RGB15(31,31,31);//by default font will be rendered with color 255
+
// Do text stuff
// console chars at 1C000 (7), map at 1D000 (74)
- BG0_CR = BG_MAP_BASE(2) | BG_TILE_BASE(0);
- BG0_Y0 = 0;
+// BG0_CR = BG_MAP_BASE(2) | BG_TILE_BASE(0);
+// BG0_Y0 = 0;
// Restore palette entry used by text in the front-end
// PALETTE_SUB[255] = savedPalEntry255;
@@ -635,7 +662,6 @@ void displayMode8Bit() {
- initGame();
#ifdef HEAVY_LOGGING
consolePrintf("done\n");
@@ -808,9 +834,11 @@ void displayMode16Bit() {
releaseAllKeys();
- if (displayModeIs8Bit) {
-// static int test = 0;
-// consolePrintf("saving buffer... %d\n", test++);
+ if (!displayModeIs8Bit) {
+ for (int r = 0; r < 32 * 32; r++) {
+ buffer[r] = ((u16 *) SCREEN_BASE_BLOCK_SUB(4))[r];
+ }
+ } else {
saveGameBackBuffer();
for (int r = 0; r < 32 * 32; r++) {
buffer[r] = ((u16 *) SCREEN_BASE_BLOCK(2))[r];
@@ -833,24 +861,24 @@ void displayMode16Bit() {
memset(BG_GFX, 0, 512 * 256 * 2);
- savedPalEntry255 = PALETTE_SUB[255];
- PALETTE_SUB[255] = RGB15(31,31,31);//by default font will be rendered with color 255
+ savedPalEntry255 = BG_PALETTE_SUB[255];
+ BG_PALETTE_SUB[255] = RGB15(31,31,31);//by default font will be rendered with color 255
// Do text stuff
SUB_BG0_CR = BG_MAP_BASE(4) | BG_TILE_BASE(0);
SUB_BG0_Y0 = 0;
- consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(4), (u16*)CHAR_BASE_BLOCK_SUB(0), 16);
+ consoleInit(NULL, 0, BgType_Text4bpp, BgSize_T_256x256, 4, 0, false);
+// consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(4), (u16*)CHAR_BASE_BLOCK_SUB(0), 16);
- if (displayModeIs8Bit) {
- //dmaCopyHalfWords(3, (u16 *) SCREEN_BASE_BLOCK_SUB(0), buffer, 32 * 32 * 2);
- for (int r = 0; r < 32 * 32; r++) {
- ((u16 *) SCREEN_BASE_BLOCK_SUB(4))[r] = buffer[r];
- }
+ for (int r = 0; r < 32 * 32; r++) {
+ ((u16 *) SCREEN_BASE_BLOCK_SUB(4))[r] = buffer[r];
}
- consolePrintSet(0, 23);
- consolePrintf("\n");
+ consoleSetWindow(NULL, 0, 0, 32, 24);
+// consolePrintSet(0, 23);
+// consolePrintf("Hello world!\n\n");
+// consolePrintf("\n");
// Show keyboard
SUB_BG1_CR = BG_TILE_BASE(1) | BG_MAP_BASE(12);
@@ -860,15 +888,20 @@ void displayMode16Bit() {
displayModeIs8Bit = false;
+ // ConsoleInit destroys the hardware palette :-(
+ OSystem_DS::instance()->restoreHardwarePalette();
+
BG3_XDX = isCpuScalerEnabled() ? 256 : (int) (1.25f * 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);
#ifdef HEAVY_LOGGING
consolePrintf("done\n");
#endif
+ BG_PALETTE_SUB[255] = RGB15(31,31,31);//by default font will be rendered with color 255
+
}
@@ -1470,6 +1503,7 @@ void addEventsToQueue() {
if ((!getIndyFightState()) && (getKeysDown() & KEY_Y)) {
consoleEnable = !consoleEnable;
+ consolePrintf("Console enable: %d\n", consoleEnable);
if (displayModeIs8Bit) {
displayMode8Bit();
} else {
@@ -1536,10 +1570,28 @@ void addEventsToQueue() {
}
- if ((getKeysDown() & KEY_SELECT)) {
- //scaledMode = !scaledMode;
- //scY = 4;
- showOptionsDialog();
+
+ static int selectHoldCount = 0;
+ static const int SELECT_HOLD_TIME = 60;
+
+ if ((getKeysHeld() & KEY_SELECT)) {
+ selectHoldCount++;
+
+ if (selectHoldCount == SELECT_HOLD_TIME) {
+ // Hold select down for one second - show GMM
+ g_engine->openMainMenuDialog();
+ }
+ } else {
+ selectHoldCount = 0;
+ }
+
+
+
+ if (getKeysReleased() & KEY_SELECT) {
+ if (selectHoldCount < SELECT_HOLD_TIME) {
+ // Just pressed select - show DS options screen
+ showOptionsDialog();
+ }
}
@@ -1654,6 +1706,7 @@ void addEventsToQueue() {
if ((getKeysChanged() & KEY_START)) {
+ event.kbd.flags = 0;
event.type = getKeyEvent(KEY_START);
if (currentGame->control == CONT_FUTURE_WARS) {
event.kbd.keycode = Common::KEYCODE_F10;
@@ -1670,7 +1723,6 @@ void addEventsToQueue() {
event.kbd.ascii = Common::ASCII_F5;
// consolePrintf("!!!!!F5!!!!!");
}
- event.kbd.flags = 0;
system->addEvent(event);
}
@@ -1780,6 +1832,13 @@ void soundBufferEmptyHandler() {
// bufferFirstHalf = true;
}
+// TIMER0
+ if ((callback) && (callbackTimer > 0)) {
+ callbackTimer--;
+ }
+ currentTimeMillis++;
+// TIMER0 end
+
soundHiPart = !soundHiPart;
}
@@ -1879,16 +1938,22 @@ void VBlankHandler(void) {
// }
//consolePrintf("X:%d Y:%d\n", getPenX(), getPenY());
-
- static bool firstTime = true;
+/*
+ if ((callback) && (callbackTimer > 0)) {
+ callbackTimer--;
+ }
+ currentTimeMillis++;
+*/
+/* static int firstTime = 1;
// This is to ensure that the ARM7 vblank handler runs before this one.
// Fixes the problem with the MMD when the screens swap over on load.
- if (firstTime) {
- firstTime = false;
+ if (firstTime > 0) {
+ REG_IF = IRQ_VBLANK;
+ firstTime--;
return;
}
-
+*/
IPC->tweak = tweak;
soundUpdate();
@@ -2165,7 +2230,7 @@ void VBlankHandler(void) {
updateOAM();
//PALETTE[0] = RGB15(0, 0, 0);
- REG_IF = IRQ_VBLANK;
+ //REG_IF = IRQ_VBLANK;
}
int getMillis() {
@@ -2181,13 +2246,17 @@ void setTimerCallback(OSystem_DS::TimerProc proc, int interval) {
}
void timerTickHandler() {
- REG_IF = IRQ_TIMER0;
+// REG_IF = IRQ_TIMER0;
if ((callback) && (callbackTimer > 0)) {
callbackTimer--;
}
currentTimeMillis++;
}
+
+
+
+
void setTalkPos(int x, int y) {
// if (gameID != Scumm::GID_SAMNMAX) {
// setTopScreenTarget(x, 0);
@@ -2238,7 +2307,7 @@ void initHardware() {
penInit();
- powerON(POWER_ALL);
+ powerOn(POWER_ALL);
/* vramSetBankA(VRAM_A_MAIN_BG);
vramSetBankB(VRAM_B_MAIN_BG);
vramSetBankC(VRAM_C_SUB_BG); */
@@ -2257,17 +2326,17 @@ void initHardware() {
for (int r = 0; r < 255; r++) {
- PALETTE[r] = 0;
+ BG_PALETTE[r] = 0;
}
- PALETTE[255] = RGB15(0,31,0);
+ BG_PALETTE[255] = RGB15(0,31,0);
for (int r = 0; r < 255; r++) {
- PALETTE_SUB[r] = 0;
+ BG_PALETTE_SUB[r] = 0;
}
- PALETTE_SUB[255] = RGB15(0,31,0);
+ BG_PALETTE_SUB[255] = RGB15(0,31,0);
// Allocate save buffer for game screen
// savedBuffer = new u8[320 * 200];
@@ -2295,7 +2364,7 @@ void initHardware() {
//BG0_CR = BG_MAP_BASE(0) | BG_TILE_BASE(1);
// BG0_Y0 = 48;
- PALETTE[255] = RGB15(31,31,31);//by default font will be rendered with color 255
+ BG_PALETTE[255] = RGB15(31,31,31);//by default font will be rendered with color 255
//consoleInit() is a lot more flexible but this gets you up and running quick
// consoleInitDefault((u16*)SCREEN_BASE_BLOCK(0), (u16*)CHAR_BASE_BLOCK(1), 16);
@@ -2303,14 +2372,14 @@ void initHardware() {
//irqs are nice
irqInit();
-// irqInitHandler();
+ irqInitHandler(OurIntrMain);
irqSet(IRQ_VBLANK, VBlankHandler);
irqSet(IRQ_TIMER0, timerTickHandler);
irqSet(IRQ_TIMER2, soundBufferEmptyHandler);
irqEnable(IRQ_VBLANK);
irqEnable(IRQ_TIMER0);
- irqEnable(IRQ_TIMER2);
+// irqEnable(IRQ_TIMER2);
#ifdef USE_PROFILER
irqSet(IRQ_HBLANK, hBlankHandler);
@@ -2330,7 +2399,7 @@ void initHardware() {
consolePrintf("done\n");
#endif
- PALETTE[255] = RGB15(0,0,31);
+ BG_PALETTE[255] = RGB15(0,0,31);
initSprites();
@@ -2682,17 +2751,15 @@ gameListType* getCurrentGame() {
///////////////////
#define FAST_RAM_SIZE (24000)
-
u8* fastRamPointer;
u8 fastRamData[FAST_RAM_SIZE] ITCM_DATA;
void* fastRamAlloc(int size) {
-// return malloc(size);
void* result = (void *) fastRamPointer;
fastRamPointer += size;
if(fastRamPointer > fastRamData + FAST_RAM_SIZE) {
consolePrintf("FastRam (ITCM) allocation failed!\n");
- return NULL;
+ return malloc(size);
}
return result;
}
@@ -2839,7 +2906,7 @@ void powerOff() {
void dsExceptionHandler() {
consolePrintf("Blue screen of death");
setExceptionHandler(NULL);
-
+ while(1);
u32 currentMode = getCPSR() & 0x1f;
u32 thumbState = ((*(u32*)0x027FFD90) & 0x20);
@@ -2875,10 +2942,10 @@ void dsExceptionHandler() {
registerNames[i], exceptionRegisters[i],
registerNames[i+8],exceptionRegisters[i+8]);
}
-// u32 *stack = (u32 *)exceptionRegisters[13];
-// for ( i=0; i<10; i++ ) {
-// consolePrintf( "\x1b[%d;2H%08X: %08X %08X", i + 14, (u32)&stack[i*2],stack[i*2], stack[(i*2)+1] );
-// }
+ u32 *stack = (u32 *)exceptionRegisters[13];
+ for ( i=0; i<10; i++ ) {
+ consolePrintf("%08X %08X %08X\n", stack[i*3], stack[i*3+1], stack[(i*3)+2] );
+ }
memoryReport();
@@ -2978,7 +3045,7 @@ int main(void) {
consolePrintf("-------------------------------\n");
consolePrintf("ScummVM DS\n");
consolePrintf("Ported by Neil Millstone\n");
- consolePrintf("Version 0.13.0 SVN ");
+ consolePrintf("Version 0.13.1 beta1 ");
#if defined(DS_BUILD_A)
consolePrintf("build A\n");
consolePrintf("Lucasarts SCUMM games (SCUMM)\n");
diff --git a/backends/platform/ds/arm9/source/dsmain.h b/backends/platform/ds/arm9/source/dsmain.h
index 7efd4a9365..49501a1fdf 100644
--- a/backends/platform/ds/arm9/source/dsmain.h
+++ b/backends/platform/ds/arm9/source/dsmain.h
@@ -25,7 +25,6 @@
#include <nds.h>
#include "osystem_ds.h"
-#include "scummconsole.h"
#include "NDS/scummvm_ipc.h"
namespace DS {
diff --git a/backends/platform/ds/arm9/source/dsoptions.cpp b/backends/platform/ds/arm9/source/dsoptions.cpp
index 38d28bcb53..52027f3a15 100644
--- a/backends/platform/ds/arm9/source/dsoptions.cpp
+++ b/backends/platform/ds/arm9/source/dsoptions.cpp
@@ -52,7 +52,9 @@ static int confGetInt(Common::String key, int defaultVal) {
DSOptionsDialog::DSOptionsDialog() : GUI::Dialog(0, 0, 320 - 10, 230 - 40) {
new GUI::ButtonWidget(this, 10, 170, 72, 16, "Close", GUI::kCloseCmd, 'C');
- _tab = new GUI::TabWidget(this, 5, 5, 300, 230 - 20 - 40 - 10);
+ new GUI::ButtonWidget(this, 320 - 10 - 130, 170, 120, 16, "ScummVM Main Menu", 0x40000000, 'M');
+
+ _tab = new GUI::TabWidget(this, 10, 5, 300, 230 - 20 - 40 - 20);
_tab->addTab("Controls");
@@ -264,8 +266,8 @@ void DSOptionsDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint
}
- if ((!guard) && (_radioButtonMode))
- {
+
+ if ((!guard) && (_radioButtonMode)) {
guard = true;
if ((sender == _touchPadStyle) && (cmd == 0x20000001)) {
@@ -332,30 +334,17 @@ void DSOptionsDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint
updateConfigManager();
close();
}
-}
-
-void togglePause() {
- // Toggle pause mode by simulating pressing 'p'. Not a good way of doing things!
- // FIXME: What is this code meant to do ?!?
- if (getCurrentGame()->control == CONT_SCUMM_ORIGINAL) {
- Common::Event event;
- OSystem_DS* system = OSystem_DS::instance();
-
- event.type = Common::EVENT_KEYDOWN;
- event.kbd.keycode = Common::KEYCODE_p;
- event.kbd.ascii = 'p';
- event.kbd.flags = 0;
- system->addEvent(event);
-
- event.type = Common::EVENT_KEYUP;
- system->addEvent(event);
+
+ if ((!guard) && (cmd == 0x40000000)) {
+ close();
+ g_engine->openMainMenuDialog();
}
}
+
void showOptionsDialog() {
- togglePause();
DS::displayMode16Bit();
@@ -366,7 +355,6 @@ void showOptionsDialog() {
DS::displayMode8Bit();
- togglePause();
}
void setOptions() {
diff --git a/backends/platform/ds/arm9/source/dsoptions.h b/backends/platform/ds/arm9/source/dsoptions.h
index 229b27ebbb..d29dd9d8ac 100644
--- a/backends/platform/ds/arm9/source/dsoptions.h
+++ b/backends/platform/ds/arm9/source/dsoptions.h
@@ -44,7 +44,6 @@ public:
protected:
virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data);
- void togglePause();
void updateConfigManager();
GUI::TabWidget* _tab;
diff --git a/backends/platform/ds/arm9/source/fat/disc_io.c b/backends/platform/ds/arm9/source/fat/disc_io.c
index 9a65812f89..5896cbb750 100644
--- a/backends/platform/ds/arm9/source/fat/disc_io.c
+++ b/backends/platform/ds/arm9/source/fat/disc_io.c
@@ -33,7 +33,6 @@
#endif
#include "disc_io.h"
-#include "scummconsole.h"
// Include known io-interfaces:
diff --git a/backends/platform/ds/arm9/source/interrupt.s b/backends/platform/ds/arm9/source/interrupt.s
new file mode 100644
index 0000000000..e04a5c686b
--- /dev/null
+++ b/backends/platform/ds/arm9/source/interrupt.s
@@ -0,0 +1,154 @@
+/*---------------------------------------------------------------------------------
+ $Id: interruptDispatcher.s,v 1.10 2007/08/11 06:00:23 wntrmute Exp $
+
+ Copyright (C) 2005
+ Dave Murphy (WinterMute)
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any
+ damages arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any
+ purpose, including commercial applications, and to alter it and
+ redistribute it freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you
+ must not claim that you wrote the original software. If you use
+ this software in a product, an acknowledgment in the product
+ documentation would be appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and
+ must not be misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source
+ distribution.
+
+ $Log: interruptDispatcher.s,v $
+ Revision 1.10 2007/08/11 06:00:23 wntrmute
+ make nesting really work
+
+ Revision 1.9 2007/01/10 15:48:27 wntrmute
+ remove unused code
+
+ Revision 1.8 2006/12/16 09:10:02 wntrmute
+ acknowledge interrupt before calling handler
+
+ Revision 1.7 2006/04/26 05:11:31 wntrmute
+ rebase dtcm, take __irq_flags and __irq_vector from linker script
+ move arm7 irq vector & irq flags to actual locations
+
+ Revision 1.6 2006/04/23 18:19:15 wntrmute
+ reworked interrupt code to allow dtcm moving
+
+ Revision 1.5 2005/12/12 13:01:55 wntrmute
+ disable interrupts on return from user handler
+
+ Revision 1.4 2005/10/21 22:43:42 wntrmute
+ restore REG_IME on exit from null handler
+
+ Revision 1.3 2005/09/27 18:21:53 wntrmute
+ safer nested interrupt support
+
+ Revision 1.2 2005/09/04 16:37:01 wntrmute
+ check for NULL handler
+
+ Revision 1.1 2005/09/03 17:09:35 wntrmute
+ added interworking aware interrupt dispatcher
+
+
+---------------------------------------------------------------------------------*/
+
+#ifdef ARM7
+ .text
+#endif
+
+#ifdef ARM9
+ .section .itcm,"ax",%progbits
+#endif
+
+ .extern irqTable
+ .code 32
+
+ .global OurIntrMain
+@---------------------------------------------------------------------------------
+OurIntrMain:
+@---------------------------------------------------------------------------------
+ mov r3, #0x4000000 @ REG_BASE
+
+ ldr r1, [r3, #0x208] @ r1 = IME
+ str r3, [r3, #0x208] @ disable IME
+ mrs r0, spsr
+ stmfd sp!, {r0-r1,r3,lr} @ {spsr, IME, REG_BASE, lr_irq}
+
+ ldr r1, [r3,#0x210] @ REG_IE
+ ldr r2, [r3,#0x214] @ REG_IF
+ and r1,r1,r2
+
+ ldr r0,=__irq_flags @ defined by linker script
+
+ ldr r2,[r0]
+ orr r2,r2,r1
+ str r2,[r0]
+
+ ldr r2,=irqTable
+@---------------------------------------------------------------------------------
+findIRQ:
+@---------------------------------------------------------------------------------
+ ldr r0, [r2, #4]
+ cmp r0,#0
+ beq no_handler
+ ands r0, r0, r1
+ bne jump_intr
+ add r2, r2, #8
+ b findIRQ
+
+@---------------------------------------------------------------------------------
+no_handler:
+@---------------------------------------------------------------------------------
+ str r1, [r3, #0x0214] @ IF Clear
+ ldmfd sp!, {r0-r1,r3,lr} @ {spsr, IME, REG_BASE, lr_irq}
+ str r1, [r3, #0x208] @ restore REG_IME
+ mov pc,lr
+
+@---------------------------------------------------------------------------------
+jump_intr:
+@---------------------------------------------------------------------------------
+ ldr r1, [r2] @ user IRQ handler address
+ cmp r1, #0
+ bne got_handler
+ mov r1, r0
+ b no_handler
+@---------------------------------------------------------------------------------
+got_handler:
+@---------------------------------------------------------------------------------
+
+ mrs r2, cpsr
+ bic r2, r2, #0xdf @ \__
+ orr r2, r2, #0x1f @ / --> Enable IRQ & FIQ. Set CPU mode to System.
+ msr cpsr,r2
+
+ str r0, [r3, #0x0214] @ IF Clear
+
+ sub r13,r13,#256
+ push {lr}
+ adr lr, IntrRet
+ bx r1
+
+@---------------------------------------------------------------------------------
+IntrRet:
+@---------------------------------------------------------------------------------
+ mov r3, #0x4000000 @ REG_BASE
+ str r3, [r3, #0x208] @ disable IME
+ pop {lr}
+ add r13,r13,#256
+
+ mrs r3, cpsr
+ bic r3, r3, #0xdf @ \__
+ orr r3, r3, #0x92 @ / --> Disable IRQ. Enable FIQ. Set CPU mode to IRQ.
+ msr cpsr, r3
+
+ ldmfd sp!, {r0-r1,r3,lr} @ {spsr, IME, REG_BASE, lr_irq}
+ msr spsr, r0 @ restore spsr
+ str r1, [r3, #0x208] @ restore REG_IME
+ mov pc,lr
+
+ .pool
+ .end
diff --git a/backends/platform/ds/arm9/source/osystem_ds.cpp b/backends/platform/ds/arm9/source/osystem_ds.cpp
index 992124dd73..057e107bb6 100644
--- a/backends/platform/ds/arm9/source/osystem_ds.cpp
+++ b/backends/platform/ds/arm9/source/osystem_ds.cpp
@@ -156,7 +156,7 @@ void OSystem_DS::setPalette(const byte *colors, uint start, uint num) {
green >>= 3;
blue >>= 3;
-// if (r != 255)
+ //if (r != 255)
{
u16 paletteValue = red | (green << 5) | (blue << 10);
@@ -175,6 +175,19 @@ void OSystem_DS::setPalette(const byte *colors, uint start, uint num) {
}
}
+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];
+
+ if (!DS::getKeyboardEnable()) {
+ BG_PALETTE_SUB[r] = _palette[r];
+ }
+ }
+}
+
void OSystem_DS::setCursorPalette(const byte *colors, uint start, uint num) {
// consolePrintf("Cursor palette set: start: %d, cols: %d\n", start, num);
@@ -213,13 +226,14 @@ bool OSystem_DS::grabRawScreen(Graphics::Surface* surf) {
return true;
}
-void OSystem_DS::grabPalette(unsigned char *colors, uint start, uint num) {
+void OSystem_DS::grabPalette(unsigned char *colours, uint start, uint num) {
// consolePrintf("Grabpalette");
for (unsigned int r = start; r < start + num; r++) {
- *colors++ = (BG_PALETTE[r] & 0x001F) << 3;
- *colors++ = (BG_PALETTE[r] & 0x03E0) >> 5 << 3;
- *colors++ = (BG_PALETTE[r] & 0x7C00) >> 10 << 3;
+ *colours++ = (BG_PALETTE[r] & 0x001F) << 3;
+ *colours++ = (BG_PALETTE[r] & 0x03E0) >> 5 << 3;
+ *colours++ = (BG_PALETTE[r] & 0x7C00) >> 10 << 3;
+ colours++;
}
}
@@ -248,12 +262,21 @@ void OSystem_DS::copyRectToScreen(const byte *buf, int pitch, int x, int y, int
stride = DS::get8BitBackBufferStride();
}
+
if (((pitch & 1) != 0) || ((w & 1) != 0) || (((int) (buf) & 1) != 0)) {
// Something is misaligned, so we have to use the slow but sure method
int by = 0;
+ 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;
+ }
+
for (int dy = y; dy < y + h; dy++) {
u8* dest = ((u8 *) (bg)) + (dy * stride) + x;
u8* destSub = ((u8 *) (bgSub)) + (dy * 512) + x;
@@ -395,8 +418,19 @@ void OSystem_DS::clearOverlay() {
// consolePrintf("clearovl\n");
}
-void OSystem_DS::grabOverlay(OverlayColor *buf, int pitch) {
-// consolePrintf("grabovl\n");
+void OSystem_DS::grabOverlay(OverlayColor* buf, int pitch) {
+// consolePrintf("grabovl\n")
+ u16* start = DS::get16BitBackBuffer();
+
+ for (int y = 0; y < 200; y++) {
+ u16* src = start + (y * 320);
+ u16* dest = ((u16 *) (buf)) + (y * pitch);
+
+ for (int x = 0; x < 320; x++) {
+ *dest++ = *src++;
+ }
+ }
+
}
void OSystem_DS::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) {
diff --git a/backends/platform/ds/arm9/source/osystem_ds.h b/backends/platform/ds/arm9/source/osystem_ds.h
index b5802803d0..5a26a25c8b 100644
--- a/backends/platform/ds/arm9/source/osystem_ds.h
+++ b/backends/platform/ds/arm9/source/osystem_ds.h
@@ -93,6 +93,7 @@ public:
virtual int16 getWidth();
virtual void setPalette(const byte *colors, uint start, uint num);
virtual void grabPalette(unsigned char* colors, uint start, uint num);
+ void restoreHardwarePalette();
virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h);
virtual void updateScreen();
diff --git a/backends/platform/ds/arm9/source/portdefs.h b/backends/platform/ds/arm9/source/portdefs.h
index 58d4df9020..7f22709206 100644
--- a/backends/platform/ds/arm9/source/portdefs.h
+++ b/backends/platform/ds/arm9/source/portdefs.h
@@ -38,6 +38,7 @@ typedef signed int s32;
#include "nds/jtypes.h"
+
// Somebody removed these from scummsys.h, but they're still required, so I'm adding them here
// in the hope that they'll stay.
#include <stdio.h>
@@ -51,6 +52,8 @@ typedef signed int s32;
#define CT_NO_TRANSPARENCY
+#define DISABLE_TEXT_CONSOLE
+#define DISABLE_COMMAND_LINE
#ifdef __cplusplus
extern "C" {
@@ -64,6 +67,8 @@ int consolePrintf(const char* s, ...);
//#define assert(expr) consolePrintf("Asserted!")
#define NO_DEBUG_MSGS
+#define consolePrintf iprintf
+
#ifdef assert
#undef assert
#endif
diff --git a/backends/platform/ds/arm9/source/scummconsole.c b/backends/platform/ds/arm9/source/scummconsole.c
deleted file mode 100644
index aafa0f7744..0000000000
--- a/backends/platform/ds/arm9/source/scummconsole.c
+++ /dev/null
@@ -1,568 +0,0 @@
-//////////////////////////////////////////////////////////////////////
-//
-// console.cpp -- provides basic print functionality
-//
-// version 0.1, February 14, 2005
-//
-// Copyright (C) 2005 Michael Noland (joat) and Jason Rogers (dovoto)
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any
-// damages arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any
-// purpose, including commercial applications, and to alter it and
-// redistribute it freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you
-// must not claim that you wrote the original software. If you use
-// this software in a product, an acknowledgment in the product
-// documentation would be appreciated but is not required.
-// 2. Altered source versions must be plainly marked as such, and
-// must not be misrepresented as being the original software.
-// 3. This notice may not be removed or altered from any source
-// distribution.
-//
-// Changelog:
-// 0.1: First version
-// 0.2: Fixed sprite mapping bug. 1D mapping should work now.
-// Changed some register defines for consistency.
-//
-//////////////////////////////////////////////////////////////////////
-
-
-#include <nds.h>
-#include "scummconsole.h"
-
-#include <stdarg.h>
-
-#include <default_font_bin.h>
-
-/////////////////////////////////////////
-//global console variables
-
-#define CONSOLE_WIDTH 32
-#define CONSOLE_HEIGHT 24
-#define TAB_SIZE 3
-
-//map to print to
-u16* fontMap;
-
-//location of cursor
-u8 row, col;
-
-//font may not start on a character base boundry
-u16 fontOffset;
-
-//the first character in the set (0 if you have a full set)
-u16 fontStart;
-
-//the 16-color palette to use
-u16 fontPal;
-
-
-
-
-///////////////////////////////////////////////////////////
-//consoleInit
-// param:
-// font: 16 color font
-// charBase: the location the font data will be loaded to
-// numCharacters: count of characters in the font
-// charStart: The ascii number of the first character in the font set
-// if you have a full set this will be zero
-// map: pointer to the map you will be printing to.
-// pal: specifies the 16 color palette to use, if > 15 it will change all non-zero
-// entries in the font to use palette index 255
-void consoleInit(u16* font, u16* charBase, u16 numCharacters, u8 charStart, u16* map, u8 pal, u8 bitDepth)
-{
- int i;
-
- row = col = 0;
-
- fontStart = charStart;
-
- fontOffset = 0;
-
- fontMap = map;
-
- if(bitDepth == 16)
- {
- if(pal < 16)
- {
- fontPal = pal << 12;
-
- for (i = 0; i < numCharacters * 16; i++)
- charBase[i] = font[i];
- }
- else
- {
- fontPal = 15 << 12;
-
- for (i = 0; i < numCharacters * 16; i++)
- {
- u16 temp = 0;
-
- if(font[i] & 0xF)
- temp |= 0xF;
- if(font[i] & 0xF0)
- temp |= 0xF0;
- if(font[i] & 0xF00)
- temp |= 0xF00;
- if(font[i] & 0xF000)
- temp |= 0xF000;
-
- charBase[i] = temp;
- }
- }
- }//end if bitdepth
- else
- {
- fontPal = 0;
- for(i = 0; i < numCharacters * 16; i++)
- {
- u32 temp = 0;
-
- if(font[i] & 0xF)
- temp = 255;
- if(font[i] & 0xF0)
- temp |= 255 << 8;
- if(font[i] & 0xF00)
- temp |= 255 << 16;
- if(font[i] & 0xF000)
- temp |= 255 << 24;
-
- ((u32*)charBase)[i] = temp;
-
- }
- }
-}
-
-void consoleInitDefault(u16* map, u16* charBase, u8 bitDepth)
-{
- consoleInit((u16 *) default_font_bin, charBase, 128, 0, map, CONSOLE_USE_COLOR255, bitDepth);
-}
-
-void consolePrintSet(int x, int y)
-{
- if(y < CONSOLE_HEIGHT)
- row = y;
- else
- row = CONSOLE_HEIGHT - 1;
-
- if(x < CONSOLE_WIDTH)
- col = x;
- else
- col = CONSOLE_WIDTH - 1;
-}
-
-void consolePrintChar(char c)
-{
- int i;
-
- if(col >= CONSOLE_WIDTH)
- {
- col = 0;
-
- row++;
- }
-
- if(row >= CONSOLE_HEIGHT)
- {
- row--;
-
- for(i = CONSOLE_WIDTH; i < CONSOLE_HEIGHT * CONSOLE_WIDTH; i++)
- fontMap[i - CONSOLE_WIDTH] = fontMap[i];
- for(i = 0; i < CONSOLE_WIDTH; i++)
- fontMap[i + (CONSOLE_HEIGHT-1)*CONSOLE_WIDTH] = fontPal | (u16)(' ' + fontOffset - fontStart);
-
-
- }
-
- switch(c)
- {
-
- case 10:
- case 11:
- case 12:
- case 13:
- row++;
- col = 0;
- break;
- case 9:
- col += TAB_SIZE;
- break;
- default:
- fontMap[col + row * CONSOLE_WIDTH] = fontPal | (u16)(c + fontOffset - fontStart);
- col++;
- break;
-
- }
-
-
-}
-
-
-void printX(int w, unsigned d)
-{
- int loop = 0;
- int i = 0;
-
- char buf[20] = {0};
-
-
- while(d > 0)
- {
- buf[loop++] = d & 0xF;
- d = d>>4;
- }
-
- for (i = 7; i >= 0; i--)
- {
- if(buf[i] || i < loop)
- {
- if(buf[i] < 10)
- consolePrintChar(buf[i] + '0');
- else
- consolePrintChar(buf[i] + 'A' - 10);
- }
- else if(i < w)
- consolePrintChar(' ');
- }
-}
-
-void printx(int w, unsigned int d)
-{
- int loop = 0;
- int i = 0;
-
- char buf[20] = {0};
-
- while(d > 0)
- {
- buf[loop++] = d & 0xF;
- d = d>>4;
- }
-
- for (i = 7; i >= 0; i--)
- {
- if(buf[i] || i < loop)
- {
- if(buf[i] < 10)
- consolePrintChar(buf[i] + '0');
- else
- consolePrintChar(buf[i] + 'a' - 10);
- }
- else if(i < w)
- consolePrintChar(' ');
- }
-}
-
-void printInt(int w, int d)
-{
- int loop = 0;
- int i = 0;
-
- char buf[20] = {0};
-
- if(d < 0)
- {
- consolePrintChar('-');
- d *= -1;
- }
-
- if (d == 0)
- buf[loop++] = 0;
- else while (d > 0)
- {
- buf[loop++] = d % 10;
- d /= 10;
- }
-
- for (i = 7; i >= 0; i--)
- {
- if(buf[i] || i < loop)
- consolePrintChar(buf[i] + '0');
- else if(i < w)
- consolePrintChar(' ');
- }
-}
-
-void printBin(int w, int d)
-{
- int i;
- int first = 0;
- for (i = 31; i >= 0; i--)
- {
- if(d & BIT(i))
- {
- first = 1;
- consolePrintChar('1');
- }
- else if (first || i == 0)
- consolePrintChar('0');
- else if (i < w)
- consolePrintChar(' ');
- }
-}
-
-void print0X(int w, unsigned d)
-{
- int loop = 0;
- int i = 0;
-
- char buf[] = {0,0,0,0,0,0,0,0}; //set to zero cause I may add formatted output someday
-
-
- while(d > 0)
- {
- buf[loop++] = d & 0xF;
- d = d>>4;
- }
-
- for (i = 7; i >= 0; i--)
- {
- if(buf[i] || i < w || i < loop)
- {
- if(buf[i] < 10)
- consolePrintChar(buf[i] + '0');
- else
- consolePrintChar(buf[i] + 'A' - 10);
- }
- }
-}
-
-void print0x(int w, unsigned int d)
-{
- int loop = 0;
- int i = 0;
-
- char buf[] = {0,0,0,0,0,0,0,0}; //set to zero cause I may add formatted output someday
-
-
- while(d > 0)
- {
- buf[loop++] = d & 0xF;
- d = d>>4;
- }
-
- for (i = 7; i >= 0; i--)
- {
- if(buf[i] || i < w || i < loop)
- {
- if(buf[i] < 10)
- consolePrintChar(buf[i] + '0');
- else
- consolePrintChar(buf[i] + 'a' - 10);
- }
- }
-}
-
-void print0Int(int w, int d)
-{
- int loop = 0;
- int i = 0;
-
- char buf[] = {0,0,0,0,0,0,0,0,0,0,0,0,0}; //set to zero cause I may add formatted output someday
-
- if(d < 0)
- {
- consolePrintChar('-');
- d *= -1;
- }
-
- while(d > 0)
- {
- buf[loop++] = d % 10;
- d /= 10;
- }
-
- for (i = 15; i >= 0; i--)
- if(buf[i] || i < w || i < loop)
- consolePrintChar(buf[i] + '0');
-
-}
-
-void print0Bin(int w, int d)
-{
- int i;
- int first = 0;
- for (i = 31; i >= 0; i--)
- {
- if(d & BIT(i))
- {
- first = 1;
- consolePrintChar('1');
- }
- else if (first || i == 0)
- consolePrintChar('0');
- else if (i < w)
- consolePrintChar('0');
- }
-}
-
-void print(const char* s)
-{
- for(; *s; s++) consolePrintChar(*s);
-}
-
-void printF(int w, float f)
-{
- unsigned int* t = (unsigned int*)&f;
- unsigned int fraction = (*t) & 0x007FFFFF;
- int exp = ((*t) >> 23) & 0xFF;
-
- if(*t & BIT(31))
- consolePrintChar('-');
-
-
- print0Bin(32, fraction);
-
- printInt(1, fraction);
- consolePrintChar('e');
- printInt(1, exp - 127);
-
- /*
- if(exp == 0 && fraction == 0)
- {
- printInt(1,0);
- }
- else if(exp == 0xFF && fraction == 0)
- {
- print("Inifinite");
- }
- else
- {
- printInt(w,fraction);
- consolePrintChar('e');
- printInt(1,exp - 127);
- }
- */
-}
-
-int consolePrintf(const char* s, ...)
-{
- int w = 1, z = 0;
-
- va_list argp;
-
- va_start(argp, s);
-
-
- while(*s)
- {
- w = 1;
- z = 0;
-
- switch(*s)
- {
- case '%':
- s++;
- if(*s == '0')
- {
- z = 1;
- s++;
- }
- if(*s > '0' && *s <= '9')
- {
- w = *s - '0';
- s++;
- }
- switch (*s)
- {
- case 'i':
- case 'I':
- case 'd':
- case 'D':
- if(z)print0Int(w, va_arg(argp, int));
- else printInt(w, va_arg(argp, int));
- s++;
- break;
- case 'X':
- if(z)print0X(w, va_arg(argp, int));
- else printX(w, va_arg(argp, int));
- s++;
- break;
-
- case 'x':
- if(z)print0x(w, va_arg(argp, int));
- else printx(w, va_arg(argp, int));
- s++;
- break;
-
- case 'b':
- case 'B':
- if(z)print0Bin(w, va_arg(argp, int));
- else printBin(w, va_arg(argp, int));
- s++;
- break;
- case 'f':
- case 'F':
-/* Need to undo our 'all doubles are floats' definition */
-#define TEMP_DEF double
-#undef double
- printF(w,va_arg(argp, double));
-#define double TEMP_DEF
-#undef TEMP_DEF
- s++;
- break;
- case 's':
- case 'S':
- print(va_arg(argp, char*));
- s++;
- break;
- default:
- consolePrintChar('%');
- break;
- }
- default:
- consolePrintChar(*s);
- break;
- }
-
- s++;
- }
- va_end(argp);
-
- return 0;
-}
-
-void consolePutString(int x, int y, char* s)
-{
- consolePrintSet(x, y);
- consolePrintf(s);
-}
-
-void consolePutInt(int x, int y, int d)
-{
- consolePrintSet(x,y);
- printInt(1,d);
-}
-
-void consolePutX(int x, int y, int d)
-{
- consolePrintSet(x, y);
- printX(1,d);
-}
-
-void consolePutChar(int x, int y, char c)
-{
- consolePrintSet(x, y);
- consolePrintChar(c);
-}
-
-void consolePutBin(int x, int y, int b)
-{
- consolePrintSet(x, y);
- printBin(1,b);
-}
-void consoleClear(void)
-{
- int i = 0;
- consolePrintSet(0,0);
-
- while(i++ < CONSOLE_HEIGHT * CONSOLE_WIDTH)
- consolePrintChar(' ');
-
- consolePrintSet(0,0);
-}
diff --git a/backends/platform/ds/arm9/source/scummconsole.h b/backends/platform/ds/arm9/source/scummconsole.h
deleted file mode 100644
index f7aa30f125..0000000000
--- a/backends/platform/ds/arm9/source/scummconsole.h
+++ /dev/null
@@ -1,67 +0,0 @@
-//////////////////////////////////////////////////////////////////////
-//
-// consol.h --provides basic consol type print functionality
-//
-// version 0.1, February 14, 2005
-//
-// Copyright (C) 2005 Michael Noland (joat) and Jason Rogers (dovoto)
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any
-// damages arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any
-// purpose, including commercial applications, and to alter it and
-// redistribute it freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you
-// must not claim that you wrote the original software. If you use
-// this software in a product, an acknowledgment in the product
-// documentation would be appreciated but is not required.
-// 2. Altered source versions must be plainly marked as such, and
-// must not be misrepresented as being the original software.
-// 3. This notice may not be removed or altered from any source
-// distribution.
-//
-// Changelog:
-// 0.1: First version
-// 0.2: Fixed sprite mapping bug. 1D mapping should work now.
-// Changed some register defines for consistency.
-//
-//////////////////////////////////////////////////////////////////////
-#ifndef CONSOLE_H2
-#define CONSOLE_H2
-
-#define CONSOLE_USE_COLOR255 16
-
-#include "portdefs.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void poo(u8 p);
-
-void consoleInit(u16* font, u16* charBase, u16 numCharacters, u8 charStart, u16* map, u8 pal, u8 bitDepth);
-void consoleInitDefault(u16* map, u16* charBase, u8 bitDepth);
-
-int consolePrintf(const char* s, ...);
-
-void consolePrintSet(int x, int y);
-
-void consolePrintChar(char c);
-
-void consolePutString(int x, int y, char* s);
-void consolePutInt(int x, int y, int d);
-void consolePutX(int x, int y, int d);
-void consolePutChar(int x, int y, char c);
-void consolePutBin(int x, int y, int b);
-
-void consoleClear(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
diff --git a/backends/platform/ds/arm9/source/scummhelp.cpp b/backends/platform/ds/arm9/source/scummhelp.cpp
index f9efd58276..e1ddaecc2c 100644
--- a/backends/platform/ds/arm9/source/scummhelp.cpp
+++ b/backends/platform/ds/arm9/source/scummhelp.cpp
@@ -48,8 +48,8 @@ void updateStrings(byte gameId, byte version, Common::Platform platform,
ADD_BIND("A", "Switch screens");
ADD_BIND("Y", "Show/hide debug console");
ADD_BIND("X", "Show/hide keyboard");
- ADD_BIND("L + Pad/Pen", "Scroll current touch screen view");
- ADD_BIND("L + B/A", "Zoom in/out");
+ ADD_BIND("L+Pad/Pen", "Scroll current touch screen view");
+ ADD_BIND("L+B/A", "Zoom in/out");
break;
}
@@ -65,13 +65,13 @@ void updateStrings(byte gameId, byte version, Common::Platform platform,
ADD_BIND("Pad Up", "Show/hide keyboard");
ADD_BIND("Pad Left", "Show/hide debug console");
ADD_BIND("Pad Right", "Swap screens");
- ADD_BIND("R + Pad/Pen", "Scroll current touch screen view");
- ADD_BIND("R+down/right", "Zoom in/out");
+ ADD_BIND("R+Pad/Pen", "Scroll current touch screen view");
+ ADD_BIND("R+dwn/rgt", "Zoom in/out");
break;
}
case 3: {
- title = "Indiana Jones Fighting controls:";
+ title = "Indiana Jones Fight controls:";
ADD_BIND("Pad Left", "Move left");
ADD_BIND("Pad Right", "Move right");
ADD_BIND("Pad Up", "High guard");
@@ -80,9 +80,6 @@ void updateStrings(byte gameId, byte version, Common::Platform platform,
ADD_BIND("X", "Punch high");
ADD_BIND("A", "Punch middle");
ADD_BIND("B", "Punch low");
-
- ADD_BIND("L+R", "Hold during bootup to clear SRAM");
- ADD_BIND("", "(flash cart only)");
break;
}
}
diff --git a/backends/platform/ds/commoninclude/NDS/scummvm_ipc.h b/backends/platform/ds/commoninclude/NDS/scummvm_ipc.h
index 6a20f775c6..743d158d34 100644
--- a/backends/platform/ds/commoninclude/NDS/scummvm_ipc.h
+++ b/backends/platform/ds/commoninclude/NDS/scummvm_ipc.h
@@ -33,6 +33,18 @@
//////////////////////////////////////////////////////////////////////
+
+
+//---------------------------------------------------------------------------------
+typedef struct sTransferSound {
+//---------------------------------------------------------------------------------
+ TransferSoundData data[16];
+ u8 count;
+ u8 PADDING[3];
+} TransferSound, * pTransferSound;
+
+
+
typedef struct _adpcmBuffer {
u8* buffer[8];
bool filled[8];