diff options
| author | Melodi <62381002+Melodi17@users.noreply.github.com> | 2025-08-28 21:57:33 +1000 |
|---|---|---|
| committer | Melodi <62381002+Melodi17@users.noreply.github.com> | 2025-08-28 21:57:33 +1000 |
| commit | 76cea79a46d42f8f59503d3bb421f0d298da66cb (patch) | |
| tree | dc4310f667068f97ff6b8488d203b55202bc274a /ROMs/lib.c | |
| parent | cf7e621c104cb4aea801392585d2dcc9335bc013 (diff) | |
implemented standard library
Diffstat (limited to 'ROMs/lib.c')
| -rw-r--r-- | ROMs/lib.c | 52 |
1 files changed, 49 insertions, 3 deletions
@@ -1,7 +1,34 @@ +#define SK_MAX 256 +#define SK_NL 13 +#define SK_BS 8 +#define SK_SHIFT 160 +#define SK_A 65 +#define SK_B 66 +#define SK_C 67 +#define SK_D 68 +#define SK_E 69 + +#define MS_LEFT 1 +#define MS_RIGHT 2 +#define MS_MIDDLE 4 + +#define SCREEN_WIDTH 128 +#define SCREEN_HEIGHT 64 +#define SCREEN_MAX 128 * 64 + +#define true 1 +#define false 0 + +#define COLOR_BLACK 8 +#define COLOR_RED 1 +#define COLOR_GREEN 2 +#define COLOR_BLUE 3 +#define COLOR_TRANSPARENT 0 + int setPixel(int x, int y, int c) { char* screenStart = 0x402F; - int i = (y * 128) + x; + int i = (y * SCREEN_WIDTH) + x; screenStart[i] = c; } @@ -14,8 +41,7 @@ int setPixel(int i, int c) int clear(int c) { char* screenStart = 0x402F; - char screenSize = 64 * 128; - for (int i = 0; i < screenSize; i++) + for (int i = 0; i < SCREEN_MAX; i++) { screenStart[i] = c; } @@ -31,6 +57,26 @@ int getKeyState(int scanCode) return (val & (1 << bit)) != 0; } +int getPressedKey() +{ + for (int sk = 0; sk < SK_MAX; sk++) + { + if (getKeyState(sk) && sk != SK_SHIFT) + return sk; + } + return 0; +} + +int readKey() +{ + while (true) + { + int sk = getPressedKey(); + if (sk != 0) + return sk; + } +} + int getMouseIndex() { return *(0x602F); |
