summaryrefslogtreecommitdiff
path: root/tetris/blocks.prn
diff options
context:
space:
mode:
Diffstat (limited to 'tetris/blocks.prn')
-rw-r--r--tetris/blocks.prn73
1 files changed, 44 insertions, 29 deletions
diff --git a/tetris/blocks.prn b/tetris/blocks.prn
index 0eb91f5..17d783e 100644
--- a/tetris/blocks.prn
+++ b/tetris/blocks.prn
@@ -1,41 +1,56 @@
7 "b_nblocks" store
-15 23 71 51 54 99 114
+15 4369 15 4369 4 mkarrayp #I
+23 547 116 785 4 mkarrayp #L
+71 802 113 275 4 mkarrayp #J
+51 51 51 51 4 mkarrayp #O
+54 561 54 561 4 mkarrayp #S
+99 306 99 306 4 mkarrayp #Z
+114 610 624 562 4 mkarrayp #T
b_nblocks mkarrayp "b_blocks" store
- 6 3 4 7 2 1 5
+6 3 4 7 2 1 5 #the tetris standard colours -- sort of
b_nblocks mkarrayp "b_blockclrs" store
-@defun "b_getblock" { #arg: block idx [0..(b_nblocks-1)]
- "b_blocks" swapoutvar swap arridx swap "b_blocks" gstore
+
+#returns the bits for the specified block
+@defun "b_getblock" { #args: blockidx blockrot (idx in [0..(b_nblocks-1)], rot in [0..3])
+ "r" store
+ "i" store
+ #"b_blocks" swapoutvar swap arridx swap "b_blocks" gstore
+ "b_blocks" swapoutvar
+ i arridx
+ swap "b_blocks" gstore
+ r arridx
+ swap pop
}
-@defun "b_drawblock" { #args: x y blockidx
- dup "blockidx" store
- b_getblock "blockbits" store
+@defun "b_drawblock" { #args: x y blockidx blockrot
+ "blockrot" store
+ "blockidx" store
+ blockidx blockrot b_getblock "blockbits" store
"y" store
"x" store
- blockbits 16 % "row1" store
- blockbits 16 / "row2" store
-
- x "xx" store
- row1 while
- row1 2 % if
- xx y blockidx io_gsquare
- end
- xx 1 + "xx" store
- row1 2 / "row1" store
- row1 end
-
- y 1 + "y" store
-
- x "xx" store
- row2 while
- row2 2 % if
- xx y blockidx io_gsquare
- end
- xx 1 + "xx" store
- row2 2 / "row2" store
- row2 end
+ blockbits while
+
+ 0 "i" store
+ i 4 < while
+ blockbits 1 & if
+ x i + y blockidx io_gsquare
+ end
+ i 1 + "i" store
+ blockbits 2 / "blockbits" store
+ i 4 < end
+
+ y 1 + "y" store
+
+ blockbits end
+}
+
+@defun "b_undrawblock" { #args: x y blockidx blockrot
+ io_blockchar "temp" store
+ " " "io_blockchar" gstore
+ b_drawblock
+ temp "io_blockchar" gstore
}