mirror of
https://github.com/dborth/fceugx.git
synced 2025-01-09 15:19:26 +01:00
sync to latest FCEUX svn
This commit is contained in:
parent
e7d364ed0a
commit
475e0f92a6
@ -23,6 +23,8 @@
|
||||
static uint8 bus_conflict = 0;
|
||||
static uint8 latche, latcheinit;
|
||||
static uint16 addrreg0, addrreg1;
|
||||
static uint8 *WRAM=NULL;
|
||||
static uint32 WRAMSIZE;
|
||||
static void(*WSync)(void);
|
||||
|
||||
static DECLFW(LatchWrite)
|
||||
@ -39,23 +41,44 @@ static void LatchPower(void)
|
||||
{
|
||||
latche=latcheinit;
|
||||
WSync();
|
||||
SetReadHandler(0x8000,0xFFFF,CartBR);
|
||||
SetReadHandler(0x6000,0xFFFF,CartBR);
|
||||
SetWriteHandler(0x6000,0x7FFF,CartBW);
|
||||
SetWriteHandler(addrreg0,addrreg1,LatchWrite);
|
||||
}
|
||||
|
||||
static void LatchClose(void)
|
||||
{
|
||||
if(WRAM)
|
||||
FCEU_gfree(WRAM);
|
||||
WRAM=NULL;
|
||||
}
|
||||
|
||||
static void StateRestore(int version)
|
||||
{
|
||||
WSync();
|
||||
}
|
||||
|
||||
static void Latch_Init(CartInfo *info, void (*proc)(void), uint8 init, uint16 adr0, uint16 adr1)
|
||||
static void Latch_Init(CartInfo *info, void (*proc)(void), uint8 init, uint16 adr0, uint16 adr1, uint8 wram)
|
||||
{
|
||||
latcheinit=init;
|
||||
addrreg0=adr0;
|
||||
addrreg1=adr1;
|
||||
WSync=proc;
|
||||
info->Power=LatchPower;
|
||||
info->Close=LatchClose;
|
||||
GameStateRestore=StateRestore;
|
||||
if(wram)
|
||||
{
|
||||
WRAMSIZE=8192;
|
||||
WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);
|
||||
SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);
|
||||
if(info->battery)
|
||||
{
|
||||
info->SaveGame[0]=WRAM;
|
||||
info->SaveGameLen[0]=WRAMSIZE;
|
||||
}
|
||||
AddExState(WRAM, WRAMSIZE, 0, "WRAM");
|
||||
}
|
||||
AddExState(&latche, 1, 0, "LATC");
|
||||
AddExState(&bus_conflict, 1, 0, "BUSC");
|
||||
}
|
||||
@ -72,7 +95,7 @@ static void CPROMSync(void)
|
||||
|
||||
void CPROM_Init(CartInfo *info)
|
||||
{
|
||||
Latch_Init(info, CPROMSync, 0, 0x8000, 0xFFFF);
|
||||
Latch_Init(info, CPROMSync, 0, 0x8000, 0xFFFF, 0);
|
||||
}
|
||||
|
||||
//------------------ Map 184 ---------------------------
|
||||
@ -87,7 +110,7 @@ static void M184Sync(void)
|
||||
|
||||
void Mapper184_Init(CartInfo *info)
|
||||
{
|
||||
Latch_Init(info, M184Sync, 0, 0x6000, 0x7FFF);
|
||||
Latch_Init(info, M184Sync, 0, 0x6000, 0x7FFF, 0);
|
||||
}
|
||||
|
||||
//------------------ CNROM ---------------------------
|
||||
@ -99,12 +122,13 @@ static void CNROMSync(void)
|
||||
setchr8(latche);
|
||||
setprg16(0x8000,0);
|
||||
setprg16(0xC000,1);
|
||||
setprg8r(0x10,0x6000,0); // Hayauchy IGO uses 2Kb or RAM
|
||||
}
|
||||
|
||||
void CNROM_Init(CartInfo *info)
|
||||
{
|
||||
bus_conflict = 1;
|
||||
Latch_Init(info, CNROMSync, 0, 0x8000, 0xFFFF);
|
||||
Latch_Init(info, CNROMSync, 0, 0x8000, 0xFFFF, 1);
|
||||
}
|
||||
|
||||
//------------------ ANROM ---------------------------
|
||||
@ -118,7 +142,7 @@ static void ANROMSync()
|
||||
|
||||
void ANROM_Init(CartInfo *info)
|
||||
{
|
||||
Latch_Init(info, ANROMSync, 0, 0x8000, 0xFFFF);
|
||||
Latch_Init(info, ANROMSync, 0, 0x8000, 0xFFFF, 0);
|
||||
}
|
||||
|
||||
//------------------ Map 70 ---------------------------
|
||||
@ -132,7 +156,7 @@ static void M70Sync()
|
||||
|
||||
void Mapper70_Init(CartInfo *info)
|
||||
{
|
||||
Latch_Init(info, M70Sync, 0, 0x8000, 0xFFFF);
|
||||
Latch_Init(info, M70Sync, 0, 0x8000, 0xFFFF, 0);
|
||||
}
|
||||
|
||||
//------------------ Map 152 ---------------------------
|
||||
@ -147,7 +171,7 @@ static void M152Sync()
|
||||
|
||||
void Mapper152_Init(CartInfo *info)
|
||||
{
|
||||
Latch_Init(info, M152Sync, 0, 0x8000, 0xFFFF);
|
||||
Latch_Init(info, M152Sync, 0, 0x8000, 0xFFFF, 0);
|
||||
}
|
||||
|
||||
//------------------ Map 78 ---------------------------
|
||||
@ -162,7 +186,7 @@ static void M78Sync()
|
||||
|
||||
void Mapper78_Init(CartInfo *info)
|
||||
{
|
||||
Latch_Init(info, M78Sync, 0, 0x8000, 0xFFFF);
|
||||
Latch_Init(info, M78Sync, 0, 0x8000, 0xFFFF, 0);
|
||||
}
|
||||
|
||||
//------------------ MHROM ---------------------------
|
||||
@ -175,17 +199,17 @@ static void MHROMSync(void)
|
||||
|
||||
void MHROM_Init(CartInfo *info)
|
||||
{
|
||||
Latch_Init(info, MHROMSync, 0, 0x8000, 0xFFFF);
|
||||
Latch_Init(info, MHROMSync, 0, 0x8000, 0xFFFF, 0);
|
||||
}
|
||||
|
||||
void Mapper140_Init(CartInfo *info)
|
||||
{
|
||||
Latch_Init(info, MHROMSync, 0, 0x6000, 0x7FFF);
|
||||
Latch_Init(info, MHROMSync, 0, 0x6000, 0x7FFF, 0);
|
||||
}
|
||||
|
||||
void Mapper240_Init(CartInfo *info)
|
||||
{
|
||||
Latch_Init(info, MHROMSync, 0, 0x4020, 0x5FFF);
|
||||
Latch_Init(info, MHROMSync, 0, 0x4020, 0x5FFF, 0);
|
||||
// need SRAM.
|
||||
}
|
||||
|
||||
@ -201,7 +225,7 @@ static void M87Sync(void)
|
||||
|
||||
void Mapper87_Init(CartInfo *info)
|
||||
{
|
||||
Latch_Init(info, M87Sync, ~0, 0x6000, 0xFFFF);
|
||||
Latch_Init(info, M87Sync, ~0, 0x6000, 0xFFFF, 0);
|
||||
}
|
||||
|
||||
//------------------ Map 101 ---------------------------
|
||||
@ -215,7 +239,7 @@ static void M101Sync(void)
|
||||
|
||||
void Mapper101_Init(CartInfo *info)
|
||||
{
|
||||
Latch_Init(info, M101Sync, ~0, 0x6000, 0x7FFF);
|
||||
Latch_Init(info, M101Sync, ~0, 0x6000, 0x7FFF, 0);
|
||||
}
|
||||
|
||||
//------------------ Map 11 ---------------------------
|
||||
@ -228,12 +252,12 @@ static void M11Sync(void)
|
||||
|
||||
void Mapper11_Init(CartInfo *info)
|
||||
{
|
||||
Latch_Init(info, M11Sync, 0, 0x8000, 0xFFFF);
|
||||
Latch_Init(info, M11Sync, 0, 0x8000, 0xFFFF, 0);
|
||||
}
|
||||
|
||||
void Mapper144_Init(CartInfo *info)
|
||||
{
|
||||
Latch_Init(info, M11Sync, 0, 0x8001, 0xFFFF);
|
||||
Latch_Init(info, M11Sync, 0, 0x8001, 0xFFFF, 0);
|
||||
}
|
||||
|
||||
//------------------ Map 38 ---------------------------
|
||||
@ -246,7 +270,7 @@ static void M38Sync(void)
|
||||
|
||||
void Mapper38_Init(CartInfo *info)
|
||||
{
|
||||
Latch_Init(info, M38Sync, 0, 0x7000, 0x7FFF);
|
||||
Latch_Init(info, M38Sync, 0, 0x7000, 0x7FFF, 0);
|
||||
}
|
||||
|
||||
//------------------ Map 36 ---------------------------
|
||||
@ -259,7 +283,7 @@ static void M36Sync(void)
|
||||
|
||||
void Mapper36_Init(CartInfo *info)
|
||||
{
|
||||
Latch_Init(info, M36Sync, 0, 0x8400, 0xfffe);
|
||||
Latch_Init(info, M36Sync, 0, 0x8400, 0xfffe, 0);
|
||||
}
|
||||
//------------------ UNROM ---------------------------
|
||||
|
||||
@ -273,7 +297,7 @@ static void UNROMSync(void)
|
||||
void UNROM_Init(CartInfo *info)
|
||||
{
|
||||
bus_conflict = 1;
|
||||
Latch_Init(info, UNROMSync, 0, 0x8000, 0xFFFF);
|
||||
Latch_Init(info, UNROMSync, 0, 0x8000, 0xFFFF, 0);
|
||||
}
|
||||
|
||||
//------------------ Map 93 ---------------------------
|
||||
@ -287,7 +311,7 @@ static void SSUNROMSync(void)
|
||||
|
||||
void SUNSOFT_UNROM_Init(CartInfo *info)
|
||||
{
|
||||
Latch_Init(info, SSUNROMSync, 0, 0x8000, 0xFFFF);
|
||||
Latch_Init(info, SSUNROMSync, 0, 0x8000, 0xFFFF, 0);
|
||||
}
|
||||
|
||||
//------------------ Map 94 ---------------------------
|
||||
@ -301,7 +325,7 @@ static void M94Sync(void)
|
||||
|
||||
void Mapper94_Init(CartInfo *info)
|
||||
{
|
||||
Latch_Init(info, M94Sync, 0, 0x8000, 0xFFFF);
|
||||
Latch_Init(info, M94Sync, 0, 0x8000, 0xFFFF, 0);
|
||||
}
|
||||
|
||||
//------------------ Map 180 ---------------------------
|
||||
@ -315,7 +339,7 @@ static void M180Sync(void)
|
||||
|
||||
void Mapper180_Init(CartInfo *info)
|
||||
{
|
||||
Latch_Init(info, M180Sync, 0, 0x8000, 0xFFFF);
|
||||
Latch_Init(info, M180Sync, 0, 0x8000, 0xFFFF, 0);
|
||||
}
|
||||
|
||||
//------------------ Map 107 ---------------------------
|
||||
@ -328,7 +352,7 @@ static void M107Sync(void)
|
||||
|
||||
void Mapper107_Init(CartInfo *info)
|
||||
{
|
||||
Latch_Init(info, M107Sync, ~0, 0x8000, 0xFFFF);
|
||||
Latch_Init(info, M107Sync, ~0, 0x8000, 0xFFFF, 0);
|
||||
}
|
||||
|
||||
//------------------ Map 113 ---------------------------
|
||||
@ -342,7 +366,7 @@ static void M113Sync(void)
|
||||
|
||||
void Mapper113_Init(CartInfo *info)
|
||||
{
|
||||
Latch_Init(info, M113Sync, 0, 0x4100, 0x7FFF);
|
||||
Latch_Init(info, M113Sync, 0, 0x4100, 0x7FFF, 0);
|
||||
}
|
||||
|
||||
//------------------ A65AS ---------------------------
|
||||
@ -370,7 +394,7 @@ static void BMCA65ASSync(void)
|
||||
|
||||
void BMCA65AS_Init(CartInfo *info)
|
||||
{
|
||||
Latch_Init(info, BMCA65ASSync, 0, 0x8000, 0xFFFF);
|
||||
Latch_Init(info, BMCA65ASSync, 0, 0x8000, 0xFFFF, 0);
|
||||
}
|
||||
|
||||
//------------------ NROM ---------------------------
|
||||
@ -379,15 +403,21 @@ void BMCA65AS_Init(CartInfo *info)
|
||||
static DECLFW(WriteHandler)
|
||||
{
|
||||
FCEU_printf("bs %04x %02x\n",A,V);
|
||||
CartBW(A,V);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void NROMPower(void)
|
||||
{
|
||||
setprg8r(0x10,0x6000,0); // Famili BASIC (v3.0) need it (uses only 4KB), FP-BASIC uses 8KB
|
||||
setprg16(0x8000,0);
|
||||
setprg16(0xC000,~0);
|
||||
setchr8(0);
|
||||
|
||||
SetReadHandler(0x6000,0x6FFF,CartBR);
|
||||
SetWriteHandler(0x6000,0x6FFF,CartBW);
|
||||
SetReadHandler(0x8000,0xFFFF,CartBR);
|
||||
|
||||
#ifdef DEBUG_MAPPER
|
||||
SetWriteHandler(0x4020,0xFFFF,WriteHandler);
|
||||
#endif
|
||||
@ -396,4 +426,16 @@ static void NROMPower(void)
|
||||
void NROM_Init(CartInfo *info)
|
||||
{
|
||||
info->Power=NROMPower;
|
||||
info->Close=LatchClose;
|
||||
|
||||
WRAMSIZE=8192;
|
||||
WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);
|
||||
SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);
|
||||
if(info->battery)
|
||||
{
|
||||
info->SaveGame[0]=WRAM;
|
||||
info->SaveGameLen[0]=WRAMSIZE;
|
||||
}
|
||||
AddExState(WRAM, WRAMSIZE, 0, "WRAM");
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* FCE Ultra - NES/Famicom Emulator
|
||||
*
|
||||
* Copyright notice for this file:
|
||||
* Copyright (C) 2007 CaH4e3
|
||||
* Copyright (C) 2007-2010 CaH4e3
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -17,106 +17,183 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* OneBus system
|
||||
* Street Dance (Dance pad) (Unl)
|
||||
* 101-in-1 Arcade Action II
|
||||
* DreamGEAR 75-in-1
|
||||
*/
|
||||
|
||||
#include "mapinc.h"
|
||||
|
||||
static uint8 reg4[16];
|
||||
static uint8 regc[6];
|
||||
static uint8 reg2000, mmc3cmd, pcm_enable = 0, pcm_irq = 0;
|
||||
static uint8 isDance;
|
||||
static uint8 regs[16],regc[6];
|
||||
static uint8 IRQCount,IRQLatch,IRQa, IRQReload, pcm_enable = 0, pcm_irq = 0;
|
||||
static int16 pcm_addr, pcm_size, pcm_latch, pcm_clock = 0xF6;
|
||||
static writefunc old4011write, old4012write, old4013write, old4015write;
|
||||
static readfunc old4015read;
|
||||
|
||||
static SFORMAT StateRegs[]=
|
||||
{
|
||||
{reg4, 16, "reg4"},
|
||||
{regc, 6, "REGSC"},
|
||||
{®2000, 1, "REGS2"},
|
||||
{regc, 6, "REGC"},
|
||||
{regs, 16, "REGS"},
|
||||
{&IRQReload, 1, "IRQR"},
|
||||
{&IRQCount, 1, "IRQC"},
|
||||
{&IRQLatch, 1, "IRQL"},
|
||||
{&IRQa, 1, "IRQA"},
|
||||
{&pcm_enable, 1, "PCME"},
|
||||
{&pcm_irq, 1, "PCMIRQ"},
|
||||
{&pcm_addr, 2, "PCMADDR"},
|
||||
{&pcm_size, 2, "PCMSIZE"},
|
||||
{&pcm_latch, 2, "PCMLATCH"},
|
||||
{&pcm_clock, 2, "PCMCLOCK"},
|
||||
{&mmc3cmd, 1, "MMC3CMD"},
|
||||
{0}
|
||||
};
|
||||
|
||||
static void Sync(void)
|
||||
{
|
||||
uint8 cbase = reg2000 - ((reg4[0x0B]&4)?6:0);
|
||||
uint8 pbase = reg4[0x09] & 0xC0;
|
||||
uint16 cswap = (regs[0xf] & 0x80) << 5;
|
||||
uint16 pswap = (regs[0xd]&1)?((regs[0xf] & 0x40) << 8):0;
|
||||
uint16 pbase = (regs[0]&0xf0)<<4;
|
||||
uint16 cbase = (((regs[0]&0x0f)<<8)|(regs[0xc]<<1)|((regs[0xd]&0xf8)>>3))<<3;
|
||||
uint16 pmask = 0x3f>>(regs[0xb]&0xf);
|
||||
|
||||
setchr1(0x0000,cbase|(regc[0]&(~1)));
|
||||
setchr1(0x0400,cbase|(regc[0]|1));
|
||||
setchr1(0x0800,cbase|(regc[1]&(-1)));
|
||||
setchr1(0x0c00,cbase|(regc[1]|1));
|
||||
setchr1(0x1000,cbase|regc[2]);
|
||||
setchr1(0x1400,cbase|regc[3]);
|
||||
setchr1(0x1800,cbase|regc[4]);
|
||||
setchr1(0x1c00,cbase|regc[5]);
|
||||
setchr1(cswap^0x0000,cbase|(regc[0]&(~1)));
|
||||
setchr1(cswap^0x0400,cbase|(regc[0]|1));
|
||||
setchr1(cswap^0x0800,cbase|(regc[1]&(-1)));
|
||||
setchr1(cswap^0x0c00,cbase|(regc[1]|1));
|
||||
setchr1(cswap^0x1000,cbase|(regc[2]));
|
||||
setchr1(cswap^0x1400,cbase|(regc[3]));
|
||||
setchr1(cswap^0x1800,cbase|(regc[4]));
|
||||
setchr1(cswap^0x1c00,cbase|(regc[5]));
|
||||
|
||||
|
||||
if(reg4[0x0B]&1)
|
||||
if(regs[0xd]&2)
|
||||
{
|
||||
setprg8(0x8000,reg4[0x07] + 0x20);
|
||||
setprg8(0xA000,reg4[0x08] + 0x20);
|
||||
setprg8(pswap^0x8000, pbase|(regs[0x7]&pmask)|(regs[0xa]&(~pmask)));
|
||||
setprg8( 0xA000, pbase|(regs[0x8]&pmask)|(regs[0xa]&(~pmask)));
|
||||
setprg8(pswap^0xC000, pbase|(regs[0x9]&pmask)|(regs[0xa]&(~pmask)));
|
||||
setprg8( 0xE000, pbase|regs[0xa]);
|
||||
}
|
||||
else
|
||||
{
|
||||
setprg8(0x8000,reg4[0x07] + pbase);
|
||||
setprg8(0xA000,reg4[0x08] + pbase);
|
||||
setprg8(pswap^0x8000, pbase|(regs[0x7]&pmask)|(regs[0xa]&(~pmask)));
|
||||
setprg8( 0xA000, pbase|(regs[0x8]&pmask)|(regs[0xa]&(~pmask)));
|
||||
setprg8(pswap^0xC000, pbase|((~1)&pmask)|(regs[0xa]&(~pmask)));
|
||||
setprg8( 0xE000, pbase|((~0)&pmask)|(regs[0xa]&(~pmask)));
|
||||
}
|
||||
|
||||
setprg8(0xC000,reg4[0x09]);
|
||||
setprg8(0xE000,reg4[0x0A]);
|
||||
setmirror(regs[0xe]);
|
||||
}
|
||||
|
||||
static DECLFW(UNLDANCEWrite2)
|
||||
static DECLFW(UNLOneBusWrite20XX)
|
||||
{
|
||||
reg2000 = V;
|
||||
// FCEU_printf("PPU %04x:%04x\n",A,V);
|
||||
if(A == 0x201A)
|
||||
regs[0xd] = V;
|
||||
else if(A == 0x2018)
|
||||
regs[0xc] = V;
|
||||
Sync();
|
||||
}
|
||||
|
||||
static DECLFW(UNLOneBusWriteExp)
|
||||
{
|
||||
// FCEU_printf("EXP %04x:%04x\n",A,V);
|
||||
// switch(A & 0x0F)
|
||||
// {
|
||||
// case 2: pcm_latch = pcm_clock; FCEU_printf("write %04x:%04x\n",A,V); break;
|
||||
// case 3: pcm_irqa = 0; X6502_IRQEnd(FCEU_IQEXT); pcm_irq = 0; FCEU_printf("write %04x:%04x\n",A,V); break;
|
||||
// case 4: pcm_irqa = 1; FCEU_printf("write %04x:%04x\n",A,V); break;
|
||||
// default:
|
||||
regs[A & 0x0F] = V;
|
||||
Sync();
|
||||
// }
|
||||
}
|
||||
|
||||
static DECLFW(UNLOneBusWriteDebug)
|
||||
{
|
||||
// FCEU_printf("write %04x:%04x\n",A,V);
|
||||
}
|
||||
|
||||
static DECLFW(UNLDANCEWrite4)
|
||||
static DECLFW(UNLOneBusWriteMMC)
|
||||
{
|
||||
reg4[A & 0x0F] = V;
|
||||
Sync();
|
||||
//FCEU_printf("write %04x:%04x\n",A,V);
|
||||
}
|
||||
|
||||
static DECLFW(UNLDANCEWrite8)
|
||||
// FCEU_printf("MMC %04x:%04x\n",A,V);
|
||||
switch(A&0xE001)
|
||||
{
|
||||
if(A&1)
|
||||
case 0x8000: regs[0xf] = V; Sync(); break;
|
||||
case 0x8001:
|
||||
{
|
||||
if(mmc3cmd<6)
|
||||
regc[mmc3cmd] = V;
|
||||
uint8 mask = 0xff, mmc3cmd = regs[0xf]&7;
|
||||
switch(mmc3cmd)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
if(regs[0xd]&4)
|
||||
mask = 0x0f;
|
||||
else
|
||||
reg4[0x07 + mmc3cmd - 6] = V;
|
||||
mask >>= ((regs[0xb]&0xf0)>>4);
|
||||
regc[mmc3cmd] = V&mask;
|
||||
break;
|
||||
case 6:
|
||||
case 7:
|
||||
mask = (mask&0x3f)>>(regs[0xb]&0xf);
|
||||
regs[mmc3cmd+1] = (regs[mmc3cmd+1]&(~mask))|(V&mask);
|
||||
break;
|
||||
}
|
||||
|
||||
Sync();
|
||||
break;
|
||||
}
|
||||
case 0xA000: regs[0xe] = (V & 1)^1; Sync(); break;
|
||||
case 0xC000: IRQLatch = V&0xfe; break;
|
||||
case 0xC001: IRQReload = 1; break;
|
||||
case 0xE000: X6502_IRQEnd(FCEU_IQEXT); IRQa = 0; break;
|
||||
case 0xE001: IRQa = 1; break;
|
||||
}
|
||||
}
|
||||
|
||||
static void UNLOneBusIRQHook(void)
|
||||
{
|
||||
int count = IRQCount;
|
||||
if(!count || IRQReload)
|
||||
{
|
||||
IRQCount = IRQLatch;
|
||||
IRQReload = 0;
|
||||
}
|
||||
else
|
||||
mmc3cmd = V & 7;
|
||||
Sync();
|
||||
//FCEU_printf("write %04x:%04x\n",A,V);
|
||||
IRQCount--;
|
||||
if(count && !IRQCount)
|
||||
{
|
||||
if(IRQa)
|
||||
X6502_IRQBegin(FCEU_IQEXT);
|
||||
}
|
||||
}
|
||||
|
||||
static DECLFW(UNLDANCEWrite4012)
|
||||
static DECLFW(UNLOneBusWriteAPU2)
|
||||
{
|
||||
// FCEU_printf("APU2 %04x:%04x\n",A,V);
|
||||
CartBW(A&0xffdf,V);
|
||||
}
|
||||
|
||||
static DECLFW(UNLOneBusWrite4012)
|
||||
{
|
||||
// FCEU_printf("write %04x:%04x\n",A,V);
|
||||
pcm_addr = V << 6;
|
||||
old4012write(A,V);
|
||||
}
|
||||
|
||||
static DECLFW(UNLDANCEWrite4013)
|
||||
static DECLFW(UNLOneBusWrite4013)
|
||||
{
|
||||
// FCEU_printf("write %04x:%04x\n",A,V);
|
||||
pcm_size = (V << 4) + 1;
|
||||
old4013write(A,V);
|
||||
}
|
||||
|
||||
static DECLFW(UNLDANCEWrite4015)
|
||||
static DECLFW(UNLOneBusWrite4015)
|
||||
{
|
||||
// FCEU_printf("write %04x:%04x\n",A,V);
|
||||
pcm_enable = V&0x10;
|
||||
if(pcm_irq)
|
||||
{
|
||||
@ -128,12 +205,14 @@ static DECLFW(UNLDANCEWrite4015)
|
||||
old4015write(A,V&0xEF);
|
||||
}
|
||||
|
||||
static DECLFR(UNLDANCERead4015)
|
||||
static DECLFR(UNLOneBusRead4015)
|
||||
{
|
||||
return (old4015read(A) & 0x7F) | pcm_irq;
|
||||
uint8 result = (old4015read(A) & 0x7F)|pcm_irq;
|
||||
// FCEU_printf("read %04x, %02x\n",A,result);
|
||||
return result;
|
||||
}
|
||||
|
||||
static void UNLDANCECpuHook(int a)
|
||||
static void UNLOneBusCpuHook(int a)
|
||||
{
|
||||
if(pcm_enable)
|
||||
{
|
||||
@ -159,34 +238,45 @@ static void UNLDANCECpuHook(int a)
|
||||
}
|
||||
}
|
||||
|
||||
static void UNLDANCEPower(void)
|
||||
static void UNLOneBusPower(void)
|
||||
{
|
||||
reg4[0x09]=0x3E;
|
||||
reg4[0x0A]=0x3F;
|
||||
SetupCartCHRMapping(0,PRGptr[0],512 * 1024,0);
|
||||
IRQCount=IRQLatch=IRQa==0;
|
||||
regs[0]=regs[1]=regs[1]=regs[2]=regs[3]=regs[4]=regs[5]=regs[6]=0;
|
||||
regs[7]=regs[8]=regs[11]=regs[12]=regs[13]=regs[14]=regs[15]=0;
|
||||
regs[0x09]=0x3E;
|
||||
regs[0x0A]=0x3F;
|
||||
|
||||
SetupCartCHRMapping(0,PRGptr[0],4096 * 1024,0);
|
||||
|
||||
if(isDance) // quick workaround, TODO: figure out how it works together
|
||||
{
|
||||
old4015read=GetReadHandler(0x4015);
|
||||
SetReadHandler(0x4015,0x4015,UNLDANCERead4015);
|
||||
SetReadHandler(0x8000,0xFFFF,CartBR);
|
||||
|
||||
SetReadHandler(0x4015,0x4015,UNLOneBusRead4015);
|
||||
old4011write=GetWriteHandler(0x4011);
|
||||
old4012write=GetWriteHandler(0x4012);
|
||||
SetWriteHandler(0x4012,0x4012,UNLDANCEWrite4012);
|
||||
SetWriteHandler(0x4012,0x4012,UNLOneBusWrite4012);
|
||||
old4013write=GetWriteHandler(0x4013);
|
||||
SetWriteHandler(0x4013,0x4013,UNLDANCEWrite4013);
|
||||
SetWriteHandler(0x4013,0x4013,UNLOneBusWrite4013);
|
||||
old4015write=GetWriteHandler(0x4015);
|
||||
SetWriteHandler(0x4015,0x4015,UNLDANCEWrite4015);
|
||||
SetWriteHandler(0x4015,0x4015,UNLOneBusWrite4015);
|
||||
}
|
||||
|
||||
SetWriteHandler(0x201A,0x201A,UNLDANCEWrite2);
|
||||
SetWriteHandler(0x4100,0x410F,UNLDANCEWrite4);
|
||||
SetWriteHandler(0x8000,0x8001,UNLDANCEWrite8);
|
||||
SetReadHandler(0x8000,0xFFFF,CartBR);
|
||||
SetWriteHandler(0x2009,0x2fff,UNLOneBusWrite20XX);
|
||||
// SetWriteHandler(0x4020,0xffff,UNLOneBusWriteDebug);
|
||||
// SetWriteHandler(0x4020,0x4040,UNLOneBusWriteAPU2);
|
||||
SetWriteHandler(0x4100,0x410f,UNLOneBusWriteExp);
|
||||
SetWriteHandler(0x8000,0xefff,UNLOneBusWriteMMC);
|
||||
Sync();
|
||||
}
|
||||
|
||||
static void UNLDANCEReset(void)
|
||||
static void UNLOneBusReset(void)
|
||||
{
|
||||
reg4[0x09]=0x3E;
|
||||
reg4[0x0A]=0x3F;
|
||||
IRQCount=IRQLatch=IRQa=0;
|
||||
regs[0]=regs[1]=regs[1]=regs[2]=regs[3]=regs[4]=regs[5]=regs[6]=0;
|
||||
regs[7]=regs[8]=regs[11]=regs[12]=regs[13]=regs[14]=regs[15]=0;
|
||||
regs[0x09]=0x3E;
|
||||
regs[0x0A]=0x3F;
|
||||
Sync();
|
||||
}
|
||||
|
||||
@ -195,11 +285,24 @@ static void StateRestore(int version)
|
||||
Sync();
|
||||
}
|
||||
|
||||
void UNLDANCE_Init(CartInfo *info)
|
||||
void UNLOneBus_Init(CartInfo *info)
|
||||
{
|
||||
info->Power=UNLDANCEPower;
|
||||
info->Reset=UNLDANCEReset;
|
||||
MapIRQHook=UNLDANCECpuHook;
|
||||
isDance = 0;
|
||||
info->Power=UNLOneBusPower;
|
||||
info->Reset=UNLOneBusReset;
|
||||
GameHBIRQHook=UNLOneBusIRQHook;
|
||||
// MapIRQHook=UNLOneBusCpuHook;
|
||||
GameStateRestore=StateRestore;
|
||||
AddExState(&StateRegs, ~0, 0, 0);
|
||||
}
|
||||
|
||||
void UNLDANCE_Init(CartInfo *info)
|
||||
{
|
||||
isDance = 1;
|
||||
info->Power=UNLOneBusPower;
|
||||
info->Reset=UNLOneBusReset;
|
||||
GameHBIRQHook=UNLOneBusIRQHook;
|
||||
MapIRQHook=UNLOneBusCpuHook;
|
||||
GameStateRestore=StateRestore;
|
||||
AddExState(&StateRegs, ~0, 0, 0);
|
||||
}
|
||||
|
@ -31,7 +31,7 @@
|
||||
* Compare -> Sum {('==' | '!=' | '<=' | '>=' | '<' | '>') Sum}
|
||||
* Sum -> Product {('+' | '-') Product}
|
||||
* Product -> Primitive {('*' | '/') Primitive}
|
||||
* Primitive -> Number | Address | Register | Flag | '(' Connect ')'
|
||||
* Primitive -> Number | Address | Register | Flag | PC Bank | '(' Connect ')'
|
||||
* Number -> '#' [1-9A-F]*
|
||||
* Address -> '$' [1-9A-F]* | '$' '[' Connect ']'
|
||||
* Register -> 'A' | 'X' | 'Y' | 'R'
|
||||
@ -228,7 +228,7 @@ Condition* Primitive(const char** str, Condition* c)
|
||||
|
||||
return c;
|
||||
}
|
||||
else if (isBank(next)) /* Registers */
|
||||
else if (isBank(next)) /* PC Bank */
|
||||
{
|
||||
if (c->type1 == TYPE_NO)
|
||||
{
|
||||
|
@ -1,4 +1,25 @@
|
||||
#include "types.h"
|
||||
/*
|
||||
Copyright (C) 2009-2010 DeSmuME team
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "emufile.h"
|
||||
|
||||
#include <vector>
|
||||
@ -13,16 +34,226 @@ bool EMUFILE::readAllBytes(std::vector<u8>* dstbuf, const std::string& fname)
|
||||
return true;
|
||||
}
|
||||
|
||||
EMUFILE* EMUFILE::memwrap(EMUFILE* fp)
|
||||
size_t EMUFILE_MEMORY::_fread(const void *ptr, size_t bytes){
|
||||
u32 remain = len-pos;
|
||||
u32 todo = std::min<u32>(remain,(u32)bytes);
|
||||
if(len==0)
|
||||
{
|
||||
EMUFILE_FILE* file;
|
||||
EMUFILE_MEMORY* mem;
|
||||
file = dynamic_cast<EMUFILE_FILE*>(fp);
|
||||
mem = dynamic_cast<EMUFILE_MEMORY*>(fp);
|
||||
if(mem) return mem;
|
||||
mem = new EMUFILE_MEMORY(file->size());
|
||||
if(file->size()==0) return mem;
|
||||
file->fread(mem->buf(),file->size());
|
||||
delete file;
|
||||
failbit = true;
|
||||
return 0;
|
||||
}
|
||||
if(todo<=4)
|
||||
{
|
||||
u8* src = buf()+pos;
|
||||
u8* dst = (u8*)ptr;
|
||||
for(size_t i=0;i<todo;i++)
|
||||
*dst++ = *src++;
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy((void*)ptr,buf()+pos,todo);
|
||||
}
|
||||
pos += todo;
|
||||
if(todo<bytes)
|
||||
failbit = true;
|
||||
return todo;
|
||||
}
|
||||
|
||||
void EMUFILE_FILE::truncate(s32 length)
|
||||
{
|
||||
fflush(fp);
|
||||
#ifdef _MSC_VER
|
||||
_chsize(_fileno(fp),length);
|
||||
#else
|
||||
ftruncate(fileno(fp),length);
|
||||
#endif
|
||||
fclose(fp);
|
||||
fp = NULL;
|
||||
open(fname.c_str(),mode);
|
||||
}
|
||||
|
||||
|
||||
EMUFILE* EMUFILE_FILE::memwrap()
|
||||
{
|
||||
EMUFILE_MEMORY* mem = new EMUFILE_MEMORY(size());
|
||||
if(size()==0) return mem;
|
||||
fread(mem->buf(),size());
|
||||
return mem;
|
||||
}
|
||||
|
||||
EMUFILE* EMUFILE_MEMORY::memwrap()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
void EMUFILE::write64le(u64* val)
|
||||
{
|
||||
write64le(*val);
|
||||
}
|
||||
|
||||
void EMUFILE::write64le(u64 val)
|
||||
{
|
||||
#ifdef LOCAL_BE
|
||||
u8 s[8];
|
||||
s[0]=(u8)b;
|
||||
s[1]=(u8)(b>>8);
|
||||
s[2]=(u8)(b>>16);
|
||||
s[3]=(u8)(b>>24);
|
||||
s[4]=(u8)(b>>32);
|
||||
s[5]=(u8)(b>>40);
|
||||
s[6]=(u8)(b>>48);
|
||||
s[7]=(u8)(b>>56);
|
||||
fwrite((char*)&s,8);
|
||||
return 8;
|
||||
#else
|
||||
fwrite(&val,8);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
size_t EMUFILE::read64le(u64 *Bufo)
|
||||
{
|
||||
u64 buf;
|
||||
if(fread((char*)&buf,8) != 8)
|
||||
return 0;
|
||||
#ifndef LOCAL_BE
|
||||
*Bufo=buf;
|
||||
#else
|
||||
*Bufo = LE_TO_LOCAL_64(buf);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
u64 EMUFILE::read64le()
|
||||
{
|
||||
u64 temp;
|
||||
read64le(&temp);
|
||||
return temp;
|
||||
}
|
||||
|
||||
void EMUFILE::write32le(u32* val)
|
||||
{
|
||||
write32le(*val);
|
||||
}
|
||||
|
||||
void EMUFILE::write32le(u32 val)
|
||||
{
|
||||
#ifdef LOCAL_BE
|
||||
u8 s[4];
|
||||
s[0]=(u8)val;
|
||||
s[1]=(u8)(val>>8);
|
||||
s[2]=(u8)(val>>16);
|
||||
s[3]=(u8)(val>>24);
|
||||
fwrite(s,4);
|
||||
#else
|
||||
fwrite(&val,4);
|
||||
#endif
|
||||
}
|
||||
|
||||
size_t EMUFILE::read32le(s32* Bufo) { return read32le((u32*)Bufo); }
|
||||
|
||||
size_t EMUFILE::read32le(u32* Bufo)
|
||||
{
|
||||
u32 buf;
|
||||
if(fread(&buf,4)<4)
|
||||
return 0;
|
||||
#ifndef LOCAL_BE
|
||||
*(u32*)Bufo=buf;
|
||||
#else
|
||||
*(u32*)Bufo=((buf&0xFF)<<24)|((buf&0xFF00)<<8)|((buf&0xFF0000)>>8)|((buf&0xFF000000)>>24);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
u32 EMUFILE::read32le()
|
||||
{
|
||||
u32 ret;
|
||||
read32le(&ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void EMUFILE::write16le(u16* val)
|
||||
{
|
||||
write16le(*val);
|
||||
}
|
||||
|
||||
void EMUFILE::write16le(u16 val)
|
||||
{
|
||||
#ifdef LOCAL_BE
|
||||
u8 s[2];
|
||||
s[0]=(u8)val;
|
||||
s[1]=(u8)(val>>8);
|
||||
fwrite(s,2);
|
||||
#else
|
||||
fwrite(&val,2);
|
||||
#endif
|
||||
}
|
||||
|
||||
size_t EMUFILE::read16le(s16* Bufo) { return read16le((u16*)Bufo); }
|
||||
|
||||
size_t EMUFILE::read16le(u16* Bufo)
|
||||
{
|
||||
u32 buf;
|
||||
if(fread(&buf,2)<2)
|
||||
return 0;
|
||||
#ifndef LOCAL_BE
|
||||
*(u16*)Bufo=buf;
|
||||
#else
|
||||
*Bufo = LE_TO_LOCAL_16(buf);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
u16 EMUFILE::read16le()
|
||||
{
|
||||
u16 ret;
|
||||
read16le(&ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void EMUFILE::write8le(u8* val)
|
||||
{
|
||||
write8le(*val);
|
||||
}
|
||||
|
||||
|
||||
void EMUFILE::write8le(u8 val)
|
||||
{
|
||||
fwrite(&val,1);
|
||||
}
|
||||
|
||||
size_t EMUFILE::read8le(u8* val)
|
||||
{
|
||||
return fread(val,1);
|
||||
}
|
||||
|
||||
u8 EMUFILE::read8le()
|
||||
{
|
||||
u8 temp;
|
||||
fread(&temp,1);
|
||||
return temp;
|
||||
}
|
||||
|
||||
void EMUFILE::writedouble(double* val)
|
||||
{
|
||||
write64le(double_to_u64(*val));
|
||||
}
|
||||
void EMUFILE::writedouble(double val)
|
||||
{
|
||||
write64le(double_to_u64(val));
|
||||
}
|
||||
|
||||
double EMUFILE::readdouble()
|
||||
{
|
||||
double temp;
|
||||
readdouble(&temp);
|
||||
return temp;
|
||||
}
|
||||
|
||||
size_t EMUFILE::readdouble(double* val)
|
||||
{
|
||||
u64 temp;
|
||||
size_t ret = read64le(&temp);
|
||||
*val = u64_to_double(temp);
|
||||
return ret;
|
||||
}
|
@ -1,22 +1,27 @@
|
||||
/* Copyright (C) 2009 DeSmuME team
|
||||
*
|
||||
* This file is part of DeSmuME
|
||||
*
|
||||
* DeSmuME 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.
|
||||
*
|
||||
* DeSmuME 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 DeSmuME; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
/*
|
||||
Copyright (C) 2009-2010 DeSmuME team
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
//don't use emufile for files bigger than 2GB! you have been warned! some day this will be fixed.
|
||||
|
||||
#ifndef EMUFILE_H
|
||||
#define EMUFILE_H
|
||||
|
||||
@ -29,21 +34,10 @@
|
||||
#include <stdarg.h>
|
||||
#include <malloc.h>
|
||||
|
||||
//should be changed to #ifdef FCEUX but too much work
|
||||
#ifndef DESMUME
|
||||
#ifndef __GCTYPES_H__
|
||||
typedef unsigned char u8;
|
||||
typedef unsigned short u16;
|
||||
typedef unsigned int u32;
|
||||
typedef char s8;
|
||||
typedef short s16;
|
||||
typedef int s32;
|
||||
#endif
|
||||
#endif
|
||||
#include "emufile_types.h"
|
||||
|
||||
#ifdef _XBOX
|
||||
#undef min;
|
||||
#undef max;
|
||||
#ifdef _MSC_VER
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
class EMUFILE {
|
||||
@ -56,14 +50,15 @@ public:
|
||||
{}
|
||||
|
||||
|
||||
//takes control of the provided EMUFILE and returns a new EMUFILE which is guranteed to be in memory
|
||||
static EMUFILE* memwrap(EMUFILE* fp);
|
||||
//returns a new EMUFILE which is guranteed to be in memory. the EMUFILE you call this on may be deleted. use the returned EMUFILE in its place
|
||||
virtual EMUFILE* memwrap() = 0;
|
||||
|
||||
virtual ~EMUFILE() {}
|
||||
|
||||
static bool readAllBytes(std::vector<u8>* buf, const std::string& fname);
|
||||
|
||||
bool fail() { return failbit; }
|
||||
bool fail(bool unset=false) { bool ret = failbit; if(unset) unfail(); return ret; }
|
||||
void unfail() { failbit=false; }
|
||||
|
||||
bool eof() { return size()==ftell(); }
|
||||
|
||||
@ -90,10 +85,37 @@ public:
|
||||
|
||||
virtual void fwrite(const void *ptr, size_t bytes) = 0;
|
||||
|
||||
void write64le(u64* val);
|
||||
void write64le(u64 val);
|
||||
size_t read64le(u64* val);
|
||||
u64 read64le();
|
||||
void write32le(u32* val);
|
||||
void write32le(s32* val) { write32le((u32*)val); }
|
||||
void write32le(u32 val);
|
||||
size_t read32le(u32* val);
|
||||
size_t read32le(s32* val);
|
||||
u32 read32le();
|
||||
void write16le(u16* val);
|
||||
void write16le(s16* val) { write16le((u16*)val); }
|
||||
void write16le(u16 val);
|
||||
size_t read16le(s16* Bufo);
|
||||
size_t read16le(u16* val);
|
||||
u16 read16le();
|
||||
void write8le(u8* val);
|
||||
void write8le(u8 val);
|
||||
size_t read8le(u8* val);
|
||||
u8 read8le();
|
||||
void writedouble(double* val);
|
||||
void writedouble(double val);
|
||||
double readdouble();
|
||||
size_t readdouble(double* val);
|
||||
|
||||
virtual int fseek(int offset, int origin) = 0;
|
||||
|
||||
virtual int ftell() = 0;
|
||||
virtual int size() = 0;
|
||||
|
||||
virtual void truncate(s32 length) = 0;
|
||||
};
|
||||
|
||||
//todo - handle read-only specially?
|
||||
@ -110,12 +132,12 @@ protected:
|
||||
|
||||
public:
|
||||
|
||||
EMUFILE_MEMORY(std::vector<u8> *underlying) : vec(underlying), ownvec(false), pos(0), len(underlying->size()) { }
|
||||
EMUFILE_MEMORY(std::vector<u8> *underlying) : vec(underlying), ownvec(false), pos(0), len((s32)underlying->size()) { }
|
||||
EMUFILE_MEMORY(u32 preallocate) : vec(new std::vector<u8>()), ownvec(true), pos(0), len(0) {
|
||||
vec->resize(preallocate);
|
||||
len = preallocate;
|
||||
}
|
||||
EMUFILE_MEMORY() : vec(new std::vector<u8>()), ownvec(true), pos(0), len(0) { vec->reserve(8192); }
|
||||
EMUFILE_MEMORY() : vec(new std::vector<u8>()), ownvec(true), pos(0), len(0) { vec->reserve(1024); }
|
||||
EMUFILE_MEMORY(void* buf, s32 size) : vec(new std::vector<u8>()), ownvec(true), pos(0), len(size) {
|
||||
vec->resize(size);
|
||||
if(size != 0)
|
||||
@ -126,7 +148,19 @@ public:
|
||||
if(ownvec) delete vec;
|
||||
}
|
||||
|
||||
u8* buf() { return &(*vec)[0]; }
|
||||
virtual EMUFILE* memwrap();
|
||||
|
||||
virtual void truncate(s32 length)
|
||||
{
|
||||
vec->resize(length);
|
||||
len = length;
|
||||
if(pos>length) pos=length;
|
||||
}
|
||||
|
||||
u8* buf() {
|
||||
if(size()==0) reserve(1);
|
||||
return &(*vec)[0];
|
||||
}
|
||||
|
||||
std::vector<u8>* get_vec() { return vec; };
|
||||
|
||||
@ -176,23 +210,15 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual size_t _fread(const void *ptr, size_t bytes){
|
||||
u32 remain = len-pos;
|
||||
u32 todo = std::min<u32>(remain,(u32)bytes);
|
||||
memcpy((void*)ptr,buf()+pos,todo);
|
||||
pos += todo;
|
||||
if(todo<bytes)
|
||||
failbit = true;
|
||||
return todo;
|
||||
}
|
||||
virtual size_t _fread(const void *ptr, size_t bytes);
|
||||
|
||||
//removing these return values for now so we can find any code that might be using them and make sure
|
||||
//they handle the return values correctly
|
||||
|
||||
virtual void fwrite(const void *ptr, size_t bytes){
|
||||
reserve(pos+bytes);
|
||||
reserve(pos+(s32)bytes);
|
||||
memcpy(buf()+pos,ptr,bytes);
|
||||
pos += bytes;
|
||||
pos += (s32)bytes;
|
||||
len = std::max(pos,len);
|
||||
}
|
||||
|
||||
@ -260,6 +286,28 @@ public:
|
||||
if(own_buffer && buffer) free(buffer);
|
||||
}
|
||||
|
||||
virtual EMUFILE* memwrap()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
virtual void truncate(s32 length)
|
||||
{
|
||||
if(own_buffer)
|
||||
{
|
||||
char *oldbuffer = buffer;
|
||||
buffer = (char *)memalign(32, length);
|
||||
if(buffer)
|
||||
{
|
||||
int bytes = std::min(len, length);
|
||||
memcpy(buffer, oldbuffer, bytes);
|
||||
}
|
||||
free(oldbuffer);
|
||||
}
|
||||
len = length;
|
||||
if(pos>length) pos=length;
|
||||
}
|
||||
|
||||
char* buf() { return buffer; }
|
||||
|
||||
virtual FILE *get_fp() { return NULL; }
|
||||
@ -356,6 +404,8 @@ public:
|
||||
class EMUFILE_FILE : public EMUFILE {
|
||||
protected:
|
||||
FILE* fp;
|
||||
std::string fname;
|
||||
char mode[16];
|
||||
|
||||
private:
|
||||
void open(const char* fname, const char* mode)
|
||||
@ -363,6 +413,8 @@ private:
|
||||
fp = fopen(fname,mode);
|
||||
if(!fp)
|
||||
failbit = true;
|
||||
this->fname = fname;
|
||||
strcpy(this->mode,mode);
|
||||
}
|
||||
|
||||
public:
|
||||
@ -379,8 +431,12 @@ public:
|
||||
return fp;
|
||||
}
|
||||
|
||||
virtual EMUFILE* memwrap();
|
||||
|
||||
bool is_open() { return fp != NULL; }
|
||||
|
||||
virtual void truncate(s32 length);
|
||||
|
||||
virtual int fprintf(const char *format, ...) {
|
||||
va_list argptr;
|
||||
va_start(argptr, format);
|
||||
|
16
source/fceultra/emufile_types.h
Normal file
16
source/fceultra/emufile_types.h
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef EMUFILE_TYPES_H
|
||||
#define EMUFILE_TYPES_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
typedef uint8 u8;
|
||||
typedef uint16 u16;
|
||||
typedef uint32 u32;
|
||||
typedef uint64 u64;
|
||||
typedef int8 s8;
|
||||
typedef int16 s16;
|
||||
typedef int32 s32;
|
||||
typedef int64 s64;
|
||||
|
||||
|
||||
#endif //EMUFILE_TYPES_H
|
@ -656,6 +656,7 @@ static BMAPPINGLocal bmap[] = {
|
||||
{"", 216, Mapper216_Init},
|
||||
{"", 217, Mapper217_Init},
|
||||
{"UNLA9746", 219, UNLA9746_Init},
|
||||
{"OneBus", 220, UNLOneBus_Init},
|
||||
|
||||
// {220, BMCFK23C_Init},
|
||||
// {220, UNL3DBlock_Init},
|
||||
|
@ -206,7 +206,7 @@ void MovieData::TryDumpIncremental()
|
||||
|
||||
currMovieData.storeTasSavestate(currFrameCounter, Z_DEFAULT_COMPRESSION);
|
||||
currMovieData.greenZoneCount=currFrameCounter+1;
|
||||
} else if (currFrameCounter < currMovieData.greenZoneCount || !movie_readonly)
|
||||
} 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())
|
||||
@ -467,6 +467,7 @@ MovieData::MovieData()
|
||||
, binaryFlag(false)
|
||||
, greenZoneCount(0)
|
||||
, microphone(false)
|
||||
, tweakCount(0)
|
||||
{
|
||||
memset(&romChecksum,0,sizeof(MD5DATA));
|
||||
}
|
||||
@ -985,6 +986,7 @@ void MovieData::storeTasSavestate(int frame, int compression_level)
|
||||
savestates.resize(frame+1);
|
||||
|
||||
MovieData::dumpSavestateTo(&savestates[frame],compression_level);
|
||||
tweakCount++;
|
||||
}
|
||||
|
||||
//begin playing an existing movie
|
||||
@ -1163,7 +1165,7 @@ void FCEUMOV_AddInputState()
|
||||
//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
|
||||
if(movieMode == MOVIEMODE_TASEDIT)
|
||||
{
|
||||
MovieRecord* mr = &currMovieData.records[currFrameCounter];
|
||||
@ -1178,12 +1180,19 @@ void FCEUMOV_AddInputState()
|
||||
}
|
||||
else
|
||||
{
|
||||
if (currMovieData.greenZoneCount>currFrameCounter+1)
|
||||
{
|
||||
|
||||
InvalidateGreenZone(currFrameCounter);
|
||||
|
||||
}
|
||||
joyports[0].log(mr);
|
||||
joyports[1].log(mr);
|
||||
mr->commands = 0;
|
||||
}
|
||||
}
|
||||
else if(movieMode == MOVIEMODE_PLAY)
|
||||
#endif
|
||||
if(movieMode == MOVIEMODE_PLAY)
|
||||
{
|
||||
//stop when we run out of frames
|
||||
if(currFrameCounter >= (int)currMovieData.records.size())
|
||||
|
@ -192,6 +192,7 @@ public:
|
||||
//----TasEdit stuff---
|
||||
int greenZoneCount;
|
||||
int loadFrameCount;
|
||||
int tweakCount;
|
||||
//----
|
||||
|
||||
int getNumRecords() { return records.size(); }
|
||||
|
@ -2169,6 +2169,15 @@ struct BGData {
|
||||
Record main[34]; //one at the end is junk, it can never be rendered
|
||||
} bgdata;
|
||||
|
||||
static inline int PaletteAdjustPixel(int pixel)
|
||||
{
|
||||
if((PPU[1]>>5)==0x7)
|
||||
return (pixel&0x3f)|0xc0;
|
||||
else if(PPU[1]&0xE0)
|
||||
return pixel | 0x40;
|
||||
else
|
||||
return (pixel&0x3F)|0x80;
|
||||
}
|
||||
|
||||
int framectr=0;
|
||||
int FCEUX_PPU_Loop(int skip) {
|
||||
@ -2338,10 +2347,7 @@ int FCEUX_PPU_Loop(int skip) {
|
||||
}
|
||||
}
|
||||
|
||||
//fceu rendering system requires that this be set
|
||||
//(so that it knows there is a valid pixel there?)
|
||||
pixelcolor |= 0x80;
|
||||
*ptr++ = pixelcolor;
|
||||
*ptr++ = PaletteAdjustPixel(pixelcolor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -433,6 +433,7 @@ static BMAPPING bmap[] = {
|
||||
{ "KONAMI-QTAI", Mapper190_Init,0},
|
||||
|
||||
{ "DANCE", UNLDANCE_Init,0},
|
||||
{ "OneBus", UNLOneBus_Init,0},
|
||||
{ "SC-127", UNLSC127_Init,0},
|
||||
|
||||
{ "TEK90", Mapper90_Init,0},
|
||||
@ -596,6 +597,7 @@ int UNIFLoad(const char *name, FCEUFILE *fp)
|
||||
#ifndef GEKKO
|
||||
FCEU_LoadGameSave(&UNIFCart);
|
||||
#endif
|
||||
|
||||
strcpy(LoadedRomFName,name); //For the debugger list
|
||||
GameInterface=UNIFGI;
|
||||
return 1;
|
||||
|
@ -115,6 +115,7 @@ void UNLKS7032_Init(CartInfo *info);
|
||||
void UNLT230_Init(CartInfo *info);
|
||||
void UNLAX5705_Init(CartInfo *info);
|
||||
void UNLDANCE_Init(CartInfo *info);
|
||||
void UNLOneBus_Init(CartInfo *info);
|
||||
void UNLSC127_Init(CartInfo *info);
|
||||
|
||||
void UNLEDU2000_Init(CartInfo *info);
|
||||
|
@ -3,8 +3,10 @@
|
||||
|
||||
#include <iosfwd>
|
||||
#include <stdio.h>
|
||||
#include "../emufile.h"
|
||||
#include "../types.h"
|
||||
#include "../emufile.h"
|
||||
|
||||
class EMUFILE;
|
||||
|
||||
inline uint64 double_to_u64(double d) {
|
||||
union {
|
||||
@ -70,9 +72,9 @@ inline int write_double_le(double b, EMUFILE*is) { uint64 temp = double_to_u64(b
|
||||
|
||||
int read8le(uint8 *Bufo, EMUFILE*is);
|
||||
int read16le(uint16 *Bufo, EMUFILE*is);
|
||||
inline int read16le(int16 *Bufo, EMUFILE*is) { return read16le((u16*)Bufo,is); }
|
||||
inline int read16le(int16 *Bufo, EMUFILE*is) { return read16le((uint16*)Bufo,is); }
|
||||
int read32le(uint32 *Bufo, EMUFILE*is);
|
||||
inline int read32le(int32 *Bufo, EMUFILE*is) { return read32le((u32*)Bufo,is); }
|
||||
inline int read32le(int32 *Bufo, EMUFILE*is) { return read32le((uint32*)Bufo,is); }
|
||||
int read64le(uint64 *Bufo, EMUFILE*is);
|
||||
inline int read_double_le(double *Bufo, EMUFILE*is) { uint64 temp; int ret = read64le(&temp,is); *Bufo = u64_to_double(temp); return ret; }
|
||||
|
||||
@ -82,10 +84,10 @@ int readle(T *Bufo, EMUFILE*is)
|
||||
{
|
||||
CTASSERT(sizeof(T)==1||sizeof(T)==2||sizeof(T)==4||sizeof(T)==8);
|
||||
switch(sizeof(T)) {
|
||||
case 1: return read8le((u8*)Bufo,is);
|
||||
case 2: return read16le((u16*)Bufo,is);
|
||||
case 4: return read32le((u32*)Bufo,is);
|
||||
case 8: return read64le((u64*)Bufo,is);
|
||||
case 1: return read8le((uint8*)Bufo,is);
|
||||
case 2: return read16le((uint16*)Bufo,is);
|
||||
case 4: return read32le((uint32*)Bufo,is);
|
||||
case 8: return read64le((uint64*)Bufo,is);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@ -96,10 +98,10 @@ int writele(T *Bufo, EMUFILE*os)
|
||||
{
|
||||
CTASSERT(sizeof(T)==1||sizeof(T)==2||sizeof(T)==4||sizeof(T)==8);
|
||||
switch(sizeof(T)) {
|
||||
case 1: return write8le((u8*)Bufo,os);
|
||||
case 2: return write16le((u16*)Bufo,os);
|
||||
case 4: return write32le((u32*)Bufo,os);
|
||||
case 8: return write64le((u64*)Bufo,os);
|
||||
case 1: return write8le((uint8*)Bufo,os);
|
||||
case 2: return write16le((uint16*)Bufo,os);
|
||||
case 4: return write32le((uint32*)Bufo,os);
|
||||
case 8: return write64le((uint64*)Bufo,os);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user