better frame advancing. debugger window no longer opens itsself.
This commit is contained in:
parent
7720f71ffa
commit
84274fe6d6
|
@ -276,8 +276,12 @@ void FCEUI_FDSSelect(void);
|
||||||
|
|
||||||
int FCEUI_DatachSet(const uint8 *rcode);
|
int FCEUI_DatachSet(const uint8 *rcode);
|
||||||
|
|
||||||
///returns flags indicating whether emulation is paused (bit0) and whether it is single-stepping (bit1)
|
///returns a flag indicating whether emulation is paused
|
||||||
int FCEUI_EmulationPaused(void);
|
int FCEUI_EmulationPaused(void);
|
||||||
|
///returns a flag indicating whether a one frame step has been requested
|
||||||
|
int FCEUI_EmulationFrameStepped();
|
||||||
|
///clears the framestepped flag. use it after youve stepped your one frame
|
||||||
|
void FCEUI_ClearEmulationFrameStepped();
|
||||||
///sets the EmulationPaused flags
|
///sets the EmulationPaused flags
|
||||||
void FCEUI_SetEmulationPaused(int val);
|
void FCEUI_SetEmulationPaused(int val);
|
||||||
///toggles the paused bit (bit0) for EmulationPaused. caused FCEUD_DebugUpdate() to fire if the emulation pauses
|
///toggles the paused bit (bit0) for EmulationPaused. caused FCEUD_DebugUpdate() to fire if the emulation pauses
|
||||||
|
|
|
@ -476,20 +476,19 @@ void UpdateRegs(HWND hwndDlg) {
|
||||||
///indicates whether we're under the control of the debugger
|
///indicates whether we're under the control of the debugger
|
||||||
bool inDebugger = false;
|
bool inDebugger = false;
|
||||||
|
|
||||||
void FCEUD_Update(uint8 *XBuf, int32 *Buffer, int Count); //HACK
|
//this code enters the debugger.
|
||||||
void FCEUD_DebugBreakpoint() {
|
void FCEUD_DebugBreakpoint() {
|
||||||
inDebugger = true;
|
UpdateDebugger();
|
||||||
DoDebug(1);
|
void win_debuggerLoop(); //HACK
|
||||||
UpdateLogWindow();
|
win_debuggerLoop();
|
||||||
if(hMemView)UpdateMemoryView(0);
|
|
||||||
//mbg merge 6/30/06 - this architecture has changed
|
|
||||||
FCEUD_Update(0,0,0);
|
|
||||||
//FCEUD_BlitScreen(XBuf+8); //this looks odd, I know. but the pause routine is in here!!
|
|
||||||
//if(logging)LogInstruction(); //logging might have been started while we were paused
|
|
||||||
inDebugger = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateDebugger() {
|
void UpdateDebugger()
|
||||||
|
{
|
||||||
|
//dont do anything if the debugger is not visible
|
||||||
|
if(!hDebug)
|
||||||
|
return;
|
||||||
|
|
||||||
char str[256]={0},chr[8];
|
char str[256]={0},chr[8];
|
||||||
int tmp,ret,i;
|
int tmp,ret,i;
|
||||||
|
|
||||||
|
|
|
@ -129,8 +129,8 @@ int NoWaiting=0;
|
||||||
bool turbo = false;
|
bool turbo = false;
|
||||||
|
|
||||||
#include "keyscan.h"
|
#include "keyscan.h"
|
||||||
static unsigned char *keys=0;
|
static unsigned int *keys=0;
|
||||||
static unsigned char *keys_nr=0;
|
static unsigned int *keys_nr=0;
|
||||||
static int DIPS=0;
|
static int DIPS=0;
|
||||||
|
|
||||||
//#define KEY(__a) keys_nr[MKK(__a)]
|
//#define KEY(__a) keys_nr[MKK(__a)]
|
||||||
|
@ -1404,7 +1404,8 @@ int FCEUD_TestCommandState(int c)
|
||||||
// else
|
// else
|
||||||
// keys_nr=GetKeyboard_nr();
|
// keys_nr=GetKeyboard_nr();
|
||||||
}
|
}
|
||||||
else if(c != EMUCMD_SPEED_TURBO) // TODO: this should be made more general by detecting if the command has an "off" function, but right now Turbo is the only command that has it
|
else
|
||||||
|
if(c != EMUCMD_SPEED_TURBO) // TODO: this should be made more general by detecting if the command has an "off" function, but right now Turbo is the only command that has it
|
||||||
{
|
{
|
||||||
keys=GetKeyboard_jd();
|
keys=GetKeyboard_jd();
|
||||||
keys_nr=GetKeyboard_nr();
|
keys_nr=GetKeyboard_nr();
|
||||||
|
|
|
@ -34,14 +34,16 @@ void KeyboardClose(void)
|
||||||
lpdid=0;
|
lpdid=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned char keys[256] = {0,}; // with repeat
|
static unsigned int keys[256] = {0,}; // with repeat
|
||||||
static unsigned char keys_nr[256] = {0,}; // non-repeating
|
static unsigned int keys_nr[256] = {0,}; // non-repeating
|
||||||
static unsigned char keys_jd[256] = {0,}; // just-down
|
static unsigned int keys_jd[256] = {0,}; // just-down
|
||||||
static unsigned char keys_jd_lock[256] = {0,}; // just-down released lock
|
static unsigned int keys_jd_lock[256] = {0,}; // just-down released lock
|
||||||
int autoHoldKey = 0, autoHoldClearKey = 0;
|
int autoHoldKey = 0, autoHoldClearKey = 0;
|
||||||
|
int ctr=0;
|
||||||
void KeyboardUpdateState(void)
|
void KeyboardUpdateState(void)
|
||||||
{
|
{
|
||||||
unsigned char tk[256];
|
unsigned char tk[256];
|
||||||
|
printf("%d!!\n",ctr++);
|
||||||
|
|
||||||
ddrval=IDirectInputDevice7_GetDeviceState(lpdid,256,tk);
|
ddrval=IDirectInputDevice7_GetDeviceState(lpdid,256,tk);
|
||||||
|
|
||||||
|
@ -49,6 +51,8 @@ void KeyboardUpdateState(void)
|
||||||
if(GetAsyncKeyState(VK_PAUSE)) // normally this should have & 0x8000, but apparently this key is too special for that to work
|
if(GetAsyncKeyState(VK_PAUSE)) // normally this should have & 0x8000, but apparently this key is too special for that to work
|
||||||
tk[0xC5] = 0x80;
|
tk[0xC5] = 0x80;
|
||||||
|
|
||||||
|
DWORD time = timeGetTime();
|
||||||
|
|
||||||
switch(ddrval)
|
switch(ddrval)
|
||||||
{
|
{
|
||||||
case DI_OK: //memcpy(keys,tk,256);break;
|
case DI_OK: //memcpy(keys,tk,256);break;
|
||||||
|
@ -64,16 +68,16 @@ void KeyboardUpdateState(void)
|
||||||
#define KEY_JUST_DOWN_DURATION (4) // must be >= 1 and <= 255
|
#define KEY_JUST_DOWN_DURATION (4) // must be >= 1 and <= 255
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i = 0 ; i < 256 ; i++)
|
for(i = 0 ; i < 256 ; i++)
|
||||||
if(tk[i])
|
if(tk[i]) {
|
||||||
if(keys_nr[i] < 255)
|
if(keys_nr[i] == 0)
|
||||||
keys_nr[i]++; // activate key, and count up for repeat
|
keys_nr[i] = time;
|
||||||
else
|
}
|
||||||
keys_nr[i] = 255 - KEY_REPEAT_REPEATING_DELAY; // oscillate for repeat
|
|
||||||
else
|
else
|
||||||
keys_nr[i] = 0; // deactivate key
|
keys_nr[i] = 0;
|
||||||
|
|
||||||
memcpy(keys,keys_nr,256);
|
memcpy(keys,keys_nr,256*4);
|
||||||
|
|
||||||
// key-down detection
|
// key-down detection
|
||||||
for(i = 0 ; i < 256 ; i++)
|
for(i = 0 ; i < 256 ; i++)
|
||||||
|
@ -87,18 +91,18 @@ void KeyboardUpdateState(void)
|
||||||
else if(keys_jd[i]
|
else if(keys_jd[i]
|
||||||
/*&& (i != 0x2A && i != 0x36 && i != 0x1D && i != 0x38)*/)
|
/*&& (i != 0x2A && i != 0x36 && i != 0x1D && i != 0x38)*/)
|
||||||
{
|
{
|
||||||
if(++keys_jd[i] > KEY_JUST_DOWN_DURATION)
|
if(time - keys_jd[i] > KEY_JUST_DOWN_DURATION)
|
||||||
{
|
{
|
||||||
keys_jd[i] = 0;
|
keys_jd[i] = 0;
|
||||||
keys_jd_lock[i] = 1;
|
keys_jd_lock[i] = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
keys_jd[i] = 1;
|
keys_jd[i] = time;
|
||||||
|
|
||||||
// key repeat
|
// key repeat
|
||||||
for(i = 0 ; i < 256 ; i++)
|
for(i = 0 ; i < 256 ; i++)
|
||||||
if(keys[i] >= KEY_REPEAT_INITIAL_DELAY && !(keys[i]%KEY_REPEAT_REPEATING_DELAY))
|
if(time - keys[i] >= KEY_REPEAT_INITIAL_DELAY && !((time-keys[i])%KEY_REPEAT_REPEATING_DELAY))
|
||||||
keys[i] = 0;
|
keys[i] = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -106,7 +110,7 @@ void KeyboardUpdateState(void)
|
||||||
|
|
||||||
case DIERR_INPUTLOST:
|
case DIERR_INPUTLOST:
|
||||||
case DIERR_NOTACQUIRED:
|
case DIERR_NOTACQUIRED:
|
||||||
memset(keys,0,256);
|
memset(keys,0,256*4);
|
||||||
IDirectInputDevice7_Acquire(lpdid);
|
IDirectInputDevice7_Acquire(lpdid);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -116,15 +120,15 @@ void KeyboardUpdateState(void)
|
||||||
autoHoldReset = autoHoldClearKey && keys[autoHoldClearKey] != 0;
|
autoHoldReset = autoHoldClearKey && keys[autoHoldClearKey] != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char *GetKeyboard(void)
|
unsigned int *GetKeyboard(void)
|
||||||
{
|
{
|
||||||
return(keys);
|
return(keys);
|
||||||
}
|
}
|
||||||
unsigned char *GetKeyboard_nr(void)
|
unsigned int *GetKeyboard_nr(void)
|
||||||
{
|
{
|
||||||
return(keys_nr);
|
return(keys_nr);
|
||||||
}
|
}
|
||||||
unsigned char *GetKeyboard_jd(void)
|
unsigned int *GetKeyboard_jd(void)
|
||||||
{
|
{
|
||||||
return(keys_jd);
|
return(keys_jd);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
void KeyboardClose(void);
|
void KeyboardClose(void);
|
||||||
int KeyboardInitialize(void);
|
int KeyboardInitialize(void);
|
||||||
void KeyboardUpdate(void);
|
void KeyboardUpdate(void);
|
||||||
unsigned char *GetKeyboard(void);
|
unsigned int *GetKeyboard(void);
|
||||||
unsigned char *GetKeyboard_nr(void);
|
unsigned int *GetKeyboard_nr(void);
|
||||||
unsigned char *GetKeyboard_jd(void);
|
unsigned int *GetKeyboard_jd(void);
|
||||||
int KeyboardSetBackgroundAccess(int on);
|
int KeyboardSetBackgroundAccess(int on);
|
||||||
|
|
|
@ -710,7 +710,6 @@ doloopy:
|
||||||
void _updateWindow()
|
void _updateWindow()
|
||||||
{
|
{
|
||||||
UpdateFCEUWindow();
|
UpdateFCEUWindow();
|
||||||
FCEUD_UpdateInput();
|
|
||||||
PPUViewDoBlit();
|
PPUViewDoBlit();
|
||||||
UpdateMemoryView(0);
|
UpdateMemoryView(0);
|
||||||
UpdateCDLogger();
|
UpdateCDLogger();
|
||||||
|
@ -921,9 +920,20 @@ void _updateWindow()
|
||||||
// } // end of !(old sound code) block
|
// } // end of !(old sound code) block
|
||||||
//}
|
//}
|
||||||
|
|
||||||
/**
|
void win_debuggerLoop()
|
||||||
* Update the game and gamewindow with a new frame
|
{
|
||||||
**/
|
//delay until something causes us to unpause.
|
||||||
|
//either a hotkey or a debugger command
|
||||||
|
while(FCEUI_EmulationPaused() && !FCEUI_EmulationFrameStepped())
|
||||||
|
{
|
||||||
|
Sleep(50);
|
||||||
|
FCEUD_UpdateInput();
|
||||||
|
_updateWindow();
|
||||||
|
}
|
||||||
|
int zzz=9;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the game and gamewindow with a new frame
|
||||||
void FCEUD_Update(uint8 *XBuf, int32 *Buffer, int Count)
|
void FCEUD_Update(uint8 *XBuf, int32 *Buffer, int Count)
|
||||||
{
|
{
|
||||||
//mbg merge 7/19/06 - leaving this untouched but untested
|
//mbg merge 7/19/06 - leaving this untouched but untested
|
||||||
|
@ -960,6 +970,7 @@ void FCEUD_Update(uint8 *XBuf, int32 *Buffer, int Count)
|
||||||
//update debugging displays
|
//update debugging displays
|
||||||
_updateWindow();
|
_updateWindow();
|
||||||
|
|
||||||
|
//MBG TODO - think about this logic
|
||||||
//throttle
|
//throttle
|
||||||
extern bool turbo; //needs to be declared better
|
extern bool turbo; //needs to be declared better
|
||||||
if(!(eoptions&EO_NOTHROTTLE)) //if throttling is enabled..
|
if(!(eoptions&EO_NOTHROTTLE)) //if throttling is enabled..
|
||||||
|
@ -968,23 +979,33 @@ void FCEUD_Update(uint8 *XBuf, int32 *Buffer, int Count)
|
||||||
//then throttle
|
//then throttle
|
||||||
win_Throttle();
|
win_Throttle();
|
||||||
|
|
||||||
//delay until we unpause. we will only stick here if we're paused by a breakpoint or debug command
|
//sleep just to be polite
|
||||||
while(FCEUI_EmulationPaused() && inDebugger)
|
if(FCEUI_EmulationPaused()) {
|
||||||
{
|
|
||||||
Sleep(50);
|
Sleep(50);
|
||||||
BlockingCheck();
|
|
||||||
FCEUD_UpdateInput(); //should this update the CONTROLS??? or only the hotkeys etc?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//something of a hack, but straightforward:
|
//while(EmulationPaused==1 && inDebugger)
|
||||||
//if we were paused, but not in the debugger, then unpause ourselves and step.
|
//{
|
||||||
//this is so that the cpu won't cut off execution due to being paused, but the debugger _will_
|
// Sleep(50);
|
||||||
//cut off execution as soon as it makes it into the main cpu cycle loop
|
// BlockingCheck();
|
||||||
if(FCEUI_EmulationPaused() && !inDebugger) {
|
// FCEUD_UpdateInput(); //should this update the CONTROLS??? or only the hotkeys etc?
|
||||||
FCEUI_ToggleEmulationPause();
|
//}
|
||||||
FCEUI_Debugger().step = 1;
|
|
||||||
}
|
////so, we're not paused anymore.
|
||||||
|
|
||||||
|
////something of a hack, but straightforward:
|
||||||
|
////if we were paused, but not in the debugger, then unpause ourselves and step.
|
||||||
|
////this is so that the cpu won't cut off execution due to being paused, but the debugger _will_
|
||||||
|
////cut off execution as soon as it makes it into the main cpu cycle loop
|
||||||
|
//if(FCEUI_EmulationPaused() && !inDebugger) {
|
||||||
|
// FCEUI_ToggleEmulationPause();
|
||||||
|
// FCEUI_Debugger().step = 1;
|
||||||
|
// FCEUD_DebugBreakpoint();
|
||||||
|
//}
|
||||||
|
|
||||||
|
//make sure to update the input once per frame
|
||||||
|
FCEUD_UpdateInput();
|
||||||
|
|
||||||
|
|
||||||
// if(soundo) //&& temp_fps_scale >= 64
|
// if(soundo) //&& temp_fps_scale >= 64
|
||||||
// {
|
// {
|
||||||
|
|
|
@ -85,7 +85,7 @@ static struct
|
||||||
#define NUM_DEFAULT_MAPPINGS (sizeof(DefaultCommandMapping)/sizeof(DefaultCommandMapping[0]))
|
#define NUM_DEFAULT_MAPPINGS (sizeof(DefaultCommandMapping)/sizeof(DefaultCommandMapping[0]))
|
||||||
|
|
||||||
static uint8 keyonce[MKK_COUNT];
|
static uint8 keyonce[MKK_COUNT];
|
||||||
static unsigned char *keys_nr = 0;
|
static unsigned int *keys_nr = 0;
|
||||||
|
|
||||||
static const char* ScanNames[256]=
|
static const char* ScanNames[256]=
|
||||||
{
|
{
|
||||||
|
|
15
src/fceu.cpp
15
src/fceu.cpp
|
@ -263,6 +263,7 @@ static void CloseGame(void)
|
||||||
void ResetGameLoaded(void)
|
void ResetGameLoaded(void)
|
||||||
{
|
{
|
||||||
if(GameInfo) CloseGame();
|
if(GameInfo) CloseGame();
|
||||||
|
EmulationPaused = 0; //mbg 5/8/08 - loading games while paused was bad news. maybe this fixes it
|
||||||
GameStateRestore=0;
|
GameStateRestore=0;
|
||||||
PPU_hook=0;
|
PPU_hook=0;
|
||||||
GameHBIRQHook=0;
|
GameHBIRQHook=0;
|
||||||
|
@ -510,6 +511,8 @@ void FCEUI_Emulate(uint8 **pXBuf, int32 **SoundBuf, int32 *SoundBufSize, int ski
|
||||||
*SoundBuf=WaveFinal;
|
*SoundBuf=WaveFinal;
|
||||||
*SoundBufSize=ssize;
|
*SoundBufSize=ssize;
|
||||||
|
|
||||||
|
//if we were asked to frame advance, then since we have just finished
|
||||||
|
//a frame, we should switch to regular pause
|
||||||
if(EmulationPaused&2)
|
if(EmulationPaused&2)
|
||||||
{
|
{
|
||||||
EmulationPaused = 1; // restore paused flag
|
EmulationPaused = 1; // restore paused flag
|
||||||
|
@ -735,7 +738,17 @@ int32 FCEUI_GetDesiredFPS(void)
|
||||||
|
|
||||||
int FCEUI_EmulationPaused(void)
|
int FCEUI_EmulationPaused(void)
|
||||||
{
|
{
|
||||||
return (EmulationPaused&1);
|
return (EmulationPaused&1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int FCEUI_EmulationFrameStepped()
|
||||||
|
{
|
||||||
|
return (EmulationPaused&2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FCEUI_ClearEmulationFrameStepped()
|
||||||
|
{
|
||||||
|
EmulationPaused &=~2;
|
||||||
}
|
}
|
||||||
|
|
||||||
//mbg merge 7/18/06 added
|
//mbg merge 7/18/06 added
|
||||||
|
|
Loading…
Reference in New Issue