Browse code

Made debugger private to screen

neauoire authored on 16/08/2023 20:46:07
Showing 3 changed files
... ...
@@ -65,6 +65,40 @@ screen_blit(Uint8 *layer, Uint8 *ram, Uint16 addr, int x1, int y1, int color, in
65 65
 	}
66 66
 }
67 67
 
68
+/* clang-format off */
69
+
70
+static Uint8 icons[] = {
71
+	0x00, 0x7c, 0x82, 0x82, 0x82, 0x82, 0x82, 0x7c, 0x00, 0x30, 0x10, 0x10, 0x10, 0x10, 0x10, 
72
+	0x10, 0x00, 0x7c, 0x82, 0x02, 0x7c, 0x80, 0x80, 0xfe, 0x00, 0x7c, 0x82, 0x02, 0x1c, 0x02, 
73
+	0x82, 0x7c, 0x00, 0x0c, 0x14, 0x24, 0x44, 0x84, 0xfe, 0x04, 0x00, 0xfe, 0x80, 0x80, 0x7c, 
74
+	0x02, 0x82, 0x7c, 0x00, 0x7c, 0x82, 0x80, 0xfc, 0x82, 0x82, 0x7c, 0x00, 0x7c, 0x82, 0x02, 
75
+	0x1e, 0x02, 0x02, 0x02, 0x00, 0x7c, 0x82, 0x82, 0x7c, 0x82, 0x82, 0x7c, 0x00, 0x7c, 0x82, 
76
+	0x82, 0x7e, 0x02, 0x82, 0x7c, 0x00, 0x7c, 0x82, 0x02, 0x7e, 0x82, 0x82, 0x7e, 0x00, 0xfc, 
77
+	0x82, 0x82, 0xfc, 0x82, 0x82, 0xfc, 0x00, 0x7c, 0x82, 0x80, 0x80, 0x80, 0x82, 0x7c, 0x00, 
78
+	0xfc, 0x82, 0x82, 0x82, 0x82, 0x82, 0xfc, 0x00, 0x7c, 0x82, 0x80, 0xf0, 0x80, 0x82, 0x7c,
79
+	0x00, 0x7c, 0x82, 0x80, 0xf0, 0x80, 0x80, 0x80};
80
+
81
+/* clang-format on */
82
+
83
+static void
84
+draw_byte(Uint8 v, Uint16 x, Uint16 y, Uint8 color)
85
+{
86
+	screen_blit(uxn_screen.fg, icons, v >> 4 << 3, x, y, color, 0, 0, 0);
87
+	screen_blit(uxn_screen.fg, icons, (v & 0xf) << 3, x + 8, y, color, 0, 0, 0);
88
+}
89
+
90
+static void
91
+screen_debugger(Uxn *u)
92
+{
93
+	int i;
94
+	for(i = 0; i < u->wst.ptr; i++)
95
+		draw_byte(u->wst.dat[i], i * 0x18 + 0x8, uxn_screen.height - 0x18, 0x2);
96
+	for(i = 0; i < u->rst.ptr; i++)
97
+		draw_byte(u->rst.dat[i], i * 0x18 + 0x8, uxn_screen.height - 0x10, 0x3);
98
+	for(i = 0; i < 0x40; i++)
99
+		draw_byte(u->ram[i], (i & 0x7) * 0x18 + 0x8, ((i >> 3) << 3) + 0x8, 1 + !!u->ram[i]);
100
+}
101
+
68 102
 void
69 103
 screen_palette(Uint8 *addr)
70 104
 {
... ...
@@ -111,15 +145,19 @@ screen_resize(Uint16 width, Uint16 height)
111 145
 }
112 146
 
113 147
 void
114
-screen_redraw(void)
148
+screen_redraw(Uxn *u)
115 149
 {
116 150
 	Uint8 *fg = uxn_screen.fg, *bg = uxn_screen.bg;
117 151
 	Uint32 palette[16], *pixels = uxn_screen.pixels;
118
-	int i, x, y, w = uxn_screen.width, h = uxn_screen.height;
119
-	int x1 = uxn_screen.x1;
120
-	int y1 = uxn_screen.y1;
121
-	int x2 = uxn_screen.x2 > w ? w : uxn_screen.x2;
122
-	int y2 = uxn_screen.y2 > h ? h : uxn_screen.y2;
152
+	int i, x, y, w = uxn_screen.width, h = uxn_screen.height, x1, y1, x2, y2;
153
+	if(u->dev[0x0e]) {
154
+		screen_change(0, 0, w, h);
155
+		screen_debugger(u);
156
+	}
157
+	x1 = uxn_screen.x1;
158
+	y1 = uxn_screen.y1;
159
+	x2 = uxn_screen.x2 > w ? w : uxn_screen.x2;
160
+	y2 = uxn_screen.y2 > h ? h : uxn_screen.y2;
123 161
 	for(i = 0; i < 16; i++)
124 162
 		palette[i] = uxn_screen.palette[(i >> 2) ? (i >> 2) : (i & 3)];
125 163
 	for(y = y1; y < y2; y++)
... ...
@@ -131,40 +169,6 @@ screen_redraw(void)
131 169
 	uxn_screen.x2 = uxn_screen.y2 = 0;
132 170
 }
133 171
 
134
-/* clang-format off */
135
-
136
-Uint8 icons[] = {
137
-	0x00, 0x7c, 0x82, 0x82, 0x82, 0x82, 0x82, 0x7c, 0x00, 0x30, 0x10, 0x10, 0x10, 0x10, 0x10, 
138
-	0x10, 0x00, 0x7c, 0x82, 0x02, 0x7c, 0x80, 0x80, 0xfe, 0x00, 0x7c, 0x82, 0x02, 0x1c, 0x02, 
139
-	0x82, 0x7c, 0x00, 0x0c, 0x14, 0x24, 0x44, 0x84, 0xfe, 0x04, 0x00, 0xfe, 0x80, 0x80, 0x7c, 
140
-	0x02, 0x82, 0x7c, 0x00, 0x7c, 0x82, 0x80, 0xfc, 0x82, 0x82, 0x7c, 0x00, 0x7c, 0x82, 0x02, 
141
-	0x1e, 0x02, 0x02, 0x02, 0x00, 0x7c, 0x82, 0x82, 0x7c, 0x82, 0x82, 0x7c, 0x00, 0x7c, 0x82, 
142
-	0x82, 0x7e, 0x02, 0x82, 0x7c, 0x00, 0x7c, 0x82, 0x02, 0x7e, 0x82, 0x82, 0x7e, 0x00, 0xfc, 
143
-	0x82, 0x82, 0xfc, 0x82, 0x82, 0xfc, 0x00, 0x7c, 0x82, 0x80, 0x80, 0x80, 0x82, 0x7c, 0x00, 
144
-	0xfc, 0x82, 0x82, 0x82, 0x82, 0x82, 0xfc, 0x00, 0x7c, 0x82, 0x80, 0xf0, 0x80, 0x82, 0x7c,
145
-	0x00, 0x7c, 0x82, 0x80, 0xf0, 0x80, 0x80, 0x80};
146
-
147
-/* clang-format on */
148
-
149
-void
150
-draw_byte(Uint8 v, Uint16 x, Uint16 y, Uint8 color)
151
-{
152
-	screen_blit(uxn_screen.fg, icons, v >> 4 << 3, x, y, color, 0, 0, 0);
153
-	screen_blit(uxn_screen.fg, icons, (v & 0xf) << 3, x + 8, y, color, 0, 0, 0);
154
-}
155
-
156
-void
157
-screen_debugger(Uxn *u)
158
-{
159
-	int i;
160
-	for(i = 0; i < u->wst.ptr; i++)
161
-		draw_byte(u->wst.dat[i], i * 0x18 + 0x8, uxn_screen.height - 0x18, 0x2);
162
-	for(i = 0; i < u->rst.ptr; i++)
163
-		draw_byte(u->rst.dat[i], i * 0x18 + 0x8, uxn_screen.height - 0x10, 0x3);
164
-	for(i = 0; i < 0x40; i++)
165
-		draw_byte(u->ram[i], (i & 0x7) * 0x18 + 0x8, ((i >> 3) << 3) + 0x8, 1 + !!u->ram[i]);
166
-}
167
-
168 172
 Uint8
169 173
 screen_dei(Uxn *u, Uint8 addr)
170 174
 {
... ...
@@ -26,8 +26,7 @@ void screen_fill(Uint8 *layer, int x1, int y1, int x2, int y2, int color);
26 26
 void screen_palette(Uint8 *addr);
27 27
 void screen_resize(Uint16 width, Uint16 height);
28 28
 void screen_change(Uint16 x1, Uint16 y1, Uint16 x2, Uint16 y2);
29
-void screen_redraw(void);
30
-void screen_debugger(Uxn *u);
29
+void screen_redraw(Uxn *u);
31 30
 
32 31
 Uint8 screen_dei(Uxn *u, Uint8 addr);
33 32
 void screen_deo(Uint8 *ram, Uint8 *d, Uint8 port);
... ...
@@ -209,12 +209,7 @@ emu_resize(int width, int height)
209 209
 static void
210 210
 emu_redraw(Uxn *u)
211 211
 {
212
-	if(u->dev[0x0e]) {
213
-		screen_change(0, 0, uxn_screen.width, uxn_screen.height);
214
-		screen_redraw();
215
-		screen_debugger(u);
216
-	} else
217
-		screen_redraw();
212
+	screen_redraw(u);
218 213
 	if(SDL_UpdateTexture(emu_texture, NULL, uxn_screen.pixels, uxn_screen.width * sizeof(Uint32)) != 0)
219 214
 		system_error("SDL_UpdateTexture", SDL_GetError());
220 215
 	SDL_RenderClear(emu_renderer);