diff --git a/asm/dewford_trend.s b/asm/dewford_trend.s deleted file mode 100644 index 7d9d67902..000000000 --- a/asm/dewford_trend.s +++ /dev/null @@ -1,975 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start InitDewfordTrend -InitDewfordTrend: @ 81224D4 - push {r4-r7,lr} - movs r6, 0 - ldr r5, =gSaveBlock1Ptr -_081224DA: - movs r0, 0xA - bl sub_811EE38 - ldr r1, [r5] - lsls r4, r6, 3 - adds r1, r4 - ldr r2, =0x00002e6c - adds r1, r2 - strh r0, [r1] - bl Random - movs r1, 0x1 - ands r1, r0 - cmp r1, 0 - beq _08122514 - movs r0, 0xC - bl sub_811EE38 - ldr r1, [r5] - adds r1, r4 - ldr r7, =0x00002e6e - adds r1, r7 - b _08122522 - .pool -_08122514: - movs r0, 0xD - bl sub_811EE38 - ldr r1, [r5] - adds r1, r4 - ldr r2, =0x00002e6e - adds r1, r2 -_08122522: - strh r0, [r1] - bl Random - ldr r3, [r5] - adds r3, r4 - movs r2, 0x1 - ands r2, r0 - ldr r7, =0x00002e69 - adds r3, r7 - lsls r2, 6 - ldrb r0, [r3] - movs r7, 0x41 - negs r7, r7 - adds r1, r7, 0 - ands r0, r1 - orrs r0, r2 - strb r0, [r3] - ldr r0, =0x00002e68 - adds r1, r4, r0 - ldr r0, [r5] - adds r0, r1 - bl sub_8122B28 - adds r0, r6, 0x1 - lsls r0, 16 - lsrs r6, r0, 16 - cmp r6, 0x4 - bls _081224DA - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r1, =0x00002e68 - adds r0, r1 - movs r1, 0x5 - movs r2, 0 - bl sub_8122804 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end InitDewfordTrend - - thumb_func_start UpdateDewfordTrendPerDay -UpdateDewfordTrendPerDay: @ 8122580 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x8 - lsls r0, 16 - lsrs r1, r0, 16 - cmp r1, 0 - bne _08122596 - b _081226BE -_08122596: - lsls r0, r1, 2 - adds r0, r1 - str r0, [sp] - movs r0, 0 - mov r10, r0 - movs r1, 0x7F - mov r9, r1 - movs r2, 0x80 - negs r2, r2 - mov r8, r2 -_081225AA: - ldr r2, [sp] - mov r3, r10 - lsls r0, r3, 3 - ldr r4, =0x00002e68 - adds r0, r4 - ldr r3, =gSaveBlock1Ptr - ldr r1, [r3] - adds r5, r1, r0 - ldrb r6, [r5, 0x1] - movs r0, 0x40 - ands r0, r6 - cmp r0, 0 - bne _08122608 - ldrb r4, [r5] - lsls r3, r4, 25 - lsrs r1, r3, 25 - lsls r0, r2, 16 - lsrs r0, 16 - cmp r1, r0 - bcc _081225F8 - adds r0, r1, 0 - subs r0, r2 - mov r1, r9 - ands r0, r1 - mov r1, r8 - ands r1, r4 - orrs r1, r0 - strb r1, [r5] - movs r0, 0x7F - ands r1, r0 - cmp r1, 0 - bne _0812269E - movs r0, 0x40 - orrs r0, r6 - b _0812269C - .pool -_081225F8: - lsrs r0, r3, 25 - subs r2, r0 - mov r0, r8 - ands r0, r4 - strb r0, [r5] - movs r0, 0x40 - orrs r0, r6 - strb r0, [r5, 0x1] -_08122608: - ldrb r7, [r5] - lsls r0, r7, 25 - lsrs r0, 25 - adds r4, r0, r2 - ldrh r0, [r5] - lsls r6, r0, 18 - lsls r0, r4, 16 - lsrs r0, 16 - lsrs r1, r6, 25 - cmp r0, r1 - bls _08122678 - adds r0, r4, 0 - bl __umodsi3 - adds r3, r0, 0 - lsrs r1, r6, 25 - adds r0, r4, 0 - str r3, [sp, 0x4] - bl __udivsi3 - adds r4, r0, 0 - movs r0, 0x1 - eors r4, r0 - ands r4, r0 - lsls r2, r4, 6 - ldrb r0, [r5, 0x1] - movs r4, 0x41 - negs r4, r4 - adds r1, r4, 0 - ands r0, r1 - orrs r0, r2 - strb r0, [r5, 0x1] - movs r1, 0x40 - ands r0, r1 - ldr r3, [sp, 0x4] - cmp r0, 0 - beq _08122662 - adds r1, r3, 0 - mov r0, r9 - ands r1, r0 - mov r0, r8 - ands r0, r7 - orrs r0, r1 - strb r0, [r5] - b _0812269E -_08122662: - ldrh r0, [r5] - lsls r0, 18 - lsrs r0, 25 - subs r0, r3 - mov r1, r9 - ands r0, r1 - mov r1, r8 - ands r1, r7 - orrs r1, r0 - strb r1, [r5] - b _0812269E -_08122678: - mov r2, r9 - ands r4, r2 - mov r0, r8 - ands r0, r7 - orrs r0, r4 - strb r0, [r5] - lsls r0, 25 - ldrh r1, [r5] - lsls r1, 18 - lsrs r0, 25 - lsrs r1, 25 - cmp r0, r1 - bne _0812269E - ldrb r0, [r5, 0x1] - movs r3, 0x41 - negs r3, r3 - adds r1, r3, 0 - ands r0, r1 -_0812269C: - strb r0, [r5, 0x1] -_0812269E: - mov r0, r10 - adds r0, 0x1 - lsls r0, 16 - lsrs r0, 16 - mov r10, r0 - cmp r0, 0x4 - bhi _081226AE - b _081225AA -_081226AE: - ldr r4, =gSaveBlock1Ptr - ldr r0, [r4] - ldr r1, =0x00002e68 - adds r0, r1 - movs r1, 0x5 - movs r2, 0 - bl sub_8122804 -_081226BE: - add sp, 0x8 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end UpdateDewfordTrendPerDay - - thumb_func_start sub_81226D8 -sub_81226D8: @ 81226D8 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x8 - mov r8, r0 - movs r0, 0 - movs r1, 0 - str r0, [sp] - str r1, [sp, 0x4] - mov r0, r8 - bl sub_8122BB0 - lsls r0, 24 - cmp r0, 0 - beq _081226F8 - b _081227F2 -_081226F8: - ldr r4, =0x00000893 - adds r0, r4, 0 - bl FlagGet - lsls r0, 24 - cmp r0, 0 - bne _08122744 - adds r0, r4, 0 - bl FlagSet - ldr r0, =0x00000894 - bl FlagGet - lsls r0, 24 - cmp r0, 0 - bne _08122744 - ldr r0, =gSaveBlock1Ptr - ldr r1, [r0] - mov r0, r8 - ldrh r2, [r0] - ldr r3, =0x00002e6c - adds r0, r1, r3 - strh r2, [r0] - mov r2, r8 - ldrh r0, [r2, 0x2] - adds r3, 0x2 - adds r1, r3 - strh r0, [r1] - movs r0, 0x1 - b _081227F4 - .pool -_08122744: - mov r0, r8 - ldrh r1, [r0, 0x2] - lsls r1, 16 - ldrh r0, [r0] - orrs r0, r1 - str r0, [sp, 0x4] - movs r1, 0x80 - lsls r1, 7 - ldr r0, [sp] - orrs r0, r1 - str r0, [sp] - mov r0, sp - bl sub_8122B28 - movs r5, 0 -_08122762: - ldr r6, =gSaveBlock1Ptr - lsls r4, r5, 3 - ldr r1, =0x00002e68 - adds r0, r4, r1 - ldr r1, [r6] - adds r1, r0 - mov r0, sp - movs r2, 0 - bl atk90_changetypestoenemyattacktype - lsls r0, 24 - adds r7, r4, 0 - cmp r0, 0 - beq _081227D4 - movs r2, 0x4 - mov r12, r6 - cmp r2, r5 - bls _081227A6 - ldr r4, =0x00002e68 -_08122788: - ldr r0, [r6] - lsls r3, r2, 3 - adds r0, r4 - adds r3, r0, r3 - subs r2, 0x1 - lsls r1, r2, 3 - adds r0, r1 - ldr r1, [r0, 0x4] - ldr r0, [r0] - str r0, [r3] - str r1, [r3, 0x4] - lsls r2, 16 - lsrs r2, 16 - cmp r2, r5 - bhi _08122788 -_081227A6: - mov r3, r12 - ldr r2, [r3] - ldr r0, =0x00002e68 - adds r2, r0 - adds r2, r7 - ldr r0, [sp] - ldr r1, [sp, 0x4] - str r0, [r2] - str r1, [r2, 0x4] - cmp r5, 0x4 - bne _081227C2 - mov r0, r8 - bl sub_80EDC60 -_081227C2: - movs r0, 0 - cmp r5, 0 - bne _081227F4 - movs r0, 0x1 - b _081227F4 - .pool -_081227D4: - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - cmp r5, 0x4 - bls _08122762 - ldr r2, [r6] - ldr r1, =0x00002e88 - adds r2, r1 - ldr r0, [sp] - ldr r1, [sp, 0x4] - str r0, [r2] - str r1, [r2, 0x4] - mov r0, r8 - bl sub_80EDC60 -_081227F2: - movs r0, 0 -_081227F4: - add sp, 0x8 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_81226D8 - - thumb_func_start sub_8122804 -sub_8122804: @ 8122804 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - mov r9, r0 - lsls r1, 16 - lsrs r7, r1, 16 - lsls r2, 24 - lsrs r2, 24 - mov r10, r2 - movs r2, 0 - cmp r2, r7 - bcs _0812286C -_08122820: - adds r1, r2, 0x1 - lsls r0, r1, 16 - lsrs r5, r0, 16 - mov r8, r1 - cmp r5, r7 - bcs _08122862 - lsls r0, r2, 3 - mov r1, r9 - adds r6, r1, r0 -_08122832: - lsls r0, r5, 3 - mov r1, r9 - adds r4, r1, r0 - adds r0, r4, 0 - adds r1, r6, 0 - mov r2, r10 - bl atk90_changetypestoenemyattacktype - lsls r0, 24 - cmp r0, 0 - beq _08122858 - ldr r2, [r4] - ldr r3, [r4, 0x4] - ldr r0, [r6] - ldr r1, [r6, 0x4] - str r0, [r4] - str r1, [r4, 0x4] - str r2, [r6] - str r3, [r6, 0x4] -_08122858: - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - cmp r5, r7 - bcc _08122832 -_08122862: - mov r1, r8 - lsls r0, r1, 16 - lsrs r2, r0, 16 - cmp r2, r7 - bcc _08122820 -_0812286C: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_8122804 - - thumb_func_start sub_812287C -sub_812287C: @ 812287C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - mov r8, r0 - adds r6, r1, 0 - movs r4, 0x80 - lsls r4, 1 - adds r0, r4, 0 - bl Alloc - mov r10, r0 - cmp r0, 0 - beq _08122980 - adds r0, r4, 0 - bl Alloc - adds r7, r0, 0 - cmp r7, 0 - bne _081228B0 - mov r0, r10 - bl Free - b _08122980 -_081228B0: - bl GetLinkPlayerCount - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - movs r5, 0 - cmp r5, r9 - bcs _081228DE -_081228C0: - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - add r0, r10 - adds r1, r5, 0 - muls r1, r6 - add r1, r8 - movs r2, 0x28 - bl memcpy - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - cmp r5, r9 - bcc _081228C0 -_081228DE: - mov r4, r10 - mov r8, r7 - movs r3, 0 - movs r5, 0 - cmp r5, r9 - bcs _08122946 -_081228EA: - movs r6, 0 -_081228EC: - adds r0, r7, 0 - adds r1, r4, 0 - adds r2, r3, 0 - str r3, [sp] - bl sub_8122C1C - lsls r0, 16 - asrs r0, 16 - ldr r3, [sp] - cmp r0, 0 - bge _08122918 - ldr r0, [r4] - ldr r1, [r4, 0x4] - mov r2, r8 - adds r2, 0x8 - mov r8, r2 - subs r2, 0x8 - stm r2!, {r0,r1} - adds r0, r3, 0x1 - lsls r0, 16 - lsrs r3, r0, 16 - b _08122930 -_08122918: - lsls r0, 3 - adds r2, r7, r0 - ldrb r1, [r2] - lsls r1, 25 - ldrb r0, [r4] - lsls r0, 25 - cmp r1, r0 - bcs _08122930 - ldr r0, [r4] - ldr r1, [r4, 0x4] - str r0, [r2] - str r1, [r2, 0x4] -_08122930: - adds r4, 0x8 - adds r0, r6, 0x1 - lsls r0, 16 - lsrs r6, r0, 16 - cmp r6, 0x4 - bls _081228EC - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - cmp r5, r9 - bcc _081228EA -_08122946: - adds r0, r7, 0 - adds r1, r3, 0 - movs r2, 0x2 - bl sub_8122804 - adds r4, r7, 0 - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r1, =0x00002e68 - adds r1, r0 - mov r8, r1 - movs r5, 0 -_0812295E: - ldm r4!, {r0,r1} - mov r2, r8 - adds r2, 0x8 - mov r8, r2 - subs r2, 0x8 - stm r2!, {r0,r1} - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - cmp r5, 0x4 - bls _0812295E - mov r0, r10 - bl Free - adds r0, r7, 0 - bl Free -_08122980: - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_812287C - - thumb_func_start sub_8122998 -sub_8122998: @ 8122998 - push {lr} - ldr r2, =gSaveBlock1Ptr - ldr r0, =gSpecialVar_0x8004 - ldrh r1, [r0] - lsls r1, 3 - ldr r0, [r2] - adds r1, r0 - ldr r0, =gStringVar1 - ldr r2, =0x00002e6c - adds r1, r2 - movs r2, 0x2 - movs r3, 0x1 - bl ConvertEasyChatWordsToString - pop {r0} - bx r0 - .pool - thumb_func_end sub_8122998 - - thumb_func_start sub_81229C8 -sub_81229C8: @ 81229C8 - push {r4,lr} - movs r4, 0 - ldr r0, =gSaveBlock1Ptr - ldr r3, [r0] - ldr r1, =0x00002e68 - adds r0, r3, r1 - ldrb r1, [r0] - lsls r1, 25 - lsrs r1, 25 - ldr r2, =0x00002e70 - adds r0, r3, r2 - ldrb r0, [r0] - lsls r0, 25 - lsrs r0, 25 - subs r1, r0 - cmp r1, 0x1 - bgt _08122A0C - ldr r1, =0x00002e69 - adds r0, r3, r1 - ldrb r1, [r0] - movs r2, 0x40 - adds r0, r2, 0 - ands r0, r1 - cmp r0, 0 - bne _08122A0C - ldr r1, =0x00002e71 - adds r0, r3, r1 - ldrb r1, [r0] - adds r0, r2, 0 - ands r0, r1 - lsls r0, 24 - lsrs r0, 24 - negs r0, r0 - lsrs r4, r0, 31 -_08122A0C: - ldr r0, =gSpecialVar_Result - strh r4, [r0] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81229C8 - - thumb_func_start sub_8122A30 -sub_8122A30: @ 8122A30 - ldr r2, =gSpecialVar_Result - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r3, =0x00002e6c - adds r1, r0, r3 - adds r3, 0x2 - adds r0, r3 - ldrh r0, [r0] - ldrh r1, [r1] - adds r0, r1 - movs r1, 0x7 - ands r0, r1 - strh r0, [r2] - bx lr - .pool - thumb_func_end sub_8122A30 - - thumb_func_start atk90_changetypestoenemyattacktype -atk90_changetypestoenemyattacktype: @ 8122A58 - push {r4,r5,lr} - adds r3, r0, 0 - adds r5, r1, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r2, 0 - cmp r2, 0x1 - beq _08122A9E - cmp r2, 0x1 - bgt _08122A72 - cmp r2, 0 - beq _08122A78 - b _08122B1A -_08122A72: - cmp r0, 0x2 - beq _08122ACA - b _08122B1A -_08122A78: - ldrb r0, [r3] - lsls r1, r0, 25 - ldrb r0, [r5] - lsls r0, 25 - cmp r1, r0 - bhi _08122B16 - cmp r1, r0 - bcc _08122AC6 - ldrh r0, [r3] - lsls r3, r0, 18 - ldrh r0, [r5] - lsls r2, r0, 18 - lsrs r1, r3, 25 - lsrs r0, r2, 25 - cmp r1, r0 - bhi _08122B16 - lsrs r1, r3, 25 - lsrs r0, r2, 25 - b _08122AC2 -_08122A9E: - ldrh r0, [r3] - lsls r4, r0, 18 - ldrh r0, [r5] - lsls r2, r0, 18 - lsrs r1, r4, 25 - lsrs r0, r2, 25 - cmp r1, r0 - bhi _08122B16 - lsrs r1, r4, 25 - lsrs r0, r2, 25 - cmp r1, r0 - bcc _08122AC6 - ldrb r0, [r3] - lsls r1, r0, 25 - ldrb r0, [r5] - lsls r0, 25 - cmp r1, r0 - bhi _08122B16 -_08122AC2: - cmp r1, r0 - bcs _08122B1A -_08122AC6: - movs r0, 0 - b _08122B22 -_08122ACA: - ldrb r0, [r3] - lsls r1, r0, 25 - ldrb r0, [r5] - lsls r0, 25 - cmp r1, r0 - bhi _08122B16 - cmp r1, r0 - bcc _08122AC6 - ldrh r0, [r3] - lsls r4, r0, 18 - ldrh r0, [r5] - lsls r2, r0, 18 - lsrs r1, r4, 25 - lsrs r0, r2, 25 - cmp r1, r0 - bhi _08122B16 - lsrs r1, r4, 25 - lsrs r0, r2, 25 - cmp r1, r0 - bcc _08122AC6 - ldrh r1, [r3, 0x2] - ldrh r0, [r5, 0x2] - cmp r1, r0 - bhi _08122B16 - cmp r1, r0 - bcc _08122AC6 - ldrh r1, [r3, 0x4] - ldrh r0, [r5, 0x4] - cmp r1, r0 - bhi _08122B16 - cmp r1, r0 - bcc _08122AC6 - ldrh r1, [r3, 0x6] - ldrh r0, [r5, 0x6] - cmp r1, r0 - bhi _08122B16 - cmp r1, r0 - bcc _08122AC6 -_08122B16: - movs r0, 0x1 - b _08122B22 -_08122B1A: - bl Random - movs r1, 0x1 - ands r0, r1 -_08122B22: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end atk90_changetypestoenemyattacktype - - thumb_func_start sub_8122B28 -sub_8122B28: @ 8122B28 - push {r4,r5,lr} - adds r5, r0, 0 - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x62 - bl __umodsi3 - lsls r0, 16 - lsrs r4, r0, 16 - cmp r4, 0x32 - bls _08122B6A - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x62 - bl __umodsi3 - lsls r0, 16 - lsrs r4, r0, 16 - cmp r4, 0x50 - bls _08122B6A - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x62 - bl __umodsi3 - lsls r0, 16 - lsrs r4, r0, 16 -_08122B6A: - adds r1, r4, 0 - adds r1, 0x1E - movs r0, 0x7F - ands r1, r0 - lsls r1, 7 - ldrh r2, [r5] - ldr r0, =0xffffc07f - ands r0, r2 - orrs r0, r1 - strh r0, [r5] - bl Random - lsls r0, 16 - lsrs r0, 16 - adds r1, r4, 0x1 - bl __modsi3 - adds r0, 0x1E - movs r1, 0x7F - ands r0, r1 - ldrb r2, [r5] - movs r1, 0x80 - negs r1, r1 - ands r1, r2 - orrs r1, r0 - strb r1, [r5] - bl Random - strh r0, [r5, 0x2] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8122B28 - - thumb_func_start sub_8122BB0 -sub_8122BB0: @ 8122BB0 - push {r4-r6,lr} - adds r5, r0, 0 - movs r4, 0 - ldr r6, =gSaveBlock1Ptr -_08122BB8: - lsls r1, r4, 3 - ldr r0, [r6] - adds r1, r0 - ldr r0, =0x00002e6c - adds r1, r0 - adds r0, r5, 0 - bl sub_8122BF0 - lsls r0, 24 - cmp r0, 0 - beq _08122BDC - movs r0, 0x1 - b _08122BE8 - .pool -_08122BDC: - adds r0, r4, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 - cmp r4, 0x4 - bls _08122BB8 - movs r0, 0 -_08122BE8: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_8122BB0 - - thumb_func_start sub_8122BF0 -sub_8122BF0: @ 8122BF0 - push {r4,lr} - adds r3, r0, 0 - adds r2, r1, 0 - movs r4, 0 -_08122BF8: - ldrh r1, [r3] - ldrh r0, [r2] - adds r2, 0x2 - adds r3, 0x2 - cmp r1, r0 - beq _08122C08 - movs r0, 0 - b _08122C14 -_08122C08: - adds r0, r4, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 - cmp r4, 0x1 - bls _08122BF8 - movs r0, 0x1 -_08122C14: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8122BF0 - - thumb_func_start sub_8122C1C -sub_8122C1C: @ 8122C1C - push {r4-r7,lr} - adds r5, r0, 0 - adds r7, r1, 0 - lsls r2, 16 - lsrs r6, r2, 16 - movs r4, 0 - cmp r4, r6 - bge _08122C52 -_08122C2C: - adds r1, r5, 0x4 - adds r0, r7, 0x4 - bl sub_8122BF0 - lsls r0, 24 - cmp r0, 0 - beq _08122C40 - lsls r0, r4, 16 - asrs r0, 16 - b _08122C56 -_08122C40: - adds r5, 0x8 - lsls r0, r4, 16 - movs r1, 0x80 - lsls r1, 9 - adds r0, r1 - lsrs r4, r0, 16 - asrs r0, 16 - cmp r0, r6 - blt _08122C2C -_08122C52: - movs r0, 0x1 - negs r0, r0 -_08122C56: - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_8122C1C - - .align 2, 0 @ Don't pad with nop. diff --git a/data/event_scripts.s b/data/event_scripts.s index 1343a4fa9..25b0c7b52 100644 --- a/data/event_scripts.s +++ b/data/event_scripts.s @@ -1890,7 +1890,7 @@ DewfordTown_EventScript_271E8B:: @ 8271E8B DewfordTown_Hall_EventScript_271E8B:: @ 8271E8B dodailyevents setvar VAR_0x8004, 0 - special sub_8122998 + special BufferTrendyPhraseString return DewfordTown_EventScript_271E95:: @ 8271E95 diff --git a/data/scripts/maps/DewfordTown_Hall.inc b/data/scripts/maps/DewfordTown_Hall.inc index 3f9518722..4d4c3732d 100644 --- a/data/scripts/maps/DewfordTown_Hall.inc +++ b/data/scripts/maps/DewfordTown_Hall.inc @@ -5,7 +5,7 @@ DewfordTown_Hall_EventScript_1FD4D0:: @ 81FD4D0 lock faceplayer call DewfordTown_Hall_EventScript_271E8B - special sub_81229C8 + special TrendyPhraseIsOld compare VAR_RESULT, 1 goto_eq DewfordTown_Hall_EventScript_1FD4EF msgbox DewfordTown_Hall_Text_1FD818, 4 @@ -87,7 +87,7 @@ DewfordTown_Hall_EventScript_1FD590:: @ 81FD590 DewfordTown_Hall_EventScript_1FD5A0:: @ 81FD5A0 lockall call DewfordTown_Hall_EventScript_271E8B - special sub_8122A30 + special GetDewfordHallPaintingNameIndex switch VAR_RESULT case 0, DewfordTown_Hall_EventScript_1FD607 case 4, DewfordTown_Hall_EventScript_1FD607 @@ -133,7 +133,7 @@ DewfordTown_Hall_EventScript_1FD63B:: @ 81FD63B DewfordTown_Hall_EventScript_1FD647:: @ 81FD647 call DewfordTown_Hall_EventScript_271E8B - special sub_8122A30 + special GetDewfordHallPaintingNameIndex switch VAR_RESULT case 0, DewfordTown_Hall_EventScript_1FD6AD case 1, DewfordTown_Hall_EventScript_1FD6AD diff --git a/data/specials.inc b/data/specials.inc index ab1a441ff..394e4a10e 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -137,10 +137,10 @@ gSpecials:: @ 81DBA64 def_special TV_PutNameRaterShowOnTheAirIfNicnkameChanged def_special TV_CopyNicknameToStringVar1AndEnsureTerminated def_special TV_CheckMonOTIDEqualsPlayerID - def_special sub_8122998 - def_special sub_81229C8 + def_special BufferTrendyPhraseString + def_special TrendyPhraseIsOld def_special sub_811EF6C - def_special sub_8122A30 + def_special GetDewfordHallPaintingNameIndex def_special sub_80D6EDC def_special CalculatePlayerPartyCount def_special CountPartyNonEggMons diff --git a/include/easy_chat.h b/include/easy_chat.h index f0ac51c22..e5fdc8bea 100644 --- a/include/easy_chat.h +++ b/include/easy_chat.h @@ -35,5 +35,6 @@ bool32 sub_811F8D8(u16 word); void InitializeEasyChatWordArray(u16 *words, u16 length); void ConvertEasyChatWordsToString(u8 *dest, const u16 *src, u16 length1, u16 length2); bool8 ECWord_CheckIfOutsideOfValidRange(u16 word); +u16 sub_811EE38(u16 group); #endif // GUARD_EASYCHAT_H diff --git a/ld_script.txt b/ld_script.txt index dda870d54..7f3026980 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -165,7 +165,7 @@ SECTIONS { asm/mauville_old_man.o(.text); src/mail.o(.text); asm/menu_helpers.o(.text); - asm/dewford_trend.o(.text); + src/dewford_trend.o(.text); src/heal_location.o(.text); src/region_map.o(.text); asm/cute_sketch.o(.text); diff --git a/src/dewford_trend.c b/src/dewford_trend.c new file mode 100644 index 000000000..3ceec6563 --- /dev/null +++ b/src/dewford_trend.c @@ -0,0 +1,340 @@ +#include "global.h" +#include "dewford_trend.h" +#include "easy_chat.h" +#include "constants/easy_chat.h" +#include "event_data.h" +#include "link.h" +#include "malloc.h" +#include "random.h" +#include "text.h" +#include "tv.h" + +// static functions +static void sub_8122804(struct EasyChatPair *s, u16 b, u8 c); +static bool8 sub_8122A58(struct EasyChatPair *a, struct EasyChatPair *b, u8 c); +static void sub_8122B28(struct EasyChatPair *s); +static bool8 SB1ContainsWords(u16 *a); +static bool8 IsEasyChatPairEqual(u16 *words1, u16 *words2); +static s16 GetEqualEasyChatPairIndex(struct EasyChatPair *s, struct EasyChatPair *a, u16 b); + +// text +void InitDewfordTrend(void) +{ + u16 i; + + for (i = 0; i < 5; i++) + { + gSaveBlock1Ptr->easyChatPairs[i].words[0] = sub_811EE38(EC_GROUP_CONDITIONS); + + if (Random() & 1) + gSaveBlock1Ptr->easyChatPairs[i].words[1] = sub_811EE38(EC_GROUP_LIFESTYLE); + else + gSaveBlock1Ptr->easyChatPairs[i].words[1] = sub_811EE38(EC_GROUP_HOBBIES); + + gSaveBlock1Ptr->easyChatPairs[i].unk1_6 = Random() & 1; + sub_8122B28(&(gSaveBlock1Ptr->easyChatPairs[i])); + } + sub_8122804(gSaveBlock1Ptr->easyChatPairs, 5, 0); +} + +void UpdateDewfordTrendPerDay(u16 a) +{ + u16 i; + + if (a != 0) + { + u32 sp0 = a * 5; + + for (i = 0; i < 5; i++) + { + u32 r4; + u32 r2 = sp0; + struct EasyChatPair *r5 = &(gSaveBlock1Ptr->easyChatPairs[i]); + + if (r5->unk1_6 == 0) + { + if (r5->unk0_0 >= (u16)r2) + { + r5->unk0_0 -= r2; + if (r5->unk0_0 == 0) + r5->unk1_6 = 1; + continue; + } + r2 -= r5->unk0_0; + r5->unk0_0 = 0; + r5->unk1_6 = 1; + } + r4 = r5->unk0_0 + r2; + if ((u16)r4 > r5->unk0_7) + { + u32 sp4 = r4 % r5->unk0_7; + r4 = r4 / r5->unk0_7; + + r5->unk1_6 = r4 ^ 1; + if (r5->unk1_6) + r5->unk0_0 = sp4; + else + r5->unk0_0 = r5->unk0_7 - sp4; + } + else + { + r5->unk0_0 = r4; + + if (r5->unk0_0 == r5->unk0_7) + r5->unk1_6 = 0; + } + } + sub_8122804(gSaveBlock1Ptr->easyChatPairs, 5, 0); + } +} + + +bool8 sub_81226D8(u16 *a) +{ + struct EasyChatPair s = {0}; + u16 i; + + if (!SB1ContainsWords(a)) + { + if (!FlagGet(FLAG_SYS_POPWORD_INPUT)) + { + FlagSet(FLAG_SYS_POPWORD_INPUT); + if (!FlagGet(FLAG_SYS_MIX_RECORD)) + { + gSaveBlock1Ptr->easyChatPairs[0].words[0] = a[0]; + gSaveBlock1Ptr->easyChatPairs[0].words[1] = a[1]; + return TRUE; + } + } + + s.words[0] = a[0]; + s.words[1] = a[1]; + s.unk1_6 = 1; + sub_8122B28(&s); + + for (i = 0; i < 5; i++) + { + if (sub_8122A58(&s, &(gSaveBlock1Ptr->easyChatPairs[i]), 0)) + { + u16 r3 = 4; + + while (r3 > i) + { + gSaveBlock1Ptr->easyChatPairs[r3] = gSaveBlock1Ptr->easyChatPairs[r3 - 1]; + r3--; + } + gSaveBlock1Ptr->easyChatPairs[i] = s; + if(i == 4) + sub_80EDC60(a); + return (i == 0); + } + } + gSaveBlock1Ptr->easyChatPairs[4] = s; + sub_80EDC60(a); + } + return FALSE; +} + + +static void sub_8122804(struct EasyChatPair *s, u16 b, u8 c) +{ + u16 h; + + for (h = 0; h < b; h++) + { + u16 i; + + for (i = h + 1; i < b; i++) + { + if (sub_8122A58(&s[i], &s[h], c)) + { + struct EasyChatPair temp; + + temp = s[i]; + s[i] = s[h]; + s[h] = temp; + } + } + } +} + +void sub_812287C(void *a, u32 b, u8 unused) +{ + u16 i, j, r3, players; + struct EasyChatPair *buffer1, *buffer2, *src, *dst, *foo_of_buffer2; + + buffer1 = Alloc(0x100); + if(buffer1 != NULL) + { + buffer2 = Alloc(0x100); + if(buffer2 == NULL) + { + Free(buffer1); + } + else + { + players = GetLinkPlayerCount(); + for (i = 0; i < players; i++) + memcpy(&(buffer1[i * 5]), (u8 *)a + i * b, 40); + src = buffer1; + dst = buffer2; + r3 = 0; + for (i = 0; i < players; i++) + { + for (j = 0; j < 5; j++) + { + s16 foo = GetEqualEasyChatPairIndex(buffer2, src, r3); + if (foo < 0) + { + *(dst++) = *src; + r3++; + } + else + { + foo_of_buffer2 = (struct EasyChatPair *)((u32)buffer2 + (foo * 8)); //required to do this to reverse the order of register operands in add ASM statement + if (foo_of_buffer2->unk0_0 < src->unk0_0) + { + *foo_of_buffer2 = *src; + } + } + src++; + } + } + sub_8122804(buffer2, r3, 2); + src = buffer2; + dst = gSaveBlock1Ptr->easyChatPairs; + for (i = 0; i < 5; i++) + *(dst++) = *(src++); + Free(buffer1); + Free(buffer2); + } + } +} + +void BufferTrendyPhraseString(void) +{ + struct EasyChatPair *s = &gSaveBlock1Ptr->easyChatPairs[gSpecialVar_0x8004]; + + ConvertEasyChatWordsToString(gStringVar1, s->words, 2, 1); +} + +void TrendyPhraseIsOld(void) +{ + u16 result = 0; + + if (gSaveBlock1Ptr->easyChatPairs[0].unk0_0 - gSaveBlock1Ptr->easyChatPairs[1].unk0_0 < 2) + { + asm("":::"r2"); //Force the compiler to store address of gSaveBlock1 in r3 instead of r2 + if (!gSaveBlock1Ptr->easyChatPairs[0].unk1_6 && gSaveBlock1Ptr->easyChatPairs[1].unk1_6) + result = 1; + } + gSpecialVar_Result = result; +} + +void GetDewfordHallPaintingNameIndex(void) +{ + gSpecialVar_Result = (gSaveBlock1Ptr->easyChatPairs[0].words[0] + gSaveBlock1Ptr->easyChatPairs[0].words[1]) & 7; +} + +static bool8 sub_8122A58(struct EasyChatPair *a, struct EasyChatPair *b, u8 c) +{ + switch (c) + { + case 0: + if (a->unk0_0 > b->unk0_0) + return 1; + if (a->unk0_0 < b->unk0_0) + return 0; + if (a->unk0_7 > b->unk0_7) + return 1; + if (a->unk0_7 < b->unk0_7) + return 0; + break; + case 1: + if (a->unk0_7 > b->unk0_7) + return 1; + if (a->unk0_7 < b->unk0_7) + return 0; + if (a->unk0_0 > b->unk0_0) + return 1; + if (a->unk0_0 < b->unk0_0) + return 0; + break; + case 2: + if (a->unk0_0 > b->unk0_0) + return 1; + if (a->unk0_0 < b->unk0_0) + return 0; + if (a->unk0_7 > b->unk0_7) + return 1; + if (a->unk0_7 < b->unk0_7) + return 0; + if (a->unk2 > b->unk2) + return 1; + if (a->unk2 < b->unk2) + return 0; + if (a->words[0] > b->words[0]) + return 1; + if (a->words[0] < b->words[0]) + return 0; + if (a->words[1] > b->words[1]) + return 1; + if (a->words[1] < b->words[1]) + return 0; + return 1; + } + return Random() & 1; +} + +static void sub_8122B28(struct EasyChatPair *s) +{ + u16 r4; + + r4 = Random() % 98; + if (r4 > 50) + { + r4 = Random() % 98; + if (r4 > 80) + r4 = Random() % 98; + } + s->unk0_7 = r4 + 30; + s->unk0_0 = (Random() % (r4 + 1)) + 30; + s->unk2 = Random(); +} + +static bool8 SB1ContainsWords(u16 *a) +{ + u16 i; + + for (i = 0; i < 5; i++) + { + if (IsEasyChatPairEqual(a, gSaveBlock1Ptr->easyChatPairs[i].words) != 0) + return TRUE; + } + return FALSE; +} + +static bool8 IsEasyChatPairEqual(u16 *words1, u16 *words2) +{ + u16 i; + + for (i = 0; i < 2; i++) + { + if (*(words1++) != *(words2++)) + return FALSE; + } + return TRUE; +} + +static s16 GetEqualEasyChatPairIndex(struct EasyChatPair*s, struct EasyChatPair *a, u16 b) +{ + s16 i; + + for (i = 0; i < b; i++) + { + if (IsEasyChatPairEqual(a->words, s->words)) + return i; + s++; + } + return -1; +}