X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=Pico%2FPicoInt.h;h=47ba2c9a3e500a54cad21280c20487166e1973f7;hb=7336a99a49268970e0df89d15210b98dd7798f1e;hp=8f328ea8ed00d9f66239097eb6e34b715408e388;hpb=c459aefdad169c97b6fb93a20c1219a76aa07505;p=picodrive.git diff --git a/Pico/PicoInt.h b/Pico/PicoInt.h index 8f328ea..47ba2c9 100644 --- a/Pico/PicoInt.h +++ b/Pico/PicoInt.h @@ -13,7 +13,7 @@ #include "Pico.h" -// to select core, define EMU_C68K, EMU_M68K or EMU_A68K in your makefile +// to select core, define EMU_C68K, EMU_M68K or EMU_A68K in your makefile or project #ifdef __cplusplus extern "C" { @@ -23,10 +23,16 @@ extern "C" { // ----------------------- 68000 CPU ----------------------- #ifdef EMU_C68K #include "../cpu/Cyclone/Cyclone.h" -extern struct Cyclone PicoCpu; -#define SekCyclesLeft PicoCpu.cycles // cycles left for this run -#define SekSetCyclesLeft(c) PicoCpu.cycles=c +extern struct Cyclone PicoCpu, PicoCpuS68k; +#define SekCyclesLeftNoMCD PicoCpu.cycles // cycles left for this run +#define SekCyclesLeft \ + (((PicoMCD&1) && (PicoOpt & 0x2000)) ? (SekCycleAim-SekCycleCnt) : SekCyclesLeftNoMCD) +#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) #endif #ifdef EMU_A68K @@ -54,8 +60,13 @@ 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 m68k_cycles_remaining() +#define SekCyclesLeft \ + (((PicoMCD&1) && (PicoOpt & 0x2000)) ? (SekCycleAim-SekCycleCnt) : SekCyclesLeftNoMCD) +#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) #endif @@ -161,32 +172,81 @@ struct PicoSRAM // MCD #include "cd/cd_sys.h" #include "cd/LC89510.h" +#include "cd/gfx_cd.h" + +struct mcd_pcm +{ + unsigned char control; // reg7 + unsigned char enabled; // reg8 + unsigned char cur_ch; + unsigned char bank; + int pad1; + + struct pcm_chan + { + unsigned char regs[8]; + unsigned int addr; // played sample address + int pad; + } ch[8]; +}; struct mcd_misc { unsigned short hint_vector; unsigned char busreq; - unsigned char pad0; - + unsigned char s68k_pend_ints; + unsigned int state_flags; // emu state: reset_pending, + unsigned int counter75hz; + unsigned short audio_offset; // for savestates: play pointer offset (0-1023) + unsigned char audio_track; // playing audio track # (zero based) + char pad1; + int timer_int3; + unsigned int timer_stopwatch; + int pad[10]; }; typedef struct { - unsigned char bios[0x20000]; - union { + unsigned char bios[0x20000]; // 128K + union { // 512K unsigned char prg_ram[0x80000]; unsigned char prg_ram_b[4][0x20000]; }; - unsigned char word_ram[0x40000]; - unsigned char s68k_regs[0x200]; + union { // 256K + struct { + unsigned char word_ram2M[0x40000]; + unsigned char unused[0x20000]; + }; + struct { + unsigned char unused[0x20000]; + unsigned char word_ram1M[2][0x20000]; + }; + }; + union { // 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; + _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) +// Area.c +int PicoAreaPackCpu(unsigned char *cpu, int is_sub); +int PicoAreaUnpackCpu(unsigned char *cpu, int is_sub); + +// cd/Area.c +int PicoCdSaveState(void *file); +int PicoCdLoadState(void *file); +int PicoCdLoadStateGfx(void *file); // Draw.c int PicoLine(int scan); @@ -198,15 +258,16 @@ void PicoFrameFull(); // Memory.c int PicoInitPc(unsigned int pc); unsigned int CPU_CALL PicoRead32(unsigned int a); -int PicoMemInit(); +void PicoMemSetup(); void PicoMemReset(); -void PicoDasm(int start,int len); +//void PicoDasm(int start,int len); unsigned char z80_read(unsigned short a); unsigned short z80_read16(unsigned short a); void z80_write(unsigned char data, unsigned short a); void z80_write16(unsigned short data, unsigned short a); // cd/Memory.c +void PicoMemSetupCD(void); unsigned char PicoReadCD8 (unsigned int a); unsigned short PicoReadCD16(unsigned int a); unsigned int PicoReadCD32(unsigned int a); @@ -236,6 +297,10 @@ int SekInitS68k(void); int SekResetS68k(void); int SekInterruptS68k(int irq); +// sound/sound.c +extern int PsndLen_exc_cnt; +extern int PsndLen_exc_add; + // VideoPort.c void PicoVideoWrite(unsigned int a,unsigned short d); unsigned int PicoVideoRead(unsigned int a); @@ -244,6 +309,14 @@ unsigned int PicoVideoRead(unsigned int a); 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); + +// cd/Misc.c +void wram_2M_to_1M(unsigned char *m); +void wram_1M_to_2M(unsigned char *m); #ifdef __cplusplus