diff --git a/src/drivers/win/taseditor.cpp b/src/drivers/win/taseditor.cpp index 192db6d6..073468ae 100644 --- a/src/drivers/win/taseditor.cpp +++ b/src/drivers/win/taseditor.cpp @@ -68,13 +68,13 @@ extern void TaseditorManualFunction(); bool EnterTasEditor() { - if(!FCEU_IsValidUI(FCEUI_TASEDITOR)) return false; - if(!taseditor_window.hwndTasEditor) + if (!FCEU_IsValidUI(FCEUI_TASEDITOR)) return false; + if (!taseditor_window.hwndTasEditor) { // start TAS Editor // create window taseditor_window.init(); - if(taseditor_window.hwndTasEditor) + if (taseditor_window.hwndTasEditor) { // save "eoptions" saved_eoptions = eoptions; @@ -180,7 +180,7 @@ bool ExitTasEditor() // everyframe function void UpdateTasEditor() { - if(!taseditor_window.hwndTasEditor) + if (!taseditor_window.hwndTasEditor) { // TAS Editor is not engaged... but we still should run Lua auto function TaseditorAutoFunction(); @@ -311,15 +311,15 @@ void NewProject() if (DialogBoxParam(fceu_hInstance, MAKEINTRESOURCE(IDD_TASEDITOR_NEWPROJECT), taseditor_window.hwndTasEditor, NewProjectProc, (LPARAM)¶ms) > 0) { FCEUMOV_CreateCleanMovie(); - // apply selected options SetInputType(currMovieData, params.input_type); + ApplyMovieInputConfig(); if (params.copy_current_input) // copy input from current snapshot (from history) history.GetCurrentSnapshot().toMovie(currMovieData); if (!params.copy_current_markers) markers_manager.reset(); - if(params.author_name != L"") currMovieData.comments.push_back(L"author " + params.author_name); + if (params.author_name != L"") currMovieData.comments.push_back(L"author " + params.author_name); // reset Taseditor project.init(); // new project has blank name @@ -362,7 +362,7 @@ void OpenProject() string initdir = FCEU_GetPath(FCEUMKF_MOVIE); ofn.lpstrInitialDir = initdir.c_str(); - if(GetOpenFileName(&ofn)) // If it is a valid filename + if (GetOpenFileName(&ofn)) // If it is a valid filename { LoadProject(nameo); } @@ -420,7 +420,7 @@ bool SaveProjectAs() string initdir = FCEU_GetPath(FCEUMKF_MOVIE); // initial directory ofn.lpstrInitialDir = initdir.c_str(); - if(GetSaveFileName(&ofn)) // if it is a valid filename + if (GetSaveFileName(&ofn)) // if it is a valid filename { project.RenameProject(nameo, true); project.save(); @@ -549,7 +549,7 @@ void SaveCompact() string initdir = FCEU_GetPath(FCEUMKF_MOVIE); // initial directory ofn.lpstrInitialDir = initdir.c_str(); - if(GetSaveFileName(&ofn)) // if it is a valid filename + if (GetSaveFileName(&ofn)) // if it is a valid filename project.save(nameo, taseditor_config.savecompact_binary, taseditor_config.savecompact_markers, taseditor_config.savecompact_bookmarks, taseditor_config.savecompact_greenzone, taseditor_config.savecompact_history, taseditor_config.savecompact_piano_roll, taseditor_config.savecompact_selection); } } @@ -564,7 +564,7 @@ bool AskSaveProject() if (changes_found) { int answer = MessageBox(taseditor_window.hwndTasEditor, "Save Project changes?", "TAS Editor", MB_YESNOCANCEL); - if(answer == IDYES) + if (answer == IDYES) return SaveProject(); return (answer != IDCANCEL); } @@ -589,7 +589,7 @@ void Import() string initdir = FCEU_GetPath(FCEUMKF_MOVIE); ofn.lpstrInitialDir = initdir.c_str(); - if(GetOpenFileName(&ofn)) + if (GetOpenFileName(&ofn)) { EMUFILE_FILE ifs(nameo, "rb"); // Load input to temporary moviedata @@ -682,7 +682,7 @@ void Export() ofn.Flags = OFN_EXPLORER|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT; std::string initdir = FCEU_GetPath(FCEUMKF_MOVIE); ofn.lpstrInitialDir = initdir.c_str(); - if(GetSaveFileName(&ofn)) + if (GetSaveFileName(&ofn)) { EMUFILE* osRecordingMovie = FCEUD_UTF8_fstream(fname, "wb"); // create copy of current movie data diff --git a/src/drivers/win/taseditor/bookmarks.cpp b/src/drivers/win/taseditor/bookmarks.cpp index 113acef1..090f96f1 100644 --- a/src/drivers/win/taseditor/bookmarks.cpp +++ b/src/drivers/win/taseditor/bookmarks.cpp @@ -594,7 +594,7 @@ int BOOKMARKS::GetSelectedSlot() void BOOKMARKS::GetDispInfo(NMLVDISPINFO* nmlvDispInfo) { LVITEM& item = nmlvDispInfo->item; - if(item.mask & LVIF_TEXT) + if (item.mask & LVIF_TEXT) { switch(item.iSubItem) { diff --git a/src/drivers/win/taseditor/editor.cpp b/src/drivers/win/taseditor/editor.cpp index 7a964347..4781e3ff 100644 --- a/src/drivers/win/taseditor/editor.cpp +++ b/src/drivers/win/taseditor/editor.cpp @@ -47,7 +47,7 @@ void EDITOR::init() strncpy(nameo, FCEU_GetPath(FCEUMKF_TASEDITOR).c_str(), 2047); strncat(nameo, patternsFilename, 2047 - strlen(nameo)); EMUFILE_FILE ifs(nameo, "rb"); - if(!ifs.fail()) + if (!ifs.fail()) { std::string tempstr1, tempstr2; while (ReadString(&ifs, tempstr1)) @@ -282,7 +282,7 @@ bool EDITOR::FrameColumnSet() bool unset_found = false, changes_made = false; for(SelectionFrames::iterator it(current_selection_begin); it != current_selection_end; it++) { - if(!markers_manager.GetMarker(*it)) + if (!markers_manager.GetMarker(*it)) { unset_found = true; break; @@ -293,7 +293,7 @@ bool EDITOR::FrameColumnSet() // set all for(SelectionFrames::iterator it(current_selection_begin); it != current_selection_end; it++) { - if(!markers_manager.GetMarker(*it)) + if (!markers_manager.GetMarker(*it)) { if (markers_manager.SetMarker(*it)) { @@ -309,7 +309,7 @@ bool EDITOR::FrameColumnSet() // unset all for(SelectionFrames::iterator it(current_selection_begin); it != current_selection_end; it++) { - if(markers_manager.GetMarker(*it)) + if (markers_manager.GetMarker(*it)) { markers_manager.ClearMarker(*it); changes_made = true; @@ -339,7 +339,7 @@ bool EDITOR::FrameColumnSetPattern() continue; if (autofire_patterns[current_pattern][pattern_offset]) { - if(!markers_manager.GetMarker(*it)) + if (!markers_manager.GetMarker(*it)) { if (markers_manager.SetMarker(*it)) { @@ -349,7 +349,7 @@ bool EDITOR::FrameColumnSetPattern() } } else { - if(markers_manager.GetMarker(*it)) + if (markers_manager.GetMarker(*it)) { markers_manager.ClearMarker(*it); changes_made = true; @@ -382,7 +382,7 @@ bool EDITOR::InputColumnSet(int joy, int button) bool newValue = false; for(SelectionFrames::iterator it(current_selection_begin); it != current_selection_end; it++) { - if(!(currMovieData.records[*it].checkBit(joy,button))) + if (!(currMovieData.records[*it].checkBit(joy,button))) { newValue = true; break; @@ -445,7 +445,7 @@ void EDITOR::SetMarkers() bool changes_made = false; for(SelectionFrames::iterator it(current_selection_begin); it != current_selection_end; it++) { - if(!markers_manager.GetMarker(*it)) + if (!markers_manager.GetMarker(*it)) { if (markers_manager.SetMarker(*it)) { @@ -471,7 +471,7 @@ void EDITOR::RemoveMarkers() bool changes_made = false; for(SelectionFrames::iterator it(current_selection_begin); it != current_selection_end; it++) { - if(markers_manager.GetMarker(*it)) + if (markers_manager.GetMarker(*it)) { markers_manager.ClearMarker(*it); changes_made = true; diff --git a/src/drivers/win/taseditor/greenzone.cpp b/src/drivers/win/taseditor/greenzone.cpp index f61f178d..7d738a8f 100644 --- a/src/drivers/win/taseditor/greenzone.cpp +++ b/src/drivers/win/taseditor/greenzone.cpp @@ -58,7 +58,6 @@ void GREENZONE::free() void GREENZONE::reset() { free(); - lag_history.resize(currMovieData.getNumRecords()); } void GREENZONE::update() { @@ -80,7 +79,7 @@ void GREENZONE::CollectCurrentState() if ((int)savestates.size() < greenZoneCount) savestates.resize(greenZoneCount); if ((int)lag_history.size() < greenZoneCount) - lag_history.resize(greenZoneCount); + lag_history.resize(greenZoneCount, 0); // if frame changed - log savestate storeTasSavestate(currFrameCounter); @@ -89,22 +88,30 @@ void GREENZONE::CollectCurrentState() { // lagFlag indicates that lag was in previous frame int old_lagFlag = lag_history[currFrameCounter - 1]; - if (lagFlag) - lag_history[currFrameCounter - 1] = 1; - else - lag_history[currFrameCounter - 1] = 0; + int saved_currFrameCounter = currFrameCounter; // Auto-adjust Input due to lag if (taseditor_config.adjust_input_due_to_lag) { if (old_lagFlag && !lagFlag) { // there's no more lag on previous frame - shift input up + lag_history.erase(lag_history.begin() + (currFrameCounter - 1)); editor.AdjustUp(currFrameCounter - 1); + // make sure the Playback cursor always rewinds too + if (currFrameCounter == saved_currFrameCounter) + InvalidateAndCheck(currFrameCounter - 1); } else if (!old_lagFlag && lagFlag) { // there's new lag on previous frame - shift input down + lag_history.insert(lag_history.begin() + (currFrameCounter - 1), 1); editor.AdjustDown(currFrameCounter - 1); } + } else + { + if (lagFlag) + lag_history[currFrameCounter - 1] = 1; + else + lag_history[currFrameCounter - 1] = 0; } } } @@ -207,7 +214,7 @@ void GREENZONE::ClearSavestate(int index) std::vector tmp; savestates[index].swap(tmp); } -// this function is used by Bookmark Unleash procedure +// this function is used by Bookmark Deploy procedure void GREENZONE::WriteSavestate(int frame, std::vector& savestate) { if ((int)savestates.size() <= frame) @@ -233,6 +240,8 @@ void GREENZONE::save(EMUFILE *os, bool really_save) write32le(greenZoneCount, os); // compress and write lag history int len = lag_history.size(); + if (len > currMovieData.getNumRecords()) + len = currMovieData.getNumRecords(); uLongf comprlen = (len>>9)+12 + len; std::vector cbuf(comprlen); compress(&cbuf[0], &comprlen, &lag_history[0], len); @@ -333,9 +342,9 @@ bool GREENZONE::load(EMUFILE *is, bool really_load) greenZoneCount = size; savestates.resize(greenZoneCount); // read and uncompress lag history - lag_history.resize(greenZoneCount); + uLongf destlen = currMovieData.getNumRecords(); + lag_history.resize(destlen, 0); int comprlen; - uLongf destlen = greenZoneCount; if (!read32le(&comprlen, is)) goto error; if (comprlen <= 0) goto error; std::vector cbuf(comprlen); @@ -489,7 +498,7 @@ int GREENZONE::GetSize() } bool GREENZONE::GetLagHistoryAtFrame(int frame) { - if (frame < greenZoneCount && frame < (int)lag_history.size()) + if (frame < (int)lag_history.size()) return lag_history[frame] != 0; else return false; diff --git a/src/drivers/win/taseditor/history.cpp b/src/drivers/win/taseditor/history.cpp index 178336fe..248a5639 100644 --- a/src/drivers/win/taseditor/history.cpp +++ b/src/drivers/win/taseditor/history.cpp @@ -1056,7 +1056,7 @@ error: void HISTORY::GetDispInfo(NMLVDISPINFO* nmlvDispInfo) { LVITEM& item = nmlvDispInfo->item; - if(item.mask & LVIF_TEXT) + if (item.mask & LVIF_TEXT) strcpy(item.pszText, GetItemDesc(item.iItem)); } @@ -1089,7 +1089,7 @@ void HISTORY::UpdateHistoryList() { //update the number of items in the history list int currLVItemCount = ListView_GetItemCount(hwndHistoryList); - if(currLVItemCount != history_total_items) + if (currLVItemCount != history_total_items) ListView_SetItemCountEx(hwndHistoryList, history_total_items, LVSICF_NOSCROLL | LVSICF_NOINVALIDATEALL); } diff --git a/src/drivers/win/taseditor/markers_manager.cpp b/src/drivers/win/taseditor/markers_manager.cpp index 6dd25917..02db85ce 100644 --- a/src/drivers/win/taseditor/markers_manager.cpp +++ b/src/drivers/win/taseditor/markers_manager.cpp @@ -241,7 +241,7 @@ bool MARKERS_MANAGER::EraseMarker(int frame) } bool MARKERS_MANAGER::insertEmpty(int at, int frames) { - if(at == -1) + if (at == -1) { // append blank frames markers.markers_array.resize(markers.markers_array.size() + frames); @@ -692,7 +692,7 @@ BOOL CALLBACK FindNoteProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lPa { case IDC_NOTE_TO_FIND: { - if(HIWORD(wParam) == EN_CHANGE) + if (HIWORD(wParam) == EN_CHANGE) { if (GetWindowTextLength(GetDlgItem(hwndDlg, IDC_NOTE_TO_FIND))) EnableWindow(GetDlgItem(hwndDlg, IDOK), true); diff --git a/src/drivers/win/taseditor/piano_roll.cpp b/src/drivers/win/taseditor/piano_roll.cpp index 3fe62214..176e3203 100644 --- a/src/drivers/win/taseditor/piano_roll.cpp +++ b/src/drivers/win/taseditor/piano_roll.cpp @@ -76,7 +76,7 @@ PIANO_ROLL::PIANO_ROLL() wincl.cbClsExtra = 0; wincl.cbWndExtra = 0; wincl.hbrBackground = 0; - if(!RegisterClassEx(&wincl)) + if (!RegisterClassEx(&wincl)) FCEU_printf("Error registering MARKER_DRAG_BOX window class\n"); // create blendfunction @@ -878,7 +878,7 @@ void PIANO_ROLL::UpdateItemCount() // update the number of items in the list int currLVItemCount = ListView_GetItemCount(hwndList); int movie_size = currMovieData.getNumRecords(); - if(currLVItemCount != movie_size) + if (currLVItemCount != movie_size) ListView_SetItemCountEx(hwndList, movie_size, LVSICF_NOSCROLL|LVSICF_NOINVALIDATEALL); } bool PIANO_ROLL::CheckItemVisible(int frame) @@ -1178,7 +1178,7 @@ void PIANO_ROLL::FinishDrag() void PIANO_ROLL::GetDispInfo(NMLVDISPINFO* nmlvDispInfo) { LVITEM& item = nmlvDispInfo->item; - if(item.mask & LVIF_TEXT) + if (item.mask & LVIF_TEXT) { switch(item.iSubItem) { @@ -1226,7 +1226,7 @@ void PIANO_ROLL::GetDispInfo(NMLVDISPINFO* nmlvDispInfo) int joy = (item.iSubItem - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS; int bit = (item.iSubItem - COLUMN_JOYPAD1_A) % NUM_JOYPAD_BUTTONS; uint8 data = ((int)currMovieData.records.size() > item.iItem) ? currMovieData.records[item.iItem].joysticks[joy] : 0; - if(data & (1<iSubItem; cell_y = msg->nmcd.dwItemSpec; - - if(cell_x > COLUMN_ICONS) + if (cell_x > COLUMN_ICONS) { // text color - if(taseditor_config.enable_hot_changes && cell_x >= COLUMN_JOYPAD1_A && cell_x <= COLUMN_JOYPAD4_R) + if (taseditor_config.enable_hot_changes && cell_x >= COLUMN_JOYPAD1_A && cell_x <= COLUMN_JOYPAD4_R) msg->clrText = hot_changes_colors[history.GetCurrentSnapshot().GetHotChangeInfo(cell_y, cell_x - COLUMN_JOYPAD1_A)]; else msg->clrText = NORMAL_TEXT_COLOR; // bg color and text font - if(cell_x == COLUMN_FRAMENUM || cell_x == COLUMN_FRAMENUM2) + if (cell_x == COLUMN_FRAMENUM || cell_x == COLUMN_FRAMENUM2) { // font - if(markers_manager.GetMarker(cell_y)) + if (markers_manager.GetMarker(cell_y)) SelectObject(msg->nmcd.hdc, hMainListSelectFont); else SelectObject(msg->nmcd.hdc, hMainListFont); @@ -1286,7 +1285,7 @@ LONG PIANO_ROLL::CustomDraw(NMLVCUSTOMDRAW* msg) } } else if (cell_y == currFrameCounter || cell_y == (playback.GetFlashingPauseFrame() - 1)) { - // current frame + // this is current frame if (markers_manager.GetMarker(cell_y) && (drag_mode != DRAG_MODE_MARKER || marker_drag_framenum != cell_y)) { msg->clrTextBk = (taseditor_config.bind_markers) ? CUR_BINDMARKED_FRAMENUM_COLOR : CUR_MARKED_FRAMENUM_COLOR; @@ -1296,31 +1295,44 @@ LONG PIANO_ROLL::CustomDraw(NMLVCUSTOMDRAW* msg) } } else if (markers_manager.GetMarker(cell_y) && (drag_mode != DRAG_MODE_MARKER || marker_drag_framenum != cell_y)) { - // marked frame + // this is marked frame msg->clrTextBk = (taseditor_config.bind_markers) ? BINDMARKED_FRAMENUM_COLOR : MARKED_FRAMENUM_COLOR; + } else if (cell_y < greenzone.GetSize()) + { + if (!greenzone.SavestateIsEmpty(cell_y)) + { + // the frame is normal Greenzone frame + if (greenzone.GetLagHistoryAtFrame(cell_y)) + msg->clrTextBk = LAG_FRAMENUM_COLOR; + else + msg->clrTextBk = GREENZONE_FRAMENUM_COLOR; + } else if ((!greenzone.SavestateIsEmpty(cell_y & EVERY16TH) && !greenzone.SavestateIsEmpty((cell_y & EVERY16TH) + 16)) + || (!greenzone.SavestateIsEmpty(cell_y & EVERY8TH) && !greenzone.SavestateIsEmpty((cell_y & EVERY8TH) + 8)) + || (!greenzone.SavestateIsEmpty(cell_y & EVERY4TH) && !greenzone.SavestateIsEmpty((cell_y & EVERY4TH) + 4)) + || (!greenzone.SavestateIsEmpty(cell_y & EVERY2ND) && !greenzone.SavestateIsEmpty((cell_y & EVERY2ND) + 2))) + { + // the frame is in a gap (in Greenzone tail) + if (greenzone.GetLagHistoryAtFrame(cell_y)) + msg->clrTextBk = PALE_LAG_FRAMENUM_COLOR; + else + msg->clrTextBk = PALE_GREENZONE_FRAMENUM_COLOR; + } else + { + // the frame is above Greenzone tail + if (greenzone.GetLagHistoryAtFrame(cell_y)) + msg->clrTextBk = VERY_PALE_LAG_FRAMENUM_COLOR; + else + msg->clrTextBk = VERY_PALE_GREENZONE_FRAMENUM_COLOR; + } } else { - if(cell_y < greenzone.GetSize()) - { - if (!greenzone.SavestateIsEmpty(cell_y)) - { - if (greenzone.GetLagHistoryAtFrame(cell_y)) - msg->clrTextBk = LAG_FRAMENUM_COLOR; - else - msg->clrTextBk = GREENZONE_FRAMENUM_COLOR; - } else if ((!greenzone.SavestateIsEmpty(cell_y & EVERY16TH) && !greenzone.SavestateIsEmpty((cell_y & EVERY16TH) + 16)) - || (!greenzone.SavestateIsEmpty(cell_y & EVERY8TH) && !greenzone.SavestateIsEmpty((cell_y & EVERY8TH) + 8)) - || (!greenzone.SavestateIsEmpty(cell_y & EVERY4TH) && !greenzone.SavestateIsEmpty((cell_y & EVERY4TH) + 4)) - || (!greenzone.SavestateIsEmpty(cell_y & EVERY2ND) && !greenzone.SavestateIsEmpty((cell_y & EVERY2ND) + 2))) - { - if (greenzone.GetLagHistoryAtFrame(cell_y)) - msg->clrTextBk = PALE_LAG_FRAMENUM_COLOR; - else - msg->clrTextBk = PALE_GREENZONE_FRAMENUM_COLOR; - } else msg->clrTextBk = NORMAL_FRAMENUM_COLOR; - } else msg->clrTextBk = NORMAL_FRAMENUM_COLOR; + // the frame is below Greenzone head + if (greenzone.GetLagHistoryAtFrame(cell_y)) + msg->clrTextBk = VERY_PALE_LAG_FRAMENUM_COLOR; + else + msg->clrTextBk = VERY_PALE_GREENZONE_FRAMENUM_COLOR; } - } else if((cell_x - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS == 0 || (cell_x - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS == 2) + } else if ((cell_x - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS == 0 || (cell_x - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS == 2) { // pad 1 or 3 // font: empty cells have "SelectFont", non-empty have normal font @@ -1338,12 +1350,13 @@ LONG PIANO_ROLL::CustomDraw(NMLVCUSTOMDRAW* msg) msg->clrTextBk = UNDOHINT_INPUT_COLOR1; } else if (cell_y == currFrameCounter || cell_y == (playback.GetFlashingPauseFrame() - 1)) { - // current frame + // this is current frame msg->clrTextBk = CUR_INPUT_COLOR1; - } else if(cell_y < greenzone.GetSize()) + } else if (cell_y < greenzone.GetSize()) { if (!greenzone.SavestateIsEmpty(cell_y)) { + // the frame is normal Greenzone frame if (greenzone.GetLagHistoryAtFrame(cell_y)) msg->clrTextBk = LAG_INPUT_COLOR1; else @@ -1353,13 +1366,28 @@ LONG PIANO_ROLL::CustomDraw(NMLVCUSTOMDRAW* msg) || (!greenzone.SavestateIsEmpty(cell_y & EVERY4TH) && !greenzone.SavestateIsEmpty((cell_y & EVERY4TH) + 4)) || (!greenzone.SavestateIsEmpty(cell_y & EVERY2ND) && !greenzone.SavestateIsEmpty((cell_y & EVERY2ND) + 2))) { + // the frame is in a gap (in Greenzone tail) if (greenzone.GetLagHistoryAtFrame(cell_y)) msg->clrTextBk = PALE_LAG_INPUT_COLOR1; else msg->clrTextBk = PALE_GREENZONE_INPUT_COLOR1; - } else msg->clrTextBk = NORMAL_INPUT_COLOR1; - } else msg->clrTextBk = NORMAL_INPUT_COLOR1; - } else if((cell_x - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS == 1 || (cell_x - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS == 3) + } else + { + // the frame is above Greenzone tail + if (greenzone.GetLagHistoryAtFrame(cell_y)) + msg->clrTextBk = VERY_PALE_LAG_INPUT_COLOR1; + else + msg->clrTextBk = VERY_PALE_GREENZONE_INPUT_COLOR1; + } + } else + { + // the frame is below Greenzone head + if (greenzone.GetLagHistoryAtFrame(cell_y)) + msg->clrTextBk = VERY_PALE_LAG_INPUT_COLOR1; + else + msg->clrTextBk = VERY_PALE_GREENZONE_INPUT_COLOR1; + } + } else if ((cell_x - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS == 1 || (cell_x - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS == 3) { // pad 2 or 4 // font: empty cells have "SelectFont", non-empty have normal font @@ -1377,12 +1405,13 @@ LONG PIANO_ROLL::CustomDraw(NMLVCUSTOMDRAW* msg) msg->clrTextBk = UNDOHINT_INPUT_COLOR2; } else if (cell_y == currFrameCounter || cell_y == (playback.GetFlashingPauseFrame() - 1)) { - // current frame + // this is current frame msg->clrTextBk = CUR_INPUT_COLOR2; - } else if(cell_y < greenzone.GetSize()) + } else if (cell_y < greenzone.GetSize()) { if (!greenzone.SavestateIsEmpty(cell_y)) { + // the frame is normal Greenzone frame if (greenzone.GetLagHistoryAtFrame(cell_y)) msg->clrTextBk = LAG_INPUT_COLOR2; else @@ -1392,12 +1421,27 @@ LONG PIANO_ROLL::CustomDraw(NMLVCUSTOMDRAW* msg) || (!greenzone.SavestateIsEmpty(cell_y & EVERY4TH) && !greenzone.SavestateIsEmpty((cell_y & EVERY4TH) + 4)) || (!greenzone.SavestateIsEmpty(cell_y & EVERY2ND) && !greenzone.SavestateIsEmpty((cell_y & EVERY2ND) + 2))) { + // the frame is in a gap (in Greenzone tail) if (greenzone.GetLagHistoryAtFrame(cell_y)) msg->clrTextBk = PALE_LAG_INPUT_COLOR2; else msg->clrTextBk = PALE_GREENZONE_INPUT_COLOR2; - } else msg->clrTextBk = NORMAL_INPUT_COLOR2; - } else msg->clrTextBk = NORMAL_INPUT_COLOR2; + } else + { + // the frame is above Greenzone tail + if (greenzone.GetLagHistoryAtFrame(cell_y)) + msg->clrTextBk = VERY_PALE_LAG_INPUT_COLOR2; + else + msg->clrTextBk = VERY_PALE_GREENZONE_INPUT_COLOR2; + } + } else + { + // the frame is below Greenzone head + if (greenzone.GetLagHistoryAtFrame(cell_y)) + msg->clrTextBk = VERY_PALE_LAG_INPUT_COLOR2; + else + msg->clrTextBk = VERY_PALE_GREENZONE_INPUT_COLOR2; + } } } default: @@ -1441,7 +1485,7 @@ void PIANO_ROLL::RightClick(LVHITTESTINFO& info) bool set_found = false, unset_found = false; for(SelectionFrames::iterator it(current_selection_begin); it != current_selection_end; it++) { - if(markers_manager.GetMarker(*it)) + if (markers_manager.GetMarker(*it)) set_found = true; else unset_found = true; @@ -1603,7 +1647,7 @@ LRESULT APIENTRY HeaderWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam info.pt.x = GET_X_LPARAM(lParam) + HEADER_DX_FIX; info.pt.y = GET_Y_LPARAM(lParam); SendMessage(hWnd, HDM_HITTEST, 0, (LPARAM)&info); - if(info.iItem >= COLUMN_FRAMENUM && info.iItem <= COLUMN_FRAMENUM2) + if (info.iItem >= COLUMN_FRAMENUM && info.iItem <= COLUMN_FRAMENUM2) piano_roll.ColumnSet(info.iItem, (GetKeyState(VK_MENU) < 0)); } } @@ -1670,7 +1714,7 @@ LRESULT APIENTRY ListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { // clicked on the "icons" column piano_roll.StartDraggingPlaybackCursor(); - } else if(column_index == COLUMN_FRAMENUM || column_index == COLUMN_FRAMENUM2) + } else if (column_index == COLUMN_FRAMENUM || column_index == COLUMN_FRAMENUM2) { // clicked on the "Frame#" column if (row_index >= 0) @@ -1833,7 +1877,7 @@ LRESULT APIENTRY ListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) info.pt.y = GET_Y_LPARAM(lParam); ListView_SubItemHitTest(hWnd, &info); // show context menu if user right-clicked on Frame# - if(info.iSubItem <= COLUMN_FRAMENUM || info.iSubItem >= COLUMN_FRAMENUM2) + if (info.iSubItem <= COLUMN_FRAMENUM || info.iSubItem >= COLUMN_FRAMENUM2) piano_roll.RightClick(info); return 0; } diff --git a/src/drivers/win/taseditor/piano_roll.h b/src/drivers/win/taseditor/piano_roll.h index 66920802..eccff744 100644 --- a/src/drivers/win/taseditor/piano_roll.h +++ b/src/drivers/win/taseditor/piano_roll.h @@ -112,6 +112,10 @@ enum DRAG_MODES #define PALE_GREENZONE_INPUT_COLOR1 0xD3F9D2 #define PALE_GREENZONE_INPUT_COLOR2 0xBAEBBA +#define VERY_PALE_GREENZONE_FRAMENUM_COLOR 0xF2FFF2 +#define VERY_PALE_GREENZONE_INPUT_COLOR1 0xE9FCE9 +#define VERY_PALE_GREENZONE_INPUT_COLOR2 0xDDF5DD + #define LAG_FRAMENUM_COLOR 0xDDDCFF #define LAG_INPUT_COLOR1 0xD2D0F0 #define LAG_INPUT_COLOR2 0xC9C6E8 @@ -120,6 +124,10 @@ enum DRAG_MODES #define PALE_LAG_INPUT_COLOR1 0xDADAF4 #define PALE_LAG_INPUT_COLOR2 0xCFCEEA +#define VERY_PALE_LAG_FRAMENUM_COLOR 0xF1F1FF +#define VERY_PALE_LAG_INPUT_COLOR1 0xEDEDFA +#define VERY_PALE_LAG_INPUT_COLOR2 0xE7E7F5 + #define CUR_FRAMENUM_COLOR 0xFCF1CE #define CUR_INPUT_COLOR1 0xF8EBB6 #define CUR_INPUT_COLOR2 0xE6DDA5 diff --git a/src/drivers/win/taseditor/playback.cpp b/src/drivers/win/taseditor/playback.cpp index 80ada012..5e8b0769 100644 --- a/src/drivers/win/taseditor/playback.cpp +++ b/src/drivers/win/taseditor/playback.cpp @@ -138,7 +138,7 @@ void PLAYBACK::update() } // pause when seeking hits pause_frame - if(pause_frame && currFrameCounter + 1 >= pause_frame) + if (pause_frame && currFrameCounter + 1 >= pause_frame) SeekingStop(); else if (currFrameCounter + 1 > lost_position_frame && currFrameCounter >= currMovieData.getNumRecords()-1 && autopause_at_the_end && taseditor_config.autopause_at_finish) // pause at the end of the movie @@ -422,7 +422,7 @@ void PLAYBACK::StartFromZero() FCEUMOV_ClearCommands(); // clear POWER SWITCH command caused by poweron() currFrameCounter = 0; // if there's no frames in current movie, create initial frame record - if(currMovieData.getNumRecords() == 0) + if (currMovieData.getNumRecords() == 0) currMovieData.insertEmpty(-1, 1); } diff --git a/src/drivers/win/taseditor/popup_display.cpp b/src/drivers/win/taseditor/popup_display.cpp index 8d5bacfe..64ff477e 100644 --- a/src/drivers/win/taseditor/popup_display.cpp +++ b/src/drivers/win/taseditor/popup_display.cpp @@ -61,7 +61,7 @@ POPUP_DISPLAY::POPUP_DISPLAY() wincl1.cbClsExtra = 0; wincl1.cbWndExtra = 0; wincl1.hbrBackground = 0; - if(!RegisterClassEx(&wincl1)) + if (!RegisterClassEx(&wincl1)) FCEU_printf("Error registering SCREENSHOT_DISPLAY window class\n"); // register MARKER_NOTE_DESCRIPTION window class @@ -77,7 +77,7 @@ POPUP_DISPLAY::POPUP_DISPLAY() wincl2.cbClsExtra = 0; wincl2.cbWndExtra = 0; wincl2.hbrBackground = 0; - if(!RegisterClassEx(&wincl2)) + if (!RegisterClassEx(&wincl2)) FCEU_printf("Error registering MARKER_NOTE_DESCRIPTION window class\n"); // create blendfunction diff --git a/src/drivers/win/taseditor/selection.cpp b/src/drivers/win/taseditor/selection.cpp index 92d9ecdf..8de9cbdd 100644 --- a/src/drivers/win/taseditor/selection.cpp +++ b/src/drivers/win/taseditor/selection.cpp @@ -367,7 +367,7 @@ void SELECTION::ItemRangeChanged(NMLVODSTATECHANGE* info) bool ON = !(info->uOldState & LVIS_SELECTED) && (info->uNewState & LVIS_SELECTED); bool OFF = (info->uOldState & LVIS_SELECTED) && !(info->uNewState & LVIS_SELECTED); - if(ON) + if (ON) for(int i = info->iFrom; i <= info->iTo; ++i) CurrentSelection().insert(i); else @@ -384,9 +384,9 @@ void SELECTION::ItemChanged(NMLISTVIEW* info) bool OFF = (info->uOldState & LVIS_SELECTED) && !(info->uNewState & LVIS_SELECTED); //if the item is -1, apply the change to all items - if(item == -1) + if (item == -1) { - if(OFF) + if (OFF) { // clear all (actually add new empty selection to history) if (CurrentSelection().size() && track_selection_changes) @@ -399,9 +399,9 @@ void SELECTION::ItemChanged(NMLISTVIEW* info) } } else { - if(ON) + if (ON) CurrentSelection().insert(item); - else if(OFF) + else if (OFF) CurrentSelection().erase(item); } @@ -652,7 +652,7 @@ int SELECTION::GetCurrentSelectionEnd() } bool SELECTION::CheckFrameSelected(int frame) { - if(CurrentSelection().find(frame) == CurrentSelection().end()) + if (CurrentSelection().find(frame) == CurrentSelection().end()) return false; return true; } diff --git a/src/drivers/win/taseditor/snapshot.cpp b/src/drivers/win/taseditor/snapshot.cpp index 1960b24a..0ae1aa79 100644 --- a/src/drivers/win/taseditor/snapshot.cpp +++ b/src/drivers/win/taseditor/snapshot.cpp @@ -517,7 +517,7 @@ int SNAPSHOT::GetCommandsInfo(int frame) void SNAPSHOT::insertFrames(int at, int frames) { size += frames; - if(at == -1) + if (at == -1) { // append frames to the end commands.resize(size); diff --git a/src/drivers/win/taseditor/splicer.cpp b/src/drivers/win/taseditor/splicer.cpp index 430291ea..2d40f13a 100644 --- a/src/drivers/win/taseditor/splicer.cpp +++ b/src/drivers/win/taseditor/splicer.cpp @@ -202,7 +202,7 @@ void SPLICER::InsertNumFrames() { SelectionFrames* current_selection = selection.MakeStrobe(); int frames = current_selection->size(); - if(CWin32InputBox::GetInteger("Insert number of Frames", "How many frames?", frames, taseditor_window.hwndTasEditor) == IDOK) + if (CWin32InputBox::GetInteger("Insert number of Frames", "How many frames?", frames, taseditor_window.hwndTasEditor) == IDOK) { if (frames > 0) { diff --git a/src/drivers/win/taseditor/taseditor_lua.cpp b/src/drivers/win/taseditor/taseditor_lua.cpp index b4d321a0..ff8c77f8 100644 --- a/src/drivers/win/taseditor/taseditor_lua.cpp +++ b/src/drivers/win/taseditor/taseditor_lua.cpp @@ -125,7 +125,7 @@ int TASEDITOR_LUA::setmarker(int frame) if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR)) { int marker_id = markers_manager.GetMarker(frame); - if(!marker_id) + if (!marker_id) { marker_id = markers_manager.SetMarker(frame); if (marker_id) diff --git a/src/drivers/win/taseditor/taseditor_project.cpp b/src/drivers/win/taseditor/taseditor_project.cpp index 073c5c96..b3ffe0b5 100644 --- a/src/drivers/win/taseditor/taseditor_project.cpp +++ b/src/drivers/win/taseditor/taseditor_project.cpp @@ -82,13 +82,13 @@ bool TASEDITOR_PROJECT::save(const char* different_name, bool save_binary, bool char md5_rom[256]; strcpy(md5_movie, md5_asciistr(currMovieData.romChecksum)); strcpy(md5_rom, md5_asciistr(GameInfo->MD5)); - if(strcmp(md5_movie, md5_rom)) + if (strcmp(md5_movie, md5_rom)) { // checksums mismatch, check if they both aren't zero unsigned int k, count1 = 0, count2 = 0; for(k = 0; k < strlen(md5_movie); k++) count1 += md5_movie[k] - '0'; for(k = 0; k < strlen(md5_rom); k++) count2 += md5_rom[k] - '0'; - if(count1 && count2) + if (count1 && count2) { // ask user if he wants to fix the checksum before saving char message[2048] = {0}; @@ -163,7 +163,7 @@ bool TASEDITOR_PROJECT::load(const char* fullname) bool load_all = true; EMUFILE_FILE ifs(fullname, "rb"); - if(ifs.fail()) + if (ifs.fail()) { FCEU_PrintError("Error opening %s!", fullname); return false; @@ -181,13 +181,13 @@ bool TASEDITOR_PROJECT::load(const char* fullname) char md5_current[256]; strcpy(md5_original, md5_asciistr(tempMovieData.romChecksum)); strcpy(md5_current, md5_asciistr(GameInfo->MD5)); - if(strcmp(md5_original, md5_current)) + if (strcmp(md5_original, md5_current)) { // checksums mismatch, check if they both aren't zero unsigned int k, count1 = 0, count2 = 0; for(k = 0; k < strlen(md5_original); k++) count1 += md5_original[k] - '0'; for(k = 0; k < strlen(md5_current); k++) count2 += md5_current[k] - '0'; - if(count1 && count2) + if (count1 && count2) { // ask user if he really wants to load the project char message[2048] = {0}; diff --git a/src/drivers/win/taseditor/taseditor_window.cpp b/src/drivers/win/taseditor/taseditor_window.cpp index 39abe950..19827fe2 100644 --- a/src/drivers/win/taseditor/taseditor_window.cpp +++ b/src/drivers/win/taseditor/taseditor_window.cpp @@ -621,14 +621,14 @@ void TASEDITOR_WINDOW::UpdateRecentProjectsMenu() for(x = MAX_NUMBER_OF_RECENT_PROJECTS - 1; x >= 0; x--) { // Skip empty strings - if(!recent_projects[x]) continue; + if (!recent_projects[x]) continue; moo.fMask = MIIM_DATA | MIIM_ID | MIIM_TYPE; moo.fType = 0; moo.wID = MENU_FIRST_RECENT_PROJECT + x; std::string tmp = recent_projects[x]; // clamp this string to 128 chars - if(tmp.size() > 128) + if (tmp.size() > 128) tmp = tmp.substr(0, 128); moo.cch = tmp.size(); moo.dwTypeData = (LPSTR)tmp.c_str(); @@ -651,9 +651,9 @@ void TASEDITOR_WINDOW::UpdateRecentProjectsArray(const char* addString) // find out if the filename is already in the recent files list for(unsigned int x = 0; x < MAX_NUMBER_OF_RECENT_PROJECTS; x++) { - if(recent_projects[x]) + if (recent_projects[x]) { - if(!strcmp(recent_projects[x], addString)) // Item is already in list + if (!strcmp(recent_projects[x], addString)) // Item is already in list { // If the filename is in the file list don't add it again, move it up in the list instead char* tmp = recent_projects[x]; // save pointer @@ -669,7 +669,7 @@ void TASEDITOR_WINDOW::UpdateRecentProjectsArray(const char* addString) } // The filename wasn't found in the list. That means we need to add it. // If there's no space left in the recent files list, get rid of the last item in the list - if(recent_projects[MAX_NUMBER_OF_RECENT_PROJECTS-1]) + if (recent_projects[MAX_NUMBER_OF_RECENT_PROJECTS-1]) free(recent_projects[MAX_NUMBER_OF_RECENT_PROJECTS-1]); // Move other items down for(unsigned int x = MAX_NUMBER_OF_RECENT_PROJECTS-1; x; x--) @@ -684,7 +684,7 @@ void TASEDITOR_WINDOW::RemoveRecentProject(unsigned int which) { if (which >= MAX_NUMBER_OF_RECENT_PROJECTS) return; // Remove the item - if(recent_projects[which]) + if (recent_projects[which]) free(recent_projects[which]); // If the item is not the last one in the list, shift the remaining ones up if (which < MAX_NUMBER_OF_RECENT_PROJECTS-1) @@ -702,7 +702,7 @@ void TASEDITOR_WINDOW::RemoveRecentProject(unsigned int which) void TASEDITOR_WINDOW::LoadRecentProject(int slot) { char*& fname = recent_projects[slot]; - if(fname && AskSaveProject()) + if (fname && AskSaveProject()) { if (!LoadProject(fname)) { @@ -730,7 +730,7 @@ void TASEDITOR_WINDOW::UpdatePatternsMenu() moo.wID = MENU_FIRST_PATTERN + x; std::string tmp = editor.autofire_patterns_names[x]; // clamp this string to 50 chars - if(tmp.size() > PATTERNS_MAX_VISIBLE_NAME) + if (tmp.size() > PATTERNS_MAX_VISIBLE_NAME) tmp = tmp.substr(0, PATTERNS_MAX_VISIBLE_NAME); moo.dwTypeData = (LPSTR)tmp.c_str(); moo.cch = tmp.size(); @@ -753,7 +753,7 @@ void TASEDITOR_WINDOW::RecheckPatternsMenu() std::string tmp = patterns_menu_prefix; tmp += editor.autofire_patterns_names[taseditor_config.current_pattern]; // clamp this string - if(tmp.size() > PATTERNMENU_MAX_VISIBLE_NAME) + if (tmp.size() > PATTERNMENU_MAX_VISIBLE_NAME) tmp = tmp.substr(0, PATTERNMENU_MAX_VISIBLE_NAME); moo.dwTypeData = (LPSTR)tmp.c_str(); moo.cch = tmp.size(); @@ -861,7 +861,7 @@ BOOL CALLBACK WndprocTasEditor(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara ExitTasEditor(); break; case WM_ACTIVATE: - if(LOWORD(wParam)) + if (LOWORD(wParam)) { taseditor_window.TASEditor_focus = true; taseditor_window.SetTaseditorInput(); @@ -1064,7 +1064,7 @@ BOOL CALLBACK WndprocTasEditor(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara case ID_CONFIG_SETGREENZONECAPACITY: { int new_capacity = taseditor_config.greenzone_capacity; - if(CWin32InputBox::GetInteger("Greenzone capacity", "Keep savestates for how many frames?\n(actual limit of savestates can be 5 times more than the number provided)", new_capacity, hWnd) == IDOK) + if (CWin32InputBox::GetInteger("Greenzone capacity", "Keep savestates for how many frames?\n(actual limit of savestates can be 5 times more than the number provided)", new_capacity, hWnd) == IDOK) { if (new_capacity < GREENZONE_CAPACITY_MIN) new_capacity = GREENZONE_CAPACITY_MIN; @@ -1081,7 +1081,7 @@ BOOL CALLBACK WndprocTasEditor(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara case ID_CONFIG_SETMAXUNDOLEVELS: { int new_size = taseditor_config.undo_levels; - if(CWin32InputBox::GetInteger("Max undo levels", "Keep history of how many changes?", new_size, hWnd) == IDOK) + if (CWin32InputBox::GetInteger("Max undo levels", "Keep history of how many changes?", new_size, hWnd) == IDOK) { if (new_size < UNDO_LEVELS_MIN) new_size = UNDO_LEVELS_MIN; @@ -1099,7 +1099,7 @@ BOOL CALLBACK WndprocTasEditor(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara case ID_CONFIG_SETAUTOSAVEPERIOD: { int new_period = taseditor_config.autosave_period; - if(CWin32InputBox::GetInteger("Autosave period", "How many minutes may the project stay not saved after being changed?\n(0 = no autosaves)", new_period, hWnd) == IDOK) + if (CWin32InputBox::GetInteger("Autosave period", "How many minutes may the project stay not saved after being changed?\n(0 = no autosaves)", new_period, hWnd) == IDOK) { if (new_period < AUTOSAVE_PERIOD_MIN) new_period = AUTOSAVE_PERIOD_MIN;