sync to latest FCEUX svn

This commit is contained in:
dborth 2010-12-06 02:46:57 +00:00
parent e7d364ed0a
commit 475e0f92a6
13 changed files with 688 additions and 218 deletions

View File

@ -23,6 +23,8 @@
static uint8 bus_conflict = 0; static uint8 bus_conflict = 0;
static uint8 latche, latcheinit; static uint8 latche, latcheinit;
static uint16 addrreg0, addrreg1; static uint16 addrreg0, addrreg1;
static uint8 *WRAM=NULL;
static uint32 WRAMSIZE;
static void(*WSync)(void); static void(*WSync)(void);
static DECLFW(LatchWrite) static DECLFW(LatchWrite)
@ -39,23 +41,44 @@ static void LatchPower(void)
{ {
latche=latcheinit; latche=latcheinit;
WSync(); WSync();
SetReadHandler(0x8000,0xFFFF,CartBR); SetReadHandler(0x6000,0xFFFF,CartBR);
SetWriteHandler(0x6000,0x7FFF,CartBW);
SetWriteHandler(addrreg0,addrreg1,LatchWrite); SetWriteHandler(addrreg0,addrreg1,LatchWrite);
} }
static void LatchClose(void)
{
if(WRAM)
FCEU_gfree(WRAM);
WRAM=NULL;
}
static void StateRestore(int version) static void StateRestore(int version)
{ {
WSync(); WSync();
} }
static void Latch_Init(CartInfo *info, void (*proc)(void), uint8 init, uint16 adr0, uint16 adr1) static void Latch_Init(CartInfo *info, void (*proc)(void), uint8 init, uint16 adr0, uint16 adr1, uint8 wram)
{ {
latcheinit=init; latcheinit=init;
addrreg0=adr0; addrreg0=adr0;
addrreg1=adr1; addrreg1=adr1;
WSync=proc; WSync=proc;
info->Power=LatchPower; info->Power=LatchPower;
info->Close=LatchClose;
GameStateRestore=StateRestore; GameStateRestore=StateRestore;
if(wram)
{
WRAMSIZE=8192;
WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);
SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);
if(info->battery)
{
info->SaveGame[0]=WRAM;
info->SaveGameLen[0]=WRAMSIZE;
}
AddExState(WRAM, WRAMSIZE, 0, "WRAM");
}
AddExState(&latche, 1, 0, "LATC"); AddExState(&latche, 1, 0, "LATC");
AddExState(&bus_conflict, 1, 0, "BUSC"); AddExState(&bus_conflict, 1, 0, "BUSC");
} }
@ -72,7 +95,7 @@ static void CPROMSync(void)
void CPROM_Init(CartInfo *info) void CPROM_Init(CartInfo *info)
{ {
Latch_Init(info, CPROMSync, 0, 0x8000, 0xFFFF); Latch_Init(info, CPROMSync, 0, 0x8000, 0xFFFF, 0);
} }
//------------------ Map 184 --------------------------- //------------------ Map 184 ---------------------------
@ -87,7 +110,7 @@ static void M184Sync(void)
void Mapper184_Init(CartInfo *info) void Mapper184_Init(CartInfo *info)
{ {
Latch_Init(info, M184Sync, 0, 0x6000, 0x7FFF); Latch_Init(info, M184Sync, 0, 0x6000, 0x7FFF, 0);
} }
//------------------ CNROM --------------------------- //------------------ CNROM ---------------------------
@ -99,12 +122,13 @@ static void CNROMSync(void)
setchr8(latche); setchr8(latche);
setprg16(0x8000,0); setprg16(0x8000,0);
setprg16(0xC000,1); setprg16(0xC000,1);
setprg8r(0x10,0x6000,0); // Hayauchy IGO uses 2Kb or RAM
} }
void CNROM_Init(CartInfo *info) void CNROM_Init(CartInfo *info)
{ {
bus_conflict = 1; bus_conflict = 1;
Latch_Init(info, CNROMSync, 0, 0x8000, 0xFFFF); Latch_Init(info, CNROMSync, 0, 0x8000, 0xFFFF, 1);
} }
//------------------ ANROM --------------------------- //------------------ ANROM ---------------------------
@ -118,7 +142,7 @@ static void ANROMSync()
void ANROM_Init(CartInfo *info) void ANROM_Init(CartInfo *info)
{ {
Latch_Init(info, ANROMSync, 0, 0x8000, 0xFFFF); Latch_Init(info, ANROMSync, 0, 0x8000, 0xFFFF, 0);
} }
//------------------ Map 70 --------------------------- //------------------ Map 70 ---------------------------
@ -132,7 +156,7 @@ static void M70Sync()
void Mapper70_Init(CartInfo *info) void Mapper70_Init(CartInfo *info)
{ {
Latch_Init(info, M70Sync, 0, 0x8000, 0xFFFF); Latch_Init(info, M70Sync, 0, 0x8000, 0xFFFF, 0);
} }
//------------------ Map 152 --------------------------- //------------------ Map 152 ---------------------------
@ -147,7 +171,7 @@ static void M152Sync()
void Mapper152_Init(CartInfo *info) void Mapper152_Init(CartInfo *info)
{ {
Latch_Init(info, M152Sync, 0, 0x8000, 0xFFFF); Latch_Init(info, M152Sync, 0, 0x8000, 0xFFFF, 0);
} }
//------------------ Map 78 --------------------------- //------------------ Map 78 ---------------------------
@ -162,7 +186,7 @@ static void M78Sync()
void Mapper78_Init(CartInfo *info) void Mapper78_Init(CartInfo *info)
{ {
Latch_Init(info, M78Sync, 0, 0x8000, 0xFFFF); Latch_Init(info, M78Sync, 0, 0x8000, 0xFFFF, 0);
} }
//------------------ MHROM --------------------------- //------------------ MHROM ---------------------------
@ -175,17 +199,17 @@ static void MHROMSync(void)
void MHROM_Init(CartInfo *info) void MHROM_Init(CartInfo *info)
{ {
Latch_Init(info, MHROMSync, 0, 0x8000, 0xFFFF); Latch_Init(info, MHROMSync, 0, 0x8000, 0xFFFF, 0);
} }
void Mapper140_Init(CartInfo *info) void Mapper140_Init(CartInfo *info)
{ {
Latch_Init(info, MHROMSync, 0, 0x6000, 0x7FFF); Latch_Init(info, MHROMSync, 0, 0x6000, 0x7FFF, 0);
} }
void Mapper240_Init(CartInfo *info) void Mapper240_Init(CartInfo *info)
{ {
Latch_Init(info, MHROMSync, 0, 0x4020, 0x5FFF); Latch_Init(info, MHROMSync, 0, 0x4020, 0x5FFF, 0);
// need SRAM. // need SRAM.
} }
@ -201,7 +225,7 @@ static void M87Sync(void)
void Mapper87_Init(CartInfo *info) void Mapper87_Init(CartInfo *info)
{ {
Latch_Init(info, M87Sync, ~0, 0x6000, 0xFFFF); Latch_Init(info, M87Sync, ~0, 0x6000, 0xFFFF, 0);
} }
//------------------ Map 101 --------------------------- //------------------ Map 101 ---------------------------
@ -215,7 +239,7 @@ static void M101Sync(void)
void Mapper101_Init(CartInfo *info) void Mapper101_Init(CartInfo *info)
{ {
Latch_Init(info, M101Sync, ~0, 0x6000, 0x7FFF); Latch_Init(info, M101Sync, ~0, 0x6000, 0x7FFF, 0);
} }
//------------------ Map 11 --------------------------- //------------------ Map 11 ---------------------------
@ -228,12 +252,12 @@ static void M11Sync(void)
void Mapper11_Init(CartInfo *info) void Mapper11_Init(CartInfo *info)
{ {
Latch_Init(info, M11Sync, 0, 0x8000, 0xFFFF); Latch_Init(info, M11Sync, 0, 0x8000, 0xFFFF, 0);
} }
void Mapper144_Init(CartInfo *info) void Mapper144_Init(CartInfo *info)
{ {
Latch_Init(info, M11Sync, 0, 0x8001, 0xFFFF); Latch_Init(info, M11Sync, 0, 0x8001, 0xFFFF, 0);
} }
//------------------ Map 38 --------------------------- //------------------ Map 38 ---------------------------
@ -246,7 +270,7 @@ static void M38Sync(void)
void Mapper38_Init(CartInfo *info) void Mapper38_Init(CartInfo *info)
{ {
Latch_Init(info, M38Sync, 0, 0x7000, 0x7FFF); Latch_Init(info, M38Sync, 0, 0x7000, 0x7FFF, 0);
} }
//------------------ Map 36 --------------------------- //------------------ Map 36 ---------------------------
@ -259,7 +283,7 @@ static void M36Sync(void)
void Mapper36_Init(CartInfo *info) void Mapper36_Init(CartInfo *info)
{ {
Latch_Init(info, M36Sync, 0, 0x8400, 0xfffe); Latch_Init(info, M36Sync, 0, 0x8400, 0xfffe, 0);
} }
//------------------ UNROM --------------------------- //------------------ UNROM ---------------------------
@ -273,7 +297,7 @@ static void UNROMSync(void)
void UNROM_Init(CartInfo *info) void UNROM_Init(CartInfo *info)
{ {
bus_conflict = 1; bus_conflict = 1;
Latch_Init(info, UNROMSync, 0, 0x8000, 0xFFFF); Latch_Init(info, UNROMSync, 0, 0x8000, 0xFFFF, 0);
} }
//------------------ Map 93 --------------------------- //------------------ Map 93 ---------------------------
@ -287,7 +311,7 @@ static void SSUNROMSync(void)
void SUNSOFT_UNROM_Init(CartInfo *info) void SUNSOFT_UNROM_Init(CartInfo *info)
{ {
Latch_Init(info, SSUNROMSync, 0, 0x8000, 0xFFFF); Latch_Init(info, SSUNROMSync, 0, 0x8000, 0xFFFF, 0);
} }
//------------------ Map 94 --------------------------- //------------------ Map 94 ---------------------------
@ -301,7 +325,7 @@ static void M94Sync(void)
void Mapper94_Init(CartInfo *info) void Mapper94_Init(CartInfo *info)
{ {
Latch_Init(info, M94Sync, 0, 0x8000, 0xFFFF); Latch_Init(info, M94Sync, 0, 0x8000, 0xFFFF, 0);
} }
//------------------ Map 180 --------------------------- //------------------ Map 180 ---------------------------
@ -315,7 +339,7 @@ static void M180Sync(void)
void Mapper180_Init(CartInfo *info) void Mapper180_Init(CartInfo *info)
{ {
Latch_Init(info, M180Sync, 0, 0x8000, 0xFFFF); Latch_Init(info, M180Sync, 0, 0x8000, 0xFFFF, 0);
} }
//------------------ Map 107 --------------------------- //------------------ Map 107 ---------------------------
@ -328,7 +352,7 @@ static void M107Sync(void)
void Mapper107_Init(CartInfo *info) void Mapper107_Init(CartInfo *info)
{ {
Latch_Init(info, M107Sync, ~0, 0x8000, 0xFFFF); Latch_Init(info, M107Sync, ~0, 0x8000, 0xFFFF, 0);
} }
//------------------ Map 113 --------------------------- //------------------ Map 113 ---------------------------
@ -342,7 +366,7 @@ static void M113Sync(void)
void Mapper113_Init(CartInfo *info) void Mapper113_Init(CartInfo *info)
{ {
Latch_Init(info, M113Sync, 0, 0x4100, 0x7FFF); Latch_Init(info, M113Sync, 0, 0x4100, 0x7FFF, 0);
} }
//------------------ A65AS --------------------------- //------------------ A65AS ---------------------------
@ -370,7 +394,7 @@ static void BMCA65ASSync(void)
void BMCA65AS_Init(CartInfo *info) void BMCA65AS_Init(CartInfo *info)
{ {
Latch_Init(info, BMCA65ASSync, 0, 0x8000, 0xFFFF); Latch_Init(info, BMCA65ASSync, 0, 0x8000, 0xFFFF, 0);
} }
//------------------ NROM --------------------------- //------------------ NROM ---------------------------
@ -379,15 +403,21 @@ void BMCA65AS_Init(CartInfo *info)
static DECLFW(WriteHandler) static DECLFW(WriteHandler)
{ {
FCEU_printf("bs %04x %02x\n",A,V); FCEU_printf("bs %04x %02x\n",A,V);
CartBW(A,V);
} }
#endif #endif
static void NROMPower(void) static void NROMPower(void)
{ {
setprg8r(0x10,0x6000,0); // Famili BASIC (v3.0) need it (uses only 4KB), FP-BASIC uses 8KB
setprg16(0x8000,0); setprg16(0x8000,0);
setprg16(0xC000,~0); setprg16(0xC000,~0);
setchr8(0); setchr8(0);
SetReadHandler(0x6000,0x6FFF,CartBR);
SetWriteHandler(0x6000,0x6FFF,CartBW);
SetReadHandler(0x8000,0xFFFF,CartBR); SetReadHandler(0x8000,0xFFFF,CartBR);
#ifdef DEBUG_MAPPER #ifdef DEBUG_MAPPER
SetWriteHandler(0x4020,0xFFFF,WriteHandler); SetWriteHandler(0x4020,0xFFFF,WriteHandler);
#endif #endif
@ -396,4 +426,16 @@ static void NROMPower(void)
void NROM_Init(CartInfo *info) void NROM_Init(CartInfo *info)
{ {
info->Power=NROMPower; info->Power=NROMPower;
info->Close=LatchClose;
WRAMSIZE=8192;
WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);
SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);
if(info->battery)
{
info->SaveGame[0]=WRAM;
info->SaveGameLen[0]=WRAMSIZE;
}
AddExState(WRAM, WRAMSIZE, 0, "WRAM");
} }

View File

@ -1,7 +1,7 @@
/* FCE Ultra - NES/Famicom Emulator /* FCE Ultra - NES/Famicom Emulator
* *
* Copyright notice for this file: * Copyright notice for this file:
* Copyright (C) 2007 CaH4e3 * Copyright (C) 2007-2010 CaH4e3
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -16,107 +16,184 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* OneBus system
* Street Dance (Dance pad) (Unl) * Street Dance (Dance pad) (Unl)
* 101-in-1 Arcade Action II
* DreamGEAR 75-in-1
*/ */
#include "mapinc.h" #include "mapinc.h"
static uint8 reg4[16]; static uint8 isDance;
static uint8 regc[6]; static uint8 regs[16],regc[6];
static uint8 reg2000, mmc3cmd, pcm_enable = 0, pcm_irq = 0; static uint8 IRQCount,IRQLatch,IRQa, IRQReload, pcm_enable = 0, pcm_irq = 0;
static int16 pcm_addr, pcm_size, pcm_latch, pcm_clock = 0xF6; static int16 pcm_addr, pcm_size, pcm_latch, pcm_clock = 0xF6;
static writefunc old4011write, old4012write, old4013write, old4015write; static writefunc old4011write, old4012write, old4013write, old4015write;
static readfunc old4015read; static readfunc old4015read;
static SFORMAT StateRegs[]= static SFORMAT StateRegs[]=
{ {
{reg4, 16, "reg4"}, {regc, 6, "REGC"},
{regc, 6, "REGSC"}, {regs, 16, "REGS"},
{&reg2000, 1, "REGS2"}, {&IRQReload, 1, "IRQR"},
{&IRQCount, 1, "IRQC"},
{&IRQLatch, 1, "IRQL"},
{&IRQa, 1, "IRQA"},
{&pcm_enable, 1, "PCME"}, {&pcm_enable, 1, "PCME"},
{&pcm_irq, 1, "PCMIRQ"}, {&pcm_irq, 1, "PCMIRQ"},
{&pcm_addr, 2, "PCMADDR"}, {&pcm_addr, 2, "PCMADDR"},
{&pcm_size, 2, "PCMSIZE"}, {&pcm_size, 2, "PCMSIZE"},
{&pcm_latch, 2, "PCMLATCH"}, {&pcm_latch, 2, "PCMLATCH"},
{&pcm_clock, 2, "PCMCLOCK"}, {&pcm_clock, 2, "PCMCLOCK"},
{&mmc3cmd, 1, "MMC3CMD"},
{0} {0}
}; };
static void Sync(void) static void Sync(void)
{ {
uint8 cbase = reg2000 - ((reg4[0x0B]&4)?6:0); uint16 cswap = (regs[0xf] & 0x80) << 5;
uint8 pbase = reg4[0x09] & 0xC0; uint16 pswap = (regs[0xd]&1)?((regs[0xf] & 0x40) << 8):0;
uint16 pbase = (regs[0]&0xf0)<<4;
setchr1(0x0000,cbase|(regc[0]&(~1))); uint16 cbase = (((regs[0]&0x0f)<<8)|(regs[0xc]<<1)|((regs[0xd]&0xf8)>>3))<<3;
setchr1(0x0400,cbase|(regc[0]|1)); uint16 pmask = 0x3f>>(regs[0xb]&0xf);
setchr1(0x0800,cbase|(regc[1]&(-1)));
setchr1(0x0c00,cbase|(regc[1]|1)); setchr1(cswap^0x0000,cbase|(regc[0]&(~1)));
setchr1(0x1000,cbase|regc[2]); setchr1(cswap^0x0400,cbase|(regc[0]|1));
setchr1(0x1400,cbase|regc[3]); setchr1(cswap^0x0800,cbase|(regc[1]&(-1)));
setchr1(0x1800,cbase|regc[4]); setchr1(cswap^0x0c00,cbase|(regc[1]|1));
setchr1(0x1c00,cbase|regc[5]); setchr1(cswap^0x1000,cbase|(regc[2]));
setchr1(cswap^0x1400,cbase|(regc[3]));
setchr1(cswap^0x1800,cbase|(regc[4]));
if(reg4[0x0B]&1) setchr1(cswap^0x1c00,cbase|(regc[5]));
if(regs[0xd]&2)
{ {
setprg8(0x8000,reg4[0x07] + 0x20); setprg8(pswap^0x8000, pbase|(regs[0x7]&pmask)|(regs[0xa]&(~pmask)));
setprg8(0xA000,reg4[0x08] + 0x20); setprg8( 0xA000, pbase|(regs[0x8]&pmask)|(regs[0xa]&(~pmask)));
setprg8(pswap^0xC000, pbase|(regs[0x9]&pmask)|(regs[0xa]&(~pmask)));
setprg8( 0xE000, pbase|regs[0xa]);
} }
else else
{ {
setprg8(0x8000,reg4[0x07] + pbase); setprg8(pswap^0x8000, pbase|(regs[0x7]&pmask)|(regs[0xa]&(~pmask)));
setprg8(0xA000,reg4[0x08] + pbase); setprg8( 0xA000, pbase|(regs[0x8]&pmask)|(regs[0xa]&(~pmask)));
setprg8(pswap^0xC000, pbase|((~1)&pmask)|(regs[0xa]&(~pmask)));
setprg8( 0xE000, pbase|((~0)&pmask)|(regs[0xa]&(~pmask)));
} }
setprg8(0xC000,reg4[0x09]); setmirror(regs[0xe]);
setprg8(0xE000,reg4[0x0A]);
}
static DECLFW(UNLDANCEWrite2)
{
reg2000 = V;
Sync();
//FCEU_printf("write %04x:%04x\n",A,V);
} }
static DECLFW(UNLDANCEWrite4) static DECLFW(UNLOneBusWrite20XX)
{ {
reg4[A & 0x0F] = V; // FCEU_printf("PPU %04x:%04x\n",A,V);
if(A == 0x201A)
regs[0xd] = V;
else if(A == 0x2018)
regs[0xc] = V;
Sync(); Sync();
//FCEU_printf("write %04x:%04x\n",A,V);
} }
static DECLFW(UNLDANCEWrite8) static DECLFW(UNLOneBusWriteExp)
{ {
if(A&1) // FCEU_printf("EXP %04x:%04x\n",A,V);
// switch(A & 0x0F)
// {
// case 2: pcm_latch = pcm_clock; FCEU_printf("write %04x:%04x\n",A,V); break;
// case 3: pcm_irqa = 0; X6502_IRQEnd(FCEU_IQEXT); pcm_irq = 0; FCEU_printf("write %04x:%04x\n",A,V); break;
// case 4: pcm_irqa = 1; FCEU_printf("write %04x:%04x\n",A,V); break;
// default:
regs[A & 0x0F] = V;
Sync();
// }
}
static DECLFW(UNLOneBusWriteDebug)
{
// FCEU_printf("write %04x:%04x\n",A,V);
}
static DECLFW(UNLOneBusWriteMMC)
{
// FCEU_printf("MMC %04x:%04x\n",A,V);
switch(A&0xE001)
{ {
if(mmc3cmd<6) case 0x8000: regs[0xf] = V; Sync(); break;
regc[mmc3cmd] = V; case 0x8001:
else {
reg4[0x07 + mmc3cmd - 6] = V; uint8 mask = 0xff, mmc3cmd = regs[0xf]&7;
switch(mmc3cmd)
{
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
if(regs[0xd]&4)
mask = 0x0f;
else
mask >>= ((regs[0xb]&0xf0)>>4);
regc[mmc3cmd] = V&mask;
break;
case 6:
case 7:
mask = (mask&0x3f)>>(regs[0xb]&0xf);
regs[mmc3cmd+1] = (regs[mmc3cmd+1]&(~mask))|(V&mask);
break;
}
Sync();
break;
}
case 0xA000: regs[0xe] = (V & 1)^1; Sync(); break;
case 0xC000: IRQLatch = V&0xfe; break;
case 0xC001: IRQReload = 1; break;
case 0xE000: X6502_IRQEnd(FCEU_IQEXT); IRQa = 0; break;
case 0xE001: IRQa = 1; break;
} }
else
mmc3cmd = V & 7;
Sync();
//FCEU_printf("write %04x:%04x\n",A,V);
} }
static DECLFW(UNLDANCEWrite4012) static void UNLOneBusIRQHook(void)
{ {
int count = IRQCount;
if(!count || IRQReload)
{
IRQCount = IRQLatch;
IRQReload = 0;
}
else
IRQCount--;
if(count && !IRQCount)
{
if(IRQa)
X6502_IRQBegin(FCEU_IQEXT);
}
}
static DECLFW(UNLOneBusWriteAPU2)
{
// FCEU_printf("APU2 %04x:%04x\n",A,V);
CartBW(A&0xffdf,V);
}
static DECLFW(UNLOneBusWrite4012)
{
// FCEU_printf("write %04x:%04x\n",A,V);
pcm_addr = V << 6; pcm_addr = V << 6;
old4012write(A,V); old4012write(A,V);
} }
static DECLFW(UNLDANCEWrite4013) static DECLFW(UNLOneBusWrite4013)
{ {
// FCEU_printf("write %04x:%04x\n",A,V);
pcm_size = (V << 4) + 1; pcm_size = (V << 4) + 1;
old4013write(A,V); old4013write(A,V);
} }
static DECLFW(UNLDANCEWrite4015) static DECLFW(UNLOneBusWrite4015)
{ {
// FCEU_printf("write %04x:%04x\n",A,V);
pcm_enable = V&0x10; pcm_enable = V&0x10;
if(pcm_irq) if(pcm_irq)
{ {
@ -128,12 +205,14 @@ static DECLFW(UNLDANCEWrite4015)
old4015write(A,V&0xEF); old4015write(A,V&0xEF);
} }
static DECLFR(UNLDANCERead4015) static DECLFR(UNLOneBusRead4015)
{ {
return (old4015read(A) & 0x7F) | pcm_irq; uint8 result = (old4015read(A) & 0x7F)|pcm_irq;
// FCEU_printf("read %04x, %02x\n",A,result);
return result;
} }
static void UNLDANCECpuHook(int a) static void UNLOneBusCpuHook(int a)
{ {
if(pcm_enable) if(pcm_enable)
{ {
@ -159,34 +238,45 @@ static void UNLDANCECpuHook(int a)
} }
} }
static void UNLDANCEPower(void) static void UNLOneBusPower(void)
{ {
reg4[0x09]=0x3E; IRQCount=IRQLatch=IRQa==0;
reg4[0x0A]=0x3F; regs[0]=regs[1]=regs[1]=regs[2]=regs[3]=regs[4]=regs[5]=regs[6]=0;
SetupCartCHRMapping(0,PRGptr[0],512 * 1024,0); regs[7]=regs[8]=regs[11]=regs[12]=regs[13]=regs[14]=regs[15]=0;
regs[0x09]=0x3E;
regs[0x0A]=0x3F;
SetupCartCHRMapping(0,PRGptr[0],4096 * 1024,0);
if(isDance) // quick workaround, TODO: figure out how it works together
{
old4015read=GetReadHandler(0x4015);
SetReadHandler(0x4015,0x4015,UNLOneBusRead4015);
old4011write=GetWriteHandler(0x4011);
old4012write=GetWriteHandler(0x4012);
SetWriteHandler(0x4012,0x4012,UNLOneBusWrite4012);
old4013write=GetWriteHandler(0x4013);
SetWriteHandler(0x4013,0x4013,UNLOneBusWrite4013);
old4015write=GetWriteHandler(0x4015);
SetWriteHandler(0x4015,0x4015,UNLOneBusWrite4015);
}
old4015read=GetReadHandler(0x4015);
SetReadHandler(0x4015,0x4015,UNLDANCERead4015);
SetReadHandler(0x8000,0xFFFF,CartBR); SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x2009,0x2fff,UNLOneBusWrite20XX);
old4011write=GetWriteHandler(0x4011); // SetWriteHandler(0x4020,0xffff,UNLOneBusWriteDebug);
old4012write=GetWriteHandler(0x4012); // SetWriteHandler(0x4020,0x4040,UNLOneBusWriteAPU2);
SetWriteHandler(0x4012,0x4012,UNLDANCEWrite4012); SetWriteHandler(0x4100,0x410f,UNLOneBusWriteExp);
old4013write=GetWriteHandler(0x4013); SetWriteHandler(0x8000,0xefff,UNLOneBusWriteMMC);
SetWriteHandler(0x4013,0x4013,UNLDANCEWrite4013);
old4015write=GetWriteHandler(0x4015);
SetWriteHandler(0x4015,0x4015,UNLDANCEWrite4015);
SetWriteHandler(0x201A,0x201A,UNLDANCEWrite2);
SetWriteHandler(0x4100,0x410F,UNLDANCEWrite4);
SetWriteHandler(0x8000,0x8001,UNLDANCEWrite8);
Sync(); Sync();
} }
static void UNLDANCEReset(void) static void UNLOneBusReset(void)
{ {
reg4[0x09]=0x3E; IRQCount=IRQLatch=IRQa=0;
reg4[0x0A]=0x3F; regs[0]=regs[1]=regs[1]=regs[2]=regs[3]=regs[4]=regs[5]=regs[6]=0;
regs[7]=regs[8]=regs[11]=regs[12]=regs[13]=regs[14]=regs[15]=0;
regs[0x09]=0x3E;
regs[0x0A]=0x3F;
Sync(); Sync();
} }
@ -195,11 +285,24 @@ static void StateRestore(int version)
Sync(); Sync();
} }
void UNLDANCE_Init(CartInfo *info) void UNLOneBus_Init(CartInfo *info)
{ {
info->Power=UNLDANCEPower; isDance = 0;
info->Reset=UNLDANCEReset; info->Power=UNLOneBusPower;
MapIRQHook=UNLDANCECpuHook; info->Reset=UNLOneBusReset;
GameHBIRQHook=UNLOneBusIRQHook;
// MapIRQHook=UNLOneBusCpuHook;
GameStateRestore=StateRestore;
AddExState(&StateRegs, ~0, 0, 0);
}
void UNLDANCE_Init(CartInfo *info)
{
isDance = 1;
info->Power=UNLOneBusPower;
info->Reset=UNLOneBusReset;
GameHBIRQHook=UNLOneBusIRQHook;
MapIRQHook=UNLOneBusCpuHook;
GameStateRestore=StateRestore; GameStateRestore=StateRestore;
AddExState(&StateRegs, ~0, 0, 0); AddExState(&StateRegs, ~0, 0, 0);
} }

View File

@ -31,7 +31,7 @@
* Compare -> Sum {('==' | '!=' | '<=' | '>=' | '<' | '>') Sum} * Compare -> Sum {('==' | '!=' | '<=' | '>=' | '<' | '>') Sum}
* Sum -> Product {('+' | '-') Product} * Sum -> Product {('+' | '-') Product}
* Product -> Primitive {('*' | '/') Primitive} * Product -> Primitive {('*' | '/') Primitive}
* Primitive -> Number | Address | Register | Flag | '(' Connect ')' * Primitive -> Number | Address | Register | Flag | PC Bank | '(' Connect ')'
* Number -> '#' [1-9A-F]* * Number -> '#' [1-9A-F]*
* Address -> '$' [1-9A-F]* | '$' '[' Connect ']' * Address -> '$' [1-9A-F]* | '$' '[' Connect ']'
* Register -> 'A' | 'X' | 'Y' | 'R' * Register -> 'A' | 'X' | 'Y' | 'R'
@ -228,7 +228,7 @@ Condition* Primitive(const char** str, Condition* c)
return c; return c;
} }
else if (isBank(next)) /* Registers */ else if (isBank(next)) /* PC Bank */
{ {
if (c->type1 == TYPE_NO) if (c->type1 == TYPE_NO)
{ {
@ -322,9 +322,9 @@ Condition* Primitive(const char** str, Condition* c)
Condition* Term(const char** str) Condition* Term(const char** str)
{ {
Condition* t; Condition* t;
Condition* t1; Condition* t1;
Condition* mid; Condition* mid;
t = (Condition*)FCEU_dmalloc(sizeof(Condition)); t = (Condition*)FCEU_dmalloc(sizeof(Condition));
if (!t) if (!t)
return NULL; return NULL;

View File

@ -1,4 +1,25 @@
#include "types.h" /*
Copyright (C) 2009-2010 DeSmuME team
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "emufile.h" #include "emufile.h"
#include <vector> #include <vector>
@ -13,16 +34,226 @@ bool EMUFILE::readAllBytes(std::vector<u8>* dstbuf, const std::string& fname)
return true; return true;
} }
EMUFILE* EMUFILE::memwrap(EMUFILE* fp) size_t EMUFILE_MEMORY::_fread(const void *ptr, size_t bytes){
u32 remain = len-pos;
u32 todo = std::min<u32>(remain,(u32)bytes);
if(len==0)
{
failbit = true;
return 0;
}
if(todo<=4)
{
u8* src = buf()+pos;
u8* dst = (u8*)ptr;
for(size_t i=0;i<todo;i++)
*dst++ = *src++;
}
else
{
memcpy((void*)ptr,buf()+pos,todo);
}
pos += todo;
if(todo<bytes)
failbit = true;
return todo;
}
void EMUFILE_FILE::truncate(s32 length)
{ {
EMUFILE_FILE* file; fflush(fp);
EMUFILE_MEMORY* mem; #ifdef _MSC_VER
file = dynamic_cast<EMUFILE_FILE*>(fp); _chsize(_fileno(fp),length);
mem = dynamic_cast<EMUFILE_MEMORY*>(fp); #else
if(mem) return mem; ftruncate(fileno(fp),length);
mem = new EMUFILE_MEMORY(file->size()); #endif
if(file->size()==0) return mem; fclose(fp);
file->fread(mem->buf(),file->size()); fp = NULL;
delete file; open(fname.c_str(),mode);
}
EMUFILE* EMUFILE_FILE::memwrap()
{
EMUFILE_MEMORY* mem = new EMUFILE_MEMORY(size());
if(size()==0) return mem;
fread(mem->buf(),size());
return mem; return mem;
}
EMUFILE* EMUFILE_MEMORY::memwrap()
{
return this;
}
void EMUFILE::write64le(u64* val)
{
write64le(*val);
}
void EMUFILE::write64le(u64 val)
{
#ifdef LOCAL_BE
u8 s[8];
s[0]=(u8)b;
s[1]=(u8)(b>>8);
s[2]=(u8)(b>>16);
s[3]=(u8)(b>>24);
s[4]=(u8)(b>>32);
s[5]=(u8)(b>>40);
s[6]=(u8)(b>>48);
s[7]=(u8)(b>>56);
fwrite((char*)&s,8);
return 8;
#else
fwrite(&val,8);
#endif
}
size_t EMUFILE::read64le(u64 *Bufo)
{
u64 buf;
if(fread((char*)&buf,8) != 8)
return 0;
#ifndef LOCAL_BE
*Bufo=buf;
#else
*Bufo = LE_TO_LOCAL_64(buf);
#endif
return 1;
}
u64 EMUFILE::read64le()
{
u64 temp;
read64le(&temp);
return temp;
}
void EMUFILE::write32le(u32* val)
{
write32le(*val);
}
void EMUFILE::write32le(u32 val)
{
#ifdef LOCAL_BE
u8 s[4];
s[0]=(u8)val;
s[1]=(u8)(val>>8);
s[2]=(u8)(val>>16);
s[3]=(u8)(val>>24);
fwrite(s,4);
#else
fwrite(&val,4);
#endif
}
size_t EMUFILE::read32le(s32* Bufo) { return read32le((u32*)Bufo); }
size_t EMUFILE::read32le(u32* Bufo)
{
u32 buf;
if(fread(&buf,4)<4)
return 0;
#ifndef LOCAL_BE
*(u32*)Bufo=buf;
#else
*(u32*)Bufo=((buf&0xFF)<<24)|((buf&0xFF00)<<8)|((buf&0xFF0000)>>8)|((buf&0xFF000000)>>24);
#endif
return 1;
}
u32 EMUFILE::read32le()
{
u32 ret;
read32le(&ret);
return ret;
}
void EMUFILE::write16le(u16* val)
{
write16le(*val);
}
void EMUFILE::write16le(u16 val)
{
#ifdef LOCAL_BE
u8 s[2];
s[0]=(u8)val;
s[1]=(u8)(val>>8);
fwrite(s,2);
#else
fwrite(&val,2);
#endif
}
size_t EMUFILE::read16le(s16* Bufo) { return read16le((u16*)Bufo); }
size_t EMUFILE::read16le(u16* Bufo)
{
u32 buf;
if(fread(&buf,2)<2)
return 0;
#ifndef LOCAL_BE
*(u16*)Bufo=buf;
#else
*Bufo = LE_TO_LOCAL_16(buf);
#endif
return 1;
}
u16 EMUFILE::read16le()
{
u16 ret;
read16le(&ret);
return ret;
}
void EMUFILE::write8le(u8* val)
{
write8le(*val);
}
void EMUFILE::write8le(u8 val)
{
fwrite(&val,1);
}
size_t EMUFILE::read8le(u8* val)
{
return fread(val,1);
}
u8 EMUFILE::read8le()
{
u8 temp;
fread(&temp,1);
return temp;
}
void EMUFILE::writedouble(double* val)
{
write64le(double_to_u64(*val));
}
void EMUFILE::writedouble(double val)
{
write64le(double_to_u64(val));
}
double EMUFILE::readdouble()
{
double temp;
readdouble(&temp);
return temp;
}
size_t EMUFILE::readdouble(double* val)
{
u64 temp;
size_t ret = read64le(&temp);
*val = u64_to_double(temp);
return ret;
} }

View File

@ -1,22 +1,27 @@
/* Copyright (C) 2009 DeSmuME team /*
* Copyright (C) 2009-2010 DeSmuME team
* This file is part of DeSmuME
* Permission is hereby granted, free of charge, to any person obtaining a copy
* DeSmuME is free software; you can redistribute it and/or modify of this software and associated documentation files (the "Software"), to deal
* it under the terms of the GNU General Public License as published by in the Software without restriction, including without limitation the rights
* the Free Software Foundation; either version 2 of the License, or to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* (at your option) any later version. copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* DeSmuME is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of The above copyright notice and this permission notice shall be included in
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the all copies or substantial portions of the Software.
* GNU General Public License for more details.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* You should have received a copy of the GNU General Public License IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* along with DeSmuME; if not, write to the Free Software FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/ */
//don't use emufile for files bigger than 2GB! you have been warned! some day this will be fixed.
#ifndef EMUFILE_H #ifndef EMUFILE_H
#define EMUFILE_H #define EMUFILE_H
@ -29,21 +34,10 @@
#include <stdarg.h> #include <stdarg.h>
#include <malloc.h> #include <malloc.h>
//should be changed to #ifdef FCEUX but too much work #include "emufile_types.h"
#ifndef DESMUME
#ifndef __GCTYPES_H__
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
typedef char s8;
typedef short s16;
typedef int s32;
#endif
#endif
#ifdef _XBOX #ifdef _MSC_VER
#undef min; #include <io.h>
#undef max;
#endif #endif
class EMUFILE { class EMUFILE {
@ -56,14 +50,15 @@ public:
{} {}
//takes control of the provided EMUFILE and returns a new EMUFILE which is guranteed to be in memory //returns a new EMUFILE which is guranteed to be in memory. the EMUFILE you call this on may be deleted. use the returned EMUFILE in its place
static EMUFILE* memwrap(EMUFILE* fp); virtual EMUFILE* memwrap() = 0;
virtual ~EMUFILE() {} virtual ~EMUFILE() {}
static bool readAllBytes(std::vector<u8>* buf, const std::string& fname); static bool readAllBytes(std::vector<u8>* buf, const std::string& fname);
bool fail() { return failbit; } bool fail(bool unset=false) { bool ret = failbit; if(unset) unfail(); return ret; }
void unfail() { failbit=false; }
bool eof() { return size()==ftell(); } bool eof() { return size()==ftell(); }
@ -90,10 +85,37 @@ public:
virtual void fwrite(const void *ptr, size_t bytes) = 0; virtual void fwrite(const void *ptr, size_t bytes) = 0;
void write64le(u64* val);
void write64le(u64 val);
size_t read64le(u64* val);
u64 read64le();
void write32le(u32* val);
void write32le(s32* val) { write32le((u32*)val); }
void write32le(u32 val);
size_t read32le(u32* val);
size_t read32le(s32* val);
u32 read32le();
void write16le(u16* val);
void write16le(s16* val) { write16le((u16*)val); }
void write16le(u16 val);
size_t read16le(s16* Bufo);
size_t read16le(u16* val);
u16 read16le();
void write8le(u8* val);
void write8le(u8 val);
size_t read8le(u8* val);
u8 read8le();
void writedouble(double* val);
void writedouble(double val);
double readdouble();
size_t readdouble(double* val);
virtual int fseek(int offset, int origin) = 0; virtual int fseek(int offset, int origin) = 0;
virtual int ftell() = 0; virtual int ftell() = 0;
virtual int size() = 0; virtual int size() = 0;
virtual void truncate(s32 length) = 0;
}; };
//todo - handle read-only specially? //todo - handle read-only specially?
@ -110,12 +132,12 @@ protected:
public: public:
EMUFILE_MEMORY(std::vector<u8> *underlying) : vec(underlying), ownvec(false), pos(0), len(underlying->size()) { } EMUFILE_MEMORY(std::vector<u8> *underlying) : vec(underlying), ownvec(false), pos(0), len((s32)underlying->size()) { }
EMUFILE_MEMORY(u32 preallocate) : vec(new std::vector<u8>()), ownvec(true), pos(0), len(0) { EMUFILE_MEMORY(u32 preallocate) : vec(new std::vector<u8>()), ownvec(true), pos(0), len(0) {
vec->resize(preallocate); vec->resize(preallocate);
len = preallocate; len = preallocate;
} }
EMUFILE_MEMORY() : vec(new std::vector<u8>()), ownvec(true), pos(0), len(0) { vec->reserve(8192); } EMUFILE_MEMORY() : vec(new std::vector<u8>()), ownvec(true), pos(0), len(0) { vec->reserve(1024); }
EMUFILE_MEMORY(void* buf, s32 size) : vec(new std::vector<u8>()), ownvec(true), pos(0), len(size) { EMUFILE_MEMORY(void* buf, s32 size) : vec(new std::vector<u8>()), ownvec(true), pos(0), len(size) {
vec->resize(size); vec->resize(size);
if(size != 0) if(size != 0)
@ -126,7 +148,19 @@ public:
if(ownvec) delete vec; if(ownvec) delete vec;
} }
u8* buf() { return &(*vec)[0]; } virtual EMUFILE* memwrap();
virtual void truncate(s32 length)
{
vec->resize(length);
len = length;
if(pos>length) pos=length;
}
u8* buf() {
if(size()==0) reserve(1);
return &(*vec)[0];
}
std::vector<u8>* get_vec() { return vec; }; std::vector<u8>* get_vec() { return vec; };
@ -176,23 +210,15 @@ public:
return 0; return 0;
} }
virtual size_t _fread(const void *ptr, size_t bytes){ virtual size_t _fread(const void *ptr, size_t bytes);
u32 remain = len-pos;
u32 todo = std::min<u32>(remain,(u32)bytes);
memcpy((void*)ptr,buf()+pos,todo);
pos += todo;
if(todo<bytes)
failbit = true;
return todo;
}
//removing these return values for now so we can find any code that might be using them and make sure //removing these return values for now so we can find any code that might be using them and make sure
//they handle the return values correctly //they handle the return values correctly
virtual void fwrite(const void *ptr, size_t bytes){ virtual void fwrite(const void *ptr, size_t bytes){
reserve(pos+bytes); reserve(pos+(s32)bytes);
memcpy(buf()+pos,ptr,bytes); memcpy(buf()+pos,ptr,bytes);
pos += bytes; pos += (s32)bytes;
len = std::max(pos,len); len = std::max(pos,len);
} }
@ -260,6 +286,28 @@ public:
if(own_buffer && buffer) free(buffer); if(own_buffer && buffer) free(buffer);
} }
virtual EMUFILE* memwrap()
{
return this;
}
virtual void truncate(s32 length)
{
if(own_buffer)
{
char *oldbuffer = buffer;
buffer = (char *)memalign(32, length);
if(buffer)
{
int bytes = std::min(len, length);
memcpy(buffer, oldbuffer, bytes);
}
free(oldbuffer);
}
len = length;
if(pos>length) pos=length;
}
char* buf() { return buffer; } char* buf() { return buffer; }
virtual FILE *get_fp() { return NULL; } virtual FILE *get_fp() { return NULL; }
@ -356,6 +404,8 @@ public:
class EMUFILE_FILE : public EMUFILE { class EMUFILE_FILE : public EMUFILE {
protected: protected:
FILE* fp; FILE* fp;
std::string fname;
char mode[16];
private: private:
void open(const char* fname, const char* mode) void open(const char* fname, const char* mode)
@ -363,6 +413,8 @@ private:
fp = fopen(fname,mode); fp = fopen(fname,mode);
if(!fp) if(!fp)
failbit = true; failbit = true;
this->fname = fname;
strcpy(this->mode,mode);
} }
public: public:
@ -379,8 +431,12 @@ public:
return fp; return fp;
} }
virtual EMUFILE* memwrap();
bool is_open() { return fp != NULL; } bool is_open() { return fp != NULL; }
virtual void truncate(s32 length);
virtual int fprintf(const char *format, ...) { virtual int fprintf(const char *format, ...) {
va_list argptr; va_list argptr;
va_start(argptr, format); va_start(argptr, format);

View File

@ -0,0 +1,16 @@
#ifndef EMUFILE_TYPES_H
#define EMUFILE_TYPES_H
#include "types.h"
typedef uint8 u8;
typedef uint16 u16;
typedef uint32 u32;
typedef uint64 u64;
typedef int8 s8;
typedef int16 s16;
typedef int32 s32;
typedef int64 s64;
#endif //EMUFILE_TYPES_H

View File

@ -655,7 +655,8 @@ static BMAPPINGLocal bmap[] = {
{"", 215, Mapper215_Init}, {"", 215, Mapper215_Init},
{"", 216, Mapper216_Init}, {"", 216, Mapper216_Init},
{"", 217, Mapper217_Init}, {"", 217, Mapper217_Init},
{"UNLA9746", 219, UNLA9746_Init}, {"UNLA9746", 219, UNLA9746_Init},
{"OneBus", 220, UNLOneBus_Init},
// {220, BMCFK23C_Init}, // {220, BMCFK23C_Init},
// {220, UNL3DBlock_Init}, // {220, UNL3DBlock_Init},

View File

@ -206,7 +206,7 @@ void MovieData::TryDumpIncremental()
currMovieData.storeTasSavestate(currFrameCounter, Z_DEFAULT_COMPRESSION); currMovieData.storeTasSavestate(currFrameCounter, Z_DEFAULT_COMPRESSION);
currMovieData.greenZoneCount=currFrameCounter+1; currMovieData.greenZoneCount=currFrameCounter+1;
} else if (currFrameCounter < currMovieData.greenZoneCount || !movie_readonly) } else if (currFrameCounter < currMovieData.greenZoneCount && !movie_readonly)
{ {
currMovieData.storeTasSavestate(currFrameCounter, Z_DEFAULT_COMPRESSION); currMovieData.storeTasSavestate(currFrameCounter, Z_DEFAULT_COMPRESSION);
} else if (currFrameCounter > currMovieData.greenZoneCount && static_cast<unsigned int>(currMovieData.greenZoneCount)<currMovieData.records.size()) } else if (currFrameCounter > currMovieData.greenZoneCount && static_cast<unsigned int>(currMovieData.greenZoneCount)<currMovieData.records.size())
@ -467,6 +467,7 @@ MovieData::MovieData()
, binaryFlag(false) , binaryFlag(false)
, greenZoneCount(0) , greenZoneCount(0)
, microphone(false) , microphone(false)
, tweakCount(0)
{ {
memset(&romChecksum,0,sizeof(MD5DATA)); memset(&romChecksum,0,sizeof(MD5DATA));
} }
@ -985,6 +986,7 @@ void MovieData::storeTasSavestate(int frame, int compression_level)
savestates.resize(frame+1); savestates.resize(frame+1);
MovieData::dumpSavestateTo(&savestates[frame],compression_level); MovieData::dumpSavestateTo(&savestates[frame],compression_level);
tweakCount++;
} }
//begin playing an existing movie //begin playing an existing movie
@ -1163,7 +1165,7 @@ void FCEUMOV_AddInputState()
//or something like that //or something like that
//(input recording is just like standard read+write movie recording with input taken from gamepad) //(input recording is just like standard read+write movie recording with input taken from gamepad)
//otherwise, it will come from the tasedit data. //otherwise, it will come from the tasedit data.
#ifdef _WIN32
if(movieMode == MOVIEMODE_TASEDIT) if(movieMode == MOVIEMODE_TASEDIT)
{ {
MovieRecord* mr = &currMovieData.records[currFrameCounter]; MovieRecord* mr = &currMovieData.records[currFrameCounter];
@ -1178,12 +1180,19 @@ void FCEUMOV_AddInputState()
} }
else else
{ {
if (currMovieData.greenZoneCount>currFrameCounter+1)
{
InvalidateGreenZone(currFrameCounter);
}
joyports[0].log(mr); joyports[0].log(mr);
joyports[1].log(mr); joyports[1].log(mr);
mr->commands = 0; mr->commands = 0;
} }
} }
else if(movieMode == MOVIEMODE_PLAY) #endif
if(movieMode == MOVIEMODE_PLAY)
{ {
//stop when we run out of frames //stop when we run out of frames
if(currFrameCounter >= (int)currMovieData.records.size()) if(currFrameCounter >= (int)currMovieData.records.size())

View File

@ -192,6 +192,7 @@ public:
//----TasEdit stuff--- //----TasEdit stuff---
int greenZoneCount; int greenZoneCount;
int loadFrameCount; int loadFrameCount;
int tweakCount;
//---- //----
int getNumRecords() { return records.size(); } int getNumRecords() { return records.size(); }

View File

@ -2169,6 +2169,15 @@ struct BGData {
Record main[34]; //one at the end is junk, it can never be rendered Record main[34]; //one at the end is junk, it can never be rendered
} bgdata; } bgdata;
static inline int PaletteAdjustPixel(int pixel)
{
if((PPU[1]>>5)==0x7)
return (pixel&0x3f)|0xc0;
else if(PPU[1]&0xE0)
return pixel | 0x40;
else
return (pixel&0x3F)|0x80;
}
int framectr=0; int framectr=0;
int FCEUX_PPU_Loop(int skip) { int FCEUX_PPU_Loop(int skip) {
@ -2338,10 +2347,7 @@ int FCEUX_PPU_Loop(int skip) {
} }
} }
//fceu rendering system requires that this be set *ptr++ = PaletteAdjustPixel(pixelcolor);
//(so that it knows there is a valid pixel there?)
pixelcolor |= 0x80;
*ptr++ = pixelcolor;
} }
} }
} }

View File

@ -129,7 +129,7 @@ static int DoMirroring(FCEUFILE *fp)
{ {
uint8 t; uint8 t;
t=FCEU_fgetc(fp); t=FCEU_fgetc(fp);
mirrortodo=t; mirrortodo=t;
{ {
static char *stuffo[6]={"Horizontal","Vertical","$2000","$2400","\"Four-screen\"","Controlled by Mapper Hardware"}; static char *stuffo[6]={"Horizontal","Vertical","$2000","$2400","\"Four-screen\"","Controlled by Mapper Hardware"};
@ -266,7 +266,7 @@ static int LoadPRG(FCEUFILE *fp)
else else
FCEU_printf("\n"); FCEU_printf("\n");
SetupCartPRGMapping(z,malloced[z],t,0); SetupCartPRGMapping(z,malloced[z],t,0);
return(1); return(1);
} }
@ -324,11 +324,11 @@ static BMAPPING bmap[] = {
{ "Sachen-8259D", S8259D_Init,0}, { "Sachen-8259D", S8259D_Init,0},
{ "Sachen-74LS374N", S74LS374N_Init,0}, { "Sachen-74LS374N", S74LS374N_Init,0},
{ "Sachen-74LS374NA", S74LS374NA_Init,0}, //seems to be custom mapper { "Sachen-74LS374NA", S74LS374NA_Init,0}, //seems to be custom mapper
{ "SA-002", TCU02_Init, 0}, { "SA-002", TCU02_Init, 0},
{ "SA-016-1M", SA0161M_Init,0}, { "SA-016-1M", SA0161M_Init,0},
{ "SA-72007", SA72007_Init,0}, { "SA-72007", SA72007_Init,0},
{ "SA-72008", SA72008_Init,0}, { "SA-72008", SA72008_Init,0},
{ "SA-009", SA009_Init,0}, { "SA-009", SA009_Init,0},
{ "SA-0036", SA0036_Init,0}, { "SA-0036", SA0036_Init,0},
{ "SA-0037", SA0037_Init,0}, { "SA-0037", SA0037_Init,0},
{ "SA-NROM", TCA01_Init,0}, { "SA-NROM", TCA01_Init,0},
@ -362,7 +362,7 @@ static BMAPPING bmap[] = {
{ "TGROM", TGROM_Init,0}, { "TGROM", TGROM_Init,0},
{ "TR1ROM", TFROM_Init,BMCFLAG_FORCE4}, { "TR1ROM", TFROM_Init,BMCFLAG_FORCE4},
{ "TBROM", TBROM_Init,0}, { "TBROM", TBROM_Init,0},
{ "TEROM", TEROM_Init,0}, { "TEROM", TEROM_Init,0},
{ "TFROM", TFROM_Init,0}, { "TFROM", TFROM_Init,0},
{ "TLROM", TLROM_Init,0}, { "TLROM", TLROM_Init,0},
@ -374,7 +374,7 @@ static BMAPPING bmap[] = {
{ "TQROM", TQROM_Init,0}, { "TQROM", TQROM_Init,0},
{ "TVROM", TLROM_Init,BMCFLAG_FORCE4}, { "TVROM", TLROM_Init,BMCFLAG_FORCE4},
{ "NTBROM", Mapper68_Init,0}, { "NTBROM", Mapper68_Init,0},
{ "CPROM", CPROM_Init,BMCFLAG_16KCHRR}, { "CPROM", CPROM_Init,BMCFLAG_16KCHRR},
{ "CNROM", CNROM_Init,0}, { "CNROM", CNROM_Init,0},
@ -385,12 +385,12 @@ static BMAPPING bmap[] = {
{ "RROM-128", NROM_Init,0 }, //NROM128_Init,0 }, { "RROM-128", NROM_Init,0 }, //NROM128_Init,0 },
{ "MHROM", MHROM_Init,0}, { "MHROM", MHROM_Init,0},
{ "UNROM", UNROM_Init,0}, { "UNROM", UNROM_Init,0},
{ "UOROM", UNROM_Init,0}, { "UOROM", UNROM_Init,0},
{ "SUNSOFT_UNROM", SUNSOFT_UNROM_Init,0}, { "SUNSOFT_UNROM", SUNSOFT_UNROM_Init,0},
{ "MARIO1-MALEE2", MALEE_Init,0}, { "MARIO1-MALEE2", MALEE_Init,0},
{ "3D-BLOCK", UNL3DBlock_Init, 0}, { "3D-BLOCK", UNL3DBlock_Init, 0},
{ "SMB2J", UNLSMB2J_Init, 0}, { "SMB2J", UNLSMB2J_Init, 0},
{ "AX5705", UNLAX5705_Init, 0}, { "AX5705", UNLAX5705_Init, 0},
{ "CC-21", UNLCC21_Init,0}, { "CC-21", UNLCC21_Init,0},
{ "H2288", UNLH2288_Init,0}, { "H2288", UNLH2288_Init,0},
@ -405,7 +405,7 @@ static BMAPPING bmap[] = {
{ "C-N22M", UNLCN22M_Init,0}, { "C-N22M", UNLCN22M_Init,0},
{ "EDU2000", UNLEDU2000_Init,0}, { "EDU2000", UNLEDU2000_Init,0},
{ "603-5052", UNL6035052_Init,0}, { "603-5052", UNL6035052_Init,0},
{ "N625092", UNLN625092_Init,0}, { "N625092", UNLN625092_Init,0},
{ "Supervision16in1", Supervision16_Init,0}, { "Supervision16in1", Supervision16_Init,0},
{ "NovelDiamond9999999in1", Novel_Init,0}, { "NovelDiamond9999999in1", Novel_Init,0},
{ "Super24in1SC03", Super24_Init,0}, { "Super24in1SC03", Super24_Init,0},
@ -417,27 +417,28 @@ static BMAPPING bmap[] = {
{ "GK-192", BMCGK192_Init, 0}, { "GK-192", BMCGK192_Init, 0},
{ "SuperHIK8in1", Mapper45_Init,0}, { "SuperHIK8in1", Mapper45_Init,0},
{ "22211", UNL22211_Init,0}, { "22211", UNL22211_Init,0},
{ "TF1201", UNLTF1201_Init, 0}, { "TF1201", UNLTF1201_Init, 0},
{ "GS-2004", BMCGS2004_Init, 0}, { "GS-2004", BMCGS2004_Init, 0},
{ "GS-2013", BMCGS2013_Init, 0}, { "GS-2013", BMCGS2013_Init, 0},
{ "KS7032", UNLKS7032_Init, 0}, { "KS7032", UNLKS7032_Init, 0},
{ "T-230", UNLT230_Init, 0}, { "T-230", UNLT230_Init, 0},
{ "190in1", BMC190in1_Init, 0}, { "190in1", BMC190in1_Init, 0},
{ "Ghostbusters63in1", BMCGhostbusters63in1_Init, 0}, { "Ghostbusters63in1", BMCGhostbusters63in1_Init, 0},
{ "BS-5",BMCBS5_Init, 0}, { "BS-5",BMCBS5_Init, 0},
{ "411120-C",BMC411120C_Init, 0}, { "411120-C",BMC411120C_Init, 0},
{ "830118C",BMC830118C_Init, 0}, { "830118C",BMC830118C_Init, 0},
{ "T-227-1",BMCT2271_Init,0}, { "T-227-1",BMCT2271_Init,0},
{ "DREAMTECH01", DreamTech01_Init,0}, { "DREAMTECH01", DreamTech01_Init,0},
{ "KONAMI-QTAI", Mapper190_Init,0}, { "KONAMI-QTAI", Mapper190_Init,0},
{ "DANCE", UNLDANCE_Init,0}, { "DANCE", UNLDANCE_Init,0},
{ "SC-127", UNLSC127_Init,0}, { "OneBus", UNLOneBus_Init,0},
{ "SC-127", UNLSC127_Init,0},
{ "TEK90", Mapper90_Init,0}, { "TEK90", Mapper90_Init,0},
{ "COPYFAMI_MMC3", MapperCopyFamiMMC3_Init,0}, { "COPYFAMI_MMC3", MapperCopyFamiMMC3_Init,0},
{0,0,0} {0,0,0}
}; };
@ -462,13 +463,13 @@ int LoadUNIFChunks(FCEUFILE *fp)
for(;;) for(;;)
{ {
t=FCEU_fread(&uchead,1,4,fp); t=FCEU_fread(&uchead,1,4,fp);
if(t<4) if(t<4)
{ {
if(t>0) if(t>0)
return 0; return 0;
return 1; return 1;
} }
if(!(FCEU_read32le(&uchead.info,fp))) if(!(FCEU_read32le(&uchead.info,fp)))
return 0; return 0;
t=0; t=0;
x=0; x=0;
@ -480,7 +481,7 @@ int LoadUNIFChunks(FCEUFILE *fp)
if(!bfunc[x].init(fp)) if(!bfunc[x].init(fp))
return 0; return 0;
t=1; t=1;
break; break;
} }
x++; x++;
} }
@ -559,7 +560,7 @@ int UNIFLoad(const char *name, FCEUFILE *fp)
FCEU_fseek(fp,0,SEEK_SET); FCEU_fseek(fp,0,SEEK_SET);
FCEU_fread(&unhead,1,4,fp); FCEU_fread(&unhead,1,4,fp);
if(memcmp(&unhead,"UNIF",4)) if(memcmp(&unhead,"UNIF",4))
return 0; return 0;
ResetCartMapping(); ResetCartMapping();
@ -596,6 +597,7 @@ int UNIFLoad(const char *name, FCEUFILE *fp)
#ifndef GEKKO #ifndef GEKKO
FCEU_LoadGameSave(&UNIFCart); FCEU_LoadGameSave(&UNIFCart);
#endif #endif
strcpy(LoadedRomFName,name); //For the debugger list strcpy(LoadedRomFName,name); //For the debugger list
GameInterface=UNIFGI; GameInterface=UNIFGI;
return 1; return 1;

View File

@ -115,6 +115,7 @@ void UNLKS7032_Init(CartInfo *info);
void UNLT230_Init(CartInfo *info); void UNLT230_Init(CartInfo *info);
void UNLAX5705_Init(CartInfo *info); void UNLAX5705_Init(CartInfo *info);
void UNLDANCE_Init(CartInfo *info); void UNLDANCE_Init(CartInfo *info);
void UNLOneBus_Init(CartInfo *info);
void UNLSC127_Init(CartInfo *info); void UNLSC127_Init(CartInfo *info);
void UNLEDU2000_Init(CartInfo *info); void UNLEDU2000_Init(CartInfo *info);

View File

@ -3,8 +3,10 @@
#include <iosfwd> #include <iosfwd>
#include <stdio.h> #include <stdio.h>
#include "../emufile.h"
#include "../types.h" #include "../types.h"
#include "../emufile.h"
class EMUFILE;
inline uint64 double_to_u64(double d) { inline uint64 double_to_u64(double d) {
union { union {
@ -70,9 +72,9 @@ inline int write_double_le(double b, EMUFILE*is) { uint64 temp = double_to_u64(b
int read8le(uint8 *Bufo, EMUFILE*is); int read8le(uint8 *Bufo, EMUFILE*is);
int read16le(uint16 *Bufo, EMUFILE*is); int read16le(uint16 *Bufo, EMUFILE*is);
inline int read16le(int16 *Bufo, EMUFILE*is) { return read16le((u16*)Bufo,is); } inline int read16le(int16 *Bufo, EMUFILE*is) { return read16le((uint16*)Bufo,is); }
int read32le(uint32 *Bufo, EMUFILE*is); int read32le(uint32 *Bufo, EMUFILE*is);
inline int read32le(int32 *Bufo, EMUFILE*is) { return read32le((u32*)Bufo,is); } inline int read32le(int32 *Bufo, EMUFILE*is) { return read32le((uint32*)Bufo,is); }
int read64le(uint64 *Bufo, EMUFILE*is); int read64le(uint64 *Bufo, EMUFILE*is);
inline int read_double_le(double *Bufo, EMUFILE*is) { uint64 temp; int ret = read64le(&temp,is); *Bufo = u64_to_double(temp); return ret; } inline int read_double_le(double *Bufo, EMUFILE*is) { uint64 temp; int ret = read64le(&temp,is); *Bufo = u64_to_double(temp); return ret; }
@ -82,10 +84,10 @@ int readle(T *Bufo, EMUFILE*is)
{ {
CTASSERT(sizeof(T)==1||sizeof(T)==2||sizeof(T)==4||sizeof(T)==8); CTASSERT(sizeof(T)==1||sizeof(T)==2||sizeof(T)==4||sizeof(T)==8);
switch(sizeof(T)) { switch(sizeof(T)) {
case 1: return read8le((u8*)Bufo,is); case 1: return read8le((uint8*)Bufo,is);
case 2: return read16le((u16*)Bufo,is); case 2: return read16le((uint16*)Bufo,is);
case 4: return read32le((u32*)Bufo,is); case 4: return read32le((uint32*)Bufo,is);
case 8: return read64le((u64*)Bufo,is); case 8: return read64le((uint64*)Bufo,is);
default: default:
return 0; return 0;
} }
@ -96,10 +98,10 @@ int writele(T *Bufo, EMUFILE*os)
{ {
CTASSERT(sizeof(T)==1||sizeof(T)==2||sizeof(T)==4||sizeof(T)==8); CTASSERT(sizeof(T)==1||sizeof(T)==2||sizeof(T)==4||sizeof(T)==8);
switch(sizeof(T)) { switch(sizeof(T)) {
case 1: return write8le((u8*)Bufo,os); case 1: return write8le((uint8*)Bufo,os);
case 2: return write16le((u16*)Bufo,os); case 2: return write16le((uint16*)Bufo,os);
case 4: return write32le((u32*)Bufo,os); case 4: return write32le((uint32*)Bufo,os);
case 8: return write64le((u64*)Bufo,os); case 8: return write64le((uint64*)Bufo,os);
default: default:
return 0; return 0;
} }