Add print_menu_string
This essentially does the same thing as print_string, but with some additional behaviour: - Custom control codes (5F and 60) are checked - Will automatically update the window's cursor_delta value - Updates the window's text X values
This commit is contained in:
parent
ba28534e5a
commit
debdea78bd
|
@ -276,6 +276,73 @@ int print_string(byte *str, int x, int y)
|
|||
return (charCount & 0xFFFF) | (totalWidth << 16);
|
||||
}
|
||||
|
||||
int print_menu_string(WINDOW* window)
|
||||
{
|
||||
byte *menu_text = window->menu_text;
|
||||
if (menu_text == NULL)
|
||||
return 0;
|
||||
|
||||
int x = window->window_x << 3;
|
||||
int y = (window->window_y + window->text_y) << 3;
|
||||
|
||||
byte chr;
|
||||
int initial_x = x;
|
||||
int charCount = 0;
|
||||
bool looping = true;
|
||||
int set_count = 0;
|
||||
byte first_set_value = 0;
|
||||
|
||||
while (looping)
|
||||
{
|
||||
if (menu_text[1] == 0xFF)
|
||||
{
|
||||
switch (menu_text[0])
|
||||
{
|
||||
case CUSTOMCC_SET_X:
|
||||
{
|
||||
byte set_value = menu_text[2];
|
||||
x = set_value + initial_x;
|
||||
menu_text += 3;
|
||||
|
||||
set_count++;
|
||||
if (set_count == 1)
|
||||
{
|
||||
first_set_value = set_value;
|
||||
}
|
||||
else if (set_count == 2)
|
||||
{
|
||||
// If we're calling SET the second time, update the
|
||||
// window cursor delta to be the difference between
|
||||
// the two set values
|
||||
window->cursor_delta = (set_value - first_set_value) >> 3;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case CUSTOMCC_ADD_X:
|
||||
x += menu_text[2];
|
||||
menu_text += 3;
|
||||
break;
|
||||
default:
|
||||
looping = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
x += print_character(decode_character(*menu_text++), x, y, 0, 0xF);
|
||||
charCount++;
|
||||
}
|
||||
}
|
||||
|
||||
window->text_x = (x / 8) - window->window_x;
|
||||
window->pixel_x = x & 7;
|
||||
|
||||
int totalWidth = x - initial_x;
|
||||
|
||||
return (charCount & 0xFFFF) | (totalWidth << 16);
|
||||
}
|
||||
|
||||
// x,y: tile coordinates
|
||||
void clear_tile(int x, int y, int pixels)
|
||||
{
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
#define WINDOW_HEADER_Y 0x11
|
||||
#define WINDOW_HEADER_TILE (WINDOW_HEADER_X + (WINDOW_HEADER_Y * 32))
|
||||
|
||||
#define CUSTOMCC_SET_X 0x5F
|
||||
#define CUSTOMCC_ADD_X 0x60
|
||||
|
||||
unsigned short *tile_offset = (unsigned short*)0x30051EC;
|
||||
unsigned short *palette_mask = (unsigned short*)0x3005228;
|
||||
unsigned short **tilemap_pointer = (unsigned short**)0x3005270;
|
||||
|
@ -52,6 +55,7 @@ void copy_tile(int xSource, int ySource, int xDest, int yDest);
|
|||
void copy_tile_up(int x, int y);
|
||||
void print_space(WINDOW *window);
|
||||
int print_string(byte *str, int x, int y);
|
||||
int print_menu_string(WINDOW* window);
|
||||
|
||||
extern unsigned short m2_coord_table[];
|
||||
extern int m2_bits_to_nybbles[];
|
||||
|
|
|
@ -26,7 +26,7 @@ typedef struct WINDOW {
|
|||
int unknown6;
|
||||
int unknown7;
|
||||
unsigned short page;
|
||||
unsigned short unknown8;
|
||||
unsigned short cursor_delta;
|
||||
int unknown9;
|
||||
int unknown10;
|
||||
int unknown11;
|
||||
|
|
|
@ -197,8 +197,8 @@ Window structure:
|
|||
0x36 - 0x37: cursor Y
|
||||
0x38 - 0x3F: ?
|
||||
0x40 - 0x41: page number?
|
||||
0x42 - 0x44: ?
|
||||
0x45 - 0x4F: ?
|
||||
0x42 - 0x43: cursor delta
|
||||
0x44 - 0x4F: ?
|
||||
|
||||
Custom codes
|
||||
------------
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
"OffsetLocation": 11639400,
|
||||
"OldPointer": 11638964,
|
||||
"Old": " はい いいえ[00 FF]",
|
||||
"New": " Yes No[00 FF]"
|
||||
"New": "[5F FF 20]Yes[5F FF 58]No[00 FF]"
|
||||
},
|
||||
{
|
||||
"Index": 1,
|
||||
|
|
Loading…
Reference in New Issue