2 * This program is free software: you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation, either version 3 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 ; item_id: item id or 0 (be careful: it DESTROYS item_id tvar)
17 ; rst_result: item thread id
18 ; stack: item id (or 0)
20 proc: game_item_at_prof
26 jne .next, THREAD_STATE_RUNNING
28 get [.cnt], item_id, [.type]
29 jlt .next, [.type], ITEM_KEY
30 jgt .next, [.type], ITEM_GLOVES
34 ; only standing on tile
45 set [item_id], [.type]
46 set [rst_result], [.cnt]
50 jlt .loop, [.cnt], 257
54 endp: game_item_at_prof
58 jeq .quit, [prof_item], 0
59 set pos_x, [pos_x], [prof_item]
60 set pos_y, [pos_y], [prof_item]
66 jeq .quit, [spr_num], PSPR_FACING
67 set [spr_num], PSPR_TURNING
70 set [spr_dir], DIR_LEFT
71 set [spr_num], PSPR_FACING
75 set [prof_dir], PDIR_FACING
79 ; set 'prof_dir' to new dir and call this
81 jeq prof_turn_to_player, [prof_dir], PDIR_FACING
82 ; to left or to right, maybe thru 'facing'
83 jeq .looking_to_player, [spr_num], PSPR_FACING
84 jeq .looking_left, [spr_dir], DIR_LEFT
87 jeq .quit, [prof_dir], PDIR_RIGHT ; ok
89 bsr prof_turn_to_player
90 set [prof_dir], PDIR_LEFT
93 set [spr_num], PSPR_TURNING
96 set [spr_num], PSPR_STANDING
102 jeq .quit, [prof_dir], PDIR_LEFT ; ok
104 bsr prof_turn_to_player
105 set [prof_dir], PDIR_RIGHT
107 set [spr_dir], DIR_RIGHT
108 jmp .complete_turning
112 jeq .to_left, [prof_dir], PDIR_LEFT
119 prof_allowed_move_in_dir:
128 ;proc: prof_allowed_move_in_dir_check
130 ; add [pos_x], [prof_dir], [.t]
131 ; mgb [.t], -666, [.t]
133 ;endp: prof_allowed_move_in_dir_check
136 prof_allowed_move_in_dir_check:
148 set [spr_num], PSPR_TAKING0
151 set [spr_num], PSPR_TAKING1
155 bsr game_item_at_prof
158 jeq .nopitem, [prof_item], 0
160 get [prof_item], item_id
162 set spr_dir, DIR_LEFT, [prof_item]
165 jeq .put_item, [.profdir], PDIR_FACING
166 set spr_dir, DIR_LEFT, [prof_item]
167 jeq .put_item, [.profdir], PDIR_LEFT
168 set spr_dir, DIR_RIGHT, [prof_item]
170 set pos_x, [pos_x], [prof_item]
171 set pos_y, [pos_y], [prof_item]
172 set pos_tx, 0, [prof_item]
173 set pos_ty, 0, [prof_item]
177 jeq .done, [rst_result], 0
179 set [prof_item], [rst_result]
182 set [spr_num], PSPR_TAKING0
185 set [spr_num], PSPR_FACING
195 add [prof_dir], [pos_x], [.x]
196 add [.dy], [pos_y], [.y]
197 mgf [.x], [.y], [.dy]
205 add [prof_dir], [pos_x], [.x]
206 add [.dy], [pos_y], [.y]
207 msf [.x], [.y], [.tile]
212 proc: get_tile_at_dx_dy
215 add [prof_dir], [pos_x], [.x]
217 add [.dy], [pos_y], [.y]
218 mgf [.x], [.y], [.dy]
220 endp: get_tile_at_dx_dy
223 proc: set_tile_at_dx_dy
226 add [prof_dir], [pos_x], [.x]
228 add [.dy], [pos_y], [.y]
229 msf [.x], [.y], [.tile]
231 endp: set_tile_at_dx_dy
236 proc: game_lift_all_items
241 ; only running thread
243 jne .next, THREAD_STATE_RUNNING
245 get [.cnt], item_id, [.type]
246 jlt .next, [.type], ITEM_KEY
247 jgt .next, [.type], ITEM_GLOVES
251 ;get [.cnt], activated
253 ; only standing on tile
265 set pos_ty, [.dy], [.cnt]
266 set liftdown, 0, [.cnt]
269 jlt .loop, [.cnt], 257
271 endp: game_lift_all_items