diff --git a/README.md b/README.md index b7578c8..faa5cae 100644 --- a/README.md +++ b/README.md @@ -24,4 +24,4 @@ A `output.gba` will be created as your patched file. - PRET for their [decompilation of Pokemon Ruby](https://github.com/pret/pokeruby). - Super Versekr Dark for their Exp Points on capturing routine. - merpp for pokeemerald's overworld shadow feature. -- Andrea for their Exp. All routine. \ No newline at end of file +- Andrea for their P/S Split routine. \ No newline at end of file diff --git a/assembly/hooks/exp_all.s b/assembly/hooks/exp_all.s index 9d28457..6180207 100644 --- a/assembly/hooks/exp_all.s +++ b/assembly/hooks/exp_all.s @@ -1,124 +1,163 @@ -.global CountEligiblePokeForExp, SetExpAmount, GetSentInPokeForExp +.global ExpAllHook1, ExpAllHook2, ExpAllHook3 -@ -CountEligiblePokeForExp: -PUSH {R0,R2-R7} -LDR R0, =(gExpAllEnabled) -ldrb r0, [r0] -CMP R0, #0 -BEQ RETURN1 - -MOV R4, #0 -MOV R5, #0 - -LOOP: -LDR R0, = 0x03004360 -MOV R1, #0x64 -MUL R1, R4 -ADD R0, R0, R1 -MOV R1, #0x56 -LDRH R2, [R0, R1] -CMP R2, #0 -BEQ COUNTER - -IS_EGG: -MOV R1, #0x2D -PUSH {R4,R5} -BL GET_DATA -POP {R4, R5} -CMP R0, #1 -BEQ COUNTER - -MOV R1, #1 -LSL R1, R1, R4 -ORR R5, R1 - -COUNTER: -ADD R4, #1 -CMP R4, #6 -BNE LOOP - -MOV R1, R5 - -POP {R0,R2-R7} -LDR R0, = 0x08020030+1 -BX R0 - -RETURN1: -POP {R0,R2-R7} -LDR R2, = 0x02024DEA -MOV R1, #2 -LDR R3, = 0x08020026+1 -BX R3 - -GET_DATA: -LDR R2, = 0x0803CB60+1 -BX R2 - -@ -SetExpAmount: -PUSH {R0} -LDR R0, =(gExpAllEnabled) +@ 0x802019a - hook via r4 +@ 0x80201fa - return +@ 0x80201e0 - else branch +@ r5 - viaSentIn +ExpAllHook1: +ldr r4, =(gExpAllEnabled) +ldrb r4, [r4] + +cmp r4, #0 +beq ExpAllHook1_GoToMainElseBranch + +mov r4, r1 + +mov r0, r4 +mov r1, r5 +swi #6 + +mov r1, sl + +cmp r0, #0 +bne ExpAllHook1_NormalExpSet +mov r0, #1 + +ExpAllHook1_NormalExpSet: +strh r0, [r1] + +ldr r5, =(0x2024dee) +lsr r0, r4, #1 + +cmp r0, #0 +bne ExpAllHook1_SharedExpSet +mov r0, #1 + +ExpAllHook1_SharedExpSet: +strh r0, [r5] + +ldr r1, =(0x80201fa | 1) +bx r1 + +ExpAllHook1_GoToMainElseBranch: +ldr r0, =(0x80201e0 | 1) +bx r0 + +@ 0x8020276 - hook via r3 +@ 0x80202a0 - next condition +@ 0x80202c8 - end condition +ExpAllHook2: +push {r0-r7} +@ Check if Pokemon is an egg +ldr r0, =(0x2016018) ldrb r0, [r0] -CMP R0, #0 -BEQ NOT_EXP - -POP {R0} - -LSR R0, R1, #1 - -@ mov r0, r1 -@ push {r1, r3} -@ mov r1, #2 -@ swi #0x6 -@ pop {r1, r3} - -BACK_TO: -LDR R1, = 0x080201A8+1 -BX R1 - -NOT_EXP: -POP {R0} -LDR R2, = 0x080201E0+1 -BX R2 - -@ -GetSentInPokeForExp: -LDRH R0, [R3] - -LDR R2, = 0x02016018 -LDRB R2, [R2] - -LDR R5, = 0x02024A6A -LDRB R7, [R5] -CMP R7, R2 -BEQ RETURN - -LDR R7, = 0x020239F8 -LDRB R7, [R7] -MOV R3, #1 -AND R7, R3 -CMP R7, #1 -BEQ DOUBLE - -DIVIDE: -PUSH {R1-R7} -MOV R1, #3 -BL DIVISION -POP {R1-R7} - -RETURN: -STRH R0, [R1] -MOV R8, R1 -LDR R0, = 0x08020376+1 -BX R0 - -DOUBLE: -LDRB R7, [R5, #4] -CMP R7, R2 -BEQ RETURN -B DIVIDE - -DIVISION: -LDR R2, = 0x081E0868+1 -BX R2 + +mov r1, #100 +mul r1, r0, r1 + +ldr r0, =(gPlayerParty) +add r0, r1, r0 + +mov r1, #45 + +bl ExpAllHook2_GetMonData + +cmp r0, #1 +beq ExpAllHook2_ConditionBlock + +push {r0-r7} +bl PrintR0 +pop {r0-r7} + +@ Check if Exp All is enabled +ldr r3, =(gExpAllEnabled) +ldrb r3, [r3] + +cmp r3, #0 +bne ExpAllHook2_NextCondition + +@ Check if Pokemon was sent out +ldr r1, =(0x201605F) +ldrb r0, [r1] + +mov r2, #1 +and r2, r0 + +cmp r2, #0 +bne ExpAllHook2_NextCondition + +ExpAllHook2_ConditionBlock: +@ set sent in pokes +ldr r1, =(0x201605F) +ldrb r0, [r1] + +lsr r0, r0, #1 +strb r0, [r1] + +@ Get exp tracker state +ldr r1, =(0x201600F) +mov r0, #5 +strb r0, [r1] + +@ Set total exp to zero +ldr r1, =(0x2024bec) +mov r0, #0 +str r0, [r1] + +ExpAllHook2_ConditionEnd: +pop {r0-r7} +ldr r0, =(0x8020996 | 1) +bx r0 + +ExpAllHook2_NextCondition: +pop {r0-r7} +ldr r3, =(0x80202a0 | 1) +bx r3 + +ExpAllHook2_GetMonData: +ldr r7, =(GetMonData) +bx r7 + +@ 0x802033c - hook via r1 +@ 0x8020386 - return +ExpAllHook3: +push {r0-r7} + +@ Check if Pokemon was sent out +ldr r1, =(0x201605F) +ldrb r0, [r1] + +mov r1, #1 +and r1, r0 + +cmp r1, #0 +beq ExpAllHook3_CheckIfShareActive +mov r7, sl +ldrh r7, [r7] + +b ExpAllHook3_ConditionEnd + +ExpAllHook3_CheckIfShareActive: +ldr r1, =(gExpAllEnabled) +ldrb r1, [r1] + +cmp r1, #0 +beq ExpAllHook3_SetExpToZero + +ldr r7, =(0x2024dee) +ldrh r7, [r7] + +b ExpAllHook3_ConditionEnd + +ExpAllHook3_SetExpToZero: +mov r7, #0 + +ExpAllHook3_ConditionEnd: +ldr r1, =(0x2024bec) +str r7, [r1] + +pop {r0-r7} + +ldr r3, =(0x8020386 | 1) +bx r3 + diff --git a/config.asm b/config.asm index 16cf49f..6075668 100644 --- a/config.asm +++ b/config.asm @@ -64,7 +64,7 @@ .definelabel AUTORUN, 1 ; Doubles Exp. Points gained after battles. -.definelabel MORE_EXP, 1 +.definelabel MORE_EXP, 0 ; New "Snakewood" logo .definelabel NEW_TITLE_SCREEN, 1 diff --git a/linker/ram.ld b/linker/ram.ld index 1e871b5..e9bd1c1 100644 --- a/linker/ram.ld +++ b/linker/ram.ld @@ -41,7 +41,7 @@ gBattleBufferA = 0x2023a60; gAutorunEnabled = 0x2024f34; gExpandedItemPockets = 0x2025420; gRegisteredItems = 0x2025520; -gExpAllEnabled = 0x202552C; +gExpAllEnabled = 0x2025530; gMapHeader = 0x202e828; gPlayerAvatar = 0x202e858; @@ -65,6 +65,9 @@ sCurrentBagPocket = 0x2038559; gSpecialVar_ItemId = 0x203855e; gWeather = 0x202f7e8; gMoveSelectionCursor = 0x2024e64; +gBank1 = 0x2024c09; +gBattlerPartyIndexes = 0x2024a6a; +gSentPokesToOpponent = 0x2024dea; /* gRepelMenuChoices = 0x203a400; */ /* gLastUsedRegisteredItem = 0x203a404; */ @@ -81,3 +84,4 @@ gCurrentBagPocketItemSlots = 0x3005d24; gScriptContext1 = 0x3007440; sMessageBoxMode = 0x30074b8; gWindowTemplate_Contest_MoveDescription = 0x3004210; +gBattleTextBuff1 = 0x30041c0; diff --git a/linker/rodata.ld b/linker/rodata.ld index e3fad7a..8ebd662 100644 --- a/linker/rodata.ld +++ b/linker/rodata.ld @@ -59,4 +59,7 @@ BattleStatText_SpDef = 0x84007f2; OtherText_MaleSymbol = 0x8410458; OtherText_FemaleSymbol = 0x841045a; gNamingScreenPtr = 0x83ce214; -gTrainers = 0x81f04fc; \ No newline at end of file +gTrainers = 0x81f04fc; +gBitTable = 0x820872c; +BattleScript_LevelUp = 0x81d8ef3; + diff --git a/linker/text.ld b/linker/text.ld index e8a1750..0948dd2 100644 --- a/linker/text.ld +++ b/linker/text.ld @@ -272,3 +272,4 @@ MainState_StartPageSwap = 0x80b61c8 | 1; GetTextEntryPosition = 0x80b6f44 | 1; ResetGpuAndVram = 0x80f9368 | 1; CountPartyNonEggMons = 0x8095b6c | 1; +HandleLowHpMusicChange = 0x80324f8 | 1; diff --git a/scripts/exp_all.asm b/scripts/exp_all.asm index 92e4827..a69c084 100644 --- a/scripts/exp_all.asm +++ b/scripts/exp_all.asm @@ -1,19 +1,18 @@ .if EXP_ALL -.org 0x8020024 -.halfword 0x4710 +.org 0x8020164 +b 0x802016a -.org 0x8020058 -.word (CountEligiblePokeForExp | 1) +.org 0x802019a +nop +set_function_hook r4, ExpAllHook1 -.org 0x802019A -.halfword 0x0 -.word 0x47004800 -.word (SetExpAmount | 1) +.org 0x8020276 +nop +set_function_hook r3, ExpAllHook2 -.org 0x8020344 -.word 0x47004800 -.word (GetSentInPokeForExp | 1) +.org 0x802033c +set_function_hook r3, ExpAllHook3 .org 0x83c5564 + 44 * ITEM_BRAIN_LINK + 24 .byte 0x1, 0x1 diff --git a/src/data/trainers.c b/src/data/trainers.c index b3180ad..d3880d1 100644 --- a/src/data/trainers.c +++ b/src/data/trainers.c @@ -1536,7 +1536,7 @@ const struct TrainerMonItemDefaultMoves gTrainerParty_Tilly[1] = { const struct TrainerMonNoItemDefaultMoves gTrainerParty_Dani[1] = { { .iv = 100, - .level = 7, + .level = 6, .species = SPECIES_OOZLE, }, }; @@ -1838,7 +1838,7 @@ const struct TrainerMonNoItemCustomMoves gTrainerParty_Mimi[2] = { const struct TrainerMonItemDefaultMoves gTrainerParty_Richie[1] = { { .iv = 0, - .level = 8, + .level = 6, .species = SPECIES_SURSKIT, .heldItem = ITEM_TAIJI_DUST, }, @@ -1847,7 +1847,7 @@ const struct TrainerMonItemDefaultMoves gTrainerParty_Richie[1] = { const struct TrainerMonNoItemDefaultMoves gTrainerParty_Orobas[1] = { { .iv = 40, - .level = 14, + .level = 12, .species = SPECIES_DIRTKROW, }, }; @@ -6089,7 +6089,7 @@ const struct TrainerMonNoItemDefaultMoves gTrainerParty_Matteo[1] = { const struct TrainerMonNoItemDefaultMoves gTrainerParty_Laura[2] = { { .iv = 255, - .level = 16, + .level = 13, .species = SPECIES_ZANGOOSE, }, { @@ -7491,7 +7491,7 @@ const struct TrainerMonNoItemDefaultMoves gTrainerParty_Alicia1[3] = { }, { .iv = 100, - .level = 15, + .level = 12, .species = SPECIES_SNEASEL, }, }; @@ -8562,13 +8562,13 @@ const struct TrainerMonNoItemDefaultMoves gTrainerParty_Salaryman5[1] = { const struct TrainerMonNoItemDefaultMoves gTrainerParty_Kent[2] = { { .iv = 0, - .level = 10, + .level = 7, .species = SPECIES_EYE_EYE, }, { .iv = 0, - .level = 13, - .species = SPECIES_EYE_EYE, + .level = 9, + .species = SPECIES_DIRTKROW, }, }; @@ -8889,17 +8889,17 @@ const struct TrainerMonNoItemDefaultMoves gTrainerParty_Rica[2] = { const struct TrainerMonNoItemDefaultMoves gTrainerParty_Lyle[3] = { { .iv = 0, - .level = 7, + .level = 4, .species = SPECIES_SLAKOTH, }, { .iv = 0, - .level = 7, + .level = 6, .species = SPECIES_WURMPLE, }, { .iv = 0, - .level = 7, + .level = 6, .species = SPECIES_RALTS, }, }; diff --git a/src/field_message_box.c b/src/field_message_box.c index 30c9e56..b78802a 100644 --- a/src/field_message_box.c +++ b/src/field_message_box.c @@ -12,6 +12,13 @@ extern u8 sMessageBoxMode; static void PrintFieldMessageInstant(const u8 *message); static void Task_FieldMessageBoxInstant(u8 taskId); +#include "debug.h" + +void PrintR0(u32 r0) +{ + DebugPrintf("%d", r0); +} + bool8 ShowFieldMessageInstant(const u8 *message) { if (sMessageBoxMode != FIELD_MESSAGE_BOX_HIDDEN)