start sprite.c

This commit is contained in:
PikalaxALT 2024-09-04 21:58:25 -04:00
parent 9b8feaa8cd
commit 29e1c8171e
No known key found for this signature in database
GPG Key ID: 7774E96AA69E5B61
40 changed files with 1925 additions and 2080 deletions

1466
asm/sprite_s.s Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
#!/bin/sh
set -e
find src include -name "*.c" -or -name "*.cpp" -or -name "*.h" -or -name "*.hpp" | xargs clang-format -i --verbose
find src include \( -name "*.c" -or -name "*.cpp" -or -name "*.h" -or -name "*.hpp" \) -exec clang-format -i --verbose {} +

View File

@ -20,10 +20,10 @@
#include "pokemon_storage_system.h"
#include "pokepic.h"
#include "sav_chatot.h"
#include "sprite.h"
#include "sys_task_api.h"
#include "trainer_data.h"
#include "unk_0200CF18.h"
#include "unk_02023694.h"
typedef struct BattleMessage {
u8 unk0;

View File

@ -9,8 +9,8 @@
#include "player_data.h"
#include "save.h"
#include "save_frontier.h"
#include "sprite.h"
#include "unk_02009D48.h"
#include "unk_02023694.h"
#define ARCADE_ENEMY_POKEMON_MAX 4

View File

@ -3,7 +3,7 @@
#include "game_stats.h"
#include "launch_application.h"
#include "overlay_16.h"
#include "unk_02023694.h"
#include "sprite.h"
enum BerryPotsApp_022036FC_Action {
BERRY_POTS_APP_022036FC_ACTION_0,

View File

@ -1,8 +1,8 @@
#ifndef POKEHEARTGOLD_FIELD_OV01_021E7FDC_H
#define POKEHEARTGOLD_FIELD_OV01_021E7FDC_H
#include "sprite.h"
#include "unk_02009D48.h"
#include "unk_02023694.h"
typedef struct UnkStruct_ov01_021E7FDC {
SpriteList *spriteList;

View File

@ -4,9 +4,9 @@
#include "bg_window.h"
#include "camera.h"
#include "gf_3d_vramman.h"
#include "sprite.h"
#include "sys_task.h"
#include "unk_02014DA0.h"
#include "unk_02023694.h"
enum IntroMovieSceneState {
INTRO_MOVIE_SCENE_INIT,

View File

@ -2,7 +2,7 @@
#define POKEHEARTGOLD_OVERLAY_01_021F72DC_H
#include "map_object.h"
#include "unk_02023694.h"
#include "sprite.h"
Sprite *ov01_021F72DC(LocalMapObject *obj);
void ov01_021F7918(LocalMapObject *obj);

View File

@ -2,7 +2,7 @@
#define POKEHEARTGOLD_OVERLAY_01_021F944C_H
#include "field_player_avatar.h"
#include "unk_02023694.h"
#include "sprite.h"
void ov01_021F9FB0(MapObjectManager *manager, void *);
BOOL ov01_021FA2D4(LocalMapObject *obj);

View File

@ -1,8 +1,17 @@
#ifndef POKEHEARTGOLD_UNK_02023694_H
#define POKEHEARTGOLD_UNK_02023694_H
#ifndef POKEHEARTGOLD_SPRITE_H
#define POKEHEARTGOLD_SPRITE_H
#include "unk_02009D48.h"
typedef struct SimpleSpriteTemplate {
SpriteList *spriteList; // 000
const SpriteResourcesHeader *header; // 004
VecFx32 position; // 008
u32 priority; // 014
NNS_G2D_VRAM_TYPE whichScreen; // 018
HeapID heapId; // 01C
} SimpleSpriteTemplate;
typedef struct SpriteTemplate {
SpriteList *spriteList; // 000
const SpriteResourcesHeader *header; // 004
@ -14,13 +23,36 @@ typedef struct SpriteTemplate {
HeapID heapId; // 02C
} SpriteTemplate;
struct SpriteAnimationData {
typedef struct SpriteAnimationData {
const NNSG2dCellDataBank *cellBank;
const NNSG2dCellAnimBankData *animBankData;
NNSG2dCellAnimation animation;
};
} SpriteAnimationData;
#define SPRITE_ANIMATION_DATA_WORD_COUNT (sizeof(struct SpriteAnimationData) / 4)
typedef struct SpriteAnimationData2 {
const NNSG2dCellDataBank *cellBank;
const NNSG2dCellAnimBankData *animBankData;
NNSG2dCellAnimation animation;
u32 cellTransferStateHandle;
} SpriteAnimationData2;
typedef struct SpriteMultiAnimationData {
const NNSG2dCellDataBank *cellBank;
const NNSG2dCellAnimBankData *animBankData;
NNSG2dMultiCellAnimation animation;
const NNSG2dMultiCellDataBank *multiCellBank;
const NNSG2dMultiCellAnimBankData *multiAnimBankData;
NNSG2dNode *node;
NNSG2dCellAnimation *cellAnim;
} SpriteMultiAnimationData;
// UB: this is too small
#ifdef BUGFIX_SPRITE_ANIM_SIZE
#define max(a, b) ((a) > (b) ? (a) : (b))
#define SPRITE_ANIMATION_DATA_WORD_COUNT (max(sizeof(SpriteAnimationData), sizeof(SpriteMultiAnimationData)) / 4)
#else
#define SPRITE_ANIMATION_DATA_WORD_COUNT 29
#endif // BUGFIX_SPRITE_ANIM_SIZE
typedef struct Sprite {
VecFx32 matrix; // 000
@ -37,8 +69,8 @@ typedef struct Sprite {
u8 drawFlag; // 034
u8 animationFrame; // 035
fx32 frame; // 038
void *unkPtr; // 03c
u32 animationData[SPRITE_ANIMATION_DATA_WORD_COUNT]; // 040, cast to SpriteAnimationData internally
SpriteList *spriteList; // 03c
u32 animationData[SPRITE_ANIMATION_DATA_WORD_COUNT]; // 040
NNSG2dImageProxy imageProxy; // 0b4
NNSG2dImagePaletteProxy paletteProxy; // 0d8
u32 flag; // 0ec
@ -57,51 +89,71 @@ typedef struct UnkImageStruct {
int vramTransfer;
} UnkImageStruct;
void sub_02023EA4(Sprite *sprite, int a1);
struct Sprite *CreateSprite(const struct SpriteTemplate *template);
void Set2dSpriteAnimActiveFlag(Sprite *sprite, int a1);
SpriteList *SpriteList_Create(struct SpriteListParam *param);
void SpriteList_Delete(SpriteList *spriteList);
struct SpriteList {
Sprite *sprites;
int numSprites;
Sprite **stack;
int stackPointer;
Sprite dummy;
NNSG2dRendererInstance *renderer;
void *animBuff;
NNSG2dCellAnimBankData *animBank;
u32 flag;
};
SpriteList *SpriteList_Create(SpriteListParam *param);
BOOL SpriteList_Delete(SpriteList *spriteList);
void sub_0202457C(SpriteList *spriteList);
Sprite *CreateSprite(const SpriteTemplate *template);
Sprite *sub_02024714(const SimpleSpriteTemplate *simpleTemplate);
void Sprite_Delete(Sprite *sprite);
void Sprite_SetMatrix(Sprite *sprite, VecFx32 *vec);
NNSG2dImagePaletteProxy *Sprite_GetPaletteProxy(Sprite *sprite);
NNS_G2D_VRAM_TYPE Sprite_GetVramType(Sprite *sprite);
void sub_0202487C(Sprite *sprite, u8 a1);
void Set2dSpriteVisibleFlag(Sprite *sprite, int a1);
void sub_020247E4(Sprite *sprite, VecFx32 *vec);
void sub_020247F4(Sprite *sprite, VecFx32 *vec);
void sub_02024804(Sprite *sprite, VecFx32 *vec, u8 a2);
void sub_02024818(Sprite *sprite, u32 a1);
void sub_0202481C(Sprite *sprite, u32 a1, u8 a2);
void Set2dSpriteVisibleFlag(Sprite *sprite, BOOL flag);
void Set2dSpriteAnimActiveFlag(Sprite *sprite, BOOL flag);
void sub_02024868(Sprite *sprite, int a1);
void sub_0202487C(Sprite *sprite, u8 a1);
void sub_02024890(Sprite *sprite, u8 a1);
VecFx32 *Sprite_GetMatrixPtr(Sprite *sprite);
VecFx32 *sub_020248B0(Sprite *sprite);
void sub_020247F4(Sprite *sprite, VecFx32 *vec);
void sub_02024818(Sprite *sprite, u32 a1);
u16 sub_020248B4(Sprite *sprite);
void sub_02024890(Sprite *sprite, u8 a1);
void sub_020247E4(Sprite *sprite, VecFx32 *vec);
void sub_02024B38(Sprite *sprite, BOOL a1);
void sub_02024B78(Sprite *sprite, GXOamMode mode);
GXOamMode sub_02024BAC(Sprite *sprite);
u32 sub_02024C9C(Sprite *sprite);
BOOL Get2dSpriteVisibleFlag(Sprite *sprite);
BOOL sub_020248C0(Sprite *sprite);
u32 Get2dSpriteAnimSeqNo(Sprite *sprite);
void Set2dSpriteAnimSeqNo(Sprite *sprite, int a1);
void TryChange2dSpriteAnimSeqNo(Sprite *sprite, int a1);
u16 Get2dSpriteCurrentAnimSeqNo(Sprite *sprite);
void Sprite_ResetAnimCtrlState(Sprite *sprite);
u16 Get2dSpriteCurrentAnimSeqNo(Sprite *sprite);
void Sprite_TickCellOrMulticellAnimation(Sprite *sprite, fx32 a1);
void Sprite_SetAnimCtrlCurrentFrame(Sprite *sprite, u16 a1);
u16 Sprite_GetAnimCtrlCurrentFrame(Sprite *sprite);
BOOL Get2dSpriteVisibleFlag(Sprite *sprite);
void Sprite_SetPalOffset(Sprite *sprite, u8 a1);
void Sprite_TickCellOrMulticellAnimation(Sprite *sprite, fx32 a1);
void Sprite_SetPriority(Sprite *sprite, u8 a1);
u8 Sprite_GetPriority(Sprite *sprite);
void Sprite_SetPalIndex(Sprite *sprite, int a1);
void sub_02024A48(Sprite *sprite, int a1);
int Sprite_GetPalIndex(Sprite *sprite);
void Sprite_SetPalOffset(Sprite *sprite, u8 a1);
void sub_02024AA8(Sprite *sprite, s32 a1);
u8 Sprite_GetPalOffset(Sprite *sprite);
void Sprite_SetPriority(Sprite *sprite, u8 a1);
u8 Sprite_GetPriority(Sprite *sprite);
void Sprite_SetDrawPriority(Sprite *sprite, u16 a1);
u16 Sprite_GetDrawPriority(Sprite *sprite);
void sub_02024B00(Sprite *sprite, NNSG2dImageProxy *proxy);
NNSG2dImagePaletteProxy *Sprite_GetPaletteProxy(Sprite *sprite);
void sub_02024B20(Sprite *sprite, NNSG2dImagePaletteProxy *proxy);
NNSG2dImageProxy *Sprite_GetImageProxy(Sprite *sprite);
void sub_02024B38(Sprite *sprite, BOOL a1);
NNS_G2D_VRAM_TYPE Sprite_GetVramType(Sprite *sprite);
int Sprite_IsCellAnimationRunning(Sprite *sprite);
void sub_02024B78(Sprite *sprite, GXOamMode mode);
GXOamMode sub_02024BAC(Sprite *sprite);
void sub_02024BBC(HeapID heapId);
void sub_02024BF4(HeapID heapId);
u32 sub_02024C24(Sprite *sprite, u32 a1);
u32 sub_02024C9C(Sprite *sprite);
NNSG2dCellAnimation *Sprite_GetCellAnim(Sprite *sprite);
#endif // POKEHEARTGOLD_UNK_02023694_H
#endif // POKEHEARTGOLD_SPRITE_H

View File

@ -38,11 +38,11 @@ typedef struct GF_G2dRenderer {
NNSG2dRenderSurface renderSurface[2];
} GF_G2dRenderer;
struct SpriteListParam {
int unk_0;
typedef struct SpriteListParam {
int num;
NNSG2dRendererInstance *rendererInstance;
HeapID heapId;
};
} SpriteListParam;
void CreateSpriteResourcesHeader(SpriteResourcesHeader *hdr, int charId, int plttId, int cellId, int cellAnmId, int multiCellId, int multiCellAnmId, int transfer, int priority, GF_2DGfxResMan *charMan, GF_2DGfxResMan *plttMan, GF_2DGfxResMan *cellMan, GF_2DGfxResMan *cellAnmMan, GF_2DGfxResMan *multiCellMan, GF_2DGfxResMan *multiCellAnmMan);
SpriteResourceHeaderList *SpriteResourceHeaderList_Create(const struct ResdatNarcEntry *resdatNarcEntry, HeapID heapId, GF_2DGfxResMan *charMan, GF_2DGfxResMan *plttMan, GF_2DGfxResMan *cellMan, GF_2DGfxResMan *animMan, GF_2DGfxResMan *mcelMan, GF_2DGfxResMan *manmMan);

View File

@ -4,8 +4,8 @@
#include "filesystem.h"
#include "palette.h"
#include "save.h"
#include "sprite.h"
#include "unk_02009D48.h"
#include "unk_02023694.h"
typedef struct UnkStruct_0200D2B4 {
int resourceSet;
@ -14,7 +14,7 @@ typedef struct UnkStruct_0200D2B4 {
s16 z;
u16 animSeqNo;
int rotation;
int unk_10;
int palIndex;
NNS_G2D_VRAM_TYPE whichScreen;
int unk_18;
int unk_1C;

View File

@ -1,30 +1,30 @@
#ifndef NNSYS_G2D_H_
#define NNSYS_G2D_H_
#include <nnsys/g2d/fmt/g2d_Character_data.h>
#include <nnsys/g2d/fmt/g2d_Screen_data.h>
#include <nnsys/g2d/fmt/g2d_Cell_data.h>
#include <nnsys/g2d/fmt/g2d_Anim_data.h>
#include <nnsys/g2d/fmt/g2d_Cell_data.h>
#include <nnsys/g2d/fmt/g2d_Character_data.h>
#include <nnsys/g2d/fmt/g2d_MultiCell_data.h>
#include <nnsys/g2d/g2d_Vec_data.h>
#include <nnsys/g2d/fmt/g2d_SRTControl_data.h>
#include <nnsys/g2d/load/g2d_NCG_load.h>
#include <nnsys/g2d/load/g2d_NSC_load.h>
#include <nnsys/g2d/load/g2d_NCL_load.h>
#include <nnsys/g2d/load/g2d_NCE_load.h>
#include <nnsys/g2d/load/g2d_NAN_load.h>
#include <nnsys/g2d/load/g2d_NMC_load.h>
#include <nnsys/g2d/g2d_Image.h>
#include <nnsys/g2d/g2d_OAM.h>
#include <nnsys/g2d/g2d_CellAnimation.h>
#include <nnsys/g2d/g2d_MultiCellAnimation.h>
#include <nnsys/g2d/g2d_Vec_data.h>
#include <nnsys/g2d/g2d_PaletteTable.h>
#include <nnsys/g2d/g2d_RendererCore.h>
#include <nnsys/g2d/g2d_Renderer.h>
#include <nnsys/g2d/g2d_Sprite.h>
#include <nnsys/g2d/g2d_CellTransferManager.h>
#include <nnsys/g2d/fmt/g2d_Screen_data.h>
#include <nnsys/g2d/g2d_Animation.h>
#include <nnsys/g2d/g2d_CellAnimation.h>
#include <nnsys/g2d/g2d_CellTransferManager.h>
#include <nnsys/g2d/g2d_Image.h>
#include <nnsys/g2d/g2d_MultiCellAnimation.h>
#include <nnsys/g2d/g2d_Node.h>
#include <nnsys/g2d/g2d_OAM.h>
#include <nnsys/g2d/g2d_PaletteTable.h>
#include <nnsys/g2d/g2d_Renderer.h>
#include <nnsys/g2d/g2d_RendererCore.h>
#include <nnsys/g2d/g2d_Softsprite.h>
#include <nnsys/g2d/g2d_Sprite.h>
#include <nnsys/g2d/g2d_Vec_data.h>
#include <nnsys/g2d/load/g2d_NAN_load.h>
#include <nnsys/g2d/load/g2d_NCE_load.h>
#include <nnsys/g2d/load/g2d_NCG_load.h>
#include <nnsys/g2d/load/g2d_NCL_load.h>
#include <nnsys/g2d/load/g2d_NMC_load.h>
#include <nnsys/g2d/load/g2d_NSC_load.h>
#endif //NNSYS_G2D_H_
#endif // NNSYS_G2D_H_

View File

@ -1,6 +1,8 @@
#ifndef NNSYS_G2D_FMT_G2D_ANIM_DATA_H_
#define NNSYS_G2D_FMT_G2D_ANIM_DATA_H_
#include <nitro.h>
typedef enum NNSG2dAnimationPlayMode {
NNS_G2D_ANIMATIONPLAYMODE_INVALID = 0x0,
NNS_G2D_ANIMATIONPLAYMODE_FORWARD,
@ -11,7 +13,7 @@ typedef enum NNSG2dAnimationPlayMode {
} NNSG2dAnimationPlayMode;
typedef struct NNSG2dAnimFrameData {
void* pContent;
void *pContent;
u16 frames;
u16 pad16;
@ -29,11 +31,11 @@ typedef struct NNSG2dAnimSequenceData {
typedef struct NNSG2dAnimBankData {
u16 numSequences;
u16 numTotalFrames;
NNSG2dAnimSequenceData* pSequenceArrayHead;
NNSG2dAnimFrameData* pFrameArrayHead;
void* pAnimContents;
void* pStringBank;
void* pExtendedData;
NNSG2dAnimSequenceData *pSequenceArrayHead;
NNSG2dAnimFrameData *pFrameArrayHead;
void *pAnimContents;
void *pStringBank;
void *pExtendedData;
} NNSG2dAnimBankData;
#endif //NNSYS_G2D_FMT_G2D_ANIM_DATA_H_
#endif // NNSYS_G2D_FMT_G2D_ANIM_DATA_H_

View File

@ -1,6 +1,9 @@
#ifndef NNSYS_G2D_FMT_G2D_CELL_DATA_H_
#define NNSYS_G2D_FMT_G2D_CELL_DATA_H_
#include <nitro.h>
#include <nnsys/g2d/fmt/g2d_Character_data.h>
typedef struct NNSG2dCellOAMAttrData {
u16 attr0;
u16 attr1;
@ -11,7 +14,7 @@ typedef struct NNSG2dCellOAMAttrData {
typedef struct NNSG2dCellData {
u16 numOAMAttrs;
u16 cellAttr;
NNSG2dCellOAMAttrData* pOamAttrArray;
NNSG2dCellOAMAttrData *pOamAttrArray;
} NNSG2dCellData;
typedef struct NNSG2dCellVramTransferData {
@ -22,18 +25,18 @@ typedef struct NNSG2dCellVramTransferData {
typedef struct NNSG2dVramTransferData {
u32 szByteMax;
NNSG2dCellVramTransferData* pCellTransferDataArray;
NNSG2dCellVramTransferData *pCellTransferDataArray;
} NNSG2dVramTransferData;
typedef struct NNSG2dCellDataBank {
u16 numCells;
u16 cellBankAttr;
NNSG2dCellData* pCellDataArrayHead;
NNSG2dCellData *pCellDataArrayHead;
NNSG2dCharacterDataMapingType mappingMode;
NNSG2dVramTransferData* pVramTransferData;
void* pStringBank;
void* pExtendedData;
NNSG2dVramTransferData *pVramTransferData;
void *pStringBank;
void *pExtendedData;
} NNSG2dCellDataBank;
#endif //NNSYS_G2D_FMT_G2D_CELL_DATA_H_
#endif // NNSYS_G2D_FMT_G2D_CELL_DATA_H_

View File

@ -1,6 +1,8 @@
#ifndef NNSYS_G2D_FMT_G2D_MULTICELL_DATA_H_
#define NNSYS_G2D_FMT_G2D_MULTICELL_DATA_H_
#include <nitro.h>
typedef struct NNSG2dMultiCellHierarchyData {
u16 animSequenceIdx;
s16 posX;
@ -11,16 +13,16 @@ typedef struct NNSG2dMultiCellHierarchyData {
typedef struct NNSG2dMultiCellData {
u16 numNodes;
u16 numCellAnim;
NNSG2dMultiCellHierarchyData* pHierDataArray;
NNSG2dMultiCellHierarchyData *pHierDataArray;
} NNSG2dMultiCellData;
typedef struct NNSG2dMultiCellDataBank {
u16 numMultiCellData;
u16 pad16;
NNSG2dMultiCellData* pMultiCellDataArray;
NNSG2dMultiCellHierarchyData* pHierarchyDataArray;
void* pStringBank;
void* pExtendedData;
NNSG2dMultiCellData *pMultiCellDataArray;
NNSG2dMultiCellHierarchyData *pHierarchyDataArray;
void *pStringBank;
void *pExtendedData;
} NNSG2dMultiCellDataBank;
#endif //NNSYS_G2D_FMT_G2D_MULTICELL_DATA_H_
#endif // NNSYS_G2D_FMT_G2D_MULTICELL_DATA_H_

View File

@ -1,6 +1,9 @@
#ifndef NNSYS_G2D_FMT_G2D_SRTCONTROL_DATA_H
#define NNSYS_G2D_FMT_G2D_SRTCONTROL_DATA_H
#include <nitro.h>
#include <nnsys/g2d/g2d_Vec_data.h>
typedef enum {
NNS_G2D_SRTCONTROLTYPE_INVALID,
NNS_G2D_SRTCONTROLTYPE_SRT,
@ -24,4 +27,4 @@ typedef struct {
NNSG2dSRTData srtData;
} NNSG2dSRTControl;
#endif //NNSYS_G2D_FMT_G2D_SRTCONTROL_DATA_H
#endif // NNSYS_G2D_FMT_G2D_SRTCONTROL_DATA_H

View File

@ -1,16 +1,18 @@
#ifndef NNSYS_G2D_G2D_CELLANIMATION_H_
#define NNSYS_G2D_G2D_CELLANIMATION_H_
#include <nnsys/g2d/fmt/g2d_Cell_data.h>
#include <nnsys/g2d/fmt/g2d_SRTControl_data.h>
#include <nnsys/g2d/g2d_Animation.h>
typedef NNSG2dAnimBankData NNSG2dCellAnimBankData;
typedef struct NNSG2dCellAnimation{
typedef struct NNSG2dCellAnimation {
NNSG2dAnimController animCtrl;
const NNSG2dCellData* pCurrentCell;
const NNSG2dCellDataBank* pCellDataBank;
const NNSG2dCellData *pCurrentCell;
const NNSG2dCellDataBank *pCellDataBank;
u32 cellTransferStateHandle;
NNSG2dSRTControl srtCtrl;
} NNSG2dCellAnimation;
#endif //NNSYS_G2D_G2D_CELLANIMATION_H_
#endif // NNSYS_G2D_G2D_CELLANIMATION_H_

View File

@ -1,11 +1,13 @@
#ifndef NNS_G2D_G2D_CELL_TRANSFER_MANAGER_H
#define NNS_G2D_G2D_CELL_TRANSFER_MANAGER_H
#include <nnsys/g2d/g2d_Image.h>
typedef struct NNSG2dCellTransferState {
NNSG2dVRamLocation dstVramLocation;
u32 szDst;
const void* pSrcNCGR;
const void* pSrcNCBR;
const void *pSrcNCGR;
const void *pSrcNCBR;
u32 szSrcData;
BOOL bActive;
u32 bDrawn;
@ -14,4 +16,6 @@ typedef struct NNSG2dCellTransferState {
u32 szByte;
} NNSG2dCellTransferState;
#endif //NNS_G2D_G2D_CELL_TRANSFER_MANAGER_H
NNS_G2dFreeCellTransferStateHandle(u32 handle);
#endif // NNS_G2D_G2D_CELL_TRANSFER_MANAGER_H

View File

@ -1,6 +1,34 @@
#ifndef NNSYS_G2D_G2D_MULTICELLANIMATION_H_
#define NNSYS_G2D_G2D_MULTICELLANIMATION_H_
#include <nnsys/g2d/fmt/g2d_Anim_data.h>
#include <nnsys/g2d/fmt/g2d_MultiCell_data.h>
#include <nnsys/g2d/fmt/g2d_SRTControl_data.h>
#include <nnsys/g2d/g2d_Animation.h>
#include <nnsys/g2d/g2d_CellAnimation.h>
typedef enum {
NNS_G2D_MCTYPE_DONOT_SHARE_CELLANIM,
NNS_G2D_MCTYPE_SHARE_CELLANIM
} NNSG2dMCType;
typedef struct NNSG2dMultiCellInstance {
const NNSG2dMultiCellData *pCurrentMultiCell;
const NNSG2dCellAnimBankData *pAnimDataBank;
NNSG2dMCType mcType;
void *pCellAnimInstasnces;
} NNSG2dMultiCellInstance;
typedef NNSG2dAnimBankData NNSG2dMultiCellAnimBankData;
#endif //NNSYS_G2D_G2D_MULTICELLANIMATION_H_
typedef struct NNSG2dMultiCellAnimation {
NNSG2dAnimController animCtrl;
u16 totalVideoFrame;
u16 pad16;
NNSG2dMultiCellInstance multiCellInstance;
const NNSG2dMultiCellDataBank *pMultiCellDataBank;
NNSG2dSRTControl srtCtrl;
} NNSG2dMultiCellAnimation;
#endif // NNSYS_G2D_G2D_MULTICELLANIMATION_H_

View File

@ -1,14 +1,19 @@
#ifndef NNSYS_G2D_G2D_RENDERER_H_
#define NNSYS_G2D_G2D_RENDERER_H_
#include <nnsys/g2d/fmt/g2d_Cell_data.h>
#include <nnsys/g2d/g2d_PaletteTable.h>
#include <nnsys/g2d/g2d_RendererCore.h>
#include <nnsys/g2d/g2d_Vec_data.h>
struct NNSG2dRendererInstance;
struct NNSG2dRenderSurface;
typedef BOOL(*NNSG2dRndCellCullingFunction)(const NNSG2dCellData* pCell, const MtxFx32* pMtx, const NNSG2dViewRect* pViewRec);
typedef BOOL (*NNSG2dRndCellCullingFunction)(const NNSG2dCellData *pCell, const MtxFx32 *pMtx, const NNSG2dViewRect *pViewRec);
typedef void(*NNSG2dRndDrawCellCallBack)(struct NNSG2dRendererInstance* pRend, struct NNSG2dRenderSurface* pSurface, const NNSG2dCellData* pCell, const MtxFx32* pMtx);
typedef void (*NNSG2dRndDrawCellCallBack)(struct NNSG2dRendererInstance *pRend, struct NNSG2dRenderSurface *pSurface, const NNSG2dCellData *pCell, const MtxFx32 *pMtx);
typedef void(*NNSG2dRndDrawOamCallBack)(struct NNSG2dRendererInstance* pRend, struct NNSG2dRenderSurface* pSurface, const NNSG2dCellData* pCell, u16 oamIdx, const MtxFx32* pMtx);
typedef void (*NNSG2dRndDrawOamCallBack)(struct NNSG2dRendererInstance *pRend, struct NNSG2dRenderSurface *pSurface, const NNSG2dCellData *pCell, u16 oamIdx, const MtxFx32 *pMtx);
typedef struct NNSG2dRenderSurface {
union {
@ -25,7 +30,7 @@ typedef struct NNSG2dRenderSurface {
};
NNSG2dOamRegisterFunction pFuncOamRegister;
NNSG2dAffineRegisterFunction pFuncOamAffineRegister;
void* pNextSurface;
void *pNextSurface;
NNSG2dRndCellCullingFunction pFuncVisibilityCulling;
NNSG2dRndDrawCellCallBack pBeforeDrawCellBackFunc;
NNSG2dRndDrawCellCallBack pAfterDrawCellBackFunc;
@ -35,9 +40,9 @@ typedef struct NNSG2dRenderSurface {
typedef struct NNSG2dRendererInstance {
NNSG2dRndCoreInstance rendererCore;
NNSG2dRenderSurface* pTargetSurfaceList;
NNSG2dRenderSurface* pCurrentSurface;
const NNSG2dPaletteSwapTable* pPaletteSwapTbl;
NNSG2dRenderSurface *pTargetSurfaceList;
NNSG2dRenderSurface *pCurrentSurface;
const NNSG2dPaletteSwapTable *pPaletteSwapTbl;
u32 opzHint;
fx32 spriteZoffsetStep;
u32 overwriteEnableFlag;
@ -49,4 +54,4 @@ typedef struct NNSG2dRendererInstance {
u16 pad16_;
} NNSG2dRendererInstance;
#endif //NNSYS_G2D_G2D_RENDERER_H_
#endif // NNSYS_G2D_G2D_RENDERER_H_

View File

@ -1,6 +1,9 @@
#ifndef NNSYS_G2D_G2D_RENDERERCORE_H_
#define NNSYS_G2D_G2D_RENDERERCORE_H_
#include <nnsys/g2d/fmt/g2d_Cell_data.h>
#include <nnsys/g2d/g2d_Vec_data.h>
#define MtxCache_NOT_AVAILABLE 0xFFFF
#define MtxCache_NOT_AVAILABLE_ForMemFill 0xFFFFFFFF
#define NNS_G2D_NUMBER_OF_2DGRAPHICS_ENGINE 2
@ -32,13 +35,13 @@ typedef enum NNSG2dRendererAffineTypeOverwiteMode {
NNS_G2D_RND_AFFINE_OVERWRITE_DOUBLE
} NNSG2dRendererAffineTypeOverwiteMode;
typedef void(*NNSG2dRndCoreDrawCellCallBack)(struct NNSG2dRndCoreInstance* pRend, const NNSG2dCellData* pCell);
typedef void (*NNSG2dRndCoreDrawCellCallBack)(struct NNSG2dRndCoreInstance *pRend, const NNSG2dCellData *pCell);
typedef void(*NNSG2dRndCoreDrawOamCallBack)(struct NNSG2dRndCoreInstance* pRend, const NNSG2dCellData* pCell, u16 oamIdx);
typedef void (*NNSG2dRndCoreDrawOamCallBack)(struct NNSG2dRndCoreInstance *pRend, const NNSG2dCellData *pCell, u16 oamIdx);
typedef BOOL (*NNSG2dOamRegisterFunction) (const GXOamAttr* pOam, u16 affineIndex, BOOL bDoubleAffine);
typedef BOOL (*NNSG2dOamRegisterFunction)(const GXOamAttr *pOam, u16 affineIndex, BOOL bDoubleAffine);
typedef u16 (*NNSG2dAffineRegisterFunction) (const MtxFx22* mtx);
typedef u16 (*NNSG2dAffineRegisterFunction)(const MtxFx22 *mtx);
typedef struct NNSG2dRndCoreSurface {
NNSG2dViewRect viewRect;
@ -51,22 +54,26 @@ typedef struct NNSG2dRndCoreSurface {
} NNSG2dRndCoreSurface;
typedef struct NNSG2dRndCoreInstance {
NNSG2dRndCoreSurface* pCurrentTargetSurface;
NNSG2dRndCoreSurface *pCurrentTargetSurface;
NNSG2dRendererAffineTypeOverwiteMode affineOverwriteMode;
const struct NNSG2dImageProxy* pImgProxy;
const struct NNSG2dImagePaletteProxy* pPltProxy;
const struct NNSG2dImageProxy *pImgProxy;
const struct NNSG2dImagePaletteProxy *pPltProxy;
u32 base2DCharOffset;
u32 baseTexAddr3D;
u32 basePltAddr3D;
NNSG2dOamRegisterFunction pFuncOamRegister;
NNSG2dAffineRegisterFunction pFuncOamAffineRegister;
u32 flipFlag;
NNSG2dRndCore2DMtxCache* pCurrentMtxCacheFor2D;
const MtxFx32* pCurrentMxt;
NNSG2dRndCore2DMtxCache *pCurrentMtxCacheFor2D;
const MtxFx32 *pCurrentMxt;
BOOL bDrawEnable;
fx32 zFor3DSoftwareSprite;
GXOamAttr currentOam;
MtxFx43 mtxFor3DGE;
} NNSG2dRndCoreInstance;
#endif //NNSYS_G2D_G2D_RENDERERCORE_H_
void NNS_G2dSetRndCoreOamRegisterFunc(NNSG2dRndCoreInstance *pRnd, NNSG2dOamRegisterFunction pFuncOamRegister, NNSG2dAffineRegisterFunction pFuncOamAffineRegister);
void NNS_G2dSetRndCoreAffineOverwriteMode(NNSG2dRndCoreInstance *pRnd, NNSG2dRendererAffineTypeOverwiteMode mode);
void NNS_G2dSetRndCoreFlipMode(NNSG2dRndCoreInstance *pRnd, BOOL bFlipH, BOOL bFlipV);
#endif // NNSYS_G2D_G2D_RENDERERCORE_H_

View File

@ -1,6 +1,8 @@
#ifndef NNSYS_G2D_G2D_VEC_DATA_H_
#define NNSYS_G2D_G2D_VEC_DATA_H_
#include <nitro.h>
typedef struct NNSG2dSVec2 {
s16 x;
s16 y;
@ -21,4 +23,4 @@ typedef union {
fx32 a[6];
} MtxFx32;
#endif //NNSYS_G2D_G2D_VEC_DATA_H_
#endif // NNSYS_G2D_G2D_VEC_DATA_H_

View File

@ -80,6 +80,8 @@ Static main
Object src/gf_gfx_planes.o
Object src/camera.o
Object asm/unk_02023694.o
Object src/sprite.o
Object asm/sprite_s.o
Object src/touchscreen.o
Object src/timer3.o
Object src/error_handling.o

View File

@ -18,6 +18,7 @@
#include "render_window.h"
#include "save_vars_flags.h"
#include "sound_02004A44.h"
#include "sprite.h"
#include "sys_flags.h"
#include "system.h"
#include "text.h"
@ -28,7 +29,6 @@
#include "unk_0200FA24.h"
#include "unk_020183F0.h"
#include "unk_020210A0.h"
#include "unk_02023694.h"
#include "vram_transfer_manager.h"
#include "yes_no_prompt.h"

View File

@ -17,6 +17,7 @@
#include "player_data.h"
#include "render_window.h"
#include "save_rankings.h"
#include "sprite.h"
#include "system.h"
#include "text.h"
#include "unk_02005D10.h"
@ -26,7 +27,6 @@
#include "unk_0200B150.h"
#include "unk_0200FA24.h"
#include "unk_02022588.h"
#include "unk_02023694.h"
#include "unk_02097D3C.h"
#include "vram_transfer_manager.h"
#include "yes_no_prompt.h"

View File

@ -20,6 +20,7 @@
#include "render_window.h"
#include "save_misc_data.h"
#include "sound_02004A44.h"
#include "sprite.h"
#include "system.h"
#include "text.h"
#include "touchscreen.h"
@ -29,7 +30,6 @@
#include "unk_0200FA24.h"
#include "unk_020183F0.h"
#include "unk_020210A0.h"
#include "unk_02023694.h"
#include "vram_transfer_manager.h"
#include "yes_no_prompt.h"

View File

@ -17,6 +17,7 @@
#include "render_text.h"
#include "render_window.h"
#include "sound.h"
#include "sprite.h"
#include "system.h"
#include "text.h"
#include "touchscreen.h"
@ -28,7 +29,6 @@
#include "unk_02013FDC.h"
#include "unk_02020B8C.h"
#include "unk_02022588.h"
#include "unk_02023694.h"
#include "unk_02026E30.h"
enum ChooseStarterInput {

View File

@ -12,6 +12,7 @@
#include "overlay_manager.h"
#include "sound.h"
#include "sound_02004A44.h"
#include "sprite.h"
#include "sys_task_api.h"
#include "system.h"
#include "text.h"
@ -21,7 +22,6 @@
#include "unk_0200B150.h"
#include "unk_0200FA24.h"
#include "unk_02022588.h"
#include "unk_02023694.h"
#ifdef HEARTGOLD
#define GAME_TITLE_MSG_NO 0

View File

@ -36,6 +36,7 @@
#include "system.h"
#include "unk_02005D10.h"
#include "unk_0200FA24.h"
#include "unk_02023694.h"
#include "unk_02030A98.h"
#include "unk_02031904.h"
#include "unk_02031AF0.h"

View File

@ -12,13 +12,13 @@
#include "math_util.h"
#include "obj_char_transfer.h"
#include "sound_02004A44.h"
#include "sprite.h"
#include "sys_task_api.h"
#include "system.h"
#include "title_screen.h"
#include "unk_0200B150.h"
#include "unk_0200FA24.h"
#include "unk_02022588.h"
#include "unk_02023694.h"
enum IntroMovieOverlayState {
INTRO_MOVIE_INIT,

View File

@ -13,7 +13,7 @@ static const UnkStruct_0200D2B4 sSpriteTemplates[] = {
.z = 0,
.animSeqNo = 0,
.rotation = 2,
.unk_10 = 1,
.palIndex = 1,
.whichScreen = NNS_G2D_VRAM_TYPE_2DMAIN,
.unk_18 = 0,
.unk_1C = 0,
@ -27,7 +27,7 @@ static const UnkStruct_0200D2B4 sSpriteTemplates[] = {
.z = 0,
.animSeqNo = 0,
.rotation = 0,
.unk_10 = 0,
.palIndex = 0,
.whichScreen = NNS_G2D_VRAM_TYPE_2DSUB,
.unk_18 = 0,
.unk_1C = 0,
@ -41,7 +41,7 @@ static const UnkStruct_0200D2B4 sSpriteTemplates[] = {
.z = 0,
.animSeqNo = 0,
.rotation = 1,
.unk_10 = 1,
.palIndex = 1,
.whichScreen = NNS_G2D_VRAM_TYPE_2DSUB,
.unk_18 = 0,
.unk_1C = 0,
@ -55,7 +55,7 @@ static const UnkStruct_0200D2B4 sSpriteTemplates[] = {
.z = 0,
.animSeqNo = 0,
.rotation = 0,
.unk_10 = 3,
.palIndex = 3,
.whichScreen = NNS_G2D_VRAM_TYPE_2DSUB,
.unk_18 = 0,
.unk_1C = 0,
@ -69,7 +69,7 @@ static const UnkStruct_0200D2B4 sSpriteTemplates[] = {
.z = 0,
.animSeqNo = 1,
.rotation = 0,
.unk_10 = 4,
.palIndex = 4,
.whichScreen = NNS_G2D_VRAM_TYPE_2DSUB,
.unk_18 = 0,
.unk_1C = 0,
@ -83,7 +83,7 @@ static const UnkStruct_0200D2B4 sSpriteTemplates[] = {
.z = 0,
.animSeqNo = 0,
.rotation = 0,
.unk_10 = 4,
.palIndex = 4,
.whichScreen = NNS_G2D_VRAM_TYPE_2DMAIN,
.unk_18 = 0,
.unk_1C = 0,
@ -100,7 +100,6 @@ void OakSpeech_InitSpriteEngine(OakSpeechData *data) {
data->spriteGfxHandler = SpriteRenderer_CreateGfxHandler(data->spriteRenderer);
{
// extern const OamManagerParam ov53_021E8764;
OamManagerParam oamManagerParam = {
.fromOBJmain = 0,
.numOBJmain = 128,
@ -112,7 +111,6 @@ void OakSpeech_InitSpriteEngine(OakSpeechData *data) {
.numAffineSub = 32,
};
// extern const OamCharTransferParam ov53_021E8750;
OamCharTransferParam oamCharTransferParam = {
.maxTasks = 10,
.sizeMain = 0x400,
@ -125,7 +123,7 @@ void OakSpeech_InitSpriteEngine(OakSpeechData *data) {
}
sub_0200CFF4(data->spriteRenderer, data->spriteGfxHandler, 10);
G2dRenderer_SetSubSurfaceCoords(SpriteRenderer_GetG2dRendererPtr(data->spriteRenderer), 0, FX32_CONST(192));
G2dRenderer_SetSubSurfaceCoords(SpriteRenderer_GetG2dRendererPtr(data->spriteRenderer), 0, FX32_CONST(GX_LCD_SIZE_Y));
{
// extern const u16 ov53_021E8740[7];

View File

@ -16,13 +16,13 @@
#include "render_text.h"
#include "render_window.h"
#include "sound.h"
#include "sprite.h"
#include "system.h"
#include "touchscreen.h"
#include "unk_02005D10.h"
#include "unk_0200CF18.h"
#include "unk_0200FA24.h"
#include "unk_020183F0.h"
#include "unk_02023694.h"
#include "unk_0203A3B0.h"
#include "vram_transfer_manager.h"
@ -180,7 +180,7 @@ static const UnkStruct_0200D2B4 ov54_021E6EAC[9] = {
.z = 0,
.animSeqNo = 0,
.rotation = 1,
.unk_10 = 0,
.palIndex = 0,
.whichScreen = NNS_G2D_VRAM_TYPE_2DMAIN,
.unk_18 = 0,
.unk_1C = 0,
@ -194,7 +194,7 @@ static const UnkStruct_0200D2B4 ov54_021E6EAC[9] = {
.z = 0,
.animSeqNo = 0,
.rotation = 1,
.unk_10 = 0,
.palIndex = 0,
.whichScreen = NNS_G2D_VRAM_TYPE_2DMAIN,
.unk_18 = 0,
.unk_1C = 0,
@ -208,7 +208,7 @@ static const UnkStruct_0200D2B4 ov54_021E6EAC[9] = {
.z = 0,
.animSeqNo = 1,
.rotation = 1,
.unk_10 = 0,
.palIndex = 0,
.whichScreen = NNS_G2D_VRAM_TYPE_2DMAIN,
.unk_18 = 0,
.unk_1C = 0,
@ -222,7 +222,7 @@ static const UnkStruct_0200D2B4 ov54_021E6EAC[9] = {
.z = 0,
.animSeqNo = 1,
.rotation = 1,
.unk_10 = 0,
.palIndex = 0,
.whichScreen = NNS_G2D_VRAM_TYPE_2DMAIN,
.unk_18 = 0,
.unk_1C = 0,
@ -236,7 +236,7 @@ static const UnkStruct_0200D2B4 ov54_021E6EAC[9] = {
.z = 0,
.animSeqNo = 1,
.rotation = 1,
.unk_10 = 0,
.palIndex = 0,
.whichScreen = NNS_G2D_VRAM_TYPE_2DMAIN,
.unk_18 = 0,
.unk_1C = 0,
@ -250,7 +250,7 @@ static const UnkStruct_0200D2B4 ov54_021E6EAC[9] = {
.z = 0,
.animSeqNo = 0,
.rotation = 1,
.unk_10 = 0,
.palIndex = 0,
.whichScreen = NNS_G2D_VRAM_TYPE_2DMAIN,
.unk_18 = 0,
.unk_1C = 0,
@ -264,7 +264,7 @@ static const UnkStruct_0200D2B4 ov54_021E6EAC[9] = {
.z = 0,
.animSeqNo = 0,
.rotation = 1,
.unk_10 = 0,
.palIndex = 0,
.whichScreen = NNS_G2D_VRAM_TYPE_2DMAIN,
.unk_18 = 0,
.unk_1C = 0,
@ -278,7 +278,7 @@ static const UnkStruct_0200D2B4 ov54_021E6EAC[9] = {
.z = 0,
.animSeqNo = 0,
.rotation = 1,
.unk_10 = 1,
.palIndex = 1,
.whichScreen = NNS_G2D_VRAM_TYPE_2DMAIN,
.unk_18 = 0,
.unk_1C = 0,
@ -292,7 +292,7 @@ static const UnkStruct_0200D2B4 ov54_021E6EAC[9] = {
.z = 0,
.animSeqNo = 0,
.rotation = 1,
.unk_10 = 1,
.palIndex = 1,
.whichScreen = NNS_G2D_VRAM_TYPE_2DMAIN,
.unk_18 = 0,
.unk_1C = 0,

View File

@ -409,7 +409,7 @@ void sub_0207EBE4(PartyMenu *partyMenu, u8 partySlot, u16 x, u16 y, NARC *narc)
sp1C.z = 0;
sp1C.animSeqNo = 0;
sp1C.rotation = 0;
sp1C.unk_10 = GetMonIconPaletteEx(partyMenu->monsDrawState[partySlot].species, partyMenu->monsDrawState[partySlot].form, isEgg) + 3;
sp1C.palIndex = GetMonIconPaletteEx(partyMenu->monsDrawState[partySlot].species, partyMenu->monsDrawState[partySlot].form, isEgg) + 3;
sp1C.whichScreen = NNS_G2D_VRAM_TYPE_2DMAIN;
sp1C.unk_18 = 0;
sp1C.unk_1C = 0;
@ -417,7 +417,7 @@ void sub_0207EBE4(PartyMenu *partyMenu, u8 partySlot, u16 x, u16 y, NARC *narc)
sp1C.unk_24 = 0;
partyMenu->monsDrawState[partySlot].iconSprite = SpriteRenderer_CreateSprite(partyMenu->spriteRenderer, partyMenu->spriteGfxHandler, &sp1C);
sp1C.whichScreen = NNS_G2D_VRAM_TYPE_2DMAIN;
sp1C.unk_10 = GetMonIconPaletteEx(partyMenu->monsDrawState[partySlot].species, partyMenu->monsDrawState[partySlot].form, isEgg) + 1;
sp1C.palIndex = GetMonIconPaletteEx(partyMenu->monsDrawState[partySlot].species, partyMenu->monsDrawState[partySlot].form, isEgg) + 1;
sp1C.x = x;
sp1C.y = y + 0x100;
partyMenu->monsDrawState[partySlot].mainScreenIconSprite = SpriteRenderer_CreateSprite(partyMenu->spriteRenderer, partyMenu->spriteGfxHandler, &sp1C);
@ -484,7 +484,7 @@ void sub_0207EF5C(PartyMenu *partyMenu, u8 partySlot, u16 x, u16 y) {
sp0.y = y;
sp0.z = 0;
sp0.animSeqNo = 0;
sp0.unk_10 = 0;
sp0.palIndex = 0;
sp0.unk_18 = 0;
sp0.unk_1C = 0;
sp0.unk_20 = 0;

View File

@ -19,11 +19,11 @@
#include "party.h"
#include "seal_case.h"
#include "sound_02004A44.h"
#include "sprite.h"
#include "trainer_data.h"
#include "trainer_memo.h"
#include "unk_0200CF18.h"
#include "unk_02016EDC.h"
#include "unk_02023694.h"
#include "unk_02078834.h"
void MonEncryptSegment(void *data, u32 size, u32 key);

200
src/sprite.c Normal file
View File

@ -0,0 +1,200 @@
#include "sprite.h"
#include "global.h"
#include "math_util.h"
#include "system.h"
BOOL sub_02024544(SpriteList *spriteList);
void sub_020245D4(SpriteList *spriteList);
void sub_020245FC(Sprite *sprite);
void sub_02024EB4(SpriteList *spriteList, Sprite *sprite);
void sub_02025010(SpriteList *spriteList, Sprite *sprite);
void sub_02025014(Sprite *sprite);
void sub_02025020(Sprite *sprite);
void sub_020250D8(SpriteList *spriteList);
Sprite *sub_02025110(SpriteList *spriteList);
BOOL sub_02024CD0(SpriteList *spriteList, const SpriteResourcesHeader *resHdr, Sprite *sprite, HeapID heapId);
u8 sub_02024E84(NNSG2dImagePaletteProxy *proxy, NNS_G2D_VRAM_TYPE vramType);
void sub_02025024(SpriteList *spriteList, Sprite *sprite);
void sub_020250BC(Sprite *sprite);
void sub_0202512C(SpriteList *spriteList, Sprite *sprite);
static void (*const _020F6314[2])(SpriteList *spriteList, Sprite *sprite) = {
sub_02025010,
sub_02024EB4,
};
static void (*const _020F631C[2])(Sprite *sprite) = {
sub_02025020,
sub_02025014,
};
SpriteList *SpriteList_Create(SpriteListParam *param) {
GF_ASSERT(param != NULL);
GF_ASSERT(param->rendererInstance != NULL);
SpriteList *ret = AllocFromHeap(param->heapId, sizeof(SpriteList));
GF_ASSERT(ret != NULL);
sub_020245D4(ret);
ret->sprites = AllocFromHeap(param->heapId, param->num * sizeof(Sprite));
GF_ASSERT(ret->sprites != NULL);
ret->numSprites = param->num;
ret->stack = AllocFromHeap(param->heapId, param->num * sizeof(Sprite *));
GF_ASSERT(ret->stack != NULL);
sub_020250D8(ret);
sub_020245FC(&ret->dummy);
ret->dummy.prev = &ret->dummy;
ret->dummy.next = &ret->dummy;
ret->renderer = param->rendererInstance;
ret->animBuff = Sys_AllocAndReadFile(param->heapId, "data/clact_default.NANR");
NNS_G2dGetUnpackedAnimBank(ret->animBuff, &ret->animBank);
ret->flag = TRUE;
return ret;
}
BOOL SpriteList_Delete(SpriteList *spriteList) {
if (spriteList == NULL) {
return FALSE;
}
if (spriteList->sprites == NULL) {
return TRUE;
}
sub_02024544(spriteList);
FreeToHeap(spriteList->animBuff);
FreeToHeap(spriteList->stack);
FreeToHeap(spriteList->sprites);
sub_020245D4(spriteList);
FreeToHeap(spriteList);
return TRUE;
}
BOOL sub_02024544(SpriteList *spriteList) {
if (spriteList == NULL) {
return FALSE;
}
if (spriteList->sprites == NULL) {
return TRUE;
}
Sprite *sprite = spriteList->dummy.next;
while (sprite != &spriteList->dummy) {
Sprite *next = sprite->next;
Sprite_Delete(sprite);
sprite = next;
}
return TRUE;
}
void sub_0202457C(SpriteList *spriteList) {
GF_ASSERT(spriteList != NULL);
if (!spriteList->flag) {
return;
}
Sprite *sprite = spriteList->dummy.next;
while (sprite != &spriteList->dummy) {
_020F6314[sprite->drawFlag](spriteList, sprite);
_020F631C[sprite->animationFrame](sprite);
sprite = sprite->next;
}
}
void sub_020245D4(SpriteList *spriteList) {
spriteList->sprites = NULL;
spriteList->numSprites = 0;
spriteList->stack = NULL;
spriteList->stackPointer = 0;
spriteList->renderer = NULL;
sub_020245FC(&spriteList->dummy);
spriteList->flag = FALSE;
}
void sub_020245FC(Sprite *sprite) {
sprite->spriteList = NULL;
memset(sprite, 0, sizeof(Sprite));
NNS_G2dInitImageProxy(&sprite->imageProxy);
NNS_G2dInitImagePaletteProxy(&sprite->paletteProxy);
sprite->mode = GX_OAM_MODE_NORMAL;
}
Sprite *CreateSprite(const SpriteTemplate *template) {
Sprite *sprite = sub_02025110(template->spriteList);
if (sprite == NULL) {
return NULL;
}
sprite->spriteList = template->spriteList;
sprite->animationNo = 0;
sprite->matrix = template->position;
sprite->scale = template->scale;
sprite->rotation = template->rotation;
sprite->type = template->whichScreen;
sprite->drawPriority = template->priority;
sprite->affine = 0;
sprite->flip = 0;
sprite->mosaic = FALSE;
sprite->mode = GX_OAM_MODE_NORMAL;
sprite->overwrite = 0x11;
NNS_G2dSetRndCoreAffineOverwriteMode(&template->spriteList->renderer->rendererCore, (NNSG2dRendererAffineTypeOverwiteMode)sprite->affine);
NNS_G2dSetRndCoreFlipMode(&template->spriteList->renderer->rendererCore, sprite->flip & 1, sprite->flip & 2);
sprite->drawFlag = 1;
sprite->animationFrame = 0;
sprite->frame = FX32_CONST(2);
if (!sub_02024CD0(template->spriteList, template->header, sprite, template->heapId)) {
Sprite_Delete(sprite);
return NULL;
}
sprite->palOffset = sub_02024E84(&sprite->paletteProxy, sprite->type);
sprite->palIndex = sprite->palOffset;
sub_02025024(template->spriteList, sprite);
return sprite;
}
Sprite *sub_02024714(const SimpleSpriteTemplate *simpleTemplate) {
SpriteTemplate template;
template.spriteList = simpleTemplate->spriteList;
template.header = simpleTemplate->header;
template.position = simpleTemplate->position;
SetVecFx32(template.scale, FX32_ONE, FX32_ONE, FX32_ONE);
template.rotation = 0;
template.priority = simpleTemplate->priority;
template.whichScreen = simpleTemplate->whichScreen;
template.heapId = simpleTemplate->heapId;
return CreateSprite(&template);
}
void Sprite_Delete(Sprite *sprite) {
if (sprite->flag == 0) {
return;
}
if (sprite->prev != NULL) {
sub_020250BC(sprite);
}
if (sprite->flag == 3) {
SpriteAnimationData2 *anim = (SpriteAnimationData2 *)sprite->animationData;
if (NNS_G2dGetImageLocation(&sprite->imageProxy, sprite->type) != -1u) {
NNS_G2dFreeCellTransferStateHandle(anim->cellTransferStateHandle);
}
}
if (sprite->flag == 2) {
SpriteMultiAnimationData *anim = (SpriteMultiAnimationData *)sprite->animationData;
if (anim->node != NULL) {
FreeToHeap(anim->node);
}
if (anim->cellAnim != NULL) {
FreeToHeap(anim->cellAnim);
}
}
sprite->flag = 0;
sub_0202512C(sprite->spriteList, sprite);
}

View File

@ -3,10 +3,10 @@
#include "global.h"
#include "obj_char_transfer.h"
#include "sprite.h"
#include "unk_0200ACF0.h"
#include "unk_0200B150.h"
#include "unk_02022588.h"
#include "unk_02023694.h"
#include "unk_02025C44.h"
void CreateSpriteResourcesHeader(struct SpriteResourcesHeader *hdr, int charId, int plttId, int cellId, int cellAnmId, int multiCellId, int multiCellAnmId, int transfer, int priority, GF_2DGfxResMan *charMan, GF_2DGfxResMan *plttMan, GF_2DGfxResMan *cellMan, GF_2DGfxResMan *cellAnmMan, GF_2DGfxResMan *multiCellMan, GF_2DGfxResMan *multiCellAnmMan) {
@ -113,7 +113,7 @@ SpriteList *G2dRenderer_Init(int a0, GF_G2dRenderer *renderer, HeapID heapId) {
rect.sizeView.x = 255 * FX32_ONE;
rect.sizeView.y = 192 * FX32_ONE;
sub_0200B27C(&renderer->renderSurface[1], &rect, 2, &renderer->rendererInstance);
param.unk_0 = a0;
param.num = a0;
param.rendererInstance = &renderer->rendererInstance;
param.heapId = heapId;
return SpriteList_Create(&param);

View File

@ -7,12 +7,12 @@
#include "heap.h"
#include "obj_char_transfer.h"
#include "palette.h"
#include "sprite.h"
#include "unk_02009D48.h"
#include "unk_0200ACF0.h"
#include "unk_0200B150.h"
#include "unk_02020654.h"
#include "unk_02022588.h"
#include "unk_02023694.h"
static void SpriteGfxHandler_DeleteSpriteList(SpriteGfxHandler *gfxHandler);
static void SpriteGfxHandler_DeleteResourceHeaderList(SpriteGfxHandler *gfxHandler);
@ -236,8 +236,8 @@ BOOL sub_0200D2A4(SpriteRenderer *renderer, SpriteGfxHandler *gfxHandler, const
return sub_0200D124(renderer, gfxHandler, fileIdList, loadCharMode, loadPlttMode);
}
Sprite *SpriteRenderer_CreateSprite(SpriteRenderer *renderer, SpriteGfxHandler *gfxHandler, const UnkStruct_0200D2B4 *a2) {
return MyCreateSprite(renderer, gfxHandler, a2->resourceSet, a2->x, a2->y, a2->x /* typo? */, a2->animSeqNo, a2->rotation, a2->unk_10, a2->whichScreen, a2->unk_18, a2->unk_1C, a2->unk_20, a2->unk_24);
Sprite *SpriteRenderer_CreateSprite(SpriteRenderer *renderer, SpriteGfxHandler *gfxHandler, const UnkStruct_0200D2B4 *template) {
return MyCreateSprite(renderer, gfxHandler, template->resourceSet, template->x, template->y, template->x /* typo? */, template->animSeqNo, template->rotation, template->palIndex, template->whichScreen, template->unk_18, template->unk_1C, template->unk_20, template->unk_24);
}
static Sprite *MyCreateSprite(SpriteRenderer *renderer, SpriteGfxHandler *gfxHandler, int headerIndex, s16 x, s16 y, s16 z, u16 animSeqNo, int priority, int palIndex, NNS_G2D_VRAM_TYPE whichScreen, int a10, int a11, int a12, int a13) {

View File

@ -30,6 +30,7 @@
#include "render_text.h"
#include "render_window.h"
#include "sound_02004A44.h"
#include "sprite.h"
#include "system.h"
#include "text.h"
#include "touchscreen.h"
@ -38,7 +39,6 @@
#include "unk_0200CF18.h"
#include "unk_0200FA24.h"
#include "unk_020183F0.h"
#include "unk_02023694.h"
#include "yes_no_prompt.h"
typedef enum CoinDisplay {