Prev: 53585 Up: Map Next: 53731
53703: Update characters' stats as they tire or regenerate
Used by the routines at 29756, 31280, 33569, 53573 and 53585.
Input
A A character's stat (strength, stamina, happiness or spell power)
C An increment (while asleep) or decrement (while awake) for that stat
Output
A New value of stat
53703 PUSH AF Store AF (A = value of character's stat)
53704 AND 128 Capture MSB in stat value and store in instruction at 53728...
53706 LD (53729),A ...
53709 POP AF Restore AF (A = value of character's stat)
53710 AND 127 Discard MSB of stat value
53712 ADD A,C Add change value
53713 OR A Check sign flag
53714 JP P,53720 If sign flag reset (i.e. MSB of result is reset and result is positive) then jump ahead to 53720
53717 XOR A else stat must have dropped below zero, so set stat to zero (as it can't be less than 0)
53718 JR 53728 Skip ahead to 53728
53720 CP 100 If new value of stat is less than or equal to 100...
53722 JR Z,53728 ...then skip ahead to 53728...
53724 JR C,53728 ...
53726 LD A,100 ...else set stat to 100 (as it can't be greater than 100)
The operand of the instruction at 53728 represents bit 7 of the input value in A. This is modified by the instruction at 53706.
53728 OR 0 Restore previously stored MSB state
53730 RET Return
Prev: 53585 Up: Map Next: 53731