From 61941bceebf5822f4b8bd0a77e8b08993fb50a2a Mon Sep 17 00:00:00 2001 From: Dennis Ranke Date: Wed, 20 Apr 2022 21:48:03 +0200 Subject: [PATCH] add simple example for doing music just using playNote function --- examples/curlywas/simple_music.cwa | 38 ++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 examples/curlywas/simple_music.cwa diff --git a/examples/curlywas/simple_music.cwa b/examples/curlywas/simple_music.cwa new file mode 100644 index 0000000..ad93e50 --- /dev/null +++ b/examples/curlywas/simple_music.cwa @@ -0,0 +1,38 @@ +include "../include/microw8-api.cwa" + +global mut frame = 0; + +export fn upd() { + if frame % 16 == 0 { + let ch: i32; + loop channels { + playNote(ch, (ch * 32 + (frame / 16) % 32)?0x20000); + branch_if ch := (ch + 1) % 4: channels; + } + } + frame = frame + 1; +} + +data 0x20000 { + i8( + 0x4e, 0x0, 0x0, 0x4c, 0x49, 0x0, 0x45, 0x47, + 0x49, 0x47, 0x45, 0x44, 0x42, 0x0, 0x3d, 0x41, + 0x44, 0x0, 0x0, 0x47, 0x49, 0x47, 0x45, 0x41, + 0x44, 0x0, 0x0, 0x0, 0x42, 0x0, 0x0, 0x0, + + 0x25, 0, 0x49, 0x25, 0x25, 0, 0x49, 0, + 0x25, 0, 0x49, 0x25, 0x25, 0, 0x49, 0, + 0x25, 0, 0x49, 0x25, 0x25, 0, 0x49, 0, + 0x25, 0, 0x49, 0x25, 0x25, 0, 0x49, 0, + + 0x2a, 0x0, 0x0, 0x0, 0x2d, 0x0, 0x0, 0x0, + 0x2c, 0x0, 0x28, 0x0, 0x2a, 0x0, 0x0, 0x0, + 0x25, 0x0, 0x0, 0x0, 0x29, 0x0, 0x0, 0x0, + 0x2c, 0x0, 0x2d, 0x0, 0x2a, 0x0, 0x25, 0x0, + + 0x0, 0x0, 0x31, 0x0, 0x34, 0x0, 0x0, 0x36, + 0x38, 0x39, 0x38, 0x34, 0x36, 0x0, 0x0, 0x0, + 0x0, 0x3d, 0x3b, 0x39, 0x38, 0x0, 0x0, 0x0, + 0x0, 0x39, 0x38, 0x39, 0x38, 0x0, 0x36, 0x0 + ) +} \ No newline at end of file