Fix negative Skilldex values
This commit is contained in:
parent
d8ae5fbd32
commit
f3eef3fe6c
|
@ -264,12 +264,25 @@ static int skilldexWindowInit()
|
||||||
int valueY = 48;
|
int valueY = 48;
|
||||||
for (int index = 0; index < SKILLDEX_SKILL_COUNT; index++) {
|
for (int index = 0; index < SKILLDEX_SKILL_COUNT; index++) {
|
||||||
int value = skillGetValue(gDude, gSkilldexSkills[index]);
|
int value = skillGetValue(gDude, gSkilldexSkills[index]);
|
||||||
if (value == -1) {
|
|
||||||
value = 0;
|
// SFALL: Fix for negative values.
|
||||||
|
//
|
||||||
|
// NOTE: Sfall's fix is different. It simply renders 0 even if
|
||||||
|
// calculated skill level is negative (which can be the case when
|
||||||
|
// playing on Hard difficulty + low Agility). For unknown reason -5 is
|
||||||
|
// the error code from `skillGetValue`, which is not handled here
|
||||||
|
// because -5 is also a legitimate skill value.
|
||||||
|
//
|
||||||
|
// TODO: Provide other error code in `skillGetValue`.
|
||||||
|
unsigned char* numbersFrmData = gSkilldexFrmData[SKILLDEX_FRM_BIG_NUMBERS];
|
||||||
|
if (value < 0) {
|
||||||
|
// First half of the bignum.frm is white, second half is red.
|
||||||
|
numbersFrmData += gSkilldexFrmSizes[SKILLDEX_FRM_BIG_NUMBERS].width / 2;
|
||||||
|
value = -value;
|
||||||
}
|
}
|
||||||
|
|
||||||
int hundreds = value / 100;
|
int hundreds = value / 100;
|
||||||
blitBufferToBuffer(gSkilldexFrmData[SKILLDEX_FRM_BIG_NUMBERS] + 14 * hundreds,
|
blitBufferToBuffer(numbersFrmData + 14 * hundreds,
|
||||||
14,
|
14,
|
||||||
24,
|
24,
|
||||||
336,
|
336,
|
||||||
|
@ -277,7 +290,7 @@ static int skilldexWindowInit()
|
||||||
gSkilldexFrmSizes[SKILLDEX_FRM_BACKGROUND].width);
|
gSkilldexFrmSizes[SKILLDEX_FRM_BACKGROUND].width);
|
||||||
|
|
||||||
int tens = (value % 100) / 10;
|
int tens = (value % 100) / 10;
|
||||||
blitBufferToBuffer(gSkilldexFrmData[SKILLDEX_FRM_BIG_NUMBERS] + 14 * tens,
|
blitBufferToBuffer(numbersFrmData + 14 * tens,
|
||||||
14,
|
14,
|
||||||
24,
|
24,
|
||||||
336,
|
336,
|
||||||
|
@ -285,7 +298,7 @@ static int skilldexWindowInit()
|
||||||
gSkilldexFrmSizes[SKILLDEX_FRM_BACKGROUND].width);
|
gSkilldexFrmSizes[SKILLDEX_FRM_BACKGROUND].width);
|
||||||
|
|
||||||
int ones = (value % 100) % 10;
|
int ones = (value % 100) % 10;
|
||||||
blitBufferToBuffer(gSkilldexFrmData[SKILLDEX_FRM_BIG_NUMBERS] + 14 * ones,
|
blitBufferToBuffer(numbersFrmData + 14 * ones,
|
||||||
14,
|
14,
|
||||||
24,
|
24,
|
||||||
336,
|
336,
|
||||||
|
|
Loading…
Reference in New Issue