annotate nuklear_ui/debug_ui.c @ 2693:46dba737b931

WIP Nuklear UI in VDP debug windows
author Michael Pavone <pavone@retrodev.com>
date Thu, 19 Jun 2025 19:59:05 -0700
parents
children 25fc676e3521
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2693
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
1 #include <limits.h>
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
2 #include <string.h>
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
3 #include <stdlib.h>
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
4
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
5 #include "blastem_nuklear.h"
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
6 #include "../blastem.h"
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
7 #include "../genesis.h"
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
8 #include "../sms.h"
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
9 #include "../coleco.h"
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
10
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
11 typedef struct {
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
12 struct nk_context *context;
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
13 uint32_t tex_width;
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
14 uint32_t tex_height;
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
15 uint8_t win_idx;
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
16 } debug_window;
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
17
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
18 static debug_window windows[NUM_DEBUG_TYPES];
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
19
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
20 static void debug_handle_event(uint8_t which, SDL_Event *event)
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
21 {
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
22 for (int i = 0; i < NUM_DEBUG_TYPES; i++)
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
23 {
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
24 if (windows[i].win_idx == which) {
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
25 nk_sdl_handle_event(windows[i].context, event);
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
26 break;
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
27 }
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
28 }
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
29 }
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
30
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
31 #ifndef DISABLE_OPENGL
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
32 vdp_context *get_vdp(void)
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
33 {
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
34 if (!current_system) {
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
35 return NULL;
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
36 }
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
37 switch (current_system->type)
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
38 {
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
39 case SYSTEM_GENESIS:
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
40 case SYSTEM_SEGACD:
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
41 case SYSTEM_PICO:
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
42 case SYSTEM_COPERA:
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
43 return ((genesis_context *)current_system)->vdp;
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
44 case SYSTEM_SMS:
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
45 case SYSTEM_GAME_GEAR:
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
46 case SYSTEM_SG1000:
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
47 case SYSTEM_SC3000:
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
48 return ((sms_context *)current_system)->vdp;
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
49 case SYSTEM_COLECOVISION:
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
50 return ((coleco_context *)current_system)->vdp;
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
51 default:
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
52 return NULL;
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
53 }
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
54 }
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
55
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
56 void write_cram_internal(vdp_context * context, uint16_t addr, uint16_t value);
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
57 static void cram_debug_ui(void)
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
58 {
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
59 vdp_context *vdp = get_vdp();
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
60 if (!vdp) {
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
61 return;
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
62 }
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
63 struct nk_context *context = windows[DEBUG_CRAM].context;
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
64 nk_input_end(context);
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
65 char buf[64];
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
66
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
67 struct nk_image main_image = nk_image_id((int)render_get_window_texture(windows[DEBUG_CRAM].win_idx));
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
68 if (nk_begin(context, "CRAM Debug", nk_rect(0, 0, windows[DEBUG_CRAM].tex_width + 100 + 8, windows[DEBUG_CRAM].tex_height + 8), NK_WINDOW_NO_SCROLLBAR)) {
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
69 nk_layout_space_begin(context, NK_STATIC, windows[DEBUG_CRAM].tex_height, INT_MAX);
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
70 nk_layout_space_push(context, nk_rect(100, 0, windows[DEBUG_CRAM].tex_width, windows[DEBUG_CRAM].tex_height));
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
71 nk_image(context, main_image);
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
72 struct nk_rect bounds = nk_layout_widget_bounds(context);
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
73 bounds.x += 100;
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
74 bounds.w -= 100;
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
75 bounds.h = (vdp->flags2 & FLAG2_REGION_PAL) ? 313 : 262;
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
76 if (nk_input_is_mouse_hovering_rect(&context->input, bounds)) {
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
77 int off_y = context->input.mouse.pos.y - bounds.y;
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
78 int off_x = context->input.mouse.pos.x - bounds.x;
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
79 pixel_t pix = vdp->debug_fbs[DEBUG_CRAM][off_y * vdp->debug_fb_pitch[DEBUG_CRAM] / sizeof(pixel_t) + off_x];
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
80 #ifdef USE_GLES
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
81 pixel_t b = pix >> 20 & 0xE, g = pix >> 12 & 0xE, r = pix >> 4 & 0xE;
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
82 #else
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
83 pixel_t r = pix >> 20 & 0xE, g = pix >> 12 & 0xE, b = pix >> 4 & 0xE;
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
84 #endif
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
85 pix = b << 8 | g << 4 | r;
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
86 snprintf(buf, sizeof(buf), "Line: %d, Index: %d, Value: %03X", off_y- vdp->border_top, off_x >> 3, pix & 0xFFFFFF);
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
87 nk_layout_space_push(context, nk_rect(100, 512 - 32*5, windows[DEBUG_CRAM].tex_width, 32));
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
88 nk_label(context, buf, NK_TEXT_LEFT);
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
89 }
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
90 bounds.y += 512-32*4;
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
91 bounds.h = 32*4;
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
92 if (nk_input_is_mouse_hovering_rect(&context->input, bounds)) {
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
93 int index = ((((int)(context->input.mouse.pos.y - bounds.y)) >> 1) & 0xF0) + (((int)(context->input.mouse.pos.x - bounds.x)) >> 5);
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
94 snprintf(buf, sizeof(buf), "Index: %2d, Value: %03X", index, vdp->cram[index]);
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
95 nk_layout_space_push(context, nk_rect(100, 512 - 32*5, windows[DEBUG_CRAM].tex_width, 32));
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
96 nk_label(context, buf, NK_TEXT_LEFT);
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
97 }
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
98
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
99 static struct nk_scroll scroll;
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
100 context->style.window.scrollbar_size.y = 0;
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
101 nk_layout_space_push(context, nk_rect(0, 0, 100, windows[DEBUG_CRAM].tex_height));
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
102 if (nk_group_scrolled_begin(context, &scroll, "Entries", 0)) {
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
103 nk_layout_space_begin(context, NK_STATIC, windows[DEBUG_CRAM].tex_height * 4, INT_MAX);
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
104 for (int i = 0; i < 64; i++)
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
105 {
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
106 nk_layout_space_push(context, nk_rect(0, i *32, 25, 32));
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
107 snprintf(buf, sizeof(buf), "%d", i);
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
108 nk_label(context, buf, NK_TEXT_RIGHT);
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
109 nk_layout_space_push(context, nk_rect(30, i *32, 50, 32));
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
110 snprintf(buf, sizeof(buf), "%03X", vdp->cram[i] & 0xEEE);
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
111 nk_edit_string_zero_terminated(context, NK_EDIT_FIELD, buf, sizeof(buf), nk_filter_hex);
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
112 char *end;
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
113 long newv = strtol(buf, &end, 16);
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
114 if (end != buf && newv != vdp->cram[i]) {
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
115 write_cram_internal(vdp, i, newv & 0xEEE);
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
116 }
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
117 }
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
118 nk_layout_space_end(context);
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
119 nk_group_scrolled_end(context);
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
120 }
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
121
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
122 nk_end(context);
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
123 }
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
124 nk_sdl_render(context, NK_ANTI_ALIASING_ON, 512 * 1024, 128 * 1024);
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
125
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
126 nk_input_begin(context);
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
127 }
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
128 #endif
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
129
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
130 uint8_t debug_create_window(uint8_t debug_type, char *caption, uint32_t width, uint32_t height, window_close_handler close_handler)
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
131 {
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
132 #ifndef DISABLE_OPENGL
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
133 if (!render_has_gl()) {
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
134 #endif
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
135 return render_create_window(caption, width, height, close_handler);
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
136 #ifndef DISABLE_OPENGL
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
137 }
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
138 uint32_t win_width = width, win_height = height;
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
139 ui_render_fun render = NULL;
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
140 switch (debug_type)
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
141 {
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
142 case DEBUG_CRAM:
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
143 win_width += 100;
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
144 render = cram_debug_ui;
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
145 break;
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
146 }
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
147 if (render) {
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
148 //compensate for padding
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
149 win_width += 4 * 2;
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
150 win_height += 4 * 2;
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
151 windows[debug_type].win_idx = render_create_window_tex(caption, win_width, win_height, width, height, close_handler);
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
152 windows[debug_type].tex_width = width;
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
153 windows[debug_type].tex_height = width;
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
154 windows[debug_type].context = shared_nuklear_init(windows[debug_type].win_idx);
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
155 render_set_ui_render_fun(windows[debug_type].win_idx, render);
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
156 render_set_event_handler(windows[debug_type].win_idx, debug_handle_event);
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
157 return windows[debug_type].win_idx;
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
158 } else {
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
159 return render_create_window(caption, width, height, close_handler);
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
160 }
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
161 #endif
46dba737b931 WIP Nuklear UI in VDP debug windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
162 }