uxneria/scroller.tal

115 lines
5.6 KiB
Tal

( a blank file )
%+ { ADD } %- { SUB } %/ { DIV }
%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 } %// { DIV2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
%DEBUG { ;print-hex JSR2 #0a .Console/write DEO }
%DEBUG2 { SWP ;print-hex JSR2 ;print-hex JSR2 #0a .Console/write DEO }
%MOD { DIVk MUL SUB }
%MOD2 { DIV2k MUL2 SUB2 }
%RTN { JMP2r }
( 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 ]
|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 ]
|80 @Controller [ &vector $2 &button $1 &key $1 ]
|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 &read $2 &write $2 ]
|b0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ]
( variables )
|0000
@scrollpos $2
@loop $2
( program )
|0100 ( -> )
#0f00 .System/r DEO2
#00f0 .System/g DEO2
#000f .System/b DEO2
.Screen/height DEI2 #0002 DIV2 .Screen/y DEO2
.Screen/width DEI2 .scrollpos STZ2
;redraw/run .Screen/vector DEO2
BRK
@redraw ( -> )
&charpos $2
&run
#0000 ;&charpos STA2
#0000 STH2
&clearloop
STH2rk ;text ADD2 LDA #00 EQU ,&clearend JCN ( end of string )
( draw new )
;font .Screen/addr DEO2
;&charpos LDA2 .scrollpos LDZ2 #0002 ADD2 ADD2 .Screen/x DEO2
( calculate Y position )
STH2rk
.scrollpos LDZ2 #0002 ADD2 ADD2
#0004 DIV2 #0014 MOD2 ;wave ADD2 LDA2
.Screen/height DEI2 #0002 DIV2 ADD2
.Screen/y DEO2 ( do wave motion )
#01 .Screen/sprite DEO
STH2r #0001 ADD2 STH2 ( increment counter )
;&charpos LDA2 #0008 ADD2 ;&charpos STA2 ( increment character position )
,&clearloop JMP
POP2r
&clearend
POP2r
#0000 ;&charpos STA2
#0000 STH2
&loop
STH2rk ;text ADD2 LDA #00 EQU ,&end JCN ( end of string )
( draw new )
;font #0008 ;text STH2rk ADD2 LDA #20 SUB #00 SWP MUL2 ADD2 .Screen/addr DEO2
;&charpos LDA2 .scrollpos LDZ2 ADD2 .Screen/x DEO2
( calculate Y position )
STH2rk
.scrollpos LDZ2 ADD2
#0004 DIV2 #0014 MOD2 ;wave ADD2 LDA2
.Screen/height DEI2 #0002 DIV2 ADD2
.Screen/y DEO2 ( do wave motion )
STH2rk SWP POP ( get low byte of counter )
#03 MOD #01 ADD .Screen/sprite DEO
STH2r #0001 ADD2 STH2 ( increment counter )
;&charpos LDA2 #0008 ADD2 ;&charpos STA2 ( increment character position )
,&loop JMP
&end
.scrollpos LDZ2 #0000 STH2r #0008 MUL2 SUB2 EQU2 ,&resetscroll JCN
.scrollpos LDZ2 #0002 SUB2 .scrollpos STZ2 ( scroll forward )
BRK
&resetscroll
.Screen/width DEI2 .scrollpos STZ2
BRK
@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
@text 'n 'i 20 'l 'i 20 's 'i 't 'e 'l 'e 'n 20 't 'a 'w 'a 20 'k 'e 'p 'e 'k 'e 'n 20 'i 'l 'o 20 'V 'a 'r 'v 'a 'r 'a 20 'a 00
@wave 0000 0002 0004 0008 000b 000f 000b 0008 0004 0002
@font ( bbcmicro1 )
0000 0000 0000 0000 1818 1818 1800 1800
6c6c 6c00 0000 0000 3636 7f36 7f36 3600
0c3f 683e 0b7e 1800 6066 0c18 3066 0600
386c 6c38 6d66 3b00 0c18 3000 0000 0000
0c18 3030 3018 0c00 3018 0c0c 0c18 3000
0018 7e3c 7e18 0000 0018 187e 1818 0000
0000 0000 0018 1830 0000 007e 0000 0000
0000 0000 0018 1800 0006 0c18 3060 0000
3c66 6e7e 7666 3c00 1838 1818 1818 7e00
3c66 060c 1830 7e00 3c66 061c 0666 3c00
0c1c 3c6c 7e0c 0c00 7e60 7c06 0666 3c00
1c30 607c 6666 3c00 7e06 0c18 3030 3000
3c66 663c 6666 3c00 3c66 663e 060c 3800
0000 1818 0018 1800 0000 1818 0018 1830
0c18 3060 3018 0c00 0000 7e00 7e00 0000
3018 0c06 0c18 3000 3c66 0c18 1800 1800
3c66 6e6a 6e60 3c00 3c66 667e 6666 6600
7c66 667c 6666 7c00 3c66 6060 6066 3c00
786c 6666 666c 7800 7e60 607c 6060 7e00
7e60 607c 6060 6000 3c66 606e 6666 3c00
6666 667e 6666 6600 7e18 1818 1818 7e00
3e0c 0c0c 0c6c 3800 666c 7870 786c 6600
6060 6060 6060 7e00 6377 7f6b 6b63 6300
6666 767e 6e66 6600 3c66 6666 6666 3c00
7c66 667c 6060 6000 3c66 6666 6a6c 3600
7c66 667c 6c66 6600 3c66 603c 0666 3c00
7e18 1818 1818 1800 6666 6666 6666 3c00
6666 6666 663c 1800 6363 6b6b 7f77 6300
6666 3c18 3c66 6600 6666 663c 1818 1800
7e06 0c18 3060 7e00 7c60 6060 6060 7c00
0060 3018 0c06 0000 3e06 0606 0606 3e00
183c 6642 0000 0000 0000 0000 0000 00ff
1c36 307c 3030 7e00 0000 3c06 3e66 3e00
6060 7c66 6666 7c00 0000 3c66 6066 3c00
0606 3e66 6666 3e00 0000 3c66 7e60 3c00
1c30 307c 3030 3000 0000 3e66 663e 063c
6060 7c66 6666 6600 1800 3818 1818 3c00
1800 3818 1818 1870 6060 666c 786c 6600
3818 1818 1818 3c00 0000 367f 6b6b 6300
0000 7c66 6666 6600 0000 3c66 6666 3c00
0000 7c66 667c 6060 0000 3e66 663e 0607
0000 6c76 6060 6000 0000 3e60 3c06 7c00
3030 7c30 3030 1c00 0000 6666 6666 3e00
0000 6666 663c 1800 0000 636b 6b7f 3600
0000 663c 183c 6600 0000 6666 663e 063c
0000 7e0c 1830 7e00 0c18 1870 1818 0c00
1818 1800 1818 1800 3018 180e 1818 3000
316b 4600 0000 0000 ffff ffff ffff ffff