Prev: 62476 Up: Map Next: 62622
62594: Update characters' stats as they tire or regenerate
Used by the routines at 45434, 62428 and 62476.
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
62594 PUSH AF Store AF (A = value of character's stat)
62595 AND 128 Capture MSB in stat value and store in instruction at 62619...
62597 LD (62620),A ...
62600 POP AF Restore AF (A = value of character's stat)
62601 AND 127 Discard MSB of stat value
62603 ADD A,C Add change value
62604 OR A Check sign flag
62605 JP P,62611 If sign flag reset (i.e. MSB of result is reset and result is positive) then jump ahead to 62611
62608 XOR A else stat must have dropped below zero, so set stat to zero (as it can't be less than 0)
62609 JR 62619 Skip ahead to 62619
62611 CP 100 If new value of stat is less than or equal to 100...
62613 JR Z,62619 ...then skip ahead to 62619...
62615 JR C,62619 ...
62617 LD A,100 ...else set stat to 100 (as it can't be greater than 100)
The operand of the instruction at 62619 represents bit 7 of the input value in A. This is modified by the instruction at 62597.
62619 OR 0 Restore previously stored MSB state
62621 RET Return
Prev: 62476 Up: Map Next: 62622