aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/ds
diff options
context:
space:
mode:
Diffstat (limited to 'backends/platform/ds')
-rw-r--r--backends/platform/ds/arm9/source/dsmain.cpp13
-rw-r--r--backends/platform/ds/arm9/source/dsmain.h1
-rw-r--r--backends/platform/ds/arm9/source/osystem_ds.cpp26
-rw-r--r--backends/platform/ds/arm9/source/osystem_ds.h12
-rw-r--r--backends/platform/ds/arm9/source/wordcompletion.cpp2
5 files changed, 24 insertions, 30 deletions
diff --git a/backends/platform/ds/arm9/source/dsmain.cpp b/backends/platform/ds/arm9/source/dsmain.cpp
index a130509e36..f4706807f7 100644
--- a/backends/platform/ds/arm9/source/dsmain.cpp
+++ b/backends/platform/ds/arm9/source/dsmain.cpp
@@ -168,7 +168,7 @@ bool displayModeIs8Bit = false;
u8 gameID;
bool snapToBorder = false;
-bool consoleEnable = false;
+bool consoleEnable = true;
bool gameScreenSwap = false;
bool isCpuScalerEnabled();
//#define HEAVY_LOGGING
@@ -899,12 +899,6 @@ u16* get8BitBackBuffer() {
return BG_GFX + 0x10000; // 16bit qty!
}
-void setSoundProc(OSystem_DS::SoundProc proc, void* param) {
-// consolePrintf("Set sound callback");
- soundCallback = proc;
- soundParam = param;
-}
-
// The sound system in ScummVM seems to always return stereo interleaved samples.
// Here, I'm treating an 11Khz stereo stream as a 22Khz mono stream, which works sorta ok, but is
// a horrible bodge. Any advice on how to change the engine to output mono would be greatly
@@ -914,7 +908,8 @@ void doSoundCallback() {
consolePrintf("doSoundCallback...");
#endif
- if (soundCallback) {
+ if (OSystem_DS::instance())
+ if (OSystem_DS::instance()->getMixerImpl()) {
lastCallbackFrame = frameCount;
for (int r = IPC->playingSection; r < IPC->playingSection + 4; r++) {
@@ -923,7 +918,7 @@ void doSoundCallback() {
if (IPC->fillNeeded[chunk]) {
IPC->fillNeeded[chunk] = false;
DC_FlushAll();
- soundCallback(soundParam, (byte *) (soundBuffer + ((bufferSamples >> 2) * chunk)), bufferSamples >> 1);
+ OSystem_DS::instance()->getMixerImpl()->mixCallback((byte *) (soundBuffer + ((bufferSamples >> 2) * chunk)), bufferSamples >> 1);
IPC->fillNeeded[chunk] = false;
DC_FlushAll();
}
diff --git a/backends/platform/ds/arm9/source/dsmain.h b/backends/platform/ds/arm9/source/dsmain.h
index f20442b11e..43258b5c5d 100644
--- a/backends/platform/ds/arm9/source/dsmain.h
+++ b/backends/platform/ds/arm9/source/dsmain.h
@@ -88,7 +88,6 @@ int getMillis(); // Return the current runtime in milliseconds
void doTimerCallback(); // Call callback function if required
// Sound
-void setSoundProc(OSystem_DS::SoundProc proc, void* param); // Setup a callback function for sound
void doSoundCallback(); // Call function if sound buffers need more data
void playSound(const void* data, u32 length, bool loop, bool adpcm = false, int rate = 22050); // Start a sound
void stopSound(int channel);
diff --git a/backends/platform/ds/arm9/source/osystem_ds.cpp b/backends/platform/ds/arm9/source/osystem_ds.cpp
index 6e6b457115..79b0c5390b 100644
--- a/backends/platform/ds/arm9/source/osystem_ds.cpp
+++ b/backends/platform/ds/arm9/source/osystem_ds.cpp
@@ -67,10 +67,12 @@ void OSystem_DS::initBackend() {
ConfMan.setInt("autosave_period", 0);
ConfMan.setBool("FM_medium_quality", true);
- _mixer = new DSAudioMixer;
- _timer = new DSTimerManager;
- DS::setSoundProc(Audio::Mixer::mixCallback, _mixer);
- DS::setTimerCallback(&OSystem_DS::timerHandler, 10);
+ _mixer = new DSAudioMixer(this);
+ _timer = new DSTimerManager();
+ DS::setTimerCallback(&OSystem_DS::timerHandler, 10);
+
+ _mixer->setOutputRate(11025 /*DS::getSoundFrequency()*/);
+ _mixer->setReady(true);
OSystem::initBackend();
}
@@ -139,7 +141,7 @@ void OSystem_DS::setPalette(const byte *colors, uint start, uint num) {
green >>= 3;
blue >>= 3;
-// if (r != 255)
+ if (r != 255)
{
BG_PALETTE[r] = red | (green << 5) | (blue << 10);
if (!DS::getKeyboardEnable()) {
@@ -158,13 +160,13 @@ bool OSystem_DS::grabRawScreen(Graphics::Surface* surf) {
// Ensure we copy using 16 bit quantities due to limitation of VRAM addressing
- u16* image = (u16 *) DS::get8BitBackBuffer();
+ const u16* image = (const u16 *) DS::get8BitBackBuffer();
for (int y = 0; y < DS::getGameHeight(); y++)
{
DC_FlushRange(image + (y << 8), DS::getGameWidth());
for (int x = 0; x < DS::getGameWidth() >> 1; x++)
{
- *(((u16 *) (surf->pixels)) + y * (DS::getGameWidth() >> 1) + x) = image[y << 8 + x];
+ *(((u16 *) (surf->pixels)) + y * (DS::getGameWidth() >> 1) + x) = image[(y << 8) + x];
}
}
@@ -277,7 +279,7 @@ void OSystem_DS::grabOverlay (OverlayColor *buf, int pitch) {
void OSystem_DS::copyRectToOverlay (const OverlayColor *buf, int pitch, int x, int y, int w, int h) {
u16* bg = (u16 *) DS::get16BitBackBuffer();
- u16* src = (u16 *) buf;
+ const u16* src = (const u16 *) buf;
// if (x + w > 256) w = 256 - x;
//if (x + h > 256) h = 256 - y;
@@ -433,13 +435,7 @@ void OSystem_DS::unlockMutex(MutexRef mutex) {
void OSystem_DS::deleteMutex(MutexRef mutex) {
}
-void OSystem_DS::clearSoundCallback() {
-// consolePrintf("Clearing sound callback");
-// DS::setSoundProc(NULL, NULL);
-}
-
-int OSystem_DS::getOutputSampleRate() const
-{
+int OSystem_DS::getOutputSampleRate() const {
return DS::getSoundFrequency();
}
diff --git a/backends/platform/ds/arm9/source/osystem_ds.h b/backends/platform/ds/arm9/source/osystem_ds.h
index 246797188f..8c8d661ad8 100644
--- a/backends/platform/ds/arm9/source/osystem_ds.h
+++ b/backends/platform/ds/arm9/source/osystem_ds.h
@@ -30,10 +30,13 @@
#include "gbampsave.h"
#include "backends/saves/default/default-saves.h"
#include "backends/timer/default/default-timer.h"
-#include "sound/mixer.h"
+#include "sound/mixer_intern.h"
#include "graphics/surface.h"
-class DSAudioMixer : public Audio::Mixer {
+class DSAudioMixer : public Audio::MixerImpl {
+
+public:
+ DSAudioMixer(OSystem* system) : Audio::MixerImpl(system) { }
};
class DSTimerManager : public DefaultTimerManager {
@@ -62,7 +65,7 @@ protected:
Graphics::Surface* createTempFrameBuffer();
public:
- typedef void (*SoundProc)(void *param, byte *buf, int len);
+ typedef void (*SoundProc)(byte *buf, int len);
typedef int (*TimerProc)(int interval);
OSystem_DS();
@@ -114,7 +117,6 @@ public:
virtual void unlockMutex(MutexRef mutex);
virtual void deleteMutex(MutexRef mutex);
- virtual void clearSoundCallback();
virtual int getOutputSampleRate() const;
virtual bool openCD(int drive);
@@ -147,6 +149,8 @@ public:
virtual void unlockScreen();
virtual Audio::Mixer* getMixer() { return _mixer; }
+ Audio::MixerImpl* getMixerImpl() { return _mixer; }
+
virtual Common::TimerManager* getTimerManager() { return _timer; }
static int timerHandler(int t);
diff --git a/backends/platform/ds/arm9/source/wordcompletion.cpp b/backends/platform/ds/arm9/source/wordcompletion.cpp
index 9eeeb62410..ff52572a40 100644
--- a/backends/platform/ds/arm9/source/wordcompletion.cpp
+++ b/backends/platform/ds/arm9/source/wordcompletion.cpp
@@ -1,6 +1,6 @@
#include "wordcompletion.h"
-#include "engines/agi/agi.h"
#include "osystem_ds.h"
+#include "engines/agi/agi.h" // Caution for #define for NUM_CHANNELS, causes problems in mixer_intern.h
#ifdef ENABLE_AGI