From 60a10527f24efc63bdca6815914a240d706236db Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 11 Nov 2007 15:38:27 +0000 Subject: [PATCH] dualcore integration in famc, bram cart C code, psp bugfixes git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@294 be3aeb3a-fb24-0410-a615-afba39da0efa --- gp2x/Makefile | 4 ++-- gp2x/port_config.h | 1 + psp/emu.c | 31 +++++++++++++++++++++---------- psp/menu.c | 9 ++++++--- psp/mp3.c | 4 ++-- psp/port_config.h | 3 ++- 6 files changed, 34 insertions(+), 18 deletions(-) diff --git a/gp2x/Makefile b/gp2x/Makefile index 0e2ffe4..dcd4531 100644 --- a/gp2x/Makefile +++ b/gp2x/Makefile @@ -217,9 +217,9 @@ readme.txt: ../../tools/textfilter ../base_readme.txt # cleanup clean: tidy - @$(RM) PicoDrive.gpe + $(RM) PicoDrive.gpe tidy: - @$(RM) $(OBJS) + $(RM) $(OBJS) # @make -C ../../cpu/Cyclone/proj -f Makefile.linux clean diff --git a/gp2x/port_config.h b/gp2x/port_config.h index 19840c8..5d9bf04 100644 --- a/gp2x/port_config.h +++ b/gp2x/port_config.h @@ -5,6 +5,7 @@ #define CASE_SENSITIVE_FS 1 // CS filesystem #define DONT_OPEN_MANY_FILES 0 +#define REDUCE_IO_CALLS 0 // draw.c #define OVERRIDE_HIGHCOL 0 diff --git a/psp/emu.c b/psp/emu.c index 51db24a..b7d6bae 100644 --- a/psp/emu.c +++ b/psp/emu.c @@ -48,10 +48,10 @@ void emu_getMainDir(char *dst, int len) if (len > 0) *dst = 0; } -static void osd_text(int x, const char *text, int is_active) +static void osd_text(int x, const char *text, int is_active, int clear_all) { unsigned short *screen = is_active ? psp_video_get_active_fb() : psp_screen; - int len = strlen(text) * 8 / 2; + int len = clear_all ? (480 / 2) : (strlen(text) * 8 / 2); int *p, h; void *tmp; for (h = 0; h < 8; h++) { @@ -66,7 +66,7 @@ static void osd_text(int x, const char *text, int is_active) void emu_msg_cb(const char *msg) { - osd_text(4, msg, 1); + osd_text(4, msg, 1, 1); noticeMsgTime = sceKernelGetSystemTimeLow() - 2000000; /* assumption: emu_msg_cb gets called only when something slow is about to happen */ @@ -149,7 +149,7 @@ void emu_setDefaultConfig(void) currentConfig.KeyBinds[30] = 1<<1; currentConfig.KeyBinds[31] = 1<<2; currentConfig.KeyBinds[29] = 1<<3; - currentConfig.PicoCDBuffers = 0; + currentConfig.PicoCDBuffers = 64; currentConfig.scaling = 1; // bilinear filtering for psp currentConfig.scale = 1.20; // fullscreen currentConfig.hscale40 = 1.25; @@ -411,8 +411,8 @@ static void blit2(const char *fps, const char *notice, int lagging_behind) int vsync = 0, emu_opt = currentConfig.EmuOpt; if (notice || (emu_opt & 2)) { - if (notice) osd_text(4, notice, 0); - if (emu_opt & 2) osd_text(OSD_FPS_X, fps, 0); + if (notice) osd_text(4, notice, 0, 0); + if (emu_opt & 2) osd_text(OSD_FPS_X, fps, 0, 0); } dbg_text(); @@ -567,8 +567,8 @@ static void sound_prepare(void) lprintf("starting audio: %i, len: %i, stereo: %i, pal: %i, block samples: %i\n", PsndRate, PsndLen, stereo, Pico.m.pal, samples_block); - while (sceAudioOutput2GetRestSample() > 0) psp_msleep(100); - sceAudio_5C37C0AE(); + // while (sceAudioOutput2GetRestSample() > 0) psp_msleep(100); + // sceAudio_5C37C0AE(); ret = sceAudio_38553111(samples_block/2, PsndRate, 2); // seems to not need that stupid 64byte alignment if (ret < 0) { lprintf("sceAudio_38553111() failed: %i\n", ret); @@ -589,8 +589,19 @@ static void sound_prepare(void) static void sound_end(void) { + int i; + if (samples_done == 0) + { + // if no data is written between sceAudio_38553111 and sceAudio_5C37C0AE calls, + // we get a deadlock on next sceAudio_38553111 call + // so this is yet another workaround: + memset32((int *)(void *)sndBuffer, 0, samples_block*4/4); + samples_made = samples_block * 3; + sceKernelSignalSema(sound_sem, 1); + } + sceKernelDelayThread(100*1000); samples_made = samples_done = 0; - while (sceAudioOutput2GetRestSample() > 0) + for (i = 0; sceAudioOutput2GetRestSample() > 0 && i < 16; i++) psp_msleep(100); sceAudio_5C37C0AE(); } @@ -685,7 +696,7 @@ static void RunEvents(unsigned int which) if (do_it) { - osd_text(4, (which & 0x1000) ? "LOADING GAME" : "SAVING GAME", 1); + osd_text(4, (which & 0x1000) ? "LOADING GAME" : "SAVING GAME", 1, 0); PicoStateProgressCB = emu_msg_cb; emu_SaveLoadGame((which & 0x1000) >> 12, 0); PicoStateProgressCB = NULL; diff --git a/psp/menu.c b/psp/menu.c index 53d7c25..86628ca 100644 --- a/psp/menu.c +++ b/psp/menu.c @@ -917,17 +917,20 @@ static void cd_menu_loop_options(void) char *bios, *p; if (emu_findBios(4, &bios)) { // US - for (p = bios+strlen(bios)-1; p > bios && *p != '/'; p--); p++; + for (p = bios+strlen(bios)-1; p > bios && *p != '/'; p--); + if (*p == '/') p++; strncpy(bios_names.us, p, sizeof(bios_names.us)); bios_names.us[sizeof(bios_names.us)-1] = 0; } else strcpy(bios_names.us, "NOT FOUND"); if (emu_findBios(8, &bios)) { // EU - for (p = bios+strlen(bios)-1; p > bios && *p != '/'; p--); p++; + for (p = bios+strlen(bios)-1; p > bios && *p != '/'; p--); + if (*p == '/') p++; strncpy(bios_names.eu, p, sizeof(bios_names.eu)); bios_names.eu[sizeof(bios_names.eu)-1] = 0; } else strcpy(bios_names.eu, "NOT FOUND"); if (emu_findBios(1, &bios)) { // JP - for (p = bios+strlen(bios)-1; p > bios && *p != '/'; p--); p++; + for (p = bios+strlen(bios)-1; p > bios && *p != '/'; p--); + if (*p == '/') p++; strncpy(bios_names.jp, p, sizeof(bios_names.jp)); bios_names.jp[sizeof(bios_names.jp)-1] = 0; } else strcpy(bios_names.jp, "NOT FOUND"); diff --git a/psp/mp3.c b/psp/mp3.c index f0cfe8f..f3abc2f 100644 --- a/psp/mp3.c +++ b/psp/mp3.c @@ -104,7 +104,7 @@ static int read_next_frame(int which_buffer) } if (frame_offset) { - lprintf("unaligned, foffs=%i, offs=%i\n", mp3_src_pos - bytes_read, frame_offset); + //lprintf("unaligned, foffs=%i, offs=%i\n", mp3_src_pos - bytes_read, frame_offset); memmove(mp3_src_buffer[which_buffer], mp3_src_buffer[which_buffer] + frame_offset, frame_size); } @@ -327,7 +327,7 @@ void mp3_start_play(FILE *f, int pos) lprintf("mp3_start_play(%s) @ %i\n", fname, pos); psp_sem_lock(thread_busy_sem); - if (mp3_fname != fname) + if (mp3_fname != fname || mp3_handle < 0) { if (mp3_handle >= 0) sceIoClose(mp3_handle); mp3_handle = sceIoOpen(fname, PSP_O_RDONLY, 0777); diff --git a/psp/port_config.h b/psp/port_config.h index f533633..231db72 100644 --- a/psp/port_config.h +++ b/psp/port_config.h @@ -4,7 +4,8 @@ #define PORT_CONFIG_H #define CASE_SENSITIVE_FS 0 -#define DONT_OPEN_MANY_FILES 1 // work around the stupid PSP 10 open file limit +#define DONT_OPEN_MANY_FILES 1 // work around the stupid PSP ~10 open file limit +#define REDUCE_IO_CALLS 1 // another workaround // draw.c #define USE_BGR555 1 -- 2.39.2