summaryrefslogtreecommitdiff
path: root/tetris/blocks.prn
blob: 17d783e6708cfc04dd109fab3ef24496b1696fc5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
7 "b_nblocks" store

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  #the tetris standard colours -- sort of
b_nblocks mkarrayp "b_blockclrs" store


#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 blockrot
	"blockrot" store
	"blockidx" store
	blockidx blockrot b_getblock "blockbits" store
	"y" store
	"x" store

	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
}