Fix cash window formatting (when pressing B)

Does not fix the cash window that pops up when e.g. accessing the ATM.
This commit is contained in:
jeffman 2018-12-06 23:07:35 -05:00
parent ffd8f7131a
commit 442d52054b
4 changed files with 52 additions and 1 deletions

View File

@ -485,3 +485,40 @@ byte print_character_to_window(byte chr, WINDOW* window)
return width;
}
// Write the following, in sequence, to str:
// [5F FF xx] code to right-align the text to padding pixels
// Dollar sign (0x54)
// Digits
// 00 symbol (0x56)
// [00 FF] end code
void format_cash_window(int value, int padding, byte* str)
{
// Convert digits to BCD for easy parsing
int digit_count;
int bcd = bin_to_bcd(value, &digit_count);
// Dollar sign is 6 pixels wide, 00 symbol is 8
padding -= 14;
// Subtract 6 pixels for each digit
padding -= (6 * digit_count);
// Control code
*str++ = 0x5F;
*str++ = 0xFF;
*str++ = padding & 0xFF;
*str++ = 0x54;
// Write the digits
for (int i = 0; i < digit_count; i++)
{
byte digit = ((bcd >> ((digit_count - 1 - i) * 4)) & 0xF) + ZERO;
*str++ = digit;
}
*str++ = 0x56;
*str++ = 0;
*str++ = 0xFF;
}

View File

@ -12,6 +12,7 @@
#define YOUWON_END 0x6C
#define ARROW 0x6D
#define SPACE 0x50
#define ZERO 0x60
#define WINDOW_AREA_BG 0x44444444
#define WINDOW_HEADER_BG 0x33333333
@ -61,6 +62,7 @@ int print_menu_string(WINDOW* window);
void print_number_menu(WINDOW* window, int style);
void print_number_menu_current(byte digit, WINDOW* window);
void clear_number_menu(WINDOW* window);
void format_cash_window(int value, int padding, byte* str);
extern unsigned short m2_coord_table[];
extern int m2_bits_to_nybbles[];

View File

@ -524,6 +524,18 @@ b 0x80D3A14
.org 0x80E0888 :: bl e06ec_redraw_psi
.org 0x80E0A16 :: bl e06ec_redraw_bash_psi
//---------------------------------------------------------
// B89EC hacks (print current cash balance)
//---------------------------------------------------------
.org 0x80B8A06
mov r2,r1
mov r1,0x38 // right-align to 56 pixels
bl format_cash_window
b 0x80B8A2E
.org 0x80B785C :: mov r0,0xC // allocate 2 extra bytes for cash window string
//---------------------------------------------------------
// [68 FF] - clear window
//---------------------------------------------------------

View File

@ -21,7 +21,7 @@
"OffsetLocation": 11632368,
"OldPointer": 11629670,
"Old": " [00 FF]",
"New": " [00 FF]"
"New": " [00 FF]"
},
{
"Index": 3,