Small ui changes to fit the window better.
This commit is contained in:
@@ -6,7 +6,7 @@ gui_bottom_tabs :: proc(rect: rl.Rectangle, sim: ^Simulator) {
|
||||
rl.DrawRectangleLinesEx(rect, 1, rl.GRAY)
|
||||
|
||||
// Setup tab bar
|
||||
tabs := [?]cstring{ "Memory", "Disassembly", "Log" }
|
||||
tabs := [?]cstring{ "Memory", "Log" }
|
||||
|
||||
tab_bar_rect := rl.Rectangle{
|
||||
rect.x,
|
||||
|
||||
@@ -6,42 +6,54 @@ import rl "vendor:raylib"
|
||||
|
||||
gui_tab_disasm :: proc(rect: rl.Rectangle, sim: ^Simulator) {
|
||||
rl.DrawRectangleRec(rect, rl.DARKGRAY)
|
||||
rl.GuiPanel(rect, "Disassembly")
|
||||
|
||||
// Header background
|
||||
rl.DrawRectangle(i32(rect.x), i32(rect.y), i32(rect.width), i32(PANEL_HEADER), rl.BLACK)
|
||||
// Header: Address label
|
||||
rl.DrawTextEx(sim.font, "Disassembled Instructions", {rect.x + 4, rect.y + 4}, 18, 1, rl.WHITE)
|
||||
|
||||
|
||||
// Scroll panel area (below header)
|
||||
panel_rect := rl.Rectangle{
|
||||
rect.x,
|
||||
rect.y + PANEL_HEADER,
|
||||
rect.width,
|
||||
rect.height - PANEL_HEADER,
|
||||
}
|
||||
rl.GuiPanel(panel_rect, nil)
|
||||
|
||||
LINE_HEIGHT :: 22
|
||||
|
||||
// Total height of all instructions
|
||||
conten_height := f32(len(sim.disasm)) * LINE_HEIGHT
|
||||
|
||||
content_rect := rl.Rectangle {
|
||||
x = rect.x,
|
||||
y = rect.y,
|
||||
width = rect.width + PANEL_HEADER,
|
||||
height = conten_height,
|
||||
x = panel_rect.x,
|
||||
y = panel_rect.y - PANEL_HEADER,
|
||||
width = panel_rect.width + PANEL_HEADER,
|
||||
height = f32(len(sim.disasm)) * LINE_HEIGHT
|
||||
}
|
||||
|
||||
view: rl.Rectangle
|
||||
rl.GuiScrollPanel(rect, nil, content_rect, &sim.disasm_scroll, &view)
|
||||
rl.GuiScrollPanel(panel_rect, nil, content_rect, &sim.disasm_scroll, &view)
|
||||
|
||||
rl.BeginScissorMode(i32(view.x), i32(view.y), i32(view.width), i32(view.height))
|
||||
defer rl.EndScissorMode()
|
||||
|
||||
for entry, i in sim.disasm {
|
||||
y_pos := rect.y + PANEL_HEADER + (f32(i) * LINE_HEIGHT) + sim.disasm_scroll.y
|
||||
y_pos := panel_rect.y + (f32(i) * LINE_HEIGHT) + sim.disasm_scroll.y
|
||||
|
||||
txt := fmt.tprintf("%d : %s", i, entry.str)
|
||||
bg_color := rl.DARKGRAY if entry.address != sim.machine.pc else rl.BLACK
|
||||
txt_color := rl.WHITE
|
||||
|
||||
rl.DrawRectangleV(
|
||||
{rect.x + sim.disasm_scroll.x, y_pos},
|
||||
{rect.width, LINE_HEIGHT},
|
||||
{panel_rect.x + sim.disasm_scroll.x, y_pos},
|
||||
{panel_rect.width, LINE_HEIGHT},
|
||||
bg_color,
|
||||
)
|
||||
rl.DrawTextEx(
|
||||
sim.font,
|
||||
strings.clone_to_cstring(txt, context.temp_allocator),
|
||||
{rect.x + PADDING_X + sim.disasm_scroll.x, y_pos},
|
||||
{panel_rect.x + PADDING_X + sim.disasm_scroll.x, y_pos},
|
||||
18, 1,
|
||||
txt_color,
|
||||
)
|
||||
|
||||
@@ -7,7 +7,6 @@ import rl "vendor:raylib"
|
||||
MEM_INDICATOR_W :: 14
|
||||
MEM_ADDRESS_W :: 72
|
||||
MEM_ROW_H :: 20
|
||||
MEM_HEADER_H :: 24
|
||||
MEM_BYTES_PER_ROW :: 16
|
||||
MEM_TOTAL_ROWS :: 256
|
||||
MEM_FONT_ROWS :: 5
|
||||
@@ -25,32 +24,32 @@ gui_tab_memory :: proc(rect: rl.Rectangle, sim: ^Simulator) {
|
||||
rl.DrawRectangleRec(rect, rl.DARKGRAY)
|
||||
|
||||
// Header background
|
||||
rl.DrawRectangle(i32(rect.x), i32(rect.y), i32(rect.width), MEM_HEADER_H, rl.BLACK)
|
||||
rl.DrawRectangle(i32(rect.x), i32(rect.y), i32(rect.width), i32(PANEL_HEADER), rl.BLACK)
|
||||
|
||||
// Header: Address label
|
||||
rl.DrawTextEx(sim.font, "Address", {rect.x + MEM_INDICATOR_W, rect.y + 4}, 16, 1, rl.GRAY)
|
||||
rl.DrawTextEx(sim.font, "Address", {rect.x + MEM_INDICATOR_W, rect.y + 4}, 18, 1, rl.WHITE)
|
||||
|
||||
// Header: column labels 0-F
|
||||
col_w := byte_col_w(rect)
|
||||
for col in 0..<16 {
|
||||
x := rect.x + MEM_INDICATOR_W + MEM_ADDRESS_W + f32(col) * col_w
|
||||
label := strings.clone_to_cstring(MEM_COL_LABELS[col], context.temp_allocator)
|
||||
rl.DrawTextEx(sim.font, label, {x, rect.y + 4}, 16, 1, rl.GRAY)
|
||||
rl.DrawTextEx(sim.font, label, {x, rect.y + 4}, 18, 1, rl.WHITE)
|
||||
}
|
||||
|
||||
// Header separator
|
||||
rl.DrawLine(
|
||||
i32(rect.x), i32(rect.y + MEM_HEADER_H),
|
||||
i32(rect.x + rect.width), i32(rect.y + MEM_HEADER_H),
|
||||
i32(rect.x), i32(rect.y + PANEL_HEADER),
|
||||
i32(rect.x + rect.width), i32(rect.y + PANEL_HEADER),
|
||||
rl.GRAY,
|
||||
)
|
||||
|
||||
// Scroll panel area (below header)
|
||||
panel_rect := rl.Rectangle{
|
||||
rect.x,
|
||||
rect.y + MEM_HEADER_H,
|
||||
rect.y + PANEL_HEADER,
|
||||
rect.width,
|
||||
rect.height - MEM_HEADER_H,
|
||||
rect.height - PANEL_HEADER,
|
||||
}
|
||||
|
||||
content_rect := rl.Rectangle{
|
||||
@@ -66,7 +65,7 @@ gui_tab_memory :: proc(rect: rl.Rectangle, sim: ^Simulator) {
|
||||
|
||||
draw_row := 0
|
||||
|
||||
// --- Font rows (0x000 - 0x04F) ---
|
||||
// Font rows (0x000 - 0x04F)
|
||||
for row in 0..<MEM_FONT_ROWS {
|
||||
addr := row * MEM_BYTES_PER_ROW
|
||||
row_y := panel_rect.y + f32(draw_row) * MEM_ROW_H + sim.mem_scroll.y
|
||||
@@ -74,7 +73,6 @@ gui_tab_memory :: proc(rect: rl.Rectangle, sim: ^Simulator) {
|
||||
draw_row += 1
|
||||
}
|
||||
|
||||
// --- Divider ---
|
||||
divider_y := panel_rect.y + f32(draw_row) * MEM_ROW_H + sim.mem_scroll.y
|
||||
rl.DrawRectangle(i32(rect.x), i32(divider_y), i32(rect.width), MEM_ROW_H, rl.ColorAlpha(rl.BLACK, 0.4))
|
||||
rl.DrawTextEx(
|
||||
@@ -85,7 +83,7 @@ gui_tab_memory :: proc(rect: rl.Rectangle, sim: ^Simulator) {
|
||||
)
|
||||
draw_row += 1
|
||||
|
||||
// --- ROM rows (0x200 onwards) ---
|
||||
// ROM rows (0x200 onwards)
|
||||
for i := 0; MEM_ROM_START + i * MEM_BYTES_PER_ROW < 4096; i += 1 {
|
||||
addr := MEM_ROM_START + i * MEM_BYTES_PER_ROW
|
||||
row_y := panel_rect.y + f32(draw_row) * MEM_ROW_H + sim.mem_scroll.y
|
||||
|
||||
Reference in New Issue
Block a user