Skip to content

Commit

Permalink
Merge pull request #277 from lhearachel/graphics
Browse files Browse the repository at this point in the history
Document palette.c and graphics.c
  • Loading branch information
lhearachel authored Oct 24, 2024
2 parents f4d97ae + 7820f1d commit b4d8ed0
Show file tree
Hide file tree
Showing 462 changed files with 4,481 additions and 4,740 deletions.
5 changes: 3 additions & 2 deletions include/battle/healthbar.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
#define POKEPLATINUM_OV16_02266F1C_H

#include "struct_decls/cell_actor_data.h"
#include "struct_decls/struct_02002F38_decl.h"
#include "struct_decls/struct_02006C24_decl.h"
#include "struct_decls/struct_0200C6E4_decl.h"
#include "struct_decls/struct_0200C704_decl.h"

#include "battle/struct_ov16_022674C4.h"

#include "narc.h"
#include "palette.h"

#define HEALTHBAR_INFO_NONE 0
#define HEALTHBAR_INFO_HP_GAUGE (1 << 0)
#define HEALTHBAR_INFO_CURRENT_HP (1 << 1)
Expand Down
2 changes: 1 addition & 1 deletion include/battle/ov16_0223DF00.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "struct_decls/pokedexdata_decl.h"
#include "struct_decls/pokemon_animation_sys_decl.h"
#include "struct_decls/sprite_decl.h"
#include "struct_decls/struct_02002F38_decl.h"
#include "struct_decls/struct_02007768_decl.h"
#include "struct_decls/struct_0200C440_decl.h"
#include "struct_decls/struct_0200C6E4_decl.h"
Expand All @@ -32,6 +31,7 @@
#include "bg_window.h"
#include "game_options.h"
#include "message.h"
#include "palette.h"
#include "pokemon.h"
#include "strbuf.h"
#include "string_template.h"
Expand Down
2 changes: 1 addition & 1 deletion include/battle/ov16_0226871C.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
#define POKEPLATINUM_OV16_0226871C_H

#include "struct_decls/battle_system.h"
#include "struct_decls/struct_02006C24_decl.h"
#include "struct_defs/struct_0209C370.h"

#include "battle/struct_ov16_02268A14_decl.h"
#include "battle/struct_ov16_0226AC98.h"

#include "bg_window.h"
#include "narc.h"

void ov16_02268744(BgConfig *param0);
void ov16_022687A0(BgConfig *param0);
Expand Down
3 changes: 2 additions & 1 deletion include/battle/ov16_0226DB7C.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#ifndef POKEPLATINUM_OV16_0226DB7C_H
#define POKEPLATINUM_OV16_0226DB7C_H

#include "struct_decls/struct_02002F38_decl.h"
#include "struct_decls/struct_0200C6E4_decl.h"
#include "struct_decls/struct_0200C704_decl.h"

#include "battle/struct_ov16_0226DC24_decl.h"

#include "palette.h"

void ov16_0226DB7C(SpriteRenderer *param0, SpriteGfxHandler *param1, PaletteData *param2, int param3, u32 param4, u32 param5, u32 param6, u32 param7);
void ov16_0226DBFC(SpriteGfxHandler *param0, u32 param1, u32 param2, u32 param3, u32 param4);
UnkStruct_ov16_0226DC24 *ov16_0226DC24(SpriteRenderer *param0, SpriteGfxHandler *param1, int param2, u32 param3, u32 param4, u32 param5, u32 param6, u32 param7, u32 param8);
Expand Down
3 changes: 2 additions & 1 deletion include/battle/ov16_0226DE44.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#ifndef POKEPLATINUM_OV16_0226DE44_H
#define POKEPLATINUM_OV16_0226DE44_H

#include "struct_decls/struct_02002F38_decl.h"
#include "struct_decls/struct_0200C6E4_decl.h"
#include "struct_decls/struct_0200C704_decl.h"

#include "battle/struct_ov16_0226DEEC_decl.h"

#include "palette.h"

void ov16_0226DE44(SpriteRenderer *param0, SpriteGfxHandler *param1, u32 param2, PaletteData *param3, u32 param4, u32 param5, u32 param6, u32 param7);
void ov16_0226DEC4(SpriteGfxHandler *param0, u32 param1, u32 param2, u32 param3, u32 param4);
UnkStruct_ov16_0226DEEC *ov16_0226DEEC(SpriteRenderer *param0, SpriteGfxHandler *param1, int param2, u32 param3, u32 param4, u32 param5, u32 param6, u32 param7, u32 param8);
Expand Down
3 changes: 2 additions & 1 deletion include/battle/party_gauge.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#ifndef POKEPLATINUM_BATTLE_PARTY_GAUGE_H
#define POKEPLATINUM_BATTLE_PARTY_GAUGE_H

#include "struct_decls/struct_02002F38_decl.h"
#include "struct_decls/struct_0200C6E4_decl.h"
#include "struct_decls/struct_0200C704_decl.h"

#include "battle/struct_ov16_0226D160_decl.h"

#include "palette.h"

enum PartyGaugeSide {
PARTY_GAUGE_OURS,
PARTY_GAUGE_THEIRS,
Expand Down
2 changes: 1 addition & 1 deletion include/battle/struct_ov16_0225BFFC_t.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#include "struct_decls/cell_actor_data.h"
#include "struct_decls/sprite_decl.h"
#include "struct_decls/struct_02006C24_decl.h"

#include "battle/struct_ov16_0225BFFC_sub1.h"
#include "battle/struct_ov16_022674C4.h"
Expand All @@ -12,6 +11,7 @@
#include "overlay012/struct_ov12_02223764.h"

#include "bg_window.h"
#include "narc.h"
#include "sys_task_manager.h"

#define DATA_BUF_SIZE 256
Expand Down
2 changes: 1 addition & 1 deletion include/battle/struct_ov16_02264408.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
#define POKEPLATINUM_STRUCT_OV16_02264408_H

#include "struct_decls/sprite_decl.h"
#include "struct_decls/struct_02002F38_decl.h"
#include "struct_decls/struct_0200C6E4_decl.h"
#include "struct_defs/chatot_cry.h"

#include "battle/struct_ov16_0223E0C8.h"
#include "battle/struct_ov16_02264408_sub1.h"

#include "bg_window.h"
#include "palette.h"

typedef struct {
SpriteRenderer *unk_00;
Expand Down
2 changes: 1 addition & 1 deletion include/berry_data.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#ifndef POKEPLATINUM_BERRY_DATA_H
#define POKEPLATINUM_BERRY_DATA_H

#include "struct_decls/struct_02006C24_decl.h"
#include "struct_decls/struct_berry_data_decl.h"

#include "narc.h"
#include "strbuf.h"

#define FIRMNESS_VERY_SOFT 1
Expand Down
43 changes: 0 additions & 43 deletions include/constants/palette.h
Original file line number Diff line number Diff line change
@@ -1,47 +1,4 @@
#ifndef POKEPLATINUM_CONSTANTS_PALETTE_H
#define POKEPLATINUM_CONSTANTS_PALETTE_H

enum PaletteBufferId {
PLTTBUF_MAIN_BG = 0,
PLTTBUF_SUB_BG,
PLTTBUF_MAIN_OBJ,
PLTTBUF_SUB_OBJ,
PLTTBUF_EX_BEGIN,

PLTTBUF_MAIN_EX_BG_0 = PLTTBUF_EX_BEGIN,
PLTTBUF_MAIN_EX_BG_1,
PLTTBUF_MAIN_EX_BG_2,
PLTTBUF_MAIN_EX_BG_3,
PLTTBUF_SUB_EX_BG_0,
PLTTBUF_SUB_EX_BG_1,
PLTTBUF_SUB_EX_BG_2,
PLTTBUF_SUB_EX_BG_3,
PLTTBUF_MAIN_EX_OBJ,
PLTTBUF_SUB_EX_OBJ,

PLTTBUF_MAX,
};

#define PLTTBUF_MAIN_BG_F (1 << PLTTBUF_MAIN_BG)
#define PLTTBUF_SUB_BG_F (1 << PLTTBUF_SUB_BG)
#define PLTTBUF_MAIN_OBJ_F (1 << PLTTBUF_MAIN_OBJ)
#define PLTTBUF_SUB_OBJ_F (1 << PLTTBUF_SUB_OBJ)
#define PLTTBUF_MAIN_EX_BG_0_F (1 << PLTTBUF_MAIN_EX_BG_0)
#define PLTTBUF_MAIN_EX_BG_1_F (1 << PLTTBUF_MAIN_EX_BG_1)
#define PLTTBUF_MAIN_EX_BG_2_F (1 << PLTTBUF_MAIN_EX_BG_2)
#define PLTTBUF_MAIN_EX_BG_3_F (1 << PLTTBUF_MAIN_EX_BG_3)
#define PLTTBUF_SUB_EX_BG_0_F (1 << PLTTBUF_SUB_EX_BG_0)
#define PLTTBUF_SUB_EX_BG_1_F (1 << PLTTBUF_SUB_EX_BG_1)
#define PLTTBUF_SUB_EX_BG_2_F (1 << PLTTBUF_SUB_EX_BG_2)
#define PLTTBUF_SUB_EX_BG_3_F (1 << PLTTBUF_SUB_EX_BG_3)
#define PLTTBUF_MAIN_EX_OBJ_F (1 << PLTTBUF_MAIN_EX_OBJ)
#define PLTTBUF_SUB_EX_OBJ_F (1 << PLTTBUF_SUB_EX_OBJ)
#define PLTTBUF_ALL_F ((1 << PLTTBUF_MAX) - 1)

enum PaletteSelector {
PLTTSEL_TRANSPARENT,
PLTTSEL_OPAQUE,
PLTTSEL_BOTH,
};

#endif // POKEPLATINUM_CONSTANTS_PALETTE_H
2 changes: 1 addition & 1 deletion include/easy3d_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "constants/heap.h"

#include "struct_decls/struct_02006C24_decl.h"
#include "narc.h"

enum RotationAxis {
ROTATION_AXIS_X = 0,
Expand Down
59 changes: 59 additions & 0 deletions include/graphics.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#ifndef POKEPLATINUM_GRAPHICS_H
#define POKEPLATINUM_GRAPHICS_H

#include <nnsys.h>

#include "bg_window.h"
#include "narc.h"

enum PaletteLoadLocation {
PAL_LOAD_MAIN_BG = 0,
PAL_LOAD_MAIN_OBJ,
PAL_LOAD_MAIN_BGEXT,
PAL_LOAD_MAIN_OBJEXT,
PAL_LOAD_SUB_BG,
PAL_LOAD_SUB_OBJ,
PAL_LOAD_SUB_BGEXT,
PAL_LOAD_SUB_OBJEXT,
};

enum ImageMappingLayout {
IMAGE_MAPPING_LAYOUT_1D = 0,
IMAGE_MAPPING_LAYOUT_2D,
};

void *LoadCompressedMemberFromNARC(u32 narcID, u32 narcMemberIdx, u32 heapID);
void *LoadMemberFromNARC(u32 narcID, u32 narcMemberIdx, BOOL compressed, u32 heapID, BOOL allocAtEnd);
void *LoadMemberFromNARC_OutFileSize(u32 narcID, u32 narcMemberIdx, BOOL compressed, u32 heapID, BOOL allocAtEnd, u32 *fileSize);
void *LoadMemberFromOpenNARC(NARC *narc, u32 narcMemberIdx, BOOL compressed, u32 heapID, BOOL allocAtEnd);
void *LoadMemberFromOpenNARC_OutFileSize(NARC *narc, u32 narcMemberIdx, BOOL compressed, u32 heapID, BOOL allocAtEnd, u32 *fileSize);

u32 Graphics_LoadTilesToBgLayer(u32 narcID, u32 narcMemberIdx, BgConfig *bgConfig, u32 bgLayer, u32 offset, u32 size, BOOL compressed, u32 heapID);
void Graphics_LoadTilemapToBgLayer(u32 narcID, u32 narcMemberIdx, BgConfig *bgConfig, u32 bgLayer, u32 offset, u32 size, BOOL compressed, u32 heapID);
void Graphics_LoadPalette(u32 narcID, u32 narcMemberIdx, enum PaletteLoadLocation loadLocation, u32 palOffset, u32 size, u32 heapID);
void Graphics_LoadPaletteWithSrcOffset(u32 narcID, u32 narcMemberIdx, enum PaletteLoadLocation loadLocation, u32 srcOffset, u32 palOffset, u32 size, u32 heapID);
u32 Graphics_LoadObjectTiles(u32 narcID, u32 narcMemberIdx, enum DSScreen display, u32 offset, u32 size, BOOL compressed, u32 heapID);
void Graphics_LoadPartialPalette(u32 narcID, u32 narcMemberIdx, NNS_G2D_VRAM_TYPE vramType, u32 baseAddr, u32 heapID, NNSG2dImagePaletteProxy *paletteProxy);
u32 Graphics_LoadImageMapping(u32 narcID, u32 narcMemberIdx, BOOL compressed, enum ImageMappingLayout layout, u32 size, NNS_G2D_VRAM_TYPE vramType, u32 baseAddr, u32 heapID, NNSG2dImageProxy *imageProxy);
void Graphics_LoadImageMappingAndSetVramMode(u32 narcID, u32 narcMemberIdx, BOOL compressed, enum ImageMappingLayout layout, u32 size, NNS_G2D_VRAM_TYPE vramType, u32 baseAddr, u32 heapID, NNSG2dImageProxy *imageProxy);

void *Graphics_GetCharData(u32 narcID, u32 narcMemberIdx, BOOL compressed, NNSG2dCharacterData **outCharData, u32 heapID);
void *Graphics_GetScrnData(u32 narcID, u32 narcMemberIdx, BOOL compressed, NNSG2dScreenData **outScreenData, u32 heapID);
void *Graphics_GetPlttData(u32 narcID, u32 narcMemberIdx, NNSG2dPaletteData **outPaletteData, u32 heapID);
void *Graphics_GetCellBank(u32 narcID, u32 narcMemberIdx, BOOL compressed, NNSG2dCellDataBank **outCellBank, u32 heapID);
void *Graphics_GetAnimBank(u32 narcID, u32 narcMemberIdx, BOOL compressed, NNSG2dAnimBankData **outAnimBank, u32 heapID);

u32 Graphics_LoadTilesToBgLayerFromOpenNARC(NARC *narc, u32 narcMemberIdx, BgConfig *bgConfig, u32 bgLayer, u32 offset, u32 size, BOOL compressed, u32 heapID);
void Graphics_LoadTilemapToBgLayerFromOpenNARC(NARC *narc, u32 narcMemberIdx, BgConfig *bgConfig, u32 bgLayer, u32 offset, u32 size, BOOL compressed, u32 heapID);
void Graphics_LoadPaletteFromOpenNARC(NARC *narc, u32 narcMemberIdx, enum PaletteLoadLocation loadLocation, u32 offset, u32 size, u32 heapID);
void Graphics_LoadPaletteWithSrcOffsetFromOpenNARC(NARC *narc, u32 narcMemberIdx, enum PaletteLoadLocation loadLocation, u32 srcOffset, u32 offset, u32 size, u32 heapID);
void Graphics_LoadPartialPaletteFromOpenNARC(NARC *narc, u32 narcMemberIdx, NNS_G2D_VRAM_TYPE vramType, u32 baseAddr, u32 heapID, NNSG2dImagePaletteProxy *paletteProxy);
u32 Graphics_LoadImageMappingFromOpenNARC(NARC *narc, u32 narcMemberIdx, BOOL compressed, enum ImageMappingLayout layout, u32 size, NNS_G2D_VRAM_TYPE vramType, u32 baseAddr, u32 heapID, NNSG2dImageProxy *imageProxy);

void *Graphics_GetCharDataFromOpenNARC(NARC *narc, u32 narcMemberIdx, BOOL compressed, NNSG2dCharacterData **outCharData, u32 heapID);
void *Graphics_GetScrnDataFromOpenNARC(NARC *narc, u32 narcMemberIdx, BOOL compressed, NNSG2dScreenData **outScreenData, u32 heapID);
void *Graphics_GetPlttDataFromOpenNARC(NARC *narc, u32 narcMemberIdx, NNSG2dPaletteData **outPaletteData, u32 heapID);
void *Graphics_GetCellBankFromOpenNARC(NARC *narc, u32 narcMemberIdx, BOOL compressed, NNSG2dCellDataBank **outCellBank, u32 heapID);
void *Graphics_GetAnimBankFromOpenNARC(NARC *narc, u32 narcMemberIdx, BOOL compressed, NNSG2dAnimBankData **outAnimBank, u32 heapID);

#endif // POKEPLATINUM_GRAPHICS_H
11 changes: 11 additions & 0 deletions include/hardware_palette.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef POKEPLATINUM_HARDWARE_PALETTE_H
#define POKEPLATINUM_HARDWARE_PALETTE_H

u16 *GetHardwareMainBgPaletteAddress(void);
u32 GetHardwareMainBgPaletteSize(void);
u16 *GetHardwareSubBgPaletteAddress(void);
u32 GetHardwareSubBgPaletteSize(void);
u16 *GetHardwareMainObjPaletteAddress(void);
u16 *GetHardwareSubObjPaletteAddress(void);

#endif // POKEPLATINUM_HARDWARE_PALETTE_H
10 changes: 5 additions & 5 deletions include/inlines.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#include <nitro/rtc.h>

#include "struct_decls/struct_02006C24_decl.h"
#include "struct_decls/struct_0203A790_decl.h"
#include "struct_defs/struct_02049FA8.h"

Expand All @@ -13,13 +12,14 @@
#include "assert.h"
#include "field_overworld_state.h"
#include "field_script_context.h"
#include "graphics.h"
#include "heap.h"
#include "map_header.h"
#include "narc.h"
#include "palette.h"
#include "script_manager.h"
#include "sys_task.h"
#include "sys_task_manager.h"
#include "unk_02002F38.h"
#include "unk_02006E3C.h"
#include "unk_0201D15C.h"
#include "unk_0206A8DC.h"
#include "vars_flags.h"
Expand All @@ -34,7 +34,7 @@ static inline void inline_ov61_0222C3B0(UnkStruct_ov61_0222C3B0 *param0, NARC *p

MI_CpuClear8(param0, sizeof(UnkStruct_ov61_0222C3B0));

v1 = sub_020071EC(param1, param2, &v0, param3);
v1 = Graphics_GetPlttDataFromOpenNARC(param1, param2, &v0, param3);

MI_CpuCopy16(&((u16 *)(v0->pRawData))[0 * 16], param0->unk_08, 4 * 0x20);
MI_CpuCopy16(&((u16 *)(v0->pRawData))[0 * 16], param0->unk_88, 4 * 0x20);
Expand Down Expand Up @@ -81,7 +81,7 @@ static inline void inline_ov61_0222C3B0_sub_1(UnkStruct_ov61_0222C3B0 *param0)
do {
GF_ASSERT(v1 < (((16 << 8) / 0x300 + 2) * (4 - 1)));
for (v4 = 1; v4 < 1 + 15; v4++) {
sub_0200393C(&param0->unk_08[v0][v4], &param0->unk_88[v1][v4], 1, v3 >> 8, param0->unk_08[v2][v4]);
BlendPalette(&param0->unk_08[v0][v4], &param0->unk_88[v1][v4], 1, v3 >> 8, param0->unk_08[v2][v4]);
}
v1++;
if (v5 == 1) {
Expand Down
2 changes: 1 addition & 1 deletion include/map_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

#include "constants/map_object.h"

#include "struct_decls/struct_02006C24_decl.h"
#include "struct_decls/struct_02061830_decl.h"
#include "struct_decls/struct_02061AB4_decl.h"
#include "struct_defs/struct_02061D3C.h"
Expand All @@ -22,6 +21,7 @@
#include "overlay005/struct_ov5_021ED0A4.h"

#include "map_header_data.h"
#include "narc.h"
#include "sys_task_manager.h"

MapObjectManager *MapObjectMan_New(FieldSystem *fieldSystem, int param1, int param2);
Expand Down
3 changes: 1 addition & 2 deletions include/message.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#ifndef POKEPLATINUM_MESSAGE_H
#define POKEPLATINUM_MESSAGE_H

#include "struct_decls/struct_02006C24_decl.h"

#include "narc.h"
#include "strbuf.h"

typedef struct MessageBankEntry {
Expand Down
22 changes: 10 additions & 12 deletions include/narc.h
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
#ifndef POKEPLATINUM_UNK_020068C8_H
#define POKEPLATINUM_UNK_020068C8_H
#ifndef POKEPLATINUM_NARC_H
#define POKEPLATINUM_NARC_H

#include "constants/narc.h"

#include "struct_decls/struct_02006C24_decl.h"

/*
* The NARC struct wraps NitroSDK type FSFile and manages the important
* offsets to the FATB and the FIMG chunks within the file.
*
* FATB defines the regions within the FIMG to which the data are allocated.
*/
struct NARC {
FSFile unk_00;
u32 unk_AC;
u32 unk_B0;
u16 unk_B4;
};
typedef struct NARC {
FSFile file;
u32 fatbStart;
u32 fimgStart;
u16 numFiles;
} NARC;

/*
* Reads the entire content of an archive member into an existing buffer
Expand Down Expand Up @@ -146,7 +144,7 @@ void NARC_ReadFromMember(NARC *narc, u32 memberIndex, u32 offset, u32 bytesToRea
*/
void NARC_ReadFile(NARC *narc, u32 bytesToRead, void *dest);

void sub_02006E28(NARC *param0, u32 param1);
void NARC_Seek(NARC *narc, u32 offset);

/*
* Gets the total number of archive members
Expand All @@ -157,4 +155,4 @@ void sub_02006E28(NARC *param0, u32 param1);
*/
u16 NARC_GetFileCount(NARC *narc);

#endif // POKEPLATINUM_UNK_020068C8_H
#endif // POKEPLATINUM_NARC_H
3 changes: 1 addition & 2 deletions include/overlay005/encounter_effect.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

#include <nitro/fx/fx.h>

#include "struct_decls/struct_02006C24_decl.h"

#include "field/field_system_decl.h"
#include "overlay005/encounter_effect.h"
#include "overlay005/hblank_system.h"
Expand All @@ -19,6 +17,7 @@
#include "bg_window.h"
#include "cell_actor.h"
#include "enc_effects.h"
#include "narc.h"
#include "sys_task_manager.h"

typedef struct EncounterEffect {
Expand Down
Loading

0 comments on commit b4d8ed0

Please sign in to comment.