diff --git a/asm/code_8083654.s b/asm/code_8083654.s deleted file mode 100644 index 854bf5259..000000000 --- a/asm/code_8083654.s +++ /dev/null @@ -1,585 +0,0 @@ - #include "asm/constants/gba_constants.inc" - #include "asm/macros.inc" - - .syntax unified - - .text - - thumb_func_start sub_8083660 -sub_8083660: - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - ldr r4, _080836D4 - add sp, r4 - movs r1, 0xE0 - lsls r1, 5 - add r1, sp - str r0, [r1] - bl GetLeader - ldr r2, _080836D8 - add r2, sp - str r0, [r2] - movs r7, 0 - movs r0, 0 - ldr r1, _080836DC - add r1, sp - str r0, [r1] -_0808368A: - movs r0, 0x38 - bl DungeonRandInt - adds r4, r0, 0 - movs r0, 0x20 - bl DungeonRandInt - ldr r2, _080836E0 - add r2, sp - str r0, [r2] - ldr r0, _080836D8 - add r0, sp - ldr r0, [r0] - ldr r3, [r0, 0x4] - adds r5, r4, 0 - movs r1, 0 - ldr r4, [r2] - ldr r0, _080836E4 - cmp r7, r0 - ble _080836B4 - b _080837E6 -_080836B4: - movs r2, 0x3 - mov r10, r2 - lsls r0, r7, 2 - mov r2, sp - adds r6, r0, r2 -_080836BE: - movs r0, 0 - mov r8, r0 - adds r2, r5, 0x1 - ldr r0, _080836E8 - add r0, sp - str r2, [r0] - adds r1, 0x1 - ldr r2, _080836EC - add r2, sp - str r1, [r2] - b _0808379C - .align 2, 0 -_080836D4: .4byte 0xffffe3e4 -_080836D8: .4byte 0x00001c04 -_080836DC: .4byte 0x00001c0c -_080836E0: .4byte 0x00001c08 -_080836E4: .4byte 0x000006ff -_080836E8: .4byte 0x00001c14 -_080836EC: .4byte 0x00001c10 -_080836F0: - ldr r0, _08083738 - add r0, sp - ldr r0, [r0] - cmp r0, 0 - bne _0808373C - ldrh r1, [r2] - mov r0, r10 - ands r0, r1 - cmp r0, 0x1 - bne _08083782 - ldrb r0, [r2, 0x9] - cmp r0, 0xFF - beq _08083782 - ldr r0, [r2, 0x14] - cmp r0, 0 - bne _08083782 - ldr r0, [r2, 0x10] - cmp r0, 0 - bne _08083782 - lsls r0, r3, 16 - asrs r0, 16 - subs r0, r5 - cmp r0, 0 - bge _08083722 - negs r0, r0 -_08083722: - cmp r0, 0x5 - bgt _08083788 - asrs r0, r3, 16 - subs r0, r4 - cmp r0, 0 - bge _08083730 - negs r0, r0 -_08083730: - cmp r0, 0x5 - ble _08083782 - b _08083788 - .align 2, 0 -_08083738: .4byte 0x00001c0c -_0808373C: - ldr r1, _08083764 - add r1, sp - ldr r1, [r1] - cmp r1, 0x1 - bne _08083768 - ldrh r1, [r2] - mov r0, r10 - ands r0, r1 - cmp r0, 0x1 - bne _08083782 - ldrb r0, [r2, 0x9] - cmp r0, 0xFF - beq _08083782 - ldr r0, [r2, 0x14] - cmp r0, 0 - bne _08083782 - ldr r0, [r2, 0x10] - cmp r0, 0 - bne _08083782 - b _08083788 - .align 2, 0 -_08083764: .4byte 0x00001c0c -_08083768: - ldrh r1, [r2] - mov r0, r10 - ands r0, r1 - cmp r0, 0x1 - bne _08083782 - ldr r0, [r2, 0x14] - cmp r0, 0 - bne _08083782 - ldr r0, [r2, 0x10] - cmp r0, 0 - bne _08083782 - movs r2, 0x1 - mov r9, r2 -_08083782: - mov r0, r9 - cmp r0, 0 - beq _08083790 -_08083788: - strb r5, [r6] - strb r4, [r6, 0x1] - adds r6, 0x4 - adds r7, 0x1 -_08083790: - adds r4, 0x1 - cmp r4, 0x1F - ble _08083798 - movs r4, 0 -_08083798: - movs r1, 0x1 - add r8, r1 -_0808379C: - mov r2, r8 - cmp r2, 0x1F - bgt _080837C2 - movs r0, 0 - mov r9, r0 - adds r0, r5, 0 - adds r1, r4, 0 - ldr r2, _0808380C - add r2, sp - str r3, [r2] - bl GetTile - adds r2, r0, 0 - ldr r0, _08083810 - ldr r1, _0808380C - add r1, sp - ldr r3, [r1] - cmp r7, r0 - ble _080836F0 -_080837C2: - ldr r2, _08083814 - add r2, sp - ldr r5, [r2] - cmp r5, 0x37 - ble _080837CE - movs r5, 0 -_080837CE: - ldr r0, _08083818 - add r0, sp - ldr r1, [r0] - cmp r1, 0x37 - bgt _080837E6 - ldr r2, _0808381C - add r2, sp - ldr r4, [r2] - ldr r0, _08083810 - cmp r7, r0 - bgt _080837E6 - b _080836BE -_080837E6: - cmp r7, 0 - beq _08083820 - adds r0, r7, 0 - bl DungeonRandInt - lsls r0, 2 - mov r2, sp - adds r1, r2, r0 - ldrb r0, [r1] - movs r2, 0xE0 - lsls r2, 5 - add r2, sp - ldr r2, [r2] - strh r0, [r2] - ldrb r0, [r1, 0x1] - strh r0, [r2, 0x2] - movs r0, 0x1 - b _08083832 - .align 2, 0 -_0808380C: .4byte 0x00001c18 -_08083810: .4byte 0x000006ff -_08083814: .4byte 0x00001c14 -_08083818: .4byte 0x00001c10 -_0808381C: .4byte 0x00001c08 -_08083820: - ldr r0, _08083844 - add r0, sp - ldr r2, [r0] - adds r2, 0x1 - str r2, [r0] - cmp r2, 0x2 - bgt _08083830 - b _0808368A -_08083830: - movs r0, 0 -_08083832: - ldr r3, _08083848 - add sp, r3 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - .align 2, 0 -_08083844: .4byte 0x00001c0c -_08083848: .4byte 0x00001c1c - thumb_func_end sub_8083660 - - thumb_func_start sub_808384C -sub_808384C: - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x4 - adds r3, r0, 0 - mov r9, r1 - movs r0, 0 - mov r8, r0 - ldr r0, _080838BC - movs r2, 0 - ldrsh r1, [r0, r2] - cmp r1, 0x63 - beq _080838D8 - movs r6, 0 -_0808386A: - adds r2, r6, r0 - movs r4, 0 - ldrsh r1, [r2, r4] - mov r5, r9 - movs r7, 0 - ldrsh r0, [r5, r7] - adds r5, r1, r0 - movs r0, 0x2 - ldrsh r1, [r2, r0] - mov r2, r9 - movs r4, 0x2 - ldrsh r0, [r2, r4] - adds r4, r1, r0 - adds r0, r5, 0 - adds r1, r4, 0 - str r3, [sp] - bl GetTile - adds r1, r0, 0 - ldrh r2, [r1] - movs r7, 0x80 - lsls r7, 4 - adds r0, r7, 0 - ands r0, r2 - ldr r3, [sp] - cmp r0, 0 - bne _080838C0 - movs r0, 0x3 - ands r0, r2 - cmp r0, 0x1 - bne _080838C0 - ldr r0, [r1, 0x14] - cmp r0, 0 - bne _080838C0 - ldr r0, [r1, 0x10] - cmp r0, 0 - bne _080838C0 - strh r5, [r3] - strh r4, [r3, 0x2] - movs r0, 0x1 - b _080838DA - .align 2, 0 -_080838BC: .4byte gUnknown_80F4468 -_080838C0: - adds r6, 0x4 - movs r0, 0x1 - add r8, r0 - mov r2, r8 - cmp r2, 0x18 - bgt _080838D8 - ldr r0, _080838E8 - adds r1, r6, r0 - movs r4, 0 - ldrsh r1, [r1, r4] - cmp r1, 0x63 - bne _0808386A -_080838D8: - movs r0, 0 -_080838DA: - add sp, 0x4 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r1} - bx r1 - .align 2, 0 -_080838E8: .4byte gUnknown_80F4468 - thumb_func_end sub_808384C - - thumb_func_start sub_80838EC -sub_80838EC: - push {lr} - adds r2, r0, 0 - ldrb r0, [r2] - adds r1, r0, 0 - cmp r1, 0x7F - beq _08083900 - cmp r1, 0 - beq _08083900 - subs r0, 0x1 - strb r0, [r2] -_08083900: - pop {r0} - bx r0 - thumb_func_end sub_80838EC - - thumb_func_start sub_8083904 -sub_8083904: - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x20 - str r0, [sp] - mov r10, r1 - ldr r4, [r1, 0x70] - str r4, [sp, 0x4] - adds r5, r4, 0 - adds r5, 0x46 - ldrb r6, [r5] - mov r0, r10 - movs r1, 0x1 - bl CheckVariousStatuses2 - lsls r0, 24 - cmp r0, 0 - beq _08083954 - ldr r0, _08083950 - lsls r2, r6, 2 - adds r2, r0 - movs r0, 0 - ldrsh r1, [r2, r0] - lsls r0, r1, 1 - adds r0, r1 - mov r1, r10 - ldrh r1, [r1, 0x4] - adds r0, r1 - ldr r3, [sp] - strh r0, [r3] - movs r4, 0x2 - ldrsh r1, [r2, r4] - lsls r0, r1, 1 - adds r0, r1 - b _08083A6E - .align 2, 0 -_08083950: .4byte gAdjacentTileOffsets -_08083954: - ldr r1, [r4, 0x58] - movs r0, 0x1 - negs r0, r0 - cmp r1, r0 - beq _08083960 - b _08083A8C -_08083960: - ldrb r0, [r5] - ldr r1, _080839A0 - lsls r0, 3 - adds r0, r1 - ldr r7, [r0] - movs r3, 0x4 - ldrsh r2, [r0, r3] - str r2, [sp, 0x8] - movs r2, 0x6 - ldrsh r1, [r0, r2] - str r1, [sp, 0xC] - mov r3, r10 - movs r0, 0x4 - ldrsh r3, [r3, r0] - str r3, [sp, 0x10] - mov r1, r10 - movs r2, 0x6 - ldrsh r1, [r1, r2] - str r1, [sp, 0x14] - ldr r0, _080839A4 - ldr r1, [r0] - ldr r3, _080839A8 - adds r0, r1, r3 - ldrb r0, [r0] - cmp r0, 0 - beq _080839B0 - ldr r4, _080839AC - adds r4, r1, r4 - str r4, [sp, 0x18] - movs r0, 0x14 - b _080839D0 - .align 2, 0 -_080839A0: .4byte gUnknown_80F4CC4 -_080839A4: .4byte gDungeon -_080839A8: .4byte 0x000037fc -_080839AC: .4byte 0x000135cc -_080839B0: - ldrb r0, [r4, 0x6] - cmp r0, 0 - bne _080839C8 - ldr r2, _080839C4 - adds r2, r1, r2 - str r2, [sp, 0x18] - movs r3, 0x10 - str r3, [sp, 0x1C] - b _080839D2 - .align 2, 0 -_080839C4: .4byte 0x0001358c -_080839C8: - ldr r4, _08083A78 - adds r4, r1, r4 - str r4, [sp, 0x18] - movs r0, 0x4 -_080839D0: - str r0, [sp, 0x1C] -_080839D2: - movs r1, 0 - ldrsh r0, [r7, r1] - cmp r0, 0x63 - beq _08083A46 -_080839DA: - movs r2, 0 - ldrsh r0, [r7, r2] - ldr r3, [sp, 0x8] - muls r0, r3 - ldr r4, [sp, 0x10] - adds r4, r0 - mov r9, r4 - movs r1, 0x2 - ldrsh r0, [r7, r1] - ldr r2, [sp, 0xC] - muls r0, r2 - ldr r3, [sp, 0x14] - adds r3, r0 - mov r8, r3 - movs r6, 0 - ldr r4, [sp, 0x1C] - cmp r6, r4 - bge _08083A3C - ldr r5, [sp, 0x18] -_08083A00: - ldr r4, [r5] - adds r0, r4, 0 - bl EntityIsValid - lsls r0, 24 - cmp r0, 0 - beq _08083A32 - movs r1, 0x4 - ldrsh r0, [r4, r1] - cmp r0, r9 - bne _08083A32 - movs r2, 0x6 - ldrsh r0, [r4, r2] - cmp r0, r8 - bne _08083A32 - mov r0, r10 - adds r1, r4, 0 - movs r2, 0 - movs r3, 0 - bl GetTreatmentBetweenMonsters - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _08083A80 -_08083A32: - adds r5, 0x4 - adds r6, 0x1 - ldr r3, [sp, 0x1C] - cmp r6, r3 - blt _08083A00 -_08083A3C: - adds r7, 0x4 - movs r4, 0 - ldrsh r0, [r7, r4] - cmp r0, 0x63 - bne _080839DA -_08083A46: - ldr r2, _08083A7C - ldr r1, [sp, 0x4] - adds r1, 0x46 - ldrb r0, [r1] - lsls r0, 2 - adds r0, r2 - movs r3, 0 - ldrsh r0, [r0, r3] - lsls r0, 1 - mov r4, r10 - ldrh r4, [r4, 0x4] - adds r0, r4 - ldr r3, [sp] - strh r0, [r3] - ldrb r0, [r1] - lsls r0, 2 - adds r0, r2 - movs r4, 0x2 - ldrsh r0, [r0, r4] - lsls r0, 1 -_08083A6E: - mov r1, r10 - ldrh r1, [r1, 0x6] - adds r0, r1 - strh r0, [r3, 0x2] - b _08083A9E - .align 2, 0 -_08083A78: .4byte 0x0001357c -_08083A7C: .4byte gAdjacentTileOffsets -_08083A80: - mov r3, r9 - ldr r2, [sp] - strh r3, [r2] - mov r4, r8 - strh r4, [r2, 0x2] - b _08083A9E -_08083A8C: - ldr r0, [sp, 0x4] - adds r0, 0x58 - ldrh r0, [r0] - ldr r1, [sp] - strh r0, [r1] - ldr r0, [sp, 0x4] - adds r0, 0x5A - ldrh r0, [r0] - strh r0, [r1, 0x2] -_08083A9E: - add sp, 0x20 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_8083904 - - .align 2, 0 diff --git a/asm/code_808417C.s b/asm/code_808417C.s deleted file mode 100644 index 369ba2e93..000000000 --- a/asm/code_808417C.s +++ /dev/null @@ -1,694 +0,0 @@ - #include "asm/constants/gba_constants.inc" - #include "asm/macros.inc" - - .syntax unified - - .text - - thumb_func_start sub_80841EC -sub_80841EC: - push {r4-r6,lr} - mov r6, r8 - push {r6} - sub sp, 0xC4 - add r0, sp, 0x60 - mov r8, r0 - movs r1, 0 - movs r2, 0x60 - bl memset - movs r0, 0x6 - str r0, [sp, 0x64] - add r1, sp, 0x68 - movs r6, 0 - movs r0, 0x4 - strh r0, [r1] - movs r2, 0x3 - strh r2, [r1, 0x2] - add r1, sp, 0x6C - movs r0, 0x16 - strh r0, [r1] - mov r0, sp - adds r0, 0x6E - movs r5, 0xE - movs r1, 0xE - strh r1, [r0] - add r0, sp, 0x70 - strh r1, [r0] - add r4, sp, 0xC0 - str r4, [sp, 0x74] - str r2, [sp, 0x7C] - add r0, sp, 0x90 - str r2, [r0, 0x4] - add r0, sp, 0xA8 - str r2, [r0, 0x4] - mov r0, sp - mov r1, r8 - movs r2, 0x60 - bl memcpy - movs r0, 0x1 - strb r0, [r4] - strb r6, [r4, 0x1] - strb r5, [r4, 0x2] - strb r6, [r4, 0x3] - mov r1, sp - movs r0, 0x14 - strh r0, [r1, 0xA] - mov r0, sp - movs r1, 0x1 - bl DungeonShowWindows - ldr r0, _0808426C - ldr r0, [r0] - ldr r1, _08084270 - adds r0, r1 - movs r2, 0 - ldrsh r1, [r0, r2] - ldr r0, _08084274 - cmp r1, r0 - ble _08084278 - bl PlayDungeonCompleteBGM - b _0808427C - .align 2, 0 -_0808426C: .4byte gDungeon -_08084270: .4byte 0x0001ceac -_08084274: .4byte 0x00000225 -_08084278: - bl PlayDungeonFailBGM -_0808427C: - ldr r0, _080842B8 - ldr r1, [r0] - ldr r0, _080842BC - ldr r2, [r0] - ldr r0, _080842C0 - adds r2, r0 - movs r0, 0 - bl sub_8094558 - mov r4, sp -_08084290: - movs r0, 0x36 - bl sub_803E668 - bl UpdateDungeonMusic - ldrh r1, [r4, 0xA] - movs r2, 0xA - ldrsh r0, [r4, r2] - cmp r0, 0x3 - ble _080842C4 - subs r0, r1, 0x1 - strh r0, [r4, 0xA] - movs r0, 0xA0 - strb r0, [r4] - mov r0, sp - movs r1, 0x1 - bl DungeonShowWindows - b _08084290 - .align 2, 0 -_080842B8: .4byte gUnknown_80FE6E8 -_080842BC: .4byte gDungeon -_080842C0: .4byte 0x0001ce98 -_080842C4: - bl sub_8094D14 - lsls r0, 24 - cmp r0, 0 - bne _080842DA - ldr r0, _080842EC - ldrh r1, [r0, 0x2] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _08084290 -_080842DA: - bl PlayDungeonConfirmationSE - add sp, 0xC4 - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r0} - bx r0 - .align 2, 0 -_080842EC: .4byte gRealInputs - thumb_func_end sub_80841EC - - thumb_func_start sub_80842F0 -sub_80842F0: - push {r4-r7,lr} - mov r7, r8 - push {r7} - ldr r1, _0808436C - ldr r0, [r1] - ldr r2, _08084370 - adds r0, r2 - movs r2, 0 - strb r2, [r0] - ldr r0, [r1] - ldr r3, _08084374 - adds r0, r3 - strb r2, [r0] - ldr r0, [r1] - movs r5, 0xCF - lsls r5, 3 - adds r0, r5 - ldrb r0, [r0] - cmp r0, 0x2 - bne _080843AE - movs r6, 0 - ldr r0, _08084378 - mov r8, r0 - movs r7, 0x1 -_08084320: - lsls r0, r6, 24 - lsrs r0, 24 - bl GetJobSlotInfo - adds r4, r0, 0 - ldrb r0, [r4] - cmp r0, 0x6 - bne _080843A8 - ldr r3, _0808436C - ldr r5, [r3] - ldr r1, _0808437C - adds r0, r5, r1 - ldrh r0, [r0] - ldrh r2, [r4, 0x4] - mov r1, r8 - ands r1, r0 - mov r0, r8 - ands r0, r2 - cmp r1, r0 - bne _080843A8 - ldrb r0, [r4, 0x1] - cmp r0, 0x3 - beq _080843A8 - cmp r0, 0x4 - bne _08084380 - ldrb r1, [r4, 0x10] - ldr r2, _08084374 - adds r0, r5, r2 - strb r1, [r0] - ldr r2, [r3] - ldrh r1, [r4, 0xE] - movs r3, 0xD1 - lsls r3, 3 - adds r0, r2, r3 - strh r1, [r0] - strb r7, [r2, 0x9] - b _080843A8 - .align 2, 0 -_0808436C: .4byte gDungeon -_08084370: .4byte 0x00000677 -_08084374: .4byte 0x0000068a -_08084378: .4byte 0x0000ffff -_0808437C: .4byte 0x00000644 -_08084380: - cmp r0, 0 - beq _0808438C - cmp r0, 0x2 - beq _0808438C - cmp r0, 0x1 - bne _080843A8 -_0808438C: - ldr r2, [r3] - ldrh r0, [r4, 0xE] - movs r5, 0xD1 - lsls r5, 3 - adds r1, r2, r5 - strh r0, [r1] - ldrb r0, [r4, 0x1] - cmp r0, 0x2 - bne _080843A4 - ldr r1, _080843B8 - adds r0, r2, r1 - strb r7, [r0] -_080843A4: - ldr r0, [r3] - strb r7, [r0, 0x9] -_080843A8: - adds r6, 0x1 - cmp r6, 0x7 - ble _08084320 -_080843AE: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 -_080843B8: .4byte 0x00000677 - thumb_func_end sub_80842F0 - - thumb_func_start sub_80843BC -sub_80843BC: - push {r4-r6,lr} - lsls r0, 16 - asrs r6, r0, 16 - movs r4, 0 - ldr r5, _08084418 -_080843C6: - lsls r0, r4, 24 - lsrs r0, 24 - bl GetJobSlotInfo - adds r3, r0, 0 - ldrb r0, [r3] - cmp r0, 0x6 - bne _0808440C - ldr r0, _0808441C - ldr r0, [r0] - ldr r1, _08084420 - adds r0, r1 - ldrh r0, [r0] - ldrh r2, [r3, 0x4] - adds r1, r5, 0 - ands r1, r0 - adds r0, r5, 0 - ands r0, r2 - cmp r1, r0 - bne _0808440C - ldrb r0, [r3, 0x1] - cmp r0, 0 - beq _08084400 - cmp r0, 0x4 - beq _08084400 - cmp r0, 0x2 - beq _08084400 - cmp r0, 0x1 - bne _0808440C -_08084400: - movs r1, 0xE - ldrsh r0, [r3, r1] - cmp r6, r0 - bne _0808440C - movs r0, 0x8 - strb r0, [r3] -_0808440C: - adds r4, 0x1 - cmp r4, 0x7 - ble _080843C6 - pop {r4-r6} - pop {r0} - bx r0 - .align 2, 0 -_08084418: .4byte 0x0000ffff -_0808441C: .4byte gDungeon -_08084420: .4byte 0x00000644 - thumb_func_end sub_80843BC - - thumb_func_start sub_8084424 -sub_8084424: - push {r4,lr} - movs r4, 0 -_08084428: - lsls r0, r4, 24 - lsrs r0, 24 - bl GetJobSlotInfo - adds r1, r0, 0 - ldrb r0, [r1] - cmp r0, 0x8 - bne _0808443C - movs r0, 0x9 - strb r0, [r1] -_0808443C: - adds r4, 0x1 - cmp r4, 0x7 - ble _08084428 - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_8084424 - - thumb_func_start sub_8084448 -sub_8084448: - push {r4-r7,lr} - adds r5, r0, 0 - ldr r7, [r5, 0x70] - ldr r4, _0808447C - bl GetLeader - adds r1, r0, 0 - adds r0, r4, 0 - movs r2, 0 - bl SubstitutePlaceholderStringTags - adds r4, 0x50 - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0 - bl SubstitutePlaceholderStringTags - adds r0, r5, 0 - bl sub_8070BC0 - lsls r0, 24 - cmp r0, 0 - bne _08084484 - ldr r0, _08084480 - b _080844F0 - .align 2, 0 -_0808447C: .4byte gFormatBuffer_Monsters -_08084480: .4byte gUnknown_80FA464 -_08084484: - ldr r4, _080844FC - ldr r0, [r4] - ldr r6, _08084500 - adds r0, r6 - ldrb r0, [r0] - cmp r0, 0 - beq _08084540 - ldr r0, _08084504 - ldr r1, [r0] - movs r0, 0 - movs r2, 0x1 - bl DisplayDungeonYesNoMessage - cmp r0, 0x1 - beq _080844A4 - b _080845D4 -_080844A4: - ldr r0, _08084508 - ldr r1, [r4] - adds r1, r6 - ldrb r1, [r1] - movs r2, 0 - bl BufferItemName - movs r3, 0 - ldr r0, _0808450C - adds r6, r0, 0 - ldr r2, [r6] -_080844BA: - ldrb r1, [r2] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _080844E2 - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - bne _080844E2 - movs r0, 0x18 - ands r0, r1 - cmp r0, 0x18 - beq _080844E2 - ldr r0, [r4] - ldr r1, _08084500 - adds r0, r1 - ldrb r1, [r2, 0x2] - ldrb r0, [r0] - cmp r1, r0 - beq _080844EA -_080844E2: - adds r2, 0x4 - adds r3, 0x1 - cmp r3, 0x13 - ble _080844BA -_080844EA: - cmp r3, 0x14 - bne _08084514 - ldr r0, _08084510 -_080844F0: - ldr r1, [r0] - movs r0, 0 - movs r2, 0x1 - bl DisplayDungeonMessage - b _080845D4 - .align 2, 0 -_080844FC: .4byte gDungeon -_08084500: .4byte 0x0000068a -_08084504: .4byte gUnknown_80FA32C -_08084508: .4byte gFormatBuffer_Items -_0808450C: .4byte gTeamInventoryRef -_08084510: .4byte gUnknown_80FA448 -_08084514: - lsls r1, r3, 2 - ldr r0, [r6] - adds r1, r0 - movs r0, 0 - strb r0, [r1, 0x2] - strb r0, [r1, 0x1] - strb r0, [r1] - bl FillInventoryGaps - ldr r0, _08084538 - ldr r1, [r0] - movs r0, 0 - movs r2, 0x1 - bl DisplayDungeonMessage - ldr r0, _0808453C - b _0808455E - .align 2, 0 -_08084538: .4byte gUnknown_80FA2B0 -_0808453C: .4byte gUnknown_80FA370 -_08084540: - ldr r0, _080845B0 - ldr r1, [r0] - movs r0, 0 - movs r2, 0x1 - bl DisplayDungeonYesNoMessage - cmp r0, 0x1 - bne _080845D4 - ldr r0, _080845B4 - ldr r1, [r0] - movs r0, 0 - movs r2, 0x1 - bl DisplayDungeonMessage - ldr r0, _080845B8 -_0808455E: - ldr r4, [r0] - movs r1, 0x2 - ldrsh r0, [r7, r1] - bl sub_80843BC - adds r0, r5, 0x4 - bl sub_8042A34 - movs r1, 0x87 - lsls r1, 2 - adds r0, r5, 0 - movs r2, 0 - bl sub_8068FE0 - movs r0, 0x1 - bl sub_804178C - ldr r5, _080845BC -_08084582: - movs r0, 0 - adds r1, r4, 0 - movs r2, 0x1 - bl DisplayDungeonYesNoMessage - cmp r0, 0x1 - bne _080845C4 - ldr r0, _080845C0 - ldr r1, [r0] - movs r0, 0 - movs r2, 0 - bl DisplayDungeonYesNoMessage - adds r1, r0, 0 - cmp r1, 0x1 - bne _08084582 - ldr r0, [r5] - strb r1, [r0, 0x4] - ldr r1, [r5] - movs r0, 0x2 - strb r0, [r1, 0x11] - b _080845D4 - .align 2, 0 -_080845B0: .4byte gUnknown_80FA2F0 -_080845B4: .4byte gUnknown_80FA260 -_080845B8: .4byte gUnknown_80FA36C -_080845BC: .4byte gDungeon -_080845C0: .4byte gUnknown_80FA394 -_080845C4: - ldr r0, _080845DC - ldr r1, [r0] - movs r0, 0 - movs r2, 0 - bl DisplayDungeonYesNoMessage - cmp r0, 0x1 - bne _08084582 -_080845D4: - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 -_080845DC: .4byte gUnknown_80FA3B8 - thumb_func_end sub_8084448 - - thumb_func_start sub_80845E0 -sub_80845E0: - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - adds r6, r0, 0 - ldr r0, [r6, 0x70] - mov r8, r0 - movs r7, 0 - movs r1, 0 - mov r9, r1 - ldr r4, _08084620 - bl GetLeader - adds r1, r0, 0 - adds r0, r4, 0 - movs r2, 0 - bl SubstitutePlaceholderStringTags - adds r4, 0x50 - adds r0, r4, 0 - adds r1, r6, 0 - movs r2, 0 - bl SubstitutePlaceholderStringTags - adds r0, r6, 0 - bl sub_8070BC0 - lsls r0, 24 - cmp r0, 0 - bne _08084630 - ldr r0, _08084624 - b _080846B4 - .align 2, 0 -_08084620: .4byte gFormatBuffer_Monsters -_08084624: .4byte gUnknown_80FA530 -_08084628: - adds r7, r4, 0 - ldr r2, [r7, 0x70] - mov r9, r2 - b _08084674 -_08084630: - movs r5, 0 -_08084632: - ldr r0, _08084660 - ldr r0, [r0] - lsls r1, r5, 2 - ldr r2, _08084664 - adds r0, r2 - adds r0, r1 - ldr r4, [r0] - adds r0, r4, 0 - bl EntityIsValid - lsls r0, 24 - cmp r0, 0 - beq _0808466E - ldr r0, [r4, 0x70] - adds r0, 0x40 - ldrb r0, [r0] - cmp r0, 0x4A - beq _0808465A - cmp r0, 0x47 - bne _08084668 -_0808465A: - movs r0, 0x1 - b _0808466A - .align 2, 0 -_08084660: .4byte gDungeon -_08084664: .4byte 0x0001357c -_08084668: - movs r0, 0 -_0808466A: - cmp r0, 0 - bne _08084628 -_0808466E: - adds r5, 0x1 - cmp r5, 0x3 - ble _08084632 -_08084674: - cmp r7, 0 - bne _08084680 - ldr r0, _0808467C - b _080846B4 - .align 2, 0 -_0808467C: .4byte gUnknown_80FA52C -_08084680: - ldr r0, _0808469C - adds r1, r7, 0 - movs r2, 0 - bl SubstitutePlaceholderStringTags - adds r0, r7, 0 - bl sub_8070BC0 - lsls r0, 24 - cmp r0, 0 - bne _080846A4 - ldr r0, _080846A0 - b _080846B4 - .align 2, 0 -_0808469C: .4byte gFormatBuffer_Monsters + 160 -_080846A0: .4byte gUnknown_80FA54C -_080846A4: - adds r0, r6, 0 - adds r1, r7, 0 - bl CanSeeTarget - lsls r0, 24 - cmp r0, 0 - bne _080846C4 - ldr r0, _080846C0 -_080846B4: - ldr r1, [r0] - movs r0, 0 - movs r2, 0x1 - bl DisplayDungeonMessage - b _08084768 - .align 2, 0 -_080846C0: .4byte gUnknown_80FA500 -_080846C4: - ldr r0, _08084744 - ldr r1, [r0] - movs r0, 0 - movs r2, 0x1 - bl DisplayDungeonMessage - mov r1, r8 - movs r2, 0x2 - ldrsh r0, [r1, r2] - bl sub_80843BC - ldr r5, _08084748 - ldr r0, [r5] - ldr r1, _0808474C - adds r0, r1 - ldrb r1, [r0] - mov r0, r9 - adds r0, 0x40 - strb r1, [r0] - adds r0, r6, 0x4 - bl sub_8042A34 - adds r0, r7, 0x4 - bl sub_8042A34 - movs r4, 0x87 - lsls r4, 2 - adds r0, r6, 0 - adds r1, r4, 0 - movs r2, 0 - bl sub_8068FE0 - adds r0, r7, 0 - adds r1, r4, 0 - movs r2, 0 - bl sub_8068FE0 - movs r0, 0x1 - bl sub_804178C - ldr r4, _08084750 -_08084716: - movs r0, 0 - ldr r1, [r4] - movs r2, 0x1 - bl DisplayDungeonYesNoMessage - cmp r0, 0x1 - bne _08084758 - ldr r0, _08084754 - ldr r1, [r0] - movs r0, 0 - movs r2, 0 - bl DisplayDungeonYesNoMessage - adds r1, r0, 0 - cmp r1, 0x1 - bne _08084716 - ldr r0, [r5] - strb r1, [r0, 0x4] - ldr r1, [r5] - movs r0, 0x2 - strb r0, [r1, 0x11] - b _08084768 - .align 2, 0 -_08084744: .4byte gUnknown_80FA4D4 -_08084748: .4byte gDungeon -_0808474C: .4byte 0x00000644 -_08084750: .4byte gUnknown_80FA4D8 -_08084754: .4byte gUnknown_80FA394 -_08084758: - ldr r0, _08084774 - ldr r1, [r0] - movs r0, 0 - movs r2, 0 - bl DisplayDungeonYesNoMessage - cmp r0, 0x1 - bne _08084716 -_08084768: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 -_08084774: .4byte gUnknown_80FA3B8 - thumb_func_end sub_80845E0 diff --git a/asm/code_8085B80.s b/asm/code_8085B80.s deleted file mode 100644 index e49e82d5f..000000000 --- a/asm/code_8085B80.s +++ /dev/null @@ -1,310 +0,0 @@ - #include "asm/constants/gba_constants.inc" - #include "asm/macros.inc" - - .syntax unified - - .text - - thumb_func_start SetDungeonBGColorRGB -SetDungeonBGColorRGB: - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x28 - str r0, [sp, 0x14] - mov r10, r1 - mov r9, r2 - ldr r4, [sp, 0x48] - lsls r3, 24 - lsrs r3, 24 - str r3, [sp, 0x18] - lsls r4, 24 - lsrs r4, 24 - bl sub_8085E98 - movs r0, 0 - mov r8, r0 - ldr r0, _08085E70 - ldr r0, [r0] - ldr r5, [r0, 0x4] - cmp r4, 0 - beq _08085CAE - ldr r1, [sp, 0x14] - cmp r1, 0 - blt _08085C92 - lsrs r0, r1, 31 - adds r0, r1, r0 - asrs r0, 1 - str r0, [sp, 0x14] -_08085C92: - mov r2, r10 - cmp r2, 0 - blt _08085CA0 - lsrs r0, r2, 31 - add r0, r10 - asrs r0, 1 - mov r10, r0 -_08085CA0: - mov r3, r9 - cmp r3, 0 - blt _08085CAE - lsrs r0, r3, 31 - add r0, r9 - asrs r0, 1 - mov r9, r0 -_08085CAE: - ldr r1, _08085E74 - ldr r0, [sp, 0x8] - ands r0, r1 - ldr r1, _08085E78 - ands r0, r1 - ldr r1, _08085E7C - ands r0, r1 - str r0, [sp, 0x8] - ldr r0, _08085E80 - ldr r2, [r0] - ldr r0, _08085E84 - ldr r3, [r0] - movs r0, 0xBE - lsls r0, 1 - adds r3, r0 - mov r0, r8 - add r1, sp, 0x8 - bl SetBGPaletteBufferColorRGB - adds r5, 0x4 - movs r1, 0x1 - add r8, r1 - ldr r2, [sp, 0x14] - lsls r2, 16 - str r2, [sp, 0x1C] - mov r3, r10 - lsls r3, 16 - str r3, [sp, 0x20] - mov r0, r9 - lsls r0, 16 - str r0, [sp, 0x24] - add r7, sp, 0xC - movs r1, 0xA0 - cmp r1, 0x1 - ble _08085D56 - add r6, sp, 0x8 - movs r4, 0xA0 - subs r4, 0x1 -_08085CFA: - ldrb r0, [r5] - ldr r3, [sp, 0x14] - adds r2, r0, r3 - ldrb r0, [r5, 0x1] - mov r3, r10 - adds r1, r0, r3 - ldrb r0, [r5, 0x2] - add r0, r9 - cmp r2, 0xFF - ble _08085D10 - movs r2, 0xFF -_08085D10: - cmp r1, 0xFF - ble _08085D16 - movs r1, 0xFF -_08085D16: - cmp r0, 0xFF - ble _08085D1C - movs r0, 0xFF -_08085D1C: - cmp r2, 0 - bge _08085D22 - movs r2, 0 -_08085D22: - cmp r1, 0 - bge _08085D28 - movs r1, 0 -_08085D28: - cmp r0, 0 - bge _08085D2E - movs r0, 0 -_08085D2E: - strb r2, [r6] - strb r1, [r6, 0x1] - strb r0, [r6, 0x2] - ldr r0, _08085E80 - ldr r2, [r0] - ldr r0, _08085E84 - ldr r3, [r0] - movs r0, 0xBE - lsls r0, 1 - adds r3, r0 - mov r0, r8 - add r1, sp, 0x8 - bl SetBGPaletteBufferColorRGB - adds r5, 0x4 - movs r1, 0x1 - add r8, r1 - subs r4, 0x1 - cmp r4, 0 - bne _08085CFA -_08085D56: - ldr r2, _08085E88 - ldr r3, [sp, 0x1C] - lsrs r0, r3, 16 - ldr r1, [sp, 0x20] - orrs r0, r1 - str r0, [sp, 0xC] - ldr r3, [sp, 0x24] - lsrs r1, r3, 16 - ldr r0, [r7, 0x4] - ands r0, r2 - orrs r0, r1 - str r0, [r7, 0x4] - ldr r0, _08085E8C - ldr r1, _08085E80 - ldr r3, [r1] - ldr r1, _08085E84 - ldr r1, [r1] - movs r2, 0xBE - lsls r2, 1 - adds r1, r2 - str r1, [sp] - str r7, [sp, 0x4] - movs r1, 0xA0 - movs r2, 0x20 - bl sub_8004C00 - movs r3, 0x20 - add r8, r3 - ldr r5, _08085E90 - add r6, sp, 0x8 - movs r4, 0x20 -_08085D94: - ldrb r0, [r5] - ldr r1, [sp, 0x14] - adds r2, r0, r1 - ldrb r0, [r5, 0x1] - mov r3, r10 - adds r1, r0, r3 - ldrb r0, [r5, 0x2] - add r0, r9 - cmp r2, 0xFF - ble _08085DAA - movs r2, 0xFF -_08085DAA: - cmp r1, 0xFF - ble _08085DB0 - movs r1, 0xFF -_08085DB0: - cmp r0, 0xFF - ble _08085DB6 - movs r0, 0xFF -_08085DB6: - cmp r2, 0 - bge _08085DBC - movs r2, 0 -_08085DBC: - cmp r1, 0 - bge _08085DC2 - movs r1, 0 -_08085DC2: - cmp r0, 0 - bge _08085DC8 - movs r0, 0 -_08085DC8: - strb r2, [r6] - strb r1, [r6, 0x1] - strb r0, [r6, 0x2] - ldr r0, _08085E80 - ldr r2, [r0] - ldr r7, _08085E84 - ldr r3, [r7] - movs r0, 0xBE - lsls r0, 1 - adds r3, r0 - mov r0, r8 - add r1, sp, 0x8 - bl SetBGPaletteBufferColorRGB - adds r5, 0x4 - movs r1, 0x1 - add r8, r1 - subs r4, 0x1 - cmp r4, 0 - bne _08085D94 - ldr r2, [sp, 0x18] - cmp r2, 0 - beq _08085E5E - ldr r0, [r7] - ldr r3, _08085E94 - adds r0, r3 - ldr r0, [r0] - ldr r5, [r0, 0x4] - movs r0, 0x80 - lsls r0, 1 - mov r8, r0 - add r6, sp, 0x8 - movs r4, 0xD0 -_08085E0A: - ldrb r0, [r5] - ldr r1, [sp, 0x14] - adds r2, r0, r1 - ldrb r0, [r5, 0x1] - mov r3, r10 - adds r1, r0, r3 - ldrb r0, [r5, 0x2] - add r0, r9 - cmp r2, 0xFF - ble _08085E20 - movs r2, 0xFF -_08085E20: - cmp r1, 0xFF - ble _08085E26 - movs r1, 0xFF -_08085E26: - cmp r0, 0xFF - ble _08085E2C - movs r0, 0xFF -_08085E2C: - cmp r2, 0 - bge _08085E32 - movs r2, 0 -_08085E32: - cmp r1, 0 - bge _08085E38 - movs r1, 0 -_08085E38: - cmp r0, 0 - bge _08085E3E - movs r0, 0 -_08085E3E: - strb r2, [r6] - strb r1, [r6, 0x1] - strb r0, [r6, 0x2] - ldr r0, _08085E80 - ldr r2, [r0] - mov r0, r8 - add r1, sp, 0x8 - movs r3, 0 - bl SetBGPaletteBufferColorRGB - adds r5, 0x4 - movs r0, 0x1 - add r8, r0 - subs r4, 0x1 - cmp r4, 0 - bne _08085E0A -_08085E5E: - add sp, 0x28 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 -_08085E70: .4byte gDungeonPaletteFile -_08085E74: .4byte 0xffffff00 -_08085E78: .4byte 0xffff00ff -_08085E7C: .4byte 0xff00ffff -_08085E80: .4byte gDungeonBrightness -_08085E84: .4byte gDungeon -_08085E88: .4byte 0xffff0000 -_08085E8C: .4byte gUnknown_202EE8C -_08085E90: .4byte gUnknown_202ECA4 -_08085E94: .4byte 0x000181e4 - thumb_func_end SetDungeonBGColorRGB diff --git a/data/data_80F4D44.s b/data/data_80F4D44.s deleted file mode 100644 index dae085b27..000000000 --- a/data/data_80F4D44.s +++ /dev/null @@ -1,11 +0,0 @@ - .section .rodata - -.align 2,0 - .string "pksdir0\0" - .align 2,0 - - .global gUnknown_80F4D8C -gUnknown_80F4D8C: @ 80F4D8C - @ replacing .incbin "baserom.gba", 0x000f4d8c, 0x14 - .string "mapparam\0" - .align 2,0 diff --git a/data/data_80F59C8_0.s b/data/data_80F59C8_0.s deleted file mode 100644 index 7e47e8ff5..000000000 --- a/data/data_80F59C8_0.s +++ /dev/null @@ -1,62 +0,0 @@ -#include "constants/status.h" -.section .rodata -#.incbin "baserom.gba", 0xF59C4, 0x4 - -.string "pksdir0\0" -.global gUnknown_80F6490 -gUnknown_80F6490: @ 80F6490 -@ replacing .incbin "baserom.gba", 0x000f6490, 0x24 -.byte 0x00, 0x00, 0x00, 0x0 -.byte 0x0f, 0x00, 0x00, 0x00 -.byte 0xff, 0x00, 0x00, 0x00 -.byte 0xff, 0x0f, 0x00, 0x00 -.byte 0xff, 0xff, 0x00, 0x00 -.byte 0xff, 0xff, 0x0f, 0x00 -.byte 0xff, 0xff, 0xff, 0x00 -.byte 0xff, 0xff, 0xff, 0x0f -.byte 0xff, 0xff, 0xff, 0xff - -.global gUnknown_80F64B4 -gUnknown_80F64B4: @ 80F64B4 -@ replacing .incbin "baserom.gba", 0x000f64b4, 0x24 -.byte 0x5a, 0x00, 0x00, 0x00 -.byte 0x50, 0x00, 0x00, 0x00 -.byte 0x46, 0x00, 0x00, 0x00 -.byte 0x3c, 0x00, 0x00, 0x00 -.byte 0x32, 0x00, 0x00, 0x00 -.byte 0x28, 0x00, 0x00, 0x00 -.byte 0x1e, 0x00, 0x00, 0x00 -.byte 0x14, 0x00, 0x00, 0x00 -.byte 0x0a, 0x00, 0x00, 0x00 - -.global gUnknown_80F64D8 -gUnknown_80F64D8: @ 80F64D8 -@ replacing .incbin "baserom.gba", 0x000f64d8, 0x24 -.byte 0x91, 0xf2, 0x90, 0xf2, 0x8f, 0xf2, 0x8e, 0xf2, 0x8d, 0xf2, 0x8c, 0xf2, 0x8b, 0xf2, 0x8a, 0xf2, 0x89, 0xf2, 0xc8, 0xf2, 0xc7, 0xf2, 0xc6, 0xf2, 0xc5, 0xf2, 0xc4, 0xf2, 0xc3, 0xf2, 0xc2, 0xf2 -.byte 0xc1, 0xf2, 0xc0, 0xf2 - -.global gUnknown_80F64FC -gUnknown_80F64FC: @ 80F64FC -@ replacing .incbin "baserom.gba", 0x000f64fc, 0x24 -.byte 0x84, 0x03, 0x00, 0x00, 0x20, 0x03, 0x00, 0x00, 0xbc, 0x02, 0x00, 0x00, 0x58, 0x02, 0x00, 0x00, 0xf4, 0x01, 0x00, 0x00, 0x90, 0x01, 0x00, 0x00, 0x2c, 0x01, 0x00, 0x00, 0xc8, 0x00, 0x00, 0x00 -.byte 0x64, 0x00, 0x00, 0x00 - -.global gUnknown_80F6520 -gUnknown_80F6520: @ 80F6520 -@ replacing .incbin "baserom.gba", 0x000f6520, 0x24 -.byte 0x5a, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00 -.byte 0x0a, 0x00, 0x00, 0x00 - -.global gUnknown_80F6544 -gUnknown_80F6544: @ 80F6544 -@ replacing .incbin "baserom.gba", 0x000f6544, 0x24 -.byte 0x91, 0xf2, 0x90, 0xf2, 0x8f, 0xf2, 0x8e, 0xf2, 0x8d, 0xf2, 0x8c, 0xf2, 0x8b, 0xf2, 0x8a, 0xf2, 0x89, 0xf2, 0xc8, 0xf2, 0xc7, 0xf2, 0xc6, 0xf2, 0xc5, 0xf2, 0xc4, 0xf2, 0xc3, 0xf2, 0xc2, 0xf2 -.byte 0xc1, 0xf2, 0xc0, 0xf2 - -.global gUnknown_80F6568 -gUnknown_80F6568: @ 80F6568 -@ replacing .incbin "baserom.gba", 0x000f6568, 0x88 -.byte 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff -.byte 0x01, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0x02, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0x02, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0x02, 0x00, 0x00, 0x00, 0xfd, 0xff, 0xff, 0xff -.byte 0x03, 0x00, 0x00, 0x00, 0xfd, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0xfd, 0xff, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff -.byte 0x04, 0x00, 0x00, 0x00, 0xfb, 0xff, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00, 0xfb, 0xff, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00, 0xfb, 0xff, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00, 0xfb, 0xff, 0xff, 0xff diff --git a/data/data_80F59C8_3.s b/data/data_80F59C8_3.s deleted file mode 100644 index e8ef47bc7..000000000 --- a/data/data_80F59C8_3.s +++ /dev/null @@ -1,26 +0,0 @@ -#include "constants/status.h" -.section .rodata -#.incbin "baserom.gba", 0xF59C4, 0x4 - -.string "pksdir0\0" - -.global gUnknown_80F61EC -gUnknown_80F61EC: @ 80F61EC -@ replacing .incbin "baserom.gba", 0x000f61ec, 0x30 -.byte 0xfc, 0xff, 0xfc, 0xff, 0xf8, 0xff, 0xfc, 0xff, 0xf0, 0xff, 0xfc, 0xff, 0xf0, 0xff, 0xfc, 0xff, 0xf0, 0xff, 0xfc, 0xff, 0xf0, 0xff, 0xfc, 0xff, 0xfc, 0xff, 0xfc, 0xff, 0xf8, 0xff, 0xfc, 0xff -.byte 0xf0, 0xff, 0xf8, 0xff, 0xf0, 0xff, 0xf8, 0xff, 0xf0, 0xff, 0xf8, 0xff, 0xf0, 0xff, 0xf8, 0xff - -.global gUnknown_80F621C -gUnknown_80F621C: @ 80F621C -@ replacing .incbin "baserom.gba", 0x000f621c, 0x8 -.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - -.global gUnknown_80F6224 -gUnknown_80F6224: @ 80F6224 -@ replacing .incbin "baserom.gba", 0x000f6224, 0x88 -.byte 0x00, 0x02, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x02, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 -.byte 0x01, 0x00, 0x00, 0x00, 0x23, 0x02, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x23, 0x02, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x23, 0x02, 0x00, 0x00 -.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x02, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00 -.byte 0x0a, 0x02, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2a, 0x02, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2a, 0x02, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 -.byte 0x02, 0x00, 0x00, 0x00, 0x2a, 0x02, 0x00, 0x00 - diff --git a/data/data_8107224.s b/data/data_8107224.s deleted file mode 100644 index bdc0e4353..000000000 --- a/data/data_8107224.s +++ /dev/null @@ -1,152 +0,0 @@ -.section .rodata - -@ ??? -.string "pksdir0\0" -@ ??? -.string "pksdir0\0" -@ ??? -.string "pksdir0\0" -@ ??? -.string "pksdir0\0" -@ ??? -.string "pksdir0\0" -@ START code_808417C #1 -.string "pksdir0\0" - -.string "pksdir0\0" - -.global gUnknown_8107224 -gUnknown_8107224: @ 8107224 -.string "??????\0" -.align 2, 0 -@ END code_808417C #1 -@ code_8085B0C -.string "pksdir0\0" - -.global gUnknown_8107234 -gUnknown_8107234: @ 8107234 -.byte 0x01, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00, 0x00, 0x02, 0x04, 0x02, 0x05, 0x03, 0x06, 0x00, 0x00 -.byte 0x03, 0x07, 0x04, 0x08, 0x05, 0x09, 0x00, 0x00, 0x04, 0x0a, 0x06, 0x0b, 0x07, 0x0c, 0x00, 0x00 -.byte 0x05, 0x0d, 0x08, 0x0e, 0x09, 0x0f, 0x00, 0x00, 0x06, 0x10, 0x0a, 0x11, 0x0a, 0x11, 0x00, 0x00 -.byte 0x07, 0x12, 0x0b, 0x13, 0x0c, 0x14, 0x00, 0x00, 0x14, 0x15, 0x0d, 0x16, 0x0d, 0x16, 0x00, 0x00 -.byte 0x08, 0x17, 0x0e, 0x18, 0x0f, 0x19, 0x00, 0x00, 0x0b, 0x1a, 0x10, 0x1b, 0x11, 0x1c, 0x00, 0x00 -.byte 0x09, 0x1d, 0x12, 0x1e, 0x13, 0x1f, 0x00, 0x00, 0x0c, 0x20, 0x14, 0x21, 0x15, 0x22, 0x00, 0x00 -.byte 0x0d, 0x23, 0x16, 0x24, 0x17, 0x25, 0x00, 0x00, 0x0e, 0x26, 0x18, 0x27, 0x19, 0x28, 0x00, 0x00 -.byte 0x0f, 0x29, 0x40, 0x29, 0x1a, 0x2a, 0x00, 0x00, 0x10, 0x2b, 0x1b, 0x2c, 0x1c, 0x2d, 0x00, 0x00 -.byte 0x11, 0x2e, 0x40, 0x2e, 0x40, 0x2e, 0x00, 0x00, 0x12, 0x2f, 0x40, 0x2f, 0x40, 0x2f, 0x00, 0x00 -.byte 0x13, 0x30, 0x40, 0x30, 0x40, 0x30, 0x00, 0x00, 0x0a, 0x31, 0x40, 0x31, 0x1e, 0x32, 0x00, 0x00 -.byte 0x15, 0x33, 0x40, 0x33, 0x40, 0x33, 0x00, 0x00, 0x16, 0x34, 0x40, 0x34, 0x40, 0x34, 0x00, 0x00 -.byte 0x17, 0x35, 0x40, 0x35, 0x40, 0x35, 0x00, 0x00, 0x19, 0x36, 0x40, 0x36, 0x40, 0x36, 0x00, 0x00 -.byte 0x1b, 0x37, 0x40, 0x37, 0x40, 0x37, 0x00, 0x00, 0x1a, 0x38, 0x20, 0x39, 0x20, 0x39, 0x00, 0x00 -.byte 0x18, 0x3a, 0x21, 0x3b, 0x21, 0x3b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - -.global gUnknown_8107314 -gUnknown_8107314: @ 8107314 -.byte 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff -.byte 0x02, 0x00, 0x00, 0x00, 0xfd, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff -.byte 0x04, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff -.byte 0x04, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff -.byte 0x04, 0x00, 0x00, 0x00 - -.global gUnknown_8107358 -gUnknown_8107358: @ 8107358 -.byte 0x04, 0x03, 0x02, 0x03, 0x04, 0x05, 0x06, 0x05, 0x04, 0x03, 0x02, 0x03, 0x04, 0x05, 0x06, 0x05 -.byte 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x06, 0x00, 0x00, 0x00, 0x00 - -.global gUnknown_8107374 -gUnknown_8107374: @ 8107374 -.byte 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - -.global gUnknown_8107380 -gUnknown_8107380: @ 8107380 -.byte 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -@ ??? -.string "pksdir0\0" -@ code_8086A3C #1 -.string "pksdir0\0" - -.global gUnknown_810739C -gUnknown_810739C: @ 810739C -.byte 0x04, 0x00, 0x02, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x02, 0x00, 0x18, 0x00, 0x00, 0x00 -.byte 0x04, 0x00, 0x02, 0x00, 0x18, 0x00, 0x00, 0x00, 0x05, 0x00, 0x02, 0x00, 0x0c, 0x00, 0x00, 0x00 -.byte 0x06, 0x00, 0x02, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -.byte 0x00, 0x00, 0x0b, 0x00, 0x08, 0x00, 0x00, 0x00 - -.global gUnknown_81073D4 -gUnknown_81073D4: @ 81073D4 -.byte 0x04, 0x00, 0x02, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x02, 0x00, 0x18, 0x00, 0x00, 0x00 -.byte 0x04, 0x00, 0x02, 0x00, 0x18, 0x00, 0x00, 0x00, 0x05, 0x00, 0x02, 0x00, 0x0c, 0x00, 0x00, 0x00 -.byte 0x06, 0x00, 0x02, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -.byte 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x00, 0x00 - -.global gUnknown_810740C -gUnknown_810740C: @ 810740C -.byte 0x04, 0x00, 0x02, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x05, 0x00, 0x02, 0x00, 0x0c, 0x00, 0x00, 0x00 -.byte 0x04, 0x00, 0x02, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x18, 0x00, 0x00, 0x00 -.byte 0x03, 0x00, 0x02, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -.byte 0x00, 0x00, 0x0a, 0x00, 0x08, 0x00, 0x00, 0x00 -@ code_8086A3C #2 -.string "pksdir0\0" - -.global gUnknown_810744C -gUnknown_810744C: @ 810744C -.byte 0x01, 0x00, 0x02, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -.byte 0x00, 0x00, 0x09, 0x00, 0x09, 0x00, 0x00, 0x00 - -.global gUnknown_8107464 -gUnknown_8107464: @ 8107464 -.byte 0x05, 0x00, 0x02, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x0c, 0x00, 0x00, 0x00 -.byte 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x07, 0x00, 0x00, 0x00 -.string "pksdir0\0" -.string "pksdir0\0" -.string "pksdir0\0" -.string "pksdir0\0" -.string "pksdir0\0" -.string "pksdir0\0" -.string "pksdir0\0" -.string "pksdir0\0" -.string "pksdir0\0" -.string "pksdir0\0" -.string "pksdir0\0" -.string "pksdir0\0" -.string "pksdir0\0" -.string "pksdir0\0" -@ ??? -.string "pksdir0\0" - -.global gUnknown_81074FC -gUnknown_81074FC: @ 81074FC -.byte 0x4e, 0x4f, 0x50, 0x51, 0x4a, 0x49, 0x3e, 0x38 - -@ ??? -.string "pksdir0\0" -@ ??? -.string "pksdir0\0" -@ ??? -.string "pksdir0\0" -@ ??? -.string "pksdir0\0" -@ ??? -.string "pksdir0\0" -@ ??? -.string "pksdir0\0" -@ ??? -.string "pksdir0\0" -@ ??? -.string "pksdir0\0" - -.global gUnknown_8107544 -gUnknown_8107544: @ 8107544 -.byte 0x02, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00 -.byte 0x02, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x08, 0x00, 0x01, 0x00, 0x00, 0x00 -.byte 0x07, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x08, 0x00, 0x01, 0x00, 0x00, 0x00 -.byte 0x0d, 0x00, 0x05, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x08, 0x00, 0x01, 0x00, 0x00, 0x00 -.byte 0x17, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x08, 0x00, 0x01, 0x00, 0x00, 0x00 -.byte 0x12, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 -.byte 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00 -.byte 0x07, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00 -.byte 0x0d, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00 -.byte 0x17, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00 -.byte 0x12, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 - -.align 2,0 diff --git a/data/pksdir_3.s b/data/pksdir_3.s index 9ccc2af69..f8df0a71f 100644 --- a/data/pksdir_3.s +++ b/data/pksdir_3.s @@ -4,4 +4,4 @@ .string "pksdir0\0" .string "pksdir0\0" -.string "pksdir0\0" \ No newline at end of file +.string "pksdir0\0" diff --git a/data/pksdir_4.s b/data/pksdir_4.s new file mode 100644 index 000000000..43dacf9e3 --- /dev/null +++ b/data/pksdir_4.s @@ -0,0 +1,4 @@ +.section .rodata + +.align 2 +.string "pksdir0\0" diff --git a/include/code_800DAC0.h b/include/code_800DAC0.h index e36cc1b99..d5b97d875 100644 --- a/include/code_800DAC0.h +++ b/include/code_800DAC0.h @@ -16,6 +16,7 @@ typedef struct unkStruct_80416E0 u16 unk12; s32 unk14; u32 unk18; + unkStruct_2039DB0 unk1C; } unkStruct_80416E0; u32 sub_800E890(unkStruct_80416E0 *); diff --git a/include/code_803E46C.h b/include/code_803E46C.h deleted file mode 100644 index dce842980..000000000 --- a/include/code_803E46C.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef GUARD_CODE_803E46C_H -#define GUARD_CODE_803E46C_H - -extern u8 gUnknown_203B40D; - -void DungeonRunFrameActions(u32); - -#endif // GUARD_CODE_803E46C_H diff --git a/include/code_8044CC8.h b/include/code_8044CC8.h deleted file mode 100644 index c5bcecc20..000000000 --- a/include/code_8044CC8.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef GUARD_CODE_8044CC8_H -#define GUARD_CODE_8044CC8_H - -// size: 0x4 -typedef struct unkStruct_202EE44 -{ - u16 actionId; - u8 unk2; - bool8 canBeChosen; -} unkStruct_202EE44; - -extern unkStruct_202EE44 gDungeonSubMenu[10]; - -void AddActionToDungeonSubMenu(u16 actionId, u8 param_2); -void SetActionUnusableInDungeonSubMenu(u16 actionId); - -#endif // GUARD_CODE_8044CC8_H diff --git a/include/code_808417C.h b/include/code_808417C.h deleted file mode 100644 index 12359877f..000000000 --- a/include/code_808417C.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef GUARD_808417C_H -#define GUARD_808417C_H - -#include "structs/dungeon_entity.h" - -s32 CalculateStatusTurns(Entity *target, const s16 *turnRange, bool8 factorCurerSkills); - -#endif // GUARD_808417C_H diff --git a/include/code_8084778.h b/include/code_8084778.h deleted file mode 100644 index e28b078ce..000000000 --- a/include/code_8084778.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef GUARD_CODE_8084778_H -#define GUARD_CODE_8084778_H - -void sub_8084778(void); - -#endif diff --git a/include/constants/dungeon_action.h b/include/constants/dungeon_action.h index edd1d28b1..f092e1a5e 100644 --- a/include/constants/dungeon_action.h +++ b/include/constants/dungeon_action.h @@ -60,4 +60,18 @@ enum DungeonAction NUM_DUNGEON_ACTIONS }; +// size: 0x4 +typedef struct SubMenuAction +{ + u16 actionId; + u8 unk2; + bool8 canBeChosen; +} SubMenuAction; + +extern SubMenuAction gDungeonSubMenu[10]; +extern s32 gDungeonSubMenuItemsCount; + +void AddActionToDungeonSubMenu(u16 actionId, u8 param_2); +void SetActionUnusableInDungeonSubMenu(u16 actionId); + #endif diff --git a/include/dungeon_8083AB0.h b/include/dungeon_8083AB0.h new file mode 100644 index 000000000..2d75d1ea4 --- /dev/null +++ b/include/dungeon_8083AB0.h @@ -0,0 +1,11 @@ +#ifndef GUARD_DUNGEON_8083AB0_H +#define GUARD_DUNGEON_8083AB0_H + +#include "structs/dungeon_entity.h" + +void sub_8083AB0(s16 param_0, Entity *target, Entity *entity); +bool8 sub_8083C24(void); +bool8 sub_8083C50(void); +bool8 sub_8083C88(u8 param_1); + +#endif // GUARD_DUNGEON_8083AB0_H diff --git a/include/dungeon_jobs.h b/include/dungeon_jobs.h new file mode 100644 index 000000000..761ca180d --- /dev/null +++ b/include/dungeon_jobs.h @@ -0,0 +1,13 @@ +#ifndef GUARD_DUNGEON_JOBS_H +#define GUARD_DUNGEON_JOBS_H + +#include "structs/dungeon_entity.h" + +void sub_80842F0(void); +void sub_80843BC(s32 id); +void sub_8084424(void); +void sub_8084448(Entity *pokemon); +void sub_80845E0(Entity *pokemon); +void sub_8084778(void); + +#endif diff --git a/include/dungeon_music.h b/include/dungeon_music.h index c6a983a9f..366f9e294 100644 --- a/include/dungeon_music.h +++ b/include/dungeon_music.h @@ -12,10 +12,6 @@ void PlayDungeonStartButtonSE(void); void PlaySoundEffect(u32 songIndex); void StopDungeonBGM(void); void StopSoundEffect(u32 songIndex); -void sub_8083AB0(s16 param_0, Entity *target, Entity *entity); -bool8 sub_8083C24(void); -bool8 sub_8083C50(void); -bool8 sub_8083C88(u8); void UpdateDungeonMusic(void); #endif // GUARD_DUNGEON_MUSIC_H diff --git a/include/dungeon_portrait_placement.h b/include/dungeon_portrait_placement.h new file mode 100644 index 000000000..7f6a1c8cb --- /dev/null +++ b/include/dungeon_portrait_placement.h @@ -0,0 +1,14 @@ +#ifndef GUARD_DUNGEON_PORTRAIT_PLACEMENT_H +#define GUARD_DUNGEON_PORTRAIT_PLACEMENT_H + +#include "structs/str_position.h" + +struct PortraitPlacementInfo +{ + DungeonPos pos; + bool8 flip; +}; + +const struct PortraitPlacementInfo *GetPortraitPlacementInfo(u8 id); + +#endif diff --git a/include/dungeon_pos_data.h b/include/dungeon_pos_data.h new file mode 100644 index 000000000..a4ad9882d --- /dev/null +++ b/include/dungeon_pos_data.h @@ -0,0 +1,22 @@ +#ifndef GUARD_DUNGEON_POS_DATA_H +#define GUARD_DUNGEON_POS_DATA_H + +#include "structs/str_position.h" +#include "constants/direction.h" + +struct PositionArrayWithOffsets +{ + const DungeonPos *posArray; + s16 xOffset; + s16 yOffset; +}; + +extern const DungeonPos gAdjacentTileOffsets[]; +extern const DungeonPos gUnknown_80F4468[76]; +extern const DungeonPos gUnknown_80F4598[158]; +extern const struct PositionArrayWithOffsets gUnknown_80F4CC4[NUM_DIRECTIONS]; +extern const s32 gFaceDirectionIncrements[]; +extern const DungeonPos gUnknown_80F4D44[]; +extern const u8 gUnknown_80F4D64[]; + +#endif diff --git a/include/dungeon_random.h b/include/dungeon_random.h index 5e3c5b6db..d0c798b96 100644 --- a/include/dungeon_random.h +++ b/include/dungeon_random.h @@ -1,6 +1,8 @@ #ifndef GUARD_DUNGEON_RANDOM_H #define GUARD_DUNGEON_RANDOM_H +#include "structs/dungeon_entity.h" + void sub_808408C(u32 param_1); u32 YetAnotherRandom24(void); void InitDungeonRNG(u32 value); @@ -9,4 +11,6 @@ s32 DungeonRandInt(s32 cap); s32 DungeonRandRange(s32 low, s32 high); bool8 DungeonRandOutcome(s32 percentChance); bool8 DungeonRandOutcome_2(s32 percentChance); +s32 CalculateStatusTurns(Entity *target, const s16 *turnRange, bool8 factorCurerSkills); + #endif diff --git a/include/dungeon_util_1.h b/include/dungeon_util_1.h index f0f5a00f0..2ace77a58 100644 --- a/include/dungeon_util_1.h +++ b/include/dungeon_util_1.h @@ -21,13 +21,11 @@ void sub_80856C8(Entity * pokemon, s32 x, s32 y); void sub_80856E0(Entity * pokemon, s32 direction); void sub_8085764(void); void sub_8085860(s32 x, s32 y); -void sub_8085890(s32 x, s32 y); void ShiftCameraToPosition(PixelPos *posStruct, s32 cameraSteps); void SetFacingDirection(Entity *pokemon, s32 direction); void sub_8085930(s32 direction); void sub_80859F0(s32 direction); bool8 ShouldRunMonsterAI(Entity *entity); -void sub_8085B0C(Entity *pokemon); void sub_8085B4C(struct_8085B80 a0[], s16 *a1[], Entity *a2[], s32 a3); void sub_80857B8(void); diff --git a/include/dungeon_vram.h b/include/dungeon_vram.h new file mode 100644 index 000000000..93b9e8fea --- /dev/null +++ b/include/dungeon_vram.h @@ -0,0 +1,10 @@ +#ifndef GUARD_DUNGEON_VRAM_H +#define GUARD_DUNGEON_VRAM_H + +// TODO: copy stuff from dungeon_vram.c to this header + +extern u8 gUnknown_203B40D; + +void DungeonRunFrameActions(u32); + +#endif // GUARD_DUNGEON_VRAM_H diff --git a/include/global.h b/include/global.h index 19f3d9f3d..b45a00bbb 100644 --- a/include/global.h +++ b/include/global.h @@ -67,7 +67,7 @@ static inline bool8 AreStringsDifferent(const u8 *str1, const u8 *str2) #define asm_unified(x) asm(".syntax unified\n" x "\n.syntax divided\n") #define ARRAY_COUNT(array) (sizeof(array) / sizeof((array)[0])) -#define ARRAY_COUNT_INT(array) ((s32)(sizeof(array) / sizeof((array)[0]))) // When an int is needed to match. +#define ARRAY_COUNT_INT(array) ((s32)(ARRAY_COUNT(array))) // When an int is needed to match. #define SWAP(a, b, temp) \ { \ diff --git a/include/structs/str_dungeon.h b/include/structs/str_dungeon.h index dd12783b3..9d9219bb5 100644 --- a/include/structs/str_dungeon.h +++ b/include/structs/str_dungeon.h @@ -12,6 +12,7 @@ #define DUNGEON_MAX_SIZE_X 56 #define DUNGEON_MAX_SIZE_Y 32 +#define DUNGEON_MAX_NUM_TILES (DUNGEON_MAX_SIZE_X * DUNGEON_MAX_SIZE_Y) #define DUNGEON_MAX_WILD_POKEMON 16 #define DUNGEON_MAX_WILD_POKEMON_BODY_SIZE 16 #define DUNGEON_MAX_POKEMON (MAX_TEAM_MEMBERS + DUNGEON_MAX_WILD_POKEMON) diff --git a/include/structs/str_position.h b/include/structs/str_position.h index 42b312f96..599267924 100644 --- a/include/structs/str_position.h +++ b/include/structs/str_position.h @@ -1,6 +1,13 @@ #ifndef GUARD_STR_POSITION_H #define GUARD_STR_POSITION_H +// Used in dungeon generation and sub_8083660 +struct PositionU8 +{ + u8 x; + u8 y; +}; + // size: 0x4 typedef struct DungeonPos { diff --git a/include/text_util.h b/include/text_util.h index 1ec7e5095..9706cb891 100644 --- a/include/text_util.h +++ b/include/text_util.h @@ -3,7 +3,7 @@ void sub_80922B4(u8 *buffer, const u8 *string, s32 size); u32 sub_80922E4(u32 r0); -void CopyStringtoBuffer(u8 *buffer, u8 *string); +void CopyStringtoBuffer(u8 *buffer, const u8 *string); void BoundedCopyStringtoBuffer(u8 *buffer, u8 *string, s32 size); const char *GetUnformattedTypeString(u8 type); const char * GetFormattedTypeString(u8 type); diff --git a/ld_script.txt b/ld_script.txt index 11dc91560..907f33151 100755 --- a/ld_script.txt +++ b/ld_script.txt @@ -197,9 +197,9 @@ SECTIONS { src/personality_test2.o(.text); src/code_803D0D8.o(.text); src/code_803D110.o(.text); - src/code_803E46C.o(.text); - src/code_803E724.o(.text); - src/code_8040094.o(.text); + src/code_803DA7C.o(.text); + src/dungeon_vram.o(.text); + src/dungeon_tilemap.o(.text); src/dungeon_map.o(.text); src/code_8040094_1.o(.text); src/code_8041AD0.o(.text); @@ -275,21 +275,38 @@ SECTIONS { src/trap.o(.text); src/dungeon_serializer.o(.text); src/dungeon_range.o(.text); - src/code_808333C.o(.text); - src/dungeon_leader.o(.text); - asm/code_8083654.o(.text); + src/dungeon_8083AB0.o(.text); src/dungeon_music.o(.text); src/dungeon_random.o(.text); - src/code_808417C.o(.text); - asm/code_808417C.o(.text); - src/code_8084778.o(.text); + src/dungeon_cleared_window.o(.text); + src/dungeon_jobs.o(.text); src/code_80848F0.o(.text); - src/dungeon_util_1.o(.text); - asm/code_8085B80.o(.text); - src/code_8085E98.o(.text); - src/code_80861A8.o(.text); - src/code_80869E4.o(.text); - src/dungeon_cutscenes.o(.text); + src/dungeon_cutscene_skarmory.o(.text); + src/dungeon_cutscene_meanies.o(.text); + src/dungeon_cutscene_zapdos.o(.text); + src/dungeon_cutscene_moltres.o(.text); + src/dungeon_cutscene_articuno.o(.text); + src/dungeon_cutscene_empty_summit.o(.text); + src/dungeon_cutscene_groudon.o(.text); + src/dungeon_cutscene_magma_cavern.o(.text); + src/dungeon_cutscene_rayquaza.o(.text); + src/dungeon_cutscene_mankey.o(.text); + src/dungeon_cutscene_mewtwo.o(.text); + src/dungeon_cutscene_entei.o(.text); + src/dungeon_cutscene_raikou.o(.text); + src/dungeon_cutscene_suicune.o(.text); + src/dungeon_cutscene_hooh.o(.text); + src/dungeon_cutscene_latios.o(.text); + src/dungeon_cutscene_regis.o(.text); + src/dungeon_cutscene_jirachi.o(.text); + src/dungeon_cutscene_lugia.o(.text); + src/dungeon_cutscene_kyogre.o(.text); + src/dungeon_cutscene_deoxys.o(.text); + src/dungeon_cutscene_celebi.o(.text); + src/dungeon_cutscene_medicham.o(.text); + src/dungeon_cutscene_smeargle.o(.text); + src/dungeon_cutscene_no_one_here.o(.text); + src/dungeon_portrait_placement.o(.text); src/pokemon.o(.text); src/pokemon_3.o(.text); src/dungeon.o(.text); @@ -535,13 +552,12 @@ SECTIONS { src/personality_test2.o(.rodata); src/code_803D0D8.o(.rodata); src/dungeon_pos_data.o(.rodata); - data/data_80F4D44.o(.rodata); + src/code_803D110.o(.rodata); src/dungeon_config.o(.rodata); data/data_80F59C8_1.o(.rodata); - src/code_803D110.o(.rodata); - data/data_80F59C8_3.o(.rodata); - src/code_803E724.o(.rodata); - data/data_80F59C8_0.o(.rodata); + src/code_803DA7C.o(.rodata); + src/dungeon_vram.o(.rodata); + src/dungeon_tilemap.o(.rodata); src/dungeon_map.o(.rodata); src/code_8040094_1.o(.rodata); data/pksdir_0.o(.rodata); @@ -621,7 +637,40 @@ SECTIONS { src/trap.o(.rodata); data/pksdir_3.o(.rodata); src/dungeon_serializer.o(.rodata); - data/data_8107224.o(.rodata); + data/pksdir_4.o(.rodata); + src/dungeon_range.o(.rodata); + src/dungeon_8083AB0.o(.rodata); + src/dungeon_music.o(.rodata); + src/dungeon_random.o(.rodata); + src/dungeon_cleared_window.o(.rodata); + src/dungeon_jobs.o(.rodata); + src/code_80848F0.o(.rodata); + src/dungeon_cutscene_skarmory.o(.rodata); + src/dungeon_cutscene_meanies.o(.rodata); + src/dungeon_cutscene_zapdos.o(.rodata); + src/dungeon_cutscene_moltres.o(.rodata); + src/dungeon_cutscene_articuno.o(.rodata); + src/dungeon_cutscene_empty_summit.o(.rodata); + src/dungeon_cutscene_groudon.o(.rodata); + src/dungeon_cutscene_magma_cavern.o(.rodata); + src/dungeon_cutscene_rayquaza.o(.rodata); + src/dungeon_cutscene_mankey.o(.rodata); + src/dungeon_cutscene_mewtwo.o(.rodata); + src/dungeon_cutscene_entei.o(.rodata); + src/dungeon_cutscene_raikou.o(.rodata); + src/dungeon_cutscene_suicune.o(.rodata); + src/dungeon_cutscene_hooh.o(.rodata); + src/dungeon_cutscene_latios.o(.rodata); + src/dungeon_cutscene_regis.o(.rodata); + src/dungeon_cutscene_jirachi.o(.rodata); + src/dungeon_cutscene_lugia.o(.rodata); + src/dungeon_cutscene_kyogre.o(.rodata); + src/dungeon_cutscene_deoxys.o(.rodata); + src/dungeon_cutscene_celebi.o(.rodata); + src/dungeon_cutscene_medicham.o(.rodata); + src/dungeon_cutscene_smeargle.o(.rodata); + src/dungeon_cutscene_no_one_here.o(.rodata); + src/dungeon_portrait_placement.o(.rodata); src/pokemon.o(.rodata); data/data_81076E4.o(.rodata); src/game_options.o(.rodata); diff --git a/src/blow_away.c b/src/blow_away.c index 0ddb16246..4b8ee372c 100644 --- a/src/blow_away.c +++ b/src/blow_away.c @@ -2,7 +2,7 @@ #include "globaldata.h" #include "constants/ability.h" #include "constants/weather.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "dungeon_message.h" #include "code_806CD90.h" #include "code_807CD9C.h" diff --git a/src/code_803D0D8.c b/src/code_803D0D8.c index 5f03d3472..ec2851414 100644 --- a/src/code_803D0D8.c +++ b/src/code_803D0D8.c @@ -246,14 +246,3 @@ void sub_803D414(u8 *buffer,WonderMail *mail) } MemoryCopy8(buffer,auStack_44,sizeof(auStack_44)); } - - -// File boundary? - - - -void sub_803D4AC(void) -{ - gDungeon->unk1C570.id = 0x63; - gDungeon->unk1C570.floor = 0xFF; -} diff --git a/src/code_803D110.c b/src/code_803D110.c index 38fb12372..86142e3ad 100644 --- a/src/code_803D110.c +++ b/src/code_803D110.c @@ -1,4 +1,5 @@ #include "global.h" +#include "globaldata.h" #include "constants/dungeon.h" #include "structs/str_202ED28.h" #include "structs/str_202EDE8.h" @@ -6,7 +7,7 @@ #include "code_8009804.h" #include "code_800D090.h" #include "code_803D110.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "cpu.h" #include "def_filearchives.h" #include "dungeon.h" @@ -19,29 +20,10 @@ #include "text_3.h" #include "dungeon_config.h" +// File split is correct. + extern s32 sub_80902C8(u8 dungeon); extern void sub_808E9C4(UnkDungeonGlobal_unk1CD98 *r0, s16 r1); -extern bool8 sub_80848EC(void); -extern u8 GetFloorType(void); -extern const u8 *GetDungeonName2(u8 dungeon); - -extern const char gUnknown_80F4D8C[]; // "mapparam" -extern const char gUnknown_80F60F8[]; // "banrpal" -extern const char gUnknown_80F6100[]; // "banfont" -extern const char gUnknown_80F6108[]; -extern const char gUnknown_80F610C[]; -extern const char gUnknown_80F6110[]; -extern const char gUnknown_80F6118[]; -extern const u32 gUnknown_80F6120[]; - -extern RGB gUnknown_202ECA4[]; -extern OpenedFile *gDungeonNameBannerPalette; -extern OpenedFile *gDungeonNameBannerFontFile; -extern OpenedFile *gUnknown_202ECA0; -extern OpenedFile *gUnknown_202EC9C; -extern OpenedFile *gUnknown_202EC98; -extern OpenedFile *gUnknown_202EC94; -extern s32 gDungeonNameBannerFont; struct UnkDungeonFileData { @@ -60,49 +42,11 @@ struct UnkDataFileStruct u16 **unk10; }; -// Very similar to unkChar struct -typedef struct UnkStruct_sub_803DC6C +void sub_803D4AC(void) { - u8 *unk0; - u16 unk4; - u8 unk6; -} UnkStruct_sub_803DC6C; - -extern u32 gUnknown_202EDD0; -extern s32 gUnknown_202EDD4; -extern s32 gDungeonBrightness; - -extern SpriteOAM gUnknown_202EDC0; -extern SpriteOAM gUnknown_202EDB8; - -extern const DungeonPos gUnknown_80F61EC[2][6]; - -struct Unk80F6224Struct -{ - s32 shape; - s32 size; - s32 tileNum; -}; - -struct FileStruct2 -{ - s32 count; - u8 array[0]; -}; - -struct FileStruct -{ - struct FileStruct2 *ptr; - struct u8 *ptr2; -}; - -extern const struct Unk80F6224Struct gUnknown_80F621C[2][6]; - -s32 sub_803DC14(const u8 *dungName, s32 strWidth, s32 a2); -s32 CalcStringWidth(const u8 *dungName); -s32 sub_803DC6C(u32 chr, s32 strWidth, s32 a2); -static UnkStruct_sub_803DC6C *sub_803DEC8(s32 chr); -void sub_803DD30(u8 *a0, u32 *a1); + gDungeon->unk1C570.id = 0x63; + gDungeon->unk1C570.floor = 0xFF; +} void sub_803D4D0(void) { @@ -116,7 +60,7 @@ void sub_803D4D0(void) return; gDungeon->unk1C570 = gDungeon->unk644.dungeonLocation2; - file = OpenFileAndGetFileDataPtr(gUnknown_80F4D8C, &gDungeonFileArchive); + file = OpenFileAndGetFileDataPtr("mapparam", &gDungeonFileArchive); strPtr = &((struct UnkDataFileStruct *)(file->data))->unk0[gDungeon->unk1C570.id][gDungeon->unk1C570.floor]; gDungeon->unk1CEC8 = GetDungeonFloorCount(gDungeon->unk644.dungeonLocation.id); @@ -289,465 +233,3 @@ s32 sub_803DA20(s32 species) } return 1; } - -struct DungeonNameFontFileData -{ - /* 0x0 */ u8 unk0; - /* 0x4 */ s32 font; -}; - -struct DungeonNamePaletteFileData -{ - RGB pal[16]; -}; - -void ShowDungeonNameBanner_Async(void) -{ - u8 text[100]; - s32 var; - s32 i, r7; - const u8 *r6; - - gDungeonNameBannerPalette = OpenFileAndGetFileDataPtr(gUnknown_80F60F8, &gDungeonFileArchive); - gDungeonNameBannerFontFile = OpenFileAndGetFileDataPtr(gUnknown_80F6100, &gDungeonFileArchive); - gDungeonNameBannerFont = ((struct DungeonNameFontFileData *)(gDungeonNameBannerFontFile->data))->font; - for (i = 0; i < 16; i++) { - SetBGPaletteBufferColorArray(i + 224, &((struct DungeonNamePaletteFileData *)(gDungeonNameBannerPalette->data))->pal[i]); - } - CpuClear((void *)(VRAM + 0x140), 0x1C00); - if (sub_80848EC()) { - s32 r8 = gDungeon->unk644.dungeonLocation.floor + gDungeon->unk14; - const u8 *dungName = GetDungeonName2(gDungeon->unk644.dungeonLocation.id); - s32 r5 = 10; - - for (r7 = 0; r7 < 8; r7++) { - for (i = 0; i < 28; r5++) { - u16 a2; - - i++; - a2 = r5 | 0xE000; - sub_8008DC8(i, r7 + 4, r5 | a2, 0); - } - } - - var = sub_803DC14(dungName, (224 - CalcStringWidth(dungName)) / 2, 0); - if (IsStairDirectionUp(gDungeon->unk644.dungeonLocation.id)) - r6 = gUnknown_80F6108; - else - r6 = gUnknown_80F610C; - - if (r8 > 9) { - sprintfStatic(text, gUnknown_80F6110, r6, 48 + (r8 / 10), 48 + (r8 % 10)); - } - else { - sprintfStatic(text, gUnknown_80F6118, r6, 48 + r8); - } - - sub_803DC14(text, (224 - CalcStringWidth(text)) / 2, var + 32); - gUnknown_20274A5 = TRUE; - } - - CloseFile(gDungeonNameBannerFontFile); - DungeonRunFrameActions(2); -} - -s32 sub_803DC14(const u8 *dungName, s32 strWidth, s32 a2) -{ - while (*dungName != '\0') { - u32 currChar = *(dungName++); - if (currChar == '/') { - strWidth = 0; - a2 += 24; - } - else if (currChar == '#') { - strWidth += 8; - } - else if (currChar == ' ') { - strWidth += 12; - } - else { - if (currChar & 0x80 && *dungName != '\0') { - currChar = (currChar << 8) | *dungName; - dungName++; - } - strWidth += sub_803DC6C(currChar, strWidth, a2); - } - } - return a2; -} - -s32 sub_803DC6C(u32 chr, s32 strWidth, s32 a2) -{ - u32 *spPtr; - s32 i, j, a2DivMul; - u32 *vramPtr; - const u32 *constData; - u32 sp[72]; - s32 r9; - UnkStruct_sub_803DC6C *strPtr = sub_803DEC8(chr); - - sub_803DD30(strPtr->unk0, sp); - r9 = strPtr->unk6; - spPtr = sp; - - a2DivMul = ((a2 / 8) * 8); - vramPtr = (void *)(VRAM + 0x140 + (((a2DivMul - a2 / 8) * 4) + (strWidth / 8)) * 32); // Pixels? - vramPtr += a2 - a2DivMul; - constData = &gUnknown_80F6120[(strWidth - ((strWidth / 8) * 8)) * 4]; - for (i = 0; i < 24; i++) { - u32 *vramPtrLoop = vramPtr; - for (j = 0; j < 3; j++) { - // Sadly cannot match it without asm :/ - #ifdef NONMATCHING - u32 spVal = *spPtr; - #else - register u32 spVal asm("r2") = *spPtr; - #endif // NONMATCHING - - if (spVal != 0) { - *vramPtrLoop |= ((constData[0] & spVal) << constData[2]); - - vramPtrLoop += 8; - spVal &= constData[1]; - spVal >>= constData[3]; - *vramPtrLoop |= spVal; - vramPtrLoop -= 8; - } - spPtr++; - vramPtrLoop += 8; - } - - vramPtr++; - a2++; - - if (!(a2 & 7)) { - vramPtr += 216; - } - } - - return r9; -} - -void sub_803DD30(u8 *a0, u32 *a1) -{ - u8 sp[576]; - u8 sp575[576]; - s32 spId = 0; - s32 i, j = 0, k; - u32 currSp; - s32 r6; - - for (i = 0; i < 576; i += 2) { - sp[i] = (*a0 >> 4) & 0xF; - sp[i+1] = *a0 & 0xF; - a0++; - } - - while (j < 576) { - currSp = sp[spId++]; - r6 = currSp & 7; - if (currSp & 8) { - currSp = sp[spId++]; - for (k = 0; k < r6; k++) { - sp575[j] = currSp; - if (++j >= 576) - break; - } - } - else { - for (k = 0; k < r6; k++) { - currSp = sp[spId++]; - sp575[j] = currSp; - if (++j >= 576) - break; - } - } - if (j >= 576) - break; - } - - for (i = 0; i < 576; i += 8) { - u32 val = sp575[i + 7] << 0x1C; - val |= (sp575[i + 6] << 0x18) & 0xF000000; - val |= (sp575[i + 5] << 0x14) & 0xF00000; - val |= (sp575[i + 4] << 0x10) & 0xF0000; - val |= (sp575[i + 3] << 0xC) & 0xF000; - val |= (sp575[i + 2] << 0x8) & 0xF00; - val |= (sp575[i + 1] << 0x4) & 0xF0; - val |= (sp575[i]) & 0xF; - *(a1++) = val; - } -} - -// Could be a misnomer? -s32 CalcStringWidth(const u8 *dungName) -{ - s32 w = 0; - - while (*dungName != '\0') { - u32 currChar = *(dungName++); - if (currChar == '#') { - w += 8; - } - else if (currChar == ' ') { - w += 12; - } - else { - struct UnkStruct_sub_803DC6C *strPtr; - - if (currChar & 0x80 && *dungName != '\0') { - currChar = (currChar << 8) | *dungName; - dungName++; - } - strPtr = sub_803DEC8(currChar); - if (strPtr != NULL) { - w += strPtr->unk6; - } - } - } - - return w; -} - -static UnkStruct_sub_803DC6C *sub_803DEC8(s32 chr) -{ - s32 r2, r4; - UnkStruct_sub_803DC6C *ret; - UnkStruct_sub_803DC6C *strPtr = *((UnkStruct_sub_803DC6C **) gDungeonNameBannerFontFile->data); - // Fakematch? Or just magic numbers which will make more sense once this file is documented? - if (chr > 63487 && chr < 65535) - { - s32 r2 = chr & 0xFF; - s32 r1 = (chr & 0xFF00) >> 8; - r2 -= 32; - r1 -= 248; - ret = &strPtr[r1 * 224 + r2]; - } - else - { - r4 = 0; - r2 = gDungeonNameBannerFont - 1; - while (r4 < r2) { - s32 r1 = (r4 + r2) / 2; - if (strPtr[r1].unk4 == chr) { - r4 = r1; - break; - } - else if (strPtr[r1].unk4 < chr) { - r4 = r1 + 1; - } - else { - r2 = r1; - } - } - - ret = &strPtr[r4]; - if (ret->unk4 != chr) - ret = &strPtr[1]; - - - } - return ret; -}; - -void sub_803DF60(void) -{ - u8 *vram; - s32 i; - const void *src; - OpenedFile *file; - - file = OpenFileAndGetFileDataPtr("itempat", &gDungeonFileArchive); - src = ((struct FileStruct *)(file->data))->ptr; - i = ((struct FileStruct2 *)(src))->count; - src = ((struct FileStruct2 *)(src))->array; - vram = OBJ_VRAM0 + 0x3400; - while (i != 0) - { - CpuCopy(vram, src, 0x20); - vram += 0x20; - src += 0x20; - i--; - } - CloseFile(file); - - file = OpenFileAndGetFileDataPtr("etcfont", &gDungeonFileArchive); - src = ((struct FileStruct2 *)(file->data)); - i = ((struct FileStruct2 *)(src))->count; - src = ((struct FileStruct2 *)(src))->array; - vram = OBJ_VRAM0 + 0x4000; - while (i != 0) - { - CpuCopy(vram, src, 0x20); - vram += 0x20; - src += 0x20; - i--; - } - CloseFile(file); - - gUnknown_202EC94 = OpenFileAndGetFileDataPtr("etcfonta", &gDungeonFileArchive); - gUnknown_202EC98 = OpenFileAndGetFileDataPtr("levfont", &gDungeonFileArchive); - gUnknown_202EC9C = OpenFileAndGetFileDataPtr("hp5font", &gDungeonFileArchive); - gUnknown_202ECA0 = OpenFileAndGetFileDataPtr("colvec", &gDungeonFileArchive); -} - -void sub_803E02C(void) -{ - u8 *vram; - s32 i, j, r6; - const void *src; - OpenedFile *file; - u8 fileName[12]; - - sub_803E13C(); - strcpy(fileName, "trappat"); - file = OpenFileAndGetFileDataPtr(fileName, &gDungeonFileArchive); - - src = ((struct FileStruct *)(file->data))->ptr; - i = ((struct FileStruct2 *)(src))->count; - src = ((struct FileStruct2 *)(src))->array; - vram = (void *) VRAM + 0xC000; - while (i != 0) - { - CpuCopy(vram, src, 0x20); - vram += 0x20; - src += 0x20; - i--; - } - CpuCopy(gUnknown_202ECA4, ((struct FileStruct *)(file->data))->ptr2, 0x80); - CloseFile(file); - - r6 = 0x200; - for (i = 0; i < UNK12A18_ARR_COUNT; i++) { - for (j = 0; j < UNK12A18_ARR_COUNT_2; j++) { - gDungeon->unk12A18[i][j] = (gUnknown_80F5F70[i] << 0xC) | r6; - r6++; - } - } - for (i = 0; i < 9; i++) { - gDungeon->unk13554[i] = 0xC000; - } - for (i = 0; i < COLOR_RAMP_COUNT; i++) { - gDungeon->colorRamp[i].r = i; - gDungeon->colorRamp[i].g = i; - gDungeon->colorRamp[i].b = i; - } -} - -void sub_803E13C(void) -{ - s32 i; - RGB *pal; - - SetWindowBGColor(); - if (gGameOptionsRef->playerGender != 0) - pal = &gFontPalette[16 * 4]; - else - pal = &gFontPalette[0]; - - for (i = 0; i < 16; i++) { - SetBGPaletteBufferColorArray(240 + i, pal); - pal++; - } -} - -void sub_803E178(void) -{ - s32 val = GetFloorType(); - - if (val == 0) { - if (gDungeon->unk644.dungeonLocation.id == DUNGEON_METEOR_CAVE && !gDungeon->deoxysDefeat) { - gDungeon->unk3A12 = 28; - } - else { - gDungeon->unk3A12 = (IsStairDirectionUp(gDungeon->unk644.dungeonLocation.id) != FALSE) ? 23 : 22; - } - } - else if (val == 1) { - gDungeon->unk3A12 = 6; - } - else { - gDungeon->unk3A12 = 24; - } -} - -void sub_803E214(void) -{ - CloseFile(gUnknown_202EC94); - CloseFile(gUnknown_202EC98); - CloseFile(gUnknown_202EC9C); - CloseFile(gUnknown_202ECA0); -} - -void nullsub_56(void) -{ -} - -void sub_803E250(void) -{ - s32 i, j; - - gUnknown_202EDD0 = 999; - gUnknown_202EDD4 = 0; - gUnknown_203B40D = 0; - gUnknown_202EDE8.unk0 = 0; - - SpriteSetY(&gUnknown_202EDC0, 0); - SpriteSetAffine1(&gUnknown_202EDC0, 0); - SpriteSetAffine2(&gUnknown_202EDC0, 0); - SpriteSetObjMode(&gUnknown_202EDC0, 0); - SpriteSetMosaic(&gUnknown_202EDC0, 0); - SpriteSetBpp(&gUnknown_202EDC0, 0); - SpriteSetShape(&gUnknown_202EDC0, 0); - SpriteSetMatrixNum(&gUnknown_202EDC0, 0); - SpriteSetSize(&gUnknown_202EDC0, 1); - SpriteSetX(&gUnknown_202EDC0, 0); - SpriteSetTileNum(&gUnknown_202EDC0, 0); - SpriteSetPriority(&gUnknown_202EDC0, 0); - SpriteSetPalNum(&gUnknown_202EDC0, 0); - SpriteSetUnk6_0(&gUnknown_202EDC0, 0); - SpriteSetUnk6_1(&gUnknown_202EDC0, 0); - SpriteSetUnk6_2(&gUnknown_202EDC0, 0); - - SpriteSetY(&gUnknown_202EDB8, 0); - SpriteSetAffine1(&gUnknown_202EDB8, 0); - SpriteSetAffine2(&gUnknown_202EDB8, 0); - SpriteSetObjMode(&gUnknown_202EDB8, 0); - SpriteSetMosaic(&gUnknown_202EDB8, 0); - SpriteSetBpp(&gUnknown_202EDB8, 0); - SpriteSetShape(&gUnknown_202EDB8, 0); - SpriteSetMatrixNum(&gUnknown_202EDB8, 0); - SpriteSetSize(&gUnknown_202EDB8, 0); - SpriteSetX(&gUnknown_202EDB8, 0); - SpriteSetTileNum(&gUnknown_202EDB8, 0); - SpriteSetPriority(&gUnknown_202EDB8, 3); - SpriteSetPalNum(&gUnknown_202EDB8, 5); - SpriteSetUnk6_0(&gUnknown_202EDB8, 0); - SpriteSetUnk6_1(&gUnknown_202EDB8, 0); - SpriteSetUnk6_2(&gUnknown_202EDB8, 0); - - for (i = 0; i < 2; i++) { - for (j = 0; j < 6; j++) { - SpriteSetAffine1(&gUnknown_202ED28[i][j].sprite, 0); - SpriteSetAffine2(&gUnknown_202ED28[i][j].sprite, 0); - SpriteSetObjMode(&gUnknown_202ED28[i][j].sprite, 0); - SpriteSetMosaic(&gUnknown_202ED28[i][j].sprite, 0); - SpriteSetBpp(&gUnknown_202ED28[i][j].sprite, 0); - SpriteSetShape(&gUnknown_202ED28[i][j].sprite, gUnknown_80F621C[i][j].shape); - SpriteSetMatrixNum(&gUnknown_202ED28[i][j].sprite, 0); - SpriteSetSize(&gUnknown_202ED28[i][j].sprite, gUnknown_80F621C[i][j].size); - SpriteSetTileNum(&gUnknown_202ED28[i][j].sprite, gUnknown_80F621C[i][j].tileNum); - SpriteSetPriority(&gUnknown_202ED28[i][j].sprite, 3); - SpriteSetPalNum(&gUnknown_202ED28[i][j].sprite, 0); - SpriteSetUnk6_0(&gUnknown_202ED28[i][j].sprite, 0); - SpriteSetUnk6_1(&gUnknown_202ED28[i][j].sprite, 0); - - gUnknown_202ED28[i][j].pos = gUnknown_80F61EC[i][j]; - } - } - - gDungeon->unk181e8.unk18217 = 1; - gDungeon->unk181e8.unk18218 = 1; - gDungeonBrightness = 0; - SetBGPaletteBufferColorRGB(0xf8, &gFontPalette[8],0,NULL); -} diff --git a/src/code_803DA7C.c b/src/code_803DA7C.c new file mode 100644 index 000000000..643698d8c --- /dev/null +++ b/src/code_803DA7C.c @@ -0,0 +1,463 @@ +#include "global.h" +#include "constants/dungeon.h" +#include "structs/str_202ED28.h" +#include "structs/str_202EDE8.h" +#include "bg_palette_buffer.h" +#include "code_8009804.h" +#include "code_800D090.h" +#include "code_803D110.h" +#include "dungeon_vram.h" +#include "cpu.h" +#include "def_filearchives.h" +#include "dungeon.h" +#include "dungeon_random.h" +#include "file_system.h" +#include "game_options.h" +#include "pokemon.h" +#include "pokemon_3.h" +#include "text_1.h" +#include "text_3.h" +#include "dungeon_config.h" + +// File split could be wrong here. Todo. + +extern bool8 sub_80848EC(void); +extern u8 GetFloorType(void); +extern const u8 *GetDungeonName2(u8 dungeon); + +extern const char gUnknown_80F60F8[]; // "banrpal" +extern const char gUnknown_80F6100[]; // "banfont" +extern const char gUnknown_80F6108[]; +extern const char gUnknown_80F610C[]; +extern const char gUnknown_80F6110[]; +extern const char gUnknown_80F6118[]; +extern const u32 gUnknown_80F6120[]; + +EWRAM_DATA OpenedFile *gDungeonNameBannerPalette = NULL; +EWRAM_DATA OpenedFile *gDungeonNameBannerFontFile = NULL; +EWRAM_DATA s32 gDungeonNameBannerFont = 0; +EWRAM_DATA OpenedFile *gUnknown_202EC94 = NULL; +EWRAM_DATA OpenedFile *gUnknown_202EC98 = NULL; +EWRAM_DATA OpenedFile *gUnknown_202EC9C = NULL; +EWRAM_DATA OpenedFile *gUnknown_202ECA0 = NULL; + +// Very similar to unkChar struct +typedef struct UnkStruct_sub_803DC6C +{ + u8 *unk0; + u16 unk4; + u8 unk6; +} UnkStruct_sub_803DC6C; + +struct FileStruct2 +{ + s32 count; + u8 array[0]; +}; + +struct FileStruct +{ + struct FileStruct2 *ptr; + struct u8 *ptr2; +}; + +s32 sub_803DC14(const u8 *dungName, s32 strWidth, s32 a2); +s32 CalcStringWidth(const u8 *dungName); +s32 sub_803DC6C(u32 chr, s32 strWidth, s32 a2); +static UnkStruct_sub_803DC6C *sub_803DEC8(s32 chr); +void sub_803DD30(u8 *a0, u32 *a1); + +struct DungeonNameFontFileData +{ + /* 0x0 */ u8 unk0; + /* 0x4 */ s32 font; +}; + +struct DungeonNamePaletteFileData +{ + RGB pal[16]; +}; + +void ShowDungeonNameBanner_Async(void) +{ + u8 text[100]; + s32 var; + s32 i, r7; + const u8 *r6; + + gDungeonNameBannerPalette = OpenFileAndGetFileDataPtr(gUnknown_80F60F8, &gDungeonFileArchive); + gDungeonNameBannerFontFile = OpenFileAndGetFileDataPtr(gUnknown_80F6100, &gDungeonFileArchive); + gDungeonNameBannerFont = ((struct DungeonNameFontFileData *)(gDungeonNameBannerFontFile->data))->font; + for (i = 0; i < 16; i++) { + SetBGPaletteBufferColorArray(i + 224, &((struct DungeonNamePaletteFileData *)(gDungeonNameBannerPalette->data))->pal[i]); + } + CpuClear((void *)(VRAM + 0x140), 0x1C00); + if (sub_80848EC()) { + s32 r8 = gDungeon->unk644.dungeonLocation.floor + gDungeon->unk14; + const u8 *dungName = GetDungeonName2(gDungeon->unk644.dungeonLocation.id); + s32 r5 = 10; + + for (r7 = 0; r7 < 8; r7++) { + for (i = 0; i < 28; r5++) { + u16 a2; + + i++; + a2 = r5 | 0xE000; + sub_8008DC8(i, r7 + 4, r5 | a2, 0); + } + } + + var = sub_803DC14(dungName, (224 - CalcStringWidth(dungName)) / 2, 0); + if (IsStairDirectionUp(gDungeon->unk644.dungeonLocation.id)) + r6 = gUnknown_80F6108; + else + r6 = gUnknown_80F610C; + + if (r8 > 9) { + sprintfStatic(text, gUnknown_80F6110, r6, 48 + (r8 / 10), 48 + (r8 % 10)); + } + else { + sprintfStatic(text, gUnknown_80F6118, r6, 48 + r8); + } + + sub_803DC14(text, (224 - CalcStringWidth(text)) / 2, var + 32); + gUnknown_20274A5 = TRUE; + } + + CloseFile(gDungeonNameBannerFontFile); + DungeonRunFrameActions(2); +} + +s32 sub_803DC14(const u8 *dungName, s32 strWidth, s32 a2) +{ + while (*dungName != '\0') { + u32 currChar = *(dungName++); + if (currChar == '/') { + strWidth = 0; + a2 += 24; + } + else if (currChar == '#') { + strWidth += 8; + } + else if (currChar == ' ') { + strWidth += 12; + } + else { + if (currChar & 0x80 && *dungName != '\0') { + currChar = (currChar << 8) | *dungName; + dungName++; + } + strWidth += sub_803DC6C(currChar, strWidth, a2); + } + } + return a2; +} + +s32 sub_803DC6C(u32 chr, s32 strWidth, s32 a2) +{ + u32 *spPtr; + s32 i, j, a2DivMul; + u32 *vramPtr; + const u32 *constData; + u32 sp[72]; + s32 r9; + UnkStruct_sub_803DC6C *strPtr = sub_803DEC8(chr); + + sub_803DD30(strPtr->unk0, sp); + r9 = strPtr->unk6; + spPtr = sp; + + a2DivMul = ((a2 / 8) * 8); + vramPtr = (void *)(VRAM + 0x140 + (((a2DivMul - a2 / 8) * 4) + (strWidth / 8)) * 32); // Pixels? + vramPtr += a2 - a2DivMul; + constData = &gUnknown_80F6120[(strWidth - ((strWidth / 8) * 8)) * 4]; + for (i = 0; i < 24; i++) { + u32 *vramPtrLoop = vramPtr; + for (j = 0; j < 3; j++) { + // Sadly cannot match it without asm :/ + #ifdef NONMATCHING + u32 spVal = *spPtr; + #else + register u32 spVal asm("r2") = *spPtr; + #endif // NONMATCHING + + if (spVal != 0) { + *vramPtrLoop |= ((constData[0] & spVal) << constData[2]); + + vramPtrLoop += 8; + spVal &= constData[1]; + spVal >>= constData[3]; + *vramPtrLoop |= spVal; + vramPtrLoop -= 8; + } + spPtr++; + vramPtrLoop += 8; + } + + vramPtr++; + a2++; + + if (!(a2 & 7)) { + vramPtr += 216; + } + } + + return r9; +} + +void sub_803DD30(u8 *a0, u32 *a1) +{ + u8 sp[576]; + u8 sp575[576]; + s32 spId = 0; + s32 i, j = 0, k; + u32 currSp; + s32 r6; + + for (i = 0; i < 576; i += 2) { + sp[i] = (*a0 >> 4) & 0xF; + sp[i+1] = *a0 & 0xF; + a0++; + } + + while (j < 576) { + currSp = sp[spId++]; + r6 = currSp & 7; + if (currSp & 8) { + currSp = sp[spId++]; + for (k = 0; k < r6; k++) { + sp575[j] = currSp; + if (++j >= 576) + break; + } + } + else { + for (k = 0; k < r6; k++) { + currSp = sp[spId++]; + sp575[j] = currSp; + if (++j >= 576) + break; + } + } + if (j >= 576) + break; + } + + for (i = 0; i < 576; i += 8) { + u32 val = sp575[i + 7] << 0x1C; + val |= (sp575[i + 6] << 0x18) & 0xF000000; + val |= (sp575[i + 5] << 0x14) & 0xF00000; + val |= (sp575[i + 4] << 0x10) & 0xF0000; + val |= (sp575[i + 3] << 0xC) & 0xF000; + val |= (sp575[i + 2] << 0x8) & 0xF00; + val |= (sp575[i + 1] << 0x4) & 0xF0; + val |= (sp575[i]) & 0xF; + *(a1++) = val; + } +} + +// Could be a misnomer? +s32 CalcStringWidth(const u8 *dungName) +{ + s32 w = 0; + + while (*dungName != '\0') { + u32 currChar = *(dungName++); + if (currChar == '#') { + w += 8; + } + else if (currChar == ' ') { + w += 12; + } + else { + struct UnkStruct_sub_803DC6C *strPtr; + + if (currChar & 0x80 && *dungName != '\0') { + currChar = (currChar << 8) | *dungName; + dungName++; + } + strPtr = sub_803DEC8(currChar); + if (strPtr != NULL) { + w += strPtr->unk6; + } + } + } + + return w; +} + +static UnkStruct_sub_803DC6C *sub_803DEC8(s32 chr) +{ + s32 r2, r4; + UnkStruct_sub_803DC6C *ret; + UnkStruct_sub_803DC6C *strPtr = *((UnkStruct_sub_803DC6C **) gDungeonNameBannerFontFile->data); + // Fakematch? Or just magic numbers which will make more sense once this file is documented? + if (chr > 63487 && chr < 65535) + { + s32 r2 = chr & 0xFF; + s32 r1 = (chr & 0xFF00) >> 8; + r2 -= 32; + r1 -= 248; + ret = &strPtr[r1 * 224 + r2]; + } + else + { + r4 = 0; + r2 = gDungeonNameBannerFont - 1; + while (r4 < r2) { + s32 r1 = (r4 + r2) / 2; + if (strPtr[r1].unk4 == chr) { + r4 = r1; + break; + } + else if (strPtr[r1].unk4 < chr) { + r4 = r1 + 1; + } + else { + r2 = r1; + } + } + + ret = &strPtr[r4]; + if (ret->unk4 != chr) + ret = &strPtr[1]; + + + } + return ret; +}; + +EWRAM_DATA RGB gUnknown_202ECA4[33] = {0}; + +void sub_803DF60(void) +{ + u8 *vram; + s32 i; + const void *src; + OpenedFile *file; + + file = OpenFileAndGetFileDataPtr("itempat", &gDungeonFileArchive); + src = ((struct FileStruct *)(file->data))->ptr; + i = ((struct FileStruct2 *)(src))->count; + src = ((struct FileStruct2 *)(src))->array; + vram = OBJ_VRAM0 + 0x3400; + while (i != 0) + { + CpuCopy(vram, src, 0x20); + vram += 0x20; + src += 0x20; + i--; + } + CloseFile(file); + + file = OpenFileAndGetFileDataPtr("etcfont", &gDungeonFileArchive); + src = ((struct FileStruct2 *)(file->data)); + i = ((struct FileStruct2 *)(src))->count; + src = ((struct FileStruct2 *)(src))->array; + vram = OBJ_VRAM0 + 0x4000; + while (i != 0) + { + CpuCopy(vram, src, 0x20); + vram += 0x20; + src += 0x20; + i--; + } + CloseFile(file); + + gUnknown_202EC94 = OpenFileAndGetFileDataPtr("etcfonta", &gDungeonFileArchive); + gUnknown_202EC98 = OpenFileAndGetFileDataPtr("levfont", &gDungeonFileArchive); + gUnknown_202EC9C = OpenFileAndGetFileDataPtr("hp5font", &gDungeonFileArchive); + gUnknown_202ECA0 = OpenFileAndGetFileDataPtr("colvec", &gDungeonFileArchive); +} + +void sub_803E02C(void) +{ + u8 *vram; + s32 i, j, r6; + const void *src; + OpenedFile *file; + u8 fileName[12]; + + sub_803E13C(); + strcpy(fileName, "trappat"); + file = OpenFileAndGetFileDataPtr(fileName, &gDungeonFileArchive); + + src = ((struct FileStruct *)(file->data))->ptr; + i = ((struct FileStruct2 *)(src))->count; + src = ((struct FileStruct2 *)(src))->array; + vram = (void *) VRAM + 0xC000; + while (i != 0) + { + CpuCopy(vram, src, 0x20); + vram += 0x20; + src += 0x20; + i--; + } + CpuCopy(gUnknown_202ECA4, ((struct FileStruct *)(file->data))->ptr2, 0x80); + CloseFile(file); + + r6 = 0x200; + for (i = 0; i < UNK12A18_ARR_COUNT; i++) { + for (j = 0; j < UNK12A18_ARR_COUNT_2; j++) { + gDungeon->unk12A18[i][j] = (gUnknown_80F5F70[i] << 0xC) | r6; + r6++; + } + } + for (i = 0; i < 9; i++) { + gDungeon->unk13554[i] = 0xC000; + } + for (i = 0; i < COLOR_RAMP_COUNT; i++) { + gDungeon->colorRamp[i].r = i; + gDungeon->colorRamp[i].g = i; + gDungeon->colorRamp[i].b = i; + } +} + +void sub_803E13C(void) +{ + s32 i; + RGB *pal; + + SetWindowBGColor(); + if (gGameOptionsRef->playerGender != 0) + pal = &gFontPalette[16 * 4]; + else + pal = &gFontPalette[0]; + + for (i = 0; i < 16; i++) { + SetBGPaletteBufferColorArray(240 + i, pal); + pal++; + } +} + +void sub_803E178(void) +{ + s32 val = GetFloorType(); + + if (val == 0) { + if (gDungeon->unk644.dungeonLocation.id == DUNGEON_METEOR_CAVE && !gDungeon->deoxysDefeat) { + gDungeon->unk3A12 = 28; + } + else { + gDungeon->unk3A12 = (IsStairDirectionUp(gDungeon->unk644.dungeonLocation.id) != FALSE) ? 23 : 22; + } + } + else if (val == 1) { + gDungeon->unk3A12 = 6; + } + else { + gDungeon->unk3A12 = 24; + } +} + +void sub_803E214(void) +{ + CloseFile(gUnknown_202EC94); + CloseFile(gUnknown_202EC98); + CloseFile(gUnknown_202EC9C); + CloseFile(gUnknown_202ECA0); +} + +void nullsub_56(void) +{ +} diff --git a/src/code_803E46C.c b/src/code_803E46C.c deleted file mode 100644 index 3de72890d..000000000 --- a/src/code_803E46C.c +++ /dev/null @@ -1,240 +0,0 @@ -#include "global.h" -#include "structs/str_dungeon.h" -#include "bg_control.h" -#include "bg_palette_buffer.h" -#include "code_8004AA0.h" -#include "code_800558C.h" -#include "code_8009804.h" -#include "code_800C9CC.h" -#include "code_80118A4.h" -#include "code_803E46C.h" -#include "code_803E668.h" -#include "code_803E724.h" -#include "dungeon_map.h" -#include "dungeon_music.h" -#include "game_options.h" -#include "input.h" -#include "play_time.h" -#include "sprite.h" -#include "text_2.h" - -EWRAM_INIT u8 gUnknown_203B40C = 0; -EWRAM_INIT u8 gUnknown_203B40D = 0; - -extern s32 gDungeonBrightness; -extern s32 gDungeonFramesCounter; -extern u32 gUnknown_202EDD0; -extern s32 gUnknown_202EDD4; - -static void sub_803E490(u32); -void xxx_draw_string_80524F0(void); -void sub_8085F78(void); -void sub_803F580(s32); -void sub_806CC10(); -void sub_804522C(); -void sub_803F9CC(); -void sub_803ECE0(); -void sub_803EDF0(); -void sub_800E90C(); -void sub_8042E5C(); -void sub_800F7D0(DungeonPos *); -void sub_803E874(s32, s32); - -void DungeonRunFrameActions(u32 a0) -{ - if (gUnknown_203B40C != 0) - sub_803E490(a0); - else - sub_803E668(a0); -} - -static void sub_803E490(u32 unused) -{ - gUnknown_202EDD4++; - xxx_draw_string_80524F0(); - sub_8085F78(); - sub_803F580(1); - - if(gDungeon->unk181e8.unk1821A) - { - gDungeon->unk181e8.priority = 2; - SetBG2RegOffsets(gDungeon->unk181e8.cameraPixelPos.x, gDungeon->unk181e8.cameraPixelPos.y); - } - else - { - gDungeon->unk181e8.priority = 3; - SetBG2RegOffsets(0, 0); - } - SetBG3RegOffsets(gDungeon->unk181e8.cameraPixelPos.x, gDungeon->unk181e8.cameraPixelPos.y - gDungeon->unk181e8.unk181FC); - sub_806CC10(); - sub_804522C(); - sub_803F9CC(); - - sub_800F7D0(&gDungeon->unk181e8.cameraPixelPos); - - if(gDungeon->unk12 <= 0x63) - gDungeon->unk12++; - - sub_800E90C(&gDungeon->unk181e8.cameraPixelPos); - sub_8042E5C(); - - if(gUnknown_202EDD0 == 0 || gUnknown_202EDD0 == 3 || gGameOptionsRef->mapOption == TOP_MAP_AND_TEAM_NO_BOTTOM) - ShowPlayerDotOnMap(); - sub_803ECE0(); - sub_803EDF0(); - - - if(gDungeon->unk181e8.unk18215 != 0 && gDungeon->unk1BDD4.unk1C06C != 3) - sub_8004AF0(gUnknown_203B40D, gUnknown_202EE8C, 0xA0, 0x20, gDungeonBrightness, gDungeon->colorRamp); - - nullsub_8(gGameOptionsRef->unkA); - sub_8005180(); - nullsub_12(); - sub_80060EC(); - - gDungeonFramesCounter++; - - IncrementPlayTime(gPlayTimeRef); - WaitForNextFrameAndAdvanceRNG(); - LoadBufferedInputs(); - CopySpritesToOam(); - nullsub_13(); - sub_8005304(); - nullsub_14(); - - TransferBGPaletteBuffer(); - sub_8009908(); - xxx_call_update_bg_vram(); - CopyDungeonMapToVram(); - xxx_call_update_bg_sound_input(); - - gDungeon->unk181e8.unk18213 = 0; - UpdateDungeonMusic(); - sub_8011860(); - TryResetDungeonMapTilesScheduledForCopy(); - ResetSprites(FALSE); - nullsub_10(FALSE); - gUnknown_202EDD4--; -} - -void sub_803E668(u32 unused) -{ - gUnknown_202EDD4++; - nullsub_8(gGameOptionsRef->unkA); - sub_8005180(); - nullsub_12(); - sub_8005838(NULL, 0); - sub_80060EC(); - gDungeonFramesCounter++; - IncrementPlayTime(gPlayTimeRef); - WaitForNextFrameAndAdvanceRNG(); - LoadBufferedInputs(); - CopySpritesToOam(); - nullsub_13(); - sub_8005304(); - nullsub_14(); - TransferBGPaletteBuffer(); - sub_8009908(); - xxx_call_update_bg_vram(); - xxx_call_update_bg_sound_input(); - gDungeon->unk181e8.unk18213 = 0; - sub_8011860(); - ResetSprites(FALSE); - nullsub_10(FALSE); - gUnknown_202EDD4--; -} - -void sub_803E708(s32 numFrames, u32 a1) -{ - while (numFrames != 0) { - DungeonRunFrameActions(a1); - numFrames--; - } -} - -void sub_803E724(s32 r0) -{ - do - { - DungeonRunFrameActions(r0); - } while (gRealInputs.held & 0xF0); -} - -void sub_803E748(void) { - - s32 index1; - s32 index2; - - index2 = 0x1F; - gUnknown_203B40D = 1; - gDungeonBrightness = 0; - - sub_803E874(1, 0x1F); - - for(index1 = 0; index1 < 0x2C; index1++) - { - if(index1 < 0x20) - { - index2 -= 2; - if(index2 <= 0) - { - index2 = 0; - sub_803EAF0(1, NULL); - gDungeon->unk181e8.unk18217 = index2; - } - } - if(index1 > 0xB) - if(gDungeonBrightness <= 0x1E) - gDungeonBrightness++; - sub_803E874(1, index2); - DungeonRunFrameActions(5); - } - gUnknown_203B40D = 0; - gDungeonBrightness = 0x1F; -} - -void sub_803E7C8(void) -{ - - s32 index1; - s32 index2; - - index2 = 0x1F; - gUnknown_203B40D = 1; - gDungeonBrightness = 0; - - DungeonRunFrameActions(5); - - for(index1 = 0; index1 < 0x2C; index1++) - { - sub_803E874(1, index2); - if(index1 < 0x20) - { - index2 -= 2; - if(index2 <= 0) - { - index2 = 0; - sub_803EAF0(1, NULL); - gDungeon->unk181e8.unk18217 = index2; - } - } - DungeonRunFrameActions(5); - } - gUnknown_203B40D = 0; -} - -void sub_803E830(void) -{ - s32 index; - - gUnknown_203B40D = 1; - for(index = 0; index < 0x20; index++) - { - sub_803E874(0, 0); - DungeonRunFrameActions(5); - if(gDungeonBrightness > 0) - gDungeonBrightness--; - } - gDungeonBrightness = 0; - gUnknown_203B40D = 0; -} diff --git a/src/code_8040094.c b/src/code_8040094.c deleted file mode 100644 index d4712b484..000000000 --- a/src/code_8040094.c +++ /dev/null @@ -1,71 +0,0 @@ -#include "global.h" -#include "structs/dungeon_entity.h" -#include "structs/str_dungeon.h" -#include "code_800558C.h" -#include "code_800C9CC.h" -#include "code_80118A4.h" -#include "def_filearchives.h" -#include "dungeon_message.h" -#include "dungeon_map_access.h" -#include "dungeon_music.h" -#include "file_system.h" -#include "play_time.h" - -extern s32 gUnknown_80F6568[]; -extern const char gUnknown_80F6604; // "zmappat" - -extern void sub_803F7BC(void); - -extern void sub_803F580(u32); -extern void ShowWholeRevealedDungeonMap(); - -extern const char *gUnknown_80FD040; // It became brighter on the floor - -// Luminous Orb??? -void HandleLuminousOrbAction(Entity *pokemon) -{ - int XCoord; - int YCoord; - - gDungeon->unk181e8.allTilesRevealed = TRUE; - - for(YCoord = 0; YCoord < DUNGEON_MAX_SIZE_Y; YCoord++) - { - for(XCoord = 0; XCoord < DUNGEON_MAX_SIZE_X; XCoord++) - { - Tile *mapTile = GetTileMut(XCoord, YCoord); - mapTile->spawnOrVisibilityFlags |= VISIBILITY_FLAG_REVEALED; - } - } - sub_803F580(0); - sub_8049ED4(); - ShowWholeRevealedDungeonMap(); - LogMessageByIdWithPopupCheckUser(pokemon, gUnknown_80FD040); -} - -void sub_8040094(u8 r0) -{ - gDungeon->unk181e8.unk18217 = r0; - sub_803F7BC(); - sub_80060EC(); - IncrementPlayTime(gPlayTimeRef); - WaitForNextFrameAndAdvanceRNG(); - LoadBufferedInputs(); - xxx_call_update_bg_sound_input(); - UpdateDungeonMusic(); - sub_8011860(); -} - -void sub_80400D4(void) -{ - s32 temp; - temp = gDungeon->unk181e8.unk18200; - if(temp == 0) - return; - if(temp > 0x1E) - temp = 0x1F; - gDungeon->unk181e8.unk181FC = gUnknown_80F6568[temp]; - gDungeon->unk181e8.unk18200--; - if(gDungeon->unk181e8.unk18200 == 0) - gDungeon->unk181e8.unk18200 = gDungeon->unk181e8.unk18204; -} diff --git a/src/code_8040094_1.c b/src/code_8040094_1.c index ee8017efd..07efa330b 100644 --- a/src/code_8040094_1.c +++ b/src/code_8040094_1.c @@ -9,7 +9,7 @@ #include "code_8009804.h" #include "code_800E9E4.h" #include "code_800ED38.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "code_804267C.h" #include "dungeon.h" #include "dungeon_message.h" diff --git a/src/code_8041AD0.c b/src/code_8041AD0.c index 7241971f4..cb89cd754 100644 --- a/src/code_8041AD0.c +++ b/src/code_8041AD0.c @@ -10,7 +10,7 @@ #include "code_800DAC0.h" #include "code_800E9A8.h" #include "code_800ED38.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "code_803E724.h" #include "code_8041AD0.h" #include "code_804267C.h" @@ -216,7 +216,6 @@ s32 sub_8041550(Entity *entity, s32 a1, u8 a2, u8 a3, s32 a4, u8 a5) EntityInfo *entInfo; DungeonPos pos; unkStruct_80416E0 sp; - unkStruct_2039DB0 unkStruct; PixelPos pixelPos; s32 var; s32 r4; @@ -258,7 +257,7 @@ s32 sub_8041550(Entity *entity, s32 a1, u8 a2, u8 a3, s32 a4, u8 a5) sp.unk12 = 0; sp.unk18 = var; - sub_8004E8C(&unkStruct); + sub_8004E8C(&sp.unk1C); r4 = sub_8041764(&sp, FALSE); if (a2) { for (i = 0; i < 100; i++) { @@ -286,7 +285,6 @@ s32 sub_80416E0(PixelPos *pos, u32 param_2, bool8 param_3) int counter; s32 ret; unkStruct_80416E0 auStack_10; - unkStruct_2039DB0 stack1C; auStack_10.unk0 = param_2; auStack_10.unk4 = 0; @@ -299,7 +297,7 @@ s32 sub_80416E0(PixelPos *pos, u32 param_2, bool8 param_3) auStack_10.unk10 = 0; auStack_10.unk12 = 0; auStack_10.unk18 = 0xffff; - sub_8004E8C(&stack1C); + sub_8004E8C(&auStack_10.unk1C); ret = sub_8041764(&auStack_10, FALSE); if (param_3) { counter = 0; @@ -1227,7 +1225,6 @@ s32 sub_8042520(Entity *a0) u32 dir; s32 iVar8; unkStruct_80416E0 local_58; - unkStruct_2039DB0 u203; // Unused PixelPos local_2c; if (sub_8045888(a0)) { @@ -1245,7 +1242,7 @@ s32 sub_8042520(Entity *a0) local_58.unk12 = 0; local_58.unk14 = -1; local_58.unk18 = iVar8; - sub_8004E8C(&u203); + sub_8004E8C(&local_58.unk1C); uVar4 = sub_8041764(&local_58, 0); for (i = 0; i < 6; i++) { @@ -1568,7 +1565,6 @@ static const unkStruct_2039DB0 gUnknown_80F683C = {0xFFFF, 0xFFFF, 0xFFFF, 0, 0, void sub_8042B34(s32 a0, s32 a1, s32 a2) { unkStruct_80416E0 spStruct; - unkStruct_2039DB0 stack1C; s32 i; s32 r8 = 0; Entity *leader = xxx_call_GetLeader(); @@ -1598,7 +1594,7 @@ void sub_8042B34(s32 a0, s32 a1, s32 a2) spStruct.unk12 = gUnknown_203B414->unk8C[i].y; spStruct.unk14 = 4; spStruct.unk18 = 0xFFFF; - stack1C = gUnknown_80F683C; + spStruct.unk1C = gUnknown_80F683C; gUnknown_203B414->unkC[i] = sub_800E890(&spStruct); r8++; diff --git a/src/code_8066D04.c b/src/code_8066D04.c index b70ae2035..c3cf50ab5 100644 --- a/src/code_8066D04.c +++ b/src/code_8066D04.c @@ -3,15 +3,15 @@ #include "constants/dungeon.h" #include "constants/item.h" #include "constants/move_id.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "code_803E724.h" #include "code_8041AD0.h" -#include "code_8044CC8.h" +#include "dungeon_action.h" #include "code_8066D04.h" #include "code_806CD90.h" #include "code_8077274_1.h" #include "code_807CD9C.h" -#include "code_8084778.h" +#include "dungeon_jobs.h" #include "run_dungeon.h" #include "dungeon_items.h" #include "dungeon_leader.h" diff --git a/src/code_8069E0C.c b/src/code_8069E0C.c index 89e9395fa..cd2d8c685 100644 --- a/src/code_8069E0C.c +++ b/src/code_8069E0C.c @@ -10,7 +10,7 @@ #include "structs/str_806B7F8.h" #include "structs/str_dungeon.h" #include "code_800F958.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "code_803E668.h" #include "code_805D8C8.h" #include "code_806CD90.h" diff --git a/src/code_806CD90.c b/src/code_806CD90.c index 4db335dab..5d0bf7f19 100644 --- a/src/code_806CD90.c +++ b/src/code_806CD90.c @@ -7,7 +7,7 @@ #include "constants/dungeon.h" #include "constants/iq_skill.h" #include "structs/str_dungeon.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "code_803E668.h" #include "code_8041AD0.h" #include "code_804267C.h" diff --git a/src/code_8073CF0.c b/src/code_8073CF0.c index 9acd21354..925c1ab8f 100644 --- a/src/code_8073CF0.c +++ b/src/code_8073CF0.c @@ -10,7 +10,7 @@ #include "position_util.h" #include "dungeon_music.h" #include "dungeon_map_access.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "code_806CD90.h" #include "game_options.h" #include "dungeon_items.h" diff --git a/src/code_8075708.c b/src/code_8075708.c index 1fe0db762..edc24b360 100644 --- a/src/code_8075708.c +++ b/src/code_8075708.c @@ -23,7 +23,7 @@ #include "position_util.h" #include "dungeon_music.h" #include "dungeon_map_access.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "code_806CD90.h" #include "game_options.h" #include "dungeon_items.h" diff --git a/src/code_8077274_1.c b/src/code_8077274_1.c index 94d2cd4b0..c30b073b9 100644 --- a/src/code_8077274_1.c +++ b/src/code_8077274_1.c @@ -1,12 +1,12 @@ #include "global.h" #include "globaldata.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "dungeon_map_access.h" #include "dungeon_message.h" #include "code_805D8C8.h" #include "code_806CD90.h" #include "code_8077274_1.h" -#include "code_808417C.h" +#include "dungeon_random.h" #include "constants/ability.h" #include "constants/item.h" #include "constants/status.h" diff --git a/src/code_808333C.c b/src/code_808333C.c deleted file mode 100644 index c1978c7f7..000000000 --- a/src/code_808333C.c +++ /dev/null @@ -1,23 +0,0 @@ -#include "global.h" -#include "structs/str_dungeon.h" -#include "structs/str_202ED28.h" -#include "sprite.h" - -bool8 sub_8083568(s32 inX, s32 inY, u8 index) -{ - s32 x = inX - gDungeon->unk181e8.cameraPixelPos.x; - s32 y = inY - gDungeon->unk181e8.cameraPixelPos.y; - - if (x >= -16 && y >= -16 && x <= 255 && y <= 175) - { - SpriteSetX(&gUnknown_202ED28[0][index].sprite, x + gUnknown_202ED28[0][index].pos.x); - SpriteSetY(&gUnknown_202ED28[0][index].sprite, y + gUnknown_202ED28[0][index].pos.y); - - AddSprite(&gUnknown_202ED28[0][index].sprite, 0, NULL, NULL); - return TRUE; - } - else - { - return FALSE; - } -} diff --git a/src/code_808417C.c b/src/code_808417C.c deleted file mode 100644 index 78ce3099a..000000000 --- a/src/code_808417C.c +++ /dev/null @@ -1,26 +0,0 @@ -#include "global.h" -#include "constants/ability.h" -#include "constants/iq_skill.h" -#include "structs/dungeon_entity.h" -#include "dungeon_logic.h" -#include "dungeon_random.h" -#include "dungeon_util.h" - -s32 CalculateStatusTurns(Entity *target, s16 *turnRange, bool8 factorCurerSkills) -{ - s32 numTurns; - - numTurns = DungeonRandRange(turnRange[0],turnRange[1]); - if (EntityIsValid(target) && (GetEntityType(target) == ENTITY_MONSTER) && (factorCurerSkills)) { - if (IQSkillIsEnabled(target, IQ_SELF_CURER) && (numTurns != 0x7f)) { - numTurns /= 2; - } - if (AbilityIsActive(target, ABILITY_NATURAL_CURE) && (numTurns != 0x7f) && (4 < numTurns)) { - numTurns = 5; - } - } - if (numTurns < 1) { - numTurns = 1; - } - return numTurns; -} diff --git a/src/code_8084778.c b/src/code_8084778.c deleted file mode 100644 index 1941474cd..000000000 --- a/src/code_8084778.c +++ /dev/null @@ -1,25 +0,0 @@ -#include "global.h" -#include "code_8084778.h" -#include "string_format.h" -#include "code_80958E8.h" -#include "mailbox.h" -#include "pokemon_mid.h" -#include "structs/str_dungeon.h" - -extern const u8 gUnknown_8107224[]; - -void sub_8084778(void) -{ - s32 i; - WonderMail *wm; - - strcpy(gFormatBuffer_Monsters[3], gUnknown_8107224); - - for (i = 0; i < MAX_ACCEPTED_JOBS; i++) { - wm = GetJobSlotInfo(i); - if (wm->mailType == MAIL_TYPE_TAKEN_JOB && gDungeon->unk644.dungeonLocation.id == wm->unk4.dungeon.id && wm->missionType == WONDER_MAIL_MISSION_TYPE_ESCORT_CLIENT) { - CopyCyanMonsterNametoBuffer(gFormatBuffer_Monsters[3], wm->targetSpecies); - break; - } - } -} diff --git a/src/code_80848F0.c b/src/code_80848F0.c index c9b47a2b3..404f3fa8e 100644 --- a/src/code_80848F0.c +++ b/src/code_80848F0.c @@ -1,7 +1,12 @@ #include "global.h" +#include "globaldata.h" #include "constants/weather.h" #include "constants/dungeon.h" +#include "constants/direction.h" +#include "constants/dungeon.h" #include "structs/str_dungeon.h" +#include "structs/str_806B7F8.h" +#include "structs/sprite_oam.h" #include "dungeon_cutscenes.h" #include "dungeon_music.h" #include "dungeon_logic.h" @@ -11,19 +16,119 @@ #include "pokemon.h" #include "dungeon_util.h" #include "dungeon_map_access.h" -#include "structs/str_806B7F8.h" +#include "dungeon_misc.h" +#include "dungeon_vram.h" +#include "code_803E668.h" +#include "code_806CD90.h" +#include "code_80861A8.h" +#include "code_8085E98.h" +#include "dungeon_leader.h" +#include "random.h" +#include "math.h" +#include "code_8004AA0.h" +#include "bg_palette_buffer.h" +#include "code_800E9A8.h" +#include "items.h" +#include "code_800DAC0.h" +#include "code_800ED38.h" +#include "sprite.h" +#include "code_800E9E4.h" +#include "code_80869E4.h" +#include "pokemon_3.h" +#include "dungeon_boss_dialogue.h" +struct RgbS16 +{ + s16 r; + s16 g; + s16 b; +}; + +extern OpenedFile *gDungeonPaletteFile; +extern s32 gDungeonBrightness; +extern RGB gUnknown_202ECA4[]; + +extern const u8 gUnknown_8107358[25]; extern const DungeonPos gUnknown_80F4598[]; + +extern bool8 sub_8004C00(unkStruct_202EE8C *a0, s32 a1, s32 a2, s32 brightness, const RGB *ramp, struct RgbS16 *a5); extern void ShowWholeRevealedDungeonMap(void); +extern s32 GetCameraXPos(void); +extern s32 GetCameraYPos(void); +extern void sub_803F4A0(u32); +extern void sub_803F878(s32, s32); +extern void sub_8085F44(s32); +extern bool8 sub_800E90C(DungeonPos *); +extern void sub_8088EE8(void); +extern void sub_8088848(void); +extern void sub_808A718(void); +extern s32 sub_800E700(s32); +extern void sub_8085F44(s32); +extern void sub_8052FB8(const u8 *); +extern void BgColorCallNullsub4(void); +extern void PlaySoundEffect(u32); +extern u8 sub_8044B28(void); +extern void sub_8085EB0(void); +extern void sub_803E748(void); +extern s32 GetCameraXPos(void); +extern s32 GetCameraYPos(void); +extern void sub_8086A54(Entity *); +extern void sub_8086A3C(Entity *); +extern void PlaySoundEffect(u32); +extern u32 sub_8002A70(u32, s32, u8); +extern s8 sub_8002984(s8, u8); struct unkData_8107234 { - u8 unk0[8]; + u8 unk0; + u8 unk1; + u8 unk2; + u8 unk3; + u8 unk4; + u8 unk5; }; -extern struct unkData_8107234 gUnknown_8107234[]; +static void sub_8084854(const struct unkData_8107234 *); +static void sub_80861EC(Entity *); -void sub_8084854(struct unkData_8107234 *); +static const struct unkData_8107234 gUnknown_8107234[28] = { + [0] = {1, 1, 0, 2, 1, 3}, + [1] = {2, 4, 2, 5, 3, 6}, + [2] = {3, 7, 4, 8, 5, 9}, + [3] = {4, 0xA, 6, 0xB, 7, 0xC}, + [4] = {5, 0xD, 8, 0xE, 9, 0xF}, + [5] = {6, 0x10, 0xA, 0x11, 0xA, 0x11}, + [6] = {7, 0x12, 0xB, 0x13, 0xC, 0x14}, + [7] = {0x14, 0x15, 0xD, 0x16, 0xD, 0x16}, + [8] = {8, 0x17, 0xE, 0x18, 0xF, 0x19}, + [9] = {0xB, 0x1A, 0x10, 0x1B, 0x11, 0x1C}, + [10] = {9, 0x1D, 0x12, 0x1E, 0x13, 0x1F}, + [11] = {0xC, 0x20, 0x14, 0x21, 0x15, 0x22}, + [12] = {0xD, 0x23, 0x16, 0x24, 0x17, 0x25}, + [13] = {0xE, 0x26, 0x18, 0x27, 0x19, 0x28}, + [14] = {0xF, 0x29, 0x40, 0x29, 0x1A, 0x2A}, + [15] = {0x10, 0x2B, 0x1B, 0x2C, 0x1C, 0x2D}, + [16] = {0x11, 0x2E, 0x40, 0x2E, 0x40, 0x2E}, + [17] = {0x12, 0x2F, 0x40, 0x2F, 0x40, 0x2F}, + [18] = {0x13, 0x30, 0x40, 0x30, 0x40, 0x30}, + [19] = {0xA, 0x31, 0x40, 0x31, 0x1E, 0x32}, + [20] = {0x15, 0x33, 0x40, 0x33, 0x40, 0x33}, + [21] = {0x16, 0x34, 0x40, 0x34, 0x40, 0x34}, + [22] = {0x17, 0x35, 0x40, 0x35, 0x40, 0x35}, + [23] = {0x19, 0x36, 0x40, 0x36, 0x40, 0x36}, + [24] = {0x1B, 0x37, 0x40, 0x37, 0x40, 0x37}, + [25] = {0x1A, 0x38, 0x20, 0x39, 0x20, 0x39}, + [26] = {0x18, 0x3A, 0x21, 0x3B, 0x21, 0x3B}, + [27] = {0}, +}; + +static const s32 gUnknown_8107314[] = { + 0, -1, 1, -2, 2, -3, 3, -4, + 4, -4, 4, -4, 4, -4, 4, -4, + 4 +}; + +EWRAM_DATA static unkStruct_202F3D0 gUnknown_202F3D0 = {0}; void sub_80847D4(void) { @@ -33,12 +138,12 @@ void sub_80847D4(void) gDungeon->unk3A0D = 0; gDungeon->unk1356C = 0; ShowWholeRevealedDungeonMap(); - for(index = 0; index < 0x3e7 && gUnknown_8107234[index].unk0[0] != 0; index++) { + for(index = 0; index < 0x3e7 && gUnknown_8107234[index].unk0 != 0; index++) { fixedRoomNumber = gDungeon->fixedRoomNumber; if (fixedRoomNumber - 0x1c < 0x16) { fixedRoomNumber = 0x1b; } - if (fixedRoomNumber == gUnknown_8107234[index].unk0[0]) + if (fixedRoomNumber == gUnknown_8107234[index].unk0) { sub_8084854(&gUnknown_8107234[index]); break; @@ -47,32 +152,26 @@ void sub_80847D4(void) sub_8097FF8(); } -void sub_8084854(struct unkData_8107234 *param_1) +void sub_8084854(const struct unkData_8107234 *param_1) { - if (gDungeon->unk644.unk34 != 0) { - gDungeon->unk3A0D = param_1->unk0[5]; - } - else - { - if (sub_8098100(param_1->unk0[4]) != 0) { - gDungeon->unk3A0D = param_1->unk0[5]; + if (gDungeon->unk644.unk34 != 0) { + gDungeon->unk3A0D = param_1->unk5; } - else - { - if (sub_8098100(param_1->unk0[2]) != 0) { - gDungeon->unk3A0D = param_1->unk0[3]; - } - else - { - gDungeon->unk3A0D = param_1->unk0[1]; - if (param_1->unk0[2] != 0x40) { - sub_8097FA8(param_1->unk0[2]); + else if (sub_8098100(param_1->unk4) != 0) { + gDungeon->unk3A0D = param_1->unk5; + } + else if (sub_8098100(param_1->unk2) != 0) { + gDungeon->unk3A0D = param_1->unk3; + } + else { + gDungeon->unk3A0D = param_1->unk1; + if (param_1->unk2 != 0x40) { + sub_8097FA8(param_1->unk2); } - } } - } - gDungeon->unk644.unk31 = 1; - sub_807E5E4(WEATHER_CLEAR); + + gDungeon->unk644.unk31 = 1; + sub_807E5E4(WEATHER_CLEAR); } u32 sub_80848EC(void) @@ -694,3 +793,1224 @@ void sub_8085374(void) j++; } } + +Entity *xxx_call_GetLeader(void) +{ + return GetLeader(); +} + +Entity *GetPartnerEntity(void) +{ + s32 counter; + Entity *entity; + for(counter = 0; counter < MAX_TEAM_MEMBERS; counter++) + { + entity = gDungeon->teamPokemon[counter]; + if(EntityIsValid(entity) && GetEntInfo(entity)->joinedAt.id == DUNGEON_JOIN_LOCATION_PARTNER) + { + return entity; + } + } + return GetEntityFromMonsterBehavior(BEHAVIOR_ALLY); +} + +void sub_80854D4(void) +{ + Entity *stack1[MAX_TEAM_MEMBERS]; + Entity *stack2[MAX_TEAM_MEMBERS]; + s32 counter = 0; + s32 index; + Entity *entity; + Entity *entity2; + Entity *entity3; + Entity *entity4; + Entity *entity5; + + for(index = 0; index < MAX_TEAM_MEMBERS; index++) + { + entity = gDungeon->teamPokemon[index]; + if(EntityIsValid(entity)) + { + stack1[counter] = entity; + counter++; + } + } + for(; counter < MAX_TEAM_MEMBERS; counter++) + { + stack1[counter] = NULL; + } + counter = 0; + for(index = 0; index < MAX_TEAM_MEMBERS; index++) + { + entity2 = stack1[index]; + if(entity2 != NULL && GetEntInfo(entity2)->isTeamLeader) + { + stack1[index] = NULL; + stack2[counter] = entity2; + counter++; + } + } + for(index = 0; index < MAX_TEAM_MEMBERS; index++) + { + entity3 = stack1[index]; + if(entity3 != NULL && GetEntInfo(entity3)->joinedAt.id == DUNGEON_JOIN_LOCATION_PARTNER) + { + stack1[index] = NULL; + stack2[counter] = entity3; + counter++; + } + } + for(index = 0; index < MAX_TEAM_MEMBERS; index++) + { + entity4 = stack1[index]; + if(entity4 != NULL) + { + stack1[index] = NULL; + stack2[counter] = entity4; + counter++; + } + } + for(; counter < MAX_TEAM_MEMBERS; counter++) + { + stack2[counter] = NULL; + } + for(index = 0; index < MAX_TEAM_MEMBERS; index++) + { + entity5 = stack2[index]; + if(entity5 != NULL) + sub_80856C8(entity5, gDungeon->unkE220[index].x, gDungeon->unkE220[index].y); + } +} + +void sub_80855E4(DungeonCallback func) +{ + bool8 flag; + Entity * entity; + Entity * partnerEntity; + s32 index; + + flag = FALSE; + for(index = 0; index < MAX_TEAM_MEMBERS; index++) + { + entity = gDungeon->teamPokemon[index]; + if (EntityIsValid(entity)) { + if (GetEntInfo(entity)->joinedAt.id == DUNGEON_JOIN_LOCATION_PARTNER) { + flag = TRUE; + } + func(entity); + } + } + if ((!flag) && (partnerEntity = GetPartnerEntity(), partnerEntity != NULL)) { + func(partnerEntity); + } +} + +void sub_808563C(DungeonCallback func) +{ + Entity * entity; + s32 index; + + for(index = 0; index < DUNGEON_MAX_WILD_POKEMON; index++) + { + entity = gDungeon->wildPokemon[index]; + if ((EntityIsValid(entity)) && (GetEntInfo(entity)->joinedAt.id != 0x41)) { + func(entity); + } + } +} + +Entity *GetEntityFromMonsterBehavior(u8 entityType) +{ + Entity * entity; + s32 index; + + for(index = 0; index < DUNGEON_MAX_POKEMON; index++) + { + entity = gDungeon->activePokemon[index]; + if ((EntityIsValid(entity)) && (GetEntInfo(entity)->monsterBehavior == entityType)) return entity; + } + return NULL; +} + +void sub_80856C8(Entity * pokemon, s32 x, s32 y) +{ + sub_80694C0(pokemon, x, y, 1); + sub_804535C(pokemon,NULL); +} + +void sub_80856E0(Entity * pokemon, s32 direction) +{ + EntityInfo *entityInfo; + s32 counter; + + entityInfo = GetEntInfo(pokemon); + sub_80861D4(pokemon, 6, direction); + + for(counter = 0; counter < 5; counter++) + { + entityInfo->unk174 = F248_Add(entityInfo->unk174, IntToF248(2)); + DungeonRunFrameActions(0x46); + } + entityInfo->action.direction = direction & DIRECTION_MASK; + sub_806CE68(pokemon, direction); + + for(counter = 0; counter < 5; counter++) + { + entityInfo->unk174 = F248_Sub(entityInfo->unk174, IntToF248(2)); + DungeonRunFrameActions(0x46); + } + entityInfo->unk174.raw = 0; // weird one that doesn't match with struct assignment + DungeonRunFrameActions(0x46); +} + +void sub_8085764(void) +{ + Entity *entity; + s32 index; + Entity stackEntity; + + sub_80457DC(&stackEntity); + for(index = 0; index < DUNGEON_MAX_WILD_POKEMON; index++) + { + entity = gDungeon->wildPokemon[index]; + if ((EntityIsValid(entity)) && (GetEntInfo(entity)->monsterBehavior == BEHAVIOR_ALLY)) { + sub_8068FE0(entity,0x207,&stackEntity); + } + } +} + +void sub_80857B8(void) +{ + u8 *direction; + EntityInfo *entityInfo; + Entity *entity; + int index; + + for(index = 0; index < DUNGEON_MAX_POKEMON; index++) + { + entity = gDungeon->activePokemon[index]; + if (EntityIsValid(entity)) { + entityInfo = GetEntInfo(entity); + if ((gDungeon->unk4 == 0) && (gDungeon->unk2 == 0)) { + sub_804535C(entity, 0); + entityInfo->unk15C = 0; + entityInfo->unkFE = 99; + direction = &entityInfo->action.direction; + entityInfo->targetPos.x = gAdjacentTileOffsets[*direction].x + entity->pos.x; + entityInfo->targetPos.y = gAdjacentTileOffsets[*direction].y + entity->pos.y; + sub_806CE68(entity,*direction); + } + } + } +} + +void sub_8085860(s32 x, s32 y) +{ + sub_803F4A0(0); + sub_803F878(X_POS_TO_PIXELPOS(x), Y_POS_TO_PIXELPOS(y)); +} + +UNUSED static void sub_8085890(s32 x, s32 y) +{ + sub_803F4A0(0); + sub_803F878(x, y); +} + +void ShiftCameraToPosition(PixelPos *posStruct, s32 cameraSteps) +{ + s32 XPos; + s32 YPos; + s32 XIncrement; + s32 YIncrement; + + XPos = GetCameraXPos(); + YPos = GetCameraYPos(); + XIncrement = (posStruct->x - XPos) / cameraSteps; + YIncrement = (posStruct->y - YPos) / cameraSteps; + sub_803F4A0(0); + if (0 < cameraSteps) { + do { + XPos += XIncrement; + YPos += YIncrement; + sub_803F878(XPos,YPos); + DungeonRunFrameActions(0x46); + cameraSteps--; + } while (cameraSteps != 0); + } + sub_803F878(posStruct->x,posStruct->y); + DungeonRunFrameActions(0x46); +} + +void SetFacingDirection(Entity *pokemon, s32 direction) +{ + GetEntInfo(pokemon)->action.direction = direction & DIRECTION_MASK; + sub_806CE68(pokemon, direction); +} + +void sub_8085930(s32 direction) +{ + s32 index; + Entity *entity; + for(index = 0; index < MAX_TEAM_MEMBERS; index++) + { + entity = gDungeon->teamPokemon[index]; + if(EntityIsValid(entity)) + { + if(direction >= NUM_DIRECTIONS) + { + sub_806CE68(entity, RandInt(NUM_DIRECTIONS)); + } + else + { + GetEntInfo(entity)->action.direction = direction & DIRECTION_MASK; + sub_806CE68(entity, direction); + } + } + } + for(index = 0; index < DUNGEON_MAX_WILD_POKEMON; index++) + { + entity = gDungeon->wildPokemon[index]; + if(EntityIsValid(entity)) + { + if(GetEntInfo(entity)->monsterBehavior == BEHAVIOR_ALLY) + { + if(direction >= NUM_DIRECTIONS) + { + sub_806CE68(entity, RandInt(NUM_DIRECTIONS)); + } + else + { + GetEntInfo(entity)->action.direction = direction & DIRECTION_MASK; + sub_806CE68(entity, direction); + } + } + } + } +} + +void sub_80859F0(s32 direction) +{ + s32 index; + Entity *entity; + for(index = 0; index < DUNGEON_MAX_WILD_POKEMON; index++) + { + entity = gDungeon->wildPokemon[index]; + if(EntityIsValid(entity)) + { + if(direction >= NUM_DIRECTIONS) + { + sub_806CE68(entity, RandInt(NUM_DIRECTIONS)); + } + else + { + GetEntInfo(entity)->action.direction = direction & DIRECTION_MASK; + sub_806CE68(entity, direction); + } + } + } +} + +bool8 ShouldRunMonsterAI(Entity *pokemon) +{ + EntityInfo *pokemonInfo = GetEntInfo(pokemon); + switch (pokemonInfo->monsterBehavior) + { + case BEHAVIOR_RESCUE_TARGET: + case BEHAVIOR_SKARMORY: + case BEHAVIOR_GENGAR: + case BEHAVIOR_EKANS: + case BEHAVIOR_MEDICHAM: + case BEHAVIOR_ZAPDOS: + case BEHAVIOR_MOLTRES: + case BEHAVIOR_ARTICUNO: + case BEHAVIOR_GROUDON_2: + case BEHAVIOR_RAYQUAZA: + case BEHAVIOR_MANKEY: + case BEHAVIOR_MEWTWO: + case BEHAVIOR_ENTEI: + case BEHAVIOR_RAIKOU: + case BEHAVIOR_SUICUNE: + case BEHAVIOR_HO_OH: + case BEHAVIOR_LATIOS: + case BEHAVIOR_REGIROCK: + case BEHAVIOR_REGICE: + case BEHAVIOR_REGISTEEL: + case BEHAVIOR_JIRACHI: + case BEHAVIOR_LUGIA: + case BEHAVIOR_KYOGRE: + case BEHAVIOR_29: + case BEHAVIOR_CELEBI: + case BEHAVIOR_SMEARGLE: + case BEHAVIOR_32: + case BEHAVIOR_33: + case BEHAVIOR_34: + case BEHAVIOR_35: + case BEHAVIOR_MAZE_BOSS: + return TRUE; + case BEHAVIOR_FIXED_ENEMY: + case BEHAVIOR_ALLY: + case BEHAVIOR_DIGLETT: + case BEHAVIOR_ALAKAZAM_1: + case BEHAVIOR_GROUDON_1: + case BEHAVIOR_ALAKAZAM_2: + default: + return FALSE; + } +} + +UNUSED static void sub_8085B0C(Entity *pokemon) +{ + s32 index = 0; + u8 local_28[] = {4, 3, 2, 3, 4, 5, 6, 5, 4, 3, 2, 3, 4, 5, 6, 5, 4, 4, 4, 4, 4, 4, 5, 6, 0}; + + while (local_28[index] != 0) { + SetFacingDirection(pokemon, local_28[index]); + sub_803E708(6,0x46); + index++; + } +} + +static EWRAM_DATA s32 gUnknown_202F3D8 = 0; + +void sub_8085B4C(struct_8085B80 a0[], s16 *a1[], Entity *a2[], s32 a3) +{ + s32 i; + + gUnknown_202F3D8 = a3; + + for (i = 0; i < a3; i++) { + a0[i].unk0 = 1; + a0[i].unk4 = a2[i]; + a0[i].unkC = a1[i]; + a0[i].unk8 = a1[i][2]; + } +} + +bool8 sub_8085B80(struct_8085B80 *a0) +{ + s16 *unkCPtr; + int i; + bool8 ret = FALSE; + + for (i = 0; i < gUnknown_202F3D8; i++) { + Entity *entity = a0[i].unk4; + EntityInfo *enInfo = GetEntInfo(entity); + unkCPtr = a0[i].unkC; + if (a0[i].unk0 != 0) { + ret = TRUE; + if (a0[i].unk8 == 0) { + unkCPtr = unkCPtr + 4; + if (unkCPtr[2] == 0) { + a0[i].unk0 = 0; + enInfo->action.direction = unkCPtr[0] & DIRECTION_MASK; + sub_806CDD4(entity, 7, unkCPtr[0]); + sub_80856C8(entity, unkCPtr[5], unkCPtr[6]); + continue; + } + a0[i].unk8 = unkCPtr[2]; + a0[i].unkC = unkCPtr; + enInfo->action.direction = unkCPtr[0] & DIRECTION_MASK; + sub_806CDD4(entity, 0, (int)*unkCPtr); + } + + a0[i].unk8--; + IncreaseEntityPixelPos(entity, + gAdjacentTileOffsets[*unkCPtr].x * unkCPtr[1] * 0x100, + gAdjacentTileOffsets[*unkCPtr].y * unkCPtr[1] * 0x100); + } + } + return ret; +} + +void SetDungeonBGColorRGB(s32 r, s32 g, s32 b, bool8 a3, bool8 a4) +{ + s32 i, palIndex, n; + const RGB *colorPtr; + RGB color; + struct RgbS16 colorS16; + + n = 160; + sub_8085E98(); + palIndex = 0; + colorPtr = gDungeonPaletteFile->data; + if (a4) { + if (r >= 0) { r /= 2; } + if (g >= 0) { g /= 2; } + if (b >= 0) { b /= 2; } + } + + color.r = 0; + color.g = 0; + color.b = 0; + SetBGPaletteBufferColorRGB(palIndex, &color, gDungeonBrightness, gDungeon->colorRamp); + colorPtr++; + palIndex++; + + for (i = 1; i < n; i++) { + s32 newR = colorPtr->r + r; + s32 newG = colorPtr->g + g; + s32 newB = colorPtr->b + b; + + if (newR > 0xFF) { newR = 0xFF; } + if (newG > 0xFF) { newG = 0xFF; } + if (newB > 0xFF) { newB = 0xFF; } + + if (newR < 0) { newR = 0; } + if (newG < 0) { newG = 0; } + if (newB < 0) { newB = 0; } + + color.r = newR; + color.g = newG; + color.b = newB; + SetBGPaletteBufferColorRGB(palIndex, &color, gDungeonBrightness, gDungeon->colorRamp); + colorPtr++; + palIndex++; + } + + colorS16.r = r; + colorS16.g = g; + colorS16.b = b; + sub_8004C00(gUnknown_202EE8C, 160, 32, gDungeonBrightness, gDungeon->colorRamp, &colorS16); + palIndex += 32; + + colorPtr = gUnknown_202ECA4; + n = 32; + for (i = 0; i < n; i++) { + s32 newR = colorPtr->r + r; + s32 newG = colorPtr->g + g; + s32 newB = colorPtr->b + b; + + if (newR > 0xFF) { newR = 0xFF; } + if (newG > 0xFF) { newG = 0xFF; } + if (newB > 0xFF) { newB = 0xFF; } + + if (newR < 0) { newR = 0; } + if (newG < 0) { newG = 0; } + if (newB < 0) { newB = 0; } + + color.r = newR; + color.g = newG; + color.b = newB; + SetBGPaletteBufferColorRGB(palIndex, &color, gDungeonBrightness, gDungeon->colorRamp); + colorPtr++; + palIndex++; + } + + if (a3) { + colorPtr = gDungeon->paletFile->data; + palIndex = 256; + n = 208; + for (i = 0; i < n; i++) { + s32 newR = colorPtr->r + r; + s32 newG = colorPtr->g + g; + s32 newB = colorPtr->b + b; + + if (newR > 0xFF) { newR = 0xFF; } + if (newG > 0xFF) { newG = 0xFF; } + if (newB > 0xFF) { newB = 0xFF; } + + if (newR < 0) { newR = 0; } + if (newG < 0) { newG = 0; } + if (newB < 0) { newB = 0; } + + color.r = newR; + color.g = newG; + color.b = newB; + SetBGPaletteBufferColorRGB(palIndex, &color, gDungeonBrightness, NULL); + colorPtr++; + palIndex++; + } + } +} + +void sub_8085E98(void) +{ + gDungeon->unk181e8.unk18215 = 0; +} + +void sub_8085EB0(void) +{ + gDungeon->unk181e8.unk18215 = 1; +} + +u32 sub_8085EC8(s16 param_1,u32 param_2,u32 param_3,DungeonPos *param_4, bool32 param_5) +{ + u32 uVar1; + unkStruct_80416E0 local_40; + + bool8 param_5_bool8; + s32 param_1_s32 = param_1; + + + param_5_bool8 = param_5; + + sub_800EE5C(param_1_s32); + sub_800EF64(); + DungeonRunFrameActions(0x46); + local_40.unk0 = param_1; + local_40.unk4 = param_2; + local_40.dir = param_3; + local_40.x = param_4->x; + local_40.y = param_4->y; + local_40.unk10 = 0; + local_40.unk12 = 0; + local_40.unk18 = 0xffff; + local_40.unk1C = (unkStruct_2039DB0) {0xFFFF, 0xFFFF, 0xFFFF, 0, 0, 0}; + + uVar1 = sub_800E890(&local_40); + if (param_5_bool8) { + sub_8085F44(uVar1); + uVar1 = -1; + } + return uVar1; +} + +void sub_8085F44(s32 param_1) +{ + while (sub_800E9A8(param_1)) { + sub_800E90C(&gDungeon->unk181e8.cameraPixelPos); + DungeonRunFrameActions(0x46); + } +} + +void sub_8085F78(void) +{ + switch(gDungeon->unk3A0D) { + case 0x12: + case 0x13: + case 0x14: + sub_8088848(); + break; + case 0x15: + sub_8088EE8(); + break; + case 0x29: + case 0x2A: + sub_808A718(); + break; + + case 0: + case 0x3C: + default: + break; + } +} + +bool8 sub_80860A8(u8 id) +{ + Item *item; + EntityInfo *info; + Entity *entity; + int index; + + + for(index = 0; index < INVENTORY_SIZE; index++) + { + item = &gTeamInventoryRef->teamItems[index]; + if((item->flags & 1) != 0) + { + if((item->id) == id) return TRUE; + } + } + + for(index = 0; index < MAX_TEAM_MEMBERS; index++) + { + entity = gDungeon->teamPokemon[index]; + if (((EntityIsValid(entity)) && (info = GetEntInfo(entity), ((info->heldItem).flags & 1))) && ((info->heldItem).id == id)) return TRUE; + } + return FALSE; +} + +UNUSED static void sub_8086124(Entity *entity, u8 param_2) +{ + GetEntInfo(entity)->unk160 = param_2; +} + +void sub_8086130(void) +{ + DungeonFadeOutBGM(0x3c); + sub_803E708(0x3c,0x46); + sub_8052FB8(gUnknown_810665C); + sub_803E708(0x1e,0x46); + sub_8052FB8(gUnknown_810668C); + sub_803E708(0x1e,0x46); + sub_8052FB8(gUnknown_81066D4); + sub_803E708(0x1e,0x46); + sub_8052FB8(gUnknown_81066F0); + sub_803E708(0x1e,0x46); + sub_8052FB8(gUnknown_810671C); + sub_803E708(0x1e,0x46); +} + +void sub_80861A8(Entity *a0) +{ + sub_806CDD4(a0, 0, NUM_DIRECTIONS); +} + +void sub_80861B8(Entity *a0, u8 r1, s32 direction) +{ + EntityInfo *info; + + info = GetEntInfo(a0); + + sub_806CDD4(a0, r1, direction); + info->unkFE = r1; +} + +void sub_80861D4(Entity *a0, u8 r1, s32 direction) +{ + sub_806CDD4(a0, r1, direction); + sub_80861EC(a0); +} + +void sub_80861EC(Entity *a0) +{ + GetEntInfo(a0)->unkFE = 0x63; +} + +s32 sub_80861F8(s32 param_1,Entity *param_2,bool32 param_3) +{ + EntityInfo *info; + s32 uVar2; + s32 uStack_38; + DungeonPos pos; + unkStruct_80416E0 stack; + + // Needed to match. + s32 param_1Copy2 = (s16) param_1; + s32 param_1Copy = param_1Copy2; + u8 param_3_bool32 = param_3; + + sub_800EE5C(param_1Copy2); + sub_800EF64(); + DungeonRunFrameActions(0x46); + info = GetEntInfo(param_2); + pos.x = 0; + pos.y = 0; + uStack_38 = sub_800E700(param_1Copy); + if (uStack_38 != -1) { + sub_800569C(&pos, ¶m_2->axObj, uStack_38); + } + stack.unk0 = param_1Copy; + stack.unk4 = 0; + stack.dir = info->action.direction; + stack.x = (param_2->pixelPos).x / 256; + stack.y = (param_2->pixelPos).y / 256; + + stack.unk10 = pos.x; + stack.unk12 = pos.y; + stack.unk14 = uStack_38; + stack.unk18 = 0xffff; + stack.unk1C = (unkStruct_2039DB0) {0xFFFF, 0xFFFF, 0xFFFF, 0, 0}; + + uVar2 = sub_800E890(&stack); + if (param_3_bool32) { + sub_8085F44(uVar2); + uVar2 = -1; + } + return uVar2; +} + +void SpriteShockEffect(Entity *entity) +{ + PlaySoundEffect(464); + sub_80861F8(323, entity, 0); +} + +static void sub_80862DC(Entity *entity) +{ + PixelPos pos; + pos.x = entity->pixelPos.x; + pos.y = entity->pixelPos.y + 0x3800; + + sub_804535C(entity, &pos); + sub_806CDD4(entity, 0, DIRECTION_NORTH); + sub_8086A54(entity); +} + +static void sub_8086310(Entity *entity) +{ + PixelPos pos; + pos.x = entity->pixelPos.x; + pos.y = entity->pixelPos.y + 0x9000; + + sub_804535C(entity, &pos); + sub_806CE68(entity, DIRECTION_SOUTH); + sub_8086A3C(entity); + entity->isVisible = 0; +} + +static void sub_8086348(Entity *entity) +{ + PixelPos pos; + pos.x = entity->pixelPos.x + 0x7800; + pos.y = entity->pixelPos.y - 0x2000; + + sub_804535C(entity, &pos); + sub_806CDD4(entity, 0, DIRECTION_WEST); + sub_8086A54(entity); +} + +static void sub_8086384(Entity *entity) +{ + PixelPos pos; + pos.x = entity->pixelPos.x + 0x7800; + pos.y = entity->pixelPos.y; + + sub_804535C(entity, &pos); + sub_806CDD4(entity, 0, DIRECTION_WEST); + sub_8086A54(entity); +} + +static void sub_80863B8(Entity *entity) +{ + sub_806CDD4(entity, 0, DIRECTION_NORTH); +} + +static void sub_80863C8(Entity *entity) +{ + sub_806CDD4(entity, 0, DIRECTION_SOUTH); +} + +static void sub_80863D8(Entity *entity) +{ + sub_806CDD4(entity, 0, DIRECTION_WEST); +} + +static void sub_80863E8(Entity *entity) +{ + sub_806CDD4(entity, 6, DIRECTION_NORTH); +} + +static void sub_80863F8(Entity *entity) +{ + sub_806CE68(entity, DIRECTION_NORTH); +} + +static void sub_8086404(Entity *entity) +{ + sub_806CE68(entity, DIRECTION_WEST); +} + +static void sub_8086410(Entity *entity) +{ + IncreaseEntityPixelPos(entity, 0, -0x100); +} + +static void sub_8086424(Entity *entity) +{ + IncreaseEntityPixelPos(entity, 0, 0x100); +} + +static void sub_8086434(Entity *entity) +{ + IncreaseEntityPixelPos(entity, -0x100, 0); +} + +void sub_8086448(void) +{ + s32 i; + u32 XPos; + u32 YPos; + + sub_80855E4(sub_80862DC); + + for (i = 0; i < 56; i++) { + XPos = GetCameraXPos(); + YPos = GetCameraYPos(); + YPos += 0x100; + sub_803F878(XPos, YPos); + sub_80855E4(sub_8086410); + DungeonRunFrameActions(0x46); + } + + sub_80855E4(sub_80863F8); +} + +static void sub_8086494(void) +{ + s32 i; + + sub_8085930(DIRECTION_NORTHEAST); + sub_803E708(4, 70); + + sub_8085930(DIRECTION_EAST); + sub_803E708(4, 70); + + sub_8085930(DIRECTION_SOUTHEAST); + sub_803E708(4, 70); + + sub_8085930(DIRECTION_SOUTH); + sub_803E708(4, 70); + + sub_80855E4(sub_80863C8); + + for (i = 0; i < 144; i++) { + sub_80855E4(sub_8086424); + DungeonRunFrameActions(70); + } + + sub_80855E4(sub_8086310); +} + +void sub_8086500(void) +{ + s32 i; + u32 XPos; + u32 YPos; + + sub_80855E4(sub_8086348); + + for (i = 0; i < 72; i++) { + XPos = GetCameraXPos(); + XPos += 0x100; + YPos = GetCameraYPos(); + sub_803F878(XPos, YPos); + sub_80855E4(sub_8086434); + DungeonRunFrameActions(70); + } + + sub_80855E4(sub_8086404); +} + +void sub_808654C(void) +{ + s32 i; + u32 XPos; + u32 YPos; + + sub_80855E4(sub_8086384); + + for (i = 0; i < 120; i++) { + XPos = GetCameraXPos(); + XPos += 0x100; + YPos = GetCameraYPos(); + sub_803F878(XPos, YPos); + sub_80855E4(sub_8086434); + DungeonRunFrameActions(70); + } + + sub_80855E4(sub_8086404); +} + +void sub_8086598(void) +{ + s32 i; + u32 XPos; + u32 YPos; + + sub_80855E4(sub_80863B8); + + for (i = 0; i < 24; i++) { + XPos = GetCameraXPos(); + YPos = GetCameraYPos(); + sub_803F878(XPos, YPos - 0x100); + sub_80855E4(sub_8086410); + DungeonRunFrameActions(70); + } + + sub_80855E4(sub_80863F8); +} + +void sub_80865E8(void) +{ + s32 i; + u32 XPos; + u32 YPos; + + sub_80855E4(sub_80863E8); + + for (i = 0; i < 12; i++) { + XPos = GetCameraXPos(); + YPos = GetCameraYPos(); + sub_803F878(XPos, YPos + 0x200); + sub_80855E4(sub_8086424); + sub_80855E4(sub_8086424); + DungeonRunFrameActions(70); + } + + sub_80855E4(sub_80863F8); +} + +void sub_808663C(void) +{ + s32 i; + u32 XPos; + u32 YPos; + + sub_80855E4(sub_80863E8); + + for (i = 0; i < 16; i++) { + XPos = GetCameraXPos(); + YPos = GetCameraYPos(); + sub_803F878(XPos, YPos + 0x200); + sub_80855E4(sub_8086424); + sub_80855E4(sub_8086424); + DungeonRunFrameActions(70); + } + + sub_80855E4(sub_80863F8); +} + +void sub_8086690(void) +{ + s32 i; + + sub_80855E4(sub_80863D8); + + for (i = 0; i < 48; i++) { + sub_80855E4(sub_8086434); + DungeonRunFrameActions(70); + } + + sub_80855E4(sub_8086404); +} + +void sub_80866C4(const struct DungeonDialogueStruct *dialogue) +{ + SpriteLookAroundEffect(xxx_call_GetLeader()); + sub_803E708(10, 70); + DisplayDungeonDialogue(dialogue); + sub_803E708(10, 70); + sub_8086494(); + gDungeon->unk2 = 1; +} + +UNUSED static void sub_80866FC(void) +{ + s32 i; + + for (i = 0; i >= -250; i -= 10) { + SetDungeonBGColorRGB(i, i, i, 1, 0); + DungeonRunFrameActions(70); + } +} + +UNUSED static void sub_808627C(void) +{ + sub_803E748(); +} + +void sub_8086738(void) +{ + s32 i; + + for (i = 0; i < 250; i += 10) { + SetDungeonBGColorRGB(i, i, i, 1, 0); + DungeonRunFrameActions(70); + } +} + +void sub_8086764(void) +{ + s32 i; + + for (i = 250; i >= 0; i -= 5) { + SetDungeonBGColorRGB(i, i, i, 1, 0); + DungeonRunFrameActions(70); + } + + sub_8085EB0(); +} + +void sub_8086794(void) +{ + s32 i; + + gDungeonBrightness = 0; + + for (i = 0; i < 200; i++) { + SetDungeonBGColorRGB(0, 0, 0, 1, 0); + BgColorCallNullsub4(); + DungeonRunFrameActions(70); + + if ((i & 3) == 0) { + gDungeonBrightness++; + if (gDungeonBrightness == 31) + break; + } + } + + DungeonRunFrameActions(70); + gDungeon->unk7 = 0; +} + +void sub_80867F4(void) +{ + gUnknown_202F3D0.unk0 = 0; + gUnknown_202F3D0.unk1 = 0; + gUnknown_202F3D0.unk2 = 0; + gUnknown_202F3D0.unk3 = 0; + gUnknown_202F3D0.unk4 = 0; + gUnknown_202F3D0.unk5 = 0; +} + +void sub_808680C(void) +{ + gUnknown_202F3D0.unk0 = 1; + if (gUnknown_202F3D0.unk3 != 0) + PlaySoundEffect(505); +} + +void sub_808682C(void) +{ + gUnknown_202F3D0.unk0 = 0; +} + +void sub_8086838(u8 entity, u8 r1, u8 r2) +{ + gUnknown_202F3D0.unk1 = entity; + gUnknown_202F3D0.unk2 = r1; + gUnknown_202F3D0.unk3 = r2; +} + +void sub_8086848(u8 entity, u8 r1) +{ + gUnknown_202F3D0.unk4 = entity; + gUnknown_202F3D0.unk5 = r1; +} + +void sub_8086854(void) +{ + if (gUnknown_202F3D0.unk0) { + if (gUnknown_202F3D0.unk4 == 0) { + if (gUnknown_202F3D0.unk1) { + gUnknown_202F3D0.unk4 = 80; + gUnknown_202F3D0.unk5 = 16; + } + else { + gUnknown_202F3D0.unk4 = RandInt(6) + 2; + gUnknown_202F3D0.unk5 = RandInt(6) + 2; + } + + if (gUnknown_202F3D0.unk3 != 0) + PlaySoundEffect(505); + } + else + gUnknown_202F3D0.unk4--; + + if (gUnknown_202F3D0.unk5 != 0) + gUnknown_202F3D0.unk5--; + + gDungeon->unk181e8.unk181FC = gUnknown_8107314[gUnknown_202F3D0.unk5]; + } + else + gDungeon->unk181e8.unk181FC = 0; +} + +void sub_80868F4(Entity *entity) +{ + GetEntInfo(entity)->unk15C = 1; + GetEntInfo(entity)->unk15D = 1; +} + +void sub_8086910(Entity *entity) +{ + GetEntInfo(entity)->unk15C = 0; + GetEntInfo(entity)->unk15D = 0; +} + +void sub_808692C(void) +{ + sub_80859F0(DIRECTION_NORTHWEST); + sub_803E708(4, 70); + + sub_80859F0(DIRECTION_WEST); + sub_803E708(4, 70); + + sub_80859F0(DIRECTION_SOUTHWEST); + sub_803E708(4, 70); + + sub_80859F0(DIRECTION_SOUTH); + sub_803E708(4, 70); +} + +void SpriteLookAroundEffect(Entity *entity) +{ + s8 r4; + s8 r3; + + r4 = sub_8002984(GetEntInfo(entity)->action.direction, 4); + + sub_80869E4(entity, 4, 2, r4); + + sub_803E708(15, 70); + + r4 = sub_8002984(r4, 5); + + sub_80869E4(entity, 4, 1, r4); + + sub_803E708(15, 70); + + r3 = sub_8002984(r4, 4); + + sub_80869E4(entity, 4, 2, r3); + + sub_803E708(15, 70); +} + +void sub_80869E4(struct Entity *entity, s32 a1, u8 a2, s32 _someDirection) +{ + s32 someDirection = (s8) _someDirection; + struct EntityInfo *info = GetEntInfo(entity); + s32 direction = (s8) info->action.direction; + + while (direction != someDirection) { + direction = (s8) sub_8002A70(direction, someDirection, a2); + info->action.direction = direction; + info->action.direction &= DIRECTION_MASK; + sub_806CE68(entity, info->action.direction); + sub_803E708(a1, 70); + } +} + +void sub_8086A3C(Entity *pokemon) +{ + GetEntInfo(pokemon)->unk15C = 1; + GetEntInfo(pokemon)->unk15E = 1; +} + +void sub_8086A54(Entity *pokemon) +{ + GetEntInfo(pokemon)->unk15C = 1; + GetEntInfo(pokemon)->unk15E = 0; +} + +void SetupBossFightHP(Entity *pokemon, s32 newHP, u16 songIndex) +{ + EntityInfo *entityInfo = GetEntInfo(pokemon); + + entityInfo->bossFlag = TRUE; + + // BUG: Source of the Reviver Seed Boss Glitch + // + // Video to demonstration: + // https://www.youtube.com/watch?v=rHu7EehrZ68 + entityInfo->originalHP = entityInfo->maxHPStat; + if (newHP != 0) { + entityInfo->maxHPStat = newHP; + entityInfo->HP = newHP; + } + + gDungeon->unk644.bossSongIndex = songIndex; + SetDefaultIQSkills(&entityInfo->IQSkillMenuFlags, entityInfo->bossFlag); + LoadIQSkills(pokemon); +} + +void sub_8086AC0(void) +{ + if(!sub_8044B28()) + if(gDungeon->unk2 == 0) + sub_8097FF8(); +} + +u8 sub_8086AE4(s16 _index) +{ + s32 pokeIndex = _index; + + if(gDungeon->unk644.unk18 == 0) + return 1; + else + return HasRecruitedMon(pokeIndex); +} + diff --git a/src/code_8085E98.c b/src/code_8085E98.c deleted file mode 100644 index e68112acb..000000000 --- a/src/code_8085E98.c +++ /dev/null @@ -1,122 +0,0 @@ -#include "global.h" -#include "code_8085E98.h" -#include "code_800E9A8.h" -#include "code_803E46C.h" -#include "dungeon_util.h" -#include "items.h" -#include "code_800DAC0.h" -#include "code_800ED38.h" -#include "structs/sprite_oam.h" -#include "structs/str_dungeon.h" - -extern const unkStruct_2039DB0 gUnknown_8107374; - - -void sub_8085F44(s32); -bool8 sub_800E90C(DungeonPos *); -void sub_8088EE8(void); -void sub_8088848(void); -void sub_808A718(void); - - -void sub_8085E98(void) -{ - gDungeon->unk181e8.unk18215 = 0; -} - -void sub_8085EB0(void) -{ - gDungeon->unk181e8.unk18215 = 1; -} - -u32 sub_8085EC8(s16 param_1,u32 param_2,u32 param_3,DungeonPos *param_4, - bool32 param_5) -{ - u32 uVar1; - unkStruct_80416E0 local_40; - unkStruct_2039DB0 stack1C; - - bool8 param_5_bool8; - s32 param_1_s32 = param_1; - - - param_5_bool8 = param_5; - - sub_800EE5C(param_1_s32); - sub_800EF64(); - DungeonRunFrameActions(0x46); - local_40.unk0 = param_1; - local_40.unk4 = param_2; - local_40.dir = param_3; - local_40.x = param_4->x; - local_40.y = param_4->y; - local_40.unk10 = 0; - local_40.unk12 = 0; - local_40.unk18 = 0xffff; - stack1C = gUnknown_8107374; - - uVar1 = sub_800E890(&local_40); - if (param_5_bool8) { - sub_8085F44(uVar1); - uVar1 = -1; - } - return uVar1; -} - -void sub_8085F44(s32 param_1) -{ - while (sub_800E9A8(param_1)) { - sub_800E90C(&gDungeon->unk181e8.cameraPixelPos); - DungeonRunFrameActions(0x46); - } -} - -void sub_8085F78(void) -{ - switch(gDungeon->unk3A0D) { - case 0x12: - case 0x13: - case 0x14: - sub_8088848(); - break; - case 0x15: - sub_8088EE8(); - break; - case 0x29: - case 0x2A: - sub_808A718(); - break; - - case 0: - case 0x3C: - default: - break; - } - return; -} - -bool8 sub_80860A8(u8 id) -{ - - Item *item; - EntityInfo *info; - Entity *entity; - int index; - - - for(index = 0; index < INVENTORY_SIZE; index++) - { - item = &gTeamInventoryRef->teamItems[index]; - if((item->flags & 1) != 0) - { - if((item->id) == id) return TRUE; - } - } - - for(index = 0; index < MAX_TEAM_MEMBERS; index++) - { - entity = gDungeon->teamPokemon[index]; - if (((EntityIsValid(entity)) && (info = GetEntInfo(entity), ((info->heldItem).flags & 1))) && ((info->heldItem).id == id)) return TRUE; - } - return FALSE; -} diff --git a/src/code_80861A8.c b/src/code_80861A8.c deleted file mode 100644 index 631569927..000000000 --- a/src/code_80861A8.c +++ /dev/null @@ -1,118 +0,0 @@ -#include "global.h" -#include "constants/direction.h" -#include "structs/sprite_oam.h" -#include "code_800DAC0.h" -#include "code_800ED38.h" -#include "code_803E46C.h" -#include "code_803E668.h" -#include "code_806CD90.h" -#include "code_80861A8.h" -#include "dungeon_music.h" -#include "dungeon_util.h" -#include "sprite.h" - -extern const unkStruct_2039DB0 gUnknown_8107380; - -extern const u8 *gUnknown_810665C[]; -extern const u8 *gUnknown_810668C[]; -extern const u8 *gUnknown_81066D4[]; -extern const u8 *gUnknown_81066F0[]; -extern const u8 *gUnknown_810671C[]; - -static void sub_80861EC(Entity *); - -s32 sub_800E700(s32); -void sub_8085F44(s32); - -void sub_8052FB8(const u8 *); - -void sub_8086124(Entity *entity, u8 param_2) -{ - GetEntInfo(entity)->unk160 = param_2; -} - -void sub_8086130(void) -{ - DungeonFadeOutBGM(0x3c); - sub_803E708(0x3c,0x46); - sub_8052FB8(*gUnknown_810665C); - sub_803E708(0x1e,0x46); - sub_8052FB8(*gUnknown_810668C); - sub_803E708(0x1e,0x46); - sub_8052FB8(*gUnknown_81066D4); - sub_803E708(0x1e,0x46); - sub_8052FB8(*gUnknown_81066F0); - sub_803E708(0x1e,0x46); - sub_8052FB8(*gUnknown_810671C); - sub_803E708(0x1e,0x46); -} - -void sub_80861A8(Entity *a0) -{ - sub_806CDD4(a0, 0, NUM_DIRECTIONS); -} - -void sub_80861B8(Entity *a0, u8 r1, s32 direction) -{ - EntityInfo *info; - - info = GetEntInfo(a0); - - sub_806CDD4(a0, r1, direction); - info->unkFE = r1; -} - -void sub_80861D4(Entity *a0, u8 r1, s32 direction) -{ - sub_806CDD4(a0, r1, direction); - sub_80861EC(a0); -} - -void sub_80861EC(Entity *a0) -{ - GetEntInfo(a0)->unkFE = 0x63; -} - -s32 sub_80861F8(s32 param_1,Entity *param_2,bool32 param_3) -{ - EntityInfo *info; - s32 uVar2; - s32 uStack_38; - DungeonPos pos; - unkStruct_80416E0 stack; - unkStruct_2039DB0 stack1C; - - // Needed to match. - s32 param_1Copy2 = (s16) param_1; - s32 param_1Copy = param_1Copy2; - u8 param_3_bool32 = param_3; - - sub_800EE5C(param_1Copy2); - sub_800EF64(); - DungeonRunFrameActions(0x46); - info = GetEntInfo(param_2); - pos.x = 0; - pos.y = 0; - uStack_38 = sub_800E700(param_1Copy); - if (uStack_38 != -1) { - sub_800569C(&pos, ¶m_2->axObj, uStack_38); - } - stack.unk0 = param_1Copy; - stack.unk4 = 0; - stack.dir = info->action.direction; - stack.x = (param_2->pixelPos).x / 256; - stack.y = (param_2->pixelPos).y / 256; - - stack.unk10 = pos.x; - stack.unk12 = pos.y; - stack.unk14 = uStack_38; - stack.unk18 = 0xffff; - stack1C = gUnknown_8107380; - - uVar2 = sub_800E890(&stack); - if (param_3_bool32) { - sub_8085F44(uVar2); - uVar2 = -1; - } - return uVar2; -} diff --git a/src/code_80869E4.c b/src/code_80869E4.c deleted file mode 100644 index a64cc5c99..000000000 --- a/src/code_80869E4.c +++ /dev/null @@ -1,492 +0,0 @@ -#include "global.h" -#include "code_800E9E4.h" -#include "code_803E46C.h" -#include "code_803E668.h" -#include "code_806CD90.h" -#include "code_80869E4.h" -#include "constants/direction.h" -#include "dungeon_util.h" -#include "dungeon_util_1.h" -#include "random.h" -#include "structs/str_dungeon.h" - -// This file may originally be merged with code_8086A3C.c and code_8057824_1.c - -// ??? -extern u32 gDungeonBrightness; - -EWRAM_DATA static unkStruct_202F3D0 gUnknown_202F3D0 = {0}; - -// data_8107010.s -extern u32 gUnknown_8107314[]; - -s8 sub_8002984(s8, u8); -extern void BgColorCallNullsub4(void); -extern void SetDungeonBGColorRGB(u32, u32, u32, u32, u32); -extern void PlaySoundEffect(u32); - - -extern void sub_8085EB0(void); -extern void sub_803E748(void); -extern s32 GetCameraXPos(void); -extern s32 GetCameraYPos(void); -extern void sub_803F878(u32, u32); -extern void sub_8086A54(Entity *); -extern void sub_8086A3C(Entity *); -extern void PlaySoundEffect(u32); -extern void sub_80861F8(u32, Entity *, u32); -extern u32 sub_8002A70(u32, s32, u8); - -void SpriteShockEffect(Entity *entity) -{ - PlaySoundEffect(464); - sub_80861F8(323, entity, 0); -} - -static void sub_80862DC(Entity *entity) -{ - PixelPos pos; - pos.x = entity->pixelPos.x; - pos.y = entity->pixelPos.y + 0x3800; - - sub_804535C(entity, &pos); - sub_806CDD4(entity, 0, DIRECTION_NORTH); - sub_8086A54(entity); -} - -static void sub_8086310(Entity *entity) -{ - PixelPos pos; - pos.x = entity->pixelPos.x; - pos.y = entity->pixelPos.y + 0x9000; - - sub_804535C(entity, &pos); - sub_806CE68(entity, DIRECTION_SOUTH); - sub_8086A3C(entity); - entity->isVisible = 0; -} - -static void sub_8086348(Entity *entity) -{ - PixelPos pos; - pos.x = entity->pixelPos.x + 0x7800; - pos.y = entity->pixelPos.y - 0x2000; - - sub_804535C(entity, &pos); - sub_806CDD4(entity, 0, DIRECTION_WEST); - sub_8086A54(entity); -} - -static void sub_8086384(Entity *entity) -{ - PixelPos pos; - pos.x = entity->pixelPos.x + 0x7800; - pos.y = entity->pixelPos.y; - - sub_804535C(entity, &pos); - sub_806CDD4(entity, 0, DIRECTION_WEST); - sub_8086A54(entity); -} - -static void sub_80863B8(Entity *entity) -{ - sub_806CDD4(entity, 0, DIRECTION_NORTH); -} - -static void sub_80863C8(Entity *entity) -{ - sub_806CDD4(entity, 0, DIRECTION_SOUTH); -} - -static void sub_80863D8(Entity *entity) -{ - sub_806CDD4(entity, 0, DIRECTION_WEST); -} - -static void sub_80863E8(Entity *entity) -{ - sub_806CDD4(entity, 6, DIRECTION_NORTH); -} - -static void sub_80863F8(Entity *entity) -{ - sub_806CE68(entity, DIRECTION_NORTH); -} - -static void sub_8086404(Entity *entity) -{ - sub_806CE68(entity, DIRECTION_WEST); -} - -static void sub_8086410(Entity *entity) -{ - IncreaseEntityPixelPos(entity, 0, -0x100); -} - -static void sub_8086424(Entity *entity) -{ - IncreaseEntityPixelPos(entity, 0, 0x100); -} - -static void sub_8086434(Entity *entity) -{ - IncreaseEntityPixelPos(entity, -0x100, 0); -} - -void sub_8086448(void) -{ - s32 i; - u32 XPos; - u32 YPos; - - sub_80855E4(sub_80862DC); - - for (i = 0; i < 56; i++) { - XPos = GetCameraXPos(); - YPos = GetCameraYPos(); - YPos += 0x100; - sub_803F878(XPos, YPos); - sub_80855E4(sub_8086410); - DungeonRunFrameActions(0x46); - } - - sub_80855E4(sub_80863F8); -} - -static void sub_8086494(void) -{ - s32 i; - - sub_8085930(DIRECTION_NORTHEAST); - sub_803E708(4, 70); - - sub_8085930(DIRECTION_EAST); - sub_803E708(4, 70); - - sub_8085930(DIRECTION_SOUTHEAST); - sub_803E708(4, 70); - - sub_8085930(DIRECTION_SOUTH); - sub_803E708(4, 70); - - sub_80855E4(sub_80863C8); - - for (i = 0; i < 144; i++) { - sub_80855E4(sub_8086424); - DungeonRunFrameActions(70); - } - - sub_80855E4(sub_8086310); -} - -void sub_8086500(void) -{ - s32 i; - u32 XPos; - u32 YPos; - - sub_80855E4(sub_8086348); - - for (i = 0; i < 72; i++) { - XPos = GetCameraXPos(); - XPos += 0x100; - YPos = GetCameraYPos(); - sub_803F878(XPos, YPos); - sub_80855E4(sub_8086434); - DungeonRunFrameActions(70); - } - - sub_80855E4(sub_8086404); -} - -void sub_808654C(void) -{ - s32 i; - u32 XPos; - u32 YPos; - - sub_80855E4(sub_8086384); - - for (i = 0; i < 120; i++) { - XPos = GetCameraXPos(); - XPos += 0x100; - YPos = GetCameraYPos(); - sub_803F878(XPos, YPos); - sub_80855E4(sub_8086434); - DungeonRunFrameActions(70); - } - - sub_80855E4(sub_8086404); -} - -void sub_8086598(void) -{ - s32 i; - u32 XPos; - u32 YPos; - - sub_80855E4(sub_80863B8); - - for (i = 0; i < 24; i++) { - XPos = GetCameraXPos(); - YPos = GetCameraYPos(); - sub_803F878(XPos, YPos - 0x100); - sub_80855E4(sub_8086410); - DungeonRunFrameActions(70); - } - - sub_80855E4(sub_80863F8); -} - -void sub_80865E8(void) -{ - s32 i; - u32 XPos; - u32 YPos; - - sub_80855E4(sub_80863E8); - - for (i = 0; i < 12; i++) { - XPos = GetCameraXPos(); - YPos = GetCameraYPos(); - sub_803F878(XPos, YPos + 0x200); - sub_80855E4(sub_8086424); - sub_80855E4(sub_8086424); - DungeonRunFrameActions(70); - } - - sub_80855E4(sub_80863F8); -} - -void sub_808663C(void) -{ - s32 i; - u32 XPos; - u32 YPos; - - sub_80855E4(sub_80863E8); - - for (i = 0; i < 16; i++) { - XPos = GetCameraXPos(); - YPos = GetCameraYPos(); - sub_803F878(XPos, YPos + 0x200); - sub_80855E4(sub_8086424); - sub_80855E4(sub_8086424); - DungeonRunFrameActions(70); - } - - sub_80855E4(sub_80863F8); -} - -void sub_8086690(void) -{ - s32 i; - - sub_80855E4(sub_80863D8); - - for (i = 0; i < 48; i++) { - sub_80855E4(sub_8086434); - DungeonRunFrameActions(70); - } - - sub_80855E4(sub_8086404); -} - -void sub_80866C4(const struct DungeonDialogueStruct *dialogue) -{ - SpriteLookAroundEffect(xxx_call_GetLeader()); - sub_803E708(10, 70); - DisplayDungeonDialogue(dialogue); - sub_803E708(10, 70); - sub_8086494(); - gDungeon->unk2 = 1; -} - -UNUSED static void sub_80866FC(void) -{ - s32 i; - - for (i = 0; i >= -250; i -= 10) { - SetDungeonBGColorRGB(i, i, i, 1, 0); - DungeonRunFrameActions(70); - } -} - -UNUSED static void sub_808627C(void) -{ - sub_803E748(); -} - -void sub_8086738(void) -{ - s32 i; - - for (i = 0; i < 250; i += 10) { - SetDungeonBGColorRGB(i, i, i, 1, 0); - DungeonRunFrameActions(70); - } -} - -void sub_8086764(void) -{ - s32 i; - - for (i = 250; i >= 0; i -= 5) { - SetDungeonBGColorRGB(i, i, i, 1, 0); - DungeonRunFrameActions(70); - } - - sub_8085EB0(); -} - -void sub_8086794(void) -{ - s32 i; - - gDungeonBrightness = 0; - - for (i = 0; i < 200; i++) { - SetDungeonBGColorRGB(0, 0, 0, 1, 0); - BgColorCallNullsub4(); - DungeonRunFrameActions(70); - - if ((i & 3) == 0) { - gDungeonBrightness++; - if (gDungeonBrightness == 31) - break; - } - } - - DungeonRunFrameActions(70); - gDungeon->unk7 = 0; -} - -void sub_80867F4(void) -{ - gUnknown_202F3D0.unk0 = 0; - gUnknown_202F3D0.unk1 = 0; - gUnknown_202F3D0.unk2 = 0; - gUnknown_202F3D0.unk3 = 0; - gUnknown_202F3D0.unk4 = 0; - gUnknown_202F3D0.unk5 = 0; -} - -void sub_808680C(void) -{ - gUnknown_202F3D0.unk0 = 1; - if (gUnknown_202F3D0.unk3 != 0) - PlaySoundEffect(505); -} - -void sub_808682C(void) -{ - gUnknown_202F3D0.unk0 = 0; -} - -void sub_8086838(u8 entity, u8 r1, u8 r2) -{ - gUnknown_202F3D0.unk1 = entity; - gUnknown_202F3D0.unk2 = r1; - gUnknown_202F3D0.unk3 = r2; -} - -void sub_8086848(u8 entity, u8 r1) -{ - gUnknown_202F3D0.unk4 = entity; - gUnknown_202F3D0.unk5 = r1; -} - -void sub_8086854(void) -{ - if (gUnknown_202F3D0.unk0) { - if (gUnknown_202F3D0.unk4 == 0) { - if (gUnknown_202F3D0.unk1) { - gUnknown_202F3D0.unk4 = 80; - gUnknown_202F3D0.unk5 = 16; - } - else { - gUnknown_202F3D0.unk4 = RandInt(6) + 2; - gUnknown_202F3D0.unk5 = RandInt(6) + 2; - } - - if (gUnknown_202F3D0.unk3 != 0) - PlaySoundEffect(505); - } - else - gUnknown_202F3D0.unk4--; - - if (gUnknown_202F3D0.unk5 != 0) - gUnknown_202F3D0.unk5--; - - gDungeon->unk181e8.unk181FC = gUnknown_8107314[gUnknown_202F3D0.unk5]; - } - else - gDungeon->unk181e8.unk181FC = 0; -} - -void sub_80868F4(Entity *entity) -{ - GetEntInfo(entity)->unk15C = 1; - GetEntInfo(entity)->unk15D = 1; -} - -void sub_8086910(Entity *entity) -{ - GetEntInfo(entity)->unk15C = 0; - GetEntInfo(entity)->unk15D = 0; -} - -void sub_808692C(void) -{ - sub_80859F0(DIRECTION_NORTHWEST); - sub_803E708(4, 70); - - sub_80859F0(DIRECTION_WEST); - sub_803E708(4, 70); - - sub_80859F0(DIRECTION_SOUTHWEST); - sub_803E708(4, 70); - - sub_80859F0(DIRECTION_SOUTH); - sub_803E708(4, 70); -} - -void SpriteLookAroundEffect(Entity *entity) -{ - s8 r4; - s8 r3; - - r4 = sub_8002984(GetEntInfo(entity)->action.direction, 4); - - sub_80869E4(entity, 4, 2, r4); - - sub_803E708(15, 70); - - r4 = sub_8002984(r4, 5); - - sub_80869E4(entity, 4, 1, r4); - - sub_803E708(15, 70); - - r3 = sub_8002984(r4, 4); - - sub_80869E4(entity, 4, 2, r3); - - sub_803E708(15, 70); -} - -void sub_80869E4(struct Entity *entity, s32 a1, u8 a2, s32 _someDirection) -{ - s32 someDirection = (s8) _someDirection; - struct EntityInfo *info = GetEntInfo(entity); - s32 direction = (s8) info->action.direction; - - while (direction != someDirection) { - direction = (s8) sub_8002A70(direction, someDirection, a2); - info->action.direction = direction; - info->action.direction &= DIRECTION_MASK; - sub_806CE68(entity, info->action.direction); - sub_803E708(a1, 70); - } -} - diff --git a/src/data/code_803D0D8.h b/src/data/code_803D0D8.h index 02baf37b0..68d7e2235 100644 --- a/src/data/code_803D0D8.h +++ b/src/data/code_803D0D8.h @@ -41,18 +41,17 @@ static const u8 sUnknown_80F42F0[256] = { }; static const u8 gUnknown_80F43F0[PASSWORD_BUFFER_SIZE] = { - 0x0d, 0x07, 0x19, 0x0f, 0x04, 0x1d, 0x2a, 0x31, 0x08, 0x13, - 0x2d, 0x18, 0x0e, 0x1a, 0x1b, 0x29, 0x01, 0x20, 0x21, - 0x22, 0x11, 0x33, 0x26, 0x00, 0x35, 0x0a, 0x2b, 0x1f, - 0x12, 0x23, 0x2c, 0x17, 0x27, 0x10, 0x1c, 0x30, 0x0b, - 0x02, 0x24, 0x09, 0x32, 0x05, 0x28, 0x34, 0x2e, 0x03, - 0x1e, 0x0c, 0x25, 0x14, 0x2f, 0x16, 0x06, 0x15 + 0x0d, 0x07, 0x19, 0x0f, 0x04, 0x1d, 0x2a, 0x31, 0x08, 0x13, + 0x2d, 0x18, 0x0e, 0x1a, 0x1b, 0x29, 0x01, 0x20, 0x21, + 0x22, 0x11, 0x33, 0x26, 0x00, 0x35, 0x0a, 0x2b, 0x1f, + 0x12, 0x23, 0x2c, 0x17, 0x27, 0x10, 0x1c, 0x30, 0x0b, + 0x02, 0x24, 0x09, 0x32, 0x05, 0x28, 0x34, 0x2e, 0x03, + 0x1e, 0x0c, 0x25, 0x14, 0x2f, 0x16, 0x06, 0x15 }; -static const u8 gUnknown_80F4426[34] = { - 0x0c, 0x06, 0x13, 0x08, 0x04, 0x0d, 0x0f, 0x09, 0x10, 0x02, - 0x14, 0x12, 0x00, 0x15, 0x0b, 0x05, 0x17, 0x03, 0x11, - 0x0a, 0x01, 0x0e, 0x16, 0x07, 0x00, 0x00,0x70, 0x6b, - 0x73, 0x64, 0x69, 0x72, 0x30, 0x00 +static const u8 gUnknown_80F4426[] = { + 0x0c, 0x06, 0x13, 0x08, 0x04, 0x0d, 0x0f, 0x09, 0x10, 0x02, + 0x14, 0x12, 0x00, 0x15, 0x0b, 0x05, 0x17, 0x03, 0x11, + 0x0a, 0x01, 0x0e, 0x16, 0x07, 0x00, 0x00 }; diff --git a/src/drought_orb.c b/src/drought_orb.c index 767a48470..73cde902a 100644 --- a/src/drought_orb.c +++ b/src/drought_orb.c @@ -2,7 +2,7 @@ #include "globaldata.h" #include "constants/ability.h" #include "constants/weather.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "dungeon_message.h" #include "code_806CD90.h" #include "code_807CD9C.h" diff --git a/src/dungeon_8067A80.c b/src/dungeon_8067A80.c index 3bc816fa5..f0cb074c6 100644 --- a/src/dungeon_8067A80.c +++ b/src/dungeon_8067A80.c @@ -3,15 +3,14 @@ #include "constants/dungeon.h" #include "constants/item.h" #include "constants/move_id.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "code_803E724.h" #include "code_8041AD0.h" -#include "code_8044CC8.h" +#include "dungeon_action.h" #include "code_8066D04.h" #include "code_806CD90.h" #include "code_8077274_1.h" #include "code_807CD9C.h" -#include "code_8084778.h" #include "run_dungeon.h" #include "dungeon_items.h" #include "dungeon_leader.h" diff --git a/src/dungeon_8072CF4.c b/src/dungeon_8072CF4.c index 80363700b..5ac5db05f 100644 --- a/src/dungeon_8072CF4.c +++ b/src/dungeon_8072CF4.c @@ -2,7 +2,7 @@ #include "globaldata.h" #include "dungeon_ai_leader.h" #include "dungeon_move_util.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "code_8041AD0.h" #include "code_804267C.h" #include "code_8066D04.h" @@ -32,8 +32,6 @@ extern u8 gUnknown_202F221; extern u8 gUnknown_202F222; -extern u8 gUnknown_202F32C; -extern u8 gUnknown_202F32D; extern u8 gUnknown_203B434; extern u8 *gUnknown_80FA5B4[]; @@ -86,6 +84,9 @@ extern void MarkLastUsedMonMove(Entity *entity, Move *move); bool8 TryUseChosenMove(struct Entity *attacker, u32 r6, s32 itemId, u32 var_30, bool32 isLinkedMove, struct Move *move); extern void sub_80838EC(u8 *a); +EWRAM_DATA u8 gUnknown_202F32C = 0; +EWRAM_DATA u8 gUnknown_202F32D = 0; + bool8 sub_8072CF4(Entity *entity) { bool8 bVar4; diff --git a/src/dungeon_8083AB0.c b/src/dungeon_8083AB0.c new file mode 100644 index 000000000..62a599c3f --- /dev/null +++ b/src/dungeon_8083AB0.c @@ -0,0 +1,110 @@ +#include "global.h" +#include "globaldata.h" +#include "dungeon_8083AB0.h" +#include "dungeon.h" +#include "dungeon_util.h" +#include "text_util.h" +#include "dungeon_logic.h" +#include "dungeon_data.h" +#include "dungeon_strings.h" + +void sub_8083AB0(s16 param_0, Entity *target, Entity *entity) +{ + u8 *defPtr; + u8 *attackPtr; + u8 *spDefPtr; + EntityInfo * entityInfo; + EntityInfo * targetEntityInfo; + u8 *spAttPtr; + u8 buffer [0x14]; + UnkDungeonGlobal_unk1CE98_sub *temp; + u8 *id; + s32 param_0_s32 = param_0; + + temp = &gDungeon->unk1CE98; + targetEntityInfo = NULL; + if ((EntityIsValid(target)) && (GetEntityType(target) == ENTITY_MONSTER)) { + targetEntityInfo = GetEntInfo(target); + } + entityInfo = GetEntInfo(entity); + if (targetEntityInfo != NULL) { + sub_80709C8(buffer, targetEntityInfo); + CopyStringtoBuffer(temp->buffer1, buffer); + } + else { + CopyStringtoBuffer(temp->buffer1, gUnknown_80FE6F4); // Someone + } + sub_80709C8(buffer,entityInfo); + CopyStringtoBuffer(temp->buffer2, buffer); + temp->moveID = param_0_s32; + temp->heldItem = entityInfo->heldItem; + temp->exp = entityInfo->exp; + temp->level = entityInfo->level; + temp->maxHPStat = entityInfo->maxHPStat; + temp->atk = entityInfo->atk[0]; + temp->spAtk = entityInfo->atk[1]; + temp->def = entityInfo->def[0]; + temp->spDef = entityInfo->def[1]; + temp->dungeonLocation = gDungeon->unk644.dungeonLocation; + attackPtr = &temp->attBoost; + *attackPtr = 0; + spAttPtr = &temp->spAttBoost; + *spAttPtr = 0; + defPtr = &temp->defBoost; + *defPtr = 0; + spDefPtr = &temp->spDefBoost; + *spDefPtr = 0; + if ((entityInfo->heldItem.flags & ITEM_FLAG_EXISTS) && !(entityInfo->heldItem.flags & ITEM_FLAG_STICKY)) { + id = &entityInfo->heldItem.id; + if (*id == ITEM_POWER_BAND) { + *attackPtr += gUnknown_810AC60; + } + if (*id == ITEM_MUNCH_BELT) { + *attackPtr += gUnknown_810AC68; + } + if (*id == ITEM_SPECIAL_BAND) { + *spAttPtr += gUnknown_810AC62; + } + if (*id == ITEM_MUNCH_BELT) { + *spAttPtr += gUnknown_810AC68; + } + if (*id == ITEM_DEF_SCARF) { + *defPtr += gUnknown_810AC64; + } + if (*id == ITEM_ZINC_BAND) { + *spDefPtr += gUnknown_810AC66; + } + } +} + +bool8 sub_8083C24(void) +{ + UnkDungeonGlobal_unk1CE98_sub *temp = &gDungeon->unk1CE98; + + if (temp->moveID < 0x226) + return TRUE; + + return FALSE; +} + +bool8 sub_8083C50(void) +{ + UnkDungeonGlobal_unk1CE98_sub *temp = &gDungeon->unk1CE98; + + if (temp->moveID == 0x227 || temp->moveID == 0x22A || temp->moveID == 0x228) + return TRUE; + + return FALSE; +} + +bool8 sub_8083C88(u8 param_1) +{ + UnkDungeonGlobal_unk1CE98_sub *temp = &gDungeon->unk1CE98; + + if ((!HasCheckpoint(gDungeon->unk644.dungeonLocation.id) && (gDungeon->unk644.unk18 != 0 || param_1 != 0)) + || temp->moveID != 0x227) { + return TRUE; + } + + return FALSE; +} diff --git a/src/dungeon_action.c b/src/dungeon_action.c index da4dad368..52e540870 100644 --- a/src/dungeon_action.c +++ b/src/dungeon_action.c @@ -14,7 +14,7 @@ #include "pokemon.h" #include "items.h" #include "structs/str_item_text.h" -#include "code_8044CC8.h" +#include "dungeon_action.h" #include "dungeon_items.h" #include "dungeon_map_access.h" #include "dungeon_engine.h" @@ -27,9 +27,8 @@ extern void TriggerWeatherAbilities(void); extern void sub_8071DA4(Entity *); extern void TickStatusHeal(Entity *); -extern unkStruct_202EE44 gDungeonSubMenu[10]; - -extern s32 gDungeonSubMenuItemsCount; +EWRAM_DATA SubMenuAction gDungeonSubMenu[10] = {0}; +EWRAM_DATA s32 gDungeonSubMenuItemsCount = 0; extern bool8 sub_8045888(Entity *); @@ -339,9 +338,9 @@ void sub_8045064(void) for (i = 0; i < gDungeonSubMenuItemsCount; i++) { for (j = i + 1; j < gDungeonSubMenuItemsCount; j++) { - unkStruct_202EE44 temp; - unkStruct_202EE44 *iPtr = &gDungeonSubMenu[i]; - unkStruct_202EE44 *jPtr = &gDungeonSubMenu[j]; + SubMenuAction temp; + SubMenuAction *iPtr = &gDungeonSubMenu[i]; + SubMenuAction *jPtr = &gDungeonSubMenu[j]; if (gUnknown_80F7C50[iPtr->actionId].val > gUnknown_80F7C50[jPtr->actionId].val) { SWAP(*iPtr, *jPtr, temp); diff --git a/src/dungeon_ai.c b/src/dungeon_ai.c index 7ef3cf44c..2dafc7994 100644 --- a/src/dungeon_ai.c +++ b/src/dungeon_ai.c @@ -5,7 +5,7 @@ #include "code_803E724.h" #include "dungeon_message.h" #include "code_8077274_1.h" -#include "code_808417C.h" +#include "dungeon_random.h" #include "constants/ability.h" #include "constants/direction.h" #include "constants/dungeon_action.h" diff --git a/src/dungeon_cleared_window.c b/src/dungeon_cleared_window.c new file mode 100644 index 000000000..1fb3c51c9 --- /dev/null +++ b/src/dungeon_cleared_window.c @@ -0,0 +1,65 @@ +#include "global.h" +#include "globaldata.h" +#include "dungeon.h" +#include "dungeon_strings.h" +#include "input.h" +#include "text_1.h" +#include "code_803E668.h" + +extern void DungeonShowWindows(WindowTemplates *a0, bool8 a1); +extern void sub_8094558(u32 param_1, const u8 *param_2,UnkDungeonGlobal_unk1CE98_sub *param_3); +extern void PlayDungeonCompleteBGM(void); +extern void PlayDungeonFailBGM(void); +extern void PlayDungeonConfirmationSE(void); +extern void UpdateDungeonMusic(void); +extern u8 sub_8094D14(void); + +void ShowDungeonClearedWindow(void) +{ + WindowHeader header; + WindowTemplates windows = { + .id = { + [0] = { + .type = WINDOW_TYPE_WITH_HEADER, + .pos = {4, 3}, + .width = 22, + .height = 14, + .unk10 = 14, + .unk12 = 0, + .header = &header, + }, + [1] = WIN_TEMPLATE_DUMMY, + [2] = WIN_TEMPLATE_DUMMY, + [3] = WIN_TEMPLATE_DUMMY, + } + }; + + header.count = 1; + header.currId = 0; + header.width = 14; + header.f3 = 0; + windows.id[0].pos.y = 20; + DungeonShowWindows(&windows, TRUE); + if (gDungeon->unk1CE98.moveID > 549) { + PlayDungeonCompleteBGM(); + } + else { + PlayDungeonFailBGM(); + } + sub_8094558(0, gUnknown_80FE6E8,&gDungeon->unk1CE98); // The Last Outing + while(1) { + sub_803E668(0x36); + UpdateDungeonMusic(); + if (windows.id[0].pos.y >= 4){ + windows.id[0].pos.y--; + windows.id[0].unk0 = 0xa0; + DungeonShowWindows(&windows, TRUE); + continue; + } + if (sub_8094D14()) + break; + if (gRealInputs.pressed & A_BUTTON) + break; + } + PlayDungeonConfirmationSE(); +} diff --git a/src/dungeon_cutscene_articuno.c b/src/dungeon_cutscene_articuno.c new file mode 100644 index 000000000..d1fdebd8c --- /dev/null +++ b/src/dungeon_cutscene_articuno.c @@ -0,0 +1,320 @@ +#include "global.h" +#include "globaldata.h" +#include "code_800DAC0.h" +#include "code_800E9A8.h" +#include "dungeon_vram.h" +#include "code_803E668.h" +#include "code_8041AD0.h" +#include "code_804267C.h" +#include "code_80861A8.h" +#include "code_806CD90.h" +#include "code_80869E4.h" +#include "constants/bg_music.h" +#include "constants/direction.h" +#include "constants/friend_area.h" +#include "constants/weather.h" +#include "dungeon_items.h" +#include "dungeon_leader.h" +#include "dungeon_map_access.h" +#include "dungeon_message.h" +#include "dungeon_music.h" +#include "dungeon_misc.h" +#include "dungeon_logic.h" +#include "dungeon_random.h" +#include "dungeon_util_1.h" +#include "dungeon_util.h" +#include "exclusive_pokemon.h" +#include "friend_area.h" +#include "items.h" +#include "pokemon_3.h" +#include "pokemon.h" +#include "position_util.h" +#include "trap.h" +#include "math.h" +#include "dungeon_config.h" +#include "dungeon_boss_dialogue.h" + +extern void sub_8042B0C(Entity *); +extern u8 sub_806FD18(Entity *); +extern void sub_806FDF4(Entity *, Entity *, Entity **); +extern s32 GetCameraXPos(void); +extern s32 GetCameraYPos(void); +extern void sub_803F878(u32, s32); +extern void BgColorCallNullsub4(void); +extern void sub_8085EB0(void); +extern void sub_8049884(void); +extern void sub_8049B8C(void); +extern void ShowWholeRevealedDungeonMap(void); +extern void sub_8086A54(Entity *); +extern void ResetMonEntityData(EntityInfo *, u32); +extern void sub_8041888(u32); +extern u32 sub_80861F8(u32, Entity *, u32); +extern u8 sub_80860A8(u32); +extern void sub_8052D44(s16 *, Entity *, Entity *); +extern void sub_80464C8(Entity *, DungeonPos *, Item *); +extern void SetDungeonBGColorRGB(u32, u32, u32, u32, u32); +extern u32 sub_8085EC8(u32, u32, u32, DungeonPos *, u32); +extern void sub_807EAA0(u32, u32); +extern void sub_8072008(Entity *, Entity *, s16, u32, u32); +extern void sub_8085374(void); +extern u32 GetRandomFloorItem(u32); +extern bool8 sub_8085B80(struct_8085B80 *); +extern void sub_8086A3C(Entity *pokemon); +extern void SetupBossFightHP(Entity *pokemon, s32 newHP, u16 songIndex); +extern u8 sub_8086AE4(s16 _index); + +static void sub_8088484(Entity *param_1); +static void ArticunoScreenFlash(void); +static void sub_8088574(void); + +void sub_8087F54(void) +{ + Entity *leaderEntity; + Entity *articunoEntity; + + leaderEntity = xxx_call_GetLeader(); + articunoEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ARTICUNO); + DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); + sub_8085374(); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + sub_80855E4(sub_8086A3C); + SetFacingDirection(articunoEntity, DIRECTION_SOUTH); + sub_8086A3C(articunoEntity); + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y + -3); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_ARTICUNO); +} + +void sub_8087FB4(void) +{ + Entity *articunoEntity; + + articunoEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ARTICUNO); + DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); + sub_8085374(); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + SetFacingDirection(articunoEntity, DIRECTION_SOUTH); + sub_806CDD4(articunoEntity, 0xF, DIRECTION_SOUTH); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_ARTICUNO); +} + +void sub_8087FF8(void) +{ + Entity *leaderEntity; + Entity *articunoEntity; + + leaderEntity = xxx_call_GetLeader(); + articunoEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ARTICUNO); + sub_8085374(); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + sub_80855E4(sub_8086A3C); + if (sub_8086AE4(MONSTER_ARTICUNO)) { + sub_8068FE0(articunoEntity,0x21c,0); + } + else { + sub_8072008(articunoEntity,articunoEntity,gArticunoConfigLevel,0,0); + SetFacingDirection(articunoEntity, DIRECTION_SOUTH); + sub_8086A3C(articunoEntity); + } + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y + -3); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_ARTICUNO); +} + +void sub_8088088(u8 param_1, u8 param_2) +{ + if ((param_2 == 0xD || param_2 == 0xE || param_2 == 0xF) && (param_1 == 0xD)) { + sub_8097FA8(0x9); + gDungeon->unk2 = 1; + } +} + +void ArticunoPreFightDialogue(void) +{ + Entity *leaderEntity; + Entity *partnerEntity; + Entity *articunoEntity; + + leaderEntity = xxx_call_GetLeader(); + partnerEntity = GetPartnerEntity(); + articunoEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ARTICUNO); + sub_8086448(); + SpriteLookAroundEffect(partnerEntity); + DisplayDungeonDialogue(gArticunoPreFightDialogue_1); + sub_803E708(10,0x46); + sub_8086598(); + DungeonStopBGM(); + DisplayDungeonDialogue(&gArticunoPreFightDialogue_2); + sub_803E708(10,0x46); + sub_80869E4(partnerEntity,4,1,DIRECTION_EAST); + sub_80869E4(leaderEntity,4,2,DIRECTION_WEST); + DisplayDungeonDialogue(&gArticunoPreFightDialogue_3); + sub_803E708(10,0x46); + SetFacingDirection(leaderEntity, DIRECTION_WEST); + sub_803E708(4,0x46); + SetFacingDirection(leaderEntity, DIRECTION_NORTHWEST); + sub_803E708(4,0x46); + SetFacingDirection(leaderEntity, DIRECTION_WEST); + sub_803E708(4,0x46); + SetFacingDirection(leaderEntity, DIRECTION_SOUTHWEST); + sub_803E708(4,0x46); + SetFacingDirection(leaderEntity, DIRECTION_WEST); + sub_803E708(4,0x46); + SetFacingDirection(leaderEntity, DIRECTION_NORTHWEST); + sub_803E708(4,0x46); + SetFacingDirection(leaderEntity, DIRECTION_WEST); + sub_803E708(10,0x46); + DisplayDungeonDialogue(gArticunoPreFightDialogue_4); + sub_803E708(10,0x46); + DisplayDungeonDialogue(&gArticunoPreFightDialogue_5); + sub_803E708(10,0x46); + sub_80869E4(leaderEntity,4,1,DIRECTION_NORTH); + sub_80869E4(partnerEntity,4,2,DIRECTION_NORTH); + PlaySoundEffect(0x1d5); + SpriteLookAroundEffect(partnerEntity); + PlaySoundEffect(0x1d5); + SpriteLookAroundEffect(leaderEntity); + DisplayDungeonDialogue(&gArticunoPreFightDialogue_6); + sub_803E708(10,0x46); + DisplayDungeonDialogue(&gArticunoPreFightDialogue_7); + sub_803E708(10,0x46); + PlaySoundEffect(0); // snow flurry + gDungeon->weather.unkE265 = WEATHER_SNOW; + sub_807EAA0(0,1); + PlaySoundEffect(0x1ee); // flash effect? + sub_8088574(); + DisplayDungeonDialogue(&gArticunoPreFightDialogue_8); + sub_803E708(10,0x46); + ArticunoScreenFlash(); + sub_8086738(); + PlaySoundEffect(0x1da); + DisplayDungeonDialogue(&gArticunoPreFightDialogue_9); + sub_803E708(10,0x46); + PlaySoundEffect(0x1ea); + sub_8088484(articunoEntity); + sub_80865E8(); + ArticunoScreenFlash(); + DisplayDungeonDialogue(&gArticunoPreFightDialogue_10); + sub_806CDD4(articunoEntity,0xf,DIRECTION_SOUTH); + ArticunoScreenFlash(); + DisplayDungeonDialogue(&gArticunoPreFightDialogue_11); + sub_806CDD4(articunoEntity,0x10,DIRECTION_SOUTH); + ArticunoScreenFlash(); + DisplayDungeonDialogue(&gArticunoPreFightDialogue_12); + sub_806CDD4(articunoEntity,0xf,DIRECTION_SOUTH); + sub_803E708(0x10,0x46); + SetupBossFightHP(articunoEntity,0x1c2,MUS_BOSS_BATTLE); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); +} + +void ArticunoReFightDialogue(void) +{ + Entity *leaderEntity; + Entity *articunoEntity; + + leaderEntity = xxx_call_GetLeader(); + articunoEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ARTICUNO); + gDungeon->weather.unkE265 = WEATHER_SNOW; + sub_807EAA0(0,1); + sub_803E708(10,0x46); + DisplayDungeonDialogue(&gArticunoReFightDialogue_1); + sub_806CDD4(articunoEntity,0x10,DIRECTION_SOUTH); + ArticunoScreenFlash(); + DisplayDungeonDialogue(&gArticunoReFightDialogue_2); + ArticunoScreenFlash(); + DisplayDungeonDialogue(&gArticunoReFightDialogue_3); + sub_806CDD4(articunoEntity,0xf,DIRECTION_SOUTH); + sub_803E708(0x28,0x46); + SetupBossFightHP(articunoEntity,0x1c2,MUS_BOSS_BATTLE); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); +} + +void ArticunoPostStoryPreFightDialogue(void) +{ + Entity *leaderEntity; + Entity *articunoEntity; + + leaderEntity = xxx_call_GetLeader(); + articunoEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ARTICUNO); + sub_8086448(); + if (sub_8086AE4(MONSTER_ARTICUNO)) { + sub_80866C4(&gUnknown_8102A9C); + } + else { + gDungeon->weather.unkE265 = WEATHER_SNOW; + sub_807EAA0(0,1); + ArticunoScreenFlash(); + sub_8086738(); + PlaySoundEffect(0x1da); + DisplayDungeonDialogue(&gArticunoPostStoryPreFightDialogue_1); + sub_803E708(10,0x46); + sub_8088484(articunoEntity); + ArticunoScreenFlash(); + DisplayDungeonDialogue(&gArticunoPostStoryPreFightDialogue_2); + sub_806CDD4(articunoEntity,0xf,DIRECTION_SOUTH); + ArticunoScreenFlash(); + DisplayDungeonDialogue(&gArticunoPostStoryPreFightDialogue_3); + sub_806CDD4(articunoEntity,0x10,DIRECTION_SOUTH); + ArticunoScreenFlash(); + DisplayDungeonDialogue(&gArticunoPostStoryPreFightDialogue_4); + ArticunoScreenFlash(); + DisplayDungeonDialogue(&gArticunoPostStoryPreFightDialogue_5); + sub_806CDD4(articunoEntity,0xf,DIRECTION_SOUTH); + sub_803E708(0x28,0x46); + SetupBossFightHP(articunoEntity,0x1c2,MUS_BOSS_BATTLE); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); + } +} + +static void sub_8088484(Entity *param_1) +{ + int iVar1; + + GetEntInfo(param_1)->unk15C = 1; + GetEntInfo(param_1)->unk15E = 0; + PlaySoundEffect(0x1ea); + for(iVar1 = 250; iVar1 >= 0; iVar1 -= 5) + { + GetEntInfo(param_1)->unk174 = IntToF248_2(iVar1); + SetDungeonBGColorRGB(iVar1,iVar1,iVar1 / 2,1,0); + DungeonRunFrameActions(0x46); + } +} + +static void ArticunoScreenFlash(void) +{ + int iVar1; + + PlaySoundEffect(0x2ad); + for(iVar1 = 250; iVar1 > 0x95; iVar1 -= 10) + { + SetDungeonBGColorRGB(iVar1 / 2,iVar1,iVar1,1,1); + DungeonRunFrameActions(0x46); + } + sub_803E708(4,0x46); + for(iVar1 = 250; iVar1 > 199; iVar1 -= 10) + { + SetDungeonBGColorRGB(0,iVar1,iVar1,1,1); + DungeonRunFrameActions(0x46); + } + sub_803E708(4,0x46); + for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10) + { + SetDungeonBGColorRGB(iVar1 / 2,iVar1,iVar1,1,1); + DungeonRunFrameActions(0x46); + } + sub_803E708(4,0x46); + sub_8085EB0(); +} + +static void sub_8088574(void) +{ + int iVar1; + + for(iVar1 = 0; iVar1 <= 80; iVar1 += 8) + { + SetDungeonBGColorRGB(iVar1,iVar1,iVar1,0,0); + DungeonRunFrameActions(0x46); + } +} diff --git a/src/dungeon_cutscene_celebi.c b/src/dungeon_cutscene_celebi.c new file mode 100644 index 000000000..bd4c57fd4 --- /dev/null +++ b/src/dungeon_cutscene_celebi.c @@ -0,0 +1,274 @@ +#include "global.h" +#include "globaldata.h" +#include "code_800DAC0.h" +#include "code_800E9A8.h" +#include "dungeon_vram.h" +#include "code_803E668.h" +#include "code_8041AD0.h" +#include "code_804267C.h" +#include "code_80861A8.h" +#include "code_806CD90.h" +#include "code_80869E4.h" +#include "constants/bg_music.h" +#include "constants/direction.h" +#include "constants/friend_area.h" +#include "constants/weather.h" +#include "dungeon_items.h" +#include "dungeon_leader.h" +#include "dungeon_map_access.h" +#include "dungeon_message.h" +#include "dungeon_music.h" +#include "dungeon_misc.h" +#include "dungeon_logic.h" +#include "dungeon_random.h" +#include "dungeon_util_1.h" +#include "dungeon_util.h" +#include "exclusive_pokemon.h" +#include "friend_area.h" +#include "items.h" +#include "pokemon_3.h" +#include "pokemon.h" +#include "position_util.h" +#include "trap.h" +#include "math.h" +#include "dungeon_config.h" +#include "dungeon_boss_dialogue.h" + +extern void sub_8042B0C(Entity *); +extern u8 sub_806FD18(Entity *); +extern void sub_806FDF4(Entity *, Entity *, Entity **); +extern s32 GetCameraXPos(void); +extern s32 GetCameraYPos(void); +extern void sub_803F878(u32, s32); +extern void BgColorCallNullsub4(void); +extern void sub_8085EB0(void); +extern void sub_8049884(void); +extern void sub_8049B8C(void); +extern void ShowWholeRevealedDungeonMap(void); +extern void sub_8086A54(Entity *); +extern void ResetMonEntityData(EntityInfo *, u32); +extern void sub_8041888(u32); +extern u32 sub_80861F8(u32, Entity *, u32); +extern u8 sub_80860A8(u32); +extern void sub_8052D44(s16 *, Entity *, Entity *); +extern void sub_80464C8(Entity *, DungeonPos *, Item *); +extern void SetDungeonBGColorRGB(u32, u32, u32, u32, u32); +extern u32 sub_8085EC8(u32, u32, u32, DungeonPos *, u32); +extern void sub_807EAA0(u32, u32); +extern void sub_8072008(Entity *, Entity *, s16, u32, u32); +extern void sub_8085374(void); +extern u32 GetRandomFloorItem(u32); +extern bool8 sub_8085B80(struct_8085B80 *); +extern void sub_8086A3C(Entity *pokemon); +extern void SetupBossFightHP(Entity *pokemon, s32 newHP, u16 songIndex); +extern u8 sub_8086AE4(s16 _index); + +static void sub_808C8E0(Entity *entity); +static void sub_808C9B0(Entity *param_1); + +void sub_808C5C0(void) +{ + Entity * leaderEntity; + Entity * celebiEntity; + + u32 XPos; + s32 YPos; + + leaderEntity = xxx_call_GetLeader(); + celebiEntity = GetEntityFromMonsterBehavior(BEHAVIOR_CELEBI); + DungeonStartNewBGM(MUS_FRIEND_AREA_HEALING_FOREST); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + SetFacingDirection(celebiEntity, DIRECTION_SOUTH); + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y); + XPos = GetCameraXPos(); + YPos = GetCameraYPos(); + sub_803F878(XPos,YPos - 0x1000); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_CELEBI); +} + +void nullsub_100(u8 r0, u8 r1, u8 r3) +{ +} + +void CelebiJoinDialogue(void) +{ + Entity *leaderEntity; + s32 state; + s32 menuChoice; + Entity *celebiEntity; + + leaderEntity = xxx_call_GetLeader(); + celebiEntity = GetEntityFromMonsterBehavior(BEHAVIOR_CELEBI); + if ((HasRecruitedMon(MONSTER_CELEBI)) || (!sub_806FD18(celebiEntity))) + { + sub_8068FE0(celebiEntity,0x21c,0); + SpriteLookAroundEffect(leaderEntity); + sub_803E708(10,0x46); + // ......... + DisplayDungeonDialogue(&gCelebiJoinDialogue_10); + } + else + { + SpriteLookAroundEffect(leaderEntity); + sub_803E708(10,0x46); + SpriteShockEffect(leaderEntity); + sub_803E708(10,0x46); + // Oh? There's someone there. + DisplayDungeonDialogue(&gCelebiJoinDialogue_1); + sub_803E708(10,0x46); + sub_8086598(); + sub_8086598(); + sub_8086598(); + sub_8086598(); + // The Time-Traveling Pokemon {POKEMON_2} (Celebi)! + DisplayDungeonDialogue(&gCelebiJoinDialogue_2); + PlaySoundEffect(0x1c7); + sub_806CDD4(celebiEntity,10,DIRECTION_SOUTH); + sub_803E708(0x14,0x46); + sub_806CE68(celebiEntity, DIRECTION_SOUTH); + sub_803E708(4,0x46); + PlaySoundEffect(0x1c7); + sub_806CDD4(celebiEntity,10,DIRECTION_SOUTH); + DisplayDungeonDialogue(&gCelebiJoinDialogue_3); + sub_803E708(10,0x46); + state = 0; + + do + { + switch(state) + { + case 0: + do + { + menuChoice = DisplayDungeonMenuMessage(0,gPtrPurityForestAllowCelebiToJoinText, gPurityForestAllowCelebiToJoinPrompt,0x701); + } while (menuChoice < 1); + + sub_803E708(10,0x46); + + if (menuChoice == 1) + { + DungeonStopBGM(); + PlaySoundEffect(0xcc); + while (IsFanfareSEPlaying_2(0xcc) != 0) { + DungeonRunFrameActions(0x46); + } + DungeonStartNewBGM(MUS_FRIEND_AREA_HEALING_FOREST); + PlaySoundEffect(0x1c7); + sub_80861D4(celebiEntity,0xd,DIRECTION_SOUTH); + sub_803E708(0x37,0x46); + PlaySoundEffect(0x1d5); + sub_803E708(0x1a,0x46); + PlaySoundEffect(0x1d5); + sub_803E708(0x1c,0x46); + DisplayDungeonDialogue(&gCelebiJoinDialogue_4); + sub_803E708(10,0x46); + sub_806FDF4(leaderEntity,celebiEntity,&celebiEntity); + DungeonStartNewBGM(MUS_FRIEND_AREA_HEALING_FOREST); + DisplayDungeonDialogue(&gCelebiJoinDialogue_5); + sub_803E708(10,0x46); + PlaySoundEffect(0x1c7); + sub_80861D4(celebiEntity,0xd,DIRECTION_SOUTH); + sub_803E708(0x37,0x46); + PlaySoundEffect(0x1d5); + sub_803E708(0x1a,0x46); + PlaySoundEffect(0x1d5); + sub_803E708(0x1b,0x46); + DisplayDungeonDialogue(&gCelebiJoinDialogue_6); + sub_803E708(10,0x46); + state = 2; + } + else + { + state = 1; + } + break; + case 1: + do + { + menuChoice = DisplayDungeonMenuMessage(0,gPtrPurityForestRefuseCelebiConfirmText, gPurityForestRefuseCelebiConfirmPrompt,0x701); + } while (menuChoice < 1); + if (menuChoice == 1) + { + state = 0; + } + else + { + sub_803E708(10,0x46); + DisplayDungeonDialogue(&gCelebiJoinDialogue_7); + sub_80861F8(0x3e,celebiEntity,1); + sub_803E708(0x18,0x46); + sub_80861F8(0x3e,celebiEntity,1); + sub_803E708(0xe,0x46); + DisplayDungeonDialogue(&gCelebiJoinDialogue_8); + sub_803E708(10,0x46); + sub_808C8E0(celebiEntity); + DisplayDungeonDialogue(&gCelebiJoinDialogue_9); + sub_803E708(10,0x46); + state = 2; + } + break; + } + } while (state != 2); + } + DungeonFadeOutBGM(0x1e); + sub_803E708(0x1e,0x46); + gDungeon->unk2 = 1; +} + +static void sub_808C8E0(Entity *entity) +{ + s32 iVar1; + + PlaySoundEffect(0x1a5); + sub_806CDD4(entity, 0, DIRECTION_SOUTH); + for(iVar1 = 0; iVar1 < 16; iVar1++){ + GetEntInfo(entity)->unk174 = IntToF248_2(iVar1); + DungeonRunFrameActions(0x46); + } + for(iVar1 = 16; iVar1 < 200; iVar1 += 4){ + GetEntInfo(entity)->unk174 = IntToF248_2(iVar1); + DungeonRunFrameActions(0x46); + } + sub_8086A3C(entity); +} + +void sub_808C938(void) +{ + sub_80855E4(sub_808C9B0); +} + +void sub_808C948(Entity *entity, u8 param_2) +{ + bool8 flag; + s32 index; + Entity *pokeEntity; + + if (param_2 == 0x37) { + flag = FALSE; + for(index = 0; index < DUNGEON_MAX_WILD_POKEMON; index++){ + pokeEntity = gDungeon->wildPokemon[index]; + if ((pokeEntity != entity) && (EntityIsValid(pokeEntity))) { + flag = TRUE; + break; + } + } + if (!flag) { + gDungeon->unk2 = 1; + } + } +} + +void sub_808C998(void) +{ + // Defeat the opposing team to win + // Be careful, your opponents are tough + DisplayDungeonDialogue(&gUnknown_8106720); + sub_803E708(0xA, 0x46); +} + +static void sub_808C9B0(Entity *param_1) +{ + GetEntInfo(param_1)->action.direction = DIRECTION_NORTH; + sub_806CE68(param_1, DIRECTION_NORTH); +} diff --git a/src/dungeon_cutscene_deoxys.c b/src/dungeon_cutscene_deoxys.c new file mode 100644 index 000000000..3809a24d1 --- /dev/null +++ b/src/dungeon_cutscene_deoxys.c @@ -0,0 +1,175 @@ +#include "global.h" +#include "globaldata.h" +#include "code_800DAC0.h" +#include "code_800E9A8.h" +#include "dungeon_vram.h" +#include "code_803E668.h" +#include "code_8041AD0.h" +#include "code_804267C.h" +#include "code_80861A8.h" +#include "code_806CD90.h" +#include "code_80869E4.h" +#include "constants/bg_music.h" +#include "constants/direction.h" +#include "constants/friend_area.h" +#include "constants/weather.h" +#include "dungeon_items.h" +#include "dungeon_leader.h" +#include "dungeon_map_access.h" +#include "dungeon_message.h" +#include "dungeon_music.h" +#include "dungeon_misc.h" +#include "dungeon_logic.h" +#include "dungeon_random.h" +#include "dungeon_util_1.h" +#include "dungeon_util.h" +#include "exclusive_pokemon.h" +#include "friend_area.h" +#include "items.h" +#include "pokemon_3.h" +#include "pokemon.h" +#include "position_util.h" +#include "trap.h" +#include "math.h" +#include "dungeon_config.h" +#include "dungeon_boss_dialogue.h" + +extern s32 gDungeonBrightness; + +extern void sub_8042B0C(Entity *); +extern u8 sub_806FD18(Entity *); +extern void sub_806FDF4(Entity *, Entity *, Entity **); +extern s32 GetCameraXPos(void); +extern s32 GetCameraYPos(void); +extern void sub_803F878(u32, s32); +extern void BgColorCallNullsub4(void); +extern void sub_8085EB0(void); +extern void sub_8049884(void); +extern void sub_8049B8C(void); +extern void ShowWholeRevealedDungeonMap(void); +extern void sub_8086A54(Entity *); +extern void ResetMonEntityData(EntityInfo *, u32); +extern void sub_8041888(u32); +extern u32 sub_80861F8(u32, Entity *, u32); +extern u8 sub_80860A8(u32); +extern void sub_8052D44(s16 *, Entity *, Entity *); +extern void sub_80464C8(Entity *, DungeonPos *, Item *); +extern void SetDungeonBGColorRGB(u32, u32, u32, u32, u32); +extern u32 sub_8085EC8(u32, u32, u32, DungeonPos *, u32); +extern void sub_807EAA0(u32, u32); +extern void sub_8072008(Entity *, Entity *, s16, u32, u32); +extern void sub_8085374(void); +extern u32 GetRandomFloorItem(u32); +extern bool8 sub_8085B80(struct_8085B80 *); +extern void sub_8086A3C(Entity *pokemon); +extern void SetupBossFightHP(Entity *pokemon, s32 newHP, u16 songIndex); +extern u8 sub_8086AE4(s16 _index); + +static void DeoxysScreenFlash(void); +static void sub_808C550(void); +static void sub_808C590(Entity *r0); +static void SetupDeoxysFacingDirection(Entity *deoxysEntity); +static void SetupDeoxysFightHP(Entity *deoxysEntity); + +void sub_808C3A0(void) +{ + Entity * leaderEntity; + + leaderEntity = xxx_call_GetLeader(); + DungeonStopBGM(); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + sub_80855E4(sub_8086A3C); + if (HasRecruitedMon(MONSTER_DEOXYS_NORMAL)) { + sub_808563C(sub_808C590); + } + else { + gDungeon->unk7 = 1; + sub_808563C(SetupDeoxysFacingDirection); + } + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 3); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_DEOXYS_NORMAL); +} + +void sub_808C414(u8 param_1,u8 param_2,u8 param_3) +{ + if ((param_2 == 0x35) && (param_1 == 0x1D)) { + gDungeon->unk2 = 1; + DungeonStartNewBGM(MUS_RAYQUAZAS_DOMAIN); + } +} + +void DeoxysPreFightDialogue(void) +{ + Entity * leaderEntity; + + leaderEntity = xxx_call_GetLeader(); + sub_8086448(); + if (HasRecruitedMon(MONSTER_DEOXYS_NORMAL)) { + // There appears to be no one here. + // It's impossible to go any further + sub_80866C4(&gDeoxysPreFightDialogue_5); + } + else { + DisplayDungeonDialogue(&gDeoxysPreFightDialogue_1); + DungeonFadeInNewBGM(MUS_RAYQUAZAS_DOMAIN, 0x3c); + sub_808C550(); + DisplayDungeonDialogue(&gDeoxysPreFightDialogue_2); + DeoxysScreenFlash(); + DisplayDungeonDialogue(&gDeoxysPreFightDialogue_3); + DeoxysScreenFlash(); + DisplayDungeonDialogue(&gDeoxysPreFightDialogue_4); + sub_803E708(10,0x46); + sub_808563C(SetupDeoxysFightHP); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); + } +} + +static void DeoxysScreenFlash(void) +{ + s32 iVar1; + + PlaySoundEffect(0x2c1); + for(iVar1 = 250; iVar1 > 149; iVar1 -= 10){ + SetDungeonBGColorRGB(iVar1,0,0,1,1); + DungeonRunFrameActions(0x46); + } + sub_803E708(10,0x46); + for(iVar1 = 250; iVar1 > 199; iVar1 -= 10){ + SetDungeonBGColorRGB(iVar1,iVar1,0,1,1); + DungeonRunFrameActions(0x46); + } + sub_803E708(10,0x46); + for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10){ + SetDungeonBGColorRGB(iVar1,0,0,1,1); + DungeonRunFrameActions(0x46); + } + sub_803E708(10,0x46); + sub_8085EB0(); +} + +static void sub_808C550(void) +{ + gDungeonBrightness = 0x1f; + SetDungeonBGColorRGB(0,0,0,1,1); + BgColorCallNullsub4(); + DungeonRunFrameActions(0x46); + gDungeon->unk7 = 0; + DeoxysScreenFlash(); +} + +static void sub_808C590(Entity *r0) +{ + sub_8068FE0(r0, 0x21C, 0); +} + +static void SetupDeoxysFacingDirection(Entity *deoxysEntity) +{ + SetFacingDirection(deoxysEntity, DIRECTION_SOUTH); +} + +static void SetupDeoxysFightHP(Entity *deoxysEntity) +{ + SetupBossFightHP(deoxysEntity, 950, MUS_BATTLE_WITH_RAYQUAZA); +} + diff --git a/src/dungeon_cutscene_empty_summit.c b/src/dungeon_cutscene_empty_summit.c new file mode 100644 index 000000000..1f530f63c --- /dev/null +++ b/src/dungeon_cutscene_empty_summit.c @@ -0,0 +1,73 @@ +#include "global.h" +#include "globaldata.h" +#include "code_800DAC0.h" +#include "code_800E9A8.h" +#include "dungeon_vram.h" +#include "code_803E668.h" +#include "code_8041AD0.h" +#include "code_804267C.h" +#include "code_80861A8.h" +#include "code_806CD90.h" +#include "code_80869E4.h" +#include "constants/bg_music.h" +#include "constants/direction.h" +#include "constants/friend_area.h" +#include "constants/weather.h" +#include "dungeon_items.h" +#include "dungeon_leader.h" +#include "dungeon_map_access.h" +#include "dungeon_message.h" +#include "dungeon_music.h" +#include "dungeon_misc.h" +#include "dungeon_logic.h" +#include "dungeon_random.h" +#include "dungeon_util_1.h" +#include "dungeon_util.h" +#include "exclusive_pokemon.h" +#include "friend_area.h" +#include "items.h" +#include "pokemon_3.h" +#include "pokemon.h" +#include "position_util.h" +#include "trap.h" +#include "math.h" +#include "dungeon_config.h" +#include "dungeon_boss_dialogue.h" + +extern void sub_8086A3C(Entity *pokemon); + +void sub_80885A0(void) +{ + DungeonFadeOutBGM(0x3c); + sub_803E708(0x3c,0x46); + DungeonStopBGM(); + gDungeon->unk7 = 1; +} + +void sub_80885C4(void) +{ + Entity * leaderEntity; + + leaderEntity = xxx_call_GetLeader(); + DungeonFadeOutBGM(0x3c); + sub_803E708(0x3c,0x46); + DungeonStopBGM(); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + sub_80855E4(sub_8086A3C); + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 3); +} + +void sub_8088608(void) +{ + gDungeon->unk2 = 1; +} + +void sub_8088618(void) +{ + sub_8086448(); + // The mountain's summit... + // But there is no one here + // It's time to go back + sub_80866C4(&gUnknown_8102B10); +} diff --git a/src/dungeon_cutscene_entei.c b/src/dungeon_cutscene_entei.c new file mode 100644 index 000000000..ae35ce2fb --- /dev/null +++ b/src/dungeon_cutscene_entei.c @@ -0,0 +1,195 @@ +#include "global.h" +#include "globaldata.h" +#include "code_800DAC0.h" +#include "code_800E9A8.h" +#include "dungeon_vram.h" +#include "code_803E668.h" +#include "code_8041AD0.h" +#include "code_804267C.h" +#include "code_80861A8.h" +#include "code_806CD90.h" +#include "code_80869E4.h" +#include "constants/bg_music.h" +#include "constants/direction.h" +#include "constants/friend_area.h" +#include "constants/weather.h" +#include "dungeon_items.h" +#include "dungeon_leader.h" +#include "dungeon_map_access.h" +#include "dungeon_message.h" +#include "dungeon_music.h" +#include "dungeon_misc.h" +#include "dungeon_logic.h" +#include "dungeon_random.h" +#include "dungeon_util_1.h" +#include "dungeon_util.h" +#include "exclusive_pokemon.h" +#include "friend_area.h" +#include "items.h" +#include "pokemon_3.h" +#include "pokemon.h" +#include "position_util.h" +#include "trap.h" +#include "math.h" +#include "dungeon_config.h" +#include "dungeon_boss_dialogue.h" + +extern void sub_8042B0C(Entity *); +extern u8 sub_806FD18(Entity *); +extern void sub_806FDF4(Entity *, Entity *, Entity **); +extern s32 GetCameraXPos(void); +extern s32 GetCameraYPos(void); +extern void sub_803F878(u32, s32); +extern void BgColorCallNullsub4(void); +extern void sub_8085EB0(void); +extern void sub_8049884(void); +extern void sub_8049B8C(void); +extern void ShowWholeRevealedDungeonMap(void); +extern void sub_8086A54(Entity *); +extern void ResetMonEntityData(EntityInfo *, u32); +extern void sub_8041888(u32); +extern u32 sub_80861F8(u32, Entity *, u32); +extern u8 sub_80860A8(u32); +extern void sub_8052D44(s16 *, Entity *, Entity *); +extern void sub_80464C8(Entity *, DungeonPos *, Item *); +extern void SetDungeonBGColorRGB(u32, u32, u32, u32, u32); +extern u32 sub_8085EC8(u32, u32, u32, DungeonPos *, u32); +extern void sub_807EAA0(u32, u32); +extern void sub_8072008(Entity *, Entity *, s16, u32, u32); +extern void sub_8085374(void); +extern u32 GetRandomFloorItem(u32); +extern bool8 sub_8085B80(struct_8085B80 *); +extern void sub_8086A3C(Entity *pokemon); +extern void SetupBossFightHP(Entity *pokemon, s32 newHP, u16 songIndex); +extern u8 sub_8086AE4(s16 _index); + +static void EnteiScreenFlash(void); + +void sub_8089C44(void) +{ + Entity * leaderEntity; + Entity * EnteiEntity; + + leaderEntity = xxx_call_GetLeader(); + EnteiEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ENTEI); + DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + SetFacingDirection(EnteiEntity, DIRECTION_SOUTH); + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_ENTEI); +} + +void sub_8089C90(void) +{ + Entity * leaderEntity; + Entity * EnteiEntity; + + leaderEntity = xxx_call_GetLeader(); + EnteiEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ENTEI); + DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + if (HasRecruitedMon(MONSTER_ENTEI)) { + sub_8068FE0(EnteiEntity,0x21c,0); + } + else { + SetFacingDirection(EnteiEntity, DIRECTION_SOUTH); + } + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_ENTEI); +} + +void sub_8089CFC(u8 param_1, u8 param_2) +{ + if ((param_2 == 0x20 || param_2 == 0x21 || param_2 == 0x22) && (param_1 == 0x12)) { + sub_8097FA8(0x15); + gDungeon->unk2 = 1; + } +} + +void EnteiPreFightDialogue(void) +{ + Entity * leaderEntity; + Entity * EnteiEntity; + + leaderEntity = xxx_call_GetLeader(); + EnteiEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ENTEI); + EnteiScreenFlash(); + DisplayDungeonDialogue(&gEnteiPreFightDialogue_1); + EnteiScreenFlash(); + DisplayDungeonDialogue(&gEnteiPreFightDialogue_2); + EnteiScreenFlash(); + DisplayDungeonDialogue(&gEnteiPreFightDialogue_3); + sub_803E708(10,70); + SetupBossFightHP(EnteiEntity,600,MUS_BOSS_BATTLE); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); +} + +void EnteiReFightDialogue(void) +{ + Entity * leaderEntity; + Entity * EnteiEntity; + + leaderEntity = xxx_call_GetLeader(); + EnteiEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ENTEI); + EnteiScreenFlash(); + DisplayDungeonDialogue(&gEnteiReFightDialogue_1); + EnteiScreenFlash(); + DisplayDungeonDialogue(&gEnteiReFightDialogue_2); + EnteiScreenFlash(); + DisplayDungeonDialogue(&gEnteiReFightDialogue_3); + sub_803E708(10,70); + SetupBossFightHP(EnteiEntity,600,MUS_BOSS_BATTLE); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); +} + +void EnteiPostStoryPreFightDialogue(void) +{ + Entity * leaderEntity; + Entity * EnteiEntity; + + leaderEntity = xxx_call_GetLeader(); + EnteiEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ENTEI); + if (HasRecruitedMon(MONSTER_ENTEI)) { + sub_80866C4(&gEnteiPostStoryPreFightDialogue_4); + } + else { + EnteiScreenFlash(); + DisplayDungeonDialogue(&gEnteiPostStoryPreFightDialogue_1); + EnteiScreenFlash(); + DisplayDungeonDialogue(&gEnteiPostStoryPreFightDialogue_2); + EnteiScreenFlash(); + DisplayDungeonDialogue(&gEnteiPostStoryPreFightDialogue_3); + sub_803E708(10,70); + SetupBossFightHP(EnteiEntity,600,MUS_BOSS_BATTLE); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); + } +} + +static void EnteiScreenFlash(void) +{ + s32 iVar1; + + PlaySoundEffect(0x1ed); + for(iVar1 = 250; iVar1 > 149; iVar1 -= 10) + { + SetDungeonBGColorRGB(iVar1, iVar1 / 2, iVar1 / 2, 1, 1); + DungeonRunFrameActions(70); + } + sub_803E708(10,70); + for(iVar1 = 250; iVar1 > 199; iVar1 -= 10) + { + SetDungeonBGColorRGB(iVar1, 0, 0, 1, 1); + DungeonRunFrameActions(70); + } + sub_803E708(10,70); + for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10) + { + SetDungeonBGColorRGB(iVar1, iVar1 / 2, iVar1 / 2, 1, 1); + DungeonRunFrameActions(70); + } + sub_803E708(10,70); + sub_8085EB0(); +} + diff --git a/src/dungeon_cutscene_groudon.c b/src/dungeon_cutscene_groudon.c new file mode 100644 index 000000000..3f8fd7e2d --- /dev/null +++ b/src/dungeon_cutscene_groudon.c @@ -0,0 +1,386 @@ +#include "global.h" +#include "globaldata.h" +#include "code_800DAC0.h" +#include "code_800E9A8.h" +#include "dungeon_vram.h" +#include "code_803E668.h" +#include "code_8041AD0.h" +#include "code_804267C.h" +#include "code_80861A8.h" +#include "code_806CD90.h" +#include "code_80869E4.h" +#include "constants/bg_music.h" +#include "constants/direction.h" +#include "constants/friend_area.h" +#include "constants/weather.h" +#include "dungeon_items.h" +#include "dungeon_leader.h" +#include "dungeon_map_access.h" +#include "dungeon_message.h" +#include "dungeon_music.h" +#include "dungeon_misc.h" +#include "dungeon_logic.h" +#include "dungeon_random.h" +#include "dungeon_util_1.h" +#include "dungeon_util.h" +#include "exclusive_pokemon.h" +#include "friend_area.h" +#include "items.h" +#include "pokemon_3.h" +#include "pokemon.h" +#include "position_util.h" +#include "trap.h" +#include "math.h" +#include "dungeon_config.h" +#include "dungeon_boss_dialogue.h" + +extern void sub_8042B0C(Entity *); +extern u8 sub_806FD18(Entity *); +extern void sub_806FDF4(Entity *, Entity *, Entity **); +extern s32 GetCameraXPos(void); +extern s32 GetCameraYPos(void); +extern void sub_803F878(u32, s32); +extern void BgColorCallNullsub4(void); +extern void sub_8085EB0(void); +extern void sub_8049884(void); +extern void sub_8049B8C(void); +extern void ShowWholeRevealedDungeonMap(void); +extern void sub_8086A54(Entity *); +extern void ResetMonEntityData(EntityInfo *, u32); +extern void sub_8041888(u32); +extern u32 sub_80861F8(u32, Entity *, u32); +extern u8 sub_80860A8(u32); +extern void sub_8052D44(s16 *, Entity *, Entity *); +extern void sub_80464C8(Entity *, DungeonPos *, Item *); +extern void SetDungeonBGColorRGB(u32, u32, u32, u32, u32); +extern u32 sub_8085EC8(u32, u32, u32, DungeonPos *, u32); +extern void sub_807EAA0(u32, u32); +extern void sub_8072008(Entity *, Entity *, s16, u32, u32); +extern void sub_8085374(void); +extern u32 GetRandomFloorItem(u32); +extern bool8 sub_8085B80(struct_8085B80 *); +extern void sub_8086A3C(Entity *pokemon); +extern void SetupBossFightHP(Entity *pokemon, s32 newHP, u16 songIndex); +extern u8 sub_8086AE4(s16 _index); + +static void SceneGroudonMovement(Entity * groudonEntity); +static void GroudonScreenFlash(void); +static void GroudonScreenFlash2(void); + +void sub_808862C(void) +{ + Entity * leaderEntity; + Entity * alakazamEntity; + Entity * groudonEntity; + + leaderEntity = xxx_call_GetLeader(); + alakazamEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ALAKAZAM_1); + groudonEntity = GetEntityFromMonsterBehavior(BEHAVIOR_GROUDON_2); + DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); + sub_80867F4(); + sub_8085374(); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + sub_80855E4(sub_8086A3C); + SetFacingDirection(alakazamEntity, DIRECTION_NORTH); + sub_80861D4(alakazamEntity,0xd,DIRECTION_NORTH); + SetFacingDirection(groudonEntity, DIRECTION_SOUTH); + sub_8086A3C(groudonEntity); + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y -3); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_GROUDON); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[3], MONSTER_ALAKAZAM); +} + +void sub_80886C4(void) +{ + Entity * leaderEntity; + Entity * alakazamEntity; + Entity * groudonEntity; + + u32 XPos; + s32 YPos; + + leaderEntity = xxx_call_GetLeader(); + alakazamEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ALAKAZAM_1); + groudonEntity = GetEntityFromMonsterBehavior(BEHAVIOR_GROUDON_2); + PlaySoundEffect(0x3e5); + sub_80867F4(); + sub_8085374(); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + sub_8068FE0(alakazamEntity,0x21c,0); + SetFacingDirection(groudonEntity, DIRECTION_SOUTH); + sub_8086A3C(groudonEntity); + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y); + XPos = GetCameraXPos(); + YPos = GetCameraYPos(); + sub_803F878(XPos,YPos + -0x1000); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_GROUDON); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[3], MONSTER_ALAKAZAM); +} + +void sub_808875C(void) +{ + Entity * leaderEntity; + Entity * alakazamEntity; + Entity * groudonEntity; + + leaderEntity = xxx_call_GetLeader(); + alakazamEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ALAKAZAM_1); + groudonEntity = GetEntityFromMonsterBehavior(BEHAVIOR_GROUDON_2); + sub_80867F4(); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + sub_80855E4(sub_8086A3C); + sub_8068FE0(alakazamEntity,0x21c,0); + if (sub_8086AE4(MONSTER_GROUDON)) { + sub_8068FE0(groudonEntity,0x21c,0); + } + else { + sub_8072008(groudonEntity,groudonEntity,gGroudonConfigLevel,0,0); + SetFacingDirection(groudonEntity, DIRECTION_SOUTH); + sub_80861D4(groudonEntity,0xf,DIRECTION_SOUTH); + } + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 3); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_GROUDON); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[3], MONSTER_ALAKAZAM); +} + +void sub_8088818(u8 param_1, u8 param_2) +{ + if ((param_2 == 0x12 || param_2 == 0x13 || param_2 == 0x14) && (param_1 == 0xE)) { + sub_8097FA8(0xC); + gDungeon->unk2 = 1; + } +} + +void sub_8088848(void) +{ + sub_8086854(); +} + +void GroudonPreFightDialogue(void) +{ + Entity * leaderEntity; + Entity * partnerEntity; + Entity * alakazamEntity; + Entity * groudonEntity; + + leaderEntity = xxx_call_GetLeader(); + partnerEntity = GetPartnerEntity(); + alakazamEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ALAKAZAM_1); + groudonEntity = GetEntityFromMonsterBehavior(BEHAVIOR_GROUDON_2); + sub_8086448(); + DisplayDungeonDialogue(GroudonPreFightDialogue_1); + sub_803E708(10,0x46); + sub_803E708(0x3c,0x46); + DisplayDungeonDialogue(&GroudonPreFightDialogue_2); + sub_803E708(10,0x46); + sub_8086838(1,1,1); + sub_808680C(); + sub_803E708(0x3c,0x46); + sub_808682C(); + sub_803E708(0x1e,0x46); + DisplayDungeonDialogue(&GroudonPreFightDialogue_3); + sub_803E708(10,0x46); + sub_8086838(1,1,1); + sub_808680C(); + sub_803E708(0x3c,0x46); + DisplayDungeonDialogue(&GroudonPreFightDialogue_4); + sub_803E708(10,0x46); + GroudonScreenFlash(); + DisplayDungeonDialogue(&GroudonPreFightDialogue_5); + sub_803E708(10,0x46); + DisplayDungeonDialogue(&GroudonPreFightDialogue_6); + sub_803E708(10,0x46); + PlaySoundEffect(0x1d5); + SpriteLookAroundEffect(partnerEntity); + DisplayDungeonDialogue(&GroudonPreFightDialogue_7); + sub_803E708(10,0x46); + sub_808682C(); + sub_803E708(0x3c,0x46); + sub_80861B8(alakazamEntity,6,DIRECTION_NORTH); + PlaySoundEffect(0x205); + sub_8086738(); + sub_8068FE0(alakazamEntity,0x21c,0); + DisplayDungeonDialogue(&GroudonPreFightDialogue_8); + sub_803E708(10,0x46); + DisplayDungeonDialogue(&GroudonPreFightDialogue_9); + sub_803E708(10,0x46); + sub_8085930(DIRECTION_NORTH); + sub_8086764(); + sub_803E708(0x28,0x46); + PlaySoundEffect(0x1d5); + SpriteLookAroundEffect(partnerEntity); + DisplayDungeonDialogue(GroudonPreFightDialogue_10); + sub_803E708(10,0x46); + sub_8086838(1,1,1); + sub_808680C(); + sub_803E708(0x3c,0x46); + DisplayDungeonDialogue(GroudonPreFightDialogue_11); + sub_803E708(10,0x46); + DungeonStopBGM(); + GroudonScreenFlash2(); + sub_803E708(0x1e,0x46); + DisplayDungeonDialogue(&GroudonPreFightDialogue_12); + sub_803E708(10,0x46); + DisplayDungeonDialogue(&GroudonPreFightDialogue_13); + sub_803E708(10,0x46); + sub_803E708(0x1e,0x46); + sub_808682C(); + sub_803E708(0x3c,0x46); + PlaySoundEffect(0x1fa); + sub_8086738(); + sub_8085930(DIRECTION_NORTH); + DisplayDungeonDialogue(GroudonPreFightDialogue_14); + sub_803E708(10,0x46); + sub_8086A54(groudonEntity); + sub_8085930(DIRECTION_NORTH); + sub_8086764(); + SetupBossFightHP(groudonEntity,500,MUS_BOSS_BATTLE); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); +} + +void GroudonReFightDialogue(void) +{ + Entity * leaderEntity; + Entity * groudonEntity; + + leaderEntity = xxx_call_GetLeader(); + groudonEntity = GetEntityFromMonsterBehavior(BEHAVIOR_GROUDON_2); + sub_8086838(1,1,1); + sub_808680C(); + sub_803E708(0x3c,0x46); + DisplayDungeonDialogue(gGroudonReFightDialogue_1); + sub_803E708(10,0x46); + GroudonScreenFlash(); + sub_803E708(0x1e,0x46); + DisplayDungeonDialogue(gGroudonReFightDialogue_2); + sub_803E708(10,0x46); + DisplayDungeonDialogue(&gGroudonReFightDialogue_3); + sub_803E708(10,0x46); + sub_808682C(); + sub_803E708(0x3c,0x46); + DungeonStopBGM(); + PlaySoundEffect(0x1fa); + sub_8086738(); + DisplayDungeonDialogue(gGroudonReFightDialogue_4); + sub_803E708(10,0x46); + sub_8086A54(groudonEntity); + sub_8085930(DIRECTION_NORTH); + sub_8086764(); + SetupBossFightHP(groudonEntity,500,MUS_BOSS_BATTLE); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); +} + +void GroudonPostStoryPreFightDialogue(void) +{ + Entity * leaderEntity; + Entity * groudonEntity; + + leaderEntity = xxx_call_GetLeader(); + groudonEntity = GetEntityFromMonsterBehavior(BEHAVIOR_GROUDON_2); + sub_8086448(); + if (sub_8086AE4(MONSTER_GROUDON)) { + sub_80866C4(&gUnknown_8103488); + } + else{ + DisplayDungeonDialogue(&gGroudonPostStoryPreFightDialogue_1); + sub_803E708(10,0x46); + SceneGroudonMovement(groudonEntity); + SceneGroudonMovement(groudonEntity); + DisplayDungeonDialogue(&gGroudonPostStoryPreFightDialogue_2); + PlaySoundEffect(0x1f6); + GroudonScreenFlash(); + DisplayDungeonDialogue(&gGroudonPostStoryPreFightDialogue_3); + PlaySoundEffect(0x1f6); + GroudonScreenFlash(); + DisplayDungeonDialogue(&gGroudonPostStoryPreFightDialogue_4); + sub_803E708(10,0x46); + SetupBossFightHP(groudonEntity,500,MUS_BOSS_BATTLE); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); + } +} + +// Moves Groudon down in a walking fashion +static void SceneGroudonMovement(Entity * groudonEntity) +{ + int iVar1; + + sub_8086848(0x18,0x10); + sub_806CDD4(groudonEntity,0,DIRECTION_SOUTH); + for(iVar1 = 0; iVar1 < 0x2C; iVar1++) + { + if ((iVar1 == 10) || (iVar1 == 0x20)) { + PlaySoundEffect(0x1f9); + sub_8086838(0,1,0); + sub_808680C(); + } + if ((iVar1 - 10U < 0xc) || (iVar1 > 0x1f)) { + IncreaseEntityPixelPos(groudonEntity,0,0x100); + } + DungeonRunFrameActions(0x46); + } + sub_80856C8(groudonEntity,groudonEntity->pos.x,groudonEntity->pos.y + 1); + sub_80861D4(groudonEntity,0xf,DIRECTION_SOUTH); + sub_803E708(10,0x46); + sub_808682C(); + sub_8085930(DIRECTION_NORTH); + sub_803E708(0x22,0x46); +} + +static void GroudonScreenFlash(void) +{ + s32 iVar1; + + for(iVar1 = 250; iVar1 > 0x95; iVar1 -= 10) + { + SetDungeonBGColorRGB(iVar1,iVar1 / 2,iVar1 / 2,1,1); + DungeonRunFrameActions(0x46); + } + sub_803E708(10,0x46); + + for(iVar1 = 250; iVar1 > 199; iVar1 -= 10) + { + SetDungeonBGColorRGB(iVar1,iVar1 / 2,0,1,1); + DungeonRunFrameActions(0x46); + } + sub_803E708(10,0x46); + + for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10) + { + SetDungeonBGColorRGB(iVar1,iVar1 / 2,iVar1 / 2,1,1); + DungeonRunFrameActions(0x46); + } + sub_803E708(10,0x46); + sub_8085EB0(); +} + +static void GroudonScreenFlash2(void) +{ + s32 iVar1; + + for(iVar1 = 250; iVar1 > 0x95; iVar1 -= 10) + { + SetDungeonBGColorRGB(iVar1,iVar1 / 2,iVar1 / 2,1,1); + DungeonRunFrameActions(0x46); + } + sub_803E708(10,0x46); + + for(iVar1 = 250; iVar1 > 199; iVar1 -= 10) + { + SetDungeonBGColorRGB(iVar1,iVar1 / 2,0,1,1); + DungeonRunFrameActions(0x46); + } + sub_803E708(10,0x46); + + for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10) + { + SetDungeonBGColorRGB(iVar1,iVar1 / 2,iVar1 / 2,1,1); + DungeonRunFrameActions(0x46); + } + sub_803E708(10,0x46); + sub_8085EB0(); +} + + diff --git a/src/dungeon_cutscene_hooh.c b/src/dungeon_cutscene_hooh.c new file mode 100644 index 000000000..647069299 --- /dev/null +++ b/src/dungeon_cutscene_hooh.c @@ -0,0 +1,245 @@ +#include "global.h" +#include "globaldata.h" +#include "code_800DAC0.h" +#include "code_800E9A8.h" +#include "dungeon_vram.h" +#include "code_803E668.h" +#include "code_8041AD0.h" +#include "code_804267C.h" +#include "code_80861A8.h" +#include "code_806CD90.h" +#include "code_80869E4.h" +#include "constants/bg_music.h" +#include "constants/direction.h" +#include "constants/friend_area.h" +#include "constants/weather.h" +#include "dungeon_items.h" +#include "dungeon_leader.h" +#include "dungeon_map_access.h" +#include "dungeon_message.h" +#include "dungeon_music.h" +#include "dungeon_misc.h" +#include "dungeon_logic.h" +#include "dungeon_random.h" +#include "dungeon_util_1.h" +#include "dungeon_util.h" +#include "exclusive_pokemon.h" +#include "friend_area.h" +#include "items.h" +#include "pokemon_3.h" +#include "pokemon.h" +#include "position_util.h" +#include "trap.h" +#include "math.h" +#include "dungeon_config.h" +#include "dungeon_boss_dialogue.h" + +extern void sub_8042B0C(Entity *); +extern u8 sub_806FD18(Entity *); +extern void sub_806FDF4(Entity *, Entity *, Entity **); +extern s32 GetCameraXPos(void); +extern s32 GetCameraYPos(void); +extern void sub_803F878(u32, s32); +extern void BgColorCallNullsub4(void); +extern void sub_8085EB0(void); +extern void sub_8049884(void); +extern void sub_8049B8C(void); +extern void ShowWholeRevealedDungeonMap(void); +extern void sub_8086A54(Entity *); +extern void ResetMonEntityData(EntityInfo *, u32); +extern void sub_8041888(u32); +extern u32 sub_80861F8(u32, Entity *, u32); +extern u8 sub_80860A8(u32); +extern void sub_8052D44(s16 *, Entity *, Entity *); +extern void sub_80464C8(Entity *, DungeonPos *, Item *); +extern void SetDungeonBGColorRGB(u32, u32, u32, u32, u32); +extern u32 sub_8085EC8(u32, u32, u32, DungeonPos *, u32); +extern void sub_807EAA0(u32, u32); +extern void sub_8072008(Entity *, Entity *, s16, u32, u32); +extern void sub_8085374(void); +extern u32 GetRandomFloorItem(u32); +extern bool8 sub_8085B80(struct_8085B80 *); +extern void sub_8086A3C(Entity *pokemon); +extern void SetupBossFightHP(Entity *pokemon, s32 newHP, u16 songIndex); +extern u8 sub_8086AE4(s16 _index); + +static void HoOhDropInEffect(Entity * param_1); +static void HoOhScreenFlash(void); + +void sub_808A608(void) +{ + Entity * leaderEntity; + Entity * HoOhEntity; + + leaderEntity = xxx_call_GetLeader(); + HoOhEntity = GetEntityFromMonsterBehavior(BEHAVIOR_HO_OH); + DungeonStartNewBGM(MUS_FRIEND_AREA_RAINBOW_PEAK); + sub_80867F4(); + sub_8086838(0,0,0); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + SetFacingDirection(HoOhEntity, DIRECTION_SOUTH); + sub_8086A3C(HoOhEntity); + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y + -6); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_HO_OH); +} + +void sub_808A668(void) +{ + Entity * leaderEntity; + Entity * HoOhEntity; + + leaderEntity = xxx_call_GetLeader(); + HoOhEntity = GetEntityFromMonsterBehavior(BEHAVIOR_HO_OH); + DungeonStartNewBGM(MUS_FRIEND_AREA_RAINBOW_PEAK); + sub_80867F4(); + sub_8086838(0,0,0); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + if (HasRecruitedMon(MONSTER_HO_OH)) { + sub_8068FE0(HoOhEntity,0x21c,0); + } + else { + SetFacingDirection(HoOhEntity, DIRECTION_SOUTH); + sub_8086A3C(HoOhEntity); + } + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 6); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_HO_OH); +} + +void sub_808A6E8(u8 param_1, u8 param_2) +{ + if ((param_2 == 0x29 || param_2 == 0x2A) && (param_1 == 0x15)) { + sub_8097FA8(0x1A); + gDungeon->unk2 = 1; + } +} + +void sub_808A718(void) +{ + sub_8086854(); +} + +void HoOhPreFightDialogue(void) +{ + Entity * leaderEntity; + Entity * HoOhEntity; + PixelPos local_14; + + leaderEntity = xxx_call_GetLeader(); + HoOhEntity = GetEntityFromMonsterBehavior(BEHAVIOR_HO_OH); + local_14.x = leaderEntity->pixelPos.x; + local_14.y = leaderEntity->pixelPos.y + -0x1000; + ShiftCameraToPosition(&local_14,0x88); + sub_803E708(0x40,70); + DisplayDungeonDialogue(&gHoOhPreFightDialogue_1); + sub_803E708(10,70); + HoOhScreenFlash(); + DisplayDungeonDialogue(&gHoOhPreFightDialogue_2); + sub_803E708(10,70); + sub_80855E4(sub_80868F4); + sub_808680C(); + PlaySoundEffect(0x1c5); + sub_803E708(0xfa,70); + HoOhDropInEffect(HoOhEntity); + StopSoundEffect(0x1c5); + sub_808682C(); + sub_80855E4(sub_8086910); + sub_8085930(DIRECTION_NORTH); + DisplayDungeonDialogue(&gHoOhPreFightDialogue_3); + DisplayDungeonDialogue(&gHoOhPreFightDialogue_4); + sub_803E708(0x1e,70); + sub_803E708(0x1e,70); + HoOhScreenFlash(); + DisplayDungeonDialogue(&gHoOhPreFightDialogue_5); + HoOhScreenFlash(); + DisplayDungeonDialogue(&gHoOhPreFightDialogue_6); + sub_803E708(10,70); + SetupBossFightHP(HoOhEntity,800,MUS_BATTLE_WITH_RAYQUAZA); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); +} + +void HoOhReFightDialogue(void) +{ + Entity * leaderEntity; + Entity * HoOhEntity; + PixelPos local_14; + + leaderEntity = xxx_call_GetLeader(); + HoOhEntity = GetEntityFromMonsterBehavior(BEHAVIOR_HO_OH); + + local_14.x = leaderEntity->pixelPos.x; + local_14.y = leaderEntity->pixelPos.y + -0x1000; + ShiftCameraToPosition(&local_14,0x88); + sub_803E708(0x40,70); + if (HasRecruitedMon(MONSTER_HO_OH)) { + sub_80866C4(&HoOhReFightDialogue_5); + } + else { + DisplayDungeonDialogue(&HoOhReFightDialogue_1); + HoOhScreenFlash(); + sub_80855E4(sub_80868F4); + sub_808680C(); + sub_803E708(10,70); + HoOhDropInEffect(HoOhEntity); + sub_808682C(); + sub_80855E4(sub_8086910); + sub_8085930(DIRECTION_NORTH); + DisplayDungeonDialogue(&HoOhReFightDialogue_2); + HoOhScreenFlash(); + DisplayDungeonDialogue(&HoOhReFightDialogue_3); + HoOhScreenFlash(); + DisplayDungeonDialogue(&HoOhReFightDialogue_4); + sub_803E708(10,70); + SetupBossFightHP(HoOhEntity,800,MUS_BATTLE_WITH_RAYQUAZA); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); + } +} + +static void HoOhDropInEffect(Entity * param_1) +{ + s24_8 iVar1; + s24_8 iVar2; + + GetEntInfo(param_1)->unk15E = 0; + iVar2 = IntToF248(200); + iVar1 = IntToF248(12); + PlaySoundEffect(0x1f8); + while( 1 ) { + iVar2.raw -= iVar1.raw; + iVar1 = F248_Sub(iVar1, FloatToF248(0.375)); + if (F248LessThanFloat(iVar1, 0.08)) { + iVar1 = FloatToF248_2(0.08); + } + if (F248LessThanInt(iVar2, 0)) break; + GetEntInfo(param_1)->unk174 = iVar2; + DungeonRunFrameActions(70); + } + GetEntInfo(param_1)->unk174 = IntToF248_2(0); +} + +static void HoOhScreenFlash(void) +{ + s32 iVar1; + + PlaySoundEffect(0x1ed); + for(iVar1 = 250; iVar1 > 149; iVar1 -= 10) + { + SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,1); + DungeonRunFrameActions(70); + } + sub_803E708(10,70); + for(iVar1 = 250; iVar1 > 199; iVar1 -= 10) + { + SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,1); + DungeonRunFrameActions(70); + } + sub_803E708(10,70); + for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10) + { + SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,1); + DungeonRunFrameActions(70); + } + sub_803E708(10,70); + sub_8085EB0(); +} diff --git a/src/dungeon_cutscene_jirachi.c b/src/dungeon_cutscene_jirachi.c new file mode 100644 index 000000000..3fb5af261 --- /dev/null +++ b/src/dungeon_cutscene_jirachi.c @@ -0,0 +1,567 @@ +#include "global.h" +#include "globaldata.h" +#include "code_800DAC0.h" +#include "code_800E9A8.h" +#include "dungeon_vram.h" +#include "code_803E668.h" +#include "code_8041AD0.h" +#include "code_804267C.h" +#include "code_80861A8.h" +#include "code_806CD90.h" +#include "code_80869E4.h" +#include "constants/bg_music.h" +#include "constants/direction.h" +#include "constants/friend_area.h" +#include "constants/weather.h" +#include "dungeon_items.h" +#include "dungeon_leader.h" +#include "dungeon_map_access.h" +#include "dungeon_message.h" +#include "dungeon_music.h" +#include "dungeon_misc.h" +#include "dungeon_logic.h" +#include "dungeon_random.h" +#include "dungeon_util_1.h" +#include "dungeon_util.h" +#include "exclusive_pokemon.h" +#include "friend_area.h" +#include "items.h" +#include "pokemon_3.h" +#include "pokemon.h" +#include "position_util.h" +#include "trap.h" +#include "math.h" +#include "dungeon_config.h" +#include "dungeon_boss_dialogue.h" + +extern s32 gDungeonBrightness; + +extern void sub_8042B0C(Entity *); +extern u8 sub_806FD18(Entity *); +extern void sub_806FDF4(Entity *, Entity *, Entity **); +extern s32 GetCameraXPos(void); +extern s32 GetCameraYPos(void); +extern void sub_803F878(u32, s32); +extern void BgColorCallNullsub4(void); +extern void sub_8085EB0(void); +extern void sub_8049884(void); +extern void sub_8049B8C(void); +extern void ShowWholeRevealedDungeonMap(void); +extern void sub_8086A54(Entity *); +extern void ResetMonEntityData(EntityInfo *, u32); +extern void sub_8041888(u32); +extern u32 sub_80861F8(u32, Entity *, u32); +extern u8 sub_80860A8(u32); +extern void sub_8052D44(s16 *, Entity *, Entity *); +extern void sub_80464C8(Entity *, DungeonPos *, Item *); +extern void SetDungeonBGColorRGB(u32, u32, u32, u32, u32); +extern u32 sub_8085EC8(u32, u32, u32, DungeonPos *, u32); +extern void sub_807EAA0(u32, u32); +extern void sub_8072008(Entity *, Entity *, s16, u32, u32); +extern void sub_8085374(void); +extern u32 GetRandomFloorItem(u32); +extern bool8 sub_8085B80(struct_8085B80 *); +extern void sub_8086A3C(Entity *pokemon); +extern void SetupBossFightHP(Entity *pokemon, s32 newHP, u16 songIndex); +extern u8 sub_8086AE4(s16 _index); + +static void sub_808B50C(void); +static void JirachiWish(void); +static void JirachiWishGrantFlash(void); +static void sub_808BB3C(DungeonPos *pos1); +static void sub_808BBA8(Entity *jirachiEntity); +static void JirachiDropInEffect(Entity *jirachiEntity); +static void JirachiSpinEffect(Entity * jirachiEntity); +static void JirachiWishGrantDialogue(Entity *jirachiEntity); +static void CreateJirachiWishWarpTile(void); +static void EnableJirachiWishWarpTile(void); +static u8 JirachiFriendAreaSearch(void); + +void sub_808B2F4(void) +{ + Entity * leaderEntity; + Entity * jirachiEntity; + + leaderEntity = xxx_call_GetLeader(); + jirachiEntity = GetEntityFromMonsterBehavior(BEHAVIOR_JIRACHI); + DungeonStartNewBGM(MUS_FRIEND_AREA_FOREST); + CreateJirachiWishWarpTile(); + sub_8049ED4(); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + sub_80855E4(sub_8086A3C); + SetFacingDirection(jirachiEntity, DIRECTION_SOUTH); + sub_8086A3C(jirachiEntity); + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 3); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_JIRACHI); +} + +void sub_808B35C(void) +{ + Entity * leaderEntity; + Entity * jirachiEntity; + + leaderEntity = xxx_call_GetLeader(); + jirachiEntity = GetEntityFromMonsterBehavior(BEHAVIOR_JIRACHI); + DungeonStartNewBGM(MUS_FRIEND_AREA_FOREST); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + sub_80855E4(sub_8086A3C); + if (HasRecruitedMon(MONSTER_JIRACHI)) { + sub_8068FE0(jirachiEntity,0x21c,0); + } + else { + SetFacingDirection(jirachiEntity, DIRECTION_SOUTH); + sub_8086A3C(jirachiEntity); + CreateJirachiWishWarpTile(); + sub_8049ED4(); + + } + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 3); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_JIRACHI); +} + +void sub_808B3E4(u8 param_1, u8 param_2, u8 param_3) +{ + u8 uVar1; + if ((param_2 == 0x31 || param_2 == 0x32) && (param_1 == 0x1A)) { + sub_8097FA8(0x1E); + if(param_3 != 0) + { + gDungeon->unk2 = 1; + } + else { + uVar1 = gDungeon->unk1356C; + if(sub_80860A8(0x36) != 0) + { + JirachiWish(); + } + else + { + sub_808B50C(); + } + gDungeon->unk1356C = uVar1; + ShowWholeRevealedDungeonMap(); + } + } +} + +void JirachiPreFightDialogue(void) +{ + Entity * leaderEntity; + Entity * jirachiEntity; + + leaderEntity = xxx_call_GetLeader(); + jirachiEntity = GetEntityFromMonsterBehavior(BEHAVIOR_JIRACHI); + sub_8086448(); + sub_803E708(0x40,70); + DisplayDungeonDialogue(&gJirachiPreFightDialogue_1); + sub_803E708(10,70); + SpriteLookAroundEffect(leaderEntity); + sub_803E708(10,70); + DisplayDungeonDialogue(&gJirachiPreFightDialogue_2); + sub_80861F8(0x37,jirachiEntity,1); + sub_80855E4(SpriteShockEffect); + sub_803E708(0x3c,70); + JirachiDropInEffect(jirachiEntity); + sub_803E708(0x5a,70); + DisplayDungeonDialogue(&gJirachiPreFightDialogue_3); + sub_803E708(10,70); + DisplayDungeonDialogue(&gJirachiPreFightDialogue_4); + sub_803E708(10,70); + SetupBossFightHP(jirachiEntity,0x15e,MUS_BATTLE_WITH_RAYQUAZA); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); +} + +static void sub_808B50C(void) +{ + Entity * jirachiEntity; + + jirachiEntity = GetEntityFromMonsterBehavior(BEHAVIOR_JIRACHI); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_JIRACHI); + sub_80855E4(sub_808BBA8); + sub_808BBA8(jirachiEntity); + sub_8041888(0); + GetEntInfo(jirachiEntity)->unk15C = 1; + GetEntInfo(jirachiEntity)->unk15E = 0; + sub_80861B8(jirachiEntity,0xe,DIRECTION_SOUTH); + DungeonFadeOutBGM(0x1e); + sub_803E708(0x1e,70); + // Fwaaaahhhh + DisplayDungeonDialogue(&gUnknown_810554C); + DungeonStartNewBGM(MUS_FRIEND_AREA_FOREST); + // I think I had a dream, and I was fighting in it + // Did I imagine it? + // I'm sleepy so I'm going back to sleep. + DisplayDungeonDialogue(&gUnknown_8105558); + sub_803E708(10,70); + JirachiSpinEffect(jirachiEntity); + DisplayDungeonDialogue(&gUnknown_81055F4); + sub_803E708(10,70); + gDungeon->unk2 = 1; +} + +static const u8 sJirachiItems[] = {ITEM_PROTEIN, ITEM_CALCIUM, ITEM_IRON, ITEM_ZINC, ITEM_JOY_SEED, ITEM_GINSENG, ITEM_LIFE_SEED, ITEM_SITRUS_BERRY}; + +static void JirachiWish(void) +{ + Entity *jirachiEntity; + DungeonPos *LeaderPos; + Entity *leaderEntity; + s32 wishChoice; + + jirachiEntity = GetEntityFromMonsterBehavior(BEHAVIOR_JIRACHI); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_JIRACHI); + sub_80855E4(sub_808BBA8); + sub_808BBA8(jirachiEntity); + sub_8041888(0); + GetEntInfo(jirachiEntity)->unk15C = 1; + GetEntInfo(jirachiEntity)->unk15E = 0; + sub_80861B8(jirachiEntity,0xe,DIRECTION_SOUTH); + sub_80855E4(sub_80861A8); + gDungeon->unk1356C = 1; + DungeonFadeOutBGM(0x1e); + sub_803E708(0x1e,0x46); + DisplayDungeonDialogue(&gUnknown_8105668); + sub_803E708(10,0x46); + PlaySoundEffect(0x1a7); + sub_803E708(0x96,0x46); + SpriteShockEffect(jirachiEntity); + DisplayDungeonDialogue(&gUnknown_8105674); + DungeonStartNewBGM(MUS_FRIEND_AREA_FOREST); + sub_803E708(10,0x46); + sub_80856E0(jirachiEntity, DIRECTION_SOUTH); + PlaySoundEffect(0x16a); + DisplayDungeonDialogue(&gUnknown_81056B8); + sub_803E708(10,0x46); + SpriteLookAroundEffect(jirachiEntity); + DisplayDungeonDialogue(&gUnknown_81056DC); + sub_803E708(10,0x46); + while( 1 ) { + while (1) { + wishChoice = DisplayDungeonMenuMessage(NULL,gUnknown_8105798,gUnknown_810579C,0x705); + if (wishChoice >= 1) break; + } + sub_803E708(10,0x46); + if (wishChoice == 1) { + s32 counter, index; + DungeonPos pos; + Item moneyItems [9]; + // Lots of Money + DisplayDungeonDialogue(&gUnknown_810581C); + sub_803E708(10,0x46); + JirachiWishGrantDialogue(jirachiEntity); + + for(counter = 0; counter < 6; counter++) + { + for(index = 0; index < 9; index++) + { + CreateItemWithStickyChance(&moneyItems[index], ITEM_POKE, 0); + } + pos.x = (jirachiEntity->pos.x + DungeonRandInt(3) - 1); + pos.y = (jirachiEntity->pos.y + DungeonRandInt(3) + -1); + if ((GetTileMut(pos.x, pos.y)->terrainType & 3) != 0) { + PlaySoundEffect(0x14c); + sub_808BB3C(&pos); + sub_8046860(jirachiEntity,&pos,moneyItems,9); + } + } + GetEntInfo(jirachiEntity)->unk15D = 0; + } + if (wishChoice == 2) { + s32 counter, index; + DungeonPos pos; + Item items [9]; + // Lots of Items + DisplayDungeonDialogue(&gUnknown_8105974); + sub_803E708(10,0x46); + JirachiWishGrantDialogue(jirachiEntity); + + for(counter = 0; counter < 6; counter++) + { + for(index = 0; index < 9; index++) + { + CreateItemWithStickyChance(&items[index], GetRandomFloorItem(0),0); + } + pos.x = (jirachiEntity->pos.x + DungeonRandInt(3) - 1); + pos.y = (jirachiEntity->pos.y + DungeonRandInt(3) + -1); + + if ((GetTileMut(pos.x, pos.y)->terrainType & 3) != 0) { + PlaySoundEffect(400); + sub_808BB3C(&pos); + sub_8046860(jirachiEntity,&pos,items,9); + } + } + GetEntInfo(jirachiEntity)->unk15D = 0; + } + + if (wishChoice == 3) + { + // A Friend Area + s32 friendArea = JirachiFriendAreaSearch(); + if (friendArea == NUM_FRIEND_AREAS) + { + // You want a friend area? But you already have many friend areas... + DisplayDungeonDialogue(&gUnknown_8105A08); + sub_803E708(10,0x46); + continue; + } + else + { + // You want a friend area? As you wish.. + DisplayDungeonDialogue(&gUnknown_8105AD4); + sub_803E708(10,0x46); + JirachiWishGrantDialogue(jirachiEntity); + GetEntInfo(jirachiEntity)->unk15D = 0; + DisplayDungeonDialogue(&gUnknown_8105B20); + UnlockFriendArea(friendArea); + PlaySoundEffect(0xd4); + leaderEntity = GetLeader(); + SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],leaderEntity,0); + WriteFriendAreaName(gFormatBuffer_Items[0],friendArea,FALSE); + // Obtained the friend area! + DisplayDungeonDialogue(&gUnknown_8105B68); + } + } + if (wishChoice == 4) { + s32 counter, index; + DungeonPos pos; + Item strengthItems [9]; + // More Strength.. + DisplayDungeonDialogue(&gUnknown_8105BA8); + sub_803E708(10,0x46); + JirachiWishGrantDialogue(jirachiEntity); + + for(counter = 0; counter < 5; counter++) + { + + for(index = 0; index < 4; index++) + { + CreateItemWithStickyChance(&strengthItems[index],sJirachiItems[DungeonRandInt(ARRAY_COUNT(sJirachiItems))],0); + } + + pos.x = (jirachiEntity->pos.x + DungeonRandInt(3) - 1); + pos.y = (jirachiEntity->pos.y + DungeonRandInt(3) + -1); + + if ((GetTileMut(pos.x, pos.y)->terrainType & 3) != 0) { + PlaySoundEffect(400); + sub_808BB3C(&pos); + sub_8046860(jirachiEntity,&pos,strengthItems,4); + } + } + GetEntInfo(jirachiEntity)->unk15D = 0; + DisplayDungeonDialogue(&gUnknown_8105BF4); + sub_803E708(10,0x46); + } + if (wishChoice == 5) { + s32 direction; + // Something Good... + DisplayDungeonDialogue(&gUnknown_8105D2C); + sub_803E708(10,0x46); + JirachiWishGrantDialogue(jirachiEntity); + GetEntInfo(jirachiEntity)->unk15D = 0; + DisplayDungeonDialogue(&gUnknown_8105D80); + sub_803E708(10,0x46); + LeaderPos = &GetLeader()->pos; + direction = GetDirectionTowardsPosition(&jirachiEntity->pos,LeaderPos); + SetFacingDirection(jirachiEntity,direction); + sub_803E708(10,0x46); + DisplayDungeonDialogue(&gUnknown_8105D9C); + sub_803E708(10,0x46); + gDungeon->unk644.unk30 = 1; + } + break; + } + + DisplayDungeonDialogue(&gUnknown_81058E0); + JirachiSpinEffect(jirachiEntity); + sub_803E708(10,0x46); + DisplayDungeonDialogue(&gUnknown_810593C); + sub_803E708(10,0x46); + EnableJirachiWishWarpTile(); +} + +void JirachiReFightDialogue(void) +{ + if(HasRecruitedMon(MONSTER_JIRACHI)) + { + sub_8086448(); + sub_80866C4(&gJirachiReFightDialogue_1); + } + else + { + JirachiPreFightDialogue(); + } +} + +static void JirachiWishGrantFlash(void) +{ + s32 iVar1; + + PlaySoundEffect(0x2c1); + gDungeonBrightness = 0x1f; + + for(iVar1 = 0xFA; iVar1 > 0x95; iVar1 -= 10) + { + SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,1); + DungeonRunFrameActions(0x46); + } + sub_803E708(10,0x46); + + for(iVar1 = 0xFA; iVar1 > 0xC7; iVar1 -= 10) + { + SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,1); + DungeonRunFrameActions(0x46); + } + sub_803E708(10,0x46); + + for(iVar1 = 0xFA; iVar1 >= 0; iVar1 -= 10) + { + SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,1); + DungeonRunFrameActions(0x46); + } + sub_803E708(10,0x46); + sub_8085EB0(); +} + +static void sub_808BB3C(DungeonPos *pos1) +{ + s32 x, y; + DungeonPos newPos; + + x = X_POS_TO_PIXELPOS(pos1->x); + newPos.x = x / 256; + + y = Y_POS_TO_PIXELPOS(pos1->y); + newPos.y = y / 256; + + sub_8085EC8(100,0,0,&newPos,0); +} + +static void sub_808BBA8(Entity *jirachiEntity) +{ + ResetMonEntityData(GetEntInfo(jirachiEntity),0); +} + +static void JirachiDropInEffect(Entity *jirachiEntity) +{ + s24_8 iVar1; + s24_8 iVar2; + + sub_80861F8(0x1b,jirachiEntity,0); + sub_8086A54(jirachiEntity); + sub_80861B8(jirachiEntity,0xe,DIRECTION_SOUTH); + iVar1 = IntToF248(160); + iVar2 = IntToF248(2); + PlaySoundEffect(0x1f8); + while (1) { + iVar1.raw = iVar1.raw - iVar2.raw; // FRAGILE! Subtraction and assignment below must use .raw + if (F248LessThanInt(iVar1, 24)) { + iVar2.raw = IntToF248_2(1).raw; + } + if (F248LessThanInt(iVar1, 0)) break; + GetEntInfo(jirachiEntity)->unk174 = iVar1; + DungeonRunFrameActions(0x46); + } + GetEntInfo(jirachiEntity)->unk174 = IntToF248_2(0); +} + +static void JirachiSpinEffect(Entity * jirachiEntity) +{ + s32 uVar1; + + PlaySoundEffect(0x298); + for(uVar1 = 0; uVar1 < 25; uVar1++){ + SetFacingDirection(jirachiEntity, uVar1 & DIRECTION_MASK); + sub_803E708(3,0x46); + } + GetEntInfo(jirachiEntity)->unk15E = 1; + PlaySoundEffect(0x27f); + sub_80861F8(99,jirachiEntity,1); +} + +static void JirachiWishGrantDialogue(Entity *jirachiEntity) +{ + u32 uVar2; + + GetEntInfo(jirachiEntity)->unk15D = 1; + // Nnnnnnnnnn! + DisplayDungeonDialogue(&gUnknown_81058A8); + PlaySoundEffect(0x375); + sub_80861F8(0x67,jirachiEntity,1); + PlaySoundEffect(0x2a8); + uVar2 = sub_80861F8(0x68,jirachiEntity,0); + // Taaaaaaaah! + DisplayDungeonDialogue(&gUnknown_81058C4); + if (sub_800E9A8(uVar2)) { + sub_800DC14(uVar2); + } + sub_803E708(10,0x46); + JirachiWishGrantFlash(); +} + +// Warp Tile is created but not enabled until the Wish is done with EnableJirachiWishWarpTile +static void CreateJirachiWishWarpTile(void) +{ + Tile *tile; + + tile = GetTileMut(gDungeon->unkE220[7].x, gDungeon->unkE220[7].y); + tile->terrainType &= ~(TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY); + tile->terrainType |= TERRAIN_TYPE_IMPASSABLE_WALL; + tile->terrainType &= ~TERRAIN_TYPE_STAIRS; + sub_8049884(); + sub_8049B8C(); + sub_8049ED4(); + ShowWholeRevealedDungeonMap(); +} + +static void EnableJirachiWishWarpTile(void) +{ + Tile *tile; + + tile = GetTileMut(gDungeon->unkE220[7].x, gDungeon->unkE220[7].y); + tile->terrainType &= ~(TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY); + tile->terrainType |= TERRAIN_TYPE_NORMAL; + tile->terrainType &= ~TERRAIN_TYPE_IMPASSABLE_WALL; + tile->terrainType |= TERRAIN_TYPE_STAIRS; + tile->unk8 = 1; + sub_8049884(); + sub_8049B8C(); + sub_8049ED4(); + ShowWholeRevealedDungeonMap(); +} + +static u8 JirachiFriendAreaSearch(void) +{ + u8 unlockCondition; + s32 friendAreaCounter; + s32 numUnlockableAreas; + u8 friendAreas[NUM_FRIEND_AREAS]; + u32 friendAreaIndex; + + // Build a copy of friend area list and keep track of + // how many are only Story Unlockable + numUnlockableAreas = 0; + for(friendAreaCounter = 1; friendAreaCounter < NUM_FRIEND_AREAS; friendAreaCounter++){ + unlockCondition = GetFriendAreaUnlockCondition(friendAreaCounter); + if (!(unlockCondition == UNLOCK_LEGENDARY_REQUEST)){ + if (!(unlockCondition == UNLOCK_WONDER_MAIL)){ + if(!gFriendAreas[friendAreaCounter]) { + friendAreas[numUnlockableAreas] = friendAreaCounter; + numUnlockableAreas++; + } + } + } + } + + if (numUnlockableAreas == 0) { + return NUM_FRIEND_AREAS; + } + else { + // Randomly pick 1 + friendAreaIndex = DungeonRandInt(numUnlockableAreas); + return friendAreas[friendAreaIndex]; + } +} + + diff --git a/src/dungeon_cutscene_kyogre.c b/src/dungeon_cutscene_kyogre.c new file mode 100644 index 000000000..64060fa06 --- /dev/null +++ b/src/dungeon_cutscene_kyogre.c @@ -0,0 +1,191 @@ +#include "global.h" +#include "globaldata.h" +#include "code_800DAC0.h" +#include "code_800E9A8.h" +#include "dungeon_vram.h" +#include "code_803E668.h" +#include "code_8041AD0.h" +#include "code_804267C.h" +#include "code_80861A8.h" +#include "code_806CD90.h" +#include "code_80869E4.h" +#include "constants/bg_music.h" +#include "constants/direction.h" +#include "constants/friend_area.h" +#include "constants/weather.h" +#include "dungeon_items.h" +#include "dungeon_leader.h" +#include "dungeon_map_access.h" +#include "dungeon_message.h" +#include "dungeon_music.h" +#include "dungeon_misc.h" +#include "dungeon_logic.h" +#include "dungeon_random.h" +#include "dungeon_util_1.h" +#include "dungeon_util.h" +#include "exclusive_pokemon.h" +#include "friend_area.h" +#include "items.h" +#include "pokemon_3.h" +#include "pokemon.h" +#include "position_util.h" +#include "trap.h" +#include "math.h" +#include "dungeon_config.h" +#include "dungeon_boss_dialogue.h" + +extern s32 gDungeonBrightness; + +extern void sub_8042B0C(Entity *); +extern u8 sub_806FD18(Entity *); +extern void sub_806FDF4(Entity *, Entity *, Entity **); +extern s32 GetCameraXPos(void); +extern s32 GetCameraYPos(void); +extern void sub_803F878(u32, s32); +extern void BgColorCallNullsub4(void); +extern void sub_8085EB0(void); +extern void sub_8049884(void); +extern void sub_8049B8C(void); +extern void ShowWholeRevealedDungeonMap(void); +extern void sub_8086A54(Entity *); +extern void ResetMonEntityData(EntityInfo *, u32); +extern void sub_8041888(u32); +extern u32 sub_80861F8(u32, Entity *, u32); +extern u8 sub_80860A8(u32); +extern void sub_8052D44(s16 *, Entity *, Entity *); +extern void sub_80464C8(Entity *, DungeonPos *, Item *); +extern void SetDungeonBGColorRGB(u32, u32, u32, u32, u32); +extern u32 sub_8085EC8(u32, u32, u32, DungeonPos *, u32); +extern void sub_807EAA0(u32, u32); +extern void sub_8072008(Entity *, Entity *, s16, u32, u32); +extern void sub_8085374(void); +extern u32 GetRandomFloorItem(u32); +extern bool8 sub_8085B80(struct_8085B80 *); +extern void sub_8086A3C(Entity *pokemon); +extern void SetupBossFightHP(Entity *pokemon, s32 newHP, u16 songIndex); +extern u8 sub_8086AE4(s16 _index); + +static void nullsub_99(void); +static void KyogreScreenFlash(void); +static void sub_808C360(void); + +void sub_808C10C(void) +{ + Entity * leaderEntity; + Entity * kyogreEntity; + + u32 XPos; + s32 YPos; + + leaderEntity = xxx_call_GetLeader(); + kyogreEntity = GetEntityFromMonsterBehavior(BEHAVIOR_KYOGRE); + DungeonStopBGM(); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + if (HasRecruitedMon(MONSTER_KYOGRE)) { + sub_8068FE0(kyogreEntity,0x21c,0); + } + else { + gDungeon->unk7 = 1; + SetFacingDirection(kyogreEntity, DIRECTION_SOUTH); + } + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y); + XPos = GetCameraXPos(); + YPos = GetCameraYPos(); + sub_803F878(XPos,YPos + -0x1000); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2],MONSTER_KYOGRE); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[3], MONSTER_GROUDON); +} + +void sub_808C1A4(u8 param_1,u8 param_2,u8 param_3) +{ + if ((param_2 == 0x34) && (param_1 == 0x1C)) { + gDungeon->unk2 = 1; + DungeonStartNewBGM(MUS_FRIEND_AREA_CRYPTIC_CAVE); + } +} + +void KyogrePreFightDialogue(void) +{ + Entity *leaderEntity; + Entity *KyogreEntity; + + leaderEntity = xxx_call_GetLeader(); + KyogreEntity = GetEntityFromMonsterBehavior(BEHAVIOR_KYOGRE); + DungeonStopBGM(); + if (HasRecruitedMon(MONSTER_KYOGRE)) { + DungeonFadeInNewBGM(MUS_FRIEND_AREA_CRYPTIC_CAVE,0x3c); + SpriteLookAroundEffect(leaderEntity); + sub_803E708(10,0x46); + DisplayDungeonDialogue(&gKyogrePreFightDialogue_8); + sub_803E708(10,0x46); + gDungeon->unk2 = 1; + } + else { + DisplayDungeonDialogue(&gKyogrePreFightDialogue_1); + sub_803E708(10,0x46); + DisplayDungeonDialogue(&gKyogrePreFightDialogue_2); + sub_803E708(10,0x46); + nullsub_99(); + sub_803E708(10,0x46); + // Gwwwwwooooooooh + DisplayDungeonDialogue(&gKyogrePreFightDialogue_3); + sub_803E708(10,0x46); + DungeonFadeInNewBGM(MUS_FRIEND_AREA_CRYPTIC_CAVE,0x3c); + sub_808C360(); + // My duels against {POKEMON_3} (Groudon) left us both exhausted + DisplayDungeonDialogue(&gKyogrePreFightDialogue_4); + KyogreScreenFlash(); + // I am {POKEMON_2} (Kyogre)! + // The lord of the sea! + DisplayDungeonDialogue(&gKyogrePreFightDialogue_5); + KyogreScreenFlash(); + // Witness the destructive force of my waves! + DisplayDungeonDialogue(&gKyogrePreFightDialogue_6); + KyogreScreenFlash(); + // Marvel at my awesome + // power! + DisplayDungeonDialogue(&gKyogrePreFightDialogue_7); + sub_803E708(10,0x46); + SetupBossFightHP(KyogreEntity,600,MUS_BOSS_BATTLE); + DungeonStartNewBGM(MUS_FRIEND_AREA_CRYPTIC_CAVE); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); + } +} + +static void nullsub_99(void) +{ +} + +static void KyogreScreenFlash(void) +{ + s32 iVar1; + + PlaySoundEffect(0x1f8); + for(iVar1 = 250; iVar1 > 149; iVar1 -= 10){ + SetDungeonBGColorRGB(0,0,iVar1,1,1); + DungeonRunFrameActions(0x46); + } + sub_803E708(10,0x46); + for(iVar1 = 250; iVar1 > 199; iVar1 -= 10){ + SetDungeonBGColorRGB(0,iVar1,iVar1,1,1); + DungeonRunFrameActions(0x46); + } + sub_803E708(10,0x46); + for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10){ + SetDungeonBGColorRGB(0,0,iVar1,1,1); + DungeonRunFrameActions(0x46); + } + sub_803E708(10,0x46); + sub_8085EB0(); +} + +static void sub_808C360(void) +{ + gDungeonBrightness = 0x1f; + SetDungeonBGColorRGB(0,0,0,1,1); + BgColorCallNullsub4(); + DungeonRunFrameActions(0x46); + gDungeon->unk7 = 0; + KyogreScreenFlash(); +} diff --git a/src/dungeon_cutscene_latios.c b/src/dungeon_cutscene_latios.c new file mode 100644 index 000000000..61dd707d6 --- /dev/null +++ b/src/dungeon_cutscene_latios.c @@ -0,0 +1,204 @@ +#include "global.h" +#include "globaldata.h" +#include "code_800DAC0.h" +#include "code_800E9A8.h" +#include "dungeon_vram.h" +#include "code_803E668.h" +#include "code_8041AD0.h" +#include "code_804267C.h" +#include "code_80861A8.h" +#include "code_806CD90.h" +#include "code_80869E4.h" +#include "constants/bg_music.h" +#include "constants/direction.h" +#include "constants/friend_area.h" +#include "constants/weather.h" +#include "dungeon_items.h" +#include "dungeon_leader.h" +#include "dungeon_map_access.h" +#include "dungeon_message.h" +#include "dungeon_music.h" +#include "dungeon_misc.h" +#include "dungeon_logic.h" +#include "dungeon_random.h" +#include "dungeon_util_1.h" +#include "dungeon_util.h" +#include "exclusive_pokemon.h" +#include "friend_area.h" +#include "items.h" +#include "pokemon_3.h" +#include "pokemon.h" +#include "position_util.h" +#include "trap.h" +#include "math.h" +#include "dungeon_config.h" +#include "dungeon_boss_dialogue.h" + +extern s32 gDungeonBrightness; + +extern void sub_8042B0C(Entity *); +extern u8 sub_806FD18(Entity *); +extern void sub_806FDF4(Entity *, Entity *, Entity **); +extern s32 GetCameraXPos(void); +extern s32 GetCameraYPos(void); +extern void sub_803F878(u32, s32); +extern void BgColorCallNullsub4(void); +extern void sub_8085EB0(void); +extern void sub_8049884(void); +extern void sub_8049B8C(void); +extern void ShowWholeRevealedDungeonMap(void); +extern void sub_8086A54(Entity *); +extern void ResetMonEntityData(EntityInfo *, u32); +extern void sub_8041888(u32); +extern u32 sub_80861F8(u32, Entity *, u32); +extern u8 sub_80860A8(u32); +extern void sub_8052D44(s16 *, Entity *, Entity *); +extern void sub_80464C8(Entity *, DungeonPos *, Item *); +extern void SetDungeonBGColorRGB(u32, u32, u32, u32, u32); +extern u32 sub_8085EC8(u32, u32, u32, DungeonPos *, u32); +extern void sub_807EAA0(u32, u32); +extern void sub_8072008(Entity *, Entity *, s16, u32, u32); +extern void sub_8085374(void); +extern u32 GetRandomFloorItem(u32); +extern bool8 sub_8085B80(struct_8085B80 *); +extern void sub_8086A3C(Entity *pokemon); +extern void SetupBossFightHP(Entity *pokemon, s32 newHP, u16 songIndex); +extern u8 sub_8086AE4(s16 _index); + +static void LatiosScreenFlash(void); + +void sub_808A9E4(void) +{ + Entity * leaderEntity; + Entity * LatiosEntity; + + leaderEntity = xxx_call_GetLeader(); + LatiosEntity = GetEntityFromMonsterBehavior(BEHAVIOR_LATIOS); + DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + sub_80855E4(sub_8086A3C); + SetFacingDirection(LatiosEntity, DIRECTION_NORTH); + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 4); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_LATIOS); +} + +void sub_808AA3C(void) +{ + Entity * leaderEntity; + Entity * LatiosEntity; + + leaderEntity = xxx_call_GetLeader(); + LatiosEntity = GetEntityFromMonsterBehavior(BEHAVIOR_LATIOS); + DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + sub_80855E4(sub_8086A3C); + SetFacingDirection(LatiosEntity, DIRECTION_NORTH); + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 3); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_LATIOS); +} + +void sub_808AA94(void) +{ + Entity * leaderEntity; + Entity * LatiosEntity; + + leaderEntity = xxx_call_GetLeader(); + LatiosEntity = GetEntityFromMonsterBehavior(BEHAVIOR_LATIOS); + DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + sub_80855E4(sub_8086A3C); + sub_8068FE0(LatiosEntity,0x21c,0); + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 3); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_LATIOS); +} + +void sub_808AAF0(u8 param_1, u8 param_2) +{ + if ((param_2 == 0x2B || param_2 == 0x2C || param_2 == 0x2D) && (param_1 == 0x16)) { + sub_8097FA8(0x1C); + gDungeon->unk2 = 1; + } +} + +void LatiosPreFightDialogue(void) +{ + Entity * leaderEntity; + Entity * LatiosEntity; + PixelPos local_18; + DungeonPos local_19; + + leaderEntity = xxx_call_GetLeader(); + LatiosEntity = GetEntityFromMonsterBehavior(BEHAVIOR_LATIOS); + + local_18.x = LatiosEntity->pixelPos.x; + local_18.y = LatiosEntity->pixelPos.y + (0x80 << 6); + local_19.y = 0x70; + local_19.x = 0xFC; + sub_8085EC8(0x1bd,0,0,&local_19,1); + + sub_803E708(0x1e,70); + sub_8086448(); + ShiftCameraToPosition(&local_18,0x18); + sub_803E708(2,70); + SpriteShockEffect(LatiosEntity); + sub_803E708(0x20,70); + sub_808692C(); + DisplayDungeonDialogue(&gLatiosPreFightDialogue_1); + LatiosScreenFlash(); + DisplayDungeonDialogue(&gLatiosPreFightDialogue_2); + LatiosScreenFlash(); + DisplayDungeonDialogue(&gLatiosPreFightDialogue_3); + sub_803E708(10,70); + SetupBossFightHP(LatiosEntity,600,MUS_BOSS_BATTLE); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); +} + +void LatiosReFightDialogue(void) +{ + Entity * leaderEntity; + Entity * LatiosEntity; + + leaderEntity = xxx_call_GetLeader(); + LatiosEntity = GetEntityFromMonsterBehavior(BEHAVIOR_LATIOS); + sub_8086448(); + sub_808692C(); + DisplayDungeonDialogue(&gLatiosReFightDialogue_1); + LatiosScreenFlash(); + DisplayDungeonDialogue(&gLatiosPreFightDialogue_2); + LatiosScreenFlash(); + DisplayDungeonDialogue(&gLatiosPreFightDialogue_3); + sub_803E708(10,70); + SetupBossFightHP(LatiosEntity,600,MUS_BOSS_BATTLE); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); +} + +void sub_808AC3C(void) +{ + sub_8086448(); + // There appears to be no one here + sub_80866C4(&gUnknown_8104FC8); +} + +static void LatiosScreenFlash(void) +{ + s32 iVar1; + + PlaySoundEffect(0x1ee); + gDungeonBrightness = 0x1f; + for(iVar1 = 250; iVar1 > 149; iVar1 -= 10) + { + SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,1); + DungeonRunFrameActions(70); + } + sub_803E708(10,70); + for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10) + { + SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,1); + DungeonRunFrameActions(70); + } + sub_803E708(10,70); + sub_8085EB0(); +} diff --git a/src/dungeon_cutscene_lugia.c b/src/dungeon_cutscene_lugia.c new file mode 100644 index 000000000..25d9aa423 --- /dev/null +++ b/src/dungeon_cutscene_lugia.c @@ -0,0 +1,207 @@ +#include "global.h" +#include "globaldata.h" +#include "code_800DAC0.h" +#include "code_800E9A8.h" +#include "dungeon_vram.h" +#include "code_803E668.h" +#include "code_8041AD0.h" +#include "code_804267C.h" +#include "code_80861A8.h" +#include "code_806CD90.h" +#include "code_80869E4.h" +#include "constants/bg_music.h" +#include "constants/direction.h" +#include "constants/friend_area.h" +#include "constants/weather.h" +#include "dungeon_items.h" +#include "dungeon_leader.h" +#include "dungeon_map_access.h" +#include "dungeon_message.h" +#include "dungeon_music.h" +#include "dungeon_misc.h" +#include "dungeon_logic.h" +#include "dungeon_random.h" +#include "dungeon_util_1.h" +#include "dungeon_util.h" +#include "exclusive_pokemon.h" +#include "friend_area.h" +#include "items.h" +#include "pokemon_3.h" +#include "pokemon.h" +#include "position_util.h" +#include "trap.h" +#include "math.h" +#include "dungeon_config.h" +#include "dungeon_boss_dialogue.h" + +extern s32 gDungeonBrightness; + +extern void sub_8042B0C(Entity *); +extern u8 sub_806FD18(Entity *); +extern void sub_806FDF4(Entity *, Entity *, Entity **); +extern s32 GetCameraXPos(void); +extern s32 GetCameraYPos(void); +extern void sub_803F878(u32, s32); +extern void BgColorCallNullsub4(void); +extern void sub_8085EB0(void); +extern void sub_8049884(void); +extern void sub_8049B8C(void); +extern void ShowWholeRevealedDungeonMap(void); +extern void sub_8086A54(Entity *); +extern void ResetMonEntityData(EntityInfo *, u32); +extern void sub_8041888(u32); +extern u32 sub_80861F8(u32, Entity *, u32); +extern u8 sub_80860A8(u32); +extern void sub_8052D44(s16 *, Entity *, Entity *); +extern void sub_80464C8(Entity *, DungeonPos *, Item *); +extern void SetDungeonBGColorRGB(u32, u32, u32, u32, u32); +extern u32 sub_8085EC8(u32, u32, u32, DungeonPos *, u32); +extern void sub_807EAA0(u32, u32); +extern void sub_8072008(Entity *, Entity *, s16, u32, u32); +extern void sub_8085374(void); +extern u32 GetRandomFloorItem(u32); +extern bool8 sub_8085B80(struct_8085B80 *); +extern void sub_8086A3C(Entity *pokemon); +extern void SetupBossFightHP(Entity *pokemon, s32 newHP, u16 songIndex); +extern u8 sub_8086AE4(s16 _index); + +static void LugiaScreenFlash(void); +static void LugiaScreenFlash2(void); +static void sub_808C0CC(void); + +void sub_808BDEC(void) +{ + Entity * leaderEntity; + Entity * lugiaEntity; + + leaderEntity = xxx_call_GetLeader(); + lugiaEntity = GetEntityFromMonsterBehavior(BEHAVIOR_LUGIA); + DungeonStopBGM(); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + sub_80855E4(sub_8086A3C); + if (HasRecruitedMon(MONSTER_LUGIA)) { + DungeonStartNewBGM(MUS_FRIEND_AREA_CRYPTIC_CAVE); + sub_8068FE0(lugiaEntity,0x21c,0); + } + else { + gDungeon->unk7 = 1; + SetFacingDirection(lugiaEntity, DIRECTION_SOUTH); + } + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 3); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_LUGIA); +} + +void sub_808BE70(u8 param_1,u8 param_2,u8 param_3) +{ + if ((param_2 == 0x33) && (param_1 == 0x1B)) { + gDungeon->unk2 = 1; + } +} + +void LugiaPreFightDialogue(void) +{ + Entity * leaderEntity; + Entity * lugiaEntity; + + leaderEntity = xxx_call_GetLeader(); + lugiaEntity = GetEntityFromMonsterBehavior(BEHAVIOR_LUGIA); + if (HasRecruitedMon(MONSTER_LUGIA)) { + sub_8086448(); + sub_80866C4(&gLugiaPreFightDialogue_8); + } + else { + DungeonStopBGM(); + sub_8086448(); + DisplayDungeonDialogue(&gLugiaPreFightDialogue_1); + DungeonFadeInNewBGM(MUS_FRIEND_AREA_CRYPTIC_CAVE,0x3c); + sub_808C0CC(); + DisplayDungeonDialogue(&gLugiaPreFightDialogue_2); + LugiaScreenFlash(); + DisplayDungeonDialogue(&gLugiaPreFightDialogue_3); + sub_803E708(10,0x46); + DisplayDungeonDialogue(&gLugiaPreFightDialogue_4); + PlaySoundEffect(0x1f8); + sub_80861D4(lugiaEntity,0xd,DIRECTION_SOUTH); + sub_803E708(0x2b,0x46); + sub_80861B8(lugiaEntity,0,DIRECTION_SOUTH); + DisplayDungeonDialogue(&gLugiaPreFightDialogue_5); + LugiaScreenFlash(); + DisplayDungeonDialogue(&gLugiaPreFightDialogue_6); + LugiaScreenFlash2(); + SetDungeonBGColorRGB(-250,-250,-250,1,0); + DungeonStopBGM(); + sub_80861D4(lugiaEntity,7,DIRECTION_SOUTH); + DisplayDungeonDialogue(&gLugiaPreFightDialogue_7); + LugiaScreenFlash(); + SetupBossFightHP(lugiaEntity,800,MUS_BATTLE_WITH_RAYQUAZA); + DungeonStartNewBGM(MUS_FRIEND_AREA_CRYPTIC_CAVE); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); + } +} + +static void LugiaScreenFlash(void) +{ + s32 iVar1; + + PlaySoundEffect(0x1f6); + for(iVar1 = 250; iVar1 > 149; iVar1 -= 10){ + SetDungeonBGColorRGB(0,0,iVar1,1,1); + DungeonRunFrameActions(0x46); + } + sub_803E708(10,0x46); + for(iVar1 = 250; iVar1 > 199; iVar1 -= 10){ + SetDungeonBGColorRGB(0,iVar1,iVar1,1,1); + DungeonRunFrameActions(0x46); + } + sub_803E708(10,0x46); + for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10){ + SetDungeonBGColorRGB(0,0,iVar1,1,1); + DungeonRunFrameActions(0x46); + } + sub_803E708(10,0x46); + sub_8085EB0(); +} + +static void LugiaScreenFlash2(void) +{ + s32 iVar1; + + PlaySoundEffect(0x1f6); + + for(iVar1 = 0; iVar1 < 200; iVar1 += 100){ + SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,0); + DungeonRunFrameActions(0x46); + } + + for(iVar1 = 200; iVar1 >= 0; iVar1 -= 100){ + SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,0); + DungeonRunFrameActions(0x46); + } + + sub_803E708(4,0x46); + + for(iVar1 = 0; iVar1 < 200; iVar1 += 100){ + SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,0); + DungeonRunFrameActions(0x46); + } + + for(iVar1 = 200; iVar1 >= 0; iVar1 -= 100){ + SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,0); + DungeonRunFrameActions(0x46); + } + + sub_803E708(10,0x46); + sub_8085EB0(); +} + +static void sub_808C0CC(void) +{ + gDungeonBrightness = 0x1f; + SetDungeonBGColorRGB(0,0,0,1,1); + BgColorCallNullsub4(); + DungeonRunFrameActions(0x46); + gDungeon->unk7 = 0; + LugiaScreenFlash(); +} + diff --git a/src/dungeon_cutscene_magma_cavern.c b/src/dungeon_cutscene_magma_cavern.c new file mode 100644 index 000000000..9b25933bc --- /dev/null +++ b/src/dungeon_cutscene_magma_cavern.c @@ -0,0 +1,331 @@ +#include "global.h" +#include "globaldata.h" +#include "code_800DAC0.h" +#include "code_800E9A8.h" +#include "dungeon_vram.h" +#include "code_803E668.h" +#include "code_8041AD0.h" +#include "code_804267C.h" +#include "code_80861A8.h" +#include "code_806CD90.h" +#include "code_80869E4.h" +#include "constants/bg_music.h" +#include "constants/direction.h" +#include "constants/friend_area.h" +#include "constants/weather.h" +#include "dungeon_items.h" +#include "dungeon_leader.h" +#include "dungeon_map_access.h" +#include "dungeon_message.h" +#include "dungeon_music.h" +#include "dungeon_misc.h" +#include "dungeon_logic.h" +#include "dungeon_random.h" +#include "dungeon_util_1.h" +#include "dungeon_util.h" +#include "exclusive_pokemon.h" +#include "friend_area.h" +#include "items.h" +#include "pokemon_3.h" +#include "pokemon.h" +#include "position_util.h" +#include "trap.h" +#include "math.h" +#include "dungeon_config.h" +#include "dungeon_boss_dialogue.h" + +extern void sub_8042B0C(Entity *); +extern u8 sub_806FD18(Entity *); +extern void sub_806FDF4(Entity *, Entity *, Entity **); +extern s32 GetCameraXPos(void); +extern s32 GetCameraYPos(void); +extern void sub_803F878(u32, s32); +extern void BgColorCallNullsub4(void); +extern void sub_8085EB0(void); +extern void sub_8049884(void); +extern void sub_8049B8C(void); +extern void ShowWholeRevealedDungeonMap(void); +extern void sub_8086A54(Entity *); +extern void ResetMonEntityData(EntityInfo *, u32); +extern void sub_8041888(u32); +extern u32 sub_80861F8(u32, Entity *, u32); +extern u8 sub_80860A8(u32); +extern void sub_8052D44(s16 *, Entity *, Entity *); +extern void sub_80464C8(Entity *, DungeonPos *, Item *); +extern void SetDungeonBGColorRGB(u32, u32, u32, u32, u32); +extern u32 sub_8085EC8(u32, u32, u32, DungeonPos *, u32); +extern void sub_807EAA0(u32, u32); +extern void sub_8072008(Entity *, Entity *, s16, u32, u32); +extern void sub_8085374(void); +extern u32 GetRandomFloorItem(u32); +extern bool8 sub_8085B80(struct_8085B80 *); +extern void sub_8086A3C(Entity *pokemon); +extern void SetupBossFightHP(Entity *pokemon, s32 newHP, u16 songIndex); +extern u8 sub_8086AE4(s16 _index); + +static void sub_80891F0(void); +static void sub_8089294(void); + +void sub_8088DC0(void) +{ + Entity * leaderEntity; + Entity * groudonEntity; + Entity * alakazamEntity; + + leaderEntity = xxx_call_GetLeader(); + groudonEntity = GetEntityFromMonsterBehavior(BEHAVIOR_GROUDON_1); + alakazamEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ALAKAZAM_2); + sub_80867F4(); + sub_8086838(0,1,0); + sub_8085374(); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + sub_80855E4(sub_8086A3C); + sub_8086A3C(groudonEntity); + sub_806CDD4(groudonEntity,0xe,DIRECTION_SOUTH); + sub_8086A3C(alakazamEntity); + sub_806CDD4(alakazamEntity,0xe,DIRECTION_SOUTH); + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 3); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_GROUDON); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[3], MONSTER_ALAKAZAM); +} + +void sub_8088E5C(void) +{ + Entity * leaderEntity; + Entity * groudonEntity; + Entity * alakazamEntity; + + leaderEntity = xxx_call_GetLeader(); + groudonEntity = GetEntityFromMonsterBehavior(BEHAVIOR_GROUDON_1); + alakazamEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ALAKAZAM_2); + sub_80867F4(); + sub_8086838(0,1,0); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + sub_80855E4(sub_8086A3C); + sub_8068FE0(groudonEntity,0x21c,0); + sub_8068FE0(alakazamEntity,0x21c,0); + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y + -3); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_GROUDON); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[3], MONSTER_ALAKAZAM); +} + +void sub_8088EE8(void) +{ + sub_8086854(); +} + +void MagmaCavernMidDialogue(void) +{ + Entity * leaderEntity; + Entity * partnerEntity; + Entity * groudonEntity; + Entity * alakazamEntity; + s16 IDStack [2]; + PixelPos pos; + + leaderEntity = xxx_call_GetLeader(); + partnerEntity = GetPartnerEntity(); + groudonEntity = GetEntityFromMonsterBehavior(BEHAVIOR_GROUDON_1); + alakazamEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ALAKAZAM_2); + sub_8052D44(IDStack,leaderEntity,partnerEntity); + sub_8086448(); + SpriteLookAroundEffect(partnerEntity); + // Let's see.. + // I wonder where we are? + DisplayDungeonDialogue(&MagmaCavernMidDialogue_1); + sub_803E708(10,0x46); + sub_80869E4(partnerEntity,4,1,DIRECTION_EAST); + sub_80869E4(leaderEntity,4,2,DIRECTION_WEST); + // I know we've come pretty + // far... + // + // I'm certain we've come quite + // far already.. + DisplayDungeonDialogue(MagmaCavernMidDialogue_2); + sub_803E708(10,0x46); + DungeonStopBGM(); + sub_80855E4(sub_80868F4); + sub_808680C(); + PlaySoundEffect(0x1c5); + sub_803E708(0x28,0x46); + // Waaah! + // Qu-quake! + DisplayDungeonDialogue(&MagmaCavernMidDialogue_3); + sub_803E708(0x78,0x46); + StopSoundEffect(0x1c5); + sub_808682C(); + sub_80855E4(sub_8086910); + sub_803E708(0x14,0x46); + sub_8085930(DIRECTION_NORTH); + sub_803E708(10,0x46); + // Whew! + // It settled down. + // + // Whew + // It's over. + DisplayDungeonDialogue(MagmaCavernMidDialogue_4); + sub_803E708(10,0x46); + PlaySoundEffect(0x1d5); + SpriteLookAroundEffect(partnerEntity); + PlaySoundEffect(0x1c7); + sub_80856E0(partnerEntity, DIRECTION_NORTH); + // Hey! {POKEMON_0}! + // Over there! + DisplayDungeonDialogue(&MagmaCavernMidDialogue_5); + GetEntInfo(groudonEntity)->unk15E = 0; + GetEntInfo(alakazamEntity)->unk15E =0; + pos.x = (groudonEntity->pixelPos.x + alakazamEntity->pixelPos.x) / 2; + pos.y = (groudonEntity->pixelPos.y + alakazamEntity->pixelPos.y) / 2 + 0x800; + ShiftCameraToPosition(&pos,0x20); + sub_803E708(0x3c,0x46); + sub_80891F0(); + // Hey! + // Are you OK?! + // + // Hey! + // Snap out of it! + DisplayDungeonDialogue(MagmaCavernMidDialogue_6); + sub_803E708(10,0x46); + // Urrrrgh... + DisplayDungeonDialogue(&MagmaCavernMidDialogue_7); + sub_803E708(10,0x46); + sub_80869E4(leaderEntity,4,2,DIRECTION_NORTHWEST); + // What happened to you? + // + // What happened here? + DisplayDungeonDialogue(MagmaCavernMidDialogue_8); + sub_803E708(10,0x46); + // We challenged.. + // {POKEMON_2}... + // And wiped out.. + DisplayDungeonDialogue(&MagmaCavernMidDialogue_9); + sub_803E708(10,0x46); + DisplayDungeonDialogue(&MagmaCavernMidDialogue_10); + sub_803E708(10,0x46); + sub_80869E4(leaderEntity,4,1,DIRECTION_NORTHEAST); + sub_80869E4(partnerEntity,4,1,DIRECTION_NORTHEAST); + // Grrgh.. + // We... It crushed us + DisplayDungeonDialogue(&MagmaCavernMidDialogue_11); + sub_803E708(10,0x46); + PlaySoundEffect(0x1d5); + SpriteLookAroundEffect(partnerEntity); + // That's right... + // What happened to {POKEMON_3}? + // Where is {POKEMON_3}? + // + // Wait... + // What about {POKEMON_3}? + // Where did {POKEMON_3} go? + DisplayDungeonDialogue(MagmaCavernMidDialogue_12); + sub_803E708(0x1e,0x46); + // {POKEMON_3} is... + // Still battling {POKEMON_2}... + DisplayDungeonDialogue(&MagmaCavernMidDialogue_13); + sub_803E708(10,0x46); + sub_80869E4(partnerEntity,4,1,DIRECTION_EAST); + sub_80869E4(leaderEntity,4,2,DIRECTION_WEST); + + // {POKEMON_0}! + // We've got to hurry! + DisplayDungeonDialogue(&MagmaCavernMidDialogue_14); + sub_8089294(); + // Be careful! + DisplayDungeonDialogue(&MagmaCavernMidDialogue_15); + sub_803E708(10,0x46); + gDungeon->unk2 = 1; +} + +void sub_8089168(void) +{ + Entity *leaderEntity; + + leaderEntity = xxx_call_GetLeader(); + sub_8086448(); + sub_803E708(10,0x46); + SpriteLookAroundEffect(leaderEntity); + sub_803E708(10,0x46); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); +} + +void sub_808919C(Entity *r0) +{ + IncreaseEntityPixelPos(r0, 0, -512); +} + +void sub_80891B0(Entity *r0) +{ + sub_806CDD4(r0, 0, DIRECTION_NORTH); + GetEntInfo(r0)->unk15F = 1; +} + +void sub_80891D0(Entity *r0) +{ + sub_806CDD4(r0, 7, DIRECTION_NORTH); + GetEntInfo(r0)->unk15F = 0; +} + +static void sub_80891F0(void) +{ + s32 iVar1; + + sub_80855E4(sub_80891B0); + for(iVar1 = 0; iVar1 < 0x30; iVar1++) + { + sub_80855E4(sub_808919C); + DungeonRunFrameActions(0x46); + } + sub_80855E4(sub_80891D0); +} + +void sub_8089224(Entity * entity) +{ + s32 xPixelPos; + + if (entity->pixelPos.y < 0x9001) { + return; + } + xPixelPos = entity->pixelPos.x; + + if(xPixelPos < 0xE400) + { + if(xPixelPos <= 0xB400) + { + // 0 - 0xB400 + IncreaseEntityPixelPos(entity, 0, -512); + } + else + { + // 0xB401 - 0xE3FF + IncreaseEntityPixelPos(entity, -512, 0); + } + } + else if(xPixelPos < 0xFC00) + { + IncreaseEntityPixelPos(entity, 0, -512); + } + else if(xPixelPos <= 0x11400) + { + IncreaseEntityPixelPos(entity, 0x200, 0); + } + else + { + IncreaseEntityPixelPos(entity, 0, -512); + } +} + +static void sub_8089294(void) +{ + s32 iVar1; + + sub_80855E4(sub_80891B0); + for(iVar1 = 0; iVar1 <= 0x77; iVar1++) + { + sub_80855E4(sub_8089224); + DungeonRunFrameActions(0x46); + } + sub_80855E4(sub_80891D0); +} + diff --git a/src/dungeon_cutscene_mankey.c b/src/dungeon_cutscene_mankey.c new file mode 100644 index 000000000..3490b3135 --- /dev/null +++ b/src/dungeon_cutscene_mankey.c @@ -0,0 +1,185 @@ +#include "global.h" +#include "globaldata.h" +#include "code_800DAC0.h" +#include "code_800E9A8.h" +#include "dungeon_vram.h" +#include "code_803E668.h" +#include "code_8041AD0.h" +#include "code_804267C.h" +#include "code_80861A8.h" +#include "code_806CD90.h" +#include "code_80869E4.h" +#include "constants/bg_music.h" +#include "constants/direction.h" +#include "constants/friend_area.h" +#include "constants/weather.h" +#include "dungeon_items.h" +#include "dungeon_leader.h" +#include "dungeon_map_access.h" +#include "dungeon_message.h" +#include "dungeon_music.h" +#include "dungeon_misc.h" +#include "dungeon_logic.h" +#include "dungeon_random.h" +#include "dungeon_util_1.h" +#include "dungeon_util.h" +#include "exclusive_pokemon.h" +#include "friend_area.h" +#include "items.h" +#include "pokemon_3.h" +#include "pokemon.h" +#include "position_util.h" +#include "trap.h" +#include "math.h" +#include "dungeon_config.h" +#include "dungeon_boss_dialogue.h" + +extern void sub_8042B0C(Entity *); +extern u8 sub_806FD18(Entity *); +extern void sub_806FDF4(Entity *, Entity *, Entity **); +extern s32 GetCameraXPos(void); +extern s32 GetCameraYPos(void); +extern void sub_803F878(u32, s32); +extern void BgColorCallNullsub4(void); +extern void sub_8085EB0(void); +extern void sub_8049884(void); +extern void sub_8049B8C(void); +extern void ShowWholeRevealedDungeonMap(void); +extern void sub_8086A54(Entity *); +extern void ResetMonEntityData(EntityInfo *, u32); +extern void sub_8041888(u32); +extern u32 sub_80861F8(u32, Entity *, u32); +extern u8 sub_80860A8(u32); +extern void sub_8052D44(s16 *, Entity *, Entity *); +extern void sub_80464C8(Entity *, DungeonPos *, Item *); +extern void SetDungeonBGColorRGB(u32, u32, u32, u32, u32); +extern u32 sub_8085EC8(u32, u32, u32, DungeonPos *, u32); +extern void sub_807EAA0(u32, u32); +extern void sub_8072008(Entity *, Entity *, s16, u32, u32); +extern void sub_8085374(void); +extern u32 GetRandomFloorItem(u32); +extern bool8 sub_8085B80(struct_8085B80 *); +extern void sub_8086A3C(Entity *pokemon); +extern void SetupBossFightHP(Entity *pokemon, s32 newHP, u16 songIndex); +extern u8 sub_8086AE4(s16 _index); + +static void sub_80898F8(Entity *r0); +static void sub_8089908(Entity *r0); + +void sub_808970C(void) +{ + Entity *leaderEntity; + + leaderEntity = xxx_call_GetLeader(); + DungeonStartNewBGM(MUS_TINY_WOODS); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + sub_80855E4(sub_8086A3C); + sub_808563C(sub_8089908); + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y -3); +} + +void sub_808974C(void) +{ + Entity *leaderEntity; + + leaderEntity = xxx_call_GetLeader(); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + sub_80855E4(sub_8086A3C); + sub_808563C(sub_80898F8); + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y + -3); +} + +void sub_8089788(Entity *entity, u8 param_2, u8 param_3) +{ + Entity *monEntity; + s32 index; + bool8 found = FALSE; + + if (param_3 == 0x1A || param_3 == 0x1B) { + for(index = 0; index < DUNGEON_MAX_WILD_POKEMON; index++) + { + monEntity = gDungeon->wildPokemon[index]; + if ((EntityIsValid(monEntity)) && (monEntity != entity) && (GetEntInfo(monEntity)->monsterBehavior == param_2)) { + found = TRUE; + break; + } + } + + if(!found){ + sub_8097FA8(0x11); + gDungeon->unk2 = 1; + } + } +} + +void sub_80897F0(void) +{ + Entity *leaderEntity; + + leaderEntity = xxx_call_GetLeader(); + sub_8086448(); + sub_803E708(10,0x46); + sub_808563C(SpriteShockEffect); + sub_803E708(0x20,0x46); + sub_808692C(); + DisplayDungeonDialogue(&gUnknown_8103BD8); + // We don't like to brag or + // nothing, but + DisplayDungeonDialogue(&gUnknown_8103C00); + // We get furious real easy + // You know that?! + DisplayDungeonDialogue(&gUnknown_8103C3C); + // What really irritates us is + // when we see some dim witted face + DisplayDungeonDialogue(&gUnknown_8103C74); + // ......... + // Wrooooooar! + // That vacant expression + DisplayDungeonDialogue(&gUnknown_8103CC4); + // Gwoooh + // It's ticking me off! + // I'm seeing red! + DisplayDungeonDialogue(&gUnknown_8103D0C); + // Mukkkeeeeeh + // Get 'em! It's frenzy time! + DisplayDungeonDialogue(&gUnknown_8103D50); + sub_803E708(10,0x46); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); +} + +void sub_8089878(void) +{ + Entity *leaderEntity; + + leaderEntity = xxx_call_GetLeader(); + sub_8086448(); + sub_803E708(10,0x46); + sub_808563C(SpriteShockEffect); + sub_803E708(0x20,0x46); + sub_808692C(); + DisplayDungeonDialogue(&gUnknown_8103D8C); + DisplayDungeonDialogue(&gUnknown_8103D98); + DisplayDungeonDialogue(&gUnknown_8103DD8); + DisplayDungeonDialogue(&gUnknown_8103E28); + sub_803E708(10,0x46); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); +} + +void sub_80898E4(void) +{ + sub_8086448(); + sub_80866C4(&gUnknown_8103E34); +} + +static void sub_80898F8(Entity *r0) +{ + sub_8068FE0(r0, 0x21C, 0); +} + +static void sub_8089908(Entity *r0) +{ + SetFacingDirection(r0, DIRECTION_NORTH); +} + diff --git a/src/dungeon_cutscene_meanies.c b/src/dungeon_cutscene_meanies.c new file mode 100644 index 000000000..79ec4e7ed --- /dev/null +++ b/src/dungeon_cutscene_meanies.c @@ -0,0 +1,219 @@ +#include "global.h" +#include "globaldata.h" +#include "code_800DAC0.h" +#include "code_800E9A8.h" +#include "dungeon_vram.h" +#include "code_803E668.h" +#include "code_8041AD0.h" +#include "code_804267C.h" +#include "code_80861A8.h" +#include "code_806CD90.h" +#include "code_80869E4.h" +#include "constants/bg_music.h" +#include "constants/direction.h" +#include "constants/friend_area.h" +#include "constants/weather.h" +#include "dungeon_items.h" +#include "dungeon_leader.h" +#include "dungeon_map_access.h" +#include "dungeon_message.h" +#include "dungeon_music.h" +#include "dungeon_misc.h" +#include "dungeon_logic.h" +#include "dungeon_random.h" +#include "dungeon_util_1.h" +#include "dungeon_util.h" +#include "exclusive_pokemon.h" +#include "friend_area.h" +#include "items.h" +#include "pokemon_3.h" +#include "pokemon.h" +#include "position_util.h" +#include "trap.h" +#include "math.h" +#include "dungeon_config.h" +#include "dungeon_boss_dialogue.h" + +extern void sub_8042B0C(Entity *); +extern u8 sub_806FD18(Entity *); +extern void sub_806FDF4(Entity *, Entity *, Entity **); +extern s32 GetCameraXPos(void); +extern s32 GetCameraYPos(void); +extern void sub_803F878(u32, s32); +extern void BgColorCallNullsub4(void); +extern void sub_8085EB0(void); +extern void sub_8049884(void); +extern void sub_8049B8C(void); +extern void ShowWholeRevealedDungeonMap(void); +extern void sub_8086A54(Entity *); +extern void ResetMonEntityData(EntityInfo *, u32); +extern void sub_8041888(u32); +extern u32 sub_80861F8(u32, Entity *, u32); +extern u8 sub_80860A8(u32); +extern void sub_8052D44(s16 *, Entity *, Entity *); +extern void sub_80464C8(Entity *, DungeonPos *, Item *); +extern void SetDungeonBGColorRGB(u32, u32, u32, u32, u32); +extern u32 sub_8085EC8(u32, u32, u32, DungeonPos *, u32); +extern void sub_807EAA0(u32, u32); +extern void sub_8072008(Entity *, Entity *, s16, u32, u32); +extern void sub_8085374(void); +extern u32 GetRandomFloorItem(u32); +extern bool8 sub_8085B80(struct_8085B80 *); +extern void sub_8086A3C(Entity *pokemon); +extern void SetupBossFightHP(Entity *pokemon, s32 newHP, u16 songIndex); +extern u8 sub_8086AE4(s16 _index); + +static void sub_8087144(void); + +void sub_8086E9C(void) +{ + Entity * leaderEntity; + + leaderEntity = xxx_call_GetLeader(); + DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); + sub_8085374(); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + sub_80855E4(sub_8086A3C); + sub_808563C(sub_8086A3C); + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 3); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_METAPOD); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[3], MONSTER_GENGAR); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[4], MONSTER_CATERPIE); +} + +void sub_8086F00(void) +{ + Entity * leaderEntity; + + leaderEntity = xxx_call_GetLeader(); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + sub_80855E4(sub_8086A3C); + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 3); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_METAPOD); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[3], MONSTER_GENGAR); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[4], MONSTER_CATERPIE); +} + +void sub_8086F54(u8 param_1, u8 param_2) +{ + s32 index; + + if (param_2 == 4 || param_2 == 5) { + bool8 found = FALSE; + for (index = 0; index < 0x10; index++) { + struct Entity *entity = gDungeon->wildPokemon[index]; + if ((EntityIsValid(entity))) { + struct EntityInfo *entInfo = GetEntInfo(entity); + if (entInfo->monsterBehavior != param_1) { + found = TRUE; + return; + } + } + } + + if (!found) { + sub_8097FA8(3); + gDungeon->unk2 = 1; + } + } +} + +void TeamMeaniesPreFightDialogue(void) +{ + Entity *leaderEntity; + + leaderEntity = xxx_call_GetLeader(); + sub_8086448(); + sub_803E708(10, 0x46); + DisplayDungeonDialogue(gTeamMeaniesPreFightDialogue_1); + sub_803E708(10, 0x46); + DisplayDungeonDialogue(&gTeamMeaniesPreFightDialogue_2); + sub_803E708(10, 0x46); + sub_8087144(); + DungeonStartNewBGM(MUS_THERES_TROUBLE); + DisplayDungeonDialogue(&gTeamMeaniesPreFightDialogue_3); + sub_803E708(10, 0x46); + DisplayDungeonDialogue(gTeamMeaniesPreFightDialogue_4); + sub_803E708(10, 0x46); + DisplayDungeonDialogue(&gTeamMeaniesPreFightDialogue_5); + sub_803E708(10, 0x46); + DisplayDungeonDialogue(&gTeamMeaniesPreFightDialogue_6); + sub_803E708(10, 0x46); + DisplayDungeonDialogue(&gTeamMeaniesPreFightDialogue_7); + sub_803E708(10, 0x46); + ShiftCameraToPosition(&leaderEntity->pixelPos, 0x10); +} + +void TeamMeaniesReFightDialogue(void) +{ + Entity *leaderEntity; + Entity *partnerEntity; + + leaderEntity = xxx_call_GetLeader(); + partnerEntity = GetPartnerEntity(); + sub_8086448(); + DisplayDungeonDialogue(gTeamMeaniesReFightDialogue_1); + sub_803E708(10, 0x46); + DisplayDungeonDialogue(&gTeamMeaniesPreFightDialogue_2); + sub_803E708(10, 0x46); + sub_8087144(); + sub_803E708(10, 0x46); + DisplayDungeonDialogue(gTeamMeaniesReFightDialogue_2); + sub_803E708(10, 0x46); + DisplayDungeonDialogue(&gTeamMeaniesReFightDialogue_3); + sub_803E708(10, 0x46); + sub_806CDD4(leaderEntity, 6, DIRECTION_NORTH); + sub_806CDD4(partnerEntity, 6, DIRECTION_NORTH); + sub_803E708(10, 0x46); + sub_806CDD4(leaderEntity, 7, DIRECTION_NORTH); + sub_806CDD4(partnerEntity, 7, DIRECTION_NORTH); + sub_803E708(10, 0x46); + DisplayDungeonDialogue(&gTeamMeaniesReFightDialogue_4); + DisplayDungeonDialogue(&gTeamMeaniesReFightDialogue_5); + sub_803E708(10, 0x46); + ShiftCameraToPosition(&leaderEntity->pixelPos, 0x10); +} + +void sub_8087130(void) +{ + sub_8086448(); + sub_80866C4(&gUnknown_8101440); +} + +static void sub_8087144(void) +{ + Entity *gengarEntity = GetEntityFromMonsterBehavior(BEHAVIOR_GENGAR); + Entity *ekansEntity = GetEntityFromMonsterBehavior(BEHAVIOR_EKANS); + Entity *medichamEntity = GetEntityFromMonsterBehavior(BEHAVIOR_MEDICHAM); + s16 auStack_10c[28] = {4, 2, 12, 0, 3, 2, 24, 0, 4, 2, 24, 0, 5, 2, 12, 0, 6, 2, 12, 0, 0, 0, 0, 0, 0, 11, 8, 0}; + s16 puStack_60[28] = {4, 2, 12, 0, 3, 2, 24, 0, 4, 2, 24, 0, 5, 2, 12, 0, 6, 2, 12, 0, 0, 0, 0, 0, 0, 12, 8, 0}; + s16 puStack_5c[28] = {4, 2, 12, 0, 5, 2, 12, 0, 4, 2, 12, 0, 4, 2, 24, 0, 3, 2, 12, 0, 0, 0, 0, 0, 0, 10, 8, 0}; + s16 *puStack_64[3]; + Entity *pEStack_58[3]; + struct_8085B80 auStack_4c[3]; + + puStack_64[0] = auStack_10c; + puStack_64[1] = puStack_60; + puStack_64[2] = puStack_5c; + pEStack_58[0] = gengarEntity; + pEStack_58[1] = ekansEntity; + pEStack_58[2] = medichamEntity; + DungeonStartNewBGM(MUS_THERES_TROUBLE); + sub_8086A54(gengarEntity); + sub_8086A54(ekansEntity); + sub_8086A54(medichamEntity); + sub_8085B4C(auStack_4c,puStack_64,pEStack_58,3); + GetEntInfo(gengarEntity)->unk15F = 1; + GetEntInfo(ekansEntity)->unk15F = 1; + GetEntInfo(medichamEntity)->unk15F = 1; + while( TRUE ) { + if (!sub_8085B80(auStack_4c)) break; + DungeonRunFrameActions(0x46); + } + GetEntInfo(gengarEntity)->unk15F = 0; + GetEntInfo(ekansEntity)->unk15F = 0; + GetEntInfo(medichamEntity)->unk15F = 0; +} + diff --git a/src/dungeon_cutscene_medicham.c b/src/dungeon_cutscene_medicham.c new file mode 100644 index 000000000..5a1e25ddc --- /dev/null +++ b/src/dungeon_cutscene_medicham.c @@ -0,0 +1,148 @@ +#include "global.h" +#include "globaldata.h" +#include "code_800DAC0.h" +#include "code_800E9A8.h" +#include "dungeon_vram.h" +#include "code_803E668.h" +#include "code_8041AD0.h" +#include "code_804267C.h" +#include "code_80861A8.h" +#include "code_806CD90.h" +#include "code_80869E4.h" +#include "constants/bg_music.h" +#include "constants/direction.h" +#include "constants/friend_area.h" +#include "constants/weather.h" +#include "dungeon_items.h" +#include "dungeon_leader.h" +#include "dungeon_map_access.h" +#include "dungeon_message.h" +#include "dungeon_music.h" +#include "dungeon_misc.h" +#include "dungeon_logic.h" +#include "dungeon_random.h" +#include "dungeon_util_1.h" +#include "dungeon_util.h" +#include "exclusive_pokemon.h" +#include "friend_area.h" +#include "items.h" +#include "pokemon_3.h" +#include "pokemon.h" +#include "position_util.h" +#include "trap.h" +#include "math.h" +#include "dungeon_config.h" +#include "dungeon_boss_dialogue.h" + +extern void sub_8042B0C(Entity *); +extern u8 sub_806FD18(Entity *); +extern void sub_806FDF4(Entity *, Entity *, Entity **); +extern s32 GetCameraXPos(void); +extern s32 GetCameraYPos(void); +extern void sub_803F878(u32, s32); +extern void BgColorCallNullsub4(void); +extern void sub_8085EB0(void); +extern void sub_8049884(void); +extern void sub_8049B8C(void); +extern void ShowWholeRevealedDungeonMap(void); +extern void sub_8086A54(Entity *); +extern void ResetMonEntityData(EntityInfo *, u32); +extern void sub_8041888(u32); +extern u32 sub_80861F8(u32, Entity *, u32); +extern u8 sub_80860A8(u32); +extern void sub_8052D44(s16 *, Entity *, Entity *); +extern void sub_80464C8(Entity *, DungeonPos *, Item *); +extern void SetDungeonBGColorRGB(u32, u32, u32, u32, u32); +extern u32 sub_8085EC8(u32, u32, u32, DungeonPos *, u32); +extern void sub_807EAA0(u32, u32); +extern void sub_8072008(Entity *, Entity *, s16, u32, u32); +extern void sub_8085374(void); +extern u32 GetRandomFloorItem(u32); +extern bool8 sub_8085B80(struct_8085B80 *); +extern void sub_8086A3C(Entity *pokemon); +extern void SetupBossFightHP(Entity *pokemon, s32 newHP, u16 songIndex); +extern u8 sub_8086AE4(s16 _index); + +void sub_808C9C4(void) +{ + Entity *leaderEntity; + Entity *medichamEntity; + + leaderEntity = xxx_call_GetLeader(); + medichamEntity = GetEntityFromMonsterBehavior(BEHAVIOR_MEDICHAM); + DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + sub_80855E4(sub_8086A3C); + SetFacingDirection(medichamEntity, DIRECTION_SOUTH); + sub_8085860(leaderEntity->pos.x, leaderEntity->pos.y - 3); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_MEDICHAM); +} + +void MedichamRescueDialogue(void) +{ + Entity *medichamEntity; + s32 counter; + + medichamEntity = GetEntityFromMonsterBehavior(BEHAVIOR_MEDICHAM); + SpriteLookAroundEffect(medichamEntity); + sub_803E708(0xA, 0x46); + // Oh my I can't seem to find a way out... + DisplayDungeonDialogue(&gMedichamRescueDialogue_1); + sub_803E708(0xA, 0x46); + sub_80869E4(medichamEntity, 4, 2, DIRECTION_NORTH); + sub_803E708(0xA, 0x46); + // What am I to do...? + DisplayDungeonDialogue(&gMedichamRescueDialogue_2); + sub_803E708(0xA, 0x46); + sub_8086448(); + sub_8086598(); + sub_803E708(0x20, 0x46); + SpriteShockEffect(medichamEntity); + sub_803E708(0x20, 0x46); + sub_80869E4(medichamEntity, 4, 2, DIRECTION_SOUTH); + DisplayDungeonDialogue(&gMedichamRescueDialogue_3); + sub_803E708(0xA, 0x46); + PlaySoundEffect(0x1c7); + sub_806CDD4(medichamEntity, 0xA, DIRECTION_SOUTH); + sub_803E708(0x14, 0x46); + sub_806CE68(medichamEntity, DIRECTION_SOUTH); + sub_803E708(0x4, 0x46); + PlaySoundEffect(0x1c7); + sub_806CDD4(medichamEntity, 0xA, DIRECTION_SOUTH); + sub_803E708(0x14, 0x46); + // Yes Yes + // I am so lucky + // + // There appears to be no one here + DisplayDungeonDialogue(&gMedichamRescueDialogue_4); + sub_803E708(0xA, 0x46); + sub_806CDD4(medichamEntity, 0, DIRECTION_SOUTH); + for(counter = 0x17; counter >= 0; counter--) + { + IncreaseEntityPixelPos(medichamEntity, 0, 0x100); + DungeonRunFrameActions(0x46); + } + sub_806CE68(medichamEntity, DIRECTION_SOUTH); + sub_803E708(0x20, 0x46); + sub_8042B0C(medichamEntity); + sub_8068FE0(medichamEntity, 0x21C, 0); + gDungeon->unk4 = 1; + gDungeon->unk11 = 4; +} + +void sub_808CB5C(void) +{ + Entity *leaderEntity; + Entity *medichamEntity; + + leaderEntity = xxx_call_GetLeader(); + medichamEntity = GetEntityFromMonsterBehavior(BEHAVIOR_MEDICHAM); + DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + sub_8068FE0(medichamEntity, 0x21C, 0); + sub_8085860(leaderEntity->pos.x, leaderEntity->pos.y); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_MEDICHAM); +} + diff --git a/src/dungeon_cutscene_mewtwo.c b/src/dungeon_cutscene_mewtwo.c new file mode 100644 index 000000000..251483394 --- /dev/null +++ b/src/dungeon_cutscene_mewtwo.c @@ -0,0 +1,221 @@ +#include "global.h" +#include "globaldata.h" +#include "code_800DAC0.h" +#include "code_800E9A8.h" +#include "dungeon_vram.h" +#include "code_803E668.h" +#include "code_8041AD0.h" +#include "code_804267C.h" +#include "code_80861A8.h" +#include "code_806CD90.h" +#include "code_80869E4.h" +#include "constants/bg_music.h" +#include "constants/direction.h" +#include "constants/friend_area.h" +#include "constants/weather.h" +#include "dungeon_items.h" +#include "dungeon_leader.h" +#include "dungeon_map_access.h" +#include "dungeon_message.h" +#include "dungeon_music.h" +#include "dungeon_misc.h" +#include "dungeon_logic.h" +#include "dungeon_random.h" +#include "dungeon_util_1.h" +#include "dungeon_util.h" +#include "exclusive_pokemon.h" +#include "friend_area.h" +#include "items.h" +#include "pokemon_3.h" +#include "pokemon.h" +#include "position_util.h" +#include "trap.h" +#include "math.h" +#include "dungeon_config.h" +#include "dungeon_boss_dialogue.h" + +extern void sub_8042B0C(Entity *); +extern u8 sub_806FD18(Entity *); +extern void sub_806FDF4(Entity *, Entity *, Entity **); +extern s32 GetCameraXPos(void); +extern s32 GetCameraYPos(void); +extern void sub_803F878(u32, s32); +extern void BgColorCallNullsub4(void); +extern void sub_8085EB0(void); +extern void sub_8049884(void); +extern void sub_8049B8C(void); +extern void ShowWholeRevealedDungeonMap(void); +extern void sub_8086A54(Entity *); +extern void ResetMonEntityData(EntityInfo *, u32); +extern void sub_8041888(u32); +extern u32 sub_80861F8(u32, Entity *, u32); +extern u8 sub_80860A8(u32); +extern void sub_8052D44(s16 *, Entity *, Entity *); +extern void sub_80464C8(Entity *, DungeonPos *, Item *); +extern void SetDungeonBGColorRGB(u32, u32, u32, u32, u32); +extern u32 sub_8085EC8(u32, u32, u32, DungeonPos *, u32); +extern void sub_807EAA0(u32, u32); +extern void sub_8072008(Entity *, Entity *, s16, u32, u32); +extern void sub_8085374(void); +extern u32 GetRandomFloorItem(u32); +extern bool8 sub_8085B80(struct_8085B80 *); +extern void sub_8086A3C(Entity *pokemon); +extern void SetupBossFightHP(Entity *pokemon, s32 newHP, u16 songIndex); +extern u8 sub_8086AE4(s16 _index); + +static void MewtwoDropInEffect(Entity *mewtwoEntity); +static void MewtwoScreenFlash(void); + +void sub_8089914(void) +{ + Entity *leaderEntity; + Entity *MewtwoEntity; + + leaderEntity = xxx_call_GetLeader(); + MewtwoEntity = GetEntityFromMonsterBehavior(BEHAVIOR_MEWTWO); + DungeonStopBGM(); + gDungeon->unk7 = 1; + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + sub_80855E4(sub_8086A3C); + SetFacingDirection(MewtwoEntity, DIRECTION_SOUTH); + sub_8086A3C(MewtwoEntity); + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 3); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2],MONSTER_MEWTWO); +} + +void sub_8089978(void) +{ + Entity *leaderEntity; + Entity *MewtwoEntity; + + leaderEntity = xxx_call_GetLeader(); + MewtwoEntity = GetEntityFromMonsterBehavior(BEHAVIOR_MEWTWO); + DungeonStopBGM(); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + sub_80855E4(sub_8086A3C); + if(HasRecruitedMon(MONSTER_MEWTWO)){ + DungeonStartNewBGM(MUS_FRIEND_AREA_CRYPTIC_CAVE); + sub_8068FE0(MewtwoEntity,0x21c,0); + } + else { + gDungeon->unk7 = 1; + SetFacingDirection(MewtwoEntity, DIRECTION_SOUTH); + sub_8086A3C(MewtwoEntity); + } + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 3); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2],MONSTER_MEWTWO); +} + +void sub_8089A00(u8 param_1, u8 param_2) +{ + if ((param_2 == 0x1d || param_2 == 0x1e || param_2 == 0x1f) && (param_1 == 0x11)) { + sub_8097FA8(0x13); + gDungeon->unk2 = 1; + } +} + +void MewtwoPreFightDialogue(void) +{ + Entity *leaderEntity; + Entity *MewtwoEntity; + + leaderEntity = xxx_call_GetLeader(); + MewtwoEntity = GetEntityFromMonsterBehavior(BEHAVIOR_MEWTWO); + sub_8086448(); + DisplayDungeonDialogue(&gMewtwoPreFightDialogue_1); + sub_803E708(10,0x46); + DungeonStartNewBGM(MUS_FRIEND_AREA_CRYPTIC_CAVE); + sub_8086794(); + sub_803E708(0x1e,0x46); + MewtwoDropInEffect(MewtwoEntity); + sub_803E708(0x3c,0x46); + DisplayDungeonDialogue(&gMewtwoPreFightDialogue_2); + DisplayDungeonDialogue(&gMewtwoPreFightDialogue_3); + sub_803E708(10,0x46); + MewtwoScreenFlash(); + DisplayDungeonDialogue(&gMewtwoPreFightDialogue_4); + MewtwoScreenFlash(); + DisplayDungeonDialogue(&gMewtwoPreFightDialogue_5); + sub_803E708(10,0x46); + SetupBossFightHP(MewtwoEntity,900,MUS_BATTLE_WITH_RAYQUAZA); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); +} + +void MewtwoReFightDialogue(void) +{ + Entity *leaderEntity; + Entity *MewtwoEntity; + + leaderEntity = xxx_call_GetLeader(); + MewtwoEntity = GetEntityFromMonsterBehavior(BEHAVIOR_MEWTWO); + sub_8086448(); + if(HasRecruitedMon(MONSTER_MEWTWO)) { + sub_80866C4(&gMewtwoReFightDialogue_5); + } + else { + DisplayDungeonDialogue(&gMewtwoReFightDialogue_1); + DungeonStartNewBGM(MUS_FRIEND_AREA_CRYPTIC_CAVE); + sub_8086794(); + MewtwoDropInEffect(MewtwoEntity); + sub_803E708(0x3c,0x46); + DisplayDungeonDialogue(&gMewtwoReFightDialogue_2); + MewtwoScreenFlash(); + DisplayDungeonDialogue(&gMewtwoReFightDialogue_3); + MewtwoScreenFlash(); + DisplayDungeonDialogue(&gMewtwoReFightDialogue_4); + SetupBossFightHP(MewtwoEntity,900,MUS_BATTLE_WITH_RAYQUAZA); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); + } +} + +static void MewtwoDropInEffect(Entity *mewtwoEntity) +{ + s24_8 iVar1; + s24_8 iVar2; + + GetEntInfo(mewtwoEntity)->unk15E = 0; + iVar2 = IntToF248_2(200); + iVar1 = IntToF248_2(4); + PlaySoundEffect(0x1f8); + while( 1 ) { + iVar2.raw -= iVar1.raw; + iVar1 = F248_Sub(iVar1, FloatToF248_2(0.045)); + if (F248LessThanFloat(iVar1, 0.12)) { + iVar1 = FloatToF248_2(0.12); + } + if (F248LessThanInt(iVar2, 0)) break; + GetEntInfo(mewtwoEntity)->unk174 = iVar2; + DungeonRunFrameActions(0x46); + } + GetEntInfo(mewtwoEntity)->unk174 = IntToF248_2(0); +} + +static void MewtwoScreenFlash(void) +{ + int iVar1; + + PlaySoundEffect(0x1f6); + for(iVar1 = 250; iVar1 > 149; iVar1 -= 10) + { + SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,1); + DungeonRunFrameActions(0x46); + } + sub_803E708(10,0x46); + for(iVar1 = 250; iVar1 > 199; iVar1 -= 10) + { + SetDungeonBGColorRGB(iVar1,iVar1,0,1,1); + DungeonRunFrameActions(0x46); + } + sub_803E708(10,0x46); + for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10) + { + SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,1); + DungeonRunFrameActions(0x46); + } + sub_803E708(10,0x46); + sub_8085EB0(); +} + + diff --git a/src/dungeon_cutscene_moltres.c b/src/dungeon_cutscene_moltres.c new file mode 100644 index 000000000..6e2f072f7 --- /dev/null +++ b/src/dungeon_cutscene_moltres.c @@ -0,0 +1,369 @@ +#include "global.h" +#include "globaldata.h" +#include "code_800DAC0.h" +#include "code_800E9A8.h" +#include "dungeon_vram.h" +#include "code_803E668.h" +#include "code_8041AD0.h" +#include "code_804267C.h" +#include "code_80861A8.h" +#include "code_806CD90.h" +#include "code_80869E4.h" +#include "constants/bg_music.h" +#include "constants/direction.h" +#include "constants/friend_area.h" +#include "constants/weather.h" +#include "dungeon_items.h" +#include "dungeon_leader.h" +#include "dungeon_map_access.h" +#include "dungeon_message.h" +#include "dungeon_music.h" +#include "dungeon_misc.h" +#include "dungeon_logic.h" +#include "dungeon_random.h" +#include "dungeon_util_1.h" +#include "dungeon_util.h" +#include "exclusive_pokemon.h" +#include "friend_area.h" +#include "items.h" +#include "pokemon_3.h" +#include "pokemon.h" +#include "position_util.h" +#include "trap.h" +#include "math.h" +#include "dungeon_config.h" +#include "dungeon_boss_dialogue.h" + +extern void sub_8042B0C(Entity *); +extern u8 sub_806FD18(Entity *); +extern void sub_806FDF4(Entity *, Entity *, Entity **); +extern s32 GetCameraXPos(void); +extern s32 GetCameraYPos(void); +extern void sub_803F878(u32, s32); +extern void BgColorCallNullsub4(void); +extern void sub_8085EB0(void); +extern void sub_8049884(void); +extern void sub_8049B8C(void); +extern void ShowWholeRevealedDungeonMap(void); +extern void sub_8086A54(Entity *); +extern void ResetMonEntityData(EntityInfo *, u32); +extern void sub_8041888(u32); +extern u32 sub_80861F8(u32, Entity *, u32); +extern u8 sub_80860A8(u32); +extern void sub_8052D44(s16 *, Entity *, Entity *); +extern void sub_80464C8(Entity *, DungeonPos *, Item *); +extern void SetDungeonBGColorRGB(u32, u32, u32, u32, u32); +extern u32 sub_8085EC8(u32, u32, u32, DungeonPos *, u32); +extern void sub_807EAA0(u32, u32); +extern void sub_8072008(Entity *, Entity *, s16, u32, u32); +extern void sub_8085374(void); +extern u32 GetRandomFloorItem(u32); +extern bool8 sub_8085B80(struct_8085B80 *); +extern void sub_8086A3C(Entity *pokemon); +extern void SetupBossFightHP(Entity *pokemon, s32 newHP, u16 songIndex); +extern u8 sub_8086AE4(s16 _index); +extern void sub_8085F44(s32); + +static void MoltresDropInEffect(Entity * moltresEntity); +static void MoltresScreenFlash1(s32 xArg, s32 yArg); +static void MoltresScreenFlash2(s32 xArg, s32 yArg); +static void MoltresScreenFlash3(void); +static void MoltresScreenDarken(void); + +void sub_80877E8(void) +{ + Entity * leaderEntity; + Entity * moltresEntity; + + leaderEntity = xxx_call_GetLeader(); + moltresEntity = GetEntityFromMonsterBehavior(BEHAVIOR_MOLTRES); + DungeonStartNewBGM(MUS_THE_MOUNTAIN_OF_FIRE); + sub_8085374(); + sub_80854D4(); + sub_8085930(DIRECTION_WEST); + sub_80855E4(sub_8086A3C); + SetFacingDirection(moltresEntity, DIRECTION_SOUTH); + sub_8086A3C(moltresEntity); + sub_8085860(leaderEntity->pos.x + -3,leaderEntity->pos.y + -2); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_MOLTRES); +} + +void sub_8087848(void) +{ + Entity *leaderEntity; + Entity *moltresEntity; + + u32 XPos; + s32 YPos; + + leaderEntity = xxx_call_GetLeader(); + moltresEntity = GetEntityFromMonsterBehavior(BEHAVIOR_MOLTRES); + DungeonStartNewBGM(MUS_THE_MOUNTAIN_OF_FIRE); + sub_80854D4(); + sub_8085930(DIRECTION_WEST); + sub_80855E4(sub_8086A3C); + if (sub_8086AE4(MONSTER_MOLTRES)) { + sub_8068FE0(moltresEntity,0x21c,0); + } + else { + sub_8072008(moltresEntity,moltresEntity,gMoltresConfigLevel,0,0); + SetFacingDirection(moltresEntity, DIRECTION_SOUTH); + sub_8086A3C(moltresEntity); + } + sub_8085860(leaderEntity->pos.x - 5, leaderEntity->pos.y); + XPos = GetCameraXPos(); + YPos = GetCameraYPos(); + sub_803F878(XPos, YPos + -0x1000); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2],MONSTER_MOLTRES); +} + +void sub_80878F4(u8 param_1, u8 param_2) +{ + if ((param_2 == 0xA || param_2 == 0xB || param_2 == 0xC) && (param_1 == 0x9)) { + sub_8097FA8(0x7); + gDungeon->unk2 = 1; + } +} + +void MoltresPreFightDialogue(void) +{ + Entity *leaderEntity; + Entity *partnerEntity; + Entity *moltresEntity; + + leaderEntity = xxx_call_GetLeader(); + partnerEntity = GetPartnerEntity(); + moltresEntity = GetEntityFromMonsterBehavior(BEHAVIOR_MOLTRES); + MoltresScreenFlash1(0xc,5); + sub_8086500(); + sub_803E708(10,0x46); + DisplayDungeonDialogue(&gMoltresPreFightDialogue_1); + sub_803E708(10,0x46); + sub_80869E4(partnerEntity,4,1,DIRECTION_NORTHWEST); + sub_803E708(4,0x46); + SpriteLookAroundEffect(partnerEntity); + sub_803E708(10,0x46); + DisplayDungeonDialogue(gMoltresPreFightDialogue_2); + sub_803E708(10,0x46); + MoltresScreenFlash1(0xc,5); + MoltresScreenFlash2(9,5); + DisplayDungeonDialogue(gMoltresPreFightDialogue_3); + sub_803E708(10,0x46); + sub_80869E4(partnerEntity,4,1,DIRECTION_EAST); + sub_80869E4(leaderEntity,4,2,DIRECTION_WEST); + DisplayDungeonDialogue(gMoltresPreFightDialogue_4); + sub_803E708(10,0x46); + sub_80869E4(partnerEntity,4,2,DIRECTION_WEST); + sub_8086690(); + DisplayDungeonDialogue(&gMoltresPreFightDialogue_5); + sub_803E708(10,0x46); + sub_8085930(DIRECTION_NORTHWEST); + sub_803E708(4,0x46); + sub_8085930(DIRECTION_NORTH); + PlaySoundEffect(0x2f2); + DungeonStopBGM(); + MoltresScreenDarken(); + DisplayDungeonDialogue(gMoltresPreFightDialogue_6); + sub_803E708(10,0x46); + DisplayDungeonDialogue(&gMoltresPreFightDialogue_7); + sub_803E708(10,0x46); + PlaySoundEffect(0x1cf); + sub_80856E0(partnerEntity, DIRECTION_NORTH); + sub_803E708(10,0x46); + DisplayDungeonDialogue(gMoltresPreFightDialogue_8); + sub_803E708(10,0x46); + MoltresScreenFlash3(); + PlaySoundEffect(0x1da); + DisplayDungeonDialogue(&gMoltresPreFightDialogue_9); + sub_803E708(10,0x46); + MoltresScreenFlash1(9,5); + MoltresScreenFlash2(0xb,5); + DisplayDungeonDialogue(&gMoltresPreFightDialogue_10); + sub_803E708(10,0x46); + MoltresScreenFlash1(0xc,5); + MoltresScreenFlash2(9,5); + MoltresDropInEffect(moltresEntity); + sub_808663C(); + MoltresScreenFlash3(); + DisplayDungeonDialogue(&gMoltresPreFightDialogue_11); + sub_803E708(10,0x46); + MoltresScreenFlash2(0xb,6); + DisplayDungeonDialogue(&gMoltresPreFightDialogue_12); + sub_803E708(10,0x46); + SetupBossFightHP(moltresEntity,400,MUS_BOSS_BATTLE); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); +} + +void MoltresReFightDialogue(void) +{ + Entity *leaderEntity; + Entity *partnerEntity; + Entity *moltresEntity; + + leaderEntity = xxx_call_GetLeader(); + partnerEntity = GetPartnerEntity(); + moltresEntity = GetEntityFromMonsterBehavior(BEHAVIOR_MOLTRES); + MoltresScreenFlash1(10,5); + sub_8086500(); + sub_803E708(10,0x46); + SpriteLookAroundEffect(partnerEntity); + sub_803E708(10,0x46); + DisplayDungeonDialogue(&gMoltresReFightDialogue_1); + sub_803E708(10,0x46); + sub_80869E4(partnerEntity,4,1,DIRECTION_EAST); + sub_80869E4(leaderEntity,4,2,DIRECTION_WEST); + DisplayDungeonDialogue(gMoltresReFightDialogue_2); + sub_803E708(10,0x46); + sub_80869E4(partnerEntity,4,2,DIRECTION_WEST); + sub_80869E4(leaderEntity,4,2,DIRECTION_WEST); + sub_8086690(); + MoltresScreenDarken(); + sub_803E708(10,0x46); + sub_8085930(DIRECTION_NORTHWEST); + sub_803E708(4,0x46); + sub_8085930(DIRECTION_NORTH); + MoltresDropInEffect(moltresEntity); + sub_808663C(); + MoltresScreenFlash3(); + DisplayDungeonDialogue(&gMoltresReFightDialogue_3); + sub_803E708(10,0x46); + MoltresScreenFlash2(0xb,6); + DisplayDungeonDialogue(gMoltresReFightDialogue_4); + sub_803E708(10,0x46); + DisplayDungeonDialogue(&gMoltresReFightDialogue_5); + sub_803E708(10,0x46); + SetupBossFightHP(moltresEntity,400,MUS_BOSS_BATTLE); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); +} + +void MoltresPostStoryPreFightDialogue(void) +{ + Entity * leaderEntity; + Entity * moltresEntity; + + leaderEntity = xxx_call_GetLeader(); + moltresEntity = GetEntityFromMonsterBehavior(BEHAVIOR_MOLTRES); + MoltresScreenFlash1(0xc,5); + sub_808654C(); + if (sub_8086AE4(MONSTER_MOLTRES)) { + sub_8085930(DIRECTION_NORTHWEST); + sub_803E708(4,0x46); + sub_8085930(DIRECTION_NORTH); + sub_803E708(4,0x46); + sub_803E708(10,0x46); + DisplayDungeonDialogue(&gUnknown_8100D3C); + sub_803E708(10,0x46); + gDungeon->unk2 = 1; + } + else { + DisplayDungeonDialogue(&gMoltresPostStoryPreFightDialogue_1); + sub_8085930(DIRECTION_NORTHWEST); + sub_803E708(4,0x46); + sub_8085930(DIRECTION_NORTH); + MoltresDropInEffect(moltresEntity); + DisplayDungeonDialogue(&gMoltresPostStoryPreFightDialogue_2); + MoltresScreenFlash1(0xc,5); + MoltresScreenFlash2(9,5); + DisplayDungeonDialogue(&gMoltresPostStoryPreFightDialogue_3); + MoltresScreenFlash3(); + DisplayDungeonDialogue(&gMoltresPostStoryPreFightDialogue_4); + MoltresScreenFlash2(0xb,6); + DisplayDungeonDialogue(&gMoltresPostStoryPreFightDialogue_5); + sub_803E708(10,0x46); + SetupBossFightHP(moltresEntity,400,MUS_BOSS_BATTLE); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); + } +} + +static void MoltresDropInEffect(Entity * moltresEntity) +{ + s32 iVar1; + + GetEntInfo(moltresEntity)->unk15C = 1; + GetEntInfo(moltresEntity)->unk15E = 0; + GetEntInfo(moltresEntity)->unk174 = IntToF248_2(200); + PlaySoundEffect(0x1f8); + for(iVar1 = 200; iVar1 >= 0; iVar1 -= 5) + { + GetEntInfo(moltresEntity)->unk174 = IntToF248_2(iVar1); + DungeonRunFrameActions(0x46); + } +} + +static void MoltresScreenFlash1(s32 xArg, s32 yArg) +{ + s32 x, y; + DungeonPos newPos; + + x = X_POS_TO_PIXELPOS(xArg); + newPos.x = x / 256; + + y = Y_POS_TO_PIXELPOS(yArg); + newPos.y = y / 256; + + sub_8085EC8(370,16,0,&newPos,0); +} + +static void MoltresScreenFlash2(s32 xArg, s32 yArg) +{ + s32 r6; + s32 i, x, y; + DungeonPos newPos; + + x = X_POS_TO_PIXELPOS(xArg); + newPos.x = x / 256; + + y = Y_POS_TO_PIXELPOS(yArg); + newPos.y = y / 256; + + r6 = sub_8085EC8(370,22,0,&newPos,0); + PlaySoundEffect(0x1EC); + + for (i = 250; i >= 20; i -= 10) { + SetDungeonBGColorRGB(i, 0, 0, 1, 1); + DungeonRunFrameActions(0x46); + } + sub_803E708(0xA, 0x46); + + for (i = 250; i >= 0; i -= 10) { + SetDungeonBGColorRGB(i, 0, 0, 1, 1); + DungeonRunFrameActions(0x46); + } + sub_803E708(0xA, 0x46); + + sub_8085EB0(); + sub_8085F44(r6); +} + +static void MoltresScreenFlash3(void) +{ + int iVar1; + + PlaySoundEffect(0x1ed); + iVar1 = 0xfa; + for(iVar1 = 250; iVar1 > 9; iVar1 -= 10) + { + SetDungeonBGColorRGB(iVar1,iVar1,iVar1 / 2,1,1); + DungeonRunFrameActions(0x46); + } + sub_803E708(0x1e,0x46); + PlaySoundEffect(0x1ed); + for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10) + { + SetDungeonBGColorRGB(iVar1,iVar1,iVar1 / 2,1,1); + DungeonRunFrameActions(0x46); + } + sub_803E708(0x1e,0x46); + sub_8085EB0(); +} + +static void MoltresScreenDarken(void) +{ + s32 iVar1; + + for(iVar1 = 0; iVar1 >= -80; iVar1 -= 8) + { + SetDungeonBGColorRGB(iVar1,iVar1,iVar1,0,0); + DungeonRunFrameActions(0x46); + } +} diff --git a/src/dungeon_cutscene_no_one_here.c b/src/dungeon_cutscene_no_one_here.c new file mode 100644 index 000000000..693c6cd95 --- /dev/null +++ b/src/dungeon_cutscene_no_one_here.c @@ -0,0 +1,13 @@ +#include "global.h" +#include "globaldata.h" +#include "code_80869E4.h" +#include "dungeon_boss_dialogue.h" + +void sub_808CD9C(void) +{ + sub_8086448(); + // There appears to be no one here. + // It's impossible to go any further + sub_80866C4(&gUnknown_810697C); +} + diff --git a/src/dungeon_cutscene_raikou.c b/src/dungeon_cutscene_raikou.c new file mode 100644 index 000000000..c81fdfe6d --- /dev/null +++ b/src/dungeon_cutscene_raikou.c @@ -0,0 +1,220 @@ +#include "global.h" +#include "globaldata.h" +#include "code_800DAC0.h" +#include "code_800E9A8.h" +#include "dungeon_vram.h" +#include "code_803E668.h" +#include "code_8041AD0.h" +#include "code_804267C.h" +#include "code_80861A8.h" +#include "code_806CD90.h" +#include "code_80869E4.h" +#include "constants/bg_music.h" +#include "constants/direction.h" +#include "constants/friend_area.h" +#include "constants/weather.h" +#include "dungeon_items.h" +#include "dungeon_leader.h" +#include "dungeon_map_access.h" +#include "dungeon_message.h" +#include "dungeon_music.h" +#include "dungeon_misc.h" +#include "dungeon_logic.h" +#include "dungeon_random.h" +#include "dungeon_util_1.h" +#include "dungeon_util.h" +#include "exclusive_pokemon.h" +#include "friend_area.h" +#include "items.h" +#include "pokemon_3.h" +#include "pokemon.h" +#include "position_util.h" +#include "trap.h" +#include "math.h" +#include "dungeon_config.h" +#include "dungeon_boss_dialogue.h" + +extern void sub_8042B0C(Entity *); +extern u8 sub_806FD18(Entity *); +extern void sub_806FDF4(Entity *, Entity *, Entity **); +extern s32 GetCameraXPos(void); +extern s32 GetCameraYPos(void); +extern void sub_803F878(u32, s32); +extern void BgColorCallNullsub4(void); +extern void sub_8085EB0(void); +extern void sub_8049884(void); +extern void sub_8049B8C(void); +extern void ShowWholeRevealedDungeonMap(void); +extern void sub_8086A54(Entity *); +extern void ResetMonEntityData(EntityInfo *, u32); +extern void sub_8041888(u32); +extern u32 sub_80861F8(u32, Entity *, u32); +extern u8 sub_80860A8(u32); +extern void sub_8052D44(s16 *, Entity *, Entity *); +extern void sub_80464C8(Entity *, DungeonPos *, Item *); +extern void SetDungeonBGColorRGB(u32, u32, u32, u32, u32); +extern u32 sub_8085EC8(u32, u32, u32, DungeonPos *, u32); +extern void sub_807EAA0(u32, u32); +extern void sub_8072008(Entity *, Entity *, s16, u32, u32); +extern void sub_8085374(void); +extern u32 GetRandomFloorItem(u32); +extern bool8 sub_8085B80(struct_8085B80 *); +extern void sub_8086A3C(Entity *pokemon); +extern void SetupBossFightHP(Entity *pokemon, s32 newHP, u16 songIndex); +extern u8 sub_8086AE4(s16 _index); + +static void RaikouScreenFlash(void); + +void sub_8089EFC(void) +{ + Entity * leaderEntity; + Entity * RaikouEntity; + + leaderEntity = xxx_call_GetLeader(); + RaikouEntity = GetEntityFromMonsterBehavior(BEHAVIOR_RAIKOU); + DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + SetFacingDirection(RaikouEntity, DIRECTION_SOUTH); + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_RAIKOU); +} + +void sub_8089F44(void) +{ + Entity * leaderEntity; + Entity * RaikouEntity; + + leaderEntity = xxx_call_GetLeader(); + RaikouEntity = GetEntityFromMonsterBehavior(BEHAVIOR_RAIKOU); + DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + SetFacingDirection(RaikouEntity, DIRECTION_SOUTH); + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_RAIKOU); +} + +void sub_8089F8C(void) +{ + Entity * leaderEntity; + Entity * RaikouEntity; + + leaderEntity = xxx_call_GetLeader(); + RaikouEntity = GetEntityFromMonsterBehavior(BEHAVIOR_RAIKOU); + DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + if (HasRecruitedMon(MONSTER_RAIKOU)) { + sub_8068FE0(RaikouEntity,0x21c,0); + } + else { + SetFacingDirection(RaikouEntity, DIRECTION_SOUTH); + } + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_RAIKOU); +} + +void sub_8089FF0(u8 param_1, u8 param_2) +{ + if ((param_2 == 0x23 || param_2 == 0x24 || param_2 == 0x25) && (param_1 == 0x13)) { + sub_8097FA8(0x17); + gDungeon->unk2 = 1; + } +} + +void RaikouPreFightDialogue(void) +{ + Entity * leaderEntity; + Entity * RaikouEntity; + + leaderEntity = xxx_call_GetLeader(); + RaikouEntity = GetEntityFromMonsterBehavior(BEHAVIOR_RAIKOU); + DisplayDungeonDialogue(&gRaikouPreFightDialogue_1); + RaikouScreenFlash(); + DisplayDungeonDialogue(&gRaikouPreFightDialogue_2); + gDungeon->weather.unkE265 = WEATHER_RAIN; + sub_807EAA0(0,1); + sub_803E708(10,70); + DisplayDungeonDialogue(&gRaikouPreFightDialogue_3); + RaikouScreenFlash(); + DisplayDungeonDialogue(&gRaikouPreFightDialogue_4); + RaikouScreenFlash(); + DisplayDungeonDialogue(&gRaikouPreFightDialogue_5); + RaikouScreenFlash(); + DisplayDungeonDialogue(&gRaikouPreFightDialogue_6); + sub_803E708(10,70); + SetupBossFightHP(RaikouEntity,0x28a,MUS_BOSS_BATTLE); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); +} + +void RaikouReFightDialogue(void) +{ + Entity * leaderEntity; + Entity * RaikouEntity; + + leaderEntity = xxx_call_GetLeader(); + RaikouEntity = GetEntityFromMonsterBehavior(BEHAVIOR_RAIKOU); + gDungeon->weather.unkE265 = WEATHER_RAIN; + sub_807EAA0(0,1); + RaikouScreenFlash(); + DisplayDungeonDialogue(&gRaikouReFightDialogue_1); + RaikouScreenFlash(); + DisplayDungeonDialogue(&gRaikouReFightDialogue_2); + RaikouScreenFlash(); + DisplayDungeonDialogue(&gRaikouReFightDialogue_3); + sub_803E708(10,70); + SetupBossFightHP(RaikouEntity,0x28a,MUS_BOSS_BATTLE); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); +} + +void RaikouPostStoryPreFightDialogue(void) +{ + Entity * leaderEntity; + Entity * RaikouEntity; + + leaderEntity = xxx_call_GetLeader(); + RaikouEntity = GetEntityFromMonsterBehavior(BEHAVIOR_RAIKOU); + if (HasRecruitedMon(MONSTER_RAIKOU)) { + sub_80866C4(&gRaikouPostStoryPreFightDialogue_4); + } + else { + gDungeon->weather.unkE265 = WEATHER_RAIN; + sub_807EAA0(0,1); + DisplayDungeonDialogue(&gRaikouPostStoryPreFightDialogue_1); + RaikouScreenFlash(); + DisplayDungeonDialogue(&gRaikouPostStoryPreFightDialogue_2); + RaikouScreenFlash(); + DisplayDungeonDialogue(&gRaikouPostStoryPreFightDialogue_3); + sub_803E708(10,70); + SetupBossFightHP(RaikouEntity,0x28a,MUS_BOSS_BATTLE); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); + } +} + +static void RaikouScreenFlash(void) +{ + s32 iVar1; + + PlaySoundEffect(0x1f6); + for(iVar1 = 250; iVar1 > 149; iVar1 -= 10) + { + SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,1); + DungeonRunFrameActions(70); + } + sub_803E708(10,70); + for(iVar1 = 250; iVar1 > 199; iVar1 -= 10) + { + SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,1); + DungeonRunFrameActions(70); + } + sub_803E708(10,70); + for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10) + { + SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,1); + DungeonRunFrameActions(70); + } + sub_803E708(10,70); + sub_8085EB0(); +} + diff --git a/src/dungeon_cutscene_rayquaza.c b/src/dungeon_cutscene_rayquaza.c new file mode 100644 index 000000000..c03bd7f23 --- /dev/null +++ b/src/dungeon_cutscene_rayquaza.c @@ -0,0 +1,255 @@ +#include "global.h" +#include "globaldata.h" +#include "code_800DAC0.h" +#include "code_800E9A8.h" +#include "dungeon_vram.h" +#include "code_803E668.h" +#include "code_8041AD0.h" +#include "code_804267C.h" +#include "code_80861A8.h" +#include "code_806CD90.h" +#include "code_80869E4.h" +#include "constants/bg_music.h" +#include "constants/direction.h" +#include "constants/friend_area.h" +#include "constants/weather.h" +#include "dungeon_items.h" +#include "dungeon_leader.h" +#include "dungeon_map_access.h" +#include "dungeon_message.h" +#include "dungeon_music.h" +#include "dungeon_misc.h" +#include "dungeon_logic.h" +#include "dungeon_random.h" +#include "dungeon_util_1.h" +#include "dungeon_util.h" +#include "exclusive_pokemon.h" +#include "friend_area.h" +#include "items.h" +#include "pokemon_3.h" +#include "pokemon.h" +#include "position_util.h" +#include "trap.h" +#include "math.h" +#include "dungeon_config.h" +#include "dungeon_boss_dialogue.h" + +extern void sub_8042B0C(Entity *); +extern u8 sub_806FD18(Entity *); +extern void sub_806FDF4(Entity *, Entity *, Entity **); +extern s32 GetCameraXPos(void); +extern s32 GetCameraYPos(void); +extern void sub_803F878(u32, s32); +extern void BgColorCallNullsub4(void); +extern void sub_8085EB0(void); +extern void sub_8049884(void); +extern void sub_8049B8C(void); +extern void ShowWholeRevealedDungeonMap(void); +extern void sub_8086A54(Entity *); +extern void ResetMonEntityData(EntityInfo *, u32); +extern void sub_8041888(u32); +extern u32 sub_80861F8(u32, Entity *, u32); +extern u8 sub_80860A8(u32); +extern void sub_8052D44(s16 *, Entity *, Entity *); +extern void sub_80464C8(Entity *, DungeonPos *, Item *); +extern void SetDungeonBGColorRGB(u32, u32, u32, u32, u32); +extern u32 sub_8085EC8(u32, u32, u32, DungeonPos *, u32); +extern void sub_807EAA0(u32, u32); +extern void sub_8072008(Entity *, Entity *, s16, u32, u32); +extern void sub_8085374(void); +extern u32 GetRandomFloorItem(u32); +extern bool8 sub_8085B80(struct_8085B80 *); +extern void sub_8086A3C(Entity *pokemon); +extern void SetupBossFightHP(Entity *pokemon, s32 newHP, u16 songIndex); +extern u8 sub_8086AE4(s16 _index); + +static void RayquazaDropInEffect(Entity *rayquazaEntity); +static void RayquazaScreenFlash(void); + +void sub_80892C8(void) +{ + Entity * leaderEntity; + Entity * RayquazaEntity; + + leaderEntity = xxx_call_GetLeader(); + RayquazaEntity = GetEntityFromMonsterBehavior(BEHAVIOR_RAYQUAZA); + DungeonStartNewBGM(MUS_RAYQUAZAS_DOMAIN); + sub_8085374(); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + sub_80855E4(sub_8086A3C); + SetFacingDirection(RayquazaEntity, DIRECTION_SOUTH); + sub_8086A3C(RayquazaEntity); + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 3); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2],MONSTER_RAYQUAZA); +} + +void sub_8089328(void) +{ + Entity * leaderEntity; + Entity * rayquazaEntity; + + leaderEntity = xxx_call_GetLeader(); + rayquazaEntity = GetEntityFromMonsterBehavior(BEHAVIOR_RAYQUAZA); + DungeonStartNewBGM(MUS_RAYQUAZAS_DOMAIN); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + sub_80855E4(sub_8086A3C); + if (sub_8086AE4(MONSTER_RAYQUAZA)) { + sub_8068FE0(rayquazaEntity,0x21c,0); + } + else { + sub_8072008(rayquazaEntity,rayquazaEntity,gRayquazaConfigLevel,0,0); + sub_8086A3C(rayquazaEntity); + } + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 3); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2],MONSTER_RAYQUAZA); +} + +void sub_80893B4(u8 param_1, u8 param_2) +{ + if ((param_2 == 0x17 || param_2 == 0x18 || param_2 == 0x19) && (param_1 == 0xF)) { + sub_8097FA8(0xF); + gDungeon->unk2 = 1; + } +} + +void RayquazaPreFightDialogue(void) +{ + Entity *leaderEntity; + Entity *partnerEntity; + Entity *rayquazaEntity; + + leaderEntity = xxx_call_GetLeader(); + partnerEntity = GetPartnerEntity(); + rayquazaEntity = GetEntityFromMonsterBehavior(BEHAVIOR_RAYQUAZA); + sub_8086448(); + DisplayDungeonDialogue(&gRayquazaPreFightDialogue_1); + RayquazaScreenFlash(); + DisplayDungeonDialogue(&gRayquazaPreFightDialogue_2); + sub_80856E0(partnerEntity, DIRECTION_NORTH); + SpriteLookAroundEffect(partnerEntity); + sub_803E708(10,0x46); + sub_80869E4(partnerEntity,4,1,DIRECTION_EAST); + sub_80869E4(leaderEntity,4,2,DIRECTION_WEST); + DisplayDungeonDialogue(gRayquazaPreFightDialogue_3); + sub_80869E4(partnerEntity,4,2,DIRECTION_NORTH); + sub_80869E4(leaderEntity,4,1,DIRECTION_NORTH); + DisplayDungeonDialogue(&gRayquazaPreFightDialogue_4); + sub_803E708(10,0x46); + DisplayDungeonDialogue(&gRayquazaPreFightDialogue_5); + sub_803E708(10,0x46); + DisplayDungeonDialogue(&gRayquazaPreFightDialogue_6); + RayquazaScreenFlash(); + PlaySoundEffect(0x1da); // Rayquaza Cry + DisplayDungeonDialogue(&gRayquazaPreFightDialogue_7); + RayquazaDropInEffect(rayquazaEntity); + DisplayDungeonDialogue(&gRayquazaPreFightDialogue_8); + RayquazaScreenFlash(); + DisplayDungeonDialogue(&gRayquazaPreFightDialogue_9); + RayquazaScreenFlash(); + DisplayDungeonDialogue(&gRayquazaPreFightDialogue_10); + RayquazaScreenFlash(); + DisplayDungeonDialogue(&gRayquazaPreFightDialogue_11); + SetupBossFightHP(rayquazaEntity,600,MUS_BATTLE_WITH_RAYQUAZA); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); +} + +void RayquazaReFightDialogue(void) +{ + Entity *leaderEntity; + Entity *rayquazaEntity; + + leaderEntity = xxx_call_GetLeader(); + rayquazaEntity = GetEntityFromMonsterBehavior(BEHAVIOR_RAYQUAZA); + sub_8086448(); + RayquazaScreenFlash(); + PlaySoundEffect(0x1da); // Rayquaza Cry + DisplayDungeonDialogue(&gRayquazaPreFightDialogue_7); + sub_803E708(10,0x46); + RayquazaDropInEffect(rayquazaEntity); + DisplayDungeonDialogue(&gRayquazaReFightDialogue_1); + RayquazaScreenFlash(); + DisplayDungeonDialogue(&gRayquazaReFightDialogue_2); + RayquazaScreenFlash(); + DisplayDungeonDialogue(&gRayquazaReFightDialogue_3); + RayquazaScreenFlash(); + DisplayDungeonDialogue(&gRayquazaReFightDialogue_4); + SetupBossFightHP(rayquazaEntity,600,MUS_BATTLE_WITH_RAYQUAZA); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); +} + +void RayquazaPostStoryPreFightDialogue(void) +{ + Entity *leaderEntity; + Entity *rayquazaEntity; + + leaderEntity = xxx_call_GetLeader(); + rayquazaEntity = GetEntityFromMonsterBehavior(BEHAVIOR_RAYQUAZA); + sub_8086448(); + if (sub_8086AE4(MONSTER_RAYQUAZA)) { + sub_80866C4(&gRayquazaPostStoryPreFightDialogue_6); + } + else { + PlaySoundEffect(0x1da); // Rayquaza Cry + DisplayDungeonDialogue(&gRayquazaPostStoryPreFightDialogue_1); + RayquazaDropInEffect(rayquazaEntity); + DisplayDungeonDialogue(&gRayquazaPostStoryPreFightDialogue_2); + RayquazaScreenFlash(); + DisplayDungeonDialogue(&gRayquazaPostStoryPreFightDialogue_3); + RayquazaScreenFlash(); + DisplayDungeonDialogue(&gRayquazaPostStoryPreFightDialogue_4); + RayquazaScreenFlash(); + DisplayDungeonDialogue(&gRayquazaPostStoryPreFightDialogue_5); + SetupBossFightHP(rayquazaEntity,600,MUS_BOSS_BATTLE); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); + } +} + +static void RayquazaDropInEffect(Entity *rayquazaEntity) +{ + s24_8 iVar1; + s24_8 iVar2; + + GetEntInfo(rayquazaEntity)->unk15E = 0; + iVar2 = IntToF248_2(200); + iVar1 = IntToF248_2(6); + PlaySoundEffect(0x1f8); + while( 1 ) { + iVar2.raw = iVar2.raw - iVar1.raw; // must be .raw + iVar1 = F248_Sub(iVar1, FloatToF248_2(3./32.)); + if (F248LessThanFloat(iVar1, 0.08)) { + iVar1 = FloatToF248(0.08); + } + if (F248LessThanInt(iVar2, 0)) break; + GetEntInfo(rayquazaEntity)->unk174 = iVar2; + DungeonRunFrameActions(0x46); + } + GetEntInfo(rayquazaEntity)->unk174 = IntToF248_2(0); +} + +static void RayquazaScreenFlash(void) +{ + s32 iVar1; + + PlaySoundEffect(0x1f6); + for(iVar1 = 250; iVar1 > 149; iVar1 -= 10) + { + SetDungeonBGColorRGB(iVar1 / 2, iVar1, iVar1 / 2, 1, 1); + DungeonRunFrameActions(70); + } + sub_803E708(10,70); + for(iVar1 = 250; iVar1 > 199; iVar1 -= 10) + { + SetDungeonBGColorRGB(iVar1 / 2, iVar1, 0, 1, 1); + DungeonRunFrameActions(70); + } + sub_803E708(10,70); + for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10) + { + SetDungeonBGColorRGB(iVar1 / 2, iVar1, iVar1 / 2, 1, 1); + DungeonRunFrameActions(70); + } + sub_803E708(10,70); + sub_8085EB0(); +} diff --git a/src/dungeon_cutscene_regis.c b/src/dungeon_cutscene_regis.c new file mode 100644 index 000000000..900d84b9d --- /dev/null +++ b/src/dungeon_cutscene_regis.c @@ -0,0 +1,363 @@ +#include "global.h" +#include "globaldata.h" +#include "code_800DAC0.h" +#include "code_800E9A8.h" +#include "dungeon_vram.h" +#include "code_803E668.h" +#include "code_8041AD0.h" +#include "code_804267C.h" +#include "code_80861A8.h" +#include "code_806CD90.h" +#include "code_80869E4.h" +#include "constants/bg_music.h" +#include "constants/direction.h" +#include "constants/friend_area.h" +#include "constants/weather.h" +#include "dungeon_items.h" +#include "dungeon_leader.h" +#include "dungeon_map_access.h" +#include "dungeon_message.h" +#include "dungeon_music.h" +#include "dungeon_misc.h" +#include "dungeon_logic.h" +#include "dungeon_random.h" +#include "dungeon_util_1.h" +#include "dungeon_util.h" +#include "exclusive_pokemon.h" +#include "friend_area.h" +#include "items.h" +#include "pokemon_3.h" +#include "pokemon.h" +#include "position_util.h" +#include "trap.h" +#include "math.h" +#include "dungeon_config.h" +#include "dungeon_boss_dialogue.h" + +extern void sub_8042B0C(Entity *); +extern u8 sub_806FD18(Entity *); +extern void sub_806FDF4(Entity *, Entity *, Entity **); +extern s32 GetCameraXPos(void); +extern s32 GetCameraYPos(void); +extern void sub_803F878(u32, s32); +extern void BgColorCallNullsub4(void); +extern void sub_8085EB0(void); +extern void sub_8049884(void); +extern void sub_8049B8C(void); +extern void ShowWholeRevealedDungeonMap(void); +extern void sub_8086A54(Entity *); +extern void ResetMonEntityData(EntityInfo *, u32); +extern void sub_8041888(u32); +extern u32 sub_80861F8(u32, Entity *, u32); +extern u8 sub_80860A8(u32); +extern void sub_8052D44(s16 *, Entity *, Entity *); +extern void sub_80464C8(Entity *, DungeonPos *, Item *); +extern void SetDungeonBGColorRGB(u32, u32, u32, u32, u32); +extern u32 sub_8085EC8(u32, u32, u32, DungeonPos *, u32); +extern void sub_807EAA0(u32, u32); +extern void sub_8072008(Entity *, Entity *, s16, u32, u32); +extern void sub_8085374(void); +extern u32 GetRandomFloorItem(u32); +extern bool8 sub_8085B80(struct_8085B80 *); +extern void sub_8086A3C(Entity *pokemon); +extern void SetupBossFightHP(Entity *pokemon, s32 newHP, u16 songIndex); +extern u8 sub_8086AE4(s16 _index); + +static void sub_808B1CC(u8 itemID); +static void SetupRegiFacingDirection(Entity *regiEntity); +static void SetupRegirockFightHP(Entity *r0); +static void SetupRegiceFightHP(Entity *r0); +static void SetupRegisteelFightHP(Entity *r0); + +void sub_808ACC0(void) +{ + Entity * entity; + + if (HasRecruitedMon(MONSTER_REGIROCK)) { + entity = GetEntityFromMonsterBehavior(BEHAVIOR_REGIROCK); + sub_8068FE0(entity,0x21c,0); + sub_8097FA8(0x22); + sub_8097FA8(0x1d); + sub_808B1CC(ITEM_ROCK_PART); + } + else if (sub_80860A8(ITEM_ROCK_PART) != 0) { + sub_8098044(0x22); + sub_8097FA8(0x1d); + } + else if (sub_80860A8(ITEM_MUSIC_BOX) != 0) { + sub_8098044(0x22); + sub_8097FA8(0x1d); + } + else { + sub_8098044(0x22); + sub_8098044(0x1d); + sub_80855E4(SetupRegiFacingDirection); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_REGIROCK); + } +} + +void sub_808AD48(void) +{ + Entity * entity; + + if (HasRecruitedMon(MONSTER_REGICE)) { + entity = GetEntityFromMonsterBehavior(BEHAVIOR_REGICE); + sub_8068FE0(entity,0x21c,0); + sub_8097FA8(0x22); + sub_8097FA8(0x1d); + sub_808B1CC(ITEM_ICE_PART); + } + else if (sub_80860A8(ITEM_ICE_PART) != 0) { + sub_8098044(0x22); + sub_8097FA8(0x1d); + } + else if (sub_80860A8(ITEM_MUSIC_BOX) != 0) { + sub_8098044(0x22); + sub_8097FA8(0x1d); + } + else { + sub_8098044(0x22); + sub_8098044(0x1d); + sub_80855E4(SetupRegiFacingDirection); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_REGICE); + } +} + +void sub_808ADCC(void) +{ + + Entity * entity; + + if (HasRecruitedMon(MONSTER_REGISTEEL)) { + entity = GetEntityFromMonsterBehavior(BEHAVIOR_REGISTEEL); + sub_8068FE0(entity,0x21c,0); + sub_8097FA8(0x22); + sub_8097FA8(0x1d); + sub_808B1CC(ITEM_STEEL_PART); + } + else if (sub_80860A8(ITEM_STEEL_PART) != 0) { + sub_8098044(0x22); + sub_8097FA8(0x1d); + } + else if (sub_80860A8(ITEM_MUSIC_BOX) != 0) { + sub_8098044(0x22); + sub_8097FA8(0x1d); + } + else { + sub_8098044(0x22); + sub_8098044(0x1d); + sub_80855E4(SetupRegiFacingDirection); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_REGISTEEL); + } +} + +void sub_808AE54(u8 param_1,u8 param_2,DungeonPos *param_3) +{ + Entity * leaderEntity; + s16 IDStack[2]; + Item item; + + + leaderEntity = xxx_call_GetLeader(); + sub_8052D44(IDStack,leaderEntity,0); + if (!sub_8098100(0x22) && (param_2 == 0x2E) && (param_1 == 0x17)) { + sub_808B1CC(ITEM_NOTHING); + if (!sub_8098100(0x1d)) { + ItemIdToSlot(&item,ITEM_ROCK_PART,0); + sub_80464C8(GetLeader(),param_3,&item); + DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); + // Something fell from Regirock's body + // Regirock was apparently guarding this item + DisplayDungeonDialogue(&gRegirockPostFightDialogue_1); + } + } +} + +void sub_808AEC8(u8 param_1,u8 param_2,DungeonPos *param_3) +{ + Entity * leaderEntity; + s16 IDStack[2]; + Item item; + + + leaderEntity = xxx_call_GetLeader(); + sub_8052D44(IDStack,leaderEntity,0); + if (!sub_8098100(0x22) && (param_2 == 0x2F) && (param_1 == 0x18)) { + sub_808B1CC(ITEM_NOTHING); + if (!sub_8098100(0x1d)) { + ItemIdToSlot(&item,ITEM_ICE_PART,0); + sub_80464C8(GetLeader(),param_3,&item); + DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); + // Something fell from Regice's body + // Regice was apparently guarding this item + DisplayDungeonDialogue(&gRegicePostFightDialogue_1); + } + } +} + +void sub_808AF3C(u8 param_1,u8 param_2,DungeonPos *param_3) +{ + Entity * leaderEntity; + s16 IDStack[2]; + Item item; + + + leaderEntity = xxx_call_GetLeader(); + sub_8052D44(IDStack,leaderEntity,0); + if (!sub_8098100(0x22) && (param_2 == 0x30) && (param_1 == 0x19)) { + sub_808B1CC(ITEM_NOTHING); + if (!sub_8098100(0x1d)) { + ItemIdToSlot(&item,ITEM_STEEL_PART,0); + sub_80464C8(GetLeader(),param_3, &item); + DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); + // Something fell from Registeel's body + // Registeel was apparently guarding this item + DisplayDungeonDialogue(&gRegisteelPostFightDialogue_1); + } + } +} + +void sub_808AFB0(u8 param_1) +{ + Entity * leaderEntity; + s16 IDStack [2]; + + leaderEntity = xxx_call_GetLeader(); + sub_8052D44(IDStack,leaderEntity,0); + if (!sub_8098100(0x22) && (param_1 == 0x2E) && (!sub_8098100(0x1d)) && (sub_80860A8(ITEM_ROCK_PART) != 0)) { + sub_8097FD0(0x1d); + SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],GetLeader(),0); + // {POKEMON_0} obtained the Rock Part that Regirock was guarding + DisplayDungeonDialogue(&gRegirockPostFightDialogue_2); + sub_80421C0(0,0xd4); + sub_803E708(10,70); + sub_8046D20(); + } +} + +void sub_808B030(u8 param_1) +{ + Entity * leaderEntity; + s16 IDStack [2]; + + leaderEntity = xxx_call_GetLeader(); + sub_8052D44(IDStack,leaderEntity,0); + if (!sub_8098100(0x22) && (param_1 == 0x2F) && (!sub_8098100(0x1d)) && (sub_80860A8(ITEM_ICE_PART) != 0)) { + sub_8097FD0(0x1d); + SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],GetLeader(),0); + // {POKEMON_0} obtained the Ice Part that Regice was guarding + DisplayDungeonDialogue(&gRegicePostFightDialogue_2); + sub_80421C0(0,0xd4); + sub_803E708(10,70); + sub_8046D20(); + } +} + +void sub_808B0B0(u8 param_1) +{ + Entity * leaderEntity; + s16 IDStack [2]; + + leaderEntity = xxx_call_GetLeader(); + sub_8052D44(IDStack,leaderEntity,0); + if (!sub_8098100(0x22) && (param_1 == 0x30) && (!sub_8098100(0x1d)) && (sub_80860A8(ITEM_STEEL_PART) != 0)) { + sub_8097FD0(0x1d); + SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0], GetLeader(), 0); + // {POKEMON_0} obtained the Steel Part that Registeel was guarding + DisplayDungeonDialogue(&gRegisteelPostFightDialogue_2); + sub_80421C0(0,0xd4); + sub_803E708(10,70); + sub_8046D20(); + } +} + +void RegirockPreFightDialogue(void) +{ + if (!sub_8098100(0x22)) { + sub_8085930(DIRECTION_NORTH); + // INTRUDER ALERT + // EXTERMINATE + DisplayDungeonDialogue(&gRegirockPreFightDialogue_1); + sub_803E708(10,70); + sub_808563C(SetupRegirockFightHP); + } +} + +void RegicePreFightDialogue(void) +{ + if (!sub_8098100(0x22)) { + sub_8085930(DIRECTION_NORTH); + // INTRUDER ALERT + // EXTERMINATE + DisplayDungeonDialogue(&gRegicePreFightDialogue_1); + sub_803E708(10,70); + sub_808563C(SetupRegiceFightHP); + } +} + +void RegisteelPreFightDialogue(void) +{ + if (!sub_8098100(0x22)) { + sub_8085930(DIRECTION_NORTH); + // INTRUDER ALERT + // EXTERMINATE + DisplayDungeonDialogue(&gRegisteelPreFightDialogue_1); + sub_803E708(10,70); + sub_808563C(SetupRegisteelFightHP); + } +} + +static void sub_808B1CC(u8 itemID) +{ + Entity *entity; + Tile *tile; + DungeonPos pos; + Item item; + + pos.x = gDungeon->unk644.unk40; + pos.y = gDungeon->unk644.unk42; + if ((pos.x < 0) || (pos.y < 0)) { + entity = GetLeader(); + if (entity == NULL) { + gDungeon->unk2 = 1; + return; + } + pos.x = entity->pos.x; + pos.y = entity->pos.y; + } + sub_807FE04(&pos, 0); + tile = GetTileMut(pos.x, pos.y); + tile->terrainType = tile->terrainType | TERRAIN_TYPE_STAIRS; + if (((itemID != ITEM_NOTHING) && (sub_80860A8(itemID) == 0)) && + (sub_80860A8(ITEM_MUSIC_BOX) == 0)) { + ItemIdToSlot(&item,itemID,0); + pos.y--; + AddItemToDungeonAt(&pos,&item,1); + } + sub_8049ED4(); + ShowWholeRevealedDungeonMap(); +} + +static void SetupRegiFacingDirection(Entity *regiEntity) +{ + GetEntInfo(regiEntity)->action.direction = DIRECTION_NORTH; + sub_806CE68(regiEntity, DIRECTION_NORTH); +} + +static void SetupRegirockFightHP(Entity *r0) +{ + SetupBossFightHP(r0, 450, MUS_BOSS_BATTLE); +} + +static void SetupRegiceFightHP(Entity *r0) +{ + SetupBossFightHP(r0, 450, MUS_BOSS_BATTLE); +} + +static void SetupRegisteelFightHP(Entity *r0) +{ + SetupBossFightHP(r0, 450, MUS_BOSS_BATTLE); +} + + + diff --git a/src/dungeon_cutscene_skarmory.c b/src/dungeon_cutscene_skarmory.c new file mode 100644 index 000000000..a72fb1818 --- /dev/null +++ b/src/dungeon_cutscene_skarmory.c @@ -0,0 +1,215 @@ +#include "global.h" +#include "globaldata.h" +#include "code_800DAC0.h" +#include "code_800E9A8.h" +#include "dungeon_vram.h" +#include "code_803E668.h" +#include "code_8041AD0.h" +#include "code_804267C.h" +#include "code_80861A8.h" +#include "code_806CD90.h" +#include "code_80869E4.h" +#include "constants/bg_music.h" +#include "constants/direction.h" +#include "constants/friend_area.h" +#include "constants/weather.h" +#include "dungeon_items.h" +#include "dungeon_leader.h" +#include "dungeon_map_access.h" +#include "dungeon_message.h" +#include "dungeon_music.h" +#include "dungeon_misc.h" +#include "dungeon_logic.h" +#include "dungeon_random.h" +#include "dungeon_util_1.h" +#include "dungeon_util.h" +#include "exclusive_pokemon.h" +#include "friend_area.h" +#include "items.h" +#include "pokemon_3.h" +#include "pokemon.h" +#include "position_util.h" +#include "trap.h" +#include "math.h" +#include "dungeon_config.h" +#include "dungeon_boss_dialogue.h" + +extern void sub_8042B0C(Entity *); +extern u8 sub_806FD18(Entity *); +extern void sub_806FDF4(Entity *, Entity *, Entity **); +extern s32 GetCameraXPos(void); +extern s32 GetCameraYPos(void); +extern void sub_803F878(u32, s32); +extern void BgColorCallNullsub4(void); +extern void sub_8085EB0(void); +extern void sub_8049884(void); +extern void sub_8049B8C(void); +extern void ShowWholeRevealedDungeonMap(void); +extern void sub_8086A54(Entity *); +extern void ResetMonEntityData(EntityInfo *, u32); +extern void sub_8041888(u32); +extern u32 sub_80861F8(u32, Entity *, u32); +extern u8 sub_80860A8(u32); +extern void sub_8052D44(s16 *, Entity *, Entity *); +extern void sub_80464C8(Entity *, DungeonPos *, Item *); +extern void SetDungeonBGColorRGB(u32, u32, u32, u32, u32); +extern u32 sub_8085EC8(u32, u32, u32, DungeonPos *, u32); +extern void sub_807EAA0(u32, u32); +extern void sub_8072008(Entity *, Entity *, s16, u32, u32); +extern void sub_8085374(void); +extern u32 GetRandomFloorItem(u32); +extern bool8 sub_8085B80(struct_8085B80 *); +extern void sub_8086A3C(Entity *pokemon); +extern void SetupBossFightHP(Entity *pokemon, s32 newHP, u16 songIndex); +extern u8 sub_8086AE4(s16 _index); + +static void SkarmoryEntry(Entity * skarmoryEntity); + +void sub_8086B14(void) +{ + Entity * leaderEntity; + Entity * diglettEntity; + Entity * skarmoryEntity; + + leaderEntity = xxx_call_GetLeader(); + diglettEntity = GetEntityFromMonsterBehavior(BEHAVIOR_DIGLETT); + skarmoryEntity = GetEntityFromMonsterBehavior(BEHAVIOR_SKARMORY); + DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); + sub_8085374(); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + sub_80855E4(sub_8086A3C); + sub_8086A3C(skarmoryEntity); + GetEntInfo(diglettEntity)->unk15C = 1; + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 2); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2],MONSTER_DIGLETT); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[3], MONSTER_SKARMORY); +} + +void sub_8086B94(void) +{ + Entity * leaderEntity; + Entity * diglettEntity; + Entity * skarmoryEntity; + + leaderEntity = xxx_call_GetLeader(); + diglettEntity = GetEntityFromMonsterBehavior(BEHAVIOR_DIGLETT); + skarmoryEntity = GetEntityFromMonsterBehavior(BEHAVIOR_SKARMORY); + + sub_8068FE0(skarmoryEntity,0x21c,0); + sub_8068FE0(diglettEntity,0x21c,0); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y); +} + +void sub_8086BDC(u8 param_1, u8 param_2) +{ + if ((param_2 == 1 || param_2 == 2) && param_1 == 3) { + sub_8097FA8(1); + gDungeon->unk2 = 1; + } +} + +void SkarmoryPreFightDialogue(void) +{ + Entity *leaderEntity; + Entity *partnerEntity; + Entity * diglettEntity; + Entity * skarmoryEntity; + + PixelPos pos1; + PixelPos pos2; + + leaderEntity = xxx_call_GetLeader(); // Player + partnerEntity = GetPartnerEntity(); // Partner + diglettEntity = GetEntityFromMonsterBehavior(BEHAVIOR_DIGLETT); // Diglett + skarmoryEntity = GetEntityFromMonsterBehavior(BEHAVIOR_SKARMORY); // Skarmory + + pos1.x = diglettEntity->pixelPos.x; + pos1.y = diglettEntity->pixelPos.y + 0x3000; + + pos2.x = skarmoryEntity->pixelPos.x; + pos2.y = skarmoryEntity->pixelPos.y + 0x2000; + + sub_8086448(); + sub_803E708(10,0x46); + SpriteShockEffect(partnerEntity); + sub_803E708(0x20,0x46); + sub_803E708(10,0x46); + DisplayDungeonDialogue(&gSkarmoryPreFightDialogue_1); + ShiftCameraToPosition(&pos1,0x40); + sub_803E708(0x40,0x46); + ShiftCameraToPosition(&pos2,0x30); + DisplayDungeonDialogue(gSkarmoryPreFightDialogue_2); + sub_803E708(10,0x46); + GetEntInfo(diglettEntity)->unk15D = 1; + ShiftCameraToPosition(&pos1,0x30); + DisplayDungeonDialogue(&gSkarmoryPreFightDialogue_3); // Diglett: ...I...\nI'm scared. + sub_803E708(10,0x46); + ShiftCameraToPosition(&pos2,0x20); + sub_803E708(0x20,0x46); + SkarmoryEntry(skarmoryEntity); + DisplayDungeonDialogue(&gSkarmoryPreFightDialogue_4); // Skarmory: You!\nWhat do you think you're doing here?! + sub_803E708(10,0x46); + DisplayDungeonDialogue(gSkarmoryPreFightDialogue_5); + sub_803E708(10,0x46); + DisplayDungeonDialogue(&gSkarmoryPreFightDialogue_6); + sub_803E708(10,0x46); + DisplayDungeonDialogue(gSkarmoryPreFightDialogue_7); + sub_803E708(10,0x46); + sub_806CDD4(skarmoryEntity,0xd,DIRECTION_SOUTH); + DisplayDungeonDialogue(&gSkarmoryPreFightDialogue_8); + sub_803E708(10,0x46); + sub_80869E4(partnerEntity,4,1,DIRECTION_EAST); + sub_80869E4(leaderEntity,4,2,DIRECTION_WEST); + DisplayDungeonDialogue(gSkarmoryPreFightDialogue_9); + sub_80869E4(partnerEntity,4,2,DIRECTION_NORTH); + sub_80869E4(leaderEntity,4,1,DIRECTION_NORTH); + sub_803E708(10,0x46); + DungeonStartNewBGM(MUS_BOSS_BATTLE); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); +} + +void SkarmoryReFightDialogue(void) +{ + Entity * leaderEntity; + Entity * skarmoryEntity; + PixelPos pos; + + leaderEntity = xxx_call_GetLeader(); + skarmoryEntity = GetEntityFromMonsterBehavior(BEHAVIOR_SKARMORY); + pos.x = skarmoryEntity->pixelPos.x; + pos.y = skarmoryEntity->pixelPos.y + 0x2000; + sub_8086448(); + sub_803E708(10,0x46); + SkarmoryEntry(skarmoryEntity); + ShiftCameraToPosition(&pos,0x10); + DisplayDungeonDialogue(&gSkarmoryReFightDialogue_1); + sub_803E708(10,0x46); + DisplayDungeonDialogue(&gSkarmoryReFightDialogue_2); + sub_803E708(10,0x46); + sub_806CDD4(skarmoryEntity,0xd,DIRECTION_SOUTH); + DisplayDungeonDialogue(&gSkarmoryReFightDialogue_3); + sub_803E708(10,0x46); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); + DungeonStartNewBGM(MUS_BOSS_BATTLE); +} + +void sub_8086E40(void) +{ + SpriteLookAroundEffect(xxx_call_GetLeader()); + sub_803E708(10,0x46); + DisplayDungeonDialogue(&gUnknown_8100D3C); + sub_803E708(10,0x46); + gDungeon->unk2 = 1; +} + +static void SkarmoryEntry(Entity * skarmoryEntity) +{ + sub_806CDD4(skarmoryEntity,0xf,DIRECTION_SOUTH); + sub_8086A54(skarmoryEntity); + PlaySoundEffect(0x1f8); + sub_803E708(0x44,0x46); +} + diff --git a/src/dungeon_cutscene_smeargle.c b/src/dungeon_cutscene_smeargle.c new file mode 100644 index 000000000..c00c5d213 --- /dev/null +++ b/src/dungeon_cutscene_smeargle.c @@ -0,0 +1,154 @@ +#include "global.h" +#include "globaldata.h" +#include "code_800DAC0.h" +#include "code_800E9A8.h" +#include "dungeon_vram.h" +#include "code_803E668.h" +#include "code_8041AD0.h" +#include "code_804267C.h" +#include "code_80861A8.h" +#include "code_806CD90.h" +#include "code_80869E4.h" +#include "constants/bg_music.h" +#include "constants/direction.h" +#include "constants/friend_area.h" +#include "constants/weather.h" +#include "dungeon_items.h" +#include "dungeon_leader.h" +#include "dungeon_map_access.h" +#include "dungeon_message.h" +#include "dungeon_music.h" +#include "dungeon_misc.h" +#include "dungeon_logic.h" +#include "dungeon_random.h" +#include "dungeon_util_1.h" +#include "dungeon_util.h" +#include "exclusive_pokemon.h" +#include "friend_area.h" +#include "items.h" +#include "pokemon_3.h" +#include "pokemon.h" +#include "position_util.h" +#include "trap.h" +#include "math.h" +#include "dungeon_config.h" +#include "dungeon_boss_dialogue.h" + +extern void sub_8042B0C(Entity *); +extern u8 sub_806FD18(Entity *); +extern void sub_806FDF4(Entity *, Entity *, Entity **); +extern s32 GetCameraXPos(void); +extern s32 GetCameraYPos(void); +extern void sub_803F878(u32, s32); +extern void BgColorCallNullsub4(void); +extern void sub_8085EB0(void); +extern void sub_8049884(void); +extern void sub_8049B8C(void); +extern void ShowWholeRevealedDungeonMap(void); +extern void sub_8086A54(Entity *); +extern void ResetMonEntityData(EntityInfo *, u32); +extern void sub_8041888(u32); +extern u32 sub_80861F8(u32, Entity *, u32); +extern u8 sub_80860A8(u32); +extern void sub_8052D44(s16 *, Entity *, Entity *); +extern void sub_80464C8(Entity *, DungeonPos *, Item *); +extern void SetDungeonBGColorRGB(u32, u32, u32, u32, u32); +extern u32 sub_8085EC8(u32, u32, u32, DungeonPos *, u32); +extern void sub_807EAA0(u32, u32); +extern void sub_8072008(Entity *, Entity *, s16, u32, u32); +extern void sub_8085374(void); +extern u32 GetRandomFloorItem(u32); +extern bool8 sub_8085B80(struct_8085B80 *); +extern void sub_8086A3C(Entity *pokemon); +extern void SetupBossFightHP(Entity *pokemon, s32 newHP, u16 songIndex); +extern u8 sub_8086AE4(s16 _index); + +void DummyFightDialogue(void) +{ +} + +void sub_808CBB0(void) +{ + Entity *leaderEntity; + Entity *smeargleEntity; + + leaderEntity = xxx_call_GetLeader(); + smeargleEntity = GetEntityFromMonsterBehavior(BEHAVIOR_SMEARGLE); + DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + sub_80855E4(sub_8086A3C); + SetFacingDirection(smeargleEntity, DIRECTION_SOUTH); + sub_8085860(leaderEntity->pos.x, leaderEntity->pos.y - 3); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_SMEARGLE); +} + +void SmeargleRescueDialogue(void) +{ + Entity *smeargleEntity; + s32 counter; + + smeargleEntity = GetEntityFromMonsterBehavior(BEHAVIOR_SMEARGLE); + SpriteLookAroundEffect(smeargleEntity); + sub_803E708(0xA, 0x46); + // Ohhh... + // I've lost my bearings + DisplayDungeonDialogue(&gSmeargleRescueDialogue_1); + sub_803E708(0xA, 0x46); + sub_80869E4(smeargleEntity, 4, 2, DIRECTION_NORTH); + sub_803E708(0xA, 0x46); + // I can't get out... + // I'm hungry... + // I'm in trouble + DisplayDungeonDialogue(&gSmeargleRescueDialogue_2); + sub_803E708(0xA, 0x46); + sub_8086448(); + sub_8086598(); + sub_803E708(0x20, 0x46); + SpriteShockEffect(smeargleEntity); + sub_803E708(0x20, 0x46); + sub_80869E4(smeargleEntity, 4, 2, DIRECTION_SOUTH); + // Oh! You are? + DisplayDungeonDialogue(&gSmeargleRescueDialogue_3); + sub_803E708(0xA, 0x46); + PlaySoundEffect(0x1c7); + sub_806CDD4(smeargleEntity, 0xA, DIRECTION_SOUTH); + sub_803E708(0x14, 0x46); + sub_806CE68(smeargleEntity, DIRECTION_SOUTH); + sub_803E708(0x4, 0x46); + PlaySoundEffect(0x1c7); + sub_806CDD4(smeargleEntity, 0xA, DIRECTION_SOUTH); + sub_803E708(0x14, 0x46); + // Did you maybe come to rescue me? + // Am I glad to see you + DisplayDungeonDialogue(&gSmeargleRescueDialogue_4); + sub_803E708(0xA, 0x46); + sub_806CDD4(smeargleEntity, 0, DIRECTION_SOUTH); + for(counter = 0x17; counter >= 0; counter--) + { + IncreaseEntityPixelPos(smeargleEntity, 0, 0x100); + DungeonRunFrameActions(0x46); + } + sub_806CE68(smeargleEntity, DIRECTION_SOUTH); + sub_803E708(0x20, 0x46); + sub_8042B0C(smeargleEntity); + sub_8068FE0(smeargleEntity, 0x21C, 0); + gDungeon->unk4 = 1; + gDungeon->unk11 = 4; +} + +void sub_808CD44(void) +{ + Entity *leaderEntity; + Entity *smeargleEntity; + + leaderEntity = xxx_call_GetLeader(); + smeargleEntity = GetEntityFromMonsterBehavior(BEHAVIOR_SMEARGLE); + DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + sub_80855E4(sub_8086A3C); + sub_8068FE0(smeargleEntity, 540, 0); + sub_8085860(leaderEntity->pos.x, leaderEntity->pos.y - 3); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_SMEARGLE); +} diff --git a/src/dungeon_cutscene_suicune.c b/src/dungeon_cutscene_suicune.c new file mode 100644 index 000000000..da768e6cd --- /dev/null +++ b/src/dungeon_cutscene_suicune.c @@ -0,0 +1,243 @@ +#include "global.h" +#include "globaldata.h" +#include "code_800DAC0.h" +#include "code_800E9A8.h" +#include "dungeon_vram.h" +#include "code_803E668.h" +#include "code_8041AD0.h" +#include "code_804267C.h" +#include "code_80861A8.h" +#include "code_806CD90.h" +#include "code_80869E4.h" +#include "constants/bg_music.h" +#include "constants/direction.h" +#include "constants/friend_area.h" +#include "constants/weather.h" +#include "dungeon_items.h" +#include "dungeon_leader.h" +#include "dungeon_map_access.h" +#include "dungeon_message.h" +#include "dungeon_music.h" +#include "dungeon_misc.h" +#include "dungeon_logic.h" +#include "dungeon_random.h" +#include "dungeon_util_1.h" +#include "dungeon_util.h" +#include "exclusive_pokemon.h" +#include "friend_area.h" +#include "items.h" +#include "pokemon_3.h" +#include "pokemon.h" +#include "position_util.h" +#include "trap.h" +#include "math.h" +#include "dungeon_config.h" +#include "dungeon_boss_dialogue.h" + +extern void sub_8042B0C(Entity *); +extern u8 sub_806FD18(Entity *); +extern void sub_806FDF4(Entity *, Entity *, Entity **); +extern s32 GetCameraXPos(void); +extern s32 GetCameraYPos(void); +extern void sub_803F878(u32, s32); +extern void BgColorCallNullsub4(void); +extern void sub_8085EB0(void); +extern void sub_8049884(void); +extern void sub_8049B8C(void); +extern void ShowWholeRevealedDungeonMap(void); +extern void sub_8086A54(Entity *); +extern void ResetMonEntityData(EntityInfo *, u32); +extern void sub_8041888(u32); +extern u32 sub_80861F8(u32, Entity *, u32); +extern u8 sub_80860A8(u32); +extern void sub_8052D44(s16 *, Entity *, Entity *); +extern void sub_80464C8(Entity *, DungeonPos *, Item *); +extern void SetDungeonBGColorRGB(u32, u32, u32, u32, u32); +extern u32 sub_8085EC8(u32, u32, u32, DungeonPos *, u32); +extern void sub_807EAA0(u32, u32); +extern void sub_8072008(Entity *, Entity *, s16, u32, u32); +extern void sub_8085374(void); +extern u32 GetRandomFloorItem(u32); +extern bool8 sub_8085B80(struct_8085B80 *); +extern void sub_8086A3C(Entity *pokemon); +extern void SetupBossFightHP(Entity *pokemon, s32 newHP, u16 songIndex); +extern u8 sub_8086AE4(s16 _index); + +static void sub_808A528(Entity * param_1); +static void SuicuneScreenFlash(void); + +void sub_808A264(void) +{ + Entity * leaderEntity; + Entity * SuicuneEntity; + + leaderEntity = xxx_call_GetLeader(); + SuicuneEntity = GetEntityFromMonsterBehavior(BEHAVIOR_SUICUNE); + DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + sub_80855E4(sub_8086A3C); + SetFacingDirection(SuicuneEntity, DIRECTION_SOUTH); + sub_8086A3C(SuicuneEntity); + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 3); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_SUICUNE); +} + +void sub_808A2C0(void) +{ + Entity * leaderEntity; + Entity * SuicuneEntity; + + leaderEntity = xxx_call_GetLeader(); + SuicuneEntity = GetEntityFromMonsterBehavior(BEHAVIOR_SUICUNE); + DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + SetFacingDirection(SuicuneEntity, DIRECTION_SOUTH); + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_SUICUNE); +} + +void sub_808A308(void) +{ + Entity * leaderEntity; + Entity * SuicuneEntity; + + leaderEntity = xxx_call_GetLeader(); + SuicuneEntity = GetEntityFromMonsterBehavior(BEHAVIOR_SUICUNE); + DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); + sub_80854D4(); + sub_8085930(DIRECTION_NORTH); + if (HasRecruitedMon(MONSTER_SUICUNE)) { + sub_8068FE0(SuicuneEntity,0x21c,0); + } + else { + SetFacingDirection(SuicuneEntity, DIRECTION_SOUTH); + } + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_SUICUNE); +} + +void sub_808A36C(u8 param_1, u8 param_2) +{ + if ((param_2 == 0x26 || param_2 == 0x27 || param_2 == 0x28) && (param_1 == 0x14)) { + sub_8097FA8(0x19); + gDungeon->unk2 = 1; + } +} + +void SuicunePreFightDialogue(void) +{ + Entity * leaderEntity; + Entity * SuicuneEntity; + + leaderEntity = xxx_call_GetLeader(); + SuicuneEntity = GetEntityFromMonsterBehavior(BEHAVIOR_SUICUNE); + sub_8086448(); + DisplayDungeonDialogue(&gSuicunePreFightDialogue_1); + sub_803E708(10,70); + DisplayDungeonDialogue(&gSuicunePreFightDialogue_2); + sub_803E708(10,70); + sub_80426C8(1,2); + sub_803E708(0x3c,70); + DisplayDungeonDialogue(&gSuicunePreFightDialogue_3); + sub_803E708(10,70); + sub_808A528(SuicuneEntity); + DisplayDungeonDialogue(&gSuicunePreFightDialogue_4); + DisplayDungeonDialogue(&gSuicunePreFightDialogue_5); + SuicuneScreenFlash(); + DisplayDungeonDialogue(&gSuicunePreFightDialogue_6); + SuicuneScreenFlash(); + DisplayDungeonDialogue(&gSuicunePreFightDialogue_7); + sub_803E708(10,70); + SetupBossFightHP(SuicuneEntity,0x28a,MUS_BOSS_BATTLE); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); +} + +void SuicuneReFightDialogue(void) +{ + Entity * leaderEntity; + Entity * SuicuneEntity; + + leaderEntity = xxx_call_GetLeader(); + SuicuneEntity = GetEntityFromMonsterBehavior(BEHAVIOR_SUICUNE); + DisplayDungeonDialogue(&gSuicuneReFightDialogue_1); + SuicuneScreenFlash(); + DisplayDungeonDialogue(&gSuicuneReFightDialogue_2); + SuicuneScreenFlash(); + DisplayDungeonDialogue(&gSuicuneReFightDialogue_3); + sub_803E708(10,70); + SetupBossFightHP(SuicuneEntity,0x28a,MUS_BOSS_BATTLE); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); +} + +void SuicunePostStoryPreFightDialogue(void) +{ + Entity * leaderEntity; + Entity * SuicuneEntity; + + leaderEntity = xxx_call_GetLeader(); + SuicuneEntity = GetEntityFromMonsterBehavior(BEHAVIOR_SUICUNE); + if (HasRecruitedMon(MONSTER_SUICUNE)) { + sub_80866C4(&gSuicunePostStoryPreFightDialogue_4); + } + else { + DisplayDungeonDialogue(&gSuicunePostStoryPreFightDialogue_1); + SuicuneScreenFlash(); + DisplayDungeonDialogue(&gSuicunePostStoryPreFightDialogue_2); + SuicuneScreenFlash(); + DisplayDungeonDialogue(&gSuicunePostStoryPreFightDialogue_3); + sub_803E708(10,70); + SetupBossFightHP(SuicuneEntity,0x28a,MUS_BOSS_BATTLE); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); + } +} + +static void sub_808A528(Entity * param_1) +{ + s24_8 iVar1; + s24_8 iVar2; + + GetEntInfo(param_1)->unk15E = 0; + iVar2 = IntToF248(200); + iVar1 = IntToF248(12); + PlaySoundEffect(0x1f8); + while( 1 ) { + iVar2.raw -= iVar1.raw; + iVar1 = F248_Sub(iVar1, FloatToF248(0.375)); + if (F248LessThanFloat(iVar1, 0.08)) { + iVar1 = FloatToF248_2(0.08); + } + if (F248LessThanInt(iVar2, 0)) break; + GetEntInfo(param_1)->unk174 = iVar2; + DungeonRunFrameActions(70); + } + GetEntInfo(param_1)->unk174 = IntToF248_2(0); +} + +static void SuicuneScreenFlash(void) +{ + s32 iVar1; + + PlaySoundEffect(0x1ee); + for(iVar1 = 250; iVar1 > 149; iVar1 -= 10) + { + SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,1); + DungeonRunFrameActions(70); + } + sub_803E708(10,70); + for(iVar1 = 250; iVar1 > 199; iVar1 -= 10) + { + SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,1); + DungeonRunFrameActions(70); + } + sub_803E708(10,70); + for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10) + { + SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,1); + DungeonRunFrameActions(70); + } + sub_803E708(10,70); + sub_8085EB0(); +} + diff --git a/src/dungeon_cutscene_zapdos.c b/src/dungeon_cutscene_zapdos.c new file mode 100644 index 000000000..92e9a1f4c --- /dev/null +++ b/src/dungeon_cutscene_zapdos.c @@ -0,0 +1,309 @@ +#include "global.h" +#include "globaldata.h" +#include "code_800DAC0.h" +#include "code_800E9A8.h" +#include "dungeon_vram.h" +#include "code_803E668.h" +#include "code_8041AD0.h" +#include "code_804267C.h" +#include "code_80861A8.h" +#include "code_806CD90.h" +#include "code_80869E4.h" +#include "constants/bg_music.h" +#include "constants/direction.h" +#include "constants/friend_area.h" +#include "constants/weather.h" +#include "dungeon_items.h" +#include "dungeon_leader.h" +#include "dungeon_map_access.h" +#include "dungeon_message.h" +#include "dungeon_music.h" +#include "dungeon_misc.h" +#include "dungeon_logic.h" +#include "dungeon_random.h" +#include "dungeon_util_1.h" +#include "dungeon_util.h" +#include "exclusive_pokemon.h" +#include "friend_area.h" +#include "items.h" +#include "pokemon_3.h" +#include "pokemon.h" +#include "position_util.h" +#include "trap.h" +#include "math.h" +#include "dungeon_config.h" +#include "dungeon_boss_dialogue.h" + +extern void sub_8042B0C(Entity *); +extern u8 sub_806FD18(Entity *); +extern void sub_806FDF4(Entity *, Entity *, Entity **); +extern s32 GetCameraXPos(void); +extern s32 GetCameraYPos(void); +extern void sub_803F878(u32, s32); +extern void BgColorCallNullsub4(void); +extern void sub_8085EB0(void); +extern void sub_8049884(void); +extern void sub_8049B8C(void); +extern void ShowWholeRevealedDungeonMap(void); +extern void sub_8086A54(Entity *); +extern void ResetMonEntityData(EntityInfo *, u32); +extern void sub_8041888(u32); +extern u32 sub_80861F8(u32, Entity *, u32); +extern u8 sub_80860A8(u32); +extern void sub_8052D44(s16 *, Entity *, Entity *); +extern void sub_80464C8(Entity *, DungeonPos *, Item *); +extern void SetDungeonBGColorRGB(u32, u32, u32, u32, u32); +extern u32 sub_8085EC8(u32, u32, u32, DungeonPos *, u32); +extern void sub_807EAA0(u32, u32); +extern void sub_8072008(Entity *, Entity *, s16, u32, u32); +extern void sub_8085374(void); +extern u32 GetRandomFloorItem(u32); +extern bool8 sub_8085B80(struct_8085B80 *); +extern void sub_8086A3C(Entity *pokemon); +extern void SetupBossFightHP(Entity *pokemon, s32 newHP, u16 songIndex); +extern u8 sub_8086AE4(s16 _index); + +struct Zapdos1 +{ + s16 unk0[12]; +}; + +struct Zapdos2 +{ + s16 unk0[16]; +}; + +static void ZapdosDropInEffect(Entity *zapdosEntity); +static void ZapdosScreenFlash(s32 numFlashes); + +void sub_8087230(void) +{ + Entity *leaderEntity; + Entity *zapdosEntity; + + leaderEntity = xxx_call_GetLeader(); + zapdosEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ZAPDOS); + DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); + sub_8085374(); + sub_80854D4(); + sub_8085930(4); + sub_80855E4(sub_8086A3C); + SetFacingDirection(zapdosEntity, DIRECTION_SOUTH); + sub_8086A3C(zapdosEntity); + sub_8085860(leaderEntity->pos.x, leaderEntity->pos.y - 3); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_SHIFTRY); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[3], MONSTER_ZAPDOS); +} + +void sub_808729C(void) +{ + Entity *leaderEntity; + Entity *zapdosEntity; + + leaderEntity = xxx_call_GetLeader(); + zapdosEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ZAPDOS); + sub_80854D4(); + sub_8085930(4); + sub_80855E4(sub_8086A3C); + if (sub_8086AE4(0x91) != 0) { + sub_8068FE0(zapdosEntity,0x21c,0); + } + else { + sub_8072008(zapdosEntity,zapdosEntity,gZapdosConfigLevel,0,0); + SetFacingDirection(zapdosEntity,DIRECTION_SOUTH); + sub_8086A3C(zapdosEntity); + } + sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 3); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_SHIFTRY); + CopyMonsterNameToBuffer(gFormatBuffer_Monsters[3], MONSTER_ZAPDOS); +} + +void sub_8087334(u8 param_1, u8 param_2) +{ + if ((param_2 == 7 || param_2 == 8 || param_2 == 9) && (param_1 == 8)) { + sub_8097FA8(5); + gDungeon->unk2 = 1; + } +} + +void ZapdosPreFightDialogue(void) +{ + Entity *leaderEntity; + Entity *partnerEntity; + struct Zapdos1 puStack_38; // sp 0x0 + struct_8085B80 auStack_78; + struct Zapdos2 puStack_30; + s16 *puStack_34[1]; // sp 0x58 + struct Entity *pEStack_34[1]; // sp 0x5c + s16 *puStack_4c[1]; // sp 0x60 + Entity *pEStack_2c[1]; // sp 0x64 + Entity *zapdosEntity; // sp 0x68 + struct_8085B80 auStack_48; // r8 + + leaderEntity = xxx_call_GetLeader(); + partnerEntity = GetPartnerEntity(); + zapdosEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ZAPDOS); + sub_8086448(); + sub_803E708(10,0x46); + SpriteLookAroundEffect(partnerEntity); + sub_803E708(10,0x46); + sub_80869E4(partnerEntity,4,1,DIRECTION_EAST); + sub_80869E4(leaderEntity,4,2,DIRECTION_WEST); + DisplayDungeonDialogue(gUnknown_81014B0); + sub_803E708(10,0x46); + sub_80869E4(partnerEntity,4,2,DIRECTION_NORTH); + sub_80869E4(leaderEntity,4,1,DIRECTION_NORTH); + DisplayDungeonDialogue(gUnknown_8101504); + sub_803E708(10,0x46); + ZapdosScreenFlash(3); + DungeonStopBGM(); + PlaySoundEffect(0x1da); + DisplayDungeonDialogue(&gUnknown_81015A0); + ZapdosDropInEffect(zapdosEntity); + DungeonStartNewBGM(MUS_RISING_FEAR); + sub_806CDD4(partnerEntity,6,DIRECTION_NORTH); + DisplayDungeonDialogue(&gUnknown_81015D4); // Waah! + sub_803E708(10,0x46); + sub_80869E4(partnerEntity,2,1,DIRECTION_SOUTHEAST); + + puStack_38 = (struct Zapdos1) {1, 2, 12, 0, 1, 0, 0, 0, 0, 9, 9, 0}; + puStack_34[0] = puStack_38.unk0; + pEStack_34[0] = partnerEntity; + sub_8085B4C(&auStack_78,puStack_34,pEStack_34,1); + GetEntInfo(partnerEntity)->unk15F = 1; + while(sub_8085B80(&auStack_78)) { + DungeonRunFrameActions(0x46); + } + + GetEntInfo(partnerEntity)->unk15F = 0; + GetEntInfo(partnerEntity)->unk15D = 1; + sub_80869E4(partnerEntity,2,2,DIRECTION_NORTH); + DisplayDungeonDialogue(&gUnknown_81015E8); // I warned you! I have no mercy for meddlers + sub_803E708(0x3c,0x46); + DisplayDungeonDialogue(&gUnknown_8101624); + sub_803E708(10,0x46); + GetEntInfo(partnerEntity)->unk15D = 0; + sub_80869E4(partnerEntity,2,2,DIRECTION_NORTHWEST); + + puStack_30 = (struct Zapdos2) {5, 2, 12, 0, 4, 2, 12, 0, 4, 0, 0, 0, 0, 8, 7, 0}; + puStack_4c[0] = puStack_30.unk0; + pEStack_2c[0] = partnerEntity; + sub_8085B4C(&auStack_48,puStack_4c,pEStack_2c,1); + while (sub_8085B80(&auStack_48)) { + DungeonRunFrameActions(0x46); + } + + sub_80869E4(partnerEntity,2,1,DIRECTION_NORTHEAST); + DisplayDungeonDialogue(gUnknown_810165C); + sub_803E708(10,0x46); + ZapdosScreenFlash(3); + DisplayDungeonDialogue(&gUnknown_8101750); + sub_803E708(10,0x46); + ZapdosScreenFlash(1); + DisplayDungeonDialogue(&gUnknown_810178C); + sub_803E708(10,0x46); + ZapdosScreenFlash(2); + DisplayDungeonDialogue(&gUnknown_81017B4); + sub_803E708(10,0x46); + SetupBossFightHP(zapdosEntity,300, MUS_BOSS_BATTLE); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); +} + +void ZapdosReFightDialogue(void) +{ + Entity *leaderEntity; + Entity *zapdosEntity; + + leaderEntity = xxx_call_GetLeader(); + zapdosEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ZAPDOS); + sub_8086448(); + sub_803E708(10,0x46); + DisplayDungeonDialogue(gZapdosReFightDialogue_1); + sub_803E708(10,0x46); + PlaySoundEffect(0x1da); + DisplayDungeonDialogue(&gUnknown_81015A0); + sub_803E708(10,0x46); + ZapdosDropInEffect(zapdosEntity); + sub_803E708(10,0x46); + DisplayDungeonDialogue(&gZapdosReFightDialogue_2); + ZapdosScreenFlash(1); + DisplayDungeonDialogue(&gZapdosReFightDialogue_3); + ZapdosScreenFlash(2); + DisplayDungeonDialogue(&gZapdosReFightDialogue_4); + SetupBossFightHP(zapdosEntity,300,MUS_BOSS_BATTLE); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); +} + +void ZapdosPostStoryPreFightDialogue(void) +{ + Entity * leaderEntity; + Entity * zapdosEntity; + + leaderEntity = xxx_call_GetLeader(); + zapdosEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ZAPDOS); + sub_8086448(); + if (sub_8086AE4(MONSTER_ZAPDOS)) { + sub_80866C4(&gZapdosPostStoryPreFightDialogue_6); + } + else { + ZapdosScreenFlash(1); + PlaySoundEffect(0x1da); + DisplayDungeonDialogue(&gZapdosPostStoryPreFightDialogue_1); + ZapdosDropInEffect(zapdosEntity); + DisplayDungeonDialogue(&gZapdosPostStoryPreFightDialogue_2); + ZapdosScreenFlash(1); + DisplayDungeonDialogue(&gZapdosPostStoryPreFightDialogue_3); + ZapdosScreenFlash(2); + DisplayDungeonDialogue(&gZapdosPostStoryPreFightDialogue_4); + ZapdosScreenFlash(2); + DisplayDungeonDialogue(&gZapdosPostStoryPreFightDialogue_5); + sub_803E708(10,0x46); + SetupBossFightHP(zapdosEntity,300,MUS_BOSS_BATTLE); + ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); + } +} + +static void ZapdosDropInEffect(Entity *zapdosEntity) +{ + int iVar1; + + GetEntInfo(zapdosEntity)->unk15C = 1; + GetEntInfo(zapdosEntity)->unk15E = 0; + GetEntInfo(zapdosEntity)->unk174.raw = 200; // incorrect value? Overwritten immediately anyway + PlaySoundEffect(0x1ea); + for(iVar1 = 200; iVar1 >= 0; iVar1 -= 5) + { + GetEntInfo(zapdosEntity)->unk174 = IntToF248_2(iVar1); + DungeonRunFrameActions(0x46); + } + sub_803E708(0x1e,0x46); +} + +static void ZapdosScreenFlash(s32 numFlashes) +{ + s32 index; + + PlaySoundEffect(0x1f6); + if (2 < numFlashes) { + for(index = 250; index > 199; index -= 10) + { + SetDungeonBGColorRGB(index,index,index / 2,1,1); + DungeonRunFrameActions(0x46); + } + } + if (1 < numFlashes) { + for(index = 250; index > 199; index -= 10) + { + SetDungeonBGColorRGB(index,index,index / 2,1,1); + DungeonRunFrameActions(0x46); + } + } + for(index = 250; index >= 0; index -= 10) + { + SetDungeonBGColorRGB(index,index,index / 4,1,1); + DungeonRunFrameActions(0x46); + } + sub_8085EB0(); +} + + diff --git a/src/dungeon_cutscenes.c b/src/dungeon_cutscenes.c deleted file mode 100644 index bd98fcc6d..000000000 --- a/src/dungeon_cutscenes.c +++ /dev/null @@ -1,4678 +0,0 @@ -#include "global.h" -#include "code_800DAC0.h" -#include "code_800E9A8.h" -#include "code_803E46C.h" -#include "code_803E668.h" -#include "code_8041AD0.h" -#include "code_804267C.h" -#include "code_80861A8.h" -#include "code_806CD90.h" -#include "code_80869E4.h" -#include "constants/bg_music.h" -#include "constants/direction.h" -#include "constants/friend_area.h" -#include "constants/weather.h" -#include "dungeon_items.h" -#include "dungeon_leader.h" -#include "dungeon_map_access.h" -#include "dungeon_message.h" -#include "dungeon_music.h" -#include "dungeon_misc.h" -#include "dungeon_logic.h" -#include "dungeon_random.h" -#include "dungeon_util_1.h" -#include "dungeon_util.h" -#include "exclusive_pokemon.h" -#include "friend_area.h" -#include "items.h" -#include "pokemon_3.h" -#include "pokemon.h" -#include "position_util.h" -#include "exclusive_pokemon.h" -#include "trap.h" -#include "math.h" -#include "dungeon_config.h" -#include "dungeon_boss_dialogue.h" - -extern u32 gDungeonBrightness; - -extern const struct MenuItem gUnknown_810579C[]; -extern const u64 gUnknown_8107544[]; -extern const u8 *const gUnknown_8105798; -extern const u8 gUnknown_810739C[]; -extern const u8 gUnknown_81073D4[]; -extern const u8 gUnknown_810740C[]; -extern const u8 gUnknown_81074FC[]; - -struct Zapdos1 -{ - s16 unk0[12]; -}; - -struct Zapdos2 -{ - s16 unk0[16]; -}; - -extern const struct Zapdos1 gUnknown_810744C; -extern struct Zapdos2 gUnknown_8107464; - -extern void sub_8042B0C(Entity *); -extern u8 sub_806FD18(Entity *); -extern void sub_806FDF4(Entity *, Entity *, Entity **); -extern s32 GetCameraXPos(void); -extern s32 GetCameraYPos(void); -extern void sub_803F878(u32, s32); -extern void BgColorCallNullsub4(void); -extern void sub_8085EB0(void); -extern void sub_8049884(void); -extern void sub_8049B8C(void); -extern void ShowWholeRevealedDungeonMap(void); -extern void sub_8086A54(Entity *); -extern void ResetMonEntityData(EntityInfo *, u32); -extern void sub_808BBA8(Entity * ); -extern void sub_8041888(u32); -extern u32 sub_80861F8(u32, Entity *, u32); -extern u8 sub_80860A8(u32); -extern void sub_8052D44(s16 *, Entity *, Entity *); -extern void sub_80464C8(Entity *, DungeonPos *, Item *); -extern void SetDungeonBGColorRGB(u32, u32, u32, u32, u32); -extern u32 sub_8085EC8(u32, u32, u32, DungeonPos *, u32); -extern void sub_807EAA0(u32, u32); -extern void sub_8072008(Entity *, Entity *, s16, u32, u32); -extern void sub_8085374(void); -extern u32 GetRandomFloorItem(u32); -extern u8 sub_8044B28(void); -extern bool8 sub_8085B80(struct_8085B80 *); - -void sub_8085F44(s32); -void sub_808BBA8(Entity * ); -void DeoxysScreenFlash(void); -void sub_8086A54(Entity *); -void ZapdosScreenFlash(s32 numFlashes); -void ZapdosDropInEffect(Entity *); -void SetupDeoxysFightHP(Entity *r0); -void sub_808C550(void); -void sub_808C590(Entity *r0); -void SetupDeoxysFacingDirection(Entity *r0); -void sub_808C9B0(Entity *); -void sub_808C8E0(Entity *param_1); -void sub_808C360(void); -void KyogreScreenFlash(void); -void sub_808C0CC(void); -void LugiaScreenFlash(void); -void LugiaScreenFlash2(void); -void nullsub_99(void); -void JirachiWish(void); -void JirachiSpinEffect(Entity *jirachiEntity); -void JirachiWishGrantDialogue(Entity *jirachiEntity); -void JirachiDropInEffect(Entity *jirachiEntity); -u8 JirachiFriendAreaSearch(void); -void sub_808B1CC(u8 itemID); -void CreateJirachiWishWarpTile(void); -void EnteiScreenFlash(void); -void RaikouScreenFlash(void); -void sub_808A528(Entity * param_1); -void SuicuneScreenFlash(void); -void HoOhDropInEffect(Entity * param_1); -void HoOhScreenFlash(void); -void LatiosScreenFlash(void); -void SetupRegiFacingDirection(Entity *entity); -void SetupRegirockFightHP(Entity *entity); -void SetupRegiceFightHP(Entity *entity); -void SetupRegisteelFightHP(Entity *entity); -void sub_808B50C(void); -void MewtwoDropInEffect(Entity *param_1); -void MewtwoScreenFlash(void); -void sub_80898F8(Entity *entity); -void sub_8089908(Entity *entity); -void RayquazaDropInEffect(Entity *param_1); -void RayquazaScreenFlash(void); -void sub_80891F0(void); -void sub_8089294(void); -void GroudonScreenFlash2(void); -void SceneGroudonMovement(Entity * param_1); -void GroudonScreenFlash(void); -void ArticunoScreenFlash(void); -void sub_8088484(Entity *param_1); -void sub_8088574(void); -void MoltresDropInEffect(Entity * param_1); -void MoltresScreenFlash1(s32 r0, s32 r1); -void MoltresScreenFlash2(s32 r0, s32 r1); -void MoltresScreenFlash3(void); -void MoltresScreenDarken(void); -void EnableJirachiWishWarpTile(void); -void sub_808BB3C(DungeonPos *pos); -void sub_8087144(); -void SkarmoryEntry(Entity *); - -void sub_8086A3C(Entity *pokemon) -{ - GetEntInfo(pokemon)->unk15C = 1; - GetEntInfo(pokemon)->unk15E = 1; -} - -void sub_8086A54(Entity *pokemon) -{ - GetEntInfo(pokemon)->unk15C = 1; - GetEntInfo(pokemon)->unk15E = 0; -} - -void SetupBossFightHP(Entity *pokemon, s32 newHP, u16 songIndex) -{ - EntityInfo *entityInfo = GetEntInfo(pokemon); - - entityInfo->bossFlag = TRUE; - - // BUG: Source of the Reviver Seed Boss Glitch - // - // Video to demonstration: - // https://www.youtube.com/watch?v=rHu7EehrZ68 - entityInfo->originalHP = entityInfo->maxHPStat; - if (newHP != 0) { - entityInfo->maxHPStat = newHP; - entityInfo->HP = newHP; - } - - gDungeon->unk644.bossSongIndex = songIndex; - SetDefaultIQSkills(&entityInfo->IQSkillMenuFlags, entityInfo->bossFlag); - LoadIQSkills(pokemon); -} - -void sub_8086AC0(void) -{ - if(!sub_8044B28()) - if(gDungeon->unk2 == 0) - sub_8097FF8(); -} - -u8 sub_8086AE4(s16 _index) -{ - s32 pokeIndex = _index; - - if(gDungeon->unk644.unk18 == 0) - return 1; - else - return HasRecruitedMon(pokeIndex); -} - -void sub_8086B14(void) -{ - Entity * leaderEntity; - Entity * diglettEntity; - Entity * skarmoryEntity; - - leaderEntity = xxx_call_GetLeader(); - diglettEntity = GetEntityFromMonsterBehavior(BEHAVIOR_DIGLETT); - skarmoryEntity = GetEntityFromMonsterBehavior(BEHAVIOR_SKARMORY); - DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); - sub_8085374(); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - sub_80855E4(sub_8086A3C); - sub_8086A3C(skarmoryEntity); - GetEntInfo(diglettEntity)->unk15C = 1; - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 2); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2],MONSTER_DIGLETT); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[3], MONSTER_SKARMORY); -} - -void sub_8086B94(void) -{ - Entity * leaderEntity; - Entity * diglettEntity; - Entity * skarmoryEntity; - - leaderEntity = xxx_call_GetLeader(); - diglettEntity = GetEntityFromMonsterBehavior(BEHAVIOR_DIGLETT); - skarmoryEntity = GetEntityFromMonsterBehavior(BEHAVIOR_SKARMORY); - - sub_8068FE0(skarmoryEntity,0x21c,0); - sub_8068FE0(diglettEntity,0x21c,0); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y); -} - -// TODO: fix this function as param_2 should be u8 -void sub_8086BDC(u8 param_1, s32 param_2) -{ - if ((((param_2 * 0x1000000) - 0x1000000U) >> 0x18 < 2) && (param_1 == 3)) { - sub_8097FA8(1); - gDungeon->unk2 = 1; - } -} - -void SkarmoryPreFightDialogue(void) -{ - Entity *leaderEntity; - Entity *partnerEntity; - Entity * diglettEntity; - Entity * skarmoryEntity; - - PixelPos pos1; - PixelPos pos2; - - leaderEntity = xxx_call_GetLeader(); // Player - partnerEntity = GetPartnerEntity(); // Partner - diglettEntity = GetEntityFromMonsterBehavior(BEHAVIOR_DIGLETT); // Diglett - skarmoryEntity = GetEntityFromMonsterBehavior(BEHAVIOR_SKARMORY); // Skarmory - - pos1.x = diglettEntity->pixelPos.x; - pos1.y = diglettEntity->pixelPos.y + 0x3000; - - pos2.x = skarmoryEntity->pixelPos.x; - pos2.y = skarmoryEntity->pixelPos.y + 0x2000; - - sub_8086448(); - sub_803E708(10,0x46); - SpriteShockEffect(partnerEntity); - sub_803E708(0x20,0x46); - sub_803E708(10,0x46); - DisplayDungeonDialogue(&gSkarmoryPreFightDialogue_1); - ShiftCameraToPosition(&pos1,0x40); - sub_803E708(0x40,0x46); - ShiftCameraToPosition(&pos2,0x30); - DisplayDungeonDialogue(gSkarmoryPreFightDialogue_2); - sub_803E708(10,0x46); - GetEntInfo(diglettEntity)->unk15D = 1; - ShiftCameraToPosition(&pos1,0x30); - DisplayDungeonDialogue(&gSkarmoryPreFightDialogue_3); // Diglett: ...I...\nI'm scared. - sub_803E708(10,0x46); - ShiftCameraToPosition(&pos2,0x20); - sub_803E708(0x20,0x46); - SkarmoryEntry(skarmoryEntity); - DisplayDungeonDialogue(&gSkarmoryPreFightDialogue_4); // Skarmory: You!\nWhat do you think you're doing here?! - sub_803E708(10,0x46); - DisplayDungeonDialogue(gSkarmoryPreFightDialogue_5); - sub_803E708(10,0x46); - DisplayDungeonDialogue(&gSkarmoryPreFightDialogue_6); - sub_803E708(10,0x46); - DisplayDungeonDialogue(gSkarmoryPreFightDialogue_7); - sub_803E708(10,0x46); - sub_806CDD4(skarmoryEntity,0xd,DIRECTION_SOUTH); - DisplayDungeonDialogue(&gSkarmoryPreFightDialogue_8); - sub_803E708(10,0x46); - sub_80869E4(partnerEntity,4,1,DIRECTION_EAST); - sub_80869E4(leaderEntity,4,2,DIRECTION_WEST); - DisplayDungeonDialogue(gSkarmoryPreFightDialogue_9); - sub_80869E4(partnerEntity,4,2,DIRECTION_NORTH); - sub_80869E4(leaderEntity,4,1,DIRECTION_NORTH); - sub_803E708(10,0x46); - DungeonStartNewBGM(MUS_BOSS_BATTLE); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); -} - -void SkarmoryReFightDialogue(void) -{ - Entity * leaderEntity; - Entity * skarmoryEntity; - PixelPos pos; - - leaderEntity = xxx_call_GetLeader(); - skarmoryEntity = GetEntityFromMonsterBehavior(BEHAVIOR_SKARMORY); - pos.x = skarmoryEntity->pixelPos.x; - pos.y = skarmoryEntity->pixelPos.y + 0x2000; - sub_8086448(); - sub_803E708(10,0x46); - SkarmoryEntry(skarmoryEntity); - ShiftCameraToPosition(&pos,0x10); - DisplayDungeonDialogue(&gSkarmoryReFightDialogue_1); - sub_803E708(10,0x46); - DisplayDungeonDialogue(&gSkarmoryReFightDialogue_2); - sub_803E708(10,0x46); - sub_806CDD4(skarmoryEntity,0xd,DIRECTION_SOUTH); - DisplayDungeonDialogue(&gSkarmoryReFightDialogue_3); - sub_803E708(10,0x46); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); - DungeonStartNewBGM(MUS_BOSS_BATTLE); -} - -void sub_8086E40(void) -{ - SpriteLookAroundEffect(xxx_call_GetLeader()); - sub_803E708(10,0x46); - DisplayDungeonDialogue(&gUnknown_8100D3C); - sub_803E708(10,0x46); - gDungeon->unk2 = 1; -} - -void SkarmoryEntry(Entity * skarmoryEntity) -{ - sub_806CDD4(skarmoryEntity,0xf,DIRECTION_SOUTH); - sub_8086A54(skarmoryEntity); - PlaySoundEffect(0x1f8); - sub_803E708(0x44,0x46); -} - -void sub_8086E9C(void) -{ - Entity * leaderEntity; - - leaderEntity = xxx_call_GetLeader(); - DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); - sub_8085374(); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - sub_80855E4(sub_8086A3C); - sub_808563C(sub_8086A3C); - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 3); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_METAPOD); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[3], MONSTER_GENGAR); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[4], MONSTER_CATERPIE); -} - -void sub_8086F00(void) -{ - Entity * leaderEntity; - - leaderEntity = xxx_call_GetLeader(); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - sub_80855E4(sub_8086A3C); - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 3); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_METAPOD); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[3], MONSTER_GENGAR); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[4], MONSTER_CATERPIE); -} - -void sub_8086F54(u8 param_1, u8 param_2) -{ - s32 index; - - if (param_2 == 4 || param_2 == 5) { - bool8 found = FALSE; - for (index = 0; index < 0x10; index++) { - struct Entity *entity = gDungeon->wildPokemon[index]; - if ((EntityIsValid(entity))) { - struct EntityInfo *entInfo = GetEntInfo(entity); - if (entInfo->monsterBehavior != param_1) { - found = TRUE; - return; - } - } - } - - if (!found) { - sub_8097FA8(3); - gDungeon->unk2 = 1; - } - } -} - -void TeamMeaniesPreFightDialogue(void) -{ - Entity *leaderEntity; - - leaderEntity = xxx_call_GetLeader(); - sub_8086448(); - sub_803E708(10, 0x46); - DisplayDungeonDialogue(gTeamMeaniesPreFightDialogue_1); - sub_803E708(10, 0x46); - DisplayDungeonDialogue(&gTeamMeaniesPreFightDialogue_2); - sub_803E708(10, 0x46); - sub_8087144(); - DungeonStartNewBGM(MUS_THERES_TROUBLE); - DisplayDungeonDialogue(&gTeamMeaniesPreFightDialogue_3); - sub_803E708(10, 0x46); - DisplayDungeonDialogue(gTeamMeaniesPreFightDialogue_4); - sub_803E708(10, 0x46); - DisplayDungeonDialogue(&gTeamMeaniesPreFightDialogue_5); - sub_803E708(10, 0x46); - DisplayDungeonDialogue(&gTeamMeaniesPreFightDialogue_6); - sub_803E708(10, 0x46); - DisplayDungeonDialogue(&gTeamMeaniesPreFightDialogue_7); - sub_803E708(10, 0x46); - ShiftCameraToPosition(&leaderEntity->pixelPos, 0x10); -} - -void TeamMeaniesReFightDialogue(void) -{ - Entity *leaderEntity; - Entity *partnerEntity; - - leaderEntity = xxx_call_GetLeader(); - partnerEntity = GetPartnerEntity(); - sub_8086448(); - DisplayDungeonDialogue(gTeamMeaniesReFightDialogue_1); - sub_803E708(10, 0x46); - DisplayDungeonDialogue(&gTeamMeaniesPreFightDialogue_2); - sub_803E708(10, 0x46); - sub_8087144(); - sub_803E708(10, 0x46); - DisplayDungeonDialogue(gTeamMeaniesReFightDialogue_2); - sub_803E708(10, 0x46); - DisplayDungeonDialogue(&gTeamMeaniesReFightDialogue_3); - sub_803E708(10, 0x46); - sub_806CDD4(leaderEntity, 6, DIRECTION_NORTH); - sub_806CDD4(partnerEntity, 6, DIRECTION_NORTH); - sub_803E708(10, 0x46); - sub_806CDD4(leaderEntity, 7, DIRECTION_NORTH); - sub_806CDD4(partnerEntity, 7, DIRECTION_NORTH); - sub_803E708(10, 0x46); - DisplayDungeonDialogue(&gTeamMeaniesReFightDialogue_4); - DisplayDungeonDialogue(&gTeamMeaniesReFightDialogue_5); - sub_803E708(10, 0x46); - ShiftCameraToPosition(&leaderEntity->pixelPos, 0x10); -} - -void sub_8087130(void) -{ - sub_8086448(); - sub_80866C4(&gUnknown_8101440); -} - -void sub_8087144(void) -{ - Entity *gengarEntity; - Entity *ekansEntity; - Entity *medichamEntity; - s16 auStack_10c[28]; - s16 puStack_60[28]; - s16 puStack_5c[28]; - s16 *puStack_64[3]; - Entity *pEStack_58[3]; - struct_8085B80 auStack_4c[3]; - - gengarEntity = GetEntityFromMonsterBehavior(BEHAVIOR_GENGAR); - ekansEntity = GetEntityFromMonsterBehavior(BEHAVIOR_EKANS); - medichamEntity = GetEntityFromMonsterBehavior(BEHAVIOR_MEDICHAM); - memcpy(auStack_10c,gUnknown_810739C, 0x38); - memcpy(puStack_60, gUnknown_81073D4, 0x38); - memcpy(puStack_5c, gUnknown_810740C, 0x38); - puStack_64[0] = auStack_10c; - puStack_64[1] = puStack_60; - puStack_64[2] = puStack_5c; - pEStack_58[0] = gengarEntity; - pEStack_58[1] = ekansEntity; - pEStack_58[2] = medichamEntity; - DungeonStartNewBGM(MUS_THERES_TROUBLE); - sub_8086A54(gengarEntity); - sub_8086A54(ekansEntity); - sub_8086A54(medichamEntity); - sub_8085B4C(auStack_4c,puStack_64,pEStack_58,3); - GetEntInfo(gengarEntity)->unk15F = 1; - GetEntInfo(ekansEntity)->unk15F = 1; - GetEntInfo(medichamEntity)->unk15F = 1; - while( TRUE ) { - if (!sub_8085B80(auStack_4c)) break; - DungeonRunFrameActions(0x46); - } - GetEntInfo(gengarEntity)->unk15F = 0; - GetEntInfo(ekansEntity)->unk15F = 0; - GetEntInfo(medichamEntity)->unk15F = 0; -} - -void sub_8087230(void) -{ - Entity *leaderEntity; - Entity *zapdosEntity; - - leaderEntity = xxx_call_GetLeader(); - zapdosEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ZAPDOS); - DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); - sub_8085374(); - sub_80854D4(); - sub_8085930(4); - sub_80855E4(sub_8086A3C); - SetFacingDirection(zapdosEntity, DIRECTION_SOUTH); - sub_8086A3C(zapdosEntity); - sub_8085860(leaderEntity->pos.x, leaderEntity->pos.y - 3); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_SHIFTRY); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[3], MONSTER_ZAPDOS); -} - -void sub_808729C(void) -{ - Entity *leaderEntity; - Entity *zapdosEntity; - - leaderEntity = xxx_call_GetLeader(); - zapdosEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ZAPDOS); - sub_80854D4(); - sub_8085930(4); - sub_80855E4(sub_8086A3C); - if (sub_8086AE4(0x91) != 0) { - sub_8068FE0(zapdosEntity,0x21c,0); - } - else { - sub_8072008(zapdosEntity,zapdosEntity,gZapdosConfigLevel,0,0); - SetFacingDirection(zapdosEntity,DIRECTION_SOUTH); - sub_8086A3C(zapdosEntity); - } - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 3); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_SHIFTRY); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[3], MONSTER_ZAPDOS); -} - -void sub_8087334(u8 param_1, u8 param_2) -{ - if ((param_2 == 7 || param_2 == 8 || param_2 == 9) && (param_1 == 8)) { - sub_8097FA8(5); - gDungeon->unk2 = 1; - } -} - -void ZapdosPreFightDialogue(void) -{ - Entity *leaderEntity; - Entity *partnerEntity; - struct Zapdos1 puStack_38; // sp 0x0 - struct_8085B80 auStack_78; - struct Zapdos2 puStack_30; - s16 *puStack_34[1]; // sp 0x58 - struct Entity *pEStack_34[1]; // sp 0x5c - s16 *puStack_4c[1]; // sp 0x60 - Entity *pEStack_2c[1]; // sp 0x64 - Entity *zapdosEntity; // sp 0x68 - struct_8085B80 auStack_48; // r8 - - leaderEntity = xxx_call_GetLeader(); - partnerEntity = GetPartnerEntity(); - zapdosEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ZAPDOS); - sub_8086448(); - sub_803E708(10,0x46); - SpriteLookAroundEffect(partnerEntity); - sub_803E708(10,0x46); - sub_80869E4(partnerEntity,4,1,DIRECTION_EAST); - sub_80869E4(leaderEntity,4,2,DIRECTION_WEST); - DisplayDungeonDialogue(gUnknown_81014B0); - sub_803E708(10,0x46); - sub_80869E4(partnerEntity,4,2,DIRECTION_NORTH); - sub_80869E4(leaderEntity,4,1,DIRECTION_NORTH); - DisplayDungeonDialogue(gUnknown_8101504); - sub_803E708(10,0x46); - ZapdosScreenFlash(3); - DungeonStopBGM(); - PlaySoundEffect(0x1da); - DisplayDungeonDialogue(&gUnknown_81015A0); - ZapdosDropInEffect(zapdosEntity); - DungeonStartNewBGM(MUS_RISING_FEAR); - sub_806CDD4(partnerEntity,6,DIRECTION_NORTH); - DisplayDungeonDialogue(&gUnknown_81015D4); // Waah! - sub_803E708(10,0x46); - sub_80869E4(partnerEntity,2,1,DIRECTION_SOUTHEAST); - - puStack_38 = gUnknown_810744C; - puStack_34[0] = puStack_38.unk0; - pEStack_34[0] = partnerEntity; - sub_8085B4C(&auStack_78,puStack_34,pEStack_34,1); - GetEntInfo(partnerEntity)->unk15F = 1; - while(sub_8085B80(&auStack_78)) { - DungeonRunFrameActions(0x46); - } - - GetEntInfo(partnerEntity)->unk15F = 0; - GetEntInfo(partnerEntity)->unk15D = 1; - sub_80869E4(partnerEntity,2,2,DIRECTION_NORTH); - DisplayDungeonDialogue(&gUnknown_81015E8); // I warned you! I have no mercy for meddlers - sub_803E708(0x3c,0x46); - DisplayDungeonDialogue(&gUnknown_8101624); - sub_803E708(10,0x46); - GetEntInfo(partnerEntity)->unk15D = 0; - sub_80869E4(partnerEntity,2,2,DIRECTION_NORTHWEST); - - puStack_30 = gUnknown_8107464; - puStack_4c[0] = puStack_30.unk0; - pEStack_2c[0] = partnerEntity; - sub_8085B4C(&auStack_48,puStack_4c,pEStack_2c,1); - while (sub_8085B80(&auStack_48)) { - DungeonRunFrameActions(0x46); - } - - sub_80869E4(partnerEntity,2,1,DIRECTION_NORTHEAST); - DisplayDungeonDialogue(gUnknown_810165C); - sub_803E708(10,0x46); - ZapdosScreenFlash(3); - DisplayDungeonDialogue(&gUnknown_8101750); - sub_803E708(10,0x46); - ZapdosScreenFlash(1); - DisplayDungeonDialogue(&gUnknown_810178C); - sub_803E708(10,0x46); - ZapdosScreenFlash(2); - DisplayDungeonDialogue(&gUnknown_81017B4); - sub_803E708(10,0x46); - SetupBossFightHP(zapdosEntity,300, MUS_BOSS_BATTLE); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); -} - -void ZapdosReFightDialogue(void) -{ - Entity *leaderEntity; - Entity *zapdosEntity; - - leaderEntity = xxx_call_GetLeader(); - zapdosEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ZAPDOS); - sub_8086448(); - sub_803E708(10,0x46); - DisplayDungeonDialogue(gZapdosReFightDialogue_1); - sub_803E708(10,0x46); - PlaySoundEffect(0x1da); - DisplayDungeonDialogue(&gUnknown_81015A0); - sub_803E708(10,0x46); - ZapdosDropInEffect(zapdosEntity); - sub_803E708(10,0x46); - DisplayDungeonDialogue(&gZapdosReFightDialogue_2); - ZapdosScreenFlash(1); - DisplayDungeonDialogue(&gZapdosReFightDialogue_3); - ZapdosScreenFlash(2); - DisplayDungeonDialogue(&gZapdosReFightDialogue_4); - SetupBossFightHP(zapdosEntity,300,MUS_BOSS_BATTLE); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); -} - -void ZapdosPostStoryPreFightDialogue(void) -{ - Entity * leaderEntity; - Entity * zapdosEntity; - - leaderEntity = xxx_call_GetLeader(); - zapdosEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ZAPDOS); - sub_8086448(); - if (sub_8086AE4(MONSTER_ZAPDOS)) { - sub_80866C4(&gZapdosPostStoryPreFightDialogue_6); - } - else { - ZapdosScreenFlash(1); - PlaySoundEffect(0x1da); - DisplayDungeonDialogue(&gZapdosPostStoryPreFightDialogue_1); - ZapdosDropInEffect(zapdosEntity); - DisplayDungeonDialogue(&gZapdosPostStoryPreFightDialogue_2); - ZapdosScreenFlash(1); - DisplayDungeonDialogue(&gZapdosPostStoryPreFightDialogue_3); - ZapdosScreenFlash(2); - DisplayDungeonDialogue(&gZapdosPostStoryPreFightDialogue_4); - ZapdosScreenFlash(2); - DisplayDungeonDialogue(&gZapdosPostStoryPreFightDialogue_5); - sub_803E708(10,0x46); - SetupBossFightHP(zapdosEntity,300,MUS_BOSS_BATTLE); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); - } -} - - -void ZapdosDropInEffect(Entity *zapdosEntity) -{ - int iVar1; - - GetEntInfo(zapdosEntity)->unk15C = 1; - GetEntInfo(zapdosEntity)->unk15E = 0; - GetEntInfo(zapdosEntity)->unk174.raw = 200; // incorrect value? Overwritten immediately anyway - PlaySoundEffect(0x1ea); - for(iVar1 = 200; iVar1 >= 0; iVar1 -= 5) - { - GetEntInfo(zapdosEntity)->unk174 = IntToF248_2(iVar1); - DungeonRunFrameActions(0x46); - } - sub_803E708(0x1e,0x46); -} - -void ZapdosScreenFlash(s32 numFlashes) -{ - s32 index; - - PlaySoundEffect(0x1f6); - if (2 < numFlashes) { - for(index = 250; index > 199; index -= 10) - { - SetDungeonBGColorRGB(index,index,index / 2,1,1); - DungeonRunFrameActions(0x46); - } - } - if (1 < numFlashes) { - for(index = 250; index > 199; index -= 10) - { - SetDungeonBGColorRGB(index,index,index / 2,1,1); - DungeonRunFrameActions(0x46); - } - } - for(index = 250; index >= 0; index -= 10) - { - SetDungeonBGColorRGB(index,index,index / 4,1,1); - DungeonRunFrameActions(0x46); - } - sub_8085EB0(); -} - -void sub_80877E8(void) -{ - Entity * leaderEntity; - Entity * moltresEntity; - - leaderEntity = xxx_call_GetLeader(); - moltresEntity = GetEntityFromMonsterBehavior(BEHAVIOR_MOLTRES); - DungeonStartNewBGM(MUS_THE_MOUNTAIN_OF_FIRE); - sub_8085374(); - sub_80854D4(); - sub_8085930(DIRECTION_WEST); - sub_80855E4(sub_8086A3C); - SetFacingDirection(moltresEntity, DIRECTION_SOUTH); - sub_8086A3C(moltresEntity); - sub_8085860(leaderEntity->pos.x + -3,leaderEntity->pos.y + -2); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_MOLTRES); -} - -void sub_8087848(void) -{ - Entity *leaderEntity; - Entity *moltresEntity; - - u32 XPos; - s32 YPos; - - leaderEntity = xxx_call_GetLeader(); - moltresEntity = GetEntityFromMonsterBehavior(BEHAVIOR_MOLTRES); - DungeonStartNewBGM(MUS_THE_MOUNTAIN_OF_FIRE); - sub_80854D4(); - sub_8085930(DIRECTION_WEST); - sub_80855E4(sub_8086A3C); - if (sub_8086AE4(MONSTER_MOLTRES)) { - sub_8068FE0(moltresEntity,0x21c,0); - } - else { - sub_8072008(moltresEntity,moltresEntity,gMoltresConfigLevel,0,0); - SetFacingDirection(moltresEntity, DIRECTION_SOUTH); - sub_8086A3C(moltresEntity); - } - sub_8085860(leaderEntity->pos.x - 5, leaderEntity->pos.y); - XPos = GetCameraXPos(); - YPos = GetCameraYPos(); - sub_803F878(XPos, YPos + -0x1000); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2],MONSTER_MOLTRES); -} - -void sub_80878F4(u8 param_1, u8 param_2) -{ - if ((param_2 == 0xA || param_2 == 0xB || param_2 == 0xC) && (param_1 == 0x9)) { - sub_8097FA8(0x7); - gDungeon->unk2 = 1; - } -} - -void MoltresPreFightDialogue(void) -{ - Entity *leaderEntity; - Entity *partnerEntity; - Entity *moltresEntity; - - leaderEntity = xxx_call_GetLeader(); - partnerEntity = GetPartnerEntity(); - moltresEntity = GetEntityFromMonsterBehavior(BEHAVIOR_MOLTRES); - MoltresScreenFlash1(0xc,5); - sub_8086500(); - sub_803E708(10,0x46); - DisplayDungeonDialogue(&gMoltresPreFightDialogue_1); - sub_803E708(10,0x46); - sub_80869E4(partnerEntity,4,1,DIRECTION_NORTHWEST); - sub_803E708(4,0x46); - SpriteLookAroundEffect(partnerEntity); - sub_803E708(10,0x46); - DisplayDungeonDialogue(gMoltresPreFightDialogue_2); - sub_803E708(10,0x46); - MoltresScreenFlash1(0xc,5); - MoltresScreenFlash2(9,5); - DisplayDungeonDialogue(gMoltresPreFightDialogue_3); - sub_803E708(10,0x46); - sub_80869E4(partnerEntity,4,1,DIRECTION_EAST); - sub_80869E4(leaderEntity,4,2,DIRECTION_WEST); - DisplayDungeonDialogue(gMoltresPreFightDialogue_4); - sub_803E708(10,0x46); - sub_80869E4(partnerEntity,4,2,DIRECTION_WEST); - sub_8086690(); - DisplayDungeonDialogue(&gMoltresPreFightDialogue_5); - sub_803E708(10,0x46); - sub_8085930(DIRECTION_NORTHWEST); - sub_803E708(4,0x46); - sub_8085930(DIRECTION_NORTH); - PlaySoundEffect(0x2f2); - DungeonStopBGM(); - MoltresScreenDarken(); - DisplayDungeonDialogue(gMoltresPreFightDialogue_6); - sub_803E708(10,0x46); - DisplayDungeonDialogue(&gMoltresPreFightDialogue_7); - sub_803E708(10,0x46); - PlaySoundEffect(0x1cf); - sub_80856E0(partnerEntity, DIRECTION_NORTH); - sub_803E708(10,0x46); - DisplayDungeonDialogue(gMoltresPreFightDialogue_8); - sub_803E708(10,0x46); - MoltresScreenFlash3(); - PlaySoundEffect(0x1da); - DisplayDungeonDialogue(&gMoltresPreFightDialogue_9); - sub_803E708(10,0x46); - MoltresScreenFlash1(9,5); - MoltresScreenFlash2(0xb,5); - DisplayDungeonDialogue(&gMoltresPreFightDialogue_10); - sub_803E708(10,0x46); - MoltresScreenFlash1(0xc,5); - MoltresScreenFlash2(9,5); - MoltresDropInEffect(moltresEntity); - sub_808663C(); - MoltresScreenFlash3(); - DisplayDungeonDialogue(&gMoltresPreFightDialogue_11); - sub_803E708(10,0x46); - MoltresScreenFlash2(0xb,6); - DisplayDungeonDialogue(&gMoltresPreFightDialogue_12); - sub_803E708(10,0x46); - SetupBossFightHP(moltresEntity,400,MUS_BOSS_BATTLE); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); -} - - -void MoltresReFightDialogue(void) -{ - Entity *leaderEntity; - Entity *partnerEntity; - Entity *moltresEntity; - - leaderEntity = xxx_call_GetLeader(); - partnerEntity = GetPartnerEntity(); - moltresEntity = GetEntityFromMonsterBehavior(BEHAVIOR_MOLTRES); - MoltresScreenFlash1(10,5); - sub_8086500(); - sub_803E708(10,0x46); - SpriteLookAroundEffect(partnerEntity); - sub_803E708(10,0x46); - DisplayDungeonDialogue(&gMoltresReFightDialogue_1); - sub_803E708(10,0x46); - sub_80869E4(partnerEntity,4,1,DIRECTION_EAST); - sub_80869E4(leaderEntity,4,2,DIRECTION_WEST); - DisplayDungeonDialogue(gMoltresReFightDialogue_2); - sub_803E708(10,0x46); - sub_80869E4(partnerEntity,4,2,DIRECTION_WEST); - sub_80869E4(leaderEntity,4,2,DIRECTION_WEST); - sub_8086690(); - MoltresScreenDarken(); - sub_803E708(10,0x46); - sub_8085930(DIRECTION_NORTHWEST); - sub_803E708(4,0x46); - sub_8085930(DIRECTION_NORTH); - MoltresDropInEffect(moltresEntity); - sub_808663C(); - MoltresScreenFlash3(); - DisplayDungeonDialogue(&gMoltresReFightDialogue_3); - sub_803E708(10,0x46); - MoltresScreenFlash2(0xb,6); - DisplayDungeonDialogue(gMoltresReFightDialogue_4); - sub_803E708(10,0x46); - DisplayDungeonDialogue(&gMoltresReFightDialogue_5); - sub_803E708(10,0x46); - SetupBossFightHP(moltresEntity,400,MUS_BOSS_BATTLE); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); -} - -void MoltresPostStoryPreFightDialogue(void) -{ - Entity * leaderEntity; - Entity * moltresEntity; - - leaderEntity = xxx_call_GetLeader(); - moltresEntity = GetEntityFromMonsterBehavior(BEHAVIOR_MOLTRES); - MoltresScreenFlash1(0xc,5); - sub_808654C(); - if (sub_8086AE4(MONSTER_MOLTRES)) { - sub_8085930(DIRECTION_NORTHWEST); - sub_803E708(4,0x46); - sub_8085930(DIRECTION_NORTH); - sub_803E708(4,0x46); - sub_803E708(10,0x46); - DisplayDungeonDialogue(&gUnknown_8100D3C); - sub_803E708(10,0x46); - gDungeon->unk2 = 1; - } - else { - DisplayDungeonDialogue(&gMoltresPostStoryPreFightDialogue_1); - sub_8085930(DIRECTION_NORTHWEST); - sub_803E708(4,0x46); - sub_8085930(DIRECTION_NORTH); - MoltresDropInEffect(moltresEntity); - DisplayDungeonDialogue(&gMoltresPostStoryPreFightDialogue_2); - MoltresScreenFlash1(0xc,5); - MoltresScreenFlash2(9,5); - DisplayDungeonDialogue(&gMoltresPostStoryPreFightDialogue_3); - MoltresScreenFlash3(); - DisplayDungeonDialogue(&gMoltresPostStoryPreFightDialogue_4); - MoltresScreenFlash2(0xb,6); - DisplayDungeonDialogue(&gMoltresPostStoryPreFightDialogue_5); - sub_803E708(10,0x46); - SetupBossFightHP(moltresEntity,400,MUS_BOSS_BATTLE); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); - } -} - -void MoltresDropInEffect(Entity * moltresEntity) -{ - s32 iVar1; - - GetEntInfo(moltresEntity)->unk15C = 1; - GetEntInfo(moltresEntity)->unk15E = 0; - GetEntInfo(moltresEntity)->unk174 = IntToF248_2(200); - PlaySoundEffect(0x1f8); - for(iVar1 = 200; iVar1 >= 0; iVar1 -= 5) - { - GetEntInfo(moltresEntity)->unk174 = IntToF248_2(iVar1); - DungeonRunFrameActions(0x46); - } -} - -void MoltresScreenFlash1(s32 xArg, s32 yArg) -{ - s32 x, y; - DungeonPos newPos; - - x = X_POS_TO_PIXELPOS(xArg); - newPos.x = x / 256; - - y = Y_POS_TO_PIXELPOS(yArg); - newPos.y = y / 256; - - sub_8085EC8(370,16,0,&newPos,0); -} - -void MoltresScreenFlash2(s32 xArg, s32 yArg) -{ - s32 r6; - s32 i, x, y; - DungeonPos newPos; - - x = X_POS_TO_PIXELPOS(xArg); - newPos.x = x / 256; - - y = Y_POS_TO_PIXELPOS(yArg); - newPos.y = y / 256; - - r6 = sub_8085EC8(370,22,0,&newPos,0); - PlaySoundEffect(0x1EC); - - for (i = 250; i >= 20; i -= 10) { - SetDungeonBGColorRGB(i, 0, 0, 1, 1); - DungeonRunFrameActions(0x46); - } - sub_803E708(0xA, 0x46); - - for (i = 250; i >= 0; i -= 10) { - SetDungeonBGColorRGB(i, 0, 0, 1, 1); - DungeonRunFrameActions(0x46); - } - sub_803E708(0xA, 0x46); - - sub_8085EB0(); - sub_8085F44(r6); -} - -void MoltresScreenFlash3(void) -{ - int iVar1; - - PlaySoundEffect(0x1ed); - iVar1 = 0xfa; - for(iVar1 = 250; iVar1 > 9; iVar1 -= 10) - { - SetDungeonBGColorRGB(iVar1,iVar1,iVar1 / 2,1,1); - DungeonRunFrameActions(0x46); - } - sub_803E708(0x1e,0x46); - PlaySoundEffect(0x1ed); - for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10) - { - SetDungeonBGColorRGB(iVar1,iVar1,iVar1 / 2,1,1); - DungeonRunFrameActions(0x46); - } - sub_803E708(0x1e,0x46); - sub_8085EB0(); -} - -void MoltresScreenDarken(void) -{ - s32 iVar1; - - for(iVar1 = 0; iVar1 >= -80; iVar1 -= 8) - { - SetDungeonBGColorRGB(iVar1,iVar1,iVar1,0,0); - DungeonRunFrameActions(0x46); - } -} - - -void sub_8087F54(void) -{ - Entity *leaderEntity; - Entity *articunoEntity; - - leaderEntity = xxx_call_GetLeader(); - articunoEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ARTICUNO); - DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); - sub_8085374(); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - sub_80855E4(sub_8086A3C); - SetFacingDirection(articunoEntity, DIRECTION_SOUTH); - sub_8086A3C(articunoEntity); - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y + -3); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_ARTICUNO); -} - -void sub_8087FB4(void) -{ - Entity *articunoEntity; - - articunoEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ARTICUNO); - DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); - sub_8085374(); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - SetFacingDirection(articunoEntity, DIRECTION_SOUTH); - sub_806CDD4(articunoEntity, 0xF, DIRECTION_SOUTH); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_ARTICUNO); -} - -void sub_8087FF8(void) -{ - Entity *leaderEntity; - Entity *articunoEntity; - - leaderEntity = xxx_call_GetLeader(); - articunoEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ARTICUNO); - sub_8085374(); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - sub_80855E4(sub_8086A3C); - if (sub_8086AE4(MONSTER_ARTICUNO)) { - sub_8068FE0(articunoEntity,0x21c,0); - } - else { - sub_8072008(articunoEntity,articunoEntity,gArticunoConfigLevel,0,0); - SetFacingDirection(articunoEntity, DIRECTION_SOUTH); - sub_8086A3C(articunoEntity); - } - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y + -3); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_ARTICUNO); -} - -void sub_8088088(u8 param_1, u8 param_2) -{ - if ((param_2 == 0xD || param_2 == 0xE || param_2 == 0xF) && (param_1 == 0xD)) { - sub_8097FA8(0x9); - gDungeon->unk2 = 1; - } -} - -void ArticunoPreFightDialogue(void) -{ - Entity *leaderEntity; - Entity *partnerEntity; - Entity *articunoEntity; - - leaderEntity = xxx_call_GetLeader(); - partnerEntity = GetPartnerEntity(); - articunoEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ARTICUNO); - sub_8086448(); - SpriteLookAroundEffect(partnerEntity); - DisplayDungeonDialogue(gArticunoPreFightDialogue_1); - sub_803E708(10,0x46); - sub_8086598(); - DungeonStopBGM(); - DisplayDungeonDialogue(&gArticunoPreFightDialogue_2); - sub_803E708(10,0x46); - sub_80869E4(partnerEntity,4,1,DIRECTION_EAST); - sub_80869E4(leaderEntity,4,2,DIRECTION_WEST); - DisplayDungeonDialogue(&gArticunoPreFightDialogue_3); - sub_803E708(10,0x46); - SetFacingDirection(leaderEntity, DIRECTION_WEST); - sub_803E708(4,0x46); - SetFacingDirection(leaderEntity, DIRECTION_NORTHWEST); - sub_803E708(4,0x46); - SetFacingDirection(leaderEntity, DIRECTION_WEST); - sub_803E708(4,0x46); - SetFacingDirection(leaderEntity, DIRECTION_SOUTHWEST); - sub_803E708(4,0x46); - SetFacingDirection(leaderEntity, DIRECTION_WEST); - sub_803E708(4,0x46); - SetFacingDirection(leaderEntity, DIRECTION_NORTHWEST); - sub_803E708(4,0x46); - SetFacingDirection(leaderEntity, DIRECTION_WEST); - sub_803E708(10,0x46); - DisplayDungeonDialogue(gArticunoPreFightDialogue_4); - sub_803E708(10,0x46); - DisplayDungeonDialogue(&gArticunoPreFightDialogue_5); - sub_803E708(10,0x46); - sub_80869E4(leaderEntity,4,1,DIRECTION_NORTH); - sub_80869E4(partnerEntity,4,2,DIRECTION_NORTH); - PlaySoundEffect(0x1d5); - SpriteLookAroundEffect(partnerEntity); - PlaySoundEffect(0x1d5); - SpriteLookAroundEffect(leaderEntity); - DisplayDungeonDialogue(&gArticunoPreFightDialogue_6); - sub_803E708(10,0x46); - DisplayDungeonDialogue(&gArticunoPreFightDialogue_7); - sub_803E708(10,0x46); - PlaySoundEffect(0); // snow flurry - gDungeon->weather.unkE265 = WEATHER_SNOW; - sub_807EAA0(0,1); - PlaySoundEffect(0x1ee); // flash effect? - sub_8088574(); - DisplayDungeonDialogue(&gArticunoPreFightDialogue_8); - sub_803E708(10,0x46); - ArticunoScreenFlash(); - sub_8086738(); - PlaySoundEffect(0x1da); - DisplayDungeonDialogue(&gArticunoPreFightDialogue_9); - sub_803E708(10,0x46); - PlaySoundEffect(0x1ea); - sub_8088484(articunoEntity); - sub_80865E8(); - ArticunoScreenFlash(); - DisplayDungeonDialogue(&gArticunoPreFightDialogue_10); - sub_806CDD4(articunoEntity,0xf,DIRECTION_SOUTH); - ArticunoScreenFlash(); - DisplayDungeonDialogue(&gArticunoPreFightDialogue_11); - sub_806CDD4(articunoEntity,0x10,DIRECTION_SOUTH); - ArticunoScreenFlash(); - DisplayDungeonDialogue(&gArticunoPreFightDialogue_12); - sub_806CDD4(articunoEntity,0xf,DIRECTION_SOUTH); - sub_803E708(0x10,0x46); - SetupBossFightHP(articunoEntity,0x1c2,MUS_BOSS_BATTLE); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); -} - -void ArticunoReFightDialogue(void) -{ - Entity *leaderEntity; - Entity *articunoEntity; - - leaderEntity = xxx_call_GetLeader(); - articunoEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ARTICUNO); - gDungeon->weather.unkE265 = WEATHER_SNOW; - sub_807EAA0(0,1); - sub_803E708(10,0x46); - DisplayDungeonDialogue(&gArticunoReFightDialogue_1); - sub_806CDD4(articunoEntity,0x10,DIRECTION_SOUTH); - ArticunoScreenFlash(); - DisplayDungeonDialogue(&gArticunoReFightDialogue_2); - ArticunoScreenFlash(); - DisplayDungeonDialogue(&gArticunoReFightDialogue_3); - sub_806CDD4(articunoEntity,0xf,DIRECTION_SOUTH); - sub_803E708(0x28,0x46); - SetupBossFightHP(articunoEntity,0x1c2,MUS_BOSS_BATTLE); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); -} - -void ArticunoPostStoryPreFightDialogue(void) -{ - Entity *leaderEntity; - Entity *articunoEntity; - - leaderEntity = xxx_call_GetLeader(); - articunoEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ARTICUNO); - sub_8086448(); - if (sub_8086AE4(MONSTER_ARTICUNO)) { - sub_80866C4(&gUnknown_8102A9C); - } - else { - gDungeon->weather.unkE265 = WEATHER_SNOW; - sub_807EAA0(0,1); - ArticunoScreenFlash(); - sub_8086738(); - PlaySoundEffect(0x1da); - DisplayDungeonDialogue(&gArticunoPostStoryPreFightDialogue_1); - sub_803E708(10,0x46); - sub_8088484(articunoEntity); - ArticunoScreenFlash(); - DisplayDungeonDialogue(&gArticunoPostStoryPreFightDialogue_2); - sub_806CDD4(articunoEntity,0xf,DIRECTION_SOUTH); - ArticunoScreenFlash(); - DisplayDungeonDialogue(&gArticunoPostStoryPreFightDialogue_3); - sub_806CDD4(articunoEntity,0x10,DIRECTION_SOUTH); - ArticunoScreenFlash(); - DisplayDungeonDialogue(&gArticunoPostStoryPreFightDialogue_4); - ArticunoScreenFlash(); - DisplayDungeonDialogue(&gArticunoPostStoryPreFightDialogue_5); - sub_806CDD4(articunoEntity,0xf,DIRECTION_SOUTH); - sub_803E708(0x28,0x46); - SetupBossFightHP(articunoEntity,0x1c2,MUS_BOSS_BATTLE); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); - } -} - -void sub_8088484(Entity *param_1) -{ - int iVar1; - - GetEntInfo(param_1)->unk15C = 1; - GetEntInfo(param_1)->unk15E = 0; - PlaySoundEffect(0x1ea); - for(iVar1 = 250; iVar1 >= 0; iVar1 -= 5) - { - GetEntInfo(param_1)->unk174 = IntToF248_2(iVar1); - SetDungeonBGColorRGB(iVar1,iVar1,iVar1 / 2,1,0); - DungeonRunFrameActions(0x46); - } -} - -void ArticunoScreenFlash(void) -{ - int iVar1; - - PlaySoundEffect(0x2ad); - for(iVar1 = 250; iVar1 > 0x95; iVar1 -= 10) - { - SetDungeonBGColorRGB(iVar1 / 2,iVar1,iVar1,1,1); - DungeonRunFrameActions(0x46); - } - sub_803E708(4,0x46); - for(iVar1 = 250; iVar1 > 199; iVar1 -= 10) - { - SetDungeonBGColorRGB(0,iVar1,iVar1,1,1); - DungeonRunFrameActions(0x46); - } - sub_803E708(4,0x46); - for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10) - { - SetDungeonBGColorRGB(iVar1 / 2,iVar1,iVar1,1,1); - DungeonRunFrameActions(0x46); - } - sub_803E708(4,0x46); - sub_8085EB0(); -} - -void sub_8088574(void) -{ - int iVar1; - - for(iVar1 = 0; iVar1 <= 80; iVar1 += 8) - { - SetDungeonBGColorRGB(iVar1,iVar1,iVar1,0,0); - DungeonRunFrameActions(0x46); - } -} - -void sub_80885A0(void) -{ - DungeonFadeOutBGM(0x3c); - sub_803E708(0x3c,0x46); - DungeonStopBGM(); - gDungeon->unk7 = 1; -} - -void sub_80885C4(void) -{ - Entity * leaderEntity; - - leaderEntity = xxx_call_GetLeader(); - DungeonFadeOutBGM(0x3c); - sub_803E708(0x3c,0x46); - DungeonStopBGM(); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - sub_80855E4(sub_8086A3C); - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 3); -} - -void sub_8088608(void) -{ - gDungeon->unk2 = 1; -} - -void sub_8088618(void) -{ - sub_8086448(); - // The mountain's summit... - // But there is no one here - // It's time to go back - sub_80866C4(&gUnknown_8102B10); -} - -void sub_808862C(void) -{ - Entity * leaderEntity; - Entity * alakazamEntity; - Entity * groudonEntity; - - leaderEntity = xxx_call_GetLeader(); - alakazamEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ALAKAZAM_1); - groudonEntity = GetEntityFromMonsterBehavior(BEHAVIOR_GROUDON_2); - DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); - sub_80867F4(); - sub_8085374(); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - sub_80855E4(sub_8086A3C); - SetFacingDirection(alakazamEntity, DIRECTION_NORTH); - sub_80861D4(alakazamEntity,0xd,DIRECTION_NORTH); - SetFacingDirection(groudonEntity, DIRECTION_SOUTH); - sub_8086A3C(groudonEntity); - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y -3); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_GROUDON); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[3], MONSTER_ALAKAZAM); -} - -void sub_80886C4(void) -{ - Entity * leaderEntity; - Entity * alakazamEntity; - Entity * groudonEntity; - - u32 XPos; - s32 YPos; - - leaderEntity = xxx_call_GetLeader(); - alakazamEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ALAKAZAM_1); - groudonEntity = GetEntityFromMonsterBehavior(BEHAVIOR_GROUDON_2); - PlaySoundEffect(0x3e5); - sub_80867F4(); - sub_8085374(); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - sub_8068FE0(alakazamEntity,0x21c,0); - SetFacingDirection(groudonEntity, DIRECTION_SOUTH); - sub_8086A3C(groudonEntity); - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y); - XPos = GetCameraXPos(); - YPos = GetCameraYPos(); - sub_803F878(XPos,YPos + -0x1000); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_GROUDON); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[3], MONSTER_ALAKAZAM); -} - -void sub_808875C(void) -{ - Entity * leaderEntity; - Entity * alakazamEntity; - Entity * groudonEntity; - - leaderEntity = xxx_call_GetLeader(); - alakazamEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ALAKAZAM_1); - groudonEntity = GetEntityFromMonsterBehavior(BEHAVIOR_GROUDON_2); - sub_80867F4(); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - sub_80855E4(sub_8086A3C); - sub_8068FE0(alakazamEntity,0x21c,0); - if (sub_8086AE4(MONSTER_GROUDON)) { - sub_8068FE0(groudonEntity,0x21c,0); - } - else { - sub_8072008(groudonEntity,groudonEntity,gGroudonConfigLevel,0,0); - SetFacingDirection(groudonEntity, DIRECTION_SOUTH); - sub_80861D4(groudonEntity,0xf,DIRECTION_SOUTH); - } - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 3); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_GROUDON); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[3], MONSTER_ALAKAZAM); -} - -void sub_8088818(u8 param_1, u8 param_2) -{ - if ((param_2 == 0x12 || param_2 == 0x13 || param_2 == 0x14) && (param_1 == 0xE)) { - sub_8097FA8(0xC); - gDungeon->unk2 = 1; - } -} - -void sub_8088848(void) -{ - sub_8086854(); -} - -void GroudonPreFightDialogue(void) -{ - Entity * leaderEntity; - Entity * partnerEntity; - Entity * alakazamEntity; - Entity * groudonEntity; - - leaderEntity = xxx_call_GetLeader(); - partnerEntity = GetPartnerEntity(); - alakazamEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ALAKAZAM_1); - groudonEntity = GetEntityFromMonsterBehavior(BEHAVIOR_GROUDON_2); - sub_8086448(); - DisplayDungeonDialogue(GroudonPreFightDialogue_1); - sub_803E708(10,0x46); - sub_803E708(0x3c,0x46); - DisplayDungeonDialogue(&GroudonPreFightDialogue_2); - sub_803E708(10,0x46); - sub_8086838(1,1,1); - sub_808680C(); - sub_803E708(0x3c,0x46); - sub_808682C(); - sub_803E708(0x1e,0x46); - DisplayDungeonDialogue(&GroudonPreFightDialogue_3); - sub_803E708(10,0x46); - sub_8086838(1,1,1); - sub_808680C(); - sub_803E708(0x3c,0x46); - DisplayDungeonDialogue(&GroudonPreFightDialogue_4); - sub_803E708(10,0x46); - GroudonScreenFlash(); - DisplayDungeonDialogue(&GroudonPreFightDialogue_5); - sub_803E708(10,0x46); - DisplayDungeonDialogue(&GroudonPreFightDialogue_6); - sub_803E708(10,0x46); - PlaySoundEffect(0x1d5); - SpriteLookAroundEffect(partnerEntity); - DisplayDungeonDialogue(&GroudonPreFightDialogue_7); - sub_803E708(10,0x46); - sub_808682C(); - sub_803E708(0x3c,0x46); - sub_80861B8(alakazamEntity,6,DIRECTION_NORTH); - PlaySoundEffect(0x205); - sub_8086738(); - sub_8068FE0(alakazamEntity,0x21c,0); - DisplayDungeonDialogue(&GroudonPreFightDialogue_8); - sub_803E708(10,0x46); - DisplayDungeonDialogue(&GroudonPreFightDialogue_9); - sub_803E708(10,0x46); - sub_8085930(DIRECTION_NORTH); - sub_8086764(); - sub_803E708(0x28,0x46); - PlaySoundEffect(0x1d5); - SpriteLookAroundEffect(partnerEntity); - DisplayDungeonDialogue(GroudonPreFightDialogue_10); - sub_803E708(10,0x46); - sub_8086838(1,1,1); - sub_808680C(); - sub_803E708(0x3c,0x46); - DisplayDungeonDialogue(GroudonPreFightDialogue_11); - sub_803E708(10,0x46); - DungeonStopBGM(); - GroudonScreenFlash2(); - sub_803E708(0x1e,0x46); - DisplayDungeonDialogue(&GroudonPreFightDialogue_12); - sub_803E708(10,0x46); - DisplayDungeonDialogue(&GroudonPreFightDialogue_13); - sub_803E708(10,0x46); - sub_803E708(0x1e,0x46); - sub_808682C(); - sub_803E708(0x3c,0x46); - PlaySoundEffect(0x1fa); - sub_8086738(); - sub_8085930(DIRECTION_NORTH); - DisplayDungeonDialogue(GroudonPreFightDialogue_14); - sub_803E708(10,0x46); - sub_8086A54(groudonEntity); - sub_8085930(DIRECTION_NORTH); - sub_8086764(); - SetupBossFightHP(groudonEntity,500,MUS_BOSS_BATTLE); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); -} - -void GroudonReFightDialogue(void) -{ - Entity * leaderEntity; - Entity * groudonEntity; - - leaderEntity = xxx_call_GetLeader(); - groudonEntity = GetEntityFromMonsterBehavior(BEHAVIOR_GROUDON_2); - sub_8086838(1,1,1); - sub_808680C(); - sub_803E708(0x3c,0x46); - DisplayDungeonDialogue(gGroudonReFightDialogue_1); - sub_803E708(10,0x46); - GroudonScreenFlash(); - sub_803E708(0x1e,0x46); - DisplayDungeonDialogue(gGroudonReFightDialogue_2); - sub_803E708(10,0x46); - DisplayDungeonDialogue(&gGroudonReFightDialogue_3); - sub_803E708(10,0x46); - sub_808682C(); - sub_803E708(0x3c,0x46); - DungeonStopBGM(); - PlaySoundEffect(0x1fa); - sub_8086738(); - DisplayDungeonDialogue(gGroudonReFightDialogue_4); - sub_803E708(10,0x46); - sub_8086A54(groudonEntity); - sub_8085930(DIRECTION_NORTH); - sub_8086764(); - SetupBossFightHP(groudonEntity,500,MUS_BOSS_BATTLE); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); -} - -void GroudonPostStoryPreFightDialogue(void) -{ - Entity * leaderEntity; - Entity * groudonEntity; - - leaderEntity = xxx_call_GetLeader(); - groudonEntity = GetEntityFromMonsterBehavior(BEHAVIOR_GROUDON_2); - sub_8086448(); - if (sub_8086AE4(MONSTER_GROUDON)) { - sub_80866C4(&gUnknown_8103488); - } - else{ - DisplayDungeonDialogue(&gGroudonPostStoryPreFightDialogue_1); - sub_803E708(10,0x46); - SceneGroudonMovement(groudonEntity); - SceneGroudonMovement(groudonEntity); - DisplayDungeonDialogue(&gGroudonPostStoryPreFightDialogue_2); - PlaySoundEffect(0x1f6); - GroudonScreenFlash(); - DisplayDungeonDialogue(&gGroudonPostStoryPreFightDialogue_3); - PlaySoundEffect(0x1f6); - GroudonScreenFlash(); - DisplayDungeonDialogue(&gGroudonPostStoryPreFightDialogue_4); - sub_803E708(10,0x46); - SetupBossFightHP(groudonEntity,500,MUS_BOSS_BATTLE); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); - } -} - -// Moves Groudon down in a walking fashion -void SceneGroudonMovement(Entity * groudonEntity) -{ - int iVar1; - - sub_8086848(0x18,0x10); - sub_806CDD4(groudonEntity,0,DIRECTION_SOUTH); - for(iVar1 = 0; iVar1 < 0x2C; iVar1++) - { - if ((iVar1 == 10) || (iVar1 == 0x20)) { - PlaySoundEffect(0x1f9); - sub_8086838(0,1,0); - sub_808680C(); - } - if ((iVar1 - 10U < 0xc) || (iVar1 > 0x1f)) { - IncreaseEntityPixelPos(groudonEntity,0,0x100); - } - DungeonRunFrameActions(0x46); - } - sub_80856C8(groudonEntity,groudonEntity->pos.x,groudonEntity->pos.y + 1); - sub_80861D4(groudonEntity,0xf,DIRECTION_SOUTH); - sub_803E708(10,0x46); - sub_808682C(); - sub_8085930(DIRECTION_NORTH); - sub_803E708(0x22,0x46); -} - -void GroudonScreenFlash(void) -{ - s32 iVar1; - - for(iVar1 = 250; iVar1 > 0x95; iVar1 -= 10) - { - SetDungeonBGColorRGB(iVar1,iVar1 / 2,iVar1 / 2,1,1); - DungeonRunFrameActions(0x46); - } - sub_803E708(10,0x46); - - for(iVar1 = 250; iVar1 > 199; iVar1 -= 10) - { - SetDungeonBGColorRGB(iVar1,iVar1 / 2,0,1,1); - DungeonRunFrameActions(0x46); - } - sub_803E708(10,0x46); - - for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10) - { - SetDungeonBGColorRGB(iVar1,iVar1 / 2,iVar1 / 2,1,1); - DungeonRunFrameActions(0x46); - } - sub_803E708(10,0x46); - sub_8085EB0(); -} - -void GroudonScreenFlash2(void) -{ - s32 iVar1; - - for(iVar1 = 250; iVar1 > 0x95; iVar1 -= 10) - { - SetDungeonBGColorRGB(iVar1,iVar1 / 2,iVar1 / 2,1,1); - DungeonRunFrameActions(0x46); - } - sub_803E708(10,0x46); - - for(iVar1 = 250; iVar1 > 199; iVar1 -= 10) - { - SetDungeonBGColorRGB(iVar1,iVar1 / 2,0,1,1); - DungeonRunFrameActions(0x46); - } - sub_803E708(10,0x46); - - for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10) - { - SetDungeonBGColorRGB(iVar1,iVar1 / 2,iVar1 / 2,1,1); - DungeonRunFrameActions(0x46); - } - sub_803E708(10,0x46); - sub_8085EB0(); -} - - -void sub_8088DC0(void) -{ - Entity * leaderEntity; - Entity * groudonEntity; - Entity * alakazamEntity; - - leaderEntity = xxx_call_GetLeader(); - groudonEntity = GetEntityFromMonsterBehavior(BEHAVIOR_GROUDON_1); - alakazamEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ALAKAZAM_2); - sub_80867F4(); - sub_8086838(0,1,0); - sub_8085374(); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - sub_80855E4(sub_8086A3C); - sub_8086A3C(groudonEntity); - sub_806CDD4(groudonEntity,0xe,DIRECTION_SOUTH); - sub_8086A3C(alakazamEntity); - sub_806CDD4(alakazamEntity,0xe,DIRECTION_SOUTH); - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 3); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_GROUDON); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[3], MONSTER_ALAKAZAM); -} - -void sub_8088E5C(void) -{ - Entity * leaderEntity; - Entity * groudonEntity; - Entity * alakazamEntity; - - leaderEntity = xxx_call_GetLeader(); - groudonEntity = GetEntityFromMonsterBehavior(BEHAVIOR_GROUDON_1); - alakazamEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ALAKAZAM_2); - sub_80867F4(); - sub_8086838(0,1,0); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - sub_80855E4(sub_8086A3C); - sub_8068FE0(groudonEntity,0x21c,0); - sub_8068FE0(alakazamEntity,0x21c,0); - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y + -3); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_GROUDON); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[3], MONSTER_ALAKAZAM); -} - -void sub_8088EE8(void) -{ - sub_8086854(); -} - - -void MagmaCavernMidDialogue(void) -{ - Entity * leaderEntity; - Entity * partnerEntity; - Entity * groudonEntity; - Entity * alakazamEntity; - s16 IDStack [2]; - PixelPos pos; - - leaderEntity = xxx_call_GetLeader(); - partnerEntity = GetPartnerEntity(); - groudonEntity = GetEntityFromMonsterBehavior(BEHAVIOR_GROUDON_1); - alakazamEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ALAKAZAM_2); - sub_8052D44(IDStack,leaderEntity,partnerEntity); - sub_8086448(); - SpriteLookAroundEffect(partnerEntity); - // Let's see.. - // I wonder where we are? - DisplayDungeonDialogue(&MagmaCavernMidDialogue_1); - sub_803E708(10,0x46); - sub_80869E4(partnerEntity,4,1,DIRECTION_EAST); - sub_80869E4(leaderEntity,4,2,DIRECTION_WEST); - // I know we've come pretty - // far... - // - // I'm certain we've come quite - // far already.. - DisplayDungeonDialogue(MagmaCavernMidDialogue_2); - sub_803E708(10,0x46); - DungeonStopBGM(); - sub_80855E4(sub_80868F4); - sub_808680C(); - PlaySoundEffect(0x1c5); - sub_803E708(0x28,0x46); - // Waaah! - // Qu-quake! - DisplayDungeonDialogue(&MagmaCavernMidDialogue_3); - sub_803E708(0x78,0x46); - StopSoundEffect(0x1c5); - sub_808682C(); - sub_80855E4(sub_8086910); - sub_803E708(0x14,0x46); - sub_8085930(DIRECTION_NORTH); - sub_803E708(10,0x46); - // Whew! - // It settled down. - // - // Whew - // It's over. - DisplayDungeonDialogue(MagmaCavernMidDialogue_4); - sub_803E708(10,0x46); - PlaySoundEffect(0x1d5); - SpriteLookAroundEffect(partnerEntity); - PlaySoundEffect(0x1c7); - sub_80856E0(partnerEntity, DIRECTION_NORTH); - // Hey! {POKEMON_0}! - // Over there! - DisplayDungeonDialogue(&MagmaCavernMidDialogue_5); - GetEntInfo(groudonEntity)->unk15E = 0; - GetEntInfo(alakazamEntity)->unk15E =0; - pos.x = (groudonEntity->pixelPos.x + alakazamEntity->pixelPos.x) / 2; - pos.y = (groudonEntity->pixelPos.y + alakazamEntity->pixelPos.y) / 2 + 0x800; - ShiftCameraToPosition(&pos,0x20); - sub_803E708(0x3c,0x46); - sub_80891F0(); - // Hey! - // Are you OK?! - // - // Hey! - // Snap out of it! - DisplayDungeonDialogue(MagmaCavernMidDialogue_6); - sub_803E708(10,0x46); - // Urrrrgh... - DisplayDungeonDialogue(&MagmaCavernMidDialogue_7); - sub_803E708(10,0x46); - sub_80869E4(leaderEntity,4,2,DIRECTION_NORTHWEST); - // What happened to you? - // - // What happened here? - DisplayDungeonDialogue(MagmaCavernMidDialogue_8); - sub_803E708(10,0x46); - // We challenged.. - // {POKEMON_2}... - // And wiped out.. - DisplayDungeonDialogue(&MagmaCavernMidDialogue_9); - sub_803E708(10,0x46); - DisplayDungeonDialogue(&MagmaCavernMidDialogue_10); - sub_803E708(10,0x46); - sub_80869E4(leaderEntity,4,1,DIRECTION_NORTHEAST); - sub_80869E4(partnerEntity,4,1,DIRECTION_NORTHEAST); - // Grrgh.. - // We... It crushed us - DisplayDungeonDialogue(&MagmaCavernMidDialogue_11); - sub_803E708(10,0x46); - PlaySoundEffect(0x1d5); - SpriteLookAroundEffect(partnerEntity); - // That's right... - // What happened to {POKEMON_3}? - // Where is {POKEMON_3}? - // - // Wait... - // What about {POKEMON_3}? - // Where did {POKEMON_3} go? - DisplayDungeonDialogue(MagmaCavernMidDialogue_12); - sub_803E708(0x1e,0x46); - // {POKEMON_3} is... - // Still battling {POKEMON_2}... - DisplayDungeonDialogue(&MagmaCavernMidDialogue_13); - sub_803E708(10,0x46); - sub_80869E4(partnerEntity,4,1,DIRECTION_EAST); - sub_80869E4(leaderEntity,4,2,DIRECTION_WEST); - - // {POKEMON_0}! - // We've got to hurry! - DisplayDungeonDialogue(&MagmaCavernMidDialogue_14); - sub_8089294(); - // Be careful! - DisplayDungeonDialogue(&MagmaCavernMidDialogue_15); - sub_803E708(10,0x46); - gDungeon->unk2 = 1; -} - -void sub_8089168(void) -{ - Entity *leaderEntity; - - leaderEntity = xxx_call_GetLeader(); - sub_8086448(); - sub_803E708(10,0x46); - SpriteLookAroundEffect(leaderEntity); - sub_803E708(10,0x46); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); -} - -void sub_808919C(Entity *r0) -{ - IncreaseEntityPixelPos(r0, 0, 0xfffffe00); -} - -void sub_80891B0(Entity *r0) -{ - sub_806CDD4(r0, 0, DIRECTION_NORTH); - GetEntInfo(r0)->unk15F = 1; -} - - -void sub_80891D0(Entity *r0) -{ - sub_806CDD4(r0, 7, DIRECTION_NORTH); - GetEntInfo(r0)->unk15F = 0; -} - -void sub_80891F0(void) -{ - s32 iVar1; - - sub_80855E4(sub_80891B0); - for(iVar1 = 0; iVar1 < 0x30; iVar1++) - { - sub_80855E4(sub_808919C); - DungeonRunFrameActions(0x46); - } - sub_80855E4(sub_80891D0); -} - -void sub_8089224(Entity * entity) -{ - s32 xPixelPos; - - if (entity->pixelPos.y < 0x9001) { - return; - } - xPixelPos = entity->pixelPos.x; - - if(xPixelPos < 0xE400) - { - if(xPixelPos <= 0xB400) - { - // 0 - 0xB400 - IncreaseEntityPixelPos(entity, 0, 0xfffffe00); - } - else - { - // 0xB401 - 0xE3FF - IncreaseEntityPixelPos(entity, 0xfffffe00, 0); - } - } - else - { - if(xPixelPos < 0xFC00) - { - IncreaseEntityPixelPos(entity, 0, 0xfffffe00); - } - else - { - if(xPixelPos <= 0x11400) - { - IncreaseEntityPixelPos(entity, 0x200, 0); - } - else - { - IncreaseEntityPixelPos(entity, 0, 0xfffffe00); - } - } - } -} - -void sub_8089294(void) -{ - s32 iVar1; - - sub_80855E4(sub_80891B0); - for(iVar1 = 0; iVar1 <= 0x77; iVar1++) - { - sub_80855E4(sub_8089224); - DungeonRunFrameActions(0x46); - } - sub_80855E4(sub_80891D0); -} - -void sub_80892C8(void) -{ - Entity * leaderEntity; - Entity * RayquazaEntity; - - leaderEntity = xxx_call_GetLeader(); - RayquazaEntity = GetEntityFromMonsterBehavior(BEHAVIOR_RAYQUAZA); - DungeonStartNewBGM(MUS_RAYQUAZAS_DOMAIN); - sub_8085374(); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - sub_80855E4(sub_8086A3C); - SetFacingDirection(RayquazaEntity, DIRECTION_SOUTH); - sub_8086A3C(RayquazaEntity); - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 3); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2],MONSTER_RAYQUAZA); -} - -void sub_8089328(void) -{ - Entity * leaderEntity; - Entity * rayquazaEntity; - - leaderEntity = xxx_call_GetLeader(); - rayquazaEntity = GetEntityFromMonsterBehavior(BEHAVIOR_RAYQUAZA); - DungeonStartNewBGM(MUS_RAYQUAZAS_DOMAIN); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - sub_80855E4(sub_8086A3C); - if (sub_8086AE4(MONSTER_RAYQUAZA)) { - sub_8068FE0(rayquazaEntity,0x21c,0); - } - else { - sub_8072008(rayquazaEntity,rayquazaEntity,gRayquazaConfigLevel,0,0); - sub_8086A3C(rayquazaEntity); - } - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 3); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2],MONSTER_RAYQUAZA); -} - -void sub_80893B4(u8 param_1, u8 param_2) -{ - if ((param_2 == 0x17 || param_2 == 0x18 || param_2 == 0x19) && (param_1 == 0xF)) { - sub_8097FA8(0xF); - gDungeon->unk2 = 1; - } -} - -void RayquazaPreFightDialogue(void) -{ - Entity *leaderEntity; - Entity *partnerEntity; - Entity *rayquazaEntity; - - leaderEntity = xxx_call_GetLeader(); - partnerEntity = GetPartnerEntity(); - rayquazaEntity = GetEntityFromMonsterBehavior(BEHAVIOR_RAYQUAZA); - sub_8086448(); - DisplayDungeonDialogue(&gRayquazaPreFightDialogue_1); - RayquazaScreenFlash(); - DisplayDungeonDialogue(&gRayquazaPreFightDialogue_2); - sub_80856E0(partnerEntity, DIRECTION_NORTH); - SpriteLookAroundEffect(partnerEntity); - sub_803E708(10,0x46); - sub_80869E4(partnerEntity,4,1,DIRECTION_EAST); - sub_80869E4(leaderEntity,4,2,DIRECTION_WEST); - DisplayDungeonDialogue(gRayquazaPreFightDialogue_3); - sub_80869E4(partnerEntity,4,2,DIRECTION_NORTH); - sub_80869E4(leaderEntity,4,1,DIRECTION_NORTH); - DisplayDungeonDialogue(&gRayquazaPreFightDialogue_4); - sub_803E708(10,0x46); - DisplayDungeonDialogue(&gRayquazaPreFightDialogue_5); - sub_803E708(10,0x46); - DisplayDungeonDialogue(&gRayquazaPreFightDialogue_6); - RayquazaScreenFlash(); - PlaySoundEffect(0x1da); // Rayquaza Cry - DisplayDungeonDialogue(&gRayquazaPreFightDialogue_7); - RayquazaDropInEffect(rayquazaEntity); - DisplayDungeonDialogue(&gRayquazaPreFightDialogue_8); - RayquazaScreenFlash(); - DisplayDungeonDialogue(&gRayquazaPreFightDialogue_9); - RayquazaScreenFlash(); - DisplayDungeonDialogue(&gRayquazaPreFightDialogue_10); - RayquazaScreenFlash(); - DisplayDungeonDialogue(&gRayquazaPreFightDialogue_11); - SetupBossFightHP(rayquazaEntity,600,MUS_BATTLE_WITH_RAYQUAZA); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); -} - -void RayquazaReFightDialogue(void) -{ - Entity *leaderEntity; - Entity *rayquazaEntity; - - leaderEntity = xxx_call_GetLeader(); - rayquazaEntity = GetEntityFromMonsterBehavior(BEHAVIOR_RAYQUAZA); - sub_8086448(); - RayquazaScreenFlash(); - PlaySoundEffect(0x1da); // Rayquaza Cry - DisplayDungeonDialogue(&gRayquazaPreFightDialogue_7); - sub_803E708(10,0x46); - RayquazaDropInEffect(rayquazaEntity); - DisplayDungeonDialogue(&gRayquazaReFightDialogue_1); - RayquazaScreenFlash(); - DisplayDungeonDialogue(&gRayquazaReFightDialogue_2); - RayquazaScreenFlash(); - DisplayDungeonDialogue(&gRayquazaReFightDialogue_3); - RayquazaScreenFlash(); - DisplayDungeonDialogue(&gRayquazaReFightDialogue_4); - SetupBossFightHP(rayquazaEntity,600,MUS_BATTLE_WITH_RAYQUAZA); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); -} - -void RayquazaPostStoryPreFightDialogue(void) -{ - Entity *leaderEntity; - Entity *rayquazaEntity; - - leaderEntity = xxx_call_GetLeader(); - rayquazaEntity = GetEntityFromMonsterBehavior(BEHAVIOR_RAYQUAZA); - sub_8086448(); - if (sub_8086AE4(MONSTER_RAYQUAZA)) { - sub_80866C4(&gRayquazaPostStoryPreFightDialogue_6); - } - else { - PlaySoundEffect(0x1da); // Rayquaza Cry - DisplayDungeonDialogue(&gRayquazaPostStoryPreFightDialogue_1); - RayquazaDropInEffect(rayquazaEntity); - DisplayDungeonDialogue(&gRayquazaPostStoryPreFightDialogue_2); - RayquazaScreenFlash(); - DisplayDungeonDialogue(&gRayquazaPostStoryPreFightDialogue_3); - RayquazaScreenFlash(); - DisplayDungeonDialogue(&gRayquazaPostStoryPreFightDialogue_4); - RayquazaScreenFlash(); - DisplayDungeonDialogue(&gRayquazaPostStoryPreFightDialogue_5); - SetupBossFightHP(rayquazaEntity,600,MUS_BOSS_BATTLE); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); - } -} - -void RayquazaDropInEffect(Entity *rayquazaEntity) -{ - s24_8 iVar1; - s24_8 iVar2; - - GetEntInfo(rayquazaEntity)->unk15E = 0; - iVar2 = IntToF248_2(200); - iVar1 = IntToF248_2(6); - PlaySoundEffect(0x1f8); - while( 1 ) { - iVar2.raw = iVar2.raw - iVar1.raw; // must be .raw - iVar1 = F248_Sub(iVar1, FloatToF248_2(3./32.)); - if (F248LessThanFloat(iVar1, 0.08)) { - iVar1 = FloatToF248(0.08); - } - if (F248LessThanInt(iVar2, 0)) break; - GetEntInfo(rayquazaEntity)->unk174 = iVar2; - DungeonRunFrameActions(0x46); - } - GetEntInfo(rayquazaEntity)->unk174 = IntToF248_2(0); -} - -void RayquazaScreenFlash(void) -{ - s32 iVar1; - - PlaySoundEffect(0x1f6); - for(iVar1 = 250; iVar1 > 149; iVar1 -= 10) - { - SetDungeonBGColorRGB(iVar1 / 2, iVar1, iVar1 / 2, 1, 1); - DungeonRunFrameActions(70); - } - sub_803E708(10,70); - for(iVar1 = 250; iVar1 > 199; iVar1 -= 10) - { - SetDungeonBGColorRGB(iVar1 / 2, iVar1, 0, 1, 1); - DungeonRunFrameActions(70); - } - sub_803E708(10,70); - for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10) - { - SetDungeonBGColorRGB(iVar1 / 2, iVar1, iVar1 / 2, 1, 1); - DungeonRunFrameActions(70); - } - sub_803E708(10,70); - sub_8085EB0(); -} - - -void sub_808970C(void) -{ - Entity *leaderEntity; - - leaderEntity = xxx_call_GetLeader(); - DungeonStartNewBGM(MUS_TINY_WOODS); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - sub_80855E4(sub_8086A3C); - sub_808563C(sub_8089908); - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y + -3); -} - -void sub_808974C(void) -{ - Entity *leaderEntity; - - leaderEntity = xxx_call_GetLeader(); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - sub_80855E4(sub_8086A3C); - sub_808563C(sub_80898F8); - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y + -3); -} - -void sub_8089788(Entity *entity, u8 param_2, u8 param_3) -{ - Entity *monEntity; - s32 index; - u32 unk1; - - unk1 = 0; - - if (param_3 == 0x1A || param_3 == 0x1B) { - for(index = 0; index < DUNGEON_MAX_WILD_POKEMON; index++) - { - monEntity = gDungeon->wildPokemon[index]; - if ((EntityIsValid(monEntity)) && (monEntity != entity) && (GetEntInfo(monEntity)->monsterBehavior == param_2)) { - return; - } - } - // WTF is this?? - if(!unk1){ - sub_8097FA8(0x11); - gDungeon->unk2 = 1; - } - } -} - -void sub_80897F0(void) -{ - Entity *leaderEntity; - - leaderEntity = xxx_call_GetLeader(); - sub_8086448(); - sub_803E708(10,0x46); - sub_808563C(SpriteShockEffect); - sub_803E708(0x20,0x46); - sub_808692C(); - DisplayDungeonDialogue(&gUnknown_8103BD8); - // We don't like to brag or - // nothing, but - DisplayDungeonDialogue(&gUnknown_8103C00); - // We get furious real easy - // You know that?! - DisplayDungeonDialogue(&gUnknown_8103C3C); - // What really irritates us is - // when we see some dim witted face - DisplayDungeonDialogue(&gUnknown_8103C74); - // ......... - // Wrooooooar! - // That vacant expression - DisplayDungeonDialogue(&gUnknown_8103CC4); - // Gwoooh - // It's ticking me off! - // I'm seeing red! - DisplayDungeonDialogue(&gUnknown_8103D0C); - // Mukkkeeeeeh - // Get 'em! It's frenzy time! - DisplayDungeonDialogue(&gUnknown_8103D50); - sub_803E708(10,0x46); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); -} - - - -void sub_8089878(void) -{ - Entity *leaderEntity; - - leaderEntity = xxx_call_GetLeader(); - sub_8086448(); - sub_803E708(10,0x46); - sub_808563C(SpriteShockEffect); - sub_803E708(0x20,0x46); - sub_808692C(); - DisplayDungeonDialogue(&gUnknown_8103D8C); - DisplayDungeonDialogue(&gUnknown_8103D98); - DisplayDungeonDialogue(&gUnknown_8103DD8); - DisplayDungeonDialogue(&gUnknown_8103E28); - sub_803E708(10,0x46); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); -} - -void sub_80898E4(void) -{ - sub_8086448(); - sub_80866C4(&gUnknown_8103E34); -} - -void sub_80898F8(Entity *r0) -{ - sub_8068FE0(r0, 0x21C, 0); -} - -void sub_8089908(Entity *r0) -{ - SetFacingDirection(r0, DIRECTION_NORTH); -} - -void sub_8089914(void) -{ - Entity *leaderEntity; - Entity *MewtwoEntity; - - leaderEntity = xxx_call_GetLeader(); - MewtwoEntity = GetEntityFromMonsterBehavior(BEHAVIOR_MEWTWO); - DungeonStopBGM(); - gDungeon->unk7 = 1; - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - sub_80855E4(sub_8086A3C); - SetFacingDirection(MewtwoEntity, DIRECTION_SOUTH); - sub_8086A3C(MewtwoEntity); - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 3); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2],MONSTER_MEWTWO); -} - -void sub_8089978(void) -{ - Entity *leaderEntity; - Entity *MewtwoEntity; - - leaderEntity = xxx_call_GetLeader(); - MewtwoEntity = GetEntityFromMonsterBehavior(BEHAVIOR_MEWTWO); - DungeonStopBGM(); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - sub_80855E4(sub_8086A3C); - if(HasRecruitedMon(MONSTER_MEWTWO)){ - DungeonStartNewBGM(MUS_FRIEND_AREA_CRYPTIC_CAVE); - sub_8068FE0(MewtwoEntity,0x21c,0); - } - else { - gDungeon->unk7 = 1; - SetFacingDirection(MewtwoEntity, DIRECTION_SOUTH); - sub_8086A3C(MewtwoEntity); - } - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 3); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2],MONSTER_MEWTWO); -} - -void sub_8089A00(u8 param_1, u8 param_2) -{ - if ((param_2 == 0x1d || param_2 == 0x1e || param_2 == 0x1f) && (param_1 == 0x11)) { - sub_8097FA8(0x13); - gDungeon->unk2 = 1; - } -} - -void MewtwoPreFightDialogue(void) -{ - Entity *leaderEntity; - Entity *MewtwoEntity; - - leaderEntity = xxx_call_GetLeader(); - MewtwoEntity = GetEntityFromMonsterBehavior(BEHAVIOR_MEWTWO); - sub_8086448(); - DisplayDungeonDialogue(&gMewtwoPreFightDialogue_1); - sub_803E708(10,0x46); - DungeonStartNewBGM(MUS_FRIEND_AREA_CRYPTIC_CAVE); - sub_8086794(); - sub_803E708(0x1e,0x46); - MewtwoDropInEffect(MewtwoEntity); - sub_803E708(0x3c,0x46); - DisplayDungeonDialogue(&gMewtwoPreFightDialogue_2); - DisplayDungeonDialogue(&gMewtwoPreFightDialogue_3); - sub_803E708(10,0x46); - MewtwoScreenFlash(); - DisplayDungeonDialogue(&gMewtwoPreFightDialogue_4); - MewtwoScreenFlash(); - DisplayDungeonDialogue(&gMewtwoPreFightDialogue_5); - sub_803E708(10,0x46); - SetupBossFightHP(MewtwoEntity,900,MUS_BATTLE_WITH_RAYQUAZA); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); -} - -void MewtwoReFightDialogue(void) -{ - Entity *leaderEntity; - Entity *MewtwoEntity; - - leaderEntity = xxx_call_GetLeader(); - MewtwoEntity = GetEntityFromMonsterBehavior(BEHAVIOR_MEWTWO); - sub_8086448(); - if(HasRecruitedMon(MONSTER_MEWTWO)) { - sub_80866C4(&gMewtwoReFightDialogue_5); - } - else { - DisplayDungeonDialogue(&gMewtwoReFightDialogue_1); - DungeonStartNewBGM(MUS_FRIEND_AREA_CRYPTIC_CAVE); - sub_8086794(); - MewtwoDropInEffect(MewtwoEntity); - sub_803E708(0x3c,0x46); - DisplayDungeonDialogue(&gMewtwoReFightDialogue_2); - MewtwoScreenFlash(); - DisplayDungeonDialogue(&gMewtwoReFightDialogue_3); - MewtwoScreenFlash(); - DisplayDungeonDialogue(&gMewtwoReFightDialogue_4); - SetupBossFightHP(MewtwoEntity,900,MUS_BATTLE_WITH_RAYQUAZA); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); - } -} - -void MewtwoDropInEffect(Entity *mewtwoEntity) -{ - s24_8 iVar1; - s24_8 iVar2; - - GetEntInfo(mewtwoEntity)->unk15E = 0; - iVar2 = IntToF248_2(200); - iVar1 = IntToF248_2(4); - PlaySoundEffect(0x1f8); - while( 1 ) { - iVar2.raw -= iVar1.raw; - iVar1 = F248_Sub(iVar1, FloatToF248_2(0.045)); - if (F248LessThanFloat(iVar1, 0.12)) { - iVar1 = FloatToF248_2(0.12); - } - if (F248LessThanInt(iVar2, 0)) break; - GetEntInfo(mewtwoEntity)->unk174 = iVar2; - DungeonRunFrameActions(0x46); - } - GetEntInfo(mewtwoEntity)->unk174 = IntToF248_2(0); -} - -void MewtwoScreenFlash(void) -{ - int iVar1; - - PlaySoundEffect(0x1f6); - for(iVar1 = 250; iVar1 > 149; iVar1 -= 10) - { - SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,1); - DungeonRunFrameActions(0x46); - } - sub_803E708(10,0x46); - for(iVar1 = 250; iVar1 > 199; iVar1 -= 10) - { - SetDungeonBGColorRGB(iVar1,iVar1,0,1,1); - DungeonRunFrameActions(0x46); - } - sub_803E708(10,0x46); - for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10) - { - SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,1); - DungeonRunFrameActions(0x46); - } - sub_803E708(10,0x46); - sub_8085EB0(); -} - -void sub_8089C44(void) -{ - Entity * leaderEntity; - Entity * EnteiEntity; - - leaderEntity = xxx_call_GetLeader(); - EnteiEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ENTEI); - DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - SetFacingDirection(EnteiEntity, DIRECTION_SOUTH); - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_ENTEI); -} - - -void sub_8089C90(void) -{ - Entity * leaderEntity; - Entity * EnteiEntity; - - leaderEntity = xxx_call_GetLeader(); - EnteiEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ENTEI); - DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - if (HasRecruitedMon(MONSTER_ENTEI)) { - sub_8068FE0(EnteiEntity,0x21c,0); - } - else { - SetFacingDirection(EnteiEntity, DIRECTION_SOUTH); - } - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_ENTEI); -} - -void sub_8089CFC(u8 param_1, u8 param_2) -{ - if ((param_2 == 0x20 || param_2 == 0x21 || param_2 == 0x22) && (param_1 == 0x12)) { - sub_8097FA8(0x15); - gDungeon->unk2 = 1; - } -} - -void EnteiPreFightDialogue(void) -{ - Entity * leaderEntity; - Entity * EnteiEntity; - - leaderEntity = xxx_call_GetLeader(); - EnteiEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ENTEI); - EnteiScreenFlash(); - DisplayDungeonDialogue(&gEnteiPreFightDialogue_1); - EnteiScreenFlash(); - DisplayDungeonDialogue(&gEnteiPreFightDialogue_2); - EnteiScreenFlash(); - DisplayDungeonDialogue(&gEnteiPreFightDialogue_3); - sub_803E708(10,70); - SetupBossFightHP(EnteiEntity,600,MUS_BOSS_BATTLE); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); -} - -void EnteiReFightDialogue(void) -{ - Entity * leaderEntity; - Entity * EnteiEntity; - - leaderEntity = xxx_call_GetLeader(); - EnteiEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ENTEI); - EnteiScreenFlash(); - DisplayDungeonDialogue(&gEnteiReFightDialogue_1); - EnteiScreenFlash(); - DisplayDungeonDialogue(&gEnteiReFightDialogue_2); - EnteiScreenFlash(); - DisplayDungeonDialogue(&gEnteiReFightDialogue_3); - sub_803E708(10,70); - SetupBossFightHP(EnteiEntity,600,MUS_BOSS_BATTLE); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); -} - -void EnteiPostStoryPreFightDialogue(void) -{ - Entity * leaderEntity; - Entity * EnteiEntity; - - leaderEntity = xxx_call_GetLeader(); - EnteiEntity = GetEntityFromMonsterBehavior(BEHAVIOR_ENTEI); - if (HasRecruitedMon(MONSTER_ENTEI)) { - sub_80866C4(&gEnteiPostStoryPreFightDialogue_4); - } - else { - EnteiScreenFlash(); - DisplayDungeonDialogue(&gEnteiPostStoryPreFightDialogue_1); - EnteiScreenFlash(); - DisplayDungeonDialogue(&gEnteiPostStoryPreFightDialogue_2); - EnteiScreenFlash(); - DisplayDungeonDialogue(&gEnteiPostStoryPreFightDialogue_3); - sub_803E708(10,70); - SetupBossFightHP(EnteiEntity,600,MUS_BOSS_BATTLE); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); - } -} - -void EnteiScreenFlash(void) -{ - s32 iVar1; - - PlaySoundEffect(0x1ed); - for(iVar1 = 250; iVar1 > 149; iVar1 -= 10) - { - SetDungeonBGColorRGB(iVar1, iVar1 / 2, iVar1 / 2, 1, 1); - DungeonRunFrameActions(70); - } - sub_803E708(10,70); - for(iVar1 = 250; iVar1 > 199; iVar1 -= 10) - { - SetDungeonBGColorRGB(iVar1, 0, 0, 1, 1); - DungeonRunFrameActions(70); - } - sub_803E708(10,70); - for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10) - { - SetDungeonBGColorRGB(iVar1, iVar1 / 2, iVar1 / 2, 1, 1); - DungeonRunFrameActions(70); - } - sub_803E708(10,70); - sub_8085EB0(); -} - -void sub_8089EFC(void) -{ - Entity * leaderEntity; - Entity * RaikouEntity; - - leaderEntity = xxx_call_GetLeader(); - RaikouEntity = GetEntityFromMonsterBehavior(BEHAVIOR_RAIKOU); - DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - SetFacingDirection(RaikouEntity, DIRECTION_SOUTH); - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_RAIKOU); -} - - -void sub_8089F44(void) -{ - Entity * leaderEntity; - Entity * RaikouEntity; - - leaderEntity = xxx_call_GetLeader(); - RaikouEntity = GetEntityFromMonsterBehavior(BEHAVIOR_RAIKOU); - DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - SetFacingDirection(RaikouEntity, DIRECTION_SOUTH); - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_RAIKOU); -} - - -void sub_8089F8C(void) -{ - Entity * leaderEntity; - Entity * RaikouEntity; - - leaderEntity = xxx_call_GetLeader(); - RaikouEntity = GetEntityFromMonsterBehavior(BEHAVIOR_RAIKOU); - DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - if (HasRecruitedMon(MONSTER_RAIKOU)) { - sub_8068FE0(RaikouEntity,0x21c,0); - } - else { - SetFacingDirection(RaikouEntity, DIRECTION_SOUTH); - } - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_RAIKOU); -} - -void sub_8089FF0(u8 param_1, u8 param_2) -{ - if ((param_2 == 0x23 || param_2 == 0x24 || param_2 == 0x25) && (param_1 == 0x13)) { - sub_8097FA8(0x17); - gDungeon->unk2 = 1; - } -} - -void RaikouPreFightDialogue(void) -{ - Entity * leaderEntity; - Entity * RaikouEntity; - - leaderEntity = xxx_call_GetLeader(); - RaikouEntity = GetEntityFromMonsterBehavior(BEHAVIOR_RAIKOU); - DisplayDungeonDialogue(&gRaikouPreFightDialogue_1); - RaikouScreenFlash(); - DisplayDungeonDialogue(&gRaikouPreFightDialogue_2); - gDungeon->weather.unkE265 = WEATHER_RAIN; - sub_807EAA0(0,1); - sub_803E708(10,70); - DisplayDungeonDialogue(&gRaikouPreFightDialogue_3); - RaikouScreenFlash(); - DisplayDungeonDialogue(&gRaikouPreFightDialogue_4); - RaikouScreenFlash(); - DisplayDungeonDialogue(&gRaikouPreFightDialogue_5); - RaikouScreenFlash(); - DisplayDungeonDialogue(&gRaikouPreFightDialogue_6); - sub_803E708(10,70); - SetupBossFightHP(RaikouEntity,0x28a,MUS_BOSS_BATTLE); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); -} - -void RaikouReFightDialogue(void) -{ - Entity * leaderEntity; - Entity * RaikouEntity; - - leaderEntity = xxx_call_GetLeader(); - RaikouEntity = GetEntityFromMonsterBehavior(BEHAVIOR_RAIKOU); - gDungeon->weather.unkE265 = WEATHER_RAIN; - sub_807EAA0(0,1); - RaikouScreenFlash(); - DisplayDungeonDialogue(&gRaikouReFightDialogue_1); - RaikouScreenFlash(); - DisplayDungeonDialogue(&gRaikouReFightDialogue_2); - RaikouScreenFlash(); - DisplayDungeonDialogue(&gRaikouReFightDialogue_3); - sub_803E708(10,70); - SetupBossFightHP(RaikouEntity,0x28a,MUS_BOSS_BATTLE); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); -} - -void RaikouPostStoryPreFightDialogue(void) -{ - Entity * leaderEntity; - Entity * RaikouEntity; - - leaderEntity = xxx_call_GetLeader(); - RaikouEntity = GetEntityFromMonsterBehavior(BEHAVIOR_RAIKOU); - if (HasRecruitedMon(MONSTER_RAIKOU)) { - sub_80866C4(&gRaikouPostStoryPreFightDialogue_4); - } - else { - gDungeon->weather.unkE265 = WEATHER_RAIN; - sub_807EAA0(0,1); - DisplayDungeonDialogue(&gRaikouPostStoryPreFightDialogue_1); - RaikouScreenFlash(); - DisplayDungeonDialogue(&gRaikouPostStoryPreFightDialogue_2); - RaikouScreenFlash(); - DisplayDungeonDialogue(&gRaikouPostStoryPreFightDialogue_3); - sub_803E708(10,70); - SetupBossFightHP(RaikouEntity,0x28a,MUS_BOSS_BATTLE); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); - } -} - -void RaikouScreenFlash(void) -{ - s32 iVar1; - - PlaySoundEffect(0x1f6); - for(iVar1 = 250; iVar1 > 149; iVar1 -= 10) - { - SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,1); - DungeonRunFrameActions(70); - } - sub_803E708(10,70); - for(iVar1 = 250; iVar1 > 199; iVar1 -= 10) - { - SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,1); - DungeonRunFrameActions(70); - } - sub_803E708(10,70); - for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10) - { - SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,1); - DungeonRunFrameActions(70); - } - sub_803E708(10,70); - sub_8085EB0(); -} - -void sub_808A264(void) -{ - Entity * leaderEntity; - Entity * SuicuneEntity; - - leaderEntity = xxx_call_GetLeader(); - SuicuneEntity = GetEntityFromMonsterBehavior(BEHAVIOR_SUICUNE); - DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - sub_80855E4(sub_8086A3C); - SetFacingDirection(SuicuneEntity, DIRECTION_SOUTH); - sub_8086A3C(SuicuneEntity); - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 3); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_SUICUNE); -} - -void sub_808A2C0(void) -{ - Entity * leaderEntity; - Entity * SuicuneEntity; - - leaderEntity = xxx_call_GetLeader(); - SuicuneEntity = GetEntityFromMonsterBehavior(BEHAVIOR_SUICUNE); - DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - SetFacingDirection(SuicuneEntity, DIRECTION_SOUTH); - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_SUICUNE); -} - -void sub_808A308(void) -{ - Entity * leaderEntity; - Entity * SuicuneEntity; - - leaderEntity = xxx_call_GetLeader(); - SuicuneEntity = GetEntityFromMonsterBehavior(BEHAVIOR_SUICUNE); - DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - if (HasRecruitedMon(MONSTER_SUICUNE)) { - sub_8068FE0(SuicuneEntity,0x21c,0); - } - else { - SetFacingDirection(SuicuneEntity, DIRECTION_SOUTH); - } - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_SUICUNE); -} - -void sub_808A36C(u8 param_1, u8 param_2) -{ - if ((param_2 == 0x26 || param_2 == 0x27 || param_2 == 0x28) && (param_1 == 0x14)) { - sub_8097FA8(0x19); - gDungeon->unk2 = 1; - } -} - -void SuicunePreFightDialogue(void) -{ - Entity * leaderEntity; - Entity * SuicuneEntity; - - leaderEntity = xxx_call_GetLeader(); - SuicuneEntity = GetEntityFromMonsterBehavior(BEHAVIOR_SUICUNE); - sub_8086448(); - DisplayDungeonDialogue(&gSuicunePreFightDialogue_1); - sub_803E708(10,70); - DisplayDungeonDialogue(&gSuicunePreFightDialogue_2); - sub_803E708(10,70); - sub_80426C8(1,2); - sub_803E708(0x3c,70); - DisplayDungeonDialogue(&gSuicunePreFightDialogue_3); - sub_803E708(10,70); - sub_808A528(SuicuneEntity); - DisplayDungeonDialogue(&gSuicunePreFightDialogue_4); - DisplayDungeonDialogue(&gSuicunePreFightDialogue_5); - SuicuneScreenFlash(); - DisplayDungeonDialogue(&gSuicunePreFightDialogue_6); - SuicuneScreenFlash(); - DisplayDungeonDialogue(&gSuicunePreFightDialogue_7); - sub_803E708(10,70); - SetupBossFightHP(SuicuneEntity,0x28a,MUS_BOSS_BATTLE); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); -} - -void SuicuneReFightDialogue(void) -{ - Entity * leaderEntity; - Entity * SuicuneEntity; - - leaderEntity = xxx_call_GetLeader(); - SuicuneEntity = GetEntityFromMonsterBehavior(BEHAVIOR_SUICUNE); - DisplayDungeonDialogue(&gSuicuneReFightDialogue_1); - SuicuneScreenFlash(); - DisplayDungeonDialogue(&gSuicuneReFightDialogue_2); - SuicuneScreenFlash(); - DisplayDungeonDialogue(&gSuicuneReFightDialogue_3); - sub_803E708(10,70); - SetupBossFightHP(SuicuneEntity,0x28a,MUS_BOSS_BATTLE); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); -} - -void SuicunePostStoryPreFightDialogue(void) -{ - Entity * leaderEntity; - Entity * SuicuneEntity; - - leaderEntity = xxx_call_GetLeader(); - SuicuneEntity = GetEntityFromMonsterBehavior(BEHAVIOR_SUICUNE); - if (HasRecruitedMon(MONSTER_SUICUNE)) { - sub_80866C4(&gSuicunePostStoryPreFightDialogue_4); - } - else { - DisplayDungeonDialogue(&gSuicunePostStoryPreFightDialogue_1); - SuicuneScreenFlash(); - DisplayDungeonDialogue(&gSuicunePostStoryPreFightDialogue_2); - SuicuneScreenFlash(); - DisplayDungeonDialogue(&gSuicunePostStoryPreFightDialogue_3); - sub_803E708(10,70); - SetupBossFightHP(SuicuneEntity,0x28a,MUS_BOSS_BATTLE); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); - } -} - -void sub_808A528(Entity * param_1) -{ - s24_8 iVar1; - s24_8 iVar2; - - GetEntInfo(param_1)->unk15E = 0; - iVar2 = IntToF248(200); - iVar1 = IntToF248(12); - PlaySoundEffect(0x1f8); - while( 1 ) { - iVar2.raw -= iVar1.raw; - iVar1 = F248_Sub(iVar1, FloatToF248(0.375)); - if (F248LessThanFloat(iVar1, 0.08)) { - iVar1 = FloatToF248_2(0.08); - } - if (F248LessThanInt(iVar2, 0)) break; - GetEntInfo(param_1)->unk174 = iVar2; - DungeonRunFrameActions(70); - } - GetEntInfo(param_1)->unk174 = IntToF248_2(0); -} - -void SuicuneScreenFlash(void) -{ - s32 iVar1; - - PlaySoundEffect(0x1ee); - for(iVar1 = 250; iVar1 > 149; iVar1 -= 10) - { - SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,1); - DungeonRunFrameActions(70); - } - sub_803E708(10,70); - for(iVar1 = 250; iVar1 > 199; iVar1 -= 10) - { - SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,1); - DungeonRunFrameActions(70); - } - sub_803E708(10,70); - for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10) - { - SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,1); - DungeonRunFrameActions(70); - } - sub_803E708(10,70); - sub_8085EB0(); -} - -void sub_808A608(void) -{ - Entity * leaderEntity; - Entity * HoOhEntity; - - leaderEntity = xxx_call_GetLeader(); - HoOhEntity = GetEntityFromMonsterBehavior(BEHAVIOR_HO_OH); - DungeonStartNewBGM(MUS_FRIEND_AREA_RAINBOW_PEAK); - sub_80867F4(); - sub_8086838(0,0,0); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - SetFacingDirection(HoOhEntity, DIRECTION_SOUTH); - sub_8086A3C(HoOhEntity); - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y + -6); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_HO_OH); -} - -void sub_808A668(void) -{ - Entity * leaderEntity; - Entity * HoOhEntity; - - leaderEntity = xxx_call_GetLeader(); - HoOhEntity = GetEntityFromMonsterBehavior(BEHAVIOR_HO_OH); - DungeonStartNewBGM(MUS_FRIEND_AREA_RAINBOW_PEAK); - sub_80867F4(); - sub_8086838(0,0,0); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - if (HasRecruitedMon(MONSTER_HO_OH)) { - sub_8068FE0(HoOhEntity,0x21c,0); - } - else { - SetFacingDirection(HoOhEntity, DIRECTION_SOUTH); - sub_8086A3C(HoOhEntity); - } - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 6); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_HO_OH); -} - -void sub_808A6E8(u8 param_1, u8 param_2) -{ - if ((param_2 == 0x29 || param_2 == 0x2A) && (param_1 == 0x15)) { - sub_8097FA8(0x1A); - gDungeon->unk2 = 1; - } -} - -void sub_808A718(void) -{ - sub_8086854(); -} - -void HoOhPreFightDialogue(void) -{ - Entity * leaderEntity; - Entity * HoOhEntity; - PixelPos local_14; - - leaderEntity = xxx_call_GetLeader(); - HoOhEntity = GetEntityFromMonsterBehavior(BEHAVIOR_HO_OH); - local_14.x = leaderEntity->pixelPos.x; - local_14.y = leaderEntity->pixelPos.y + -0x1000; - ShiftCameraToPosition(&local_14,0x88); - sub_803E708(0x40,70); - DisplayDungeonDialogue(&gHoOhPreFightDialogue_1); - sub_803E708(10,70); - HoOhScreenFlash(); - DisplayDungeonDialogue(&gHoOhPreFightDialogue_2); - sub_803E708(10,70); - sub_80855E4(sub_80868F4); - sub_808680C(); - PlaySoundEffect(0x1c5); - sub_803E708(0xfa,70); - HoOhDropInEffect(HoOhEntity); - StopSoundEffect(0x1c5); - sub_808682C(); - sub_80855E4(sub_8086910); - sub_8085930(DIRECTION_NORTH); - DisplayDungeonDialogue(&gHoOhPreFightDialogue_3); - DisplayDungeonDialogue(&gHoOhPreFightDialogue_4); - sub_803E708(0x1e,70); - sub_803E708(0x1e,70); - HoOhScreenFlash(); - DisplayDungeonDialogue(&gHoOhPreFightDialogue_5); - HoOhScreenFlash(); - DisplayDungeonDialogue(&gHoOhPreFightDialogue_6); - sub_803E708(10,70); - SetupBossFightHP(HoOhEntity,800,MUS_BATTLE_WITH_RAYQUAZA); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); -} - -void HoOhReFightDialogue(void) -{ - Entity * leaderEntity; - Entity * HoOhEntity; - PixelPos local_14; - - leaderEntity = xxx_call_GetLeader(); - HoOhEntity = GetEntityFromMonsterBehavior(BEHAVIOR_HO_OH); - - local_14.x = leaderEntity->pixelPos.x; - local_14.y = leaderEntity->pixelPos.y + -0x1000; - ShiftCameraToPosition(&local_14,0x88); - sub_803E708(0x40,70); - if (HasRecruitedMon(MONSTER_HO_OH)) { - sub_80866C4(&HoOhReFightDialogue_5); - } - else { - DisplayDungeonDialogue(&HoOhReFightDialogue_1); - HoOhScreenFlash(); - sub_80855E4(sub_80868F4); - sub_808680C(); - sub_803E708(10,70); - HoOhDropInEffect(HoOhEntity); - sub_808682C(); - sub_80855E4(sub_8086910); - sub_8085930(DIRECTION_NORTH); - DisplayDungeonDialogue(&HoOhReFightDialogue_2); - HoOhScreenFlash(); - DisplayDungeonDialogue(&HoOhReFightDialogue_3); - HoOhScreenFlash(); - DisplayDungeonDialogue(&HoOhReFightDialogue_4); - sub_803E708(10,70); - SetupBossFightHP(HoOhEntity,800,MUS_BATTLE_WITH_RAYQUAZA); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); - } -} - -void HoOhDropInEffect(Entity * param_1) -{ - s24_8 iVar1; - s24_8 iVar2; - - GetEntInfo(param_1)->unk15E = 0; - iVar2 = IntToF248(200); - iVar1 = IntToF248(12); - PlaySoundEffect(0x1f8); - while( 1 ) { - iVar2.raw -= iVar1.raw; - iVar1 = F248_Sub(iVar1, FloatToF248(0.375)); - if (F248LessThanFloat(iVar1, 0.08)) { - iVar1 = FloatToF248_2(0.08); - } - if (F248LessThanInt(iVar2, 0)) break; - GetEntInfo(param_1)->unk174 = iVar2; - DungeonRunFrameActions(70); - } - GetEntInfo(param_1)->unk174 = IntToF248_2(0); -} - -void HoOhScreenFlash(void) -{ - s32 iVar1; - - PlaySoundEffect(0x1ed); - for(iVar1 = 250; iVar1 > 149; iVar1 -= 10) - { - SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,1); - DungeonRunFrameActions(70); - } - sub_803E708(10,70); - for(iVar1 = 250; iVar1 > 199; iVar1 -= 10) - { - SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,1); - DungeonRunFrameActions(70); - } - sub_803E708(10,70); - for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10) - { - SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,1); - DungeonRunFrameActions(70); - } - sub_803E708(10,70); - sub_8085EB0(); -} - -void sub_808A9E4(void) -{ - Entity * leaderEntity; - Entity * LatiosEntity; - - leaderEntity = xxx_call_GetLeader(); - LatiosEntity = GetEntityFromMonsterBehavior(BEHAVIOR_LATIOS); - DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - sub_80855E4(sub_8086A3C); - SetFacingDirection(LatiosEntity, DIRECTION_NORTH); - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 4); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_LATIOS); -} - -void sub_808AA3C(void) -{ - Entity * leaderEntity; - Entity * LatiosEntity; - - leaderEntity = xxx_call_GetLeader(); - LatiosEntity = GetEntityFromMonsterBehavior(BEHAVIOR_LATIOS); - DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - sub_80855E4(sub_8086A3C); - SetFacingDirection(LatiosEntity, DIRECTION_NORTH); - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 3); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_LATIOS); -} - -void sub_808AA94(void) -{ - Entity * leaderEntity; - Entity * LatiosEntity; - - leaderEntity = xxx_call_GetLeader(); - LatiosEntity = GetEntityFromMonsterBehavior(BEHAVIOR_LATIOS); - DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - sub_80855E4(sub_8086A3C); - sub_8068FE0(LatiosEntity,0x21c,0); - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 3); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_LATIOS); -} - -void sub_808AAF0(u8 param_1, u8 param_2) -{ - if ((param_2 == 0x2B || param_2 == 0x2C || param_2 == 0x2D) && (param_1 == 0x16)) { - sub_8097FA8(0x1C); - gDungeon->unk2 = 1; - } -} - -void LatiosPreFightDialogue(void) -{ - Entity * leaderEntity; - Entity * LatiosEntity; - PixelPos local_18; - DungeonPos local_19; - - leaderEntity = xxx_call_GetLeader(); - LatiosEntity = GetEntityFromMonsterBehavior(BEHAVIOR_LATIOS); - - local_18.x = LatiosEntity->pixelPos.x; - local_18.y = LatiosEntity->pixelPos.y + (0x80 << 6); - local_19.y = 0x70; - local_19.x = 0xFC; - sub_8085EC8(0x1bd,0,0,&local_19,1); - - sub_803E708(0x1e,70); - sub_8086448(); - ShiftCameraToPosition(&local_18,0x18); - sub_803E708(2,70); - SpriteShockEffect(LatiosEntity); - sub_803E708(0x20,70); - sub_808692C(); - DisplayDungeonDialogue(&gLatiosPreFightDialogue_1); - LatiosScreenFlash(); - DisplayDungeonDialogue(&gLatiosPreFightDialogue_2); - LatiosScreenFlash(); - DisplayDungeonDialogue(&gLatiosPreFightDialogue_3); - sub_803E708(10,70); - SetupBossFightHP(LatiosEntity,600,MUS_BOSS_BATTLE); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); -} - -void LatiosReFightDialogue(void) -{ - Entity * leaderEntity; - Entity * LatiosEntity; - - leaderEntity = xxx_call_GetLeader(); - LatiosEntity = GetEntityFromMonsterBehavior(BEHAVIOR_LATIOS); - sub_8086448(); - sub_808692C(); - DisplayDungeonDialogue(&gLatiosReFightDialogue_1); - LatiosScreenFlash(); - DisplayDungeonDialogue(&gLatiosPreFightDialogue_2); - LatiosScreenFlash(); - DisplayDungeonDialogue(&gLatiosPreFightDialogue_3); - sub_803E708(10,70); - SetupBossFightHP(LatiosEntity,600,MUS_BOSS_BATTLE); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); -} - -void sub_808AC3C(void) -{ - sub_8086448(); - // There appears to be no one here - sub_80866C4(&gUnknown_8104FC8); -} - -void LatiosScreenFlash(void) -{ - s32 iVar1; - - PlaySoundEffect(0x1ee); - gDungeonBrightness = 0x1f; - for(iVar1 = 250; iVar1 > 149; iVar1 -= 10) - { - SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,1); - DungeonRunFrameActions(70); - } - sub_803E708(10,70); - for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10) - { - SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,1); - DungeonRunFrameActions(70); - } - sub_803E708(10,70); - sub_8085EB0(); -} - -void sub_808ACC0(void) -{ - Entity * entity; - - if (HasRecruitedMon(MONSTER_REGIROCK)) { - entity = GetEntityFromMonsterBehavior(BEHAVIOR_REGIROCK); - sub_8068FE0(entity,0x21c,0); - sub_8097FA8(0x22); - sub_8097FA8(0x1d); - sub_808B1CC(ITEM_ROCK_PART); - } - else if (sub_80860A8(ITEM_ROCK_PART) != 0) { - sub_8098044(0x22); - sub_8097FA8(0x1d); - } - else if (sub_80860A8(ITEM_MUSIC_BOX) != 0) { - sub_8098044(0x22); - sub_8097FA8(0x1d); - } - else { - sub_8098044(0x22); - sub_8098044(0x1d); - sub_80855E4(SetupRegiFacingDirection); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_REGIROCK); - } -} - -void sub_808AD48(void) -{ - Entity * entity; - - if (HasRecruitedMon(MONSTER_REGICE)) { - entity = GetEntityFromMonsterBehavior(BEHAVIOR_REGICE); - sub_8068FE0(entity,0x21c,0); - sub_8097FA8(0x22); - sub_8097FA8(0x1d); - sub_808B1CC(ITEM_ICE_PART); - } - else if (sub_80860A8(ITEM_ICE_PART) != 0) { - sub_8098044(0x22); - sub_8097FA8(0x1d); - } - else if (sub_80860A8(ITEM_MUSIC_BOX) != 0) { - sub_8098044(0x22); - sub_8097FA8(0x1d); - } - else { - sub_8098044(0x22); - sub_8098044(0x1d); - sub_80855E4(SetupRegiFacingDirection); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_REGICE); - } -} - -void sub_808ADCC(void) -{ - - Entity * entity; - - if (HasRecruitedMon(MONSTER_REGISTEEL)) { - entity = GetEntityFromMonsterBehavior(BEHAVIOR_REGISTEEL); - sub_8068FE0(entity,0x21c,0); - sub_8097FA8(0x22); - sub_8097FA8(0x1d); - sub_808B1CC(ITEM_STEEL_PART); - } - else if (sub_80860A8(ITEM_STEEL_PART) != 0) { - sub_8098044(0x22); - sub_8097FA8(0x1d); - } - else if (sub_80860A8(ITEM_MUSIC_BOX) != 0) { - sub_8098044(0x22); - sub_8097FA8(0x1d); - } - else { - sub_8098044(0x22); - sub_8098044(0x1d); - sub_80855E4(SetupRegiFacingDirection); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_REGISTEEL); - } -} - -void sub_808AE54(u8 param_1,u8 param_2,DungeonPos *param_3) -{ - Entity * leaderEntity; - s16 IDStack[2]; - Item item; - - - leaderEntity = xxx_call_GetLeader(); - sub_8052D44(IDStack,leaderEntity,0); - if (!sub_8098100(0x22) && (param_2 == 0x2E) && (param_1 == 0x17)) { - sub_808B1CC(ITEM_NOTHING); - if (!sub_8098100(0x1d)) { - ItemIdToSlot(&item,ITEM_ROCK_PART,0); - sub_80464C8(GetLeader(),param_3,&item); - DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); - // Something fell from Regirock's body - // Regirock was apparently guarding this item - DisplayDungeonDialogue(&gRegirockPostFightDialogue_1); - } - } -} - - -void sub_808AEC8(u8 param_1,u8 param_2,DungeonPos *param_3) -{ - Entity * leaderEntity; - s16 IDStack[2]; - Item item; - - - leaderEntity = xxx_call_GetLeader(); - sub_8052D44(IDStack,leaderEntity,0); - if (!sub_8098100(0x22) && (param_2 == 0x2F) && (param_1 == 0x18)) { - sub_808B1CC(ITEM_NOTHING); - if (!sub_8098100(0x1d)) { - ItemIdToSlot(&item,ITEM_ICE_PART,0); - sub_80464C8(GetLeader(),param_3,&item); - DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); - // Something fell from Regice's body - // Regice was apparently guarding this item - DisplayDungeonDialogue(&gRegicePostFightDialogue_1); - } - } -} - -void sub_808AF3C(u8 param_1,u8 param_2,DungeonPos *param_3) -{ - Entity * leaderEntity; - s16 IDStack[2]; - Item item; - - - leaderEntity = xxx_call_GetLeader(); - sub_8052D44(IDStack,leaderEntity,0); - if (!sub_8098100(0x22) && (param_2 == 0x30) && (param_1 == 0x19)) { - sub_808B1CC(ITEM_NOTHING); - if (!sub_8098100(0x1d)) { - ItemIdToSlot(&item,ITEM_STEEL_PART,0); - sub_80464C8(GetLeader(),param_3, &item); - DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); - // Something fell from Registeel's body - // Registeel was apparently guarding this item - DisplayDungeonDialogue(&gRegisteelPostFightDialogue_1); - } - } -} - -void sub_808AFB0(u8 param_1) -{ - Entity * leaderEntity; - s16 IDStack [2]; - - leaderEntity = xxx_call_GetLeader(); - sub_8052D44(IDStack,leaderEntity,0); - if (!sub_8098100(0x22) && (param_1 == 0x2E) && (!sub_8098100(0x1d)) && (sub_80860A8(ITEM_ROCK_PART) != 0)) { - sub_8097FD0(0x1d); - SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],GetLeader(),0); - // {POKEMON_0} obtained the Rock Part that Regirock was guarding - DisplayDungeonDialogue(&gRegirockPostFightDialogue_2); - sub_80421C0(0,0xd4); - sub_803E708(10,70); - sub_8046D20(); - } -} - -void sub_808B030(u8 param_1) -{ - Entity * leaderEntity; - s16 IDStack [2]; - - leaderEntity = xxx_call_GetLeader(); - sub_8052D44(IDStack,leaderEntity,0); - if (!sub_8098100(0x22) && (param_1 == 0x2F) && (!sub_8098100(0x1d)) && (sub_80860A8(ITEM_ICE_PART) != 0)) { - sub_8097FD0(0x1d); - SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],GetLeader(),0); - // {POKEMON_0} obtained the Ice Part that Regice was guarding - DisplayDungeonDialogue(&gRegicePostFightDialogue_2); - sub_80421C0(0,0xd4); - sub_803E708(10,70); - sub_8046D20(); - } -} - -void sub_808B0B0(u8 param_1) -{ - Entity * leaderEntity; - s16 IDStack [2]; - - leaderEntity = xxx_call_GetLeader(); - sub_8052D44(IDStack,leaderEntity,0); - if (!sub_8098100(0x22) && (param_1 == 0x30) && (!sub_8098100(0x1d)) && (sub_80860A8(ITEM_STEEL_PART) != 0)) { - sub_8097FD0(0x1d); - SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0], GetLeader(), 0); - // {POKEMON_0} obtained the Steel Part that Registeel was guarding - DisplayDungeonDialogue(&gRegisteelPostFightDialogue_2); - sub_80421C0(0,0xd4); - sub_803E708(10,70); - sub_8046D20(); - } -} - -void RegirockPreFightDialogue(void) -{ - if (!sub_8098100(0x22)) { - sub_8085930(DIRECTION_NORTH); - // INTRUDER ALERT - // EXTERMINATE - DisplayDungeonDialogue(&gRegirockPreFightDialogue_1); - sub_803E708(10,70); - sub_808563C(SetupRegirockFightHP); - } -} - -void RegicePreFightDialogue(void) -{ - if (!sub_8098100(0x22)) { - sub_8085930(DIRECTION_NORTH); - // INTRUDER ALERT - // EXTERMINATE - DisplayDungeonDialogue(&gRegicePreFightDialogue_1); - sub_803E708(10,70); - sub_808563C(SetupRegiceFightHP); - } -} - -void RegisteelPreFightDialogue(void) -{ - if (!sub_8098100(0x22)) { - sub_8085930(DIRECTION_NORTH); - // INTRUDER ALERT - // EXTERMINATE - DisplayDungeonDialogue(&gRegisteelPreFightDialogue_1); - sub_803E708(10,70); - sub_808563C(SetupRegisteelFightHP); - } -} - -void sub_808B1CC(u8 itemID) -{ - Entity *entity; - Tile *tile; - DungeonPos pos; - Item item; - - pos.x = gDungeon->unk644.unk40; - pos.y = gDungeon->unk644.unk42; - if ((pos.x < 0) || (pos.y < 0)) { - entity = GetLeader(); - if (entity == NULL) { - gDungeon->unk2 = 1; - return; - } - pos.x = entity->pos.x; - pos.y = entity->pos.y; - } - sub_807FE04(&pos, 0); - tile = GetTileMut(pos.x, pos.y); - tile->terrainType = tile->terrainType | TERRAIN_TYPE_STAIRS; - if (((itemID != ITEM_NOTHING) && (sub_80860A8(itemID) == 0)) && - (sub_80860A8(ITEM_MUSIC_BOX) == 0)) { - ItemIdToSlot(&item,itemID,0); - pos.y--; - AddItemToDungeonAt(&pos,&item,1); - } - sub_8049ED4(); - ShowWholeRevealedDungeonMap(); -} - -void SetupRegiFacingDirection(Entity *regiEntity) -{ - GetEntInfo(regiEntity)->action.direction = DIRECTION_NORTH; - sub_806CE68(regiEntity, DIRECTION_NORTH); -} - - -void SetupRegirockFightHP(Entity *r0) -{ - SetupBossFightHP(r0, 450, MUS_BOSS_BATTLE); -} - - -void SetupRegiceFightHP(Entity *r0) -{ - SetupBossFightHP(r0, 450, MUS_BOSS_BATTLE); -} - - -void SetupRegisteelFightHP(Entity *r0) -{ - SetupBossFightHP(r0, 450, MUS_BOSS_BATTLE); -} - -void sub_808B2F4(void) -{ - Entity * leaderEntity; - Entity * jirachiEntity; - - leaderEntity = xxx_call_GetLeader(); - jirachiEntity = GetEntityFromMonsterBehavior(BEHAVIOR_JIRACHI); - DungeonStartNewBGM(MUS_FRIEND_AREA_FOREST); - CreateJirachiWishWarpTile(); - sub_8049ED4(); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - sub_80855E4(sub_8086A3C); - SetFacingDirection(jirachiEntity, DIRECTION_SOUTH); - sub_8086A3C(jirachiEntity); - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 3); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_JIRACHI); -} - -void sub_808B35C(void) -{ - Entity * leaderEntity; - Entity * jirachiEntity; - - leaderEntity = xxx_call_GetLeader(); - jirachiEntity = GetEntityFromMonsterBehavior(BEHAVIOR_JIRACHI); - DungeonStartNewBGM(MUS_FRIEND_AREA_FOREST); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - sub_80855E4(sub_8086A3C); - if (HasRecruitedMon(MONSTER_JIRACHI)) { - sub_8068FE0(jirachiEntity,0x21c,0); - } - else { - SetFacingDirection(jirachiEntity, DIRECTION_SOUTH); - sub_8086A3C(jirachiEntity); - CreateJirachiWishWarpTile(); - sub_8049ED4(); - - } - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 3); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_JIRACHI); -} - -void sub_808B3E4(u8 param_1, u8 param_2, u8 param_3) -{ - u8 uVar1; - if ((param_2 == 0x31 || param_2 == 0x32) && (param_1 == 0x1A)) { - sub_8097FA8(0x1E); - if(param_3 != 0) - { - gDungeon->unk2 = 1; - } - else { - uVar1 = gDungeon->unk1356C; - if(sub_80860A8(0x36) != 0) - { - JirachiWish(); - } - else - { - sub_808B50C(); - } - gDungeon->unk1356C = uVar1; - ShowWholeRevealedDungeonMap(); - } - } -} - -void JirachiPreFightDialogue(void) -{ - Entity * leaderEntity; - Entity * jirachiEntity; - - leaderEntity = xxx_call_GetLeader(); - jirachiEntity = GetEntityFromMonsterBehavior(BEHAVIOR_JIRACHI); - sub_8086448(); - sub_803E708(0x40,70); - DisplayDungeonDialogue(&gJirachiPreFightDialogue_1); - sub_803E708(10,70); - SpriteLookAroundEffect(leaderEntity); - sub_803E708(10,70); - DisplayDungeonDialogue(&gJirachiPreFightDialogue_2); - sub_80861F8(0x37,jirachiEntity,1); - sub_80855E4(SpriteShockEffect); - sub_803E708(0x3c,70); - JirachiDropInEffect(jirachiEntity); - sub_803E708(0x5a,70); - DisplayDungeonDialogue(&gJirachiPreFightDialogue_3); - sub_803E708(10,70); - DisplayDungeonDialogue(&gJirachiPreFightDialogue_4); - sub_803E708(10,70); - SetupBossFightHP(jirachiEntity,0x15e,MUS_BATTLE_WITH_RAYQUAZA); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); -} - -void sub_808B50C(void) -{ - Entity * jirachiEntity; - - jirachiEntity = GetEntityFromMonsterBehavior(BEHAVIOR_JIRACHI); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_JIRACHI); - sub_80855E4(sub_808BBA8); - sub_808BBA8(jirachiEntity); - sub_8041888(0); - GetEntInfo(jirachiEntity)->unk15C = 1; - GetEntInfo(jirachiEntity)->unk15E = 0; - sub_80861B8(jirachiEntity,0xe,DIRECTION_SOUTH); - DungeonFadeOutBGM(0x1e); - sub_803E708(0x1e,70); - // Fwaaaahhhh - DisplayDungeonDialogue(&gUnknown_810554C); - DungeonStartNewBGM(MUS_FRIEND_AREA_FOREST); - // I think I had a dream, and I was fighting in it - // Did I imagine it? - // I'm sleepy so I'm going back to sleep. - DisplayDungeonDialogue(&gUnknown_8105558); - sub_803E708(10,70); - JirachiSpinEffect(jirachiEntity); - DisplayDungeonDialogue(&gUnknown_81055F4); - sub_803E708(10,70); - gDungeon->unk2 = 1; -} - -void JirachiWish(void) -{ - Entity *jirachiEntity; - DungeonPos *LeaderPos; - Entity *leaderEntity; - s32 wishChoice; - - jirachiEntity = GetEntityFromMonsterBehavior(BEHAVIOR_JIRACHI); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_JIRACHI); - sub_80855E4(sub_808BBA8); - sub_808BBA8(jirachiEntity); - sub_8041888(0); - GetEntInfo(jirachiEntity)->unk15C = 1; - GetEntInfo(jirachiEntity)->unk15E = 0; - sub_80861B8(jirachiEntity,0xe,DIRECTION_SOUTH); - sub_80855E4(sub_80861A8); - gDungeon->unk1356C = 1; - DungeonFadeOutBGM(0x1e); - sub_803E708(0x1e,0x46); - DisplayDungeonDialogue(&gUnknown_8105668); - sub_803E708(10,0x46); - PlaySoundEffect(0x1a7); - sub_803E708(0x96,0x46); - SpriteShockEffect(jirachiEntity); - DisplayDungeonDialogue(&gUnknown_8105674); - DungeonStartNewBGM(MUS_FRIEND_AREA_FOREST); - sub_803E708(10,0x46); - sub_80856E0(jirachiEntity, DIRECTION_SOUTH); - PlaySoundEffect(0x16a); - DisplayDungeonDialogue(&gUnknown_81056B8); - sub_803E708(10,0x46); - SpriteLookAroundEffect(jirachiEntity); - DisplayDungeonDialogue(&gUnknown_81056DC); - sub_803E708(10,0x46); - while( 1 ) { - while (1) { - wishChoice = DisplayDungeonMenuMessage(NULL,gUnknown_8105798,gUnknown_810579C,0x705); - if (wishChoice >= 1) break; - } - sub_803E708(10,0x46); - if (wishChoice == 1) { - s32 counter, index; - DungeonPos pos; - Item moneyItems [9]; - // Lots of Money - DisplayDungeonDialogue(&gUnknown_810581C); - sub_803E708(10,0x46); - JirachiWishGrantDialogue(jirachiEntity); - - for(counter = 0; counter < 6; counter++) - { - for(index = 0; index < 9; index++) - { - CreateItemWithStickyChance(&moneyItems[index], ITEM_POKE, 0); - } - pos.x = (jirachiEntity->pos.x + DungeonRandInt(3) - 1); - pos.y = (jirachiEntity->pos.y + DungeonRandInt(3) + -1); - if ((GetTileMut(pos.x, pos.y)->terrainType & 3) != 0) { - PlaySoundEffect(0x14c); - sub_808BB3C(&pos); - sub_8046860(jirachiEntity,&pos,moneyItems,9); - } - } - GetEntInfo(jirachiEntity)->unk15D = 0; - } - if (wishChoice == 2) { - s32 counter, index; - DungeonPos pos; - Item items [9]; - // Lots of Items - DisplayDungeonDialogue(&gUnknown_8105974); - sub_803E708(10,0x46); - JirachiWishGrantDialogue(jirachiEntity); - - for(counter = 0; counter < 6; counter++) - { - for(index = 0; index < 9; index++) - { - CreateItemWithStickyChance(&items[index], GetRandomFloorItem(0),0); - } - pos.x = (jirachiEntity->pos.x + DungeonRandInt(3) - 1); - pos.y = (jirachiEntity->pos.y + DungeonRandInt(3) + -1); - - if ((GetTileMut(pos.x, pos.y)->terrainType & 3) != 0) { - PlaySoundEffect(400); - sub_808BB3C(&pos); - sub_8046860(jirachiEntity,&pos,items,9); - } - } - GetEntInfo(jirachiEntity)->unk15D = 0; - } - - if (wishChoice == 3) - { - // A Friend Area - s32 friendArea = JirachiFriendAreaSearch(); - if (friendArea == NUM_FRIEND_AREAS) - { - // You want a friend area? But you already have many friend areas... - DisplayDungeonDialogue(&gUnknown_8105A08); - sub_803E708(10,0x46); - continue; - } - else - { - // You want a friend area? As you wish.. - DisplayDungeonDialogue(&gUnknown_8105AD4); - sub_803E708(10,0x46); - JirachiWishGrantDialogue(jirachiEntity); - GetEntInfo(jirachiEntity)->unk15D = 0; - DisplayDungeonDialogue(&gUnknown_8105B20); - UnlockFriendArea(friendArea); - PlaySoundEffect(0xd4); - leaderEntity = GetLeader(); - SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],leaderEntity,0); - WriteFriendAreaName(gFormatBuffer_Items[0],friendArea,FALSE); - // Obtained the friend area! - DisplayDungeonDialogue(&gUnknown_8105B68); - } - } - if (wishChoice == 4) { - s32 counter, index; - DungeonPos pos; - Item strengthItems [9]; - // More Strength.. - DisplayDungeonDialogue(&gUnknown_8105BA8); - sub_803E708(10,0x46); - JirachiWishGrantDialogue(jirachiEntity); - - for(counter = 0; counter < 5; counter++) - { - - for(index = 0; index < 4; index++) - { - CreateItemWithStickyChance(&strengthItems[index],gUnknown_81074FC[DungeonRandInt(8)],0); - } - - pos.x = (jirachiEntity->pos.x + DungeonRandInt(3) - 1); - pos.y = (jirachiEntity->pos.y + DungeonRandInt(3) + -1); - - if ((GetTileMut(pos.x, pos.y)->terrainType & 3) != 0) { - PlaySoundEffect(400); - sub_808BB3C(&pos); - sub_8046860(jirachiEntity,&pos,strengthItems,4); - } - } - GetEntInfo(jirachiEntity)->unk15D = 0; - DisplayDungeonDialogue(&gUnknown_8105BF4); - sub_803E708(10,0x46); - } - if (wishChoice == 5) { - s32 direction; - // Something Good... - DisplayDungeonDialogue(&gUnknown_8105D2C); - sub_803E708(10,0x46); - JirachiWishGrantDialogue(jirachiEntity); - GetEntInfo(jirachiEntity)->unk15D = 0; - DisplayDungeonDialogue(&gUnknown_8105D80); - sub_803E708(10,0x46); - LeaderPos = &GetLeader()->pos; - direction = GetDirectionTowardsPosition(&jirachiEntity->pos,LeaderPos); - SetFacingDirection(jirachiEntity,direction); - sub_803E708(10,0x46); - DisplayDungeonDialogue(&gUnknown_8105D9C); - sub_803E708(10,0x46); - gDungeon->unk644.unk30 = 1; - } - break; - } - - DisplayDungeonDialogue(&gUnknown_81058E0); - JirachiSpinEffect(jirachiEntity); - sub_803E708(10,0x46); - DisplayDungeonDialogue(&gUnknown_810593C); - sub_803E708(10,0x46); - EnableJirachiWishWarpTile(); -} - -void JirachiReFightDialogue(void) -{ - if(HasRecruitedMon(MONSTER_JIRACHI)) - { - sub_8086448(); - sub_80866C4(&gJirachiReFightDialogue_1); - } - else - { - JirachiPreFightDialogue(); - } -} - -void JirachiWishGrantFlash(void) -{ - s32 iVar1; - - PlaySoundEffect(0x2c1); - gDungeonBrightness = 0x1f; - - for(iVar1 = 0xFA; iVar1 > 0x95; iVar1 -= 10) - { - SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,1); - DungeonRunFrameActions(0x46); - } - sub_803E708(10,0x46); - - for(iVar1 = 0xFA; iVar1 > 0xC7; iVar1 -= 10) - { - SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,1); - DungeonRunFrameActions(0x46); - } - sub_803E708(10,0x46); - - for(iVar1 = 0xFA; iVar1 >= 0; iVar1 -= 10) - { - SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,1); - DungeonRunFrameActions(0x46); - } - sub_803E708(10,0x46); - sub_8085EB0(); -} - -void sub_808BB3C(DungeonPos *pos1) -{ - s32 x, y; - DungeonPos newPos; - - x = X_POS_TO_PIXELPOS(pos1->x); - newPos.x = x / 256; - - y = Y_POS_TO_PIXELPOS(pos1->y); - newPos.y = y / 256; - - sub_8085EC8(100,0,0,&newPos,0); -} - -void sub_808BBA8(Entity *jirachiEntity) -{ - ResetMonEntityData(GetEntInfo(jirachiEntity),0); -} - -void JirachiDropInEffect(Entity *jirachiEntity) -{ - s24_8 iVar1; - s24_8 iVar2; - - sub_80861F8(0x1b,jirachiEntity,0); - sub_8086A54(jirachiEntity); - sub_80861B8(jirachiEntity,0xe,DIRECTION_SOUTH); - iVar1 = IntToF248(160); - iVar2 = IntToF248(2); - PlaySoundEffect(0x1f8); - while (1) { - iVar1.raw = iVar1.raw - iVar2.raw; // FRAGILE! Subtraction and assignment below must use .raw - if (F248LessThanInt(iVar1, 24)) { - iVar2.raw = IntToF248_2(1).raw; - } - if (F248LessThanInt(iVar1, 0)) break; - GetEntInfo(jirachiEntity)->unk174 = iVar1; - DungeonRunFrameActions(0x46); - } - GetEntInfo(jirachiEntity)->unk174 = IntToF248_2(0); -} - -void JirachiSpinEffect(Entity * jirachiEntity) -{ - s32 uVar1; - - PlaySoundEffect(0x298); - for(uVar1 = 0; uVar1 < 25; uVar1++){ - SetFacingDirection(jirachiEntity, uVar1 & DIRECTION_MASK); - sub_803E708(3,0x46); - } - GetEntInfo(jirachiEntity)->unk15E = 1; - PlaySoundEffect(0x27f); - sub_80861F8(99,jirachiEntity,1); -} - -void JirachiWishGrantDialogue(Entity *jirachiEntity) -{ - u32 uVar2; - - GetEntInfo(jirachiEntity)->unk15D = 1; - // Nnnnnnnnnn! - DisplayDungeonDialogue(&gUnknown_81058A8); - PlaySoundEffect(0x375); - sub_80861F8(0x67,jirachiEntity,1); - PlaySoundEffect(0x2a8); - uVar2 = sub_80861F8(0x68,jirachiEntity,0); - // Taaaaaaaah! - DisplayDungeonDialogue(&gUnknown_81058C4); - if (sub_800E9A8(uVar2)) { - sub_800DC14(uVar2); - } - sub_803E708(10,0x46); - JirachiWishGrantFlash(); -} - -// Warp Tile is created but not enabled until the Wish is done with EnableJirachiWishWarpTile -void CreateJirachiWishWarpTile(void) -{ - Tile *tile; - - tile = GetTileMut(gDungeon->unkE220[7].x, gDungeon->unkE220[7].y); - tile->terrainType &= ~(TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY); - tile->terrainType |= TERRAIN_TYPE_IMPASSABLE_WALL; - tile->terrainType &= ~TERRAIN_TYPE_STAIRS; - sub_8049884(); - sub_8049B8C(); - sub_8049ED4(); - ShowWholeRevealedDungeonMap(); -} - -void EnableJirachiWishWarpTile(void) -{ - Tile *tile; - - tile = GetTileMut(gDungeon->unkE220[7].x, gDungeon->unkE220[7].y); - tile->terrainType &= ~(TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY); - tile->terrainType |= TERRAIN_TYPE_NORMAL; - tile->terrainType &= ~TERRAIN_TYPE_IMPASSABLE_WALL; - tile->terrainType |= TERRAIN_TYPE_STAIRS; - tile->unk8 = 1; - sub_8049884(); - sub_8049B8C(); - sub_8049ED4(); - ShowWholeRevealedDungeonMap(); -} - -u8 JirachiFriendAreaSearch(void) -{ - u8 unlockCondition; - s32 friendAreaCounter; - s32 numUnlockableAreas; - u8 friendAreas[NUM_FRIEND_AREAS]; - u32 friendAreaIndex; - - // Build a copy of friend area list and keep track of - // how many are only Story Unlockable - numUnlockableAreas = 0; - for(friendAreaCounter = 1; friendAreaCounter < NUM_FRIEND_AREAS; friendAreaCounter++){ - unlockCondition = GetFriendAreaUnlockCondition(friendAreaCounter); - if (!(unlockCondition == UNLOCK_LEGENDARY_REQUEST)){ - if (!(unlockCondition == UNLOCK_WONDER_MAIL)){ - if(!gFriendAreas[friendAreaCounter]) { - friendAreas[numUnlockableAreas] = friendAreaCounter; - numUnlockableAreas++; - } - } - } - } - - if (numUnlockableAreas == 0) { - return NUM_FRIEND_AREAS; - } - else { - // Randomly pick 1 - friendAreaIndex = DungeonRandInt(numUnlockableAreas); - return friendAreas[friendAreaIndex]; - } -} - -void sub_808BDEC(void) -{ - Entity * leaderEntity; - Entity * lugiaEntity; - - leaderEntity = xxx_call_GetLeader(); - lugiaEntity = GetEntityFromMonsterBehavior(BEHAVIOR_LUGIA); - DungeonStopBGM(); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - sub_80855E4(sub_8086A3C); - if (HasRecruitedMon(MONSTER_LUGIA)) { - DungeonStartNewBGM(MUS_FRIEND_AREA_CRYPTIC_CAVE); - sub_8068FE0(lugiaEntity,0x21c,0); - } - else { - gDungeon->unk7 = 1; - SetFacingDirection(lugiaEntity, DIRECTION_SOUTH); - } - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 3); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_LUGIA); -} - -void sub_808BE70(u8 param_1,u8 param_2,u8 param_3) -{ - if ((param_2 == 0x33) && (param_1 == 0x1B)) { - gDungeon->unk2 = 1; - } -} - - -void LugiaPreFightDialogue(void) -{ - Entity * leaderEntity; - Entity * lugiaEntity; - - leaderEntity = xxx_call_GetLeader(); - lugiaEntity = GetEntityFromMonsterBehavior(BEHAVIOR_LUGIA); - if (HasRecruitedMon(MONSTER_LUGIA)) { - sub_8086448(); - sub_80866C4(&gLugiaPreFightDialogue_8); - } - else { - DungeonStopBGM(); - sub_8086448(); - DisplayDungeonDialogue(&gLugiaPreFightDialogue_1); - DungeonFadeInNewBGM(MUS_FRIEND_AREA_CRYPTIC_CAVE,0x3c); - sub_808C0CC(); - DisplayDungeonDialogue(&gLugiaPreFightDialogue_2); - LugiaScreenFlash(); - DisplayDungeonDialogue(&gLugiaPreFightDialogue_3); - sub_803E708(10,0x46); - DisplayDungeonDialogue(&gLugiaPreFightDialogue_4); - PlaySoundEffect(0x1f8); - sub_80861D4(lugiaEntity,0xd,DIRECTION_SOUTH); - sub_803E708(0x2b,0x46); - sub_80861B8(lugiaEntity,0,DIRECTION_SOUTH); - DisplayDungeonDialogue(&gLugiaPreFightDialogue_5); - LugiaScreenFlash(); - DisplayDungeonDialogue(&gLugiaPreFightDialogue_6); - LugiaScreenFlash2(); - SetDungeonBGColorRGB(0xffffff06,0xffffff06,0xffffff06,1,0); - DungeonStopBGM(); - sub_80861D4(lugiaEntity,7,DIRECTION_SOUTH); - DisplayDungeonDialogue(&gLugiaPreFightDialogue_7); - LugiaScreenFlash(); - SetupBossFightHP(lugiaEntity,800,MUS_BATTLE_WITH_RAYQUAZA); - DungeonStartNewBGM(MUS_FRIEND_AREA_CRYPTIC_CAVE); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); - } -} - -void LugiaScreenFlash(void) -{ - s32 iVar1; - - PlaySoundEffect(0x1f6); - for(iVar1 = 250; iVar1 > 149; iVar1 -= 10){ - SetDungeonBGColorRGB(0,0,iVar1,1,1); - DungeonRunFrameActions(0x46); - } - sub_803E708(10,0x46); - for(iVar1 = 250; iVar1 > 199; iVar1 -= 10){ - SetDungeonBGColorRGB(0,iVar1,iVar1,1,1); - DungeonRunFrameActions(0x46); - } - sub_803E708(10,0x46); - for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10){ - SetDungeonBGColorRGB(0,0,iVar1,1,1); - DungeonRunFrameActions(0x46); - } - sub_803E708(10,0x46); - sub_8085EB0(); -} - -void LugiaScreenFlash2(void) -{ - s32 iVar1; - - PlaySoundEffect(0x1f6); - - for(iVar1 = 0; iVar1 < 200; iVar1 += 100){ - SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,0); - DungeonRunFrameActions(0x46); - } - - for(iVar1 = 200; iVar1 >= 0; iVar1 -= 100){ - SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,0); - DungeonRunFrameActions(0x46); - } - - sub_803E708(4,0x46); - - for(iVar1 = 0; iVar1 < 200; iVar1 += 100){ - SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,0); - DungeonRunFrameActions(0x46); - } - - for(iVar1 = 200; iVar1 >= 0; iVar1 -= 100){ - SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,0); - DungeonRunFrameActions(0x46); - } - - sub_803E708(10,0x46); - sub_8085EB0(); -} - -void sub_808C0CC(void) -{ - gDungeonBrightness = 0x1f; - SetDungeonBGColorRGB(0,0,0,1,1); - BgColorCallNullsub4(); - DungeonRunFrameActions(0x46); - gDungeon->unk7 = 0; - LugiaScreenFlash(); -} - -void sub_808C10C(void) -{ - Entity * leaderEntity; - Entity * kyogreEntity; - - u32 XPos; - s32 YPos; - - leaderEntity = xxx_call_GetLeader(); - kyogreEntity = GetEntityFromMonsterBehavior(BEHAVIOR_KYOGRE); - DungeonStopBGM(); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - if (HasRecruitedMon(MONSTER_KYOGRE)) { - sub_8068FE0(kyogreEntity,0x21c,0); - } - else { - gDungeon->unk7 = 1; - SetFacingDirection(kyogreEntity, DIRECTION_SOUTH); - } - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y); - XPos = GetCameraXPos(); - YPos = GetCameraYPos(); - sub_803F878(XPos,YPos + -0x1000); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2],MONSTER_KYOGRE); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[3], MONSTER_GROUDON); -} - -void sub_808C1A4(u8 param_1,u8 param_2,u8 param_3) -{ - if ((param_2 == 0x34) && (param_1 == 0x1C)) { - gDungeon->unk2 = 1; - DungeonStartNewBGM(MUS_FRIEND_AREA_CRYPTIC_CAVE); - } -} - -void KyogrePreFightDialogue(void) -{ - Entity *leaderEntity; - Entity *KyogreEntity; - - leaderEntity = xxx_call_GetLeader(); - KyogreEntity = GetEntityFromMonsterBehavior(BEHAVIOR_KYOGRE); - DungeonStopBGM(); - if (HasRecruitedMon(MONSTER_KYOGRE)) { - DungeonFadeInNewBGM(MUS_FRIEND_AREA_CRYPTIC_CAVE,0x3c); - SpriteLookAroundEffect(leaderEntity); - sub_803E708(10,0x46); - DisplayDungeonDialogue(&gKyogrePreFightDialogue_8); - sub_803E708(10,0x46); - gDungeon->unk2 = 1; - } - else { - DisplayDungeonDialogue(&gKyogrePreFightDialogue_1); - sub_803E708(10,0x46); - DisplayDungeonDialogue(&gKyogrePreFightDialogue_2); - sub_803E708(10,0x46); - nullsub_99(); - sub_803E708(10,0x46); - // Gwwwwwooooooooh - DisplayDungeonDialogue(&gKyogrePreFightDialogue_3); - sub_803E708(10,0x46); - DungeonFadeInNewBGM(MUS_FRIEND_AREA_CRYPTIC_CAVE,0x3c); - sub_808C360(); - // My duels against {POKEMON_3} (Groudon) left us both exhausted - DisplayDungeonDialogue(&gKyogrePreFightDialogue_4); - KyogreScreenFlash(); - // I am {POKEMON_2} (Kyogre)! - // The lord of the sea! - DisplayDungeonDialogue(&gKyogrePreFightDialogue_5); - KyogreScreenFlash(); - // Witness the destructive force of my waves! - DisplayDungeonDialogue(&gKyogrePreFightDialogue_6); - KyogreScreenFlash(); - // Marvel at my awesome - // power! - DisplayDungeonDialogue(&gKyogrePreFightDialogue_7); - sub_803E708(10,0x46); - SetupBossFightHP(KyogreEntity,600,MUS_BOSS_BATTLE); - DungeonStartNewBGM(MUS_FRIEND_AREA_CRYPTIC_CAVE); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); - } -} - -void nullsub_99(void) -{ -} - -void KyogreScreenFlash(void) -{ - s32 iVar1; - - PlaySoundEffect(0x1f8); - for(iVar1 = 250; iVar1 > 149; iVar1 -= 10){ - SetDungeonBGColorRGB(0,0,iVar1,1,1); - DungeonRunFrameActions(0x46); - } - sub_803E708(10,0x46); - for(iVar1 = 250; iVar1 > 199; iVar1 -= 10){ - SetDungeonBGColorRGB(0,iVar1,iVar1,1,1); - DungeonRunFrameActions(0x46); - } - sub_803E708(10,0x46); - for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10){ - SetDungeonBGColorRGB(0,0,iVar1,1,1); - DungeonRunFrameActions(0x46); - } - sub_803E708(10,0x46); - sub_8085EB0(); -} - -void sub_808C360(void) -{ - gDungeonBrightness = 0x1f; - SetDungeonBGColorRGB(0,0,0,1,1); - BgColorCallNullsub4(); - DungeonRunFrameActions(0x46); - gDungeon->unk7 = 0; - KyogreScreenFlash(); -} - -void sub_808C3A0(void) -{ - Entity * leaderEntity; - - leaderEntity = xxx_call_GetLeader(); - DungeonStopBGM(); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - sub_80855E4(sub_8086A3C); - if (HasRecruitedMon(MONSTER_DEOXYS_NORMAL)) { - sub_808563C(sub_808C590); - } - else { - gDungeon->unk7 = 1; - sub_808563C(SetupDeoxysFacingDirection); - } - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y - 3); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_DEOXYS_NORMAL); -} - -void sub_808C414(u8 param_1,u8 param_2,u8 param_3) -{ - if ((param_2 == 0x35) && (param_1 == 0x1D)) { - gDungeon->unk2 = 1; - DungeonStartNewBGM(MUS_RAYQUAZAS_DOMAIN); - } -} - -void DeoxysPreFightDialogue(void) -{ - Entity * leaderEntity; - - leaderEntity = xxx_call_GetLeader(); - sub_8086448(); - if (HasRecruitedMon(MONSTER_DEOXYS_NORMAL)) { - // There appears to be no one here. - // It's impossible to go any further - sub_80866C4(&gDeoxysPreFightDialogue_5); - } - else { - DisplayDungeonDialogue(&gDeoxysPreFightDialogue_1); - DungeonFadeInNewBGM(MUS_RAYQUAZAS_DOMAIN, 0x3c); - sub_808C550(); - DisplayDungeonDialogue(&gDeoxysPreFightDialogue_2); - DeoxysScreenFlash(); - DisplayDungeonDialogue(&gDeoxysPreFightDialogue_3); - DeoxysScreenFlash(); - DisplayDungeonDialogue(&gDeoxysPreFightDialogue_4); - sub_803E708(10,0x46); - sub_808563C(SetupDeoxysFightHP); - ShiftCameraToPosition(&leaderEntity->pixelPos,0x10); - } -} - -void DeoxysScreenFlash(void) -{ - s32 iVar1; - - PlaySoundEffect(0x2c1); - for(iVar1 = 250; iVar1 > 149; iVar1 -= 10){ - SetDungeonBGColorRGB(iVar1,0,0,1,1); - DungeonRunFrameActions(0x46); - } - sub_803E708(10,0x46); - for(iVar1 = 250; iVar1 > 199; iVar1 -= 10){ - SetDungeonBGColorRGB(iVar1,iVar1,0,1,1); - DungeonRunFrameActions(0x46); - } - sub_803E708(10,0x46); - for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10){ - SetDungeonBGColorRGB(iVar1,0,0,1,1); - DungeonRunFrameActions(0x46); - } - sub_803E708(10,0x46); - sub_8085EB0(); -} - -void sub_808C550(void) -{ - gDungeonBrightness = 0x1f; - SetDungeonBGColorRGB(0,0,0,1,1); - BgColorCallNullsub4(); - DungeonRunFrameActions(0x46); - gDungeon->unk7 = 0; - DeoxysScreenFlash(); -} - -void sub_808C590(Entity *r0) -{ - sub_8068FE0(r0, 0x21C, 0); -} - -void SetupDeoxysFacingDirection(Entity *deoxysEntity) -{ - SetFacingDirection(deoxysEntity, DIRECTION_SOUTH); -} - -void SetupDeoxysFightHP(Entity *deoxysEntity) -{ - SetupBossFightHP(deoxysEntity, 950, MUS_BATTLE_WITH_RAYQUAZA); -} - -void sub_808C5C0(void) -{ - Entity * leaderEntity; - Entity * celebiEntity; - - u32 XPos; - s32 YPos; - - leaderEntity = xxx_call_GetLeader(); - celebiEntity = GetEntityFromMonsterBehavior(BEHAVIOR_CELEBI); - DungeonStartNewBGM(MUS_FRIEND_AREA_HEALING_FOREST); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - SetFacingDirection(celebiEntity, DIRECTION_SOUTH); - sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y); - XPos = GetCameraXPos(); - YPos = GetCameraYPos(); - sub_803F878(XPos,YPos - 0x1000); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_CELEBI); -} - -void nullsub_100(u8 r0, u8 r1, u8 r3) -{ -} - -void CelebiJoinDialogue(void) -{ - Entity *leaderEntity; - s32 state; - s32 menuChoice; - Entity *celebiEntity; - - leaderEntity = xxx_call_GetLeader(); - celebiEntity = GetEntityFromMonsterBehavior(BEHAVIOR_CELEBI); - if ((HasRecruitedMon(MONSTER_CELEBI)) || (!sub_806FD18(celebiEntity))) - { - sub_8068FE0(celebiEntity,0x21c,0); - SpriteLookAroundEffect(leaderEntity); - sub_803E708(10,0x46); - // ......... - DisplayDungeonDialogue(&gCelebiJoinDialogue_10); - } - else - { - SpriteLookAroundEffect(leaderEntity); - sub_803E708(10,0x46); - SpriteShockEffect(leaderEntity); - sub_803E708(10,0x46); - // Oh? There's someone there. - DisplayDungeonDialogue(&gCelebiJoinDialogue_1); - sub_803E708(10,0x46); - sub_8086598(); - sub_8086598(); - sub_8086598(); - sub_8086598(); - // The Time-Traveling Pokemon {POKEMON_2} (Celebi)! - DisplayDungeonDialogue(&gCelebiJoinDialogue_2); - PlaySoundEffect(0x1c7); - sub_806CDD4(celebiEntity,10,DIRECTION_SOUTH); - sub_803E708(0x14,0x46); - sub_806CE68(celebiEntity, DIRECTION_SOUTH); - sub_803E708(4,0x46); - PlaySoundEffect(0x1c7); - sub_806CDD4(celebiEntity,10,DIRECTION_SOUTH); - DisplayDungeonDialogue(&gCelebiJoinDialogue_3); - sub_803E708(10,0x46); - state = 0; - - do - { - switch(state) - { - case 0: - do - { - menuChoice = DisplayDungeonMenuMessage(0,gPtrPurityForestAllowCelebiToJoinText, gPurityForestAllowCelebiToJoinPrompt,0x701); - } while (menuChoice < 1); - - sub_803E708(10,0x46); - - if (menuChoice == 1) - { - DungeonStopBGM(); - PlaySoundEffect(0xcc); - while (IsFanfareSEPlaying_2(0xcc) != 0) { - DungeonRunFrameActions(0x46); - } - DungeonStartNewBGM(MUS_FRIEND_AREA_HEALING_FOREST); - PlaySoundEffect(0x1c7); - sub_80861D4(celebiEntity,0xd,DIRECTION_SOUTH); - sub_803E708(0x37,0x46); - PlaySoundEffect(0x1d5); - sub_803E708(0x1a,0x46); - PlaySoundEffect(0x1d5); - sub_803E708(0x1c,0x46); - DisplayDungeonDialogue(&gCelebiJoinDialogue_4); - sub_803E708(10,0x46); - sub_806FDF4(leaderEntity,celebiEntity,&celebiEntity); - DungeonStartNewBGM(MUS_FRIEND_AREA_HEALING_FOREST); - DisplayDungeonDialogue(&gCelebiJoinDialogue_5); - sub_803E708(10,0x46); - PlaySoundEffect(0x1c7); - sub_80861D4(celebiEntity,0xd,DIRECTION_SOUTH); - sub_803E708(0x37,0x46); - PlaySoundEffect(0x1d5); - sub_803E708(0x1a,0x46); - PlaySoundEffect(0x1d5); - sub_803E708(0x1b,0x46); - DisplayDungeonDialogue(&gCelebiJoinDialogue_6); - sub_803E708(10,0x46); - state = 2; - } - else - { - state = 1; - } - break; - case 1: - do - { - menuChoice = DisplayDungeonMenuMessage(0,gPtrPurityForestRefuseCelebiConfirmText, gPurityForestRefuseCelebiConfirmPrompt,0x701); - } while (menuChoice < 1); - if (menuChoice == 1) - { - state = 0; - } - else - { - sub_803E708(10,0x46); - DisplayDungeonDialogue(&gCelebiJoinDialogue_7); - sub_80861F8(0x3e,celebiEntity,1); - sub_803E708(0x18,0x46); - sub_80861F8(0x3e,celebiEntity,1); - sub_803E708(0xe,0x46); - DisplayDungeonDialogue(&gCelebiJoinDialogue_8); - sub_803E708(10,0x46); - sub_808C8E0(celebiEntity); - DisplayDungeonDialogue(&gCelebiJoinDialogue_9); - sub_803E708(10,0x46); - state = 2; - } - break; - } - } while (state != 2); - } - DungeonFadeOutBGM(0x1e); - sub_803E708(0x1e,0x46); - gDungeon->unk2 = 1; -} - -void sub_808C8E0(Entity *entity) -{ - s32 iVar1; - - PlaySoundEffect(0x1a5); - sub_806CDD4(entity, 0, DIRECTION_SOUTH); - for(iVar1 = 0; iVar1 < 16; iVar1++){ - GetEntInfo(entity)->unk174 = IntToF248_2(iVar1); - DungeonRunFrameActions(0x46); - } - for(iVar1 = 16; iVar1 < 200; iVar1 += 4){ - GetEntInfo(entity)->unk174 = IntToF248_2(iVar1); - DungeonRunFrameActions(0x46); - } - sub_8086A3C(entity); -} - -void sub_808C938(void) -{ - sub_80855E4(sub_808C9B0); -} - -void sub_808C948(Entity *entity, u8 param_2) -{ - bool8 flag; - s32 index; - Entity *pokeEntity; - - if (param_2 == 0x37) { - flag = FALSE; - for(index = 0; index < DUNGEON_MAX_WILD_POKEMON; index++){ - pokeEntity = gDungeon->wildPokemon[index]; - if ((pokeEntity != entity) && (EntityIsValid(pokeEntity))) { - flag = TRUE; - break; - } - } - if (!flag) { - gDungeon->unk2 = 1; - } - } -} - -void sub_808C998(void) -{ - // Defeat the opposing team to win - // Be careful, your opponents are tough - DisplayDungeonDialogue(&gUnknown_8106720); - sub_803E708(0xA, 0x46); -} - -void sub_808C9B0(Entity *param_1) -{ - GetEntInfo(param_1)->action.direction = DIRECTION_NORTH; - sub_806CE68(param_1, DIRECTION_NORTH); -} - -void sub_808C9C4(void) -{ - Entity *leaderEntity; - Entity *medichamEntity; - - leaderEntity = xxx_call_GetLeader(); - medichamEntity = GetEntityFromMonsterBehavior(BEHAVIOR_MEDICHAM); - DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - sub_80855E4(sub_8086A3C); - SetFacingDirection(medichamEntity, DIRECTION_SOUTH); - sub_8085860(leaderEntity->pos.x, leaderEntity->pos.y - 3); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_MEDICHAM); -} - -void MedichamRescueDialogue(void) -{ - Entity *medichamEntity; - s32 counter; - - medichamEntity = GetEntityFromMonsterBehavior(BEHAVIOR_MEDICHAM); - SpriteLookAroundEffect(medichamEntity); - sub_803E708(0xA, 0x46); - // Oh my I can't seem to find a way out... - DisplayDungeonDialogue(&gMedichamRescueDialogue_1); - sub_803E708(0xA, 0x46); - sub_80869E4(medichamEntity, 4, 2, DIRECTION_NORTH); - sub_803E708(0xA, 0x46); - // What am I to do...? - DisplayDungeonDialogue(&gMedichamRescueDialogue_2); - sub_803E708(0xA, 0x46); - sub_8086448(); - sub_8086598(); - sub_803E708(0x20, 0x46); - SpriteShockEffect(medichamEntity); - sub_803E708(0x20, 0x46); - sub_80869E4(medichamEntity, 4, 2, DIRECTION_SOUTH); - DisplayDungeonDialogue(&gMedichamRescueDialogue_3); - sub_803E708(0xA, 0x46); - PlaySoundEffect(0x1c7); - sub_806CDD4(medichamEntity, 0xA, DIRECTION_SOUTH); - sub_803E708(0x14, 0x46); - sub_806CE68(medichamEntity, DIRECTION_SOUTH); - sub_803E708(0x4, 0x46); - PlaySoundEffect(0x1c7); - sub_806CDD4(medichamEntity, 0xA, DIRECTION_SOUTH); - sub_803E708(0x14, 0x46); - // Yes Yes - // I am so lucky - // - // There appears to be no one here - DisplayDungeonDialogue(&gMedichamRescueDialogue_4); - sub_803E708(0xA, 0x46); - sub_806CDD4(medichamEntity, 0, DIRECTION_SOUTH); - for(counter = 0x17; counter >= 0; counter--) - { - IncreaseEntityPixelPos(medichamEntity, 0, 0x100); - DungeonRunFrameActions(0x46); - } - sub_806CE68(medichamEntity, DIRECTION_SOUTH); - sub_803E708(0x20, 0x46); - sub_8042B0C(medichamEntity); - sub_8068FE0(medichamEntity, 0x21C, 0); - gDungeon->unk4 = 1; - gDungeon->unk11 = 4; -} - -void sub_808CB5C(void) -{ - Entity *leaderEntity; - Entity *medichamEntity; - - leaderEntity = xxx_call_GetLeader(); - medichamEntity = GetEntityFromMonsterBehavior(BEHAVIOR_MEDICHAM); - DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - sub_8068FE0(medichamEntity, 0x21C, 0); - sub_8085860(leaderEntity->pos.x, leaderEntity->pos.y); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_MEDICHAM); -} - -void DummyFightDialogue(void) -{ -} - -void sub_808CBB0(void) -{ - Entity *leaderEntity; - Entity *smeargleEntity; - - leaderEntity = xxx_call_GetLeader(); - smeargleEntity = GetEntityFromMonsterBehavior(BEHAVIOR_SMEARGLE); - DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - sub_80855E4(sub_8086A3C); - SetFacingDirection(smeargleEntity, DIRECTION_SOUTH); - sub_8085860(leaderEntity->pos.x, leaderEntity->pos.y - 3); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_SMEARGLE); -} - -void SmeargleRescueDialogue(void) -{ - Entity *smeargleEntity; - s32 counter; - - smeargleEntity = GetEntityFromMonsterBehavior(BEHAVIOR_SMEARGLE); - SpriteLookAroundEffect(smeargleEntity); - sub_803E708(0xA, 0x46); - // Ohhh... - // I've lost my bearings - DisplayDungeonDialogue(&gSmeargleRescueDialogue_1); - sub_803E708(0xA, 0x46); - sub_80869E4(smeargleEntity, 4, 2, DIRECTION_NORTH); - sub_803E708(0xA, 0x46); - // I can't get out... - // I'm hungry... - // I'm in trouble - DisplayDungeonDialogue(&gSmeargleRescueDialogue_2); - sub_803E708(0xA, 0x46); - sub_8086448(); - sub_8086598(); - sub_803E708(0x20, 0x46); - SpriteShockEffect(smeargleEntity); - sub_803E708(0x20, 0x46); - sub_80869E4(smeargleEntity, 4, 2, DIRECTION_SOUTH); - // Oh! You are? - DisplayDungeonDialogue(&gSmeargleRescueDialogue_3); - sub_803E708(0xA, 0x46); - PlaySoundEffect(0x1c7); - sub_806CDD4(smeargleEntity, 0xA, DIRECTION_SOUTH); - sub_803E708(0x14, 0x46); - sub_806CE68(smeargleEntity, DIRECTION_SOUTH); - sub_803E708(0x4, 0x46); - PlaySoundEffect(0x1c7); - sub_806CDD4(smeargleEntity, 0xA, DIRECTION_SOUTH); - sub_803E708(0x14, 0x46); - // Did you maybe come to rescue me? - // Am I glad to see you - DisplayDungeonDialogue(&gSmeargleRescueDialogue_4); - sub_803E708(0xA, 0x46); - sub_806CDD4(smeargleEntity, 0, DIRECTION_SOUTH); - for(counter = 0x17; counter >= 0; counter--) - { - IncreaseEntityPixelPos(smeargleEntity, 0, 0x100); - DungeonRunFrameActions(0x46); - } - sub_806CE68(smeargleEntity, DIRECTION_SOUTH); - sub_803E708(0x20, 0x46); - sub_8042B0C(smeargleEntity); - sub_8068FE0(smeargleEntity, 0x21C, 0); - gDungeon->unk4 = 1; - gDungeon->unk11 = 4; - -} - -void sub_808CD44(void) -{ - Entity *leaderEntity; - Entity *smeargleEntity; - - leaderEntity = xxx_call_GetLeader(); - smeargleEntity = GetEntityFromMonsterBehavior(BEHAVIOR_SMEARGLE); - DungeonStartNewBGM(MUS_IN_THE_DEPTHS_OF_THE_PIT); - sub_80854D4(); - sub_8085930(DIRECTION_NORTH); - sub_80855E4(sub_8086A3C); - sub_8068FE0(smeargleEntity, 540, 0); - sub_8085860(leaderEntity->pos.x, leaderEntity->pos.y - 3); - CopyMonsterNameToBuffer(gFormatBuffer_Monsters[2], MONSTER_SMEARGLE); -} - -void sub_808CD9C(void) -{ - sub_8086448(); - // There appears to be no one here. - // It's impossible to go any further - sub_80866C4(&gUnknown_810697C); -} - -const u64 *sub_808CDB0(u8 r0) -{ - return &gUnknown_8107544[r0]; -} diff --git a/src/dungeon_damage.c b/src/dungeon_damage.c index ec29ea568..2f2432951 100644 --- a/src/dungeon_damage.c +++ b/src/dungeon_damage.c @@ -27,7 +27,7 @@ #include "code_806CD90.h" #include "constants/direction.h" #include "constants/dungeon.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "code_803E668.h" #include "code_8041AD0.h" #include "code_804267C.h" diff --git a/src/dungeon_engine.c b/src/dungeon_engine.c index 505c5ef70..8ecc3b56f 100644 --- a/src/dungeon_engine.c +++ b/src/dungeon_engine.c @@ -1,7 +1,7 @@ #include "global.h" #include "globaldata.h" #include "run_dungeon.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "constants/dungeon.h" #include "dungeon_ai_leader.h" #include "dungeon_ai.h" @@ -11,6 +11,7 @@ #include "structs/str_dungeon.h" #include "constants/ability.h" #include "dungeon_logic.h" +#include "menu_input.h" extern bool8 sub_8044B28(void); extern void TrySpawnMonsterAndActivatePlusMinus(void); @@ -32,6 +33,9 @@ extern void sub_807EAA0(u32, u32); static void sub_8044454(void); static bool8 xxx_dungeon_80442D0(bool8); +EWRAM_DATA DungeonPos gUnknown_202EE0C = {0}; +EWRAM_DATA MenuInputStruct gDungeonMenu = {0}; + const s16 gSpeedTurns[NUM_SPEED_COUNTERS][25] = { [0] = {0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3, 0}, [1] = {0, 0, 0, 4, 0, 0, 0, 5, 0, 0, 0, 6, 0, 0, 0, 7, 0, 0, 0, 8, 0, 0, 0, 9, 0}, diff --git a/src/dungeon_generation.c b/src/dungeon_generation.c index 6ccf6a307..14ad20887 100644 --- a/src/dungeon_generation.c +++ b/src/dungeon_generation.c @@ -4044,12 +4044,6 @@ static void ResetFloor(void) } } -struct PositionU8 -{ - u8 x; - u8 y; -}; - /* * ShuffleSpawnPositions - Randomly shuffle an array of spawn positions */ @@ -4083,7 +4077,7 @@ static void ShuffleSpawnPositions(struct PositionU8 *spawns, s32 count) */ static void SpawnNonEnemies(FloorProperties *floorProps, bool8 isEmptyMonsterHouse) { - struct PositionU8 validSpawns[DUNGEON_MAX_SIZE_X * DUNGEON_MAX_SIZE_Y]; + struct PositionU8 validSpawns[DUNGEON_MAX_NUM_TILES]; s32 count; s32 randIndex; s32 i; @@ -4419,7 +4413,7 @@ static void SpawnNonEnemies(FloorProperties *floorProps, bool8 isEmptyMonsterHou */ static void SpawnEnemies(FloorProperties *floorProps, bool8 isEmptyMonsterHouse) { - struct PositionU8 validSpawns[DUNGEON_MAX_SIZE_X * DUNGEON_MAX_SIZE_Y]; + struct PositionU8 validSpawns[DUNGEON_MAX_NUM_TILES]; s32 count; s32 randIndex; s32 i; diff --git a/src/dungeon_item_action.c b/src/dungeon_item_action.c index 6037e86d1..187f82990 100644 --- a/src/dungeon_item_action.c +++ b/src/dungeon_item_action.c @@ -5,7 +5,7 @@ #include "dungeon_message.h" #include "code_8077274_1.h" #include "code_807CD9C.h" -#include "code_808417C.h" +#include "dungeon_random.h" #include "constants/dungeon_action.h" #include "constants/dungeon.h" #include "constants/iq_skill.h" diff --git a/src/dungeon_items.c b/src/dungeon_items.c index 15420c01d..934084f38 100644 --- a/src/dungeon_items.c +++ b/src/dungeon_items.c @@ -23,7 +23,7 @@ #include "trap.h" #include "math.h" #include "structs/str_item_text.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "sprite.h" extern SpriteOAM gUnknown_202EDC0; diff --git a/src/dungeon_jobs.c b/src/dungeon_jobs.c new file mode 100644 index 000000000..c21326b4f --- /dev/null +++ b/src/dungeon_jobs.c @@ -0,0 +1,219 @@ +#include "global.h" +#include "globaldata.h" +#include "dungeon_jobs.h" +#include "dungeon_strings.h" +#include "dungeon_util.h" +#include "dungeon_message.h" +#include "dungeon_misc.h" +#include "dungeon_logic.h" +#include "dungeon_leader.h" +#include "string_format.h" +#include "code_80958E8.h" +#include "mailbox.h" +#include "pokemon_mid.h" +#include "structs/str_dungeon.h" +#include "constants/dungeon.h" + +extern void sub_8042A34(DungeonPos *r0); +extern void sub_804178C(u32); + +void sub_80842F0(void) +{ + s32 i; + + gDungeon->unk644.unk33 = 0; + gDungeon->unk644.unk46 = 0; + if (gDungeon->unk644.unk34 != 2) + return; + + for (i = 0; i < MAX_ACCEPTED_JOBS; i++) { + WonderMail *jobSlot = GetJobSlotInfo(i); + if (jobSlot->mailType == MAIL_TYPE_TAKEN_JOB) { + if (gDungeon->unk644.dungeonLocation.id == jobSlot->unk4.dungeon.id + && gDungeon->unk644.dungeonLocation.floor == jobSlot->unk4.dungeon.floor + && jobSlot->missionType != 3) + { + if (jobSlot->missionType == 4) { + gDungeon->unk644.unk46 = jobSlot->targetItem; + gDungeon->unk644.unk44 = jobSlot->targetSpecies; + gDungeon->unk9 = 1; + } + else if (jobSlot->missionType == 0 || jobSlot->missionType == 2 || jobSlot->missionType == 1) { + gDungeon->unk644.unk44 = jobSlot->targetSpecies; + if (jobSlot->missionType == 2) { + gDungeon->unk644.unk33 = 1; + } + gDungeon->unk9 = 1; + } + } + } + } +} + +void sub_80843BC(s32 id) +{ + s32 i; + s32 id_s32 = (s16) id; + + for (i = 0; i < MAX_ACCEPTED_JOBS; i++) { + WonderMail *jobSlot = GetJobSlotInfo(i); + if (jobSlot->mailType == MAIL_TYPE_TAKEN_JOB) { + if (gDungeon->unk644.dungeonLocation.id == jobSlot->unk4.dungeon.id + && (gDungeon->unk644.dungeonLocation.floor == jobSlot->unk4.dungeon.floor) + && (jobSlot->missionType == 0 || jobSlot->missionType == 4 || jobSlot->missionType == 2 || jobSlot->missionType == 1) + && id_s32 == jobSlot->targetSpecies) { + jobSlot->mailType = MAIL_TYPE_UNK8; + } + } + } +} + +void sub_8084424(void) +{ + s32 i; + + for (i = 0; i < MAX_ACCEPTED_JOBS; i++) { + WonderMail *jobSlot = GetJobSlotInfo(i); + if (jobSlot->mailType == MAIL_TYPE_UNK8) { + jobSlot->mailType = MAIL_TYPE_UNK9; + } + } +} + +void sub_8084448(Entity *pokemon) +{ + int i; + const u8 *str; + EntityInfo *entInfo = GetEntInfo(pokemon); + + SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],GetLeader(),0); + SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[1],pokemon,0); + if (!sub_8070BC0(pokemon)) { + DisplayDungeonMessage(0,gUnknown_80FA464,1); + return; + } + + if (gDungeon->unk644.unk46 != 0) { + if (DisplayDungeonYesNoMessage(0, gUnknown_80FA32C, 1) != 1) + return; + BufferItemName(gFormatBuffer_Items[0], gDungeon->unk644.unk46, 0); + for (i = 0; i < INVENTORY_SIZE; i++) { + Item *item = &gTeamInventoryRef->teamItems[i]; + if (ItemExists(item) + && !(item->flags & ITEM_FLAG_IN_SHOP) + && !(item->flags & ITEM_FLAG_STICKY && (item->flags & ITEM_FLAG_SET)) + && item->id == gDungeon->unk644.unk46) + { + break; + } + } + + if (i == INVENTORY_SIZE) { + DisplayDungeonMessage(0, gUnknown_80FA448, 1); + return; + } + ZeroOutItem(&gTeamInventoryRef->teamItems[i]); + FillInventoryGaps(); + DisplayDungeonMessage(0, gUnknown_80FA2B0, 1); + str = gUnknown_80FA370; + } + else { + if (DisplayDungeonYesNoMessage(0, gUnknown_80FA2F0, 1) != 1) + return; + DisplayDungeonMessage(0, gUnknown_80FA260, 1); + str = gUnknown_80FA36C; + } + + sub_80843BC(entInfo->id); + sub_8042A34(&pokemon->pos); + sub_8068FE0(pokemon,0x21c,0); + sub_804178C(1); + while(1) { + if (DisplayDungeonYesNoMessage(0,str,1) == 1) { + if (DisplayDungeonYesNoMessage(0,gUnknown_80FA394,0) == 1) { + gDungeon->unk4 = 1; + gDungeon->unk11 = 2; + return; + } + } + else if (DisplayDungeonYesNoMessage(0,gUnknown_80FA3B8,0) == 1) { + return; + } + } +} + +void sub_80845E0(Entity *pokemon) +{ + int i; + EntityInfo *info1 = GetEntInfo(pokemon); + Entity *entity = NULL; + EntityInfo *info2 = NULL; + SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],GetLeader(),0); + SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[1],pokemon,0); + if (!sub_8070BC0(pokemon)) { + DisplayDungeonMessage(0,gUnknown_80FA530,1); + return; + } + + for (i = 0; i < MAX_TEAM_MEMBERS; i++) { + Entity *teamMon = gDungeon->teamPokemon[i]; + if (EntityIsValid(teamMon)) { + if (IsExperienceLocked(GetEntInfo(teamMon)->joinedAt.id)) { + entity = teamMon; + info2 = GetEntInfo(teamMon); + break; + } + } + } + if (entity == NULL) { + DisplayDungeonMessage(0,gUnknown_80FA52C,1); + return; + } + + SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[2],entity,0); + if (!sub_8070BC0(entity)) { + DisplayDungeonMessage(0,gUnknown_80FA54C,1); + return; + } + if (!CanSeeTarget(pokemon,entity)) { + DisplayDungeonMessage(0,gUnknown_80FA500,1); + return; + } + + DisplayDungeonMessage(0,gUnknown_80FA4D4,1); + sub_80843BC(info1->id); + info2->joinedAt.id = gDungeon->unk644.dungeonLocation.id; + sub_8042A34(&pokemon->pos); + sub_8042A34(&entity->pos); + sub_8068FE0(pokemon,0x21c,0); + sub_8068FE0(entity,0x21c,0); + sub_804178C(1); + while(1) { + if (DisplayDungeonYesNoMessage(0,gUnknown_80FA4D8,1) == 1) { + if (DisplayDungeonYesNoMessage(0,gUnknown_80FA394,0) == 1) { + gDungeon->unk4 = 1; + gDungeon->unk11 = 2; + return; + } + } + else if (DisplayDungeonYesNoMessage(0,gUnknown_80FA3B8,0) == 1) { + return; + } + } +} + +void sub_8084778(void) +{ + s32 i; + WonderMail *wm; + + InlineStrcpy(gFormatBuffer_Monsters[3], "??????"); + + for (i = 0; i < MAX_ACCEPTED_JOBS; i++) { + wm = GetJobSlotInfo(i); + if (wm->mailType == MAIL_TYPE_TAKEN_JOB && gDungeon->unk644.dungeonLocation.id == wm->unk4.dungeon.id && wm->missionType == WONDER_MAIL_MISSION_TYPE_ESCORT_CLIENT) { + CopyCyanMonsterNametoBuffer(gFormatBuffer_Monsters[3], wm->targetSpecies); + break; + } + } +} diff --git a/src/dungeon_kecleon_shop.c b/src/dungeon_kecleon_shop.c index b4d1e5927..355f8c9d2 100644 --- a/src/dungeon_kecleon_shop.c +++ b/src/dungeon_kecleon_shop.c @@ -2,7 +2,7 @@ #include "globaldata.h" #include "weather.h" #include "code_804267C.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "dungeon.h" #include "dungeon_config.h" #include "dungeon_leader.h" diff --git a/src/dungeon_leader.c b/src/dungeon_leader.c deleted file mode 100644 index 56e1c737b..000000000 --- a/src/dungeon_leader.c +++ /dev/null @@ -1,31 +0,0 @@ -#include "global.h" -#include "structs/str_dungeon.h" -#include "dungeon_leader.h" -#include "dungeon_util.h" - -EWRAM_INIT Entity *gLeaderPointer = NULL; - -Entity* GetLeader(void) -{ - Entity *leader = gLeaderPointer; - if (leader == NULL) - { - s32 i; - for (i = 0; i < MAX_TEAM_MEMBERS; i++) - { - Entity *currentPokemon = gDungeon->teamPokemon[i]; - if (EntityIsValid(currentPokemon) && GetEntInfo(currentPokemon)->isTeamLeader) - { - gLeaderPointer = currentPokemon; - return currentPokemon; - } - } - return NULL; - } - return leader; -} - -EntityInfo* GetLeaderInfo(void) -{ - return GetEntInfo(GetLeader()); -} diff --git a/src/dungeon_main.c b/src/dungeon_main.c index b21dc9381..d6451ee20 100644 --- a/src/dungeon_main.c +++ b/src/dungeon_main.c @@ -14,9 +14,9 @@ #include "code_800D090.h" #include "code_801602C.h" #include "code_801B3C0.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "code_803E724.h" -#include "code_8044CC8.h" +#include "dungeon_action.h" #include "code_8066D04.h" #include "code_806CD90.h" #include "dungeon_action.h" diff --git a/src/dungeon_menu_items.c b/src/dungeon_menu_items.c index 9c88939b4..26b0faf54 100644 --- a/src/dungeon_menu_items.c +++ b/src/dungeon_menu_items.c @@ -16,7 +16,7 @@ #include "dungeon_music.h" #include "dungeon_ai_movement.h" #include "string_format.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "code_803E724.h" #include "trap.h" #include "dungeon_map_access.h" @@ -24,7 +24,7 @@ #include "dungeon_leader.h" #include "menu_input.h" #include "text_1.h" -#include "code_8044CC8.h" +#include "dungeon_action.h" #include "code_801B3C0.h" extern void PlayDungeonCancelSE(void); diff --git a/src/dungeon_menu_moves.c b/src/dungeon_menu_moves.c index 65f54babc..35e18bdc5 100644 --- a/src/dungeon_menu_moves.c +++ b/src/dungeon_menu_moves.c @@ -2,9 +2,9 @@ #include "globaldata.h" #include "structs/map.h" #include "structs/str_dungeon.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "code_803E724.h" -#include "code_8044CC8.h" +#include "dungeon_action.h" #include "dungeon_action.h" #include "dungeon_leader.h" #include "dungeon_main.h" diff --git a/src/dungeon_menu_others.c b/src/dungeon_menu_others.c index 613cfc419..9d4ba3376 100644 --- a/src/dungeon_menu_others.c +++ b/src/dungeon_menu_others.c @@ -1,11 +1,12 @@ #include "global.h" #include "globaldata.h" #include "code_803D110.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "code_803E724.h" -#include "code_8044CC8.h" +#include "dungeon_action.h" #include "code_8097DD0.h" #include "dungeon.h" +#include "dungeon_8083AB0.h" #include "dungeon_action.h" #include "dungeon_leader.h" #include "dungeon_main.h" diff --git a/src/dungeon_menu_recruitment.c b/src/dungeon_menu_recruitment.c index 39ee7cbcc..11a589ed6 100644 --- a/src/dungeon_menu_recruitment.c +++ b/src/dungeon_menu_recruitment.c @@ -1,7 +1,7 @@ #include "global.h" #include "globaldata.h" #include "code_800D090.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "code_803E724.h" #include "dungeon.h" #include "dungeon_menu_recruitment.h" diff --git a/src/dungeon_menu_stairs.c b/src/dungeon_menu_stairs.c index 269b249aa..659356a68 100644 --- a/src/dungeon_menu_stairs.c +++ b/src/dungeon_menu_stairs.c @@ -1,8 +1,8 @@ #include "global.h" #include "globaldata.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "code_803E724.h" -#include "code_8044CC8.h" +#include "dungeon_action.h" #include "code_8097DD0.h" #include "dungeon.h" #include "dungeon_action.h" diff --git a/src/dungeon_menu_team.c b/src/dungeon_menu_team.c index f32bb7e89..a9c2d4ea3 100644 --- a/src/dungeon_menu_team.c +++ b/src/dungeon_menu_team.c @@ -8,9 +8,9 @@ #include "code_800D090.h" #include "code_801602C.h" #include "code_801B3C0.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "code_803E724.h" -#include "code_8044CC8.h" +#include "dungeon_action.h" #include "code_806CD90.h" #include "code_8097DD0.h" #include "dungeon_action.h" diff --git a/src/dungeon_menu_tile.c b/src/dungeon_menu_tile.c index 1079ea36b..32a8b417b 100644 --- a/src/dungeon_menu_tile.c +++ b/src/dungeon_menu_tile.c @@ -1,8 +1,8 @@ #include "global.h" #include "globaldata.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "code_803E724.h" -#include "code_8044CC8.h" +#include "dungeon_action.h" #include "code_8097DD0.h" #include "dungeon.h" #include "dungeon_action.h" diff --git a/src/dungeon_message.c b/src/dungeon_message.c index ff2ae0523..5037cfde9 100644 --- a/src/dungeon_message.c +++ b/src/dungeon_message.c @@ -7,7 +7,7 @@ #include "code_8009804.h" #include "code_800D090.h" #include "code_800E9E4.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "code_803E668.h" #include "code_803E724.h" #include "dungeon.h" @@ -27,6 +27,7 @@ #include "text_2.h" #include "text_3.h" #include "dungeon_strings.h" +#include "dungeon_portrait_placement.h" void sub_80526D0(s32 r0); static bool8 sub_8052DC0(Entity *); @@ -381,14 +382,6 @@ void DisplayDungeonLoggableMessage(Entity *pokemon, const u8 *str) DisplayDungeonLoggableMessageFalse(pokemon, str); } -struct Struct_sub_808CDB0 -{ - DungeonPos pos; - bool8 flip; -}; - -extern const struct Struct_sub_808CDB0 *sub_808CDB0(s32 a0); - static const u16 sUnknownDialogueFlags[] = {0x30D, 0x10D, 0x30D, 0x10D, 0x301, 1, 0x11}; void DisplayDungeonDialogue(const struct DungeonDialogueStruct *dialogueInfo) @@ -465,7 +458,7 @@ void DisplayDungeonDialogue(const struct DungeonDialogueStruct *dialogueInfo) && dialogueInfo->spriteId != 0x80 && dialogueMonId != MONSTER_NONE) { - const struct Struct_sub_808CDB0 *strPtr = sub_808CDB0(dialogueInfo->spritePlacementId); + const struct PortraitPlacementInfo *placementInfo = GetPortraitPlacementInfo(dialogueInfo->spritePlacementId); monPortraitPtr = &monPortrait; monPortraitPtr->faceFile = GetDialogueSpriteDataPtr(dialogueMonId); @@ -473,9 +466,9 @@ void DisplayDungeonDialogue(const struct DungeonDialogueStruct *dialogueInfo) monPortraitPtr->faceData = (PortraitGfx *) monPortraitPtr->faceFile->data; monPortraitPtr->unkE = 0; monPortraitPtr->spriteId = dialogueInfo->spriteId; - monPortraitPtr->flip = strPtr->flip; - monPortraitPtr->pos.x = strPtr->pos.x; - monPortraitPtr->pos.y = strPtr->pos.y; + monPortraitPtr->flip = placementInfo->flip; + monPortraitPtr->pos.x = placementInfo->pos.x; + monPortraitPtr->pos.y = placementInfo->pos.y; if (monPortraitPtr->pos.y < 2) { monPortraitPtr->pos.y = 2; } diff --git a/src/dungeon_message_log.c b/src/dungeon_message_log.c index e9e5729ec..20dce465e 100644 --- a/src/dungeon_message_log.c +++ b/src/dungeon_message_log.c @@ -8,7 +8,7 @@ #include "text_3.h" #include "input.h" #include "menu_input.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "dungeon_music.h" #include "sprite.h" #include "code_803E724.h" diff --git a/src/dungeon_misc.c b/src/dungeon_misc.c index f1a141221..a003d9496 100644 --- a/src/dungeon_misc.c +++ b/src/dungeon_misc.c @@ -38,10 +38,11 @@ #include "dungeon_random.h" #include "position_util.h" #include "dungeon_ai_movement.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "def_filearchives.h" #include "code_803D110.h" #include "dungeon_strings.h" +#include "dungeon_8083AB0.h" static void EnsureCastformLoaded(void); static void EnsureDeoxysLoaded(void); diff --git a/src/dungeon_move.c b/src/dungeon_move.c index b59185341..ed7fb698b 100644 --- a/src/dungeon_move.c +++ b/src/dungeon_move.c @@ -11,14 +11,14 @@ #include "code_800DAC0.h" #include "code_800E9E4.h" #include "code_800ED38.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "code_803E668.h" #include "code_803E724.h" #include "code_8041AD0.h" #include "code_806CD90.h" #include "code_8077274_1.h" #include "code_807CD9C.h" -#include "code_808417C.h" +#include "dungeon_random.h" #include "dungeon_logic.h" #include "dungeon_config.h" #include "run_dungeon.h" diff --git a/src/dungeon_move_util.c b/src/dungeon_move_util.c index b9f104eb5..9bc5b5fe7 100644 --- a/src/dungeon_move_util.c +++ b/src/dungeon_move_util.c @@ -10,14 +10,14 @@ #include "code_800DAC0.h" #include "code_800E9E4.h" #include "code_800ED38.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "code_803E668.h" #include "code_803E724.h" #include "code_8041AD0.h" #include "code_806CD90.h" #include "code_8077274_1.h" #include "code_807CD9C.h" -#include "code_808417C.h" +#include "dungeon_random.h" #include "dungeon_logic.h" #include "dungeon_config.h" #include "run_dungeon.h" diff --git a/src/dungeon_music.c b/src/dungeon_music.c index ff857b99e..01e441e96 100644 --- a/src/dungeon_music.c +++ b/src/dungeon_music.c @@ -1,129 +1,18 @@ #include "global.h" +#include "globaldata.h" #include "constants/bg_music.h" #include "structs/menu.h" -#include "structs/str_dungeon.h" #include "code_80118A4.h" #include "dungeon.h" #include "dungeon_music.h" -#include "dungeon_util.h" #include "music.h" -#include "text_util.h" -#include "dungeon_logic.h" extern MenuInputStruct gDungeonMenu; -extern u8 *gUnknown_80FE6F4[]; -extern u8 gUnknown_810AC60; // 0xC -extern u8 gUnknown_810AC62; // 0xC -extern u8 gUnknown_810AC68; // 0x8 -extern u8 gUnknown_810AC64; // 0x8 -extern u8 gUnknown_810AC66; // 0x8 - // Dungeon Music Player adds in this flag to tell // the system to fade in rather than immediately playing #define DUNGEON_MUSIC_FADE_IN 0x8000 -void sub_8083AB0(s16 param_0, Entity *target, Entity *entity) -{ - u8 *defPtr; - u8 *attackPtr; - u8 *spDefPtr; - EntityInfo * entityInfo; - EntityInfo * targetEntityInfo; - u8 *spAttPtr; - u8 buffer [0x14]; - UnkDungeonGlobal_unk1CE98_sub *temp; - u8 *id; - s32 param_0_s32 = param_0; - - temp = &gDungeon->unk1CE98; - targetEntityInfo = NULL; - if ((EntityIsValid(target)) && (GetEntityType(target) == ENTITY_MONSTER)) { - targetEntityInfo = GetEntInfo(target); - } - entityInfo = GetEntInfo(entity); - if (targetEntityInfo != NULL) { - sub_80709C8(buffer, targetEntityInfo); - CopyStringtoBuffer(temp->buffer1, buffer); - } - else { - CopyStringtoBuffer(temp->buffer1, *gUnknown_80FE6F4); // Someone - } - sub_80709C8(buffer,entityInfo); - CopyStringtoBuffer(temp->buffer2, buffer); - temp->moveID = param_0_s32; - temp->heldItem = entityInfo->heldItem; - temp->exp = entityInfo->exp; - temp->level = entityInfo->level; - temp->maxHPStat = entityInfo->maxHPStat; - temp->atk = entityInfo->atk[0]; - temp->spAtk = entityInfo->atk[1]; - temp->def = entityInfo->def[0]; - temp->spDef = entityInfo->def[1]; - temp->dungeonLocation = gDungeon->unk644.dungeonLocation; - attackPtr = &temp->attBoost; - *attackPtr = 0; - spAttPtr = &temp->spAttBoost; - *spAttPtr = 0; - defPtr = &temp->defBoost; - *defPtr = 0; - spDefPtr = &temp->spDefBoost; - *spDefPtr = 0; - if ((entityInfo->heldItem.flags & ITEM_FLAG_EXISTS) && !(entityInfo->heldItem.flags & ITEM_FLAG_STICKY)) { - id = &entityInfo->heldItem.id; - if (*id == ITEM_POWER_BAND) { - *attackPtr += gUnknown_810AC60; - } - if (*id == ITEM_MUNCH_BELT) { - *attackPtr += gUnknown_810AC68; - } - if (*id == ITEM_SPECIAL_BAND) { - *spAttPtr += gUnknown_810AC62; - } - if (*id == ITEM_MUNCH_BELT) { - *spAttPtr += gUnknown_810AC68; - } - if (*id == ITEM_DEF_SCARF) { - *defPtr += gUnknown_810AC64; - } - if (*id == ITEM_ZINC_BAND) { - *spDefPtr += gUnknown_810AC66; - } - } -} - -bool8 sub_8083C24(void) -{ - UnkDungeonGlobal_unk1CE98_sub *temp = &gDungeon->unk1CE98; - - if (temp->moveID < 0x226) - return TRUE; - - return FALSE; -} - -bool8 sub_8083C50(void) -{ - UnkDungeonGlobal_unk1CE98_sub *temp = &gDungeon->unk1CE98; - - if (temp->moveID == 0x227 || temp->moveID == 0x22A || temp->moveID == 0x228) - return TRUE; - - return FALSE; -} - -bool8 sub_8083C88(u8 param_1) -{ - UnkDungeonGlobal_unk1CE98_sub *temp = &gDungeon->unk1CE98; - - if ((!HasCheckpoint(gDungeon->unk644.dungeonLocation.id) && (gDungeon->unk644.unk18 != 0 || param_1 != 0)) - || temp->moveID != 0x227) { - return TRUE; - } - - return FALSE; -} - void PlayDungeonCursorSE(bool8 checkMenuEntriesCount) { if (!checkMenuEntriesCount || gDungeonMenu.unk1A > 1) diff --git a/src/dungeon_portrait_placement.c b/src/dungeon_portrait_placement.c new file mode 100644 index 000000000..60f3a184e --- /dev/null +++ b/src/dungeon_portrait_placement.c @@ -0,0 +1,34 @@ +#include "global.h" +#include "globaldata.h" +#include "dungeon_portrait_placement.h" + +// Note: this file is not part of overlay5. It's most likely arm9.bin, but I couldn't locate the address + +static const struct PortraitPlacementInfo sDungeonPortraitsInfo[] = { + [0] = {{2, 8}, FALSE}, + [1] = {{12, 5}, FALSE}, + [2] = {{2, 8}, FALSE}, + [3] = {{23, 8}, TRUE}, + [4] = {{7, 8}, FALSE}, + [5] = {{18, 8}, TRUE}, + [6] = {{13, 5}, TRUE}, + [7] = {{2, 8}, TRUE}, + [8] = {{23, 8}, FALSE}, + [9] = {{7, 8}, TRUE}, + [10] = {{18, 8}, FALSE}, + [11] = {{12, 1}, FALSE}, + [12] = {{2, 2}, FALSE}, + [13] = {{23, 2}, TRUE}, + [14] = {{7, 1}, FALSE}, + [15] = {{18, 1}, TRUE}, + [16] = {{13, 1}, TRUE}, + [17] = {{2, 2}, TRUE}, + [18] = {{23, 2}, FALSE}, + [19] = {{7, 1}, TRUE}, + [20] = {{18, 1}, FALSE}, +}; + +const struct PortraitPlacementInfo *GetPortraitPlacementInfo(u8 id) +{ + return &sDungeonPortraitsInfo[id]; +} diff --git a/src/dungeon_pos_data.c b/src/dungeon_pos_data.c index 914137d61..9ea80c42c 100644 --- a/src/dungeon_pos_data.c +++ b/src/dungeon_pos_data.c @@ -1,5 +1,6 @@ #include "global.h" -#include "structs/str_position.h" +#include "globaldata.h" +#include "dungeon_pos_data.h" const DungeonPos gAdjacentTileOffsets[] = { {0, 1}, @@ -562,21 +563,15 @@ static const DungeonPos gUnknown_80F4B30[101] = { {99, 99}, }; -struct Struct80F4CC4 { - const DungeonPos *posArray; - s16 unk4; - s16 unk6; -}; - -const struct Struct80F4CC4 gUnknown_80F4CC4[] = { - {gUnknown_80F4810, 1, 1}, - {gUnknown_80F4B30, 1, 1}, - {gUnknown_80F499C, 1, 1}, - {gUnknown_80F4B30, 1, -1}, - {gUnknown_80F4810, -1, -1}, - {gUnknown_80F4B30, -1, -1}, - {gUnknown_80F499C, -1, -1}, - {gUnknown_80F4B30, -1, 1}, +const struct PositionArrayWithOffsets gUnknown_80F4CC4[NUM_DIRECTIONS] = { + [DIRECTION_SOUTH] = {gUnknown_80F4810, 1, 1}, + [DIRECTION_SOUTHEAST] = {gUnknown_80F4B30, 1, 1}, + [DIRECTION_EAST] = {gUnknown_80F499C, 1, 1}, + [DIRECTION_NORTHEAST] = {gUnknown_80F4B30, 1, -1}, + [DIRECTION_NORTH] = {gUnknown_80F4810, -1, -1}, + [DIRECTION_NORTHWEST] = {gUnknown_80F4B30, -1, -1}, + [DIRECTION_WEST] = {gUnknown_80F499C, -1, -1}, + [DIRECTION_SOUTHWEST] = {gUnknown_80F4B30, -1, 1}, }; const s32 gFaceDirectionIncrements[] = {0, 1, -1, 2, -2, 3, -3, 4, 0, -1, 1, -2, 2, -3, 3, 4}; diff --git a/src/dungeon_random.c b/src/dungeon_random.c index 058e72fc8..decde9674 100644 --- a/src/dungeon_random.c +++ b/src/dungeon_random.c @@ -1,5 +1,12 @@ #include "global.h" +#include "globaldata.h" #include "dungeon_random.h" +#include "constants/ability.h" +#include "constants/iq_skill.h" +#include "structs/dungeon_entity.h" +#include "dungeon_logic.h" +#include "dungeon_random.h" +#include "dungeon_util.h" EWRAM_INIT u32 gDungeonRngState = {1}; EWRAM_INIT u32 gUnknown_203B458 = {1}; @@ -75,3 +82,21 @@ bool8 DungeonRandOutcome_2(s32 percentChance) return FALSE; } +s32 CalculateStatusTurns(Entity *target, const s16 *turnRange, bool8 factorCurerSkills) +{ + s32 numTurns; + + numTurns = DungeonRandRange(turnRange[0],turnRange[1]); + if (EntityIsValid(target) && (GetEntityType(target) == ENTITY_MONSTER) && (factorCurerSkills)) { + if (IQSkillIsEnabled(target, IQ_SELF_CURER) && (numTurns != 0x7f)) { + numTurns /= 2; + } + if (AbilityIsActive(target, ABILITY_NATURAL_CURE) && (numTurns != 0x7f) && (4 < numTurns)) { + numTurns = 5; + } + } + if (numTurns < 1) { + numTurns = 1; + } + return numTurns; +} diff --git a/src/dungeon_range.c b/src/dungeon_range.c index 1c933b0b3..ab1905ade 100644 --- a/src/dungeon_range.c +++ b/src/dungeon_range.c @@ -1,9 +1,18 @@ #include "global.h" +#include "globaldata.h" #include "dungeon_range.h" - +#include "dungeon_leader.h" +#include "dungeon_random.h" +#include "dungeon_logic.h" +#include "dungeon_pos_data.h" +#include "dungeon_util.h" +#include "sprite.h" #include "structs/str_dungeon.h" #include "dungeon_map_access.h" #include "structs/map.h" +#include "structs/str_202ED28.h" + +EWRAM_INIT Entity *gLeaderPointer = NULL; bool8 IsPositionActuallyInSight(DungeonPos *pos1, DungeonPos *pos2) { @@ -137,33 +146,17 @@ bool8 IsTargetTwoTilesAway(DungeonPos *pos1, DungeonPos *pos2) s32 x2; s32 y2; - diff = pos1->x - pos2->x; - if (diff < 0) - { - diff = -diff; - } + diff = abs(pos1->x - pos2->x); if (diff < 2) { - diff = pos1->y - pos2->y; - if (diff < 0) - { - diff = -diff; - } + diff = abs(pos1->y - pos2->y); if (diff < 2) { return TRUE; } } - xDiff = pos1->x - pos2->x; - if (xDiff < 0) - { - xDiff = -xDiff; - } - yDiff = pos1->y - pos2->y; - if (yDiff < 0) - { - yDiff = -yDiff; - } + xDiff = abs(pos1->x - pos2->x); + yDiff = abs(pos1->y - pos2->y); if (yDiff < xDiff) { yDiff = xDiff; @@ -229,3 +222,229 @@ bool8 IsTargetTwoTilesAway(DungeonPos *pos1, DungeonPos *pos2) } return FALSE; } + +bool8 sub_8083568(s32 inX, s32 inY, u8 index) +{ + s32 x = inX - gDungeon->unk181e8.cameraPixelPos.x; + s32 y = inY - gDungeon->unk181e8.cameraPixelPos.y; + + if (x >= -16 && y >= -16 && x <= 255 && y <= 175) + { + SpriteSetX(&gUnknown_202ED28[0][index].sprite, x + gUnknown_202ED28[0][index].pos.x); + SpriteSetY(&gUnknown_202ED28[0][index].sprite, y + gUnknown_202ED28[0][index].pos.y); + + AddSprite(&gUnknown_202ED28[0][index].sprite, 0, NULL, NULL); + return TRUE; + } + else + { + return FALSE; + } +} + +Entity* GetLeader(void) +{ + Entity *leader = gLeaderPointer; + if (leader == NULL) { + s32 i; + for (i = 0; i < MAX_TEAM_MEMBERS; i++) { + Entity *currentPokemon = gDungeon->teamPokemon[i]; + if (EntityIsValid(currentPokemon) && GetEntInfo(currentPokemon)->isTeamLeader) { + gLeaderPointer = currentPokemon; + return currentPokemon; + } + } + return NULL; + } + return leader; +} + +EntityInfo* GetLeaderInfo(void) +{ + return GetEntInfo(GetLeader()); +} + +bool8 sub_8083660(DungeonPos *posDst) +{ + struct PositionU8 positions[DUNGEON_MAX_NUM_TILES]; + s32 yLoop, xLoop; + Entity *leader = GetLeader(); + s32 randX, randY; + s32 i; + s32 x, y; + s32 count = 0; + + for (i = 0; i < 3; i++) { + DungeonPos leaderPos; + + randX = DungeonRandInt(DUNGEON_MAX_SIZE_X); + randY = DungeonRandInt(DUNGEON_MAX_SIZE_Y); + leaderPos = leader->pos; + x = randX; + + for (xLoop = 0; xLoop < DUNGEON_MAX_SIZE_X; xLoop++) { + y = randY; + if (count >= DUNGEON_MAX_NUM_TILES) + break; + + for (yLoop = 0; yLoop < DUNGEON_MAX_SIZE_Y; yLoop++) { + bool8 setPosition = FALSE; + const Tile *tile = GetTile(x, y); + if (count >= DUNGEON_MAX_NUM_TILES) + break; + if (i == 0) { + if (GetTerrainType(tile) == TERRAIN_TYPE_NORMAL + && tile->room != CORRIDOR_ROOM + && tile->object == NULL + && tile->monster == NULL + && (abs(leaderPos.x - x) >= 6 || abs(leaderPos.y - y) >= 6)) + { + setPosition = TRUE; + } + } + // No abs checks + else if (i == 1) { + if (GetTerrainType(tile) == TERRAIN_TYPE_NORMAL + && tile->room != CORRIDOR_ROOM + && tile->object == NULL + && tile->monster == NULL) + { + setPosition = TRUE; + } + } + // No abs checks and no CORRIDOR_ROOM check + else { + if (GetTerrainType(tile) == TERRAIN_TYPE_NORMAL + && tile->object == NULL + && tile->monster == NULL) + { + setPosition = TRUE; + } + } + + if (setPosition) { + positions[count].x = x; + positions[count].y = y; + count++; + } + + if (++y >= DUNGEON_MAX_SIZE_Y) { + y = 0; + } + } + + if (++x >= DUNGEON_MAX_SIZE_X) { + x = 0; + } + } + + if (count != 0) { + s32 posId = DungeonRandInt(count); + posDst->x = positions[posId].x; + posDst->y = positions[posId].y; + return TRUE; + } + } + + return FALSE; +} + +bool8 sub_808384C(DungeonPos *posDst, const DungeonPos *posSrc) +{ + s32 i; + s32 x, y; + const Tile *tile; + + for (i = 0; i < 25; i++) { + if (gUnknown_80F4468[i].x == 99) + break; + + x = gUnknown_80F4468[i].x + posSrc->x; + y = gUnknown_80F4468[i].y + posSrc->y; + tile = GetTile(x, y); + if (!(tile->terrainType & TERRAIN_TYPE_UNK_x800) + && GetTerrainType(tile) == TERRAIN_TYPE_NORMAL + && tile->object == NULL + && tile->monster == NULL) + { + posDst->x = x; + posDst->y = y; + return TRUE; + } + } + + return FALSE; +} + +void sub_80838EC(u8 *a0) +{ + if (*a0 == 0x7F) + return; + if (*a0 != 0) { + *a0 -= 1; + } +} + +void sub_8083904(struct DungeonPos *posDst, struct Entity *entityArg) +{ + struct EntityInfo *info; + s32 xOffset, yOffset; + s32 pokeX, pokeY; + s32 i; + const struct DungeonPos *posArray; + Entity **possibleTargets; + s32 maxTargets; + s32 direction; + + info = GetEntInfo(entityArg); + direction = info->action.direction; + if (CheckVariousStatuses2(entityArg, TRUE)) { + posDst->x = (gAdjacentTileOffsets[direction].x * 3) + entityArg->pos.x; + posDst->y = (gAdjacentTileOffsets[direction].y * 3) + entityArg->pos.y; + } + else if (info->action.itemTargetPosition.x == -1 && info->action.itemTargetPosition.y == -1) { + s32 strId = info->action.direction; + posArray = gUnknown_80F4CC4[strId].posArray; + xOffset = gUnknown_80F4CC4[strId].xOffset; + yOffset = gUnknown_80F4CC4[strId].yOffset; + pokeX = entityArg->pos.x; + pokeY = entityArg->pos.y; + if (gDungeon->decoyIsActive) { + possibleTargets = gDungeon->activePokemon; + maxTargets = DUNGEON_MAX_POKEMON; + } + else if (!info->isNotTeamMember) { + possibleTargets = gDungeon->wildPokemon; + maxTargets = DUNGEON_MAX_WILD_POKEMON; + } + else { + possibleTargets = gDungeon->teamPokemon; + maxTargets = MAX_TEAM_MEMBERS; + } + + while (posArray->x != 99) { + s32 x = pokeX + (xOffset * posArray->x); + s32 y = pokeY + (yOffset * posArray->y); + + for (i = 0; i < maxTargets; i++) { + Entity *entity = possibleTargets[i]; + if (EntityIsValid(entity) + && entity->pos.x == x + && entity->pos.y == y + && GetTreatmentBetweenMonsters(entityArg,entity,FALSE,FALSE) == 1) + { + posDst->x = x; + posDst->y = y; + return; + } + } + posArray++; + } + posDst->x = (gAdjacentTileOffsets[info->action.direction].x * 2) + entityArg->pos.x; + posDst->y = (gAdjacentTileOffsets[info->action.direction].y * 2) + entityArg->pos.y; + } + else { + posDst->x = info->action.itemTargetPosition.x; + posDst->y = info->action.itemTargetPosition.y; + } +} diff --git a/src/code_803E724.c b/src/dungeon_tilemap.c similarity index 52% rename from src/code_803E724.c rename to src/dungeon_tilemap.c index 90fad0fbb..da8ac9eb7 100644 --- a/src/code_803E724.c +++ b/src/dungeon_tilemap.c @@ -1,4 +1,5 @@ #include "global.h" +#include "globaldata.h" #include "constants/item.h" #include "constants/status.h" #include "structs/str_202EDE8.h" @@ -9,7 +10,7 @@ #include "code_8009804.h" #include "code_800E9E4.h" #include "code_801602C.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "code_803E724.h" #include "code_806CD90.h" #include "dungeon.h" @@ -26,38 +27,18 @@ #include "menu_input.h" #include "sprite.h" #include "text_1.h" - -extern s32 gDungeonBrightness; -extern u32 gUnknown_202EDD0; -extern s32 gUnknown_202EDD8; -extern u32 gUnknown_202EDFC; - -struct DungeonPalFile -{ - void *unk0; - const void *unk4; -}; - -extern struct DungeonPalFile *gDungeonPaletteFile; -extern struct DungeonPalFile *gDungeonNameBannerPalette; -extern struct DungeonPalFile *gUnknown_202EC94; -extern RGB gUnknown_202ECA4[]; -extern u8 gUnknown_203B40C; -extern MenuInputStruct gDungeonMenu; -extern SpriteOAM gUnknown_202EDDC; - -extern const u32 gUnknown_80F6490[]; -extern const s32 gUnknown_80F64B4[]; -extern const s32 gUnknown_80F64FC[]; -extern const s32 gUnknown_80F6520[]; -extern const u16 gUnknown_80F64D8[][9]; -extern const u16 gUnknown_80F6544[][9]; +#include "play_time.h" +#include "code_800C9CC.h" +#include "code_80118A4.h" +#include "dungeon_strings.h" extern s32 gDungeonFramesCounter; extern void ShowWholeRevealedDungeonMap(void); extern void sub_80400D4(void); extern void sub_8041888(u8 param_1); +extern void sub_803F7BC(void); +extern void ShowWholeRevealedDungeonMap(); void sub_803EC94(void); s32 sub_803EF90(s32 a0, u8 a1); @@ -68,597 +49,7 @@ void sub_803FB74(void); void sub_803FE30(s32 a0, u16 *a1, bool8 a2, bool8 a3); void sub_803FF18(s32 a0, u16 *a1, bool8 a2); -static const RGB sBlackRgb = {0, 0, 0}; - -void sub_803E874(bool8 r10, s32 r9) -{ - s32 i, index, count; - const RGB *color; - - color = gDungeonPaletteFile->unk4; - SetBGPaletteBufferColorRGB(0, &sBlackRgb, gDungeonBrightness, gDungeon->colorRamp); - color++; - index = 1; - count = 159; - for (i = 0; i < count; i++) { - SetBGPaletteBufferColorRGB(index, color, gDungeonBrightness, gDungeon->colorRamp); - color++; - index++; - } - - if (gDungeon->unk181e8.unk18215 == 0 || gDungeon->unk1BDD4.unk1C06C == 3) { - sub_8004AF0(TRUE, gUnknown_202EE8C, 0xA0, 0x20, gDungeonBrightness, gDungeon->colorRamp); - } - - index += 32; - color = gUnknown_202ECA4; - count = 32; - for (i = 0; i < count; i++) { - SetBGPaletteBufferColorRGB(index, color, gDungeonBrightness, gDungeon->colorRamp); - color++; - index++; - } - - if (r10) { - index = 224; - color = gDungeonNameBannerPalette->unk4; - count = 16; - for (i = 0; i < count; i++) { - SetBGPaletteBufferColorRGB(index, color, r9, NULL); - color++; - index++; - } - } - - SetBGPaletteBufferColorRGB(248, &gFontPalette[8], gDungeonBrightness, NULL); - - color = ((struct DungeonPalFile*) gDungeon->paletFile)->unk4; - index = 256; - count = 208; - for (i = 0; i < count; i++) { - SetBGPaletteBufferColorRGB(index, color, gDungeonBrightness, gDungeon->colorRamp); - nullsub_4(index, color, gDungeonBrightness, NULL); - color++; - index++; - } -} - -void BgColorCallNullsub4(void) -{ - s32 i, index, count; - const RGB *color; - - color = ((struct DungeonPalFile*) gDungeon->paletFile)->unk4; - index = 256; - count = 208; - for (i = 0; i < count; i++) { - nullsub_4(index, color, gDungeonBrightness, NULL); - color++; - index++; - } -} - -void sub_803EA10(void) -{ - s32 i, index, count; - const RGB *color; - - color= gDungeonPaletteFile->unk4; - SetBGPaletteBufferColorRGB(0, &sBlackRgb, gDungeonBrightness, gDungeon->colorRamp); - color++; - index = 1; - count = 159; - for (i = 0; i < count; i++) { - SetBGPaletteBufferColorRGB(index, color, gDungeonBrightness, gDungeon->colorRamp); - color++; - index++; - } - - if (gDungeon->unk181e8.unk18215 == 0 || gDungeon->unk1BDD4.unk1C06C == 3) { - sub_8004AF0(TRUE, gUnknown_202EE8C, 0xA0, 0x20, gDungeonBrightness, gDungeon->colorRamp); - } - - index += 32; - color = gUnknown_202ECA4; - count = 32; - for (i = 0; i < count; i++) { - SetBGPaletteBufferColorRGB(index, color, gDungeonBrightness, gDungeon->colorRamp); - color++; - index++; - } - - SetBGPaletteBufferColorRGB(248, &gFontPalette[8], gDungeonBrightness, NULL); -} - -static const WindowTemplates gUnknown_80F62B0 = -{ - .id = { - [0] = { - .type = WINDOW_TYPE_0, - .pos = {2, 15}, - .width = 26, - .height = 5, - .unk10 = 7, - .unk12 = 0, - .header = NULL, - }, - [1] = WIN_TEMPLATE_DUMMY, - [2] = WIN_TEMPLATE_DUMMY, - [3] = WIN_TEMPLATE_DUMMY, - } -}; - -static const WindowTemplates gUnknown_80F6310 = -{ - .id = { - [0] = { - .type = WINDOW_TYPE_NORMAL, - .pos = {2, 3}, - .width = 6, - .height = 7, - .unk10 = 7, - .unk12 = 0, - .header = NULL, - }, - [1] = WIN_TEMPLATE_DUMMY, - [2] = WIN_TEMPLATE_DUMMY, - [3] = WIN_TEMPLATE_DUMMY, - } -}; - -static const WindowTemplates gUnknown_80F6370 = -{ - .id = { - [0] = { - .type = WINDOW_TYPE_NORMAL, - .pos = {2, 3}, - .width = 6, - .height = 7, - .unk10 = 7, - .unk12 = 0, - .header = NULL, - }, - [1] = { - .type = WINDOW_TYPE_NORMAL, - .pos = {10, 4}, - .width = 17, - .height = 2, - .unk10 = 2, - .unk12 = 0, - .header = NULL, - }, - [2] = { - .type = WINDOW_TYPE_NORMAL, - .pos = {2, 13}, - .width = 26, - .height = 6, - .unk10 = 6, - .unk12 = 0, - .header = NULL, - }, - [3] = WIN_TEMPLATE_DUMMY, - } -}; - -static const WindowTemplates gUnknown_80F63D0 = -{ - .id = { - [0] = { - .type = WINDOW_TYPE_NORMAL, - .pos = {2, 3}, - .width = 26, - .height = 14, - .unk10 = 18, - .unk12 = 2, - .header = NULL, - }, - [1] = WIN_TEMPLATE_DUMMY, - [2] = WIN_TEMPLATE_DUMMY, - [3] = WIN_TEMPLATE_DUMMY, - } -}; - -// kind==8 uses the `name` param. -void sub_803EAF0(u32 kind, u8 *name) -{ - if (kind == gUnknown_202EDD0) - return; - - switch (kind) { - case 1: { - if (gUnknown_203B40C != 0) - sub_8052210(0); - - ResetUnusedInputStruct(); - sub_803EC94(); - ShowWindows(NULL, TRUE, TRUE); - break; - } - case 0: { - sub_803EC94(); - ShowWindows(NULL, TRUE, TRUE); - if (gUnknown_203B40C != 0) { - ShowWholeRevealedDungeonMap(); - UpdateBgTilemapForDungeonMap(FALSE); - } - break; - } - case 3: { - ShowWindows(&gUnknown_80F62B0, TRUE, TRUE); - if (gUnknown_203B40C != 0) - UpdateBgTilemapForDungeonMap(TRUE); - break; - } - case 6: { - if (gUnknown_203B40C != 0) - sub_8052210(0); - - ResetUnusedInputStruct(); - ShowWindows(&gUnknown_80F6310, TRUE, TRUE); - break; - } - case 7: { - if (gUnknown_203B40C != 0) - sub_8052210(0); - - ResetUnusedInputStruct(); - ShowWindows(&gUnknown_80F6370, TRUE, TRUE); - break; - } - case 2: - case 4: { - if (gUnknown_203B40C != 0) - sub_8052210(0); - - ResetUnusedInputStruct(); - sub_803EC94(); - ShowWindows(NULL, TRUE, TRUE); - break; - } - case 5: { - if (gUnknown_203B40C != 0) - sub_8052210(0); - - ShowWindows(NULL, TRUE, TRUE); - break; - } - case 8: { - if (gUnknown_203B40C != 0) { - PlayDungeonStartButtonSE(); - sub_8052210(0); - } - - CreateConfirmNameMenu(2, name); - break; - } - case 9: { - if (gUnknown_203B40C != 0) { - sub_8052210(0); - PlayDungeonStartButtonSE(); - } - - ResetUnusedInputStruct(); - ShowWindows(&gUnknown_80F63D0, FALSE, TRUE); - break; - } - case 10: { - PlayDungeonStartButtonSE(); - break; - } - case 150: { // Dummy case put here to match, any value >= 150 works - break; - } - } - - gUnknown_202EDD0 = kind; -} - -void sub_803EC94(void) -{ - gDungeonMenu.unk1E = 0; - gDungeonMenu.unk20 = 0; - gDungeonMenu.unkC = 0; - gDungeonMenu.unkE = 0; - gDungeonMenu.unk14.x = 0; - sub_801317C(&gDungeonMenu.unk28); -} - -void DungeonShowWindows(WindowTemplates *a0, bool8 a1) -{ - gUnknown_202EDD0 = 10; - sub_8052210(0); - ResetUnusedInputStruct(); - ShowWindows(a0, TRUE, a1); -} - -void sub_803ECE0(void) -{ - gUnknown_202EDD8++; - if (gUnknown_202EDD8 < 0) - gUnknown_202EDD8 = 0; - if (gUnknown_202EDD8 > 11) - gUnknown_202EDD8 = 0; - - sub_80098BC((void *)VRAM + 0x14400, gUnknown_202EC94->unk4 + ((gUnknown_202EDD8 / 4) * 0x240), 0x240); -} - -void sub_803ED30(s32 a0, Entity *mon, u8 a2, s32 a3) -{ - s32 i, var; - - if (a0 == 0 || gDungeon->unk181e8.blinded) - return; - - for (i = 0; i < 20; i++) { - if (gUnknown_202EDE8.unk0 == 0) - break; - DungeonRunFrameActions(0x29); - } - - var = sub_803EF90(a0, a2); - gUnknown_202EDE8.unk0 = 60; - gUnknown_202EDE8.unk4 = mon; - gUnknown_202EDE8.unk8 = mon->spawnGenID; - gUnknown_202EDE8.unkC = -(var * 768); - gUnknown_202EDE8.unk10 = 0; - - if (a3 < 0) { - if (a0 < -999) { - gUnknown_202EDE8.unk2 = 6; - } - else if (a0 >= 0) { - gUnknown_202EDE8.unk2 = 10; - } - else { - gUnknown_202EDE8.unk2 = 3; - } - } - else { - gUnknown_202EDE8.unk2 = a3; - } - - sub_80098BC((void *) VRAM + 0x142C0, gDungeon->unk18, 0x80); -} - -void sub_803EDF0(void) -{ - EntityInfo *entInfo; - s32 x, y, y1, y2; - - if (gUnknown_202EDE8.unk0 == 0) - return; - if (!EntityIsValid(gUnknown_202EDE8.unk4)) { - gUnknown_202EDE8.unk0 = 0; - return; - } - if (gUnknown_202EDE8.unk8 != gUnknown_202EDE8.unk4->spawnGenID) { - gUnknown_202EDE8.unk0 = 0; - return; - } - - gUnknown_202EDE8.unk0--; - gUnknown_202EDE8.unk10 -= 46; - entInfo = GetEntInfo(gUnknown_202EDE8.unk4); - x = (entInfo->pixelPos.x + (gUnknown_202EDE8.unkC / 256)) - gDungeon->unk181e8.cameraPixelPos.x; - y1 = (entInfo->pixelPos.y + (gUnknown_202EDE8.unk10 / 256)); - y2 = (gDungeon->unk181e8.cameraPixelPos.y + 24); - y = y1 - y2; - - // sprite oam memes strike again - if (x >= -32 && y >= -8 && x < 240 && y < 160) { - SpriteSetY(&gUnknown_202EDDC, y); - SpriteSetAffine1(&gUnknown_202EDDC, 0); - SpriteSetAffine2(&gUnknown_202EDDC, 0); - SpriteSetObjMode(&gUnknown_202EDDC, 0); - SpriteSetMosaic(&gUnknown_202EDDC, 0); - SpriteSetBpp(&gUnknown_202EDDC, 0); - SpriteSetShape(&gUnknown_202EDDC, 1); - SpriteSetX(&gUnknown_202EDDC, x); - SpriteSetMatrixNum(&gUnknown_202EDDC, 0); - SpriteSetSize(&gUnknown_202EDDC, 1); - SpriteSetTileNum(&gUnknown_202EDDC, 0x216); - SpriteSetPriority(&gUnknown_202EDDC, gDungeon->unk181e8.priority); - SpriteSetPalNum(&gUnknown_202EDDC, gUnknown_202EDE8.unk2); - - SpriteSetUnk6_0(&gUnknown_202EDDC, 0); - SpriteSetUnk6_1(&gUnknown_202EDDC, 0); - SpriteSetUnk6_2(&gUnknown_202EDDC, 0); - - AddSprite(&gUnknown_202EDDC, 0x100, NULL, NULL); - } -} - -extern OpenedFile *gUnknown_202EC9C; - -static const s32 gUnknown_80F6430[][9] = -{ - [0] = {900, 800, 700, 600, 500, 400, 300, 200, 100}, - [1] = {90, 80, 70, 60, 50, 40, 30, 20, 10}, -}; - -s32 sub_803EF90(s32 a0, u8 a1) -{ - s32 i, id; - const u32 *r2; - s32 bitsNo; - s32 ret; - bool8 unkBool; - u32 *mainDst = gDungeon->unk18; - u32 *sp[] = {(u32 *)(gUnknown_202EC9C->data + 0x124), - (u32 *)(gUnknown_202EC9C->data + 0x104), - (u32 *)(gUnknown_202EC9C->data + 0xE4), - (u32 *)(gUnknown_202EC9C->data + 0xC4), - (u32 *)(gUnknown_202EC9C->data + 0xA4), - (u32 *)(gUnknown_202EC9C->data + 0x84), - (u32 *)(gUnknown_202EC9C->data + 0x64), - (u32 *)(gUnknown_202EC9C->data + 0x44), - (u32 *)(gUnknown_202EC9C->data + 0x24)}; - s32 dstId = 0; - u32 *clearDst = mainDst; - for (i = 0; i < 4; i++) { - clearDst[dstId++] = 0; - clearDst[dstId++] = 0; - clearDst[dstId++] = 0; - clearDst[dstId++] = 0; - clearDst[dstId++] = 0; - clearDst[dstId++] = 0; - clearDst[dstId++] = 0; - clearDst[dstId++] = 0; - } - - if (a0 == 9999) { - u32 r12[] = {13, 14, 15, 15}; - - bitsNo = 0; - for (id = 0; id < 4; id++) { - u32 *dst = mainDst; - const u32 *src = (u32 *)((&((u8 *)gUnknown_202EC9C->data)[4] + r12[id] * 32)); - - for (i = 0; i < 8; i++) { - u32 toOr1, toOr2; - if (bitsNo == 0) { - toOr1 = 0; - toOr2 = *src; - } - else { - toOr1 = *src >> (32 - bitsNo); - toOr2 = *src << bitsNo; - } - - src++; - dst[0] |= toOr2; - dst[8] |= toOr1; - dst++; - } - - bitsNo += 24; - if (bitsNo >= 32) { - bitsNo -= 32; - mainDst += 8; - } - } - - return 4; - } - - if (a0 > 999) a0 = 999; - if (a0 < -999) a0 = -999; - - r2 = (u32 *)((u8 *)gUnknown_202EC9C->data + 0x184); - if (a1) { - if (a0 > 0) { - r2 = (u32 *)((u8 *)gUnknown_202EC9C->data + 0x144); - } - else if (a0 < 0) { - r2 = (u32 *)((u8 *)gUnknown_202EC9C->data + 0x164); - a0 = -a0; - } - } - - mainDst[0] = *r2++; - mainDst[1] = *r2++; - mainDst[2] = *r2++; - mainDst[3] = *r2++; - mainDst[4] = *r2++; - mainDst[5] = *r2++; - mainDst[6] = *r2++; - mainDst[7] = *r2++; - - bitsNo = 24; - ret = 1; - unkBool = FALSE; - for (id = 0; id < 2; id++) { - s32 arrId; - - for (arrId = 0; arrId < 9; arrId++) { - if (gUnknown_80F6430[id][arrId] <= a0) { - const u32 *src = sp[arrId]; - u32 *dst = mainDst; - - for (i = 0; i < 8; i++) { - u32 toOr1, toOr2; - if (bitsNo == 0) { - toOr1 = 0; - toOr2 = *src; - } - else { - toOr1 = *src >> (32 - bitsNo); - toOr2 = *src << bitsNo; - } - - src++; - dst[0] |= toOr2; - dst[8] |= toOr1; - dst++; - unkBool = TRUE; - } - - bitsNo += 24; - if (bitsNo >= 32) { - bitsNo -= 32; - mainDst += 8; - } - - a0 -= gUnknown_80F6430[id][arrId]; - ret++; - break; - } - } - - if (arrId == 9 && unkBool) { - const u32 *src = (u32 *)(&((u8 *)gUnknown_202EC9C->data)[4]); - u32 *dst = mainDst; - for (i = 0; i < 8; i++) { - u32 toOr1, toOr2; - if (bitsNo == 0) { - toOr1 = 0; - toOr2 = *src; - } - else { - toOr1 = *src >> (32 - bitsNo); - toOr2 = *src << bitsNo; - } - - src++; - dst[0] |= toOr2; - dst[8] |= toOr1; - dst++; - } - - bitsNo += 24; - if (bitsNo >= 32) { - bitsNo -= 32; - mainDst += 8; - } - - ret++; - } - } - - { - const u32 *src = (u32 *)(&((u8 *)gUnknown_202EC9C->data)[4] + (a0 * 32)); - u32 *dst = mainDst; - for (i = 0; i < 8; i++) { - u32 toOr1, toOr2; - if (bitsNo == 0) { - toOr1 = 0; - toOr2 = *src; - } - else { - toOr1 = *src >> (32 - bitsNo); - toOr2 = *src << bitsNo; - } - - src++; - dst[0] |= toOr2; - dst[8] |= toOr1; - dst++; - } - } - - ret++; - return ret; -} +static EWRAM_DATA u32 gUnknown_202EDFC = 0; void sub_803F27C(bool8 a0) { @@ -1026,10 +417,9 @@ void sub_803FA4C(s32 a0, s32 a1, bool8 a2) s32 i; s32 r5; u32 r10, r9; - u32 sp[9]; UnkDungeonGlobal_unk181E8_sub *strPtr = &gDungeon->unk181e8; u32 *dst = gUnknown_3001018; - memcpy(sp, gUnknown_80F6490, sizeof(sp)); + u32 sp[9] = {0, 0xF, 0xFF, 0xFFF, 0xFFFF, 0xFFFFF, 0xFFFFFF, 0xFFFFFFF, 0xFFFFFFFF}; r10 = 0x22222222; r9 = 0x44444444; @@ -1205,6 +595,12 @@ void sub_803FB74(void) } } +static const s32 gUnknown_80F64B4[] = {90, 80, 70, 60, 50, 40, 30, 20, 10}; +static const u16 gUnknown_80F64D8[][9] = { + [0] = {0xF291, 0xF290, 0xF28F, 0xF28E, 0xF28D, 0xF28C, 0xF28B, 0xF28A, 0xF289}, + [1] = {0xF2C8, 0xF2C7, 0xF2C6, 0xF2C5, 0xF2C4, 0xF2C3, 0xF2C2, 0xF2C1, 0xF2C0}, +}; + void sub_803FE30(s32 a0, u16 *a1, bool8 a2, bool8 a3) { s32 var = (a2) ? 0 : 55; @@ -1218,11 +614,15 @@ void sub_803FE30(s32 a0, u16 *a1, bool8 a2, bool8 a3) a1[0] = 0xF2C8; a1[1] = 0xF2C8; } + return; } - else if (a0 == 100) { + + if (a0 == 100) { a1[0] = 0xF294; a1[1] = 0xF295; + return; } + // This is a fakematch, I was actually to decompile this function for Blue(https://decomp.me/scratch/tqonk), but agbcc doesn't want to cooperate... else { // I thought 'ptr' was a compiler generated variable, but I couldn't match the function without declaring it. u16 *ptr = a1 + 1; @@ -1232,7 +632,7 @@ void sub_803FE30(s32 a0, u16 *a1, bool8 a2, bool8 a3) s32 i; s32 arrId = (!a2) ? 1 : 0; - for (i = 0; i < 9; i++) { + for (i = 0; i < ARRAY_COUNT_INT(gUnknown_80F64B4); i++) { ASM_MATCH_TRICK(a1); if (gUnknown_80F64B4[i] <= a0) { *a1 = gUnknown_80F64D8[arrId][i]; @@ -1249,6 +649,13 @@ void sub_803FE30(s32 a0, u16 *a1, bool8 a2, bool8 a3) } } +static const s32 gUnknown_80F64FC[] = {900, 800, 700, 600, 500, 400, 300, 200, 100}; +static const s32 gUnknown_80F6520[] = {90, 80, 70, 60, 50, 40, 30, 20, 10}; +static const u16 gUnknown_80F6544[][9] = { + [0] = {0xF291, 0xF290, 0xF28F, 0xF28E, 0xF28D, 0xF28C, 0xF28B, 0xF28A, 0xF289}, + [1] = {0xF2C8, 0xF2C7, 0xF2C6, 0xF2C5, 0xF2C4, 0xF2C3, 0xF2C2, 0xF2C1, 0xF2C0}, +}; + void sub_803FF18(s32 a0, u16 *a1, bool8 a2) { s32 arrId = (!a2) ? 1 : 0; @@ -1265,7 +672,7 @@ void sub_803FF18(s32 a0, u16 *a1, bool8 a2) s32 i = 0; s32 varAdd = var + 48; - for (i = 0; i < 9; i++) { + for (i = 0; i < ARRAY_COUNT_INT(gUnknown_80F64FC); i++) { if (gUnknown_80F64FC[i] <= a0) { *(a1++) = gUnknown_80F6544[arrId][i]; a0 -= gUnknown_80F64FC[i]; @@ -1277,7 +684,7 @@ void sub_803FF18(s32 a0, u16 *a1, bool8 a2) *(a1++) = (toAdd + 0x258) | 0xF000; } - for (i = 0; i < 9; i++) { + for (i = 0; i < ARRAY_COUNT_INT(gUnknown_80F6520); i++) { if (gUnknown_80F6520[i] <= a0) { *(a1++) = gUnknown_80F6544[arrId][i]; a0 -= gUnknown_80F6520[i]; @@ -1291,3 +698,55 @@ void sub_803FF18(s32 a0, u16 *a1, bool8 a2) *a1 = (a0 + varAdd + 0x258) | 0xF000; } } + +void HandleLuminousOrbAction(Entity *pokemon) +{ + int XCoord; + int YCoord; + + gDungeon->unk181e8.allTilesRevealed = TRUE; + + for(YCoord = 0; YCoord < DUNGEON_MAX_SIZE_Y; YCoord++) + { + for(XCoord = 0; XCoord < DUNGEON_MAX_SIZE_X; XCoord++) + { + Tile *mapTile = GetTileMut(XCoord, YCoord); + mapTile->spawnOrVisibilityFlags |= VISIBILITY_FLAG_REVEALED; + } + } + sub_803F580(0); + sub_8049ED4(); + ShowWholeRevealedDungeonMap(); + LogMessageByIdWithPopupCheckUser(pokemon, gUnknown_80FD040); +} + +void sub_8040094(u8 r0) +{ + gDungeon->unk181e8.unk18217 = r0; + sub_803F7BC(); + sub_80060EC(); + IncrementPlayTime(gPlayTimeRef); + WaitForNextFrameAndAdvanceRNG(); + LoadBufferedInputs(); + xxx_call_update_bg_sound_input(); + UpdateDungeonMusic(); + sub_8011860(); +} + +static const s32 gUnknown_80F6568[] = { + 0, -1, 1, -1, 1, -1, 1, -2, 1, -2, 2, -2, 2, -2, 2, -3, 3, -3, 3, -3, 4, -4, 4, -4, 4, -5, 4, -5, 4, -5, 4, -5 +}; + +void sub_80400D4(void) +{ + s32 temp; + temp = gDungeon->unk181e8.unk18200; + if(temp == 0) + return; + if(temp >= 0x1F) + temp = 0x1F; + gDungeon->unk181e8.unk181FC = gUnknown_80F6568[temp]; + gDungeon->unk181e8.unk18200--; + if(gDungeon->unk181e8.unk18200 == 0) + gDungeon->unk181e8.unk18200 = gDungeon->unk181e8.unk18204; +} diff --git a/src/dungeon_util.c b/src/dungeon_util.c index e54d23143..6e5fc9220 100644 --- a/src/dungeon_util.c +++ b/src/dungeon_util.c @@ -27,15 +27,15 @@ #include "items.h" #include "trap.h" -extern u8 gUnknown_202EE70[MAX_TEAM_BODY_SIZE]; -extern u8 gUnknown_202EE76[DUNGEON_MAX_WILD_POKEMON_BODY_SIZE]; - extern const u8 *gUnknown_80FE6F4[]; extern void sub_8045ACC(void); extern s32 GetMonsterApparentID(Entity *pokemon, s32 id); extern void sub_8045BF8(u8 *, Item *); +EWRAM_DATA u8 gUnknown_202EE70[MAX_TEAM_BODY_SIZE] = {0}; +EWRAM_DATA u8 gUnknown_202EE76[DUNGEON_MAX_WILD_POKEMON_BODY_SIZE] = {0}; + bool8 EntityIsValid(Entity *entity) { if (!entity) diff --git a/src/dungeon_util_1.c b/src/dungeon_util_1.c deleted file mode 100644 index ef2df02e7..000000000 --- a/src/dungeon_util_1.c +++ /dev/null @@ -1,451 +0,0 @@ -#include "global.h" -#include "dungeon_util_1.h" -#include "dungeon_misc.h" -#include "code_803E46C.h" -#include "code_803E668.h" -#include "code_806CD90.h" -#include "constants/direction.h" -#include "constants/dungeon.h" -#include "code_80861A8.h" -#include "dungeon_leader.h" -#include "dungeon_util.h" -#include "random.h" -#include "math.h" -#include "structs/str_dungeon.h" - -extern s32 gUnknown_202F3D8; -extern const u8 gUnknown_8107358[25]; - -extern s32 GetCameraXPos(void); -extern s32 GetCameraYPos(void); -extern void sub_803F4A0(u32); -extern void sub_803F878(s32, s32); - -Entity *xxx_call_GetLeader(void) -{ - return GetLeader(); -} - -Entity *GetPartnerEntity(void) -{ - s32 counter; - Entity *entity; - for(counter = 0; counter < MAX_TEAM_MEMBERS; counter++) - { - entity = gDungeon->teamPokemon[counter]; - if(EntityIsValid(entity) && GetEntInfo(entity)->joinedAt.id == DUNGEON_JOIN_LOCATION_PARTNER) - { - return entity; - } - } - return GetEntityFromMonsterBehavior(BEHAVIOR_ALLY); -} - -void sub_80854D4(void) -{ - Entity *stack1[MAX_TEAM_MEMBERS]; - Entity *stack2[MAX_TEAM_MEMBERS]; - s32 counter = 0; - s32 index; - Entity *entity; - Entity *entity2; - Entity *entity3; - Entity *entity4; - Entity *entity5; - - for(index = 0; index < MAX_TEAM_MEMBERS; index++) - { - entity = gDungeon->teamPokemon[index]; - if(EntityIsValid(entity)) - { - stack1[counter] = entity; - counter++; - } - } - for(; counter < MAX_TEAM_MEMBERS; counter++) - { - stack1[counter] = NULL; - } - counter = 0; - for(index = 0; index < MAX_TEAM_MEMBERS; index++) - { - entity2 = stack1[index]; - if(entity2 != NULL && GetEntInfo(entity2)->isTeamLeader) - { - stack1[index] = NULL; - stack2[counter] = entity2; - counter++; - } - } - for(index = 0; index < MAX_TEAM_MEMBERS; index++) - { - entity3 = stack1[index]; - if(entity3 != NULL && GetEntInfo(entity3)->joinedAt.id == DUNGEON_JOIN_LOCATION_PARTNER) - { - stack1[index] = NULL; - stack2[counter] = entity3; - counter++; - } - } - for(index = 0; index < MAX_TEAM_MEMBERS; index++) - { - entity4 = stack1[index]; - if(entity4 != NULL) - { - stack1[index] = NULL; - stack2[counter] = entity4; - counter++; - } - } - for(; counter < MAX_TEAM_MEMBERS; counter++) - { - stack2[counter] = NULL; - } - for(index = 0; index < MAX_TEAM_MEMBERS; index++) - { - entity5 = stack2[index]; - if(entity5 != NULL) - sub_80856C8(entity5, gDungeon->unkE220[index].x, gDungeon->unkE220[index].y); - } -} - -void sub_80855E4(DungeonCallback func) -{ - bool8 flag; - Entity * entity; - Entity * partnerEntity; - s32 index; - - flag = FALSE; - for(index = 0; index < MAX_TEAM_MEMBERS; index++) - { - entity = gDungeon->teamPokemon[index]; - if (EntityIsValid(entity)) { - if (GetEntInfo(entity)->joinedAt.id == DUNGEON_JOIN_LOCATION_PARTNER) { - flag = TRUE; - } - func(entity); - } - } - if ((!flag) && (partnerEntity = GetPartnerEntity(), partnerEntity != NULL)) { - func(partnerEntity); - } -} - -void sub_808563C(DungeonCallback func) -{ - Entity * entity; - s32 index; - - for(index = 0; index < DUNGEON_MAX_WILD_POKEMON; index++) - { - entity = gDungeon->wildPokemon[index]; - if ((EntityIsValid(entity)) && (GetEntInfo(entity)->joinedAt.id != 0x41)) { - func(entity); - } - } -} - -Entity *GetEntityFromMonsterBehavior(u8 entityType) -{ - Entity * entity; - s32 index; - - for(index = 0; index < DUNGEON_MAX_POKEMON; index++) - { - entity = gDungeon->activePokemon[index]; - if ((EntityIsValid(entity)) && (GetEntInfo(entity)->monsterBehavior == entityType)) return entity; - } - return NULL; -} - -void sub_80856C8(Entity * pokemon, s32 x, s32 y) -{ - sub_80694C0(pokemon, x, y, 1); - sub_804535C(pokemon,NULL); -} - -void sub_80856E0(Entity * pokemon, s32 direction) -{ - EntityInfo *entityInfo; - s32 counter; - - entityInfo = GetEntInfo(pokemon); - sub_80861D4(pokemon, 6, direction); - - for(counter = 0; counter < 5; counter++) - { - entityInfo->unk174 = F248_Add(entityInfo->unk174, IntToF248(2)); - DungeonRunFrameActions(0x46); - } - entityInfo->action.direction = direction & DIRECTION_MASK; - sub_806CE68(pokemon, direction); - - for(counter = 0; counter < 5; counter++) - { - entityInfo->unk174 = F248_Sub(entityInfo->unk174, IntToF248(2)); - DungeonRunFrameActions(0x46); - } - entityInfo->unk174.raw = 0; // weird one that doesn't match with struct assignment - DungeonRunFrameActions(0x46); -} - -void sub_8085764(void) -{ - Entity *entity; - s32 index; - Entity stackEntity; - - sub_80457DC(&stackEntity); - for(index = 0; index < DUNGEON_MAX_WILD_POKEMON; index++) - { - entity = gDungeon->wildPokemon[index]; - if ((EntityIsValid(entity)) && (GetEntInfo(entity)->monsterBehavior == BEHAVIOR_ALLY)) { - sub_8068FE0(entity,0x207,&stackEntity); - } - } -} - -void sub_80857B8(void) -{ - u8 *direction; - EntityInfo *entityInfo; - Entity *entity; - int index; - - for(index = 0; index < DUNGEON_MAX_POKEMON; index++) - { - entity = gDungeon->activePokemon[index]; - if (EntityIsValid(entity)) { - entityInfo = GetEntInfo(entity); - if ((gDungeon->unk4 == 0) && (gDungeon->unk2 == 0)) { - sub_804535C(entity, 0); - entityInfo->unk15C = 0; - entityInfo->unkFE = 99; - direction = &entityInfo->action.direction; - entityInfo->targetPos.x = gAdjacentTileOffsets[*direction].x + entity->pos.x; - entityInfo->targetPos.y = gAdjacentTileOffsets[*direction].y + entity->pos.y; - sub_806CE68(entity,*direction); - } - } - } -} - -void sub_8085860(s32 x, s32 y) -{ - sub_803F4A0(0); - sub_803F878(X_POS_TO_PIXELPOS(x), Y_POS_TO_PIXELPOS(y)); -} - -void sub_8085890(s32 x, s32 y) -{ - sub_803F4A0(0); - sub_803F878(x, y); -} - -void ShiftCameraToPosition(PixelPos *posStruct, s32 cameraSteps) -{ - s32 XPos; - s32 YPos; - s32 XIncrement; - s32 YIncrement; - - XPos = GetCameraXPos(); - YPos = GetCameraYPos(); - XIncrement = (posStruct->x - XPos) / cameraSteps; - YIncrement = (posStruct->y - YPos) / cameraSteps; - sub_803F4A0(0); - if (0 < cameraSteps) { - do { - XPos += XIncrement; - YPos += YIncrement; - sub_803F878(XPos,YPos); - DungeonRunFrameActions(0x46); - cameraSteps--; - } while (cameraSteps != 0); - } - sub_803F878(posStruct->x,posStruct->y); - DungeonRunFrameActions(0x46); -} - -void SetFacingDirection(Entity *pokemon, s32 direction) -{ - GetEntInfo(pokemon)->action.direction = direction & DIRECTION_MASK; - sub_806CE68(pokemon, direction); -} - -void sub_8085930(s32 direction) -{ - s32 index; - Entity *entity; - for(index = 0; index < MAX_TEAM_MEMBERS; index++) - { - entity = gDungeon->teamPokemon[index]; - if(EntityIsValid(entity)) - { - if(direction >= NUM_DIRECTIONS) - { - sub_806CE68(entity, RandInt(NUM_DIRECTIONS)); - } - else - { - GetEntInfo(entity)->action.direction = direction & DIRECTION_MASK; - sub_806CE68(entity, direction); - } - } - } - for(index = 0; index < DUNGEON_MAX_WILD_POKEMON; index++) - { - entity = gDungeon->wildPokemon[index]; - if(EntityIsValid(entity)) - { - if(GetEntInfo(entity)->monsterBehavior == BEHAVIOR_ALLY) - { - if(direction >= NUM_DIRECTIONS) - { - sub_806CE68(entity, RandInt(NUM_DIRECTIONS)); - } - else - { - GetEntInfo(entity)->action.direction = direction & DIRECTION_MASK; - sub_806CE68(entity, direction); - } - } - } - } -} - -void sub_80859F0(s32 direction) -{ - s32 index; - Entity *entity; - for(index = 0; index < DUNGEON_MAX_WILD_POKEMON; index++) - { - entity = gDungeon->wildPokemon[index]; - if(EntityIsValid(entity)) - { - if(direction >= NUM_DIRECTIONS) - { - sub_806CE68(entity, RandInt(NUM_DIRECTIONS)); - } - else - { - GetEntInfo(entity)->action.direction = direction & DIRECTION_MASK; - sub_806CE68(entity, direction); - } - } - } -} - -bool8 ShouldRunMonsterAI(Entity *pokemon) -{ - EntityInfo *pokemonInfo = GetEntInfo(pokemon); - switch (pokemonInfo->monsterBehavior) - { - case BEHAVIOR_RESCUE_TARGET: - case BEHAVIOR_SKARMORY: - case BEHAVIOR_GENGAR: - case BEHAVIOR_EKANS: - case BEHAVIOR_MEDICHAM: - case BEHAVIOR_ZAPDOS: - case BEHAVIOR_MOLTRES: - case BEHAVIOR_ARTICUNO: - case BEHAVIOR_GROUDON_2: - case BEHAVIOR_RAYQUAZA: - case BEHAVIOR_MANKEY: - case BEHAVIOR_MEWTWO: - case BEHAVIOR_ENTEI: - case BEHAVIOR_RAIKOU: - case BEHAVIOR_SUICUNE: - case BEHAVIOR_HO_OH: - case BEHAVIOR_LATIOS: - case BEHAVIOR_REGIROCK: - case BEHAVIOR_REGICE: - case BEHAVIOR_REGISTEEL: - case BEHAVIOR_JIRACHI: - case BEHAVIOR_LUGIA: - case BEHAVIOR_KYOGRE: - case BEHAVIOR_29: - case BEHAVIOR_CELEBI: - case BEHAVIOR_SMEARGLE: - case BEHAVIOR_32: - case BEHAVIOR_33: - case BEHAVIOR_34: - case BEHAVIOR_35: - case BEHAVIOR_MAZE_BOSS: - return TRUE; - case BEHAVIOR_FIXED_ENEMY: - case BEHAVIOR_ALLY: - case BEHAVIOR_DIGLETT: - case BEHAVIOR_ALAKAZAM_1: - case BEHAVIOR_GROUDON_1: - case BEHAVIOR_ALAKAZAM_2: - default: - return FALSE; - } -} - -void sub_8085B0C(Entity *pokemon) -{ - s32 index; - u8 local_28 [25]; - - index = 0; - - memcpy(local_28, gUnknown_8107358, 25); - while (local_28[index] != 0) { - SetFacingDirection(pokemon, local_28[index]); - sub_803E708(6,0x46); - index++; - } -} - -void sub_8085B4C(struct_8085B80 a0[], s16 *a1[], Entity *a2[], s32 a3) -{ - s32 i; - - gUnknown_202F3D8 = a3; - - for (i = 0; i < a3; i++) { - a0[i].unk0 = 1; - a0[i].unk4 = a2[i]; - a0[i].unkC = a1[i]; - a0[i].unk8 = a1[i][2]; - } -} - -bool8 sub_8085B80(struct_8085B80 *a0) -{ - s16 *unkCPtr; - int i; - bool8 ret = FALSE; - - for (i = 0; i < gUnknown_202F3D8; i++) { - Entity *entity = a0[i].unk4; - EntityInfo *enInfo = GetEntInfo(entity); - unkCPtr = a0[i].unkC; - if (a0[i].unk0 != 0) { - ret = TRUE; - if (a0[i].unk8 == 0) { - unkCPtr = unkCPtr + 4; - if (unkCPtr[2] == 0) { - a0[i].unk0 = 0; - enInfo->action.direction = unkCPtr[0] & DIRECTION_MASK; - sub_806CDD4(entity, 7, unkCPtr[0]); - sub_80856C8(entity, unkCPtr[5], unkCPtr[6]); - continue; - } - a0[i].unk8 = unkCPtr[2]; - a0[i].unkC = unkCPtr; - enInfo->action.direction = unkCPtr[0] & DIRECTION_MASK; - sub_806CDD4(entity, 0, (int)*unkCPtr); - } - - a0[i].unk8--; - IncreaseEntityPixelPos(entity, - gAdjacentTileOffsets[*unkCPtr].x * unkCPtr[1] * 0x100, - gAdjacentTileOffsets[*unkCPtr].y * unkCPtr[1] * 0x100); - } - } - return ret; -} diff --git a/src/dungeon_vram.c b/src/dungeon_vram.c new file mode 100644 index 000000000..cd749cc00 --- /dev/null +++ b/src/dungeon_vram.c @@ -0,0 +1,952 @@ +#include "global.h" +#include "globaldata.h" +#include "dungeon_vram.h" +#include "structs/str_dungeon.h" +#include "bg_control.h" +#include "bg_palette_buffer.h" +#include "code_8004AA0.h" +#include "code_800558C.h" +#include "code_8009804.h" +#include "code_800C9CC.h" +#include "code_80118A4.h" +#include "code_803E668.h" +#include "code_803E724.h" +#include "dungeon_map.h" +#include "dungeon_music.h" +#include "game_options.h" +#include "input.h" +#include "play_time.h" +#include "sprite.h" +#include "text_1.h" +#include "text_2.h" +#include "structs/str_202ED28.h" +#include "structs/str_202EDE8.h" +#include "dungeon_map.h" +#include "dungeon_map_access.h" +#include "dungeon_message.h" +#include "dungeon_music.h" +#include "dungeon_logic.h" +#include "dungeon_range.h" +#include "dungeon_util.h" +#include "menu_input.h" +#include "code_801602C.h" + +// File split is correct. This technical file deals with windows, advancing frames(v-blanks) and vram / pal set-up. + +struct DungeonPalFile +{ + void *unk0; + const void *unk4; +}; + +extern struct DungeonPalFile *gDungeonPaletteFile; +extern struct DungeonPalFile *gDungeonNameBannerPalette; +extern struct DungeonPalFile *gUnknown_202EC94; +extern RGB gUnknown_202ECA4[]; +extern MenuInputStruct gDungeonMenu; +extern OpenedFile *gUnknown_202EC9C; + +void xxx_draw_string_80524F0(void); +void sub_8085F78(void); +void sub_803F580(s32); +void sub_806CC10(); +void sub_804522C(); +void sub_803F9CC(); +void sub_803ECE0(); +void sub_803EDF0(); +void sub_800E90C(); +void sub_8042E5C(); +void sub_800F7D0(DungeonPos *); + +static void sub_803E490(u32); +static s32 sub_803EF90(s32 a0, u8 a1); +static void sub_803EC94(void); +void sub_803E874(bool8 r10, s32 r9); + +EWRAM_DATA struct unkStruct_202ED28 gUnknown_202ED28[2][6] = {0}; +EWRAM_DATA SpriteOAM gUnknown_202EDB8 = {0}; +EWRAM_DATA SpriteOAM gUnknown_202EDC0 = {0}; +EWRAM_DATA s32 gDungeonBrightness = 0; +EWRAM_DATA s32 gDungeonFramesCounter = 0; +EWRAM_DATA s32 gUnknown_202EDD0 = 0; +EWRAM_DATA s32 gUnknown_202EDD4 = 0; +EWRAM_DATA s32 gUnknown_202EDD8 = 0; +static EWRAM_DATA SpriteOAM gUnknown_202EDDC = {0}; +UNUSED static EWRAM_DATA s32 sUnused = 0; +EWRAM_DATA struct UnkStruct_202EDE8 gUnknown_202EDE8 = {0}; + +EWRAM_INIT u8 gUnknown_203B40C = 0; +EWRAM_INIT u8 gUnknown_203B40D = 0; + +static const DungeonPos gUnknown_80F61EC[2][6] = { + [0] = {{-4, -4}, {-8, -4}, {-16, -4}, {-16, -4}, {-16, -4}, {-16, -4}}, + [1] = {{-4, -4}, {-8, -4}, {-16, -8}, {-16, -8}, {-16, -8}, {-16, -8}}, +}; + +struct SpriteInfo +{ + s32 shape; + s32 size; + s32 tileNum; +}; + +static const struct SpriteInfo gUnknown_80F621C[2][6] = { + [0] = {{0, 0, 0x200}, {1, 0, 0x201}, {1, 1, 0x203}, {1, 1, 0x223}, {1, 1, 0x223}, {1, 1, 0x223}}, + [1] = {{0, 0, 0x207}, {1, 0, 0x208}, {1, 2, 0x20A}, {1, 2, 0x22A}, {1, 2, 0x22A}, {1, 2, 0x22A}}, +}; + +void sub_803E250(void) +{ + s32 i, j; + + gUnknown_202EDD0 = 999; + gUnknown_202EDD4 = 0; + gUnknown_203B40D = 0; + gUnknown_202EDE8.unk0 = 0; + + SpriteSetY(&gUnknown_202EDC0, 0); + SpriteSetAffine1(&gUnknown_202EDC0, 0); + SpriteSetAffine2(&gUnknown_202EDC0, 0); + SpriteSetObjMode(&gUnknown_202EDC0, 0); + SpriteSetMosaic(&gUnknown_202EDC0, 0); + SpriteSetBpp(&gUnknown_202EDC0, 0); + SpriteSetShape(&gUnknown_202EDC0, 0); + SpriteSetMatrixNum(&gUnknown_202EDC0, 0); + SpriteSetSize(&gUnknown_202EDC0, 1); + SpriteSetX(&gUnknown_202EDC0, 0); + SpriteSetTileNum(&gUnknown_202EDC0, 0); + SpriteSetPriority(&gUnknown_202EDC0, 0); + SpriteSetPalNum(&gUnknown_202EDC0, 0); + SpriteSetUnk6_0(&gUnknown_202EDC0, 0); + SpriteSetUnk6_1(&gUnknown_202EDC0, 0); + SpriteSetUnk6_2(&gUnknown_202EDC0, 0); + + SpriteSetY(&gUnknown_202EDB8, 0); + SpriteSetAffine1(&gUnknown_202EDB8, 0); + SpriteSetAffine2(&gUnknown_202EDB8, 0); + SpriteSetObjMode(&gUnknown_202EDB8, 0); + SpriteSetMosaic(&gUnknown_202EDB8, 0); + SpriteSetBpp(&gUnknown_202EDB8, 0); + SpriteSetShape(&gUnknown_202EDB8, 0); + SpriteSetMatrixNum(&gUnknown_202EDB8, 0); + SpriteSetSize(&gUnknown_202EDB8, 0); + SpriteSetX(&gUnknown_202EDB8, 0); + SpriteSetTileNum(&gUnknown_202EDB8, 0); + SpriteSetPriority(&gUnknown_202EDB8, 3); + SpriteSetPalNum(&gUnknown_202EDB8, 5); + SpriteSetUnk6_0(&gUnknown_202EDB8, 0); + SpriteSetUnk6_1(&gUnknown_202EDB8, 0); + SpriteSetUnk6_2(&gUnknown_202EDB8, 0); + + for (i = 0; i < 2; i++) { + for (j = 0; j < 6; j++) { + SpriteSetAffine1(&gUnknown_202ED28[i][j].sprite, 0); + SpriteSetAffine2(&gUnknown_202ED28[i][j].sprite, 0); + SpriteSetObjMode(&gUnknown_202ED28[i][j].sprite, 0); + SpriteSetMosaic(&gUnknown_202ED28[i][j].sprite, 0); + SpriteSetBpp(&gUnknown_202ED28[i][j].sprite, 0); + SpriteSetShape(&gUnknown_202ED28[i][j].sprite, gUnknown_80F621C[i][j].shape); + SpriteSetMatrixNum(&gUnknown_202ED28[i][j].sprite, 0); + SpriteSetSize(&gUnknown_202ED28[i][j].sprite, gUnknown_80F621C[i][j].size); + SpriteSetTileNum(&gUnknown_202ED28[i][j].sprite, gUnknown_80F621C[i][j].tileNum); + SpriteSetPriority(&gUnknown_202ED28[i][j].sprite, 3); + SpriteSetPalNum(&gUnknown_202ED28[i][j].sprite, 0); + SpriteSetUnk6_0(&gUnknown_202ED28[i][j].sprite, 0); + SpriteSetUnk6_1(&gUnknown_202ED28[i][j].sprite, 0); + + gUnknown_202ED28[i][j].pos = gUnknown_80F61EC[i][j]; + } + } + + gDungeon->unk181e8.unk18217 = 1; + gDungeon->unk181e8.unk18218 = 1; + gDungeonBrightness = 0; + SetBGPaletteBufferColorRGB(0xf8, &gFontPalette[8],0,NULL); +} + +void DungeonRunFrameActions(u32 a0) +{ + if (gUnknown_203B40C != 0) + sub_803E490(a0); + else + sub_803E668(a0); +} + +static void sub_803E490(u32 unused) +{ + gUnknown_202EDD4++; + xxx_draw_string_80524F0(); + sub_8085F78(); + sub_803F580(1); + + if(gDungeon->unk181e8.unk1821A) + { + gDungeon->unk181e8.priority = 2; + SetBG2RegOffsets(gDungeon->unk181e8.cameraPixelPos.x, gDungeon->unk181e8.cameraPixelPos.y); + } + else + { + gDungeon->unk181e8.priority = 3; + SetBG2RegOffsets(0, 0); + } + SetBG3RegOffsets(gDungeon->unk181e8.cameraPixelPos.x, gDungeon->unk181e8.cameraPixelPos.y - gDungeon->unk181e8.unk181FC); + sub_806CC10(); + sub_804522C(); + sub_803F9CC(); + + sub_800F7D0(&gDungeon->unk181e8.cameraPixelPos); + + if(gDungeon->unk12 <= 0x63) + gDungeon->unk12++; + + sub_800E90C(&gDungeon->unk181e8.cameraPixelPos); + sub_8042E5C(); + + if(gUnknown_202EDD0 == 0 || gUnknown_202EDD0 == 3 || gGameOptionsRef->mapOption == TOP_MAP_AND_TEAM_NO_BOTTOM) + ShowPlayerDotOnMap(); + sub_803ECE0(); + sub_803EDF0(); + + + if(gDungeon->unk181e8.unk18215 != 0 && gDungeon->unk1BDD4.unk1C06C != 3) + sub_8004AF0(gUnknown_203B40D, gUnknown_202EE8C, 0xA0, 0x20, gDungeonBrightness, gDungeon->colorRamp); + + nullsub_8(gGameOptionsRef->unkA); + sub_8005180(); + nullsub_12(); + sub_80060EC(); + + gDungeonFramesCounter++; + + IncrementPlayTime(gPlayTimeRef); + WaitForNextFrameAndAdvanceRNG(); + LoadBufferedInputs(); + CopySpritesToOam(); + nullsub_13(); + sub_8005304(); + nullsub_14(); + + TransferBGPaletteBuffer(); + sub_8009908(); + xxx_call_update_bg_vram(); + CopyDungeonMapToVram(); + xxx_call_update_bg_sound_input(); + + gDungeon->unk181e8.unk18213 = 0; + UpdateDungeonMusic(); + sub_8011860(); + TryResetDungeonMapTilesScheduledForCopy(); + ResetSprites(FALSE); + nullsub_10(FALSE); + gUnknown_202EDD4--; +} + +void sub_803E668(u32 unused) +{ + gUnknown_202EDD4++; + nullsub_8(gGameOptionsRef->unkA); + sub_8005180(); + nullsub_12(); + sub_8005838(NULL, 0); + sub_80060EC(); + gDungeonFramesCounter++; + IncrementPlayTime(gPlayTimeRef); + WaitForNextFrameAndAdvanceRNG(); + LoadBufferedInputs(); + CopySpritesToOam(); + nullsub_13(); + sub_8005304(); + nullsub_14(); + TransferBGPaletteBuffer(); + sub_8009908(); + xxx_call_update_bg_vram(); + xxx_call_update_bg_sound_input(); + gDungeon->unk181e8.unk18213 = 0; + sub_8011860(); + ResetSprites(FALSE); + nullsub_10(FALSE); + gUnknown_202EDD4--; +} + +void sub_803E708(s32 numFrames, u32 a1) +{ + while (numFrames != 0) { + DungeonRunFrameActions(a1); + numFrames--; + } +} + +void sub_803E724(s32 r0) +{ + do + { + DungeonRunFrameActions(r0); + } while (gRealInputs.held & 0xF0); +} + +void sub_803E748(void) +{ + s32 index1; + s32 index2; + + index2 = 0x1F; + gUnknown_203B40D = 1; + gDungeonBrightness = 0; + + sub_803E874(1, 0x1F); + + for(index1 = 0; index1 < 0x2C; index1++) + { + if(index1 < 0x20) + { + index2 -= 2; + if(index2 <= 0) + { + index2 = 0; + sub_803EAF0(1, NULL); + gDungeon->unk181e8.unk18217 = index2; + } + } + if(index1 > 0xB) + if(gDungeonBrightness <= 0x1E) + gDungeonBrightness++; + sub_803E874(1, index2); + DungeonRunFrameActions(5); + } + gUnknown_203B40D = 0; + gDungeonBrightness = 0x1F; +} + +void sub_803E7C8(void) +{ + s32 index1; + s32 index2; + + index2 = 0x1F; + gUnknown_203B40D = 1; + gDungeonBrightness = 0; + + DungeonRunFrameActions(5); + + for(index1 = 0; index1 < 0x2C; index1++) + { + sub_803E874(1, index2); + if(index1 < 0x20) + { + index2 -= 2; + if(index2 <= 0) + { + index2 = 0; + sub_803EAF0(1, NULL); + gDungeon->unk181e8.unk18217 = index2; + } + } + DungeonRunFrameActions(5); + } + gUnknown_203B40D = 0; +} + +void sub_803E830(void) +{ + s32 index; + + gUnknown_203B40D = 1; + for(index = 0; index < 0x20; index++) + { + sub_803E874(0, 0); + DungeonRunFrameActions(5); + if(gDungeonBrightness > 0) + gDungeonBrightness--; + } + gDungeonBrightness = 0; + gUnknown_203B40D = 0; +} + +static const RGB sBlackRgb = {0, 0, 0}; + +void sub_803E874(bool8 r10, s32 r9) +{ + s32 i, index, count; + const RGB *color; + + color = gDungeonPaletteFile->unk4; + SetBGPaletteBufferColorRGB(0, &sBlackRgb, gDungeonBrightness, gDungeon->colorRamp); + color++; + index = 1; + count = 159; + for (i = 0; i < count; i++) { + SetBGPaletteBufferColorRGB(index, color, gDungeonBrightness, gDungeon->colorRamp); + color++; + index++; + } + + if (gDungeon->unk181e8.unk18215 == 0 || gDungeon->unk1BDD4.unk1C06C == 3) { + sub_8004AF0(TRUE, gUnknown_202EE8C, 0xA0, 0x20, gDungeonBrightness, gDungeon->colorRamp); + } + + index += 32; + color = gUnknown_202ECA4; + count = 32; + for (i = 0; i < count; i++) { + SetBGPaletteBufferColorRGB(index, color, gDungeonBrightness, gDungeon->colorRamp); + color++; + index++; + } + + if (r10) { + index = 224; + color = gDungeonNameBannerPalette->unk4; + count = 16; + for (i = 0; i < count; i++) { + SetBGPaletteBufferColorRGB(index, color, r9, NULL); + color++; + index++; + } + } + + SetBGPaletteBufferColorRGB(248, &gFontPalette[8], gDungeonBrightness, NULL); + + color = ((struct DungeonPalFile*) gDungeon->paletFile)->unk4; + index = 256; + count = 208; + for (i = 0; i < count; i++) { + SetBGPaletteBufferColorRGB(index, color, gDungeonBrightness, gDungeon->colorRamp); + nullsub_4(index, color, gDungeonBrightness, NULL); + color++; + index++; + } +} + +void BgColorCallNullsub4(void) +{ + s32 i, index, count; + const RGB *color; + + color = ((struct DungeonPalFile*) gDungeon->paletFile)->unk4; + index = 256; + count = 208; + for (i = 0; i < count; i++) { + nullsub_4(index, color, gDungeonBrightness, NULL); + color++; + index++; + } +} + +void sub_803EA10(void) +{ + s32 i, index, count; + const RGB *color; + + color= gDungeonPaletteFile->unk4; + SetBGPaletteBufferColorRGB(0, &sBlackRgb, gDungeonBrightness, gDungeon->colorRamp); + color++; + index = 1; + count = 159; + for (i = 0; i < count; i++) { + SetBGPaletteBufferColorRGB(index, color, gDungeonBrightness, gDungeon->colorRamp); + color++; + index++; + } + + if (gDungeon->unk181e8.unk18215 == 0 || gDungeon->unk1BDD4.unk1C06C == 3) { + sub_8004AF0(TRUE, gUnknown_202EE8C, 0xA0, 0x20, gDungeonBrightness, gDungeon->colorRamp); + } + + index += 32; + color = gUnknown_202ECA4; + count = 32; + for (i = 0; i < count; i++) { + SetBGPaletteBufferColorRGB(index, color, gDungeonBrightness, gDungeon->colorRamp); + color++; + index++; + } + + SetBGPaletteBufferColorRGB(248, &gFontPalette[8], gDungeonBrightness, NULL); +} + +static const WindowTemplates gUnknown_80F62B0 = +{ + .id = { + [0] = { + .type = WINDOW_TYPE_0, + .pos = {2, 15}, + .width = 26, + .height = 5, + .unk10 = 7, + .unk12 = 0, + .header = NULL, + }, + [1] = WIN_TEMPLATE_DUMMY, + [2] = WIN_TEMPLATE_DUMMY, + [3] = WIN_TEMPLATE_DUMMY, + } +}; + +static const WindowTemplates gUnknown_80F6310 = +{ + .id = { + [0] = { + .type = WINDOW_TYPE_NORMAL, + .pos = {2, 3}, + .width = 6, + .height = 7, + .unk10 = 7, + .unk12 = 0, + .header = NULL, + }, + [1] = WIN_TEMPLATE_DUMMY, + [2] = WIN_TEMPLATE_DUMMY, + [3] = WIN_TEMPLATE_DUMMY, + } +}; + +static const WindowTemplates gUnknown_80F6370 = +{ + .id = { + [0] = { + .type = WINDOW_TYPE_NORMAL, + .pos = {2, 3}, + .width = 6, + .height = 7, + .unk10 = 7, + .unk12 = 0, + .header = NULL, + }, + [1] = { + .type = WINDOW_TYPE_NORMAL, + .pos = {10, 4}, + .width = 17, + .height = 2, + .unk10 = 2, + .unk12 = 0, + .header = NULL, + }, + [2] = { + .type = WINDOW_TYPE_NORMAL, + .pos = {2, 13}, + .width = 26, + .height = 6, + .unk10 = 6, + .unk12 = 0, + .header = NULL, + }, + [3] = WIN_TEMPLATE_DUMMY, + } +}; + +static const WindowTemplates gUnknown_80F63D0 = +{ + .id = { + [0] = { + .type = WINDOW_TYPE_NORMAL, + .pos = {2, 3}, + .width = 26, + .height = 14, + .unk10 = 18, + .unk12 = 2, + .header = NULL, + }, + [1] = WIN_TEMPLATE_DUMMY, + [2] = WIN_TEMPLATE_DUMMY, + [3] = WIN_TEMPLATE_DUMMY, + } +}; + +// kind==8 uses the `name` param. +void sub_803EAF0(u32 kind, u8 *name) +{ + if (kind == gUnknown_202EDD0) + return; + + switch (kind) { + case 1: { + if (gUnknown_203B40C != 0) + sub_8052210(0); + + ResetUnusedInputStruct(); + sub_803EC94(); + ShowWindows(NULL, TRUE, TRUE); + break; + } + case 0: { + sub_803EC94(); + ShowWindows(NULL, TRUE, TRUE); + if (gUnknown_203B40C != 0) { + ShowWholeRevealedDungeonMap(); + UpdateBgTilemapForDungeonMap(FALSE); + } + break; + } + case 3: { + ShowWindows(&gUnknown_80F62B0, TRUE, TRUE); + if (gUnknown_203B40C != 0) + UpdateBgTilemapForDungeonMap(TRUE); + break; + } + case 6: { + if (gUnknown_203B40C != 0) + sub_8052210(0); + + ResetUnusedInputStruct(); + ShowWindows(&gUnknown_80F6310, TRUE, TRUE); + break; + } + case 7: { + if (gUnknown_203B40C != 0) + sub_8052210(0); + + ResetUnusedInputStruct(); + ShowWindows(&gUnknown_80F6370, TRUE, TRUE); + break; + } + case 2: + case 4: { + if (gUnknown_203B40C != 0) + sub_8052210(0); + + ResetUnusedInputStruct(); + sub_803EC94(); + ShowWindows(NULL, TRUE, TRUE); + break; + } + case 5: { + if (gUnknown_203B40C != 0) + sub_8052210(0); + + ShowWindows(NULL, TRUE, TRUE); + break; + } + case 8: { + if (gUnknown_203B40C != 0) { + PlayDungeonStartButtonSE(); + sub_8052210(0); + } + + CreateConfirmNameMenu(2, name); + break; + } + case 9: { + if (gUnknown_203B40C != 0) { + sub_8052210(0); + PlayDungeonStartButtonSE(); + } + + ResetUnusedInputStruct(); + ShowWindows(&gUnknown_80F63D0, FALSE, TRUE); + break; + } + case 10: { + PlayDungeonStartButtonSE(); + break; + } + case 150: { // Dummy case put here to match, any value >= 150 works + break; + } + } + + gUnknown_202EDD0 = kind; +} + +static void sub_803EC94(void) +{ + gDungeonMenu.unk1E = 0; + gDungeonMenu.unk20 = 0; + gDungeonMenu.unkC = 0; + gDungeonMenu.unkE = 0; + gDungeonMenu.unk14.x = 0; + sub_801317C(&gDungeonMenu.unk28); +} + +void DungeonShowWindows(WindowTemplates *a0, bool8 a1) +{ + gUnknown_202EDD0 = 10; + sub_8052210(0); + ResetUnusedInputStruct(); + ShowWindows(a0, TRUE, a1); +} + +void sub_803ECE0(void) +{ + gUnknown_202EDD8++; + if (gUnknown_202EDD8 < 0) + gUnknown_202EDD8 = 0; + if (gUnknown_202EDD8 > 11) + gUnknown_202EDD8 = 0; + + sub_80098BC((void *)VRAM + 0x14400, gUnknown_202EC94->unk4 + ((gUnknown_202EDD8 / 4) * 0x240), 0x240); +} + +void sub_803ED30(s32 a0, Entity *mon, u8 a2, s32 a3) +{ + s32 i, var; + + if (a0 == 0 || gDungeon->unk181e8.blinded) + return; + + for (i = 0; i < 20; i++) { + if (gUnknown_202EDE8.unk0 == 0) + break; + DungeonRunFrameActions(0x29); + } + + var = sub_803EF90(a0, a2); + gUnknown_202EDE8.unk0 = 60; + gUnknown_202EDE8.unk4 = mon; + gUnknown_202EDE8.unk8 = mon->spawnGenID; + gUnknown_202EDE8.unkC = -(var * 768); + gUnknown_202EDE8.unk10 = 0; + + if (a3 < 0) { + if (a0 < -999) { + gUnknown_202EDE8.unk2 = 6; + } + else if (a0 >= 0) { + gUnknown_202EDE8.unk2 = 10; + } + else { + gUnknown_202EDE8.unk2 = 3; + } + } + else { + gUnknown_202EDE8.unk2 = a3; + } + + sub_80098BC((void *) VRAM + 0x142C0, gDungeon->unk18, 0x80); +} + +void sub_803EDF0(void) +{ + EntityInfo *entInfo; + s32 x, y, y1, y2; + + if (gUnknown_202EDE8.unk0 == 0) + return; + if (!EntityIsValid(gUnknown_202EDE8.unk4)) { + gUnknown_202EDE8.unk0 = 0; + return; + } + if (gUnknown_202EDE8.unk8 != gUnknown_202EDE8.unk4->spawnGenID) { + gUnknown_202EDE8.unk0 = 0; + return; + } + + gUnknown_202EDE8.unk0--; + gUnknown_202EDE8.unk10 -= 46; + entInfo = GetEntInfo(gUnknown_202EDE8.unk4); + x = (entInfo->pixelPos.x + (gUnknown_202EDE8.unkC / 256)) - gDungeon->unk181e8.cameraPixelPos.x; + y1 = (entInfo->pixelPos.y + (gUnknown_202EDE8.unk10 / 256)); + y2 = (gDungeon->unk181e8.cameraPixelPos.y + 24); + y = y1 - y2; + + if (x >= -32 && y >= -8 && x < 240 && y < 160) { + SpriteSetY(&gUnknown_202EDDC, y); + SpriteSetAffine1(&gUnknown_202EDDC, 0); + SpriteSetAffine2(&gUnknown_202EDDC, 0); + SpriteSetObjMode(&gUnknown_202EDDC, 0); + SpriteSetMosaic(&gUnknown_202EDDC, 0); + SpriteSetBpp(&gUnknown_202EDDC, 0); + SpriteSetShape(&gUnknown_202EDDC, 1); + SpriteSetX(&gUnknown_202EDDC, x); + SpriteSetMatrixNum(&gUnknown_202EDDC, 0); + SpriteSetSize(&gUnknown_202EDDC, 1); + SpriteSetTileNum(&gUnknown_202EDDC, 0x216); + SpriteSetPriority(&gUnknown_202EDDC, gDungeon->unk181e8.priority); + SpriteSetPalNum(&gUnknown_202EDDC, gUnknown_202EDE8.unk2); + + SpriteSetUnk6_0(&gUnknown_202EDDC, 0); + SpriteSetUnk6_1(&gUnknown_202EDDC, 0); + SpriteSetUnk6_2(&gUnknown_202EDDC, 0); + + AddSprite(&gUnknown_202EDDC, 0x100, NULL, NULL); + } +} + +static const s32 gUnknown_80F6430[][9] = +{ + [0] = {900, 800, 700, 600, 500, 400, 300, 200, 100}, + [1] = {90, 80, 70, 60, 50, 40, 30, 20, 10}, +}; + +static s32 sub_803EF90(s32 a0, u8 a1) +{ + s32 i, id; + const u32 *r2; + s32 bitsNo; + s32 ret; + bool8 unkBool; + u32 *mainDst = gDungeon->unk18; + u32 *sp[] = {(u32 *)(gUnknown_202EC9C->data + 0x124), + (u32 *)(gUnknown_202EC9C->data + 0x104), + (u32 *)(gUnknown_202EC9C->data + 0xE4), + (u32 *)(gUnknown_202EC9C->data + 0xC4), + (u32 *)(gUnknown_202EC9C->data + 0xA4), + (u32 *)(gUnknown_202EC9C->data + 0x84), + (u32 *)(gUnknown_202EC9C->data + 0x64), + (u32 *)(gUnknown_202EC9C->data + 0x44), + (u32 *)(gUnknown_202EC9C->data + 0x24)}; + s32 dstId = 0; + u32 *clearDst = mainDst; + for (i = 0; i < 4; i++) { + clearDst[dstId++] = 0; + clearDst[dstId++] = 0; + clearDst[dstId++] = 0; + clearDst[dstId++] = 0; + clearDst[dstId++] = 0; + clearDst[dstId++] = 0; + clearDst[dstId++] = 0; + clearDst[dstId++] = 0; + } + + if (a0 == 9999) { + u32 r12[] = {13, 14, 15, 15}; + + bitsNo = 0; + for (id = 0; id < 4; id++) { + u32 *dst = mainDst; + const u32 *src = (u32 *)((&((u8 *)gUnknown_202EC9C->data)[4] + r12[id] * 32)); + + for (i = 0; i < 8; i++) { + u32 toOr1, toOr2; + if (bitsNo == 0) { + toOr1 = 0; + toOr2 = *src; + } + else { + toOr1 = *src >> (32 - bitsNo); + toOr2 = *src << bitsNo; + } + + src++; + dst[0] |= toOr2; + dst[8] |= toOr1; + dst++; + } + + bitsNo += 24; + if (bitsNo >= 32) { + bitsNo -= 32; + mainDst += 8; + } + } + + return 4; + } + + if (a0 > 999) a0 = 999; + if (a0 < -999) a0 = -999; + + r2 = (u32 *)((u8 *)gUnknown_202EC9C->data + 0x184); + if (a1) { + if (a0 > 0) { + r2 = (u32 *)((u8 *)gUnknown_202EC9C->data + 0x144); + } + else if (a0 < 0) { + r2 = (u32 *)((u8 *)gUnknown_202EC9C->data + 0x164); + a0 = -a0; + } + } + + mainDst[0] = *r2++; + mainDst[1] = *r2++; + mainDst[2] = *r2++; + mainDst[3] = *r2++; + mainDst[4] = *r2++; + mainDst[5] = *r2++; + mainDst[6] = *r2++; + mainDst[7] = *r2++; + + bitsNo = 24; + ret = 1; + unkBool = FALSE; + for (id = 0; id < 2; id++) { + s32 arrId; + + for (arrId = 0; arrId < 9; arrId++) { + if (gUnknown_80F6430[id][arrId] <= a0) { + const u32 *src = sp[arrId]; + u32 *dst = mainDst; + + for (i = 0; i < 8; i++) { + u32 toOr1, toOr2; + if (bitsNo == 0) { + toOr1 = 0; + toOr2 = *src; + } + else { + toOr1 = *src >> (32 - bitsNo); + toOr2 = *src << bitsNo; + } + + src++; + dst[0] |= toOr2; + dst[8] |= toOr1; + dst++; + unkBool = TRUE; + } + + bitsNo += 24; + if (bitsNo >= 32) { + bitsNo -= 32; + mainDst += 8; + } + + a0 -= gUnknown_80F6430[id][arrId]; + ret++; + break; + } + } + + if (arrId == 9 && unkBool) { + const u32 *src = (u32 *)(&((u8 *)gUnknown_202EC9C->data)[4]); + u32 *dst = mainDst; + for (i = 0; i < 8; i++) { + u32 toOr1, toOr2; + if (bitsNo == 0) { + toOr1 = 0; + toOr2 = *src; + } + else { + toOr1 = *src >> (32 - bitsNo); + toOr2 = *src << bitsNo; + } + + src++; + dst[0] |= toOr2; + dst[8] |= toOr1; + dst++; + } + + bitsNo += 24; + if (bitsNo >= 32) { + bitsNo -= 32; + mainDst += 8; + } + + ret++; + } + } + + { + const u32 *src = (u32 *)(&((u8 *)gUnknown_202EC9C->data)[4] + (a0 * 32)); + u32 *dst = mainDst; + for (i = 0; i < 8; i++) { + u32 toOr1, toOr2; + if (bitsNo == 0) { + toOr1 = 0; + toOr2 = *src; + } + else { + toOr1 = *src >> (32 - bitsNo); + toOr2 = *src << bitsNo; + } + + src++; + dst[0] |= toOr2; + dst[8] |= toOr1; + dst++; + } + } + + ret++; + return ret; +} diff --git a/src/explosion.c b/src/explosion.c index 837cf0a19..ed8afcedd 100644 --- a/src/explosion.c +++ b/src/explosion.c @@ -2,7 +2,7 @@ #include "globaldata.h" #include "constants/ability.h" #include "constants/weather.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "dungeon_message.h" #include "code_806CD90.h" #include "code_807CD9C.h" diff --git a/src/expose_trap.c b/src/expose_trap.c index 929c7c824..bf67d7225 100644 --- a/src/expose_trap.c +++ b/src/expose_trap.c @@ -2,7 +2,7 @@ #include "globaldata.h" #include "constants/ability.h" #include "constants/weather.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "dungeon_message.h" #include "code_806CD90.h" #include "code_807CD9C.h" diff --git a/src/hurl_orb.c b/src/hurl_orb.c index 9a2703772..90a3d46ae 100644 --- a/src/hurl_orb.c +++ b/src/hurl_orb.c @@ -1,6 +1,6 @@ #include "global.h" #include "globaldata.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "code_803E668.h" #include "code_8041AD0.h" #include "code_804267C.h" diff --git a/src/move_orb_actions_1.c b/src/move_orb_actions_1.c index e27fac8ed..018b9f162 100644 --- a/src/move_orb_actions_1.c +++ b/src/move_orb_actions_1.c @@ -1,12 +1,12 @@ #include "global.h" #include "globaldata.h" #include "dungeon_move_util.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "code_803E724.h" #include "code_806CD90.h" #include "code_8077274_1.h" #include "code_807CD9C.h" -#include "code_808417C.h" +#include "dungeon_random.h" #include "constants/ability.h" #include "constants/status.h" #include "constants/targeting.h" diff --git a/src/move_orb_actions_2.c b/src/move_orb_actions_2.c index a4136ffd0..22c280086 100644 --- a/src/move_orb_actions_2.c +++ b/src/move_orb_actions_2.c @@ -1,12 +1,12 @@ #include "global.h" #include "globaldata.h" #include "dungeon_move_util.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "code_803E724.h" #include "code_806CD90.h" #include "code_8077274_1.h" #include "code_807CD9C.h" -#include "code_808417C.h" +#include "dungeon_random.h" #include "constants/ability.h" #include "constants/status.h" #include "constants/targeting.h" diff --git a/src/move_orb_actions_3.c b/src/move_orb_actions_3.c index c70bfbb75..077c54e98 100644 --- a/src/move_orb_actions_3.c +++ b/src/move_orb_actions_3.c @@ -1,11 +1,11 @@ #include "global.h" #include "globaldata.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "code_803E724.h" #include "code_806CD90.h" #include "code_8077274_1.h" #include "code_807CD9C.h" -#include "code_808417C.h" +#include "dungeon_random.h" #include "constants/ability.h" #include "constants/move_id.h" #include "constants/status.h" diff --git a/src/move_orb_actions_4.c b/src/move_orb_actions_4.c index 8c15430f5..169f6360c 100644 --- a/src/move_orb_actions_4.c +++ b/src/move_orb_actions_4.c @@ -7,7 +7,7 @@ #include "code_806CD90.h" #include "code_8077274_1.h" #include "code_807CD9C.h" -#include "code_808417C.h" +#include "dungeon_random.h" #include "constants/ability.h" #include "constants/move_id.h" #include "constants/status.h" diff --git a/src/move_orb_effects_1.c b/src/move_orb_effects_1.c index 6177cc583..a99ef4b75 100644 --- a/src/move_orb_effects_1.c +++ b/src/move_orb_effects_1.c @@ -4,7 +4,7 @@ #include "dungeon_message.h" #include "code_806CD90.h" #include "code_8077274_1.h" -#include "code_808417C.h" +#include "dungeon_random.h" #include "constants/ability.h" #include "constants/direction.h" #include "constants/dungeon_action.h" @@ -32,7 +32,7 @@ #include "dungeon_config.h" #include "dungeon_strings.h" #include "status.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" extern void sub_80420A0(Entity *); extern void sub_8041C58(Entity *r0); diff --git a/src/move_orb_effects_2.c b/src/move_orb_effects_2.c index 0e2d836e0..07c114419 100644 --- a/src/move_orb_effects_2.c +++ b/src/move_orb_effects_2.c @@ -1,10 +1,10 @@ #include "global.h" #include "globaldata.h" #include "status.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "code_806CD90.h" #include "code_8077274_1.h" -#include "code_808417C.h" +#include "dungeon_random.h" #include "constants/ability.h" #include "constants/status.h" #include "constants/type.h" diff --git a/src/move_orb_effects_3.c b/src/move_orb_effects_3.c index 95f0be70c..da749b519 100644 --- a/src/move_orb_effects_3.c +++ b/src/move_orb_effects_3.c @@ -1,12 +1,12 @@ #include "global.h" #include "globaldata.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "dungeon_map_access.h" #include "dungeon_message.h" #include "code_805D8C8.h" #include "code_806CD90.h" #include "code_8077274_1.h" -#include "code_808417C.h" +#include "dungeon_random.h" #include "constants/ability.h" #include "constants/item.h" #include "constants/status.h" diff --git a/src/move_orb_effects_4.c b/src/move_orb_effects_4.c index 41ac68895..a76ae9e3f 100644 --- a/src/move_orb_effects_4.c +++ b/src/move_orb_effects_4.c @@ -1,12 +1,12 @@ #include "global.h" #include "globaldata.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "dungeon_map_access.h" #include "dungeon_message.h" #include "code_805D8C8.h" #include "code_806CD90.h" #include "code_8077274_1.h" -#include "code_808417C.h" +#include "dungeon_random.h" #include "constants/ability.h" #include "constants/item.h" #include "constants/status.h" diff --git a/src/move_orb_effects_5.c b/src/move_orb_effects_5.c index 6643ff8e8..9ff148a16 100644 --- a/src/move_orb_effects_5.c +++ b/src/move_orb_effects_5.c @@ -1,12 +1,12 @@ #include "global.h" #include "globaldata.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "dungeon_map_access.h" #include "dungeon_message.h" #include "code_805D8C8.h" #include "code_806CD90.h" #include "code_8077274_1.h" -#include "code_808417C.h" +#include "dungeon_random.h" #include "constants/ability.h" #include "constants/item.h" #include "constants/status.h" diff --git a/src/one_room_orb.c b/src/one_room_orb.c index 264d95f33..baa0179d2 100644 --- a/src/one_room_orb.c +++ b/src/one_room_orb.c @@ -2,7 +2,7 @@ #include "globaldata.h" #include "constants/ability.h" #include "constants/weather.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "dungeon_message.h" #include "code_806CD90.h" #include "code_807CD9C.h" diff --git a/src/pounce_orb.c b/src/pounce_orb.c index c3ee387d8..05fd3bb4c 100644 --- a/src/pounce_orb.c +++ b/src/pounce_orb.c @@ -2,7 +2,7 @@ #include "globaldata.h" #include "constants/ability.h" #include "constants/weather.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "dungeon_message.h" #include "code_806CD90.h" #include "code_807CD9C.h" diff --git a/src/run_dungeon.c b/src/run_dungeon.c index e8ae65257..1189c2f4d 100644 --- a/src/run_dungeon.c +++ b/src/run_dungeon.c @@ -15,13 +15,14 @@ #include "code_800E9E4.h" #include "code_800ED38.h" #include "code_803D110.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "code_803E668.h" #include "code_803E724.h" #include "code_805D8C8.h" #include "code_8094F88.h" #include "code_8099360.h" #include "cpu.h" +#include "dungeon_8083AB0.h" #include "dungeon.h" #include "dungeon_ai.h" #include "dungeon_config.h" @@ -66,7 +67,7 @@ extern void sub_803E830(void); extern void sub_8068F28(void); extern void sub_806C1D8(void); extern void IncrementThievingSuccesses(void); -extern void sub_80841EC(void); +extern void ShowDungeonClearedWindow(void); extern void sub_8084424(void); extern void sub_8086130(void); extern void FreeDungeonPokemonSprites(void); @@ -653,7 +654,7 @@ void RunDungeon_Async(UnkStruct_RunDungeon *r8) sub_803E13C(); sub_800CDA8(4); if (gDungeon->unk6 == 0 && sub_8083C88(gDungeon->unk644.unk34)) { - sub_80841EC(); + ShowDungeonClearedWindow(); } if (sub_8083C24()) { diff --git a/src/switcher_orb.c b/src/switcher_orb.c index fa799511e..d0a40ab9f 100644 --- a/src/switcher_orb.c +++ b/src/switcher_orb.c @@ -2,7 +2,7 @@ #include "globaldata.h" #include "constants/ability.h" #include "constants/weather.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "dungeon_message.h" #include "code_806CD90.h" #include "code_807CD9C.h" diff --git a/src/text_util.c b/src/text_util.c index e31e86eac..2675a61d2 100644 --- a/src/text_util.c +++ b/src/text_util.c @@ -42,7 +42,7 @@ u32 sub_80922E4(u32 r0) return gUnknown_810983C[r0]; } -void CopyStringtoBuffer(u8 *buffer, u8 *string) +void CopyStringtoBuffer(u8 *buffer, const u8 *string) { while( *string != '\0' ) { *buffer++ = *string++; diff --git a/src/trap.c b/src/trap.c index 5da4a52ba..6d050f14a 100644 --- a/src/trap.c +++ b/src/trap.c @@ -7,7 +7,7 @@ #include "dungeon_message.h" #include "code_8077274_1.h" #include "code_807CD9C.h" -#include "code_808417C.h" +#include "dungeon_random.h" #include "code_806CD90.h" #include "constants/trap.h" #include "constants/type.h" diff --git a/src/trawl_orb.c b/src/trawl_orb.c index 29faad793..2898547a3 100644 --- a/src/trawl_orb.c +++ b/src/trawl_orb.c @@ -2,7 +2,7 @@ #include "globaldata.h" #include "constants/ability.h" #include "constants/weather.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "dungeon_message.h" #include "code_806CD90.h" #include "code_807CD9C.h" diff --git a/src/warp_target.c b/src/warp_target.c index 6f5e08d0b..1648999a2 100644 --- a/src/warp_target.c +++ b/src/warp_target.c @@ -2,7 +2,7 @@ #include "globaldata.h" #include "constants/ability.h" #include "constants/weather.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "dungeon_message.h" #include "code_806CD90.h" #include "code_807CD9C.h" diff --git a/src/weather.c b/src/weather.c index 1e666aedd..c06790b02 100644 --- a/src/weather.c +++ b/src/weather.c @@ -6,7 +6,7 @@ #include "constants/weather.h" #include "structs/str_dungeon.h" #include "code_804267C.h" -#include "code_803E46C.h" +#include "dungeon_vram.h" #include "dungeon.h" #include "dungeon_config.h" #include "dungeon_leader.h" diff --git a/sym_ewram.txt b/sym_ewram.txt index 7630506ff..5ce6c959c 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -16,8 +16,6 @@ .include "src/main.o" .include "src/reg_control.o" .include "src/music.o" - .space 0x3 - .include "src/bg_control.o" .include "src/cpu.o" .space 0x4 @@ -57,84 +55,19 @@ gUnknown_202DCF8: /* 202DCF8 (sub_80001E8 - sub_800D9B8) */ .include "src/friend_areas_map.o" .include "src/code_80118A4.o" - .space 0x2 - .include "src/save.o" .space 4 .include "src/string_format.o" .space 4 .include "src/other_menus2.o" .include "src/rescue_password_menu.o" - .space 0x2 - -gDungeonNameBannerPalette: /* 202EC88 (ShowDungeonNameBanner_Async - xxx_dungeon_8042F6C) */ - .space 0x4 -gDungeonNameBannerFontFile: /* 202EC8C (ShowDungeonNameBanner_Async - sub_803DEC8) */ - .space 0x4 -gDungeonNameBannerFont: /* 202EC90 (ShowDungeonNameBanner_Async - sub_803DEC8) */ - .space 0x4 - -gUnknown_202EC94: /* 202EC94 (sub_803DF60 - sub_803ECE0) */ - .space 0x4 -gUnknown_202EC98: /* 202EC98 (sub_803DF60 - sub_803E214) */ - .space 0x4 -gUnknown_202EC9C: /* 202EC9C (sub_803DF60 - sub_803EF90) */ - .space 0x4 -gUnknown_202ECA0: /* 202ECA0 (sub_803DF60 - sub_807E88C) */ - .space 0x4 -gUnknown_202ECA4: /* 202ECA4 (sub_803E02C - SetDungeonBGColorRGB) */ - .space 0x84 -gUnknown_202ED28: /* 202ED28 (sub_803E250 - sub_8083568) */ - .space 0x8 -gUnknown_202ED30: /* 202ED30 (sub_803E250) */ - .space 0x88 -gUnknown_202EDB8: /* 202EDB8 (sub_803E250) */ - .space 0x8 -gUnknown_202EDC0: /* 202EDC0 (sub_803E250 - sub_80462AC) */ - .space 0x8 -gDungeonBrightness: /* 202EDC8 (sub_803E250 - sub_8086794) */ - .space 0x4 -gDungeonFramesCounter: /* 202EDCC (sub_803E490 - sub_807D148) */ - .space 0x4 -gUnknown_202EDD0: /* 202EDD0 (sub_803E250 - sub_8052210) */ - .space 0x4 -gUnknown_202EDD4: /* 202EDD4 (sub_803E250 - sub_803E668) */ - .space 0x4 -gUnknown_202EDD8: /* 202EDD8 (sub_803ECE0) */ - .space 0x4 -gUnknown_202EDDC: /* 202EDDC (sub_803EDF0) */ - .space 0xC -gUnknown_202EDE8: /* 202EDE8 (sub_803E250 - sub_803EDF0) */ - .space 0x14 -gUnknown_202EDFC: /* 202EDFC (sub_803F27C - sub_803F878) */ - .space 0x4 - + .include "src/code_803DA7C.o" + .include "src/dungeon_vram.o" + .include "src/dungeon_tilemap.o" .include "src/dungeon_map.o" - -gUnknown_202EE0C: /* 202EE0C (sub_80694C0 - sub_806B8CC) */ - .space 0x4 - -gDungeonMenu: /* 202EE10 (sub_803EC94 - sub_8083CE0) */ - .space 0x28 - -gUnknown_202EE38: /* 202EE38 (sub_8063834) */ - .space 0x1 -gUnknown_202EE39: /* 202EE39 (sub_8060E38) */ - .space 0x1 - -gUnknown_202EE3A: /* 202EE3A (sub_8060E38 - sub_8065DBC) */ - .space 0xA - -gDungeonSubMenu: /* 202EE44 (sub_8044EC8 - sub_80647F0) */ - .space 0x28 -gDungeonSubMenuItemsCount: /* 202EE6C (sub_8044F5C - sub_8067A80) */ - .space 0x4 - -gUnknown_202EE70: /* 202EE70 (sub_804513C - sub_80828E0) */ - .space 0x6 -gUnknown_202EE76: /* 202EE76 (sub_804513C - sub_8082A08) */ - .space 0x10 - + .include "src/dungeon_engine.o" + .include "src/dungeon_action.o" + .include "src/dungeon_util.o" .include "src/dungeon_map_access.o" .include "src/dungeon_generation.o" .include "src/dungeon_message.o" @@ -154,23 +87,14 @@ gUnknown_202EE76: /* 202EE76 (sub_804513C - sub_8082A08) */ .include "src/dungeon_8067A80.o" .include "src/dungeon_logic.o" .include "src/code_80718D8.o" - -gUnknown_202F32C: /* 202F32C (xxx_dungeon_8042F6C - sub_8072CF4) */ - .space 0x1 -gUnknown_202F32D: /* 202F32D (sub_8072CF4 - UseAttack) */ - .space 0x3 - + .include "src/dungeon_8072CF4.o" .include "src/dungeon_ai_items.o" .include "src/code_8073CF0.o" .include "src/code_8075708.o" .space 0x4 .include "src/dungeon_ai_attack.o" - .include "src/code_80869E4.o" - -gUnknown_202F3D8: /* 202F3D8 (sub_8085B4C - sub_8085B80) */ - .space 0x8 - - + .include "src/code_80848F0.o" + .space 0x4 .include "src/pokemon.o" .include "src/items.o" .include "src/rescue_team_info.o" diff --git a/sym_ewram_init.txt b/sym_ewram_init.txt index 1048a3c5c..0ee7af698 100644 --- a/sym_ewram_init.txt +++ b/sym_ewram_init.txt @@ -109,7 +109,7 @@ .include "src/personality_test1.o" .include "src/personality_test2.o" .include "src/code_803D0D8.o" -.include "src/code_803E46C.o" +.include "src/dungeon_vram.o" .include "src/dungeon_map.o" .include "src/run_dungeon.o" .include "src/dungeon_items.o" @@ -121,7 +121,7 @@ .include "src/dungeon_menu_recruitment.o" .include "src/dungeon_ai_items.o" .include "src/explosion.o" -.include "src/dungeon_leader.o" +.include "src/dungeon_range.o" .include "src/dungeon_random.o" .include "src/dungeon_music.o" .include "src/pokemon.o" diff --git a/sym_iwram.txt b/sym_iwram.txt index a98bce035..33f4c290b 100644 --- a/sym_iwram.txt +++ b/sym_iwram.txt @@ -8,5 +8,5 @@ gUnknown_3000C00: /* 3000C00 */ .include "src/text_1.o" .include "src/music.o" -.include "src/code_803E724.o" +.include "src/dungeon_tilemap.o" .include "src/random_mersenne_twister.o"