uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit 1b4623be1bdfadec0a7cf7f33e861b63da4eb2f1
parent dad55324aafcf1fe9bb6f9f968d28f9d67abc86c
Author: neauoire <aliceffekt@gmail.com>
Date:   Thu, 22 Apr 2021 19:57:47 -0700

Templated examples

Diffstat:
Mbuild.sh | 2+-
Metc/usm.sublime-syntax | 76+++++++++++++++++++++++++++++++++++++++++++++++-----------------------------
Mprojects/examples/blank.usm | 30++++++++++++++++++++++--------
Mprojects/examples/dev.audio.usm | 67+++++++++++++++++++++++++++++++++----------------------------------
Mprojects/examples/dev.controller.buttons.usm | 61++++++++++++++++++++++++++++++++-----------------------------
Mprojects/examples/dev.controller.keys.usm | 38++++++++++++++++++++------------------
Mprojects/examples/dev.file.usm | 39++++++++++++++++++++++-----------------
Mprojects/examples/dev.mouse.usm | 124+++++++++++++++++++++++++++++++++----------------------------------------------
Mprojects/examples/gui.animation.usm | 54++++++++++++++++++++++++++++--------------------------
Msrc/assembler.c | 6+++---
10 files changed, 260 insertions(+), 237 deletions(-)

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