mirror of
https://git.sr.ht/~rabbits/uxn
synced 2024-11-10 16:25:05 +00:00
Templated examples
This commit is contained in:
parent
dad55324aa
commit
1b4623be1b
10 changed files with 258 additions and 237 deletions
2
build.sh
2
build.sh
|
@ -32,7 +32,7 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Assembling.."
|
echo "Assembling.."
|
||||||
./bin/assembler projects/examples/dev.mouse.usm bin/boot.rom
|
./bin/assembler projects/examples/gui.animation.usm bin/boot.rom
|
||||||
|
|
||||||
echo "Running.."
|
echo "Running.."
|
||||||
if [ "${2}" = '--cli' ];
|
if [ "${2}" = '--cli' ];
|
||||||
|
|
|
@ -10,52 +10,35 @@ scope: source.usm
|
||||||
|
|
||||||
contexts:
|
contexts:
|
||||||
main:
|
main:
|
||||||
# pointer
|
# label
|
||||||
- match: '\@(\S+)\s?'
|
- match: '\@(\S+)\s?'
|
||||||
scope: string.control
|
scope: string.control
|
||||||
pop: true
|
pop: true
|
||||||
|
# sublabel
|
||||||
- match: '\&(\S+)\s?'
|
- match: '\&(\S+)\s?'
|
||||||
scope: string.control
|
scope: string.control
|
||||||
pop: true
|
pop: true
|
||||||
|
|
||||||
# jump
|
# jump
|
||||||
- match: '\|(\S+)\s?'
|
- match: '\|(\S+)\s?'
|
||||||
scope: variable.control
|
scope: entity.name.tag.structure.any
|
||||||
pop: true
|
pop: true
|
||||||
|
# pad
|
||||||
- match: '\$(\S+)\s?'
|
- match: '\$(\S+)\s?'
|
||||||
scope: variable.control
|
scope: entity.name.tag.structure.any
|
||||||
pop: true
|
|
||||||
# constants
|
|
||||||
|
|
||||||
# templated
|
|
||||||
- match: '(\S+)\^\s?'
|
|
||||||
scope: storage.type
|
|
||||||
pop: true
|
|
||||||
- match: '(\S+)\=\s?'
|
|
||||||
scope: constant.numeric
|
|
||||||
pop: true
|
|
||||||
- match: '(\S+)\?\s?'
|
|
||||||
scope: storage.type
|
|
||||||
pop: true
|
|
||||||
- match: '(\S+)\!\s?'
|
|
||||||
scope: constant.numeric
|
|
||||||
pop: true
|
pop: true
|
||||||
|
|
||||||
# Pushing to stack
|
# Pushing to stack
|
||||||
|
|
||||||
- match: '\#(\S+)\s?'
|
|
||||||
scope: keyword.control
|
|
||||||
pop: true
|
|
||||||
- match: '\"(\S+)\s?'
|
- match: '\"(\S+)\s?'
|
||||||
scope: entity.control
|
scope: variable.parameter.option
|
||||||
pop: true
|
pop: true
|
||||||
|
|
||||||
# Addressing
|
# Addressing
|
||||||
- match: '\.(\S+)\s?' # zero-page
|
- match: '\.(\S+)\s?' # zero-page
|
||||||
scope: variable.control
|
scope: variable.function.shell
|
||||||
pop: true
|
pop: true
|
||||||
- match: '\,(\S+)\s?' # relative
|
- match: '\,(\S+)\s?' # relative
|
||||||
scope: entity.name.type
|
scope: entity.name.tag.yaml
|
||||||
pop: true
|
pop: true
|
||||||
- match: '\;(\S+)\s?' # absolute
|
- match: '\;(\S+)\s?' # absolute
|
||||||
scope: keyword.control
|
scope: keyword.control
|
||||||
|
@ -64,6 +47,7 @@ contexts:
|
||||||
scope: keyword.control
|
scope: keyword.control
|
||||||
pop: true
|
pop: true
|
||||||
|
|
||||||
|
# Blocks
|
||||||
- match: '\[\s?'
|
- match: '\[\s?'
|
||||||
scope: comment
|
scope: comment
|
||||||
pop: true
|
pop: true
|
||||||
|
@ -71,9 +55,6 @@ contexts:
|
||||||
scope: comment
|
scope: comment
|
||||||
pop: true
|
pop: true
|
||||||
|
|
||||||
|
|
||||||
# Blocks
|
|
||||||
|
|
||||||
- match: '\{'
|
- match: '\{'
|
||||||
scope: variable.control
|
scope: variable.control
|
||||||
push:
|
push:
|
||||||
|
@ -87,3 +68,39 @@ contexts:
|
||||||
- meta_scope: comment.line
|
- meta_scope: comment.line
|
||||||
- match: '\)'
|
- match: '\)'
|
||||||
pop: true
|
pop: true
|
||||||
|
|
||||||
|
# templated
|
||||||
|
|
||||||
|
- match: '(\S+)\^\!\s?'
|
||||||
|
scope: entity.name.type.typedef
|
||||||
|
pop: true
|
||||||
|
- match: '(\S+)\~\!\s?'
|
||||||
|
scope: constant.numeric
|
||||||
|
pop: true
|
||||||
|
- match: '(\S+)\*\!\s?'
|
||||||
|
scope: entity.name.type.typedef
|
||||||
|
pop: true
|
||||||
|
- match: '(\S+)\=\!\s?'
|
||||||
|
scope: constant.numeric
|
||||||
|
pop: true
|
||||||
|
|
||||||
|
- match: '(\S+)\^\s?'
|
||||||
|
scope: entity.name.type.typedef
|
||||||
|
pop: true
|
||||||
|
- match: '(\S+)\~\s?'
|
||||||
|
scope: constant.numeric
|
||||||
|
pop: true
|
||||||
|
- match: '(\S+)\*\s?'
|
||||||
|
scope: entity.name.type.typedef
|
||||||
|
pop: true
|
||||||
|
- match: '(\S+)\=\s?'
|
||||||
|
scope: constant.numeric
|
||||||
|
pop: true
|
||||||
|
|
||||||
|
|
||||||
|
- match: '(\S+)\?\s?'
|
||||||
|
scope: storage.type
|
||||||
|
pop: true
|
||||||
|
- match: '(\S+)\!\s?'
|
||||||
|
scope: constant.numeric
|
||||||
|
pop: true
|
|
@ -2,14 +2,14 @@
|
||||||
|
|
||||||
( devices )
|
( devices )
|
||||||
|
|
||||||
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|
||||||
|10 @Console [ &pad $8 &char $1 &byte $1 &short $2 &string $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 ]
|
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ]
|
||||||
|30 @Audio [ &wave $2 &envelope $2 &pad $4 &volume $1 &pitch $1 &play $1 &value $2 &delay $2 &finish $1 ]
|
|30 @Audio [ &wave $2 &envelope $2 &pad $4 &volume $1 &pitch $1 &play $1 &value $2 &delay $2 &finish $1 ]
|
||||||
|40 @Controller [ &vector $2 &button $1 &key $1 ]
|
|40 @Controller [ &vector $2 &button $1 &key $1 ]
|
||||||
|60 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &chord $1 ]
|
|60 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &chord $1 ]
|
||||||
|70 @File [ &vector $2 &success $2 &offset $2 &pad $2 &name $2 &length $2 &load $2 &save $2 ]
|
|70 @File [ &vector $2 &success $2 &offset $2 &pad $2 &name $2 &length $2 &load $2 &save $2 ]
|
||||||
|a0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 &refresh $1 ]
|
|a0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 &refresh $1 ]
|
||||||
|
|
||||||
( variables )
|
( variables )
|
||||||
|
|
||||||
|
@ -19,3 +19,16 @@
|
||||||
|
|
||||||
|0100 ( -> )
|
|0100 ( -> )
|
||||||
|
|
||||||
|
;deferred
|
||||||
|
,relative
|
||||||
|
.zero-page
|
||||||
|
:immediate
|
||||||
|
|
||||||
|
|goto
|
||||||
|
$padding
|
||||||
|
|
||||||
|
@label
|
||||||
|
&sublabel
|
||||||
|
|
||||||
|
#value
|
||||||
|
"string
|
|
@ -2,13 +2,12 @@
|
||||||
|
|
||||||
%MOD { DUP2 DIV MUL SUB }
|
%MOD { DUP2 DIV MUL SUB }
|
||||||
|
|
||||||
(
|
%%^! { .% DEI } %%~! { .% DEO }
|
||||||
position in track,
|
%%*! { .% DEI2 } %%=! { .% DEO2 }
|
||||||
frame: counter for current frame,
|
%%^ { .% PEK } %%~ { .% POK }
|
||||||
only playing every few frames
|
%%* { .% PEK2 } %%= { .% POK2 }
|
||||||
)
|
|
||||||
|
|
||||||
@timer $1
|
@timer $1
|
||||||
@progress $1
|
@progress $1
|
||||||
|
|
||||||
( devices )
|
( devices )
|
||||||
|
@ -20,41 +19,41 @@
|
||||||
|0100 ( -> )
|
|0100 ( -> )
|
||||||
|
|
||||||
( set color pallete )
|
( set color pallete )
|
||||||
#00ff .System/r DEO2
|
#00ff System/r=!
|
||||||
#0f0f .System/g DEO2
|
#0f0f System/g=!
|
||||||
#0ff0 .System/b DEO2
|
#0ff0 System/b=!
|
||||||
|
|
||||||
;on-frame .Screen/vector DEO2 ( run on-frame every 1/60th of a second )
|
;on-frame Screen/vector=! ( run on-frame every 1/60th of a second )
|
||||||
#ff .Audio/vol DEO ( set volume to max )
|
#ff Audio/vol~! ( set volume to max )
|
||||||
;saw .Audio/wave DEO2 ( set waveform to saw for audio engine )
|
;saw Audio/wave=! ( set waveform to saw for audio engine )
|
||||||
;env .Audio/env DEO2 ( set envelope for audio engine )
|
;env Audio/env=! ( set envelope for audio engine )
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
@on-frame ( -> )
|
@on-frame ( -> )
|
||||||
|
|
||||||
( incr ) .timer PEK #01 ADD .timer POK
|
( incr ) timer^ #01 ADD timer~
|
||||||
( skip ) .timer PEK #10 EQU ,&play-note JNZ BRK &play-note
|
( skip ) timer^ #10 EQU ,&play-note JNZ BRK &play-note
|
||||||
|
|
||||||
( get note )
|
( get note )
|
||||||
;melody #00 .progress PEK ADD2 GET ( -- note )
|
;melody #00 progress^ ADD2 GET
|
||||||
|
|
||||||
( play note )
|
( play note )
|
||||||
DUP #80 ORA .Audio/pitch DEO ( -- note ) ( OR note with #80 and set the audio pitch to it. )
|
DUP #80 ORA Audio/pitch~!
|
||||||
#01 .Audio/play DEO ( play the note )
|
#01 Audio/play~!
|
||||||
|
|
||||||
( erase last note )
|
( erase last note )
|
||||||
#20 .Screen/color DEO ( draw a dot )
|
#20 Screen/color~!
|
||||||
|
|
||||||
( draw note )
|
( draw note )
|
||||||
#00 SWP #0004 MUL2 #0100 SUB2 .Screen/y DEO2 ( calculate the y position of a dot. TODO make this not upside down )
|
#00 SWP #0004 MUL2 #0100 SUB2 Screen/y=!
|
||||||
#00 .progress PEK #0008 MUL2 .Screen/x DEO2 ( calculate the x position of a dot )
|
#00 progress^ #0008 MUL2 Screen/x=!
|
||||||
;dot .Screen/addr DEO2 ( set the sprite for a dot )
|
;dot Screen/addr=!
|
||||||
#21 .Screen/color DEO ( draw a dot )
|
#21 Screen/color~!
|
||||||
|
|
||||||
( incr ) .progress PEK #01 ADD #20 MOD .progress POK
|
( incr ) progress^ #01 ADD #20 MOD progress~
|
||||||
|
|
||||||
#00 .timer POK
|
#00 timer~
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
|
@ -66,10 +65,10 @@ BRK
|
||||||
|
|
||||||
@saw ( -> )
|
@saw ( -> )
|
||||||
|
|
||||||
#6000 .Audio/value DEO2
|
#6000 Audio/value=!
|
||||||
#0000 .Audio/delay DEO2 ( move to volume #600 after 0 delay )
|
#0000 Audio/delay=! ( move to volume #600 after 0 delay )
|
||||||
#0000 .Audio/value DEO2
|
#0000 Audio/value=!
|
||||||
#ffff .Audio/delay DEO2 ( reach volume 0 after the whole note. Interpolated linearly )
|
#ffff Audio/delay=! ( reach volume 0 after the whole note. Interpolated linearly )
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
|
@ -77,11 +76,11 @@ BRK
|
||||||
|
|
||||||
@env ( -> )
|
@env ( -> )
|
||||||
|
|
||||||
#ffff .Audio/value DEO2
|
#ffff Audio/value=!
|
||||||
#1000 .Audio/delay DEO2 ( move pretty quickly to volume #ffff (maximum) )
|
#1000 Audio/delay=! ( move pretty quickly to volume #ffff (maximum) )
|
||||||
#0000 .Audio/value DEO2
|
#0000 Audio/value=!
|
||||||
#4000 .Audio/delay DEO2 ( interpolating linearly, move to #0000 after a delay of #4000 where #8000 is half a second )
|
#4000 Audio/delay=! ( interpolating linearly, move to #0000 after a delay of #4000 where #8000 is half a second )
|
||||||
#00 .Audio/finish DEO ( end the envelope )
|
#00 Audio/finish~! ( end the envelope )
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
( dev/controller/buttons )
|
( dev/controller/buttons )
|
||||||
|
|
||||||
%=>SC/ADDR { .Screen/addr DEO2 }
|
|
||||||
%->SC/COLR { .Screen/color DEO }
|
|
||||||
%++ { #0001 ADD2 }
|
%++ { #0001 ADD2 }
|
||||||
%-- { #0001 SUB2 }
|
%-- { #0001 SUB2 }
|
||||||
%2/ { #0002 DIV2 }
|
%2/ { #0002 DIV2 }
|
||||||
|
|
||||||
|
%%^! { .% DEI } %%~! { .% DEO }
|
||||||
|
%%*! { .% DEI2 } %%=! { .% DEO2 }
|
||||||
|
%%^ { .% PEK } %%~ { .% POK }
|
||||||
|
%%* { .% PEK2 } %%= { .% POK2 }
|
||||||
|
|
||||||
( devices )
|
( devices )
|
||||||
|
|
||||||
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|
||||||
|
@ -23,62 +26,62 @@
|
||||||
|0100 ( -> )
|
|0100 ( -> )
|
||||||
|
|
||||||
( theme )
|
( theme )
|
||||||
#0daf .System/r DEO2
|
#0daf System/r=!
|
||||||
#02ff .System/g DEO2
|
#02ff System/g=!
|
||||||
#035f .System/b DEO2
|
#035f System/b=!
|
||||||
|
|
||||||
( vectors )
|
( vectors )
|
||||||
;on-frame .Screen/vector DEO2
|
;on-frame Screen/vector=!
|
||||||
|
|
||||||
( set origin )
|
( set origin )
|
||||||
.Screen/width DEI2 2/ .Screen/x DEO2
|
Screen/width*! 2/ Screen/x=!
|
||||||
.Screen/height DEI2 2/ .Screen/y DEO2
|
Screen/height*! 2/ Screen/y=!
|
||||||
|
|
||||||
;default_icn =>SC/ADDR
|
;default_icn Screen/addr=!
|
||||||
#31 ->SC/COLR
|
#31 Screen/color~!
|
||||||
#2a .slime POK
|
#2a slime~
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
@on-frame ( -> )
|
@on-frame ( -> )
|
||||||
|
|
||||||
#2a .slime POK
|
#2a slime~
|
||||||
;default_icn =>SC/ADDR
|
;default_icn Screen/addr=!
|
||||||
|
|
||||||
( hold ctrl key to change slime color )
|
( hold ctrl key to change slime color )
|
||||||
.Controller/button DEI #0f AND
|
Controller/button^! #0f AND
|
||||||
DUP #01 NEQ ,&no-ctrl JNZ #25 .slime POK &no-ctrl
|
DUP #01 NEQ ,&no-ctrl JNZ #25 slime~ &no-ctrl
|
||||||
DUP #02 NEQ ,&no-alt JNZ #2f .slime POK &no-alt
|
DUP #02 NEQ ,&no-alt JNZ #2f slime~ &no-alt
|
||||||
POP
|
POP
|
||||||
|
|
||||||
( clear ) #30 ->SC/COLR
|
( clear ) #30 Screen/color~!
|
||||||
|
|
||||||
( detect movement )
|
( detect movement )
|
||||||
.Controller/button DEI #f0 AND
|
Controller/button^! #f0 AND
|
||||||
DUP #04 SFT #01 AND #01 NEQ ,&no-up JNZ
|
DUP #04 SFT #01 AND #01 NEQ ,&no-up JNZ
|
||||||
( move )
|
( move )
|
||||||
.Screen/y DEI2 -- .Screen/y DEO2
|
Screen/y*! -- Screen/y=!
|
||||||
;up_icn =>SC/ADDR &no-up
|
;up_icn Screen/addr=! &no-up
|
||||||
DUP #05 SFT #01 AND #01 NEQ ,&no-down JNZ
|
DUP #05 SFT #01 AND #01 NEQ ,&no-down JNZ
|
||||||
( move )
|
( move )
|
||||||
.Screen/y DEI2 ++ .Screen/y DEO2
|
Screen/y*! ++ Screen/y=!
|
||||||
;down_icn =>SC/ADDR &no-down
|
;down_icn Screen/addr=! &no-down
|
||||||
DUP #06 SFT #01 AND #01 NEQ ,&no-left JNZ
|
DUP #06 SFT #01 AND #01 NEQ ,&no-left JNZ
|
||||||
( move )
|
( move )
|
||||||
.Screen/x DEI2 -- .Screen/x DEO2
|
Screen/x*! -- Screen/x=!
|
||||||
;left_icn =>SC/ADDR &no-left
|
;left_icn Screen/addr=! &no-left
|
||||||
DUP #07 SFT #01 AND #01 NEQ ,&no-right JNZ
|
DUP #07 SFT #01 AND #01 NEQ ,&no-right JNZ
|
||||||
( move )
|
( move )
|
||||||
.Screen/x DEI2 ++ .Screen/x DEO2
|
Screen/x*! ++ Screen/x=!
|
||||||
;right_icn =>SC/ADDR &no-right
|
;right_icn Screen/addr=! &no-right
|
||||||
POP
|
POP
|
||||||
|
|
||||||
( draw face )
|
( draw face )
|
||||||
#31 ->SC/COLR
|
#31 Screen/color~!
|
||||||
|
|
||||||
( draw slime )
|
( draw slime )
|
||||||
;slime_icn =>SC/ADDR
|
;slime_icn Screen/addr=!
|
||||||
.slime PEK ->SC/COLR
|
slime^ Screen/color~!
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,11 @@
|
||||||
%8+ { #0008 ADD2 }
|
%8+ { #0008 ADD2 }
|
||||||
%8* { #0030 SFT2 }
|
%8* { #0030 SFT2 }
|
||||||
|
|
||||||
|
%%^! { .% DEI } %%~! { .% DEO }
|
||||||
|
%%*! { .% DEI2 } %%=! { .% DEO2 }
|
||||||
|
%%^ { .% PEK } %%~ { .% POK }
|
||||||
|
%%* { .% PEK2 } %%= { .% POK2 }
|
||||||
|
|
||||||
( devices )
|
( devices )
|
||||||
|
|
||||||
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|
||||||
|
@ -15,39 +20,36 @@
|
||||||
|0100 ( -> )
|
|0100 ( -> )
|
||||||
|
|
||||||
( theme )
|
( theme )
|
||||||
#0f73 .System/r DEO2
|
#0f73 System/r=!
|
||||||
#0fe3 .System/g DEO2
|
#0fe3 System/g=!
|
||||||
#0fc3 .System/b DEO2
|
#0fc3 System/b=!
|
||||||
|
( vectors )
|
||||||
( vectors ) ;on-button .Controller/vector DEO2
|
;on-button Controller/vector=!
|
||||||
|
|
||||||
;draw-cursor JSR2
|
;draw-cursor JSR2
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
@on-button ( -> )
|
@on-button ( -> )
|
||||||
|
|
||||||
.Controller/key DEI #00 NEQ ,&skip JNZ BRK &skip
|
Controller/key^! #00 NEQ ,&skip JNZ BRK &skip
|
||||||
|
Controller/key^! #0d NEQ ,&no-return JNZ
|
||||||
.Controller/key DEI #0d NEQ ,&no-return JNZ
|
( draw ) #20 Screen/color~!
|
||||||
( draw ) #20 .Screen/color DEO
|
( reset ) #0000 Screen/x=!
|
||||||
( reset ) #0000 .Screen/x DEO2
|
( incr ) Screen/y*! 8+ Screen/y=!
|
||||||
( incr ) .Screen/y DEI2 8+ .Screen/y DEO2
|
|
||||||
;draw-cursor JSR2
|
;draw-cursor JSR2
|
||||||
BRK
|
BRK
|
||||||
&no-return
|
&no-return
|
||||||
|
;font #00 Controller/key^! 8* ADD2 Screen/addr=!
|
||||||
;font #00 .Controller/key DEI 8* ADD2 .Screen/addr DEO2
|
( draw ) #21 Screen/color~!
|
||||||
( draw ) #21 .Screen/color DEO
|
( incr ) Screen/x*! 8+ Screen/x=!
|
||||||
( incr ) .Screen/x DEI2 8+ .Screen/x DEO2
|
|
||||||
|
|
||||||
;draw-cursor JSR2
|
;draw-cursor JSR2
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
@draw-cursor ( -- )
|
@draw-cursor ( -- )
|
||||||
|
|
||||||
;cursor .Screen/addr DEO2 #22 .Screen/color DEO
|
;cursor Screen/addr=!
|
||||||
|
#22 Screen/color~!
|
||||||
|
|
||||||
RTN
|
RTN
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,11 @@
|
||||||
%8+ { #0008 ADD2 }
|
%8+ { #0008 ADD2 }
|
||||||
%MEMORY { #1000 }
|
%MEMORY { #1000 }
|
||||||
|
|
||||||
|
%%^! { .% DEI } %%~! { .% DEO }
|
||||||
|
%%*! { .% DEI2 } %%=! { .% DEO2 }
|
||||||
|
%%^ { .% PEK } %%~ { .% POK }
|
||||||
|
%%* { .% PEK2 } %%= { .% POK2 }
|
||||||
|
|
||||||
( devices )
|
( devices )
|
||||||
|
|
||||||
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|
||||||
|
@ -19,35 +24,35 @@
|
||||||
|0100 ( -> )
|
|0100 ( -> )
|
||||||
|
|
||||||
( theme )
|
( theme )
|
||||||
#0efc .System/r DEO2
|
#0efc System/r=!
|
||||||
#03cc .System/g DEO2
|
#03cc System/g=!
|
||||||
#03ac .System/b DEO2
|
#03ac System/b=!
|
||||||
|
|
||||||
( load file )
|
( load file )
|
||||||
#1000 .File/length DEO2
|
#1000 File/length=!
|
||||||
;srcpath .File/name DEO2
|
;srcpath File/name=!
|
||||||
MEMORY .File/load DEO2
|
MEMORY File/load=!
|
||||||
|
|
||||||
.File/success DEI2 #0000 NEQ2 ;on-success JNZ2
|
File/success*! #0000 NEQ2 ;on-success JNZ2
|
||||||
|
|
||||||
;failedtxt .Console/string DEO2
|
;failedtxt Console/string=!
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
@on-success ( -> )
|
@on-success ( -> )
|
||||||
|
|
||||||
;successtxt .Console/string DEO2
|
;successtxt Console/string=!
|
||||||
|
|
||||||
( draw image )
|
( draw image )
|
||||||
MEMORY .Screen/addr DEO2
|
MEMORY Screen/addr=!
|
||||||
#0000 #0080
|
#0000 #0080
|
||||||
&ver
|
&ver
|
||||||
( save ) OVR2 .Screen/y DEO2
|
( save ) OVR2 Screen/y=!
|
||||||
#0000 #0080
|
#0000 #0080
|
||||||
&hor
|
&hor
|
||||||
( save ) OVR2 .Screen/x DEO2
|
( save ) OVR2 Screen/x=!
|
||||||
( draw ) #41 .Screen/color DEO
|
( draw ) #41 Screen/color~!
|
||||||
( incr ) .Screen/addr DEI2 #0010 ADD2 .Screen/addr DEO2
|
( incr ) Screen/addr*! #0010 ADD2 Screen/addr=!
|
||||||
( incr ) SWP2 8+ SWP2
|
( incr ) SWP2 8+ SWP2
|
||||||
OVR2 OVR2 LTH2 ,&hor JNZ
|
OVR2 OVR2 LTH2 ,&hor JNZ
|
||||||
POP2 POP2
|
POP2 POP2
|
||||||
|
@ -56,9 +61,9 @@ BRK
|
||||||
POP2 POP2
|
POP2 POP2
|
||||||
|
|
||||||
( save file )
|
( save file )
|
||||||
#1000 .File/length DEO2
|
#1000 File/length=!
|
||||||
;dstpath .File/name DEO2
|
;dstpath File/name=!
|
||||||
MEMORY .File/save DEO2
|
MEMORY File/save=!
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,23 @@
|
||||||
( dev/mouse )
|
( dev/mouse )
|
||||||
|
|
||||||
%RTN { JMP2r }
|
%RTN { JMP2r }
|
||||||
%8+ { #0008 ADD2 }
|
|
||||||
%++ { #0001 ADD2 }
|
|
||||||
%-- { #0001 SUB2 }
|
|
||||||
%ABS2 { DUP2 #000f SFT2 EQU #04 JNZ #ffff MUL2 }
|
%ABS2 { DUP2 #000f SFT2 EQU #04 JNZ #ffff MUL2 }
|
||||||
|
|
||||||
(
|
%%^! { .% DEI } %%~! { .% DEO }
|
||||||
%%^ { .% PEK } %%= { .% POK }
|
%%*! { .% DEI2 } %%=! { .% DEO2 }
|
||||||
%%? { .% DEI } %%! { .% DEO }
|
%%^ { .% PEK } %%~ { .% POK }
|
||||||
)
|
%%* { .% PEK2 } %%= { .% POK2 }
|
||||||
|
|
||||||
%%^ { .% PEK2 } %%= { .% POK2 }
|
|
||||||
%%? { .% DEI2 } %%! { .% DEO2 }
|
|
||||||
|
|
||||||
( devices )
|
( devices )
|
||||||
|
|
||||||
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|
|00 @System [ &vector $2 &pad $6 &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 ]
|
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ]
|
||||||
|40 @Controller [ &vector $2 &button $1 &key $1 ]
|
|
||||||
|60 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &chord $1 ]
|
|60 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &chord $1 ]
|
||||||
|
|
||||||
|0000
|
|0000
|
||||||
|
|
||||||
@line [ &x0 $2 &y0 $2 &x $2 &y $2 &sx $2 &sy $2 &dx $2 &dy $2 &e1 $2 &e2 $2 ]
|
@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 ]
|
@pointer [ &x $2 &y $2 &lastx $2 &lasty $2 &state $1 ]
|
||||||
@color $1
|
@color $1
|
||||||
|
|
||||||
( program )
|
( program )
|
||||||
|
@ -33,108 +25,96 @@
|
||||||
|0100 ( -> )
|
|0100 ( -> )
|
||||||
|
|
||||||
( theme )
|
( theme )
|
||||||
#f0f0 System/r!
|
#f0f0 System/r=!
|
||||||
#f00f System/g!
|
#f00f System/g=!
|
||||||
#f000 System/b!
|
#f000 System/b=!
|
||||||
|
|
||||||
( vectors )
|
( vectors )
|
||||||
;on-mouse Mouse/vector!
|
;on-mouse Mouse/vector=!
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
@on-mouse ( -> )
|
@on-mouse ( -> )
|
||||||
|
|
||||||
;draw-cursor JSR2
|
;draw-cursor JSR2
|
||||||
|
|
||||||
( on down )
|
( on down )
|
||||||
.Mouse/state DEI #00 NEQ .pointer/state PEK #00 EQU #0101 EQU2 ,on-mouse-down JNZ
|
Mouse/state^! #00 NEQ pointer/state^ #00 EQU #0101 EQU2 ,on-mouse-down JNZ
|
||||||
|
|
||||||
( on drag )
|
( on drag )
|
||||||
.Mouse/state DEI #00 NEQ ,on-mouse-drag JNZ
|
Mouse/state^! #00 NEQ ,on-mouse-drag JNZ
|
||||||
|
Mouse/state^! pointer/state~
|
||||||
.Mouse/state DEI .pointer/state POK
|
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
@on-mouse-down ( -> )
|
@on-mouse-down ( -> )
|
||||||
|
|
||||||
( record start position )
|
( record start position )
|
||||||
Mouse/x? DUP2 pointer/x= pointer/lastx=
|
Mouse/x*! DUP2 pointer/x= pointer/lastx=
|
||||||
Mouse/y? DUP2 pointer/y= pointer/lasty=
|
Mouse/y*! DUP2 pointer/y= pointer/lasty=
|
||||||
|
Mouse/state^! pointer/state~
|
||||||
.Mouse/state DEI .pointer/state POK
|
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
@on-mouse-drag ( -> )
|
@on-mouse-drag ( -> )
|
||||||
|
|
||||||
( draw line )
|
( draw line )
|
||||||
pointer/lastx^
|
pointer/lastx*
|
||||||
pointer/lasty^
|
pointer/lasty*
|
||||||
pointer/x^
|
pointer/x*
|
||||||
pointer/y^
|
pointer/y*
|
||||||
#01 ( add mouse state ) [ .Mouse/state DEI #10 EQU #02 MUL ADD ]
|
#01 [ Mouse/state^! #10 EQU #02 MUL ADD ]
|
||||||
;draw-line JSR2
|
;draw-line JSR2
|
||||||
|
|
||||||
( record last position )
|
( record last position )
|
||||||
Mouse/x? pointer/lastx=
|
Mouse/x*! pointer/lastx=
|
||||||
Mouse/y? pointer/lasty=
|
Mouse/y*! pointer/lasty=
|
||||||
|
Mouse/state^! pointer/state~
|
||||||
.Mouse/state DEI .pointer/state POK
|
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
@draw-cursor ( -- )
|
@draw-cursor ( -- )
|
||||||
|
|
||||||
( clear last cursor )
|
( clear last cursor )
|
||||||
;clear Screen/addr!
|
;clear Screen/addr=!
|
||||||
pointer/x^ Screen/x!
|
pointer/x* Screen/x=!
|
||||||
pointer/y^ Screen/y!
|
pointer/y* Screen/y=!
|
||||||
#30 .Screen/color DEO
|
#30 Screen/color~!
|
||||||
|
|
||||||
( record pointer positions )
|
( record pointer positions )
|
||||||
Mouse/x? pointer/x=
|
Mouse/x*! pointer/x=
|
||||||
Mouse/y? pointer/y=
|
Mouse/y*! pointer/y=
|
||||||
|
|
||||||
( draw new cursor )
|
( draw new cursor )
|
||||||
;cursor Screen/addr!
|
;cursor Screen/addr=!
|
||||||
pointer/x^ Screen/x!
|
pointer/x* Screen/x=!
|
||||||
pointer/y^ Screen/y!
|
pointer/y* Screen/y=!
|
||||||
|
|
||||||
( colorize on state )
|
( colorize on state )
|
||||||
.Mouse/state DEI #00 NEQ
|
#31 [ Mouse/state^! #00 NEQ ] ADD Screen/color~!
|
||||||
#31 ADD .Screen/color DEO
|
|
||||||
|
|
||||||
RTN
|
RTN
|
||||||
|
|
||||||
@draw-line ( x1 y1 x2 y2 color -- )
|
@draw-line ( x1 y1 x2 y2 color -- )
|
||||||
|
|
||||||
( load ) .color POK line/y0= line/x0= line/y= line/x=
|
( load ) color~ line/y0= line/x0= line/y= line/x=
|
||||||
line/x0^ line/x^ SUB2 ABS2 line/dx=
|
line/x0* line/x* SUB2 ABS2 line/dx=
|
||||||
line/y0^ line/y^ SUB2 ABS2 #0000 SWP2 SUB2 line/dy=
|
line/y0* line/y* SUB2 ABS2 #0000 SWP2 SUB2 line/dy=
|
||||||
#ffff #00 line/x^ line/x0^ LTS2 #0002 MUL2 ADD2 line/sx=
|
#ffff #00 line/x* line/x0* LTS2 #0002 MUL2 ADD2 line/sx=
|
||||||
#ffff #00 line/y^ line/y0^ LTS2 #0002 MUL2 ADD2 line/sy=
|
#ffff #00 line/y* line/y0* LTS2 #0002 MUL2 ADD2 line/sy=
|
||||||
line/dx^ line/dy^ ADD2 line/e1=
|
line/dx* line/dy* ADD2 line/e1=
|
||||||
&loop
|
&loop
|
||||||
( draw )
|
( draw )
|
||||||
line/x^ Screen/x!
|
line/x* Screen/x=!
|
||||||
line/y^ Screen/y!
|
line/y* Screen/y=!
|
||||||
.color PEK
|
color^ Screen/color~!
|
||||||
.Screen/color DEO
|
line/x* line/x0* EQU2 line/y* line/y0* EQU2 #0101 EQU2 ,&end JNZ
|
||||||
line/x^ line/x0^ EQU2 line/y^ line/y0^ EQU2 #0101 EQU2 ,&end JNZ
|
line/e1* #0002 MUL2 line/e2=
|
||||||
line/e1^ #0002 MUL2 line/e2=
|
line/e2* line/dy* LTS2 ,&skipy JNZ
|
||||||
line/e2^ line/dy^ LTS2 ,&skipy JNZ
|
line/e1* line/dy* ADD2 line/e1=
|
||||||
line/e1^ line/dy^ ADD2 line/e1=
|
line/x* line/sx* ADD2 line/x=
|
||||||
line/x^ line/sx^ ADD2 line/x=
|
|
||||||
&skipy
|
&skipy
|
||||||
line/e2^ line/dx^ GTS2 ,&skipx JNZ
|
line/e2* line/dx* GTS2 ,&skipx JNZ
|
||||||
line/e1^ line/dx^ ADD2 line/e1=
|
line/e1* line/dx* ADD2 line/e1=
|
||||||
line/y^ line/sy^ ADD2 line/y=
|
line/y* line/sy* ADD2 line/y=
|
||||||
&skipx
|
&skipx
|
||||||
,&loop JMP
|
,&loop JMP
|
||||||
&end
|
&end
|
||||||
|
|
||||||
RTN
|
RTN
|
||||||
|
|
||||||
@clear [ 0000 0000 0000 0000 ]
|
@clear [ 0000 0000 0000 0000 ]
|
||||||
@cursor [ 80c0 e0f0 f8e0 1000 ]
|
@cursor [ 80c0 e0f0 f8e0 1000 ]
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
( GUI Animation )
|
( GUI Animation )
|
||||||
|
|
||||||
|
%%^! { .% DEI } %%~! { .% DEO }
|
||||||
|
%%*! { .% DEI2 } %%=! { .% DEO2 }
|
||||||
|
%%^ { .% PEK } %%~ { .% POK }
|
||||||
|
%%* { .% PEK2 } %%= { .% POK2 }
|
||||||
|
|
||||||
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|
|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 ]
|
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ]
|
||||||
|
|
||||||
|
@ -12,17 +17,14 @@
|
||||||
|0100 ( -> )
|
|0100 ( -> )
|
||||||
|
|
||||||
( theme )
|
( theme )
|
||||||
#4cfd .System/r DEO2
|
#4cfd System/r=!
|
||||||
#4cf3 .System/g DEO2
|
#4cf3 System/g=!
|
||||||
#dcf2 .System/b DEO2
|
#dcf2 System/b=!
|
||||||
|
|
||||||
( vectors )
|
( vectors )
|
||||||
;on-frame .Screen/vector DEO2
|
;on-frame Screen/vector=!
|
||||||
|
|
||||||
( starting position )
|
( starting position )
|
||||||
.Screen/width DEI2 #0002 DIV2 .dvd/x POK2
|
Screen/width*! #0002 DIV2 dvd/x=
|
||||||
.Screen/height DEI2 #0002 DIV2 .dvd/y POK2
|
Screen/height*! #0002 DIV2 dvd/y=
|
||||||
|
|
||||||
#21 ;draw-dvd JSR2
|
#21 ;draw-dvd JSR2
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
@ -30,39 +32,39 @@ BRK
|
||||||
@on-frame ( -> )
|
@on-frame ( -> )
|
||||||
|
|
||||||
( clear ) #20 ;draw-dvd JSR2
|
( clear ) #20 ;draw-dvd JSR2
|
||||||
( hit-right ) .dvd/x PEK2 .Screen/width DEI2 #0020 SUB2 EQU2
|
( case: hit-right ) dvd/x* Screen/width*! #0020 SUB2 EQU2
|
||||||
( hit-left ) .dvd/x PEK2 #0000 EQU2
|
( case: hit-left ) dvd/x* #0000 EQU2
|
||||||
#0000 EQU2 ,&no-flipx JNZ
|
#0000 EQU2 ,&no-flipx JNZ
|
||||||
.dvd/dx PEK #00 EQU .dvd/dx POK &no-flipx
|
dvd/dx^ #00 EQU dvd/dx~ &no-flipx
|
||||||
( hit-bottom ) .dvd/y PEK2 .Screen/height DEI2 #0010 SUB2 EQU2
|
( case: hit-bottom ) dvd/y* Screen/height*! #0010 SUB2 EQU2
|
||||||
( hit-top ) .dvd/y PEK2 #0000 EQU2
|
( case: hit-top ) dvd/y* #0000 EQU2
|
||||||
#0000 EQU2 ,&no-flipy JNZ
|
#0000 EQU2 ,&no-flipy JNZ
|
||||||
.dvd/dy PEK #00 EQU .dvd/dy POK &no-flipy
|
dvd/dy^ #00 EQU dvd/dy~ &no-flipy
|
||||||
( incr ) .dvd/x PEK2 #0001 #00 .dvd/dx PEK #00 EQU #fffe MUL2 ADD2 ADD2 .dvd/x POK2
|
( incr ) dvd/x* #0001 #00 dvd/dx^ #00 EQU #fffe MUL2 ADD2 ADD2 dvd/x=
|
||||||
( incr ) .dvd/y PEK2 #0001 #00 .dvd/dy PEK #00 EQU #fffe MUL2 ADD2 ADD2 .dvd/y POK2
|
( incr ) dvd/y* #0001 #00 dvd/dy^ #00 EQU #fffe MUL2 ADD2 ADD2 dvd/y=
|
||||||
( draw ) #21 ;draw-dvd JSR2
|
( draw ) #21 ;draw-dvd JSR2
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
@draw-dvd ( color -- )
|
@draw-dvd ( color -- )
|
||||||
|
|
||||||
( stash color ) STH
|
( stash ) STH
|
||||||
;dvd_icn .Screen/addr DEO2
|
;dvd_icn Screen/addr=!
|
||||||
.dvd/y PEK2 .dvd/y PEK2 #0010 ADD2
|
dvd/y* [ dvd/y* #0010 ADD2 ]
|
||||||
&ver
|
&ver
|
||||||
OVR2 .Screen/y DEO2
|
OVR2 Screen/y=!
|
||||||
.dvd/x PEK2 .dvd/x PEK2 #0020 ADD2
|
dvd/x* [ dvd/x* #0020 ADD2 ]
|
||||||
&hor
|
&hor
|
||||||
OVR2 .Screen/x DEO2
|
OVR2 Screen/x=!
|
||||||
( draw ) DUPr STHr .Screen/color DEO
|
( draw ) DUPr STHr Screen/color~!
|
||||||
( next ) .Screen/addr DEI2 #0008 ADD2 .Screen/addr DEO2
|
( next ) Screen/addr*! #0008 ADD2 Screen/addr=!
|
||||||
( incr ) SWP2 #0008 ADD2 SWP2
|
( incr ) SWP2 #0008 ADD2 SWP2
|
||||||
OVR2 OVR2 LTH2 ,&hor JNZ
|
OVR2 OVR2 LTH2 ,&hor JNZ
|
||||||
POP2 POP2
|
POP2 POP2
|
||||||
( incr ) SWP2 #0008 ADD2 SWP2
|
( incr ) SWP2 #0008 ADD2 SWP2
|
||||||
OVR2 OVR2 LTH2 ,&ver JNZ
|
OVR2 OVR2 LTH2 ,&ver JNZ
|
||||||
POP2 POP2
|
POP2 POP2
|
||||||
( destroy color ) POPr
|
( destroy ) POPr
|
||||||
|
|
||||||
JMP2r
|
JMP2r
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,6 @@ findmacro(char *name)
|
||||||
for(i = 0; i < p.mlen; ++i)
|
for(i = 0; i < p.mlen; ++i)
|
||||||
if(scmp(p.macros[i].name, name, 64))
|
if(scmp(p.macros[i].name, name, 64))
|
||||||
return &p.macros[i];
|
return &p.macros[i];
|
||||||
/* look for templated */
|
|
||||||
for(i = 0; i < p.mlen; ++i)
|
for(i = 0; i < p.mlen; ++i)
|
||||||
if(p.macros[i].name[0] == '%' && ssin(name, p.macros[i].name + 1) != -1)
|
if(p.macros[i].name[0] == '%' && ssin(name, p.macros[i].name + 1) != -1)
|
||||||
return &p.macros[i];
|
return &p.macros[i];
|
||||||
|
@ -141,7 +140,6 @@ char *template(char *src, char *dst, char *w, Macro *m)
|
||||||
scpy(src, dst, scin(src, '%') + 1);
|
scpy(src, dst, scin(src, '%') + 1);
|
||||||
scat(dst, input);
|
scat(dst, input);
|
||||||
scat(dst, src + scin(src, '%') + 1);
|
scat(dst, src + scin(src, '%') + 1);
|
||||||
printf(" Templated %s, to %s\n", w, dst);
|
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,7 +373,9 @@ cleanup(char *filename)
|
||||||
int i;
|
int i;
|
||||||
printf("Assembled %s(%d bytes), %d labels, %d macros.\n\n", filename, (p.length - TRIM), p.llen, p.mlen);
|
printf("Assembled %s(%d bytes), %d labels, %d macros.\n\n", filename, (p.length - TRIM), p.llen, p.mlen);
|
||||||
for(i = 0; i < p.llen; ++i)
|
for(i = 0; i < p.llen; ++i)
|
||||||
if(!p.labels[i].refs)
|
if(p.labels[i].name[0] >= 'A' && p.labels[i].name[0] <= 'Z')
|
||||||
|
continue; /* Ignore capitalized labels(devices) */
|
||||||
|
else if(!p.labels[i].refs && scin(p.labels[i].name, '/') > 0)
|
||||||
printf("--- Unused label: %s\n", p.labels[i].name);
|
printf("--- Unused label: %s\n", p.labels[i].name);
|
||||||
for(i = 0; i < p.mlen; ++i)
|
for(i = 0; i < p.mlen; ++i)
|
||||||
if(!p.macros[i].refs)
|
if(!p.macros[i].refs)
|
||||||
|
|
Loading…
Reference in a new issue