Prev: A27F Up: Map Next: A2E2
A289: Wake up
This gets the hero and the six other prisoners out of bed.
Used by the routine at event_wake_up.
wake_up A289 LD A,($A13F) If the hero's not in bed, jump forward (note: it could jump one instruction later instead)
A28C AND A
A28D JP Z,wake_up_0
Hero gets out of bed.
A290 LD HL,$800F Set the hero's vischar position to (46, 46)
A293 LD (HL),$2E
A295 INC L
A296 INC L
A297 LD (HL),$2E
wake_up_0 A299 XOR A Clear the 'hero in bed' flag
A29A LD ($A13F),A
A29D LD BC,$2A00 Set the hero's route to (routeindex_42_HUT2_LEFT_TO_RIGHT, 0)
A2A0 CALL set_hero_route
Position all six prisoners.
A2A3 LD HL,$769F Point HL at characterstruct 20's room field (character 20 is the first of the prisoners)
A2A6 LD DE,$0007 Prepare the characterstruct stride
A2A9 LD A,$03 Prepare room_3_HUT2RIGHT
A2AB LD B,$03 Do the first three prisoner characters
Start loop
wake_up_1 A2AD LD (HL),A Set this characterstruct's room to room_3_HUT2RIGHT
A2AE ADD HL,DE Advance to the next characterstruct
A2AF DJNZ wake_up_1 ...loop
A2B1 LD A,$05 Prepare room_5_HUT3RIGHT
A2B3 LD B,$03 Do the second three prisoner characters
Start loop
wake_up_2 A2B5 LD (HL),A Set this characterstruct's room to room_5_HUT3RIGHT
A2B6 ADD HL,DE Advance to the next characterstruct
A2B7 DJNZ wake_up_2 ...loop
A2B9 LD A,$05 Set initial route index in A'. This gets incremented by set_prisoners_and_guards_route_B for every route it assigns
A2BB EX AF,AF'
A2BC LD C,$00 Zero route step
A2BE CALL set_prisoners_and_guards_route_B Set the routes of all characters in prisoners_and_guards
Update all the bed objects to be empty.
A2C1 LD A,$09 Prepare interiorobject_EMPTY_BED
A2C3 LD HL,$6B79 Point HL at table of pointers to prisoner bed objects
Bug: Seven iterations are specified here BUT there are only six beds in the 'beds' array. This results in a spurious write to ROM location $1A42.
A2C6 LD B,$07 Set seven iterations
Start loop
wake_up_3 A2C8 LD E,(HL) Load the current bed object address into DE
A2C9 INC HL
A2CA LD D,(HL)
A2CB INC HL
A2CC LD (DE),A Overwrite the current bed object with interiorobject_EMPTY_BED
A2CD DJNZ wake_up_3 ...loop
Update the hero's bed object to be empty and redraw if required.
A2CF LD HL,$6C61 Set room definition 2's bed object to interiorobject_EMPTY_BED
A2D2 LD (HL),A
A2D3 LD A,($68A0) If the global current room index is outdoors, or is not a hut room (6 or above) then return
A2D6 AND A
A2D7 RET Z
A2D8 CP $06
A2DA RET NC
A2DB CALL setup_room Expand out the room definition for room_index
A2DE CALL plot_interior_tiles Render visible tiles array into the screen buffer.
A2E1 RET Return
Prev: A27F Up: Map Next: A2E2