From 9efe047bbed97f08d0627c08149c1488deb4326a Mon Sep 17 00:00:00 2001 From: Lorenzooone Date: Wed, 28 Aug 2019 01:51:04 +0200 Subject: [PATCH] Add alphabet switching and complete letters table --- src/c/fileselect.c | 14 ++++- src/data/m2-overworld-alphabet-table.bin | 2 +- src/m2-hack.asm | 19 ++++++- src/m2-vwf-entries.asm | 70 ++++++++++++++++++++++-- working/m12-misctext.json | 2 +- 5 files changed, 98 insertions(+), 9 deletions(-) diff --git a/src/c/fileselect.c b/src/c/fileselect.c index 759528a..b69e6d4 100644 --- a/src/c/fileselect.c +++ b/src/c/fileselect.c @@ -224,10 +224,11 @@ unsigned short setupCursorAction(int *Pos1, int *Pos2) return letter; } -void setupCursorMovement_Overworld_Alphabet(WINDOW *window, unsigned short *directionsMantainedTime) +byte setupCursorMovement_Overworld_Alphabet(WINDOW *window, unsigned short *directionsMantainedTime) { int CursorX = window->cursor_x; int CursorY = window->cursor_y; + byte returnByte = 0; int yAxys = 0; int xAxys = 0; bool mantainedX = false; @@ -371,8 +372,19 @@ void setupCursorMovement_Overworld_Alphabet(WINDOW *window, unsigned short *dire m2_soundeffect(0x1A8); } + if(CursorY == 4 && CursorX == 0) + returnByte = 1; + else if(CursorY == 4 && CursorX ==0x7) + returnByte = 2; + else if(CursorY == 5 && CursorX == 0x11) + returnByte = 3; + else if(CursorY == 5) + returnByte = 4; + window->cursor_x = CursorX; window->cursor_y = CursorY; + + return returnByte; } void setupCursorMovement() diff --git a/src/data/m2-overworld-alphabet-table.bin b/src/data/m2-overworld-alphabet-table.bin index 5c3129c..e255efe 100644 --- a/src/data/m2-overworld-alphabet-table.bin +++ b/src/data/m2-overworld-alphabet-table.bin @@ -1 +1 @@ -MMMMMMMMMyMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM \ No newline at end of file +MqMrMsMtMuMvMwMxMyMMMMM]MSMMMzM{M|M}M~MMMMMMMMMWMMMMMMMMMMMMPMMMMM^M_MMM`MaMbMcMdMeMfMgMhMiMMMQMMMMMMMMMMMMMMMMMMMMMMMMMMoMMMMMMMMMMMMMMMMM]MSMMMMMMMMMMMMMMMMWMMMMMMMMMMMMPMMMMM^M_MMM`MaMbMcMdMeMfMgMhMiMMMQMMMMMMMMMMMMMMMMMMMMMMMMMMoMMM \ No newline at end of file diff --git a/src/m2-hack.asm b/src/m2-hack.asm index 3cc9f63..f81b5b1 100644 --- a/src/m2-hack.asm +++ b/src/m2-hack.asm @@ -1327,7 +1327,22 @@ nop .org 0x80C6CC6 :: bl c6cc6_overworld_naming_top_printing :: b 0x80C6D5E //Player name alphabet - cursor movement -.org 0x80C6F24 :: bl c6f24_overworld_alphabet_movement :: b 0x80C7364 +.org 0x80C6F24 :: bl c6f24_overworld_alphabet_movement :: b 0x80C7340 + +//Alphabet - switching support - removal of unused alphabet +.org 0x80C7380 :: nop :: nop :: nop :: mov r0,r9 :: cmp r0,#0 :: beq 0x80C741A :: nop :: nop :: cmp r0,#1 + +//Print CAPITAL alphabet only if needed +.org 0x80C7394 :: bl c7394_CAPITAL_overworld_alphabet :: b 0x80C73B8 + +//Print small alphabet +.org 0x80C73B8 :: nop :: mov r0,r9 :: cmp r0,#2 + +//Print small alphabet only if needed +.org 0x80C73C0 :: bl c73c0_small_overworld_alphabet :: b 0x80C73E2 + +//Choose character table based on alphabet loaded in +.org 0x80C7578 :: bl c7578_load_letters //============================================================================== // Data files @@ -1336,7 +1351,7 @@ nop .org m2_default_names .incbin "data/m2-default-names.bin" -.org 0x8B1BBA0 +.org 0x8B1BA88 m2_overworld_alphabet_table: .incbin "data/m2-overworld-alphabet-table.bin" diff --git a/src/m2-vwf-entries.asm b/src/m2-vwf-entries.asm index 54292cb..0a67e6e 100644 --- a/src/m2-vwf-entries.asm +++ b/src/m2-vwf-entries.asm @@ -2469,7 +2469,7 @@ mov r1,#0 pop {pc} //============================================================================== -// A Press +//A Press c75b4_overworld_naming_top_printing: push {lr} ldr r0,=#m2_player1 @@ -2479,7 +2479,7 @@ bl player_name_printing_registration pop {pc} //============================================================================== -// B Press +//B Press c780e_overworld_naming_top_printing: push {lr} ldr r1,=#0x3005230 @@ -2489,7 +2489,7 @@ bl player_name_printing_registration pop {pc} //============================================================================== -// Backspace +//Backspace c74cc_overworld_naming_top_printing: push {lr} ldr r1,=#0x3005230 @@ -2499,7 +2499,7 @@ bl player_name_printing_registration pop {pc} //============================================================================== -// Re-enter the menu +//Re-enter the menu c6cc6_overworld_naming_top_printing: push {lr} mov r2,r0 @@ -2518,6 +2518,68 @@ mov r0,r7 ldr r1,=#0x3002500 add r1,#0x18 bl setupCursorMovement_Overworld_Alphabet +mov r9,r0 +ldr r2,=#0x3002500 +pop {pc} + +.pool + +//============================================================================== +//Generic alphabet printing routine. Uses the default code. r0 is the alphabet and r1 is the alphabet string to print if need be +print_alphabet_if_needed: +push {lr} +ldr r2,[sp,#0x2C] +cmp r2,r0 //Is the alphabet loaded different from the one we're going in? +beq @@end + +str r0,[sp,#0x2C] //If it is, print the new alphabet +ldr r5,=#0x3005230 //Default printing code +ldr r4,[r5,#0x10] //Window +mov r2,r1 //String to load +ldr r0,=#0x8B17EE4 //String +ldr r1,=#0x8B17424 +bl m2_strlookup +mov r1,r0 +mov r0,r4 +mov r2,#0 +bl m2_initwindow +ldr r0,[r5,#0x10] +bl 0x80C8FFC //Print alphabet + +@@end: +pop {pc} + +//============================================================================== +//Loads stuff up for the small alphabet and calls print_alphabet_if_needed +c73c0_small_overworld_alphabet: +push {lr} +mov r0,#1 //Alphabet 1, small +mov r1,#0x62 //String 0x62, small alphabet +bl print_alphabet_if_needed +pop {pc} + +//============================================================================== +//Loads stuff up for the CAPITAL alphabet and calls print_alphabet_if_needed +c7394_CAPITAL_overworld_alphabet: +push {lr} +mov r0,#0 //Alphabet 0, CAPITAL +mov r1,#0x63 //String 0x63, CAPITAL alphabet +bl print_alphabet_if_needed +pop {pc} + +//============================================================================== +//Loads the proper letter table based on the loaded alphabet +c7578_load_letters: +push {lr} +ldr r2,=#m2_overworld_alphabet_table //Letter table +ldr r0,[sp,#0x28] +cmp r0,#1 +bne @@generic_end +mov r0,#0x90 //If this is the small alphabet, go to its alphabet +add r2,r2,r0 + +@@generic_end: +mov r3,#0x36 //Clobbered code pop {pc} .pool diff --git a/working/m12-misctext.json b/working/m12-misctext.json index 459a36a..deb7ed2 100644 --- a/working/m12-misctext.json +++ b/working/m12-misctext.json @@ -719,7 +719,7 @@ "OffsetLocation": 11632760, "OldPointer": 11631723, "Old": "ひらがな カタカナ[00 FF]", - "New": "misc64[00 FF]" + "New": "[00 FF]" }, { "Index": 101,