Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/fceux.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAutomerge Bot <bot@example.com>2022-08-24 03:32:58 +0300
committerAutomerge Bot <bot@example.com>2022-08-24 03:32:58 +0300
commit310c42ed2867b4d1973003c7f413f743cd36c655 (patch)
tree03e33b484a0fc93a169064f9acb73d0d3f72b08d
parent719665fb6e777aac12c01f92fdc52f5c2bff2ee5 (diff)
parentd0add7a609ec818b4bfb93ca586873b41847d3a9 (diff)
Merge branch 'master' of https://github.com/TASVideos/fceux into coolgirl
-rw-r--r--src/drivers/Qt/ConsoleWindow.cpp11
-rw-r--r--src/drivers/Qt/config.cpp7
-rw-r--r--src/drivers/Qt/config.h2
-rw-r--r--src/drivers/common/vidblit.cpp10
-rw-r--r--src/ines.cpp14
-rw-r--r--src/ppu.cpp62
-rw-r--r--src/state.cpp21
-rw-r--r--src/utils/memory.cpp65
-rw-r--r--src/utils/memory.h18
-rw-r--r--src/video.cpp22
-rw-r--r--src/video.h10
11 files changed, 159 insertions, 83 deletions
diff --git a/src/drivers/Qt/ConsoleWindow.cpp b/src/drivers/Qt/ConsoleWindow.cpp
index 23e4bf40..fd5119c4 100644
--- a/src/drivers/Qt/ConsoleWindow.cpp
+++ b/src/drivers/Qt/ConsoleWindow.cpp
@@ -1282,16 +1282,16 @@ void consoleWin_t::createMainMenu(void)
connect( Hotkeys[ HK_POWER ].getShortcut(), SIGNAL(activated()), this, SLOT(powerConsoleCB(void)) );
// Emulation -> Reset
- resetAct = new QAction(tr("&Reset"), this);
+ resetAct = new QAction(tr("Hard &Reset"), this);
//resetAct->setShortcut( QKeySequence(tr("Ctrl+R")));
- resetAct->setStatusTip(tr("Reset Console"));
+ resetAct->setStatusTip(tr("Hard Reset of Console"));
resetAct->setIcon( style()->standardIcon( QStyle::SP_DialogResetButton ) );
connect(resetAct, SIGNAL(triggered()), this, SLOT(consoleHardReset(void)) );
emuMenu->addAction(resetAct);
- Hotkeys[ HK_RESET ].setAction( resetAct );
- connect( Hotkeys[ HK_RESET ].getShortcut(), SIGNAL(activated()), this, SLOT(consoleHardReset(void)) );
+ Hotkeys[ HK_HARD_RESET ].setAction( resetAct );
+ connect( Hotkeys[ HK_HARD_RESET ].getShortcut(), SIGNAL(activated()), this, SLOT(consoleHardReset(void)) );
// Emulation -> Soft Reset
sresetAct = new QAction(tr("&Soft Reset"), this);
@@ -1302,6 +1302,9 @@ void consoleWin_t::createMainMenu(void)
emuMenu->addAction(sresetAct);
+ Hotkeys[ HK_SOFT_RESET ].setAction( sresetAct );
+ connect( Hotkeys[ HK_SOFT_RESET ].getShortcut(), SIGNAL(activated()), this, SLOT(consoleSoftReset(void)) );
+
// Emulation -> Pause
pauseAct = new QAction(tr("&Pause"), this);
//pauseAct->setShortcut( QKeySequence(tr("Pause")));
diff --git a/src/drivers/Qt/config.cpp b/src/drivers/Qt/config.cpp
index 25442b96..fff49ff4 100644
--- a/src/drivers/Qt/config.cpp
+++ b/src/drivers/Qt/config.cpp
@@ -187,8 +187,11 @@ int getHotKeyConfig( int i, const char **nameOut, const char **keySeqOut, const
case HK_POWER:
name = "Power"; keySeq = ""; title = "Power"; group = "Emulation";
break;
- case HK_RESET:
- name = "Reset"; keySeq = "Ctrl+R"; title = "Reset"; group = "Emulation";
+ case HK_SOFT_RESET:
+ name = "SoftReset"; keySeq = "Ctrl+R"; title = "Soft Reset"; group = "Emulation";
+ break;
+ case HK_HARD_RESET:
+ name = "HardReset"; keySeq = "Ctrl+Shift+R"; title = "Hard Reset"; group = "Emulation";
break;
case HK_PAUSE:
name = "Pause"; keySeq = "Pause"; title = "Pause"; group = "Emulation";
diff --git a/src/drivers/Qt/config.h b/src/drivers/Qt/config.h
index d719f12d..5b2beb92 100644
--- a/src/drivers/Qt/config.h
+++ b/src/drivers/Qt/config.h
@@ -14,7 +14,7 @@ enum HOTKEY {
HK_OPEN_ROM=0, HK_CLOSE_ROM,
// Emulation power, reset, pause, quit
- HK_POWER, HK_RESET, HK_PAUSE, HK_QUIT,
+ HK_POWER, HK_SOFT_RESET, HK_HARD_RESET, HK_PAUSE, HK_QUIT,
// Emulation Execution Control
HK_FRAME_ADVANCE, HK_DECREASE_SPEED, HK_INCREASE_SPEED, HK_TURBO,
diff --git a/src/drivers/common/vidblit.cpp b/src/drivers/common/vidblit.cpp
index 9b6f1c22..b2fbda24 100644
--- a/src/drivers/common/vidblit.cpp
+++ b/src/drivers/common/vidblit.cpp
@@ -238,18 +238,18 @@ void KillBlitToHigh(void)
{
if(palettetranslate)
{
- free(palettetranslate);
+ FCEU_free(palettetranslate);
palettetranslate=NULL;
}
if(specbuf8bpp)
{
- free(specbuf8bpp);
+ FCEU_free(specbuf8bpp);
specbuf8bpp = NULL;
}
if(specbuf32bpp)
{
- free(specbuf32bpp);
+ FCEU_free(specbuf32bpp);
specbuf32bpp = NULL;
}
if(specbuf)
@@ -259,11 +259,11 @@ void KillBlitToHigh(void)
hq3x_Kill();
else
hq2x_Kill();
- free(specbuf);
+ FCEU_free(specbuf);
specbuf=NULL;
}
if (nes_ntsc) {
- free(nes_ntsc);
+ FCEU_free(nes_ntsc);
nes_ntsc = NULL;
}
if (ntscblit) {
diff --git a/src/ines.cpp b/src/ines.cpp
index f0f714ff..bf67c8d9 100644
--- a/src/ines.cpp
+++ b/src/ines.cpp
@@ -108,11 +108,11 @@ void iNESGI(GI h) { //bbit edited: removed static keyword
if (iNESCart.Close)
iNESCart.Close();
if (ROM) {
- free(ROM);
+ FCEU_free(ROM);
ROM = NULL;
}
if (VROM) {
- free(VROM);
+ FCEU_free(VROM);
VROM = NULL;
}
if (trainerpoo) {
@@ -816,17 +816,11 @@ int iNESLoad(const char *name, FCEUFILE *fp, int OverwriteVidMode) {
}
}
- if ((ROM = (uint8*)FCEU_malloc(ROM_size << 14)) == NULL)
- return 0;
+ ROM = (uint8*)FCEU_malloc(ROM_size << 14);
memset(ROM, 0xFF, ROM_size << 14);
if (VROM_size) {
- if ((VROM = (uint8*)FCEU_malloc(VROM_size << 13)) == NULL) {
- free(ROM);
- ROM = NULL;
- FCEU_PrintError("Unable to allocate memory.");
- return LOADER_HANDLED_ERROR;
- }
+ VROM = (uint8*)FCEU_malloc(VROM_size << 13);
memset(VROM, 0xFF, VROM_size << 13);
}
diff --git a/src/ppu.cpp b/src/ppu.cpp
index 01a03a79..89bd1af9 100644
--- a/src/ppu.cpp
+++ b/src/ppu.cpp
@@ -57,6 +57,7 @@
#define PPU_status (PPU[2])
+#define READPALNOGS(ofs) (PALRAM[(ofs)])
#define READPAL(ofs) (PALRAM[(ofs)] & (GRAYSCALE ? 0x30 : 0xFF))
#define READUPAL(ofs) (UPALRAM[(ofs)] & (GRAYSCALE ? 0x30 : 0xFF))
@@ -1987,6 +1988,7 @@ void runppu(int x) {
struct BGData {
struct Record {
uint8 nt, pecnt, at, pt[2], qtnt;
+ uint8 ppu1[8];
INLINE void Read() {
NTRefreshAddr = RefreshAddr = ppur.get_ntread();
@@ -1998,7 +2000,12 @@ struct BGData {
}
pecnt = (RefreshAddr & 1) << 3;
nt = CALL_PPUREAD(RefreshAddr);
- runppu(kFetchTime);
+ ppu1[0] = PPU[1];
+ runppu(1);
+ ppu1[1] = PPU[1];
+ runppu(1);
+
+
RefreshAddr = ppur.get_atread();
at = CALL_PPUREAD(RefreshAddr);
@@ -2010,37 +2017,57 @@ struct BGData {
at <<= 2;
//horizontal scroll clocked at cycle 3 and then
//vertical scroll at 251
+ ppu1[2] = PPU[1];
runppu(1);
if (PPUON) {
ppur.increment_hsc();
if (ppur.status.cycle == 251)
ppur.increment_vs();
}
+ ppu1[3] = PPU[1];
runppu(1);
ppur.par = nt;
RefreshAddr = ppur.get_ptread();
if (PEC586Hack) {
pt[0] = CALL_PPUREAD(RefreshAddr | pecnt);
- runppu(kFetchTime);
+ ppu1[4] = PPU[1];
+ runppu(1);
+ ppu1[5] = PPU[1];
+ runppu(1);
pt[1] = CALL_PPUREAD(RefreshAddr | pecnt);
- runppu(kFetchTime);
+ ppu1[6] = PPU[1];
+ runppu(1);
+ ppu1[7] = PPU[1];
+ runppu(1);
} else if (QTAIHack && (qtnt & 0x40)) {
pt[0] = *(CHRptr[0] + RefreshAddr);
- runppu(kFetchTime);
+ ppu1[4] = PPU[1];
+ runppu(1);
+ ppu1[5] = PPU[1];
+ runppu(1);
RefreshAddr |= 8;
pt[1] = *(CHRptr[0] + RefreshAddr);
- runppu(kFetchTime);
+ ppu1[6] = PPU[1];
+ runppu(1);
+ ppu1[7] = PPU[1];
+ runppu(1);
} else {
if (ScreenON)
RENDER_LOG(RefreshAddr);
pt[0] = CALL_PPUREAD(RefreshAddr);
- runppu(kFetchTime);
+ ppu1[4] = PPU[1];
+ runppu(1);
+ ppu1[5] = PPU[1];
+ runppu(1);
RefreshAddr |= 8;
if (ScreenON)
RENDER_LOG(RefreshAddr);
pt[1] = CALL_PPUREAD(RefreshAddr);
- runppu(kFetchTime);
+ ppu1[6] = PPU[1];
+ runppu(1);
+ ppu1[7] = PPU[1];
+ runppu(1);
}
}
};
@@ -2216,7 +2243,7 @@ int FCEUX_PPU_Loop(int skip) {
pixel = ((pt[0] >> (7 - bgpx)) & 1) | (((pt[1] >> (7 - bgpx)) & 1) << 1) | bgdata.main[bgtile].at;
}
if (renderbg)
- pixelcolor = READPAL(pixel);
+ pixelcolor = READPALNOGS(pixel);
//look for a sprite to be drawn
bool havepixel = false;
@@ -2261,12 +2288,25 @@ int FCEUX_PPU_Loop(int skip) {
spixel |= (oam[2] & 3) << 2;
if (rendersprites)
- pixelcolor = READPAL(0x10 + spixel);
+ pixelcolor = READPALNOGS(0x10 + spixel);
}
}
- *ptr++ = PaletteAdjustPixel(pixelcolor);
- *dptr++= PPU[1]>>5; //grab deemph
+ //apply grayscale.. kind of clunky
+ //really we need to read the entire palette instead of just ppu1
+ //this will be needed for special color effects probably (very fine rainbows and whatnot?)
+ //are you allowed to chang the palette mid-line anyway? well you can definitely change the grayscale flag as we know from the FF1 "polygon" effect
+ if(bgdata.main[xt+2].ppu1[xp]&1)
+ pixelcolor &= 0x30;
+
+ //this does deemph stuff inside it.. which is probably wrong...
+ *ptr = PaletteAdjustPixel(pixelcolor);
+
+ ptr++;
+
+ //grab deemph..
+ //I guess this works the same way as the grayscale, ideally?
+ *dptr++ = bgdata.main[xt+2].ppu1[xp]>>5;
}
}
}
diff --git a/src/state.cpp b/src/state.cpp
index d46e44e8..3a8fac80 100644
--- a/src/state.cpp
+++ b/src/state.cpp
@@ -307,13 +307,24 @@ static bool ReadStateChunks(EMUFILE* is, int32 totalsize)
// load back buffer
{
extern uint8 *XBackBuf;
- if(is->fread((char*)XBackBuf,size) != size)
- ret = false;
+ //ignore 8 garbage bytes, whose idea was it to write these or even have them there in the first place
+ if(size == 256*256+8)
+ {
+ if(is->fread((char*)XBackBuf,256*256) != 256*256)
+ ret = false;
+ is->fseek(8,SEEK_CUR);
+ }
+ else
+ {
+ if(is->fread((char*)XBackBuf,size) != size)
+ ret = false;
+ }
+
//MBG TODO - can this be moved to a better place?
//does it even make sense, displaying XBuf when its XBackBuf we just loaded?
#ifdef __WIN_DRIVER__
- else
+ if(ret)
{
FCEUD_BlitScreen(XBuf);
UpdateFCEUWindow();
@@ -404,7 +415,7 @@ bool FCEUSS_SaveMS(EMUFILE* outstream, int compressionLevel)
// save back buffer
{
extern uint8 *XBackBuf;
- uint32 size = 256 * 256 + 8;
+ uint32 size = 256 * 256;
os->fputc(8);
write32le(size, os);
os->fwrite((char*)XBackBuf,size);
@@ -848,7 +859,7 @@ void ResetExState(void (*PreSave)(void), void (*PostSave)(void))
for(x=0;x<SFEXINDEX;x++)
{
if(SFMDATA[x].desc)
- free( (void*)SFMDATA[x].desc);
+ FCEU_free( (void*)SFMDATA[x].desc);
}
// adelikat, 3/14/09: had to add this to clear out the size parameter. NROM(mapper 0) games were having savestate crashes if loaded after a non NROM game because the size variable was carrying over and causing savestates to save too much data
SFMDATA[0].s = 0;
diff --git a/src/utils/memory.cpp b/src/utils/memory.cpp
index 80e072e1..5ed626ea 100644
--- a/src/utils/memory.cpp
+++ b/src/utils/memory.cpp
@@ -28,53 +28,70 @@
#include "../fceu.h"
#include "memory.h"
+static void *_FCEU_malloc(uint32 size)
+{
+ #ifdef _MSC_VER
+ void *ret = _aligned_malloc(size,32);
+ #else
+ void *ret = aligned_alloc(32,size);
+ #endif
+
+ if(!ret)
+ {
+ FCEU_PrintError("Error allocating memory! Doing a hard exit.");
+ exit(1);
+ }
+
+ memset(ret, 0, size);
+
+ return ret;
+}
+
+static void _FCEU_free(void* ptr)
+{
+ #ifdef _MSC_VER
+ _aligned_free(ptr);
+ #else
+ free(ptr);
+ #endif
+}
+
///allocates the specified number of bytes. exits process if this fails
void *FCEU_gmalloc(uint32 size)
{
-
- void *ret;
- ret=malloc(size);
- if(!ret)
- {
- FCEU_PrintError("Error allocating memory! Doing a hard exit.");
- exit(1);
- }
- FCEU_MemoryRand((uint8*)ret,size,true); // initialize according to RAMInitOption, default zero
+ void *ret = _FCEU_malloc(size);
+
+ // initialize according to RAMInitOption, default zero
+ FCEU_MemoryRand((uint8*)ret,size,true);
+
return ret;
}
-///allocates the specified number of bytes. returns null if this fails
void *FCEU_malloc(uint32 size)
{
- void *ret;
- ret=malloc(size);
- if(!ret)
- {
- FCEU_PrintError("Error allocating memory!");
- return(0);
- }
- memset(ret,0,size); // initialize to 0
- return ret;
+ void *ret = _FCEU_malloc(size);
+ memset(ret, 0, size);
+ return ret;
}
///frees memory allocated with FCEU_gmalloc
void FCEU_gfree(void *ptr)
{
- free(ptr);
+ _FCEU_free(ptr);
}
///frees memory allocated with FCEU_malloc
-void FCEU_free(void *ptr) // Might do something with this and FCEU_malloc later...
+void FCEU_free(void *ptr)
{
- free(ptr);
+ _FCEU_free(ptr);
}
void *FCEU_dmalloc(uint32 size)
{
- return malloc(size);
+ return FCEU_malloc(size);
}
void FCEU_dfree(void *ptr)
{
- free(ptr);
+ return FCEU_free(ptr);
}
diff --git a/src/utils/memory.h b/src/utils/memory.h
index 559c7bad..174b3d31 100644
--- a/src/utils/memory.h
+++ b/src/utils/memory.h
@@ -24,13 +24,21 @@
#define FCEU_dwmemset(d,c,n) {int _x; for(_x=n-4;_x>=0;_x-=4) *(uint32 *)&(d)[_x]=c;}
-void *FCEU_malloc(uint32 size); // initialized to 0
-void *FCEU_gmalloc(uint32 size); // used by boards for WRAM etc, initialized to 0 (default) or other via RAMInitOption
+//returns a 32-aligned buffer, initialized to 0
+void *FCEU_malloc(uint32 size);
+
+//returns a 32-aligned buffer, with jumbled initial contents
+//used by boards for WRAM etc, initialized to 0 (default) or other via RAMInitOption
+void *FCEU_gmalloc(uint32 size);
+
+//free memory allocated with FCEU_gmalloc
void FCEU_gfree(void *ptr);
+
+//free memory allocated with
void FCEU_free(void *ptr);
-void FCEU_memmove(void *d, void *s, uint32 l);
-// wrapper for debugging when its needed, otherwise act like
-// normal malloc/free
+//don't use these. change them if you find them.
void *FCEU_dmalloc(uint32 size);
+
+//don't use these. change them if you find them.
void FCEU_dfree(void *ptr);
diff --git a/src/video.cpp b/src/video.cpp
index 531c5f3c..cbad58fc 100644
--- a/src/video.cpp
+++ b/src/video.cpp
@@ -116,27 +116,17 @@ void FCEU_KillVirtualVideo(void)
int FCEU_InitVirtualVideo(void)
{
//Some driver code may allocate XBuf externally.
- //256 bytes per scanline, * 240 scanline maximum, +16 for alignment,
+ //256 bytes per scanline, * 240 scanline maximum
if(XBuf)
return 1;
- XBuf = (u8*)FCEU_malloc(256 * 256 + 16);
- XBackBuf = (u8*)FCEU_malloc(256 * 256 + 16);
- XDBuf = (u8*)FCEU_malloc(256 * 256 + 16);
- XDBackBuf = (u8*)FCEU_malloc(256 * 256 + 16);
- if(!XBuf || !XBackBuf || !XDBuf || !XDBackBuf)
- {
- return 0;
- }
+ XBuf = (u8*)FCEU_malloc(256 * 256);
+ XBackBuf = (u8*)FCEU_malloc(256 * 256);
+ XDBuf = (u8*)FCEU_malloc(256 * 256);
+ XDBackBuf = (u8*)FCEU_malloc(256 * 256);
- xbsave = XBuf;
- if( sizeof(uint8*) == 4 )
- {
- uintptr_t m = (uintptr_t)XBuf;
- m = ( 8 - m) & 7;
- XBuf+=m;
- }
+ xbsave = XBuf;
memset(XBuf,128,256*256);
memset(XBackBuf,128,256*256);
diff --git a/src/video.h b/src/video.h
index 64e0688b..7fbb6bad 100644
--- a/src/video.h
+++ b/src/video.h
@@ -7,10 +7,20 @@ int SaveSnapshot(char[]);
void ResetScreenshotsCounter();
uint32 GetScreenPixel(int x, int y, bool usebackup);
int GetScreenPixelPalette(int x, int y, bool usebackup);
+
+//in case we need more flags in the future we can change the size here
+//bit0 : monochrome bit
+//bit5 : emph red
+//bit6 : emph green
+//bit7 : emph blue
+typedef uint8 xfbuf_t;
+
extern uint8 *XBuf;
extern uint8 *XBackBuf;
extern uint8 *XDBuf;
extern uint8 *XDBackBuf;
+extern xfbuf_t *XFBuf;
+
extern int ClipSidesOffset;
struct GUIMESSAGE