sync to FCEUX r2381

This commit is contained in:
dborth 2012-01-09 01:59:06 +00:00
parent 1e9847bff9
commit fb508312c7
40 changed files with 2823 additions and 2944 deletions

View File

@ -1,93 +1,195 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 CaH4e3
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mapinc.h"
#include "mmc3.h"
static uint8 cmdin;
static uint8 UNL8237_perm[8] = {0, 2, 6, 1, 7, 3, 4, 5};
static void UNL8237CW(uint32 A, uint8 V)
{
setchr1(A,((EXPREGS[1]&4)<<6)|V);
}
static void UNL8237PW(uint32 A, uint8 V)
{
if(EXPREGS[0]&0x80)
{
if(EXPREGS[0]&0x20)
setprg32(0x8000,(EXPREGS[0]&0xF)>>1);
else
{
setprg16(0x8000,(EXPREGS[0]&0x1F));
setprg16(0xC000,(EXPREGS[0]&0x1F));
}
}
else
setprg8(A,V&0x3F);
}
static DECLFW(UNL8237Write)
{
if((A&0xF000)==0xF000)
IRQCount=V;
else if((A&0xF000)==0xE000)
X6502_IRQEnd(FCEU_IQEXT);
else switch(A&0xE001)
{
case 0x8000: setmirror(((V|(V>>7))&1)^1); break;
case 0xA000: MMC3_CMDWrite(0x8000,(V&0xC0)|(UNL8237_perm[V&7])); cmdin=1; break;
case 0xC000: if(cmdin)
{
MMC3_CMDWrite(0x8001,V);
cmdin=0;
}
break;
}
}
static DECLFW(UNL8237ExWrite)
{
switch(A)
{
case 0x5000: EXPREGS[0]=V; FixMMC3PRG(MMC3_cmd); break;
case 0x5001: EXPREGS[1]=V; FixMMC3CHR(MMC3_cmd); break;
}
}
static void UNL8237Power(void)
{
IRQa=1;
EXPREGS[0]=EXPREGS[1]=0;
GenMMC3Power();
SetWriteHandler(0x8000,0xFFFF,UNL8237Write);
SetWriteHandler(0x5000,0x7FFF,UNL8237ExWrite);
}
void UNL8237_Init(CartInfo *info)
{
GenMMC3_Init(info, 256, 256, 0, 0);
cwrap=UNL8237CW;
pwrap=UNL8237PW;
info->Power=UNL8237Power;
AddExState(EXPREGS, 3, 0, "EXPR");
AddExState(&cmdin, 1, 0, "CMDIN");
}
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005-2011 CaH4e3
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Super Game (Sugar Softec) protected mapper
* Pocahontas 2 (Unl) [U][!], etc.
* TODO: 9in1 LION KING HANGS!
*/
#include "mapinc.h"
#include "mmc3.h"
static uint8 cmdin;
static uint8 regperm[8][8] =
{
{0, 1, 2, 3, 4, 5, 6, 7},
{0, 2, 6, 1, 7, 3, 4, 5},
{0, 5, 4, 1, 7, 2, 6, 3}, // unused
{0, 6, 3, 7, 5, 2, 4, 1},
{0, 2, 5, 3, 6, 1, 7, 4},
{0, 1, 2, 3, 4, 5, 6, 7}, // empty
{0, 1, 2, 3, 4, 5, 6, 7}, // empty
{0, 1, 2, 3, 4, 5, 6, 7}, // empty
};
static uint8 adrperm[8][8] =
{
{0, 1, 2, 3, 4, 5, 6, 7},
{3, 2, 0, 4, 1, 5, 6, 7},
{0, 1, 2, 3, 4, 5, 6, 7}, // unused
{5, 0, 1, 2, 3, 7, 6, 4},
{3, 1, 0, 5, 2, 4, 6, 7},
{0, 1, 2, 3, 4, 5, 6, 7}, // empty
{0, 1, 2, 3, 4, 5, 6, 7}, // empty
{0, 1, 2, 3, 4, 5, 6, 7}, // empty
};
static void UNL8237CW(uint32 A, uint8 V)
{
if(EXPREGS[0]&0x40)
setchr1(A,((EXPREGS[1]&0xc)<<6)|(V&0x7F)|((EXPREGS[1]&0x20)<<2));
else
setchr1(A,((EXPREGS[1]&0xc)<<6)|V);
}
static void UNL8237PW(uint32 A, uint8 V)
{
if(EXPREGS[0]&0x40)
{
uint8 sbank = (EXPREGS[1]&0x10);
if(EXPREGS[0]&0x80)
{
uint8 bank = ((EXPREGS[1]&3)<<4)|(EXPREGS[0]&0x7)|(sbank>>1);
if(EXPREGS[0]&0x20)
setprg32(0x8000,bank>>1);
else
{
setprg16(0x8000,bank);
setprg16(0xC000,bank);
}
}
else
setprg8(A,((EXPREGS[1]&3)<<5)|(V&0x0F)|sbank);
}
else
{
if(EXPREGS[0]&0x80)
{
uint8 bank = ((EXPREGS[1]&3)<<4)|(EXPREGS[0]&0xF);
if(EXPREGS[0]&0x20)
setprg32(0x8000,bank>>1);
else
{
setprg16(0x8000,bank);
setprg16(0xC000,bank);
}
}
else
setprg8(A,((EXPREGS[1]&3)<<5)|(V&0x1F));
}
}
static void UNL8237ACW(uint32 A, uint8 V)
{
if(EXPREGS[0]&0x40)
setchr1(A,((EXPREGS[1]&0xE)<<7)|(V&0x7F)|((EXPREGS[1]&0x20)<<2));
else
setchr1(A,((EXPREGS[1]&0xE)<<7)|V);
}
static void UNL8237APW(uint32 A, uint8 V)
{
if(EXPREGS[0]&0x40)
{
uint8 sbank = (EXPREGS[1]&0x10);
if(EXPREGS[0]&0x80)
{
uint8 bank = ((EXPREGS[1]&3)<<4)|((EXPREGS[1]&8)<<3)|(EXPREGS[0]&0x7)|(sbank>>1);
if(EXPREGS[0]&0x20)
setprg32(0x8000,bank>>1);
else
{
setprg16(0x8000,bank);
setprg16(0xC000,bank);
}
}
else
setprg8(A,((EXPREGS[1]&3)<<5)|((EXPREGS[1]&8)<<4)|(V&0x0F)|sbank);
}
else
{
if(EXPREGS[0]&0x80)
{
uint8 bank = ((EXPREGS[1]&3)<<4)|((EXPREGS[1]&8)<<3)|(EXPREGS[0]&0xF);
if(EXPREGS[0]&0x20)
setprg32(0x8000,bank>>1);
else
{
setprg16(0x8000,bank);
setprg16(0xC000,bank);
}
}
else
setprg8(A,((EXPREGS[1]&3)<<5)|((EXPREGS[1]&8)<<4)|(V&0x1F));
}
}
static DECLFW(UNL8237Write)
{
uint8 dat = V;
uint8 adr = adrperm[EXPREGS[2]][((A>>12)&6)|(A&1)];
uint16 addr = (adr & 1)|((adr & 6)<<12)|0x8000;
if(adr < 4)
{
if(!adr)
dat = (dat & 0xC0)|(regperm[EXPREGS[2]][dat & 7]);
MMC3_CMDWrite(addr,dat);
}
else
MMC3_IRQWrite(addr,dat);
}
static DECLFW(UNL8237ExWrite)
{
switch(A)
{
case 0x5000: EXPREGS[0]=V; FixMMC3PRG(MMC3_cmd); break;
case 0x5001: EXPREGS[1]=V; FixMMC3PRG(MMC3_cmd); FixMMC3CHR(MMC3_cmd); break;
case 0x5007: EXPREGS[2]=V; break;
}
}
static void UNL8237Power(void)
{
EXPREGS[0]=EXPREGS[2]=0;
EXPREGS[1]=3;
GenMMC3Power();
SetWriteHandler(0x8000,0xFFFF,UNL8237Write);
SetWriteHandler(0x5000,0x7FFF,UNL8237ExWrite);
}
void UNL8237_Init(CartInfo *info)
{
GenMMC3_Init(info, 256, 256, 0, 0);
cwrap=UNL8237CW;
pwrap=UNL8237PW;
info->Power=UNL8237Power;
AddExState(EXPREGS, 3, 0, "EXPR");
AddExState(&cmdin, 1, 0, "CMDIN");
}
void UNL8237A_Init(CartInfo *info)
{
GenMMC3_Init(info, 256, 256, 0, 0);
cwrap=UNL8237ACW;
pwrap=UNL8237APW;
info->Power=UNL8237Power;
AddExState(EXPREGS, 3, 0, "EXPR");
AddExState(&cmdin, 1, 0, "CMDIN");
}

View File

@ -2,6 +2,7 @@
*
* Copyright notice for this file:
* Copyright (C) 2007 CaH4e3
* Copyright (C) 2011 FCEUX team
*
* 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
@ -21,6 +22,11 @@
*
*/
//Famicom Jump 2 should get transformed to m153
//All other games are not supporting EEPROM saving right now.
//We may need to distinguish between 16 and 159 in order to know the EEPROM configuration.
//Until then, we just return 0x00 from the EEPROM read
#include "mapinc.h"
static uint8 reg[16], is153;
@ -58,13 +64,7 @@ static void BandaiSync(void)
if(is153)
{
int base=(reg[0]&1)<<4;
if(!UNIFchrrama) // SD Gundam Gaiden - Knight Gundam Monogatari 2 - Hikari no Kishi (J) uses WRAM but have CHRROM too
{
int i;
for(i=0; i<8; i++) setchr1(i<<10,reg[i]);
}
else
setchr8(0);
setchr8(0);
setprg16(0x8000,(reg[8]&0x0F)|base);
setprg16(0xC000,0x0F|base);
}
@ -102,11 +102,17 @@ static DECLFW(BandaiWrite)
}
}
DECLFR(BandaiRead)
{
return 0;
}
static void BandaiPower(void)
{
BandaiSync();
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x6000,0xFFFF,BandaiWrite);
SetReadHandler(0x6000,0x7FFF,BandaiRead);
}
static void M153Power(void)
@ -141,6 +147,12 @@ void Mapper16_Init(CartInfo *info)
AddExState(&StateRegs, ~0, 0, 0);
}
void Mapper159_Init(CartInfo *info)
{
Mapper16_Init(info);
}
void Mapper153_Init(CartInfo *info)
{
is153=1;

View File

@ -20,8 +20,7 @@
#include "mapinc.h"
static uint8 bus_conflict = 0;
static uint8 latche, latcheinit;
static uint8 latche, latcheinit, bus_conflict;
static uint16 addrreg0, addrreg1;
static uint8 *WRAM=NULL;
static uint32 WRAMSIZE;
@ -41,8 +40,15 @@ static void LatchPower(void)
{
latche=latcheinit;
WSync();
SetReadHandler(0x6000,0xFFFF,CartBR);
SetWriteHandler(0x6000,0x7FFF,CartBW);
if(WRAM)
{
SetReadHandler(0x6000,0xFFFF,CartBR);
SetWriteHandler(0x6000,0x7FFF,CartBW);
}
else
{
SetReadHandler(0x8000,0xFFFF,CartBR);
}
SetWriteHandler(addrreg0,addrreg1,LatchWrite);
}
@ -58,8 +64,9 @@ static void StateRestore(int version)
WSync();
}
static void Latch_Init(CartInfo *info, void (*proc)(void), uint8 init, uint16 adr0, uint16 adr1, uint8 wram)
static void Latch_Init(CartInfo *info, void (*proc)(void), uint8 init, uint16 adr0, uint16 adr1, uint8 wram, uint8 busc)
{
bus_conflict = busc;
latcheinit=init;
addrreg0=adr0;
addrreg1=adr1;
@ -80,7 +87,6 @@ static void Latch_Init(CartInfo *info, void (*proc)(void), uint8 init, uint16 ad
AddExState(WRAM, WRAMSIZE, 0, "WRAM");
}
AddExState(&latche, 1, 0, "LATC");
AddExState(&bus_conflict, 1, 0, "BUSC");
}
//------------------ CPROM ---------------------------
@ -95,7 +101,7 @@ static void CPROMSync(void)
void CPROM_Init(CartInfo *info)
{
Latch_Init(info, CPROMSync, 0, 0x8000, 0xFFFF, 0);
Latch_Init(info, CPROMSync, 0, 0x8000, 0xFFFF, 0, 0);
}
//------------------ Map 184 ---------------------------
@ -110,7 +116,7 @@ static void M184Sync(void)
void Mapper184_Init(CartInfo *info)
{
Latch_Init(info, M184Sync, 0, 0x6000, 0x7FFF, 0);
Latch_Init(info, M184Sync, 0, 0x6000, 0x7FFF, 0, 0);
}
//------------------ CNROM ---------------------------
@ -127,8 +133,7 @@ static void CNROMSync(void)
void CNROM_Init(CartInfo *info)
{
bus_conflict = 1;
Latch_Init(info, CNROMSync, 0, 0x8000, 0xFFFF, 1);
Latch_Init(info, CNROMSync, 0, 0x8000, 0xFFFF, 1, 1);
}
//------------------ ANROM ---------------------------
@ -142,7 +147,7 @@ static void ANROMSync()
void ANROM_Init(CartInfo *info)
{
Latch_Init(info, ANROMSync, 0, 0x8000, 0xFFFF, 0);
Latch_Init(info, ANROMSync, 0, 0x8000, 0xFFFF, 0, 0);
}
//------------------ Map 70 ---------------------------
@ -156,7 +161,7 @@ static void M70Sync()
void Mapper70_Init(CartInfo *info)
{
Latch_Init(info, M70Sync, 0, 0x8000, 0xFFFF, 0);
Latch_Init(info, M70Sync, 0, 0x8000, 0xFFFF, 0, 0);
}
//------------------ Map 152 ---------------------------
@ -171,7 +176,7 @@ static void M152Sync()
void Mapper152_Init(CartInfo *info)
{
Latch_Init(info, M152Sync, 0, 0x8000, 0xFFFF, 0);
Latch_Init(info, M152Sync, 0, 0x8000, 0xFFFF, 0, 0);
}
//------------------ Map 78 ---------------------------
@ -186,7 +191,7 @@ static void M78Sync()
void Mapper78_Init(CartInfo *info)
{
Latch_Init(info, M78Sync, 0, 0x8000, 0xFFFF, 0);
Latch_Init(info, M78Sync, 0, 0x8000, 0xFFFF, 0, 0);
}
//------------------ MHROM ---------------------------
@ -199,17 +204,17 @@ static void MHROMSync(void)
void MHROM_Init(CartInfo *info)
{
Latch_Init(info, MHROMSync, 0, 0x8000, 0xFFFF, 0);
Latch_Init(info, MHROMSync, 0, 0x8000, 0xFFFF, 0, 0);
}
void Mapper140_Init(CartInfo *info)
{
Latch_Init(info, MHROMSync, 0, 0x6000, 0x7FFF, 0);
Latch_Init(info, MHROMSync, 0, 0x6000, 0x7FFF, 0, 0);
}
void Mapper240_Init(CartInfo *info)
{
Latch_Init(info, MHROMSync, 0, 0x4020, 0x5FFF, 0);
Latch_Init(info, MHROMSync, 0, 0x4020, 0x5FFF, 0, 0);
// need SRAM.
}
@ -225,7 +230,7 @@ static void M87Sync(void)
void Mapper87_Init(CartInfo *info)
{
Latch_Init(info, M87Sync, ~0, 0x6000, 0xFFFF, 0);
Latch_Init(info, M87Sync, ~0, 0x6000, 0xFFFF, 0, 0);
}
//------------------ Map 101 ---------------------------
@ -239,7 +244,7 @@ static void M101Sync(void)
void Mapper101_Init(CartInfo *info)
{
Latch_Init(info, M101Sync, ~0, 0x6000, 0x7FFF, 0);
Latch_Init(info, M101Sync, ~0, 0x6000, 0x7FFF, 0, 0);
}
//------------------ Map 11 ---------------------------
@ -252,12 +257,12 @@ static void M11Sync(void)
void Mapper11_Init(CartInfo *info)
{
Latch_Init(info, M11Sync, 0, 0x8000, 0xFFFF, 0);
Latch_Init(info, M11Sync, 0, 0x8000, 0xFFFF, 0, 0);
}
void Mapper144_Init(CartInfo *info)
{
Latch_Init(info, M11Sync, 0, 0x8001, 0xFFFF, 0);
Latch_Init(info, M11Sync, 0, 0x8001, 0xFFFF, 0, 0);
}
//------------------ Map 38 ---------------------------
@ -270,7 +275,7 @@ static void M38Sync(void)
void Mapper38_Init(CartInfo *info)
{
Latch_Init(info, M38Sync, 0, 0x7000, 0x7FFF, 0);
Latch_Init(info, M38Sync, 0, 0x7000, 0x7FFF, 0, 0);
}
//------------------ Map 36 ---------------------------
@ -283,7 +288,7 @@ static void M36Sync(void)
void Mapper36_Init(CartInfo *info)
{
Latch_Init(info, M36Sync, 0, 0x8400, 0xfffe, 0);
Latch_Init(info, M36Sync, 0, 0x8400, 0xfffe, 0, 0);
}
//------------------ UNROM ---------------------------
@ -296,8 +301,7 @@ static void UNROMSync(void)
void UNROM_Init(CartInfo *info)
{
bus_conflict = 1;
Latch_Init(info, UNROMSync, 0, 0x8000, 0xFFFF, 0);
Latch_Init(info, UNROMSync, 0, 0x8000, 0xFFFF, 0, 1);
}
//------------------ Map 93 ---------------------------
@ -311,7 +315,7 @@ static void SSUNROMSync(void)
void SUNSOFT_UNROM_Init(CartInfo *info)
{
Latch_Init(info, SSUNROMSync, 0, 0x8000, 0xFFFF, 0);
Latch_Init(info, SSUNROMSync, 0, 0x8000, 0xFFFF, 0, 0);
}
//------------------ Map 94 ---------------------------
@ -325,7 +329,7 @@ static void M94Sync(void)
void Mapper94_Init(CartInfo *info)
{
Latch_Init(info, M94Sync, 0, 0x8000, 0xFFFF, 0);
Latch_Init(info, M94Sync, 0, 0x8000, 0xFFFF, 0, 0);
}
//------------------ Map 180 ---------------------------
@ -339,7 +343,7 @@ static void M180Sync(void)
void Mapper180_Init(CartInfo *info)
{
Latch_Init(info, M180Sync, 0, 0x8000, 0xFFFF, 0);
Latch_Init(info, M180Sync, 0, 0x8000, 0xFFFF, 0, 0);
}
//------------------ Map 107 ---------------------------
@ -352,7 +356,7 @@ static void M107Sync(void)
void Mapper107_Init(CartInfo *info)
{
Latch_Init(info, M107Sync, ~0, 0x8000, 0xFFFF, 0);
Latch_Init(info, M107Sync, ~0, 0x8000, 0xFFFF, 0, 0);
}
//------------------ Map 113 ---------------------------
@ -366,7 +370,7 @@ static void M113Sync(void)
void Mapper113_Init(CartInfo *info)
{
Latch_Init(info, M113Sync, 0, 0x4100, 0x7FFF, 0);
Latch_Init(info, M113Sync, 0, 0x4100, 0x7FFF, 0, 0);
}
//------------------ A65AS ---------------------------
@ -394,7 +398,7 @@ static void BMCA65ASSync(void)
void BMCA65AS_Init(CartInfo *info)
{
Latch_Init(info, BMCA65ASSync, 0, 0x8000, 0xFFFF, 0);
Latch_Init(info, BMCA65ASSync, 0, 0x8000, 0xFFFF, 0, 0);
}
//------------------ NROM ---------------------------
@ -414,8 +418,8 @@ static void NROMPower(void)
setprg16(0xC000,~0);
setchr8(0);
SetReadHandler(0x6000,0x6FFF,CartBR);
SetWriteHandler(0x6000,0x6FFF,CartBW);
SetReadHandler(0x6000,0x7FFF,CartBR);
SetWriteHandler(0x6000,0x7FFF,CartBW);
SetReadHandler(0x8000,0xFFFF,CartBR);
#ifdef DEBUG_MAPPER
@ -437,5 +441,4 @@ void NROM_Init(CartInfo *info)
info->SaveGameLen[0]=WRAMSIZE;
}
AddExState(WRAM, WRAMSIZE, 0, "WRAM");
}

File diff suppressed because it is too large Load Diff

View File

@ -152,7 +152,6 @@ void FCEU_PowerCheats()
numsubcheats=0; /* Quick hack to prevent setting of ancient read addresses. */
RebuildSubCheats();
}
static void CheatMemErr(void)
{
FCEUD_PrintError("Error allocating memory for cheat data.");
@ -621,7 +620,8 @@ int FCEUI_SetCheat(uint32 which, const char *name, int32 a, int32 v, int compare
next->val=v;
if(s>=0)
next->status=s;
next->compare=compare;
if(compare>=0)
next->compare=compare;
next->type=type;
savecheats=1;

View File

@ -91,13 +91,14 @@ Condition* InfixOperator(const char** str, Condition(*nextPart(const char**)), i
if (t1 == 0)
{
freeTree(t);
if(t)
freeTree(t);
return 0;
}
mid = (Condition*)FCEU_dmalloc(sizeof(Condition));
if (!mid)
return NULL;
if (!mid)
return NULL;
memset(mid, 0, sizeof(Condition));
mid->lhs = t;

View File

@ -17,18 +17,19 @@ static char *aboutString = 0;
char *FCEUI_GetAboutString() {
const char *aboutTemplate =
FCEU_NAME_AND_VERSION "\n\n\
Authors:\n\
zeromus, adelikat,\n\n\
Contributers:\n\
Acmlm,CaH4e3\n\
DWEdit,QFox\n\
qeed,Shinydoofy,ugetab\n\
Administrators:\n\
zeromus, adelikat\n\n\
Current Contributors:\n\
punkrockguy318 (Lukas Sabota)\n\
Plombo (Bryan Cain)\n\
qeed, QFox, Shinydoofy, ugetab\n\
CaH4e3, gocha, Acmlm, DWEdit, AnS\n\
\n\
FCEUX 2.0\n\
FCEUX 2.0:\n\
mz, nitsujrehtona, Lukas Sabota,\n\
SP, Ugly Joe\n\
\n\n\
Previous versions:\n\n\
\n\
Previous versions:\n\
FCE - Bero\n\
FCEU - Xodnizel\n\
FCEU XD - Bbitmaster & Parasyte\n\
@ -37,6 +38,10 @@ FCEU MM - CaH4e3\n\
FCEU TAS - blip & nitsuja\n\
FCEU TAS+ - Luke Gustafson\n\
\n\
FCEUX is dedicated to the fallen heroes\n\
of NES emulation. In Memoriam --\n\
ugetab\n\
\n\
"__TIME__" "__DATE__"\n";
if(aboutString) return aboutString;

View File

@ -395,21 +395,19 @@ void LogCDData(){
uint16 A = 0;
uint8 opcode[3] = {0}, memop = 0;
j = GetPRGAddress(_PC);
if(j != -1) {
opcode[0] = GetMem(_PC);
switch (opsize[opcode[0]]) {
case 2:
opcode[1] = GetMem(_PC + 1);
break;
case 3:
opcode[1] = GetMem(_PC + 1);
opcode[2] = GetMem(_PC + 2);
break;
}
opcode[0] = GetMem(_PC);
switch (opsize[opcode[0]]) {
case 2:
opcode[1] = GetMem(_PC + 1);
break;
case 3:
opcode[1] = GetMem(_PC + 1);
opcode[2] = GetMem(_PC + 2);
break;
}
for (i = 0; i < opsize[opcode[0]]; i++){
if((j = GetPRGAddress(_PC)) != -1)
for (i = 0; i < opsize[opcode[0]]; i++) {
if(cdloggerdata[j+i] & 1)continue; //this has been logged so skip
cdloggerdata[j+i] |= 1;
cdloggerdata[j+i] |=((_PC+i)>>11)&0x0c;
@ -418,36 +416,35 @@ void LogCDData(){
if(!(cdloggerdata[j+i] & 2))undefinedcount--;
}
//log instruction jumped to in an indirect jump
if(opcode[0] == 0x6c) indirectnext = 1; else indirectnext = 0;
//log instruction jumped to in an indirect jump
if(opcode[0] == 0x6c) indirectnext = 1; else indirectnext = 0;
switch (optype[opcode[0]]) {
case 0: break;
case 1:
A = (opcode[1]+_X) & 0xFF;
A = GetMem(A) | (GetMem(A+1)<<8);
memop = 0x20;
break;
case 2: A = opcode[1]; break;
case 3: A = opcode[1] | opcode[2]<<8; break;
case 4:
A = (GetMem(opcode[1]) | (GetMem(opcode[1]+1)<<8))+_Y;
memop = 0x20;
break;
case 5: A = opcode[1]+_X; break;
case 6: A = (opcode[1] | (opcode[2]<<8))+_Y; break;
case 7: A = (opcode[1] | (opcode[2]<<8))+_X; break;
case 8: A = opcode[1]+_Y; break;
}
switch (optype[opcode[0]]) {
case 0: break;
case 1:
A = (opcode[1]+_X) & 0xFF;
A = GetMem(A) | (GetMem(A+1)<<8);
memop = 0x20;
break;
case 2: A = opcode[1]; break;
case 3: A = opcode[1] | opcode[2]<<8; break;
case 4:
A = (GetMem(opcode[1]) | (GetMem(opcode[1]+1)<<8))+_Y;
memop = 0x20;
break;
case 5: A = opcode[1]+_X; break;
case 6: A = (opcode[1] | (opcode[2]<<8))+_Y; break;
case 7: A = (opcode[1] | (opcode[2]<<8))+_X; break;
case 8: A = opcode[1]+_Y; break;
}
if((j = GetPRGAddress(A)) != -1) {
if(!(cdloggerdata[j] & 2)) {
cdloggerdata[j] |= 2;
cdloggerdata[j] |=(A>>11)&0x0c;
cdloggerdata[j] |= memop;
datacount++;
if(!(cdloggerdata[j] & 1))undefinedcount--;
}
if((j = GetPRGAddress(A)) != -1) {
if(!(cdloggerdata[j] & 2)) {
cdloggerdata[j] |= 2;
cdloggerdata[j] |=(A>>11)&0x0c;
cdloggerdata[j] |= memop;
datacount++;
if(!(cdloggerdata[j] & 1))undefinedcount--;
}
}
}

View File

@ -419,6 +419,9 @@ void DrawTextTransWH(uint8 *dest, uint32 width, uint8 *textmsg, uint8 fgcolor, i
ch = FixJoedChar(*textmsg);
wid = JoedCharWidth(*textmsg);
int newx = x+wid;
if(newx >= (int)width) { x=beginx; y+=8; }
for(int ny=0; ny<7; ++ny)
{
uint8 d = Font6x7[ch*8 + 1+ny];
@ -434,8 +437,8 @@ void DrawTextTransWH(uint8 *dest, uint32 width, uint8 *textmsg, uint8 fgcolor, i
target[y+ny][x+nx] = 1;
}
}
x += wid;
if(x >= width) { x=beginx; y+=8; }
x += wid;
}
textoverflow:
for(y=0; y<62; ++y) //Max border is 2, so the max safe y is 62 (since 64 is the max for the target array

View File

@ -211,7 +211,7 @@ void FCEUI_CheatSearchSetCurrentAsOriginal(void);
#define FCEUIOD_MOVIES 6 //.fm2 files
#define FCEUIOD_MEMW 7 //memory watch fiels
#define FCEUIOD_BBOT 8 //basicbot, obsolete
#define FCEUIOD_MACRO 9 //macro files - tasedit, currently not implemented
#define FCEUIOD_MACRO 9 //macro files - old tasedit v0.1 paradigm, not implemented, probably obsolete
#define FCEUIOD_INPUT 10 //input presets
#define FCEUIOD_LUA 11 //lua scripts
#define FCEUIOD_AVI 12 //default file for avi output
@ -274,6 +274,8 @@ void FCEUI_AviEnd(void);
void FCEUI_AviVideoUpdate(const unsigned char* buffer);
void FCEUI_AviSoundUpdate(void* soundData, int soundLen);
bool FCEUI_AviIsRecording();
bool FCEUI_AviEnableHUDrecording();
void FCEUI_SetAviEnableHUDrecording(bool enable);
bool FCEUI_AviDisableMovieMessages();
void FCEUI_SetAviDisableMovieMessages(bool disable);

View File

@ -61,7 +61,7 @@ size_t EMUFILE_MEMORY::_fread(const void *ptr, size_t bytes){
void EMUFILE_FILE::truncate(s32 length)
{
fflush(fp);
::fflush(fp);
#ifdef _MSC_VER
_chsize(_fileno(fp),length);
#else

View File

@ -32,7 +32,9 @@ THE SOFTWARE.
#include <algorithm>
#include <string>
#include <stdarg.h>
#ifdef GEKKO
#include <malloc.h>
#endif
#include "emufile_types.h"
@ -114,6 +116,7 @@ public:
virtual int ftell() = 0;
virtual int size() = 0;
virtual void fflush() = 0;
virtual void truncate(s32 length) = 0;
};
@ -141,7 +144,7 @@ public:
EMUFILE_MEMORY(void* buf, s32 size) : vec(new std::vector<u8>()), ownvec(true), pos(0), len(size) {
vec->resize(size);
if(size != 0)
memcpy(&vec[0],buf,size);
memcpy(&vec->front(),buf,size);
}
~EMUFILE_MEMORY() {
@ -245,6 +248,8 @@ public:
return pos;
}
virtual void fflush() {}
void trim()
{
vec->resize(len);
@ -391,6 +396,10 @@ public:
virtual int ftell() {
return pos;
}
virtual void fflush() {
}
void trim()
{
@ -468,7 +477,7 @@ public:
failbit = true;
}
virtual int fseek(int offset, int origin){
virtual int fseek(int offset, int origin) {
return ::fseek(fp, offset, origin);
}
@ -484,6 +493,10 @@ public:
return len;
}
virtual void fflush() {
::fflush(fp);
}
};
#endif

View File

@ -52,6 +52,9 @@
#ifdef WIN32
#include "drivers/win/pref.h"
#include "drivers/win/taseditlib/greenzone.h"
extern GREENZONE greenzone;
#endif
#include <fstream>
@ -332,29 +335,14 @@ uint8 *RAM;
static void AllocBuffers()
{
#ifdef _USE_SHARED_MEMORY_
void win_AllocBuffers(uint8 **GameMemBlock, uint8 **RAM);
win_AllocBuffers(&GameMemBlock, &RAM);
#else
GameMemBlock = (uint8*)FCEU_gmalloc(GAME_MEM_BLOCK_SIZE);
RAM = (uint8*)FCEU_gmalloc(0x800);
#endif
}
static void FreeBuffers()
{
#ifdef _USE_SHARED_MEMORY_
void win_FreeBuffers(uint8 *GameMemBlock, uint8 *RAM);
win_FreeBuffers(GameMemBlock, RAM);
#else
FCEU_free(GameMemBlock);
FCEU_free(RAM);
#endif
}
//------
@ -428,17 +416,13 @@ FCEUGI *FCEUI_LoadGameVirtual(const char *name, int OverwriteVidMode)
const char* romextensions[] = {"nes","fds",0};
fp=FCEU_fopen(name,0,"rb",0,-1,romextensions);
if(!fp)
{
return 0;
}
GetFileBase(fp->filename.c_str());
if(!fp) {
FCEU_PrintError("Error opening \"%s\"!",name);
return 0;
}
GetFileBase(fp->filename.c_str());
//---------
//file opened ok. start loading.
@ -729,8 +713,6 @@ void FCEUI_Emulate(uint8 **pXBuf, int32 **SoundBuf, int32 *SoundBufSize, int ski
}
currMovieData.TryDumpIncremental();
if (lagFlag)
{
lagCounter++;
@ -740,6 +722,11 @@ void FCEUI_Emulate(uint8 **pXBuf, int32 **SoundBuf, int32 *SoundBufSize, int ski
if (movieSubtitles)
ProcessSubtitles();
#ifdef WIN32
if(FCEUMOV_Mode(MOVIEMODE_TASEDIT))
greenzone.TryDumpIncremental(lagFlag != 0);
#endif
}
void FCEUI_CloseGame(void)
@ -831,6 +818,10 @@ void PowerNES(void)
// clear back baffer
extern uint8 *XBackBuf;
memset(XBackBuf,0,256*256);
#ifdef WIN32
Update_RAM_Search(); // Update_RAM_Watch() is also called.
#endif
}
void FCEU_ResetVidSys(void)
@ -1057,6 +1048,7 @@ bool FCEU_IsValidUI(EFCEUI ui)
case FCEUI_TASEDIT:
if(!GameInfo) return false;
if(FCEUMOV_Mode(MOVIEMODE_TASEDIT)) return false;
break;
case FCEUI_RESET:

View File

@ -900,16 +900,14 @@ void FDSClose(void)
FILE *fp;
int x;
isFDS = false;
char *fn=strdup(FCEU_MakeFName(FCEUMKF_FDS,0,0).c_str());
if(!DiskWritten) return;
if(!(fp=FCEUD_UTF8fopen(fn,"wb")))
const std::string &fn = FCEU_MakeFName(FCEUMKF_FDS,0,0);
if(!(fp=FCEUD_UTF8fopen(fn.c_str(),"wb")))
{
free(fn);
return;
}
free(fn);
for(x=0;x<TotalSides;x++)
{

View File

@ -106,43 +106,43 @@ int32 NeoFilterSound(int32 *in, int32 *out, uint32 inlen, int32 *leftover)
max=(inlen-1)<<16;
if(FSettings.soundq==2)
for(x=mrindex;x<max;x+=mrratio)
{
int32 acc=0,acc2=0;
unsigned int c;
int32 *S,*D;
for(x=mrindex;x<max;x+=mrratio)
{
int32 acc=0,acc2=0;
unsigned int c;
int32 *S,*D;
for(c=SQ2NCOEFFS,S=&in[(x>>16)-SQ2NCOEFFS],D=sq2coeffs;c;c--,D++)
{
acc+=(S[c]**D)>>6;
acc2+=(S[1+c]**D)>>6;
}
for(c=SQ2NCOEFFS,S=&in[(x>>16)-SQ2NCOEFFS],D=sq2coeffs;c;c--,D++)
{
acc+=(S[c]**D)>>6;
acc2+=(S[1+c]**D)>>6;
}
acc=((int64)acc*(65536-(x&65535))+(int64)acc2*(x&65535))>>(16+11);
*out=acc;
out++;
count++;
}
acc=((int64)acc*(65536-(x&65535))+(int64)acc2*(x&65535))>>(16+11);
*out=acc;
out++;
count++;
}
else
for(x=mrindex;x<max;x+=mrratio)
{
int32 acc=0,acc2=0;
unsigned int c;
const int32 *S,*D;
for(x=mrindex;x<max;x+=mrratio)
{
int32 acc=0,acc2=0;
unsigned int c;
const int32 *S,*D;
for(c=NCOEFFS,S=&in[(x>>16)-NCOEFFS],D=coeffs;c;c--,D++)
{
acc+=(S[c]**D)>>6;
acc2+=(S[1+c]**D)>>6;
}
for(c=NCOEFFS,S=&in[(x>>16)-NCOEFFS],D=coeffs;c;c--,D++)
{
acc+=(S[c]**D)>>6;
acc2+=(S[1+c]**D)>>6;
}
acc=((int64)acc*(65536-(x&65535))+(int64)acc2*(x&65535))>>(16+11);
*out=acc;
out++;
count++;
}
acc=((int64)acc*(65536-(x&65535))+(int64)acc2*(x&65535))>>(16+11);
*out=acc;
out++;
count++;
}
mrindex=x-max;
mrindex=x-max;
if(FSettings.soundq==2)
{

View File

@ -49,10 +49,11 @@ inline const char* ESI_Name(ESI esi)
"Zapper",
"Power Pad A",
"Power Pad B",
"Arkanoid Paddle"
"Arkanoid Paddle",
"Mouse"
};
if(esi >= SI_NONE && esi < SI_COUNT)
if(esi >= SI_NONE && esi <= SI_COUNT)
return names[esi];
else return "<invalid ESI>";
}
@ -101,7 +102,7 @@ inline const char* ESIFC_Name(ESIFC esifc)
"Top Rider"
};
if(esifc >= SIFC_NONE && esifc < SIFC_COUNT)
if(esifc >= SIFC_NONE && esifc <= SIFC_COUNT)
return names[esifc];
else return "<invalid ESIFC>";
}

View File

@ -1,252 +1,252 @@
{0x9cbadc25,5,8}, /* JustBreed */
{0x6e68e31a,16,8}, /* Dragon Ball 3*/
{0xbfc7a2e9,16,8},
{0x33b899c9,16,-1}, /* Dragon Ball - Dai Maou Fukkatsu (J) [!] */
{0x3f15d20d,153,8}, /* Famicom Jump 2 */
// {0xb049a8c4,153,-1}, /* SD Gundam Gaiden - Knight Gundam Monogatari 2 - Hikari no Kishi (J) [!] */
// NOT 16, since uses WRAM but 8000-FFFF address range for bankswitching,
{0x983d8175,157,8}, /* Datach Battle Rush */
{0x894efdbc,157,8}, /* Datach Crayon Shin Chan */
{0x19e81461,157,8}, /* Datach DBZ */
{0xbe06853f,157,8}, /* Datach J-League */
{0x0be0a328,157,8}, /* Datach SD Gundam Wars */
{0x5b457641,157,8}, /* Datach Ultraman Club */
{0xf51a7f46,157,8}, /* Datach Yuu Yuu Hakusho */
{0xe62e3382,71,-1}, /* Mig-29 Soviet Fighter */
{0x21a653c7,4,-1}, /* Super Sky Kid */
{0xdd4d9a62,209,-1}, /* Shin Samurai Spirits 2 */
{0x063b1151,209,-1}, /* Power Rangers 4 */
{0xdd8ced31,209,-1}, /* Power Rangers 3 */
{0x0c47946d,210,1}, /* Chibi Maruko Chan */
{0xbd523011,210,2}, /* Dream Master */ // may be wrong, but seems it solve most problems
{0xc247cc80,210,1}, /* Family Circuit '91 */
{0x6ec51de5,210,1}, /* Famista '92 */
{0xadffd64f,210,1}, /* Famista '93 */
{0x429103c9,210,1}, /* Famista '94 */
{0x81b7f1a8,210,1}, /* Heisei Tensai Bakabon */
{0x2447e03b,210,1}, /* Top Striker */
{0x1dc0f740,210,1}, /* Wagyan Land 2 */
{0xd323b806,210,1}, /* Wagyan Land 3 */
{0x07eb2c12,208,-1}, /* Street Fighter IV */
{0x96ce586e,189,8}, /* Street Fighter 2 YOKO */
{0x7678f1d5,207,8}, /* Fudou Myouou Den */
{0x276237b3,206,0}, /* Karnov */
{0x4e1c1e3c,206,0}, /* Karnov */
/* Some entries to sort out the minor 33/48 mess. */
{0xaebd6549,48,8}, /* Bakushou!! Jinsei Gekijou 3 */
{0x6cdc0cd9,48,8}, /* Bubble Bobble 2 */
//{0x10e24006,48,8}, /* Flintstones 2 - bad dump? */
{0x40c0ad47,48,8}, /* Flintstones 2 */
{0xa7b0536c,48,8}, /* Don Doko Don 2 */
{0x99c395f9,48,8}, /* Captain Saver */
{0x1500e835,48,8}, /* Jetsons (J) */
{0x637134e8,193,1}, /* Fighting Hero */
{0xcbf4366f,118,8}, /* Alien Syndrome (U.S. unlicensed) */
{0xb19a55dd,64,8}, /* Road Runner */
//{0x3eafd012,116,-1}, /* AV Girl Fighting */
{0x1d0f4d6b,2,1}, /* Black Bass thinging */
{0xf92be3ec,64,-1}, /* Rolling Thunder */
{0x345ee51a,245,-1}, /* DQ4c */
{0xf518dd58,7,8}, /* Captain Skyhawk */
{0x7ccb12a3,43,-1}, /* SMB2j */
{0x6f12afc5,235,-1}, /* Golden Game 150-in-1 */
{0xccc03440,156,-1},
{0xc9ee15a7,3,-1}, /* 3 is probably best. 41 WILL NOT WORK. */
{0x3e1271d5,79,1}, /* Tiles of Fate */
{0x8eab381c,113,1}, /* Death Bots */
{0xd4a76b07,79,0}, /* F-15 City Wars*/
{0xa4fbb438,79,0},
{0x1eb4a920,79,1}, /* Double Strike */
{0x345d3a1a,11,1}, /* Castle of Deceit */
{0x62ef6c79,232,8}, /* Quattro Sports -Aladdin */
{0x5caa3e61,144,1}, /* Death Race */
{0xd2699893,88,0}, /* Dragon Spirit */
{0x2f27cdef,155,8}, /* Tatakae!! Rahmen Man */
{0xcfd4a281,155,8}, /* Money Game. Yay for money! */
{0xd1691028,154,8}, /* Devil Man */
{0xc68363f6,180,0}, /* Crazy Climber */
{0xbe939fce,9,1}, /* Punchout*/
{0x5e66eaea,13,1}, /* Videomation */
{0xaf5d7aa2,-1,0}, /* Clu Clu Land */
{0xc2730c30,34,0}, /* Deadly Towers */
{0x932ff06e,34,1}, /* Classic Concentration */
{0x4c7c1af3,34,1}, /* Caesar's Palace */
{0x15141401,4,8}, /* Asmik Kun Land */
{0x59280bec,4,8}, /* Jackie Chan */
{0x4cccd878,4,8}, /* Cat Ninden Teyandee */
{0x9eefb4b4,4,8}, /* Pachi Slot Adventure 2 */
{0x5337f73c,4,8}, /* Niji no Silk Road */
{0x7474ac92,4,8}, /* Kabuki: Quantum Fighter */
{0xbb7c5f7a,89,8}, /* Mito Koumon or something similar */
/* Probably a Namco MMC3-workalike */
//{0xa5e6baf9,4,1|4}, /* Dragon Slayer 4 */
//{0xe40b4973,4,1|4}, /* Metro Cross */
//{0xd97c31b0,4,1|4}, /* Rasaaru Ishii no Childs Quest */
{0x84382231,9,0}, /* Punch Out (J) */
{0xe28f2596,0,1}, /* Pac Land (J) */
{0xfcdaca80,0,0}, /* Elevator Action */
{0xe492d45a,0,0}, /* Zippy Race */
{0x32fa246f,0,0}, /* Tag Team Pro Wrestling */
{0xc05a365b,0,0}, /* Exed Exes (J) */
{0xb3c30bea,0,0}, /* Xevious (J) */
{0x804f898a,2,1}, /* Dragon Unit */
{0xe1b260da,2,1}, /* Argos no Senshi */
{0x6d65cac6,2,0}, /* Terra Cresta */
{0x9ea1dc76,2,0}, /* Rainbow Islands */
{0x28c11d24,2,1}, /* Sukeban Deka */
{0x02863604,2,1}, /* Sukeban Deka */
{0x2bb6a0f8,2,1}, /* Sherlock Holmes */
{0x55773880,2,1}, /* Gilligan's Island */
{0x419461d0,2,1}, /* Super Cars */
{0x6e0eb43e,2,1}, /* Puss n Boots */
{0x266ce198,2,1}, /* City Adventure Touch */
//{0x48349b0b,1,8}, /* Dragon Quest 2 */
{0xd09b74dc,1,8}, /* Great Tank (J) */
{0xe8baa782,1,8}, /* Gun Hed (J) */
{0x970bd9c2,1,8}, /* Hanjuku Hero */
{0xcd7a2fd7,1,8}, /* Hanjuku Hero */
{0x63469396,1,8}, /* Hokuto no Ken 4 */
{0x291bcd7d,1,8}, /* Pachio Kun 2 */
{0xf74dfc91,1,-1}, /* Win, Lose, or Draw */
{0x3f56a392,1,8}, /* Captain Ed (J) */
{0x078ced30,1,8}, /* Choujin - Ultra Baseball */
{0x391aa1b8,1,8}, /* Bloody Warriors (J) */
{0x61a852ea,1,8}, /* Battle Stadium - Senbatsu Pro Yakyuu */
{0xfe364be5,1,8}, /* Deep Dungeon 4 */
{0xd8ee7669,1,8}, /* Adventures of Rad Gravity */
{0xa5e8d2cd,1,8}, /* Breakthru */
{0xf6fa4453,1,8}, /* Bigfoot */
{0x37ba3261,1,8}, /* Back to the Future 2 and 3 */
{0x934db14a,1,-1}, /* All-Pro Basketball */
{0xe94d5181,1,8}, /* Mirai Senshi - Lios */
{0x7156cb4d,1,8}, /* Muppet Adventure Carnival thingy */
{0x5b6ca654,1,8}, /* Barbie rev X*/
{0x57c12280,1,8}, /* Demon Sword */
{0x70f67ab7,1,8}, /* Musashi no Bouken */
{0xa9a4ea4c,1,8}, /* Satomi Hakkenden */
{0xcc3544b0,1,8}, /* Triathron */
{0x1d41cc8c,3,1}, /* Gyruss */
{0xd8eff0df,3,1}, /* Gradius (J) */
{0xdbf90772,3,0}, /* Alpha Mission */
{0xd858033d,3,0}, /* Armored Scrum Object */
{0xcf322bb3,3,1}, /* John Elway's Quarterback */
{0x9bde3267,3,1}, /* Adventures of Dino Riki */
{0x02cc3973,3,1}, /* Ninja Kid */
{0xb5d28ea2,3,1}, /* Mystery Quest - mapper 3?*/
{0xbc065fc3,3,1}, /* Pipe Dream */
{0x5b837e8d,1,8}, /* Alien Syndrome */
{0x283ad224,32,8}, /* Ai Sensei no Oshiete */
{0x5555fca3,32,8}, /* "" "" */
{0x243a8735,32,0x10|4}, /* Major League */
{0x6bc65d7e,140,1}, /* Youkai Club*/
{0xc2df0a00,140,1}, /* Bio Senshi Dan(hacked) */
{0xbde3ae9b,66,1}, /* Doraemon */
{0xd26efd78,66,1}, /* SMB Duck Hunt */
{0x811f06d9,66,1}, /* Dragon Power */
{0x3293afea,140,1}, /* Mississippi Satsujin Jiken */
{0xe46b1c5d,140,1}, /* Mississippi Satsujin Jiken */
{0xe84274c5,66,1}, /* "" "" */
{0x9552e8df,66,1}, /* Dragon Ball */
{0xba51ac6f,78,2},
{0x3d1c3137,78,8}, /* Uchuusen - Cosmo Carrier */
{0xbda8f8e4,152,8}, /* Gegege no Kitarou 2 */
{0x026c5fca,152,8}, /* Saint Seiya Ougon Densetsu */
{0x0f141525,152,8}, /* Arkanoid 2 (Japanese) */
{0xb1a94b82,152,8}, /* Pocket Zaurus */
{0xbba58be5,70,-1}, /* Family Trainer - Manhattan Police */
{0x370ceb65,70,-1}, /* Family Trainer - Meiro Dai Sakusen */
{0xdd8ed0f7,70,1}, /* Kamen Rider Club */
{0x90c773c1,118,-1}, /* Goal! 2 */
{0xb9b4d9e0,118,-1}, /* NES Play Action Football */
{0x78b657ac,118,-1}, /* Armadillo */
{0x37b62d04,118,-1}, /* Ys 3 */
{0x07d92c31,118,-1}, /* RPG Jinsei Game */
{0x2705eaeb,234,-1}, /* Maxi 15 */
{0x404b2e8b,4,2}, /* Rad Racer 2 */
{0xa912b064,51|0x800,8}, /* 11-in-1 Ball Games(has CHR ROM when it shouldn't) */
{0xc5e5c5b2,115,-1}, /* Bao Qing Tian (As).nes */
{0xcfb224e6,-1,1}, /* Dragon Ninja (J) [p1][!].nes */
{0xf46ef39a,37,-1}, /* Super Mario Bros. + Tetris + Nintendo World Cup (E) [!] */
{0x0f05ff0a,181,-1}, /* Seicross (redump) */
{0x054bd3e9,74,-1}, /* Di 4 Ci - Ji Qi Ren Dai Zhan (As) */
{0x496ac8f7,74,-1}, /* Ji Jia Zhan Shi (As) */
{0xae854cef,74,-1}, /* Jia A Fung Yun (Chinese) */
{0x2cc381f6,191,-1}, /* Sugoro Quest - Dice no Senshitachi (As) */
{0x555a555e,191,-1},
{0x98c1cd4b,192,-1},/* Ying Lie Qun Xia Zhuan (Chinese) */
{0x442f1a29,192,-1},/* Young chivalry */
{0xa9115bc1,192,-1},
{0x4c7bbb0e,192,-1},
{0xa145fae6,192,-1},
{0xa925226c,194,-1},/* Dai-2-Ji - Super Robot Taisen (As) */
{0xd5224fde,195,-1},/* Crystalis (c) */
{0x1bc0be6c,195,-1},/* Captain Tsubasa Vol 2 - Super Striker (C) */
{0x33c5df92,195,-1},
{0xb616885c,195,0}, /* CHaos WOrld (Ch)*/
{0x7f3dbf1b,195,0},
{0xdd431ba7,198,-1},/* Tenchi wo kurau 2 (c) */
{0x28192599,198,-1},
{0x700705f4,198,-1},
{0x9a2cf02c,198,-1},
{0xd8b401a7,198,-1},
{0x19b9e732,198,-1},
{0xd871d3e6,199,-1},/* Dragon Ball Z 2 - Gekishin Freeza! (C) */
{0xed481b7c,199,-1},/* Dragon Ball Z Gaiden - Saiya Jin Zetsumetsu Keikaku (C) */
{0x44c20420,199,-1},/* San Guo Zhi 2 (C) */
{0xa1dc16c0,116,-1},
{0xcc868d4e,149,-1}, /* 16 Mahjong [p1][!] */
{0x48239b42,146,-1}, /* Mahjong Companion (Sachen) [!] */
{0xb6a727fa,146,-1}, /* Papillion (As) [!] */
{0xa62b79e1,146,-1}, /* Side Winder (HES) [!] */
{0x73fb55ac,150,-1}, /* 2-in-1 Cosmo Cop + Cyber Monster (Sachen) [!] */
{0xddcbda16,150,-1}, /* 2-in-1 Tough Cop + Super Tough Cop (Sachen) [!] */
{0x47918d84,150,-1}, /* auto-upturn */
{0x29582ca1,150,-1},
{0x40dbf7a2,150,-1},
{0x5aefbc94,133,-1}, /* Jovial Race (Sachen) [a1][!] */
{0x58152b42,160,1}, /* Pipe 5 (Sachen) */
{0x22d6d5bd,4,1},
{0x6a03d3f3,114,-1},
{0x02c41438,176,-1}, /* Xing He Zhan Shi (C) */
{0x0da5e32e,101,-1}, /* new Uruusey Yatsura */
{0x4f2f1846,-1,1}, /* Famista '89 - Kaimaku Han!! (J) */
{0x6c71feae,45,-1}, /* Kunio 8-in-1 */
// {0xbdbe3c96,238,-1}, /* Contra Fighter iNES version */
{0,-1,-1}
{0x9cbadc25,5,8}, /* JustBreed */
{0x6e68e31a,16,8}, /* Dragon Ball 3*/
{0xbfc7a2e9,16,8},
{0x33b899c9,16,-1}, /* Dragon Ball - Dai Maou Fukkatsu (J) [!] */
{0x3f15d20d,153,8}, /* Famicom Jump 2 */
{0x983d8175,157,8}, /* Datach Battle Rush */
{0x894efdbc,157,8}, /* Datach Crayon Shin Chan */
{0x19e81461,157,8}, /* Datach DBZ */
{0xbe06853f,157,8}, /* Datach J-League */
{0x0be0a328,157,8}, /* Datach SD Gundam Wars */
{0x5b457641,157,8}, /* Datach Ultraman Club */
{0xf51a7f46,157,8}, /* Datach Yuu Yuu Hakusho */
{0xe62e3382,71,-1}, /* Mig-29 Soviet Fighter */
{0x21a653c7,4,-1}, /* Super Sky Kid */
{0xdd4d9a62,209,-1}, /* Shin Samurai Spirits 2 */
{0x063b1151,209,-1}, /* Power Rangers 4 */
{0xdd8ced31,209,-1}, /* Power Rangers 3 */
{0x0c47946d,210,1}, /* Chibi Maruko Chan */
{0xbd523011,210,2}, /* Dream Master */ // may be wrong, but seems it solve most problems
{0xc247cc80,210,1}, /* Family Circuit '91 */
{0x6ec51de5,210,1}, /* Famista '92 */
{0xadffd64f,210,1}, /* Famista '93 */
{0x429103c9,210,1}, /* Famista '94 */
{0x81b7f1a8,210,1}, /* Heisei Tensai Bakabon */
{0x2447e03b,210,1}, /* Top Striker */
{0x1dc0f740,210,1}, /* Wagyan Land 2 */
{0xd323b806,210,1}, /* Wagyan Land 3 */
{0x07eb2c12,208,-1}, /* Street Fighter IV */
{0x96ce586e,189,8}, /* Street Fighter 2 YOKO */
{0x7678f1d5,207,8}, /* Fudou Myouou Den */
{0x276237b3,206,0}, /* Karnov */
{0x4e1c1e3c,206,0}, /* Karnov */
/* Some entries to sort out the minor 33/48 mess. */
{0xaebd6549,48,8}, /* Bakushou!! Jinsei Gekijou 3 */
{0x6cdc0cd9,48,8}, /* Bubble Bobble 2 */
//{0x10e24006,48,8}, /* Flintstones 2 - bad dump? */
{0x40c0ad47,48,8}, /* Flintstones 2 */
{0xa7b0536c,48,8}, /* Don Doko Don 2 */
{0x99c395f9,48,8}, /* Captain Saver */
{0x1500e835,48,8}, /* Jetsons (J) */
{0x637134e8,193,1}, /* Fighting Hero */
{0xcbf4366f,118,8}, /* Alien Syndrome (U.S. unlicensed) */
{0xb19a55dd,64,8}, /* Road Runner */
//{0x3eafd012,116,-1}, /* AV Girl Fighting */
{0x1d0f4d6b,2,1}, /* Black Bass thinging */
{0xf92be3ec,64,-1}, /* Rolling Thunder */
{0x345ee51a,245,-1}, /* DQ4c */
{0xf518dd58,7,8}, /* Captain Skyhawk */
{0x7ccb12a3,43,-1}, /* SMB2j */
{0x6f12afc5,235,-1}, /* Golden Game 150-in-1 */
{0xccc03440,156,-1},
{0xc9ee15a7,3,-1}, /* 3 is probably best. 41 WILL NOT WORK. */
{0x3e1271d5,79,1}, /* Tiles of Fate */
{0x8eab381c,113,1}, /* Death Bots */
{0xd4a76b07,79,0}, /* F-15 City Wars*/
{0xa4fbb438,79,0},
{0x1eb4a920,79,1}, /* Double Strike */
{0x345d3a1a,11,1}, /* Castle of Deceit */
{0x62ef6c79,232,8}, /* Quattro Sports -Aladdin */
{0x5caa3e61,144,1}, /* Death Race */
{0xd2699893,88,0}, /* Dragon Spirit */
{0x2f27cdef,155,8}, /* Tatakae!! Rahmen Man */
{0xcfd4a281,155,8}, /* Money Game. Yay for money! */
{0xd1691028,154,8}, /* Devil Man */
{0xc68363f6,180,0}, /* Crazy Climber */
{0xbe939fce,9,1}, /* Punchout*/
{0x5e66eaea,13,1}, /* Videomation */
{0xaf5d7aa2,-1,0}, /* Clu Clu Land */
{0xc2730c30,34,0}, /* Deadly Towers */
{0x932ff06e,34,1}, /* Classic Concentration */
{0x4c7c1af3,34,1}, /* Caesar's Palace */
{0x15141401,4,8}, /* Asmik Kun Land */
{0x59280bec,4,8}, /* Jackie Chan */
{0x4cccd878,4,8}, /* Cat Ninden Teyandee */
{0x9eefb4b4,4,8}, /* Pachi Slot Adventure 2 */
{0x5337f73c,4,8}, /* Niji no Silk Road */
{0x7474ac92,4,8}, /* Kabuki: Quantum Fighter */
{0xbb7c5f7a,89,8}, /* Mito Koumon or something similar */
/* Probably a Namco MMC3-workalike */
//{0xa5e6baf9,4,1|4}, /* Dragon Slayer 4 */
//{0xe40b4973,4,1|4}, /* Metro Cross */
//{0xd97c31b0,4,1|4}, /* Rasaaru Ishii no Childs Quest */
{0x84382231,9,0}, /* Punch Out (J) */
{0xe28f2596,0,1}, /* Pac Land (J) */
{0xfcdaca80,0,0}, /* Elevator Action */
{0xe492d45a,0,0}, /* Zippy Race */
{0x32fa246f,0,0}, /* Tag Team Pro Wrestling */
{0xc05a365b,0,0}, /* Exed Exes (J) */
{0xb3c30bea,0,0}, /* Xevious (J) */
{0x804f898a,2,1}, /* Dragon Unit */
{0xe1b260da,2,1}, /* Argos no Senshi */
{0x6d65cac6,2,0}, /* Terra Cresta */
{0x9ea1dc76,2,0}, /* Rainbow Islands */
{0x28c11d24,2,1}, /* Sukeban Deka */
{0x02863604,2,1}, /* Sukeban Deka */
{0x2bb6a0f8,2,1}, /* Sherlock Holmes */
{0x55773880,2,1}, /* Gilligan's Island */
{0x419461d0,2,1}, /* Super Cars */
{0x6e0eb43e,2,1}, /* Puss n Boots */
{0x266ce198,2,1}, /* City Adventure Touch */
//{0x48349b0b,1,8}, /* Dragon Quest 2 */
{0xd09b74dc,1,8}, /* Great Tank (J) */
{0xe8baa782,1,8}, /* Gun Hed (J) */
{0x970bd9c2,1,8}, /* Hanjuku Hero */
{0xcd7a2fd7,1,8}, /* Hanjuku Hero */
{0x63469396,1,8}, /* Hokuto no Ken 4 */
{0x291bcd7d,1,8}, /* Pachio Kun 2 */
{0xf74dfc91,1,-1}, /* Win, Lose, or Draw */
{0x3f56a392,1,8}, /* Captain Ed (J) */
{0x078ced30,1,8}, /* Choujin - Ultra Baseball */
{0x391aa1b8,1,8}, /* Bloody Warriors (J) */
{0x61a852ea,1,8}, /* Battle Stadium - Senbatsu Pro Yakyuu */
{0xfe364be5,1,8}, /* Deep Dungeon 4 */
{0xd8ee7669,1,8}, /* Adventures of Rad Gravity */
{0xa5e8d2cd,1,8}, /* Breakthru */
{0xf6fa4453,1,8}, /* Bigfoot */
{0x37ba3261,1,8}, /* Back to the Future 2 and 3 */
{0x934db14a,1,-1}, /* All-Pro Basketball */
{0xe94d5181,1,8}, /* Mirai Senshi - Lios */
{0x7156cb4d,1,8}, /* Muppet Adventure Carnival thingy */
{0x5b6ca654,1,8}, /* Barbie rev X*/
{0x57c12280,1,8}, /* Demon Sword */
{0x70f67ab7,1,8}, /* Musashi no Bouken */
{0xa9a4ea4c,1,8}, /* Satomi Hakkenden */
{0xcc3544b0,1,8}, /* Triathron */
{0x1d41cc8c,3,1}, /* Gyruss */
{0xd8eff0df,3,1}, /* Gradius (J) */
{0xdbf90772,3,0}, /* Alpha Mission */
{0xd858033d,3,0}, /* Armored Scrum Object */
{0xcf322bb3,3,1}, /* John Elway's Quarterback */
{0x9bde3267,3,1}, /* Adventures of Dino Riki */
{0x02cc3973,3,1}, /* Ninja Kid */
{0xb5d28ea2,3,1}, /* Mystery Quest - mapper 3?*/
{0xbc065fc3,3,1}, /* Pipe Dream */
{0x5b837e8d,1,8}, /* Alien Syndrome */
{0x283ad224,32,8}, /* Ai Sensei no Oshiete */
{0x5555fca3,32,8}, /* "" "" */
{0x243a8735,32,0x10|4}, /* Major League */
{0x6bc65d7e,140,1}, /* Youkai Club*/
{0xc2df0a00,140,1}, /* Bio Senshi Dan(hacked) */
{0xbde3ae9b,66,1}, /* Doraemon */
{0xd26efd78,66,1}, /* SMB Duck Hunt */
{0x811f06d9,66,1}, /* Dragon Power */
{0x3293afea,140,1}, /* Mississippi Satsujin Jiken */
{0xe46b1c5d,140,1}, /* Mississippi Satsujin Jiken */
{0xe84274c5,66,1}, /* "" "" */
{0x9552e8df,66,1}, /* Dragon Ball */
{0xba51ac6f,78,2},
{0x3d1c3137,78,8}, /* Uchuusen - Cosmo Carrier */
{0xbda8f8e4,152,8}, /* Gegege no Kitarou 2 */
{0x026c5fca,152,8}, /* Saint Seiya Ougon Densetsu */
{0x0f141525,152,8}, /* Arkanoid 2 (Japanese) */
{0xb1a94b82,152,8}, /* Pocket Zaurus */
{0xbba58be5,70,-1}, /* Family Trainer - Manhattan Police */
{0x370ceb65,70,-1}, /* Family Trainer - Meiro Dai Sakusen */
{0xdd8ed0f7,70,1}, /* Kamen Rider Club */
{0x90c773c1,118,-1}, /* Goal! 2 */
{0xb9b4d9e0,118,-1}, /* NES Play Action Football */
{0x78b657ac,118,-1}, /* Armadillo */
{0x37b62d04,118,-1}, /* Ys 3 */
{0x07d92c31,118,-1}, /* RPG Jinsei Game */
{0x2705eaeb,234,-1}, /* Maxi 15 */
{0x404b2e8b,4,2}, /* Rad Racer 2 */
{0xa912b064,51|0x800,8}, /* 11-in-1 Ball Games(has CHR ROM when it shouldn't) */
{0xc5e5c5b2,115,-1}, /* Bao Qing Tian (As).nes */
{0xcfb224e6,-1,1}, /* Dragon Ninja (J) [p1][!].nes */
{0xf46ef39a,37,-1}, /* Super Mario Bros. + Tetris + Nintendo World Cup (E) [!] */
{0x0f05ff0a,181,-1}, /* Seicross (redump) */
{0x054bd3e9,74,-1}, /* Di 4 Ci - Ji Qi Ren Dai Zhan (As) */
{0x496ac8f7,74,-1}, /* Ji Jia Zhan Shi (As) */
{0xae854cef,74,-1}, /* Jia A Fung Yun (Chinese) */
{0x2cc381f6,191,-1}, /* Sugoro Quest - Dice no Senshitachi (As) */
{0x555a555e,191,-1},
{0x98c1cd4b,192,-1},/* Ying Lie Qun Xia Zhuan (Chinese) */
{0x442f1a29,192,-1},/* Young chivalry */
{0xa9115bc1,192,-1},
{0x4c7bbb0e,192,-1},
{0xa145fae6,192,-1},
{0xa925226c,194,-1},/* Dai-2-Ji - Super Robot Taisen (As) */
{0xd5224fde,195,-1},/* Crystalis (c) */
{0x1bc0be6c,195,-1},/* Captain Tsubasa Vol 2 - Super Striker (C) */
{0x33c5df92,195,-1},
{0xb616885c,195,0}, /* CHaos WOrld (Ch)*/
{0x7f3dbf1b,195,0},
{0xdd431ba7,198,-1},/* Tenchi wo kurau 2 (c) */
{0x28192599,198,-1},
{0x700705f4,198,-1},
{0x9a2cf02c,198,-1},
{0xd8b401a7,198,-1},
{0x19b9e732,198,-1},
{0xd871d3e6,199,-1},/* Dragon Ball Z 2 - Gekishin Freeza! (C) */
{0xed481b7c,199,-1},/* Dragon Ball Z Gaiden - Saiya Jin Zetsumetsu Keikaku (C) */
{0x44c20420,199,-1},/* San Guo Zhi 2 (C) */
{0xa1dc16c0,116,-1},
{0xcc868d4e,149,-1}, /* 16 Mahjong [p1][!] */
{0x48239b42,146,-1}, /* Mahjong Companion (Sachen) [!] */
{0xb6a727fa,146,-1}, /* Papillion (As) [!] */
{0xa62b79e1,146,-1}, /* Side Winder (HES) [!] */
{0x73fb55ac,150,-1}, /* 2-in-1 Cosmo Cop + Cyber Monster (Sachen) [!] */
{0xddcbda16,150,-1}, /* 2-in-1 Tough Cop + Super Tough Cop (Sachen) [!] */
{0x47918d84,150,-1}, /* auto-upturn */
{0x29582ca1,150,-1},
{0x40dbf7a2,150,-1},
{0x5aefbc94,133,-1}, /* Jovial Race (Sachen) [a1][!] */
{0x58152b42,160,1}, /* Pipe 5 (Sachen) */
{0x22d6d5bd,4,1},
{0x6a03d3f3,114,-1},
{0x0d98db53,114,-1}, /* Pocahontas */
{0x4e7729ff,114,-1}, /* Super Donkey Kong */
{0x02c41438,176,-1}, /* Xing He Zhan Shi (C) */
{0x0da5e32e,101,-1}, /* new Uruusey Yatsura */
{0x4f2f1846,-1,1}, /* Famista '89 - Kaimaku Han!! (J) */
{0x6c71feae,45,-1}, /* Kunio 8-in-1 */
// {0xbdbe3c96,238,-1}, /* Contra Fighter iNES version */
{0,-1,-1}

View File

@ -23,10 +23,6 @@
#include <stdlib.h>
#include <string.h>
#ifdef _USE_SHARED_MEMORY_
#include <windows.h>
#endif
#include "types.h"
#include "x6502.h"
#include "fceu.h"
@ -55,9 +51,6 @@ uint8 *VROM = NULL;
iNES_HEADER head ;
#ifdef _USE_SHARED_MEMORY_
HANDLE mapROM = NULL, mapVROM = NULL;
#endif
CartInfo iNESCart;
@ -70,6 +63,7 @@ uint32 ROM_size=0;
uint32 VROM_size=0;
char LoadedRomFName[2048]; //mbg merge 7/17/06 added
static int CHRRAMSize = -1;
static void iNESPower(void);
static int NewiNES_Init(int num);
@ -88,6 +82,28 @@ static DECLFR(TrainerRead)
return(trainerpoo[A&0x1FF]);
}
static void iNES_ExecPower()
{
if(CHRRAMSize != -1)
FCEU_MemoryRand(VROM,CHRRAMSize);
if(iNESCart.Power)
iNESCart.Power();
if(trainerpoo)
{
int x;
for(x=0;x<512;x++)
{
X6502_DMW(0x7000+x,trainerpoo[x]);
if(X6502_DMR(0x7000+x)!=trainerpoo[x])
{
SetReadHandler(0x7000,0x71FF,TrainerRead);
break;
}
}
}
}
void iNESGI(GI h) //bbit edited: removed static keyword
{
@ -104,21 +120,8 @@ void iNESGI(GI h) //bbit edited: removed static keyword
iNESCart.Reset();
break;
case GI_POWER:
if(iNESCart.Power)
iNESCart.Power();
if(trainerpoo)
{
int x;
for(x=0;x<512;x++)
{
X6502_DMW(0x7000+x,trainerpoo[x]);
if(X6502_DMR(0x7000+x)!=trainerpoo[x])
{
SetReadHandler(0x7000,0x71FF,TrainerRead);
break;
}
}
}
iNES_ExecPower();
break;
case GI_CLOSE:
{
@ -127,35 +130,8 @@ void iNESGI(GI h) //bbit edited: removed static keyword
#endif
if(iNESCart.Close) iNESCart.Close();
#ifdef _USE_SHARED_MEMORY_
if(ROM)
{
if(mapROM)
{
CloseHandle(mapROM);
mapROM = NULL;
UnmapViewOfFile(ROM);
}
else
free(ROM);
ROM = NULL;
}
if(VROM)
{
if(mapVROM)
{
CloseHandle(mapVROM);
mapVROM = NULL;
UnmapViewOfFile(VROM);
}
else
free(VROM);
VROM = NULL;
}
#else
if(ROM) {free(ROM); ROM = NULL;}
if(VROM) {free(VROM); VROM = NULL;}
#endif
if(MapClose) MapClose();
if(trainerpoo) {FCEU_gfree(trainerpoo);trainerpoo=0;}
}
@ -419,20 +395,7 @@ static void CheckHInfo(void)
if(moo[x].mapper&0x800 && VROM_size)
{
VROM_size=0;
#ifdef _USE_SHARED_MEMORY_
if(mapVROM)
{
CloseHandle(mapVROM);
UnmapViewOfFile(VROM);
mapVROM = NULL;
}
else
{
free(VROM);
}
#else
free(VROM);
#endif
VROM = NULL;
tofix|=8;
}
@ -615,6 +578,7 @@ static BMAPPINGLocal bmap[] = {
{"", 153, Mapper153_Init},
{"", 154, Mapper154_Init},
{"", 155, Mapper155_Init},
{"", 159, Mapper159_Init},
{"SA009", 160, SA009_Init},
{"", 163, Mapper163_Init},
{"", 164, Mapper164_Init},
@ -629,7 +593,7 @@ static BMAPPINGLocal bmap[] = {
{"", 178, Mapper178_Init},
{"", 180, Mapper180_Init},
{"", 181, Mapper181_Init},
{"", 182, Mapper182_Init},
// {"", 182, Mapper182_Init}, // identical to 114
{"", 183, Mapper183_Init},
{"", 184, Mapper184_Init},
{"", 185, Mapper185_Init},
@ -652,9 +616,9 @@ static BMAPPINGLocal bmap[] = {
{"", 209, Mapper209_Init},
{"", 210, Mapper210_Init},
{"", 211, Mapper211_Init},
{"", 215, Mapper215_Init},
{"", 215, UNL8237_Init},
{"", 216, Mapper216_Init},
{"", 217, Mapper217_Init},
// {"", 217, Mapper217_Init},
{"UNLA9746", 219, UNLA9746_Init},
{"OneBus", 220, UNLOneBus_Init},
@ -736,63 +700,6 @@ int iNESLoad(const char *name, FCEUFILE *fp, int OverwriteVidMode)
if(head.ROM_type&8) Mirroring=2;
#ifdef _USE_SHARED_MEMORY_
mapROM = CreateFileMapping((HANDLE)0xFFFFFFFF,NULL,PAGE_READWRITE, 0, ROM_size<<14,"fceu.ROM");
if(mapROM == NULL || GetLastError() == ERROR_ALREADY_EXISTS)
{
if((ROM = (uint8 *)FCEU_malloc(ROM_size<<14)) == NULL) return 0;
}
else
{
if((ROM = (uint8 *)MapViewOfFile(mapROM, FILE_MAP_WRITE, 0, 0, 0)) == NULL)
{
CloseHandle(mapROM);
mapROM = NULL;
if((ROM = (uint8 *)FCEU_malloc(ROM_size<<14)) == NULL) return 0;
}
}
if(VROM_size)
{
mapVROM = CreateFileMapping((HANDLE)0xFFFFFFFF,NULL,PAGE_READWRITE, 0, VROM_size<<13,"fceu.VROM");
if(mapVROM == NULL || GetLastError() == ERROR_ALREADY_EXISTS)
{
if((VROM=(uint8 *)FCEU_malloc(VROM_size<<13)) == NULL)
{
if(mapROM)
{
UnmapViewOfFile(mapROM);
mapROM = NULL;
CloseHandle(ROM);
}
else
free(ROM);
ROM = NULL;
return 0;
}
}
else
{
if((VROM = (uint8 *)MapViewOfFile(mapVROM, FILE_MAP_WRITE, 0, 0, 0)) == NULL)
{
CloseHandle(mapVROM);
mapVROM = NULL;
if((VROM=(uint8 *)FCEU_malloc(VROM_size<<13)) == NULL)
{
if(mapROM)
{
UnmapViewOfFile(mapROM);
mapROM = NULL;
CloseHandle(ROM);
}
else
free(ROM);
ROM = NULL;
return 0;
}
}
}
}
#else
if((ROM = (uint8 *)FCEU_malloc(ROM_size<<14)) == NULL) return 0;
if(VROM_size)
@ -804,7 +711,6 @@ int iNESLoad(const char *name, FCEUFILE *fp, int OverwriteVidMode)
return 0;
}
}
#endif
memset(ROM,0xFF,ROM_size<<14);
if(VROM_size) memset(VROM,0xFF,VROM_size<<13);
if(head.ROM_type&4) /* Trainer */
@ -954,7 +860,11 @@ int iNesSave(){
fp = fopen(name,"wb");
if(fwrite(&head,1,16,fp)!=16)return 0;
if(fwrite(&head,1,16,fp)!=16)
{
fclose(fp);
return 0;
}
if(head.ROM_type&4) /* Trainer */
{
@ -981,7 +891,11 @@ int iNesSaveAs(char* name)
int x = 0;
if (!fp)
int x = 1;
if(fwrite(&head,1,16,fp)!=16)return 0;
if(fwrite(&head,1,16,fp)!=16)
{
fclose(fp);
return 0;
}
if(head.ROM_type&4) /* Trainer */
{
@ -1406,12 +1320,12 @@ void iNESStateRestore(int version)
if(0) switch(Mirroring)
{
case 0:setmirror(MI_H);break;
case 1:setmirror(MI_V);break;
case 0x12:
case 0x10:setmirror(MI_0);break;
case 0x13:
case 0x11:setmirror(MI_1);break;
case 0:setmirror(MI_H);break;
case 1:setmirror(MI_V);break;
case 0x12:
case 0x10:setmirror(MI_0);break;
case 0x13:
case 0x11:setmirror(MI_1);break;
}
if(MapStateRestore) MapStateRestore(version);
}
@ -1437,9 +1351,9 @@ static void iNESPower(void)
all of the iNES mapper code... */
IRQCount=IRQLatch=IRQa=0;
if(head.ROM_type&2)
memset(GameMemBlock+8192,0,GAME_MEM_BLOCK_SIZE-8192);
memset(GameMemBlock+8192,0,GAME_MEM_BLOCK_SIZE-8192);
else
memset(GameMemBlock,0,GAME_MEM_BLOCK_SIZE);
memset(GameMemBlock,0,GAME_MEM_BLOCK_SIZE);
NONE_init();
ResetExState(0,0);
@ -1484,6 +1398,8 @@ static int NewiNES_Init(int num)
{
BMAPPINGLocal *tmp=bmap;
CHRRAMSize = -1;
if(GameInfo->type == GIT_VSUNI)
AddExState(FCEUVSUNI_STATEINFO, ~0, 0, 0);
@ -1494,7 +1410,6 @@ static int NewiNES_Init(int num)
UNIFchrrama=0; // need here for compatibility with UNIF mapper code
if(!VROM_size)
{
int CHRRAMSize;
if(num==13)
{
CHRRAMSize=16384;
@ -1503,26 +1418,9 @@ static int NewiNES_Init(int num)
{
CHRRAMSize=8192;
}
#ifdef _USE_SHARED_MEMORY_
mapVROM = CreateFileMapping((HANDLE)0xFFFFFFFF,NULL,PAGE_READWRITE, 0, CHRRAMSize,"fceu.VROM");
if(mapVROM == NULL || GetLastError() == ERROR_ALREADY_EXISTS)
{
CloseHandle(mapVROM);
mapVROM = NULL;
if((VROM = (uint8 *)FCEU_dmalloc(CHRRAMSize)) == NULL) return 0;
}
else
{
if((VROM = (uint8 *)MapViewOfFile(mapVROM, FILE_MAP_WRITE, 0, 0, 0)) == NULL)
{
CloseHandle(mapVROM);
mapVROM = NULL;
if((VROM = (uint8 *)FCEU_dmalloc(CHRRAMSize)) == NULL) return 0;
}
}
#else
if((VROM = (uint8 *)FCEU_dmalloc(CHRRAMSize)) == NULL) return 0;
#endif
FCEU_MemoryRand(VROM,CHRRAMSize);
UNIFchrrama=VROM;
SetupCartCHRMapping(0,VROM,CHRRAMSize,1);
AddExState(VROM,CHRRAMSize, 0, "CHRR");

View File

@ -406,6 +406,7 @@ void Mapper152_Init(CartInfo *);
void Mapper153_Init(CartInfo *);
void Mapper154_Init(CartInfo *);
void Mapper155_Init(CartInfo *);
void Mapper159_Init(CartInfo *);
void Mapper163_Init(CartInfo *);
void Mapper164_Init(CartInfo *);
void Mapper165_Init(CartInfo *);
@ -418,7 +419,7 @@ void Mapper177_Init(CartInfo *);
void Mapper178_Init(CartInfo *);
void Mapper180_Init(CartInfo *);
void Mapper181_Init(CartInfo *);
void Mapper182_Init(CartInfo *);
//void Mapper182_Init(CartInfo *);
void Mapper183_Init(CartInfo *);
void Mapper184_Init(CartInfo *);
void Mapper185_Init(CartInfo *);
@ -440,9 +441,9 @@ void Mapper208_Init(CartInfo *);
void Mapper209_Init(CartInfo *);
void Mapper210_Init(CartInfo *);
void Mapper211_Init(CartInfo *);
void Mapper215_Init(CartInfo *);
//void Mapper215_Init(CartInfo *);
void Mapper216_Init(CartInfo *);
void Mapper217_Init(CartInfo *);
//void Mapper217_Init(CartInfo *);
void Mapper220_Init(CartInfo *);
void Mapper222_Init(CartInfo *);
void Mapper226_Init(CartInfo *);

View File

@ -49,7 +49,16 @@
#include "drivers/win/cdlogger.h"
#include "drivers/win/tracer.h"
#include "drivers/win/memview.h"
#include "drivers/win/window.h"
#include "drivers/win/ntview.h"
#include "./drivers/win/taseditlib/taseditor_window.h"
#include "./drivers/win/taseditlib/markers.h"
#include "./drivers/win/taseditlib/inputsnapshot.h"
#include "./drivers/win/taseditlib/bookmarks.h"
extern bool Taseditor_rewind_now;
extern BOOKMARKS bookmarks;
extern TASEDITOR_WINDOW taseditor_window;
#endif // WIN32
//it is easier to declare these input drivers extern here than include a bunch of files
@ -71,7 +80,10 @@ extern INPUTCFC *FCEU_InitFamilyTrainerB(void);
extern INPUTCFC *FCEU_InitOekaKids(void);
extern INPUTCFC *FCEU_InitTopRider(void);
extern INPUTCFC *FCEU_InitBarcodeWorld(void);
#ifdef GEKKO
extern INPUTCFC *FCEU_InitFamicom3D(void);
#endif
//---------------
//global lag variables
@ -88,10 +100,6 @@ static uint8 LastStrobe;
bool replaceP2StartWithMicrophone = false;
#ifdef _USE_SHARED_MEMORY_
static uint32 BotPointer = 0; //mbg merge 7/18/06 changed to uint32
#endif
//This function is a quick hack to get the NSF player to use emulated gamepad input.
uint8 FCEU_GetJoyJoy(void)
{
@ -407,7 +415,11 @@ static void SetInputStuffFC()
switch(portFC.type)
{
case SIFC_NONE:
portFC.driver=FCEU_InitFamicom3D(); //CAK: originally this used &DummyPortFC;
#ifdef GEKKO
portFC.driver=FCEU_InitFamicom3D();
#else
portFC.driver=&DummyPortFC;
#endif
break;
case SIFC_ARKANOID:
portFC.driver=FCEU_InitArkanoidFC();
@ -588,6 +600,7 @@ void FCEUI_ResetNES(void)
return;
FCEU_QSimpleCommand(FCEUNPCMD_RESET);
ResetFrameCounter();
FCEU_DispMessage("Soft reset", 0);
}
//Powers off the NES
@ -597,6 +610,7 @@ void FCEUI_PowerNES(void)
return;
FCEU_QSimpleCommand(FCEUNPCMD_POWER);
ResetFrameCounter();
FCEU_DispMessage("Power switch", 0);
}
const char* FCEUI_CommandTypeNames[]=
@ -622,12 +636,13 @@ static void CommandSoundAdjust(void);
static void CommandUsePreset(void);
static void BackgroundDisplayToggle(void);
static void ObjectDisplayToggle(void);
static void LagCounterToggle(void);
static void ViewSlots(void);
static void LaunchTasEdit(void);
static void LaunchMemoryWatch(void);
static void LaunchCheats(void);
static void LaunchDebugger(void);
static void LaunchPPU(void);
static void LaunchNTView(void);
static void LaunchHex(void);
static void LaunchTraceLogger(void);
static void LaunchCodeDataLogger(void);
@ -642,10 +657,13 @@ static void RamSearchOpNE(void);
static void FA_SkipLag(void);
static void OpenRom(void);
static void CloseRom(void);
static void ReloadRom(void);
static void MovieSubtitleToggle(void);
static void UndoRedoSavestate(void);
static void FCEUI_DoExit(void);
static void ToggleFullscreen(void);
static void TaseditRewindOn(void);
static void TaseditRewindOff(void);
struct EMUCMDTABLE FCEUI_CommandTable[]=
{
@ -654,71 +672,71 @@ struct EMUCMDTABLE FCEUI_CommandTable[]=
{ EMUCMD_PAUSE, EMUCMDTYPE_MISC, FCEUI_ToggleEmulationPause, 0, 0, "Pause", EMUCMDFLAG_TASEDIT },
{ EMUCMD_FRAME_ADVANCE, EMUCMDTYPE_MISC, FCEUI_FrameAdvance, FCEUI_FrameAdvanceEnd, 0, "Frame Advance", EMUCMDFLAG_TASEDIT },
{ EMUCMD_SCREENSHOT, EMUCMDTYPE_MISC, FCEUI_SaveSnapshot, 0, 0, "Screenshot", EMUCMDFLAG_TASEDIT },
{ EMUCMD_HIDE_MENU_TOGGLE, EMUCMDTYPE_MISC, FCEUD_HideMenuToggle, 0, 0, "Hide Menu Toggle", EMUCMDFLAG_TASEDIT },
{ EMUCMD_HIDE_MENU_TOGGLE, EMUCMDTYPE_MISC, FCEUD_HideMenuToggle, 0, 0, "Hide Menu Toggle", 0 },
{ EMUCMD_EXIT, EMUCMDTYPE_MISC, FCEUI_DoExit, 0, 0, "Exit", 0},
{ EMUCMD_SPEED_SLOWEST, EMUCMDTYPE_SPEED, CommandEmulationSpeed, 0, 0, "Slowest Speed", 0 },
{ EMUCMD_SPEED_SLOWER, EMUCMDTYPE_SPEED, CommandEmulationSpeed, 0, 0, "Speed Down", 0 },
{ EMUCMD_SPEED_NORMAL, EMUCMDTYPE_SPEED, CommandEmulationSpeed, 0, 0, "Normal Speed", 0 },
{ EMUCMD_SPEED_FASTER, EMUCMDTYPE_SPEED, CommandEmulationSpeed, 0, 0, "Speed Up", 0 },
{ EMUCMD_SPEED_SLOWEST, EMUCMDTYPE_SPEED, CommandEmulationSpeed, 0, 0, "Slowest Speed", EMUCMDFLAG_TASEDIT },
{ EMUCMD_SPEED_SLOWER, EMUCMDTYPE_SPEED, CommandEmulationSpeed, 0, 0, "Speed Down", EMUCMDFLAG_TASEDIT },
{ EMUCMD_SPEED_NORMAL, EMUCMDTYPE_SPEED, CommandEmulationSpeed, 0, 0, "Normal Speed", EMUCMDFLAG_TASEDIT },
{ EMUCMD_SPEED_FASTER, EMUCMDTYPE_SPEED, CommandEmulationSpeed, 0, 0, "Speed Up", EMUCMDFLAG_TASEDIT },
{ EMUCMD_SPEED_FASTEST, EMUCMDTYPE_SPEED, CommandEmulationSpeed, 0, 0, "Fastest Speed", 0 },
{ EMUCMD_SPEED_TURBO, EMUCMDTYPE_SPEED, FCEUD_TurboOn, FCEUD_TurboOff, 0, "Turbo", EMUCMDFLAG_TASEDIT },
{ EMUCMD_SPEED_TURBO_TOGGLE, EMUCMDTYPE_SPEED, FCEUD_TurboToggle, 0, 0, "Turbo Toggle", EMUCMDFLAG_TASEDIT },
{ EMUCMD_SAVE_SLOT_0, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Savestate Slot 0", 0 },
{ EMUCMD_SAVE_SLOT_1, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Savestate Slot 1", 0 },
{ EMUCMD_SAVE_SLOT_2, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Savestate Slot 2", 0 },
{ EMUCMD_SAVE_SLOT_3, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Savestate Slot 3", 0 },
{ EMUCMD_SAVE_SLOT_4, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Savestate Slot 4", 0 },
{ EMUCMD_SAVE_SLOT_5, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Savestate Slot 5", 0 },
{ EMUCMD_SAVE_SLOT_6, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Savestate Slot 6", 0 },
{ EMUCMD_SAVE_SLOT_7, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Savestate Slot 7", 0 },
{ EMUCMD_SAVE_SLOT_8, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Savestate Slot 8", 0 },
{ EMUCMD_SAVE_SLOT_9, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Savestate Slot 9", 0 },
{ EMUCMD_SAVE_SLOT_0, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Savestate Slot 0", EMUCMDFLAG_TASEDIT },
{ EMUCMD_SAVE_SLOT_1, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Savestate Slot 1", EMUCMDFLAG_TASEDIT },
{ EMUCMD_SAVE_SLOT_2, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Savestate Slot 2", EMUCMDFLAG_TASEDIT },
{ EMUCMD_SAVE_SLOT_3, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Savestate Slot 3", EMUCMDFLAG_TASEDIT },
{ EMUCMD_SAVE_SLOT_4, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Savestate Slot 4", EMUCMDFLAG_TASEDIT },
{ EMUCMD_SAVE_SLOT_5, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Savestate Slot 5", EMUCMDFLAG_TASEDIT },
{ EMUCMD_SAVE_SLOT_6, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Savestate Slot 6", EMUCMDFLAG_TASEDIT },
{ EMUCMD_SAVE_SLOT_7, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Savestate Slot 7", EMUCMDFLAG_TASEDIT },
{ EMUCMD_SAVE_SLOT_8, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Savestate Slot 8", EMUCMDFLAG_TASEDIT },
{ EMUCMD_SAVE_SLOT_9, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Savestate Slot 9", EMUCMDFLAG_TASEDIT },
{ EMUCMD_SAVE_SLOT_NEXT, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Next Savestate Slot", 0 },
{ EMUCMD_SAVE_SLOT_PREV, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Previous Savestate Slot", 0 },
{ EMUCMD_SAVE_STATE, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State", 0 },
{ EMUCMD_SAVE_STATE_AS, EMUCMDTYPE_STATE, FCEUD_SaveStateAs, 0, 0, "Save State As...", 0 },
{ EMUCMD_SAVE_STATE_SLOT_0, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State to Slot 0", 0 },
{ EMUCMD_SAVE_STATE_SLOT_1, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State to Slot 1", 0 },
{ EMUCMD_SAVE_STATE_SLOT_2, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State to Slot 2", 0 },
{ EMUCMD_SAVE_STATE_SLOT_3, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State to Slot 3", 0 },
{ EMUCMD_SAVE_STATE_SLOT_4, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State to Slot 4", 0 },
{ EMUCMD_SAVE_STATE_SLOT_5, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State to Slot 5", 0 },
{ EMUCMD_SAVE_STATE_SLOT_6, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State to Slot 6", 0 },
{ EMUCMD_SAVE_STATE_SLOT_7, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State to Slot 7", 0 },
{ EMUCMD_SAVE_STATE_SLOT_8, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State to Slot 8", 0 },
{ EMUCMD_SAVE_STATE_SLOT_9, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State to Slot 9", 0 },
{ EMUCMD_SAVE_STATE_SLOT_0, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State to Slot 0", EMUCMDFLAG_TASEDIT },
{ EMUCMD_SAVE_STATE_SLOT_1, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State to Slot 1", EMUCMDFLAG_TASEDIT },
{ EMUCMD_SAVE_STATE_SLOT_2, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State to Slot 2", EMUCMDFLAG_TASEDIT },
{ EMUCMD_SAVE_STATE_SLOT_3, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State to Slot 3", EMUCMDFLAG_TASEDIT },
{ EMUCMD_SAVE_STATE_SLOT_4, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State to Slot 4", EMUCMDFLAG_TASEDIT },
{ EMUCMD_SAVE_STATE_SLOT_5, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State to Slot 5", EMUCMDFLAG_TASEDIT },
{ EMUCMD_SAVE_STATE_SLOT_6, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State to Slot 6", EMUCMDFLAG_TASEDIT },
{ EMUCMD_SAVE_STATE_SLOT_7, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State to Slot 7", EMUCMDFLAG_TASEDIT },
{ EMUCMD_SAVE_STATE_SLOT_8, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State to Slot 8", EMUCMDFLAG_TASEDIT },
{ EMUCMD_SAVE_STATE_SLOT_9, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State to Slot 9", EMUCMDFLAG_TASEDIT },
{ EMUCMD_LOAD_STATE, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State", 0 },
{ EMUCMD_LOAD_STATE_FROM, EMUCMDTYPE_STATE, FCEUD_LoadStateFrom, 0, 0, "Load State From...", 0 },
{ EMUCMD_LOAD_STATE_SLOT_0, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State from Slot 0", 0 },
{ EMUCMD_LOAD_STATE_SLOT_1, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State from Slot 1", 0 },
{ EMUCMD_LOAD_STATE_SLOT_2, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State from Slot 2", 0 },
{ EMUCMD_LOAD_STATE_SLOT_3, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State from Slot 3", 0 },
{ EMUCMD_LOAD_STATE_SLOT_4, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State from Slot 4", 0 },
{ EMUCMD_LOAD_STATE_SLOT_5, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State from Slot 5", 0 },
{ EMUCMD_LOAD_STATE_SLOT_6, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State from Slot 6", 0 },
{ EMUCMD_LOAD_STATE_SLOT_7, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State from Slot 7", 0 },
{ EMUCMD_LOAD_STATE_SLOT_8, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State from Slot 8", 0 },
{ EMUCMD_LOAD_STATE_SLOT_9, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State from Slot 9", 0 },
{ EMUCMD_LOAD_STATE_SLOT_0, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State from Slot 0", EMUCMDFLAG_TASEDIT },
{ EMUCMD_LOAD_STATE_SLOT_1, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State from Slot 1", EMUCMDFLAG_TASEDIT },
{ EMUCMD_LOAD_STATE_SLOT_2, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State from Slot 2", EMUCMDFLAG_TASEDIT },
{ EMUCMD_LOAD_STATE_SLOT_3, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State from Slot 3", EMUCMDFLAG_TASEDIT },
{ EMUCMD_LOAD_STATE_SLOT_4, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State from Slot 4", EMUCMDFLAG_TASEDIT },
{ EMUCMD_LOAD_STATE_SLOT_5, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State from Slot 5", EMUCMDFLAG_TASEDIT },
{ EMUCMD_LOAD_STATE_SLOT_6, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State from Slot 6", EMUCMDFLAG_TASEDIT },
{ EMUCMD_LOAD_STATE_SLOT_7, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State from Slot 7", EMUCMDFLAG_TASEDIT },
{ EMUCMD_LOAD_STATE_SLOT_8, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State from Slot 8", EMUCMDFLAG_TASEDIT },
{ EMUCMD_LOAD_STATE_SLOT_9, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State from Slot 9", EMUCMDFLAG_TASEDIT },
{ EMUCMD_MOVIE_RECORD_TO, EMUCMDTYPE_MOVIE, FCEUD_MovieRecordTo, 0, 0, "Record Movie To...",0 },
{ EMUCMD_MOVIE_REPLAY_FROM, EMUCMDTYPE_MOVIE, FCEUD_MovieReplayFrom, 0, 0, "Play Movie From...", },
{ EMUCMD_MOVIE_PLAY_FROM_BEGINNING, EMUCMDTYPE_MOVIE, FCEUI_MoviePlayFromBeginning, 0, 0, "Play Movie From Beginning", 0 },
{ EMUCMD_MOVIE_RECORD_TO, EMUCMDTYPE_MOVIE, FCEUD_MovieRecordTo, 0, 0, "Record Movie To...", 0 },
{ EMUCMD_MOVIE_REPLAY_FROM, EMUCMDTYPE_MOVIE, FCEUD_MovieReplayFrom, 0, 0, "Play Movie From...", 0 },
{ EMUCMD_MOVIE_PLAY_FROM_BEGINNING, EMUCMDTYPE_MOVIE, FCEUI_MoviePlayFromBeginning, 0, 0, "Play Movie From Beginning", EMUCMDFLAG_TASEDIT },
{ EMUCMD_MOVIE_STOP, EMUCMDTYPE_MOVIE, FCEUI_StopMovie, 0, 0, "Stop Movie", 0 },
{ EMUCMD_MOVIE_READONLY_TOGGLE, EMUCMDTYPE_MOVIE, FCEUI_MovieToggleReadOnly, 0, 0, "Toggle Read-Only", EMUCMDFLAG_TASEDIT },
{ EMUCMD_MOVIE_FRAME_DISPLAY_TOGGLE, EMUCMDTYPE_MOVIE, FCEUI_MovieToggleFrameDisplay, 0, 0, "Frame Display Toggle", 0 },
{ EMUCMD_MOVIE_FRAME_DISPLAY_TOGGLE, EMUCMDTYPE_MOVIE, FCEUI_MovieToggleFrameDisplay, 0, 0, "Toggle Frame Display", EMUCMDFLAG_TASEDIT },
{ EMUCMD_MOVIE_INPUT_DISPLAY_TOGGLE, EMUCMDTYPE_MISC, FCEUI_ToggleInputDisplay, 0, 0, "Toggle Input Display", 0 },
{ EMUCMD_MOVIE_ICON_DISPLAY_TOGGLE, EMUCMDTYPE_MISC, FCEUD_ToggleStatusIcon, 0, 0, "Toggle Status Icon", 0 },
{ EMUCMD_MOVIE_INPUT_DISPLAY_TOGGLE, EMUCMDTYPE_MISC, FCEUI_ToggleInputDisplay, 0, 0, "Toggle Input Display", EMUCMDFLAG_TASEDIT },
{ EMUCMD_MOVIE_ICON_DISPLAY_TOGGLE, EMUCMDTYPE_MISC, FCEUD_ToggleStatusIcon, 0, 0, "Toggle Status Icon", EMUCMDFLAG_TASEDIT },
#ifdef _S9XLUA_H
{ EMUCMD_SCRIPT_RELOAD, EMUCMDTYPE_MISC, FCEU_ReloadLuaCode, 0, 0, "Reload current Lua script", },
{ EMUCMD_SCRIPT_RELOAD, EMUCMDTYPE_MISC, FCEU_ReloadLuaCode, 0, 0, "Reload current Lua script", 0 },
#endif
{ EMUCMD_SOUND_TOGGLE, EMUCMDTYPE_SOUND, FCEUD_SoundToggle, 0, 0, "Sound Mute Toggle", EMUCMDFLAG_TASEDIT },
{ EMUCMD_SOUND_VOLUME_UP, EMUCMDTYPE_SOUND, CommandSoundAdjust, 0, 0, "Sound Volume Up", EMUCMDFLAG_TASEDIT },
{ EMUCMD_SOUND_VOLUME_DOWN, EMUCMDTYPE_SOUND, CommandSoundAdjust, 0, 0, "Sound Volume Down", EMUCMDFLAG_TASEDIT },
{ EMUCMD_SOUND_VOLUME_NORMAL, EMUCMDTYPE_SOUND, CommandSoundAdjust, 0, 0, "Sound Volume Normal", EMUCMDFLAG_TASEDIT },
{ EMUCMD_SOUND_VOLUME_UP, EMUCMDTYPE_SOUND, CommandSoundAdjust, 0, 0, "Sound Volume Up", 0 },
{ EMUCMD_SOUND_VOLUME_DOWN, EMUCMDTYPE_SOUND, CommandSoundAdjust, 0, 0, "Sound Volume Down", 0 },
{ EMUCMD_SOUND_VOLUME_NORMAL, EMUCMDTYPE_SOUND, CommandSoundAdjust, 0, 0, "Sound Volume Normal", 0 },
{ EMUCMD_AVI_RECORD_AS, EMUCMDTYPE_AVI, FCEUD_AviRecordTo, 0, 0, "Record AVI As...", 0 },
{ EMUCMD_AVI_STOP, EMUCMDTYPE_AVI, FCEUD_AviStop, 0, 0, "Stop AVI", 0 },
@ -739,27 +757,29 @@ struct EMUCMDTABLE FCEUI_CommandTable[]=
{ EMUCMD_VSUNI_TOGGLE_DIP_9, EMUCMDTYPE_VSUNI, CommandToggleDip, 0, 0, "Toggle Dipswitch 9", 0 },
{ EMUCMD_MISC_AUTOSAVE, EMUCMDTYPE_MISC, FCEUI_Autosave, 0, 0, "Load Last Auto-save", 0},
{ EMUCMD_MISC_SHOWSTATES, EMUCMDTYPE_MISC, ViewSlots, 0, 0, "View save slots", 0 },
{ EMUCMD_MISC_USE_INPUT_PRESET_1, EMUCMDTYPE_MISC, CommandUsePreset, 0, 0, "Use Input Preset 1", 0 },
{ EMUCMD_MISC_USE_INPUT_PRESET_2, EMUCMDTYPE_MISC, CommandUsePreset, 0, 0, "Use Input Preset 2", 0 },
{ EMUCMD_MISC_USE_INPUT_PRESET_3, EMUCMDTYPE_MISC, CommandUsePreset, 0, 0, "Use Input Preset 3", 0 },
{ EMUCMD_MISC_USE_INPUT_PRESET_1, EMUCMDTYPE_MISC, CommandUsePreset, 0, 0, "Use Input Preset 1", EMUCMDFLAG_TASEDIT },
{ EMUCMD_MISC_USE_INPUT_PRESET_2, EMUCMDTYPE_MISC, CommandUsePreset, 0, 0, "Use Input Preset 2", EMUCMDFLAG_TASEDIT },
{ EMUCMD_MISC_USE_INPUT_PRESET_3, EMUCMDTYPE_MISC, CommandUsePreset, 0, 0, "Use Input Preset 3", EMUCMDFLAG_TASEDIT },
{ EMUCMD_MISC_DISPLAY_BG_TOGGLE, EMUCMDTYPE_MISC, BackgroundDisplayToggle, 0, 0, "Toggle Background Display", 0 },
{ EMUCMD_MISC_DISPLAY_OBJ_TOGGLE, EMUCMDTYPE_MISC, ObjectDisplayToggle, 0, 0, "Toggle Object Display", 0 },
{ EMUCMD_MISC_DISPLAY_LAGCOUNTER_TOGGLE,EMUCMDTYPE_MISC, LagCounterToggle, 0, 0, "Lag Counter Toggle", 0 },
{ EMUCMD_MISC_LAGCOUNTER_RESET, EMUCMDTYPE_MISC, LagCounterReset, 0, 0, "Lag Counter Reset", 0},
{ EMUCMD_TOOL_OPENMEMORYWATCH, EMUCMDTYPE_TOOL, LaunchMemoryWatch,0, 0, "Open Memory Watch", 0},
{ EMUCMD_MISC_DISPLAY_LAGCOUNTER_TOGGLE,EMUCMDTYPE_MISC, LagCounterToggle, 0, 0, "Lag Counter Toggle", EMUCMDFLAG_TASEDIT },
{ EMUCMD_MISC_OPENTASEDIT, EMUCMDTYPE_TOOL, LaunchTasEdit, 0, 0, "Open TAS Editor", 0},
{ EMUCMD_TOOL_OPENMEMORYWATCH, EMUCMDTYPE_TOOL, LaunchMemoryWatch,0, 0, "Open Memory Watch", EMUCMDFLAG_TASEDIT },
{ EMUCMD_TOOL_OPENCHEATS, EMUCMDTYPE_TOOL, LaunchCheats, 0, 0, "Open Cheats", 0},
{ EMUCMD_TOOL_OPENDEBUGGER, EMUCMDTYPE_TOOL, LaunchDebugger, 0, 0, "Open Debugger", 0},
{ EMUCMD_TOOL_OPENHEX, EMUCMDTYPE_TOOL, LaunchHex, 0, 0, "Open Hex Editor", 0},
{ EMUCMD_TOOL_OPENPPU, EMUCMDTYPE_TOOL, LaunchPPU, 0, 0, "Open PPU Viewer", 0},
{ EMUCMD_TOOL_OPENNTVIEW, EMUCMDTYPE_TOOL, LaunchNTView, 0, 0, "Open Name Table Viewer", 0},
{ EMUCMD_TOOL_OPENTRACELOGGER, EMUCMDTYPE_TOOL, LaunchTraceLogger, 0, 0, "Open Trace Logger", 0},
{ EMUCMD_TOOL_OPENCDLOGGER, EMUCMDTYPE_TOOL, LaunchCodeDataLogger, 0, 0, "Open Code/Data Logger", 0},
{ EMUCMD_FRAMEADV_SKIPLAG, EMUCMDTYPE_MISC, FA_SkipLag, 0, 0, "Frame Adv.-Skip Lag", 0},
{ EMUCMD_OPENROM, EMUCMDTYPE_TOOL, OpenRom, 0, 0, "Open ROM", 0},
{ EMUCMD_CLOSEROM, EMUCMDTYPE_TOOL, CloseRom, 0, 0, "Close ROM", 0},
{ EMUCMD_RELOAD, EMUCMDTYPE_TOOL, ReloadRom, 0, 0, "Reload ROM or TAS Editor Project", EMUCMDFLAG_TASEDIT },
{ EMUCMD_MISC_DISPLAY_MOVIESUBTITLES, EMUCMDTYPE_MISC, MovieSubtitleToggle,0,0,"Toggle Movie Subtitles", 0},
{ EMUCMD_MISC_UNDOREDOSAVESTATE, EMUCMDTYPE_MISC, UndoRedoSavestate, 0,0,"Undo/Redo Savestate", 0},
{ EMUCMD_MISC_TOGGLEFULLSCREEN, EMUCMDTYPE_MISC, ToggleFullscreen, 0, 0, "Toggle Fullscreen", 0},
{ EMUCMD_TOOL_OPENRAMWATCH, EMUCMDTYPE_TOOL, LaunchRamWatch, 0, 0, "Open Ram Watch", 0},
{ EMUCMD_TOOL_OPENRAMWATCH, EMUCMDTYPE_TOOL, LaunchRamWatch, 0, 0, "Open Ram Watch", EMUCMDFLAG_TASEDIT },
{ EMUCMD_TOOL_OPENRAMSEARCH, EMUCMDTYPE_TOOL, LaunchRamSearch, 0, 0, "Open Ram Search", 0},
{ EMUCMD_TOOL_RAMSEARCHLT, EMUCMDTYPE_TOOL, RamSearchOpLT, 0, 0, "Ram Search - Less Than", 0},
{ EMUCMD_TOOL_RAMSEARCHGT, EMUCMDTYPE_TOOL, RamSearchOpGT, 0, 0, "Ram Search - Greater Than", 0},
@ -767,6 +787,8 @@ struct EMUCMDTABLE FCEUI_CommandTable[]=
{ EMUCMD_TOOL_RAMSEARCHGTE, EMUCMDTYPE_TOOL, RamSearchOpGTE, 0, 0, "Ram Search - Greater Than or Equal", 0},
{ EMUCMD_TOOL_RAMSEARCHEQ, EMUCMDTYPE_TOOL, RamSearchOpEQ, 0, 0, "Ram Search - Equal", 0},
{ EMUCMD_TOOL_RAMSEARCHNE, EMUCMDTYPE_TOOL, RamSearchOpNE, 0, 0, "Ram Search - Not Equal", 0},
{ EMUCMD_TASEDIT_REWIND, EMUCMDTYPE_MISC, TaseditRewindOn, TaseditRewindOff, 0, "Rewind Frame (TAS Editor only)", EMUCMDFLAG_TASEDIT },
{ EMUCMD_RERECORD_DISPLAY_TOGGLE, EMUCMDTYPE_MISC, FCEUI_MovieToggleRerecordDisplay, 0, 0, "Toggle Rerecord Display", EMUCMDFLAG_TASEDIT },
};
#define NUM_EMU_CMDS (sizeof(FCEUI_CommandTable)/sizeof(FCEUI_CommandTable[0]))
@ -823,37 +845,61 @@ static void ViewSlots(void)
static void CommandSelectSaveSlot(void)
{
if(execcmd <= EMUCMD_SAVE_SLOT_9)
FCEUI_SelectState(execcmd-EMUCMD_SAVE_SLOT_0, 1);
else if(execcmd == EMUCMD_SAVE_SLOT_NEXT)
FCEUI_SelectStateNext(1);
else if(execcmd == EMUCMD_SAVE_SLOT_PREV)
FCEUI_SelectStateNext(-1);
if (FCEUMOV_Mode(MOVIEMODE_TASEDIT))
{
#ifdef WIN32
bookmarks.jump(execcmd - EMUCMD_SAVE_SLOT_0);
#endif
} else
{
if(execcmd <= EMUCMD_SAVE_SLOT_9)
FCEUI_SelectState(execcmd - EMUCMD_SAVE_SLOT_0, 1);
else if(execcmd == EMUCMD_SAVE_SLOT_NEXT)
FCEUI_SelectStateNext(1);
else if(execcmd == EMUCMD_SAVE_SLOT_PREV)
FCEUI_SelectStateNext(-1);
}
}
static void CommandStateSave(void)
{
// FCEU_PrintError("execcmd=%d, EMUCMD_SAVE_STATE_SLOT_0=%d, EMUCMD_SAVE_STATE_SLOT_9=%d", execcmd,EMUCMD_SAVE_STATE_SLOT_0,EMUCMD_SAVE_STATE_SLOT_9);
if(execcmd >= EMUCMD_SAVE_STATE_SLOT_0 && execcmd <= EMUCMD_SAVE_STATE_SLOT_9)
if (FCEUMOV_Mode(MOVIEMODE_TASEDIT))
{
int oldslot=FCEUI_SelectState(execcmd-EMUCMD_SAVE_STATE_SLOT_0, 0);
FCEUI_SaveState(0);
FCEUI_SelectState(oldslot, 0);
#ifdef WIN32
bookmarks.set(execcmd - EMUCMD_SAVE_STATE_SLOT_0);
#endif
} else
{
// FCEU_PrintError("execcmd=%d, EMUCMD_SAVE_STATE_SLOT_0=%d, EMUCMD_SAVE_STATE_SLOT_9=%d", execcmd,EMUCMD_SAVE_STATE_SLOT_0,EMUCMD_SAVE_STATE_SLOT_9);
if(execcmd >= EMUCMD_SAVE_STATE_SLOT_0 && execcmd <= EMUCMD_SAVE_STATE_SLOT_9)
{
int oldslot=FCEUI_SelectState(execcmd-EMUCMD_SAVE_STATE_SLOT_0, 0);
FCEUI_SaveState(0);
FCEUI_SelectState(oldslot, 0);
}
else
FCEUI_SaveState(0);
}
else
FCEUI_SaveState(0);
}
static void CommandStateLoad(void)
{
if(execcmd >= EMUCMD_LOAD_STATE_SLOT_0 && execcmd <= EMUCMD_LOAD_STATE_SLOT_9)
if (FCEUMOV_Mode(MOVIEMODE_TASEDIT))
{
int oldslot=FCEUI_SelectState(execcmd-EMUCMD_LOAD_STATE_SLOT_0, 0);
FCEUI_LoadState(0);
FCEUI_SelectState(oldslot, 0);
#ifdef WIN32
bookmarks.unleash(execcmd - EMUCMD_LOAD_STATE_SLOT_0);
#endif
} else
{
if(execcmd >= EMUCMD_LOAD_STATE_SLOT_0 && execcmd <= EMUCMD_LOAD_STATE_SLOT_9)
{
int oldslot=FCEUI_SelectState(execcmd-EMUCMD_LOAD_STATE_SLOT_0, 0);
FCEUI_LoadState(0);
FCEUI_SelectState(oldslot, 0);
}
else
FCEUI_LoadState(0);
}
else
FCEUI_LoadState(0);
}
static void CommandSoundAdjust(void)
@ -896,11 +942,19 @@ void LagCounterReset()
lagCounter = 0;
}
static void LagCounterToggle(void)
void LagCounterToggle(void)
{
lagCounterDisplay ^= 1;
}
static void LaunchTasEdit(void)
{
#ifdef WIN32
extern bool EnterTasEdit();
EnterTasEdit();
#endif
}
static void LaunchMemoryWatch(void)
{
#ifdef WIN32
@ -915,6 +969,13 @@ static void LaunchDebugger(void)
#endif
}
static void LaunchNTView(void)
{
#ifdef WIN32
DoNTView();
#endif
}
static void LaunchPPU(void)
{
#ifdef WIN32
@ -969,55 +1030,73 @@ static void LaunchRamSearch(void)
static void RamSearchOpLT(void) {
#ifdef WIN32
extern void SetSearchType(int SearchType);
extern void DoRamSearchOperation();
SetSearchType(0);
DoRamSearchOperation();
if (GameInfo)
{
extern void SetSearchType(int SearchType);
extern void DoRamSearchOperation();
SetSearchType(0);
DoRamSearchOperation();
}
#endif
}
static void RamSearchOpGT(void) {
#ifdef WIN32
extern void SetSearchType(int SearchType);
extern void DoRamSearchOperation();
SetSearchType(1);
DoRamSearchOperation();
if (GameInfo)
{
extern void SetSearchType(int SearchType);
extern void DoRamSearchOperation();
SetSearchType(1);
DoRamSearchOperation();
}
#endif
}
static void RamSearchOpLTE(void) {
#ifdef WIN32
extern void SetSearchType(int SearchType);
extern void DoRamSearchOperation();
SetSearchType(2);
DoRamSearchOperation();
if (GameInfo)
{
extern void SetSearchType(int SearchType);
extern void DoRamSearchOperation();
SetSearchType(2);
DoRamSearchOperation();
}
#endif
}
static void RamSearchOpGTE(void) {
#ifdef WIN32
extern void SetSearchType(int SearchType);
extern void DoRamSearchOperation();
SetSearchType(3);
DoRamSearchOperation();
if (GameInfo)
{
extern void SetSearchType(int SearchType);
extern void DoRamSearchOperation();
SetSearchType(3);
DoRamSearchOperation();
}
#endif
}
static void RamSearchOpEQ(void) {
#ifdef WIN32
extern void SetSearchType(int SearchType);
extern void DoRamSearchOperation();
SetSearchType(4);
DoRamSearchOperation();
if (GameInfo)
{
extern void SetSearchType(int SearchType);
extern void DoRamSearchOperation();
SetSearchType(4);
DoRamSearchOperation();
}
#endif
}
static void RamSearchOpNE(void) {
#ifdef WIN32
extern void SetSearchType(int SearchType);
extern void DoRamSearchOperation();
SetSearchType(5);
DoRamSearchOperation();
if (GameInfo)
{
extern void SetSearchType(int SearchType);
extern void DoRamSearchOperation();
SetSearchType(5);
DoRamSearchOperation();
}
#endif
}
@ -1041,6 +1120,22 @@ static void CloseRom(void)
#endif
}
static void ReloadRom(void)
{
#ifdef WIN32
if (FCEUMOV_Mode(MOVIEMODE_TASEDIT))
{
// load most recent project
taseditor_window.LoadRecentProject(0);
} else
{
// load most recent ROM
extern void LoadRecentRom(int slot);
LoadRecentRom(0);
}
#endif
}
static void MovieSubtitleToggle(void)
{
movieSubtitles ^= 1;
@ -1075,4 +1170,19 @@ static void ToggleFullscreen(void)
SetVideoMode(oldmode);
changerecursive=0;
#endif
}
}
static void TaseditRewindOn(void)
{
#ifdef WIN32
Taseditor_rewind_now = true;
#endif
}
static void TaseditRewindOff(void)
{
#ifdef WIN32
Taseditor_rewind_now = false;
#endif
}

View File

@ -5,6 +5,8 @@
#include "git.h"
void LagCounterToggle(void);
class MovieRecord;
//MBG TODO - COMBINE THESE INPUTC AND INPUTCFC
@ -201,8 +203,8 @@ enum EMUCMD
EMUCMD_MISC_DISPLAY_OBJ_TOGGLE,
EMUCMD_MISC_DISPLAY_LAGCOUNTER_TOGGLE,
EMUCMD_MISC_LAGCOUNTER_RESET,
//Currently Windows only------
EMUCMD_MISC_OPENTASEDIT,
EMUCMD_TOOL_OPENMEMORYWATCH,
EMUCMD_TOOL_OPENCHEATS,
EMUCMD_TOOL_OPENDEBUGGER,
@ -215,6 +217,7 @@ enum EMUCMD
//Currently only windows (but sdl could easily add onto these)
EMUCMD_OPENROM,
EMUCMD_CLOSEROM,
EMUCMD_RELOAD,
//-----------------------------
EMUCMD_MISC_DISPLAY_MOVIESUBTITLES,
EMUCMD_MISC_UNDOREDOSAVESTATE,
@ -227,6 +230,12 @@ enum EMUCMD
EMUCMD_TOOL_RAMSEARCHGTE,
EMUCMD_TOOL_RAMSEARCHEQ,
EMUCMD_TOOL_RAMSEARCHNE,
EMUCMD_TOOL_OPENNTVIEW,
EMUCMD_TASEDIT_REWIND,
//-----------------------------
//keep adding these in order of newness or else the hotkey binding configs will get messed up...
EMUCMD_RERECORD_DISPLAY_TOGGLE,
EMUCMD_MAX
};

View File

@ -76,16 +76,52 @@ static void ZapperFrapper(int w, uint8 *bg, uint8 *spr, uint32 linets, int final
}
endo:
ZD[w].zappo=final;
//if this was a miss, clear out the hit
if(ZD[w].mzb&2)
ZD[w].zaphit=0;
}
static INLINE int CheckColor(int w)
{
FCEUPPU_LineUpdate();
if((ZD[w].zaphit+100)>=(timestampbase+timestamp)
&& !(ZD[w].mzb&2)) return(0);
if(newppu)
{
int x = (int)ZD[w].mzx;
int y = (int)ZD[w].mzy;
int b = (int)ZD[w].mzb;
bool block = (b&2)!=0;
return(1);
int mousetime = y*256+x;
int nowtime = scanline*256 + g_rasterpos;
if(!block && mousetime < nowtime && mousetime >= nowtime - 384)
{
extern uint8 *XBuf;
uint8 *pix = XBuf+(ZD[w].mzy<<8);
uint8 a1 = pix[ZD[w].mzx];
a1&=63;
uint32 sum=palo[a1].r+palo[a1].g+palo[a1].b;
//return ZD[w].zaphit = sum != 0;
ZD[w].zaphit = (sum>=100*3)?1:0;
}
else
{
ZD[w].zaphit = 0;
}
return ZD[w].zaphit?0:1;
}
if((ZD[w].zaphit+100)>=(timestampbase+timestamp))
{
return 0;
}
return 1;
}
static uint8 ReadZapperVS(int w)
@ -133,14 +169,25 @@ static void UpdateZapper(int w, void *data, int arg)
{
uint32 *ptr=(uint32 *)data;
if(ZD[w].bogo)
ZD[w].bogo--;
if(ptr[2]&3 && (!(ZD[w].mzb&3)))
ZD[w].bogo=5;
bool newclicked = (ptr[2]&3)!=0;
bool oldclicked = (ZD[w].lastInput)!=0;
if(ZD[w].bogo)
{
ZD[w].bogo--;
}
ZD[w].lastInput = ptr[2]&3;
//woah.. this looks like broken bit logic.
if(newclicked && !oldclicked)
{
ZD[w].bogo=5;
ZD[w].mzb=ptr[2];
ZD[w].mzx=ptr[0];
ZD[w].mzy=ptr[1];
}
ZD[w].mzx=ptr[0];
ZD[w].mzy=ptr[1];
ZD[w].mzb=ptr[2];
}
static void LogZapper(int w, MovieRecord* mr)

View File

@ -10,6 +10,7 @@ struct ZAPPER
uint8 bogo;
int zappo;
uint64 zaphit;
uint32 lastInput;
};
#endif

View File

@ -37,9 +37,13 @@
#ifdef WIN32
#include <windows.h>
#include "./drivers/win/common.h"
#include "./drivers/win/tasedit.h"
#include "./drivers/win/window.h"
extern void AddRecentMovieFile(const char *filename);
#include "./drivers/win/taseditlib/playback.h"
#include "./drivers/win/taseditlib/recorder.h"
extern PLAYBACK playback;
extern RECORDER recorder;
#endif
using namespace std;
@ -88,6 +92,7 @@ int pauseframe = -1;
bool movie_readonly = true;
int input_display = 0;
int frame_display = 0;
int rerecord_display = 0;
bool fullSaveStateLoads = false; //Option for loading a savestates full contents in read+write mode instead of up to the frame count in the savestate (useful as a recovery option)
SFORMAT FCEUMOV_STATEINFO[]={
@ -103,10 +108,11 @@ int currRerecordCount;
#ifdef GEKKO
void MovieData::clearRecordRange(int start, int len) { }
void MovieData::insertEmpty(int at, int frames) { }
void MovieData::TryDumpIncremental() { }
void MovieData::cloneRegion(int at, int frames) { }
MovieRecord::MovieRecord() { }
void MovieRecord::clear() { }
bool MovieRecord::Compare(MovieRecord& compareRec) { return false; }
void MovieRecord::Clone(MovieRecord& sourceRec) { }
void MovieRecord::dumpJoy(EMUFILE* os, uint8 joystate) { }
void MovieRecord::parseJoy(EMUFILE* is, uint8& joystate) { }
void MovieRecord::parse(MovieData* md, EMUFILE* is) { }
@ -117,8 +123,6 @@ MovieData::MovieData() { }
void MovieData::truncateAt(int frame) { }
void MovieData::installValue(std::string& key, std::string& val) { }
int MovieData::dump(EMUFILE *os, bool binary) { return 0; }
int MovieData::dumpGreenzone(EMUFILE *os, bool binary) { return 0; }
int MovieData::loadGreenzone(EMUFILE *is, bool binary) { return 0; }
int FCEUMOV_GetFrame(void) { return 0; }
int FCEUI_GetLagCount(void) { return 0; }
bool FCEUI_GetLagged(void) { return false; }
@ -129,13 +133,10 @@ bool FCEUMOV_Mode(int modemask) { return false; }
bool LoadFM2(MovieData& movieData, EMUFILE* fp, int size, bool stopAfterHeader) { return false; }
void FCEUI_StopMovie() { }
void poweron(bool shouldDisableBatteryLoading) { }
void FCEUMOV_EnterTasEdit() { }
void FCEUMOV_ExitTasEdit() { }
void CreateCleanMovie() { }
bool FCEUMOV_FromPoweron() { return false; }
bool MovieData::loadSavestateFrom(std::vector<uint8>* buf) { return false; }
void MovieData::dumpSavestateTo(std::vector<uint8>* buf, int compressionLevel) { }
bool MovieData::loadTasSavestate(int frame) { return false; }
void MovieData::storeTasSavestate(int frame, int compression_level) { }
bool FCEUI_LoadMovie(const char *fname, bool _read_only, bool tasedit, int _pauseframe) { return false; }
void FCEUI_SaveMovie(const char *fname, EMOVIE_FLAG flags, std::wstring author) { }
void FCEUMOV_AddInputState() { }
@ -148,6 +149,7 @@ bool FCEUMOV_ReadState(EMUFILE* is, uint32 size) { return false; }
void FCEUMOV_PreLoad(void) { }
bool FCEUMOV_PostLoad(void) { return false; }
void FCEUI_MovieToggleFrameDisplay(void) { }
void FCEUI_MovieToggleRerecordDisplay() { }
void FCEUI_ToggleInputDisplay(void) { }
int FCEUI_GetMovieLength() { return 0; }
int FCEUI_GetMovieRerecordCount() { return 0; }
@ -168,7 +170,9 @@ void FCEUI_MakeBackupMovie(bool dispMessage) { }
void MovieData::clearRecordRange(int start, int len)
{
for(int i=0;i<len;i++)
{
records[i+start].clear();
}
}
void MovieData::insertEmpty(int at, int frames)
@ -176,46 +180,23 @@ void MovieData::insertEmpty(int at, int frames)
if(at == -1)
{
int currcount = records.size();
records.resize(records.size()+frames);
clearRecordRange(currcount,frames);
}
else
records.resize(currcount + frames);
clearRecordRange(currcount, frames);
} else
{
records.insert(records.begin()+at,frames,MovieRecord());
records.insert(records.begin() + at, frames, MovieRecord());
clearRecordRange(at,frames);
}
}
void MovieData::TryDumpIncremental()
void MovieData::cloneRegion(int at, int frames)
{
if(movieMode == MOVIEMODE_TASEDIT)
{
//only log the savestate if we are appending to the green zone
if (turbo && pauseframe!=-1 && static_cast<unsigned int>(currFrameCounter)<currMovieData.records.size())
{
if (turbo && pauseframe-256>currFrameCounter && ((currFrameCounter-pauseframe)&0xff))
return;
currMovieData.storeTasSavestate(currFrameCounter, Z_DEFAULT_COMPRESSION);
}
if(currFrameCounter == currMovieData.greenZoneCount)
{
if(currFrameCounter == (int)currMovieData.records.size() || currMovieData.records.size()==0)
{
currMovieData.insertEmpty(-1,1);
}
currMovieData.storeTasSavestate(currFrameCounter, Z_DEFAULT_COMPRESSION);
currMovieData.greenZoneCount=currFrameCounter+1;
} else if (currFrameCounter < currMovieData.greenZoneCount && !movie_readonly)
{
currMovieData.storeTasSavestate(currFrameCounter, Z_DEFAULT_COMPRESSION);
} else if (currFrameCounter > currMovieData.greenZoneCount && static_cast<unsigned int>(currMovieData.greenZoneCount)<currMovieData.records.size())
{
/* May be required in some malformed TAS projects. */
currMovieData.storeTasSavestate(currFrameCounter, Z_DEFAULT_COMPRESSION);
currMovieData.greenZoneCount= currFrameCounter+1;
}
}
if(at == -1) return;
records.insert(records.begin() + at, frames, MovieRecord());
for(int i = 0; i < frames; i++)
records[i+at].Clone(records[i + at + frames]);
}
MovieRecord::MovieRecord()
@ -253,9 +234,6 @@ bool MovieRecord::Compare(MovieRecord& compareRec)
if (this->joysticks != compareRec.joysticks)
return false;
//if (this->commands != compareRec.commands)
// return false;
//if new commands are ever recordable, they need to be added here if we go with this method
if(this->command_reset() != compareRec.command_reset()) return false;
@ -275,9 +253,29 @@ bool MovieRecord::Compare(MovieRecord& compareRec)
if (this->zappers[1].b != compareRec.zappers[1].b) return false;
if (this->zappers[1].bogo != compareRec.zappers[1].bogo) return false;
return true;
}
void MovieRecord::Clone(MovieRecord& sourceRec)
{
this->joysticks[0] = sourceRec.joysticks[0];
this->joysticks[1] = sourceRec.joysticks[1];
this->joysticks[2] = sourceRec.joysticks[2];
this->joysticks[3] = sourceRec.joysticks[3];
this->zappers[0].x = sourceRec.zappers[0].x;
this->zappers[0].y = sourceRec.zappers[0].y;
this->zappers[0].zaphit = sourceRec.zappers[0].zaphit;
this->zappers[0].b = sourceRec.zappers[0].b;
this->zappers[0].bogo = sourceRec.zappers[0].bogo;
this->zappers[1].x = sourceRec.zappers[1].x;
this->zappers[1].y = sourceRec.zappers[1].y;
this->zappers[1].zaphit = sourceRec.zappers[1].zaphit;
this->zappers[1].b = sourceRec.zappers[1].b;
this->zappers[1].bogo = sourceRec.zappers[1].bogo;
this->commands = sourceRec.commands;
}
const char MovieRecord::mnemonics[8] = {'A','B','S','T','U','D','L','R'};
void MovieRecord::dumpJoy(EMUFILE* os, uint8 joystate)
@ -413,11 +411,6 @@ void MovieRecord::dumpBinary(MovieData* md, EMUFILE* os, int index)
void MovieRecord::dump(MovieData* md, EMUFILE* os, int index)
{
if (false/*currMovieData.binaryFlag*/)
{
dumpBinary(md, os, index);
return;
}
//dump the misc commands
//*os << '|' << setw(1) << (int)commands;
os->fputc('|');
@ -465,9 +458,8 @@ MovieData::MovieData()
, PPUflag(false)
, rerecordCount(0)
, binaryFlag(false)
, greenZoneCount(0)
, loadFrameCount(-1)
, microphone(false)
, tweakCount(0)
{
memset(&romChecksum,0,sizeof(MD5DATA));
}
@ -545,8 +537,8 @@ int MovieData::dump(EMUFILE *os, bool binary)
os->fprintf("port0 %d\n" , ports[0] );
os->fprintf("port1 %d\n" , ports[1] );
os->fprintf("port2 %d\n" , ports[2] );
os->fprintf("FDS %d\n" , isFDS?1:0 );
os->fprintf("NewPPU %d\n" , newppu?1:0 );
os->fprintf("FDS %d\n" , fds?1:0 );
os->fprintf("NewPPU %d\n" , PPUflag?1:0 );
for(uint32 i=0;i<comments.size();i++)
os->fprintf("comment %s\n" , wcstombs(comments[i]).c_str() );
@ -557,71 +549,28 @@ int MovieData::dump(EMUFILE *os, bool binary)
if(binary)
os->fprintf("binary 1\n" );
if(savestate.size() != 0)
if(savestate.size())
os->fprintf("savestate %s\n" , BytesToString(&savestate[0],savestate.size()).c_str() );
if(FCEUMOV_Mode(MOVIEMODE_TASEDIT))
os->fprintf("length %d\n" , this->records.size() );
if (this->loadFrameCount >= 0)
os->fprintf("length %d\n" , this->loadFrameCount);
if(binary)
{
//put one | to start the binary dump
os->fputc('|');
for(int i=0;i<(int)records.size();i++)
records[i].dumpBinary(this,os,i);
}
else
records[i].dumpBinary(this, os, i);
} else
{
for(int i=0;i<(int)records.size();i++)
records[i].dump(this,os,i);
records[i].dump(this, os, i);
}
int end = os->ftell();
return end-start;
}
int MovieData::dumpGreenzone(EMUFILE *os, bool binary)
{
int start = os->ftell();
int frame, size;
for (int i=0; i<(int)savestates.size(); ++i)
{
if (savestates[i].empty())
continue;
frame=i;
size=savestates[i].size();
write32le(frame, os);
write32le(size, os);
os->fwrite(&savestates[i][0], size);
}
frame=-1;
size=currMovieData.greenZoneCount;
write32le(frame, os);
write32le(size, os);
int end= os->ftell();
return end-start;
}
int MovieData::loadGreenzone(EMUFILE *is, bool binary)
{
int frame, size;
while(1)
{
if (!read32le((uint32 *)&frame, is)) {size=0; break;}
if (!read32le((uint32 *)&size, is)) {size=0; break;}
if (frame==-1) break;
int pos = is->ftell();
FCEUSS_LoadFP(is, SSLOADPARAM_NOBACKUP);
storeTasSavestate(frame, Z_DEFAULT_COMPRESSION);
is->fseek(pos+size,SEEK_SET);
}
greenZoneCount=size;
return 1;
}
int FCEUMOV_GetFrame(void)
{
return currFrameCounter;
@ -640,9 +589,9 @@ bool FCEUI_GetLagged(void)
bool FCEUMOV_ShouldPause(void)
{
if(pauseframe && currFrameCounter == (pauseframe-1)) //adelikat: changed to pauseframe -1 to prevent an off by 1 error. THis is probably the hackiest solution but I think it would cause some major restructuring to fix it properly.
if(pauseframe && currFrameCounter+1 == pauseframe)
{
pauseframe = 0; //only pause once!
pauseframe = 0;
return true;
}
else
@ -707,9 +656,10 @@ static void LoadFM2_binarychunk(MovieData& movieData, EMUFILE* fp, int size)
//yuck... another custom text parser.
bool LoadFM2(MovieData& movieData, EMUFILE* fp, int size, bool stopAfterHeader)
{
std::string a("length"), b("-1");
// Non-TAS projects consume until EOF
movieData.installValue(a, b);
// if there's no "binary" tag in the movie header, consider it as a movie in text format
movieData.binaryFlag = false;
// Non-TASEditor projects consume until EOF
movieData.loadFrameCount = -1;
//first, look for an fcm signature
char fcmbuf[3];
@ -750,7 +700,9 @@ bool LoadFM2(MovieData& movieData, EMUFILE* fp, int size, bool stopAfterHeader)
{
LoadFM2_binarychunk(movieData, fp, size);
return true;
}
} else if (isnewline && movieData.loadFrameCount == movieData.records.size())
// exit prematurely if loaded the specified amound of records
return true;
switch(state)
{
case NEWLINE:
@ -898,59 +850,23 @@ void poweron(bool shouldDisableBatteryLoading)
disableBatteryLoading = 0;
}
void FCEUMOV_EnterTasEdit()
void CreateCleanMovie()
{
//If no movie, start a new project, currMovieData will serve as the "main branch" file, so give it a filename and save that into the project
//Dump all header info int ot the project file
//Else use the currentmovie to create a new project
//BIG TODO: Why is this tasedit stuff in movie.cpp? Let's movie it out, it is win32 only anyway
if (movieMode == MOVIEMODE_INACTIVE)
{
//stop any current movie activity
FCEUI_StopMovie();
//clear the current movie
currFrameCounter = 0;
currMovieData = MovieData();
currMovieData.guid.newGuid();
currMovieData.palFlag = FCEUI_GetCurrentVidSystem(0,0)!=0;
currMovieData.romChecksum = GameInfo->MD5;
currMovieData.romFilename = FileBase;
//reset the rom
poweron(false);
}
else
{
FCEUI_StopMovie();
currMovieData.greenZoneCount=currFrameCounter;
}
//todo - think about this
//ResetInputTypes();
//todo - maybe this instead
//FCEUD_SetInput(currMovieData.fourscore,currMovieData.microphone,(ESI)currMovieData.ports[0],(ESI)currMovieData.ports[1],(ESIFC)currMovieData.ports[2]);
#ifdef WIN32
CreateProject(currMovieData);
#endif
FCEUI_SetEmulationPaused(1); //pause the emulator
//and enter tasedit mode
movieMode = MOVIEMODE_TASEDIT;
currMovieData.TryDumpIncremental();
FCEU_DispMessage("Tasedit engaged",0);
}
void FCEUMOV_ExitTasEdit()
{
movieMode = MOVIEMODE_INACTIVE;
FCEU_DispMessage("Tasedit disengaged",0);
currMovieData = MovieData();
currMovieData.palFlag = FCEUI_GetCurrentVidSystem(0,0)!=0;
currMovieData.romFilename = FileBase;
currMovieData.romChecksum = GameInfo->MD5;
currMovieData.guid.newGuid();
currMovieData.fourscore = FCEUI_GetInputFourscore();
currMovieData.microphone = FCEUI_GetInputMicrophone();
//currMovieData.ports[0] = InputType[0];
//currMovieData.ports[1] = InputType[1];
//currMovieData.ports[2] = InputType[2];
currMovieData.ports[0] = joyports[0].type;
currMovieData.ports[1] = joyports[1].type;
currMovieData.ports[2] = portFC.type;
currMovieData.fds = isFDS;
currMovieData.PPUflag = (newppu != 0);
}
bool FCEUMOV_FromPoweron()
@ -970,29 +886,10 @@ void MovieData::dumpSavestateTo(std::vector<uint8>* buf, int compressionLevel)
ms.trim();
}
bool MovieData::loadTasSavestate(int frame)
{
if (frame<0 || frame>=(int)currMovieData.records.size())
return false;
if ((int)savestates.size()<=frame || savestates[frame].empty())
return false;
return MovieData::loadSavestateFrom(&savestates[frame]);
}
void MovieData::storeTasSavestate(int frame, int compression_level)
{
if ((int)savestates.size()<=frame)
savestates.resize(frame+1);
MovieData::dumpSavestateTo(&savestates[frame],compression_level);
tweakCount++;
}
//begin playing an existing movie
bool FCEUI_LoadMovie(const char *fname, bool _read_only, bool tasedit, int _pauseframe)
bool FCEUI_LoadMovie(const char *fname, bool _read_only, int _pauseframe)
{
if(!tasedit && !FCEU_IsValidUI(FCEUI_PLAYMOVIE))
if(!FCEU_IsValidUI(FCEUI_PLAYMOVIE))
return true; //adelikat: file did not fail to load, so let's return true here, just do nothing
assert(fname);
@ -1035,12 +932,12 @@ bool FCEUI_LoadMovie(const char *fname, bool _read_only, bool tasedit, int _paus
//fully reload the game to reinitialize everything before playing any movie
poweron(true);
//WE NEED TO LOAD A SAVESTATE
if(currMovieData.savestate.size() != 0)
if(currMovieData.savestate.size())
{
//WE NEED TO LOAD A SAVESTATE
movieFromPoweron = false;
bool success = MovieData::loadSavestateFrom(&currMovieData.savestate);
if(!success) return true; //adelikat: I guess return true here? False is only for a bad movie filename, if it got this far the file was god?
if(!success) return true; //adelikat: I guess return true here? False is only for a bad movie filename, if it got this far the file was good?
} else {
movieFromPoweron = true;
}
@ -1053,29 +950,19 @@ bool FCEUI_LoadMovie(const char *fname, bool _read_only, bool tasedit, int _paus
FCEUI_SetVidSystem(0);
//force the input configuration stored in the movie to apply
FCEUD_SetInput(currMovieData.fourscore,currMovieData.microphone,(ESI)currMovieData.ports[0],(ESI)currMovieData.ports[1],(ESIFC)currMovieData.ports[2]);
FCEUD_SetInput(currMovieData.fourscore, currMovieData.microphone, (ESI)currMovieData.ports[0], (ESI)currMovieData.ports[1], (ESIFC)currMovieData.ports[2]);
//stuff that should only happen when we're ready to positively commit to the replay
if(tasedit)
{
currFrameCounter = 0;
pauseframe = _pauseframe;
currFrameCounter = 0;
pauseframe = _pauseframe;
movie_readonly = _read_only;
movieMode = MOVIEMODE_PLAY;
currRerecordCount = currMovieData.rerecordCount;
currMovieData.TryDumpIncremental();
}
if(movie_readonly)
FCEU_DispMessage("Replay started Read-Only.",0);
else
{
currFrameCounter = 0;
pauseframe = _pauseframe;
movie_readonly = _read_only;
movieMode = MOVIEMODE_PLAY;
currRerecordCount = currMovieData.rerecordCount;
if(movie_readonly)
FCEU_DispMessage("Replay started Read-Only.",0);
else
FCEU_DispMessage("Replay started Read+Write.",0);
}
FCEU_DispMessage("Replay started Read+Write.",0);
#ifdef WIN32
SetMainWindowText();
@ -1120,19 +1007,9 @@ void FCEUI_SaveMovie(const char *fname, EMOVIE_FLAG flags, std::wstring author)
currFrameCounter = 0;
LagCounterReset();
currMovieData = MovieData();
currMovieData.guid.newGuid();
CreateCleanMovie();
if(author != L"") currMovieData.comments.push_back(L"author " + author);
currMovieData.palFlag = FCEUI_GetCurrentVidSystem(0,0)!=0;
currMovieData.romChecksum = GameInfo->MD5;
currMovieData.romFilename = FileBase;
currMovieData.fourscore = FCEUI_GetInputFourscore();
currMovieData.microphone = FCEUI_GetInputMicrophone();
currMovieData.ports[0] = joyports[0].type;
currMovieData.ports[1] = joyports[1].type;
currMovieData.ports[2] = portFC.type;
if(flags & MOVIE_FLAG_FROM_POWERON)
{
@ -1161,37 +1038,35 @@ static int _currCommand = 0;
//either dumps the current joystick state or loads one state from the movie
void FCEUMOV_AddInputState()
{
//todo - for tasedit, either dump or load depending on whether input recording is enabled
//or something like that
//(input recording is just like standard read+write movie recording with input taken from gamepad)
//otherwise, it will come from the tasedit data.
#ifdef _WIN32
#ifdef _WIN32
if(movieMode == MOVIEMODE_TASEDIT)
{
// if movie length is less than currFrame, pad it with empty frames
if((int)currMovieData.records.size() <= currFrameCounter)
currMovieData.insertEmpty(-1, 1 + currFrameCounter - (int)currMovieData.records.size());
MovieRecord* mr = &currMovieData.records[currFrameCounter];
if(movie_readonly)
if(movie_readonly || turbo || playback.pause_frame > currFrameCounter)
{
//reset if necessary
// replay buttons
if(mr->command_reset())
ResetNES();
if(mr->command_fds_insert())
FCEU_FDSInsert();
if(mr->command_fds_select())
FCEU_FDSSelect();
joyports[0].load(mr);
joyports[1].load(mr);
}
else
} else
{
if (currMovieData.greenZoneCount>currFrameCounter+1)
{
InvalidateGreenZone(currFrameCounter);
}
// record buttons
joyports[0].log(mr);
joyports[1].log(mr);
mr->commands = 0;
recorder.InputChanged();
}
}
#endif
_currCommand = 0;
} else
#endif
if(movieMode == MOVIEMODE_PLAY)
{
//stop when we run out of frames
@ -1251,7 +1126,8 @@ void FCEUMOV_AddInputState()
if (fullSaveStateLoads && (currFrameCounter < (int)currMovieData.records.size()))
currMovieData.truncateAt(currFrameCounter);
mr.dump(&currMovieData, osRecordingMovie,currMovieData.records.size());
mr.dump(&currMovieData, osRecordingMovie,currMovieData.records.size()); // to disk
currMovieData.records.push_back(mr);
}
@ -1282,7 +1158,7 @@ void FCEUMOV_AddCommand(int cmd)
void FCEU_DrawMovies(uint8 *XBuf)
{
if(frame_display && movieMode != MOVIEMODE_TASEDIT)
if(frame_display)
{
char counterbuf[32] = {0};
int color = 0x20;
@ -1294,13 +1170,23 @@ void FCEU_DrawMovies(uint8 *XBuf)
{
sprintf(counterbuf,"%d/%d (finished)",currFrameCounter,currMovieData.records.size());
color = 0x17; //Show red to get attention
}
else
} else if(movieMode == MOVIEMODE_TASEDIT)
{
sprintf(counterbuf,"%d",currFrameCounter);
} else
sprintf(counterbuf,"%d (no movie)",currFrameCounter);
if(counterbuf[0])
DrawTextTrans(ClipSidesOffset+XBuf+FCEU_TextScanlineOffsetFromBottom(30)+1, 256, (uint8*)counterbuf, color+0x80);
}
if(rerecord_display && movieMode != MOVIEMODE_INACTIVE)
{
char counterbuf[32] = {0};
sprintf(counterbuf,"%d",currMovieData.rerecordCount);
if(counterbuf[0])
DrawTextTrans(ClipSidesOffset+XBuf+FCEU_TextScanlineOffsetFromBottom(50)+1, 256, (uint8*)counterbuf, 0x28+0x80);
}
}
void FCEU_DrawLagCounter(uint8 *XBuf)
@ -1361,11 +1247,33 @@ bool FCEUMOV_ReadState(EMUFILE* is, uint32 size)
{
load_successful = false;
//a little rule: cant load states in read+write mode with a movie from an archive.
//so we are going to switch it to readonly mode in that case
if(!movie_readonly && FCEU_isFileInArchive(curMovieFilename)) {
FCEU_PrintError("Cannot loadstate in Read+Write with movie from archive. Movie is now Read-Only.");
movie_readonly = true;
if (!movie_readonly)
{
if (currMovieData.loadFrameCount >= 0)
{
#ifdef WIN32
int result = MessageBox(hAppWnd, "This movie is a TAS Editor project file.\nIt can be modified in TAS Editor only.\n\nOpen it in TAS Editor now?", "Movie Replay", MB_YESNO);
if (result == IDYES)
{
extern bool EnterTasEdit();
extern bool LoadProject(char* fullname);
char fullname[512];
strcpy(fullname, curMovieFilename);
if (EnterTasEdit())
LoadProject(fullname);
}
#else
FCEUI_printf("This movie is a TAS Editor project file! It can be modified in TAS Editor only.\nMovie is now Read-Only.\n");
#endif
movie_readonly = true;
}
if (FCEU_isFileInArchive(curMovieFilename))
{
//a little rule: cant load states in read+write mode with a movie from an archive.
//so we are going to switch it to readonly mode in that case
FCEU_PrintError("Cannot loadstate in Read+Write with movie from archive. Movie is now Read-Only.");
movie_readonly = true;
}
}
MovieData tempMovieData = MovieData();
@ -1529,7 +1437,7 @@ bool FCEUMOV_ReadState(EMUFILE* is, uint32 size)
if (currFrameCounter > (int)tempMovieData.records.size())
{
//This is a post movie savestate, handle it differently
//Recplae movie contents but then switch to movie finished mode
//Replace movie contents but then switch to movie finished mode
currMovieData = tempMovieData;
openRecordingMovie(curMovieFilename);
currMovieData.dump(osRecordingMovie, false/*currMovieData.binaryFlag*/);
@ -1579,6 +1487,11 @@ void FCEUI_MovieToggleFrameDisplay(void)
frame_display=!frame_display;
}
void FCEUI_MovieToggleRerecordDisplay()
{
rerecord_display ^= 1;
}
void FCEUI_ToggleInputDisplay(void)
{
switch(input_display)
@ -1658,27 +1571,34 @@ void FCEUI_MovieToggleReadOnly()
void FCEUI_MoviePlayFromBeginning(void)
{
if (movieMode != MOVIEMODE_INACTIVE && movieMode != MOVIEMODE_TASEDIT)
if (movieMode == MOVIEMODE_TASEDIT)
{
movie_readonly = true;
#ifdef WIN32
playback.jump(0);
#endif
} else if (movieMode != MOVIEMODE_INACTIVE)
{
if (currMovieData.savestate.empty())
{
movie_readonly=true;
movieMode = MOVIEMODE_PLAY;
poweron(true);
currFrameCounter=0;
movieMode = MOVIEMODE_PLAY;
FCEU_DispMessage("Movie is now Read-Only. Playing from beginning.",0);
}
else
{
// movie starting from savestate - reload movie file
string str = curMovieFilename;
FCEUI_StopMovie();
if (FCEUI_LoadMovie(str.c_str(),1, 0, 0))
if (FCEUI_LoadMovie(str.c_str(), 1, 0))
{
movieMode = MOVIEMODE_PLAY;
movie_readonly=true;
movie_readonly = true;
FCEU_DispMessage("Movie is now Read-Only. Playing from beginning.",0);
}
//currMovieData.loadSavestateFrom(&currMovieData.savestate); //TODO: make something like this work instead so it doesn't have to reload
//currMovieData.loadSavestateFrom(&currMovieData.savestate); //TODO: make something like this work instead so it doesn't have to reload
}
}
#ifdef WIN32
@ -1717,6 +1637,8 @@ bool FCEUI_MovieGetInfo(FCEUFILE* fp, MOVIE_INFO& info, bool skipFrameCount)
//This function creates an array of frame numbers and corresponding strings for displaying subtitles
void LoadSubtitles(MovieData &moviedata)
{
subtitleFrames.resize(0);
subtitleMessages.resize(0);
extern std::vector<string> subtitles;
for(uint32 i=0; i < moviedata.subtitles.size() ; i++)
{
@ -1726,17 +1648,16 @@ void LoadSubtitles(MovieData &moviedata)
//If we can't split them, then don't process this one
if(splitat == std::string::npos)
{
}
{
}
//Else split the subtitle into the int and string arrays
else
{
key = subtitle.substr(0,splitat);
value = subtitle.substr(splitat+1);
subtitleFrames.push_back(atoi(key.c_str()));
subtitleMessages.push_back(value);
}
{
key = subtitle.substr(0,splitat);
value = subtitle.substr(splitat+1);
subtitleFrames.push_back(atoi(key.c_str()));
subtitleMessages.push_back(value);
}
}
}
@ -1761,7 +1682,7 @@ void FCEU_DisplaySubtitles(char *format, ...)
vsnprintf(subtitleMessage.errmsg,sizeof(subtitleMessage.errmsg),format,ap);
va_end(ap);
subtitleMessage.howlong = 300;
subtitleMessage.howlong = 400;
subtitleMessage.isMovieMessage = subtitlesOnAVI;
subtitleMessage.linesFromBottom = 0;
}

View File

@ -1,6 +1,8 @@
#ifndef __MOVIE_H_
#define __MOVIE_H_
#define PROGRESSBAR_UPDATE_RATE 2000 // in frames of greenzone
#include <vector>
#include <map>
#include <string>
@ -88,10 +90,10 @@ bool FCEUMOV_ReadState(EMUFILE* is, uint32 size);
void FCEUMOV_PreLoad();
bool FCEUMOV_PostLoad();
void FCEUMOV_EnterTasEdit();
void FCEUMOV_ExitTasEdit();
bool FCEUMOV_FromPoweron();
void CreateCleanMovie();
class MovieData;
class MovieRecord
{
@ -141,6 +143,7 @@ public:
}
bool Compare(MovieRecord& compareRec);
void Clone(MovieRecord& sourceRec);
void clear();
void parse(MovieData* md, EMUFILE* is);
@ -172,7 +175,6 @@ public:
std::string romFilename;
std::vector<uint8> savestate;
std::vector<MovieRecord> records;
std::vector<std::vector<uint8> > savestates;
std::vector<std::wstring> comments;
std::vector<std::string> subtitles;
//this is the RERECORD COUNT. please rename variable.
@ -181,6 +183,8 @@ public:
//was the frame data stored in binary?
bool binaryFlag;
// TAS Editor project files contain additional data after input
int loadFrameCount;
//which ports are defined for the movie
int ports[3];
@ -189,12 +193,6 @@ public:
//whether microphone is enabled
bool microphone;
//----TasEdit stuff---
int greenZoneCount;
int loadFrameCount;
int tweakCount;
//----
int getNumRecords() { return records.size(); }
class TDictionary : public std::map<std::string,std::string>
@ -228,19 +226,14 @@ public:
void truncateAt(int frame);
void installValue(std::string& key, std::string& val);
int dump(EMUFILE* os, bool binary);
int dumpGreenzone(EMUFILE *os, bool binary);
int loadGreenzone(EMUFILE *is, bool binary);
void clearRecordRange(int start, int len);
void insertEmpty(int at, int frames);
void cloneRegion(int at, int frames);
static bool loadSavestateFrom(std::vector<uint8>* buf);
static void dumpSavestateTo(std::vector<uint8>* buf, int compressionLevel);
bool loadTasSavestate(int frame);
void storeTasSavestate(int frame, int compression_level);
void TryDumpIncremental();
private:
void installInt(std::string& val, int& var)
{
@ -260,13 +253,12 @@ extern bool subtitlesOnAVI;
extern bool freshMovie;
extern bool movie_readonly;
extern bool autoMovieBackup;
extern int pauseframe;
extern bool fullSaveStateLoads;
//--------------------------------------------------
void FCEUI_MakeBackupMovie(bool dispMessage);
void FCEUI_CreateMovieFile(std::string fn);
void FCEUI_SaveMovie(const char *fname, EMOVIE_FLAG flags, std::wstring author);
bool FCEUI_LoadMovie(const char *fname, bool read_only, bool tasedit, int _stopframe);
bool FCEUI_LoadMovie(const char *fname, bool read_only, int _stopframe);
void FCEUI_MoviePlayFromBeginning(void);
void FCEUI_StopMovie(void);
bool FCEUI_MovieGetInfo(FCEUFILE* fp, MOVIE_INFO& info, bool skipFrameCount = false);
@ -278,6 +270,7 @@ int FCEUI_GetMovieLength();
int FCEUI_GetMovieRerecordCount();
std::string FCEUI_GetMovieName(void);
void FCEUI_MovieToggleFrameDisplay();
void FCEUI_MovieToggleRerecordDisplay();
void FCEUI_ToggleInputDisplay(void);
void LoadSubtitles(MovieData &);

View File

@ -62,7 +62,7 @@ pal palette[64] = {
{ 0x3F<<2, 0x3F<<2, 0x3F<<2 }, /* Value 32 */
{ 0x0F<<2, 0x2F<<2, 0x3F<<2 }, /* Value 33 */
{ 0x17<<2, 0x25<<2, 0x3F<<2 }, /* Value 34 */
{ 0x10<<2, 0x22<<2, 0x3F<<2 }, /* Value 35 */
{ 0x33<<2, 0x22<<2, 0x3F<<2 }, /* Value 35 */
{ 0x3D<<2, 0x1E<<2, 0x3F<<2 }, /* Value 36 */
{ 0x3F<<2, 0x1D<<2, 0x2D<<2 }, /* Value 37 */
{ 0x3F<<2, 0x1D<<2, 0x18<<2 }, /* Value 38 */

View File

@ -207,11 +207,15 @@ struct PPUREGS {
void increment_vs() {
fv++;
vt += (fv>>3);
int fv_overflow = (fv >> 3);
vt += fv_overflow;
vt &= 31; //fixed tecmo super bowl
v += (vt==30)?1:0;
if(vt == 30 && fv_overflow==1) //caution here (only do it at the exact instant of overflow) fixes p'radikus conflict
{
v++;
vt=0;
}
fv &= 7;
if(vt==30) vt=0;
v &= 1;
}
@ -345,6 +349,7 @@ static int maxsprites=8;
//scanline is equal to the current visible scanline we're on.
int scanline;
int g_rasterpos;
static uint32 scanlines_per_frame;
uint8 PPU[4];
@ -924,9 +929,7 @@ static DECLFW(B2005)
static DECLFW(B2006)
{
if(!newppu)
FCEUPPU_LineUpdate();
FCEUPPU_LineUpdate();
PPUGenLatch=V;
if(!vtoggle)
@ -965,6 +968,7 @@ static DECLFW(B2007)
uint32 tmp=RefreshAddr&0x3FFF;
if(newppu) {
PPUGenLatch=V;
RefreshAddr = ppur.get_2007access() & 0x3FFF;
CALL_PPUWRITE(RefreshAddr,V);
//printf("%04x ",RefreshAddr);
@ -1034,6 +1038,9 @@ static uint8 sprlinebuf[256+8];
void FCEUPPU_LineUpdate(void)
{
if(newppu)
return;
#ifdef FCEUDEF_DEBUGGER
if(!fceuindbg)
#endif
@ -2242,9 +2249,10 @@ int FCEUX_PPU_Loop(int skip) {
//int xscroll = ppur.fh;
//render 241 scanlines (including 1 dummy at beginning)
for(int sl=0;sl<241;sl++) {
spr_read.start_scanline();
spr_read.start_scanline();
ppur.status.sl = sl;
g_rasterpos = 0;
ppur.status.sl = sl;
const int yp = sl-1;
ppuphase = PPUPHASE_BG;
@ -2270,7 +2278,6 @@ int FCEUX_PPU_Loop(int skip) {
for(int xt=0;xt<32;xt++) {
bgdata.main[xt+2].Read();
//ok, we're also going to draw here.
//unless we're on the first dummy scanline
if(sl != 0) {
@ -2283,7 +2290,7 @@ int FCEUX_PPU_Loop(int skip) {
//check all the conditions that can cause things to render in these 8px
const bool renderspritenow = SpriteON && rendersprites && (xt>0 || SpriteLeft8);
const bool renderbgnow = ScreenON && renderbg && (xt>0 || BGLeft8);
for(int xp=0;xp<8;xp++,rasterpos++) {
for(int xp=0;xp<8;xp++,rasterpos++,g_rasterpos++) {
//bg pos is different from raster pos due to its offsetability.
//so adjust for that here
@ -2357,19 +2364,21 @@ int FCEUX_PPU_Loop(int skip) {
oamcount=0;
const int spriteHeight = Sprite16?16:8;
for(int i=0;i<64;i++) {
oams[scanslot][oamcount][7] = 0;
uint8* spr = SPRAM+i*4;
if(yp >= spr[0] && yp < spr[0]+spriteHeight) {
//if we already have maxsprites, then this new one causes an overflow,
//set the flag and bail out.
if(oamcount >= 8 && PPUON) {
PPU_status |= 0x20;
if (maxsprites == 8)
break;
if (maxsprites == 8)
break;
}
//just copy some bytes into the internal sprite buffer
for(int j=0;j<4;j++)
oams[scanslot][oamcount][j] = spr[j];
oams[scanslot][oamcount][7] = 1;
//note that we stuff the oam index into [6].
//i need to turn this into a struct so we can have fewer magic numbers
@ -2419,6 +2428,13 @@ int FCEUX_PPU_Loop(int skip) {
uint32 patternNumber = oam[1];
uint32 patternAddress;
//create deterministic dummy fetch pattern
if(!oam[7])
{
patternNumber = 0;
line = 0;
}
//8x16 sprite handling:
if(Sprite16) {
uint32 bank = (patternNumber&1)<<12;
@ -2435,27 +2451,28 @@ int FCEUX_PPU_Loop(int skip) {
patternAddress += line&7;
//garbage nametable fetches
//reset the scroll counter, happens at cycle 304
if (realSprite)
{
if ((sl == 0) && PPUON)
{
if (ppur.status.cycle == 304)
{
runppu(1);
ppur.install_latches();
runppu(1);
}
else
runppu(kFetchTime);
}
else
runppu(kFetchTime);
}
//Dragon's Lair (Europe version mapper 4)
//does not set SpriteON in the beginning but it does
//set the bg on so if using the conditional SpriteON the MMC3 counter
//the counter will never count and no IRQs will be fired so use PPUON
//reset the scroll counter, happens at cycle 304
if (realSprite)
{
if ((sl == 0) && PPUON)
{
if (ppur.status.cycle == 304)
{
runppu(1);
ppur.install_latches();
runppu(1);
}
else
runppu(kFetchTime);
}
else
runppu(kFetchTime);
}
//Dragon's Lair (Europe version mapper 4)
//does not set SpriteON in the beginning but it does
//set the bg on so if using the conditional SpriteON the MMC3 counter
//the counter will never count and no IRQs will be fired so use PPUON
if(((PPU[0]&0x38)!=0x18) && s == 2 && PPUON) { //SpriteON ) {
//(The MMC3 scanline counter is based entirely on PPU A12, triggered on rising edges (after the line remains low for a sufficiently long period of time))
//http://nesdevwiki.org/wiki/index.php/Nintendo_MMC3
@ -2518,7 +2535,8 @@ int FCEUX_PPU_Loop(int skip) {
//first one on every second frame, then this delay simply doesn't exist.
if (ppur.status.end_cycle == 341)
runppu(1);
}
} //scanline loop
if(MMC5Hack && PPUON) MMC5_hb(240);

View File

@ -33,6 +33,7 @@ extern uint8 FASTCALL FFCEUX_PPURead_Default(uint32 A);
void FFCEUX_PPUWrite_Default(uint32 A, uint8 V);
extern int scanline;
extern int g_rasterpos;
extern uint8 PPU[4];
enum PPUPHASE {

View File

@ -42,7 +42,7 @@ int32 WaveFinal[2048+512];
EXPSOUND GameExpSound={0,0,0};
static uint8 TriCount=0;
/*static*/ uint8 TriCount=0;
static uint8 TriMode=0;
static int32 tristep=0;
@ -50,29 +50,22 @@ static int32 tristep=0;
static int32 wlcount[4]={0,0,0,0}; /* Wave length counters. */
static uint8 IRQFrameMode=0; /* $4017 / xx000000 */
static uint8 PSG[0x10];
/*static*/ uint8 PSG[0x10];
static uint8 RawDALatch=0; /* $4011 0xxxxxxx */
/*static*/ uint8 InitialRawDALatch=0; // used only for lua
uint8 EnabledChannels=0; /* Byte written to $4015 */
typedef struct {
uint8 Speed;
uint8 Mode; /* Fixed volume(1), and loop(2) */
uint8 DecCountTo1;
uint8 decvolume;
int reloaddec;
} ENVUNIT;
static ENVUNIT EnvUnits[3];
/*static*/ ENVUNIT EnvUnits[3];
static const int RectDuties[4]={1,2,4,6};
static int32 RectDutyCount[2];
static uint8 sweepon[2];
static int32 curfreq[2];
/*static*/ int32 curfreq[2];
static uint8 SweepCount[2];
static uint16 nreg=0;
static uint16 nreg=0;
static uint8 fcnt=0;
static int32 fhcnt=0;
@ -87,7 +80,7 @@ uint32 soundtsi=0;
static int32 sqacc[2];
/* LQ variables segment ends. */
static int32 lengthcount[4];
/*static*/ int32 lengthcount[4];
static const uint8 lengthtable[0x20]=
{
10,254, 20, 2, 40, 4, 80, 6, 160, 8, 60, 10, 14, 12, 26, 14,
@ -95,19 +88,19 @@ static const uint8 lengthtable[0x20]=
};
static const uint32 NoiseFreqTableNTSC[0x10] =
static const uint32 NoiseFreqTableNTSC[0x10] =
{
4, 8, 16, 32, 64, 96, 128, 160, 202,
4, 8, 16, 32, 64, 96, 128, 160, 202,
254, 380, 508, 762, 1016, 2034, 4068
};
static const uint32 NoiseFreqTablePAL[0x10] =
static const uint32 NoiseFreqTablePAL[0x10] =
{
4, 7, 14, 30, 60, 88, 118, 148, 188,
4, 7, 14, 30, 60, 88, 118, 148, 188,
236, 354, 472, 708, 944, 1890, 3778
};
static const uint32 *NoiseFreqTable = NoiseFreqTableNTSC;
const uint32 *NoiseFreqTable = NoiseFreqTableNTSC; // for lua only
static const uint32 NTSCDMCTable[0x10]=
{
@ -123,7 +116,7 @@ static const uint32 NTSCDMCTable[0x10]=
static const uint32 PALDMCTable[0x10]=
{
398, 354, 316, 298, 276, 236, 210, 198,
398, 354, 316, 298, 276, 236, 210, 198,
176, 148, 132, 118, 98, 78, 66, 50
};
@ -133,20 +126,20 @@ static const uint32 PALDMCTable[0x10]=
// $4013 - Size register: Size in bytes = (V+1)*64
/*static*/ int32 DMCacc=1;
static int32 DMCPeriod=0;
/*static*/ int32 DMCPeriod=0;
/*static*/ uint8 DMCBitCount=0;
static uint8 DMCAddressLatch=0,DMCSizeLatch=0; /* writes to 4012 and 4013 */
static uint8 DMCFormat=0; /* Write to $4010 */
/*static*/ uint8 DMCAddressLatch=0,DMCSizeLatch=0; /* writes to 4012 and 4013 */
/*static*/ uint8 DMCFormat=0; /* Write to $4010 */
static uint32 DMCAddress=0;
static int32 DMCSize=0;
static uint8 DMCShift=0;
static uint8 DMCShift=0;
static uint8 SIRQStat=0;
static char DMCHaveDMA=0;
static uint8 DMCDMABuf=0;
static char DMCHaveSample=0;
static uint8 DMCDMABuf=0;
/*static*/ char DMCHaveSample=0;
static void Dummyfunc(void) {};
static void (*DoNoise)(void)=Dummyfunc;
@ -205,7 +198,7 @@ void LogDPCM(int romaddress, int dpcmsize){
/* Instantaneous? Maybe the new freq value is being calculated all of the time... */
static int CheckFreq(uint32 cf, uint8 sr)
/*static*/ int CheckFreq(uint32 cf, uint8 sr)
{
uint32 mod;
if(!(sr&0x8))
@ -220,7 +213,7 @@ static int CheckFreq(uint32 cf, uint8 sr)
static void SQReload(int x, uint8 V)
{
if(EnabledChannels&(1<<x))
{
{
if(x)
DoSQ2();
else
@ -230,7 +223,7 @@ static void SQReload(int x, uint8 V)
sweepon[x]=PSG[(x<<2)|1]&0x80;
curfreq[x]=PSG[(x<<2)|0x2]|((V&7)<<8);
SweepCount[x]=((PSG[(x<<2)|0x1]>>4)&7)+1;
SweepCount[x]=((PSG[(x<<2)|0x1]>>4)&7)+1;
RectDutyCount[x]=7;
EnvUnits[x].reloaddec=1;
@ -257,19 +250,19 @@ static DECLFW(Write_PSG)
case 0x3:
SQReload(0,V);
break;
case 0x4:
case 0x4:
DoSQ2();
EnvUnits[1].Mode=(V&0x30)>>4;
EnvUnits[1].Speed=(V&0xF);
break;
case 0x5:
case 0x5:
sweepon[1]=V&0x80;
break;
case 0x6:DoSQ2();
curfreq[1]&=0xFF00;
curfreq[1]|=V;
break;
case 0x7:
case 0x7:
SQReload(1,V);
break;
case 0xa:DoTriangle();
@ -321,7 +314,7 @@ static DECLFW(Write_DMCRegs)
if(SIRQStat&0x80)
{
if(!(V&0x80))
{
{
X6502_IRQEnd(FCEU_IQDPCM);
SIRQStat&=~0x80;
}
@ -330,7 +323,8 @@ static DECLFW(Write_DMCRegs)
DMCFormat=V;
break;
case 0x01:DoPCM();
RawDALatch=V&0x7F;
InitialRawDALatch=V&0x7F;
RawDALatch=InitialRawDALatch;
break;
case 0x02:DMCAddressLatch=V;break;
case 0x03:DMCSizeLatch=V;break;
@ -408,7 +402,7 @@ static void FrameSoundStuff(int V)
{
if(!(PSG[P<<2]&0x20)) /* Make sure loop flag is not set. */
if(lengthcount[P]>0)
lengthcount[P]--;
lengthcount[P]--;
/* Frequency Sweep Code Here */
/* xxxx 0000 */
@ -417,13 +411,13 @@ static void FrameSoundStuff(int V)
{
int32 mod=0;
if(SweepCount[P]>0) SweepCount[P]--;
if(SweepCount[P]>0) SweepCount[P]--;
if(SweepCount[P]<=0)
{
SweepCount[P]=((PSG[(P<<2)+0x1]>>4)&7)+1; //+1;
if(PSG[(P<<2)+0x1]&0x8)
{
mod-=(P^1)+((curfreq[P])>>(PSG[(P<<2)+0x1]&7));
mod-=(P^1)+((curfreq[P])>>(PSG[(P<<2)+0x1]&7));
if(curfreq[P] && (PSG[(P<<2)+0x1]&7)/* && sweepon[P]&0x80*/)
{
curfreq[P]+=mod;
@ -443,14 +437,14 @@ static void FrameSoundStuff(int V)
{
curfreq[P]+=mod;
}
}
}
}
}
}
else /* Sweeping is disabled: */
{
//curfreq[P]&=0xFF00;
//curfreq[P]|=PSG[(P<<2)|0x2]; //|((PSG[(P<<2)|3]&7)<<8);
//curfreq[P]|=PSG[(P<<2)|0x2]; //|((PSG[(P<<2)|3]&7)<<8);
}
}
}
@ -521,7 +515,7 @@ static INLINE void tester(void)
DMCShift=DMCDMABuf;
DMCHaveDMA=0;
}
}
}
}
static INLINE void DMCDMA(void)
@ -568,7 +562,7 @@ fhcnt-=cycles*48;
uint8 bah=RawDALatch;
int t=((DMCShift&1)<<2)-2;
/* Unbelievably ugly hack */
/* Unbelievably ugly hack */
if(FSettings.SndRate)
{
soundtsoffs+=DMCacc;
@ -582,7 +576,7 @@ fhcnt-=cycles*48;
DMCacc+=DMCPeriod;
DMCBitCount=(DMCBitCount+1)&7;
DMCShift>>=1;
DMCShift>>=1;
tester();
}
}
@ -592,7 +586,7 @@ void RDoPCM(void)
uint32 V; //mbg merge 7/17/06 made uint32
for(V=ChannelBC[4];V<SOUNDTS;V++)
WaveHi[V]+=(((RawDALatch<<16)/256) * FSettings.PCMVolume)&(~0xFFFF); // TODO get rid of floating calculations to binary. set log volume scaling.
WaveHi[V]+=(((RawDALatch<<16)/256) * FSettings.PCMVolume)&(~0xFFFF); // TODO get rid of floating calculations to binary. set log volume scaling.
ChannelBC[4]=SOUNDTS;
}
@ -618,19 +612,19 @@ static INLINE void RDoSQ(int x) //Int x decides if this is Square Wave 1 or 2
amp=EnvUnits[x].Speed;
else
amp=EnvUnits[x].decvolume; //Set the volume of the Square Wave
//Modify Square wave volume based on channel volume modifiers
//adelikat: Note: the formulat x = x * y /100 does not yield exact results, but is "close enough" and avoids the need for using double vales or implicit cohersion which are slower (we need speed here)
ampx = x ? FSettings.Square2Volume : FSettings.Square1Volume; // TODO OPTIMIZE ME!
if (ampx != 256) amp = (amp * ampx) / 256; // CaH4e3: fixed - setting up maximum volume for square2 caused complete mute square2 channel
amp<<=24;
rthresh=RectDuties[(PSG[(x<<2)]&0xC0)>>6];
D=&WaveHi[ChannelBC[x]];
V=SOUNDTS-ChannelBC[x];
currdc=RectDutyCount[x];
cf=(curfreq[x]+1)*2;
rc=wlcount[x];
@ -647,8 +641,8 @@ static INLINE void RDoSQ(int x) //Int x decides if this is Square Wave 1 or 2
}
V--;
D++;
}
}
RectDutyCount[x]=currdc;
wlcount[x]=rc;
@ -666,9 +660,9 @@ static void RDoSQ2(void)
RDoSQ(1);
}
static void RDoSQLQ(void)
static void RDoSQLQ(void)
{
int32 start,end;
int32 start,end;
int32 V;
int32 amp[2], ampx;
int32 rthresh[2];
@ -742,7 +736,7 @@ static void RDoSQLQ(void)
Wave[V>>4]+=totalout; //tmpamp;
sqacc[0]-=inie[0];
sqacc[1]-=inie[1];
sqacc[1]-=inie[1];
if(sqacc[0]<=0)
{
@ -826,7 +820,7 @@ static void RDoTriangleNoisePCMLQ(void)
end=(SOUNDTS<<16)/soundtsinc;
if(end<=start) return;
ChannelBC[2]=end;
inie[0]=inie[1]=nesincsize;
freq[0]=(((PSG[0xa]|((PSG[0xb]&7)<<8))+1));
@ -835,15 +829,15 @@ static void RDoTriangleNoisePCMLQ(void)
inie[0]=0;
freq[0]<<=17;
if(EnvUnits[2].Mode&0x1)
if(EnvUnits[2].Mode&0x1)
amptab[0]=EnvUnits[2].Speed;
else
amptab[0]=EnvUnits[2].decvolume;
//Modify Square wave volume based on channel volume modifiers
//Modify Square wave volume based on channel volume modifiers
//adelikat: Note: the formulat x = x * y /100 does not yield exact results, but is "close enough" and avoids the need for using double vales or implicit cohersion which are slower (we need speed here)
if (FSettings.TriangleVolume != 256) amptab[0] = (amptab[0] * FSettings.TriangleVolume) / 256; // TODO OPTIMIZE ME!
amptab[1]=0;
amptab[0]<<=1;
@ -851,7 +845,7 @@ static void RDoTriangleNoisePCMLQ(void)
amptab[0]=inie[1]=0; /* Quick hack speedup, set inie[1] to 0 */
noiseout=amptab[(nreg>>0xe)&1];
if(PSG[0xE]&0x80)
nshift=8;
else
@ -872,7 +866,7 @@ static void RDoTriangleNoisePCMLQ(void)
if(triacc<=0)
{
rea:
triacc+=freq[0]; //t;
triacc+=freq[0]; //t;
tristep=(tristep+1)&0x1F;
if(triacc<=0) goto rea;
tcout=(tristep&0xF);
@ -886,10 +880,13 @@ static void RDoTriangleNoisePCMLQ(void)
rea2:
//used to added <<(16+2) when the noise table
//values were half.
noiseacc+=NoiseFreqTable[PSG[0xE]&0xF]<<(16+1);
if(PAL)
noiseacc+=NoiseFreqTablePAL[PSG[0xE]&0xF]<<(16+1);
else
noiseacc+=NoiseFreqTableNTSC[PSG[0xE]&0xF]<<(16+1);
nreg=(nreg<<1)+(((nreg>>nshift)^(nreg>>14))&1);
nreg&=0x7fff;
noiseout=amptab[(nreg>>0xe)];
noiseout=amptab[(nreg>>0xe)&1];
if(noiseacc<=0) goto rea2;
totalout = wlookup2[tcout+noiseout+RawDALatch];
} /* noiseacc<=0 */
@ -927,10 +924,13 @@ static void RDoTriangleNoisePCMLQ(void)
area2:
//used to be added <<(16+2) when the noise table
//values were half.
noiseacc+=NoiseFreqTable[PSG[0xE]&0xF]<<(16+1);
if(PAL)
noiseacc+=NoiseFreqTablePAL[PSG[0xE]&0xF]<<(16+1);
else
noiseacc+=NoiseFreqTableNTSC[PSG[0xE]&0xF]<<(16+1);
nreg=(nreg<<1)+(((nreg>>nshift)^(nreg>>14))&1);
nreg&=0x7fff;
noiseout=amptab[(nreg>>0xe)];
noiseout=amptab[(nreg>>0xe)&1];
if(noiseacc<=0) goto area2;
totalout = wlookup2[tcout+noiseout+RawDALatch];
} /* noiseacc<=0 */
@ -963,7 +963,7 @@ static void RDoNoise(void)
amptab[0]<<=1;
outo=amptab[nreg&1]; //(nreg>>0xe)&1];
outo=amptab[(nreg>>0xe)&1];
if(!lengthcount[3])
{
@ -978,7 +978,10 @@ static void RDoNoise(void)
if(!wlcount[3])
{
uint8 feedback;
wlcount[3]=NoiseFreqTable[PSG[0xE]&0xF];
if(PAL)
wlcount[3]=NoiseFreqTablePAL[PSG[0xE]&0xF];
else
wlcount[3]=NoiseFreqTableNTSC[PSG[0xE]&0xF];
feedback=((nreg>>8)&1)^((nreg>>14)&1);
nreg=(nreg<<1)+feedback;
nreg&=0x7fff;
@ -993,7 +996,10 @@ static void RDoNoise(void)
if(!wlcount[3])
{
uint8 feedback;
wlcount[3]=NoiseFreqTable[PSG[0xE]&0xF];
if(PAL)
wlcount[3]=NoiseFreqTablePAL[PSG[0xE]&0xF];
else
wlcount[3]=NoiseFreqTableNTSC[PSG[0xE]&0xF];
feedback=((nreg>>13)&1)^((nreg>>14)&1);
nreg=(nreg<<1)+feedback;
nreg&=0x7fff;
@ -1007,7 +1013,7 @@ DECLFW(Write_IRQFM)
{
V=(V&0xC0)>>6;
fcnt=0;
if(V&0x2)
if(V&0x2)
FrameSoundUpdate();
fcnt=1;
fhcnt=fhinc;
@ -1017,7 +1023,7 @@ DECLFW(Write_IRQFM)
}
void SetNESSoundMap(void)
{
{
SetWriteHandler(0x4000,0x400F,Write_PSG);
SetWriteHandler(0x4010,0x4013,Write_DMCRegs);
SetWriteHandler(0x4017,0x4017,Write_IRQFM);
@ -1055,7 +1061,7 @@ int FlushEmulateSound(void)
for(x=timestamp;x;x--)
{
uint32 b=*tmpo;
uint32 b=*tmpo;
*tmpo=(b&65535)+wlookup2[(b>>16)&255]+wlookup1[b>>24];
tmpo++;
}
@ -1115,17 +1121,12 @@ due to that whole MegaMan 2 Game Genie thing.
void FCEUSND_Reset(void)
{
int x;
IRQFrameMode=0x0;
fhcnt=fhinc;
fcnt=0;
nreg=1;
if (PAL)
NoiseFreqTable = NoiseFreqTablePAL;
else
NoiseFreqTable = NoiseFreqTableNTSC;
for(x=0;x<2;x++)
{
wlcount[x]=2048;
@ -1136,7 +1137,7 @@ void FCEUSND_Reset(void)
sweepon[x]=0;
curfreq[x]=0;
}
wlcount[2]=1; //2048;
wlcount[3]=2048;
@ -1161,7 +1162,7 @@ void FCEUSND_Reset(void)
// MAJOR BUG WAS HERE: DMCacc and DMCBitCount never got reset...
// so, do some ridiculous hackery if a movie's about to play to keep it in sync...
if(movieSyncHackOn)
{
if(resetDMCacc)
@ -1195,7 +1196,7 @@ void FCEUSND_Reset(void)
void FCEUSND_Power(void)
{
int x;
SetNESSoundMap();
memset(PSG,0x00,sizeof(PSG));
FCEUSND_Reset();
@ -1213,7 +1214,7 @@ void FCEUSND_Power(void)
void SetSoundVariables(void)
{
int x;
int x;
fhinc=PAL?16626:14915; // *2 CPU clock rate
fhinc*=24;
@ -1249,7 +1250,7 @@ void SetSoundVariables(void)
DoNoise=RDoTriangleNoisePCMLQ;
DoPCM=RDoTriangleNoisePCMLQ;
}
}
}
else
{
DoNoise=DoTriangle=DoPCM=DoSQ1=DoSQ2=Dummyfunc;
@ -1320,7 +1321,7 @@ void FCEUI_SetPCMVolume(uint32 volume)
SFORMAT FCEUSND_STATEINFO[]={
{ &fhcnt, 4|FCEUSTATE_RLSB,"FHCN"},
{ &fcnt, 1, "FCNT"},
{ &fcnt, 1, "FCNT"},
{ PSG, 0x10, "PSG"},
{ &EnabledChannels, 1, "ENCH"},
{ &IRQFrameMode, 1, "IQFM"},

View File

@ -73,4 +73,12 @@ void Write_IRQFM (uint32 A, uint8 V); //mbg merge 7/17/06 brought over from late
void LogDPCM(int romaddress, int dpcmsize);
typedef struct {
uint8 Speed;
uint8 Mode; /* Fixed volume(1), and loop(2) */
uint8 DecCountTo1;
uint8 decvolume;
int reloaddec;
} ENVUNIT;
#endif

View File

@ -617,18 +617,17 @@ int FCEUSS_LoadFP_old(EMUFILE* is, ENUM_SSLOADPARAMS params)
bool FCEUSS_LoadFP(EMUFILE* is, ENUM_SSLOADPARAMS params)
{
if(!is) return false;
//maybe make a backup savestate
EMUFILE_MEMORY msBackupSavestate;
bool backup = (params == SSLOADPARAM_BACKUP);
if(!is)
return false;
EMUFILE_MEMORY msBackupSavestate;
if(backup)
{
FCEUSS_SaveMS(&msBackupSavestate,Z_NO_COMPRESSION);
}
uint8 header[16];
//read and analyze the header
is->fread((char*)&header,16);
if(memcmp(header,"FCSX",4)) {
@ -725,7 +724,8 @@ bool FCEUSS_Load(const char *fname)
if(st == NULL || (st->get_fp() == NULL))
{
FCEU_DispMessage("State %d load error. Filename: %s",0,CurrentState, fn);
FCEU_DispMessage("State %d load error.",0,CurrentState);
//FCEU_DispMessage("State %d load error. Filename: %s",0,CurrentState, fn);
SaveStateStatus[CurrentState]=0;
return false;
}
@ -739,11 +739,13 @@ bool FCEUSS_Load(const char *fname)
{
char szFilename[260]={0};
splitpath(fname, 0, 0, szFilename, 0);
FCEU_DispMessage("State %s loaded. Filename: %s",0,szFilename, fn);
FCEU_DispMessage("State %s loaded.",0,szFilename);
//FCEU_DispMessage("State %s loaded. Filename: %s",0,szFilename, fn);
}
else
{
FCEU_DispMessage("State %d loaded. Filename: %s",0,CurrentState, fn);
FCEU_DispMessage("State %d loaded.",0,CurrentState);
//FCEU_DispMessage("State %d loaded. Filename: %s",0,CurrentState, fn);
SaveStateStatus[CurrentState]=1;
}
delete st;
@ -786,7 +788,8 @@ bool FCEUSS_Load(const char *fname)
{
SaveStateStatus[CurrentState]=1;
}
FCEU_DispMessage("Error(s) reading state %d! Filename: %s",0,CurrentState, fn);
FCEU_DispMessage("Error(s) reading state %d!",0,CurrentState);
//FCEU_DispMessage("Error(s) reading state %d! Filename: %s",0,CurrentState, fn);
delete st;
return 0;
}
@ -833,7 +836,7 @@ void AddExState(void *v, uint32 s, int type, char *desc)
{
if(desc)
{
SFMDATA[SFEXINDEX].desc=(char *)FCEU_malloc(5);
SFMDATA[SFEXINDEX].desc=(char *)FCEU_malloc(strlen(desc)+1);
strcpy(SFMDATA[SFEXINDEX].desc,desc);
}
else
@ -1026,7 +1029,7 @@ void SwapSaveState()
redoSS = true;
FCEUI_DispMessage("%s restored",0,backup.c_str());
FCEUI_printf("%s restored\n",0,backup.c_str());
FCEUI_printf("%s restored\n",backup.c_str());
}
//------------------------------------------------------------------------------------------------------------------------------------------------------

View File

@ -392,12 +392,12 @@ static BMAPPING bmap[] = {
{ "SMB2J", UNLSMB2J_Init, 0},
{ "AX5705", UNLAX5705_Init, 0},
{ "CC-21", UNLCC21_Init,0},
{ "H2288", UNLH2288_Init,0},
{ "KOF97", UNLKOF97_Init,0},
{ "SL1632", UNLSL1632_Init,0},
{ "SHERO", UNLSHeroes_Init,0},
{ "8237", UNL8237_Init,0},
{ "8237A", UNL8237A_Init,0},
{ "8157", UNL8157_Init,0},
{ "T-262", BMCT262_Init,0},
{ "FK23C", BMCFK23C_Init,0},
@ -438,8 +438,6 @@ static BMAPPING bmap[] = {
{ "TEK90", Mapper90_Init,0},
{ "COPYFAMI_MMC3", MapperCopyFamiMMC3_Init,0},
{0,0,0}
};

View File

@ -108,6 +108,7 @@ void UNLA9746_Init(CartInfo *info);
void UNLSHeroes_Init(CartInfo *info);
void UNLH2288_Init(CartInfo *info);
void UNL8237_Init(CartInfo *info);
void UNL8237A_Init(CartInfo *info);
void UNL8157_Init(CartInfo *info);
void UNL22211_Init(CartInfo *info);
void UNLTF1201_Init(CartInfo *info);
@ -127,7 +128,5 @@ void BMC411120C_Init(CartInfo *info);
void BMC830118C_Init(CartInfo *info);
void BMCT2271_Init(CartInfo *info);
void MapperCopyFamiMMC3_Init(CartInfo *info);
extern uint8 *UNIFchrrama; // Meh. So I can stop CHR RAM
// bank switcherooing with certain boards...

View File

@ -526,6 +526,21 @@ char *U32ToDecStr(uint32 a)
{
return U32ToDecStr(TempArray,a);
}
char *U32ToDecStr(char* buf, uint32 a, int digits)
{
if (digits < 1)
digits = 1;
else if (digits > 10)
digits = 10;
for (int i = 1; i <= digits; ++i)
{
buf[digits - i] = '0' + (a % 10);
a /= 10;
}
buf[digits] = 0;
return buf;
}
char *U16ToHexStr(uint16 a)
{

View File

@ -57,6 +57,7 @@ uint16 FastStrToU16(char* s, bool& valid);
char *U16ToDecStr(uint16 a);
char *U32ToDecStr(uint32 a);
char *U32ToDecStr(char* buf, uint32 a);
char *U32ToDecStr(char* buf, uint32 a, int digits);
char *U8ToDecStr(uint8 a);
char *U8ToHexStr(uint8 a);
char *U16ToHexStr(uint16 a);

View File

@ -58,8 +58,8 @@
#define FCEU_COMPILER_DETAIL ""
#endif
#define FCEU_VERSION_NUMERIC 21040
#define FCEU_VERSION_STRING "2.1.5" FCEU_SUBVERSION_STRING FCEU_FEATURE_STRING FCEU_COMPILER
#define FCEU_VERSION_NUMERIC 21060
#define FCEU_VERSION_STRING "2.1.6" FCEU_SUBVERSION_STRING FCEU_FEATURE_STRING FCEU_COMPILER
#define FCEU_NAME_AND_VERSION FCEU_NAME " " FCEU_VERSION_STRING
#endif

View File

@ -28,10 +28,6 @@
#include <stdarg.h>
#include <zlib.h>
#ifdef _USE_SHARED_MEMORY_
#include <windows.h>
#endif
#include "types.h"
#include "video.h"
#include "fceu.h"
@ -73,10 +69,6 @@ extern uint32 cur_input_display;
bool oldInputDisplay = false;
#ifdef _USE_SHARED_MEMORY_
HANDLE mapXBuf;
#endif
std::string AsSnapshotName =""; //adelikat:this will set the snapshot name when for s savesnapshot as function
void FCEUI_SetSnapshotAsName(std::string name) { AsSnapshotName = name; }
@ -114,38 +106,12 @@ int FCEU_InitVirtualVideo(void)
/* 256 bytes per scanline, * 240 scanline maximum, +16 for alignment,
*/
#ifdef _USE_SHARED_MEMORY_
mapXBuf = CreateFileMapping((HANDLE)0xFFFFFFFF,NULL,PAGE_READWRITE, 0, 256 * 256 + 16, "fceu.XBuf");
if(mapXBuf == NULL || GetLastError() == ERROR_ALREADY_EXISTS)
{
CloseHandle(mapXBuf);
mapXBuf = NULL;
XBuf = (uint8*) (FCEU_malloc(256 * 256 + 16));
XBackBuf = (uint8*) (FCEU_malloc(256 * 256 + 16));
}
else
{
XBuf = (uint8 *)MapViewOfFile(mapXBuf, FILE_MAP_WRITE, 0, 0, 0);
XBackBuf = (uint8*) (FCEU_malloc(256 * 256 + 16));
}
if (!XBuf || !XBackBuf)
{
return 0;
}
#else
if(!(XBuf= (uint8*) (FCEU_malloc(256 * 256 + 16))) ||
!(XBackBuf= (uint8*) (FCEU_malloc(256 * 256 + 16))))
{
return 0;
}
#endif //_USE_SHARED_MEMORY_
xbsave = XBuf;
if( sizeof(uint8*) == 4 )
@ -243,16 +209,15 @@ void FCEU_PutImage(void)
FCEU_LuaGui(XBuf);
#endif
//Update AVI before overlay stuff is written
if(!FCEUI_EmulationPaused())
FCEUI_AviVideoUpdate(XBuf);
//Save snapshot before overlay stuff is written.
//Save snapshot
if(dosnapsave==1)
{
ReallySnap();
dosnapsave=0;
}
if (!FCEUI_AviEnableHUDrecording()) snapAVI();
if(GameInfo->type==GIT_VSUNI)
FCEU_VSUniDraw(XBuf);
@ -263,8 +228,6 @@ void FCEU_PutImage(void)
FCEU_DrawRecordingStatus(XBuf);
}
DrawMessage(false);
if(FCEUD_ShouldDrawInputAids())
FCEU_DrawInput(XBuf);
@ -447,6 +410,26 @@ void FCEU_PutImage(void)
}
}
}
if (FCEUI_AviEnableHUDrecording())
{
if (FCEUI_AviDisableMovieMessages())
{
snapAVI();
DrawMessage(false);
} else
{
DrawMessage(false);
snapAVI();
}
} else DrawMessage(false);
}
void snapAVI()
{
//Update AVI
if(!FCEUI_EmulationPaused())
FCEUI_AviVideoUpdate(XBuf);
}
void FCEU_DispMessageOnMovie(char *format, ...)
@ -471,6 +454,11 @@ void FCEU_DispMessage(char *format, int disppos=0, ...)
va_start(ap,disppos);
vsnprintf(guiMessage.errmsg,sizeof(guiMessage.errmsg),format,ap);
// also log messages
char temp[2048];
vsnprintf(temp,sizeof(temp),format,ap);
strcat(temp, "\n");
FCEU_printf(temp);
va_end(ap);
guiMessage.howlong = 180;
@ -565,7 +553,6 @@ int SaveSnapshot(void)
{
unsigned int lastu=0;
char *fn=0;
int totallines=FSettings.LastSLine-FSettings.FirstSLine+1;
int x,u,y;
FILE *pp=NULL;
@ -577,20 +564,19 @@ int SaveSnapshot(void)
for(u=lastu;u<99999;u++)
{
pp=FCEUD_UTF8fopen((fn=strdup(FCEU_MakeFName(FCEUMKF_SNAP,u,"png").c_str())),"rb");
pp=FCEUD_UTF8fopen(FCEU_MakeFName(FCEUMKF_SNAP,u,"png").c_str(),"rb");
if(pp==NULL) break;
fclose(pp);
}
lastu=u;
if(!(pp=FCEUD_UTF8fopen(fn,"wb")))
if(!(pp=FCEUD_UTF8fopen(FCEU_MakeFName(FCEUMKF_SNAP,u,"png").c_str(),"wb")))
{
free(fn);
free(compmem);
return 0;
}
free(fn);
{
static uint8 header[8]={137,80,78,71,13,10,26,10};
if(fwrite(header,8,1,pp)!=1)
@ -678,8 +664,6 @@ int SaveSnapshot(char fileName[512])
if(!(compmem=(uint8 *)FCEU_malloc(compmemsize)))
return 0;
pp = fopen(fileName, "w");
if(!(pp=FCEUD_UTF8fopen(fileName,"wb")))
{
free(compmem);

View File

@ -28,4 +28,5 @@ extern GUIMESSAGE subtitleMessage;
void FCEU_DrawNumberRow(uint8 *XBuf, int *nstatus, int cur);
std::string FCEUI_GetSnapshotAsName();
void FCEUI_SetSnapshotAsName(std::string name);
void FCEUI_SetSnapshotAsName(std::string name);
void snapAVI();

View File

@ -479,7 +479,7 @@ extern int test; test++;
}
//will probably cause a major speed decrease on low-end systems
DEBUG( DebugCycle() );
DEBUG( DebugCycle() );
_PI=_P;
b1=RdMem(_PC);

View File

@ -158,6 +158,8 @@ DUMMY(FCEUD_AviStop)
void FCEUI_AviVideoUpdate(const unsigned char* buffer) { }
int FCEUD_ShowStatusIcon(void) { return 0; }
bool FCEUI_AviIsRecording(void) { return 0; }
bool FCEUI_AviEnableHUDrecording() { return 0; }
void FCEUI_SetAviEnableHUDrecording(bool enable) { }
bool FCEUI_AviDisableMovieMessages() { return true; }
const char *FCEUD_GetCompilerString() { return NULL; }
void FCEUI_UseInputPreset(int preset) { }