can draw to window after game closes
This commit is contained in:
parent
66ed3d6b58
commit
3f5f4fe7b9
|
@ -30,3 +30,13 @@ Looks like the control is not properly being handed back to the lua scrip as I t
|
|||
|
||||
Indeed there was, it works now!frameAdvanceWaiting must be set to true to indicate a thread is waiting to run after a frame is emulated.
|
||||
|
||||
11/20/2022
|
||||
I am going to fix this graphics bug today. I suspect that the buffer I am editing and the buffer that is actually being drawn are two seperate entities, which is causing it to look like my changes to the display buffer are not going through.
|
||||
|
||||
From wikipedia "Bit blit (also written BITBLT, BIT BLT, BitBLT, Bit BLT, Bit Blt etc., which stands for bit block transfer) is a data operation commonly used in computer graphics in which several bitmaps are combined into one using a boolean function.[1]"... So that's what the blit function called in FCEUD_Update is doing.
|
||||
|
||||
The call to RedrawWindow() after a game is closed in main() has the flags RDW_ERASE and RDW_INVALIDATE. The erase flag clears the window, and the invalidate flag seems to prevent the window from being edited (drawn over). The window must be in a "validated" state for the lua gui to show up. Aditionally, it appears that the screen must be cleared manually after the lua gui is drawn if no frame is emulated.
|
||||
|
||||
11/21/2022
|
||||
I added a function to clear the screen to fceu.cpp. This is not necessary while a game is running (presumeably because game frame data overwrites what was previously there), but is necessary for drawing lua gui with nothing running. With this addition, this aspect of the project (being able to run lua + draw to the gui without a ROM loaded) is functional...but only if a ROM is first opened then closed. Even though I am drawing a new window when lua is loaded, it does not seem to work if loading a script before a game is initially loaded. Again, the script IS running properly... I need to investigate loading a ROM as well as how the main window is being drawn at launch...
|
||||
|
||||
|
|
|
@ -919,6 +919,7 @@ int main(int argc,char *argv[])
|
|||
if (PauseAfterLoad) FCEUI_ToggleEmulationPause();
|
||||
SetAutoFirePattern(AFon, AFoff);
|
||||
UpdateCheckedMenuItems();
|
||||
|
||||
doloopy:
|
||||
UpdateFCEUWindow();
|
||||
if(GameInfo)
|
||||
|
@ -963,24 +964,27 @@ doloopy:
|
|||
//xbsave = NULL;
|
||||
RedrawWindow(hAppWnd,0,0,RDW_ERASE|RDW_INVALIDATE);
|
||||
}
|
||||
else
|
||||
UpdateRawInputAndHotkeys();
|
||||
else if (luaYieldFlag) {
|
||||
RedrawWindow(hAppWnd, 0, 0, RDW_ERASE | RDW_VALIDATE);
|
||||
|
||||
extern bool yieldFlag;
|
||||
if (yieldFlag) {
|
||||
yieldFlag = false;
|
||||
//extern uint8* XBuf;
|
||||
//memset(XBuf, -1, 256 * 256);
|
||||
FCEU_LuaFrameBoundary();
|
||||
while (luaYieldFlag && !exiting) {
|
||||
UpdateFCEUWindow();
|
||||
luaYieldFlag = false;
|
||||
UpdateRawInputAndHotkeys();
|
||||
|
||||
u8 dog[256*257];
|
||||
memset(dog, -1, 256 * 256);//128
|
||||
FCEU_LuaGui(dog);
|
||||
FCEUD_BlitScreen(dog);
|
||||
uint8* gfx = 0;
|
||||
FCEUI_AdvanceNoFrame(&gfx);
|
||||
FCEUD_BlitScreen(gfx);
|
||||
|
||||
Sleep(50);
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
UpdateRawInputAndHotkeys();
|
||||
}
|
||||
|
||||
Sleep(50);
|
||||
if(!exiting)
|
||||
if (!exiting)
|
||||
goto doloopy;
|
||||
|
||||
DriverKill();
|
||||
|
|
15
src/fceu.cpp
15
src/fceu.cpp
|
@ -236,6 +236,13 @@ static void FCEU_CloseGame(void)
|
|||
}
|
||||
}
|
||||
|
||||
void FCEU_ClearScreen(void) {
|
||||
//clear screen when game is closed
|
||||
extern uint8* XBuf;
|
||||
if (XBuf)
|
||||
memset(XBuf, 0, 256 * 256);
|
||||
}
|
||||
|
||||
|
||||
uint64 timestampbase;
|
||||
|
||||
|
@ -254,6 +261,7 @@ static int RWWrap = 0;
|
|||
//mbg merge 7/18/06 docs
|
||||
//bit0 indicates whether emulation is paused
|
||||
//bit1 indicates whether emulation is in frame step mode
|
||||
bool luaYieldFlag = false;
|
||||
int EmulationPaused = 0;
|
||||
bool frameAdvanceRequested=false;
|
||||
int frameAdvance_Delay_count = 0;
|
||||
|
@ -871,6 +879,13 @@ void FCEUI_Emulate(uint8 **pXBuf, int32 **SoundBuf, int32 *SoundBufSize, int ski
|
|||
ProcessSubtitles();
|
||||
}
|
||||
|
||||
void FCEUI_AdvanceNoFrame(uint8** pXBuf) {
|
||||
FCEU_ClearScreen();
|
||||
FCEU_LuaFrameBoundary();
|
||||
FCEU_DrawLuaGui();
|
||||
*pXBuf = XBuf;
|
||||
}
|
||||
|
||||
void FCEUI_CloseGame(void) {
|
||||
if (!FCEU_IsValidUI(FCEUI_CLOSEGAME))
|
||||
return;
|
||||
|
|
|
@ -72,6 +72,8 @@ extern uint8 qtaintramreg;
|
|||
|
||||
extern uint8 *RAM; //shared memory modifications
|
||||
extern int EmulationPaused;
|
||||
//Lua-engine (emugators)
|
||||
extern bool luaYieldFlag;
|
||||
extern int frameAdvance_Delay;
|
||||
extern int RAMInitOption;
|
||||
|
||||
|
@ -148,6 +150,10 @@ void FCEU_TogglePPU();
|
|||
void SetNESDeemph_OldHacky(uint8 d, int force);
|
||||
void DrawTextTrans(uint8 *dest, uint32 width, uint8 *textmsg, uint8 fgcolor);
|
||||
void FCEU_PutImage(void);
|
||||
|
||||
void FCEUI_AdvanceNoFrame(uint8** pXBuf); // - emugator
|
||||
void FCEU_ClearScreen(void); // -emugator
|
||||
|
||||
#ifdef FRAMESKIP
|
||||
void FCEU_PutImageDummy(void);
|
||||
#endif
|
||||
|
|
|
@ -5442,12 +5442,10 @@ static int cdl_resetcdlog(lua_State *L)
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool yieldFlag = false;
|
||||
|
||||
static int emugator_yieldwithflag(lua_State* L)
|
||||
{
|
||||
frameAdvanceWaiting = TRUE;
|
||||
yieldFlag = true;
|
||||
luaYieldFlag = true;
|
||||
|
||||
return lua_yield(L, 0);
|
||||
|
||||
|
@ -6400,6 +6398,7 @@ void FCEU_LuaFrameBoundary()
|
|||
*
|
||||
* Returns true on success, false on failure.
|
||||
*/
|
||||
|
||||
int FCEU_LoadLuaCode(const char *filename, const char *arg)
|
||||
{
|
||||
if (!DemandLua())
|
||||
|
|
|
@ -383,6 +383,11 @@ void FCEU_PutImage(void)
|
|||
} else DrawMessage(false);
|
||||
|
||||
}
|
||||
|
||||
void FCEU_DrawLuaGui(void) {
|
||||
FCEU_LuaGui(XBuf);
|
||||
}
|
||||
|
||||
void snapAVI()
|
||||
{
|
||||
//Update AVI
|
||||
|
|
|
@ -7,6 +7,8 @@ int SaveSnapshot(char[]);
|
|||
void ResetScreenshotsCounter();
|
||||
uint32 GetScreenPixel(int x, int y, bool usebackup);
|
||||
int GetScreenPixelPalette(int x, int y, bool usebackup);
|
||||
void FCEU_DrawLuaGui(void);
|
||||
|
||||
|
||||
//in case we need more flags in the future we can change the size here
|
||||
//bit0 : monochrome bit
|
||||
|
|
Loading…
Reference in New Issue