Prev: 39599 Up: Map Next: 39699
39601: Update states of coloured creatures
Used by the routine at 39137.
39601 LD A,(44903) Load A with first coloured creature's flags
39604 BIT 2,A If coloured-creatures-reward-given flag is set...
39606 RET NZ ...then return
39607 BIT 1,A If all-coloured-creatures-home flag is set...
39609 JP NZ,39760 ...then present reward for getting coloured creatures home, and return
39612 CALL 39699 Count coloured creatures in slots and return if all are home
39615 LD A,L If all three coloured creatures are in slots...
39616 CP 3 ...
39618 RET Z ...then return
39619 LD A,(34218) If current character's current room is not 6 (coloured creatures' room)...
39622 CP 6 ...
39624 RET NZ ...then return
39625 LD HL,39600 Increase cycles elapsed since last swap of creatures...
39628 INC (HL) ...
39629 LD A,(HL) ...
39630 CP 100 ...and if less than 100...
39632 RET C ...then return
39633 LD (HL),0 Set cycles elapsed since last swap of creatures to zero
39635 CALL 36616 Cycle attributes (full-screen), clear display buffers and paint red areas outside current room
39638 LD HL,39599 Point HL at current sequence ID
39641 LD A,3 Load A with a random number, 0-2...
39643 CALL 54222 ...
39646 CP (HL) ...and if this is the same as the current sequence ID...
39647 JR Z,39641 ...then jump back to 39641 to generate a new random number
39649 LD (HL),A Set new sequence ID to generated number
39650 ADD A,A Load BC with three times sequence ID...
39651 ADD A,(HL) ...
39652 LD C,A ...
39653 LD B,0 ...
39655 LD IY,39584 Load IY with start address of table of coloured creatures' properties...
39659 ADD IY,BC ...and add three times sequence ID to get address of first entry in new sequence
39661 LD IX,44894 Load IX with address of complex state data for first coloured creature (level 3)
39665 LD B,3 Load B with 3 (as there are three coloured creatures)
39667 LD A,(IY+0) Set class of current coloured creature...
39670 LD (IX+8),A ...
39673 LD A,(IY+1) ...and address of graphic layout data...
39676 LD (IX+2),A ...
39679 LD A,(IY+2) ...
39682 LD (IX+3),A ...to values in current record in table of coloured creatures' properties
39685 INC IY Advance IY to next entry in properties table...
39687 INC IY ...
39689 INC IY ...
39691 LD DE,13 Advance IX to next coloured creature's properties...
39694 ADD IX,DE ...
39696 DJNZ 39667 Decrease remaining number of coloured creatures to update and loop back to 39667 if not zero
39698 RET Return
Prev: 39599 Up: Map Next: 39699