Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.1 | PSP] Generate PARAM.SFO / Fix HOME button #18

Open
wants to merge 5 commits into
base: main/2.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed PARAM.SFO
Binary file not shown.
6 changes: 5 additions & 1 deletion platform/psp/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)


72 changes: 20 additions & 52 deletions platform/psp/audio_driver_psp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion platform/psp/audio_driver_psp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
30 changes: 27 additions & 3 deletions platform/psp/os_psp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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;
Expand All @@ -379,6 +402,7 @@ void OS_PSP::run() {
return;

main_loop->init();
SetupCallbacks();

while (!force_quit) {

Expand Down