0
0
Fork 0
mirror of https://git.sr.ht/~rabbits/uxn synced 2024-11-10 16:25:05 +00:00

Cleaned a few examples

This commit is contained in:
neauoire 2021-04-28 21:00:39 -07:00
parent 3d5e7f7e48
commit ec3c5a691b
12 changed files with 180 additions and 227 deletions

View file

@ -38,7 +38,7 @@ Read more in the [Uxambly Guide](https://wiki.xxiivv.com/site/uxambly.html).
BRK
@print ( addr -- )
@print ( addr* -- )
&loop
( send ) DUP2 GET .Console/char DEO

View file

@ -54,6 +54,7 @@ BRK
( only draw once per second )
.DateTime/second DEI .last PEK NEQ #01 JNZ [ BRK ]
.DateTime/second DEI .last POK
;redraw JSR2
@ -144,7 +145,7 @@ RTN
@draw-cursor ( -- )
( clear last cursor )
;clear .Screen/addr DEO2
#fff8 .Screen/addr DEO2
.pointer/x PEK2 .Screen/x DEO2
.pointer/y PEK2 .Screen/y DEO2
#30 .Screen/color DEO
@ -160,13 +161,14 @@ RTN
RTN
@clear [
0000 0000 0000 0000 ]
@cursor [
80c0 e0f0 f8e0 1000 ]
@digits [
7b6f 2492 73e7 73cf 5bc9
79cf 49ef 7249 7bef 7bc9 ]
7b6f 2492 73e7 73cf
5bc9 79cf 49ef 7249
7bef 7bc9 ]
@tiles [
0102 0408 1020 4080
8040 2010 0804 0201

View file

@ -5,7 +5,6 @@
%2/ { #0001 SFT2 }
%8+ { #0008 ADD2 }
%STEP8 { #0033 SFT2 }
%S2B { SWP POP }
( devices )
@ -17,15 +16,15 @@
|0000
@color $1
@selection $1
@center [ &x $2 &y $2 ]
@color [ &byte $1 ]
@pointer [ &x $2 &y $2 &sprite $2 ]
@pointer [ &x $2 &y $2 ]
@rect [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
@window [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 &w $2 &h $2 ]
@label [ &x $2 &y $2 &addr $2 ]
@slider [ &x1 $2 &y $2 &x2 $2 &pos $2 ]
@selection [ &byte $1 ]
@addr [ &byte $1 ]
@theme [
&r1 $1 &r2 $1 &r3 $1 &r4 $1
&g1 $1 &g2 $1 &g3 $1 &g4 $1
@ -34,18 +33,23 @@
( program )
|0100
|0100 ( -> )
( theme ) #127f .System/r DEO2 #34e7 .System/g DEO2 #56c4 .System/b DEO2
( vectors ) ;on-mouse .Mouse/vector DEO2
( theme )
#027f .System/r DEO2
#04e7 .System/g DEO2
#06c4 .System/b DEO2
( vectors )
;on-mouse .Mouse/vector DEO2
( size window )
#00b0 .window/w POK2
#0050 .window/h POK2
( center window )
.Screen/width DEI2 #0002 DIV2 .window/w PEK2 #0002 DIV2 SUB2 .window/x1 POK2
.Screen/height DEI2 #0002 DIV2 .window/h PEK2 #0002 DIV2 SUB2 .window/y1 POK2
.Screen/width DEI2 2/ .window/w PEK2 2/ SUB2 .window/x1 POK2
.Screen/height DEI2 2/ .window/h PEK2 2/ SUB2 .window/y1 POK2
#01 .theme/r1 POK #02 .theme/g1 POK #03 .theme/b1 POK
#04 .theme/r2 POK #06 .theme/g2 POK #07 .theme/b2 POK
@ -53,8 +57,8 @@
#0c .theme/r4 POK #0b .theme/g4 POK #0d .theme/b4 POK
( find screen center )
.Screen/width DEI2 #0002 DIV2 .center/x POK2
.Screen/height DEI2 #0002 DIV2 .center/y POK2
.Screen/width DEI2 2/ .center/x POK2
.Screen/height DEI2 2/ .center/y POK2
;update-theme JSR2
;draw-background JSR2
@ -62,35 +66,33 @@
BRK
@on-mouse
@on-mouse ( -> )
;draw-cursor JSR2
.Mouse/state DEI #00 NEQ ;&no-skip JNZ2 BRK &no-skip
.Mouse/state DEI #00 NEQ #01 JNZ [ BRK ]
.Mouse/y DEI2 .window/y1 PEK2 SUB2 STEP8
DUP2 #0010 NEQ2 ,&no-touch-red JNZ
.Mouse/x DEI2 .window/x1 PEK2 #0060 ADD2 LTH2 ,&no-touch-red JNZ
.Mouse/x DEI2 .window/x1 PEK2 #009c ADD2 GTH2 ,&no-touch-red JNZ
( get new value ) .Mouse/x DEI2 .window/x1 PEK2 SUB2 #0060 SUB2 #0004 DIV2 S2B ;theme/r1 #00 .selection PEK ADD2 PUT
( get new value ) .Mouse/x DEI2 .window/x1 PEK2 SUB2 #0060 SUB2 #0004 DIV2 SWP POP ;theme/r1 #00 .selection PEK ADD2 PUT
&no-touch-red
DUP2 #0020 NEQ2 ,&no-touch-green JNZ
.Mouse/x DEI2 .window/x1 PEK2 #0060 ADD2 LTH2 ,&no-touch-green JNZ
.Mouse/x DEI2 .window/x1 PEK2 #009c ADD2 GTH2 ,&no-touch-green JNZ
( get new value ) .Mouse/x DEI2 .window/x1 PEK2 SUB2 #0060 SUB2 #0004 DIV2 S2B ;theme/g1 #00 .selection PEK ADD2 PUT
( get new value ) .Mouse/x DEI2 .window/x1 PEK2 SUB2 #0060 SUB2 #0004 DIV2 SWP POP ;theme/g1 #00 .selection PEK ADD2 PUT
&no-touch-green
DUP2 #0030 NEQ2 ,&no-touch-blue JNZ
.Mouse/x DEI2 .window/x1 PEK2 #0060 ADD2 LTH2 ,&no-touch-blue JNZ
.Mouse/x DEI2 .window/x1 PEK2 #009c ADD2 GTH2 ,&no-touch-blue JNZ
( get new value ) .Mouse/x DEI2 .window/x1 PEK2 SUB2 #0060 SUB2 #0004 DIV2 S2B ;theme/b1 #00 .selection PEK ADD2 PUT
( get new value ) .Mouse/x DEI2 .window/x1 PEK2 SUB2 #0060 SUB2 #0004 DIV2 SWP POP ;theme/b1 #00 .selection PEK ADD2 PUT
&no-touch-blue
DUP2 #0040 NEQ2 ,&no-touch-radio JNZ
.Mouse/x DEI2 .window/x1 PEK2 #0050 ADD2 LTH2 ,&no-touch-radio JNZ
.Mouse/x DEI2 .window/x1 PEK2 #008c ADD2 GTH2 ,&no-touch-radio JNZ
.Mouse/x DEI2 .window/x1 PEK2 SUB2 #0050 SUB2 STEP8 2/ #0008 DIV2 S2B .selection POK
.Mouse/x DEI2 .window/x1 PEK2 SUB2 #0050 SUB2 STEP8 2/ #0008 DIV2 SWP POP .selection POK
&no-touch-radio
POP2
;update-theme JSR2
@ -98,7 +100,7 @@ BRK
BRK
@update-theme
@update-theme ( -- )
#08 DEI #0f AND .theme/r1 PEK #40 SFT ADD #08 DEO
#0a DEI #0f AND .theme/g1 PEK #40 SFT ADD #0a DEO
@ -115,7 +117,7 @@ BRK
RTN
@draw-background
@draw-background ( -- )
( draw hor line )
#0000 .Screen/x DEO2 .center/y PEK2 .Screen/y DEO2
@ -140,7 +142,7 @@ RTN
#0010 .Screen/y DEO2
#00 #08
&draw-pixel1
( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 .Screen/x DEO2
( move ) OVR #08 MUL #00 SWP #0010 ADD2 .Screen/x DEO2
( draw ) OVR .Screen/color DEO
( incr ) SWP #01 ADD SWP
DUP2 LTH ,&draw-pixel1 JNZ
@ -148,7 +150,7 @@ RTN
#0018 .Screen/y DEO2
#00 #08
&draw-pixel2
( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 .Screen/x DEO2
( move ) OVR #08 MUL #00 SWP #0010 ADD2 .Screen/x DEO2
( draw ) OVR #08 ADD .Screen/color DEO
( incr ) SWP #01 ADD SWP
DUP2 LTH ,&draw-pixel2 JNZ
@ -156,7 +158,7 @@ RTN
#0020 .Screen/y DEO2
#00 #08
&draw-icn1
( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 .Screen/x DEO2
( move ) OVR #08 MUL #00 SWP #0010 ADD2 .Screen/x DEO2
( draw ) OVR #20 ADD .Screen/color DEO
( incr ) SWP #01 ADD SWP
DUP2 LTH ,&draw-icn1 JNZ
@ -164,7 +166,7 @@ RTN
#0028 .Screen/y DEO2
#00 #08
&draw-icn2
( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 .Screen/x DEO2
( move ) OVR #08 MUL #00 SWP #0010 ADD2 .Screen/x DEO2
( draw ) OVR #28 ADD .Screen/color DEO
( incr ) SWP #01 ADD SWP
DUP2 LTH ,&draw-icn2 JNZ
@ -172,7 +174,7 @@ RTN
#0030 .Screen/y DEO2
#00 #08
&draw-chr1
( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 .Screen/x DEO2
( move ) OVR #08 MUL #00 SWP #0010 ADD2 .Screen/x DEO2
( draw ) OVR #40 ADD .Screen/color DEO
( incr ) SWP #01 ADD SWP
DUP2 LTH ,&draw-chr1 JNZ
@ -180,7 +182,7 @@ RTN
#0038 .Screen/y DEO2
#00 #08
&draw-chr2
( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 .Screen/x DEO2
( move ) OVR #08 MUL #00 SWP #0010 ADD2 .Screen/x DEO2
( draw ) OVR #48 ADD .Screen/color DEO
( incr ) SWP #01 ADD SWP
DUP2 LTH ,&draw-chr2 JNZ
@ -188,7 +190,7 @@ RTN
RTN
@draw-window
@draw-window ( -- )
.window/x1 PEK2 .window/w PEK2 ADD2 .window/x2 POK2
.window/y1 PEK2 .window/h PEK2 ADD2 .window/y2 POK2
@ -196,17 +198,17 @@ RTN
.window/x1 PEK2 .window/y1 PEK2 .window/x2 PEK2 .window/y2 PEK2 #01 ;line-rect JSR2
.window/x1 PEK2 #0002 SUB2 .window/y1 PEK2 #0002 SUB2 .window/x2 PEK2 #0002 ADD2 .window/y2 PEK2 #0002 ADD2 #01 ;line-rect JSR2
.window/x1 PEK2 #0008 ADD2 .window/y1 PEK2 #0010 ADD2 #25 ;red_txt ;draw-label JSR2
.window/x1 PEK2 #0038 ADD2 .window/y1 PEK2 #0010 ADD2 #28 .System/r ;draw-byte JSR2
.window/x1 PEK2 #0048 ADD2 .window/y1 PEK2 #0010 ADD2 #28 .System/r #01 ADD ;draw-byte JSR2
.window/x1 PEK2 #0008 ADD2 .window/y1 PEK2 #0010 ADD2 ;red_txt #25 ;draw-label JSR2
.window/x1 PEK2 #0038 ADD2 .Screen/x DEO2
.System/r DEI2 #28 ;draw-short JSR2
.window/x1 PEK2 #0008 ADD2 .window/y1 PEK2 #0020 ADD2 #25 ;green_txt ;draw-label JSR2
.window/x1 PEK2 #0038 ADD2 .window/y1 PEK2 #0020 ADD2 #28 .System/g ;draw-byte JSR2
.window/x1 PEK2 #0048 ADD2 .window/y1 PEK2 #0020 ADD2 #28 .System/g #01 ADD ;draw-byte JSR2
.window/x1 PEK2 #0008 ADD2 .window/y1 PEK2 #0020 ADD2 ;green_txt #25 ;draw-label JSR2
.window/x1 PEK2 #0038 ADD2 .Screen/x DEO2
.System/g DEI2 #28 ;draw-short JSR2
.window/x1 PEK2 #0008 ADD2 .window/y1 PEK2 #0030 ADD2 #25 ;blue_txt ;draw-label JSR2
.window/x1 PEK2 #0038 ADD2 .window/y1 PEK2 #0030 ADD2 #28 .System/b ;draw-byte JSR2
.window/x1 PEK2 #0048 ADD2 .window/y1 PEK2 #0030 ADD2 #28 .System/b #01 ADD ;draw-byte JSR2
.window/x1 PEK2 #0008 ADD2 .window/y1 PEK2 #0030 ADD2 ;blue_txt #25 ;draw-label JSR2
.window/x1 PEK2 #0038 ADD2 .Screen/x DEO2
.System/b DEI2 #28 ;draw-short JSR2
.window/x1 PEK2 #0060 ADD2 .window/y1 PEK2 #0010 ADD2 .window/x1 PEK2 #0090 ADD2 #00 ;theme/r1 .selection PEK ADD GET #0004 MUL2 #01 ;draw-slider JSR2
.window/x1 PEK2 #0060 ADD2 .window/y1 PEK2 #0020 ADD2 .window/x1 PEK2 #0090 ADD2 #00 ;theme/g1 .selection PEK ADD GET #0004 MUL2 #01 ;draw-slider JSR2
@ -237,13 +239,14 @@ RTN
@draw-cursor ( -- )
( clear last cursor )
;clear_icn .Screen/addr DEO2
#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
.Mouse/x DEI2 .pointer/x POK2
.Mouse/y DEI2 .pointer/y POK2
( draw new cursor )
;pointer_icn .Screen/addr DEO2
@ -253,7 +256,7 @@ RTN
RTN
@draw-slider ( x1 y x2 pos color -- )
@draw-slider ( x1* y* x2* pos* color -- )
( load ) .color POK .slider/pos POK2 .slider/x2 POK2 .slider/y POK2 .slider/x1 POK2
@ -280,7 +283,7 @@ RTN
RTN
@fill-rect ( x1 y1 x2 y2 color )
@fill-rect ( x1* y1* x2* y2* color -- )
.color POK
( x1 x2 y1 y2 ) ROT2 SWP2
@ -299,7 +302,7 @@ RTN
RTN
@line-rect ( x1 y1 x2 y2 color -- )
@line-rect ( x1* y1* x2* y2* color -- )
( load ) .color POK .rect/y2 POK2 .rect/x2 POK2 DUP2 .Screen/y DEO2 .rect/y1 POK2 DUP2 .Screen/x DEO2 .rect/x1 POK2
&hor
@ -316,49 +319,58 @@ RTN
RTN
@draw-label ( x y color addr -- )
@draw-label ( x* y* addr* color -- )
( load ) .label/addr POK2 .color POK .Screen/y DEO2 .Screen/x DEO2 .label/addr PEK2
STH STH2
.Screen/y DEO2
.Screen/x DEO2
STH2r
&loop
( draw ) DUP2 GET #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2 .color PEK .Screen/color DEO
DUP2 GET #00 SWP #0008 MUL2
;font ADD2 .Screen/addr DEO2
( draw ) DUPr STHr .Screen/color DEO
( incr ) ++
( incr ) .Screen/x DEI2 8+ .Screen/x DEO2
DUP2 GET #00 NEQ ,&loop JNZ
POP2
POP2 POPr
RTN
@draw-byte ( x y color addr -- )
@draw-short ( short* color -- )
.addr POK STH
.Screen/y DEO2
.Screen/x DEO2
;font_hex #00 .addr PEK DEI #04 SFT #0008 MUL2 ADD2 .Screen/addr DEO2
STHr DUP STH .Screen/color DEO
;font_hex #00 .addr PEK DEI #0f AND #0008 MUL2 ADD2 .Screen/addr DEO2
STH SWP
DUP #04 SFT #00 SWP #0008 MUL2 ;font-hex ADD2 .Screen/addr DEO2
( draw ) DUPr STHr .Screen/color DEO
#0f AND #00 SWP #0008 MUL2 ;font-hex ADD2 .Screen/addr DEO2
.Screen/x DEI2 8+ .Screen/x DEO2
STHr .Screen/color DEO
( draw ) DUPr STHr .Screen/color DEO
DUP #04 SFT #00 SWP #0008 MUL2 ;font-hex ADD2 .Screen/addr DEO2
.Screen/x DEI2 8+ .Screen/x DEO2
( draw ) DUPr STHr .Screen/color DEO
#0f AND #00 SWP #0008 MUL2 ;font-hex ADD2 .Screen/addr DEO2
.Screen/x DEI2 8+ .Screen/x DEO2
( draw ) STHr .Screen/color DEO
RTN
@clear_icn [ 0000 0000 0000 0000 ]
@red_txt [ "Red 00 ]
@green_txt [ "Green 00 ]
@blue_txt [ "Blue 00 ]
@pointer_icn [ 80c0 e0f0 f8e0 1000 ]
@halftone_icn [ aa55 aa55 aa55 aa55 ]
@slidera_icn [ 3f7f ffff ffff 7f3f ]
@sliderb_icn [ ffff ffff ffff ffff ]
@sliderc_icn [ fcfe ffff ffff fefc ]
@sliderd_icn [ 003c 7e7e 7e7e 3c00 ]
@preview_icn [ 183c 66db db66 3c18 0000 183c 3c18 0000 ]
@preview_icn [
183c 66db db66 3c18
0000 183c 3c18 0000 ]
@radio_icns
[ 3c42 8181 8181 423c ]
[ 3c42 99bd bd99 423c ]
@red_txt [ "Red 00 ]
@green_txt [ "Green 00 ]
@blue_txt [ "Blue 00 ]
@font_hex ( 0-F TODO: should pull from @font instead.. )
[
@font-hex [
003c 464a 5262 3c00 0018 0808 0808 1c00
003c 4202 3c40 7e00 003c 421c 0242 3c00
000c 1424 447e 0400 007e 407c 0242 3c00
@ -366,11 +378,9 @@ RTN
003c 423c 4242 3c00 003c 4242 3e02 3c00
003c 4242 7e42 4200 007c 427c 4242 7c00
003c 4240 4042 3c00 007c 4242 4242 7c00
007e 4078 4040 7e00 007e 4078 4040 4000
]
007e 4078 4040 7e00 007e 4078 4040 4000 ]
@font ( spectrum-zx font )
[
@font ( spectrum-zx font ) [
0000 0000 0000 0000 0000 2400 7e3c 0000 0000 2400 3c42 0000 0000 6c7c 7c38 1000
0010 387c 7c38 1000 0038 387c 6c10 3800 0010 387c 7c10 3800 0000 0018 1800 0000
007e 4242 4242 7e00 0000 1824 2418 0000 0018 2442 4224 1800 001e 063a 4a48 3000
@ -402,5 +412,4 @@ RTN
0000 7844 4478 4040 0000 3c44 443c 0406 0000 2c30 2020 2000 0000 3840 3804 7800
0010 103c 1010 0c00 0000 4444 4444 3800 0000 4444 2828 1000 0000 4454 5454 2800
0000 4428 1028 4400 0000 4444 443c 0438 0000 7c08 1020 7c00 000c 0810 1008 0c00
0008 0808 0808 0800 0030 1008 0810 3000 0000 0032 4c00 0000 3c42 99a1 a199 423c
]
0008 0808 0808 0800 0030 1008 0810 3000 0000 0032 4c00 0000 3c42 99a1 a199 423c ]

View file

@ -9,33 +9,36 @@
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ]
|30 @Audio [ &pad $8 &adsr $2 &len $2 &addr $2 &volume $1 &pitch $1 ]
|30 @Audio0 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
|0100 ( -> )
( set color pallete )
( theme )
#00ff .System/r DEO2
#0f0f .System/g DEO2
#0ff0 .System/b DEO2
;on-frame .Screen/vector DEO2 ( run on-frame every 1/60th of a second )
#ff .Audio/volume DEO ( set volume to max )
;saw .Audio/addr DEO2 ( set waveform to saw for audio engine )
;saw/end ;saw SUB2 .Audio/len DEO2
#1202 .Audio/adsr DEO2 ( set envelope for audio engine )
( vectors )
;on-frame .Screen/vector DEO2
( setup synth )
#1202 .Audio0/adsr DEO2
;saw .Audio0/addr DEO2
#0100 .Audio0/length DEO2
#ff .Audio0/volume DEO
BRK
@on-frame ( -> )
( incr ) .timer PEK #01 ADD .timer POK
( skip ) .timer PEK #10 EQU ,&play-note JNZ BRK &play-note
( skip ) .timer PEK #10 EQU #01 JNZ [ BRK ]
( get note )
;melody #00 .progress PEK ADD2 GET
( play note )
DUP .Audio/pitch DEO
DUP .Audio0/pitch DEO
( erase last note )
#20 .Screen/color DEO
@ -52,42 +55,28 @@ BRK
BRK
@silence ( -> )
@dot [ 003c 7eff 7e3c 0000 ]
BRK
( defines a sawtooth wave. )
@saw ( -> )
5f5f 5e5e 5e5d 5d5d 5c5c 5b5b 5b5a 5a5a
5959 5858 5857 5757 5656 5555 5554 5454
5353 5252 5251 5151 5050 4f4f 4f4e 4e4e
4d4d 4c4c 4c4b 4b4b 4a4a 4949 4948 4848
4747 4646 4645 4545 4444 4343 4342 4242
4141 4040 403f 3f3f 3e3e 3d3d 3d3c 3c3c
3b3b 3a3a 3a39 3939 3838 3737 3736 3636
3535 3434 3433 3333 3232 3131 3130 3030
2f2f 2e2e 2e2d 2d2d 2c2c 2b2b 2b2a 2a2a
2929 2828 2827 2727 2626 2525 2524 2424
2323 2222 2221 2121 2020 1f1f 1f1e 1e1e
1d1d 1c1c 1c1b 1b1b 1a1a 1919 1918 1818
1717 1616 1615 1515 1414 1313 1312 1212
1111 1010 100f 0f0f 0e0e 0d0d 0d0c 0c0c
0b0b 0a0a 0a09 0909 0808 0707 0706 0606
0505 0404 0403 0303 0202 0101 0100 0000
&end
BRK
( song data, #ff is used for a rest )
@saw [
0003 0609 0c0f 1215 181b 1e21 2427 2a2d
3033 3639 3b3e 4143 4649 4b4e 5052 5557
595b 5e60 6264 6667 696b 6c6e 7071 7274
7576 7778 797a 7b7b 7c7d 7d7e 7e7e 7e7e
7f7e 7e7e 7e7e 7d7d 7c7b 7b7a 7978 7776
7574 7271 706e 6c6b 6967 6664 6260 5e5b
5957 5552 504e 4b49 4643 413e 3b39 3633
302d 2a27 2421 1e1b 1815 120f 0c09 0603
00fd faf7 f4f1 eeeb e8e5 e2df dcd9 d6d3
d0cd cac7 c5c2 bfbd bab7 b5b2 b0ae aba9
a7a5 a2a0 9e9c 9a99 9795 9492 908f 8e8c
8b8a 8988 8786 8585 8483 8382 8282 8282
8182 8282 8282 8383 8485 8586 8788 898a
8b8c 8e8f 9092 9495 9799 9a9c 9ea0 a2a5
a7a9 abae b0b2 b5b7 babd bfc2 c5c7 cacd
d0d3 d6d9 dcdf e2e5 e8eb eef1 f4f7 fafd ]
@melody [
54 52 54 4f 4b 4f 48 ff
54 52 54 4f 4b 4f 48 ff
54 56 57 56 57 54 56 54
56 52 54 52 54 50 54 ff
]
( dot sprite )
@dot [ 003c 7eff 7e3c 0000 ]
56 52 54 52 54 50 54 ff ]

View file

@ -14,7 +14,7 @@
BRK
@print ( addr -- )
@print ( addr* -- )
&loop
( send ) DUP2 GET .Console/char DEO

View file

@ -18,6 +18,7 @@
#0f73 .System/r DEO2
#0fe3 .System/g DEO2
#0fc3 .System/b DEO2
( vectors )
;on-button .Controller/vector DEO2
;draw-cursor JSR2
@ -26,7 +27,8 @@ BRK
@on-button ( -> )
.Controller/key DEI #00 NEQ ,&skip JNZ BRK &skip
( skip ) .Controller/key DEI #00 NEQ #01 JNZ [ BRK ]
.Controller/key DEI #0d NEQ ,&no-return JNZ
( draw ) #20 .Screen/color DEO
( reset ) #0000 .Screen/x DEO2
@ -34,9 +36,11 @@ BRK
;draw-cursor JSR2
BRK
&no-return
;font #00 .Controller/key DEI 8* ADD2 .Screen/addr DEO2
( draw ) #21 .Screen/color DEO
( incr ) .Screen/x DEI2 8+ .Screen/x DEO2
;draw-cursor JSR2
BRK

View file

@ -24,21 +24,23 @@
( program )
|0100
|0100 ( -> )
( theme )
#0ff8 .System/r DEO2
#0f08 .System/g DEO2
#0f08 .System/b DEO2
( vectors )
;on-frame .Screen/vector DEO2
BRK
@on-frame
@on-frame ( -> )
( only draw once per second )
.DateTime/second DEI .current PEK NEQ #01 JNZ [ BRK ]
( skip ) .DateTime/second DEI .current PEK NEQ #01 JNZ [ BRK ]
.DateTime/second DEI .current POK
( clear )

View file

@ -62,8 +62,8 @@ BRK
BRK
@successtxt "Success! $1
@failedtxt "Failed. $1
@successtxt "Success! 09 $1
@failedtxt "Failed. 09 $1
@srcpath "projects/pictures/ako10x10.chr $1
@dstpath "bin/image-copy.chr $1

View file

@ -11,18 +11,19 @@
|0000
@color $1
@line [ &x0 $2 &y0 $2 &x $2 &y $2 &sx $2 &sy $2 &dx $2 &dy $2 &e1 $2 &e2 $2 ]
@pointer [ &x $2 &y $2 &lastx $2 &lasty $2 &state $1 ]
@color $1
( program )
|0100 ( -> )
( theme )
#f0f0 .System/r DEO2
#f00f .System/g DEO2
#f000 .System/b DEO2
#f030 .System/r DEO2
#f04f .System/g DEO2
#f050 .System/b DEO2
( vectors )
;on-mouse .Mouse/vector DEO2
@ -31,8 +32,10 @@ BRK
@on-mouse ( -> )
;draw-cursor JSR2
( on down )
.Mouse/state DEI #00 NEQ .pointer/state PEK #00 EQU #0101 EQU2 ,on-mouse-down JNZ
( on drag )
.Mouse/state DEI #00 NEQ ,on-mouse-drag JNZ
.Mouse/state DEI .pointer/state POK
@ -57,6 +60,7 @@ BRK
.pointer/y PEK2
#01 [ .Mouse/state DEI #10 EQU #02 MUL ADD ]
;draw-line JSR2
( record last position )
.Mouse/x DEI2 .pointer/lastx POK2
.Mouse/y DEI2 .pointer/lasty POK2
@ -67,19 +71,20 @@ BRK
@draw-cursor ( -- )
( clear last cursor )
;clear .Screen/addr DEO2
#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_icn .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
#33 .Mouse/state DEI #00 NEQ #02 MUL SUB .Screen/color DEO
RTN
@ -111,5 +116,4 @@ RTN
RTN
@clear [ 0000 0000 0000 0000 ]
@cursor [ 80c0 e0f0 f8e0 1000 ]
@pointer_icn [ 80c0 e0f0 f8e0 1000 ]

View file

@ -1,6 +1,7 @@
( dev/screen )
%RTN { JMP2r }
%MOD { DUP2 DIV MUL SUB }
( devices )
@ -18,94 +19,33 @@
|0100 ( -> )
( theme )
#530f .System/r DEO2
#f20f .System/g DEO2
#ad0f .System/b DEO2
#0c5f .System/r DEO2
#022f .System/g DEO2
#0da4 .System/b DEO2
( find screen center )
.Screen/width DEI2 #0002 DIV2 .center/x POK2
.Screen/height DEI2 #0002 DIV2 .center/y POK2
( draw )
;draw-background JSR2
;draw-sprites JSR2
BRK
@draw-background ( -- )
( draw hor line )
#0000 .Screen/x DEO2 .center/y PEK2 .Screen/y DEO2
#0000 .Screen/width DEI2 ( from/to )
&draw-hor
( draw ) #01 .Screen/color DEO
( incr ) SWP2 #0002 ADD2 DUP2 .Screen/x DEO2 SWP2
OVR2 OVR2 LTH2 ,&draw-hor JNZ
POP2 POP2
( draw ver line )
.center/x PEK2 .Screen/x DEO2 #0000 .Screen/y DEO2
#0000 .Screen/height DEI2 ( from/to )
&draw-ver
( draw ) #02 .Screen/color DEO
( incr ) SWP2 #0002 ADD2 DUP2 .Screen/y DEO2 SWP2
OVR2 OVR2 LTH2 ,&draw-ver JNZ
POP2 POP2
RTN
@draw-sprites ( -- )
( draw blending modes )
;preview_icn .Screen/addr DEO2
#0010 .Screen/y DEO2
#00 #08
&draw-pixel1
( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 .Screen/x DEO2
#00 #ff
&loop
( move ) OVR #0f AND #40 SFT #02 DIV #00 SWP
.center/x PEK2 #0040 SUB2 ADD2 .Screen/x DEO2
( move ) OVR #f0 AND #02 DIV #00 SWP
.center/y PEK2 #0018 SUB2 ADD2 .Screen/y DEO2
( draw ) OVR .Screen/color DEO
( incr ) SWP #01 ADD SWP
DUP2 LTH ,&draw-pixel1 JNZ
POP POP
#0018 .Screen/y DEO2
#00 #08
&draw-pixel2
( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 .Screen/x DEO2
( draw ) OVR #08 ADD .Screen/color DEO
( incr ) SWP #01 ADD SWP
DUP2 LTH ,&draw-pixel2 JNZ
POP POP
#0020 .Screen/y DEO2
#00 #08
&draw-icn1
( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 .Screen/x DEO2
( draw ) OVR #20 ADD .Screen/color DEO
( incr ) SWP #01 ADD SWP
DUP2 LTH ,&draw-icn1 JNZ
POP POP
#0028 .Screen/y DEO2
#00 #08
&draw-icn2
( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 .Screen/x DEO2
( draw ) OVR #28 ADD .Screen/color DEO
( incr ) SWP #01 ADD SWP
DUP2 LTH ,&draw-icn2 JNZ
POP POP
#0030 .Screen/y DEO2
#00 #08
&draw-chr1
( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 .Screen/x DEO2
( draw ) OVR #40 ADD .Screen/color DEO
( incr ) SWP #01 ADD SWP
DUP2 LTH ,&draw-chr1 JNZ
POP POP
#0038 .Screen/y DEO2
#00 #08
&draw-chr2
( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 .Screen/x DEO2
( draw ) OVR #48 ADD .Screen/color DEO
( incr ) SWP #01 ADD SWP
DUP2 LTH ,&draw-chr2 JNZ
POP POP
DUP2 LTH ,&loop JNZ
POP2
RTN

View file

@ -15,11 +15,14 @@
#4cfd .System/r DEO2
#4cf3 .System/g DEO2
#dcf2 .System/b DEO2
( vectors )
;on-frame .Screen/vector DEO2
( starting position )
.Screen/width DEI2 #0002 DIV2 .dvd/x POK2
.Screen/height DEI2 #0002 DIV2 .dvd/y POK2
#21 ;draw-dvd JSR2
BRK

View file

@ -82,7 +82,7 @@ BRK
RTN
@line-rect ( x1 y1 x2 y2 color )
@line-rect ( x1* y1* x2* y2* color -- )
( load ) .color POK .rect/y2 POK2 .rect/x2 POK2 DUP2 .Screen/y DEO2 .rect/y1 POK2 DUP2 .Screen/x DEO2 .rect/x1 POK2
&hor