1 // Pico Library - Internal Header File
\r
3 // (c) Copyright 2004 Dave, All rights reserved.
\r
4 // (c) Copyright 2006-2008 Grazvydas "notaz" Ignotas, all rights reserved.
\r
5 // Free for non-commercial use.
\r
7 // For commercial use, separate licencing terms must be obtained.
\r
9 #ifndef PICO_INTERNAL_INCLUDED
\r
10 #define PICO_INTERNAL_INCLUDED
\r
16 #include "carthw/carthw.h"
\r
19 #define USE_POLL_DETECT
\r
21 #ifndef PICO_INTERNAL
\r
22 #define PICO_INTERNAL
\r
24 #ifndef PICO_INTERNAL_ASM
\r
25 #define PICO_INTERNAL_ASM
\r
28 // to select core, define EMU_C68K, EMU_M68K or EMU_F68K in your makefile or project
\r
35 // ----------------------- 68000 CPU -----------------------
\r
37 #include "../cpu/Cyclone/Cyclone.h"
\r
38 extern struct Cyclone PicoCpuCM68k, PicoCpuCS68k;
\r
39 #define SekCyclesLeftNoMCD PicoCpuCM68k.cycles // cycles left for this run
\r
40 #define SekCyclesLeft \
\r
41 (((PicoAHW&1) && (PicoOpt & POPT_EN_MCD_PSYNC)) ? (SekCycleAim-SekCycleCnt) : SekCyclesLeftNoMCD)
\r
42 #define SekCyclesLeftS68k \
\r
43 ((PicoOpt & POPT_EN_MCD_PSYNC) ? (SekCycleAimS68k-SekCycleCntS68k) : PicoCpuCS68k.cycles)
\r
44 #define SekSetCyclesLeftNoMCD(c) PicoCpuCM68k.cycles=c
\r
45 #define SekSetCyclesLeft(c) { \
\r
46 if ((PicoAHW&1) && (PicoOpt & POPT_EN_MCD_PSYNC)) SekCycleCnt=SekCycleAim-(c); else SekSetCyclesLeftNoMCD(c); \
\r
48 #define SekPc (PicoCpuCM68k.pc-PicoCpuCM68k.membase)
\r
49 #define SekPcS68k (PicoCpuCS68k.pc-PicoCpuCS68k.membase)
\r
50 #define SekSetStop(x) { PicoCpuCM68k.state_flags&=~1; if (x) { PicoCpuCM68k.state_flags|=1; PicoCpuCM68k.cycles=0; } }
\r
51 #define SekSetStopS68k(x) { PicoCpuCS68k.state_flags&=~1; if (x) { PicoCpuCS68k.state_flags|=1; PicoCpuCS68k.cycles=0; } }
\r
52 #define SekIsStoppedS68k() (PicoCpuCS68k.state_flags&1)
\r
53 #define SekShouldInterrupt (PicoCpuCM68k.irq > (PicoCpuCM68k.srh&7))
\r
55 #define SekInterrupt(i) PicoCpuCM68k.irq=i
\r
58 #define EMU_CORE_DEBUG
\r
63 #include "../cpu/fame/fame.h"
\r
64 extern M68K_CONTEXT PicoCpuFM68k, PicoCpuFS68k;
\r
65 #define SekCyclesLeftNoMCD PicoCpuFM68k.io_cycle_counter
\r
66 #define SekCyclesLeft \
\r
67 (((PicoAHW&1) && (PicoOpt & POPT_EN_MCD_PSYNC)) ? (SekCycleAim-SekCycleCnt) : SekCyclesLeftNoMCD)
\r
68 #define SekCyclesLeftS68k \
\r
69 ((PicoOpt & POPT_EN_MCD_PSYNC) ? (SekCycleAimS68k-SekCycleCntS68k) : PicoCpuFS68k.io_cycle_counter)
\r
70 #define SekSetCyclesLeftNoMCD(c) PicoCpuFM68k.io_cycle_counter=c
\r
71 #define SekSetCyclesLeft(c) { \
\r
72 if ((PicoAHW&1) && (PicoOpt & POPT_EN_MCD_PSYNC)) SekCycleCnt=SekCycleAim-(c); else SekSetCyclesLeftNoMCD(c); \
\r
74 #define SekPc fm68k_get_pc(&PicoCpuFM68k)
\r
75 #define SekPcS68k fm68k_get_pc(&PicoCpuFS68k)
\r
76 #define SekSetStop(x) { \
\r
77 PicoCpuFM68k.execinfo &= ~FM68K_HALTED; \
\r
78 if (x) { PicoCpuFM68k.execinfo |= FM68K_HALTED; PicoCpuFM68k.io_cycle_counter = 0; } \
\r
80 #define SekSetStopS68k(x) { \
\r
81 PicoCpuFS68k.execinfo &= ~FM68K_HALTED; \
\r
82 if (x) { PicoCpuFS68k.execinfo |= FM68K_HALTED; PicoCpuFS68k.io_cycle_counter = 0; } \
\r
84 #define SekIsStoppedS68k() (PicoCpuFS68k.execinfo&FM68K_HALTED)
\r
85 #define SekShouldInterrupt fm68k_would_interrupt()
\r
87 #define SekInterrupt(irq) PicoCpuFM68k.interrupts[0]=irq
\r
90 #define EMU_CORE_DEBUG
\r
95 #include "../cpu/musashi/m68kcpu.h"
\r
96 extern m68ki_cpu_core PicoCpuMM68k, PicoCpuMS68k;
\r
97 #ifndef SekCyclesLeft
\r
98 #define SekCyclesLeftNoMCD PicoCpuMM68k.cyc_remaining_cycles
\r
99 #define SekCyclesLeft \
\r
100 (((PicoAHW&1) && (PicoOpt & POPT_EN_MCD_PSYNC)) ? (SekCycleAim-SekCycleCnt) : SekCyclesLeftNoMCD)
\r
101 #define SekCyclesLeftS68k \
\r
102 ((PicoOpt & POPT_EN_MCD_PSYNC) ? (SekCycleAimS68k-SekCycleCntS68k) : PicoCpuMS68k.cyc_remaining_cycles)
\r
103 #define SekSetCyclesLeftNoMCD(c) SET_CYCLES(c)
\r
104 #define SekSetCyclesLeft(c) { \
\r
105 if ((PicoAHW&1) && (PicoOpt & POPT_EN_MCD_PSYNC)) SekCycleCnt=SekCycleAim-(c); else SET_CYCLES(c); \
\r
107 #define SekPc m68k_get_reg(&PicoCpuMM68k, M68K_REG_PC)
\r
108 #define SekPcS68k m68k_get_reg(&PicoCpuMS68k, M68K_REG_PC)
\r
109 #define SekSetStop(x) { \
\r
110 if(x) { SET_CYCLES(0); PicoCpuMM68k.stopped=STOP_LEVEL_STOP; } \
\r
111 else PicoCpuMM68k.stopped=0; \
\r
113 #define SekSetStopS68k(x) { \
\r
114 if(x) { SET_CYCLES(0); PicoCpuMS68k.stopped=STOP_LEVEL_STOP; } \
\r
115 else PicoCpuMS68k.stopped=0; \
\r
117 #define SekIsStoppedS68k() (PicoCpuMS68k.stopped==STOP_LEVEL_STOP)
\r
118 #define SekShouldInterrupt (CPU_INT_LEVEL > FLAG_INT_MASK)
\r
120 #define SekInterrupt(irq) { \
\r
121 void *oldcontext = m68ki_cpu_p; \
\r
122 m68k_set_context(&PicoCpuMM68k); \
\r
123 m68k_set_irq(irq); \
\r
124 m68k_set_context(oldcontext); \
\r
130 extern int SekCycleCnt; // cycles done in this frame
\r
131 extern int SekCycleAim; // cycle aim
\r
132 extern unsigned int SekCycleCntT; // total cycle counter, updated once per frame
\r
134 #define SekCyclesReset() { \
\r
135 SekCycleCntT+=SekCycleAim; \
\r
136 SekCycleCnt-=SekCycleAim; \
\r
139 #define SekCyclesBurn(c) SekCycleCnt+=c
\r
140 #define SekCyclesDone() (SekCycleAim-SekCyclesLeft) // number of cycles done in this frame (can be checked anywhere)
\r
141 #define SekCyclesDoneT() (SekCycleCntT+SekCyclesDone()) // total nuber of cycles done for this rom
\r
143 #define SekEndRun(after) { \
\r
144 SekCycleCnt -= SekCyclesLeft - after; \
\r
145 if(SekCycleCnt < 0) SekCycleCnt = 0; \
\r
146 SekSetCyclesLeft(after); \
\r
149 extern int SekCycleCntS68k;
\r
150 extern int SekCycleAimS68k;
\r
152 #define SekCyclesResetS68k() { \
\r
153 SekCycleCntS68k-=SekCycleAimS68k; \
\r
154 SekCycleAimS68k=0; \
\r
156 #define SekCyclesDoneS68k() (SekCycleAimS68k-SekCyclesLeftS68k)
\r
158 #ifdef EMU_CORE_DEBUG
\r
159 extern int dbg_irq_level;
\r
160 #undef SekSetCyclesLeftNoMCD
\r
161 #undef SekSetCyclesLeft
\r
162 #undef SekCyclesBurn
\r
164 #undef SekInterrupt
\r
165 #define SekSetCyclesLeftNoMCD(c)
\r
166 #define SekSetCyclesLeft(c)
\r
167 #define SekCyclesBurn(c) c
\r
168 #define SekEndRun(c)
\r
169 #define SekInterrupt(irq) dbg_irq_level=irq
\r
172 // ----------------------- Z80 CPU -----------------------
\r
174 #if defined(_USE_MZ80)
\r
175 #include "../cpu/mz80/mz80.h"
\r
177 #define z80_run(cycles) { mz80GetElapsedTicks(1); mz80_run(cycles) }
\r
178 #define z80_run_nr(cycles) mz80_run(cycles)
\r
179 #define z80_int() mz80int(0)
\r
181 #elif defined(_USE_DRZ80)
\r
182 #include "../cpu/DrZ80/drz80.h"
\r
184 extern struct DrZ80 drZ80;
\r
186 #define z80_run(cycles) ((cycles) - DrZ80Run(&drZ80, cycles))
\r
187 #define z80_run_nr(cycles) DrZ80Run(&drZ80, cycles)
\r
188 #define z80_int() drZ80.Z80_IRQ = 1
\r
190 #define z80_cyclesLeft drZ80.cycles
\r
192 #elif defined(_USE_CZ80)
\r
193 #include "../cpu/cz80/cz80.h"
\r
195 #define z80_run(cycles) Cz80_Exec(&CZ80, cycles)
\r
196 #define z80_run_nr(cycles) Cz80_Exec(&CZ80, cycles)
\r
197 #define z80_int() Cz80_Set_IRQ(&CZ80, 0, HOLD_LINE)
\r
199 #define z80_cyclesLeft (CZ80.ICount - CZ80.ExtraCycles)
\r
203 #define z80_run(cycles) (cycles)
\r
204 #define z80_run_nr(cycles)
\r
209 extern int z80stopCycle; /* in 68k cycles */
\r
210 extern int z80_cycle_cnt; /* 'done' z80 cycles before z80_run() */
\r
211 extern int z80_cycle_aim;
\r
212 extern int z80_scanline;
\r
213 extern int z80_scanline_cycles; /* cycles done until z80_scanline */
\r
215 #define z80_resetCycles() \
\r
216 z80_cycle_cnt = z80_cycle_aim = z80_scanline = z80_scanline_cycles = 0;
\r
218 #define z80_cyclesDone() \
\r
219 (z80_cycle_aim - z80_cyclesLeft)
\r
221 #define cycles_68k_to_z80(x) ((x)*957 >> 11)
\r
223 // ---------------------------------------------------------
\r
225 // main oscillator clock which controls timing
\r
226 #define OSC_NTSC 53693100
\r
227 // seems to be accurate, see scans from http://www.hot.ee/tmeeco/
\r
228 #define OSC_PAL 53203424
\r
232 unsigned char reg[0x20];
\r
233 unsigned int command; // 32-bit Command
\r
234 unsigned char pending; // 1 if waiting for second half of 32-bit command
\r
235 unsigned char type; // Command type (v/c/vsram read/write)
\r
236 unsigned short addr; // Read/Write address
\r
237 int status; // Status bits
\r
238 unsigned char pending_ints; // pending interrupts: ??VH????
\r
239 signed char lwrite_cnt; // VDP write count during active display line
\r
240 unsigned short v_counter; // V-counter
\r
241 unsigned char pad[0x10];
\r
246 unsigned char rotate;
\r
247 unsigned char z80Run;
\r
248 unsigned char padTHPhase[2]; // 02 phase of gamepad TH switches
\r
249 unsigned short scanline; // 04 0 to 261||311
\r
250 char dirtyPal; // 06 Is the palette dirty (1 - change @ this frame, 2 - some time before)
\r
251 unsigned char hardware; // 07 Hardware value for country
\r
252 unsigned char pal; // 08 1=PAL 0=NTSC
\r
253 unsigned char sram_reg; // SRAM mode register. bit0: allow read? bit1: deny write? bit2: EEPROM? bit4: detected? (header or by access)
\r
254 unsigned short z80_bank68k; // 0a
\r
255 unsigned short z80_lastaddr; // this is for Z80 faking
\r
256 unsigned char z80_fakeval;
\r
257 unsigned char z80_reset; // z80 reset held
\r
258 unsigned char padDelay[2]; // 10 gamepad phase time outs, so we count a delay
\r
259 unsigned short eeprom_addr; // EEPROM address register
\r
260 unsigned char eeprom_cycle; // EEPROM SRAM cycle number
\r
261 unsigned char eeprom_slave; // EEPROM slave word for X24C02 and better SRAMs
\r
262 unsigned char prot_bytes[2]; // simple protection faking
\r
263 unsigned short dma_xfers; // 18
\r
264 unsigned char pad[2];
\r
265 unsigned int frame_count; // 1c for movies and idle det
\r
268 // some assembly stuff depend on these, do not touch!
\r
271 unsigned char ram[0x10000]; // 0x00000 scratch ram
\r
272 unsigned short vram[0x8000]; // 0x10000
\r
273 unsigned char zram[0x2000]; // 0x20000 Z80 ram
\r
274 unsigned char ioports[0x10];
\r
275 unsigned int pad[0x3c]; // unused
\r
276 unsigned short cram[0x40]; // 0x22100
\r
277 unsigned short vsram[0x40]; // 0x22180
\r
279 unsigned char *rom; // 0x22200
\r
280 unsigned int romsize; // 0x22204
\r
283 struct PicoVideo video;
\r
289 unsigned char *data; // actual data
\r
290 unsigned int start; // start address in 68k address space
\r
292 unsigned char unused1; // 0c: unused
\r
293 unsigned char unused2;
\r
294 unsigned char changed;
\r
295 unsigned char eeprom_type; // eeprom type: 0: 7bit (24C01), 2: device with 2 addr words (X24C02+), 3: dev with 3 addr words
\r
296 unsigned char eeprom_abits; // eeprom access must be odd addr for: bit0 ~ cl, bit1 ~ out
\r
297 unsigned char eeprom_bit_cl; // bit number for cl
\r
298 unsigned char eeprom_bit_in; // bit number for in
\r
299 unsigned char eeprom_bit_out; // bit number for out
\r
303 #include "cd/cd_sys.h"
\r
304 #include "cd/LC89510.h"
\r
305 #include "cd/gfx_cd.h"
\r
309 unsigned char control; // reg7
\r
310 unsigned char enabled; // reg8
\r
311 unsigned char cur_ch;
\r
312 unsigned char bank;
\r
315 struct pcm_chan // 08, size 0x10
\r
317 unsigned char regs[8];
\r
318 unsigned int addr; // .08: played sample address
\r
325 unsigned short hint_vector;
\r
326 unsigned char busreq;
\r
327 unsigned char s68k_pend_ints;
\r
328 unsigned int state_flags; // 04: emu state: reset_pending, dmna_pending
\r
329 unsigned int counter75hz;
\r
331 int timer_int3; // 10
\r
332 unsigned int timer_stopwatch;
\r
333 unsigned char bcram_reg; // 18: battery-backed RAM cart register
\r
334 unsigned char pad2;
\r
335 unsigned short pad3;
\r
341 unsigned char bios[0x20000]; // 000000: 128K
\r
342 union { // 020000: 512K
\r
343 unsigned char prg_ram[0x80000];
\r
344 unsigned char prg_ram_b[4][0x20000];
\r
346 union { // 0a0000: 256K
\r
348 unsigned char word_ram2M[0x40000];
\r
349 unsigned char unused0[0x20000];
\r
352 unsigned char unused1[0x20000];
\r
353 unsigned char word_ram1M[2][0x20000];
\r
356 union { // 100000: 64K
\r
357 unsigned char pcm_ram[0x10000];
\r
358 unsigned char pcm_ram_b[0x10][0x1000];
\r
360 unsigned char s68k_regs[0x200]; // 110000: GA, not CPU regs
\r
361 unsigned char bram[0x2000]; // 110200: 8K
\r
362 struct mcd_misc m; // 112200: misc
\r
363 struct mcd_pcm pcm; // 112240:
\r
364 _scd_toc TOC; // not to be saved
\r
371 #define Pico_mcd ((mcd_state *)Pico.rom)
\r
375 PICO_INTERNAL void PicoAreaPackCpu(unsigned char *cpu, int is_sub);
\r
376 PICO_INTERNAL void PicoAreaUnpackCpu(unsigned char *cpu, int is_sub);
\r
377 extern void (*PicoLoadStateHook)(void);
\r
380 PICO_INTERNAL int PicoCdSaveState(void *file);
\r
381 PICO_INTERNAL int PicoCdLoadState(void *file);
\r
387 } carthw_state_chunk;
\r
388 extern carthw_state_chunk *carthw_chunks;
\r
389 #define CHUNK_CARTHW 64
\r
392 extern void (*PicoCartUnloadHook)(void);
\r
395 int CM_compareRun(int cyc, int is_sub);
\r
398 PICO_INTERNAL void PicoFrameStart(void);
\r
399 void PicoDrawSync(int to, int blank_last_line);
\r
400 extern int DrawScanline;
\r
401 #define MAX_LINE_SPRITES 29
\r
402 extern unsigned char HighLnSpr[240][3 + MAX_LINE_SPRITES];
\r
405 PICO_INTERNAL void PicoFrameFull();
\r
408 PICO_INTERNAL void PicoInitPc(unsigned int pc);
\r
409 PICO_INTERNAL unsigned int PicoCheckPc(unsigned int pc);
\r
410 PICO_INTERNAL_ASM unsigned int PicoRead32(unsigned int a);
\r
411 PICO_INTERNAL void PicoMemSetup(void);
\r
412 PICO_INTERNAL_ASM void PicoMemReset(void);
\r
413 PICO_INTERNAL void PicoMemResetHooks(void);
\r
414 PICO_INTERNAL int PadRead(int i);
\r
415 PICO_INTERNAL unsigned char z80_read(unsigned short a);
\r
417 PICO_INTERNAL_ASM void z80_write(unsigned char data, unsigned short a);
\r
418 PICO_INTERNAL void z80_write16(unsigned short data, unsigned short a);
\r
419 PICO_INTERNAL unsigned short z80_read16(unsigned short a);
\r
421 PICO_INTERNAL_ASM void z80_write(unsigned int a, unsigned char data);
\r
423 PICO_INTERNAL int ym2612_write_local(unsigned int a, unsigned int d, int is_from_z80);
\r
424 extern unsigned int (*PicoRead16Hook)(unsigned int a, int realsize);
\r
425 extern void (*PicoWrite8Hook) (unsigned int a,unsigned int d,int realsize);
\r
426 extern void (*PicoWrite16Hook)(unsigned int a,unsigned int d,int realsize);
\r
429 PICO_INTERNAL void PicoMemSetupCD(void);
\r
430 PICO_INTERNAL_ASM void PicoMemResetCD(int r3);
\r
431 PICO_INTERNAL_ASM void PicoMemResetCDdecode(int r3);
\r
434 PICO_INTERNAL void PicoMemSetupPico(void);
\r
435 PICO_INTERNAL unsigned int ym2612_read_local_68k(void);
\r
438 extern struct Pico Pico;
\r
439 extern struct PicoSRAM SRam;
\r
440 extern int PicoPadInt[2];
\r
441 extern int emustatus;
\r
442 extern void (*PicoResetHook)(void);
\r
443 extern void (*PicoLineHook)(void);
\r
444 PICO_INTERNAL int CheckDMA(void);
\r
445 PICO_INTERNAL void PicoDetectRegion(void);
\r
446 PICO_INTERNAL void PicoSyncZ80(int m68k_cycles_done);
\r
449 PICO_INTERNAL void PicoInitMCD(void);
\r
450 PICO_INTERNAL void PicoExitMCD(void);
\r
451 PICO_INTERNAL void PicoPowerMCD(void);
\r
452 PICO_INTERNAL int PicoResetMCD(void);
\r
453 PICO_INTERNAL void PicoFrameMCD(void);
\r
456 PICO_INTERNAL void PicoInitPico(void);
\r
457 PICO_INTERNAL void PicoReratePico(void);
\r
460 PICO_INTERNAL void PicoPicoPCMUpdate(short *buffer, int length, int stereo);
\r
461 PICO_INTERNAL void PicoPicoPCMReset(void);
\r
462 PICO_INTERNAL void PicoPicoPCMRerate(int xpcm_rate);
\r
465 PICO_INTERNAL void SekInit(void);
\r
466 PICO_INTERNAL int SekReset(void);
\r
467 PICO_INTERNAL void SekState(int *data);
\r
468 PICO_INTERNAL void SekSetRealTAS(int use_real);
\r
469 void SekStepM68k(void);
\r
470 void SekInitIdleDet(void);
\r
471 void SekFinishIdleDet(void);
\r
474 PICO_INTERNAL void SekInitS68k(void);
\r
475 PICO_INTERNAL int SekResetS68k(void);
\r
476 PICO_INTERNAL int SekInterruptS68k(int irq);
\r
479 PICO_INTERNAL void cdda_start_play();
\r
480 extern short cdda_out_buffer[2*1152];
\r
481 extern int PsndLen_exc_cnt;
\r
482 extern int PsndLen_exc_add;
\r
483 extern int timer_a_next_oflow, timer_a_step; // in z80 cycles
\r
484 extern int timer_b_next_oflow, timer_b_step;
\r
486 void ym2612_sync_timers(int z80_cycles, int mode_old, int mode_new);
\r
487 void ym2612_pack_state(void);
\r
488 void ym2612_unpack_state(void);
\r
490 #define TIMER_NO_OFLOW 0x70000000
\r
491 // tA = 72 * (1024 - NA) / M
\r
492 #define TIMER_A_TICK_ZCYCLES 17203
\r
493 // tB = 1152 * (256 - NA) / M
\r
494 #define TIMER_B_TICK_ZCYCLES 262800 // 275251 broken, see Dai Makaimura
\r
496 #define timers_cycle() \
\r
497 if (timer_a_next_oflow > 0 && timer_a_next_oflow < TIMER_NO_OFLOW) \
\r
498 timer_a_next_oflow -= Pico.m.pal ? 70938*256 : 59659*256; \
\r
499 if (timer_b_next_oflow > 0 && timer_b_next_oflow < TIMER_NO_OFLOW) \
\r
500 timer_b_next_oflow -= Pico.m.pal ? 70938*256 : 59659*256; \
\r
501 ym2612_sync_timers(0, ym2612.OPN.ST.mode, ym2612.OPN.ST.mode);
\r
503 #define timers_reset() \
\r
504 timer_a_next_oflow = timer_b_next_oflow = TIMER_NO_OFLOW; \
\r
505 timer_a_step = TIMER_A_TICK_ZCYCLES * 1024; \
\r
506 timer_b_step = TIMER_B_TICK_ZCYCLES * 256;
\r
510 PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d);
\r
511 PICO_INTERNAL_ASM unsigned int PicoVideoRead(unsigned int a);
\r
512 PICO_INTERNAL_ASM unsigned int PicoVideoRead8(unsigned int a);
\r
513 extern int (*PicoDmaHook)(unsigned int source, int len, unsigned short **srcp, unsigned short **limitp);
\r
516 PICO_INTERNAL void SRAMWriteEEPROM(unsigned int d);
\r
517 PICO_INTERNAL void SRAMUpdPending(unsigned int a, unsigned int d);
\r
518 PICO_INTERNAL_ASM unsigned int SRAMReadEEPROM(void);
\r
519 PICO_INTERNAL_ASM void memcpy16(unsigned short *dest, unsigned short *src, int count);
\r
520 PICO_INTERNAL_ASM void memcpy16bswap(unsigned short *dest, void *src, int count);
\r
521 PICO_INTERNAL_ASM void memcpy32(int *dest, int *src, int count); // 32bit word count
\r
522 PICO_INTERNAL_ASM void memset32(int *dest, int c, int count);
\r
525 PICO_INTERNAL_ASM void wram_2M_to_1M(unsigned char *m);
\r
526 PICO_INTERNAL_ASM void wram_1M_to_2M(unsigned char *m);
\r
529 PICO_INTERNAL void PicoCDBufferRead(void *dest, int lba);
\r
532 PICO_INTERNAL void PsndReset(void);
\r
533 PICO_INTERNAL void PsndDoDAC(int line_to);
\r
534 PICO_INTERNAL int PsndRender(int offset, int length);
\r
535 PICO_INTERNAL void PsndClear(void);
\r
536 // z80 functionality wrappers
\r
537 PICO_INTERNAL void z80_init(void);
\r
538 PICO_INTERNAL void z80_pack(unsigned char *data);
\r
539 PICO_INTERNAL void z80_unpack(unsigned char *data);
\r
540 PICO_INTERNAL void z80_reset(void);
\r
541 PICO_INTERNAL void z80_exit(void);
\r
542 extern int PsndDacLine;
\r
544 // emulation event logging
\r
546 #define EL_LOGMASK 0
\r
549 #define EL_HVCNT 0x00000001 /* hv counter reads */
\r
550 #define EL_SR 0x00000002 /* SR reads */
\r
551 #define EL_INTS 0x00000004 /* ints and acks */
\r
552 #define EL_YMTIMER 0x00000008 /* ym2612 timer stuff */
\r
553 #define EL_INTSW 0x00000010 /* log irq switching on/off */
\r
554 #define EL_ASVDP 0x00000020 /* VDP accesses during active scan */
\r
555 #define EL_VDPDMA 0x00000040 /* VDP DMA transfers and their timing */
\r
556 #define EL_BUSREQ 0x00000080 /* z80 busreq r/w or reset w */
\r
557 #define EL_Z80BNK 0x00000100 /* z80 i/o through bank area */
\r
558 #define EL_SRAMIO 0x00000200 /* sram i/o */
\r
559 #define EL_EEPROM 0x00000400 /* eeprom debug */
\r
560 #define EL_UIO 0x00000800 /* unmapped i/o */
\r
561 #define EL_IO 0x00001000 /* all i/o */
\r
562 #define EL_CDPOLL 0x00002000 /* MCD: log poll detection */
\r
563 #define EL_SVP 0x00004000 /* SVP stuff */
\r
564 #define EL_PICOHW 0x00008000 /* Pico stuff */
\r
565 #define EL_IDLE 0x00010000 /* idle loop det. */
\r
567 #define EL_STATUS 0x40000000 /* status messages */
\r
568 #define EL_ANOMALY 0x80000000 /* some unexpected conditions (during emulation) */
\r
571 extern void lprintf(const char *fmt, ...);
\r
572 #define elprintf(w,f,...) \
\r
574 if ((w) & EL_LOGMASK) \
\r
575 lprintf("%05i:%03i: " f "\n",Pico.m.frame_count,Pico.m.scanline,##__VA_ARGS__); \
\r
577 #elif defined(_MSC_VER)
\r
580 #define elprintf(w,f,...)
\r
586 #define cdprintf(x...)
\r
590 } // End of extern "C"
\r
593 #endif // PICO_INTERNAL_INCLUDED
\r