From b7cfa9d36537b8ae53012eb88d59f8b842fb35c4 Mon Sep 17 00:00:00 2001 From: Phlosioneer Date: Fri, 8 Mar 2019 21:39:51 -0500 Subject: [PATCH] Move more contest constants into C --- data/contest.s | 138 ------------------- include/graphics.h | 8 ++ include/sprite.h | 20 +++ ld_script.txt | 1 + src/contest.c | 337 +++++++++++++++++++++++++++++++++++++++++++-- 5 files changed, 351 insertions(+), 153 deletions(-) diff --git a/data/contest.s b/data/contest.s index 48bfa1080..a0aaa62f2 100644 --- a/data/contest.s +++ b/data/contest.s @@ -6,144 +6,6 @@ .section .rodata .align 2, 0 -gUnknown_08587A6C:: @ 8587A6C - .byte 0x24, 0x4c, 0x74, 0x9c - -gUnknown_08587A70:: @ 8587A70 - .byte 0x24, 0x4c, 0x74, 0x9c - - .align 2 -gUnknown_08587A74:: @ 8587A74 - obj_tiles gTiles_8C19450, 0x0020, 0x4e20 - - .align 2 -gOamData_8587A7C:: @ 8587A7C - .2byte 0x0000 - .2byte 0x0000 - .2byte 0x0000 - - .align 2 -gSpriteAffineAnim_8587A84:: @ 8587A84 - obj_rot_scal_anim_frame 0x100, 0x100, 0, 0 - obj_rot_scal_anim_end - - .align 2 -gSpriteAffineAnim_8587A94:: @ 8587A94 - obj_rot_scal_anim_frame 0x100, 0x100, 0, 0 - obj_rot_scal_anim_frame 0xFFF6, 0xFFF6, -20, 20 - obj_rot_scal_anim_end - - .align 2 -gSpriteAffineAnim_8587AAC:: @ 8587AAC - obj_rot_scal_anim_frame 0x38, 0x38, 0, 0 - obj_rot_scal_anim_frame 0xA, 0xA, 20, 20 - obj_rot_scal_anim_end - - .align 2 -gSpriteAffineAnimTable_8587AC4:: @ 8587AC4 - .4byte gSpriteAffineAnim_8587A84 - .4byte gSpriteAffineAnim_8587A94 - .4byte gSpriteAffineAnim_8587AAC - - .align 2 -gSpriteTemplate_8587AD0:: @ 8587AD0 - spr_template 0x4e20, 0xabe0, gOamData_8587A7C, gDummySpriteAnimTable, NULL, gSpriteAffineAnimTable_8587AC4, SpriteCallbackDummy - - .align 2 -gUnknown_08587AE8:: @ 8587AE8 - obj_tiles gContestNextTurnGfx, 0x0100, 0x4e22 - obj_tiles gContestNextTurnGfx, 0x0100, 0x4e23 - obj_tiles gContestNextTurnGfx, 0x0100, 0x4e24 - obj_tiles gContestNextTurnGfx, 0x0100, 0x4e25 - - .align 2 -gUnknown_08587B08:: @ 8587B08 - obj_pal gContestPal, 0x4e22 - - .align 2 -gOamData_8587B10:: @ 8587B10 - .2byte 0x4000 - .2byte 0x4000 - .2byte 0x0000 - - .align 2 -gSpriteTemplate_8587B18:: @ 8587B18 - spr_template 0x4e22, 0x4e22, gOamData_8587B10, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy - spr_template 0x4e23, 0x4e22, gOamData_8587B10, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy - spr_template 0x4e24, 0x4e22, gOamData_8587B10, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy - spr_template 0x4e25, 0x4e22, gOamData_8587B10, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy - - .align 2 -gSubspriteTable_8587B78:: @ 8587B78 - subsprite -28, -4, 0, 0, 32x8 - subsprite 4, -4, 0, 4, 32x8 - - .align 2 -gSubspriteTables_8587B80:: @ 8587B80 - .4byte 2, gSubspriteTable_8587B78 - - .align 2 -gUnknown_08587B88:: @ 8587B88 - obj_tiles gUnknown_08C19168, 0x0180, 0xabe1 - - .align 2 -gOamData_8587B90:: @ 8587B90 - .2byte 0x0000 - .2byte 0x4000 - .2byte 0x0000 - - .align 2 -gSpriteTemplate_8587B98:: @ 8587B98 - spr_template 0xabe1, 0xabe0, gOamData_8587B90, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy - - .align 2 -gUnknown_08587BB0:: @ 8587BB0 - obj_tiles gContestApplauseGfx, 0x0400, 0xabe2 - - .align 2 -gUnknown_08587BB8:: @ 8587BB8 - obj_pal gContestPal, 0xabe2 - - .align 2 -gOamData_8587BC0:: @ 8587BC0 - .2byte 0x4000 - .2byte 0xC000 - .2byte 0x0000 - - .align 2 -gSpriteTemplate_8587BC8:: @ 8587BC8 - spr_template 0xabe2, 0xabe2, gOamData_8587BC0, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy - - .align 2 -gOamData_8587BE0:: @ 8587BE0 - .2byte 0x0000 - .2byte 0xC000 - .2byte 0x2C00 - - .align 2 -gSpriteTemplate_8587BE8:: @ 8587BE8 - spr_template 0x4e21, 0x4e21, gOamData_8587BE0, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy - - .align 2 -gUnknown_08587C00:: @ 8587C00 - obj_tiles gContestJudgeGfx, 0x0800, 0x4e21 - - .align 2 -gUnknown_08587C08:: @ 8587C08 - obj_tiles gContestJudgeSymbolsGfx, 0x0380, 0xabe0 - - .align 2 -gUnknown_08587C10:: @ 8587C10 - obj_pal gContest3Pal, 0xabe0 - - .align 2 -gSpriteTemplate_8587C18:: @ 8587C18 - spr_template 0xabe0, 0xabe0, gUnknown_0852490C, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy - - .align 2 -gUnknown_08587C30:: @ 8587C30 - .incbin "graphics/unknown/unknown_587C30.gbapal" - @ 8587C50 .include "data/text/contest_text_pointers.inc" diff --git a/include/graphics.h b/include/graphics.h index c651268ca..063f71ee5 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -4765,6 +4765,14 @@ extern const u32 gUnknown_08C16FA8[]; extern const u32 gUnknown_08C16E90[]; extern const u32 gUnknown_08C17170[]; extern const u32 gUnknown_08C17980[]; +extern const u32 gTiles_8C19450[]; +extern const u32 gContestNextTurnGfx[]; +extern const u16 gContestPal[]; +extern const u32 gUnknown_08C19168[]; +extern const u32 gContestApplauseGfx[]; +extern const u32 gContestJudgeGfx[]; +extern const u32 gContestJudgeSymbolsGfx[]; +extern const u32 gContest3Pal[]; extern const u32 gUnknown_08D95E00[]; extern const u32 gUnknown_08D960D0[]; diff --git a/include/sprite.h b/include/sprite.h index 32bdd9c55..10c4145b0 100644 --- a/include/sprite.h +++ b/include/sprite.h @@ -151,6 +151,26 @@ enum SUBSPRITES_IGNORE_PRIORITY, // on but priority is ignored }; +#define OAM_SIZE_0 (0) +#define OAM_SIZE_1 (1 << 0) +#define OAM_SIZE_2 (1 << 1) +#define OAM_SIZE_3 (1 << 2) + +#define SPRITE_SIZE_8x8 .shape = ST_OAM_SQUARE, .size = OAM_SIZE_0 +#define SPRITE_SIZE_16x16 .shape = ST_OAM_SQUARE, .size = OAM_SIZE_1 +#define SPRITE_SIZE_32x32 .shape = ST_OAM_SQUARE, .size = OAM_SIZE_2 +#define SPRITE_SIZE_64x64 .shape = ST_OAM_SQUARE, .size = OAM_SIZE_3 + +#define SPRITE_SIZE_16x8 .shape = ST_OAM_H_RECTANGLE, .size = OAM_SIZE_0 +#define SPRITE_SIZE_32x8 .shape = ST_OAM_H_RECTANGLE, .size = OAM_SIZE_1 +#define SPRITE_SIZE_32x16 .shape = ST_OAM_H_RECTANGLE, .size = OAM_SIZE_2 +#define SPRITE_SIZE_64x32 .shape = ST_OAM_H_RECTANGLE, .size = OAM_SIZE_3 + +#define SPRITE_SIZE_8x16 .shape = ST_OAM_V_RECTANGLE, .size = OAM_SIZE_0 +#define SPRITE_SIZE_8x32 .shape = ST_OAM_V_RECTANGLE, .size = OAM_SIZE_1 +#define SPRITE_SIZE_16x32 .shape = ST_OAM_V_RECTANGLE, .size = OAM_SIZE_2 +#define SPRITE_SIZE_32x64 .shape = ST_OAM_V_RECTANGLE, .size = OAM_SIZE_3 + struct Subsprite { s8 x; // was u16 in R/S diff --git a/ld_script.txt b/ld_script.txt index e60badcc2..b87bb34f3 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -461,6 +461,7 @@ SECTIONS { src/item_menu_icons.o(.rodata); src/battle_anim_80D51AC.o(.rodata); src/item.o(.rodata); + src/contest.o(.rodata); data/contest.o(.rodata); src/shop.o(.rodata); src/fldeff_escalator.o(.rodata); diff --git a/src/contest.c b/src/contest.c index 114a1fb69..241d38e48 100644 --- a/src/contest.c +++ b/src/contest.c @@ -218,7 +218,6 @@ EWRAM_DATA u8 gUnknown_02039F5D = 0; // IWRAM common vars. u32 gContestRngValue; -extern const u16 gUnknown_08587C30[]; extern const struct BgTemplate gUnknown_08587F34[4]; extern const struct WindowTemplate gUnknown_08587F44[]; extern const u8 *const gUnknown_08587D90[]; @@ -250,25 +249,11 @@ extern const u8 gText_CDot[]; extern const u8 *const gUnknown_08587E10[]; extern const struct ContestPokemon gContestOpponents[96]; extern const u8 gUnknown_085898A4[96]; -extern const struct CompressedSpriteSheet gUnknown_08587C00; -extern const struct SpriteTemplate gSpriteTemplate_8587BE8; -extern const struct CompressedSpriteSheet gUnknown_08587C08; -extern const struct CompressedSpritePalette gUnknown_08587C10; -extern const struct SpriteTemplate gSpriteTemplate_8587C18; extern const union AffineAnimCmd *const gUnknown_082FF6C0[]; extern const union AffineAnimCmd *const gUnknown_082FF694[]; extern const u8 *const gContestEffectDescriptionPointers[]; -extern const struct SpriteSheet gUnknown_08587A74; -extern const u8 gUnknown_08587A6C[]; extern const struct SpriteTemplate gSpriteTemplate_8587AD0; -extern const struct SpritePalette gUnknown_08587B08; -extern const struct CompressedSpriteSheet gUnknown_08587AE8[]; extern const struct SpriteTemplate gSpriteTemplate_8587B18[]; -extern const u8 gUnknown_08587A70[]; -extern const struct SubspriteTable gSubspriteTables_8587B80[]; -extern const struct CompressedSpriteSheet gUnknown_08587BB0; -extern const struct SpritePalette gUnknown_08587BB8; -extern const struct SpriteTemplate gSpriteTemplate_8587BC8; extern void (*const gContestEffectFuncs[])(void); extern const s8 gContestExcitementTable[][5]; extern const struct ContestWinner gUnknown_08587FA4[]; @@ -276,6 +261,328 @@ extern const struct CompressedSpriteSheet gUnknown_08589904[]; extern const struct SpritePalette gUnknown_08589924[]; extern const struct SpriteTemplate gSpriteTemplate_858998C[]; +static const u8 gUnknown_08587A6C[] = +{ + 0x24, 0x4C, 0x74, 0x9C +}; + +static const u8 gUnknown_08587A70[] = +{ + 0x24, 0x4C, 0x74, 0x9C +}; + +static const struct SpriteSheet gUnknown_08587A74 = +{ + .data = gTiles_8C19450, + .size = 0x20, + .tag = 0x4E20 +}; + +static const struct OamData gOamData_8587A7C = +{ + .y = 0, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 0, + .tileNum = 0, + .priority = 0, + .paletteNum = 0, + .affineParam = 0 +}; + +static const union AffineAnimCmd gSpriteAffineAnim_8587A84[] = +{ + AFFINEANIMCMD_FRAME(0x100, 0x100, 0, 0), + AFFINEANIMCMD_END, +}; + +static const union AffineAnimCmd gSpriteAffineAnim_8587A94[] = +{ + AFFINEANIMCMD_FRAME(0x100, 0x100, 0, 0), + AFFINEANIMCMD_FRAME(0xFFF6, 0xFFF6, -20, 20), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd gSpriteAffineAnim_8587AAC[] = +{ + AFFINEANIMCMD_FRAME(0x38, 0x38, 0, 0), + AFFINEANIMCMD_FRAME(10, 10, 20, 20), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd* const gSpriteAffineAnimTable_8587AC4[] = +{ + gSpriteAffineAnim_8587A84, + gSpriteAffineAnim_8587A94, + gSpriteAffineAnim_8587AAC +}; + +static const struct SpriteTemplate gSpriteTemplate_8587AD0 = +{ + .tileTag = 0x4E20, + .paletteTag = 0xABE0, + .oam = &gOamData_8587A7C, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gSpriteAffineAnimTable_8587AC4, + .callback = SpriteCallbackDummy +}; + +static const struct CompressedSpriteSheet gUnknown_08587AE8[] = +{ + { + .data = gContestNextTurnGfx, + .size = 0x100, + .tag = 0x4E22 + }, + { + .data = gContestNextTurnGfx, + .size = 0x100, + .tag = 0x4E23 + }, + { + .data = gContestNextTurnGfx, + .size = 0x100, + .tag = 0x4E24 + }, + { + .data = gContestNextTurnGfx, + .size = 0x100, + .tag = 0x4E25 + } +}; + +static const struct SpritePalette gUnknown_08587B08 = +{ + .data = gContestPal, + .tag = 0x4E22 +}; + +static const struct OamData gOamData_8587B10 = +{ + .y = 0, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 1, + .x = 0, + .matrixNum = 0, + .size = 1, + .tileNum = 0, + .priority = 0, + .paletteNum = 0, + .affineParam = 0 +}; + +static const struct SpriteTemplate gSpriteTemplate_8587B18[] = +{ + { + .tileTag = 0x4E22, + .paletteTag = 0x4E22, + .oam = &gOamData_8587B10, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, + }, + { + .tileTag = 0x4E23, + .paletteTag = 0x4E22, + .oam = &gOamData_8587B10, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, + }, + { + .tileTag = 0x4E24, + .paletteTag = 0x4E22, + .oam = &gOamData_8587B10, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, + }, + { + .tileTag = 0x4E25, + .paletteTag = 0x4E22, + .oam = &gOamData_8587B10, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, + } +}; + +const struct Subsprite gSubspriteTable_8587B78[] = +{ + { + .x = -28, + .y = -4, + SPRITE_SIZE_32x8, + .tileOffset = 0, + .priority = 0 + }, + { + .x = 4, + .y = -4, + SPRITE_SIZE_32x8, + .tileOffset = 4, + .priority = 0 + } +}; + +const struct SubspriteTable gSubspriteTables_8587B80[] = +{ + { + .subspriteCount = 2, + .subsprites = gSubspriteTable_8587B78 + } +}; + +const struct CompressedSpriteSheet gUnknown_08587B88 = +{ + .data = gUnknown_08C19168, + .size = 0x180, + .tag = 0xABE1 +}; + +const struct OamData gOamData_8587B90 = +{ + .y = 0, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 1, + .tileNum = 0, + .priority = 0, + .paletteNum = 0, + .affineParam = 0 +}; + +const struct SpriteTemplate gSpriteTemplate_8587B98 = +{ + .tileTag = 0xABE1, + .paletteTag = 0xABE0, + .oam = &gOamData_8587B90, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy +}; + +const struct CompressedSpriteSheet gUnknown_08587BB0 = +{ + .data = gContestApplauseGfx, + .size = 0x400, + .tag = 0xABE2 +}; + +const struct SpritePalette gUnknown_08587BB8 = +{ + .data = gContestPal, + .tag = 0xABE2 +}; + +const struct OamData gOamData_8587BC0 = +{ + .y = 0, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 1, + .x = 0, + .matrixNum = 0, + .size = 3, + .tileNum = 0, + .priority = 0, + .paletteNum = 0, + .affineParam = 0 +}; + +const struct SpriteTemplate gSpriteTemplate_8587BC8 = +{ + .tileTag = 0xABE2, + .paletteTag = 0xABE2, + .oam = &gOamData_8587BC0, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy +}; + +const struct OamData gOamData_8587BE0 = +{ + .y = 0, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 3, + .tileNum = 0, + .priority = 3, + .paletteNum = 2, + .affineParam = 0 +}; + +const struct SpriteTemplate gSpriteTemplate_8587BE8 = +{ + .tileTag = 0x4E21, + .paletteTag = 0x4E21, + .oam = &gOamData_8587BE0, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy +}; + +const struct CompressedSpriteSheet gUnknown_08587C00 = +{ + .data = gContestJudgeGfx, + .size = 0x800, + .tag = 0x4E21 +}; + +const struct CompressedSpriteSheet gUnknown_08587C08 = +{ + .data = gContestJudgeSymbolsGfx, + .size = 0x380, + .tag = 0xABE0 +}; + +const struct CompressedSpritePalette gUnknown_08587C10 = +{ + .data = gContest3Pal, + .tag = 0xABE0 +}; + +const struct SpriteTemplate gSpriteTemplate_8587C18 = +{ + .tileTag = 0xABE0, + .paletteTag = 0xABE0, + .oam = &gUnknown_0852490C, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy +}; + +const u16 gUnknown_08587C30[] = INCBIN_U16("graphics/unknown/unknown_587C30.gbapal"); + static void TaskDummy1(u8 taskId) { }