From aa4615c41714b43dfe71831760494e1ce51d8597 Mon Sep 17 00:00:00 2001 From: Autechre Date: Sat, 5 Jun 2021 15:05:07 +0200 Subject: [PATCH] Revert "some cleanups" --- Makefile.libretro | 4 +- src/cart.h | 3 - src/drivers/libretro/libretro.c | 143 ++++++++++++++++++++++---------- src/fceu.c | 26 +++--- src/fceu.h | 28 ++++--- src/ines.c | 3 +- src/input.h | 2 - src/ppu.c | 36 ++++---- src/ppu.h | 14 ---- src/ppuview.h | 13 +++ src/sound.c | 6 +- src/sound.h | 1 - src/video.c | 11 +-- src/video.h | 1 + src/x6502.c | 7 +- src/x6502.h | 3 +- 16 files changed, 174 insertions(+), 127 deletions(-) create mode 100644 src/ppuview.h diff --git a/Makefile.libretro b/Makefile.libretro index 2387bed..86563b0 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -752,8 +752,8 @@ else WARNING_DEFINES = -Wno-write-strings endif -CFLAGS += $(fpic) $(WARNING_DEFINES) $(DEFINES) $(ENDIANNESS_DEFINES) -Werror=implicit-function-declaration -LDFLAGS += $(LIBM) -Werror=implicit-function-declaration +CFLAGS += $(fpic) $(WARNING_DEFINES) $(DEFINES) $(ENDIANNESS_DEFINES) +LDFLAGS += $(LIBM) ifeq ($(platform), psp1) INCFLAGS += -I$(shell psp-config --pspsdk-path)/include diff --git a/src/cart.h b/src/cart.h index cd05d4b..4573403 100644 --- a/src/cart.h +++ b/src/cart.h @@ -104,7 +104,4 @@ void FCEU_OpenGenie(void); void FCEU_CloseGenie(void); void FCEU_KillGenie(void); -extern CartInfo iNESCart; -extern CartInfo UNIFCart; - #endif diff --git a/src/drivers/libretro/libretro.c b/src/drivers/libretro/libretro.c index 7ff7dcb..39263fc 100644 --- a/src/drivers/libretro/libretro.c +++ b/src/drivers/libretro/libretro.c @@ -67,6 +67,8 @@ void linearFree(void* mem); RETRO_HW_RENDER_INTEFACE_GSKIT_PS2 *ps2 = NULL; #endif +extern void FCEU_ZapperSetTolerance(int t); + static retro_video_refresh_t video_cb = NULL; static retro_input_poll_t poll_cb = NULL; static retro_input_state_t input_cb = NULL; @@ -93,7 +95,7 @@ static int aspect_ratio_par; #define MAX_BUTTONS 8 #define TURBO_BUTTONS 2 -unsigned turbo_button_toggle[MAX_PLAYERS][TURBO_BUTTONS] = { {0} }; +unsigned char turbo_button_toggle[MAX_PLAYERS][TURBO_BUTTONS] = { {0} }; typedef struct { @@ -143,11 +145,27 @@ static bool libretro_supports_bitmasks = false; const size_t PPU_BIT = 1ULL << 31ULL; +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_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; +unsigned dendy = 0; + static unsigned systemRegion = 0; static unsigned opt_region = 0; static unsigned opt_showAdvSoundOptions = 0; static unsigned opt_showAdvSystemOptions = 0; +int FCEUnetplay; + #if defined(PSP) || defined(PS2) static __attribute__((aligned(16))) uint16_t retro_palette[256]; #else @@ -163,14 +181,28 @@ static uint16_t* fceu_video_out; static unsigned sndsamplerate; static unsigned sndquality; static unsigned sndvolume; +unsigned swapDuty; static int32_t *sound = 0; static uint32_t Dummy = 0; static uint32_t current_palette = 0; static unsigned serialize_size; +int PPUViewScanline=0; +int PPUViewer=0; + +/* extern forward decls.*/ +extern FCEUGI *GameInfo; +extern uint8 *XBuf; +extern CartInfo iNESCart; +extern CartInfo UNIFCart; +extern int show_crosshair; +extern int option_ramstate; + /* emulator-specific callback functions */ +void UpdatePPUView(int refreshchr) { } + const char * GetKeyboard(void) { return ""; @@ -273,7 +305,13 @@ FILE *FCEUD_UTF8fopen(const char *n, const char *m) } /*palette for FCEU*/ +#define PAL_TOTAL 16 /* total no. of palettes in palettes[] */ +#define PAL_DEFAULT (PAL_TOTAL + 1) +#define PAL_RAW (PAL_TOTAL + 2) +#define PAL_CUSTOM (PAL_TOTAL + 3) + static int external_palette_exist = 0; +extern int ipalette; /* table for currently loaded palette */ static uint8_t base_palette[192]; @@ -575,11 +613,6 @@ struct st_palettes palettes[] = { } }; -#define PAL_TOTAL (sizeof(palettes) / sizeof(palettes[0])) /* total palettes in table */ -#define PAL_DEFAULT (PAL_TOTAL + 1) -#define PAL_RAW (PAL_TOTAL + 2) -#define PAL_CUSTOM (PAL_TOTAL + 3) - #ifdef HAVE_NTSC_FILTER /* ntsc */ #include "nes_ntsc.h" @@ -955,7 +988,7 @@ void retro_get_system_av_info(struct retro_system_av_info *info) info->geometry.max_height = NES_HEIGHT; info->geometry.aspect_ratio = get_aspect_ratio(width, height); info->timing.sample_rate = (float)sndsamplerate; - if (FSettings.PAL || FSettings.dendy) + if (FSettings.PAL || dendy) info->timing.fps = 838977920.0/16777215.0; else info->timing.fps = 1008307711.0/16777215.0; @@ -1060,7 +1093,7 @@ static void FCEUD_RegionOverride(unsigned region) break; } - FSettings.dendy = d; + dendy = d; FCEUI_SetVidSystem(pal); ResetPalette(); } @@ -1116,11 +1149,11 @@ static void check_variables(bool startup) if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { if (!strcmp(var.value, "random")) - FSettings.ramstate = 2; + option_ramstate = 2; else if (!strcmp(var.value, "fill $00")) - FSettings.ramstate = 1; + option_ramstate = 1; else - FSettings.ramstate = 0; + option_ramstate = 0; } #ifdef HAVE_NTSC_FILTER @@ -1159,18 +1192,38 @@ static void check_variables(bool startup) current_palette = PAL_RAW; else if (!strcmp(var.value, "custom")) current_palette = PAL_CUSTOM; - else - { - unsigned i; - for (i = 0; i < PAL_TOTAL; i++) - { - if (!strcmp(var.value, palettes[i].name)) - { - current_palette = i; - break; - } - } - } + else if (!strcmp(var.value, "asqrealc")) + current_palette = 0; + else if (!strcmp(var.value, "nintendo-vc")) + current_palette = 1; + else if (!strcmp(var.value, "rgb")) + current_palette = 2; + else if (!strcmp(var.value, "yuv-v3")) + current_palette = 3; + else if (!strcmp(var.value, "unsaturated-final")) + current_palette = 4; + else if (!strcmp(var.value, "sony-cxa2025as-us")) + current_palette = 5; + else if (!strcmp(var.value, "pal")) + current_palette = 6; + else if (!strcmp(var.value, "bmf-final2")) + current_palette = 7; + else if (!strcmp(var.value, "bmf-final3")) + current_palette = 8; + else if (!strcmp(var.value, "smooth-fbx")) + current_palette = 9; + else if (!strcmp(var.value, "composite-direct-fbx")) + current_palette = 10; + else if (!strcmp(var.value, "pvm-style-d93-fbx")) + current_palette = 11; + else if (!strcmp(var.value, "ntsc-hardware-fbx")) + current_palette = 12; + else if (!strcmp(var.value, "nes-classic-fbx-fs")) + current_palette = 13; + else if (!strcmp(var.value, "nescap")) + current_palette = 14; + else if (!strcmp(var.value, "wavebeam")) + current_palette = 15; if (current_palette != orig_value) { @@ -1201,33 +1254,33 @@ static void check_variables(bool startup) bool do_reinit = false; if (!strcmp(var.value, "disabled") - && ppu.overclock_enabled != 0) + && overclock_enabled != 0) { - ppu.skip_7bit_overclocking = 1; - ppu.extrascanlines = 0; - ppu.vblankscanlines = 0; - ppu.overclock_enabled = 0; + skip_7bit_overclocking = 1; + extrascanlines = 0; + vblankscanlines = 0; + overclock_enabled = 0; do_reinit = true; } else if (!strcmp(var.value, "2x-Postrender")) { - ppu.skip_7bit_overclocking = 1; - ppu.extrascanlines = 266; - ppu.vblankscanlines = 0; - ppu.overclock_enabled = 1; + skip_7bit_overclocking = 1; + extrascanlines = 266; + vblankscanlines = 0; + overclock_enabled = 1; do_reinit = true; } else if (!strcmp(var.value, "2x-VBlank")) { - ppu.skip_7bit_overclocking = 1; - ppu.extrascanlines = 0; - ppu.vblankscanlines = 266; - ppu.overclock_enabled = 1; + skip_7bit_overclocking = 1; + extrascanlines = 0; + vblankscanlines = 266; + overclock_enabled = 1; do_reinit = true; } - ppu.normal_scanlines = FSettings.dendy ? SCANLINES_DENDY : SCANLINES_NORMAL; - ppu.totalscanlines = ppu.normal_scanlines + (ppu.overclock_enabled ? ppu.extrascanlines : 0); + normal_scanlines = dendy ? 290 : 240; + totalscanlines = normal_scanlines + (overclock_enabled ? extrascanlines : 0); if (do_reinit && startup) { @@ -1259,10 +1312,8 @@ static void check_variables(bool startup) if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { - if (!strcmp(var.value, "enabled")) - FSettings.show_crosshair = 1; - else if (!strcmp(var.value, "disabled")) - FSettings.show_crosshair = 0; + if (!strcmp(var.value, "enabled")) show_crosshair = 1; + else if (!strcmp(var.value, "disabled")) show_crosshair = 0; } #ifdef PSP @@ -1400,8 +1451,8 @@ static void check_variables(bool startup) if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { bool newval = (!strcmp(var.value, "enabled")); - if (newval != FSettings.swapDuty) - FSettings.swapDuty = newval; + if (newval != swapDuty) + swapDuty = newval; } var.key = key; @@ -2377,6 +2428,8 @@ bool retro_load_game(const struct retro_game_info *game) #endif sndquality = 0; sndvolume = 150; + swapDuty = 0; + dendy = 0; opt_region = 0; /* Wii: initialize this or else last variable is passed through @@ -2436,7 +2489,7 @@ bool retro_load_game(const struct retro_game_info *game) FCEU_printf(" Loading custom palette: %s%cnes.pal\n", dir, slash); /* Save region and dendy mode for region-auto detect */ - systemRegion = (FSettings.dendy << 1) | (retro_get_region() & 1); + systemRegion = (dendy << 1) | (retro_get_region() & 1); current_palette = 0; diff --git a/src/fceu.c b/src/fceu.c index 564b67f..0d471b9 100644 --- a/src/fceu.c +++ b/src/fceu.c @@ -339,14 +339,6 @@ int FCEUI_Initialize(void) { FSettings.UsrLastSLine[0] = 231; FSettings.UsrLastSLine[1] = 239; FSettings.SoundVolume = 100; - FSettings.dendy = 0; - FSettings.swapDuty = 0; - ppu.overclock_enabled = 0; - ppu.skip_7bit_overclocking = 1; - ppu.totalscanlines = 0; - ppu.normal_scanlines = SCANLINES_NORMAL; - ppu.extrascanlines = 0; - ppu.vblankscanlines = 0; FCEUPPU_Init(); X6502_Init(); return 1; @@ -387,6 +379,8 @@ void ResetNES(void) X6502_Reset(); } +int option_ramstate = 0; + void FCEU_MemoryRand(uint8 *ptr, uint32 size) { int x = 0; @@ -401,7 +395,7 @@ void FCEU_MemoryRand(uint8 *ptr, uint32 size) /* 1942 SCORE/HISCORE is screwed... */ #endif uint8_t v = 0; - switch (FSettings.ramstate) + switch (option_ramstate) { case 0: v = 0xff; break; case 1: v = 0x00; break; @@ -470,7 +464,7 @@ void FCEU_ResetVidSys(void) else if (GameInfo->vidsys == GIV_PAL) { w = 1; - FSettings.dendy = 0; + dendy = 0; } else w = FSettings.PAL; @@ -478,12 +472,12 @@ void FCEU_ResetVidSys(void) PAL = w ? 1 : 0; if (PAL) - FSettings.dendy = 0; + dendy = 0; - ppu.normal_scanlines = FSettings.dendy ? SCANLINES_DENDY : SCANLINES_NORMAL; - ppu.totalscanlines = ppu.normal_scanlines + (ppu.overclock_enabled ? ppu.extrascanlines : 0); + normal_scanlines = dendy ? 290 : 240; + totalscanlines = normal_scanlines + (overclock_enabled ? extrascanlines : 0); - FCEUPPU_SetVideoSystem(w || FSettings.dendy); + FCEUPPU_SetVideoSystem(w || dendy); SetSoundVariables(); } @@ -521,7 +515,7 @@ void FCEUI_SetRenderedLines(int ntscf, int ntscl, int palf, int pall) FSettings.UsrLastSLine[0] = ntscl; FSettings.UsrFirstSLine[1] = palf; FSettings.UsrLastSLine[1] = pall; - if (PAL || FSettings.dendy) + if (PAL || dendy) { FSettings.FirstSLine = FSettings.UsrFirstSLine[1]; FSettings.LastSLine = FSettings.UsrLastSLine[1]; @@ -565,7 +559,7 @@ void FCEUI_SetSnapName(int a) int32 FCEUI_GetDesiredFPS(void) { - if (PAL || FSettings.dendy) + if (PAL || dendy) return(838977920); /* ~50.007 */ else return(1008307711); /* ~60.1 */ diff --git a/src/fceu.h b/src/fceu.h index 4756bda..f97b425 100644 --- a/src/fceu.h +++ b/src/fceu.h @@ -5,6 +5,24 @@ extern int fceuindbg; +/* Overclocking-related */ +extern unsigned overclock_enabled; +extern unsigned overclocked; +extern unsigned skip_7bit_overclocking; +extern unsigned DMC_7bit; +extern unsigned totalscanlines; +extern unsigned normal_scanlines; +extern unsigned extrascanlines; +extern unsigned vblankscanlines; + +/* Region selection */ +extern unsigned dendy; + +/* Audio mods*/ +extern unsigned swapDuty; /* Swap bits 6 & 7 of $4000/$4004 to mimic bug + * found on some famiclones/Dendy models. + */ + void ResetGameLoaded(void); #define DECLFR(x) uint8 FP_FASTAPASS(1) x(uint32 A) @@ -61,9 +79,6 @@ extern uint8 PAL; #include "driver.h" -#define SCANLINES_NORMAL 240 -#define SCANLINES_DENDY 290 - typedef struct { int PAL; int NetworkPlay; @@ -87,13 +102,6 @@ typedef struct { uint32 SndRate; int soundq; int lowpass; - - int show_crosshair; - int ramstate; - int dendy; - int swapDuty; /* Swap bits 6 & 7 of $4000/$4004 to mimic bug - * found on some famiclones/Dendy models. - */ } FCEUS; extern FCEUS FSettings; diff --git a/src/ines.c b/src/ines.c index 0c92e30..ca7f2bc 100644 --- a/src/ines.c +++ b/src/ines.c @@ -1067,8 +1067,7 @@ int iNESLoad(const char *name, FCEUFILE *fp) { * 1: RP2C07 ("Licensed PAL NES") * 2: Multiple-region * 3: UMC 6527P ("Dendy") */ - if (iNESCart.region == 3) - FSettings.dendy = 1; + if (iNESCart.region == 3) dendy = 1; FCEUI_SetVidSystem((iNESCart.region == 1) ? 1 : 0); return 1; diff --git a/src/input.h b/src/input.h index 1ab1e39..82061bc 100644 --- a/src/input.h +++ b/src/input.h @@ -29,6 +29,4 @@ extern void (*InputScanlineHook)(uint8 *bg, uint8 *spr, uint32 linets, int final void FCEU_DoSimpleCommand(int cmd); -void FCEU_ZapperSetTolerance(int t); - #endif diff --git a/src/ppu.c b/src/ppu.c index b6ae1c5..45ccc7f 100644 --- a/src/ppu.c +++ b/src/ppu.c @@ -32,6 +32,7 @@ #include "general.h" #include "fceu-endian.h" #include "fceu-memory.h" +#include "ppuview.h" #include "cart.h" #include "palette.h" @@ -63,8 +64,6 @@ static uint32 ppulut1[256]; static uint32 ppulut2[256]; static uint32 ppulut3[128]; -FCEU_PPU ppu; - static void makeppulut(void) { int x; int y; @@ -661,7 +660,7 @@ static void DoLine(void) uint8 *target = NULL; uint8 *dtarget = NULL; - if (scanline >= 240 && scanline != ppu.totalscanlines) + if (scanline >= 240 && scanline != totalscanlines) { X6502_Run(256 + 69); scanline++; @@ -1067,7 +1066,7 @@ static void CopySprites(uint8 *target) { void FCEUPPU_SetVideoSystem(int w) { if (w) { - scanlines_per_frame = FSettings.dendy ? 262 : 312; + scanlines_per_frame = dendy ? 262 : 312; FSettings.FirstSLine = FSettings.UsrFirstSLine[1]; FSettings.LastSLine = FSettings.UsrLastSLine[1]; } else { @@ -1167,11 +1166,11 @@ int FCEUPPU_Loop(int skip) { TriggerNMI(); } X6502_Run((scanlines_per_frame - 242) * (256 + 85) - 12); - if (ppu.overclock_enabled && ppu.vblankscanlines) { - if (!DMC_7bit || !ppu.skip_7bit_overclocking) { - overclocking = 1; - X6502_Run(ppu.vblankscanlines * (256 + 85) - 12); - overclocking = 0; + if (overclock_enabled && vblankscanlines) { + if (!DMC_7bit || !skip_7bit_overclocking) { + overclocked = 1; + X6502_Run(vblankscanlines * (256 + 85) - 12); + overclocked = 0; } } PPU_status &= 0x1f; @@ -1204,7 +1203,7 @@ int FCEUPPU_Loop(int skip) { kook ^= 1; } if (GameInfo->type == GIT_NSF) - X6502_Run((256 + 85) * ppu.normal_scanlines); + X6502_Run((256 + 85) * normal_scanlines); #ifdef FRAMESKIP else if (skip) { int y; @@ -1235,20 +1234,21 @@ int FCEUPPU_Loop(int skip) { deemp = PPU[1] >> 5; /* manual samples can't play correctly with overclocking */ - if (DMC_7bit && ppu.skip_7bit_overclocking) - ppu.totalscanlines = ppu.normal_scanlines; + if (DMC_7bit && skip_7bit_overclocking) + totalscanlines = normal_scanlines; else - ppu.totalscanlines = ppu.normal_scanlines + (ppu.overclock_enabled ? ppu.extrascanlines : 0); + totalscanlines = normal_scanlines + (overclock_enabled ? extrascanlines : 0); - for (scanline = 0; scanline < ppu.totalscanlines; ) { /* scanline is incremented in DoLine. Evil. :/ */ + for (scanline = 0; scanline < totalscanlines; ) { /* scanline is incremented in DoLine. Evil. :/ */ deempcnt[deemp]++; + /* if ((PPUViewer) && (scanline == PPUViewScanline)) UpdatePPUView(1); */ DoLine(); - if (scanline < ppu.normal_scanlines || scanline == ppu.totalscanlines) - overclocking = 0; + if (scanline < normal_scanlines || scanline == totalscanlines) + overclocked = 0; else { - if (DMC_7bit && ppu.skip_7bit_overclocking) /* 7bit sample started after 240th line */ + if (DMC_7bit && skip_7bit_overclocking) /* 7bit sample started after 240th line */ break; - overclocking = 1; + overclocked = 1; } } diff --git a/src/ppu.h b/src/ppu.h index 829de71..96338a1 100644 --- a/src/ppu.h +++ b/src/ppu.h @@ -1,18 +1,6 @@ #ifndef _FCEU_PPU_H #define _FCEU_PPU_H -typedef struct { - /* PPU Overclocking */ - int overclock_enabled; /* 1 : enable, 0 : disable duh! */ - int skip_7bit_overclocking; /* 7-bit samples have priority over overclocking */ - int extrascanlines; - int vblankscanlines; - int normal_scanlines; /* 240 : normal, 290 : dendy */ - int totalscanlines; -} FCEU_PPU; - -extern FCEU_PPU ppu; - void FCEUPPU_Init(void); void FCEUPPU_Reset(void); void FCEUPPU_Power(void); @@ -28,8 +16,6 @@ extern void FP_FASTAPASS(1) (*PPU_hook)(uint32 A); extern uint8 NTARAM[0x800], *vnapage[4]; extern uint8 PPUNTARAM; extern uint8 PPUCHRRAM; -extern uint8 PALRAM[0x20]; -extern uint8 SPRAM[0x100]; void FCEUPPU_SaveState(void); void FCEUPPU_LoadState(int version); diff --git a/src/ppuview.h b/src/ppuview.h new file mode 100644 index 0000000..740a183 --- /dev/null +++ b/src/ppuview.h @@ -0,0 +1,13 @@ +#ifndef _FCEU_PPUVIEW_H +#define _FCEU_PPUVIEW_H + +extern int PPUViewScanline; +extern int PPUViewer; +extern int scanline; + +void PPUViewDoBlit(); +void DoPPUView(); +void UpdatePPUView(int refreshchr); + + +#endif diff --git a/src/sound.c b/src/sound.c index a72f93a..a483d16 100644 --- a/src/sound.c +++ b/src/sound.c @@ -61,7 +61,7 @@ typedef struct { int reloaddec; } ENVUNIT; -uint32 DMC_7bit = 0; /* used to skip overclocking */ +unsigned DMC_7bit = 0; /* used to skip overclocking */ static ENVUNIT EnvUnits[3]; static const int RectDuties[4] = { 1, 2, 4, 6 }; @@ -195,7 +195,7 @@ static DECLFW(Write_PSG) { DoSQ1(); EnvUnits[0].Mode = (V & 0x30) >> 4; EnvUnits[0].Speed = (V & 0xF); - if (FSettings.swapDuty) + if (swapDuty) V = (V & 0x3F) | ((V & 0x80) >> 1) | ((V & 0x40) << 1); break; case 0x1: @@ -216,7 +216,7 @@ static DECLFW(Write_PSG) { DoSQ2(); EnvUnits[1].Mode = (V & 0x30) >> 4; EnvUnits[1].Speed = (V & 0xF); - if (FSettings.swapDuty) + if (swapDuty) V = (V & 0x3F) | ((V & 0x80) >> 1) | ((V & 0x40) << 1); break; case 0x5: diff --git a/src/sound.h b/src/sound.h index d10a56a..c4413cc 100644 --- a/src/sound.h +++ b/src/sound.h @@ -50,7 +50,6 @@ extern int32 Wave[2048 + 512]; extern int32 WaveFinal[2048 + 512]; extern int32 WaveHi[]; extern uint32 soundtsinc; -extern uint32 DMC_7bit; extern uint32 soundtsoffs; #define SOUNDTS (sound_timestamp + soundtsoffs) diff --git a/src/video.c b/src/video.c index 80da854..0017fc1 100644 --- a/src/video.c +++ b/src/video.c @@ -37,6 +37,7 @@ uint8 *XBuf = NULL; uint8 *XDBuf = NULL; +int show_crosshair = 0; void FCEU_KillVirtualVideo(void) { @@ -52,15 +53,15 @@ int FCEU_InitVirtualVideo(void) { /* 256 bytes per scanline, * 240 scanline maximum, +8 for alignment, */ if (!XBuf) - XBuf = (uint8*)(FCEU_malloc(256 * (256 + ppu.extrascanlines + 8))); + XBuf = (uint8*)(FCEU_malloc(256 * (256 + extrascanlines + 8))); if (!XDBuf) - XDBuf = (uint8*)(FCEU_malloc(256 * (256 + ppu.extrascanlines + 8))); + XDBuf = (uint8*)(FCEU_malloc(256 * (256 + extrascanlines + 8))); if (!XBuf || !XDBuf) return 0; - memset(XBuf, 128, 256 * (256 + ppu.extrascanlines + 8)); - memset(XDBuf, 128, 256 * (256 + ppu.extrascanlines + 8)); + memset(XBuf, 128, 256 * (256 + extrascanlines + 8)); + memset(XDBuf, 128, 256 * (256 + extrascanlines + 8)); return 1; } @@ -81,7 +82,7 @@ void FCEU_PutImage(void) FCEU_VSUniDraw(XBuf); } if (howlong) howlong--; - if (FSettings.show_crosshair) + if (show_crosshair) FCEU_DrawInput(XBuf); } diff --git a/src/video.h b/src/video.h index b98a419..9eef95b 100644 --- a/src/video.h +++ b/src/video.h @@ -6,6 +6,7 @@ void FCEU_KillVirtualVideo(void); int SaveSnapshot(void); extern uint8 *XBuf; extern uint8 *XDBuf; +extern int show_crosshair; void FCEU_DrawNumberRow(uint8 *XBuf, int *nstatus, int cur); #endif diff --git a/src/x6502.c b/src/x6502.c index 0d00377..b8bf2d9 100644 --- a/src/x6502.c +++ b/src/x6502.c @@ -34,7 +34,6 @@ void (*X6502_Run)(int32 cycles); uint32 timestamp; uint32 sound_timestamp; -uint32 overclocking = 0; void FP_FASTAPASS(1) (*MapIRQHook)(int a); #define _PC X.PC @@ -55,7 +54,7 @@ void FP_FASTAPASS(1) (*MapIRQHook)(int a); _tcount += __x; \ _count -= __x * 48; \ timestamp += __x; \ - if (!overclocking) sound_timestamp += __x; \ + if (!overclocked) sound_timestamp += __x; \ } static INLINE uint8 RdMemNorm(uint32 A) { @@ -517,7 +516,7 @@ static void X6502_RunDebug(int32 cycles) { _tcount = 0; if (MapIRQHook) MapIRQHook(temp); - if (!overclocking) + if (!overclocked) FCEU_SoundCPUHook(temp); _PC++; @@ -614,7 +613,7 @@ void X6502_Run(int32 cycles) temp = _tcount; _tcount = 0; if (MapIRQHook) MapIRQHook(temp); - if (!overclocking) + if (!overclocked) FCEU_SoundCPUHook(temp); X.PC = pbackus; _PC++; diff --git a/src/x6502.h b/src/x6502.h index d9d8b65..f480544 100644 --- a/src/x6502.h +++ b/src/x6502.h @@ -35,7 +35,6 @@ void X6502_Run(int32 cycles); extern uint32 timestamp; extern uint32 sound_timestamp; -extern uint32 overclocking; extern X6502 X; #define N_FLAG 0x80 @@ -49,7 +48,7 @@ extern X6502 X; extern void FP_FASTAPASS(1) (*MapIRQHook)(int a); -#define NTSC_CPU (FSettings.dendy ? 1773447.467 : 1789772.7272727272727272) +#define NTSC_CPU (dendy ? 1773447.467 : 1789772.7272727272727272) #define PAL_CPU 1662607.125 #define FCEU_IQEXT 0x001