december_adventure_2023

December Adventure (2023)
git clone https://git.eamoncaddigan.net/december_adventure_2023.git
Log | Files | Refs | README

commit 89fef553728d417977ae822efc1bd54ac3dcb9cd
parent 87fc7a22648d1d466917127094794335601b543f
Author: Eamon Caddigan <eamon.caddigan@gmail.com>
Date:   Sat, 30 Dec 2023 20:06:36 -0800

Playing/displaying Morse Code and Text!

The message is completely hard-coded, but I had to learn a lot of stuff
to get here.

Diffstat:
Dbeep.tal | 52----------------------------------------------------
Adecember-adventure.tal | 245+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 245 insertions(+), 52 deletions(-)

diff --git a/beep.tal b/beep.tal @@ -1,52 +0,0 @@ -( beep.tal ) - -|30 @Audio0 &vector $2 &position $2 &output $1 &duration $2 &pad $1 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 - -|0000 - -|0100 - ( Current test code should toggle a beep on and off every 200 ms ) - - ;toggle-sound .Audio0/vector DEO2 - #00c8 .Audio0/duration DEO2 - #00f0 .Audio0/adsr DEO2 - #0100 .Audio0/length DEO2 - ;sin-pcm .Audio0/addr DEO2 - #ff .Audio0/volume DEO - - #4e .Audio0/pitch DEO -BRK - -@toggle-sound ( -> ) - [ LIT2 00 &f $1 ] INCk ,&f STR - #01 AND ,&beep JCN - #0001 .Audio0/length DEO2 - ;silence .Audio0/addr DEO2 - #4e .Audio0/pitch DEO -BRK - &beep - #0100 .Audio0/length DEO2 - ;sin-pcm .Audio0/addr DEO2 - #4e .Audio0/pitch DEO -BRK - -@sin-pcm - 8083 8689 8c8f 9295 989b 9ea1 a4a7 aaad - b0b3 b6b9 bbbe c1c3 c6c9 cbce d0d2 d5d7 - d9db dee0 e2e4 e6e7 e9eb ecee f0f1 f2f4 - f5f6 f7f8 f9fa fbfb fcfd fdfe fefe fefe - fffe fefe fefe fdfd fcfb fbfa f9f8 f7f6 - f5f4 f2f1 f0ee eceb e9e7 e6e4 e2e0 dedb - d9d7 d5d2 d0ce cbc9 c6c3 c1be bbb9 b6b3 - b0ad aaa7 a4a1 9e9b 9895 928f 8c89 8683 - 807d 7a77 7471 6e6b 6865 625f 5c59 5653 - 504d 4a47 4542 3f3d 3a37 3532 302e 2b29 - 2725 2220 1e1c 1a19 1715 1412 100f 0e0c - 0b0a 0908 0706 0505 0403 0302 0202 0202 - 0102 0202 0202 0303 0405 0506 0708 090a - 0b0c 0e0f 1012 1415 1719 1a1c 1e20 2225 - 2729 2b2e 3032 3537 3a3d 3f42 4547 4a4d - 5053 5659 5c5f 6265 686b 6e71 7477 7a7d - -@silence - 7e diff --git a/december-adventure.tal b/december-adventure.tal @@ -0,0 +1,245 @@ +( december-adventure.tal ) + +|00 @System &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &halt $1 +|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1 +|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 +|30 @Audio0 &vector $2 &position $2 &output $1 &duration $2 &pad $1 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 + +|0000 + +|0100 + #0a6f .System/r DEO2 + #05cf .System/g DEO2 + #0caf .System/b DEO2 + + ( Attempt to set to 320 x 200 ) + #0140 .Screen/width DEO2 + #00c8 .Screen/height DEO2 + + ( Center the text and draw it ) + .Screen/width DEI2 #00 #0e #08 MUL SUB2 #01 SFT2 .Screen/x DEO2 + .Screen/height DEI2 #0008 SUB2 #01 SFT2 .Screen/y DEO2 + ;message ;draw-string JSR2 + + ( Set up the audio device to play the message ) + ;play-message .Audio0/vector DEO2 + #00c8 .Audio0/duration DEO2 + #00f0 .Audio0/adsr DEO2 + #0001 .Audio0/length DEO2 + ;silence .Audio0/addr DEO2 + #ff .Audio0/volume DEO + #4e .Audio0/pitch DEO +BRK + +@play-message ( -> ) + [ LIT2 00 &f $1 ] INCk ,&f STR + DUP2 + #10 SFT ;durations ADD2 + DUP2 ;durations/end LTH2 ,&play JCN + POP2 +BRK + &play + LDA2 .Audio0/duration DEO2 + #0001 AND2 ,&mute JCN + #0100 .Audio0/length DEO2 + ;sin-pcm .Audio0/addr DEO2 + #4e .Audio0/pitch DEO +BRK + &mute + #0001 .Audio0/length DEO2 + ;silence .Audio0/addr DEO2 + #4e .Audio0/pitch DEO +BRK + +@draw-character ( char -- ) + #20 SUB #00 SWP #30 SFT2 + ;font ADD2 .Screen/addr DEO2 + #43 .Screen/sprite DEO +JMP2r + +@draw-string ( text* -- ) + [ #00 .Screen/auto DEI ] .Screen/x DEI2 ROT2 + #01 .Screen/auto DEO + &while + LDAk + [ #00 ] NEQk NIP ,&not-00 JCN + POP + ,&end-while JMP + &not-00 + [ #0a ] NEQk NIP ,&not-0a JCN + POP + OVR2 .Screen/x DEO2 + .Screen/y DEI2 #0008 ADD2 .Screen/y DEO2 + ,&end-if JMP + &not-0a + ( else ) + ;draw-character JSR2 + &end-if + INC2 ,&while JMP + &end-while + POP2 POP2 + .Screen/auto DEO POP +JMP2r + +@message + "Happy 20 "New 20 "Year 00 + +( Hard-coding a message with a 5 WPM transmission speed but an 18 WPM + character speed ) +@durations + ( "H", "....", ) + 0043 0043 0043 0043 0043 0043 0043 + 0620 + ( "A", ".-", ) + 0043 0043 00c8 + 0620 + ( "P", ".--.", ) + 0043 0043 00c8 0043 00c8 0043 0043 + 0620 + ( "P", ".--.", ) + 0043 0043 00c8 0043 00c8 0043 0043 + 0620 + ( "Y", "-.--", ) + 00c8 0043 0043 0043 00c8 0043 00c8 + 0e4c + ( "N", "-.", ) + 00c8 0043 0043 + 0620 + ( "E", ".", ) + 0043 + 0620 + ( "W", ".--", ) + 0043 0043 00c8 0043 00c8 + 0e4c + ( "Y", "-.--", ) + 00c8 0043 0043 0043 00c8 0043 00c8 + 0620 + ( "E", ".", ) + 0043 + 0620 + ( "A", ".-", ) + 0043 0043 00c8 + 0620 + ( "R", ".-.", ) + 0043 0043 00c8 0043 0043 + 0e4c + &end + +@sin-pcm + 8083 8689 8c8f 9295 989b 9ea1 a4a7 aaad + b0b3 b6b9 bbbe c1c3 c6c9 cbce d0d2 d5d7 + d9db dee0 e2e4 e6e7 e9eb ecee f0f1 f2f4 + f5f6 f7f8 f9fa fbfb fcfd fdfe fefe fefe + fffe fefe fefe fdfd fcfb fbfa f9f8 f7f6 + f5f4 f2f1 f0ee eceb e9e7 e6e4 e2e0 dedb + d9d7 d5d2 d0ce cbc9 c6c3 c1be bbb9 b6b3 + b0ad aaa7 a4a1 9e9b 9895 928f 8c89 8683 + 807d 7a77 7471 6e6b 6865 625f 5c59 5653 + 504d 4a47 4542 3f3d 3a37 3532 302e 2b29 + 2725 2220 1e1c 1a19 1715 1412 100f 0e0c + 0b0a 0908 0706 0505 0403 0302 0202 0202 + 0102 0202 0202 0303 0405 0506 0708 090a + 0b0c 0e0f 1012 1415 1719 1a1c 1e20 2225 + 2729 2b2e 3032 3537 3a3d 3f42 4547 4a4d + 5053 5659 5c5f 6265 686b 6e71 7477 7a7d + +@silence + 7e + +@font + 0000 0000 0000 0000 + 1818 1818 1800 1800 + 6c6c 6c00 0000 0000 + 3636 7f36 7f36 3600 + 0c3f 683e 0b7e 1800 + 6066 0c18 3066 0600 + 386c 6c38 6d66 3b00 + 0c18 3000 0000 0000 + 0c18 3030 3018 0c00 + 3018 0c0c 0c18 3000 + 0018 7e3c 7e18 0000 + 0018 187e 1818 0000 + 0000 0000 0018 1830 + 0000 007e 0000 0000 + 0000 0000 0018 1800 + 0006 0c18 3060 0000 + 3c66 6e7e 7666 3c00 + 1838 1818 1818 7e00 + 3c66 060c 1830 7e00 + 3c66 061c 0666 3c00 + 0c1c 3c6c 7e0c 0c00 + 7e60 7c06 0666 3c00 + 1c30 607c 6666 3c00 + 7e06 0c18 3030 3000 + 3c66 663c 6666 3c00 + 3c66 663e 060c 3800 + 0000 1818 0018 1800 + 0000 1818 0018 1830 + 0c18 3060 3018 0c00 + 0000 7e00 7e00 0000 + 3018 0c06 0c18 3000 + 3c66 0c18 1800 1800 + 3c66 6e6a 6e60 3c00 + 3c66 667e 6666 6600 + 7c66 667c 6666 7c00 + 3c66 6060 6066 3c00 + 786c 6666 666c 7800 + 7e60 607c 6060 7e00 + 7e60 607c 6060 6000 + 3c66 606e 6666 3c00 + 6666 667e 6666 6600 + 7e18 1818 1818 7e00 + 3e0c 0c0c 0c6c 3800 + 666c 7870 786c 6600 + 6060 6060 6060 7e00 + 6377 7f6b 6b63 6300 + 6666 767e 6e66 6600 + 3c66 6666 6666 3c00 + 7c66 667c 6060 6000 + 3c66 6666 6a6c 3600 + 7c66 667c 6c66 6600 + 3c66 603c 0666 3c00 + 7e18 1818 1818 1800 + 6666 6666 6666 3c00 + 6666 6666 663c 1800 + 6363 6b6b 7f77 6300 + 6666 3c18 3c66 6600 + 6666 663c 1818 1800 + 7e06 0c18 3060 7e00 + 7c60 6060 6060 7c00 + 0060 3018 0c06 0000 + 3e06 0606 0606 3e00 + 183c 6642 0000 0000 + 0000 0000 0000 00ff + 1c36 307c 3030 7e00 + 0000 3c06 3e66 3e00 + 6060 7c66 6666 7c00 + 0000 3c66 6066 3c00 + 0606 3e66 6666 3e00 + 0000 3c66 7e60 3c00 + 1c30 307c 3030 3000 + 0000 3e66 663e 063c + 6060 7c66 6666 6600 + 1800 3818 1818 3c00 + 1800 3818 1818 1870 + 6060 666c 786c 6600 + 3818 1818 1818 3c00 + 0000 367f 6b6b 6300 + 0000 7c66 6666 6600 + 0000 3c66 6666 3c00 + 0000 7c66 667c 6060 + 0000 3e66 663e 0607 + 0000 6c76 6060 6000 + 0000 3e60 3c06 7c00 + 3030 7c30 3030 1c00 + 0000 6666 6666 3e00 + 0000 6666 663c 1800 + 0000 636b 6b7f 3600 + 0000 663c 183c 6600 + 0000 6666 663e 063c + 0000 7e0c 1830 7e00 + 0c18 1870 1818 0c00 + 1818 1800 1818 1800 + 3018 180e 1818 3000 + 316b 4600 0000 0000 + ffff ffff ffff ffff