Properly write the English player name during the credits

This commit is contained in:
Lorenzo Carletti 2020-08-22 03:01:52 +02:00
parent 2ad223a8cb
commit 3c2d5aae97
6 changed files with 63 additions and 0 deletions

View File

@ -14,6 +14,7 @@ $input_c_files =
"src/c/ext.c",
"src/c/vwf.c",
"src/c/locs.c",
"src/c/credits.c",
"src/c/goods.c",
"src/c/fileselect.c",
"src/c/status.c",

32
src/c/credits.c Normal file
View File

@ -0,0 +1,32 @@
#include "credits.h"
void printPlayerNameCredits(unsigned short *arrangements)
{
//Converts the player name to arrangements
int length = 0;
byte *player_name = m2_player1;
//First things first, it calculates the length of the string
for(length = 0; length < PLAYER_NAME_SIZE && (*(++player_name)) != 0xFF; length++);
//Gets where to position the arrangements...
int start_pos = ((0x1F - length) >> 1) + 1;
int start_pos_default = ((0x1F - 5) >> 1) + 1;
unsigned short *player_name_arrangements = ((0x89 << 2) << 5) + arrangements + start_pos;
unsigned short *default_player_name_arrangements = ((0x89 << 2) << 5) + arrangements + start_pos_default;
player_name = m2_player1;
//Clears the default MARIO player name...
for(int i = 0; i < 5; i++)
{
default_player_name_arrangements[i] = 0xF19B;
default_player_name_arrangements[i + 0x20] = 0xF19B;
}
//Puts the new arrangements in
for(int i = 0; i < length; i++)
{
unsigned short arrangement = m2_credits_conversion_table[player_name[i]];
player_name_arrangements[i] = arrangement;
player_name_arrangements[i + 0x20] = arrangement + 0x20;
}
}

14
src/c/credits.h Normal file
View File

@ -0,0 +1,14 @@
#ifndef HEADER_CREDITS_INCLUDED
#define HEADER_CREDITS_INCLUDED
#include "types.h"
#include "locs.h"
#define PLAYER_NAME_SIZE 24
void printPlayerNameCredits(unsigned short *arrangements);
extern byte m2_player1[];
extern unsigned short m2_credits_conversion_table[];
#endif

Binary file not shown.

Binary file not shown.

View File

@ -1701,6 +1701,14 @@ nop
//Choose character table based on alphabet loaded in
.org 0x80C7578 :: bl c7578_load_letters
//==============================================================================
// Credits hacks
//==============================================================================
//Repoint credits font (Before it pointed to 0x82FF1B8)
.org 0x82DB284 :: dw m2_credits_font
.org 0x801352E :: bl printPlayerNameCredits
//==============================================================================
// Move stuff around in order to make space for the code
//==============================================================================
@ -1859,6 +1867,14 @@ m2InsaneCultist:
m2_coord_table_file:
.incbin "data/m2-coord-table-file-select.bin"
.align 2
m2_credits_conversion_table:
.incbin "data/m2-credits-conversion-table.bin"
.align 4
m2_credits_font:
.incbin "data/m2-credits-font_[c].bin"
optimized_byte_4bpp_to_1bpp_table:
.incbin "data/optimized-byte-4bpp-to-1bpp-table.bin"