f = fopen(path, "rb");\r
if (f == NULL) return NULL;\r
\r
+#ifndef NO_IONBF\r
/* we use our own buffering */\r
setvbuf(f, NULL, _IONBF, 0);\r
+#endif\r
\r
file = malloc(sizeof(*file));\r
if (file == NULL) {\r
#include <string.h>\r
#include "Pico.h"\r
\r
+//\r
+#define USE_POLL_DETECT\r
+\r
\r
// to select core, define EMU_C68K, EMU_M68K or EMU_A68K in your makefile or project\r
\r
unsigned short hint_vector;\r
unsigned char busreq;\r
unsigned char s68k_pend_ints;\r
- unsigned int state_flags; // 04: emu state: reset_pending,\r
+ unsigned int state_flags; // 04: emu state: reset_pending, dmna_pending\r
unsigned int counter75hz;\r
unsigned short audio_offset; // 0c: for savestates: play pointer offset (0-1023)\r
unsigned char audio_track; // playing audio track # (zero based)\r
// -----------------------------------------------------------------\r
\r
// poller detection\r
-#define USE_POLL_DETECT\r
#define POLL_LIMIT 16\r
#define POLL_CYCLES 124\r
// int m68k_poll_addr, m68k_poll_cnt;\r
goto end;\r
case 2:\r
d = (Pico_mcd->s68k_regs[a]<<8) | (Pico_mcd->s68k_regs[a+1]&0xc7);\r
- dprintf("m68k_regs r3: %02x @%06x", (u8)d, SekPcS68k);\r
+ dprintf("m68k_regs r3: %02x @%06x", (u8)d, SekPc);\r
goto end;\r
case 4:\r
d = Pico_mcd->s68k_regs[4]<<8;\r
d ^= 2; // writing 0 to DMNA actually sets it, 1 does nothing\r
} else {\r
//dold &= ~2; // ??\r
+#if 1\r
+ if ((d & 2) && !(dold & 2)) {\r
+ Pico_mcd->m.state_flags |= 2; // we must delay setting DMNA bit (needed for Silpheed)\r
+ d &= ~2;\r
+ }\r
+#else\r
if (d & 2) dold &= ~1; // return word RAM to s68k in 2M mode\r
+#endif\r
}\r
Pico_mcd->s68k_regs[3] = d | dold; // really use s68k side register\r
#ifdef USE_POLL_DETECT\r
return; // only m68k can change WP\r
case 3: {\r
int dold = Pico_mcd->s68k_regs[3];\r
- dprintf("s68k_regs w3: %02x @%06x", (u8)d, SekPc);\r
+ dprintf("s68k_regs w3: %02x @%06x", (u8)d, SekPcS68k);\r
d &= 0x1d;\r
d |= dold&0xc2;\r
if (d&4) {\r
bx lr
-PicoMemResetCDdecode: @r3
- tst r3, #4
+PicoMemResetCDdecode: @reg3
+ tst r0, #4
bxeq lr @ we should not be called in 2M mode
ldr r1, =m_s68k_write8_table
ldr r3, =m_s68k_decode_write_table
extern unsigned char formatted_bram[4*0x10];
+extern unsigned int s68k_poll_adclk;
+
+
+#define dump_ram(ram,fname) \
+{ \
+ int i, d; \
+ FILE *f; \
+\
+ for (i = 0; i < sizeof(ram); i+=2) { \
+ d = (ram[i]<<8) | ram[i+1]; \
+ *(unsigned short *)(ram+i) = d; \
+ } \
+ f = fopen(fname, "wb"); \
+ if (f) { \
+ fwrite(ram, 1, sizeof(ram), f); \
+ fclose(f); \
+ } \
+ for (i = 0; i < sizeof(ram); i+=2) { \
+ d = (ram[i]<<8) | ram[i+1]; \
+ *(unsigned short *)(ram+i) = d; \
+ } \
+}
int PicoInitMCD(void)
void PicoExitMCD(void)
{
End_CD_Driver();
+
+ //dump_ram(Pico_mcd->prg_ram, "prg.bin");
+ //dump_ram(Pico.ram, "ram.bin");
}
int PicoResetMCD(int hard)
// update gfx chip
if (Pico_mcd->rot_comp.Reg_58 & 0x8000)
gfx_cd_update();
+
+ // delayed setting of DMNA bit (needed for Silpheed)
+ if (Pico_mcd->m.state_flags & 2) {
+ Pico_mcd->m.state_flags &= ~2;
+ Pico_mcd->s68k_regs[3] |= 2;
+ Pico_mcd->s68k_regs[3] &= ~1;
+#ifdef USE_POLL_DETECT
+ if ((s68k_poll_adclk&0xfe) == 2) {
+ SekSetStopS68k(0); s68k_poll_adclk = 0;
+ }
+#endif
+ }
}
// Run scanline:
//dprintf("m68k starting exec @ %06x", SekPc);
- if(Pico.m.dma_bytes) SekCycleCnt+=CheckDMA();
- if((PicoOpt & 0x2000) && (Pico_mcd->m.busreq&3) == 1) {
+ if (Pico.m.dma_bytes) SekCycleCnt+=CheckDMA();
+ if ((PicoOpt & 0x2000) && (Pico_mcd->m.busreq&3) == 1) {
SekRunPS(cycles_68k, cycles_s68k); // "better/perfect sync"
} else {
SekRun(cycles_68k);
SekRunS68k(cycles_s68k);
}
- if((PicoOpt&4) && Pico.m.z80Run) {
+ if ((PicoOpt&4) && Pico.m.z80Run) {
Pico.m.z80Run|=2;
z80CycleAim+=cycles_z80;
total_z80+=z80_run(z80CycleAim-total_z80);
}
// draw a frame just after vblank in alternative render mode
- if(!PicoSkipFrame && (PicoOpt&0x10))
+ if (!PicoSkipFrame && (PicoOpt&0x10))
PicoFrameFull();
return 0;
-// TODO...
-// #include <string.h>
#include "../PicoInt.h"
#define rot_comp Pico_mcd->rot_comp
dprintf("gfx_cd_read(%02x) = %04x", a, d);
- return 0;
+ return d;
}
void gfx_cd_write16(unsigned int a, unsigned int d)
} else {\r
if (PicoCDBuffers < 64) PicoCDBuffers = 64;\r
else PicoCDBuffers <<= 1;\r
- if (PicoCDBuffers > 4096) PicoCDBuffers = 4096;\r
+ if (PicoCDBuffers > 8*1024) PicoCDBuffers = 8*1024; // 16M\r
}\r
break;\r
case 7: currentConfig.PicoOpt^=0x1000; break;\r
#define PORT_CONFIG_H
#define CPU_CALL
+#define NO_IONBF
// draw2.c
#define START_ROW 0 // which row of tiles to start rendering at?
// pico.c
#define CAN_HANDLE_240_LINES 1
-//#define dprintf(f,...) printf("%05i:%03i: " f "\n",Pico.m.frame_count,Pico.m.scanline,##__VA_ARGS__)
-#define dprintf(x...)
+#define dprintf(f,...) printf("%05i:%03i: " f "\n",Pico.m.frame_count,Pico.m.scanline,##__VA_ARGS__)
+//#define dprintf(x...)
#endif //PORT_CONFIG_H