File tree Expand file tree Collapse file tree 4 files changed +77
-6
lines changed Expand file tree Collapse file tree 4 files changed +77
-6
lines changed Original file line number Diff line number Diff line change 1+ |00 @System &vector $2 &pad $6 &r $2 &g $2 &b $2
2+ |10 @Console &vector $2 &read $1 &pad $5 &write $1 &error $1
3+ |20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
Original file line number Diff line number Diff line change 1+ # Compile with:
2+ # cac main.cal -b uxn -i ../../std -h header.tal -o sierpinski.rom
3+
4+ include "cores/select.cal"
5+
6+ func init_palette begin asm
7+ # 0f 0f 3f 0f 0e 0f
8+ "#0f0f .System/r DEO2"
9+ "#3f0f .System/g DEO2"
10+ "#0e0f .System/b DEO2"
11+ end end
12+
13+ func set_screen_size begin asm # width, height
14+ ".Screen/height DEO2"
15+ ".Screen/width DEO2"
16+ end end
17+
18+ func get_screen_size begin asm # -> width, height
19+ ".Screen/width DEI2"
20+ ".Screen/height DEI2"
21+ end end
22+
23+ inline draw_pixel begin asm # colour, x, y
24+ ".Screen/y DEO2"
25+ ".Screen/x DEO2"
26+ "NIP .Screen/pixel DEO"
27+ end end
28+
29+ func sierpinski begin
30+ let cell n
31+ let cell x
32+ let cell y
33+ let cell pad
34+ let cell rowStart
35+ 2 * n !
36+
37+ 0 y !
38+ n @ 2 / pad !
39+
40+ n @ 2 / n @ 2 / set_screen_size
41+
42+ while y @ n @ 2 / < do
43+ 0 x !
44+
45+ while x @ pad @ < do
46+ x @ 1 + x !
47+ end
48+
49+ x @ 2 / rowStart !
50+ 0 x !
51+
52+ while x @ n @ < do
53+ if x @ n @ y @ 1 + - and then
54+
55+ else
56+ 1 x @ rowStart @ + y @ draw_pixel
57+ end
58+
59+ x @ 1 + x !
60+ end
61+
62+ y @ 1 + y !
63+ pad @ 1 - pad !
64+ end
65+ end
66+
67+ init_palette
68+ 512 sierpinski
Original file line number Diff line number Diff line change @@ -301,10 +301,12 @@ int main(string[] args) {
301301 catch (PreprocessorError) {
302302 return 1 ;
303303 }
304-
305- /* auto codeRemover = new CodeRemover();
306- codeRemover.Run(nodes);
307- nodes = codeRemover.res;*/
304+
305+ if (optimise) {
306+ auto codeRemover = new CodeRemover();
307+ codeRemover.Run(nodes);
308+ nodes = codeRemover.res;
309+ }
308310
309311 compiler.versions = preproc.versions;
310312
Original file line number Diff line number Diff line change @@ -115,7 +115,6 @@ class BackendUXN : CompilerBackend {
115115 override long MaxInt () => 0xFFFF ;
116116
117117 override string DefaultHeader () => "
118- |0 @vsp $2 @arraySrc $2 @arrayDest $2
119118 |10 @Console &vector $2 &read $1 &pad $5 &write $1 &error $1
120119 " ;
121120
@@ -153,7 +152,6 @@ class BackendUXN : CompilerBackend {
153152
154153 override void Init () {
155154 output ~= " |0 @vsp $2 @arraySrc $2 @arrayDest $2\n " ;
156- output ~= " |10 @Console &vector $2 &read $1 &pad $5 &write $1 &error $1\n " ;
157155 output ~= " |100\n " ;
158156 output ~= " @on-reset\n " ;
159157 output ~= " #ffff .vsp STZ2\n " ;
You can’t perform that action at this time.
0 commit comments