removed RTN macros
This commit is contained in:
parent
ecc8ac8d30
commit
4aa4b7095c
|
@ -57,9 +57,8 @@ publish them in itch.io
|
|||
* 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
|
||||
* in {uxn tutorial day 6} we use constants, and HALF, DOUBLE
|
||||
|
||||
|
||||
### pending
|
||||
|
|
|
@ -463,7 +463,7 @@ JMP2r
|
|||
|
||||
note that the draw-pointer label is accompanied by the stack state notation ( -- ) to indicate that, in this case, it doesn't consume or produce contents from or to the working stack.
|
||||
|
||||
also note how this subroutine ends with a RTN (JMP2r) that indicates that the flow of the program will return to the position after the subroutine was called.
|
||||
also note how this subroutine ends with a JMP2r that indicates that the flow of the program will return to the position after the subroutine was called.
|
||||
|
||||
## notes on subroutines as "functions"
|
||||
|
||||
|
|
|
@ -36,9 +36,6 @@ let's start with the following program as a template. it includes the data for a
|
|||
|20 @Screen [ &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 ]
|
||||
|80 @Controller [ &vector $2 &button $1 &key $1 ]
|
||||
|
||||
( macros )
|
||||
%RTN { JMP2r }
|
||||
|
||||
( main program )
|
||||
|0100
|
||||
@setup
|
||||
|
@ -180,9 +177,6 @@ the following shows our program in context, completely filling the first row of
|
|||
|20 @Screen [ &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 ]
|
||||
|80 @Controller [ &vector $2 &button $1 &key $1 ]
|
||||
|
||||
( macros )
|
||||
%RTN { JMP2r }
|
||||
|
||||
( main program )
|
||||
|0100
|
||||
@setup
|
||||
|
@ -309,7 +303,7 @@ now we can just wrap these nested loops inside a subroutine:
|
|||
GTH2k ( is the limit greater than y? aka is y less than the limit ? )
|
||||
,&loop-y JCN ( jump if y is less than the limit )
|
||||
POP2 POP2 ( remove y and limit )
|
||||
RTN
|
||||
JMP2r
|
||||
```
|
||||
|
||||
that we can simply call from our initialization subroutine:
|
||||
|
@ -514,7 +508,7 @@ for this, we can configure it so that we draw two tiles in a row, automatically
|
|||
STHr
|
||||
( draw three rows: )
|
||||
.Screen/sprite DEOk DEOk DEO
|
||||
RTN
|
||||
JMP2r
|
||||
```
|
||||
|
||||
that's it!
|
||||
|
@ -614,7 +608,6 @@ omitting the definition of the draw-background and draw-paddle subroutines, and
|
|||
|80 @Controller [ &vector $2 &button $1 &key $1 ]
|
||||
|
||||
( macros )
|
||||
%RTN { JMP2r }
|
||||
%HALF2 { #01 SFT2 } ( short -- short/2 )
|
||||
|
||||
( constants )
|
||||
|
@ -747,7 +740,7 @@ all of this can go inside its own subroutine for readability purposes:
|
|||
|
||||
&end
|
||||
POP ( pop duplicate value of button )
|
||||
RTN
|
||||
JMP2r
|
||||
```
|
||||
|
||||
### complete procedure
|
||||
|
@ -854,7 +847,7 @@ let's have the subroutine receive the color as an argument, so that we can clear
|
|||
.Screen/sprite
|
||||
( draw two rows: )
|
||||
DEOk DEO
|
||||
RTN
|
||||
JMP2r
|
||||
```
|
||||
|
||||
notice how we are using a very similar approach to the draw-paddle subroutine!
|
||||
|
@ -1023,7 +1016,7 @@ based on what we just discussed, we can start our update-ball subroutine with th
|
|||
.ball/speed-y LDZ2 .ball/y LDZ2
|
||||
ADD2 ( add them together )
|
||||
.ball/y STZ2 ( store new y )
|
||||
RTN
|
||||
JMP2r
|
||||
```
|
||||
|
||||
if we complement our setup routine with the initial speeds, we'll be able to see the ball moving:
|
||||
|
@ -1156,7 +1149,7 @@ our update-ball subroutine looks like the following right now:
|
|||
&set-negative-speed
|
||||
BALL-NEGATIVE-SPEED .ball/speed-y STZ2
|
||||
&continue
|
||||
RTN
|
||||
JMP2r
|
||||
```
|
||||
|
||||
you can test it using different initial speed-y inside setup. the ball should be bouncing at the top and bottom now! :)
|
||||
|
@ -1291,7 +1284,7 @@ for the right paddle we will do the same as above, but changing the comparisons
|
|||
,&finish JMP
|
||||
|
||||
&finish
|
||||
RTN
|
||||
JMP2r
|
||||
```
|
||||
|
||||
that should be it! you can find the complete update-ball subroutine below!
|
||||
|
@ -1309,7 +1302,7 @@ here we'll just define a reset subroutine that returns the ball to the middle of
|
|||
HALF2 .ball/x STZ2
|
||||
.Screen/height DEI2 BALL-SIZE SUB2
|
||||
HALF2 .ball/y STZ2
|
||||
RTN
|
||||
JMP2r
|
||||
```
|
||||
|
||||
it would be interesting to have some mechanism to also change the speed: maybe based on the framecount, in the position of the paddles, or whatever else you choose.
|
||||
|
@ -1332,7 +1325,6 @@ here's all of the code we wrote today!
|
|||
|80 @Controller [ &vector $2 &button $1 &key $1 ]
|
||||
|
||||
( macros )
|
||||
%RTN { JMP2r }
|
||||
%HALF2 { #01 SFT2 } ( short -- short/2 )
|
||||
%DOUBLE2 { #10 SFT2 }
|
||||
|
||||
|
@ -1425,7 +1417,7 @@ BRK
|
|||
HALF2 .ball/x STZ2
|
||||
.Screen/height DEI2 BALL-SIZE SUB2
|
||||
HALF2 .ball/y STZ2
|
||||
RTN
|
||||
JMP2r
|
||||
```
|
||||
|
||||
## ball-related
|
||||
|
@ -1524,7 +1516,7 @@ RTN
|
|||
,&finish JMP
|
||||
|
||||
&finish
|
||||
RTN
|
||||
JMP2r
|
||||
```
|
||||
|
||||
### draw-ball
|
||||
|
@ -1547,7 +1539,7 @@ RTN
|
|||
.Screen/sprite
|
||||
( draw two rows: )
|
||||
DEOk DEO
|
||||
RTN
|
||||
JMP2r
|
||||
```
|
||||
|
||||
## paddle-related
|
||||
|
@ -1590,7 +1582,7 @@ RTN
|
|||
|
||||
&end
|
||||
POP ( pop duplicate value of button )
|
||||
RTN
|
||||
JMP2r
|
||||
```
|
||||
|
||||
## draw-paddle
|
||||
|
@ -1614,7 +1606,7 @@ RTN
|
|||
STHr .Screen/sprite
|
||||
( draw three rows: )
|
||||
DEOk DEOk DEO
|
||||
RTN
|
||||
JMP2r
|
||||
```
|
||||
|
||||
## draw-background
|
||||
|
@ -1642,7 +1634,7 @@ RTN
|
|||
GTH2k ( is the limit greater than y? aka is y less than the limit ? )
|
||||
,&loop-y JCN ( jump if y is less than the limit )
|
||||
POP2 POP2 ( remove y and limit )
|
||||
RTN
|
||||
JMP2r
|
||||
```
|
||||
|
||||
## data
|
||||
|
|
Loading…
Reference in New Issue