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 rst FRST_GET_MAX_THREAD_ID
51 jle .loop, [.cnt], [rst_result]
55 endp: game_item_at_prof
59 jeq .quit, [prof_item], 0
60 set pos_x, [pos_x], [prof_item]
61 set pos_y, [pos_y], [prof_item]
67 jeq .quit, [spr_num], PSPR_FACING
68 set [spr_num], PSPR_TURNING
71 set [spr_dir], DIR_LEFT
72 set [spr_num], PSPR_FACING
76 set [prof_dir], PDIR_FACING
80 ; set 'prof_dir' to new dir and call this
82 jeq prof_turn_to_player, [prof_dir], PDIR_FACING
83 ; to left or to right, maybe thru 'facing'
84 jeq .looking_to_player, [spr_num], PSPR_FACING
85 jeq .looking_left, [spr_dir], DIR_LEFT
88 jeq .quit, [prof_dir], PDIR_RIGHT ; ok
90 bsr prof_turn_to_player
91 set [prof_dir], PDIR_LEFT
94 set [spr_num], PSPR_TURNING
97 set [spr_num], PSPR_STANDING
103 jeq .quit, [prof_dir], PDIR_LEFT ; ok
105 bsr prof_turn_to_player
106 set [prof_dir], PDIR_RIGHT
108 set [spr_dir], DIR_RIGHT
109 jmp .complete_turning
113 jeq .to_left, [prof_dir], PDIR_LEFT
120 prof_allowed_move_in_dir:
129 ;proc: prof_allowed_move_in_dir_check
131 ; add [pos_x], [prof_dir], [.t]
132 ; mgb [.t], -666, [.t]
134 ;endp: prof_allowed_move_in_dir_check
137 prof_allowed_move_in_dir_check:
149 set [spr_num], PSPR_TAKING0
152 set [spr_num], PSPR_TAKING1
156 bsr game_item_at_prof
159 jeq .nopitem, [prof_item], 0
161 get [prof_item], item_id
163 set spr_dir, DIR_LEFT, [prof_item]
166 jeq .put_item, [.profdir], PDIR_FACING
167 set spr_dir, DIR_LEFT, [prof_item]
168 jeq .put_item, [.profdir], PDIR_LEFT
169 set spr_dir, DIR_RIGHT, [prof_item]
171 set pos_x, [pos_x], [prof_item]
172 set pos_y, [pos_y], [prof_item]
173 set pos_tx, 0, [prof_item]
174 set pos_ty, 0, [prof_item]
178 jeq .done, [rst_result], 0
180 set [prof_item], [rst_result]
183 set [spr_num], PSPR_TAKING0
186 set [spr_num], PSPR_FACING
189 bsr set_item_name_vars, [prof_item]
197 add [prof_dir], [pos_x], [.x]
198 add [.dy], [pos_y], [.y]
199 mgf [.x], [.y], [.dy]
207 add [prof_dir], [pos_x], [.x]
208 add [.dy], [pos_y], [.y]
209 msf [.x], [.y], [.tile]
214 proc: get_tile_at_dx_dy
217 add [prof_dir], [pos_x], [.x]
219 add [.dy], [pos_y], [.y]
220 mgf [.x], [.y], [.dy]
222 endp: get_tile_at_dx_dy
225 proc: set_tile_at_dx_dy
228 add [prof_dir], [pos_x], [.x]
230 add [.dy], [pos_y], [.y]
231 msf [.x], [.y], [.tile]
233 endp: set_tile_at_dx_dy
238 proc: game_lift_all_items
243 ; only running thread
245 jne .next, THREAD_STATE_RUNNING
247 get [.cnt], item_id, [.type]
248 jlt .next, [.type], ITEM_KEY
249 ;jgt .next, [.type], ITEM_GLOVES
253 ;get [.cnt], activated
255 ; only standing on tile
267 set pos_ty, [.dy], [.cnt]
268 set liftdown, 0, [.cnt]
271 rst FRST_GET_MAX_THREAD_ID
272 jle .loop, [.cnt], [rst_result]
274 endp: game_lift_all_items