// enable_ym2612&dac, enable_sn76496, enable_z80, stereo_sound,\r
// alt_renderer, 6button_gamepad, accurate_timing, accurate_sprites,\r
// draw_no_32col_border, external_ym2612, enable_pcm, enable cdda\r
+// enable_cdgfx, cd_perfect_sync\r
extern int PicoOpt;\r
extern int PicoVer;\r
extern int PicoSkipFrame; // skip rendering frame, but still do sound (if enabled) and emulation stuff\r
//#define __debug_io2\r
//#define rdprintf dprintf\r
#define rdprintf(...)\r
+//#define wrdprintf dprintf\r
#define wrdprintf(...)\r
\r
// -----------------------------------------------------------------\r
}\r
\r
// word RAM (1M area)\r
- if ((a&0xfe0000)==0x0c0000) { // 0c0000-0dffff\r
+ if ((a&0xfe0000)==0x0c0000 && (Pico_mcd->s68k_regs[3]&4)) { // 0c0000-0dffff\r
int bank;\r
wrdprintf("s68k_wram1M r8: [%06x] @%06x", a, SekPcS68k);\r
- if (!(Pico_mcd->s68k_regs[3]&4))\r
- dprintf("s68k_wram1M FIXME: wrong mode");\r
+// if (!(Pico_mcd->s68k_regs[3]&4))\r
+// dprintf("s68k_wram1M FIXME: wrong mode");\r
bank = !(Pico_mcd->s68k_regs[3]&1);\r
d = Pico_mcd->word_ram1M[bank][(a^1)&0x1ffff];\r
wrdprintf("ret = %02x", (u8)d);\r
}\r
\r
// word RAM (1M area)\r
- if ((a&0xfe0000)==0x0c0000) { // 0c0000-0dffff\r
+ if ((a&0xfe0000)==0x0c0000 && (Pico_mcd->s68k_regs[3]&4)) { // 0c0000-0dffff\r
int bank;\r
wrdprintf("s68k_wram1M r16: [%06x] @%06x", a, SekPcS68k);\r
- if (!(Pico_mcd->s68k_regs[3]&4))\r
- dprintf("s68k_wram1M FIXME: wrong mode");\r
+// if (!(Pico_mcd->s68k_regs[3]&4))\r
+// dprintf("s68k_wram1M FIXME: wrong mode");\r
bank = !(Pico_mcd->s68k_regs[3]&1);\r
d = *(u16 *)(Pico_mcd->word_ram1M[bank]+(a&0x1fffe));\r
wrdprintf("ret = %04x", d);\r
}\r
\r
// word RAM (1M area)\r
- if ((a&0xfe0000)==0x0c0000) { // 0c0000-0dffff\r
+ if ((a&0xfe0000)==0x0c0000 && (Pico_mcd->s68k_regs[3]&4)) { // 0c0000-0dffff\r
int bank;\r
wrdprintf("s68k_wram1M r32: [%06x] @%06x", a, SekPcS68k);\r
- if (!(Pico_mcd->s68k_regs[3]&4))\r
- dprintf("s68k_wram1M FIXME: wrong mode");\r
+// if (!(Pico_mcd->s68k_regs[3]&4))\r
+// dprintf("s68k_wram1M FIXME: wrong mode");\r
bank = !(Pico_mcd->s68k_regs[3]&1);\r
u16 *pm=(u16 *)(Pico_mcd->word_ram1M[bank]+(a&0x1fffe)); d = (pm[0]<<16)|pm[1];\r
wrdprintf("ret = %08x", d);\r
}\r
\r
// word RAM (1M area)\r
- if ((a&0xfe0000)==0x0c0000) { // 0c0000-0dffff\r
+ if ((a&0xfe0000)==0x0c0000 && (Pico_mcd->s68k_regs[3]&4)) { // 0c0000-0dffff\r
+ // Wing Commander tries to write here in wrong mode\r
int bank;\r
if (d)\r
wrdprintf("s68k_wram1M w8: [%06x] %02x @%06x", a, d, SekPcS68k);\r
- if (!(Pico_mcd->s68k_regs[3]&4))\r
- dprintf("s68k_wram1M FIXME: wrong mode");\r
+// if (!(Pico_mcd->s68k_regs[3]&4))\r
+// dprintf("s68k_wram1M FIXME: wrong mode");\r
bank = !(Pico_mcd->s68k_regs[3]&1);\r
*(u8 *)(Pico_mcd->word_ram1M[bank]+((a^1)&0x1ffff))=d;\r
return;\r
}\r
\r
// word RAM (1M area)\r
- if ((a&0xfe0000)==0x0c0000) { // 0c0000-0dffff\r
+ if ((a&0xfe0000)==0x0c0000 && (Pico_mcd->s68k_regs[3]&4)) { // 0c0000-0dffff\r
int bank;\r
if (d)\r
wrdprintf("s68k_wram1M w16: [%06x] %04x @%06x", a, d, SekPcS68k);\r
- if (!(Pico_mcd->s68k_regs[3]&4))\r
- dprintf("s68k_wram1M FIXME: wrong mode");\r
+// if (!(Pico_mcd->s68k_regs[3]&4))\r
+// dprintf("s68k_wram1M FIXME: wrong mode");\r
bank = !(Pico_mcd->s68k_regs[3]&1);\r
*(u16 *)(Pico_mcd->word_ram1M[bank]+(a&0x1fffe))=d;\r
return;\r
}\r
\r
// word RAM (1M area)\r
- if ((a&0xfe0000)==0x0c0000) { // 0c0000-0dffff\r
+ if ((a&0xfe0000)==0x0c0000 && (Pico_mcd->s68k_regs[3]&4)) { // 0c0000-0dffff\r
int bank;\r
u16 *pm;\r
if (d)\r
wrdprintf("s68k_wram1M w32: [%06x] %08x @%06x", a, d, SekPcS68k);\r
- if (!(Pico_mcd->s68k_regs[3]&4))\r
- dprintf("s68k_wram1M FIXME: wrong mode");\r
+// if (!(Pico_mcd->s68k_regs[3]&4))\r
+// dprintf("s68k_wram1M FIXME: wrong mode");\r
bank = !(Pico_mcd->s68k_regs[3]&1);\r
pm=(u16 *)(Pico_mcd->word_ram1M[bank]+(a&0x1fffe));\r
pm[0]=(u16)(d>>16); pm[1]=(u16)d;\r
#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;
// 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) {
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);
}
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;
dst[511-8] = 0;\r
if (dst[strlen(dst)-4] == '.') dst[strlen(dst)-4] = 0;\r
if (ext) strcat(dst, ext);\r
-\r
- printf("romfname_ext: %s\n", dst);\r
}\r
\r
\r
PicoOpt = po_old;\r
\r
if (!(Pico.video.reg[12]&1)) {\r
- vidCpyM2 = vidCpyM2_40col;\r
+ vidCpyM2 = vidCpyM2_32col;\r
clearArea(1);\r
- } else vidCpyM2 = vidCpyM2_32col;\r
+ } else vidCpyM2 = vidCpyM2_40col;\r
\r
vidCpyM2((unsigned char *)gp2x_screen+320*8, framebuff+328*8);\r
vidConvCpyRGB32(localPal, Pico.cram, 0x40);\r
// make save filename\r
saveFname = emu_GetSaveFName(load, sram, state_slot);\r
if (saveFname == NULL) {\r
- strcpy(noticeMsg, load ? "LOAD FAILED (missing file)" : "SAVE FAILED ");\r
- gettimeofday(¬iceMsgTime, 0);\r
+ if (!sram) {\r
+ strcpy(noticeMsg, load ? "LOAD FAILED (missing file)" : "SAVE FAILED ");\r
+ gettimeofday(¬iceMsgTime, 0);\r
+ }\r
return -1;\r
}\r
\r
gp2x_text_out8(tl_x, y, "USA BIOS: %s", b_us); // 0\r
gp2x_text_out8(tl_x, (y+=10), "EUR BIOS: %s", b_eu); // 1\r
gp2x_text_out8(tl_x, (y+=10), "JAP BIOS: %s", b_jp); // 2\r
- gp2x_text_out8(tl_x, (y+=10), "CD LEDs %s", (currentConfig.EmuOpt &0x400)?"ON":"OFF"); // 3\r
- gp2x_text_out8(tl_x, (y+=10), "CDDA audio (using mp3s) %s", (currentConfig.PicoOpt&0x800)?"ON":"OFF"); // 4\r
- gp2x_text_out8(tl_x, (y+=10), "PCM audio %s", (currentConfig.PicoOpt&0x400)?"ON":"OFF"); // 5\r
+ gp2x_text_out8(tl_x, (y+=10), "CD LEDs %s", (currentConfig.EmuOpt &0x0400)?"ON":"OFF"); // 3\r
+ gp2x_text_out8(tl_x, (y+=10), "CDDA audio (using mp3s) %s", (currentConfig.PicoOpt&0x0800)?"ON":"OFF"); // 4\r
+ gp2x_text_out8(tl_x, (y+=10), "PCM audio %s", (currentConfig.PicoOpt&0x0400)?"ON":"OFF"); // 5\r
+ gp2x_text_out8(tl_x, (y+=10), "Better sync (very slow) %s", (currentConfig.PicoOpt&0x2000)?"ON":"OFF"); // 6\r
gp2x_text_out8(tl_x, (y+=10), "Done");\r
\r
// draw cursor\r
\r
static void cd_menu_loop_options(void)\r
{\r
- int menu_sel = 0, menu_sel_max = 6;\r
+ int menu_sel = 0, menu_sel_max = 7;\r
unsigned long inp = 0;\r
char bios_us[32], bios_eu[32], bios_jp[32], *bios, *p;\r
\r
if(inp & GP2X_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }\r
if((inp& GP2X_B)||(inp&GP2X_LEFT)||(inp&GP2X_RIGHT)) { // toggleable options\r
switch (menu_sel) {\r
- case 3: currentConfig.EmuOpt ^=0x400; break;\r
- case 4: currentConfig.PicoOpt^=0x800; break;\r
- case 5: currentConfig.PicoOpt^=0x400; break;\r
- case 6: return;\r
+ case 3: currentConfig.EmuOpt ^=0x0400; break;\r
+ case 4: currentConfig.PicoOpt^=0x0800; break;\r
+ case 5: currentConfig.PicoOpt^=0x0400; break;\r
+ case 6: currentConfig.PicoOpt^=0x2000; break;\r
+ case 7: return;\r
}\r
}\r
if(inp & (GP2X_X|GP2X_A)) return;\r
-#define VERSION "1.15"\r
+#define VERSION "1.20"\r
\r
{
}
+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);