X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=Pico%2FPicoInt.h;h=2b802d79b23e8bfebea92fd7d30c463c6bc3bb78;hb=d9153729685381acb0559d8a4fdca47cb839427a;hp=0b0675671a38c26a2329b9210c4981bbfc03f26c;hpb=860c6322c346c8e2ec2a4626e79f26d8b0d23777;p=picodrive.git diff --git a/Pico/PicoInt.h b/Pico/PicoInt.h index 0b06756..2b802d7 100644 --- a/Pico/PicoInt.h +++ b/Pico/PicoInt.h @@ -12,6 +12,9 @@ #include #include "Pico.h" +// +#define USE_POLL_DETECT + // to select core, define EMU_C68K, EMU_M68K or EMU_A68K in your makefile or project @@ -24,10 +27,19 @@ extern "C" { #ifdef EMU_C68K #include "../cpu/Cyclone/Cyclone.h" extern struct Cyclone PicoCpu, PicoCpuS68k; -#define SekCyclesLeft PicoCpu.cycles // cycles left for this run -#define SekSetCyclesLeft(c) PicoCpu.cycles=c +#define SekCyclesLeftNoMCD PicoCpu.cycles // cycles left for this run +#define SekCyclesLeft \ + (((PicoMCD&1) && (PicoOpt & 0x2000)) ? (SekCycleAim-SekCycleCnt) : SekCyclesLeftNoMCD) +#define SekCyclesLeftS68k \ + ((PicoOpt & 0x2000) ? (SekCycleAimS68k-SekCycleCntS68k) : PicoCpuS68k.cycles) +#define SekSetCyclesLeftNoMCD(c) PicoCpu.cycles=c +#define SekSetCyclesLeft(c) { \ + if ((PicoMCD&1) && (PicoOpt & 0x2000)) SekCycleCnt=SekCycleAim-(c); else SekSetCyclesLeftNoMCD(c); \ +} #define SekPc (PicoCpu.pc-PicoCpu.membase) #define SekPcS68k (PicoCpuS68k.pc-PicoCpuS68k.membase) +#define SekSetStop(x) { PicoCpu.stopped=x; if (x) PicoCpu.cycles=0; } +#define SekSetStopS68k(x) { PicoCpuS68k.stopped=x; if (x) PicoCpuS68k.cycles=0; } #endif #ifdef EMU_A68K @@ -55,10 +67,25 @@ extern int m68k_ICount; extern m68ki_cpu_core PicoM68kCPU; // MD's CPU extern m68ki_cpu_core PicoS68kCPU; // Mega CD's CPU #ifndef SekCyclesLeft -#define SekCyclesLeft m68k_cycles_remaining() -#define SekSetCyclesLeft(c) SET_CYCLES(c) +#define SekCyclesLeftNoMCD PicoM68kCPU.cyc_remaining_cycles +#define SekCyclesLeft \ + (((PicoMCD&1) && (PicoOpt & 0x2000)) ? (SekCycleAim-SekCycleCnt) : SekCyclesLeftNoMCD) +#define SekCyclesLeftS68k \ + ((PicoOpt & 0x2000) ? (SekCycleAimS68k-SekCycleCntS68k) : PicoS68kCPU.cyc_remaining_cycles) +#define SekSetCyclesLeftNoMCD(c) SET_CYCLES(c) +#define SekSetCyclesLeft(c) { \ + if ((PicoMCD&1) && (PicoOpt & 0x2000)) SekCycleCnt=SekCycleAim-(c); else SET_CYCLES(c); \ +} #define SekPc m68k_get_reg(&PicoM68kCPU, M68K_REG_PC) #define SekPcS68k m68k_get_reg(&PicoS68kCPU, M68K_REG_PC) +#define SekSetStop(x) { \ + if(x) { SET_CYCLES(0); PicoM68kCPU.stopped=STOP_LEVEL_STOP; } \ + else PicoM68kCPU.stopped=0; \ +} +#define SekSetStopS68k(x) { \ + if(x) { SET_CYCLES(0); PicoS68kCPU.stopped=STOP_LEVEL_STOP; } \ + else PicoS68kCPU.stopped=0; \ +} #endif #endif @@ -81,6 +108,7 @@ extern int SekCycleCntS68k; extern int SekCycleAimS68k; #define SekCyclesResetS68k() {SekCycleCntS68k=SekCycleAimS68k=0;} +#define SekCyclesDoneS68k() (SekCycleAimS68k-SekCyclesLeftS68k) // does not work as expected //extern int z80ExtraCycles; // extra z80 cycles, used when z80 is [en|dis]abled @@ -150,11 +178,11 @@ struct Pico // sram struct PicoSRAM { - unsigned char *data; // actual data - unsigned int start; // start address in 68k address space + unsigned char *data; // actual data + unsigned int start; // start address in 68k address space unsigned int end; - unsigned char resize; // 1=SRAM size changed and needs to be reallocated on PicoReset - unsigned char reg_back; // copy of Pico.m.sram_reg to set after reset + unsigned char resize; // 0c: 1=SRAM size changed and needs to be reallocated on PicoReset + unsigned char reg_back; // copy of Pico.m.sram_reg to set after reset unsigned char changed; unsigned char pad; }; @@ -172,10 +200,10 @@ struct mcd_pcm unsigned char bank; int pad1; - struct pcm_chan + struct pcm_chan // 08, size 0x10 { unsigned char regs[8]; - unsigned int addr; // played sample address + unsigned int addr; // .08: played sample address int pad; } ch[8]; }; @@ -185,24 +213,24 @@ struct mcd_misc unsigned short hint_vector; unsigned char busreq; unsigned char s68k_pend_ints; - unsigned int state_flags; // emu state: reset_pending, + unsigned int state_flags; // 04: emu state: reset_pending, dmna_pending unsigned int counter75hz; - unsigned short audio_offset; // for savestates: play pointer offset (0-1023) + unsigned short audio_offset; // 0c: for savestates: play pointer offset (0-1023) unsigned char audio_track; // playing audio track # (zero based) char pad1; - int timer_int3; + int timer_int3; // 10 unsigned int timer_stopwatch; int pad[10]; }; typedef struct { - unsigned char bios[0x20000]; // 128K - union { // 512K + unsigned char bios[0x20000]; // 000000: 128K + union { // 020000: 512K unsigned char prg_ram[0x80000]; unsigned char prg_ram_b[4][0x20000]; }; - union { // 256K + union { // 0a0000: 256K struct { unsigned char word_ram2M[0x40000]; unsigned char unused[0x20000]; @@ -212,19 +240,19 @@ typedef struct unsigned char word_ram1M[2][0x20000]; }; }; - union { // 64K + union { // 100000: 64K unsigned char pcm_ram[0x10000]; unsigned char pcm_ram_b[0x10][0x1000]; }; - unsigned char bram[0x2000]; // 8K - unsigned char s68k_regs[0x200]; // GA, not CPU regs - struct mcd_pcm pcm; + unsigned char s68k_regs[0x200]; // 110000: GA, not CPU regs + unsigned char bram[0x2000]; // 110200: 8K + struct mcd_misc m; // 112200: misc + struct mcd_pcm pcm; // 112240: _scd_toc TOC; // not to be saved CDD cdd; CDC cdc; _scd scd; Rot_Comp rot_comp; - struct mcd_misc m; } mcd_state; #define Pico_mcd ((mcd_state *)Pico.rom) @@ -257,7 +285,9 @@ void z80_write(unsigned char data, unsigned short a); void z80_write16(unsigned short data, unsigned short a); // cd/Memory.c -void PicoMemSetupCD(); +void PicoMemSetupCD(void); +void PicoMemResetCD(int r3); +void PicoMemResetCDdecode(int r3); unsigned char PicoReadCD8 (unsigned int a); unsigned short PicoReadCD16(unsigned int a); unsigned int PicoReadCD32(unsigned int a); @@ -269,6 +299,7 @@ void PicoWriteCD32(unsigned int a, unsigned int d); extern struct Pico Pico; extern struct PicoSRAM SRam; extern int emustatus; +extern int z80startCycle, z80stopCycle; // in 68k cycles int CheckDMA(void); // cd/Pico.c @@ -281,6 +312,7 @@ int SekInit(void); int SekReset(void); int SekInterrupt(int irq); void SekState(unsigned char *data); +void SekSetRealTAS(int use_real); // cd/Sek.c int SekInitS68k(void); @@ -300,6 +332,7 @@ void SRAMWriteEEPROM(unsigned int d); unsigned int SRAMReadEEPROM(); void SRAMUpdPending(unsigned int a, unsigned int d); void memcpy16(unsigned short *dest, unsigned short *src, int count); +void memcpy16bswap(unsigned short *dest, void *src, int count); void memcpy32(int *dest, int *src, int count); void memset32(int *dest, int c, int count);