diff --git a/asm/contest_painting_effects.s b/asm/contest_painting_effects.s index 36ef184b9..f9f2b96fc 100644 --- a/asm/contest_painting_effects.s +++ b/asm/contest_painting_effects.s @@ -5,1728 +5,6 @@ .text - thumb_func_start sub_8124F2C -sub_8124F2C: @ 8124F2C - push {lr} - ldr r2, =gUnknown_03006168 - ldr r1, [r0, 0x4] - str r1, [r2] - ldr r2, =gUnknown_0300617C - ldrb r1, [r0, 0x1F] - strb r1, [r2] - ldr r2, =gUnknown_03006164 - ldrb r1, [r0, 0x19] - strb r1, [r2] - ldr r2, =gUnknown_03006178 - ldrb r1, [r0, 0x1A] - strb r1, [r2] - ldr r2, =gUnknown_03006174 - ldrb r1, [r0, 0x1B] - strb r1, [r2] - ldr r2, =gUnknown_0300616C - ldrb r1, [r0, 0x1C] - strb r1, [r2] - ldr r2, =gUnknown_03006180 - ldrb r1, [r0, 0x1D] - strb r1, [r2] - ldr r2, =gUnknown_03006170 - ldrb r1, [r0, 0x1E] - strb r1, [r2] - ldrb r0, [r0] - subs r0, 0x2 - cmp r0, 0x22 - bls _08124F68 - b _081250B4 -_08124F68: - lsls r0, 2 - ldr r1, =_08124F98 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08124F98: - .4byte _08125024 - .4byte _081250B4 - .4byte _081250B4 - .4byte _081250B4 - .4byte _08125084 - .4byte _081250B4 - .4byte _0812502A - .4byte _08125030 - .4byte _08125044 - .4byte _08125056 - .4byte _081250B4 - .4byte _0812506C - .4byte _081250B4 - .4byte _081250B4 - .4byte _081250B4 - .4byte _081250B4 - .4byte _081250B4 - .4byte _081250B4 - .4byte _081250B4 - .4byte _081250B4 - .4byte _081250B4 - .4byte _081250B4 - .4byte _081250B4 - .4byte _081250B4 - .4byte _081250B4 - .4byte _081250B4 - .4byte _081250B4 - .4byte _081250B4 - .4byte _08125072 - .4byte _08125050 - .4byte _08125078 - .4byte _0812507E - .4byte _081250B4 - .4byte _081250B4 - .4byte _08125090 -_08125024: - bl sub_8125230 - b _081250B4 -_0812502A: - bl sub_81252E8 - b _081250B4 -_08125030: - bl sub_81254E0 - ldr r0, =gUnknown_0300617C - ldrb r0, [r0] - bl sub_81253A4 - b _081250B4 - .pool -_08125044: - bl sub_81254E0 - bl sub_8125630 - bl sub_8125448 -_08125050: - bl sub_8125630 - b _081250B4 -_08125056: - bl sub_81254E0 - bl sub_81257F8 - bl sub_81257F8 - bl sub_81258A0 - bl sub_8125448 - b _081250B4 -_0812506C: - bl sub_81256C8 - b _081250B4 -_08125072: - bl sub_81254E0 - b _081250B4 -_08125078: - bl sub_81257F8 - b _081250B4 -_0812507E: - bl sub_81258A0 - b _081250B4 -_08125084: - bl sub_8125250 - movs r0, 0x3 - bl sub_81250B8 - b _081250B4 -_08125090: - bl sub_81254E0 - bl sub_81257F8 - bl sub_81258A0 - bl sub_8125448 - bl sub_81252E8 - bl sub_81252E8 - movs r0, 0x2 - bl sub_81250B8 - movs r0, 0x4 - bl sub_8125170 -_081250B4: - pop {r0} - bx r0 - thumb_func_end sub_8124F2C - - thumb_func_start sub_81250B8 -sub_81250B8: @ 81250B8 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - lsls r0, 24 - lsrs r7, r0, 24 - movs r2, 0 - ldr r0, =gUnknown_0300616C - mov r8, r0 - ldrb r0, [r0] - cmp r2, r0 - bcs _0812514A - ldr r1, =gUnknown_03006174 - mov r12, r1 - ldr r3, =gUnknown_03006180 - mov r10, r3 - ldr r0, =gUnknown_03006164 - mov r9, r0 -_081250DE: - ldr r1, =gUnknown_03006178 - ldrb r0, [r1] - adds r0, r2 - mov r3, r10 - ldrb r1, [r3] - muls r0, r1 - lsls r0, 1 - ldr r3, =gUnknown_03006168 - ldr r1, [r3] - adds r1, r0 - mov r3, r9 - ldrb r0, [r3] - lsls r0, 1 - adds r3, r1, r0 - movs r4, 0 - adds r5, r2, 0x1 - mov r0, r12 - ldrb r0, [r0] - cmp r4, r0 - bcs _0812513E - movs r6, 0x80 - lsls r6, 8 -_0812510A: - ldrh r1, [r3] - adds r0, r6, 0 - ands r0, r1 - cmp r0, 0 - bne _0812512E - movs r0, 0x1F - ands r0, r1 - adds r0, r7 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x1F - bls _08125124 - movs r2, 0x1F -_08125124: - lsls r0, r2, 10 - lsls r1, r2, 5 - orrs r0, r1 - orrs r0, r2 - strh r0, [r3] -_0812512E: - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - adds r3, 0x2 - mov r1, r12 - ldrb r1, [r1] - cmp r4, r1 - bcc _0812510A -_0812513E: - lsls r0, r5, 24 - lsrs r2, r0, 24 - mov r3, r8 - ldrb r3, [r3] - cmp r2, r3 - bcc _081250DE -_0812514A: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81250B8 - - thumb_func_start sub_8125170 -sub_8125170: @ 8125170 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - movs r2, 0 - ldr r0, =gUnknown_0300616C - ldrb r0, [r0] - cmp r2, r0 - bcs _08125208 - ldr r1, =gUnknown_03006174 - mov r10, r1 -_0812518E: - ldr r3, =gUnknown_03006178 - ldrb r0, [r3] - adds r0, r2 - ldr r3, =gUnknown_03006180 - ldrb r1, [r3] - muls r0, r1 - lsls r0, 1 - ldr r3, =gUnknown_03006168 - ldr r1, [r3] - adds r1, r0 - ldr r3, =gUnknown_03006164 - ldrb r0, [r3] - lsls r0, 1 - adds r3, r1, r0 - movs r5, 0 - adds r7, r2, 0x1 - mov r0, r10 - ldrb r0, [r0] - cmp r5, r0 - bcs _081251FC - movs r1, 0x80 - lsls r1, 8 - mov r9, r1 - movs r0, 0x1F - mov r12, r0 - mov r1, r8 - subs r6, r0, r1 -_081251C4: - ldrh r1, [r3] - mov r0, r9 - ands r0, r1 - cmp r0, 0 - bne _081251EC - movs r4, 0x1F - mov r2, r12 - ands r2, r1 - cmp r2, r6 - ble _081251E2 - mov r1, r8 - lsrs r0, r1, 1 - subs r0, r4, r0 - lsls r0, 24 - lsrs r2, r0, 24 -_081251E2: - lsls r0, r2, 10 - lsls r1, r2, 5 - orrs r0, r1 - orrs r0, r2 - strh r0, [r3] -_081251EC: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - adds r3, 0x2 - mov r0, r10 - ldrb r0, [r0] - cmp r5, r0 - bcc _081251C4 -_081251FC: - lsls r0, r7, 24 - lsrs r2, r0, 24 - ldr r1, =gUnknown_0300616C - ldrb r1, [r1] - cmp r2, r1 - bcc _0812518E -_08125208: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8125170 - - thumb_func_start sub_8125230 -sub_8125230: @ 8125230 - push {r4,r5,lr} - movs r4, 0 - ldr r5, =0x00000c7f -_08125236: - lsls r0, r4, 16 - lsrs r0, 16 - bl sub_8125954 - adds r4, 0x1 - cmp r4, r5 - bls _08125236 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8125230 - - thumb_func_start sub_8125250 -sub_8125250: @ 8125250 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x4 - movs r2, 0 - ldr r0, =gUnknown_0300616C - ldrb r0, [r0] - cmp r2, r0 - bcs _081252C2 - ldr r0, =gUnknown_03006168 - mov r8, r0 - ldr r3, =gUnknown_03006174 -_08125268: - ldr r0, =gUnknown_03006178 - ldrb r1, [r0] - adds r1, r2 - ldr r0, =gUnknown_03006180 - ldrb r0, [r0] - muls r0, r1 - lsls r0, 1 - mov r4, r8 - ldr r1, [r4] - adds r1, r0 - ldr r0, =gUnknown_03006164 - ldrb r0, [r0] - lsls r0, 1 - adds r4, r1, r0 - movs r5, 0 - adds r6, r2, 0x1 - ldrb r0, [r3] - cmp r5, r0 - bcs _081252B6 - movs r0, 0x80 - lsls r0, 8 - adds r7, r0, 0 -_08125294: - ldrh r0, [r4] - ands r0, r7 - cmp r0, 0 - bne _081252A8 - adds r0, r4, 0 - str r3, [sp] - bl sub_8125B28 - strh r0, [r4] - ldr r3, [sp] -_081252A8: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - adds r4, 0x2 - ldrb r0, [r3] - cmp r5, r0 - bcc _08125294 -_081252B6: - lsls r0, r6, 24 - lsrs r2, r0, 24 - ldr r0, =gUnknown_0300616C - ldrb r0, [r0] - cmp r2, r0 - bcc _08125268 -_081252C2: - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8125250 - - thumb_func_start sub_81252E8 -sub_81252E8: @ 81252E8 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x8 - movs r2, 0 - ldr r0, =gUnknown_03006174 - ldrb r0, [r0] - cmp r2, r0 - bcs _0812537E - ldr r0, =gUnknown_03006168 - mov r8, r0 - ldr r3, =gUnknown_03006180 -_08125300: - ldr r0, =gUnknown_03006178 - ldrb r1, [r0] - ldrb r0, [r3] - muls r0, r1 - lsls r0, 1 - mov r4, r8 - ldr r1, [r4] - adds r1, r0 - ldr r0, =gUnknown_03006164 - ldrb r0, [r0] - adds r0, r2 - lsls r0, 1 - adds r4, r1, r0 - ldrh r1, [r4] - mov r0, sp - strh r1, [r0] - movs r5, 0x1 - ldrb r0, [r3] - lsls r0, 1 - adds r4, r0 - ldr r0, =gUnknown_0300616C - ldrb r0, [r0] - subs r0, 0x1 - adds r7, r2, 0x1 - cmp r5, r0 - bge _08125372 - ldr r6, =gUnknown_03006180 -_08125336: - ldrh r0, [r4] - movs r2, 0x80 - lsls r2, 8 - adds r1, r2, 0 - ands r0, r1 - cmp r0, 0 - bne _0812535C - ldrb r2, [r6] - lsls r2, 1 - adds r2, r4, r2 - mov r0, sp - adds r1, r4, 0 - str r3, [sp, 0x4] - bl sub_8125E18 - strh r0, [r4] - mov r1, sp - strh r0, [r1] - ldr r3, [sp, 0x4] -_0812535C: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - ldrb r0, [r6] - lsls r0, 1 - adds r4, r0 - ldr r0, =gUnknown_0300616C - ldrb r0, [r0] - subs r0, 0x1 - cmp r5, r0 - blt _08125336 -_08125372: - lsls r0, r7, 24 - lsrs r2, r0, 24 - ldr r0, =gUnknown_03006174 - ldrb r0, [r0] - cmp r2, r0 - bcc _08125300 -_0812537E: - add sp, 0x8 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81252E8 - - thumb_func_start sub_81253A4 -sub_81253A4: @ 81253A4 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x4 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - movs r2, 0 - ldr r0, =gUnknown_0300616C - ldrb r0, [r0] - cmp r2, r0 - bcs _08125420 - ldr r0, =gUnknown_03006168 - mov r9, r0 - ldr r3, =gUnknown_03006174 -_081253C4: - ldr r0, =gUnknown_03006178 - ldrb r1, [r0] - adds r1, r2 - ldr r0, =gUnknown_03006180 - ldrb r0, [r0] - muls r0, r1 - lsls r0, 1 - mov r4, r9 - ldr r1, [r4] - adds r1, r0 - ldr r0, =gUnknown_03006164 - ldrb r0, [r0] - lsls r0, 1 - adds r4, r1, r0 - movs r5, 0 - adds r6, r2, 0x1 - ldrb r0, [r3] - cmp r5, r0 - bcs _08125414 - movs r0, 0x80 - lsls r0, 8 - adds r7, r0, 0 -_081253F0: - ldrh r0, [r4] - ands r0, r7 - cmp r0, 0 - bne _08125406 - adds r0, r4, 0 - mov r1, r8 - str r3, [sp] - bl sub_8125B5C - strh r0, [r4] - ldr r3, [sp] -_08125406: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - adds r4, 0x2 - ldrb r0, [r3] - cmp r5, r0 - bcc _081253F0 -_08125414: - lsls r0, r6, 24 - lsrs r2, r0, 24 - ldr r0, =gUnknown_0300616C - ldrb r0, [r0] - cmp r2, r0 - bcc _081253C4 -_08125420: - add sp, 0x4 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81253A4 - - thumb_func_start sub_8125448 -sub_8125448: @ 8125448 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x4 - movs r2, 0 - ldr r0, =gUnknown_0300616C - ldrb r0, [r0] - cmp r2, r0 - bcs _081254BA - ldr r0, =gUnknown_03006168 - mov r8, r0 - ldr r3, =gUnknown_03006174 -_08125460: - ldr r0, =gUnknown_03006178 - ldrb r1, [r0] - adds r1, r2 - ldr r0, =gUnknown_03006180 - ldrb r0, [r0] - muls r0, r1 - lsls r0, 1 - mov r4, r8 - ldr r1, [r4] - adds r1, r0 - ldr r0, =gUnknown_03006164 - ldrb r0, [r0] - lsls r0, 1 - adds r4, r1, r0 - movs r5, 0 - adds r6, r2, 0x1 - ldrb r0, [r3] - cmp r5, r0 - bcs _081254AE - movs r0, 0x80 - lsls r0, 8 - adds r7, r0, 0 -_0812548C: - ldrh r0, [r4] - ands r0, r7 - cmp r0, 0 - bne _081254A0 - adds r0, r4, 0 - str r3, [sp] - bl sub_8125C68 - strh r0, [r4] - ldr r3, [sp] -_081254A0: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - adds r4, 0x2 - ldrb r0, [r3] - cmp r5, r0 - bcc _0812548C -_081254AE: - lsls r0, r6, 24 - lsrs r2, r0, 24 - ldr r0, =gUnknown_0300616C - ldrb r0, [r0] - cmp r2, r0 - bcc _08125460 -_081254BA: - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8125448 - - thumb_func_start sub_81254E0 -sub_81254E0: @ 81254E0 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - movs r7, 0 - ldr r0, =gUnknown_0300616C - ldrb r0, [r0] - cmp r7, r0 - bcs _0812556C - ldr r0, =gUnknown_03006168 - mov r8, r0 -_081254F6: - ldr r0, =gUnknown_03006178 - ldrb r1, [r0] - adds r1, r7 - ldr r0, =gUnknown_03006180 - ldrb r0, [r0] - muls r0, r1 - lsls r0, 1 - mov r2, r8 - ldr r1, [r2] - adds r1, r0 - ldr r0, =gUnknown_03006164 - ldrb r0, [r0] - lsls r0, 1 - adds r5, r1, r0 - adds r4, r5, 0x2 - adds r0, r5, 0 - adds r1, r4, 0 - bl sub_8125C98 - strh r0, [r5] - movs r6, 0x1 - adds r5, r4, 0 - ldr r0, =gUnknown_03006174 - ldrb r0, [r0] - subs r0, 0x1 - adds r7, 0x1 - cmp r6, r0 - bge _08125556 -_0812552E: - adds r4, r5, 0x2 - adds r0, r5, 0 - adds r1, r4, 0 - bl sub_8125C98 - strh r0, [r5] - subs r1, r5, 0x2 - adds r0, r5, 0 - bl sub_8125C98 - strh r0, [r5] - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 - adds r5, r4, 0 - ldr r0, =gUnknown_03006174 - ldrb r0, [r0] - subs r0, 0x1 - cmp r6, r0 - blt _0812552E -_08125556: - subs r1, r5, 0x2 - adds r0, r5, 0 - bl sub_8125C98 - strh r0, [r5] - lsls r0, r7, 24 - lsrs r7, r0, 24 - ldr r0, =gUnknown_0300616C - ldrb r0, [r0] - cmp r7, r0 - bcc _081254F6 -_0812556C: - movs r6, 0 - ldr r0, =gUnknown_03006174 - ldrb r0, [r0] - cmp r6, r0 - bcs _0812560C - ldr r3, =gUnknown_03006168 - mov r9, r3 - ldr r0, =gUnknown_03006180 - mov r8, r0 -_0812557E: - ldr r0, =gUnknown_03006178 - ldrb r0, [r0] - mov r2, r8 - ldrb r1, [r2] - muls r0, r1 - lsls r0, 1 - mov r3, r9 - ldr r2, [r3] - adds r2, r0 - ldr r0, =gUnknown_03006164 - ldrb r0, [r0] - adds r0, r6 - lsls r0, 1 - adds r5, r2, r0 - lsls r1, 1 - adds r1, r5, r1 - adds r0, r5, 0 - bl sub_8125C98 - strh r0, [r5] - movs r7, 0x1 - mov r1, r8 - ldrb r0, [r1] - lsls r0, 1 - adds r5, r0 - ldr r0, =gUnknown_0300616C - ldrb r0, [r0] - subs r0, 0x1 - adds r6, 0x1 - cmp r7, r0 - bge _081255F0 - ldr r4, =gUnknown_03006180 -_081255BE: - ldrb r1, [r4] - lsls r1, 1 - adds r1, r5, r1 - adds r0, r5, 0 - bl sub_8125C98 - strh r0, [r5] - ldrb r1, [r4] - lsls r1, 1 - subs r1, r5, r1 - adds r0, r5, 0 - bl sub_8125C98 - strh r0, [r5] - adds r0, r7, 0x1 - lsls r0, 24 - lsrs r7, r0, 24 - ldrb r0, [r4] - lsls r0, 1 - adds r5, r0 - ldr r0, =gUnknown_0300616C - ldrb r0, [r0] - subs r0, 0x1 - cmp r7, r0 - blt _081255BE -_081255F0: - mov r2, r8 - ldrb r1, [r2] - lsls r1, 1 - subs r1, r5, r1 - adds r0, r5, 0 - bl sub_8125C98 - strh r0, [r5] - lsls r0, r6, 24 - lsrs r6, r0, 24 - ldr r0, =gUnknown_03006174 - ldrb r0, [r0] - cmp r6, r0 - bcc _0812557E -_0812560C: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81254E0 - - thumb_func_start sub_8125630 -sub_8125630: @ 8125630 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x4 - movs r2, 0 - ldr r0, =gUnknown_0300616C - ldrb r0, [r0] - cmp r2, r0 - bcs _081256A2 - ldr r0, =gUnknown_03006168 - mov r8, r0 - ldr r3, =gUnknown_03006174 -_08125648: - ldr r0, =gUnknown_03006178 - ldrb r1, [r0] - adds r1, r2 - ldr r0, =gUnknown_03006180 - ldrb r0, [r0] - muls r0, r1 - lsls r0, 1 - mov r4, r8 - ldr r1, [r4] - adds r1, r0 - ldr r0, =gUnknown_03006164 - ldrb r0, [r0] - lsls r0, 1 - adds r4, r1, r0 - movs r5, 0 - adds r6, r2, 0x1 - ldrb r0, [r3] - cmp r5, r0 - bcs _08125696 - movs r0, 0x80 - lsls r0, 8 - adds r7, r0, 0 -_08125674: - ldrh r0, [r4] - ands r0, r7 - cmp r0, 0 - bne _08125688 - adds r0, r4, 0 - str r3, [sp] - bl sub_8125CC8 - strh r0, [r4] - ldr r3, [sp] -_08125688: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - adds r4, 0x2 - ldrb r0, [r3] - cmp r5, r0 - bcc _08125674 -_08125696: - lsls r0, r6, 24 - lsrs r2, r0, 24 - ldr r0, =gUnknown_0300616C - ldrb r0, [r0] - cmp r2, r0 - bcc _08125648 -_081256A2: - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8125630 - - thumb_func_start sub_81256C8 -sub_81256C8: @ 81256C8 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x8 - ldr r0, =gUnknown_03006168 - ldr r4, [r0] - movs r6, 0 - movs r0, 0x80 - lsls r0, 8 - adds r5, r0, 0 -_081256E0: - movs r7, 0 -_081256E2: - ldrh r0, [r4] - ands r0, r5 - cmp r0, 0 - bne _081256F2 - adds r0, r4, 0 - bl sub_8125CC8 - strh r0, [r4] -_081256F2: - adds r0, r7, 0x1 - lsls r0, 24 - lsrs r7, r0, 24 - adds r4, 0x2 - cmp r7, 0x3F - bls _081256E2 - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 - cmp r6, 0x3F - bls _081256E0 - movs r7, 0 - ldr r1, =gUnknown_03006168 - mov r10, r1 - mov r3, sp - movs r2, 0x80 - lsls r2, 8 - mov r9, r2 -_08125716: - lsls r0, r7, 1 - mov r2, r10 - ldr r1, [r2] - adds r4, r1, r0 - ldrh r1, [r4] - strh r1, [r3] - mov r1, r9 - strh r1, [r4] - movs r6, 0x1 - adds r4, 0x80 - adds r5, r0, 0 -_0812572C: - ldrh r0, [r4] - movs r2, 0x80 - lsls r2, 8 - ands r0, r2 - cmp r0, 0 - bne _0812574C - adds r2, r4, 0 - adds r2, 0x80 - mov r0, sp - adds r1, r4, 0 - str r3, [sp, 0x4] - bl sub_8125F38 - strh r0, [r4] - ldr r3, [sp, 0x4] - strh r0, [r3] -_0812574C: - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 - adds r4, 0x80 - cmp r6, 0x3E - bls _0812572C - mov r0, r9 - strh r0, [r4] - mov r1, r10 - ldr r0, [r1] - adds r4, r0, r5 - ldrh r0, [r4] - strh r0, [r3] - mov r2, r9 - strh r2, [r4] - movs r6, 0x1 - adds r4, 0x80 - movs r0, 0x80 - lsls r0, 8 - mov r8, r0 -_08125774: - ldrh r0, [r4] - mov r1, r8 - ands r0, r1 - adds r5, r4, 0 - adds r5, 0x80 - cmp r0, 0 - bne _08125794 - mov r0, sp - adds r1, r4, 0 - adds r2, r5, 0 - str r3, [sp, 0x4] - bl sub_8125F38 - strh r0, [r4] - ldr r3, [sp, 0x4] - strh r0, [r3] -_08125794: - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 - adds r4, r5, 0 - cmp r6, 0x3E - bls _08125774 - mov r2, r9 - strh r2, [r4] - adds r0, r7, 0x1 - lsls r0, 24 - lsrs r7, r0, 24 - cmp r7, 0x3F - bls _08125716 - ldr r0, =gUnknown_03006168 - ldr r4, [r0] - movs r6, 0 - movs r0, 0x80 - lsls r0, 8 - mov r8, r0 -_081257BA: - movs r7, 0 - adds r5, r6, 0x1 -_081257BE: - ldrh r0, [r4] - mov r1, r8 - ands r0, r1 - cmp r0, 0 - bne _081257D0 - adds r0, r4, 0 - bl sub_8125CC8 - strh r0, [r4] -_081257D0: - adds r0, r7, 0x1 - lsls r0, 24 - lsrs r7, r0, 24 - adds r4, 0x2 - cmp r7, 0x3F - bls _081257BE - lsls r0, r5, 24 - lsrs r6, r0, 24 - cmp r6, 0x3F - bls _081257BA - 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 sub_81256C8 - - thumb_func_start sub_81257F8 -sub_81257F8: @ 81257F8 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x4 - movs r2, 0 - ldr r0, =gUnknown_0300616C - ldrb r0, [r0] - cmp r2, r0 - bcs _0812587A - ldr r0, =gUnknown_03006168 - mov r8, r0 -_0812580E: - ldr r0, =gUnknown_03006178 - ldrb r1, [r0] - adds r1, r2 - ldr r0, =gUnknown_03006180 - ldrb r0, [r0] - muls r0, r1 - lsls r0, 1 - mov r3, r8 - ldr r1, [r3] - adds r1, r0 - ldr r0, =gUnknown_03006164 - ldrb r0, [r0] - lsls r0, 1 - adds r4, r1, r0 - ldrh r1, [r4] - mov r0, sp - strh r1, [r0] - movs r5, 0x1 - adds r4, 0x2 - ldr r0, =gUnknown_03006174 - ldrb r0, [r0] - subs r0, 0x1 - adds r6, r2, 0x1 - cmp r5, r0 - bge _0812586E - movs r0, 0x80 - lsls r0, 8 - adds r7, r0, 0 -_08125846: - ldrh r0, [r4] - ands r0, r7 - cmp r0, 0 - bne _0812585C - mov r0, sp - adds r1, r4, 0 - bl sub_8125CF4 - strh r0, [r4] - mov r1, sp - strh r0, [r1] -_0812585C: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - adds r4, 0x2 - ldr r0, =gUnknown_03006174 - ldrb r0, [r0] - subs r0, 0x1 - cmp r5, r0 - blt _08125846 -_0812586E: - lsls r0, r6, 24 - lsrs r2, r0, 24 - ldr r0, =gUnknown_0300616C - ldrb r0, [r0] - cmp r2, r0 - bcc _0812580E -_0812587A: - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81257F8 - - thumb_func_start sub_81258A0 -sub_81258A0: @ 81258A0 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x8 - movs r2, 0 - ldr r0, =gUnknown_03006174 - ldrb r0, [r0] - cmp r2, r0 - bcs _0812592E - ldr r0, =gUnknown_03006168 - mov r8, r0 - ldr r7, =gUnknown_03006180 -_081258B8: - ldr r0, =gUnknown_03006178 - ldrb r1, [r0] - ldrb r0, [r7] - muls r0, r1 - lsls r0, 1 - mov r3, r8 - ldr r1, [r3] - adds r1, r0 - ldr r0, =gUnknown_03006164 - ldrb r0, [r0] - adds r0, r2 - lsls r0, 1 - adds r4, r1, r0 - ldrh r1, [r4] - mov r0, sp - strh r1, [r0] - movs r5, 0x1 - ldrb r0, [r7] - lsls r0, 1 - adds r4, r0 - ldr r0, =gUnknown_0300616C - ldrb r0, [r0] - subs r0, 0x1 - adds r6, r2, 0x1 - cmp r5, r0 - bge _08125922 - movs r0, 0x80 - lsls r0, 8 - adds r2, r0, 0 -_081258F2: - ldrh r0, [r4] - ands r0, r2 - cmp r0, 0 - bne _0812590C - mov r0, sp - adds r1, r4, 0 - str r2, [sp, 0x4] - bl sub_8125CF4 - strh r0, [r4] - mov r1, sp - strh r0, [r1] - ldr r2, [sp, 0x4] -_0812590C: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - ldrb r0, [r7] - lsls r0, 1 - adds r4, r0 - ldr r0, =gUnknown_0300616C - ldrb r0, [r0] - subs r0, 0x1 - cmp r5, r0 - blt _081258F2 -_08125922: - lsls r0, r6, 24 - lsrs r2, r0, 24 - ldr r0, =gUnknown_03006174 - ldrb r0, [r0] - cmp r2, r0 - bcc _081258B8 -_0812592E: - add sp, 0x8 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81258A0 - - thumb_func_start sub_8125954 -sub_8125954: @ 8125954 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x20 - lsls r0, 16 - lsrs r0, 16 - mov r10, r0 - mov r2, sp - ldr r3, =gUnknown_085A1F94 - lsls r1, r0, 1 - add r1, r10 - adds r0, r1, r3 - ldrb r0, [r0] - strb r0, [r2] - adds r0, r3, 0x1 - adds r0, r1, r0 - ldrb r0, [r0] - strb r0, [r2, 0x1] - mov r5, sp - adds r0, r3, 0x2 - adds r1, r0 - ldrb r4, [r1] - lsls r2, r4, 24 - lsrs r1, r2, 27 - movs r0, 0x7 - ands r1, r0 - strh r1, [r5, 0x2] - lsrs r2, 25 - mov r9, r2 - movs r0, 0x3 - ands r2, r0 - mov r9, r2 - movs r5, 0x1 - ands r5, r4 - movs r4, 0x1 - mov r8, r4 - cmp r8, r1 - bcs _08125A06 - mov r3, sp -_081259A6: - cmp r5, 0 - bne _081259C4 - mov r0, r8 - lsls r2, r0, 2 - mov r4, sp - adds r1, r4, r2 - ldrb r0, [r3] - mov r4, r8 - subs r0, r4 - strb r0, [r1] - ldrb r0, [r3, 0x1] - add r0, r8 - b _081259D6 - .pool -_081259C4: - mov r0, r8 - lsls r2, r0, 2 - mov r4, sp - adds r1, r4, r2 - ldrb r0, [r3] - adds r0, 0x1 - strb r0, [r1] - ldrb r0, [r3, 0x1] - subs r0, 0x1 -_081259D6: - strb r0, [r1, 0x1] - add r2, sp - ldrb r0, [r2] - cmp r0, 0x3F - bhi _081259E6 - ldrb r0, [r2, 0x1] - cmp r0, 0x3F - bls _081259EE -_081259E6: - mov r0, r8 - subs r0, 0x1 - strh r0, [r3, 0x2] - b _08125A06 -_081259EE: - ldrh r0, [r3, 0x2] - mov r1, r8 - subs r0, r1 - strh r0, [r2, 0x2] - mov r0, r8 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - ldrh r0, [r3, 0x2] - cmp r8, r0 - bcc _081259A6 -_08125A06: - movs r2, 0 - mov r8, r2 - mov r0, sp - ldrh r0, [r0, 0x2] - cmp r8, r0 - bcc _08125A14 - b _08125B16 -_08125A14: - movs r3, 0x1F -_08125A16: - ldr r1, =gUnknown_03006168 - mov r4, r8 - lsls r0, r4, 2 - mov r2, sp - adds r6, r2, r0 - ldrb r0, [r6, 0x1] - lsls r0, 7 - ldr r1, [r1] - adds r1, r0 - ldrb r0, [r6] - lsls r0, 1 - adds r2, r1, r0 - ldrh r1, [r2] - movs r4, 0x80 - lsls r4, 8 - adds r0, r4, 0 - ands r0, r1 - cmp r0, 0 - bne _08125B02 - movs r7, 0x1F - ands r7, r1 - lsls r0, r1, 16 - lsrs r5, r0, 21 - ands r5, r3 - lsrs r4, r0, 26 - ands r4, r3 - mov r0, r9 - cmp r0, 0 - blt _08125AF8 - cmp r0, 0x1 - ble _08125A78 - cmp r0, 0x3 - bgt _08125AF8 - ldrh r0, [r6, 0x2] - adds r1, r7, r0 - lsls r1, 16 - lsrs r7, r1, 16 - adds r1, r5, r0 - lsls r1, 16 - lsrs r5, r1, 16 - adds r0, r4, r0 - lsls r0, 16 - lsrs r4, r0, 16 - cmp r7, 0x1F - bls _08125AEC - movs r7, 0x1F - b _08125AEC - .pool -_08125A78: - mov r1, r10 - lsls r0, r1, 1 - add r0, r10 - ldr r1, =gUnknown_085A1F94 - adds r1, 0x2 - adds r0, r1 - ldrb r0, [r0] - lsrs r0, 3 - movs r1, 0x7 - ands r0, r1 - movs r1, 0x3 - str r2, [sp, 0x18] - str r3, [sp, 0x1C] - bl __umodsi3 - lsls r0, 24 - lsrs r0, 24 - ldr r2, [sp, 0x18] - ldr r3, [sp, 0x1C] - cmp r0, 0x1 - beq _08125AC8 - cmp r0, 0x1 - bgt _08125AB0 - cmp r0, 0 - beq _08125AB6 - b _08125AF8 - .pool -_08125AB0: - cmp r0, 0x2 - beq _08125ADA - b _08125AF8 -_08125AB6: - ldrh r0, [r6, 0x2] - cmp r7, r0 - bcc _08125AC4 - subs r0, r7, r0 - lsls r0, 16 - lsrs r7, r0, 16 - b _08125AF8 -_08125AC4: - movs r7, 0 - b _08125AF8 -_08125AC8: - ldrh r0, [r6, 0x2] - cmp r5, r0 - bcc _08125AD6 - subs r0, r5, r0 - lsls r0, 16 - lsrs r5, r0, 16 - b _08125AF8 -_08125AD6: - movs r5, 0 - b _08125AF8 -_08125ADA: - ldrh r0, [r6, 0x2] - cmp r4, r0 - bcc _08125AE8 - subs r0, r4, r0 - lsls r0, 16 - lsrs r4, r0, 16 - b _08125AF8 -_08125AE8: - movs r4, 0 - b _08125AF8 -_08125AEC: - cmp r5, 0x1F - bls _08125AF2 - movs r5, 0x1F -_08125AF2: - cmp r4, 0x1F - bls _08125AF8 - movs r4, 0x1F -_08125AF8: - lsls r0, r4, 10 - lsls r1, r5, 5 - orrs r0, r1 - orrs r7, r0 - strh r7, [r2] -_08125B02: - mov r0, r8 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - mov r0, sp - ldrh r0, [r0, 0x2] - cmp r8, r0 - bcs _08125B16 - b _08125A16 -_08125B16: - 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_8125954 - - thumb_func_start sub_8125B28 -sub_8125B28: @ 8125B28 - ldrh r2, [r0] - movs r0, 0x1F - adds r1, r2, 0 - ands r1, r0 - asrs r3, r2, 5 - ands r3, r0 - asrs r2, 10 - ands r2, r0 - movs r0, 0x4C - muls r1, r0 - movs r0, 0x97 - muls r0, r3 - adds r1, r0 - lsls r0, r2, 3 - subs r0, r2 - lsls r0, 2 - adds r0, r2 - adds r1, r0 - asrs r1, 8 - lsls r0, r1, 10 - lsls r2, r1, 5 - orrs r0, r2 - orrs r0, r1 - lsls r0, 16 - lsrs r0, 16 - bx lr - thumb_func_end sub_8125B28 - - thumb_func_start sub_8125B5C -sub_8125B5C: @ 8125B5C - push {r4,lr} - lsls r1, 24 - lsrs r4, r1, 24 - ldrh r0, [r0] - movs r2, 0x1F - movs r1, 0x1F - ands r1, r0 - lsls r0, 16 - lsrs r3, r0, 21 - ands r3, r2 - lsrs r0, 26 - ands r0, r2 - cmp r1, 0x10 - bhi _08125B8C - cmp r3, 0x10 - bhi _08125B8C - cmp r0, 0x10 - bhi _08125B8C - adds r0, r4, 0 - bl sub_8125B98 - lsls r0, 16 - lsrs r0, 16 - b _08125B8E -_08125B8C: - ldr r0, =0x00007fff -_08125B8E: - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8125B5C - - thumb_func_start sub_8125B98 -sub_8125B98: @ 8125B98 - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - movs r0, 0 - mov r8, r0 - movs r6, 0 - movs r7, 0 - adds r0, r4, 0 - movs r1, 0x6 - bl __udivsi3 - lsls r0, 24 - lsrs r0, 24 - movs r1, 0x3 - bl __umodsi3 - lsls r0, 24 - lsrs r5, r0, 24 - adds r0, r4, 0 - movs r1, 0x6 - bl __umodsi3 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x5 - bhi _08125C50 - lsls r0, 2 - ldr r1, =_08125BE0 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08125BE0: - .4byte _08125BF8 - .4byte _08125C08 - .4byte _08125C18 - .4byte _08125C26 - .4byte _08125C34 - .4byte _08125C42 -_08125BF8: - movs r0, 0x15 - subs r0, r5 - lsls r0, 16 - lsrs r6, r0, 16 - adds r7, r6, 0 - movs r1, 0 - mov r8, r1 - b _08125C50 -_08125C08: - movs r7, 0 - movs r0, 0x15 - subs r0, r5 - lsls r0, 16 - lsrs r0, 16 - mov r8, r0 - mov r6, r8 - b _08125C50 -_08125C18: - movs r0, 0x15 - subs r0, r5 - lsls r0, 16 - lsrs r7, r0, 16 - movs r6, 0 - mov r8, r7 - b _08125C50 -_08125C26: - movs r7, 0 - movs r6, 0 - movs r0, 0x17 - subs r0, r5 - lsls r0, 16 - lsrs r0, 16 - b _08125C4E -_08125C34: - movs r0, 0x17 - subs r0, r5 - lsls r0, 16 - lsrs r7, r0, 16 - movs r6, 0 - mov r8, r6 - b _08125C50 -_08125C42: - movs r7, 0 - movs r0, 0x17 - subs r0, r5 - lsls r0, 16 - lsrs r6, r0, 16 - movs r0, 0 -_08125C4E: - mov r8, r0 -_08125C50: - lsls r0, r7, 10 - lsls r1, r6, 5 - orrs r0, r1 - mov r1, r8 - orrs r1, r0 - lsls r0, r1, 16 - lsrs r0, 16 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_8125B98 - - thumb_func_start sub_8125C68 -sub_8125C68: @ 8125C68 - push {lr} - ldrh r0, [r0] - movs r2, 0x1F - movs r1, 0x1F - ands r1, r0 - lsls r0, 16 - lsrs r3, r0, 21 - ands r3, r2 - lsrs r0, 26 - ands r0, r2 - cmp r1, 0x10 - bhi _08125C8C - cmp r3, 0x10 - bhi _08125C8C - cmp r0, 0x10 - bhi _08125C8C - movs r0, 0 - b _08125C8E -_08125C8C: - ldr r0, =0x00007fff -_08125C8E: - pop {r1} - bx r1 - .pool - thumb_func_end sub_8125C68 - - thumb_func_start sub_8125C98 -sub_8125C98: @ 8125C98 - push {r4,lr} - adds r4, r0, 0 - ldrh r3, [r4] - cmp r3, 0 - beq _08125CC0 - movs r2, 0x80 - lsls r2, 8 - adds r0, r2, 0 - ands r0, r3 - cmp r0, 0 - beq _08125CB2 - adds r0, r2, 0 - b _08125CC2 -_08125CB2: - ldrh r1, [r1] - adds r0, r2, 0 - ands r0, r1 - cmp r0, 0 - bne _08125CC0 - ldrh r0, [r4] - b _08125CC2 -_08125CC0: - movs r0, 0 -_08125CC2: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8125C98 - - thumb_func_start sub_8125CC8 -sub_8125CC8: @ 8125CC8 - push {r4,lr} - ldrh r1, [r0] - movs r0, 0x1F - movs r3, 0x1F - ands r3, r1 - lsls r1, 16 - lsrs r2, r1, 21 - lsrs r1, 26 - subs r3, r0, r3 - adds r4, r0, 0 - bics r4, r2 - adds r2, r4, 0 - bics r0, r1 - lsls r0, 10 - lsls r2, 5 - orrs r0, r2 - orrs r0, r3 - lsls r0, 16 - lsrs r0, 16 - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8125CC8 thumb_func_start sub_8125CF4 sub_8125CF4: @ 8125CF4 @@ -2793,7 +1071,7 @@ _0812653C: .pool _0812656C: adds r0, r4, 0 - bl sub_8125C68 + bl ConvertToBlackOrWhite lsls r0, 16 cmp r0, 0 bne _0812657E diff --git a/src/contest_painting_effects.c b/src/contest_painting_effects.c new file mode 100644 index 000000000..46bc375db --- /dev/null +++ b/src/contest_painting_effects.c @@ -0,0 +1,602 @@ +#include "global.h" +#include "contest_painting_effects.h" +#include "contest_painting.h" +#include "constants/rgb.h" + +extern u8 gUnknown_03006164; +extern u16 (*gUnknown_03006168)[][32]; +extern u8 gUnknown_0300616C; +extern u8 gUnknown_03006170; +extern u8 gUnknown_03006174; +extern u8 gUnknown_03006178; +extern u8 gUnknown_0300617C; +extern u8 gUnknown_03006180; + +// this file's functions +void sub_8125230(void); +void sub_81252E8(void); +void sub_81254E0(void); +void sub_8125630(void); +void sub_8125448(void); +void sub_81257F8(void); +void sub_81258A0(void); +void sub_81256C8(void); +void sub_8125250(void); +void sub_81253A4(u8); +void sub_81250B8(u8); +void sub_8125170(u8); +void sub_8125954(u16); +u16 ConvertColorToGrayscale(u16*); +u16 sub_8125E18(u16*, u16*, u16*); +u16 ConvertCoolColor(u16*, u8); +u16 ConvertToBlackOrWhite(u16*); +u16 sub_8125C98(u16*, u16*); +u16 InvertColor(u16*); +u16 sub_8125F38(u16*, u16*, u16*); +u16 sub_8125CF4(u16*, u16*); +u16 GetCoolColorFromPersonality(u8); + +void sub_8124F2C(struct Unk03005E20 *info) +{ + gUnknown_03006168 = info->var_4; + gUnknown_0300617C = info->var_1F; + gUnknown_03006164 = info->var_19; + gUnknown_03006178 = info->var_1A; + gUnknown_03006174 = info->var_1B; + gUnknown_0300616C = info->var_1C; + gUnknown_03006180 = info->var_1D; + gUnknown_03006170 = info->var_1E; + switch (info->var_0) + { + case 2: + sub_8125230(); + break; + case 8: + sub_81252E8(); + break; + case 9: + sub_81254E0(); + sub_81253A4(gUnknown_0300617C); + break; + case 10: + sub_81254E0(); + sub_8125630(); + sub_8125448(); + case 31: + sub_8125630(); + break; + case 11: + sub_81254E0(); + sub_81257F8(); + sub_81257F8(); + sub_81258A0(); + sub_8125448(); + break; + case 13: + sub_81256C8(); + break; + case 30: + sub_81254E0(); + break; + case 32: + sub_81257F8(); + break; + case 33: + sub_81258A0(); + break; + case 6: + sub_8125250(); + sub_81250B8(3); + break; + case 36: + sub_81254E0(); + sub_81257F8(); + sub_81258A0(); + sub_8125448(); + sub_81252E8(); + sub_81252E8(); + sub_81250B8(2); + sub_8125170(4); + break; + } +} + +void sub_81250B8(u8 a0) // it changes palette someway somehow... .__. +{ + u8 i, j; + + for (i = 0; i < gUnknown_0300616C; i++) + { + u16* var2 = &(*gUnknown_03006168)[0][(gUnknown_03006178 + i) * gUnknown_03006180]; + u16* pal = &var2[gUnknown_03006164]; + for (j = 0; j < gUnknown_03006174; j++, pal++) + { + if (!(0x8000 & *pal)) + { + u8 val = (31 & *pal); + val += a0; + if (val > 31) + val = 31; + + *pal = RGB2(val, val, val); + } + } + } +} + +void sub_8125170(u8 a0) +{ + u8 i, j; + + for (i = 0; i < gUnknown_0300616C; i++) + { + u16* var2 = &(*gUnknown_03006168)[0][(gUnknown_03006178 + i) * gUnknown_03006180]; + u16* pal = &var2[gUnknown_03006164]; + for (j = 0; j < gUnknown_03006174; j++, pal++) + { + if (!(0x8000 & *pal)) + { + u8 val = (31 & *pal); + if (val > 31 - a0) + val = 31 - (a0 >> 1); + + *pal = RGB2(val, val, val); + } + } + } +} + +void sub_8125230(void) +{ + u32 i; + for (i = 0; i < 3200; i++) + sub_8125954(i); +} + +void sub_8125250(void) +{ + u8 i, j; + + for (i = 0; i < gUnknown_0300616C; i++) + { + u16* var2 = &(*gUnknown_03006168)[0][(gUnknown_03006178 + i) * gUnknown_03006180]; + u16* color = &var2[gUnknown_03006164]; + for (j = 0; j < gUnknown_03006174; j++, color++) + { + if (!(0x8000 & *color)) + { + *color = ConvertColorToGrayscale(color); + } + } + } +} + +void sub_81252E8(void) +{ + u8 i, j; + + for (i = 0; i < gUnknown_03006174; i++) + { + u16* var0 = &(*gUnknown_03006168)[0][gUnknown_03006178 * gUnknown_03006180]; + u16* palette = &var0[gUnknown_03006164 + i]; + u16 color = *palette; + + j = 1; + palette += gUnknown_03006180; + while (j < gUnknown_0300616C - 1) + { + if (!(0x8000 & *palette)) + { + *palette = sub_8125E18(&color, palette, palette + gUnknown_03006180); + color = *palette; + } + + j++; + palette += gUnknown_03006180; + } + } +} + +void sub_81253A4(u8 arg0) +{ + u8 i, j; + + for (i = 0; i < gUnknown_0300616C; i++) + { + u16* var0 = &(*gUnknown_03006168)[0][(gUnknown_03006178 + i) * gUnknown_03006180]; + u16* color = &var0[gUnknown_03006164]; + for (j = 0; j < gUnknown_03006174; j++, color++) + { + if (!(0x8000 & *color)) + { + *color = ConvertCoolColor(color, arg0); + } + } + } +} + +void sub_8125448(void) +{ + u8 i, j; + + for (i = 0; i < gUnknown_0300616C; i++) + { + u16* var0 = &(*gUnknown_03006168)[0][(gUnknown_03006178 + i) * gUnknown_03006180]; + u16* color = &var0[gUnknown_03006164]; + for (j = 0; j < gUnknown_03006174; j++, color++) + { + if (!(0x8000 & *color)) + { + *color = ConvertToBlackOrWhite(color); + } + } + } +} + +void sub_81254E0(void) +{ + u8 i, j; + u16 *palette; + + for (i = 0; i < gUnknown_0300616C; i++) + { + u16 *var0 = &(*gUnknown_03006168)[0][(gUnknown_03006178 + i) * gUnknown_03006180]; + palette = &var0[gUnknown_03006164]; + *palette = sub_8125C98(palette, palette + 1); + for (j = 1, palette = palette + 1; j < gUnknown_03006174 - 1; j++, palette++) + { + *palette = sub_8125C98(palette, palette + 1); + *palette = sub_8125C98(palette, palette - 1); + } + + *palette = sub_8125C98(palette, palette - 1); + } + + for (j = 0; j < gUnknown_03006174; j++) + { + u16 *var0 = &(*gUnknown_03006168)[0][gUnknown_03006178 * gUnknown_03006180]; + palette = &var0[gUnknown_03006164 + j]; + *palette = sub_8125C98(palette, palette + gUnknown_03006180); + for (i = 1, palette = palette + gUnknown_03006180; i < gUnknown_0300616C - 1; i++, palette += gUnknown_03006180) + { + *palette = sub_8125C98(palette, palette + gUnknown_03006180); + *palette = sub_8125C98(palette, palette - gUnknown_03006180); + } + + *palette = sub_8125C98(palette, palette - gUnknown_03006180); + } +} + +void sub_8125630(void) +{ + u8 i, j; + + for (i = 0; i < gUnknown_0300616C; i++) + { + u16 *var0 = &(*gUnknown_03006168)[0][(gUnknown_03006178 + i) * gUnknown_03006180]; + u16 *color = &var0[gUnknown_03006164]; + for (j = 0; j < gUnknown_03006174; j++, color++) + { + if (!(0x8000 & *color)) + { + *color = InvertColor(color); + } + } + } +} + +void sub_81256C8(void) +{ + u8 i, j; + u16 *palette; + u16 color; + + palette = (*gUnknown_03006168)[0]; + for (i = 0; i < 64; i++) + { + for (j = 0; j < 64; j++, palette++) + { + if (!(0x8000 & *palette)) + { + *palette = InvertColor(palette); + } + } + } + + for (j = 0; j < 64; j++) + { + palette = &(*gUnknown_03006168)[0][j]; + color = *palette; + *palette = 0x8000; + for (i = 1, palette += 64; i < 63; i++, palette += 64) + { + if (!(0x8000 & *palette)) + { + *palette = sub_8125F38(&color, palette, palette + 64); + color = *palette; + } + } + + *palette = 0x8000; + palette = &(*gUnknown_03006168)[0][j]; + color = *palette; + *palette = 0x8000; + for (i = 1, palette += 64; i < 63; i++, palette += 64) + { + if (!(0x8000 & *palette)) + { + *palette = sub_8125F38(&color, palette, palette + 64); + color = *palette; + } + } + + *palette = 0x8000; + } + + palette = (*gUnknown_03006168)[0]; + for (i = 0; i < 64; i++) + { + for (j = 0; j < 64; j++, palette++) + { + if (!(0x8000 & *palette)) + { + *palette = InvertColor(palette); + } + } + } +} + +void sub_81257F8(void) +{ + u8 i, j; + + for (i = 0; i < gUnknown_0300616C; i++) + { + u16 *var0 = &(*gUnknown_03006168)[0][(gUnknown_03006178 + i) * gUnknown_03006180]; + u16 *palette = &var0[gUnknown_03006164]; + u16 color = *palette; + for (j = 1, palette++; j < gUnknown_03006174 - 1; j++, palette++) + { + if (!(0x8000 & *palette)) + { + *palette = sub_8125CF4(&color, palette); + color = *palette; + } + } + } +} + +void sub_81258A0(void) +{ + u8 i, j; + + for (i = 0; i < gUnknown_03006174; i++) + { + u16* var0 = &(*gUnknown_03006168)[0][gUnknown_03006178 * gUnknown_03006180]; + u16* palette = &var0[gUnknown_03006164 + i]; + u16 color = *palette; + for (j = 1, palette += gUnknown_03006180; j < gUnknown_0300616C - 1; j++, palette += gUnknown_03006180) + { + if (!(0x8000 & *palette)) + { + *palette = sub_8125CF4(&color, palette); + color = *palette; + } + } + } +} + +struct Unk8125954 +{ + u8 unk0; + u8 unk1; + u16 unk2; +}; + +extern const u8 gUnknown_085A1F94[][3]; + +void sub_8125954(u16 arg0) +{ + u8 i; + u8 r5, r9; + struct Unk8125954 unkStruct[6]; + + unkStruct[0].unk0 = gUnknown_085A1F94[arg0][0]; + unkStruct[0].unk1 = gUnknown_085A1F94[arg0][1]; + unkStruct[0].unk2 = (gUnknown_085A1F94[arg0][2] >> 3) & 7; + + r9 = (gUnknown_085A1F94[arg0][2] >> 1) & 3; + r5 = gUnknown_085A1F94[arg0][2] & 1; + for (i = 1; i < unkStruct[0].unk2; i++) + { + if (!r5) + { + unkStruct[i].unk0 = unkStruct[0].unk0 - i; + unkStruct[i].unk1 = unkStruct[0].unk1 + i; + } + else + { + unkStruct[i].unk0 = unkStruct[0].unk0 + 1; + unkStruct[i].unk1 = unkStruct[0].unk1 - 1; + } + + if (unkStruct[i].unk0 > 63 || unkStruct[i].unk1 > 63) + { + unkStruct[0].unk2 = i - 1; + break; + } + + unkStruct[i].unk2 = unkStruct[0].unk2 - i; + } + + for (i = 0; i < unkStruct[0].unk2; i++) + { + u16 *pal = &(*gUnknown_03006168)[unkStruct[i].unk1 * 2][unkStruct[i].unk0]; + + if (!(0x8000 & *pal)) + { + u16 r = (*pal) & 0x1F; + u16 g = (*pal >> 5) & 0x1F; + u16 b = (*pal >> 10) & 0x1F; + + switch (r9) + { + case 0: + case 1: + switch (((gUnknown_085A1F94[arg0][2] >> 3) & 7) % 3) + { + case 0: + if (r >= unkStruct[i].unk2) + r -= unkStruct[i].unk2; + else + r = 0; + break; + case 1: + if (g >= unkStruct[i].unk2) + g -= unkStruct[i].unk2; + else + g = 0; + break; + case 2: + if (b >= unkStruct[i].unk2) + b -= unkStruct[i].unk2; + else + b = 0; + break; + } + break; + case 2: + case 3: + r += unkStruct[i].unk2; + g += unkStruct[i].unk2; + b += unkStruct[i].unk2; + if (r > 31) + r = 31; + if (g > 31) + g = 31; + if (b > 31) + b = 31; + break; + } + + *pal = RGB2(r, g, b); + } + } +} + +u16 ConvertColorToGrayscale(u16 *color) +{ + s32 clr = *color; + s32 r = clr & 0x1F; + s32 g = (clr >> 5) & 0x1F; + s32 b = (clr >> 10) & 0x1F; + s32 gray = (r * Q_8_8(0.3) + g * Q_8_8(0.59) + b * Q_8_8(0.1133)) >> 8; + return RGB2(gray, gray, gray); +} + +// The dark colors are the colored edges of the Cool painting effect. +// Everything else is white. +u16 ConvertCoolColor(u16 *color, u8 personality) +{ + u16 red = *color & 0x1F; + u16 green = (*color >> 5) & 0x1F; + u16 blue = (*color >> 10) & 0x1F; + + if (red < 17 && green < 17 && blue < 17) + return GetCoolColorFromPersonality(personality); + else + return RGB_WHITE; +} + +// Based on the given value, which comes from the first 8 bits of +// the mon's personality value, return a color. +u16 GetCoolColorFromPersonality(u8 personality) +{ + u16 red = 0; + u16 green = 0; + u16 blue = 0; + u8 strength = (personality / 6) % 3; + u8 colorType = personality % 6; + + switch (colorType) + { + case 0: + // Teal color + green = 21 - strength; + blue = green; + red = 0; + break; + case 1: + // Yellow color + blue = 0; + red = 21 - strength; + green = red; + break; + case 2: + // Purple color + blue = 21 - strength; + green = 0; + red = blue; + break; + case 3: + // Red color + blue = 0; + green = 0; + red = 23 - strength; + break; + case 4: + // Blue color + blue = 23 - strength; + green = 0; + red = 0; + break; + case 5: + // Green color + blue = 0; + green = 23 - strength; + red = 0; + break; + } + + return RGB2(red, green, blue); +} + +u16 ConvertToBlackOrWhite(u16 *color) +{ + u16 red = *color & 0x1F; + u16 green = (*color >> 5) & 0x1F; + u16 blue = (*color >> 10) & 0x1F; + + if (red < 17 && green < 17 && blue < 17) + return RGB_BLACK; + else + return RGB_WHITE; +} + +u16 sub_8125C98(u16 *colorA, u16 *colorB) +{ + if (*colorA) + { + if (*colorA & 0x8000) + return 0x8000; + if (*colorB & 0x8000) + return RGB_BLACK; + + return *colorA; + } + + return RGB_BLACK; +} + +u16 InvertColor(u16 *color) +{ + u16 red = *color & 0x1F; + u16 green = (*color >> 5) & 0x1F; + u16 blue = (*color >> 10) & 0x1F; + + red = 31 - red; + green = 31 - green; + blue = 31 - blue; + + return RGB2(red, green, blue); +}