Player name input menu buffer

This commit is contained in:
Lorenzooone 2019-09-21 01:32:23 +02:00
parent f0420979f4
commit 98874ae6a6
5 changed files with 109 additions and 7 deletions

View File

@ -28,6 +28,10 @@ int get_tile_number_buffer(int x, int y)
{
x--;
y--;
//Covers the alphabet-printing issues
if(y >= 0x10)
y -= 0xC;
int totalLenght = x + ((y >> 1) * 28);
int addedValue = (totalLenght >> 5) << 6;
return (totalLenght & 0x1F) + addedValue + (y & 1) * 32;
@ -996,8 +1000,8 @@ int player_name_printing_registration(byte* str, WINDOW* window)
}
String[24] = 0;
String[25] = 0xFF;
print_blankstr_window(0, 2, 24, window);
m2_printstr(window, String, 0, 1, 0);
print_blankstr_window_buffer(0, 2, 24, window);
printstr_buffer(window, String, 0, 1, 0);
return total;
}
@ -1330,7 +1334,7 @@ byte print_character_with_codes(WINDOW* window, byte* dest)
{
handle_first_window_buffer(window, (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * TILESET_OFFSET_BUFFER_MULTIPLIER)));
window->delay = window->delay_between_prints;
if(x > 0x1F)
if(window->text_x >= window->window_width || (window->text_x + window->window_x) > 0x1F)
{
window->text_y += 2;
window->text_x = 0;
@ -1744,6 +1748,64 @@ void print_blankstr_buffer(int x, int y, int width, byte *dest)
clear_rect_buffer(x, y, width, 2, dest);
}
//Function called for printing the alphabet. Seems to be a trimmed down version of the normal script-reading function. Probably done in order to make this faster
int print_alphabet_buffer(WINDOW* window)
{
byte* dest = (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * TILESET_OFFSET_BUFFER_MULTIPLIER));
if(window->redraw)
buffer_drawwindow(window, dest);
if(window->loaded_code == 0 || (*script_readability) != 0)
return 0;
window->delay = 0;
byte* str = window->text_start + window->text_offset;
while(true)
{
unsigned short y = window->window_y + window->text_y;
while(window->text_y >= window->window_height || y > 0x1F)
{
properScroll(window, dest);
y = window->window_y + window->text_y;
}
if(str[1] == 0xFF)
{
byte returnedVal = customcodes_parse_generic(str[0], str, window, dest);
if(returnedVal != 0)
{
window->text_offset += returnedVal;
str += returnedVal;
}
else if(str[0] == 1)
{
window->text_y += 2;
window->text_x = 0;
window->pixel_x = 0;
str += 2;
window->text_offset += 2;
}
else if(str[0] == 0)
{
window->loaded_code = 0;
return 0;
}
}
else
{
if(window->text_x >= window->window_width || (window->text_x + window->window_x) > 0x1F)
{
window->text_y += 2;
window->text_x = 0;
window->pixel_x = 0;
}
weld_entry_custom_buffer(window, str, 0, 0xF, dest);
str++;
window->text_offset++;
}
}
}
void load_pixels_overworld_buffer()
{
byte* buffer = (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * TILESET_OFFSET_BUFFER_MULTIPLIER));
@ -1821,6 +1883,12 @@ void store_pixels_overworld_buffer(int totalYs)
}
}
// x, y, width: tile coordinates
void print_blankstr_window_buffer(int x, int y, int width, WINDOW* window)
{
print_blankstr_buffer(x + window->window_x, y + window->window_y, width, (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * TILESET_OFFSET_BUFFER_MULTIPLIER)));
}
// x,y: tile coordinates
void copy_tile_buffer(int xSource, int ySource, int xDest, int yDest, byte *dest)
{

View File

@ -105,6 +105,8 @@ void setStuffWindow_Graphics();
void clearWindowTiles_buffer(WINDOW* window);
int initWindow_buffer(WINDOW* window, byte* text_start, unsigned short delay_between_prints);
void print_blankstr_buffer(int x, int y, int width, byte *dest);
void print_blankstr_window_buffer(int x, int y, int width, WINDOW* window);
int print_alphabet_buffer(WINDOW* window);
unsigned short ailmentTileSetup(byte *ailmentBase, unsigned short defaultVal);
int setNumber_getLength(int value, byte *str, int maxLength);
int print_string_in_buffer(byte *str, int x, int y, byte *dest);

View File

@ -1,5 +1,5 @@
//==============================================================================
// void parse_generic(int code, char* parserAddress, WINDOW* window, byte* dest)
// int parse_generic(int code, char* parserAddress, WINDOW* window, byte* dest)
// In:
// r0: code
// r1: parser address

View File

@ -1567,10 +1567,20 @@ nop
//==============================================================================
// Overworld player name alphabet
//==============================================================================
//"Register your name" in buffer
.org 0x80C6C54 :: bl printstr_buffer
//BLANK name in buffer
.org 0x80C6C7A :: bl printstr_buffer
//First time entering the menu's alphabet
.org 0x80C6D72 :: bl initWindow_buffer :: ldr r0,[r5,#0x10] :: bl c6d78_print_slphabet_store
//Player name printing - character is added
.org 0x80C75B4 :: bl c75b4_overworld_naming_top_printing :: b 0x80C777A
//Player name printing - character is deleted via add
//Player name printing - character is deleted via b button
.org 0x80C780E :: bl c780e_overworld_naming_top_printing :: b 0x80C789A
//Player name printing - character is deleted via backspace
@ -1766,6 +1776,7 @@ m2_coord_table_file:
.definelabel m2_psiwindow ,0x80C1FBC
.definelabel m2_drawwindow ,0x80C87D0
.definelabel m2_print_window ,0x80C8BE4
.definelabel m2_print_alphabet ,0x80C8FFC
.definelabel m2_printstr ,0x80C9634
.definelabel m2_printstr_hlight ,0x80C96F0
.definelabel m2_printnextch ,0x80C980C

View File

@ -2910,6 +2910,7 @@ ldr r0,=#m2_player1
mov r1,r2
str r3,[sp,#0x24]
bl player_name_printing_registration
bl store_pixels_overworld_player_naming
pop {pc}
//==============================================================================
@ -2920,6 +2921,7 @@ ldr r1,=#0x3005230
ldr r1,[r1,#0x0C]
ldr r0,=#m2_player1
bl player_name_printing_registration
bl store_pixels_overworld_player_naming
pop {pc}
//==============================================================================
@ -2930,6 +2932,7 @@ ldr r1,=#0x3005230
ldr r1,[r1,#0x0C]
ldr r0,=#m2_player1
bl player_name_printing_registration
bl store_pixels_overworld_player_naming
pop {pc}
//==============================================================================
@ -2976,13 +2979,22 @@ bl m2_strlookup
mov r1,r0
mov r0,r4
mov r2,#0
bl m2_initwindow
bl initWindow_buffer
ldr r0,[r5,#0x10]
bl 0x80C8FFC //Print alphabet
bl print_alphabet_buffer //Print alphabet in buffer
bl store_pixels_overworld
@@end:
pop {pc}
//==============================================================================
//Prints the first alphabet and stores the buffer
c6d78_print_slphabet_store:
push {lr}
bl print_alphabet_buffer
bl store_pixels_overworld
pop {pc}
//==============================================================================
//Loads stuff up for the small alphabet and calls print_alphabet_if_needed
c73c0_small_overworld_alphabet:
@ -3074,6 +3086,15 @@ mov r0,#0x10
bl store_pixels_overworld_buffer
pop {r0-r3,pc}
//==============================================================================
//Stores the buffer into the vram. This avoids screen tearing.
store_pixels_overworld_player_naming:
push {r0-r3,lr}
swi #5 //The improved performances allow using a VBlank before the storage in order to prevent screen tearing effectively
mov r0,#0x4
bl store_pixels_overworld_buffer
pop {r0-r3,pc}
//==============================================================================
//Stores the buffer into the vram. This avoids screen tearing.
store_pixels_overworld_psi_window: