summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkdx <kikoodx@paranoici.org>2023-06-18 21:03:37 +0200
committerkdx <kikoodx@paranoici.org>2023-06-18 21:03:37 +0200
commit9a5df4a563eace94aa461d6eb96ee3a29c92a6a7 (patch)
tree49b152ac19d7b8d4637211efcea8376998781809
parentdd513a4fbee3c04f4b0a825198b9fe1e43dda767 (diff)
downloadgolem-9a5df4a563eace94aa461d6eb96ee3a29c92a6a7.tar.gz
cleanup samples
-rw-r--r--samples/malloc.golem11
-rw-r--r--samples/move.golem14
2 files changed, 14 insertions, 11 deletions
diff --git a/samples/malloc.golem b/samples/malloc.golem
index 1a3b1a9..a920e4e 100644
--- a/samples/malloc.golem
+++ b/samples/malloc.golem
@@ -1,4 +1,7 @@
-main() => nopipe() |> pipe();
+main() {
+ nopipe();
+ pipe();
+}
nopipe() {
local s = strdup("yo comment cava\n");
@@ -28,9 +31,7 @@ strlen(s) {
}
}
-strdup(s) {
- return strcpy(malloc(strlen(s) + 1), s);
-}
+strdup(s) => malloc(strlen(s) + 1) |> strcpy(s);
strcpy(dst, src) {
local i = 0;
@@ -59,7 +60,7 @@ malloc(n) {
local p = heap + heap_size;
heap_size = heap_size + n;
if (heap_size > 4096) {
- write("malloc error: heap is full");
+ write("malloc error: heap is full\n");
return 0;
}
return p;
diff --git a/samples/move.golem b/samples/move.golem
index feece58..1086e25 100644
--- a/samples/move.golem
+++ b/samples/move.golem
@@ -1,17 +1,20 @@
define INPUT = 0xbffe;
define SCREEN = 0xbfff;
-define TRUE = 1;
-define FALSE = 0;
main() {
loop {
slp;
- erase() |> update() |> draw();
+ erase();
+ update();
+ draw();
}
}
-update() => input_update() |> player_update();
+update() {
+ input_update();
+ => player_update();
+}
erase() => player_erase();
@@ -26,8 +29,7 @@ global input_up;
global input_down;
input_update() {
- local input;
- input = [INPUT];
+ local input = [INPUT];
input_up = (input & 0x10) != 0;
input_down = (input & 0x20) != 0;
input_left = (input & 0x40) != 0;