mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-02-21 12:01:53 +00:00
Start adding stuff for Wii.
This commit is contained in:
parent
325a9fb48e
commit
534163a57f
@ -52,6 +52,7 @@
|
||||
#define AUDIO_COREAUDIO 17
|
||||
#define AUDIO_PS3 18
|
||||
#define AUDIO_XENON360 20
|
||||
#define AUDIO_WII 22
|
||||
////////////////////////
|
||||
#define INPUT_SDL 7
|
||||
#define INPUT_X 12
|
||||
@ -75,6 +76,8 @@
|
||||
#define AUDIO_DEFAULT_DRIVER AUDIO_PS3
|
||||
#elif defined(XENON)
|
||||
#define AUDIO_DEFAULT_DRIVER AUDIO_XENON360
|
||||
#elif defined(GEKKO)
|
||||
#define AUDIO_DEFAULT_DRIVER AUDIO_WII
|
||||
#elif defined(HAVE_ALSA)
|
||||
#define AUDIO_DEFAULT_DRIVER AUDIO_ALSA
|
||||
#elif defined(HAVE_PULSE)
|
||||
|
9
driver.c
9
driver.c
@ -29,9 +29,6 @@
|
||||
#endif
|
||||
|
||||
static const audio_driver_t *audio_drivers[] = {
|
||||
#ifdef __CELLOS_LV2__
|
||||
&audio_ps3,
|
||||
#endif
|
||||
#ifdef HAVE_ALSA
|
||||
&audio_alsa,
|
||||
#endif
|
||||
@ -68,9 +65,15 @@ static const audio_driver_t *audio_drivers[] = {
|
||||
#ifdef HAVE_DYLIB
|
||||
&audio_ext,
|
||||
#endif
|
||||
#ifdef __CELLOS_LV2__
|
||||
&audio_ps3,
|
||||
#endif
|
||||
#ifdef XENON
|
||||
&audio_xenon360,
|
||||
#endif
|
||||
#ifdef GEKKO
|
||||
&audio_wii,
|
||||
#endif
|
||||
};
|
||||
|
||||
static const video_driver_t *video_drivers[] = {
|
||||
|
1
driver.h
1
driver.h
@ -169,6 +169,7 @@ extern const audio_driver_t audio_dsound;
|
||||
extern const audio_driver_t audio_coreaudio;
|
||||
extern const audio_driver_t audio_xenon360;
|
||||
extern const audio_driver_t audio_ps3;
|
||||
extern const audio_driver_t audio_wii;
|
||||
extern const video_driver_t video_gl;
|
||||
extern const video_driver_t video_xvideo;
|
||||
extern const video_driver_t video_sdl;
|
||||
|
@ -407,6 +407,8 @@ static inline void ssnes_sleep(unsigned msec)
|
||||
Sleep(msec);
|
||||
#elif defined(XENON)
|
||||
udelay(1000 * msec);
|
||||
#elif defined(GEKKO)
|
||||
usleep(1000 * msec);
|
||||
#else
|
||||
struct timespec tv = {
|
||||
.tv_sec = msec / 1000,
|
||||
|
11
settings.c
11
settings.c
@ -62,9 +62,6 @@ static void set_defaults(void)
|
||||
|
||||
switch (AUDIO_DEFAULT_DRIVER)
|
||||
{
|
||||
case AUDIO_PS3:
|
||||
def_audio = "ps3";
|
||||
break;
|
||||
case AUDIO_RSOUND:
|
||||
def_audio = "rsound";
|
||||
break;
|
||||
@ -101,6 +98,12 @@ static void set_defaults(void)
|
||||
case AUDIO_XENON360:
|
||||
def_audio = "xenon360";
|
||||
break;
|
||||
case AUDIO_PS3:
|
||||
def_audio = "ps3";
|
||||
break;
|
||||
case AUDIO_WII:
|
||||
def_audio = "wii";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -118,7 +121,7 @@ static void set_defaults(void)
|
||||
break;
|
||||
case INPUT_XENON360:
|
||||
def_input = "xenon360";
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
147
wii/audio.c
Normal file
147
wii/audio.c
Normal file
@ -0,0 +1,147 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
* SSNES is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* SSNES is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with SSNES.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../driver.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include "../general.h"
|
||||
|
||||
#include <gccore.h>
|
||||
#include <ogcsys.h>
|
||||
|
||||
#define CHUNK_FRAMES 256
|
||||
#define CHUNK_SIZE (CHUNK_FRAMES * sizeof(uint32_t))
|
||||
#define BLOCKS 4
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t data[BLOCKS][CHUNK_FRAMES];
|
||||
|
||||
volatile unsigned dma_busy;
|
||||
volatile unsigned dma_next;
|
||||
volatile unsigned dma_write;
|
||||
size_t write_ptr;
|
||||
|
||||
lwpq_t cond;
|
||||
bool nonblock;
|
||||
} wii_audio_t;
|
||||
|
||||
static wii_audio_t *g_audio;
|
||||
|
||||
static void dma_callback(void)
|
||||
{
|
||||
g_audio->dma_busy = g_audio->dma_next;
|
||||
g_audio->dma_next = (g_audio->dma_next + 1) & (BLOCKS - 1);
|
||||
|
||||
DCFlushRange(g_audio->data[g_audio->dma_next], CHUNK_SIZE);
|
||||
AUDIO_InitDMA((u32)g_audio->data[g_audio->dma_next], CHUNK_SIZE);
|
||||
|
||||
LWP_ThreadSignal(g_audio->cond);
|
||||
}
|
||||
|
||||
static void *wii_audio_init(const char *device, unsigned rate, unsigned latency)
|
||||
{
|
||||
static bool inited = false;
|
||||
if (!inited)
|
||||
{
|
||||
AUDIO_Init(NULL);
|
||||
AUDIO_SetDSPSampleRate(AI_SAMPLERATE_48KHZ);
|
||||
g_settings.audio.out_rate = 48000;
|
||||
AUDIO_RegisterDMACallback(dma_callback);
|
||||
inited = true;
|
||||
}
|
||||
|
||||
g_audio = memalign(32, sizeof(*g_audio));
|
||||
memset(g_audio, 0, sizeof(*g_audio));
|
||||
LWP_InitQueue(&g_audio->cond);
|
||||
|
||||
g_audio->dma_write = BLOCKS - 1;
|
||||
DCFlushRange(g_audio->data, sizeof(g_audio->data));
|
||||
AUDIO_InitDMA((u32)g_audio->data[g_audio->dma_next], CHUNK_SIZE);
|
||||
AUDIO_StartDMA();
|
||||
|
||||
return g_audio;
|
||||
}
|
||||
|
||||
static ssize_t wii_audio_write(void *data, const void *buf_, size_t size)
|
||||
{
|
||||
wii_audio_t *wa = data;
|
||||
|
||||
size_t frames = size >> 2;
|
||||
const uint32_t *buf = buf_;
|
||||
while (frames)
|
||||
{
|
||||
size_t to_write = CHUNK_FRAMES - wa->write_ptr;
|
||||
if (frames < to_write)
|
||||
to_write = frames;
|
||||
|
||||
while ((wa->write_ptr == wa->dma_next || wa->write_ptr == wa->dma_busy) && wa->nonblock)
|
||||
LWP_ThreadSleep(wa->cond);
|
||||
|
||||
memcpy(wa->data[wa->dma_write] + wa->write_ptr, buf, to_write * sizeof(uint32_t));
|
||||
wa->write_ptr += to_write;
|
||||
frames -= to_write;
|
||||
buf += to_write;
|
||||
|
||||
if (wa->write_ptr >= CHUNK_FRAMES)
|
||||
{
|
||||
wa->write_ptr -= CHUNK_FRAMES;
|
||||
wa->dma_write = (wa->dma_write + 1) & (BLOCKS - 1);
|
||||
}
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
static bool wii_audio_stop(void *data)
|
||||
{
|
||||
(void)data;
|
||||
AUDIO_StopDMA();
|
||||
return true;
|
||||
}
|
||||
|
||||
static void wii_audio_set_nonblock_state(void *data, bool state)
|
||||
{
|
||||
wii_audio_t *wa = data;
|
||||
wa->nonblock = state;
|
||||
}
|
||||
|
||||
static bool wii_audio_start(void *data)
|
||||
{
|
||||
(void)data;
|
||||
AUDIO_StartDMA();
|
||||
return true;
|
||||
}
|
||||
|
||||
static void wii_audio_free(void *data)
|
||||
{
|
||||
AUDIO_StopDMA();
|
||||
if (data)
|
||||
free(data);
|
||||
g_audio = NULL;
|
||||
}
|
||||
|
||||
const audio_driver_t audio_wii = {
|
||||
.init = wii_audio_init,
|
||||
.write = wii_audio_write,
|
||||
.stop = wii_audio_stop,
|
||||
.start = wii_audio_start,
|
||||
.set_nonblock_state = wii_audio_set_nonblock_state,
|
||||
.free = wii_audio_free,
|
||||
.ident = "wii"
|
||||
};
|
||||
|
32
wii/main.c
Normal file
32
wii/main.c
Normal file
@ -0,0 +1,32 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
* SSNES is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* SSNES is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with SSNES.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#undef main
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
int ssnes_main(int argc, char **argv);
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char arg0[] = "ssnes";
|
||||
char arg1[] = "/path/to/game";
|
||||
|
||||
char *argv[] = { arg0, arg1, NULL };
|
||||
return ssnes_main(sizeof(argv) / sizeof(argv[0]) - 1, argv);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user