diff --git a/build.ps1 b/build.ps1 index f1de5ea..94ce9a9 100644 --- a/build.ps1 +++ b/build.ps1 @@ -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", diff --git a/src/c/credits.c b/src/c/credits.c new file mode 100644 index 0000000..3aa5e46 --- /dev/null +++ b/src/c/credits.c @@ -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; + } +} \ No newline at end of file diff --git a/src/c/credits.h b/src/c/credits.h new file mode 100644 index 0000000..f1c48fc --- /dev/null +++ b/src/c/credits.h @@ -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 \ No newline at end of file diff --git a/src/data/m2-credits-conversion-table.bin b/src/data/m2-credits-conversion-table.bin new file mode 100644 index 0000000..8ac8038 Binary files /dev/null and b/src/data/m2-credits-conversion-table.bin differ diff --git a/src/data/m2-credits-font_[c].bin b/src/data/m2-credits-font_[c].bin new file mode 100644 index 0000000..44e290b Binary files /dev/null and b/src/data/m2-credits-font_[c].bin differ diff --git a/src/m2-hack.asm b/src/m2-hack.asm index 43db3ea..6a07d1b 100644 --- a/src/m2-hack.asm +++ b/src/m2-hack.asm @@ -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"