From 68cba51e206ea6089e8ebc04d7dcd9980bc9575c Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 25 Feb 2007 23:04:33 +0000 Subject: [PATCH] 1.20 release git-svn-id: file:///home/notaz/opt/svn/PicoDrive@57 be3aeb3a-fb24-0410-a615-afba39da0efa --- Pico/Pico.h | 1 + Pico/cd/Memory.c | 38 +++++++++++++------------ Pico/cd/Pico.c | 63 ++++++++++++++++++++++++++++++----------- Pico/cd/pcm.c | 7 +++-- platform/gp2x/emu.c | 12 ++++---- platform/gp2x/menu.c | 18 ++++++------ platform/gp2x/version.h | 2 +- platform/linux/gp2x.c | 5 ++++ 8 files changed, 93 insertions(+), 53 deletions(-) diff --git a/Pico/Pico.h b/Pico/Pico.h index 0d8bcf0c..e7dd52a7 100644 --- a/Pico/Pico.h +++ b/Pico/Pico.h @@ -31,6 +31,7 @@ void mp3_update(int *buffer, int length, int stereo); // enable_ym2612&dac, enable_sn76496, enable_z80, stereo_sound, // alt_renderer, 6button_gamepad, accurate_timing, accurate_sprites, // draw_no_32col_border, external_ym2612, enable_pcm, enable cdda +// enable_cdgfx, cd_perfect_sync extern int PicoOpt; extern int PicoVer; extern int PicoSkipFrame; // skip rendering frame, but still do sound (if enabled) and emulation stuff diff --git a/Pico/cd/Memory.c b/Pico/cd/Memory.c index df015ddd..b6a4a821 100644 --- a/Pico/cd/Memory.c +++ b/Pico/cd/Memory.c @@ -29,6 +29,7 @@ typedef unsigned int u32; //#define __debug_io2 //#define rdprintf dprintf #define rdprintf(...) +//#define wrdprintf dprintf #define wrdprintf(...) // ----------------------------------------------------------------- @@ -698,11 +699,11 @@ u8 PicoReadS68k8(u32 a) } // word RAM (1M area) - if ((a&0xfe0000)==0x0c0000) { // 0c0000-0dffff + if ((a&0xfe0000)==0x0c0000 && (Pico_mcd->s68k_regs[3]&4)) { // 0c0000-0dffff int bank; wrdprintf("s68k_wram1M r8: [%06x] @%06x", a, SekPcS68k); - if (!(Pico_mcd->s68k_regs[3]&4)) - dprintf("s68k_wram1M FIXME: wrong mode"); +// if (!(Pico_mcd->s68k_regs[3]&4)) +// dprintf("s68k_wram1M FIXME: wrong mode"); bank = !(Pico_mcd->s68k_regs[3]&1); d = Pico_mcd->word_ram1M[bank][(a^1)&0x1ffff]; wrdprintf("ret = %02x", (u8)d); @@ -781,11 +782,11 @@ u16 PicoReadS68k16(u32 a) } // word RAM (1M area) - if ((a&0xfe0000)==0x0c0000) { // 0c0000-0dffff + if ((a&0xfe0000)==0x0c0000 && (Pico_mcd->s68k_regs[3]&4)) { // 0c0000-0dffff int bank; wrdprintf("s68k_wram1M r16: [%06x] @%06x", a, SekPcS68k); - if (!(Pico_mcd->s68k_regs[3]&4)) - dprintf("s68k_wram1M FIXME: wrong mode"); +// if (!(Pico_mcd->s68k_regs[3]&4)) +// dprintf("s68k_wram1M FIXME: wrong mode"); bank = !(Pico_mcd->s68k_regs[3]&1); d = *(u16 *)(Pico_mcd->word_ram1M[bank]+(a&0x1fffe)); wrdprintf("ret = %04x", d); @@ -871,11 +872,11 @@ u32 PicoReadS68k32(u32 a) } // word RAM (1M area) - if ((a&0xfe0000)==0x0c0000) { // 0c0000-0dffff + if ((a&0xfe0000)==0x0c0000 && (Pico_mcd->s68k_regs[3]&4)) { // 0c0000-0dffff int bank; wrdprintf("s68k_wram1M r32: [%06x] @%06x", a, SekPcS68k); - if (!(Pico_mcd->s68k_regs[3]&4)) - dprintf("s68k_wram1M FIXME: wrong mode"); +// if (!(Pico_mcd->s68k_regs[3]&4)) +// dprintf("s68k_wram1M FIXME: wrong mode"); bank = !(Pico_mcd->s68k_regs[3]&1); u16 *pm=(u16 *)(Pico_mcd->word_ram1M[bank]+(a&0x1fffe)); d = (pm[0]<<16)|pm[1]; wrdprintf("ret = %08x", d); @@ -972,12 +973,13 @@ void PicoWriteS68k8(u32 a,u8 d) } // word RAM (1M area) - if ((a&0xfe0000)==0x0c0000) { // 0c0000-0dffff + if ((a&0xfe0000)==0x0c0000 && (Pico_mcd->s68k_regs[3]&4)) { // 0c0000-0dffff + // Wing Commander tries to write here in wrong mode int bank; if (d) wrdprintf("s68k_wram1M w8: [%06x] %02x @%06x", a, d, SekPcS68k); - if (!(Pico_mcd->s68k_regs[3]&4)) - dprintf("s68k_wram1M FIXME: wrong mode"); +// if (!(Pico_mcd->s68k_regs[3]&4)) +// dprintf("s68k_wram1M FIXME: wrong mode"); bank = !(Pico_mcd->s68k_regs[3]&1); *(u8 *)(Pico_mcd->word_ram1M[bank]+((a^1)&0x1ffff))=d; return; @@ -1051,12 +1053,12 @@ void PicoWriteS68k16(u32 a,u16 d) } // word RAM (1M area) - if ((a&0xfe0000)==0x0c0000) { // 0c0000-0dffff + if ((a&0xfe0000)==0x0c0000 && (Pico_mcd->s68k_regs[3]&4)) { // 0c0000-0dffff int bank; if (d) wrdprintf("s68k_wram1M w16: [%06x] %04x @%06x", a, d, SekPcS68k); - if (!(Pico_mcd->s68k_regs[3]&4)) - dprintf("s68k_wram1M FIXME: wrong mode"); +// if (!(Pico_mcd->s68k_regs[3]&4)) +// dprintf("s68k_wram1M FIXME: wrong mode"); bank = !(Pico_mcd->s68k_regs[3]&1); *(u16 *)(Pico_mcd->word_ram1M[bank]+(a&0x1fffe))=d; return; @@ -1136,13 +1138,13 @@ void PicoWriteS68k32(u32 a,u32 d) } // word RAM (1M area) - if ((a&0xfe0000)==0x0c0000) { // 0c0000-0dffff + if ((a&0xfe0000)==0x0c0000 && (Pico_mcd->s68k_regs[3]&4)) { // 0c0000-0dffff int bank; u16 *pm; if (d) wrdprintf("s68k_wram1M w32: [%06x] %08x @%06x", a, d, SekPcS68k); - if (!(Pico_mcd->s68k_regs[3]&4)) - dprintf("s68k_wram1M FIXME: wrong mode"); +// if (!(Pico_mcd->s68k_regs[3]&4)) +// dprintf("s68k_wram1M FIXME: wrong mode"); bank = !(Pico_mcd->s68k_regs[3]&1); pm=(u16 *)(Pico_mcd->word_ram1M[bank]+(a&0x1fffe)); pm[0]=(u16)(d>>16); pm[1]=(u16)d; diff --git a/Pico/cd/Pico.c b/Pico/cd/Pico.c index eddd8785..678ef97e 100644 --- a/Pico/cd/Pico.c +++ b/Pico/cd/Pico.c @@ -83,6 +83,46 @@ static __inline void SekRunS68k(int cyc) #endif } +#define PS_STEP_M68K 8 +#define PS_STEP_S68K 13 + +static __inline void SekRunPS(int cyc_m68k, int cyc_s68k) +{ + int cyc_do_m68k, cyc_do_s68k, it=0; + int cyc_done_m68k=0, cyc_done_s68k=0; + SekCycleAim+=cyc_m68k; + SekCycleAimS68k+=cyc_s68k; + cyc_do_m68k=SekCycleAim-SekCycleCnt; + cyc_do_s68k=SekCycleAimS68k-SekCycleCntS68k; + while (cyc_done_m68k < cyc_do_m68k || cyc_done_s68k < cyc_do_s68k) { + it++; + if (cyc_done_m68k < cyc_do_m68k && it*PS_STEP_M68K > cyc_done_m68k) { +#if defined(EMU_C68K) + PicoCpu.cycles = PS_STEP_M68K; + CycloneRun(&PicoCpu); + cyc_done_m68k += PS_STEP_M68K - PicoCpu.cycles; +#elif defined(EMU_M68K) + m68k_set_context(&PicoM68kCPU); + cyc_done_m68k += m68k_execute(PS_STEP_M68K); +#endif + } //else dprintf("m68k skipping it #%i", it); + if (cyc_done_s68k < cyc_do_s68k && it*PS_STEP_S68K > cyc_done_s68k) { +#if defined(EMU_C68K) + PicoCpuS68k.cycles = PS_STEP_S68K; + CycloneRun(&PicoCpuS68k); + cyc_done_s68k += PS_STEP_S68K - PicoCpuS68k.cycles; +#elif defined(EMU_M68K) + m68k_set_context(&PicoS68kCPU); + cyc_done_s68k += m68k_execute(PS_STEP_S68K); +#endif + } //else dprintf("s68k skipping it #%i", it); + } + SekCycleCnt += cyc_done_m68k; + SekCycleCntS68k += cyc_done_s68k; + //dprintf("== end SekRunPS, it=%i ==", it); +} + + static __inline void check_cd_dma(void) { int ddx; @@ -230,23 +270,12 @@ static int PicoFrameHintsMCD(void) // Run scanline: //dprintf("m68k starting exec @ %06x", SekPc); if(Pico.m.dma_bytes) SekCycleCnt+=CheckDMA(); - SekRun(cycles_68k); - if ((Pico_mcd->m.busreq&3) == 1) { // no busreq/no reset -#if 0 - int i; - FILE *f = fopen("prg_ram.bin", "wb"); - for (i = 0; i < 0x80000; i+=2) - { - int tmp = Pico_mcd->prg_ram[i]; - Pico_mcd->prg_ram[i] = Pico_mcd->prg_ram[i+1]; - Pico_mcd->prg_ram[i+1] = tmp; - } - fwrite(Pico_mcd->prg_ram, 1, 0x80000, f); - fclose(f); - exit(1); -#endif - //dprintf("s68k starting exec @ %06x", SekPcS68k); - SekRunS68k(cycles_s68k); + if((PicoOpt & 0x2000) && (Pico_mcd->m.busreq&3) == 1) { + SekRunPS(cycles_68k, cycles_s68k); // "perfect sync" + } else { + SekRun(cycles_68k); + if ((Pico_mcd->m.busreq&3) == 1) // no busreq/no reset + SekRunS68k(cycles_s68k); } if((PicoOpt&4) && Pico.m.z80Run) { diff --git a/Pico/cd/pcm.c b/Pico/cd/pcm.c index 1de04d62..2b818e01 100644 --- a/Pico/cd/pcm.c +++ b/Pico/cd/pcm.c @@ -48,10 +48,11 @@ void pcm_write(unsigned int a, unsigned int d) void pcm_set_rate(int rate) { - double step = 31.8 * 1024.0 / (double) rate; // max <4 @ 8000Hz + float step = 31.8 * 1024.0 / (float) rate; // max <4 @ 8000Hz step *= 256*256/4; g_rate = (unsigned int) step; - printf("g_rate: %08x\n", g_rate); + if (step - (float) g_rate >= 0.5) g_rate++; + printf("g_rate: %f %08x\n", (double)step, g_rate); } @@ -82,7 +83,7 @@ void pcm_update(int *buffer, int length, int stereo) mul_l = ((int)ch->regs[0] * (ch->regs[1] & 0xf)) >> (5+1); // (env * pan) >> 5 mul_r = ((int)ch->regs[0] * (ch->regs[1] >> 4)) >> (5+1); step = ((unsigned int)(*(unsigned short *)&ch->regs[2]) * g_rate) >> 14; // freq step -// printf("step=%i, cstep=%i, mul_l=%i, mul_r=%i, ch=%i, addr=%x, en=%02x\n", +// fprintf(stderr, "step=%i, cstep=%i, mul_l=%i, mul_r=%i, ch=%i, addr=%x, en=%02x\n", // *(unsigned short *)&ch->regs[2], step, mul_l, mul_r, i, addr, Pico_mcd->pcm.enabled); if (!stereo && mul_l < mul_r) mul_l = mul_r; diff --git a/platform/gp2x/emu.c b/platform/gp2x/emu.c index cdb69b75..d9738055 100644 --- a/platform/gp2x/emu.c +++ b/platform/gp2x/emu.c @@ -424,8 +424,6 @@ static void romfname_ext(char *dst, const char *prefix, const char *ext) dst[511-8] = 0; if (dst[strlen(dst)-4] == '.') dst[strlen(dst)-4] = 0; if (ext) strcat(dst, ext); - - printf("romfname_ext: %s\n", dst); } @@ -973,9 +971,9 @@ void emu_forced_frame(void) PicoOpt = po_old; if (!(Pico.video.reg[12]&1)) { - vidCpyM2 = vidCpyM2_40col; + vidCpyM2 = vidCpyM2_32col; clearArea(1); - } else vidCpyM2 = vidCpyM2_32col; + } else vidCpyM2 = vidCpyM2_40col; vidCpyM2((unsigned char *)gp2x_screen+320*8, framebuff+328*8); vidConvCpyRGB32(localPal, Pico.cram, 0x40); @@ -1369,8 +1367,10 @@ int emu_SaveLoadGame(int load, int sram) // make save filename saveFname = emu_GetSaveFName(load, sram, state_slot); if (saveFname == NULL) { - strcpy(noticeMsg, load ? "LOAD FAILED (missing file)" : "SAVE FAILED "); - gettimeofday(¬iceMsgTime, 0); + if (!sram) { + strcpy(noticeMsg, load ? "LOAD FAILED (missing file)" : "SAVE FAILED "); + gettimeofday(¬iceMsgTime, 0); + } return -1; } diff --git a/platform/gp2x/menu.c b/platform/gp2x/menu.c index 9a2914a7..236b6939 100644 --- a/platform/gp2x/menu.c +++ b/platform/gp2x/menu.c @@ -688,9 +688,10 @@ static void draw_cd_menu_options(int menu_sel, char *b_us, char *b_eu, char *b_j gp2x_text_out8(tl_x, y, "USA BIOS: %s", b_us); // 0 gp2x_text_out8(tl_x, (y+=10), "EUR BIOS: %s", b_eu); // 1 gp2x_text_out8(tl_x, (y+=10), "JAP BIOS: %s", b_jp); // 2 - gp2x_text_out8(tl_x, (y+=10), "CD LEDs %s", (currentConfig.EmuOpt &0x400)?"ON":"OFF"); // 3 - gp2x_text_out8(tl_x, (y+=10), "CDDA audio (using mp3s) %s", (currentConfig.PicoOpt&0x800)?"ON":"OFF"); // 4 - gp2x_text_out8(tl_x, (y+=10), "PCM audio %s", (currentConfig.PicoOpt&0x400)?"ON":"OFF"); // 5 + gp2x_text_out8(tl_x, (y+=10), "CD LEDs %s", (currentConfig.EmuOpt &0x0400)?"ON":"OFF"); // 3 + gp2x_text_out8(tl_x, (y+=10), "CDDA audio (using mp3s) %s", (currentConfig.PicoOpt&0x0800)?"ON":"OFF"); // 4 + gp2x_text_out8(tl_x, (y+=10), "PCM audio %s", (currentConfig.PicoOpt&0x0400)?"ON":"OFF"); // 5 + gp2x_text_out8(tl_x, (y+=10), "Better sync (very slow) %s", (currentConfig.PicoOpt&0x2000)?"ON":"OFF"); // 6 gp2x_text_out8(tl_x, (y+=10), "Done"); // draw cursor @@ -706,7 +707,7 @@ static void draw_cd_menu_options(int menu_sel, char *b_us, char *b_eu, char *b_j static void cd_menu_loop_options(void) { - int menu_sel = 0, menu_sel_max = 6; + int menu_sel = 0, menu_sel_max = 7; unsigned long inp = 0; char bios_us[32], bios_eu[32], bios_jp[32], *bios, *p; @@ -733,10 +734,11 @@ static void cd_menu_loop_options(void) if(inp & GP2X_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } if((inp& GP2X_B)||(inp&GP2X_LEFT)||(inp&GP2X_RIGHT)) { // toggleable options switch (menu_sel) { - case 3: currentConfig.EmuOpt ^=0x400; break; - case 4: currentConfig.PicoOpt^=0x800; break; - case 5: currentConfig.PicoOpt^=0x400; break; - case 6: return; + case 3: currentConfig.EmuOpt ^=0x0400; break; + case 4: currentConfig.PicoOpt^=0x0800; break; + case 5: currentConfig.PicoOpt^=0x0400; break; + case 6: currentConfig.PicoOpt^=0x2000; break; + case 7: return; } } if(inp & (GP2X_X|GP2X_A)) return; diff --git a/platform/gp2x/version.h b/platform/gp2x/version.h index 0645b779..eeb782ce 100644 --- a/platform/gp2x/version.h +++ b/platform/gp2x/version.h @@ -1,2 +1,2 @@ -#define VERSION "1.15" +#define VERSION "1.20" diff --git a/platform/linux/gp2x.c b/platform/linux/gp2x.c index 38ab0533..e4e34213 100644 --- a/platform/linux/gp2x.c +++ b/platform/linux/gp2x.c @@ -260,6 +260,11 @@ void gp2x_video_RGB_setscaling(int W, int H) { } +void gp2x_memcpy_buffers(int buffers, void *data, int offset, int len) +{ + memcpy((char *)gp2x_screen + offset, data, len); +} + void gp2x_memcpy_all_buffers(void *data, int offset, int len) { memcpy((char *)gp2x_screen + offset, data, len); -- 2.39.5