X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=Pico%2FPicoInt.h;h=c2f8b60fa9eef902fe73753bc580e1bfe5af1960;hb=e53704e691c4de8c53ebe3c54e75a9ca8825bb2b;hp=cbefce26f9e608eef4105ad2546b0c57ba9c887f;hpb=213c16adcb630666f694646645a8ed4bc30c334b;p=picodrive.git diff --git a/Pico/PicoInt.h b/Pico/PicoInt.h index cbefce2..c2f8b60 100644 --- a/Pico/PicoInt.h +++ b/Pico/PicoInt.h @@ -1,7 +1,7 @@ // Pico Library - Internal Header File // (c) Copyright 2004 Dave, All rights reserved. -// (c) Copyright 2006,2007 Grazvydas "notaz" Ignotas, all rights reserved. +// (c) Copyright 2006-2008 Grazvydas "notaz" Ignotas, all rights reserved. // Free for non-commercial use. // For commercial use, separate licencing terms must be obtained. @@ -137,7 +137,7 @@ extern unsigned int SekCycleCntT; // total cycle counter, updated once per frame SekCycleAim=0; \ } #define SekCyclesBurn(c) SekCycleCnt+=c -#define SekCyclesDone() (SekCycleAim-SekCyclesLeft) // nuber of cycles done in this frame (can be checked anywhere) +#define SekCyclesDone() (SekCycleAim-SekCyclesLeft) // number of cycles done in this frame (can be checked anywhere) #define SekCyclesDoneT() (SekCycleCntT+SekCyclesDone()) // total nuber of cycles done for this rom #define SekEndRun(after) { \ @@ -174,10 +174,9 @@ extern int dbg_irq_level; #if defined(_USE_MZ80) #include "../cpu/mz80/mz80.h" -#define z80_run(cycles) mz80_run(cycles) +#define z80_run(cycles) { mz80GetElapsedTicks(1); mz80_run(cycles) } #define z80_run_nr(cycles) mz80_run(cycles) #define z80_int() mz80int(0) -#define z80_resetCycles() mz80GetElapsedTicks(1) #elif defined(_USE_DRZ80) #include "../cpu/DrZ80/drz80.h" @@ -186,11 +185,9 @@ extern struct DrZ80 drZ80; #define z80_run(cycles) ((cycles) - DrZ80Run(&drZ80, cycles)) #define z80_run_nr(cycles) DrZ80Run(&drZ80, cycles) -#define z80_int() { \ - drZ80.z80irqvector = 0xFF; /* default IRQ vector RST opcode */ \ - drZ80.Z80_IRQ = 1; \ -} -#define z80_resetCycles() +#define z80_int() drZ80.Z80_IRQ = 1 + +#define z80_cyclesLeft drZ80.cycles #elif defined(_USE_CZ80) #include "../cpu/cz80/cz80.h" @@ -198,25 +195,32 @@ extern struct DrZ80 drZ80; #define z80_run(cycles) Cz80_Exec(&CZ80, cycles) #define z80_run_nr(cycles) Cz80_Exec(&CZ80, cycles) #define z80_int() Cz80_Set_IRQ(&CZ80, 0, HOLD_LINE) -#define z80_resetCycles() + +#define z80_cyclesLeft (CZ80.ICount - CZ80.ExtraCycles) #else #define z80_run(cycles) (cycles) #define z80_run_nr(cycles) #define z80_int() -#define z80_resetCycles() #endif -// --------------------------------------------------------- +extern int z80stopCycle; /* in 68k cycles */ +extern int z80_cycle_cnt; /* 'done' z80 cycles before z80_run() */ +extern int z80_cycle_aim; +extern int z80_scanline; +extern int z80_scanline_cycles; /* cycles done until z80_scanline */ + +#define z80_resetCycles() \ + z80_cycle_cnt = z80_cycle_aim = z80_scanline = z80_scanline_cycles = 0; + +#define z80_cyclesDone() \ + (z80_cycle_aim - z80_cyclesLeft) + +#define cycles_68k_to_z80(x) ((x)*957 >> 11) -// Pico active hw -#define PAHW_MCD (1<<0) -#define PAHW_32X (1<<1) -#define PAHW_SVP (1<<2) -#define PAHW_PICO (1<<3) -extern int PicoAHW; +// --------------------------------------------------------- // main oscillator clock which controls timing #define OSC_NTSC 53693100 @@ -412,6 +416,7 @@ PICO_INTERNAL unsigned short z80_read16(unsigned short a); #else PICO_INTERNAL_ASM void z80_write(unsigned int a, unsigned char data); #endif +PICO_INTERNAL int ym2612_write_local(unsigned int a, unsigned int d, int is_from_z80); extern unsigned int (*PicoRead16Hook)(unsigned int a, int realsize); extern void (*PicoWrite8Hook) (unsigned int a,unsigned int d,int realsize); extern void (*PicoWrite16Hook)(unsigned int a,unsigned int d,int realsize); @@ -423,16 +428,17 @@ PICO_INTERNAL_ASM void PicoMemResetCDdecode(int r3); // Pico/Memory.c PICO_INTERNAL void PicoMemSetupPico(void); +PICO_INTERNAL unsigned int ym2612_read_local_68k(void); // Pico.c extern struct Pico Pico; extern struct PicoSRAM SRam; extern int emustatus; -extern int z80startCycle, z80stopCycle; // in 68k cycles extern void (*PicoResetHook)(void); extern void (*PicoLineHook)(int count); PICO_INTERNAL int CheckDMA(void); PICO_INTERNAL void PicoDetectRegion(void); +PICO_INTERNAL void PicoSyncZ80(int m68k_cycles_done); // cd/Pico.c PICO_INTERNAL int PicoInitMCD(void); @@ -466,6 +472,27 @@ PICO_INTERNAL void cdda_start_play(); extern short cdda_out_buffer[2*1152]; extern int PsndLen_exc_cnt; extern int PsndLen_exc_add; +extern int timer_a_next_oflow, timer_a_step, timer_a_offset; // in z80 cycles +extern int timer_b_next_oflow, timer_b_step, timer_b_offset; + +void ym2612_sync_timers(int z80_cycles, int mode_old, int mode_new); +void ym2612_pack_state(void); +void ym2612_unpack_state(void); + +#define TIMER_NO_OFLOW 0x70000000 + +#define timers_cycle() \ + if (timer_a_next_oflow > 0 && timer_a_next_oflow < TIMER_NO_OFLOW) \ + timer_a_next_oflow -= Pico.m.pal ? 70938*256 : 59659*256; \ + if (timer_b_next_oflow > 0 && timer_b_next_oflow < TIMER_NO_OFLOW) \ + timer_b_next_oflow -= Pico.m.pal ? 70938*256 : 59659*256; \ + ym2612_sync_timers(0, ym2612.OPN.ST.mode, ym2612.OPN.ST.mode); + +#define timers_reset() \ + timer_a_next_oflow = timer_b_next_oflow = TIMER_NO_OFLOW; \ + timer_a_step = timer_a_offset = 16495 * 1024; \ + timer_b_step = timer_b_offset = 263912 * 256; + // VideoPort.c PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d); @@ -490,7 +517,7 @@ PICO_INTERNAL void PicoCDBufferRead(void *dest, int lba); // sound/sound.c PICO_INTERNAL void PsndReset(void); -PICO_INTERNAL void Psnd_timers_and_dac(int raster); +PICO_INTERNAL void PsndDoDAC(int line_to); PICO_INTERNAL int PsndRender(int offset, int length); PICO_INTERNAL void PsndClear(void); // z80 functionality wrappers @@ -499,7 +526,7 @@ PICO_INTERNAL void z80_pack(unsigned char *data); PICO_INTERNAL void z80_unpack(unsigned char *data); PICO_INTERNAL void z80_reset(void); PICO_INTERNAL void z80_exit(void); - +extern int PsndDacLine; #ifdef __cplusplus } // End of extern "C" @@ -513,7 +540,7 @@ PICO_INTERNAL void z80_exit(void); #define EL_HVCNT 0x00000001 /* hv counter reads */ #define EL_SR 0x00000002 /* SR reads */ #define EL_INTS 0x00000004 /* ints and acks */ -#define EL_YM2612R 0x00000008 /* 68k ym2612 reads */ +#define EL_YMTIMER 0x00000008 /* ym2612 timer stuff */ #define EL_INTSW 0x00000010 /* log irq switching on/off */ #define EL_ASVDP 0x00000020 /* VDP accesses during active scan */ #define EL_VDPDMA 0x00000040 /* VDP DMA transfers and their timing */ @@ -525,6 +552,7 @@ PICO_INTERNAL void z80_exit(void); #define EL_IO 0x00001000 /* all i/o */ #define EL_CDPOLL 0x00002000 /* MCD: log poll detection */ #define EL_SVP 0x00004000 /* SVP stuff */ +#define EL_PICOHW 0x00008000 /* Pico stuff */ #define EL_STATUS 0x40000000 /* status messages */ #define EL_ANOMALY 0x80000000 /* some unexpected conditions (during emulation) */