From: notaz Date: Thu, 1 Nov 2007 19:24:13 +0000 (+0000) Subject: psp memhandlers, vsync, stuff X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4b8f4f3c0d614637f1ec6df36330b1ad7a32b498;p=libpicofe.git psp memhandlers, vsync, stuff git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@289 be3aeb3a-fb24-0410-a615-afba39da0efa --- diff --git a/common/emu.h b/common/emu.h index 34c6f01..42a1bfb 100644 --- a/common/emu.h +++ b/common/emu.h @@ -9,6 +9,7 @@ typedef struct { // squidgehack, no_save_cfg_on_exit, , 16_bit_mode // craigix_ram, confirm_save, show_cd_leds, confirm_load // A_SNs_gamma, perfect_vsync, giz_scanlines, giz_dblbuff + // vsync_mode int PicoOpt; // used for config saving only, see Pico.h int PsndRate; // ditto int PicoRegion; // ditto diff --git a/common/menu.h b/common/menu.h index cd7fa44..2635967 100644 --- a/common/menu.h +++ b/common/menu.h @@ -70,6 +70,7 @@ typedef enum MA_OPT3_PRES_NOSCALE, MA_OPT3_PRES_FULLSCR, MA_OPT3_FILTERING, + MA_OPT3_VSYNC, MA_OPT3_DONE, MA_CDOPT_TESTBIOS_USA, MA_CDOPT_TESTBIOS_EUR, diff --git a/gp2x/Makefile b/gp2x/Makefile index 595db53..0e2ffe4 100644 --- a/gp2x/Makefile +++ b/gp2x/Makefile @@ -31,7 +31,7 @@ else use_cyclone = 1 endif -DEFINC = -I../.. -I. -DARM -D__GP2X__ -D_UNZIP_SUPPORT # -DBENCHMARK +DEFINC = -I../.. -I. -DARM -D__GP2X__ # -DBENCHMARK COPT_COMMON = -static -Wall -Winline ifeq ($(DEBUG),) COPT_COMMON += -O2 -ftracer -fstrength-reduce -fomit-frame-pointer -fstrict-aliasing -ffast-math diff --git a/gp2x/menu.c b/gp2x/menu.c index a60e4d8..7dd2e58 100644 --- a/gp2x/menu.c +++ b/gp2x/menu.c @@ -1394,7 +1394,7 @@ static void draw_menu_credits(void) text_out16(tl_x, 20, "PicoDrive v" VERSION " (c) notaz, 2006,2007"); y = tl_y; text_out16(tl_x, y, "Credits:"); - text_out16(tl_x, (y+=10), "Dave: Cyclone 68000 core,"); + text_out16(tl_x, (y+=10), "fDave: Cyclone 68000 core,"); text_out16(tl_x, (y+=10), " base code of PicoDrive"); text_out16(tl_x, (y+=10), "Reesy & FluBBa: DrZ80 core"); text_out16(tl_x, (y+=10), "MAME devs: YM2612 and SN76496 cores"); diff --git a/psp/Makefile b/psp/Makefile index aecad36..49f9f7b 100644 --- a/psp/Makefile +++ b/psp/Makefile @@ -10,7 +10,7 @@ amalgamate = 0 #up = 1 -CFLAGS += -I../.. -I. -D_UNZIP_SUPPORT -DNO_SYNC -D_ASM_DRAW_C_MIPS # -DBENCHMARK +CFLAGS += -I../.. -I. -DNO_SYNC CFLAGS += -Wall -Winline -G0 ifeq ($(DEBUG),) CFLAGS += -O2 -ftracer -fstrength-reduce -ffast-math @@ -37,7 +37,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/Patch.o ../../Pico/Draw_amips.o ../../Pico/Memory_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 \ @@ -82,7 +82,7 @@ LIBS += -lpng -lm -lpspgu -lpsppower -Wl,-Map=PicoDrive.map -lpspaudio TARGET = PicoDrive EXTRA_TARGETS = EBOOT.PBP PSP_EBOOT_TITLE = PICODRIVE -#PSP_EBOOT_ICON = .png +PSP_EBOOT_ICON = data/icon.png #PSP_EBOOT_PIC1 = .png CUSTOM_CLEAN = myclean @@ -103,16 +103,24 @@ AS := psp-as ../../cpu/musashi/m68kops.c : make -C ../../cpu/musashi +../../cpu/fame/famec.o : ../../cpu/fame/famec.c + @echo ">>>" $< + $(CC) $(CFLAGS) -Wno-unused -c $< -o $@ + +../../Pico/Memory.o : ../../Pico/Memory.c + @echo ">>>" $< + $(CC) $(CFLAGS) -c $< -o $@ -D_ASM_MEMORY_C -D_ASM_MEMORY_C_AMIPS + +../../Pico/Draw.o : ../../Pico/Draw.c + @echo ">>>" $< + $(CC) $(CFLAGS) -c $< -o $@ -D_ASM_DRAW_C_MIPS + readme.txt: ../../tools/textfilter ../base_readme.txt ../../tools/textfilter ../base_readme.txt $@ PSP ../../tools/textfilter: ../../tools/textfilter.c make -C ../../tools/ textfilter -../../cpu/fame/famec.o : ../../cpu/fame/famec.c - @echo ">>>" $< - $(CC) $(CFLAGS) -Wno-unused -c $< -o $@ - data/bg32.o: data/bg32.bin bin2o -i $< $@ bgdatac32 diff --git a/psp/emu.c b/psp/emu.c index 0e64f2a..3f645ed 100644 --- a/psp/emu.c +++ b/psp/emu.c @@ -15,7 +15,7 @@ #include "../common/lprintf.h" #include "../../Pico/PicoInt.h" -#define OSD_FPS_X 420 +#define OSD_FPS_X 424 // additional pspaudio imports, credits to crazyc int sceAudio_38553111(unsigned short samples, unsigned short freq, char unknown); // play with conversion? @@ -35,7 +35,7 @@ int reset_timing = 0; // do we need this? static void sound_init(void); static void sound_deinit(void); -static void blit2(const char *fps, const char *notice); +static void blit2(const char *fps, const char *notice, int lagging_behind); static void clearArea(int full); void emu_noticeMsgUpdated(void) @@ -133,7 +133,7 @@ void emu_setDefaultConfig(void) currentConfig.PicoAutoRgnOrder = 0x184; // US, EU, JP currentConfig.Frameskip = -1; // auto currentConfig.volume = 50; - currentConfig.CPUclock = 222; + currentConfig.CPUclock = 333; currentConfig.KeyBinds[ 4] = 1<<0; // SACB RLDU currentConfig.KeyBinds[ 6] = 1<<1; currentConfig.KeyBinds[ 7] = 1<<2; @@ -361,7 +361,7 @@ static void cd_leds(void) p = (unsigned int *)((short *)psp_screen + 512*2+4+2); col_g = (old_reg & 2) ? 0x06000600 : 0; - col_r = (old_reg & 1) ? 0xc000c000 : 0; + col_r = (old_reg & 1) ? 0x00180018 : 0; *p++ = col_g; *p++ = col_g; p+=2; *p++ = col_r; *p++ = col_r; p += 512/2 - 12/2; *p++ = col_g; *p++ = col_g; p+=2; *p++ = col_r; *p++ = col_r; p += 512/2 - 12/2; *p++ = col_g; *p++ = col_g; p+=2; *p++ = col_r; *p++ = col_r; @@ -402,11 +402,9 @@ void blit1(void) } -static void blit2(const char *fps, const char *notice) +static void blit2(const char *fps, const char *notice, int lagging_behind) { - int emu_opt = currentConfig.EmuOpt; - - sceGuSync(0,0); + int vsync = 0, emu_opt = currentConfig.EmuOpt; if (notice || (emu_opt & 2)) { if (notice) osd_text(4, notice, 0); @@ -418,7 +416,11 @@ static void blit2(const char *fps, const char *notice) if ((emu_opt & 0x400) && (PicoMCD & 1)) cd_leds(); - psp_video_flip(0); + if (currentConfig.EmuOpt & 0x2000) { // want vsync + if (!(currentConfig.EmuOpt & 0x10000) || !lagging_behind) vsync = 1; + } + + psp_video_flip(vsync); } // clears whole screen or just the notice area (in all buffers) @@ -666,7 +668,8 @@ static void RunEvents(unsigned int which) (!(which & 0x1000) && (currentConfig.EmuOpt & 0x200))) ) // save { int keys; - blit2("", (which & 0x1000) ? "LOAD STATE? (X=yes, O=no)" : "OVERWRITE SAVE? (X=yes, O=no)"); + sceGuSync(0,0); + blit2("", (which & 0x1000) ? "LOAD STATE? (X=yes, O=no)" : "OVERWRITE SAVE? (X=yes, O=no)", 0); while( !((keys = psp_pad_read(1)) & (BTN_X|BTN_CIRCLE)) ) psp_msleep(50); if (keys & BTN_CIRCLE) do_it = 0; @@ -966,12 +969,14 @@ void emu_Loop(void) PicoFrame(); - blit2(fpsbuff, notice); + sceGuSync(0,0); // check time tval = sceKernelGetSystemTimeLow(); tval_diff = (int)(tval - tval_thissec) << 8; + blit2(fpsbuff, notice, tval_diff > lim_time); + if (currentConfig.Frameskip < 0 && tval_diff - lim_time >= (300000<<8)) // slowdown detection reset_timing = 1; else if (PsndOut != NULL || currentConfig.Frameskip < 0) diff --git a/psp/menu.c b/psp/menu.c index 32c4115..2231d95 100644 --- a/psp/menu.c +++ b/psp/menu.c @@ -962,6 +962,7 @@ menu_entry opt3_entries[] = { NULL, MB_NONE, MA_OPT3_HSCALE32, NULL, 0, 0, 0, 1 }, { NULL, MB_NONE, MA_OPT3_HSCALE40, NULL, 0, 0, 0, 1 }, { NULL, MB_ONOFF, MA_OPT3_FILTERING, ¤tConfig.scaling, 1, 0, 0, 1 }, + { NULL, MB_NONE, MA_OPT3_VSYNC, NULL, 0, 0, 0, 1 }, { "Set to unscaled centered", MB_NONE, MA_OPT3_PRES_NOSCALE, NULL, 0, 0, 0, 1 }, { "Set to fullscreen", MB_NONE, MA_OPT3_PRES_FULLSCR, NULL, 0, 0, 0, 1 }, { "done", MB_NONE, MA_OPT3_DONE, NULL, 0, 0, 0, 1 }, @@ -986,6 +987,13 @@ static void menu_opt3_cust_draw(const menu_entry *entry, int x, int y, void *par case MA_OPT3_FILTERING: text_out16(x, y, "Bilinear filtering %s", currentConfig.scaling?"ON":"OFF"); break; + case MA_OPT3_VSYNC: { + char *val = " never"; + if (currentConfig.EmuOpt & 0x2000) + val = (currentConfig.EmuOpt & 0x10000) ? "sometimes" : " always"; + text_out16(x, y, "Wait for vsync %s", val); + break; + } default: break; } } @@ -1023,11 +1031,11 @@ static void menu_opt3_preview(int is_32col) static void draw_dispmenu_options(int menu_sel) { - int tl_x = 80+25, tl_y = 16+50; + int tl_x = 80, tl_y = 16+50; menu_draw_begin(); - menu_draw_selection(tl_x - 16, tl_y + menu_sel*10, 252); + menu_draw_selection(tl_x - 16, tl_y + menu_sel*10, 316); me_draw(opt3_entries, OPT3_ENTRY_COUNT, tl_x, tl_y, menu_opt3_cust_draw, NULL); @@ -1043,7 +1051,7 @@ static void dispmenu_loop_options(void) menu_sel_max = me_count_enabled(opt3_entries, OPT3_ENTRY_COUNT) - 1; - for(;;) + for (;;) { draw_dispmenu_options(menu_sel); inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_LEFT|BTN_RIGHT|BTN_X|BTN_CIRCLE); @@ -1056,12 +1064,19 @@ static void dispmenu_loop_options(void) if (inp & (BTN_LEFT|BTN_RIGHT)) // multi choise { float *setting = NULL; + int tmp; me_process(opt3_entries, OPT3_ENTRY_COUNT, selected_id, (inp&BTN_RIGHT) ? 1 : 0); switch (selected_id) { case MA_OPT3_SCALE: setting = ¤tConfig.scale; break; case MA_OPT3_HSCALE40: setting = ¤tConfig.hscale40; is_32col = 0; break; case MA_OPT3_HSCALE32: setting = ¤tConfig.hscale32; is_32col = 1; break; case MA_OPT3_FILTERING:menu_opt3_preview(is_32col); break; + case MA_OPT3_VSYNC: tmp = ((currentConfig.EmuOpt>>13)&1) | ((currentConfig.EmuOpt>>15)&2); + tmp = (inp & BTN_LEFT) ? (tmp>>1) : ((tmp<<1)|1); + if (tmp > 3) tmp = 3; + currentConfig.EmuOpt &= ~0x12000; + currentConfig.EmuOpt |= ((tmp&2)<<15) | ((tmp&1)<<13); + break; default: break; } if (setting != NULL) { @@ -1462,12 +1477,15 @@ static void draw_menu_credits(void) y = tl_y; text_out16(tl_x, y, "Credits:"); - text_out16(tl_x, (y+=10), "Dave: base code of PicoDrive"); + text_out16(tl_x, (y+=10), "fDave: base code of PicoDrive"); + text_out16(tl_x, (y+=10), "Chui: Fame/C"); + text_out16(tl_x, (y+=10), "NJ: CZ80"); text_out16(tl_x, (y+=10), "MAME devs: YM2612 and SN76496 cores"); - text_out16(tl_x, (y+=10), "Charles MacDonald: Genesis hw docs"); text_out16(tl_x, (y+=10), "Stephane Dallongeville:"); - text_out16(tl_x, (y+=10), " opensource Gens"); + text_out16(tl_x, (y+=10), " Gens code, base of Fame/C, CZ80"); + text_out16(tl_x, (y+=10), "Charles MacDonald: Genesis hw docs"); text_out16(tl_x, (y+=10), "Haze: Genesis hw info"); + text_out16(tl_x, (y+=10), "ps2dev.org people: PSP SDK/code"); text_out16(tl_x, (y+=10), "ketchupgun: skin design"); menu_draw_end();