Prev: 53573 Up: Map Next: 53703
53585: Update all characters' stats (deteriorate or regenerate) and wake up / send to sleep if required
Used by the routine at 53498.
53585 LD DE,8 Load DE with 8 (as data is 8 bytes long)
53588 LD HL,53955 Point HL at start of characters' stat regeneration data table
53591 LD IX,25028 Point IX at Gordon's current stats (2nd entry in characters' current stats table, as first is Magic Knight's)
53595 LD B,16 Load B with 16 (16 characters) (see trivia)
53597 BIT 7,(IX+6) If current character is awake...
53601 JR Z,53607 ...then skip ahead to 53607
53603 INC HL Advance HL by four bytes to stat deterioration data...
53604 INC HL ...
53605 INC HL ...
53606 INC HL ...
53607 LD C,(HL) Load stat change value into C
53608 LD A,(IX+0) Load current character's strength into A
53611 CALL 53703 Update character's strength as they tire (awake) or regenerate (asleep)...
53614 LD (IX+0),A ...
53617 INC HL Advance HL to next (happiness) data
53618 LD C,(HL) Load stat change value into C
53619 LD A,(IX+1) Load current character's happiness into A
53622 CALL 53703 Update character's happiness as they tire (awake) or regenerate (asleep)...
53625 LD (IX+1),A ...
53628 INC HL Advance HL to next (stamina) data
53629 LD C,(HL) Load stat change value into C
53630 LD A,(IX+2) Load current character's stamina into A
53633 CALL 53703 Update character's stamina as they tire (awake) or regenerate (asleep)...
53636 LD (IX+2),A ...
53639 INC HL Advance HL to next (charisma) data
53640 LD C,(HL) Load stat change value into C
53641 LD A,(IX+3) Load current character's charisma into A
53644 CALL 53703 Update character's charisma as they tire (awake) or regenerate (asleep)...
53647 LD (IX+3),A ...
53650 INC HL Advance HL to next block of data
53651 BIT 7,(IX+6) If current character is asleep...
53655 JR NZ,53661 ...then we have already moved into data for next character, so skip ahead to 53661
53657 INC HL Else, we are now in same character's "asleep" data, so need to advance HL by four bytes to get to next character's data...
53658 INC HL ...
53659 INC HL ...
53660 INC HL ...
53661 ADD IX,DE Advance IX by eight bytes to next character's stats
53663 DJNZ 53597 Loop back to 53597
53665 LD DE,8 Load DE with 8
53668 LD IX,25028 Point IX to Gordon's current stats
53672 LD B,16 Load B with 16 (16 characters) (see trivia)
53674 LD C,0 Load C with zero (to denote first character, Gordon)
53676 LD A,(IX+2) Load current character's stamina into A
53679 AND 127 If stamina (bits 0-6) is not zero...
53681 JR NZ,53689 ...then skip ahead to 53689
53683 SET 7,(IX+6) Else send character to sleep
53687 JR 53697 Skip ahead to 53697
53689 CP 100 If stamina is not 100...
53691 JR NZ,53697 ...then skip ahead to 53697
53693 RES 7,(IX+6) Else wake character up
53697 ADD IX,DE Advance IX to next character's stats
53699 INC C Increase C for next character
53700 DJNZ 53676 Loop back to 53676 for next character
53702 RET Return
Prev: 53573 Up: Map Next: 53703