mirror of https://git.sr.ht/~rabbits/uxn
Compare commits
10 Commits
250aecc920
...
5668efaac8
Author | SHA1 | Date |
---|---|---|
Devine Lu Linvega | 5668efaac8 | |
Devine Lu Linvega | 3e2082dddf | |
Devine Lu Linvega | 5cf69a2659 | |
Devine Lu Linvega | 852e34c304 | |
Devine Lu Linvega | 4d329e7e5f | |
Devine Lu Linvega | c73f1e066a | |
Devine Lu Linvega | 220983d694 | |
Devine Lu Linvega | c9b691448b | |
Devine Lu Linvega | 641872fe21 | |
Devine Lu Linvega | 370c3a60c9 |
|
@ -14,7 +14,7 @@
|
|||
|
||||
|0100
|
||||
( variables )
|
||||
#01 .direction STZ
|
||||
[ LIT2 01 -direction ] STZ
|
||||
( vectors )
|
||||
;on-frame .Screen/vector DEO2
|
||||
( theme )
|
||||
|
@ -89,7 +89,7 @@ JMP2r
|
|||
.timer LDZk INC DUP ROT STZ #06 EQU ?&pull
|
||||
|
||||
!&pass
|
||||
&pull #00 .timer STZ .ball/vy LDZ2k INC2 STH2k ROT STZ2 !&end
|
||||
&pull [ LIT2 00 -timer ] STZ .ball/vy LDZ2k INC2 STH2k ROT STZ2 !&end
|
||||
&pass .ball/vy LDZ2k STH2k ROT STZ2 !&end
|
||||
&end .ball/y LDZ2k STH2r ADD2 check-flip-vy ROT STZ2
|
||||
|
||||
|
|
|
@ -83,8 +83,8 @@
|
|||
|
||||
@<cover-pattern> ( addr* -- )
|
||||
.Screen/addr DEO2
|
||||
.Screen/height DEI2 #03 SFT2 NIP ,&h STR
|
||||
.Screen/width DEI2 #03 SFT2 NIP ,&w STR
|
||||
.Screen/height DEI2 #03 SFT2 ,&h STR POP
|
||||
.Screen/width DEI2 #03 SFT2 ,&w STR POP
|
||||
[ LIT &h $1 ] #00
|
||||
&ver ( -- )
|
||||
#00 OVR #30 SFT2 .Screen/y DEO2
|
||||
|
@ -103,6 +103,7 @@
|
|||
.Mouse/x DEI2 ,<draw-cursor>/x STR2
|
||||
.Mouse/y DEI2 ,<draw-cursor>/y STR2
|
||||
.Screen/addr DEO2
|
||||
( >> )
|
||||
|
||||
@<draw-cursor> ( color -- )
|
||||
[ LIT2 &x $2 ] .Screen/x DEO2
|
||||
|
|
|
@ -2,14 +2,13 @@
|
|||
|
||||
|00 @System &vector $2 &wst $1 &rst $1 &eaddr $2 &ecode $1 &pad $1 &r $2 &g $2 &b $2 &debug $1 &halt $1
|
||||
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
|
||||
|000
|
||||
|
||||
|0000
|
||||
|
||||
@timer $1
|
||||
@cube &v0 $8 &v4 $8
|
||||
@center &x $2 &y $2
|
||||
@timer $1
|
||||
|
||||
|0100
|
||||
|100
|
||||
|
||||
@on-reset ( -> )
|
||||
( | theme )
|
||||
|
@ -23,43 +22,45 @@
|
|||
;on-frame .Screen/vector DEO2
|
||||
|
||||
@on-frame ( -> )
|
||||
[ LIT &f $1 ] INCk ,&f STR
|
||||
DUP #01 AND ?{ POP BRK }
|
||||
#01 SFT .timer STZ
|
||||
( | clear )
|
||||
#0000 DUP2 .Screen/x DEO2
|
||||
.Screen/y DEO2
|
||||
[ LIT2 80 -Screen/pixel ] DEO
|
||||
( | draw )
|
||||
.timer LDZk INC SWP STZ
|
||||
<draw-cube>
|
||||
BRK
|
||||
|
||||
@<draw-cube> ( frame -- )
|
||||
( | create box )
|
||||
#0800
|
||||
&loop ( -- )
|
||||
&>loop ( -- )
|
||||
STHk [ LIT2 00 -timer ] LDZ #00 STHkr INC #07 AND #60 SFT ADD2 #00ff AND2 ;table ADD2 LDA #01 SFT #00 .timer LDZ #00 STHkr #60 SFT ADD2 #00ff AND2 ;table ADD2 LDA #02 SFT #00 STHkr #62 SFT2 ADD2 .cube/v0 STHr DUP ADD ADD STZ2
|
||||
INC GTHk ?&loop
|
||||
INC GTHk ?&>loop
|
||||
POP2
|
||||
( | vertices )
|
||||
#0800
|
||||
&ver-loop ( -- )
|
||||
DUP DUP ADD .cube ADD LDZ2 <draw-vertex>
|
||||
INC GTHk ?&ver-loop
|
||||
&>ver-loop ( -- )
|
||||
DUP DUP ADD LDZ2 <draw-vertex>
|
||||
INC GTHk ?&>ver-loop
|
||||
POP2
|
||||
( lines ) #0400
|
||||
&line-loop ( -- )
|
||||
&>line-loop ( -- )
|
||||
STHk .cube/v0 STHkr DUP ADD ADD .cube/v0 STHkr INC #03 AND DUP ADD ADD <draw-edge>
|
||||
.cube/v0 STHkr DUP ADD ADD .cube/v4 STHkr DUP ADD ADD <draw-edge>
|
||||
.cube/v4 STHkr DUP ADD ADD .cube/v4 STHr INC #03 AND DUP ADD ADD <draw-edge>
|
||||
INC GTHk ?&line-loop
|
||||
INC GTHk ?&>line-loop
|
||||
POP2 JMP2r
|
||||
|
||||
@<draw-edge> ( a b -- )
|
||||
STH STH
|
||||
STH
|
||||
STH
|
||||
( ) #00 STHkr LDZ .center/x LDZ2 ADD2
|
||||
( ) #00 STHr INC LDZ .center/y LDZ2 ADD2
|
||||
( ) #00 STHkr LDZ .center/x LDZ2 ADD2
|
||||
( ) #00 STHr INC LDZ .center/y LDZ2 ADD2 #05 <draw-line>
|
||||
JMP2r
|
||||
( ) #00 STHr INC LDZ .center/y LDZ2 ADD2 #05 !<draw-line>
|
||||
|
||||
@<draw-vertex> ( x y -- )
|
||||
#00 SWP #0004 SUB2 .center/y LDZ2 ADD2 .Screen/y DEO2
|
||||
|
@ -81,15 +82,17 @@
|
|||
#ffff [ LIT2 00 _&y2 ] LDR2 ,&y LDR2 lts2 DUP2 ADD2 ADD2 ,&sy STR2
|
||||
[ LIT2 &dx $2 ] [ LIT2 &dy $2 ] ADD2 STH2
|
||||
&while ( -- )
|
||||
[ LIT2 &x2 $2 ] DUP2 .Screen/x DEO2
|
||||
[ LIT2 &x $2 ] EQU2 [ LIT2 &y2 $2 ] DUP2 .Screen/y DEO2
|
||||
[ LIT2 &y $2 ] EQU2 [ LIT2 &color $1 -Screen/pixel ] DEO
|
||||
AND ?&end
|
||||
STH2kr DUP2 ADD2 DUP2 ,&dy LDR2 lts2 ?&skipy
|
||||
STH2r ,&dy LDR2 ADD2 STH2 ,&x2 LDR2 [ LIT2 &sx $2 ] ADD2 ,&x2 STR2
|
||||
[ LIT2 &x2 $2 ] DUP2 .Screen/x DEO2
|
||||
[ LIT2 &x $2 ] EQU2 [ LIT2 &y2 $2 ] DUP2 .Screen/y DEO2
|
||||
[ LIT2 &y $2 ] EQU2 [ LIT2 &color $1 -Screen/pixel ] DEO
|
||||
AND ?&end
|
||||
STH2kr DUP2 ADD2 DUP2 ,&dy LDR2 lts2 ?&skipy
|
||||
STH2r ,&dy LDR2 ADD2 STH2
|
||||
,&x2 LDR2 [ LIT2 &sx $2 ] ADD2 ,&x2 STR2
|
||||
&skipy ( -- )
|
||||
,&dx LDR2 gts2 ?&while
|
||||
STH2r ,&dx LDR2 ADD2 STH2 ,&y2 LDR2 [ LIT2 &sy $2 ] ADD2 ,&y2 STR2
|
||||
,&dx LDR2 gts2 ?&while
|
||||
STH2r ,&dx LDR2 ADD2 STH2
|
||||
,&y2 LDR2 [ LIT2 &sy $2 ] ADD2 ,&y2 STR2
|
||||
!&while
|
||||
&end POP2r JMP2r
|
||||
|
||||
|
|
|
@ -3,12 +3,11 @@
|
|||
|00 @System &vector $2 &pad $6 &r $2 &g $2 &b $2
|
||||
|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
|
||||
|
||||
|0000
|
||||
|000
|
||||
|
||||
@hello &x $2 &y $2
|
||||
|
||||
|0100
|
||||
|100
|
||||
|
||||
@on-reset ( -> )
|
||||
( | theme )
|
||||
|
@ -17,41 +16,40 @@
|
|||
#c0f7 .System/b DEO2
|
||||
( | vectors )
|
||||
;on-frame .Screen/vector DEO2
|
||||
( | set origin ) .Screen/width DEI2 #01 SFT2 .hello/x STZ2
|
||||
( | set origin )
|
||||
.Screen/width DEI2 #01 SFT2 .hello/x STZ2
|
||||
.Screen/height DEI2 #01 SFT2 .hello/y STZ2
|
||||
[ LIT2 16 -Screen/auto ] DEO
|
||||
#00 on-frame/draw BRK
|
||||
#00 !on-frame/draw
|
||||
|
||||
@on-frame ( -> )
|
||||
.Controller/button DEI DUP ?{ POP BRK }
|
||||
( | clear )
|
||||
[ LIT2 40 -Screen/sprite ] DEO
|
||||
( flip ) #ff EOR
|
||||
( | movement )
|
||||
DUP #10 AND #00 EQU ?{
|
||||
DUP #10 AND ?{
|
||||
.hello/y LDZ2k #0001 SUB2 ROT STZ2 }
|
||||
DUP #20 AND #00 EQU ?{
|
||||
DUP #20 AND ?{
|
||||
.hello/y LDZ2k INC2 ROT STZ2 }
|
||||
DUP #40 AND #00 EQU ?{
|
||||
DUP #40 AND ?{
|
||||
.hello/x LDZ2k #0001 SUB2 ROT STZ2 }
|
||||
DUP #80 AND #00 EQU ?{
|
||||
DUP #80 AND ?{
|
||||
.hello/x LDZ2k INC2 ROT STZ2 }
|
||||
&draw ( button -> )
|
||||
.hello/x LDZ2 STH2k .Screen/x DEO2
|
||||
.hello/y LDZ2 STH2k .Screen/y DEO2
|
||||
;hello-chr .Screen/addr DEO2
|
||||
[ LIT2 c1 -Screen/sprite ] DEOk
|
||||
DEO
|
||||
( draw slime ) STH2r .Screen/y DEO2
|
||||
STH2r .Screen/x DEO2
|
||||
;slime-icn .Screen/addr DEO2
|
||||
get-slime .Screen/sprite DEOk
|
||||
DEO
|
||||
BRK
|
||||
.hello/x LDZ2 STH2k .Screen/x DEO2
|
||||
.hello/y LDZ2 STH2k .Screen/y DEO2
|
||||
;hello-chr .Screen/addr DEO2
|
||||
[ LIT2 c1 -Screen/sprite ] DEOk DEO
|
||||
( | draw slime )
|
||||
[ LITr -Screen/y ] DEO2r
|
||||
[ LITr -Screen/x ] DEO2r
|
||||
;slime-icn .Screen/addr DEO2
|
||||
get-slime .Screen/sprite DEOk DEO
|
||||
BRK
|
||||
|
||||
@get-slime ( button -- color )
|
||||
#0f AND DUP #01 NEQ ?{ POP #05 JMP2r }
|
||||
DUP #02 NEQ ?{ POP #0a JMP2r }
|
||||
POP #0f JMP2r
|
||||
DUP #01 AND ?{ POP #05 JMP2r }
|
||||
#02 AND ?{ #0a JMP2r }
|
||||
#0f JMP2r
|
||||
|
||||
@hello-chr [
|
||||
0007 1820 2040 4044 0000 071f 1f3f 3f3b
|
||||
|
|
|
@ -1,215 +1,165 @@
|
|||
( uxnasm projects/examples/demos/snake.tal bin/snake.rom && uxnemu bin/snake.rom )
|
||||
( uxnemu snake.rom )
|
||||
|
||||
( devices )
|
||||
|00 @System &vector $2 &expansion $2 &wst $1 &rst $1 &metadata $2 &r $2 &g $2 &b $2 &debug $1 &state $1
|
||||
|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
|
||||
|c0 @DateTime &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1
|
||||
|000
|
||||
|
||||
|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 ]
|
||||
|80 @Controller [ &vector $2 &button $1 &key $1 ]
|
||||
|c0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ]
|
||||
@arena &w $1 &h $1
|
||||
@apple &pos &x $1 &y $1
|
||||
@snake &pos &x $1 &y $1 &direction $1 &length $1 &dead $1 &tail $40
|
||||
|
||||
( variables )
|
||||
|100
|
||||
|
||||
|0000
|
||||
|
||||
( program )
|
||||
|
||||
@arena
|
||||
&w $1 &h $1 &timer $1
|
||||
@apple
|
||||
&x $1 &y $1
|
||||
@snake
|
||||
&direction $1 &length $1 &dead $1
|
||||
&x $1 &y $1
|
||||
&tail
|
||||
|
||||
|0100 ( -> )
|
||||
|
||||
( theme )
|
||||
#0f7e .System/r DEO2
|
||||
#0fe6 .System/g DEO2
|
||||
@on-reset ( -> )
|
||||
( | theme )
|
||||
#0f7e .System/r DEO2
|
||||
#0fe6 .System/g DEO2
|
||||
#0f62 .System/b DEO2
|
||||
|
||||
( vectors )
|
||||
( | vectors )
|
||||
;on-frame .Screen/vector DEO2
|
||||
;on-button .Controller/vector DEO2
|
||||
|
||||
( resize )
|
||||
( | resize )
|
||||
#00c8 .Screen/width DEO2
|
||||
#0100 .Screen/height DEO2
|
||||
|
||||
( set arena )
|
||||
.Screen/width DEI2 #03 SFT2 NIP .arena/w STZ
|
||||
.Screen/height DEI2 #03 SFT2 NIP .arena/h STZ
|
||||
|
||||
;reset JSR2
|
||||
|
||||
BRK
|
||||
( | set arena )
|
||||
.Screen/width DEI2 #03 SFT2 .arena/w STZ
|
||||
POP .Screen/height DEI2 #03 SFT2 .arena/h STZ
|
||||
POP [ LIT2 01 -Screen/auto ] DEO
|
||||
reset BRK
|
||||
|
||||
@on-frame ( -> )
|
||||
|
||||
.arena/timer LDZ INC DUP .arena/timer STZ
|
||||
#06 ( difficulty - lower value produces faster gameplay )
|
||||
EQU JMP BRK
|
||||
|
||||
( clear ) #00 ;draw-snake JSR2
|
||||
( update ) ;move JSR2
|
||||
( draw ) #02 .snake/dead LDZ ADD ;draw-snake JSR2
|
||||
#83 ;draw-apple JSR2
|
||||
( score ) .snake/length LDZ #41 ;draw-score JSR2
|
||||
( reset ) #00 .arena/timer STZ
|
||||
|
||||
BRK
|
||||
[ LIT &f $1 ] INCk ,&f STR
|
||||
#04 GTH ?{ BRK }
|
||||
[ LIT2 00 _&f ] STR
|
||||
#00 <draw-snake>
|
||||
<move>
|
||||
[ LIT2 02 -snake/dead ] LDZ ADD <draw-snake>
|
||||
#83 <draw-apple>
|
||||
<draw-score>
|
||||
BRK
|
||||
|
||||
@on-button ( -> )
|
||||
|
||||
.Controller/button DEI
|
||||
DUP #08 NEQ ,&no-escape JCN
|
||||
;reset JSR2
|
||||
&no-escape
|
||||
#04 SFT DUP #00 EQU ,&skip JCN
|
||||
DUP .snake/direction STZ
|
||||
&skip
|
||||
POP
|
||||
|
||||
BRK
|
||||
.Controller/button DEI
|
||||
( ) DUP #f0 AND ?&arrow
|
||||
( ) #0f AND ?&button
|
||||
BRK
|
||||
&arrow ( button -> )
|
||||
#04 SFT .snake/direction STZ
|
||||
BRK
|
||||
&button ( -> )
|
||||
reset BRK
|
||||
|
||||
@reset ( -- )
|
||||
|
||||
#00 ;draw-snake JSR2
|
||||
#00 ;draw-apple JSR2
|
||||
|
||||
#00 <draw-snake>
|
||||
#00 <draw-apple>
|
||||
[ LIT2 00 -snake/dead ] STZ
|
||||
[ LIT2 00 -snake/length ] STZ
|
||||
[ LIT2 00 -snake/direction ] STZ
|
||||
.arena/w LDZ #01 SFT #01 SUB .snake/x STZ
|
||||
.arena/h LDZ #01 SFT #01 SUB .snake/y STZ
|
||||
#00 .snake/dead STZ
|
||||
#00 .snake/length STZ
|
||||
#00 .snake/direction STZ
|
||||
|
||||
#03 ;draw-snake JSR2
|
||||
;add-apple JSR2
|
||||
|
||||
JMP2r
|
||||
|
||||
@move ( -- )
|
||||
|
||||
( tail )
|
||||
.snake/x LDZ2 STH2
|
||||
.snake/length LDZ #00
|
||||
&loop
|
||||
( pop ) DUPk ADD .snake/tail ADD LDZ2 STH2 SWP2r
|
||||
( push ) DUPk ADD .snake/tail ADD STH2r ROT STZ2
|
||||
INC GTHk ,&loop JCN
|
||||
POP2
|
||||
POP2r
|
||||
|
||||
.snake/dead LDZ #00 EQU JMP JMP2r
|
||||
#03 <draw-snake>
|
||||
!<add-apple>
|
||||
|
||||
@<move> ( -- )
|
||||
( | copy tail )
|
||||
[ LITr -snake/pos ] LDZ2r .snake/length LDZ #00
|
||||
&>loop ( -- )
|
||||
DUPk ADD .snake/tail ADD LDZ2k STH2
|
||||
SWP2r STH2r ROT STZ2
|
||||
INC GTHk ?&>loop
|
||||
POP2 POP2r
|
||||
( ) .snake/dead LDZ ?&end
|
||||
.snake/direction LDZ
|
||||
DUP #01 NEQ ,&no-up JCN
|
||||
.snake/y LDZ #01 SUB
|
||||
.arena/h LDZ LTHk JMP SWP POP
|
||||
.snake/y STZ
|
||||
&no-up
|
||||
DUP #02 NEQ ,&no-down JCN
|
||||
.snake/y LDZ INC
|
||||
.arena/h LDZ DIVk MUL SUB
|
||||
.snake/y STZ
|
||||
&no-down
|
||||
DUP #04 NEQ ,&no-left JCN
|
||||
.snake/x LDZ #01 SUB
|
||||
.arena/w LDZ LTHk JMP SWP POP
|
||||
.snake/x STZ
|
||||
&no-left
|
||||
DUP #08 NEQ ,&no-right JCN
|
||||
.snake/x LDZ INC
|
||||
.arena/w LDZ DIVk MUL SUB
|
||||
.snake/x STZ
|
||||
&no-right
|
||||
( ) DUP #01 NEQ ?{
|
||||
.snake/y LDZk #01 SUB .arena/h set-pos }
|
||||
DUP #02 NEQ ?{
|
||||
.snake/y LDZk INC .arena/h set-pos }
|
||||
DUP #04 NEQ ?{
|
||||
.snake/x LDZk #01 SUB .arena/w set-pos }
|
||||
DUP #08 NEQ ?{
|
||||
.snake/x LDZk INC .arena/w set-pos }
|
||||
POP
|
||||
|
||||
( detect collision with apple )
|
||||
.snake/x LDZ2 .apple/x LDZ2 NEQ2 ,&no-collision-apple JCN
|
||||
#00 ;draw-apple JSR2
|
||||
.snake/length LDZ INC .snake/length STZ
|
||||
;add-apple JSR2
|
||||
;move JSR2
|
||||
&no-collision-apple
|
||||
|
||||
( | detect collision with apple )
|
||||
.snake/pos LDZ2 .apple/pos LDZ2 NEQ2 ?{
|
||||
#00 <draw-apple>
|
||||
.snake/length LDZk INC SWP STZ
|
||||
<add-apple>
|
||||
!<move> }
|
||||
( | detect collision with body )
|
||||
.snake/length LDZ #01
|
||||
&loop-body
|
||||
( pop ) DUPk ADD .snake/tail ADD LDZ2
|
||||
.snake/x LDZ2 NEQ2 ,&no-collision-body JCN
|
||||
#01 .snake/dead STZ
|
||||
#03 ;draw-snake JSR2
|
||||
&no-collision-body
|
||||
INC GTHk ,&loop-body JCN
|
||||
POP2
|
||||
&>loop-body ( -- )
|
||||
DUPk ADD .snake/tail ADD LDZ2 .snake/pos LDZ2 NEQ2 ?{
|
||||
[ LIT2 01 -snake/dead ] STZ
|
||||
#03 <draw-snake> }
|
||||
INC GTHk ?&>loop-body
|
||||
POP2 &end JMP2r
|
||||
|
||||
JMP2r
|
||||
@set-pos ( z mod max -- )
|
||||
LDZ OVR INC ?{ ROT STZ
|
||||
POP JMP2r }
|
||||
DIVk MUL SUB SWP STZ
|
||||
JMP2r
|
||||
|
||||
@add-apple ( -- )
|
||||
@<add-apple> ( -- )
|
||||
.DateTime/hour DEI2 .DateTime/minute DEI2 MUL2
|
||||
( ) DUP2 #1234 MUL2 ADD .arena/w LDZ DIVk MUL SUB .apple/x STZ
|
||||
( ) #abcd MUL2 ADD .arena/h LDZ DIVk MUL SUB .apple/y STZ
|
||||
JMP2r
|
||||
|
||||
.DateTime/hour DEI2 .DateTime/minute DEI2 MUL2 #1234 MUL2 ADD
|
||||
.arena/w LDZ DIVk MUL SUB .apple/x STZ
|
||||
.DateTime/hour DEI2 .DateTime/minute DEI2 MUL2 #abcd MUL2 ADD
|
||||
.arena/h LDZ DIVk MUL SUB .apple/y STZ
|
||||
|
||||
JMP2r
|
||||
|
||||
@draw-snake ( color -- )
|
||||
(
|
||||
@|drawing )
|
||||
|
||||
@<draw-snake> ( color -- )
|
||||
STH
|
||||
( draw tail )
|
||||
( | draw tail )
|
||||
;snake-icns .Screen/addr DEO2
|
||||
.snake/length LDZ #00
|
||||
&loop
|
||||
DUPk ADD .snake/tail ADD LDZ #0005 SFT2 .Screen/x DEO2
|
||||
DUPk ADD .snake/tail ADD INC LDZ #0005 SFT2 .Screen/y DEO2
|
||||
STHkr .Screen/sprite DEO
|
||||
INC GTHk ,&loop JCN
|
||||
[ LIT2 -snake/tail -snake/length ] LDZ DUP ADD OVR ADD SWP
|
||||
&>loop ( -- )
|
||||
LDZ2k #0005 SFT2 .Screen/y DEO2
|
||||
#0005 SFT2 .Screen/x DEO2
|
||||
DUPr [ LITr -Screen/sprite ] DEOr
|
||||
INC INC GTHk ?&>loop
|
||||
POP2
|
||||
( draw head )
|
||||
.snake/x LDZ #0005 SFT2 .Screen/x DEO2
|
||||
.snake/y LDZ #0005 SFT2 .Screen/y DEO2
|
||||
( | draw head )
|
||||
.snake/pos LDZ2 #0005 SFT2 .Screen/y DEO2
|
||||
#0005 SFT2 .Screen/x DEO2
|
||||
;snake-icns/face .Screen/addr DEO2
|
||||
STHr .Screen/sprite DEO
|
||||
|
||||
JMP2r
|
||||
|
||||
@draw-apple ( color -- )
|
||||
[ LITr -Screen/sprite ] DEOr
|
||||
JMP2r
|
||||
|
||||
@<draw-apple> ( color -- )
|
||||
.apple/x LDZ #0005 SFT2 .Screen/x DEO2
|
||||
.apple/y LDZ #0005 SFT2 .Screen/y DEO2
|
||||
;apple-chr .Screen/addr DEO2
|
||||
STHk ;apple-chr ;fill-icn [ LITr 01 JCNr SWP2 POP2 ] .Screen/addr DEO2
|
||||
.Screen/sprite DEO
|
||||
JMP2r
|
||||
|
||||
JMP2r
|
||||
@<draw-score> ( -- )
|
||||
#0010 DUP2 .Screen/x DEO2
|
||||
.Screen/y DEO2
|
||||
.snake/length LDZ
|
||||
( x0 ) DUP #04 SFT <draw-num>
|
||||
( >> )
|
||||
|
||||
@draw-score ( score color -- )
|
||||
@<draw-num> ( num -- )
|
||||
#000f ROT AND #30 SFT2 ;font-hex ADD2 .Screen/addr DEO2
|
||||
[ LIT2 41 -Screen/sprite ] DEO
|
||||
JMP2r
|
||||
|
||||
STH
|
||||
#0010 .Screen/x DEO2
|
||||
#0010 .Screen/y DEO2
|
||||
DUP #04 SFT #0005 SFT2 ;font-hex ADD2 .Screen/addr DEO2
|
||||
.Screen/x DEI2 #0008 ADD2 .Screen/x DEO2
|
||||
( draw ) STHkr .Screen/sprite DEO
|
||||
#0f AND #0005 SFT2 ;font-hex ADD2 .Screen/addr DEO2
|
||||
.Screen/x DEI2 #0008 ADD2 .Screen/x DEO2
|
||||
( draw ) STHr .Screen/sprite DEO
|
||||
(
|
||||
@|assets )
|
||||
|
||||
JMP2r
|
||||
@snake-icns [ 7eff ffff ffff ff7e ]
|
||||
&face [ 7eff ffdb ffe7 ff7e ]
|
||||
|
||||
( assets )
|
||||
@apple-chr [
|
||||
0000 76ff ffff 7e3c 1008 0000 0000 0000 ]
|
||||
|
||||
@snake-icns
|
||||
7eff ffff ffff ff7e
|
||||
&face
|
||||
7eff ffdb ffe7 ff7e
|
||||
@apple-chr
|
||||
0000 76ff ffff 7e3c
|
||||
1008 0000 0000 0000
|
||||
@font-hex ( 0-F )
|
||||
@fill-icn [ ffff ffff ffff ffff ]
|
||||
|
||||
@font-hex [
|
||||
007c 8282 8282 827c 0030 1010 1010 1010
|
||||
007c 8202 7c80 80fe 007c 8202 1c02 827c
|
||||
000c 1424 4484 fe04 00fe 8080 7c02 827c
|
||||
|
@ -217,5 +167,5 @@ JMP2r
|
|||
007c 8282 7c82 827c 007c 8282 7e02 827c
|
||||
007c 8202 7e82 827e 00fc 8282 fc82 82fc
|
||||
007c 8280 8080 827c 00fc 8282 8282 82fc
|
||||
007c 8280 f080 827c 007c 8280 f080 8080
|
||||
007c 8280 f080 827c 007c 8280 f080 8080 ]
|
||||
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
@on-reset ( -> )
|
||||
#0b #14 #18 tak
|
||||
#010e DEO
|
||||
BRK
|
||||
|
||||
@tak ( z y x -- res )
|
||||
LTHk ?{ POP2 JMP2r }
|
||||
ROT ROTk ROTk
|
||||
( x-1 ) #01 SUB tak STH
|
||||
( y-1 ) #01 SUB tak STH
|
||||
( z-1 ) #01 SUB tak STHr STHr !tak
|
||||
|
Loading…
Reference in New Issue