Update region overrides and overclocking
- ines.c - misc cleanups - Fix Dendy not restored when changing overrides back to auto mode - directly apply new scanlines and additional scanlines when changing overclock settings - (readability) change variable name overlock_state to overclock_enabled
This commit is contained in:
@@ -92,18 +92,18 @@ extern uint8 NTARAM[0x800], PALRAM[0x20], SPRAM[0x100], PPU[4];
|
||||
/* overclock the console by adding dummy scanlines to PPU loop
|
||||
* disables DMC DMA and WaveHi filling for these dummies
|
||||
* doesn't work with new PPU */
|
||||
unsigned overclock_state = -1;
|
||||
unsigned overclock_enabled = -1;
|
||||
unsigned overclocked = 0;
|
||||
unsigned skip_7bit_overclocking = 1; /* 7-bit samples have priority over overclocking */
|
||||
unsigned totalscanlines = 0;
|
||||
unsigned normal_scanlines = 240;
|
||||
unsigned extrascanlines = 0;
|
||||
unsigned vblankscanlines = 0;
|
||||
|
||||
static unsigned is_PAL = 0;
|
||||
static unsigned setregion = 0;
|
||||
unsigned dendy = 0;
|
||||
|
||||
static unsigned systemRegion = 0;
|
||||
static unsigned opt_region = 0;
|
||||
|
||||
int FCEUnetplay;
|
||||
#ifdef PSP
|
||||
#include "pspgu.h"
|
||||
@@ -944,34 +944,30 @@ static void retro_set_custom_palette(void)
|
||||
void FCEUD_RegionOverride(unsigned region)
|
||||
{
|
||||
unsigned pal = 0;
|
||||
unsigned d = 0;
|
||||
|
||||
switch (region)
|
||||
{
|
||||
case 0: /* auto */
|
||||
normal_scanlines = 240;
|
||||
dendy = 0;
|
||||
pal = is_PAL;
|
||||
d = (systemRegion >> 1) & 1;
|
||||
pal = systemRegion & 1;
|
||||
break;
|
||||
case 1: /* ntsc */
|
||||
normal_scanlines = 240;
|
||||
dendy = 0;
|
||||
pal = 0;
|
||||
FCEU_DispMessage("Switched to NTSC");
|
||||
FCEU_DispMessage("System: NTSC");
|
||||
break;
|
||||
case 2: /* pal */
|
||||
normal_scanlines = 240;
|
||||
dendy = 0;
|
||||
pal = 1;
|
||||
FCEU_DispMessage("Switched to PAL");
|
||||
FCEU_DispMessage("System: PAL");
|
||||
break;
|
||||
case 3: /* dendy */
|
||||
normal_scanlines = 290;
|
||||
dendy = 1;
|
||||
pal = 0;
|
||||
FCEU_DispMessage("Switched to Dendy");
|
||||
d = 1;
|
||||
FCEU_DispMessage("System: Dendy");
|
||||
break;
|
||||
}
|
||||
|
||||
dendy = d;
|
||||
normal_scanlines = dendy ? 290 : 240;
|
||||
totalscanlines = normal_scanlines + (overclock_enabled ? extrascanlines : 0);
|
||||
FCEUI_SetVidSystem(pal);
|
||||
retro_set_custom_palette();
|
||||
}
|
||||
@@ -1114,34 +1110,34 @@ static void check_variables(bool startup)
|
||||
bool do_reinit = false;
|
||||
|
||||
if (!strcmp(var.value, "disabled")
|
||||
&& overclock_state != 0)
|
||||
&& overclock_enabled != 0)
|
||||
{
|
||||
overclocked = 0;
|
||||
skip_7bit_overclocking = 1;
|
||||
extrascanlines = 0;
|
||||
vblankscanlines = 0;
|
||||
overclock_state = 0;
|
||||
overclock_enabled = 0;
|
||||
do_reinit = true;
|
||||
}
|
||||
else if (!strcmp(var.value, "2x-Postrender"))
|
||||
{
|
||||
overclocked = 1;
|
||||
skip_7bit_overclocking = 1;
|
||||
extrascanlines = 266;
|
||||
vblankscanlines = 0;
|
||||
overclock_state = 1;
|
||||
overclock_enabled = 1;
|
||||
do_reinit = true;
|
||||
}
|
||||
else if (!strcmp(var.value, "2x-VBlank"))
|
||||
{
|
||||
overclocked = 1;
|
||||
skip_7bit_overclocking = 1;
|
||||
extrascanlines = 0;
|
||||
vblankscanlines = 266;
|
||||
overclock_state = 1;
|
||||
overclock_enabled = 1;
|
||||
do_reinit = true;
|
||||
}
|
||||
|
||||
normal_scanlines = dendy ? 290 : 240;
|
||||
totalscanlines = normal_scanlines + (overclock_enabled ? extrascanlines : 0);
|
||||
|
||||
if (do_reinit && startup)
|
||||
{
|
||||
FCEU_KillVirtualVideo();
|
||||
@@ -1239,17 +1235,17 @@ static void check_variables(bool startup)
|
||||
var.key = "fceumm_region";
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
|
||||
{
|
||||
unsigned oldval = setregion;
|
||||
unsigned oldval = opt_region;
|
||||
if (!strcmp(var.value, "Auto"))
|
||||
setregion = 0;
|
||||
opt_region = 0;
|
||||
else if (!strcmp(var.value, "NTSC"))
|
||||
setregion = 1;
|
||||
opt_region = 1;
|
||||
else if (!strcmp(var.value, "PAL"))
|
||||
setregion = 2;
|
||||
opt_region = 2;
|
||||
else if (!strcmp(var.value, "Dendy"))
|
||||
setregion = 3;
|
||||
if (setregion != oldval)
|
||||
FCEUD_RegionOverride(setregion);
|
||||
opt_region = 3;
|
||||
if (opt_region != oldval)
|
||||
FCEUD_RegionOverride(opt_region);
|
||||
}
|
||||
|
||||
var.key = "fceumm_aspect";
|
||||
@@ -2110,6 +2106,7 @@ bool retro_load_game(const struct retro_game_info *game)
|
||||
sndquality = 0;
|
||||
sndvolume = 150;
|
||||
swapDuty = 0;
|
||||
dendy = 0;
|
||||
|
||||
/* Wii: initialize this or else last variable is passed through
|
||||
* when loading another rom causing save state size change. */
|
||||
@@ -2158,7 +2155,8 @@ bool retro_load_game(const struct retro_game_info *game)
|
||||
if (external_palette_exist)
|
||||
FCEU_printf(" Loading custom palette: %s%cnes.pal\n", dir, slash);
|
||||
|
||||
is_PAL = retro_get_region(); /* Save current loaded region info */
|
||||
/* Save region and dendy mode for region-auto detect */
|
||||
systemRegion = (dendy << 1) | retro_get_region() & 1;
|
||||
|
||||
retro_set_custom_palette();
|
||||
FCEUD_SoundToggle();
|
||||
|
||||
@@ -477,7 +477,7 @@ void FCEU_ResetVidSys(void)
|
||||
dendy = 0;
|
||||
|
||||
normal_scanlines = dendy ? 290 : 240;
|
||||
totalscanlines = normal_scanlines + (overclock_state ? extrascanlines : 0);
|
||||
totalscanlines = normal_scanlines + (overclock_enabled ? extrascanlines : 0);
|
||||
|
||||
FCEUPPU_SetVideoSystem(w || dendy);
|
||||
SetSoundVariables();
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
extern int fceuindbg;
|
||||
|
||||
/* Overclocking-related */
|
||||
extern unsigned overclock_state;
|
||||
extern unsigned overclock_enabled;
|
||||
extern unsigned overclocked;
|
||||
extern unsigned skip_7bit_overclocking;
|
||||
extern unsigned DMC_7bit;
|
||||
|
||||
78
src/ines.c
78
src/ines.c
@@ -763,10 +763,12 @@ static BMAPPINGLocal bmap[] = {
|
||||
int iNESLoad(const char *name, FCEUFILE *fp) {
|
||||
struct md5_context md5;
|
||||
char* mappername = NULL;
|
||||
uint32 filesize = fp->fp->size;
|
||||
uint64 filesize = FCEU_fgetsize(fp);
|
||||
uint64 romSize = 0;
|
||||
uint32 mappertest = 0;
|
||||
uint32 prgRom = 0;
|
||||
uint32 chrRom = 0;
|
||||
uint32 region = 0;
|
||||
|
||||
if (FCEU_fread(&head, 1, 16, fp) != 16)
|
||||
return 0;
|
||||
@@ -795,46 +797,42 @@ int iNESLoad(const char *name, FCEUFILE *fp) {
|
||||
memset((char*)(&head) + 0xA, 0, 0x6);
|
||||
}
|
||||
|
||||
Mirroring = 0;
|
||||
ROM_size = 0;
|
||||
VROM_size = 0;
|
||||
iNES2 = 0;
|
||||
MapperNo = 0;
|
||||
subMapper = 0;
|
||||
|
||||
MapperNo = (head.ROM_type >> 4) | (head.ROM_type2 & 0xF0);
|
||||
Mirroring = (head.ROM_type & 8) ? 2 : (head.ROM_type & 1);
|
||||
prgRom = head.ROM_size;
|
||||
chrRom = head.VROM_size;
|
||||
iNES2 = ((head.ROM_type2 & 0x0C) == 0x08) ? 1 : 0;
|
||||
|
||||
if ((head.ROM_type2 & 0x0C) == 0x08) {
|
||||
iNES2 = 1;
|
||||
if (iNES2) {
|
||||
MapperNo |= ((uint32)head.ROM_type3 << 8) & 0xF00;
|
||||
prgRom |= ((uint32)head.upper_PRG_CHR_size << 8) & 0xF00;
|
||||
chrRom |= ((uint32)head.upper_PRG_CHR_size << 4) & 0xF00;
|
||||
|
||||
subMapper = head.ROM_type3 >> 4 & 0x0F;
|
||||
subMapper = (head.ROM_type3 >> 4) & 0x0F;
|
||||
iNESCart.prgRam = (head.PRGRAM_size & 0x0F) ? (64 << (head.PRGRAM_size & 0x0F)) : 0;
|
||||
iNESCart.chrRam = (head.CHRRAM_size & 0x0F) ? (64 << (head.CHRRAM_size & 0x0F)) : 0;
|
||||
iNESCart.prgRam_battery = (head.PRGRAM_size & 0xF0) ? (64 << ((head.PRGRAM_size & 0xF0) >> 4)) : 0;
|
||||
iNESCart.chrRam_battery = (head.CHRRAM_size & 0xF0) ? (64 << ((head.CHRRAM_size & 0xF0) >> 4)) : 0;
|
||||
iNESCart.region = head.Region;
|
||||
region = (head.Region & 3);
|
||||
} else {
|
||||
if (!prgRom)
|
||||
prgRom = 256;
|
||||
}
|
||||
|
||||
if (head.ROM_type & 4) { /* Trainer */
|
||||
/* Trainer */
|
||||
if (head.ROM_type & 4) {
|
||||
trainerpoo = (uint8*)FCEU_gmalloc(512);
|
||||
FCEU_fread(trainerpoo, 512, 1, fp);
|
||||
filesize -= 512;
|
||||
}
|
||||
|
||||
if (((prgRom * 0x4000) + (chrRom * 0x2000)) > filesize) {
|
||||
FCEU_PrintError(" File length is too short to contain all data reported from header by %llu\n", ((prgRom * 0x4000) + (chrRom * 0x2000)) - filesize);
|
||||
romSize = (prgRom * 0x4000) + (chrRom * 0x2000);
|
||||
if (romSize > filesize) {
|
||||
FCEU_PrintError(" File length is too short to contain all data reported from header by %llu\n", romSize - filesize);
|
||||
return 0;
|
||||
} else if (((prgRom * 0x4000) + (chrRom * 0x2000)) < filesize)
|
||||
FCEU_PrintError(" File contains %llu bytes of unused data\n", filesize - ((prgRom * 0x4000) + (chrRom * 0x2000)));
|
||||
} else if (romSize < filesize)
|
||||
FCEU_PrintError(" File contains %llu bytes of unused data\n", filesize - romSize);
|
||||
|
||||
iNESCart.prgRom = prgRom;
|
||||
iNESCart.chrRom = chrRom;
|
||||
@@ -907,11 +905,11 @@ int iNESLoad(const char *name, FCEUFILE *fp) {
|
||||
else
|
||||
SetupCartMirroring(Mirroring & 1, (Mirroring & 4) >> 2, 0);
|
||||
|
||||
iNESCart.iNES2 = iNES2;
|
||||
iNESCart.mapper = MapperNo;
|
||||
iNESCart.iNES2 = iNES2;
|
||||
iNESCart.mapper = MapperNo;
|
||||
iNESCart.submapper = subMapper;
|
||||
iNESCart.battery = (head.ROM_type & 2) ? 1 : 0;
|
||||
iNESCart.mirror = Mirroring;
|
||||
iNESCart.battery = (head.ROM_type & 2) ? 1 : 0;
|
||||
iNESCart.mirror = Mirroring;
|
||||
|
||||
mappername = "Not Listed";
|
||||
|
||||
@@ -945,7 +943,7 @@ int iNESLoad(const char *name, FCEUFILE *fp) {
|
||||
}
|
||||
}
|
||||
FCEU_printf(" Mirroring: %s\n", Mirroring == 2 ? "None (Four-screen)" : Mirroring ? "Vertical" : "Horizontal");
|
||||
FCEU_printf(" System: %s\n", tv_region[(iNESCart.region & 3)]);
|
||||
FCEU_printf(" System: %s\n", tv_region[region]);
|
||||
FCEU_printf(" Trained: %s\n", (head.ROM_type & 4) ? "Yes" : "No");
|
||||
} else {
|
||||
FCEU_printf(" Mapper #: %3d\n", MapperNo);
|
||||
@@ -963,18 +961,7 @@ int iNESLoad(const char *name, FCEUFILE *fp) {
|
||||
|
||||
GameInterface = iNESGI;
|
||||
|
||||
if (iNES2) {
|
||||
switch (iNESCart.region & 0x03) {
|
||||
/* 0: RP2C02 ("NTSC NES")
|
||||
* 1: RP2C07 ("Licensed PAL NES")
|
||||
* 2: Multiple-region
|
||||
* 3: UMC 6527P ("Dendy")
|
||||
*/
|
||||
case 0: case 2: FCEUI_SetVidSystem(0); break;
|
||||
case 1: FCEUI_SetVidSystem(1); break;
|
||||
case 3: dendy = 1; FCEUI_SetVidSystem(0); break;
|
||||
}
|
||||
} else {
|
||||
if (iNES2 == 0) {
|
||||
if (strstr(name, "(E)") || strstr(name, "(e)") ||
|
||||
strstr(name, "(Europe)") || strstr(name, "(PAL)") ||
|
||||
strstr(name, "(F)") || strstr(name, "(f)") ||
|
||||
@@ -986,14 +973,31 @@ int iNESLoad(const char *name, FCEUFILE *fp) {
|
||||
strstr(name, "(Sweden)") || strstr(name, "(Sw)") ||
|
||||
strstr(name, "(Australia)") || strstr(name, "(A)") ||
|
||||
strstr(name, "(a)")) {
|
||||
iNESCart.region = 1;
|
||||
FCEUI_SetVidSystem(1);
|
||||
region = 1;
|
||||
} else {
|
||||
iNESCart.region = 0;
|
||||
FCEUI_SetVidSystem(0);
|
||||
region = 0;
|
||||
}
|
||||
}
|
||||
|
||||
iNESCart.region = region;
|
||||
switch (region) {
|
||||
/* 0: RP2C02 ("NTSC NES")
|
||||
* 1: RP2C07 ("Licensed PAL NES")
|
||||
* 2: Multiple-region
|
||||
* 3: UMC 6527P ("Dendy")
|
||||
*/
|
||||
case 1:
|
||||
FCEUI_SetVidSystem(1);
|
||||
break;
|
||||
case 3:
|
||||
dendy = 1;
|
||||
/* fallthrough */
|
||||
case 0:
|
||||
case 2:
|
||||
FCEUI_SetVidSystem(0);
|
||||
break;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -1156,7 +1156,7 @@ int FCEUPPU_Loop(int skip) {
|
||||
TriggerNMI();
|
||||
}
|
||||
X6502_Run((scanlines_per_frame - 242) * (256 + 85) - 12);
|
||||
if (overclock_state && vblankscanlines) {
|
||||
if (overclock_enabled && vblankscanlines) {
|
||||
if (!DMC_7bit || !skip_7bit_overclocking) {
|
||||
overclocked = 1;
|
||||
X6502_Run(vblankscanlines * (256 + 85) - 12);
|
||||
@@ -1227,7 +1227,7 @@ int FCEUPPU_Loop(int skip) {
|
||||
if (DMC_7bit && skip_7bit_overclocking)
|
||||
totalscanlines = normal_scanlines;
|
||||
else
|
||||
totalscanlines = normal_scanlines + (overclock_state ? extrascanlines : 0);
|
||||
totalscanlines = normal_scanlines + (overclock_enabled ? extrascanlines : 0);
|
||||
|
||||
for (scanline = 0; scanline < totalscanlines; ) { /* scanline is incremented in DoLine. Evil. :/ */
|
||||
deempcnt[deemp]++;
|
||||
|
||||
Reference in New Issue
Block a user