From 7a938d57b1dd2ff4170d801a5a70191a6e003717 Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 29 Jun 2008 22:00:19 +0000 Subject: [PATCH 01/16] menu text adjustment git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@506 be3aeb3a-fb24-0410-a615-afba39da0efa --- gp2x/menu.c | 2 +- psp/menu.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gp2x/menu.c b/gp2x/menu.c index 8ec98aa..f55b838 100644 --- a/gp2x/menu.c +++ b/gp2x/menu.c @@ -1446,7 +1446,7 @@ static void draw_menu_credits(void) text_out16(tl_x, (y+=10), "craigix: GP2X hardware"); text_out16(tl_x, (y+=10), "ketchupgun: skin design"); - text_out16(tl_x, (y+=20), "special thanks (for code, docs, ideas)"); + text_out16(tl_x, (y+=20), "special thanks (for docs, ideas):"); text_out16(tl_x, (y+=10), " Charles MacDonald, Haze,"); text_out16(tl_x, (y+=10), " Stephane Dallongeville,"); text_out16(tl_x, (y+=10), " Lordus, Exophase, Rokas,"); diff --git a/psp/menu.c b/psp/menu.c index 44c7c66..89ba742 100644 --- a/psp/menu.c +++ b/psp/menu.c @@ -1515,7 +1515,7 @@ static void draw_menu_credits(void) text_out16(tl_x, (y+=10), "ps2dev.org people: PSP SDK/code"); text_out16(tl_x, (y+=10), "ketchupgun: skin design"); - text_out16(tl_x, (y+=20), "special thanks (for code, docs, ideas):"); + text_out16(tl_x, (y+=20), "special thanks (for docs, ideas):"); text_out16(tl_x, (y+=10), " Charles MacDonald, Haze,"); text_out16(tl_x, (y+=10), " Stephane Dallongeville,"); text_out16(tl_x, (y+=10), " Lordus, Exophase, Rokas,"); -- 2.39.2 From a479005630268d6f2adfcc0f9562593f643c4c2c Mon Sep 17 00:00:00 2001 From: notaz Date: Tue, 1 Jul 2008 14:32:09 +0000 Subject: [PATCH 02/16] nonacc mode removal, function return value audit git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@510 be3aeb3a-fb24-0410-a615-afba39da0efa --- common/emu.c | 2 +- gp2x/menu.c | 1 - psp/menu.c | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/common/emu.c b/common/emu.c index fabd521..1d57e22 100644 --- a/common/emu.c +++ b/common/emu.c @@ -450,7 +450,7 @@ int emu_ReloadRom(void) if(movie_data[0x14] == '6') PicoOpt |= POPT_6BTN_PAD; // 6 button pad else PicoOpt &= ~POPT_6BTN_PAD; - PicoOpt |= POPT_DIS_VDP_FIFO|POPT_ACC_TIMING; // accurate timing, no VDP fifo timing + PicoOpt |= POPT_DIS_VDP_FIFO; // no VDP fifo timing if(movie_data[0xF] >= 'A') { if(movie_data[0x16] & 0x80) { PicoRegionOverride = 8; diff --git a/gp2x/menu.c b/gp2x/menu.c index f55b838..c428a60 100644 --- a/gp2x/menu.c +++ b/gp2x/menu.c @@ -1150,7 +1150,6 @@ menu_entry opt_entries[] = { { NULL, MB_NONE, MA_OPT_RENDERER, NULL, 0, 0, 0, 1, 1 }, { NULL, MB_RANGE, MA_OPT_SCALING, ¤tConfig.scaling, 0, 0, 3, 1, 1 }, - { "Accurate timing (slower)", MB_ONOFF, MA_OPT_ACC_TIMING, &PicoOpt, 0x040, 0, 0, 1, 1 }, { "Accurate sprites (slower)", MB_ONOFF, MA_OPT_ACC_SPRITES, &PicoOpt, 0x080, 0, 0, 1, 1 }, { "Show FPS", MB_ONOFF, MA_OPT_SHOW_FPS, ¤tConfig.EmuOpt, 0x002, 0, 0, 1, 1 }, { NULL, MB_RANGE, MA_OPT_FRAMESKIP, ¤tConfig.Frameskip, 0, -1, 16, 1, 1 }, diff --git a/psp/menu.c b/psp/menu.c index 89ba742..1c1b5df 100644 --- a/psp/menu.c +++ b/psp/menu.c @@ -1235,7 +1235,6 @@ static void amenu_loop_options(void) menu_entry opt_entries[] = { { NULL, MB_NONE, MA_OPT_RENDERER, NULL, 0, 0, 0, 1, 1 }, - { "Accurate timing (slower)", MB_ONOFF, MA_OPT_ACC_TIMING, &PicoOpt, 0x0040, 0, 0, 1, 1 }, { "Accurate sprites (slower)", MB_ONOFF, MA_OPT_ACC_SPRITES, &PicoOpt, 0x0080, 0, 0, 1, 1 }, { "Show FPS", MB_ONOFF, MA_OPT_SHOW_FPS, ¤tConfig.EmuOpt, 0x0002, 0, 0, 1, 1 }, { NULL, MB_RANGE, MA_OPT_FRAMESKIP, ¤tConfig.Frameskip, 0, -1, 16, 1, 1 }, -- 2.39.2 From 4306047f67cf2cf80511939ef4329374f0c5234d Mon Sep 17 00:00:00 2001 From: notaz Date: Thu, 3 Jul 2008 21:25:28 +0000 Subject: [PATCH 03/16] sprite acching removed in asm too git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@518 be3aeb3a-fb24-0410-a615-afba39da0efa --- gp2x/Makefile | 2 +- linux/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gp2x/Makefile b/gp2x/Makefile index 1066a85..d9beac8 100644 --- a/gp2x/Makefile +++ b/gp2x/Makefile @@ -203,7 +203,7 @@ up: PicoDrive.gpe ../../cpu/musashi/m68kops.c : @make -C ../../cpu/musashi -../../Pico/Pico.o : ../../Pico/PicoFrameHints.c ../../Pico/PicoInt.h +../../Pico/Pico.o ../../Pico/cd/Pico.o: ../../Pico/PicoFrameHints.c ../../Pico/PicoInt.h ../../Pico/Memory.o Pico/cd/Memory.o : ../../Pico/MemoryCmn.c ../../Pico/PicoInt.h # build helix libs diff --git a/linux/Makefile b/linux/Makefile index cafe81e..68f73a1 100644 --- a/linux/Makefile +++ b/linux/Makefile @@ -99,7 +99,7 @@ mkdirs: mkdir -p $(DIRS) Pico/carthw/svp/compiler.o : ../../Pico/carthw/svp/gen_arm.c -Pico/Pico.o : ../../Pico/PicoFrameHints.c ../../Pico/PicoInt.h +Pico/Pico.o Pico/cd/Pico.o : ../../Pico/PicoFrameHints.c ../../Pico/PicoInt.h Pico/Memory.o Pico/cd/Memory.o : ../../Pico/MemoryCmn.c ../../Pico/PicoInt.h ../../cpu/musashi/m68kops.c : -- 2.39.2 From 2707a9cbaae3230f65eb3d7c14c8820040165686 Mon Sep 17 00:00:00 2001 From: notaz Date: Fri, 4 Jul 2008 15:06:09 +0000 Subject: [PATCH 04/16] new code to collect/use more stats, some debug tools git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@520 be3aeb3a-fb24-0410-a615-afba39da0efa --- gp2x/menu.c | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/gp2x/menu.c b/gp2x/menu.c index c428a60..b7c926f 100644 --- a/gp2x/menu.c +++ b/gp2x/menu.c @@ -432,8 +432,10 @@ rescan: // ------------ debug menu ------------ char *debugString(void); +void PicoDrawShowSpriteStats(unsigned short *screen); +void PicoDrawShowPalette(unsigned short *screen); -static void draw_debug(void) +static void draw_main_debug(void) { char *p, *str = debugString(); int len, line; @@ -450,13 +452,47 @@ static void draw_debug(void) if (*p == 0) break; p++; str = p; } - menu_flip(); +} + +static void draw_frame_debug(void) +{ + char layer_str[48] = "layers: "; + if (PicoDrawMask & PDRAW_LAYERB_ON) memcpy(layer_str + 8, "B", 1); + if (PicoDrawMask & PDRAW_LAYERA_ON) memcpy(layer_str + 10, "A", 1); + if (PicoDrawMask & PDRAW_SPRITES_LOW_ON) memcpy(layer_str + 12, "spr_lo", 6); + if (PicoDrawMask & PDRAW_SPRITES_HI_ON) memcpy(layer_str + 19, "spr_hi", 6); + + memset(gp2x_screen, 0, 320*240*2); + emu_forcedFrame(); + smalltext_out16(4, 232, layer_str, 0xffff); } static void debug_menu_loop(void) { - draw_debug(); - wait_for_input(GP2X_B|GP2X_X); + int inp, mode = 0; + + while (1) + { + switch (mode) + { + case 0: draw_main_debug(); break; + case 1: draw_frame_debug(); break; + case 2: PicoDrawShowSpriteStats(gp2x_screen); break; + case 3: PicoDrawShowPalette(gp2x_screen); break; + } + menu_flip(); + + inp = wait_for_input(GP2X_B|GP2X_X|GP2X_L|GP2X_R|GP2X_UP|GP2X_DOWN|GP2X_LEFT|GP2X_RIGHT); + if (inp & (GP2X_B|GP2X_X)) return; + if (inp & GP2X_L) { mode--; if (mode < 0) mode = 3; } + if (inp & GP2X_R) { mode++; if (mode > 3) mode = 0; } + if (mode == 1) { + if (inp & GP2X_LEFT) PicoDrawMask ^= PDRAW_LAYERB_ON; + if (inp & GP2X_RIGHT) PicoDrawMask ^= PDRAW_LAYERA_ON; + if (inp & GP2X_DOWN) PicoDrawMask ^= PDRAW_SPRITES_LOW_ON; + if (inp & GP2X_UP) PicoDrawMask ^= PDRAW_SPRITES_HI_ON; + } + } } // ------------ patch/gg menu ------------ -- 2.39.2 From 84e21f25e41b90d9729088dba5991a84330964ea Mon Sep 17 00:00:00 2001 From: notaz Date: Fri, 4 Jul 2008 22:20:48 +0000 Subject: [PATCH 05/16] bugfix, sprites adjustment git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@521 be3aeb3a-fb24-0410-a615-afba39da0efa --- common/emu.h | 1 + gp2x/emu.c | 10 +++++----- gp2x/emu.h | 1 - gp2x/menu.c | 4 ++-- psp/emu.c | 6 +++--- psp/emu.h | 1 - 6 files changed, 11 insertions(+), 12 deletions(-) diff --git a/common/emu.h b/common/emu.h index d118e5b..922633a 100644 --- a/common/emu.h +++ b/common/emu.h @@ -52,6 +52,7 @@ void emu_textOut8 (int x, int y, const char *text); void emu_textOut16(int x, int y, const char *text); char *emu_makeRomId(void); void emu_findKeyBindCombos(void); +void emu_forcedFrame(int opts); extern const char * const keyNames[]; void emu_prepareDefaultConfig(void); diff --git a/gp2x/emu.c b/gp2x/emu.c index 5f4a0e2..92a1831 100644 --- a/gp2x/emu.c +++ b/gp2x/emu.c @@ -141,7 +141,7 @@ void emu_prepareDefaultConfig(void) { memset(&defaultConfig, 0, sizeof(defaultConfig)); defaultConfig.EmuOpt = 0x1d | 0x00700; // | <- ram_tmng, confirm_save, cd_leds - defaultConfig.s_PicoOpt = 0x0f | 0x20e00; // | <- use_940, cd_pcm, cd_cdda, svp drc + defaultConfig.s_PicoOpt = 0x0f | POPT_EXT_FM|POPT_EN_MCD_PCM|POPT_EN_MCD_CDDA|POPT_EN_SVP_DRC|POPT_ACC_SPRITES; defaultConfig.s_PsndRate = 44100; defaultConfig.s_PicoRegion = 0; // auto defaultConfig.s_PicoAutoRgnOrder = 0x184; // US, EU, JP @@ -701,13 +701,13 @@ static void SkipFrame(int do_audio) } -void emu_forcedFrame(void) +void emu_forcedFrame(int opts) { int po_old = PicoOpt; int eo_old = currentConfig.EmuOpt; - PicoOpt &= ~0x0010; - PicoOpt |= 0x4080; // soft_scale | acc_sprites + PicoOpt &= ~0x10; + PicoOpt |= opts|POPT_ACC_SPRITES; // acc_sprites currentConfig.EmuOpt |= 0x80; //vidResetMode(); @@ -1057,7 +1057,7 @@ void emu_Loop(void) // if in 8bit mode, generate 16bit image for menu background if ((PicoOpt&0x10) || !(currentConfig.EmuOpt&0x80)) - emu_forcedFrame(); + emu_forcedFrame(POPT_EN_SOFTSCALE); } diff --git a/gp2x/emu.h b/gp2x/emu.h index 8eddd1f..88947b5 100644 --- a/gp2x/emu.h +++ b/gp2x/emu.h @@ -24,7 +24,6 @@ void emu_Init(void); void emu_Deinit(void); void emu_Loop(void); void emu_ResetGame(void); -void emu_forcedFrame(void); void osd_text(int x, int y, const char *text); diff --git a/gp2x/menu.c b/gp2x/menu.c index b7c926f..76eb73e 100644 --- a/gp2x/menu.c +++ b/gp2x/menu.c @@ -463,7 +463,7 @@ static void draw_frame_debug(void) if (PicoDrawMask & PDRAW_SPRITES_HI_ON) memcpy(layer_str + 19, "spr_hi", 6); memset(gp2x_screen, 0, 320*240*2); - emu_forcedFrame(); + emu_forcedFrame(0); smalltext_out16(4, 232, layer_str, 0xffff); } @@ -605,7 +605,7 @@ static void draw_savestate_bg(int slot) areaClose(file); } - emu_forcedFrame(); + emu_forcedFrame(POPT_EN_SOFTSCALE); menu_prepare_bg(1); memcpy(Pico.vram, tmp_vram, sizeof(Pico.vram)); diff --git a/psp/emu.c b/psp/emu.c index 4857371..09b5d46 100644 --- a/psp/emu.c +++ b/psp/emu.c @@ -687,13 +687,13 @@ static void SkipFrame(void) PicoSkipFrame=0; } -void emu_forcedFrame(void) +void emu_forcedFrame(int opts) { int po_old = PicoOpt; int eo_old = currentConfig.EmuOpt; - PicoOpt &= ~0x0010; - PicoOpt |= 0x4080; // soft_scale | acc_sprites + PicoOpt &= ~0x10; + PicoOpt |= opts|POPT_ACC_SPRITES currentConfig.EmuOpt |= 0x80; vidResetMode(); diff --git a/psp/emu.h b/psp/emu.h index 17b20e7..61e4e7a 100644 --- a/psp/emu.h +++ b/psp/emu.h @@ -25,7 +25,6 @@ void emu_Init(void); void emu_Deinit(void); void emu_Loop(void); void emu_ResetGame(void); -void emu_forcedFrame(void); void emu_HandleResume(void); void emu_msg_cb(const char *msg); -- 2.39.2 From 100ae778a0d55d2a07307c52ced8e222044d30dd Mon Sep 17 00:00:00 2001 From: notaz Date: Sat, 5 Jul 2008 16:02:15 +0000 Subject: [PATCH 06/16] default cfg changed git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@523 be3aeb3a-fb24-0410-a615-afba39da0efa --- game_def.cfg | 28 ---------------------------- gp2x/emu.c | 2 +- gp2x/menu.c | 2 +- 3 files changed, 2 insertions(+), 30 deletions(-) diff --git a/game_def.cfg b/game_def.cfg index 7d8adbf..50f32c7 100644 --- a/game_def.cfg +++ b/game_def.cfg @@ -131,15 +131,6 @@ Renderer = 16bit accurate [MD|GM MK-1569 -00|4|COMIX ZONE] Renderer = 16bit accurate -[MD|GM T-70246 -00|E|DUNE - THE BATTLE FOR ARRAKIS] -Accurate timing (slower) = 1 - -[MD|GM T-50256 -00|U|FATAL REWIND] -Accurate timing (slower) = 1 - -[MD|GM T-50256 -00|U|THE KILLING GAME SHOW] -Accurate timing (slower) = 1 - [MD|GM T-097116 00|4|MORTAL KOMBAT 3] Renderer = 16bit accurate @@ -151,47 +142,28 @@ Renderer = 16bit accurate [MD|GM T-48376 00|JUE|RED-ZONE] Renderer = 16bit accurate -Accurate timing (slower) = 1 [MD|GM T-177016-00|F|STREET RACER] Renderer = 16bit accurate -Accurate timing (slower) = 1 - -[MD|GM MK-1551 -00|E|SUB-TERRANIA] -Accurate timing (slower) = 1 - -[MD|GM MK-1551 -00|J|SUB-TERRANIA] -Accurate timing (slower) = 1 - -[MD|GM MK-1551 -00|U|SUB-TERRANIA] -Accurate timing (slower) = 1 [MD|GM T-95043-00|J|] Renderer = 16bit accurate [MD|GM T-25036 -00|U| SHOVE IT!] Renderer = 16bit accurate -Accurate timing (slower) = 1 [MD|GM MK-1104 -00|U|AFTER BURNERII] Renderer = 16bit accurate [MD|GM T-32053 -00|U|ARCUS ODYSSEY] Renderer = 16bit accurate -Accurate timing (slower) = 1 [MD|GM 00054010-00|JUE|RAMBO \87V] Renderer = 16bit accurate -Accurate timing (slower) = 1 [MD|GM 00054010-01|JUE|RAMBO \87V] Renderer = 16bit accurate -Accurate timing (slower) = 1 - -[MD|MK-1136-50|E|Shinobi3 Return of the Ninja Master] -Accurate timing (slower) = 1 [MD|GM T-50406 -01|U|GALAHAD] Renderer = 16bit accurate -Accurate timing (slower) = 1 diff --git a/gp2x/emu.c b/gp2x/emu.c index 92a1831..14080a5 100644 --- a/gp2x/emu.c +++ b/gp2x/emu.c @@ -140,7 +140,7 @@ void emu_Deinit(void) void emu_prepareDefaultConfig(void) { memset(&defaultConfig, 0, sizeof(defaultConfig)); - defaultConfig.EmuOpt = 0x1d | 0x00700; // | <- ram_tmng, confirm_save, cd_leds + defaultConfig.EmuOpt = 0x9d | 0x00700; // | <- ram_tmng, confirm_save, cd_leds defaultConfig.s_PicoOpt = 0x0f | POPT_EXT_FM|POPT_EN_MCD_PCM|POPT_EN_MCD_CDDA|POPT_EN_SVP_DRC|POPT_ACC_SPRITES; defaultConfig.s_PsndRate = 44100; defaultConfig.s_PicoRegion = 0; // auto diff --git a/gp2x/menu.c b/gp2x/menu.c index 76eb73e..a0b913a 100644 --- a/gp2x/menu.c +++ b/gp2x/menu.c @@ -1186,7 +1186,7 @@ menu_entry opt_entries[] = { { NULL, MB_NONE, MA_OPT_RENDERER, NULL, 0, 0, 0, 1, 1 }, { NULL, MB_RANGE, MA_OPT_SCALING, ¤tConfig.scaling, 0, 0, 3, 1, 1 }, - { "Accurate sprites (slower)", MB_ONOFF, MA_OPT_ACC_SPRITES, &PicoOpt, 0x080, 0, 0, 1, 1 }, + { "Accurate sprites (slower)", MB_ONOFF, MA_OPT_ACC_SPRITES, &PicoOpt, 0x080, 0, 0, 0, 1 }, { "Show FPS", MB_ONOFF, MA_OPT_SHOW_FPS, ¤tConfig.EmuOpt, 0x002, 0, 0, 1, 1 }, { NULL, MB_RANGE, MA_OPT_FRAMESKIP, ¤tConfig.Frameskip, 0, -1, 16, 1, 1 }, { "Enable sound", MB_ONOFF, MA_OPT_ENABLE_SOUND, ¤tConfig.EmuOpt, 0x004, 0, 0, 1, 1 }, -- 2.39.2 From 8a091e48251d061ad06ffd12dfe205cbb42c78df Mon Sep 17 00:00:00 2001 From: notaz Date: Sat, 5 Jul 2008 23:10:24 +0000 Subject: [PATCH 07/16] FAMEC idle loops, PSP port sync, minor adjustments git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@525 be3aeb3a-fb24-0410-a615-afba39da0efa --- common/emu.c | 58 +++++++++++++++++++++++++++++++++++ common/emu.h | 3 ++ gp2x/emu.c | 66 +++++++--------------------------------- gp2x/menu.c | 12 +++++--- linux/port_config.h | 2 +- psp/Makefile | 2 ++ psp/emu.c | 68 ++++++++++++++++++++++++++++++++++++----- psp/main.c | 1 + psp/menu.c | 74 ++++++++++++++++++++++++++++++++++----------- psp/port_config.h | 2 +- 10 files changed, 201 insertions(+), 87 deletions(-) diff --git a/common/emu.c b/common/emu.c index 1d57e22..44e15a6 100644 --- a/common/emu.c +++ b/common/emu.c @@ -43,6 +43,7 @@ int state_slot = 0; int config_slot = 0, config_slot_current = 0; char lastRomFile[512]; int kb_combo_keys = 0, kb_combo_acts = 0; // keys and actions which need button combos +int pico_inp_mode = 0; unsigned char *movie_data = NULL; static int movie_size = 0; @@ -971,3 +972,60 @@ int emu_SaveLoadGame(int load, int sram) } } +void emu_changeFastForward(int set_on) +{ + static void *set_PsndOut = NULL; + static int set_Frameskip, set_EmuOpt, is_on = 0; + + if (set_on && !is_on) { + set_PsndOut = PsndOut; + set_Frameskip = currentConfig.Frameskip; + set_EmuOpt = currentConfig.EmuOpt; + PsndOut = NULL; + currentConfig.Frameskip = 8; + currentConfig.EmuOpt &= ~4; + currentConfig.EmuOpt |= 0x40000; + is_on = 1; + strcpy(noticeMsg, "FAST FORWARD "); + emu_noticeMsgUpdated(); + } + else if (!set_on && is_on) { + PsndOut = set_PsndOut; + currentConfig.Frameskip = set_Frameskip; + currentConfig.EmuOpt = set_EmuOpt; + PsndRerate(1); + is_on = 0; + } +} + +void emu_RunEventsPico(unsigned int events) +{ + if (events & (1 << 3)) { + pico_inp_mode++; + if (pico_inp_mode > 2) pico_inp_mode = 0; + switch (pico_inp_mode) { + case 2: strcpy(noticeMsg, "Input: Pen on Pad "); break; + case 1: strcpy(noticeMsg, "Input: Pen on Storyware"); break; + case 0: strcpy(noticeMsg, "Input: Joytick "); + PicoPicohw.pen_pos[0] = PicoPicohw.pen_pos[1] = 0x8000; + break; + } + emu_noticeMsgUpdated(); + } + if (events & (1 << 4)) { + PicoPicohw.page--; + if (PicoPicohw.page < 0) PicoPicohw.page = 0; + sprintf(noticeMsg, "Page %i ", PicoPicohw.page); + emu_noticeMsgUpdated(); + } + if (events & (1 << 5)) { + PicoPicohw.page++; + if (PicoPicohw.page > 6) PicoPicohw.page = 6; + sprintf(noticeMsg, "Page %i ", PicoPicohw.page); + emu_noticeMsgUpdated(); + } +} + + + + diff --git a/common/emu.h b/common/emu.h index 922633a..ac75dd0 100644 --- a/common/emu.h +++ b/common/emu.h @@ -36,6 +36,7 @@ extern int config_slot, config_slot_current; extern unsigned char *movie_data; extern char lastRomFile[512]; extern int kb_combo_keys, kb_combo_acts; // keys and actions which need button combos +extern int pico_inp_mode; int emu_ReloadRom(void); @@ -53,6 +54,8 @@ void emu_textOut16(int x, int y, const char *text); char *emu_makeRomId(void); void emu_findKeyBindCombos(void); void emu_forcedFrame(int opts); +void emu_changeFastForward(int set_on); +void emu_RunEventsPico(unsigned int events); extern const char * const keyNames[]; void emu_prepareDefaultConfig(void); diff --git a/gp2x/emu.c b/gp2x/emu.c index 14080a5..19f3c67 100644 --- a/gp2x/emu.c +++ b/gp2x/emu.c @@ -55,7 +55,7 @@ int reset_timing = 0; #define PICO_PEN_ADJUST_X 4 #define PICO_PEN_ADJUST_Y 2 -static int pico_pen_x = 320/2, pico_pen_y = 240/2, pico_inp_mode = 0; +static int pico_pen_x = 320/2, pico_pen_y = 240/2; static void emu_msg_cb(const char *msg); static void emu_msg_tray_open(void); @@ -436,31 +436,10 @@ static void emu_msg_tray_open(void) static void RunEventsPico(unsigned int events, unsigned int gp2x_keys) { - if (events & (1 << 3)) { - pico_inp_mode++; - if (pico_inp_mode > 2) pico_inp_mode = 0; - switch (pico_inp_mode) { - case 2: strcpy(noticeMsg, "Input: Pen on Pad "); break; - case 1: strcpy(noticeMsg, "Input: Pen on Storyware"); break; - case 0: strcpy(noticeMsg, "Input: Joytick "); - PicoPicohw.pen_pos[0] = PicoPicohw.pen_pos[1] = 0x8000; - break; - } - gettimeofday(¬iceMsgTime, 0); - } - if (events & (1 << 4)) { - PicoPicohw.page--; - if (PicoPicohw.page < 0) PicoPicohw.page = 0; - sprintf(noticeMsg, "Page %i ", PicoPicohw.page); - gettimeofday(¬iceMsgTime, 0); - } - if (events & (1 << 5)) { - PicoPicohw.page++; - if (PicoPicohw.page > 6) PicoPicohw.page = 6; - sprintf(noticeMsg, "Page %i ", PicoPicohw.page); - gettimeofday(¬iceMsgTime, 0); - } - if (pico_inp_mode != 0) { + emu_RunEventsPico(events); + + if (pico_inp_mode != 0) + { PicoPad[0] &= ~0x0f; // release UDLR if (gp2x_keys & GP2X_UP) { pico_pen_y--; if (pico_pen_y < 0) pico_pen_y = 0; } if (gp2x_keys & GP2X_DOWN) { pico_pen_y++; if (pico_pen_y > 239-PICO_PEN_ADJUST_Y) pico_pen_y = 239-PICO_PEN_ADJUST_Y; } @@ -512,31 +491,6 @@ static void update_volume(int has_changed, int is_up) } } -static void change_fast_forward(int set_on) -{ - static void *set_PsndOut = NULL; - static int set_Frameskip, set_EmuOpt, is_on = 0; - - if (set_on && !is_on) { - set_PsndOut = PsndOut; - set_Frameskip = currentConfig.Frameskip; - set_EmuOpt = currentConfig.EmuOpt; - PsndOut = NULL; - currentConfig.Frameskip = 8; - currentConfig.EmuOpt &= ~4; - is_on = 1; - } - else if (!set_on && is_on) { - PsndOut = set_PsndOut; - currentConfig.Frameskip = set_Frameskip; - currentConfig.EmuOpt = set_EmuOpt; - PsndRerate(1); - update_volume(0, 0); - reset_timing = 1; - is_on = 0; - } -} - static void RunEvents(unsigned int which) { if (which & 0x1800) // save or load (but not both) @@ -668,14 +622,16 @@ static void updateKeys(void) if (events & 0x6000) update_volume(1, events & 0x2000); - if ((events ^ prevEvents) & 0x40) - change_fast_forward(events & 0x40); + if ((events ^ prevEvents) & 0x40) { + emu_changeFastForward(events & 0x40); + update_volume(0, 0); + reset_timing = 1; + } events &= ~prevEvents; if (PicoAHW == PAHW_PICO) RunEventsPico(events, keys); - if (events) RunEvents(events); if (movie_data) emu_updateMovie(); @@ -1044,7 +1000,7 @@ void emu_Loop(void) frames_done++; frames_shown++; } - change_fast_forward(0); + emu_changeFastForward(0); if (PicoAHW & PAHW_MCD) PicoCDBufferFree(); diff --git a/gp2x/menu.c b/gp2x/menu.c index a0b913a..a9b0825 100644 --- a/gp2x/menu.c +++ b/gp2x/menu.c @@ -432,8 +432,8 @@ rescan: // ------------ debug menu ------------ char *debugString(void); -void PicoDrawShowSpriteStats(unsigned short *screen); -void PicoDrawShowPalette(unsigned short *screen); +void PicoDrawShowSpriteStats(unsigned short *screen, int stride); +void PicoDrawShowPalette(unsigned short *screen, int stride); static void draw_main_debug(void) { @@ -477,8 +477,10 @@ static void debug_menu_loop(void) { case 0: draw_main_debug(); break; case 1: draw_frame_debug(); break; - case 2: PicoDrawShowSpriteStats(gp2x_screen); break; - case 3: PicoDrawShowPalette(gp2x_screen); break; + case 2: gp2x_pd_clone_buffer2(); + PicoDrawShowSpriteStats(gp2x_screen, 320); break; + case 3: memset(gp2x_screen, 0, 320*240*2); + PicoDrawShowPalette(gp2x_screen, 320); break; } menu_flip(); @@ -1186,7 +1188,7 @@ menu_entry opt_entries[] = { { NULL, MB_NONE, MA_OPT_RENDERER, NULL, 0, 0, 0, 1, 1 }, { NULL, MB_RANGE, MA_OPT_SCALING, ¤tConfig.scaling, 0, 0, 3, 1, 1 }, - { "Accurate sprites (slower)", MB_ONOFF, MA_OPT_ACC_SPRITES, &PicoOpt, 0x080, 0, 0, 0, 1 }, + { "Accurate sprites", MB_ONOFF, MA_OPT_ACC_SPRITES, &PicoOpt, 0x080, 0, 0, 0, 1 }, { "Show FPS", MB_ONOFF, MA_OPT_SHOW_FPS, ¤tConfig.EmuOpt, 0x002, 0, 0, 1, 1 }, { NULL, MB_RANGE, MA_OPT_FRAMESKIP, ¤tConfig.Frameskip, 0, -1, 16, 1, 1 }, { "Enable sound", MB_ONOFF, MA_OPT_ENABLE_SOUND, ¤tConfig.EmuOpt, 0x004, 0, 0, 1, 1 }, diff --git a/linux/port_config.h b/linux/port_config.h index 21e5b32..5ccbacb 100644 --- a/linux/port_config.h +++ b/linux/port_config.h @@ -15,7 +15,7 @@ #define SIMPLE_WRITE_SOUND 0 #define mix_32_to_16l_stereo_lvl mix_32_to_16l_stereo -#define EL_LOGMASK (EL_ANOMALY|EL_STATUS|EL_SRAMIO|EL_EEPROM|EL_UIO)//|EL_VDPDMA|EL_HVCNT|EL_ASVDP)//|EL_SVP) +#define EL_LOGMASK (EL_ANOMALY|EL_STATUS|EL_SRAMIO|EL_EEPROM|EL_UIO|EL_IDLE)//|EL_VDPDMA|EL_HVCNT|EL_ASVDP)//|EL_SVP) // EL_VDPDMA|EL_ASVDP|EL_SR) // |EL_BUSREQ|EL_Z80BNK) //#define dprintf(f,...) printf("%05i:%03i: " f "\n",Pico.m.frame_count,Pico.m.scanline,##__VA_ARGS__) diff --git a/psp/Makefile b/psp/Makefile index c89f1d6..69505e3 100644 --- a/psp/Makefile +++ b/psp/Makefile @@ -43,6 +43,8 @@ OBJS += ../../Pico/cd/Pico.o ../../Pico/cd/Memory.o ../../Pico/cd/Sek.o ../../Pi # Pico - carthw OBJS += ../../Pico/carthw/carthw.o ../../Pico/carthw/svp/svp.o ../../Pico/carthw/svp/Memory.o \ ../../Pico/carthw/svp/ssp16.o +# Pico - Pico +OBJS += ../../Pico/Pico/Pico.o ../../Pico/Pico/Memory.o ../../Pico/Pico/xpcm.o endif # Pico - sound diff --git a/psp/emu.c b/psp/emu.c index 09b5d46..bdf6a6e 100644 --- a/psp/emu.c +++ b/psp/emu.c @@ -39,6 +39,9 @@ int engineState = PGS_Menu; static unsigned int noticeMsgTime = 0; int reset_timing = 0; // do we need this? +#define PICO_PEN_ADJUST_X 4 +#define PICO_PEN_ADJUST_Y 2 +static int pico_pen_x = 320/2, pico_pen_y = 240/2; static void sound_init(void); static void sound_deinit(void); @@ -122,7 +125,7 @@ void emu_prepareDefaultConfig(void) { memset(&defaultConfig, 0, sizeof(defaultConfig)); defaultConfig.EmuOpt = 0x1d | 0x680; // | <- confirm_save, cd_leds, acc rend - defaultConfig.s_PicoOpt = 0x0f | POPT_EN_MCD_PCM|POPT_EN_MCD_CDDA|POPT_EN_MCD_GFX; + defaultConfig.s_PicoOpt = 0x0f | POPT_EN_MCD_PCM|POPT_EN_MCD_CDDA|POPT_EN_MCD_GFX|POPT_ACC_SPRITES; defaultConfig.s_PsndRate = 22050; defaultConfig.s_PicoRegion = 0; // auto defaultConfig.s_PicoAutoRgnOrder = 0x184; // US, EU, JP @@ -164,7 +167,7 @@ void emu_setDefaultConfig(void) extern void amips_clut(unsigned short *dst, unsigned char *src, unsigned short *pal, int count); extern void amips_clut_6bit(unsigned short *dst, unsigned char *src, unsigned short *pal, int count); -extern void (*amips_clut_f)(unsigned short *dst, unsigned char *src, unsigned short *pal, int count) = NULL; +static void (*amips_clut_f)(unsigned short *dst, unsigned char *src, unsigned short *pal, int count) = NULL; struct Vertex { @@ -265,12 +268,11 @@ static void do_pal_update(int allow_sh, int allow_as) localPal[0x80|i]=(unsigned short)t; } localPal[0xe0] = 0; + localPal[0xf0] = 0x001f; } else if (allow_as && (rendstatus & PDRAW_ACC_SPRITES)) { - memcpy32(localPal+0x40, localPal, 0x40); - memcpy32(localPal+0x80, localPal, 0x40); - memcpy32(localPal+0xc0, localPal, 0x40); + memcpy32((int *)(void *)(localPal+0x80), (void *)localPal, 0x40/2); } } @@ -340,7 +342,7 @@ static void blitscreen_clut(void) if (dynamic_palette) { - if (!blit_16bit_mode) { + if (!blit_16bit_mode) { // the current mode is not 16bit sceGuTexMode(GU_PSM_5650, 0, 0, 0); sceGuTexImage(0,512,512,512,(char *)VRAM_STUFF + 512*240); @@ -407,6 +409,21 @@ static void cd_leds(void) *p++ = col_g; *p++ = col_g; p+=2; *p++ = col_r; *p++ = col_r; } +static void draw_pico_ptr(void) +{ + unsigned char *p = (unsigned char *)VRAM_STUFF + 16; + + // only if pen enabled and for 8bit mode + if (pico_inp_mode == 0 || blit_16bit_mode) return; + + p += 512 * (pico_pen_y + PICO_PEN_ADJUST_Y); + p += pico_pen_x + PICO_PEN_ADJUST_X; + p[ -1] = 0xe0; p[ 0] = 0xf0; p[ 1] = 0xe0; + p[ 511] = 0xf0; p[ 512] = 0xf0; p[ 513] = 0xf0; + p[1023] = 0xe0; p[1024] = 0xf0; p[1025] = 0xe0; +} + + #if 0 static void dbg_text(void) { @@ -438,6 +455,9 @@ void blit1(void) memset32((int *)pd, 0xe0e0e0e0, 320/4); } + if (PicoAHW & PAHW_PICO) + draw_pico_ptr(); + blitscreen_clut(); } @@ -502,6 +522,7 @@ static void vidResetMode(void) PicoScanEnd = EmuScanSlowEnd; localPal[0xe0] = 0; + localPal[0xf0] = 0x001f; Pico.m.dirtyPal = 1; blit_16bit_mode = dynamic_palette = 0; @@ -693,7 +714,7 @@ void emu_forcedFrame(int opts) int eo_old = currentConfig.EmuOpt; PicoOpt &= ~0x10; - PicoOpt |= opts|POPT_ACC_SPRITES + PicoOpt |= opts|POPT_ACC_SPRITES; currentConfig.EmuOpt |= 0x80; vidResetMode(); @@ -714,6 +735,29 @@ void emu_forcedFrame(int opts) } +static void RunEventsPico(unsigned int events, unsigned int keys) +{ + emu_RunEventsPico(events); + + if (pico_inp_mode != 0) + { + PicoPad[0] &= ~0x0f; // release UDLR + if (keys & BTN_UP) { pico_pen_y--; if (pico_pen_y < 8) pico_pen_y = 8; } + if (keys & BTN_DOWN) { pico_pen_y++; if (pico_pen_y > 224-PICO_PEN_ADJUST_Y) pico_pen_y = 224-PICO_PEN_ADJUST_Y; } + if (keys & BTN_LEFT) { pico_pen_x--; if (pico_pen_x < 0) pico_pen_x = 0; } + if (keys & BTN_RIGHT) { + int lim = (Pico.video.reg[12]&1) ? 319 : 255; + pico_pen_x++; + if (pico_pen_x > lim-PICO_PEN_ADJUST_X) + pico_pen_x = lim-PICO_PEN_ADJUST_X; + } + PicoPicohw.pen_pos[0] = pico_pen_x; + if (!(Pico.video.reg[12]&1)) PicoPicohw.pen_pos[0] += pico_pen_x/4; + PicoPicohw.pen_pos[0] += 0x3c; + PicoPicohw.pen_pos[1] = pico_inp_mode == 1 ? (0x2f8 + pico_pen_y) : (0x1fc + pico_pen_y); + } +} + static void RunEvents(unsigned int which) { if (which & 0x1800) // save or load (but not both) @@ -822,7 +866,15 @@ static void updateKeys(void) events = (allActions[0] | allActions[1]) >> 16; + if ((events ^ prevEvents) & 0x40) { + emu_changeFastForward(events & 0x40); + reset_timing = 1; + } + events &= ~prevEvents; + + if (PicoAHW == PAHW_PICO) + RunEventsPico(events, keys); if (events) RunEvents(events); if (movie_data) emu_updateMovie(); @@ -1030,6 +1082,8 @@ void emu_Loop(void) } + emu_changeFastForward(0); + if (PicoAHW & PAHW_MCD) PicoCDBufferFree(); if (PsndOut != NULL) { diff --git a/psp/main.c b/psp/main.c index 952f80e..4c7eef6 100644 --- a/psp/main.c +++ b/psp/main.c @@ -10,6 +10,7 @@ #include "mp3.h" #include "../common/menu.h" #include "../common/emu.h" +#include "../common/config.h" #include "../common/lprintf.h" #include "version.h" diff --git a/psp/menu.c b/psp/menu.c index 1c1b5df..966dee4 100644 --- a/psp/menu.c +++ b/psp/menu.c @@ -62,8 +62,6 @@ static unsigned long wait_for_input(unsigned int interesting, int is_key_config) else if (repeats == 4) wait = 2; else if (repeats == 6) wait = 1; - for (i = 0; i < wait && inp_prev == gp2x_joystick_read(1); i++) { - for (i = 0; i < wait && inp_prev == psp_pad_read(1); i++) { if (i == 0) repeats++; psp_msleep(30); @@ -439,8 +437,10 @@ static char *romsel_loop(char *curr_path) // ------------ debug menu ------------ char *debugString(void); +void PicoDrawShowSpriteStats(unsigned short *screen, int stride); +void PicoDrawShowPalette(unsigned short *screen, int stride); -static void draw_debug(void) +static void draw_main_debug(void) { char *p, *str = debugString(); int len, line; @@ -457,15 +457,49 @@ static void draw_debug(void) if (*p == 0) break; p++; str = p; } - menu_draw_end(); +} + +static void draw_frame_debug(void) +{ + char layer_str[48] = "layers: "; + if (PicoDrawMask & PDRAW_LAYERB_ON) memcpy(layer_str + 8, "B", 1); + if (PicoDrawMask & PDRAW_LAYERA_ON) memcpy(layer_str + 10, "A", 1); + if (PicoDrawMask & PDRAW_SPRITES_LOW_ON) memcpy(layer_str + 12, "spr_lo", 6); + if (PicoDrawMask & PDRAW_SPRITES_HI_ON) memcpy(layer_str + 19, "spr_hi", 6); + + memset(psp_screen, 0, 512*272*2); + emu_forcedFrame(0); + smalltext_out16(4, 264, layer_str, 0xffff); } static void debug_menu_loop(void) { - int ret = 0; - draw_debug(); - while (!(ret & (BTN_X|BTN_CIRCLE))) - ret = wait_for_input(BTN_X|BTN_CIRCLE, 0); + int inp, mode = 0; + + while (1) + { + switch (mode) + { + case 0: draw_main_debug(); break; + case 1: draw_frame_debug(); break; + case 2: menu_draw_begin(); + PicoDrawShowSpriteStats((unsigned short *)psp_screen+512*16+80, 512); break; + case 3: memset(psp_screen, 0, 512*272*2); + PicoDrawShowPalette(psp_screen, 512); break; + } + menu_draw_end(); + + inp = wait_for_input(BTN_X|BTN_CIRCLE|BTN_L|BTN_R|BTN_UP|BTN_DOWN|BTN_LEFT|BTN_RIGHT, 0); + if (inp & (BTN_X|BTN_CIRCLE)) return; + if (inp & BTN_L) { mode--; if (mode < 0) mode = 3; } + if (inp & BTN_R) { mode++; if (mode > 3) mode = 0; } + if (mode == 1) { + if (inp & BTN_LEFT) PicoDrawMask ^= PDRAW_LAYERB_ON; + if (inp & BTN_RIGHT) PicoDrawMask ^= PDRAW_LAYERA_ON; + if (inp & BTN_DOWN) PicoDrawMask ^= PDRAW_SPRITES_LOW_ON; + if (inp & BTN_UP) PicoDrawMask ^= PDRAW_SPRITES_HI_ON; + } + } } // ------------ patch/gg menu ------------ @@ -592,7 +626,7 @@ static void draw_savestate_bg(int slot) areaClose(file); } - emu_forcedFrame(); + emu_forcedFrame(0); menu_prepare_bg(1, 0); restore_oldstate(oldstate); @@ -797,12 +831,16 @@ static void draw_kc_sel(int menu_sel) // "LOAD STATE", "VOLUME UP", "VOLUME DOWN", "DONE" me_bind_action emuctrl_actions[] = { - { "Load State ", 1<<28 }, - { "Save State ", 1<<27 }, - { "Prev Save Slot ", 1<<25 }, - { "Next Save Slot ", 1<<24 }, - { "Switch Renderer", 1<<26 }, - { NULL, 0 } + { "Load State ", 1<<28 }, + { "Save State ", 1<<27 }, + { "Prev Save Slot ", 1<<25 }, + { "Next Save Slot ", 1<<24 }, + { "Switch Renderer ", 1<<26 }, + { "Fast forward ", 1<<22 }, + { "Pico Next page ", 1<<21 }, + { "Pico Prev page ", 1<<20 }, + { "Pico Switch input", 1<<19 }, + { NULL, 0 } }; static void kc_sel_loop(void) @@ -1065,7 +1103,7 @@ static void menu_opt3_preview(int is_32col) } memset32_uncached(psp_screen, 0, 512*272*2/4); - emu_forcedFrame(); + emu_forcedFrame(0); menu_prepare_bg(1, 0); if (oldstate) restore_oldstate(oldstate); @@ -1176,7 +1214,7 @@ menu_entry opt2_entries[] = { "gzip savestates", MB_ONOFF, MA_OPT2_GZIP_STATES, ¤tConfig.EmuOpt, 0x00008, 0, 0, 1, 1 }, { "Don't save last used ROM", MB_ONOFF, MA_OPT2_NO_LAST_ROM, ¤tConfig.EmuOpt, 0x00020, 0, 0, 1, 1 }, { "Status line in main menu", MB_ONOFF, MA_OPT2_STATUS_LINE, ¤tConfig.EmuOpt, 0x20000, 0, 0, 1, 1 }, - { "Disable frame limitter", MB_ONOFF, MA_OPT2_NO_FRAME_LIMIT, ¤tConfig.EmuOpt, 0x40000, 0, 0, 1, 1 }, + { "Disable frame limiter", MB_ONOFF, MA_OPT2_NO_FRAME_LIMIT, ¤tConfig.EmuOpt, 0x40000, 0, 0, 1, 1 }, { "done", MB_NONE, MA_OPT2_DONE, NULL, 0, 0, 0, 1, 0 }, }; @@ -1235,7 +1273,7 @@ static void amenu_loop_options(void) menu_entry opt_entries[] = { { NULL, MB_NONE, MA_OPT_RENDERER, NULL, 0, 0, 0, 1, 1 }, - { "Accurate sprites (slower)", MB_ONOFF, MA_OPT_ACC_SPRITES, &PicoOpt, 0x0080, 0, 0, 1, 1 }, + { "Accurate sprites", MB_ONOFF, MA_OPT_ACC_SPRITES, &PicoOpt, 0x0080, 0, 0, 0, 1 }, { "Show FPS", MB_ONOFF, MA_OPT_SHOW_FPS, ¤tConfig.EmuOpt, 0x0002, 0, 0, 1, 1 }, { NULL, MB_RANGE, MA_OPT_FRAMESKIP, ¤tConfig.Frameskip, 0, -1, 16, 1, 1 }, { "Enable sound", MB_ONOFF, MA_OPT_ENABLE_SOUND, ¤tConfig.EmuOpt, 0x0004, 0, 0, 1, 1 }, diff --git a/psp/port_config.h b/psp/port_config.h index 3bd139d..56513c0 100644 --- a/psp/port_config.h +++ b/psp/port_config.h @@ -23,7 +23,7 @@ extern void blit1(void); #define CAN_HANDLE_240_LINES 1 // logging emu events -#define EL_LOGMASK EL_STATUS // (EL_STATUS|EL_ANOMALY|EL_UIO|EL_SRAMIO) // xffff +#define EL_LOGMASK (EL_STATUS|EL_IDLE) // (EL_STATUS|EL_ANOMALY|EL_UIO|EL_SRAMIO) // xffff //#define dprintf(f,...) printf("%05i:%03i: " f "\n",Pico.m.frame_count,Pico.m.scanline,##__VA_ARGS__) #define dprintf(x...) -- 2.39.2 From ac3494f42e030f50c5fe1fa35de684c2c3055af4 Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 6 Jul 2008 11:33:13 +0000 Subject: [PATCH 08/16] idle debug removed, vpath added to Makefiles git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@526 be3aeb3a-fb24-0410-a615-afba39da0efa --- gp2x/Makefile | 117 +++++++++++++++++++++++++++----------------------- psp/Makefile | 65 ++++++++++++++++------------ 2 files changed, 100 insertions(+), 82 deletions(-) diff --git a/gp2x/Makefile b/gp2x/Makefile index d9beac8..0fd9feb 100644 --- a/gp2x/Makefile +++ b/gp2x/Makefile @@ -58,89 +58,94 @@ OBJS += main.o menu.o gp2x.o usbjoy.o emu.o squidgehack.o cpuctrl.o OBJS += 940ctl.o # common -OBJS += ../common/emu.o ../common/menu.o ../common/fonts.o ../common/config.o ../common/arm_utils.o \ - ../common/readpng.o ../common/mp3_helix.o +OBJS += platform/common/emu.o platform/common/menu.o platform/common/fonts.o platform/common/config.o \ + platform/common/arm_utils.o platform/common/readpng.o platform/common/mp3_helix.o # Pico ifeq "$(amalgamate)" "1" 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 +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 - 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/cue.o ../../Pico/cd/gfx_cd.o \ - ../../Pico/cd/Area.o ../../Pico/cd/Misc.o ../../Pico/cd/pcm.o ../../Pico/cd/buffering.o +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/cue.o Pico/cd/gfx_cd.o \ + Pico/cd/Area.o Pico/cd/Misc.o Pico/cd/pcm.o Pico/cd/buffering.o endif # Pico - Pico -OBJS += ../../Pico/Pico/Pico.o ../../Pico/Pico/Memory.o ../../Pico/Pico/xpcm.o +OBJS += Pico/Pico/Pico.o Pico/Pico/Memory.o Pico/Pico/xpcm.o # Pico - carthw -OBJS += ../../Pico/carthw/carthw.o ../../Pico/carthw/svp/svp.o ../../Pico/carthw/svp/Memory.o \ - ../../Pico/carthw/svp/ssp16.o ../../Pico/carthw/svp/compiler.o ../../Pico/carthw/svp/stub_arm.o +OBJS += Pico/carthw/carthw.o Pico/carthw/svp/svp.o Pico/carthw/svp/Memory.o \ + Pico/carthw/svp/ssp16.o Pico/carthw/svp/compiler.o Pico/carthw/svp/stub_arm.o # asm stuff ifeq "$(asm_render)" "1" DEFINC += -D_ASM_DRAW_C -OBJS += ../../Pico/draw_asm.o ../../Pico/draw2_asm.o +OBJS += Pico/draw_asm.o Pico/draw2_asm.o endif ifeq "$(asm_memory)" "1" DEFINC += -D_ASM_MEMORY_C -OBJS += ../../Pico/memory_asm.o +OBJS += Pico/memory_asm.o endif ifeq "$(asm_ym2612)" "1" DEFINC += -D_ASM_YM2612_C -OBJS += ../../Pico/sound/ym2612_asm.o +OBJS += Pico/sound/ym2612_asm.o endif ifeq "$(asm_misc)" "1" DEFINC += -D_ASM_MISC_C -OBJS += ../../Pico/misc_asm.o -OBJS += ../../Pico/cd/misc_asm.o +OBJS += Pico/misc_asm.o +OBJS += Pico/cd/misc_asm.o endif ifeq "$(asm_cdpico)" "1" DEFINC += -D_ASM_CD_PICO_C -OBJS += ../../Pico/cd/pico_asm.o +OBJS += Pico/cd/pico_asm.o endif ifeq "$(asm_cdmemory)" "1" DEFINC += -D_ASM_CD_MEMORY_C -OBJS += ../../Pico/cd/memory_asm.o +OBJS += Pico/cd/memory_asm.o endif # Pico - sound ifneq "$(amalgamate)" "1" -OBJS += ../../Pico/sound/sound.o +OBJS += Pico/sound/sound.o endif -OBJS += ../../Pico/sound/mix_asm.o -OBJS += ../../Pico/sound/sn76496.o ../../Pico/sound/ym2612.o +OBJS += Pico/sound/mix_asm.o +OBJS += Pico/sound/sn76496.o Pico/sound/ym2612.o # zlib -OBJS += ../../zlib/gzio.o ../../zlib/inffast.o ../../zlib/inflate.o ../../zlib/inftrees.o ../../zlib/trees.o \ - ../../zlib/deflate.o ../../zlib/crc32.o ../../zlib/adler32.o ../../zlib/zutil.o ../../zlib/compress.o +OBJS += zlib/gzio.o zlib/inffast.o zlib/inflate.o zlib/inftrees.o zlib/trees.o \ + zlib/deflate.o zlib/crc32.o zlib/adler32.o zlib/zutil.o zlib/compress.o # unzip -OBJS += ../../unzip/unzip.o ../../unzip/unzip_stream.o +OBJS += unzip/unzip.o unzip/unzip_stream.o # debug ifeq "$(debug_cyclone)" "1" -OBJS += ../../Pico/Debug.o ../../cpu/musashi/m68kdasm.o +OBJS += Pico/Debug.o cpu/musashi/m68kdasm.o endif # CPU cores ifeq "$(use_musashi)" "1" DEFINC += -DEMU_M68K -OBJS += ../../cpu/musashi/m68kops.o ../../cpu/musashi/m68kcpu.o +OBJS += cpu/musashi/m68kops.o cpu/musashi/m68kcpu.o endif ifeq "$(use_cyclone)" "1" DEFINC += -DEMU_C68K -OBJS += ../../cpu/Cyclone/proj/Cyclone.o ../../cpu/Cyclone/tools/idle.o +OBJS += cpu/Cyclone/proj/Cyclone.o cpu/Cyclone/tools/idle.o endif # drz80/mz80 ifeq "$(mz80)" "1" DEFINC += -D_USE_MZ80 -OBJS += ../../cpu/mz80/mz80.o +OBJS += cpu/mz80/mz80.o else DEFINC += -D_USE_DRZ80 -OBJS += ../../cpu/DrZ80/drz80.o +OBJS += cpu/DrZ80/drz80.o endif +vpath %.c = ../.. +vpath %.s = ../.. +vpath %.S = ../.. +DIRS = platform platform/gp2x platform/common Pico Pico/cd Pico/Pico Pico/sound Pico/carthw/svp \ + zlib unzip cpu cpu/musashi cpu/Cyclone/proj cpu/Cyclone/tools cpu/mz80 cpu/DrZ80 -all: PicoDrive.gpe + +all: mkdirs PicoDrive.gpe PicoDrive.gpe : $(OBJS) ../common/helix/helix_mp3.a @echo ">>>" $@ @@ -154,6 +159,22 @@ up: PicoDrive.gpe # @cmd //C copy PicoDrive.gpe \\\\10.0.1.2\\gp2x\\mnt\\sd\\games\\PicoDrive\\ +# cleanup +clean: tidy + $(RM) PicoDrive.gpe +tidy: + $(RM) $(OBJS) + rm -rf $(DIRS) +# @make -C ../../cpu/Cyclone/proj -f Makefile.linux clean + + +clean_prof: + find ../.. -name '*.gcno' -delete + find ../.. -name '*.gcda' -delete + + +mkdirs: + mkdir -p $(DIRS) .c.o: @echo ">>>" $< @@ -165,33 +186,33 @@ up: PicoDrive.gpe @echo ">>>" $< $(GCC) $(COPT) $(DEFINC) -c $< -o $@ -../../Pico/carthw/svp/compiler.o : ../../Pico/carthw/svp/ssp16.o ../../Pico/carthw/svp/gen_arm.c +Pico/carthw/svp/compiler.o : ../../Pico/carthw/svp/ssp16.o ../../Pico/carthw/svp/gen_arm.c -../../Pico/draw_asm.o : ../../Pico/Draw.s +Pico/draw_asm.o : ../../Pico/Draw.s @echo ">>>" $< $(AS) $(ASOPT) $< -o $@ -../../Pico/draw2_asm.o : ../../Pico/Draw2.s +Pico/draw2_asm.o : ../../Pico/Draw2.s @echo ">>>" $< $(AS) $(ASOPT) $< -o $@ -../../Pico/memory_asm.o : ../../Pico/Memory.s +Pico/memory_asm.o : ../../Pico/Memory.s @echo ">>>" $< $(AS) $(ASOPT) $< -o $@ -../../Pico/sound/ym2612_asm.o : ../../Pico/sound/ym2612.s +Pico/sound/ym2612_asm.o : ../../Pico/sound/ym2612.s @echo ">>>" $< $(AS) $(ASOPT) $< -o $@ -../../Pico/sound/mix_asm.o : ../../Pico/sound/mix.s +Pico/sound/mix_asm.o : ../../Pico/sound/mix.s @echo ">>>" $< $(AS) $(ASOPT) $< -o $@ -../../Pico/misc_asm.o : ../../Pico/Misc.s +Pico/misc_asm.o : ../../Pico/Misc.s @echo ">>>" $< $(AS) $(ASOPT) $< -o $@ -../../Pico/cd/pico_asm.o : ../../Pico/cd/Pico.s +Pico/cd/pico_asm.o : ../../Pico/cd/Pico.s @echo ">>>" $< $(AS) $(ASOPT) $< -o $@ -../../Pico/cd/memory_asm.o : ../../Pico/cd/Memory.s +Pico/cd/memory_asm.o : ../../Pico/cd/Memory.s @echo ">>>" $< $(AS) $(ASOPT) $< -o $@ -../../Pico/cd/misc_asm.o : ../../Pico/cd/Misc.s +Pico/cd/misc_asm.o : ../../Pico/cd/Misc.s @echo ">>>" $< $(AS) $(ASOPT) $< -o $@ @@ -203,8 +224,8 @@ up: PicoDrive.gpe ../../cpu/musashi/m68kops.c : @make -C ../../cpu/musashi -../../Pico/Pico.o ../../Pico/cd/Pico.o: ../../Pico/PicoFrameHints.c ../../Pico/PicoInt.h -../../Pico/Memory.o Pico/cd/Memory.o : ../../Pico/MemoryCmn.c ../../Pico/PicoInt.h +Pico/Pico.o Pico/cd/Pico.o: ../../Pico/PicoFrameHints.c ../../Pico/PicoInt.h +Pico/Memory.o Pico/cd/Memory.o : ../../Pico/MemoryCmn.c ../../Pico/PicoInt.h # build helix libs ../common/helix/helix_mp3.a: @@ -217,18 +238,6 @@ readme.txt: ../../tools/textfilter ../base_readme.txt make -C ../../tools/ textfilter -# cleanup -clean: tidy - $(RM) PicoDrive.gpe -tidy: - $(RM) $(OBJS) -# @make -C ../../cpu/Cyclone/proj -f Makefile.linux clean - - -clean_prof: - find ../.. -name '*.gcno' -delete - find ../.. -name '*.gcda' -delete - # ----------- release ----------- ifneq ($(findstring rel,$(MAKECMDGOALS)),) ifeq ($(VER),) diff --git a/psp/Makefile b/psp/Makefile index 69505e3..075130e 100644 --- a/psp/Makefile +++ b/psp/Makefile @@ -27,57 +27,62 @@ endif OBJS += main.o emu.o mp3.o menu.o psp.o asm_utils.o # common -OBJS += ../common/emu.o ../common/menu.o ../common/fonts.o ../common/config.o ../common/readpng.o +OBJS += platform/common/emu.o platform/common/menu.o platform/common/fonts.o platform/common/config.o platform/common/readpng.o # Pico ifeq "$(amalgamate)" "1" 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/Misc_amips.o +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/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/cue.o ../../Pico/cd/gfx_cd.o \ - ../../Pico/cd/Area.o ../../Pico/cd/Misc.o ../../Pico/cd/pcm.o ../../Pico/cd/buffering.o +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/cue.o Pico/cd/gfx_cd.o \ + Pico/cd/Area.o Pico/cd/Misc.o Pico/cd/pcm.o Pico/cd/buffering.o # Pico - carthw -OBJS += ../../Pico/carthw/carthw.o ../../Pico/carthw/svp/svp.o ../../Pico/carthw/svp/Memory.o \ - ../../Pico/carthw/svp/ssp16.o +OBJS += Pico/carthw/carthw.o Pico/carthw/svp/svp.o Pico/carthw/svp/Memory.o \ + Pico/carthw/svp/ssp16.o # Pico - Pico -OBJS += ../../Pico/Pico/Pico.o ../../Pico/Pico/Memory.o ../../Pico/Pico/xpcm.o +OBJS += Pico/Pico/Pico.o Pico/Pico/Memory.o Pico/Pico/xpcm.o endif # Pico - sound ifneq "$(amalgamate)" "1" -OBJS += ../../Pico/sound/sound.o +OBJS += Pico/sound/sound.o endif -OBJS += ../../Pico/sound/mix.o -OBJS += ../../Pico/sound/sn76496.o ../../Pico/sound/ym2612.o +OBJS += Pico/sound/mix.o +OBJS += Pico/sound/sn76496.o Pico/sound/ym2612.o # zlib (hacked) -OBJS += ../../zlib/gzio.o ../../zlib/inffast.o ../../zlib/inflate.o ../../zlib/inftrees.o ../../zlib/trees.o \ - ../../zlib/deflate.o ../../zlib/crc32.o ../../zlib/adler32.o ../../zlib/zutil.o ../../zlib/compress.o \ - ../../zlib/uncompr.o +OBJS += zlib/gzio.o zlib/inffast.o zlib/inflate.o zlib/inftrees.o zlib/trees.o \ + zlib/deflate.o zlib/crc32.o zlib/adler32.o zlib/zutil.o zlib/compress.o \ + zlib/uncompr.o # unzip -OBJS += ../../unzip/unzip.o ../../unzip/unzip_stream.o +OBJS += unzip/unzip.o unzip/unzip_stream.o # CPU cores ifeq "$(use_musashi)" "1" CFLAGS += -DEMU_M68K -OBJS += ../../cpu/musashi/m68kops.o ../../cpu/musashi/m68kcpu.o +OBJS += cpu/musashi/m68kops.o cpu/musashi/m68kcpu.o else CFLAGS += -DEMU_F68K -OBJS += ../../cpu/fame/famec.o +OBJS += cpu/fame/famec.o endif # z80 ifeq "$(use_mz80)" "1" CFLAGS += -D_USE_MZ80 -OBJS += ../../cpu/mz80/mz80.o +OBJS += cpu/mz80/mz80.o else CFLAGS += -D_USE_CZ80 -OBJS += ../../cpu/cz80/cz80.o +OBJS += cpu/cz80/cz80.o endif # bg images OBJS += data/bg32.o data/bg40.o +vpath %.c = ../.. +vpath %.s = ../.. +DIRS = platform platform/psp platform/common Pico Pico/cd Pico/Pico Pico/sound Pico/carthw/svp \ + zlib unzip cpu cpu/musashi cpu/fame cpu/mz80 cpu/cz80 + LIBS += -lpng -lm -lpspgu -lpsppower -lpspaudio -lpsprtc -lpspaudiocodec -lpspkubridge #LIBS += -lpspprof @@ -86,7 +91,7 @@ LDFLAGS += -Wl,-Map=PicoDrive.map # target TARGET = PicoDrive -EXTRA_TARGETS = EBOOT.PBP +EXTRA_TARGETS = mkdirs EBOOT.PBP PSP_EBOOT_TITLE = PicoDrive PSP_EBOOT_ICON = data/icon.png #PSP_EBOOT_PIC1 = .png @@ -99,6 +104,9 @@ CUSTOM_CLEAN = myclean include $(PSPSDK)/lib/build.mak # some additional rules +mkdirs: + mkdir -p $(DIRS) + .c.o: @echo ">>>" $< $(CC) $(CFLAGS) -c $< -o $@ @@ -112,27 +120,27 @@ AS := psp-as ../../cpu/musashi/m68kops.c : make -C ../../cpu/musashi -../../cpu/fame/famec.o : ../../cpu/fame/famec.c +cpu/fame/famec.o : ../../cpu/fame/famec.c @echo ">>>" $< $(CC) $(CFLAGS) -Wno-unused -c $< -o $@ -../../Pico/Memory.o : ../../Pico/Memory.c +Pico/Memory.o : ../../Pico/Memory.c @echo ">>>" $< $(CC) $(CFLAGS) -O2 -c $< -o $@ -D_ASM_MEMORY_C -D_ASM_MEMORY_C_AMIPS -../../Pico/cd/Memory.o : ../../Pico/cd/Memory.c +Pico/cd/Memory.o : ../../Pico/cd/Memory.c @echo ">>>" $< $(CC) $(CFLAGS) -O2 -c $< -o $@ -../../Pico/Draw.o : ../../Pico/Draw.c +Pico/Draw.o : ../../Pico/Draw.c @echo ">>>" $< $(CC) $(CFLAGS) -c $< -o $@ -D_ASM_DRAW_C_AMIPS -../../Pico/Misc.o : ../../Pico/Misc.c +Pico/Misc.o : ../../Pico/Misc.c @echo ">>>" $< $(CC) $(CFLAGS) -c $< -o $@ -D_ASM_MISC_C_AMIPS -../../Pico/cd/gfx_cd.o : ../../Pico/cd/gfx_cd.c +Pico/cd/gfx_cd.o : ../../Pico/cd/gfx_cd.c @echo ">>>" $< $(CC) $(CFLAGS) -O2 -c $< -o $@ @@ -159,6 +167,7 @@ up: EBOOT.PBP # cleanup myclean: + rm -rf $(DIRS) $(RM) PicoDrive.map make -C ../../cpu/musashi clean -- 2.39.2 From 8fc24df108f8e3aff19e7f003db936f488118bdc Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 6 Jul 2008 15:43:26 +0000 Subject: [PATCH 09/16] attempt to fix PSP sleep wake git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@528 be3aeb3a-fb24-0410-a615-afba39da0efa --- common/emu.c | 4 ++-- psp/psp.c | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/common/emu.c b/common/emu.c index 44e15a6..c482673 100644 --- a/common/emu.c +++ b/common/emu.c @@ -960,10 +960,10 @@ int emu_SaveLoadGame(int load, int sram) } else ret = -1; if (!ret) - strcpy(noticeMsg, load ? "GAME LOADED " : "GAME SAVED "); + strcpy(noticeMsg, load ? "GAME LOADED " : "GAME SAVED "); else { - strcpy(noticeMsg, load ? "LOAD FAILED " : "SAVE FAILED "); + strcpy(noticeMsg, load ? "LOAD FAILED " : "SAVE FAILED "); ret = -1; } diff --git a/psp/psp.c b/psp/psp.c index 8d1134c..fd55b6c 100644 --- a/psp/psp.c +++ b/psp/psp.c @@ -276,16 +276,19 @@ void psp_resume_suspend(void) SceUID fd; int i; for (i = 0; i < 30; i++) { - fd = sceIoOpen("dummy.txt", PSP_O_WRONLY|PSP_O_APPEND, 0777); - if (fd != 0x80010013) break; // device not available - sceKernelDelayThread(32 * 1024); + fd = sceIoOpen("EBOOT.PBP", PSP_O_RDONLY, 0777); + if (fd >= 0) break; + sceKernelDelayThread(100 * 1024); } if (fd >= 0) sceIoClose(fd); sceDisplayWaitVblankStart(); psp_unhandled_suspend = 0; if (i < 30) - lprintf("io resumed after %i tries\n", i); - else lprintf("io resume failed\n"); + lprintf("io resumed after %i tries\n", i); + else { + lprintf("io resume failed with %08x\n", fd); + sceKernelDelayThread(500 * 1024); + } } /* alt logging */ -- 2.39.2 From 6e507f764b95d5f6088ea7f174586cfb0360a236 Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 6 Jul 2008 20:28:11 +0000 Subject: [PATCH 10/16] occasional mp3 click noises fixed git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@530 be3aeb3a-fb24-0410-a615-afba39da0efa --- common/mp3_helix.c | 52 ++++++++++++++++++++++++++++++++++++++++------ gp2x/940ctl.c | 12 ++++++++--- 2 files changed, 55 insertions(+), 9 deletions(-) diff --git a/common/mp3_helix.c b/common/mp3_helix.c index 3e75ab9..f28abda 100644 --- a/common/mp3_helix.c +++ b/common/mp3_helix.c @@ -15,13 +15,40 @@ static HMP3Decoder mp3dec = 0; static int mp3_buffer_offs = 0; +static int find_sync_word(unsigned char *buf, int nBytes) +{ + unsigned char *p, *pe; + + /* find byte-aligned syncword - need 12 (MPEG 1,2) or 11 (MPEG 2.5) matching bits */ + for (p = buf, pe = buf + nBytes - 4; p < pe; p++) + { + int pn; + if (p[0] != 0xff) continue; + pn = p[1]; + if ((pn & 0xf8) != 0xf8 || // currently must be MPEG1 + (pn & 6) == 0) { // invalid layer + p++; continue; + } + pn = p[2]; + if ((pn & 0xf0) < 0x20 || (pn & 0xf0) == 0xf0 || // bitrates + (pn & 0x0c) != 0) { // not 44kHz + continue; + } + + return p - buf; + } + + return -1; +} + + static int try_get_header(unsigned char *buff, MP3FrameInfo *fi) { int ret, offs1, offs = 0; while (1) { - offs1 = MP3FindSyncWord(buff + offs, 2048 - offs); + offs1 = find_sync_word(buff + offs, 2048 - offs); if (offs1 < 0) return -2; offs += offs1; if (2048 - offs < 4) return -3; @@ -44,7 +71,8 @@ int mp3_get_bitrate(FILE *f, int len) memset(buff, 0, 2048); - if (!mp3dec) mp3dec = MP3InitDecoder(); + if (mp3dec) MP3FreeDecoder(mp3dec); + mp3dec = MP3InitDecoder(); fseek(f, 0, SEEK_SET); ret = fread(buff, 1, 2048, f); @@ -81,11 +109,12 @@ static int mp3_decode(void) unsigned char *readPtr = mp3_mem + mp3_offs; int bytesLeft = shared_ctl->mp3_len - mp3_offs; int offset; // frame offset from readPtr - int err; + int retries = 0, err; if (bytesLeft <= 0) return 1; // EOF, nothing to do - offset = MP3FindSyncWord(readPtr, bytesLeft); +retry: + offset = find_sync_word(readPtr, bytesLeft); if (offset < 0) { shared_ctl->mp3_offs = shared_ctl->mp3_len; return 1; // EOF @@ -102,6 +131,9 @@ static int mp3_decode(void) // ERR_MP3_INVALID_FRAMEHEADER, ERR_MP3_INVALID_* // just try to skip the offending frame.. readPtr++; + bytesLeft--; + if (retries++ < 2) goto retry; + else lprintf("mp3 decode failed with %i after %i retries\n", err, retries); } shared_ctl->mp3_errors++; shared_ctl->mp3_lasterr = err; @@ -112,6 +144,10 @@ static int mp3_decode(void) void mp3_start_local(void) { + // must re-init decoder for new track + if (mp3dec) MP3FreeDecoder(mp3dec); + mp3dec = MP3InitDecoder(); + mp3_buffer_offs = 0; mp3_decode(); } @@ -138,9 +174,9 @@ static int mp3_decode(void) fseek(mp3_current_file, mp3_file_pos, SEEK_SET); bytesLeft = fread(mp3_input_buffer, 1, sizeof(mp3_input_buffer), mp3_current_file); - offset = MP3FindSyncWord(mp3_input_buffer, bytesLeft); + offset = find_sync_word(mp3_input_buffer, bytesLeft); if (offset < 0) { - //lprintf("MP3FindSyncWord (%i/%i) err %i\n", mp3_file_pos, mp3_file_len, offset); + //lprintf("find_sync_word (%i/%i) err %i\n", mp3_file_pos, mp3_file_len, offset); mp3_file_pos = mp3_file_len; return 1; // EOF } @@ -179,6 +215,10 @@ void mp3_start_play(FILE *f, int pos) mp3_current_file = NULL; mp3_buffer_offs = 0; + // must re-init decoder for new track + if (mp3dec) MP3FreeDecoder(mp3dec); + mp3dec = MP3InitDecoder(); + if (!(PicoOpt&POPT_EN_MCD_CDDA) || f == NULL) // cdda disabled or no file? return; diff --git a/gp2x/940ctl.c b/gp2x/940ctl.c index ee250f8..f01ffa3 100644 --- a/gp2x/940ctl.c +++ b/gp2x/940ctl.c @@ -508,7 +508,7 @@ void mp3_start_play(FILE *f, int pos) // pos is 0-1023 shared_ctl->mp3_len = ftell(f); loaded_mp3 = f; - if (PicoOpt&0x200) { + if (PicoOpt & POPT_EXT_FM) { // as we are going to change 940's cacheable area, we must invalidate it's cache.. if (CHECK_BUSY(JOB940_MP3DECODE)) wait_busy_940(JOB940_MP3DECODE); add_job_940(JOB940_INVALIDATE_DCACHE); @@ -522,7 +522,7 @@ void mp3_start_play(FILE *f, int pos) // pos is 0-1023 byte_offs *= pos; byte_offs >>= 6; } - // printf("mp3 pos1024: %i, byte_offs %i/%i\n", pos, byte_offs, shared_ctl->mp3_len); + printf(" mp3 pos1024: %i, byte_offs %i/%i\n", pos, byte_offs, shared_ctl->mp3_len); shared_ctl->mp3_offs = byte_offs; @@ -531,7 +531,13 @@ void mp3_start_play(FILE *f, int pos) // pos is 0-1023 mp3_job_started = 0; shared_ctl->mp3_buffsel = 1; // will change to 0 on first decode - if (!(PicoOpt&0x200)) mp3_start_local(); + if (PicoOpt & POPT_EXT_FM) + { + add_job_940(JOB940_MP3RESET); + if (CHECK_BUSY(JOB940_MP3RESET)) wait_busy_940(JOB940_MP3RESET); + } + else + mp3_start_local(); } -- 2.39.2 From 3f2aaff20c940e90e970c008e56f5253d494a92c Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 6 Jul 2008 22:39:21 +0000 Subject: [PATCH 11/16] some ts support, currently for Pico only git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@531 be3aeb3a-fb24-0410-a615-afba39da0efa --- gp2x/emu.c | 30 ++++++++++++++++++++++++++++-- gp2x/gp2x.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- gp2x/gp2x.h | 3 ++- linux/gp2x.c | 5 +++++ 4 files changed, 81 insertions(+), 5 deletions(-) diff --git a/gp2x/emu.c b/gp2x/emu.c index 19f3c67..570b0fc 100644 --- a/gp2x/emu.c +++ b/gp2x/emu.c @@ -436,13 +436,16 @@ static void emu_msg_tray_open(void) static void RunEventsPico(unsigned int events, unsigned int gp2x_keys) { + int ret, px, py; + static int pdown_frames = 0; + emu_RunEventsPico(events); if (pico_inp_mode != 0) { PicoPad[0] &= ~0x0f; // release UDLR - if (gp2x_keys & GP2X_UP) { pico_pen_y--; if (pico_pen_y < 0) pico_pen_y = 0; } - if (gp2x_keys & GP2X_DOWN) { pico_pen_y++; if (pico_pen_y > 239-PICO_PEN_ADJUST_Y) pico_pen_y = 239-PICO_PEN_ADJUST_Y; } + if (gp2x_keys & GP2X_UP) { pico_pen_y--; if (pico_pen_y < 8) pico_pen_y = 8; } + if (gp2x_keys & GP2X_DOWN) { pico_pen_y++; if (pico_pen_y > 224-PICO_PEN_ADJUST_Y) pico_pen_y = 224-PICO_PEN_ADJUST_Y; } if (gp2x_keys & GP2X_LEFT) { pico_pen_x--; if (pico_pen_x < 0) pico_pen_x = 0; } if (gp2x_keys & GP2X_RIGHT) { int lim = (Pico.video.reg[12]&1) ? 319 : 255; @@ -455,6 +458,29 @@ static void RunEventsPico(unsigned int events, unsigned int gp2x_keys) PicoPicohw.pen_pos[0] += 0x3c; PicoPicohw.pen_pos[1] = pico_inp_mode == 1 ? (0x2f8 + pico_pen_y) : (0x1fc + pico_pen_y); } + + // for F200 + ret = gp2x_touchpad_read(&px, &py); + if (ret >= 0) { + if (ret > 5000) { + if (pdown_frames++ > 5) + PicoPad[0] |= 0x20; + + pico_pen_x = px; + pico_pen_y = py; + if (!(Pico.video.reg[12]&1)) { + pico_pen_x -= 32; + if (pico_pen_x < 0) pico_pen_x = 0; + if (pico_pen_x > 248) pico_pen_x = 248; + } + if (pico_pen_y > 224) pico_pen_y = 224; + } + else + pdown_frames= 0; + + //if (ret == 0) + // PicoPicohw.pen_pos[0] = PicoPicohw.pen_pos[1] = 0x8000; + } } static void update_volume(int has_changed, int is_up) diff --git a/gp2x/gp2x.c b/gp2x/gp2x.c index 7706e41..78e8561 100644 --- a/gp2x/gp2x.c +++ b/gp2x/gp2x.c @@ -44,7 +44,8 @@ static void *gp2x_screens[4]; static int screensel = 0; //static int memdev = 0; -static int sounddev = 0, mixerdev = 0; +static int sounddev = -1, mixerdev = -1, touchdev = -1; +static int touchcal[7] = { 6203, 0, -1501397, 0, -4200, 16132680, 65536 }; void *gp2x_screen; @@ -218,6 +219,36 @@ unsigned long gp2x_joystick_read(int allow_usb_joy) return value; } +typedef struct ucb1x00_ts_event +{ + unsigned short pressure; + unsigned short x; + unsigned short y; + unsigned short pad; + struct timeval stamp; +} UCB1X00_TS_EVENT; + +int gp2x_touchpad_read(int *x, int *y) +{ + UCB1X00_TS_EVENT event; + int retval; + + if (touchdev < 0) return -1; + + retval = read(touchdev, &event, sizeof(event)); + if (retval < 0) { + printf("touch read failed %i %i\n", retval, errno); + return -1; + } + + if (x) *x = (event.x * touchcal[0] + touchcal[2]) >> 16; + if (y) *y = (event.y * touchcal[4] + touchcal[5]) >> 16; + // printf("read %i %i %i\n", event.pressure, *x, *y); + + return event.pressure; +} + + static int s_oldrate = 0, s_oldbits = 0, s_oldstereo = 0; void gp2x_start_sound(int rate, int bits, int stereo) @@ -364,6 +395,18 @@ void gp2x_init(void) /* init usb joys -GnoStiC */ gp2x_usbjoy_init(); + // touchscreen + touchdev = open("/dev/touchscreen/wm97xx", O_RDONLY); + if (touchdev >= 0) { + FILE *pcf = fopen("/etc/pointercal", "r"); + if (pcf) { + fscanf(pcf, "%d %d %d %d %d %d %d", &touchcal[0], &touchcal[1], + &touchcal[2], &touchcal[3], &touchcal[4], &touchcal[5], &touchcal[6]); + fclose(pcf); + } + printf("found touchscreen/wm97xx\n"); + } + /* disable Linux read-ahead */ proc_set("/proc/sys/vm/max-readahead", "0\n"); proc_set("/proc/sys/vm/min-readahead", "0\n"); @@ -388,7 +431,8 @@ void gp2x_deinit(void) munmap((void *)gp2x_memregs, 0x10000); close(memdev); close(mixerdev); - if (sounddev > 0) close(sounddev); + if (sounddev >= 0) close(sounddev); + if (touchdev >= 0) close(touchdev); gp2x_usbjoy_deinit(); diff --git a/gp2x/gp2x.h b/gp2x/gp2x.h index 2d2e535..f9aa851 100644 --- a/gp2x/gp2x.h +++ b/gp2x/gp2x.h @@ -25,8 +25,9 @@ void gp2x_start_sound(int rate, int bits, int stereo); void gp2x_sound_write(void *buff, int len); void gp2x_sound_volume(int l, int r); -/* joy */ +/* input */ unsigned long gp2x_joystick_read(int allow_usb_joy); +int gp2x_touchpad_read(int *x, int *y); /* 940 core */ void Pause940(int yes); diff --git a/linux/gp2x.c b/linux/gp2x.c index c552ad1..ef21a67 100644 --- a/linux/gp2x.c +++ b/linux/gp2x.c @@ -368,6 +368,11 @@ unsigned long gp2x_joystick_read(int allow_usb_joy) return value; } +int gp2x_touchpad_read(int *x, int *y) +{ + return -1; +} + /* 940 */ int crashed_940 = 0; void Pause940(int yes) -- 2.39.2 From df845b39622988a6b98657e5225ee5477dffc720 Mon Sep 17 00:00:00 2001 From: notaz Date: Mon, 7 Jul 2008 19:08:20 +0000 Subject: [PATCH 12/16] readme updated git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@533 be3aeb3a-fb24-0410-a615-afba39da0efa --- base_readme.txt | 50 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/base_readme.txt b/base_readme.txt index 6c8e528..71b2b5e 100644 --- a/base_readme.txt +++ b/base_readme.txt @@ -58,7 +58,6 @@ If you are on 1.5, there is a separate KXploited version for it. Note that this emulator may require some tweaking of configuration settings to run some games well. For Genesis/MegaDrive, if you have any problems (game does not boot, sound is glitchy, broken graphics), try to: - * enable "Accurate timing" (options menu) #ifdef PSP * enable "accurate renderer" #else @@ -122,9 +121,8 @@ SonicCD_03.mp3 Other important stuff --------------------- -* If your Genesis/MD game hangs or has glitches, this is most likely because - "Accurate timing" option is not enabled, or fast renderer is used - (try the accurate one), or Z80 is disabled in "advanced options". +* If your Genesis/MD game has graphical glitches, this is most likely because + "accurate renderer" is not enabled (see options). * Sega/Mega CD: If the game hangs after Sega logo, you may need to enable "better sync" and/or "Scale/Rot. fx" options, found in "Sega/Mega CD options" submenu, and then reset the game. Some other games may also require @@ -140,6 +138,8 @@ Other important stuff Some games (like Snatcher) may hang in certain scenes because of this. Some mp3 rippers/encoders remove silence and beginning/end of audio tracks, what causes audio desyncs and/or mentioned problems. + If you have cue/bin rip, you can use the bin_to_cso_mp3 tool (included with + the emulator) to make a proper iso/mp3 rip. * Sega/Mega CD: If your games hangs at the BIOS screen (with planets shown), you may be using a bad BIOS dump. Try another from a different source. * Some Sega/Mega CD games don't use Z80 for anything, but they leave it active, @@ -215,17 +215,6 @@ pixels wide. This option scales their width to 320 by using simple pixel averaging scaling. Works only when 16bit renderer is enabled. #endif -@@0. "Accurate timing" -This adds some more emulation precision, but slows the emulation down. Without -this option some games do not boot (Red Zone for example), others have sound -problems. This options has no effect for Sega/Mega CD emulation. - -@@0. "Accurate sprites" -This option improves emulation of sprite priorities, it also enables emulation -of sprite collision bit. If you see one sprite being drawn incorrectly above -the other (often seen in Sonic 3D Blast), you can enable this to fix the problem. -This only works with the accurate renderers (see first option). - @@0. "Show FPS" Self-explanatory. Format is XX/YY, where XX is the number of rendered frames and YY is the number of emulated frames per second. @@ -654,9 +643,36 @@ Additional thanks Changelog --------- -1.4x +1.50 + + Added some basic support for Sega Pico, a MegaDrive-based toy. + Added proper support for cue/bin images, including cdda playback. - .cue sheets with iso/cso/mp3/wav files listed in them are also supported. + .cue sheets with iso/cso/mp3/wav files listed in them are now + supported too (but 44kHz restriction still applies). + + Added bin_to_cso_mp3 tool, based on Exophase's bin_to_iso_ogg. + The tool can convert .cue/.bin Sega CD images to .cso/.mp3. + * Changed how scheduling between 68k and z80 is handled. Improves + performance for some games. Credits to Lordus for the idea. + * YM2612 state was not 100% saved, this should be better now. + * Improved renderer performance for shadow/hilight mode. + * Added a hack for YM2612 frequency overflow issue (bleep noises + in Shaq Fu, Spider-Man - The Animated Series (intro music), etc.) + Credits to Nemesis @ spritesmind forum. Works only sound rate + is set to 44kHz. + + Implemented some sprite rendering improvements, as suggested by + Exophase. Games with lots of sprites now perform better. + + Added better idle loop detection, based on Lordus' idea again. + * "accurate timing" option removed, as disabling it no longer + improves performance. + * "accurate sprites" was removed too, the new sprite code can + properly handle sprite priorities in all cases. + * Timers adjusted again. + * Improved .smd detection code. + * ARM: fixed a bug in DrZ80 core, which could cause problems in + some rare cases. + * ARM: fixed a problem of occasional clicks on MP3 music start. + * Minor general optimizations and menu improvements. + * Fixed a bug in Sega CD savestate loader, where the game would + sometimes crash after load. * Fixed a crash of games using eeprom (introduced in 1.40b). 1.40c -- 2.39.2 From 9039861feb457d5cd5935fb7cc86d2a2323649b7 Mon Sep 17 00:00:00 2001 From: notaz Date: Mon, 7 Jul 2008 20:56:24 +0000 Subject: [PATCH 13/16] minor readme adjustments git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@534 be3aeb3a-fb24-0410-a615-afba39da0efa --- base_readme.txt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/base_readme.txt b/base_readme.txt index 71b2b5e..a6586e6 100644 --- a/base_readme.txt +++ b/base_readme.txt @@ -33,7 +33,7 @@ How to make it run ------------------ #ifdef GP2X -Copy PicoDrive.gpe, pico940_v2.bin and mmuhack.o to any place in your filesystem +Copy PicoDrive.gpe, pico940_v3.bin and mmuhack.o to any place in your filesystem (all 3 files must be in the same directory) and run PicoDrive.gpe. Then load a ROM and enjoy! ROMs can be in .smd or .bin format and can be zipped. @@ -107,7 +107,7 @@ mp3pro). ISO files can also be .cso compressed or zipped (but not mp3 files, as they are already compressed). CSO will cause slightly longer loading times, and -is not very good for FMV games. Zipping ISOs is not recommened, as it will +is not very good for FMV games. Zipping ISOs is not recommended, as it will cause very long (several minute) loading times, and make some games unplayable. File naming is similar as with uncompressed ISOs. Example: @@ -650,6 +650,7 @@ Changelog supported too (but 44kHz restriction still applies). + Added bin_to_cso_mp3 tool, based on Exophase's bin_to_iso_ogg. The tool can convert .cue/.bin Sega CD images to .cso/.mp3. + * Greatly improved Sega CD load times. * Changed how scheduling between 68k and z80 is handled. Improves performance for some games. Credits to Lordus for the idea. * YM2612 state was not 100% saved, this should be better now. @@ -661,9 +662,9 @@ Changelog + Implemented some sprite rendering improvements, as suggested by Exophase. Games with lots of sprites now perform better. + Added better idle loop detection, based on Lordus' idea again. - * "accurate timing" option removed, as disabling it no longer + - "accurate timing" option removed, as disabling it no longer improves performance. - * "accurate sprites" was removed too, the new sprite code can + - "accurate sprites" was removed too, the new sprite code can properly handle sprite priorities in all cases. * Timers adjusted again. * Improved .smd detection code. -- 2.39.2 From 425cae19e290633047389c7cc3ecd49e8c4610a9 Mon Sep 17 00:00:00 2001 From: notaz Date: Tue, 8 Jul 2008 18:17:52 +0000 Subject: [PATCH 14/16] minor Makefile adj git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@536 be3aeb3a-fb24-0410-a615-afba39da0efa --- gp2x/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gp2x/Makefile b/gp2x/Makefile index 0fd9feb..62bf697 100644 --- a/gp2x/Makefile +++ b/gp2x/Makefile @@ -164,7 +164,7 @@ clean: tidy $(RM) PicoDrive.gpe tidy: $(RM) $(OBJS) - rm -rf $(DIRS) +# rm -rf $(DIRS) # don't clean, gcda may be there # @make -C ../../cpu/Cyclone/proj -f Makefile.linux clean @@ -245,7 +245,7 @@ $(error need VER) endif endif -rel: PicoDrive.gpe code940/pico940_v2.bin readme.txt PicoDrive.man.txt PicoDrive.png ../game_def.cfg +rel: PicoDrive.gpe code940/pico940_v3.bin readme.txt PicoDrive.man.txt PicoDrive.png ../game_def.cfg zip -9 -j ../../PicoDrive_$(VER).zip $^ mmuhack.o zip -9 -r ../../PicoDrive_$(VER).zip skin -i \*.png -i \*.txt mkdir bin_to_cso_mp3 -- 2.39.2 From 366747cc4b3ac4ccf55960b210476f8ddbdd7358 Mon Sep 17 00:00:00 2001 From: notaz Date: Tue, 8 Jul 2008 19:36:54 +0000 Subject: [PATCH 15/16] minor PSP improvement git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@537 be3aeb3a-fb24-0410-a615-afba39da0efa --- psp/emu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/psp/emu.c b/psp/emu.c index bdf6a6e..e099d58 100644 --- a/psp/emu.c +++ b/psp/emu.c @@ -292,7 +292,8 @@ static void EmuScanPrepare(void) HighCol = (unsigned char *)VRAM_CACHED_STUFF + 8; if (!(Pico.video.reg[1]&8)) HighCol += 8*512; - dynamic_palette = 0; + if (dynamic_palette > 0) + dynamic_palette--; if (Pico.m.dirtyPal) do_pal_update(1, 1); if ((rendstatus & PDRAW_ACC_SPRITES) && !(Pico.video.reg[0xC]&8)) @@ -317,7 +318,7 @@ static int EmuScanSlowEnd(unsigned int num) if (Pico.m.dirtyPal) { if (!dynamic_palette) { do_slowmode_lines(num); - dynamic_palette = 1; + dynamic_palette = 3; // last for 2 more frames } do_pal_update(1, 0); } -- 2.39.2 From 4b811a8abecf3ca8ee0b8a02214982a87d013e2f Mon Sep 17 00:00:00 2001 From: notaz Date: Wed, 9 Jul 2008 19:52:17 +0000 Subject: [PATCH 16/16] PSP sleep mode fixed, hopefully for read; 1.50 release git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@538 be3aeb3a-fb24-0410-a615-afba39da0efa --- base_readme.txt | 3 ++- psp/emu.h | 1 + psp/main.c | 7 ++++--- psp/psp.c | 14 +++++++++++--- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/base_readme.txt b/base_readme.txt index a6586e6..f99a4c0 100644 --- a/base_readme.txt +++ b/base_readme.txt @@ -657,7 +657,7 @@ Changelog * Improved renderer performance for shadow/hilight mode. * Added a hack for YM2612 frequency overflow issue (bleep noises in Shaq Fu, Spider-Man - The Animated Series (intro music), etc.) - Credits to Nemesis @ spritesmind forum. Works only sound rate + Credits to Nemesis @ spritesmind forum. Works only if sound rate is set to 44kHz. + Implemented some sprite rendering improvements, as suggested by Exophase. Games with lots of sprites now perform better. @@ -675,6 +675,7 @@ Changelog * Fixed a bug in Sega CD savestate loader, where the game would sometimes crash after load. * Fixed a crash of games using eeprom (introduced in 1.40b). + * PSP: fixed suspend/resume (hopefully for real). 1.40c * Fixed a problem with sound in Marble Madness. diff --git a/psp/emu.h b/psp/emu.h index 61e4e7a..1ef9450 100644 --- a/psp/emu.h +++ b/psp/emu.h @@ -15,6 +15,7 @@ enum TPicoGameState { PGS_Menu, PGS_RestartRun, PGS_Suspending, + PGS_SuspendAck, }; extern char romFileName[]; diff --git a/psp/main.c b/psp/main.c index 4c7eef6..d970f8a 100644 --- a/psp/main.c +++ b/psp/main.c @@ -12,7 +12,6 @@ #include "../common/emu.h" #include "../common/config.h" #include "../common/lprintf.h" -#include "version.h" #ifdef GPROF #include @@ -32,7 +31,6 @@ void dummy(void) int pico_main(void) { - lprintf("\nPicoDrive v" VERSION " " __DATE__ " " __TIME__ "\n"); psp_init(); emu_prepareDefaultConfig(); @@ -71,8 +69,11 @@ int pico_main(void) break; case PGS_Suspending: - while (engineState == PGS_Suspending) + while (engineState == PGS_Suspending || engineState == PGS_SuspendAck) { + if (engineState == PGS_Suspending) + engineState = PGS_SuspendAck; psp_wait_suspend(); + } break; case PGS_RestartRun: diff --git a/psp/psp.c b/psp/psp.c index fd55b6c..4046e29 100644 --- a/psp/psp.c +++ b/psp/psp.c @@ -20,19 +20,20 @@ #include "psp.h" #include "emu.h" #include "../common/lprintf.h" +#include "version.h" extern int pico_main(void); #ifndef FW15 -PSP_MODULE_INFO("PicoDrive", 0, 1, 40); +PSP_MODULE_INFO("PicoDrive", 0, 1, 50); PSP_HEAP_SIZE_MAX(); int main() { return pico_main(); } /* just a wrapper */ #else -PSP_MODULE_INFO("PicoDrive", 0x1000, 1, 40); +PSP_MODULE_INFO("PicoDrive", 0x1000, 1, 50); PSP_MAIN_THREAD_ATTR(0); int main() @@ -79,16 +80,20 @@ static int exit_callback(int arg1, int arg2, void *common) static int power_callback(int unknown, int pwrflags, void *common) { static int old_state = PGS_Menu; + int i; lprintf("power_callback: flags: 0x%08X\n", pwrflags); /* 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 || pwrflags & PSP_POWER_CB_STANDBY) { - if (engineState != PGS_Suspending) { + if (engineState != PGS_Suspending && engineState != PGS_SuspendAck) { old_state = engineState; engineState = PGS_Suspending; } + for (i = 0; i < 10 && engineState != PGS_SuspendAck; i++) + sceKernelDelayThread(100*1024); + } else if (pwrflags & PSP_POWER_CB_RESUME_COMPLETE) { @@ -129,6 +134,7 @@ void psp_init(void) main_thread_id = sceKernelGetThreadId(); + lprintf("\n%s\n", "PicoDrive v" VERSION " " __DATE__ " " __TIME__); lprintf("running on %08x kernel\n", sceKernelDevkitVersion()), lprintf("entered psp_init, threadId %08x, priority %i\n", main_thread_id, sceKernelGetThreadCurrentPriority()); @@ -304,6 +310,8 @@ typedef struct _log_entry static log_entry *le_root = NULL; #endif +/* strange: if this function leaks memory (before psp_init() call?), + * resume after suspend breaks on 3.90 */ void lprintf(const char *fmt, ...) { va_list vl; -- 2.39.2