From 2b90fc61e0907707c60bb01d97645b6afc22d4ae Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 21 Oct 2007 10:20:56 +0000 Subject: [PATCH] FAME + some random stuff added git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@276 be3aeb3a-fb24-0410-a615-afba39da0efa --- common/lprintf.h | 2 +- linux/Makefile | 12 +++++++++++- psp/Makefile | 21 ++++++++++++++++----- psp/emu.c | 12 ++++++++++++ psp/menu.c | 12 ++++++++++++ psp/port_config.h | 1 + psp/psp.c | 17 ++++++++++++++++- psp/psp.h | 2 ++ 8 files changed, 71 insertions(+), 8 deletions(-) diff --git a/common/lprintf.h b/common/lprintf.h index 1d74323..dc49c65 100644 --- a/common/lprintf.h +++ b/common/lprintf.h @@ -2,7 +2,7 @@ #include #define lprintf printf #elif defined(PSP) - #if 0 + #if 1 #include #define lprintf printf #else diff --git a/linux/Makefile b/linux/Makefile index e3aac31..6aed56e 100644 --- a/linux/Makefile +++ b/linux/Makefile @@ -1,6 +1,7 @@ # settings -dprint = 1 +use_fame = 1 + # profile = 1 @@ -46,8 +47,13 @@ OBJS += ../../zlib/gzio.o ../../zlib/inffast.o ../../zlib/inflate.o ../../zlib/i # unzip OBJS += ../../unzip/unzip.o ../../unzip/unzip_stream.o # CPU cores +ifeq "$(use_fame)" "1" +DEFINC += -DEMU_F68K +OBJS += ../../cpu/fame/famec.o +else DEFINC += -DEMU_M68K OBJS += ../../cpu/musashi/m68kops.o ../../cpu/musashi/m68kcpu.o +endif # mz80 DEFINC += -D_USE_MZ80 OBJS += ../../cpu/mz80/mz80.o @@ -95,3 +101,7 @@ PicoDrive : $(OBJS) ../common/helix/helix_mp3_x86.a @echo $@ @$(GCC) $(COPT_COMMON) $(DEFINC) -c $< -o $@ # -mtune=arm940t -DEXTERNAL_YM2612 +../../cpu/fame/famec.o : ../../cpu/fame/famec.c + @echo $< + @$(GCC) $(COPT) $(DEFINC) -Wno-unused -c $< -o $@ + diff --git a/psp/Makefile b/psp/Makefile index 769f3ed..7a0cada 100644 --- a/psp/Makefile +++ b/psp/Makefile @@ -3,7 +3,7 @@ PSPSDK = $(shell psp-config --pspsdk-path) # settings -use_musashi = 1 +#use_musashi = 1 use_mz80 = 1 amalgamate = 0 #profile = 1 @@ -13,7 +13,7 @@ amalgamate = 0 CFLAGS += -I../.. -I. -D_UNZIP_SUPPORT -DNO_SYNC # -DBENCHMARK CFLAGS += -Wall -Winline ifeq ($(DEBUG),) -CFLAGS += -O2 -G0 -ftracer -fstrength-reduce -fomit-frame-pointer -fstrict-aliasing -ffast-math +CFLAGS += -O2 -G0 -ftracer -fstrength-reduce -ffast-math else CFLAGS += -ggdb endif @@ -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/Patch.o ../../Pico/Draw_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 \ @@ -59,6 +59,9 @@ OBJS += ../../unzip/unzip.o ../../unzip/unzip_stream.o ifeq "$(use_musashi)" "1" CFLAGS += -DEMU_M68K OBJS += ../../cpu/musashi/m68kops.o ../../cpu/musashi/m68kcpu.o +else +CFLAGS += -DEMU_F68K +OBJS += ../../cpu/fame/famec.o endif # z80 ifeq "$(use_mz80)" "1" @@ -69,7 +72,7 @@ $(error nothing here!) endif -LIBS += -lpng -lm -lpspgu # -lpspaudio -lpspgu -lpsppower -lpsphprm -lz -lm -lstdc++ +LIBS += -lpng -lm -lpspgu -lpsppower -Wl,-Map=PicoDrive.map # -lpspaudio -lpsphprm # target TARGET = PicoDrive @@ -82,12 +85,17 @@ CUSTOM_CLEAN = myclean include $(PSPSDK)/lib/build.mak - # some additional rules .c.o: @echo ">>>" $< $(CC) $(CFLAGS) -c $< -o $@ +AS := psp-as + +.s.o: + @echo ">>>" $< + $(AS) -march=allegrex -mtune=allegrex $< -o $@ + ../../cpu/musashi/m68kops.c : make -C ../../cpu/musashi @@ -97,6 +105,9 @@ readme.txt: ../../tools/textfilter ../base_readme.txt ../../tools/textfilter: ../../tools/textfilter.c make -C ../../tools/ textfilter +../../cpu/fame/famec.o : ../../cpu/fame/famec.c + @echo ">>>" $< + $(CC) $(CFLAGS) -Wno-unused -c $< -o $@ # ? up: EBOOT.PBP diff --git a/psp/emu.c b/psp/emu.c index 338ffa4..6c1b050 100644 --- a/psp/emu.c +++ b/psp/emu.c @@ -3,6 +3,7 @@ #include // PATH_MAX #include +#include #include "psp.h" #include "menu.h" @@ -121,6 +122,7 @@ void emu_setDefaultConfig(void) currentConfig.PicoAutoRgnOrder = 0x184; // US, EU, JP currentConfig.Frameskip = -1; // auto currentConfig.volume = 50; + currentConfig.CPUclock = 222; currentConfig.KeyBinds[ 4] = 1<<0; // SACB RLDU currentConfig.KeyBinds[ 6] = 1<<1; currentConfig.KeyBinds[ 7] = 1<<2; @@ -386,6 +388,9 @@ static void updateKeys(void) int i; keys = psp_pad_read(0); + if (keys & PSP_CTRL_HOME) + sceDisplayWaitVblankStart(); + if (keys & BTN_SELECT) engineState = PGS_Menu; @@ -498,6 +503,13 @@ void emu_Loop(void) fpsbuff[0] = 0; + if (currentConfig.CPUclock != psp_get_cpu_clock()) { + lprintf("setting cpu clock to %iMHz... ", currentConfig.CPUclock); + i = psp_set_cpu_clock(currentConfig.CPUclock); + lprintf(i ? "failed\n" : "done\n"); + currentConfig.CPUclock = psp_get_cpu_clock(); + } + // make sure we are in correct mode vidResetMode(); Pico.m.dirtyPal = 1; diff --git a/psp/menu.c b/psp/menu.c index c878f40..b2b3fc5 100644 --- a/psp/menu.c +++ b/psp/menu.c @@ -1032,6 +1032,7 @@ menu_entry opt_entries[] = { "Use SRAM/BRAM savestates", MB_ONOFF, MA_OPT_SRAM_STATES, ¤tConfig.EmuOpt, 0x0001, 0, 0, 1 }, { NULL, MB_NONE, MA_OPT_CONFIRM_STATES,NULL, 0, 0, 0, 1 }, { "Save slot", MB_RANGE, MA_OPT_SAVE_SLOT, &state_slot, 0, 0, 9, 1 }, + { NULL, MB_NONE, MA_OPT_CPU_CLOCKS, NULL, 0, 0, 0, 1 }, { "[Sega/Mega CD options]", MB_NONE, MA_OPT_SCD_OPTS, NULL, 0, 0, 0, 1 }, { "[advanced options]", MB_NONE, MA_OPT_ADV_OPTS, NULL, 0, 0, 0, 1 }, { NULL, MB_NONE, MA_OPT_SAVECFG, NULL, 0, 0, 0, 1 }, @@ -1102,6 +1103,9 @@ static void menu_opt_cust_draw(const menu_entry *entry, int x, int y, void *para } text_out16(x, y, "Confirm savestate %s", str); break; + case MA_OPT_CPU_CLOCKS: + text_out16(x, y, "CPU/bus clock %3i/%3iMHz", currentConfig.CPUclock, currentConfig.CPUclock/2); + break; case MA_OPT_SAVECFG: str24[0] = 0; if (config_slot != 0) sprintf(str24, " (profile: %i)", config_slot); @@ -1250,6 +1254,14 @@ static int menu_loop_options(void) } else {state_slot--; if (state_slot < 0) state_slot = 9; } break; + case MA_OPT_CPU_CLOCKS: + while ((inp = psp_pad_read(0)) & (BTN_LEFT|BTN_RIGHT)) { + currentConfig.CPUclock += (inp & BTN_LEFT) ? -1 : 1; + if (currentConfig.CPUclock < 19) currentConfig.CPUclock = 19; + if (currentConfig.CPUclock > 333) currentConfig.CPUclock = 333; + draw_menu_options(menu_sel); // will wait vsync + } + break; case MA_OPT_SAVECFG: case MA_OPT_SAVECFG_GAME: case MA_OPT_LOADCFG: diff --git a/psp/port_config.h b/psp/port_config.h index dcd5032..fe56132 100644 --- a/psp/port_config.h +++ b/psp/port_config.h @@ -6,6 +6,7 @@ #define CPU_CALL // draw.c +#define USE_BGR555 1 #define OVERRIDE_HIGHCOL 0 // draw2.c diff --git a/psp/psp.c b/psp/psp.c index 48e5e63..e740f21 100644 --- a/psp/psp.c +++ b/psp/psp.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include "psp.h" @@ -76,7 +77,8 @@ void psp_finish(void) void psp_video_flip(int wait_vsync) { if (wait_vsync) sceDisplayWaitVblankStart(); - sceDisplaySetFrameBuf(psp_screen, 512, PSP_DISPLAY_PIXEL_FORMAT_565, PSP_DISPLAY_SETBUF_NEXTFRAME); + sceDisplaySetFrameBuf(psp_screen, 512, PSP_DISPLAY_PIXEL_FORMAT_565, + wait_vsync ? PSP_DISPLAY_SETBUF_IMMEDIATE : PSP_DISPLAY_SETBUF_NEXTFRAME); current_screen ^= 1; psp_screen = current_screen ? PSP_VRAM_BASE0 : PSP_VRAM_BASE1; } @@ -108,6 +110,19 @@ unsigned int psp_pad_read(int blocking) return pad.Buttons; } +int psp_get_cpu_clock(void) +{ + return scePowerGetCpuClockFrequencyInt(); +} + +int psp_set_cpu_clock(int clock) +{ + int ret = scePowerSetClockFrequency(clock, clock, clock/2); + if (ret != 0) lprintf("failed to set clock: %i\n", ret); + + return ret; +} + /* alt logging */ #define LOG_FILE "log.log" diff --git a/psp/psp.h b/psp/psp.h index e6d04ff..07d4093 100644 --- a/psp/psp.h +++ b/psp/psp.h @@ -15,6 +15,8 @@ extern void *psp_screen; unsigned int psp_pad_read(int blocking); +int psp_get_cpu_clock(void); +int psp_set_cpu_clock(int clock); /* shorter btn names */ #define BTN_UP PSP_CTRL_UP -- 2.39.2