2022-05-28 13:00:31 -04:00
|
|
|
(
|
2022-02-03 22:52:12 -05:00
|
|
|
wireworld
|
2022-05-28 13:00:31 -04:00
|
|
|
|
2022-02-03 22:52:12 -05:00
|
|
|
A - conductor
|
|
|
|
B - tail
|
|
|
|
Sel - head
|
|
|
|
Start - clear
|
|
|
|
mouse1 - paint
|
|
|
|
mouse2 - erase
|
|
|
|
|
|
|
|
RULES:
|
2022-05-28 13:00:31 -04:00
|
|
|
- electron head<3>, becomes electron tail<2>
|
|
|
|
- electron tail<2>, becomes conductor<1>
|
|
|
|
- conductor<1>, becomes electron head<3>
|
|
|
|
if there are exactly 1 or 2 electron heads around it. )
|
2022-01-21 18:02:46 -05:00
|
|
|
|
|
|
|
( devices )
|
|
|
|
|
2022-05-28 13:00:31 -04:00
|
|
|
|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
|
2022-01-21 18:02:46 -05:00
|
|
|
|
|
|
|
|0000
|
|
|
|
|
|
|
|
@color $1
|
2022-05-28 13:00:31 -04:00
|
|
|
@pointer &x $2 &y $2
|
|
|
|
@timer &frame $1 &play $1
|
2022-01-21 18:02:46 -05:00
|
|
|
|
|
|
|
( program )
|
|
|
|
|
|
|
|
|0100 ( -> )
|
|
|
|
|
2022-05-28 13:00:31 -04:00
|
|
|
( theme )
|
|
|
|
#07fe .System/r DEO2
|
|
|
|
#07b6 .System/g DEO2
|
|
|
|
#0fc6 .System/b DEO2
|
2022-01-21 18:02:46 -05:00
|
|
|
( size )
|
2022-05-28 13:00:31 -04:00
|
|
|
#0100 .Screen/width DEO2
|
|
|
|
#0100 .Screen/height DEO2
|
|
|
|
( vectors )
|
2022-01-21 18:02:46 -05:00
|
|
|
;on-frame .Screen/vector DEO2
|
|
|
|
;on-mouse .Mouse/vector DEO2
|
|
|
|
;on-button .Controller/vector DEO2
|
|
|
|
( setup )
|
2022-01-21 18:14:36 -05:00
|
|
|
#01 .timer/play STZ
|
2022-01-21 18:02:46 -05:00
|
|
|
#01 .color STZ
|
2022-05-28 13:00:31 -04:00
|
|
|
( start )
|
2022-01-22 19:32:46 -05:00
|
|
|
;world ;get-addr/current STA2
|
2022-05-28 13:00:31 -04:00
|
|
|
#1000 ;run/future STA2
|
2022-01-21 18:02:46 -05:00
|
|
|
;redraw JSR2
|
|
|
|
|
|
|
|
BRK
|
|
|
|
|
|
|
|
@on-frame ( -> )
|
|
|
|
|
2022-01-21 18:14:36 -05:00
|
|
|
.timer/play LDZ JMP BRK
|
|
|
|
( every 4th )
|
2022-05-28 13:00:31 -04:00
|
|
|
.timer/frame LDZk
|
|
|
|
#03 AND ,&no-run JCN
|
2022-01-22 18:49:32 -05:00
|
|
|
;run JSR2
|
2022-01-21 18:14:36 -05:00
|
|
|
&no-run
|
2022-01-21 18:02:46 -05:00
|
|
|
LDZk INC SWP STZ
|
|
|
|
|
|
|
|
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 )
|
2022-05-28 13:00:31 -04:00
|
|
|
.Mouse/x DEI2 DUP2 .pointer/x STZ2 .Screen/x DEO2
|
2022-01-21 18:02:46 -05:00
|
|
|
.Mouse/y DEI2 DUP2 .pointer/y STZ2 .Screen/y DEO2
|
2022-05-28 13:00:31 -04:00
|
|
|
#40 .color LDZ ADD .Screen/sprite DEO
|
2022-01-21 18:14:36 -05:00
|
|
|
( paint )
|
2022-05-28 13:00:31 -04:00
|
|
|
.Mouse/state DEI ,on-mouse-down JCN
|
2022-01-21 18:02:46 -05:00
|
|
|
|
|
|
|
BRK
|
|
|
|
|
2022-05-28 13:00:31 -04:00
|
|
|
@on-mouse-down ( -> )
|
|
|
|
|
|
|
|
.Mouse/x DEI2 #03 SFT2 NIP
|
|
|
|
.Mouse/y DEI2 #03 SFT2 NIP
|
|
|
|
#0202 NEQ2k NIP2 ,&no-color1 JCN
|
|
|
|
#01 .color STZ
|
|
|
|
#00 .Mouse/state DEO
|
|
|
|
POP2 BRK
|
|
|
|
&no-color1
|
|
|
|
#0302 NEQ2k NIP2 ,&no-color2 JCN
|
|
|
|
#02 .color STZ
|
|
|
|
#00 .Mouse/state DEO
|
|
|
|
POP2 BRK
|
|
|
|
&no-color2
|
|
|
|
#0402 NEQ2k NIP2 ,&no-color3 JCN
|
|
|
|
#03 .color STZ
|
|
|
|
#00 .Mouse/state DEO
|
|
|
|
POP2 BRK
|
|
|
|
&no-color3
|
|
|
|
#0602 NEQ2k NIP2 ,&no-toggle JCN
|
|
|
|
.timer/play LDZk #00 EQU SWP STZ
|
|
|
|
#00 .Mouse/state DEO
|
|
|
|
;draw-ui JSR2
|
|
|
|
POP2 BRK
|
|
|
|
&no-toggle
|
|
|
|
POP2
|
|
|
|
|
|
|
|
( color ) .color LDZ .Mouse/state DEI #01 GTH #00 EQU MUL
|
|
|
|
( cell* ) .Mouse/x DEI2 #02 SFT2 NIP .Mouse/y DEI2 #02 SFT2 NIP
|
|
|
|
;get-addr JSR2 STA
|
|
|
|
;redraw JSR2
|
|
|
|
|
|
|
|
BRK
|
|
|
|
|
|
|
|
@print ( short* -- )
|
|
|
|
|
|
|
|
SWP ,&byte JSR
|
|
|
|
&byte ( byte -- ) DUP #04 SFT ,&char JSR
|
|
|
|
&char ( char -- ) #0f AND DUP #09 GTH #27 MUL ADD #30 ADD #18 DEO
|
|
|
|
|
|
|
|
JMP2r
|
|
|
|
|
2022-02-03 22:52:12 -05:00
|
|
|
@on-button ( -> )
|
|
|
|
|
|
|
|
.Controller/button DEI
|
2022-05-28 13:00:31 -04:00
|
|
|
[ #01 ] NEQk NIP ,&no-a JCN #01 .color STZ &no-a
|
|
|
|
[ #02 ] NEQk NIP ,&no-b JCN #02 .color STZ &no-b
|
|
|
|
[ #04 ] NEQk NIP ,&no-select JCN #03 .color STZ &no-select
|
|
|
|
[ #08 ] NEQk NIP ,&no-start JCN ;world #2000 ;mclr JSR2 ;redraw JSR2 &no-start
|
2022-02-03 22:52:12 -05:00
|
|
|
POP
|
|
|
|
( space )
|
2022-05-28 13:00:31 -04:00
|
|
|
.Controller/key DEI #20 NEQ ,&no-space JCN .timer/play LDZk #00 EQU SWP STZ &no-space
|
2022-02-03 22:52:12 -05:00
|
|
|
|
|
|
|
BRK
|
|
|
|
|
2022-05-28 13:00:31 -04:00
|
|
|
@draw-ui ( -- )
|
|
|
|
|
|
|
|
( colors )
|
|
|
|
#01 .Screen/auto DEO
|
|
|
|
#0010 DUP2 .Screen/x DEO2 .Screen/y DEO2
|
|
|
|
;color-icn .Screen/addr DEO2
|
|
|
|
#01 .Screen/sprite DEO
|
|
|
|
#02 .Screen/sprite DEO
|
|
|
|
#03 .Screen/sprite DEO
|
|
|
|
( toggle )
|
|
|
|
#0030 .Screen/x DEO2
|
|
|
|
;toggle-icn #00 .timer/play LDZ #30 SFT2 ADD2 .Screen/addr DEO2
|
|
|
|
#01 .Screen/sprite DEO
|
|
|
|
|
|
|
|
JMP2r
|
|
|
|
|
2022-01-21 18:02:46 -05:00
|
|
|
@redraw ( -- )
|
|
|
|
|
|
|
|
;cell-icn .Screen/addr DEO2
|
2022-05-28 13:00:31 -04:00
|
|
|
#4000
|
2022-01-21 18:02:46 -05:00
|
|
|
&ver
|
2022-05-28 13:00:31 -04:00
|
|
|
#00 OVR #20 SFT2 .Screen/y DEO2
|
2022-01-21 18:02:46 -05:00
|
|
|
STHk
|
2022-05-28 13:00:31 -04:00
|
|
|
#4000
|
2022-01-21 18:02:46 -05:00
|
|
|
&hor
|
2022-05-28 13:00:31 -04:00
|
|
|
#00 OVR #20 SFT2 .Screen/x DEO2
|
2022-01-21 18:02:46 -05:00
|
|
|
DUP STHkr ,get-addr JSR LDA .Screen/sprite DEO
|
|
|
|
INC GTHk ,&hor JCN
|
|
|
|
POP2
|
|
|
|
POPr
|
|
|
|
INC GTHk ,&ver JCN
|
|
|
|
POP2
|
2022-05-28 13:00:31 -04:00
|
|
|
;draw-ui JSR2
|
2022-01-21 18:02:46 -05:00
|
|
|
|
2022-05-28 13:00:31 -04:00
|
|
|
JMP2r
|
2022-01-21 18:02:46 -05:00
|
|
|
|
|
|
|
@run ( -- )
|
|
|
|
|
2022-05-28 13:00:31 -04:00
|
|
|
#40 #00
|
2022-01-21 18:02:46 -05:00
|
|
|
&ver
|
|
|
|
STHk
|
2022-05-28 13:00:31 -04:00
|
|
|
#40 #00
|
2022-01-21 18:02:46 -05:00
|
|
|
&hor
|
2022-05-28 13:00:31 -04:00
|
|
|
( x,y ) DUP STHkr
|
2022-01-22 18:49:32 -05:00
|
|
|
( cell ) DUP2 ,get-addr JSR STH2k LDA
|
2022-05-28 13:00:31 -04:00
|
|
|
( transform ) ,transform JSR STH2r [ LIT2 &future $2 ] ADD2 STA
|
2022-01-21 18:02:46 -05:00
|
|
|
INC GTHk ,&hor JCN
|
|
|
|
POP2
|
|
|
|
POPr
|
|
|
|
INC GTHk ,&ver JCN
|
|
|
|
POP2
|
2022-02-03 22:52:12 -05:00
|
|
|
( Swap worlds )
|
2022-05-28 13:00:31 -04:00
|
|
|
;get-addr/current LDA2k ;run/future LDA2 STH2k ADD2 SWP2 STA2
|
|
|
|
#0000 STH2r SUB2 ;run/future STA2
|
2022-02-03 22:52:12 -05:00
|
|
|
,redraw JSR
|
2022-01-21 18:02:46 -05:00
|
|
|
|
2022-05-28 13:00:31 -04:00
|
|
|
JMP2r
|
2022-01-21 18:02:46 -05:00
|
|
|
|
|
|
|
@get-addr ( x y -- addr* )
|
|
|
|
|
2022-05-28 13:00:31 -04:00
|
|
|
#00 SWP #60 SFT2 ROT #00 SWP ADD2 [ LIT2 ¤t $2 ] ADD2
|
2022-01-21 18:02:46 -05:00
|
|
|
|
2022-05-28 13:00:31 -04:00
|
|
|
JMP2r
|
2022-01-21 18:02:46 -05:00
|
|
|
|
2022-01-22 17:48:07 -05:00
|
|
|
@transform ( xy cell -- cell )
|
2022-01-21 18:02:46 -05:00
|
|
|
|
2022-05-28 13:00:31 -04:00
|
|
|
DUP #00 NEQ ,&no-null JCN NIP NIP JMP2r &no-null
|
|
|
|
DUP #03 NEQ ,&no-head JCN POP POP2 #02 JMP2r &no-head
|
|
|
|
DUP #02 NEQ ,&no-tail JCN POP POP2 #01 JMP2r &no-tail
|
|
|
|
DUP #01 NEQ ,&no-cond JCN POP
|
2022-01-22 17:48:07 -05:00
|
|
|
LITr 00
|
2022-05-28 13:00:31 -04:00
|
|
|
DUP2 #01 SUB ,get-addr JSR
|
|
|
|
( tl ) #0001 SUB2 LDAk #03 NEQ JMP INCr
|
|
|
|
( tc ) INC2 LDAk #03 NEQ JMP INCr
|
|
|
|
( tr ) INC2 LDA #03 NEQ JMP INCr
|
2022-01-22 17:48:07 -05:00
|
|
|
DUP2 ,get-addr JSR
|
2022-05-28 13:00:31 -04:00
|
|
|
( ml ) #0001 SUB2 LDAk #03 NEQ JMP INCr
|
|
|
|
( mr ) INC2 INC2 LDA #03 NEQ JMP INCr
|
2022-01-22 17:48:07 -05:00
|
|
|
INC ,get-addr JSR
|
2022-05-28 13:00:31 -04:00
|
|
|
( 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 #0000 GTH2
|
|
|
|
#10 SFT INC JMP2r
|
2022-01-22 17:48:07 -05:00
|
|
|
&no-cond
|
|
|
|
( unknown )
|
|
|
|
NIP NIP
|
2022-01-21 18:02:46 -05:00
|
|
|
|
2022-05-28 13:00:31 -04:00
|
|
|
JMP2r
|
2022-01-21 18:02:46 -05:00
|
|
|
|
2022-01-22 17:54:02 -05:00
|
|
|
@mclr ( addr* len* -- )
|
|
|
|
|
2022-05-28 13:00:31 -04:00
|
|
|
OVR2 ADD2 SWP2
|
2022-01-22 17:54:02 -05:00
|
|
|
&loop
|
|
|
|
STH2k #00 STH2r STA
|
|
|
|
INC2 GTH2k ,&loop JCN
|
|
|
|
POP2 POP2
|
|
|
|
|
|
|
|
JMP2r
|
|
|
|
|
2022-05-28 13:00:31 -04:00
|
|
|
@pointer-icn
|
2022-01-21 18:14:36 -05:00
|
|
|
80c0 e0f0 f8e0 1000
|
2022-05-28 13:00:31 -04:00
|
|
|
@cell-icn
|
2022-01-21 18:14:36 -05:00
|
|
|
e0e0 e000 0000 0000
|
2022-05-28 13:00:31 -04:00
|
|
|
@color-icn
|
|
|
|
7cfe fefe fefe 7c00
|
|
|
|
@toggle-icn
|
|
|
|
( pause ) 6666 6666 6666 6600
|
|
|
|
( play ) 4666 767e 7666 4600
|
|
|
|
|
2022-01-21 18:02:46 -05:00
|
|
|
|
2022-05-28 13:00:31 -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?
|
2022-01-21 18:14:36 -05:00
|
|
|
How do I find peace? )
|
2022-01-21 18:02:46 -05:00
|
|
|
|
2022-01-22 19:32:46 -05:00
|
|
|
@world
|