-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
77 additions
and
6 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|00 @System &vector $2 &pad $6 &r $2 &g $2 &b $2 | ||
|10 @Console &vector $2 &read $1 &pad $5 &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 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# Compile with: | ||
# cac main.cal -b uxn -i ../../std -h header.tal -o sierpinski.rom | ||
|
||
include "cores/select.cal" | ||
|
||
func init_palette begin asm | ||
# 0f 0f 3f 0f 0e 0f | ||
"#0f0f .System/r DEO2" | ||
"#3f0f .System/g DEO2" | ||
"#0e0f .System/b DEO2" | ||
end end | ||
|
||
func set_screen_size begin asm # width, height | ||
".Screen/height DEO2" | ||
".Screen/width DEO2" | ||
end end | ||
|
||
func get_screen_size begin asm # -> width, height | ||
".Screen/width DEI2" | ||
".Screen/height DEI2" | ||
end end | ||
|
||
inline draw_pixel begin asm # colour, x, y | ||
".Screen/y DEO2" | ||
".Screen/x DEO2" | ||
"NIP .Screen/pixel DEO" | ||
end end | ||
|
||
func sierpinski begin | ||
let cell n | ||
let cell x | ||
let cell y | ||
let cell pad | ||
let cell rowStart | ||
2 * n ! | ||
|
||
0 y ! | ||
n @ 2 / pad ! | ||
|
||
n @ 2 / n @ 2 / set_screen_size | ||
|
||
while y @ n @ 2 / < do | ||
0 x ! | ||
|
||
while x @ pad @ < do | ||
x @ 1 + x ! | ||
end | ||
|
||
x @ 2 / rowStart ! | ||
0 x ! | ||
|
||
while x @ n @ < do | ||
if x @ n @ y @ 1 + - and then | ||
|
||
else | ||
1 x @ rowStart @ + y @ draw_pixel | ||
end | ||
|
||
x @ 1 + x ! | ||
end | ||
|
||
y @ 1 + y ! | ||
pad @ 1 - pad ! | ||
end | ||
end | ||
|
||
init_palette | ||
512 sierpinski |
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
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