commit addc257
Devine Lu Linvega
·
2026-03-13 16:57:59 +0000 UTC
parent 13a1af2
Removed dirty rectangle recording
1 files changed,
+13,
-41
+13,
-41
1@@ -40,8 +40,6 @@ static int rX, rY, rA, rMX, rMY, rMA, rML, rDX, rDY, rL1, rL2;
2 #define WIDTH (64 * 8)
3 #define HEIGHT (40 * 8)
4
5-#define CLAMP(v, a, b) { if(v < a) v = a; else if(v >= b) v = b; }
6-
7 static inline Uint16 peek2(const Uint8 *d) { return ((Uint16)d[0] << 8) | d[1]; }
8 static inline void poke2(Uint8 *d, Uint16 v) { d[0] = v >> 8, d[1] = v; }
9
10@@ -341,7 +339,6 @@ static void console_deo_lb(void) { fprintf(stderr, "%02x", dev[0x1b]); }
11
12 static int screen_zoom = 1, screen_reqsize, screen_reqdraw;
13 static int screen_width, screen_height, screen_wmar2, screen_hmar2;
14-static int screen_x1, screen_y1, screen_x2, screen_y2;
15 static int *screen_pixels, screen_palette[16];
16 static Uint8 *screen_layers;
17
18@@ -365,15 +362,6 @@ static const Uint8 blend_lut[16][2][4] = {
19
20 void emu_redraw(void), emu_resize(void);
21
22-static void
23-screen_change(const int x1, const int y1, const int x2, const int y2)
24-{
25- screen_x1 = x1 < screen_x1 ? x1 : screen_x1;
26- screen_y1 = y1 < screen_y1 ? y1 : screen_y1;
27- screen_x2 = x2 > screen_x2 ? x2 : screen_x2;
28- screen_y2 = y2 > screen_y2 ? y2 : screen_y2;
29-}
30-
31 static void
32 system_deo_colorize(void)
33 {
34@@ -411,13 +399,13 @@ static void
35 screen_redraw(void)
36 {
37 if(screen_zoom == 1) {
38- const int colmar = (screen_y1 + 8) * screen_wmar2 + (screen_x1 + 8);
39- const int row_width = screen_x2 - screen_x1;
40+ const int colmar = 8 * screen_wmar2 + 8;
41+ const int row_width = screen_width;
42 const int src_stride = screen_wmar2 - row_width;
43 const int dst_stride = screen_width - row_width;
44- int y, *dst_ptr = &screen_pixels[screen_y1 * screen_width + screen_x1];
45+ int y, *dst_ptr = &screen_pixels[0];
46 Uint8 *src_ptr = &screen_layers[colmar];
47- for(y = screen_y1; y < screen_y2; y++) {
48+ for(y = 0; y < screen_height; y++) {
49 int *dst_end = dst_ptr + row_width;
50 while(dst_ptr < dst_end)
51 *dst_ptr++ = screen_palette[*src_ptr++];
52@@ -427,9 +415,9 @@ screen_redraw(void)
53 } else {
54 int x, y, i, k, l;
55 const int stride = screen_width * screen_zoom;
56- for(y = screen_y1; y < screen_y2; y++) {
57+ for(y = 0; y < screen_height; y++) {
58 const int ys = y * screen_zoom;
59- for(x = screen_x1, i = (x + 8) + (y + 8) * screen_wmar2; x < screen_x2; x++, i++) {
60+ for(x = 0, i = (x + 8) + (y + 8) * screen_wmar2; x < screen_width; x++, i++) {
61 const int c = screen_palette[screen_layers[i]];
62 for(k = 0; k < screen_zoom; k++) {
63 const int oo = (ys + k) * stride + x * screen_zoom;
64@@ -440,7 +428,7 @@ screen_redraw(void)
65 }
66 }
67 emu_redraw();
68- screen_x1 = screen_y1 = screen_x2 = screen_y2 = screen_reqdraw = 0;
69+ screen_reqdraw = 0;
70 }
71
72 static void
73@@ -458,18 +446,8 @@ screen_update(void)
74 screen_reqsize = 0;
75 emu_resize();
76 }
77- if(screen_reqdraw) {
78- screen_x1 = screen_y1 = 0;
79- screen_x2 = screen_width;
80- screen_y2 = screen_height;
81- screen_redraw();
82- } else if(screen_x2 > screen_x1 && screen_y2 > screen_y1) {
83- CLAMP(screen_x1, 0, screen_width);
84- CLAMP(screen_y1, 0, screen_height);
85- CLAMP(screen_x2, 0, screen_width);
86- CLAMP(screen_y2, 0, screen_height);
87+ if(screen_reqdraw)
88 screen_redraw();
89- }
90 }
91
92 static void
93@@ -541,11 +519,7 @@ screen_deo_sprite(void)
94 }
95 }
96 }
97- if(!screen_reqdraw) {
98- int x1 = flipx ? x : rX, x2 = flipx ? rX : x;
99- int y1 = flipy ? y : rY, y2 = flipy ? rY : y;
100- screen_change(x1 - 8, y1 - 8, x2 + 8, y2 + 8);
101- }
102+ screen_reqdraw = 1;
103 if(rMX) rX += flipx ? -rDX : rDX;
104 if(rMY) rY += flipy ? -rDY : rDY;
105 }
106@@ -1118,11 +1092,9 @@ emu_resize(void)
107 void
108 emu_redraw(void)
109 {
110- const int ax = screen_x1 * screen_zoom;
111- const int ay = screen_y1 * screen_zoom;
112- const int aw = screen_x2 * screen_zoom - ax;
113- const int ah = screen_y2 * screen_zoom - ay;
114- XPutImage(emu_dpy, emu_win, DefaultGC(emu_dpy, 0), emu_img, ax, ay, ax, ay, aw, ah);
115+ const int w = screen_width * screen_zoom;
116+ const int h = screen_height * screen_zoom;
117+ XPutImage(emu_dpy, emu_win, DefaultGC(emu_dpy, 0), emu_img, 0, 0, 0, 0, w, h);
118 }
119
120 static void
121@@ -1312,7 +1284,7 @@ main(int argc, char **argv)
122 {
123 int i = 1;
124 if(argc == 2 && argv[1][0] == '-' && argv[1][1] == 'v')
125- return !fprintf(stdout, "%s - Varvara Emulator, 11 Mar 2026.\n", argv[0]);
126+ return !fprintf(stdout, "%s - Varvara Emulator, 13 Mar 2026.\n", argv[0]);
127 else if(argc == 1)
128 return !fprintf(stdout, "usage: %s [-v] file.rom [args..]\n", argv[0]);
129 else if(!system_boot(argv[i++], argc > 2))