From 5994f6b6df438a03a697d7c2a199d4ab3e52af50 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Mon, 16 Jul 2012 21:49:51 +0200 Subject: [PATCH] (PS3/PSL1GHT) Redefine SDK function macros - fix some PSL1GHT incompatibilities --- Makefile.psl1ght | 2 +- general.h | 2 +- gfx/gfx_common.c | 6 +- ps3/ps3_audio.c | 71 ++++++++++++----------- ps3/ps3_input.c | 32 +++++------ ps3/sdk_defines.h | 144 ++++++++++++---------------------------------- 6 files changed, 98 insertions(+), 159 deletions(-) diff --git a/Makefile.psl1ght b/Makefile.psl1ght index c5791f455b..360371a0ac 100644 --- a/Makefile.psl1ght +++ b/Makefile.psl1ght @@ -37,7 +37,7 @@ endif RSXGL_DEFINES = -D__RSX__ -DGL3_PROTOTYPES -CFLAGS += -std=gnu99 -DHAVE_FILEBROWSER -DHAVE_OPENGLES20 $(RSXGL_DEFINES) -DHAVE_OSKUTIL -DHAVE_MOUSE -DHAVE_DEFAULT_RETROPAD_INPUT -DRARCH_CONSOLE -DHAVE_CONFIGFILE=1 -DHAVE_ZLIB -DHAVE_RARCH_MAIN_WRAP -DHAVE_GRIFFIN=1 -DPACKAGE_VERSION=\"0.9.6\" -Dmain=rarch_main -Wno-char-subscripts +CFLAGS += -std=gnu99 -DHAVE_FILEBROWSER $(RSXGL_DEFINES) -DHAVE_OSKUTIL -DHAVE_MOUSE -DHAVE_DEFAULT_RETROPAD_INPUT -DRARCH_CONSOLE -DHAVE_CONFIGFILE=1 -DHAVE_ZLIB -DHAVE_RARCH_MAIN_WRAP -DHAVE_GRIFFIN=1 -DPACKAGE_VERSION=\"0.9.6\" -Dmain=rarch_main -Wno-char-subscripts ifeq ($(DEBUG), 1) CFLAGS += -O0 -g diff --git a/general.h b/general.h index 5f48377bac..f1c7ded0bd 100644 --- a/general.h +++ b/general.h @@ -254,7 +254,7 @@ struct console_settings char default_sram_dir[PATH_MAX]; char launch_app_on_exit[PATH_MAX]; float menu_font_size; -#if defined(__CELLOS_LV2__) +#if defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) oskutil_params oskutil_handle; #endif }; diff --git a/gfx/gfx_common.c b/gfx/gfx_common.c index 87b95c9ac1..f5475af8b7 100644 --- a/gfx/gfx_common.c +++ b/gfx/gfx_common.c @@ -26,10 +26,14 @@ #endif #ifdef __CELLOS_LV2__ +#ifdef __PSL1GHT__ +#include +#else #include #endif +#endif -#if defined(__CELLOS_LV2__) || defined(_MSC_VER) +#if defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) || defined(_MSC_VER) static int gettimeofday(struct timeval *val, void *dummy) { (void)dummy; diff --git a/ps3/ps3_audio.c b/ps3/ps3_audio.c index 450b4cc4eb..993906e0a4 100644 --- a/ps3/ps3_audio.c +++ b/ps3/ps3_audio.c @@ -73,28 +73,28 @@ static void event_loop(uint64_t data) sys_ipc_key_t key; sys_event_t event; - pAudioCreateNotifyEventQueue(&id, &key); - pAudioSetNotifyEventQueue(key); + cellAudioCreateNotifyEventQueue(&id, &key); + cellAudioSetNotifyEventQueue(key); float out_tmp[CELL_AUDIO_BLOCK_SAMPLES * AUDIO_CHANNELS] __attribute__((aligned(16))); while (!aud->quit_thread) { - pSysEventQueueReceive(id, &event, SYS_NO_TIMEOUT); + sys_event_queue_receive(id, &event, SYS_NO_TIMEOUT); - pLwMutexLock(&aud->lock, SYS_NO_TIMEOUT); + sys_lwmutex_lock(&aud->lock, SYS_NO_TIMEOUT); if (fifo_read_avail(aud->buffer) >= sizeof(out_tmp)) fifo_read(aud->buffer, out_tmp, sizeof(out_tmp)); else memset(out_tmp, 0, sizeof(out_tmp)); - pLwMutexUnlock(&aud->lock); - pLwCondSignal(&aud->cond); + sys_lwmutex_unlock(&aud->lock); + sys_lwcond_signal(&aud->cond); - pAudioAddData(aud->audio_port, out_tmp, CELL_AUDIO_BLOCK_SAMPLES, 1.0); + cellAudioAddData(aud->audio_port, out_tmp, CELL_AUDIO_BLOCK_SAMPLES, 1.0); } - pAudioRemoveNotifyEventQueue(key); - pThreadExit(0); + cellAudioRemoveNotifyEventQueue(key); + sys_ppu_thread_exit(0); } static void *ps3_audio_init(const char *device, unsigned rate, unsigned latency) @@ -108,8 +108,8 @@ static void *ps3_audio_init(const char *device, unsigned rate, unsigned latency) if (!data) return NULL; - pAudioPortParam params; - pAudioInit(); + CellAudioPortParam params; + cellAudioInit(); params.numChannels = AUDIO_CHANNELS; params.numBlocks = AUDIO_BLOCKS; #ifdef HAVE_HEADSET @@ -119,9 +119,9 @@ static void *ps3_audio_init(const char *device, unsigned rate, unsigned latency) #endif params.param_attrib = 0; - if (pAudioPortOpen(¶ms, &data->audio_port) != CELL_OK) + if (cellAudioPortOpen(¶ms, &data->audio_port) != CELL_OK) { - pAudioQuit(); + cellAudioQuit(); free(data); return NULL; } @@ -139,21 +139,24 @@ static void *ps3_audio_init(const char *device, unsigned rate, unsigned latency) #endif #ifndef __PSL1GHT__ - pLwMutexAttributeInitialize(lock_attr); - pLwMutexAttributeInitialize(cond_lock_attr); + sys_lwmutex_attribute_initialize(lock_attr); + sys_lwmutex_attribute_initialize(cond_lock_attr); sys_lwcond_attribute_initialize(cond_attr); #endif - pLwMutexCreate(&data->lock, &lock_attr); - pLwMutexCreate(&data->cond_lock, &cond_lock_attr); - pLwCondCreate(&data->cond, &data->cond_lock, &cond_attr); + sys_lwmutex_create(&data->lock, &lock_attr); + sys_lwmutex_create(&data->cond_lock, &cond_lock_attr); + sys_lwcond_create(&data->cond, &data->cond_lock, &cond_attr); - pAudioPortStart(data->audio_port); + cellAudioPortStart(data->audio_port); + sys_ppu_thread_create(&data->thread, event_loop, #ifdef __PSL1GHT__ - pThreadCreate(&data->thread, event_loop, data, 1500, 0x1000, SYS_PPU_THREAD_CREATE_JOINABLE, (char*)"sound"); + data, #else - pThreadCreate(&data->thread, event_loop, (uint64_t)data, 1500, 0x1000, SYS_PPU_THREAD_CREATE_JOINABLE, (char*)"sound"); + (uint64_t)data, #endif + 1500, 0x1000, SYS_PPU_THREAD_CREATE_JOINABLE, (char*)"sound"); + return data; } @@ -169,26 +172,26 @@ static ssize_t ps3_audio_write(void *data, const void *buf, size_t size) else { while (fifo_write_avail(aud->buffer) < size) - pLwCondWait(&aud->cond, 0); + sys_lwcond_wait(&aud->cond, 0); } - pLwMutexLock(&aud->lock, SYS_NO_TIMEOUT); + sys_lwmutex_lock(&aud->lock, SYS_NO_TIMEOUT); fifo_write(aud->buffer, buf, size); - pLwMutexUnlock(&aud->lock); + sys_lwmutex_unlock(&aud->lock); return size; } static bool ps3_audio_stop(void *data) { ps3_audio_t *aud = data; - pAudioPortStop(aud->audio_port); + cellAudioPortStop(aud->audio_port); return true; } static bool ps3_audio_start(void *data) { ps3_audio_t *aud = data; - pAudioPortStart(aud->audio_port); + cellAudioPortStart(aud->audio_port); return true; } @@ -204,17 +207,17 @@ static void ps3_audio_free(void *data) ps3_audio_t *aud = data; aud->quit_thread = true; - pAudioPortStart(aud->audio_port); - pThreadJoin(aud->thread, &val); + cellAudioPortStart(aud->audio_port); + sys_ppu_thread_join(aud->thread, &val); - pAudioPortStop(aud->audio_port); - pAudioPortClose(aud->audio_port); - pAudioQuit(); + cellAudioPortStop(aud->audio_port); + cellAudioPortClose(aud->audio_port); + cellAudioQuit(); fifo_free(aud->buffer); - pLwMutexDestroy(&aud->lock); - pLwMutexDestroy(&aud->cond_lock); - pLwCondDestroy(&aud->cond); + sys_lwmutex_destroy(&aud->lock); + sys_lwmutex_destroy(&aud->cond_lock); + sys_lwcond_destroy(&aud->cond); free(data); } diff --git a/ps3/ps3_input.c b/ps3/ps3_input.c index b45755d667..24b1511367 100644 --- a/ps3/ps3_input.c +++ b/ps3/ps3_input.c @@ -69,22 +69,22 @@ static void ps3_mouse_input_deinit(void) { - pMouseEnd(); + cellMouseEnd(); } static uint32_t ps3_mouse_input_mice_connected(void) { - pMouseInfo mouse_info; - pMouseGetInfo(&mouse_info); + CellMouseInfo mouse_info; + cellMouseGetInfo(&mouse_info); return mouse_info.now_connect; } -pMouseData ps3_mouse_input_poll_device(uint32_t id) +CellMouseData ps3_mouse_input_poll_device(uint32_t id) { - pMouseData mouse_data; + CellMouseData mouse_data; // Get new pad data - pMouseGetData(id, &mouse_data); + cellMouseGetData(id, &mouse_data); return mouse_data; } @@ -105,11 +105,11 @@ static unsigned mice_connected; uint64_t cell_pad_input_poll_device(uint32_t id) { - pPadData pad_data; + CellPadData pad_data; static uint64_t ret[MAX_PADS]; // Get new pad data - pPadGetData(id, &pad_data); + cellPadGetData(id, &pad_data); if (pad_data.len != 0) { @@ -138,13 +138,13 @@ uint64_t cell_pad_input_poll_device(uint32_t id) } static void ps3_input_poll(void *data) { - pPadInfo pad_info; + CellPadInfo2 pad_info; (void)data; for (unsigned i = 0; i < MAX_PADS; i++) state[i] = cell_pad_input_poll_device(i); - pPadGetInfo(&pad_info); + cellPadGetInfo2(&pad_info); pads_connected = pad_info.now_connect; #ifdef HAVE_MOUSE mice_connected = ps3_mouse_input_mice_connected(); @@ -155,7 +155,7 @@ static void ps3_input_poll(void *data) static int16_t ps3_mouse_device_state(void *data, unsigned player, unsigned id) { - pMouseData mouse_state = ps3_mouse_input_poll_device(player); + CellMouseData mouse_state = ps3_mouse_input_poll_device(player); switch (id) { @@ -268,7 +268,7 @@ bool oskutil_start(oskutil_params *params) if (params->flags & OSK_IN_USE) return (true); - int ret = pSysMemContainerCreate(¶ms->containerid, params->osk_memorycontainer); + int ret = sys_memory_container_create(¶ms->containerid, params->osk_memorycontainer); if(ret < 0) return (false); @@ -326,7 +326,7 @@ void oskutil_finished(oskutil_params *params) void oskutil_unload(oskutil_params *params) { - pSysMemContainerDestroy(params->containerid); + sys_memory_container_destroy(params->containerid); params->is_running = false; } @@ -339,14 +339,14 @@ void oskutil_unload(oskutil_params *params) static void ps3_free_input(void *data) { (void)data; - //pPadEnd(); + //cellPadEnd(); } static void* ps3_input_initialize(void) { - pPadInit(MAX_PADS); + cellPadInit(MAX_PADS); #ifdef HAVE_MOUSE - pMouseInit(MAX_MICE); + cellMouseInit(MAX_MICE); #endif for(unsigned i = 0; i < MAX_PADS; i++) ps3_input_map_dpad_to_stick(g_settings.input.dpad_emulation[i], i); diff --git a/ps3/sdk_defines.h b/ps3/sdk_defines.h index d918beb4a3..6ca3baaca7 100644 --- a/ps3/sdk_defines.h +++ b/ps3/sdk_defines.h @@ -23,33 +23,33 @@ #ifdef __PSL1GHT__ /* define all the audio/audio port functions */ -#define pAudioQuit audioQuit -#define pAudioInit audioInit -#define pAudioPortStart audioPortStart -#define pAudioPortOpen audioPortOpen -#define pAudioPortClose audioPortClose -#define pAudioPortStop audioPortStop -#define pAudioPortParam audioPortParam -#define pAudioPortOpen audioPortOpen -#define pAudioAddData audioAddData +#define cellAudioQuit audioQuit +#define cellAudioInit audioInit +#define cellAudioPortStart audioPortStart +#define cellAudioPortOpen audioPortOpen +#define cellAudioPortClose audioPortClose +#define cellAudioPortStop audioPortStop +#define CellAudioPortParam audioPortParam +#define cellAudioPortOpen audioPortOpen +#define cellAudioAddData audioAddData /* define all the event queue functions */ -#define pSysEventQueueReceive sysEventQueueReceive -#define pAudioSetNotifyEventQueue audioSetNotifyEventQueue -#define pAudioRemoveNotifyEventQueue audioRemoveNotifyEventQueue -#define pAudioCreateNotifyEventQueue audioCreateNotifyEventQueue +#define sys_event_queue_receive sysEventQueueReceive +#define cellAudioSetNotifyEventQueue audioSetNotifyEventQueue +#define cellAudioRemoveNotifyEventQueue audioRemoveNotifyEventQueue +#define cellAudioCreateNotifyEventQueue audioCreateNotifyEventQueue /* define all the lightweight mutex functions */ -#define pLwMutexDestroy sysLwMutexDestroy -#define pLwMutexLock sysLwMutexLock -#define pLwMutexUnlock sysLwMutexUnlock -#define pLwMutexCreate sysLwMutexCreate +#define sys_lwmutex_destroy sysLwMutexDestroy +#define sys_lwmutex_lock sysLwMutexLock +#define sys_lwmutex_unlock sysLwMutexUnlock +#define sys_lwmutex_create sysLwMutexCreate /* define all the lightweight condition functions */ -#define pLwCondCreate sysLwCondCreate -#define pLwCondDestroy sysLwCondDestroy -#define pLwCondWait sysLwCondWait -#define pLwCondSignal sysLwCondSignal +#define sys_lwcond_create sysLwCondCreate +#define sys_lwcond_destroy sysLwCondDestroy +#define sys_lwcond_wait sysLwCondWait +#define sys_lwcond_signal sysLwCondSignal #define CELL_AUDIO_BLOCK_SAMPLES AUDIO_BLOCK_SAMPLES #define SYS_NO_TIMEOUT 0 @@ -58,36 +58,6 @@ #define sys_lwcond_attribute_t sys_lwcond_attr_t #else - -/* define all the audio/audio port functions */ -#define pAudioQuit cellAudioQuit -#define pAudioInit cellAudioInit -#define pAudioPortStart cellAudioPortStart -#define pAudioPortOpen cellAudioPortOpen -#define pAudioPortClose cellAudioPortClose -#define pAudioPortStop cellAudioPortStop -#define pAudioPortParam CellAudioPortParam -#define pAudioAddData cellAudioAddData - -/* define all the event queue functions */ -#define pSysEventQueueReceive sys_event_queue_receive -#define pAudioSetNotifyEventQueue cellAudioSetNotifyEventQueue -#define pAudioRemoveNotifyEventQueue cellAudioRemoveNotifyEventQueue -#define pAudioCreateNotifyEventQueue cellAudioCreateNotifyEventQueue - -/* define all the lightweight mutex functions */ -#define pLwMutexDestroy sys_lwmutex_destroy -#define pLwMutexUnlock sys_lwmutex_unlock -#define pLwMutexLock sys_lwmutex_lock -#define pLwMutexCreate sys_lwmutex_create -#define pLwMutexAttributeInitialize sys_lwmutex_attribute_initialize - -/* define all the lightweight condition functions */ -#define pLwCondCreate sys_lwcond_create -#define pLwCondDestroy sys_lwcond_destroy -#define pLwCondWait sys_lwcond_wait -#define pLwCondSignal sys_lwcond_signal - #define numChannels nChannel #define numBlocks nBlock #define param_attrib attr @@ -100,35 +70,16 @@ #ifdef __PSL1GHT__ /* define all the ps3 pad structs */ -#define pPadInfo padInfo2 -#define pPadData padData +#define CellPadInfo2 padInfo2 +#define CellPadData padData /* define all the ps3 pad functions */ -#define pPadGetInfo ioPadGetInfo2 -#define pPadGetData ioPadGetData -#define pPadInit ioPadInit -#define pPadEnd ioPadEnd +#define cellPadGetInfo2 ioPadGetInfo2 +#define cellPadGetData ioPadGetData +#define cellPadInit ioPadInit +#define cellPadEnd ioPadEnd #define now_connect connected - -#else -/* define all the ps3 pad structs */ -/* #if (CELL_SDK_VERSION > 0x340000) */ -#define pPadInfo CellPadInfo2 -#define pPadGetInfo cellPadGetInfo2 -/* -#else -#define pPadInfo CellPadInfo -#define pPadGetInfo cellPadGetInfo -#endif -*/ - -#define pPadData CellPadData - -/* define all the ps3 pad functions */ -#define pPadInit cellPadInit -#define pPadEnd cellPadEnd -#define pPadGetData cellPadGetData #endif /*============================================================ @@ -137,17 +88,16 @@ #ifdef HAVE_MOUSE - #ifdef __PSL1GHT__ /* define ps3 mouse structs */ -#define pMouseInfo mouseInfo -#define pMouseData mouseData +#define CellMouseInfo mouseInfo +#define CellMouseData mouseData /* define all the ps3 mouse functions */ -#define pMouseInit ioMouseInit -#define pMouseGetData ioMouseGetData -#define pMouseEnd ioMouseEnd -#define pMouseGetInfo ioMouseGetInfo +#define cellMouseInit ioMouseInit +#define cellMouseGetData ioMouseGetData +#define cellMouseEnd ioMouseEnd +#define cellMouseGetInfo ioMouseGetInfo /* PSL1GHT does not define these in its header */ #define CELL_MOUSE_BUTTON_1 (1 << 0) /* Button 1 */ @@ -159,16 +109,6 @@ #define CELL_MOUSE_BUTTON_7 (1 << 6) /* Button 7 */ #define CELL_MOUSE_BUTTON_8 (1 << 7) /* Button 8 */ -#else -/* define ps3 mouse structs */ -#define pMouseInfo CellMouseInfo -#define pMouseData CellMouseData - -/* define all the ps3 mouse functions */ -#define pMouseInit cellMouseInit -#define pMouseGetData cellMouseGetData -#define pMouseEnd cellMouseEnd -#define pMouseGetInfo cellMouseGetInfo #endif #endif @@ -395,16 +335,11 @@ #ifdef __PSL1GHT__ /* define all the thread functions */ -#define pThreadCreate sysThreadCreate -#define pThreadJoin sysThreadJoin -#define pThreadExit sysThreadExit +#define sys_ppu_thread_create sysThreadCreate +#define sys_ppu_thread_join sysThreadJoin +#define sys_ppu_thread_exit sysThreadExit #define SYS_PPU_THREAD_CREATE_JOINABLE 0 /* FIXME - not sure if this is correct */ -#else -/* define all the thread functions */ -#define pThreadCreate sys_ppu_thread_create -#define pThreadJoin sys_ppu_thread_join -#define pThreadExit sys_ppu_thread_exit #endif /*============================================================ @@ -412,11 +347,8 @@ ============================================================ */ #ifdef __PSL1GHT__ -#define pSysMemContainerCreate sysMemContainerCreate -#define pSysMemContainerDestroy sysMemContainerDestroy -#else -#define pSysMemContainerCreate sys_memory_container_create -#define pSysMemContainerDestroy sys_memory_container_destroy +#define sys_memory_container_create sysMemContainerCreate +#define sys_memory_container_destroy sysMemContainerDestroy #endif #endif