(examples) Housekeeping
This commit is contained in:
parent
d4ee3a4760
commit
559d2ae8f2
|
@ -20,7 +20,7 @@
|
|||
#0f0f .System/b DEO2
|
||||
( find center )
|
||||
.Screen/width DEI2 #01 SFT2 .center/x STZ2
|
||||
.Screen/height DEI2 #01 SFT2 .center/y STZ2
|
||||
.Screen/height DEI2 #01 SFT2 #0020 ADD2 .center/y STZ2
|
||||
( place controller )
|
||||
#0068 .frame/w STZ2
|
||||
#0030 .frame/h STZ2
|
||||
|
@ -33,15 +33,15 @@
|
|||
( frame )
|
||||
.frame/x0 LDZ2 .frame/y0 LDZ2
|
||||
.frame/x1 LDZ2 .frame/y1 LDZ2
|
||||
#03 ;line-rect JSR2
|
||||
#03 line-rect
|
||||
|
||||
,draw-controller JSR
|
||||
draw-controller
|
||||
|
||||
BRK
|
||||
|
||||
@on-button ( -> )
|
||||
|
||||
,draw-controller JSR
|
||||
draw-controller
|
||||
|
||||
( print stack on start button )
|
||||
.Controller/button DEI #08 EQU [ JMP BRK ] #010e DEO
|
||||
|
@ -55,52 +55,52 @@ BRK
|
|||
( d-pad )
|
||||
.frame/x0 LDZ2 #0010 ADD2 .Screen/x DEO2
|
||||
.frame/y0 LDZ2 #0010 ADD2 .Screen/y DEO2
|
||||
;controller-icn/dpad-up .Screen/addr DEO2
|
||||
;ctrl-icns/dpad-up .Screen/addr DEO2
|
||||
#03 STHkr #04 SFT #01 AND SUB .Screen/sprite DEO
|
||||
.Screen/y DEI2 #0010 ADD2 .Screen/y DEO2
|
||||
;controller-icn/dpad-down .Screen/addr DEO2
|
||||
;ctrl-icns/dpad-down .Screen/addr DEO2
|
||||
#03 STHkr #05 SFT #01 AND SUB .Screen/sprite DEO
|
||||
.Screen/y DEI2 #0008 SUB2 .Screen/y DEO2
|
||||
.Screen/x DEI2 #0008 SUB2 .Screen/x DEO2
|
||||
;controller-icn/dpad-left .Screen/addr DEO2
|
||||
;ctrl-icns/dpad-left .Screen/addr DEO2
|
||||
#03 STHkr #06 SFT #01 AND SUB .Screen/sprite DEO
|
||||
.Screen/x DEI2 #0010 ADD2 .Screen/x DEO2
|
||||
;controller-icn/dpad-right .Screen/addr DEO2
|
||||
;ctrl-icns/dpad-right .Screen/addr DEO2
|
||||
#03 STHkr #07 SFT #01 AND SUB .Screen/sprite DEO
|
||||
.Screen/x DEI2 #0008 SUB2 .Screen/x DEO2
|
||||
;controller-icn/dpad .Screen/addr DEO2
|
||||
#03 .Screen/sprite DEO
|
||||
;ctrl-icns/dpad .Screen/addr DEO2
|
||||
[ LIT2 03 -Screen/sprite ] DEO
|
||||
|
||||
( options )
|
||||
.center/y LDZ2 #0009 ADD2 .Screen/y DEO2
|
||||
.center/x LDZ2 #0009 SUB2 .Screen/x DEO2
|
||||
;controller-icn/option .Screen/addr DEO2
|
||||
;ctrl-icns/option .Screen/addr DEO2
|
||||
#03 STHkr #03 SFT #01 AND SUB .Screen/sprite DEO
|
||||
.center/x LDZ2 #0004 ADD2 .Screen/x DEO2
|
||||
;controller-icn/option .Screen/addr DEO2
|
||||
;ctrl-icns/option .Screen/addr DEO2
|
||||
#03 STHkr #02 SFT #01 AND SUB .Screen/sprite DEO
|
||||
|
||||
( buttons )
|
||||
.center/y LDZ2 .Screen/y DEO2
|
||||
.center/x LDZ2 #0018 ADD2 .Screen/x DEO2
|
||||
;controller-icn/button .Screen/addr DEO2
|
||||
;ctrl-icns/button .Screen/addr DEO2
|
||||
#03 STHkr #01 SFT #01 AND SUB .Screen/sprite DEO
|
||||
.Screen/y DEI2 #000a ADD2 .Screen/y DEO2
|
||||
;font-hex/b .Screen/addr DEO2
|
||||
#03 .Screen/sprite DEO
|
||||
[ LIT2 03 -Screen/sprite ] DEO
|
||||
|
||||
.center/y LDZ2 .Screen/y DEO2
|
||||
.center/x LDZ2 #0024 ADD2 .Screen/x DEO2
|
||||
;controller-icn/button .Screen/addr DEO2
|
||||
;ctrl-icns/button .Screen/addr DEO2
|
||||
#03 STHr #01 AND SUB .Screen/sprite DEO
|
||||
.Screen/y DEI2 #000a ADD2 .Screen/y DEO2
|
||||
;font-hex/a .Screen/addr DEO2
|
||||
#03 .Screen/sprite DEO
|
||||
[ LIT2 03 -Screen/sprite ] DEO
|
||||
|
||||
.center/x LDZ2 #0010 SUB2 .Screen/x DEO2
|
||||
.center/y LDZ2 #0010 SUB2 .Screen/y DEO2
|
||||
#01 .Screen/auto DEO
|
||||
.Controller/button DEI2 ,draw-short JSR
|
||||
.Controller/button DEI2 draw-short
|
||||
#00 .Screen/auto DEO
|
||||
|
||||
JMP2r
|
||||
|
@ -109,16 +109,16 @@ JMP2r
|
|||
|
||||
@draw-short ( short* -- )
|
||||
|
||||
SWP ,draw-byte JSR
|
||||
SWP draw-byte
|
||||
|
||||
@draw-byte ( byte -- )
|
||||
|
||||
DUP #04 SFT ,draw-hex JSR
|
||||
DUP #04 SFT draw-hex
|
||||
|
||||
@draw-hex ( char -- )
|
||||
|
||||
#00 SWP #0f AND #30 SFT2 ;font-hex ADD2 .Screen/addr DEO2
|
||||
#03 .Screen/sprite DEO
|
||||
[ LIT2 03 -Screen/sprite ] DEO
|
||||
|
||||
JMP2r
|
||||
|
||||
|
@ -135,7 +135,7 @@ JMP2r
|
|||
DUP2 .Screen/x DEO2
|
||||
[ LIT2 &hor-y1 $2 ] .Screen/y DEO2 STHkr .Screen/pixel DEOk
|
||||
[ LIT2 &hor-y2 $2 ] .Screen/y DEO2 DEO
|
||||
INC2 GTH2k ,&hor JCN
|
||||
INC2 GTH2k ?&hor
|
||||
POP2 POP2
|
||||
( vertical )
|
||||
[ LIT2 &ver-y2 $2 ] [ LIT2 &ver-y1 $2 ]
|
||||
|
@ -143,20 +143,20 @@ JMP2r
|
|||
DUP2 .Screen/y DEO2
|
||||
[ LIT2 &ver-x1 $2 ] .Screen/x DEO2 STHkr .Screen/pixel DEOk
|
||||
[ LIT2 &ver-x2 $2 ] .Screen/x DEO2 DEO
|
||||
INC2 GTH2k ,&ver JCN
|
||||
INC2 GTH2k ?&ver
|
||||
POP2 POP2
|
||||
POPr
|
||||
|
||||
JMP2r
|
||||
|
||||
@controller-icn
|
||||
@ctrl-icns [
|
||||
&dpad ffff ffff ffff ffff
|
||||
&dpad-up 7eff e7c3 ffff ffff
|
||||
&dpad-down ffff ffff c3e7 ff7e
|
||||
&dpad-left 7fff efcf cfef ff7f
|
||||
&dpad-right feff f7f3 f3f7 fffe
|
||||
&option 0000 7eff ff7e 0000
|
||||
&button 3c7e ffff ffff 7e3c
|
||||
&button 3c7e ffff ffff 7e3c ]
|
||||
|
||||
@font-hex
|
||||
007c 8282 8282 827c 0030 1010 1010 1010
|
||||
|
|
|
@ -31,7 +31,7 @@ BRK
|
|||
|
||||
@on-frame ( -> )
|
||||
|
||||
.Mouse/state DEI ,&skip JCN
|
||||
.Mouse/state DEI ?&skip
|
||||
;run DUP2 JSR2 JSR2
|
||||
&skip
|
||||
|
||||
|
@ -43,15 +43,15 @@ BRK
|
|||
( clear last cursor )
|
||||
.pointer/x LDZ2 .Screen/x DEO2
|
||||
.pointer/y LDZ2 .Screen/y DEO2
|
||||
#40 .Screen/sprite DEO
|
||||
[ LIT2 40 -Screen/sprite ] DEO
|
||||
( draw new cursor )
|
||||
.Mouse/x DEI2 DUP2 .pointer/x STZ2 .Screen/x DEO2
|
||||
.Mouse/y DEI2 DUP2 .pointer/y STZ2 .Screen/y DEO2
|
||||
#42 .Mouse/state DEI #00 NEQ ADD .Screen/sprite DEO
|
||||
( on down )
|
||||
.Mouse/state DEI #00 NEQ .pointer/state LDZ #00 EQU AND ,on-mouse-down JCN
|
||||
.Mouse/state DEI #00 NEQ .pointer/state LDZ #00 EQU AND ?on-mouse-down
|
||||
( on drag )
|
||||
.Mouse/state DEI ,on-mouse-drag JCN
|
||||
.Mouse/state DEI ?on-mouse-drag
|
||||
.Mouse/state DEI .pointer/state STZ
|
||||
|
||||
BRK
|
||||
|
@ -59,7 +59,7 @@ BRK
|
|||
@on-mouse-down ( -> )
|
||||
|
||||
#0000 DUP2 .length STZ2 .frame STZ2
|
||||
;clear-screen JSR2
|
||||
clear-screen
|
||||
( record start position )
|
||||
.Mouse/x DEI2 DUP2 .pointer/x STZ2 .pointer/lastx STZ2
|
||||
.Mouse/y DEI2 DUP2 .pointer/y STZ2 .pointer/lasty STZ2
|
||||
|
@ -80,8 +80,7 @@ BRK
|
|||
.pointer/lasty LDZ2
|
||||
.pointer/x LDZ2
|
||||
.pointer/y LDZ2
|
||||
#01
|
||||
;draw-line JSR2
|
||||
#01 draw-line
|
||||
( record last position )
|
||||
.Mouse/x DEI2
|
||||
DUP2 .pointer/lastx STZ2
|
||||
|
@ -104,7 +103,7 @@ BRK
|
|||
( line )
|
||||
.pen/x LDZ2 .pen/y LDZ2
|
||||
.pen/x2 LDZ2 .pen/y2 LDZ2
|
||||
.frame LDZ2 #01 SFT2 NIP #01 AND INC ;draw-line JSR2
|
||||
.frame LDZ2 #01 SFT2 NIP #01 AND INC draw-line
|
||||
( history )
|
||||
.pen/x LDZ2 .pen/x2 STZ2
|
||||
.pen/y LDZ2 .pen/y2 STZ2
|
||||
|
@ -116,26 +115,26 @@ JMP2r
|
|||
@draw-line ( x1* y1* x2* y2* color -- )
|
||||
|
||||
( load ) STH ,&y STR2 ,&x STR2 .line/y STZ2 .line/x STZ2
|
||||
,&x LDR2 .line/x LDZ2 SUB2 ;abs2 JSR2 .line/dx STZ2
|
||||
#0000 ,&y LDR2 .line/y LDZ2 SUB2 ;abs2 JSR2 SUB2 .line/dy STZ2
|
||||
#ffff #00 .line/x LDZ2 ,&x LDR2 ;lts2 JSR2 DUP2 ADD2 ADD2 ,&sx STR2
|
||||
#ffff #00 .line/y LDZ2 ,&y LDR2 ;lts2 JSR2 DUP2 ADD2 ADD2 ,&sy STR2
|
||||
,&x LDR2 .line/x LDZ2 SUB2 abs2 .line/dx STZ2
|
||||
#0000 ,&y LDR2 .line/y LDZ2 SUB2 abs2 SUB2 .line/dy STZ2
|
||||
#ffff #00 .line/x LDZ2 ,&x LDR2 lts2 DUP2 ADD2 ADD2 ,&sx STR2
|
||||
#ffff #00 .line/y LDZ2 ,&y LDR2 lts2 DUP2 ADD2 ADD2 ,&sy STR2
|
||||
.line/dx LDZ2 .line/dy LDZ2 ADD2 .line/e1 STZ2
|
||||
&loop
|
||||
.line/x LDZ2 DUP2 .Screen/x DEO2 [ LIT2 &x $2 ] EQU2
|
||||
.line/y LDZ2 DUP2 .Screen/y DEO2 [ LIT2 &y $2 ] EQU2
|
||||
STHkr .Screen/pixel DEO
|
||||
AND ,&end JCN
|
||||
AND ?&end
|
||||
.line/e1 LDZ2 DUP2 ADD2 DUP2
|
||||
.line/dy LDZ2 ;lts2 JSR2 ,&skipy JCN
|
||||
.line/dy LDZ2 lts2 ?&skipy
|
||||
.line/e1 LDZ2 .line/dy LDZ2 ADD2 .line/e1 STZ2
|
||||
.line/x LDZ2 [ LIT2 &sx $2 ] ADD2 .line/x STZ2
|
||||
&skipy
|
||||
.line/dx LDZ2 ;gts2 JSR2 ,&skipx JCN
|
||||
.line/dx LDZ2 gts2 ?&skipx
|
||||
.line/e1 LDZ2 .line/dx LDZ2 ADD2 .line/e1 STZ2
|
||||
.line/y LDZ2 [ LIT2 &sy $2 ] ADD2 .line/y STZ2
|
||||
&skipx
|
||||
,&loop JMP
|
||||
!&loop
|
||||
&end
|
||||
POPr
|
||||
|
||||
|
@ -153,10 +152,10 @@ JMP2r
|
|||
.Screen/width DEI2 #03 SFT2 NIP #00
|
||||
&x
|
||||
#00 OVR #30 SFT2 .Screen/x DEO2
|
||||
#00 .Screen/sprite DEO
|
||||
INC GTHk ,&x JCN
|
||||
[ LIT2 00 -Screen/sprite ] DEO
|
||||
INC GTHk ?&x
|
||||
POP2
|
||||
INC GTHk ,&y JCN
|
||||
INC GTHk ?&y
|
||||
POP2
|
||||
|
||||
JMP2r
|
||||
|
|
|
@ -6,18 +6,17 @@
|
|||
|
||||
#0000 INC2k ADD2k
|
||||
&loop
|
||||
DUP2 ,print-hex JSR #0a18 DEO
|
||||
ADD2k LTH2k ,&loop JCN
|
||||
|
||||
DUP2 print #0a18 DEO
|
||||
ADD2k LTH2k ?&loop
|
||||
( halt )
|
||||
#010f DEO
|
||||
|
||||
BRK
|
||||
|
||||
@print-hex ( short* -- )
|
||||
@print ( short* -- )
|
||||
|
||||
SWP ,&byte JSR
|
||||
&byte ( byte -- ) DUP #04 SFT ,&char JSR
|
||||
SWP print/byte
|
||||
&byte ( byte -- ) DUP #04 SFT print/char
|
||||
&char ( char -- ) #0f AND DUP #09 GTH #27 MUL ADD #30 ADD #18 DEO
|
||||
|
||||
JMP2r
|
||||
|
|
Loading…
Reference in New Issue