From e2fe1444aea74c71714062b5f2eabd5371fc1abf Mon Sep 17 00:00:00 2001 From: dborth Date: Fri, 19 Sep 2008 05:33:26 +0000 Subject: [PATCH] update core to 0.98.13pre --- readme.txt | 2 + source/fceultra/boards/simple.c | 343 ++--- source/fceultra/cart.c | 5 +- source/fceultra/cheat.c | 4 +- source/fceultra/debug.c | 1043 +++++++------- source/fceultra/debug.h | 7 +- source/fceultra/fceu.c | 1011 +++++++------- source/fceultra/file.c | 4 +- source/fceultra/filter.c | 6 +- source/fceultra/general.c | 7 +- source/fceultra/ines-bad.h | 37 + source/fceultra/ines-correct.h | 191 +++ source/fceultra/ines.c | 363 ++--- source/fceultra/ines.h | 42 +- source/fceultra/linux/bits/wchar.h | 26 - source/fceultra/linux/bits/wordsize.h | 19 - source/fceultra/linux/features.h | 340 ----- source/fceultra/linux/gnu/stubs-32.h | 24 - source/fceultra/linux/gnu/stubs.h | 12 - source/fceultra/linux/inttypes.h | 461 ------- source/fceultra/linux/stdint.h | 320 ----- source/fceultra/mappers/000.c | 30 +- source/fceultra/mappers/27.c | 69 - source/fceultra/mappers/33.c | 3 +- source/fceultra/mappers/86.c | 4 +- source/fceultra/mappers/subor.c | 79 -- source/fceultra/mbshare/164.c | 86 +- source/fceultra/mbshare/199.c | 95 -- source/fceultra/mbshare/252.c | 95 -- source/fceultra/mbshare/karaoke.c | 80 ++ source/fceultra/mbshare/mmc3.c | 1827 +++++++++---------------- source/fceultra/mbshare/mmc3.h | 25 - source/fceultra/mbshare/mmc5.c | 773 ++++++----- source/fceultra/movie.c | 23 +- source/fceultra/netplay.c | 12 - source/fceultra/ops.h | 30 +- source/fceultra/ppu.c | 82 +- source/fceultra/pputile.h | 55 + source/fceultra/sound.c | 458 +++---- source/fceultra/state.c | 11 +- source/fceultra/types.h | 1 - source/fceultra/unif.c | 14 +- source/fceultra/x6502.c | 42 +- source/fceultra/x6502.h | 7 +- source/fceultra/x6502struct.h | 4 + source/ngc/button_mapping.c | 2 +- 46 files changed, 3048 insertions(+), 5126 deletions(-) create mode 100644 source/fceultra/ines-bad.h create mode 100644 source/fceultra/ines-correct.h delete mode 100644 source/fceultra/linux/bits/wchar.h delete mode 100644 source/fceultra/linux/bits/wordsize.h delete mode 100644 source/fceultra/linux/features.h delete mode 100644 source/fceultra/linux/gnu/stubs-32.h delete mode 100644 source/fceultra/linux/gnu/stubs.h delete mode 100644 source/fceultra/linux/inttypes.h delete mode 100644 source/fceultra/linux/stdint.h delete mode 100644 source/fceultra/mappers/27.c delete mode 100644 source/fceultra/mappers/subor.c delete mode 100644 source/fceultra/mbshare/199.c delete mode 100644 source/fceultra/mbshare/252.c create mode 100644 source/fceultra/mbshare/karaoke.c delete mode 100644 source/fceultra/mbshare/mmc3.h diff --git a/readme.txt b/readme.txt index a00cfc9..5300802 100644 --- a/readme.txt +++ b/readme.txt @@ -33,6 +33,8 @@ SNES9x GX and Genesis Plus GX projects. * Fixed network freeze-up problem * Zapper now mapped to A and B * Fixed auto-save feature +* Performance slowdowns should be fixed +* Update core to 0.98.13pre * Will now attempt to load old save states with CRC filename [What's New 2.0.1] diff --git a/source/fceultra/boards/simple.c b/source/fceultra/boards/simple.c index 596e1fb..7b10451 100644 --- a/source/fceultra/boards/simple.c +++ b/source/fceultra/boards/simple.c @@ -20,331 +20,176 @@ #include "mapinc.h" -static uint8 latche, latcheinit; -static uint16 addrreg0, addrreg1; -static void(*WSync)(void); +#define CHRRAM (GameMemBlock) +static uint8 latche; -static DECLFW(LatchWrite) +DECLFW(CPROMWrite) { -// FCEU_printf("bs %04x %02x\n",A,V); - latche=V; - WSync(); + latche=V&3; + setvram4(0x1000,CHRRAM+((V&3)<<12)); } -static void LatchPower(void) +static void CPROMReset(void) { - latche=latcheinit; - WSync(); - SetReadHandler(0x8000,0xFFFF,CartBR); - SetWriteHandler(addrreg0,addrreg1,LatchWrite); + setprg32(0x8000,0); + setvram8(0); + SetReadHandler(0x8000,0xFFFF,CartBR); + SetWriteHandler(0x8000,0xffff,CPROMWrite); } -static void StateRestore(int version) +static void CPROMRestore(int version) { - WSync(); -} - -static void Latch_Init(CartInfo *info, void (*proc)(void), uint8 init, uint16 adr0, uint16 adr1) -{ - latcheinit=init; - addrreg0=adr0; - addrreg1=adr1; - WSync=proc; - info->Power=LatchPower; - GameStateRestore=StateRestore; - AddExState(&latche, 1, 0, "LATC"); -} - -//------------------ CPROM --------------------------- - -static void CPROMSync(void) -{ - setchr4(0x0000,0); - setchr4(0x1000,latche&3); - setprg16(0x8000,0); - setprg16(0xC000,1); + setvram4(0x1000,CHRRAM+((latche)<<12)); } void CPROM_Init(CartInfo *info) { - Latch_Init(info, CPROMSync, 0, 0x8000, 0xFFFF); + info->Power=CPROMReset; + GameStateRestore=CPROMRestore; + AddExState(&latche, 1, 0, "LATC"); } -//------------------ Map 184 --------------------------- - -static void M184Sync(void) +DECLFW(CNROMWrite) +{ + latche=V&3; + setchr8(V&3); +} + +static void CNROMReset(void) { - setchr4(0x0000,latche); - setchr4(0x1000,latche>>4); setprg16(0x8000,0); setprg16(0xC000,1); + SetReadHandler(0x8000,0xFFFF,CartBR); + SetWriteHandler(0x8000,0xffff,CNROMWrite); } -void Mapper184_Init(CartInfo *info) +static void CNROMRestore(int version) { - Latch_Init(info, M184Sync, 0, 0x6000, 0x7FFF); -} - -//------------------ CNROM --------------------------- - -static void CNROMSync(void) -{ - setchr8(latche&3); - setprg16(0x8000,0); - setprg16(0xC000,1); + setchr8(latche); } void CNROM_Init(CartInfo *info) { - Latch_Init(info, CNROMSync, 0, 0x8000, 0xFFFF); + info->Power=CNROMReset; + GameStateRestore=CNROMRestore; + AddExState(&latche, 1, 0, "LATC"); } -//------------------ ANROM --------------------------- - -static void ANROMSync() +static void NROM128Reset(void) { - setprg32(0x8000,latche&0xf); - setmirror(MI_0+((latche>>4)&1)); + setprg16(0x8000,0); + setprg16(0xC000,0); setchr8(0); + SetReadHandler(0x8000,0xFFFF,CartBR); } -void ANROM_Init(CartInfo *info) +static void NROM256Reset(void) { - Latch_Init(info, ANROMSync, 0, 0x8000, 0xFFFF); + setprg16(0x8000,0); + setprg16(0xC000,1); + setchr8(0); + SetReadHandler(0x8000,0xFFFF,CartBR); } -//------------------ Map 70 --------------------------- - -static void M70Sync() +void NROM128_Init(CartInfo *info) { - setprg16(0x8000,latche>>4); - setprg16(0xc000,~0); - setchr8(latche&0xf); + info->Power=NROM128Reset; } -void Mapper70_Init(CartInfo *info) +void NROM256_Init(CartInfo *info) { - Latch_Init(info, M70Sync, 0, 0x8000, 0xFFFF); + info->Power=NROM256Reset; } -//------------------ Map 152 --------------------------- - -static void M152Sync() +static DECLFW(MHROMWrite) { - setprg16(0x8000,(latche>>4)&7); - setprg16(0xc000,~0); - setchr8(latche&0xf); - setmirror(MI_0+((latche>>7)&1)); /* Saint Seiya...hmm. */ + setprg32(0x8000,V>>4); + setchr8(V); + latche=V; } -void Mapper152_Init(CartInfo *info) +static void MHROMReset(void) { - Latch_Init(info, M152Sync, 0, 0x8000, 0xFFFF); + setprg32(0x8000,0); + setchr8(0); + latche=0; + SetReadHandler(0x8000,0xFFFF,CartBR); } -//------------------ Map 78 --------------------------- -/* Should be two separate emulation functions for this "mapper". Sigh. URGE TO KILL RISING. */ -static void M78Sync() +static void MHROMRestore(int version) { - setprg16(0x8000,(latche&7)); - setprg16(0xc000,~0); - setchr8(latche>>4); - setmirror(MI_0+((latche>>3)&1)); -} - -void Mapper78_Init(CartInfo *info) -{ - Latch_Init(info, M78Sync, 0, 0x8000, 0xFFFF); -} - -//------------------ MHROM --------------------------- - -static void MHROMSync(void) -{ - setprg32(0x8000,latche>>4); - setchr8(latche&0xf); + setprg32(0x8000,latche); + setchr8(latche); + SetWriteHandler(0x8000,0xffff,MHROMWrite); } void MHROM_Init(CartInfo *info) { - Latch_Init(info, MHROMSync, 0, 0x8000, 0xFFFF); + info->Power=MHROMReset; + AddExState(&latche, 1, 0,"LATC"); + PRGmask32[0]&=1; + CHRmask8[0]&=1; + GameStateRestore=MHROMRestore; } -void Mapper140_Init(CartInfo *info) -{ - Latch_Init(info, MHROMSync, 0, 0x6000, 0x7FFF); -} - -void Mapper240_Init(CartInfo *info) -{ - Latch_Init(info, MHROMSync, 0, 0x4020, 0x5FFF); - // need SRAM. -} - -//------------------ Map 87 --------------------------- - -static void M87Sync(void) +static void UNROMRestore(int version) { - setprg16(0x8000,0); - setprg16(0xC000,1); - setchr8(latche>>1); + setprg16(0x8000,latche); } -void Mapper87_Init(CartInfo *info) -{ - Latch_Init(info, M87Sync, ~0, 0x6000, 0xFFFF); -} - -//------------------ Map 11 --------------------------- - -static void M11Sync(void) +static DECLFW(UNROMWrite) { - setprg32(0x8000,latche&0xf); - setchr8(latche>>4); + setprg16(0x8000,V); + latche=V; } -void Mapper11_Init(CartInfo *info) -{ - Latch_Init(info, M11Sync, 0, 0x8000, 0xFFFF); -} - -void Mapper144_Init(CartInfo *info) -{ - Latch_Init(info, M11Sync, 0, 0x8001, 0xFFFF); -} - -//------------------ UNROM --------------------------- - -static void UNROMSync(void) +static void UNROMReset(void) { - setprg16(0x8000,latche); - setprg16(0xc000,~0); - setchr8(0); + setprg16(0x8000,0); + setprg16(0xc000,~0); + setvram8(CHRRAM); + SetWriteHandler(0x8000,0xffff,UNROMWrite); + SetReadHandler(0x8000,0xFFFF,CartBR); + latche=0; } void UNROM_Init(CartInfo *info) { - Latch_Init(info, UNROMSync, 0, 0x8000, 0xFFFF); + info->Power=UNROMReset; + PRGmask16[0]&=7; + AddExState(&latche, 1, 0, "LATC"); + AddExState(CHRRAM, 8192, 0, "CHRR"); + GameStateRestore=UNROMRestore; } -//------------------ Map 93 --------------------------- - -static void SSUNROMSync(void) +static void GNROMSync() { - setprg16(0x8000,latche>>4); - setprg16(0xc000,~0); - setchr8(0); + setchr8(latche&3); + setprg32(0x8000,(latche>>4)&3); } -void SUNSOFT_UNROM_Init(CartInfo *info) +static DECLFW(GNROMWrite) { - Latch_Init(info, SSUNROMSync, 0, 0x8000, 0xFFFF); + latche=V&0x33; + GNROMSync(); } -//------------------ Map 94 --------------------------- - -static void M94Sync(void) +static void GNROMStateRestore(int version) { - setprg16(0x8000,latche>>2); - setprg16(0xc000,~0); - setchr8(0); + GNROMSync(); } -void Mapper94_Init(CartInfo *info) +static void GNROMReset(void) { - Latch_Init(info, M94Sync, 0, 0x8000, 0xFFFF); + latche=0; + GNROMSync(); + SetWriteHandler(0x8000,0xffff,GNROMWrite); + SetReadHandler(0x8000,0xFFFF,CartBR); } -//------------------ Map 180 --------------------------- - -static void M180Sync(void) +void GNROM_Init(CartInfo *info) { - setprg16(0x8000,0); - setprg16(0xc000,latche); - setchr8(0); -} - -void Mapper180_Init(CartInfo *info) -{ - Latch_Init(info, M180Sync, 0, 0x8000, 0xFFFF); -} - -//------------------ Map 107 --------------------------- - -static void M107Sync(void) -{ - setprg32(0x8000,(latche>>1)&3); - setchr8(latche&7); -} - -void Mapper107_Init(CartInfo *info) -{ - Latch_Init(info, M107Sync, ~0, 0x8000, 0xFFFF); -} - -//------------------ Map 113 --------------------------- - -static void M113Sync(void) -{ - setprg32(0x8000,(latche>>3)&7); - setchr8(((latche>>3)&8)|(latche&7)); -// setmirror(latche>>7); // only for HES 6in1 -} - -void Mapper113_Init(CartInfo *info) -{ - Latch_Init(info, M113Sync, 0, 0x4100, 0x7FFF); -} - -//------------------ A65AS --------------------------- - -// actually, there is two cart in one... First have extra mirroring -// mode (one screen) and 32K bankswitching, second one have only -// 16 bankswitching mode and normal mirroring... But there is no any -// correlations between modes and they can be used in one mapper code. - -static void BMCA65ASSync(void) -{ - if(latche&0x40) - setprg32(0x8000,(latche>>1)&0x0F); - else - { - setprg16(0x8000,((latche&0x30)>>1)|(latche&7)); - setprg16(0xC000,((latche&0x30)>>1)|7); - } - setchr8(0); - if(latche&0x80) - setmirror(MI_0+(((latche>>5)&1))); - else - setmirror(((latche>>3)&1)^1); -} - -void BMCA65AS_Init(CartInfo *info) -{ - Latch_Init(info, BMCA65ASSync, 0, 0x8000, 0xFFFF); -} - -//------------------ NROM --------------------------- - -#ifdef DEBUG_MAPPER -static DECLFW(WriteHandler) -{ - FCEU_printf("bs %04x %02x\n",A,V); -} -#endif - -static void NROMPower(void) -{ - setprg16(0x8000,0); - setprg16(0xC000,~0); - setchr8(0); - SetReadHandler(0x8000,0xFFFF,CartBR); - #ifdef DEBUG_MAPPER - SetWriteHandler(0x4020,0xFFFF,WriteHandler); - #endif -} - -void NROM_Init(CartInfo *info) -{ - info->Power=NROMPower; + info->Power=GNROMReset; + AddExState(&latche, 1, 0, "LATC"); + GameStateRestore=GNROMStateRestore; } diff --git a/source/fceultra/cart.c b/source/fceultra/cart.c index 096bde0..102390b 100644 --- a/source/fceultra/cart.c +++ b/source/fceultra/cart.c @@ -416,7 +416,10 @@ void FASTAPASS(1) setmirror(int t) void SetupCartMirroring(int m, int hard, uint8 *extra) { if(m<4) + { + mirrorhard = 0; setmirror(m); + } else { vnapage[0]=NTARAM; @@ -425,7 +428,7 @@ void SetupCartMirroring(int m, int hard, uint8 *extra) vnapage[3]=extra+0x400; PPUNTARAM=0xF; } - mirrorhard=hard; + mirrorhard = hard; } static uint8 *GENIEROM=0; diff --git a/source/fceultra/cheat.c b/source/fceultra/cheat.c index 89b6275..cf820d1 100644 --- a/source/fceultra/cheat.c +++ b/source/fceultra/cheat.c @@ -337,8 +337,8 @@ void FCEU_FlushGameCheats(FILE *override, int nosave) FCEUD_PrintError("Error saving cheats."); cheats=cheatsl=0; } - //else if(!override) - // remove(fn); + else if(!override) + remove(fn); if(!override) free(fn); } diff --git a/source/fceultra/debug.c b/source/fceultra/debug.c index 1b92791..4295ea2 100644 --- a/source/fceultra/debug.c +++ b/source/fceultra/debug.c @@ -1,520 +1,523 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2003 Xodnizel - * - * 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 -#include -#include - -#include "types.h" -#include "x6502.h" -#include "fceu.h" -#include "debug.h" - - - -void FCEUI_DumpMem(const char *fname, uint32 start, uint32 end) -{ - FILE *fp=FCEUD_UTF8fopen(fname,"wb"); - fceuindbg=1; - for(;start<=end;start++) - fputc(ARead[start](start),fp); - fclose(fp); - fceuindbg=0; -} - -void FCEUI_LoadMem(const char *fname, uint32 start, int hl) -{ - int t; - - FILE *fp=FCEUD_UTF8fopen(fname,"rb"); - while((t=fgetc(fp))>=0) - { - if(start>0xFFFF) break; - if(hl) - { - extern uint8 *Page[32]; - if(Page[start/2048]) - Page[start/2048][start]=t; - } - else - BWrite[start](start,t); - start++; - } - fclose(fp); -} - -static char *fstrings[12]= -{ - "#$%02X", // immediate - "$%04X", // RELATIVE(jump) - "$%02X", // Z - "$%02X,X", // Z,x - "$%02X,Y", // Z,y - "$%04X", //ABS - "$%04X,X", // ABS,x - "$%04X,Y", // ABS,y - "($%04X)", // IND - "($%02X,X)", // INX - "($%02X),Y", // INY - "" -}; -static int flengths[12]={1,1,1,1,1,2,2,2,2,1,1,0}; - -#define IMD(x) ((0<<16)|x) -#define REL(x) ((1<<16)|x) -#define ZP(x) ((2<<16)|x) -#define ZPX(x) ((3<<16)|x) -#define ZPY(x) ((4<<16)|x) -#define ABS(x) ((5<<16)|x) -#define ABX(x) ((6<<16)|x) -#define ABY(x) ((7<<16)|x) -#define IND(x) ((8<<16)|x) -#define INX(x) ((9<<16)|x) -#define INY(x) ((10<<16)|x) -#define IMP(x) ((11<<16)|x) - -typedef struct { - char *name; - int type; /* 1 for read, 2 for write, 3 for r then write. */ - int32 modes[10]; -} OPS; -#define NUMOPS 56 -static OPS optable[NUMOPS]= -{ - {"BRK",0,{IMP(0x00),-1}}, - {"RTI",0,{IMP(0x40),-1}}, - {"RTS",0,{IMP(0x60),-1}}, - {"PHA",2,{IMP(0x48),-1}}, - {"PHP",2,{IMP(0x08),-1}}, - {"PLA",1,{IMP(0x68),-1}}, - {"PLP",1,{IMP(0x28),-1}}, - {"JMP",0,{ABS(0x4C),IND(0x6C),-1}}, - {"JSR",0,{ABS(0x20),-1}}, - {"TAX",0,{IMP(0xAA),-1}}, - {"TXA",0,{IMP(0x8A),-1}}, - {"TAY",0,{IMP(0xA8),-1}}, - {"TYA",0,{IMP(0x98),-1}}, - {"TSX",0,{IMP(0xBA),-1}}, - {"TXS",0,{IMP(0x9A),-1}}, - {"DEX",0,{IMP(0xCA),-1}}, - {"DEY",0,{IMP(0x88),-1}}, - {"INX",0,{IMP(0xE8),-1}}, - {"INY",0,{IMP(0xC8),-1}}, - {"CLC",0,{IMP(0x18),-1}}, - {"CLD",0,{IMP(0xD8),-1}}, - {"CLI",0,{IMP(0x58),-1}}, - {"CLV",0,{IMP(0xB8),-1}}, - {"SEC",0,{IMP(0x38),-1}}, - {"SED",0,{IMP(0xF8),-1}}, - {"SEI",0,{IMP(0x78),-1}}, - {"NOP",0,{IMP(0xEA),-1}}, - {"ASL",1,{IMP(0x0a),ZP(0x06),ZPX(0x16),ABS(0x0E),ABX(0x1E),-1}}, - {"DEC",3,{ZP(0xc6),ZPX(0xd6),ABS(0xcE),ABX(0xdE),-1}}, - {"INC",3,{ZP(0xe6),ZPX(0xf6),ABS(0xeE),ABX(0xfE),-1}}, - {"LSR",3,{IMP(0x4a),ZP(0x46),ZPX(0x56),ABS(0x4E),ABX(0x5E),-1}}, - {"ROL",3,{IMP(0x2a),ZP(0x26),ZPX(0x36),ABS(0x2E),ABX(0x3E),-1}}, - {"ROR",3,{IMP(0x6a),ZP(0x66),ZPX(0x76),ABS(0x6E),ABX(0x7E),-1}}, - {"ADC",1,{IMD(0x69),ZP(0x65),ZPX(0x75),ABS(0x6D),ABX(0x7d),ABY(0x79), - INX(0x61),INY(0x71),-1}}, - {"AND",1,{IMD(0x29),ZP(0x25),ZPX(0x35),ABS(0x2D),ABX(0x3d),ABY(0x39), - INX(0x21),INY(0x31),-1}}, - {"BIT",1,{ZP(0x24),ABS(0x2c),-1}}, - {"CMP",1,{IMD(0xc9),ZP(0xc5),ZPX(0xd5),ABS(0xcD),ABX(0xdd),ABY(0xd9), - INX(0xc1),INY(0xd1),-1}}, - {"CPX",1,{IMD(0xe0),ZP(0xe4),ABS(0xec),-1}}, - {"CPY",1,{IMD(0xc0),ZP(0xc4),ABS(0xcc),-1}}, - {"EOR",1,{IMD(0x49),ZP(0x45),ZPX(0x55),ABS(0x4D),ABX(0x5d),ABY(0x59), - INX(0x41),INY(0x51),-1}}, - {"LDA",1,{IMD(0xa9),ZP(0xa5),ZPX(0xb5),ABS(0xaD),ABX(0xbd),ABY(0xb9), - INX(0xa1),INY(0xb1),-1}}, - {"LDX",1,{IMD(0xa2),ZP(0xa6),ZPY(0xB6),ABS(0xae),ABY(0xbe),-1}}, - {"LDY",1,{IMD(0xa0),ZP(0xa4),ZPX(0xB4),ABS(0xac),ABX(0xbc),-1}}, - {"ORA",1,{IMD(0x09),ZP(0x05),ZPX(0x15),ABS(0x0D),ABX(0x1d),ABY(0x19), - INX(0x01),INY(0x11),-1}}, - {"SBC",1,{IMD(0xEB),IMD(0xe9),ZP(0xe5),ZPX(0xf5),ABS(0xeD),ABX(0xfd),ABY(0xf9), - INX(0xe1),INY(0xf1),-1}}, - {"STA",2,{ZP(0x85),ZPX(0x95),ABS(0x8D),ABX(0x9d),ABY(0x99), - INX(0x81),INY(0x91),-1}}, - {"STX",2,{ZP(0x86),ZPY(0x96),ABS(0x8E),-1}}, - {"STY",2,{ZP(0x84),ZPX(0x94),ABS(0x8C),-1}}, - {"BCC",1,{REL(0x90),-1}}, - {"BCS",1,{REL(0xb0),-1}}, - {"BEQ",1,{REL(0xf0),-1}}, - {"BNE",1,{REL(0xd0),-1}}, - {"BMI",1,{REL(0x30),-1}}, - {"BPL",1,{REL(0x10),-1}}, - {"BVC",1,{REL(0x50),-1}}, - {"BVS",1,{REL(0x70),-1}}, -}; - -uint16 FCEUI_Disassemble(void *XA, uint16 a, char *stringo) -{ - X6502 *X=XA; - uint8 buf; - unsigned int arg; - int32 info; - int x; - int y; - - info=-1; - fceuindbg=1; - - buf=ARead[a](a); - a++; - - for(x=0;x=0) - { - if((optable[x].modes[y]&0xFF)==buf) - { - info=optable[x].modes[y]; - goto endy; - } - y++; - } - } - - endy: - sprintf(stringo,"%02X ",buf); - if(info>=0) - { - int z=flengths[(info>>16)]; - - if(z) - { - arg=ARead[a](a); - sprintf(stringo+strlen(stringo),"%02X ",arg); - a++; - if(z==2) {arg|=ARead[a](a)<<8;sprintf(stringo+strlen(stringo),"%02X ",arg>>8);a++;} - else - strcat(stringo," "); - - if((info>>16)==1) /* Relative branch */ - arg=a+(char)arg; - sprintf(stringo+strlen(stringo),"%s ",optable[x].name); - sprintf(stringo+strlen(stringo),fstrings[info>>16],arg); -/* - 0 "#$%02X", // immediate - 1 "$%04X", // RELATIVE(jump) - 2 "$%02X", // Z - 3 "$%02X,X", // Z,x - 4 "$%02X,Y", // Z,y - 5 "$%04X", //ABS - 6 "$%04X,X", // ABS,x - 7 "$%04X,Y", // ABS,y - 8 "($%04X)", // IND - 9 "($%02X,X)", // INX - 10 "($%02X),Y", // INY - 11 #define IMP(x) ((11<<16)|x) -*/ - { - unsigned int tmp; - switch(info>>16) - { - case 2:tmp=arg; - if(optable[x].type&1) - { - sprintf(stringo+strlen(stringo)," @ $%04X",tmp); - sprintf(stringo+strlen(stringo)," = $%02X",ARead[tmp](tmp)); - } - break; - case 3:tmp=(arg+X->X)&0xff; - sprintf(stringo+strlen(stringo)," @ $%04X",tmp); - if(optable[x].type&1) - sprintf(stringo+strlen(stringo)," = $%02X",ARead[tmp](tmp)); - break; - case 4:tmp=(arg+X->Y)&0xff; - sprintf(stringo+strlen(stringo)," @ $%04X",tmp); - if(optable[x].type&1) - sprintf(stringo+strlen(stringo)," = $%02X",ARead[tmp](tmp)); - break; - case 5:tmp=arg; - if(optable[x].type&1) - { - sprintf(stringo+strlen(stringo)," @ $%04X",tmp); - sprintf(stringo+strlen(stringo)," = $%02X",ARead[tmp](tmp)); - } - break; - case 6:tmp=(arg+X->X)&0xffff; - sprintf(stringo+strlen(stringo)," @ $%04X",tmp); - if(optable[x].type&1) - sprintf(stringo+strlen(stringo)," = $%02X",ARead[tmp](tmp)); - break; - case 7:tmp=(arg+X->Y)&0xffff; - sprintf(stringo+strlen(stringo)," @ $%04X",tmp); - if(optable[x].type&1) - sprintf(stringo+strlen(stringo)," = $%02X",ARead[tmp](tmp)); - break; - case 8:tmp=ARead[arg](arg)|(ARead[(arg+1)&0xffff]((arg+1)&0xffff)<<8); - sprintf(stringo+strlen(stringo)," $%04X",tmp); - break; - case 9:tmp=(arg+X->X)&0xFF; - tmp=ARead[tmp](tmp) | (ARead[(tmp+1)&0xFF]((tmp+1)&0xFF)<<8); - sprintf(stringo+strlen(stringo)," @ $%04X",tmp); - if(optable[x].type&1) - sprintf(stringo+strlen(stringo)," = $%02X",ARead[tmp](tmp)); - break; - case 10:tmp=ARead[arg](arg) | (ARead[(arg+1)&0xFF]((arg+1)&0xFF)<<8); - tmp=(tmp+X->Y)&0xFFFF; - sprintf(stringo+strlen(stringo)," @ $%04X",tmp); - if(optable[x].type&1) - sprintf(stringo+strlen(stringo)," = $%02X",ARead[tmp](tmp)); - break; - - } - } - - - } - else - { - strcat(stringo," "); - strcat(stringo,optable[x].name); - } - } - else - sprintf(stringo+strlen(stringo)," .db $%02X",buf); - fceuindbg=0; - return(a); -} - -void FCEUI_MemDump(uint16 a, int32 len, void (*callb)(uint16 a, uint8 v)) -{ - fceuindbg=1; - while(len) - { - callb(a,ARead[a](a)); - a++; - len--; - } - fceuindbg=0; -} - -uint8 FCEUI_MemSafePeek(uint16 A) -{ - uint8 ret; - - fceuindbg=1; - ret=ARead[A](A); - fceuindbg=0; - return(ret); -} - -void FCEUI_MemPoke(uint16 a, uint8 v, int hl) -{ - extern uint8 *Page[32]; - if(hl) - { - if(Page[a/2048]) - Page[a/2048][a]=v; - } - else - BWrite[a](a,v); -} - -typedef struct __BPOINT { - struct __BPOINT *next; - void (*Handler)(X6502 *X, int type, unsigned int A); - unsigned int A[2]; - int type; -} BPOINT; - -static BPOINT *BreakPoints=NULL; -static BPOINT *LastBP=NULL; - -static void (*CPUHook)(X6502 *)=NULL; - -static int FindBPoint(X6502 *X, int who, unsigned int A) -{ - BPOINT *tmp; - - tmp=BreakPoints; - while(tmp) - { - if(tmp->type&who) - { - if(tmp->type&BPOINT_PC) - if(X->PC!=A) goto don; /* Doesn't match, so go on. */ - - if((A>=tmp->A[0]) && (A<=tmp->A[1])) /* Whee, match. */ - { - tmp->Handler(X,tmp->type,A); - return(1); - } - } - don: - tmp=tmp->next; - } - return(0); -} - -static uint8 ReadHandler(X6502 *X, unsigned int A) -{ - extern X6502 XSave; - - if(X->preexec) - FindBPoint(&XSave,BPOINT_READ,A); - return(ARead[A](A)); -} - -static void WriteHandler(X6502 *X, unsigned int A, uint8 V) -{ - extern X6502 XSave; - - if(X->preexec) - FindBPoint(&XSave,BPOINT_WRITE,A); - else - BWrite[A](A,V); -} - -int FCEUI_AddBreakPoint(int type, unsigned int A1, unsigned int A2, - void (*Handler)(X6502 *, int type, unsigned int A)) -{ - BPOINT *tmp; - - tmp=(BPOINT *)malloc(sizeof(BPOINT)); - - tmp->A[0]=A1; - tmp->A[1]=A2; - tmp->Handler=Handler; - tmp->type=type; - tmp->next=0; - - if(BreakPoints==NULL) - BreakPoints=tmp; - else - LastBP->next=tmp; - - LastBP=tmp; - - X6502_Debug(CPUHook,ReadHandler,WriteHandler); - return(1); -} - -int FCEUI_SetBreakPoint(uint32 w, int type, unsigned int A1, unsigned int A2, - void (*Handler)(X6502 *, int type, unsigned int A)) -{ - uint32 x=0; - BPOINT *tmp; - - tmp=BreakPoints; - - while(tmp) - { - if(w==x) - { - tmp->type=type; - tmp->A[0]=A1; - tmp->A[1]=A2; - tmp->Handler=Handler; - return(1); - } - x++; - tmp=tmp->next; - } - return(0); -} - -int FCEUI_GetBreakPoint(uint32 w, int *type, unsigned int *A1, unsigned int *A2, - void (**Handler)(X6502 *, int type, unsigned int A)) -{ - uint32 x=0; - BPOINT *tmp; - - tmp=BreakPoints; - - while(tmp) - { - if(w==x) - { - *type=tmp->type; - *A1=tmp->A[0]; - *A2=tmp->A[1]; - *Handler=tmp->Handler; - return(1); - } - x++; - tmp=tmp->next; - } - return(0); -} - -int FCEUI_ListBreakPoints(int (*callb)(int type, unsigned int A1, unsigned int A2, - void (*Handler)(X6502 *, int type, unsigned int A) )) -{ - BPOINT *tmp; - tmp=BreakPoints; - while(tmp) - { - callb(tmp->type,tmp->A[0],tmp->A[1],tmp->Handler); - tmp=tmp->next; - } - return(1); -} - -int FCEUI_DeleteBreakPoint(uint32 w) -{ - BPOINT *tmp,*prev=NULL; - uint32 x=0; - - tmp=BreakPoints; - - while(tmp) - { - if(w==x) - { - if(prev) /* Not the first breakpoint. */ - { - if(tmp->next) /* More breakpoints. */ - prev->next=tmp->next; - else /* This is the last breakpoint. */ - { - prev->next=0; - LastBP=prev; - } - } - else /* The first breakpoint. */ - { - if(tmp->next) /* More breakpoints. */ - BreakPoints=tmp->next; - else - { - BreakPoints=LastBP=0; /* No more breakpoints. */ - /* Update the CPU hooks. */ - X6502_Debug(CPUHook,BreakPoints?ReadHandler:0,BreakPoints?WriteHandler:0); - } - } - free(tmp); - return(1); - } - prev=tmp; - tmp=tmp->next; - x++; - } - return(0); -} - -void FCEUI_SetCPUCallback(void (*callb)(X6502 *X)) -{ - CPUHook=callb; - X6502_Debug(CPUHook,BreakPoints?ReadHandler:0,BreakPoints?WriteHandler:0); -} +/* FCE Ultra - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2003 Xodnizel + * + * 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 +#include +#include + +#include "types.h" +#include "x6502.h" +#include "fceu.h" +#include "debug.h" + + + +void FCEUI_DumpMem(const char *fname, uint32 start, uint32 end) +{ + FILE *fp=FCEUD_UTF8fopen(fname,"wb"); + fceuindbg=1; + for(;start<=end;start++) + fputc(ARead[start](start),fp); + fclose(fp); + fceuindbg=0; +} + +void FCEUI_LoadMem(const char *fname, uint32 start, int hl) +{ + int t; + + FILE *fp=FCEUD_UTF8fopen(fname,"rb"); + while((t=fgetc(fp))>=0) + { + if(start>0xFFFF) break; + if(hl) + { + extern uint8 *Page[32]; + if(Page[start/2048]) + Page[start/2048][start]=t; + } + else + BWrite[start](start,t); + start++; + } + fclose(fp); +} + +#ifdef FCEUDEF_DEBUGGER + +static char *fstrings[12]= +{ + "#$%02X", // immediate + "$%04X", // RELATIVE(jump) + "$%02X", // Z + "$%02X,X", // Z,x + "$%02X,Y", // Z,y + "$%04X", //ABS + "$%04X,X", // ABS,x + "$%04X,Y", // ABS,y + "($%04X)", // IND + "($%02X,X)", // INX + "($%02X),Y", // INY + "" +}; +static int flengths[12]={1,1,1,1,1,2,2,2,2,1,1,0}; + +#define IMD(x) ((0<<16)|x) +#define REL(x) ((1<<16)|x) +#define ZP(x) ((2<<16)|x) +#define ZPX(x) ((3<<16)|x) +#define ZPY(x) ((4<<16)|x) +#define ABS(x) ((5<<16)|x) +#define ABX(x) ((6<<16)|x) +#define ABY(x) ((7<<16)|x) +#define IND(x) ((8<<16)|x) +#define INX(x) ((9<<16)|x) +#define INY(x) ((10<<16)|x) +#define IMP(x) ((11<<16)|x) + +typedef struct { + char *name; + int type; /* 1 for read, 2 for write, 3 for r then write. */ + int32 modes[10]; +} OPS; +#define NUMOPS 56 +static OPS optable[NUMOPS]= +{ + {"BRK",0,{IMP(0x00),-1}}, + {"RTI",0,{IMP(0x40),-1}}, + {"RTS",0,{IMP(0x60),-1}}, + {"PHA",2,{IMP(0x48),-1}}, + {"PHP",2,{IMP(0x08),-1}}, + {"PLA",1,{IMP(0x68),-1}}, + {"PLP",1,{IMP(0x28),-1}}, + {"JMP",0,{ABS(0x4C),IND(0x6C),-1}}, + {"JSR",0,{ABS(0x20),-1}}, + {"TAX",0,{IMP(0xAA),-1}}, + {"TXA",0,{IMP(0x8A),-1}}, + {"TAY",0,{IMP(0xA8),-1}}, + {"TYA",0,{IMP(0x98),-1}}, + {"TSX",0,{IMP(0xBA),-1}}, + {"TXS",0,{IMP(0x9A),-1}}, + {"DEX",0,{IMP(0xCA),-1}}, + {"DEY",0,{IMP(0x88),-1}}, + {"INX",0,{IMP(0xE8),-1}}, + {"INY",0,{IMP(0xC8),-1}}, + {"CLC",0,{IMP(0x18),-1}}, + {"CLD",0,{IMP(0xD8),-1}}, + {"CLI",0,{IMP(0x58),-1}}, + {"CLV",0,{IMP(0xB8),-1}}, + {"SEC",0,{IMP(0x38),-1}}, + {"SED",0,{IMP(0xF8),-1}}, + {"SEI",0,{IMP(0x78),-1}}, + {"NOP",0,{IMP(0xEA),-1}}, + {"ASL",1,{IMP(0x0a),ZP(0x06),ZPX(0x16),ABS(0x0E),ABX(0x1E),-1}}, + {"DEC",3,{ZP(0xc6),ZPX(0xd6),ABS(0xcE),ABX(0xdE),-1}}, + {"INC",3,{ZP(0xe6),ZPX(0xf6),ABS(0xeE),ABX(0xfE),-1}}, + {"LSR",3,{IMP(0x4a),ZP(0x46),ZPX(0x56),ABS(0x4E),ABX(0x5E),-1}}, + {"ROL",3,{IMP(0x2a),ZP(0x26),ZPX(0x36),ABS(0x2E),ABX(0x3E),-1}}, + {"ROR",3,{IMP(0x6a),ZP(0x66),ZPX(0x76),ABS(0x6E),ABX(0x7E),-1}}, + {"ADC",1,{IMD(0x69),ZP(0x65),ZPX(0x75),ABS(0x6D),ABX(0x7d),ABY(0x79), + INX(0x61),INY(0x71),-1}}, + {"AND",1,{IMD(0x29),ZP(0x25),ZPX(0x35),ABS(0x2D),ABX(0x3d),ABY(0x39), + INX(0x21),INY(0x31),-1}}, + {"BIT",1,{ZP(0x24),ABS(0x2c),-1}}, + {"CMP",1,{IMD(0xc9),ZP(0xc5),ZPX(0xd5),ABS(0xcD),ABX(0xdd),ABY(0xd9), + INX(0xc1),INY(0xd1),-1}}, + {"CPX",1,{IMD(0xe0),ZP(0xe4),ABS(0xec),-1}}, + {"CPY",1,{IMD(0xc0),ZP(0xc4),ABS(0xcc),-1}}, + {"EOR",1,{IMD(0x49),ZP(0x45),ZPX(0x55),ABS(0x4D),ABX(0x5d),ABY(0x59), + INX(0x41),INY(0x51),-1}}, + {"LDA",1,{IMD(0xa9),ZP(0xa5),ZPX(0xb5),ABS(0xaD),ABX(0xbd),ABY(0xb9), + INX(0xa1),INY(0xb1),-1}}, + {"LDX",1,{IMD(0xa2),ZP(0xa6),ZPY(0xB6),ABS(0xae),ABY(0xbe),-1}}, + {"LDY",1,{IMD(0xa0),ZP(0xa4),ZPX(0xB4),ABS(0xac),ABX(0xbc),-1}}, + {"ORA",1,{IMD(0x09),ZP(0x05),ZPX(0x15),ABS(0x0D),ABX(0x1d),ABY(0x19), + INX(0x01),INY(0x11),-1}}, + {"SBC",1,{IMD(0xEB),IMD(0xe9),ZP(0xe5),ZPX(0xf5),ABS(0xeD),ABX(0xfd),ABY(0xf9), + INX(0xe1),INY(0xf1),-1}}, + {"STA",2,{ZP(0x85),ZPX(0x95),ABS(0x8D),ABX(0x9d),ABY(0x99), + INX(0x81),INY(0x91),-1}}, + {"STX",2,{ZP(0x86),ZPY(0x96),ABS(0x8E),-1}}, + {"STY",2,{ZP(0x84),ZPX(0x94),ABS(0x8C),-1}}, + {"BCC",1,{REL(0x90),-1}}, + {"BCS",1,{REL(0xb0),-1}}, + {"BEQ",1,{REL(0xf0),-1}}, + {"BNE",1,{REL(0xd0),-1}}, + {"BMI",1,{REL(0x30),-1}}, + {"BPL",1,{REL(0x10),-1}}, + {"BVC",1,{REL(0x50),-1}}, + {"BVS",1,{REL(0x70),-1}}, +}; + +uint16 FCEUI_Disassemble(void *XA, uint16 a, char *stringo) +{ + X6502 *X=XA; + uint8 buf; + unsigned int arg; + int32 info; + int x; + int y; + + info=-1; + fceuindbg=1; + + buf=ARead[a](a); + a++; + + for(x=0;x=0) + { + if((optable[x].modes[y]&0xFF)==buf) + { + info=optable[x].modes[y]; + goto endy; + } + y++; + } + } + + endy: + sprintf(stringo,"%02X ",buf); + if(info>=0) + { + int z=flengths[(info>>16)]; + + if(z) + { + arg=ARead[a](a); + sprintf(stringo+strlen(stringo),"%02X ",arg); + a++; + if(z==2) {arg|=ARead[a](a)<<8;sprintf(stringo+strlen(stringo),"%02X ",arg>>8);a++;} + else + strcat(stringo," "); + + if((info>>16)==1) /* Relative branch */ + arg=a+(char)arg; + sprintf(stringo+strlen(stringo),"%s ",optable[x].name); + sprintf(stringo+strlen(stringo),fstrings[info>>16],arg); +/* + 0 "#$%02X", // immediate + 1 "$%04X", // RELATIVE(jump) + 2 "$%02X", // Z + 3 "$%02X,X", // Z,x + 4 "$%02X,Y", // Z,y + 5 "$%04X", //ABS + 6 "$%04X,X", // ABS,x + 7 "$%04X,Y", // ABS,y + 8 "($%04X)", // IND + 9 "($%02X,X)", // INX + 10 "($%02X),Y", // INY + 11 #define IMP(x) ((11<<16)|x) +*/ + { + unsigned int tmp; + switch(info>>16) + { + case 2:tmp=arg; + if(optable[x].type&1) + { + sprintf(stringo+strlen(stringo)," @ $%04X",tmp); + sprintf(stringo+strlen(stringo)," = $%02X",ARead[tmp](tmp)); + } + break; + case 3:tmp=(arg+X->X)&0xff; + sprintf(stringo+strlen(stringo)," @ $%04X",tmp); + if(optable[x].type&1) + sprintf(stringo+strlen(stringo)," = $%02X",ARead[tmp](tmp)); + break; + case 4:tmp=(arg+X->Y)&0xff; + sprintf(stringo+strlen(stringo)," @ $%04X",tmp); + if(optable[x].type&1) + sprintf(stringo+strlen(stringo)," = $%02X",ARead[tmp](tmp)); + break; + case 5:tmp=arg; + if(optable[x].type&1) + { + sprintf(stringo+strlen(stringo)," @ $%04X",tmp); + sprintf(stringo+strlen(stringo)," = $%02X",ARead[tmp](tmp)); + } + break; + case 6:tmp=(arg+X->X)&0xffff; + sprintf(stringo+strlen(stringo)," @ $%04X",tmp); + if(optable[x].type&1) + sprintf(stringo+strlen(stringo)," = $%02X",ARead[tmp](tmp)); + break; + case 7:tmp=(arg+X->Y)&0xffff; + sprintf(stringo+strlen(stringo)," @ $%04X",tmp); + if(optable[x].type&1) + sprintf(stringo+strlen(stringo)," = $%02X",ARead[tmp](tmp)); + break; + case 8:tmp=ARead[arg](arg)|(ARead[(arg+1)&0xffff]((arg+1)&0xffff)<<8); + sprintf(stringo+strlen(stringo)," $%04X",tmp); + break; + case 9:tmp=(arg+X->X)&0xFF; + tmp=ARead[tmp](tmp) | (ARead[(tmp+1)&0xFF]((tmp+1)&0xFF)<<8); + sprintf(stringo+strlen(stringo)," @ $%04X",tmp); + if(optable[x].type&1) + sprintf(stringo+strlen(stringo)," = $%02X",ARead[tmp](tmp)); + break; + case 10:tmp=ARead[arg](arg) | (ARead[(arg+1)&0xFF]((arg+1)&0xFF)<<8); + tmp=(tmp+X->Y)&0xFFFF; + sprintf(stringo+strlen(stringo)," @ $%04X",tmp); + if(optable[x].type&1) + sprintf(stringo+strlen(stringo)," = $%02X",ARead[tmp](tmp)); + break; + + } + } + + + } + else + { + strcat(stringo," "); + strcat(stringo,optable[x].name); + } + } + else + sprintf(stringo+strlen(stringo)," .db $%02X",buf); + fceuindbg=0; + return(a); +} + +void FCEUI_MemDump(uint16 a, int32 len, void (*callb)(uint16 a, uint8 v)) +{ + fceuindbg=1; + while(len) + { + callb(a,ARead[a](a)); + a++; + len--; + } + fceuindbg=0; +} + +uint8 FCEUI_MemSafePeek(uint16 A) +{ + uint8 ret; + + fceuindbg=1; + ret=ARead[A](A); + fceuindbg=0; + return(ret); +} + +void FCEUI_MemPoke(uint16 a, uint8 v, int hl) +{ + extern uint8 *Page[32]; + if(hl) + { + if(Page[a/2048]) + Page[a/2048][a]=v; + } + else + BWrite[a](a,v); +} + +typedef struct __BPOINT { + struct __BPOINT *next; + void (*Handler)(X6502 *X, int type, unsigned int A); + unsigned int A[2]; + int type; +} BPOINT; + +static BPOINT *BreakPoints=NULL; +static BPOINT *LastBP=NULL; + +static void (*CPUHook)(X6502 *)=NULL; + +static int FindBPoint(X6502 *X, int who, unsigned int A) +{ + BPOINT *tmp; + + tmp=BreakPoints; + while(tmp) + { + if(tmp->type&who) + { + if(tmp->type&BPOINT_PC) + if(X->PC!=A) goto don; /* Doesn't match, so go on. */ + + if((A>=tmp->A[0]) && (A<=tmp->A[1])) /* Whee, match. */ + { + tmp->Handler(X,tmp->type,A); + return(1); + } + } + don: + tmp=tmp->next; + } + return(0); +} + +static uint8 ReadHandler(X6502 *X, unsigned int A) +{ + extern X6502 XSave; + + if(X->preexec) + FindBPoint(&XSave,BPOINT_READ,A); + return(ARead[A](A)); +} + +static void WriteHandler(X6502 *X, unsigned int A, uint8 V) +{ + extern X6502 XSave; + + if(X->preexec) + FindBPoint(&XSave,BPOINT_WRITE,A); + else + BWrite[A](A,V); +} + +int FCEUI_AddBreakPoint(int type, unsigned int A1, unsigned int A2, + void (*Handler)(X6502 *, int type, unsigned int A)) +{ + BPOINT *tmp; + + tmp=(BPOINT *)malloc(sizeof(BPOINT)); + + tmp->A[0]=A1; + tmp->A[1]=A2; + tmp->Handler=Handler; + tmp->type=type; + tmp->next=0; + + if(BreakPoints==NULL) + BreakPoints=tmp; + else + LastBP->next=tmp; + + LastBP=tmp; + + X6502_Debug(CPUHook,ReadHandler,WriteHandler); + return(1); +} + +int FCEUI_SetBreakPoint(uint32 w, int type, unsigned int A1, unsigned int A2, + void (*Handler)(X6502 *, int type, unsigned int A)) +{ + uint32 x=0; + BPOINT *tmp; + + tmp=BreakPoints; + + while(tmp) + { + if(w==x) + { + tmp->type=type; + tmp->A[0]=A1; + tmp->A[1]=A2; + tmp->Handler=Handler; + return(1); + } + x++; + tmp=tmp->next; + } + return(0); +} + +int FCEUI_GetBreakPoint(uint32 w, int *type, unsigned int *A1, unsigned int *A2, + void (**Handler)(X6502 *, int type, unsigned int A)) +{ + uint32 x=0; + BPOINT *tmp; + + tmp=BreakPoints; + + while(tmp) + { + if(w==x) + { + *type=tmp->type; + *A1=tmp->A[0]; + *A2=tmp->A[1]; + *Handler=tmp->Handler; + return(1); + } + x++; + tmp=tmp->next; + } + return(0); +} + +int FCEUI_ListBreakPoints(int (*callb)(int type, unsigned int A1, unsigned int A2, + void (*Handler)(X6502 *, int type, unsigned int A) )) +{ + BPOINT *tmp; + tmp=BreakPoints; + while(tmp) + { + callb(tmp->type,tmp->A[0],tmp->A[1],tmp->Handler); + tmp=tmp->next; + } + return(1); +} + +int FCEUI_DeleteBreakPoint(uint32 w) +{ + BPOINT *tmp,*prev=NULL; + uint32 x=0; + + tmp=BreakPoints; + + while(tmp) + { + if(w==x) + { + if(prev) /* Not the first breakpoint. */ + { + if(tmp->next) /* More breakpoints. */ + prev->next=tmp->next; + else /* This is the last breakpoint. */ + { + prev->next=0; + LastBP=prev; + } + } + else /* The first breakpoint. */ + { + if(tmp->next) /* More breakpoints. */ + BreakPoints=tmp->next; + else + { + BreakPoints=LastBP=0; /* No more breakpoints. */ + /* Update the CPU hooks. */ + X6502_Debug(CPUHook,BreakPoints?ReadHandler:0,BreakPoints?WriteHandler:0); + } + } + free(tmp); + return(1); + } + prev=tmp; + tmp=tmp->next; + x++; + } + return(0); +} + +void FCEUI_SetCPUCallback(void (*callb)(X6502 *X)) +{ + CPUHook=callb; + X6502_Debug(CPUHook,BreakPoints?ReadHandler:0,BreakPoints?WriteHandler:0); +} +#endif diff --git a/source/fceultra/debug.h b/source/fceultra/debug.h index 00252d0..2c91a32 100644 --- a/source/fceultra/debug.h +++ b/source/fceultra/debug.h @@ -1,3 +1,7 @@ +void FCEUI_DumpMem(const char *fname, uint32 start, uint32 end); +void FCEUI_LoadMem(const char *fname, uint32 start, int hl); + +#ifdef FCEUDEF_DEBUGGER /* Type attributes, you can OR them together. */ #define BPOINT_READ 1 @@ -6,8 +10,6 @@ #include "x6502struct.h" -void FCEUI_DumpMem(const char *fname, uint32 start, uint32 end); -void FCEUI_LoadMem(const char *fname, uint32 start, int hl); void FCEUI_SetCPUCallback(void (*callb)(X6502 *X)); int FCEUI_DeleteBreakPoint(uint32 w); int FCEUI_ListBreakPoints(int (*callb)(int type, unsigned int A1, unsigned int A2, @@ -18,3 +20,4 @@ int FCEUI_SetBreakPoint(uint32 w, int type, unsigned int A1, unsigned int A2, void (*Handler)(X6502 *, int type, unsigned int A)); int FCEUI_AddBreakPoint(int type, unsigned int A1, unsigned int A2, void (*Handler)(X6502 *, int type, unsigned int A)); +#endif diff --git a/source/fceultra/fceu.c b/source/fceultra/fceu.c index 4f2c856..11f4baa 100644 --- a/source/fceultra/fceu.c +++ b/source/fceultra/fceu.c @@ -1,505 +1,506 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2003 Xodnizel - * - * 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 -#include -#include -#include - -#include "types.h" -#include "x6502.h" -#include "fceu.h" -#include "ppu.h" -#include "sound.h" -#include "netplay.h" -#include "general.h" -#include "endian.h" -#include "memory.h" - -#include "cart.h" -#include "nsf.h" -#include "fds.h" -#include "ines.h" -#include "unif.h" -#include "cheat.h" -#include "palette.h" -#include "state.h" -#include "movie.h" -#include "video.h" -#include "input.h" -#include "file.h" -#include "crc32.h" -#include "vsuni.h" - -uint64 timestampbase; - - -FCEUGI *FCEUGameInfo = NULL; -void (*GameInterface)(int h); - -void (*GameStateRestore)(int version); - -readfunc ARead[0x10000]; -writefunc BWrite[0x10000]; -static readfunc *AReadG; -static writefunc *BWriteG; -static int RWWrap=0; - -static DECLFW(BNull) -{ - -} - -static DECLFR(ANull) -{ - return(X.DB); -} - -int AllocGenieRW(void) -{ - if(!(AReadG=(readfunc *)FCEU_malloc(0x8000*sizeof(readfunc)))) - return 0; - if(!(BWriteG=(writefunc *)FCEU_malloc(0x8000*sizeof(writefunc)))) - return 0; - RWWrap=1; - return 1; -} - -void FlushGenieRW(void) -{ - int32 x; - - if(RWWrap) - { - for(x=0;x<0x8000;x++) - { - ARead[x+0x8000]=AReadG[x]; - BWrite[x+0x8000]=BWriteG[x]; - } - free(AReadG); - free(BWriteG); - AReadG=0; - BWriteG=0; - RWWrap=0; - } -} - -readfunc FASTAPASS(1) GetReadHandler(int32 a) -{ - if(a>=0x8000 && RWWrap) - return AReadG[a-0x8000]; - else - return ARead[a]; -} - -void FASTAPASS(3) SetReadHandler(int32 start, int32 end, readfunc func) -{ - int32 x; - - if(!func) - func=ANull; - - if(RWWrap) - for(x=end;x>=start;x--) - { - if(x>=0x8000) - AReadG[x-0x8000]=func; - else - ARead[x]=func; - } - else - - for(x=end;x>=start;x--) - ARead[x]=func; -} - -writefunc FASTAPASS(1) GetWriteHandler(int32 a) -{ - if(RWWrap && a>=0x8000) - return BWriteG[a-0x8000]; - else - return BWrite[a]; -} - -void FASTAPASS(3) SetWriteHandler(int32 start, int32 end, writefunc func) -{ - int32 x; - - if(!func) - func=BNull; - - if(RWWrap) - for(x=end;x>=start;x--) - { - if(x>=0x8000) - BWriteG[x-0x8000]=func; - else - BWrite[x]=func; - } - else - for(x=end;x>=start;x--) - BWrite[x]=func; -} - -uint8 GameMemBlock[131072]; -uint8 RAM[0x800]; -uint8 PAL=0; - -static DECLFW(BRAML) -{ - RAM[A]=V; -} - -static DECLFW(BRAMH) -{ - RAM[A&0x7FF]=V; -} - -static DECLFR(ARAML) -{ - return RAM[A]; -} - -static DECLFR(ARAMH) -{ - return RAM[A&0x7FF]; -} - -static void CloseGame(void) -{ - if(FCEUGameInfo) - { - //if(FCEUnetplay) - // FCEUD_NetworkClose(); - if(FCEUGameInfo->name) - { - free(FCEUGameInfo->name); - FCEUGameInfo->name=0; - } - if(FCEUGameInfo->type!=GIT_NSF) - FCEU_FlushGameCheats(0,0); - GameInterface(GI_CLOSE); - ResetExState(0,0); - //CloseGenie(); - free(FCEUGameInfo); - FCEUGameInfo = 0; - } -} - -void ResetGameLoaded(void) -{ - if(FCEUGameInfo) CloseGame(); - GameStateRestore=0; - PPU_hook=0; - GameHBIRQHook=0; - if(GameExpSound.Kill) - GameExpSound.Kill(); - memset(&GameExpSound,0,sizeof(GameExpSound)); - MapIRQHook=0; - MMC5Hack=0; - PAL&=1; - pale=0; -} - -int UNIFLoad(const char *name, FCEUFILE *fp); -int iNESLoad(const char *name, FCEUFILE *fp); -int FDSLoad(const char *name, FCEUFILE *fp); -int NSFLoad(FCEUFILE *fp); - -FCEUGI *FCEUI_LoadGame(const char *name) -{ - FCEUFILE *fp; - char *ipsfn; - - ResetGameLoaded(); - - FCEUGameInfo = malloc(sizeof(FCEUGI)); - memset(FCEUGameInfo, 0, sizeof(FCEUGI)); - - FCEUGameInfo->soundchan = 0; - FCEUGameInfo->soundrate = 0; - FCEUGameInfo->name=0; - FCEUGameInfo->type=GIT_CART; - FCEUGameInfo->vidsys=GIV_USER; - FCEUGameInfo->input[0]=FCEUGameInfo->input[1]=-1; - FCEUGameInfo->inputfc=-1; - FCEUGameInfo->cspecial=0; - - FCEU_printf("Loading %s...\n\n",name); - - GetFileBase(name); - - ipsfn=FCEU_MakeFName(FCEUMKF_IPS,0,0); - fp=FCEU_fopen(name,ipsfn,"rb",0); - free(ipsfn); - - if(!fp) - { - FCEU_PrintError("Error opening \"%s\"!",name); - return 0; - } - - if(iNESLoad(name,fp)) - goto endlseq; - if(NSFLoad(fp)) - goto endlseq; - if(UNIFLoad(name,fp)) - goto endlseq; - if(FDSLoad(name,fp)) - goto endlseq; - - FCEU_PrintError("An error occurred while loading the file."); - FCEU_fclose(fp); - return 0; - - endlseq: - FCEU_fclose(fp); - - FCEU_ResetVidSys(); - if(FCEUGameInfo->type!=GIT_NSF) - if(FSettings.GameGenie) - OpenGenie(); - - PowerNES(); - FCEUSS_CheckStates(); - FCEUMOV_CheckMovies(); - - if(FCEUGameInfo->type!=GIT_NSF) - { - FCEU_LoadGamePalette(); - FCEU_LoadGameCheats(0); - } - - FCEU_ResetPalette(); - FCEU_ResetMessages(); // Save state, status messages, etc. - - return(FCEUGameInfo); -} - - -int FCEUI_Initialize(void) -{ - if(!FCEU_InitVirtualVideo()) - return 0; - memset(&FSettings,0,sizeof(FSettings)); - FSettings.UsrFirstSLine[0]=8; - FSettings.UsrFirstSLine[1]=0; - FSettings.UsrLastSLine[0]=231; - FSettings.UsrLastSLine[1]=239; - FSettings.SoundVolume=100; - FCEUPPU_Init(); - X6502_Init(); - return 1; -} - -void FCEUI_Kill(void) -{ - FCEU_KillVirtualVideo(); - FCEU_KillGenie(); -} - -void FCEUI_Emulate(uint8 **pXBuf, int32 **SoundBuf, int32 *SoundBufSize, int skip) -{ - int r,ssize; - - FCEU_UpdateInput(); - if(geniestage!=1) FCEU_ApplyPeriodicCheats(); - r=FCEUPPU_Loop(skip); - - ssize=FlushEmulateSound(); - - timestampbase += timestamp; - timestamp = 0; - - *pXBuf=skip?0:XBuf; - *SoundBuf=WaveFinal; - *SoundBufSize=ssize; -} - -void FCEUI_CloseGame(void) -{ - CloseGame(); -} - -void ResetNES(void) -{ - FCEUMOV_AddCommand(FCEUNPCMD_RESET); - if(!FCEUGameInfo) return; - GameInterface(GI_RESETM2); - FCEUSND_Reset(); - FCEUPPU_Reset(); - X6502_Reset(); -} - -void FCEU_MemoryRand(uint8 *ptr, uint32 size) -{ - int x=0; - while(size) - { - *ptr=(x&4)?0xFF:0x00; - x++; - size--; - ptr++; - } -} - -void hand(X6502 *X, int type, unsigned int A) -{ - -} - -void PowerNES(void) -{ - FCEUMOV_AddCommand(FCEUNPCMD_POWER); - if(!FCEUGameInfo) return; - - FCEU_CheatResetRAM(); - FCEU_CheatAddRAM(2,0,RAM); - - GeniePower(); - - FCEU_MemoryRand(RAM,0x800); - //memset(RAM,0xFF,0x800); - - SetReadHandler(0x0000,0xFFFF,ANull); - SetWriteHandler(0x0000,0xFFFF,BNull); - - SetReadHandler(0,0x7FF,ARAML); - SetWriteHandler(0,0x7FF,BRAML); - - SetReadHandler(0x800,0x1FFF,ARAMH); /* Part of a little */ - SetWriteHandler(0x800,0x1FFF,BRAMH); /* hack for a small speed boost. */ - - InitializeInput(); - FCEUSND_Power(); - FCEUPPU_Power(); - - /* Have the external game hardware "powered" after the internal NES stuff. - Needed for the NSF code and VS System code. - */ - GameInterface(GI_POWER); - if(FCEUGameInfo->type==GIT_VSUNI) - FCEU_VSUniPower(); - - - timestampbase=0; - X6502_Power(); - FCEU_PowerCheats(); -} - -void FCEU_ResetVidSys(void) -{ - int w; - - if(FCEUGameInfo->vidsys==GIV_NTSC) - w=0; - else if(FCEUGameInfo->vidsys==GIV_PAL) - w=1; - else - w=FSettings.PAL; - - PAL=w?1:0; - FCEUPPU_SetVideoSystem(w); - SetSoundVariables(); -} - -FCEUS FSettings; - -void FCEU_printf(char *format, ...) -{ - char temp[2048]; - - va_list ap; - - va_start(ap,format); - vsprintf(temp,format,ap); - FCEUD_Message(temp); - - va_end(ap); -} - -void FCEU_PrintError(char *format, ...) -{ - char temp[2048]; - - va_list ap; - - va_start(ap,format); - vsprintf(temp,format,ap); - FCEUD_PrintError(temp); - - va_end(ap); -} - -void FCEUI_SetRenderedLines(int ntscf, int ntscl, int palf, int pall) -{ - FSettings.UsrFirstSLine[0]=ntscf; - FSettings.UsrLastSLine[0]=ntscl; - FSettings.UsrFirstSLine[1]=palf; - FSettings.UsrLastSLine[1]=pall; - if(PAL) - { - FSettings.FirstSLine=FSettings.UsrFirstSLine[1]; - FSettings.LastSLine=FSettings.UsrLastSLine[1]; - } - else - { - FSettings.FirstSLine=FSettings.UsrFirstSLine[0]; - FSettings.LastSLine=FSettings.UsrLastSLine[0]; - } - -} - -void FCEUI_SetVidSystem(int a) -{ - FSettings.PAL=a?1:0; - if(FCEUGameInfo) - { - FCEU_ResetVidSys(); - FCEU_ResetPalette(); - } -} - -int FCEUI_GetCurrentVidSystem(int *slstart, int *slend) -{ - if(slstart) - *slstart=FSettings.FirstSLine; - if(slend) - *slend=FSettings.LastSLine; - return(PAL); -} - -void FCEUI_SetGameGenie(int a) -{ - FSettings.GameGenie=a?1:0; -} - -void FCEUI_SetSnapName(int a) -{ - FSettings.SnapName=a; -} - -int32 FCEUI_GetDesiredFPS(void) -{ - if(PAL) - return(838977920); // ~50.007 - else - return(1008307711); // ~60.1 -} +/* FCE Ultra - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2003 Xodnizel + * + * 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 +#include +#include +#include + +#include "types.h" +#include "x6502.h" +#include "fceu.h" +#include "ppu.h" +#include "sound.h" +#include "netplay.h" +#include "general.h" +#include "endian.h" +#include "memory.h" + +#include "cart.h" +#include "nsf.h" +#include "fds.h" +#include "ines.h" +#include "unif.h" +#include "cheat.h" +#include "palette.h" +#include "state.h" +#include "movie.h" +#include "video.h" +#include "input.h" +#include "file.h" +#include "crc32.h" +#include "vsuni.h" + +uint64 timestampbase; + + +FCEUGI *FCEUGameInfo = NULL; +void (*GameInterface)(int h); + +void (*GameStateRestore)(int version); + +readfunc ARead[0x10000]; +writefunc BWrite[0x10000]; +static readfunc *AReadG; +static writefunc *BWriteG; +static int RWWrap=0; + +static DECLFW(BNull) +{ + +} + +static DECLFR(ANull) +{ + return(X.DB); +} + +int AllocGenieRW(void) +{ + if(!(AReadG=(readfunc *)FCEU_malloc(0x8000*sizeof(readfunc)))) + return 0; + if(!(BWriteG=(writefunc *)FCEU_malloc(0x8000*sizeof(writefunc)))) + return 0; + RWWrap=1; + return 1; +} + +void FlushGenieRW(void) +{ + int32 x; + + if(RWWrap) + { + for(x=0;x<0x8000;x++) + { + ARead[x+0x8000]=AReadG[x]; + BWrite[x+0x8000]=BWriteG[x]; + } + free(AReadG); + free(BWriteG); + AReadG=0; + BWriteG=0; + RWWrap=0; + } +} + +readfunc FASTAPASS(1) GetReadHandler(int32 a) +{ + if(a>=0x8000 && RWWrap) + return AReadG[a-0x8000]; + else + return ARead[a]; +} + +void FASTAPASS(3) SetReadHandler(int32 start, int32 end, readfunc func) +{ + int32 x; + + if(!func) + func=ANull; + + if(RWWrap) + for(x=end;x>=start;x--) + { + if(x>=0x8000) + AReadG[x-0x8000]=func; + else + ARead[x]=func; + } + else + + for(x=end;x>=start;x--) + ARead[x]=func; +} + +writefunc FASTAPASS(1) GetWriteHandler(int32 a) +{ + if(RWWrap && a>=0x8000) + return BWriteG[a-0x8000]; + else + return BWrite[a]; +} + +void FASTAPASS(3) SetWriteHandler(int32 start, int32 end, writefunc func) +{ + int32 x; + + if(!func) + func=BNull; + + if(RWWrap) + for(x=end;x>=start;x--) + { + if(x>=0x8000) + BWriteG[x-0x8000]=func; + else + BWrite[x]=func; + } + else + for(x=end;x>=start;x--) + BWrite[x]=func; +} + +uint8 GameMemBlock[131072]; +uint8 RAM[0x800]; +uint8 PAL=0; + +static DECLFW(BRAML) +{ + RAM[A]=V; +} + +static DECLFW(BRAMH) +{ + RAM[A&0x7FF]=V; +} + +static DECLFR(ARAML) +{ + return RAM[A]; +} + +static DECLFR(ARAMH) +{ + return RAM[A&0x7FF]; +} + +static void CloseGame(void) +{ + if(FCEUGameInfo) + { + if(FCEUnetplay) + FCEUD_NetworkClose(); + if(FCEUGameInfo->name) + { + free(FCEUGameInfo->name); + FCEUGameInfo->name=0; + } + if(FCEUGameInfo->type!=GIT_NSF) + FCEU_FlushGameCheats(0,0); + GameInterface(GI_CLOSE); + ResetExState(0,0); + CloseGenie(); + free(FCEUGameInfo); + FCEUGameInfo = 0; + } +} + +void ResetGameLoaded(void) +{ + if(FCEUGameInfo) CloseGame(); + GameStateRestore=0; + PPU_hook=0; + GameHBIRQHook=0; + if(GameExpSound.Kill) + GameExpSound.Kill(); + memset(&GameExpSound,0,sizeof(GameExpSound)); + MapIRQHook=0; + MMC5Hack=0; + PAL&=1; + pale=0; +} + +int UNIFLoad(const char *name, FCEUFILE *fp); +int iNESLoad(const char *name, FCEUFILE *fp); +int FDSLoad(const char *name, FCEUFILE *fp); +int NSFLoad(FCEUFILE *fp); + +FCEUGI *FCEUI_LoadGame(const char *name) +{ + FCEUFILE *fp; + char *ipsfn; + + ResetGameLoaded(); + + FCEUGameInfo = malloc(sizeof(FCEUGI)); + memset(FCEUGameInfo, 0, sizeof(FCEUGI)); + + FCEUGameInfo->soundchan = 0; + FCEUGameInfo->soundrate = 0; + FCEUGameInfo->name=0; + FCEUGameInfo->type=GIT_CART; + FCEUGameInfo->vidsys=GIV_USER; + FCEUGameInfo->input[0]=FCEUGameInfo->input[1]=-1; + FCEUGameInfo->inputfc=-1; + FCEUGameInfo->cspecial=0; + + FCEU_printf("Loading %s...\n\n",name); + + GetFileBase(name); + + ipsfn=FCEU_MakeFName(FCEUMKF_IPS,0,0); + fp=FCEU_fopen(name,ipsfn,"rb",0); + free(ipsfn); + + if(!fp) + { + FCEU_PrintError("Error opening \"%s\"!",name); + return 0; + } + + if(iNESLoad(name,fp)) + goto endlseq; + if(NSFLoad(fp)) + goto endlseq; + if(UNIFLoad(name,fp)) + goto endlseq; + if(FDSLoad(name,fp)) + goto endlseq; + + FCEU_PrintError("An error occurred while loading the file."); + FCEU_fclose(fp); + return 0; + + endlseq: + FCEU_fclose(fp); + + FCEU_ResetVidSys(); + if(FCEUGameInfo->type!=GIT_NSF) + if(FSettings.GameGenie) + OpenGenie(); + + PowerNES(); + FCEUSS_CheckStates(); + FCEUMOV_CheckMovies(); + + if(FCEUGameInfo->type!=GIT_NSF) + { + FCEU_LoadGamePalette(); + FCEU_LoadGameCheats(0); + } + + FCEU_ResetPalette(); + FCEU_ResetMessages(); // Save state, status messages, etc. + + return(FCEUGameInfo); +} + + +int FCEUI_Initialize(void) +{ + if(!FCEU_InitVirtualVideo()) + return 0; + memset(&FSettings,0,sizeof(FSettings)); + FSettings.UsrFirstSLine[0]=8; + FSettings.UsrFirstSLine[1]=0; + FSettings.UsrLastSLine[0]=231; + FSettings.UsrLastSLine[1]=239; + FSettings.SoundVolume=100; + FCEUPPU_Init(); + X6502_Init(); + return 1; +} + +void FCEUI_Kill(void) +{ + FCEU_KillVirtualVideo(); + FCEU_KillGenie(); +} + +void FCEUI_Emulate(uint8 **pXBuf, int32 **SoundBuf, int32 *SoundBufSize, int skip) +{ + int r,ssize; + + FCEU_UpdateInput(); + if(geniestage!=1) FCEU_ApplyPeriodicCheats(); + r=FCEUPPU_Loop(skip); + + ssize=FlushEmulateSound(); + + timestampbase += timestamp; + + timestamp = 0; + + *pXBuf=skip?0:XBuf; + *SoundBuf=WaveFinal; + *SoundBufSize=ssize; +} + +void FCEUI_CloseGame(void) +{ + CloseGame(); +} + +void ResetNES(void) +{ + FCEUMOV_AddCommand(FCEUNPCMD_RESET); + if(!FCEUGameInfo) return; + GameInterface(GI_RESETM2); + FCEUSND_Reset(); + FCEUPPU_Reset(); + X6502_Reset(); +} + +void FCEU_MemoryRand(uint8 *ptr, uint32 size) +{ + int x=0; + while(size) + { + *ptr=(x&4)?0xFF:0x00; + x++; + size--; + ptr++; + } +} + +void hand(X6502 *X, int type, unsigned int A) +{ + +} + +void PowerNES(void) +{ + FCEUMOV_AddCommand(FCEUNPCMD_POWER); + if(!FCEUGameInfo) return; + + FCEU_CheatResetRAM(); + FCEU_CheatAddRAM(2,0,RAM); + + GeniePower(); + + FCEU_MemoryRand(RAM,0x800); + //memset(RAM,0xFF,0x800); + + SetReadHandler(0x0000,0xFFFF,ANull); + SetWriteHandler(0x0000,0xFFFF,BNull); + + SetReadHandler(0,0x7FF,ARAML); + SetWriteHandler(0,0x7FF,BRAML); + + SetReadHandler(0x800,0x1FFF,ARAMH); /* Part of a little */ + SetWriteHandler(0x800,0x1FFF,BRAMH); /* hack for a small speed boost. */ + + InitializeInput(); + FCEUSND_Power(); + FCEUPPU_Power(); + + /* Have the external game hardware "powered" after the internal NES stuff. + Needed for the NSF code and VS System code. + */ + GameInterface(GI_POWER); + if(FCEUGameInfo->type==GIT_VSUNI) + FCEU_VSUniPower(); + + + timestampbase=0; + X6502_Power(); + FCEU_PowerCheats(); +} + +void FCEU_ResetVidSys(void) +{ + int w; + + if(FCEUGameInfo->vidsys==GIV_NTSC) + w=0; + else if(FCEUGameInfo->vidsys==GIV_PAL) + w=1; + else + w=FSettings.PAL; + + PAL=w?1:0; + FCEUPPU_SetVideoSystem(w); + SetSoundVariables(); +} + +FCEUS FSettings; + +void FCEU_printf(char *format, ...) +{ + char temp[2048]; + + va_list ap; + + va_start(ap,format); + vsprintf(temp,format,ap); + FCEUD_Message(temp); + + va_end(ap); +} + +void FCEU_PrintError(char *format, ...) +{ + char temp[2048]; + + va_list ap; + + va_start(ap,format); + vsprintf(temp,format,ap); + FCEUD_PrintError(temp); + + va_end(ap); +} + +void FCEUI_SetRenderedLines(int ntscf, int ntscl, int palf, int pall) +{ + FSettings.UsrFirstSLine[0]=ntscf; + FSettings.UsrLastSLine[0]=ntscl; + FSettings.UsrFirstSLine[1]=palf; + FSettings.UsrLastSLine[1]=pall; + if(PAL) + { + FSettings.FirstSLine=FSettings.UsrFirstSLine[1]; + FSettings.LastSLine=FSettings.UsrLastSLine[1]; + } + else + { + FSettings.FirstSLine=FSettings.UsrFirstSLine[0]; + FSettings.LastSLine=FSettings.UsrLastSLine[0]; + } + +} + +void FCEUI_SetVidSystem(int a) +{ + FSettings.PAL=a?1:0; + if(FCEUGameInfo) + { + FCEU_ResetVidSys(); + FCEU_ResetPalette(); + } +} + +int FCEUI_GetCurrentVidSystem(int *slstart, int *slend) +{ + if(slstart) + *slstart=FSettings.FirstSLine; + if(slend) + *slend=FSettings.LastSLine; + return(PAL); +} + +void FCEUI_SetGameGenie(int a) +{ + FSettings.GameGenie=a?1:0; +} + +void FCEUI_SetSnapName(int a) +{ + FSettings.SnapName=a; +} + +int32 FCEUI_GetDesiredFPS(void) +{ + if(PAL) + return(838977920); // ~50.007 + else + return(1008307711); // ~60.1 +} diff --git a/source/fceultra/file.c b/source/fceultra/file.c index 5818ae6..0c0af95 100644 --- a/source/fceultra/file.c +++ b/source/fceultra/file.c @@ -286,10 +286,8 @@ FCEUFILE * FCEU_fopen(const char *path, const char *ipsfn, char *mode, char *ext else /* Probably gzip */ { int fd; - - /*** REMOVED GCV1.0 + fd = dup(fileno( (FILE *)t)); - REMOVED GCV1.0 ***/ fclose(t); diff --git a/source/fceultra/filter.c b/source/fceultra/filter.c index 1d23e57..2c96b37 100644 --- a/source/fceultra/filter.c +++ b/source/fceultra/filter.c @@ -58,9 +58,8 @@ void SexyFilter(int32 *in, int32 *out, int32 count) int64 ino=(int64)*in*vmul; acc1+=((ino-acc1)*mul1)>>16; acc2+=((ino-acc1-acc2)*mul2)>>16; - //printf("%d ",*in); *in=0; - { + { int32 t=(acc1-ino+acc2)>>16; //if(t>32767 || t<-32768) printf("Flow: %d\n",t); if(t>32767) t=32767; @@ -128,12 +127,13 @@ int32 NeoFilterSound(int32 *in, int32 *out, uint32 inlen, int32 *leftover) 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++; } + mrindex=x-max; if(FSettings.soundq==2) diff --git a/source/fceultra/general.c b/source/fceultra/general.c index 06d01b2..30ca49d 100644 --- a/source/fceultra/general.c +++ b/source/fceultra/general.c @@ -83,8 +83,8 @@ static int asprintf(char **strp, const char *fmt, ...) char *FCEU_MakeFName(int type, int id1, char *cd1) { char *ret=0; - -/*** REMOVED GC V1.0 + +#ifndef NGC struct stat tmpstat; switch(type) @@ -164,8 +164,7 @@ char *FCEU_MakeFName(int type, int id1, char *cd1) asprintf(&ret,"%s"PSS"gameinfo"PSS"%s.pal",BaseDirectory,FileBase); break; } - - REMOVED GC V1.0 ***/ +#endif return(ret); } diff --git a/source/fceultra/ines-bad.h b/source/fceultra/ines-bad.h new file mode 100644 index 0000000..b734514 --- /dev/null +++ b/source/fceultra/ines-bad.h @@ -0,0 +1,37 @@ +{ 0xecf78d8a13a030a6LL, "Ai Sensei no Oshiete", INESB_HACKED }, +{ 0x10f90ba5bd55c22eLL, "Alien Syndrome", INESB_HACKED }, +{ 0x4712856d3e12f21fLL, "Akumajou Densetsu", INESB_HACKED }, +{ 0x0d69ab3ad28ad1c2LL, "Banana", INESB_INCOMPLETE }, +{ 0x85d2c348a161cdbfLL, "Bio Senshi Dan", INESB_HACKED }, +{ 0x18fdb7c16aa8cb5cLL, "Bucky O'Hare", INESB_CORRUPT }, +{ 0xe27c48302108d11bLL, "Chibi Maruko Chan", INESB_HACKED }, +{ 0x9d1f505c6ba507bfLL, "Contra", INESB_HACKED }, +{ 0x60936436d3ea0ab6LL, "Crisis Force", INESB_HACKED }, +{ 0xcf31097ddbb03c5dLL, "Crystalis (Prototype)", INESB_CORRUPT }, +{ 0x92080a8ce94200eaLL, "Digital Devil Story II", INESB_HACKED }, +{ 0x97f133d8bc1c28dbLL, "Dragon Ball", INESB_HACKED }, +{ 0x6c2a2f95c2fe4b6eLL, "Dragon Ball", INESB_HACKED }, +{ 0x767aaff62963c58fLL, "Dragon Ball", INESB_HACKED }, +{ 0x500b267abb323005LL, "Dragon Warrior 4", INESB_CORRUPT }, +{ 0x02bdcf375704784bLL, "Erika to Satoru no Yume Bouken", INESB_HACKED }, +{ 0xd4fea9d2633b9186LL, "Famista 91", INESB_HACKED }, +{ 0xfdf8c812839b61f0LL, "Famista 92", INESB_HACKED }, +{ 0xb5bb1d0fb47d0850LL, "Famista 93", INESB_HACKED }, +{ 0x30471e773f7cdc89LL, "Famista 94", INESB_HACKED }, +{ 0x76c5c44ffb4a0bd7LL, "Fantasy Zone", INESB_HACKED }, +{ 0x27da2b0c500dc346LL, "Fire Emblem", INESB_HACKED }, +{ 0xb470bfb90e2b1049LL, "Fire Emblem Gaiden", INESB_HACKED }, +{ 0x23214fe456fba2ceLL, "Ganbare Goemon 2", INESB_HACKED }, +{ 0xbf8b22524e8329d9LL, "Ganbare Goemon Gaiden", INESB_HACKED }, +{ 0xa97041c3da0134e3LL, "Gegege no Kitarou 2", INESB_INCOMPLETE }, +{ 0x805db49a86db5449LL, "Goonies", INESB_HACKED }, +{ 0xc5abdaa65ac49b6bLL, "Gradius 2", INESB_HACKED }, +{ 0x04afae4ad480c11cLL, "Gradius 2", INESB_HACKED }, +{ 0x9b4bad37b5498992LL, "Gradius 2", INESB_HACKED }, +{ 0xb068d4ac10ef848eLL, "Highway Star", INESB_HACKED }, +{ 0xbf5175271e5019c3LL, "Kaiketsu Yanchamaru 3", INESB_HACKED }, +{ 0xfb4b508a236bbba3LL, "Salamander", INESB_HACKED }, +{ 0x3716c4bebf885344LL, "Super Mario Bros.", INESB_HACKED }, +{ 0x1895afc6eef26c7dLL, "Super Mario Bros.", INESB_HACKED }, +{ 0x103fc85d978b861bLL, "Sweet Home", INESB_CORRUPT }, +{ 0xfffda4407d80885aLL, "Sweet Home", INESB_CORRUPT }, diff --git a/source/fceultra/ines-correct.h b/source/fceultra/ines-correct.h new file mode 100644 index 0000000..c5b3439 --- /dev/null +++ b/source/fceultra/ines-correct.h @@ -0,0 +1,191 @@ +{0x9cbadc25,5,8}, /* JustBreed */ + +{0x6e68e31a,16,8}, /* Dragon Ball 3*/ +{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 */ + +{0x60bfeb0c,90,-1}, /* MK 2*/ +{0x0c47946d,210,-1}, /* Chibi Maruko Chan */ +{0xbd523011,210,-1}, /* Dream Master */ +{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,158,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,66,1}, /* Youkai Club*/ +{0xc2df0a00,66,1}, /* Bio Senshi Dan(hacked) */ +{0xbde3ae9b,66,1}, /* Doraemon */ +{0xd26efd78,66,1}, /* SMB Duck Hunt */ +{0x811f06d9,66,1}, /* Dragon Power */ +{0x3293afea,66,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) */ + {0,-1,-1} diff --git a/source/fceultra/ines.c b/source/fceultra/ines.c index b627ae5..9ec215a 100644 --- a/source/fceultra/ines.c +++ b/source/fceultra/ines.c @@ -1,7 +1,7 @@ /* FCE Ultra - NES/Famicom Emulator * * Copyright notice for this file: - * Copyright (C) 1998 BERO + * Copyright (C) 1998 BERO * Copyright (C) 2002 Xodnizel * * This program is free software; you can redistribute it and/or modify @@ -62,11 +62,11 @@ static int NewiNES_Init(int num); void (*MapClose)(void); void (*MapperReset)(void); -int MapperNo = 0; +int MapperNo; iNES_HEADER head; -/* MapperReset() is called when the NES is reset(with the reset button). +/* MapperReset() is called when the NES is reset(with the reset button). Mapperxxx_init is called when the NES has been powered on. */ @@ -104,7 +104,7 @@ static void iNESGI(int h) break; case GI_CLOSE: { - //FCEU_SaveGameSave(&iNESCart); + FCEU_SaveGameSave(&iNESCart); if(iNESCart.Close) iNESCart.Close(); if(ROM) {free(ROM);ROM=0;} @@ -143,7 +143,7 @@ static void SetInput(void) {0xaf4010ea,SI_GAMEPAD,SI_POWERPADB,-1}, /* World Class Track Meet */ {0xd74b2719,SI_GAMEPAD,SI_POWERPADB,-1}, /* Super Team Games */ {0x61d86167,SI_GAMEPAD,SI_POWERPADB,-1}, /* Street Cop */ - // Bad dump? {0x23040fc4,SI_GAMEPAD,SI_POWERPADB,-1}, /* Short Order/Eggsplode */ + {0x6435c095,SI_GAMEPAD,SI_POWERPADB,-1}, /* Short Order/Eggsplode */ {0x47232739,SI_GAMEPAD,SI_GAMEPAD,SIFC_TOPRIDER}, /* Top Rider */ @@ -179,6 +179,8 @@ static void SetInput(void) {0xbeb8ab01,-1,SI_ZAPPER,0}, /* Gumshoe */ {0xde8fd935,-1,SI_ZAPPER,0}, /* To the Earth */ {0xedc3662b,-1,SI_ZAPPER,0}, /* Operation Wolf */ + {0x2a6559a1,-1,SI_ZAPPER,0}, /* Operation Wolf (J) */ + {0x23d17f5e,SI_GAMEPAD,SI_ZAPPER,0}, /* The Lone Ranger */ {0xb8b9aca3,-1,SI_ZAPPER,0}, /* Wild Gunman */ {0x5112dc21,-1,SI_ZAPPER,0}, /* Wild Gunman */ @@ -191,6 +193,7 @@ static void SetInput(void) {0xd89e5a67,-1,-1,SIFC_ARKANOID}, /* Arkanoid (J) */ {0x0f141525,-1,-1,SIFC_ARKANOID}, /* Arkanoid 2(J) */ + {0x912989dc,-1,-1,SIFC_FKB}, /* Playbox BASIC */ {0xf7606810,-1,-1,SIFC_FKB}, /* Family BASIC 2.0A */ {0x895037bc,-1,-1,SIFC_FKB}, /* Family BASIC 2.1a */ {0xb2530afc,-1,-1,SIFC_FKB}, /* Family BASIC 3.0 */ @@ -211,8 +214,43 @@ static void SetInput(void) } } +#define INESB_INCOMPLETE 1 +#define INESB_CORRUPT 2 +#define INESB_HACKED 4 + +struct BADINF { + uint64 md5partial; + char *name; + uint32 type; +}; + + +static struct BADINF BadROMImages[]= +{ + #include "ines-bad.h" +}; + +void CheckBad(uint64 md5partial) +{ + int x; + + x=0; + //printf("0x%llx\n",md5partial); + while(BadROMImages[x].name) + { + if(BadROMImages[x].md5partial == md5partial) + { + FCEU_PrintError("The copy game you have loaded, \"%s\", is bad, and will not work properly on FCE Ultra.", BadROMImages[x].name); + return; + } + x++; + } + +} + + struct CHINF { - uint32 crc32; + uint32 crc32; int32 mapper; int32 mirror; }; @@ -230,7 +268,7 @@ static void CheckHInfo(void) { 0x498c10dc463cfe95LL, /* Battle Fleet */ 0x6917ffcaca2d8466LL, /* Famista '90 */ - + 0xd63dcc68c2b20adcLL, /* Final Fantasy J */ 0x012df596e2b31174LL, /* Final Fantasy 1+2 */ 0xf6b359a720549ecdLL, /* Final Fantasy 2 */ @@ -268,7 +306,7 @@ static void CheckHInfo(void) 0x94b9484862a26cbaLL, /* Legend of Zelda */ 0x04a31647de80fdabLL, /* "" */ - + 0x9aa1dc16c05e7de5LL, /* Startropics */ 0x1b084107d0878bd0LL, /* Startropics 2*/ @@ -278,182 +316,9 @@ static void CheckHInfo(void) }; static struct CHINF moo[]= - { - {0x9cbadc25,5,8}, /* JustBreed */ - -// {0x5f6e8a07,66,0}, - {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 */ - - {0x60bfeb0c,90,-1}, /* MK 2*/ - - {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,-1}, /* Dream Master */ - {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. */ - {0x40c0ad47,48,8}, /* Flintstones 2 */ - {0xa7b0536c,48,8}, /* Don Doko Don 2 */ - {0x99c395f9,48,8}, /* Captain Saver */ - - {0x637134e8,193,1}, /* Fighting Hero */ - {0xcbf4366f,158,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 */ - {0x9ea1dc76,2,0}, /* Rainbow Islands */ - - {0x9eefb4b4,4,8}, /* Pachi Slot Adventure 2 */ - {0x5337f73c,4,8}, /* Niji no Silk Road */ - {0x7474ac92,4,8}, /* Kabuki: Quantum Fighter */ - - {0x970bd9c2,1,8}, /* Hanjuku Hero */ - - {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) */ - - {0xfcdaca80,0,0}, /* Elevator Action */ - {0xe492d45a,0,0}, /* Zippy Race */ - {0x32fa246f,0,0}, /* Tag Team Pro Wrestling */ - {0x6d65cac6,2,0}, /* Terra Cresta */ - {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 */ - - {0x291bcd7d,1,8}, /* Pachio Kun 2 */ - {0xf74dfc91,1,-1}, /* Win, Lose, or Draw */ - - {0x59280bec,4,8}, /* Jackie Chan */ - - {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 */ - - {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,66,1}, /* Youkai Club*/ - {0xc2df0a00,66,1}, /* Bio Senshi Dan(hacked) */ - {0xbde3ae9b,66,1}, /* Doraemon */ - {0xd26efd78,66,1}, /* SMB Duck Hunt */ - {0x811f06d9,66,1}, /* Dragon Power */ - - {0x3293afea,66,1}, /* Mississippi Satsujin Jiken */ - {0xe84274c5,66,1}, /* "" "" */ - - {0x9552e8df,66,1}, /* Dragon Ball */ - - {0x6e68e31a,16,8}, /* Dragon Ball 3*/ - - {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 */ - - {0x3f15d20d,153,8}, /* Famicom Jump 2 */ - - {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) */ - {0,-1,-1} - }; + { + #include "ines-correct.h" + }; int tofix=0; int x; uint64 partialmd5=0; @@ -463,6 +328,7 @@ static void CheckHInfo(void) partialmd5 |= (uint64)iNESCart.MD5[15-x] << (x*8); //printf("%16llx\n",partialmd5); } + CheckBad(partialmd5); x=0; @@ -536,7 +402,7 @@ static void CheckHInfo(void) /* Four-screen mirroring implicitly set. */ if(MapperNo==99) - Mirroring=2; + Mirroring=2; if(tofix) { @@ -550,7 +416,7 @@ static void CheckHInfo(void) sprintf(gigastr+strlen(gigastr),"Mirroring should be set to \"%s\". ",mstr[Mirroring&3]); } if(tofix&4) - strcat(gigastr,"The battery-backed bit should be set. "); + strcat(gigastr,"The battery-backed bit should be set. "); if(tofix&8) strcat(gigastr,"This game should not have any CHR ROM. "); strcat(gigastr,"\n"); @@ -614,8 +480,8 @@ int iNESLoad(const char *name, FCEUFILE *fp) if(!(ROM=(uint8 *)FCEU_malloc(ROM_size<<14))) return 0; - - if (VROM_size) + + if (VROM_size) if(!(VROM=(uint8 *)FCEU_malloc(VROM_size<<13))) { free(ROM); @@ -641,7 +507,7 @@ int iNESLoad(const char *name, FCEUFILE *fp) if(VROM_size) FCEU_fread(VROM,0x2000,head.VROM_size,fp); - md5_starts(&md5); + md5_starts(&md5); md5_update(&md5,ROM,ROM_size<<14); iNESGameCRC32=CalcCRC32(0,ROM,ROM_size<<14); @@ -662,7 +528,7 @@ int iNESLoad(const char *name, FCEUFILE *fp) { int x; FCEU_printf(" ROM MD5: 0x"); - for(x=0;x<16;x++) + for(x=0;x<16;x++) FCEU_printf("%02x",iNESCart.MD5[x]); FCEU_printf("\n"); } @@ -679,7 +545,7 @@ int iNESLoad(const char *name, FCEUFILE *fp) for(x=0;x<8;x++) { partialmd5 |= (uint64)iNESCart.MD5[7-x] << (x*8); - } + } FCEU_VSUniCheck(partialmd5, &MapperNo, &Mirroring); } @@ -695,7 +561,7 @@ int iNESLoad(const char *name, FCEUFILE *fp) SetupCartMirroring(2+(Mirroring&1),1,0); else SetupCartMirroring(Mirroring&1,(Mirroring&4)>>2,0); - + iNESCart.battery=(head.ROM_type&2)?1:0; iNESCart.mirror=Mirroring; @@ -733,7 +599,7 @@ void FASTAPASS(2) VRAM_BANK1(uint32 A, uint8 V) CHRBankList[(A)>>10]=V; VPage[(A)>>10]=&CHRRAM[V<<10]-(A); } - + void FASTAPASS(2) VRAM_BANK4(uint32 A, uint32 V) { V&=1; @@ -749,7 +615,7 @@ void FASTAPASS(2) VROM_BANK1(uint32 A,uint32 V) setchr1(A,V); CHRBankList[(A)>>10]=V; } - + void FASTAPASS(2) VROM_BANK2(uint32 A,uint32 V) { setchr2(A,V); @@ -785,16 +651,16 @@ void FASTAPASS(2) ROM_BANK8(uint32 A, uint32 V) if(A>=0x8000) PRGBankList[((A-0x8000)>>13)]=V; } - + void FASTAPASS(2) ROM_BANK16(uint32 A, uint32 V) { setprg16(A,V); - if(A>=0x8000) + if(A>=0x8000) { PRGBankList[((A-0x8000)>>13)]=V<<1; PRGBankList[((A-0x8000)>>13)+1]=(V<<1)+1; } -} +} void FASTAPASS(1) ROM_BANK32(uint32 V) { @@ -834,7 +700,7 @@ static void NONE_init(void) ROM_BANK16(0x8000,0); ROM_BANK16(0xC000,~0); - if(VROM_size) + if(VROM_size) VROM_BANK8(0); else setvram8(CHRRAM); @@ -845,8 +711,8 @@ void (*MapInitTab[256])(void)= 0, 0,Mapper2_init,Mapper3_init,0, 0,Mapper6_init,Mapper7_init,Mapper8_init, - Mapper9_init,Mapper10_init,0,0, - Mapper13_init,0,0,Mapper16_init, + Mapper9_init,Mapper10_init,Mapper11_init,0, + Mapper13_init,0,Mapper15_init,Mapper16_init, Mapper17_init,Mapper18_init,0,0, Mapper21_init,Mapper22_init,Mapper23_init,Mapper24_init, Mapper25_init,Mapper26_init,0,0, @@ -857,33 +723,33 @@ void (*MapInitTab[256])(void)= 0,Mapper46_init,0,Mapper48_init,0,Mapper50_init,Mapper51_init,0, 0,0,0,0,Mapper57_init,Mapper58_init,Mapper59_init,Mapper60_init, Mapper61_init,Mapper62_init,0,Mapper64_init, - Mapper65_init,Mapper66_init,Mapper67_init,0, - Mapper69_init,0,Mapper71_init,Mapper72_init, + Mapper65_init,Mapper66_init,Mapper67_init,Mapper68_init, + Mapper69_init,Mapper70_init,Mapper71_init,Mapper72_init, Mapper73_init,0,Mapper75_init,Mapper76_init, - Mapper77_init,0,Mapper79_init,Mapper80_init, + Mapper77_init,Mapper78_init,Mapper79_init,Mapper80_init, 0,Mapper82_init,Mapper83_init,0, - Mapper85_init,Mapper86_init,0,Mapper88_init, + Mapper85_init,Mapper86_init,Mapper87_init,Mapper88_init, Mapper89_init,0,Mapper91_init,Mapper92_init, - Mapper93_init,0,0,Mapper96_init, + Mapper93_init,Mapper94_init,0,Mapper96_init, Mapper97_init,0,Mapper99_init,0, - 0,0,0,0,0,0,0,0, - 0,0,0,Mapper112_init,0,0,0,0, - 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,Mapper107_init,0, + 0,0,0,Mapper112_init,Mapper113_init,Mapper114_init,0,0, + Mapper117_init,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,Mapper140_init, - 0,0,0,0,0,0,0,0, - 0,0,Mapper151_init,0,Mapper153_init,Mapper154_init,0,Mapper156_init, + 0,0,0,Mapper144_init,0,0,0,0, + 0,0,Mapper151_init,Mapper152_init,Mapper153_init,Mapper154_init,0,Mapper156_init, Mapper157_init,Mapper158_init,Mapper159_init,0,0,0,0,0, 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,Mapper185_init,0,0,0, + 0,0,0,0,0,0,0,Mapper180_init, + 0,Mapper182_init,0,Mapper184_init,Mapper185_init,0,0,0, Mapper189_init,0,0,0,Mapper193_init,0,0,0, 0,0,0,Mapper200_init,Mapper201_init,Mapper202_init,Mapper203_init,0, 0,0,Mapper207_init,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,Mapper225_init,Mapper226_init,Mapper227_init,Mapper228_init, Mapper229_init,Mapper230_init,Mapper231_init,Mapper232_init,0,Mapper234_init,Mapper235_init,0, - 0,0,0,0,Mapper241_init,0,0,Mapper244_init, + 0,0,0,Mapper240_init,Mapper241_init,Mapper242_init,0,Mapper244_init, 0,Mapper246_init,0,Mapper248_init,0,0,0,0,0,0,Mapper255_init }; @@ -901,14 +767,14 @@ void (*MapStateRestore)(int version); void iNESStateRestore(int version) { int x; - + if(!MapperNo) return; for(x=0;x<4;x++) setprg8(0x8000+x*8192,PRGBankList[x]); if(VROM_size) - for(x=0;x<8;x++) + for(x=0;x<8;x++) setchr1(0x400*x,CHRBankList[x]); if(0) switch(Mirroring) @@ -963,7 +829,7 @@ static void iNESPower(void) if(head.ROM_type&8) AddExState(ExtraNTARAM, 2048, 0, "EXNR"); - /* Exclude some mappers whose emulation code handle save state stuff + /* Exclude some mappers whose emulation code handle save state stuff themselves. */ if(type && type!=13 && type!=96) { @@ -976,7 +842,7 @@ static void iNESPower(void) for(x=0;x<8;x++) { char tak[8]; - sprintf(tak,"CBL%d",x); + sprintf(tak,"CBL%d",x); AddExState(&CHRBankList[x], 2, 1,tak); } } @@ -990,7 +856,7 @@ static void iNESPower(void) typedef struct { - int number; + int number; void (*init)(CartInfo *); } BMAPPING; @@ -1013,63 +879,20 @@ static BMAPPING bmap[] = { {95, Mapper95_Init}, {105, Mapper105_Init}, - {115, Mapper115_Init}, - {116, Mapper116_Init}, + {115, Mapper115_Init}, + {116, Mapper116_Init}, {118, Mapper118_Init}, {119, Mapper119_Init}, /* Has CHR ROM and CHR RAM by default. Hmm. */ {155, Mapper155_Init}, {164, Mapper164_Init}, - {187, Mapper187_Init}, + {187, Mapper187_Init}, + {188, Mapper188_Init}, {206, Mapper206_Init}, - {208, Mapper208_Init}, + {208, Mapper208_Init}, {210, Mapper210_Init}, - {245, Mapper245_Init}, - {249, Mapper249_Init}, - {250, Mapper250_Init}, - //¦Û©wmmc3 - {205, Mapper205_Init}, - {215, Mapper215_Init}, - {254, Mapper254_Init}, - {198, Mapper198_Init}, - {217, Mapper217_Init}, - {195, Mapper195_Init}, - {194, Mapper194_Init}, - {192, Mapper192_Init}, - {191, Mapper191_Init}, - {182, Mapper182_Init}, - {165, Mapper165_Init}, - {114, Mapper114_Init}, - {37, Mapper37_Init}, - //simple - {78, Mapper78_Init}, - {70, Mapper70_Init}, - {152, Mapper152_Init}, - {87, Mapper87_Init}, - {11, Mapper11_Init}, - {144, Mapper144_Init}, - {94, Mapper94_Init}, - {180, Mapper180_Init}, - {107, Mapper107_Init}, - {113, Mapper107_Init}, - //199.c - {199, Mapper199_Init}, - {240, Mapper240_Init}, - //164.c - {164, Mapper164_Init}, - {163, Mapper163_Init}, - //15.c - {15, Mapper15_init}, - //subor.c //warning message - {166, Mapper166_init}, - {167, Mapper167_init}, - //27.c - {27, Mapper27_init}, - //242.c - {242, Mapper242_init}, - //252.c - {252, Mapper252_Init}, - - + {245, Mapper245_Init}, + {249, Mapper249_Init}, + {250, Mapper250_Init}, {0,0} }; @@ -1100,6 +923,7 @@ static int NewiNES_Init(int num) return(0); } + /**************************************************************************** ** GC V1.0 ** @@ -1255,4 +1079,3 @@ int iNESMemLoad(char *nesrom) GameInterface=iNESGI; return 1; } - diff --git a/source/fceultra/ines.h b/source/fceultra/ines.h index c7d23ee..dadc4ad 100644 --- a/source/fceultra/ines.h +++ b/source/fceultra/ines.h @@ -162,7 +162,7 @@ void Mapper64_init(void); void Mapper65_init(void); void Mapper66_init(void); void Mapper67_init(void); -//void Mapper68_init(void); +void Mapper68_init(void); void Mapper69_init(void); void Mapper70_init(void); void Mapper71_init(void); @@ -363,6 +363,7 @@ void Mapper74_Init(CartInfo *); void Mapper90_Init(CartInfo *); void Mapper165_Init(CartInfo *); void Mapper209_Init(CartInfo *); + void Mapper95_Init(CartInfo *); void Mapper105_Init(CartInfo *); void Mapper115_Init(CartInfo *); @@ -372,6 +373,7 @@ void Mapper119_Init(CartInfo *); void Mapper155_Init(CartInfo *); void Mapper164_Init(CartInfo *); void Mapper187_Init(CartInfo *); +void Mapper188_Init(CartInfo *); void Mapper206_Init(CartInfo *); void Mapper208_Init(CartInfo *); void Mapper209_Init(CartInfo *); @@ -379,41 +381,3 @@ void Mapper210_Init(CartInfo *); void Mapper245_Init(CartInfo *); void Mapper249_Init(CartInfo *); void Mapper250_Init(CartInfo *); -// -void Mapper205_Init(CartInfo *); -void Mapper215_Init(CartInfo *); -void Mapper254_Init(CartInfo *); -void Mapper78_Init(CartInfo *); -void Mapper184_Init(CartInfo *); -void Mapper70_Init(CartInfo *); -void Mapper152_Init(CartInfo *); -void Mapper87_Init(CartInfo *); -void Mapper11_Init(CartInfo *); -void Mapper144_Init(CartInfo *); -void Mapper94_Init(CartInfo *); -void Mapper180_Init(CartInfo *); -void Mapper107_Init(CartInfo *); -void Mapper113_Init(CartInfo *); -void Mapper199_Init(CartInfo *); -void Mapper198_Init(CartInfo *); -void Mapper217_Init(CartInfo *); -void Mapper195_Init(CartInfo *); -void Mapper194_Init(CartInfo *); -void Mapper192_Init(CartInfo *); -void Mapper191_Init(CartInfo *); -void Mapper182_Init(CartInfo *); -void Mapper165_Init(CartInfo *); -void Mapper114_Init(CartInfo *); -void Mapper37_Init(CartInfo *); - -void Mapper240_Init(CartInfo *); -void Mapper164_Init(CartInfo *); -void Mapper163_Init(CartInfo *); -void Mapper15_Init(CartInfo *); -void Mapper166_Init(CartInfo *); -void Mapper167_Init(CartInfo *); -void Mapper27_Init(CartInfo *); -void Mapper242_Init(CartInfo *); -void Mapper252_Init(CartInfo *); - - diff --git a/source/fceultra/linux/bits/wchar.h b/source/fceultra/linux/bits/wchar.h deleted file mode 100644 index 442a462..0000000 --- a/source/fceultra/linux/bits/wchar.h +++ /dev/null @@ -1,26 +0,0 @@ -/* wchar_t type related definitions. - Copyright (C) 2000 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#ifndef _BITS_WCHAR_H -#define _BITS_WCHAR_H 1 - -#define __WCHAR_MIN (-2147483647l - 1l) -#define __WCHAR_MAX (2147483647l) - -#endif /* bits/wchar.h */ diff --git a/source/fceultra/linux/bits/wordsize.h b/source/fceultra/linux/bits/wordsize.h deleted file mode 100644 index ba643b6..0000000 --- a/source/fceultra/linux/bits/wordsize.h +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright (C) 1999 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#define __WORDSIZE 32 diff --git a/source/fceultra/linux/features.h b/source/fceultra/linux/features.h deleted file mode 100644 index a191d80..0000000 --- a/source/fceultra/linux/features.h +++ /dev/null @@ -1,340 +0,0 @@ -/* Copyright (C) 1991-1993,1995-2003,2004,2005 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#ifndef _FEATURES_H -#define _FEATURES_H 1 - -/* These are defined by the user (or the compiler) - to specify the desired environment: - - __STRICT_ANSI__ ISO Standard C. - _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. - _POSIX_SOURCE IEEE Std 1003.1. - _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; - if >=199309L, add IEEE Std 1003.1b-1993; - if >=199506L, add IEEE Std 1003.1c-1995; - if >=200112L, all of IEEE 1003.1-2004 - _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if - Single Unix conformance is wanted, to 600 for the - upcoming sixth revision. - _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. - _LARGEFILE_SOURCE Some more functions for correct standard I/O. - _LARGEFILE64_SOURCE Additional functionality from LFS for large files. - _FILE_OFFSET_BITS=N Select default filesystem interface. - _BSD_SOURCE ISO C, POSIX, and 4.3BSD things. - _SVID_SOURCE ISO C, POSIX, and SVID things. - _GNU_SOURCE All of the above, plus GNU extensions. - _REENTRANT Select additionally reentrant object. - _THREAD_SAFE Same as _REENTRANT, often used by other systems. - _FORTIFY_SOURCE If set to numeric value > 0 additional security - measures are defined, according to level. - - The `-ansi' switch to the GNU C compiler defines __STRICT_ANSI__. - If none of these are defined, the default is to have _SVID_SOURCE, - _BSD_SOURCE, and _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to - 199506L. If more than one of these are defined, they accumulate. - For example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE - together give you ISO C, 1003.1, and 1003.2, but nothing else. - - These are defined by this file and are used by the - header files to decide what to declare or define: - - __USE_ISOC99 Define ISO C99 things. - __USE_POSIX Define IEEE Std 1003.1 things. - __USE_POSIX2 Define IEEE Std 1003.2 things. - __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. - __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. - __USE_XOPEN Define XPG things. - __USE_XOPEN_EXTENDED Define X/Open Unix things. - __USE_UNIX98 Define Single Unix V2 things. - __USE_XOPEN2K Define XPG6 things. - __USE_LARGEFILE Define correct standard I/O things. - __USE_LARGEFILE64 Define LFS things with separate names. - __USE_FILE_OFFSET64 Define 64bit interface as default. - __USE_BSD Define 4.3BSD things. - __USE_SVID Define SVID things. - __USE_MISC Define things common to BSD and System V Unix. - __USE_GNU Define GNU extensions. - __USE_REENTRANT Define reentrant/thread-safe *_r functions. - __USE_FORTIFY_LEVEL Additional security measures used, according to level. - __FAVOR_BSD Favor 4.3BSD things in cases of conflict. - - The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are - defined by this file unconditionally. `__GNU_LIBRARY__' is provided - only for compatibility. All new code should use the other symbols - to test for features. - - All macros listed above as possibly being defined by this file are - explicitly undefined if they are not explicitly defined. - Feature-test macros that are not defined by the user or compiler - but are implied by the other feature-test macros defined (or by the - lack of any definitions) are defined by the file. */ - - -/* Undefine everything, so we get a clean slate. */ -#undef __USE_ISOC99 -#undef __USE_POSIX -#undef __USE_POSIX2 -#undef __USE_POSIX199309 -#undef __USE_POSIX199506 -#undef __USE_XOPEN -#undef __USE_XOPEN_EXTENDED -#undef __USE_UNIX98 -#undef __USE_XOPEN2K -#undef __USE_LARGEFILE -#undef __USE_LARGEFILE64 -#undef __USE_FILE_OFFSET64 -#undef __USE_BSD -#undef __USE_SVID -#undef __USE_MISC -#undef __USE_GNU -#undef __USE_REENTRANT -#undef __USE_FORTIFY_LEVEL -#undef __FAVOR_BSD -#undef __KERNEL_STRICT_NAMES - -/* Suppress kernel-name space pollution unless user expressedly asks - for it. */ -#ifndef _LOOSE_KERNEL_NAMES -# define __KERNEL_STRICT_NAMES -#endif - -/* Always use ISO C things. */ -#define __USE_ANSI 1 - -/* Convenience macros to test the versions of glibc and gcc. - Use them like this: - #if __GNUC_PREREQ (2,8) - ... code requiring gcc 2.8 or later ... - #endif - Note - they won't work for gcc1 or glibc1, since the _MINOR macros - were not defined then. */ -#if defined __GNUC__ && defined __GNUC_MINOR__ -# define __GNUC_PREREQ(maj, min) \ - ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) -#else -# define __GNUC_PREREQ(maj, min) 0 -#endif - - -/* If _BSD_SOURCE was defined by the user, favor BSD over POSIX. */ -#if defined _BSD_SOURCE && \ - !(defined _POSIX_SOURCE || defined _POSIX_C_SOURCE || \ - defined _XOPEN_SOURCE || defined _XOPEN_SOURCE_EXTENDED || \ - defined _GNU_SOURCE || defined _SVID_SOURCE) -# define __FAVOR_BSD 1 -#endif - -/* If _GNU_SOURCE was defined by the user, turn on all the other features. */ -#ifdef _GNU_SOURCE -# undef _ISOC99_SOURCE -# define _ISOC99_SOURCE 1 -# undef _POSIX_SOURCE -# define _POSIX_SOURCE 1 -# undef _POSIX_C_SOURCE -# define _POSIX_C_SOURCE 199506L -# undef _XOPEN_SOURCE -# define _XOPEN_SOURCE 600 -# undef _XOPEN_SOURCE_EXTENDED -# define _XOPEN_SOURCE_EXTENDED 1 -# undef _LARGEFILE64_SOURCE -# define _LARGEFILE64_SOURCE 1 -# undef _BSD_SOURCE -# define _BSD_SOURCE 1 -# undef _SVID_SOURCE -# define _SVID_SOURCE 1 -#endif - -/* If nothing (other than _GNU_SOURCE) is defined, - define _BSD_SOURCE and _SVID_SOURCE. */ -#if (!defined __STRICT_ANSI__ && !defined _ISOC99_SOURCE && \ - !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE && \ - !defined _XOPEN_SOURCE && !defined _XOPEN_SOURCE_EXTENDED && \ - !defined _BSD_SOURCE && !defined _SVID_SOURCE) -# define _BSD_SOURCE 1 -# define _SVID_SOURCE 1 -#endif - -/* This is to enable the ISO C99 extension. Also recognize the old macro - which was used prior to the standard acceptance. This macro will - eventually go away and the features enabled by default once the ISO C99 - standard is widely adopted. */ -#if (defined _ISOC99_SOURCE || defined _ISOC9X_SOURCE \ - || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)) -# define __USE_ISOC99 1 -#endif - -/* If none of the ANSI/POSIX macros are defined, use POSIX.1 and POSIX.2 - (and IEEE Std 1003.1b-1993 unless _XOPEN_SOURCE is defined). */ -#if ((!defined __STRICT_ANSI__ || (_XOPEN_SOURCE - 0) >= 500) && \ - !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE) -# define _POSIX_SOURCE 1 -# if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 500 -# define _POSIX_C_SOURCE 2 -# else -# define _POSIX_C_SOURCE 199506L -# endif -#endif - -#if defined _POSIX_SOURCE || _POSIX_C_SOURCE >= 1 || defined _XOPEN_SOURCE -# define __USE_POSIX 1 -#endif - -#if defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 2 || defined _XOPEN_SOURCE -# define __USE_POSIX2 1 -#endif - -#if (_POSIX_C_SOURCE - 0) >= 199309L -# define __USE_POSIX199309 1 -#endif - -#if (_POSIX_C_SOURCE - 0) >= 199506L -# define __USE_POSIX199506 1 -#endif - -#if (_POSIX_C_SOURCE - 0) >= 200112L -# define __USE_XOPEN2K 1 -#endif - -#ifdef _XOPEN_SOURCE -# define __USE_XOPEN 1 -# if (_XOPEN_SOURCE - 0) >= 500 -# define __USE_XOPEN_EXTENDED 1 -# define __USE_UNIX98 1 -# undef _LARGEFILE_SOURCE -# define _LARGEFILE_SOURCE 1 -# if (_XOPEN_SOURCE - 0) >= 600 -# define __USE_XOPEN2K 1 -# undef __USE_ISOC99 -# define __USE_ISOC99 1 -# endif -# else -# ifdef _XOPEN_SOURCE_EXTENDED -# define __USE_XOPEN_EXTENDED 1 -# endif -# endif -#endif - -#ifdef _LARGEFILE_SOURCE -# define __USE_LARGEFILE 1 -#endif - -#ifdef _LARGEFILE64_SOURCE -# define __USE_LARGEFILE64 1 -#endif - -#if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64 -# define __USE_FILE_OFFSET64 1 -#endif - -#if defined _BSD_SOURCE || defined _SVID_SOURCE -# define __USE_MISC 1 -#endif - -#ifdef _BSD_SOURCE -# define __USE_BSD 1 -#endif - -#ifdef _SVID_SOURCE -# define __USE_SVID 1 -#endif - -#ifdef _GNU_SOURCE -# define __USE_GNU 1 -#endif - -#if defined _REENTRANT || defined _THREAD_SAFE -# define __USE_REENTRANT 1 -#endif - -#if _FORTIFY_SOURCE > 0 && __OPTIMIZE__ > 0 \ - && (__GNUC_PREREQ (4, 1) \ - || (defined __GNUC_RH_RELEASE__ && __GNUC_PREREQ (4, 0)) \ - || (defined __GNUC_RH_RELEASE__ && __GNUC_PREREQ (3, 4) \ - && __GNUC_MINOR__ == 4 \ - && (__GNUC_PATCHLEVEL__ > 2 \ - || (__GNUC_PATCHLEVEL__ == 2 && __GNUC_RH_RELEASE__ >= 8)))) -# if _FORTIFY_SOURCE == 1 -# define __USE_FORTIFY_LEVEL 1 -# elif _FORTIFY_SOURCE > 1 -# define __USE_FORTIFY_LEVEL 2 -# endif -#endif - -/* We do support the IEC 559 math functionality, real and complex. */ -#define __STDC_IEC_559__ 1 -#define __STDC_IEC_559_COMPLEX__ 1 - -/* wchar_t uses ISO 10646-1 (2nd ed., published 2000-09-15) / Unicode 3.1. */ -#define __STDC_ISO_10646__ 200009L - -/* This macro indicates that the installed library is the GNU C Library. - For historic reasons the value now is 6 and this will stay from now - on. The use of this variable is deprecated. Use __GLIBC__ and - __GLIBC_MINOR__ now (see below) when you want to test for a specific - GNU C library version and use the values in to get - the sonames of the shared libraries. */ -#undef __GNU_LIBRARY__ -#define __GNU_LIBRARY__ 6 - -/* Major and minor version number of the GNU C library package. Use - these macros to test for features in specific releases. */ -#define __GLIBC__ 2 -#define __GLIBC_MINOR__ 3 - -#define __GLIBC_PREREQ(maj, min) \ - ((__GLIBC__ << 16) + __GLIBC_MINOR__ >= ((maj) << 16) + (min)) - -/* Decide whether a compiler supports the long long datatypes. */ -#if defined __GNUC__ \ - || (defined __PGI && defined __i386__ ) \ - || (defined __INTEL_COMPILER && (defined __i386__ || defined __ia64__)) \ - || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L) -# define __GLIBC_HAVE_LONG_LONG 1 -#endif - -/* This is here only because every header file already includes this one. */ -#ifndef __ASSEMBLER__ -# ifndef _SYS_CDEFS_H -# include -# endif - -/* If we don't have __REDIRECT, prototypes will be missing if - __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. */ -# if defined __USE_FILE_OFFSET64 && !defined __REDIRECT -# define __USE_LARGEFILE 1 -# define __USE_LARGEFILE64 1 -# endif - -#endif /* !ASSEMBLER */ - -/* Decide whether we can define 'extern inline' functions in headers. */ -#if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \ - && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__ -# define __USE_EXTERN_INLINES 1 -#endif - - -/* This is here only because every header file already includes this one. - Get the definitions of all the appropriate `__stub_FUNCTION' symbols. - contains `#define __stub_FUNCTION' when FUNCTION is a stub - that will always return failure (and set errno to ENOSYS). */ -#include - - -#endif /* features.h */ diff --git a/source/fceultra/linux/gnu/stubs-32.h b/source/fceultra/linux/gnu/stubs-32.h deleted file mode 100644 index 1404dcd..0000000 --- a/source/fceultra/linux/gnu/stubs-32.h +++ /dev/null @@ -1,24 +0,0 @@ -/* This file is automatically generated. - It defines a symbol `__stub_FUNCTION' for each function - in the C library which is a stub, meaning it will fail - every time called, usually setting errno to ENOSYS. */ - -#ifdef _LIBC - #error Applications may not define the macro _LIBC -#endif - -#define __stub___kernel_cosl -#define __stub___kernel_sinl -#define __stub___kernel_tanl -#define __stub_chflags -#define __stub_fattach -#define __stub_fchflags -#define __stub_fdetach -#define __stub_gtty -#define __stub_lchmod -#define __stub_lutimes -#define __stub_revoke -#define __stub_setlogin -#define __stub_sigreturn -#define __stub_sstk -#define __stub_stty diff --git a/source/fceultra/linux/gnu/stubs.h b/source/fceultra/linux/gnu/stubs.h deleted file mode 100644 index fc086bd..0000000 --- a/source/fceultra/linux/gnu/stubs.h +++ /dev/null @@ -1,12 +0,0 @@ -/* This file selects the right generated file of `__stub_FUNCTION' macros - based on the architecture being compiled for. */ - -#include - -#if __WORDSIZE == 32 -# include -#elif __WORDSIZE == 64 -# include -#else -# error "unexpected value for __WORDSIZE macro" -#endif diff --git a/source/fceultra/linux/inttypes.h b/source/fceultra/linux/inttypes.h deleted file mode 100644 index 13abb14..0000000 --- a/source/fceultra/linux/inttypes.h +++ /dev/null @@ -1,461 +0,0 @@ -/* Copyright (C) 1997-2001, 2004 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -/* - * ISO C99: 7.8 Format conversion of integer types - */ - -#ifndef _INTTYPES_H -#define _INTTYPES_H 1 - -#include -/* Get the type definitions. */ -#include - -/* Get a definition for wchar_t. But we must not define wchar_t itself. */ -#ifndef ____gwchar_t_defined -# ifdef __cplusplus -# define __gwchar_t wchar_t -# elif defined __WCHAR_TYPE__ -typedef __WCHAR_TYPE__ __gwchar_t; -# else -# define __need_wchar_t -# include -typedef wchar_t __gwchar_t; -# endif -# define ____gwchar_t_defined 1 -#endif - - -/* The ISO C99 standard specifies that these macros must only be - defined if explicitly requested. */ -#if !defined __cplusplus || defined __STDC_FORMAT_MACROS - -# if __WORDSIZE == 64 -# define __PRI64_PREFIX "l" -# define __PRIPTR_PREFIX "l" -# else -# define __PRI64_PREFIX "ll" -# define __PRIPTR_PREFIX -# endif - -/* Macros for printing format specifiers. */ - -/* Decimal notation. */ -# define PRId8 "d" -# define PRId16 "d" -# define PRId32 "d" -# define PRId64 __PRI64_PREFIX "d" - -# define PRIdLEAST8 "d" -# define PRIdLEAST16 "d" -# define PRIdLEAST32 "d" -# define PRIdLEAST64 __PRI64_PREFIX "d" - -# define PRIdFAST8 "d" -# define PRIdFAST16 __PRIPTR_PREFIX "d" -# define PRIdFAST32 __PRIPTR_PREFIX "d" -# define PRIdFAST64 __PRI64_PREFIX "d" - - -# define PRIi8 "i" -# define PRIi16 "i" -# define PRIi32 "i" -# define PRIi64 __PRI64_PREFIX "i" - -# define PRIiLEAST8 "i" -# define PRIiLEAST16 "i" -# define PRIiLEAST32 "i" -# define PRIiLEAST64 __PRI64_PREFIX "i" - -# define PRIiFAST8 "i" -# define PRIiFAST16 __PRIPTR_PREFIX "i" -# define PRIiFAST32 __PRIPTR_PREFIX "i" -# define PRIiFAST64 __PRI64_PREFIX "i" - -/* Octal notation. */ -# define PRIo8 "o" -# define PRIo16 "o" -# define PRIo32 "o" -# define PRIo64 __PRI64_PREFIX "o" - -# define PRIoLEAST8 "o" -# define PRIoLEAST16 "o" -# define PRIoLEAST32 "o" -# define PRIoLEAST64 __PRI64_PREFIX "o" - -# define PRIoFAST8 "o" -# define PRIoFAST16 __PRIPTR_PREFIX "o" -# define PRIoFAST32 __PRIPTR_PREFIX "o" -# define PRIoFAST64 __PRI64_PREFIX "o" - -/* Unsigned integers. */ -# define PRIu8 "u" -# define PRIu16 "u" -# define PRIu32 "u" -# define PRIu64 __PRI64_PREFIX "u" - -# define PRIuLEAST8 "u" -# define PRIuLEAST16 "u" -# define PRIuLEAST32 "u" -# define PRIuLEAST64 __PRI64_PREFIX "u" - -# define PRIuFAST8 "u" -# define PRIuFAST16 __PRIPTR_PREFIX "u" -# define PRIuFAST32 __PRIPTR_PREFIX "u" -# define PRIuFAST64 __PRI64_PREFIX "u" - -/* lowercase hexadecimal notation. */ -# define PRIx8 "x" -# define PRIx16 "x" -# define PRIx32 "x" -# define PRIx64 __PRI64_PREFIX "x" - -# define PRIxLEAST8 "x" -# define PRIxLEAST16 "x" -# define PRIxLEAST32 "x" -# define PRIxLEAST64 __PRI64_PREFIX "x" - -# define PRIxFAST8 "x" -# define PRIxFAST16 __PRIPTR_PREFIX "x" -# define PRIxFAST32 __PRIPTR_PREFIX "x" -# define PRIxFAST64 __PRI64_PREFIX "x" - -/* UPPERCASE hexadecimal notation. */ -# define PRIX8 "X" -# define PRIX16 "X" -# define PRIX32 "X" -# define PRIX64 __PRI64_PREFIX "X" - -# define PRIXLEAST8 "X" -# define PRIXLEAST16 "X" -# define PRIXLEAST32 "X" -# define PRIXLEAST64 __PRI64_PREFIX "X" - -# define PRIXFAST8 "X" -# define PRIXFAST16 __PRIPTR_PREFIX "X" -# define PRIXFAST32 __PRIPTR_PREFIX "X" -# define PRIXFAST64 __PRI64_PREFIX "X" - - -/* Macros for printing `intmax_t' and `uintmax_t'. */ -# define PRIdMAX __PRI64_PREFIX "d" -# define PRIiMAX __PRI64_PREFIX "i" -# define PRIoMAX __PRI64_PREFIX "o" -# define PRIuMAX __PRI64_PREFIX "u" -# define PRIxMAX __PRI64_PREFIX "x" -# define PRIXMAX __PRI64_PREFIX "X" - - -/* Macros for printing `intptr_t' and `uintptr_t'. */ -# define PRIdPTR __PRIPTR_PREFIX "d" -# define PRIiPTR __PRIPTR_PREFIX "i" -# define PRIoPTR __PRIPTR_PREFIX "o" -# define PRIuPTR __PRIPTR_PREFIX "u" -# define PRIxPTR __PRIPTR_PREFIX "x" -# define PRIXPTR __PRIPTR_PREFIX "X" - - -/* Macros for scanning format specifiers. */ - -/* Signed decimal notation. */ -# define SCNd8 "hhd" -# define SCNd16 "hd" -# define SCNd32 "d" -# define SCNd64 __PRI64_PREFIX "d" - -# define SCNdLEAST8 "hhd" -# define SCNdLEAST16 "hd" -# define SCNdLEAST32 "d" -# define SCNdLEAST64 __PRI64_PREFIX "d" - -# define SCNdFAST8 "hhd" -# define SCNdFAST16 __PRIPTR_PREFIX "d" -# define SCNdFAST32 __PRIPTR_PREFIX "d" -# define SCNdFAST64 __PRI64_PREFIX "d" - -/* Signed decimal notation. */ -# define SCNi8 "hhi" -# define SCNi16 "hi" -# define SCNi32 "i" -# define SCNi64 __PRI64_PREFIX "i" - -# define SCNiLEAST8 "hhi" -# define SCNiLEAST16 "hi" -# define SCNiLEAST32 "i" -# define SCNiLEAST64 __PRI64_PREFIX "i" - -# define SCNiFAST8 "hhi" -# define SCNiFAST16 __PRIPTR_PREFIX "i" -# define SCNiFAST32 __PRIPTR_PREFIX "i" -# define SCNiFAST64 __PRI64_PREFIX "i" - -/* Unsigned decimal notation. */ -# define SCNu8 "hhu" -# define SCNu16 "hu" -# define SCNu32 "u" -# define SCNu64 __PRI64_PREFIX "u" - -# define SCNuLEAST8 "hhu" -# define SCNuLEAST16 "hu" -# define SCNuLEAST32 "u" -# define SCNuLEAST64 __PRI64_PREFIX "u" - -# define SCNuFAST8 "hhu" -# define SCNuFAST16 __PRIPTR_PREFIX "u" -# define SCNuFAST32 __PRIPTR_PREFIX "u" -# define SCNuFAST64 __PRI64_PREFIX "u" - -/* Octal notation. */ -# define SCNo8 "hho" -# define SCNo16 "ho" -# define SCNo32 "o" -# define SCNo64 __PRI64_PREFIX "o" - -# define SCNoLEAST8 "hho" -# define SCNoLEAST16 "ho" -# define SCNoLEAST32 "o" -# define SCNoLEAST64 __PRI64_PREFIX "o" - -# define SCNoFAST8 "hho" -# define SCNoFAST16 __PRIPTR_PREFIX "o" -# define SCNoFAST32 __PRIPTR_PREFIX "o" -# define SCNoFAST64 __PRI64_PREFIX "o" - -/* Hexadecimal notation. */ -# define SCNx8 "hhx" -# define SCNx16 "hx" -# define SCNx32 "x" -# define SCNx64 __PRI64_PREFIX "x" - -# define SCNxLEAST8 "hhx" -# define SCNxLEAST16 "hx" -# define SCNxLEAST32 "x" -# define SCNxLEAST64 __PRI64_PREFIX "x" - -# define SCNxFAST8 "hhx" -# define SCNxFAST16 __PRIPTR_PREFIX "x" -# define SCNxFAST32 __PRIPTR_PREFIX "x" -# define SCNxFAST64 __PRI64_PREFIX "x" - - -/* Macros for scanning `intmax_t' and `uintmax_t'. */ -# define SCNdMAX __PRI64_PREFIX "d" -# define SCNiMAX __PRI64_PREFIX "i" -# define SCNoMAX __PRI64_PREFIX "o" -# define SCNuMAX __PRI64_PREFIX "u" -# define SCNxMAX __PRI64_PREFIX "x" - -/* Macros for scaning `intptr_t' and `uintptr_t'. */ -# define SCNdPTR __PRIPTR_PREFIX "d" -# define SCNiPTR __PRIPTR_PREFIX "i" -# define SCNoPTR __PRIPTR_PREFIX "o" -# define SCNuPTR __PRIPTR_PREFIX "u" -# define SCNxPTR __PRIPTR_PREFIX "x" - -#endif /* C++ && format macros */ - - -__BEGIN_DECLS - -#if __WORDSIZE == 64 - -/* We have to define the `uintmax_t' type using `ldiv_t'. */ -typedef struct - { - long int quot; /* Quotient. */ - long int rem; /* Remainder. */ - } imaxdiv_t; - -#else - -/* We have to define the `uintmax_t' type using `lldiv_t'. */ -typedef struct - { - long long int quot; /* Quotient. */ - long long int rem; /* Remainder. */ - } imaxdiv_t; - -#endif - - -/* Compute absolute value of N. */ -extern intmax_t imaxabs (intmax_t __n) __THROW __attribute__ ((__const__)); - -/* Return the `imaxdiv_t' representation of the value of NUMER over DENOM. */ -extern imaxdiv_t imaxdiv (intmax_t __numer, intmax_t __denom) - __THROW __attribute__ ((__const__)); - -/* Like `strtol' but convert to `intmax_t'. */ -extern intmax_t strtoimax (__const char *__restrict __nptr, - char **__restrict __endptr, int __base) __THROW; - -/* Like `strtoul' but convert to `uintmax_t'. */ -extern uintmax_t strtoumax (__const char *__restrict __nptr, - char ** __restrict __endptr, int __base) __THROW; - -/* Like `wcstol' but convert to `intmax_t'. */ -extern intmax_t wcstoimax (__const __gwchar_t *__restrict __nptr, - __gwchar_t **__restrict __endptr, int __base) - __THROW; - -/* Like `wcstoul' but convert to `uintmax_t'. */ -extern uintmax_t wcstoumax (__const __gwchar_t *__restrict __nptr, - __gwchar_t ** __restrict __endptr, int __base) - __THROW; - -#ifdef __USE_EXTERN_INLINES - -# if __WORDSIZE == 64 - -/* Like `strtol' but convert to `intmax_t'. */ -# ifndef __strtol_internal_defined -extern long int __strtol_internal (__const char *__restrict __nptr, - char **__restrict __endptr, - int __base, int __group) __THROW; -# define __strtol_internal_defined 1 -# endif -extern __inline intmax_t -(strtoimax (__const char *__restrict nptr, char **__restrict endptr, - int base)) -{ - return __strtol_internal (nptr, endptr, base, 0); -} - -/* Like `strtoul' but convert to `uintmax_t'. */ -# ifndef __strtoul_internal_defined -extern unsigned long int __strtoul_internal (__const char * - __restrict __nptr, - char ** __restrict __endptr, - int __base, int __group) __THROW; -# define __strtoul_internal_defined 1 -# endif -extern __inline uintmax_t -(strtoumax (__const char *__restrict nptr, char **__restrict endptr, - int base)) -{ - return __strtoul_internal (nptr, endptr, base, 0); -} - -/* Like `wcstol' but convert to `intmax_t'. */ -# ifndef __wcstol_internal_defined -extern long int __wcstol_internal (__const __gwchar_t * __restrict __nptr, - __gwchar_t **__restrict __endptr, - int __base, int __group) __THROW; -# define __wcstol_internal_defined 1 -# endif -extern __inline intmax_t -(wcstoimax (__const __gwchar_t *__restrict nptr, - __gwchar_t **__restrict endptr, int base)) -{ - return __wcstol_internal (nptr, endptr, base, 0); -} - - -/* Like `wcstoul' but convert to `uintmax_t'. */ -# ifndef __wcstoul_internal_defined -extern unsigned long int __wcstoul_internal (__const __gwchar_t * - __restrict __nptr, - __gwchar_t ** - __restrict __endptr, - int __base, int __group) __THROW; -# define __wcstoul_internal_defined 1 -# endif -extern __inline uintmax_t -(wcstoumax (__const __gwchar_t *__restrict nptr, - __gwchar_t **__restrict endptr, int base)) -{ - return __wcstoul_internal (nptr, endptr, base, 0); -} - -# else /* __WORDSIZE == 32 */ - -/* Like `strtol' but convert to `intmax_t'. */ -# ifndef __strtoll_internal_defined -__extension__ -extern long long int __strtoll_internal (__const char *__restrict __nptr, - char **__restrict __endptr, - int __base, int __group) __THROW; -# define __strtoll_internal_defined 1 -# endif -extern __inline intmax_t -(strtoimax (__const char *__restrict nptr, char **__restrict endptr, - int base)) -{ - return __strtoll_internal (nptr, endptr, base, 0); -} - -/* Like `strtoul' but convert to `uintmax_t'. */ -# ifndef __strtoull_internal_defined -__extension__ -extern unsigned long long int __strtoull_internal (__const char * - __restrict __nptr, - char ** - __restrict __endptr, - int __base, - int __group) __THROW; -# define __strtoull_internal_defined 1 -# endif -extern __inline uintmax_t -(strtoumax (__const char *__restrict nptr, char **__restrict endptr, - int base)) -{ - return __strtoull_internal (nptr, endptr, base, 0); -} - -/* Like `wcstol' but convert to `intmax_t'. */ -# ifndef __wcstoll_internal_defined -__extension__ -extern long long int __wcstoll_internal (__const __gwchar_t * - __restrict __nptr, - __gwchar_t **__restrict __endptr, - int __base, int __group) __THROW; -# define __wcstoll_internal_defined 1 -# endif -extern __inline intmax_t -(wcstoimax (__const __gwchar_t *__restrict nptr, - __gwchar_t **__restrict endptr, int base)) -{ - return __wcstoll_internal (nptr, endptr, base, 0); -} - - -/* Like `wcstoul' but convert to `uintmax_t'. */ -# ifndef __wcstoull_internal_defined -__extension__ -extern unsigned long long int __wcstoull_internal (__const __gwchar_t * - __restrict __nptr, - __gwchar_t ** - __restrict __endptr, - int __base, - int __group) __THROW; -# define __wcstoull_internal_defined 1 -# endif -extern __inline uintmax_t -(wcstoumax (__const __gwchar_t *__restrict nptr, - __gwchar_t **__restrict endptr, int base)) -{ - return __wcstoull_internal (nptr, endptr, base, 0); -} - -# endif /* __WORDSIZE == 32 */ -#endif /* Use extern inlines. */ - -__END_DECLS - -#endif /* inttypes.h */ diff --git a/source/fceultra/linux/stdint.h b/source/fceultra/linux/stdint.h deleted file mode 100644 index c860030..0000000 --- a/source/fceultra/linux/stdint.h +++ /dev/null @@ -1,320 +0,0 @@ -/* Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -/* - * ISO C99: 7.18 Integer types - */ - -#ifndef _STDINT_H -#define _STDINT_H 1 - -#include -#include -#include - -/* Exact integral types. */ - -/* Signed. */ - -/* There is some amount of overlap with as known by inet code */ -#ifndef __int8_t_defined -# define __int8_t_defined -typedef signed char int8_t; -typedef short int int16_t; -typedef int int32_t; -# if __WORDSIZE == 64 -typedef long int int64_t; -# else -__extension__ -typedef long long int int64_t; -# endif -#endif - -/* Unsigned. */ -typedef unsigned char uint8_t; -typedef unsigned short int uint16_t; -#ifndef __uint32_t_defined -typedef unsigned int uint32_t; -# define __uint32_t_defined -#endif -#if __WORDSIZE == 64 -typedef unsigned long int uint64_t; -#else -__extension__ -typedef unsigned long long int uint64_t; -#endif - - -/* Small types. */ - -/* Signed. */ -typedef signed char int_least8_t; -typedef short int int_least16_t; -typedef int int_least32_t; -#if __WORDSIZE == 64 -typedef long int int_least64_t; -#else -__extension__ -typedef long long int int_least64_t; -#endif - -/* Unsigned. */ -typedef unsigned char uint_least8_t; -typedef unsigned short int uint_least16_t; -typedef unsigned int uint_least32_t; -#if __WORDSIZE == 64 -typedef unsigned long int uint_least64_t; -#else -__extension__ -typedef unsigned long long int uint_least64_t; -#endif - - -/* Fast types. */ - -/* Signed. */ -typedef signed char int_fast8_t; -#if __WORDSIZE == 64 -typedef long int int_fast16_t; -typedef long int int_fast32_t; -typedef long int int_fast64_t; -#else -typedef int int_fast16_t; -typedef int int_fast32_t; -__extension__ -typedef long long int int_fast64_t; -#endif - -/* Unsigned. */ -typedef unsigned char uint_fast8_t; -#if __WORDSIZE == 64 -typedef unsigned long int uint_fast16_t; -typedef unsigned long int uint_fast32_t; -typedef unsigned long int uint_fast64_t; -#else -typedef unsigned int uint_fast16_t; -typedef unsigned int uint_fast32_t; -__extension__ -typedef unsigned long long int uint_fast64_t; -#endif - - -/* Types for `void *' pointers. */ -#if __WORDSIZE == 64 -# ifndef __intptr_t_defined -typedef long int intptr_t; -# define __intptr_t_defined -# endif -typedef unsigned long int uintptr_t; -#else -# ifndef __intptr_t_defined -typedef int intptr_t; -# define __intptr_t_defined -# endif -typedef unsigned int uintptr_t; -#endif - - -/* Largest integral types. */ -#if __WORDSIZE == 64 -typedef long int intmax_t; -typedef unsigned long int uintmax_t; -#else -__extension__ -typedef long long int intmax_t; -__extension__ -typedef unsigned long long int uintmax_t; -#endif - - -/* The ISO C99 standard specifies that in C++ implementations these - macros should only be defined if explicitly requested. */ -#if !defined __cplusplus || defined __STDC_LIMIT_MACROS - -# if __WORDSIZE == 64 -# define __INT64_C(c) c ## L -# define __UINT64_C(c) c ## UL -# else -# define __INT64_C(c) c ## LL -# define __UINT64_C(c) c ## ULL -# endif - -/* Limits of integral types. */ - -/* Minimum of signed integral types. */ -# define INT8_MIN (-128) -# define INT16_MIN (-32767-1) -# define INT32_MIN (-2147483647-1) -# define INT64_MIN (-__INT64_C(9223372036854775807)-1) -/* Maximum of signed integral types. */ -# define INT8_MAX (127) -# define INT16_MAX (32767) -# define INT32_MAX (2147483647) -# define INT64_MAX (__INT64_C(9223372036854775807)) - -/* Maximum of unsigned integral types. */ -# define UINT8_MAX (255) -# define UINT16_MAX (65535) -# define UINT32_MAX (4294967295U) -# define UINT64_MAX (__UINT64_C(18446744073709551615)) - - -/* Minimum of signed integral types having a minimum size. */ -# define INT_LEAST8_MIN (-128) -# define INT_LEAST16_MIN (-32767-1) -# define INT_LEAST32_MIN (-2147483647-1) -# define INT_LEAST64_MIN (-__INT64_C(9223372036854775807)-1) -/* Maximum of signed integral types having a minimum size. */ -# define INT_LEAST8_MAX (127) -# define INT_LEAST16_MAX (32767) -# define INT_LEAST32_MAX (2147483647) -# define INT_LEAST64_MAX (__INT64_C(9223372036854775807)) - -/* Maximum of unsigned integral types having a minimum size. */ -# define UINT_LEAST8_MAX (255) -# define UINT_LEAST16_MAX (65535) -# define UINT_LEAST32_MAX (4294967295U) -# define UINT_LEAST64_MAX (__UINT64_C(18446744073709551615)) - - -/* Minimum of fast signed integral types having a minimum size. */ -# define INT_FAST8_MIN (-128) -# if __WORDSIZE == 64 -# define INT_FAST16_MIN (-9223372036854775807L-1) -# define INT_FAST32_MIN (-9223372036854775807L-1) -# else -# define INT_FAST16_MIN (-2147483647-1) -# define INT_FAST32_MIN (-2147483647-1) -# endif -# define INT_FAST64_MIN (-__INT64_C(9223372036854775807)-1) -/* Maximum of fast signed integral types having a minimum size. */ -# define INT_FAST8_MAX (127) -# if __WORDSIZE == 64 -# define INT_FAST16_MAX (9223372036854775807L) -# define INT_FAST32_MAX (9223372036854775807L) -# else -# define INT_FAST16_MAX (2147483647) -# define INT_FAST32_MAX (2147483647) -# endif -# define INT_FAST64_MAX (__INT64_C(9223372036854775807)) - -/* Maximum of fast unsigned integral types having a minimum size. */ -# define UINT_FAST8_MAX (255) -# if __WORDSIZE == 64 -# define UINT_FAST16_MAX (18446744073709551615UL) -# define UINT_FAST32_MAX (18446744073709551615UL) -# else -# define UINT_FAST16_MAX (4294967295U) -# define UINT_FAST32_MAX (4294967295U) -# endif -# define UINT_FAST64_MAX (__UINT64_C(18446744073709551615)) - - -/* Values to test for integral types holding `void *' pointer. */ -# if __WORDSIZE == 64 -# define INTPTR_MIN (-9223372036854775807L-1) -# define INTPTR_MAX (9223372036854775807L) -# define UINTPTR_MAX (18446744073709551615UL) -# else -# define INTPTR_MIN (-2147483647-1) -# define INTPTR_MAX (2147483647) -# define UINTPTR_MAX (4294967295U) -# endif - - -/* Minimum for largest signed integral type. */ -# define INTMAX_MIN (-__INT64_C(9223372036854775807)-1) -/* Maximum for largest signed integral type. */ -# define INTMAX_MAX (__INT64_C(9223372036854775807)) - -/* Maximum for largest unsigned integral type. */ -# define UINTMAX_MAX (__UINT64_C(18446744073709551615)) - - -/* Limits of other integer types. */ - -/* Limits of `ptrdiff_t' type. */ -# if __WORDSIZE == 64 -# define PTRDIFF_MIN (-9223372036854775807L-1) -# define PTRDIFF_MAX (9223372036854775807L) -# else -# define PTRDIFF_MIN (-2147483647-1) -# define PTRDIFF_MAX (2147483647) -# endif - -/* Limits of `sig_atomic_t'. */ -# define SIG_ATOMIC_MIN (-2147483647-1) -# define SIG_ATOMIC_MAX (2147483647) - -/* Limit of `size_t' type. */ -# if __WORDSIZE == 64 -# define SIZE_MAX (18446744073709551615UL) -# else -# define SIZE_MAX (4294967295U) -# endif - -/* Limits of `wchar_t'. */ -# ifndef WCHAR_MIN -/* These constants might also be defined in . */ -# define WCHAR_MIN __WCHAR_MIN -# define WCHAR_MAX __WCHAR_MAX -# endif - -/* Limits of `wint_t'. */ -# define WINT_MIN (0u) -# define WINT_MAX (4294967295u) - -#endif /* C++ && limit macros */ - - -/* The ISO C99 standard specifies that in C++ implementations these - should only be defined if explicitly requested. */ -#if !defined __cplusplus || defined __STDC_CONSTANT_MACROS - -/* Signed. */ -# define INT8_C(c) c -# define INT16_C(c) c -# define INT32_C(c) c -# if __WORDSIZE == 64 -# define INT64_C(c) c ## L -# else -# define INT64_C(c) c ## LL -# endif - -/* Unsigned. */ -# define UINT8_C(c) c ## U -# define UINT16_C(c) c ## U -# define UINT32_C(c) c ## U -# if __WORDSIZE == 64 -# define UINT64_C(c) c ## UL -# else -# define UINT64_C(c) c ## ULL -# endif - -/* Maximal type. */ -# if __WORDSIZE == 64 -# define INTMAX_C(c) c ## L -# define UINTMAX_C(c) c ## UL -# else -# define INTMAX_C(c) c ## LL -# define UINTMAX_C(c) c ## ULL -# endif - -#endif /* C++ && constant macros */ - -#endif /* stdint.h */ diff --git a/source/fceultra/mappers/000.c b/source/fceultra/mappers/000.c index 5e09ad9..fb3139e 100644 --- a/source/fceultra/mappers/000.c +++ b/source/fceultra/mappers/000.c @@ -285,17 +285,20 @@ static void M185Sync(int version) { int x; -// DumpMem("out",0x8000,0xFFFF); -// exit(1); -// if(mapbyte1[0]==0x15) - if(!(mapbyte1[0]&3)) -// if(!(mapbyte1[0]==0x21)) + //printf("%02x\n",mapbyte1[0]); + //if((mapbyte1[0]&3)==3) + if(VROM_size == 1) { - for(x=0;x<8;x++) - setchr1r(0x10,x<<10,0); - } - else - setchr8(0); + if((mapbyte1[0]&3) == 1) + setchr8(0); + else + setchr8r(0x10,0); + } + else if(VROM_size == 2) + { + if((mapbyte1[0]&2)) setchr8(mapbyte1[0]&1); + else setchr8r(0x10,0); + } } static DECLFW(Mapper185_write) @@ -307,12 +310,15 @@ static DECLFW(Mapper185_write) void Mapper185_init(void) { - memset(MapperExRAM,0xFF,1024); + int x; + for(x=0;x<8192;x++) + MapperExRAM[x]=0xFF; + //memset(MapperExRAM,0xFF,1024); MapStateRestore=M185Sync; mapbyte1[0]=0; M185Sync(0); - SetupCartCHRMapping(0x10,MapperExRAM,1024,0); + SetupCartCHRMapping(0x10,MapperExRAM,8192,0); SetWriteHandler(0x8000,0xFFFF,Mapper185_write); } diff --git a/source/fceultra/mappers/27.c b/source/fceultra/mappers/27.c deleted file mode 100644 index c3b6b36..0000000 --- a/source/fceultra/mappers/27.c +++ /dev/null @@ -1,69 +0,0 @@ -#include "mapinc.h" - -static uint32 regchr[9]; - -static DECLFW(Mapper27_write) -{ - A&=0xF00F; - int regnum; - if((A>=0xB000) && (A<=0xE003)) { - regnum=((((A>>12)+1)&0x03)<<1)|((A&0x02)>>1); - if(A&1) - regchr[regnum]=(regchr[regnum]&0x00F)|(V<<4); - else - regchr[regnum]=(regchr[regnum]&0x1F0)|(V&0xF); - VROM_BANK1(regnum<<10,regchr[regnum]); - } - switch(A) - { - case 0x8000: ROM_BANK8(0x8000|((regchr[8]&2)<<13),V); break; - case 0xA000: ROM_BANK8(0xa000,V); break; - case 0x9000: switch(V&3){ - case 0:setmirror(MI_V);break; - case 1:setmirror(MI_H);break; - case 2:setmirror(MI_0);break; - case 3:setmirror(MI_1);break; - } - case 0x9002: regchr[8]=V; break; - case 0xF000: //X6502_IRQEnd(FCEU_IQEXT); - IRQLatch=(IRQLatch&0xF0)|(V&0x0F); - break; - case 0xF001: //X6502_IRQEnd(FCEU_IQEXT); - IRQLatch=(IRQLatch&0x0F)|((V&0xF)<<4); - break; - case 0xF003: IRQa=((IRQa&0x1)<<1)|(IRQa&0x1); - X6502_IRQEnd(FCEU_IQEXT); - break; - case 0xF002: IRQa=V&3; - if(IRQa&0x02) IRQCount=IRQLatch-1; -// X6502_IRQEnd(FCEU_IQEXT); - break; - } -// if((A&0xF000)==0xF000) FCEU_printf("$%04x:$%02x, %d\n",A,V, scanline); -} - -static void Mapper27_hb(void) -{ -// FCEU_printf("%02x-%d,%d,%d\n",scanline,IRQa,IRQCount,IRQLatch); - if(IRQa&0x2){ - if(IRQCount==0xFF){ - X6502_IRQBegin(FCEU_IQEXT); - IRQCount=IRQLatch+1; - } else { - IRQCount++; - } - } -} - -void Mapper27_init(void) -{ - int i; - for (i=0; i<9; i++) { - regchr[i]=0; - } - IRQa=0; - IRQCount=IRQLatch=0; - SetWriteHandler(0x8000,0xffff,Mapper27_write); - GameHBIRQHook=Mapper27_hb; -} - diff --git a/source/fceultra/mappers/33.c b/source/fceultra/mappers/33.c index abd22e1..121b349 100644 --- a/source/fceultra/mappers/33.c +++ b/source/fceultra/mappers/33.c @@ -24,8 +24,9 @@ static int is48; static DECLFW(Mapper33_write) { - A&=0xF003; + //printf("%04x:%02x, %d\n",A,V,scanline); + A&=0xF003; if(A>=0xA000 && A<=0xA003) VROM_BANK1(0x1000+((A&3)<<10),V); else switch(A) diff --git a/source/fceultra/mappers/86.c b/source/fceultra/mappers/86.c index 555784a..8404985 100644 --- a/source/fceultra/mappers/86.c +++ b/source/fceultra/mappers/86.c @@ -27,9 +27,9 @@ DECLFW(Mapper86_write) VROM_BANK8((V&3)|((V>>4)&4)); ROM_BANK32((V>>4)&3); } - else + //else //if(A!=0x6000) - printf("$%04x:$%02x\n",A,V); + // printf("$%04x:$%02x\n",A,V); } void Mapper86_init(void) { diff --git a/source/fceultra/mappers/subor.c b/source/fceultra/mappers/subor.c deleted file mode 100644 index 9f0386d..0000000 --- a/source/fceultra/mappers/subor.c +++ /dev/null @@ -1,79 +0,0 @@ -#include "mapinc.h" - -static uint8 mode; -static uint8 DRegs[4]; - -static SFORMAT StateRegs[]= -{ - {DRegs, 4, "DREG"}, - {0} -}; - -static void Sync(void) -{ - int base, bank; - base = ((DRegs[0]^DRegs[1])&0x10)<<1; - bank = (DRegs[2]^DRegs[3])&0x1f; - - if(DRegs[1]&0x08) - { - bank &= 0xfe; - if(mode==0) - { - setprg16(0x8000,base+bank+1); - setprg16(0xC000,base+bank+0); - } - else - { - setprg16(0x8000,base+bank+0); - setprg16(0xC000,base+bank+1); - } - } - else - { - if(DRegs[1]&0x04) - { - setprg16(0x8000,0x1f); - setprg16(0xC000,base+bank); - } - else - { - setprg16(0x8000,base+bank); - if(mode==0) - setprg16(0xC000,0x20); - else - setprg16(0xC000,0x07); - } - } -} - -static DECLFW(Mapper167_write) -{ - DRegs[(A>>13)&0x03]=V; - Sync(); -} - -static void StateRestore(int version) -{ - Sync(); -} - -void Mapper166_init(void) -{ - mode=1; - DRegs[0]=DRegs[1]=DRegs[2]=DRegs[3]=0; - Sync(); - SetWriteHandler(0x8000,0xFFFF,Mapper167_write); - GameStateRestore=StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} - -void Mapper167_init(void) -{ - mode=0; - DRegs[0]=DRegs[1]=DRegs[2]=DRegs[3]=0; - Sync(); - SetWriteHandler(0x8000,0xFFFF,Mapper167_write); - GameStateRestore=StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/source/fceultra/mbshare/164.c b/source/fceultra/mbshare/164.c index 60bda02..7ad0ca6 100644 --- a/source/fceultra/mbshare/164.c +++ b/source/fceultra/mbshare/164.c @@ -22,96 +22,62 @@ static uint8 cmd; static uint8 DRegs[8]; + static SFORMAT StateRegs[]= { - {&cmd, 1, "CMD"}, - {DRegs, 8, "DREG"}, - {0} + {&cmd, 1, "CMD"}, + {DRegs, 8, "DREG"}, + {0} }; static void Sync(void) { - setprg32(0x8000,(DRegs[0]<<4)|(DRegs[1]&0xF)); - setchr8(0); + + } static void StateRestore(int version) { - Sync(); + Sync(); } static DECLFW(Write) { - switch (A&0x7300) - { - case 0x5100: DRegs[0]=V; Sync(); break; - case 0x5000: DRegs[1]=V; Sync(); break; - } -} - -static DECLFW(Write2) -{ -// FCEU_printf("bs %04x %02x\n",A,V); - switch (A&0x7300) - { - case 0x5200: DRegs[0]=V; Sync(); break; - case 0x5000: DRegs[1]=V; Sync(); break; - } + if((A&0x7300)==0x5000) + setprg32(0x8000,V); + //else + //if(A==0x5200) + // printf("$%04x:$%02x\n",A,V); } static uint8 WRAM[8192]; static DECLFR(AWRAM) { - return(WRAM[A-0x6000]); + return(WRAM[A-0x6000]); } static DECLFW(BWRAM) { - WRAM[A-0x6000]=V; + WRAM[A-0x6000]=V; } static void Power(void) { - memset(DRegs,0,8); - DRegs[1]=0xFF; - cmd=0; - SetReadHandler(0x8000,0xFFFF,CartBR); - SetWriteHandler(0x4020,0x5FFF,Write); - SetReadHandler(0x6000,0x7FFF,AWRAM); - SetWriteHandler(0x6000,0x7FFF,BWRAM); - Sync(); + setchr8(0); + setprg32(0x8000,~0); + cmd=0; + memset(DRegs,0,8); + Sync(); + SetReadHandler(0x8000,0xFFFF,CartBR); + SetWriteHandler(0x4020,0xFFFF,Write); + SetReadHandler(0x6000,0x7FFF,AWRAM); + SetWriteHandler(0x6000,0x7FFF,BWRAM); } -static void M163HB(void) -{ - if(scanline==127&&DRegs[1]&0x80) - setchr4(0x0000,1); -} - - -static void Power2(void) -{ - memset(DRegs,0,8); - DRegs[1]=0xFF; - cmd=0; - SetReadHandler(0x8000,0xFFFF,CartBR); - SetWriteHandler(0x4020,0x5FFF,Write2); - SetReadHandler(0x6000,0x7FFF,AWRAM); - SetWriteHandler(0x6000,0x7FFF,BWRAM); - Sync(); -} void Mapper164_Init(CartInfo *info) { - info->Power=Power; - GameStateRestore=StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} - -void Mapper163_Init(CartInfo *info) -{ - info->Power=Power2; - GameHBIRQHook=M163HB; - GameStateRestore=StateRestore; - AddExState(&StateRegs, ~0, 0, 0); + info->Power=Power; + GameStateRestore=StateRestore; + AddExState(&StateRegs, ~0, 0, 0); } diff --git a/source/fceultra/mbshare/199.c b/source/fceultra/mbshare/199.c deleted file mode 100644 index d4b0160..0000000 --- a/source/fceultra/mbshare/199.c +++ /dev/null @@ -1,95 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2006 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 - * - * Dragon Ball Z 2 - Gekishin Freeza! (C) - * Dragon Ball Z Gaiden - Saiya Jin Zetsumetsu Keikaku (C) - * San Guo Zhi 2 (C) - * - */ - -#include "mapinc.h" -#include "mmc3.h" - -static void M199PW(uint32 A, uint8 V) -{ - setprg8(A,V); - setprg8(0xC000,EXPREGS[0]); - setprg8(0xE000,EXPREGS[1]); -} - -static void M199CW(uint32 A, uint8 V) -{ - setchr1r((V<8)?0x10:0x00,A,V); - setchr1r((DRegBuf[0]<8)?0x10:0x00,0x0000,DRegBuf[0]); - setchr1r((EXPREGS[2]<8)?0x10:0x00,0x0400,EXPREGS[2]); - setchr1r((DRegBuf[1]<8)?0x10:0x00,0x0800,DRegBuf[1]); - setchr1r((EXPREGS[3]<8)?0x10:0x00,0x0c00,EXPREGS[3]); -} - -static void M199MW(uint8 V) -{ -// FCEU_printf("%02x\n",V); - switch(V&3) - { - case 0: setmirror(MI_V); break; - case 1: setmirror(MI_H); break; - case 2: setmirror(MI_0); break; - case 3: setmirror(MI_1); break; - } -} - -static DECLFW(M199Write) -{ - if((A==0x8001)&&(MMC3_cmd&8)) - { -// FCEU_printf("%02x=>%02x\n",MMC3_cmd,V); - EXPREGS[MMC3_cmd&3]=V; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); - } - else - if(A<0xC000) - MMC3_CMDWrite(A,V); - else - MMC3_IRQWrite(A,V); -} - -static void M199Power(void) -{ - EXPREGS[0]=~1; - EXPREGS[1]=~0; - EXPREGS[2]=1; - EXPREGS[3]=3; - GenMMC3Power(); - SetWriteHandler(0x8000,0xFFFF,M199Write); -} - -void Mapper199_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap=M199CW; - pwrap=M199PW; - mwrap=M199MW; - info->Power=M199Power; - int CHRRAMSize=1024*8; - CHRRAM=(uint8*)FCEU_gmalloc(CHRRAMSize); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); - AddExState(CHRRAM, CHRRAMSize, 0, "CHRR"); - AddExState(EXPREGS, 4, 0, "EXPR"); -} diff --git a/source/fceultra/mbshare/252.c b/source/fceultra/mbshare/252.c deleted file mode 100644 index 7bffeee..0000000 --- a/source/fceultra/mbshare/252.c +++ /dev/null @@ -1,95 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2006 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 - * - * Dragon Ball Z 2 - Gekishin Freeza! (C) - * Dragon Ball Z Gaiden - Saiya Jin Zetsumetsu Keikaku (C) - * San Guo Zhi 2 (C) - * - */ - -#include "mapinc.h" -#include "mmc3.h" - -static void M252PW(uint32 A, uint8 V) -{ - setprg8(A,V); - setprg8(0xC000,EXPREGS[0]); - setprg8(0xE000,EXPREGS[1]); -} - -static void M252CW(uint32 A, uint8 V) -{ - setchr1r((V<8)?0x10:0x00,A,V); - setchr1r((DRegBuf[0]<8)?0x10:0x00,0x0000,DRegBuf[0]); - setchr1r((EXPREGS[2]<8)?0x10:0x00,0x0400,EXPREGS[2]); - setchr1r((DRegBuf[1]<8)?0x10:0x00,0x0800,DRegBuf[1]); - setchr1r((EXPREGS[3]<8)?0x10:0x00,0x0c00,EXPREGS[3]); -} - -static void M252MW(uint8 V) -{ -// FCEU_printf("%02x\n",V); - switch(V&3) - { - case 0: setmirror(MI_V); break; - case 1: setmirror(MI_H); break; - case 2: setmirror(MI_0); break; - case 3: setmirror(MI_1); break; - } -} - -static DECLFW(M252Write) -{ - if((A==0x8001)&&(MMC3_cmd&8)) - { -// FCEU_printf("%02x=>%02x\n",MMC3_cmd,V); - EXPREGS[MMC3_cmd&3]=V; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); - } - else - if(A<0xC000) - MMC3_CMDWrite(A,V); - else - MMC3_IRQWrite(A,V); -} - -static void M252Power(void) -{ - EXPREGS[0]=~1; - EXPREGS[1]=~0; - EXPREGS[2]=1; - EXPREGS[3]=3; - GenMMC3Power(); - SetWriteHandler(0x8000,0xFFFF,M252Write); -} - -void Mapper252_Init(CartInfo *info) -{ - GenMMC3_Init(info, 256, 128, 8, info->battery); - cwrap=M252CW; - pwrap=M252PW; - mwrap=M252MW; - info->Power=M252Power; - int CHRRAMSize=1024*8; - CHRRAM=(uint8*)FCEU_gmalloc(CHRRAMSize); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); - AddExState(CHRRAM, CHRRAMSize, 0, "CHRR"); - AddExState(EXPREGS, 4, 0, "EXPR"); -} diff --git a/source/fceultra/mbshare/karaoke.c b/source/fceultra/mbshare/karaoke.c new file mode 100644 index 0000000..83a40fd --- /dev/null +++ b/source/fceultra/mbshare/karaoke.c @@ -0,0 +1,80 @@ +/* FCE Ultra - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2002 Xodnizel + * + * 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" + +static uint8 DReg; +static SFORMAT StateRegs[]= +{ + {&DReg, 1, "DREG"}, + {0} +}; + +static void Sync(void) +{ + //if(!DReg) + //printf("%02x\n",DReg); + if(DReg) + { + if(DReg & 0x10) + setprg16(0x8000, (DReg & 0x7)); + else + setprg16(0x8000, (DReg&0x7) | 0x8); + } + else + setprg16(0x8000, 0x7); +} + +static void StateRestore(int version) +{ + Sync(); +} + +static DECLFW(M188Write) +{ + DReg = V; + Sync(); +} + +static DECLFR(testr) +{ + return(3); +} + + +static void Power(void) +{ + setchr8(0); + setprg8(0xc000,0xE); + setprg8(0xe000,0xF); + DReg = 0; + Sync(); + SetReadHandler(0x6000,0x7FFF,testr); + SetReadHandler(0x8000,0xFFFF,CartBR); + SetWriteHandler(0x8000,0xFFFF,M188Write); +} + + +void Mapper188_Init(CartInfo *info) +{ + info->Power=Power; + GameStateRestore=StateRestore; + AddExState(&StateRegs, ~0, 0, 0); +} diff --git a/source/fceultra/mbshare/mmc3.c b/source/fceultra/mbshare/mmc3.c index 6eec042..80032c9 100644 --- a/source/fceultra/mbshare/mmc3.c +++ b/source/fceultra/mbshare/mmc3.c @@ -20,91 +20,82 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Code for emulating iNES mappers 4,12,44,45,47,49,52,74,114,115,116,118, - 119,148,165,205,214,215,245,249,250,254 -*/ +/* Code for emulating iNES mappers 4, 118,119 */ #include "mapinc.h" -#include "mmc3.h" -uint8 MMC3_cmd; -uint8 *WRAM; -uint8 *CHRRAM; -uint32 CHRRAMSize; -uint8 DRegBuf[8]; -uint8 EXPREGS[8]; /* For bootleg games, mostly. */ +static uint8 resetmode,MMC3_cmd,A000B,A001B; +static uint8 DRegBuf[8]; -static uint8 A000B,A001B; +static uint8 *WRAM; +static uint8 *CHRRAM; +static uint32 CHRRAMSize; +static uint8 PPUCHRBus; +static uint8 TKSMIR[8]; +static uint8 EXPREGS[8]; /* For bootleg games, mostly. */ #undef IRQCount #undef IRQLatch #undef IRQa -uint8 IRQCount,IRQLatch,IRQa; -uint8 IRQReload; +static uint8 IRQCount,IRQLatch,IRQa; +static uint8 IRQReload; -static SFORMAT MMC3_StateRegs[]= -{ - {DRegBuf, 8, "REGS"}, - {&MMC3_cmd, 1, "CMD"}, - {&A000B, 1, "A000"}, - {&A001B, 1, "A001"}, - {&IRQReload, 1, "IRQR"}, - {&IRQCount, 1, "IRQC"}, - {&IRQLatch, 1, "IRQL"}, - {&IRQa, 1, "IRQA"}, - {0} +static SFORMAT MMC3_StateRegs[]={ + {DRegBuf, 8, "REGS"}, + {&resetmode, 1, "RMOD"}, + {&MMC3_cmd, 1, "CMD"}, + {&A000B, 1, "A000"}, + {&A001B, 1, "A001"}, + {&IRQReload, 1, "IRQR"}, + {&IRQCount, 1, "IRQC"}, + {&IRQLatch, 1, "IRQL"}, + {&IRQa, 1, "IRQA"}, + {0} }; + +static void (*pwrap)(uint32 A, uint8 V); +static void (*cwrap)(uint32 A, uint8 V); +static void (*mwrap)(uint8 V); + static int mmc3opts=0; -static int wrams; -static int isRevB=1; - -void (*pwrap)(uint32 A, uint8 V); -void (*cwrap)(uint32 A, uint8 V); -void (*mwrap)(uint8 V); - -void GenMMC3Power(void); -void FixMMC3PRG(int V); -void FixMMC3CHR(int V); void GenMMC3_Init(CartInfo *info, int prg, int chr, int wram, int battery); +static void GenMMC3Power(void); +static void FixMMC3PRG(int V); +static void FixMMC3CHR(int V); -// ---------------------------------------------------------------------- -// ------------------------- Generic MM3 Code --------------------------- -// ---------------------------------------------------------------------- - -void FixMMC3PRG(int V) +static void FixMMC3PRG(int V) { - if(V&0x40) - { - pwrap(0xC000,DRegBuf[6]); - pwrap(0x8000,~1); - } - else - { - pwrap(0x8000,DRegBuf[6]); - pwrap(0xC000,~1); - } - pwrap(0xA000,DRegBuf[7]); - pwrap(0xE000,~0); + if(V&0x40) + { + pwrap(0xC000,DRegBuf[6]); + pwrap(0x8000,~1); + } + else + { + pwrap(0x8000,DRegBuf[6]); + pwrap(0xC000,~1); + } + pwrap(0xA000,DRegBuf[7]); + pwrap(0xE000,~0); } -void FixMMC3CHR(int V) +static void FixMMC3CHR(int V) { - int cbase=(V&0x80)<<5; + int cbase=(V&0x80)<<5; + cwrap((cbase^0x000),DRegBuf[0]&(~1)); + cwrap((cbase^0x400),DRegBuf[0]|1); + cwrap((cbase^0x800),DRegBuf[1]&(~1)); + cwrap((cbase^0xC00),DRegBuf[1]|1); - cwrap((cbase^0x000),DRegBuf[0]&(~1)); - cwrap((cbase^0x400),DRegBuf[0]|1); - cwrap((cbase^0x800),DRegBuf[1]&(~1)); - cwrap((cbase^0xC00),DRegBuf[1]|1); - - cwrap(cbase^0x1000,DRegBuf[2]); - cwrap(cbase^0x1400,DRegBuf[3]); - cwrap(cbase^0x1800,DRegBuf[4]); - cwrap(cbase^0x1c00,DRegBuf[5]); + cwrap(cbase^0x1000,DRegBuf[2]); + cwrap(cbase^0x1400,DRegBuf[3]); + cwrap(cbase^0x1800,DRegBuf[4]); + cwrap(cbase^0x1c00,DRegBuf[5]); } -void MMC3RegReset(void) +static void MMC3RegReset(void) { IRQCount=IRQLatch=IRQa=MMC3_cmd=0; @@ -121,111 +112,134 @@ void MMC3RegReset(void) FixMMC3CHR(0); } -DECLFW(MMC3_CMDWrite) +static DECLFW(Mapper4_write) { -// FCEU_printf("bs %04x %02x\n",A,V); - switch(A&0xE001) - { - case 0x8000: - if((V&0x40) != (MMC3_cmd&0x40)) - FixMMC3PRG(V); - if((V&0x80) != (MMC3_cmd&0x80)) - FixMMC3CHR(V); - MMC3_cmd = V; - break; - case 0x8001: - { - int cbase=(MMC3_cmd&0x80)<<5; - DRegBuf[MMC3_cmd&0x7]=V; - switch(MMC3_cmd&0x07) - { - case 0: cwrap((cbase^0x000),V&(~1)); - cwrap((cbase^0x400),V|1); - break; - case 1: cwrap((cbase^0x800),V&(~1)); - cwrap((cbase^0xC00),V|1); - break; - case 2: cwrap(cbase^0x1000,V); - break; - case 3: cwrap(cbase^0x1400,V); - break; - case 4: cwrap(cbase^0x1800,V); - break; - case 5: cwrap(cbase^0x1C00,V); - break; - case 6: - if(MMC3_cmd&0x40) - pwrap(0xC000,V); - else - pwrap(0x8000,V); - break; - case 7: - pwrap(0xA000,V); - break; - } - } - break; - case 0xA000: - if(mwrap) mwrap(V); - break; - case 0xA001: - A001B=V; - Write_IRQFM(0x4017,0x40); - break; + switch(A&0xE001) + { + case 0x8000: + if((V&0x40) != (MMC3_cmd&0x40)) + FixMMC3PRG(V); + if((V&0x80) != (MMC3_cmd&0x80)) + FixMMC3CHR(V); + MMC3_cmd = V; + break; + + case 0x8001: + { + int cbase=(MMC3_cmd&0x80)<<5; + DRegBuf[MMC3_cmd&0x7]=V; + switch(MMC3_cmd&0x07) + { + case 0: cwrap((cbase^0x000),V&(~1)); + cwrap((cbase^0x400),V|1); + break; + case 1: cwrap((cbase^0x800),V&(~1)); + cwrap((cbase^0xC00),V|1); + break; + case 2: cwrap(cbase^0x1000,V); break; + case 3: cwrap(cbase^0x1400,V); break; + case 4: cwrap(cbase^0x1800,V); break; + case 5: cwrap(cbase^0x1C00,V); break; + case 6: if (MMC3_cmd&0x40) pwrap(0xC000,V); + else pwrap(0x8000,V); + break; + case 7: pwrap(0xA000,V); + break; + } + } + break; + + case 0xA000: + if(mwrap) mwrap(V&1); + break; + case 0xA001: + A001B=V; + break; } } -DECLFW(MMC3_IRQWrite) +static DECLFW(MMC3_IRQWrite) { -// FCEU_printf("%04x:%04x\n",A,V); - switch(A&0xE001) - { - case 0xC000:IRQLatch=V;break; - case 0xC001:IRQReload=1;break; - case 0xE000:X6502_IRQEnd(FCEU_IQEXT);IRQa=0;break; - case 0xE001:IRQa=1;break; - } + switch(A&0xE001) + { + case 0xc000:IRQLatch=V;break; + case 0xc001:IRQReload = 1;break; + case 0xE000:X6502_IRQEnd(FCEU_IQEXT);IRQa=0;break; + case 0xE001:IRQa=1;break; + } } + + static void ClockMMC3Counter(void) { - int count = IRQCount; - if(!count || IRQReload) - { - IRQCount = IRQLatch; - IRQReload = 0; - } - else - IRQCount--; - if((count|isRevB) && !IRQCount) - { - if(IRQa) - { - X6502_IRQBegin(FCEU_IQEXT); - } - } + int count = IRQCount; + if(!count || IRQReload) + { + IRQCount = IRQLatch; + IRQReload = 0; + } + else IRQCount--; + if(count && !IRQCount) + { + if(IRQa) + { + X6502_IRQBegin(FCEU_IQEXT); + } + } } static void MMC3_hb(void) { - ClockMMC3Counter(); + ClockMMC3Counter(); } static void MMC3_hb_KickMasterHack(void) { - if(scanline==238) ClockMMC3Counter(); - ClockMMC3Counter(); + if(scanline==238) + ClockMMC3Counter(); + ClockMMC3Counter(); } static void MMC3_hb_PALStarWarsHack(void) { - if(scanline==240) ClockMMC3Counter(); - ClockMMC3Counter(); + if(scanline==240) + ClockMMC3Counter(); + ClockMMC3Counter(); } - -void GenMMC3Restore(int version) +/* +static void ClockMMC6Counter(void) { - if(mwrap) mwrap(A000B); + unsigned int count = IRQCount; + + if(!count || IRQReload) + { + IRQCount = IRQLatch; + IRQReload = 0; + } + else IRQCount--; + if(!IRQCount) + { + if(IRQa) + X6502_IRQBegin(FCEU_IQEXT); + } +} +*/ + +/* +static uint32 lasta; +static void FP_FASTAPASS(1) MMC3_PPUIRQ(uint32 A) +{ + if(A&0x2000) return; + if((A&0x1000) && !(lasta&0x1000)) + ClockMMC3Counter(); + lasta = A; +} +*/ + +static void genmmc3restore(int version) +{ + mwrap(A000B&1); FixMMC3PRG(MMC3_cmd); FixMMC3CHR(MMC3_cmd); } @@ -243,7 +257,7 @@ static void GENPWRAP(uint32 A, uint8 V) static void GENMWRAP(uint8 V) { A000B=V; - setmirror((V&1)^1); + setmirror(V^1); } static void GENNOMWRAP(uint8 V) @@ -251,155 +265,7 @@ static void GENNOMWRAP(uint8 V) A000B=V; } -static DECLFW(MBWRAM) -{ - WRAM[A-0x6000]=V; -} -static DECLFR(MAWRAM) -{ - return(WRAM[A-0x6000]); -} - -static DECLFW(MBWRAMMMC6) -{ - WRAM[A&0x3ff]=V; -} - -static DECLFR(MAWRAMMMC6) -{ - return(WRAM[A&0x3ff]); -} - -void GenMMC3Power(void) -{ - SetWriteHandler(0x8000,0xBFFF,MMC3_CMDWrite); - SetWriteHandler(0xC000,0xFFFF,MMC3_IRQWrite); - SetReadHandler(0x8000,0xFFFF,CartBR); - A001B=A000B=0; - setmirror(1); - if(mmc3opts&1) - { - if(wrams==1024) - { - FCEU_CheatAddRAM(1,0x7000,WRAM); - SetReadHandler(0x7000,0x7FFF,MAWRAMMMC6); - SetWriteHandler(0x7000,0x7FFF,MBWRAMMMC6); - } - else - { - FCEU_CheatAddRAM(wrams>>10,0x6000,WRAM); - SetReadHandler(0x6000,0x6000+wrams-1,MAWRAM); - SetWriteHandler(0x6000,0x6000+wrams-1,MBWRAM); - } - if(!(mmc3opts&2)) - FCEU_dwmemset(WRAM,0,wrams); - } - MMC3RegReset(); - if(CHRRAM) - FCEU_dwmemset(CHRRAM,0,CHRRAMSize); -} - -static void GenMMC3Close(void) -{ - if(CHRRAM) - FCEU_gfree(CHRRAM); - if(WRAM) - FCEU_gfree(WRAM); - CHRRAM=WRAM=NULL; -} - -//static uint16 _a12; -//static void FP_FASTAPASS(1) MMC3_PPU(uint32 A) -//{ -// if(A&0x2000)return; -// if((!_a12)&&(A&0x1000)) -// ClockMMC3Counter(); -// _a12=A&0x1000; -//} - -void GenMMC3_Init(CartInfo *info, int prg, int chr, int wram, int battery) -{ - pwrap=GENPWRAP; - cwrap=GENCWRAP; - mwrap=GENMWRAP; - - wrams=wram<<10; - - PRGmask8[0]&=(prg>>13)-1; - CHRmask1[0]&=(chr>>10)-1; - CHRmask2[0]&=(chr>>11)-1; - - if(wram) - { - mmc3opts|=1; - WRAM=(uint8*)FCEU_gmalloc(wrams); - AddExState(WRAM, wrams, 0, "WRAM"); - } - - if(battery) - { - mmc3opts|=2; - info->SaveGame[0]=WRAM; - info->SaveGameLen[0]=wrams; - } - -// if(!chr) // duplicated CHR RAM set up -// { -// CHRRAM=(uint8*)FCEU_gmalloc(8192); -// CHRRAMSize=8192; -// SetupCartCHRMapping(0, CHRRAM, 8192, 1); -// AddExState(CHRRAM, 8192, 0, "CHRR"); -// } - - AddExState(MMC3_StateRegs, ~0, 0, 0); - - info->Power=GenMMC3Power; - info->Reset=MMC3RegReset; - info->Close=GenMMC3Close; - - if(info->CRC32 == 0x5104833e) // Kick Master - GameHBIRQHook = MMC3_hb_KickMasterHack; - else if(info->CRC32 == 0x5a6860f1 || info->CRC32 == 0xae280e20) // Shougi Meikan '92/'93 - GameHBIRQHook = MMC3_hb_KickMasterHack; - else if(info->CRC32 == 0xfcd772eb) // PAL Star Wars, similar problem as Kick Master. - GameHBIRQHook = MMC3_hb_PALStarWarsHack; - else - GameHBIRQHook=MMC3_hb; -// PPU_hook=MMC3_PPU; - GameStateRestore=GenMMC3Restore; -} - -// ---------------------------------------------------------------------- -// -------------------------- MMC3 Based Code --------------------------- -// ---------------------------------------------------------------------- - -// ---------------------------- Mapper 4 -------------------------------- - -static int hackm4=0;/* For Karnov, maybe others. BLAH. Stupid iNES format.*/ - -static void M4Power(void) -{ - GenMMC3Power(); - A000B=(hackm4^1)&1; - setmirror(hackm4); -} - -void Mapper4_Init(CartInfo *info) -{ - int ws=8; - - if((info->CRC32==0x93991433 || info->CRC32==0xaf65aa84)) - { - FCEU_printf("Low-G-Man can not work normally in the iNES format.\nThis game has been recognized by its CRC32 value, and the appropriate changes will be made so it will run.\nIf you wish to hack this game, you should use the UNIF format for your hack.\n\n"); - ws=0; - } - GenMMC3_Init(info,512,256,ws,info->battery); - info->Power=M4Power; - hackm4=info->mirror; -} - -// ---------------------------- Mapper 12 ------------------------------- static void M12CW(uint32 A, uint8 V) { @@ -408,191 +274,25 @@ static void M12CW(uint32 A, uint8 V) static DECLFW(M12Write) { - EXPREGS[0]=V&0x01; - EXPREGS[1]=(V&0x10)>>4; + EXPREGS[0]= V&0x01; + EXPREGS[1]= (V&0x10)>>4; } -static void M12Power(void) +static void M12_Power(void) { EXPREGS[0]=EXPREGS[1]=0; GenMMC3Power(); - SetWriteHandler(0x4100,0x5FFF,M12Write); + SetWriteHandler(0x4100,0x5FFF,M12Write); } void Mapper12_Init(CartInfo *info) { GenMMC3_Init(info, 512, 256, 8, info->battery); cwrap=M12CW; - info->Power=M12Power; + info->Power=M12_Power; AddExState(EXPREGS, 2, 0, "EXPR"); } -// ---------------------------- Mapper 37 ------------------------------- - -static void M37PW(uint32 A, uint8 V) -{ - if(EXPREGS[0]!=2) - V&=0x7; - else - V&=0xF; - V|=EXPREGS[0]<<3; - setprg8(A,V); -} - -static void M37CW(uint32 A, uint8 V) -{ - uint32 NV=V; - NV&=0x7F; - NV|=EXPREGS[0]<<6; - setchr1(A,NV); -} - -static DECLFW(M37Write) -{ - EXPREGS[0]=(V&6)>>1; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); -} - -static void M37Reset(void) -{ - EXPREGS[0]=0; - MMC3RegReset(); -} - -static void M37Power(void) -{ - EXPREGS[0]=0; - GenMMC3Power(); - SetWriteHandler(0x6000,0x7FFF,M37Write); -} - -void Mapper37_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); - pwrap=M37PW; - cwrap=M37CW; - info->Power=M37Power; - info->Reset=M37Reset; - AddExState(EXPREGS, 1, 0, "EXPR"); -} - -// ---------------------------- Mapper 44 ------------------------------- - -static void M44PW(uint32 A, uint8 V) -{ - uint32 NV=V; - if(EXPREGS[0]>=6) NV&=0x1F; - else NV&=0x0F; - NV|=EXPREGS[0]<<4; - setprg8(A,NV); -} - -static void M44CW(uint32 A, uint8 V) -{ - uint32 NV=V; - if(EXPREGS[0]<6) NV&=0x7F; - NV|=EXPREGS[0]<<7; - setchr1(A,NV); -} - -static DECLFW(M44Write) -{ - if(A&1) - { - EXPREGS[0]=V&7; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); - } - else - MMC3_CMDWrite(A,V); -} - -static void M44Power(void) -{ - EXPREGS[0]=0; - GenMMC3Power(); - SetWriteHandler(0xA000,0xBFFF,M44Write); -} - -void Mapper44_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap=M44CW; - pwrap=M44PW; - info->Power=M44Power; - AddExState(EXPREGS, 1, 0, "EXPR"); -} - -// ---------------------------- Mapper 45 ------------------------------- - -static void M45CW(uint32 A, uint8 V) -{ - - uint32 NV=V; - if(EXPREGS[2]&8) - NV&=(1<<((EXPREGS[2]&7)+1))-1; -// else -// NV&=0; - NV|=EXPREGS[0]|((EXPREGS[2]&0xF0)<<4); - setchr1(A,NV); - -} - -static void M45PW(uint32 A, uint8 V) -{ - V&=(EXPREGS[3]&0x3F)^0x3F; - V|=EXPREGS[1]; - setprg8(A,V); -} - -static DECLFW(M45Write) -{ - if(EXPREGS[3]&0x40) - { - WRAM[A-0x6000]=V; - return; - } - EXPREGS[EXPREGS[4]]=V; - EXPREGS[4]=(EXPREGS[4]+1)&3; -// if(!EXPREGS[4]) -// { -// FCEU_printf("CHROR %02x, PRGOR %02x, CHRAND %02x, PRGAND %02x\n",EXPREGS[0],EXPREGS[1],EXPREGS[2],EXPREGS[3]); -// FCEU_printf("CHR0 %03x, CHR1 %03x, PRG0 %03x, PRG1 %03x\n", -// (0x00&((1<<((EXPREGS[2]&7)+1))-1))|(EXPREGS[0]|((EXPREGS[2]&0xF0)<<4)), -// (0xFF&((1<<((EXPREGS[2]&7)+1))-1))|(EXPREGS[0]|((EXPREGS[2]&0xF0)<<4)), -// (0x00&((EXPREGS[3]&0x3F)^0x3F))|(EXPREGS[1]), -// (0xFF&((EXPREGS[3]&0x3F)^0x3F))|(EXPREGS[1])); -// } - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); -} - -static void M45Reset(void) -{ - EXPREGS[0]=EXPREGS[1]=EXPREGS[2]=EXPREGS[3]=EXPREGS[4]=0; - MMC3RegReset(); -} - -static void M45Power(void) -{ - setchr8(0); - GenMMC3Power(); - SetWriteHandler(0x6000,0x7FFF,M45Write); -} - -void Mapper45_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap=M45CW; - pwrap=M45PW; - info->Reset=M45Reset; - info->Power=M45Power; - AddExState(EXPREGS, 5, 0, "EXPR"); -} - -// ---------------------------- Mapper 47 ------------------------------- - static void M47PW(uint32 A, uint8 V) { V&=0xF; @@ -612,15 +312,15 @@ static DECLFW(M47Write) { EXPREGS[0]=V&1; FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); + FixMMC3CHR(MMC3_cmd); } -static void M47Power(void) +static void M47_Power(void) { EXPREGS[0]=0; GenMMC3Power(); SetWriteHandler(0x6000,0x7FFF,M47Write); -// SetReadHandler(0x6000,0x7FFF,0); + SetReadHandler(0x6000,0x7FFF,0); } void Mapper47_Init(CartInfo *info) @@ -628,11 +328,168 @@ void Mapper47_Init(CartInfo *info) GenMMC3_Init(info, 512, 256, 8, info->battery); pwrap=M47PW; cwrap=M47CW; - info->Power=M47Power; + info->Power=M47_Power; AddExState(EXPREGS, 1, 0, "EXPR"); } -// ---------------------------- Mapper 49 ------------------------------- +static void M44PW(uint32 A, uint8 V) +{ + uint32 NV=V; + if(EXPREGS[0]>=6) NV&=0x1F; + else NV&=0x0F; + NV|=EXPREGS[0]<<4; + setprg8(A,NV); +} + +static void M44CW(uint32 A, uint8 V) +{ + uint32 NV=V; + if(EXPREGS[0]<6) NV&=0x7F; + NV|=EXPREGS[0]<<7; + setchr1(A,NV); +} + +static DECLFW(Mapper44_write) +{ + if(A&1) + { + EXPREGS[0]=V&7; + FixMMC3PRG(MMC3_cmd); + FixMMC3CHR(MMC3_cmd); + } + else + Mapper4_write(A,V); +} + +static void M44_Power(void) +{ + EXPREGS[0]=0; + GenMMC3Power(); + SetWriteHandler(0xA000,0xBFFF,Mapper44_write); +} + +void Mapper44_Init(CartInfo *info) +{ + GenMMC3_Init(info, 512, 256, 8, info->battery); + cwrap=M44CW; + pwrap=M44PW; + info->Power=M44_Power; + AddExState(EXPREGS, 1, 0, "EXPR"); +} + +static void M52PW(uint32 A, uint8 V) +{ + uint32 NV=V; + NV&=0x1F^((EXPREGS[0]&8)<<1); + NV|=((EXPREGS[0]&6)|((EXPREGS[0]>>3)&EXPREGS[0]&1))<<4; + setprg8(A,NV); +} + +static void M52CW(uint32 A, uint8 V) +{ + uint32 NV=V; + NV&=0xFF^((EXPREGS[0]&0x40)<<1); + NV|=(((EXPREGS[0]>>3)&4)|((EXPREGS[0]>>1)&2)|((EXPREGS[0]>>6)&(EXPREGS[0]>>4)&1))<<7; + setchr1(A,NV); +} + +static DECLFW(Mapper52_write) +{ + if(EXPREGS[1]) + { + WRAM[A-0x6000]=V; + return; + } + EXPREGS[1]=1; + EXPREGS[0]=V; + FixMMC3PRG(MMC3_cmd); + FixMMC3CHR(MMC3_cmd); +} + +static void M52Reset(void) +{ + EXPREGS[0]=EXPREGS[1]=0; + MMC3RegReset(); +} + +static void M52Power(void) +{ + M52Reset(); + GenMMC3Power(); + SetWriteHandler(0x6000,0x7FFF,Mapper52_write); +} + +void Mapper52_Init(CartInfo *info) +{ + GenMMC3_Init(info, 512, 256, 8, info->battery); + cwrap=M52CW; + pwrap=M52PW; + info->Reset=M52Reset; + info->Power=M52Power; + AddExState(EXPREGS, 2, 0, "EXPR"); +} + +static void M45CW(uint32 A, uint8 V) +{ + uint32 NV=V; + if(EXPREGS[2]&8) + NV&=(1<<( (EXPREGS[2]&7)+1 ))-1; + else + NV&=0; + NV|=EXPREGS[0]|((EXPREGS[2]&0xF0)<<4); // &0x10(not 0xf0) is valid given the original + // description of mapper 45 by kevtris, + // but this fixes Super 8 in 1. + setchr1(A,NV); +} + +static void M45PW(uint32 A, uint8 V) +{ + //V=((V&(EXPREGS[3]^0xFF))&0x3f)|EXPREGS[1]; + V&=(EXPREGS[3]&0x3F)^0x3F; + V|=EXPREGS[1]; + //printf("$%04x, $%02x\n",A,V); + setprg8(A,V); +} + +static DECLFW(Mapper45_write) +{ + //printf("$%02x, %d\n",V,EXPREGS[4]); + if(EXPREGS[3]&0x40) + { + WRAM[A-0x6000]=V; + return; + } + EXPREGS[EXPREGS[4]]=V; + EXPREGS[4]=(EXPREGS[4]+1)&3; + FixMMC3PRG(MMC3_cmd); + FixMMC3CHR(MMC3_cmd); +} + +static void M45Reset(void) +{ + FCEU_dwmemset(EXPREGS,0,5); + MMC3RegReset(); +} + +static void M45Power(void) +{ + M45Reset(); + GenMMC3Power(); + SetWriteHandler(0x6000,0x7FFF,Mapper45_write); +} + +void Mapper45_Init(CartInfo *info) +{ + GenMMC3_Init(info, 512, 256, 8, info->battery); + + cwrap=M45CW; + pwrap=M45PW; + + info->Reset=M45Reset; + info->Power=M45Power; + + AddExState(EXPREGS, 5, 0, "EXPR"); +} static void M49PW(uint32 A, uint8 V) { @@ -656,6 +513,7 @@ static void M49CW(uint32 A, uint8 V) static DECLFW(M49Write) { + //printf("$%04x:$%02x\n",A,V); if(A001B&0x80) { EXPREGS[0]=V; @@ -685,765 +543,150 @@ void Mapper49_Init(CartInfo *info) pwrap=M49PW; info->Reset=M49Reset; info->Power=M49Power; + AddExState(EXPREGS, 1, 0, "EXPR"); } -// ---------------------------- Mapper 52 ------------------------------- - -static void M52PW(uint32 A, uint8 V) -{ - uint32 NV=V; - NV&=0x1F^((EXPREGS[0]&8)<<1); - NV|=((EXPREGS[0]&6)|((EXPREGS[0]>>3)&EXPREGS[0]&1))<<4; - setprg8(A,NV); -} - -static void M52CW(uint32 A, uint8 V) -{ - uint32 NV=V; - NV&=0xFF^((EXPREGS[0]&0x40)<<1); - NV|=(((EXPREGS[0]>>3)&4)|((EXPREGS[0]>>1)&2)|((EXPREGS[0]>>6)&(EXPREGS[0]>>4)&1))<<7; - setchr1(A,NV); -} - -static DECLFW(M52Write) -{ - if(EXPREGS[1]) - { - WRAM[A-0x6000]=V; - return; - } - EXPREGS[1]=1; - EXPREGS[0]=V; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); -} - -static void M52Reset(void) -{ - EXPREGS[0]=EXPREGS[1]=0; - MMC3RegReset(); -} - -static void M52Power(void) -{ - M52Reset(); - GenMMC3Power(); - SetWriteHandler(0x6000,0x7FFF,M52Write); -} - -void Mapper52_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap=M52CW; - pwrap=M52PW; - info->Reset=M52Reset; - info->Power=M52Power; - AddExState(EXPREGS, 2, 0, "EXPR"); -} - -// ---------------------------- Mapper 74 ------------------------------- - -static void M74CW(uint32 A, uint8 V) -{ - if((V==8)||(V==9)) //Di 4 Ci - Ji Qi Ren Dai Zhan (As).nes, Ji Jia Zhan Shi (As).nes - setchr1r(0x10,A,V); - else - setchr1r(0,A,V); -} - -void Mapper74_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap=M74CW; - CHRRAMSize=2048; - CHRRAM=(uint8*)FCEU_gmalloc(CHRRAMSize); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); - AddExState(CHRRAM, CHRRAMSize, 0, "CHRR"); -} - -// ---------------------------- Mapper 114 ------------------------------ - -static uint8 cmdin; -uint8 m114_perm[8] = {0, 3, 1, 5, 6, 7, 2, 4}; - -static void M114PWRAP(uint32 A, uint8 V) -{ - if(EXPREGS[0]&0x80) - { - setprg16(0x8000,EXPREGS[0]&0xF); - setprg16(0xC000,EXPREGS[0]&0xF); - } - else - setprg8(A,V&0x3F); -} - -static DECLFW(M114Write) -{ - if(A==0xE003) - { - IRQa=1; - IRQLatch=V; - IRQReload=1; - } - else if(A==0xE002) - { - IRQa=0; - X6502_IRQEnd(FCEU_IQEXT); - } - else switch(A&0xE000) - { - case 0x8000: setmirror((V&1)^1); break; - case 0xA000: MMC3_CMDWrite(0x8000,(V&0xC0)|(m114_perm[V&7])); cmdin=1; break; - case 0xC000: if(!cmdin) break; - MMC3_CMDWrite(0x8001,V); - cmdin=0; - break; - } -} - -static DECLFW(M114ExWrite) -{ - if(A<=0x7FFF) - { - EXPREGS[0]=V; - FixMMC3PRG(MMC3_cmd); - } -} - -static void M114Power(void) -{ - GenMMC3Power(); - SetWriteHandler(0x8000,0xFFFF,M114Write); - SetWriteHandler(0x5000,0x7FFF,M114ExWrite); -} - -static void M114Reset(void) -{ - EXPREGS[0]=0; - MMC3RegReset(); -} - -void Mapper114_Init(CartInfo *info) -{ - GenMMC3_Init(info, 256, 256, 0, 0); - pwrap=M114PWRAP; - info->Power=M114Power; - info->Reset=M114Reset; - AddExState(EXPREGS, 1, 0, "EXPR"); - AddExState(&cmdin, 1, 0, "CMDIN"); -} - -// ---------------------------- Mapper 115 ------------------------------ - static void M115PW(uint32 A, uint8 V) { - if(EXPREGS[0]&0x80) - setprg32(0x8000,(EXPREGS[0]&7)>>1); - else - setprg8(A,V); + setprg8(A,V); + if(EXPREGS[0]&0x80) + { + setprg16(0x8000,EXPREGS[0]&7); + } } static void M115CW(uint32 A, uint8 V) { - setchr1(A,(uint32)V|((EXPREGS[1]&1)<<8)); + setchr1(A,(uint32)V|((EXPREGS[1]&1)<<8)); } static DECLFW(M115Write) { if(A==0x6000) - EXPREGS[0]=V; + EXPREGS[0]=V; else if(A==0x6001) - EXPREGS[1]=V; + EXPREGS[1]=V; FixMMC3PRG(MMC3_cmd); } static void M115Power(void) { GenMMC3Power(); - SetWriteHandler(0x4100,0x7FFF,M115Write); - SetReadHandler(0x4100,0x7FFF,0); + SetWriteHandler(0x6000,0x7FFF,M115Write); + SetReadHandler(0x6000,0x7FFF,0); } void Mapper115_Init(CartInfo *info) { - GenMMC3_Init(info, 128, 512, 0, 0); + GenMMC3_Init(info, 512, 256, 0, 0); cwrap=M115CW; pwrap=M115PW; info->Power=M115Power; AddExState(EXPREGS, 2, 0, "EXPR"); } -// ---------------------------- Mapper 116 ------------------------------ +static void M116PW(uint32 A, uint8 V) +{ + // setprg8(A,(V&0xF)|((EXPREGS[1]&0x2)<<3)); + // setprg8(A,(V&7)|(<<3)); + setprg8(A,V); + if(!(EXPREGS[1]&2)) + { + setprg16(0x8000,1); //EXPREGS[2]); + } +} static void M116CW(uint32 A, uint8 V) { -// setchr1(A,V|((EXPREGS[0]&0x4)<<6)); - if(EXPREGS[0]&2) - setchr8r(0x10,0); - else - setchr1(A,V); + //if(EXPREGS[1]&2) + setchr1(A,V|((EXPREGS[0]&0x4)<<6)); + //else + //{ + // setchr1(A,(V&7)|((EXPREGS[2])<<3)); + //} } static DECLFW(M116Write) { - EXPREGS[0]=V; + if(A==0x4100) {EXPREGS[0]=V;setmirror(V&1);} + else if(A==0x4141) EXPREGS[1]=V; + else if(A==0xa000) EXPREGS[2]=V; + else if(A==0x4106) EXPREGS[3]=V; + FixMMC3PRG(MMC3_cmd); FixMMC3CHR(MMC3_cmd); +// MIRROR_SET(0); + //printf("Wr: $%04x:$%02x, $%04x, %d, %d\n",A,V,X.PC,timestamp,scanline); +} +static DECLFW(M116Write2) +{ + //printf("Wr2: %04x:%02x\n",A,V); } - static void M116Power(void) { + + EXPREGS[0]=0; + EXPREGS[1]=2; + EXPREGS[2]=0; + EXPREGS[3]=0; + GenMMC3Power(); - SetWriteHandler(0x4100,0x4100,M116Write); + + SetWriteHandler(0x4020,0x7fff,M116Write); + SetWriteHandler(0xa000,0xbfff,M116Write2); } void Mapper116_Init(CartInfo *info) { - GenMMC3_Init(info, 128, 512, 0, 0); + GenMMC3_Init(info, 512, 256, 0, 0); cwrap=M116CW; + pwrap=M116PW; info->Power=M116Power; - CHRRAM = (uint8*)FCEU_gmalloc(8192); - SetupCartCHRMapping(0x10, CHRRAM, 8192, 1); AddExState(EXPREGS, 4, 0, "EXPR"); } -// ---------------------------- Mapper 118 ------------------------------ - -static uint8 PPUCHRBus; -static uint8 TKSMIR[8]; - -static void FP_FASTAPASS(1) TKSPPU(uint32 A) -{ - A&=0x1FFF; - A>>=10; - PPUCHRBus=A; - setmirror(MI_0+TKSMIR[A]); -} - -static void TKSWRAP(uint32 A, uint8 V) -{ - TKSMIR[A>>10]=V>>7; - setchr1(A,V&0x7F); - if(PPUCHRBus==(A>>10)) - setmirror(MI_0+(V>>7)); -} - -void Mapper118_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap=TKSWRAP; - mwrap=GENNOMWRAP; - PPU_hook=TKSPPU; - AddExState(&PPUCHRBus, 1, 0, "PPUC"); -} - -// ---------------------------- Mapper 119 ------------------------------ - -static void TQWRAP(uint32 A, uint8 V) -{ - setchr1r((V&0x40)>>2,A,V&0x3F); -} - -void Mapper119_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 64, 0, 0); - cwrap=TQWRAP; - CHRRAMSize=8192; - CHRRAM=(uint8*)FCEU_gmalloc(CHRRAMSize); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); -} - -// ---------------------------- Mapper 165 ------------------------------ - static void M165CW(uint32 A, uint8 V) { - if(V==0) - setchr4r(0x10,A,0); + //printf("%04x:%02x\n",A,V); + if(V < 0x4) + setchr1r(0x10, A, V); else - setchr4(A,V>>2); -} - -static void M165PPUFD(void) -{ - if(EXPREGS[0]==0xFD) - { - M165CW(0x0000,DRegBuf[0]); - M165CW(0x1000,DRegBuf[2]); - } -} - -static void M165PPUFE(void) -{ - if(EXPREGS[0]==0xFE) - { - M165CW(0x0000,DRegBuf[1]); - M165CW(0x1000,DRegBuf[4]); - } -} - -static void M165CWM(uint32 A, uint8 V) -{ - if(((MMC3_cmd&0x7)==0)||((MMC3_cmd&0x7)==2)) - M165PPUFD(); - if(((MMC3_cmd&0x7)==1)||((MMC3_cmd&0x7)==4)) - M165PPUFE(); -} - -static void FP_FASTAPASS(1) M165PPU(uint32 A) -{ - if((A&0x1FF0)==0x1FD0) - { - EXPREGS[0]=0xFD; - M165PPUFD(); - } else if((A&0x1FF0)==0x1FE0) - { - EXPREGS[0]=0xFE; - M165PPUFE(); - } -} - -static void M165Power(void) -{ - EXPREGS[0]=0xFD; - GenMMC3Power(); + setchr1(A,V); } void Mapper165_Init(CartInfo *info) { GenMMC3_Init(info, 512, 128, 8, info->battery); - cwrap=M165CWM; - PPU_hook=M165PPU; - info->Power=M165Power; - CHRRAMSize = 4096; - CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSize); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); - AddExState(CHRRAM, CHRRAMSize, 0, "CHRR"); - AddExState(EXPREGS, 4, 0, "EXPR"); + cwrap=M165CW; + CHRRAM = (uint8*)FCEU_gmalloc(8192); + CHRRAMSize = 8192; + AddExState(CHRRAM, 8192, 0, "chrr"); + SetupCartCHRMapping(0x10, CHRRAM, 8192, 1); } -// ---------------------------- Mapper 182 ------------------------------ -// òàáëèöà ïåðìóòàöè àíàëîãè÷íà 114 ìàïïåðó, ðåãèñòðû ìàïïåðà ãîðàçäî ñëîæíåå, -// ÷åì èñïîëüçóþòñÿ çäåñü, õîòÿ âñå ïðåêðàñíî ðàáîòàåò. - -//static uint8 m182_perm[8] = {0, 3, 1, 5, 6, 7, 2, 4}; -static DECLFW(M182Write) +static DECLFW(Mapper250_write) { - switch(A&0xF003) - { - case 0x8001: setmirror((V&1)^1); break; - case 0xA000: MMC3_CMDWrite(0x8000,m114_perm[V&7]); break; - case 0xC000: MMC3_CMDWrite(0x8001,V); break; - case 0xE003: if(V) - { - IRQLatch=V; - IRQReload=1; - IRQa=1; - } - X6502_IRQEnd(FCEU_IQEXT); - break; - } + Mapper4_write((A&0xE000)|((A&0x400)>>10),A&0xFF); } -static void M182Power(void) +static DECLFW(M250_IRQWrite) { - GenMMC3Power(); - SetWriteHandler(0x8000,0xFFFF,M182Write); + MMC3_IRQWrite((A&0xE000)|((A&0x400)>>10),A&0xFF); } -void Mapper182_Init(CartInfo *info) +static void M250_Power(void) { - GenMMC3_Init(info, 256, 256, 0, 0); - info->Power=M182Power; + GenMMC3Power(); + SetWriteHandler(0x8000,0xBFFF,Mapper250_write); + SetWriteHandler(0xC000,0xFFFF,M250_IRQWrite); } -// ---------------------------- Mapper 191 ------------------------------ - -static void M191CW(uint32 A, uint8 V) -{ - setchr1r((V&0x80)>>3,A,V); -} - -void Mapper191_Init(CartInfo *info) -{ - GenMMC3_Init(info, 256, 256, 8, info->battery); - cwrap=M191CW; - CHRRAMSize=2048; - CHRRAM=(uint8*)FCEU_gmalloc(CHRRAMSize); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); - AddExState(CHRRAM, CHRRAMSize, 0, "CHRR"); -} - -// ---------------------------- Mapper 192 ------------------------------- - -static void M192CW(uint32 A, uint8 V) -{ - if((V==8)||(V==9)||(V==0xA)||(V==0xB)) //Ying Lie Qun Xia Zhuan (Chinese), - setchr1r(0x10,A,V); - else - setchr1r(0,A,V); -} - -void Mapper192_Init(CartInfo *info) +void Mapper250_Init(CartInfo *info) { GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap=M192CW; - CHRRAMSize=4096; - CHRRAM=(uint8*)FCEU_gmalloc(CHRRAMSize); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); - AddExState(CHRRAM, CHRRAMSize, 0, "CHRR"); + info->Power=M250_Power; } -// ---------------------------- Mapper 194 ------------------------------- - -static void M194CW(uint32 A, uint8 V) -{ - if(V<=1) //Dai-2-Ji - Super Robot Taisen (As).nes - setchr1r(0x10,A,V); - else - setchr1r(0,A,V); -} - -void Mapper194_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap=M194CW; - CHRRAMSize=2048; - CHRRAM=(uint8*)FCEU_gmalloc(CHRRAMSize); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); - AddExState(CHRRAM, CHRRAMSize, 0, "CHRR"); -} - -// ---------------------------- Mapper 195 ------------------------------- -static uint8 *wramtw; -static uint16 wramsize; - -static void M195CW(uint32 A, uint8 V) -{ - if(V<=3) // Crystalis (c).nes, Captain Tsubasa Vol 2 - Super Striker (C) - setchr1r(0x10,A,V); - else - setchr1r(0,A,V); -} - -static void M195Power(void) -{ - GenMMC3Power(); - setprg4r(0x10,0x5000,0); - SetWriteHandler(0x5000,0x5fff,CartBW); - SetReadHandler(0x5000,0x5fff,CartBR); -} - -static void M195Close(void) -{ - if(wramtw) - FCEU_gfree(wramtw); - wramtw=NULL; -} - -void Mapper195_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap=M195CW; - info->Power=M195Power; - info->Close=M195Close; - CHRRAMSize=4096; - CHRRAM=(uint8*)FCEU_gmalloc(CHRRAMSize); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); - wramsize=4096; - wramtw=(uint8*)FCEU_gmalloc(wramsize); - SetupCartPRGMapping(0x10, wramtw, wramsize, 1); - AddExState(CHRRAM, CHRRAMSize, 0, "CHRR"); - AddExState(wramtw, wramsize, 0, "WRAMTW"); -} - -// ---------------------------- Mapper 198 ------------------------------- - -static void M198PW(uint32 A, uint8 V) -{ - if(V>=0x50) // Tenchi o Kurau II - Shokatsu Koumei Den (J) (C).nes - setprg8(A,V&0x4F); - else - setprg8(A,V); -} - -static void M198CW(uint32 A, uint8 V) -{ - if(A==0x0000) - setchr4(0x0000,V>>1); - else if(A==0x1000) - setchr2(0x1000,V); - else if(A==0x1400) - setchr2(0x1800,V); -} - -void Mapper198_Init(CartInfo *info) -{ - GenMMC3_Init(info, 1024, 256, 8, info->battery); - pwrap=M198PW; - cwrap=M198CW; - info->Power=M195Power; - info->Close=M195Close; - wramsize=4096; - wramtw=(uint8*)FCEU_gmalloc(wramsize); - SetupCartPRGMapping(0x10, wramtw, wramsize, 1); - AddExState(wramtw, wramsize, 0, "WRAMTW"); -} - -// ---------------------------- Mapper 205 ------------------------------ - -static void M205PW(uint32 A, uint8 V) -{ - if(EXPREGS[0]&2) - setprg8(A,(V&0x0f)|((EXPREGS[0]&3)<<4)); - else - setprg8(A,(V&0x1f)|((EXPREGS[0]&3)<<4)); -} - -static void M205CW(uint32 A, uint8 V) -{ - setchr1(A,V|((EXPREGS[0]&3)<<7)); -} - -static DECLFW(M205Write) -{ - if((A&0x6800)==0x6800) EXPREGS[0]= V; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); -} - -static void M205Reset(void) -{ - EXPREGS[0]=0; - MMC3RegReset(); -} - -static void M205Power(void) -{ - GenMMC3Power(); - SetWriteHandler(0x4020,0x7FFF,M205Write); -} - -void Mapper205_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, 0); - pwrap=M205PW; - cwrap=M205CW; - info->Power=M205Power; - info->Reset=M205Reset; - AddExState(EXPREGS, 1, 0, "EXPR"); -} - -// ---------------------------- Mapper 215 ------------------------------ - -static uint8 m215_perm[8] = {0, 2, 5, 3, 6, 1, 7, 4}; -//static uint8 m215_perm[8] = {0, 1, 2, 3, 4, 5, 6, 7}; - -static void M215CW(uint32 A, uint8 V) -{ - if(EXPREGS[1]&0x04) - setchr1(A,V|0x100); - else - setchr1(A,(V&0x7F)|((EXPREGS[1]&0x10)<<3)); -} - -static void M215PW(uint32 A, uint8 V) -{ - if(EXPREGS[0]&0x80) - { - setprg16(0x8000,(EXPREGS[0]&0x0F)|(EXPREGS[1]&0x10)); - setprg16(0xC000,(EXPREGS[0]&0x0F)|(EXPREGS[1]&0x10)); - } - else if(EXPREGS[1]&0x08) - setprg8(A,(V&0x1F)|0x20); - else - setprg8(A,(V&0x0F)|(EXPREGS[1]&0x10)); -} - -static DECLFW(M215Write) -{ -// FCEU_printf("bs %04x %02x\n",A,V); - if(!(EXPREGS[2])) - { - if(A >= 0xc000) - MMC3_IRQWrite(A,V); - else - MMC3_CMDWrite(A,V); - } - else switch(A&0xE001) - { - case 0xC001: IRQLatch=V; break; - case 0xA001: IRQReload=1; break; - case 0xE001: IRQa=1; break; - case 0xE000: X6502_IRQEnd(FCEU_IQEXT); IRQa=0; break; - case 0xC000: setmirror(((V|(V>>7))&1)^1); break; - case 0xA000: MMC3_CMDWrite(0x8000,(V&0xC0)|(m215_perm[V&7])); cmdin=1; break; - case 0x8001: if(!cmdin) break; - MMC3_CMDWrite(0x8001,V); - cmdin=0; - break; - } -} - -static DECLFW(M215ExWrite) -{ -// FCEU_printf("bs %04x %02x (%04x)\n",A,V,A&0x5007); - switch(A) - { - case 0x6000: - case 0x5000: - EXPREGS[0]=V; - FixMMC3PRG(MMC3_cmd); - break; - case 0x6001: - case 0x5001: - EXPREGS[1]=V; - FixMMC3CHR(MMC3_cmd); - break; - case 0x6007: - case 0x5007: - EXPREGS[2]=V; - MMC3RegReset(); - break; - } -} - -static void M215Power(void) -{ - EXPREGS[0]=0; - EXPREGS[1]=0xFF; - EXPREGS[2]=4; - GenMMC3Power(); - SetWriteHandler(0x8000,0xFFFF,M215Write); - SetWriteHandler(0x5000,0x7FFF,M215ExWrite); -} - -void Mapper215_Init(CartInfo *info) -{ - GenMMC3_Init(info, 256, 256, 0, 0); - cwrap=M215CW; - pwrap=M215PW; - info->Power=M215Power; - AddExState(EXPREGS, 3, 0, "EXPR"); - AddExState(&cmdin, 1, 0, "CMDIN"); -} - -// ---------------------------- Mapper 217 ------------------------------ - -static uint8 m217_perm[8] = {0, 6, 3, 7, 5, 2, 4, 1}; - -static void M217CW(uint32 A, uint8 V) -{ - if(EXPREGS[1]&0x08) - setchr1(A,V|((EXPREGS[1]&3)<<8)); - else - setchr1(A,(V&0x7F)|((EXPREGS[1]&3)<<8)|((EXPREGS[1]&0x10)<<3)); -} - -static void M217PW(uint32 A, uint8 V) -{ - if(EXPREGS[0]&0x80) - { - setprg16(0x8000,(EXPREGS[0]&0x0F)|((EXPREGS[1]&3)<<4)); - setprg16(0xC000,(EXPREGS[0]&0x0F)|((EXPREGS[1]&3)<<4)); - } - else if(EXPREGS[1]&0x08) - setprg8(A,(V&0x1F)|((EXPREGS[1]&3)<<5)); - else - setprg8(A,(V&0x0F)|((EXPREGS[1]&3)<<5)|(EXPREGS[1]&0x10)); -} - -static DECLFW(M217Write) -{ - if(!EXPREGS[2]) - { - if(A >= 0xc000) - MMC3_IRQWrite(A, V); - else - MMC3_CMDWrite(A,V); - } - else switch(A&0xE001) - { - case 0x8000: IRQCount=V; break; - case 0xE000: X6502_IRQEnd(FCEU_IQEXT);IRQa=0; break; - case 0xC001: IRQa=1; break; - case 0xA001: setmirror((V&1)^1); break; - case 0x8001: MMC3_CMDWrite(0x8000,(V&0xC0)|(m217_perm[V&7])); cmdin=1; break; - case 0xA000: if(!cmdin) break; - MMC3_CMDWrite(0x8001,V); - cmdin=0; - break; - } -} - -static DECLFW(M217ExWrite) -{ - switch(A) - { - case 0x5000: - EXPREGS[0]=V; - FixMMC3PRG(MMC3_cmd); - break; - case 0x5001: - EXPREGS[1]=V; - FixMMC3PRG(MMC3_cmd); - break; - case 0x5007: - EXPREGS[2]=V; - break; - } -} - -static void M217Power(void) -{ - EXPREGS[0]=0; - EXPREGS[1]=0xFF; - EXPREGS[2]=3; - GenMMC3Power(); - SetWriteHandler(0x8000,0xFFFF,M217Write); - SetWriteHandler(0x5000,0x7FFF,M217ExWrite); -} - -void Mapper217_Init(CartInfo *info) -{ - GenMMC3_Init(info, 256, 256, 0, 0); - cwrap=M217CW; - pwrap=M217PW; - info->Power=M217Power; - AddExState(EXPREGS, 3, 0, "EXPR"); - AddExState(&cmdin, 1, 0, "CMDIN"); -} - -// ---------------------------- Mapper 245 ------------------------------ - -static void M245CW(uint32 A, uint8 V) -{ - setchr1(A,V&7); - EXPREGS[0]=V; - FixMMC3PRG(MMC3_cmd); -} - -static void M245PW(uint32 A, uint8 V) -{ - setprg8(A,(V&0x3F)|((EXPREGS[0]&2)<<5)); -} - -static void M245Power(void) -{ - EXPREGS[0]=0; - GenMMC3Power(); -} - -void Mapper245_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap=M245CW; - pwrap=M245PW; - info->Power=M245Power; - AddExState(EXPREGS, 1, 0, "EXPR"); -} - -// ---------------------------- Mapper 249 ------------------------------ - static void M249PW(uint32 A, uint8 V) { if(EXPREGS[0]&0x2) @@ -1462,11 +705,11 @@ static void M249PW(uint32 A, uint8 V) static void M249CW(uint32 A, uint8 V) { if(EXPREGS[0]&0x2) - V=(V&3)|((V>>1)&4)|((V>>4)&8)|((V>>2)&0x10)|((V<<3)&0x20)|((V<<2)&0xC0); + V=(V&3)|((V>>1)&4)|((V>>4)&8)|((V>>2)&0x10)|((V<<3)&0x20)|((V<<2)&0xC0); setchr1(A,V); } -static DECLFW(M249Write) +static DECLFW(Mapper249_write) { EXPREGS[0]=V; FixMMC3PRG(MMC3_cmd); @@ -1477,7 +720,7 @@ static void M249Power(void) { EXPREGS[0]=0; GenMMC3Power(); - SetWriteHandler(0x5000,0x5000,M249Write); + SetWriteHandler(0x5000,0x5000,Mapper249_write); } void Mapper249_Init(CartInfo *info) @@ -1489,66 +732,263 @@ void Mapper249_Init(CartInfo *info) AddExState(EXPREGS, 1, 0, "EXPR"); } -// ---------------------------- Mapper 250 ------------------------------ - -static DECLFW(M250Write) +static void M245CW(uint32 A, uint8 V) { - MMC3_CMDWrite((A&0xE000)|((A&0x400)>>10),A&0xFF); + //printf("$%04x:$%02x\n",A,V); + //setchr1(A,V); + // + EXPREGS[0]=V; + FixMMC3PRG(MMC3_cmd); } -static DECLFW(M250IRQWrite) +static void M245PW(uint32 A, uint8 V) { - MMC3_IRQWrite((A&0xE000)|((A&0x400)>>10),A&0xFF); + setprg8(A,(V&0x3F)|((EXPREGS[0]&2)<<5)); + //printf("%d\n",(V&0x3F)|((EXPREGS[0]&2)<<5)); } -static void M250_Power(void) +static void M245Power(void) { + EXPREGS[0]=0; GenMMC3Power(); - SetWriteHandler(0x8000,0xBFFF,M250Write); - SetWriteHandler(0xC000,0xFFFF,M250IRQWrite); } -void Mapper250_Init(CartInfo *info) +void Mapper245_Init(CartInfo *info) { GenMMC3_Init(info, 512, 256, 8, info->battery); - info->Power=M250_Power; + info->Power=M245Power; + cwrap=M245CW; + pwrap=M245PW; + AddExState(EXPREGS, 1, 0, "EXPR"); } -// ---------------------------- Mapper 254 ------------------------------ - -static DECLFR(MR254WRAM) +void m74p(uint32 a, uint8 v) { - if(EXPREGS[0]) - return WRAM[A-0x6000]; + setprg8(a,v&0x3f); +} + +static void m74kie(uint32 a, uint8 v) +{ + if(v==((PRGsize[0]>>16)&0x08) || v==1+((PRGsize[0]>>16)&0x08)) + setchr1r(0x10,a,v); + else + setchr1r(0x0,a,v); +} + +void Mapper74_Init(CartInfo *info) +{ + GenMMC3_Init(info, 512, 256, 8, info->battery); + cwrap=m74kie; + pwrap=m74p; + CHRRAM=(uint8*)FCEU_gmalloc(2048); + CHRRAMSize=2048; + SetupCartCHRMapping(0x10, CHRRAM, 2048, 1); + AddExState(CHRRAM, 2048, 0, "CHRR"); +} + +static void m148kie(uint32 a, uint8 v) +{ + if(v==128 || v==129) + setchr1r(0x10,a,v); + else + setchr1r(0x0,a,v); +} + +void Mapper148_Init(CartInfo *info) +{ + GenMMC3_Init(info, 512, 256, 8, info->battery); + cwrap=m148kie; + pwrap=m74p; + CHRRAM=(uint8*)FCEU_gmalloc(2048); + CHRRAMSize=2048; + SetupCartCHRMapping(0x10, CHRRAM, 2048, 1); + AddExState(CHRRAM, 2048, 0, "CHRR"); +} + +static void FP_FASTAPASS(1) TKSPPU(uint32 A) +{ + //static uint8 z; + //if(A>=0x2000 || type<0) return; + //if(type<0) return; + A&=0x1FFF; + //if(scanline>=140 && scanline<=200) {setmirror(MI_1);return;} + //if(scanline>=140 && scanline<=200) + // if(scanline>=190 && scanline<=200) {setmirror(MI_1);return;} + // setmirror(MI_1); + //printf("$%04x\n",A); + + A>>=10; + PPUCHRBus=A; + setmirror(MI_0+TKSMIR[A]); +} + +static void TKSWRAP(uint32 A, uint8 V) +{ + TKSMIR[A>>10]=V>>7; + setchr1(A,V&0x7F); + if(PPUCHRBus==(A>>10)) + setmirror(MI_0+(V>>7)); +} + + +static void TQWRAP(uint32 A, uint8 V) +{ + setchr1r((V&0x40)>>2,A,V&0x3F); +} + +static int wrams; + +static DECLFW(MBWRAM) +{ + WRAM[A-0x6000]=V; +} + +static DECLFR(MAWRAM) +{ + return(WRAM[A-0x6000]); +} + +static DECLFW(MBWRAMMMC6) +{ + WRAM[A&0x3ff]=V; +} + +static DECLFR(MAWRAMMMC6) +{ + return(WRAM[A&0x3ff]); +} + +static void GenMMC3Power(void) +{ + SetWriteHandler(0x8000,0xBFFF,Mapper4_write); + SetReadHandler(0x8000,0xFFFF,CartBR); + SetWriteHandler(0xC000,0xFFFF,MMC3_IRQWrite); + A001B=A000B=0; + setmirror((A000B&1)^1); + if(mmc3opts&1) + { + if(wrams==1024) + { + FCEU_CheatAddRAM(1,0x7000,WRAM); + SetReadHandler(0x7000,0x7FFF,MAWRAMMMC6); + SetWriteHandler(0x7000,0x7FFF,MBWRAMMMC6); + } else - return WRAM[A-0x6000]^EXPREGS[1]; -} - -static DECLFW(M254Write) -{ - switch (A) { - case 0x8000: EXPREGS[0]=0xff; - break; - case 0xA001: EXPREGS[1]=V; + { + FCEU_CheatAddRAM(wrams/1024,0x6000,WRAM); + SetReadHandler(0x6000,0x6000+wrams-1,MAWRAM); + SetWriteHandler(0x6000,0x6000+wrams-1,MBWRAM); + } + if(!(mmc3opts&2)) + FCEU_dwmemset(WRAM,0,wrams); } - MMC3_CMDWrite(A,V); + MMC3RegReset(); + if(CHRRAM) + FCEU_dwmemset(CHRRAM,0,CHRRAMSize); } -static void M254_Power(void) +static void GenMMC3Close(void) +{ + if(CHRRAM) + FCEU_gfree(CHRRAM); + if(WRAM) + FCEU_gfree(WRAM); + CHRRAM=WRAM=NULL; +} + +void GenMMC3_Init(CartInfo *info, int prg, int chr, int wram, int battery) +{ + pwrap=GENPWRAP; + cwrap=GENCWRAP; + mwrap=GENMWRAP; + + wrams=wram*1024; + + PRGmask8[0]&=(prg>>13)-1; + CHRmask1[0]&=(chr>>10)-1; + CHRmask2[0]&=(chr>>11)-1; + + if(wram) + { + mmc3opts|=1; + WRAM=(uint8*)FCEU_gmalloc(wram*1024); + AddExState(WRAM, wram*1024, 0, "WRAM"); + } + + if(battery) + { + mmc3opts|=2; + + info->SaveGame[0]=WRAM; + info->SaveGameLen[0]=wram*1024; + } + + if(!chr) + { + CHRRAM=(uint8*)FCEU_gmalloc(8192); + CHRRAMSize=8192; + SetupCartCHRMapping(0, CHRRAM, 8192, 1); + AddExState(CHRRAM, 8192, 0, "CHRR"); + } + AddExState(MMC3_StateRegs, ~0, 0, 0); + + info->Power=GenMMC3Power; + info->Reset=MMC3RegReset; + info->Close=GenMMC3Close; + + //PPU_hook=MMC3_PPUIRQ; + + if(info->CRC32 == 0x5104833e) // Kick Master + GameHBIRQHook = MMC3_hb_KickMasterHack; + else if(info->CRC32 == 0x5a6860f1 || info->CRC32 == 0xae280e20) // Shougi Meikan '92/'93 + GameHBIRQHook = MMC3_hb_KickMasterHack; + else if(info->CRC32 == 0xfcd772eb) // PAL Star Wars, similar problem as Kick Master. + GameHBIRQHook = MMC3_hb_PALStarWarsHack; + else + GameHBIRQHook=MMC3_hb; + GameStateRestore=genmmc3restore; +} + +static int hackm4=0; /* For Karnov, maybe others. BLAH. Stupid iNES format.*/ + +static void Mapper4Power(void) { GenMMC3Power(); - SetWriteHandler(0x8000,0xBFFF,M254Write); - SetReadHandler(0x6000,0x7FFF,MR254WRAM); + A000B=(hackm4^1)&1; + setmirror(hackm4); } -void Mapper254_Init(CartInfo *info) +void Mapper4_Init(CartInfo *info) { - GenMMC3_Init(info, 128, 128, 8, info->battery); - info->Power=M254_Power; - AddExState(EXPREGS, 2, 0, "EXPR"); + int ws=8; + + if((info->CRC32==0x93991433 || info->CRC32==0xaf65aa84)) + { + FCEU_printf("Low-G-Man can not work normally in the iNES format.\nThis game has been recognized by its CRC32 value, and the appropriate changes will be made so it will run.\nIf you wish to hack this game, you should use the UNIF format for your hack.\n\n"); + ws=0; + } + GenMMC3_Init(info,512,256,ws,info->battery); + info->Power=Mapper4Power; + hackm4=info->mirror; } -// ---------------------------- UNIF Boards ----------------------------- +void Mapper118_Init(CartInfo *info) +{ + GenMMC3_Init(info, 512, 256, 8, info->battery); + cwrap=TKSWRAP; + mwrap=GENNOMWRAP; + PPU_hook=TKSPPU; + AddExState(&PPUCHRBus, 1, 0, "PPUC"); +} + +void Mapper119_Init(CartInfo *info) +{ + GenMMC3_Init(info, 512, 64, 0, 0); + cwrap=TQWRAP; + CHRRAM=(uint8*)FCEU_gmalloc(8192); + CHRRAMSize=8192; + SetupCartCHRMapping(0x10, CHRRAM, 8192, 1); +} void TEROM_Init(CartInfo *info) { @@ -1602,11 +1042,12 @@ void TQROM_Init(CartInfo *info) { GenMMC3_Init(info, 512, 64, 0, 0); cwrap=TQWRAP; + CHRRAM=(uint8*)FCEU_gmalloc(8192); CHRRAMSize=8192; - CHRRAM=(uint8*)FCEU_gmalloc(CHRRAMSize); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); + SetupCartCHRMapping(0x10, CHRRAM, 8192, 1); } +/* MMC6 board */ void HKROM_Init(CartInfo *info) { GenMMC3_Init(info, 512, 512, 1, info->battery); diff --git a/source/fceultra/mbshare/mmc3.h b/source/fceultra/mbshare/mmc3.h deleted file mode 100644 index 937f80f..0000000 --- a/source/fceultra/mbshare/mmc3.h +++ /dev/null @@ -1,25 +0,0 @@ -extern uint8 MMC3_cmd; -extern uint8 *WRAM; -extern uint8 *CHRRAM; -extern uint8 EXPREGS[8]; -extern uint8 DRegBuf[8]; - -#undef IRQCount -#undef IRQLatch -#undef IRQa -extern uint8 IRQCount,IRQLatch,IRQa; -extern uint8 IRQReload; - -extern void (*pwrap)(uint32 A, uint8 V); -extern void (*cwrap)(uint32 A, uint8 V); -extern void (*mwrap)(uint8 V); - -void GenMMC3Power(void); -void GenMMC3Restore(int version); -void MMC3RegReset(void); -void FixMMC3PRG(int V); -void FixMMC3CHR(int V); -DECLFW(MMC3_CMDWrite); -DECLFW(MMC3_IRQWrite); - -void GenMMC3_Init(CartInfo *info, int prg, int chr, int wram, int battery); diff --git a/source/fceultra/mbshare/mmc5.c b/source/fceultra/mbshare/mmc5.c index ce3fc9c..b64b236 100644 --- a/source/fceultra/mbshare/mmc5.c +++ b/source/fceultra/mbshare/mmc5.c @@ -28,13 +28,13 @@ static void (*psfun)(void); void MMC5RunSound(int Count); void MMC5RunSoundHQ(void); -static INLINE void MMC5SPRVROM_BANK1(uint32 A,uint32 V) +static INLINE void MMC5SPRVROM_BANK1(uint32 A,uint32 V) { - if(CHRptr[0]) - { - V&=CHRmask1[0]; - MMC5SPRVPage[(A)>>10]=&CHRptr[0][(V)<<10]-(A); - } + if(CHRptr[0]) + { + V&=CHRmask1[0]; + MMC5SPRVPage[(A)>>10]=&CHRptr[0][(V)<<10]-(A); + } } static INLINE void MMC5BGVROM_BANK1(uint32 A,uint32 V) {if(CHRptr[0]){V&=CHRmask1[0];MMC5BGVPage[(A)>>10]=&CHRptr[0][(V)<<10]-(A);}} @@ -52,7 +52,7 @@ static uint8 PRGBanks[4]; static uint8 WRAMPage; static uint8 CHRBanksA[8], CHRBanksB[4]; static uint8 WRAMMaskEnable[2]; -static uint8 ABMode; /* A=0, B=1 */ +static uint8 ABMode; /* A=0, B=1 */ static uint8 IRQScanline,IRQEnable; static uint8 CHRMode, NTAMirroring, NTFill, ATFill; @@ -76,8 +76,8 @@ static void MMC5CHRA(void); static void MMC5CHRB(void); typedef struct __cartdata { - uint32 crc32; - uint8 size; + uint32 crc32; + uint8 size; } cartdata; @@ -87,300 +87,316 @@ typedef struct __cartdata { #define MMC5_NOCARTS 14 cartdata MMC5CartList[MMC5_NOCARTS]= { - {0x9c18762b,2}, /* L'Empereur */ - {0x26533405,2}, - {0x6396b988,2}, + {0x9c18762b,2}, /* L'Empereur */ + {0x26533405,2}, + {0x6396b988,2}, - {0xaca15643,2}, /* Uncharted Waters */ - {0xfe3488d1,2}, /* Dai Koukai Jidai */ + {0xaca15643,2}, /* Uncharted Waters */ + {0xfe3488d1,2}, /* Dai Koukai Jidai */ - {0x15fe6d0f,2}, /* BKAC */ - {0x39f2ce4b,2}, /* Suikoden */ + {0x15fe6d0f,2}, /* BKAC */ + {0x39f2ce4b,2}, /* Suikoden */ - {0x8ce478db,2}, /* Nobunaga's Ambition 2 */ - {0xeee9a682,2}, + {0x8ce478db,2}, /* Nobunaga's Ambition 2 */ + {0xeee9a682,2}, - {0x1ced086f,2}, /* Ishin no Arashi */ + {0x1ced086f,2}, /* Ishin no Arashi */ - {0xf540677b,4}, /* Nobunaga...Bushou Fuuun Roku */ + {0xf540677b,4}, /* Nobunaga...Bushou Fuuun Roku */ - {0x6f4e4312,4}, /* Aoki Ookami..Genchou */ + {0x6f4e4312,4}, /* Aoki Ookami..Genchou */ - {0xf011e490,4}, /* Romance of the 3 Kingdoms 2 */ - {0x184c2124,4}, /* Sangokushi 2 */ + {0xf011e490,4}, /* Romance of the 3 Kingdoms 2 */ + {0x184c2124,4}, /* Sangokushi 2 */ }; int DetectMMC5WRAMSize(uint32 crc32) { - int x; - for(x=0;x8KB external WRAM present. Use UNIF if you hack the ROM image.\n"); - return(MMC5CartList[x].size*8); - } - return(8); + int x; + + for(x=0;x8KB external WRAM present. Use UNIF if you hack the ROM image.\n"); + return(MMC5CartList[x].size*8); + } + return(8); } static void BuildWRAMSizeTable(void) { - int x; - for(x=0;x<8;x++) + int x; + + for(x=0;x<8;x++) + { + switch(MMC5WRAMsize) { - switch(MMC5WRAMsize) - { - case 0: MMC5WRAMIndex[x]=255; break; - case 1: MMC5WRAMIndex[x]=(x>3)?255:0; break; - case 2: MMC5WRAMIndex[x]=(x&4)>>2; break; - case 4: MMC5WRAMIndex[x]=(x>3)?255:(x&3); break; - } + case 0:MMC5WRAMIndex[x]=255;break; + case 1:MMC5WRAMIndex[x]=(x>3)?255:0;break; + case 2:MMC5WRAMIndex[x]=(x&4)>>2;break; + case 4:MMC5WRAMIndex[x]=(x>3)?255:(x&3);break; } + } } static void MMC5CHRA(void) { - int x; - switch(mmc5vsize&3) - { - case 0: setchr8(CHRBanksA[7]); - MMC5SPRVROM_BANK8(CHRBanksA[7]); - break; - case 1: setchr4(0x0000,CHRBanksA[3]); - setchr4(0x1000,CHRBanksA[7]); - MMC5SPRVROM_BANK4(0x0000,CHRBanksA[3]); - MMC5SPRVROM_BANK4(0x1000,CHRBanksA[7]); - break; - case 2: setchr2(0x0000,CHRBanksA[1]); - setchr2(0x0800,CHRBanksA[3]); - setchr2(0x1000,CHRBanksA[5]); - setchr2(0x1800,CHRBanksA[7]); - MMC5SPRVROM_BANK2(0x0000,CHRBanksA[1]); - MMC5SPRVROM_BANK2(0x0800,CHRBanksA[3]); - MMC5SPRVROM_BANK2(0x1000,CHRBanksA[5]); - MMC5SPRVROM_BANK2(0x1800,CHRBanksA[7]); - break; - case 3: for(x=0;x<8;x++) - { - setchr1(x<<10,CHRBanksA[x]); - MMC5SPRVROM_BANK1(x<<10,CHRBanksA[x]); - } - break; - } + int x; + switch(mmc5vsize&3) + { + case 0:setchr8(CHRBanksA[7]); + MMC5SPRVROM_BANK8(CHRBanksA[7]); + break; + case 1:setchr4(0x0000,CHRBanksA[3]); + setchr4(0x1000,CHRBanksA[7]); + MMC5SPRVROM_BANK4(0x0000,CHRBanksA[3]); + MMC5SPRVROM_BANK4(0x1000,CHRBanksA[7]); + break; + case 2:setchr2(0x0000,CHRBanksA[1]); + setchr2(0x0800,CHRBanksA[3]); + setchr2(0x1000,CHRBanksA[5]); + setchr2(0x1800,CHRBanksA[7]); + MMC5SPRVROM_BANK2(0x0000,CHRBanksA[1]); + MMC5SPRVROM_BANK2(0x0800,CHRBanksA[3]); + MMC5SPRVROM_BANK2(0x1000,CHRBanksA[5]); + MMC5SPRVROM_BANK2(0x1800,CHRBanksA[7]); + break; + case 3: + for(x=0;x<8;x++) + { + setchr1(x<<10,CHRBanksA[x]); + MMC5SPRVROM_BANK1(x<<10,CHRBanksA[x]); + } + break; + } } static void MMC5CHRB(void) { - int x; - switch(mmc5vsize&3) - { - case 0: setchr8(CHRBanksB[3]); - MMC5BGVROM_BANK8(CHRBanksB[3]); - break; - case 1: setchr4(0x0000,CHRBanksB[3]); - setchr4(0x1000,CHRBanksB[3]); - MMC5BGVROM_BANK4(0x0000,CHRBanksB[3]); - MMC5BGVROM_BANK4(0x1000,CHRBanksB[3]); - break; - case 2: setchr2(0x0000,CHRBanksB[1]); - setchr2(0x0800,CHRBanksB[3]); - setchr2(0x1000,CHRBanksB[1]); - setchr2(0x1800,CHRBanksB[3]); - MMC5BGVROM_BANK2(0x0000,CHRBanksB[1]); - MMC5BGVROM_BANK2(0x0800,CHRBanksB[3]); - MMC5BGVROM_BANK2(0x1000,CHRBanksB[1]); - MMC5BGVROM_BANK2(0x1800,CHRBanksB[3]); - break; - case 3: for(x=0;x<8;x++) - { - setchr1(x<<10,CHRBanksB[x&3]); - MMC5BGVROM_BANK1(x<<10,CHRBanksB[x&3]); - } - break; - } + int x; + switch(mmc5vsize&3) + { + case 0: + setchr8(CHRBanksB[3]); + MMC5BGVROM_BANK8(CHRBanksB[3]); + break; + + case 1: + setchr4(0x0000,CHRBanksB[3]); + setchr4(0x1000,CHRBanksB[3]); + MMC5BGVROM_BANK4(0x0000,CHRBanksB[3]); + MMC5BGVROM_BANK4(0x1000,CHRBanksB[3]); + break; + + case 2: + setchr2(0x0000,CHRBanksB[1]); + setchr2(0x0800,CHRBanksB[3]); + setchr2(0x1000,CHRBanksB[1]); + setchr2(0x1800,CHRBanksB[3]); + MMC5BGVROM_BANK2(0x0000,CHRBanksB[1]); + MMC5BGVROM_BANK2(0x0800,CHRBanksB[3]); + MMC5BGVROM_BANK2(0x1000,CHRBanksB[1]); + MMC5BGVROM_BANK2(0x1800,CHRBanksB[3]); + break; + case 3: + for(x=0;x<8;x++) + { + setchr1(x<<10,CHRBanksB[x&3]); + MMC5BGVROM_BANK1(x<<10,CHRBanksB[x&3]); + } + break; + } } static void FASTAPASS(2) MMC5WRAM(uint32 A, uint32 V) { - //printf("%02x\n",V); - V=MMC5WRAMIndex[V&7]; - if(V!=255) - { + //printf("%02x\n",V); + V=MMC5WRAMIndex[V&7]; + if(V!=255) + { setprg8r(0x10,A,V); MMC5MemIn[(A-0x6000)>>13]=1; - } - else + } + else MMC5MemIn[(A-0x6000)>>13]=0; } static void MMC5PRG(void) { - int x; - switch(mmc5psize&3) - { - case 0: MMC5ROMWrProtect[0]=MMC5ROMWrProtect[1]= - MMC5ROMWrProtect[2]=MMC5ROMWrProtect[3]=1; - setprg32(0x8000,((PRGBanks[1]&0x7F)>>2)); - for(x=0;x<4;x++) - MMC5MemIn[1+x]=1; - break; - case 1: if(PRGBanks[1]&0x80) - { - MMC5ROMWrProtect[0]=MMC5ROMWrProtect[1]=1; - setprg16(0x8000,(PRGBanks[1]>>1)); - MMC5MemIn[1]=MMC5MemIn[2]=1; - } - else - { - MMC5ROMWrProtect[0]=MMC5ROMWrProtect[1]=0; - MMC5WRAM(0x8000,PRGBanks[1]&7&0xFE); - MMC5WRAM(0xA000,(PRGBanks[1]&7&0xFE)+1); - } - MMC5MemIn[3]=MMC5MemIn[4]=1; - MMC5ROMWrProtect[2]=MMC5ROMWrProtect[3]=1; - setprg16(0xC000,(PRGBanks[3]&0x7F)>>1); - break; - case 2: if(PRGBanks[1]&0x80) - { - MMC5MemIn[1]=MMC5MemIn[2]=1; - MMC5ROMWrProtect[0]=MMC5ROMWrProtect[1]=1; - setprg16(0x8000,(PRGBanks[1]&0x7F)>>1); - } - else - { - MMC5ROMWrProtect[0]=MMC5ROMWrProtect[1]=0; - MMC5WRAM(0x8000,PRGBanks[1]&7&0xFE); - MMC5WRAM(0xA000,(PRGBanks[1]&7&0xFE)+1); - } - if(PRGBanks[2]&0x80) - { - MMC5ROMWrProtect[2]=1; - MMC5MemIn[3]=1; - setprg8(0xC000,PRGBanks[2]&0x7F); - } - else - { - MMC5ROMWrProtect[2]=0; - MMC5WRAM(0xC000,PRGBanks[2]&7); - } - MMC5MemIn[4]=1; - MMC5ROMWrProtect[3]=1; - setprg8(0xE000,PRGBanks[3]&0x7F); - break; - case 3: for(x=0;x<3;x++) - if(PRGBanks[x]&0x80) - { - MMC5ROMWrProtect[x]=1; - setprg8(0x8000+(x<<13),PRGBanks[x]&0x7F); - MMC5MemIn[1+x]=1; - } - else - { - MMC5ROMWrProtect[x]=0; - MMC5WRAM(0x8000+(x<<13),PRGBanks[x]&7); - } - MMC5MemIn[4]=1; - MMC5ROMWrProtect[3]=1; - setprg8(0xE000,PRGBanks[3]&0x7F); - break; + int x; + + switch(mmc5psize&3) + { + case 0: + MMC5ROMWrProtect[0]=MMC5ROMWrProtect[1]= + MMC5ROMWrProtect[2]=MMC5ROMWrProtect[3]=1; + setprg32(0x8000,((PRGBanks[1]&0x7F)>>2)); + for(x=0;x<4;x++) + MMC5MemIn[1+x]=1; + break; + case 1: + if(PRGBanks[1]&0x80) + { + MMC5ROMWrProtect[0]=MMC5ROMWrProtect[1]=1; + setprg16(0x8000,(PRGBanks[1]>>1)); + MMC5MemIn[1]=MMC5MemIn[2]=1; + } + else + { + MMC5ROMWrProtect[0]=MMC5ROMWrProtect[1]=0; + MMC5WRAM(0x8000,PRGBanks[1]&7&0xFE); + MMC5WRAM(0xA000,(PRGBanks[1]&7&0xFE)+1); + } + MMC5MemIn[3]=MMC5MemIn[4]=1; + MMC5ROMWrProtect[2]=MMC5ROMWrProtect[3]=1; + setprg16(0xC000,(PRGBanks[3]&0x7F)>>1); + break; + case 2: + if(PRGBanks[1]&0x80) + { + MMC5MemIn[1]=MMC5MemIn[2]=1; + MMC5ROMWrProtect[0]=MMC5ROMWrProtect[1]=1; + setprg16(0x8000,(PRGBanks[1]&0x7F)>>1); + } + else + { + MMC5ROMWrProtect[0]=MMC5ROMWrProtect[1]=0; + MMC5WRAM(0x8000,PRGBanks[1]&7&0xFE); + MMC5WRAM(0xA000,(PRGBanks[1]&7&0xFE)+1); + } + if(PRGBanks[2]&0x80) + {MMC5ROMWrProtect[2]=1;MMC5MemIn[3]=1;setprg8(0xC000,PRGBanks[2]&0x7F);} + else + {MMC5ROMWrProtect[2]=0;MMC5WRAM(0xC000,PRGBanks[2]&7);} + MMC5MemIn[4]=1; + MMC5ROMWrProtect[3]=1; + setprg8(0xE000,PRGBanks[3]&0x7F); + break; + case 3: + for(x=0;x<3;x++) + if(PRGBanks[x]&0x80) + { + MMC5ROMWrProtect[x]=1; + setprg8(0x8000+(x<<13),PRGBanks[x]&0x7F); + MMC5MemIn[1+x]=1; + } + else + { + MMC5ROMWrProtect[x]=0; + MMC5WRAM(0x8000+(x<<13),PRGBanks[x]&7); + } + MMC5MemIn[4]=1; + MMC5ROMWrProtect[3]=1; + setprg8(0xE000,PRGBanks[3]&0x7F); + break; } } static DECLFW(Mapper5_write) { - if(A>=0x5120&&A<=0x5127) - { - ABMode = 0; - CHRBanksA[A&7]=V; - MMC5CHRA(); - } - else switch(A) - { - case 0x5105: { - int x; - for(x=0;x<4;x++) - { - switch((V>>(x<<1))&3) - { - case 0:PPUNTARAM|=1<= 0x5120 && A<=0x5127) + { + ABMode = 0; + CHRBanksA[A&7]=V; + MMC5CHRA(); + } + else switch(A) + { + default: + //printf("$%04x, $%02x\n",A,V); + break; + case 0x5105: + { + int x; + for(x=0;x<4;x++) + { + switch((V>>(x<<1))&3) { - uint32 t; - t=V|(V<<8)|(V<<16)|(V<<24); - FCEU_dwmemset(MMC5fill,t,0x3c0); + case 0:PPUNTARAM|=1<>3)&0x1F;break; - case 0x5202: MMC5HackSPPage=V&0x3F;break; - case 0x5203: X6502_IRQEnd(FCEU_IQEXT);IRQScanline=V;break; - case 0x5204: X6502_IRQEnd(FCEU_IQEXT);IRQEnable=V&0x80;break; - case 0x5205: mul[0]=V;break; - case 0x5206: mul[1]=V;break; + } + } + NTAMirroring=V; + break; + + case 0x5113:WRAMPage=V;MMC5WRAM(0x6000,V&7);break; + case 0x5100:mmc5psize=V;MMC5PRG();break; + case 0x5101:mmc5vsize=V; + if(!ABMode) + {MMC5CHRB();MMC5CHRA();} + else + {MMC5CHRA();MMC5CHRB();} + break; + + case 0x5114: + case 0x5115: + case 0x5116: + case 0x5117: + PRGBanks[A&3]=V;MMC5PRG();break; + case 0x5128: + case 0x5129: + case 0x512a: + case 0x512b:ABMode=1; + CHRBanksB[A&3]=V; + MMC5CHRB(); + break; + case 0x5102:WRAMMaskEnable[0]=V;break; + case 0x5103:WRAMMaskEnable[1]=V;break; + case 0x5104:CHRMode=V;MMC5HackCHRMode=V&3;break; + case 0x5106:if(V!=NTFill) + { + uint32 t; + t=V|(V<<8)|(V<<16)|(V<<24); + FCEU_dwmemset(MMC5fill,t,0x3c0); + } + NTFill=V; + break; + case 0x5107:if(V!=ATFill) + { + unsigned char moop; + uint32 t; + moop=V|(V<<2)|(V<<4)|(V<<6); + t=moop|(moop<<8)|(moop<<16)|(moop<<24); + FCEU_dwmemset(MMC5fill+0x3c0,t,0x40); + } + ATFill=V; + break; + case 0x5200:MMC5HackSPMode=V;break; + case 0x5201:MMC5HackSPScroll=(V>>3)&0x1F;break; + case 0x5202:MMC5HackSPPage=V&0x3F;break; + case 0x5203:X6502_IRQEnd(FCEU_IQEXT);IRQScanline=V;break; + case 0x5204:X6502_IRQEnd(FCEU_IQEXT);IRQEnable=V&0x80;break; + case 0x5205:mul[0]=V;break; + case 0x5206:mul[1]=V;break; } } static DECLFR(MMC5_ReadROMRAM) { - if(MMC5MemIn[(A-0x6000)>>13]) - return Page[A>>11][A]; - else - return X.DB; + if(MMC5MemIn[(A-0x6000)>>13]) + return Page[A>>11][A]; + else + return X.DB; } static DECLFW(MMC5_WriteROMRAM) { - if(A>=0x8000) - if(MMC5ROMWrProtect[(A-0x8000)>>13]) return; - if(MMC5MemIn[(A-0x6000)>>13]) - if(((WRAMMaskEnable[0]&3)|((WRAMMaskEnable[1]&3)<<2)) == 6) Page[A>>11][A]=V; + if(A>=0x8000) + if(MMC5ROMWrProtect[(A-0x8000)>>13]) + return; + if(MMC5MemIn[(A-0x6000)>>13]) + if(((WRAMMaskEnable[0]&3)|((WRAMMaskEnable[1]&3)<<2)) == 6) + Page[A>>11][A]=V; } static DECLFW(MMC5_ExRAMWr) { - if(MMC5HackCHRMode!=3) - ExRAM[A&0x3ff]=V; + if(MMC5HackCHRMode!=3) + ExRAM[A&0x3ff]=V; } static DECLFR(MMC5_ExRAMRd) @@ -394,59 +410,60 @@ static DECLFR(MMC5_ExRAMRd) static DECLFR(MMC5_read) { - switch(A) - { - case 0x5204: X6502_IRQEnd(FCEU_IQEXT); - { - uint8 x; - x=MMC5IRQR; - if(!fceuindbg) - MMC5IRQR&=0x40; - return x; - } - case 0x5205: return (mul[0]*mul[1]); - case 0x5206: return ((mul[0]*mul[1])>>8); - } - return(X.DB); + switch(A) + { + //default:printf("$%04x\n",A);break; + case 0x5204:X6502_IRQEnd(FCEU_IQEXT); + { + uint8 x; + x=MMC5IRQR; + if(!fceuindbg) + MMC5IRQR&=0x40; + return x; + } + case 0x5205:return (mul[0]*mul[1]); + case 0x5206:return ((mul[0]*mul[1])>>8); + } + return(X.DB); } void MMC5Synco(void) { - int x; + int x; - MMC5PRG(); - for(x=0;x<4;x++) - { - switch((NTAMirroring>>(x<<1))&3) - { - case 0:PPUNTARAM|=1<>(x<<1))&3) + { + case 0:PPUNTARAM|=1<>4]+=MMC5Sound.raw<<1; + Wave[V>>4]+=MMC5Sound.raw<<1; } static void Do5PCMHQ() { - int32 V; - if(!(MMC5Sound.rawcontrol&0x40) && MMC5Sound.raw) + int32 V; + if(!(MMC5Sound.rawcontrol&0x40) && MMC5Sound.raw) for(V=MMC5Sound.BC[2];V>2); - MMC5Sound.env[A>>2]=V; - break; - case 0x2: - case 0x6: if(sfun) sfun(A>>2); - MMC5Sound.wl[A>>2]&=~0x00FF; - MMC5Sound.wl[A>>2]|=V&0xFF; - break; - case 0x3: - case 0x7://printf("%04x:$%02x\n",A,V>>3); - MMC5Sound.wl[A>>2]&=~0x0700; - MMC5Sound.wl[A>>2]|=(V&0x07)<<8; - MMC5Sound.running|=1<<(A>>2); + case 0x0: + case 0x4://printf("%04x:$%02x\n",A,V&0x30); + if(sfun) sfun(A>>2); + MMC5Sound.env[A>>2]=V; break; + case 0x2: + case 0x6:if(sfun) sfun(A>>2); + MMC5Sound.wl[A>>2]&=~0x00FF; + MMC5Sound.wl[A>>2]|=V&0xFF; + break; + case 0x3: + case 0x7://printf("%04x:$%02x\n",A,V>>3); + MMC5Sound.wl[A>>2]&=~0x0700; + MMC5Sound.wl[A>>2]|=(V&0x07)<<8; + MMC5Sound.running|=1<<(A>>2); + break; case 0x15:if(sfun) { sfun(0); sfun(1); } - MMC5Sound.running&=V; + MMC5Sound.running&=V; MMC5Sound.enable=V; - //printf("%02x\n",V); + //printf("%02x\n",V); break; } } static void Do5SQ(int P) -{ +{ static int tal[4]={1,2,4,6}; int32 V,amp,rthresh,wl; int32 start,end; start=MMC5Sound.BC[P]; - end=(SOUNDTS<<16)/soundtsinc; + end=(SOUNDTS<<16)/soundtsinc; if(end<=start) return; MMC5Sound.BC[P]=end; - + wl=MMC5Sound.wl[P]+1; amp=(MMC5Sound.env[P]&0xF)<<4; rthresh=tal[(MMC5Sound.env[P]&0xC0)>>6]; - + if(wl>=8 && (MMC5Sound.running&(P+1))) - { - int dc,vc; - + { + int dc,vc; + wl<<=18; dc=MMC5Sound.dcount[P]; vc=MMC5Sound.vcount[P]; @@ -587,7 +610,7 @@ static void Do5SQ(int P) if(dc>4]+=amp; vc-=nesincsize; - while(vc<=0) + while(vc<=0) { vc+=wl; dc=(dc+1)&7; @@ -602,18 +625,18 @@ static void Do5SQHQ(int P) { static int tal[4]={1,2,4,6}; int32 V,amp,rthresh,wl; - + wl=MMC5Sound.wl[P]+1; amp=((MMC5Sound.env[P]&0xF)<<8); rthresh=tal[(MMC5Sound.env[P]&0xC0)>>6]; - + if(wl>=8 && (MMC5Sound.running&(P+1))) { int dc,vc; - + wl<<=1; - dc=MMC5Sound.dcount[P]; + dc=MMC5Sound.dcount[P]; vc=MMC5Sound.vcount[P]; for(V=MMC5Sound.BC[P];V=1) { sfun=Do5SQHQ; - psfun=Do5PCMHQ; + psfun=Do5PCMHQ; } else { @@ -688,7 +711,7 @@ void NSFMMC5_Init(void) ExRAM=(uint8*)FCEU_gmalloc(1024); Mapper5_ESI(); SetWriteHandler(0x5c00,0x5fef,MMC5_ExRAMWr); - SetReadHandler(0x5c00,0x5fef,MMC5_ExRAMRd); + SetReadHandler(0x5c00,0x5fef,MMC5_ExRAMRd); MMC5HackCHRMode=2; SetWriteHandler(0x5000,0x5015,Mapper5_SW); SetWriteHandler(0x5205,0x5206,Mapper5_write); @@ -739,21 +762,21 @@ static SFORMAT MMC5_StateRegs[]={ { PRGBanks, 4, "PRGB"}, { CHRBanksA, 8, "CHRA"}, { CHRBanksB, 4, "CHRB"}, - { &WRAMPage, 1, "WRMP"}, - { WRAMMaskEnable, 2, "WRME"}, - { &ABMode, 1, "ABMD"}, - { &IRQScanline, 1, "IRQS"}, - { &IRQEnable, 1, "IRQE"}, - { &CHRMode, 1, "CHRM"}, - { &NTAMirroring, 1, "NTAM"}, - { &NTFill, 1, "NTFL"}, - { &ATFill, 1, "ATFL"}, + { &WRAMPage, 1, "WRMP"}, + { WRAMMaskEnable, 2, "WRME"}, + { &ABMode, 1, "ABMD"}, + { &IRQScanline, 1, "IRQS"}, + { &IRQEnable, 1, "IRQE"}, + { &CHRMode, 1, "CHRM"}, + { &NTAMirroring, 1, "NTAM"}, + { &NTFill, 1, "NTFL"}, + { &ATFill, 1, "ATFL"}, { &MMC5Sound.wl[0], 2|FCEUSTATE_RLSB, "SDW0"}, { &MMC5Sound.wl[1], 2|FCEUSTATE_RLSB, "SDW1"}, { MMC5Sound.env, 2, "SDEV"}, { &MMC5Sound.enable, 1, "SDEN"}, - { &MMC5Sound.running, 1, "SDRU"}, + { &MMC5Sound.running, 1, "SDRU"}, { &MMC5Sound.raw, 1, "SDRW"}, { &MMC5Sound.rawcontrol, 1, "SDRC"}, {0} @@ -778,7 +801,7 @@ static void GenMMC5_Init(CartInfo *info, int wsize, int battery) AddExState(&MMC5HackSPScroll, 1, 0, "SPLS"); AddExState(&MMC5HackSPPage, 1, 0, "SPLP"); - MMC5WRAMsize=wsize/8; + MMC5WRAMsize=wsize/8; BuildWRAMSizeTable(); GameStateRestore=MMC5_StateRestore; info->Power=GenMMC5Reset; diff --git a/source/fceultra/movie.c b/source/fceultra/movie.c index f5ea7be..2c5dbd7 100644 --- a/source/fceultra/movie.c +++ b/source/fceultra/movie.c @@ -191,18 +191,21 @@ void FCEUMOV_AddJoy(uint8 *js) tmp &= 0x3; ti=0; - int tmpfix = tmp; - while(tmp--) { nextts |= fgetc(slots[-1 - current]) << (ti * 8); ti++; } + { + int tmpfix = tmp; + while(tmp--) { nextts |= fgetc(slots[-1 - current]) << (ti * 8); ti++; } - // This fixes a bug in movies recorded before version 0.98.11 - // It's probably not necessary, but it may keep away CRAZY PEOPLE who recorded - // movies on <= 0.98.10 and don't work on playback. - if(tmpfix == 1 && !nextts) - {nextts |= fgetc(slots[-1 - current])<<8; } - else if(tmpfix == 2 && !nextts) {nextts |= fgetc(slots[-1 - current])<<16; } + // This fixes a bug in movies recorded before version 0.98.11 + // It's probably not necessary, but it may keep away CRAZY PEOPLE who recorded + // movies on <= 0.98.10 and don't work on playback. + if(tmpfix == 1 && !nextts) + {nextts |= fgetc(slots[-1 - current])<<8; } + else if(tmpfix == 2 && !nextts) {nextts |= fgetc(slots[-1 - current])<<16; } + + framets = 0; + nextd = d; + } - framets = 0; - nextd = d; } memcpy(js,joop,4); } diff --git a/source/fceultra/netplay.c b/source/fceultra/netplay.c index da5041d..3311e4b 100644 --- a/source/fceultra/netplay.c +++ b/source/fceultra/netplay.c @@ -173,9 +173,7 @@ static FILE *FetchFile(uint32 remlen) if(!FCEUD_RecvData(cbuf, clen)) { NetError(); - /*** REMOVED GC V1.0 unlink(fn); - REMOVED GC V1.0 ***/ fclose(fp); free(cbuf); free(fn); @@ -186,9 +184,7 @@ static FILE *FetchFile(uint32 remlen) if(len > 500000) // Another sanity check { NetError(); - /*** REMOVED GC V1.0 unlink(fn); - REMOVED GC V1.0 ***/ fclose(fp); free(cbuf); free(fn); @@ -200,9 +196,7 @@ static FILE *FetchFile(uint32 remlen) fwrite(buf, 1, len, fp); free(buf); fseek(fp, 0, SEEK_SET); - /*** REMOVED GC V1.0 unlink(fn); - REMOVED GC V1.0 ***/ free(fn); return(fp); } @@ -289,24 +283,18 @@ void NetplayUpdate(uint8 *joyp) fclose(fp); if(!FCEUNET_SendFile(FCEUNPCMD_LOADSTATE, fn)) { - /*** REMOVED GC V1.0 unlink(fn); - REMOVED GC V1.0 ***/ free(fn); return; } - /*** REMOVED GC V1.0 unlink(fn); - REMOVED GC V1.0 ***/ free(fn); } else { fclose(fp); FCEUD_PrintError("File error. (K)ill, (M)aim, (D)estroy? Now!"); - /*** REMOVED GC V1.0 unlink(fn); - REMOVED GC V1.0 ***/ free(fn); return; } diff --git a/source/fceultra/ops.h b/source/fceultra/ops.h index aec518b..48d8dc2 100644 --- a/source/fceultra/ops.h +++ b/source/fceultra/ops.h @@ -350,22 +350,22 @@ case 0xAB: LD_IM(_A|=0xEE;AND;_X=_A); case 0xCB: LD_IM(AXS); /* DCP */ -case 0xC7: LD_ZP(DEC;CMP); -case 0xD7: LD_ZPX(DEC;CMP); -case 0xCF: LD_AB(DEC;CMP); -case 0xDF: LD_ABX(DEC;CMP); -case 0xDB: LD_ABY(DEC;CMP); -case 0xC3: LD_IX(DEC;CMP); -case 0xD3: LD_IY(DEC;CMP); +case 0xC7: RMW_ZP(DEC;CMP); +case 0xD7: RMW_ZPX(DEC;CMP); +case 0xCF: RMW_AB(DEC;CMP); +case 0xDF: RMW_ABX(DEC;CMP); +case 0xDB: RMW_ABY(DEC;CMP); +case 0xC3: RMW_IX(DEC;CMP); +case 0xD3: RMW_IY(DEC;CMP); -/* ISC */ -case 0xE7: LD_ZP(INC;SBC); -case 0xF7: LD_ZPX(INC;SBC); -case 0xEF: LD_AB(INC;SBC); -case 0xFF: LD_ABX(INC;SBC); -case 0xFB: LD_ABY(INC;SBC); -case 0xE3: LD_IX(INC;SBC); -case 0xF3: LD_IY(INC;SBC); +/* ISB */ +case 0xE7: RMW_ZP(INC;SBC); +case 0xF7: RMW_ZPX(INC;SBC); +case 0xEF: RMW_AB(INC;SBC); +case 0xFF: RMW_ABX(INC;SBC); +case 0xFB: RMW_ABY(INC;SBC); +case 0xE3: RMW_IX(INC;SBC); +case 0xF3: RMW_IY(INC;SBC); /* DOP */ diff --git a/source/fceultra/ppu.c b/source/fceultra/ppu.c index 8b1be75..a853f26 100644 --- a/source/fceultra/ppu.c +++ b/source/fceultra/ppu.c @@ -153,7 +153,10 @@ static DECLFR(A2002) FCEUPPU_LineUpdate(); ret = PPU_status; ret|=PPUGenLatch&0x1F; + + #ifdef FCEUDEF_DEBUGGER if(!fceuindbg) + #endif { vtoggle=0; PPU_status&=0x7F; @@ -202,7 +205,9 @@ static DECLFR(A2007) ret=VRAMBuffer; + #ifdef FCEUDEF_DEBUGGER if(!fceuindbg) + #endif { if(PPU_hook) PPU_hook(tmp); PPUGenLatch=VRAMBuffer; @@ -215,7 +220,9 @@ static DECLFR(A2007) VRAMBuffer=vnapage[(tmp>>10)&0x3][tmp&0x3FF]; } } + #ifdef FCEUDEF_DEBUGGER if(!fceuindbg) + #endif { if (INC32) RefreshAddr+=32; else RefreshAddr++; @@ -374,6 +381,7 @@ static int tofix=0; static void ResetRL(uint8 *target) { + memset(target,0xFF,256); if(InputScanlineHook) InputScanlineHook(0,0,0,0); Plinef=target; @@ -388,11 +396,14 @@ static uint8 sprlinebuf[256+8]; void FCEUPPU_LineUpdate(void) { - if(Pline && !fceuindbg) - { - int l=GETLASTPIXEL; - RefreshLine(l); - } + #ifdef FCEUDEF_DEBUGGER + if(!fceuindbg) + #endif + if(Pline) + { + int l=GETLASTPIXEL; + RefreshLine(l); + } } static int tileview=0; @@ -462,14 +473,20 @@ static void CheckSpriteHit(int p) int x; if(sphitx==0x100) return; + for(x=sphitx;x<(sphitx+8) && x>(x-sphitx))) && !(Plinef[x]&64)) { PPU_status|=0x40; //printf("Ha: %d, %d, Hita: %d, %d, %d, %d, %d\n",p,p&~7,scanline,GETLASTPIXEL-16,&Plinef[x],Pline,Pline-Plinef); + //printf("%d\n",GETLASTPIXEL-16); + //if(Plinef[x] == 0xFF) + //printf("PL: %d, %02x\n",scanline, Plinef[x]); sphitx=0x100; break; } + } } static int spork=0; /* spork the world. Any sprites on this line? Then this will be set to 1. Needed for zapper @@ -497,6 +514,16 @@ static void FASTAPASS(1) RefreshLine(int lastpixel) function. */ if(norecurse) return; + if(sphitx != 0x100 && !(PPU_status&0x40)) + { + if((sphitx < (lastpixel-16)) && !(sphitx < ((lasttile - 2)*8))) + { + //printf("OK: %d\n",scanline); + lasttile++; + } + + } + if(lasttile>34) lasttile=34; numtiles=lasttile-firsttile; @@ -660,7 +687,11 @@ static void FASTAPASS(1) RefreshLine(int lastpixel) tofix=0; } - CheckSpriteHit(lasttile*8); //lasttile*8); //lastpixel); + //CheckSpriteHit(lasttile*8); //lasttile*8); //lastpixel); + + CheckSpriteHit(lastpixel); /* This only works right because + of a hack earlier in this function. + */ if(InputScanlineHook && (lastpixel-16)>=0) { InputScanlineHook(Plinef,spork?sprlinebuf:0,linestartts,lasttile*8-16); @@ -964,19 +995,25 @@ static void RefreshSprites(void) FCEU_dwmemset(sprlinebuf,0x80808080,256); numsprites--; - spr = (SPRB*)SPRBUF+numsprites; + spr = (SPRB*)SPRBUF+numsprites; - for(n=numsprites;n>=0;n--,spr--) - { - register uint32 pixdata; - register uint8 J,atr; - int x=spr->x; - uint8 *C; - uint8 *VB; + for(n=numsprites;n>=0;n--,spr--) + { + //#ifdef C80x86 + //register uint32 pixdata asm ("eax"); + //register uint8 J, atr; + //#else + register uint32 pixdata; + register uint8 J,atr; + //#endif + + int x=spr->x; + uint8 *C; + uint8 *VB; - pixdata=ppulut1[spr->ca[0]]|ppulut2[spr->ca[1]]; - J=spr->ca[0]|spr->ca[1]; - atr=spr->atr; + pixdata=ppulut1[spr->ca[0]]|ppulut2[spr->ca[1]]; + J=spr->ca[0]|spr->ca[1]; + atr=spr->atr; if(J) { @@ -1073,7 +1110,7 @@ static void RefreshSprites(void) } } SpriteBlurp=0; - spork=1; + spork=1; } static void CopySprites(uint8 *target) @@ -1085,6 +1122,7 @@ static void CopySprites(uint8 *target) spork=0; if(rendis & 1) return; /* User asked to not display sprites. */ + loopskie: { uint32 t=*(uint32 *)(sprlinebuf+n); @@ -1094,25 +1132,25 @@ static void CopySprites(uint8 *target) #ifdef LSB_FIRST if(!(t&0x80)) { - if(!(t&0x40) || (P[n]&64)) // Normal sprite || behind bg sprite + if(!(t&0x40) || (P[n]&0x40)) // Normal sprite || behind bg sprite P[n]=sprlinebuf[n]; } if(!(t&0x8000)) { - if(!(t&0x4000) || (P[n+1]&64)) // Normal sprite || behind bg sprite + if(!(t&0x4000) || (P[n+1]&0x40)) // Normal sprite || behind bg sprite P[n+1]=(sprlinebuf+1)[n]; } if(!(t&0x800000)) { - if(!(t&0x400000) || (P[n+2]&64)) // Normal sprite || behind bg sprite + if(!(t&0x400000) || (P[n+2]&0x40)) // Normal sprite || behind bg sprite P[n+2]=(sprlinebuf+2)[n]; } if(!(t&0x80000000)) { - if(!(t&0x40000000) || (P[n+3]&64)) // Normal sprite || behind bg sprite + if(!(t&0x40000000) || (P[n+3]&0x40)) // Normal sprite || behind bg sprite P[n+3]=(sprlinebuf+3)[n]; } #else diff --git a/source/fceultra/pputile.h b/source/fceultra/pputile.h index 0332a50..6da930c 100644 --- a/source/fceultra/pputile.h +++ b/source/fceultra/pputile.h @@ -21,6 +21,60 @@ pixdata|=ppulut3[XOffset|(atlatch<<3)]; //printf("%02x ",ppulut3[XOffset|(atlatch<<3)]); + #ifdef C80x86 + asm volatile( + "movl %%ebx,%%eax\n\t" + "andl $15,%%eax\n\t" + "movb (%%esi,%%eax),%%cl\n\t" + "shrl $4, %%ebx\n\t" + "movb %%cl, (%%edi)\n\t" + + "movl %%ebx,%%eax\n\t" + "andl $15,%%eax\n\t" + "movb (%%esi,%%eax),%%cl\n\t" + "shrl $4, %%ebx\n\t" + "movb %%cl, 1(%%edi)\n\t" + + "movl %%ebx,%%eax\n\t" + "andl $15,%%eax\n\t" + "movb (%%esi,%%eax),%%cl\n\t" + "shrl $4, %%ebx\n\t" + "movb %%cl, 2(%%edi)\n\t" + + "movl %%ebx,%%eax\n\t" + "andl $15,%%eax\n\t" + "movb (%%esi,%%eax),%%cl\n\t" + "shrl $4, %%ebx\n\t" + "movb %%cl, 3(%%edi)\n\t" + + "movl %%ebx,%%eax\n\t" + "andl $15,%%eax\n\t" + "movb (%%esi,%%eax),%%cl\n\t" + "shrl $4, %%ebx\n\t" + "movb %%cl, 4(%%edi)\n\t" + + "movl %%ebx,%%eax\n\t" + "andl $15,%%eax\n\t" + "movb (%%esi,%%eax),%%cl\n\t" + "shrl $4, %%ebx\n\t" + "movb %%cl, 5(%%edi)\n\t" + + "movl %%ebx,%%eax\n\t" + "andl $15,%%eax\n\t" + "movb (%%esi,%%eax),%%cl\n\t" + "shrl $4, %%ebx\n\t" + "movb %%cl, 6(%%edi)\n\t" + + //"movl %%ebx,%%eax\n\t" + //"andl $15,%%eax\n\t" + //"movb (%%esi,%%eax),%%cl\n\t" + //"movb %%cl, 7(%%edi)\n\t" + "movb (%%esi, %%ebx),%%cl\n\t" + "movb %%cl, 7(%%edi)\n\t" + : + : "S" (S), "D" (P), "b" (pixdata) + : "eax", "cl" ); + #else P[0]=S[pixdata&0xF]; pixdata>>=4; P[1]=S[pixdata&0xF]; @@ -36,6 +90,7 @@ P[6]=S[pixdata&0xF]; pixdata>>=4; P[7]=S[pixdata&0xF]; + #endif P+=8; } diff --git a/source/fceultra/sound.c b/source/fceultra/sound.c index 25a5eaf..d0eec24 100644 --- a/source/fceultra/sound.c +++ b/source/fceultra/sound.c @@ -46,20 +46,20 @@ static uint8 TriMode; static int32 tristep; -static int32 wlcount[4]; /* Wave length counters. */ +static int32 wlcount[4]; /* Wave length counters. */ -static uint8 IRQFrameMode; /* $4017 / xx000000 */ +static uint8 IRQFrameMode; /* $4017 / xx000000 */ static uint8 PSG[0x10]; -static uint8 RawDALatch; /* $4011 0xxxxxxx */ +static uint8 RawDALatch; /* $4011 0xxxxxxx */ -uint8 EnabledChannels; /* Byte written to $4015 */ +uint8 EnabledChannels; /* Byte written to $4015 */ typedef struct { - uint8 Speed; - uint8 Mode; /* Fixed volume(1), and loop(2) */ - uint8 DecCountTo1; - uint8 decvolume; - int reloaddec; + uint8 Speed; + uint8 Mode; /* Fixed volume(1), and loop(2) */ + uint8 DecCountTo1; + uint8 decvolume; + int reloaddec; } ENVUNIT; static ENVUNIT EnvUnits[3]; @@ -71,7 +71,7 @@ static uint8 sweepon[2]; static int32 curfreq[2]; static uint8 SweepCount[2]; -static uint16 nreg; +static uint16 nreg; static uint8 fcnt; static int32 fhcnt; @@ -86,7 +86,7 @@ uint32 soundtsi; static int32 sqacc[2]; /* LQ variables segment ends. */ -static int32 lengthcount[4]; +static int32 lengthcount[4]; static const uint8 lengthtable[0x20]= { 0x5*2,0x7f*2,0xA*2,0x1*2,0x14*2,0x2*2,0x28*2,0x3*2,0x50*2,0x4*2,0x1E*2,0x5*2,0x7*2,0x6*2,0x0E*2,0x7*2, @@ -106,29 +106,29 @@ static const uint32 NTSCDMCTable[0x10]= static const uint32 PALDMCTable[0x10]= { - 397, 353, 315, 297, 265, 235, 209, 198, - 176, 148, 131, 118, 98, 78, 66, 50, + 397, 353, 315, 297, 265, 235, 209, 198, + 176, 148, 131, 118, 98, 78, 66, 50, }; -// $4010 - Frequency -// $4011 - Actual data outputted -// $4012 - Address register: $c000 + V*64 -// $4013 - Size register: Size in bytes = (V+1)*64 +// $4010 - Frequency +// $4011 - Actual data outputted +// $4012 - Address register: $c000 + V*64 +// $4013 - Size register: Size in bytes = (V+1)*64 static int32 DMCacc=1; static int32 DMCPeriod; static uint8 DMCBitCount=0; static uint8 DMCAddressLatch,DMCSizeLatch; /* writes to 4012 and 4013 */ -static uint8 DMCFormat; /* Write to $4010 */ +static uint8 DMCFormat; /* 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 uint8 DMCDMABuf=0; static char DMCHaveSample=0; static void Dummyfunc(void) {}; @@ -170,22 +170,22 @@ static int FASTAPASS(2) CheckFreq(uint32 cf, uint8 sr) static void SQReload(int x, uint8 V) { - if(EnabledChannels&(1<>3)&0x1f]; - } + if(EnabledChannels&(1<>3)&0x1f]; + } - 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; + 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; - RectDutyCount[x]=7; - EnvUnits[x].reloaddec=1; - //reloadfreq[x]=1; + RectDutyCount[x]=7; + EnvUnits[x].reloaddec=1; + //reloadfreq[x]=1; } static DECLFW(Write_PSG) @@ -194,68 +194,68 @@ static DECLFW(Write_PSG) switch(A) { case 0x0:DoSQ1(); - EnvUnits[0].Mode=(V&0x30)>>4; - EnvUnits[0].Speed=(V&0xF); - break; + EnvUnits[0].Mode=(V&0x30)>>4; + EnvUnits[0].Speed=(V&0xF); + break; case 0x1: - sweepon[0]=V&0x80; - break; + sweepon[0]=V&0x80; + break; case 0x2: - DoSQ1(); - curfreq[0]&=0xFF00; - curfreq[0]|=V; - break; + DoSQ1(); + curfreq[0]&=0xFF00; + curfreq[0]|=V; + break; case 0x3: - SQReload(0,V); - break; - case 0x4: - DoSQ2(); - EnvUnits[1].Mode=(V&0x30)>>4; - EnvUnits[1].Speed=(V&0xF); - break; - case 0x5: - sweepon[1]=V&0x80; - break; + SQReload(0,V); + break; + case 0x4: + DoSQ2(); + EnvUnits[1].Mode=(V&0x30)>>4; + EnvUnits[1].Speed=(V&0xF); + break; + case 0x5: + sweepon[1]=V&0x80; + break; case 0x6:DoSQ2(); - curfreq[1]&=0xFF00; - curfreq[1]|=V; - break; - case 0x7: - SQReload(1,V); - break; + curfreq[1]&=0xFF00; + curfreq[1]|=V; + break; + case 0x7: + SQReload(1,V); + break; case 0xa:DoTriangle(); - break; + break; case 0xb: - DoTriangle(); - if(EnabledChannels&0x4) - lengthcount[2]=lengthtable[(V>>3)&0x1f]; - TriMode=1; // Load mode - break; + DoTriangle(); + if(EnabledChannels&0x4) + lengthcount[2]=lengthtable[(V>>3)&0x1f]; + TriMode=1; // Load mode + break; case 0xC:DoNoise(); - EnvUnits[2].Mode=(V&0x30)>>4; - EnvUnits[2].Speed=(V&0xF); - break; + EnvUnits[2].Mode=(V&0x30)>>4; + EnvUnits[2].Speed=(V&0xF); + break; case 0xE:DoNoise(); - break; + break; case 0xF: - DoNoise(); - if(EnabledChannels&0x8) - lengthcount[3]=lengthtable[(V>>3)&0x1f]; - EnvUnits[2].reloaddec=1; - break; + DoNoise(); + if(EnabledChannels&0x8) + lengthcount[3]=lengthtable[(V>>3)&0x1f]; + EnvUnits[2].reloaddec=1; + break; case 0x10:DoPCM(); - LoadDMCPeriod(V&0xF); + LoadDMCPeriod(V&0xF); - if(SIRQStat&0x80) - { - if(!(V&0x80)) - { - X6502_IRQEnd(FCEU_IQDPCM); - SIRQStat&=~0x80; - } - else X6502_IRQBegin(FCEU_IQDPCM); - } - break; + if(SIRQStat&0x80) + { + if(!(V&0x80)) + { + X6502_IRQEnd(FCEU_IQDPCM); + SIRQStat&=~0x80; + } + else X6502_IRQBegin(FCEU_IQDPCM); + } + break; } PSG[A]=V; } @@ -267,22 +267,22 @@ static DECLFW(Write_DMCRegs) switch(A) { case 0x00:DoPCM(); - LoadDMCPeriod(V&0xF); + LoadDMCPeriod(V&0xF); - if(SIRQStat&0x80) - { - if(!(V&0x80)) - { - X6502_IRQEnd(FCEU_IQDPCM); - SIRQStat&=~0x80; - } - else X6502_IRQBegin(FCEU_IQDPCM); - } - DMCFormat=V; - break; + if(SIRQStat&0x80) + { + if(!(V&0x80)) + { + X6502_IRQEnd(FCEU_IQDPCM); + SIRQStat&=~0x80; + } + else X6502_IRQBegin(FCEU_IQDPCM); + } + DMCFormat=V; + break; case 0x01:DoPCM(); - RawDALatch=V&0x7F; - break; + RawDALatch=V&0x7F; + break; case 0x02:DMCAddressLatch=V;break; case 0x03:DMCSizeLatch=V;break; } @@ -292,28 +292,28 @@ static DECLFW(Write_DMCRegs) static DECLFW(StatusWrite) { - int x; + int x; - DoSQ1(); - DoSQ2(); - DoTriangle(); - DoNoise(); - DoPCM(); - for(x=0;x<4;x++) - if(!(V&(1<0) lengthcount[2]--; - if(!(PSG[0xC]&0x20)) /* Make sure loop flag is not set. */ + if(!(PSG[0xC]&0x20)) /* Make sure loop flag is not set. */ if(lengthcount[3]>0) lengthcount[3]--; for(P=0;P<2;P++) { - if(!(PSG[P<<2]&0x20)) /* Make sure loop flag is not set. */ + 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 */ @@ -368,13 +368,13 @@ static void FASTAPASS(1) 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; @@ -392,16 +392,16 @@ static void FASTAPASS(1) FrameSoundStuff(int V) { if(curfreq[P] && (PSG[(P<<2)+0x1]&7)/* && sweepon[P]&0x80*/) { - curfreq[P]+=mod; + curfreq[P]+=mod; } - } + } } } } - else /* Sweeping is disabled: */ + 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); } } } @@ -446,14 +446,14 @@ void FrameSoundUpdate(void) if(!fcnt && !(IRQFrameMode&0x3)) { - SIRQStat|=0x40; - X6502_IRQBegin(FCEU_IQFCOUNT); + SIRQStat|=0x40; + X6502_IRQBegin(FCEU_IQFCOUNT); } if(fcnt==3) { - if(IRQFrameMode&0x2) - fhcnt+=fhinc; + if(IRQFrameMode&0x2) + fhcnt+=fhinc; } FrameSoundStuff(fcnt); fcnt=(fcnt+1)&3; @@ -472,7 +472,7 @@ static INLINE void tester(void) DMCShift=DMCDMABuf; DMCHaveDMA=0; } - } + } } static INLINE void DMCDMA(void) @@ -519,7 +519,7 @@ void FASTAPASS(1) FCEU_SoundCPUHook(int cycles) uint8 bah=RawDALatch; int t=((DMCShift&1)<<2)-2; - /* Unbelievably ugly hack */ + /* Unbelievably ugly hack */ if(FSettings.SndRate) { soundtsoffs+=DMCacc; @@ -533,7 +533,7 @@ void FASTAPASS(1) FCEU_SoundCPUHook(int cycles) DMCacc+=DMCPeriod; DMCBitCount=(DMCBitCount+1)&7; - DMCShift>>=1; + DMCShift>>=1; tester(); } } @@ -577,7 +577,7 @@ static INLINE void RDoSQ(int x) D=&WaveHi[ChannelBC[x]]; V=SOUNDTS-ChannelBC[x]; - + currdc=RectDutyCount[x]; cf=(curfreq[x]+1)*2; rc=wlcount[x]; @@ -594,8 +594,8 @@ static INLINE void RDoSQ(int x) } V--; D++; - } - + } + RectDutyCount[x]=currdc; wlcount[x]=rc; @@ -613,9 +613,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]; int32 rthresh[2]; @@ -648,7 +648,7 @@ static void RDoSQLQ(void) else amp[x]=EnvUnits[x].decvolume; - if(!inie[x]) amp[x]=0; /* Correct? Buzzing in MM2, others otherwise... */ + if(!inie[x]) amp[x]=0; /* Correct? Buzzing in MM2, others otherwise... */ rthresh[x]=RectDuties[(PSG[x*4]&0xC0)>>6]; @@ -667,7 +667,7 @@ static void RDoSQLQ(void) if(!inie[0] && !inie[1]) { - for(V=start;V>4]+=totalout; } else @@ -684,7 +684,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) { @@ -713,10 +713,10 @@ static void RDoTriangle(void) tcout=(tristep&0xF); if(!(tristep&0x10)) tcout^=0xF; - tcout=(tcout*3) << 16; //(tcout<<1); + tcout=(tcout*3) << 16; //(tcout<<1); if(!lengthcount[2] || !TriCount) - { /* Counter is halted, but we still need to output. */ + { /* Counter is halted, but we still need to output. */ int32 *start = &WaveHi[ChannelBC[2]]; int32 count = SOUNDTS - ChannelBC[2]; while(count--) @@ -765,7 +765,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)); @@ -774,7 +774,7 @@ 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; @@ -782,10 +782,10 @@ static void RDoTriangleNoisePCMLQ(void) amptab[0]<<=1; if(!lengthcount[3]) - amptab[0]=inie[1]=0; /* Quick hack speedup, set inie[1] to 0 */ + 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 @@ -796,37 +796,37 @@ static void RDoTriangleNoisePCMLQ(void) if(inie[0] && inie[1]) { - for(V=start;V>4]+=totalout; - triacc-=inie[0]; - noiseacc-=inie[1]; + triacc-=inie[0]; + noiseacc-=inie[1]; - if(triacc<=0) - { - rea: - triacc+=freq[0]; //t; - tristep=(tristep+1)&0x1F; - if(triacc<=0) goto rea; - tcout=(tristep&0xF); - if(!(tristep&0x10)) tcout^=0xF; - tcout=tcout*3; + if(triacc<=0) + { + rea: + triacc+=freq[0]; //t; + tristep=(tristep+1)&0x1F; + if(triacc<=0) goto rea; + tcout=(tristep&0xF); + if(!(tristep&0x10)) tcout^=0xF; + tcout=tcout*3; totalout = wlookup2[tcout+noiseout+RawDALatch]; - } + } - if(noiseacc<=0) - { - rea2: - noiseacc+=NoiseFreqTable[PSG[0xE]&0xF]<<(16+2); - nreg=(nreg<<1)+(((nreg>>nshift)^(nreg>>14))&1); - nreg&=0x7fff; - noiseout=amptab[(nreg>>0xe)]; - if(noiseacc<=0) goto rea2; + if(noiseacc<=0) + { + rea2: + noiseacc+=NoiseFreqTable[PSG[0xE]&0xF]<<(16+2); + nreg=(nreg<<1)+(((nreg>>nshift)^(nreg>>14))&1); + nreg&=0x7fff; + noiseout=amptab[(nreg>>0xe)]; + if(noiseacc<=0) goto rea2; totalout = wlookup2[tcout+noiseout+RawDALatch]; - } /* noiseacc<=0 */ - } /* for(V=... */ -} + } /* noiseacc<=0 */ + } /* for(V=... */ + } else if(inie[0]) { for(V=start;V>6; fcnt=0; - if(V&0x2) + if(V&0x2) FrameSoundUpdate(); fcnt=1; fhcnt=fhinc; @@ -944,7 +944,7 @@ DECLFW(Write_IRQFM) } void SetNESSoundMap(void) -{ +{ SetWriteHandler(0x4000,0x400F,Write_PSG); SetWriteHandler(0x4010,0x4013,Write_DMCRegs); SetWriteHandler(0x4017,0x4017,Write_IRQFM); @@ -982,7 +982,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++; } @@ -1025,7 +1025,7 @@ int FlushEmulateSound(void) inbuf=end; FCEU_WriteWaveData(WaveFinal, end); /* This function will just return - if sound recording is off. */ + if sound recording is off. */ return(end); } @@ -1041,68 +1041,68 @@ due to that whole MegaMan 2 Game Genie thing. void FCEUSND_Reset(void) { - int x; + int x; - IRQFrameMode=0x0; - fhcnt=fhinc; - fcnt=0; + IRQFrameMode=0x0; + fhcnt=fhinc; + fcnt=0; - nreg=1; - for(x=0;x<2;x++) - { - wlcount[x]=2048; - if(nesincsize) // lq mode - sqacc[x]=((uint32)2048<<17)/nesincsize; - else - sqacc[x]=1; - sweepon[x]=0; - curfreq[x]=0; - } - wlcount[2]=1; //2048; - wlcount[3]=2048; - DMCHaveDMA=DMCHaveSample=0; - SIRQStat=0x00; + nreg=1; + for(x=0;x<2;x++) + { + wlcount[x]=2048; + if(nesincsize) // lq mode + sqacc[x]=((uint32)2048<<17)/nesincsize; + else + sqacc[x]=1; + sweepon[x]=0; + curfreq[x]=0; + } + wlcount[2]=1; //2048; + wlcount[3]=2048; + DMCHaveDMA=DMCHaveSample=0; + SIRQStat=0x00; - RawDALatch=0x00; - TriCount=0; - TriMode=0; - tristep=0; - EnabledChannels=0; - for(x=0;x<4;x++) - lengthcount[x]=0; + RawDALatch=0x00; + TriCount=0; + TriMode=0; + tristep=0; + EnabledChannels=0; + for(x=0;x<4;x++) + lengthcount[x]=0; - DMCAddressLatch=0; - DMCSizeLatch=0; - DMCFormat=0; - DMCAddress=0; - DMCSize=0; - DMCShift=0; + DMCAddressLatch=0; + DMCSizeLatch=0; + DMCFormat=0; + DMCAddress=0; + DMCSize=0; + DMCShift=0; } void FCEUSND_Power(void) { - int x; + int x; + + SetNESSoundMap(); + memset(PSG,0x00,sizeof(PSG)); + FCEUSND_Reset(); - SetNESSoundMap(); - memset(PSG,0x00,sizeof(PSG)); - FCEUSND_Reset(); + memset(Wave,0,sizeof(Wave)); + memset(WaveHi,0,sizeof(WaveHi)); + memset(&EnvUnits,0,sizeof(EnvUnits)); - memset(Wave,0,sizeof(Wave)); - memset(WaveHi,0,sizeof(WaveHi)); - memset(&EnvUnits,0,sizeof(EnvUnits)); - - for(x=0;x<5;x++) - ChannelBC[x]=0; - soundtsoffs=0; - LoadDMCPeriod(DMCFormat&0xF); + for(x=0;x<5;x++) + ChannelBC[x]=0; + soundtsoffs=0; + LoadDMCPeriod(DMCFormat&0xF); } void SetSoundVariables(void) { - int x; + int x; - fhinc=PAL?16626:14915; // *2 CPU clock rate + fhinc=PAL?16626:14915; // *2 CPU clock rate fhinc*=24; if(FSettings.SndRate) @@ -1136,7 +1136,7 @@ void SetSoundVariables(void) DoNoise=RDoTriangleNoisePCMLQ; DoPCM=RDoTriangleNoisePCMLQ; } - } + } else { DoNoise=DoTriangle=DoPCM=DoSQ1=DoSQ2=Dummyfunc; @@ -1152,7 +1152,7 @@ void SetSoundVariables(void) memset(sqacc,0,sizeof(sqacc)); memset(ChannelBC,0,sizeof(ChannelBC)); - LoadDMCPeriod(DMCFormat&0xF); // For changing from PAL to NTSC + LoadDMCPeriod(DMCFormat&0xF); // For changing from PAL to NTSC soundtsinc=(uint32)((uint64)(PAL?(long double)PAL_CPU*65536:(long double)NTSC_CPU*65536)/(FSettings.SndRate * 16)); } @@ -1183,7 +1183,7 @@ void FCEUI_SetSoundVolume(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"}, diff --git a/source/fceultra/state.c b/source/fceultra/state.c index 619bf0b..bbcc4b6 100644 --- a/source/fceultra/state.c +++ b/source/fceultra/state.c @@ -79,11 +79,6 @@ SFORMAT SFCPUC[]={ { 0 } }; -void cleanSFMDATA() -{ - memset(&SFMDATA[0], 0, sizeof(SFMDATA) * 64 ); -} - static int SubWrite(FILE *st, SFORMAT *sf) { uint32 acc=0; @@ -451,9 +446,7 @@ void FCEUI_LoadState(char *fname) FCEUNET_SendFile(FCEUNPCMD_LOADSTATE, fn); } else fclose(fp); - /*** REMOVED GC V1.0 unlink(fn); - REMOVED GC V1.0 ***/ } free(fn); } @@ -468,3 +461,7 @@ void FCEU_DrawSaveStates(uint8 *XBuf) StateShow--; } +void cleanSFMDATA() +{ + memset(&SFMDATA[0], 0, sizeof(SFMDATA) * 64 ); +} diff --git a/source/fceultra/types.h b/source/fceultra/types.h index 1206a96..cddd2ea 100644 --- a/source/fceultra/types.h +++ b/source/fceultra/types.h @@ -41,7 +41,6 @@ typedef uint32_t uint32; typedef long long int64; #define INLINE inline #define GINLINE inline - #define PSS_STYLE 3 #elif MSVC typedef __int64 int64; typedef unsigned __int64 uint64; diff --git a/source/fceultra/unif.c b/source/fceultra/unif.c index a6bfd6a..719ec08 100644 --- a/source/fceultra/unif.c +++ b/source/fceultra/unif.c @@ -371,14 +371,12 @@ static BMAPPING bmap[] = { { "CPROM", CPROM_Init,0}, { "CNROM", CNROM_Init,0}, - - //{ "GNROM", GNROM_Init,0}, - //{ "NROM", NROM256_Init,0 }, - //{ "RROM", NROM128_Init,0 }, - //{ "RROM-128", NROM128_Init,0 }, - //{ "NROM-128", NROM128_Init,0 }, - //{ "NROM-256", NROM256_Init,0 }, - + { "GNROM", GNROM_Init,0}, + { "NROM", NROM256_Init,0 }, + { "RROM", NROM128_Init,0 }, + { "RROM-128", NROM128_Init,0 }, + { "NROM-128", NROM128_Init,0 }, + { "NROM-256", NROM256_Init,0 }, { "MHROM", MHROM_Init,0}, { "UNROM", UNROM_Init,0}, { "MARIO1-MALEE2", MALEE_Init,0}, diff --git a/source/fceultra/x6502.c b/source/fceultra/x6502.c index 6a27592..be7a65f 100644 --- a/source/fceultra/x6502.c +++ b/source/fceultra/x6502.c @@ -27,7 +27,9 @@ X6502 X; +#ifdef FCEUDEF_DEBUGGER void (*X6502_Run)(int32 cycles); +#endif uint32 timestamp; void FP_FASTAPASS(1) (*MapIRQHook)(int a); @@ -63,6 +65,7 @@ static INLINE void WrMemNorm(unsigned int A, uint8 V) BWrite[A](A,V); } +#ifdef FCEUDEF_DEBUGGER X6502 XSave; /* This is getting ugly. */ //#define RdMemHook(A) ( X.ReadHook?(_DB=X.ReadHook(&X,A)):(_DB=ARead[A](A)) ) //#define WrMemHook(A,V) { if(X.WriteHook) X.WriteHook(&X,A,V); else BWrite[A](A,V); } @@ -82,6 +85,7 @@ static INLINE void WrMemHook(unsigned int A, uint8 V) else BWrite[A](A,V); } +#endif //#define RdRAMFast(A) (_DB=RAM[(A)]) //#define WrRAMFast(A,V) RAM[(A)]=(V) @@ -129,18 +133,19 @@ static uint8 ZNTable[256]; if(cond) \ { \ uint32 tmp; \ - int8 disp; \ - disp=RdMem(_PC); \ + int32 disp; \ + disp=(int8)RdMem(_PC); \ _PC++; \ ADDCYC(1); \ tmp=_PC; \ _PC+=disp; \ - if((tmp^_PC)&0x100) \ - ADDCYC(1); \ + if((tmp^_PC)&0x100) \ + ADDCYC(1); \ } \ else _PC++; \ } + #define LDA _A=x;X_ZN(_A) #define LDX _X=x;X_ZN(_X) #define LDY _Y=x;X_ZN(_Y) @@ -393,6 +398,7 @@ void TriggerNMI2(void) _IRQlow|=FCEU_IQNMI2; } +#ifdef FCEUDEF_DEBUGGER /* Called from debugger. */ void FCEUI_NMI(void) { @@ -404,11 +410,6 @@ void FCEUI_IRQ(void) _IRQlow|=FCEU_IQTEMP; } -void X6502_Reset(void) -{ - _IRQlow=FCEU_IQRESET; -} - void FCEUI_GetIVectors(uint16 *reset, uint16 *irq, uint16 *nmi) { fceuindbg=1; @@ -421,8 +422,14 @@ void FCEUI_GetIVectors(uint16 *reset, uint16 *irq, uint16 *nmi) *irq|=RdMemNorm(0xFFFF)<<8; fceuindbg=0; } - static int debugmode; +#endif + +void X6502_Reset(void) +{ + _IRQlow=FCEU_IQRESET; +} + void X6502_Init(void) { int x; @@ -432,7 +439,9 @@ void X6502_Init(void) if(!x) ZNTable[x]=Z_FLAG; else if (x&0x80) ZNTable[x]=N_FLAG; else ZNTable[x]=0; + #ifdef FCEUDEF_DEBUGGER X6502_Debug(0,0,0); + #endif } void X6502_Power(void) @@ -442,6 +451,7 @@ void X6502_Power(void) X6502_Reset(); } +#ifdef FCEUDEF_DEBUGGER static void X6502_RunDebug(int32 cycles) { #define RdRAM RdMemHook @@ -565,6 +575,9 @@ static void X6502_RunDebug(int32 cycles) } static void X6502_RunNormal(int32 cycles) +#else +void X6502_Run(int32 cycles) +#endif { #define RdRAM RdRAMFast #define WrRAM WrRAMFast @@ -650,15 +663,13 @@ static void X6502_RunNormal(int32 cycles) _PI=_P; b1=RdMem(_PC); - //printf("$%04x, $%02x\n",_PC,b1); + ADDCYC(CycTable[b1]); - //PPUHack(); + temp=_tcount; _tcount=0; - if(MapIRQHook) MapIRQHook(temp); FCEU_SoundCPUHook(temp); - //printf("%04x\n",X.PC); X.PC=pbackus; _PC++; @@ -675,6 +686,7 @@ static void X6502_RunNormal(int32 cycles) #undef WrRAM } +#ifdef FCEUDEF_DEBUGGER void X6502_Debug(void (*CPUHook)(X6502 *), uint8 (*ReadHook)(X6502 *, unsigned int), void (*WriteHook)(X6502 *, unsigned int, uint8)) @@ -689,3 +701,5 @@ void X6502_Debug(void (*CPUHook)(X6502 *), else X6502_Run=X6502_RunDebug; } + +#endif diff --git a/source/fceultra/x6502.h b/source/fceultra/x6502.h index 16ecd67..f70cfac 100644 --- a/source/fceultra/x6502.h +++ b/source/fceultra/x6502.h @@ -22,13 +22,18 @@ #include "x6502struct.h" +#ifdef FCEUDEF_DEBUGGER void X6502_Debug(void (*CPUHook)(X6502 *), uint8 (*ReadHook)(X6502 *, unsigned int), void (*WriteHook)(X6502 *, unsigned int, uint8)); +extern void (*X6502_Run)(int32 cycles); +#else +void X6502_Run(int32 cycles); +#endif + extern uint32 timestamp; extern X6502 X; -extern void (*X6502_Run)(int32 cycles); #define N_FLAG 0x80 #define V_FLAG 0x40 diff --git a/source/fceultra/x6502struct.h b/source/fceultra/x6502struct.h index 88293c2..4bc8f2b 100644 --- a/source/fceultra/x6502struct.h +++ b/source/fceultra/x6502struct.h @@ -14,9 +14,13 @@ typedef struct __X6502 { uint8 DB; /* Data bus "cache" for reads from certain areas */ int preexec; /* Pre-exec'ing for debug breakpoints. */ + + #ifdef FCEUDEF_DEBUGGER void (*CPUHook)(struct __X6502 *); uint8 (*ReadHook)(struct __X6502 *, unsigned int); void (*WriteHook)(struct __X6502 *, unsigned int, uint8); + #endif + } X6502; #define _X6502STRUCTH #endif diff --git a/source/ngc/button_mapping.c b/source/ngc/button_mapping.c index c6958e7..2e0bf7d 100644 --- a/source/ngc/button_mapping.c +++ b/source/ngc/button_mapping.c @@ -84,7 +84,7 @@ CtrlrMap ctrlr_def[4] = { {PAD_BUTTON_B, "B"}, {PAD_BUTTON_X, "X"}, {PAD_BUTTON_Y, "Y"}, - {PAD_BUTTON_MENU, "MENU"}, + {PAD_BUTTON_MENU, "START"}, {PAD_BUTTON_START, "START"}, {PAD_TRIGGER_L, "L TRIG"}, {PAD_TRIGGER_R, "R TRIG"},