💾 Archived View for m15o.smol.pub › 1630436418 captured on 2024-02-05 at 09:33:12. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2021-12-03)

-=-=-=-=-=-=-

m15o

uxn

I just discovered uxn, a programmable virtual computer with its own assembly language. I spent a few hours learning it over the last couple days and it's extremely fun. I did do a little bit of assembly when I was in engineering school around 10 years ago, but it's nothing like "uxntal" (or simply tal), the assembly programming language that comes with uxn. It comes with great ideas that makes writing assembly a little like a game.

So hold and behold my first rom, it's called "bg-change" and it changes the background color over time. Pretty slick, isn't it? Code below, if you're interested.

You can actually run this rom by heading to:

https://metasyn.github.io/learn-uxn/

From there you can copy/paste the code and assemble it. You'll probably be disappointed though!

However if you do want to learn how to program the uxn machine, have a look at the following tutorial:

https://compudanzas.net/uxn_tutorial.html

And now the code:

( bg-change.tal )
( Change bg color over time)

( devices )
|00 @System  [ &vector $2 &pad $6   &r $2 &g $2 &b $2 ]
|20 @Screen  [ &vector $2 &width $2 &height $2 &pad  $2 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 ]

( macros )
%ADD-VAL { #0800 } ( -- val )

( zero page )
|0000
@loop [ &r $1 &g $1 ]

( init )
|0100
	( set system colors )
	#9728 .System/r DEO2
	#3928 .System/g DEO2
	#1af3 .System/b DEO2

	( attach the address of on-frame to the screen vector )
	;on-frame .Screen/vector DEO2
BRK

@on-frame ( -> )
	 .loop/r LDZ #00 EQU
	 ,&red JCN
	 .loop/g LDZ #00 EQU
	 ,&green JCN
	 ,&blue JMP
	 BRK

	 &red
	      	.System/r DEI2 ADD-VAL ADD2 .System/r DEO2
		#01 .loop/r STZ
 	 BRK
	 &green
	      	.System/g DEI2 ADD-VAL ADD2 .System/g DEO2
		.System/g DEI2 #ffff EQU ,&reset-red JCN
		#01 .loop/g STZ
		BRK
		&reset-red #00 .loop/r STZ
	 BRK
	 &blue
	   	.System/b DEI2 ADD-VAL ADD2 .System/b DEO2
		.System/b DEI2 #ffff EQU ,&reset-green JCN
		BRK
		&reset-green #00 .loop/g STZ
	 BRK
BRK

EOF

Written with Smol Pub

From Dusk's End, Nightfall City

m15o@posteo.net