commit baa2f2450f1d981c3591103ee78361d2b82420f9
parent e8c70d954a055672770490efae5530763ec3f0f4
Author: neauoire <aliceffekt@gmail.com>
Date: Fri, 30 Apr 2021 12:08:24 -0700
Rewriting polycat
Diffstat:
4 files changed, 194 insertions(+), 21 deletions(-)
diff --git a/build.sh b/build.sh
@@ -34,7 +34,7 @@ else
fi
echo "Assembling.."
-./bin/assembler projects/demos/piano.usm bin/boot.rom
+./bin/assembler projects/demos/polycat.usm bin/boot.rom
echo "Running.."
if [ "${2}" = '--cli' ];
diff --git a/projects/demos/piano.usm b/projects/demos/piano.usm
@@ -16,9 +16,6 @@
|10 @Console [ &pad $8 &char $1 &byte $1 &short $2 &string $2 ]
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ]
|30 @Audio0 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
-|40 @Audio1 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
-|50 @Audio2 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
-|60 @Audio3 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
|70 @Midi [ &vector $2 &channel $1 ¬e $1 &velocity $1 ]
|80 @Controller [ &vector $2 &button $1 &key $1 ]
|90 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &chord $1 ]
@@ -28,13 +25,12 @@
|0000
-@last-note $1
-@octave $1
-@addr $1
-@color $1
+@last-note $1
+@octave $1
+@color $1
@pointer [ &x $2 &y $2 ]
-@knob [ &x $2 &y $2 &value $1 ]
@center [ &x $2 &y $2 ]
+@knob [ &x $2 &y $2 &value $1 ]
@adsr-view [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
@wave-view [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
@octave-view [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
@@ -88,16 +84,6 @@
WAVEFORM .Audio0/addr DEO2
#0100 .Audio0/length DEO2
- #011a .Audio1/adsr DEO2
- #88 .Audio1/volume DEO
- WAVEFORM #0100 ADD2 .Audio1/addr DEO2
- #0100 .Audio1/length DEO2
-
- #1118 .Audio2/adsr DEO2
- #88 .Audio2/volume DEO
- WAVEFORM #0200 ADD2 .Audio2/addr DEO2
- #0100 .Audio2/length DEO2
-
( inital drawing )
;draw-octave JSR2
;draw-adsr JSR2
diff --git a/projects/demos/polycat.usm b/projects/demos/polycat.usm
@@ -0,0 +1,187 @@
+( polycat )
+
+%RTN { JMP2r }
+%8+ { #0008 ADD2 }
+%2/ { #0002 DIV2 }
+%MOD { DUP2 DIV MUL SUB }
+%INC { #01 ADD }
+%TOS { #00 SWP }
+
+( devices )
+
+|00 @System [ &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 ]
+|10 @Console [ &pad $8 &char $1 &byte $1 &short $2 &string $2 ]
+|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ]
+|30 @Audio0 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
+|40 @Audio1 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
+|50 @Audio2 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
+|60 @Audio3 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
+|70 @Midi [ &vector $2 &channel $1 ¬e $1 &velocity $1 ]
+|80 @Controller [ &vector $2 &button $1 &key $1 ]
+|90 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &chord $1 ]
+|a0 @File [ &vector $2 &success $2 &offset $2 &pad $2 &name $2 &length $2 &load $2 &save $2 ]
+|b0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ]
+
+( variables )
+
+|0000
+
+@cat [ &x $2 &y $2 &timer $1 ]
+@pointer [ &x $2 &y $2 ]
+
+( program )
+
+|0100 ( -> )
+
+ ( theme )
+ #0a3f .System/r DEO2
+ #05df .System/g DEO2
+ #0caf .System/b DEO2
+
+ ( find center )
+ .Screen/width DEI2 2/ #0008 SUB2 .cat/x POK2
+ .Screen/height DEI2 #0004 DIV2 #0003 MUL2 #0018 SUB2 .cat/y POK2
+
+ ( place polycat )
+
+ ( vectors )
+ ;on-mouse .Mouse/vector DEO2
+ ;on-frame .Screen/vector DEO2
+
+ ;draw-polycat JSR2
+ ;draw-ground JSR2
+
+BRK
+
+@on-mouse ( -> )
+
+ ;draw-cursor JSR2
+
+ .Mouse/x DEI2 .cat/x PEK2 GTH2 #20 MUL
+ .Mouse/y DEI2 .cat/y PEK2 GTH2 #40 MUL
+ ADD #00 SWP ;draw-eye JSR2
+
+BRK
+
+@on-frame ( -> )
+
+ .cat/timer PEK #01 ADD [ DUP ] .cat/timer POK
+ DUP #00 NEQ ,&skip0 JNZ #0000 ;draw-tail JSR2 &skip0
+ DUP #10 NEQ ,&skip1 JNZ #0001 ;draw-tail JSR2 &skip1
+ DUP #20 NEQ ,&skip2 JNZ #0002 ;draw-tail JSR2 &skip2
+ DUP #30 NEQ ,&skip3 JNZ #0003 ;draw-tail JSR2 &skip3
+ DUP #40 NEQ ,&skip4 JNZ #0002 ;draw-tail JSR2 &skip4
+ DUP #50 NEQ ,&skip5 JNZ #0001 ;draw-tail JSR2 &skip5
+ POP
+
+BRK
+
+@draw-polycat ( -- )
+
+ ( ears )
+ .cat/y PEK2 .Screen/y DEO2
+
+ .cat/x PEK2 #0008 SUB2 .Screen/x DEO2
+ ;ears .Screen/addr DEO2
+ #41 .Screen/color DEO
+ .cat/x PEK2 .Screen/x DEO2
+ ;ears #0010 ADD2 .Screen/addr DEO2
+ #41 .Screen/color DEO
+
+ #0000 ;draw-eye JSR2
+ #0000 ;draw-tail JSR2
+
+RTN
+
+@draw-eye ( quad* -- )
+
+ .cat/y PEK2 #0008 ADD2 .Screen/y DEO2
+ .cat/x PEK2 #0008 SUB2 .Screen/x DEO2
+
+ DUP2 ;eye ADD2 .Screen/addr DEO2
+ #41 .Screen/color DEO
+ .cat/x PEK2 .Screen/x DEO2
+ ;eye #0010 ADD2 ADD2 .Screen/addr DEO2
+ #41 .Screen/color DEO
+
+RTN
+
+@draw-tail ( frame* -- )
+
+ .cat/y PEK2 #0010 ADD2 .Screen/y DEO2
+
+ .cat/x PEK2 #0008 SUB2 .Screen/x DEO2
+ ;body .Screen/addr DEO2
+ #41 .Screen/color DEO
+ .cat/x PEK2 .Screen/x DEO2
+ #0010 MUL2 ;body #0010 ADD2 ADD2 .Screen/addr DEO2
+ #41 .Screen/color DEO
+
+RTN
+
+@draw-cursor ( -- )
+
+ ( clear last cursor )
+ #fff8 .Screen/addr DEO2
+ .pointer/x PEK2 .Screen/x DEO2
+ .pointer/y PEK2 .Screen/y DEO2
+ #30 .Screen/color DEO
+ ( record pointer positions )
+ .Mouse/x DEI2 .pointer/x POK2
+ .Mouse/y DEI2 .pointer/y POK2
+ ( draw new cursor )
+ ;cursor .Screen/addr DEO2
+ .pointer/x PEK2 .Screen/x DEO2
+ .pointer/y PEK2 .Screen/y DEO2
+ ( colorize on state )
+ #31 [ .Mouse/state DEI #00 NEQ ] ADD .Screen/color DEO
+
+RTN
+
+@draw-ground ( -- )
+
+ .cat/y PEK2 #0018 ADD2 .Screen/y DEO2
+ .cat/x PEK2 #0010 SUB2 .Screen/x DEO2
+ ;ground .Screen/addr DEO2
+
+ #00 #10
+ &loop
+ #21 .Screen/color DEO
+ .Screen/addr DEI2 #0008 ADD2 .Screen/addr DEO2
+ .Screen/x DEI2 #0008 ADD2 .Screen/x DEO2
+ SWP #01 ADD SWP
+ DUP2 LTH ,&loop JNZ
+ POP2
+
+RTN
+
+@cursor [
+ 80c0 e0f0 f8e0 1000 ]
+
+@ears [
+ 081c 3e3e 7f7f ffff 081c 3e3e 7f7f fffc
+ 081c 3c3e 7e7e ffff 081c 3c3e 7e7e ff1f ]
+
+@eye [
+ ffff ffff ff7f 3f0f f7ef cfe7 f07c 3f0f
+ ffff ffff fffe fcf0 87c3 c183 071e fcf0
+ ffff ffff ff7f 3f0f f0e1 c1e0 f07c 3f0f
+ ffff ffff fffe fcf0 f7fb f9f3 071e fcf0
+ ffff ffff ff7f 3f0f f0e7 cfef f77c 3f0f
+ ffff ffff fffe fcf0 0783 c1c3 871e fcf0
+ ffff ffff ff7f 3f0f f0e0 c1e1 f07c 3f0f
+ ffff ffff fffe fcf0 07f3 f9fb f71e fcf0
+]
+
+@body [
+ 0707 0707 0302 0200 0107 0707 0300 0000
+ e0f0 f0e0 e080 8000 c0f2 f9f9 fef8 b000
+ e0f0 f0e0 e080 8000 c0f2 f9f9 fef8 b000
+ e0f0 f0e0 e080 8000 c0f2 faf9 fef8 b000
+ e0f0 f0e0 e080 8000 c0f1 faf9 fef8 b000
+ 0707 0707 0f08 1000 0307 0707 0f00 0000
+ e0e0 e0e0 e080 8000 f2f9 f9fe b884 8400 ]
+
+@ground [
+ bf15 0210 0200 0200 ff55 aa54 a900 2000
+ fb55 aa45 2200 0400 ba40 a040 8880 0080 ]
+\ No newline at end of file
diff --git a/src/uxn.h b/src/uxn.h
@@ -48,4 +48,4 @@ int evaluxn(Uxn *u, Uint16 vec);
void mempoke16(Uint8 *m, Uint16 a, Uint16 b);
Uint16 mempeek16(Uint8 *m, Uint16 a);
-Device *portuxn(Uxn *u, Uint8 id, char *name, void (*talkfn)(Device *, Uint8, Uint8));
-\ No newline at end of file
+Device *portuxn(Uxn *u, Uint8 id, char *name, void (*talkfn)(Device *, Uint8, Uint8));