-
Notifications
You must be signed in to change notification settings - Fork 3
Increase money limit
Credit to DizzyEgg for this feature. This feature may also be directly be pulled from DizzyEgg's money branch.
This tutorial will raise the money limit to 9,999,999.
The first and most obvious thing we need to do is increase the max money constant. Edit src/money.c:
-#define MAX_MONEY 999999
+#define MAX_MONEY 9999999
Doing this change alone will have some consequences elsewhere though. A 7 digit number for money won't be processed and displayed correctly.
The position the money amount is at is now incorrect. We can fix this by editing the function to print the amount in the same file:
void PrintMoneyAmountInMoneyBox(u8 windowId, int amount, u8 speed)
{
- PrintMoneyAmount(windowId, 38, 1, amount, speed);
+ PrintMoneyAmount(windowId, 32, 1, amount, speed);
}
We also need to fix the printing of the money itself, as right now, it only supports a 6 digit number. All we need to do is change 6 to 7 in the same file:
void PrintMoneyAmount(u8 windowId, u8 x, u8 y, int amount, u8 speed)
{
u8 *txtPtr;
s32 strLength;
- ConvertIntToDecimalStringN(gStringVar1, amount, STR_CONV_MODE_LEFT_ALIGN, 6);
+ ConvertIntToDecimalStringN(gStringVar1, amount, STR_CONV_MODE_LEFT_ALIGN, 7);
- strLength = 6 - StringLength(gStringVar1);
+ strLength = 7 - StringLength(gStringVar1);
txtPtr = gStringVar4;
while (strLength-- > 0)
*(txtPtr++) = CHAR_SPACER;
StringExpandPlaceholders(txtPtr, gText_PokedollarVar1);
AddTextPrinterParameterized(windowId, FONT_NORMAL, gStringVar4, x, y, speed, NULL);
}
Now that money prints properly, we need to update the places where they are used.
The x value when printing money in shops also needs to be adjusted. Edit src/shop.c:
static void BuyMenuPrintItemQuantityAndPrice(u8 taskId)
{
s16 *data = gTasks[taskId].data;
FillWindowPixelBuffer(4, PIXEL_FILL(1));
- PrintMoneyAmount(4, 38, 1, sShopData->totalCost, TEXT_SKIP_DRAW);
+ PrintMoneyAmount(4, 32, 1, sShopData->totalCost, TEXT_SKIP_DRAW);
ConvertIntToDecimalStringN(gStringVar1, tItemCount, STR_CONV_MODE_LEADING_ZEROS, BAG_ITEM_CAPACITY_DIGITS);
StringExpandPlaceholders(gStringVar4, gText_xVar1);
BuyMenuPrint(4, gStringVar4, 0, 1, 0, 0);
}
We need to adjust the function call in the trainer card. Edit src/trainer_card.c:
static void PrintMoneyOnCard(void)
{
s32 xOffset;
u8 top;
if (!sData->isHoenn)
AddTextPrinterParameterized3(1, 1, 20, 56, sTrainerCardTextColors, TEXT_SKIP_DRAW, gText_TrainerCardMoney);
else
AddTextPrinterParameterized3(1, 1, 16, 57, sTrainerCardTextColors, TEXT_SKIP_DRAW, gText_TrainerCardMoney);
- ConvertIntToDecimalStringN(gStringVar1, sData->trainerCard.money, STR_CONV_MODE_LEFT_ALIGN, 6);
+ ConvertIntToDecimalStringN(gStringVar1, sData->trainerCard.money, STR_CONV_MODE_LEFT_ALIGN, 7);
StringExpandPlaceholders(gStringVar4, gText_PokedollarVar1);
if (!sData->isHoenn)
{
xOffset = GetStringRightAlignXOffset(1, gStringVar4, 144);
top = 56;
}
else
{
xOffset = GetStringRightAlignXOffset(1, gStringVar4, 128);
top = 57;
}
AddTextPrinterParameterized3(1, FONT_NORMAL, xOffset, top, sTrainerCardTextColors, TEXT_SKIP_DRAW, gStringVar4);
}
Finally, we need to adjust the x value in src/item_menu.c:
static void PrintItemSoldAmount(int windowId, int numSold, int moneyEarned)
{
u8 numDigits = (gBagPosition.pocket == BERRIES_POCKET) ? BERRY_CAPACITY_DIGITS : BAG_ITEM_CAPACITY_DIGITS;
ConvertIntToDecimalStringN(gStringVar1, numSold, STR_CONV_MODE_LEADING_ZEROS, numDigits);
StringExpandPlaceholders(gStringVar4, gText_xVar1);
AddTextPrinterParameterized(windowId, FONT_NORMAL, gStringVar4, 0, 1, TEXT_SKIP_DRAW, 0);
- PrintMoneyAmount(windowId, 38, 1, moneyEarned, 0);
+ PrintMoneyAmount(windowId, 32, 1, moneyEarned, 0);
}
And that's it!
Note: if you want 8 digits, use 8
instead of 7
for digit count and 26
instead of 32
. Don't forget to set MAX_MONEY
appropriately.