mirror of
https://github.com/libretro/RetroArch
synced 2025-03-02 19:13:34 +00:00
Improvement in:
* Makefile.ps2 * ps2_gfx * ps2_platform * ps2_audio
This commit is contained in:
parent
e2ca8aa1b5
commit
56207bd08e
16
Makefile.ps2
16
Makefile.ps2
@ -5,7 +5,6 @@ HAVE_LOGGER = 0
|
||||
HAVE_FILE_LOGGER = 0
|
||||
HAVE_THREADS = 0
|
||||
BIG_STACK = 0
|
||||
WHOLE_ARCHIVE_LINK = 0
|
||||
PS2_IP = 192.168.1.150
|
||||
|
||||
#Configuration for IRX
|
||||
@ -22,11 +21,6 @@ else
|
||||
OPTIMIZE_LV := -O2
|
||||
endif
|
||||
|
||||
ifeq ($(WHOLE_ARCHIVE_LINK), 1)
|
||||
WHOLE_START := -Wl,--whole-archive
|
||||
WHOLE_END := -Wl,--no-whole-archive
|
||||
endif
|
||||
|
||||
INCDIR = -I$(PS2DEV)/gsKit/include -I$(PS2SDK)/ports/include
|
||||
INCDIR += -Ips2 -Ips2/include -Ilibretro-common/include
|
||||
INCDIR += -Ideps -Ideps/stb -Ideps/libz -Ideps/7zip -Ideps/pthreads -Ideps/pthreads/platform/ps2 -Ideps/pthreads/platform/helper
|
||||
@ -39,12 +33,11 @@ RARCH_DEFINES += -DHAVE_GRIFFIN=1 -DRARCH_INTERNAL -DRARCH_CONSOLE -DHAVE_MENU -
|
||||
|
||||
LIBDIR =
|
||||
LDFLAGS = -L$(PS2SDK)/ports/lib -L$(PS2DEV)/gsKit/lib -L$(PS2SDK)/ee/lib -L. -s
|
||||
LIBS += $(WHOLE_START) -lretro_ps2 $(WHOLE_END)
|
||||
LIBS += -lgskit -ldmakit -laudsrv -lpad -lmc -lhdd -lsdl -lc -lfileXio -lpatches -lpoweroff -lc
|
||||
LIBS += -lretro_ps2 -lgskit -ldmakit -laudsrv -lpad -lmc -lhdd -lsdl -lfileXio -lpatches -lpoweroff
|
||||
|
||||
#IRX modules
|
||||
# IRX modules - modules have to be in IRX_DIR
|
||||
IRX = iomanX.irx fileXio.irx usbd.irx usbhdfsd.irx freesd.irx audsrv.irx poweroff.irx ps2dev9.irx ps2atad.irx ps2hdd.irx ps2fs.irx
|
||||
IRX = iomanX.irx fileXio.irx mcman.irx mcserv.irx usbd.irx usbhdfsd.irx freesd.irx audsrv.irx poweroff.irx ps2dev9.irx ps2atad.irx ps2hdd.irx ps2fs.irx
|
||||
IRX_OBJ = $(IRX:.irx=.o)
|
||||
EE_OBJS += $(IRX_OBJ)
|
||||
|
||||
@ -108,10 +101,7 @@ $(EE_IRX_OBJ):
|
||||
include $(PS2SDK)/samples/Makefile.pref
|
||||
include $(PS2SDK)/samples/Makefile.eeglobal
|
||||
|
||||
|
||||
#Linking with C++
|
||||
$(EE_BIN): $(EE_OBJS) $(PS2SDK)/ee/startup/crt0.o
|
||||
$(EE_CXX) $(EE_NO_CRT) -T$(PS2SDK)/ee/startup/linkfile $(EE_CXXFLAGS) \
|
||||
-o $(EE_BIN) $(PS2SDK)/ee/startup/crt0.o $(CRTI_OBJ) $(CRTBEGIN_OBJ) $(EE_OBJS) $(CRTEND_OBJ) $(CRTN_OBJ) $(EE_LDFLAGS) $(EE_LIBS)
|
||||
|
||||
|
||||
|
@ -18,54 +18,44 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <rthreads/rthreads.h>
|
||||
#include <queues/fifo_queue.h>
|
||||
|
||||
#include <kernel.h>
|
||||
#include <audsrv.h>
|
||||
|
||||
#include "../audio_driver.h"
|
||||
|
||||
typedef struct ps2_audio
|
||||
{
|
||||
bool nonblocking;
|
||||
|
||||
typedef struct ps2_audio {
|
||||
fifo_buffer_t* buffer;
|
||||
|
||||
bool nonblocking;
|
||||
volatile bool running;
|
||||
|
||||
int worker_thread;
|
||||
|
||||
int lock;
|
||||
int cond_lock;
|
||||
|
||||
} ps2_audio_t;
|
||||
|
||||
static ps2_audio_t *backup_ps2;
|
||||
static u8 audioThreadStack[512 * 16] __attribute__ ((aligned(16)));
|
||||
static u8 audioThreadStack[4 * 1024] __attribute__ ((aligned(16)));
|
||||
|
||||
#define AUDIO_OUT_BUFFER 2 * 1024
|
||||
#define AUDIO_BUFFER 64 * 1024
|
||||
#define AUDIO_CHANNELS 2
|
||||
#define AUDIO_BITS 16
|
||||
#define AUDIO_PRIORITY 0x7F /* LOWER VALUE GRATHER PRIORITY*/
|
||||
|
||||
|
||||
static void audioMainLoop(void *data)
|
||||
{
|
||||
static void audioMainLoop(void *data) {
|
||||
char out_tmp[AUDIO_OUT_BUFFER];
|
||||
ps2_audio_t* ps2 = backup_ps2;
|
||||
|
||||
char out_tmp[AUDIO_OUT_BUFFER];
|
||||
|
||||
while (ps2->running)
|
||||
{
|
||||
while (ps2->running) {
|
||||
WaitSema(ps2->lock);
|
||||
size_t size = MIN(fifo_read_avail(ps2->buffer), sizeof(out_tmp));
|
||||
fifo_read(ps2->buffer, out_tmp, size);
|
||||
|
||||
iSignalSema(ps2->lock);
|
||||
iSignalSema(ps2->cond_lock);
|
||||
|
||||
int ret;
|
||||
audsrv_wait_audio(size);
|
||||
ret = audsrv_play_audio(out_tmp, size);
|
||||
audsrv_play_audio(out_tmp, size);
|
||||
}
|
||||
|
||||
audsrv_stop_audio();
|
||||
@ -81,7 +71,7 @@ static void audioCreateThread(ps2_audio_t *ps2) {
|
||||
thread.stack=audioThreadStack;
|
||||
thread.stack_size=sizeof(audioThreadStack);
|
||||
thread.gp_reg=&_gp;
|
||||
thread.initial_priority=0x40;
|
||||
thread.initial_priority=AUDIO_PRIORITY;
|
||||
thread.attr=thread.option=0;
|
||||
|
||||
/*Backup the PS2 content to be used in the thread */
|
||||
@ -106,13 +96,12 @@ static void audioStopNDeleteThread(ps2_audio_t *ps2) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void audioConfigure(ps2_audio_t *ps2, unsigned rate) {
|
||||
int err;
|
||||
struct audsrv_fmt_t format;
|
||||
format.bits = 16;
|
||||
format.bits = AUDIO_BITS;
|
||||
format.freq = rate;
|
||||
format.channels = 2;
|
||||
format.channels = AUDIO_CHANNELS;
|
||||
|
||||
err = audsrv_set_format(&format);
|
||||
if (err) {
|
||||
@ -144,19 +133,17 @@ static void *ps2_audio_init(const char *device,
|
||||
{
|
||||
ps2_audio_t *ps2 = (ps2_audio_t*)calloc(1, sizeof(ps2_audio_t));
|
||||
|
||||
if (!ps2)
|
||||
return NULL;
|
||||
|
||||
ps2->buffer = fifo_new(AUDIO_BUFFER);
|
||||
audioConfigure(ps2, rate);
|
||||
audioCreateSemas(ps2);
|
||||
audioCreateThread(ps2);
|
||||
if (ps2) {
|
||||
ps2->buffer = fifo_new(AUDIO_BUFFER);
|
||||
audioConfigure(ps2, rate);
|
||||
audioCreateSemas(ps2);
|
||||
audioCreateThread(ps2);
|
||||
}
|
||||
|
||||
return ps2;
|
||||
}
|
||||
|
||||
static void ps2_audio_free(void *data)
|
||||
{
|
||||
static void ps2_audio_free(void *data) {
|
||||
ps2_audio_t* ps2 = (ps2_audio_t*)data;
|
||||
if(!ps2)
|
||||
return;
|
||||
@ -179,15 +166,13 @@ static void ps2_audio_free(void *data)
|
||||
free(ps2);
|
||||
}
|
||||
|
||||
static ssize_t ps2_audio_write(void *data, const void *buf, size_t size)
|
||||
{
|
||||
static ssize_t ps2_audio_write(void *data, const void *buf, size_t size) {
|
||||
ps2_audio_t* ps2 = (ps2_audio_t*)data;
|
||||
|
||||
if (!ps2->running)
|
||||
return -1;
|
||||
|
||||
if (ps2->nonblocking)
|
||||
{
|
||||
if (ps2->nonblocking) {
|
||||
if (fifo_write_avail(ps2->buffer) < size)
|
||||
return 0;
|
||||
}
|
||||
@ -203,8 +188,7 @@ static ssize_t ps2_audio_write(void *data, const void *buf, size_t size)
|
||||
return size;
|
||||
}
|
||||
|
||||
static bool ps2_audio_alive(void *data)
|
||||
{
|
||||
static bool ps2_audio_alive(void *data) {
|
||||
bool alive = false;
|
||||
|
||||
ps2_audio_t* ps2 = (ps2_audio_t*)data;
|
||||
@ -215,8 +199,7 @@ static bool ps2_audio_alive(void *data)
|
||||
return alive;
|
||||
}
|
||||
|
||||
static bool ps2_audio_stop(void *data)
|
||||
{
|
||||
static bool ps2_audio_stop(void *data) {
|
||||
bool stop = true;
|
||||
ps2_audio_t* ps2 = (ps2_audio_t*)data;
|
||||
|
||||
@ -228,8 +211,7 @@ static bool ps2_audio_stop(void *data)
|
||||
return stop;
|
||||
}
|
||||
|
||||
static bool ps2_audio_start(void *data, bool is_shutdown)
|
||||
{
|
||||
static bool ps2_audio_start(void *data, bool is_shutdown) {
|
||||
bool start = true;
|
||||
ps2_audio_t* ps2 = (ps2_audio_t*)data;
|
||||
|
||||
@ -242,38 +224,31 @@ static bool ps2_audio_start(void *data, bool is_shutdown)
|
||||
return start;
|
||||
}
|
||||
|
||||
static void ps2_audio_set_nonblock_state(void *data, bool toggle)
|
||||
{
|
||||
static void ps2_audio_set_nonblock_state(void *data, bool toggle) {
|
||||
ps2_audio_t* ps2 = (ps2_audio_t*)data;
|
||||
if (ps2) {
|
||||
ps2->nonblocking = toggle;
|
||||
}
|
||||
}
|
||||
|
||||
static bool ps2_audio_use_float(void *data)
|
||||
{
|
||||
(void)data;
|
||||
static bool ps2_audio_use_float(void *data) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static size_t psp_write_avail(void *data)
|
||||
{
|
||||
size_t val;
|
||||
static size_t ps2_audio_write_avail(void *data) {
|
||||
size_t size = 0;
|
||||
ps2_audio_t* ps2 = (ps2_audio_t*)data;
|
||||
|
||||
if (!ps2||!ps2->running)
|
||||
return 0;
|
||||
|
||||
WaitSema(ps2->lock);
|
||||
size_t size = AUDIO_BUFFER - fifo_read_avail(ps2->buffer);
|
||||
iSignalSema(ps2->lock);
|
||||
|
||||
if (ps2 && ps2->running) {
|
||||
WaitSema(ps2->lock);
|
||||
size_t size = AUDIO_BUFFER - fifo_read_avail(ps2->buffer);
|
||||
iSignalSema(ps2->lock);
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
static size_t psp_buffer_size(void *data)
|
||||
{
|
||||
static size_t ps2_audio_buffer_size(void *data) {
|
||||
return AUDIO_BUFFER ;
|
||||
}
|
||||
|
||||
@ -289,6 +264,6 @@ audio_driver_t audio_ps2 = {
|
||||
"ps2",
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
ps2_audio_write_avail,
|
||||
ps2_audio_buffer_size
|
||||
};
|
||||
|
@ -72,6 +72,12 @@ extern unsigned int usbd_irx_size;
|
||||
extern unsigned char usbhdfsd_irx_start[];
|
||||
extern unsigned int usbhdfsd_irx_size;
|
||||
|
||||
extern unsigned char mcman_irx_start[];
|
||||
extern unsigned int mcman_irx_size;
|
||||
|
||||
extern unsigned char mcserv_irx_start[];
|
||||
extern unsigned int mcserv_irx_size;
|
||||
|
||||
static unsigned char HDDModulesLoaded=0;
|
||||
|
||||
char eboot_path[512];
|
||||
@ -305,14 +311,17 @@ static void frontend_ps2_init(void *data)
|
||||
SifInitRpc(0);
|
||||
sbv_patch_enable_lmb();
|
||||
|
||||
// Controllers
|
||||
SifLoadModule("rom0:SIO2MAN", 0, NULL);
|
||||
SifLoadModule("rom0:PADMAN", 0, NULL);
|
||||
|
||||
// I/O Files
|
||||
SifExecModuleBuffer(iomanX_irx_start, iomanX_irx_size, 0, NULL, NULL);
|
||||
SifExecModuleBuffer(fileXio_irx_start, fileXio_irx_size, 0, NULL, NULL);
|
||||
|
||||
SifLoadModule("rom0:SIO2MAN", 0, NULL);
|
||||
SifLoadModule("rom0:MCMAN", 0, NULL);
|
||||
SifLoadModule("rom0:MCSERV", 0, NULL);
|
||||
SifLoadModule("rom0:PADMAN", 0, NULL);
|
||||
|
||||
// Memory Card
|
||||
SifExecModuleBuffer(mcman_irx_start, mcman_irx_size, 0, NULL, NULL);
|
||||
SifExecModuleBuffer(mcserv_irx_start, mcserv_irx_size, 0, NULL, NULL);
|
||||
|
||||
// USB
|
||||
SifExecModuleBuffer(usbd_irx_start, usbd_irx_size, 0, NULL, NULL);
|
||||
|
@ -25,6 +25,9 @@
|
||||
#define GS_TEXT GS_SETREG_RGBAQ(0x80,0x80,0x80,0x80,0x00) // turn white GS Screen
|
||||
#define GS_BLACK GS_SETREG_RGBAQ(0x00,0x00,0x00,0x00,0x00) // turn white GS Screen
|
||||
|
||||
#define NTSC_WIDTH 640
|
||||
#define NTSC_HEIGHT 448
|
||||
|
||||
typedef struct ps2_video
|
||||
{
|
||||
GSGLOBAL *gsGlobal;
|
||||
@ -47,8 +50,8 @@ static GSGLOBAL *init_GSGlobal(void) {
|
||||
gsGlobal->Mode = GS_MODE_NTSC;
|
||||
gsGlobal->Interlace = GS_INTERLACED;
|
||||
gsGlobal->Field = GS_FIELD;
|
||||
gsGlobal->Width = 640;
|
||||
gsGlobal->Height = 448;
|
||||
gsGlobal->Width = NTSC_WIDTH;
|
||||
gsGlobal->Height = NTSC_HEIGHT;
|
||||
|
||||
gsGlobal->PSM = GS_PSM_CT16;
|
||||
gsGlobal->PSMZ = GS_PSMZ_16;
|
||||
|
Loading…
x
Reference in New Issue
Block a user