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:
notaz 2008-04-03 20:17:29 +00:00
parent 95dc5c5e5e
commit 602133e1c6
27 changed files with 359 additions and 945 deletions

View file

@ -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) {

View file

@ -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();

View file

@ -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,12 +609,10 @@ 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|=0x80;
rendstatus |= PDRAW_SHHI_DONE;
while (c--)
{
int tmp = *zb;
@ -625,7 +624,6 @@ static void DrawTilesFromCacheShPrep(void)
}
zb++;
}
}
}
static void DrawTilesFromCache(int *hc, int sh, int rlim)
@ -635,8 +633,9 @@ 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)))
{
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;
}

View file

@ -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;

View file

@ -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]++;
}

View file

@ -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();

View file

@ -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

View file

@ -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:

View file

@ -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

View file

@ -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,30 +369,48 @@ 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,
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);
if (num==01) elprintf(EL_INTSW, "vint_onoff: %i->%i [%i] pend=%i @ %06x", (dold&0x20)>>5,
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 (num == 5 && (d^dold)) rendstatus|=1;
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
else if (num == 0xc && ((d^dold)&8)) Pico.m.dirtyPal = 2;
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
{
int lines, pints, irq=0;
@ -401,10 +422,10 @@ PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d)
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,7 +452,7 @@ 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 (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)

View file

@ -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;
}

View file

@ -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])

View file

@ -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();

View file

@ -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

View file

@ -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

View file

@ -70,9 +70,9 @@ static void custom_write(FILE *f, const menu_entry *me, int no_def)
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";
@ -99,9 +99,9 @@ static void custom_write(FILE *f, const menu_entry *me, int no_def)
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:
@ -438,14 +438,14 @@ static int custom_read(menu_entry *me, const char *var, const char *val)
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
@ -480,9 +480,9 @@ static int custom_read(menu_entry *me, const char *var, const char *val)
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;

View file

@ -235,7 +235,7 @@ char *emu_makeRomId(void)
static char id_string[3+0x11+0x11+0x30+16];
int pos, swab = 1;
if (PicoMCD & 1) {
if (PicoAHW & PAHW_MCD) {
strcpy(id_string, "CD|");
swab = 0;
}
@ -325,14 +325,14 @@ int emu_ReloadRom(void)
get_ext(romFileName, ext);
}
if ((PicoMCD & 1) && Pico_mcd != NULL)
if ((PicoAHW & PAHW_MCD) && Pico_mcd != NULL)
Stop_CD();
// check for MegaCD image
cd_state = emu_cdCheck(&cd_region);
if (cd_state > 0)
{
PicoMCD |= 1;
PicoAHW |= PAHW_MCD;
// valid CD image, check for BIOS..
// we need to have config loaded at this point
@ -346,7 +346,7 @@ int emu_ReloadRom(void)
}
if (!emu_findBios(cd_region, &used_rom_name)) {
// bios_help() ?
PicoMCD &= ~1;
PicoAHW &= ~PAHW_MCD;
return 0;
}
@ -354,8 +354,8 @@ int emu_ReloadRom(void)
}
else
{
if (PicoMCD & 1) Stop_CD();
PicoMCD &= ~1;
if (PicoAHW & PAHW_MCD) Stop_CD();
PicoAHW &= ~PAHW_MCD;
}
rom = pm_open(used_rom_name);
@ -388,7 +388,7 @@ int emu_ReloadRom(void)
}
// load config for this ROM (do this before insert to get correct region)
if (!(PicoMCD&1))
if (!(PicoAHW & PAHW_MCD))
memcpy(id_header, rom_data + 0x100, sizeof(id_header));
if (!cfg_loaded) {
ret = emu_ReadConfig(1, 1);
@ -425,9 +425,9 @@ int emu_ReloadRom(void)
// additional movie stuff
if (movie_data) {
if(movie_data[0x14] == '6')
PicoOpt |= 0x20; // 6 button pad
else PicoOpt &= ~0x20;
PicoOpt |= 0x10040; // accurate timing, no VDP fifo timing
PicoOpt |= POPT_6BTN_PAD; // 6 button pad
else PicoOpt &= ~POPT_6BTN_PAD;
PicoOpt |= POPT_DIS_VDP_FIFO|POPT_ACC_TIMING; // accurate timing, no VDP fifo timing
if(movie_data[0xF] >= 'A') {
if(movie_data[0x16] & 0x80) {
PicoRegionOverride = 8;
@ -442,7 +442,7 @@ int emu_ReloadRom(void)
}
else
{
PicoOpt &= ~0x10000;
PicoOpt &= ~POPT_DIS_VDP_FIFO;
if(Pico.m.pal) {
strcpy(noticeMsg, "PAL SYSTEM / 50 FPS");
} else {
@ -773,11 +773,11 @@ char *emu_GetSaveFName(int load, int is_sram, int slot)
if (is_sram)
{
romfname_ext(saveFname, (PicoMCD&1) ? "brm/" : "srm/", (PicoMCD&1) ? ".brm" : ".srm");
romfname_ext(saveFname, (PicoAHW&1) ? "brm/" : "srm/", (PicoAHW&1) ? ".brm" : ".srm");
if (load) {
if (try_ropen_file(saveFname)) return saveFname;
// try in current dir..
romfname_ext(saveFname, NULL, (PicoMCD&1) ? ".brm" : ".srm");
romfname_ext(saveFname, NULL, (PicoAHW & PAHW_MCD) ? ".brm" : ".srm");
if (try_ropen_file(saveFname)) return saveFname;
return NULL; // give up
}
@ -855,8 +855,9 @@ int emu_SaveLoadGame(int load, int sram)
int sram_size;
unsigned char *sram_data;
int truncate = 1;
if (PicoMCD&1) {
if (PicoOpt&0x8000) { // MCD RAM cart?
if (PicoAHW & PAHW_MCD)
{
if (PicoOpt&POPT_EN_MCD_RAMCART) {
sram_size = 0x12000;
sram_data = SRam.data;
if (sram_data)
@ -873,12 +874,13 @@ int emu_SaveLoadGame(int load, int sram)
}
if (!sram_data) return 0; // SRam forcefully disabled for this game
if (load) {
if (load)
{
sramFile = fopen(saveFname, "rb");
if(!sramFile) return -1;
fread(sram_data, 1, sram_size, sramFile);
fclose(sramFile);
if ((PicoMCD&1) && (PicoOpt&0x8000))
if ((PicoAHW & PAHW_MCD) && (PicoOpt&POPT_EN_MCD_RAMCART))
memcpy32((int *)Pico_mcd->bram, (int *)sram_data, 0x2000/4);
} else {
// sram save needs some special processing

View file

@ -180,7 +180,7 @@ void mp3_start_play(FILE *f, int pos)
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);
@ -204,7 +204,7 @@ int mp3_get_offset(void)
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) {

View file

@ -143,10 +143,10 @@ void emu_setDefaultConfig(void)
}
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
@ -154,11 +154,11 @@ static int EmuScan16(unsigned int num, void *sdata)
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;
}
@ -253,7 +253,7 @@ static void blit(const char *fps, const char *notice)
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();
}
@ -280,10 +280,10 @@ static void vidResetMode(void)
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
@ -356,8 +356,7 @@ void emu_forcedFrame(void)
giz_screen = Framework2D_LockBuffer(1);
PicoDrawSetColorFormat(1);
PicoScan = EmuScan16;
PicoScan((unsigned) -1, NULL);
PicoScanBegin = EmuScanBegin16;
Pico.m.dirtyPal = 1;
PicoFrameDrawOnly();
@ -546,7 +545,7 @@ void emu_Loop(void)
reset_timing = 1;
// prepare CD buffer
if (PicoMCD & 1) PicoCDBufferInit();
if (PicoAHW & PAHW_MCD) PicoCDBufferInit();
// prepare sound stuff
PsndOut = NULL;
@ -716,9 +715,6 @@ void emu_Loop(void)
/* 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)
@ -757,7 +753,7 @@ void emu_Loop(void)
}
if (PicoMCD & 1) PicoCDBufferFree();
if (PicoAHW & PAHW_MCD) PicoCDBufferFree();
if (PsndOut != NULL) {
PsndOut = snd_cbuff = NULL;

View file

@ -561,7 +561,7 @@ static void draw_savestate_bg(int slot)
}
if (file) {
if (PicoMCD & 1) {
if (PicoAHW & 1) {
PicoCdLoadStateGfx(file);
} else {
areaSeek(file, 0x10020, SEEK_SET); // skip header and RAM in state file
@ -1224,7 +1224,7 @@ static int menu_loop_options(void)
currentConfig.PsndRate = 11025;
currentConfig.PicoOpt |= 8;
} else if ((inp & BTN_LEFT) && currentConfig.PsndRate == 11025 &&
(currentConfig.PicoOpt&0x08) && !(PicoMCD&1))
(currentConfig.PicoOpt&0x08) && !(PicoAHW&1))
{
currentConfig.PsndRate = 44100;
currentConfig.PicoOpt &= ~8;

View file

@ -611,7 +611,7 @@ int mp3_get_offset(void)
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) && loaded_mp3;
if (cdda_on) {

View file

@ -225,18 +225,18 @@ static void cd_leds(void)
}
}
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 *) gp2x_screen + 320*(num+1);
DrawLineDest = (unsigned short *) gp2x_screen + 320 * num;
return 0;
}
static int EmuScan8(unsigned int num, void *sdata)
static int EmuScanBegin8(unsigned int num)
{
if (!(Pico.video.reg[1]&8)) num += 8;
DrawLineDest = (unsigned char *) gp2x_screen + 320*(num+1);
DrawLineDest = (unsigned char *) gp2x_screen + 320 * num;
return 0;
}
@ -266,7 +266,8 @@ static void blit(const char *fps, const char *notice)
else if (!(emu_opt&0x80))
{
// 8bit accurate renderer
if (Pico.m.dirtyPal) {
if (Pico.m.dirtyPal)
{
Pico.m.dirtyPal = 0;
if(Pico.video.reg[0xC]&8) { // shadow/hilight mode
vidConvCpyRGB32(localPal, Pico.cram, 0x40);
@ -278,7 +279,7 @@ static void blit(const char *fps, const char *notice)
localPal[0xe0] = 0x00000000; // reserved pixels for OSD
localPal[0xf0] = 0x00ffffff;
gp2x_video_setpalette(localPal, 0x100);
} else if (rendstatus & 0x20) { // mid-frame palette changes
} else if (rendstatus & PDRAW_SONIC_MODE) { // mid-frame palette changes
vidConvCpyRGB32(localPal, Pico.cram, 0x40);
vidConvCpyRGB32(localPal+0x40, HighPal, 0x40);
vidConvCpyRGB32(localPal+0x80, HighPal+0x40, 0x40);
@ -297,7 +298,7 @@ static void blit(const char *fps, const char *notice)
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();
//gp2x_video_wait_vsync();
@ -339,13 +340,11 @@ static void vidResetMode(void)
} else if (currentConfig.EmuOpt&0x80) {
gp2x_video_changemode(16);
PicoDrawSetColorFormat(1);
PicoScan = EmuScan16;
PicoScan(0, 0);
PicoScanBegin = EmuScanBegin16;
} else {
gp2x_video_changemode(8);
PicoDrawSetColorFormat(2);
PicoScan = EmuScan8;
PicoScan(0, 0);
PicoScanBegin = EmuScanBegin8;
}
if ((PicoOpt&0x10)||!(currentConfig.EmuOpt&0x80)) {
// setup pal for 8-bit modes
@ -625,8 +624,7 @@ void emu_forcedFrame(void)
//vidResetMode();
PicoDrawSetColorFormat(1);
PicoScan = EmuScan16;
PicoScan(0, 0);
PicoScanBegin = EmuScanBegin16;
Pico.m.dirtyPal = 1;
PicoFrameDrawOnly();
@ -782,7 +780,7 @@ void emu_Loop(void)
}
// prepare CD buffer
if (PicoMCD & 1) PicoCDBufferInit();
if (PicoAHW & PAHW_MCD) PicoCDBufferInit();
// calc vsync offset to sync timing code with vsync
if (currentConfig.EmuOpt&0x2000) {
@ -960,7 +958,7 @@ void emu_Loop(void)
change_fast_forward(0);
if (PicoMCD & 1) PicoCDBufferFree();
if (PicoAHW & PAHW_MCD) PicoCDBufferFree();
// save SRAM
if((currentConfig.EmuOpt & 1) && SRam.changed) {

View file

@ -553,7 +553,7 @@ static void draw_savestate_bg(int slot)
}
if (file) {
if (PicoMCD & 1) {
if (PicoAHW & PAHW_MCD) {
PicoCdLoadStateGfx(file);
} else {
areaSeek(file, 0x10020, SEEK_SET); // skip header and RAM in state file
@ -878,7 +878,7 @@ static void kc_sel_loop(void)
{
int menu_sel = 3, menu_sel_max = 3;
unsigned long inp = 0;
int is_6button = PicoOpt & 0x020;
int is_6button = PicoOpt & POPT_6BTN_PAD;
while (1)
{
@ -1174,7 +1174,7 @@ static void menu_opt_cust_draw(const menu_entry *entry, int x, int y, void *para
switch (entry->id)
{
case MA_OPT_RENDERER:
if (PicoOpt&0x10)
if (PicoOpt & POPT_ALT_RENDERER)
str = " 8bit fast";
else if (currentConfig.EmuOpt&0x80)
str = "16bit accurate";
@ -1198,7 +1198,7 @@ static void menu_opt_cust_draw(const menu_entry *entry, int x, int y, void *para
text_out16(x, y, "Frameskip %s", str24);
break;
case MA_OPT_SOUND_QUALITY:
str = (PicoOpt&0x08)?"stereo":"mono";
str = (PicoOpt & POPT_EN_STEREO) ? "stereo" : "mono";
text_out16(x, y, "Sound Quality: %5iHz %s", PsndRate, str);
break;
case MA_OPT_REGION:
@ -1288,7 +1288,7 @@ static void menu_options_save(void)
// force setting possibly changed..
Pico.m.pal = (PicoRegionOverride == 2 || PicoRegionOverride == 8) ? 1 : 0;
}
if (!(PicoOpt & 0x20)) {
if (!(PicoOpt & POPT_6BTN_PAD)) {
// unbind XYZ MODE, just in case
unbind_action(0xf00, -1, -1);
}

View file

@ -1,667 +0,0 @@
// This is part of Pico Library
// (c) Copyright 2004 Dave, All rights reserved.
// (c) Copyright 2006 notaz, All rights reserved.
// Free for non-commercial use.
// For commercial use, separate licencing terms must be obtained.
#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]];
}

View file

@ -276,7 +276,7 @@ static void EmuScanPrepare(void)
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;
@ -422,7 +422,7 @@ static void blit2(const char *fps, const char *notice, int lagging_behind)
//dbg_text();
if ((emu_opt & 0x400) && (PicoMCD & 1))
if ((emu_opt & 0x400) && (PicoAHW & PAHW_MCD))
cd_leds();
if (currentConfig.EmuOpt & 0x2000) { // want vsync
@ -467,7 +467,7 @@ static void vidResetMode(void)
// slow rend.
PicoDrawSetColorFormat(-1);
PicoScan = EmuScanSlow;
PicoScanEnd = EmuScanSlow;
localPal[0xe0] = 0;
Pico.m.dirtyPal = 1;
@ -670,7 +670,7 @@ void emu_forcedFrame(void)
memset32_uncached((int *)psp_screen + 512*264*2/4, 0, 512*8*2/4);
PicoDrawSetColorFormat(-1);
PicoScan = EmuScanSlow;
PicoScanEnd = EmuScanSlow;
EmuScanPrepare();
PicoFrameDrawOnly();
blit1();
@ -855,7 +855,7 @@ void emu_Loop(void)
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...
@ -1001,7 +1001,7 @@ void emu_Loop(void)
}
if (PicoMCD & 1) PicoCDBufferFree();
if (PicoAHW & PAHW_MCD) PicoCDBufferFree();
if (PsndOut != NULL) {
PsndOut = NULL;
@ -1028,7 +1028,7 @@ void emu_ResetGame(void)
void emu_HandleResume(void)
{
if (!(PicoMCD & 1)) return;
if (!(PicoAHW & PAHW_MCD)) return;
// reopen files..
if (Pico_mcd->TOC.Tracks[0].F != NULL)

View file

@ -573,7 +573,7 @@ static void draw_savestate_bg(int slot)
}
if (file) {
if (PicoMCD & 1) {
if (PicoAHW & PAHW_MCD) {
PicoCdLoadStateGfx(file);
} else {
areaSeek(file, 0x10020, SEEK_SET); // skip header and RAM in state file

View file

@ -460,7 +460,7 @@ int mp3_get_offset(void) // 0-1023
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) {