Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
nzeemin committed Jul 27, 2024
1 parent f85c456 commit 5e64a0b
Show file tree
Hide file tree
Showing 6 changed files with 147 additions and 44 deletions.
12 changes: 0 additions & 12 deletions emulator/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,6 @@ UKNCBTL. If not, see <http://www.gnu.org/licenses/>. */

#pragma once

//////////////////////////////////////////////////////////////////////

#ifdef _DEBUG
#define APP_VERSION_STRING "DEBUG"
#define APP_REVISION 0
#elif !defined(PRODUCT)
#define APP_VERSION_STRING "RELEASE"
#define APP_REVISION 0
#else
#include "Version.h"
#endif

//////////////////////////////////////////////////////////////////////
// Assertions checking - MFC-like ASSERT macro

Expand Down
2 changes: 1 addition & 1 deletion emulator/ConsoleView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void ConsoleView_DoConsoleCommand();

void ConsoleView_Init()
{
ConsoleView_Print("UKNCBTL emulator TODO version information.");
ConsoleView_Print("UKNCBTL ImGui version " APP_VERSION_STRING);
ConsoleView_Print("Use 'h' command to show help.");
ConsoleView_Print("");
}
Expand Down
2 changes: 1 addition & 1 deletion emulator/DebugViews.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ void Breakpoints_ImGuiWidget()

if (isDeleteHovered)
{
ImGui::TextColored(ImVec4(1.0f, 0.0f, 0.0f, 1.0f), ICON_FA_MINUS_CIRCLE);
ImGui::TextColored(g_colorBreak, ICON_FA_MINUS_CIRCLE);
ImGui::SameLine();
}

Expand Down
23 changes: 13 additions & 10 deletions emulator/DisasmView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void Disasm_DrawForRunningEmulator()

int index = 5;
ImGui::SetCursorPosX(xPosCurrentSign);
ImGui::TextColored(ImVec4(0.0f, 0.67f, 0.0f, 1.0f), ICON_FA_PLAY);
ImGui::TextColored(g_colorPlay, ICON_FA_PLAY);
ImGui::SameLine(0.0f, 0.0f);
ImGui::SetCursorPosX(xPosAddress);
ImGui::Text("%06o ", address);
Expand All @@ -106,7 +106,7 @@ void Disasm_DrawForRunningEmulator()

void DisasmView_DrawJump(ImDrawList* draw_list, ImVec2 lineMin, int delta, float cyLine)
{
ImU32 col = ImGui::ColorConvertFloat4ToU32(ImVec4(0.5f, 0.7f, 1.0f, 0.67f));
ImU32 col = ImGui::ColorConvertFloat4ToU32(g_colorJumpLine);

int dist = abs(delta);
if (dist < 2) dist = 2;
Expand Down Expand Up @@ -165,8 +165,8 @@ void Disasm_DrawForStoppedEmulator(CProcessor* pProc)
if (isBreakpoint || isBreakpointHovered)
{
ImVec4 colorBreak = isBreakpoint
? (isBreakpointHovered ? ImVec4(1.0f, 0.0f, 0.0f, 1.0f) : ImVec4(0.67f, 0.0f, 0.0f, 1.0f))
: ImVec4(0.25f, 0.25f, 0.25f, 1.0f);
? (isBreakpointHovered ? g_colorDisabledRed : g_colorBreak)
: ImGui::GetStyleColorVec4(ImGuiCol_TextDisabled);
ImGui::TextColored(colorBreak, ICON_FA_CIRCLE);
ImGui::SameLine(0.0f, 0.0f);

Expand All @@ -176,13 +176,16 @@ void Disasm_DrawForStoppedEmulator(CProcessor* pProc)
if (address == proccurrent)
{
ImGui::SetCursorPosX(xPosCurrentSign);
ImGui::TextColored(ImVec4(0.0f, 0.67f, 0.0f, 1.0f), ICON_FA_PLAY);
ImGui::TextColored(g_colorPlay, ICON_FA_PLAY);
ImGui::SameLine(0.0f, 0.0f);
}

int memorytype = m_DisasmAddrType[index];
ImVec4 colorAddr = (memorytype == ADDRTYPE_ROM) ? g_colorDisabledBlue : ImGui::GetStyleColorVec4(ImGuiCol_TextDisabled);
ImGui::SetCursorPosX(xPosAddress);
ImGui::Text("%06o ", address);
ImGui::TextColored(colorAddr, "%06o ", address);
ImGui::SameLine();
ImGui::Text("%06o ", m_DisasmMemory[index]);
ImGui::TextDisabled("%06o ", m_DisasmMemory[index]);
ImGui::SameLine();

if (address >= disasmfrom && length == 0)
Expand All @@ -208,20 +211,20 @@ void Disasm_DrawForStoppedEmulator(CProcessor* pProc)
if (*m_strDisasmHint == 0) // we don't have the jump hint
{
Disasm_GetInstructionHint(m_DisasmMemory + index, pProc, pMemCtl, m_strDisasmHint, m_strDisasmHint2);
ImGui::Text("%S", m_strDisasmHint);
ImGui::TextDisabled("%S", m_strDisasmHint);
ImGui::SameLine(0.0f, 0.0f);
}
else // we have jump hint
{
ImVec4 color = m_okDisasmJumpPredict ? ImVec4(0.0f, 1.0f, 0.0f, 1.0f) : ImVec4(1.0f, 0.0f, 0.0f, 1.0f);
ImVec4 color = m_okDisasmJumpPredict ? g_colorDisabledGreen : g_colorDisabledRed;
ImGui::TextColored(color, "%S", m_strDisasmHint);
ImGui::SameLine(0.0f, 0.0f);
}
}
if (address == proccurrent + 2 && *m_strDisasmHint2 != 0)
{
ImGui::SetCursorPosX(xPosHints);
ImGui::Text("%S", m_strDisasmHint2);
ImGui::TextDisabled("%S", m_strDisasmHint2);
ImGui::SameLine(0.0f, 0.0f);
}
}
Expand Down
14 changes: 13 additions & 1 deletion emulator/Main.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ UKNCBTL. If not, see <http://www.gnu.org/licenses/>. */

#pragma once

//#include "res/Resource.h"
#ifdef _DEBUG
#define APP_VERSION_STRING "DEBUG"
#else
#include "Version.h"
#endif

//////////////////////////////////////////////////////////////////////

Expand All @@ -31,6 +35,14 @@ extern bool g_okVsyncSwitchable;
extern uint32_t* m_bits; // Screen buffer
extern ImTextureID g_ScreenTextureID;

// Derived colors based and calculated using the current style
extern ImVec4 g_colorPlay; // Play sign in Disasm window
extern ImVec4 g_colorBreak; // Breakpoint
extern ImVec4 g_colorJumpLine; // Jump arrow
extern ImVec4 g_colorDisabledRed; // Disabled color shifted to red
extern ImVec4 g_colorDisabledGreen; // Disabled color shifted to green
extern ImVec4 g_colorDisabledBlue; // Disabled color shifted to blue


//////////////////////////////////////////////////////////////////////
// Main Window
Expand Down
138 changes: 119 additions & 19 deletions emulator/MainWindow.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

#include "stdafx.h"
#include "imgui/imgui_internal.h"
#include "Main.h"
#include "Emulator.h"
#include "emubase/Emubase.h"
Expand All @@ -15,6 +16,14 @@ bool show_demo_window = false;
bool open_settings_popup = false;
bool open_about_popup = false;

// Derived colors based and calculated using the current style
ImVec4 g_colorPlay; // Play sign in Disasm window
ImVec4 g_colorBreak; // Breakpoint
ImVec4 g_colorJumpLine; // Jump arrow
ImVec4 g_colorDisabledRed; // Disabled color shifted to red
ImVec4 g_colorDisabledGreen; // Disabled color shifted to green
ImVec4 g_colorDisabledBlue; // Disabled color shifted to blue


//////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -88,6 +97,14 @@ void MainWindow_SetColorSheme(int scheme)
case 1: ImGui::StyleColorsLight(); break;
case 2: ImGui::StyleColorsClassic(); break;
}

// Calculate derived colors
g_colorPlay = ImLerp(ImGui::GetStyleColorVec4(ImGuiCol_Text), ImVec4(0.0f, 0.67f, 0.0f, 1.0f), 0.67f);
g_colorBreak = ImLerp(ImGui::GetStyleColorVec4(ImGuiCol_Text), ImVec4(1.0f, 0.0f, 0.0f, 1.0f), 0.67f);
g_colorJumpLine = ImLerp(ImGui::GetStyleColorVec4(ImGuiCol_Text), ImVec4(0.5f, 0.7f, 1.0f, 0.67f), 0.67f);
g_colorDisabledRed = ImLerp(ImGui::GetStyleColorVec4(ImGuiCol_TextDisabled), ImVec4(1.0f, 0.0f, 0.0f, 1.0f), 0.33f);
g_colorDisabledGreen = ImLerp(ImGui::GetStyleColorVec4(ImGuiCol_TextDisabled), ImVec4(0.0f, 1.0f, 0.0f, 1.0f), 0.33f);
g_colorDisabledBlue = ImLerp(ImGui::GetStyleColorVec4(ImGuiCol_TextDisabled), ImVec4(0.0f, 0.0f, 1.0f, 1.0f), 0.33f);
}

void ImGuiMainMenu()
Expand All @@ -106,24 +123,6 @@ void ImGuiMainMenu()
//ImGui::MenuItem("Quit");//TODO
ImGui::EndMenu();
}
if (ImGui::BeginMenu("View"))
{
int viewmode = Settings_GetScreenViewMode();
bool checkedRGB = viewmode == 0;
ImGui::BeginDisabled(checkedRGB);
if (ImGui::MenuItem("RGB Screen", nullptr, &checkedRGB)) MainWindow_DoScreenViewMode(RGBScreen);
ImGui::EndDisabled();
bool checkedGRB = viewmode == 1;
ImGui::BeginDisabled(checkedGRB);
if (ImGui::MenuItem("GRB Screen", nullptr, &checkedGRB)) MainWindow_DoScreenViewMode(GRBScreen);
ImGui::EndDisabled();
bool checkedGray = viewmode == 2;
ImGui::BeginDisabled(checkedGray);
if (ImGui::MenuItem("Grayscale Screen", nullptr, &checkedGray)) MainWindow_DoScreenViewMode(GrayScreen);
ImGui::EndDisabled();

ImGui::EndMenu();
}
if (ImGui::BeginMenu("Emulator"))
{
if (!g_okEmulatorRunning)
Expand All @@ -147,6 +146,12 @@ void ImGuiMainMenu()

ImGui::Separator();

bool sound = Settings_GetSound();
if (ImGui::MenuItem("Sound", nullptr, &sound))
MainWindow_DoEmulatorSound(sound);

ImGui::Separator();

WORD speed = Settings_GetRealSpeed();
bool checked25 = speed == 0x7ffe;
ImGui::BeginDisabled(checked25);
Expand All @@ -171,6 +176,101 @@ void ImGuiMainMenu()

ImGui::EndMenu();
}
if (ImGui::BeginMenu("Configuration"))
{
for (int floppyslot = 0; floppyslot < 4; floppyslot++)
{
char bufname[64];
if (g_pBoard->IsFloppyImageAttached(floppyslot))
{
sprintf(bufname, "FDD %d: " ICON_FA_EJECT " Eject###MenuFloppyEject%d", floppyslot, floppyslot);
if (ImGui::MenuItem(bufname))
MainWindow_DoFloppyImageEject(floppyslot);
ImGui::SameLine();

TCHAR buffilepath[MAX_PATH];
Settings_GetFloppyFilePath(floppyslot, buffilepath);
LPCTSTR lpFileName = GetFileNameFromFilePath(buffilepath);
ImGui::Text("%S", lpFileName);
}
else
{
sprintf(bufname, "FDD %d: Select...###MenuFloppySelect%d", floppyslot, floppyslot);
if (ImGui::MenuItem(bufname))
MainWindow_DoFloppyImageSelect(floppyslot);
}
}

ImGui::Separator();

for (int cartslot = 1; cartslot <= 2; cartslot++)
{
char bufname[64];
if (g_pBoard->IsROMCartridgeLoaded(cartslot))
{
sprintf(bufname, "Cart %d: " ICON_FA_EJECT " Eject###MenuCartEject%d", cartslot, cartslot);
if (ImGui::MenuItem(bufname))
MainWindow_DoCartridgeEject(cartslot);
ImGui::SameLine();

TCHAR buffilepath[MAX_PATH];
Settings_GetCartridgeFilePath(cartslot, buffilepath);
LPCTSTR lpFileName = GetFileNameFromFilePath(buffilepath);
ImGui::Text("%S", lpFileName);
}
else
{
sprintf(bufname, "Cart %d: Select...###MenuCartSelect%d", cartslot, cartslot);
if (ImGui::MenuItem(bufname))
MainWindow_DoCartridgeSelect(cartslot);
}
if (g_pBoard->IsROMCartridgeLoaded(cartslot))
{
if (g_pBoard->IsHardImageAttached(cartslot))
{
sprintf(bufname, " " ICON_FA_HDD " HDD: " ICON_FA_EJECT " Eject###MenuHardEject%d", cartslot);
if (ImGui::MenuItem(bufname))
MainWindow_DoHardImageEject(cartslot);
ImGui::SameLine();

TCHAR buffilepath[MAX_PATH];
Settings_GetHardFilePath(cartslot, buffilepath);
LPCTSTR lpFileName = GetFileNameFromFilePath(buffilepath);
ImGui::Text("%S", lpFileName);
}
else
{
sprintf(bufname, " " ICON_FA_HDD " HDD: Select... ###MenuHardSelect%d", cartslot);
if (ImGui::MenuItem(bufname))
MainWindow_DoHardImageSelect(cartslot);
}
}
else
{
ImGui::TextDisabled(" " ICON_FA_HDD " HDD");
}
}

ImGui::EndMenu();
}
if (ImGui::BeginMenu("Video"))
{
int viewmode = Settings_GetScreenViewMode();
bool checkedRGB = viewmode == 0;
ImGui::BeginDisabled(checkedRGB);
if (ImGui::MenuItem("RGB Screen", nullptr, &checkedRGB)) MainWindow_DoScreenViewMode(RGBScreen);
ImGui::EndDisabled();
bool checkedGRB = viewmode == 1;
ImGui::BeginDisabled(checkedGRB);
if (ImGui::MenuItem("GRB Screen", nullptr, &checkedGRB)) MainWindow_DoScreenViewMode(GRBScreen);
ImGui::EndDisabled();
bool checkedGray = viewmode == 2;
ImGui::BeginDisabled(checkedGray);
if (ImGui::MenuItem("Grayscale Screen", nullptr, &checkedGray)) MainWindow_DoScreenViewMode(GrayScreen);
ImGui::EndDisabled();

ImGui::EndMenu();
}
if (ImGui::BeginMenu("Debug"))
{
ImGui::BeginDisabled(g_okEmulatorRunning);
Expand Down Expand Up @@ -260,7 +360,7 @@ void ImGuiAboutPopup()
{
if (ImGui::BeginPopupModal("about_popup", nullptr, ImGuiWindowFlags_AlwaysAutoResize))
{
ImGui::Text("UKNCBTL ImGui version");
ImGui::Text("UKNCBTL ImGui version " APP_VERSION_STRING);
ImGui::TextLinkOpenURL("Source code", "https://github.com/nzeemin/ukncbtl-imgui");
ImGui::Spacing();

Expand Down

0 comments on commit 5e64a0b

Please sign in to comment.