sub_02026EB4

This commit is contained in:
PikalaxALT 2022-03-06 09:59:32 -05:00
parent 6225e2cbd9
commit d427fc556b
15 changed files with 156 additions and 89 deletions

View File

@ -3,84 +3,6 @@
.text
thumb_func_start sub_02026EB4
sub_02026EB4: ; 0x02026EB4
push {r3, r4, r5, r6, r7, lr}
sub sp, #8
add r7, r1, #0
mov r1, #0xc
add r6, r0, #0
add r5, r2, #0
str r3, [sp, #4]
bl AllocFromHeap
add r4, r0, #0
str r6, [r4]
bl NNS_G3dInit
bl G3X_InitMtxStack
mov r1, #2
ldr r0, _02026F50 ; =0x04000540
cmp r7, #0
str r1, [r0]
bne _02026F00
lsl r0, r5, #7
bl NNS_GfdGetLnkTexVramManagerWorkSize
add r6, r0, #0
ldr r0, [r4]
add r1, r6, #0
bl AllocFromHeap
str r0, [r4, #8]
mov r0, #1
str r0, [sp]
ldr r2, [r4, #8]
lsl r0, r5, #0x11
mov r1, #0
add r3, r6, #0
bl sub_02026FE8
b _02026F0A
_02026F00:
lsl r0, r5, #0x10
lsr r0, r0, #0x10
mov r1, #1
bl sub_02027000
_02026F0A:
ldr r0, [sp, #4]
cmp r0, #0
bne _02026F34
ldr r0, [sp, #0x20]
lsl r0, r0, #8
bl NNS_GfdGetLnkPlttVramManagerWorkSize
add r5, r0, #0
ldr r0, [r4]
add r1, r5, #0
bl AllocFromHeap
str r0, [r4, #4]
ldr r0, [sp, #0x20]
ldr r1, [r4, #4]
lsl r0, r0, #0xd
add r2, r5, #0
mov r3, #1
bl sub_02026FF8
b _02026F3C
_02026F34:
ldr r0, [sp, #0x20]
mov r1, #1
bl sub_02027008
_02026F3C:
ldr r0, [sp, #0x24]
cmp r0, #0
beq _02026F46
blx r0
b _02026F4A
_02026F46:
bl sub_02026F6C
_02026F4A:
add r0, r4, #0
add sp, #8
pop {r3, r4, r5, r6, r7, pc}
.balign 4, 0
_02026F50: .word 0x04000540
thumb_func_end sub_02026EB4
thumb_func_start sub_02026F54
sub_02026F54: ; 0x02026F54
push {r4, lr}

12
include/unk_02026EB4.h Normal file
View File

@ -0,0 +1,12 @@
#ifndef POKEHEARTGOLD_UNK_02026EB4_H
#define POKEHEARTGOLD_UNK_02026EB4_H
#include "heap.h"
struct Unk3Dstruct_02026EB4 {
HeapID heapId;
void *plttWork;
void *texWork;
};
#endif //POKEHEARTGOLD_UNK_02026EB4_H

View File

@ -5,6 +5,8 @@
#include <nitro/gx/gx_bgcnt.h>
#include <nitro/gx/g2.h>
#include <nitro/gx/g3.h>
#include <nitro/gx/g3x.h>
#include <nitro/gx/g3imm.h>
#include <nitro/gx/gx_load.h>
#ifdef SDK_ARM9

View File

@ -1,18 +1,27 @@
#ifndef NITRO_GX_GX_G2_H_
#define NITRO_GX_GX_G2_H_
void G2x_SetBGyAffine_(u32 ptr, const MtxFx22 *mtx, fx32 a, fx32 b, fx32 c, fx32 d);
void G2x_SetBlendAlpha_(u32 *ptr, fx32 a, fx32 b, fx32 c, fx32 d);
void G2x_SetBGyAffine_(u32 addr, const MtxFx22 *mtx, fx32 a, fx32 b, fx32 c, fx32 d);
void G2x_SetBlendAlpha_(u32 addr, int plane1, int plane2, int ev1, int ev2);
void G2x_SetBlendBrightness_(u16 *ptr, fx32 a, fx32 brightness);
void G2x_SetBlendBrightnessExt_(u16 *ptr, fx32 a, fx32 b, fx32 c, fx32 d, fx32 brightness);
void G2x_ChangeBlendBrightness_(u16 *ptr, fx32 brightness);
typedef struct {
u8 planeMask:5;
u8 effect:1;
u8 _reserve:2;
}
GXWndPlane;
u8 planeMask:5;
u8 effect:1;
u8 _reserve:2;
} GXWndPlane;
typedef enum {
GX_BLEND_PLANEMASK_NONE = 0x0000,
GX_BLEND_PLANEMASK_BG0 = 0x0001,
GX_BLEND_PLANEMASK_BG1 = 0x0002,
GX_BLEND_PLANEMASK_BG2 = 0x0004,
GX_BLEND_PLANEMASK_BG3 = 0x0008,
GX_BLEND_PLANEMASK_OBJ = 0x0010,
GX_BLEND_PLANEMASK_BD = 0x0020
} GXBlendPlaneMask;
typedef enum {
GX_WND_PLANEMASK_NONE = 0x0000,
@ -21,8 +30,7 @@ typedef enum {
GX_WND_PLANEMASK_BG2 = 0x0004,
GX_WND_PLANEMASK_BG3 = 0x0008,
GX_WND_PLANEMASK_OBJ = 0x0010
}
GXWndPlaneMask;
} GXWndPlaneMask;
static inline void G2_SetWndOutsidePlane(int wnd, BOOL effect) {
u32 tmp;
@ -100,6 +108,14 @@ static inline void G2S_BlendNone(void) {
reg_G2S_DB_BLDCNT = 0;
}
static inline void G2_SetBlendAlpha(int plane1, int plane2, int ev1, int ev2) {
G2x_SetBlendAlpha_((u32)&reg_G2_BLDCNT, plane1, plane2, ev1, ev2);
}
static inline void G2S_SetBlendAlpha(int plane1, int plane2, int ev1, int ev2) {
G2x_SetBlendAlpha_((u32)&reg_G2S_DB_BLDCNT, plane1, plane2, ev1, ev2);
}
//The g2 and g2_oam headers contain a lot of inline functions and enums that may want to be ported over at some point
#endif //NITRO_GX_GX_G2_H_

View File

@ -0,0 +1,22 @@
#ifndef NITRO_GX_G3IMM_H_
#define NITRO_GX_G3IMM_H_
typedef enum {
GX_SORTMODE_AUTO = 0,
GX_SORTMODE_MANUAL = 1
} GXSortMode;
typedef enum {
GX_BUFFERMODE_Z = 0,
GX_BUFFERMODE_W = 1
} GXBufferMode;
#define GX_PACK_SWAPBUFFERS_PARAM(am, zw) \
((u32) (((am) << REG_G3_SWAP_BUFFERS_XS_SHIFT) | \
((zw) << REG_G3_SWAP_BUFFERS_DP_SHIFT)))
static inline void G3_SwapBuffers(GXSortMode am, GXBufferMode zw) {
reg_G3_SWAP_BUFFERS = GX_PACK_SWAPBUFFERS_PARAM(am, zw);
}
#endif //NITRO_GX_G3IMM_H_

View File

@ -0,0 +1,10 @@
#ifndef NITRO_GX_G3X_H_
#define NITRO_GX_G3X_H_
void G3X_Init(void);
void G3X_InitMtxStack(void);
void G3X_ResetMtxStack(void);
void G3X_InitTable(void);
void G3X_Reset(void);
#endif //NITRO_GX_G3X_H_

View File

@ -96,4 +96,26 @@
((u32)(send_emp) << REG_PXI_FIFO_CNT_SEND_EMP_SHIFT))
#endif
#define REG_G3_SWAP_BUFFERS_DP_SHIFT 1
#define REG_G3_SWAP_BUFFERS_DP_SIZE 1
#define REG_G3_SWAP_BUFFERS_DP_MASK 0x00000002
#define REG_G3_SWAP_BUFFERS_XS_SHIFT 0
#define REG_G3_SWAP_BUFFERS_XS_SIZE 1
#define REG_G3_SWAP_BUFFERS_XS_MASK 0x00000001
#define REG_G3_SWAP_BUFFERS_DP_SHIFT 1
#define REG_G3_SWAP_BUFFERS_DP_SIZE 1
#define REG_G3_SWAP_BUFFERS_DP_MASK 0x00000002
#define REG_G3_SWAP_BUFFERS_XS_SHIFT 0
#define REG_G3_SWAP_BUFFERS_XS_SIZE 1
#define REG_G3_SWAP_BUFFERS_XS_MASK 0x00000001
#ifndef SDK_ASM
#define REG_G3_SWAP_BUFFERS_FIELD( dp, xs ) \
(u32)( \
((u32)(dp) << REG_G3_SWAP_BUFFERS_DP_SHIFT) | \
((u32)(xs) << REG_G3_SWAP_BUFFERS_XS_SHIFT))
#endif
#endif //NITRO_IO_REG_H_

View File

@ -4,6 +4,7 @@
#include <nnsys/g3d/binres/res_struct.h>
#include <nnsys/g3d/config.h>
#include <nnsys/g3d/kernel.h>
#include <nnsys/g3d/util.h>
#include <nnsys/g3d/glbstate.h>
#endif //NNSYS_G3D_H_

View File

@ -0,0 +1,6 @@
#ifndef NNS_G3D_UTIL_H_
#define NNS_G3D_UTIL_H_
void NNS_G3dInit(void);
#endif //NNS_G3D_UTIL_H_

View File

@ -2,6 +2,8 @@
#define NNSYS_GFD_H
#include <nnsys/gfd/VramManager/gfd_TexVramMan_Types.h>
#include <nnsys/gfd/VramManager/gfd_LinkedListTexVramMan.h>
#include <nnsys/gfd/VramManager/gfd_LinkedListPlttVramMan.h>
#include <nnsys/gfd/VramTransferMan/gfd_VramTransferManager.h>
#endif //NNSYS_GFD_H

View File

@ -0,0 +1,6 @@
#ifndef NNSYS_GFD_VRAMMANAGER_GFD_LINKEDLISTPLTTVRAMMAN_H_
#define NNSYS_GFD_VRAMMANAGER_GFD_LINKEDLISTPLTTVRAMMAN_H_
u32 NNS_GfdGetLnkPlttVramManagerWorkSize( u32 numMemBlk );
#endif //NNSYS_GFD_VRAMMANAGER_GFD_LINKEDLISTPLTTVRAMMAN_H_

View File

@ -0,0 +1,6 @@
#ifndef NNSYS_GFD_VRAMMANAGER_GFD_LINKEDLISTTEXVRAMMAN_H_
#define NNSYS_GFD_VRAMMANAGER_GFD_LINKEDLISTTEXVRAMMAN_H_
u32 NNS_GfdGetLnkTexVramManagerWorkSize( u32 numMemBlk );
#endif //NNSYS_GFD_VRAMMANAGER_GFD_LINKEDLISTTEXVRAMMAN_H_

View File

@ -85,7 +85,8 @@ Static main
Object asm/unk_02026DE0.o
Object asm/unk_02026E30.o
Object asm/unk_02026E84.o
Object asm/unk_02026EB4.o
Object src/unk_02026EB4.o
Object asm/unk_02026EB4_s.o
Object asm/unk_02027010.o
Object src/save_arrays.o
Object src/save.o

39
src/unk_02026EB4.c Normal file
View File

@ -0,0 +1,39 @@
#include "unk_02026EB4.h"
void sub_02026FE8(u32 szByte, u32 szByteFor4x4, void *pManagementWork, u32 szByteManagementWork, BOOL useAsDefault);
void sub_02026FF8(u32 szByte, void *pManagementWork, u32 szByteManagementWork, BOOL useAsDefault);
void sub_02027000(u16 numSlot, BOOL useAsDefault);
void sub_02027008(int numSlot, BOOL useAsDefault);
void sub_02026F6C(void);
struct Unk3Dstruct_02026EB4 *sub_02026EB4(HeapID heapId, int r7, int r5, int sp4, int sp20, void (*sp24)(void)) {
struct Unk3Dstruct_02026EB4 *ret;
u32 texWorkSz, pltWorkSz;
ret = AllocFromHeap(heapId, sizeof(struct Unk3Dstruct_02026EB4));
ret->heapId = heapId;
NNS_G3dInit();
G3X_InitMtxStack();
G3_SwapBuffers(GX_SORTMODE_AUTO, GX_BUFFERMODE_W);
if (!r7) {
texWorkSz = NNS_GfdGetLnkTexVramManagerWorkSize(r5 << 7);
ret->texWork = AllocFromHeap(ret->heapId, texWorkSz);
sub_02026FE8(r5 << 17, 0, ret->texWork, texWorkSz, TRUE);
} else {
sub_02027000(r5, TRUE);
}
if (!sp4) {
pltWorkSz = NNS_GfdGetLnkPlttVramManagerWorkSize(sp20 << 8);
ret->plttWork = AllocFromHeap(ret->heapId, pltWorkSz);
sub_02026FF8(sp20 << 13, ret->plttWork, pltWorkSz, TRUE);
} else {
sub_02027008(sp20, TRUE);
}
if (sp24 != NULL) {
sp24();
} else {
sub_02026F6C();
}
return ret;
}

View File

@ -6,7 +6,7 @@ u32 sub_02031AF0(void) {
}
void sub_02031AF4(UnkSaveStruct29* unk) {
MI_CpuFill8(unk, 0, sizeof(UnkSaveStruct29));
MI_CpuClear8(unk, sizeof(UnkSaveStruct29));
}
UnkSaveStruct29* sub_02031B00(SAVEDATA* savedata) {