diff --git a/PARAM.SFO b/PARAM.SFO deleted file mode 100644 index 72923dba5c06..000000000000 Binary files a/PARAM.SFO and /dev/null differ diff --git a/platform/psp/SCsub b/platform/psp/SCsub index 7c347c7cab1a..8872d2067c59 100644 --- a/platform/psp/SCsub +++ b/platform/psp/SCsub @@ -25,7 +25,11 @@ env.Command( ) env.Command( - "#bin/EBOOT.PBP", "#bin/strip2.elf" ,"pack-pbp bin/EBOOT.PBP PARAM.SFO NULL NULL NULL NULL NULL bin/strip2.elf NULL" + "#bin/PARAM.SFO", "", "mksfoex -d MEMSIZE=1 Godot bin/PARAM.SFO" +) + +env.Command( + "#bin/EBOOT.PBP", ["#bin/strip2.elf", "#bin/PARAM.SFO"] ,"pack-pbp bin/EBOOT.PBP bin/PARAM.SFO NULL NULL NULL NULL NULL bin/strip2.elf NULL" ) diff --git a/platform/psp/audio_driver_psp.cpp b/platform/psp/audio_driver_psp.cpp index bbb7fbefa57d..17aed09e15c6 100644 --- a/platform/psp/audio_driver_psp.cpp +++ b/platform/psp/audio_driver_psp.cpp @@ -54,63 +54,31 @@ Error AudioDriverPSP::init() { samples_in = memnew_arr(int32_t, buffer_size*channels); samples_out = memnew_arr(int16_t, buffer_size*channels); - - // channel_num = sceAudioChReserve(1, PSP_AUDIO_SAMPLE_ALIGN(buffer_size*channels), PSP_AUDIO_FORMAT_MONO); - sceAudioOutput2Reserve(buffer_size); - - mutex = Mutex::create(); - thread = Thread::create(AudioDriverPSP::thread_func, this); - + + pspAudioInit(); + pspAudioSetChannelCallback(0, thread_func, (void*)this); return OK; }; -void AudioDriverPSP::thread_func(void *p_udata) { - - int buffer_index = 0; - printf("out\n"); - AudioDriverPSP* ad = (AudioDriverPSP*)p_udata; - - int sample_count = ad->buffer_size ; - uint64_t usdelay = (ad->buffer_size / float(ad->mix_rate)) * 1000000; - - while (!ad->exit_thread) { - - - if (ad->exit_thread) - break; -#ifndef PPSSPP - while(sceAudioWaitInputEnd()) { - OS::get_singleton()->delay_usec(usdelay); - } -#endif - if (ad->active) { - ad->lock(); - - ad->audio_server_process(ad->buffer_size, ad->samples_in); - - ad->unlock(); - - for(int i = 0; i < sample_count*2; ++i) { - ad->samples_out[i] = ad->samples_in[i] >> 16; - } - - - } else - { - for (int i = 0; i < sample_count*2; i++) { - - ad->samples_out[i] = 0; - } - } -// #ifdef PPSSPP -// OS::get_singleton()->delay_usec(usdelay); -// #endif - sceAudioOutput2OutputBlocking(0x8000, ad->samples_out); +void AudioDriverPSP::thread_func(void *udata, unsigned int numSamples, void *userdata) +{ + AudioDriverPSP* ad = (AudioDriverPSP*)userdata; + if (ad->active) { + ad->lock(); + ad->audio_server_process(numSamples, ad->samples_in); + ad->unlock(); + short * _buf = (short *) udata; + unsigned int count; + for (count = 0; count < numSamples * 2; count++) + *(_buf + count) = (ad->samples_in[count] >> 16) * 0.9; + } else + { + short * _buf = (short *) udata; + unsigned int count; + for (count = 0; count < numSamples * 2; count++) + *(_buf + count) = 0; } - - - ad->thread_exited=true; }; void AudioDriverPSP::start() { diff --git a/platform/psp/audio_driver_psp.h b/platform/psp/audio_driver_psp.h index d1387c0def7c..5937cba4e8d5 100644 --- a/platform/psp/audio_driver_psp.h +++ b/platform/psp/audio_driver_psp.h @@ -47,7 +47,7 @@ class AudioDriverPSP : public AudioDriverSW { int16_t* samples_out; int id; - static void thread_func(void *p_udata); + static void thread_func(void *udata, unsigned int numSamples, void *userdata); int buffer_size; diff --git a/platform/psp/os_psp.cpp b/platform/psp/os_psp.cpp index 294fed30d414..0c2e3f0ad3ad 100644 --- a/platform/psp/os_psp.cpp +++ b/platform/psp/os_psp.cpp @@ -334,9 +334,6 @@ void OS_PSP::process_keys() { input->joy_axis(0, 0, 0, lx); input->joy_axis(0, 0, 1, ly); - - if(pad.Buttons & PSP_CTRL_HOME) - sceKernelExitGame(); } void OS_PSP::delete_main_loop() { @@ -371,6 +368,32 @@ void OS_PSP::set_cursor_shape(CursorShape p_shape) { void OS_PSP::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) { } +// Standard callback functions +/* Exit callback */ +int exit_callback(int arg1, int arg2, void *common) { + sceKernelExitGame(); + return 0; +} + +/* Callback thread */ +int CallbackThread(SceSize args, void *argp) { + int cbid; + cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL); + sceKernelRegisterExitCallback(cbid); + sceKernelSleepThreadCB(); + return 0; +} + +/* Sets up the callback thread and returns its thread id */ +int SetupCallbacks(void) { + int thid = 0; + thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0); + if(thid >= 0) { + sceKernelStartThread(thid, 0, 0); + } + return thid; +} + void OS_PSP::run() { force_quit = false; @@ -379,6 +402,7 @@ void OS_PSP::run() { return; main_loop->init(); + SetupCallbacks(); while (!force_quit) {