commit f98b698
neauoire
·
2023-11-12 05:47:54 +0000 UTC
parent e52db28
(Screen) Only check for screen boundary in blit, once
2 files changed,
+15,
-15
+14,
-14
1@@ -47,7 +47,7 @@ screen_fill(Uint8 *layer, int color)
2 }
3
4 void
5-screen_rect(Uint8 *layer, int x1, int y1, int x2, int y2, int color)
6+screen_rect(Uint8 *layer, Uint16 x1, Uint16 y1, Uint16 x2, Uint16 y2, int color)
7 {
8 int x, y, width = uxn_screen.width, height = uxn_screen.height;
9 for(y = y1; y < y2 && y < height; y++)
10@@ -56,19 +56,19 @@ screen_rect(Uint8 *layer, int x1, int y1, int x2, int y2, int color)
11 }
12
13 static void
14-screen_blit(Uint8 *layer, Uint8 *ram, Uint16 addr, int x1, int y1, int color, int flipx, int flipy, int twobpp)
15+screen_blit(Uint8 *layer, Uint8 *ram, Uint16 addr, Uint16 x1, Uint16 y1, Uint16 color, int flipx, int flipy, int twobpp)
16 {
17 int v, h, width = uxn_screen.width, height = uxn_screen.height, opaque = (color % 5);
18+ /* TODO: Draw partial tile */
19+ if(x1 + 8 >= width) return;
20+ if(y1 + 8 >= height) return;
21 for(v = 0; v < 8; v++) {
22 Uint16 c = ram[(addr + v) & 0xffff] | (twobpp ? (ram[(addr + v + 8) & 0xffff] << 8) : 0);
23- Uint16 y = y1 + (flipy ? 7 - v : v);
24+ int y = (y1 + (flipy ? 7 - v : v)) * width;
25 for(h = 7; h >= 0; --h, c >>= 1) {
26 Uint8 ch = (c & 1) | ((c >> 7) & 2);
27- if(opaque || ch) {
28- Uint16 x = x1 + (flipx ? 7 - h : h);
29- if(x < width && y < height)
30- layer[x + y * width] = blending[ch][color];
31- }
32+ if(opaque || ch)
33+ layer[(x1 + (flipx ? 7 - h : h)) + y] = blending[ch][color];
34 }
35 }
36 }
37@@ -104,16 +104,16 @@ screen_debugger(Uxn *u)
38 int i;
39 for(i = 0; i < 0x08; i++) {
40 Uint8 pos = u->wst.ptr - 4 + i;
41- Uint8 color = i > 4 ? 0x01 : !pos ? 0xc
42- : i == 4 ? 0x8
43- : 0x2;
44+ Uint8 color = i > 4 ? 0x01 : !pos ? 0xc :
45+ i == 4 ? 0x8 :
46+ 0x2;
47 draw_byte(u->wst.dat[pos], i * 0x18 + 0x8, uxn_screen.height - 0x18, color);
48 }
49 for(i = 0; i < 0x08; i++) {
50 Uint8 pos = u->rst.ptr - 4 + i;
51- Uint8 color = i > 4 ? 0x01 : !pos ? 0xc
52- : i == 4 ? 0x8
53- : 0x2;
54+ Uint8 color = i > 4 ? 0x01 : !pos ? 0xc :
55+ i == 4 ? 0x8 :
56+ 0x2;
57 draw_byte(u->rst.dat[pos], i * 0x18 + 0x8, uxn_screen.height - 0x10, color);
58 }
59 screen_blit(uxn_screen.fg, arrow, 0, 0x68, uxn_screen.height - 0x20, 3, 0, 0, 0);
+1,
-1
1@@ -23,7 +23,7 @@ extern UxnScreen uxn_screen;
2 extern int emu_resize(int width, int height);
3
4 void screen_fill(Uint8 *layer, int color);
5-void screen_rect(Uint8 *layer, int x1, int y1, int x2, int y2, int color);
6+void screen_rect(Uint8 *layer, Uint16 x1, Uint16 y1, Uint16 x2, Uint16 y2, int color);
7 void screen_palette(Uint8 *addr);
8 void screen_resize(Uint16 width, Uint16 height);
9 void screen_change(Uint16 x1, Uint16 y1, Uint16 x2, Uint16 y2);