int minimum=0;\r
unsigned char head[32];\r
\r
- if ((PicoMCD & 1) || carthw_chunks != NULL)\r
+ if ((PicoAHW & PAHW_MCD) || carthw_chunks != NULL)\r
{\r
if (PmovAction&1) return PicoCdSaveState(PmovFile);\r
if (PmovAction&2) {\r
int alloc_size;\r
unsigned char *rom;\r
\r
- if (PicoMCD & 1) return cd_realloc(NULL, filesize);\r
+ if (PicoAHW & PAHW_MCD) return cd_realloc(NULL, filesize);\r
\r
alloc_size=filesize+0x7ffff;\r
if((filesize&0x3fff)==0x200) alloc_size-=0x200;\r
}\r
\r
// maybe we are loading MegaCD BIOS?\r
- if (!(PicoMCD&1) && size == 0x20000 && (!strncmp((char *)rom+0x124, "BOOT", 4) || !strncmp((char *)rom+0x128, "BOOT", 4))) {\r
- PicoMCD |= 1;\r
+ if (!(PicoAHW & PAHW_MCD) && size == 0x20000 && (!strncmp((char *)rom+0x124, "BOOT", 4) ||\r
+ !strncmp((char *)rom+0x128, "BOOT", 4))) {\r
+ PicoAHW |= PAHW_MCD;\r
rom = cd_realloc(rom, size);\r
}\r
\r
PicoCartUnloadHook = NULL;\r
}\r
\r
+ PicoAHW &= ~PAHW_SVP;\r
+\r
PicoMemResetHooks();\r
PicoDmaHook = NULL;\r
PicoResetHook = NULL;\r
\r
PicoMemReset();\r
\r
- if (!(PicoMCD & 1))\r
+ if (!(PicoAHW & PAHW_MCD))\r
PicoCartDetect();\r
\r
// setup correct memory map for loaded ROM\r
// call PicoMemReset again due to possible memmap change\r
- if (PicoMCD & 1)\r
+ if (PicoAHW & PAHW_MCD)\r
PicoMemSetupCD();\r
else PicoMemSetup();\r
PicoMemReset();\r
\r
#include "PicoInt.h"\r
\r
-int (*PicoScan)(unsigned int num, void *data)=NULL;\r
+int (*PicoScanBegin)(unsigned int num) = NULL;\r
+int (*PicoScanEnd) (unsigned int num) = NULL;\r
\r
#if OVERRIDE_HIGHCOL\r
static unsigned char DefHighCol[8+320+8];\r
static int HighPreSpr[80*2+1]; // slightly preprocessed sprites\r
char HighSprZ[320+8+8]; // Z-buffer for accurate sprites and shadow/hilight mode\r
// (if bit 7 == 0, sh caused by tile; if bit 6 == 0 pixel must be shadowed, else hilighted, if bit5 == 1)\r
-// lsb->msb: moved sprites, not all window tiles use same priority, accurate sprites (copied from PicoOpt), interlace\r
-// dirty sprites, sonic mode, have layer with all hi prio tiles (mk3), layer sh/hi already processed\r
-int rendstatus;\r
-int Scanline=0; // Scanline\r
+int rendstatus = 0;\r
+int Scanline = 0; // Scanline\r
\r
static int SpriteBlocks;\r
+static int skip_next_line=0;\r
+\r
//unsigned short ppt[] = { 0x0f11, 0x0ff1, 0x01f1, 0x011f, 0x01ff, 0x0f1f, 0x0f0e, 0x0e7c };\r
\r
struct TileStrip\r
// terminate the cache list\r
*ts->hc = 0;\r
// if oldcode wasn't changed, it means all layer is hi priority\r
- if (oldcode == -1) rendstatus|=0x40;\r
+ if (oldcode == -1) rendstatus |= PDRAW_PLANE_HI_PRIO;\r
}\r
\r
// this is messy\r
\r
// terminate the cache list\r
*ts->hc = 0;\r
- if (oldcode == -1) rendstatus|=0x40;\r
+ if (oldcode == -1) rendstatus |= PDRAW_PLANE_HI_PRIO;\r
}\r
#endif\r
\r
\r
ty=(Scanline&7)<<1; // Y-Offset into tile\r
\r
- if(!(rendstatus&2)) {\r
+ if (!(rendstatus & PDRAW_WND_DIFF_PRIO)) {\r
// check the first tile code\r
code=Pico.vram[nametab+tilex];\r
// if the whole window uses same priority (what is often the case), we may be able to skip this field\r
- if((code>>15) != prio) return;\r
+ if ((code>>15) != prio) return;\r
}\r
\r
// Draw tiles across screen:\r
int pal;\r
\r
code=Pico.vram[nametab+tilex];\r
- if(code==blank) continue;\r
- if((code>>15) != prio) {\r
- rendstatus|=2;\r
+ if (code==blank) continue;\r
+ if ((code>>15) != prio) {\r
+ rendstatus |= PDRAW_WND_DIFF_PRIO;\r
continue;\r
}\r
\r
code=Pico.vram[nametab+tilex];\r
if(code==blank) continue;\r
if((code>>15) != prio) {\r
- rendstatus|=2;\r
+ rendstatus |= PDRAW_WND_DIFF_PRIO;\r
continue;\r
}\r
\r
\r
static void DrawTilesFromCacheShPrep(void)\r
{\r
- if (!(rendstatus&0x80))\r
+ // as some layer has covered whole line with hi priority tiles,\r
+ // we can process whole line and then act as if sh/hi mode was off.\r
+ int c = 320/4, *zb = (int *)(HighCol+8);\r
+ rendstatus |= PDRAW_SHHI_DONE;\r
+ while (c--)\r
{\r
- // as some layer has covered whole line with hi priority tiles,\r
- // we can process whole line and then act as if sh/hi mode was off.\r
- int c = 320/4, *zb = (int *)(HighCol+8);\r
- rendstatus|=0x80;\r
- while (c--)\r
- {\r
- int tmp = *zb;\r
- if (!(tmp & 0x80808080)) *zb=tmp&0x3f3f3f3f;\r
- else {\r
- if(!(tmp&0x00000080)) tmp&=~0x000000c0; if(!(tmp&0x00008000)) tmp&=~0x0000c000;\r
- if(!(tmp&0x00800000)) tmp&=~0x00c00000; if(!(tmp&0x80000000)) tmp&=~0xc0000000;\r
- *zb=tmp;\r
- }\r
- zb++;\r
+ int tmp = *zb;\r
+ if (!(tmp & 0x80808080)) *zb=tmp&0x3f3f3f3f;\r
+ else {\r
+ if(!(tmp&0x00000080)) tmp&=~0x000000c0; if(!(tmp&0x00008000)) tmp&=~0x0000c000;\r
+ if(!(tmp&0x00800000)) tmp&=~0x00c00000; if(!(tmp&0x80000000)) tmp&=~0xc0000000;\r
+ *zb=tmp;\r
}\r
+ zb++;\r
}\r
}\r
\r
\r
// *ts->hc++ = code | (dx<<16) | (ty<<25); // cache it\r
\r
- if (sh && (rendstatus&0xc0))\r
+ if (sh && (rendstatus & (PDRAW_SHHI_DONE|PDRAW_PLANE_HI_PRIO)))\r
{\r
- DrawTilesFromCacheShPrep();\r
+ if (!(rendstatus & PDRAW_SHHI_DONE))\r
+ DrawTilesFromCacheShPrep();\r
sh = 0;\r
}\r
\r
DrawAllSpritesInterlace(prio, maxwidth);\r
return;\r
}\r
- if(rs&0x11) {\r
+ if (rs & (PDRAW_SPRITES_MOVED|PDRAW_DIRTY_SPRITES)) {\r
//dprintf("PrepareSprites(%i) [%i]", (rs>>4)&1, scan);\r
- PrepareSprites(rs&0x10);\r
- rendstatus=rs&~0x11;\r
+ PrepareSprites(rs & PDRAW_DIRTY_SPRITES);\r
+ rendstatus = rs & ~(PDRAW_SPRITES_MOVED|PDRAW_DIRTY_SPRITES);\r
}\r
if (!(SpriteBlocks & (1<<(scan>>3)))) return;\r
\r
- if(((rs&4)||sh)&&prio==0)\r
+ if (((rs&PDRAW_ACC_SPRITES)||sh) && prio==0)\r
memset(HighSprZ, 0, 328);\r
- if(!(rs&4)&&prio) {\r
+ if (!(rs&PDRAW_ACC_SPRITES)&&prio) {\r
if(hcache[0]) DrawSpritesFromCache(hcache, sh);\r
return;\r
}\r
\r
// accurate sprites\r
//dprintf("P:%i",((sx>>15)&1));\r
- if(rs&4) {\r
+ if (rs & PDRAW_ACC_SPRITES) {\r
// might need to skip this sprite\r
- if((pack2&0x8000) ^ (prio<<15)) continue;\r
+ if ((pack2&0x8000) ^ (prio<<15)) continue;\r
DrawSpriteZ(pack,pack2,sh|(prio<<1),(char)(0x1f-n));\r
continue;\r
}\r
}\r
\r
// Go through sprites backwards:\r
- if(!(rs&4)) {\r
+ if (!(rs & PDRAW_ACC_SPRITES)) {\r
for (i--; i>=0; i--)\r
DrawSprite(sprites[i],&hcache,sh);\r
\r
if (Pico.video.reg[12]&1) {\r
len = 320;\r
} else {\r
- if(!(PicoOpt&0x100)) pd+=32;\r
+ if(!(PicoOpt&POPT_DIS_32C_BORDER)) pd+=32;\r
len = 256;\r
}\r
\r
if (Pico.video.reg[12]&1) {\r
len = 320;\r
} else {\r
- if (!(PicoOpt&0x100)) pd+=32;\r
+ if (!(PicoOpt&POPT_DIS_32C_BORDER)) pd+=32;\r
len = 256;\r
}\r
\r
int len, rs = rendstatus;\r
static int dirty_count;\r
\r
- if (!sh && Pico.m.dirtyPal == 1 && Scanline < 222) {\r
+ if (!sh && Pico.m.dirtyPal == 1 && Scanline < 222)\r
+ {\r
// a hack for mid-frame palette changes\r
- if (!(rs & 0x20))\r
+ if (!(rs & PDRAW_SONIC_MODE))\r
dirty_count = 1;\r
else dirty_count++;\r
- rs |= 0x20;\r
+ rs |= PDRAW_SONIC_MODE;\r
rendstatus = rs;\r
if (dirty_count == 3) {\r
blockcpy(HighPal, Pico.cram, 0x40*2);\r
if (Pico.video.reg[12]&1) {\r
len = 320;\r
} else {\r
- if(!(PicoOpt&0x100)) pd+=32;\r
+ if (!(PicoOpt&POPT_DIS_32C_BORDER)) pd+=32;\r
len = 256;\r
}\r
\r
- if (!sh && rs & 0x20) {\r
+ if (!sh && (rs & PDRAW_SONIC_MODE)) {\r
if (dirty_count >= 11) {\r
blockcpy_or(pd, HighCol+8, len, 0x80);\r
} else {\r
\r
static void (*FinalizeLine)(int sh) = FinalizeLineBGR444;\r
\r
+// hblank was enabled early during prev line processng -\r
+// it should have been blanked\r
+static void handle_early_blank(int scanline, int sh)\r
+{\r
+ scanline--;\r
+\r
+ if (PicoScanBegin != NULL)\r
+ PicoScanBegin(scanline);\r
+\r
+ BackFill(Pico.video.reg[7], sh);\r
+\r
+ if (FinalizeLine != NULL)\r
+ FinalizeLine(sh);\r
+\r
+ if (PicoScanEnd != NULL)\r
+ PicoScanEnd(scanline);\r
+}\r
+\r
// --------------------------------------------\r
\r
static int DrawDisplay(int sh)\r
int win=0,edge=0,hvwind=0;\r
int maxw, maxcells;\r
\r
- rendstatus&=~0xc0;\r
+ rendstatus &= ~(PDRAW_SHHI_DONE|PDRAW_PLANE_HI_PRIO);\r
\r
if(pvid->reg[12]&1) {\r
maxw = 328; maxcells = 40;\r
}\r
\r
\r
-static int Skip=0;\r
-\r
PICO_INTERNAL void PicoFrameStart(void)\r
{\r
// prepare to do this frame\r
- rendstatus = (PicoOpt&0x80)>>5; // accurate sprites\r
- if(rendstatus)\r
+ rendstatus = (PicoOpt&0x80)>>5; // accurate sprites, clear everything else\r
+ if (rendstatus)\r
Pico.video.status &= ~0x0020;\r
else Pico.video.status |= 0x0020; // sprite collision\r
- if((Pico.video.reg[12]&6) == 6) rendstatus |= 8; // interlace mode\r
- if(Pico.m.dirtyPal) Pico.m.dirtyPal = 2; // reset dirty if needed\r
+ if ((Pico.video.reg[12]&6) == 6) rendstatus |= PDRAW_INTERLACE; // interlace mode\r
+ if (Pico.m.dirtyPal) Pico.m.dirtyPal = 2; // reset dirty if needed\r
\r
PrepareSprites(1);\r
- Skip=0;\r
+ skip_next_line=0;\r
}\r
\r
PICO_INTERNAL int PicoLine(int scan)\r
{\r
int sh;\r
- if (Skip>0) { Skip--; return 0; } // Skip rendering lines\r
+ if (skip_next_line>0) { skip_next_line--; return 0; } // skip_next_line rendering lines\r
\r
Scanline=scan;\r
sh=(Pico.video.reg[0xC]&8)>>3; // shadow/hilight?\r
\r
+ if (rendstatus & PDRAW_EARLY_BLANK) {\r
+ if (scan > 0) handle_early_blank(scan, sh);\r
+ rendstatus &= ~PDRAW_EARLY_BLANK;\r
+ }\r
+\r
+ if (PicoScanBegin != NULL)\r
+ skip_next_line = PicoScanBegin(scan);\r
+\r
// Draw screen:\r
BackFill(Pico.video.reg[7], sh);\r
if (Pico.video.reg[1]&0x40)\r
if (FinalizeLine != NULL)\r
FinalizeLine(sh);\r
\r
- Skip=PicoScan(Scanline,DrawLineDest);\r
+ if (PicoScanEnd != NULL)\r
+ PicoScanEnd(scan);\r
\r
return 0;\r
}\r
// orr the bits, which are set as output\r
value = data_reg&(Pico.ioports[i+4]|0x80);\r
\r
- if(PicoOpt & 0x20) { // 6 button gamepad enabled\r
+ if (PicoOpt & POPT_6BTN_PAD)\r
+ {\r
int phase = Pico.m.padTHPhase[i];\r
\r
if(phase == 2 && !(data_reg&0x40)) { // TH\r
#ifdef EMU_CORE_DEBUG\r
if(do_fake&&((ppop&0x3f)==0x3a||(ppop&0x3f)==0x3b)) return lastread_d[lrp_mus++&15];\r
#endif\r
- if(PicoMCD&1) return m68k_read_pcrelative_CD8(a);\r
+ if(PicoAHW&1) return m68k_read_pcrelative_CD8(a);\r
if((a&0xe00000)==0xe00000) return *(u8 *)(Pico.ram+((a^1)&0xffff)); // Ram\r
return 0;\r
}\r
#ifdef EMU_CORE_DEBUG\r
if(do_fake&&((ppop&0x3f)==0x3a||(ppop&0x3f)==0x3b)) return lastread_d[lrp_mus++&15];\r
#endif\r
- if(PicoMCD&1) return m68k_read_pcrelative_CD16(a);\r
+ if(PicoAHW&1) return m68k_read_pcrelative_CD16(a);\r
if((a&0xe00000)==0xe00000) return *(u16 *)(Pico.ram+(a&0xfffe)); // Ram\r
return 0;\r
}\r
#ifdef EMU_CORE_DEBUG\r
if(do_fake&&((ppop&0x3f)==0x3a||(ppop&0x3f)==0x3b)) return lastread_d[lrp_mus++&15];\r
#endif\r
- if(PicoMCD&1) return m68k_read_pcrelative_CD32(a);\r
+ if(PicoAHW&1) return m68k_read_pcrelative_CD32(a);\r
if((a&0xe00000)==0xe00000) { u16 *pm=(u16 *)(Pico.ram+(a&0xfffe)); return (pm[0]<<16)|pm[1]; } // Ram\r
return 0;\r
}\r
/* it appears that Musashi doesn't always mask the unused bits */\r
unsigned int m68k_read_memory_8(unsigned int address)\r
{\r
- unsigned int d = (PicoMCD&1) ? PicoReadCD8w(address) : PicoRead8(address);\r
+ unsigned int d = (PicoAHW&1) ? PicoReadCD8w(address) : PicoRead8(address);\r
return d&0xff;\r
}\r
\r
unsigned int m68k_read_memory_16(unsigned int address)\r
{\r
- unsigned int d = (PicoMCD&1) ? PicoReadCD16w(address) : PicoRead16(address);\r
+ unsigned int d = (PicoAHW&1) ? PicoReadCD16w(address) : PicoRead16(address);\r
return d&0xffff;\r
}\r
\r
unsigned int m68k_read_memory_32(unsigned int address)\r
{\r
- return (PicoMCD&1) ? PicoReadCD32w(address) : PicoRead32(address);\r
+ return (PicoAHW&1) ? PicoReadCD32w(address) : PicoRead32(address);\r
}\r
\r
void m68k_write_memory_8(unsigned int address, unsigned int value)\r
{\r
- if (PicoMCD&1) PicoWriteCD8w(address, (u8)value); else PicoWrite8(address, (u8)value);\r
+ if (PicoAHW&1) PicoWriteCD8w(address, (u8)value); else PicoWrite8(address, (u8)value);\r
}\r
\r
void m68k_write_memory_16(unsigned int address, unsigned int value)\r
{\r
- if (PicoMCD&1) PicoWriteCD16w(address,(u16)value); else PicoWrite16(address,(u16)value);\r
+ if (PicoAHW&1) PicoWriteCD16w(address,(u16)value); else PicoWrite16(address,(u16)value);\r
}\r
\r
void m68k_write_memory_32(unsigned int address, unsigned int value)\r
{\r
- if (PicoMCD&1) PicoWriteCD32w(address, value); else PicoWrite32(address, value);\r
+ if (PicoAHW&1) PicoWriteCD32w(address, value); else PicoWrite32(address, value);\r
}\r
#endif\r
#endif // EMU_M68K\r
\r
if ((a>>13)==2) // 0x4000-0x5fff (Charles MacDonald)\r
{\r
- if (PicoOpt&1) ret = (u8) YM2612Read();\r
+ if (PicoOpt&POPT_EN_FM) ret = (u8) YM2612Read();\r
return ret;\r
}\r
\r
addr68k=Pico.m.z80_bank68k<<15;\r
addr68k+=a&0x7fff;\r
\r
- if (PicoMCD & 1)\r
+ if (PicoAHW & PAHW_MCD)\r
ret = PicoReadM68k8(addr68k);\r
else ret = PicoRead8(addr68k);\r
elprintf(EL_Z80BNK, "z80->68k r8 [%06x] %02x", addr68k, ret);\r
{\r
if ((a>>13)==2) // 0x4000-0x5fff (Charles MacDonald)\r
{\r
- if(PicoOpt&1) emustatus|=YM2612Write(a, data) & 1;\r
+ if(PicoOpt&POPT_EN_FM) emustatus|=YM2612Write(a, data) & 1;\r
return;\r
}\r
\r
if ((a&0xfff9)==0x7f11) // 7f11 7f13 7f15 7f17\r
{\r
- if(PicoOpt&2) SN76496Write(data);\r
+ if(PicoOpt&POPT_EN_PSG) SN76496Write(data);\r
return;\r
}\r
\r
addr68k=Pico.m.z80_bank68k<<15;\r
addr68k+=a&0x7fff;\r
elprintf(EL_Z80BNK, "z80->68k w8 [%06x] %02x", addr68k, data);\r
- if (PicoMCD & 1)\r
+ if (PicoAHW & PAHW_MCD)\r
PicoWriteM68k8(addr68k, data);\r
else PicoWrite8(addr68k, data);\r
return;\r
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
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;
{
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]++;
}
\r
int PicoVer=0x0133;\r
struct Pico Pico;\r
-int PicoOpt=0; // disable everything by default\r
-int PicoSkipFrame=0; // skip rendering frame?\r
+int PicoOpt = 0;\r
+int PicoSkipFrame = 0; // skip rendering frame?\r
+int emustatus = 0; // rapid_ym2612, multi_ym_updates\r
+int PicoPad[2]; // Joypads, format is SACB RLDU\r
+int PicoAHW = 0; // active addon hardware: scd_active, 32x_active, svp_active\r
int PicoRegionOverride = 0; // override the region detection 0: Auto, 1: Japan NTSC, 2: Japan PAL, 4: US, 8: Europe\r
int PicoAutoRgnOrder = 0;\r
-int emustatus = 0; // rapid_ym2612, multi_ym_updates\r
+int z80startCycle, z80stopCycle; // in 68k cycles\r
+struct PicoSRAM SRam = {0,};\r
+\r
void (*PicoWriteSound)(int len) = NULL; // called at the best time to send sound buffer (PsndOut) to hardware\r
void (*PicoResetHook)(void) = NULL;\r
void (*PicoLineHook)(int count) = NULL;\r
\r
-struct PicoSRAM SRam = {0,};\r
-int z80startCycle, z80stopCycle; // in 68k cycles\r
-int PicoPad[2]; // Joypads, format is SACB RLDU\r
-int PicoMCD = 0; // mega CD status: scd_started\r
-\r
// to be called once on emu init\r
int PicoInit(void)\r
{\r
// to be called once on emu exit\r
void PicoExit(void)\r
{\r
- if (PicoMCD&1)\r
+ if (PicoAHW & PAHW_MCD)\r
PicoExitMCD();\r
z80_exit();\r
\r
Pico.video.reg[0xc] = 0x81;\r
Pico.video.reg[0xf] = 0x02;\r
\r
- if (PicoMCD & 1)\r
+ if (PicoAHW & PAHW_MCD)\r
PicoPowerMCD();\r
\r
PicoReset();\r
PicoMemReset();\r
SekReset();\r
// s68k doesn't have the TAS quirk, so we just globally set normal TAS handler in MCD mode (used by Batman games).\r
- SekSetRealTAS(PicoMCD & 1);\r
+ SekSetRealTAS(PicoAHW & PAHW_MCD);\r
SekCycleCntT=0;\r
\r
- if (PicoMCD & 1)\r
+ if (PicoAHW & PAHW_MCD)\r
// needed for MCD to reset properly, probably some bug hides behind this..\r
memset(Pico.ioports,0,sizeof(Pico.ioports));\r
emustatus = 0;\r
PsndReset(); // pal must be known here\r
\r
// create an empty "dma" to cause 68k exec start at random frame location\r
- if (Pico.m.dma_xfers == 0 && !(PicoOpt&0x10000))\r
+ if (Pico.m.dma_xfers == 0 && !(PicoOpt&POPT_DIS_VDP_FIFO))\r
Pico.m.dma_xfers = rand() & 0x1fff;\r
\r
- if (PicoMCD & 1) {\r
+ if (PicoAHW & PAHW_MCD) {\r
PicoResetMCD();\r
return 0;\r
}\r
int line_from_r=line_from, line_to_r=line_to, line=0;\r
int line_sample = Pico.m.pal ? 68 : 93;\r
\r
- if (!(PicoOpt&4) || Pico.m.z80Run == 0) line_to_r = 0;\r
+ if (!(PicoOpt&POPT_EN_Z80) || Pico.m.z80Run == 0) line_to_r = 0;\r
else {\r
extern const unsigned short vcounts[];\r
if (z80startCycle) {\r
z80startCycle = SekCyclesDone();\r
}\r
\r
- if (PicoOpt&1) {\r
+ if (PicoOpt&POPT_EN_FM) {\r
// we have ym2612 enabled, so we have to run Z80 in lines, so we could update DAC and timers\r
for (line = line_from; line < line_to; line++) {\r
Psnd_timers_and_dac(line);\r
}\r
\r
// a hack for VR, to get it running in fast mode\r
- if (PicoRead16Hook == PicoSVPRead16)\r
+ if (PicoAHW & PAHW_SVP)\r
Pico.ram[0xd864^1] = 0x1a;\r
\r
// we don't emulate DMA timing in this mode\r
}\r
\r
// another hack for VR (it needs hints to work)\r
- if (PicoRead16Hook == PicoSVPRead16) {\r
+ if (PicoAHW & PAHW_SVP) {\r
Pico.ram[0xd864^1] = 1;\r
pv->pending_ints|=0x10;\r
if (pv->reg[0]&0x10) SekInterrupt(4);\r
// render screen\r
if (!PicoSkipFrame)\r
{\r
- if (!(PicoOpt&0x10))\r
+ if (!(PicoOpt&POPT_ALT_RENDERER))\r
{\r
// Draw the screen\r
#if CAN_HANDLE_240_LINES\r
}\r
\r
// here we render sound if ym2612 is disabled\r
- if (!(PicoOpt&1) && PsndOut) {\r
+ if (!(PicoOpt&POPT_EN_FM) && PsndOut) {\r
int len = PsndRender(0, PsndLen);\r
if (PicoWriteSound) PicoWriteSound(len);\r
// clear sound buffer\r
}\r
\r
if (pv->reg[1]&0x20) SekInterrupt(6); // Set IRQ\r
- if (Pico.m.z80Run && (PicoOpt&4))\r
+ if (Pico.m.z80Run && (PicoOpt&POPT_EN_Z80))\r
z80_int();\r
\r
- while (sects) {\r
+ while (sects)\r
+ {\r
lines += lines_step;\r
\r
SekRunM68k(cycles_68k_vblock);\r
\r
Pico.m.frame_count++;\r
\r
- if (PicoMCD & 1) {\r
+ if (PicoAHW & PAHW_MCD) {\r
PicoFrameMCD();\r
return 0;\r
}\r
\r
// be accurate if we are asked for this\r
- if(PicoOpt&0x40) acc=1;\r
+ if (PicoOpt&POPT_ACC_TIMING) acc=1;\r
// don't be accurate in alternative render mode, as hint effects will not be rendered anyway\r
- else if(PicoOpt&0x10) acc = 0;\r
+ else if (PicoOpt&POPT_ALT_RENDERER) acc = 0;\r
else acc=Pico.video.reg[0]&0x10; // be accurate if hints are used\r
\r
//if(Pico.video.reg[12]&0x2) Pico.video.status ^= 0x10; // change odd bit in interlace mode\r
\r
- if(!(PicoOpt&0x10))\r
+ if (!(PicoOpt&POPT_ALT_RENDERER))\r
PicoFrameStart();\r
\r
- if(acc)\r
+ if (acc)\r
PicoFrameHints();\r
else PicoFrameSimple();\r
\r
// Pico Library - Header File\r
\r
// (c) Copyright 2004 Dave, All rights reserved.\r
-// (c) Copyright 2006-2007 notaz, All rights reserved.\r
+// (c) Copyright 2006-2008 notaz, All rights reserved.\r
// Free for non-commercial use.\r
\r
// For commercial use, separate licencing terms must be obtained.\r
\r
\r
// Pico.c\r
-// PicoOpt bits LSb->MSb:\r
-// 00 000x enable_ym2612&dac, enable_sn76496, enable_z80, stereo_sound,\r
-// 00 00x0 alt_renderer, 6button_gamepad, accurate_timing, accurate_sprites,\r
-// 00 0x00 draw_no_32col_border, external_ym2612, enable_cd_pcm, enable_cd_cdda\r
-// 00 x000 enable_cd_gfx, cd_perfect_sync, soft_32col_scaling, enable_cd_ramcart\r
-// 0x 0000 disable_vdp_fifo, no_svp_dynarec, no_sprite_limit\r
-extern int PicoOpt;\r
+#define POPT_EN_FM (1<< 0) // 00 000x\r
+#define POPT_EN_PSG (1<< 1)\r
+#define POPT_EN_Z80 (1<< 2)\r
+#define POPT_EN_STEREO (1<< 3)\r
+#define POPT_ALT_RENDERER (1<< 4) // 00 00x0\r
+#define POPT_6BTN_PAD (1<< 5)\r
+#define POPT_ACC_TIMING (1<< 6)\r
+#define POPT_ACC_SPRITES (1<< 7)\r
+#define POPT_DIS_32C_BORDER (1<< 8) // 00 0x00\r
+#define POPT_EXT_FM (1<< 9)\r
+#define POPT_EN_MCD_PCM (1<<10)\r
+#define POPT_EN_MCD_CDDA (1<<11)\r
+#define POPT_EN_MCD_GFX (1<<12) // 00 x000\r
+#define POPT_EN_MCD_PSYNC (1<<13)\r
+#define POPT_EN_SOFTSCALE (1<<14)\r
+#define POPT_EN_MCD_RAMCART (1<<15)\r
+#define POPT_DIS_VDP_FIFO (1<<16) // 0x 0000\r
+#define POPT_EN_SVP_DRC (1<<17)\r
+extern int PicoOpt; // bitfield\r
extern int PicoVer;\r
extern int PicoSkipFrame; // skip rendering frame, but still do sound (if enabled) and emulation stuff\r
extern int PicoRegionOverride; // override the region detection 0: auto, 1: Japan NTSC, 2: Japan PAL, 4: US, 8: Europe\r
#if OVERRIDE_HIGHCOL\r
extern unsigned char *HighCol;\r
#endif\r
-extern int (*PicoScan)(unsigned int num, void *data);\r
-// internals\r
-extern unsigned short HighPal[0x100];\r
-extern int rendstatus;\r
+extern int (*PicoScanBegin)(unsigned int num);\r
+extern int (*PicoScanEnd)(unsigned int num);\r
// utility\r
#ifdef _ASM_DRAW_C\r
void vidConvCpyRGB565(void *to, void *from, int pixels);\r
#endif\r
+// internals\r
+#define PDRAW_SPRITES_MOVED (1<<0)\r
+#define PDRAW_WND_DIFF_PRIO (1<<1) // not all window tiles use same priority\r
+#define PDRAW_ACC_SPRITES (1<<2) // accurate sprites (copied from PicoOpt)\r
+#define PDRAW_INTERLACE (1<<3) // \r
+#define PDRAW_DIRTY_SPRITES (1<<4)\r
+#define PDRAW_SONIC_MODE (1<<5) // mid-frame palette changes for 8bit renderer\r
+#define PDRAW_PLANE_HI_PRIO (1<<6) // have layer with all hi prio tiles (mk3)\r
+#define PDRAW_SHHI_DONE (1<<7) // layer sh/hi already processed\r
+#define PDRAW_EARLY_BLANK (1<<8) // blanking enabled at the start of prev line\r
+extern int rendstatus;\r
+extern unsigned short HighPal[0x100];\r
\r
// Draw2.c\r
// stuff below is optional\r
// 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; \
#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); \
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();
// 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();
}
}
- if (PicoOpt&1)
+ if (PicoOpt&POPT_EN_FM)
Psnd_timers_and_dac(y);
#ifndef PICO_CD
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
check_cd_dma();
#endif
- if(PicoOpt&1)
+ if (PicoOpt&POPT_EN_FM)
Psnd_timers_and_dac(y);
// Run scanline:
extern struct Cyclone PicoCpuCM68k, PicoCpuCS68k;\r
#define SekCyclesLeftNoMCD PicoCpuCM68k.cycles // cycles left for this run\r
#define SekCyclesLeft \\r
- (((PicoMCD&1) && (PicoOpt & 0x2000)) ? (SekCycleAim-SekCycleCnt) : SekCyclesLeftNoMCD)\r
+ (((PicoAHW&1) && (PicoOpt & POPT_EN_MCD_PSYNC)) ? (SekCycleAim-SekCycleCnt) : SekCyclesLeftNoMCD)\r
#define SekCyclesLeftS68k \\r
- ((PicoOpt & 0x2000) ? (SekCycleAimS68k-SekCycleCntS68k) : PicoCpuCS68k.cycles)\r
+ ((PicoOpt & POPT_EN_MCD_PSYNC) ? (SekCycleAimS68k-SekCycleCntS68k) : PicoCpuCS68k.cycles)\r
#define SekSetCyclesLeftNoMCD(c) PicoCpuCM68k.cycles=c\r
#define SekSetCyclesLeft(c) { \\r
- if ((PicoMCD&1) && (PicoOpt & 0x2000)) SekCycleCnt=SekCycleAim-(c); else SekSetCyclesLeftNoMCD(c); \\r
+ if ((PicoAHW&1) && (PicoOpt & POPT_EN_MCD_PSYNC)) SekCycleCnt=SekCycleAim-(c); else SekSetCyclesLeftNoMCD(c); \\r
}\r
#define SekPc (PicoCpuCM68k.pc-PicoCpuCM68k.membase)\r
#define SekPcS68k (PicoCpuCS68k.pc-PicoCpuCS68k.membase)\r
extern M68K_CONTEXT PicoCpuFM68k, PicoCpuFS68k;\r
#define SekCyclesLeftNoMCD PicoCpuFM68k.io_cycle_counter\r
#define SekCyclesLeft \\r
- (((PicoMCD&1) && (PicoOpt & 0x2000)) ? (SekCycleAim-SekCycleCnt) : SekCyclesLeftNoMCD)\r
+ (((PicoAHW&1) && (PicoOpt & POPT_EN_MCD_PSYNC)) ? (SekCycleAim-SekCycleCnt) : SekCyclesLeftNoMCD)\r
#define SekCyclesLeftS68k \\r
- ((PicoOpt & 0x2000) ? (SekCycleAimS68k-SekCycleCntS68k) : PicoCpuFS68k.io_cycle_counter)\r
+ ((PicoOpt & POPT_EN_MCD_PSYNC) ? (SekCycleAimS68k-SekCycleCntS68k) : PicoCpuFS68k.io_cycle_counter)\r
#define SekSetCyclesLeftNoMCD(c) PicoCpuFM68k.io_cycle_counter=c\r
#define SekSetCyclesLeft(c) { \\r
- if ((PicoMCD&1) && (PicoOpt & 0x2000)) SekCycleCnt=SekCycleAim-(c); else SekSetCyclesLeftNoMCD(c); \\r
+ if ((PicoAHW&1) && (PicoOpt & POPT_EN_MCD_PSYNC)) SekCycleCnt=SekCycleAim-(c); else SekSetCyclesLeftNoMCD(c); \\r
}\r
#define SekPc fm68k_get_pc(&PicoCpuFM68k)\r
#define SekPcS68k fm68k_get_pc(&PicoCpuFS68k)\r
#ifndef SekCyclesLeft\r
#define SekCyclesLeftNoMCD PicoCpuMM68k.cyc_remaining_cycles\r
#define SekCyclesLeft \\r
- (((PicoMCD&1) && (PicoOpt & 0x2000)) ? (SekCycleAim-SekCycleCnt) : SekCyclesLeftNoMCD)\r
+ (((PicoAHW&1) && (PicoOpt & POPT_EN_MCD_PSYNC)) ? (SekCycleAim-SekCycleCnt) : SekCyclesLeftNoMCD)\r
#define SekCyclesLeftS68k \\r
- ((PicoOpt & 0x2000) ? (SekCycleAimS68k-SekCycleCntS68k) : PicoCpuMS68k.cyc_remaining_cycles)\r
+ ((PicoOpt & POPT_EN_MCD_PSYNC) ? (SekCycleAimS68k-SekCycleCntS68k) : PicoCpuMS68k.cyc_remaining_cycles)\r
#define SekSetCyclesLeftNoMCD(c) SET_CYCLES(c)\r
#define SekSetCyclesLeft(c) { \\r
- if ((PicoMCD&1) && (PicoOpt & 0x2000)) SekCycleCnt=SekCycleAim-(c); else SET_CYCLES(c); \\r
+ if ((PicoAHW&1) && (PicoOpt & POPT_EN_MCD_PSYNC)) SekCycleCnt=SekCycleAim-(c); else SET_CYCLES(c); \\r
}\r
#define SekPc m68k_get_reg(&PicoCpuMM68k, M68K_REG_PC)\r
#define SekPcS68k m68k_get_reg(&PicoCpuMS68k, M68K_REG_PC)\r
\r
// ---------------------------------------------------------\r
\r
-extern int PicoMCD;\r
+// Pico active hw\r
+#define PAHW_MCD (1<<0)\r
+#define PAHW_32X (1<<1)\r
+#define PAHW_SVP (1<<2)\r
+extern int PicoAHW;\r
\r
// main oscillator clock which controls timing\r
#define OSC_NTSC 53693100\r
extern const unsigned char hcounts_32[];\r
extern const unsigned char hcounts_40[];\r
extern const unsigned short vcounts[];\r
-extern int rendstatus;\r
\r
#ifndef UTYPES_DEFINED\r
typedef unsigned char u8;\r
{\r
case 1: if(a&1) d=(u16)((d<<8)|(d>>8)); // If address is odd, bytes are swapped (which game needs this?)\r
Pico.vram [(a>>1)&0x7fff]=d;\r
- rendstatus|=0x10; break;\r
+ rendstatus |= PDRAW_DIRTY_SPRITES; break;\r
case 3: Pico.m.dirtyPal = 1;\r
Pico.cram [(a>>1)&0x003f]=d; break; // wraps (Desert Strike)\r
case 5: Pico.vsram[(a>>1)&0x003f]=d; break;\r
Pico.video.type, source, a, len, inc, (Pico.video.status&8)||!(Pico.video.reg[1]&0x40),\r
SekCyclesDone(), SekPc);\r
\r
- if(Pico.m.scanline != -1) {\r
+ if (Pico.m.scanline != -1) {\r
Pico.m.dma_xfers += len;\r
- if ((PicoMCD&1) && (PicoOpt & 0x2000)) SekCyclesBurn(CheckDMA());\r
+ if ((PicoAHW & PAHW_MCD) && (PicoOpt & POPT_EN_MCD_PSYNC)) SekCyclesBurn(CheckDMA());\r
else SekSetCyclesLeftNoMCD(SekCyclesLeftNoMCD - CheckDMA());\r
} else {\r
// be approximate in non-accurate mode\r
if ((source&0xe00000)==0xe00000) { // Ram\r
pd=(u16 *)(Pico.ram+(source&0xfffe));\r
pdend=(u16 *)(Pico.ram+0x10000);\r
- } else if (PicoMCD & 1) {\r
+ }\r
+ else if (PicoAHW & PAHW_MCD)\r
+ {\r
elprintf(EL_VDPDMA, "DmaSlow CD, r3=%02x", Pico_mcd->s68k_regs[3]);\r
if(source<0x20000) { // Bios area\r
pd=(u16 *)(Pico_mcd->bios+(source&~1));\r
elprintf(EL_VDPDMA|EL_ANOMALY, "DmaSlow[%i] %06x->%04x: FIXME: unsupported src", Pico.video.type, source, a);\r
return;\r
}\r
- } else {\r
+ }\r
+ else\r
+ {\r
// if we have DmaHook, let it handle ROM because of possible DMA delay\r
if (PicoDmaHook && PicoDmaHook(source, len, &pd, &pdend));\r
else if (source<Pico.romsize) { // Rom\r
//if(pd >= pdend) pd-=0x8000; // should be good for RAM, bad for ROM\r
}\r
}\r
- rendstatus|=0x10;\r
+ rendstatus |= PDRAW_DIRTY_SPRITES;\r
break;\r
\r
case 3: // cram\r
}\r
// remember addr\r
Pico.video.addr=a;\r
- rendstatus|=0x10;\r
+ rendstatus |= PDRAW_DIRTY_SPRITES;\r
}\r
\r
// check: Contra, Megaman\r
// update length\r
Pico.video.reg[0x13] = Pico.video.reg[0x14] = 0; // Dino Dini's Soccer (E) (by Haze)\r
\r
- rendstatus|=0x10;\r
+ rendstatus |= PDRAW_DIRTY_SPRITES;\r
}\r
\r
static void CommandDma(void)\r
else\r
{\r
// preliminary FIFO emulation for Chaos Engine, The (E)\r
- if(!(pvid->status&8) && (pvid->reg[1]&0x40) && Pico.m.scanline!=-1 && !(PicoOpt&0x10000)) // active display, accurate mode?\r
+ if(!(pvid->status&8) && (pvid->reg[1]&0x40) && Pico.m.scanline!=-1 && !(PicoOpt&POPT_DIS_VDP_FIFO)) // active display, accurate mode?\r
{\r
pvid->status&=~0x200; // FIFO no longer empty\r
pvid->lwrite_cnt++;\r
pvid->command|=d;\r
pvid->pending=0;\r
CommandChange();\r
- } else {\r
- if((d&0xc000)==0x8000)\r
+ }\r
+ else\r
+ {\r
+ if ((d&0xc000)==0x8000)\r
{\r
// Register write:\r
int num=(d>>8)&0x1f;\r
int dold=pvid->reg[num];\r
+ pvid->type=0; // register writes clear command (else no Sega logo in Golden Axe II)\r
if (num > 0x0a && !(pvid->reg[1]&4)) {\r
elprintf(EL_ANOMALY, "%02x written to reg %02x in SMS mode @ %06x", d, num, SekPc);\r
+ return;\r
} else\r
- pvid->reg[num]=(unsigned char)d;\r
- if (num==00) elprintf(EL_INTSW, "hint_onoff: %i->%i [%i] pend=%i @ %06x", (dold&0x10)>>4,\r
- (d&0x10)>>4, SekCyclesDone(), (pvid->pending_ints&0x10)>>4, SekPc);\r
- if (num==01) elprintf(EL_INTSW, "vint_onoff: %i->%i [%i] pend=%i @ %06x", (dold&0x20)>>5,\r
- (d&0x20)>>5, SekCyclesDone(), (pvid->pending_ints&0x20)>>5, SekPc);\r
- if (num == 5 && (d^dold)) rendstatus|=1;\r
- // renderers should update their palettes if sh/hi mode is changed\r
- else if (num == 0xc && ((d^dold)&8)) Pico.m.dirtyPal = 2;\r
+ pvid->reg[num]=(unsigned char)d;\r
+\r
+ switch (num)\r
+ {\r
+ case 0x00:\r
+ elprintf(EL_INTSW, "hint_onoff: %i->%i [%i] pend=%i @ %06x", (dold&0x10)>>4,\r
+ (d&0x10)>>4, SekCyclesDone(), (pvid->pending_ints&0x10)>>4, SekPc);\r
+ goto update_irq;\r
+ case 0x01:\r
+ elprintf(EL_INTSW, "vint_onoff: %i->%i [%i] pend=%i @ %06x", (dold&0x20)>>5,\r
+ (d&0x20)>>5, SekCyclesDone(), (pvid->pending_ints&0x20)>>5, SekPc);\r
+ if (!(d&0x40) && SekCyclesLeft > 420) { /*elprintf(EL_ANOMALY, "aa %i", SekCyclesLeft);*/ rendstatus |= PDRAW_EARLY_BLANK; }\r
+ goto update_irq;\r
+ case 0x05:\r
+ if (d^dold) rendstatus |= PDRAW_SPRITES_MOVED;\r
+ break;\r
+ case 0x0c:\r
+ // renderers should update their palettes if sh/hi mode is changed\r
+ if ((d^dold)&8) Pico.m.dirtyPal = 2;\r
+ break;\r
+ }\r
+ return;\r
+\r
+update_irq:\r
#ifndef EMU_CORE_DEBUG\r
// update IRQ level (Lemmings, Wiz 'n' Liz intro, ... )\r
// may break if done improperly:\r
// International Superstar Soccer Deluxe (crash), Street Racer (logos), Burning Force (gfx),\r
// Fatal Rewind (crash), Sesame Street Counting Cafe\r
- else if (num < 2)\r
+ if (!SekShouldInterrupt) // hack\r
{\r
- if (!SekShouldInterrupt) // hack\r
- {\r
- int lines, pints, irq=0;\r
- lines = (pvid->reg[1] & 0x20) | (pvid->reg[0] & 0x10);\r
- pints = (pvid->pending_ints&lines);\r
- if(pints & 0x20) irq = 6;\r
- else if(pints & 0x10) irq = 4;\r
- SekInterrupt(irq); // update line\r
-\r
- if (irq && Pico.m.scanline!=-1) SekEndRun(24); // make it delayed\r
- }\r
+ int lines, pints, irq=0;\r
+ lines = (pvid->reg[1] & 0x20) | (pvid->reg[0] & 0x10);\r
+ pints = (pvid->pending_ints&lines);\r
+ if(pints & 0x20) irq = 6;\r
+ else if(pints & 0x10) irq = 4;\r
+ SekInterrupt(irq); // update line\r
+\r
+ if (irq && Pico.m.scanline!=-1) SekEndRun(24); // make it delayed\r
}\r
#endif\r
- pvid->type=0; // register writes clear command (else no Sega logo in Golden Axe II)\r
- } else {\r
+ }\r
+ else\r
+ {\r
// High word of command:\r
pvid->command&=0x0000ffff;\r
pvid->command|=d<<16;\r
{\r
struct PicoVideo *pv=&Pico.video;\r
d=pv->status;\r
- if (PicoOpt&0x10) d|=0x0020; // sprite collision (Shadow of the Beast)\r
- if (!(pv->reg[1]&0x40)) d|=0x0008; // set V-Blank if display is disabled\r
- if (SekCyclesLeft < 84+4) d|=0x0004; // H-Blank (Sonic3 vs)\r
+ if (PicoOpt&POPT_ALT_RENDERER) d|=0x0020; // sprite collision (Shadow of the Beast)\r
+ if (!(pv->reg[1]&0x40)) d|=0x0008; // set V-Blank if display is disabled\r
+ if (SekCyclesLeft < 84+4) d|=0x0004; // H-Blank (Sonic3 vs)\r
\r
d|=(pv->pending_ints&0x20)<<2; // V-int pending?\r
if (d&0x100) pv->status&=~0x100; // FIFO no longer full\r
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);
// 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;
}
svp_states[1].ptr = svp->dram;
svp_states[2].ptr = &svp->ssp1601;
carthw_chunks = svp_states;
+ PicoAHW |= PAHW_SVP;
}
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));
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));
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))
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])
breakswitch:;
}
- if (PicoMCD & 1)
+ if (PicoAHW & PAHW_MCD)
{
/* after load events */
if (Pico_mcd->s68k_regs[3]&4) // 1M mode?
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)
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])
#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);
}
PICO_INTERNAL int PicoFrameMCD(void)
{
- if(!(PicoOpt&0x10))
+ if (!(PicoOpt&POPT_ALT_RENDERER))
PicoFrameStart();
PicoFrameHints();
_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;
// AutoIncrement
a=(u16)(a+inc);
}
- rendstatus|=0x10;
+ rendstatus |= PDRAW_SPRITES_MOVED;
break;
case 3: // cram
int target_fps = Pico.m.pal ? 50 : 60;\r
\r
// not all rates are supported in MCD mode due to mp3 decoder limitations\r
- if (PicoMCD & 1) {\r
+ if (PicoAHW & PAHW_MCD) {\r
if (PsndRate != 11025 && PsndRate != 22050 && PsndRate != 44100) PsndRate = 22050;\r
- PicoOpt |= 8; // force stereo\r
+ PicoOpt |= POPT_EN_STEREO; // force stereo\r
}\r
\r
if (preserve_state) {\r
state = malloc(0x200);\r
if (state == NULL) return;\r
memcpy(state, YM2612GetRegs(), 0x200);\r
- if ((PicoMCD & 1) && Pico_mcd->m.audio_track)\r
+ if ((PicoAHW & PAHW_MCD) && Pico_mcd->m.audio_track)\r
Pico_mcd->m.audio_offset = mp3_get_offset();\r
}\r
YM2612Init(Pico.m.pal ? OSC_PAL/7 : OSC_NTSC/7, PsndRate);\r
// feed it back it's own registers, just like after loading state\r
memcpy(YM2612GetRegs(), state, 0x200);\r
YM2612PicoStateLoad();\r
- if ((PicoMCD & 1) && Pico_mcd->m.audio_track)\r
+ if ((PicoAHW & PAHW_MCD) && Pico_mcd->m.audio_track)\r
mp3_start_play(Pico_mcd->TOC.Tracks[Pico_mcd->m.audio_track].F, Pico_mcd->m.audio_offset);\r
}\r
\r
// recalculate dac info\r
dac_recalculate();\r
\r
- if (PicoMCD & 1)\r
+ if (PicoAHW & PAHW_MCD)\r
pcm_set_rate(PsndRate);\r
\r
// clear all buffers\r
PsndClear();\r
\r
// set mixer\r
- PsndMix_32_to_16l = (PicoOpt & 8) ? mix_32_to_16l_stereo : mix_32_to_16_mono;\r
+ PsndMix_32_to_16l = (PicoOpt & POPT_EN_STEREO) ? mix_32_to_16l_stereo : mix_32_to_16_mono;\r
}\r
\r
\r
PICO_INTERNAL void Psnd_timers_and_dac(int raster)\r
{\r
int pos, len;\r
- int do_dac = PsndOut && (PicoOpt&1) && *ym2612_dacen;\r
-// int do_pcm = PsndOut && (PicoMCD&1) && (PicoOpt&0x400);\r
+ int do_dac = PsndOut && (PicoOpt&POPT_EN_FM) && *ym2612_dacen;\r
+// int do_pcm = PsndOut && (PicoAHW&1) && (PicoOpt&0x400);\r
\r
// Our raster lasts 63.61323/64.102564 microseconds (NTSC/PAL)\r
YM2612PicoTick(1);\r
\r
pos>>=4;\r
\r
- if (do_dac) {\r
+ if (do_dac)\r
+ {\r
short *d = PsndOut + pos*2;\r
int dout = *ym2612_dacout;\r
- if(PicoOpt&8) {\r
+ if(PicoOpt&POPT_EN_STEREO) {\r
// some manual loop unrolling here :)\r
d[0] = dout;\r
if (len > 1) {\r
{\r
int len = PsndLen;\r
if (PsndLen_exc_add) len++;\r
- if (PicoOpt & 8)\r
+ if (PicoOpt & POPT_EN_STEREO)\r
memset32((int *) PsndOut, 0, len); // assume PsndOut to be aligned\r
else {\r
short *out = PsndOut;\r
int *buf32 = PsndBuffer+offset;\r
int stereo = (PicoOpt & 8) >> 3;\r
// emulating CD && PCM option enabled && PCM chip on && have enabled channels\r
- int do_pcm = (PicoMCD&1) && (PicoOpt&0x400) && (Pico_mcd->pcm.control & 0x80) && Pico_mcd->pcm.enabled;\r
+ int do_pcm = (PicoAHW & PAHW_MCD) && (PicoOpt&POPT_EN_MCD_PCM) &&\r
+ (Pico_mcd->pcm.control & 0x80) && Pico_mcd->pcm.enabled;\r
offset <<= stereo;\r
\r
#if !SIMPLE_WRITE_SOUND\r
#endif\r
\r
// PSG\r
- if (PicoOpt & 2)\r
+ if (PicoOpt & POPT_EN_PSG)\r
SN76496Update(PsndOut+offset, length, stereo);\r
\r
// Add in the stereo FM buffer\r
- if (PicoOpt & 1) {\r
+ if (PicoOpt & POPT_EN_FM) {\r
buf32_updated = YM2612UpdateOne(buf32, length, stereo, 1);\r
} else\r
memset32(buf32, 0, length<<stereo);\r
\r
// CD: CDDA audio\r
// CD mode, cdda enabled, not data track, CDC is reading\r
- if ((PicoMCD & 1) && (PicoOpt & 0x800) && !(Pico_mcd->s68k_regs[0x36] & 1) && (Pico_mcd->scd.Status_CDC & 1))\r
+ if ((PicoAHW & PAHW_MCD) && (PicoOpt & POPT_EN_MCD_CDDA) &&\r
+ !(Pico_mcd->s68k_regs[0x36] & 1) && (Pico_mcd->scd.Status_CDC & 1))\r
mp3_update(buf32, length, stereo);\r
\r
// convert + limit to normal 16bit output\r
switch (me->id)
{
case MA_OPT_RENDERER:
- if (no_def && !((defaultConfig.s_PicoOpt^PicoOpt)&0x10) &&
+ if (no_def && !((defaultConfig.s_PicoOpt^PicoOpt)&POPT_ALT_RENDERER) &&
!((defaultConfig.EmuOpt^currentConfig.EmuOpt)&0x80)) return;
- if (PicoOpt&0x10)
+ if (PicoOpt&POPT_ALT_RENDERER)
str = "8bit fast";
else if (currentConfig.EmuOpt&0x80)
str = "16bit accurate";
fprintf(f, "Frameskip = %s", str24);
break;
case MA_OPT_SOUND_QUALITY:
- if (no_def && !((defaultConfig.s_PicoOpt^PicoOpt)&8) &&
+ if (no_def && !((defaultConfig.s_PicoOpt^PicoOpt)&POPT_EN_STEREO) &&
defaultConfig.s_PsndRate == PsndRate) return;
- str = (PicoOpt&0x08)?"stereo":"mono";
+ str = (PicoOpt&POPT_EN_STEREO)?"stereo":"mono";
fprintf(f, "Sound Quality = %i %s", PsndRate, str);
break;
case MA_OPT_REGION:
case MA_OPT_RENDERER:
if (strcasecmp(var, "Renderer") != 0) return 0;
if (strcasecmp(val, "8bit fast") == 0) {
- PicoOpt |= 0x10;
+ PicoOpt |= POPT_ALT_RENDERER;
}
else if (strcasecmp(val, "16bit accurate") == 0) {
- PicoOpt &= ~0x10;
+ PicoOpt &= ~POPT_ALT_RENDERER;
currentConfig.EmuOpt |= 0x80;
}
else if (strcasecmp(val, "8bit accurate") == 0) {
- PicoOpt &= ~0x10;
+ PicoOpt &= ~POPT_ALT_RENDERER;
currentConfig.EmuOpt &= ~0x80;
}
else
PsndRate = 22050;
while (*tmp == ' ') tmp++;
if (strcasecmp(tmp, "stereo") == 0) {
- PicoOpt |= 8;
+ PicoOpt |= POPT_EN_STEREO;
} else if (strcasecmp(tmp, "mono") == 0) {
- PicoOpt &= ~8;
+ PicoOpt &= ~POPT_EN_STEREO;
} else
return 0;
return 1;
static char id_string[3+0x11+0x11+0x30+16];\r
int pos, swab = 1;\r
\r
- if (PicoMCD & 1) {\r
+ if (PicoAHW & PAHW_MCD) {\r
strcpy(id_string, "CD|");\r
swab = 0;\r
}\r
get_ext(romFileName, ext);\r
}\r
\r
- if ((PicoMCD & 1) && Pico_mcd != NULL)\r
+ if ((PicoAHW & PAHW_MCD) && Pico_mcd != NULL)\r
Stop_CD();\r
\r
// check for MegaCD image\r
cd_state = emu_cdCheck(&cd_region);\r
if (cd_state > 0)\r
{\r
- PicoMCD |= 1;\r
+ PicoAHW |= PAHW_MCD;\r
// valid CD image, check for BIOS..\r
\r
// we need to have config loaded at this point\r
}\r
if (!emu_findBios(cd_region, &used_rom_name)) {\r
// bios_help() ?\r
- PicoMCD &= ~1;\r
+ PicoAHW &= ~PAHW_MCD;\r
return 0;\r
}\r
\r
}\r
else\r
{\r
- if (PicoMCD & 1) Stop_CD();\r
- PicoMCD &= ~1;\r
+ if (PicoAHW & PAHW_MCD) Stop_CD();\r
+ PicoAHW &= ~PAHW_MCD;\r
}\r
\r
rom = pm_open(used_rom_name);\r
}\r
\r
// load config for this ROM (do this before insert to get correct region)\r
- if (!(PicoMCD&1))\r
+ if (!(PicoAHW & PAHW_MCD))\r
memcpy(id_header, rom_data + 0x100, sizeof(id_header));\r
if (!cfg_loaded) {\r
ret = emu_ReadConfig(1, 1);\r
// additional movie stuff\r
if (movie_data) {\r
if(movie_data[0x14] == '6')\r
- PicoOpt |= 0x20; // 6 button pad\r
- else PicoOpt &= ~0x20;\r
- PicoOpt |= 0x10040; // accurate timing, no VDP fifo timing\r
+ PicoOpt |= POPT_6BTN_PAD; // 6 button pad\r
+ else PicoOpt &= ~POPT_6BTN_PAD;\r
+ PicoOpt |= POPT_DIS_VDP_FIFO|POPT_ACC_TIMING; // accurate timing, no VDP fifo timing\r
if(movie_data[0xF] >= 'A') {\r
if(movie_data[0x16] & 0x80) {\r
PicoRegionOverride = 8;\r
}\r
else\r
{\r
- PicoOpt &= ~0x10000;\r
+ PicoOpt &= ~POPT_DIS_VDP_FIFO;\r
if(Pico.m.pal) {\r
strcpy(noticeMsg, "PAL SYSTEM / 50 FPS");\r
} else {\r
\r
if (is_sram)\r
{\r
- romfname_ext(saveFname, (PicoMCD&1) ? "brm/" : "srm/", (PicoMCD&1) ? ".brm" : ".srm");\r
+ romfname_ext(saveFname, (PicoAHW&1) ? "brm/" : "srm/", (PicoAHW&1) ? ".brm" : ".srm");\r
if (load) {\r
if (try_ropen_file(saveFname)) return saveFname;\r
// try in current dir..\r
- romfname_ext(saveFname, NULL, (PicoMCD&1) ? ".brm" : ".srm");\r
+ romfname_ext(saveFname, NULL, (PicoAHW & PAHW_MCD) ? ".brm" : ".srm");\r
if (try_ropen_file(saveFname)) return saveFname;\r
return NULL; // give up\r
}\r
int sram_size;\r
unsigned char *sram_data;\r
int truncate = 1;\r
- if (PicoMCD&1) {\r
- if (PicoOpt&0x8000) { // MCD RAM cart?\r
+ if (PicoAHW & PAHW_MCD)\r
+ {\r
+ if (PicoOpt&POPT_EN_MCD_RAMCART) {\r
sram_size = 0x12000;\r
sram_data = SRam.data;\r
if (sram_data)\r
}\r
if (!sram_data) return 0; // SRam forcefully disabled for this game\r
\r
- if (load) {\r
+ if (load)\r
+ {\r
sramFile = fopen(saveFname, "rb");\r
if(!sramFile) return -1;\r
fread(sram_data, 1, sram_size, sramFile);\r
fclose(sramFile);\r
- if ((PicoMCD&1) && (PicoOpt&0x8000))\r
+ if ((PicoAHW & PAHW_MCD) && (PicoOpt&POPT_EN_MCD_RAMCART))\r
memcpy32((int *)Pico_mcd->bram, (int *)sram_data, 0x2000/4);\r
} else {\r
// sram save needs some special processing\r
mp3_current_file = NULL;
mp3_buffer_offs = 0;
- if (!(PicoOpt&0x800) || f == NULL) // cdda disabled or no file?
+ if (!(PicoOpt&POPT_EN_MCD_CDDA) || f == NULL) // cdda disabled or no file?
return;
//lprintf("mp3_start_play %p %i\n", f, pos);
unsigned int offs1024 = 0;
int cdda_on;
- cdda_on = (PicoMCD & 1) && (PicoOpt&0x800) && !(Pico_mcd->s68k_regs[0x36] & 1) &&
+ cdda_on = (PicoAHW & PAHW_MCD) && (PicoOpt&POPT_EN_MCD_CDDA) && !(Pico_mcd->s68k_regs[0x36] & 1) &&
(Pico_mcd->scd.Status_CDC & 1) && mp3_current_file != NULL;
if (cdda_on) {
}
-static int EmuScan16(unsigned int num, void *sdata)
+static int EmuScanBegin16(unsigned int num)
{
if (!(Pico.video.reg[1]&8)) num += 8;
- DrawLineDest = (unsigned short *) giz_screen + 321*(num+1);
+ DrawLineDest = (unsigned short *) giz_screen + 321 * num;
if ((currentConfig.EmuOpt&0x4000) && (num&1) == 0) // (Pico.m.frame_count&1))
return 1; // skip next line
return 0;
}
-static int EmuScan8(unsigned int num, void *sdata)
+static int EmuScanBegin8(unsigned int num)
{
// draw like the fast renderer
if (!(Pico.video.reg[1]&8)) num += 8;
- HighCol = gfx_buffer + 328*(num+1);
+ HighCol = gfx_buffer + 328 * num;
return 0;
}
if (emu_opt & 2) osd_text(OSD_FPS_X, h, fps);
}
- if ((emu_opt & 0x400) && (PicoMCD & 1))
+ if ((emu_opt & 0x400) && (PicoAHW & PAHW_MCD))
cd_leds();
}
if (PicoOpt&0x10) {
} else if (currentConfig.EmuOpt&0x80) {
PicoDrawSetColorFormat(1);
- PicoScan = EmuScan16;
+ PicoScanBegin = EmuScanBegin16;
} else {
PicoDrawSetColorFormat(-1);
- PicoScan = EmuScan8;
+ PicoScanBegin = EmuScanBegin8;
}
if ((PicoOpt&0x10) || !(currentConfig.EmuOpt&0x80)) {
// setup pal for 8-bit modes
giz_screen = Framework2D_LockBuffer(1);
PicoDrawSetColorFormat(1);
- PicoScan = EmuScan16;
- PicoScan((unsigned) -1, NULL);
+ PicoScanBegin = EmuScanBegin16;
Pico.m.dirtyPal = 1;
PicoFrameDrawOnly();
reset_timing = 1;
// prepare CD buffer
- if (PicoMCD & 1) PicoCDBufferInit();
+ if (PicoAHW & PAHW_MCD) PicoCDBufferInit();
// prepare sound stuff
PsndOut = NULL;
/* be sure correct framebuffer is locked */
giz_screen = Framework2D_LockBuffer((currentConfig.EmuOpt&0x8000) ? 0 : 1);
- if (!(PicoOpt&0x10))
- PicoScan((unsigned) -1, NULL);
-
PicoFrame();
if (giz_screen == NULL)
}
- if (PicoMCD & 1) PicoCDBufferFree();
+ if (PicoAHW & PAHW_MCD) PicoCDBufferFree();
if (PsndOut != NULL) {
PsndOut = snd_cbuff = NULL;
}\r
\r
if (file) {\r
- if (PicoMCD & 1) {\r
+ if (PicoAHW & 1) {\r
PicoCdLoadStateGfx(file);\r
} else {\r
areaSeek(file, 0x10020, SEEK_SET); // skip header and RAM in state file\r
currentConfig.PsndRate = 11025;\r
currentConfig.PicoOpt |= 8;\r
} else if ((inp & BTN_LEFT) && currentConfig.PsndRate == 11025 &&\r
- (currentConfig.PicoOpt&0x08) && !(PicoMCD&1))\r
+ (currentConfig.PicoOpt&0x08) && !(PicoAHW&1))\r
{\r
currentConfig.PsndRate = 44100;\r
currentConfig.PicoOpt &= ~8;\r
unsigned int offs1024 = 0;\r
int cdda_on;\r
\r
- cdda_on = (PicoMCD & 1) && (PicoOpt&0x800) && !(Pico_mcd->s68k_regs[0x36] & 1) &&\r
+ cdda_on = (PicoAHW & PAHW_MCD) && (PicoOpt&0x800) && !(Pico_mcd->s68k_regs[0x36] & 1) &&\r
(Pico_mcd->scd.Status_CDC & 1) && loaded_mp3;\r
\r
if (cdda_on) {\r
}\r
}\r
\r
-static int EmuScan16(unsigned int num, void *sdata)\r
+static int EmuScanBegin16(unsigned int num)\r
{\r
if (!(Pico.video.reg[1]&8)) num += 8;\r
- DrawLineDest = (unsigned short *) gp2x_screen + 320*(num+1);\r
+ DrawLineDest = (unsigned short *) gp2x_screen + 320 * num;\r
\r
return 0;\r
}\r
\r
-static int EmuScan8(unsigned int num, void *sdata)\r
+static int EmuScanBegin8(unsigned int num)\r
{\r
if (!(Pico.video.reg[1]&8)) num += 8;\r
- DrawLineDest = (unsigned char *) gp2x_screen + 320*(num+1);\r
+ DrawLineDest = (unsigned char *) gp2x_screen + 320 * num;\r
\r
return 0;\r
}\r
else if (!(emu_opt&0x80))\r
{\r
// 8bit accurate renderer\r
- if (Pico.m.dirtyPal) {\r
+ if (Pico.m.dirtyPal)\r
+ {\r
Pico.m.dirtyPal = 0;\r
if(Pico.video.reg[0xC]&8) { // shadow/hilight mode\r
vidConvCpyRGB32(localPal, Pico.cram, 0x40);\r
localPal[0xe0] = 0x00000000; // reserved pixels for OSD\r
localPal[0xf0] = 0x00ffffff;\r
gp2x_video_setpalette(localPal, 0x100);\r
- } else if (rendstatus & 0x20) { // mid-frame palette changes\r
+ } else if (rendstatus & PDRAW_SONIC_MODE) { // mid-frame palette changes\r
vidConvCpyRGB32(localPal, Pico.cram, 0x40);\r
vidConvCpyRGB32(localPal+0x40, HighPal, 0x40);\r
vidConvCpyRGB32(localPal+0x80, HighPal+0x40, 0x40);\r
if (emu_opt & 2)\r
osd_text(osd_fps_x, h, fps);\r
}\r
- if ((emu_opt & 0x400) && (PicoMCD & 1))\r
+ if ((emu_opt & 0x400) && (PicoAHW & PAHW_MCD))\r
cd_leds();\r
\r
//gp2x_video_wait_vsync();\r
} else if (currentConfig.EmuOpt&0x80) {\r
gp2x_video_changemode(16);\r
PicoDrawSetColorFormat(1);\r
- PicoScan = EmuScan16;\r
- PicoScan(0, 0);\r
+ PicoScanBegin = EmuScanBegin16;\r
} else {\r
gp2x_video_changemode(8);\r
PicoDrawSetColorFormat(2);\r
- PicoScan = EmuScan8;\r
- PicoScan(0, 0);\r
+ PicoScanBegin = EmuScanBegin8;\r
}\r
if ((PicoOpt&0x10)||!(currentConfig.EmuOpt&0x80)) {\r
// setup pal for 8-bit modes\r
\r
//vidResetMode();\r
PicoDrawSetColorFormat(1);\r
- PicoScan = EmuScan16;\r
- PicoScan(0, 0);\r
+ PicoScanBegin = EmuScanBegin16;\r
Pico.m.dirtyPal = 1;\r
PicoFrameDrawOnly();\r
\r
}\r
\r
// prepare CD buffer\r
- if (PicoMCD & 1) PicoCDBufferInit();\r
+ if (PicoAHW & PAHW_MCD) PicoCDBufferInit();\r
\r
// calc vsync offset to sync timing code with vsync\r
if (currentConfig.EmuOpt&0x2000) {\r
\r
change_fast_forward(0);\r
\r
- if (PicoMCD & 1) PicoCDBufferFree();\r
+ if (PicoAHW & PAHW_MCD) PicoCDBufferFree();\r
\r
// save SRAM\r
if((currentConfig.EmuOpt & 1) && SRam.changed) {\r
}\r
\r
if (file) {\r
- if (PicoMCD & 1) {\r
+ if (PicoAHW & PAHW_MCD) {\r
PicoCdLoadStateGfx(file);\r
} else {\r
areaSeek(file, 0x10020, SEEK_SET); // skip header and RAM in state file\r
{\r
int menu_sel = 3, menu_sel_max = 3;\r
unsigned long inp = 0;\r
- int is_6button = PicoOpt & 0x020;\r
+ int is_6button = PicoOpt & POPT_6BTN_PAD;\r
\r
while (1)\r
{\r
switch (entry->id)\r
{\r
case MA_OPT_RENDERER:\r
- if (PicoOpt&0x10)\r
+ if (PicoOpt & POPT_ALT_RENDERER)\r
str = " 8bit fast";\r
else if (currentConfig.EmuOpt&0x80)\r
str = "16bit accurate";\r
text_out16(x, y, "Frameskip %s", str24);\r
break;\r
case MA_OPT_SOUND_QUALITY:\r
- str = (PicoOpt&0x08)?"stereo":"mono";\r
+ str = (PicoOpt & POPT_EN_STEREO) ? "stereo" : "mono";\r
text_out16(x, y, "Sound Quality: %5iHz %s", PsndRate, str);\r
break;\r
case MA_OPT_REGION:\r
// force setting possibly changed..\r
Pico.m.pal = (PicoRegionOverride == 2 || PicoRegionOverride == 8) ? 1 : 0;\r
}\r
- if (!(PicoOpt & 0x20)) {\r
+ if (!(PicoOpt & POPT_6BTN_PAD)) {\r
// unbind XYZ MODE, just in case\r
unbind_action(0xf00, -1, -1);\r
}\r
+++ /dev/null
-// 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.
-
-
-#include "../../Pico/PicoInt.h"
-#undef blockcpy
-
-extern unsigned short DefOutBuff[320*2];
-extern unsigned char HighCol[8+320+8];
-extern 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, all window tiles don't use same priority, accurate sprites (copied from PicoOpt), interlace
-// dirty sprites, sonic mode
-extern int rendstatus;
-extern int Scanline; // Scanline
-
-
-struct TileStrip
-{
- int nametab; // Position in VRAM of name table (for this tile line)
- int line; // Line number in pixels 0x000-0x3ff within the virtual tilemap
- int hscroll; // Horizontal scroll value in pixels for the line
- int xmask; // X-Mask (0x1f - 0x7f) for horizontal wraparound in the tilemap
- int *hc; // cache for high tile codes and their positions
- int cells; // cells (tiles) to draw (32 col mode doesn't need to update whole 320)
-};
-
-// utility
-void *blockcpy(void *dst, const void *src, size_t n)
-{
- return memcpy(dst, src, n);
-}
-
-void blockcpy_or(void *dst, void *src, size_t n, int pat)
-{
- unsigned char *pd = dst, *ps = src;
- for (; n; n--)
- *pd++ = (unsigned char) (*ps++ | pat);
-}
-
-
-static int TileNorm(int sx,int addr,int pal)
-{
- unsigned char *pd = HighCol+sx;
- unsigned int pack=0; unsigned int t=0;
-
- pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
- if (pack)
- {
- t=pack&0x0000f000; if (t) pd[0]=(unsigned char)(pal|(t>>12));
- t=pack&0x00000f00; if (t) pd[1]=(unsigned char)(pal|(t>> 8));
- t=pack&0x000000f0; if (t) pd[2]=(unsigned char)(pal|(t>> 4));
- t=pack&0x0000000f; if (t) pd[3]=(unsigned char)(pal|(t ));
- t=pack&0xf0000000; if (t) pd[4]=(unsigned char)(pal|(t>>28));
- t=pack&0x0f000000; if (t) pd[5]=(unsigned char)(pal|(t>>24));
- t=pack&0x00f00000; if (t) pd[6]=(unsigned char)(pal|(t>>20));
- t=pack&0x000f0000; if (t) pd[7]=(unsigned char)(pal|(t>>16));
- return 0;
- }
-
- return 1; // Tile blank
-}
-
-static int TileFlip(int sx,int addr,int pal)
-{
- unsigned char *pd = HighCol+sx;
- unsigned int pack=0; unsigned int t=0;
-
- pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
- if (pack)
- {
- t=pack&0x000f0000; if (t) pd[0]=(unsigned char)(pal|(t>>16));
- t=pack&0x00f00000; if (t) pd[1]=(unsigned char)(pal|(t>>20));
- t=pack&0x0f000000; if (t) pd[2]=(unsigned char)(pal|(t>>24));
- t=pack&0xf0000000; if (t) pd[3]=(unsigned char)(pal|(t>>28));
- t=pack&0x0000000f; if (t) pd[4]=(unsigned char)(pal|(t ));
- t=pack&0x000000f0; if (t) pd[5]=(unsigned char)(pal|(t>> 4));
- t=pack&0x00000f00; if (t) pd[6]=(unsigned char)(pal|(t>> 8));
- t=pack&0x0000f000; if (t) pd[7]=(unsigned char)(pal|(t>>12));
- return 0;
- }
- return 1; // Tile blank
-}
-
-
-// tile renderers for hacky operator sprite support
-#define sh_pix(x) \
- if(!t); \
- else if(t==0xe) pd[x]=(unsigned char)((pd[x]&0x3f)|0x80); /* hilight */ \
- else if(t==0xf) pd[x]=(unsigned char)((pd[x]&0x3f)|0xc0); /* shadow */ \
- else pd[x]=(unsigned char)(pal|t);
-
-static int TileNormSH(int sx,int addr,int pal)
-{
- unsigned int pack=0; unsigned int t=0;
- unsigned char *pd = HighCol+sx;
-
- pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
- if (pack)
- {
- t=(pack&0x0000f000)>>12; sh_pix(0);
- t=(pack&0x00000f00)>> 8; sh_pix(1);
- t=(pack&0x000000f0)>> 4; sh_pix(2);
- t=(pack&0x0000000f) ; sh_pix(3);
- t=(pack&0xf0000000)>>28; sh_pix(4);
- t=(pack&0x0f000000)>>24; sh_pix(5);
- t=(pack&0x00f00000)>>20; sh_pix(6);
- t=(pack&0x000f0000)>>16; sh_pix(7);
- return 0;
- }
-
- return 1; // Tile blank
-}
-
-static int TileFlipSH(int sx,int addr,int pal)
-{
- unsigned int pack=0; unsigned int t=0;
- unsigned char *pd = HighCol+sx;
-
- pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
- if (pack)
- {
- t=(pack&0x000f0000)>>16; sh_pix(0);
- t=(pack&0x00f00000)>>20; sh_pix(1);
- t=(pack&0x0f000000)>>24; sh_pix(2);
- t=(pack&0xf0000000)>>28; sh_pix(3);
- t=(pack&0x0000000f) ; sh_pix(4);
- t=(pack&0x000000f0)>> 4; sh_pix(5);
- t=(pack&0x00000f00)>> 8; sh_pix(6);
- t=(pack&0x0000f000)>>12; sh_pix(7);
- return 0;
- }
- return 1; // Tile blank
-}
-
-
-// --------------------------------------------
-
-static void DrawStrip(struct TileStrip *ts, int sh)
-{
- int tilex=0,dx=0,ty=0,code=0,addr=0,cells;
- int oldcode=-1,blank=-1; // The tile we know is blank
- int pal=0;
-
- // Draw tiles across screen:
- tilex=(-ts->hscroll)>>3;
- ty=(ts->line&7)<<1; // Y-Offset into tile
- dx=((ts->hscroll-1)&7)+1;
- cells = ts->cells;
- if(dx != 8) cells++; // have hscroll, need to draw 1 cell more
-
- for (; cells; dx+=8,tilex++,cells--)
- {
- int zero=0;
-
- code=Pico.vram[ts->nametab+(tilex&ts->xmask)];
- if (code==blank) continue;
- if (code>>15) { // high priority tile
- int cval = code | (dx<<16) | (ty<<25);
- if(code&0x1000) cval^=7<<26;
- *ts->hc++ = cval; // cache it
- continue;
- }
-continue;
- if (code!=oldcode) {
- oldcode = code;
- // Get tile address/2:
- addr=(code&0x7ff)<<4;
- addr+=ty;
- if (code&0x1000) addr^=0xe; // Y-flip
-
-// pal=Pico.cram+((code>>9)&0x30);
- pal=((code>>9)&0x30)|(sh<<6);
- }
-
- if (code&0x0800) zero=TileFlip(dx,addr,pal);
- else zero=TileNorm(dx,addr,pal);
-
- if (zero) blank=code; // We know this tile is blank now
- }
-
- // terminate the cache list
- *ts->hc = 0;
-}
-
-static void DrawStripVSRam(struct TileStrip *ts, int plane)
-{
- int tilex=0,dx=0,ty=0,code=0,addr=0,cell=0,nametabadd=0;
- int oldcode=-1,blank=-1; // The tile we know is blank
- int pal=0,scan=Scanline;
-
- // Draw tiles across screen:
- tilex=(-ts->hscroll)>>3;
- dx=((ts->hscroll-1)&7)+1;
- if(dx != 8) {
- int vscroll, line;
- cell--; // have hscroll, start with negative cell
- // also calculate intial VS stuff
- vscroll=Pico.vsram[plane];
-
- // Find the line in the name table
- line=(vscroll+scan)&ts->line&0xffff; // ts->line is really ymask ..
- nametabadd=(line>>3)<<(ts->line>>24); // .. and shift[width]
- ty=(line&7)<<1; // Y-Offset into tile
- }
-
- for (; cell < ts->cells; dx+=8,tilex++,cell++)
- {
- int zero=0;
-
- if((cell&1)==0) {
- int line,vscroll;
- vscroll=Pico.vsram[plane+(cell&~1)];
-
- // Find the line in the name table
- line=(vscroll+scan)&ts->line&0xffff; // ts->line is really ymask ..
- nametabadd=(line>>3)<<(ts->line>>24); // .. and shift[width]
- ty=(line&7)<<1; // Y-Offset into tile
- }
-
- code=Pico.vram[ts->nametab+nametabadd+(tilex&ts->xmask)];
- if (code==blank) continue;
- if (code>>15) { // high priority tile
- int cval = code | (dx<<16) | (ty<<25);
- if(code&0x1000) cval^=7<<26;
- *ts->hc++ = cval; // cache it
- continue;
- }
-
- if (code!=oldcode) {
- oldcode = code;
- // Get tile address/2:
- addr=(code&0x7ff)<<4;
- if (code&0x1000) addr+=14-ty; else addr+=ty; // Y-flip
-
-// pal=Pico.cram+((code>>9)&0x30);
- pal=((code>>9)&0x30);
- }
-
- if (code&0x0800) zero=TileFlip(dx,addr,pal);
- else zero=TileNorm(dx,addr,pal);
-
- if (zero) blank=code; // We know this tile is blank now
- }
-
- // terminate the cache list
- *ts->hc = 0;
-}
-
-static void DrawStripInterlace(struct TileStrip *ts)
-{
- int tilex=0,dx=0,ty=0,code=0,addr=0,cells;
- int oldcode=-1,blank=-1; // The tile we know is blank
- int pal=0;
-
- // Draw tiles across screen:
- tilex=(-ts->hscroll)>>3;
- ty=(ts->line&15)<<1; // Y-Offset into tile
- dx=((ts->hscroll-1)&7)+1;
- cells = ts->cells;
- if(dx != 8) cells++; // have hscroll, need to draw 1 cell more
-
- for (; cells; dx+=8,tilex++,cells--)
- {
- int zero=0;
-
- code=Pico.vram[ts->nametab+(tilex&ts->xmask)];
- if (code==blank) continue;
- if (code>>15) { // high priority tile
- int cval = (code&0xfc00) | (dx<<16) | (ty<<25);
- cval|=(code&0x3ff)<<1;
- if(code&0x1000) cval^=0xf<<26;
- *ts->hc++ = cval; // cache it
- continue;
- }
-
- if (code!=oldcode) {
- oldcode = code;
- // Get tile address/2:
- addr=(code&0x7ff)<<5;
- if (code&0x1000) addr+=30-ty; else addr+=ty; // Y-flip
-
-// pal=Pico.cram+((code>>9)&0x30);
- pal=((code>>9)&0x30);
- }
-
- if (code&0x0800) zero=TileFlip(dx,addr,pal);
- else zero=TileNorm(dx,addr,pal);
-
- if (zero) blank=code; // We know this tile is blank now
- }
-
- // terminate the cache list
- *ts->hc = 0;
-}
-
-// --------------------------------------------
-
-void DrawLayer(int plane, int *hcache, int maxcells, int sh)
-{
- struct PicoVideo *pvid=&Pico.video;
- const char shift[4]={5,6,5,7}; // 32,64 or 128 sized tilemaps (2 is invalid)
- struct TileStrip ts;
- int width, height, ymask;
- int vscroll, htab;
-
- ts.hc=hcache;
- ts.cells=maxcells;
-
- // Work out the TileStrip to draw
-
- // Work out the name table size: 32 64 or 128 tiles (0-3)
- width=pvid->reg[16];
- height=(width>>4)&3; width&=3;
-
- ts.xmask=(1<<shift[width])-1; // X Mask in tiles (0x1f-0x7f)
- ymask=(height<<8)|0xff; // Y Mask in pixels
- if(width == 1) ymask&=0x1ff;
- else if(width>1) ymask =0x0ff;
-
- // Find name table:
- if (plane==0) ts.nametab=(pvid->reg[2]&0x38)<< 9; // A
- else ts.nametab=(pvid->reg[4]&0x07)<<12; // B
-
- htab=pvid->reg[13]<<9; // Horizontal scroll table address
- if ( pvid->reg[11]&2) htab+=Scanline<<1; // Offset by line
- if ((pvid->reg[11]&1)==0) htab&=~0xf; // Offset by tile
- htab+=plane; // A or B
-
- // Get horizontal scroll value, will be masked later
- ts.hscroll=Pico.vram[htab&0x7fff];
-
- if((pvid->reg[12]&6) == 6) {
- // interlace mode 2
- vscroll=Pico.vsram[plane]; // Get vertical scroll value
-
- // Find the line in the name table
- ts.line=(vscroll+(Scanline<<1))&((ymask<<1)|1);
- ts.nametab+=(ts.line>>4)<<shift[width];
-
- DrawStripInterlace(&ts);
- } else if( pvid->reg[11]&4) {
- // shit, we have 2-cell column based vscroll
- // luckily this doesn't happen too often
- ts.line=ymask|(shift[width]<<24); // save some stuff instead of line
- DrawStripVSRam(&ts, plane);
- } else {
- vscroll=Pico.vsram[plane]; // Get vertical scroll value
-
- // Find the line in the name table
- ts.line=(vscroll+Scanline)&ymask;
- ts.nametab+=(ts.line>>3)<<shift[width];
-
- DrawStrip(&ts, sh);
- }
-}
-
-
-// --------------------------------------------
-
-// tstart & tend are tile pair numbers
-void DrawWindow(int tstart, int tend, int prio, int sh) // int *hcache
-{
- struct PicoVideo *pvid=&Pico.video;
- int tilex=0,ty=0,nametab,code=0;
- int blank=-1; // The tile we know is blank
-
- // Find name table line:
- if (pvid->reg[12]&1)
- {
- nametab=(pvid->reg[3]&0x3c)<<9; // 40-cell mode
- nametab+=(Scanline>>3)<<6;
- }
- else
- {
- nametab=(pvid->reg[3]&0x3e)<<9; // 32-cell mode
- nametab+=(Scanline>>3)<<5;
- }
-
- tilex=tstart<<1;
- tend<<=1;
-
- ty=(Scanline&7)<<1; // Y-Offset into tile
-
- if(!(rendstatus&2)) {
- // 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;
- }
-
- // Draw tiles across screen:
- for (; tilex < tend; tilex++)
- {
- int addr=0,zero=0;
- int pal;
-
- code=Pico.vram[nametab+tilex];
- if(code==blank) continue;
- if((code>>15) != prio) {
- rendstatus|=2;
- continue;
- }
-
- pal=((code>>9)&0x30);
-
- if(sh) {
- int tmp, *zb = (int *)(HighCol+8+(tilex<<3));
- if(prio) {
- tmp = *zb;
- if(!(tmp&0x00000080)) tmp&=~0x000000c0; if(!(tmp&0x00008000)) tmp&=~0x0000c000;
- if(!(tmp&0x00800000)) tmp&=~0x00c00000; if(!(tmp&0x80000000)) tmp&=~0xc0000000;
- *zb++=tmp; tmp = *zb;
- if(!(tmp&0x00000080)) tmp&=~0x000000c0; if(!(tmp&0x00008000)) tmp&=~0x0000c000;
- if(!(tmp&0x00800000)) tmp&=~0x00c00000; if(!(tmp&0x80000000)) tmp&=~0xc0000000;
- *zb++=tmp;
- } else {
- pal |= 0x40;
- }
- }
-
- // Get tile address/2:
- addr=(code&0x7ff)<<4;
- if (code&0x1000) addr+=14-ty; else addr+=ty; // Y-flip
-
- if (code&0x0800) zero=TileFlip(8+(tilex<<3),addr,pal);
- else zero=TileNorm(8+(tilex<<3),addr,pal);
-
- if (zero) blank=code; // We know this tile is blank now
- }
-
- // terminate the cache list
- //*hcache = 0;
-}
-
-// --------------------------------------------
-
-void DrawTilesFromCache(int *hc, int sh)
-{
- int code, addr, zero, dx;
- int pal;
- short blank=-1; // The tile we know is blank
-
- // *ts->hc++ = code | (dx<<16) | (ty<<25); // cache it
-
- while((code=*hc++)) {
- if(!sh && (short)code == blank) continue;
-
- // Get tile address/2:
- addr=(code&0x7ff)<<4;
- addr+=(unsigned int)code>>25; // y offset into tile
- dx=(code>>16)&0x1ff;
- if(sh) {
- unsigned char *zb = HighCol+dx;
- if(!(*zb&0x80)) *zb&=0x3f; zb++; if(!(*zb&0x80)) *zb&=0x3f; zb++;
- if(!(*zb&0x80)) *zb&=0x3f; zb++; if(!(*zb&0x80)) *zb&=0x3f; zb++;
- if(!(*zb&0x80)) *zb&=0x3f; zb++; if(!(*zb&0x80)) *zb&=0x3f; zb++;
- if(!(*zb&0x80)) *zb&=0x3f; zb++; if(!(*zb&0x80)) *zb&=0x3f; zb++;
- }
-
- pal=((code>>9)&0x30);
-
- if (code&0x0800) zero=TileFlip(dx,addr,pal);
- else zero=TileNorm(dx,addr,pal);
-
- if(zero) blank=(short)code;
- }
-}
-
-// --------------------------------------------
-
-// Index + 0 : hhhhvvvv ab--hhvv yyyyyyyy yyyyyyyy // a: offscreen h, b: offs. v, h: horiz. size
-// Index + 4 : xxxxxxxx xxxxxxxx pccvhnnn nnnnnnnn // x: x coord + 8
-
-void DrawSprite(int *sprite, int **hc, int sh)
-{
- int width=0,height=0;
- int row=0,code=0;
- int pal;
- int tile=0,delta=0;
- int sx, sy;
- int (*fTileFunc)(int sx,int addr,int pal);
-
- // parse the sprite data
- sy=sprite[0];
- code=sprite[1];
- sx=code>>16; // X
- width=sy>>28;
- height=(sy>>24)&7; // Width and height in tiles
- sy=(sy<<16)>>16; // Y
-
- row=Scanline-sy; // Row of the sprite we are on
-
- if (code&0x1000) row=(height<<3)-1-row; // Flip Y
-
- tile=code&0x7ff; // Tile number
- tile+=row>>3; // Tile number increases going down
- delta=height; // Delta to increase tile by going right
- if (code&0x0800) { tile+=delta*(width-1); delta=-delta; } // Flip X
-
- tile<<=4; tile+=(row&7)<<1; // Tile address
-
- if(code&0x8000) { // high priority - cache it
- *(*hc)++ = (tile<<16)|((code&0x0800)<<5)|((sx<<6)&0x0000ffc0)|((code>>9)&0x30)|((sprite[0]>>16)&0xf);
- } else {
- delta<<=4; // Delta of address
- pal=((code>>9)&0x30)|(sh<<6);
-
- if(sh && (code&0x6000) == 0x6000) {
- if(code&0x0800) fTileFunc=TileFlipSH;
- else fTileFunc=TileNormSH;
- } else {
- if(code&0x0800) fTileFunc=TileFlip;
- else fTileFunc=TileNorm;
- }
-
- for (; width; width--,sx+=8,tile+=delta)
- {
- if(sx<=0) continue;
- if(sx>=328) break; // Offscreen
-
- tile&=0x7fff; // Clip tile address
- fTileFunc(sx,tile,pal);
- }
- }
-}
-
-
-void DrawSpritesFromCache(int *hc, int sh)
-{
- int code, tile, sx, delta, width;
- int pal;
- int (*fTileFunc)(int sx,int addr,int pal);
-
- // *(*hc)++ = (tile<<16)|((code&0x0800)<<5)|((sx<<6)&0x0000ffc0)|((code>>9)&0x30)|((sprite[0]>>24)&0xf);
-
- while((code=*hc++)) {
- pal=(code&0x30);
- delta=code&0xf;
- width=delta>>2; delta&=3;
- width++; delta++; // Width and height in tiles
- if (code&0x10000) delta=-delta; // Flip X
- delta<<=4;
- tile=((unsigned int)code>>17)<<1;
- sx=(code<<16)>>22; // sx can be negative (start offscreen), so sign extend
-
- if(sh && pal == 0x30) { //
- if(code&0x10000) fTileFunc=TileFlipSH;
- else fTileFunc=TileNormSH;
- } else {
- if(code&0x10000) fTileFunc=TileFlip;
- else fTileFunc=TileNorm;
- }
-
- for (; width; width--,sx+=8,tile+=delta)
- {
- if(sx<=0) continue;
- if(sx>=328) break; // Offscreen
-
- tile&=0x7fff; // Clip tile address
- fTileFunc(sx,tile,pal);
- }
- }
-}
-
-
-void BackFill(int reg7, int sh)
-{
- unsigned int back=0;
- unsigned int *pd=NULL,*end=NULL;
-
- // Start with a blank scanline (background colour):
- back=reg7&0x3f;
- back|=sh<<6;
- back|=back<<8;
- back|=back<<16;
-
- pd= (unsigned int *)(HighCol+8);
- end=(unsigned int *)(HighCol+8+320);
-
- do { pd[0]=pd[1]=pd[2]=pd[3]=back; pd+=4; } while (pd<end);
-}
-
-// --------------------------------------------
-
-extern unsigned short HighPal[0x100];
-
-void FinalizeLineBGR444(int sh)
-{
- unsigned short *pd=DrawLineDest;
- unsigned char *ps=HighCol+8;
- unsigned short *pal=Pico.cram;
- int len, i, t;
-
- if (Pico.video.reg[12]&1) {
- len = 320;
- } else {
- if(!(PicoOpt&0x100)) pd+=32;
- len = 256;
- }
-
- if(sh) {
- pal=HighPal;
- if(Pico.m.dirtyPal) {
- blockcpy(pal, Pico.cram, 0x40*2);
- // shadowed pixels
- for(i = 0x3f; i >= 0; i--)
- pal[0x40|i] = pal[0xc0|i] = (unsigned short)((pal[i]>>1)&0x0777);
- // hilighted pixels
- for(i = 0x3f; i >= 0; i--) {
- t=pal[i]&0xeee;t+=0x444;if(t&0x10)t|=0xe;if(t&0x100)t|=0xe0;if(t&0x1000)t|=0xe00;t&=0xeee;
- pal[0x80|i]=(unsigned short)t;
- }
- Pico.m.dirtyPal = 0;
- }
- }
-
- for(i = 0; i < len; i++)
- pd[i] = pal[ps[i]];
-}
-
-
-void FinalizeLineRGB555(int sh)
-{
- unsigned short *pd=DrawLineDest;
- unsigned char *ps=HighCol+8;
- unsigned short *pal=HighPal;
- int len, i, t, dirtyPal = Pico.m.dirtyPal;
-
- if(dirtyPal) {
- unsigned short *ppal=Pico.cram;
- for(i = 0x3f; i >= 0; i--)
- pal[i] = (unsigned short) (((ppal[i]&0x00f)<<12)|((ppal[i]&0x0f0)<<3)|((ppal[i]&0xf00)>>7));
- Pico.m.dirtyPal = 0;
- }
-
- if (Pico.video.reg[12]&1) {
- len = 320;
- } else {
- if(!(PicoOpt&0x100)) pd+=32;
- len = 256;
- }
-
- if(sh) {
- if(dirtyPal) {
- // shadowed pixels
- for(i = 0x3f; i >= 0; i--)
- pal[0x40|i] = pal[0xc0|i] = (unsigned short)((pal[i]>>1)&0x738e);
- // hilighted pixels
- for(i = 0x3f; i >= 0; i--) {
- t=pal[i]&0xe71c;t+=0x4208;if(t&0x20)t|=0x1c;if(t&0x800)t|=0x700;if(t&0x10000)t|=0xe000;t&=0xe71c;
- pal[0x80|i]=(unsigned short)t;
- }
- }
- }
-
- for(i = 0; i < len; i++)
- pd[i] = pal[ps[i]];
-}
-
-
-
do_pal_update(1);
}
-static int EmuScanSlow(unsigned int num, void *sdata)
+static int EmuScanSlow(unsigned int num)
{
if (!(Pico.video.reg[1]&8)) num += 8;
//dbg_text();
- if ((emu_opt & 0x400) && (PicoMCD & 1))
+ if ((emu_opt & 0x400) && (PicoAHW & PAHW_MCD))
cd_leds();
if (currentConfig.EmuOpt & 0x2000) { // want vsync
// slow rend.
PicoDrawSetColorFormat(-1);
- PicoScan = EmuScanSlow;
+ PicoScanEnd = EmuScanSlow;
localPal[0xe0] = 0;
Pico.m.dirtyPal = 1;
memset32_uncached((int *)psp_screen + 512*264*2/4, 0, 512*8*2/4);
PicoDrawSetColorFormat(-1);
- PicoScan = EmuScanSlow;
+ PicoScanEnd = EmuScanSlow;
EmuScanPrepare();
PicoFrameDrawOnly();
blit1();
target_frametime = Pico.m.pal ? (1000000<<8)/50 : (1000000<<8)/60+1;
reset_timing = 1;
- if (PicoMCD & 1) {
+ if (PicoAHW & PAHW_MCD) {
// prepare CD buffer
PicoCDBufferInit();
// mp3...
}
- if (PicoMCD & 1) PicoCDBufferFree();
+ if (PicoAHW & PAHW_MCD) PicoCDBufferFree();
if (PsndOut != NULL) {
PsndOut = NULL;
void emu_HandleResume(void)
{
- if (!(PicoMCD & 1)) return;
+ if (!(PicoAHW & PAHW_MCD)) return;
// reopen files..
if (Pico_mcd->TOC.Tracks[0].F != NULL)
}
if (file) {
- if (PicoMCD & 1) {
+ if (PicoAHW & PAHW_MCD) {
PicoCdLoadStateGfx(file);
} else {
areaSeek(file, 0x10020, SEEK_SET); // skip header and RAM in state file
unsigned int offs1024 = 0;
int cdda_on;
- cdda_on = (PicoMCD & 1) && (PicoOpt&0x800) && !(Pico_mcd->s68k_regs[0x36] & 1) &&
+ cdda_on = (PicoAHW & PAHW_MCD) && (PicoOpt&0x800) && !(Pico_mcd->s68k_regs[0x36] & 1) &&
(Pico_mcd->scd.Status_CDC & 1) && mp3_handle >= 0;
if (cdda_on) {