![]() |
Routines |
| Prev: 7AC9 | Up: Map | Next: 7B8B |
|
This handles picking up items.
Used by the routine at process_player_input_fire.
|
||||
| pick_up_item | 7B36 | LD HL,($8215) | Load both held items into HL | |
| 7B39 | LD A,$FF | Set A to item_NONE ($FF) | ||
| 7B3B | CP L | If neither item slot is empty then return - we don't have the space to pick another item up | ||
| 7B3C | JR Z,pick_up_have_empty_slot | |||
| 7B3E | CP H | |||
| 7B3F | RET NZ | |||
| pick_up_have_empty_slot | 7B40 | CALL find_nearby_item | Find nearby items. HL points to an item in item_structs if found | |
| 7B43 | RET NZ | Return if no items were found | ||
|
Locate an empty item slot.
|
||||
| 7B44 | LD DE,$8215 | Point DE at the held items array | ||
| 7B47 | LD A,(DE) | Load an item | ||
| 7B48 | CP $FF | Step over the item if it's item_NONE | ||
| 7B4A | JR Z,pick_up_item_0 | |||
| 7B4C | INC DE | |||
| pick_up_item_0 | 7B4D | LD A,(HL) | Fetch the item_struct item's first byte and mask off the item. Note: The mask used here is $1F, not $0F as seen elsewhere in the code. Unsure why | |
| 7B4E | AND $1F | |||
| 7B50 | LD (DE),A | |||
| 7B51 | PUSH HL | Save the item_struct item pointer | ||
| 7B52 | LD A,($68A0) | Fetch the global current room index | ||
| 7B55 | CP $00 | Are we outdoors? | ||
| 7B57 | JP NZ,pick_up_indoors | No - jump to indoor handling | ||
| pick_up_outdoors | 7B5A | CALL plot_all_tiles | Plot all tiles | |
| 7B5D | JR pick_up_item_1 | Jump over indoor handling | ||
| pick_up_indoors | 7B5F | CALL setup_room | Expand out the room definition for room_index | |
| 7B62 | CALL plot_interior_tiles | Render visible tiles array into the screen buffer. | ||
| 7B65 | CALL choose_game_window_attributes | Choose game window attributes | ||
| 7B68 | CALL set_game_window_attributes | Set game window attributes | ||
| pick_up_item_1 | 7B6B | POP HL | Retrieve the item_struct item pointer | |
| 7B6C | BIT 7,(HL) | Is the itemstruct_ITEM_FLAG_HELD flag set? ($80) | ||
| 7B6E | JR NZ,pick_up_item_2 | Jump if so | ||
|
Have picked up an item not previously held - increase the score.
|
||||
| pick_up_novel_item | 7B70 | SET 7,(HL) | Set the itemstruct_ITEM_FLAG_HELD flag so we only award these points on the first pick-up | |
| 7B72 | PUSH HL | Save the item_struct item pointer again | ||
| 7B73 | CALL increase_morale_by_5_score_by_5 | Increase morale by 5, score by 5 | ||
| 7B76 | POP HL | Retrieve again | ||
|
Make the item disappear.
|
||||
| pick_up_item_2 | 7B77 | XOR A | Zero A | |
| 7B78 | INC HL | Zero itemstruct->room_and_flags | ||
| 7B79 | LD (HL),A | |||
| 7B7A | INC HL | Advance HL to itemstruct->iso_pos | ||
| 7B7B | INC HL | |||
| 7B7C | INC HL | |||
| 7B7D | INC HL | |||
| 7B7E | LD (HL),A | Zero itemstruct->iso_pos.screen_x and screen_y | ||
| 7B7F | INC HL | |||
| 7B80 | LD (HL),A | |||
| 7B81 | CALL draw_all_items | Draw held items | ||
| 7B84 | LD BC,$3030 | Play the "pick up item" sound | ||
| 7B87 | CALL play_speaker | |||
| 7B8A | RET | Return | ||
| Prev: 7AC9 | Up: Map | Next: 7B8B |