From 24ae92916db9adf728f6522ef6daa4f880631d7b Mon Sep 17 00:00:00 2001 From: starnakin Date: Tue, 20 Jun 2023 21:30:28 +0200 Subject: [PATCH] init: draw_map work --- .gitignore | 1 + game.🗿 | 118 +++++++++++++++++++++++++++++++++++++++++++++++++++++ run.sh | 4 ++ 3 files changed, 123 insertions(+) create mode 100644 .gitignore create mode 100644 game.🗿 create mode 100755 run.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bcd672a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +tmp.* diff --git a/game.🗿 b/game.🗿 new file mode 100644 index 0000000..789e6ad --- /dev/null +++ b/game.🗿 @@ -0,0 +1,118 @@ +define INPUT = 0xbffe; +define SCREEN = 0xbfff; +define SPAWN_X = 1; +define SPAWN_Y = 1; +define CASE_SIZE = 42; + +draw_pixel(x, y, c) +{ + [SCREEN + (x & 127) + (y & 127) * 128] = c; +} + +draw_x(x, y, selected) +{ + local current_x = 0; + local current_y; + loop + { + if (current_x == CASE_SIZE) + return; + current_y = 0; + loop + { + if (current_y == CASE_SIZE) + break; + if (current_x == current_y | current_x == CASE_SIZE - current_y) + draw_pixel(x + current_x, y + current_y, 0xffff); + else + draw_pixel(x + current_x, y + current_y, 0x1111 * (selected + 2)); + current_y++; + } + current_x++; + } +} + +draw_o(x, y, selected) +{ + local current_x = 0; + local current_y; + loop + { + if (current_x == CASE_SIZE) + return; + current_y = 0; + loop + { + if (current_y == CASE_SIZE) + break; + if (current_x == 2 | current_y == 2 | current_x == CASE_SIZE - 2 | current_y == CASE_SIZE - 2) + draw_pixel(x + current_x, y + current_y, 0xffff); + else + draw_pixel(x + current_x, y + current_y, 0x1111 * (selected + 2)); + current_y++; + } + current_x++; + } +} + +draw_blank(x, y, selected) +{ + local current_x = 0; + local current_y; + loop + { + if (current_x == CASE_SIZE) + return; + current_y = 0; + loop + { + if (current_y == CASE_SIZE) + break; + draw_pixel(x + current_x, y + current_y, 0x1111 * (selected + 2)); + current_y++; + } + current_x++; + } +} + +draw_case(x, y, content, selected) +{ + if (content == 'x') + draw_x(x, y, selected); + else if (content == 'o') + draw_o(x, y, selected); + else + draw_blank(x, y, selected); +} + +draw_map(map, cursor_x, cursor_y) +{ + local x = 0; + local y; + + loop + { + if (x == 3) + return; + y = 0; + loop + { + if (y == 3) + break; + draw_case(x * CASE_SIZE + (x != 0) * (x), y * CASE_SIZE + (y != 0) * (y), [map + x * 3 + y], cursor_x == x & cursor_y == y); + y++; + } + x++; + } +} + + +main() +{ + local map = {'b', 'b', 'b','b', 'b', 'b', 'b', 'b', 'b'}; + loop + { + slp; + draw_map(map, 0, 0); + } +} diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..d6bde10 --- /dev/null +++ b/run.sh @@ -0,0 +1,4 @@ +cat game.🗿 >tmp.🗿 +golemc tmp.🗿 >tmp.asm +orgaasm tmp.asm tmp.rom +orgaemu tmp.rom