From 9a5df4a563eace94aa461d6eb96ee3a29c92a6a7 Mon Sep 17 00:00:00 2001 From: kdx Date: Sun, 18 Jun 2023 21:03:37 +0200 Subject: cleanup samples --- samples/malloc.golem | 11 ++++++----- samples/move.golem | 14 ++++++++------ 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; -- cgit v1.2.3