uxn

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

commit 755efc4fbde6952b9b0a720d791385fcce64b795
parent 41f7eaed6ce2185dfcd7c49245fccce886f692dc
Author: Devine Lu Linvega <aliceffekt@gmail.com>
Date:   Fri, 27 May 2022 20:12:59 -0700

Minor changes to a few example projects

Diffstat:
Mprojects/examples/blank.tal | 50+++++++-------------------------------------------
Mprojects/examples/demos/bunnymark.tal | 19+++++++++----------
Mprojects/examples/demos/drool.tal | 2+-
Mprojects/examples/demos/life.tal | 6+++---
Mprojects/examples/demos/logic.tal | 2+-
Mprojects/examples/demos/piano.tal | 2+-
6 files changed, 22 insertions(+), 59 deletions(-)

diff --git a/projects/examples/blank.tal b/projects/examples/blank.tal @@ -1,30 +1,5 @@ ( a blank file ) -%+ { ADD } %- { SUB } %* { MUL } %/ { DIV } -%< { LTH } %> { GTH } %= { EQU } %! { NEQ } -%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 } -%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 } - -%2* { #10 SFT } %2/ { #01 SFT } %2** { #10 SFT2 } %2// { #01 SFT2 } -%4* { #20 SFT } %4/ { #02 SFT } %4** { #20 SFT2 } %4// { #02 SFT2 } -%8* { #30 SFT } %8/ { #03 SFT } %8** { #30 SFT2 } %8// { #03 SFT2 } -%10* { #40 SFT } %10/ { #04 SFT } %10** { #40 SFT2 } %10// { #04 SFT2 } -%20* { #50 SFT } %20/ { #05 SFT } %20** { #50 SFT2 } %20// { #05 SFT2 } - -%2MOD { #01 AND } %2MOD2 { #0001 AND2 } -%4MOD { #03 AND } %4MOD2 { #0003 AND2 } -%8MOD { #07 AND } %8MOD2 { #0007 AND2 } -%10MOD { #0f AND } %10MOD2 { #000f AND2 } - -%HALT { #010f DEO } -%EMIT { #18 DEO } -%DEBUG { ;print/byte JSR2 #0a EMIT } -%DEBUG2 { ;print/short JSR2 #0a EMIT } - -%RTN { JMP2r } - -( devices ) - |00 @System &vector $2 &wst $1 &rst $1 &eaddr $2 &ecode $1 &pad $1 &r $2 &g $2 &b $2 &debug $1 &halt $1 |10 @Console &vector $2 &read $1 &pad $5 &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 @@ -55,27 +30,17 @@ BRK @print ( short* -- ) - &short ( short* -- ) SWP ,&byte JSR + SWP ,&byte JSR &byte ( byte -- ) DUP #04 SFT ,&char JSR - &char ( char -- ) #0f AND DUP #09 GTH #27 MUL ADD #30 ADD EMIT - -RTN - -@print-dec ( value* -- ) - - #2710 DIV2k DUP #30 ADD #18 DEO MUL2 SUB2 - #03e8 DIV2k DUP #30 ADD #18 DEO MUL2 SUB2 - #0064 DIV2k DUP #30 ADD #18 DEO MUL2 SUB2 - #000a DIV2k DUP #30 ADD #18 DEO MUL2 SUB2 - #30 ADD #18 DEO POP + &char ( char -- ) #0f AND DUP #09 GTH #27 MUL ADD #30 ADD #18 DEO -RTN +JMP2r -@print-str ( string* -- ) +@print-str ( str* -- ) - #0001 -- &while - INC2 LDAk DUP #18 DEO ,&while JCN + LDAk #18 DEO + INC2 LDAk ,&while JCN POP2 -RTN -\ No newline at end of file +JMP2r diff --git a/projects/examples/demos/bunnymark.tal b/projects/examples/demos/bunnymark.tal @@ -26,7 +26,7 @@ ( draw "FPS:" and "BUNNIES:" and instructions labels ) .Screen/width DEI2 #0046 SUB2 #0008 ;text/fps #42 ;draw-str JSR2 #0004 #0008 ;text/bunnies #42 ;draw-str JSR2 - .Screen/width DEI2 #0002 DIV2 #0050 SUB2 #0008 ;text/instructions #43 ;draw-str JSR2 + .Screen/width DEI2 #01 SFT2 #0050 SUB2 #0008 ;text/instructions #43 ;draw-str JSR2 #0028 #0008 #0000 ;draw-dec JSR2 ( seed prng ) @@ -36,7 +36,6 @@ BRK @on-frame ( -> ) - ( frames++ ) .frames LDZ2k INC2 ROT STZ2 .Date/second DEI .last LDZ EQU ,&post-fps-update JCN @@ -75,12 +74,12 @@ BRK ( clear the old sprite location ) ( top ) [ LDA2k ] #05 SFT2 .Screen/x DEO2 - [ DUP2 #0002 ADD2 LDA2 ] #05 SFT2 .Screen/y DEO2 + [ INC2k INC2 LDA2 ] #05 SFT2 .Screen/y DEO2 #00 ;draw-sprite JSR2 ( move the sprite by its velocity ) [ LDA2k ] [ OVR2 #0004 ADD2 LDA2 ] ADD2 OVR2 STA2 - [ DUP2 #0002 ADD2 LDA2 ] [ OVR2 #0006 ADD2 LDA2 ] ADD2 OVR2 #0002 ADD2 STA2 + [ INC2k INC2 LDA2 ] [ OVR2 #0006 ADD2 LDA2 ] ADD2 OVR2 INC2 INC2 STA2 ( check for right wall collision + bounce x ) [ DUP2 #0004 ADD2 LDA2 ] #0f SFT2 #0001 EQU2 ,&skip-max-x JCN @@ -89,7 +88,7 @@ BRK &skip-max-x ( check for bottom wall collision + bounce y ) [ DUP2 #0006 ADD2 LDA2 ] #0f SFT2 #0001 EQU2 ,&skip-max-y JCN - [ DUP2 #0002 ADD2 LDA2 ] #05 SFT2 #0008 ADD2 [ .Screen/height DEI2 ] LTH2 ,&skip-max-y JCN + [ INC2k INC2 LDA2 ] #05 SFT2 #0008 ADD2 [ .Screen/height DEI2 ] LTH2 ,&skip-max-y JCN [ DUP2 #0006 ADD2 LDA2 ] #ffff MUL2 [ OVR2 #0006 ADD2 STA2 ] &skip-max-y ( check for left wall collision + bounce x ) @@ -97,17 +96,17 @@ BRK [ DUP2 #0004 ADD2 LDA2 ] #ffff MUL2 [ OVR2 #0004 ADD2 STA2 ] &skip-min-x ( check for top wall collision + bounce x ) - [ DUP2 #0002 ADD2 LDA2 ] #0f SFT2 #0000 EQU2 ,&skip-min-y JCN + [ INC2k INC2 LDA2 ] #0f SFT2 #0000 EQU2 ,&skip-min-y JCN [ DUP2 #0006 ADD2 LDA2 ] #ffff MUL2 [ OVR2 #0006 ADD2 STA2 ] &skip-min-y - ( ( apply gravity ) ) + ( apply gravity ) [ DUP2 #0006 ADD2 LDA2 ] #0004 ADD2 OVR2 #0006 ADD2 STA2 ( draw the sprite ) ( top ) [ LDA2k ] #05 SFT2 .Screen/x DEO2 - [ #0002 ADD2 LDA2 ] #05 SFT2 .Screen/y DEO2 + [ INC2 INC2 LDA2 ] #05 SFT2 .Screen/y DEO2 #85 ,draw-sprite JSR JMP2r @@ -130,7 +129,7 @@ JMP2r DUP2 #30 SFT2 ;sprite/array ADD2 ( populate the new bunny's x/y/xvel/yvel with random values ) #00 [ ;rand JSR2 ] OVR2 STA2 - [ ;rand JSR2 #1f AND ] [ ;rand JSR2 ] OVR2 #0002 ADD2 STA2 + [ ;rand JSR2 #1f AND ] [ ;rand JSR2 ] OVR2 INC2 INC2 STA2 #00 [ ;rand JSR2 #7f AND ] OVR2 #0004 ADD2 STA2 #00 [ ;rand JSR2 #7f AND ] OVR2 #0006 ADD2 STA2 ( pop ptr to bunny data ) POP2 @@ -186,7 +185,7 @@ JMP2r DUP2 #0001 SUB2 #30 SFT2 ;sprite/array ADD2 ( top ) [ LDA2k ] #05 SFT2 .Screen/x DEO2 - [ DUP2 #0002 ADD2 LDA2 ] #05 SFT2 .Screen/y DEO2 + [ INC2k INC2 LDA2 ] #05 SFT2 .Screen/y DEO2 ( clear ) #00 ;draw-sprite JSR2 POP2 diff --git a/projects/examples/demos/drool.tal b/projects/examples/demos/drool.tal @@ -93,7 +93,7 @@ DUP2 #00 ,set-occupied JSR ;&possible-moves ( x y possible* / addr* ) OVR2 #01 SUB ,&check-move JSR ( up ) - OVR2 #01 ADD ,&check-move JSR ( down ) + OVR2 INC INC ,&check-move JSR ( down ) OVR2 #0100 SUB2 ,&check-move JSR ( left ) OVR2 #0100 ADD2 ,&check-move JSR ( right ) ;&possible-moves SUB2 ( x y num-possible-times-2* / addr* ) diff --git a/projects/examples/demos/life.tal b/projects/examples/demos/life.tal @@ -124,8 +124,8 @@ JMP2r @run-cell ( x y -- ) - ( x y ) DUP2 - ( neighbours ) DUP2 ;get-neighbours JSR2 + ( x y ) DUP2k + ( neighbours ) ;get-neighbours JSR2 ( state ) ROT ROT ;get-cell JSR2 #00 EQU ,&dead JCN DUP #02 LTH ,&dies JCN @@ -219,7 +219,7 @@ JMP2r @within-rect ( x* y* rect -- flag ) STH - ( y < rect.y1 ) DUP2 STHkr #02 ADD LDZ2 LTH2 ,&skip JCN + ( y < rect.y1 ) DUP2 STHkr INC INC LDZ2 LTH2 ,&skip JCN ( y > rect.y2 ) DUP2 STHkr #06 ADD LDZ2 GTH2 ,&skip JCN SWP2 ( x < rect.x1 ) DUP2 STHkr LDZ2 LTH2 ,&skip JCN diff --git a/projects/examples/demos/logic.tal b/projects/examples/demos/logic.tal @@ -1,4 +1,4 @@ -( a blank file ) +( logic ) %+ { ADD } %- { SUB } %/ { DIV } %< { LTH } %> { GTH } %= { EQU } %! { NEQ } diff --git a/projects/examples/demos/piano.tal b/projects/examples/demos/piano.tal @@ -392,7 +392,7 @@ JMP2r @within-rect ( x* y* rect -- flag ) STH - ( y < rect.y1 ) DUP2 STHkr #02 ADD LDZ2 LTH2 ,&skip JCN + ( y < rect.y1 ) DUP2 STHkr INC INC LDZ2 LTH2 ,&skip JCN ( y > rect.y2 ) DUP2 STHkr #06 ADD LDZ2 GTH2 ,&skip JCN SWP2 ( x < rect.x1 ) DUP2 STHkr LDZ2 LTH2 ,&skip JCN