diff options
Diffstat (limited to 'ROMs/paint.c')
| -rw-r--r-- | ROMs/paint.c | 52 |
1 files changed, 10 insertions, 42 deletions
diff --git a/ROMs/paint.c b/ROMs/paint.c index 443719a..7e0427b 100644 --- a/ROMs/paint.c +++ b/ROMs/paint.c @@ -1,55 +1,23 @@ -int setPixel(int x, int y, int c) -{ - char* screenStart = 0x402F; - int i = (y * 128) + x; - screenStart[i] = c; -} - -int setPixelIndex(int i, int c) -{ - char* screenStart = 0x402F; - screenStart[i] = c; -} - -int clear(int c) -{ - char* screenStart = 0x402F; - char screenSize = 64 * 128; - for (int i = 0; i < screenSize; i++) - { - screenStart[i] = c; - } -} - -int getKeyState(int scanCode) -{ - char* hid = 0x6033; - int index = scanCode / 8; - int bit = scanCode % 8; - - int val = hid[index - 1]; - return (val & (1 << bit)) != 0; -} +#include "lib.c" int main() { int color = 0; - while (1) + while (true) { - int* hid = 0x602F; - int mouseIndex = hid[0]; - int mouseState = hid[1]; + int mouseIndex = getMouseIndex(); + int mouseState = getMouseState(); - if (mouseState & 1) - setPixelIndex(mouseIndex, (color % 3) + 1); + if (mouseState & MS_LEFT) + setPixel(mouseIndex, (color % 3) + 1); - if (getKeyState(67)) - clear(8); + if (getKeyState(SK_C)) + clear(COLOR_BLACK); - if (getKeyState(65)) + if (getKeyState(SK_A)) { color++; - while (getKeyState(65)) { } + while (getKeyState(SK_A)) { } } } }
\ No newline at end of file |
