0
0
Fork 0
mirror of https://git.sr.ht/~rabbits/uxn synced 2024-11-19 20:35:10 +00:00
uxn/projects/examples/blank.tal

95 lines
2.7 KiB
Tal
Raw Normal View History

2021-03-30 16:28:11 +00:00
( a blank file )
%+ { ADD } %- { SUB } %/ { DIV }
2021-05-06 03:16:27 +00:00
%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 } %// { DIV2 }
2021-05-06 03:16:27 +00:00
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
2021-07-04 03:24:36 +00:00
%DEBUG { ;print-hex JSR2 #0a .Console/write DEO }
%DEBUG2 { SWP ;print-hex JSR2 ;print-hex JSR2 #0a .Console/write DEO }
%RTN { JMP2r }
2021-05-06 03:16:27 +00:00
2021-03-30 16:28:11 +00:00
( devices )
|00 @System [ &vector $2 &wst $1 &rst $1 &pad $4 &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 &pad $2 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 ]
2021-07-29 22:31:09 +00:00
|30 @Audio0 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
|40 @Audio1 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
|50 @Audio2 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
|60 @Audio3 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
2021-04-26 17:52:46 +00:00
|80 @Controller [ &vector $2 &button $1 &key $1 ]
2021-07-29 22:31:09 +00:00
|90 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &wheel $1 ]
|a0 @File [ &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &load $2 &save $2 ]
2021-07-29 22:31:09 +00:00
|b0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ]
2021-04-21 20:13:39 +00:00
( variables )
|0000
2021-07-04 03:24:36 +00:00
@lista $3
@listb $3
@listc $3
2021-04-21 20:13:39 +00:00
( program )
|0100 ( -> )
2021-03-30 16:28:11 +00:00
2021-07-04 03:24:36 +00:00
( theme )
#0fe5 .System/r DEO2
#0fc5 .System/g DEO2
#0f25 .System/b DEO2
2021-08-26 22:27:18 +00:00
#01 .lista STZ
#02 .lista INC STZ
2021-07-04 03:24:36 +00:00
#03 .lista #02 + STZ
2021-08-26 22:27:18 +00:00
#10 .listb STZ
#20 .listb INC STZ
2021-07-04 03:24:36 +00:00
#30 .listb #02 + STZ
.lista .listb .listc ;add-lists-loop JSR2
2021-08-26 22:27:18 +00:00
.listc LDZ DEBUG
.listc INC LDZ DEBUG
2021-07-04 03:24:36 +00:00
.listc #02 + LDZ DEBUG
BRK
( Write a Forth word to add together two integer
vectors (a.k.a. arrays) of three elements each. )
@add-lists-linear ( a b c -- )
STH
( a[0] b[0] + ) LDZk STH SWP LDZk STHr + STHkr STZ
2021-08-26 22:27:18 +00:00
( a[1] b[1] + ) INC LDZk STH SWP INC LDZk STHr + STHkr INC STZ
( a[2] b[2] + ) INC LDZ SWP INC LDZ + STHr #02 + STZ
2021-07-04 03:24:36 +00:00
RTN
@add-lists-loop ( a b c -- )
STH
#00 #03
&loop
( get incr ) OVR STH
( get a[x] ) OVR2 STHkr ADD LDZ
( get b[x] ) SWP STHkr ADD LDZ
( set c[x] ) ADD STHr STHkr ADD STZ
2021-08-26 22:27:18 +00:00
( incr ) SWP INC SWP
2021-07-04 03:24:36 +00:00
LTHk ,&loop JCN
POP2 POP2 POPr
2021-04-23 02:57:47 +00:00
2021-07-04 03:24:36 +00:00
JMP2r
2021-04-23 02:57:47 +00:00
2021-07-04 03:24:36 +00:00
@print-hex ( value -- )
STHk #04 SFT ,&parse JSR .Console/write DEO
STHr #0f AND ,&parse JSR .Console/write DEO
RTN
&parse ( value -- char )
DUP #09 GTH ,&above JCN #30 ADD RTN &above #09 SUB #60 ADD RTN
2021-04-23 02:57:47 +00:00
2021-07-04 03:24:36 +00:00
RTN