commit 2200eaf
0uppy
·
2026-07-21 17:32:56 +0000 UTC
parent 83d4eb4
cotton v0.2 - added scaling options as arguments, thank you chld for the idea :D
1 files changed,
+22,
-5
+22,
-5
1@@ -1,28 +1,45 @@
2 #include <stdio.h>
3+#include <stdlib.h>
4+#include <string.h>
5 #include "cotton.h"
6 #include "cottonwindow.h"
7 #include "interpreter.h"
8
9 int main(int argc, char **argv)
10 {
11- if (argc != 2)
12+ //thank you chld for the idea of changing the scale and having it be optional ^^
13+ int scale = 4;
14+ char *filename = NULL;
15+
16+ if (argc == 4 && strcmp(argv[1], "-s") == 0)
17+ {
18+ scale = atoi(argv[2]);
19+ filename = argv[3];
20+ }
21+ else if (argc == 2)
22 {
23- fprintf(stderr, "usage: cotton <file.cot>\n");
24+ filename = argv[1];
25+ }
26+ else
27+ {
28+ fprintf(stderr, "usage: cotton <-s scale (scale being 2 or 4)> <file.cot>\n");
29 return 1;
30 }
31
32 CottonWindow cw;
33
34- if (!cottonwindow_init(&cw, "cotton", VIDEO_WIDTH * 4, VIDEO_HEIGHT * 4, VIDEO_WIDTH, VIDEO_HEIGHT))
35+ if (!cottonwindow_init(&cw, "cotton", VIDEO_WIDTH * scale, VIDEO_HEIGHT * scale, VIDEO_WIDTH, VIDEO_HEIGHT))
36+ {
37 return 1;
38+ }
39
40 Cotton cotton;
41 cotton_init(&cotton);
42
43- FILE *file = fopen(argv[1], "r");
44+ FILE *file = fopen(filename, "r");
45 if (!file)
46 {
47- fprintf(stderr, "cotton couldn't open \"%s\" :(\n", argv[1]);
48+ fprintf(stderr, "cotton couldn't open \"%s\" :(\n", filename);
49 return 1;
50 }
51