commit patch #662 nes 2.0, mapper 30 (unrom-512)
This commit is contained in:
parent
b77c835d8a
commit
40ad98c0cd
|
@ -0,0 +1,269 @@
|
||||||
|
/* FCE Ultra - NES/Famicom Emulator
|
||||||
|
*
|
||||||
|
* Copyright notice for this file:
|
||||||
|
* Copyright (C) 2014 CaitSith2
|
||||||
|
*
|
||||||
|
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Roms still using NES 1.0 format should be loaded as 32K CHR RAM.
|
||||||
|
* Roms defined under NES 2.0 should use the VRAM size field, defining 7, 8 or 9, based on how much VRAM should be present.
|
||||||
|
* UNIF doesn't have this problem, because unique board names can define this information.
|
||||||
|
* The UNIF names are UNROM-512-8K, UNROM-512-16K and UNROM-512-32K
|
||||||
|
*
|
||||||
|
* The battery flag in the NES header enables flash, Mirrror mode 2 Enables MI_0 and MI_1 mode.
|
||||||
|
* Known games to use this board are:
|
||||||
|
* Battle Kid 2: Mountain of Torment (512K PRG, 8K CHR RAM, Horizontal Mirroring, Flash disabled)
|
||||||
|
* Study Hall (128K PRG (in 512K flash chip), 8K CHR RAM, Horizontal Mirroring, Flash enabled)
|
||||||
|
* Although Xmas 2013 uses a different board, where LEDs can be controlled (with writes to the $8000-BFFF space),
|
||||||
|
* it otherwise functions identically.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "mapinc.h"
|
||||||
|
#include "../ines.h"
|
||||||
|
|
||||||
|
static uint8 latche, latcheinit, bus_conflict, chrram_mask, software_id=false;
|
||||||
|
static uint16 latcha;
|
||||||
|
static uint8 *flashdata;
|
||||||
|
static uint32 *flash_write_count;
|
||||||
|
static uint8 *FlashPage[32];
|
||||||
|
static uint32 *FlashWriteCountPage[32];
|
||||||
|
static uint8 flashloaded = false;
|
||||||
|
|
||||||
|
static uint8 flash_save=0, flash_state=0, flash_mode=0, flash_bank;
|
||||||
|
static void (*WLSync)(void);
|
||||||
|
static void (*WHSync)(void);
|
||||||
|
|
||||||
|
static INLINE void setfpageptr(int s, uint32 A, uint8 *p) {
|
||||||
|
uint32 AB = A >> 11;
|
||||||
|
int x;
|
||||||
|
|
||||||
|
if (p)
|
||||||
|
for (x = (s >> 1) - 1; x >= 0; x--) {
|
||||||
|
FlashPage[AB + x] = p - A;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
for (x = (s >> 1) - 1; x >= 0; x--) {
|
||||||
|
FlashPage[AB + x] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void setfprg16(uint32 A, uint32 V) {
|
||||||
|
if (PRGsize[0] >= 16384) {
|
||||||
|
V &= PRGmask16[0];
|
||||||
|
setfpageptr(16, A, flashdata ? (&flashdata[V << 14]) : 0);
|
||||||
|
} else {
|
||||||
|
uint32 VA = V << 3;
|
||||||
|
int x;
|
||||||
|
|
||||||
|
for (x = 0; x < 8; x++)
|
||||||
|
setfpageptr(2, A + (x << 11), flashdata ? (&flashdata[((VA + x) & PRGmask2[0]) << 11]) : 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void inc_flash_write_count(uint8 bank, uint32 A)
|
||||||
|
{
|
||||||
|
flash_write_count[(bank*4) + ((A&0x3000)>>12)]++;
|
||||||
|
if(!flash_write_count[(bank*4) + ((A&0x3000)>>12)])
|
||||||
|
flash_write_count[(bank*4) + ((A&0x3000)>>12)]++;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 GetFlashWriteCount(uint8 bank, uint32 A)
|
||||||
|
{
|
||||||
|
return flash_write_count[(bank*4) + ((A&0x3000)>>12)];
|
||||||
|
}
|
||||||
|
|
||||||
|
static void StateRestore(int version) {
|
||||||
|
WHSync();
|
||||||
|
}
|
||||||
|
|
||||||
|
static DECLFW(UNROM512LLatchWrite)
|
||||||
|
{
|
||||||
|
latche = V;
|
||||||
|
latcha = A;
|
||||||
|
WLSync();
|
||||||
|
}
|
||||||
|
|
||||||
|
static DECLFW(UNROM512HLatchWrite)
|
||||||
|
{
|
||||||
|
if (bus_conflict)
|
||||||
|
latche = (V == CartBR(A)) ? V : 0;
|
||||||
|
else
|
||||||
|
latche = V;
|
||||||
|
latcha = A;
|
||||||
|
WHSync();
|
||||||
|
}
|
||||||
|
|
||||||
|
static DECLFR(UNROM512LatchRead)
|
||||||
|
{
|
||||||
|
uint8 flash_id[3]={0xB5,0xB6,0xB7};
|
||||||
|
if(software_id)
|
||||||
|
{
|
||||||
|
if(A&1)
|
||||||
|
return flash_id[ROM_size>>4];
|
||||||
|
else
|
||||||
|
return 0xBF;
|
||||||
|
}
|
||||||
|
if(flash_save)
|
||||||
|
{
|
||||||
|
if(A < 0xC000)
|
||||||
|
{
|
||||||
|
if(GetFlashWriteCount(flash_bank,A))
|
||||||
|
return FlashPage[A >> 11][A];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(GetFlashWriteCount(ROM_size-1,A))
|
||||||
|
return FlashPage[A >> 11][A];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Page[A >> 11][A];
|
||||||
|
}
|
||||||
|
|
||||||
|
static void UNROM512LatchPower(void) {
|
||||||
|
latche = latcheinit;
|
||||||
|
WHSync();
|
||||||
|
SetReadHandler(0x8000, 0xFFFF, UNROM512LatchRead);
|
||||||
|
if(!flash_save)
|
||||||
|
SetWriteHandler(0x8000, 0xFFFF, UNROM512HLatchWrite);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetWriteHandler(0x8000,0xBFFF,UNROM512LLatchWrite);
|
||||||
|
SetWriteHandler(0xC000,0xFFFF,UNROM512HLatchWrite);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void UNROM512LatchClose(void) {
|
||||||
|
if(flash_write_count)
|
||||||
|
FCEU_gfree(flash_write_count);
|
||||||
|
if(flashdata)
|
||||||
|
FCEU_gfree(flashdata);
|
||||||
|
flash_write_count = NULL;
|
||||||
|
flashdata = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void UNROM512LSync() {
|
||||||
|
int erase_a[5]={0x9555,0xAAAA,0x9555,0x9555,0xAAAA};
|
||||||
|
int erase_d[5]={0xAA,0x55,0x80,0xAA,0x55};
|
||||||
|
int erase_b[5]={1,0,1,1,0};
|
||||||
|
|
||||||
|
if(flash_mode==0)
|
||||||
|
{
|
||||||
|
if((latcha == erase_a[flash_state]) && (latche == erase_d[flash_state]) && (flash_bank == erase_b[flash_state]))
|
||||||
|
{
|
||||||
|
flash_state++;
|
||||||
|
if(flash_state == 5)
|
||||||
|
{
|
||||||
|
flash_mode=1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ((flash_state==2)&&(latcha==0x9555)&&(latche==0xA0)&&(flash_bank==1))
|
||||||
|
{
|
||||||
|
flash_state++;
|
||||||
|
flash_mode=2;
|
||||||
|
}
|
||||||
|
else if ((flash_state==2)&&(latcha==0x9555)&&(latche==0x90)&&(flash_bank==1))
|
||||||
|
{
|
||||||
|
flash_state=0;
|
||||||
|
software_id=true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(latche==0xF0)
|
||||||
|
software_id=false;
|
||||||
|
flash_state=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(flash_mode==1) //Chip Erase or Sector Erase
|
||||||
|
{
|
||||||
|
if(latche==0x30)
|
||||||
|
{
|
||||||
|
inc_flash_write_count(flash_bank,latcha);
|
||||||
|
memset(&FlashPage[(latcha & 0xF000) >> 11][latcha & 0xF000],0xFF,0x1000);
|
||||||
|
}
|
||||||
|
else if (latche==0x10)
|
||||||
|
{
|
||||||
|
for(int i=0;i<(ROM_size*4);i++)
|
||||||
|
inc_flash_write_count(i>>2,i<<12);
|
||||||
|
memset(flashdata,0xFF,ROM_size*0x4000); //Erasing the rom chip as instructed. Crash rate calulated to be 99.9% :)
|
||||||
|
}
|
||||||
|
flash_state=0;
|
||||||
|
flash_mode=0;
|
||||||
|
}
|
||||||
|
else if(flash_mode==2) //Byte Program
|
||||||
|
{
|
||||||
|
if(!GetFlashWriteCount(flash_bank,latcha))
|
||||||
|
{
|
||||||
|
inc_flash_write_count(flash_bank,latcha);
|
||||||
|
memcpy(&FlashPage[(latcha & 0xF000) >> 11][latcha & 0xF000],&Page[(latcha & 0xF000)>>11][latcha & 0xF000],0x1000);
|
||||||
|
}
|
||||||
|
FlashPage[latcha>>11][latcha]&=latche;
|
||||||
|
flash_state=0;
|
||||||
|
flash_mode=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void UNROM512HSync()
|
||||||
|
{
|
||||||
|
flash_bank=latche&(ROM_size-1);
|
||||||
|
|
||||||
|
setprg16(0x8000, flash_bank);
|
||||||
|
setprg16(0xc000, ~0);
|
||||||
|
setfprg16(0x8000, flash_bank);
|
||||||
|
setfprg16(0xC000, ~0);
|
||||||
|
setchr8r(0, (latche & chrram_mask) >> 5);
|
||||||
|
setmirror(MI_0+(latche>>7));
|
||||||
|
}
|
||||||
|
|
||||||
|
void UNROM512_Init(CartInfo *info) {
|
||||||
|
flash_state=0;
|
||||||
|
flash_bank=0;
|
||||||
|
flash_save=info->battery;
|
||||||
|
|
||||||
|
if(info->vram_size == 8192)
|
||||||
|
chrram_mask = 0;
|
||||||
|
else if (info->vram_size == 16384)
|
||||||
|
chrram_mask = 0x20;
|
||||||
|
else
|
||||||
|
chrram_mask = 0x60;
|
||||||
|
|
||||||
|
SetupCartMirroring(info->mirror,(info->mirror>=MI_0)?0:1,0);
|
||||||
|
bus_conflict = !info->battery;
|
||||||
|
latcheinit = 0;
|
||||||
|
WLSync = UNROM512LSync;
|
||||||
|
WHSync = UNROM512HSync;
|
||||||
|
info->Power = UNROM512LatchPower;
|
||||||
|
info->Close = UNROM512LatchClose;
|
||||||
|
GameStateRestore = StateRestore;
|
||||||
|
if(flash_save)
|
||||||
|
{
|
||||||
|
flashdata = (uint8*)FCEU_gmalloc(ROM_size*0x4000);
|
||||||
|
flash_write_count = (uint32*)FCEU_gmalloc(ROM_size*4*sizeof(uint32));
|
||||||
|
info->SaveGame[0] = (uint8*)flash_write_count;
|
||||||
|
info->SaveGame[1] = flashdata;
|
||||||
|
info->SaveGameLen[0] = ROM_size*4*sizeof(uint32);
|
||||||
|
info->SaveGameLen[1] = ROM_size*0x4000;
|
||||||
|
AddExState(flash_write_count,ROM_size*4*sizeof(uint32),0,"FLASH_WRITE_COUNT");
|
||||||
|
AddExState(flashdata,ROM_size*0x4000,0,"FLASH_DATA");
|
||||||
|
AddExState(&flash_state,1,0,"FLASH_STATE");
|
||||||
|
AddExState(&flash_mode,1,0,"FLASH_MODE");
|
||||||
|
AddExState(&flash_bank,1,0,"FLASH_BANK");
|
||||||
|
AddExState(&latcha,2,0,"LATA");
|
||||||
|
}
|
||||||
|
AddExState(&latche, 1, 0, "LATC");
|
||||||
|
AddExState(&bus_conflict, 1, 0, "BUSC");
|
||||||
|
}
|
|
@ -13,6 +13,12 @@ typedef struct {
|
||||||
// that are not really MMC3 but are
|
// that are not really MMC3 but are
|
||||||
// set to mapper 4.
|
// set to mapper 4.
|
||||||
int battery; // Presence of an actual battery.
|
int battery; // Presence of an actual battery.
|
||||||
|
int ines2;
|
||||||
|
int submapper; // Submappers as defined by NES 2.0
|
||||||
|
int wram_size;
|
||||||
|
int battery_wram_size;
|
||||||
|
int vram_size;
|
||||||
|
int battery_vram_size;
|
||||||
uint8 MD5[16];
|
uint8 MD5[16];
|
||||||
uint32 CRC32; // Should be set by the iNES/UNIF loading
|
uint32 CRC32; // Should be set by the iNES/UNIF loading
|
||||||
// code, used by mapper/board code, maybe
|
// code, used by mapper/board code, maybe
|
||||||
|
|
|
@ -63,6 +63,8 @@ static int iNES_Init(int num);
|
||||||
|
|
||||||
static int MapperNo = 0;
|
static int MapperNo = 0;
|
||||||
|
|
||||||
|
static int iNES2 = 0;
|
||||||
|
|
||||||
static DECLFR(TrainerRead) {
|
static DECLFR(TrainerRead) {
|
||||||
return(trainerpoo[A & 0x1FF]);
|
return(trainerpoo[A & 0x1FF]);
|
||||||
}
|
}
|
||||||
|
@ -473,8 +475,8 @@ static BMAPPINGLocal bmap[] = {
|
||||||
{"Konami VRC6 Rev. B", 26, Mapper26_Init},
|
{"Konami VRC6 Rev. B", 26, Mapper26_Init},
|
||||||
{"CC-21 MI HUN CHE", 27, UNLCC21_Init}, // Former dupe for VRC2/VRC4 mapper, redefined with crc to mihunche boards
|
{"CC-21 MI HUN CHE", 27, UNLCC21_Init}, // Former dupe for VRC2/VRC4 mapper, redefined with crc to mihunche boards
|
||||||
{"", 28, Mapper28_Init},
|
{"", 28, Mapper28_Init},
|
||||||
{"", 29, Mapper29_Init},
|
{"RET-CUFROM", 29, Mapper29_Init},
|
||||||
// {"", 30, Mapper30_Init},
|
{"UNROM 512", 30, UNROM512_Init},
|
||||||
// {"", 31, Mapper31_Init},
|
// {"", 31, Mapper31_Init},
|
||||||
{"IREM G-101", 32, Mapper32_Init},
|
{"IREM G-101", 32, Mapper32_Init},
|
||||||
{"TC0190FMC/TC0350FMR", 33, Mapper33_Init},
|
{"TC0190FMC/TC0350FMR", 33, Mapper33_Init},
|
||||||
|
@ -700,6 +702,11 @@ static BMAPPINGLocal bmap[] = {
|
||||||
{"DRAGON BALL PIRATE", 253, Mapper253_Init},
|
{"DRAGON BALL PIRATE", 253, Mapper253_Init},
|
||||||
{"", 254, Mapper254_Init},
|
{"", 254, Mapper254_Init},
|
||||||
// {"", 255, Mapper255_Init}, // No good dumps for this mapper
|
// {"", 255, Mapper255_Init}, // No good dumps for this mapper
|
||||||
|
|
||||||
|
//-------- Mappers 256-511 is the Supplementary Multilingual Plane ----------
|
||||||
|
//-------- Mappers 512-767 is the Supplementary Ideographic Plane -----------
|
||||||
|
//-------- Mappers 3840-4095 are for rom dumps not publicly released --------
|
||||||
|
|
||||||
{"", 0, NULL}
|
{"", 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -716,19 +723,35 @@ int iNESLoad(const char *name, FCEUFILE *fp, int OverwriteVidMode) {
|
||||||
|
|
||||||
memset(&iNESCart, 0, sizeof(iNESCart));
|
memset(&iNESCart, 0, sizeof(iNESCart));
|
||||||
|
|
||||||
|
iNES2 = ((head.ROM_type2 & 0x0C) == 0x08);
|
||||||
|
if(iNES2)
|
||||||
|
{
|
||||||
|
iNESCart.ines2 = true;
|
||||||
|
iNESCart.wram_size = (head.RAM_size & 0x0F)?(64 << (head.RAM_size & 0x0F)):0;
|
||||||
|
iNESCart.battery_wram_size = (head.RAM_size & 0xF0)?(64 << ((head.RAM_size & 0xF0)>>4)):0;
|
||||||
|
iNESCart.vram_size = (head.VRAM_size & 0x0F)?(64 << (head.VRAM_size & 0x0F)):0;
|
||||||
|
iNESCart.battery_vram_size = (head.VRAM_size & 0xF0)?(64 << ((head.VRAM_size & 0xF0)>>4)):0;
|
||||||
|
iNESCart.submapper = head.ROM_type3 >> 4;
|
||||||
|
}
|
||||||
|
|
||||||
MapperNo = (head.ROM_type >> 4);
|
MapperNo = (head.ROM_type >> 4);
|
||||||
MapperNo |= (head.ROM_type2 & 0xF0);
|
MapperNo |= (head.ROM_type2 & 0xF0);
|
||||||
|
if(iNES2) MapperNo |= ((head.ROM_type3 & 0x0F) << 8);
|
||||||
|
|
||||||
if (head.ROM_type & 8) {
|
if (head.ROM_type & 8) {
|
||||||
Mirroring = 2;
|
Mirroring = 2;
|
||||||
} else
|
} else
|
||||||
Mirroring = (head.ROM_type & 1);
|
Mirroring = (head.ROM_type & 1);
|
||||||
|
|
||||||
if (!head.ROM_size)
|
int not_round_size = head.ROM_size;
|
||||||
|
if(iNES2) not_round_size |= ((head.Upper_ROM_VROM_size & 0x0F) << 8);
|
||||||
|
|
||||||
|
if (!head.ROM_size && !iNES2)
|
||||||
ROM_size = 256;
|
ROM_size = 256;
|
||||||
else
|
else
|
||||||
ROM_size = uppow2(head.ROM_size);
|
ROM_size = uppow2(not_round_size);
|
||||||
|
|
||||||
VROM_size = uppow2(head.VROM_size);
|
VROM_size = uppow2(head.VROM_size | (iNES2?((head.Upper_ROM_VROM_size & 0xF0)<<4):0));
|
||||||
|
|
||||||
int round = true;
|
int round = true;
|
||||||
for (int i = 0; i != sizeof(not_power2) / sizeof(not_power2[0]); ++i) {
|
for (int i = 0; i != sizeof(not_power2) / sizeof(not_power2[0]); ++i) {
|
||||||
|
@ -766,7 +789,7 @@ int iNESLoad(const char *name, FCEUFILE *fp, int OverwriteVidMode) {
|
||||||
|
|
||||||
SetupCartPRGMapping(0, ROM, ROM_size << 14, 0);
|
SetupCartPRGMapping(0, ROM, ROM_size << 14, 0);
|
||||||
|
|
||||||
FCEU_fread(ROM, 0x4000, (round) ? ROM_size : head.ROM_size, fp);
|
FCEU_fread(ROM, 0x4000, (round) ? ROM_size : not_round_size, fp);
|
||||||
|
|
||||||
if (VROM_size)
|
if (VROM_size)
|
||||||
FCEU_fread(VROM, 0x2000, VROM_size, fp);
|
FCEU_fread(VROM, 0x2000, VROM_size, fp);
|
||||||
|
@ -785,7 +808,7 @@ int iNESLoad(const char *name, FCEUFILE *fp, int OverwriteVidMode) {
|
||||||
|
|
||||||
iNESCart.CRC32 = iNESGameCRC32;
|
iNESCart.CRC32 = iNESGameCRC32;
|
||||||
|
|
||||||
FCEU_printf(" PRG ROM: %3d x 16KiB\n", (round) ? ROM_size: head.ROM_size);
|
FCEU_printf(" PRG ROM: %3d x 16KiB\n", (round) ? ROM_size: not_round_size);
|
||||||
FCEU_printf(" CHR ROM: %3d x 8KiB\n", head.VROM_size);
|
FCEU_printf(" CHR ROM: %3d x 8KiB\n", head.VROM_size);
|
||||||
FCEU_printf(" ROM CRC32: 0x%08lx\n", iNESGameCRC32);
|
FCEU_printf(" ROM CRC32: 0x%08lx\n", iNESGameCRC32);
|
||||||
{
|
{
|
||||||
|
@ -810,6 +833,18 @@ int iNESLoad(const char *name, FCEUFILE *fp, int OverwriteVidMode) {
|
||||||
FCEU_printf(" Mirroring: %s\n", Mirroring == 2 ? "None (Four-screen)" : Mirroring ? "Vertical" : "Horizontal");
|
FCEU_printf(" Mirroring: %s\n", Mirroring == 2 ? "None (Four-screen)" : Mirroring ? "Vertical" : "Horizontal");
|
||||||
FCEU_printf(" Battery-backed: %s\n", (head.ROM_type & 2) ? "Yes" : "No");
|
FCEU_printf(" Battery-backed: %s\n", (head.ROM_type & 2) ? "Yes" : "No");
|
||||||
FCEU_printf(" Trained: %s\n", (head.ROM_type & 4) ? "Yes" : "No");
|
FCEU_printf(" Trained: %s\n", (head.ROM_type & 4) ? "Yes" : "No");
|
||||||
|
if(iNES2)
|
||||||
|
{
|
||||||
|
FCEU_printf(" NES2.0 Extensions\n");
|
||||||
|
FCEU_printf(" Sub Mapper #: %d\n", iNESCart.submapper);
|
||||||
|
FCEU_printf(" Total WRAM size: %d\n", iNESCart.wram_size + iNESCart.battery_wram_size);
|
||||||
|
FCEU_printf(" Total VRAM size: %d\n", iNESCart.vram_size + iNESCart.battery_vram_size);
|
||||||
|
if(head.ROM_type & 2)
|
||||||
|
{
|
||||||
|
FCEU_printf(" WRAM backked by battery: %d\n", iNESCart.battery_wram_size);
|
||||||
|
FCEU_printf(" VRAM backed by battery: %d\n", iNESCart.battery_vram_size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SetInput();
|
SetInput();
|
||||||
CheckHInfo();
|
CheckHInfo();
|
||||||
|
@ -876,45 +911,20 @@ int iNESLoad(const char *name, FCEUFILE *fp, int OverwriteVidMode) {
|
||||||
|
|
||||||
// bbit edited: the whole function below was added
|
// bbit edited: the whole function below was added
|
||||||
int iNesSave() {
|
int iNesSave() {
|
||||||
FILE *fp;
|
|
||||||
char name[2048];
|
char name[2048];
|
||||||
|
|
||||||
if (GameInfo->type != GIT_CART) return 0;
|
|
||||||
if (GameInterface != iNESGI) return 0;
|
|
||||||
|
|
||||||
strcpy(name, LoadedRomFName);
|
strcpy(name, LoadedRomFName);
|
||||||
if (strcmp(name + strlen(name) - 4, ".nes") != 0) { //para edit
|
if (strcmp(name + strlen(name) - 4, ".nes") != 0) { //para edit
|
||||||
strcat(name, ".nes");
|
strcat(name, ".nes");
|
||||||
}
|
}
|
||||||
|
|
||||||
fp = fopen(name, "wb");
|
return iNesSaveAs(name);
|
||||||
if (!fp)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (fwrite(&head, 1, 16, fp) != 16)
|
|
||||||
{
|
|
||||||
fclose(fp);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (head.ROM_type & 4)
|
|
||||||
{
|
|
||||||
/* Trainer */
|
|
||||||
fwrite(trainerpoo, 512, 1, fp);
|
|
||||||
}
|
|
||||||
|
|
||||||
fwrite(ROM, 0x4000, ROM_size, fp);
|
|
||||||
|
|
||||||
if (head.VROM_size)
|
|
||||||
fwrite(VROM, 0x2000, head.VROM_size, fp);
|
|
||||||
|
|
||||||
fclose(fp);
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int iNesSaveAs(char* name)
|
int iNesSaveAs(char* name)
|
||||||
{
|
{
|
||||||
//adelikat: TODO: iNesSave() and this have pretty much the same code, outsource the common code to a single function
|
//adelikat: TODO: iNesSave() and this have pretty much the same code, outsource the common code to a single function
|
||||||
|
//caitsith2: done. iNesSave() now gets filename and calls iNesSaveAs with that filename.
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
if (GameInfo->type != GIT_CART) return 0;
|
if (GameInfo->type != GIT_CART) return 0;
|
||||||
|
@ -969,13 +979,22 @@ static int iNES_Init(int num) {
|
||||||
if (num == tmp->number) {
|
if (num == tmp->number) {
|
||||||
UNIFchrrama = 0; // need here for compatibility with UNIF mapper code
|
UNIFchrrama = 0; // need here for compatibility with UNIF mapper code
|
||||||
if (!VROM_size) {
|
if (!VROM_size) {
|
||||||
switch (num) { // FIXME, mapper or game data base with the board parameters and ROM/RAM sizes
|
if(!iNESCart.ines2)
|
||||||
case 13: CHRRAMSize = 16 * 1024; break;
|
{
|
||||||
case 6:
|
switch (num) { // FIXME, mapper or game data base with the board parameters and ROM/RAM sizes
|
||||||
case 29:
|
case 13: CHRRAMSize = 16 * 1024; break;
|
||||||
case 96: CHRRAMSize = 32 * 1024; break;
|
case 6:
|
||||||
case 176: CHRRAMSize = 128 * 1024; break;
|
case 29:
|
||||||
default: CHRRAMSize = 8 * 1024; break;
|
case 30:
|
||||||
|
case 96: CHRRAMSize = 32 * 1024; break;
|
||||||
|
case 176: CHRRAMSize = 128 * 1024; break;
|
||||||
|
default: CHRRAMSize = 8 * 1024; break;
|
||||||
|
}
|
||||||
|
iNESCart.vram_size = CHRRAMSize;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CHRRAMSize = iNESCart.battery_vram_size + iNESCart.vram_size;
|
||||||
}
|
}
|
||||||
if ((VROM = (uint8*)FCEU_dmalloc(CHRRAMSize)) == NULL) return 0;
|
if ((VROM = (uint8*)FCEU_dmalloc(CHRRAMSize)) == NULL) return 0;
|
||||||
FCEU_MemoryRand(VROM, CHRRAMSize);
|
FCEU_MemoryRand(VROM, CHRRAMSize);
|
||||||
|
|
|
@ -56,7 +56,13 @@ struct iNES_HEADER {
|
||||||
uint8 VROM_size;
|
uint8 VROM_size;
|
||||||
uint8 ROM_type;
|
uint8 ROM_type;
|
||||||
uint8 ROM_type2;
|
uint8 ROM_type2;
|
||||||
uint8 reserve[8];
|
uint8 ROM_type3;
|
||||||
|
uint8 Upper_ROM_VROM_size;
|
||||||
|
uint8 RAM_size;
|
||||||
|
uint8 VRAM_size;
|
||||||
|
uint8 TV_system;
|
||||||
|
uint8 VS_hardware;
|
||||||
|
uint8 reserved[2];
|
||||||
|
|
||||||
void cleanup()
|
void cleanup()
|
||||||
{
|
{
|
||||||
|
|
|
@ -448,6 +448,9 @@ static BMAPPING bmap[] = {
|
||||||
{ "TVROM", TLROM_Init, BMCFLAG_FORCE4 },
|
{ "TVROM", TLROM_Init, BMCFLAG_FORCE4 },
|
||||||
{ "Transformer", Transformer_Init, 0 },
|
{ "Transformer", Transformer_Init, 0 },
|
||||||
{ "UNROM", UNROM_Init, 0 },
|
{ "UNROM", UNROM_Init, 0 },
|
||||||
|
{ "UNROM-512-8", UNROM512_Init, 0 },
|
||||||
|
{ "UNROM-512-16", UNROM512_Init, BMCFLAG_16KCHRR },
|
||||||
|
{ "UNROM-512-32", UNROM512_Init, BMCFLAG_32KCHRR },
|
||||||
{ "UOROM", UNROM_Init, 0 },
|
{ "UOROM", UNROM_Init, 0 },
|
||||||
{ "VRC7", UNLVRC7_Init, 0 },
|
{ "VRC7", UNLVRC7_Init, 0 },
|
||||||
{ "YOKO", UNLYOKO_Init, 0 },
|
{ "YOKO", UNLYOKO_Init, 0 },
|
||||||
|
@ -513,6 +516,7 @@ static int InitializeBoard(void) {
|
||||||
CHRRAMSize = 128 * 1024;
|
CHRRAMSize = 128 * 1024;
|
||||||
else
|
else
|
||||||
CHRRAMSize = 8192;
|
CHRRAMSize = 8192;
|
||||||
|
UNIFCart.vram_size = CHRRAMSize;
|
||||||
if ((UNIFchrrama = (uint8*)FCEU_malloc(CHRRAMSize))) {
|
if ((UNIFchrrama = (uint8*)FCEU_malloc(CHRRAMSize))) {
|
||||||
SetupCartCHRMapping(0, UNIFchrrama, CHRRAMSize, 1);
|
SetupCartCHRMapping(0, UNIFchrrama, CHRRAMSize, 1);
|
||||||
AddExState(UNIFchrrama, CHRRAMSize, 0, "CHRR");
|
AddExState(UNIFchrrama, CHRRAMSize, 0, "CHRR");
|
||||||
|
|
|
@ -142,6 +142,7 @@ void UNLTF1201_Init(CartInfo *info);
|
||||||
void UNLVRC7_Init(CartInfo *info);
|
void UNLVRC7_Init(CartInfo *info);
|
||||||
void UNLYOKO_Init(CartInfo *info);
|
void UNLYOKO_Init(CartInfo *info);
|
||||||
void UNROM_Init(CartInfo *info);
|
void UNROM_Init(CartInfo *info);
|
||||||
|
void UNROM512_Init(CartInfo *info);
|
||||||
|
|
||||||
extern uint8 *UNIFchrrama; // Meh. So I can stop CHR RAM
|
extern uint8 *UNIFchrrama; // Meh. So I can stop CHR RAM
|
||||||
// bank switcherooing with certain boards...
|
// bank switcherooing with certain boards...
|
||||||
|
|
|
@ -329,6 +329,7 @@
|
||||||
<ClCompile Include="..\src\boards\pec-586.cpp" />
|
<ClCompile Include="..\src\boards\pec-586.cpp" />
|
||||||
<ClCompile Include="..\src\boards\sa-9602b.cpp" />
|
<ClCompile Include="..\src\boards\sa-9602b.cpp" />
|
||||||
<ClCompile Include="..\src\boards\transformer.cpp" />
|
<ClCompile Include="..\src\boards\transformer.cpp" />
|
||||||
|
<ClCompile Include="..\src\boards\unrom512.cpp" />
|
||||||
<ClCompile Include="..\src\boards\vrc1.cpp" />
|
<ClCompile Include="..\src\boards\vrc1.cpp" />
|
||||||
<ClCompile Include="..\src\boards\vrc2and4.cpp" />
|
<ClCompile Include="..\src\boards\vrc2and4.cpp" />
|
||||||
<ClCompile Include="..\src\boards\vrc3.cpp" />
|
<ClCompile Include="..\src\boards\vrc3.cpp" />
|
||||||
|
|
|
@ -904,6 +904,9 @@
|
||||||
<ClCompile Include="..\src\boards\transformer.cpp">
|
<ClCompile Include="..\src\boards\transformer.cpp">
|
||||||
<Filter>boards</Filter>
|
<Filter>boards</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\src\boards\unrom512.cpp">
|
||||||
|
<Filter>boards</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="..\src\boards\vrc1.cpp">
|
<ClCompile Include="..\src\boards\vrc1.cpp">
|
||||||
<Filter>boards</Filter>
|
<Filter>boards</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
|
@ -1170,6 +1170,10 @@
|
||||||
RelativePath="..\src\boards\transformer.cpp"
|
RelativePath="..\src\boards\transformer.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\src\boards\unrom512.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\src\boards\vrc1.cpp"
|
RelativePath="..\src\boards\vrc1.cpp"
|
||||||
>
|
>
|
||||||
|
|
|
@ -943,6 +943,10 @@
|
||||||
RelativePath="..\src\boards\transformer.cpp"
|
RelativePath="..\src\boards\transformer.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\src\boards\unrom512.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\src\boards\vrc1.cpp"
|
RelativePath="..\src\boards\vrc1.cpp"
|
||||||
>
|
>
|
||||||
|
|
Loading…
Reference in New Issue