From 475e0f92a64861c6e5d1744d70bdf49ab8c78baf Mon Sep 17 00:00:00 2001 From: dborth Date: Mon, 6 Dec 2010 02:46:57 +0000 Subject: [PATCH] sync to latest FCEUX svn --- source/fceultra/boards/datalatch.cpp | 92 +++++++--- source/fceultra/boards/onebus.cpp | 265 +++++++++++++++++++-------- source/fceultra/conddebug.cpp | 8 +- source/fceultra/emufile.cpp | 253 +++++++++++++++++++++++-- source/fceultra/emufile.h | 152 ++++++++++----- source/fceultra/emufile_types.h | 16 ++ source/fceultra/ines.cpp | 3 +- source/fceultra/movie.cpp | 15 +- source/fceultra/movie.h | 1 + source/fceultra/ppu.cpp | 14 +- source/fceultra/unif.cpp | 62 ++++--- source/fceultra/unif.h | 1 + source/fceultra/utils/endian.h | 24 +-- 13 files changed, 688 insertions(+), 218 deletions(-) create mode 100644 source/fceultra/emufile_types.h diff --git a/source/fceultra/boards/datalatch.cpp b/source/fceultra/boards/datalatch.cpp index bbf6448..8016cee 100644 --- a/source/fceultra/boards/datalatch.cpp +++ b/source/fceultra/boards/datalatch.cpp @@ -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"); + } diff --git a/source/fceultra/boards/onebus.cpp b/source/fceultra/boards/onebus.cpp index 9afe721..d1e8bee 100644 --- a/source/fceultra/boards/onebus.cpp +++ b/source/fceultra/boards/onebus.cpp @@ -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 @@ -16,107 +16,184 @@ * 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 - * + * + * 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; - - 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]); - - - if(reg4[0x0B]&1) + 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(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(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]); -} - -static DECLFW(UNLDANCEWrite2) -{ - reg2000 = V; - Sync(); - //FCEU_printf("write %04x:%04x\n",A,V); + setmirror(regs[0xe]); } -static DECLFW(UNLDANCEWrite4) +static DECLFW(UNLOneBusWrite20XX) { - reg4[A & 0x0F] = V; +// FCEU_printf("PPU %04x:%04x\n",A,V); + if(A == 0x201A) + regs[0xd] = V; + else if(A == 0x2018) + regs[0xc] = V; Sync(); - //FCEU_printf("write %04x:%04x\n",A,V); } -static DECLFW(UNLDANCEWrite8) +static DECLFW(UNLOneBusWriteExp) { - if(A&1) +// FCEU_printf("EXP %04x:%04x\n",A,V); +// switch(A & 0x0F) +// { +// case 2: pcm_latch = pcm_clock; FCEU_printf("write %04x:%04x\n",A,V); break; +// case 3: pcm_irqa = 0; X6502_IRQEnd(FCEU_IQEXT); pcm_irq = 0; FCEU_printf("write %04x:%04x\n",A,V); break; +// case 4: pcm_irqa = 1; FCEU_printf("write %04x:%04x\n",A,V); break; +// default: + regs[A & 0x0F] = V; + Sync(); +// } +} + +static DECLFW(UNLOneBusWriteDebug) +{ +// FCEU_printf("write %04x:%04x\n",A,V); +} + +static DECLFW(UNLOneBusWriteMMC) +{ +// FCEU_printf("MMC %04x:%04x\n",A,V); + switch(A&0xE001) { - if(mmc3cmd<6) - regc[mmc3cmd] = V; - else - reg4[0x07 + mmc3cmd - 6] = V; + case 0x8000: regs[0xf] = V; Sync(); break; + case 0x8001: + { + uint8 mask = 0xff, mmc3cmd = regs[0xf]&7; + switch(mmc3cmd) + { + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + if(regs[0xd]&4) + mask = 0x0f; + else + mask >>= ((regs[0xb]&0xf0)>>4); + regc[mmc3cmd] = V&mask; + break; + case 6: + case 7: + mask = (mask&0x3f)>>(regs[0xb]&0xf); + regs[mmc3cmd+1] = (regs[mmc3cmd+1]&(~mask))|(V&mask); + break; + } + + Sync(); + break; + } + case 0xA000: regs[0xe] = (V & 1)^1; Sync(); break; + case 0xC000: IRQLatch = V&0xfe; break; + case 0xC001: IRQReload = 1; break; + case 0xE000: X6502_IRQEnd(FCEU_IQEXT); IRQa = 0; break; + case 0xE001: IRQa = 1; break; } - else - mmc3cmd = V & 7; - Sync(); - //FCEU_printf("write %04x:%04x\n",A,V); } -static DECLFW(UNLDANCEWrite4012) +static void UNLOneBusIRQHook(void) { + int count = IRQCount; + if(!count || IRQReload) + { + IRQCount = IRQLatch; + IRQReload = 0; + } + else + IRQCount--; + if(count && !IRQCount) + { + if(IRQa) + X6502_IRQBegin(FCEU_IQEXT); + } +} + +static DECLFW(UNLOneBusWriteAPU2) +{ +// FCEU_printf("APU2 %04x:%04x\n",A,V); + CartBW(A&0xffdf,V); +} + +static DECLFW(UNLOneBusWrite4012) +{ +// FCEU_printf("write %04x:%04x\n",A,V); pcm_addr = V << 6; 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,UNLOneBusRead4015); + old4011write=GetWriteHandler(0x4011); + old4012write=GetWriteHandler(0x4012); + SetWriteHandler(0x4012,0x4012,UNLOneBusWrite4012); + old4013write=GetWriteHandler(0x4013); + SetWriteHandler(0x4013,0x4013,UNLOneBusWrite4013); + old4015write=GetWriteHandler(0x4015); + SetWriteHandler(0x4015,0x4015,UNLOneBusWrite4015); + } - old4015read=GetReadHandler(0x4015); - SetReadHandler(0x4015,0x4015,UNLDANCERead4015); SetReadHandler(0x8000,0xFFFF,CartBR); - - old4011write=GetWriteHandler(0x4011); - old4012write=GetWriteHandler(0x4012); - SetWriteHandler(0x4012,0x4012,UNLDANCEWrite4012); - old4013write=GetWriteHandler(0x4013); - SetWriteHandler(0x4013,0x4013,UNLDANCEWrite4013); - old4015write=GetWriteHandler(0x4015); - SetWriteHandler(0x4015,0x4015,UNLDANCEWrite4015); - - SetWriteHandler(0x201A,0x201A,UNLDANCEWrite2); - SetWriteHandler(0x4100,0x410F,UNLDANCEWrite4); - SetWriteHandler(0x8000,0x8001,UNLDANCEWrite8); + 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); } diff --git a/source/fceultra/conddebug.cpp b/source/fceultra/conddebug.cpp index 2acea4e..7a9a4ae 100644 --- a/source/fceultra/conddebug.cpp +++ b/source/fceultra/conddebug.cpp @@ -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) { @@ -322,9 +322,9 @@ Condition* Primitive(const char** str, Condition* c) Condition* Term(const char** str) { Condition* t; - Condition* t1; + Condition* t1; Condition* mid; - + t = (Condition*)FCEU_dmalloc(sizeof(Condition)); if (!t) return NULL; diff --git a/source/fceultra/emufile.cpp b/source/fceultra/emufile.cpp index d07ab65..fbe004f 100644 --- a/source/fceultra/emufile.cpp +++ b/source/fceultra/emufile.cpp @@ -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 @@ -13,16 +34,226 @@ bool EMUFILE::readAllBytes(std::vector* 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(remain,(u32)bytes); + if(len==0) + { + failbit = true; + return 0; + } + if(todo<=4) + { + u8* src = buf()+pos; + u8* dst = (u8*)ptr; + for(size_t i=0;i(fp); - mem = dynamic_cast(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; + 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; } \ No newline at end of file diff --git a/source/fceultra/emufile.h b/source/fceultra/emufile.h index cae1040..0b8bb8d 100644 --- a/source/fceultra/emufile.h +++ b/source/fceultra/emufile.h @@ -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 #include -//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 #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* 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 *underlying) : vec(underlying), ownvec(false), pos(0), len(underlying->size()) { } + EMUFILE_MEMORY(std::vector *underlying) : vec(underlying), ownvec(false), pos(0), len((s32)underlying->size()) { } EMUFILE_MEMORY(u32 preallocate) : vec(new std::vector()), ownvec(true), pos(0), len(0) { vec->resize(preallocate); len = preallocate; } - EMUFILE_MEMORY() : vec(new std::vector()), ownvec(true), pos(0), len(0) { vec->reserve(8192); } + EMUFILE_MEMORY() : vec(new std::vector()), ownvec(true), pos(0), len(0) { vec->reserve(1024); } EMUFILE_MEMORY(void* buf, s32 size) : vec(new std::vector()), 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* 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(remain,(u32)bytes); - memcpy((void*)ptr,buf()+pos,todo); - pos += todo; - if(todolength) 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); diff --git a/source/fceultra/emufile_types.h b/source/fceultra/emufile_types.h new file mode 100644 index 0000000..690b861 --- /dev/null +++ b/source/fceultra/emufile_types.h @@ -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 diff --git a/source/fceultra/ines.cpp b/source/fceultra/ines.cpp index 13929e5..aded040 100644 --- a/source/fceultra/ines.cpp +++ b/source/fceultra/ines.cpp @@ -655,7 +655,8 @@ static BMAPPINGLocal bmap[] = { {"", 215, Mapper215_Init}, {"", 216, Mapper216_Init}, {"", 217, Mapper217_Init}, - {"UNLA9746", 219, UNLA9746_Init}, + {"UNLA9746", 219, UNLA9746_Init}, + {"OneBus", 220, UNLOneBus_Init}, // {220, BMCFK23C_Init}, // {220, UNL3DBlock_Init}, diff --git a/source/fceultra/movie.cpp b/source/fceultra/movie.cpp index a3d1595..ceca05b 100644 --- a/source/fceultra/movie.cpp +++ b/source/fceultra/movie.cpp @@ -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(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()) diff --git a/source/fceultra/movie.h b/source/fceultra/movie.h index f4ffedc..a2d87e5 100644 --- a/source/fceultra/movie.h +++ b/source/fceultra/movie.h @@ -192,6 +192,7 @@ public: //----TasEdit stuff--- int greenZoneCount; int loadFrameCount; + int tweakCount; //---- int getNumRecords() { return records.size(); } diff --git a/source/fceultra/ppu.cpp b/source/fceultra/ppu.cpp index 12e673a..d2cdd40 100644 --- a/source/fceultra/ppu.cpp +++ b/source/fceultra/ppu.cpp @@ -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); } } } diff --git a/source/fceultra/unif.cpp b/source/fceultra/unif.cpp index 0a56741..eaaec05 100644 --- a/source/fceultra/unif.cpp +++ b/source/fceultra/unif.cpp @@ -129,7 +129,7 @@ static int DoMirroring(FCEUFILE *fp) { uint8 t; t=FCEU_fgetc(fp); - mirrortodo=t; + mirrortodo=t; { static char *stuffo[6]={"Horizontal","Vertical","$2000","$2400","\"Four-screen\"","Controlled by Mapper Hardware"}; @@ -266,7 +266,7 @@ static int LoadPRG(FCEUFILE *fp) else FCEU_printf("\n"); - SetupCartPRGMapping(z,malloced[z],t,0); + SetupCartPRGMapping(z,malloced[z],t,0); return(1); } @@ -324,11 +324,11 @@ static BMAPPING bmap[] = { { "Sachen-8259D", S8259D_Init,0}, { "Sachen-74LS374N", S74LS374N_Init,0}, { "Sachen-74LS374NA", S74LS374NA_Init,0}, //seems to be custom mapper - { "SA-002", TCU02_Init, 0}, + { "SA-002", TCU02_Init, 0}, { "SA-016-1M", SA0161M_Init,0}, { "SA-72007", SA72007_Init,0}, { "SA-72008", SA72008_Init,0}, - { "SA-009", SA009_Init,0}, + { "SA-009", SA009_Init,0}, { "SA-0036", SA0036_Init,0}, { "SA-0037", SA0037_Init,0}, { "SA-NROM", TCA01_Init,0}, @@ -362,7 +362,7 @@ static BMAPPING bmap[] = { { "TGROM", TGROM_Init,0}, { "TR1ROM", TFROM_Init,BMCFLAG_FORCE4}, - { "TBROM", TBROM_Init,0}, + { "TBROM", TBROM_Init,0}, { "TEROM", TEROM_Init,0}, { "TFROM", TFROM_Init,0}, { "TLROM", TLROM_Init,0}, @@ -374,7 +374,7 @@ static BMAPPING bmap[] = { { "TQROM", TQROM_Init,0}, { "TVROM", TLROM_Init,BMCFLAG_FORCE4}, - { "NTBROM", Mapper68_Init,0}, + { "NTBROM", Mapper68_Init,0}, { "CPROM", CPROM_Init,BMCFLAG_16KCHRR}, { "CNROM", CNROM_Init,0}, @@ -385,12 +385,12 @@ static BMAPPING bmap[] = { { "RROM-128", NROM_Init,0 }, //NROM128_Init,0 }, { "MHROM", MHROM_Init,0}, { "UNROM", UNROM_Init,0}, - { "UOROM", UNROM_Init,0}, + { "UOROM", UNROM_Init,0}, { "SUNSOFT_UNROM", SUNSOFT_UNROM_Init,0}, { "MARIO1-MALEE2", MALEE_Init,0}, - { "3D-BLOCK", UNL3DBlock_Init, 0}, - { "SMB2J", UNLSMB2J_Init, 0}, - { "AX5705", UNLAX5705_Init, 0}, + { "3D-BLOCK", UNL3DBlock_Init, 0}, + { "SMB2J", UNLSMB2J_Init, 0}, + { "AX5705", UNLAX5705_Init, 0}, { "CC-21", UNLCC21_Init,0}, { "H2288", UNLH2288_Init,0}, @@ -405,7 +405,7 @@ static BMAPPING bmap[] = { { "C-N22M", UNLCN22M_Init,0}, { "EDU2000", UNLEDU2000_Init,0}, { "603-5052", UNL6035052_Init,0}, - { "N625092", UNLN625092_Init,0}, + { "N625092", UNLN625092_Init,0}, { "Supervision16in1", Supervision16_Init,0}, { "NovelDiamond9999999in1", Novel_Init,0}, { "Super24in1SC03", Super24_Init,0}, @@ -417,27 +417,28 @@ static BMAPPING bmap[] = { { "GK-192", BMCGK192_Init, 0}, { "SuperHIK8in1", Mapper45_Init,0}, { "22211", UNL22211_Init,0}, - { "TF1201", UNLTF1201_Init, 0}, - { "GS-2004", BMCGS2004_Init, 0}, - { "GS-2013", BMCGS2013_Init, 0}, - { "KS7032", UNLKS7032_Init, 0}, - { "T-230", UNLT230_Init, 0}, - { "190in1", BMC190in1_Init, 0}, - { "Ghostbusters63in1", BMCGhostbusters63in1_Init, 0}, - { "BS-5",BMCBS5_Init, 0}, - { "411120-C",BMC411120C_Init, 0}, - { "830118C",BMC830118C_Init, 0}, - { "T-227-1",BMCT2271_Init,0}, + { "TF1201", UNLTF1201_Init, 0}, + { "GS-2004", BMCGS2004_Init, 0}, + { "GS-2013", BMCGS2013_Init, 0}, + { "KS7032", UNLKS7032_Init, 0}, + { "T-230", UNLT230_Init, 0}, + { "190in1", BMC190in1_Init, 0}, + { "Ghostbusters63in1", BMCGhostbusters63in1_Init, 0}, + { "BS-5",BMCBS5_Init, 0}, + { "411120-C",BMC411120C_Init, 0}, + { "830118C",BMC830118C_Init, 0}, + { "T-227-1",BMCT2271_Init,0}, { "DREAMTECH01", DreamTech01_Init,0}, { "KONAMI-QTAI", Mapper190_Init,0}, - { "DANCE", UNLDANCE_Init,0}, - { "SC-127", UNLSC127_Init,0}, + { "DANCE", UNLDANCE_Init,0}, + { "OneBus", UNLOneBus_Init,0}, + { "SC-127", UNLSC127_Init,0}, { "TEK90", Mapper90_Init,0}, - { "COPYFAMI_MMC3", MapperCopyFamiMMC3_Init,0}, + { "COPYFAMI_MMC3", MapperCopyFamiMMC3_Init,0}, {0,0,0} }; @@ -462,13 +463,13 @@ int LoadUNIFChunks(FCEUFILE *fp) for(;;) { t=FCEU_fread(&uchead,1,4,fp); - if(t<4) + if(t<4) { if(t>0) - return 0; + return 0; return 1; } - if(!(FCEU_read32le(&uchead.info,fp))) + if(!(FCEU_read32le(&uchead.info,fp))) return 0; t=0; x=0; @@ -480,7 +481,7 @@ int LoadUNIFChunks(FCEUFILE *fp) if(!bfunc[x].init(fp)) return 0; t=1; - break; + break; } x++; } @@ -559,7 +560,7 @@ int UNIFLoad(const char *name, FCEUFILE *fp) FCEU_fseek(fp,0,SEEK_SET); FCEU_fread(&unhead,1,4,fp); if(memcmp(&unhead,"UNIF",4)) - return 0; + return 0; ResetCartMapping(); @@ -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; diff --git a/source/fceultra/unif.h b/source/fceultra/unif.h index 9e5f309..7512ea5 100644 --- a/source/fceultra/unif.h +++ b/source/fceultra/unif.h @@ -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); diff --git a/source/fceultra/utils/endian.h b/source/fceultra/utils/endian.h index 1ad5864..026b6e4 100644 --- a/source/fceultra/utils/endian.h +++ b/source/fceultra/utils/endian.h @@ -3,8 +3,10 @@ #include #include -#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; }