(wireworld) Cleanup

This commit is contained in:
Devine Lu Linvega 2023-06-07 16:41:30 -07:00
parent f237ac0578
commit ba7c2f861b
1 changed files with 53 additions and 52 deletions

View File

@ -1,14 +1,10 @@
( uxnemu wireworld.rom )
( wireworld
(
Wireworld:
- electron head<3>, becomes electron tail<2>
- electron tail<2>, becomes conductor<1>
- conductor<1>, becomes electron head<3>
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. )
( devices )
|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
@ -20,12 +16,15 @@
@pointer &x $2 &y $2
@timer &frame $1 &play $1
(
@|vectors )
|0100 ( -> )
( theme )
#07fe .System/r DEO2
#07b6 .System/g DEO2
#0fc6 .System/b DEO2
#0ff2 .System/r DEO2
#0d46 .System/g DEO2
#006f .System/b DEO2
( size )
#0100 .Screen/width DEO2
#0100 .Screen/height DEO2
@ -34,8 +33,8 @@
;on-mouse .Mouse/vector DEO2
;on-button .Controller/vector DEO2
( setup )
#00 .timer/play STZ
#01 .color STZ
#01 .timer/play STZ
#01 set-color
( start )
;world ;get-addr/current STA2
#1000 ;run/future STA2
@ -67,36 +66,30 @@ BRK
.Mouse/y DEI2 DUP2 .pointer/y STZ2 .Screen/y DEO2
#40 .color LDZ ADD .Screen/sprite DEO
( paint )
.Mouse/state DEI ?on-mouse-down
.Mouse/state DEI ?&down
BRK
@on-mouse-down ( -> )
&down ( -> )
.Mouse/y DEI2 #03 SFT2 NIP #02 NEQ ?&no-menu
.Mouse/x DEI2 #03 SFT2 NIP
.Mouse/y DEI2 #03 SFT2 NIP
#0202 NEQ2k NIP2 ?&no-color1
#01 .color STZ
#00 .Mouse/state DEO
POP2 BRK
DUP #02 NEQ ?&no-color1
#01 set-color
&no-color1
#0302 NEQ2k NIP2 ?&no-color2
#02 .color STZ
#00 .Mouse/state DEO
POP2 BRK
DUP #03 NEQ ?&no-color2
#02 set-color
&no-color2
#0402 NEQ2k NIP2 ?&no-color3
#03 .color STZ
#00 .Mouse/state DEO
POP2 BRK
DUP #04 NEQ ?&no-color3
#03 set-color
&no-color3
#0602 NEQ2k NIP2 ?&no-toggle
DUP #06 NEQ ?&no-toggle
.timer/play LDZk #00 EQU SWP STZ
#00 .Mouse/state DEO
draw-ui
POP2 BRK
&no-toggle
POP2
POP
&no-menu
( color ) .color LDZ .Mouse/state DEI #01 GTH #00 EQU MUL
( cell* ) .Mouse/x DEI2 #02 SFT2 NIP .Mouse/y DEI2 #02 SFT2 NIP
@ -108,9 +101,9 @@ BRK
@on-button ( -> )
.Controller/button DEI
[ #01 ] NEQk NIP ?&no-a #01 .color STZ &no-a
[ #02 ] NEQk NIP ?&no-b #02 .color STZ &no-b
[ #04 ] NEQk NIP ?&no-select #03 .color STZ &no-select
[ #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
[ #08 ] NEQk NIP ?&no-start ;world #2000 mclr redraw &no-start
POP
( space )
@ -121,12 +114,23 @@ BRK
(
@|core )
@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
@run ( -- )
#40 #00
#4000
&ver
STHk
#40 #00
#4000
&hor
( x,y ) DUP STHkr
( cell ) DUP2 get-addr STH2k LDA
@ -139,9 +143,8 @@ BRK
( Swap worlds )
;get-addr/current LDA2k ;run/future LDA2 STH2k ADD2 SWP2 STA2
#0000 STH2r SUB2 ;run/future STA2
redraw
JMP2r
!redraw
@get-addr ( x y -- addr* )
@ -175,6 +178,16 @@ JMP2r
JMP2r
@mclr ( addr* len* -- )
OVR2 ADD2 SWP2
&loop
STH2k #00 STH2r STA
INC2 GTH2k ?&loop
POP2 POP2
JMP2r
(
@|drawing )
@ -195,8 +208,6 @@ JMP2r
INC GTHk ?&ver
POP2
( >> )
@draw-ui ( -- )
( colors )
@ -213,16 +224,6 @@ JMP2r
JMP2r
@mclr ( addr* len* -- )
OVR2 ADD2 SWP2
&loop
STH2k #00 STH2r STA
INC2 GTH2k ?&loop
POP2 POP2
JMP2r
(
@|assets )
@ -233,8 +234,8 @@ JMP2r
@color-icn [
7cfe fefe fefe 7c00 ]
@toggle-icn [
( pause ) 6666 6666 6666 6600
( play ) 4666 767e 7666 4600 ]
6666 6666 6666 6600
4666 767e 7666 4600 ]
(
I live in the atom with the happy protons and neutrons.