From 1ca3656d74faf8565e0f61b31a1cd3ab22a44706 Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Sat, 15 Dec 2018 13:07:07 -0600 Subject: [PATCH] Decompile contest_painting.c (#447) --- asm/contest_painting.s | 1197 ----------------- ...te_sketch.s => contest_painting_effects.s} | 0 data/contest_painting.s | 106 -- ...te_sketch.s => contest_painting_effects.s} | 0 include/contest.h | 1 + include/contest_painting.h | 13 +- include/contest_painting_effects.h | 28 + include/strings.h | 1 + ld_script.txt | 7 +- src/battle_anim_8170478.c | 64 +- src/contest_painting.c | 711 +++++++++- src/script_pokemon_util_80F87D8.c | 2 +- sym_common.txt | 2 +- 13 files changed, 784 insertions(+), 1348 deletions(-) delete mode 100644 asm/contest_painting.s rename asm/{cute_sketch.s => contest_painting_effects.s} (100%) delete mode 100644 data/contest_painting.s rename data/{cute_sketch.s => contest_painting_effects.s} (100%) create mode 100755 include/contest_painting_effects.h diff --git a/asm/contest_painting.s b/asm/contest_painting.s deleted file mode 100644 index f7c146e3e..000000000 --- a/asm/contest_painting.s +++ /dev/null @@ -1,1197 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_812FDA8 -sub_812FDA8: @ 812FDA8 - push {r4-r7,lr} - ldr r3, =gUnknown_02039F5D - ldr r4, =gUnknown_02039F5C - ldr r1, =gSaveBlock1Ptr - ldr r2, [r1] - subs r0, 0x1 - lsls r1, r0, 5 - adds r2, r1 - ldr r1, =gUnknown_02039F3C - ldr r5, =0x00002e90 - adds r2, r5 - ldm r2!, {r5-r7} - stm r1!, {r5-r7} - ldm r2!, {r5-r7} - stm r1!, {r5-r7} - ldm r2!, {r6,r7} - stm r1!, {r6,r7} - strb r0, [r3] - movs r0, 0 - strb r0, [r4] - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_812FDA8 - - thumb_func_start sub_812FDEC -sub_812FDEC: @ 812FDEC - push {lr} - bl sub_812FE58 - pop {r0} - bx r0 - thumb_func_end sub_812FDEC - - thumb_func_start sub_812FDF8 -sub_812FDF8: @ 812FDF8 - push {lr} - bl sub_812FFC8 - bl RunTextPrinters - bl UpdatePaletteFade - pop {r0} - bx r0 - thumb_func_end sub_812FDF8 - - thumb_func_start sub_812FE0C -sub_812FE0C: @ 812FE0C - push {r4,r5,lr} - ldr r0, =gMain - ldr r0, [r0, 0x8] - bl SetMainCallback2 - ldr r4, =gUnknown_030061C4 - ldr r0, [r4] - bl Free - movs r5, 0 - str r5, [r4] - ldr r4, =gUnknown_03006190 - ldr r0, [r4] - bl Free - str r5, [r4] - ldr r0, =gUnknown_030011F7 - ldrb r0, [r0] - bl RemoveWindow - movs r0, 0x1 - bl GetBgTilemapBuffer - bl Free - bl FreeMonSpritesGfx - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_812FE0C - - thumb_func_start sub_812FE58 -sub_812FE58: @ 812FE58 - push {r4-r7,lr} - sub sp, 0x4 - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r0, r1, r2 - ldrb r0, [r0] - adds r4, r1, 0 - cmp r0, 0x4 - bls _0812FE6E - b _0812FFA0 -_0812FE6E: - lsls r0, 2 - ldr r1, =_0812FE80 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0812FE80: - .4byte _0812FE94 - .4byte _0812FEC8 - .4byte _0812FF14 - .4byte _0812FF2A - .4byte _0812FF54 -_0812FE94: - bl ScanlineEffect_Stop - movs r0, 0 - bl SetVBlankCallback - bl AllocateMonSpritesGfx - ldr r1, =gUnknown_030061C0 - ldr r0, =gUnknown_02039F3C - str r0, [r1] - movs r0, 0x1 - bl sub_8130238 - bl sub_81301EC - ldr r1, =gMain - movs r0, 0x87 - lsls r0, 3 - adds r1, r0 - b _0812FF3E - .pool -_0812FEC8: - bl ResetPaletteFade - movs r2, 0xC0 - lsls r2, 19 - movs r3, 0xC0 - lsls r3, 9 - movs r5, 0 - ldr r1, =0x040000d4 - movs r4, 0x80 - lsls r4, 5 - ldr r6, =0x85000400 - movs r7, 0x85 - lsls r7, 24 -_0812FEE2: - str r5, [sp] - mov r0, sp - str r0, [r1] - str r2, [r1, 0x4] - str r6, [r1, 0x8] - ldr r0, [r1, 0x8] - adds r2, r4 - subs r3, r4 - cmp r3, r4 - bhi _0812FEE2 - str r5, [sp] - mov r0, sp - str r0, [r1] - str r2, [r1, 0x4] - lsrs r0, r3, 2 - orrs r0, r7 - str r0, [r1, 0x8] - ldr r0, [r1, 0x8] - bl ResetSpriteData - b _0812FF36 - .pool -_0812FF14: - ldrh r0, [r4, 0x20] - bl SeedRng - bl InitKeys - bl sub_8130098 - movs r0, 0x87 - lsls r0, 3 - adds r1, r4, r0 - b _0812FF3E -_0812FF2A: - ldr r0, =gUnknown_02039F5D - ldrb r0, [r0] - ldr r1, =gUnknown_02039F5C - ldrb r1, [r1] - bl sub_8130884 -_0812FF36: - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r1, r2 -_0812FF3E: - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - b _0812FFA0 - .pool -_0812FF54: - ldr r0, =gUnknown_02039F5D - ldrb r0, [r0] - ldr r1, =gUnknown_02039F5C - ldrb r1, [r1] - bl sub_813010C - ldr r0, =gUnknown_085B0838 - movs r1, 0 - movs r2, 0x2 - bl LoadPalette - movs r1, 0xA0 - lsls r1, 19 - movs r4, 0 - str r4, [sp] - ldr r0, =0x040000d4 - mov r2, sp - str r2, [r0] - str r1, [r0, 0x4] - ldr r1, =0x85000100 - str r1, [r0, 0x8] - ldr r0, [r0, 0x8] - movs r0, 0x2 - bl BeginFastPaletteFade - ldr r0, =sub_81302D0 - bl SetVBlankCallback - ldr r0, =gUnknown_030011F0 - strb r4, [r0] - movs r1, 0x9A - lsls r1, 5 - movs r0, 0 - bl SetGpuReg - ldr r0, =sub_812FDF8 - bl SetMainCallback2 -_0812FFA0: - add sp, 0x4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_812FE58 - - thumb_func_start sub_812FFC8 -sub_812FFC8: @ 812FFC8 - push {lr} - sub sp, 0x4 - ldr r3, =gUnknown_030011F0 - ldrb r1, [r3] - cmp r1, 0x1 - beq _0813001C - cmp r1, 0x1 - bgt _0812FFE4 - cmp r1, 0 - beq _0812FFEA - b _08130082 - .pool -_0812FFE4: - cmp r1, 0x2 - beq _0813005C - b _08130082 -_0812FFEA: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _0812FFFA - movs r0, 0x1 - strb r0, [r3] -_0812FFFA: - ldr r0, =gUnknown_030011F6 - ldrb r0, [r0] - cmp r0, 0 - beq _08130082 - ldr r1, =gUnknown_030011F4 - ldrh r0, [r1] - cmp r0, 0 - beq _08130082 - subs r0, 0x1 - b _08130080 - .pool -_0813001C: - ldr r0, =gMain - ldrh r2, [r0, 0x2E] - ands r1, r2 - cmp r1, 0 - bne _0813002E - movs r0, 0x2 - ands r0, r2 - cmp r0, 0 - beq _08130040 -_0813002E: - movs r0, 0x2 - strb r0, [r3] - subs r0, 0x3 - movs r1, 0 - str r1, [sp] - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade -_08130040: - ldr r0, =gUnknown_030011F6 - ldrb r0, [r0] - cmp r0, 0 - beq _08130082 - ldr r1, =gUnknown_030011F4 - movs r0, 0 - b _08130080 - .pool -_0813005C: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _0813006E - ldr r0, =sub_812FE0C - bl SetMainCallback2 -_0813006E: - ldr r0, =gUnknown_030011F6 - ldrb r0, [r0] - cmp r0, 0 - beq _08130082 - ldr r1, =gUnknown_030011F4 - ldrh r0, [r1] - cmp r0, 0x1D - bhi _08130082 - adds r0, 0x1 -_08130080: - strh r0, [r1] -_08130082: - add sp, 0x4 - pop {r0} - bx r0 - .pool - thumb_func_end sub_812FFC8 - - thumb_func_start sub_8130098 -sub_8130098: @ 8130098 - push {r4,lr} - movs r0, 0 - bl ResetBgsAndClearDma3BusyFlags - ldr r1, =gUnknown_085B07E8 - movs r0, 0 - movs r2, 0x1 - bl InitBgsFromTemplates - movs r0, 0x1 - movs r1, 0 - movs r2, 0 - bl ChangeBgX - movs r0, 0x1 - movs r1, 0 - movs r2, 0 - bl ChangeBgY - movs r0, 0x80 - lsls r0, 4 - bl AllocZeroed - adds r1, r0, 0 - movs r0, 0x1 - bl SetBgTilemapBuffer - ldr r4, =gUnknown_030011F7 - ldr r0, =gUnknown_085B07EC - bl AddWindow - strb r0, [r4] - bl DeactivateAllTextPrinters - ldrb r0, [r4] - movs r1, 0 - bl FillWindowPixelBuffer - ldrb r0, [r4] - bl PutWindowTilemap - ldrb r0, [r4] - movs r1, 0x3 - bl CopyWindowToVram - movs r0, 0x1 - bl ShowBg - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8130098 - - thumb_func_start sub_813010C -sub_813010C: @ 813010C - push {r4-r6,lr} - sub sp, 0xC - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsrs r1, 24 - cmp r1, 0x1 - beq _081301D4 - ldr r6, =gUnknown_030061C0 - ldr r1, [r6] - ldrb r5, [r1, 0xA] - cmp r0, 0x7 - bhi _08130190 - ldr r4, =gStringVar1 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_818E868 - ldr r1, =gText_Space - adds r0, r4, 0 - bl StringAppend - ldr r1, =gContestRankTextPointers - ldr r0, [r6] - ldrb r0, [r0, 0x1E] - lsls r0, 2 - adds r0, r1 - ldr r1, [r0] - adds r0, r4, 0 - bl StringAppend - ldr r4, =gStringVar2 - ldr r1, [r6] - adds r1, 0x16 - adds r0, r4, 0 - bl StringCopy - adds r0, r4, 0 - bl sub_81DB5AC - ldr r0, =gStringVar3 - ldr r1, [r6] - adds r1, 0xB - bl StringCopy - ldr r0, =gStringVar4 - ldr r1, =gUnknown_0827EA0C - bl StringExpandPlaceholders - b _081301A6 - .pool -_08130190: - ldr r0, =gStringVar1 - adds r1, 0xB - bl StringCopy - ldr r0, =gStringVar4 - ldr r2, =gContestPaintingDescriptionPointers - lsls r1, r5, 2 - adds r1, r2 - ldr r1, [r1] - bl StringExpandPlaceholders -_081301A6: - ldr r4, =gStringVar4 - movs r0, 0x1 - adds r1, r4, 0 - movs r2, 0xD0 - bl GetStringCenterAlignXOffset - adds r3, r0, 0 - ldr r0, =gUnknown_030011F7 - ldrb r0, [r0] - lsls r3, 24 - lsrs r3, 24 - movs r1, 0x1 - str r1, [sp] - movs r1, 0 - str r1, [sp, 0x4] - str r1, [sp, 0x8] - movs r1, 0x1 - adds r2, r4, 0 - bl AddTextPrinterParameterized - movs r0, 0x1 - bl CopyBgTilemapBufferToVram -_081301D4: - add sp, 0xC - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_813010C - - thumb_func_start sub_81301EC -sub_81301EC: @ 81301EC - push {lr} - movs r0, 0 - movs r1, 0 - bl SetGpuReg - ldr r2, =0x04000200 - ldrh r0, [r2] - movs r1, 0x1 - orrs r0, r1 - strh r0, [r2] - ldr r1, =0x00000c42 - movs r0, 0x8 - bl SetGpuReg - ldr r1, =0x00000a45 - movs r0, 0xA - bl SetGpuReg - movs r0, 0x50 - movs r1, 0 - bl SetGpuReg - movs r0, 0x52 - movs r1, 0 - bl SetGpuReg - movs r0, 0x54 - movs r1, 0 - bl SetGpuReg - pop {r0} - bx r0 - .pool - thumb_func_end sub_81301EC - - thumb_func_start sub_8130238 -sub_8130238: @ 8130238 - push {lr} - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0 - bne _0813025C - ldr r0, =gUnknown_030011F6 - strb r1, [r0] - ldr r0, =gUnknown_030011F2 - strh r1, [r0] - ldr r0, =gUnknown_030011F4 - strh r1, [r0] - b _0813026E - .pool -_0813025C: - ldr r1, =gUnknown_030011F6 - movs r0, 0x1 - strb r0, [r1] - ldr r1, =gUnknown_030011F2 - movs r0, 0xF - strh r0, [r1] - ldr r1, =gUnknown_030011F4 - movs r0, 0x1E - strh r0, [r1] -_0813026E: - pop {r0} - bx r0 - .pool - thumb_func_end sub_8130238 - - thumb_func_start sub_8130280 -sub_8130280: @ 8130280 - push {lr} - ldr r0, =gUnknown_030011F6 - ldrb r0, [r0] - cmp r0, 0 - bne _08130298 - movs r0, 0x4C - movs r1, 0 - bl SetGpuReg - b _081302C0 - .pool -_08130298: - ldr r1, =0x00000a45 - movs r0, 0xA - bl SetGpuReg - ldr r1, =gUnknown_030011F2 - ldr r0, =gUnknown_030011F4 - ldrh r0, [r0] - lsrs r0, 1 - strh r0, [r1] - lsls r1, r0, 12 - lsls r2, r0, 8 - orrs r1, r2 - lsls r2, r0, 4 - orrs r1, r2 - orrs r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x4C - bl SetGpuReg -_081302C0: - pop {r0} - bx r0 - .pool - thumb_func_end sub_8130280 - - thumb_func_start sub_81302D0 -sub_81302D0: @ 81302D0 - push {lr} - bl sub_8130280 - bl LoadOam - bl ProcessSpriteCopyRequests - bl TransferPlttBuffer - pop {r0} - bx r0 - thumb_func_end sub_81302D0 - - thumb_func_start sub_81302E8 -sub_81302E8: @ 81302E8 - push {r4-r7,lr} - adds r4, r1, 0 - lsls r0, 16 - lsrs r5, r0, 16 - lsls r4, 24 - lsrs r4, 24 - ldr r6, =gUnknown_030061C0 - ldr r0, [r6] - ldr r1, [r0, 0x4] - ldr r2, [r0] - adds r0, r5, 0 - bl GetFrontSpritePalFromSpeciesAndPersonality - ldr r7, =gUnknown_030061C4 - ldr r1, [r7] - bl LZDecompressVram - cmp r4, 0 - bne _08130348 - lsls r0, r5, 3 - ldr r1, =gMonFrontPicTable - adds r0, r1 - ldr r4, =gMonSpritesGfxPtr - ldr r1, [r4] - ldr r1, [r1, 0x8] - ldr r2, [r6] - ldr r3, [r2] - adds r2, r5, 0 - bl HandleLoadSpecialPokePic_DontHandleDeoxys - ldr r0, [r4] - ldr r0, [r0, 0x8] - ldr r1, [r7] - ldr r2, =gUnknown_03006190 - ldr r2, [r2] - bl sub_8130380 - b _0813036C - .pool -_08130348: - lsls r0, r5, 3 - ldr r1, =gMonBackPicTable - adds r0, r1 - ldr r4, =gMonSpritesGfxPtr - ldr r1, [r4] - ldr r1, [r1, 0x4] - ldr r2, [r6] - ldr r3, [r2] - adds r2, r5, 0 - bl HandleLoadSpecialPokePic_DontHandleDeoxys - ldr r0, [r4] - ldr r0, [r0, 0x4] - ldr r1, [r7] - ldr r2, =gUnknown_03006190 - ldr r2, [r2] - bl sub_8130380 -_0813036C: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81302E8 - - thumb_func_start sub_8130380 -sub_8130380: @ 8130380 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0xC - mov r10, r0 - mov r9, r1 - str r2, [sp] - movs r0, 0 -_08130394: - movs r3, 0 - adds r1, r0, 0x1 - str r1, [sp, 0x4] - lsls r0, 3 - str r0, [sp, 0x8] -_0813039E: - movs r1, 0 - adds r2, r3, 0x1 - mov r8, r2 - ldr r7, [sp, 0x8] - adds r0, r7, r3 - lsls r0, 5 - mov r12, r0 - lsls r4, r3, 3 -_081303AE: - movs r3, 0 - lsls r0, r1, 2 - adds r6, r1, 0x1 - mov r2, r12 - adds r5, r2, r0 - ldr r7, [sp, 0x8] - adds r0, r7, r1 - lsls r0, 7 - ldr r1, [sp] - adds r2, r0, r1 -_081303C2: - lsrs r0, r3, 1 - adds r0, r5, r0 - add r0, r10 - ldrb r1, [r0] - movs r0, 0x1 - ands r0, r3 - cmp r0, 0 - beq _081303D6 - lsrs r1, 4 - b _081303DA -_081303D6: - movs r0, 0xF - ands r1, r0 -_081303DA: - cmp r1, 0 - bne _081303EC - adds r0, r4, r3 - lsls r0, 1 - adds r0, r2 - movs r7, 0x80 - lsls r7, 8 - adds r1, r7, 0 - b _081303F8 -_081303EC: - adds r0, r4, r3 - lsls r0, 1 - adds r0, r2 - lsls r1, 1 - add r1, r9 - ldrh r1, [r1] -_081303F8: - strh r1, [r0] - adds r0, r3, 0x1 - lsls r0, 16 - lsrs r3, r0, 16 - cmp r3, 0x7 - bls _081303C2 - lsls r0, r6, 16 - lsrs r1, r0, 16 - cmp r1, 0x7 - bls _081303AE - mov r1, r8 - lsls r0, r1, 16 - lsrs r3, r0, 16 - cmp r3, 0x7 - bls _0813039E - ldr r2, [sp, 0x4] - lsls r0, r2, 16 - lsrs r0, 16 - cmp r0, 0x7 - bls _08130394 - 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_8130380 - - thumb_func_start sub_8130430 -sub_8130430: @ 8130430 - push {r4-r7,lr} - adds r4, r1, 0 - lsls r0, 24 - lsrs r5, r0, 24 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =gUnknown_085A989C - movs r2, 0x80 - lsls r2, 1 - movs r1, 0 - bl LoadPalette - cmp r4, 0x1 - beq _0813044E - b _081305A4 -_0813044E: - ldr r0, =gUnknown_030061C0 - ldr r0, [r0] - ldrb r0, [r0, 0xA] - movs r1, 0x3 - bl __udivsi3 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x4 - bhi _0813050C - lsls r0, 2 - ldr r1, =_08130478 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08130478: - .4byte _0813048C - .4byte _081304A4 - .4byte _081304BC - .4byte _081304D4 - .4byte _081304F8 -_0813048C: - ldr r0, =gUnknown_085A9A9C - movs r1, 0xC0 - lsls r1, 19 - bl RLUnCompVram - ldr r0, =gUnknown_085AE974 - b _081304E0 - .pool -_081304A4: - ldr r0, =gUnknown_085AAB20 - movs r1, 0xC0 - lsls r1, 19 - bl RLUnCompVram - ldr r0, =gUnknown_085AEE80 - b _081304E0 - .pool -_081304BC: - ldr r0, =gUnknown_085AB750 - movs r1, 0xC0 - lsls r1, 19 - bl RLUnCompVram - ldr r0, =gUnknown_085AF38C - b _081304E0 - .pool -_081304D4: - ldr r0, =gUnknown_085AC288 - movs r1, 0xC0 - lsls r1, 19 - bl RLUnCompVram - ldr r0, =gUnknown_085AF898 -_081304E0: - ldr r1, =gUnknown_03006190 - ldr r1, [r1] - bl RLUnCompWram - b _0813050C - .pool -_081304F8: - ldr r0, =gUnknown_085AD240 - movs r1, 0xC0 - lsls r1, 19 - bl RLUnCompVram - ldr r0, =gUnknown_085AFDA4 - ldr r1, =gUnknown_03006190 - ldr r1, [r1] - bl RLUnCompWram -_0813050C: - movs r1, 0 - ldr r5, =0x06006000 - ldr r0, =0x00001015 - adds r4, r0, 0 -_08130514: - movs r3, 0 - lsls r2, r1, 5 -_08130518: - adds r0, r2, r3 - lsls r0, 1 - adds r0, r5 - strh r4, [r0] - adds r0, r3, 0x1 - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, 0x1F - bls _08130518 - adds r0, r1, 0x1 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x13 - bls _08130514 - movs r1, 0 - ldr r0, =0x0600608c - mov r12, r0 - ldr r7, =gUnknown_03006190 -_0813053C: - movs r3, 0 - adds r6, r1, 0x1 - lsls r5, r1, 5 - lsls r4, r1, 6 -_08130544: - adds r2, r5, r3 - lsls r2, 1 - add r2, r12 - ldr r0, [r7] - adds r0, r4, r0 - lsls r1, r3, 1 - adds r0, r1 - adds r0, 0x8C - ldrh r0, [r0] - strh r0, [r2] - adds r0, r3, 0x1 - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, 0x11 - bls _08130544 - lsls r0, r6, 24 - lsrs r1, r0, 24 - cmp r1, 0x9 - bls _0813053C - movs r3, 0 - ldr r4, =0x0600608e - ldr r2, =gUnknown_03006190 -_08130570: - lsls r1, r3, 1 - adds r1, r4 - ldr r0, [r2] - adds r0, 0x8E - ldrh r0, [r0] - strh r0, [r1] - adds r0, r3, 0x1 - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, 0xF - bls _08130570 - b _08130676 - .pool -_081305A4: - cmp r5, 0x7 - bhi _081305C0 - ldr r0, =gUnknown_085AE370 - movs r1, 0xC0 - lsls r1, 19 - bl RLUnCompVram - ldr r0, =gUnknown_085B02B0 - b _08130650 - .pool -_081305C0: - ldr r0, =gUnknown_030061C0 - ldr r0, [r0] - ldrb r0, [r0, 0xA] - movs r1, 0x3 - bl __udivsi3 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x4 - bhi _08130676 - lsls r0, 2 - ldr r1, =_081305E8 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_081305E8: - .4byte _081305FC - .4byte _08130614 - .4byte _0813062C - .4byte _08130644 - .4byte _08130664 -_081305FC: - ldr r0, =gUnknown_085A9A9C - movs r1, 0xC0 - lsls r1, 19 - bl RLUnCompVram - ldr r0, =gUnknown_085AE974 - b _08130650 - .pool -_08130614: - ldr r0, =gUnknown_085AAB20 - movs r1, 0xC0 - lsls r1, 19 - bl RLUnCompVram - ldr r0, =gUnknown_085AEE80 - b _08130650 - .pool -_0813062C: - ldr r0, =gUnknown_085AB750 - movs r1, 0xC0 - lsls r1, 19 - bl RLUnCompVram - ldr r0, =gUnknown_085AF38C - b _08130650 - .pool -_08130644: - ldr r0, =gUnknown_085AC288 - movs r1, 0xC0 - lsls r1, 19 - bl RLUnCompVram - ldr r0, =gUnknown_085AF898 -_08130650: - ldr r1, =0x06006000 - bl RLUnCompVram - b _08130676 - .pool -_08130664: - ldr r0, =gUnknown_085AD240 - movs r1, 0xC0 - lsls r1, 19 - bl RLUnCompVram - ldr r0, =gUnknown_085AFDA4 - ldr r1, =0x06006000 - bl RLUnCompVram -_08130676: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8130430 - - thumb_func_start sub_8130688 -sub_8130688: @ 8130688 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r3, =gMain - ldr r1, =gUnknown_085B0830 - ldr r2, [r1, 0x4] - ldr r1, [r1] - str r1, [r3, 0x38] - str r2, [r3, 0x3C] - ldrh r2, [r3, 0x3C] - ldr r1, =0xfffffc00 - ands r1, r2 - strh r1, [r3, 0x3C] - ldrh r1, [r3, 0x3A] - ldr r0, =0xfffffe00 - ands r0, r1 - movs r1, 0x58 - orrs r0, r1 - strh r0, [r3, 0x3A] - adds r1, r3, 0 - adds r1, 0x38 - movs r0, 0x18 - strb r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end sub_8130688 - - thumb_func_start sub_81306CC -sub_81306CC: @ 81306CC - push {lr} - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x7 - bhi _081306E4 - ldr r0, =gUnknown_030061C0 - ldr r0, [r0] - ldrb r0, [r0, 0xA] - b _081306F4 - .pool -_081306E4: - ldr r0, =gUnknown_030061C0 - ldr r0, [r0] - ldrb r0, [r0, 0xA] - movs r1, 0x3 - bl __udivsi3 - lsls r0, 24 - lsrs r0, 24 -_081306F4: - cmp r0, 0x4 - bhi _08130732 - lsls r0, 2 - ldr r1, =_0813070C - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0813070C: - .4byte _08130720 - .4byte _08130724 - .4byte _08130728 - .4byte _0813072C - .4byte _08130730 -_08130720: - movs r0, 0x9 - b _08130732 -_08130724: - movs r0, 0xD - b _08130732 -_08130728: - movs r0, 0x2 - b _08130732 -_0813072C: - movs r0, 0x24 - b _08130732 -_08130730: - movs r0, 0x6 -_08130732: - pop {r1} - bx r1 - thumb_func_end sub_81306CC - - thumb_func_start sub_8130738 -sub_8130738: @ 8130738 - push {r4,lr} - ldr r4, =gUnknown_030061C4 - movs r0, 0x80 - lsls r0, 2 - bl AllocZeroed - str r0, [r4] - ldr r4, =gUnknown_03006190 - movs r0, 0x80 - lsls r0, 6 - bl AllocZeroed - str r0, [r4] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8130738 - - thumb_func_start sub_8130760 -sub_8130760: @ 8130760 - push {r4,lr} - lsls r0, 24 - lsrs r3, r0, 24 - ldr r1, =gUnknown_030061A0 - ldr r0, =gUnknown_03006190 - ldr r0, [r0] - str r0, [r1, 0x4] - ldr r0, =gUnknown_030061C4 - ldr r0, [r0] - str r0, [r1, 0x8] - movs r2, 0 - strb r2, [r1, 0x18] - ldr r0, =gUnknown_030061C0 - ldr r0, [r0] - ldrb r0, [r0] - strb r0, [r1, 0x1F] - strb r2, [r1, 0x19] - strb r2, [r1, 0x1A] - movs r0, 0x40 - strb r0, [r1, 0x1B] - strb r0, [r1, 0x1C] - strb r0, [r1, 0x1D] - strb r0, [r1, 0x1E] - subs r0, r3, 0x2 - adds r4, r1, 0 - cmp r0, 0x22 - bhi _08130844 - lsls r0, 2 - ldr r1, =_081307B4 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_081307B4: - .4byte _08130844 - .4byte _08130844 - .4byte _08130844 - .4byte _08130844 - .4byte _08130840 - .4byte _08130844 - .4byte _08130844 - .4byte _08130844 - .4byte _08130844 - .4byte _08130844 - .4byte _08130844 - .4byte _08130844 - .4byte _08130844 - .4byte _08130844 - .4byte _08130844 - .4byte _08130844 - .4byte _08130844 - .4byte _08130844 - .4byte _08130844 - .4byte _08130844 - .4byte _08130844 - .4byte _08130844 - .4byte _08130844 - .4byte _08130844 - .4byte _08130844 - .4byte _08130844 - .4byte _08130844 - .4byte _08130844 - .4byte _08130844 - .4byte _08130844 - .4byte _08130844 - .4byte _08130844 - .4byte _08130844 - .4byte _08130844 - .4byte _08130840 -_08130840: - movs r0, 0x3 - b _08130846 -_08130844: - movs r0, 0x1 -_08130846: - strh r0, [r4, 0x14] - movs r0, 0x2 - strh r0, [r4, 0x16] - strb r3, [r4] - ldr r0, =0x06010000 - str r0, [r4, 0x10] - adds r0, r4, 0 - bl sub_8124F2C - adds r0, r4, 0 - bl sub_81261A4 - adds r0, r4, 0 - bl sub_8126058 - ldr r0, =gUnknown_030061C4 - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 1 - movs r2, 0x80 - lsls r2, 2 - bl LoadPalette - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8130760 - - thumb_func_start sub_8130884 -sub_8130884: @ 8130884 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - lsls r4, 24 - lsrs r4, 24 - lsls r5, 24 - lsrs r5, 24 - bl sub_8130738 - ldr r0, =gUnknown_030061C0 - ldr r0, [r0] - ldrh r0, [r0, 0x8] - movs r1, 0 - bl sub_81302E8 - adds r0, r4, 0 - bl sub_81306CC - lsls r0, 24 - lsrs r0, 24 - bl sub_8130760 - adds r0, r4, 0 - bl sub_8130688 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8130430 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8130884 - - .align 2, 0 @ Don't pad with nop. diff --git a/asm/cute_sketch.s b/asm/contest_painting_effects.s similarity index 100% rename from asm/cute_sketch.s rename to asm/contest_painting_effects.s diff --git a/data/contest_painting.s b/data/contest_painting.s deleted file mode 100644 index 42d76f9bc..000000000 --- a/data/contest_painting.s +++ /dev/null @@ -1,106 +0,0 @@ -@ the third big chunk of data - - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - - .align 2 -gUnknown_085A989C:: @ 85A989C - .incbin "graphics/picture_frame/bg.gbapal" - - .align 2 -gUnknown_085A9A9C:: @ 85A9A9C - .incbin "graphics/picture_frame/frame0.4bpp.rl" - - .align 2 -gUnknown_085AAB20:: @ 85AAB20 - .incbin "graphics/picture_frame/frame1.4bpp.rl" - - .align 2 -gUnknown_085AB750:: @ 85AB750 - .incbin "graphics/picture_frame/frame2.4bpp.rl" - - .align 2 -gUnknown_085AC288:: @ 85AC288 - .incbin "graphics/picture_frame/frame3.4bpp.rl" - - .align 2 -gUnknown_085AD240:: @ 85AD240 - .incbin "graphics/picture_frame/frame4.4bpp.rl" - - .align 2 -gUnknown_085AE370:: @ 85AE370 - .incbin "graphics/picture_frame/frame5.4bpp.rl" - - .align 2 -gUnknown_085AE974:: @ 85AE974 - .incbin "graphics/picture_frame/frame0_map.bin.rl" - - .align 2 -gUnknown_085AEE80:: @ 85AEE80 - .incbin "graphics/picture_frame/frame1_map.bin.rl" - - .align 2 -gUnknown_085AF38C:: @ 85AF38C - .incbin "graphics/picture_frame/frame2_map.bin.rl" - - .align 2 -gUnknown_085AF898:: @ 85AF898 - .incbin "graphics/picture_frame/frame3_map.bin.rl" - - .align 2 -gUnknown_085AFDA4:: @ 85AFDA4 - .incbin "graphics/picture_frame/frame4_map.bin.rl" - - .align 2 -gUnknown_085B02B0:: @ 85B02B0 - .incbin "graphics/picture_frame/frame5_map.bin.rl" - - .align 2 -gUnknown_085B07C0:: @ 85B07C0 - .4byte gContestCoolness - .4byte gContestBeauty - .4byte gContestCuteness - .4byte gContestSmartness - .4byte gContestToughness - - .align 2 -gContestRankTextPointers:: @ 85B07D4 - .4byte gContestRankNormal - .4byte gContestRankSuper - .4byte gContestRankHyper - .4byte gContestRankMaster - .4byte gContestLink - - .align 2 -gUnknown_085B07E8:: @ 85B07E8 - .4byte 0x000010a5 - - .align 2 -gUnknown_085B07EC:: @ 85B07EC - window_template 0x01, 0x02, 0x0e, 0x1a, 0x04, 0x0f, 0x0001 - - .align 2 -gContestPaintingDescriptionPointers:: @ 85B07F4 - .4byte gContestPaintingCool1 - .4byte gContestPaintingCool2 - .4byte gContestPaintingCool3 - .4byte gContestPaintingBeauty1 - .4byte gContestPaintingBeauty2 - .4byte gContestPaintingBeauty3 - .4byte gContestPaintingCute1 - .4byte gContestPaintingCute2 - .4byte gContestPaintingCute3 - .4byte gContestPaintingSmart1 - .4byte gContestPaintingSmart2 - .4byte gContestPaintingSmart3 - .4byte gContestPaintingTough1 - .4byte gContestPaintingTough2 - .4byte gContestPaintingTough3 - -gUnknown_085B0830:: @ 85B0830 - .4byte 0xc0003000, 0x00000000 - -gUnknown_085B0838:: @ 85B0838 - .2byte 0x0000, 0x0000 diff --git a/data/cute_sketch.s b/data/contest_painting_effects.s similarity index 100% rename from data/cute_sketch.s rename to data/contest_painting_effects.s diff --git a/include/contest.h b/include/contest.h index 8790d7371..c205737ee 100644 --- a/include/contest.h +++ b/include/contest.h @@ -231,6 +231,7 @@ extern u8 gContestPlayerMonIndex; extern s16 gUnknown_02039F08[4]; extern s16 gContestMonConditions[4]; extern u8 gIsLinkContest; +extern struct ContestWinner gUnknown_02039F3C; struct Shared18000 { diff --git a/include/contest_painting.h b/include/contest_painting.h index 67a845d62..c633c50cc 100644 --- a/include/contest_painting.h +++ b/include/contest_painting.h @@ -1,7 +1,16 @@ #ifndef GUARD_CONTESTPAINTING_H #define GUARD_CONTESTPAINTING_H -void sub_812FDA8(u32); -void sub_812FDEC(void); +enum +{ + CONTESTRESULT_COOL = 9, + CONTESTRESULT_BEAUTY = 13, + CONTESTRESULT_CUTE = 2, + CONTESTRESULT_SMART = 36, + CONTESTRESULT_TOUGH = 6, +}; + +void sub_812FDA8(int); +void CB2_ContestPainting(void); #endif diff --git a/include/contest_painting_effects.h b/include/contest_painting_effects.h new file mode 100755 index 000000000..3b6964666 --- /dev/null +++ b/include/contest_painting_effects.h @@ -0,0 +1,28 @@ +#ifndef GUARD_CONTEST_PAINTING_EFFECTS_H +#define GUARD_CONTEST_PAINTING_EFFECTS_H + +struct Unk030061A0 +{ + u8 var_0; + u8 pad1[3]; + u16 (*var_4)[][32]; + u16 *var_8; + u8 pad0C[4]; + u32 var_10; + u16 var_14; + u16 var_16; + u8 var_18; + u8 var_19; + u8 var_1A; + u8 var_1B; + u8 var_1C; + u8 var_1D; + u8 var_1E; + u8 var_1F; +}; + +void sub_8124F2C(struct Unk030061A0 *); +void sub_81261A4(struct Unk030061A0 *); +void sub_8126058(struct Unk030061A0 *); + +#endif diff --git a/include/strings.h b/include/strings.h index f0df4bdec..c780a80b4 100644 --- a/include/strings.h +++ b/include/strings.h @@ -1226,6 +1226,7 @@ extern const u8 gText_SpaceAndSpace[]; extern const u8 gText_CommaSpace[]; extern const u8 gText_NewLine[]; extern const u8 gText_ScrollTextUp[]; +extern const u8 gText_Space[]; extern const u8 gText_Space2[]; extern const u8 gText_Are[]; extern const u8 gText_Are2[]; diff --git a/ld_script.txt b/ld_script.txt index 1413941f1..68aa8463c 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -186,11 +186,10 @@ SECTIONS { src/dewford_trend.o(.text); src/heal_location.o(.text); src/region_map.o(.text); - asm/cute_sketch.o(.text); + asm/contest_painting_effects.o(.text); src/decoration.o(.text); src/slot_machine.o(.text); src/contest_painting.o(.text); - asm/contest_painting.o(.text); src/battle_ai_script_commands.o(.text); src/trader.o(.text); src/starter_choose.o(.text); @@ -511,11 +510,11 @@ SECTIONS { src/menu_helpers.o(.rodata); src/heal_location.o(.rodata); src/region_map.o(.rodata); - data/cute_sketch.o(.rodata); + data/contest_painting_effects.o(.rodata); src/decoration.o(.rodata); src/slot_machine.o(.rodata); data/slot_machine.o(.rodata); - data/contest_painting.o(.rodata); + src/contest_painting.o(.rodata); src/battle_ai_script_commands.o(.rodata); src/trader.o(.rodata); src/starter_choose.o(.rodata); diff --git a/src/battle_anim_8170478.c b/src/battle_anim_8170478.c index 6c91ff934..94f2c95b5 100755 --- a/src/battle_anim_8170478.c +++ b/src/battle_anim_8170478.c @@ -79,9 +79,9 @@ static void sub_817330C(struct Sprite *); struct BallCaptureSuccessStarData { - s8 xOffset; - s8 yOffset; - s8 unk2; + s8 xOffset; + s8 yOffset; + s8 unk2; }; static const struct BallCaptureSuccessStarData sBallCaptureSuccessStarData[] = @@ -478,7 +478,7 @@ static void sub_8170660(u8 taskId) SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG_ALL | WININ_WIN1_OBJ | WININ_WIN1_CLR); SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG_ALL | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR | WINOUT_WINOBJ_BG_ALL | WINOUT_WINOBJ_OBJ | WINOUT_WINOBJ_CLR); if (!IsContest()) - SetAnimBgAttribute(1, BG_ANIM_CHAR_BASE_BLOCK, 0); + SetAnimBgAttribute(1, BG_ANIM_CHAR_BASE_BLOCK, 0); SetGpuReg(REG_OFFSET_DISPCNT, GetGpuReg(REG_OFFSET_DISPCNT) ^ DISPCNT_OBJWIN_ON); SetGpuReg(REG_OFFSET_BLDCNT, 0); @@ -522,9 +522,9 @@ static void sub_8170834(u8 *paletteId1, u8 *paletteId2, u8 battler) void sub_8170920(u8 taskId) { - u8 paletteId1, paletteId2; - sub_8170834(&paletteId1, &paletteId2, gBattleAnimAttacker); - DestroyAnimVisualTask(taskId); + u8 paletteId1, paletteId2; + sub_8170834(&paletteId1, &paletteId2, gBattleAnimAttacker); + DestroyAnimVisualTask(taskId); } static void sub_817094C(u8 battler) @@ -548,8 +548,8 @@ static void sub_817094C(u8 battler) void sub_81709EC(u8 taskId) { - sub_817094C(gBattleAnimAttacker); - DestroyAnimVisualTask(taskId); + sub_817094C(gBattleAnimAttacker); + DestroyAnimVisualTask(taskId); } void sub_8170A0C(u8 taskId) @@ -1162,13 +1162,13 @@ static void sub_81717F8(struct Sprite *sprite) sprite->data[4]++; if (sprite->data[4] == 40) { - PlaySE(SE_RG_GETTING); - BlendPalettes(0x10000 << sprite->oam.paletteNum, 6, RGB(0, 0, 0)); - sub_81719EC(sprite); + PlaySE(SE_RG_GETTING); + BlendPalettes(0x10000 << sprite->oam.paletteNum, 6, RGB(0, 0, 0)); + sub_81719EC(sprite); } else if (sprite->data[4] == 60) { - BeginNormalPaletteFade(0x10000 << sprite->oam.paletteNum, 2, 6, 0, RGB(0, 0, 0)); + BeginNormalPaletteFade(0x10000 << sprite->oam.paletteNum, 2, 6, 0, RGB(0, 0, 0)); } else if (sprite->data[4] == 95) { @@ -1243,41 +1243,41 @@ static void sub_81719C0(struct Sprite *sprite) static void sub_81719EC(struct Sprite *sprite) { - u32 i; - u8 subpriority; + u32 i; + u8 subpriority; if (sprite->subpriority) { - subpriority = sprite->subpriority - 1; + subpriority = sprite->subpriority - 1; } else { - subpriority = 0; - sprite->subpriority = 1; + subpriority = 0; + sprite->subpriority = 1; } sub_8171D60(4); for (i = 0; i < 3; i++) { - u8 spriteId = CreateSprite(&gUnknown_085E51F0[4], sprite->pos1.x, sprite->pos1.y, subpriority); - if (spriteId != MAX_SPRITES) - { - gSprites[spriteId].data[0] = 24; - gSprites[spriteId].data[2] = sprite->pos1.x + sBallCaptureSuccessStarData[i].xOffset; - gSprites[spriteId].data[4] = sprite->pos1.y + sBallCaptureSuccessStarData[i].yOffset; - gSprites[spriteId].data[5] = sBallCaptureSuccessStarData[i].unk2; - InitAnimArcTranslation(&gSprites[spriteId]); - gSprites[spriteId].callback = sub_8171AAC; - StartSpriteAnim(&gSprites[spriteId], gBallOpenParticleAnimNums[4]); - } + u8 spriteId = CreateSprite(&gUnknown_085E51F0[4], sprite->pos1.x, sprite->pos1.y, subpriority); + if (spriteId != MAX_SPRITES) + { + gSprites[spriteId].data[0] = 24; + gSprites[spriteId].data[2] = sprite->pos1.x + sBallCaptureSuccessStarData[i].xOffset; + gSprites[spriteId].data[4] = sprite->pos1.y + sBallCaptureSuccessStarData[i].yOffset; + gSprites[spriteId].data[5] = sBallCaptureSuccessStarData[i].unk2; + InitAnimArcTranslation(&gSprites[spriteId]); + gSprites[spriteId].callback = sub_8171AAC; + StartSpriteAnim(&gSprites[spriteId], gBallOpenParticleAnimNums[4]); + } } } static void sub_8171AAC(struct Sprite *sprite) { - sprite->invisible = !sprite->invisible; - if (TranslateAnimArc(sprite)) - DestroySprite(sprite); + sprite->invisible = !sprite->invisible; + if (TranslateAnimArc(sprite)) + DestroySprite(sprite); } // fakematching. I think the return type of ItemIdToBallId() diff --git a/src/contest_painting.c b/src/contest_painting.c index 7950b7cac..b1b189c09 100644 --- a/src/contest_painting.c +++ b/src/contest_painting.c @@ -1,8 +1,709 @@ #include "global.h" +#include "alloc.h" +#include "battle.h" +#include "bg.h" +#include "contest.h" +#include "contest_painting.h" +#include "contest_painting_effects.h" +#include "battle_gfx_sfx_util.h" +#include "decompress.h" +#include "gpu_regs.h" +#include "international_string_util.h" +#include "main.h" +#include "lilycove_lady.h" +#include "palette.h" +#include "random.h" +#include "scanline_effect.h" +#include "string_util.h" +#include "strings.h" +#include "text.h" +#include "window.h" +#include "constants/rgb.h" + +extern u8 gUnknown_02039F5C; +extern u8 gUnknown_02039F5D; + +extern u16 (*gUnknown_03006190)[][32]; +extern struct ContestWinner *gUnknown_030061C0; +extern u16 *gContestPaintingMonPalette; +extern struct Unk030061A0 gUnknown_030061A0; // IWRAM bss -IWRAM_DATA u8 gUnknown_030011F0; -IWRAM_DATA u16 gUnknown_030011F2; -IWRAM_DATA u16 gUnknown_030011F4; -IWRAM_DATA u8 gUnknown_030011F6; -IWRAM_DATA u8 gUnknown_030011F7; +IWRAM_DATA u8 gContestPaintingState; +IWRAM_DATA u16 gContestPaintingMosaicVal; +IWRAM_DATA u16 gContestPaintingFadeCounter; +IWRAM_DATA bool8 gUnknown_030011F6; +IWRAM_DATA u8 gContestPaintingWindowId; + +static void ShowContestPainting(void); +static void HoldContestPainting(void); +static void InitContestPaintingWindow(void); +static void InitContestPaintingBg(void); +static void InitContestPaintingVars(bool8); +static void sub_8130884(u8, u8); +static void PrintContestPaintingCaption(u8, u8); +static void VBlankCB_ContestPainting(void); +static void sub_8130380(u8 *spritePixels, u16 *palette, u16 (*destColorBuffer)[64][64]); + +extern const u8 gUnknown_0827EA0C[]; +extern const struct CompressedSpriteSheet gMonFrontPicTable[]; +extern const struct CompressedSpriteSheet gMonBackPicTable[]; +extern const u8 gContestCoolness[]; +extern const u8 gContestBeauty[]; +extern const u8 gContestCuteness[]; +extern const u8 gContestSmartness[]; +extern const u8 gContestToughness[]; +extern const u8 gContestRankNormal[]; +extern const u8 gContestRankSuper[]; +extern const u8 gContestRankHyper[]; +extern const u8 gContestRankMaster[]; +extern const u8 gContestLink[]; +extern const u8 gContestPaintingCool1[]; +extern const u8 gContestPaintingCool2[]; +extern const u8 gContestPaintingCool3[]; +extern const u8 gContestPaintingBeauty1[]; +extern const u8 gContestPaintingBeauty2[]; +extern const u8 gContestPaintingBeauty3[]; +extern const u8 gContestPaintingCute1[]; +extern const u8 gContestPaintingCute2[]; +extern const u8 gContestPaintingCute3[]; +extern const u8 gContestPaintingSmart1[]; +extern const u8 gContestPaintingSmart2[]; +extern const u8 gContestPaintingSmart3[]; +extern const u8 gContestPaintingTough1[]; +extern const u8 gContestPaintingTough2[]; +extern const u8 gContestPaintingTough3[]; + +const u16 gPictureFramePalettes[] = INCBIN_U16("graphics/picture_frame/bg.gbapal"); +const u8 gPictureFrameTiles_0[] = INCBIN_U8("graphics/picture_frame/frame0.4bpp.rl"); +const u8 gPictureFrameTiles_1[] = INCBIN_U8("graphics/picture_frame/frame1.4bpp.rl"); +const u8 gPictureFrameTiles_2[] = INCBIN_U8("graphics/picture_frame/frame2.4bpp.rl"); +const u8 gPictureFrameTiles_3[] = INCBIN_U8("graphics/picture_frame/frame3.4bpp.rl"); +const u8 gPictureFrameTiles_4[] = INCBIN_U8("graphics/picture_frame/frame4.4bpp.rl"); +const u8 gPictureFrameTiles_5[] = INCBIN_U8("graphics/picture_frame/frame5.4bpp.rl"); +const u8 gPictureFrameTilemap_0[] = INCBIN_U8("graphics/picture_frame/frame0_map.bin.rl"); +const u8 gPictureFrameTilemap_1[] = INCBIN_U8("graphics/picture_frame/frame1_map.bin.rl"); +const u8 gPictureFrameTilemap_2[] = INCBIN_U8("graphics/picture_frame/frame2_map.bin.rl"); +const u8 gPictureFrameTilemap_3[] = INCBIN_U8("graphics/picture_frame/frame3_map.bin.rl"); +const u8 gPictureFrameTilemap_4[] = INCBIN_U8("graphics/picture_frame/frame4_map.bin.rl"); +const u8 gPictureFrameTilemap_5[] = INCBIN_U8("graphics/picture_frame/frame5_map.bin.rl"); + +const u8 *const gUnknown_085B07C0[] = +{ + gContestCoolness, + gContestBeauty, + gContestCuteness, + gContestSmartness, + gContestToughness, +}; + +const u8 *const gContestRankTextPointers[] = +{ + gContestRankNormal, + gContestRankSuper, + gContestRankHyper, + gContestRankMaster, + gContestLink, +}; + +const struct BgTemplate gUnknown_085B07E8[] = +{ + { + .bg = 1, + .charBaseIndex = 1, + .mapBaseIndex = 10, + .screenSize = 0, + .paletteMode = 0, + .priority = 1, + .baseTile = 0, + }, +}; + +const struct WindowTemplate gUnknown_085B07EC = +{ + .bg = 1, + .tilemapLeft = 2, + .tilemapTop = 14, + .width = 26, + .height = 4, + .paletteNum = 15, + .baseBlock = 1, +}; + +const u8 *const gContestPaintingDescriptionPointers[] = +{ + gContestPaintingCool1, + gContestPaintingCool2, + gContestPaintingCool3, + gContestPaintingBeauty1, + gContestPaintingBeauty2, + gContestPaintingBeauty3, + gContestPaintingCute1, + gContestPaintingCute2, + gContestPaintingCute3, + gContestPaintingSmart1, + gContestPaintingSmart2, + gContestPaintingSmart3, + gContestPaintingTough1, + gContestPaintingTough2, + gContestPaintingTough3, +}; + +const struct OamData gUnknown_085B0830 = +{ + .y = 0, + .affineMode = ST_OAM_AFFINE_OFF, + .objMode = ST_OAM_OBJ_NORMAL, + .mosaic = 1, + .bpp = ST_OAM_8BPP, + .shape = ST_OAM_SQUARE, + .x = 0, + .matrixNum = 0, + .size = 3, + .tileNum = 0, + .priority = 0, + .paletteNum = 0, + .affineParam = 0, +}; + +const u16 gUnknown_085B0838[] = {RGB(0, 0, 0), RGB(0, 0, 0)}; + +void sub_812FDA8(int contestWinner) +{ + // probably fakematching + u8 *ptr1 = &gUnknown_02039F5D; + u8 *ptr2 = &gUnknown_02039F5C; + gUnknown_02039F3C = gSaveBlock1Ptr->contestWinners[contestWinner - 1]; + *ptr1 = contestWinner - 1; + *ptr2 = 0; +} + +void CB2_ContestPainting(void) +{ + ShowContestPainting(); +} + +static void CB2_HoldContestPainting(void) +{ + HoldContestPainting(); + RunTextPrinters(); + UpdatePaletteFade(); +} + +static void CB2_QuitContestPainting(void) +{ + SetMainCallback2(gMain.savedCallback); + FREE_AND_SET_NULL(gContestPaintingMonPalette); + FREE_AND_SET_NULL(gUnknown_03006190); + RemoveWindow(gContestPaintingWindowId); + Free(GetBgTilemapBuffer(1)); + FreeMonSpritesGfx(); +} + +static void ShowContestPainting(void) +{ + switch (gMain.state) + { + case 0: + ScanlineEffect_Stop(); + SetVBlankCallback(NULL); + AllocateMonSpritesGfx(); + gUnknown_030061C0 = &gUnknown_02039F3C; + InitContestPaintingVars(1); + InitContestPaintingBg(); + gMain.state++; + break; + case 1: + ResetPaletteFade(); + DmaFillLarge32(3, 0, (void *)BG_VRAM, 0x18000, 0x1000); + ResetSpriteData(); + gMain.state++; + break; + case 2: + SeedRng(gMain.vblankCounter1); + InitKeys(); + InitContestPaintingWindow(); + gMain.state++; + break; + case 3: + sub_8130884(gUnknown_02039F5D, gUnknown_02039F5C); + gMain.state++; + break; + case 4: + PrintContestPaintingCaption(gUnknown_02039F5D, gUnknown_02039F5C); + LoadPalette(gUnknown_085B0838, 0, 1 * 2); + DmaClear32(3, PLTT, PLTT_SIZE); + BeginFastPaletteFade(2); + SetVBlankCallback(VBlankCB_ContestPainting); + gContestPaintingState = 0; + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG1_ON | DISPCNT_OBJ_ON); + SetMainCallback2(CB2_HoldContestPainting); + break; + } +} + +static void HoldContestPainting(void) +{ + switch (gContestPaintingState) + { + case 0: + if (!gPaletteFade.active) + gContestPaintingState = 1; + if (gUnknown_030011F6 && gContestPaintingFadeCounter) + gContestPaintingFadeCounter--; + break; + case 1: + if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) + { + u8 two = 2; //needed to make the asm match + gContestPaintingState = two; + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB(0, 0, 0)); + } + + if (gUnknown_030011F6) + gContestPaintingFadeCounter = 0; + break; + case 2: + if (!gPaletteFade.active) + SetMainCallback2(CB2_QuitContestPainting); + if (gUnknown_030011F6 && gContestPaintingFadeCounter < 30) + gContestPaintingFadeCounter++; + break; + } +} + +static void InitContestPaintingWindow(void) +{ + ResetBgsAndClearDma3BusyFlags(0); + InitBgsFromTemplates(0, gUnknown_085B07E8, ARRAY_COUNT(gUnknown_085B07E8)); + ChangeBgX(1, 0, 0); + ChangeBgY(1, 0, 0); + SetBgTilemapBuffer(1, AllocZeroed(BG_SCREEN_SIZE)); + gContestPaintingWindowId = AddWindow(&gUnknown_085B07EC); + DeactivateAllTextPrinters(); + FillWindowPixelBuffer(gContestPaintingWindowId, 0); + PutWindowTilemap(gContestPaintingWindowId); + CopyWindowToVram(gContestPaintingWindowId, 3); + ShowBg(1); +} + +static void PrintContestPaintingCaption(u8 contestType, u8 arg1) +{ + int x; + u8 category; + + if (arg1 == TRUE) + return; + + category = gUnknown_030061C0->contestCategory; + if (contestType < 8) + { + sub_818E868(gStringVar1, category); + StringAppend(gStringVar1, gText_Space); + StringAppend(gStringVar1, gContestRankTextPointers[gUnknown_030061C0->contestRank]); + StringCopy(gStringVar2, gUnknown_030061C0->trainerName); + sub_81DB5AC(gStringVar2); + StringCopy(gStringVar3, gUnknown_030061C0->monName); + StringExpandPlaceholders(gStringVar4, gUnknown_0827EA0C); + } + else + { + StringCopy(gStringVar1, gUnknown_030061C0->monName); + StringExpandPlaceholders(gStringVar4, gContestPaintingDescriptionPointers[category]); + } + + x = GetStringCenterAlignXOffset(1, gStringVar4, 208); + AddTextPrinterParameterized(gContestPaintingWindowId, 1, gStringVar4, x, 1, 0, 0); + CopyBgTilemapBufferToVram(1); +} + +static void InitContestPaintingBg(void) +{ + SetGpuReg(REG_OFFSET_DISPCNT, 0); + REG_IE |= INTR_FLAG_VBLANK; + SetGpuReg(REG_OFFSET_BG0CNT, BGCNT_PRIORITY(2) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(12) | BGCNT_MOSAIC | BGCNT_16COLOR | BGCNT_TXT256x256); + SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(1) | BGCNT_CHARBASE(1) | BGCNT_SCREENBASE(10) | BGCNT_MOSAIC | BGCNT_16COLOR | BGCNT_TXT256x256); + SetGpuReg(REG_OFFSET_BLDCNT, 0); + SetGpuReg(REG_OFFSET_BLDALPHA, 0); + SetGpuReg(REG_OFFSET_BLDY, 0); +} + +static void InitContestPaintingVars(bool8 arg0) +{ + if (arg0 == FALSE) + { + gUnknown_030011F6 = FALSE; + gContestPaintingMosaicVal = 0; + gContestPaintingFadeCounter = 0; + } + else + { + gUnknown_030011F6 = TRUE; + gContestPaintingMosaicVal = 15; + gContestPaintingFadeCounter = 30; + } +} + +static void UpdateContestPaitingMosaicEffect(void) +{ + if (!gUnknown_030011F6) + { + SetGpuReg(REG_OFFSET_MOSAIC, 0); + } + else + { + SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(1) | BGCNT_CHARBASE(1) | BGCNT_SCREENBASE(10) | BGCNT_MOSAIC | BGCNT_16COLOR | BGCNT_TXT256x256); + gContestPaintingMosaicVal = gContestPaintingFadeCounter / 2; + SetGpuReg(REG_OFFSET_MOSAIC, (gContestPaintingMosaicVal << 12) | (gContestPaintingMosaicVal << 8) | (gContestPaintingMosaicVal << 4) | (gContestPaintingMosaicVal << 0)); + } +} + +static void VBlankCB_ContestPainting(void) +{ + UpdateContestPaitingMosaicEffect(); + LoadOam(); + ProcessSpriteCopyRequests(); + TransferPlttBuffer(); +} + +void sub_81302E8(u16 species, u8 arg1) +{ + const void *pal = GetFrontSpritePalFromSpeciesAndPersonality(species, gUnknown_030061C0->trainerId, gUnknown_030061C0->personality); + LZDecompressVram(pal, gContestPaintingMonPalette); + if (!arg1) + { + HandleLoadSpecialPokePic_DontHandleDeoxys( + &gMonFrontPicTable[species], + gMonSpritesGfxPtr->sprites[1], + species, + gUnknown_030061C0->personality); + sub_8130380(gMonSpritesGfxPtr->sprites[1], gContestPaintingMonPalette, (void *)gUnknown_03006190); + } + else + { + HandleLoadSpecialPokePic_DontHandleDeoxys( + &gMonBackPicTable[species], + gMonSpritesGfxPtr->sprites[0], + species, + gUnknown_030061C0->personality); + sub_8130380(gMonSpritesGfxPtr->sprites[0], gContestPaintingMonPalette, (void *)gUnknown_03006190); + } +} + +#ifdef NONMATCHING +// functionally equivalent. +static void sub_8130380(u8 *spritePixels, u16 *palette, u16 (*destColorBuffer)[64][64]) +{ + u16 tileY, tileX, pixelY, pixelX; + u8 colorIndex; + + for (tileY = 0; tileY < 8; tileY++) + { + for (tileX = 0; tileX < 8; tileX++) + { + for (pixelY = 0; pixelY < 8; pixelY++) + { + for (pixelX = 0; pixelX < 8; pixelX++) + { + int offset = 32 * (8 * tileY + tileX) + (pixelY * 4 + pixelX / 2); + colorIndex = spritePixels[offset]; + if (pixelX & 1) + colorIndex >>= 4; + else + colorIndex &= 0xF; + + if (colorIndex == 0) // transparent pixel + (*destColorBuffer)[8 * tileY + pixelY][tileX * 8 + pixelX] = 0x8000; + else + (*destColorBuffer)[8 * tileY + pixelY][tileX * 8 + pixelX] = palette[colorIndex]; + } + } + } + } +} +#else +NAKED +static void sub_8130380(u8 *spritePixels, u16 *palette, u16 (*destColorBuffer)[64][64]) +{ + 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\ + mov r10, r0\n\ + mov r9, r1\n\ + str r2, [sp]\n\ + movs r0, 0\n\ +_08130394:\n\ + movs r3, 0\n\ + adds r1, r0, 0x1\n\ + str r1, [sp, 0x4]\n\ + lsls r0, 3\n\ + str r0, [sp, 0x8]\n\ +_0813039E:\n\ + movs r1, 0\n\ + adds r2, r3, 0x1\n\ + mov r8, r2\n\ + ldr r7, [sp, 0x8]\n\ + adds r0, r7, r3\n\ + lsls r0, 5\n\ + mov r12, r0\n\ + lsls r4, r3, 3\n\ +_081303AE:\n\ + movs r3, 0\n\ + lsls r0, r1, 2\n\ + adds r6, r1, 0x1\n\ + mov r2, r12\n\ + adds r5, r2, r0\n\ + ldr r7, [sp, 0x8]\n\ + adds r0, r7, r1\n\ + lsls r0, 7\n\ + ldr r1, [sp]\n\ + adds r2, r0, r1\n\ +_081303C2:\n\ + lsrs r0, r3, 1\n\ + adds r0, r5, r0\n\ + add r0, r10\n\ + ldrb r1, [r0]\n\ + movs r0, 0x1\n\ + ands r0, r3\n\ + cmp r0, 0\n\ + beq _081303D6\n\ + lsrs r1, 4\n\ + b _081303DA\n\ +_081303D6:\n\ + movs r0, 0xF\n\ + ands r1, r0\n\ +_081303DA:\n\ + cmp r1, 0\n\ + bne _081303EC\n\ + adds r0, r4, r3\n\ + lsls r0, 1\n\ + adds r0, r2\n\ + movs r7, 0x80\n\ + lsls r7, 8\n\ + adds r1, r7, 0\n\ + b _081303F8\n\ +_081303EC:\n\ + adds r0, r4, r3\n\ + lsls r0, 1\n\ + adds r0, r2\n\ + lsls r1, 1\n\ + add r1, r9\n\ + ldrh r1, [r1]\n\ +_081303F8:\n\ + strh r1, [r0]\n\ + adds r0, r3, 0x1\n\ + lsls r0, 16\n\ + lsrs r3, r0, 16\n\ + cmp r3, 0x7\n\ + bls _081303C2\n\ + lsls r0, r6, 16\n\ + lsrs r1, r0, 16\n\ + cmp r1, 0x7\n\ + bls _081303AE\n\ + mov r1, r8\n\ + lsls r0, r1, 16\n\ + lsrs r3, r0, 16\n\ + cmp r3, 0x7\n\ + bls _0813039E\n\ + ldr r2, [sp, 0x4]\n\ + lsls r0, r2, 16\n\ + lsrs r0, 16\n\ + cmp r0, 0x7\n\ + bls _08130394\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"); +} +#endif + +static void sub_8130430(u8 arg0, u8 arg1) +{ + u8 x, y; + + LoadPalette(gPictureFramePalettes, 0, 0x100); + if (arg1 == 1) + { + switch (gUnknown_030061C0->contestCategory / 3) + { + case CONTEST_CATEGORY_COOL: + RLUnCompVram(gPictureFrameTiles_0, (void *)VRAM); + RLUnCompWram(gPictureFrameTilemap_0, gUnknown_03006190); + break; + case CONTEST_CATEGORY_BEAUTY: + RLUnCompVram(gPictureFrameTiles_1, (void *)VRAM); + RLUnCompWram(gPictureFrameTilemap_1, gUnknown_03006190); + break; + case CONTEST_CATEGORY_CUTE: + RLUnCompVram(gPictureFrameTiles_2, (void *)VRAM); + RLUnCompWram(gPictureFrameTilemap_2, gUnknown_03006190); + break; + case CONTEST_CATEGORY_SMART: + RLUnCompVram(gPictureFrameTiles_3, (void *)VRAM); + RLUnCompWram(gPictureFrameTilemap_3, gUnknown_03006190); + break; + case CONTEST_CATEGORY_TOUGH: + RLUnCompVram(gPictureFrameTiles_4, (void *)VRAM); + RLUnCompWram(gPictureFrameTilemap_4, gUnknown_03006190); + break; + } + +#define VRAM_PICTURE_DATA(x, y) (((u16 *)(VRAM + 0x6000))[(y) * 32 + (x)]) + + // Set the background + for (y = 0; y < 20; y++) + { + for (x = 0; x < 32; x++) + VRAM_PICTURE_DATA(x, y) = 0x1015; + } + + // Copy the image frame + for (y = 0; y < 10; y++) + { + for (x = 0; x < 18; x++) + VRAM_PICTURE_DATA(x + 6, y + 2) = (*gUnknown_03006190)[y + 2][x + 6]; + } + + // Re-set the entire top row to the first top frame part + for (x = 0; x < 16; x++) + VRAM_PICTURE_DATA(x + 7, 2) = (*gUnknown_03006190)[2][7]; + +#undef VRAM_PICTURE_DATA + } + else if (arg0 < 8) + { + RLUnCompVram(gPictureFrameTiles_5, (void *)VRAM); + RLUnCompVram(gPictureFrameTilemap_5, (void *)(VRAM + 0x6000)); + } + else + { + switch (gUnknown_030061C0->contestCategory / 3) + { + case CONTEST_CATEGORY_COOL: + RLUnCompVram(gPictureFrameTiles_0, (void *)VRAM); + RLUnCompVram(gPictureFrameTilemap_0, (void *)(VRAM + 0x6000)); + break; + case CONTEST_CATEGORY_BEAUTY: + RLUnCompVram(gPictureFrameTiles_1, (void *)VRAM); + RLUnCompVram(gPictureFrameTilemap_1, (void *)(VRAM + 0x6000)); + break; + case CONTEST_CATEGORY_CUTE: + RLUnCompVram(gPictureFrameTiles_2, (void *)VRAM); + RLUnCompVram(gPictureFrameTilemap_2, (void *)(VRAM + 0x6000)); + break; + case CONTEST_CATEGORY_SMART: + RLUnCompVram(gPictureFrameTiles_3, (void *)VRAM); + RLUnCompVram(gPictureFrameTilemap_3, (void *)(VRAM + 0x6000)); + break; + case CONTEST_CATEGORY_TOUGH: + RLUnCompVram(gPictureFrameTiles_4, (void *)VRAM); + RLUnCompVram(gPictureFrameTilemap_4, (void *)(VRAM + 0x6000)); + break; + } + } +} + +static void sub_8130688(u8 arg0) +{ + //Some hacks just to get the asm to match +#ifndef NONMATCHING + asm(""::"r"(arg0)); +#endif + + gMain.oamBuffer[0] = gUnknown_085B0830; + gMain.oamBuffer[0].tileNum = 0; + +#ifndef NONMATCHING + if (arg0) arg0 = gMain.oamBuffer[0].tileNum; +#endif + + gMain.oamBuffer[0].x = 88; + gMain.oamBuffer[0].y = 24; +} + +static u8 sub_81306CC(u8 arg0) +{ + u8 contestCategory; + + if (arg0 < 8) + contestCategory = gUnknown_030061C0->contestCategory; + else + contestCategory = gUnknown_030061C0->contestCategory / 3; + + switch (contestCategory) + { + case CONTEST_CATEGORY_COOL: + return CONTESTRESULT_COOL; + case CONTEST_CATEGORY_BEAUTY: + return CONTESTRESULT_BEAUTY; + case CONTEST_CATEGORY_CUTE: + return CONTESTRESULT_CUTE; + case CONTEST_CATEGORY_SMART: + return CONTESTRESULT_SMART; + case CONTEST_CATEGORY_TOUGH: + return CONTESTRESULT_TOUGH; + } + + return contestCategory; +} + +static void sub_8130738(void) +{ + gContestPaintingMonPalette = AllocZeroed(0x200); + gUnknown_03006190 = AllocZeroed(0x2000); +} + +static void sub_8130760(u8 contestResult) +{ + gUnknown_030061A0.var_4 = gUnknown_03006190; + gUnknown_030061A0.var_8 = gContestPaintingMonPalette; + gUnknown_030061A0.var_18 = 0; + gUnknown_030061A0.var_1F = gUnknown_030061C0->personality % 256; + gUnknown_030061A0.var_19 = 0; + gUnknown_030061A0.var_1A = 0; + gUnknown_030061A0.var_1B = 64; + gUnknown_030061A0.var_1C = 64; + gUnknown_030061A0.var_1D = 64; + gUnknown_030061A0.var_1E = 64; + + switch (contestResult) + { + case CONTESTRESULT_SMART: + case CONTESTRESULT_TOUGH: + gUnknown_030061A0.var_14 = 3; + break; + case CONTESTRESULT_COOL: + case CONTESTRESULT_BEAUTY: + case CONTESTRESULT_CUTE: + default: + gUnknown_030061A0.var_14 = 1; + break; + } + + gUnknown_030061A0.var_16 = 2; + gUnknown_030061A0.var_0 = contestResult; + gUnknown_030061A0.var_10 = 0x6010000; + + sub_8124F2C(&gUnknown_030061A0); + sub_81261A4(&gUnknown_030061A0); + sub_8126058(&gUnknown_030061A0); + + LoadPalette(gContestPaintingMonPalette, 0x100, 0x200); +} + +static void sub_8130884(u8 arg0, u8 arg1) +{ + sub_8130738(); + sub_81302E8(gUnknown_030061C0->species, 0); + sub_8130760(sub_81306CC(arg0)); + sub_8130688(arg0); + sub_8130430(arg0, arg1); +} diff --git a/src/script_pokemon_util_80F87D8.c b/src/script_pokemon_util_80F87D8.c index 7fc61f953..f2d5b5cb6 100755 --- a/src/script_pokemon_util_80F87D8.c +++ b/src/script_pokemon_util_80F87D8.c @@ -220,7 +220,7 @@ static void ShowContestWinnerCleanup(void) void ShowContestWinner(void) { - SetMainCallback2(sub_812FDEC); + SetMainCallback2(CB2_ContestPainting); gMain.savedCallback = ShowContestWinnerCleanup; } diff --git a/sym_common.txt b/sym_common.txt index bb84ec06e..3a7d698fd 100644 --- a/sym_common.txt +++ b/sym_common.txt @@ -63,7 +63,7 @@ gUnknown_030061A0: @ 30061A0 gUnknown_030061C0: @ 30061C0 .space 0x4 -gUnknown_030061C4: @ 30061C4 +gContestPaintingMonPalette: @ 30061C4 .space 0xC .include "field_specials.o"