commit 1328521
Devine Lu Linvega
·
2026-01-08 20:37:52 +0000 UTC
parent b24ebcb
Faster screen redraw
1 files changed,
+13,
-9
+13,
-9
1@@ -507,18 +507,22 @@ screen_resize(int width, int height)
2 static void
3 screen_redraw(void)
4 {
5- int x, y;
6 if(screen_zoom == 1) {
7- int colmar = (screen_y1 + 8) * screen_wmar2;
8- int *dst = &screen_pixels[screen_y1 * screen_width + screen_x1];
9- for(y = screen_y1; y < screen_y2; y++, dst += screen_width, colmar += screen_wmar2) {
10- int i = (screen_x1 + 8) + colmar;
11- int *a = dst, *b = a + (screen_x2 - screen_x1);
12- while(a < b)
13- *a++ = screen_palette[screen_layers[i++]];
14+ const int colmar = (screen_y1 + 8) * screen_wmar2 + (screen_x1 + 8);
15+ const int row_width = screen_x2 - screen_x1;
16+ const int src_stride = screen_wmar2 - row_width;
17+ const int dst_stride = screen_width - row_width;
18+ int y, *dst_ptr = &screen_pixels[screen_y1 * screen_width + screen_x1];
19+ Uint8 *src_ptr = &screen_layers[colmar];
20+ for(y = screen_y1; y < screen_y2; y++) {
21+ int *dst_end = dst_ptr + row_width;
22+ while(dst_ptr < dst_end)
23+ *dst_ptr++ = screen_palette[*src_ptr++];
24+ dst_ptr += dst_stride;
25+ src_ptr += src_stride;
26 }
27 } else {
28- int i, k, l;
29+ int x, y, i, k, l;
30 const int stride = screen_width * screen_zoom;
31 for(y = screen_y1; y < screen_y2; y++) {
32 const int ys = y * screen_zoom;