amalgamation

git-svn-id: file:///home/notaz/opt/svn/PicoDrive@227 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
notaz 2007-08-25 18:06:54 +00:00
parent a4f0cc8647
commit eff55556cf
35 changed files with 607 additions and 363 deletions

View file

@ -42,7 +42,7 @@ static int ScanVar(void *data,int len,char *name,void *PmovFile,int PmovAction)
#define SCANP(x) ScanVar(&Pico.x,sizeof(Pico.x),#x,PmovFile,PmovAction); #define SCANP(x) ScanVar(&Pico.x,sizeof(Pico.x),#x,PmovFile,PmovAction);
// Pack the cpu into a common format: // Pack the cpu into a common format:
int PicoAreaPackCpu(unsigned char *cpu, int is_sub) PICO_INTERNAL int PicoAreaPackCpu(unsigned char *cpu, int is_sub)
{ {
unsigned int pc=0; unsigned int pc=0;
@ -82,7 +82,7 @@ int PicoAreaPackCpu(unsigned char *cpu, int is_sub)
return 0; return 0;
} }
int PicoAreaUnpackCpu(unsigned char *cpu, int is_sub) PICO_INTERNAL int PicoAreaUnpackCpu(unsigned char *cpu, int is_sub)
{ {
#ifdef EMU_A68K #ifdef EMU_A68K
memcpy(M68000_regs.d,cpu,0x40); memcpy(M68000_regs.d,cpu,0x40);

View file

@ -1242,7 +1242,7 @@ static int DrawDisplay(int sh)
static int Skip=0; static int Skip=0;
void PicoFrameStart() PICO_INTERNAL void PicoFrameStart(void)
{ {
// prepare to do this frame // prepare to do this frame
rendstatus = (PicoOpt&0x80)>>5; // accurate sprites rendstatus = (PicoOpt&0x80)>>5; // accurate sprites
@ -1256,7 +1256,7 @@ void PicoFrameStart()
Skip=0; Skip=0;
} }
int PicoLine(int scan) PICO_INTERNAL int PicoLine(int scan)
{ {
int sh; int sh;
if (Skip>0) { Skip--; return 0; } // Skip rendering lines if (Skip>0) { Skip--; return 0; } // Skip rendering lines

View file

@ -10,10 +10,6 @@
#include "PicoInt.h" #include "PicoInt.h"
#include <assert.h>
#ifndef __GNUC__
#pragma warning (disable:4706) // Disable assignment within conditional
#endif
// port_config.h include must define these 2 defines: // port_config.h include must define these 2 defines:
// #define START_ROW 1 // which row of tiles to start rendering at? // #define START_ROW 1 // which row of tiles to start rendering at?
@ -28,8 +24,8 @@
extern unsigned char *framebuff; // in format (8+320)x(8+224+8) (eights for borders) extern unsigned char *framebuff; // in format (8+320)x(8+224+8) (eights for borders)
int currpri = 0; int currpri = 0;
static int HighCacheA[41*(TILE_ROWS+1)+1+1]; // caches for high layers static int HighCache2A[41*(TILE_ROWS+1)+1+1]; // caches for high layers
static int HighCacheB[41*(TILE_ROWS+1)+1+1]; static int HighCache2B[41*(TILE_ROWS+1)+1+1];
unsigned short *PicoCramHigh=Pico.cram; // pointer to CRAM buff (0x40 shorts), converted to native device color (works only with 16bit for now) unsigned short *PicoCramHigh=Pico.cram; // pointer to CRAM buff (0x40 shorts), converted to native device color (works only with 16bit for now)
void (*PicoPrepareCram)()=0; // prepares PicoCramHigh for renderer to use void (*PicoPrepareCram)()=0; // prepares PicoCramHigh for renderer to use
@ -563,17 +559,17 @@ static void DrawDisplayFull()
if(hvwin==1) { winend|=maxcolc<<16; planeend|=maxcolc<<16; } if(hvwin==1) { winend|=maxcolc<<16; planeend|=maxcolc<<16; }
currpri = 0; currpri = 0;
DrawLayerFull(1, HighCacheB, START_ROW, (maxcolc<<16)|END_ROW); DrawLayerFull(1, HighCache2B, START_ROW, (maxcolc<<16)|END_ROW);
switch(hvwin) { switch(hvwin) {
case 4: case 4:
// fullscreen window // fullscreen window
DrawWindowFull(START_ROW, (maxcolc<<16)|END_ROW, 0); DrawWindowFull(START_ROW, (maxcolc<<16)|END_ROW, 0);
HighCacheA[1] = 0; HighCache2A[1] = 0;
break; break;
case 3: case 3:
// we have plane A and both v and h windows // we have plane A and both v and h windows
DrawLayerFull(0, HighCacheA, planestart, planeend); DrawLayerFull(0, HighCache2A, planestart, planeend);
DrawWindowFull( winstart&~0xff0000, (winend&~0xff0000)|(maxcolc<<16), 0); // h DrawWindowFull( winstart&~0xff0000, (winend&~0xff0000)|(maxcolc<<16), 0); // h
DrawWindowFull((winstart&~0xff)|START_ROW, (winend&~0xff)|END_ROW, 0); // v DrawWindowFull((winstart&~0xff)|START_ROW, (winend&~0xff)|END_ROW, 0); // v
break; break;
@ -581,20 +577,20 @@ static void DrawDisplayFull()
case 2: case 2:
case 1: case 1:
// both window and plane A visible, window is vertical XOR horizontal // both window and plane A visible, window is vertical XOR horizontal
DrawLayerFull(0, HighCacheA, planestart, planeend); DrawLayerFull(0, HighCache2A, planestart, planeend);
DrawWindowFull(winstart, winend, 0); DrawWindowFull(winstart, winend, 0);
break; break;
default: default:
// fullscreen plane A // fullscreen plane A
DrawLayerFull(0, HighCacheA, START_ROW, (maxcolc<<16)|END_ROW); DrawLayerFull(0, HighCache2A, START_ROW, (maxcolc<<16)|END_ROW);
break; break;
} }
DrawAllSpritesFull(0, maxw); DrawAllSpritesFull(0, maxw);
#ifdef USE_CACHE #ifdef USE_CACHE
if(HighCacheB[1]) DrawTilesFromCacheF(HighCacheB); if(HighCache2B[1]) DrawTilesFromCacheF(HighCache2B);
if(HighCacheA[1]) DrawTilesFromCacheF(HighCacheA); if(HighCache2A[1]) DrawTilesFromCacheF(HighCache2A);
switch(hvwin) { switch(hvwin) {
case 4: case 4:
// fullscreen window // fullscreen window
@ -621,7 +617,7 @@ static void DrawDisplayFull()
} }
void PicoFrameFull() PICO_INTERNAL void PicoFrameFull()
{ {
// prepare cram? // prepare cram?
if(PicoPrepareCram) PicoPrepareCram(); if(PicoPrepareCram) PicoPrepareCram();

View file

@ -11,13 +11,15 @@
#include "PicoInt.h" #include "PicoInt.h"
#include "sound/sound.h"
#include "sound/ym2612.h" #include "sound/ym2612.h"
#include "sound/sn76496.h" #include "sound/sn76496.h"
#ifndef UTYPES_DEFINED
typedef unsigned char u8; typedef unsigned char u8;
typedef unsigned short u16; typedef unsigned short u16;
typedef unsigned int u32; typedef unsigned int u32;
#define UTYPES_DEFINED
#endif
extern unsigned int lastSSRamWrite; // used by serial SRAM code extern unsigned int lastSSRamWrite; // used by serial SRAM code
@ -88,14 +90,14 @@ static u32 CPU_CALL PicoCheckPc(u32 pc)
} }
int PicoInitPc(u32 pc) PICO_INTERNAL int PicoInitPc(u32 pc)
{ {
PicoCheckPc(pc); PicoCheckPc(pc);
return 0; return 0;
} }
#ifndef _ASM_MEMORY_C #ifndef _ASM_MEMORY_C
void PicoMemReset() PICO_INTERNAL_ASM void PicoMemReset(void)
{ {
} }
#endif #endif
@ -266,7 +268,7 @@ static void OtherWrite8End(u32 a,u32 d,int realsize)
// Read Rom and read Ram // Read Rom and read Ram
#ifndef _ASM_MEMORY_C #ifndef _ASM_MEMORY_C
u32 CPU_CALL PicoRead8(u32 a) PICO_INTERNAL_ASM u32 CPU_CALL PicoRead8(u32 a)
{ {
u32 d=0; u32 d=0;
@ -317,7 +319,7 @@ u32 CPU_CALL PicoRead8(u32 a)
return d; return d;
} }
u32 CPU_CALL PicoRead16(u32 a) PICO_INTERNAL_ASM u32 CPU_CALL PicoRead16(u32 a)
{ {
u32 d=0; u32 d=0;
@ -353,7 +355,7 @@ u32 CPU_CALL PicoRead16(u32 a)
return d; return d;
} }
u32 CPU_CALL PicoRead32(u32 a) PICO_INTERNAL_ASM u32 CPU_CALL PicoRead32(u32 a)
{ {
u32 d=0; u32 d=0;
@ -446,7 +448,7 @@ static void CPU_CALL PicoWrite32(u32 a,u32 d)
// ----------------------------------------------------------------- // -----------------------------------------------------------------
void PicoMemSetup() PICO_INTERNAL void PicoMemSetup(void)
{ {
#ifdef EMU_C68K #ifdef EMU_C68K
// Setup memory callbacks: // Setup memory callbacks:
@ -623,7 +625,7 @@ void m68k_write_memory_32(unsigned int address, unsigned int value)
// ----------------------------------------------------------------- // -----------------------------------------------------------------
// z80 memhandlers // z80 memhandlers
unsigned char z80_read(unsigned short a) PICO_INTERNAL unsigned char z80_read(unsigned short a)
{ {
u8 ret = 0; u8 ret = 0;
@ -651,14 +653,14 @@ end:
return ret; return ret;
} }
unsigned short z80_read16(unsigned short a) PICO_INTERNAL unsigned short z80_read16(unsigned short a)
{ {
//dprintf("z80_read16"); //dprintf("z80_read16");
return (u16) ( (u16)z80_read(a) | ((u16)z80_read((u16)(a+1))<<8) ); return (u16) ( (u16)z80_read(a) | ((u16)z80_read((u16)(a+1))<<8) );
} }
void z80_write(unsigned char data, unsigned short a) PICO_INTERNAL_ASM void z80_write(unsigned char data, unsigned short a)
{ {
//if (a<0x4000) //if (a<0x4000)
// dprintf("z80 w8 : %06x, %02x @%04x", a, data, mz80GetRegisterValue(NULL, 0)); // dprintf("z80 w8 : %06x, %02x @%04x", a, data, mz80GetRegisterValue(NULL, 0));
@ -697,7 +699,7 @@ void z80_write(unsigned char data, unsigned short a)
if (a<0x4000) { Pico.zram[a&0x1fff]=data; return; } if (a<0x4000) { Pico.zram[a&0x1fff]=data; return; }
} }
void z80_write16(unsigned short data, unsigned short a) PICO_INTERNAL void z80_write16(unsigned short data, unsigned short a)
{ {
//dprintf("z80_write16"); //dprintf("z80_write16");

View file

@ -1,6 +1,20 @@
// common code for Memory.c and cd/Memory.c // common code for Memory.c and cd/Memory.c
// (c) Copyright 2006-2007, Grazvydas "notaz" Ignotas // (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) static int PadRead(int i)
{ {
int pad=0,value=0,TH; int pad=0,value=0,TH;

View file

@ -141,7 +141,7 @@ unsigned int lastSSRamWrite = 0xffff0000;
// sram_reg: LAtd sela (L=pending SCL, A=pending SDA, t=type(1==uses 0x200000 for SCL and 2K bytes), // sram_reg: LAtd sela (L=pending SCL, A=pending SDA, t=type(1==uses 0x200000 for SCL and 2K bytes),
// d=SRAM was detected (header or by access), s=started, e=save is EEPROM, l=old SCL, a=old SDA) // d=SRAM was detected (header or by access), s=started, e=save is EEPROM, l=old SCL, a=old SDA)
void SRAMWriteEEPROM(unsigned int d) // ???? ??la (l=SCL, a=SDA) PICO_INTERNAL void SRAMWriteEEPROM(unsigned int d) // ???? ??la (l=SCL, a=SDA)
{ {
unsigned int sreg = Pico.m.sram_reg, saddr = Pico.m.sram_addr, scyc = Pico.m.sram_cycle, ssa = Pico.m.sram_slave; unsigned int sreg = Pico.m.sram_reg, saddr = Pico.m.sram_addr, scyc = Pico.m.sram_cycle, ssa = Pico.m.sram_slave;
@ -247,7 +247,7 @@ void SRAMWriteEEPROM(unsigned int d) // ???? ??la (l=SCL, a=SDA)
Pico.m.sram_slave= (unsigned char) ssa; Pico.m.sram_slave= (unsigned char) ssa;
} }
unsigned int SRAMReadEEPROM() PICO_INTERNAL_ASM unsigned int SRAMReadEEPROM(void)
{ {
unsigned int shift, d=0; unsigned int shift, d=0;
unsigned int sreg, saddr, scyc, ssa; unsigned int sreg, saddr, scyc, ssa;
@ -282,7 +282,7 @@ unsigned int SRAMReadEEPROM()
return d; return d;
} }
void SRAMUpdPending(unsigned int a, unsigned int d) PICO_INTERNAL void SRAMUpdPending(unsigned int a, unsigned int d)
{ {
unsigned int sreg = Pico.m.sram_reg; unsigned int sreg = Pico.m.sram_reg;
@ -306,14 +306,14 @@ void SRAMUpdPending(unsigned int a, unsigned int d)
#ifndef _ASM_MISC_C #ifndef _ASM_MISC_C
void memcpy16(unsigned short *dest, unsigned short *src, int count) PICO_INTERNAL_ASM void memcpy16(unsigned short *dest, unsigned short *src, int count)
{ {
while (count--) while (count--)
*dest++ = *src++; *dest++ = *src++;
} }
void memcpy16bswap(unsigned short *dest, void *src, int count) PICO_INTERNAL_ASM void memcpy16bswap(unsigned short *dest, void *src, int count)
{ {
unsigned char *src_ = src; unsigned char *src_ = src;
@ -322,14 +322,14 @@ void memcpy16bswap(unsigned short *dest, void *src, int count)
} }
void memcpy32(int *dest, int *src, int count) PICO_INTERNAL_ASM void memcpy32(int *dest, int *src, int count)
{ {
while (count--) while (count--)
*dest++ = *src++; *dest++ = *src++;
} }
void memset32(int *dest, int c, int count) PICO_INTERNAL_ASM void memset32(int *dest, int c, int count)
{ {
while (count--) while (count--)
*dest++ = c; *dest++ = c;

View file

@ -213,7 +213,7 @@ bad_code:
unsigned short PicoRead16(unsigned int a); unsigned int PicoRead16(unsigned int a);
void PicoWrite16(unsigned int a, unsigned short d); void PicoWrite16(unsigned int a, unsigned short d);

View file

@ -8,7 +8,6 @@
#include "PicoInt.h" #include "PicoInt.h"
#include "sound/sound.h"
#include "sound/ym2612.h" #include "sound/ym2612.h"
int PicoVer=0x0110; int PicoVer=0x0110;
@ -218,8 +217,8 @@ static int dma_bsycles[] = {
(488<<8)/9, (488<<8)/18, (488<<8)/17, (488<<8)/9 (488<<8)/9, (488<<8)/18, (488<<8)/17, (488<<8)/9
}; };
//static
int CheckDMA(void) PICO_INTERNAL int CheckDMA(void)
{ {
int burn = 0, bytes_can = 0, dma_op = Pico.video.reg[0x17]>>6; // see gens for 00 and 01 modes int burn = 0, bytes_can = 0, dma_op = Pico.video.reg[0x17]>>6; // see gens for 00 and 01 modes
int bytes = Pico.m.dma_bytes; int bytes = Pico.m.dma_bytes;

View file

@ -12,6 +12,8 @@
#ifndef PICO_H #ifndef PICO_H
#define PICO_H #define PICO_H
#include <stdio.h>
// port-specific compile-time settings // port-specific compile-time settings
#include <port_config.h> #include <port_config.h>
@ -47,10 +49,8 @@ extern void (*PicoWriteSound)(int len); // called once per frame at the best tim
extern void (*PicoMessage)(const char *msg); // callback to output text message from emu extern void (*PicoMessage)(const char *msg); // callback to output text message from emu
// cd/Pico.c // cd/Pico.c
int PicoFrameMCD(void);
extern void (*PicoMCDopenTray)(void); extern void (*PicoMCDopenTray)(void);
extern int (*PicoMCDcloseTray)(void); extern int (*PicoMCDcloseTray)(void);
extern int PicoCDBuffers; extern int PicoCDBuffers;
// Area.c // Area.c
@ -67,10 +67,17 @@ extern areaseek *areaSeek;
extern areaclose *areaClose; extern areaclose *areaClose;
extern void (*PicoStateProgressCB)(const char *str); extern void (*PicoStateProgressCB)(const char *str);
// cd/Area.c
int PicoCdLoadStateGfx(void *file);
// cd/buffering.c // cd/buffering.c
void PicoCDBufferInit(void); void PicoCDBufferInit(void);
void PicoCDBufferFree(void); void PicoCDBufferFree(void);
// cd/cd_sys.c
int Insert_CD(char *iso_name, int is_bin);
void Stop_CD(void); // releases all resources taken when CD game was started.
// Cart.c // Cart.c
typedef enum typedef enum
{ {
@ -117,11 +124,7 @@ extern void (*PicoPrepareCram)(); // prepares PicoCramHigh for renderer to us
// sound.c // sound.c
extern int PsndRate,PsndLen; extern int PsndRate,PsndLen;
extern short *PsndOut; extern short *PsndOut;
void sound_reset();
void sound_rerate(int preserve_state); void sound_rerate(int preserve_state);
void z80_pack(unsigned char *data);
void z80_unpack(unsigned char *data);
void z80_reset();
// Utils.c // Utils.c
extern int PicuAnd; extern int PicuAnd;

View file

@ -1,4 +1,4 @@
// Pico Library - Header File // Pico Library - Internal Header File
// (c) Copyright 2004 Dave, All rights reserved. // (c) Copyright 2004 Dave, All rights reserved.
// (c) Copyright 2006,2007 Grazvydas "notaz" Ignotas, all rights reserved. // (c) Copyright 2006,2007 Grazvydas "notaz" Ignotas, all rights reserved.
@ -6,6 +6,8 @@
// For commercial use, separate licencing terms must be obtained. // For commercial use, separate licencing terms must be obtained.
#ifndef PICO_INTERNAL_INCLUDED
#define PICO_INTERNAL_INCLUDED
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -15,6 +17,12 @@
// //
#define USE_POLL_DETECT #define USE_POLL_DETECT
#ifndef PICO_INTERNAL
#define PICO_INTERNAL
#endif
#ifndef PICO_INTERNAL_ASM
#define PICO_INTERNAL_ASM
#endif
// to select core, define EMU_C68K, EMU_M68K or EMU_A68K in your makefile or project // to select core, define EMU_C68K, EMU_M68K or EMU_A68K in your makefile or project
@ -270,89 +278,102 @@ typedef struct
#define Pico_mcd ((mcd_state *)Pico.rom) #define Pico_mcd ((mcd_state *)Pico.rom)
// Area.c // Area.c
int PicoAreaPackCpu(unsigned char *cpu, int is_sub); PICO_INTERNAL int PicoAreaPackCpu(unsigned char *cpu, int is_sub);
int PicoAreaUnpackCpu(unsigned char *cpu, int is_sub); PICO_INTERNAL int PicoAreaUnpackCpu(unsigned char *cpu, int is_sub);
// cd/Area.c // cd/Area.c
int PicoCdSaveState(void *file); PICO_INTERNAL int PicoCdSaveState(void *file);
int PicoCdLoadState(void *file); PICO_INTERNAL int PicoCdLoadState(void *file);
int PicoCdLoadStateGfx(void *file);
// Draw.c // Draw.c
int PicoLine(int scan); PICO_INTERNAL int PicoLine(int scan);
void PicoFrameStart(); PICO_INTERNAL void PicoFrameStart(void);
// Draw2.c // Draw2.c
void PicoFrameFull(); PICO_INTERNAL void PicoFrameFull();
// Memory.c // Memory.c
int PicoInitPc(unsigned int pc); PICO_INTERNAL int PicoInitPc(unsigned int pc);
unsigned int CPU_CALL PicoRead32(unsigned int a); PICO_INTERNAL_ASM unsigned int CPU_CALL PicoRead32(unsigned int a);
void PicoMemSetup(); PICO_INTERNAL void PicoMemSetup(void);
void PicoMemReset(); PICO_INTERNAL_ASM void PicoMemReset(void);
//void PicoDasm(int start,int len); PICO_INTERNAL unsigned char z80_read(unsigned short a);
unsigned char z80_read(unsigned short a); PICO_INTERNAL unsigned short z80_read16(unsigned short a);
unsigned short z80_read16(unsigned short a); PICO_INTERNAL_ASM void z80_write(unsigned char data, unsigned short a);
void z80_write(unsigned char data, unsigned short a); PICO_INTERNAL void z80_write16(unsigned short data, unsigned short a);
void z80_write16(unsigned short data, unsigned short a);
// cd/Memory.c // cd/Memory.c
void PicoMemSetupCD(void); PICO_INTERNAL void PicoMemSetupCD(void);
void PicoMemResetCD(int r3); PICO_INTERNAL_ASM void PicoMemResetCD(int r3);
void PicoMemResetCDdecode(int r3); PICO_INTERNAL_ASM void PicoMemResetCDdecode(int r3);
unsigned char PicoReadCD8 (unsigned int a);
unsigned short PicoReadCD16(unsigned int a);
unsigned int PicoReadCD32(unsigned int a);
void PicoWriteCD8 (unsigned int a, unsigned char d);
void PicoWriteCD16(unsigned int a, unsigned short d);
void PicoWriteCD32(unsigned int a, unsigned int d);
// Pico.c // Pico.c
extern struct Pico Pico; extern struct Pico Pico;
extern struct PicoSRAM SRam; extern struct PicoSRAM SRam;
extern int emustatus; extern int emustatus;
extern int z80startCycle, z80stopCycle; // in 68k cycles extern int z80startCycle, z80stopCycle; // in 68k cycles
int CheckDMA(void); PICO_INTERNAL int CheckDMA(void);
// cd/Pico.c // cd/Pico.c
int PicoInitMCD(void); PICO_INTERNAL int PicoInitMCD(void);
void PicoExitMCD(void); PICO_INTERNAL int PicoResetMCD(int hard);
int PicoResetMCD(int hard); PICO_INTERNAL int PicoFrameMCD(void);
// Sek.c // Sek.c
int SekInit(void); PICO_INTERNAL int SekInit(void);
int SekReset(void); PICO_INTERNAL int SekReset(void);
int SekInterrupt(int irq); PICO_INTERNAL int SekInterrupt(int irq);
void SekState(unsigned char *data); PICO_INTERNAL void SekState(unsigned char *data);
void SekSetRealTAS(int use_real); PICO_INTERNAL void SekSetRealTAS(int use_real);
// cd/Sek.c // cd/Sek.c
int SekInitS68k(void); PICO_INTERNAL int SekInitS68k(void);
int SekResetS68k(void); PICO_INTERNAL int SekResetS68k(void);
int SekInterruptS68k(int irq); PICO_INTERNAL int SekInterruptS68k(int irq);
// sound/sound.c // sound/sound.c
extern int PsndLen_exc_cnt; extern int PsndLen_exc_cnt;
extern int PsndLen_exc_add; extern int PsndLen_exc_add;
// VideoPort.c // VideoPort.c
void PicoVideoWrite(unsigned int a,unsigned short d); PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d);
unsigned int PicoVideoRead(unsigned int a); PICO_INTERNAL_ASM unsigned int PicoVideoRead(unsigned int a);
// Misc.c // Misc.c
void SRAMWriteEEPROM(unsigned int d); PICO_INTERNAL void SRAMWriteEEPROM(unsigned int d);
unsigned int SRAMReadEEPROM(); PICO_INTERNAL void SRAMUpdPending(unsigned int a, unsigned int d);
void SRAMUpdPending(unsigned int a, unsigned int d); PICO_INTERNAL_ASM unsigned int SRAMReadEEPROM(void);
void memcpy16(unsigned short *dest, unsigned short *src, int count); PICO_INTERNAL_ASM void memcpy16(unsigned short *dest, unsigned short *src, int count);
void memcpy16bswap(unsigned short *dest, void *src, int count); PICO_INTERNAL_ASM void memcpy16bswap(unsigned short *dest, void *src, int count);
void memcpy32(int *dest, int *src, int count); // 32bit word count PICO_INTERNAL_ASM void memcpy32(int *dest, int *src, int count); // 32bit word count
void memset32(int *dest, int c, int count); PICO_INTERNAL_ASM void memset32(int *dest, int c, int count);
// cd/Misc.c // cd/Misc.c
void wram_2M_to_1M(unsigned char *m); PICO_INTERNAL_ASM void wram_2M_to_1M(unsigned char *m);
void wram_1M_to_2M(unsigned char *m); PICO_INTERNAL_ASM void wram_1M_to_2M(unsigned char *m);
// cd/buffering.c
PICO_INTERNAL void PicoCDBufferRead(void *dest, int lba);
// sound/sound.c
PICO_INTERNAL void sound_reset(void);
PICO_INTERNAL void sound_timers_and_dac(int raster);
PICO_INTERNAL int sound_render(int offset, int length);
PICO_INTERNAL void sound_clear(void);
// z80 functionality wrappers
PICO_INTERNAL void z80_init(void);
PICO_INTERNAL void z80_resetCycles(void);
PICO_INTERNAL void z80_int(void);
PICO_INTERNAL int z80_run(int cycles);
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);
#ifdef __cplusplus #ifdef __cplusplus
} // End of extern "C" } // End of extern "C"
#endif #endif
#endif // PICO_INTERNAL_INCLUDED

View file

@ -102,7 +102,7 @@ static int SekTasCallback(void)
int SekInit() PICO_INTERNAL int SekInit()
{ {
#ifdef EMU_C68K #ifdef EMU_C68K
CycloneInit(); CycloneInit();
@ -134,7 +134,7 @@ int SekInit()
} }
// Reset the 68000: // Reset the 68000:
int SekReset() PICO_INTERNAL int SekReset()
{ {
if (Pico.rom==NULL) return 1; if (Pico.rom==NULL) return 1;
@ -166,7 +166,7 @@ int SekReset()
} }
int SekInterrupt(int irq) PICO_INTERNAL int SekInterrupt(int irq)
{ {
#if defined(EMU_C68K) && defined(EMU_M68K) #if defined(EMU_C68K) && defined(EMU_M68K)
{ {
@ -196,7 +196,7 @@ int SekInterrupt(int irq)
//int SekPc() { return M68000_regs.pc; } //int SekPc() { return M68000_regs.pc; }
//int SekPc() { return m68k_get_reg(NULL, M68K_REG_PC); } //int SekPc() { return m68k_get_reg(NULL, M68K_REG_PC); }
void SekState(unsigned char *data) PICO_INTERNAL void SekState(unsigned char *data)
{ {
#ifdef EMU_C68K #ifdef EMU_C68K
memcpy(data,PicoCpu.d,0x44); memcpy(data,PicoCpu.d,0x44);
@ -209,7 +209,7 @@ void SekState(unsigned char *data)
#endif #endif
} }
void SekSetRealTAS(int use_real) PICO_INTERNAL void SekSetRealTAS(int use_real)
{ {
#ifdef EMU_C68K #ifdef EMU_C68K
CycloneSetRealTAS(use_real); CycloneSetRealTAS(use_real);

View file

@ -15,8 +15,12 @@ extern const unsigned char hcounts_40[];
extern const unsigned short vcounts[]; extern const unsigned short vcounts[];
extern int rendstatus; extern int rendstatus;
#ifndef UTYPES_DEFINED
typedef unsigned char u8; typedef unsigned char u8;
typedef unsigned short u16; typedef unsigned short u16;
typedef unsigned int u32;
#define UTYPES_DEFINED
#endif
static __inline void AutoIncrement() static __inline void AutoIncrement()
@ -308,7 +312,7 @@ static void CommandChange()
if (cmd&0x80) CommandDma(); if (cmd&0x80) CommandDma();
} }
void PicoVideoWrite(unsigned int a,unsigned short d) PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d)
{ {
struct PicoVideo *pvid=&Pico.video; struct PicoVideo *pvid=&Pico.video;
@ -390,7 +394,7 @@ void PicoVideoWrite(unsigned int a,unsigned short d)
} }
} }
unsigned int PicoVideoRead(unsigned int a) PICO_INTERNAL_ASM unsigned int PicoVideoRead(unsigned int a)
{ {
unsigned int d=0; unsigned int d=0;

View file

@ -88,7 +88,7 @@ static int write_chunk(chunk_name_e name, int len, void *data, void *file)
if (PicoStateProgressCB) PicoStateProgressCB(chunk_names[name]); \ if (PicoStateProgressCB) PicoStateProgressCB(chunk_names[name]); \
if (!write_chunk(name, sizeof(buff), &buff, file)) return 1; if (!write_chunk(name, sizeof(buff), &buff, file)) return 1;
int PicoCdSaveState(void *file) PICO_INTERNAL int PicoCdSaveState(void *file)
{ {
unsigned char buff[0x60]; unsigned char buff[0x60];
void *ym2612_regs = YM2612GetRegs(); void *ym2612_regs = YM2612GetRegs();
@ -168,7 +168,7 @@ static int g_read_offs = 0;
#define CHECKED_READ_BUFF(buff) CHECKED_READ2(sizeof(buff), &buff); #define CHECKED_READ_BUFF(buff) CHECKED_READ2(sizeof(buff), &buff);
int PicoCdLoadState(void *file) PICO_INTERNAL int PicoCdLoadState(void *file)
{ {
unsigned char buff[0x60]; unsigned char buff[0x60];
int ver, len; int ver, len;

View file

@ -56,7 +56,7 @@ static void CDC_Reset(void)
} }
void LC89510_Reset(void) PICO_INTERNAL void LC89510_Reset(void)
{ {
CDD_Reset(); CDD_Reset();
CDC_Reset(); CDC_Reset();
@ -66,7 +66,7 @@ void LC89510_Reset(void)
} }
void Update_CDC_TRansfer(int which) PICO_INTERNAL void Update_CDC_TRansfer(int which)
{ {
unsigned int DMA_Adr, dep, length; unsigned int DMA_Adr, dep, length;
unsigned short *dest; unsigned short *dest;
@ -178,7 +178,7 @@ void Update_CDC_TRansfer(int which)
} }
unsigned short Read_CDC_Host(int is_sub) PICO_INTERNAL_ASM unsigned short Read_CDC_Host(int is_sub)
{ {
int addr; int addr;
@ -230,7 +230,7 @@ unsigned short Read_CDC_Host(int is_sub)
} }
void CDC_Update_Header(void) PICO_INTERNAL void CDC_Update_Header(void)
{ {
if (Pico_mcd->cdc.CTRL.B.B1 & 0x01) // Sub-Header wanted ? if (Pico_mcd->cdc.CTRL.B.B1 & 0x01) // Sub-Header wanted ?
{ {
@ -253,7 +253,7 @@ void CDC_Update_Header(void)
} }
unsigned char CDC_Read_Reg(void) PICO_INTERNAL unsigned char CDC_Read_Reg(void)
{ {
unsigned char ret; unsigned char ret;
@ -376,7 +376,7 @@ unsigned char CDC_Read_Reg(void)
} }
void CDC_Write_Reg(unsigned char Data) PICO_INTERNAL void CDC_Write_Reg(unsigned char Data)
{ {
cdprintf("CDC write reg%02d = %.2X", Pico_mcd->s68k_regs[5] & 0xF, Data); cdprintf("CDC write reg%02d = %.2X", Pico_mcd->s68k_regs[5] & 0xF, Data);
@ -494,7 +494,7 @@ static int bswapwrite(int a, unsigned short d)
return d + (d >> 8); return d + (d >> 8);
} }
void CDD_Export_Status(void) PICO_INTERNAL void CDD_Export_Status(void)
{ {
unsigned int csum; unsigned int csum;
@ -524,7 +524,7 @@ void CDD_Export_Status(void)
} }
void CDD_Import_Command(void) PICO_INTERNAL void CDD_Import_Command(void)
{ {
// cdprintf("CDD importing command\n"); // cdprintf("CDD importing command\n");
cdprintf("in: Command=%.4X, Minute=%.4X, Second=%.4X, Frame=%.4X Checksum=%.4X", cdprintf("in: Command=%.4X, Minute=%.4X, Second=%.4X, Frame=%.4X Checksum=%.4X",

View file

@ -115,16 +115,16 @@ typedef struct
} CDD; } CDD;
void LC89510_Reset(void); PICO_INTERNAL_ASM unsigned short Read_CDC_Host(int is_sub);
unsigned short Read_CDC_Host(int is_sub); PICO_INTERNAL void LC89510_Reset(void);
void Update_CDC_TRansfer(int which); PICO_INTERNAL void Update_CDC_TRansfer(int which);
void CDC_Update_Header(void); PICO_INTERNAL void CDC_Update_Header(void);
unsigned char CDC_Read_Reg(void); PICO_INTERNAL unsigned char CDC_Read_Reg(void);
void CDC_Write_Reg(unsigned char Data); PICO_INTERNAL void CDC_Write_Reg(unsigned char Data);
void CDD_Export_Status(void); PICO_INTERNAL void CDD_Export_Status(void);
void CDD_Import_Command(void); PICO_INTERNAL void CDD_Import_Command(void);
#ifdef __cplusplus #ifdef __cplusplus
}; };

View file

@ -8,16 +8,18 @@
#include "../PicoInt.h" #include "../PicoInt.h"
#include "../sound/sound.h"
#include "../sound/ym2612.h" #include "../sound/ym2612.h"
#include "../sound/sn76496.h" #include "../sound/sn76496.h"
#include "gfx_cd.h" #include "gfx_cd.h"
#include "pcm.h" #include "pcm.h"
#ifndef UTYPES_DEFINED
typedef unsigned char u8; typedef unsigned char u8;
typedef unsigned short u16; typedef unsigned short u16;
typedef unsigned int u32; typedef unsigned int u32;
#define UTYPES_DEFINED
#endif
//#define __debug_io //#define __debug_io
//#define __debug_io2 //#define __debug_io2
@ -1454,7 +1456,7 @@ static u32 PicoCheckPcS68k(u32 pc)
#endif #endif
void PicoMemSetupCD() PICO_INTERNAL void PicoMemSetupCD(void)
{ {
dprintf("PicoMemSetupCD()"); dprintf("PicoMemSetupCD()");
#ifdef EMU_C68K #ifdef EMU_C68K

View file

@ -24,7 +24,7 @@ unsigned char formatted_bram[4*0x10] =
// 256K | unused | bank1 | // 256K | unused | bank1 |
#ifndef _ASM_MISC_C #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 short *m1M_b0, *m1M_b1;
unsigned int i, tmp, *m2M; unsigned int i, tmp, *m2M;
@ -41,7 +41,7 @@ void wram_2M_to_1M(unsigned char *m)
} }
} }
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 short *m1M_b0, *m1M_b1;
unsigned int i, tmp, *m2M; unsigned int i, tmp, *m2M;

View file

@ -2,7 +2,6 @@
#include "../PicoInt.h" #include "../PicoInt.h"
#include "../sound/sound.h"
extern unsigned char formatted_bram[4*0x10]; extern unsigned char formatted_bram[4*0x10];
@ -32,7 +31,7 @@ int (*PicoMCDcloseTray)(void) = NULL;
} }
int PicoInitMCD(void) PICO_INTERNAL int PicoInitMCD(void)
{ {
SekInitS68k(); SekInitS68k();
Init_CD_Driver(); Init_CD_Driver();
@ -41,7 +40,7 @@ int PicoInitMCD(void)
} }
void PicoExitMCD(void) PICO_INTERNAL void PicoExitMCD(void)
{ {
End_CD_Driver(); End_CD_Driver();
@ -49,7 +48,7 @@ void PicoExitMCD(void)
//dump_ram(Pico.ram, "ram.bin"); //dump_ram(Pico.ram, "ram.bin");
} }
int PicoResetMCD(int hard) PICO_INTERNAL int PicoResetMCD(int hard)
{ {
if (hard) { if (hard) {
int fmt_size = sizeof(formatted_bram); int fmt_size = sizeof(formatted_bram);
@ -84,7 +83,7 @@ int PicoResetMCD(int hard)
return 0; return 0;
} }
static __inline void SekRun(int cyc) static __inline void SekRunM68k(int cyc)
{ {
int cyc_do; int cyc_do;
SekCycleAim+=cyc; SekCycleAim+=cyc;
@ -291,7 +290,7 @@ static int PicoFrameHintsMCD(void)
{ {
//dprintf("vint: @ %06x [%i|%i]", SekPc, y, SekCycleCnt); //dprintf("vint: @ %06x [%i|%i]", SekPc, y, SekCycleCnt);
pv->status|=0x88; // V-Int happened, go into vblank 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)) { /*if(Pico.m.z80Run && (PicoOpt&4)) {
z80CycleAim+=cycles_z80/2; z80CycleAim+=cycles_z80/2;
total_z80+=z80_run(z80CycleAim-total_z80); total_z80+=z80_run(z80CycleAim-total_z80);
@ -329,7 +328,7 @@ static int PicoFrameHintsMCD(void)
if ((PicoOpt & 0x2000) && (Pico_mcd->m.busreq&3) == 1) { if ((PicoOpt & 0x2000) && (Pico_mcd->m.busreq&3) == 1) {
SekRunPS(cycles_68k, cycles_s68k); // "better/perfect sync" SekRunPS(cycles_68k, cycles_s68k); // "better/perfect sync"
} else { } else {
SekRun(cycles_68k); SekRunM68k(cycles_68k);
if ((Pico_mcd->m.busreq&3) == 1) // no busreq/no reset if ((Pico_mcd->m.busreq&3) == 1) // no busreq/no reset
SekRunS68k(cycles_s68k); SekRunS68k(cycles_s68k);
} }
@ -358,7 +357,7 @@ static int PicoFrameHintsMCD(void)
} }
int PicoFrameMCD(void) PICO_INTERNAL int PicoFrameMCD(void)
{ {
if(!(PicoOpt&0x10)) if(!(PicoOpt&0x10))
PicoFrameStart(); PicoFrameStart();

View file

@ -49,12 +49,12 @@ static int SekIntAckS68k(int level)
return CYCLONE_INT_ACK_AUTOVECTOR; return CYCLONE_INT_ACK_AUTOVECTOR;
} }
static void SekResetAck() static void SekResetAckS68k(void)
{ {
dprintf("s68k: Reset encountered @ %06x", SekPcS68k); dprintf("s68k: Reset encountered @ %06x", SekPcS68k);
} }
static int SekUnrecognizedOpcode() static int SekUnrecognizedOpcodeS68k(void)
{ {
unsigned int pc, op; unsigned int pc, op;
pc = SekPcS68k; pc = SekPcS68k;
@ -67,14 +67,14 @@ static int SekUnrecognizedOpcode()
int SekInitS68k() PICO_INTERNAL int SekInitS68k()
{ {
#ifdef EMU_C68K #ifdef EMU_C68K
// CycloneInit(); // CycloneInit();
memset(&PicoCpuS68k,0,sizeof(PicoCpuS68k)); memset(&PicoCpuS68k,0,sizeof(PicoCpuS68k));
PicoCpuS68k.IrqCallback=SekIntAckS68k; PicoCpuS68k.IrqCallback=SekIntAckS68k;
PicoCpuS68k.ResetCallback=SekResetAck; PicoCpuS68k.ResetCallback=SekResetAckS68k;
PicoCpuS68k.UnrecognizedCallback=SekUnrecognizedOpcode; PicoCpuS68k.UnrecognizedCallback=SekUnrecognizedOpcodeS68k;
#endif #endif
#ifdef EMU_M68K #ifdef EMU_M68K
{ {
@ -93,7 +93,7 @@ int SekInitS68k()
} }
// Reset the 68000: // Reset the 68000:
int SekResetS68k() PICO_INTERNAL int SekResetS68k()
{ {
if (Pico.rom==NULL) return 1; if (Pico.rom==NULL) return 1;
@ -122,7 +122,7 @@ int SekResetS68k()
return 0; return 0;
} }
int SekInterruptS68k(int irq) PICO_INTERNAL int SekInterruptS68k(int irq)
{ {
int irqs, real_irq = 1; int irqs, real_irq = 1;
Pico_mcd->m.s68k_pend_ints |= 1 << irq; Pico_mcd->m.s68k_pend_ints |= 1 << irq;

View file

@ -50,7 +50,7 @@ void PicoCDBufferFree(void)
/* this is a try to fight slow SD access of GP2X */ /* 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; int is_bin, offs, read_len, moved = 0;
reads++; reads++;

View file

@ -8,22 +8,16 @@
***********************************************************/ ***********************************************************/
#include <sys/stat.h> #include <sys/stat.h>
#include "cd_file.h"
#include "../PicoInt.h" #include "../PicoInt.h"
#include "cd_file.h"
#define cdprintf dprintf #define cdprintf dprintf
//#define cdprintf(x...) //#define cdprintf(x...)
#define DEBUG_CD #define DEBUG_CD
void FILE_End(void) PICO_INTERNAL int Load_ISO(const char *iso_name, int is_bin)
{
Unload_ISO();
}
int Load_ISO(const char *iso_name, int is_bin)
{ {
int i, j, num_track, Cur_LBA, index, ret, iso_name_len; int i, j, num_track, Cur_LBA, index, ret, iso_name_len;
_scd_track *Tracks = Pico_mcd->TOC.Tracks; _scd_track *Tracks = Pico_mcd->TOC.Tracks;
@ -134,7 +128,7 @@ int Load_ISO(const char *iso_name, int is_bin)
} }
void Unload_ISO(void) PICO_INTERNAL void Unload_ISO(void)
{ {
int i; int i;
@ -150,10 +144,7 @@ void Unload_ISO(void)
} }
void PicoCDBufferRead(void *dest, int lba); PICO_INTERNAL int FILE_Read_One_LBA_CDC(void)
int FILE_Read_One_LBA_CDC(void)
{ {
// static char cp_buf[2560]; // static char cp_buf[2560];
@ -281,7 +272,7 @@ int FILE_Read_One_LBA_CDC(void)
} }
int FILE_Play_CD_LBA(void) PICO_INTERNAL int FILE_Play_CD_LBA(void)
{ {
int index = Pico_mcd->scd.Cur_Track - 1; int index = Pico_mcd->scd.Cur_Track - 1;
Pico_mcd->m.audio_track = index; Pico_mcd->m.audio_track = index;

View file

@ -12,11 +12,10 @@ extern "C" {
void FILE_End(void); PICO_INTERNAL int Load_ISO(const char *iso_name, int is_bin);
int Load_ISO(const char *iso_name, int is_bin); PICO_INTERNAL void Unload_ISO(void);
void Unload_ISO(void); PICO_INTERNAL int FILE_Read_One_LBA_CDC(void);
int FILE_Read_One_LBA_CDC(void); PICO_INTERNAL int FILE_Play_CD_LBA(void);
int FILE_Play_CD_LBA(void);
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -8,10 +8,10 @@
***********************************************************/ ***********************************************************/
#include <stdio.h> #include <stdio.h>
#include "cd_sys.h"
#include "cd_file.h"
#include "../PicoInt.h" #include "../PicoInt.h"
#include "cd_sys.h"
#include "cd_file.h"
#define cdprintf dprintf #define cdprintf dprintf
//#define cdprintf(x...) //#define cdprintf(x...)
@ -68,7 +68,7 @@ static int MSF_to_LBA(_msf *MSF)
} }
void LBA_to_MSF(int lba, _msf *MSF) PICO_INTERNAL void LBA_to_MSF(int lba, _msf *MSF)
{ {
if (lba < -150) lba = 0; if (lba < -150) lba = 0;
else lba += 150; else lba += 150;
@ -122,7 +122,7 @@ static void Track_to_MSF(int track, _msf *MSF)
} }
int Track_to_LBA(int track) PICO_INTERNAL int Track_to_LBA(int track)
{ {
_msf MSF; _msf MSF;
@ -131,7 +131,7 @@ int Track_to_LBA(int track)
} }
void Check_CD_Command(void) PICO_INTERNAL void Check_CD_Command(void)
{ {
cdprintf("CHECK CD COMMAND"); cdprintf("CHECK CD COMMAND");
@ -175,19 +175,19 @@ void Check_CD_Command(void)
} }
int Init_CD_Driver(void) PICO_INTERNAL int Init_CD_Driver(void)
{ {
return 0; return 0;
} }
void End_CD_Driver(void) PICO_INTERNAL void End_CD_Driver(void)
{ {
FILE_End(); Unload_ISO();
} }
void Reset_CD(void) PICO_INTERNAL void Reset_CD(void)
{ {
Pico_mcd->scd.Cur_Track = 0; Pico_mcd->scd.Cur_Track = 0;
Pico_mcd->scd.Cur_LBA = -150; Pico_mcd->scd.Cur_LBA = -150;
@ -202,9 +202,6 @@ int Insert_CD(char *iso_name, int is_bin)
{ {
int ret = 0; int ret = 0;
// memset(CD_Audio_Buffer_L, 0, 4096 * 4);
// memset(CD_Audio_Buffer_R, 0, 4096 * 4);
CD_Present = 0; CD_Present = 0;
Pico_mcd->scd.Status_CDD = NOCD; Pico_mcd->scd.Status_CDD = NOCD;
@ -228,14 +225,15 @@ void Stop_CD(void)
} }
void Change_CD(void) /*
PICO_INTERNAL void Change_CD(void)
{ {
if (Pico_mcd->scd.Status_CDD == TRAY_OPEN) Close_Tray_CDD_cC(); if (Pico_mcd->scd.Status_CDD == TRAY_OPEN) Close_Tray_CDD_cC();
else Open_Tray_CDD_cD(); else Open_Tray_CDD_cD();
} }
*/
PICO_INTERNAL int Get_Status_CDD_c0(void)
int Get_Status_CDD_c0(void)
{ {
cdprintf("Status command : Cur LBA = %d", Pico_mcd->scd.Cur_LBA); cdprintf("Status command : Cur LBA = %d", Pico_mcd->scd.Cur_LBA);
@ -253,7 +251,7 @@ int Get_Status_CDD_c0(void)
} }
int Stop_CDD_c1(void) PICO_INTERNAL int Stop_CDD_c1(void)
{ {
CHECK_TRAY_OPEN CHECK_TRAY_OPEN
@ -276,7 +274,7 @@ int Stop_CDD_c1(void)
} }
int Get_Pos_CDD_c20(void) PICO_INTERNAL int Get_Pos_CDD_c20(void)
{ {
_msf MSF; _msf MSF;
@ -308,7 +306,7 @@ int Get_Pos_CDD_c20(void)
} }
int Get_Track_Pos_CDD_c21(void) PICO_INTERNAL int Get_Track_Pos_CDD_c21(void)
{ {
int elapsed_time; int elapsed_time;
_msf MSF; _msf MSF;
@ -342,7 +340,7 @@ int Get_Track_Pos_CDD_c21(void)
} }
int Get_Current_Track_CDD_c22(void) PICO_INTERNAL int Get_Current_Track_CDD_c22(void)
{ {
cdprintf("Status CDD = %.4X Status = %.4X", Pico_mcd->scd.Status_CDD, Pico_mcd->cdd.Status); cdprintf("Status CDD = %.4X Status = %.4X", Pico_mcd->scd.Status_CDD, Pico_mcd->cdd.Status);
@ -371,7 +369,7 @@ int Get_Current_Track_CDD_c22(void)
} }
int Get_Total_Lenght_CDD_c23(void) PICO_INTERNAL int Get_Total_Lenght_CDD_c23(void)
{ {
CHECK_TRAY_OPEN CHECK_TRAY_OPEN
@ -395,7 +393,7 @@ int Get_Total_Lenght_CDD_c23(void)
} }
int Get_First_Last_Track_CDD_c24(void) PICO_INTERNAL int Get_First_Last_Track_CDD_c24(void)
{ {
CHECK_TRAY_OPEN CHECK_TRAY_OPEN
@ -418,7 +416,7 @@ int Get_First_Last_Track_CDD_c24(void)
} }
int Get_Track_Adr_CDD_c25(void) PICO_INTERNAL int Get_Track_Adr_CDD_c25(void)
{ {
int track_number; int track_number;
@ -452,7 +450,7 @@ int Get_Track_Adr_CDD_c25(void)
} }
int Play_CDD_c3(void) PICO_INTERNAL int Play_CDD_c3(void)
{ {
_msf MSF; _msf MSF;
int delay, new_lba; int delay, new_lba;
@ -510,7 +508,7 @@ int Play_CDD_c3(void)
} }
int Seek_CDD_c4(void) PICO_INTERNAL int Seek_CDD_c4(void)
{ {
_msf MSF; _msf MSF;
@ -548,7 +546,7 @@ int Seek_CDD_c4(void)
} }
int Pause_CDD_c6(void) PICO_INTERNAL int Pause_CDD_c6(void)
{ {
CHECK_TRAY_OPEN CHECK_TRAY_OPEN
CHECK_CD_PRESENT CHECK_CD_PRESENT
@ -571,7 +569,7 @@ int Pause_CDD_c6(void)
} }
int Resume_CDD_c7(void) PICO_INTERNAL int Resume_CDD_c7(void)
{ {
CHECK_TRAY_OPEN CHECK_TRAY_OPEN
CHECK_CD_PRESENT CHECK_CD_PRESENT
@ -613,7 +611,7 @@ int Resume_CDD_c7(void)
} }
int Fast_Foward_CDD_c8(void) PICO_INTERNAL int Fast_Foward_CDD_c8(void)
{ {
CHECK_TRAY_OPEN CHECK_TRAY_OPEN
CHECK_CD_PRESENT CHECK_CD_PRESENT
@ -634,7 +632,7 @@ int Fast_Foward_CDD_c8(void)
} }
int Fast_Rewind_CDD_c9(void) PICO_INTERNAL int Fast_Rewind_CDD_c9(void)
{ {
CHECK_TRAY_OPEN CHECK_TRAY_OPEN
CHECK_CD_PRESENT CHECK_CD_PRESENT
@ -655,7 +653,7 @@ int Fast_Rewind_CDD_c9(void)
} }
int Close_Tray_CDD_cC(void) PICO_INTERNAL int Close_Tray_CDD_cC(void)
{ {
CD_Present = 0; CD_Present = 0;
//Clear_Sound_Buffer(); //Clear_Sound_Buffer();
@ -681,7 +679,7 @@ int Close_Tray_CDD_cC(void)
} }
int Open_Tray_CDD_cD(void) PICO_INTERNAL int Open_Tray_CDD_cD(void)
{ {
CHECK_TRAY_OPEN CHECK_TRAY_OPEN
@ -709,7 +707,7 @@ int Open_Tray_CDD_cD(void)
} }
int CDD_cA(void) PICO_INTERNAL int CDD_cA(void)
{ {
CHECK_TRAY_OPEN CHECK_TRAY_OPEN
CHECK_CD_PRESENT CHECK_CD_PRESENT
@ -730,7 +728,7 @@ int CDD_cA(void)
} }
int CDD_Def(void) PICO_INTERNAL int CDD_Def(void)
{ {
Pico_mcd->cdd.Status = Pico_mcd->scd.Status_CDD; Pico_mcd->cdd.Status = Pico_mcd->scd.Status_CDD;

View file

@ -68,38 +68,38 @@ typedef struct {
} _scd; } _scd;
void LBA_to_MSF(int lba, _msf *MSF); PICO_INTERNAL void LBA_to_MSF(int lba, _msf *MSF);
int Track_to_LBA(int track); PICO_INTERNAL int Track_to_LBA(int track);
// moved to Pico.h
// int Insert_CD(char *iso_name, int is_bin);
// void Stop_CD(void);
void Check_CD_Command(void); PICO_INTERNAL void Check_CD_Command(void);
int Init_CD_Driver(void); PICO_INTERNAL int Init_CD_Driver(void);
void End_CD_Driver(void); PICO_INTERNAL void End_CD_Driver(void);
int Insert_CD(char *iso_name, int is_bin); PICO_INTERNAL void Reset_CD(void);
void Stop_CD(void);
void Change_CD(void);
void Reset_CD(void);
int Get_Status_CDD_c0(void); PICO_INTERNAL int Get_Status_CDD_c0(void);
int Stop_CDD_c1(void); PICO_INTERNAL int Stop_CDD_c1(void);
int Get_Pos_CDD_c20(void); PICO_INTERNAL int Get_Pos_CDD_c20(void);
int Get_Track_Pos_CDD_c21(void); PICO_INTERNAL int Get_Track_Pos_CDD_c21(void);
int Get_Current_Track_CDD_c22(void); PICO_INTERNAL int Get_Current_Track_CDD_c22(void);
int Get_Total_Lenght_CDD_c23(void); PICO_INTERNAL int Get_Total_Lenght_CDD_c23(void);
int Get_First_Last_Track_CDD_c24(void); PICO_INTERNAL int Get_First_Last_Track_CDD_c24(void);
int Get_Track_Adr_CDD_c25(void); PICO_INTERNAL int Get_Track_Adr_CDD_c25(void);
int Play_CDD_c3(void); PICO_INTERNAL int Play_CDD_c3(void);
int Seek_CDD_c4(void); PICO_INTERNAL int Seek_CDD_c4(void);
int Pause_CDD_c6(void); PICO_INTERNAL int Pause_CDD_c6(void);
int Resume_CDD_c7(void); PICO_INTERNAL int Resume_CDD_c7(void);
int Fast_Foward_CDD_c8(void); PICO_INTERNAL int Fast_Foward_CDD_c8(void);
int Fast_Rewind_CDD_c9(void); PICO_INTERNAL int Fast_Rewind_CDD_c9(void);
int CDD_cA(void); PICO_INTERNAL int CDD_cA(void);
int Close_Tray_CDD_cC(void); PICO_INTERNAL int Close_Tray_CDD_cC(void);
int Open_Tray_CDD_cD(void); PICO_INTERNAL int Open_Tray_CDD_cD(void);
int CDD_Def(void); PICO_INTERNAL int CDD_Def(void);
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -7,7 +7,7 @@
#include "../PicoInt.h" #include "../PicoInt.h"
#define rot_comp Pico_mcd->rot_comp #define _rot_comp Pico_mcd->rot_comp
static const int Table_Rot_Time[] = static const int Table_Rot_Time[] =
{ {
@ -37,35 +37,35 @@ static void gfx_cd_start(void)
{ {
int upd_len; int upd_len;
// rot_comp.XD_Mul = ((rot_comp.Reg_5C & 0x1f) + 1) * 4; // unused // _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.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.Buffer_Adr = (_rot_comp.Reg_5E & 0xfff8) << 2; // unused?
rot_comp.YD = (rot_comp.Reg_60 >> 3) & 7; _rot_comp.YD = (_rot_comp.Reg_60 >> 3) & 7;
rot_comp.Vector_Adr = (rot_comp.Reg_66 & 0xfffe) << 2; _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]; 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: // ? 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; break;
case 2: // .Dot_32 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; break;
case 4: // .Scr_16 case 4: // .Scr_16
rot_comp.Stamp_Map_Adr = 0x20000; _rot_comp.Stamp_Map_Adr = 0x20000;
break; break;
case 6: // .Scr_16_Dot_32 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; 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(); gfx_cd_update();
} }
@ -73,8 +73,8 @@ static void gfx_cd_start(void)
static void gfx_completed(void) static void gfx_completed(void)
{ {
rot_comp.Reg_58 &= 0x7fff; // Stamp_Size _rot_comp.Reg_58 &= 0x7fff; // Stamp_Size
rot_comp.Reg_64 = 0; _rot_comp.Reg_64 = 0;
if (Pico_mcd->s68k_regs[0x33] & (1<<1)) if (Pico_mcd->s68k_regs[0x33] & (1<<1))
{ {
dprintf("gfx_cd irq 1"); dprintf("gfx_cd irq 1");
@ -89,14 +89,14 @@ static void gfx_do(unsigned int func, unsigned short *stamp_base, unsigned int H
unsigned int XD, Buffer_Adr; unsigned int XD, Buffer_Adr;
int DYXS; int DYXS;
XD = rot_comp.Reg_60 & 7; XD = _rot_comp.Reg_60 & 7;
Buffer_Adr = ((rot_comp.Reg_5E & 0xfff8) + rot_comp.YD) << 2; Buffer_Adr = ((_rot_comp.Reg_5E & 0xfff8) + _rot_comp.YD) << 2;
ecx = *(unsigned int *)(Pico_mcd->word_ram2M + rot_comp.Vector_Adr); ecx = *(unsigned int *)(Pico_mcd->word_ram2M + _rot_comp.Vector_Adr);
edx = ecx >> 16; edx = ecx >> 16;
ecx = (ecx & 0xffff) << 8; ecx = (ecx & 0xffff) << 8;
edx <<= 8; edx <<= 8;
DYXS = *(int *)(Pico_mcd->word_ram2M + rot_comp.Vector_Adr + 4); DYXS = *(int *)(Pico_mcd->word_ram2M + _rot_comp.Vector_Adr + 4);
rot_comp.Vector_Adr += 8; _rot_comp.Vector_Adr += 8;
// MAKE_IMAGE_LINE // MAKE_IMAGE_LINE
while (H_Dot) while (H_Dot)
@ -269,12 +269,12 @@ Pixel_Out:
Next_Pixel: Next_Pixel:
ecx += (DYXS << 16) >> 16; // rot_comp.DXS; ecx += (DYXS << 16) >> 16; // _rot_comp.DXS;
edx += DYXS >> 16; // rot_comp.DYS; edx += DYXS >> 16; // _rot_comp.DYS;
XD++; XD++;
if (XD >= 8) if (XD >= 8)
{ {
Buffer_Adr += ((rot_comp.Reg_5C & 0x1f) + 1) << 5; Buffer_Adr += ((_rot_comp.Reg_5C & 0x1f) + 1) << 5;
XD = 0; XD = 0;
} }
H_Dot--; H_Dot--;
@ -283,17 +283,17 @@ Next_Pixel:
// nothing_to_draw: // nothing_to_draw:
rot_comp.YD++; _rot_comp.YD++;
// rot_comp.V_Dot--; // will be done by caller // _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; 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) if (!V_Dot)
{ {
@ -301,22 +301,22 @@ void gfx_cd_update(void)
return; return;
} }
jobs = rot_comp.Float_Part >> 16; jobs = _rot_comp.Float_Part >> 16;
if (!jobs) if (!jobs)
{ {
rot_comp.Float_Part += rot_comp.Draw_Speed; _rot_comp.Float_Part += _rot_comp.Draw_Speed;
return; return;
} }
rot_comp.Float_Part &= 0xffff; _rot_comp.Float_Part &= 0xffff;
rot_comp.Float_Part += rot_comp.Draw_Speed; _rot_comp.Float_Part += _rot_comp.Draw_Speed;
if (PicoOpt & 0x1000) // scale/rot enabled if (PicoOpt & 0x1000) // scale/rot enabled
{ {
unsigned int func = rot_comp.Function; unsigned int func = _rot_comp.Function;
unsigned int H_Dot = rot_comp.Reg_62 & 0x1ff; 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 short *stamp_base = (unsigned short *) (Pico_mcd->word_ram2M + _rot_comp.Stamp_Map_Adr);
while (jobs--) while (jobs--)
{ {
@ -341,22 +341,22 @@ void gfx_cd_update(void)
V_Dot -= 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; unsigned int d = 0;
switch (a) { switch (a) {
case 0x58: d = rot_comp.Reg_58; break; case 0x58: d = _rot_comp.Reg_58; break;
case 0x5A: d = rot_comp.Reg_5A; break; case 0x5A: d = _rot_comp.Reg_5A; break;
case 0x5C: d = rot_comp.Reg_5C; break; case 0x5C: d = _rot_comp.Reg_5C; break;
case 0x5E: d = rot_comp.Reg_5E; break; case 0x5E: d = _rot_comp.Reg_5E; break;
case 0x60: d = rot_comp.Reg_60; break; case 0x60: d = _rot_comp.Reg_60; break;
case 0x62: d = rot_comp.Reg_62; break; case 0x62: d = _rot_comp.Reg_62; break;
case 0x64: d = rot_comp.Reg_64; break; case 0x64: d = _rot_comp.Reg_64; break;
case 0x66: break; case 0x66: break;
default: dprintf("gfx_cd_read FIXME: unexpected address: %02x", a); break; default: dprintf("gfx_cd_read FIXME: unexpected address: %02x", a); break;
} }
@ -366,41 +366,41 @@ unsigned int gfx_cd_read(unsigned int a)
return d; 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); dprintf("gfx_cd_write16(%x, %04x)", a, d);
switch (a) { switch (a) {
case 0x58: // .Reg_Stamp_Size case 0x58: // .Reg_Stamp_Size
rot_comp.Reg_58 = d & 7; _rot_comp.Reg_58 = d & 7;
return; return;
case 0x5A: // .Reg_Stamp_Adr case 0x5A: // .Reg_Stamp_Adr
rot_comp.Reg_5A = d & 0xffe0; _rot_comp.Reg_5A = d & 0xffe0;
return; return;
case 0x5C: // .Reg_IM_VCell_Size case 0x5C: // .Reg_IM_VCell_Size
rot_comp.Reg_5C = d & 0x1f; _rot_comp.Reg_5C = d & 0x1f;
return; return;
case 0x5E: // .Reg_IM_Adr case 0x5E: // .Reg_IM_Adr
rot_comp.Reg_5E = d & 0xFFF8; _rot_comp.Reg_5E = d & 0xFFF8;
return; return;
case 0x60: // .Reg_IM_Offset case 0x60: // .Reg_IM_Offset
rot_comp.Reg_60 = d & 0x3f; _rot_comp.Reg_60 = d & 0x3f;
return; return;
case 0x62: // .Reg_IM_HDot_Size case 0x62: // .Reg_IM_HDot_Size
rot_comp.Reg_62 = d & 0x1ff; _rot_comp.Reg_62 = d & 0x1ff;
return; return;
case 0x64: // .Reg_IM_VDot_Size 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; return;
case 0x66: // .Reg_Vector_Adr 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 if (Pico_mcd->s68k_regs[3]&4) return; // can't do tanformations in 1M mode
gfx_cd_start(); gfx_cd_start();
return; return;
@ -410,9 +410,9 @@ void gfx_cd_write16(unsigned int a, unsigned int d)
} }
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));
} }
@ -420,10 +420,12 @@ void gfx_cd_reset(void)
#include "cell_map.c" #include "cell_map.c"
#ifndef UTYPES_DEFINED
typedef unsigned short u16; typedef unsigned short u16;
#endif
// check: Heart of the alien, jaguar xj 220 // 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 char *base;
unsigned int asrc, a2; unsigned int asrc, a2;

View file

@ -24,14 +24,14 @@ typedef struct
} Rot_Comp; } Rot_Comp;
void gfx_cd_update(void); PICO_INTERNAL void gfx_cd_update(void);
unsigned int gfx_cd_read(unsigned int a); PICO_INTERNAL_ASM unsigned int gfx_cd_read(unsigned int a);
void gfx_cd_write16(unsigned int a, unsigned int d); 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 #endif // _GFX_CD_H

View file

@ -7,7 +7,7 @@
static unsigned int g_rate = 0; // 18.14 fixed point 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); //printf("pcm_write(%i, %02x)\n", a, d);
@ -50,7 +50,7 @@ void pcm_write(unsigned int a, unsigned int 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 float step = 31.8 * 1024.0 / (float) rate; // max <4 @ 8000Hz
step *= 256*256/4; step *= 256*256/4;
@ -60,9 +60,7 @@ void pcm_set_rate(int rate)
} }
// TODO: make use of the fact that max_length == 3 PICO_INTERNAL void pcm_update(int *buffer, int length, int stereo)
void pcm_update(int *buffer, int length, int stereo)
{ {
struct pcm_chan *ch; struct pcm_chan *ch;
unsigned int step, addr; unsigned int step, addr;

View file

@ -1,7 +1,7 @@
#define PCM_STEP_SHIFT 11 #define PCM_STEP_SHIFT 11
void pcm_write(unsigned int a, unsigned int d); PICO_INTERNAL_ASM void pcm_write(unsigned int a, unsigned int d);
void pcm_set_rate(int rate); PICO_INTERNAL void pcm_set_rate(int rate);
void pcm_update(int *buffer, int length, int stereo); PICO_INTERNAL void pcm_update(int *buffer, int length, int stereo);

View file

@ -8,14 +8,9 @@
#include <string.h> #include <string.h>
#include "sound.h"
#include "ym2612.h" #include "ym2612.h"
#include "sn76496.h" #include "sn76496.h"
#ifndef __GNUC__
#pragma warning (disable:4244)
#endif
#if defined(_USE_MZ80) #if defined(_USE_MZ80)
#include "../../cpu/mz80/mz80.h" #include "../../cpu/mz80/mz80.h"
#elif defined(_USE_DRZ80) #elif defined(_USE_DRZ80)
@ -29,11 +24,8 @@
// master int buffer to mix to // master int buffer to mix to
static int PsndBuffer[2*44100/50]; static int PsndBuffer[2*44100/50];
//int z80CycleAim = 0;
// dac // dac
short *dac_out; static unsigned short dac_info[312]; // pppppppp ppppllll, p - pos in buff, l - length to write for this sample
unsigned short dac_info[312]; // pppppppp ppppllll, p - pos in buff, l - length to write for this sample
// for Pico // for Pico
int PsndRate=0; int PsndRate=0;
@ -51,7 +43,7 @@ void YM2612TimerHandler(int c,int cnt);
extern int *sn76496_regs; extern int *sn76496_regs;
static void dac_recalculate() static void dac_recalculate(void)
{ {
int i, dac_cnt, pos, len, lines = Pico.m.pal ? 312 : 262, mid = Pico.m.pal ? 68 : 93; int i, dac_cnt, pos, len, lines = Pico.m.pal ? 312 : 262, mid = Pico.m.pal ? 68 : 93;
@ -107,7 +99,7 @@ static void dac_recalculate()
} }
void sound_reset() PICO_INTERNAL void sound_reset(void)
{ {
void *ym2612_regs; void *ym2612_regs;
@ -169,7 +161,7 @@ void sound_rerate(int preserve_state)
// This is called once per raster (aka line), but not necessarily for every line // This is called once per raster (aka line), but not necessarily for every line
void sound_timers_and_dac(int raster) PICO_INTERNAL void sound_timers_and_dac(int raster)
{ {
int pos, len; int pos, len;
int do_dac = PsndOut && (PicoOpt&1) && *ym2612_dacen; int do_dac = PsndOut && (PicoOpt&1) && *ym2612_dacen;
@ -217,7 +209,7 @@ void sound_timers_and_dac(int raster)
} }
void sound_clear(void) PICO_INTERNAL void sound_clear(void)
{ {
int len = PsndLen; int len = PsndLen;
if (PsndLen_exc_add) len++; if (PsndLen_exc_add) len++;
@ -226,7 +218,7 @@ void sound_clear(void)
} }
int sound_render(int offset, int length) PICO_INTERNAL int sound_render(int offset, int length)
{ {
int buf32_updated = 0; int buf32_updated = 0;
int *buf32 = PsndBuffer+offset; int *buf32 = PsndBuffer+offset;
@ -333,7 +325,7 @@ static void DrZ80_irq_callback()
#endif #endif
// z80 functionality wrappers // z80 functionality wrappers
void z80_init() PICO_INTERNAL void z80_init(void)
{ {
#if defined(_USE_MZ80) #if defined(_USE_MZ80)
struct mz80context z80; struct mz80context z80;
@ -367,7 +359,7 @@ void z80_init()
#endif #endif
} }
void z80_reset() PICO_INTERNAL void z80_reset(void)
{ {
#if defined(_USE_MZ80) #if defined(_USE_MZ80)
mz80reset(); mz80reset();
@ -384,14 +376,14 @@ void z80_reset()
Pico.m.z80_fakeval = 0; // for faking when Z80 is disabled Pico.m.z80_fakeval = 0; // for faking when Z80 is disabled
} }
void z80_resetCycles() PICO_INTERNAL void z80_resetCycles(void)
{ {
#if defined(_USE_MZ80) #if defined(_USE_MZ80)
mz80GetElapsedTicks(1); mz80GetElapsedTicks(1);
#endif #endif
} }
void z80_int() PICO_INTERNAL void z80_int(void)
{ {
#if defined(_USE_MZ80) #if defined(_USE_MZ80)
mz80int(0); mz80int(0);
@ -402,7 +394,7 @@ void z80_int()
} }
// returns number of cycles actually executed // returns number of cycles actually executed
int z80_run(int cycles) PICO_INTERNAL int z80_run(int cycles)
{ {
#if defined(_USE_MZ80) #if defined(_USE_MZ80)
int ticks_pre = mz80GetElapsedTicks(0); int ticks_pre = mz80GetElapsedTicks(0);
@ -415,7 +407,7 @@ int z80_run(int cycles)
#endif #endif
} }
void z80_pack(unsigned char *data) PICO_INTERNAL void z80_pack(unsigned char *data)
{ {
#if defined(_USE_MZ80) #if defined(_USE_MZ80)
struct mz80context mz80; struct mz80context mz80;
@ -430,7 +422,7 @@ void z80_pack(unsigned char *data)
#endif #endif
} }
void z80_unpack(unsigned char *data) PICO_INTERNAL void z80_unpack(unsigned char *data)
{ {
#if defined(_USE_MZ80) #if defined(_USE_MZ80)
if(*(int *)data == 0x00005A6D) { // "mZ" save? if(*(int *)data == 0x00005A6D) { // "mZ" save?
@ -456,7 +448,7 @@ void z80_unpack(unsigned char *data)
#endif #endif
} }
void z80_exit() PICO_INTERNAL void z80_exit(void)
{ {
#if defined(_USE_MZ80) #if defined(_USE_MZ80)
mz80shutdown(); mz80shutdown();
@ -464,7 +456,7 @@ void z80_exit()
} }
#if defined(__DEBUG_PRINT) || defined(__GP2X__) #if defined(__DEBUG_PRINT) || defined(__GP2X__)
void z80_debug(char *dstr) PICO_INTERNAL void z80_debug(char *dstr)
{ {
#if defined(_USE_DRZ80) #if defined(_USE_DRZ80)
sprintf(dstr, "Z80 state: PC: %04x SP: %04x\n", drZ80.Z80PC-drZ80.Z80PC_BASE, drZ80.Z80SP-drZ80.Z80SP_BASE); sprintf(dstr, "Z80 state: PC: %04x SP: %04x\n", drZ80.Z80PC-drZ80.Z80PC_BASE, drZ80.Z80SP-drZ80.Z80SP_BASE);

View file

@ -1,29 +0,0 @@
// This is part of Pico Library
// (c) Copyright 2004 Dave, All rights reserved.
// (c) Copyright 2006 notaz, All rights reserved.
// Free for non-commercial use.
// For commercial use, separate licencing terms must be obtained.
#ifdef __cplusplus
extern "C" {
#endif
void sound_timers_and_dac(int raster);
int sound_render(int offset, int length);
void sound_clear(void);
//int YM2612PicoTick(int n);
// z80 functionality wrappers
void z80_init();
void z80_resetCycles();
void z80_int();
int z80_run(int cycles);
void z80_exit();
#ifdef __cplusplus
} // End of extern "C"
#endif

View file

@ -13,6 +13,7 @@ asm_ym2612 = 1
asm_misc = 1 asm_misc = 1
asm_cdpico = 1 asm_cdpico = 1
asm_cdmemory = 1 asm_cdmemory = 1
amalgamate = 1
#profile = 1 #profile = 1
#use_musashi = 1 #use_musashi = 1
#up = 1 #up = 1
@ -50,14 +51,20 @@ OBJCOPY = $(CROSS)objcopy
OBJS += main.o menu.o fonts.o gp2x.o usbjoy.o emu.o squidgehack.o asmutils.o cpuctrl.o readpng.o OBJS += main.o menu.o fonts.o gp2x.o usbjoy.o emu.o squidgehack.o asmutils.o cpuctrl.o readpng.o
# 940 core control # 940 core control
OBJS += 940ctl.o OBJS += 940ctl.o
# Pico # Pico
OBJS += ../../Pico/Area.o ../../Pico/Cart.o ../../Pico/Utils.o ../../Pico/Memory.o ../../Pico/Misc.o \ ifeq "$(amalgamate)" "1"
OBJS += ../../PicoAll.o
else
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/Pico.o ../../Pico/Sek.o ../../Pico/VideoPort.o ../../Pico/Draw2.o ../../Pico/Draw.o \
../../Pico/Patch.o ../../Pico/Patch.o
# Pico - CD # Pico - CD
OBJS += ../../Pico/cd/Pico.o ../../Pico/cd/Memory.o ../../Pico/cd/Sek.o ../../Pico/cd/LC89510.o \ OBJS += ../../Pico/cd/Pico.o ../../Pico/cd/Memory.o ../../Pico/cd/Sek.o ../../Pico/cd/LC89510.o \
../../Pico/cd/cd_sys.o ../../Pico/cd/cd_file.o ../../Pico/cd/gfx_cd.o \ ../../Pico/cd/cd_sys.o ../../Pico/cd/cd_file.o ../../Pico/cd/gfx_cd.o \
../../Pico/cd/Area.o ../../Pico/cd/Misc.o ../../Pico/cd/pcm.o ../../Pico/cd/buffering.o ../../Pico/cd/Area.o ../../Pico/cd/Misc.o ../../Pico/cd/pcm.o ../../Pico/cd/buffering.o
endif
# asm stuff # asm stuff
ifeq "$(asm_render)" "1" ifeq "$(asm_render)" "1"
DEFINC += -D_ASM_DRAW_C DEFINC += -D_ASM_DRAW_C
@ -84,9 +91,13 @@ ifeq "$(asm_cdmemory)" "1"
DEFINC += -D_ASM_CD_MEMORY_C DEFINC += -D_ASM_CD_MEMORY_C
OBJS += ../../Pico/cd/memory_asm.o OBJS += ../../Pico/cd/memory_asm.o
endif endif
# Pico - sound # Pico - sound
ifneq "$(amalgamate)" "1"
OBJS += ../../Pico/sound/sound.o
endif
OBJS += ../../Pico/sound/mix_asm.o OBJS += ../../Pico/sound/mix_asm.o
OBJS += ../../Pico/sound/sound.o ../../Pico/sound/sn76496.o ../../Pico/sound/ym2612.o OBJS += ../../Pico/sound/sn76496.o ../../Pico/sound/ym2612.o
# zlib # zlib
OBJS += ../../zlib/gzio.o ../../zlib/inffast.o ../../zlib/inflate.o ../../zlib/inftrees.o ../../zlib/trees.o \ OBJS += ../../zlib/gzio.o ../../zlib/inffast.o ../../zlib/inflate.o ../../zlib/inftrees.o ../../zlib/trees.o \
../../zlib/deflate.o ../../zlib/crc32.o ../../zlib/adler32.o ../../zlib/zutil.o ../../zlib/compress.o ../../zlib/deflate.o ../../zlib/crc32.o ../../zlib/adler32.o ../../zlib/zutil.o ../../zlib/compress.o
@ -217,17 +228,3 @@ rel: PicoDrive.gpe code940/pico940.bin ../readme.txt config.txt PicoDrive.man.tx
code940/code940.bin: code940/code940.bin:
make -C code940/ make -C code940/
# test
#usbjoy.o : usbjoy.c
# @echo $<
# @$(GCC) $(COPT) $(DEFINC) -fno-profile-generate -c $< -o $@
#
#../../Pico/Cart.o : ../../Pico/Cart.c
# @echo $<
# @$(GCC) $(COPT) $(DEFINC) -fno-profile-generate -c $< -o $@
#
#../../zlib/trees.o : ../../zlib/trees.c
# @echo $<
# @$(GCC) $(COPT) $(DEFINC) -fno-profile-generate -c $< -o $@

View file

@ -278,7 +278,7 @@ int emu_ReloadRom(void)
// bios_help() ? // bios_help() ?
return 0; return 0;
} else { } else {
if (PicoMCD & 1) PicoExitMCD(); if (PicoMCD & 1) Stop_CD();
PicoMCD &= ~1; PicoMCD &= ~1;
} }

View file

@ -27,7 +27,7 @@ LDFLAGS += `pkg-config --libs gthread-2.0`
OBJS += ../gp2x/main.o ../gp2x/menu.o ../gp2x/fonts.o ../gp2x/emu.o ../gp2x/usbjoy.o blit.o \ 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 gp2x.o 940ctl_ym2612.o ../gp2x/readpng.o
# Pico # 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/Pico.o ../../Pico/Sek.o ../../Pico/VideoPort.o ../../Pico/Draw2.o ../../Pico/Draw.o \
../../Pico/Patch.o ../../Pico/Patch.o
# Pico - CD # Pico - CD

10
tools/Makefile Normal file
View file

@ -0,0 +1,10 @@
CFLAGS = -Wall -ggdb
TARGET = amalgamate
OBJS = amalgamate.o
all: $(TARGET)
clean:
$(RM) $(TARGET) $(OBJS)

246
tools/amalgamate.c Normal file
View file

@ -0,0 +1,246 @@
#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;
}