blob: da30162098284817a4282807869e12d0c78d00ab (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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())
}
|