diff options
| author | James Barnett <noreply@jamesbarnett.xyz> | 2018-07-24 20:24:58 +0100 |
|---|---|---|
| committer | James Barnett <noreply@jamesbarnett.xyz> | 2018-07-24 20:24:58 +0100 |
| commit | e4e561bd94df819f4ce9487f28b1d18a8d178810 (patch) | |
| tree | 4ff6bb0d6e9afbb6cb06eeceb2dc3d538bbc5adc /src/main/kotlin | |
| parent | 6acdde8f7093c0fb2e95d8dbc14dfab096b0a027 (diff) | |
| download | KGB-e4e561bd94df819f4ce9487f28b1d18a8d178810.tar.xz KGB-e4e561bd94df819f4ce9487f28b1d18a8d178810.zip | |
Add ram dump debug window
Diffstat (limited to 'src/main/kotlin')
| -rw-r--r-- | src/main/kotlin/gui/CpuRegisterWindow.kt | 2 | ||||
| -rw-r--r-- | src/main/kotlin/gui/DebugWindow.kt | 2 | ||||
| -rw-r--r-- | src/main/kotlin/gui/EmulationOutputWindow.kt | 2 | ||||
| -rw-r--r-- | src/main/kotlin/gui/RamDumpWindow.kt | 43 | ||||
| -rw-r--r-- | src/main/kotlin/gui/RunControlWindow.kt | 4 | ||||
| -rw-r--r-- | src/main/kotlin/gui/WindowContainer.kt | 1 |
6 files changed, 50 insertions, 4 deletions
diff --git a/src/main/kotlin/gui/CpuRegisterWindow.kt b/src/main/kotlin/gui/CpuRegisterWindow.kt index 618d298..b7f9116 100644 --- a/src/main/kotlin/gui/CpuRegisterWindow.kt +++ b/src/main/kotlin/gui/CpuRegisterWindow.kt @@ -8,7 +8,7 @@ import imgui.ImGui fun paintCpuRegisterWindow(registers: Registers) { with(ImGui) { setNextWindowSize(Vec2(200, 250), Cond.FirstUseEver) - setNextWindowPos(Vec2(20, 150), Cond.FirstUseEver) + setNextWindowPos(Vec2(15, 80), Cond.FirstUseEver) begin("CPU state") text("Registers:") diff --git a/src/main/kotlin/gui/DebugWindow.kt b/src/main/kotlin/gui/DebugWindow.kt index d80d2b3..f336ef6 100644 --- a/src/main/kotlin/gui/DebugWindow.kt +++ b/src/main/kotlin/gui/DebugWindow.kt @@ -6,7 +6,7 @@ import imgui.ImGui fun paintDebugWindow() { with(ImGui) { - setNextWindowPos(Vec2(20, 50), Cond.FirstUseEver) + setNextWindowPos(Vec2(15, 10), Cond.FirstUseEver) begin("Debug info") text("%.1f FPS (%.2f ms/frame)", io.framerate, 1_000f / io.framerate) end() diff --git a/src/main/kotlin/gui/EmulationOutputWindow.kt b/src/main/kotlin/gui/EmulationOutputWindow.kt index 489edbe..14fe246 100644 --- a/src/main/kotlin/gui/EmulationOutputWindow.kt +++ b/src/main/kotlin/gui/EmulationOutputWindow.kt @@ -7,7 +7,7 @@ import imgui.ImGui fun paintEmulationOutputWindow() { with(ImGui) { setNextWindowSize(Vec2(640, 576), Cond.FirstUseEver) - setNextWindowPos(Vec2(400, 50), Cond.FirstUseEver) + setNextWindowPos(Vec2(620, 10), Cond.FirstUseEver) begin("Emulation output - 4x scale") text("TODO - actually render something...") end() diff --git a/src/main/kotlin/gui/RamDumpWindow.kt b/src/main/kotlin/gui/RamDumpWindow.kt new file mode 100644 index 0000000..da30162 --- /dev/null +++ b/src/main/kotlin/gui/RamDumpWindow.kt @@ -0,0 +1,43 @@ +package gui + +import glm_.vec2.Vec2 +import imgui.Cond +import imgui.ImGui +import ram.Ram + +fun paintRamDumpWindow(ram: Ram) { + with(ImGui) { + setNextWindowSize(Vec2(425, 300), Cond.FirstUseEver) + setNextWindowPos(Vec2(15, 340), Cond.FirstUseEver) + + begin("Ram dump") + + // TODO - lock range to scroll position + paintRamRange(0, 0x00FF, ram.ram) + + end() + } +} + +private fun paintRamRange(startAddress: Int, endAddress: Int, data: IntArray) { + (startAddress .. endAddress step 16).forEach { + paintLine(it, data) + } +} + +private fun paintLine(startAddress: Int, data: IntArray) { + val sb = StringBuilder() + sb.append(String.format("0x%04X: ", startAddress)) + + (0..15).forEach { + val address = startAddress + it + if(address <= (data.size-1)) { + sb.append(String.format("%02X ", data[startAddress + it])) + if(it == 7) {sb.append(" ")} + } + } + + ImGui.text(sb.toString()) +} + + diff --git a/src/main/kotlin/gui/RunControlWindow.kt b/src/main/kotlin/gui/RunControlWindow.kt index 8ffc764..cff33e5 100644 --- a/src/main/kotlin/gui/RunControlWindow.kt +++ b/src/main/kotlin/gui/RunControlWindow.kt @@ -8,7 +8,9 @@ import imgui.ImGui fun paintRunControlWindow(cpu: Cpu) { with(ImGui) { - setNextWindowPos(Vec2(20, 410), Cond.FirstUseEver) + setNextWindowSize(Vec2(120, 200), Cond.FirstUseEver) + setNextWindowPos(Vec2(220, 80), Cond.FirstUseEver) + begin("Run control") text("Current op:") diff --git a/src/main/kotlin/gui/WindowContainer.kt b/src/main/kotlin/gui/WindowContainer.kt index 4d58c18..8dcd37b 100644 --- a/src/main/kotlin/gui/WindowContainer.kt +++ b/src/main/kotlin/gui/WindowContainer.kt @@ -58,6 +58,7 @@ class WindowContainer { paintEmulationOutputWindow() paintCpuRegisterWindow(cpu.registers) paintRunControlWindow(cpu) + paintRamDumpWindow(cpu.ram) } gln.glViewport(window.framebufferSize) |