commit 141a733
0uppy
·
2026-07-22 23:57:33 +0000 UTC
parent 9b95d77
sidequest commit part 2 : electric boogalo - i just saw that clang-format fucked some of my stuff up so i had to fix it rq
5 files changed,
+17,
-35
+2,
-4
1@@ -25,7 +25,7 @@ void cotton_store_var
2 }
3 }
4
5- if (cotton->var_count < VARS) {
6+ if (cotton->var_count < VARS) {
7 strncpy(cotton->vars[cotton->var_count].name, name, VAR_NAME_LEN - 1);
8 cotton->vars[cotton->var_count].name[VAR_NAME_LEN - 1] = '\0';
9
10@@ -34,8 +34,6 @@ void cotton_store_var
11
12 cotton->var_count++;
13 } else {
14- fprintf(stderr,
15- "cotton ran out of variable slots :( - max ammount is %d\n",
16- VARS);
17+ fprintf(stderr, "cotton ran out of variable slots :( - max ammount is %d\n", VARS);
18 }
19 }
+2,
-6
1@@ -7,13 +7,9 @@
2 #define VIDEO_WIDTH 250
3 #define VIDEO_HEIGHT 200
4
5-#define COTTOLETTE_SIZE \
6- 7 // would be 6 but due to high demand we invited green into the mix because
7- // green is cool <3
8+#define COTTOLETTE_SIZE 7 // would be 6 but due to high demand we invited green into the mix because green is cool <3
9
10-#define VARS \
11- 32 // i think this is enough,, not like cot programs can be that complex rn
12- // anyway :P
13+#define VARS 32 // i think this is enough,, not like cot programs can be that complex rn anyway :P
14 #define VAR_NAME_LEN 16
15 #define VAR_VAL_LEN 32
16
+6,
-10
1@@ -10,27 +10,23 @@ cottonwindow_init (CottonWindow *cw, const char *title, int window_w, int window
2 return 0;
3 }
4
5- cw->window =
6- SDL_CreateWindow(title, 0, 0, window_w, window_h, SDL_WINDOW_SHOWN);
7+ cw->window = SDL_CreateWindow(title, 0, 0, window_w, window_h, SDL_WINDOW_SHOWN);
8+
9 if (!cw->window) {
10- fprintf(stderr, "cotton couldn't create a window :( : %s\n",
11- SDL_GetError());
12+ fprintf(stderr, "cotton couldn't create a window :( : %s\n", SDL_GetError());
13 return 0;
14 }
15
16 cw->renderer = SDL_CreateRenderer(cw->window, -1, 0);
17 if (!cw->renderer) {
18- fprintf(stderr, "cotton couldn't render this :( : %s\n",
19- SDL_GetError());
20+ fprintf(stderr, "cotton couldn't render this :( : %s\n", SDL_GetError());
21 return 0;
22 }
23
24 cw->texture =
25- SDL_CreateTexture(cw->renderer, SDL_PIXELFORMAT_ARGB8888,
26- SDL_TEXTUREACCESS_STREAMING, texture_w, texture_h);
27+ SDL_CreateTexture(cw->renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, texture_w, texture_h);
28 if (!cw->texture) {
29- fprintf(stderr, "cotton couldn't apply textures :( : %s\n",
30- SDL_GetError());
31+ fprintf(stderr, "cotton couldn't apply textures :( : %s\n", SDL_GetError());
32 return 0;
33 }
34
+3,
-6
1@@ -42,8 +42,7 @@ static char
2 char *end = strrchr(s, '"');
3
4 if (end == NULL) {
5- fprintf(stderr, "cot syntax error : looks like you forgot a quote "
6- "at the end xP\n");
7+ fprintf(stderr, "cot syntax error : looks like you forgot a quote at the end xP\n");
8 return s;
9 }
10
11@@ -124,8 +123,7 @@ static void cmd_print
12 cotton->cursor_x = 0;
13 cotton->cursor_y += FONT_HEIGHT + 4;
14
15- cottonwindow_update(cw, cotton->video,
16- sizeof(cotton->video[0]) * VIDEO_WIDTH);
17+ cottonwindow_update(cw, cotton->video, sizeof(cotton->video[0]) * VIDEO_WIDTH);
18 }
19
20 static void cmd_var
21@@ -136,8 +134,7 @@ static void cmd_var
22
23 char *space = strchr(arg, ' ');
24 if (!space) {
25- fprintf(stderr, "cot syntax error: you forgor to put a value for your "
26- "variable xP\n");
27+ fprintf(stderr, "cot syntax error: you forgor to put a value for your variable xP\n");
28 return;
29 }
30
+4,
-9
1@@ -9,13 +9,10 @@ int main
2 (int argc, char **argv)
3 {
4
5- // added this specifically with the new user input command in mind, makes it
6- // so the terminal isnt so cluttered for when there is user input needed,
7- // atleast for me :P
8+ // added this specifically with the new user input command in mind, makes it so the terminal isnt so cluttered for when there is user input needed, atleast for me :P
9 printf("\033[2J\033[H");
10
11- // thank you chld for the idea of changing the scale and having it be
12- // optional ^^
13+ // thank you chld for the idea of changing the scale and having it be optional ^^
14 int scale = 4;
15 char *filename = NULL;
16
17@@ -25,15 +22,13 @@ int main
18 } else if (argc == 2) {
19 filename = argv[1];
20 } else {
21- fprintf(stderr,
22- "usage: cotton <-s scale (scale being 2 or 4)> <file.cot>\n");
23+ fprintf(stderr, "usage: cotton <-s scale (scale being 2 or 4)> <file.cot>\n");
24 return 1;
25 }
26
27 CottonWindow cw;
28
29- if (!cottonwindow_init(&cw, "cotton", VIDEO_WIDTH * scale,
30- VIDEO_HEIGHT * scale, VIDEO_WIDTH, VIDEO_HEIGHT)) {
31+ if (!cottonwindow_init(&cw, "cotton", VIDEO_WIDTH * scale, VIDEO_HEIGHT * scale, VIDEO_WIDTH, VIDEO_HEIGHT)) {
32 return 1;
33 }
34