From ecc8ac8d308baf3b4bd2d22123aa2bced67214a9 Mon Sep 17 00:00:00 2001 From: sejo Date: Thu, 28 Mar 2024 19:37:44 +0100 Subject: [PATCH] update roadmap with macro stuff --- src/roadmap.gmo | 13 ++++++++++++- src/uxn_tutorial_day_3.gmo | 14 ++------------ src/uxn_tutorial_day_5.gmo | 17 +++++------------ 3 files changed, 19 insertions(+), 25 deletions(-) diff --git a/src/roadmap.gmo b/src/roadmap.gmo index 1bb5506..75b7136 100644 --- a/src/roadmap.gmo +++ b/src/roadmap.gmo @@ -51,10 +51,21 @@ publish them in itch.io * {uxn tutorial day 6} auto sprite flipping => https://lists.sr.ht/~rabbits/uxn/%3CCAE2DaSQQMb8XVfsn2NSsXQO+-0m2t4U2GD7nYD3GBUO4GPeTxQ%40mail.gmail.com%3E Whole auto sprite flipping +### removing macros +* in {uxn tutorial day 1} they are deeply embedded as a learning block, so they need some rewriting +* in {uxn tutorial day 2} they are used to increment coordinates and repeat the drawing of pixels or sprites. +* in {uxn tutorial day 2} we also have them as example for HALF and HALF2. +* there are some from {uxn tutorial day 4} and onwards that are used as constants: replace these with enums! +* in {uxn tutorial day 4} we introduce MOD, 8MOD, TO-SHORT +* in {uxn tutorial day 5} we introduce and use RTN +* in {uxn tutorial day 5} we re-work MOD +* in {uxn tutorial day 6} we use RTN and use constants, and HALF, DOUBLE + + ### pending * remove square brackets in devices * update images (to do: emulator needs a patch) -* remove macros + ### further possible changes * make a folder of examples diff --git a/src/uxn_tutorial_day_3.gmo b/src/uxn_tutorial_day_3.gmo index 045936c..14022e0 100644 --- a/src/uxn_tutorial_day_3.gmo +++ b/src/uxn_tutorial_day_3.gmo @@ -425,7 +425,7 @@ we'll be using these instructions in many different ways during the following da the following are some examples based on snippets of code that we discussed already. -keep in mind that using these instructions may contribute to a code that is hard to follow or read, so it will be always a good idea to use them within macros or to have comments in the code explaining what's happening :) +keep in mind that using these instructions may contribute to a code that is hard to follow or read, so it will be always a good idea to have comments in the code explaining what's happening :) ### ascii digit: duplicate and swap @@ -719,17 +719,7 @@ BRK @square ff81 8181 8181 81ff ``` -some possibilities for you to practice: - -* modify the code so that it will also respond to you pressing more than one arrow at the same time. -* convert the increments and decrements of the coordinates to macros that take the address of the port as input, and perform an equivalent operation. both of these lines should work using the same macro: - -``` -.Screen/x INCREMENT -.Screen/y INCREMENT -``` - -remember that .Screen/x is a literal address in the zero page, i.e. it pushes a byte corresponding to the address of the Screen/x sublabel :) +as a possible exercise for you, modify the code so that it will also respond to you pressing more than one arrow at the same time. # practice possibilities diff --git a/src/uxn_tutorial_day_5.gmo b/src/uxn_tutorial_day_5.gmo index 04a55e7..76d8121 100644 --- a/src/uxn_tutorial_day_5.gmo +++ b/src/uxn_tutorial_day_5.gmo @@ -397,17 +397,13 @@ additionally, as the addresses pushed by JSR are shorts, we need to activate the JMP2r ( jump to the absolute address at the top of the return stack ) ``` -in many uxntal programs you will see this instruction written as a macro, RTN (return): +at some point in time, this instruction was written as a macro, RTN, which stood for "return". -``` -%RTN { JMP2r } -``` - -we can finish a subroutine using this macro in order to "return" to the position in the program after the corresponding JSR. +we can finish a subroutine using this instruction in order to "return" to the position in the program after the corresponding JSR. ## complete example using subroutines -this is the hello-pointer.tal program, but using draw-pointer as a subroutine that is "called" with JSR2 and that ends with RTN: +this is the hello-pointer.tal program, but using draw-pointer as a subroutine that is "called" with JSR2 and that ends with JMP2r: ``` ( hello-pointer.tal ) @@ -417,9 +413,6 @@ this is the hello-pointer.tal program, but using draw-pointer as a subroutine th |20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 ] |90 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &pad $3 &scrollx $2 &scrolly $2 ] -( macros ) -%RTN { JMP2r } - ( zero page ) |0000 @pointer [ &x $2 &y $2 ] @@ -463,7 +456,7 @@ BRK ( draw sprite with color 2 in foreground ) #4a .Screen/sprite DEO -RTN +JMP2r @pointer_icn [ 80c0 e0f0 f8e0 1000 ] ``` @@ -553,7 +546,7 @@ a caret (^) after a value name indicates that it corresponds to a short. NEQ ( ws: length count flag / rs: ) ,&loop JCN ( ws: length count / rs: ) POP2 ( ws: / rs: ) -RTN +JMP2r ``` ### calling