#define SCANP(x) ScanVar(&Pico.x,sizeof(Pico.x),#x,PmovFile,PmovAction);\r
\r
// Pack the cpu into a common format:\r
-int PicoAreaPackCpu(unsigned char *cpu, int is_sub)\r
+PICO_INTERNAL int PicoAreaPackCpu(unsigned char *cpu, int is_sub)\r
{\r
unsigned int pc=0;\r
\r
return 0;\r
}\r
\r
-int PicoAreaUnpackCpu(unsigned char *cpu, int is_sub)\r
+PICO_INTERNAL int PicoAreaUnpackCpu(unsigned char *cpu, int is_sub)\r
{\r
#ifdef EMU_A68K\r
memcpy(M68000_regs.d,cpu,0x40);\r
\r
static int Skip=0;\r
\r
-void PicoFrameStart()\r
+PICO_INTERNAL void PicoFrameStart(void)\r
{\r
// prepare to do this frame\r
rendstatus = (PicoOpt&0x80)>>5; // accurate sprites\r
Skip=0;\r
}\r
\r
-int PicoLine(int scan)\r
+PICO_INTERNAL int PicoLine(int scan)\r
{\r
int sh;\r
if (Skip>0) { Skip--; return 0; } // Skip rendering lines\r
\r
\r
#include "PicoInt.h"\r
-#include <assert.h>\r
-#ifndef __GNUC__\r
-#pragma warning (disable:4706) // Disable assignment within conditional\r
-#endif\r
\r
// port_config.h include must define these 2 defines:\r
// #define START_ROW 1 // which row of tiles to start rendering at?\r
extern unsigned char *framebuff; // in format (8+320)x(8+224+8) (eights for borders)\r
int currpri = 0;\r
\r
-static int HighCacheA[41*(TILE_ROWS+1)+1+1]; // caches for high layers\r
-static int HighCacheB[41*(TILE_ROWS+1)+1+1];\r
+static int HighCache2A[41*(TILE_ROWS+1)+1+1]; // caches for high layers\r
+static int HighCache2B[41*(TILE_ROWS+1)+1+1];\r
\r
unsigned short *PicoCramHigh=Pico.cram; // pointer to CRAM buff (0x40 shorts), converted to native device color (works only with 16bit for now)\r
void (*PicoPrepareCram)()=0; // prepares PicoCramHigh for renderer to use\r
height=(width>>4)&3; width&=3;\r
\r
xmask=(1<<shift[width ])-1; // X Mask in tiles\r
- ymask=(height<<5)|0x1f; // Y Mask in tiles\r
- if(width == 1) ymask&=0x3f;\r
- else if(width>1) ymask =0x1f;\r
+ ymask=(height<<5)|0x1f; // Y Mask in tiles\r
+ if(width == 1) ymask&=0x3f;\r
+ else if(width>1) ymask =0x1f;\r
\r
// Find name table:\r
if (plane==0) nametab=(pvid->reg[2]&0x38)<< 9; // A\r
if(hvwin==1) { winend|=maxcolc<<16; planeend|=maxcolc<<16; }\r
\r
currpri = 0;\r
- DrawLayerFull(1, HighCacheB, START_ROW, (maxcolc<<16)|END_ROW);\r
+ DrawLayerFull(1, HighCache2B, START_ROW, (maxcolc<<16)|END_ROW);\r
switch(hvwin) {\r
case 4:\r
// fullscreen window\r
DrawWindowFull(START_ROW, (maxcolc<<16)|END_ROW, 0);\r
- HighCacheA[1] = 0;\r
+ HighCache2A[1] = 0;\r
break;\r
\r
case 3:\r
// we have plane A and both v and h windows\r
- DrawLayerFull(0, HighCacheA, planestart, planeend);\r
+ DrawLayerFull(0, HighCache2A, planestart, planeend);\r
DrawWindowFull( winstart&~0xff0000, (winend&~0xff0000)|(maxcolc<<16), 0); // h\r
DrawWindowFull((winstart&~0xff)|START_ROW, (winend&~0xff)|END_ROW, 0); // v\r
break;\r
case 2:\r
case 1:\r
// both window and plane A visible, window is vertical XOR horizontal\r
- DrawLayerFull(0, HighCacheA, planestart, planeend);\r
+ DrawLayerFull(0, HighCache2A, planestart, planeend);\r
DrawWindowFull(winstart, winend, 0);\r
break;\r
\r
default:\r
// fullscreen plane A\r
- DrawLayerFull(0, HighCacheA, START_ROW, (maxcolc<<16)|END_ROW);\r
+ DrawLayerFull(0, HighCache2A, START_ROW, (maxcolc<<16)|END_ROW);\r
break;\r
}\r
DrawAllSpritesFull(0, maxw);\r
\r
#ifdef USE_CACHE\r
- if(HighCacheB[1]) DrawTilesFromCacheF(HighCacheB);\r
- if(HighCacheA[1]) DrawTilesFromCacheF(HighCacheA);\r
+ if(HighCache2B[1]) DrawTilesFromCacheF(HighCache2B);\r
+ if(HighCache2A[1]) DrawTilesFromCacheF(HighCache2A);\r
switch(hvwin) {\r
case 4:\r
// fullscreen window\r
}\r
\r
\r
-void PicoFrameFull()\r
+PICO_INTERNAL void PicoFrameFull()\r
{\r
// prepare cram?\r
if(PicoPrepareCram) PicoPrepareCram();\r
\r
#include "PicoInt.h"\r
\r
-#include "sound/sound.h"\r
#include "sound/ym2612.h"\r
#include "sound/sn76496.h"\r
\r
+#ifndef UTYPES_DEFINED\r
typedef unsigned char u8;\r
typedef unsigned short u16;\r
typedef unsigned int u32;\r
+#define UTYPES_DEFINED\r
+#endif\r
\r
extern unsigned int lastSSRamWrite; // used by serial SRAM code\r
\r
}\r
\r
\r
-int PicoInitPc(u32 pc)\r
+PICO_INTERNAL int PicoInitPc(u32 pc)\r
{\r
PicoCheckPc(pc);\r
return 0;\r
}\r
\r
#ifndef _ASM_MEMORY_C\r
-void PicoMemReset()\r
+PICO_INTERNAL_ASM void PicoMemReset(void)\r
{\r
}\r
#endif\r
// Read Rom and read Ram\r
\r
#ifndef _ASM_MEMORY_C\r
-u32 CPU_CALL PicoRead8(u32 a)\r
+PICO_INTERNAL_ASM u32 CPU_CALL PicoRead8(u32 a)\r
{\r
u32 d=0;\r
\r
return d;\r
}\r
\r
-u32 CPU_CALL PicoRead16(u32 a)\r
+PICO_INTERNAL_ASM u32 CPU_CALL PicoRead16(u32 a)\r
{\r
u32 d=0;\r
\r
return d;\r
}\r
\r
-u32 CPU_CALL PicoRead32(u32 a)\r
+PICO_INTERNAL_ASM u32 CPU_CALL PicoRead32(u32 a)\r
{\r
u32 d=0;\r
\r
\r
\r
// -----------------------------------------------------------------\r
-void PicoMemSetup()\r
+PICO_INTERNAL void PicoMemSetup(void)\r
{\r
#ifdef EMU_C68K\r
// Setup memory callbacks:\r
// -----------------------------------------------------------------\r
// z80 memhandlers\r
\r
-unsigned char z80_read(unsigned short a)\r
+PICO_INTERNAL unsigned char z80_read(unsigned short a)\r
{\r
u8 ret = 0;\r
\r
return ret;\r
}\r
\r
-unsigned short z80_read16(unsigned short a)\r
+PICO_INTERNAL unsigned short z80_read16(unsigned short a)\r
{\r
//dprintf("z80_read16");\r
\r
return (u16) ( (u16)z80_read(a) | ((u16)z80_read((u16)(a+1))<<8) );\r
}\r
\r
-void z80_write(unsigned char data, unsigned short a)\r
+PICO_INTERNAL_ASM void z80_write(unsigned char data, unsigned short a)\r
{\r
//if (a<0x4000)\r
// dprintf("z80 w8 : %06x, %02x @%04x", a, data, mz80GetRegisterValue(NULL, 0));\r
if (a<0x4000) { Pico.zram[a&0x1fff]=data; return; }\r
}\r
\r
-void z80_write16(unsigned short data, unsigned short a)\r
+PICO_INTERNAL void z80_write16(unsigned short data, unsigned short a)\r
{\r
//dprintf("z80_write16");\r
\r
// common code for Memory.c and cd/Memory.c
// (c) Copyright 2006-2007, Grazvydas "notaz" Ignotas
+#ifndef UTYPES_DEFINED
+typedef unsigned char u8;
+typedef unsigned short u16;
+typedef unsigned int u32;
+#define UTYPES_DEFINED
+#endif
+
+#ifdef _ASM_MEMORY_C
+u32 OtherRead16End(u32 a, int realsize);
+#endif
+#ifdef _ASM_CD_MEMORY_C
+static void OtherWrite8End(u32 a,u32 d,int realsize);
+#endif
+
static int PadRead(int i)
{
int pad=0,value=0,TH;
\r
// sram_reg: LAtd sela (L=pending SCL, A=pending SDA, t=type(1==uses 0x200000 for SCL and 2K bytes),\r
// d=SRAM was detected (header or by access), s=started, e=save is EEPROM, l=old SCL, a=old SDA)\r
-void SRAMWriteEEPROM(unsigned int d) // ???? ??la (l=SCL, a=SDA)\r
+PICO_INTERNAL void SRAMWriteEEPROM(unsigned int d) // ???? ??la (l=SCL, a=SDA)\r
{\r
unsigned int sreg = Pico.m.sram_reg, saddr = Pico.m.sram_addr, scyc = Pico.m.sram_cycle, ssa = Pico.m.sram_slave;\r
\r
Pico.m.sram_slave= (unsigned char) ssa;\r
}\r
\r
-unsigned int SRAMReadEEPROM()\r
+PICO_INTERNAL_ASM unsigned int SRAMReadEEPROM(void)\r
{\r
unsigned int shift, d=0;\r
unsigned int sreg, saddr, scyc, ssa;\r
return d;\r
}\r
\r
-void SRAMUpdPending(unsigned int a, unsigned int d)\r
+PICO_INTERNAL void SRAMUpdPending(unsigned int a, unsigned int d)\r
{\r
unsigned int sreg = Pico.m.sram_reg;\r
\r
\r
\r
#ifndef _ASM_MISC_C\r
-void memcpy16(unsigned short *dest, unsigned short *src, int count)\r
+PICO_INTERNAL_ASM void memcpy16(unsigned short *dest, unsigned short *src, int count)\r
{\r
while (count--)\r
*dest++ = *src++;\r
}\r
\r
\r
-void memcpy16bswap(unsigned short *dest, void *src, int count)\r
+PICO_INTERNAL_ASM void memcpy16bswap(unsigned short *dest, void *src, int count)\r
{\r
unsigned char *src_ = src;\r
\r
}\r
\r
\r
-void memcpy32(int *dest, int *src, int count)\r
+PICO_INTERNAL_ASM void memcpy32(int *dest, int *src, int count)\r
{\r
while (count--)\r
*dest++ = *src++;\r
}\r
\r
\r
-void memset32(int *dest, int c, int count)\r
+PICO_INTERNAL_ASM void memset32(int *dest, int c, int count)\r
{\r
while (count--)\r
*dest++ = c;\r
-unsigned short PicoRead16(unsigned int a);
+unsigned int PicoRead16(unsigned int a);
void PicoWrite16(unsigned int a, unsigned short d);
\r
\r
#include "PicoInt.h"\r
-#include "sound/sound.h"\r
#include "sound/ym2612.h"\r
\r
int PicoVer=0x0110;\r
(488<<8)/9, (488<<8)/18, (488<<8)/17, (488<<8)/9\r
};\r
\r
-//static\r
-int CheckDMA(void)\r
+\r
+PICO_INTERNAL int CheckDMA(void)\r
{\r
int burn = 0, bytes_can = 0, dma_op = Pico.video.reg[0x17]>>6; // see gens for 00 and 01 modes\r
int bytes = Pico.m.dma_bytes;\r
#ifndef PICO_H\r
#define PICO_H\r
\r
+#include <stdio.h>\r
+\r
// port-specific compile-time settings\r
#include <port_config.h>\r
\r
extern void (*PicoMessage)(const char *msg); // callback to output text message from emu\r
\r
// cd/Pico.c\r
-int PicoFrameMCD(void);\r
extern void (*PicoMCDopenTray)(void);\r
extern int (*PicoMCDcloseTray)(void);\r
-\r
extern int PicoCDBuffers;\r
\r
// Area.c\r
extern areaclose *areaClose;\r
extern void (*PicoStateProgressCB)(const char *str);\r
\r
+// cd/Area.c\r
+int PicoCdLoadStateGfx(void *file);\r
+\r
// cd/buffering.c\r
void PicoCDBufferInit(void);\r
void PicoCDBufferFree(void);\r
\r
+// cd/cd_sys.c\r
+int Insert_CD(char *iso_name, int is_bin);\r
+void Stop_CD(void); // releases all resources taken when CD game was started.\r
+\r
// Cart.c\r
typedef enum\r
{\r
// sound.c\r
extern int PsndRate,PsndLen;\r
extern short *PsndOut;\r
-void sound_reset();\r
void sound_rerate(int preserve_state);\r
-void z80_pack(unsigned char *data);\r
-void z80_unpack(unsigned char *data);\r
-void z80_reset();\r
\r
// Utils.c\r
extern int PicuAnd;\r
-// Pico Library - Header File\r
+// Pico Library - Internal Header File\r
\r
// (c) Copyright 2004 Dave, All rights reserved.\r
// (c) Copyright 2006,2007 Grazvydas "notaz" Ignotas, all rights reserved.\r
\r
// For commercial use, separate licencing terms must be obtained.\r
\r
+#ifndef PICO_INTERNAL_INCLUDED\r
+#define PICO_INTERNAL_INCLUDED\r
\r
#include <stdio.h>\r
#include <stdlib.h>\r
//\r
#define USE_POLL_DETECT\r
\r
+#ifndef PICO_INTERNAL\r
+#define PICO_INTERNAL\r
+#endif\r
+#ifndef PICO_INTERNAL_ASM\r
+#define PICO_INTERNAL_ASM\r
+#endif\r
\r
// to select core, define EMU_C68K, EMU_M68K or EMU_A68K in your makefile or project\r
\r
#define Pico_mcd ((mcd_state *)Pico.rom)\r
\r
// Area.c\r
-int PicoAreaPackCpu(unsigned char *cpu, int is_sub);\r
-int PicoAreaUnpackCpu(unsigned char *cpu, int is_sub);\r
+PICO_INTERNAL int PicoAreaPackCpu(unsigned char *cpu, int is_sub);\r
+PICO_INTERNAL int PicoAreaUnpackCpu(unsigned char *cpu, int is_sub);\r
\r
// cd/Area.c\r
-int PicoCdSaveState(void *file);\r
-int PicoCdLoadState(void *file);\r
-int PicoCdLoadStateGfx(void *file);\r
+PICO_INTERNAL int PicoCdSaveState(void *file);\r
+PICO_INTERNAL int PicoCdLoadState(void *file);\r
\r
// Draw.c\r
-int PicoLine(int scan);\r
-void PicoFrameStart();\r
+PICO_INTERNAL int PicoLine(int scan);\r
+PICO_INTERNAL void PicoFrameStart(void);\r
\r
// Draw2.c\r
-void PicoFrameFull();\r
+PICO_INTERNAL void PicoFrameFull();\r
\r
// Memory.c\r
-int PicoInitPc(unsigned int pc);\r
-unsigned int CPU_CALL PicoRead32(unsigned int a);\r
-void PicoMemSetup();\r
-void PicoMemReset();\r
-//void PicoDasm(int start,int len);\r
-unsigned char z80_read(unsigned short a);\r
-unsigned short z80_read16(unsigned short a);\r
-void z80_write(unsigned char data, unsigned short a);\r
-void z80_write16(unsigned short data, unsigned short a);\r
+PICO_INTERNAL int PicoInitPc(unsigned int pc);\r
+PICO_INTERNAL_ASM unsigned int CPU_CALL PicoRead32(unsigned int a);\r
+PICO_INTERNAL void PicoMemSetup(void);\r
+PICO_INTERNAL_ASM void PicoMemReset(void);\r
+PICO_INTERNAL unsigned char z80_read(unsigned short a);\r
+PICO_INTERNAL unsigned short z80_read16(unsigned short a);\r
+PICO_INTERNAL_ASM void z80_write(unsigned char data, unsigned short a);\r
+PICO_INTERNAL void z80_write16(unsigned short data, unsigned short a);\r
\r
// cd/Memory.c\r
-void PicoMemSetupCD(void);\r
-void PicoMemResetCD(int r3);\r
-void PicoMemResetCDdecode(int r3);\r
-unsigned char PicoReadCD8 (unsigned int a);\r
-unsigned short PicoReadCD16(unsigned int a);\r
-unsigned int PicoReadCD32(unsigned int a);\r
-void PicoWriteCD8 (unsigned int a, unsigned char d);\r
-void PicoWriteCD16(unsigned int a, unsigned short d);\r
-void PicoWriteCD32(unsigned int a, unsigned int d);\r
+PICO_INTERNAL void PicoMemSetupCD(void);\r
+PICO_INTERNAL_ASM void PicoMemResetCD(int r3);\r
+PICO_INTERNAL_ASM void PicoMemResetCDdecode(int r3);\r
\r
// Pico.c\r
extern struct Pico Pico;\r
extern struct PicoSRAM SRam;\r
extern int emustatus;\r
extern int z80startCycle, z80stopCycle; // in 68k cycles\r
-int CheckDMA(void);\r
+PICO_INTERNAL int CheckDMA(void);\r
\r
// cd/Pico.c\r
-int PicoInitMCD(void);\r
-void PicoExitMCD(void);\r
-int PicoResetMCD(int hard);\r
+PICO_INTERNAL int PicoInitMCD(void);\r
+PICO_INTERNAL int PicoResetMCD(int hard);\r
+PICO_INTERNAL int PicoFrameMCD(void);\r
\r
// Sek.c\r
-int SekInit(void);\r
-int SekReset(void);\r
-int SekInterrupt(int irq);\r
-void SekState(unsigned char *data);\r
-void SekSetRealTAS(int use_real);\r
+PICO_INTERNAL int SekInit(void);\r
+PICO_INTERNAL int SekReset(void);\r
+PICO_INTERNAL int SekInterrupt(int irq);\r
+PICO_INTERNAL void SekState(unsigned char *data);\r
+PICO_INTERNAL void SekSetRealTAS(int use_real);\r
\r
// cd/Sek.c\r
-int SekInitS68k(void);\r
-int SekResetS68k(void);\r
-int SekInterruptS68k(int irq);\r
+PICO_INTERNAL int SekInitS68k(void);\r
+PICO_INTERNAL int SekResetS68k(void);\r
+PICO_INTERNAL int SekInterruptS68k(int irq);\r
\r
// sound/sound.c\r
extern int PsndLen_exc_cnt;\r
extern int PsndLen_exc_add;\r
\r
// VideoPort.c\r
-void PicoVideoWrite(unsigned int a,unsigned short d);\r
-unsigned int PicoVideoRead(unsigned int a);\r
+PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d);\r
+PICO_INTERNAL_ASM unsigned int PicoVideoRead(unsigned int a);\r
\r
// Misc.c\r
-void SRAMWriteEEPROM(unsigned int d);\r
-unsigned int SRAMReadEEPROM();\r
-void SRAMUpdPending(unsigned int a, unsigned int d);\r
-void memcpy16(unsigned short *dest, unsigned short *src, int count);\r
-void memcpy16bswap(unsigned short *dest, void *src, int count);\r
-void memcpy32(int *dest, int *src, int count); // 32bit word count\r
-void memset32(int *dest, int c, int count);\r
+PICO_INTERNAL void SRAMWriteEEPROM(unsigned int d);\r
+PICO_INTERNAL void SRAMUpdPending(unsigned int a, unsigned int d);\r
+PICO_INTERNAL_ASM unsigned int SRAMReadEEPROM(void);\r
+PICO_INTERNAL_ASM void memcpy16(unsigned short *dest, unsigned short *src, int count);\r
+PICO_INTERNAL_ASM void memcpy16bswap(unsigned short *dest, void *src, int count);\r
+PICO_INTERNAL_ASM void memcpy32(int *dest, int *src, int count); // 32bit word count\r
+PICO_INTERNAL_ASM void memset32(int *dest, int c, int count);\r
\r
// cd/Misc.c\r
-void wram_2M_to_1M(unsigned char *m);\r
-void wram_1M_to_2M(unsigned char *m);\r
+PICO_INTERNAL_ASM void wram_2M_to_1M(unsigned char *m);\r
+PICO_INTERNAL_ASM void wram_1M_to_2M(unsigned char *m);\r
+\r
+// cd/buffering.c\r
+PICO_INTERNAL void PicoCDBufferRead(void *dest, int lba);\r
+\r
+// sound/sound.c\r
+PICO_INTERNAL void sound_reset(void);\r
+PICO_INTERNAL void sound_timers_and_dac(int raster);\r
+PICO_INTERNAL int sound_render(int offset, int length);\r
+PICO_INTERNAL void sound_clear(void);\r
+// z80 functionality wrappers\r
+PICO_INTERNAL void z80_init(void);\r
+PICO_INTERNAL void z80_resetCycles(void);\r
+PICO_INTERNAL void z80_int(void);\r
+PICO_INTERNAL int z80_run(int cycles);\r
+PICO_INTERNAL void z80_pack(unsigned char *data);\r
+PICO_INTERNAL void z80_unpack(unsigned char *data);\r
+PICO_INTERNAL void z80_reset(void);\r
+PICO_INTERNAL void z80_exit(void);\r
\r
\r
#ifdef __cplusplus\r
} // End of extern "C"\r
#endif\r
+\r
+#endif // PICO_INTERNAL_INCLUDED\r
+\r
\r
\r
\r
-int SekInit()\r
+PICO_INTERNAL int SekInit()\r
{\r
#ifdef EMU_C68K\r
CycloneInit();\r
}\r
\r
// Reset the 68000:\r
-int SekReset()\r
+PICO_INTERNAL int SekReset()\r
{\r
if (Pico.rom==NULL) return 1;\r
\r
}\r
\r
\r
-int SekInterrupt(int irq)\r
+PICO_INTERNAL int SekInterrupt(int irq)\r
{\r
#if defined(EMU_C68K) && defined(EMU_M68K)\r
{\r
//int SekPc() { return M68000_regs.pc; }\r
//int SekPc() { return m68k_get_reg(NULL, M68K_REG_PC); }\r
\r
-void SekState(unsigned char *data)\r
+PICO_INTERNAL void SekState(unsigned char *data)\r
{\r
#ifdef EMU_C68K\r
memcpy(data,PicoCpu.d,0x44);\r
#endif\r
}\r
\r
-void SekSetRealTAS(int use_real)\r
+PICO_INTERNAL void SekSetRealTAS(int use_real)\r
{\r
#ifdef EMU_C68K\r
CycloneSetRealTAS(use_real);\r
extern const unsigned short vcounts[];\r
extern int rendstatus;\r
\r
+#ifndef UTYPES_DEFINED\r
typedef unsigned char u8;\r
typedef unsigned short u16;\r
+typedef unsigned int u32;\r
+#define UTYPES_DEFINED\r
+#endif\r
\r
\r
static __inline void AutoIncrement()\r
if (cmd&0x80) CommandDma();\r
}\r
\r
-void PicoVideoWrite(unsigned int a,unsigned short d)\r
+PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d)\r
{\r
struct PicoVideo *pvid=&Pico.video;\r
\r
}\r
}\r
\r
-unsigned int PicoVideoRead(unsigned int a)\r
+PICO_INTERNAL_ASM unsigned int PicoVideoRead(unsigned int a)\r
{\r
unsigned int d=0;\r
\r
if (PicoStateProgressCB) PicoStateProgressCB(chunk_names[name]); \
if (!write_chunk(name, sizeof(buff), &buff, file)) return 1;
-int PicoCdSaveState(void *file)
+PICO_INTERNAL int PicoCdSaveState(void *file)
{
unsigned char buff[0x60];
void *ym2612_regs = YM2612GetRegs();
#define CHECKED_READ_BUFF(buff) CHECKED_READ2(sizeof(buff), &buff);
-int PicoCdLoadState(void *file)
+PICO_INTERNAL int PicoCdLoadState(void *file)
{
unsigned char buff[0x60];
int ver, len;
}\r
\r
\r
-void LC89510_Reset(void)\r
+PICO_INTERNAL void LC89510_Reset(void)\r
{\r
CDD_Reset();\r
CDC_Reset();\r
}\r
\r
\r
-void Update_CDC_TRansfer(int which)\r
+PICO_INTERNAL void Update_CDC_TRansfer(int which)\r
{\r
unsigned int DMA_Adr, dep, length;\r
unsigned short *dest;\r
}\r
\r
\r
-unsigned short Read_CDC_Host(int is_sub)\r
+PICO_INTERNAL_ASM unsigned short Read_CDC_Host(int is_sub)\r
{\r
int addr;\r
\r
}\r
\r
\r
-void CDC_Update_Header(void)\r
+PICO_INTERNAL void CDC_Update_Header(void)\r
{\r
if (Pico_mcd->cdc.CTRL.B.B1 & 0x01) // Sub-Header wanted ?\r
{\r
}\r
\r
\r
-unsigned char CDC_Read_Reg(void)\r
+PICO_INTERNAL unsigned char CDC_Read_Reg(void)\r
{\r
unsigned char ret;\r
\r
}\r
\r
\r
-void CDC_Write_Reg(unsigned char Data)\r
+PICO_INTERNAL void CDC_Write_Reg(unsigned char Data)\r
{\r
cdprintf("CDC write reg%02d = %.2X", Pico_mcd->s68k_regs[5] & 0xF, Data);\r
\r
return d + (d >> 8);\r
}\r
\r
-void CDD_Export_Status(void)\r
+PICO_INTERNAL void CDD_Export_Status(void)\r
{\r
unsigned int csum;\r
\r
}\r
\r
\r
-void CDD_Import_Command(void)\r
+PICO_INTERNAL void CDD_Import_Command(void)\r
{\r
// cdprintf("CDD importing command\n");\r
cdprintf("in: Command=%.4X, Minute=%.4X, Second=%.4X, Frame=%.4X Checksum=%.4X",\r
} CDD;\r
\r
\r
-void LC89510_Reset(void);\r
-unsigned short Read_CDC_Host(int is_sub);\r
-void Update_CDC_TRansfer(int which);\r
-void CDC_Update_Header(void);\r
+PICO_INTERNAL_ASM unsigned short Read_CDC_Host(int is_sub);\r
+PICO_INTERNAL void LC89510_Reset(void);\r
+PICO_INTERNAL void Update_CDC_TRansfer(int which);\r
+PICO_INTERNAL void CDC_Update_Header(void);\r
\r
-unsigned char CDC_Read_Reg(void);\r
-void CDC_Write_Reg(unsigned char Data);\r
+PICO_INTERNAL unsigned char CDC_Read_Reg(void);\r
+PICO_INTERNAL void CDC_Write_Reg(unsigned char Data);\r
\r
-void CDD_Export_Status(void);\r
-void CDD_Import_Command(void);\r
+PICO_INTERNAL void CDD_Export_Status(void);\r
+PICO_INTERNAL void CDD_Import_Command(void);\r
\r
#ifdef __cplusplus\r
};\r
\r
#include "../PicoInt.h"\r
\r
-#include "../sound/sound.h"\r
#include "../sound/ym2612.h"\r
#include "../sound/sn76496.h"\r
\r
#include "gfx_cd.h"\r
#include "pcm.h"\r
\r
+#ifndef UTYPES_DEFINED\r
typedef unsigned char u8;\r
typedef unsigned short u16;\r
typedef unsigned int u32;\r
+#define UTYPES_DEFINED\r
+#endif\r
\r
//#define __debug_io\r
//#define __debug_io2\r
#endif\r
\r
\r
-void PicoMemSetupCD()\r
+PICO_INTERNAL void PicoMemSetupCD(void)\r
{\r
dprintf("PicoMemSetupCD()");\r
#ifdef EMU_C68K\r
// 256K | unused | bank1 |
#ifndef _ASM_MISC_C
-void wram_2M_to_1M(unsigned char *m)
+PICO_INTERNAL_ASM void wram_2M_to_1M(unsigned char *m)
{
unsigned short *m1M_b0, *m1M_b1;
unsigned int i, tmp, *m2M;
}
}
-void wram_1M_to_2M(unsigned char *m)
+PICO_INTERNAL_ASM void wram_1M_to_2M(unsigned char *m)
{
unsigned short *m1M_b0, *m1M_b1;
unsigned int i, tmp, *m2M;
#include "../PicoInt.h"
-#include "../sound/sound.h"
extern unsigned char formatted_bram[4*0x10];
}
-int PicoInitMCD(void)
+PICO_INTERNAL int PicoInitMCD(void)
{
SekInitS68k();
Init_CD_Driver();
}
-void PicoExitMCD(void)
+PICO_INTERNAL void PicoExitMCD(void)
{
End_CD_Driver();
//dump_ram(Pico.ram, "ram.bin");
}
-int PicoResetMCD(int hard)
+PICO_INTERNAL int PicoResetMCD(int hard)
{
if (hard) {
int fmt_size = sizeof(formatted_bram);
return 0;
}
-static __inline void SekRun(int cyc)
+static __inline void SekRunM68k(int cyc)
{
int cyc_do;
SekCycleAim+=cyc;
{
//dprintf("vint: @ %06x [%i|%i]", SekPc, y, SekCycleCnt);
pv->status|=0x88; // V-Int happened, go into vblank
- SekRun(128); SekCycleAim-=128; // there must be a gap between H and V ints, also after vblank bit set (Mazin Saga, Bram Stoker's Dracula)
+ SekRunM68k(128); SekCycleAim-=128; // there must be a gap between H and V ints, also after vblank bit set (Mazin Saga, Bram Stoker's Dracula)
/*if(Pico.m.z80Run && (PicoOpt&4)) {
z80CycleAim+=cycles_z80/2;
total_z80+=z80_run(z80CycleAim-total_z80);
if ((PicoOpt & 0x2000) && (Pico_mcd->m.busreq&3) == 1) {
SekRunPS(cycles_68k, cycles_s68k); // "better/perfect sync"
} else {
- SekRun(cycles_68k);
+ SekRunM68k(cycles_68k);
if ((Pico_mcd->m.busreq&3) == 1) // no busreq/no reset
SekRunS68k(cycles_s68k);
}
}
-int PicoFrameMCD(void)
+PICO_INTERNAL int PicoFrameMCD(void)
{
if(!(PicoOpt&0x10))
PicoFrameStart();
return CYCLONE_INT_ACK_AUTOVECTOR;
}
-static void SekResetAck()
+static void SekResetAckS68k(void)
{
dprintf("s68k: Reset encountered @ %06x", SekPcS68k);
}
-static int SekUnrecognizedOpcode()
+static int SekUnrecognizedOpcodeS68k(void)
{
unsigned int pc, op;
pc = SekPcS68k;
-int SekInitS68k()
+PICO_INTERNAL int SekInitS68k()
{
#ifdef EMU_C68K
// CycloneInit();
memset(&PicoCpuS68k,0,sizeof(PicoCpuS68k));
PicoCpuS68k.IrqCallback=SekIntAckS68k;
- PicoCpuS68k.ResetCallback=SekResetAck;
- PicoCpuS68k.UnrecognizedCallback=SekUnrecognizedOpcode;
+ PicoCpuS68k.ResetCallback=SekResetAckS68k;
+ PicoCpuS68k.UnrecognizedCallback=SekUnrecognizedOpcodeS68k;
#endif
#ifdef EMU_M68K
{
}
// Reset the 68000:
-int SekResetS68k()
+PICO_INTERNAL int SekResetS68k()
{
if (Pico.rom==NULL) return 1;
return 0;
}
-int SekInterruptS68k(int irq)
+PICO_INTERNAL int SekInterruptS68k(int irq)
{
int irqs, real_irq = 1;
Pico_mcd->m.s68k_pend_ints |= 1 << irq;
/* this is a try to fight slow SD access of GP2X */
-void PicoCDBufferRead(void *dest, int lba)
+PICO_INTERNAL void PicoCDBufferRead(void *dest, int lba)
{
int is_bin, offs, read_len, moved = 0;
reads++;
***********************************************************/
#include <sys/stat.h>
-#include "cd_file.h"
#include "../PicoInt.h"
+#include "cd_file.h"
#define cdprintf dprintf
//#define cdprintf(x...)
#define DEBUG_CD
-void FILE_End(void)
-{
- Unload_ISO();
-}
-
-
-int Load_ISO(const char *iso_name, int is_bin)
+PICO_INTERNAL int Load_ISO(const char *iso_name, int is_bin)
{
int i, j, num_track, Cur_LBA, index, ret, iso_name_len;
_scd_track *Tracks = Pico_mcd->TOC.Tracks;
}
-void Unload_ISO(void)
+PICO_INTERNAL void Unload_ISO(void)
{
int i;
}
-void PicoCDBufferRead(void *dest, int lba);
-
-
-int FILE_Read_One_LBA_CDC(void)
+PICO_INTERNAL int FILE_Read_One_LBA_CDC(void)
{
// static char cp_buf[2560];
}
-int FILE_Play_CD_LBA(void)
+PICO_INTERNAL int FILE_Play_CD_LBA(void)
{
int index = Pico_mcd->scd.Cur_Track - 1;
Pico_mcd->m.audio_track = index;
-void FILE_End(void);
-int Load_ISO(const char *iso_name, int is_bin);
-void Unload_ISO(void);
-int FILE_Read_One_LBA_CDC(void);
-int FILE_Play_CD_LBA(void);
+PICO_INTERNAL int Load_ISO(const char *iso_name, int is_bin);
+PICO_INTERNAL void Unload_ISO(void);
+PICO_INTERNAL int FILE_Read_One_LBA_CDC(void);
+PICO_INTERNAL int FILE_Play_CD_LBA(void);
#ifdef __cplusplus
***********************************************************/\r
\r
#include <stdio.h>\r
-#include "cd_sys.h"\r
-#include "cd_file.h"\r
\r
#include "../PicoInt.h"\r
+#include "cd_sys.h"\r
+#include "cd_file.h"\r
\r
#define cdprintf dprintf\r
//#define cdprintf(x...)\r
}\r
\r
\r
-void LBA_to_MSF(int lba, _msf *MSF)\r
+PICO_INTERNAL void LBA_to_MSF(int lba, _msf *MSF)\r
{\r
if (lba < -150) lba = 0;\r
else lba += 150;\r
}\r
\r
\r
-int Track_to_LBA(int track)\r
+PICO_INTERNAL int Track_to_LBA(int track)\r
{\r
_msf MSF;\r
\r
}\r
\r
\r
-void Check_CD_Command(void)\r
+PICO_INTERNAL void Check_CD_Command(void)\r
{\r
cdprintf("CHECK CD COMMAND");\r
\r
}\r
\r
\r
-int Init_CD_Driver(void)\r
+PICO_INTERNAL int Init_CD_Driver(void)\r
{\r
return 0;\r
}\r
\r
\r
-void End_CD_Driver(void)\r
+PICO_INTERNAL void End_CD_Driver(void)\r
{\r
- FILE_End();\r
+ Unload_ISO();\r
}\r
\r
\r
-void Reset_CD(void)\r
+PICO_INTERNAL void Reset_CD(void)\r
{\r
Pico_mcd->scd.Cur_Track = 0;\r
Pico_mcd->scd.Cur_LBA = -150;\r
{\r
int ret = 0;\r
\r
-// memset(CD_Audio_Buffer_L, 0, 4096 * 4);\r
-// memset(CD_Audio_Buffer_R, 0, 4096 * 4);\r
-\r
CD_Present = 0;\r
Pico_mcd->scd.Status_CDD = NOCD;\r
\r
}\r
\r
\r
-void Change_CD(void)\r
+/*\r
+PICO_INTERNAL void Change_CD(void)\r
{\r
if (Pico_mcd->scd.Status_CDD == TRAY_OPEN) Close_Tray_CDD_cC();\r
else Open_Tray_CDD_cD();\r
}\r
+*/\r
\r
-\r
-int Get_Status_CDD_c0(void)\r
+PICO_INTERNAL int Get_Status_CDD_c0(void)\r
{\r
cdprintf("Status command : Cur LBA = %d", Pico_mcd->scd.Cur_LBA);\r
\r
}\r
\r
\r
-int Stop_CDD_c1(void)\r
+PICO_INTERNAL int Stop_CDD_c1(void)\r
{\r
CHECK_TRAY_OPEN\r
\r
}\r
\r
\r
-int Get_Pos_CDD_c20(void)\r
+PICO_INTERNAL int Get_Pos_CDD_c20(void)\r
{\r
_msf MSF;\r
\r
}\r
\r
\r
-int Get_Track_Pos_CDD_c21(void)\r
+PICO_INTERNAL int Get_Track_Pos_CDD_c21(void)\r
{\r
int elapsed_time;\r
_msf MSF;\r
}\r
\r
\r
-int Get_Current_Track_CDD_c22(void)\r
+PICO_INTERNAL int Get_Current_Track_CDD_c22(void)\r
{\r
cdprintf("Status CDD = %.4X Status = %.4X", Pico_mcd->scd.Status_CDD, Pico_mcd->cdd.Status);\r
\r
}\r
\r
\r
-int Get_Total_Lenght_CDD_c23(void)\r
+PICO_INTERNAL int Get_Total_Lenght_CDD_c23(void)\r
{\r
CHECK_TRAY_OPEN\r
\r
}\r
\r
\r
-int Get_First_Last_Track_CDD_c24(void)\r
+PICO_INTERNAL int Get_First_Last_Track_CDD_c24(void)\r
{\r
CHECK_TRAY_OPEN\r
\r
}\r
\r
\r
-int Get_Track_Adr_CDD_c25(void)\r
+PICO_INTERNAL int Get_Track_Adr_CDD_c25(void)\r
{\r
int track_number;\r
\r
}\r
\r
\r
-int Play_CDD_c3(void)\r
+PICO_INTERNAL int Play_CDD_c3(void)\r
{\r
_msf MSF;\r
int delay, new_lba;\r
}\r
\r
\r
-int Seek_CDD_c4(void)\r
+PICO_INTERNAL int Seek_CDD_c4(void)\r
{\r
_msf MSF;\r
\r
}\r
\r
\r
-int Pause_CDD_c6(void)\r
+PICO_INTERNAL int Pause_CDD_c6(void)\r
{\r
CHECK_TRAY_OPEN\r
CHECK_CD_PRESENT\r
}\r
\r
\r
-int Resume_CDD_c7(void)\r
+PICO_INTERNAL int Resume_CDD_c7(void)\r
{\r
CHECK_TRAY_OPEN\r
CHECK_CD_PRESENT\r
}\r
\r
\r
-int Fast_Foward_CDD_c8(void)\r
+PICO_INTERNAL int Fast_Foward_CDD_c8(void)\r
{\r
CHECK_TRAY_OPEN\r
CHECK_CD_PRESENT\r
}\r
\r
\r
-int Fast_Rewind_CDD_c9(void)\r
+PICO_INTERNAL int Fast_Rewind_CDD_c9(void)\r
{\r
CHECK_TRAY_OPEN\r
CHECK_CD_PRESENT\r
}\r
\r
\r
-int Close_Tray_CDD_cC(void)\r
+PICO_INTERNAL int Close_Tray_CDD_cC(void)\r
{\r
CD_Present = 0;\r
//Clear_Sound_Buffer();\r
}\r
\r
\r
-int Open_Tray_CDD_cD(void)\r
+PICO_INTERNAL int Open_Tray_CDD_cD(void)\r
{\r
CHECK_TRAY_OPEN\r
\r
}\r
\r
\r
-int CDD_cA(void)\r
+PICO_INTERNAL int CDD_cA(void)\r
{\r
CHECK_TRAY_OPEN\r
CHECK_CD_PRESENT\r
}\r
\r
\r
-int CDD_Def(void)\r
+PICO_INTERNAL int CDD_Def(void)\r
{\r
Pico_mcd->cdd.Status = Pico_mcd->scd.Status_CDD;\r
\r
} _scd;\r
\r
\r
-void LBA_to_MSF(int lba, _msf *MSF);\r
-int Track_to_LBA(int track);\r
-\r
-\r
-void Check_CD_Command(void);\r
-\r
-int Init_CD_Driver(void);\r
-void End_CD_Driver(void);\r
-int Insert_CD(char *iso_name, int is_bin);\r
-void Stop_CD(void);\r
-void Change_CD(void);\r
-void Reset_CD(void);\r
-\r
-int Get_Status_CDD_c0(void);\r
-int Stop_CDD_c1(void);\r
-int Get_Pos_CDD_c20(void);\r
-int Get_Track_Pos_CDD_c21(void);\r
-int Get_Current_Track_CDD_c22(void);\r
-int Get_Total_Lenght_CDD_c23(void);\r
-int Get_First_Last_Track_CDD_c24(void);\r
-int Get_Track_Adr_CDD_c25(void);\r
-int Play_CDD_c3(void);\r
-int Seek_CDD_c4(void);\r
-int Pause_CDD_c6(void);\r
-int Resume_CDD_c7(void);\r
-int Fast_Foward_CDD_c8(void);\r
-int Fast_Rewind_CDD_c9(void);\r
-int CDD_cA(void);\r
-int Close_Tray_CDD_cC(void);\r
-int Open_Tray_CDD_cD(void);\r
-\r
-int CDD_Def(void);\r
+PICO_INTERNAL void LBA_to_MSF(int lba, _msf *MSF);\r
+PICO_INTERNAL int Track_to_LBA(int track);\r
+\r
+// moved to Pico.h\r
+// int Insert_CD(char *iso_name, int is_bin);\r
+// void Stop_CD(void);\r
+\r
+PICO_INTERNAL void Check_CD_Command(void);\r
+\r
+PICO_INTERNAL int Init_CD_Driver(void);\r
+PICO_INTERNAL void End_CD_Driver(void);\r
+PICO_INTERNAL void Reset_CD(void);\r
+\r
+PICO_INTERNAL int Get_Status_CDD_c0(void);\r
+PICO_INTERNAL int Stop_CDD_c1(void);\r
+PICO_INTERNAL int Get_Pos_CDD_c20(void);\r
+PICO_INTERNAL int Get_Track_Pos_CDD_c21(void);\r
+PICO_INTERNAL int Get_Current_Track_CDD_c22(void);\r
+PICO_INTERNAL int Get_Total_Lenght_CDD_c23(void);\r
+PICO_INTERNAL int Get_First_Last_Track_CDD_c24(void);\r
+PICO_INTERNAL int Get_Track_Adr_CDD_c25(void);\r
+PICO_INTERNAL int Play_CDD_c3(void);\r
+PICO_INTERNAL int Seek_CDD_c4(void);\r
+PICO_INTERNAL int Pause_CDD_c6(void);\r
+PICO_INTERNAL int Resume_CDD_c7(void);\r
+PICO_INTERNAL int Fast_Foward_CDD_c8(void);\r
+PICO_INTERNAL int Fast_Rewind_CDD_c9(void);\r
+PICO_INTERNAL int CDD_cA(void);\r
+PICO_INTERNAL int Close_Tray_CDD_cC(void);\r
+PICO_INTERNAL int Open_Tray_CDD_cD(void);\r
+\r
+PICO_INTERNAL int CDD_Def(void);\r
\r
\r
#ifdef __cplusplus\r
#include "../PicoInt.h"
-#define rot_comp Pico_mcd->rot_comp
+#define _rot_comp Pico_mcd->rot_comp
static const int Table_Rot_Time[] =
{
{
int upd_len;
- // rot_comp.XD_Mul = ((rot_comp.Reg_5C & 0x1f) + 1) * 4; // unused
- rot_comp.Function = (rot_comp.Reg_58 & 7) | (Pico_mcd->s68k_regs[3] & 0x18); // Jmp_Adr
- // rot_comp.Buffer_Adr = (rot_comp.Reg_5E & 0xfff8) << 2; // unused?
- rot_comp.YD = (rot_comp.Reg_60 >> 3) & 7;
- rot_comp.Vector_Adr = (rot_comp.Reg_66 & 0xfffe) << 2;
+ // _rot_comp.XD_Mul = ((_rot_comp.Reg_5C & 0x1f) + 1) * 4; // unused
+ _rot_comp.Function = (_rot_comp.Reg_58 & 7) | (Pico_mcd->s68k_regs[3] & 0x18); // Jmp_Adr
+ // _rot_comp.Buffer_Adr = (_rot_comp.Reg_5E & 0xfff8) << 2; // unused?
+ _rot_comp.YD = (_rot_comp.Reg_60 >> 3) & 7;
+ _rot_comp.Vector_Adr = (_rot_comp.Reg_66 & 0xfffe) << 2;
- upd_len = (rot_comp.Reg_62 >> 3) & 0x3f;
+ upd_len = (_rot_comp.Reg_62 >> 3) & 0x3f;
upd_len = Table_Rot_Time[upd_len];
- rot_comp.Draw_Speed = rot_comp.Float_Part = upd_len;
+ _rot_comp.Draw_Speed = _rot_comp.Float_Part = upd_len;
- rot_comp.Reg_58 |= 0x8000; // Stamp_Size, we start a new GFX operation
+ _rot_comp.Reg_58 |= 0x8000; // Stamp_Size, we start a new GFX operation
- switch (rot_comp.Reg_58 & 6) // Scr_16?
+ switch (_rot_comp.Reg_58 & 6) // Scr_16?
{
case 0: // ?
- rot_comp.Stamp_Map_Adr = (rot_comp.Reg_5A & 0xff80) << 2;
+ _rot_comp.Stamp_Map_Adr = (_rot_comp.Reg_5A & 0xff80) << 2;
break;
case 2: // .Dot_32
- rot_comp.Stamp_Map_Adr = (rot_comp.Reg_5A & 0xffe0) << 2;
+ _rot_comp.Stamp_Map_Adr = (_rot_comp.Reg_5A & 0xffe0) << 2;
break;
case 4: // .Scr_16
- rot_comp.Stamp_Map_Adr = 0x20000;
+ _rot_comp.Stamp_Map_Adr = 0x20000;
break;
case 6: // .Scr_16_Dot_32
- rot_comp.Stamp_Map_Adr = (rot_comp.Reg_5A & 0xe000) << 2;
+ _rot_comp.Stamp_Map_Adr = (_rot_comp.Reg_5A & 0xe000) << 2;
break;
}
- dprintf("gfx_cd_start, stamp_map_addr=%06x", rot_comp.Stamp_Map_Adr);
+ dprintf("gfx_cd_start, stamp_map_addr=%06x", _rot_comp.Stamp_Map_Adr);
gfx_cd_update();
}
static void gfx_completed(void)
{
- rot_comp.Reg_58 &= 0x7fff; // Stamp_Size
- rot_comp.Reg_64 = 0;
+ _rot_comp.Reg_58 &= 0x7fff; // Stamp_Size
+ _rot_comp.Reg_64 = 0;
if (Pico_mcd->s68k_regs[0x33] & (1<<1))
{
dprintf("gfx_cd irq 1");
unsigned int XD, Buffer_Adr;
int DYXS;
- XD = rot_comp.Reg_60 & 7;
- Buffer_Adr = ((rot_comp.Reg_5E & 0xfff8) + rot_comp.YD) << 2;
- ecx = *(unsigned int *)(Pico_mcd->word_ram2M + rot_comp.Vector_Adr);
+ XD = _rot_comp.Reg_60 & 7;
+ Buffer_Adr = ((_rot_comp.Reg_5E & 0xfff8) + _rot_comp.YD) << 2;
+ ecx = *(unsigned int *)(Pico_mcd->word_ram2M + _rot_comp.Vector_Adr);
edx = ecx >> 16;
ecx = (ecx & 0xffff) << 8;
edx <<= 8;
- DYXS = *(int *)(Pico_mcd->word_ram2M + rot_comp.Vector_Adr + 4);
- rot_comp.Vector_Adr += 8;
+ DYXS = *(int *)(Pico_mcd->word_ram2M + _rot_comp.Vector_Adr + 4);
+ _rot_comp.Vector_Adr += 8;
// MAKE_IMAGE_LINE
while (H_Dot)
Next_Pixel:
- ecx += (DYXS << 16) >> 16; // rot_comp.DXS;
- edx += DYXS >> 16; // rot_comp.DYS;
+ ecx += (DYXS << 16) >> 16; // _rot_comp.DXS;
+ edx += DYXS >> 16; // _rot_comp.DYS;
XD++;
if (XD >= 8)
{
- Buffer_Adr += ((rot_comp.Reg_5C & 0x1f) + 1) << 5;
+ Buffer_Adr += ((_rot_comp.Reg_5C & 0x1f) + 1) << 5;
XD = 0;
}
H_Dot--;
// nothing_to_draw:
- rot_comp.YD++;
- // rot_comp.V_Dot--; // will be done by caller
+ _rot_comp.YD++;
+ // _rot_comp.V_Dot--; // will be done by caller
}
-void gfx_cd_update(void)
+PICO_INTERNAL void gfx_cd_update(void)
{
- int V_Dot = rot_comp.Reg_64 & 0xff;
+ int V_Dot = _rot_comp.Reg_64 & 0xff;
int jobs;
- dprintf("gfx_cd_update, Reg_64 = %04x", rot_comp.Reg_64);
+ dprintf("gfx_cd_update, Reg_64 = %04x", _rot_comp.Reg_64);
if (!V_Dot)
{
return;
}
- jobs = rot_comp.Float_Part >> 16;
+ jobs = _rot_comp.Float_Part >> 16;
if (!jobs)
{
- rot_comp.Float_Part += rot_comp.Draw_Speed;
+ _rot_comp.Float_Part += _rot_comp.Draw_Speed;
return;
}
- rot_comp.Float_Part &= 0xffff;
- rot_comp.Float_Part += rot_comp.Draw_Speed;
+ _rot_comp.Float_Part &= 0xffff;
+ _rot_comp.Float_Part += _rot_comp.Draw_Speed;
if (PicoOpt & 0x1000) // scale/rot enabled
{
- unsigned int func = rot_comp.Function;
- unsigned int H_Dot = rot_comp.Reg_62 & 0x1ff;
- unsigned short *stamp_base = (unsigned short *) (Pico_mcd->word_ram2M + rot_comp.Stamp_Map_Adr);
+ unsigned int func = _rot_comp.Function;
+ unsigned int H_Dot = _rot_comp.Reg_62 & 0x1ff;
+ unsigned short *stamp_base = (unsigned short *) (Pico_mcd->word_ram2M + _rot_comp.Stamp_Map_Adr);
while (jobs--)
{
V_Dot -= jobs;
}
- rot_comp.Reg_64 = V_Dot;
+ _rot_comp.Reg_64 = V_Dot;
}
-unsigned int gfx_cd_read(unsigned int a)
+PICO_INTERNAL_ASM unsigned int gfx_cd_read(unsigned int a)
{
unsigned int d = 0;
switch (a) {
- case 0x58: d = rot_comp.Reg_58; break;
- case 0x5A: d = rot_comp.Reg_5A; break;
- case 0x5C: d = rot_comp.Reg_5C; break;
- case 0x5E: d = rot_comp.Reg_5E; break;
- case 0x60: d = rot_comp.Reg_60; break;
- case 0x62: d = rot_comp.Reg_62; break;
- case 0x64: d = rot_comp.Reg_64; break;
+ case 0x58: d = _rot_comp.Reg_58; break;
+ case 0x5A: d = _rot_comp.Reg_5A; break;
+ case 0x5C: d = _rot_comp.Reg_5C; break;
+ case 0x5E: d = _rot_comp.Reg_5E; break;
+ case 0x60: d = _rot_comp.Reg_60; break;
+ case 0x62: d = _rot_comp.Reg_62; break;
+ case 0x64: d = _rot_comp.Reg_64; break;
case 0x66: break;
default: dprintf("gfx_cd_read FIXME: unexpected address: %02x", a); break;
}
return d;
}
-void gfx_cd_write16(unsigned int a, unsigned int d)
+PICO_INTERNAL_ASM void gfx_cd_write16(unsigned int a, unsigned int d)
{
dprintf("gfx_cd_write16(%x, %04x)", a, d);
switch (a) {
case 0x58: // .Reg_Stamp_Size
- rot_comp.Reg_58 = d & 7;
+ _rot_comp.Reg_58 = d & 7;
return;
case 0x5A: // .Reg_Stamp_Adr
- rot_comp.Reg_5A = d & 0xffe0;
+ _rot_comp.Reg_5A = d & 0xffe0;
return;
case 0x5C: // .Reg_IM_VCell_Size
- rot_comp.Reg_5C = d & 0x1f;
+ _rot_comp.Reg_5C = d & 0x1f;
return;
case 0x5E: // .Reg_IM_Adr
- rot_comp.Reg_5E = d & 0xFFF8;
+ _rot_comp.Reg_5E = d & 0xFFF8;
return;
case 0x60: // .Reg_IM_Offset
- rot_comp.Reg_60 = d & 0x3f;
+ _rot_comp.Reg_60 = d & 0x3f;
return;
case 0x62: // .Reg_IM_HDot_Size
- rot_comp.Reg_62 = d & 0x1ff;
+ _rot_comp.Reg_62 = d & 0x1ff;
return;
case 0x64: // .Reg_IM_VDot_Size
- rot_comp.Reg_64 = d & 0xff; // V_Dot, must be 32bit?
+ _rot_comp.Reg_64 = d & 0xff; // V_Dot, must be 32bit?
return;
case 0x66: // .Reg_Vector_Adr
- rot_comp.Reg_66 = d & 0xfffe;
+ _rot_comp.Reg_66 = d & 0xfffe;
if (Pico_mcd->s68k_regs[3]&4) return; // can't do tanformations in 1M mode
gfx_cd_start();
return;
}
-void gfx_cd_reset(void)
+PICO_INTERNAL void gfx_cd_reset(void)
{
- memset(&rot_comp.Reg_58, 0, sizeof(rot_comp));
+ memset(&_rot_comp.Reg_58, 0, sizeof(_rot_comp));
}
#include "cell_map.c"
+#ifndef UTYPES_DEFINED
typedef unsigned short u16;
+#endif
// check: Heart of the alien, jaguar xj 220
-void DmaSlowCell(unsigned int source, unsigned int a, int len, unsigned char inc)
+PICO_INTERNAL void DmaSlowCell(unsigned int source, unsigned int a, int len, unsigned char inc)
{
unsigned char *base;
unsigned int asrc, a2;
} Rot_Comp;
-void gfx_cd_update(void);
+PICO_INTERNAL void gfx_cd_update(void);
-unsigned int gfx_cd_read(unsigned int a);
-void gfx_cd_write16(unsigned int a, unsigned int d);
+PICO_INTERNAL_ASM unsigned int gfx_cd_read(unsigned int a);
+PICO_INTERNAL_ASM void gfx_cd_write16(unsigned int a, unsigned int d);
-void gfx_cd_reset(void);
+PICO_INTERNAL void gfx_cd_reset(void);
-void DmaSlowCell(unsigned int source, unsigned int a, int len, unsigned char inc);
+PICO_INTERNAL void DmaSlowCell(unsigned int source, unsigned int a, int len, unsigned char inc);
#endif // _GFX_CD_H
static unsigned int g_rate = 0; // 18.14 fixed point
-void pcm_write(unsigned int a, unsigned int d)
+PICO_INTERNAL_ASM void pcm_write(unsigned int a, unsigned int d)
{
//printf("pcm_write(%i, %02x)\n", a, d);
}
-void pcm_set_rate(int rate)
+PICO_INTERNAL void pcm_set_rate(int rate)
{
float step = 31.8 * 1024.0 / (float) rate; // max <4 @ 8000Hz
step *= 256*256/4;
}
-// TODO: make use of the fact that max_length == 3
-
-void pcm_update(int *buffer, int length, int stereo)
+PICO_INTERNAL void pcm_update(int *buffer, int length, int stereo)
{
struct pcm_chan *ch;
unsigned int step, addr;
#define PCM_STEP_SHIFT 11
-void pcm_write(unsigned int a, unsigned int d);
-void pcm_set_rate(int rate);
-void pcm_update(int *buffer, int length, int stereo);
+PICO_INTERNAL_ASM void pcm_write(unsigned int a, unsigned int d);
+PICO_INTERNAL void pcm_set_rate(int rate);
+PICO_INTERNAL void pcm_update(int *buffer, int length, int stereo);
\r
\r
#include <string.h>\r
-#include "sound.h"\r
#include "ym2612.h"\r
#include "sn76496.h"\r
\r
-#ifndef __GNUC__\r
-#pragma warning (disable:4244)\r
-#endif\r
-\r
#if defined(_USE_MZ80)\r
#include "../../cpu/mz80/mz80.h"\r
#elif defined(_USE_DRZ80)\r
// master int buffer to mix to\r
static int PsndBuffer[2*44100/50];\r
\r
-//int z80CycleAim = 0;\r
-\r
// dac\r
-short *dac_out;\r
-unsigned short dac_info[312]; // pppppppp ppppllll, p - pos in buff, l - length to write for this sample\r
+static unsigned short dac_info[312]; // pppppppp ppppllll, p - pos in buff, l - length to write for this sample\r
\r
// for Pico\r
int PsndRate=0;\r
extern int *sn76496_regs;\r
\r
\r
-static void dac_recalculate()\r
+static void dac_recalculate(void)\r
{\r
int i, dac_cnt, pos, len, lines = Pico.m.pal ? 312 : 262, mid = Pico.m.pal ? 68 : 93;\r
\r
}\r
\r
\r
-void sound_reset()\r
+PICO_INTERNAL void sound_reset(void)\r
{\r
void *ym2612_regs;\r
\r
\r
\r
// This is called once per raster (aka line), but not necessarily for every line\r
-void sound_timers_and_dac(int raster)\r
+PICO_INTERNAL void sound_timers_and_dac(int raster)\r
{\r
int pos, len;\r
int do_dac = PsndOut && (PicoOpt&1) && *ym2612_dacen;\r
}\r
\r
\r
-void sound_clear(void)\r
+PICO_INTERNAL void sound_clear(void)\r
{\r
int len = PsndLen;\r
if (PsndLen_exc_add) len++;\r
}\r
\r
\r
-int sound_render(int offset, int length)\r
+PICO_INTERNAL int sound_render(int offset, int length)\r
{\r
int buf32_updated = 0;\r
int *buf32 = PsndBuffer+offset;\r
#endif\r
\r
// z80 functionality wrappers\r
-void z80_init()\r
+PICO_INTERNAL void z80_init(void)\r
{\r
#if defined(_USE_MZ80)\r
struct mz80context z80;\r
#endif\r
}\r
\r
-void z80_reset()\r
+PICO_INTERNAL void z80_reset(void)\r
{\r
#if defined(_USE_MZ80)\r
mz80reset();\r
Pico.m.z80_fakeval = 0; // for faking when Z80 is disabled\r
}\r
\r
-void z80_resetCycles()\r
+PICO_INTERNAL void z80_resetCycles(void)\r
{\r
#if defined(_USE_MZ80)\r
mz80GetElapsedTicks(1);\r
#endif\r
}\r
\r
-void z80_int()\r
+PICO_INTERNAL void z80_int(void)\r
{\r
#if defined(_USE_MZ80)\r
mz80int(0);\r
}\r
\r
// returns number of cycles actually executed\r
-int z80_run(int cycles)\r
+PICO_INTERNAL int z80_run(int cycles)\r
{\r
#if defined(_USE_MZ80)\r
int ticks_pre = mz80GetElapsedTicks(0);\r
#endif\r
}\r
\r
-void z80_pack(unsigned char *data)\r
+PICO_INTERNAL void z80_pack(unsigned char *data)\r
{\r
#if defined(_USE_MZ80)\r
struct mz80context mz80;\r
#endif\r
}\r
\r
-void z80_unpack(unsigned char *data)\r
+PICO_INTERNAL void z80_unpack(unsigned char *data)\r
{\r
#if defined(_USE_MZ80)\r
if(*(int *)data == 0x00005A6D) { // "mZ" save?\r
#endif\r
}\r
\r
-void z80_exit()\r
+PICO_INTERNAL void z80_exit(void)\r
{\r
#if defined(_USE_MZ80)\r
mz80shutdown();\r
}\r
\r
#if defined(__DEBUG_PRINT) || defined(__GP2X__)\r
-void z80_debug(char *dstr)\r
+PICO_INTERNAL void z80_debug(char *dstr)\r
{\r
#if defined(_USE_DRZ80)\r
sprintf(dstr, "Z80 state: PC: %04x SP: %04x\n", drZ80.Z80PC-drZ80.Z80PC_BASE, drZ80.Z80SP-drZ80.Z80SP_BASE);\r
+++ /dev/null
-// This is part of Pico Library\r
-\r
-// (c) Copyright 2004 Dave, All rights reserved.\r
-// (c) Copyright 2006 notaz, All rights reserved.\r
-// Free for non-commercial use.\r
-\r
-// For commercial use, separate licencing terms must be obtained.\r
-\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-void sound_timers_and_dac(int raster);\r
-int sound_render(int offset, int length);\r
-void sound_clear(void);\r
-\r
-//int YM2612PicoTick(int n);\r
-\r
-// z80 functionality wrappers\r
-void z80_init();\r
-void z80_resetCycles();\r
-void z80_int();\r
-int z80_run(int cycles);\r
-void z80_exit();\r
-\r
-#ifdef __cplusplus\r
-} // End of extern "C"\r
-#endif\r
asm_misc = 1\r
asm_cdpico = 1\r
asm_cdmemory = 1\r
+amalgamate = 1\r
#profile = 1\r
#use_musashi = 1\r
#up = 1\r
OBJS += main.o menu.o fonts.o gp2x.o usbjoy.o emu.o squidgehack.o asmutils.o cpuctrl.o readpng.o\r
# 940 core control\r
OBJS += 940ctl.o\r
+\r
# Pico\r
-OBJS += ../../Pico/Area.o ../../Pico/Cart.o ../../Pico/Utils.o ../../Pico/Memory.o ../../Pico/Misc.o \\r
+ifeq "$(amalgamate)" "1"\r
+OBJS += ../../PicoAll.o\r
+else\r
+OBJS += ../../Pico/Area.o ../../Pico/Cart.o ../../Pico/Memory.o ../../Pico/Misc.o \\r
../../Pico/Pico.o ../../Pico/Sek.o ../../Pico/VideoPort.o ../../Pico/Draw2.o ../../Pico/Draw.o \\r
../../Pico/Patch.o\r
# Pico - CD\r
OBJS += ../../Pico/cd/Pico.o ../../Pico/cd/Memory.o ../../Pico/cd/Sek.o ../../Pico/cd/LC89510.o \\r
../../Pico/cd/cd_sys.o ../../Pico/cd/cd_file.o ../../Pico/cd/gfx_cd.o \\r
../../Pico/cd/Area.o ../../Pico/cd/Misc.o ../../Pico/cd/pcm.o ../../Pico/cd/buffering.o\r
+endif\r
+\r
# asm stuff\r
ifeq "$(asm_render)" "1"\r
DEFINC += -D_ASM_DRAW_C\r
DEFINC += -D_ASM_CD_MEMORY_C\r
OBJS += ../../Pico/cd/memory_asm.o\r
endif\r
+\r
# Pico - sound\r
+ifneq "$(amalgamate)" "1"\r
+OBJS += ../../Pico/sound/sound.o\r
+endif\r
OBJS += ../../Pico/sound/mix_asm.o\r
-OBJS += ../../Pico/sound/sound.o ../../Pico/sound/sn76496.o ../../Pico/sound/ym2612.o\r
+OBJS += ../../Pico/sound/sn76496.o ../../Pico/sound/ym2612.o\r
# zlib\r
OBJS += ../../zlib/gzio.o ../../zlib/inffast.o ../../zlib/inflate.o ../../zlib/inftrees.o ../../zlib/trees.o \\r
../../zlib/deflate.o ../../zlib/crc32.o ../../zlib/adler32.o ../../zlib/zutil.o ../../zlib/compress.o\r
code940/code940.bin:\r
make -C code940/\r
\r
-\r
-# test\r
-#usbjoy.o : usbjoy.c\r
-# @echo $<\r
-# @$(GCC) $(COPT) $(DEFINC) -fno-profile-generate -c $< -o $@\r
-#\r
-#../../Pico/Cart.o : ../../Pico/Cart.c\r
-# @echo $<\r
-# @$(GCC) $(COPT) $(DEFINC) -fno-profile-generate -c $< -o $@\r
-#\r
-#../../zlib/trees.o : ../../zlib/trees.c\r
-# @echo $<\r
-# @$(GCC) $(COPT) $(DEFINC) -fno-profile-generate -c $< -o $@\r
-\r
// bios_help() ?\r
return 0;\r
} else {\r
- if (PicoMCD & 1) PicoExitMCD();\r
+ if (PicoMCD & 1) Stop_CD();\r
PicoMCD &= ~1;\r
}\r
\r
OBJS += ../gp2x/main.o ../gp2x/menu.o ../gp2x/fonts.o ../gp2x/emu.o ../gp2x/usbjoy.o blit.o \
gp2x.o 940ctl_ym2612.o ../gp2x/readpng.o
# Pico
-OBJS += ../../Pico/Area.o ../../Pico/Cart.o ../../Pico/Utils.o ../../Pico/Memory.o ../../Pico/Misc.o \
+OBJS += ../../Pico/Area.o ../../Pico/Cart.o ../../Pico/Memory.o ../../Pico/Misc.o \
../../Pico/Pico.o ../../Pico/Sek.o ../../Pico/VideoPort.o ../../Pico/Draw2.o ../../Pico/Draw.o \
../../Pico/Patch.o
# Pico - CD
--- /dev/null
+CFLAGS = -Wall -ggdb
+
+TARGET = amalgamate
+OBJS = amalgamate.o
+
+all: $(TARGET)
+
+clean:
+ $(RM) $(TARGET) $(OBJS)
+
--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <ctype.h>
+
+#define OUT_FILE "PicoAll.c"
+
+// files to amalgamate, in order
+static const char *files[] =
+{
+ "Pico/Pico.h",
+ // PicoInt.h includes some CD stuff, so start with them
+ "Pico/cd/cd_file.h",
+ "Pico/cd/cd_sys.h",
+ "Pico/cd/LC89510.h",
+ "Pico/cd/gfx_cd.h",
+ "Pico/cd/pcm.h",
+ "Pico/PicoInt.h",
+ "Pico/Patch.h",
+ "Pico/sound/mix.h",
+ // source
+ "Pico/Area.c",
+ "Pico/Cart.c",
+ "Pico/Draw2.c",
+ "Pico/Draw.c",
+ "Pico/VideoPort.c",
+ "Pico/sound/sound.c",
+ "Pico/MemoryCmn.c",
+ "Pico/Memory.c",
+ "Pico/Misc.c",
+ "Pico/Patch.c",
+ "Pico/Sek.c",
+ "Pico/cd/Area.c",
+ "Pico/cd/buffering.c",
+ "Pico/cd/cd_file.c",
+ "Pico/cd/cd_sys.c",
+ "Pico/cd/cell_map.c",
+ "Pico/cd/gfx_cd.c",
+ "Pico/cd/LC89510.c",
+ "Pico/cd/Memory.c",
+ "Pico/cd/Misc.c",
+ "Pico/cd/pcm.c",
+ "Pico/cd/Sek.c",
+ "Pico/cd/Pico.c",
+ "Pico/Pico.c",
+};
+
+static char *includes[128];
+
+static void eprintf(const char *fmt, ...)
+{
+ va_list args;
+
+ va_start(args, fmt);
+ vprintf(fmt, args);
+ va_end(args);
+
+ exit(1);
+}
+
+static void emit_header(FILE *f, const char *fname)
+{
+ char tmp[128] = "/* */";
+ memcpy(tmp + 3, fname, strlen(fname));
+ fprintf(f, "\n\n");
+ fprintf(f, "/**************************************************************/\n");
+ fprintf(f, "/**************************************************************/\n");
+ fprintf(f, "%s\n", tmp);
+ fprintf(f, "/**************************************************************/\n");
+}
+
+static const char *add_include(const char *include)
+{
+ int i;
+ char processed_inc[128+4];
+
+ // must first quote relative includes
+ snprintf(processed_inc, sizeof(processed_inc), (include[0] != '<') ? "\"%s\"" : "%s", include);
+
+ // find in include list
+ for (i = 0; includes[i] && i < 128; i++)
+ {
+ if (strcmp(processed_inc, includes[i]) == 0) break;
+ }
+ if (i == 128) eprintf("add_include: includes overflowed\n");
+ if (includes[i] != NULL)
+ {
+ printf("already have: %s\n", processed_inc);
+ return NULL;
+ }
+ else
+ {
+ printf("adding: %s\n", processed_inc);
+ includes[i] = strdup(processed_inc);
+ if (includes[i] == NULL) eprintf("add_include: OOM\n");
+ return includes[i];
+ }
+}
+
+static const char *add_raw_include(const char *include, const char *base)
+{
+ const char *ps, *pe;
+ char processed_inc[128];
+
+ for (ps = include; *ps && isspace(*ps); ps++);
+
+ if (*ps == '<')
+ {
+ int len = 1;
+ // system include, search for '>'
+ for (pe = ps; *pe && *pe != '>'; pe++, len++);
+ if (*pe == 0 || len > 127) eprintf("add_raw_include: failed sysinclude, len=%i\n", len);
+ strncpy(processed_inc, ps, len);
+ processed_inc[len] = 0;
+ }
+ else if (*ps == '\"')
+ {
+ int len, pos;
+ // relative include, make path absolute (or relative to base dir)
+ strcpy(processed_inc, base);
+ ps++;
+ while (*ps == '.')
+ {
+ if (strncmp(ps, "../", 3) == 0)
+ {
+ char *p;
+ if (processed_inc[0] == 0)
+ eprintf("add_raw_include: already in root, can't go down: %s | %s\n", ps, include);
+ p = strrchr(processed_inc, '/');
+ if (p == NULL) eprintf("add_raw_include: can't happen\n");
+ *p = 0;
+ p = strrchr(processed_inc, '/');
+ if (p != NULL) p[1] = 0;
+ else processed_inc[0] = 0;
+ ps += 3;
+ }
+ else if (strncmp(ps, "./", 2) == 0)
+ {
+ ps += 2; // just skip
+ }
+ while (*ps == '/') ps++;
+ }
+ if (*ps == 0) eprintf("add_raw_include: failed with %s\n", include);
+
+ len = pos = strlen(processed_inc);
+ for (pe = ps; *pe && *pe != '\"'; pe++, len++);
+ if (*pe == 0 || len > 127) eprintf("add_raw_include: failed with %s, len=%i\n", include, len);
+ strncpy(processed_inc + pos, ps, len - pos);
+ processed_inc[len] = 0;
+ }
+ else
+ eprintf("add_raw_include: unhandled include: %s\n", ps);
+
+ return add_include(processed_inc);
+}
+
+// returns pointer to location after part in string
+static const char *substr_end(const char *string, const char *part)
+{
+ const char *p = string;
+ int len = strlen(part);
+
+ while (*p && isspace(*p)) p++;
+ return (strncmp(p, part, len) == 0) ? (p + len) : NULL;
+}
+
+static void strip_cr(char *str)
+{
+ int len = strlen(str);
+ char *p = str;
+
+ while ((p = strchr(p, '\r')))
+ {
+ memmove(p, p + 1, len - (p - str) + 1);
+ }
+ if (strlen(str) > 0)
+ {
+ p = str + strlen(str) - 1;
+ while (p >= str && isspace(*p)) { *p = 0; p--; } // strip spaces on line ends
+ }
+ strcat(str, "\n"); // re-add newline
+}
+
+int main(void)
+{
+ char buff[512]; // tmp buffer
+ char path[128]; // path to file being included, with ending slash
+ int i, ifile;
+ FILE *fo;
+
+ memset(includes, 0, sizeof(includes));
+
+ fo = fopen(OUT_FILE, "w");
+ if (fo == NULL) return 1;
+
+ // special header
+ fprintf(fo, "#define PICO_INTERNAL static\n");
+ fprintf(fo, "#define PICO_INTERNAL_ASM\n");
+
+ for (ifile = 0; ifile < sizeof(files) / sizeof(files[0]); ifile++)
+ {
+ FILE *fi;
+ const char *file = files[ifile], *p;
+ p = strrchr(file, '/');
+ if (p == NULL) eprintf("main: file in root? %s\n", file);
+ strncpy(path, file, p - file + 1);
+ path[p - file + 1] = 0;
+
+ fi = fopen(file, "r");
+ if (fi == NULL) eprintf("main: failed to open %s\n", file);
+
+ // if (strcmp(file + strlen(file) - 2, ".h") == 0)
+ add_include(file);
+ emit_header(fo, file);
+
+ while (!feof(fi))
+ {
+ p = fgets(buff, sizeof(buff), fi);
+ if (p == NULL) break;
+ strip_cr(buff);
+ // include?
+ p = substr_end(buff, "#include");
+ if (p != NULL)
+ {
+ p = add_raw_include(p, path);
+ if (p != NULL) fprintf(fo, "#include %s\n", p);
+ continue;
+ }
+ // passthrough
+ fputs(buff, fo);
+ }
+ }
+
+ emit_header(fo, "EOF");
+
+ for (i = 0; includes[i] && i < 128; i++)
+ {
+ free(includes[i]);
+ }
+
+ fclose(fo);
+
+ return 0;
+}
+