diff --git a/asm/contest_painting_effects.s b/asm/contest_painting_effects.s deleted file mode 100644 index 801e840b9..000000000 --- a/asm/contest_painting_effects.s +++ /dev/null @@ -1,1152 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - - - - - thumb_func_start sub_8126058 -sub_8126058: @ 8126058 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0xC - ldrb r1, [r0, 0x1D] - lsrs r5, r1, 3 - ldrb r1, [r0, 0x1E] - lsrs r1, 3 - str r1, [sp, 0x8] - ldr r1, [r0, 0x4] - str r1, [sp] - ldr r2, [r0, 0x10] - str r2, [sp, 0x4] - ldrh r0, [r0, 0x16] - cmp r0, 0x2 - bne _08126108 - movs r1, 0 - ldr r0, [sp, 0x8] - cmp r1, r0 - bcc _08126086 - b _08126194 -_08126086: - movs r0, 0 - adds r2, r1, 0x1 - mov r10, r2 - cmp r0, r5 - bcs _081260FA - adds r2, r1, 0 - muls r2, r5 - mov r9, r2 - lsls r1, 3 - mov r8, r1 -_0812609A: - movs r4, 0 - lsls r6, r0, 4 - adds r7, r0, 0x1 - add r0, r9 - lsls r0, 6 - ldr r1, [sp, 0x4] - adds r1, r0 - mov r12, r1 -_081260AA: - lsls r0, r4, 3 - mov r2, r12 - adds r3, r2, r0 - mov r1, r8 - adds r0, r1, r4 - lsls r0, 3 - muls r0, r5 - lsls r0, 1 - ldr r2, [sp] - adds r0, r2, r0 - adds r2, r0, r6 - ldrh r0, [r2, 0x2] - lsls r0, 8 - ldrh r1, [r2] - orrs r0, r1 - strh r0, [r3] - ldrh r0, [r2, 0x6] - lsls r0, 8 - ldrh r1, [r2, 0x4] - orrs r0, r1 - strh r0, [r3, 0x2] - ldrh r0, [r2, 0xA] - lsls r0, 8 - ldrh r1, [r2, 0x8] - orrs r0, r1 - strh r0, [r3, 0x4] - ldrh r0, [r2, 0xE] - lsls r0, 8 - ldrh r1, [r2, 0xC] - orrs r0, r1 - strh r0, [r3, 0x6] - adds r0, r4, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 - cmp r4, 0x7 - bls _081260AA - lsls r0, r7, 16 - lsrs r0, 16 - cmp r0, r5 - bcc _0812609A -_081260FA: - mov r1, r10 - lsls r0, r1, 16 - lsrs r1, r0, 16 - ldr r2, [sp, 0x8] - cmp r1, r2 - bcc _08126086 - b _08126194 -_08126108: - movs r1, 0 - ldr r0, [sp, 0x8] - cmp r1, r0 - bcs _08126194 -_08126110: - movs r0, 0 - adds r2, r1, 0x1 - mov r10, r2 - cmp r0, r5 - bcs _08126188 - adds r2, r1, 0 - muls r2, r5 - mov r9, r2 - lsls r1, 3 - mov r8, r1 -_08126124: - movs r4, 0 - lsls r6, r0, 4 - adds r7, r0, 0x1 - add r0, r9 - lsls r0, 5 - ldr r1, [sp, 0x4] - adds r1, r0 - mov r12, r1 -_08126134: - lsls r0, r4, 2 - mov r2, r12 - adds r3, r2, r0 - mov r1, r8 - adds r0, r1, r4 - lsls r0, 3 - muls r0, r5 - lsls r0, 1 - ldr r2, [sp] - adds r0, r2, r0 - adds r2, r0, r6 - ldrh r1, [r2, 0x2] - lsls r1, 4 - ldrh r0, [r2] - orrs r1, r0 - ldrh r0, [r2, 0x4] - lsls r0, 8 - orrs r1, r0 - ldrh r0, [r2, 0x6] - lsls r0, 12 - orrs r1, r0 - strh r1, [r3] - ldrh r1, [r2, 0xA] - lsls r1, 4 - ldrh r0, [r2, 0x8] - orrs r1, r0 - ldrh r0, [r2, 0xC] - lsls r0, 8 - orrs r1, r0 - ldrh r0, [r2, 0xE] - lsls r0, 12 - orrs r1, r0 - strh r1, [r3, 0x2] - adds r0, r4, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 - cmp r4, 0x7 - bls _08126134 - lsls r0, r7, 16 - lsrs r0, 16 - cmp r0, r5 - bcc _08126124 -_08126188: - mov r1, r10 - lsls r0, r1, 16 - lsrs r1, r0, 16 - ldr r2, [sp, 0x8] - cmp r1, r2 - bcc _08126110 -_08126194: - add sp, 0xC - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_8126058 - - thumb_func_start sub_81261A4 -sub_81261A4: @ 81261A4 - push {lr} - ldr r2, =gUnknown_03006188 - ldrb r1, [r0, 0x18] - lsls r1, 4 - strh r1, [r2] - ldr r3, =gUnknown_03006184 - ldrh r2, [r2] - lsls r2, 1 - ldr r1, [r0, 0x8] - adds r1, r2 - str r1, [r3] - ldr r2, =gUnknown_03006168 - ldr r1, [r0, 0x4] - str 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] - ldrh r0, [r0, 0x14] - cmp r0, 0x5 - bhi _0812626A - lsls r0, 2 - ldr r1, =_0812621C - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0812621C: - .4byte _08126234 - .4byte _0812623C - .4byte _08126244 - .4byte _0812624E - .4byte _08126258 - .4byte _08126262 -_08126234: - movs r0, 0 - bl sub_81263A4 - b _0812626A -_0812623C: - movs r0, 0x1 - bl sub_81263A4 - b _0812626A -_08126244: - bl sub_8126270 - bl sub_8126714 - b _0812626A -_0812624E: - bl sub_8126370 - bl sub_8126664 - b _0812626A -_08126258: - bl sub_8126334 - bl sub_81265B4 - b _0812626A -_08126262: - bl sub_8126318 - bl sub_81264FC -_0812626A: - pop {r0} - bx r0 - thumb_func_end sub_81261A4 - - thumb_func_start sub_8126270 -sub_8126270: @ 8126270 - ldr r2, =gUnknown_03006184 - ldr r1, [r2] - movs r0, 0 - strh r0, [r1] - ldr r0, [r2] - ldr r2, =0x000018c6 - adds r1, r2, 0 - strh r1, [r0, 0x2] - ldr r2, =0x000077bd - adds r1, r2, 0 - strh r1, [r0, 0x4] - ldr r2, =0x00002d6b - adds r1, r2, 0 - strh r1, [r0, 0x6] - ldr r2, =0x000018dd - adds r1, r2, 0 - strh r1, [r0, 0x8] - ldr r2, =0x00001ba6 - adds r1, r2, 0 - strh r1, [r0, 0xA] - ldr r2, =0x000074c6 - adds r1, r2, 0 - strh r1, [r0, 0xC] - ldr r2, =0x00001bbd - adds r1, r2, 0 - strh r1, [r0, 0xE] - ldr r2, =0x000074dd - adds r1, r2, 0 - strh r1, [r0, 0x10] - ldr r2, =0x000077a6 - adds r1, r2, 0 - strh r1, [r0, 0x12] - ldr r2, =0x0000197d - adds r1, r2, 0 - strh r1, [r0, 0x14] - ldr r2, =0x00001bab - adds r1, r2, 0 - strh r1, [r0, 0x16] - ldr r2, =0x00007566 - adds r1, r2, 0 - strh r1, [r0, 0x18] - ldr r2, =0x00002cdd - adds r1, r2, 0 - strh r1, [r0, 0x1A] - ldr r2, =0x00002fa6 - adds r1, r2, 0 - strh r1, [r0, 0x1C] - ldr r2, =0x000074cb - adds r1, r2, 0 - strh r1, [r0, 0x1E] - bx lr - .pool - thumb_func_end sub_8126270 - - thumb_func_start sub_8126318 -sub_8126318: @ 8126318 - ldr r2, =gUnknown_03006184 - ldr r0, [r2] - movs r1, 0 - strh r1, [r0] - ldr r2, [r2] - strh r1, [r2, 0x2] - ldr r1, =0x00007fff - adds r0, r1, 0 - strh r0, [r2, 0x4] - bx lr - .pool - thumb_func_end sub_8126318 - - thumb_func_start sub_8126334 -sub_8126334: @ 8126334 - push {r4,r5,lr} - ldr r1, =gUnknown_03006184 - ldr r0, [r1] - movs r2, 0 - strh r2, [r0] - ldr r0, [r1] - strh r2, [r0, 0x2] - movs r4, 0 - adds r5, r1, 0 -_08126346: - ldr r0, [r5] - lsls r2, r4, 1 - adds r2, r0 - adds r0, r4, 0x2 - lsls r3, r0, 1 - lsls r1, r0, 11 - lsls r0, 6 - orrs r1, r0 - orrs r1, r3 - strh r1, [r2, 0x4] - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0xD - bls _08126346 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8126334 - - thumb_func_start sub_8126370 -sub_8126370: @ 8126370 - push {r4,lr} - ldr r2, =gUnknown_03006184 - ldr r1, [r2] - movs r0, 0 - strh r0, [r1] - movs r3, 0 - adds r4, r2, 0 -_0812637E: - ldr r0, [r4] - lsls r2, r3, 1 - adds r2, r0 - lsls r0, r3, 10 - lsls r1, r3, 5 - orrs r0, r1 - orrs r0, r3 - strh r0, [r2, 0x2] - adds r0, r3, 0x1 - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, 0x1F - bls _0812637E - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8126370 - - thumb_func_start sub_81263A4 -sub_81263A4: @ 81263A4 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - lsls r0, 24 - movs r1, 0xDF - mov r9, r1 - cmp r0, 0 - bne _081263BC - movs r2, 0xFF - mov r9, r2 -_081263BC: - movs r6, 0 - ldr r3, =gUnknown_03006184 - mov r12, r3 - mov r0, r9 - lsls r4, r0, 1 - ldr r5, =gUnknown_0300616C - cmp r6, r9 - bcs _081263E0 - movs r2, 0 -_081263CE: - ldr r0, [r3] - lsls r1, r6, 1 - adds r1, r0 - strh r2, [r1] - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 - cmp r6, r9 - bcc _081263CE -_081263E0: - mov r1, r12 - ldr r0, [r1] - adds r0, r4, r0 - ldr r2, =0x00003def - adds r1, r2, 0 - strh r1, [r0] - movs r3, 0 - ldrb r5, [r5] - cmp r3, r5 - bcs _081264E4 -_081263F4: - ldr r2, =gUnknown_03006168 - ldr r0, =gUnknown_03006178 - ldrb r1, [r0] - adds r1, r3 - ldr r0, =gUnknown_03006180 - ldrb r0, [r0] - muls r0, r1 - lsls r0, 1 - ldr r1, [r2] - adds r1, r0 - ldr r0, =gUnknown_03006164 - ldrb r0, [r0] - lsls r0, 1 - adds r4, r1, r0 - movs r6, 0 - ldr r0, =gUnknown_03006174 - adds r2, r0, 0 - adds r3, 0x1 - mov r10, r3 - ldrb r3, [r2] - cmp r6, r3 - bcs _081264D6 - ldr r0, =gUnknown_03006188 - mov r8, r0 -_08126424: - ldrh r0, [r4] - movs r3, 0x80 - lsls r3, 8 - adds r1, r3, 0 - ands r0, r1 - cmp r0, 0 - beq _08126464 - mov r1, r8 - ldrh r0, [r1] - strh r0, [r4] - adds r6, 0x1 - adds r7, r4, 0x2 - b _081264CA - .pool -_08126464: - adds r0, r4, 0 - bl sub_81267C4 - lsls r0, 16 - lsrs r5, r0, 16 - movs r3, 0x1 - adds r6, 0x1 - adds r7, r4, 0x2 - cmp r3, r9 - bcs _081264C0 - ldr r0, =gUnknown_03006184 - ldr r2, [r0] - ldrh r1, [r2, 0x2] - mov r12, r0 - cmp r1, 0 - bne _08126494 - strh r5, [r2, 0x2] - mov r2, r8 - ldrh r0, [r2] - adds r0, 0x1 - b _081264BE - .pool -_08126494: - mov r2, r12 - ldr r1, [r2] - lsls r0, r3, 1 - adds r0, r1 - ldrh r0, [r0] - cmp r0, r5 - beq _081264B8 - adds r0, r3, 0x1 - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, r9 - bcs _081264C0 - lsls r0, r3, 1 - adds r1, r0, r1 - ldrh r0, [r1] - cmp r0, 0 - bne _08126494 - strh r5, [r1] -_081264B8: - mov r1, r8 - ldrh r0, [r1] - adds r0, r3 -_081264BE: - strh r0, [r4] -_081264C0: - ldr r2, =gUnknown_03006174 - cmp r3, r9 - bne _081264CA - mov r3, r9 - strh r3, [r4] -_081264CA: - lsls r0, r6, 24 - lsrs r6, r0, 24 - adds r4, r7, 0 - ldrb r0, [r2] - cmp r6, r0 - bcc _08126424 -_081264D6: - mov r1, r10 - lsls r0, r1, 24 - lsrs r3, r0, 24 - ldr r0, =gUnknown_0300616C - ldrb r0, [r0] - cmp r3, r0 - bcc _081263F4 -_081264E4: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81263A4 - - thumb_func_start sub_81264FC -sub_81264FC: @ 81264FC - push {r4-r7,lr} - mov r7, r8 - push {r7} - movs r2, 0 - ldr r0, =gUnknown_0300616C - ldrb r0, [r0] - cmp r2, r0 - bcs _081265A0 - ldr r0, =gUnknown_03006168 - mov r8, r0 -_08126510: - 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 - movs r6, 0 - ldr r0, =gUnknown_03006174 - adds r3, r0, 0 - adds r7, r2, 0x1 - ldrb r0, [r3] - cmp r6, r0 - bcs _08126594 - ldr r5, =gUnknown_03006188 -_0812653C: - ldrh r0, [r4] - movs r2, 0x80 - lsls r2, 8 - adds r1, r2, 0 - ands r0, r1 - cmp r0, 0 - beq _0812656C - ldrh r0, [r5] - strh r0, [r4] - b _08126586 - .pool -_0812656C: - adds r0, r4, 0 - bl ConvertToBlackOrWhite - lsls r0, 16 - cmp r0, 0 - bne _0812657E - ldrh r0, [r5] - adds r0, 0x1 - b _08126582 -_0812657E: - ldrh r0, [r5] - adds r0, 0x2 -_08126582: - strh r0, [r4] - ldr r3, =gUnknown_03006174 -_08126586: - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 - adds r4, 0x2 - ldrb r0, [r3] - cmp r6, r0 - bcc _0812653C -_08126594: - lsls r0, r7, 24 - lsrs r2, r0, 24 - ldr r0, =gUnknown_0300616C - ldrb r0, [r0] - cmp r2, r0 - bcc _08126510 -_081265A0: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81264FC - - thumb_func_start sub_81265B4 -sub_81265B4: @ 81265B4 - 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 _08126650 - ldr r0, =gUnknown_03006168 - mov r8, r0 -_081265CA: - 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 - movs r5, 0 - ldr r0, =gUnknown_03006174 - adds r7, r2, 0x1 - ldrb r0, [r0] - cmp r5, r0 - bcs _08126644 - ldr r6, =gUnknown_03006188 - movs r0, 0x80 - lsls r0, 8 - adds r2, r0, 0 -_081265FA: - ldrh r0, [r4] - ands r0, r2 - cmp r0, 0 - beq _08126624 - ldrh r0, [r6] - strh r0, [r4] - b _08126634 - .pool -_08126624: - adds r0, r4, 0 - str r2, [sp] - bl sub_8126908 - ldrh r1, [r6] - adds r0, r1 - strh r0, [r4] - ldr r2, [sp] -_08126634: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - adds r4, 0x2 - ldr r0, =gUnknown_03006174 - ldrb r0, [r0] - cmp r5, r0 - bcc _081265FA -_08126644: - lsls r0, r7, 24 - lsrs r2, r0, 24 - ldr r0, =gUnknown_0300616C - ldrb r0, [r0] - cmp r2, r0 - bcc _081265CA -_08126650: - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81265B4 - - thumb_func_start sub_8126664 -sub_8126664: @ 8126664 - 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 _08126700 - ldr r0, =gUnknown_03006168 - mov r8, r0 -_0812667A: - 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 - movs r5, 0 - ldr r0, =gUnknown_03006174 - adds r7, r2, 0x1 - ldrb r0, [r0] - cmp r5, r0 - bcs _081266F4 - ldr r6, =gUnknown_03006188 - movs r0, 0x80 - lsls r0, 8 - adds r2, r0, 0 -_081266AA: - ldrh r0, [r4] - ands r0, r2 - cmp r0, 0 - beq _081266D4 - ldrh r0, [r6] - strh r0, [r4] - b _081266E4 - .pool -_081266D4: - adds r0, r4, 0 - str r2, [sp] - bl sub_812693C - ldrh r1, [r6] - adds r0, r1 - strh r0, [r4] - ldr r2, [sp] -_081266E4: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - adds r4, 0x2 - ldr r0, =gUnknown_03006174 - ldrb r0, [r0] - cmp r5, r0 - bcc _081266AA -_081266F4: - lsls r0, r7, 24 - lsrs r2, r0, 24 - ldr r0, =gUnknown_0300616C - ldrb r0, [r0] - cmp r2, r0 - bcc _0812667A -_08126700: - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8126664 - - thumb_func_start sub_8126714 -sub_8126714: @ 8126714 - 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 _081267B0 - ldr r0, =gUnknown_03006168 - mov r8, r0 -_0812672A: - 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 - movs r5, 0 - ldr r0, =gUnknown_03006174 - adds r7, r2, 0x1 - ldrb r0, [r0] - cmp r5, r0 - bcs _081267A4 - ldr r6, =gUnknown_03006188 - movs r0, 0x80 - lsls r0, 8 - adds r2, r0, 0 -_0812675A: - ldrh r0, [r4] - ands r0, r2 - cmp r0, 0 - beq _08126784 - ldrh r0, [r6] - strh r0, [r4] - b _08126794 - .pool -_08126784: - adds r0, r4, 0 - str r2, [sp] - bl sub_8126838 - ldrh r1, [r6] - adds r0, r1 - strh r0, [r4] - ldr r2, [sp] -_08126794: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - adds r4, 0x2 - ldr r0, =gUnknown_03006174 - ldrb r0, [r0] - cmp r5, r0 - bcc _0812675A -_081267A4: - lsls r0, r7, 24 - lsrs r2, r0, 24 - ldr r0, =gUnknown_0300616C - ldrb r0, [r0] - cmp r2, r0 - bcc _0812672A -_081267B0: - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8126714 - - thumb_func_start sub_81267C4 -sub_81267C4: @ 81267C4 - push {r4,lr} - ldrh r0, [r0] - movs r1, 0x1F - movs r4, 0x1F - ands r4, r0 - lsls r0, 16 - lsrs r3, r0, 21 - ands r3, r1 - lsrs r2, r0, 26 - ands r2, r1 - movs r1, 0x3 - adds r0, r4, 0 - ands r0, r1 - cmp r0, 0 - beq _081267E8 - movs r0, 0x1C - ands r0, r4 - adds r4, r0, 0x4 -_081267E8: - adds r0, r3, 0 - ands r0, r1 - cmp r0, 0 - beq _081267F6 - movs r0, 0x1C - ands r0, r3 - adds r3, r0, 0x4 -_081267F6: - adds r0, r2, 0 - ands r0, r1 - cmp r0, 0 - beq _08126804 - movs r0, 0x1C - ands r0, r2 - adds r2, r0, 0x4 -_08126804: - cmp r4, 0x5 - bhi _0812680A - movs r4, 0x6 -_0812680A: - cmp r4, 0x1E - bls _08126810 - movs r4, 0x1E -_08126810: - cmp r3, 0x5 - bhi _08126816 - movs r3, 0x6 -_08126816: - cmp r3, 0x1E - bls _0812681C - movs r3, 0x1E -_0812681C: - cmp r2, 0x5 - bhi _08126822 - movs r2, 0x6 -_08126822: - cmp r2, 0x1E - bls _08126828 - movs r2, 0x1E -_08126828: - lsls r0, r2, 10 - lsls r1, r3, 5 - orrs r0, r1 - orrs r4, r0 - adds r0, r4, 0 - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_81267C4 - - thumb_func_start sub_8126838 -sub_8126838: @ 8126838 - push {lr} - ldrh r0, [r0] - movs r1, 0x1F - movs r3, 0x1F - ands r3, r0 - lsls r0, 16 - lsrs r2, r0, 21 - ands r2, r1 - lsrs r0, 26 - ands r0, r1 - cmp r3, 0xB - bhi _0812685C - cmp r2, 0xA - bhi _0812685C - cmp r0, 0xA - bhi _0812685C - movs r0, 0x1 - b _08126902 -_0812685C: - cmp r3, 0x13 - bls _08126880 - cmp r2, 0x13 - bls _08126868 - cmp r0, 0x13 - bhi _0812688C -_08126868: - cmp r3, 0x13 - bls _08126880 - cmp r2, 0x13 - bls _08126876 - cmp r0, 0xE - bhi _0812688C - b _081268C4 -_08126876: - cmp r0, 0x13 - bls _08126880 - cmp r2, 0xE - bhi _0812688C - b _081268A0 -_08126880: - cmp r2, 0x13 - bls _08126890 - cmp r0, 0x13 - bls _08126890 - cmp r3, 0xE - bls _081268E8 -_0812688C: - movs r0, 0x2 - b _08126902 -_08126890: - cmp r3, 0x13 - bls _081268B4 - cmp r2, 0xB - bls _081268A8 - cmp r0, 0xB - bls _081268A4 - cmp r2, r0 - bcs _081268C4 -_081268A0: - movs r0, 0x8 - b _08126902 -_081268A4: - movs r0, 0xA - b _08126902 -_081268A8: - cmp r0, 0xB - bls _081268B0 - movs r0, 0xD - b _08126902 -_081268B0: - movs r0, 0x4 - b _08126902 -_081268B4: - cmp r2, 0x13 - bls _081268D8 - cmp r3, 0xB - bls _081268CC - cmp r0, 0xB - bls _081268C8 - cmp r3, r0 - bcc _081268E8 -_081268C4: - movs r0, 0x7 - b _08126902 -_081268C8: - movs r0, 0xB - b _08126902 -_081268CC: - cmp r0, 0xB - bls _081268D4 - movs r0, 0xE - b _08126902 -_081268D4: - movs r0, 0x5 - b _08126902 -_081268D8: - cmp r0, 0x13 - bls _08126900 - cmp r3, 0xB - bls _081268EC - cmp r2, 0xB - bls _081268F4 - cmp r3, r2 - bcs _081268A0 -_081268E8: - movs r0, 0x9 - b _08126902 -_081268EC: - cmp r2, 0xB - bls _081268F4 - movs r0, 0xC - b _08126902 -_081268F4: - cmp r0, 0xB - bls _081268FC - movs r0, 0xF - b _08126902 -_081268FC: - movs r0, 0x6 - b _08126902 -_08126900: - movs r0, 0x3 -_08126902: - pop {r1} - bx r1 - thumb_func_end sub_8126838 - - thumb_func_start sub_8126908 -sub_8126908: @ 8126908 - push {lr} - ldrh r1, [r0] - movs r3, 0x1F - movs r0, 0x1F - ands r0, r1 - lsls r1, 16 - lsrs r2, r1, 21 - ands r2, r3 - lsrs r1, 26 - ands r1, r3 - adds r0, r2 - adds r0, r1 - movs r1, 0x3 - bl __divsi3 - movs r1, 0x1E - ands r0, r1 - lsls r0, 16 - cmp r0, 0 - beq _08126934 - lsrs r0, 17 - b _08126936 -_08126934: - movs r0, 0x1 -_08126936: - pop {r1} - bx r1 - thumb_func_end sub_8126908 - - thumb_func_start sub_812693C -sub_812693C: @ 812693C - push {lr} - ldrh r1, [r0] - movs r3, 0x1F - movs r0, 0x1F - ands r0, r1 - lsls r1, 16 - lsrs r2, r1, 21 - ands r2, r3 - lsrs r1, 26 - ands r1, r3 - adds r0, r2 - adds r0, r1 - movs r1, 0x3 - bl __divsi3 - lsls r0, 16 - movs r1, 0x80 - lsls r1, 9 - adds r0, r1 - lsrs r0, 16 - pop {r1} - bx r1 - thumb_func_end sub_812693C - - .align 2, 0 @ Don't pad with nop. diff --git a/ld_script.txt b/ld_script.txt index e60badcc2..263bcbd20 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -185,7 +185,6 @@ SECTIONS { src/heal_location.o(.text); src/region_map.o(.text); src/contest_painting_effects.o(.text); - asm/contest_painting_effects.o(.text); src/decoration.o(.text); src/slot_machine.o(.text); src/contest_painting.o(.text); diff --git a/src/contest_painting_effects.c b/src/contest_painting_effects.c index 142ad7bc9..a791df65c 100644 --- a/src/contest_painting_effects.c +++ b/src/contest_painting_effects.c @@ -3,6 +3,13 @@ #include "contest_painting.h" #include "constants/rgb.h" +struct Unk8125954 +{ + u8 unk0; + u8 unk1; + u16 unk2; +}; + // IWRAM common u8 gUnknown_03006164; u16 (*gUnknown_03006168)[][32]; @@ -12,32 +19,46 @@ u8 gUnknown_03006174; u8 gUnknown_03006178; u8 gUnknown_0300617C; u8 gUnknown_03006180; -u16 gUnknown_03006184; +u16 *gUnknown_03006184; u16 gUnknown_03006188; -// 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); +static void sub_8125230(void); +static void sub_81252E8(void); +static void sub_81254E0(void); +static void sub_8125630(void); +static void sub_8125448(void); +static void sub_81257F8(void); +static void sub_81258A0(void); +static void sub_81256C8(void); +static void sub_8125250(void); +static void sub_81253A4(u8); +static void sub_81250B8(u8); +static void sub_8125170(u8); +static void sub_8125954(u16); +static u16 ConvertColorToGrayscale(u16*); +static u16 sub_8125E18(u16*, u16*, u16*); +static u16 ConvertCoolColor(u16*, u8); +static u16 ConvertToBlackOrWhite(u16*); +static u16 sub_8125C98(u16*, u16*); +static u16 InvertColor(u16*); +static u16 sub_8125F38(u16*, u16*, u16*); +static u16 sub_8125CF4(u16*, u16*); +static u16 GetCoolColorFromPersonality(u8); +static void sub_81263A4(bool8); +static void sub_8126270(void); +static void sub_8126714(void); +static void sub_8126370(void); +static void sub_8126664(void); +static void sub_8126334(void); +static void sub_81265B4(void); +static void sub_8126318(void); +static void sub_81264FC(void); +static u16 sub_81267C4(u16*); +static u16 sub_8126908(u16*); +static u16 sub_812693C(u16*); +static u16 sub_8126838(u16*); + +extern const u8 gUnknown_085A1F94[][3]; void sub_8124F2C(struct Unk030061A0 *info) { @@ -104,7 +125,7 @@ void sub_8124F2C(struct Unk030061A0 *info) } } -void sub_81250B8(u8 a0) // it changes palette someway somehow... .__. +static void sub_81250B8(u8 a0) // it changes palette someway somehow... .__. { u8 i, j; @@ -127,7 +148,7 @@ void sub_81250B8(u8 a0) // it changes palette someway somehow... .__. } } -void sub_8125170(u8 a0) +static void sub_8125170(u8 a0) { u8 i, j; @@ -149,14 +170,14 @@ void sub_8125170(u8 a0) } } -void sub_8125230(void) +static void sub_8125230(void) { u32 i; for (i = 0; i < 3200; i++) sub_8125954(i); } -void sub_8125250(void) +static void sub_8125250(void) { u8 i, j; @@ -174,7 +195,7 @@ void sub_8125250(void) } } -void sub_81252E8(void) +static void sub_81252E8(void) { u8 i, j; @@ -200,7 +221,7 @@ void sub_81252E8(void) } } -void sub_81253A4(u8 arg0) +static void sub_81253A4(u8 arg0) { u8 i, j; @@ -218,7 +239,7 @@ void sub_81253A4(u8 arg0) } } -void sub_8125448(void) +static void sub_8125448(void) { u8 i, j; @@ -236,7 +257,7 @@ void sub_8125448(void) } } -void sub_81254E0(void) +static void sub_81254E0(void) { u8 i, j; u16 *palette; @@ -270,7 +291,7 @@ void sub_81254E0(void) } } -void sub_8125630(void) +static void sub_8125630(void) { u8 i, j; @@ -288,7 +309,7 @@ void sub_8125630(void) } } -void sub_81256C8(void) +static void sub_81256C8(void) { u8 i, j; u16 *palette; @@ -349,7 +370,7 @@ void sub_81256C8(void) } } -void sub_81257F8(void) +static void sub_81257F8(void) { u8 i, j; @@ -369,7 +390,7 @@ void sub_81257F8(void) } } -void sub_81258A0(void) +static void sub_81258A0(void) { u8 i, j; @@ -389,16 +410,7 @@ void sub_81258A0(void) } } -struct Unk8125954 -{ - u8 unk0; - u8 unk1; - u16 unk2; -}; - -extern const u8 gUnknown_085A1F94[][3]; - -void sub_8125954(u16 arg0) +static void sub_8125954(u16 arg0) { u8 i; u8 r5, r9; @@ -487,7 +499,7 @@ void sub_8125954(u16 arg0) } } -u16 ConvertColorToGrayscale(u16 *color) +static u16 ConvertColorToGrayscale(u16 *color) { s32 clr = *color; s32 r = clr & 0x1F; @@ -499,7 +511,7 @@ u16 ConvertColorToGrayscale(u16 *color) // The dark colors are the colored edges of the Cool painting effect. // Everything else is white. -u16 ConvertCoolColor(u16 *color, u8 personality) +static u16 ConvertCoolColor(u16 *color, u8 personality) { u16 red = *color & 0x1F; u16 green = (*color >> 5) & 0x1F; @@ -513,7 +525,7 @@ u16 ConvertCoolColor(u16 *color, u8 personality) // 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) +static u16 GetCoolColorFromPersonality(u8 personality) { u16 red = 0; u16 green = 0; @@ -564,7 +576,7 @@ u16 GetCoolColorFromPersonality(u8 personality) return RGB2(red, green, blue); } -u16 ConvertToBlackOrWhite(u16 *color) +static u16 ConvertToBlackOrWhite(u16 *color) { u16 red = *color & 0x1F; u16 green = (*color >> 5) & 0x1F; @@ -576,7 +588,7 @@ u16 ConvertToBlackOrWhite(u16 *color) return RGB_WHITE; } -u16 sub_8125C98(u16 *colorA, u16 *colorB) +static u16 sub_8125C98(u16 *colorA, u16 *colorB) { if (*colorA) { @@ -591,7 +603,7 @@ u16 sub_8125C98(u16 *colorA, u16 *colorB) return RGB_BLACK; } -u16 InvertColor(u16 *color) +static u16 InvertColor(u16 *color) { u16 red = *color & 0x1F; u16 green = (*color >> 5) & 0x1F; @@ -604,7 +616,7 @@ u16 InvertColor(u16 *color) return RGB2(red, green, blue); } -u16 sub_8125CF4(u16 *a0, u16 *a1) +static u16 sub_8125CF4(u16 *a0, u16 *a1) { u16 sp0[2][3]; u16 spC[3]; @@ -660,7 +672,7 @@ u16 sub_8125CF4(u16 *a0, u16 *a1) return RGB2(r, g, b); } -u16 sub_8125E18(u16 * a0, u16 * a1, u16 * a2) +static u16 sub_8125E18(u16 * a0, u16 * a1, u16 * a2) { u16 red, green, blue; u16 avg0, avg1, avg2; @@ -704,7 +716,7 @@ u16 sub_8125E18(u16 * a0, u16 * a1, u16 * a2) return RGB2(red, green, blue); } -u16 sub_8125F38(u16 *a0, u16 *a1, u16 *a2) +static u16 sub_8125F38(u16 *a0, u16 *a1, u16 *a2) { u16 red, green, blue; u16 avg0, avg1, avg2; @@ -772,3 +784,582 @@ void sub_8126058(struct Unk030061A0 *arg0) } } */ + +NAKED +void sub_8126058(struct Unk030061A0 *arg0) +{ + asm_unified("\n\ + push {r4-r7,lr}\n\ + mov r7, r10\n\ + mov r6, r9\n\ + mov r5, r8\n\ + push {r5-r7}\n\ + sub sp, 0xC\n\ + ldrb r1, [r0, 0x1D]\n\ + lsrs r5, r1, 3\n\ + ldrb r1, [r0, 0x1E]\n\ + lsrs r1, 3\n\ + str r1, [sp, 0x8]\n\ + ldr r1, [r0, 0x4]\n\ + str r1, [sp]\n\ + ldr r2, [r0, 0x10]\n\ + str r2, [sp, 0x4]\n\ + ldrh r0, [r0, 0x16]\n\ + cmp r0, 0x2\n\ + bne _08126108\n\ + movs r1, 0\n\ + ldr r0, [sp, 0x8]\n\ + cmp r1, r0\n\ + bcc _08126086\n\ + b _08126194\n\ +_08126086:\n\ + movs r0, 0\n\ + adds r2, r1, 0x1\n\ + mov r10, r2\n\ + cmp r0, r5\n\ + bcs _081260FA\n\ + adds r2, r1, 0\n\ + muls r2, r5\n\ + mov r9, r2\n\ + lsls r1, 3\n\ + mov r8, r1\n\ +_0812609A:\n\ + movs r4, 0\n\ + lsls r6, r0, 4\n\ + adds r7, r0, 0x1\n\ + add r0, r9\n\ + lsls r0, 6\n\ + ldr r1, [sp, 0x4]\n\ + adds r1, r0\n\ + mov r12, r1\n\ +_081260AA:\n\ + lsls r0, r4, 3\n\ + mov r2, r12\n\ + adds r3, r2, r0\n\ + mov r1, r8\n\ + adds r0, r1, r4\n\ + lsls r0, 3\n\ + muls r0, r5\n\ + lsls r0, 1\n\ + ldr r2, [sp]\n\ + adds r0, r2, r0\n\ + adds r2, r0, r6\n\ + ldrh r0, [r2, 0x2]\n\ + lsls r0, 8\n\ + ldrh r1, [r2]\n\ + orrs r0, r1\n\ + strh r0, [r3]\n\ + ldrh r0, [r2, 0x6]\n\ + lsls r0, 8\n\ + ldrh r1, [r2, 0x4]\n\ + orrs r0, r1\n\ + strh r0, [r3, 0x2]\n\ + ldrh r0, [r2, 0xA]\n\ + lsls r0, 8\n\ + ldrh r1, [r2, 0x8]\n\ + orrs r0, r1\n\ + strh r0, [r3, 0x4]\n\ + ldrh r0, [r2, 0xE]\n\ + lsls r0, 8\n\ + ldrh r1, [r2, 0xC]\n\ + orrs r0, r1\n\ + strh r0, [r3, 0x6]\n\ + adds r0, r4, 0x1\n\ + lsls r0, 16\n\ + lsrs r4, r0, 16\n\ + cmp r4, 0x7\n\ + bls _081260AA\n\ + lsls r0, r7, 16\n\ + lsrs r0, 16\n\ + cmp r0, r5\n\ + bcc _0812609A\n\ +_081260FA:\n\ + mov r1, r10\n\ + lsls r0, r1, 16\n\ + lsrs r1, r0, 16\n\ + ldr r2, [sp, 0x8]\n\ + cmp r1, r2\n\ + bcc _08126086\n\ + b _08126194\n\ +_08126108:\n\ + movs r1, 0\n\ + ldr r0, [sp, 0x8]\n\ + cmp r1, r0\n\ + bcs _08126194\n\ +_08126110:\n\ + movs r0, 0\n\ + adds r2, r1, 0x1\n\ + mov r10, r2\n\ + cmp r0, r5\n\ + bcs _08126188\n\ + adds r2, r1, 0\n\ + muls r2, r5\n\ + mov r9, r2\n\ + lsls r1, 3\n\ + mov r8, r1\n\ +_08126124:\n\ + movs r4, 0\n\ + lsls r6, r0, 4\n\ + adds r7, r0, 0x1\n\ + add r0, r9\n\ + lsls r0, 5\n\ + ldr r1, [sp, 0x4]\n\ + adds r1, r0\n\ + mov r12, r1\n\ +_08126134:\n\ + lsls r0, r4, 2\n\ + mov r2, r12\n\ + adds r3, r2, r0\n\ + mov r1, r8\n\ + adds r0, r1, r4\n\ + lsls r0, 3\n\ + muls r0, r5\n\ + lsls r0, 1\n\ + ldr r2, [sp]\n\ + adds r0, r2, r0\n\ + adds r2, r0, r6\n\ + ldrh r1, [r2, 0x2]\n\ + lsls r1, 4\n\ + ldrh r0, [r2]\n\ + orrs r1, r0\n\ + ldrh r0, [r2, 0x4]\n\ + lsls r0, 8\n\ + orrs r1, r0\n\ + ldrh r0, [r2, 0x6]\n\ + lsls r0, 12\n\ + orrs r1, r0\n\ + strh r1, [r3]\n\ + ldrh r1, [r2, 0xA]\n\ + lsls r1, 4\n\ + ldrh r0, [r2, 0x8]\n\ + orrs r1, r0\n\ + ldrh r0, [r2, 0xC]\n\ + lsls r0, 8\n\ + orrs r1, r0\n\ + ldrh r0, [r2, 0xE]\n\ + lsls r0, 12\n\ + orrs r1, r0\n\ + strh r1, [r3, 0x2]\n\ + adds r0, r4, 0x1\n\ + lsls r0, 16\n\ + lsrs r4, r0, 16\n\ + cmp r4, 0x7\n\ + bls _08126134\n\ + lsls r0, r7, 16\n\ + lsrs r0, 16\n\ + cmp r0, r5\n\ + bcc _08126124\n\ +_08126188:\n\ + mov r1, r10\n\ + lsls r0, r1, 16\n\ + lsrs r1, r0, 16\n\ + ldr r2, [sp, 0x8]\n\ + cmp r1, r2\n\ + bcc _08126110\n\ +_08126194:\n\ + add sp, 0xC\n\ + pop {r3-r5}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + mov r10, r5\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0"); +} + +void sub_81261A4(struct Unk030061A0 *arg0) +{ + gUnknown_03006188 = arg0->var_18 * 16; + gUnknown_03006184 = &arg0->var_8[gUnknown_03006188]; + gUnknown_03006168 = arg0->var_4; + gUnknown_03006164 = arg0->var_19; + gUnknown_03006178 = arg0->var_1A; + gUnknown_03006174 = arg0->var_1B; + gUnknown_0300616C = arg0->var_1C; + gUnknown_03006180 = arg0->var_1D; + gUnknown_03006170 = arg0->var_1E; + + switch (arg0->var_14) + { + case 0: + sub_81263A4(FALSE); + break; + case 1: + sub_81263A4(TRUE); + break; + case 2: + sub_8126270(); + sub_8126714(); + break; + case 3: + sub_8126370(); + sub_8126664(); + break; + case 4: + sub_8126334(); + sub_81265B4(); + break; + case 5: + sub_8126318(); + sub_81264FC(); + break; + } +} + +static void sub_8126270(void) +{ + gUnknown_03006184[0] = RGB2(0, 0, 0); + gUnknown_03006184[1] = RGB2(6, 6, 6); + gUnknown_03006184[2] = RGB2(29, 29, 29); + gUnknown_03006184[3] = RGB2(11, 11, 11); + gUnknown_03006184[4] = RGB2(29, 6, 6); + gUnknown_03006184[5] = RGB2(6, 29, 6); + gUnknown_03006184[6] = RGB2(6, 6, 29); + gUnknown_03006184[7] = RGB2(29, 29, 6); + gUnknown_03006184[8] = RGB2(29, 6, 29); + gUnknown_03006184[9] = RGB2(6, 29, 29); + gUnknown_03006184[10] = RGB2(29, 11, 6); + gUnknown_03006184[11] = RGB2(11, 29, 6); + gUnknown_03006184[12] = RGB2(6, 11, 29); + gUnknown_03006184[13] = RGB2(29, 6, 11); + gUnknown_03006184[14] = RGB2(6, 29, 11); + gUnknown_03006184[15] = RGB2(11, 6, 29); +} + +static void sub_8126318(void) +{ + gUnknown_03006184[0] = RGB2(0, 0, 0); + gUnknown_03006184[1] = RGB2(0, 0, 0); + gUnknown_03006184[2] = RGB2(31, 31, 31); +} + +static void sub_8126334(void) +{ + u8 i; + + gUnknown_03006184[0] = RGB2(0, 0, 0); + gUnknown_03006184[1] = RGB2(0, 0, 0); + for (i = 0; i < 14; i++) + gUnknown_03006184[i + 2] = RGB2(2 * (i + 2), 2 * (i + 2), 2 * (i + 2)); +} + +static void sub_8126370(void) +{ + u8 i; + + gUnknown_03006184[0] = RGB2(0, 0, 0); + for (i = 0; i < 32; i++) + gUnknown_03006184[i + 1] = RGB2(i, i, i); +} + +static void sub_81263A4(bool8 arg0) +{ + u8 i, j; + u16 maxIndex; + + maxIndex = 0xDF; + if (!arg0) + maxIndex = 0xFF; + + for (j = 0; j < maxIndex; j++) + gUnknown_03006184[j] = 0; + + gUnknown_03006184[maxIndex] = RGB2(15, 15, 15); + 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 (*pal & 0x8000) + { + *pal = gUnknown_03006188; + } + else + { + u16 color = sub_81267C4(pal); + u8 curIndex = 1; + if (curIndex < maxIndex) + { + if (gUnknown_03006184[curIndex] == RGB_BLACK) + { + gUnknown_03006184[curIndex] = color; + *pal = gUnknown_03006188 + curIndex; + } + else + { + while (curIndex < maxIndex) + { + if (gUnknown_03006184[curIndex] == RGB_BLACK) + { + gUnknown_03006184[curIndex] = color; + *pal = gUnknown_03006188 + curIndex; + break; + } + + if (gUnknown_03006184[curIndex] == color) + { + *pal = gUnknown_03006188 + curIndex; + break; + } + + curIndex++; + } + } + } + + if (curIndex == maxIndex) + { + curIndex = maxIndex; + *pal = curIndex; + } + } + } + } +} + +static void sub_81264FC(void) +{ + 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 (*pal & 0x8000) + { + *pal = gUnknown_03006188; + } + else + { + if (ConvertToBlackOrWhite(pal) == RGB_BLACK) + *pal = gUnknown_03006188 + 1; + else + *pal = gUnknown_03006188 + 2; + } + } + } +} + +static void sub_81265B4(void) +{ + 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 (*pal & 0x8000) + *pal = gUnknown_03006188; + else + *pal = sub_8126908(pal) + gUnknown_03006188; + } + } +} + +static void sub_8126664(void) +{ + 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 (*pal & 0x8000) + *pal = gUnknown_03006188; + else + *pal = sub_812693C(pal) + gUnknown_03006188; + } + } +} + +static void sub_8126714(void) +{ + 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 (*pal & 0x8000) + *pal = gUnknown_03006188; + else + *pal = sub_8126838(pal) + gUnknown_03006188; + } + } +} + +static u16 sub_81267C4(u16 *color) +{ + u16 red = *color & 0x1F; + u16 green = (*color >> 5) & 0x1F; + u16 blue = (*color >> 10) & 0x1F; + + if (red & 3) + red = (red & 0x1C) + 4; + if (green & 3) + green = (green & 0x1C) + 4; + if (blue & 3) + blue = (blue & 0x1C) + 4; + + if (red < 6) + red = 6; + if (red > 30) + red = 30; + + if (green < 6) + green = 6; + if (green > 30) + green = 30; + + if (blue < 6) + blue = 6; + if (blue > 30) + blue = 30; + + return RGB2(red, green, blue); +} + +static u16 sub_8126838(u16* color) +{ + u16 red = *color & 0x1F; + u16 green = (*color >> 5) & 0x1F; + u16 blue = (*color >> 10) & 0x1F; + + if (red < 12 && green < 11 && blue < 11) + return 1; + + if (red > 19 && green > 19 && blue > 19) + return 2; + + if (red > 19) + { + if (green > 19) + { + if (blue > 14) + return 2; + else + return 7; + } + else if (blue > 19) + { + if (green > 14) + return 2; + else + return 8; + } + } + + if (green > 19 && blue > 19) + { + if (red > 14) + return 2; + else + return 9; + } + + if (red > 19) + { + if (green > 11) + { + if (blue > 11) + { + if (green < blue) + return 8; + else + return 7; + } + else + { + return 10; + } + } + else if (blue > 11) + { + return 13; + } + else + { + return 4; + } + } + + if (green > 19) + { + if (red > 11) + { + if (blue > 11) + { + if (red < blue) + return 9; + else + return 7; + } + else + { + return 11; + } + } + else + { + if (blue > 11) + return 14; + else + return 5; + } + } + + if (blue > 19) + { + if (red > 11) + { + if (green > 11) + { + if (red < green) + return 9; + else + return 8; + } + } + else if (green > 11) + { + return 12; + } + + if (blue > 11) + return 15; + else + return 6; + } + + return 3; +} + +static u16 sub_8126908(u16 *color) +{ + u16 red = *color & 0x1F; + u16 green = (*color >> 5) & 0x1F; + u16 blue = (*color >> 10) & 0x1F; + u16 average = ((red + green + blue) / 3) & 0x1E; + if (average == 0) + return 1; + else + return average / 2; +} + +static u16 sub_812693C(u16 *color) +{ + u16 red = *color & 0x1F; + u16 green = (*color >> 5) & 0x1F; + u16 blue = (*color >> 10) & 0x1F; + u16 average = (red + green + blue) / 3; + return average + 1; +}