commit 652a9cd

chld  ·  2026-07-21 20:20:26 +0000 UTC
parent 7890268
i forgot to push
7 files changed,  +894, -411
+6, -1
 1@@ -1,5 +1,10 @@
 2 SRC=cotton
 3 LIB=`pkg-config --libs sdl2` -lbe
 4+SRCS=src/cotton.c src/interpreter.c src/cottonwindow.cpp src/main.c
 5+CFLAG=-g -Wall -Wextra
 6 
 7 ${SRC}:
 8-	cc src/*.c ${LIB} -o ${SRC}
 9+	cc ${SRCS} ${CFLAG} ${LIB} -o ${SRC}
10+
11+clean:
12+	rm ${SRC}
+0, -81
 1@@ -1,81 +0,0 @@
 2-#include "cottonwindow.h"
 3-#include <stdio.h>
 4-
 5-int cottonwindow_init(CottonWindow *cw, const char *title, int window_w, int window_h, int texture_w, int texture_h)
 6-{
 7-    SDL_Init(SDL_INIT_VIDEO);
 8-
 9-    if (SDL_Init(SDL_INIT_VIDEO) != 0)
10-    {
11-        fprintf(stderr, "cotton couldn't start SDL :( : %s\n", SDL_GetError());
12-        return 0;
13-    }
14-
15-    cw->window = SDL_CreateWindow(title, 0, 0, window_w, window_h, SDL_WINDOW_SHOWN);
16-    if (!cw->window)
17-    {
18-        fprintf(stderr, "cotton couldn't create a window :( : %s\n", SDL_GetError());
19-        return 0;
20-    }
21-
22-    cw->renderer = SDL_CreateRenderer(cw->window, -1, 0);
23-    if (!cw->renderer)
24-    {
25-        fprintf(stderr, "cotton couldn't render this :( : %s\n", SDL_GetError());
26-        return 0;
27-    }
28-
29-    cw->texture = SDL_CreateTexture(cw->renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_STREAMING, texture_w, texture_h);
30-    if (!cw->texture)
31-    {
32-        fprintf(stderr, "cotton couldn't apply textures :( : %s\n", SDL_GetError());
33-        return 0;
34-    }
35-
36-    return 1;
37-}
38-
39-void cottonwindow_update(CottonWindow *cw, const void *buffer, int pitch)
40-{
41-    SDL_UpdateTexture(cw->texture, NULL, buffer, pitch);
42-    SDL_RenderClear(cw->renderer);
43-    SDL_RenderCopy(cw->renderer, cw->texture, NULL, NULL);
44-    SDL_RenderPresent(cw->renderer);
45-}
46-
47-int cottonwindow_process_input(CottonWindow *cw, uint8_t *keys)
48-{
49-    (void)cw;
50-    (void)keys;
51-    int quit = 0;
52-    SDL_Event event;
53-
54-    while (SDL_PollEvent(&event))
55-    {
56-        switch (event.type)
57-        {
58-            case SDL_QUIT:
59-            {
60-                quit = 1;
61-                break;
62-            }
63-
64-            case SDL_KEYDOWN:
65-            {
66-                if (event.key.keysym.sym == SDLK_ESCAPE)
67-                    quit = 1;
68-                break;
69-            }
70-        }
71-    }
72-
73-    return quit;
74-}
75-
76-void cottonwindow_destroy(CottonWindow *cw)
77-{
78-    SDL_DestroyTexture(cw->texture);
79-    SDL_DestroyRenderer(cw->renderer);
80-    SDL_DestroyWindow(cw->window);
81-    SDL_Quit();
82-}
+106, -0
  1@@ -0,0 +1,106 @@
  2+#include <Application.h>
  3+#include <Window.h>
  4+#include <View.h>
  5+#include <Bitmap.h>
  6+
  7+#include "cottonwindow.h"
  8+
  9+// hello
 10+
 11+class View:public BView
 12+{
 13+public:View(BRect f, BBitmap *bmp):
 14+  BView(f, "cottonview", B_FOLLOW_ALL, B_WILL_DRAW), bmp(bmp){}
 15+
 16+  void Draw(BRect r){
 17+    DrawBitmap(bmp, Bounds());
 18+  }
 19+  BBitmap *bmp;
 20+
 21+};
 22+
 23+class Win:public BWindow
 24+{
 25+public:Win(BRect f, const char *title, int texture_w, int texture_h):
 26+  BWindow(f, title, B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE|B_WILL_DRAW){
 27+  bmp = new BBitmap(BRect(0, 0, texture_w - 1, texture_h - 1), B_RGB32);
 28+  view = new View(Bounds(), bmp);
 29+  AddChild(view);
 30+}
 31+
 32+  BBitmap *bmp;
 33+  View *view;
 34+};
 35+
 36+class App:public BApplication
 37+{
 38+public:App(BRect r, const char *title, int texture_w, int texture_h):BApplication("application/x-vnd.example.blank")
 39+  {
 40+    w = new Win(r, title, texture_w, texture_h);
 41+    w->Show();
 42+  }
 43+
 44+  Win *w;
 45+};
 46+
 47+static App *_app=nullptr;
 48+static sem_id g_ready_sem = -1;
 49+
 50+int cottonwindow_init(CottonWindow *cw, const char *title, int window_w, int window_h, int texture_w, int texture_h)
 51+{
 52+  (void)cw;
 53+  g_ready_sem = create_sem(0, "r");
 54+
 55+  struct InitData { const char *title; int ww, wh, tw, th; };
 56+  struct InitData d{title, window_w, window_h,texture_w, texture_h};
 57+
 58+  thread_id id=spawn_thread([](void *data) -> status_t{
 59+    InitData *d = (InitData*)data;
 60+    _app=new App(BRect(100, 100, 100 + d->ww, 100 + d->wh), d->title, d->tw, d->th);
 61+    release_sem(g_ready_sem);
 62+    _app->Run();
 63+    return 0;
 64+  }, "cotton", B_NORMAL_PRIORITY, &d);
 65+  resume_thread(id);
 66+  acquire_sem(g_ready_sem);
 67+  
 68+  return 0;
 69+}
 70+
 71+void cottonwindow_update(CottonWindow *cw, const void *buffer, int pitch)
 72+{
 73+  (void)cw;
 74+
 75+  if(!_app) return;
 76+
 77+  if(_app->w->Lock()){
 78+    uint8 *d=(uint8*)_app->w->bmp->Bits();
 79+    int32 dP=_app->w->bmp->BytesPerRow();
 80+    int32 r=_app->w->bmp->Bounds().IntegerHeight()+1;
 81+
 82+    const uint8 *src=(const uint8*)buffer;
 83+
 84+    for(int32 y=0; y<r; y++){
 85+      memcpy(d+y*dP, src+y*pitch, std::min(dP, pitch));
 86+    }
 87+      _app->w->view->Invalidate();
 88+  _app->w->Unlock();
 89+  }
 90+}
 91+
 92+int cottonwindow_process_input(CottonWindow *cw, uint8_t *k)
 93+{
 94+  (void)cw;
 95+  (void)k;
 96+
 97+  // stub toe
 98+  return 0;
 99+}
100+
101+void cottonwindow_destroy(CottonWindow *cw)
102+{
103+  App *a=(App *)cw->app;
104+  if (_app){
105+    BMessenger(_app).SendMessage(B_QUIT_REQUESTED);
106+  } 
107+}
+11, -4
 1@@ -6,15 +6,22 @@
 2 
 3 typedef struct
 4 {
 5-    SDL_Window   *window;
 6-    SDL_Renderer *renderer;
 7-    SDL_Texture  *texture;
 8-
 9+  void *app;
10+  void *window;
11+  void *bitmap;
12 } CottonWindow;
13 
14+#ifdef __cplusplus
15+extern "C" {
16+#endif
17+
18 int  cottonwindow_init(CottonWindow *cw, const char *title, int window_w, int window_h, int texture_w, int texture_h);
19 void cottonwindow_update(CottonWindow *cw, const void *buffer, int pitch);
20 int  cottonwindow_process_input(CottonWindow *cw, uint8_t *keys);
21 void cottonwindow_destroy(CottonWindow *cw);
22 
23+#ifdef __cplusplus
24+}
25+#endif
26+  
27 #endif
+752, -308
   1@@ -1,316 +1,760 @@
   2-// I might refactor some of these letters and characters at some point but but for now this should be a-okay :D
   3-// Atleast i think these are readable for now so that's good enough x3
   4-
   5 #ifndef EIKI_H
   6 #define EIKI_H
   7 
   8 #include <stdint.h>
   9 
  10-static const uint8_t EIKI_FONT[256][5] = {
  11-
  12-    [' '] = {
  13-        0b00000000,
  14-        0b00000000,
  15-        0b00000000,
  16-        0b00000000,
  17-        0b00000000,
  18-    },
  19-
  20-    ['A'] = {
  21-        0b00001110,
  22-        0b00010001,
  23-        0b00011111,
  24-        0b00010001,
  25-        0b00010001,
  26-    },
  27-
  28-    ['B'] = {
  29-        0b00001111,
  30-        0b00010001,
  31-        0b00001111,
  32-        0b00010001,
  33-        0b00001111,
  34-    },
  35-
  36-    ['C'] = {
  37-        0b00011111,
  38-        0b00000001,
  39-        0b00000001,
  40-        0b00000001,
  41-        0b00011111,
  42-    },
  43-
  44-    ['D'] = {
  45-        0b00001111,
  46-        0b00010001,
  47-        0b00010001,
  48-        0b00010001,
  49-        0b00001111,
  50-    },
  51-
  52-    ['E'] = {
  53-        0b00011111,
  54-        0b00000001,
  55-        0b00011111,
  56-        0b00000001,
  57-        0b00011111,
  58-    },
  59-
  60-    ['F'] = {
  61-        0b00011111,
  62-        0b00000001,
  63-        0b00011111,
  64-        0b00000001,
  65-        0b00000001,
  66-    },
  67-
  68-    ['G'] = {
  69-        0b00011111,
  70-        0b00000001,
  71-        0b00011001,
  72-        0b00010001,
  73-        0b00011111,
  74-    },
  75-
  76-    ['H'] = {
  77-        0b00010001,
  78-        0b00010001,
  79-        0b00011111,
  80-        0b00010001,
  81-        0b00010001,
  82-    },
  83-
  84-    ['I'] = {
  85-        0b00011111,
  86-        0b00000100,
  87-        0b00000100,
  88-        0b00000100,
  89-        0b00011111,
  90-    },
  91-
  92-    ['J'] = {
  93-        0b00011100,
  94-        0b00010000,
  95-        0b00010000,
  96-        0b00010011,
  97-        0b00011110,
  98-    },
  99-
 100-    ['K'] = {
 101-        0b00010001,
 102-        0b00011001,
 103-        0b00000111,
 104-        0b00010001,
 105-        0b00010001,
 106-    },
 107-
 108-    ['L'] = {
 109-        0b00000001,
 110-        0b00000001,
 111-        0b00000001,
 112-        0b00010001,
 113-        0b00011111,
 114-    },
 115-
 116-    ['M'] = {
 117-        0b00011011,
 118-        0b00011111,
 119-        0b00010101,
 120-        0b00010001,
 121-        0b00010001,
 122-    },
 123-
 124-    ['N'] = {
 125-        0b00010001,
 126-        0b00010011,
 127-        0b00010101,
 128-        0b00011001,
 129-        0b00010001,
 130-    },
 131-
 132-    ['O'] = {
 133-        0b00011111,
 134-        0b00010001,
 135-        0b00010001,
 136-        0b00010001,
 137-        0b00011111,
 138-    },
 139-
 140-    ['P'] = {
 141-        0b00011111,
 142-        0b00010001,
 143-        0b00011111,
 144-        0b00000001,
 145-        0b00000001,
 146-    },
 147-
 148-    ['Q'] = {
 149-        0b00011111,
 150-        0b00010001,
 151-        0b00010001,
 152-        0b00011001,
 153-        0b00011111,
 154-    },
 155-
 156-    ['R'] = {
 157-        0b00011111,
 158-        0b00010001,
 159-        0b00011111,
 160-        0b00001001,
 161-        0b00010001,
 162-    },
 163-
 164-    ['S'] = {
 165-        0b00011111,
 166-        0b00000001,
 167-        0b00011111,
 168-        0b00010000,
 169-        0b00011111,
 170-    },
 171-
 172-    ['T'] = {
 173-        0b00011111,
 174-        0b00000100,
 175-        0b00000100,
 176-        0b00000100,
 177-        0b00000100,
 178-    },
 179-
 180-    ['U'] = {
 181-        0b00010001,
 182-        0b00010001,
 183-        0b00010001,
 184-        0b00010001,
 185-        0b00011111,
 186-    },
 187-
 188-    ['V'] = {
 189-        0b00010001,
 190-        0b00010001,
 191-        0b00011011,
 192-        0b00001010,
 193-        0b00000100,
 194-    },
 195-
 196-    ['W'] = {
 197-        0b00010001,
 198-        0b00010001,
 199-        0b00010101,
 200-        0b00011011,
 201-        0b00010001,
 202-    },
 203-
 204-    ['X'] = {
 205-        0b00010001,
 206-        0b00001010,
 207-        0b00000100,
 208-        0b00001010,
 209-        0b00010001,
 210-    },
 211-
 212-    ['Y'] = {
 213-        0b00010001,
 214-        0b00010001,
 215-        0b00001010,
 216-        0b00000100,
 217-        0b00000100,
 218-    },
 219-
 220-    ['Z'] = {
 221-        0b00011111,
 222-        0b00010001,
 223-        0b00000100,
 224-        0b00010010,
 225-        0b00011111,
 226-    },
 227-
 228-    ['0'] = {
 229-        0b00001110,
 230-        0b00010001,
 231-        0b00010001,
 232-        0b00010001,
 233-        0b00001110,
 234-    },
 235-
 236-    ['1'] = {
 237-        0b00000100,
 238-        0b00001100,
 239-        0b00000100,
 240-        0b00000100,
 241-        0b00001110,
 242-    },
 243-
 244-    ['2'] = {
 245-        0b00001110,
 246-        0b00010001,
 247-        0b00000010,
 248-        0b00000100,
 249-        0b00011111,
 250-    },
 251-
 252-    ['3'] = {
 253-        0b00011111,
 254-        0b00010001,
 255-        0b00011100,
 256-        0b00010001,
 257-        0b00011111,
 258-    },
 259-
 260-    ['4'] = {
 261-        0b00010010,
 262-        0b00010010,
 263-        0b00011111,
 264-        0b00000010,
 265-        0b00000010,
 266-    },
 267-
 268-    ['5'] = {
 269-        0b00011111,
 270-        0b00010000,
 271-        0b00011110,
 272-        0b00000001,
 273-        0b00011110,
 274-    },
 275-
 276-    ['6'] = {
 277-        0b00001110,
 278-        0b00010000,
 279-        0b00011110,
 280-        0b00010001,
 281-        0b00001110,
 282-    },
 283-
 284-    ['7'] = {
 285-        0b00011111,
 286-        0b00000001,
 287-        0b00000010,
 288-        0b00000100,
 289-        0b00000100,
 290-    },
 291-
 292-    ['8'] = {
 293-        0b00001110,
 294-        0b00010001,
 295-        0b00001110,
 296-        0b00010001,
 297-        0b00001110,
 298-    },
 299-
 300-    ['9'] = {
 301-        0b00001110,
 302-        0b00010001,
 303-        0b00001111,
 304-        0b00000001,
 305-        0b00001110,
 306-    },
 307-
 308-    [':'] = {
 309-        0b00000000,
 310-        0b00000100,
 311-        0b00000000,
 312-        0b00000100,
 313-        0b00000000,
 314-    },
 315+#define FONT_WIDTH  6
 316+#define FONT_HEIGHT 8
 317+
 318+static const uint8_t EIKI_FONT[256][FONT_HEIGHT] = {
 319+
 320+[' '] = {
 321+    0b00000000,
 322+    0b00000000,
 323+    0b00000000,
 324+    0b00000000,
 325+    0b00000000,
 326+    0b00000000,
 327+    0b00000000,
 328+    0b00000000,
 329+},
 330+
 331+['A'] = {
 332+    0b00000000,
 333+    0b00011110,
 334+    0b00100001,
 335+    0b00100001,
 336+    0b00111111,
 337+    0b00100001,
 338+    0b00110011,
 339+    0b00000000,
 340+},
 341+
 342+['B'] = {
 343+    0b00000000,
 344+    0b00011110,
 345+    0b00100010,
 346+    0b00011110,
 347+    0b00100010,
 348+    0b00100010,
 349+    0b00011110,
 350+    0b00000000,
 351+},
 352+
 353+['C'] = {
 354+    0b00000000,
 355+    0b00011110,
 356+    0b00100001,
 357+    0b00000001,
 358+    0b00000001,
 359+    0b00100001,
 360+    0b00011110,
 361+    0b00000000,
 362+},
 363+
 364+['D'] = {
 365+    0b00000000,
 366+    0b00011110,
 367+    0b00100010,
 368+    0b00100010,
 369+    0b00100010,
 370+    0b00010010,
 371+    0b00001110,
 372+    0b00000000,
 373+},
 374+
 375+['E'] = {
 376+    0b00000000,
 377+    0b00011111,
 378+    0b00000001,
 379+    0b00000111,
 380+    0b00000001,
 381+    0b00000001,
 382+    0b00011111,
 383+    0b00000000,
 384+},
 385+
 386+['F'] = {
 387+    0b00000000,
 388+    0b00011111,
 389+    0b00000001,
 390+    0b00000111,
 391+    0b00000001,
 392+    0b00000001,
 393+    0b00000001,
 394+    0b00000000,
 395+},
 396+
 397+['G'] = {
 398+    0b00000000,
 399+    0b00011110,
 400+    0b00010001,
 401+    0b00000001,
 402+    0b00011001,
 403+    0b00010001,
 404+    0b00001110,
 405+    0b00000000,
 406+},
 407+
 408+['H'] = {
 409+    0b00000000,
 410+    0b00010010,
 411+    0b00010010,
 412+    0b00011110,
 413+    0b00010010,
 414+    0b00010010,
 415+    0b00010010,
 416+    0b00000000,
 417+},
 418+
 419+['I'] = {
 420+    0b00000000,
 421+    0b00001110,
 422+    0b00000100,
 423+    0b00000100,
 424+    0b00000100,
 425+    0b00000100,
 426+    0b00001110,
 427+    0b00000000,
 428+},
 429+
 430+['J'] = {
 431+    0b00000000,
 432+    0b00011100,
 433+    0b00001000,
 434+    0b00001000,
 435+    0b00001000,
 436+    0b00001001,
 437+    0b00000111,
 438+    0b00000000,
 439+},
 440+
 441+['K'] = {
 442+    0b00000000,
 443+    0b00010010,
 444+    0b00010010,
 445+    0b00001010,
 446+    0b00000110,
 447+    0b00001010,
 448+    0b00010010,
 449+    0b00000000,
 450+},
 451+
 452+['L'] = {
 453+    0b00000000,
 454+    0b00000100,
 455+    0b00000100,
 456+    0b00000100,
 457+    0b00000100,
 458+    0b00100100,
 459+    0b00111100,
 460+    0b00000000,
 461+},
 462+
 463+['M'] = {
 464+    0b00000000,
 465+    0b00100001,
 466+    0b00110011,
 467+    0b00101101,
 468+    0b00100001,
 469+    0b00100001,
 470+    0b00100001,
 471+    0b00000000,
 472+},
 473+
 474+['N'] = {
 475+    0b00000000,
 476+    0b00010010,
 477+    0b00010110,
 478+    0b00011010,
 479+    0b00010010,
 480+    0b00010010,
 481+    0b00010010,
 482+    0b00000000,
 483+},
 484+
 485+['O'] = {
 486+    0b00000000,
 487+    0b00011110,
 488+    0b00100001,
 489+    0b00100001,
 490+    0b00100001,
 491+    0b00100001,
 492+    0b00011110,
 493+    0b00000000,
 494+},
 495+
 496+['P'] = {
 497+    0b00000000,
 498+    0b00011111,
 499+    0b00100001,
 500+    0b00100001,
 501+    0b00011111,
 502+    0b00000001,
 503+    0b00000001,
 504+    0b00000000,
 505+},
 506+
 507+['Q'] = {
 508+    0b00000000,
 509+    0b00011110,
 510+    0b00100001,
 511+    0b00100001,
 512+    0b00101001,
 513+    0b00110001,
 514+    0b00011110,
 515+    0b00000000,
 516+},
 517+
 518+['R'] = {
 519+    0b00000000,
 520+    0b00011110,
 521+    0b00100010,
 522+    0b00100010,
 523+    0b00011110,
 524+    0b00100010,
 525+    0b00100010,
 526+    0b00000000,
 527+},
 528+
 529+['S'] = {
 530+    0b00000000,
 531+    0b00001110,
 532+    0b00010001,
 533+    0b00000110,
 534+    0b00001000,
 535+    0b00010001,
 536+    0b00001110,
 537+    0b00000000,
 538+},
 539+
 540+['T'] = {
 541+    0b00000000,
 542+    0b00111111,
 543+    0b00000100,
 544+    0b00000100,
 545+    0b00000100,
 546+    0b00000100,
 547+    0b00001110,
 548+    0b00000000,
 549+},
 550+
 551+['U'] = {
 552+    0b00000000,
 553+    0b00100001,
 554+    0b00100001,
 555+    0b00100001,
 556+    0b00100001,
 557+    0b00100001,
 558+    0b00011110,
 559+    0b00000000,
 560+},
 561+
 562+['V'] = {
 563+    0b00000000,
 564+    0b00100001,
 565+    0b00100001,
 566+    0b00010010,
 567+    0b00010010,
 568+    0b00001100,
 569+    0b00000100,
 570+    0b00000000,
 571+},
 572+
 573+['W'] = {
 574+    0b00000000,
 575+    0b00100001,
 576+    0b00100001,
 577+    0b00100001,
 578+    0b00101101,
 579+    0b00110011,
 580+    0b00100001,
 581+    0b00000000,
 582+},
 583+
 584+['X'] = {
 585+    0b00000000,
 586+    0b00100001,
 587+    0b00100001,
 588+    0b00010010,
 589+    0b00001100,
 590+    0b00010010,
 591+    0b00100001,
 592+    0b00000000,
 593+},
 594+
 595+['Y'] = {
 596+    0b00000000,
 597+    0b00100001,
 598+    0b00100001,
 599+    0b00010010,
 600+    0b00001100,
 601+    0b00001100,
 602+    0b00001100,
 603+    0b00000000,
 604+},
 605+
 606+['Z'] = {
 607+    0b00000000,
 608+    0b00111111,
 609+    0b00010000,
 610+    0b00001000,
 611+    0b00000100,
 612+    0b00000010,
 613+    0b00111111,
 614+    0b00000000,
 615+},
 616+
 617+['a'] = {
 618+    0b00000000,
 619+    0b00000000,
 620+    0b00001110,
 621+    0b00010000,
 622+    0b00011110,
 623+    0b00010010,
 624+    0b00011110,
 625+    0b00000000,
 626+},
 627+
 628+['b'] = {
 629+    0b00000000,
 630+    0b00000010,
 631+    0b00000010,
 632+    0b00011110,
 633+    0b00010010,
 634+    0b00010010,
 635+    0b00011110,
 636+    0b00000000,
 637+},
 638+
 639+['c'] = {
 640+    0b00000000,
 641+    0b00000000,
 642+    0b00011110,
 643+    0b00000001,
 644+    0b00000001,
 645+    0b00000001,
 646+    0b00011110,
 647+    0b00000000,
 648+},
 649+
 650+['d'] = {
 651+    0b00000000,
 652+    0b00010000,
 653+    0b00010000,
 654+    0b00011110,
 655+    0b00010010,
 656+    0b00010010,
 657+    0b00011110,
 658+    0b00000000,
 659+},
 660+
 661+['e'] = {
 662+    0b00000000,
 663+    0b00000000,
 664+    0b00011110,
 665+    0b00010001,
 666+    0b00111111,
 667+    0b00000001,
 668+    0b00011110,
 669+    0b00000000,
 670+},
 671+
 672+['f'] = {
 673+    0b00011000,
 674+    0b00000100,
 675+    0b00111110,
 676+    0b00000100,
 677+    0b00000100,
 678+    0b00000100,
 679+    0b00000100,
 680+    0b00000000,
 681+},
 682+
 683+['g'] = {
 684+    0b00000000,
 685+    0b00000000,
 686+    0b00011110,
 687+    0b00010010,
 688+    0b00011110,
 689+    0b00010000,
 690+    0b00010000,
 691+    0b00001110,
 692+},
 693+
 694+['h'] = {
 695+    0b00000000,
 696+    0b00000010,
 697+    0b00000010,
 698+    0b00011110,
 699+    0b00010010,
 700+    0b00010010,
 701+    0b00010010,
 702+    0b00000000,
 703+},
 704+
 705+['i'] = {
 706+    0b00000000,
 707+    0b00000100,
 708+    0b00000000,
 709+    0b00000100,
 710+    0b00000100,
 711+    0b00000100,
 712+    0b00001100,
 713+    0b00000000,
 714+},
 715+
 716+['j'] = {
 717+    0b00001000,
 718+    0b00000000,
 719+    0b00001000,
 720+    0b00001000,
 721+    0b00001000,
 722+    0b00001000,
 723+    0b00001000,
 724+    0b00001110,
 725+},
 726+
 727+['k'] = {
 728+    0b00000001,
 729+    0b00000001,
 730+    0b00001001,
 731+    0b00000101,
 732+    0b00000011,
 733+    0b00000101,
 734+    0b00001001,
 735+    0b00000000,
 736+},
 737+
 738+['l'] = {
 739+    0b00000000,
 740+    0b00000100,
 741+    0b00000100,
 742+    0b00000100,
 743+    0b00000100,
 744+    0b00000100,
 745+    0b00000100,
 746+    0b00000000,
 747+},
 748+
 749+['m'] = {
 750+    0b00000000,
 751+    0b00000000,
 752+    0b00110110,
 753+    0b00101010,
 754+    0b00101010,
 755+    0b00101010,
 756+    0b00101010,
 757+    0b00000000,
 758+},
 759+
 760+['n'] = {
 761+    0b00000000,
 762+    0b00000000,
 763+    0b00011110,
 764+    0b00010010,
 765+    0b00010010,
 766+    0b00010010,
 767+    0b00010010,
 768+    0b00000000,
 769+},
 770+
 771+['o'] = {
 772+    0b00000000,
 773+    0b00000000,
 774+    0b00000000,
 775+    0b00001110,
 776+    0b00010001,
 777+    0b00010001,
 778+    0b00001110,
 779+    0b00000000,
 780+},
 781+
 782+['p'] = {
 783+    0b00000000,
 784+    0b00000000,
 785+    0b00011110,
 786+    0b00010010,
 787+    0b00011110,
 788+    0b00000010,
 789+    0b00000010,
 790+    0b00000010,
 791+},
 792+
 793+['q'] = {
 794+    0b00000000,
 795+    0b00000000,
 796+    0b00011110,
 797+    0b00010010,
 798+    0b00011110,
 799+    0b00010000,
 800+    0b00010000,
 801+    0b00000000,
 802+},
 803+
 804+['r'] = {
 805+    0b00000000,
 806+    0b00000000,
 807+    0b00001110,
 808+    0b00000010,
 809+    0b00000010,
 810+    0b00000010,
 811+    0b00000010,
 812+    0b00000000,
 813+},
 814+
 815+['s'] = {
 816+    0b00000000,
 817+    0b00000000,
 818+    0b00011110,
 819+    0b00000001,
 820+    0b00011110,
 821+    0b00100000,
 822+    0b00011110,
 823+    0b00000000,
 824+},
 825+
 826+['t'] = {
 827+    0b00001000,
 828+    0b00001000,
 829+    0b00111110,
 830+    0b00001000,
 831+    0b00001000,
 832+    0b00001000,
 833+    0b00010000,
 834+    0b00000000,
 835+},
 836+
 837+['u'] = {
 838+    0b00000000,
 839+    0b00000000,
 840+    0b00010001,
 841+    0b00010001,
 842+    0b00010001,
 843+    0b00010001,
 844+    0b00011110,
 845+    0b00000000,
 846+},
 847+
 848+['v'] = {
 849+    0b00000000,
 850+    0b00000000,
 851+    0b00010001,
 852+    0b00010001,
 853+    0b00001010,
 854+    0b00001010,
 855+    0b00000100,
 856+    0b00000000,
 857+},
 858+
 859+['w'] = {
 860+    0b00000000,
 861+    0b00000000,
 862+    0b00010001,
 863+    0b00010001,
 864+    0b00010101,
 865+    0b00010101,
 866+    0b00001010,
 867+    0b00000000,
 868+},
 869+
 870+['x'] = {
 871+    0b00000000,
 872+    0b00000000,
 873+    0b00010001,
 874+    0b00001010,
 875+    0b00000100,
 876+    0b00001010,
 877+    0b00010001,
 878+    0b00000000,
 879+},
 880+
 881+['y'] = {
 882+    0b00000000,
 883+    0b00000000,
 884+    0b00010001,
 885+    0b00010001,
 886+    0b00011110,
 887+    0b00100000,
 888+    0b00011110,
 889+    0b00000000,
 890+},
 891+
 892+['z'] = {
 893+    0b00000000,
 894+    0b00000000,
 895+    0b00111111,
 896+    0b00010000,
 897+    0b00001000,
 898+    0b00000100,
 899+    0b00111111,
 900+    0b00000000,
 901+},
 902+
 903+['0'] = {
 904+    0b00000000,
 905+    0b00011110,
 906+    0b00100001,
 907+    0b00100001,
 908+    0b00100001,
 909+    0b00100001,
 910+    0b00011110,
 911+    0b00000000,
 912+},
 913+
 914+['1'] = {
 915+    0b00000000,
 916+    0b00001100,
 917+    0b00001000,
 918+    0b00001000,
 919+    0b00001000,
 920+    0b00001000,
 921+    0b00111110,
 922+    0b00000000,
 923+},
 924+
 925+['2'] = {
 926+    0b00000000,
 927+    0b00011110,
 928+    0b00100000,
 929+    0b00011000,
 930+    0b00000100,
 931+    0b00000010,
 932+    0b00111110,
 933+    0b00000000,
 934+},
 935+
 936+['3'] = {
 937+    0b00000000,
 938+    0b00111111,
 939+    0b00100000,
 940+    0b00011110,
 941+    0b00100000,
 942+    0b00100000,
 943+    0b00111111,
 944+    0b00000000,
 945+},
 946+
 947+['4'] = {
 948+    0b00000000,
 949+    0b00010001,
 950+    0b00010001,
 951+    0b00111111,
 952+    0b00010000,
 953+    0b00010000,
 954+    0b00010000,
 955+    0b00000000,
 956+},
 957+
 958+['5'] = {
 959+    0b00000000,
 960+    0b00111111,
 961+    0b00000001,
 962+    0b00011111,
 963+    0b00100000,
 964+    0b00100000,
 965+    0b00011111,
 966+    0b00000000,
 967+},
 968+
 969+['6'] = {
 970+    0b00000000,
 971+    0b00011110,
 972+    0b00000001,
 973+    0b00011111,
 974+    0b00100001,
 975+    0b00100001,
 976+    0b00011110,
 977+    0b00000000,
 978+},
 979+
 980+['7'] = {
 981+    0b00000000,
 982+    0b00111111,
 983+    0b00100000,
 984+    0b00010000,
 985+    0b00001000,
 986+    0b00001000,
 987+    0b00001000,
 988+    0b00000000,
 989+},
 990+
 991+['8'] = {
 992+    0b00000000,
 993+    0b00011110,
 994+    0b00100001,
 995+    0b00011110,
 996+    0b00100001,
 997+    0b00100001,
 998+    0b00011110,
 999+    0b00000000,
1000+},
1001+
1002+['9'] = {
1003+    0b00000000,
1004+    0b00011110,
1005+    0b00100001,
1006+    0b00111110,
1007+    0b00100000,
1008+    0b00100000,
1009+    0b00011110,
1010+    0b00000000,
1011+},
1012+
1013+['?'] = {
1014+    0b00000000,
1015+    0b00011110,
1016+    0b00100001,
1017+    0b00010000,
1018+    0b00001000,
1019+    0b00000000,
1020+    0b00001000,
1021+    0b00000000,
1022+},
1023+
1024+['!'] = {
1025+    0b00000000,
1026+    0b00001100,
1027+    0b00001100,
1028+    0b00000100,
1029+    0b00000100,
1030+    0b00000000,
1031+    0b00000100,
1032+    0b00000000,
1033+},
1034+
1035+[':'] = {
1036+    0b00000000,
1037+    0b00001100,
1038+    0b00001100,
1039+    0b00000000,
1040+    0b00001100,
1041+    0b00001100,
1042+    0b00000000,
1043+    0b00000000,
1044+},
1045+
1046+[';'] = {
1047+    0b00000000,
1048+    0b00001100,
1049+    0b00001100,
1050+    0b00000000,
1051+    0b00001100,
1052+    0b00001100,
1053+    0b00001000,
1054+    0b00000000,
1055+},
1056+
1057+['.'] = {
1058+    0b00000000,
1059+    0b00000000,
1060+    0b00000000,
1061+    0b00000000,
1062+    0b00000000,
1063+    0b00001100,
1064+    0b00001100,
1065+    0b00000000,
1066+},
1067 
1068 };
1069 
+13, -14
 1@@ -9,6 +9,8 @@
 2 #include "cottonwindow.h"
 3 #include "eiki.h"
 4 
 5+#include <OS.h>
 6+
 7 // maximum length of a .cot file line
 8 #define MAX_LINE 256
 9 
10@@ -64,11 +66,11 @@ static void draw_pixel(Cotton *cotton, int x, int y, uint32_t color)
11 
12 static void draw_char(Cotton *cotton, char c, int x, int y)
13 {
14-    for (int row = 0; row < 5; row++)
15+    for (int row = 0; row < FONT_HEIGHT; row++)
16     {
17         uint8_t bits = EIKI_FONT[(uint8_t)c][row];
18 
19-    for (int col = 0; col < 5; col++)
20+    for (int col = 0; col < FONT_WIDTH; col++)
21     {
22 
23         if (bits & (1 << col)) 
24@@ -86,8 +88,8 @@ static void draw_char(Cotton *cotton, char c, int x, int y)
25 static void cmd_print(Cotton *cotton, CottonWindow *cw, char *arg)
26 {
27     (void)cw;
28-    
29-    if (!arg) 
30+
31+    if (!arg)
32         return;
33 
34     char *text = strip_quotes(arg);
35@@ -96,28 +98,25 @@ static void cmd_print(Cotton *cotton, CottonWindow *cw, char *arg)
36 
37     for (int i = 0; text[i] != '\0'; i++)
38     {
39-        // when the limit of a line is reached we go down one line,, pmo when it just gluedtogehterlikethisacrosslinesaaaaaa
40         if (text[i] == '\n')
41         {
42             cotton->cursor_x = 0;
43-            cotton->cursor_y += 6; 
44+            cotton->cursor_y += FONT_HEIGHT + 4;
45             continue;
46         }
47 
48         draw_char(cotton, text[i], cotton->cursor_x, cotton->cursor_y);
49-        cotton->cursor_x += 6;
50-        
51-        // those who wrap
52-        if (cotton->cursor_x + 6 >= VIDEO_WIDTH)
53+        cotton->cursor_x += FONT_WIDTH + 2;
54+
55+        if (cotton->cursor_x + FONT_WIDTH + 2 >= VIDEO_WIDTH)
56         {
57             cotton->cursor_x = 0;
58-            cotton->cursor_y += 6;
59+            cotton->cursor_y += FONT_HEIGHT + 4;
60         }
61     }
62 
63     cotton->cursor_x = 0;
64-    cotton->cursor_y += 6;
65-
66+    cotton->cursor_y += FONT_HEIGHT + 4;
67 }
68 
69 static void cmd_wait(Cotton *cotton, char *arg)
70@@ -127,7 +126,7 @@ static void cmd_wait(Cotton *cotton, char *arg)
71 
72     int seconds = atoi(arg);
73 
74-    cotton->ticktock = SDL_GetTicks() + (seconds * 1000);
75+    cotton->ticktock = system_time() /1000 + (seconds * 1000);
76 }
77 
78 static void cmd_kill(void)
+6, -3
 1@@ -1,4 +1,5 @@
 2 #include <stdio.h>
 3+#include <OS.h>
 4 #include "cotton.h"
 5 #include "cottonwindow.h"
 6 #include "interpreter.h"
 7@@ -11,13 +12,15 @@ int main(int argc, char **argv)
 8         return 1;
 9     }
10 
11+  printf("hello world");
12+
13     CottonWindow cw;
14 
15-    if (!cottonwindow_init(&cw, "cotton", VIDEO_WIDTH * 4, VIDEO_HEIGHT * 4, VIDEO_WIDTH, VIDEO_HEIGHT))
16-        return 1;
17+    cottonwindow_init(&cw, "cotton", VIDEO_WIDTH*2, VIDEO_HEIGHT*2, VIDEO_WIDTH, VIDEO_HEIGHT))
18 
19     Cotton cotton;
20     cotton_init(&cotton);
21+    printf("crashec");
22 
23     FILE *file = fopen(argv[1], "r");
24     if (!file)
25@@ -33,7 +36,7 @@ int main(int argc, char **argv)
26     {
27         quit = cottonwindow_process_input(&cw, NULL);
28 
29-        if (SDL_GetTicks() >= cotton.ticktock)
30+        if (system_time() / 1000 >= cotton.ticktock)
31         {
32             cotton_interpret(&cotton, &cw, file);
33         }