2023-06-07 19:41:30 -04:00
|
|
|
( wireworld
|
2023-03-18 00:20:28 -04:00
|
|
|
|
2023-06-07 19:41:30 -04:00
|
|
|
electron head<3>, becomes electron tail<2>
|
|
|
|
electron tail<2>, becomes conductor<1>
|
|
|
|
conductor<1>, becomes electron head<3>
|
2023-03-18 00:20:28 -04:00
|
|
|
if there are exactly 1 or 2 electron heads around it. )
|
|
|
|
|
|
|
|
|00 @System &vector $2 &wst $1 &rst $1 &pad $4 &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
|
|
|
|
|80 @Controller &vector $2 &button $1 &key $1 &func $1
|
|
|
|
|90 @Mouse &vector $2 &x $2 &y $2 &state $1 &pad $3 &modx $2 &mody $2
|
|
|
|
|
|
|
|
|0000
|
|
|
|
|
|
|
|
@color $1
|
|
|
|
@pointer &x $2 &y $2
|
2023-06-07 21:48:25 -04:00
|
|
|
@timer &play $1
|
2023-03-18 00:20:28 -04:00
|
|
|
|
2023-06-07 19:41:30 -04:00
|
|
|
(
|
|
|
|
@|vectors )
|
|
|
|
|
2023-03-18 00:20:28 -04:00
|
|
|
|0100 ( -> )
|
|
|
|
|
|
|
|
( theme )
|
2023-06-07 19:41:30 -04:00
|
|
|
#0ff2 .System/r DEO2
|
|
|
|
#0d46 .System/g DEO2
|
|
|
|
#006f .System/b DEO2
|
2023-03-18 00:20:28 -04:00
|
|
|
( size )
|
2023-06-07 22:13:15 -04:00
|
|
|
#0200 .Screen/width DEO2
|
|
|
|
#0200 .Screen/height DEO2
|
2023-03-18 00:20:28 -04:00
|
|
|
( vectors )
|
|
|
|
;on-frame .Screen/vector DEO2
|
|
|
|
;on-mouse .Mouse/vector DEO2
|
|
|
|
;on-button .Controller/vector DEO2
|
|
|
|
( setup )
|
2023-06-07 19:41:30 -04:00
|
|
|
#01 .timer/play STZ
|
|
|
|
#01 set-color
|
2023-03-18 00:20:28 -04:00
|
|
|
( start )
|
|
|
|
;world ;get-addr/current STA2
|
|
|
|
#1000 ;run/future STA2
|
|
|
|
redraw
|
|
|
|
|
|
|
|
BRK
|
|
|
|
|
|
|
|
@on-frame ( -> )
|
|
|
|
|
2023-06-07 21:48:25 -04:00
|
|
|
.Mouse/state DEI #00 EQU [ JMP BRK ]
|
2023-03-18 00:20:28 -04:00
|
|
|
.timer/play LDZ [ JMP BRK ]
|
2023-06-07 21:48:25 -04:00
|
|
|
|
2023-03-18 00:20:28 -04:00
|
|
|
( every 4th )
|
2023-06-07 21:48:25 -04:00
|
|
|
[ LIT &f $1 ] INCk ,&f STR
|
2023-03-18 00:20:28 -04:00
|
|
|
#03 AND ?&no-run
|
2023-06-07 21:48:25 -04:00
|
|
|
run &no-run
|
2023-03-18 00:20:28 -04:00
|
|
|
|
|
|
|
BRK
|
|
|
|
|
|
|
|
@on-mouse ( -> )
|
|
|
|
|
|
|
|
;pointer-icn .Screen/addr DEO2
|
|
|
|
( clear last cursor )
|
|
|
|
.pointer/x LDZ2 .Screen/x DEO2
|
|
|
|
.pointer/y LDZ2 .Screen/y DEO2
|
|
|
|
#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
|
|
|
|
#40 .color LDZ ADD .Screen/sprite DEO
|
|
|
|
( paint )
|
2023-06-07 19:41:30 -04:00
|
|
|
.Mouse/state DEI ?&down
|
2023-03-18 00:20:28 -04:00
|
|
|
|
|
|
|
BRK
|
|
|
|
|
2023-06-07 19:41:30 -04:00
|
|
|
&down ( -> )
|
2023-03-18 00:20:28 -04:00
|
|
|
|
2023-06-07 19:41:30 -04:00
|
|
|
.Mouse/y DEI2 #03 SFT2 NIP #02 NEQ ?&no-menu
|
2023-03-18 00:20:28 -04:00
|
|
|
.Mouse/x DEI2 #03 SFT2 NIP
|
2023-06-07 19:41:30 -04:00
|
|
|
DUP #02 NEQ ?&no-color1
|
|
|
|
#01 set-color
|
2023-03-18 00:20:28 -04:00
|
|
|
&no-color1
|
2023-06-07 19:41:30 -04:00
|
|
|
DUP #03 NEQ ?&no-color2
|
|
|
|
#02 set-color
|
2023-03-18 00:20:28 -04:00
|
|
|
&no-color2
|
2023-06-07 19:41:30 -04:00
|
|
|
DUP #04 NEQ ?&no-color3
|
|
|
|
#03 set-color
|
2023-03-18 00:20:28 -04:00
|
|
|
&no-color3
|
2023-06-07 19:41:30 -04:00
|
|
|
DUP #06 NEQ ?&no-toggle
|
2023-03-18 00:20:28 -04:00
|
|
|
.timer/play LDZk #00 EQU SWP STZ
|
|
|
|
#00 .Mouse/state DEO
|
|
|
|
draw-ui
|
|
|
|
&no-toggle
|
2023-06-07 19:41:30 -04:00
|
|
|
POP
|
|
|
|
&no-menu
|
2023-03-18 00:20:28 -04:00
|
|
|
( color ) .color LDZ .Mouse/state DEI #01 GTH #00 EQU MUL
|
2023-06-07 22:13:15 -04:00
|
|
|
( cell* ) .Mouse/x DEI2 #03 SFT2 .Mouse/y DEI2 #03 SFT2 make-addr STA
|
2023-03-18 00:20:28 -04:00
|
|
|
redraw
|
|
|
|
|
|
|
|
BRK
|
|
|
|
|
|
|
|
@on-button ( -> )
|
|
|
|
|
|
|
|
.Controller/button DEI
|
2023-06-07 19:41:30 -04:00
|
|
|
[ #01 ] NEQk NIP ?&no-a #01 set-color &no-a
|
|
|
|
[ #02 ] NEQk NIP ?&no-b #02 set-color &no-b
|
|
|
|
[ #04 ] NEQk NIP ?&no-select #03 set-color &no-select
|
2023-03-18 00:20:28 -04:00
|
|
|
[ #08 ] NEQk NIP ?&no-start ;world #2000 mclr redraw &no-start
|
|
|
|
POP
|
|
|
|
( space )
|
|
|
|
.Controller/key DEI #20 NEQ ?&no-space .timer/play LDZk #00 EQU SWP STZ &no-space
|
|
|
|
|
|
|
|
BRK
|
|
|
|
|
|
|
|
(
|
|
|
|
@|core )
|
|
|
|
|
2023-06-07 19:41:30 -04:00
|
|
|
@set-color ( color -- )
|
|
|
|
|
|
|
|
.color STZ
|
|
|
|
.pointer/x LDZ2 .Screen/x DEO2
|
|
|
|
.pointer/y LDZ2 .Screen/y DEO2
|
|
|
|
;pointer-icn .Screen/addr DEO2
|
|
|
|
#40 .color LDZ ADD .Screen/sprite DEO
|
|
|
|
#00 .Mouse/state DEO
|
|
|
|
|
|
|
|
JMP2r
|
|
|
|
|
2023-03-18 00:20:28 -04:00
|
|
|
@run ( -- )
|
|
|
|
|
2023-06-07 19:41:30 -04:00
|
|
|
#4000
|
2023-03-18 00:20:28 -04:00
|
|
|
&ver
|
|
|
|
STHk
|
2023-06-07 19:41:30 -04:00
|
|
|
#4000
|
2023-03-18 00:20:28 -04:00
|
|
|
&hor
|
|
|
|
( x,y ) DUP STHkr
|
|
|
|
( cell ) DUP2 get-addr STH2k LDA
|
|
|
|
( transform ) transform STH2r [ LIT2 &future $2 ] ADD2 STA
|
|
|
|
INC GTHk ?&hor
|
|
|
|
POP2
|
|
|
|
POPr
|
|
|
|
INC GTHk ?&ver
|
|
|
|
POP2
|
|
|
|
( Swap worlds )
|
|
|
|
;get-addr/current LDA2k ;run/future LDA2 STH2k ADD2 SWP2 STA2
|
|
|
|
#0000 STH2r SUB2 ;run/future STA2
|
|
|
|
|
2023-06-07 19:41:30 -04:00
|
|
|
!redraw
|
2023-03-18 00:20:28 -04:00
|
|
|
|
|
|
|
@get-addr ( x y -- addr* )
|
|
|
|
|
|
|
|
#00 SWP #60 SFT2 ROT #00 SWP ADD2 [ LIT2 ¤t $2 ] ADD2
|
|
|
|
|
|
|
|
JMP2r
|
|
|
|
|
|
|
|
@transform ( xy cell -- cell )
|
|
|
|
|
|
|
|
DUP ?&no-null NIP NIP JMP2r &no-null
|
|
|
|
DUP #03 NEQ ?&no-head POP POP2 #02 JMP2r &no-head
|
|
|
|
DUP #02 NEQ ?&no-tail POP POP2 #01 JMP2r &no-tail
|
|
|
|
DUP #01 NEQ ?&no-cond POP
|
|
|
|
LITr 00
|
|
|
|
DUP2 #01 SUB get-addr
|
|
|
|
( tl ) #0001 SUB2 LDAk #03 NEQ JMP INCr
|
|
|
|
( tc ) INC2 LDAk #03 NEQ JMP INCr
|
|
|
|
( tr ) INC2 LDA #03 NEQ JMP INCr
|
|
|
|
DUP2 get-addr
|
|
|
|
( ml ) #0001 SUB2 LDAk #03 NEQ JMP INCr
|
|
|
|
( mr ) INC2 INC2 LDA #03 NEQ JMP INCr
|
|
|
|
INC get-addr
|
|
|
|
( bl ) #0001 SUB2 LDAk #03 NEQ JMP INCr
|
|
|
|
( bc ) INC2 LDAk #03 NEQ JMP INCr
|
|
|
|
( br ) INC2 LDA #03 NEQ JMP INCr
|
|
|
|
STHkr #02 EQU STHr #01 EQU ORA
|
|
|
|
DUP ADD INC JMP2r
|
|
|
|
&no-cond
|
|
|
|
( unknown )
|
|
|
|
NIP NIP
|
|
|
|
|
|
|
|
JMP2r
|
|
|
|
|
2023-06-07 19:41:30 -04:00
|
|
|
@mclr ( addr* len* -- )
|
|
|
|
|
|
|
|
OVR2 ADD2 SWP2
|
|
|
|
&loop
|
|
|
|
STH2k #00 STH2r STA
|
|
|
|
INC2 GTH2k ?&loop
|
|
|
|
POP2 POP2
|
|
|
|
|
|
|
|
JMP2r
|
|
|
|
|
2023-06-07 22:13:15 -04:00
|
|
|
@make-addr ( x* y* -- addr* )
|
|
|
|
|
|
|
|
#60 SFT2 ADD2 ;get-addr/current LDA2 ADD2
|
|
|
|
|
|
|
|
JMP2r
|
|
|
|
|
2023-03-18 00:20:28 -04:00
|
|
|
(
|
|
|
|
@|drawing )
|
|
|
|
|
|
|
|
@redraw ( -- )
|
|
|
|
|
|
|
|
;cell-icn .Screen/addr DEO2
|
2023-06-07 22:18:21 -04:00
|
|
|
[ LIT2 01 -Screen/auto ] DEO
|
2023-06-07 22:13:15 -04:00
|
|
|
#0000
|
|
|
|
DUP2 .Screen/x DEO2
|
|
|
|
.Screen/y DEO2
|
|
|
|
|
|
|
|
#1000 #0000
|
|
|
|
&l
|
|
|
|
( x ) DUP2 #003f AND2
|
|
|
|
( y ) OVR2 #06 SFT2
|
|
|
|
make-addr LDA .Screen/sprite DEO
|
|
|
|
INCk #3f AND ?&no-bound
|
|
|
|
#0000 .Screen/x DEO2
|
|
|
|
.Screen/y DEI2 #0008 ADD2 .Screen/y DEO2
|
|
|
|
&no-bound
|
|
|
|
INC2 GTH2k ?&l
|
|
|
|
POP2 POP2
|
2023-03-18 00:20:28 -04:00
|
|
|
|
|
|
|
@draw-ui ( -- )
|
|
|
|
|
|
|
|
( colors )
|
2023-06-07 22:18:21 -04:00
|
|
|
[ LIT2 01 -Screen/auto ] DEO
|
|
|
|
#0010
|
|
|
|
DUP2 .Screen/x DEO2
|
|
|
|
.Screen/y DEO2
|
2023-06-07 22:13:15 -04:00
|
|
|
;cell-icn .Screen/addr DEO2
|
2023-06-07 22:18:21 -04:00
|
|
|
[ LIT2 01 -Screen/sprite ] DEO
|
|
|
|
[ LIT2 02 -Screen/sprite ] DEO
|
|
|
|
[ LIT2 03 -Screen/sprite ] DEO
|
2023-03-18 00:20:28 -04:00
|
|
|
( toggle )
|
|
|
|
#0030 .Screen/x DEO2
|
2023-06-07 22:18:21 -04:00
|
|
|
;toggle-icn [ LIT2 00 -timer/play ] LDZ #30 SFT2 ADD2 .Screen/addr DEO2
|
|
|
|
[ LIT2 01 -Screen/sprite ] DEO
|
2023-03-18 00:20:28 -04:00
|
|
|
|
|
|
|
JMP2r
|
|
|
|
|
|
|
|
(
|
|
|
|
@|assets )
|
|
|
|
|
|
|
|
@pointer-icn [
|
|
|
|
80c0 e0f0 f8e0 1000 ]
|
|
|
|
@cell-icn [
|
|
|
|
7cfe fefe fefe 7c00 ]
|
|
|
|
@toggle-icn [
|
2023-06-07 19:41:30 -04:00
|
|
|
6666 6666 6666 6600
|
|
|
|
4666 767e 7666 4600 ]
|
2023-03-18 00:20:28 -04:00
|
|
|
|
|
|
|
(
|
|
|
|
I live in the atom with the happy protons and neutrons.
|
|
|
|
I'm also so negative all the freakin time.
|
|
|
|
What do I do?
|
|
|
|
How do I find peace? )
|
|
|
|
|
|
|
|
@world
|
|
|
|
|