-
Notifications
You must be signed in to change notification settings - Fork 0
/
graphics.asm
141 lines (120 loc) · 3.28 KB
/
graphics.asm
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#include p18f87k22.inc
#include constants.inc
global render_graphics, grid_value_out
extern item_x, item_y, draw_item, grid_iter
extern wall_x, wall_y, draw_wall
extern goal_x, goal_y, draw_goal
extern fire_x, fire_y, draw_fire
acs0 udata_acs
onevolt res 1
grid_value_out res 1
yx res 1
counter res 1
pos res 1
graphics code
render_graphics
movlw onevolt_hex
movwf onevolt
movlw 0x07
mulwf grid_iter
movf PRODL, W
addwf counter, 0 ; store result in W
movwf pos
movff PLUSW1, grid_value_out
movlw 0x07 ; < decimal 7
cpfslt grid_iter ; skip next line if iter < 7 decimal
clrf grid_iter ; resets iter to 0
check_item
movlw item
xorwf grid_value_out, 0 ; Store result of XOR in W
btfsc STATUS, Z
goto set_item_xy
check_wall
movlw wall
cpfseq grid_value_out ; compare if grid_value_out == wall
bra check_boundary ; if != wall
goto set_wall_xy ; if == wall
check_boundary
movlw boundary
cpfseq grid_value_out
bra check_fire ; if != boundary (and != wall)
goto set_wall_xy ; if == boundary
goto set_wall_xy
check_fire
movlw fire
xorwf grid_value_out, 0 ; Store result of XOR in W
btfsc STATUS, Z
goto set_fire_xy
check_goal
movlw goal
xorwf grid_value_out, 0 ; Store result of XOR in F
btfsc STATUS, Z
goto set_goal_xy
goto end_graphics
set_item_xy
movf pos, W
movff PLUSW0, yx
movlw 0x0F
andwf yx, 0 ; logical AND yx with 00001111 to get only low nibble stored in W
mulwf onevolt
movff PRODL, item_x ; item_x now holds x coordinates
swapf yx, 1 ; swap yx (to xy) result stored in yx
movlw 0x0F
andwf yx, 0 ; logical AND. Result stored in W.
mulwf onevolt
movff PRODL, item_y ; item_y now holds high nibbles in original yx. Holds y coordinates
call draw_item
goto end_graphics
set_wall_xy
movf pos, W
movff PLUSW0, yx
movlw 0x0F
andwf yx, 0 ; logical AND yx with 00001111 to get only low nibble stored in W
mulwf onevolt
movff PRODL, wall_x ; wall_x now holds x coordinates
swapf yx, 1 ; swap yx (to xy) result stored in yx
movlw 0x0F
andwf yx, 0 ; logical AND. Result stored in W.
mulwf onevolt
movff PRODL, wall_y ; wall_y now holds high nibbles in original yx. Holds y coordinates
call draw_wall
goto end_graphics
set_fire_xy
movf pos, W
movff PLUSW0, yx
movlw 0x0F
andwf yx, 0 ; logical AND yx with 00001111 to get only low nibble stored in W
mulwf onevolt
movff PRODL, fire_x ; wall_x now holds x coordinates
swapf yx, 1 ; swap yx (to xy) result stored in yx
movlw 0x0F
andwf yx, 0 ; logical AND. Result stored in W.
mulwf onevolt
movff PRODL, fire_y ; wall_y now holds high nibbles in original yx. Holds y coordinates
call draw_fire
goto end_graphics
set_goal_xy
movf pos, W
movff PLUSW0, yx
movlw 0x0F
andwf yx, 0 ; logical AND yx with 00001111 to get only low nibble stored in W
mulwf onevolt
movff PRODL, goal_x ; goal_x now holds x coordinates
swapf yx, 1 ; swap yx (to xy) result stored in yx
movlw 0x0F
andwf yx, 0 ; logical AND. Result stored in W.
mulwf onevolt
movff PRODL, goal_y ; goal_y now holds high nibbles in original yx. Holds y coordinates
call draw_goal
goto end_graphics
end_graphics
incf counter
movlw 0x07
cpfslt counter
goto increment_grid_iter
bra render_graphics
increment_grid_iter
clrf counter
incf grid_iter
return
end