From 0a78cd8405f128ab120ed6a1154953066d01f041 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Sat, 21 Feb 2026 12:16:32 -0500 Subject: [PATCH] more gud ui --- attempt_1/main.c | 65 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 50 insertions(+), 15 deletions(-) diff --git a/attempt_1/main.c b/attempt_1/main.c index f59345d..abff56c 100644 --- a/attempt_1/main.c +++ b/attempt_1/main.c @@ -576,22 +576,22 @@ S8 win_proc(void* hwnd, U4 msg, U8 wparam, S8 lparam) return 0; } case MS_WM_MOUSEMOVE: { - mu_input_mousemove(&mu_ctx, lparam & 0xFFFF, (lparam >> 16) & 0xFFFF); + mu_input_mousemove(&mu_ctx, (S2)(lparam & 0xFFFF), (S2)((lparam >> 16) & 0xFFFF)); ms_invalidate_rect(hwnd, nullptr, true); return 0; } case MS_WM_LBUTTONDOWN: { - mu_input_mousedown(&mu_ctx, lparam & 0xFFFF, (lparam >> 16) & 0xFFFF, MU_MOUSE_LEFT); + mu_input_mousedown(&mu_ctx, (S2)(lparam & 0xFFFF), (S2)((lparam >> 16) & 0xFFFF), MU_MOUSE_LEFT); ms_invalidate_rect(hwnd, nullptr, true); return 0; } case MS_WM_LBUTTONUP: { - mu_input_mouseup(&mu_ctx, lparam & 0xFFFF, (lparam >> 16) & 0xFFFF, MU_MOUSE_LEFT); + mu_input_mouseup(&mu_ctx, (S2)(lparam & 0xFFFF), (S2)((lparam >> 16) & 0xFFFF), MU_MOUSE_LEFT); ms_invalidate_rect(hwnd, nullptr, true); return 0; } case MS_WM_MOUSEWHEEL: { - mu_input_scroll(&mu_ctx, 0, ((S4)(wparam >> 16)) / -30); + mu_input_scroll(&mu_ctx, 0, ((S2)((wparam >> 16) & 0xFFFF)) / -30); ms_invalidate_rect(hwnd, nullptr, true); return 0; } @@ -811,13 +811,14 @@ S8 win_proc(void* hwnd, U4 msg, U8 wparam, S8 lparam) y += spacing_y; } - mu_ctx.style->colors[MU_COLOR_BUTTON] = mu_color(color_u32 & 0xFF, (color_u32 >> 8) & 0xFF, (color_u32 >> 16) & 0xFF, 255); + mu_ctx.style->colors[MU_COLOR_TEXT] = mu_color(color_u32 & 0xFF, (color_u32 >> 8) & 0xFF, (color_u32 >> 16) & 0xFF, 255); if (i == cursor_idx && editor_mode == MODE_EDIT) { - mu_ctx.style->colors[MU_COLOR_TEXT] = mu_color(0,0,0,255); - mu_ctx.style->colors[MU_COLOR_BUTTON] = mu_color(0x8E, 0x56, 0x3B, 255); + mu_ctx.style->colors[MU_COLOR_BUTTON] = mu_color(0x56, 0x3B, 0x1E, 255); // Dark Orange } else if (i == cursor_idx && editor_mode == MODE_NAV) { - mu_ctx.style->colors[MU_COLOR_BUTTON] = mu_color(0x26, 0x2F, 0x3B, 255); + mu_ctx.style->colors[MU_COLOR_BUTTON] = mu_color(0x3B, 0x46, 0x56, 255); // Dark Blue + } else { + mu_ctx.style->colors[MU_COLOR_BUTTON] = mu_color(0x1E, 0x1E, 0x1E, 255); // Dark Gray } mu_layout_set_next(&mu_ctx, mu_rect(x, y, btn_w, 22), 1); @@ -840,22 +841,21 @@ S8 win_proc(void* hwnd, U4 msg, U8 wparam, S8 lparam) mu_end_window(&mu_ctx); } - if (mu_begin_window(&mu_ctx, "HUD / Memory", mu_rect(10, 500, 900, 200))) { + if (mu_begin_window(&mu_ctx, "Compiler & Status", mu_rect(10, 500, 350, 200))) { char jit_str[64] = "Mode: Incremental | JIT Size: 0x000 bytes"; if (run_full) mem_copy(u8_(jit_str + 6), u8_("Full "), 11); u64_to_hex(code_arena.used, jit_str + 32, 3); mu_layout_row(&mu_ctx, 1, (int[]){-1}, 0); - mu_text(&mu_ctx, "x86-64 Machine Code Emitter | 2-Reg Stack | [F5] Toggle Run Mode | [PgUp/PgDn] Scroll"); + mu_ctx.style->colors[MU_COLOR_TEXT] = mu_color(170, 170, 170, 255); + mu_text(&mu_ctx, "2-Reg Stack x86-64 Emitter"); + mu_text(&mu_ctx, "[F5] Toggle Run | [PgUp/PgDn] Scroll"); + mu_ctx.style->colors[MU_COLOR_TEXT] = mu_color(255, 255, 255, 255); mu_text(&mu_ctx, jit_str); - char state_str[64] = "RAX: 00000000 | RDX: 00000000"; - u64_to_hex(vm_rax, state_str + 5, 8); - u64_to_hex(vm_rdx, state_str + 21, 8); - mu_text(&mu_ctx, state_str); - if (tape_count > 0 && cursor_idx < tape_count) { U4 cur_tag = unpack_tag(tape_ptr[cursor_idx]); const char* tag_name = tag_names [cur_tag]; + U4 cur_color = tag_colors[cur_tag]; char semantics_str[64] = "Current Tag: "; U4 name_len = 0; while (tag_name[name_len]) { @@ -863,8 +863,43 @@ S8 win_proc(void* hwnd, U4 msg, U8 wparam, S8 lparam) name_len ++; } semantics_str[13 + name_len] = '\0'; + mu_ctx.style->colors[MU_COLOR_TEXT] = mu_color(cur_color & 0xFF, (cur_color >> 8) & 0xFF, (cur_color >> 16) & 0xFF, 255); mu_text(&mu_ctx, semantics_str); } + mu_ctx.style->colors[MU_COLOR_TEXT] = mu_color(230, 230, 230, 255); + mu_end_window(&mu_ctx); + } + + if (mu_begin_window(&mu_ctx, "Registers & Globals", mu_rect(370, 500, 350, 200))) { + char state_str[64] = "RAX: 00000000 | RDX: 00000000"; + u64_to_hex(vm_rax, state_str + 5, 8); + u64_to_hex(vm_rdx, state_str + 21, 8); + mu_layout_row(&mu_ctx, 1, (int[]){-1}, 0); + mu_ctx.style->colors[MU_COLOR_TEXT] = mu_color(161, 186, 148, 255); // #94BAA1 mapped roughly + mu_text(&mu_ctx, state_str); + + for (int i=0; i < 4; i ++) { + char glob_str[32] = "[0]: 00000000"; + glob_str[1] = '0' + i; + u64_to_hex(vm_globals[i], glob_str + 5, 8); + mu_ctx.style->colors[MU_COLOR_TEXT] = mu_color(84, 164, 214, 255); // #D6A454 rough mapping to bgr? + // actually #D6A454 is R=D6(214) G=A4(164) B=54(84) but tag colors are 0x00BBGGRR, so 54(R) A4(G) D6(B). + // It was orange before, so 54, 164, 214. + mu_text(&mu_ctx, glob_str); + } + mu_ctx.style->colors[MU_COLOR_TEXT] = mu_color(230, 230, 230, 255); + mu_end_window(&mu_ctx); + } + + if (mu_begin_window(&mu_ctx, "Print Log", mu_rect(730, 500, 250, 200))) { + mu_layout_row(&mu_ctx, 1, (int[]){-1}, 0); + mu_ctx.style->colors[MU_COLOR_TEXT] = mu_color(161, 186, 148, 255); + for (int i = 0; icolors[MU_COLOR_TEXT] = mu_color(230, 230, 230, 255); mu_end_window(&mu_ctx); }