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 set_item_name_vars, -1
157 ; set [rst_result] to new item_tid
158 bsr game_item_at_prof
161 ; have something to put?
162 jeq .nopitem, [prof_item], 0
164 get [prof_item], item_id
166 set spr_dir, DIR_LEFT, [prof_item]
169 jeq .put_item, [.profdir], PDIR_FACING
170 set spr_dir, DIR_LEFT, [prof_item]
171 jeq .put_item, [.profdir], PDIR_LEFT
172 set spr_dir, DIR_RIGHT, [prof_item]
174 set pos_x, [pos_x], [prof_item]
175 set pos_y, [pos_y], [prof_item]
176 set pos_tx, 0, [prof_item]
177 set pos_ty, 0, [prof_item]
181 jeq .done, [rst_result], 0 ; there was no item at prof position
183 set [prof_item], [rst_result]
186 get [prof_item], item_id
187 bsr set_item_name_vars
189 set [spr_num], PSPR_TAKING0
192 set [spr_num], PSPR_FACING
202 add [prof_dir], [pos_x], [.x]
203 add [.dy], [pos_y], [.y]
204 mgf [.x], [.y], [.dy]
212 add [prof_dir], [pos_x], [.x]
213 add [.dy], [pos_y], [.y]
214 msf [.x], [.y], [.tile]
219 proc: get_tile_at_dx_dy
222 add [prof_dir], [pos_x], [.x]
224 add [.dy], [pos_y], [.y]
225 mgf [.x], [.y], [.dy]
227 endp: get_tile_at_dx_dy
230 proc: set_tile_at_dx_dy
233 add [prof_dir], [pos_x], [.x]
235 add [.dy], [pos_y], [.y]
236 msf [.x], [.y], [.tile]
238 endp: set_tile_at_dx_dy
243 proc: game_lift_all_items
248 ; only running thread
250 jne .next, THREAD_STATE_RUNNING
252 get [.cnt], item_id, [.type]
253 jlt .next, [.type], ITEM_KEY
254 ;jgt .next, [.type], ITEM_GLOVES
258 ;get [.cnt], activated
260 ; only standing on tile
272 set pos_ty, [.dy], [.cnt]
273 set liftdown, 0, [.cnt]
276 rst FRST_GET_MAX_THREAD_ID
277 jle .loop, [.cnt], [rst_result]
279 endp: game_lift_all_items