* Debugger: fixed Cycles counter reset when loading an earlier savestate

* Taseditor: small cleanup because of a failed experiment with different "Follow cursor" behavior
This commit is contained in:
ansstuff 2013-09-05 14:53:07 +00:00
parent 405c20d871
commit 4f0c7474df
8 changed files with 87 additions and 39 deletions

View File

@ -894,7 +894,7 @@ void UpdateDebugger(bool jump_to_pc)
SetDlgItemText(hDebug, IDC_DEBUGGER_VAL_PPUPIXEL, str2); SetDlgItemText(hDebug, IDC_DEBUGGER_VAL_PPUPIXEL, str2);
// update counters // update counters
uint64 counter_value = timestampbase + (uint64)timestamp - total_cycles_base; int64 counter_value = timestampbase + (uint64)timestamp - total_cycles_base;
if (counter_value < 0) // sanity check if (counter_value < 0) // sanity check
{ {
ResetDebugStatisticsCounters(); ResetDebugStatisticsCounters();
@ -902,7 +902,7 @@ void UpdateDebugger(bool jump_to_pc)
} }
sprintf(str, "%llu", counter_value); sprintf(str, "%llu", counter_value);
SetDlgItemText(hDebug, IDC_DEBUGGER_VAL_CYCLES_COUNT, str); SetDlgItemText(hDebug, IDC_DEBUGGER_VAL_CYCLES_COUNT, str);
counter_value = timestampbase + (long)timestamp - delta_cycles_base; counter_value = timestampbase + (uint64)timestamp - delta_cycles_base;
if (counter_value < 0) // sanity check if (counter_value < 0) // sanity check
{ {
ResetDebugStatisticsCounters(); ResetDebugStatisticsCounters();

View File

@ -74,7 +74,7 @@ using namespace std;
#define HIGHLIGHT_ACTIVITY_NUM_COLORS 16 #define HIGHLIGHT_ACTIVITY_NUM_COLORS 16
#define PREVIOUS_VALUE_UNDEFINED -1 #define PREVIOUS_VALUE_UNDEFINED -1
COLORREF highlightActivityColors[HIGHLIGHT_ACTIVITY_NUM_COLORS] = { 0x0, 0x005252, 0x227322, 0x768046, 0x99641f, 0xbf0003, 0xe00056, 0xd90090, 0xcc00b4, 0x8500ba, 0x7100d4, 0x1c00d1, 0x003ce0, 0x0069d9, 0x008ae5, 0x4ea2de }; COLORREF highlightActivityColors[HIGHLIGHT_ACTIVITY_NUM_COLORS] = { 0x0, 0x004f4f, 0x1d611d, 0x757241, 0x994d00, 0xc70003, 0xe50058, 0xd90094, 0xcc00b4, 0x9400bd, 0x7e00d9, 0x0000cf, 0x0034e0, 0x0064d6, 0x0086e5, 0x4ea2de };
string memviewhelp = "HexEditor"; //Hex Editor Help Page string memviewhelp = "HexEditor"; //Hex Editor Help Page

View File

@ -55,7 +55,7 @@ LRESULT APIENTRY markerDragBoxWndProc(HWND hwnd, UINT message, WPARAM wParam, LP
char pianoRollSaveID[PIANO_ROLL_ID_LEN] = "PIANO_ROLL"; char pianoRollSaveID[PIANO_ROLL_ID_LEN] = "PIANO_ROLL";
char pianoRollSkipSaveID[PIANO_ROLL_ID_LEN] = "PIANO_ROLX"; char pianoRollSkipSaveID[PIANO_ROLL_ID_LEN] = "PIANO_ROLX";
//COLORREF hotChangesColors[16] = { 0x0, 0x495249, 0x666361, 0x855a45, 0xa13620, 0xbd003f, 0xd6006f, 0xcc008b, 0xba00a1, 0x8b00ad, 0x5c00bf, 0x0003d1, 0x0059d6, 0x0077d9, 0x0096db, 0x00aede }; //COLORREF hotChangesColors[16] = { 0x0, 0x495249, 0x666361, 0x855a45, 0xa13620, 0xbd003f, 0xd6006f, 0xcc008b, 0xba00a1, 0x8b00ad, 0x5c00bf, 0x0003d1, 0x0059d6, 0x0077d9, 0x0096db, 0x00aede };
COLORREF hotChangesColors[16] = { 0x0, 0x005252, 0x227322, 0x768046, 0x99641f, 0xbf0003, 0xe00056, 0xd90090, 0xcc00b4, 0x8500ba, 0x7100d4, 0x1c00d1, 0x003ce0, 0x0069d9, 0x008ae5, 0x4ea2de }; COLORREF hotChangesColors[16] = { 0x0, 0x004f4f, 0x1d611d, 0x757241, 0x994d00, 0xc70003, 0xe50058, 0xd90094, 0xcc00b4, 0x9400bd, 0x7e00d9, 0x0000cf, 0x0034e0, 0x0064d6, 0x0086e5, 0x4ea2de };
COLORREF headerLightsColors[11] = { 0x0, 0x007313, 0x009100, 0x1daf00, 0x42c700, 0x65d900, 0x91e500, 0xb0f000, 0xdaf700, 0xf0fc7c, 0xfcffba }; COLORREF headerLightsColors[11] = { 0x0, 0x007313, 0x009100, 0x1daf00, 0x42c700, 0x65d900, 0x91e500, 0xb0f000, 0xdaf700, 0xf0fc7c, 0xfcffba };
char markerDragBoxClassName[] = "MarkerDragBox"; char markerDragBoxClassName[] = "MarkerDragBox";
@ -417,6 +417,7 @@ void PIANO_ROLL::free()
void PIANO_ROLL::reset() void PIANO_ROLL::reset()
{ {
mustRedrawList = mustCheckItemUnderMouse = true; mustRedrawList = mustCheckItemUnderMouse = true;
playbackCursorOffset = 0;
shiftHeld = ctrlHeld = altHeld = false; shiftHeld = ctrlHeld = altHeld = false;
shiftTimer = ctrlTimer = shiftActionsÑount = ctrlActionsÑount = 0; shiftTimer = ctrlTimer = shiftActionsÑount = ctrlActionsÑount = 0;
nextHeaderUpdateTime = headerItemUnderMouse = 0; nextHeaderUpdateTime = headerItemUnderMouse = 0;
@ -455,32 +456,6 @@ void PIANO_ROLL::update()
{ {
updateLinesCount(); updateLinesCount();
if (mustCheckItemUnderMouse)
{
// find row and column
POINT p;
if (GetCursorPos(&p))
{
ScreenToClient(hwndList, &p);
// perform hit test
LVHITTESTINFO info;
info.pt.x = p.x;
info.pt.y = p.y;
ListView_SubItemHitTest(hwndList, &info);
rowUnderMouse = info.iItem;
realRowUnderMouse = rowUnderMouse;
if (realRowUnderMouse < 0)
{
realRowUnderMouse = ListView_GetTopIndex(hwndList) + (p.y - listTopMargin) / listRowHeight;
if (realRowUnderMouse < 0) realRowUnderMouse--;
}
columnUnderMouse = info.iSubItem;
}
// and don't check until mouse moves or Piano Roll scrolls
mustCheckItemUnderMouse = false;
taseditorWindow.mustUpdateMouseCursor = true;
}
// update state of Shift/Ctrl/Alt holding // update state of Shift/Ctrl/Alt holding
bool last_shift_held = shiftHeld, last_ctrl_held = ctrlHeld, last_alt_held = altHeld; bool last_shift_held = shiftHeld, last_ctrl_held = ctrlHeld, last_alt_held = altHeld;
shiftHeld = (GetAsyncKeyState(VK_SHIFT) < 0); shiftHeld = (GetAsyncKeyState(VK_SHIFT) < 0);
@ -522,6 +497,32 @@ void PIANO_ROLL::update()
ctrlTimer = clock(); ctrlTimer = clock();
} }
if (mustCheckItemUnderMouse)
{
// find row and column
POINT p;
if (GetCursorPos(&p))
{
ScreenToClient(hwndList, &p);
// perform hit test
LVHITTESTINFO info;
info.pt.x = p.x;
info.pt.y = p.y;
ListView_SubItemHitTest(hwndList, &info);
rowUnderMouse = info.iItem;
realRowUnderMouse = rowUnderMouse;
if (realRowUnderMouse < 0)
{
realRowUnderMouse = ListView_GetTopIndex(hwndList) + (p.y - listTopMargin) / listRowHeight;
if (realRowUnderMouse < 0) realRowUnderMouse--;
}
columnUnderMouse = info.iSubItem;
}
// and don't check until mouse moves or Piano Roll scrolls
mustCheckItemUnderMouse = false;
taseditorWindow.mustUpdateMouseCursor = true;
}
// update dragging // update dragging
if (dragMode != DRAG_MODE_NONE) if (dragMode != DRAG_MODE_NONE)
{ {
@ -912,7 +913,6 @@ void PIANO_ROLL::updateLinesCount()
bool PIANO_ROLL::isLineVisible(int frame) bool PIANO_ROLL::isLineVisible(int frame)
{ {
int top = ListView_GetTopIndex(hwndList); int top = ListView_GetTopIndex(hwndList);
// in fourscore there's horizontal scrollbar which takes one row for itself
if (frame >= top && frame < top + ListView_GetCountPerPage(hwndList)) if (frame >= top && frame < top + ListView_GetCountPerPage(hwndList))
return true; return true;
return false; return false;
@ -920,18 +920,40 @@ bool PIANO_ROLL::isLineVisible(int frame)
void PIANO_ROLL::centerListAroundLine(int rowIndex) void PIANO_ROLL::centerListAroundLine(int rowIndex)
{ {
int list_items = ListView_GetCountPerPage(hwndList); int numItemsPerPage = ListView_GetCountPerPage(hwndList);
int lower_border = (list_items - 1) / 2; int lowerBorder = (numItemsPerPage - 1) / 2;
int upper_border = (list_items - 1) - lower_border; int upperBorder = (numItemsPerPage - 1) - lowerBorder;
int index = rowIndex + lower_border; int index = rowIndex + lowerBorder;
if (index >= currMovieData.getNumRecords()) if (index >= currMovieData.getNumRecords())
index = currMovieData.getNumRecords()-1; index = currMovieData.getNumRecords()-1;
ListView_EnsureVisible(hwndList, index, false); ListView_EnsureVisible(hwndList, index, false);
index = rowIndex - upper_border; index = rowIndex - upperBorder;
if (index < 0) if (index < 0)
index = 0; index = 0;
ListView_EnsureVisible(hwndList, index, false); ListView_EnsureVisible(hwndList, index, false);
} }
void PIANO_ROLL::setListTopRow(int rowIndex)
{
ListView_Scroll(hwndList, 0, listRowHeight * (rowIndex - ListView_GetTopIndex(hwndList)));
}
void PIANO_ROLL::recalculatePlaybackCursorOffset()
{
int frame = playback.getPauseFrame();
if (frame < 0)
frame = currFrameCounter;
playbackCursorOffset = frame - ListView_GetTopIndex(hwndList);
if (playbackCursorOffset < 0)
{
playbackCursorOffset = 0;
} else
{
int numItemsPerPage = ListView_GetCountPerPage(hwndList);
if (playbackCursorOffset > numItemsPerPage - 1)
playbackCursorOffset = numItemsPerPage - 1;
}
}
void PIANO_ROLL::followPlaybackCursor() void PIANO_ROLL::followPlaybackCursor()
{ {
@ -947,6 +969,14 @@ void PIANO_ROLL::followPlaybackCursorIfNeeded(bool followPauseframe)
ListView_EnsureVisible(hwndList, playback.getPauseFrame(), FALSE); ListView_EnsureVisible(hwndList, playback.getPauseFrame(), FALSE);
} }
} }
void PIANO_ROLL::updatePlaybackCursorPositionInPianoRoll()
{
if (taseditorConfig.followPlaybackCursor)
{
if (playback.getPauseFrame() < 0)
setListTopRow(currFrameCounter - playbackCursorOffset);
}
}
void PIANO_ROLL::followPauseframe() void PIANO_ROLL::followPauseframe()
{ {
if (playback.getPauseFrame() >= 0) if (playback.getPauseFrame() >= 0)

View File

@ -166,8 +166,11 @@ public:
void updateLinesCount(); void updateLinesCount();
bool isLineVisible(int frame); bool isLineVisible(int frame);
void recalculatePlaybackCursorOffset();
void followPlaybackCursor(); void followPlaybackCursor();
void followPlaybackCursorIfNeeded(bool followPauseframe = true); void followPlaybackCursorIfNeeded(bool followPauseframe = true);
void updatePlaybackCursorPositionInPianoRoll();
void followPauseframe(); void followPauseframe();
void followUndoHint(); void followUndoHint();
void followSelection(); void followSelection();
@ -223,6 +226,7 @@ public:
private: private:
void centerListAroundLine(int rowIndex); void centerListAroundLine(int rowIndex);
void setListTopRow(int rowIndex);
void handlePlaybackCursorDragging(); void handlePlaybackCursorDragging();
void finishDrag(); void finishDrag();
@ -232,6 +236,7 @@ private:
int nextHeaderUpdateTime; int nextHeaderUpdateTime;
bool mustRedrawList; bool mustRedrawList;
int playbackCursorOffset;
HMENU hrMenu; HMENU hrMenu;

View File

@ -152,7 +152,7 @@ void PLAYBACK::update()
bookmarks.redrawChangedBookmarks(currFrameCounter); bookmarks.redrawChangedBookmarks(currFrameCounter);
lastCursorPos = currFrameCounter; lastCursorPos = currFrameCounter;
// follow the Playback cursor, but in case of seeking don't follow it // follow the Playback cursor, but in case of seeking don't follow it
pianoRoll.followPlaybackCursorIfNeeded(false); pianoRoll.followPlaybackCursorIfNeeded(false); //pianoRoll.updatePlaybackCursorPositionInPianoRoll(); // an unfinished experiment
// enforce redrawing now // enforce redrawing now
UpdateWindow(pianoRoll.hwndList); UpdateWindow(pianoRoll.hwndList);
// lazy update of "Playback's Marker text" // lazy update of "Playback's Marker text"

View File

@ -841,6 +841,7 @@ BOOL CALLBACK TASEditorWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara
break; break;
case LVN_ENDSCROLL: case LVN_ENDSCROLL:
pianoRoll.mustCheckItemUnderMouse = true; pianoRoll.mustCheckItemUnderMouse = true;
//pianoRoll.recalculatePlaybackCursorOffset(); // an unfinished experiment
break; break;
} }
break; break;

View File

@ -500,7 +500,13 @@ void FCEUD_TraceInstruction(uint8 *opcode, int size)
} }
if (logging_options & LOG_CYCLES_COUNT) if (logging_options & LOG_CYCLES_COUNT)
{ {
sprintf(str_temp, "c%-11llu ", (timestampbase + (uint64)timestamp - total_cycles_base)); int64 counter_value = timestampbase + (uint64)timestamp - total_cycles_base;
if (counter_value < 0) // sanity check
{
ResetDebugStatisticsCounters();
counter_value = 0;
}
sprintf(str_temp, "c%-11llu ", counter_value);
strcat(str_result, str_temp); strcat(str_result, str_temp);
} }
if (logging_options & LOG_INSTRUCTIONS_COUNT) if (logging_options & LOG_INSTRUCTIONS_COUNT)

View File

@ -4364,7 +4364,13 @@ static int debugger_hitbreakpoint(lua_State *L)
// debugger.getcyclescount() // debugger.getcyclescount()
static int debugger_getcyclescount(lua_State *L) static int debugger_getcyclescount(lua_State *L)
{ {
lua_pushinteger(L, (timestampbase + (uint64)timestamp - total_cycles_base)); int64 counter_value = timestampbase + (uint64)timestamp - total_cycles_base;
if (counter_value < 0) // sanity check
{
ResetDebugStatisticsCounters();
counter_value = 0;
}
lua_pushinteger(L, counter_value);
return 1; return 1;
} }