From: notaz Date: Thu, 15 Nov 2007 23:01:20 +0000 (+0000) Subject: optimizations, fixes, hacks, psp, ... X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5ecedd0cc2257b564dfcf68cb0e9d7d541bfc2b8;p=libpicofe.git optimizations, fixes, hacks, psp, ... git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@295 be3aeb3a-fb24-0410-a615-afba39da0efa --- diff --git a/gp2x/940ctl.c b/gp2x/940ctl.c index a927913..917ed29 100644 --- a/gp2x/940ctl.c +++ b/gp2x/940ctl.c @@ -51,22 +51,12 @@ static FILE *loaded_mp3 = 0; } /* these will be managed locally on our side */ -extern int *ym2612_dacen; -extern INT32 *ym2612_dacout; static UINT8 *REGS = 0; /* we will also keep local copy of regs for savestates and such */ static INT32 *addr_A1; /* address line A1 */ static int dacen; static INT32 dacout; static UINT8 ST_address; /* address register */ -static UINT8 ST_status; /* status flag */ -static UINT8 ST_mode; /* mode CSM / 3SLOT */ -static int ST_TA; /* timer a */ -static int ST_TAC; /* timer a maxval */ -static int ST_TAT; /* timer a ticker */ -static UINT8 ST_TB; /* timer b */ -static int ST_TBC; /* timer b maxval */ -static int ST_TBT; /* timer b ticker */ static int writebuff_ptr = 0; @@ -84,16 +74,16 @@ static int set_timers( int v ) /* b2 = timer enable a */ /* b1 = load b */ /* b0 = load a */ - change = (ST_mode ^ v) & 0xc0; - ST_mode = v; + change = (ym2612_st->mode ^ v) & 0xc0; + ym2612_st->mode = v; /* reset Timer b flag */ if( v & 0x20 ) - ST_status &= ~2; + ym2612_st->status &= ~2; /* reset Timer a flag */ if( v & 0x10 ) - ST_status &= ~1; + ym2612_st->status &= ~1; return change; } @@ -139,30 +129,30 @@ int YM2612Write_940(unsigned int a, unsigned int v) switch( addr ) { case 0x24: { // timer A High 8 - int TAnew = (ST_TA & 0x03)|(((int)v)<<2); - if(ST_TA != TAnew) { + int TAnew = (ym2612_st->TA & 0x03)|(((int)v)<<2); + if (ym2612_st->TA != TAnew) { // we should reset ticker only if new value is written. Outrun requires this. - ST_TA = TAnew; - ST_TAC = (1024-TAnew)*18; - ST_TAT = 0; + ym2612_st->TA = TAnew; + ym2612_st->TAC = (1024-TAnew)*18; + ym2612_st->TAT = 0; } return 0; } case 0x25: { // timer A Low 2 - int TAnew = (ST_TA & 0x3fc)|(v&3); - if(ST_TA != TAnew) { - ST_TA = TAnew; - ST_TAC = (1024-TAnew)*18; - ST_TAT = 0; + int TAnew = (ym2612_st->TA & 0x3fc)|(v&3); + if (ym2612_st->TA != TAnew) { + ym2612_st->TA = TAnew; + ym2612_st->TAC = (1024-TAnew)*18; + ym2612_st->TAT = 0; } return 0; } case 0x26: // timer B - if(ST_TB != v) { - ST_TB = v; - ST_TBC = (256-v)<<4; - ST_TBC *= 18; - ST_TBT = 0; + if (ym2612_st->TB != v) { + ym2612_st->TB = v; + ym2612_st->TBC = (256-v)<<4; + ym2612_st->TBC *= 18; + ym2612_st->TBT = 0; } return 0; case 0x27: /* mode, timer control */ @@ -229,38 +219,6 @@ int YM2612Write_940(unsigned int a, unsigned int v) return 0; // cause the engine to do updates once per frame only } -UINT8 YM2612Read_940(void) -{ - return ST_status; -} - - -int YM2612PicoTick_940(int n) -{ - //int ret = 0; - - // timer A - if(ST_mode & 0x01 && (ST_TAT+=64*n) >= ST_TAC) { - ST_TAT -= ST_TAC; - if(ST_mode & 0x04) ST_status |= 1; - // CSM mode total level latch and auto key on -/* FIXME - if(ST_mode & 0x80) { - CSMKeyControll( &(ym2612_940->CH[2]) ); // Vectorman2, etc. - ret = 1; - } -*/ - } - - // timer B - if(ST_mode & 0x02 && (ST_TBT+=64*n) >= ST_TBC) { - ST_TBT -= ST_TBC; - if(ST_mode & 0x08) ST_status |= 2; - } - - return 0; -} - #define CHECK_BUSY(job) \ (gp2x_memregs[0x3b46>>1] & (1<<(job-1))) @@ -339,12 +297,14 @@ void YM2612PicoStateLoad_940(void) static void internal_reset(void) { writebuff_ptr = 0; - ST_mode = 0; - ST_status = 0; /* normal mode */ - ST_TA = 0; - ST_TAC = 0; - ST_TB = 0; - ST_TBC = 0; + ym2612_st->mode = 0; + ym2612_st->status = 0; /* normal mode */ + ym2612_st->TA = 0; + ym2612_st->TAC = 0; + ym2612_st->TAT = 0; + ym2612_st->TB = 0; + ym2612_st->TBC = 0; + ym2612_st->TBT = 0; dacen = 0; dacout = 0; ST_address= 0; diff --git a/gp2x/Makefile b/gp2x/Makefile index dcd4531..eeb37c7 100644 --- a/gp2x/Makefile +++ b/gp2x/Makefile @@ -138,15 +138,10 @@ endif all: PicoDrive.gpe PicoDrive.gpe : $(OBJS) ../common/helix/helix_mp3.a - @echo $@ - @$(GCC) -o $@ $(COPT) $^ -lm -lpng -Wl,-Map=PicoDrive.map + @echo ">>>" $@ + $(GCC) -o $@ $(COPT) $^ -lm -lpng -Wl,-Map=PicoDrive.map ifeq ($(DEBUG),) - @$(STRIP) $@ -endif -# @$(GCC) $(COPT) $(OBJS) -lm -o PicoDrive_.gpe -# @gpecomp PicoDrive_.gpe $@ -ifeq "$(up)" "1" - @cmd //C copy $@ \\\\10.0.1.2\\gp2x\\mnt\\sd\\games\\PicoDrive\\ + $(STRIP) $@ endif up: PicoDrive.gpe @@ -155,45 +150,40 @@ up: PicoDrive.gpe # @cmd //C copy PicoDrive.gpe \\\\10.0.1.2\\gp2x\\mnt\\sd\\games\\PicoDrive\\ -testrefr.gpe : test.o gp2x.o - @echo $@ - @$(GCC) $(COPT) $^ -o $@ - @$(STRIP) $@ - .c.o: - @echo $< - @$(GCC) $(COPT) $(DEFINC) -c $< -o $@ + @echo ">>>" $< + $(GCC) $(COPT) $(DEFINC) -c $< -o $@ .s.o: - @echo $< - @$(GCC) $(COPT) $(DEFINC) -c $< -o $@ + @echo ">>>" $< + $(GCC) $(COPT) $(DEFINC) -c $< -o $@ ../../Pico/draw_asm.o : ../../Pico/Draw.s - @echo $< - @$(AS) $(ASOPT) $< -o $@ + @echo ">>>" $< + $(AS) $(ASOPT) $< -o $@ ../../Pico/draw2_asm.o : ../../Pico/Draw2.s - @echo $< - @$(AS) $(ASOPT) $< -o $@ + @echo ">>>" $< + $(AS) $(ASOPT) $< -o $@ ../../Pico/memory_asm.o : ../../Pico/Memory.s - @echo $< - @$(AS) $(ASOPT) $< -o $@ + @echo ">>>" $< + $(AS) $(ASOPT) $< -o $@ ../../Pico/sound/ym2612_asm.o : ../../Pico/sound/ym2612.s - @echo $< - @$(AS) $(ASOPT) $< -o $@ + @echo ">>>" $< + $(AS) $(ASOPT) $< -o $@ ../../Pico/sound/mix_asm.o : ../../Pico/sound/mix.s - @echo $< - @$(AS) $(ASOPT) $< -o $@ + @echo ">>>" $< + $(AS) $(ASOPT) $< -o $@ ../../Pico/misc_asm.o : ../../Pico/Misc.s - @echo $< - @$(AS) $(ASOPT) $< -o $@ + @echo ">>>" $< + $(AS) $(ASOPT) $< -o $@ ../../Pico/cd/pico_asm.o : ../../Pico/cd/Pico.s - @echo $< - @$(AS) $(ASOPT) $< -o $@ + @echo ">>>" $< + $(AS) $(ASOPT) $< -o $@ ../../Pico/cd/memory_asm.o : ../../Pico/cd/Memory.s - @echo $< - @$(AS) $(ASOPT) $< -o $@ + @echo ">>>" $< + $(AS) $(ASOPT) $< -o $@ ../../Pico/cd/misc_asm.o : ../../Pico/cd/Misc.s - @echo $< - @$(AS) $(ASOPT) $< -o $@ + @echo ">>>" $< + $(AS) $(ASOPT) $< -o $@ # build Cyclone ../../cpu/Cyclone/proj/Cyclone.s : diff --git a/gp2x/version.h b/gp2x/version.h index 93ee956..f2fb563 100644 --- a/gp2x/version.h +++ b/gp2x/version.h @@ -1,2 +1,2 @@ -#define VERSION "1.34" +#define VERSION "1.35" diff --git a/linux/940ctl_ym2612.c b/linux/940ctl_ym2612.c index 403cca2..ee63458 100644 --- a/linux/940ctl_ym2612.c +++ b/linux/940ctl_ym2612.c @@ -40,19 +40,6 @@ int YM2612Write_940(unsigned int a, unsigned int v) return 0; // cause the engine to do updates once per frame only } -UINT8 YM2612Read_940(void) -{ - return YM2612Read_(); -} - - -int YM2612PicoTick_940(int n) -{ - YM2612PicoTick_(n); - - return 0; -} - void YM2612PicoStateLoad_940(void) { diff --git a/linux/Makefile b/linux/Makefile index 9dd365f..0af279c 100644 --- a/linux/Makefile +++ b/linux/Makefile @@ -13,8 +13,8 @@ STRIP = strip AS = gcc ifeq "$(profile)" "1" -COPT_COMMON = -s -O3 -ftracer -fstrength-reduce -Wall -funroll-loops -fomit-frame-pointer -fstrict-aliasing -ffast-math -fprofile-generate # -static -COPT = $(COPT_COMMON) # -mtune=arm920t +COPT_COMMON = -s -O3 -ftracer -fstrength-reduce -Wall -funroll-loops -fomit-frame-pointer -fstrict-aliasing -ffast-math -fprofile-generate +COPT = $(COPT_COMMON) else COPT = -ggdb -Wall -fno-strict-aliasing # -pg -O3 -ftracer -fstrength-reduce -funroll-loops -fomit-frame-pointer -ffast-math COPT_COMMON = $(COPT) diff --git a/psp/Makefile b/psp/Makefile index 6acc3eb..c3b04cd 100644 --- a/psp/Makefile +++ b/psp/Makefile @@ -6,23 +6,19 @@ PSPSDK = $(shell psp-config --pspsdk-path) #use_musashi = 1 #use_mz80 = 1 amalgamate = 0 -#profile = 1 -#up = 1 CFLAGS += -I../.. -I. -DNO_SYNC -DLPRINTF_STDIO CFLAGS += -Wall -Winline -G0 +CFLAGS += -DLPRINTF_STDIO +#CFLAGS += -fprofile-generate +#CFLAGS += -fprofile-use +#CFLAGS += -pg ifeq ($(DEBUG),) CFLAGS += -O2 -ftracer -fstrength-reduce -ffast-math else CFLAGS += -ggdb endif -ifeq "$(profile)" "1" -CFLAGS += -fprofile-generate -endif -ifeq "$(profile)" "2" -CFLAGS += -fprofile-use -endif # frontend @@ -37,7 +33,7 @@ OBJS += ../../PicoAll.o else OBJS += ../../Pico/Area.o ../../Pico/Cart.o ../../Pico/Memory.o ../../Pico/Misc.o \ ../../Pico/Pico.o ../../Pico/Sek.o ../../Pico/VideoPort.o ../../Pico/Draw2.o ../../Pico/Draw.o \ - ../../Pico/Patch.o ../../Pico/Draw_amips.o ../../Pico/Memory_amips.o + ../../Pico/Patch.o ../../Pico/Draw_amips.o ../../Pico/Memory_amips.o ../../Pico/Misc_amips.o # Pico - CD OBJS += ../../Pico/cd/Pico.o ../../Pico/cd/Memory.o ../../Pico/cd/Sek.o ../../Pico/cd/LC89510.o \ ../../Pico/cd/cd_sys.o ../../Pico/cd/cd_file.o ../../Pico/cd/gfx_cd.o \ @@ -77,8 +73,10 @@ OBJS += data/bg32.o data/bg40.o LIBS += -lpng -lm -lpspgu -lpsppower -lpspaudio -lpsprtc -lpspaudiocodec +#LIBS += -lpspprof LDFLAGS += -Wl,-Map=PicoDrive.map + # target TARGET = PicoDrive EXTRA_TARGETS = EBOOT.PBP @@ -114,7 +112,11 @@ AS := psp-as ../../Pico/Draw.o : ../../Pico/Draw.c @echo ">>>" $< - $(CC) $(CFLAGS) -c $< -o $@ -D_ASM_DRAW_C_MIPS + $(CC) $(CFLAGS) -c $< -o $@ -D_ASM_DRAW_C_AMIPS + +../../Pico/Misc.o : ../../Pico/Misc.c + @echo ">>>" $< + $(CC) $(CFLAGS) -c $< -o $@ -D_ASM_MISC_C_AMIPS readme.txt: ../../tools/textfilter ../base_readme.txt ../../tools/textfilter ../base_readme.txt $@ PSP @@ -152,6 +154,5 @@ endif # ? rel: EBOOT.PBP readme.txt - zip -9 -j ../../PicoDrive_$(VER).zip $^ -# zip -9 -r ../../PicoDrive_$(VER).zip skin -i \*.png -i \*.txt + zip -9 -r ../../PicoDrive_$(VER).zip skin -i \*.png -i \*.txt diff --git a/psp/emu.c b/psp/emu.c index b7d6bae..6ce910d 100644 --- a/psp/emu.c +++ b/psp/emu.c @@ -11,6 +11,7 @@ #include "psp.h" #include "menu.h" #include "emu.h" +#include "mp3.h" #include "../common/emu.h" #include "../common/lprintf.h" #include "../../Pico/PicoInt.h" @@ -57,7 +58,7 @@ static void osd_text(int x, const char *text, int is_active, int clear_all) for (h = 0; h < 8; h++) { p = (int *) (screen+x+512*(264+h)); p = (int *) ((int)p & ~3); // align - memset32(p, 0, len); + memset32_uncached(p, 0, len); } if (is_active) { tmp = psp_screen; psp_screen = screen; } // nasty pointer tricks emu_textOut16(x, 264, text); @@ -126,8 +127,8 @@ void emu_setDefaultConfig(void) { memset(¤tConfig, 0, sizeof(currentConfig)); currentConfig.lastRomFile[0] = 0; - currentConfig.EmuOpt = 0x1f | 0x680; // | confirm_save, cd_leds, 16bit rend - currentConfig.PicoOpt = 0x0f | 0xc00; // | cd_pcm, cd_cdda + currentConfig.EmuOpt = 0x1d | 0x680; // | confirm_save, cd_leds, acc rend + currentConfig.PicoOpt = 0x0f | 0x1c00; // | gfx_cd, cd_pcm, cd_cdda currentConfig.PsndRate = 22050; currentConfig.PicoRegion = 0; // auto currentConfig.PicoAutoRgnOrder = 0x184; // US, EU, JP @@ -172,7 +173,7 @@ static int fbimg_offs = 0; static void set_scaling_params(void) { - int src_width, fbimg_width, fbimg_height, fbimg_xoffs, fbimg_yoffs; + int src_width, fbimg_width, fbimg_height, fbimg_xoffs, fbimg_yoffs, border_hack = 0; g_vertices[0].x = g_vertices[0].y = g_vertices[0].z = g_vertices[1].z = 0; @@ -185,9 +186,13 @@ static void set_scaling_params(void) src_width = 256; } + if (fbimg_width & 1) fbimg_width++; // make even + if (fbimg_height & 1) fbimg_height++; + if (fbimg_width >= 480) { g_vertices[0].u = (fbimg_width-480)/2; - g_vertices[1].u = src_width - (fbimg_width-480)/2; + g_vertices[1].u = src_width - (fbimg_width-480)/2 - 1; + if (fbimg_width == 480) border_hack = 1; fbimg_width = 480; fbimg_xoffs = 0; } else { @@ -211,6 +216,12 @@ static void set_scaling_params(void) g_vertices[1].y = fbimg_height; if (fbimg_xoffs < 0) fbimg_xoffs = 0; if (fbimg_yoffs < 0) fbimg_yoffs = 0; + if (border_hack) { + g_vertices[0].u++; + g_vertices[0].x++; + g_vertices[1].u--; + g_vertices[1].x--; + } fbimg_offs = (fbimg_yoffs*512 + fbimg_xoffs) * 2; // dst is always 16bit /* @@ -371,7 +382,7 @@ static void cd_leds(void) *p++ = col_g; *p++ = col_g; p+=2; *p++ = col_r; *p++ = col_r; } - +#if 0 static void dbg_text(void) { int *p, h, len; @@ -382,11 +393,11 @@ static void dbg_text(void) for (h = 0; h < 8; h++) { p = (int *) ((unsigned short *) psp_screen+2+512*(256+h)); p = (int *) ((int)p & ~3); // align - memset32(p, 0, len); + memset32_uncached(p, 0, len); } emu_textOut16(2, 256, text); } - +#endif /* called after rendering is done, but frame emulation is not finished */ void blit1(void) @@ -415,7 +426,7 @@ static void blit2(const char *fps, const char *notice, int lagging_behind) if (emu_opt & 2) osd_text(OSD_FPS_X, fps, 0, 0); } - dbg_text(); + //dbg_text(); if ((emu_opt & 0x400) && (PicoMCD & 1)) cd_leds(); @@ -431,15 +442,15 @@ static void blit2(const char *fps, const char *notice, int lagging_behind) static void clearArea(int full) { if (full) { - memset32(psp_screen, 0, 512*272*2/4); + memset32_uncached(psp_screen, 0, 512*272*2/4); psp_video_flip(0); - memset32(psp_screen, 0, 512*272*2/4); + memset32_uncached(psp_screen, 0, 512*272*2/4); memset32(VRAM_CACHED_STUFF, 0xe0e0e0e0, 512*240/4); memset32((int *)VRAM_CACHED_STUFF+512*240/4, 0, 512*240*2/4); } else { void *fb = psp_video_get_active_fb(); - memset32((int *)((char *)psp_screen + 512*264*2), 0, 512*8*2/4); - memset32((int *)((char *)fb + 512*264*2), 0, 512*8*2/4); + memset32_uncached((int *)((char *)psp_screen + 512*264*2), 0, 512*8*2/4); + memset32_uncached((int *)((char *)fb + 512*264*2), 0, 512*8*2/4); } } @@ -659,7 +670,7 @@ void emu_forcedFrame(void) vidResetMode(); memset32(VRAM_CACHED_STUFF, 0xe0e0e0e0, 512*8/4); // borders memset32((int *)VRAM_CACHED_STUFF + 512*232/4, 0xe0e0e0e0, 512*8/4); - memset32((int *)psp_screen + 512*264*2/4, 0, 512*8*2/4); + memset32_uncached((int *)psp_screen + 512*264*2/4, 0, 512*8*2/4); PicoDrawSetColorFormat(-1); PicoScan = EmuScanSlow; @@ -1036,7 +1047,7 @@ void emu_Loop(void) } // clear fps counters and stuff - memset32((int *)psp_video_get_active_fb() + 512*264*2/4, 0, 512*8*2/4); + memset32_uncached((int *)psp_video_get_active_fb() + 512*264*2/4, 0, 512*8*2/4); } diff --git a/psp/emu.h b/psp/emu.h index d122a20..affd540 100644 --- a/psp/emu.h +++ b/psp/emu.h @@ -28,4 +28,6 @@ void emu_forcedFrame(void); void emu_msg_cb(const char *msg); +// actually comes from Pico/Misc_amips.s +void memset32_uncached(int *dest, int c, int count); diff --git a/psp/menu.c b/psp/menu.c index 86628ca..52381eb 100644 --- a/psp/menu.c +++ b/psp/menu.c @@ -154,7 +154,7 @@ void menu_romload_prepare(const char *rom_name) psp_video_switch_to_single(); if (rom_data) menu_draw_begin(); - else memset32(psp_screen, 0, 512*272*2/4); + else memset32_uncached(psp_screen, 0, 512*272*2/4); smalltext_out16(1, 1, "Loading", 0xffff); smalltext_out16_lim(1, 10, p, 0xffff, 80); @@ -453,8 +453,10 @@ static void draw_debug(void) static void debug_menu_loop(void) { + int ret = 0; draw_debug(); - wait_for_input(BTN_X|BTN_CIRCLE, 0); + while (!(ret & (BTN_X|BTN_CIRCLE))) + ret = wait_for_input(BTN_X|BTN_CIRCLE, 0); } // ------------ patch/gg menu ------------ @@ -1059,7 +1061,7 @@ static void menu_opt3_preview(int is_32col) lprintf("uncompress returned %i\n", ret); } - memset32(psp_screen, 0, 512*272*2/4); + memset32_uncached(psp_screen, 0, 512*272*2/4); emu_forcedFrame(); menu_prepare_bg(1, 0); @@ -1119,6 +1121,7 @@ static void dispmenu_loop_options(void) if (setting != NULL) { while ((inp = psp_pad_read(0)) & (BTN_LEFT|BTN_RIGHT)) { *setting += (inp & BTN_LEFT) ? -0.01 : 0.01; + if (*setting <= 0) *setting = 0.01; menu_opt3_preview(is_32col); draw_dispmenu_options(menu_sel); // will wait vsync } @@ -1735,12 +1738,12 @@ static void menu_prepare_bg(int use_game_bg, int use_fg) int i; for (i = 272; i > 0; i--, dst += 480, src += 512) menu_darken_bg(dst, src, 480, 1); - //memset32((int *)(bg_buffer + 480*264), 0, 480*8*2/4); + //memset32_uncached((int *)(bg_buffer + 480*264), 0, 480*8*2/4); } else { // should really only happen once, on startup.. - memset32((int *)(void *)bg_buffer, 0, sizeof(bg_buffer)/4); + memset32_uncached((int *)(void *)bg_buffer, 0, sizeof(bg_buffer)/4); readpng(bg_buffer, "skin/background.png", READPNG_BG); } sceKernelDcacheWritebackAll(); @@ -1814,7 +1817,7 @@ int menu_loop_tray(void) for (;;) { draw_menu_tray(menu_sel); - inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_X, 0); + inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_CIRCLE, 0); if(inp & BTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } if(inp & BTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } if(inp & BTN_CIRCLE) { diff --git a/psp/mp3.c b/psp/mp3.c index f3abc2f..5a87877 100644 --- a/psp/mp3.c +++ b/psp/mp3.c @@ -181,8 +181,6 @@ int mp3_init(void) goto fail2; } - lprintf("thread_busy_sem: %08x, thread_job_sem: %08x\n", thread_busy_sem, thread_job_sem); - thread_exit = 0; thid = sceKernelCreateThread("mp3decode_thread", decode_thread, 30, 0x2000, 0, 0); /* use slightly higher prio then main */ if (thid < 0) { @@ -273,7 +271,7 @@ static int decode_thread(SceSize args, void *argp) int mp3_get_bitrate(FILE *f, int size) { - int ret = -1, sample_rate, bitrate; + int ret, retval = -1, sample_rate, bitrate; // filenames are stored instead handles in PSP, due to stupid max open file limit char *fname = (char *)f; @@ -307,14 +305,14 @@ int mp3_get_bitrate(FILE *f, int size) } /* looking good.. */ - ret = bitrate; + retval = bitrate; end: if (mp3_handle >= 0) sceIoClose(mp3_handle); mp3_handle = -1; mp3_fname = NULL; psp_sem_unlock(thread_busy_sem); - if (ret < 0) mp3_last_error = -1; // remember we had a problem.. - return ret; + if (retval < 0) mp3_last_error = -1; // remember we had a problem.. + return retval; } diff --git a/psp/mp3.h b/psp/mp3.h new file mode 100644 index 0000000..d95d04b --- /dev/null +++ b/psp/mp3.h @@ -0,0 +1,8 @@ + +// additional stuff for PSP mp3 decoder implementation +extern int mp3_last_error; + +int mp3_init(void); +void mp3_deinit(void); + + diff --git a/psp/psp.c b/psp/psp.c index 05af63d..c8d73ac 100644 --- a/psp/psp.c +++ b/psp/psp.c @@ -10,6 +10,7 @@ #include #include "psp.h" +#include "emu.h" #include "../common/lprintf.h" PSP_MODULE_INFO("PicoDrive", 0, 1, 34); @@ -28,6 +29,19 @@ static int exit_callback(int arg1, int arg2, void *common) return 0; } +/* Power Callback */ +static int power_callback(int unknown, int pwrflags, void *common) +{ + /* check for power switch and suspending as one is manual and the other automatic */ + if (pwrflags & PSP_POWER_CB_POWER_SWITCH || pwrflags & PSP_POWER_CB_SUSPENDING) + { + lprintf("power_callback: flags: 0x%08X: suspending\n", pwrflags); + engineState = PGS_Menu; + } + sceDisplayWaitVblankStart(); + return 0; +} + /* Callback thread */ static int callback_thread(SceSize args, void *argp) { @@ -38,6 +52,8 @@ static int callback_thread(SceSize args, void *argp) cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL); sceKernelRegisterExitCallback(cbid); + cbid = sceKernelCreateCallback("Power Callback", power_callback, NULL); + scePowerRegisterCallback(0, cbid); sceKernelSleepThreadCB(); diff --git a/psp/version.h b/psp/version.h index 93ee956..f2fb563 100644 --- a/psp/version.h +++ b/psp/version.h @@ -1,2 +1,2 @@ -#define VERSION "1.34" +#define VERSION "1.35"