Created
August 12, 2024 23:29
-
-
Save Ismael-VC/d423600f8ef0afe2834ed472291473aa to your computer and use it in GitHub Desktop.
Changing colors at runtime in UXN.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|00 @System | |
&vector $2 &expansion $2 &wst $1 &rst $1 &metadata $2 &r $2 &g $2 &b $2 | |
&debug $1 &state $1 | |
|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $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 | |
|100 | |
@on-reset ( -> ) | |
#f07f .System/r DEO2 | |
#f0d6 .System/g DEO2 | |
#f0b2 .System/b DEO2 | |
#0100 .Screen/height DEO2 | |
#0200 .Screen/width DEO2 | |
;heart .Screen/addr DEO2 | |
#0000 .Screen/x DEO2 | |
#0000 .Screen/y DEO2 | |
#41 .Screen/sprite DEO | |
#0008 .Screen/x DEO2 | |
#42 .Screen/sprite DEO | |
#0010 .Screen/x DEO2 | |
#43 .Screen/sprite DEO | |
prng-init | |
;random-theme .Controller/vector DEO2 | |
BRK | |
@random-theme ( -- ) | |
pstr: "Changing 20 "theme! 0a00 | |
prng .System/r DEO2 | |
prng .System/g DEO2 | |
prng .System/b DEO2 | |
BRK | |
@set-theme ( r^ g^ b^ -- ) | |
( b^ ) #f07f .System/b DEO2 | |
( g^ ) #f0d6 .System/g DEO2 | |
( r^ ) .System/r DEO2 | |
JMP2r | |
@prng-init ( -- ) | |
[ LIT2 00 -DateTime/second ] DEI | |
[ LIT2 00 -DateTime/minute ] DEI #60 SFT2 EOR2 | |
[ LIT2 00 -DateTime/hour ] DEI #c0 SFT2 EOR2 ,prng/x STR2 | |
[ LIT2 00 -DateTime/hour ] DEI #04 SFT2 | |
[ LIT2 00 -DateTime/day ] DEI #10 SFT2 EOR2 | |
[ LIT2 00 -DateTime/month ] DEI #60 SFT2 EOR2 | |
.DateTime/year DEI2 #a0 SFT2 EOR2 ,prng/y STR2 | |
JMP2r | |
@prng ( -- number* ) | |
[ LIT2 &x $2 ] | |
DUP2 #50 SFT2 EOR2 | |
DUP2 #03 SFT2 EOR2 | |
[ LIT2 &y $2 ] DUP2 ,&x STR2 | |
DUP2 #01 SFT2 EOR2 EOR2 | |
,&y STR2k POP | |
JMP2r | |
@pstr: ( -- ) | |
STH2r | |
&loop | |
LDAk .Console/write DEO | |
INC2 LDAk ?&loop | |
INC2 JMP2 | |
@heart | |
00 66 ff ff ff 7e 3c 18 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment