commit 7377477
Devine Lu Linvega
·
2023-05-06 00:21:46 +0000 UTC
parent cac4e5d
Implemented scaling
3 files changed,
+11,
-9
+9,
-8
1@@ -84,7 +84,7 @@ screen_resize(Uint16 width, Uint16 height)
2 return;
3 bg = realloc(uxn_screen.bg, width * height),
4 fg = realloc(uxn_screen.fg, width * height);
5- pixels = realloc(uxn_screen.pixels, width * height * sizeof(Uint32));
6+ pixels = realloc(uxn_screen.pixels, width * height * sizeof(Uint32) * SCALE * SCALE);
7 if(!bg || !fg || !pixels)
8 return;
9 uxn_screen.bg = bg;
10@@ -101,17 +101,18 @@ screen_redraw(void)
11 {
12 Uint8 *fg = uxn_screen.fg, *bg = uxn_screen.bg;
13 Uint32 palette[16], *pixels = uxn_screen.pixels;
14- int i, x, y, w = uxn_screen.width, h = uxn_screen.height;
15- int x1 = uxn_screen.x1;
16- int y1 = uxn_screen.y1;
17- int x2 = uxn_screen.x2 > w ? w : uxn_screen.x2;
18- int y2 = uxn_screen.y2 > h ? h : uxn_screen.y2;
19+ int i, j, x, y, w = uxn_screen.width, h = uxn_screen.height;
20+ int x1 = uxn_screen.x1 * SCALE;
21+ int y1 = uxn_screen.y1 * SCALE;
22+ int x2 = (uxn_screen.x2 > w ? w : uxn_screen.x2) * SCALE;
23+ int y2 = (uxn_screen.y2 > h ? h : uxn_screen.y2) * SCALE;
24 for(i = 0; i < 16; i++)
25 palette[i] = uxn_screen.palette[(i >> 2) ? (i >> 2) : (i & 3)];
26 for(y = y1; y < y2; y++)
27 for(x = x1; x < x2; x++) {
28- i = x + y * w;
29- pixels[i] = palette[fg[i] << 2 | bg[i]];
30+ i = x / SCALE + y / SCALE * w;
31+ j = x + y * w * SCALE;
32+ pixels[j] = palette[fg[i] << 2 | bg[i]];
33 }
34 uxn_screen.x1 = uxn_screen.y1 = 0xffff;
35 uxn_screen.x2 = uxn_screen.y2 = 0;
+2,
-0
1@@ -22,3 +22,5 @@ void screen_resize(Uint16 width, Uint16 height);
2 void screen_redraw(void);
3 Uint8 screen_dei(Uxn *u, Uint8 addr);
4 void screen_deo(Uint8 *ram, Uint8 *d, Uint8 port);
5+
6+#define SCALE 3
+0,
-1
1@@ -33,7 +33,6 @@ static Window window;
2
3 char *rom_path;
4
5-#define SCALE 1
6 #define WIDTH (64 * 8)
7 #define HEIGHT (40 * 8)
8 #define PAD 4