diff options
author | Freya Murphy <freya@freyacat.org> | 2025-04-28 11:43:24 -0400 |
---|---|---|
committer | Freya Murphy <freya@freyacat.org> | 2025-04-28 11:43:24 -0400 |
commit | dce1a7d3f2f49431888c14940c73b7c204d322d5 (patch) | |
tree | 895cf6d1fad34bd545836f44df985f8a1ca2cb5e /user/apple.c | |
parent | make sure sleep sets pcb to state sleeping (diff) | |
download | comus-dce1a7d3f2f49431888c14940c73b7c204d322d5.tar.gz comus-dce1a7d3f2f49431888c14940c73b7c204d322d5.tar.bz2 comus-dce1a7d3f2f49431888c14940c73b7c204d322d5.zip |
anti aliasing :3
Diffstat (limited to '')
-rw-r--r-- | user/apple.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/user/apple.c b/user/apple.c index 5adafe8..a0a7e9a 100644 --- a/user/apple.c +++ b/user/apple.c @@ -21,14 +21,34 @@ static size_t frame = 0; static size_t frame_size; static size_t ticks_off; +#define PIXEL(x, y) \ + gAPPLEData[offset + \ + (((x + APPLE_WIDTH % APPLE_WIDTH) / scale) + \ + ((y + APPLE_HEIGHT % APPLE_HEIGHT) / scale) * APPLE_WIDTH)] + static void draw_frame(void) { size_t offset = frame_size * frame; for (int y = 0; y < APPLE_HEIGHT * scale; y++) { for (int x = 0; x < APPLE_WIDTH * scale; x++) { - uint8_t color = - gAPPLEData[offset + ((x / scale) + (y / scale) * APPLE_WIDTH)]; + uint8_t colors[9]; + colors[0] = PIXEL(x, y); + colors[1] = PIXEL(x - 1, y); + colors[2] = PIXEL(x + 1, y); + colors[3] = PIXEL(x, y - 1); + colors[4] = PIXEL(x - 1, y - 1); + colors[5] = PIXEL(x + 1, y - 1); + colors[6] = PIXEL(x, y + 1); + colors[7] = PIXEL(x - 1, y + 1); + colors[8] = PIXEL(x + 1, y + 1); + + // anti aliasing + uint8_t color = (colors[0] + colors[0] + colors[0] + colors[0] + + colors[1] + colors[2] + colors[3] + colors[4] + + colors[5] + colors[6] + colors[7] + colors[8]) / + 12; + fb[x + y * width] = (color << 16) | (color << 8) | (color << 0); } } |