commit c583153df90af406e12f00c3fca27d05828689fc Author: sandyx Date: Sat Jun 15 16:34:31 2024 -0500 first commit diff --git a/main.c b/main.c new file mode 100644 index 0000000..bc19bbe --- /dev/null +++ b/main.c @@ -0,0 +1,93 @@ +#include +#include +#include +#include + +#define overload _Generic + +#define WIDTH 640 +#define HEIGHT 480 +#define VMEM WIDTH * HEIGHT + +Color video_memory[VMEM] = {}; +Image charset[26]; + +void draw_frame() { + for (int i = 0; i < WIDTH; i++) { + for (int j = 0; j < HEIGHT; j++) { + DrawPixel(i, j, video_memory[i + (j * WIDTH)]); + } + } +} + +void red_line(Color *vmem) { + static int i = 0; + for (; i < 70; i++) { + video_memory[i] = RED; + } +} + +void write_image(Color *vmem, Image image, uint32_t x, uint32_t y) { + for (int i = 0; i < 16; i++) { + int image_size = image.width * sizeof(uint32_t); //16 pixels, 4 bytes per pixel + memcpy(vmem + (i * WIDTH) + (y * WIDTH * 16) + (x * 16), &image.data[i * image_size], image_size); + } +} + +void load_charset() { + char filenames[][26] = { + "resources/A.png", + "resources/B.png", + "resources/C.png", + "resources/D.png", + "resources/E.png", + "resources/F.png", + "resources/G.png", + "resources/H.png", + "resources/I.png", + "resources/J.png", + "resources/K.png", + "resources/L.png", + "resources/M.png", + "resources/N.png", + "resources/O.png", + "resources/P.png", + "resources/Q.png", + "resources/R.png", + "resources/S.png", + "resources/T.png", + "resources/U.png", + "resources/V.png", + "resources/W.png", + "resources/X.png", + "resources/Y.png", + "resources/Z.png" + }; + + for (int i = 0; i < 26; i++) { + charset[i] = LoadImage(filenames[i]); + } +} + +int main(void) { + InitWindow(WIDTH, HEIGHT, "Computer :3"); + SetTargetFPS(60); + + load_charset(); + + int i = 0; + + while (!WindowShouldClose()) { + BeginDrawing(); + ClearBackground(BLUE); + + draw_frame(); + //red_line(video_memory); + write_image(&video_memory, charset[i++ % 26], 0, 0); + //tc_putchar(video_memory, &checkers, 1, 2); + + EndDrawing(); + } + + return 0; +} \ No newline at end of file diff --git a/resources/A.png b/resources/A.png new file mode 100644 index 0000000..309c0b3 Binary files /dev/null and b/resources/A.png differ diff --git a/resources/B.png b/resources/B.png new file mode 100644 index 0000000..ed64cbb Binary files /dev/null and b/resources/B.png differ diff --git a/resources/C.png b/resources/C.png new file mode 100644 index 0000000..bff5597 Binary files /dev/null and b/resources/C.png differ diff --git a/resources/D.png b/resources/D.png new file mode 100644 index 0000000..b48fbe3 Binary files /dev/null and b/resources/D.png differ diff --git a/resources/E.png b/resources/E.png new file mode 100644 index 0000000..bcd9abb Binary files /dev/null and b/resources/E.png differ diff --git a/resources/F.png b/resources/F.png new file mode 100644 index 0000000..ae8156e Binary files /dev/null and b/resources/F.png differ diff --git a/resources/G.png b/resources/G.png new file mode 100644 index 0000000..b893366 Binary files /dev/null and b/resources/G.png differ diff --git a/resources/H.png b/resources/H.png new file mode 100644 index 0000000..b4ea07b Binary files /dev/null and b/resources/H.png differ diff --git a/resources/I.png b/resources/I.png new file mode 100644 index 0000000..69bfdf2 Binary files /dev/null and b/resources/I.png differ diff --git a/resources/J.png b/resources/J.png new file mode 100644 index 0000000..1f6e5b6 Binary files /dev/null and b/resources/J.png differ diff --git a/resources/K.png b/resources/K.png new file mode 100644 index 0000000..2a0e851 Binary files /dev/null and b/resources/K.png differ diff --git a/resources/L.png b/resources/L.png new file mode 100644 index 0000000..87c92f5 Binary files /dev/null and b/resources/L.png differ diff --git a/resources/M.png b/resources/M.png new file mode 100644 index 0000000..534882b Binary files /dev/null and b/resources/M.png differ diff --git a/resources/N.png b/resources/N.png new file mode 100644 index 0000000..4415aab Binary files /dev/null and b/resources/N.png differ diff --git a/resources/O.png b/resources/O.png new file mode 100644 index 0000000..5365f2a Binary files /dev/null and b/resources/O.png differ diff --git a/resources/P.png b/resources/P.png new file mode 100644 index 0000000..b0ed9e6 Binary files /dev/null and b/resources/P.png differ diff --git a/resources/Q.png b/resources/Q.png new file mode 100644 index 0000000..491a670 Binary files /dev/null and b/resources/Q.png differ diff --git a/resources/R.png b/resources/R.png new file mode 100644 index 0000000..4e19d8c Binary files /dev/null and b/resources/R.png differ diff --git a/resources/S.png b/resources/S.png new file mode 100644 index 0000000..be585b6 Binary files /dev/null and b/resources/S.png differ diff --git a/resources/T.png b/resources/T.png new file mode 100644 index 0000000..24fc33c Binary files /dev/null and b/resources/T.png differ diff --git a/resources/U.png b/resources/U.png new file mode 100644 index 0000000..c14db54 Binary files /dev/null and b/resources/U.png differ diff --git a/resources/V.png b/resources/V.png new file mode 100644 index 0000000..74ea95a Binary files /dev/null and b/resources/V.png differ diff --git a/resources/W.png b/resources/W.png new file mode 100644 index 0000000..920d771 Binary files /dev/null and b/resources/W.png differ diff --git a/resources/X.png b/resources/X.png new file mode 100644 index 0000000..15c1362 Binary files /dev/null and b/resources/X.png differ diff --git a/resources/Y.png b/resources/Y.png new file mode 100644 index 0000000..4fe5a14 Binary files /dev/null and b/resources/Y.png differ diff --git a/resources/Z.png b/resources/Z.png new file mode 100644 index 0000000..5e195ca Binary files /dev/null and b/resources/Z.png differ