comparison nuklear_ui/debug_ui.c @ 2700:1cfd000dc750 default tip

WIP display screen border in plane debugger
author Michael Pavone <pavone@retrodev.com>
date Sun, 29 Jun 2025 23:38:56 -0700
parents 25fc676e3521
children
comparison
equal deleted inserted replaced
2699:89c06782589f 2700:1cfd000dc750
60 return; 60 return;
61 } 61 }
62 struct nk_context *context = windows[DEBUG_PLANE].context; 62 struct nk_context *context = windows[DEBUG_PLANE].context;
63 nk_input_end(context); 63 nk_input_end(context);
64 struct nk_image main_image = nk_image_id((int)render_get_window_texture(windows[DEBUG_PLANE].win_idx)); 64 struct nk_image main_image = nk_image_id((int)render_get_window_texture(windows[DEBUG_PLANE].win_idx));
65 if (nk_begin(context, "Plane Debug", nk_rect(0, 0, windows[DEBUG_PLANE].tex_width + 100 + 8, windows[DEBUG_PLANE].tex_height + 8), NK_WINDOW_NO_SCROLLBAR)) { 65 if (nk_begin(context, "Plane Debug", nk_rect(0, 0, windows[DEBUG_PLANE].tex_width + 150 + 8, windows[DEBUG_PLANE].tex_height + 8), NK_WINDOW_NO_SCROLLBAR)) {
66 nk_layout_space_begin(context, NK_STATIC, windows[DEBUG_PLANE].tex_height, INT_MAX); 66 nk_layout_space_begin(context, NK_STATIC, windows[DEBUG_PLANE].tex_height, INT_MAX);
67 nk_layout_space_push(context, nk_rect(100, 0, windows[DEBUG_PLANE].tex_width, windows[DEBUG_PLANE].tex_height)); 67 nk_layout_space_push(context, nk_rect(150, 0, windows[DEBUG_PLANE].tex_width, windows[DEBUG_PLANE].tex_height));
68 nk_image(context, main_image); 68 nk_image(context, main_image);
69 struct nk_rect bounds = nk_layout_widget_bounds(context); 69 struct nk_rect bounds = nk_layout_widget_bounds(context);
70 bounds.x += 100; 70 bounds.x += 100;
71 bounds.w -= 100; 71 bounds.w -= 100;
72 char buf[64]; 72 char buf[64];
73 if (nk_input_is_mouse_hovering_rect(&context->input, bounds)) { 73 if (nk_input_is_mouse_hovering_rect(&context->input, bounds)) {
74 //TODO: display plane position 74 //TODO: display plane position
75 int x = context->input.mouse.pos.x - bounds.x; 75 int x = context->input.mouse.pos.x - bounds.x;
76 int y = context->input.mouse.pos.y - bounds.y; 76 int y = context->input.mouse.pos.y - bounds.y;
77 switch (vdp->debug_modes[DEBUG_PLANE]) 77 switch (vdp->debug_modes[DEBUG_PLANE] & 3)
78 { 78 {
79 case 0: 79 case 0:
80 case 1: 80 case 1:
81 y &= 0xFF | (vdp->regs[REG_SCROLL] & 0x30) << 4; 81 y &= 0xFF | (vdp->regs[REG_SCROLL] & 0x30) << 4;
82 switch(vdp->regs[REG_SCROLL] & 0x3) 82 switch(vdp->regs[REG_SCROLL] & 0x3)
108 y >>= 1; 108 y >>= 1;
109 x -= 128; 109 x -= 128;
110 y -= 128; 110 y -= 128;
111 break; 111 break;
112 } 112 }
113 nk_layout_space_push(context, nk_rect(0, windows[DEBUG_PLANE].tex_height - 52, 100, 32)); 113 nk_layout_space_push(context, nk_rect(0, windows[DEBUG_PLANE].tex_height - 52, 150, 32));
114 snprintf(buf, sizeof(buf), "X: %d", x); 114 snprintf(buf, sizeof(buf), "X: %d", x);
115 nk_label(context, buf, NK_TEXT_LEFT); 115 nk_label(context, buf, NK_TEXT_LEFT);
116 nk_layout_space_push(context, nk_rect(0, windows[DEBUG_PLANE].tex_height - 32, 100, 32)); 116 nk_layout_space_push(context, nk_rect(0, windows[DEBUG_PLANE].tex_height - 32, 150, 32));
117 snprintf(buf, sizeof(buf), "Y: %d", y); 117 snprintf(buf, sizeof(buf), "Y: %d", y);
118 nk_label(context, buf, NK_TEXT_LEFT); 118 nk_label(context, buf, NK_TEXT_LEFT);
119 } 119 }
120 static const char* names[] = { 120 static const char* names[] = {
121 "Plane A", 121 "Plane A",
123 "Window", 123 "Window",
124 "Sprites" 124 "Sprites"
125 }; 125 };
126 for (int i = 0; i < 4; i++) 126 for (int i = 0; i < 4; i++)
127 { 127 {
128 nk_layout_space_push(context, nk_rect(0, i * 32, 100, 32)); 128 nk_layout_space_push(context, nk_rect(0, i * 32, 150, 32));
129 int selected = i == vdp->debug_modes[DEBUG_PLANE]; 129 int selected = i == (vdp->debug_modes[DEBUG_PLANE] & 3);
130 nk_selectable_label(context, names[i], NK_TEXT_ALIGN_LEFT, &selected); 130 nk_selectable_label(context, names[i], NK_TEXT_ALIGN_LEFT, &selected);
131 if (selected) { 131 if (selected) {
132 vdp->debug_modes[DEBUG_PLANE] = i; 132 vdp->debug_modes[DEBUG_PLANE] = i;
133 }
134 }
135 if ((vdp->debug_modes[DEBUG_PLANE] & 3) < 3) {
136 nk_layout_space_push(context, nk_rect(0, 5 * 32, 150, 32));
137 if (nk_check_label(context, "Screen Border", vdp->debug_flags & DEBUG_FLAG_PLANE_BORDER)) {
138 vdp->debug_flags |= DEBUG_FLAG_PLANE_BORDER;
139 } else {
140 vdp->debug_flags &= ~DEBUG_FLAG_PLANE_BORDER;
133 } 141 }
134 } 142 }
135 nk_end(context); 143 nk_end(context);
136 } 144 }
137 nk_sdl_render(context, NK_ANTI_ALIASING_ON, 512 * 1024, 128 * 1024); 145 nk_sdl_render(context, NK_ANTI_ALIASING_ON, 512 * 1024, 128 * 1024);
223 uint32_t win_width = width, win_height = height; 231 uint32_t win_width = width, win_height = height;
224 ui_render_fun render = NULL; 232 ui_render_fun render = NULL;
225 switch (debug_type) 233 switch (debug_type)
226 { 234 {
227 case DEBUG_PLANE: 235 case DEBUG_PLANE:
228 win_width += 100; 236 win_width += 150;
229 render = plane_debug_ui; 237 render = plane_debug_ui;
230 break; 238 break;
231 case DEBUG_CRAM: 239 case DEBUG_CRAM:
232 win_width += 100; 240 win_width += 100;
233 render = cram_debug_ui; 241 render = cram_debug_ui;