mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-06 15:48:05 -04:00
work on 'vblank on line start' problem, var changes, mask defines
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@408 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
95dc5c5e5e
commit
602133e1c6
27 changed files with 359 additions and 945 deletions
|
@ -175,7 +175,7 @@ int PmovState(int PmovAction, void *PmovFile)
|
|||
int minimum=0;
|
||||
unsigned char head[32];
|
||||
|
||||
if ((PicoMCD & 1) || carthw_chunks != NULL)
|
||||
if ((PicoAHW & PAHW_MCD) || carthw_chunks != NULL)
|
||||
{
|
||||
if (PmovAction&1) return PicoCdSaveState(PmovFile);
|
||||
if (PmovAction&2) {
|
||||
|
|
13
Pico/Cart.c
13
Pico/Cart.c
|
@ -418,7 +418,7 @@ static unsigned char *PicoCartAlloc(int filesize)
|
|||
int alloc_size;
|
||||
unsigned char *rom;
|
||||
|
||||
if (PicoMCD & 1) return cd_realloc(NULL, filesize);
|
||||
if (PicoAHW & PAHW_MCD) return cd_realloc(NULL, filesize);
|
||||
|
||||
alloc_size=filesize+0x7ffff;
|
||||
if((filesize&0x3fff)==0x200) alloc_size-=0x200;
|
||||
|
@ -474,8 +474,9 @@ int PicoCartLoad(pm_file *f,unsigned char **prom,unsigned int *psize)
|
|||
}
|
||||
|
||||
// maybe we are loading MegaCD BIOS?
|
||||
if (!(PicoMCD&1) && size == 0x20000 && (!strncmp((char *)rom+0x124, "BOOT", 4) || !strncmp((char *)rom+0x128, "BOOT", 4))) {
|
||||
PicoMCD |= 1;
|
||||
if (!(PicoAHW & PAHW_MCD) && size == 0x20000 && (!strncmp((char *)rom+0x124, "BOOT", 4) ||
|
||||
!strncmp((char *)rom+0x128, "BOOT", 4))) {
|
||||
PicoAHW |= PAHW_MCD;
|
||||
rom = cd_realloc(rom, size);
|
||||
}
|
||||
|
||||
|
@ -511,6 +512,8 @@ int PicoCartInsert(unsigned char *rom,unsigned int romsize)
|
|||
PicoCartUnloadHook = NULL;
|
||||
}
|
||||
|
||||
PicoAHW &= ~PAHW_SVP;
|
||||
|
||||
PicoMemResetHooks();
|
||||
PicoDmaHook = NULL;
|
||||
PicoResetHook = NULL;
|
||||
|
@ -520,12 +523,12 @@ int PicoCartInsert(unsigned char *rom,unsigned int romsize)
|
|||
|
||||
PicoMemReset();
|
||||
|
||||
if (!(PicoMCD & 1))
|
||||
if (!(PicoAHW & PAHW_MCD))
|
||||
PicoCartDetect();
|
||||
|
||||
// setup correct memory map for loaded ROM
|
||||
// call PicoMemReset again due to possible memmap change
|
||||
if (PicoMCD & 1)
|
||||
if (PicoAHW & PAHW_MCD)
|
||||
PicoMemSetupCD();
|
||||
else PicoMemSetup();
|
||||
PicoMemReset();
|
||||
|
|
135
Pico/Draw.c
135
Pico/Draw.c
|
@ -9,7 +9,8 @@
|
|||
|
||||
#include "PicoInt.h"
|
||||
|
||||
int (*PicoScan)(unsigned int num, void *data)=NULL;
|
||||
int (*PicoScanBegin)(unsigned int num) = NULL;
|
||||
int (*PicoScanEnd) (unsigned int num) = NULL;
|
||||
|
||||
#if OVERRIDE_HIGHCOL
|
||||
static unsigned char DefHighCol[8+320+8];
|
||||
|
@ -26,12 +27,12 @@ static int HighCacheS[80+1]; // and sprites
|
|||
static int HighPreSpr[80*2+1]; // slightly preprocessed sprites
|
||||
char HighSprZ[320+8+8]; // Z-buffer for accurate sprites and shadow/hilight mode
|
||||
// (if bit 7 == 0, sh caused by tile; if bit 6 == 0 pixel must be shadowed, else hilighted, if bit5 == 1)
|
||||
// lsb->msb: moved sprites, not all window tiles use same priority, accurate sprites (copied from PicoOpt), interlace
|
||||
// dirty sprites, sonic mode, have layer with all hi prio tiles (mk3), layer sh/hi already processed
|
||||
int rendstatus;
|
||||
int Scanline=0; // Scanline
|
||||
int rendstatus = 0;
|
||||
int Scanline = 0; // Scanline
|
||||
|
||||
static int SpriteBlocks;
|
||||
static int skip_next_line=0;
|
||||
|
||||
//unsigned short ppt[] = { 0x0f11, 0x0ff1, 0x01f1, 0x011f, 0x01ff, 0x0f1f, 0x0f0e, 0x0e7c };
|
||||
|
||||
struct TileStrip
|
||||
|
@ -327,7 +328,7 @@ static void DrawStrip(struct TileStrip *ts, int plane_sh, int cellskip)
|
|||
// terminate the cache list
|
||||
*ts->hc = 0;
|
||||
// if oldcode wasn't changed, it means all layer is hi priority
|
||||
if (oldcode == -1) rendstatus|=0x40;
|
||||
if (oldcode == -1) rendstatus |= PDRAW_PLANE_HI_PRIO;
|
||||
}
|
||||
|
||||
// this is messy
|
||||
|
@ -386,7 +387,7 @@ void DrawStripVSRam(struct TileStrip *ts, int plane_sh, int cellskip)
|
|||
|
||||
// terminate the cache list
|
||||
*ts->hc = 0;
|
||||
if (oldcode == -1) rendstatus|=0x40;
|
||||
if (oldcode == -1) rendstatus |= PDRAW_PLANE_HI_PRIO;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -529,11 +530,11 @@ static void DrawWindow(int tstart, int tend, int prio, int sh) // int *hcache
|
|||
|
||||
ty=(Scanline&7)<<1; // Y-Offset into tile
|
||||
|
||||
if(!(rendstatus&2)) {
|
||||
if (!(rendstatus & PDRAW_WND_DIFF_PRIO)) {
|
||||
// check the first tile code
|
||||
code=Pico.vram[nametab+tilex];
|
||||
// if the whole window uses same priority (what is often the case), we may be able to skip this field
|
||||
if((code>>15) != prio) return;
|
||||
if ((code>>15) != prio) return;
|
||||
}
|
||||
|
||||
// Draw tiles across screen:
|
||||
|
@ -545,9 +546,9 @@ static void DrawWindow(int tstart, int tend, int prio, int sh) // int *hcache
|
|||
int pal;
|
||||
|
||||
code=Pico.vram[nametab+tilex];
|
||||
if(code==blank) continue;
|
||||
if((code>>15) != prio) {
|
||||
rendstatus|=2;
|
||||
if (code==blank) continue;
|
||||
if ((code>>15) != prio) {
|
||||
rendstatus |= PDRAW_WND_DIFF_PRIO;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -573,7 +574,7 @@ static void DrawWindow(int tstart, int tend, int prio, int sh) // int *hcache
|
|||
code=Pico.vram[nametab+tilex];
|
||||
if(code==blank) continue;
|
||||
if((code>>15) != prio) {
|
||||
rendstatus|=2;
|
||||
rendstatus |= PDRAW_WND_DIFF_PRIO;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -608,23 +609,20 @@ static void DrawWindow(int tstart, int tend, int prio, int sh) // int *hcache
|
|||
|
||||
static void DrawTilesFromCacheShPrep(void)
|
||||
{
|
||||
if (!(rendstatus&0x80))
|
||||
// as some layer has covered whole line with hi priority tiles,
|
||||
// we can process whole line and then act as if sh/hi mode was off.
|
||||
int c = 320/4, *zb = (int *)(HighCol+8);
|
||||
rendstatus |= PDRAW_SHHI_DONE;
|
||||
while (c--)
|
||||
{
|
||||
// as some layer has covered whole line with hi priority tiles,
|
||||
// we can process whole line and then act as if sh/hi mode was off.
|
||||
int c = 320/4, *zb = (int *)(HighCol+8);
|
||||
rendstatus|=0x80;
|
||||
while (c--)
|
||||
{
|
||||
int tmp = *zb;
|
||||
if (!(tmp & 0x80808080)) *zb=tmp&0x3f3f3f3f;
|
||||
else {
|
||||
if(!(tmp&0x00000080)) tmp&=~0x000000c0; if(!(tmp&0x00008000)) tmp&=~0x0000c000;
|
||||
if(!(tmp&0x00800000)) tmp&=~0x00c00000; if(!(tmp&0x80000000)) tmp&=~0xc0000000;
|
||||
*zb=tmp;
|
||||
}
|
||||
zb++;
|
||||
int tmp = *zb;
|
||||
if (!(tmp & 0x80808080)) *zb=tmp&0x3f3f3f3f;
|
||||
else {
|
||||
if(!(tmp&0x00000080)) tmp&=~0x000000c0; if(!(tmp&0x00008000)) tmp&=~0x0000c000;
|
||||
if(!(tmp&0x00800000)) tmp&=~0x00c00000; if(!(tmp&0x80000000)) tmp&=~0xc0000000;
|
||||
*zb=tmp;
|
||||
}
|
||||
zb++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -635,9 +633,10 @@ static void DrawTilesFromCache(int *hc, int sh, int rlim)
|
|||
|
||||
// *ts->hc++ = code | (dx<<16) | (ty<<25); // cache it
|
||||
|
||||
if (sh && (rendstatus&0xc0))
|
||||
if (sh && (rendstatus & (PDRAW_SHHI_DONE|PDRAW_PLANE_HI_PRIO)))
|
||||
{
|
||||
DrawTilesFromCacheShPrep();
|
||||
if (!(rendstatus & PDRAW_SHHI_DONE))
|
||||
DrawTilesFromCacheShPrep();
|
||||
sh = 0;
|
||||
}
|
||||
|
||||
|
@ -1069,16 +1068,16 @@ static void DrawAllSprites(int *hcache, int maxwidth, int prio, int sh)
|
|||
DrawAllSpritesInterlace(prio, maxwidth);
|
||||
return;
|
||||
}
|
||||
if(rs&0x11) {
|
||||
if (rs & (PDRAW_SPRITES_MOVED|PDRAW_DIRTY_SPRITES)) {
|
||||
//dprintf("PrepareSprites(%i) [%i]", (rs>>4)&1, scan);
|
||||
PrepareSprites(rs&0x10);
|
||||
rendstatus=rs&~0x11;
|
||||
PrepareSprites(rs & PDRAW_DIRTY_SPRITES);
|
||||
rendstatus = rs & ~(PDRAW_SPRITES_MOVED|PDRAW_DIRTY_SPRITES);
|
||||
}
|
||||
if (!(SpriteBlocks & (1<<(scan>>3)))) return;
|
||||
|
||||
if(((rs&4)||sh)&&prio==0)
|
||||
if (((rs&PDRAW_ACC_SPRITES)||sh) && prio==0)
|
||||
memset(HighSprZ, 0, 328);
|
||||
if(!(rs&4)&&prio) {
|
||||
if (!(rs&PDRAW_ACC_SPRITES)&&prio) {
|
||||
if(hcache[0]) DrawSpritesFromCache(hcache, sh);
|
||||
return;
|
||||
}
|
||||
|
@ -1131,9 +1130,9 @@ static void DrawAllSprites(int *hcache, int maxwidth, int prio, int sh)
|
|||
|
||||
// accurate sprites
|
||||
//dprintf("P:%i",((sx>>15)&1));
|
||||
if(rs&4) {
|
||||
if (rs & PDRAW_ACC_SPRITES) {
|
||||
// might need to skip this sprite
|
||||
if((pack2&0x8000) ^ (prio<<15)) continue;
|
||||
if ((pack2&0x8000) ^ (prio<<15)) continue;
|
||||
DrawSpriteZ(pack,pack2,sh|(prio<<1),(char)(0x1f-n));
|
||||
continue;
|
||||
}
|
||||
|
@ -1143,7 +1142,7 @@ static void DrawAllSprites(int *hcache, int maxwidth, int prio, int sh)
|
|||
}
|
||||
|
||||
// Go through sprites backwards:
|
||||
if(!(rs&4)) {
|
||||
if (!(rs & PDRAW_ACC_SPRITES)) {
|
||||
for (i--; i>=0; i--)
|
||||
DrawSprite(sprites[i],&hcache,sh);
|
||||
|
||||
|
@ -1185,7 +1184,7 @@ static void FinalizeLineBGR444(int sh)
|
|||
if (Pico.video.reg[12]&1) {
|
||||
len = 320;
|
||||
} else {
|
||||
if(!(PicoOpt&0x100)) pd+=32;
|
||||
if(!(PicoOpt&POPT_DIS_32C_BORDER)) pd+=32;
|
||||
len = 256;
|
||||
}
|
||||
|
||||
|
@ -1247,7 +1246,7 @@ static void FinalizeLineRGB555(int sh)
|
|||
if (Pico.video.reg[12]&1) {
|
||||
len = 320;
|
||||
} else {
|
||||
if (!(PicoOpt&0x100)) pd+=32;
|
||||
if (!(PicoOpt&POPT_DIS_32C_BORDER)) pd+=32;
|
||||
len = 256;
|
||||
}
|
||||
|
||||
|
@ -1269,12 +1268,13 @@ static void FinalizeLine8bit(int sh)
|
|||
int len, rs = rendstatus;
|
||||
static int dirty_count;
|
||||
|
||||
if (!sh && Pico.m.dirtyPal == 1 && Scanline < 222) {
|
||||
if (!sh && Pico.m.dirtyPal == 1 && Scanline < 222)
|
||||
{
|
||||
// a hack for mid-frame palette changes
|
||||
if (!(rs & 0x20))
|
||||
if (!(rs & PDRAW_SONIC_MODE))
|
||||
dirty_count = 1;
|
||||
else dirty_count++;
|
||||
rs |= 0x20;
|
||||
rs |= PDRAW_SONIC_MODE;
|
||||
rendstatus = rs;
|
||||
if (dirty_count == 3) {
|
||||
blockcpy(HighPal, Pico.cram, 0x40*2);
|
||||
|
@ -1286,11 +1286,11 @@ static void FinalizeLine8bit(int sh)
|
|||
if (Pico.video.reg[12]&1) {
|
||||
len = 320;
|
||||
} else {
|
||||
if(!(PicoOpt&0x100)) pd+=32;
|
||||
if (!(PicoOpt&POPT_DIS_32C_BORDER)) pd+=32;
|
||||
len = 256;
|
||||
}
|
||||
|
||||
if (!sh && rs & 0x20) {
|
||||
if (!sh && (rs & PDRAW_SONIC_MODE)) {
|
||||
if (dirty_count >= 11) {
|
||||
blockcpy_or(pd, HighCol+8, len, 0x80);
|
||||
} else {
|
||||
|
@ -1303,6 +1303,24 @@ static void FinalizeLine8bit(int sh)
|
|||
|
||||
static void (*FinalizeLine)(int sh) = FinalizeLineBGR444;
|
||||
|
||||
// hblank was enabled early during prev line processng -
|
||||
// it should have been blanked
|
||||
static void handle_early_blank(int scanline, int sh)
|
||||
{
|
||||
scanline--;
|
||||
|
||||
if (PicoScanBegin != NULL)
|
||||
PicoScanBegin(scanline);
|
||||
|
||||
BackFill(Pico.video.reg[7], sh);
|
||||
|
||||
if (FinalizeLine != NULL)
|
||||
FinalizeLine(sh);
|
||||
|
||||
if (PicoScanEnd != NULL)
|
||||
PicoScanEnd(scanline);
|
||||
}
|
||||
|
||||
// --------------------------------------------
|
||||
|
||||
static int DrawDisplay(int sh)
|
||||
|
@ -1311,7 +1329,7 @@ static int DrawDisplay(int sh)
|
|||
int win=0,edge=0,hvwind=0;
|
||||
int maxw, maxcells;
|
||||
|
||||
rendstatus&=~0xc0;
|
||||
rendstatus &= ~(PDRAW_SHHI_DONE|PDRAW_PLANE_HI_PRIO);
|
||||
|
||||
if(pvid->reg[12]&1) {
|
||||
maxw = 328; maxcells = 40;
|
||||
|
@ -1373,30 +1391,36 @@ static int DrawDisplay(int sh)
|
|||
}
|
||||
|
||||
|
||||
static int Skip=0;
|
||||
|
||||
PICO_INTERNAL void PicoFrameStart(void)
|
||||
{
|
||||
// prepare to do this frame
|
||||
rendstatus = (PicoOpt&0x80)>>5; // accurate sprites
|
||||
if(rendstatus)
|
||||
rendstatus = (PicoOpt&0x80)>>5; // accurate sprites, clear everything else
|
||||
if (rendstatus)
|
||||
Pico.video.status &= ~0x0020;
|
||||
else Pico.video.status |= 0x0020; // sprite collision
|
||||
if((Pico.video.reg[12]&6) == 6) rendstatus |= 8; // interlace mode
|
||||
if(Pico.m.dirtyPal) Pico.m.dirtyPal = 2; // reset dirty if needed
|
||||
if ((Pico.video.reg[12]&6) == 6) rendstatus |= PDRAW_INTERLACE; // interlace mode
|
||||
if (Pico.m.dirtyPal) Pico.m.dirtyPal = 2; // reset dirty if needed
|
||||
|
||||
PrepareSprites(1);
|
||||
Skip=0;
|
||||
skip_next_line=0;
|
||||
}
|
||||
|
||||
PICO_INTERNAL int PicoLine(int scan)
|
||||
{
|
||||
int sh;
|
||||
if (Skip>0) { Skip--; return 0; } // Skip rendering lines
|
||||
if (skip_next_line>0) { skip_next_line--; return 0; } // skip_next_line rendering lines
|
||||
|
||||
Scanline=scan;
|
||||
sh=(Pico.video.reg[0xC]&8)>>3; // shadow/hilight?
|
||||
|
||||
if (rendstatus & PDRAW_EARLY_BLANK) {
|
||||
if (scan > 0) handle_early_blank(scan, sh);
|
||||
rendstatus &= ~PDRAW_EARLY_BLANK;
|
||||
}
|
||||
|
||||
if (PicoScanBegin != NULL)
|
||||
skip_next_line = PicoScanBegin(scan);
|
||||
|
||||
// Draw screen:
|
||||
BackFill(Pico.video.reg[7], sh);
|
||||
if (Pico.video.reg[1]&0x40)
|
||||
|
@ -1405,7 +1429,8 @@ PICO_INTERNAL int PicoLine(int scan)
|
|||
if (FinalizeLine != NULL)
|
||||
FinalizeLine(sh);
|
||||
|
||||
Skip=PicoScan(Scanline,DrawLineDest);
|
||||
if (PicoScanEnd != NULL)
|
||||
PicoScanEnd(scan);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -112,7 +112,8 @@ int PadRead(int i)
|
|||
// orr the bits, which are set as output
|
||||
value = data_reg&(Pico.ioports[i+4]|0x80);
|
||||
|
||||
if(PicoOpt & 0x20) { // 6 button gamepad enabled
|
||||
if (PicoOpt & POPT_6BTN_PAD)
|
||||
{
|
||||
int phase = Pico.m.padTHPhase[i];
|
||||
|
||||
if(phase == 2 && !(data_reg&0x40)) { // TH
|
||||
|
@ -556,7 +557,7 @@ static unsigned int m68k_read_8 (unsigned int a, int do_fake)
|
|||
#ifdef EMU_CORE_DEBUG
|
||||
if(do_fake&&((ppop&0x3f)==0x3a||(ppop&0x3f)==0x3b)) return lastread_d[lrp_mus++&15];
|
||||
#endif
|
||||
if(PicoMCD&1) return m68k_read_pcrelative_CD8(a);
|
||||
if(PicoAHW&1) return m68k_read_pcrelative_CD8(a);
|
||||
if((a&0xe00000)==0xe00000) return *(u8 *)(Pico.ram+((a^1)&0xffff)); // Ram
|
||||
return 0;
|
||||
}
|
||||
|
@ -567,7 +568,7 @@ static unsigned int m68k_read_16(unsigned int a, int do_fake)
|
|||
#ifdef EMU_CORE_DEBUG
|
||||
if(do_fake&&((ppop&0x3f)==0x3a||(ppop&0x3f)==0x3b)) return lastread_d[lrp_mus++&15];
|
||||
#endif
|
||||
if(PicoMCD&1) return m68k_read_pcrelative_CD16(a);
|
||||
if(PicoAHW&1) return m68k_read_pcrelative_CD16(a);
|
||||
if((a&0xe00000)==0xe00000) return *(u16 *)(Pico.ram+(a&0xfffe)); // Ram
|
||||
return 0;
|
||||
}
|
||||
|
@ -578,7 +579,7 @@ static unsigned int m68k_read_32(unsigned int a, int do_fake)
|
|||
#ifdef EMU_CORE_DEBUG
|
||||
if(do_fake&&((ppop&0x3f)==0x3a||(ppop&0x3f)==0x3b)) return lastread_d[lrp_mus++&15];
|
||||
#endif
|
||||
if(PicoMCD&1) return m68k_read_pcrelative_CD32(a);
|
||||
if(PicoAHW&1) return m68k_read_pcrelative_CD32(a);
|
||||
if((a&0xe00000)==0xe00000) { u16 *pm=(u16 *)(Pico.ram+(a&0xfffe)); return (pm[0]<<16)|pm[1]; } // Ram
|
||||
return 0;
|
||||
}
|
||||
|
@ -638,34 +639,34 @@ void PicoWriteCD32w(unsigned int a, unsigned int d);
|
|||
/* it appears that Musashi doesn't always mask the unused bits */
|
||||
unsigned int m68k_read_memory_8(unsigned int address)
|
||||
{
|
||||
unsigned int d = (PicoMCD&1) ? PicoReadCD8w(address) : PicoRead8(address);
|
||||
unsigned int d = (PicoAHW&1) ? PicoReadCD8w(address) : PicoRead8(address);
|
||||
return d&0xff;
|
||||
}
|
||||
|
||||
unsigned int m68k_read_memory_16(unsigned int address)
|
||||
{
|
||||
unsigned int d = (PicoMCD&1) ? PicoReadCD16w(address) : PicoRead16(address);
|
||||
unsigned int d = (PicoAHW&1) ? PicoReadCD16w(address) : PicoRead16(address);
|
||||
return d&0xffff;
|
||||
}
|
||||
|
||||
unsigned int m68k_read_memory_32(unsigned int address)
|
||||
{
|
||||
return (PicoMCD&1) ? PicoReadCD32w(address) : PicoRead32(address);
|
||||
return (PicoAHW&1) ? PicoReadCD32w(address) : PicoRead32(address);
|
||||
}
|
||||
|
||||
void m68k_write_memory_8(unsigned int address, unsigned int value)
|
||||
{
|
||||
if (PicoMCD&1) PicoWriteCD8w(address, (u8)value); else PicoWrite8(address, (u8)value);
|
||||
if (PicoAHW&1) PicoWriteCD8w(address, (u8)value); else PicoWrite8(address, (u8)value);
|
||||
}
|
||||
|
||||
void m68k_write_memory_16(unsigned int address, unsigned int value)
|
||||
{
|
||||
if (PicoMCD&1) PicoWriteCD16w(address,(u16)value); else PicoWrite16(address,(u16)value);
|
||||
if (PicoAHW&1) PicoWriteCD16w(address,(u16)value); else PicoWrite16(address,(u16)value);
|
||||
}
|
||||
|
||||
void m68k_write_memory_32(unsigned int address, unsigned int value)
|
||||
{
|
||||
if (PicoMCD&1) PicoWriteCD32w(address, value); else PicoWrite32(address, value);
|
||||
if (PicoAHW&1) PicoWriteCD32w(address, value); else PicoWrite32(address, value);
|
||||
}
|
||||
#endif
|
||||
#endif // EMU_M68K
|
||||
|
@ -680,7 +681,7 @@ PICO_INTERNAL unsigned char z80_read(unsigned short a)
|
|||
|
||||
if ((a>>13)==2) // 0x4000-0x5fff (Charles MacDonald)
|
||||
{
|
||||
if (PicoOpt&1) ret = (u8) YM2612Read();
|
||||
if (PicoOpt&POPT_EN_FM) ret = (u8) YM2612Read();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -691,7 +692,7 @@ PICO_INTERNAL unsigned char z80_read(unsigned short a)
|
|||
addr68k=Pico.m.z80_bank68k<<15;
|
||||
addr68k+=a&0x7fff;
|
||||
|
||||
if (PicoMCD & 1)
|
||||
if (PicoAHW & PAHW_MCD)
|
||||
ret = PicoReadM68k8(addr68k);
|
||||
else ret = PicoRead8(addr68k);
|
||||
elprintf(EL_Z80BNK, "z80->68k r8 [%06x] %02x", addr68k, ret);
|
||||
|
@ -713,13 +714,13 @@ PICO_INTERNAL_ASM void z80_write(unsigned int a, unsigned char data)
|
|||
{
|
||||
if ((a>>13)==2) // 0x4000-0x5fff (Charles MacDonald)
|
||||
{
|
||||
if(PicoOpt&1) emustatus|=YM2612Write(a, data) & 1;
|
||||
if(PicoOpt&POPT_EN_FM) emustatus|=YM2612Write(a, data) & 1;
|
||||
return;
|
||||
}
|
||||
|
||||
if ((a&0xfff9)==0x7f11) // 7f11 7f13 7f15 7f17
|
||||
{
|
||||
if(PicoOpt&2) SN76496Write(data);
|
||||
if(PicoOpt&POPT_EN_PSG) SN76496Write(data);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -738,7 +739,7 @@ PICO_INTERNAL_ASM void z80_write(unsigned int a, unsigned char data)
|
|||
addr68k=Pico.m.z80_bank68k<<15;
|
||||
addr68k+=a&0x7fff;
|
||||
elprintf(EL_Z80BNK, "z80->68k w8 [%06x] %02x", addr68k, data);
|
||||
if (PicoMCD & 1)
|
||||
if (PicoAHW & PAHW_MCD)
|
||||
PicoWriteM68k8(addr68k, data);
|
||||
else PicoWrite8(addr68k, data);
|
||||
return;
|
||||
|
|
|
@ -18,7 +18,8 @@ u8 z80Read8(u32 a)
|
|||
|
||||
a&=0x1fff;
|
||||
|
||||
if(!(PicoOpt&4)) {
|
||||
if (!(PicoOpt&POPT_EN_Z80))
|
||||
{
|
||||
// Z80 disabled, do some faking
|
||||
static u8 zerosent = 0;
|
||||
if(a == Pico.m.z80_lastaddr) { // probably polling something
|
||||
|
@ -120,7 +121,7 @@ u32 OtherRead16(u32 a, int realsize)
|
|||
if ((a&0xff0000)==0xa00000) {
|
||||
if ((a&0x4000)==0x0000) { d=z80Read8(a); d|=d<<8; goto end; } // Z80 ram (not byteswaped)
|
||||
if ((a&0x6000)==0x4000) { // 0x4000-0x5fff, Fudge if disabled
|
||||
if(PicoOpt&1) d=YM2612Read();
|
||||
if(PicoOpt&POPT_EN_FM) d=YM2612Read();
|
||||
else d=Pico.m.rotate++&3;
|
||||
elprintf(EL_YM2612R, "read ym2612: %02x", d);
|
||||
goto end;
|
||||
|
@ -139,12 +140,13 @@ static void IoWrite8(u32 a, u32 d)
|
|||
{
|
||||
a=(a>>1)&0xf;
|
||||
// 6 button gamepad: if TH went from 0 to 1, gamepad changes state
|
||||
if(PicoOpt&0x20) {
|
||||
if(a==1) {
|
||||
if(PicoOpt&POPT_6BTN_PAD)
|
||||
{
|
||||
if (a==1) {
|
||||
Pico.m.padDelay[0] = 0;
|
||||
if(!(Pico.ioports[1]&0x40) && (d&0x40)) Pico.m.padTHPhase[0]++;
|
||||
}
|
||||
else if(a==2) {
|
||||
else if (a==2) {
|
||||
Pico.m.padDelay[1] = 0;
|
||||
if(!(Pico.ioports[2]&0x40) && (d&0x40)) Pico.m.padTHPhase[1]++;
|
||||
}
|
||||
|
|
55
Pico/Pico.c
55
Pico/Pico.c
|
@ -12,20 +12,20 @@
|
|||
|
||||
int PicoVer=0x0133;
|
||||
struct Pico Pico;
|
||||
int PicoOpt=0; // disable everything by default
|
||||
int PicoSkipFrame=0; // skip rendering frame?
|
||||
int PicoOpt = 0;
|
||||
int PicoSkipFrame = 0; // skip rendering frame?
|
||||
int emustatus = 0; // rapid_ym2612, multi_ym_updates
|
||||
int PicoPad[2]; // Joypads, format is SACB RLDU
|
||||
int PicoAHW = 0; // active addon hardware: scd_active, 32x_active, svp_active
|
||||
int PicoRegionOverride = 0; // override the region detection 0: Auto, 1: Japan NTSC, 2: Japan PAL, 4: US, 8: Europe
|
||||
int PicoAutoRgnOrder = 0;
|
||||
int emustatus = 0; // rapid_ym2612, multi_ym_updates
|
||||
int z80startCycle, z80stopCycle; // in 68k cycles
|
||||
struct PicoSRAM SRam = {0,};
|
||||
|
||||
void (*PicoWriteSound)(int len) = NULL; // called at the best time to send sound buffer (PsndOut) to hardware
|
||||
void (*PicoResetHook)(void) = NULL;
|
||||
void (*PicoLineHook)(int count) = NULL;
|
||||
|
||||
struct PicoSRAM SRam = {0,};
|
||||
int z80startCycle, z80stopCycle; // in 68k cycles
|
||||
int PicoPad[2]; // Joypads, format is SACB RLDU
|
||||
int PicoMCD = 0; // mega CD status: scd_started
|
||||
|
||||
// to be called once on emu init
|
||||
int PicoInit(void)
|
||||
{
|
||||
|
@ -48,7 +48,7 @@ int PicoInit(void)
|
|||
// to be called once on emu exit
|
||||
void PicoExit(void)
|
||||
{
|
||||
if (PicoMCD&1)
|
||||
if (PicoAHW & PAHW_MCD)
|
||||
PicoExitMCD();
|
||||
z80_exit();
|
||||
|
||||
|
@ -71,7 +71,7 @@ void PicoPower(void)
|
|||
Pico.video.reg[0xc] = 0x81;
|
||||
Pico.video.reg[0xf] = 0x02;
|
||||
|
||||
if (PicoMCD & 1)
|
||||
if (PicoAHW & PAHW_MCD)
|
||||
PicoPowerMCD();
|
||||
|
||||
PicoReset();
|
||||
|
@ -92,10 +92,10 @@ int PicoReset(void)
|
|||
PicoMemReset();
|
||||
SekReset();
|
||||
// s68k doesn't have the TAS quirk, so we just globally set normal TAS handler in MCD mode (used by Batman games).
|
||||
SekSetRealTAS(PicoMCD & 1);
|
||||
SekSetRealTAS(PicoAHW & PAHW_MCD);
|
||||
SekCycleCntT=0;
|
||||
|
||||
if (PicoMCD & 1)
|
||||
if (PicoAHW & PAHW_MCD)
|
||||
// needed for MCD to reset properly, probably some bug hides behind this..
|
||||
memset(Pico.ioports,0,sizeof(Pico.ioports));
|
||||
emustatus = 0;
|
||||
|
@ -155,10 +155,10 @@ int PicoReset(void)
|
|||
PsndReset(); // pal must be known here
|
||||
|
||||
// create an empty "dma" to cause 68k exec start at random frame location
|
||||
if (Pico.m.dma_xfers == 0 && !(PicoOpt&0x10000))
|
||||
if (Pico.m.dma_xfers == 0 && !(PicoOpt&POPT_DIS_VDP_FIFO))
|
||||
Pico.m.dma_xfers = rand() & 0x1fff;
|
||||
|
||||
if (PicoMCD & 1) {
|
||||
if (PicoAHW & PAHW_MCD) {
|
||||
PicoResetMCD();
|
||||
return 0;
|
||||
}
|
||||
|
@ -306,7 +306,7 @@ static void PicoRunZ80Simple(int line_from, int line_to)
|
|||
int line_from_r=line_from, line_to_r=line_to, line=0;
|
||||
int line_sample = Pico.m.pal ? 68 : 93;
|
||||
|
||||
if (!(PicoOpt&4) || Pico.m.z80Run == 0) line_to_r = 0;
|
||||
if (!(PicoOpt&POPT_EN_Z80) || Pico.m.z80Run == 0) line_to_r = 0;
|
||||
else {
|
||||
extern const unsigned short vcounts[];
|
||||
if (z80startCycle) {
|
||||
|
@ -317,7 +317,7 @@ static void PicoRunZ80Simple(int line_from, int line_to)
|
|||
z80startCycle = SekCyclesDone();
|
||||
}
|
||||
|
||||
if (PicoOpt&1) {
|
||||
if (PicoOpt&POPT_EN_FM) {
|
||||
// we have ym2612 enabled, so we have to run Z80 in lines, so we could update DAC and timers
|
||||
for (line = line_from; line < line_to; line++) {
|
||||
Psnd_timers_and_dac(line);
|
||||
|
@ -358,7 +358,7 @@ static int PicoFrameSimple(void)
|
|||
}
|
||||
|
||||
// a hack for VR, to get it running in fast mode
|
||||
if (PicoRead16Hook == PicoSVPRead16)
|
||||
if (PicoAHW & PAHW_SVP)
|
||||
Pico.ram[0xd864^1] = 0x1a;
|
||||
|
||||
// we don't emulate DMA timing in this mode
|
||||
|
@ -409,7 +409,7 @@ static int PicoFrameSimple(void)
|
|||
}
|
||||
|
||||
// another hack for VR (it needs hints to work)
|
||||
if (PicoRead16Hook == PicoSVPRead16) {
|
||||
if (PicoAHW & PAHW_SVP) {
|
||||
Pico.ram[0xd864^1] = 1;
|
||||
pv->pending_ints|=0x10;
|
||||
if (pv->reg[0]&0x10) SekInterrupt(4);
|
||||
|
@ -419,7 +419,7 @@ static int PicoFrameSimple(void)
|
|||
// render screen
|
||||
if (!PicoSkipFrame)
|
||||
{
|
||||
if (!(PicoOpt&0x10))
|
||||
if (!(PicoOpt&POPT_ALT_RENDERER))
|
||||
{
|
||||
// Draw the screen
|
||||
#if CAN_HANDLE_240_LINES
|
||||
|
@ -439,7 +439,7 @@ static int PicoFrameSimple(void)
|
|||
}
|
||||
|
||||
// here we render sound if ym2612 is disabled
|
||||
if (!(PicoOpt&1) && PsndOut) {
|
||||
if (!(PicoOpt&POPT_EN_FM) && PsndOut) {
|
||||
int len = PsndRender(0, PsndLen);
|
||||
if (PicoWriteSound) PicoWriteSound(len);
|
||||
// clear sound buffer
|
||||
|
@ -470,10 +470,11 @@ static int PicoFrameSimple(void)
|
|||
}
|
||||
|
||||
if (pv->reg[1]&0x20) SekInterrupt(6); // Set IRQ
|
||||
if (Pico.m.z80Run && (PicoOpt&4))
|
||||
if (Pico.m.z80Run && (PicoOpt&POPT_EN_Z80))
|
||||
z80_int();
|
||||
|
||||
while (sects) {
|
||||
while (sects)
|
||||
{
|
||||
lines += lines_step;
|
||||
|
||||
SekRunM68k(cycles_68k_vblock);
|
||||
|
@ -502,23 +503,23 @@ int PicoFrame(void)
|
|||
|
||||
Pico.m.frame_count++;
|
||||
|
||||
if (PicoMCD & 1) {
|
||||
if (PicoAHW & PAHW_MCD) {
|
||||
PicoFrameMCD();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// be accurate if we are asked for this
|
||||
if(PicoOpt&0x40) acc=1;
|
||||
if (PicoOpt&POPT_ACC_TIMING) acc=1;
|
||||
// don't be accurate in alternative render mode, as hint effects will not be rendered anyway
|
||||
else if(PicoOpt&0x10) acc = 0;
|
||||
else if (PicoOpt&POPT_ALT_RENDERER) acc = 0;
|
||||
else acc=Pico.video.reg[0]&0x10; // be accurate if hints are used
|
||||
|
||||
//if(Pico.video.reg[12]&0x2) Pico.video.status ^= 0x10; // change odd bit in interlace mode
|
||||
|
||||
if(!(PicoOpt&0x10))
|
||||
if (!(PicoOpt&POPT_ALT_RENDERER))
|
||||
PicoFrameStart();
|
||||
|
||||
if(acc)
|
||||
if (acc)
|
||||
PicoFrameHints();
|
||||
else PicoFrameSimple();
|
||||
|
||||
|
|
46
Pico/Pico.h
46
Pico/Pico.h
|
@ -4,7 +4,7 @@
|
|||
// Pico Library - Header File
|
||||
|
||||
// (c) Copyright 2004 Dave, All rights reserved.
|
||||
// (c) Copyright 2006-2007 notaz, All rights reserved.
|
||||
// (c) Copyright 2006-2008 notaz, All rights reserved.
|
||||
// Free for non-commercial use.
|
||||
|
||||
// For commercial use, separate licencing terms must be obtained.
|
||||
|
@ -29,13 +29,25 @@ void mp3_update(int *buffer, int length, int stereo);
|
|||
|
||||
|
||||
// Pico.c
|
||||
// PicoOpt bits LSb->MSb:
|
||||
// 00 000x enable_ym2612&dac, enable_sn76496, enable_z80, stereo_sound,
|
||||
// 00 00x0 alt_renderer, 6button_gamepad, accurate_timing, accurate_sprites,
|
||||
// 00 0x00 draw_no_32col_border, external_ym2612, enable_cd_pcm, enable_cd_cdda
|
||||
// 00 x000 enable_cd_gfx, cd_perfect_sync, soft_32col_scaling, enable_cd_ramcart
|
||||
// 0x 0000 disable_vdp_fifo, no_svp_dynarec, no_sprite_limit
|
||||
extern int PicoOpt;
|
||||
#define POPT_EN_FM (1<< 0) // 00 000x
|
||||
#define POPT_EN_PSG (1<< 1)
|
||||
#define POPT_EN_Z80 (1<< 2)
|
||||
#define POPT_EN_STEREO (1<< 3)
|
||||
#define POPT_ALT_RENDERER (1<< 4) // 00 00x0
|
||||
#define POPT_6BTN_PAD (1<< 5)
|
||||
#define POPT_ACC_TIMING (1<< 6)
|
||||
#define POPT_ACC_SPRITES (1<< 7)
|
||||
#define POPT_DIS_32C_BORDER (1<< 8) // 00 0x00
|
||||
#define POPT_EXT_FM (1<< 9)
|
||||
#define POPT_EN_MCD_PCM (1<<10)
|
||||
#define POPT_EN_MCD_CDDA (1<<11)
|
||||
#define POPT_EN_MCD_GFX (1<<12) // 00 x000
|
||||
#define POPT_EN_MCD_PSYNC (1<<13)
|
||||
#define POPT_EN_SOFTSCALE (1<<14)
|
||||
#define POPT_EN_MCD_RAMCART (1<<15)
|
||||
#define POPT_DIS_VDP_FIFO (1<<16) // 0x 0000
|
||||
#define POPT_EN_SVP_DRC (1<<17)
|
||||
extern int PicoOpt; // bitfield
|
||||
extern int PicoVer;
|
||||
extern int PicoSkipFrame; // skip rendering frame, but still do sound (if enabled) and emulation stuff
|
||||
extern int PicoRegionOverride; // override the region detection 0: auto, 1: Japan NTSC, 2: Japan PAL, 4: US, 8: Europe
|
||||
|
@ -114,14 +126,24 @@ extern void *DrawLineDest;
|
|||
#if OVERRIDE_HIGHCOL
|
||||
extern unsigned char *HighCol;
|
||||
#endif
|
||||
extern int (*PicoScan)(unsigned int num, void *data);
|
||||
// internals
|
||||
extern unsigned short HighPal[0x100];
|
||||
extern int rendstatus;
|
||||
extern int (*PicoScanBegin)(unsigned int num);
|
||||
extern int (*PicoScanEnd)(unsigned int num);
|
||||
// utility
|
||||
#ifdef _ASM_DRAW_C
|
||||
void vidConvCpyRGB565(void *to, void *from, int pixels);
|
||||
#endif
|
||||
// internals
|
||||
#define PDRAW_SPRITES_MOVED (1<<0)
|
||||
#define PDRAW_WND_DIFF_PRIO (1<<1) // not all window tiles use same priority
|
||||
#define PDRAW_ACC_SPRITES (1<<2) // accurate sprites (copied from PicoOpt)
|
||||
#define PDRAW_INTERLACE (1<<3) //
|
||||
#define PDRAW_DIRTY_SPRITES (1<<4)
|
||||
#define PDRAW_SONIC_MODE (1<<5) // mid-frame palette changes for 8bit renderer
|
||||
#define PDRAW_PLANE_HI_PRIO (1<<6) // have layer with all hi prio tiles (mk3)
|
||||
#define PDRAW_SHHI_DONE (1<<7) // layer sh/hi already processed
|
||||
#define PDRAW_EARLY_BLANK (1<<8) // blanking enabled at the start of prev line
|
||||
extern int rendstatus;
|
||||
extern unsigned short HighPal[0x100];
|
||||
|
||||
// Draw2.c
|
||||
// stuff below is optional
|
||||
|
|
|
@ -11,14 +11,14 @@
|
|||
|
||||
// pad delay (for 6 button pads)
|
||||
#define PAD_DELAY \
|
||||
if (PicoOpt&0x20) { \
|
||||
if (PicoOpt&POPT_6BTN_PAD) { \
|
||||
if(Pico.m.padDelay[0]++ > 25) Pico.m.padTHPhase[0]=0; \
|
||||
if(Pico.m.padDelay[1]++ > 25) Pico.m.padTHPhase[1]=0; \
|
||||
}
|
||||
|
||||
#define Z80_RUN(z80_cycles) \
|
||||
{ \
|
||||
if ((PicoOpt&4) && Pico.m.z80Run) \
|
||||
if ((PicoOpt&POPT_EN_Z80) && Pico.m.z80Run) \
|
||||
{ \
|
||||
int cnt; \
|
||||
if (Pico.m.z80Run & 2) z80CycleAim += z80_cycles; \
|
||||
|
@ -42,7 +42,7 @@
|
|||
#else
|
||||
#define CPUS_RUN(m68k_cycles,z80_cycles,s68k_cycles) \
|
||||
{ \
|
||||
if ((PicoOpt & 0x2000) && (Pico_mcd->m.busreq&3) == 1) { \
|
||||
if ((PicoOpt&POPT_EN_MCD_PSYNC) && (Pico_mcd->m.busreq&3) == 1) { \
|
||||
SekRunPS(m68k_cycles, s68k_cycles); /* "better/perfect sync" */ \
|
||||
} else { \
|
||||
SekRunM68k(m68k_cycles); \
|
||||
|
@ -60,7 +60,7 @@ static int PicoFrameHints(void)
|
|||
int lines, y, lines_vis = 224, total_z80 = 0, z80CycleAim = 0, line_sample, skip;
|
||||
int hint; // Hint counter
|
||||
|
||||
if ((PicoOpt&0x10) && !PicoSkipFrame && (pv->reg[1]&0x40)) { // fast rend., display enabled
|
||||
if ((PicoOpt&POPT_ALT_RENDERER) && !PicoSkipFrame && (pv->reg[1]&0x40)) { // fast rend., display enabled
|
||||
// draw a frame just after vblank in alternative render mode
|
||||
// yes, this will cause 1 frame lag, but this is inaccurate mode anyway.
|
||||
PicoFrameFull();
|
||||
|
@ -127,7 +127,7 @@ static int PicoFrameHints(void)
|
|||
// decide if we draw this line
|
||||
if (!skip)
|
||||
{
|
||||
if (PicoOpt&0x10) {
|
||||
if (PicoOpt&POPT_ALT_RENDERER) {
|
||||
// find the right moment for fast renderer, when display is no longer blanked
|
||||
if ((pv->reg[1]&0x40) || y > 100) {
|
||||
PicoFrameFull();
|
||||
|
@ -148,7 +148,7 @@ static int PicoFrameHints(void)
|
|||
}
|
||||
}
|
||||
|
||||
if (PicoOpt&1)
|
||||
if (PicoOpt&POPT_EN_FM)
|
||||
Psnd_timers_and_dac(y);
|
||||
|
||||
#ifndef PICO_CD
|
||||
|
@ -209,10 +209,10 @@ static int PicoFrameHints(void)
|
|||
elprintf(EL_INTS, "vint: @ %06x [%i]", SekPc, SekCycleCnt);
|
||||
SekInterrupt(6);
|
||||
}
|
||||
if (Pico.m.z80Run && (PicoOpt&4))
|
||||
if (Pico.m.z80Run && (PicoOpt&POPT_EN_Z80))
|
||||
z80_int();
|
||||
|
||||
if (PicoOpt&1)
|
||||
if (PicoOpt&POPT_EN_FM)
|
||||
Psnd_timers_and_dac(y);
|
||||
|
||||
// get samples from sound chips
|
||||
|
@ -245,7 +245,7 @@ static int PicoFrameHints(void)
|
|||
check_cd_dma();
|
||||
#endif
|
||||
|
||||
if(PicoOpt&1)
|
||||
if (PicoOpt&POPT_EN_FM)
|
||||
Psnd_timers_and_dac(y);
|
||||
|
||||
// Run scanline:
|
||||
|
|
|
@ -38,12 +38,12 @@ extern "C" {
|
|||
extern struct Cyclone PicoCpuCM68k, PicoCpuCS68k;
|
||||
#define SekCyclesLeftNoMCD PicoCpuCM68k.cycles // cycles left for this run
|
||||
#define SekCyclesLeft \
|
||||
(((PicoMCD&1) && (PicoOpt & 0x2000)) ? (SekCycleAim-SekCycleCnt) : SekCyclesLeftNoMCD)
|
||||
(((PicoAHW&1) && (PicoOpt & POPT_EN_MCD_PSYNC)) ? (SekCycleAim-SekCycleCnt) : SekCyclesLeftNoMCD)
|
||||
#define SekCyclesLeftS68k \
|
||||
((PicoOpt & 0x2000) ? (SekCycleAimS68k-SekCycleCntS68k) : PicoCpuCS68k.cycles)
|
||||
((PicoOpt & POPT_EN_MCD_PSYNC) ? (SekCycleAimS68k-SekCycleCntS68k) : PicoCpuCS68k.cycles)
|
||||
#define SekSetCyclesLeftNoMCD(c) PicoCpuCM68k.cycles=c
|
||||
#define SekSetCyclesLeft(c) { \
|
||||
if ((PicoMCD&1) && (PicoOpt & 0x2000)) SekCycleCnt=SekCycleAim-(c); else SekSetCyclesLeftNoMCD(c); \
|
||||
if ((PicoAHW&1) && (PicoOpt & POPT_EN_MCD_PSYNC)) SekCycleCnt=SekCycleAim-(c); else SekSetCyclesLeftNoMCD(c); \
|
||||
}
|
||||
#define SekPc (PicoCpuCM68k.pc-PicoCpuCM68k.membase)
|
||||
#define SekPcS68k (PicoCpuCS68k.pc-PicoCpuCS68k.membase)
|
||||
|
@ -64,12 +64,12 @@ extern struct Cyclone PicoCpuCM68k, PicoCpuCS68k;
|
|||
extern M68K_CONTEXT PicoCpuFM68k, PicoCpuFS68k;
|
||||
#define SekCyclesLeftNoMCD PicoCpuFM68k.io_cycle_counter
|
||||
#define SekCyclesLeft \
|
||||
(((PicoMCD&1) && (PicoOpt & 0x2000)) ? (SekCycleAim-SekCycleCnt) : SekCyclesLeftNoMCD)
|
||||
(((PicoAHW&1) && (PicoOpt & POPT_EN_MCD_PSYNC)) ? (SekCycleAim-SekCycleCnt) : SekCyclesLeftNoMCD)
|
||||
#define SekCyclesLeftS68k \
|
||||
((PicoOpt & 0x2000) ? (SekCycleAimS68k-SekCycleCntS68k) : PicoCpuFS68k.io_cycle_counter)
|
||||
((PicoOpt & POPT_EN_MCD_PSYNC) ? (SekCycleAimS68k-SekCycleCntS68k) : PicoCpuFS68k.io_cycle_counter)
|
||||
#define SekSetCyclesLeftNoMCD(c) PicoCpuFM68k.io_cycle_counter=c
|
||||
#define SekSetCyclesLeft(c) { \
|
||||
if ((PicoMCD&1) && (PicoOpt & 0x2000)) SekCycleCnt=SekCycleAim-(c); else SekSetCyclesLeftNoMCD(c); \
|
||||
if ((PicoAHW&1) && (PicoOpt & POPT_EN_MCD_PSYNC)) SekCycleCnt=SekCycleAim-(c); else SekSetCyclesLeftNoMCD(c); \
|
||||
}
|
||||
#define SekPc fm68k_get_pc(&PicoCpuFM68k)
|
||||
#define SekPcS68k fm68k_get_pc(&PicoCpuFS68k)
|
||||
|
@ -97,12 +97,12 @@ extern m68ki_cpu_core PicoCpuMM68k, PicoCpuMS68k;
|
|||
#ifndef SekCyclesLeft
|
||||
#define SekCyclesLeftNoMCD PicoCpuMM68k.cyc_remaining_cycles
|
||||
#define SekCyclesLeft \
|
||||
(((PicoMCD&1) && (PicoOpt & 0x2000)) ? (SekCycleAim-SekCycleCnt) : SekCyclesLeftNoMCD)
|
||||
(((PicoAHW&1) && (PicoOpt & POPT_EN_MCD_PSYNC)) ? (SekCycleAim-SekCycleCnt) : SekCyclesLeftNoMCD)
|
||||
#define SekCyclesLeftS68k \
|
||||
((PicoOpt & 0x2000) ? (SekCycleAimS68k-SekCycleCntS68k) : PicoCpuMS68k.cyc_remaining_cycles)
|
||||
((PicoOpt & POPT_EN_MCD_PSYNC) ? (SekCycleAimS68k-SekCycleCntS68k) : PicoCpuMS68k.cyc_remaining_cycles)
|
||||
#define SekSetCyclesLeftNoMCD(c) SET_CYCLES(c)
|
||||
#define SekSetCyclesLeft(c) { \
|
||||
if ((PicoMCD&1) && (PicoOpt & 0x2000)) SekCycleCnt=SekCycleAim-(c); else SET_CYCLES(c); \
|
||||
if ((PicoAHW&1) && (PicoOpt & POPT_EN_MCD_PSYNC)) SekCycleCnt=SekCycleAim-(c); else SET_CYCLES(c); \
|
||||
}
|
||||
#define SekPc m68k_get_reg(&PicoCpuMM68k, M68K_REG_PC)
|
||||
#define SekPcS68k m68k_get_reg(&PicoCpuMS68k, M68K_REG_PC)
|
||||
|
@ -208,7 +208,11 @@ extern struct DrZ80 drZ80;
|
|||
|
||||
// ---------------------------------------------------------
|
||||
|
||||
extern int PicoMCD;
|
||||
// Pico active hw
|
||||
#define PAHW_MCD (1<<0)
|
||||
#define PAHW_32X (1<<1)
|
||||
#define PAHW_SVP (1<<2)
|
||||
extern int PicoAHW;
|
||||
|
||||
// main oscillator clock which controls timing
|
||||
#define OSC_NTSC 53693100
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
extern const unsigned char hcounts_32[];
|
||||
extern const unsigned char hcounts_40[];
|
||||
extern const unsigned short vcounts[];
|
||||
extern int rendstatus;
|
||||
|
||||
#ifndef UTYPES_DEFINED
|
||||
typedef unsigned char u8;
|
||||
|
@ -37,7 +36,7 @@ static void VideoWrite(u16 d)
|
|||
{
|
||||
case 1: if(a&1) d=(u16)((d<<8)|(d>>8)); // If address is odd, bytes are swapped (which game needs this?)
|
||||
Pico.vram [(a>>1)&0x7fff]=d;
|
||||
rendstatus|=0x10; break;
|
||||
rendstatus |= PDRAW_DIRTY_SPRITES; break;
|
||||
case 3: Pico.m.dirtyPal = 1;
|
||||
Pico.cram [(a>>1)&0x003f]=d; break; // wraps (Desert Strike)
|
||||
case 5: Pico.vsram[(a>>1)&0x003f]=d; break;
|
||||
|
@ -93,9 +92,9 @@ static void DmaSlow(int len)
|
|||
Pico.video.type, source, a, len, inc, (Pico.video.status&8)||!(Pico.video.reg[1]&0x40),
|
||||
SekCyclesDone(), SekPc);
|
||||
|
||||
if(Pico.m.scanline != -1) {
|
||||
if (Pico.m.scanline != -1) {
|
||||
Pico.m.dma_xfers += len;
|
||||
if ((PicoMCD&1) && (PicoOpt & 0x2000)) SekCyclesBurn(CheckDMA());
|
||||
if ((PicoAHW & PAHW_MCD) && (PicoOpt & POPT_EN_MCD_PSYNC)) SekCyclesBurn(CheckDMA());
|
||||
else SekSetCyclesLeftNoMCD(SekCyclesLeftNoMCD - CheckDMA());
|
||||
} else {
|
||||
// be approximate in non-accurate mode
|
||||
|
@ -105,7 +104,9 @@ static void DmaSlow(int len)
|
|||
if ((source&0xe00000)==0xe00000) { // Ram
|
||||
pd=(u16 *)(Pico.ram+(source&0xfffe));
|
||||
pdend=(u16 *)(Pico.ram+0x10000);
|
||||
} else if (PicoMCD & 1) {
|
||||
}
|
||||
else if (PicoAHW & PAHW_MCD)
|
||||
{
|
||||
elprintf(EL_VDPDMA, "DmaSlow CD, r3=%02x", Pico_mcd->s68k_regs[3]);
|
||||
if(source<0x20000) { // Bios area
|
||||
pd=(u16 *)(Pico_mcd->bios+(source&~1));
|
||||
|
@ -133,7 +134,9 @@ static void DmaSlow(int len)
|
|||
elprintf(EL_VDPDMA|EL_ANOMALY, "DmaSlow[%i] %06x->%04x: FIXME: unsupported src", Pico.video.type, source, a);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// if we have DmaHook, let it handle ROM because of possible DMA delay
|
||||
if (PicoDmaHook && PicoDmaHook(source, len, &pd, &pdend));
|
||||
else if (source<Pico.romsize) { // Rom
|
||||
|
@ -175,7 +178,7 @@ static void DmaSlow(int len)
|
|||
//if(pd >= pdend) pd-=0x8000; // should be good for RAM, bad for ROM
|
||||
}
|
||||
}
|
||||
rendstatus|=0x10;
|
||||
rendstatus |= PDRAW_DIRTY_SPRITES;
|
||||
break;
|
||||
|
||||
case 3: // cram
|
||||
|
@ -244,7 +247,7 @@ static void DmaCopy(int len)
|
|||
}
|
||||
// remember addr
|
||||
Pico.video.addr=a;
|
||||
rendstatus|=0x10;
|
||||
rendstatus |= PDRAW_DIRTY_SPRITES;
|
||||
}
|
||||
|
||||
// check: Contra, Megaman
|
||||
|
@ -284,7 +287,7 @@ static void DmaFill(int data)
|
|||
// update length
|
||||
Pico.video.reg[0x13] = Pico.video.reg[0x14] = 0; // Dino Dini's Soccer (E) (by Haze)
|
||||
|
||||
rendstatus|=0x10;
|
||||
rendstatus |= PDRAW_DIRTY_SPRITES;
|
||||
}
|
||||
|
||||
static void CommandDma(void)
|
||||
|
@ -341,7 +344,7 @@ PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d)
|
|||
else
|
||||
{
|
||||
// preliminary FIFO emulation for Chaos Engine, The (E)
|
||||
if(!(pvid->status&8) && (pvid->reg[1]&0x40) && Pico.m.scanline!=-1 && !(PicoOpt&0x10000)) // active display, accurate mode?
|
||||
if(!(pvid->status&8) && (pvid->reg[1]&0x40) && Pico.m.scanline!=-1 && !(PicoOpt&POPT_DIS_VDP_FIFO)) // active display, accurate mode?
|
||||
{
|
||||
pvid->status&=~0x200; // FIFO no longer empty
|
||||
pvid->lwrite_cnt++;
|
||||
|
@ -366,45 +369,63 @@ PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d)
|
|||
pvid->command|=d;
|
||||
pvid->pending=0;
|
||||
CommandChange();
|
||||
} else {
|
||||
if((d&0xc000)==0x8000)
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((d&0xc000)==0x8000)
|
||||
{
|
||||
// Register write:
|
||||
int num=(d>>8)&0x1f;
|
||||
int dold=pvid->reg[num];
|
||||
pvid->type=0; // register writes clear command (else no Sega logo in Golden Axe II)
|
||||
if (num > 0x0a && !(pvid->reg[1]&4)) {
|
||||
elprintf(EL_ANOMALY, "%02x written to reg %02x in SMS mode @ %06x", d, num, SekPc);
|
||||
return;
|
||||
} else
|
||||
pvid->reg[num]=(unsigned char)d;
|
||||
if (num==00) elprintf(EL_INTSW, "hint_onoff: %i->%i [%i] pend=%i @ %06x", (dold&0x10)>>4,
|
||||
(d&0x10)>>4, SekCyclesDone(), (pvid->pending_ints&0x10)>>4, SekPc);
|
||||
if (num==01) elprintf(EL_INTSW, "vint_onoff: %i->%i [%i] pend=%i @ %06x", (dold&0x20)>>5,
|
||||
(d&0x20)>>5, SekCyclesDone(), (pvid->pending_ints&0x20)>>5, SekPc);
|
||||
if (num == 5 && (d^dold)) rendstatus|=1;
|
||||
// renderers should update their palettes if sh/hi mode is changed
|
||||
else if (num == 0xc && ((d^dold)&8)) Pico.m.dirtyPal = 2;
|
||||
pvid->reg[num]=(unsigned char)d;
|
||||
|
||||
switch (num)
|
||||
{
|
||||
case 0x00:
|
||||
elprintf(EL_INTSW, "hint_onoff: %i->%i [%i] pend=%i @ %06x", (dold&0x10)>>4,
|
||||
(d&0x10)>>4, SekCyclesDone(), (pvid->pending_ints&0x10)>>4, SekPc);
|
||||
goto update_irq;
|
||||
case 0x01:
|
||||
elprintf(EL_INTSW, "vint_onoff: %i->%i [%i] pend=%i @ %06x", (dold&0x20)>>5,
|
||||
(d&0x20)>>5, SekCyclesDone(), (pvid->pending_ints&0x20)>>5, SekPc);
|
||||
if (!(d&0x40) && SekCyclesLeft > 420) { /*elprintf(EL_ANOMALY, "aa %i", SekCyclesLeft);*/ rendstatus |= PDRAW_EARLY_BLANK; }
|
||||
goto update_irq;
|
||||
case 0x05:
|
||||
if (d^dold) rendstatus |= PDRAW_SPRITES_MOVED;
|
||||
break;
|
||||
case 0x0c:
|
||||
// renderers should update their palettes if sh/hi mode is changed
|
||||
if ((d^dold)&8) Pico.m.dirtyPal = 2;
|
||||
break;
|
||||
}
|
||||
return;
|
||||
|
||||
update_irq:
|
||||
#ifndef EMU_CORE_DEBUG
|
||||
// update IRQ level (Lemmings, Wiz 'n' Liz intro, ... )
|
||||
// may break if done improperly:
|
||||
// International Superstar Soccer Deluxe (crash), Street Racer (logos), Burning Force (gfx),
|
||||
// Fatal Rewind (crash), Sesame Street Counting Cafe
|
||||
else if (num < 2)
|
||||
if (!SekShouldInterrupt) // hack
|
||||
{
|
||||
if (!SekShouldInterrupt) // hack
|
||||
{
|
||||
int lines, pints, irq=0;
|
||||
lines = (pvid->reg[1] & 0x20) | (pvid->reg[0] & 0x10);
|
||||
pints = (pvid->pending_ints&lines);
|
||||
if(pints & 0x20) irq = 6;
|
||||
else if(pints & 0x10) irq = 4;
|
||||
SekInterrupt(irq); // update line
|
||||
int lines, pints, irq=0;
|
||||
lines = (pvid->reg[1] & 0x20) | (pvid->reg[0] & 0x10);
|
||||
pints = (pvid->pending_ints&lines);
|
||||
if(pints & 0x20) irq = 6;
|
||||
else if(pints & 0x10) irq = 4;
|
||||
SekInterrupt(irq); // update line
|
||||
|
||||
if (irq && Pico.m.scanline!=-1) SekEndRun(24); // make it delayed
|
||||
}
|
||||
if (irq && Pico.m.scanline!=-1) SekEndRun(24); // make it delayed
|
||||
}
|
||||
#endif
|
||||
pvid->type=0; // register writes clear command (else no Sega logo in Golden Axe II)
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// High word of command:
|
||||
pvid->command&=0x0000ffff;
|
||||
pvid->command|=d<<16;
|
||||
|
@ -431,9 +452,9 @@ PICO_INTERNAL_ASM unsigned int PicoVideoRead(unsigned int a)
|
|||
{
|
||||
struct PicoVideo *pv=&Pico.video;
|
||||
d=pv->status;
|
||||
if (PicoOpt&0x10) d|=0x0020; // sprite collision (Shadow of the Beast)
|
||||
if (!(pv->reg[1]&0x40)) d|=0x0008; // set V-Blank if display is disabled
|
||||
if (SekCyclesLeft < 84+4) d|=0x0004; // H-Blank (Sonic3 vs)
|
||||
if (PicoOpt&POPT_ALT_RENDERER) d|=0x0020; // sprite collision (Shadow of the Beast)
|
||||
if (!(pv->reg[1]&0x40)) d|=0x0008; // set V-Blank if display is disabled
|
||||
if (SekCyclesLeft < 84+4) d|=0x0004; // H-Blank (Sonic3 vs)
|
||||
|
||||
d|=(pv->pending_ints&0x20)<<2; // V-int pending?
|
||||
if (d&0x100) pv->status&=~0x100; // FIFO no longer full
|
||||
|
|
|
@ -38,14 +38,14 @@ static void PicoSVPReset(void)
|
|||
|
||||
memcpy(svp->iram_rom + 0x800, Pico.rom + 0x800, 0x20000 - 0x800);
|
||||
ssp1601_reset(&svp->ssp1601);
|
||||
if ((PicoOpt&0x20000) && svp_dyn_ready)
|
||||
if ((PicoOpt&POPT_EN_SVP_DRC) && svp_dyn_ready)
|
||||
ssp1601_dyn_reset(&svp->ssp1601);
|
||||
}
|
||||
|
||||
|
||||
static void PicoSVPLine(int count)
|
||||
{
|
||||
if ((PicoOpt&0x20000) && svp_dyn_ready)
|
||||
if ((PicoOpt&POPT_EN_SVP_DRC) && svp_dyn_ready)
|
||||
ssp1601_dyn_run(PicoSVPCycles * count);
|
||||
else {
|
||||
ssp1601_run(PicoSVPCycles * count);
|
||||
|
@ -126,7 +126,7 @@ void PicoSVPStartup(void)
|
|||
|
||||
// init SVP compiler
|
||||
svp_dyn_ready = 0;
|
||||
if (PicoOpt&0x20000) {
|
||||
if (PicoOpt&POPT_EN_SVP_DRC) {
|
||||
if (ssp1601_dyn_startup()) return;
|
||||
svp_dyn_ready = 1;
|
||||
}
|
||||
|
@ -145,6 +145,7 @@ void PicoSVPStartup(void)
|
|||
svp_states[1].ptr = svp->dram;
|
||||
svp_states[2].ptr = &svp->ssp1601;
|
||||
carthw_chunks = svp_states;
|
||||
PicoAHW |= PAHW_SVP;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ PICO_INTERNAL int PicoCdSaveState(void *file)
|
|||
unsigned char buff[0x60];
|
||||
void *ym2612_regs = YM2612GetRegs();
|
||||
|
||||
areaWrite("PicoSMCD", 1, 8, file);
|
||||
areaWrite("PicoSEXT", 1, 8, file);
|
||||
areaWrite(&PicoVer, 1, 4, file);
|
||||
|
||||
memset(buff, 0, sizeof(buff));
|
||||
|
@ -124,7 +124,7 @@ PICO_INTERNAL int PicoCdSaveState(void *file)
|
|||
if (PicoOpt&1)
|
||||
CHECKED_WRITE(CHUNK_FM, 0x200+4, ym2612_regs);
|
||||
|
||||
if (PicoMCD & 1)
|
||||
if (PicoAHW & PAHW_MCD)
|
||||
{
|
||||
Pico_mcd->m.audio_offset = mp3_get_offset();
|
||||
memset(buff, 0, sizeof(buff));
|
||||
|
@ -197,7 +197,8 @@ PICO_INTERNAL int PicoCdLoadState(void *file)
|
|||
|
||||
g_read_offs = 0;
|
||||
CHECKED_READ(8, buff);
|
||||
if (strncmp((char *)buff, "PicoSMCD", 8)) R_ERROR_RETURN("bad header");
|
||||
if (strncmp((char *)buff, "PicoSMCD", 8) && strncmp((char *)buff, "PicoSEXT", 8))
|
||||
R_ERROR_RETURN("bad header");
|
||||
CHECKED_READ(4, &ver);
|
||||
|
||||
while (!areaEof(file))
|
||||
|
@ -205,7 +206,7 @@ PICO_INTERNAL int PicoCdLoadState(void *file)
|
|||
CHECKED_READ(1, buff);
|
||||
CHECKED_READ(4, &len);
|
||||
if (len < 0 || len > 1024*512) R_ERROR_RETURN("bad length");
|
||||
if (buff[0] > CHUNK_FM && buff[0] <= CHUNK_MISC_CD && !(PicoMCD & 1))
|
||||
if (buff[0] > CHUNK_FM && buff[0] <= CHUNK_MISC_CD && !(PicoAHW & PAHW_MCD))
|
||||
R_ERROR_RETURN("cd chunk in non CD state?");
|
||||
|
||||
switch (buff[0])
|
||||
|
@ -269,7 +270,7 @@ PICO_INTERNAL int PicoCdLoadState(void *file)
|
|||
breakswitch:;
|
||||
}
|
||||
|
||||
if (PicoMCD & 1)
|
||||
if (PicoAHW & PAHW_MCD)
|
||||
{
|
||||
/* after load events */
|
||||
if (Pico_mcd->s68k_regs[3]&4) // 1M mode?
|
||||
|
@ -296,7 +297,8 @@ int PicoCdLoadStateGfx(void *file)
|
|||
|
||||
g_read_offs = 0;
|
||||
CHECKED_READ(8, buff);
|
||||
if (strncmp(buff, "PicoSMCD", 8)) R_ERROR_RETURN("bad header");
|
||||
if (strncmp((char *)buff, "PicoSMCD", 8) && strncmp((char *)buff, "PicoSEXT", 8))
|
||||
R_ERROR_RETURN("bad header");
|
||||
CHECKED_READ(4, &ver);
|
||||
|
||||
while (!areaEof(file) && found < 4)
|
||||
|
@ -304,7 +306,7 @@ int PicoCdLoadStateGfx(void *file)
|
|||
CHECKED_READ(1, buff);
|
||||
CHECKED_READ(4, &len);
|
||||
if (len < 0 || len > 1024*512) R_ERROR_RETURN("bad length");
|
||||
if (buff[0] > CHUNK_FM && buff[0] <= CHUNK_MISC_CD && !(PicoMCD & 1))
|
||||
if (buff[0] > CHUNK_FM && buff[0] <= CHUNK_MISC_CD && !(PicoAHW & PAHW_MCD))
|
||||
R_ERROR_RETURN("cd chunk in non CD state?");
|
||||
|
||||
switch (buff[0])
|
||||
|
|
|
@ -77,7 +77,7 @@ PICO_INTERNAL int PicoResetMCD(void)
|
|||
#endif
|
||||
|
||||
// use SRam.data for RAM cart
|
||||
if (PicoOpt&0x8000) {
|
||||
if (PicoOpt&POPT_EN_MCD_RAMCART) {
|
||||
if (SRam.data == NULL)
|
||||
SRam.data = calloc(1, 0x12000);
|
||||
}
|
||||
|
@ -266,7 +266,7 @@ static __inline void getSamples(int y)
|
|||
|
||||
PICO_INTERNAL int PicoFrameMCD(void)
|
||||
{
|
||||
if(!(PicoOpt&0x10))
|
||||
if (!(PicoOpt&POPT_ALT_RENDERER))
|
||||
PicoFrameStart();
|
||||
|
||||
PicoFrameHints();
|
||||
|
|
|
@ -312,7 +312,7 @@ PICO_INTERNAL void gfx_cd_update(void)
|
|||
_rot_comp.Float_Part &= 0xffff;
|
||||
_rot_comp.Float_Part += _rot_comp.Draw_Speed;
|
||||
|
||||
if (PicoOpt & 0x1000) // scale/rot enabled
|
||||
if (PicoOpt & POPT_EN_MCD_GFX)
|
||||
{
|
||||
unsigned int func = _rot_comp.Function;
|
||||
unsigned int H_Dot = _rot_comp.Reg_62 & 0x1ff;
|
||||
|
@ -447,7 +447,7 @@ PICO_INTERNAL void DmaSlowCell(unsigned int source, unsigned int a, int len, uns
|
|||
// AutoIncrement
|
||||
a=(u16)(a+inc);
|
||||
}
|
||||
rendstatus|=0x10;
|
||||
rendstatus |= PDRAW_SPRITES_MOVED;
|
||||
break;
|
||||
|
||||
case 3: // cram
|
||||
|
|
|
@ -110,16 +110,16 @@ void PsndRerate(int preserve_state)
|
|||
int target_fps = Pico.m.pal ? 50 : 60;
|
||||
|
||||
// not all rates are supported in MCD mode due to mp3 decoder limitations
|
||||
if (PicoMCD & 1) {
|
||||
if (PicoAHW & PAHW_MCD) {
|
||||
if (PsndRate != 11025 && PsndRate != 22050 && PsndRate != 44100) PsndRate = 22050;
|
||||
PicoOpt |= 8; // force stereo
|
||||
PicoOpt |= POPT_EN_STEREO; // force stereo
|
||||
}
|
||||
|
||||
if (preserve_state) {
|
||||
state = malloc(0x200);
|
||||
if (state == NULL) return;
|
||||
memcpy(state, YM2612GetRegs(), 0x200);
|
||||
if ((PicoMCD & 1) && Pico_mcd->m.audio_track)
|
||||
if ((PicoAHW & PAHW_MCD) && Pico_mcd->m.audio_track)
|
||||
Pico_mcd->m.audio_offset = mp3_get_offset();
|
||||
}
|
||||
YM2612Init(Pico.m.pal ? OSC_PAL/7 : OSC_NTSC/7, PsndRate);
|
||||
|
@ -127,7 +127,7 @@ void PsndRerate(int preserve_state)
|
|||
// feed it back it's own registers, just like after loading state
|
||||
memcpy(YM2612GetRegs(), state, 0x200);
|
||||
YM2612PicoStateLoad();
|
||||
if ((PicoMCD & 1) && Pico_mcd->m.audio_track)
|
||||
if ((PicoAHW & PAHW_MCD) && Pico_mcd->m.audio_track)
|
||||
mp3_start_play(Pico_mcd->TOC.Tracks[Pico_mcd->m.audio_track].F, Pico_mcd->m.audio_offset);
|
||||
}
|
||||
|
||||
|
@ -146,7 +146,7 @@ void PsndRerate(int preserve_state)
|
|||
// recalculate dac info
|
||||
dac_recalculate();
|
||||
|
||||
if (PicoMCD & 1)
|
||||
if (PicoAHW & PAHW_MCD)
|
||||
pcm_set_rate(PsndRate);
|
||||
|
||||
// clear all buffers
|
||||
|
@ -155,7 +155,7 @@ void PsndRerate(int preserve_state)
|
|||
PsndClear();
|
||||
|
||||
// set mixer
|
||||
PsndMix_32_to_16l = (PicoOpt & 8) ? mix_32_to_16l_stereo : mix_32_to_16_mono;
|
||||
PsndMix_32_to_16l = (PicoOpt & POPT_EN_STEREO) ? mix_32_to_16l_stereo : mix_32_to_16_mono;
|
||||
}
|
||||
|
||||
|
||||
|
@ -163,8 +163,8 @@ void PsndRerate(int preserve_state)
|
|||
PICO_INTERNAL void Psnd_timers_and_dac(int raster)
|
||||
{
|
||||
int pos, len;
|
||||
int do_dac = PsndOut && (PicoOpt&1) && *ym2612_dacen;
|
||||
// int do_pcm = PsndOut && (PicoMCD&1) && (PicoOpt&0x400);
|
||||
int do_dac = PsndOut && (PicoOpt&POPT_EN_FM) && *ym2612_dacen;
|
||||
// int do_pcm = PsndOut && (PicoAHW&1) && (PicoOpt&0x400);
|
||||
|
||||
// Our raster lasts 63.61323/64.102564 microseconds (NTSC/PAL)
|
||||
YM2612PicoTick(1);
|
||||
|
@ -176,10 +176,11 @@ PICO_INTERNAL void Psnd_timers_and_dac(int raster)
|
|||
|
||||
pos>>=4;
|
||||
|
||||
if (do_dac) {
|
||||
if (do_dac)
|
||||
{
|
||||
short *d = PsndOut + pos*2;
|
||||
int dout = *ym2612_dacout;
|
||||
if(PicoOpt&8) {
|
||||
if(PicoOpt&POPT_EN_STEREO) {
|
||||
// some manual loop unrolling here :)
|
||||
d[0] = dout;
|
||||
if (len > 1) {
|
||||
|
@ -212,7 +213,7 @@ PICO_INTERNAL void PsndClear(void)
|
|||
{
|
||||
int len = PsndLen;
|
||||
if (PsndLen_exc_add) len++;
|
||||
if (PicoOpt & 8)
|
||||
if (PicoOpt & POPT_EN_STEREO)
|
||||
memset32((int *) PsndOut, 0, len); // assume PsndOut to be aligned
|
||||
else {
|
||||
short *out = PsndOut;
|
||||
|
@ -229,7 +230,8 @@ PICO_INTERNAL int PsndRender(int offset, int length)
|
|||
int *buf32 = PsndBuffer+offset;
|
||||
int stereo = (PicoOpt & 8) >> 3;
|
||||
// emulating CD && PCM option enabled && PCM chip on && have enabled channels
|
||||
int do_pcm = (PicoMCD&1) && (PicoOpt&0x400) && (Pico_mcd->pcm.control & 0x80) && Pico_mcd->pcm.enabled;
|
||||
int do_pcm = (PicoAHW & PAHW_MCD) && (PicoOpt&POPT_EN_MCD_PCM) &&
|
||||
(Pico_mcd->pcm.control & 0x80) && Pico_mcd->pcm.enabled;
|
||||
offset <<= stereo;
|
||||
|
||||
#if !SIMPLE_WRITE_SOUND
|
||||
|
@ -244,11 +246,11 @@ PICO_INTERNAL int PsndRender(int offset, int length)
|
|||
#endif
|
||||
|
||||
// PSG
|
||||
if (PicoOpt & 2)
|
||||
if (PicoOpt & POPT_EN_PSG)
|
||||
SN76496Update(PsndOut+offset, length, stereo);
|
||||
|
||||
// Add in the stereo FM buffer
|
||||
if (PicoOpt & 1) {
|
||||
if (PicoOpt & POPT_EN_FM) {
|
||||
buf32_updated = YM2612UpdateOne(buf32, length, stereo, 1);
|
||||
} else
|
||||
memset32(buf32, 0, length<<stereo);
|
||||
|
@ -263,7 +265,8 @@ PICO_INTERNAL int PsndRender(int offset, int length)
|
|||
|
||||
// CD: CDDA audio
|
||||
// CD mode, cdda enabled, not data track, CDC is reading
|
||||
if ((PicoMCD & 1) && (PicoOpt & 0x800) && !(Pico_mcd->s68k_regs[0x36] & 1) && (Pico_mcd->scd.Status_CDC & 1))
|
||||
if ((PicoAHW & PAHW_MCD) && (PicoOpt & POPT_EN_MCD_CDDA) &&
|
||||
!(Pico_mcd->s68k_regs[0x36] & 1) && (Pico_mcd->scd.Status_CDC & 1))
|
||||
mp3_update(buf32, length, stereo);
|
||||
|
||||
// convert + limit to normal 16bit output
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue