aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorAndre Heider2010-08-28 12:51:12 +0000
committerAndre Heider2010-08-28 12:51:12 +0000
commit80b9e8371b3cb8ef07df3495f8569271f8088211 (patch)
tree194d26afb0dd18aae730892e9e7c7567069a45e2 /backends
parentc45b3e4e0e66ae56d06dcf1215477cf77eecc375 (diff)
downloadscummvm-rg350-80b9e8371b3cb8ef07df3495f8569271f8088211.tar.gz
scummvm-rg350-80b9e8371b3cb8ef07df3495f8569271f8088211.tar.bz2
scummvm-rg350-80b9e8371b3cb8ef07df3495f8569271f8088211.zip
WII: svn merge Wii port commits from trunk
svn-id: r52425
Diffstat (limited to 'backends')
-rw-r--r--backends/fs/wii/wii-fs-factory.cpp22
-rw-r--r--backends/platform/wii/main.cpp12
-rw-r--r--backends/platform/wii/options.cpp6
-rw-r--r--backends/platform/wii/osystem.h2
-rw-r--r--backends/platform/wii/osystem_gfx.cpp3
-rw-r--r--backends/platform/wii/osystem_sfx.cpp52
6 files changed, 42 insertions, 55 deletions
diff --git a/backends/fs/wii/wii-fs-factory.cpp b/backends/fs/wii/wii-fs-factory.cpp
index 5bc8ba56f5..2e8051029d 100644
--- a/backends/fs/wii/wii-fs-factory.cpp
+++ b/backends/fs/wii/wii-fs-factory.cpp
@@ -29,6 +29,7 @@
#ifdef USE_WII_DI
#include <di/di.h>
+#include <iso9660.h>
#endif
#ifdef USE_WII_SMB
@@ -71,8 +72,10 @@ void WiiFilesystemFactory::asyncInit() {
void WiiFilesystemFactory::asyncDeinit() {
#ifdef USE_WII_DI
umount(kDVD);
+#ifndef GAMECUBE
DI_Close();
#endif
+#endif
#ifdef USE_WII_SMB
umount(kSMB);
net_deinit();
@@ -125,24 +128,11 @@ void WiiFilesystemFactory::mount(FileSystemType type) {
break;
printf("mount dvd\n");
- DI_Mount();
-
- while (DI_GetStatus() & DVD_INIT)
- usleep(20 * 1000);
-
- if (!(DI_GetStatus() & DVD_READY)) {
- DI_StopMotor();
- printf("error mounting dvd\n");
- break;
- }
-
- printf("mount ISO9660\n");
if (ISO9660_Mount()) {
_dvdMounted = true;
_dvdError = false;
printf("ISO9660 mounted\n");
} else {
- DI_StopMotor();
_dvdError = true;
printf("ISO9660 mount failed\n");
}
@@ -185,7 +175,6 @@ void WiiFilesystemFactory::umount(FileSystemType type) {
printf("umount dvd\n");
ISO9660_Unmount();
- DI_StopMotor();
_dvdMounted = false;
_dvdError = false;
@@ -199,10 +188,7 @@ void WiiFilesystemFactory::umount(FileSystemType type) {
printf("umount smb\n");
- if (smbClose("smb:"))
- printf("smb umounted\n");
- else
- printf("error umounting smb\n");
+ smbClose("smb:");
_smbMounted = false;
_smbError = false;
diff --git a/backends/platform/wii/main.cpp b/backends/platform/wii/main.cpp
index 627cc7d1db..7f141f2339 100644
--- a/backends/platform/wii/main.cpp
+++ b/backends/platform/wii/main.cpp
@@ -37,8 +37,7 @@
#ifdef DEBUG_WII_GDB
#include <debug.h>
#endif
-#include <gfx/gfx.h>
-#include <gfx/gfx_con.h>
+#include <gxflux/gfx_con.h>
#ifdef __cplusplus
extern "C" {
@@ -51,7 +50,6 @@ void reset_cb(void) {
#ifdef DEBUG_WII_GDB
printf("attach gdb now\n");
_break();
- SYS_SetResetCallback(reset_cb);
#else
reset_btn_pressed = true;
#endif
@@ -78,6 +76,11 @@ static void show_console(int code) {
for (i = 0; i < 60 * 3; ++i)
VIDEO_WaitVSync();
+#ifdef DEBUG_WII_GDB
+ printf("attach gdb now\n");
+ _break();
+#endif
+
printf("Press any key to continue.\n");
if (!gfx_frame_start())
@@ -157,12 +160,13 @@ void wii_memstats(void) {
int main(int argc, char *argv[]) {
s32 res;
-#ifdef USE_WII_DI
+#if defined(USE_WII_DI) && !defined(GAMECUBE)
DI_Init();
#endif
VIDEO_Init();
PAD_Init();
+ DSP_Init();
AUDIO_Init(NULL);
gfx_video_init(NULL);
diff --git a/backends/platform/wii/options.cpp b/backends/platform/wii/options.cpp
index 295856d564..0a21b45561 100644
--- a/backends/platform/wii/options.cpp
+++ b/backends/platform/wii/options.cpp
@@ -22,7 +22,7 @@
#include <errno.h>
#include <network.h>
-#include <gfx/gfx.h>
+#include <gxflux/gfx.h>
#include "common/config-manager.h"
#include "gui/dialog.h"
@@ -133,11 +133,9 @@ WiiOptionsDialog::~WiiOptionsDialog() {
}
void WiiOptionsDialog::handleTickle() {
-#ifndef GAMECUBE
WiiFilesystemFactory &fsf = WiiFilesystemFactory::instance();
int tab = _tab->getActiveTab();
-#endif
#ifdef USE_WII_DI
if (tab == _tabDVD) {
@@ -198,9 +196,7 @@ void WiiOptionsDialog::handleTickle() {
void WiiOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd,
uint32 data) {
-#ifndef GAMECUBE
WiiFilesystemFactory &fsf = WiiFilesystemFactory::instance();
-#endif
switch (cmd) {
case 'x':
diff --git a/backends/platform/wii/osystem.h b/backends/platform/wii/osystem.h
index 8180d5727f..eaaf616538 100644
--- a/backends/platform/wii/osystem.h
+++ b/backends/platform/wii/osystem.h
@@ -26,7 +26,7 @@
#include <gccore.h>
#include <ogcsys.h>
-#include <gfx/gfx.h>
+#include <gxflux/gfx.h>
#include "base/main.h"
#include "common/fs.h"
diff --git a/backends/platform/wii/osystem_gfx.cpp b/backends/platform/wii/osystem_gfx.cpp
index 19190048a0..3ce6343800 100644
--- a/backends/platform/wii/osystem_gfx.cpp
+++ b/backends/platform/wii/osystem_gfx.cpp
@@ -21,8 +21,7 @@
#include <malloc.h>
-#include <gfx/gfx.h>
-#include <gfx/gfx_con.h>
+#include <gxflux/gfx_con.h>
#include "common/config-manager.h"
#include "graphics/conversion.h"
diff --git a/backends/platform/wii/osystem_sfx.cpp b/backends/platform/wii/osystem_sfx.cpp
index d2e884aa22..33397f0a93 100644
--- a/backends/platform/wii/osystem_sfx.cpp
+++ b/backends/platform/wii/osystem_sfx.cpp
@@ -25,7 +25,8 @@
#define SFX_THREAD_STACKSIZE (1024 * 128)
#define SFX_THREAD_PRIO 80
-#define SFX_THREAD_FRAG_SIZE 4096
+#define SFX_THREAD_FRAG_SIZE (1024 * 8)
+#define SFX_BUFFERS 3
static lwpq_t sfx_queue;
static lwp_t sfx_thread;
@@ -33,20 +34,18 @@ static u8 *sfx_stack;
static bool sfx_thread_running = false;
static bool sfx_thread_quit = false;
-static u8 sb = 0;
-static u8 *sound_buffer[2];
+static u32 sb_hw;
+static u8 *sound_buffer[SFX_BUFFERS];
static void audio_switch_buffers() {
- AUDIO_StopDMA();
- AUDIO_InitDMA((u32) sound_buffer[sb], SFX_THREAD_FRAG_SIZE);
- AUDIO_StartDMA();
-
+ sb_hw = (sb_hw + 1) % SFX_BUFFERS;
+ AUDIO_InitDMA((u32) sound_buffer[sb_hw], SFX_THREAD_FRAG_SIZE);
LWP_ThreadSignal(sfx_queue);
}
static void * sfx_thread_func(void *arg) {
Audio::MixerImpl *mixer = (Audio::MixerImpl *) arg;
- u8 next_sb;
+ u8 sb_sw;
while (true) {
LWP_ThreadSleep(sfx_queue);
@@ -54,11 +53,15 @@ static void * sfx_thread_func(void *arg) {
if (sfx_thread_quit)
break;
- next_sb = sb ^ 1;
- mixer->mixCallback(sound_buffer[next_sb], SFX_THREAD_FRAG_SIZE);
- DCFlushRange(sound_buffer[next_sb], SFX_THREAD_FRAG_SIZE);
-
- sb = next_sb;
+ // the hardware uses two buffers: a front and a back buffer
+ // we use 3 buffers here: two are beeing pushed to the DSP,
+ // and the free one is where our mixer writes to
+ // thus the latency of our stream is:
+ // 8192 [frag size] / 48000 / 2 [16bit] / 2 [stereo] * 2 [hw buffers]
+ // -> 85.3ms
+ sb_sw = (sb_hw + 1) % SFX_BUFFERS;
+ mixer->mixCallback(sound_buffer[sb_sw], SFX_THREAD_FRAG_SIZE);
+ DCFlushRange(sound_buffer[sb_sw], SFX_THREAD_FRAG_SIZE);
}
return NULL;
@@ -89,21 +92,20 @@ void OSystem_Wii::initSfx() {
sfx_thread_running = true;
}
- sound_buffer[0] = (u8 *) memalign(32, SFX_THREAD_FRAG_SIZE);
- sound_buffer[1] = (u8 *) memalign(32, SFX_THREAD_FRAG_SIZE);
-
- memset(sound_buffer[0], 0, SFX_THREAD_FRAG_SIZE);
- memset(sound_buffer[1], 0, SFX_THREAD_FRAG_SIZE);
-
- DCFlushRange(sound_buffer[0], SFX_THREAD_FRAG_SIZE);
- DCFlushRange(sound_buffer[1], SFX_THREAD_FRAG_SIZE);
+ for (u32 i = 0; i < SFX_BUFFERS; ++i) {
+ sound_buffer[i] = (u8 *) memalign(32, SFX_THREAD_FRAG_SIZE);
+ memset(sound_buffer[i], 0, SFX_THREAD_FRAG_SIZE);
+ DCFlushRange(sound_buffer[i], SFX_THREAD_FRAG_SIZE);
+ }
_mixer->setReady(true);
+ sb_hw = 0;
+
AUDIO_SetDSPSampleRate(AI_SAMPLERATE_48KHZ);
AUDIO_RegisterDMACallback(audio_switch_buffers);
-
- audio_switch_buffers();
+ AUDIO_InitDMA((u32) sound_buffer[sb_hw], SFX_THREAD_FRAG_SIZE);
+ AUDIO_StartDMA();
}
void OSystem_Wii::deinitSfx() {
@@ -123,8 +125,8 @@ void OSystem_Wii::deinitSfx() {
free(sfx_stack);
sfx_thread_running = false;
- free(sound_buffer[0]);
- free(sound_buffer[1]);
+ for (u32 i = 0; i < SFX_BUFFERS; ++i)
+ free(sound_buffer[i]);
}
}