mirror of
https://github.com/pret/pokediamond.git
synced 2026-03-21 17:54:29 -05:00
apply clang-format
This commit is contained in:
parent
bcc5bdf08b
commit
a708d06955
120
.clang-format
120
.clang-format
|
|
@ -1,25 +1,103 @@
|
|||
BasedOnStyle: LLVM
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
BreakBeforeBraces: Allman
|
||||
ColumnLimit: 100
|
||||
UseTab: Never
|
||||
IndentWidth: 4
|
||||
TabWidth: 4
|
||||
---
|
||||
BasedOnStyle: WebKit
|
||||
Language: Cpp
|
||||
LineEnding: LF
|
||||
ColumnLimit: 0
|
||||
|
||||
AlignAfterOpenBracket: DontAlign
|
||||
Cpp11BracedListStyle: false
|
||||
BreakStringLiterals: false
|
||||
IndentCaseLabels: true
|
||||
AlignConsecutiveAssignments:
|
||||
Enabled: true
|
||||
AlignConsecutiveBitFields:
|
||||
Enabled: true
|
||||
AlignConsecutiveDeclarations: None
|
||||
AlignConsecutiveMacros: Consecutive
|
||||
AlignTrailingComments: true
|
||||
AlignArrayOfStructures: Left
|
||||
|
||||
AllowShortBlocksOnASingleLine: Empty
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortEnumsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
|
||||
BinPackArguments: false
|
||||
BinPackParameters: false
|
||||
AlignTrailingComments: false
|
||||
BitFieldColonSpacing: Both
|
||||
|
||||
InsertBraces: true
|
||||
BreakBeforeBraces: Custom
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: false
|
||||
AfterControlStatement: Never
|
||||
AfterEnum: false
|
||||
AfterFunction: false
|
||||
AfterStruct: false
|
||||
AfterUnion: false
|
||||
BeforeElse: false
|
||||
BeforeWhile: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: true
|
||||
SplitEmptyRecord: false
|
||||
|
||||
AlwaysBreakAfterReturnType: None
|
||||
BreakBeforeBinaryOperators: All
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakStringLiterals: true
|
||||
|
||||
DerivePointerAlignment: false
|
||||
PointerAlignment: Right
|
||||
ReferenceAlignment: Right
|
||||
|
||||
ContinuationIndentWidth: 4
|
||||
IndentCaseBlocks: false
|
||||
IndentCaseLabels: false
|
||||
IndentGotoLabels: false
|
||||
IndentPPDirectives: None
|
||||
IndentWidth: 4
|
||||
|
||||
SortIncludes: CaseSensitive
|
||||
IncludeBlocks: Regroup
|
||||
IncludeCategories:
|
||||
- Regex: '^"nitro/types\.h"$'
|
||||
Priority: -4
|
||||
- Regex: '^"global\.h"$'
|
||||
Priority: -3
|
||||
- Regex: '^"nitro/nitro\.h"$'
|
||||
Priority: -2
|
||||
- Regex: '^"nitro/'
|
||||
Priority: -1
|
||||
- Regex: '.\*'
|
||||
Priority: 1
|
||||
- Regex: '((<.+>)|("nitro/.*\.h"))'
|
||||
Priority: 1
|
||||
- Regex: '"global\.h"'
|
||||
Priority: 2
|
||||
- Regex: '"(consts|constants)/.*\.h"'
|
||||
Priority: 3
|
||||
- Regex: '"(struct_(decls|defs))/.*\.h"'
|
||||
Priority: 4
|
||||
- Regex: '"(constdata|res)/.*\.(h|naix)"'
|
||||
Priority: 7
|
||||
- Regex: '"[[:alnum:]_]+/.*\.(h|naix)"'
|
||||
Priority: 5
|
||||
- Regex: '"[[:alnum:]_]+\.(h|naix)"'
|
||||
Priority: 6
|
||||
- Regex: '.*'
|
||||
Priority: 8
|
||||
|
||||
InsertTrailingCommas: Wrapped
|
||||
InsertNewlineAtEOF: true
|
||||
KeepEmptyLinesAtEOF: false
|
||||
MaxEmptyLinesToKeep: 1
|
||||
RemoveParentheses: ReturnStatement
|
||||
RemoveSemicolon: true
|
||||
|
||||
# QualifierAlignment: Custom
|
||||
# QualifierOrder: [static, inline, const, volatile, type]
|
||||
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAroundPointerQualifiers: Default
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCaseColon: false
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeSquareBrackets: false
|
||||
SpaceInEmptyBlock: false
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesInContainerLiterals: true
|
||||
SpacesInLineCommentPrefix:
|
||||
Minimum: 1
|
||||
Maximum: -1
|
||||
SpacesInParens: Never
|
||||
|
|
|
|||
6
.clang-format-ignore
Normal file
6
.clang-format-ignore
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
**/*.s
|
||||
**/*.inc
|
||||
**/*.json
|
||||
arm9/lib/
|
||||
arm7/lib/
|
||||
include/nitro/
|
||||
9
.githooks/pre-commit
Normal file
9
.githooks/pre-commit
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/sh
|
||||
# Redirect output to stderr.
|
||||
exec 1>&2
|
||||
|
||||
# Run clang-format on staged files; abort the commit if any files are changed
|
||||
if ! git clang-format --extensions c,cpp,h,hpp ; then
|
||||
echo "linting made changes to source files; aborting commit"
|
||||
exit 1
|
||||
fi
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
#define NITRO_PAD_PAD_H_
|
||||
|
||||
#include "registers.h"
|
||||
#include "mmap.h"
|
||||
|
||||
//================================================================================
|
||||
// BUTTONS
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef NITRO_RTC_API_H_
|
||||
#define NITRO_RTC_API_H_
|
||||
|
||||
#include "nitro/types.h"
|
||||
|
||||
typedef enum RTCAlarmChan
|
||||
{
|
||||
RTC_ALARM_CHAN_1 = 0,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#include "global.h"
|
||||
|
||||
#include "sinit.h"
|
||||
|
||||
static void NitroStaticInit(void) {
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@
|
|||
#define POKEDIAMOND_ov05_021E72FC_H
|
||||
|
||||
#include "nitro/types.h"
|
||||
|
||||
#include "field_system.h"
|
||||
#include "task.h"
|
||||
|
||||
typedef struct UnkStruct021E7358
|
||||
{
|
||||
typedef struct UnkStruct021E7358 {
|
||||
u32 Unk00;
|
||||
u32 Unk04;
|
||||
u32 Unk08;
|
||||
|
|
@ -22,4 +22,4 @@ BOOL ov05_021E73B4(TaskManager *taskManager);
|
|||
UnkStruct021E7358 *ov05_021E74D4(u32 param0);
|
||||
void ov05_021E74F8(UnkStruct021E7358 *param0);
|
||||
|
||||
#endif //POKEDIAMOND_ov05_021E72FC_H
|
||||
#endif // POKEDIAMOND_ov05_021E72FC_H
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
#ifndef POKEDIAMOND_OVERLAY_05_H
|
||||
#define POKEDIAMOND_OVERLAY_05_H
|
||||
|
||||
//todo: remove this file
|
||||
// todo: remove this file
|
||||
|
||||
#include "pokemon.h"
|
||||
|
||||
void ov05_SetEggStats(struct Pokemon * mon, u16 species, int a1, PlayerProfile * data, int a2, int metLoc);
|
||||
void ov05_SetEggStats(struct Pokemon *mon, u16 species, int a1, PlayerProfile *data, int a2, int metLoc);
|
||||
|
||||
#endif //POKEDIAMOND_OVERLAY_05_H
|
||||
#endif // POKEDIAMOND_OVERLAY_05_H
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
#include "global.h"
|
||||
#include "ov05_021E72FC.h"
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "constants/sndseq.h"
|
||||
|
||||
#include "heap.h"
|
||||
#include "map_object.h"
|
||||
#include "unk_020051F4.h"
|
||||
|
|
@ -19,27 +22,19 @@ extern void sub_02055304(u32 param0, u32 param1);
|
|||
extern BOOL sub_02056B74(u32 param0, LocalMapObject *object, u32 param2);
|
||||
extern void MapObject_ClearFlagsBits(LocalMapObject *object, u32 bits);
|
||||
|
||||
BOOL ov05_021E72FC(FieldSystem *fieldSystem, u32 param1)
|
||||
{
|
||||
BOOL ov05_021E72FC(FieldSystem *fieldSystem, u32 param1) {
|
||||
u8 res = (u8)sub_02058720(PlayerAvatar_GetMapObject(param1));
|
||||
u32 r2;
|
||||
if (sub_02054B30(res) == TRUE)
|
||||
{
|
||||
if (sub_02054B30(res) == TRUE) {
|
||||
r2 = 3;
|
||||
goto label;
|
||||
}
|
||||
else if (sub_02054B3C(res) == TRUE)
|
||||
{
|
||||
} else if (sub_02054B3C(res) == TRUE) {
|
||||
r2 = 2;
|
||||
goto label;
|
||||
}
|
||||
else if (sub_02054B48(res) == TRUE)
|
||||
{
|
||||
} else if (sub_02054B48(res) == TRUE) {
|
||||
r2 = 0;
|
||||
goto label;
|
||||
}
|
||||
else if (sub_02054B54(res) == TRUE)
|
||||
{
|
||||
} else if (sub_02054B54(res) == TRUE) {
|
||||
r2 = 1;
|
||||
goto label;
|
||||
}
|
||||
|
|
@ -49,110 +44,89 @@ label:
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
void ov05_021E7358(FieldSystem *fieldSystem, u32 param1, u32 param2)
|
||||
{
|
||||
void ov05_021E7358(FieldSystem *fieldSystem, u32 param1, u32 param2) {
|
||||
UnkStruct021E7358 *res = ov05_021E74D4(24);
|
||||
res->fieldSystem = fieldSystem;
|
||||
res->Unk10 = param1;
|
||||
res->Unk00 = param2;
|
||||
res->fieldSystem = fieldSystem;
|
||||
res->Unk10 = param1;
|
||||
res->Unk00 = param2;
|
||||
PlaySE(SEQ_SE_DP_F209);
|
||||
FieldSystem_CreateTask(fieldSystem, ov05_021E73B4, res);
|
||||
}
|
||||
|
||||
u32 ov05_021E7388(u32 param0)
|
||||
{
|
||||
switch (param0)
|
||||
{
|
||||
case 0:
|
||||
return 2;
|
||||
case 2:
|
||||
return 1;
|
||||
case 1:
|
||||
return 3;
|
||||
case 3:
|
||||
return 0;
|
||||
u32 ov05_021E7388(u32 param0) {
|
||||
switch (param0) {
|
||||
case 0:
|
||||
return 2;
|
||||
case 2:
|
||||
return 1;
|
||||
case 1:
|
||||
return 3;
|
||||
case 3:
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
BOOL ov05_021E73B4(TaskManager *taskManager)
|
||||
{
|
||||
UnkStruct021E7358 *strct = TaskManager_GetEnvironment(taskManager);
|
||||
BOOL ov05_021E73B4(TaskManager *taskManager) {
|
||||
UnkStruct021E7358 *strct = TaskManager_GetEnvironment(taskManager);
|
||||
LocalMapObject *playerObject = PlayerAvatar_GetMapObject(strct->Unk10);
|
||||
u8 res2 = (u8)sub_02058720(playerObject);
|
||||
switch (strct->Unk08)
|
||||
{
|
||||
case 0:
|
||||
MapObject_SetFlagsBits(playerObject, MAPOBJECTFLAG_UNK8);
|
||||
strct->Unk08++;
|
||||
u8 res2 = (u8)sub_02058720(playerObject);
|
||||
switch (strct->Unk08) {
|
||||
case 0:
|
||||
MapObject_SetFlagsBits(playerObject, MAPOBJECTFLAG_UNK8);
|
||||
strct->Unk08++;
|
||||
break;
|
||||
case 1:
|
||||
if (!sub_02057254(strct->Unk10)) {
|
||||
break;
|
||||
case 1:
|
||||
if (!sub_02057254(strct->Unk10))
|
||||
{
|
||||
break;
|
||||
}
|
||||
sub_02057260(strct->Unk10, sub_0205AFDC(strct->Unk00, 12));
|
||||
}
|
||||
sub_02057260(strct->Unk10, sub_0205AFDC(strct->Unk00, 12));
|
||||
sub_02055304(strct->Unk10, strct->Unk00);
|
||||
strct->Unk08++;
|
||||
strct->Unk04 = 7;
|
||||
break;
|
||||
case 2:
|
||||
if (strct->Unk04 == 2 || strct->Unk04 == 4 || strct->Unk04 == 6) {
|
||||
strct->Unk00 = ov05_021E7388(strct->Unk00);
|
||||
sub_02055304(strct->Unk10, strct->Unk00);
|
||||
strct->Unk08++;
|
||||
strct->Unk04 = 7;
|
||||
}
|
||||
if (--(strct->Unk04)) {
|
||||
break;
|
||||
case 2:
|
||||
if (strct->Unk04 == 2 || strct->Unk04 == 4 || strct->Unk04 == 6)
|
||||
{
|
||||
strct->Unk00 = ov05_021E7388(strct->Unk00);
|
||||
sub_02055304(strct->Unk10, strct->Unk00);
|
||||
}
|
||||
if (--(strct->Unk04))
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (sub_02054B30(res2) == TRUE)
|
||||
{
|
||||
strct->Unk00 = 3;
|
||||
}
|
||||
else if (sub_02054B3C(res2) == TRUE)
|
||||
{
|
||||
strct->Unk00 = 2;
|
||||
}
|
||||
else if (sub_02054B48(res2) == TRUE)
|
||||
{
|
||||
strct->Unk00 = 0;
|
||||
}
|
||||
else if (sub_02054B54(res2) == TRUE)
|
||||
{
|
||||
strct->Unk00 = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
strct->Unk00 = ov05_021E7388(strct->Unk00);
|
||||
}
|
||||
if (sub_02056B74(strct->Unk10, playerObject, strct->Unk00) == FALSE)
|
||||
{
|
||||
strct->Unk08 = 1;
|
||||
break;
|
||||
}
|
||||
MapObject_ClearFlagsBits(playerObject, MAPOBJECTFLAG_UNK7);
|
||||
MapObject_ClearFlagsBits(playerObject, MAPOBJECTFLAG_UNK8);
|
||||
sub_02055304(strct->Unk10, strct->Unk00);
|
||||
ov05_021E74F8(strct);
|
||||
sub_020054F0(1624, 0);
|
||||
return TRUE;
|
||||
}
|
||||
if (sub_02054B30(res2) == TRUE) {
|
||||
strct->Unk00 = 3;
|
||||
} else if (sub_02054B3C(res2) == TRUE) {
|
||||
strct->Unk00 = 2;
|
||||
} else if (sub_02054B48(res2) == TRUE) {
|
||||
strct->Unk00 = 0;
|
||||
} else if (sub_02054B54(res2) == TRUE) {
|
||||
strct->Unk00 = 1;
|
||||
} else {
|
||||
strct->Unk00 = ov05_021E7388(strct->Unk00);
|
||||
}
|
||||
if (sub_02056B74(strct->Unk10, playerObject, strct->Unk00) == FALSE) {
|
||||
strct->Unk08 = 1;
|
||||
break;
|
||||
}
|
||||
MapObject_ClearFlagsBits(playerObject, MAPOBJECTFLAG_UNK7);
|
||||
MapObject_ClearFlagsBits(playerObject, MAPOBJECTFLAG_UNK8);
|
||||
sub_02055304(strct->Unk10, strct->Unk00);
|
||||
ov05_021E74F8(strct);
|
||||
sub_020054F0(1624, 0);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
UnkStruct021E7358 *ov05_021E74D4(u32 param0)
|
||||
{
|
||||
UnkStruct021E7358 *ov05_021E74D4(u32 param0) {
|
||||
UnkStruct021E7358 *res = (UnkStruct021E7358 *)AllocFromHeapAtEnd(HEAP_ID_4, param0);
|
||||
if (res == NULL)
|
||||
{
|
||||
if (res == NULL) {
|
||||
GF_AssertFail();
|
||||
}
|
||||
memset((void *)res, 0, param0);
|
||||
return res;
|
||||
}
|
||||
|
||||
void ov05_021E74F8(UnkStruct021E7358 *param0)
|
||||
{
|
||||
void ov05_021E74F8(UnkStruct021E7358 *param0) {
|
||||
FreeToHeapExplicit(HEAP_ID_4, param0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
#ifndef POKEDIAMOND_OVERLAY_06_H
|
||||
#define POKEDIAMOND_OVERLAY_06_H
|
||||
|
||||
enum MartType
|
||||
{
|
||||
#include "field_system.h"
|
||||
|
||||
enum MartType {
|
||||
MART_ITEMS = 0,
|
||||
MART_GOODS,
|
||||
MART_SEALS,
|
||||
|
|
@ -11,4 +12,4 @@ enum MartType
|
|||
|
||||
void ov06_0223D3D0(struct TaskManager *, struct FieldSystem *, const u16 *, enum MartType, u32);
|
||||
|
||||
#endif //POKEDIAMOND_OVERLAY_06_H
|
||||
#endif // POKEDIAMOND_OVERLAY_06_H
|
||||
|
|
|
|||
|
|
@ -1,15 +1,13 @@
|
|||
#include "global.h"
|
||||
#include "poke_overlay.h"
|
||||
#include "FS_overlay.h"
|
||||
#include "unk_02031734.h"
|
||||
|
||||
#include "FS_overlay.h"
|
||||
#include "poke_overlay.h"
|
||||
#include "unk_02031734.h"
|
||||
|
||||
FS_EXTERN_OVERLAY(OVERLAY_16);
|
||||
|
||||
static void ov11_0222F284(void)
|
||||
{
|
||||
if (!sub_02033590())
|
||||
{
|
||||
static void ov11_0222F284(void) {
|
||||
if (!sub_02033590()) {
|
||||
HandleLoadOverlay(FS_OVERLAY_ID(OVERLAY_16), 2);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
#include "bg_window.h"
|
||||
|
||||
void ov19_02252440(struct BgConfig * bgConfig);
|
||||
void ov19_022524F4(struct BgConfig * bgConfig);
|
||||
BOOL ov19_02252504(struct BgConfig * bgConfig);
|
||||
void ov19_02252440(struct BgConfig *bgConfig);
|
||||
void ov19_022524F4(struct BgConfig *bgConfig);
|
||||
BOOL ov19_02252504(struct BgConfig *bgConfig);
|
||||
|
||||
#endif //POKEDIAMOND_OVERLAY_19_H
|
||||
#endif // POKEDIAMOND_OVERLAY_19_H
|
||||
|
|
|
|||
|
|
@ -1,27 +1,29 @@
|
|||
#include "global.h"
|
||||
#include "overlay_19.h"
|
||||
#include "heap.h"
|
||||
#include "gx.h"
|
||||
#include "gf_gfx_loader.h"
|
||||
#include "bg_window.h"
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "graphic/poketch.naix"
|
||||
|
||||
#include "bg_window.h"
|
||||
#include "gf_gfx_loader.h"
|
||||
#include "gx.h"
|
||||
#include "heap.h"
|
||||
|
||||
const struct BgTemplate ov19_02252508 = {
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.bufferSize = 0x800,
|
||||
.baseTile = 0x000,
|
||||
.size = GF_BG_SCR_SIZE_256x256,
|
||||
.colorMode = GF_BG_CLR_4BPP,
|
||||
.baseTile = 0x000,
|
||||
.size = GF_BG_SCR_SIZE_256x256,
|
||||
.colorMode = GF_BG_CLR_4BPP,
|
||||
.screenBase = 12,
|
||||
.charBase = 0,
|
||||
.priority = 0,
|
||||
.areaOver = 0,
|
||||
.mosaic = 0
|
||||
.charBase = 0,
|
||||
.priority = 0,
|
||||
.areaOver = 0,
|
||||
.mosaic = 0
|
||||
};
|
||||
|
||||
void ov19_02252440(struct BgConfig * bgConfig)
|
||||
{
|
||||
void ov19_02252440(struct BgConfig *bgConfig) {
|
||||
CreateHeap(3, 8, 0x18000);
|
||||
GXS_SetGraphicsMode(GX_BGMODE_0);
|
||||
GX_SetBankForSubBG(0x80);
|
||||
|
|
@ -35,14 +37,12 @@ void ov19_02252440(struct BgConfig * bgConfig)
|
|||
GXS_SetVisiblePlane(GX_PLANEMASK_BG0);
|
||||
}
|
||||
|
||||
void ov19_022524F4(struct BgConfig * bgConfig)
|
||||
{
|
||||
void ov19_022524F4(struct BgConfig *bgConfig) {
|
||||
FreeBgTilemapBuffer(bgConfig, GF_BG_LYR_SUB_0);
|
||||
DestroyHeap(HEAP_ID_POKETCH_APP);
|
||||
}
|
||||
|
||||
BOOL ov19_02252504(struct BgConfig * bgConfig)
|
||||
{
|
||||
BOOL ov19_02252504(struct BgConfig *bgConfig) {
|
||||
#pragma unused(bgConfig)
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,17 +2,16 @@
|
|||
#define POKEDIAMOND_ov21_02254854_H
|
||||
|
||||
#include "nitro/types.h"
|
||||
|
||||
#include "ov21_02254A6C.h"
|
||||
#include "unk_0200CA44.h"
|
||||
|
||||
typedef struct Time
|
||||
{
|
||||
typedef struct Time {
|
||||
u32 hour;
|
||||
u32 minute;
|
||||
} Time;
|
||||
|
||||
typedef struct UnkStruct02254854
|
||||
{
|
||||
typedef struct UnkStruct02254854 {
|
||||
u8 bytearray[8];
|
||||
u8 padding0[8];
|
||||
BOOL Unk10;
|
||||
|
|
@ -28,10 +27,10 @@ BOOL ov21_0225489C(UnkStruct02254854 *param0, u32 param1, u32 param2, u32 param3
|
|||
void ov21_02254918(UnkStruct02254854 *param0);
|
||||
void ov21_02254930(SysTask *task, UnkStruct02254854 *param1);
|
||||
void ov21_0225496C(UnkStruct02254854 *param0);
|
||||
void ov21_02254974(u32 param0, u32 param1, u32 param2, UnkStruct02254854 * param3);
|
||||
void ov21_02254990(UnkStruct02254854 * param0, u8 param1);
|
||||
BOOL ov21_022549A4(UnkStruct02254854 * param0);
|
||||
BOOL ov21_022549E4(UnkStruct02254854 * param0);
|
||||
BOOL ov21_02254A38(UnkStruct02254854 * param0);
|
||||
void ov21_02254974(u32 param0, u32 param1, u32 param2, UnkStruct02254854 *param3);
|
||||
void ov21_02254990(UnkStruct02254854 *param0, u8 param1);
|
||||
BOOL ov21_022549A4(UnkStruct02254854 *param0);
|
||||
BOOL ov21_022549E4(UnkStruct02254854 *param0);
|
||||
BOOL ov21_02254A38(UnkStruct02254854 *param0);
|
||||
|
||||
#endif //POKEDIAMOND_ov21_02254854_H
|
||||
#endif // POKEDIAMOND_ov21_02254854_H
|
||||
|
|
|
|||
|
|
@ -5,8 +5,7 @@
|
|||
|
||||
typedef struct UnkStruct02254A6C UnkStruct02254A6C;
|
||||
|
||||
struct UnkStruct02254A6C
|
||||
{
|
||||
struct UnkStruct02254A6C {
|
||||
UnkStruct02254A6C *Unk00;
|
||||
u32 Unk04;
|
||||
u32 Unk08[1];
|
||||
|
|
@ -15,12 +14,11 @@ struct UnkStruct02254A6C
|
|||
u32 Unk30[1];
|
||||
};
|
||||
|
||||
typedef struct UnkOverlayStruct1
|
||||
{
|
||||
typedef struct UnkOverlayStruct1 {
|
||||
u32 number;
|
||||
BOOL (*func)(u32 param0, void *param1);
|
||||
u32 Unk08;
|
||||
} UnkOverlayStruct1; //todo should probably be in ov 20 header
|
||||
} UnkOverlayStruct1; // todo should probably be in ov 20 header
|
||||
|
||||
BOOL ov21_02254A6C(UnkStruct02254A6C *param0, void *param1);
|
||||
void ov21_02254AD4(void *param0, void *param1);
|
||||
|
|
@ -35,4 +33,4 @@ BOOL ov21_02254C14(u32 param0, void *param1);
|
|||
BOOL ov21_02254C40(u32 param0, void *param1);
|
||||
void ov21_02254C5C(UnkStruct02254A6C *param0);
|
||||
|
||||
#endif //POKEDIAMOND_ov21_02254A6C_H
|
||||
#endif // POKEDIAMOND_ov21_02254A6C_H
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
#include "ov21_02254854.h"
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "heap.h"
|
||||
#include "unk_0200CA44.h"
|
||||
#include "ov21_02254854.h"
|
||||
|
||||
extern void GF_RTC_CopyTime(Time *param0);
|
||||
|
||||
|
|
@ -16,21 +18,17 @@ extern void ov20_0225298C(u32 param0);
|
|||
|
||||
extern void Poketch_InitApp(void *func1, void *func2);
|
||||
|
||||
static void ov21_02254840(void)
|
||||
{
|
||||
static void ov21_02254840(void) {
|
||||
Poketch_InitApp(ov21_02254854, ov21_0225496C);
|
||||
}
|
||||
|
||||
#define NitroStaticInit ov21_02254840
|
||||
#include "sinit.h"
|
||||
|
||||
BOOL ov21_02254854(UnkStruct02254854 **param0, u32 param1, u32 param2, u32 param3)
|
||||
{
|
||||
BOOL ov21_02254854(UnkStruct02254854 **param0, u32 param1, u32 param2, u32 param3) {
|
||||
UnkStruct02254854 *alloced = (UnkStruct02254854 *)AllocFromHeap(HEAP_ID_POKETCH_APP, sizeof(UnkStruct02254854));
|
||||
if (alloced != NULL)
|
||||
{
|
||||
if (ov21_0225489C(alloced, param1, param2, param3) && SysTask_CreateOnMainQueue((SysTaskFunc)ov21_02254930, (void *)alloced, 1))
|
||||
{
|
||||
if (alloced != NULL) {
|
||||
if (ov21_0225489C(alloced, param1, param2, param3) && SysTask_CreateOnMainQueue((SysTaskFunc)ov21_02254930, (void *)alloced, 1)) {
|
||||
*param0 = alloced;
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -39,30 +37,26 @@ BOOL ov21_02254854(UnkStruct02254854 **param0, u32 param1, u32 param2, u32 param
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL ov21_0225489C(UnkStruct02254854 *param0, u32 param1, u32 param2, u32 param3)
|
||||
{
|
||||
#pragma unused (param2, param3) //not sure, please check
|
||||
if (ov21_02254A6C((UnkStruct02254A6C *)¶m0->Unk24, ¶m0->time)) //todo fix
|
||||
BOOL ov21_0225489C(UnkStruct02254854 *param0, u32 param1, u32 param2, u32 param3) {
|
||||
#pragma unused(param2, param3) // not sure, please check
|
||||
if (ov21_02254A6C((UnkStruct02254A6C *)¶m0->Unk24, ¶m0->time)) // todo fix
|
||||
{
|
||||
param0->bytearray[0] = 0;
|
||||
param0->bytearray[1] = 0;
|
||||
param0->bytearray[2] = 0;
|
||||
param0->bytearray[3] = 1;
|
||||
param0->bytearray[6] = 0;
|
||||
param0->Unk20 = 0;
|
||||
param0->Unk20 = 0;
|
||||
GF_RTC_CopyTime(¶m0->time);
|
||||
if (param0->time.hour >= 0x18)
|
||||
{
|
||||
if (param0->time.hour >= 0x18) {
|
||||
param0->time.hour = param0->time.hour % 0x18;
|
||||
}
|
||||
if (param0->time.minute >= 0x3c)
|
||||
{
|
||||
if (param0->time.minute >= 0x3c) {
|
||||
param0->time.hour = param0->time.hour % 0x3c;
|
||||
}
|
||||
param0->bytearray[5] = (u8)param0->time.minute;
|
||||
param0->Unk10 = ov20_02254130((void *)ov21_02254D80, TRUE, ov21_02254974, param0, 8);
|
||||
if (param0->Unk10 == FALSE)
|
||||
{
|
||||
param0->Unk10 = ov20_02254130((void *)ov21_02254D80, TRUE, ov21_02254974, param0, 8);
|
||||
if (param0->Unk10 == FALSE) {
|
||||
return FALSE;
|
||||
}
|
||||
param0->Unk28 = param1;
|
||||
|
|
@ -71,24 +65,20 @@ BOOL ov21_0225489C(UnkStruct02254854 *param0, u32 param1, u32 param2, u32 param3
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL (* const ov21_02254D84[])(UnkStruct02254854 *) = { ov21_022549A4, ov21_022549E4, ov21_02254A38 };
|
||||
BOOL (*const ov21_02254D84[])(UnkStruct02254854 *) = { ov21_022549A4, ov21_022549E4, ov21_02254A38 };
|
||||
|
||||
void ov21_02254918(UnkStruct02254854 *param0)
|
||||
{
|
||||
void ov21_02254918(UnkStruct02254854 *param0) {
|
||||
ov21_02254B04(param0->Unk24);
|
||||
ov20_02254198(param0->Unk10);
|
||||
FreeToHeap((void *)param0);
|
||||
}
|
||||
|
||||
void ov21_02254930(SysTask *task, UnkStruct02254854 *param1)
|
||||
{
|
||||
if (param1->bytearray[0] >= 3)
|
||||
{
|
||||
void ov21_02254930(SysTask *task, UnkStruct02254854 *param1) {
|
||||
if (param1->bytearray[0] >= 3) {
|
||||
return;
|
||||
}
|
||||
ov20_02252C14(param1->Unk28, param1->Unk10);
|
||||
if (!ov21_02254D84[param1->bytearray[0]](param1))
|
||||
{
|
||||
if (!ov21_02254D84[param1->bytearray[0]](param1)) {
|
||||
return;
|
||||
}
|
||||
ov21_02254918(param1);
|
||||
|
|
@ -96,104 +86,86 @@ void ov21_02254930(SysTask *task, UnkStruct02254854 *param1)
|
|||
ov20_022529A0(param1->Unk28);
|
||||
}
|
||||
|
||||
void ov21_0225496C(UnkStruct02254854 *param0)
|
||||
{
|
||||
void ov21_0225496C(UnkStruct02254854 *param0) {
|
||||
param0->bytearray[2] = 1;
|
||||
}
|
||||
|
||||
void ov21_02254974(u32 param0, u32 param1, u32 param2, UnkStruct02254854 * param3)
|
||||
{
|
||||
#pragma unused (param0, param1)
|
||||
switch (param2)
|
||||
{
|
||||
case 1:
|
||||
param3->Unk20 = 1;
|
||||
param3->bytearray[6] = 1;
|
||||
return;
|
||||
case 0:
|
||||
param3->Unk20 = 0;
|
||||
param3->bytearray[6] = 1;
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
void ov21_02254974(u32 param0, u32 param1, u32 param2, UnkStruct02254854 *param3) {
|
||||
#pragma unused(param0, param1)
|
||||
switch (param2) {
|
||||
case 1:
|
||||
param3->Unk20 = 1;
|
||||
param3->bytearray[6] = 1;
|
||||
return;
|
||||
case 0:
|
||||
param3->Unk20 = 0;
|
||||
param3->bytearray[6] = 1;
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void ov21_02254990(UnkStruct02254854 * param0, u8 param1)
|
||||
{
|
||||
if (param0->bytearray[2] == 0)
|
||||
{
|
||||
void ov21_02254990(UnkStruct02254854 *param0, u8 param1) {
|
||||
if (param0->bytearray[2] == 0) {
|
||||
param0->bytearray[0] = param1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
param0->bytearray[0] = 2;
|
||||
}
|
||||
param0->bytearray[1] = 0;
|
||||
}
|
||||
|
||||
BOOL ov21_022549A4(UnkStruct02254854 * param0)
|
||||
{
|
||||
switch (param0->bytearray[1])
|
||||
{
|
||||
case 0:
|
||||
ov21_02254B10(param0->Unk24, 0);
|
||||
param0->bytearray[1]++;
|
||||
break;
|
||||
case 1:
|
||||
if (ov21_02254B34(param0->Unk24, 0) == FALSE)
|
||||
{
|
||||
break;
|
||||
}
|
||||
ov20_0225298C(param0->Unk28);
|
||||
ov21_02254990(param0, 1);
|
||||
break;
|
||||
default:
|
||||
BOOL ov21_022549A4(UnkStruct02254854 *param0) {
|
||||
switch (param0->bytearray[1]) {
|
||||
case 0:
|
||||
ov21_02254B10(param0->Unk24, 0);
|
||||
param0->bytearray[1]++;
|
||||
break;
|
||||
case 1:
|
||||
if (ov21_02254B34(param0->Unk24, 0) == FALSE) {
|
||||
break;
|
||||
}
|
||||
ov20_0225298C(param0->Unk28);
|
||||
ov21_02254990(param0, 1);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL ov21_022549E4(UnkStruct02254854 * param0)
|
||||
{
|
||||
if (param0->bytearray[2])
|
||||
{
|
||||
BOOL ov21_022549E4(UnkStruct02254854 *param0) {
|
||||
if (param0->bytearray[2]) {
|
||||
ov21_02254990(param0, 2);
|
||||
return FALSE;
|
||||
}
|
||||
if (param0->bytearray[6])
|
||||
{
|
||||
if (param0->bytearray[6]) {
|
||||
param0->bytearray[6] = 0;
|
||||
ov21_02254B10(param0->Unk24, 2);
|
||||
}
|
||||
if (ov21_02254B34(param0->Unk24, 1))
|
||||
{
|
||||
if (ov21_02254B34(param0->Unk24, 1)) {
|
||||
param0->bytearray[5] = (u8)param0->time.minute;
|
||||
GF_RTC_CopyTime(¶m0->time);
|
||||
if (param0->bytearray[5] != param0->time.minute)
|
||||
{
|
||||
if (param0->bytearray[5] != param0->time.minute) {
|
||||
ov21_02254B10(param0->Unk24, 1);
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL ov21_02254A38(UnkStruct02254854 * param0)
|
||||
{
|
||||
switch (param0->bytearray[1])
|
||||
{
|
||||
case 0:
|
||||
ov21_02254B10(param0->Unk24, 3);
|
||||
param0->bytearray[1]++;
|
||||
break;
|
||||
case 1:
|
||||
if (ov21_02254B40(param0->Unk24))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
BOOL ov21_02254A38(UnkStruct02254854 *param0) {
|
||||
switch (param0->bytearray[1]) {
|
||||
case 0:
|
||||
ov21_02254B10(param0->Unk24, 3);
|
||||
param0->bytearray[1]++;
|
||||
break;
|
||||
case 1:
|
||||
if (ov21_02254B40(param0->Unk24)) {
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
#include "ov21_02254A6C.h"
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "MI_memory.h"
|
||||
#include "heap.h"
|
||||
#include "registers.h"
|
||||
#include "MI_memory.h"
|
||||
|
||||
extern void ov20_022536F4(u32 *param0, u32 param1);
|
||||
extern u32 ov20_02252D34(void);
|
||||
|
|
@ -11,11 +12,11 @@ extern void *GfGfxLoader_GetScrnData(u32 param0, u32 param1, u32 param2, void *p
|
|||
extern void ov20_022537E0(void *param0, u32 param1, void *param2, u32 param3, void *param4, u32 param5, u32 param6);
|
||||
|
||||
UnkOverlayStruct1 const ov21_02254DAC[] = {
|
||||
{ 0, ov21_02254B60, 0 },
|
||||
{ 1, ov21_02254BF4, 0 },
|
||||
{ 2, ov21_02254C14, 0 },
|
||||
{ 3, ov21_02254C40, 0 },
|
||||
{ 0, NULL, 0 }
|
||||
{ 0, ov21_02254B60, 0 },
|
||||
{ 1, ov21_02254BF4, 0 },
|
||||
{ 2, ov21_02254C14, 0 },
|
||||
{ 3, ov21_02254C40, 0 },
|
||||
{ 0, NULL, 0 }
|
||||
};
|
||||
|
||||
extern BOOL ov20_02253794(void *param0, u32 param1);
|
||||
|
|
@ -23,9 +24,8 @@ extern BOOL ov20_022537B8(void *param0);
|
|||
extern UnkStruct02254A6C *ov20_022538A0(void *param0);
|
||||
extern BOOL ov20_02253888(void *param0, void *param1);
|
||||
|
||||
//todo datatype
|
||||
u8 const ov21_02254D90[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x01, 0x00, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
// todo datatype
|
||||
u8 const ov21_02254D90[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
|
||||
extern void InitBgFromTemplate(u32 param0, u32 param1, void *param2, u32 param3);
|
||||
extern void GfGfxLoader_LoadCharData(u32 param0, u32 param1, u32 param2, u32 param3, u32 param4, u32 param5, u32 param6, u32 param7);
|
||||
|
|
@ -38,18 +38,15 @@ extern void CopyToBgTilemapRect(u32 param0, u32 param1, u32 param2, u32 param3,
|
|||
|
||||
extern void ov11_02252DB4(u32 param0, u32 param1);
|
||||
|
||||
BOOL ov21_02254A6C(UnkStruct02254A6C *param0, void *param1)
|
||||
{
|
||||
BOOL ov21_02254A6C(UnkStruct02254A6C *param0, void *param1) {
|
||||
UnkStruct02254A6C *strct = (UnkStruct02254A6C *)AllocFromHeap(HEAP_ID_POKETCH_APP, 3 << 8);
|
||||
u32 sp4;
|
||||
if (strct != NULL)
|
||||
{
|
||||
if (strct != NULL) {
|
||||
ov20_022536F4(strct->Unk08, 8);
|
||||
strct->Unk00 = param1;
|
||||
strct->Unk04 = ov20_02252D34();
|
||||
void *res = GfGfxLoader_GetScrnData(12, 0x19, 1, &sp4, 8);
|
||||
if (res == 0)
|
||||
{
|
||||
void *res = GfGfxLoader_GetScrnData(12, 0x19, 1, &sp4, 8);
|
||||
if (res == 0) {
|
||||
FreeToHeap(strct);
|
||||
return FALSE;
|
||||
}
|
||||
|
|
@ -61,11 +58,9 @@ BOOL ov21_02254A6C(UnkStruct02254A6C *param0, void *param1)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
void ov21_02254AD4(void *param0, void *param1)
|
||||
{
|
||||
void ov21_02254AD4(void *param0, void *param1) {
|
||||
s32 i = 0;
|
||||
for (u32 r6 = 9 << 6; i < 9; r6 -= 0x30)
|
||||
{
|
||||
for (u32 r6 = 9 << 6; i < 9; r6 -= 0x30) {
|
||||
MI_CpuCopy16(param0, param1, 0x40);
|
||||
MI_CpuCopy16((void *)((u32)param0 + r6), (void *)((u32)param1 + 0x40), 0x10);
|
||||
i++;
|
||||
|
|
@ -74,37 +69,30 @@ void ov21_02254AD4(void *param0, void *param1)
|
|||
}
|
||||
}
|
||||
|
||||
void ov21_02254B04(void *param0)
|
||||
{
|
||||
if (param0 != NULL)
|
||||
{
|
||||
void ov21_02254B04(void *param0) {
|
||||
if (param0 != NULL) {
|
||||
FreeToHeap(param0);
|
||||
}
|
||||
}
|
||||
|
||||
void ov21_02254B10(u32 *param0, u32 param1)
|
||||
{
|
||||
void ov21_02254B10(u32 *param0, u32 param1) {
|
||||
ov20_022537E0(ov21_02254DAC, param1, param0, *param0, (void *)(param0 + 2), 2, 8);
|
||||
}
|
||||
|
||||
BOOL ov21_02254B34(void *param0, u32 param1)
|
||||
{
|
||||
BOOL ov21_02254B34(void *param0, u32 param1) {
|
||||
return ov20_02253794((void *)((u32)param0 + 8), param1);
|
||||
}
|
||||
|
||||
BOOL ov21_02254B40(void *param0)
|
||||
{
|
||||
BOOL ov21_02254B40(void *param0) {
|
||||
return ov20_022537B8((void *)((u32)param0 + 8));
|
||||
}
|
||||
|
||||
BOOL ov21_02254B4C(void *param0)
|
||||
{
|
||||
BOOL ov21_02254B4C(void *param0) {
|
||||
return ov20_02253888((void *)((u32)ov20_022538A0(param0) + 8), param0);
|
||||
}
|
||||
|
||||
BOOL ov21_02254B60(u32 param0, void *param1)
|
||||
{
|
||||
#pragma unused (param0)
|
||||
BOOL ov21_02254B60(u32 param0, void *param1) {
|
||||
#pragma unused(param0)
|
||||
UnkStruct02254A6C *strct = ov20_022538A0(param1);
|
||||
InitBgFromTemplate(strct->Unk04, 6, ov21_02254D90, 0);
|
||||
GfGfxLoader_LoadCharData(12, 23, strct->Unk04, 6, 0, 0, 1, 8);
|
||||
|
|
@ -112,76 +100,69 @@ BOOL ov21_02254B60(u32 param0, void *param1)
|
|||
ov20_02252D7C(0, 0);
|
||||
ov21_02254C5C(strct);
|
||||
BgCommitTilemapBufferToVram(strct->Unk04, 6);
|
||||
u32 r3 = reg_GXS_DB_DISPCNT;
|
||||
u32 r2 = reg_GXS_DB_DISPCNT;
|
||||
vu32 tmp = r3; //unused? wtf
|
||||
u32 r0 = ~0x1F00 & r2;
|
||||
r2 = r3 << 19; //cast with shift? can't replicate both though
|
||||
r3 = r2 >> 27;
|
||||
r2 = 4 | r3;
|
||||
u32 r3 = reg_GXS_DB_DISPCNT;
|
||||
u32 r2 = reg_GXS_DB_DISPCNT;
|
||||
vu32 tmp = r3; // unused? wtf
|
||||
u32 r0 = ~0x1F00 & r2;
|
||||
r2 = r3 << 19; // cast with shift? can't replicate both though
|
||||
r3 = r2 >> 27;
|
||||
r2 = 4 | r3;
|
||||
r2 <<= 8;
|
||||
r0 |= r2;
|
||||
reg_GXS_DB_DISPCNT = r0;
|
||||
return ov21_02254B4C(param1);
|
||||
}
|
||||
|
||||
BOOL ov21_02254BF4(u32 param0, void *param1)
|
||||
{
|
||||
#pragma unused (param0)
|
||||
BOOL ov21_02254BF4(u32 param0, void *param1) {
|
||||
#pragma unused(param0)
|
||||
UnkStruct02254A6C *strct = ov20_022538A0(param1);
|
||||
ov21_02254C5C(strct);
|
||||
BgCommitTilemapBufferToVram(strct->Unk04, 6);
|
||||
return ov21_02254B4C(param1);
|
||||
}
|
||||
|
||||
BOOL ov21_02254C14(u32 param0, void *param1)
|
||||
{
|
||||
#pragma unused (param0)
|
||||
BOOL ov21_02254C14(u32 param0, void *param1) {
|
||||
#pragma unused(param0)
|
||||
UnkStruct02254A6C *strct = ov20_022538A0(param1);
|
||||
if (strct->Unk00->Unk0C)
|
||||
{
|
||||
if (strct->Unk00->Unk0C) {
|
||||
ov11_02252DB4(0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
ov20_02252D7C(0, 0);
|
||||
}
|
||||
return ov21_02254B4C(param1);
|
||||
}
|
||||
|
||||
BOOL ov21_02254C40(u32 param0, void *param1)
|
||||
{
|
||||
#pragma unused (param0)
|
||||
BOOL ov21_02254C40(u32 param0, void *param1) {
|
||||
#pragma unused(param0)
|
||||
UnkStruct02254A6C *strct = ov20_022538A0(param1);
|
||||
FreeBgTilemapBuffer(strct->Unk04, 6);
|
||||
return ov21_02254B4C(param1);
|
||||
}
|
||||
|
||||
void ov21_02254C5C(UnkStruct02254A6C *param0)
|
||||
{
|
||||
u32 tmp = (u32)param0->Unk00->Unk00;
|
||||
reg_CP_DIVCNT = 0;
|
||||
void ov21_02254C5C(UnkStruct02254A6C *param0) {
|
||||
u32 tmp = (u32)param0->Unk00->Unk00;
|
||||
reg_CP_DIVCNT = 0;
|
||||
(*(vu32 *)REG_DIV_NUMER_ADDR) = tmp;
|
||||
reg_CP_DIV_DENOM = 10;
|
||||
while (reg_CP_DIVCNT & ((u32)®_CP_DIVCNT >> 0xb)) { }
|
||||
reg_CP_DIV_DENOM = 10;
|
||||
while (reg_CP_DIVCNT & ((u32)®_CP_DIVCNT >> 0xb)) {}
|
||||
|
||||
u32 regaddr = (u32)®_CP_DIV_RESULT_L;
|
||||
u32 regaddr = (u32)®_CP_DIV_RESULT_L;
|
||||
u32 divResult = *(u32 *)regaddr;
|
||||
while (reg_CP_DIVCNT & (regaddr >> 0xb)) { }
|
||||
while (reg_CP_DIVCNT & (regaddr >> 0xb)) {}
|
||||
|
||||
u32 divRemRes = reg_CP_DIVREM_RESULT_L;
|
||||
CopyToBgTilemapRect(param0->Unk04, 6, 3, 7, 4, 9, param0->Unk30, (u8)(divResult << 2), 0, 40, 9);
|
||||
CopyToBgTilemapRect(param0->Unk04, 6, 8, 7, 4, 9, param0->Unk30, (u8)(divRemRes << 2), 0, 40, 9);
|
||||
|
||||
tmp = param0->Unk00->Unk04;
|
||||
reg_CP_DIVCNT = 0;
|
||||
tmp = param0->Unk00->Unk04;
|
||||
reg_CP_DIVCNT = 0;
|
||||
(*(vu32 *)REG_DIV_NUMER_ADDR) = tmp;
|
||||
reg_CP_DIV_DENOM = 10;
|
||||
reg_CP_DIV_DENOM = 10;
|
||||
|
||||
while (reg_CP_DIVCNT & ((u32)®_CP_DIVCNT >> 0xb)) { }
|
||||
while (reg_CP_DIVCNT & ((u32)®_CP_DIVCNT >> 0xb)) {}
|
||||
|
||||
divResult = *(u32 *)regaddr;
|
||||
while (reg_CP_DIVCNT & (regaddr >> 0xb)) { }
|
||||
while (reg_CP_DIVCNT & (regaddr >> 0xb)) {}
|
||||
|
||||
divRemRes = reg_CP_DIVREM_RESULT_L;
|
||||
CopyToBgTilemapRect(param0->Unk04, 6, 15, 7, 4, 9, param0->Unk30, (u8)(divResult << 2), 0, 40, 9);
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ extern void Poketch_InitApp(void *func1, void *func2);
|
|||
extern void ov22_02254854();
|
||||
extern void ov22_022549D8();
|
||||
|
||||
static void ov22_02254840(void)
|
||||
{
|
||||
static void ov22_02254840(void) {
|
||||
Poketch_InitApp(ov22_02254854, ov22_022549D8);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ extern void Poketch_InitApp(void *func1, void *func2);
|
|||
extern void ov23_02254854();
|
||||
extern void ov23_022549A4();
|
||||
|
||||
static void ov23_02254840(void)
|
||||
{
|
||||
static void ov23_02254840(void) {
|
||||
Poketch_InitApp(ov23_02254854, ov23_022549A4);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,16 +3,15 @@
|
|||
|
||||
typedef enum {
|
||||
TOUCH_TYPE_ERASE = 0,
|
||||
TOUCH_TYPE_DRAW = 1,
|
||||
TOUCH_TYPE_DRAW = 1,
|
||||
} TouchType;
|
||||
|
||||
typedef enum {
|
||||
MEMO_PAD_PIXEL_TYPE_FILLED = 1,
|
||||
MEMO_PAD_PIXEL_TYPE_EMPTY = 4,
|
||||
MEMO_PAD_PIXEL_TYPE_EMPTY = 4,
|
||||
} MemoPadPixelType;
|
||||
|
||||
typedef struct MemoPadDrawState
|
||||
{
|
||||
typedef struct MemoPadDrawState {
|
||||
TouchType touchType;
|
||||
u32 lastModifiedX;
|
||||
u32 lastModifiedY;
|
||||
|
|
@ -21,8 +20,7 @@ typedef struct MemoPadDrawState
|
|||
u32 unk16E8;
|
||||
} MemoPadDrawState;
|
||||
|
||||
typedef struct MemoPadDisplayHandler
|
||||
{
|
||||
typedef struct MemoPadDisplayHandler {
|
||||
MemoPadDrawState *drawState;
|
||||
BgConfig *config;
|
||||
u32 unk8;
|
||||
|
|
@ -33,8 +31,7 @@ typedef struct MemoPadDisplayHandler
|
|||
Window *window;
|
||||
} MemoPadDisplayHandler;
|
||||
|
||||
typedef struct MemoPadAppHandler
|
||||
{
|
||||
typedef struct MemoPadAppHandler {
|
||||
u8 unk0;
|
||||
u8 unk1;
|
||||
u8 unk2;
|
||||
|
|
@ -75,4 +72,4 @@ void ov24_02255050(u32 arg0, void *arg1);
|
|||
void ov24_02255078(MemoPadDisplayHandler *displayHandler);
|
||||
void ov24_022550D4(MemoPadDisplayHandler *displayHandler);
|
||||
|
||||
#endif //POKEDIAMOND_OVERLAY_24_H
|
||||
#endif // POKEDIAMOND_OVERLAY_24_H
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
#include "global.h"
|
||||
|
||||
#include "bg_window.h"
|
||||
#include "unk_0200CA44.h"
|
||||
#include "gf_gfx_loader.h"
|
||||
#include "overlay_24.h"
|
||||
#include "unk_0200CA44.h"
|
||||
|
||||
extern void Poketch_InitApp(void *func1, void *func2);
|
||||
extern u32 ov20_02254130(void *arg0, u32 arg1, void *arg2, void *arg3, u32 arg4);
|
||||
|
|
@ -13,8 +14,7 @@ extern void ov20_0225298C(u32 arg0);
|
|||
extern BOOL ov20_02252C08(u32 arg0);
|
||||
extern BOOL TouchScreen_GetTapState(u32 *arg0, u32 *arg1);
|
||||
|
||||
static void ov24_02254840(void)
|
||||
{
|
||||
static void ov24_02254840(void) {
|
||||
Poketch_InitApp(ov24_02254854, ov24_02254990);
|
||||
}
|
||||
|
||||
|
|
@ -39,15 +39,15 @@ BOOL ov24_0225489C(MemoPadAppHandler *appHandler, u32 arg1, u32 arg2, u32 arg3)
|
|||
static const u8 ov24_022550F8[] = {
|
||||
0x18, 0x58, 0xB4, 0xCC, 0x68, 0xA8, 0xB4, 0xCC
|
||||
};
|
||||
appHandler->drawState.unk16E8 = arg3;
|
||||
appHandler->drawState.unk16E8 = arg3;
|
||||
appHandler->drawState.touchType = TOUCH_TYPE_DRAW;
|
||||
if (ov24_02254CA0(&(appHandler->displayHandler), &(appHandler->drawState))) {
|
||||
appHandler->unk0 = 0;
|
||||
appHandler->unk1 = 0;
|
||||
appHandler->unk2 = 0;
|
||||
appHandler->unk0 = 0;
|
||||
appHandler->unk1 = 0;
|
||||
appHandler->unk2 = 0;
|
||||
appHandler->touchHeld = FALSE;
|
||||
appHandler->unk16FC = ov20_02254130(ov24_022550F8, 2, ov24_02254960, appHandler, 8);
|
||||
appHandler->unk16F8 = arg1;
|
||||
appHandler->unk16FC = ov20_02254130(ov24_022550F8, 2, ov24_02254960, appHandler, 8);
|
||||
appHandler->unk16F8 = arg1;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
|
|
@ -60,7 +60,7 @@ void ov24_022548F4(MemoPadAppHandler *appHandler) {
|
|||
}
|
||||
|
||||
void ov24_02254918(void *arg0, MemoPadAppHandler *appHandler) {
|
||||
static BOOL (*const ov24_02255100[3])(MemoPadAppHandler*) = {
|
||||
static BOOL (*const ov24_02255100[3])(MemoPadAppHandler *) = {
|
||||
ov24_022549AC, ov24_022549F8, ov24_02254C64
|
||||
};
|
||||
if (appHandler->unk0 < 3) {
|
||||
|
|
@ -77,8 +77,7 @@ void ov24_02254960(s32 arg0, s32 arg1, s32 arg2, MemoPadAppHandler *appHandler)
|
|||
if (arg2 == 1) {
|
||||
if (
|
||||
(appHandler->drawState.touchType == TOUCH_TYPE_DRAW && arg0 == 0)
|
||||
|| (appHandler->drawState.touchType == TOUCH_TYPE_ERASE && arg0 == 1)
|
||||
) {
|
||||
|| (appHandler->drawState.touchType == TOUCH_TYPE_ERASE && arg0 == 1)) {
|
||||
appHandler->drawState.touchType ^= 1;
|
||||
ov24_02254D8C(appHandler->displayHandler, 1);
|
||||
}
|
||||
|
|
@ -92,8 +91,7 @@ void ov24_02254990(MemoPadAppHandler *appHandler) {
|
|||
void ov24_02254998(MemoPadAppHandler *appHandler, u8 arg1) {
|
||||
if (appHandler->unk2 == 0) {
|
||||
appHandler->unk0 = arg1;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
appHandler->unk0 = 2;
|
||||
}
|
||||
appHandler->unk1 = 0;
|
||||
|
|
@ -101,18 +99,18 @@ void ov24_02254998(MemoPadAppHandler *appHandler, u8 arg1) {
|
|||
|
||||
BOOL ov24_022549AC(MemoPadAppHandler *appHandler) {
|
||||
switch (appHandler->unk1) {
|
||||
case 0:
|
||||
ov24_02254D8C(appHandler->displayHandler, 0);
|
||||
appHandler->unk1++;
|
||||
break;
|
||||
case 1:
|
||||
if (ov24_02254DB0(appHandler->displayHandler, 0)) {
|
||||
ov20_0225298C(appHandler->unk16F8);
|
||||
ov24_02254998(appHandler, 1);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case 0:
|
||||
ov24_02254D8C(appHandler->displayHandler, 0);
|
||||
appHandler->unk1++;
|
||||
break;
|
||||
case 1:
|
||||
if (ov24_02254DB0(appHandler->displayHandler, 0)) {
|
||||
ov20_0225298C(appHandler->unk16F8);
|
||||
ov24_02254998(appHandler, 1);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
|
@ -122,25 +120,25 @@ BOOL ov24_022549F8(MemoPadAppHandler *appHandler) {
|
|||
ov24_02254998(appHandler, 2);
|
||||
}
|
||||
switch (appHandler->unk1) {
|
||||
case 0:
|
||||
if (ov20_02252C08(appHandler->unk16F8)) {
|
||||
break;
|
||||
}
|
||||
if (appHandler->touchHeld) {
|
||||
u32 x = appHandler->drawState.lastModifiedX;
|
||||
u32 y = appHandler->drawState.lastModifiedY;
|
||||
if (ov24_02254AD4(appHandler)) {
|
||||
ov24_02254B20(appHandler, x, y, appHandler->drawState.lastModifiedX, appHandler->drawState.lastModifiedY);
|
||||
} else {
|
||||
appHandler->touchHeld = FALSE;
|
||||
}
|
||||
} else {
|
||||
if (ov24_02254A70(appHandler)) {
|
||||
ov24_02254D8C(appHandler->displayHandler, 3);
|
||||
appHandler->touchHeld = TRUE;
|
||||
}
|
||||
}
|
||||
case 0:
|
||||
if (ov20_02252C08(appHandler->unk16F8)) {
|
||||
break;
|
||||
}
|
||||
if (appHandler->touchHeld) {
|
||||
u32 x = appHandler->drawState.lastModifiedX;
|
||||
u32 y = appHandler->drawState.lastModifiedY;
|
||||
if (ov24_02254AD4(appHandler)) {
|
||||
ov24_02254B20(appHandler, x, y, appHandler->drawState.lastModifiedX, appHandler->drawState.lastModifiedY);
|
||||
} else {
|
||||
appHandler->touchHeld = FALSE;
|
||||
}
|
||||
} else {
|
||||
if (ov24_02254A70(appHandler)) {
|
||||
ov24_02254D8C(appHandler->displayHandler, 3);
|
||||
appHandler->touchHeld = TRUE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
|
@ -153,11 +151,11 @@ BOOL ov24_02254A70(MemoPadAppHandler *appHandler) {
|
|||
y = (y - 16) >> 1;
|
||||
if (appHandler->drawState.pixelData[x][y] != appHandler->drawState.touchType) {
|
||||
appHandler->drawState.pixelData[x][y] = appHandler->drawState.touchType;
|
||||
appHandler->drawState.lastModifiedX = x;
|
||||
appHandler->drawState.lastModifiedY = y;
|
||||
appHandler->drawState.lastModifiedX = x;
|
||||
appHandler->drawState.lastModifiedY = y;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
|
@ -166,8 +164,8 @@ BOOL ov24_02254AD4(MemoPadAppHandler *appHandler) {
|
|||
u32 x, y;
|
||||
if (TouchScreen_GetTapState(&x, &y)) {
|
||||
if (((x - 16) < 156) & ((y - 16) < 150)) {
|
||||
x = (x - 16) >> 1;
|
||||
y = (y - 16) >> 1;
|
||||
x = (x - 16) >> 1;
|
||||
y = (y - 16) >> 1;
|
||||
appHandler->drawState.lastModifiedX = x;
|
||||
appHandler->drawState.lastModifiedY = y;
|
||||
return TRUE;
|
||||
|
|
@ -199,8 +197,8 @@ void ov24_02254B20(MemoPadAppHandler *appHandler, u32 x0, u32 y0, u32 x1, u32 y1
|
|||
if ((x0 < 0x4e) && ((u32)offset < 0x4b)) {
|
||||
if (appHandler->drawState.touchType != appHandler->drawState.pixelData[x0][offset]) {
|
||||
appHandler->drawState.pixelData[x0][offset] = appHandler->drawState.touchType;
|
||||
appHandler->drawState.lastModifiedX = x0;
|
||||
appHandler->drawState.lastModifiedY = offset;
|
||||
appHandler->drawState.lastModifiedX = x0;
|
||||
appHandler->drawState.lastModifiedY = offset;
|
||||
ov24_02254D8C(appHandler->displayHandler, 3);
|
||||
}
|
||||
}
|
||||
|
|
@ -222,8 +220,8 @@ void ov24_02254B20(MemoPadAppHandler *appHandler, u32 x0, u32 y0, u32 x1, u32 y1
|
|||
if ((y0 < 0x4b) && ((u32)offset < 0x4e)) {
|
||||
if (appHandler->drawState.touchType != appHandler->drawState.pixelData[offset][y0]) {
|
||||
appHandler->drawState.pixelData[offset][y0] = appHandler->drawState.touchType;
|
||||
appHandler->drawState.lastModifiedX = offset;
|
||||
appHandler->drawState.lastModifiedY = y0;
|
||||
appHandler->drawState.lastModifiedX = offset;
|
||||
appHandler->drawState.lastModifiedY = y0;
|
||||
ov24_02254D8C(appHandler->displayHandler, 3);
|
||||
}
|
||||
}
|
||||
|
|
@ -240,15 +238,15 @@ void ov24_02254B20(MemoPadAppHandler *appHandler, u32 x0, u32 y0, u32 x1, u32 y1
|
|||
|
||||
BOOL ov24_02254C64(MemoPadAppHandler *appHandler) {
|
||||
switch (appHandler->unk1) {
|
||||
case 0:
|
||||
ov24_02254D8C(appHandler->displayHandler, 5);
|
||||
appHandler->unk1++;
|
||||
break;
|
||||
case 1:
|
||||
if (ov24_02254DBC(appHandler->displayHandler)) {
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
case 0:
|
||||
ov24_02254D8C(appHandler->displayHandler, 5);
|
||||
appHandler->unk1++;
|
||||
break;
|
||||
case 1:
|
||||
if (ov24_02254DBC(appHandler->displayHandler)) {
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
#include "global.h"
|
||||
|
||||
#include "constants/sndseq.h"
|
||||
|
||||
#include "graphic/poketch.naix"
|
||||
|
||||
#include "SPI_pm.h"
|
||||
#include "bg_window.h"
|
||||
#include "unk_0200CA44.h"
|
||||
#include "gf_gfx_loader.h"
|
||||
#include "overlay_24.h"
|
||||
#include "SPI_pm.h"
|
||||
#include "constants/sndseq.h"
|
||||
#include "graphic/poketch.naix"
|
||||
#include "unk_0200CA44.h"
|
||||
|
||||
extern BOOL sub_0208946C(u32 arg0, void *arg1, u32 arg2);
|
||||
extern void sub_02089444(u32 arg0, void *arg1, u32 arg2);
|
||||
|
|
@ -32,8 +35,8 @@ BOOL ov24_02254CA0(MemoPadDisplayHandler **displayHandlerOut, MemoPadDrawState *
|
|||
ov20_022536F4(&(displayHandler->unk8), 0x10);
|
||||
GF_ASSERT(GF_heap_c_dummy_return_true(HEAP_ID_POKETCH_MAIN));
|
||||
displayHandler->drawState = drawState;
|
||||
displayHandler->config = ov20_02252D34();
|
||||
displayHandler->unk50 = ov20_02252D24();
|
||||
displayHandler->config = ov20_02252D34();
|
||||
displayHandler->unk50 = ov20_02252D24();
|
||||
GF_ASSERT(GF_heap_c_dummy_return_true(HEAP_ID_POKETCH_MAIN));
|
||||
*displayHandlerOut = displayHandler;
|
||||
return TRUE;
|
||||
|
|
@ -43,12 +46,12 @@ BOOL ov24_02254CA0(MemoPadDisplayHandler **displayHandlerOut, MemoPadDrawState *
|
|||
|
||||
BOOL ov24_02254D00(MemoPadDisplayHandler *displayHandler) {
|
||||
static const WindowTemplate template = {
|
||||
.bgId = GF_BG_LYR_SUB_3,
|
||||
.left = 2,
|
||||
.top = 2,
|
||||
.width = 20,
|
||||
.height = 19,
|
||||
.palette = 0,
|
||||
.bgId = GF_BG_LYR_SUB_3,
|
||||
.left = 2,
|
||||
.top = 2,
|
||||
.width = 20,
|
||||
.height = 19,
|
||||
.palette = 0,
|
||||
.baseTile = 12,
|
||||
};
|
||||
displayHandler->window = AllocWindows(HEAP_ID_POKETCH_APP, 1);
|
||||
|
|
@ -77,13 +80,27 @@ void ov24_02254D48(MemoPadDisplayHandler *displayHandler) {
|
|||
void ov24_02254D8C(MemoPadDisplayHandler *displayHandler, u32 arg1) {
|
||||
// TODO: types
|
||||
static const u32 ov24_0225516C[] = {
|
||||
0x00, (u32)ov24_02254DDC, 0x00,
|
||||
0x01, (u32)ov24_02254EE0, 0x00,
|
||||
0x02, (u32)ov24_02254F28, 0x00,
|
||||
0x03, (u32)ov24_02254F40, 0x00,
|
||||
0x04, (u32)ov24_02255038, 0x00,
|
||||
0x05, (u32)ov24_02255050, 0x00,
|
||||
0x00, 0x00000000, 0x00,
|
||||
0x00,
|
||||
(u32)ov24_02254DDC,
|
||||
0x00,
|
||||
0x01,
|
||||
(u32)ov24_02254EE0,
|
||||
0x00,
|
||||
0x02,
|
||||
(u32)ov24_02254F28,
|
||||
0x00,
|
||||
0x03,
|
||||
(u32)ov24_02254F40,
|
||||
0x00,
|
||||
0x04,
|
||||
(u32)ov24_02255038,
|
||||
0x00,
|
||||
0x05,
|
||||
(u32)ov24_02255050,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00000000,
|
||||
0x00,
|
||||
};
|
||||
ov20_022537E0(ov24_0225516C, arg1, displayHandler, displayHandler->drawState, &(displayHandler->unk8), 2, 8);
|
||||
}
|
||||
|
|
@ -97,49 +114,49 @@ BOOL ov24_02254DBC(MemoPadDisplayHandler *displayHandler) {
|
|||
}
|
||||
|
||||
void ov24_02254DC8(void *arg0) {
|
||||
ov20_02253888(&(((MemoPadDisplayHandler*)ov20_022538A0(arg0))->unk8), arg0);
|
||||
ov20_02253888(&(((MemoPadDisplayHandler *)ov20_022538A0(arg0))->unk8), arg0);
|
||||
}
|
||||
|
||||
void ov24_02254DDC(void *arg0, void *arg1) {
|
||||
static const BgTemplate template_7000 = {
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.bufferSize = 0,
|
||||
.baseTile = 0,
|
||||
.size = 1,
|
||||
.colorMode = 0,
|
||||
.baseTile = 0,
|
||||
.size = 1,
|
||||
.colorMode = 0,
|
||||
.screenBase = GX_BG_SCRBASE_0x7000,
|
||||
.charBase = GX_BG_CHARBASE_0x00000,
|
||||
.bgExtPltt = 0,
|
||||
.priority = 2,
|
||||
.areaOver = 0,
|
||||
.dummy = 0,
|
||||
.mosaic = 0,
|
||||
.charBase = GX_BG_CHARBASE_0x00000,
|
||||
.bgExtPltt = 0,
|
||||
.priority = 2,
|
||||
.areaOver = 0,
|
||||
.dummy = 0,
|
||||
.mosaic = 0,
|
||||
};
|
||||
static const BgTemplate template_7800 = {
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.bufferSize = 0x800,
|
||||
.baseTile = 0,
|
||||
.size = 1,
|
||||
.colorMode = 0,
|
||||
.baseTile = 0,
|
||||
.size = 1,
|
||||
.colorMode = 0,
|
||||
.screenBase = GX_BG_SCRBASE_0x7800,
|
||||
.charBase = GX_BG_CHARBASE_0x00000,
|
||||
.bgExtPltt = 0,
|
||||
.priority = 3,
|
||||
.areaOver = 0,
|
||||
.dummy = 0,
|
||||
.mosaic = 0,
|
||||
.charBase = GX_BG_CHARBASE_0x00000,
|
||||
.bgExtPltt = 0,
|
||||
.priority = 3,
|
||||
.areaOver = 0,
|
||||
.dummy = 0,
|
||||
.mosaic = 0,
|
||||
};
|
||||
GF_ASSERT(GF_heap_c_dummy_return_true(HEAP_ID_POKETCH_APP));
|
||||
GXSDispCnt dispcnt;
|
||||
MemoPadDisplayHandler *displayHandler = ov20_022538A0(arg1);
|
||||
InitBgFromTemplate(displayHandler->config, GF_BG_LYR_SUB_2, &template_7000, 0);
|
||||
InitBgFromTemplate(displayHandler->config, GF_BG_LYR_SUB_3, &template_7800, 0);
|
||||
GF_ASSERT(GF_heap_c_dummy_return_true(HEAP_ID_POKETCH_APP));
|
||||
GF_ASSERT(GF_heap_c_dummy_return_true(HEAP_ID_POKETCH_APP));
|
||||
GfGfxLoader_LoadCharData(NARC_GRAPHIC_POKETCH, NARC_poketch_narc_0030_bin, displayHandler->config, GF_BG_LYR_SUB_2, 0, 0, TRUE, HEAP_ID_POKETCH_APP);
|
||||
GfGfxLoader_LoadScrnData(NARC_GRAPHIC_POKETCH, NARC_poketch_narc_0031_NSCR, displayHandler->config, GF_BG_LYR_SUB_2, 0, 0, TRUE, HEAP_ID_POKETCH_APP);
|
||||
ov20_02252D7C(0,0);
|
||||
ov20_02252D7C(0, 0);
|
||||
GF_ASSERT(GF_heap_c_dummy_return_true(HEAP_ID_POKETCH_APP));
|
||||
ov24_02254D00(displayHandler);
|
||||
CopyWindowToVram(displayHandler->window);
|
||||
|
|
@ -174,12 +191,12 @@ void ov24_02254F28(s32 arg0, void *arg1) {
|
|||
|
||||
void ov24_02254F40(u32 arg0, void *arg1) {
|
||||
MemoPadDisplayHandler *displayHandler = ov20_022538A0(arg1);
|
||||
MemoPadDrawState *drawState = displayHandler->drawState;
|
||||
MemoPadDrawState *drawState = displayHandler->drawState;
|
||||
if (drawState->touchType == TOUCH_TYPE_ERASE) {
|
||||
s32 width, height;
|
||||
width = height = 8;
|
||||
s32 x = drawState->lastModifiedX * 2 - 4;
|
||||
s32 y = drawState->lastModifiedY * 2 - 4;
|
||||
s32 x = drawState->lastModifiedX * 2 - 4;
|
||||
s32 y = drawState->lastModifiedY * 2 - 4;
|
||||
if (x < 0) {
|
||||
width += x;
|
||||
x = 0;
|
||||
|
|
@ -193,17 +210,17 @@ void ov24_02254F40(u32 arg0, void *arg1) {
|
|||
s32 e = ((x + width - 1) >> 3) - (x >> 3) + 1;
|
||||
s32 b = ((y + height - 1) >> 3) - (y >> 3) + 1;
|
||||
while (b--) {
|
||||
GXS_LoadBG3Char((u8*)(displayHandler->window->pixelBuffer) + (a * 0x20), (a + 0xc) * 0x20, e * 0x20);
|
||||
GXS_LoadBG3Char((u8 *)(displayHandler->window->pixelBuffer) + (a * 0x20), (a + 0xc) * 0x20, e * 0x20);
|
||||
a += 0x14;
|
||||
}
|
||||
} else {
|
||||
s32 height = 2;
|
||||
s32 width = 2;
|
||||
s32 x = drawState->lastModifiedX * 2;
|
||||
s32 y = drawState->lastModifiedY * 2;
|
||||
s32 a = (x >> 3) + ((y >> 3) * 0x14);
|
||||
s32 width = 2;
|
||||
s32 x = drawState->lastModifiedX * 2;
|
||||
s32 y = drawState->lastModifiedY * 2;
|
||||
s32 a = (x >> 3) + ((y >> 3) * 0x14);
|
||||
FillWindowPixelRect(displayHandler->window, MEMO_PAD_PIXEL_TYPE_FILLED, x, y, width, height);
|
||||
GXS_LoadBG3Char((u8*)(displayHandler->window->pixelBuffer) + a * 0x20, (a + 0xc) * 0x20, 0x20);
|
||||
GXS_LoadBG3Char((u8 *)(displayHandler->window->pixelBuffer) + a * 0x20, (a + 0xc) * 0x20, 0x20);
|
||||
}
|
||||
ov24_02254DC8(arg1);
|
||||
}
|
||||
|
|
@ -225,12 +242,8 @@ void ov24_02255050(u32 arg0, void *arg1) {
|
|||
void ov24_02255078(MemoPadDisplayHandler *displayHandler) {
|
||||
// TODO: types
|
||||
static const u32 ov24_0225514C[2][4] = {
|
||||
{
|
||||
0xC0000, 0x38000, 0x2000000, 0x0
|
||||
},
|
||||
{
|
||||
0xC0000, 0x88000, 0x2000003, 0x0
|
||||
}
|
||||
{ 0xC0000, 0x38000, 0x2000000, 0x0 },
|
||||
{ 0xC0000, 0x88000, 0x2000003, 0x0 }
|
||||
};
|
||||
GfGfxLoader_LoadWholePalette(NARC_GRAPHIC_POKETCH, NARC_poketch_narc_0032_bin, PM_LCD_BOTTOM, 0, 0, TRUE, HEAP_ID_POKETCH_APP);
|
||||
if (ov20_02253FBC(&(displayHandler->unk54), NARC_GRAPHIC_POKETCH, NARC_poketch_narc_0033_NCER, NARC_poketch_narc_0034_NANR, HEAP_ID_POKETCH_APP)) {
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ extern void Poketch_InitApp(void *func1, void *func2);
|
|||
extern void ov25_02254854();
|
||||
extern void ov25_0225496C();
|
||||
|
||||
static void ov25_02254840(void)
|
||||
{
|
||||
static void ov25_02254840(void) {
|
||||
Poketch_InitApp(ov25_02254854, ov25_0225496C);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ extern void Poketch_InitApp(void *func1, void *func2);
|
|||
extern void ov26_02254854();
|
||||
extern void ov26_02254A84();
|
||||
|
||||
static void ov26_02254840(void)
|
||||
{
|
||||
static void ov26_02254840(void) {
|
||||
Poketch_InitApp(ov26_02254854, ov26_02254A84);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ extern void Poketch_InitApp(void *func1, void *func2);
|
|||
extern void ov27_02254854();
|
||||
extern void ov27_0225492C();
|
||||
|
||||
static void ov27_02254840(void)
|
||||
{
|
||||
static void ov27_02254840(void) {
|
||||
Poketch_InitApp(ov27_02254854, ov27_0225492C);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ extern void Poketch_InitApp(void *func1, void *func2);
|
|||
extern void ov28_02254854();
|
||||
extern void ov28_022549F4();
|
||||
|
||||
static void ov28_02254840(void)
|
||||
{
|
||||
static void ov28_02254840(void) {
|
||||
Poketch_InitApp(ov28_02254854, ov28_022549F4);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ extern void Poketch_InitApp(void *func1, void *func2);
|
|||
extern void ov29_02254854();
|
||||
extern void ov29_02254914();
|
||||
|
||||
static void ov29_02254840(void)
|
||||
{
|
||||
static void ov29_02254840(void) {
|
||||
Poketch_InitApp(ov29_02254854, ov29_02254914);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ extern void Poketch_InitApp(void *func1, void *func2);
|
|||
extern void ov30_02254854();
|
||||
extern void ov30_0225496C();
|
||||
|
||||
static void ov30_02254840(void)
|
||||
{
|
||||
static void ov30_02254840(void) {
|
||||
Poketch_InitApp(ov30_02254854, ov30_0225496C);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ extern void Poketch_InitApp(void *func1, void *func2);
|
|||
extern void ov31_02254854();
|
||||
extern void ov31_02254954();
|
||||
|
||||
static void ov31_02254840(void)
|
||||
{
|
||||
static void ov31_02254840(void) {
|
||||
Poketch_InitApp(ov31_02254854, ov31_02254954);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ extern void Poketch_InitApp(void *func1, void *func2);
|
|||
extern void ov32_02254854();
|
||||
extern void ov32_0225495C();
|
||||
|
||||
static void ov32_02254840(void)
|
||||
{
|
||||
static void ov32_02254840(void) {
|
||||
Poketch_InitApp(ov32_02254854, ov32_0225495C);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ extern void Poketch_InitApp(void *func1, void *func2);
|
|||
extern void ov33_02254854();
|
||||
extern void ov33_02254908();
|
||||
|
||||
static void ov33_02254840(void)
|
||||
{
|
||||
static void ov33_02254840(void) {
|
||||
Poketch_InitApp(ov33_02254854, ov33_02254908);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ extern void Poketch_InitApp(void *func1, void *func2);
|
|||
extern void ov34_02254854();
|
||||
extern void ov34_02254948();
|
||||
|
||||
static void ov34_02254840(void)
|
||||
{
|
||||
static void ov34_02254840(void) {
|
||||
Poketch_InitApp(ov34_02254854, ov34_02254948);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ extern void Poketch_InitApp(void *func1, void *func2);
|
|||
extern void ov35_02254854();
|
||||
extern void ov35_02254924();
|
||||
|
||||
static void ov35_02254840(void)
|
||||
{
|
||||
static void ov35_02254840(void) {
|
||||
Poketch_InitApp(ov35_02254854, ov35_02254924);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ extern void Poketch_InitApp(void *func1, void *func2);
|
|||
extern void ov36_02254854();
|
||||
extern void ov36_02254990();
|
||||
|
||||
static void ov36_02254840(void)
|
||||
{
|
||||
static void ov36_02254840(void) {
|
||||
Poketch_InitApp(ov36_02254854, ov36_02254990);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ extern void Poketch_InitApp(void *func1, void *func2);
|
|||
extern void ov37_02254854();
|
||||
extern void ov37_02254934();
|
||||
|
||||
static void ov37_02254840(void)
|
||||
{
|
||||
static void ov37_02254840(void) {
|
||||
Poketch_InitApp(ov37_02254854, ov37_02254934);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ extern void Poketch_InitApp(void *func1, void *func2);
|
|||
extern void ov38_02254854();
|
||||
extern void ov38_02254990();
|
||||
|
||||
static void ov38_02254840(void)
|
||||
{
|
||||
static void ov38_02254840(void) {
|
||||
Poketch_InitApp(ov38_02254854, ov38_02254990);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ extern void Poketch_InitApp(void *func1, void *func2);
|
|||
extern void ov39_02254854();
|
||||
extern void ov39_022549D4();
|
||||
|
||||
static void ov39_02254840(void)
|
||||
{
|
||||
static void ov39_02254840(void) {
|
||||
Poketch_InitApp(ov39_02254854, ov39_022549D4);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ extern void Poketch_InitApp(void *func1, void *func2);
|
|||
extern void ov40_02254854();
|
||||
extern void ov40_022549D4();
|
||||
|
||||
static void ov40_02254840(void)
|
||||
{
|
||||
static void ov40_02254840(void) {
|
||||
Poketch_InitApp(ov40_02254854, ov40_022549D4);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ extern void Poketch_InitApp(void *func1, void *func2);
|
|||
extern void ov41_02254854();
|
||||
extern void ov41_02254AD8();
|
||||
|
||||
static void ov41_02254840(void)
|
||||
{
|
||||
static void ov41_02254840(void) {
|
||||
Poketch_InitApp(ov41_02254854, ov41_02254AD8);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ extern void Poketch_InitApp(void *func1, void *func2);
|
|||
extern void ov42_02254854();
|
||||
extern void ov42_02254A38();
|
||||
|
||||
static void ov42_02254840(void)
|
||||
{
|
||||
static void ov42_02254840(void) {
|
||||
Poketch_InitApp(ov42_02254854, ov42_02254A38);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ extern void Poketch_InitApp(void *func1, void *func2);
|
|||
extern void ov43_02254854();
|
||||
extern void ov43_02254970();
|
||||
|
||||
static void ov43_02254840(void)
|
||||
{
|
||||
static void ov43_02254840(void) {
|
||||
Poketch_InitApp(ov43_02254854, ov43_02254970);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ extern void Poketch_InitApp(void *func1, void *func2);
|
|||
extern void ov44_02254854();
|
||||
extern void ov44_02254920();
|
||||
|
||||
static void ov44_02254840(void)
|
||||
{
|
||||
static void ov44_02254840(void) {
|
||||
Poketch_InitApp(ov44_02254854, ov44_02254920);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ extern void Poketch_InitApp(void *func1, void *func2);
|
|||
extern void ov45_02254854();
|
||||
extern void ov45_02254A30();
|
||||
|
||||
static void ov45_02254840(void)
|
||||
{
|
||||
static void ov45_02254840(void) {
|
||||
Poketch_InitApp(ov45_02254854, ov45_02254A30);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ extern void Poketch_InitApp(void *func1, void *func2);
|
|||
extern void ov46_02254854();
|
||||
extern void ov46_02254908();
|
||||
|
||||
static void ov46_02254840(void)
|
||||
{
|
||||
static void ov46_02254840(void) {
|
||||
Poketch_InitApp(ov46_02254854, ov46_02254908);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ extern void Poketch_InitApp(void *func1, void *func2);
|
|||
extern void ov47_02254854();
|
||||
extern void ov47_0225491C();
|
||||
|
||||
static void ov47_02254840(void)
|
||||
{
|
||||
static void ov47_02254840(void) {
|
||||
Poketch_InitApp(ov47_02254854, ov47_0225491C);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ extern void Poketch_InitApp(void *func1, void *func2);
|
|||
extern void ov48_02254854();
|
||||
extern void ov48_0225498C();
|
||||
|
||||
static void ov48_02254840(void)
|
||||
{
|
||||
static void ov48_02254840(void) {
|
||||
Poketch_InitApp(ov48_02254854, ov48_0225498C);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ extern void Poketch_InitApp(void *func1, void *func2);
|
|||
extern void ov49_02254854();
|
||||
extern void ov49_02254974();
|
||||
|
||||
static void ov49_02254840(void)
|
||||
{
|
||||
static void ov49_02254840(void) {
|
||||
Poketch_InitApp(ov49_02254854, ov49_02254974);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ extern void Poketch_InitApp(void *func1, void *func2);
|
|||
extern void ov50_02254854();
|
||||
extern void ov50_02254908();
|
||||
|
||||
static void ov50_02254840(void)
|
||||
{
|
||||
static void ov50_02254840(void) {
|
||||
Poketch_InitApp(ov50_02254854, ov50_02254908);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,15 +2,16 @@
|
|||
#define POKEDIAMOND_OVERLAY_52_H
|
||||
|
||||
#include "global.h"
|
||||
#include "save_vars_flags.h"
|
||||
|
||||
#include "main.h"
|
||||
#include "math_util.h"
|
||||
#include "options.h"
|
||||
#include "overlay_manager.h"
|
||||
#include "player_data.h"
|
||||
#include "poke_overlay.h"
|
||||
#include "save_system_info.h"
|
||||
#include "save.h"
|
||||
#include "save_system_info.h"
|
||||
#include "save_vars_flags.h"
|
||||
#include "unk_02024E64.h"
|
||||
#include "unk_020286F8.h"
|
||||
|
||||
|
|
@ -34,4 +35,4 @@ void ov52_021D7604(HeapID heapId, struct SaveData *save, BOOL set_trainerid);
|
|||
void ov52_021D7688(u32 param0, struct SaveData *save);
|
||||
void ov52_021D769C(u32 param0, struct SaveData *save);
|
||||
|
||||
#endif // POKEDIAMOND_OVERLAY_52_H
|
||||
#endif // POKEDIAMOND_OVERLAY_52_H
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
#include "global.h"
|
||||
#include "overlay_52.h"
|
||||
#include "heap.h"
|
||||
#include "unk_0205FA2C.h"
|
||||
#include "play_timer.h"
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "heap.h"
|
||||
#include "play_timer.h"
|
||||
#include "unk_0205FA2C.h"
|
||||
|
||||
extern struct OverlayManagerTemplate UNK_020FD144;
|
||||
extern struct OverlayManagerTemplate UNK_020F2B7C;
|
||||
|
|
@ -36,128 +37,245 @@ const struct OverlayManagerTemplate ov52_021D76C8 = {
|
|||
};
|
||||
|
||||
const u16 ov52_021D76F8[] = {
|
||||
ITEM_ORAN_BERRY, 1,
|
||||
ITEM_CHERI_BERRY, 1,
|
||||
ITEM_CHESTO_BERRY, 1,
|
||||
ITEM_PECHA_BERRY, 1,
|
||||
ITEM_ORAN_BERRY, 1,
|
||||
ITEM_PECHA_BERRY, 1,
|
||||
ITEM_RAZZ_BERRY, 2,
|
||||
ITEM_BLUK_BERRY, 2,
|
||||
ITEM_CHERI_BERRY, 1,
|
||||
ITEM_ORAN_BERRY, 2,
|
||||
ITEM_SITRUS_BERRY, 1,
|
||||
ITEM_WEPEAR_BERRY, 2,
|
||||
ITEM_WEPEAR_BERRY, 2,
|
||||
ITEM_KELPSY_BERRY, 1,
|
||||
ITEM_CHERI_BERRY, 1,
|
||||
ITEM_PECHA_BERRY, 1,
|
||||
ITEM_ORAN_BERRY, 1,
|
||||
ITEM_ORAN_BERRY, 1,
|
||||
ITEM_RAWST_BERRY, 1,
|
||||
ITEM_RAWST_BERRY, 1,
|
||||
ITEM_RAZZ_BERRY, 1,
|
||||
ITEM_RAZZ_BERRY, 1,
|
||||
ITEM_CHERI_BERRY, 1,
|
||||
ITEM_ORAN_BERRY, 1,
|
||||
ITEM_ORAN_BERRY, 1,
|
||||
ITEM_BLUK_BERRY, 1,
|
||||
ITEM_NANAB_BERRY, 2,
|
||||
ITEM_RAZZ_BERRY, 2,
|
||||
ITEM_BLUK_BERRY, 2,
|
||||
ITEM_PINAP_BERRY, 2,
|
||||
ITEM_LEPPA_BERRY, 1,
|
||||
ITEM_CHESTO_BERRY, 1,
|
||||
ITEM_RAZZ_BERRY, 1,
|
||||
ITEM_RAZZ_BERRY, 1,
|
||||
ITEM_PERSIM_BERRY, 1,
|
||||
ITEM_NANAB_BERRY, 1,
|
||||
ITEM_NANAB_BERRY, 1,
|
||||
ITEM_FIGY_BERRY, 1,
|
||||
ITEM_ASPEAR_BERRY, 1,
|
||||
ITEM_ASPEAR_BERRY, 1,
|
||||
ITEM_RAZZ_BERRY, 1,
|
||||
ITEM_PINAP_BERRY, 1,
|
||||
ITEM_SITRUS_BERRY, 1,
|
||||
ITEM_CHESTO_BERRY, 1,
|
||||
ITEM_WIKI_BERRY, 1,
|
||||
ITEM_AGUAV_BERRY, 1,
|
||||
ITEM_PECHA_BERRY, 1,
|
||||
ITEM_ASPEAR_BERRY, 1,
|
||||
ITEM_IAPAPA_BERRY, 1,
|
||||
ITEM_GREPA_BERRY, 1,
|
||||
ITEM_SITRUS_BERRY, 1,
|
||||
ITEM_ASPEAR_BERRY, 1,
|
||||
ITEM_TAMATO_BERRY, 1,
|
||||
ITEM_LUM_BERRY, 1,
|
||||
ITEM_PECHA_BERRY, 1,
|
||||
ITEM_PINAP_BERRY, 1,
|
||||
ITEM_PINAP_BERRY, 1,
|
||||
ITEM_PINAP_BERRY, 1,
|
||||
ITEM_PERSIM_BERRY, 1,
|
||||
ITEM_PERSIM_BERRY, 1,
|
||||
ITEM_NANAB_BERRY, 1,
|
||||
ITEM_NANAB_BERRY, 1,
|
||||
ITEM_AGUAV_BERRY, 1,
|
||||
ITEM_IAPAPA_BERRY, 1,
|
||||
ITEM_RAWST_BERRY, 1,
|
||||
ITEM_RAWST_BERRY, 1,
|
||||
ITEM_CHERI_BERRY, 1,
|
||||
ITEM_SITRUS_BERRY, 1,
|
||||
ITEM_CHESTO_BERRY, 1,
|
||||
ITEM_POMEG_BERRY, 1,
|
||||
ITEM_PECHA_BERRY, 2,
|
||||
ITEM_BLUK_BERRY, 2,
|
||||
ITEM_WIKI_BERRY, 1,
|
||||
ITEM_MAGO_BERRY, 1,
|
||||
ITEM_RAWST_BERRY, 1,
|
||||
ITEM_PERSIM_BERRY, 1,
|
||||
ITEM_FIGY_BERRY, 1,
|
||||
ITEM_PINAP_BERRY, 2,
|
||||
ITEM_LEPPA_BERRY, 1,
|
||||
ITEM_PECHA_BERRY, 1,
|
||||
ITEM_MAGO_BERRY, 1,
|
||||
ITEM_HONDEW_BERRY, 1,
|
||||
ITEM_WIKI_BERRY, 2,
|
||||
ITEM_MAGO_BERRY, 2,
|
||||
ITEM_AGUAV_BERRY, 2,
|
||||
ITEM_QUALOT_BERRY, 1,
|
||||
ITEM_SITRUS_BERRY, 2,
|
||||
ITEM_BLUK_BERRY, 3,
|
||||
ITEM_NANAB_BERRY, 3,
|
||||
ITEM_WEPEAR_BERRY, 3,
|
||||
ITEM_POMEG_BERRY, 1,
|
||||
ITEM_POMEG_BERRY, 1,
|
||||
ITEM_HONDEW_BERRY, 2,
|
||||
ITEM_HONDEW_BERRY, 2,
|
||||
ITEM_KELPSY_BERRY, 1,
|
||||
ITEM_KELPSY_BERRY, 1,
|
||||
ITEM_TAMATO_BERRY, 1,
|
||||
ITEM_TAMATO_BERRY, 1,
|
||||
ITEM_QUALOT_BERRY, 1,
|
||||
ITEM_QUALOT_BERRY, 1,
|
||||
ITEM_POMEG_BERRY, 1,
|
||||
ITEM_POMEG_BERRY, 1,
|
||||
ITEM_HONDEW_BERRY, 1,
|
||||
ITEM_HONDEW_BERRY, 1,
|
||||
ITEM_TAMATO_BERRY, 1,
|
||||
ITEM_TAMATO_BERRY, 1,
|
||||
ITEM_GREPA_BERRY, 1,
|
||||
ITEM_GREPA_BERRY, 1,
|
||||
ITEM_QUALOT_BERRY, 1,
|
||||
ITEM_QUALOT_BERRY, 1,
|
||||
ITEM_LUM_BERRY, 1,
|
||||
ITEM_LEPPA_BERRY, 1,
|
||||
ITEM_QUALOT_BERRY, 2,
|
||||
ITEM_GREPA_BERRY, 2,
|
||||
ITEM_KELPSY_BERRY, 2,
|
||||
ITEM_KELPSY_BERRY, 2,
|
||||
ITEM_GREPA_BERRY, 1,
|
||||
ITEM_GREPA_BERRY, 1,
|
||||
ITEM_ORAN_BERRY,
|
||||
1,
|
||||
ITEM_CHERI_BERRY,
|
||||
1,
|
||||
ITEM_CHESTO_BERRY,
|
||||
1,
|
||||
ITEM_PECHA_BERRY,
|
||||
1,
|
||||
ITEM_ORAN_BERRY,
|
||||
1,
|
||||
ITEM_PECHA_BERRY,
|
||||
1,
|
||||
ITEM_RAZZ_BERRY,
|
||||
2,
|
||||
ITEM_BLUK_BERRY,
|
||||
2,
|
||||
ITEM_CHERI_BERRY,
|
||||
1,
|
||||
ITEM_ORAN_BERRY,
|
||||
2,
|
||||
ITEM_SITRUS_BERRY,
|
||||
1,
|
||||
ITEM_WEPEAR_BERRY,
|
||||
2,
|
||||
ITEM_WEPEAR_BERRY,
|
||||
2,
|
||||
ITEM_KELPSY_BERRY,
|
||||
1,
|
||||
ITEM_CHERI_BERRY,
|
||||
1,
|
||||
ITEM_PECHA_BERRY,
|
||||
1,
|
||||
ITEM_ORAN_BERRY,
|
||||
1,
|
||||
ITEM_ORAN_BERRY,
|
||||
1,
|
||||
ITEM_RAWST_BERRY,
|
||||
1,
|
||||
ITEM_RAWST_BERRY,
|
||||
1,
|
||||
ITEM_RAZZ_BERRY,
|
||||
1,
|
||||
ITEM_RAZZ_BERRY,
|
||||
1,
|
||||
ITEM_CHERI_BERRY,
|
||||
1,
|
||||
ITEM_ORAN_BERRY,
|
||||
1,
|
||||
ITEM_ORAN_BERRY,
|
||||
1,
|
||||
ITEM_BLUK_BERRY,
|
||||
1,
|
||||
ITEM_NANAB_BERRY,
|
||||
2,
|
||||
ITEM_RAZZ_BERRY,
|
||||
2,
|
||||
ITEM_BLUK_BERRY,
|
||||
2,
|
||||
ITEM_PINAP_BERRY,
|
||||
2,
|
||||
ITEM_LEPPA_BERRY,
|
||||
1,
|
||||
ITEM_CHESTO_BERRY,
|
||||
1,
|
||||
ITEM_RAZZ_BERRY,
|
||||
1,
|
||||
ITEM_RAZZ_BERRY,
|
||||
1,
|
||||
ITEM_PERSIM_BERRY,
|
||||
1,
|
||||
ITEM_NANAB_BERRY,
|
||||
1,
|
||||
ITEM_NANAB_BERRY,
|
||||
1,
|
||||
ITEM_FIGY_BERRY,
|
||||
1,
|
||||
ITEM_ASPEAR_BERRY,
|
||||
1,
|
||||
ITEM_ASPEAR_BERRY,
|
||||
1,
|
||||
ITEM_RAZZ_BERRY,
|
||||
1,
|
||||
ITEM_PINAP_BERRY,
|
||||
1,
|
||||
ITEM_SITRUS_BERRY,
|
||||
1,
|
||||
ITEM_CHESTO_BERRY,
|
||||
1,
|
||||
ITEM_WIKI_BERRY,
|
||||
1,
|
||||
ITEM_AGUAV_BERRY,
|
||||
1,
|
||||
ITEM_PECHA_BERRY,
|
||||
1,
|
||||
ITEM_ASPEAR_BERRY,
|
||||
1,
|
||||
ITEM_IAPAPA_BERRY,
|
||||
1,
|
||||
ITEM_GREPA_BERRY,
|
||||
1,
|
||||
ITEM_SITRUS_BERRY,
|
||||
1,
|
||||
ITEM_ASPEAR_BERRY,
|
||||
1,
|
||||
ITEM_TAMATO_BERRY,
|
||||
1,
|
||||
ITEM_LUM_BERRY,
|
||||
1,
|
||||
ITEM_PECHA_BERRY,
|
||||
1,
|
||||
ITEM_PINAP_BERRY,
|
||||
1,
|
||||
ITEM_PINAP_BERRY,
|
||||
1,
|
||||
ITEM_PINAP_BERRY,
|
||||
1,
|
||||
ITEM_PERSIM_BERRY,
|
||||
1,
|
||||
ITEM_PERSIM_BERRY,
|
||||
1,
|
||||
ITEM_NANAB_BERRY,
|
||||
1,
|
||||
ITEM_NANAB_BERRY,
|
||||
1,
|
||||
ITEM_AGUAV_BERRY,
|
||||
1,
|
||||
ITEM_IAPAPA_BERRY,
|
||||
1,
|
||||
ITEM_RAWST_BERRY,
|
||||
1,
|
||||
ITEM_RAWST_BERRY,
|
||||
1,
|
||||
ITEM_CHERI_BERRY,
|
||||
1,
|
||||
ITEM_SITRUS_BERRY,
|
||||
1,
|
||||
ITEM_CHESTO_BERRY,
|
||||
1,
|
||||
ITEM_POMEG_BERRY,
|
||||
1,
|
||||
ITEM_PECHA_BERRY,
|
||||
2,
|
||||
ITEM_BLUK_BERRY,
|
||||
2,
|
||||
ITEM_WIKI_BERRY,
|
||||
1,
|
||||
ITEM_MAGO_BERRY,
|
||||
1,
|
||||
ITEM_RAWST_BERRY,
|
||||
1,
|
||||
ITEM_PERSIM_BERRY,
|
||||
1,
|
||||
ITEM_FIGY_BERRY,
|
||||
1,
|
||||
ITEM_PINAP_BERRY,
|
||||
2,
|
||||
ITEM_LEPPA_BERRY,
|
||||
1,
|
||||
ITEM_PECHA_BERRY,
|
||||
1,
|
||||
ITEM_MAGO_BERRY,
|
||||
1,
|
||||
ITEM_HONDEW_BERRY,
|
||||
1,
|
||||
ITEM_WIKI_BERRY,
|
||||
2,
|
||||
ITEM_MAGO_BERRY,
|
||||
2,
|
||||
ITEM_AGUAV_BERRY,
|
||||
2,
|
||||
ITEM_QUALOT_BERRY,
|
||||
1,
|
||||
ITEM_SITRUS_BERRY,
|
||||
2,
|
||||
ITEM_BLUK_BERRY,
|
||||
3,
|
||||
ITEM_NANAB_BERRY,
|
||||
3,
|
||||
ITEM_WEPEAR_BERRY,
|
||||
3,
|
||||
ITEM_POMEG_BERRY,
|
||||
1,
|
||||
ITEM_POMEG_BERRY,
|
||||
1,
|
||||
ITEM_HONDEW_BERRY,
|
||||
2,
|
||||
ITEM_HONDEW_BERRY,
|
||||
2,
|
||||
ITEM_KELPSY_BERRY,
|
||||
1,
|
||||
ITEM_KELPSY_BERRY,
|
||||
1,
|
||||
ITEM_TAMATO_BERRY,
|
||||
1,
|
||||
ITEM_TAMATO_BERRY,
|
||||
1,
|
||||
ITEM_QUALOT_BERRY,
|
||||
1,
|
||||
ITEM_QUALOT_BERRY,
|
||||
1,
|
||||
ITEM_POMEG_BERRY,
|
||||
1,
|
||||
ITEM_POMEG_BERRY,
|
||||
1,
|
||||
ITEM_HONDEW_BERRY,
|
||||
1,
|
||||
ITEM_HONDEW_BERRY,
|
||||
1,
|
||||
ITEM_TAMATO_BERRY,
|
||||
1,
|
||||
ITEM_TAMATO_BERRY,
|
||||
1,
|
||||
ITEM_GREPA_BERRY,
|
||||
1,
|
||||
ITEM_GREPA_BERRY,
|
||||
1,
|
||||
ITEM_QUALOT_BERRY,
|
||||
1,
|
||||
ITEM_QUALOT_BERRY,
|
||||
1,
|
||||
ITEM_LUM_BERRY,
|
||||
1,
|
||||
ITEM_LEPPA_BERRY,
|
||||
1,
|
||||
ITEM_QUALOT_BERRY,
|
||||
2,
|
||||
ITEM_GREPA_BERRY,
|
||||
2,
|
||||
ITEM_KELPSY_BERRY,
|
||||
2,
|
||||
ITEM_KELPSY_BERRY,
|
||||
2,
|
||||
ITEM_GREPA_BERRY,
|
||||
1,
|
||||
ITEM_GREPA_BERRY,
|
||||
1,
|
||||
};
|
||||
|
||||
BOOL ov52_021D74E0(struct OverlayManager *manager, u32 *status)
|
||||
{
|
||||
BOOL ov52_021D74E0(struct OverlayManager *manager, u32 *status) {
|
||||
#pragma unused(manager)
|
||||
#pragma unused(status)
|
||||
CreateHeap(3, 0x4d, 0x20000);
|
||||
|
|
@ -166,8 +284,7 @@ BOOL ov52_021D74E0(struct OverlayManager *manager, u32 *status)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL ov52_021D74F8(struct OverlayManager *manager, u32 *status)
|
||||
{
|
||||
BOOL ov52_021D74F8(struct OverlayManager *manager, u32 *status) {
|
||||
#pragma unused(status)
|
||||
struct SaveData *save = (struct SaveData *)OverlayManager_GetField18(manager)[2]; // weird
|
||||
|
||||
|
|
@ -176,8 +293,7 @@ BOOL ov52_021D74F8(struct OverlayManager *manager, u32 *status)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL ov52_021D750C(struct OverlayManager *manager, u32 *status)
|
||||
{
|
||||
BOOL ov52_021D750C(struct OverlayManager *manager, u32 *status) {
|
||||
#pragma unused(manager)
|
||||
#pragma unused(status)
|
||||
DestroyHeap(HEAP_ID_77);
|
||||
|
|
@ -186,8 +302,7 @@ BOOL ov52_021D750C(struct OverlayManager *manager, u32 *status)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL ov52_021D7528(struct OverlayManager *manager, u32 *status)
|
||||
{
|
||||
BOOL ov52_021D7528(struct OverlayManager *manager, u32 *status) {
|
||||
#pragma unused(manager)
|
||||
#pragma unused(status)
|
||||
CreateHeap(3, 0x4d, 0x20000);
|
||||
|
|
@ -196,8 +311,7 @@ BOOL ov52_021D7528(struct OverlayManager *manager, u32 *status)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL ov52_021D7540(struct OverlayManager *manager, u32 *status)
|
||||
{
|
||||
BOOL ov52_021D7540(struct OverlayManager *manager, u32 *status) {
|
||||
#pragma unused(status)
|
||||
struct SaveData *save = (struct SaveData *)OverlayManager_GetField18(manager)[2]; // weird
|
||||
|
||||
|
|
@ -208,8 +322,7 @@ BOOL ov52_021D7540(struct OverlayManager *manager, u32 *status)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL ov52_021D7560(struct OverlayManager *manager, u32 *status)
|
||||
{
|
||||
BOOL ov52_021D7560(struct OverlayManager *manager, u32 *status) {
|
||||
#pragma unused(manager)
|
||||
#pragma unused(status)
|
||||
DestroyHeap(HEAP_ID_77);
|
||||
|
|
@ -218,8 +331,7 @@ BOOL ov52_021D7560(struct OverlayManager *manager, u32 *status)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL ov52_021D757C(struct OverlayManager *manager, u32 *status)
|
||||
{
|
||||
BOOL ov52_021D757C(struct OverlayManager *manager, u32 *status) {
|
||||
#pragma unused(manager)
|
||||
#pragma unused(status)
|
||||
CreateHeap(3, 0x4d, 0x20000);
|
||||
|
|
@ -228,8 +340,7 @@ BOOL ov52_021D757C(struct OverlayManager *manager, u32 *status)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL ov52_021D7594(struct OverlayManager *manager, u32 *status)
|
||||
{
|
||||
BOOL ov52_021D7594(struct OverlayManager *manager, u32 *status) {
|
||||
#pragma unused(status)
|
||||
struct SaveData *save = (struct SaveData *)OverlayManager_GetField18(manager)[2]; // weird
|
||||
|
||||
|
|
@ -238,8 +349,7 @@ BOOL ov52_021D7594(struct OverlayManager *manager, u32 *status)
|
|||
ov52_021D7688(0x4d, save);
|
||||
Options_SetButtonModeOnMain(save, 0);
|
||||
|
||||
if (!Save_SysInfo_MacAddressIsMine(save_info) || !Save_SysInfo_RTCOffsetIsMine(save_info))
|
||||
{
|
||||
if (!Save_SysInfo_MacAddressIsMine(save_info) || !Save_SysInfo_RTCOffsetIsMine(save_info)) {
|
||||
sub_020238A4(Save_SysInfo_RTC_Get(save));
|
||||
Save_SysInfo_InitFromSystem(save_info);
|
||||
}
|
||||
|
|
@ -249,8 +359,7 @@ BOOL ov52_021D7594(struct OverlayManager *manager, u32 *status)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL ov52_021D75E8(struct OverlayManager *manager, u32 *status)
|
||||
{
|
||||
BOOL ov52_021D75E8(struct OverlayManager *manager, u32 *status) {
|
||||
#pragma unused(manager)
|
||||
#pragma unused(status)
|
||||
DestroyHeap(HEAP_ID_77);
|
||||
|
|
@ -259,8 +368,7 @@ BOOL ov52_021D75E8(struct OverlayManager *manager, u32 *status)
|
|||
return 1;
|
||||
}
|
||||
|
||||
void ov52_021D7604(HeapID heapId, struct SaveData *save, BOOL set_trainerid)
|
||||
{
|
||||
void ov52_021D7604(HeapID heapId, struct SaveData *save, BOOL set_trainerid) {
|
||||
Save_SysInfo_InitFromSystem(Save_SysInfo_Get(save));
|
||||
Save_SysInfo_RTC_Init(Save_SysInfo_RTC_Get(save));
|
||||
|
||||
|
|
@ -270,10 +378,9 @@ void ov52_021D7604(HeapID heapId, struct SaveData *save, BOOL set_trainerid)
|
|||
sub_0206007C(save);
|
||||
|
||||
PlayerProfile *playerProfile = Save_PlayerData_GetProfileAddr(save);
|
||||
u32 trainerid = MTRandom();
|
||||
u32 trainerid = MTRandom();
|
||||
|
||||
if (set_trainerid)
|
||||
{
|
||||
if (set_trainerid) {
|
||||
PlayerProfile_SetTrainerID(playerProfile, trainerid);
|
||||
}
|
||||
|
||||
|
|
@ -285,20 +392,17 @@ void ov52_021D7604(HeapID heapId, struct SaveData *save, BOOL set_trainerid)
|
|||
sub_020250C4(sub_02024ECC(save), heapId, ov52_021D76F8, NELEMS(ov52_021D76F8) / 2);
|
||||
}
|
||||
|
||||
void ov52_021D7688(u32 unused, struct SaveData *save)
|
||||
{
|
||||
void ov52_021D7688(u32 unused, struct SaveData *save) {
|
||||
#pragma unused(unused)
|
||||
|
||||
if (sub_020226FC(save))
|
||||
{
|
||||
if (sub_020226FC(save)) {
|
||||
return;
|
||||
}
|
||||
|
||||
OS_ResetSystem(0);
|
||||
}
|
||||
|
||||
void ov52_021D769C(u32 unused, struct SaveData *save)
|
||||
{
|
||||
void ov52_021D769C(u32 unused, struct SaveData *save) {
|
||||
#pragma unused(unused)
|
||||
|
||||
Save_InitDynamicRegion(save);
|
||||
|
|
|
|||
|
|
@ -2,24 +2,23 @@
|
|||
#define POKEDIAMOND_ov59_INTRO_H
|
||||
|
||||
#include "nitro/types.h"
|
||||
#include "heap.h"
|
||||
#include "options.h"
|
||||
#include "save.h"
|
||||
#include "main.h"
|
||||
#include "player_data.h"
|
||||
#include "list_menu_items.h"
|
||||
#include "list_menu.h"
|
||||
|
||||
struct ov59_UnkPlayerStruct
|
||||
{
|
||||
#include "heap.h"
|
||||
#include "list_menu.h"
|
||||
#include "list_menu_items.h"
|
||||
#include "main.h"
|
||||
#include "options.h"
|
||||
#include "player_data.h"
|
||||
#include "save.h"
|
||||
|
||||
struct ov59_UnkPlayerStruct {
|
||||
u8 padding[0x4];
|
||||
PlayerGender gender;
|
||||
u8 padding2[0x10];
|
||||
struct String *name;
|
||||
};
|
||||
|
||||
typedef struct ov59_IntroOverlayData
|
||||
{
|
||||
typedef struct ov59_IntroOverlayData {
|
||||
HeapID heapId;
|
||||
struct SaveData *save;
|
||||
struct Options *options;
|
||||
|
|
@ -65,40 +64,33 @@ typedef struct ov59_IntroOverlayData
|
|||
u32 unkB0;
|
||||
} ov59_IntroOverlayData;
|
||||
|
||||
struct ov59_ListStruct021D9E0C
|
||||
{
|
||||
struct ov59_ListStruct021D9E0C {
|
||||
u32 msgNo;
|
||||
s32 val;
|
||||
};
|
||||
|
||||
struct ov59_WindowTemplateGroup
|
||||
{
|
||||
struct ov59_WindowTemplateGroup {
|
||||
struct WindowTemplate template1;
|
||||
struct WindowTemplate template2;
|
||||
};
|
||||
|
||||
struct ov59_GraphicsPaletteMapSubstruct021D9F90
|
||||
{
|
||||
struct ov59_GraphicsPaletteMapSubstruct021D9F90 {
|
||||
u32 charNum;
|
||||
u32 palNum;
|
||||
};
|
||||
struct ov59_GraphicsPaletteMap021D9F90
|
||||
{
|
||||
struct ov59_GraphicsPaletteMap021D9F90 {
|
||||
struct ov59_GraphicsPaletteMapSubstruct021D9F90 map[11];
|
||||
};
|
||||
|
||||
struct ov59_UnkStruct021D9E30
|
||||
{
|
||||
struct ov59_UnkStruct021D9E30 {
|
||||
u32 scrnIds[5];
|
||||
};
|
||||
|
||||
struct ov59_CharStruct021D9DEC
|
||||
{
|
||||
struct ov59_CharStruct021D9DEC {
|
||||
u32 narcId[4];
|
||||
};
|
||||
|
||||
struct ov59_CharStruct021D9E70
|
||||
{
|
||||
struct ov59_CharStruct021D9E70 {
|
||||
u32 charData[6];
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@
|
|||
#define POKEDIAMOND_ov59_TV_H
|
||||
|
||||
#include "nitro/types.h"
|
||||
#include "main.h"
|
||||
|
||||
#include "bg_window.h"
|
||||
#include "main.h"
|
||||
#include "msgdata.h"
|
||||
|
||||
typedef struct ov59_TVOverlayData2
|
||||
{
|
||||
typedef struct ov59_TVOverlayData2 {
|
||||
HeapID heapId;
|
||||
struct BgConfig *bgConfig;
|
||||
struct MsgData *msgData;
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,17 +1,21 @@
|
|||
#include "global.h"
|
||||
#include "ov59_TV.h"
|
||||
#include "gf_gfx_planes.h"
|
||||
#include "PAD_pad.h"
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "constants/rgb.h"
|
||||
#include "constants/sndseq.h"
|
||||
|
||||
#include "demo/intro/intro_tv.naix"
|
||||
#include "msgdata/msg.naix"
|
||||
#include "msgdata/msg/narc_0549.h"
|
||||
|
||||
#include "PAD_pad.h"
|
||||
#include "filesystem.h"
|
||||
#include "font.h"
|
||||
#include "game_init.h"
|
||||
#include "gf_gfx_loader.h"
|
||||
#include "gf_gfx_planes.h"
|
||||
#include "heap.h"
|
||||
#include "msgdata/msg.naix"
|
||||
#include "msgdata/msg/narc_0549.h"
|
||||
#include "overlay_manager.h"
|
||||
#include "text.h"
|
||||
#include "unk_020040F4.h"
|
||||
|
|
@ -21,271 +25,253 @@ extern void sub_0200E3A0(PMLCDTarget, s32);
|
|||
extern void BeginNormalPaletteFade(u32 pattern, u32 typeTop, u32 typeBottom, u16 colour, u32 duration, u32 framesPer, HeapID heapId);
|
||||
extern BOOL IsPaletteFadeFinished(void);
|
||||
|
||||
const struct WindowTemplate ov59_021DA04C =
|
||||
{
|
||||
.bgId = GF_BG_LYR_MAIN_2,
|
||||
.left = 0,
|
||||
.top = 0,
|
||||
.width = 32,
|
||||
.height = 24,
|
||||
.palette = 1,
|
||||
.baseTile = 1,
|
||||
};
|
||||
const struct WindowTemplate ov59_021DA04C = {
|
||||
.bgId = GF_BG_LYR_MAIN_2,
|
||||
.left = 0,
|
||||
.top = 0,
|
||||
.width = 32,
|
||||
.height = 24,
|
||||
.palette = 1,
|
||||
.baseTile = 1,
|
||||
};
|
||||
|
||||
const struct GraphicsModes ov59_021DA054 =
|
||||
{
|
||||
.dispMode = GX_DISPMODE_GRAPHICS,
|
||||
.bgMode = GX_BGMODE_0,
|
||||
.subMode = GX_BGMODE_0,
|
||||
._2d3dMode = GX_BG0_AS_2D,
|
||||
};
|
||||
const struct GraphicsModes ov59_021DA054 = {
|
||||
.dispMode = GX_DISPMODE_GRAPHICS,
|
||||
.bgMode = GX_BGMODE_0,
|
||||
.subMode = GX_BGMODE_0,
|
||||
._2d3dMode = GX_BG0_AS_2D,
|
||||
};
|
||||
|
||||
const struct BgTemplate ov59_021DA080 =
|
||||
{
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.bufferSize = 2048,
|
||||
.baseTile = 0,
|
||||
const struct BgTemplate ov59_021DA080 = {
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.bufferSize = 2048,
|
||||
.baseTile = 0,
|
||||
|
||||
.size = GF_BG_SCR_SIZE_256x256,
|
||||
.colorMode = GX_BG_COLORMODE_16,
|
||||
.screenBase = GX_BG_SCRBASE_0x0000,
|
||||
.charBase = GX_BG_CHARBASE_0x18000,
|
||||
.bgExtPltt = GX_BG_EXTPLTT_01,
|
||||
.priority = 1,
|
||||
.areaOver = GX_BG_AREAOVER_XLU,
|
||||
.dummy = 0,
|
||||
.mosaic = FALSE
|
||||
};
|
||||
.size = GF_BG_SCR_SIZE_256x256,
|
||||
.colorMode = GX_BG_COLORMODE_16,
|
||||
.screenBase = GX_BG_SCRBASE_0x0000,
|
||||
.charBase = GX_BG_CHARBASE_0x18000,
|
||||
.bgExtPltt = GX_BG_EXTPLTT_01,
|
||||
.priority = 1,
|
||||
.areaOver = GX_BG_AREAOVER_XLU,
|
||||
.dummy = 0,
|
||||
.mosaic = FALSE
|
||||
};
|
||||
|
||||
const struct BgTemplate ov59_021DA09C =
|
||||
{
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.bufferSize = 2048,
|
||||
.baseTile = 0,
|
||||
const struct BgTemplate ov59_021DA09C = {
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.bufferSize = 2048,
|
||||
.baseTile = 0,
|
||||
|
||||
.size = GF_BG_SCR_SIZE_256x256,
|
||||
.colorMode = GX_BG_COLORMODE_16,
|
||||
.screenBase = GX_BG_SCRBASE_0x0800,
|
||||
.charBase = GX_BG_CHARBASE_0x14000,
|
||||
.bgExtPltt = GX_BG_EXTPLTT_01,
|
||||
.priority = 1,
|
||||
.areaOver = GX_BG_AREAOVER_XLU,
|
||||
.dummy = 0,
|
||||
.mosaic = FALSE
|
||||
};
|
||||
.size = GF_BG_SCR_SIZE_256x256,
|
||||
.colorMode = GX_BG_COLORMODE_16,
|
||||
.screenBase = GX_BG_SCRBASE_0x0800,
|
||||
.charBase = GX_BG_CHARBASE_0x14000,
|
||||
.bgExtPltt = GX_BG_EXTPLTT_01,
|
||||
.priority = 1,
|
||||
.areaOver = GX_BG_AREAOVER_XLU,
|
||||
.dummy = 0,
|
||||
.mosaic = FALSE
|
||||
};
|
||||
|
||||
const struct BgTemplate ov59_021DA064 =
|
||||
{
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.bufferSize = 2048,
|
||||
.baseTile = 0,
|
||||
const struct BgTemplate ov59_021DA064 = {
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.bufferSize = 2048,
|
||||
.baseTile = 0,
|
||||
|
||||
.size = GF_BG_SCR_SIZE_256x256,
|
||||
.colorMode = GX_BG_COLORMODE_16,
|
||||
.screenBase = GX_BG_SCRBASE_0x1000,
|
||||
.charBase = GX_BG_CHARBASE_0x10000,
|
||||
.bgExtPltt = GX_BG_EXTPLTT_01,
|
||||
.priority = 1,
|
||||
.areaOver = GX_BG_AREAOVER_XLU,
|
||||
.dummy = 0,
|
||||
.mosaic = FALSE
|
||||
};
|
||||
.size = GF_BG_SCR_SIZE_256x256,
|
||||
.colorMode = GX_BG_COLORMODE_16,
|
||||
.screenBase = GX_BG_SCRBASE_0x1000,
|
||||
.charBase = GX_BG_CHARBASE_0x10000,
|
||||
.bgExtPltt = GX_BG_EXTPLTT_01,
|
||||
.priority = 1,
|
||||
.areaOver = GX_BG_AREAOVER_XLU,
|
||||
.dummy = 0,
|
||||
.mosaic = FALSE
|
||||
};
|
||||
|
||||
const struct BgTemplate ov59_021DA0B8 =
|
||||
{
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.bufferSize = 2048,
|
||||
.baseTile = 0,
|
||||
const struct BgTemplate ov59_021DA0B8 = {
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.bufferSize = 2048,
|
||||
.baseTile = 0,
|
||||
|
||||
.size = GF_BG_SCR_SIZE_256x256,
|
||||
.colorMode = GX_BG_COLORMODE_256,
|
||||
.screenBase = GX_BG_SCRBASE_0x1800,
|
||||
.charBase = GX_BG_CHARBASE_0x20000,
|
||||
.bgExtPltt = GX_BG_EXTPLTT_01,
|
||||
.priority = 1,
|
||||
.areaOver = GX_BG_AREAOVER_XLU,
|
||||
.dummy = 0,
|
||||
.mosaic = FALSE
|
||||
};
|
||||
.size = GF_BG_SCR_SIZE_256x256,
|
||||
.colorMode = GX_BG_COLORMODE_256,
|
||||
.screenBase = GX_BG_SCRBASE_0x1800,
|
||||
.charBase = GX_BG_CHARBASE_0x20000,
|
||||
.bgExtPltt = GX_BG_EXTPLTT_01,
|
||||
.priority = 1,
|
||||
.areaOver = GX_BG_AREAOVER_XLU,
|
||||
.dummy = 0,
|
||||
.mosaic = FALSE
|
||||
};
|
||||
|
||||
const struct GraphicsBanks ov59_021DA0D4 =
|
||||
{
|
||||
.bg = GX_VRAM_BG_256_AB,
|
||||
.bgextpltt = GX_VRAM_BGEXTPLTT_NONE,
|
||||
.subbg = GX_VRAM_SUB_BG_NONE,
|
||||
.subbgextpltt = GX_VRAM_SUB_BGEXTPLTT_NONE,
|
||||
.obj = GX_VRAM_OBJ_NONE,
|
||||
.objextpltt = GX_VRAM_OBJEXTPLTT_NONE,
|
||||
.subobj = GX_VRAM_SUB_OBJ_NONE,
|
||||
.subobjextpltt = GX_VRAM_SUB_OBJEXTPLTT_NONE,
|
||||
.tex = GX_VRAM_TEX_NONE,
|
||||
.texpltt = GX_VRAM_TEXPLTT_NONE
|
||||
};
|
||||
const struct GraphicsBanks ov59_021DA0D4 = {
|
||||
.bg = GX_VRAM_BG_256_AB,
|
||||
.bgextpltt = GX_VRAM_BGEXTPLTT_NONE,
|
||||
.subbg = GX_VRAM_SUB_BG_NONE,
|
||||
.subbgextpltt = GX_VRAM_SUB_BGEXTPLTT_NONE,
|
||||
.obj = GX_VRAM_OBJ_NONE,
|
||||
.objextpltt = GX_VRAM_OBJEXTPLTT_NONE,
|
||||
.subobj = GX_VRAM_SUB_OBJ_NONE,
|
||||
.subobjextpltt = GX_VRAM_SUB_OBJEXTPLTT_NONE,
|
||||
.tex = GX_VRAM_TEX_NONE,
|
||||
.texpltt = GX_VRAM_TEXPLTT_NONE
|
||||
};
|
||||
|
||||
BOOL ov59_TVInit(struct OverlayManager *overlayManager, u32 *status)
|
||||
{
|
||||
BOOL ov59_TVInit(struct OverlayManager *overlayManager, u32 *status) {
|
||||
#pragma unused(status)
|
||||
CreateHeap(3, HEAP_ID_INTRO_TV, 0x40000);
|
||||
ov59_TVOverlayData *data = (ov59_TVOverlayData *)OverlayManager_CreateAndGetData(overlayManager, sizeof(ov59_TVOverlayData), HEAP_ID_INTRO_TV);
|
||||
memset((void *)data, 0, sizeof(ov59_TVOverlayData));
|
||||
data->heapId = HEAP_ID_INTRO_TV;
|
||||
data->unk24 = 0;
|
||||
data->unk24 = 0;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL ov59_TVMain(struct OverlayManager *overlayManager, u32 *status)
|
||||
{
|
||||
BOOL ov59_TVMain(struct OverlayManager *overlayManager, u32 *status) {
|
||||
ov59_TVOverlayData *data = (ov59_TVOverlayData *)OverlayManager_GetData(overlayManager);
|
||||
BOOL ret = FALSE;
|
||||
BOOL ret = FALSE;
|
||||
|
||||
switch (*status)
|
||||
{
|
||||
case 0:
|
||||
sub_0200E3A0(PM_LCD_TOP, 0);
|
||||
sub_0200E3A0(PM_LCD_BOTTOM, 0);
|
||||
switch (*status) {
|
||||
case 0:
|
||||
sub_0200E3A0(PM_LCD_TOP, 0);
|
||||
sub_0200E3A0(PM_LCD_BOTTOM, 0);
|
||||
|
||||
Main_SetVBlankIntrCB(NULL, NULL);
|
||||
Main_SetHBlankIntrCB(NULL, NULL);
|
||||
Main_SetVBlankIntrCB(NULL, NULL);
|
||||
Main_SetHBlankIntrCB(NULL, NULL);
|
||||
|
||||
GfGfx_DisableEngineAPlanes();
|
||||
GfGfx_DisableEngineBPlanes();
|
||||
GfGfx_DisableEngineAPlanes();
|
||||
GfGfx_DisableEngineBPlanes();
|
||||
|
||||
GX_SetVisiblePlane(0);
|
||||
GXS_SetVisiblePlane(0);
|
||||
GX_SetVisiblePlane(0);
|
||||
GXS_SetVisiblePlane(0);
|
||||
|
||||
SetKeyRepeatTimers(4, 8);
|
||||
SetKeyRepeatTimers(4, 8);
|
||||
|
||||
ov59_TVSetupGraphics(data);
|
||||
ov59_TVSetupMsg(data);
|
||||
ov59_TVSetupGraphics(data);
|
||||
ov59_TVSetupMsg(data);
|
||||
|
||||
Main_SetVBlankIntrCB((void (*)(void *))ov59_TVDoGpuBgUpdate, data);
|
||||
Main_SetVBlankIntrCB((void (*)(void *))ov59_TVDoGpuBgUpdate, data);
|
||||
|
||||
GfGfx_BothDispOn();
|
||||
GfGfx_BothDispOn();
|
||||
|
||||
data->unk24 = 60;
|
||||
data->unk24 = 60;
|
||||
|
||||
*status = 1;
|
||||
*status = 1;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if (data->unk24 != 0) {
|
||||
data->unk24--;
|
||||
break;
|
||||
}
|
||||
|
||||
case 1:
|
||||
if (data->unk24 != 0)
|
||||
{
|
||||
data->unk24--;
|
||||
break;
|
||||
}
|
||||
sub_0200414C(SEQ_TV_HOUSOU);
|
||||
sub_0200433C(4, SEQ_TV_HOUSOU, 1);
|
||||
|
||||
sub_0200414C(SEQ_TV_HOUSOU);
|
||||
sub_0200433C(4, SEQ_TV_HOUSOU, 1);
|
||||
data->unk24 = 90;
|
||||
|
||||
data->unk24 = 90;
|
||||
*status = 2;
|
||||
break;
|
||||
|
||||
*status = 2;
|
||||
case 2:
|
||||
if (data->unk24 != 0) {
|
||||
data->unk24--;
|
||||
break;
|
||||
}
|
||||
data->unk24 = 0; //??
|
||||
|
||||
case 2:
|
||||
if (data->unk24 != 0)
|
||||
{
|
||||
data->unk24--;
|
||||
break;
|
||||
}
|
||||
data->unk24 = 0; //??
|
||||
BeginNormalPaletteFade(0, 1, 1, RGB_BLACK, 6, 1, data->heapId);
|
||||
|
||||
BeginNormalPaletteFade(0, 1, 1, RGB_BLACK, 6, 1, data->heapId);
|
||||
*status = 3;
|
||||
break;
|
||||
|
||||
*status = 3;
|
||||
case 3:
|
||||
ov59_021D9D78(data);
|
||||
|
||||
if (IsPaletteFadeFinished() != TRUE) {
|
||||
break;
|
||||
}
|
||||
|
||||
case 3:
|
||||
ov59_021D9D78(data);
|
||||
*status = 4;
|
||||
break;
|
||||
|
||||
if (IsPaletteFadeFinished() != TRUE)
|
||||
{
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
ov59_021D9D78(data);
|
||||
|
||||
*status = 4;
|
||||
if (ov59_021D9C74(data, narc_0549_00000, 40, 48) != TRUE) {
|
||||
break;
|
||||
}
|
||||
|
||||
case 4:
|
||||
ov59_021D9D78(data);
|
||||
BeginNormalPaletteFade(0, 0, 0, RGB_BLACK, 6, 1, data->heapId);
|
||||
|
||||
if (ov59_021D9C74(data, narc_0549_00000, 40, 48) != TRUE)
|
||||
{
|
||||
break;
|
||||
}
|
||||
*status = 5;
|
||||
break;
|
||||
|
||||
BeginNormalPaletteFade(0, 0, 0, RGB_BLACK, 6, 1, data->heapId);
|
||||
case 5:
|
||||
ov59_021D9D78(data);
|
||||
|
||||
*status = 5;
|
||||
if (IsPaletteFadeFinished() != TRUE) {
|
||||
break;
|
||||
}
|
||||
|
||||
case 5:
|
||||
ov59_021D9D78(data);
|
||||
ov59_TVDestroyMsg(data);
|
||||
ov59_TVDestroyGraphics(data);
|
||||
|
||||
if (IsPaletteFadeFinished() != TRUE)
|
||||
{
|
||||
break;
|
||||
}
|
||||
Main_SetVBlankIntrCB(NULL, NULL);
|
||||
|
||||
ov59_TVDestroyMsg(data);
|
||||
ov59_TVDestroyGraphics(data);
|
||||
|
||||
Main_SetVBlankIntrCB(NULL, NULL);
|
||||
|
||||
ret = TRUE;
|
||||
break;
|
||||
ret = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
BOOL ov59_TVExit(struct OverlayManager *overlayManager, u32 *status)
|
||||
{
|
||||
#pragma unused (status)
|
||||
BOOL ov59_TVExit(struct OverlayManager *overlayManager, u32 *status) {
|
||||
#pragma unused(status)
|
||||
HeapID heapId = ((ov59_TVOverlayData *)OverlayManager_GetData(overlayManager))->heapId;
|
||||
OverlayManager_FreeData(overlayManager);
|
||||
DestroyHeap(heapId);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void ov59_TVDoGpuBgUpdate(ov59_TVOverlayData *data)
|
||||
{
|
||||
void ov59_TVDoGpuBgUpdate(ov59_TVOverlayData *data) {
|
||||
DoScheduledBgGpuUpdates(data->bgConfig);
|
||||
}
|
||||
|
||||
void ov59_TVSetupGraphics(ov59_TVOverlayData *data)
|
||||
{
|
||||
const struct GraphicsBanks banks = ov59_021DA0D4; //sp #0x90
|
||||
void ov59_TVSetupGraphics(ov59_TVOverlayData *data) {
|
||||
const struct GraphicsBanks banks = ov59_021DA0D4; // sp #0x90
|
||||
GfGfx_SetBanks(&banks);
|
||||
|
||||
data->bgConfig = BgConfig_Alloc(data->heapId);
|
||||
|
||||
const struct GraphicsModes modes = ov59_021DA054; //sp #0x80
|
||||
const struct GraphicsModes modes = ov59_021DA054; // sp #0x80
|
||||
SetBothScreensModesAndDisable(&modes);
|
||||
|
||||
const struct BgTemplate bgTemplateMain2 = ov59_021DA080; //sp #0x64
|
||||
const struct BgTemplate bgTemplateMain2 = ov59_021DA080; // sp #0x64
|
||||
InitBgFromTemplate(data->bgConfig, GF_BG_LYR_MAIN_2, &bgTemplateMain2, GF_BG_TYPE_TEXT);
|
||||
|
||||
BG_ClearCharDataRange(GF_BG_LYR_MAIN_2, 0x20, 0, data->heapId);
|
||||
BgClearTilemapBufferAndCommit(data->bgConfig, GF_BG_LYR_MAIN_2);
|
||||
|
||||
const struct BgTemplate bgTemplateMain0 = ov59_021DA09C; //sp #0x48
|
||||
const struct BgTemplate bgTemplateMain0 = ov59_021DA09C; // sp #0x48
|
||||
InitBgFromTemplate(data->bgConfig, GF_BG_LYR_MAIN_0, &bgTemplateMain0, GF_BG_TYPE_TEXT);
|
||||
|
||||
GfGfxLoader_LoadCharData(NARC_DEMO_INTRO_INTRO_TV, NARC_intro_tv_narc_0001_NCGR, data->bgConfig, GF_BG_LYR_MAIN_0, 0, 0, FALSE, data->heapId);
|
||||
GfGfxLoader_LoadScrnData(NARC_DEMO_INTRO_INTRO_TV, NARC_intro_tv_narc_0004_NSCR, data->bgConfig, GF_BG_LYR_MAIN_0, 0, 0, FALSE, data->heapId);
|
||||
|
||||
const struct BgTemplate bgTemplateMain1 = ov59_021DA064; //sp #0x2C
|
||||
const struct BgTemplate bgTemplateMain1 = ov59_021DA064; // sp #0x2C
|
||||
InitBgFromTemplate(data->bgConfig, GF_BG_LYR_MAIN_1, &bgTemplateMain1, GF_BG_TYPE_TEXT);
|
||||
|
||||
GfGfxLoader_LoadCharData(NARC_DEMO_INTRO_INTRO_TV, NARC_intro_tv_narc_0002_NCGR, data->bgConfig, GF_BG_LYR_MAIN_1, 0, 0, FALSE, data->heapId);
|
||||
GfGfxLoader_LoadScrnData(NARC_DEMO_INTRO_INTRO_TV, NARC_intro_tv_narc_0005_NSCR, data->bgConfig, GF_BG_LYR_MAIN_1, 0, 0, FALSE, data->heapId);
|
||||
|
||||
const struct BgTemplate bgTemplateMain3 = ov59_021DA0B8; //sp #0x10
|
||||
const struct BgTemplate bgTemplateMain3 = ov59_021DA0B8; // sp #0x10
|
||||
InitBgFromTemplate(data->bgConfig, GF_BG_LYR_MAIN_3, &bgTemplateMain3, GF_BG_TYPE_TEXT);
|
||||
|
||||
GfGfxLoader_LoadCharData(NARC_DEMO_INTRO_INTRO_TV, NARC_intro_tv_narc_0000_NCGR, data->bgConfig, GF_BG_LYR_MAIN_3, 0, 0, FALSE, data->heapId);
|
||||
|
|
@ -301,8 +287,7 @@ void ov59_TVSetupGraphics(ov59_TVOverlayData *data)
|
|||
G2_SetBlendAlpha(GX_BLEND_PLANEMASK_BG1, (GXBlendPlaneMask)(GX_BLEND_PLANEMASK_BG3 | GX_BLEND_PLANEMASK_BG2), 4, 12);
|
||||
}
|
||||
|
||||
void ov59_TVDestroyGraphics(ov59_TVOverlayData *data)
|
||||
{
|
||||
void ov59_TVDestroyGraphics(ov59_TVOverlayData *data) {
|
||||
ToggleBgLayer(GF_BG_LYR_MAIN_0, GX_PLANE_TOGGLE_OFF);
|
||||
ToggleBgLayer(GF_BG_LYR_MAIN_1, GX_PLANE_TOGGLE_OFF);
|
||||
ToggleBgLayer(GF_BG_LYR_MAIN_2, GX_PLANE_TOGGLE_OFF);
|
||||
|
|
@ -321,8 +306,7 @@ void ov59_TVDestroyGraphics(ov59_TVOverlayData *data)
|
|||
FreeToHeap(data->bgConfig);
|
||||
}
|
||||
|
||||
void ov59_TVSetupMsg(ov59_TVOverlayData *data)
|
||||
{
|
||||
void ov59_TVSetupMsg(ov59_TVOverlayData *data) {
|
||||
data->msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0549_bin, data->heapId);
|
||||
|
||||
ResetAllTextPrinters();
|
||||
|
|
@ -330,62 +314,56 @@ void ov59_TVSetupMsg(ov59_TVOverlayData *data)
|
|||
data->unk0C = 0;
|
||||
}
|
||||
|
||||
void ov59_TVDestroyMsg(ov59_TVOverlayData *data)
|
||||
{
|
||||
void ov59_TVDestroyMsg(ov59_TVOverlayData *data) {
|
||||
DestroyMsgData(data->msgData);
|
||||
}
|
||||
|
||||
BOOL ov59_021D9C74(ov59_TVOverlayData *data, u32 msgNo, u32 param2, u32 param3)
|
||||
{
|
||||
BOOL ov59_021D9C74(ov59_TVOverlayData *data, u32 msgNo, u32 param2, u32 param3) {
|
||||
BOOL ret = FALSE;
|
||||
switch (data->unk0C)
|
||||
{
|
||||
case 0:
|
||||
ToggleBgLayer(GF_BG_LYR_MAIN_2, GX_PLANE_TOGGLE_OFF);
|
||||
struct String *string = String_New(1024, data->heapId);
|
||||
ReadMsgDataIntoString(data->msgData, msgNo, string);
|
||||
AddWindow(data->bgConfig, &data->window, &ov59_021DA04C);
|
||||
FillWindowPixelRect(&data->window, 0, 0, 0, 256, 192);
|
||||
u32 width = FontID_String_GetWidthMultiline(0, string, 0);
|
||||
switch (data->unk0C) {
|
||||
case 0:
|
||||
ToggleBgLayer(GF_BG_LYR_MAIN_2, GX_PLANE_TOGGLE_OFF);
|
||||
struct String *string = String_New(1024, data->heapId);
|
||||
ReadMsgDataIntoString(data->msgData, msgNo, string);
|
||||
AddWindow(data->bgConfig, &data->window, &ov59_021DA04C);
|
||||
FillWindowPixelRect(&data->window, 0, 0, 0, 256, 192);
|
||||
u32 width = FontID_String_GetWidthMultiline(0, string, 0);
|
||||
|
||||
width = (256 - width) / 2;
|
||||
AddTextPrinterParameterized2(&data->window, 0, string, width, param3, TEXT_SPEED_INSTANT, MAKE_TEXT_COLOR(15, 2, 0), NULL);
|
||||
String_Delete(string);
|
||||
CopyWindowToVram(&data->window);
|
||||
ToggleBgLayer(GF_BG_LYR_MAIN_2, GX_PLANE_TOGGLE_ON);
|
||||
data->unk24 = 240;
|
||||
data->unk0C = 1;
|
||||
break;
|
||||
width = (256 - width) / 2;
|
||||
AddTextPrinterParameterized2(&data->window, 0, string, width, param3, TEXT_SPEED_INSTANT, MAKE_TEXT_COLOR(15, 2, 0), NULL);
|
||||
String_Delete(string);
|
||||
CopyWindowToVram(&data->window);
|
||||
ToggleBgLayer(GF_BG_LYR_MAIN_2, GX_PLANE_TOGGLE_ON);
|
||||
data->unk24 = 240;
|
||||
data->unk0C = 1;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if (data->unk24 != 0)
|
||||
{
|
||||
data->unk24--;
|
||||
break;
|
||||
}
|
||||
data->unk0C = 2;
|
||||
case 1:
|
||||
if (data->unk24 != 0) {
|
||||
data->unk24--;
|
||||
break;
|
||||
}
|
||||
data->unk0C = 2;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if((gSystem.newKeys & PAD_BUTTON_A) != 1 && (gSystem.newKeys & PAD_BUTTON_B) != 2)
|
||||
{
|
||||
break;
|
||||
}
|
||||
data->unk0C = 3;
|
||||
case 2:
|
||||
if ((gSystem.newKeys & PAD_BUTTON_A) != 1 && (gSystem.newKeys & PAD_BUTTON_B) != 2) {
|
||||
break;
|
||||
}
|
||||
data->unk0C = 3;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
RemoveWindow(&data->window);
|
||||
BgClearTilemapBufferAndCommit(data->bgConfig, GF_BG_LYR_MAIN_2);
|
||||
data->unk0C = 0;
|
||||
ret = TRUE;
|
||||
break;
|
||||
case 3:
|
||||
RemoveWindow(&data->window);
|
||||
BgClearTilemapBufferAndCommit(data->bgConfig, GF_BG_LYR_MAIN_2);
|
||||
data->unk0C = 0;
|
||||
ret = TRUE;
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ov59_021D9D78(ov59_TVOverlayData *data)
|
||||
{
|
||||
void ov59_021D9D78(ov59_TVOverlayData *data) {
|
||||
data->unk20 += 4;
|
||||
BgSetPosTextAndCommit(data->bgConfig, GF_BG_LYR_MAIN_1, BG_POS_OP_SET_Y, data->unk20 >> 4);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
#include "global.h"
|
||||
#include "poke_overlay.h"
|
||||
|
||||
#include "FS_overlay.h"
|
||||
#include "poke_overlay.h"
|
||||
|
||||
FS_EXTERN_OVERLAY(OVERLAY_08);
|
||||
|
||||
static void ov62_0222D5C0(void)
|
||||
{
|
||||
static void ov62_0222D5C0(void) {
|
||||
HandleLoadOverlay(FS_OVERLAY_ID(OVERLAY_08), 2);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,19 +2,20 @@
|
|||
#define POKEDIAMOND_ov63_021DB450_H
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "unk_02006D98.h"
|
||||
|
||||
typedef struct UnkStruct63_021DB450 //intro base struct type
|
||||
typedef struct UnkStruct63_021DB450 // intro base struct type
|
||||
{
|
||||
struct UnkStruct_02006D98 * field_00; //oddly requires this to be set to progress past copyright/pokemon screen.
|
||||
struct UnkStruct_02006D98_2 * field_04[3]; //mon animations?
|
||||
struct UnkStruct_02006D98 *field_00; // oddly requires this to be set to progress past copyright/pokemon screen.
|
||||
struct UnkStruct_02006D98_2 *field_04[3]; // mon animations?
|
||||
u32 field_10;
|
||||
void * field_14;
|
||||
void * field_18;
|
||||
void *field_14;
|
||||
void *field_18;
|
||||
u8 field_1C;
|
||||
u8 field_1D;
|
||||
u8 padding_1E[2];
|
||||
u32 ** field_20;
|
||||
u32 **field_20;
|
||||
u32 field_24;
|
||||
u32 field_28;
|
||||
u32 field_2C;
|
||||
|
|
@ -22,16 +23,12 @@ typedef struct UnkStruct63_021DB450 //intro base struct type
|
|||
u8 filler_34[0x30];
|
||||
} UnkStruct63_021DB450;
|
||||
|
||||
|
||||
|
||||
typedef struct UnkStruct63_021DBEF0
|
||||
{
|
||||
typedef struct UnkStruct63_021DBEF0 {
|
||||
u32 field_00;
|
||||
u32 field_04;
|
||||
} UnkStruct63_021DBEF0;
|
||||
|
||||
typedef struct UnkStruct63_021DBED8
|
||||
{
|
||||
typedef struct UnkStruct63_021DBED8 {
|
||||
BOOL (*unk_00)(struct UnkStruct63_021DB450 *, u32);
|
||||
BOOL (*unk_04)(struct UnkStruct63_021DB450 *, u32);
|
||||
} UnkStruct63_021DBED8;
|
||||
|
|
@ -39,7 +36,7 @@ typedef struct UnkStruct63_021DBED8
|
|||
u32 ov63_021DB450(u32 param0, u32 param1);
|
||||
u32 ov63_021DB474(u32 param0, u32 param1);
|
||||
u32 ov63_021DB498(void);
|
||||
void Title_SetupMonAnimationSprites(struct UnkStruct63_021DB450 * arg0);
|
||||
void Title_SetupMonAnimationSprites(struct UnkStruct63_021DB450 *arg0);
|
||||
void ov63_021DB580(UnkStruct63_021DB450 *param0);
|
||||
void ov63_021DB598(UnkStruct63_021DB450 *param0);
|
||||
void ov63_021DB5A8(UnkStruct63_021DB450 *param0);
|
||||
|
|
@ -51,6 +48,6 @@ BOOL ov63_021DB838(UnkStruct63_021DB450 *param0, u32 param1);
|
|||
BOOL ov63_021DB884(UnkStruct63_021DB450 *param0, u32 param1);
|
||||
BOOL ov63_021DB8E8(UnkStruct63_021DB450 *param0, u32 param1);
|
||||
void ov63_021DB934(void);
|
||||
void ov63_021DB940(struct UnkStruct63_021DB450 * a0);
|
||||
void ov63_021DB940(struct UnkStruct63_021DB450 *a0);
|
||||
|
||||
#endif //POKEDIAMOND_ov63_021DB450_H
|
||||
#endif // POKEDIAMOND_ov63_021DB450_H
|
||||
|
|
|
|||
|
|
@ -1,29 +1,31 @@
|
|||
#include "global.h"
|
||||
#include "camera.h"
|
||||
#include "heap.h"
|
||||
#include "constants/species.h"
|
||||
#include "gx.h"
|
||||
#include "ov63_021DB450.h"
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "constants/species.h"
|
||||
|
||||
#include "camera.h"
|
||||
#include "gx.h"
|
||||
#include "heap.h"
|
||||
#include "unk_02006D98.h"
|
||||
|
||||
//todo resolve to static code
|
||||
// todo resolve to static code
|
||||
extern u32 (*NNS_GfdDefaultFuncAllocTexVram)(u32 param0, u32 param1, u32 param2);
|
||||
extern u32 (*NNS_GfdDefaultFuncAllocPlttVram)(u32 param0, u32 param1, u32 param2);
|
||||
|
||||
extern void sub_0201327C(u32 param0);
|
||||
extern void sub_020132BC(u32 param0);
|
||||
|
||||
extern void * sub_02012CDC(void *, void *, void *, u32, u32, HeapID);
|
||||
extern void *sub_02012CDC(void *, void *, void *, u32, u32, HeapID);
|
||||
|
||||
extern void sub_02068C00(struct UnkStruct_02006D98_4*, u16, u32, u32, u32, u32, u32);
|
||||
extern void sub_02068C00(struct UnkStruct_02006D98_4 *, u16, u32, u32, u32, u32, u32);
|
||||
extern void sub_02012CC8(void);
|
||||
extern struct Camera * sub_0201343C(void);
|
||||
extern struct Camera *sub_0201343C(void);
|
||||
extern void sub_02013194(void *, u32, u32, u32);
|
||||
extern u32 sub_0201318C(u32, u32, HeapID);
|
||||
|
||||
extern void sub_02012DE4(void *);
|
||||
|
||||
|
||||
extern void sub_020222AC(void);
|
||||
extern void NNS_G2dSetupSoftwareSpriteCamera(void);
|
||||
extern void sub_020222B4(u32, u32);
|
||||
|
|
@ -32,44 +34,40 @@ extern void sub_02013440(void *, u32);
|
|||
extern void sub_020133AC(void *, u32, const void *, struct UnkStruct_02006D98_2 *);
|
||||
extern BOOL sub_020133C8(void *);
|
||||
|
||||
|
||||
extern void sub_02013364(void);
|
||||
extern void sub_02013388(void);
|
||||
|
||||
struct UnkStruct_02006D98_2 * sub_0201341C(struct UnkStruct63_021DB450 *);
|
||||
struct UnkStruct_02006D98_2 *sub_0201341C(struct UnkStruct63_021DB450 *);
|
||||
|
||||
const s32 ov63_021DBEC0[3] = {0x703, 0x7CE, 0x8A8};
|
||||
const s32 ov63_021DBEC0[3] = { 0x703, 0x7CE, 0x8A8 };
|
||||
const struct UnkStruct63_021DBEF0 ov63_021DBEF0[3];
|
||||
|
||||
u32 ov63_021DB450(u32 param0, u32 param1)
|
||||
{
|
||||
u32 ov63_021DB450(u32 param0, u32 param1) {
|
||||
u32 res0 = (NNS_GfdDefaultFuncAllocTexVram)(param0, param1, 0);
|
||||
sub_0201327C(res0);
|
||||
GF_ASSERT(res0);
|
||||
return (u32)((u16)res0 * 8);
|
||||
}
|
||||
|
||||
u32 ov63_021DB474(u32 param0, u32 param1)
|
||||
{
|
||||
u32 ov63_021DB474(u32 param0, u32 param1) {
|
||||
u32 res0 = (NNS_GfdDefaultFuncAllocPlttVram)(param0, param1, 1);
|
||||
GF_ASSERT(res0);
|
||||
sub_020132BC(res0);
|
||||
return (u32)((u16)res0 * 8);
|
||||
}
|
||||
|
||||
u32 ov63_021DB498(void)
|
||||
{
|
||||
u32 ov63_021DB498(void) {
|
||||
return 32;
|
||||
}
|
||||
|
||||
void Title_SetupMonAnimationSprites(struct UnkStruct63_021DB450 * arg0) //TODO: this does a lot more than setup anim sprites
|
||||
void Title_SetupMonAnimationSprites(struct UnkStruct63_021DB450 *arg0) // TODO: this does a lot more than setup anim sprites
|
||||
{
|
||||
struct UnkStruct_02006D98_4 sp1C;
|
||||
int introMonArray[3] = {SPECIES_TURTWIG, SPECIES_CHIMCHAR, SPECIES_PIPLUP};
|
||||
int introMonArray[3] = { SPECIES_TURTWIG, SPECIES_CHIMCHAR, SPECIES_PIPLUP };
|
||||
|
||||
arg0->field_00 = sub_02006D98(HEAP_ID_76); //this is needed to get into the world view, otherwise it is just black
|
||||
arg0->field_00 = sub_02006D98(HEAP_ID_76); // this is needed to get into the world view, otherwise it is just black
|
||||
|
||||
for (u8 i = 0; i < 3; i++) //some kind of animation assignment TODO: investigate further
|
||||
for (u8 i = 0; i < 3; i++) // some kind of animation assignment TODO: investigate further
|
||||
{
|
||||
sub_02068C00(&sp1C, (u16)introMonArray[i], 0, 2, 0, 0, 0);
|
||||
arg0->field_04[i] = sub_020073A0(arg0->field_00, &sp1C, ov63_021DBEF0[i].field_00, ov63_021DBEF0[i].field_04, 0x3FF, i, 0, 0);
|
||||
|
|
@ -84,26 +82,21 @@ void Title_SetupMonAnimationSprites(struct UnkStruct63_021DB450 * arg0) //TODO:
|
|||
sub_02013194(arg0->field_18, sub_0201318C(0x3D, 4, HEAP_ID_76), 10, 1);
|
||||
}
|
||||
|
||||
void ov63_021DB580(UnkStruct63_021DB450 *param0)
|
||||
{
|
||||
void ov63_021DB580(UnkStruct63_021DB450 *param0) {
|
||||
sub_02012DE4(param0->field_18);
|
||||
FreeToHeap(param0->field_14);
|
||||
sub_020072E8(param0->field_00);
|
||||
}
|
||||
|
||||
void ov63_021DB598(UnkStruct63_021DB450 *param0)
|
||||
{
|
||||
if (param0 == NULL)
|
||||
{
|
||||
void ov63_021DB598(UnkStruct63_021DB450 *param0) {
|
||||
if (param0 == NULL) {
|
||||
return;
|
||||
}
|
||||
sub_020081C4(param0->field_00);
|
||||
}
|
||||
|
||||
void ov63_021DB5A8(UnkStruct63_021DB450 *param0)
|
||||
{
|
||||
if (param0 == NULL)
|
||||
{
|
||||
void ov63_021DB5A8(UnkStruct63_021DB450 *param0) {
|
||||
if (param0 == NULL) {
|
||||
return;
|
||||
}
|
||||
sub_020222AC();
|
||||
|
|
@ -114,86 +107,79 @@ void ov63_021DB5A8(UnkStruct63_021DB450 *param0)
|
|||
}
|
||||
|
||||
const struct UnkStruct63_021DBED8 ov63_021DBED8[3] = {
|
||||
{ov63_021DB720, ov63_021DB784},
|
||||
{ov63_021DB7D0, ov63_021DB838},
|
||||
{ov63_021DB884, ov63_021DB8E8}
|
||||
{ ov63_021DB720, ov63_021DB784 },
|
||||
{ ov63_021DB7D0, ov63_021DB838 },
|
||||
{ ov63_021DB884, ov63_021DB8E8 }
|
||||
};
|
||||
|
||||
const struct UnkStruct63_021DBEF0 ov63_021DBEF0[3] = {
|
||||
{0x080, 0xC0},
|
||||
{0x100, 0xC0},
|
||||
{0x050, 0xC0}
|
||||
{ 0x080, 0xC0 },
|
||||
{ 0x100, 0xC0 },
|
||||
{ 0x050, 0xC0 }
|
||||
};
|
||||
|
||||
const struct UnkStruct63_021DBEF0 ov63_021DBF08[3] = { //no idea if this is the right type
|
||||
{4, 5},
|
||||
{2, 3},
|
||||
{0, 1}
|
||||
const struct UnkStruct63_021DBEF0 ov63_021DBF08[3] = {
|
||||
// no idea if this is the right type
|
||||
{ 4, 5 },
|
||||
{ 2, 3 },
|
||||
{ 0, 1 }
|
||||
};
|
||||
|
||||
BOOL ov63_021DB5CC(UnkStruct63_021DB450 *param0, u32 param1, s32 param2)
|
||||
{
|
||||
u8 * state = ¶m0->field_1C;
|
||||
switch(*state)
|
||||
{
|
||||
case 0:
|
||||
G2_SetWndOutsidePlane(GX_WND_PLANEMASK_OBJ | GX_WND_PLANEMASK_BG0, TRUE);
|
||||
sub_02007558(param0->field_04[param1], 12, 0x400);
|
||||
sub_02007558(param0->field_04[param1], 13, 0x400);
|
||||
sub_02007558(param0->field_04[param1], 6, 0);
|
||||
BOOL ov63_021DB5CC(UnkStruct63_021DB450 *param0, u32 param1, s32 param2) {
|
||||
u8 *state = ¶m0->field_1C;
|
||||
switch (*state) {
|
||||
case 0:
|
||||
G2_SetWndOutsidePlane(GX_WND_PLANEMASK_OBJ | GX_WND_PLANEMASK_BG0, TRUE);
|
||||
sub_02007558(param0->field_04[param1], 12, 0x400);
|
||||
sub_02007558(param0->field_04[param1], 13, 0x400);
|
||||
sub_02007558(param0->field_04[param1], 6, 0);
|
||||
(*state)++;
|
||||
// fallthrough
|
||||
case 1:
|
||||
if (ov63_021DBED8[param1].unk_00(param0, param1)) {
|
||||
param0->field_1D = 0;
|
||||
(*state)++;
|
||||
// fallthrough
|
||||
case 1:
|
||||
if (ov63_021DBED8[param1].unk_00(param0, param1))
|
||||
{
|
||||
param0->field_1D = 0;
|
||||
(*state)++;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
sub_02013440(param0->field_18, 1);
|
||||
sub_020133AC(param0->field_18, ov63_021DBF08[param1].field_00, ov63_021DB940, param0->field_04[param1]);
|
||||
sub_020133AC(param0->field_18, ov63_021DBF08[param1].field_04, ov63_021DB940, param0->field_04[param1]);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
sub_02013440(param0->field_18, 1);
|
||||
sub_020133AC(param0->field_18, ov63_021DBF08[param1].field_00, ov63_021DB940, param0->field_04[param1]);
|
||||
sub_020133AC(param0->field_18, ov63_021DBF08[param1].field_04, ov63_021DB940, param0->field_04[param1]);
|
||||
(*state)++;
|
||||
break;
|
||||
case 3:
|
||||
if (!sub_020133C8(param0->field_18) && param2 >= ov63_021DBEC0[param1]) {
|
||||
G2_SetWndOutsidePlane(GX_WND_PLANEMASK_OBJ, TRUE);
|
||||
(*state)++;
|
||||
break;
|
||||
case 3:
|
||||
if (!sub_020133C8(param0->field_18) && param2 >= ov63_021DBEC0[param1])
|
||||
{
|
||||
G2_SetWndOutsidePlane(GX_WND_PLANEMASK_OBJ, TRUE);
|
||||
(*state)++;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if (ov63_021DBED8[param1].unk_04(param0, param1))
|
||||
{
|
||||
sub_02007558(param0->field_04[param1], 6, 1);
|
||||
param0->field_1D = 0;
|
||||
(*state)++;
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
param0->field_1D++;
|
||||
if (param0->field_1D >= 20)
|
||||
{
|
||||
param0->field_1D = 0;
|
||||
*state = 0;
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if (ov63_021DBED8[param1].unk_04(param0, param1)) {
|
||||
sub_02007558(param0->field_04[param1], 6, 1);
|
||||
param0->field_1D = 0;
|
||||
(*state)++;
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
param0->field_1D++;
|
||||
if (param0->field_1D >= 20) {
|
||||
param0->field_1D = 0;
|
||||
*state = 0;
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL ov63_021DB720(UnkStruct63_021DB450 *param0, u32 param1)
|
||||
{
|
||||
BOOL ov63_021DB720(UnkStruct63_021DB450 *param0, u32 param1) {
|
||||
struct UnkStruct_02006D98_2 *field = param0->field_04[param1];
|
||||
sub_020079E0(field, 0x0, 0x6);
|
||||
sub_020079E0(field, 0x1, -0x10);
|
||||
sub_020079E0(field, 0xC, -0x80);
|
||||
sub_020079E0(field, 0xD, -0x80);
|
||||
param0->field_1D++;
|
||||
if (param0->field_1D >= 6)
|
||||
{
|
||||
if (param0->field_1D >= 6) {
|
||||
sub_02007558(field, 0xC, 0x100);
|
||||
sub_02007558(field, 0xD, 0x100);
|
||||
return TRUE;
|
||||
|
|
@ -201,14 +187,12 @@ BOOL ov63_021DB720(UnkStruct63_021DB450 *param0, u32 param1)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL ov63_021DB784(UnkStruct63_021DB450 *param0, u32 param1)
|
||||
{
|
||||
BOOL ov63_021DB784(UnkStruct63_021DB450 *param0, u32 param1) {
|
||||
struct UnkStruct_02006D98_2 *field = param0->field_04[param1];
|
||||
sub_020079E0(field, 0x0, -0x3);
|
||||
sub_020079E0(field, 0x1, -0x12);
|
||||
param0->field_1D++;
|
||||
if (param0->field_1D >= 6)
|
||||
{
|
||||
if (param0->field_1D >= 6) {
|
||||
sub_02007558(field, 0xC, 0x100);
|
||||
sub_02007558(field, 0xD, 0x100);
|
||||
return TRUE;
|
||||
|
|
@ -216,16 +200,14 @@ BOOL ov63_021DB784(UnkStruct63_021DB450 *param0, u32 param1)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL ov63_021DB7D0(UnkStruct63_021DB450 *param0, u32 param1)
|
||||
{
|
||||
BOOL ov63_021DB7D0(UnkStruct63_021DB450 *param0, u32 param1) {
|
||||
struct UnkStruct_02006D98_2 *field = param0->field_04[param1];
|
||||
sub_020079E0(field, 0x0, -0x10);
|
||||
sub_020079E0(field, 0x1, -0x10);
|
||||
sub_020079E0(field, 0xC, -0x80);
|
||||
sub_020079E0(field, 0xD, -0x80);
|
||||
param0->field_1D++;
|
||||
if (param0->field_1D >= 6)
|
||||
{
|
||||
if (param0->field_1D >= 6) {
|
||||
sub_02007558(field, 0xC, 0x100);
|
||||
sub_02007558(field, 0xD, 0x100);
|
||||
return TRUE;
|
||||
|
|
@ -233,14 +215,12 @@ BOOL ov63_021DB7D0(UnkStruct63_021DB450 *param0, u32 param1)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL ov63_021DB838(UnkStruct63_021DB450 *param0, u32 param1)
|
||||
{
|
||||
BOOL ov63_021DB838(UnkStruct63_021DB450 *param0, u32 param1) {
|
||||
struct UnkStruct_02006D98_2 *field = param0->field_04[param1];
|
||||
sub_020079E0(field, 0, -0x6);
|
||||
sub_020079E0(field, 1, -0x10);
|
||||
param0->field_1D++;
|
||||
if (param0->field_1D >= 6)
|
||||
{
|
||||
if (param0->field_1D >= 6) {
|
||||
sub_02007558(field, 0xC, 0x100);
|
||||
sub_02007558(field, 0xD, 0x100);
|
||||
return TRUE;
|
||||
|
|
@ -248,16 +228,14 @@ BOOL ov63_021DB838(UnkStruct63_021DB450 *param0, u32 param1)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL ov63_021DB884(UnkStruct63_021DB450 *param0, u32 param1)
|
||||
{
|
||||
BOOL ov63_021DB884(UnkStruct63_021DB450 *param0, u32 param1) {
|
||||
struct UnkStruct_02006D98_2 *field = param0->field_04[param1];
|
||||
sub_020079E0(field, 0, 0x8);
|
||||
sub_020079E0(field, 1, -0x10);
|
||||
sub_020079E0(field, 0xC, -0x80);
|
||||
sub_020079E0(field, 0xD, -0x80);
|
||||
param0->field_1D++;
|
||||
if (param0->field_1D >= 6)
|
||||
{
|
||||
if (param0->field_1D >= 6) {
|
||||
sub_02007558(field, 0xC, 0x100);
|
||||
sub_02007558(field, 0xD, 0x100);
|
||||
return TRUE;
|
||||
|
|
@ -265,14 +243,12 @@ BOOL ov63_021DB884(UnkStruct63_021DB450 *param0, u32 param1)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL ov63_021DB8E8(UnkStruct63_021DB450 *param0, u32 param1)
|
||||
{
|
||||
BOOL ov63_021DB8E8(UnkStruct63_021DB450 *param0, u32 param1) {
|
||||
struct UnkStruct_02006D98_2 *field = param0->field_04[param1];
|
||||
sub_020079E0(field, 0, 0x6);
|
||||
sub_020079E0(field, 1, -0x14);
|
||||
param0->field_1D++;
|
||||
if (param0->field_1D >= 6)
|
||||
{
|
||||
if (param0->field_1D >= 6) {
|
||||
sub_02007558(field, 0xC, 0x100);
|
||||
sub_02007558(field, 0xD, 0x100);
|
||||
return TRUE;
|
||||
|
|
@ -280,20 +256,18 @@ BOOL ov63_021DB8E8(UnkStruct63_021DB450 *param0, u32 param1)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
void ov63_021DB934(void)
|
||||
{
|
||||
void ov63_021DB934(void) {
|
||||
sub_02013364();
|
||||
sub_02013388();
|
||||
}
|
||||
|
||||
void ov63_021DB940(struct UnkStruct63_021DB450 * a0)
|
||||
{
|
||||
struct UnkStruct_02006D98_2 * r4 = sub_0201341C(a0);
|
||||
int sp0[3] = {0, 0, 0};
|
||||
sp0[0] = (sub_0200782C(r4, 0) - 0x80) * 0xAC;
|
||||
sp0[1] = (sub_0200782C(r4, 1) - 0x60) * 0xAC;
|
||||
sp0[2] = 0x40;
|
||||
a0->field_28 = sp0[0] + (*a0->field_20)[1];
|
||||
a0->field_2C = sp0[1] + (*a0->field_20)[2];
|
||||
a0->field_30 = sp0[2] + (*a0->field_20)[3];
|
||||
void ov63_021DB940(struct UnkStruct63_021DB450 *a0) {
|
||||
struct UnkStruct_02006D98_2 *r4 = sub_0201341C(a0);
|
||||
int sp0[3] = { 0, 0, 0 };
|
||||
sp0[0] = (sub_0200782C(r4, 0) - 0x80) * 0xAC;
|
||||
sp0[1] = (sub_0200782C(r4, 1) - 0x60) * 0xAC;
|
||||
sp0[2] = 0x40;
|
||||
a0->field_28 = sp0[0] + (*a0->field_20)[1];
|
||||
a0->field_2C = sp0[1] + (*a0->field_20)[2];
|
||||
a0->field_30 = sp0[2] + (*a0->field_20)[3];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "global.h"
|
||||
#include "ascii_util.h"
|
||||
|
||||
#include "global.h"
|
||||
|
||||
s32 Ascii_StrLen(const s8 *str) {
|
||||
s32 i = 0;
|
||||
while (str[i] != 0) {
|
||||
|
|
@ -28,7 +29,7 @@ s32 Ascii_StrToL(const s8 *str) {
|
|||
s32 length = Ascii_StrLen(str);
|
||||
s32 i;
|
||||
s32 pow10 = 1;
|
||||
s32 num = 0;
|
||||
s32 num = 0;
|
||||
|
||||
// Traverse from right to left
|
||||
for (i = length - 1; i >= 0; i--) {
|
||||
|
|
@ -38,7 +39,7 @@ s32 Ascii_StrToL(const s8 *str) {
|
|||
} else {
|
||||
// If first character is a minus sign, it's negative
|
||||
if (i == 0) {
|
||||
if(str[i] == '-') {
|
||||
if (str[i] == '-') {
|
||||
num *= -1;
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
276
arm9/src/bag.c
276
arm9/src/bag.c
|
|
@ -1,9 +1,12 @@
|
|||
#include "global.h"
|
||||
#include "constants/items.h"
|
||||
#include "MI_memory.h"
|
||||
#include "bag.h"
|
||||
#include "itemtool.h"
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "constants/items.h"
|
||||
|
||||
#include "MI_memory.h"
|
||||
#include "heap.h"
|
||||
#include "itemtool.h"
|
||||
|
||||
static u32 Bag_GetItemPocket(Bag *bag, u16 itemId, ItemSlot **itemSlots, u32 *countPtr, HeapID heapId);
|
||||
static ItemSlot *Pocket_GetItemSlotForAdd(ItemSlot *slots, u32 count, u16 itemId, u16 quantity, u16 maxQuantity);
|
||||
|
|
@ -19,7 +22,7 @@ u32 Save_Bag_sizeof(void) {
|
|||
}
|
||||
|
||||
Bag *Save_Bag_New(HeapID heapId) {
|
||||
Bag *bag = (Bag *) AllocFromHeap(heapId, sizeof(Bag));
|
||||
Bag *bag = (Bag *)AllocFromHeap(heapId, sizeof(Bag));
|
||||
Save_Bag_Init(bag);
|
||||
return bag;
|
||||
}
|
||||
|
|
@ -43,38 +46,38 @@ void Bag_SetRegisteredItem(Bag *bag, u32 item) {
|
|||
static u32 Bag_GetItemPocket(Bag *bag, u16 itemId, ItemSlot **itemSlots, u32 *countPtr, HeapID heapId) {
|
||||
u32 pocket = GetItemAttr(itemId, ITEMATTR_POCKET, heapId);
|
||||
switch (pocket) {
|
||||
case POCKET_KEY_ITEMS:
|
||||
*itemSlots = bag->keyItems;
|
||||
*countPtr = NUM_BAG_KEY_ITEMS;
|
||||
break;
|
||||
case POCKET_ITEMS:
|
||||
*itemSlots = bag->items;
|
||||
*countPtr = NUM_BAG_ITEMS;
|
||||
break;
|
||||
case POCKET_BERRIES:
|
||||
*itemSlots = bag->berries;
|
||||
*countPtr = NUM_BAG_BERRIES;
|
||||
break;
|
||||
case POCKET_MEDICINE:
|
||||
*itemSlots = bag->medicine;
|
||||
*countPtr = NUM_BAG_MEDICINE;
|
||||
break;
|
||||
case POCKET_BALLS:
|
||||
*itemSlots = bag->balls;
|
||||
*countPtr = NUM_BAG_BALLS;
|
||||
break;
|
||||
case POCKET_BATTLE_ITEMS:
|
||||
*itemSlots = bag->battleItems;
|
||||
*countPtr = NUM_BAG_BATTLE_ITEMS;
|
||||
break;
|
||||
case POCKET_MAIL:
|
||||
*itemSlots = bag->mail;
|
||||
*countPtr = NUM_BAG_MAIL;
|
||||
break;
|
||||
case POCKET_TMHMS:
|
||||
*itemSlots = bag->TMsHMs;
|
||||
*countPtr = NUM_BAG_TMS_HMS;
|
||||
break;
|
||||
case POCKET_KEY_ITEMS:
|
||||
*itemSlots = bag->keyItems;
|
||||
*countPtr = NUM_BAG_KEY_ITEMS;
|
||||
break;
|
||||
case POCKET_ITEMS:
|
||||
*itemSlots = bag->items;
|
||||
*countPtr = NUM_BAG_ITEMS;
|
||||
break;
|
||||
case POCKET_BERRIES:
|
||||
*itemSlots = bag->berries;
|
||||
*countPtr = NUM_BAG_BERRIES;
|
||||
break;
|
||||
case POCKET_MEDICINE:
|
||||
*itemSlots = bag->medicine;
|
||||
*countPtr = NUM_BAG_MEDICINE;
|
||||
break;
|
||||
case POCKET_BALLS:
|
||||
*itemSlots = bag->balls;
|
||||
*countPtr = NUM_BAG_BALLS;
|
||||
break;
|
||||
case POCKET_BATTLE_ITEMS:
|
||||
*itemSlots = bag->battleItems;
|
||||
*countPtr = NUM_BAG_BATTLE_ITEMS;
|
||||
break;
|
||||
case POCKET_MAIL:
|
||||
*itemSlots = bag->mail;
|
||||
*countPtr = NUM_BAG_MAIL;
|
||||
break;
|
||||
case POCKET_TMHMS:
|
||||
*itemSlots = bag->TMsHMs;
|
||||
*countPtr = NUM_BAG_TMS_HMS;
|
||||
break;
|
||||
}
|
||||
return pocket;
|
||||
}
|
||||
|
|
@ -184,43 +187,43 @@ BOOL Bag_HasItem(Bag *bag, u16 itemId, u16 quantity, HeapID heapId) {
|
|||
}
|
||||
|
||||
BOOL Bag_PocketNotEmpty(Bag *bag, u32 pocket) {
|
||||
ItemSlot * slots;
|
||||
ItemSlot *slots;
|
||||
u32 count;
|
||||
switch (pocket) {
|
||||
case POCKET_KEY_ITEMS:
|
||||
slots = bag->keyItems;
|
||||
count = NUM_BAG_KEY_ITEMS;
|
||||
break;
|
||||
case POCKET_ITEMS:
|
||||
slots = bag->items;
|
||||
count = NUM_BAG_ITEMS;
|
||||
break;
|
||||
case POCKET_BERRIES:
|
||||
slots = bag->berries;
|
||||
count = NUM_BAG_BERRIES;
|
||||
break;
|
||||
case POCKET_MEDICINE:
|
||||
slots = bag->medicine;
|
||||
count = NUM_BAG_MEDICINE;
|
||||
break;
|
||||
case POCKET_BALLS:
|
||||
slots = bag->balls;
|
||||
count = NUM_BAG_BALLS;
|
||||
break;
|
||||
case POCKET_BATTLE_ITEMS:
|
||||
slots = bag->battleItems;
|
||||
count = NUM_BAG_BATTLE_ITEMS;
|
||||
break;
|
||||
case POCKET_MAIL:
|
||||
slots = bag->mail;
|
||||
count = NUM_BAG_MAIL;
|
||||
break;
|
||||
case POCKET_TMHMS:
|
||||
slots = bag->TMsHMs;
|
||||
count = NUM_BAG_TMS_HMS;
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
case POCKET_KEY_ITEMS:
|
||||
slots = bag->keyItems;
|
||||
count = NUM_BAG_KEY_ITEMS;
|
||||
break;
|
||||
case POCKET_ITEMS:
|
||||
slots = bag->items;
|
||||
count = NUM_BAG_ITEMS;
|
||||
break;
|
||||
case POCKET_BERRIES:
|
||||
slots = bag->berries;
|
||||
count = NUM_BAG_BERRIES;
|
||||
break;
|
||||
case POCKET_MEDICINE:
|
||||
slots = bag->medicine;
|
||||
count = NUM_BAG_MEDICINE;
|
||||
break;
|
||||
case POCKET_BALLS:
|
||||
slots = bag->balls;
|
||||
count = NUM_BAG_BALLS;
|
||||
break;
|
||||
case POCKET_BATTLE_ITEMS:
|
||||
slots = bag->battleItems;
|
||||
count = NUM_BAG_BATTLE_ITEMS;
|
||||
break;
|
||||
case POCKET_MAIL:
|
||||
slots = bag->mail;
|
||||
count = NUM_BAG_MAIL;
|
||||
break;
|
||||
case POCKET_TMHMS:
|
||||
slots = bag->TMsHMs;
|
||||
count = NUM_BAG_TMS_HMS;
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
for (s32 i = 0; i < count; i++) {
|
||||
|
|
@ -249,8 +252,8 @@ u16 Pocket_GetQuantity(ItemSlot *slots, u32 count, u16 itemId) {
|
|||
|
||||
static void SwapItemSlots(ItemSlot *a, ItemSlot *b) {
|
||||
ItemSlot c = *a;
|
||||
*a = *b;
|
||||
*b = c;
|
||||
*a = *b;
|
||||
*b = c;
|
||||
}
|
||||
|
||||
static void PocketCompaction(ItemSlot *slots, u32 count) {
|
||||
|
|
@ -273,36 +276,35 @@ static void SortPocket(ItemSlot *slots, u32 count) {
|
|||
}
|
||||
}
|
||||
|
||||
BagView *Bag_CreateView(Bag *bag, const u8 *pockets, HeapID heapId)
|
||||
{
|
||||
BagView *Bag_CreateView(Bag *bag, const u8 *pockets, HeapID heapId) {
|
||||
BagView *ret = BagView_New(heapId);
|
||||
|
||||
for (u32 i = 0; pockets[i] != POCKET_BAG_VIEW_END; i++) {
|
||||
switch (pockets[i]) {
|
||||
case POCKET_KEY_ITEMS:
|
||||
BagView_SetItem(ret, bag->keyItems, POCKET_KEY_ITEMS, i);
|
||||
break;
|
||||
case POCKET_ITEMS:
|
||||
BagView_SetItem(ret, bag->items, POCKET_ITEMS, i);
|
||||
break;
|
||||
case POCKET_BERRIES:
|
||||
BagView_SetItem(ret, bag->berries, POCKET_BERRIES, i);
|
||||
break;
|
||||
case POCKET_MEDICINE:
|
||||
BagView_SetItem(ret, bag->medicine, POCKET_MEDICINE, i);
|
||||
break;
|
||||
case POCKET_BALLS:
|
||||
BagView_SetItem(ret, bag->balls, POCKET_BALLS, i);
|
||||
break;
|
||||
case POCKET_BATTLE_ITEMS:
|
||||
BagView_SetItem(ret, bag->battleItems, POCKET_BATTLE_ITEMS, i);
|
||||
break;
|
||||
case POCKET_MAIL:
|
||||
BagView_SetItem(ret, bag->mail, POCKET_MAIL, i);
|
||||
break;
|
||||
case POCKET_TMHMS:
|
||||
BagView_SetItem(ret, bag->TMsHMs, POCKET_TMHMS, i);
|
||||
break;
|
||||
case POCKET_KEY_ITEMS:
|
||||
BagView_SetItem(ret, bag->keyItems, POCKET_KEY_ITEMS, i);
|
||||
break;
|
||||
case POCKET_ITEMS:
|
||||
BagView_SetItem(ret, bag->items, POCKET_ITEMS, i);
|
||||
break;
|
||||
case POCKET_BERRIES:
|
||||
BagView_SetItem(ret, bag->berries, POCKET_BERRIES, i);
|
||||
break;
|
||||
case POCKET_MEDICINE:
|
||||
BagView_SetItem(ret, bag->medicine, POCKET_MEDICINE, i);
|
||||
break;
|
||||
case POCKET_BALLS:
|
||||
BagView_SetItem(ret, bag->balls, POCKET_BALLS, i);
|
||||
break;
|
||||
case POCKET_BATTLE_ITEMS:
|
||||
BagView_SetItem(ret, bag->battleItems, POCKET_BATTLE_ITEMS, i);
|
||||
break;
|
||||
case POCKET_MAIL:
|
||||
BagView_SetItem(ret, bag->mail, POCKET_MAIL, i);
|
||||
break;
|
||||
case POCKET_TMHMS:
|
||||
BagView_SetItem(ret, bag->TMsHMs, POCKET_TMHMS, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
|
@ -313,38 +315,38 @@ ItemSlot *Bag_GetPocketSlotN(Bag *bag, u8 pocket, u32 slot) {
|
|||
u32 count;
|
||||
|
||||
switch (pocket) {
|
||||
case POCKET_KEY_ITEMS:
|
||||
slots = bag->keyItems;
|
||||
count = NUM_BAG_KEY_ITEMS;
|
||||
break;
|
||||
case POCKET_ITEMS:
|
||||
slots = bag->items;
|
||||
count = NUM_BAG_ITEMS;
|
||||
break;
|
||||
case POCKET_BERRIES:
|
||||
slots = bag->berries;
|
||||
count = NUM_BAG_BERRIES;
|
||||
break;
|
||||
case POCKET_MEDICINE:
|
||||
slots = bag->medicine;
|
||||
count = NUM_BAG_MEDICINE;
|
||||
break;
|
||||
case POCKET_BALLS:
|
||||
slots = bag->balls;
|
||||
count = NUM_BAG_BALLS;
|
||||
break;
|
||||
case POCKET_BATTLE_ITEMS:
|
||||
slots = bag->battleItems;
|
||||
count = NUM_BAG_BATTLE_ITEMS;
|
||||
break;
|
||||
case POCKET_MAIL:
|
||||
slots = bag->mail;
|
||||
count = NUM_BAG_MAIL;
|
||||
break;
|
||||
case POCKET_TMHMS:
|
||||
slots = bag->TMsHMs;
|
||||
count = NUM_BAG_TMS_HMS;
|
||||
break;
|
||||
case POCKET_KEY_ITEMS:
|
||||
slots = bag->keyItems;
|
||||
count = NUM_BAG_KEY_ITEMS;
|
||||
break;
|
||||
case POCKET_ITEMS:
|
||||
slots = bag->items;
|
||||
count = NUM_BAG_ITEMS;
|
||||
break;
|
||||
case POCKET_BERRIES:
|
||||
slots = bag->berries;
|
||||
count = NUM_BAG_BERRIES;
|
||||
break;
|
||||
case POCKET_MEDICINE:
|
||||
slots = bag->medicine;
|
||||
count = NUM_BAG_MEDICINE;
|
||||
break;
|
||||
case POCKET_BALLS:
|
||||
slots = bag->balls;
|
||||
count = NUM_BAG_BALLS;
|
||||
break;
|
||||
case POCKET_BATTLE_ITEMS:
|
||||
slots = bag->battleItems;
|
||||
count = NUM_BAG_BATTLE_ITEMS;
|
||||
break;
|
||||
case POCKET_MAIL:
|
||||
slots = bag->mail;
|
||||
count = NUM_BAG_MAIL;
|
||||
break;
|
||||
case POCKET_TMHMS:
|
||||
slots = bag->TMsHMs;
|
||||
count = NUM_BAG_TMS_HMS;
|
||||
break;
|
||||
}
|
||||
// UB: If pocket invalid, count and slot are uninitialized
|
||||
if (slot >= count) {
|
||||
|
|
@ -365,7 +367,7 @@ BagCursor *BagCursor_New(HeapID heapId) {
|
|||
|
||||
void BagCursor_Field_PocketGetPosition(BagCursor *cursor, u32 pocket, u8 *position, u8 *scroll) {
|
||||
*position = cursor->field.position[pocket];
|
||||
*scroll = cursor->field.scroll[pocket];
|
||||
*scroll = cursor->field.scroll[pocket];
|
||||
}
|
||||
|
||||
u16 BagCursor_Field_GetPocket(BagCursor *cursor) {
|
||||
|
|
@ -374,7 +376,7 @@ u16 BagCursor_Field_GetPocket(BagCursor *cursor) {
|
|||
|
||||
void BagCursor_Field_PocketSetPosition(BagCursor *cursor, u32 pocket, u8 position, u8 scroll) {
|
||||
cursor->field.position[pocket] = position;
|
||||
cursor->field.scroll[pocket] = scroll;
|
||||
cursor->field.scroll[pocket] = scroll;
|
||||
}
|
||||
|
||||
void BagCursor_Field_SetPocket(BagCursor *cursor, u16 pocket) {
|
||||
|
|
@ -383,7 +385,7 @@ void BagCursor_Field_SetPocket(BagCursor *cursor, u16 pocket) {
|
|||
|
||||
void BagCursor_Battle_PocketGetPosition(BagCursor *cursor, u32 pocket, u8 *position, u8 *scroll) {
|
||||
*position = cursor->battle.position[pocket];
|
||||
*scroll = cursor->battle.scroll[pocket];
|
||||
*scroll = cursor->battle.scroll[pocket];
|
||||
}
|
||||
|
||||
u16 BagCursor_Battle_GetLastUsedItem(BagCursor *cursor) {
|
||||
|
|
@ -400,7 +402,7 @@ u16 BagCursor_Battle_GetPocket(BagCursor *cursor) {
|
|||
|
||||
void BagCursor_Battle_PocketSetPosition(BagCursor *cursor, u32 pocket, u8 position, u8 scroll) {
|
||||
cursor->battle.position[pocket] = position;
|
||||
cursor->battle.scroll[pocket] = scroll;
|
||||
cursor->battle.scroll[pocket] = scroll;
|
||||
}
|
||||
|
||||
void BagCursor_Battle_Init(BagCursor *cursor) {
|
||||
|
|
@ -411,7 +413,7 @@ void BagCursor_Battle_Init(BagCursor *cursor) {
|
|||
}
|
||||
|
||||
void BagCursor_Battle_SetLastUsedItem(BagCursor *cursor, u16 itemId, u16 pocket) {
|
||||
cursor->battle.lastUsedItem = itemId;
|
||||
cursor->battle.lastUsedItem = itemId;
|
||||
cursor->battle.lastUsedPocket = pocket;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,19 @@
|
|||
#include "global.h"
|
||||
#include "bag_view.h"
|
||||
#include "coins.h"
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "constants/items.h"
|
||||
#include "constants/seal_constants.h"
|
||||
|
||||
#include "msgdata/msg.naix"
|
||||
#include "msgdata/msg/narc_0007.h"
|
||||
#include "msgdata/msg/narc_0199.h"
|
||||
|
||||
#include "coins.h"
|
||||
#include "fashion_case.h"
|
||||
#include "heap.h"
|
||||
#include "message_format.h"
|
||||
#include "msgdata.h"
|
||||
#include "msgdata/msg.naix"
|
||||
#include "msgdata/msg/narc_0007.h"
|
||||
#include "msgdata/msg/narc_0199.h"
|
||||
#include "player_data.h"
|
||||
#include "seal.h"
|
||||
#include "unk_0202A1E0.h"
|
||||
|
|
@ -44,12 +48,12 @@ void sub_0206E314(BagView *bagView, SaveData *save, u8 r2, BagCursor *cursor) {
|
|||
sub_0206E30C(bagView, r2);
|
||||
|
||||
bagView->saveData = save;
|
||||
bagView->cursor = cursor;
|
||||
bagView->unk66 = 0;
|
||||
bagView->cursor = cursor;
|
||||
bagView->unk66 = 0;
|
||||
}
|
||||
|
||||
void BagView_SetItem(BagView *bagView, ItemSlot *slot, u8 pocket, u8 idx) {
|
||||
bagView->pockets[idx].slot = slot;
|
||||
bagView->pockets[idx].slot = slot;
|
||||
bagView->pockets[idx].pocket = pocket;
|
||||
}
|
||||
|
||||
|
|
@ -114,7 +118,7 @@ static u32 GetNumBattlePoints(SaveData *saveData) {
|
|||
}
|
||||
|
||||
BOOL TryFormatRegisteredKeyItemUseMessage(SaveData *saveData, String *dest, u32 itemId, HeapID heapId) {
|
||||
MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_DIRECT, NARC_MSGDATA_MSG, NARC_msg_narc_0007_bin, heapId);
|
||||
MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_DIRECT, NARC_MSGDATA_MSG, NARC_msg_narc_0007_bin, heapId);
|
||||
MessageFormat *messageFormat = MessageFormat_New(heapId);
|
||||
String *string;
|
||||
|
||||
|
|
@ -151,28 +155,28 @@ void GetItemUseErrorMessage(PlayerProfile *playerProfile, String *dest, u16 item
|
|||
MsgData *msgData;
|
||||
|
||||
switch (code) {
|
||||
case ITEMUSEERROR_NODISMOUNT:
|
||||
// You can’t dismount your Bike here.
|
||||
msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0007_bin, heapId);
|
||||
ReadMsgDataIntoString(msgData, narc_0007_00056, dest);
|
||||
DestroyMsgData(msgData);
|
||||
break;
|
||||
case ITEMUSEERROR_NOFOLLOWER:
|
||||
// It can’t be used when you have someone with you.
|
||||
msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0007_bin, heapId);
|
||||
ReadMsgDataIntoString(msgData, narc_0007_00111, dest);
|
||||
DestroyMsgData(msgData);
|
||||
break;
|
||||
default:
|
||||
// Rowan’s words echoed... {STRVAR_1 3, 0}! There’s a time and place for everything! But not now.
|
||||
msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0199_bin, heapId);
|
||||
MessageFormat *messageFormat = MessageFormat_New(heapId);
|
||||
String *src = NewString_ReadMsgData(msgData, narc_0199_00036);
|
||||
BufferPlayersName(messageFormat, 0, playerProfile);
|
||||
StringExpandPlaceholders(messageFormat, dest, src);
|
||||
String_Delete(src);
|
||||
MessageFormat_Delete(messageFormat);
|
||||
DestroyMsgData(msgData);
|
||||
break;
|
||||
case ITEMUSEERROR_NODISMOUNT:
|
||||
// You can’t dismount your Bike here.
|
||||
msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0007_bin, heapId);
|
||||
ReadMsgDataIntoString(msgData, narc_0007_00056, dest);
|
||||
DestroyMsgData(msgData);
|
||||
break;
|
||||
case ITEMUSEERROR_NOFOLLOWER:
|
||||
// It can’t be used when you have someone with you.
|
||||
msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0007_bin, heapId);
|
||||
ReadMsgDataIntoString(msgData, narc_0007_00111, dest);
|
||||
DestroyMsgData(msgData);
|
||||
break;
|
||||
default:
|
||||
// Rowan’s words echoed... {STRVAR_1 3, 0}! There’s a time and place for everything! But not now.
|
||||
msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0199_bin, heapId);
|
||||
MessageFormat *messageFormat = MessageFormat_New(heapId);
|
||||
String *src = NewString_ReadMsgData(msgData, narc_0199_00036);
|
||||
BufferPlayersName(messageFormat, 0, playerProfile);
|
||||
StringExpandPlaceholders(messageFormat, dest, src);
|
||||
String_Delete(src);
|
||||
MessageFormat_Delete(messageFormat);
|
||||
DestroyMsgData(msgData);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
1817
arm9/src/bg_window.c
1817
arm9/src/bg_window.c
File diff suppressed because it is too large
Load Diff
|
|
@ -1,13 +1,16 @@
|
|||
#include "blackout.h"
|
||||
#include "bg_window.h"
|
||||
#include "brightness.h"
|
||||
|
||||
#include "constants/maps.h"
|
||||
#include "constants/rgb.h"
|
||||
|
||||
#include "graphic/font.naix"
|
||||
#include "msgdata/msg.naix"
|
||||
#include "msgdata/msg/narc_0328.h"
|
||||
#include "graphic/font.naix"
|
||||
#include "gf_gfx_loader.h"
|
||||
|
||||
#include "PAD_pad.h"
|
||||
#include "bg_window.h"
|
||||
#include "brightness.h"
|
||||
#include "gf_gfx_loader.h"
|
||||
#include "render_window.h"
|
||||
#include "save_local_field_data.h"
|
||||
#include "script.h" //TODO: temp include, remove when structs are split
|
||||
|
|
@ -35,48 +38,48 @@ extern void sub_0204AB0C(void);
|
|||
extern u16 GetMomSpawnId(void);
|
||||
|
||||
static const struct GraphicsBanks sBlackoutGraphicsBanks = {
|
||||
.bg = GX_VRAM_BG_128_B,
|
||||
.bgextpltt = GX_VRAM_BGEXTPLTT_NONE,
|
||||
.subbg = GX_VRAM_SUB_BG_128_C,
|
||||
.subbgextpltt = GX_VRAM_SUB_BGEXTPLTT_NONE,
|
||||
.obj = GX_VRAM_OBJ_64_E,
|
||||
.objextpltt = GX_VRAM_OBJEXTPLTT_NONE,
|
||||
.subobj = GX_VRAM_SUB_OBJ_16_I,
|
||||
.bg = GX_VRAM_BG_128_B,
|
||||
.bgextpltt = GX_VRAM_BGEXTPLTT_NONE,
|
||||
.subbg = GX_VRAM_SUB_BG_128_C,
|
||||
.subbgextpltt = GX_VRAM_SUB_BGEXTPLTT_NONE,
|
||||
.obj = GX_VRAM_OBJ_64_E,
|
||||
.objextpltt = GX_VRAM_OBJEXTPLTT_NONE,
|
||||
.subobj = GX_VRAM_SUB_OBJ_16_I,
|
||||
.subobjextpltt = GX_VRAM_SUB_OBJEXTPLTT_NONE,
|
||||
.tex = GX_VRAM_TEX_0_A,
|
||||
.texpltt = GX_VRAM_TEXPLTT_01_FG,
|
||||
.tex = GX_VRAM_TEX_0_A,
|
||||
.texpltt = GX_VRAM_TEXPLTT_01_FG,
|
||||
};
|
||||
|
||||
static const struct GraphicsModes sBlackoutGraphicsModes = {
|
||||
.dispMode = GX_DISPMODE_GRAPHICS,
|
||||
.bgMode = GX_BGMODE_0,
|
||||
.subMode = GX_BGMODE_0,
|
||||
.dispMode = GX_DISPMODE_GRAPHICS,
|
||||
.bgMode = GX_BGMODE_0,
|
||||
.subMode = GX_BGMODE_0,
|
||||
._2d3dMode = GX_BG0_AS_2D,
|
||||
};
|
||||
|
||||
static const BgTemplate sBlackoutBgTemplate = {
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.bufferSize = 0x800,
|
||||
.baseTile = 0,
|
||||
.size = GF_BG_SCR_SIZE_256x256,
|
||||
.colorMode = GX_BG_COLORMODE_16,
|
||||
.baseTile = 0,
|
||||
.size = GF_BG_SCR_SIZE_256x256,
|
||||
.colorMode = GX_BG_COLORMODE_16,
|
||||
.screenBase = GX_BG_SCRBASE_0xf800,
|
||||
.charBase = GX_BG_CHARBASE_0x00000,
|
||||
.bgExtPltt = GX_BG_EXTPLTT_01,
|
||||
.priority = 1,
|
||||
.areaOver = GX_BG_AREAOVER_XLU,
|
||||
.dummy = 0,
|
||||
.mosaic = FALSE
|
||||
.charBase = GX_BG_CHARBASE_0x00000,
|
||||
.bgExtPltt = GX_BG_EXTPLTT_01,
|
||||
.priority = 1,
|
||||
.areaOver = GX_BG_AREAOVER_XLU,
|
||||
.dummy = 0,
|
||||
.mosaic = FALSE
|
||||
};
|
||||
|
||||
static const WindowTemplate sBlackoutWindowTemplate = {
|
||||
.bgId = GF_BG_LYR_MAIN_3,
|
||||
.left = 4,
|
||||
.top = 5,
|
||||
.width = 25,
|
||||
.height = 15,
|
||||
.palette = 13,
|
||||
.bgId = GF_BG_LYR_MAIN_3,
|
||||
.left = 4,
|
||||
.top = 5,
|
||||
.width = 25,
|
||||
.height = 15,
|
||||
.palette = 13,
|
||||
.baseTile = 0x01
|
||||
};
|
||||
|
||||
|
|
@ -92,13 +95,13 @@ static void Blackout_DrawMessage(FieldSystem *fieldSystem, TaskManager *taskMana
|
|||
|
||||
GF_ASSERT(env != NULL);
|
||||
memset(env, 0, sizeof(BlackoutScreenEnvironment));
|
||||
env->state = 0;
|
||||
env->state = 0;
|
||||
env->fieldSystem = fieldSystem;
|
||||
env->bgConfig = BgConfig_Alloc(HEAP_ID_FIELD);
|
||||
env->bgConfig = BgConfig_Alloc(HEAP_ID_FIELD);
|
||||
|
||||
Blackout_InitDisplays(env->bgConfig);
|
||||
env->msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0328_bin, HEAP_ID_FIELD);
|
||||
env->msgFmt = MessageFormat_New(HEAP_ID_FIELD);
|
||||
env->msgFmt = MessageFormat_New(HEAP_ID_FIELD);
|
||||
|
||||
AddWindow(env->bgConfig, &env->window, &sBlackoutWindowTemplate);
|
||||
|
||||
|
|
@ -125,36 +128,36 @@ enum {
|
|||
static BOOL Task_ShowPrintedBlackoutMessage(TaskManager *taskManager) {
|
||||
BlackoutScreenEnvironment *env = TaskManager_GetEnvironment(taskManager);
|
||||
switch (env->state) {
|
||||
case STATE_SHOW_PRINTED_BLACKOUT_FADE_IN:
|
||||
BeginNormalPaletteFade(3, 1, 42, RGB_BLACK, 8, 1, HEAP_ID_32);
|
||||
case STATE_SHOW_PRINTED_BLACKOUT_FADE_IN:
|
||||
BeginNormalPaletteFade(3, 1, 42, RGB_BLACK, 8, 1, HEAP_ID_32);
|
||||
env->state++;
|
||||
break;
|
||||
case STATE_SHOW_PRINTED_BLACKOUT_FADE_IN_WAIT:
|
||||
if (IsPaletteFadeFinished()) {
|
||||
env->state++;
|
||||
break;
|
||||
case STATE_SHOW_PRINTED_BLACKOUT_FADE_IN_WAIT:
|
||||
if (IsPaletteFadeFinished()) {
|
||||
env->state++;
|
||||
}
|
||||
break;
|
||||
case STATE_SHOW_PRINTED_BLACKOUT_FADE_OUT_INPUT:
|
||||
if (gSystem.newKeys & PAD_BUTTON_A || gSystem.newKeys & PAD_BUTTON_B) {
|
||||
BeginNormalPaletteFade(0, 0, 0, RGB_BLACK, 8, 1, HEAP_ID_32);
|
||||
env->state++;
|
||||
}
|
||||
break;
|
||||
case STATE_SHOW_PRINTED_BLACKOUT_FADE_OUT_WAIT:
|
||||
if (IsPaletteFadeFinished()) {
|
||||
FillWindowPixelBuffer(&env->window, 0);
|
||||
env->state++;
|
||||
}
|
||||
break;
|
||||
case STATE_SHOW_PRINTED_BLACKOUT_CLEANUP:
|
||||
ClearFrameAndWindow2(&env->window, FALSE);
|
||||
RemoveWindow(&env->window);
|
||||
MessageFormat_Delete(env->msgFmt);
|
||||
DestroyMsgData(env->msgData);
|
||||
FreeBgTilemapBuffer(env->bgConfig, GF_BG_LYR_MAIN_3);
|
||||
FreeToHeap(env->bgConfig);
|
||||
FreeToHeap(env);
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
case STATE_SHOW_PRINTED_BLACKOUT_FADE_OUT_INPUT:
|
||||
if (gSystem.newKeys & PAD_BUTTON_A || gSystem.newKeys & PAD_BUTTON_B) {
|
||||
BeginNormalPaletteFade(0, 0, 0, RGB_BLACK, 8, 1, HEAP_ID_32);
|
||||
env->state++;
|
||||
}
|
||||
break;
|
||||
case STATE_SHOW_PRINTED_BLACKOUT_FADE_OUT_WAIT:
|
||||
if (IsPaletteFadeFinished()) {
|
||||
FillWindowPixelBuffer(&env->window, 0);
|
||||
env->state++;
|
||||
}
|
||||
break;
|
||||
case STATE_SHOW_PRINTED_BLACKOUT_CLEANUP:
|
||||
ClearFrameAndWindow2(&env->window, FALSE);
|
||||
RemoveWindow(&env->window);
|
||||
MessageFormat_Delete(env->msgFmt);
|
||||
DestroyMsgData(env->msgData);
|
||||
FreeBgTilemapBuffer(env->bgConfig, GF_BG_LYR_MAIN_3);
|
||||
FreeToHeap(env->bgConfig);
|
||||
FreeToHeap(env);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
|
@ -167,9 +170,9 @@ static void Blackout_PrintMessage(BlackoutScreenEnvironment *environment, s32 ms
|
|||
FillWindowPixelBuffer(&environment->window, 0);
|
||||
ReadMsgDataIntoString(environment->msgData, msgNo, tmpStr);
|
||||
StringExpandPlaceholders(environment->msgFmt, finStr, tmpStr);
|
||||
|
||||
|
||||
u32 width = FontID_String_GetWidthMultiline(0, finStr, 0);
|
||||
x = (environment->window.width * 8 - width);
|
||||
x = (environment->window.width * 8 - width);
|
||||
x /= 2;
|
||||
x -= 4;
|
||||
|
||||
|
|
@ -191,52 +194,52 @@ enum {
|
|||
|
||||
BOOL Task_Blackout(TaskManager *taskManager) {
|
||||
FieldSystem *fieldSystem = TaskManager_GetFieldSystem(taskManager);
|
||||
u32 *state = TaskManager_GetStatePtr(taskManager);
|
||||
u32 *state = TaskManager_GetStatePtr(taskManager);
|
||||
LocalFieldData *localFieldData;
|
||||
Location deathWarp;
|
||||
u16 deathSpawn;
|
||||
|
||||
switch (*state) {
|
||||
case STATE_BLACKOUT_TASK_INIT:
|
||||
localFieldData = Save_LocalFieldData_Get(fieldSystem->saveData);
|
||||
deathSpawn = LocalFieldData_GetBlackoutSpawn(localFieldData);
|
||||
GetDeathWarpData(deathSpawn, &deathWarp);
|
||||
GetSpecialSpawnWarpData(deathSpawn, LocalFieldData_GetSpecialSpawnWarpPtr(localFieldData));
|
||||
sub_02049160(taskManager, &deathWarp);
|
||||
FieldSystem_ClearFollowingTrainer(fieldSystem);
|
||||
case STATE_BLACKOUT_TASK_INIT:
|
||||
localFieldData = Save_LocalFieldData_Get(fieldSystem->saveData);
|
||||
deathSpawn = LocalFieldData_GetBlackoutSpawn(localFieldData);
|
||||
GetDeathWarpData(deathSpawn, &deathWarp);
|
||||
GetSpecialSpawnWarpData(deathSpawn, LocalFieldData_GetSpecialSpawnWarpPtr(localFieldData));
|
||||
sub_02049160(taskManager, &deathWarp);
|
||||
FieldSystem_ClearFollowingTrainer(fieldSystem);
|
||||
(*state)++;
|
||||
break;
|
||||
case STATE_BLACKOUT_TASK_SOUND_FADE:
|
||||
GF_SndStartFadeOutBGM(0, 20);
|
||||
(*state)++;
|
||||
break;
|
||||
case STATE_BLACKOUT_TASK_SOUND_FADE_WAIT:
|
||||
if (GF_SndGetFadeTimer() == 0) {
|
||||
sub_0204AB0C();
|
||||
(*state)++;
|
||||
break;
|
||||
case STATE_BLACKOUT_TASK_SOUND_FADE:
|
||||
GF_SndStartFadeOutBGM(0, 20);
|
||||
(*state)++;
|
||||
break;
|
||||
case STATE_BLACKOUT_TASK_SOUND_FADE_WAIT:
|
||||
if (GF_SndGetFadeTimer() == 0) {
|
||||
sub_0204AB0C();
|
||||
(*state)++;
|
||||
}
|
||||
break;
|
||||
case STATE_BLACKOUT_TASK_DRAW:
|
||||
SetBlendBrightness(-16, (GXBlendPlaneMask)(GX_BLEND_PLANEMASK_BD | GX_BLEND_PLANEMASK_OBJ | GX_BLEND_PLANEMASK_BG2 | GX_BLEND_PLANEMASK_BG1 | GX_BLEND_PLANEMASK_BG0), SCREEN_MASK_MAIN);
|
||||
SetBlendBrightness(-16, (GXBlendPlaneMask)(GX_BLEND_PLANEMASK_BD | GX_BLEND_PLANEMASK_OBJ | GX_BLEND_PLANEMASK_BG3 | GX_BLEND_PLANEMASK_BG2 | GX_BLEND_PLANEMASK_BG1 | GX_BLEND_PLANEMASK_BG0), SCREEN_MASK_SUB);
|
||||
Blackout_DrawMessage(fieldSystem, taskManager);
|
||||
(*state)++;
|
||||
break;
|
||||
case STATE_BLACKOUT_TASK_RESTORE_OVERWORLD:
|
||||
CallTask_RestoreOverworld(taskManager);
|
||||
(*state)++;
|
||||
break;
|
||||
case STATE_BLACKOUT_TASK_QUEUE_SCRIPT:
|
||||
SetBlendBrightness(0, (GXBlendPlaneMask)(GX_BLEND_PLANEMASK_BD | GX_BLEND_PLANEMASK_OBJ | GX_BLEND_PLANEMASK_BG3 | GX_BLEND_PLANEMASK_BG2 | GX_BLEND_PLANEMASK_BG1 | GX_BLEND_PLANEMASK_BG0), SCREEN_MASK_MAIN | SCREEN_MASK_SUB);
|
||||
if (GetMomSpawnId() == LocalFieldData_GetBlackoutSpawn(Save_LocalFieldData_Get(fieldSystem->saveData))) {
|
||||
QueueScript(taskManager, 0x7E4, NULL, NULL);
|
||||
} else {
|
||||
QueueScript(taskManager, 0x7E5, NULL, NULL);
|
||||
}
|
||||
(*state)++;
|
||||
break;
|
||||
case STATE_BLACKOUT_TASK_EXIT:
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
case STATE_BLACKOUT_TASK_DRAW:
|
||||
SetBlendBrightness(-16, (GXBlendPlaneMask)(GX_BLEND_PLANEMASK_BD | GX_BLEND_PLANEMASK_OBJ | GX_BLEND_PLANEMASK_BG2 | GX_BLEND_PLANEMASK_BG1 | GX_BLEND_PLANEMASK_BG0), SCREEN_MASK_MAIN);
|
||||
SetBlendBrightness(-16, (GXBlendPlaneMask)(GX_BLEND_PLANEMASK_BD | GX_BLEND_PLANEMASK_OBJ | GX_BLEND_PLANEMASK_BG3 | GX_BLEND_PLANEMASK_BG2 | GX_BLEND_PLANEMASK_BG1 | GX_BLEND_PLANEMASK_BG0), SCREEN_MASK_SUB);
|
||||
Blackout_DrawMessage(fieldSystem, taskManager);
|
||||
(*state)++;
|
||||
break;
|
||||
case STATE_BLACKOUT_TASK_RESTORE_OVERWORLD:
|
||||
CallTask_RestoreOverworld(taskManager);
|
||||
(*state)++;
|
||||
break;
|
||||
case STATE_BLACKOUT_TASK_QUEUE_SCRIPT:
|
||||
SetBlendBrightness(0, (GXBlendPlaneMask)(GX_BLEND_PLANEMASK_BD | GX_BLEND_PLANEMASK_OBJ | GX_BLEND_PLANEMASK_BG3 | GX_BLEND_PLANEMASK_BG2 | GX_BLEND_PLANEMASK_BG1 | GX_BLEND_PLANEMASK_BG0), SCREEN_MASK_MAIN | SCREEN_MASK_SUB);
|
||||
if (GetMomSpawnId() == LocalFieldData_GetBlackoutSpawn(Save_LocalFieldData_Get(fieldSystem->saveData))) {
|
||||
QueueScript(taskManager, 0x7E4, NULL, NULL);
|
||||
} else {
|
||||
QueueScript(taskManager, 0x7E5, NULL, NULL);
|
||||
}
|
||||
(*state)++;
|
||||
break;
|
||||
case STATE_BLACKOUT_TASK_EXIT:
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#include "global.h"
|
||||
#include "brightness.h"
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "GX_g2.h"
|
||||
#include "MI_memory.h"
|
||||
|
||||
|
|
@ -23,7 +25,7 @@ void DoBrightnessTransitionStep(BrightnessData *brightness) {
|
|||
}
|
||||
} else {
|
||||
brightness->currentBrightness = brightness->targetBrightness;
|
||||
transitionFinished = TRUE;
|
||||
transitionFinished = TRUE;
|
||||
}
|
||||
|
||||
if (brightness->screenMask & SCREEN_MASK_MAIN) {
|
||||
|
|
@ -40,13 +42,13 @@ void DoBrightnessTransitionStep(BrightnessData *brightness) {
|
|||
void InitBrightnessTransition(BrightnessData *brightnessData, u16 stepCount, s16 targetBrightness, s16 startBrightness, GXBlendPlaneMask surfaceMask, u32 screenMask) {
|
||||
GF_ASSERT(!brightnessData->transitionActive);
|
||||
|
||||
brightnessData->transitionActive = TRUE;
|
||||
brightnessData->surfaceMask = (GXBlendPlaneMask)(u8)surfaceMask;
|
||||
brightnessData->screenMask = (u8)screenMask;
|
||||
brightnessData->stepCount = stepCount;
|
||||
brightnessData->targetBrightness = targetBrightness;
|
||||
brightnessData->transitionActive = TRUE;
|
||||
brightnessData->surfaceMask = (GXBlendPlaneMask)(u8)surfaceMask;
|
||||
brightnessData->screenMask = (u8)screenMask;
|
||||
brightnessData->stepCount = stepCount;
|
||||
brightnessData->targetBrightness = targetBrightness;
|
||||
brightnessData->currentBrightness = startBrightness;
|
||||
brightnessData->brightnessDiff = startBrightness - targetBrightness;
|
||||
brightnessData->brightnessDiff = startBrightness - targetBrightness;
|
||||
|
||||
if (brightnessData->brightnessDiff > 0) {
|
||||
brightnessData->transitionDirection = -1;
|
||||
|
|
@ -55,9 +57,9 @@ void InitBrightnessTransition(BrightnessData *brightnessData, u16 stepCount, s16
|
|||
brightnessData->brightnessDiff *= -1;
|
||||
}
|
||||
|
||||
brightnessData->stepSizeInteger = brightnessData->brightnessDiff / stepCount;
|
||||
brightnessData->stepSizeInteger = brightnessData->brightnessDiff / stepCount;
|
||||
brightnessData->stepSizeFractional = brightnessData->brightnessDiff % stepCount;
|
||||
brightnessData->fractionalCount = 0;
|
||||
brightnessData->fractionalCount = 0;
|
||||
}
|
||||
|
||||
void StartBrightnessTransition(u16 stepCount, s16 targetBrightness, s16 startBrightness, GXBlendPlaneMask surfaceMask, u32 screenMask) {
|
||||
|
|
@ -91,7 +93,7 @@ void ScreenBrightnessData_InitAll(void) {
|
|||
MI_CpuFill8(&sSubScreenBrightnessData, 0, sizeof(BrightnessData));
|
||||
|
||||
sMainScreenBrightnessData.transitionActive = FALSE;
|
||||
sSubScreenBrightnessData.transitionActive = FALSE;
|
||||
sSubScreenBrightnessData.transitionActive = FALSE;
|
||||
}
|
||||
|
||||
void InitScreenBrightnessData(u32 screenMask) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
#include "global.h"
|
||||
#include "nitro/NNS_g3d.h"
|
||||
#include "camera.h"
|
||||
|
||||
#include "nitro/NNS_g3d.h"
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "GX_g3.h"
|
||||
#include "fx.h"
|
||||
#include "heap.h"
|
||||
|
|
@ -17,7 +20,7 @@ GXBufferMode gG3dDepthBufferingMode = GX_BUFFERMODE_W;
|
|||
static Camera *sCameraPtr;
|
||||
|
||||
static void Camera_CalcLookAtPosFromTargetAndAngle(Camera *camera) {
|
||||
u16 negx = -camera->angle.x;
|
||||
u16 negx = -camera->angle.x;
|
||||
camera->lookAt.camPos.x = FX_Mul(FX_Mul(FX_SinIdx(camera->angle.y), camera->distance), FX_CosIdx(camera->angle.x));
|
||||
camera->lookAt.camPos.z = FX_Mul(FX_Mul(FX_CosIdx(camera->angle.y), camera->distance), FX_CosIdx(camera->angle.x));
|
||||
camera->lookAt.camPos.y = FX_Mul(FX_SinIdx(negx), camera->distance);
|
||||
|
|
@ -25,7 +28,7 @@ static void Camera_CalcLookAtPosFromTargetAndAngle(Camera *camera) {
|
|||
}
|
||||
|
||||
static void Camera_CalcLookAtTargetFromPosAndAngle(Camera *camera) {
|
||||
u16 negx = -camera->angle.x;
|
||||
u16 negx = -camera->angle.x;
|
||||
camera->lookAt.camTarget.x = -FX_Mul(FX_Mul(FX_SinIdx(camera->angle.y), camera->distance), FX_CosIdx(camera->angle.x));
|
||||
camera->lookAt.camTarget.z = -FX_Mul(FX_Mul(FX_CosIdx(camera->angle.y), camera->distance), FX_CosIdx(camera->angle.x));
|
||||
camera->lookAt.camTarget.y = -FX_Mul(FX_SinIdx(negx), camera->distance);
|
||||
|
|
@ -33,20 +36,20 @@ static void Camera_CalcLookAtTargetFromPosAndAngle(Camera *camera) {
|
|||
}
|
||||
|
||||
static void Camera_InitInternal(u16 perspectiveAngle, Camera *camera) {
|
||||
camera->perspectiveAngle = perspectiveAngle;
|
||||
camera->perspectiveAngle = perspectiveAngle;
|
||||
camera->perspective.fovySin = FX_SinIdx(perspectiveAngle);
|
||||
camera->perspective.fovyCos = FX_CosIdx(perspectiveAngle);
|
||||
camera->perspective.aspect = FX32_CONST(1.33333333); // 4x3
|
||||
camera->perspective.near = FX32_CONST(150);
|
||||
camera->perspective.far = FX32_CONST(900);
|
||||
camera->lookAt.camUp.x = 0;
|
||||
camera->lookAt.camUp.y = FX32_ONE;
|
||||
camera->lookAt.camUp.z = 0;
|
||||
camera->curTarget = NULL;
|
||||
camera->enableOffsetX = FALSE;
|
||||
camera->enableOffsetY = FALSE;
|
||||
camera->enableOffsetZ = FALSE;
|
||||
camera->history = NULL;
|
||||
camera->perspective.aspect = FX32_CONST(1.33333333); // 4x3
|
||||
camera->perspective.near = FX32_CONST(150);
|
||||
camera->perspective.far = FX32_CONST(900);
|
||||
camera->lookAt.camUp.x = 0;
|
||||
camera->lookAt.camUp.y = FX32_ONE;
|
||||
camera->lookAt.camUp.z = 0;
|
||||
camera->curTarget = NULL;
|
||||
camera->enableOffsetX = FALSE;
|
||||
camera->enableOffsetY = FALSE;
|
||||
camera->enableOffsetZ = FALSE;
|
||||
camera->history = NULL;
|
||||
}
|
||||
|
||||
static void Camera_VecResetCoordsIfOffsetComponentNotEnabled(Camera *camera, VecFx32 *vec) {
|
||||
|
|
@ -65,7 +68,7 @@ static void Camera_GetVecFromSomeRingBufferMaybe(Camera *camera, const VecFx32 *
|
|||
if (camera->history == NULL) {
|
||||
*vecDest = *vecDefault;
|
||||
} else {
|
||||
s32 *idxPtr = &camera->history->readIdx;
|
||||
s32 *idxPtr = &camera->history->readIdx;
|
||||
s32 *idx2Ptr = &camera->history->writeIdx;
|
||||
if (!camera->history->overrideEnabled) {
|
||||
*vecDest = *vecDefault;
|
||||
|
|
@ -75,9 +78,9 @@ static void Camera_GetVecFromSomeRingBufferMaybe(Camera *camera, const VecFx32 *
|
|||
} else {
|
||||
*vecDest = camera->history->vecs[camera->history->readIdx];
|
||||
}
|
||||
*idxPtr = (*idxPtr + 1) % camera->history->count;
|
||||
*idxPtr = (*idxPtr + 1) % camera->history->count;
|
||||
camera->history->vecs[*idx2Ptr] = *vecDefault;
|
||||
*idx2Ptr = (*idx2Ptr + 1) % camera->history->count;
|
||||
*idx2Ptr = (*idx2Ptr + 1) % camera->history->count;
|
||||
if (!camera->history->enableUpdateX) {
|
||||
vecDest->x = vecDefault->x;
|
||||
}
|
||||
|
|
@ -96,20 +99,20 @@ void Camera_History_New(s32 count, s32 initialWriteIdx, s32 updateEnableFlags, H
|
|||
}
|
||||
GF_ASSERT(initialWriteIdx + 1 <= count);
|
||||
CameraHistory *history = AllocFromHeap(heapId, sizeof(CameraHistory));
|
||||
history->vecs = AllocFromHeap(heapId, sizeof(VecFx32) * count);
|
||||
history->vecs = AllocFromHeap(heapId, sizeof(VecFx32) * count);
|
||||
for (s32 i = 0; i < count; i++) {
|
||||
history->vecs[i].x = 0;
|
||||
history->vecs[i].y = 0;
|
||||
history->vecs[i].z = 0;
|
||||
}
|
||||
history->count = count;
|
||||
history->readIdx = 0;
|
||||
history->writeIdx = initialWriteIdx;
|
||||
history->writeIdxInit = initialWriteIdx;
|
||||
history->count = count;
|
||||
history->readIdx = 0;
|
||||
history->writeIdx = initialWriteIdx;
|
||||
history->writeIdxInit = initialWriteIdx;
|
||||
history->overrideEnabled = FALSE;
|
||||
history->enableUpdateX = FALSE;
|
||||
history->enableUpdateY = FALSE;
|
||||
history->enableUpdateZ = FALSE;
|
||||
history->enableUpdateX = FALSE;
|
||||
history->enableUpdateY = FALSE;
|
||||
history->enableUpdateZ = FALSE;
|
||||
if (updateEnableFlags & CAMERA_UPDATE_ENABLE_X) {
|
||||
history->enableUpdateX = TRUE;
|
||||
}
|
||||
|
|
@ -171,15 +174,15 @@ void Camera_SetLookAtCamUp(VecFx32 *camUp, Camera *camera) {
|
|||
}
|
||||
|
||||
void Camera_SetFixedTarget(VecFx32 *target, Camera *camera) {
|
||||
camera->curTarget = target;
|
||||
camera->lastTarget = *target;
|
||||
camera->curTarget = target;
|
||||
camera->lastTarget = *target;
|
||||
camera->enableOffsetX = TRUE;
|
||||
camera->enableOffsetY = TRUE;
|
||||
camera->enableOffsetZ = TRUE;
|
||||
}
|
||||
|
||||
void Camera_ClearFixedTarget(Camera *camera) {
|
||||
camera->curTarget = NULL;
|
||||
camera->curTarget = NULL;
|
||||
camera->enableOffsetX = FALSE;
|
||||
camera->enableOffsetY = FALSE;
|
||||
camera->enableOffsetZ = FALSE;
|
||||
|
|
@ -187,22 +190,22 @@ void Camera_ClearFixedTarget(Camera *camera) {
|
|||
|
||||
void Camera_SetPerspectiveClippingPlane(fx32 near, fx32 far, Camera *camera) {
|
||||
camera->perspective.near = near;
|
||||
camera->perspective.far = far,
|
||||
camera->perspective.far = far,
|
||||
Camera_ApplyPerspectiveType(camera->perspectiveType, camera);
|
||||
}
|
||||
|
||||
void Camera_Init_FromTargetDistanceAndAngle(VecFx32 *target, fx32 distance, CameraAngle *angle, u16 perspectiveAngle, u8 perspectiveType, BOOL setReference, Camera *camera) {
|
||||
Camera_InitInternal(perspectiveAngle, camera);
|
||||
camera->lookAt.camTarget = *target;
|
||||
camera->distance = distance;
|
||||
camera->angle = *angle;
|
||||
camera->distance = distance;
|
||||
camera->angle = *angle;
|
||||
Camera_CalcLookAtPosFromTargetAndAngle(camera);
|
||||
Camera_ApplyPerspectiveType(perspectiveType, camera);
|
||||
if (!setReference) {
|
||||
return;
|
||||
}
|
||||
camera->curTarget = target;
|
||||
camera->lastTarget = *target;
|
||||
}
|
||||
camera->curTarget = target;
|
||||
camera->lastTarget = *target;
|
||||
camera->enableOffsetX = TRUE;
|
||||
camera->enableOffsetY = TRUE;
|
||||
camera->enableOffsetZ = TRUE;
|
||||
|
|
@ -211,8 +214,8 @@ void Camera_Init_FromTargetDistanceAndAngle(VecFx32 *target, fx32 distance, Came
|
|||
void Camera_Init_FromPosDistanceAndAngle(VecFx32 *pos, fx32 distance, CameraAngle *angle, u16 perspectiveAngle, u8 perspectiveType, Camera *camera) {
|
||||
Camera_InitInternal(perspectiveAngle, camera);
|
||||
camera->lookAt.camPos = *pos;
|
||||
camera->distance = distance;
|
||||
camera->angle = *angle;
|
||||
camera->distance = distance;
|
||||
camera->angle = *angle;
|
||||
Camera_CalcLookAtTargetFromPosAndAngle(camera);
|
||||
Camera_ApplyPerspectiveType(perspectiveType, camera);
|
||||
}
|
||||
|
|
@ -222,28 +225,28 @@ void Camera_Init_FromTargetAndPos(const VecFx32 *target, const VecFx32 *pos, u16
|
|||
Camera_InitInternal(perspectiveAngle, camera);
|
||||
|
||||
camera->lookAt.camTarget = *target;
|
||||
camera->lookAt.camPos = *pos;
|
||||
camera->lookAt.camPos = *pos;
|
||||
|
||||
VEC_Subtract(pos, target, &vec_from_pos_to_target);
|
||||
camera->distance = VEC_Mag(&vec_from_pos_to_target);
|
||||
VecFx32 sp24 = {0, 0, 0}; // unused
|
||||
VecFx32 sp18 = {0, 0, 0}; // unused
|
||||
VecFx32 sp0C = {0, 0, 0};
|
||||
VecFx32 sp24 = { 0, 0, 0 }; // unused
|
||||
VecFx32 sp18 = { 0, 0, 0 }; // unused
|
||||
VecFx32 sp0C = { 0, 0, 0 };
|
||||
VecFx32 sp00;
|
||||
|
||||
sp00.x = 0;
|
||||
sp00.y = 0;
|
||||
sp00.z = FX32_ONE;
|
||||
sp0C = vec_from_pos_to_target;
|
||||
sp0C.y = 0;
|
||||
sp00.x = 0;
|
||||
sp00.y = 0;
|
||||
sp00.z = FX32_ONE;
|
||||
sp0C = vec_from_pos_to_target;
|
||||
sp0C.y = 0;
|
||||
camera->angle.y = CalcAngleBetweenVecs(&sp00, &sp0C);
|
||||
|
||||
sp00.x = FX32_ONE;
|
||||
sp00.y = 0;
|
||||
sp00.z = 0;
|
||||
sp0C.x = vec_from_pos_to_target.z;
|
||||
sp0C.z = vec_from_pos_to_target.y;
|
||||
sp0C.y = 0;
|
||||
sp00.x = FX32_ONE;
|
||||
sp00.y = 0;
|
||||
sp00.z = 0;
|
||||
sp0C.x = vec_from_pos_to_target.z;
|
||||
sp0C.z = vec_from_pos_to_target.y;
|
||||
sp0C.y = 0;
|
||||
camera->angle.x = CalcAngleBetweenVecs(&sp00, &sp0C);
|
||||
|
||||
camera->angle.z = 0;
|
||||
|
|
@ -252,8 +255,8 @@ void Camera_Init_FromTargetAndPos(const VecFx32 *target, const VecFx32 *pos, u16
|
|||
if (!setReference) {
|
||||
return;
|
||||
}
|
||||
camera->curTarget = target;
|
||||
camera->lastTarget = *target;
|
||||
camera->curTarget = target;
|
||||
camera->lastTarget = *target;
|
||||
camera->enableOffsetX = TRUE;
|
||||
camera->enableOffsetY = TRUE;
|
||||
camera->enableOffsetZ = TRUE;
|
||||
|
|
@ -263,18 +266,18 @@ void Camera_ApplyPerspectiveType(u8 perspectiveType, Camera *camera) {
|
|||
if (perspectiveType == CAMERA_PERSPECTIVE_TYPE_PERSPECTIVE) {
|
||||
NNS_G3dGlbPerspective(camera->perspective.fovySin, camera->perspective.fovyCos, camera->perspective.aspect, camera->perspective.near, camera->perspective.far);
|
||||
camera->perspectiveType = CAMERA_PERSPECTIVE_TYPE_PERSPECTIVE;
|
||||
gG3dDepthBufferingMode = GX_BUFFERMODE_Z;
|
||||
gG3dDepthBufferingMode = GX_BUFFERMODE_Z;
|
||||
} else {
|
||||
fx32 y = FX_Mul(FX_Div(camera->perspective.fovySin, camera->perspective.fovyCos), camera->distance);
|
||||
fx32 x = FX_Mul(y, camera->perspective.aspect);
|
||||
NNS_G3dGlbOrtho(y, -y, -x, x, camera->perspective.near, camera->perspective.far);
|
||||
camera->perspectiveType = CAMERA_PERSPECTIVE_TYPE_ORTHOGRAPHIC;
|
||||
gG3dDepthBufferingMode = GX_BUFFERMODE_Z;
|
||||
gG3dDepthBufferingMode = GX_BUFFERMODE_Z;
|
||||
}
|
||||
}
|
||||
|
||||
void Camera_SetPerspectiveAngle(u16 perspectiveAngle, Camera *camera) {
|
||||
camera->perspectiveAngle = perspectiveAngle;
|
||||
camera->perspectiveAngle = perspectiveAngle;
|
||||
camera->perspective.fovySin = FX_SinIdx(camera->perspectiveAngle);
|
||||
camera->perspective.fovyCos = FX_CosIdx(camera->perspectiveAngle);
|
||||
Camera_ApplyPerspectiveType(camera->perspectiveType, camera);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "global.h"
|
||||
#include "coins.h"
|
||||
|
||||
#include "global.h"
|
||||
|
||||
void InitCoins(u16 *coins) {
|
||||
*coins = 0;
|
||||
}
|
||||
|
|
@ -14,7 +15,7 @@ u16 CheckCoins(u16 *coins) {
|
|||
return *coins;
|
||||
}
|
||||
|
||||
BOOL GiveCoins(u16 * coins, u16 amount) {
|
||||
BOOL GiveCoins(u16 *coins, u16 amount) {
|
||||
if (*coins >= MAX_COINS) {
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,63 +1,67 @@
|
|||
#include "global.h"
|
||||
#include "bg_window.h"
|
||||
#include "communication_error.h"
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "constants/rgb.h"
|
||||
#include "game_init.h"
|
||||
#include "MI_dma.h"
|
||||
#include "msgdata.h"
|
||||
|
||||
#include "msgdata/msg.naix"
|
||||
#include "msgdata/msg/narc_0200.h"
|
||||
#include "text.h"
|
||||
|
||||
#include "MI_dma.h"
|
||||
#include "bg_window.h"
|
||||
#include "brightness.h"
|
||||
#include "game_init.h"
|
||||
#include "msgdata.h"
|
||||
#include "render_window.h"
|
||||
#include "text.h"
|
||||
|
||||
extern void SetMasterBrightnessNeutral(BOOL set_brightness_on_bottom_screen);
|
||||
extern void sub_0200E3A0(BOOL set_brightness_on_bottom_screen, s32);
|
||||
|
||||
static const struct WindowTemplate sCommunicationErrorWindowTemplate = {
|
||||
.bgId = GF_BG_LYR_MAIN_0,
|
||||
.left = 3,
|
||||
.top = 3,
|
||||
.width = 26,
|
||||
.height = 18,
|
||||
.palette = 1,
|
||||
.bgId = GF_BG_LYR_MAIN_0,
|
||||
.left = 3,
|
||||
.top = 3,
|
||||
.width = 26,
|
||||
.height = 18,
|
||||
.palette = 1,
|
||||
.baseTile = 0x23,
|
||||
};
|
||||
|
||||
static const struct GraphicsModes sCommunicationErrorGraphicsModes = {
|
||||
.dispMode = GX_DISPMODE_GRAPHICS,
|
||||
.bgMode = GX_BGMODE_0,
|
||||
.subMode = GX_BGMODE_0,
|
||||
.dispMode = GX_DISPMODE_GRAPHICS,
|
||||
.bgMode = GX_BGMODE_0,
|
||||
.subMode = GX_BGMODE_0,
|
||||
._2d3dMode = GX_BG0_AS_2D,
|
||||
};
|
||||
|
||||
static const struct BgTemplate sCommunicationErrorBgTemplate = {
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.bufferSize = 0x800,
|
||||
.baseTile = 0,
|
||||
.size = GF_BG_SCR_SIZE_256x256,
|
||||
.colorMode = GX_BG_COLORMODE_16,
|
||||
.baseTile = 0,
|
||||
.size = GF_BG_SCR_SIZE_256x256,
|
||||
.colorMode = GX_BG_COLORMODE_16,
|
||||
.screenBase = GX_BG_SCRBASE_0x0000,
|
||||
.charBase = GX_BG_CHARBASE_0x18000,
|
||||
.bgExtPltt = GX_BG_EXTPLTT_01,
|
||||
.priority = 1,
|
||||
.areaOver = GX_BG_AREAOVER_XLU,
|
||||
.dummy = 0,
|
||||
.mosaic = FALSE,
|
||||
.charBase = GX_BG_CHARBASE_0x18000,
|
||||
.bgExtPltt = GX_BG_EXTPLTT_01,
|
||||
.priority = 1,
|
||||
.areaOver = GX_BG_AREAOVER_XLU,
|
||||
.dummy = 0,
|
||||
.mosaic = FALSE,
|
||||
};
|
||||
|
||||
static const GraphicsBanks sCommunicationErrorGraphicsBanks = {
|
||||
.bg = GX_VRAM_BG_256_AB,
|
||||
.bgextpltt = GX_VRAM_BGEXTPLTT_NONE,
|
||||
.subbg = GX_VRAM_SUB_BG_NONE,
|
||||
.subbgextpltt = GX_VRAM_SUB_BGEXTPLTT_NONE,
|
||||
.obj = GX_VRAM_OBJ_NONE,
|
||||
.objextpltt = GX_VRAM_OBJEXTPLTT_NONE,
|
||||
.subobj = GX_VRAM_SUB_OBJ_NONE,
|
||||
.bg = GX_VRAM_BG_256_AB,
|
||||
.bgextpltt = GX_VRAM_BGEXTPLTT_NONE,
|
||||
.subbg = GX_VRAM_SUB_BG_NONE,
|
||||
.subbgextpltt = GX_VRAM_SUB_BGEXTPLTT_NONE,
|
||||
.obj = GX_VRAM_OBJ_NONE,
|
||||
.objextpltt = GX_VRAM_OBJEXTPLTT_NONE,
|
||||
.subobj = GX_VRAM_SUB_OBJ_NONE,
|
||||
.subobjextpltt = GX_VRAM_SUB_OBJEXTPLTT_NONE,
|
||||
.tex = GX_VRAM_TEX_NONE,
|
||||
.texpltt = GX_VRAM_TEXPLTT_NONE,
|
||||
.tex = GX_VRAM_TEX_NONE,
|
||||
.texpltt = GX_VRAM_TEXPLTT_NONE,
|
||||
};
|
||||
|
||||
static void VBlankIntr(void);
|
||||
|
|
@ -69,25 +73,25 @@ static void VBlankIntr(void) {
|
|||
|
||||
void ShowCommunicationError(HeapID heapId, u32 error, u32 errorCode) {
|
||||
Window window;
|
||||
|
||||
|
||||
u32 msgNo;
|
||||
switch (error) {
|
||||
default:
|
||||
case 0:
|
||||
msgNo = narc_0200_00001; //A communication error has occurred. If you were in the Union Room...
|
||||
break;
|
||||
case 1:
|
||||
msgNo = narc_0200_00002; //An error occurred while attempting to communicate. ({STRVAR_1 54, 0}) Please turn off the power...
|
||||
break;
|
||||
case 2:
|
||||
msgNo = narc_0200_00003; //A communication error has occurred. You will be returned to the title screen...
|
||||
break;
|
||||
case 3:
|
||||
msgNo = narc_0200_00004; //The GTS is extremely busy now. Please wait a while and try again.
|
||||
break;
|
||||
case 4:
|
||||
msgNo = narc_0200_00005; //An error occurred while attempting\nto communicate.\nPlease turn off the power...
|
||||
break;
|
||||
default:
|
||||
case 0:
|
||||
msgNo = narc_0200_00001; // A communication error has occurred. If you were in the Union Room...
|
||||
break;
|
||||
case 1:
|
||||
msgNo = narc_0200_00002; // An error occurred while attempting to communicate. ({STRVAR_1 54, 0}) Please turn off the power...
|
||||
break;
|
||||
case 2:
|
||||
msgNo = narc_0200_00003; // A communication error has occurred. You will be returned to the title screen...
|
||||
break;
|
||||
case 3:
|
||||
msgNo = narc_0200_00004; // The GTS is extremely busy now. Please wait a while and try again.
|
||||
break;
|
||||
case 4:
|
||||
msgNo = narc_0200_00005; // An error occurred while attempting\nto communicate.\nPlease turn off the power...
|
||||
break;
|
||||
}
|
||||
|
||||
sub_0200E3A0(PM_LCD_TOP, 0);
|
||||
|
|
@ -116,7 +120,7 @@ void ShowCommunicationError(HeapID heapId, u32 error, u32 errorCode) {
|
|||
GXS_SetVisibleWnd(0);
|
||||
GfGfx_SetBanks(&sCommunicationErrorGraphicsBanks);
|
||||
|
||||
BgConfig* bgConfig = BgConfig_Alloc(heapId);
|
||||
BgConfig *bgConfig = BgConfig_Alloc(heapId);
|
||||
SetBothScreensModesAndDisable(&sCommunicationErrorGraphicsModes);
|
||||
InitBgFromTemplate(bgConfig, 0, &sCommunicationErrorBgTemplate, GX_BGMODE_0);
|
||||
BgClearTilemapBufferAndCommit(bgConfig, GF_BG_LYR_MAIN_0);
|
||||
|
|
@ -126,11 +130,11 @@ void ShowCommunicationError(HeapID heapId, u32 error, u32 errorCode) {
|
|||
BG_SetMaskColor(GF_BG_LYR_MAIN_0, RGB(1, 1, 27));
|
||||
BG_SetMaskColor(GF_BG_LYR_SUB_0, RGB(1, 1, 27));
|
||||
|
||||
MsgData* errorMessageData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0200_bin, heapId);
|
||||
String* errorMessageStr = String_New(384, heapId);
|
||||
String* tmpStr = String_New(384, heapId);
|
||||
MsgData *errorMessageData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0200_bin, heapId);
|
||||
String *errorMessageStr = String_New(384, heapId);
|
||||
String *tmpStr = String_New(384, heapId);
|
||||
ResetAllTextPrinters();
|
||||
MessageFormat* messageFormat = MessageFormat_New(heapId);
|
||||
MessageFormat *messageFormat = MessageFormat_New(heapId);
|
||||
|
||||
AddWindow(bgConfig, &window, &sCommunicationErrorWindowTemplate);
|
||||
FillWindowPixelRect(&window, 0xF, 0, 0, 208, 144);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
#include "global.h"
|
||||
#include "pokemon.h"
|
||||
#include "mail.h"
|
||||
#include "save.h"
|
||||
#include "daycare.h"
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "mail.h"
|
||||
#include "pokemon.h"
|
||||
#include "save.h"
|
||||
|
||||
u32 Save_Daycare_sizeof(void) {
|
||||
return sizeof(Daycare);
|
||||
}
|
||||
|
|
@ -12,7 +14,7 @@ void Save_Daycare_Init(Daycare *daycare) {
|
|||
memset(daycare, 0, sizeof(Daycare));
|
||||
ZeroBoxMonData(&daycare->mons[0].mon);
|
||||
ZeroBoxMonData(&daycare->mons[1].mon);
|
||||
daycare->egg_pid = 0;
|
||||
daycare->egg_pid = 0;
|
||||
daycare->egg_cycles = 0;
|
||||
}
|
||||
|
||||
|
|
@ -65,15 +67,14 @@ BOOL Save_Daycare_MasudaCheck(Daycare *daycare) {
|
|||
// Uses language as a proxy for country, even though it
|
||||
// only accounts for European languages and Japanese.
|
||||
// If true, shiny odds are increased.
|
||||
return GetBoxMonData(&daycare->mons[0].mon, MON_DATA_GAME_LANGUAGE, NULL) !=
|
||||
GetBoxMonData(&daycare->mons[1].mon, MON_DATA_GAME_LANGUAGE, NULL);
|
||||
return GetBoxMonData(&daycare->mons[0].mon, MON_DATA_GAME_LANGUAGE, NULL) != GetBoxMonData(&daycare->mons[1].mon, MON_DATA_GAME_LANGUAGE, NULL);
|
||||
}
|
||||
|
||||
void DaycareMon_Copy(DaycareMon *dest, const DaycareMon *src) {
|
||||
*dest = *src;
|
||||
}
|
||||
|
||||
void DaycareMon_Extras_Init(DaycareMail *mail){
|
||||
void DaycareMon_Extras_Init(DaycareMail *mail) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < PLAYER_NAME_LENGTH + 1; i++) {
|
||||
|
|
@ -84,7 +85,7 @@ void DaycareMon_Extras_Init(DaycareMail *mail){
|
|||
mail->nickname[i] = 0;
|
||||
}
|
||||
|
||||
mail->ot_name[0] = EOS;
|
||||
mail->ot_name[0] = EOS;
|
||||
mail->nickname[0] = EOS;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,23 +1,26 @@
|
|||
#include "global.h"
|
||||
#include "msgdata.h"
|
||||
#include "heap.h"
|
||||
#include "save.h"
|
||||
#include "math_util.h"
|
||||
#include "easy_chat.h"
|
||||
#include "msgdata/msg.naix"
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "constants/abilities.h"
|
||||
#include "constants/easy_chat.h"
|
||||
#include "constants/moves.h"
|
||||
|
||||
#include "msgdata/msg.naix"
|
||||
#include "msgdata/msg/narc_0390.h"
|
||||
|
||||
#include "heap.h"
|
||||
#include "math_util.h"
|
||||
#include "msgdata.h"
|
||||
#include "save.h"
|
||||
|
||||
static const u8 sLanguageToGreetingMap[6][2] = {
|
||||
{ LANGUAGE_JAPANESE, narc_0390_konnichiwa },
|
||||
{ LANGUAGE_ENGLISH, narc_0390_hello },
|
||||
{ LANGUAGE_FRENCH, narc_0390_bonjour },
|
||||
{ LANGUAGE_ITALIAN, narc_0390_ciao },
|
||||
{ LANGUAGE_GERMAN, narc_0390_hallo },
|
||||
{ LANGUAGE_SPANISH, narc_0390_hola },
|
||||
{ LANGUAGE_ENGLISH, narc_0390_hello },
|
||||
{ LANGUAGE_FRENCH, narc_0390_bonjour },
|
||||
{ LANGUAGE_ITALIAN, narc_0390_ciao },
|
||||
{ LANGUAGE_GERMAN, narc_0390_hallo },
|
||||
{ LANGUAGE_SPANISH, narc_0390_hola },
|
||||
};
|
||||
|
||||
static const u16 sNarcMsgBanks[EC_GROUP_MAX] = {
|
||||
|
|
@ -48,18 +51,18 @@ static const u16 sNarcMsgCounts[EC_GROUP_MAX] = {
|
|||
EC_WORDS_UNION_COUNT,
|
||||
};
|
||||
|
||||
static const ecword_t sEasyChatHey[] = {EC_WORD_GREETINGS_HEY, EC_WORD_GREETINGS_HEY_2};
|
||||
static const ecword_t sEasyChatHuh_[] = {EC_WORD_GREETINGS_HUH_, EC_WORD_GREETINGS_HUH__2};
|
||||
static const ecword_t sEasyChatI[] = {EC_WORD_PEOPLE_I, EC_WORD_PEOPLE_I_2, EC_WORD_PEOPLE_I_3, EC_WORD_PEOPLE_I_4};
|
||||
static const ecword_t sEasyChatKids[] = {EC_WORD_PEOPLE_KIDS, EC_WORD_PEOPLE_KIDS_2};
|
||||
static const ecword_t sEasyChatNoWay[] = {EC_WORD_GREETINGS_NO_WAY, EC_WORD_FEELINGS_NO_WAY};
|
||||
static const ecword_t sEasyChatYou[] = {EC_WORD_PEOPLE_YOU, EC_WORD_PEOPLE_YOU_2};
|
||||
static const ecword_t sEasyChatAnticipation[] = {EC_WORD_ABILITY(ABILITY_ANTICIPATION), EC_WORD_FEELINGS_ANTICIPATION};
|
||||
static const ecword_t sEasyChatSimple[] = {EC_WORD_ABILITY(ABILITY_SIMPLE), EC_WORD_FEELINGS_SIMPLE};
|
||||
static const ecword_t sEasyChatWelcome[] = {EC_WORD_GREETINGS_WELCOME, EC_WORD_GREETINGS_WELCOME_2};
|
||||
static const ecword_t sEasyChatWow[] = {EC_WORD_GREETINGS_WOW, EC_WORD_GREETINGS_WOW_2};
|
||||
static const ecword_t sEasyChatPsychic[] = {EC_WORD_MOVE(MOVE_PSYCHIC), EC_WORD_TYPE(TYPE_PSYCHIC)};
|
||||
static const ecword_t sEasyChatOk[] = {EC_WORD_GREETINGS_OK, EC_WORD_GREETINGS_OK_2};
|
||||
static const ecword_t sEasyChatHey[] = { EC_WORD_GREETINGS_HEY, EC_WORD_GREETINGS_HEY_2 };
|
||||
static const ecword_t sEasyChatHuh_[] = { EC_WORD_GREETINGS_HUH_, EC_WORD_GREETINGS_HUH__2 };
|
||||
static const ecword_t sEasyChatI[] = { EC_WORD_PEOPLE_I, EC_WORD_PEOPLE_I_2, EC_WORD_PEOPLE_I_3, EC_WORD_PEOPLE_I_4 };
|
||||
static const ecword_t sEasyChatKids[] = { EC_WORD_PEOPLE_KIDS, EC_WORD_PEOPLE_KIDS_2 };
|
||||
static const ecword_t sEasyChatNoWay[] = { EC_WORD_GREETINGS_NO_WAY, EC_WORD_FEELINGS_NO_WAY };
|
||||
static const ecword_t sEasyChatYou[] = { EC_WORD_PEOPLE_YOU, EC_WORD_PEOPLE_YOU_2 };
|
||||
static const ecword_t sEasyChatAnticipation[] = { EC_WORD_ABILITY(ABILITY_ANTICIPATION), EC_WORD_FEELINGS_ANTICIPATION };
|
||||
static const ecword_t sEasyChatSimple[] = { EC_WORD_ABILITY(ABILITY_SIMPLE), EC_WORD_FEELINGS_SIMPLE };
|
||||
static const ecword_t sEasyChatWelcome[] = { EC_WORD_GREETINGS_WELCOME, EC_WORD_GREETINGS_WELCOME_2 };
|
||||
static const ecword_t sEasyChatWow[] = { EC_WORD_GREETINGS_WOW, EC_WORD_GREETINGS_WOW_2 };
|
||||
static const ecword_t sEasyChatPsychic[] = { EC_WORD_MOVE(MOVE_PSYCHIC), EC_WORD_TYPE(TYPE_PSYCHIC) };
|
||||
static const ecword_t sEasyChatOk[] = { EC_WORD_GREETINGS_OK, EC_WORD_GREETINGS_OK_2 };
|
||||
|
||||
typedef struct ECIdenticalPhrases {
|
||||
const ecword_t *data;
|
||||
|
|
@ -68,24 +71,24 @@ typedef struct ECIdenticalPhrases {
|
|||
|
||||
static const ECIdenticalPhrases sIdenticalPhrases[12] = {
|
||||
{ sEasyChatAnticipation, NELEMS(sEasyChatAnticipation) },
|
||||
{ sEasyChatHey, NELEMS(sEasyChatHey) },
|
||||
{ sEasyChatHuh_, NELEMS(sEasyChatHuh_) },
|
||||
{ sEasyChatI, NELEMS(sEasyChatI) },
|
||||
{ sEasyChatKids, NELEMS(sEasyChatKids) },
|
||||
{ sEasyChatNoWay, NELEMS(sEasyChatNoWay) },
|
||||
{ sEasyChatOk, NELEMS(sEasyChatOk) },
|
||||
{ sEasyChatPsychic, NELEMS(sEasyChatPsychic) },
|
||||
{ sEasyChatSimple, NELEMS(sEasyChatSimple) },
|
||||
{ sEasyChatWelcome, NELEMS(sEasyChatWelcome) },
|
||||
{ sEasyChatWow, NELEMS(sEasyChatWow) },
|
||||
{ sEasyChatYou, NELEMS(sEasyChatYou) },
|
||||
{ sEasyChatHey, NELEMS(sEasyChatHey) },
|
||||
{ sEasyChatHuh_, NELEMS(sEasyChatHuh_) },
|
||||
{ sEasyChatI, NELEMS(sEasyChatI) },
|
||||
{ sEasyChatKids, NELEMS(sEasyChatKids) },
|
||||
{ sEasyChatNoWay, NELEMS(sEasyChatNoWay) },
|
||||
{ sEasyChatOk, NELEMS(sEasyChatOk) },
|
||||
{ sEasyChatPsychic, NELEMS(sEasyChatPsychic) },
|
||||
{ sEasyChatSimple, NELEMS(sEasyChatSimple) },
|
||||
{ sEasyChatWelcome, NELEMS(sEasyChatWelcome) },
|
||||
{ sEasyChatWow, NELEMS(sEasyChatWow) },
|
||||
{ sEasyChatYou, NELEMS(sEasyChatYou) },
|
||||
};
|
||||
|
||||
EasyChatManager *EasyChatManager_New(HeapID heapId) {
|
||||
EasyChatManager *ret = AllocFromHeap(heapId, sizeof(EasyChatManager));
|
||||
|
||||
for (s32 i = 0; i < EC_GROUP_MAX; i++) {
|
||||
ret->heapId = heapId; // inadvertently inside the loop
|
||||
ret->heapId = heapId; // inadvertently inside the loop
|
||||
ret->msgData[i] = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, sNarcMsgBanks[i], heapId);
|
||||
}
|
||||
return ret;
|
||||
|
|
@ -112,8 +115,7 @@ void GetECWordIntoStringByIndex(u32 ecWord, String *dest) {
|
|||
GetCategoryAndMsgNoByECWordIdx(ecWord, &category, &msgNo);
|
||||
category = sNarcMsgBanks[category];
|
||||
ReadMsgData_NewNarc_ExistingString(NARC_MSGDATA_MSG, category, msgNo, HEAP_ID_DEFAULT, dest);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
String_SetEmpty(dest);
|
||||
}
|
||||
}
|
||||
|
|
@ -143,7 +145,7 @@ void GetCategoryAndMsgNoByECWordIdx(u32 ecWord, u32 *category, u32 *msgNo) {
|
|||
count += sNarcMsgCounts[bank];
|
||||
if (wordId < count) {
|
||||
*category = bank;
|
||||
*msgNo = (wordId - (count - sNarcMsgCounts[bank]));
|
||||
*msgNo = (wordId - (count - sNarcMsgCounts[bank]));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -157,7 +159,7 @@ void Save_EasyChat_Init(SaveEasyChat *saveEasyChat) {
|
|||
u32 i;
|
||||
|
||||
saveEasyChat->greetings = 0;
|
||||
saveEasyChat->trendy = 0;
|
||||
saveEasyChat->trendy = 0;
|
||||
for (i = 0; i < NELEMS(sLanguageToGreetingMap); i++) {
|
||||
if (sLanguageToGreetingMap[i][0] == GAME_LANGUAGE) {
|
||||
Save_EasyChat_SetGreetingFlag(saveEasyChat, sLanguageToGreetingMap[i][1]);
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
#include "global.h"
|
||||
#include "encounter.h"
|
||||
#include "blackout.h"
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "constants/battle.h"
|
||||
#include "constants/game_stats.h"
|
||||
#include "save_vars_flags.h"
|
||||
|
||||
#include "blackout.h"
|
||||
#include "field_system.h"
|
||||
#include "igt.h"
|
||||
#include "save_vars_flags.h"
|
||||
#include "task.h"
|
||||
#include "unk_020040F4.h"
|
||||
#include "unk_02022504.h"
|
||||
|
|
@ -84,18 +87,18 @@ static void sub_020473CC(FieldSystem *fieldSystem, BattleSetup *setup);
|
|||
static BOOL Task_StartBattle(TaskManager *taskManager) {
|
||||
FieldSystem *fieldSystem = TaskManager_GetFieldSystem(taskManager);
|
||||
BattleSetup *battleSetup = TaskManager_GetEnvironment(taskManager);
|
||||
u32 *state = TaskManager_GetStatePtr(taskManager);
|
||||
u32 *state = TaskManager_GetStatePtr(taskManager);
|
||||
|
||||
switch (*state) {
|
||||
case 0:
|
||||
sub_0203780C(fieldSystem, battleSetup);
|
||||
(*state)++;
|
||||
break;
|
||||
case 1:
|
||||
if (!FieldSystem_ApplicationIsRunning(fieldSystem)) {
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
case 0:
|
||||
sub_0203780C(fieldSystem, battleSetup);
|
||||
(*state)++;
|
||||
break;
|
||||
case 1:
|
||||
if (!FieldSystem_ApplicationIsRunning(fieldSystem)) {
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
|
@ -107,13 +110,13 @@ static void CallTask_StartBattle(TaskManager *taskManager, BattleSetup *setup) {
|
|||
|
||||
static Encounter *Encounter_New(BattleSetup *setup, s32 effect, s32 bgm, u32 *winFlag) {
|
||||
Encounter *encounter = AllocFromHeapAtEnd(HEAP_ID_FIELD, sizeof(Encounter));
|
||||
encounter->winFlag = winFlag;
|
||||
encounter->winFlag = winFlag;
|
||||
if (winFlag != NULL) {
|
||||
*winFlag = BATTLE_OUTCOME_NONE;
|
||||
}
|
||||
encounter->effect = effect;
|
||||
encounter->bgm = bgm;
|
||||
encounter->setup = setup;
|
||||
encounter->bgm = bgm;
|
||||
encounter->setup = setup;
|
||||
return encounter;
|
||||
}
|
||||
|
||||
|
|
@ -135,54 +138,54 @@ static void sub_020465E4(BattleSetup *setup, FieldSystem *fieldSystem) {
|
|||
}
|
||||
}
|
||||
|
||||
static BOOL Task_StartEncounter(TaskManager *taskManager) { //todo: better name
|
||||
static BOOL Task_StartEncounter(TaskManager *taskManager) { // todo: better name
|
||||
FieldSystem *fieldSystem = TaskManager_GetFieldSystem(taskManager);
|
||||
Encounter *encounter = TaskManager_GetEnvironment(taskManager);
|
||||
u32 *state = TaskManager_GetStatePtr(taskManager);
|
||||
Encounter *encounter = TaskManager_GetEnvironment(taskManager);
|
||||
u32 *state = TaskManager_GetStatePtr(taskManager);
|
||||
|
||||
switch (*state) {
|
||||
case 0:
|
||||
MapObjectManager_PauseAllMovement(fieldSystem->mapObjectManager);
|
||||
sub_0204AEF8(taskManager, encounter->effect, encounter->bgm);
|
||||
(*state)++;
|
||||
break;
|
||||
case 1:
|
||||
sub_0204AF3C(taskManager);
|
||||
(*state)++;
|
||||
break;
|
||||
case 2:
|
||||
CallTask_StartBattle(taskManager, encounter->setup);
|
||||
(*state)++;
|
||||
break;
|
||||
case 3:
|
||||
sub_020465E4(encounter->setup, fieldSystem);
|
||||
if (encounter->setup->flags == BATTLE_TYPE_NONE || encounter->setup->flags == BATTLE_TYPE_8 || encounter->setup->flags == (BATTLE_TYPE_DOUBLES | BATTLE_TYPE_MULTI | BATTLE_TYPE_6)) {
|
||||
sub_02061080(fieldSystem, encounter->setup->unk134, encounter->setup->winFlag);
|
||||
}
|
||||
case 0:
|
||||
MapObjectManager_PauseAllMovement(fieldSystem->mapObjectManager);
|
||||
sub_0204AEF8(taskManager, encounter->effect, encounter->bgm);
|
||||
(*state)++;
|
||||
break;
|
||||
case 1:
|
||||
sub_0204AF3C(taskManager);
|
||||
(*state)++;
|
||||
break;
|
||||
case 2:
|
||||
CallTask_StartBattle(taskManager, encounter->setup);
|
||||
(*state)++;
|
||||
break;
|
||||
case 3:
|
||||
sub_020465E4(encounter->setup, fieldSystem);
|
||||
if (encounter->setup->flags == BATTLE_TYPE_NONE || encounter->setup->flags == BATTLE_TYPE_8 || encounter->setup->flags == (BATTLE_TYPE_DOUBLES | BATTLE_TYPE_MULTI | BATTLE_TYPE_6)) {
|
||||
sub_02061080(fieldSystem, encounter->setup->unk134, encounter->setup->winFlag);
|
||||
}
|
||||
|
||||
if (Encounter_GetResult(encounter) == FALSE) {
|
||||
Encounter_Delete(encounter);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (Save_VarsFlags_CheckHaveFollower(Save_VarsFlags_Get(fieldSystem->saveData))) {
|
||||
HealParty(SaveArray_Party_Get(fieldSystem->saveData));
|
||||
}
|
||||
|
||||
sub_020472F4(fieldSystem, encounter->setup);
|
||||
sub_020473CC(fieldSystem, encounter->setup);
|
||||
CallTask_RestoreOverworld(taskManager);
|
||||
(*state)++;
|
||||
break;
|
||||
case 4:
|
||||
MapObjectManager_UnpauseAllMovement(fieldSystem->mapObjectManager);
|
||||
CallTask_FadeFromBlack(taskManager);
|
||||
(*state)++;
|
||||
break;
|
||||
case 5:
|
||||
if (Encounter_GetResult(encounter) == FALSE) {
|
||||
Encounter_Delete(encounter);
|
||||
return TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (Save_VarsFlags_CheckHaveFollower(Save_VarsFlags_Get(fieldSystem->saveData))) {
|
||||
HealParty(SaveArray_Party_Get(fieldSystem->saveData));
|
||||
}
|
||||
|
||||
sub_020472F4(fieldSystem, encounter->setup);
|
||||
sub_020473CC(fieldSystem, encounter->setup);
|
||||
CallTask_RestoreOverworld(taskManager);
|
||||
(*state)++;
|
||||
break;
|
||||
case 4:
|
||||
MapObjectManager_UnpauseAllMovement(fieldSystem->mapObjectManager);
|
||||
CallTask_FadeFromBlack(taskManager);
|
||||
(*state)++;
|
||||
break;
|
||||
case 5:
|
||||
Encounter_Delete(encounter);
|
||||
return TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
|
@ -194,111 +197,111 @@ static void CallTask_StartEncounter(TaskManager *taskManager, BattleSetup *setup
|
|||
}
|
||||
|
||||
static void sub_0204671C(s32 flag, FieldSystem *fieldSystem) {
|
||||
switch(flag & 0xF) {
|
||||
case 1:
|
||||
case 6:
|
||||
sub_0202E25C(fieldSystem->saveData, 1);
|
||||
break;
|
||||
case 2:
|
||||
case 5:
|
||||
sub_0202E25C(fieldSystem->saveData, -1);
|
||||
break;
|
||||
switch (flag & 0xF) {
|
||||
case 1:
|
||||
case 6:
|
||||
sub_0202E25C(fieldSystem->saveData, 1);
|
||||
break;
|
||||
case 2:
|
||||
case 5:
|
||||
sub_0202E25C(fieldSystem->saveData, -1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static BOOL Task_02046758(TaskManager *taskManager) {
|
||||
FieldSystem *fieldSystem = TaskManager_GetFieldSystem(taskManager);
|
||||
Encounter *encounter = TaskManager_GetEnvironment(taskManager);
|
||||
u32 *state = TaskManager_GetStatePtr(taskManager);
|
||||
Encounter *encounter = TaskManager_GetEnvironment(taskManager);
|
||||
u32 *state = TaskManager_GetStatePtr(taskManager);
|
||||
switch (*state) {
|
||||
case 0:
|
||||
sub_0204AEF8(taskManager, encounter->effect, encounter->bgm);
|
||||
(*state)++;
|
||||
break;
|
||||
case 1:
|
||||
sub_0204AF3C(taskManager);
|
||||
(*state)++;
|
||||
break;
|
||||
case 2:
|
||||
CallTask_StartBattle(taskManager, encounter->setup);
|
||||
(*state)++;
|
||||
break;
|
||||
case 3:
|
||||
sub_0204671C(encounter->setup->winFlag, fieldSystem);
|
||||
sub_02047FA4(encounter->setup, fieldSystem);
|
||||
GameStats_AddSpecial(Save_GameStats_Get(fieldSystem->saveData), GAME_STAT_UNK21);
|
||||
CallTask_RestoreOverworld(taskManager);
|
||||
(*state)++;
|
||||
break;
|
||||
case 4:
|
||||
case 5: //??
|
||||
Encounter_Delete(encounter);
|
||||
return TRUE;
|
||||
case 0:
|
||||
sub_0204AEF8(taskManager, encounter->effect, encounter->bgm);
|
||||
(*state)++;
|
||||
break;
|
||||
case 1:
|
||||
sub_0204AF3C(taskManager);
|
||||
(*state)++;
|
||||
break;
|
||||
case 2:
|
||||
CallTask_StartBattle(taskManager, encounter->setup);
|
||||
(*state)++;
|
||||
break;
|
||||
case 3:
|
||||
sub_0204671C(encounter->setup->winFlag, fieldSystem);
|
||||
sub_02047FA4(encounter->setup, fieldSystem);
|
||||
GameStats_AddSpecial(Save_GameStats_Get(fieldSystem->saveData), GAME_STAT_UNK21);
|
||||
CallTask_RestoreOverworld(taskManager);
|
||||
(*state)++;
|
||||
break;
|
||||
case 4:
|
||||
case 5: //??
|
||||
Encounter_Delete(encounter);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static BOOL Task_020467FC(TaskManager *taskManager) {
|
||||
FieldSystem *fieldSystem = TaskManager_GetFieldSystem(taskManager);
|
||||
Encounter *encounter = TaskManager_GetEnvironment(taskManager);
|
||||
u32 *state = TaskManager_GetStatePtr(taskManager);
|
||||
Encounter *encounter = TaskManager_GetEnvironment(taskManager);
|
||||
u32 *state = TaskManager_GetStatePtr(taskManager);
|
||||
|
||||
switch (*state) {
|
||||
case 0:
|
||||
sub_0200433C(5, encounter->bgm, 1);
|
||||
CallTask_StartBattle(taskManager, encounter->setup);
|
||||
(*state)++;
|
||||
break;
|
||||
case 1:
|
||||
sub_0204671C(encounter->setup->winFlag, fieldSystem);
|
||||
sub_02047FA4(encounter->setup, fieldSystem);
|
||||
GameStats_AddSpecial(Save_GameStats_Get(fieldSystem->saveData), GAME_STAT_UNK21);
|
||||
(*state)++;
|
||||
break;
|
||||
case 2:
|
||||
Encounter_Delete(encounter);
|
||||
return TRUE;
|
||||
case 0:
|
||||
sub_0200433C(5, encounter->bgm, 1);
|
||||
CallTask_StartBattle(taskManager, encounter->setup);
|
||||
(*state)++;
|
||||
break;
|
||||
case 1:
|
||||
sub_0204671C(encounter->setup->winFlag, fieldSystem);
|
||||
sub_02047FA4(encounter->setup, fieldSystem);
|
||||
GameStats_AddSpecial(Save_GameStats_Get(fieldSystem->saveData), GAME_STAT_UNK21);
|
||||
(*state)++;
|
||||
break;
|
||||
case 2:
|
||||
Encounter_Delete(encounter);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static BOOL Task_02046878(TaskManager *taskManager) {
|
||||
FieldSystem *fieldSystem = TaskManager_GetFieldSystem(taskManager);
|
||||
Encounter *encounter = TaskManager_GetEnvironment(taskManager);
|
||||
u32 *state = TaskManager_GetStatePtr(taskManager);
|
||||
Encounter *encounter = TaskManager_GetEnvironment(taskManager);
|
||||
u32 *state = TaskManager_GetStatePtr(taskManager);
|
||||
|
||||
switch (*state) {
|
||||
case 0:
|
||||
sub_0204AEF8(taskManager, encounter->effect, encounter->bgm);
|
||||
(*state)++;
|
||||
break;
|
||||
case 1:
|
||||
sub_0204AF3C(taskManager);
|
||||
(*state)++;
|
||||
break;
|
||||
case 2:
|
||||
CallTask_StartBattle(taskManager, encounter->setup);
|
||||
(*state)++;
|
||||
break;
|
||||
case 3:
|
||||
sub_02047FA4(encounter->setup, fieldSystem);
|
||||
sub_02060044(fieldSystem, &encounter->setup->unk138);
|
||||
Encounter_GetResult(encounter);
|
||||
CallTask_RestoreOverworld(taskManager);
|
||||
(*state)++;
|
||||
break;
|
||||
case 4:
|
||||
CallTask_FadeFromBlack(taskManager);
|
||||
(*state)++;
|
||||
break;
|
||||
case 5:
|
||||
Encounter_Delete(encounter);
|
||||
return TRUE;
|
||||
case 0:
|
||||
sub_0204AEF8(taskManager, encounter->effect, encounter->bgm);
|
||||
(*state)++;
|
||||
break;
|
||||
case 1:
|
||||
sub_0204AF3C(taskManager);
|
||||
(*state)++;
|
||||
break;
|
||||
case 2:
|
||||
CallTask_StartBattle(taskManager, encounter->setup);
|
||||
(*state)++;
|
||||
break;
|
||||
case 3:
|
||||
sub_02047FA4(encounter->setup, fieldSystem);
|
||||
sub_02060044(fieldSystem, &encounter->setup->unk138);
|
||||
Encounter_GetResult(encounter);
|
||||
CallTask_RestoreOverworld(taskManager);
|
||||
(*state)++;
|
||||
break;
|
||||
case 4:
|
||||
CallTask_FadeFromBlack(taskManager);
|
||||
(*state)++;
|
||||
break;
|
||||
case 5:
|
||||
Encounter_Delete(encounter);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void CallTask_02046878(TaskManager *taskManager, BattleSetup *battleSetup, s32 effect, s32 bgm, u32 *winFlag) { //CallTask_02046878
|
||||
static void CallTask_02046878(TaskManager *taskManager, BattleSetup *battleSetup, s32 effect, s32 bgm, u32 *winFlag) { // CallTask_02046878
|
||||
Encounter *encounter = Encounter_New(battleSetup, effect, bgm, winFlag);
|
||||
TaskManager_Call(taskManager, Task_02046878, encounter);
|
||||
}
|
||||
|
|
@ -306,21 +309,21 @@ static void CallTask_02046878(TaskManager *taskManager, BattleSetup *battleSetup
|
|||
void sub_02046948(TaskManager *taskManager, u32 param1, u32 *winFlag) {
|
||||
FieldSystem *fieldSystem = TaskManager_GetFieldSystem(taskManager);
|
||||
BattleSetup *battleSetup = ov06_02244558(param1, fieldSystem);
|
||||
s32 effect = sub_020475A0(battleSetup);
|
||||
s32 bgm = sub_020475B0(battleSetup);
|
||||
s32 effect = sub_020475A0(battleSetup);
|
||||
s32 bgm = sub_020475B0(battleSetup);
|
||||
CallTask_02046878(taskManager, battleSetup, effect, bgm, winFlag);
|
||||
}
|
||||
|
||||
static WildEncounter *WildEncounter_New(BattleSetup *setup, s32 effect, s32 bgm, u32 *winFlag) {
|
||||
WildEncounter *encounter = AllocFromHeapAtEnd(HEAP_ID_FIELD, sizeof(WildEncounter));
|
||||
encounter->winFlag = winFlag;
|
||||
encounter->winFlag = winFlag;
|
||||
if (winFlag != NULL) {
|
||||
*winFlag = BATTLE_OUTCOME_NONE;
|
||||
}
|
||||
encounter->effect = effect;
|
||||
encounter->bgm = bgm;
|
||||
encounter->setup = setup;
|
||||
encounter->state = 0;
|
||||
encounter->bgm = bgm;
|
||||
encounter->setup = setup;
|
||||
encounter->state = 0;
|
||||
return encounter;
|
||||
}
|
||||
|
||||
|
|
@ -358,139 +361,139 @@ static BOOL Task_WildEncounter(TaskManager *taskManager) {
|
|||
WildEncounter *encounter = TaskManager_GetEnvironment(taskManager);
|
||||
|
||||
switch (encounter->state) {
|
||||
case 0:
|
||||
MapObjectManager_PauseAllMovement(fieldSystem->mapObjectManager);
|
||||
GameStats_Inc(Save_GameStats_Get(fieldSystem->saveData), GAME_STAT_UNK7);
|
||||
sub_0204AEF8(taskManager, encounter->effect, encounter->bgm);
|
||||
encounter->state++;
|
||||
break;
|
||||
case 1:
|
||||
sub_0204AF3C(taskManager);
|
||||
encounter->state++;
|
||||
break;
|
||||
case 2:
|
||||
CallTask_StartBattle(taskManager, encounter->setup);
|
||||
encounter->state++;
|
||||
break;
|
||||
case 3:
|
||||
sub_020465E4(encounter->setup, fieldSystem);
|
||||
sub_02061080(fieldSystem, encounter->setup->unk134, encounter->setup->winFlag);
|
||||
case 0:
|
||||
MapObjectManager_PauseAllMovement(fieldSystem->mapObjectManager);
|
||||
GameStats_Inc(Save_GameStats_Get(fieldSystem->saveData), GAME_STAT_UNK7);
|
||||
sub_0204AEF8(taskManager, encounter->effect, encounter->bgm);
|
||||
encounter->state++;
|
||||
break;
|
||||
case 1:
|
||||
sub_0204AF3C(taskManager);
|
||||
encounter->state++;
|
||||
break;
|
||||
case 2:
|
||||
CallTask_StartBattle(taskManager, encounter->setup);
|
||||
encounter->state++;
|
||||
break;
|
||||
case 3:
|
||||
sub_020465E4(encounter->setup, fieldSystem);
|
||||
sub_02061080(fieldSystem, encounter->setup->unk134, encounter->setup->winFlag);
|
||||
|
||||
if (IsBattleResultWin(encounter->setup->winFlag) == FALSE) {
|
||||
WildEncounter_Delete(encounter);
|
||||
sub_0205DD40(fieldSystem->unk90);
|
||||
TaskManager_Jump(taskManager, Task_Blackout, NULL);
|
||||
return FALSE;
|
||||
}
|
||||
if (IsBattleResultWin(encounter->setup->winFlag) == FALSE) {
|
||||
WildEncounter_Delete(encounter);
|
||||
sub_0205DD40(fieldSystem->unk90);
|
||||
TaskManager_Jump(taskManager, Task_Blackout, NULL);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (Save_VarsFlags_CheckHaveFollower(Save_VarsFlags_Get(fieldSystem->saveData))) {
|
||||
HealParty(SaveArray_Party_Get(fieldSystem->saveData));
|
||||
}
|
||||
if (Save_VarsFlags_CheckHaveFollower(Save_VarsFlags_Get(fieldSystem->saveData))) {
|
||||
HealParty(SaveArray_Party_Get(fieldSystem->saveData));
|
||||
}
|
||||
|
||||
sub_020472F4(fieldSystem, encounter->setup);
|
||||
sub_020473CC(fieldSystem, encounter->setup);
|
||||
|
||||
if (sub_0205E128(fieldSystem->unk90) != 0) {
|
||||
if (sub_0205E0A4(fieldSystem->unk90) != 0) {
|
||||
if (encounter->setup->winFlag != BATTLE_OUTCOME_WIN && encounter->setup->winFlag != BATTLE_OUTCOME_MON_CAUGHT) {
|
||||
sub_0205DD40(fieldSystem->unk90);
|
||||
}
|
||||
} else {
|
||||
sub_020472F4(fieldSystem, encounter->setup);
|
||||
sub_020473CC(fieldSystem, encounter->setup);
|
||||
|
||||
if (sub_0205E128(fieldSystem->unk90) != 0) {
|
||||
if (sub_0205E0A4(fieldSystem->unk90) != 0) {
|
||||
if (encounter->setup->winFlag != BATTLE_OUTCOME_WIN && encounter->setup->winFlag != BATTLE_OUTCOME_MON_CAUGHT) {
|
||||
sub_0205DD40(fieldSystem->unk90);
|
||||
}
|
||||
}
|
||||
CallTask_RestoreOverworld(taskManager);
|
||||
encounter->state++;
|
||||
break;
|
||||
case 4:
|
||||
ov06_02248724(fieldSystem, encounter->setup);
|
||||
CallTask_FadeFromBlack(taskManager);
|
||||
encounter->state++;
|
||||
break;
|
||||
case 5:
|
||||
if (sub_0205E128(fieldSystem->unk90) != 0) {
|
||||
sub_0205DED4(fieldSystem, encounter->setup->winFlag, fieldSystem->unk90);
|
||||
sub_0205DF44(fieldSystem, fieldSystem->unk90);
|
||||
} else {
|
||||
sub_0205DD40(fieldSystem->unk90);
|
||||
}
|
||||
encounter->state++;
|
||||
break;
|
||||
case 6:
|
||||
if (sub_0205DF9C(fieldSystem->unk90)) {
|
||||
MapObjectManager_UnpauseAllMovement(fieldSystem->mapObjectManager);
|
||||
WildEncounter_Delete(encounter);
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
CallTask_RestoreOverworld(taskManager);
|
||||
encounter->state++;
|
||||
break;
|
||||
case 4:
|
||||
ov06_02248724(fieldSystem, encounter->setup);
|
||||
CallTask_FadeFromBlack(taskManager);
|
||||
encounter->state++;
|
||||
break;
|
||||
case 5:
|
||||
if (sub_0205E128(fieldSystem->unk90) != 0) {
|
||||
sub_0205DED4(fieldSystem, encounter->setup->winFlag, fieldSystem->unk90);
|
||||
sub_0205DF44(fieldSystem, fieldSystem->unk90);
|
||||
}
|
||||
encounter->state++;
|
||||
break;
|
||||
case 6:
|
||||
if (sub_0205DF9C(fieldSystem->unk90)) {
|
||||
MapObjectManager_UnpauseAllMovement(fieldSystem->mapObjectManager);
|
||||
WildEncounter_Delete(encounter);
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static BOOL Task_SafariEncounter(TaskManager *taskManager) {
|
||||
FieldSystem *fieldSystem = TaskManager_GetFieldSystem(taskManager);
|
||||
Encounter *encounter = TaskManager_GetEnvironment(taskManager);
|
||||
u32 *state = TaskManager_GetStatePtr(taskManager);
|
||||
u16 *safariBalls = LocalFieldData_GetSafariBallsCounter(Save_LocalFieldData_Get(fieldSystem->saveData));
|
||||
Encounter *encounter = TaskManager_GetEnvironment(taskManager);
|
||||
u32 *state = TaskManager_GetStatePtr(taskManager);
|
||||
u16 *safariBalls = LocalFieldData_GetSafariBallsCounter(Save_LocalFieldData_Get(fieldSystem->saveData));
|
||||
|
||||
switch (*state) {
|
||||
case 0:
|
||||
MapObjectManager_PauseAllMovement(fieldSystem->mapObjectManager);
|
||||
GameStats_Inc(Save_GameStats_Get(fieldSystem->saveData), GAME_STAT_UNK7);
|
||||
sub_0204AEF8(taskManager, encounter->effect, encounter->bgm);
|
||||
(*state)++;
|
||||
break;
|
||||
case 1:
|
||||
sub_0204AF3C(taskManager);
|
||||
(*state)++;
|
||||
break;
|
||||
case 2:
|
||||
CallTask_StartBattle(taskManager, encounter->setup);
|
||||
(*state)++;
|
||||
break;
|
||||
case 3:
|
||||
sub_020465E4(encounter->setup, fieldSystem);
|
||||
case 0:
|
||||
MapObjectManager_PauseAllMovement(fieldSystem->mapObjectManager);
|
||||
GameStats_Inc(Save_GameStats_Get(fieldSystem->saveData), GAME_STAT_UNK7);
|
||||
sub_0204AEF8(taskManager, encounter->effect, encounter->bgm);
|
||||
(*state)++;
|
||||
break;
|
||||
case 1:
|
||||
sub_0204AF3C(taskManager);
|
||||
(*state)++;
|
||||
break;
|
||||
case 2:
|
||||
CallTask_StartBattle(taskManager, encounter->setup);
|
||||
(*state)++;
|
||||
break;
|
||||
case 3:
|
||||
sub_020465E4(encounter->setup, fieldSystem);
|
||||
if (encounter->setup->winFlag == BATTLE_OUTCOME_MON_CAUGHT) {
|
||||
SafariZone *safariZone = Save_SafariZone_Get(fieldSystem->saveData);
|
||||
Pokemon *pokemon = Party_GetMonByIndex(encounter->setup->party[BATTLER_ENEMY], 0);
|
||||
sub_02060FE0(safariZone, pokemon);
|
||||
}
|
||||
|
||||
sub_020472F4(fieldSystem, encounter->setup);
|
||||
|
||||
if (*safariBalls == 0 && encounter->setup->winFlag != BATTLE_OUTCOME_MON_CAUGHT) {
|
||||
Location *location = LocalFieldData_GetDynamicWarp(Save_LocalFieldData_Get(fieldSystem->saveData));
|
||||
sub_02049160(taskManager, location);
|
||||
}
|
||||
sub_020473CC(fieldSystem, encounter->setup);
|
||||
(*state)++;
|
||||
break;
|
||||
case 4:
|
||||
CallTask_RestoreOverworld(taskManager);
|
||||
(*state)++;
|
||||
break;
|
||||
case 5:
|
||||
MapObjectManager_UnpauseAllMovement(fieldSystem->mapObjectManager);
|
||||
CallTask_FadeFromBlack(taskManager);
|
||||
(*state)++;
|
||||
break;
|
||||
case 6:
|
||||
if (*safariBalls == 0) {
|
||||
if (encounter->setup->winFlag == BATTLE_OUTCOME_MON_CAUGHT) {
|
||||
SafariZone *safariZone = Save_SafariZone_Get(fieldSystem->saveData);
|
||||
Pokemon *pokemon = Party_GetMonByIndex(encounter->setup->party[BATTLER_ENEMY], 0);
|
||||
sub_02060FE0(safariZone, pokemon);
|
||||
}
|
||||
|
||||
sub_020472F4(fieldSystem, encounter->setup);
|
||||
|
||||
if (*safariBalls == 0 && encounter->setup->winFlag != BATTLE_OUTCOME_MON_CAUGHT) {
|
||||
Location *location = LocalFieldData_GetDynamicWarp(Save_LocalFieldData_Get(fieldSystem->saveData));
|
||||
sub_02049160(taskManager, location);
|
||||
}
|
||||
sub_020473CC(fieldSystem, encounter->setup);
|
||||
(*state)++;
|
||||
break;
|
||||
case 4:
|
||||
CallTask_RestoreOverworld(taskManager);
|
||||
(*state)++;
|
||||
break;
|
||||
case 5:
|
||||
MapObjectManager_UnpauseAllMovement(fieldSystem->mapObjectManager);
|
||||
CallTask_FadeFromBlack(taskManager);
|
||||
(*state)++;
|
||||
break;
|
||||
case 6:
|
||||
if (*safariBalls == 0) {
|
||||
if (encounter->setup->winFlag == BATTLE_OUTCOME_MON_CAUGHT) {
|
||||
QueueScript(taskManager, 0x2262, NULL, NULL);
|
||||
} else {
|
||||
QueueScript(taskManager, 0x2269, NULL, NULL);
|
||||
}
|
||||
QueueScript(taskManager, 0x2262, NULL, NULL);
|
||||
} else {
|
||||
PCStorage *pc = SaveArray_PCStorage_Get(fieldSystem->saveData);
|
||||
Party *party = SaveArray_Party_Get(fieldSystem->saveData);
|
||||
if (PCStorage_FindFirstBoxWithEmptySlot(pc) == NUM_BOXES && Party_GetCount(party) == PARTY_SIZE) {
|
||||
QueueScript(taskManager, 0x2276, NULL, NULL);
|
||||
}
|
||||
QueueScript(taskManager, 0x2269, NULL, NULL);
|
||||
}
|
||||
(*state)++;
|
||||
break;
|
||||
case 7:
|
||||
Encounter_Delete(encounter);
|
||||
return TRUE;
|
||||
} else {
|
||||
PCStorage *pc = SaveArray_PCStorage_Get(fieldSystem->saveData);
|
||||
Party *party = SaveArray_Party_Get(fieldSystem->saveData);
|
||||
if (PCStorage_FindFirstBoxWithEmptySlot(pc) == NUM_BOXES && Party_GetCount(party) == PARTY_SIZE) {
|
||||
QueueScript(taskManager, 0x2276, NULL, NULL);
|
||||
}
|
||||
}
|
||||
(*state)++;
|
||||
break;
|
||||
case 7:
|
||||
Encounter_Delete(encounter);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
|
@ -529,46 +532,46 @@ void SetupAndStartWildBattle(TaskManager *taskManager, u16 species, u8 level, u3
|
|||
|
||||
static BOOL Task_PalParkEncounter(TaskManager *taskManager) {
|
||||
FieldSystem *fieldSystem = TaskManager_GetFieldSystem(taskManager);
|
||||
Encounter *encounter = TaskManager_GetEnvironment(taskManager);
|
||||
u32 *state = TaskManager_GetStatePtr(taskManager);
|
||||
Encounter *encounter = TaskManager_GetEnvironment(taskManager);
|
||||
u32 *state = TaskManager_GetStatePtr(taskManager);
|
||||
|
||||
switch (*state) {
|
||||
case 0:
|
||||
MapObjectManager_PauseAllMovement(fieldSystem->mapObjectManager);
|
||||
GameStats_Inc(Save_GameStats_Get(fieldSystem->saveData), GAME_STAT_UNK7);
|
||||
sub_0204AEF8(taskManager, encounter->effect, encounter->bgm);
|
||||
(*state)++;
|
||||
break;
|
||||
case 1:
|
||||
sub_0204AF3C(taskManager);
|
||||
(*state)++;
|
||||
break;
|
||||
case 2:
|
||||
CallTask_StartBattle(taskManager, encounter->setup);
|
||||
(*state)++;
|
||||
break;
|
||||
case 3:
|
||||
sub_020465E4(encounter->setup, fieldSystem);
|
||||
PalPark_HandleBattleEnd(fieldSystem, encounter->setup);
|
||||
sub_020472F4(fieldSystem, encounter->setup);
|
||||
(*state)++;
|
||||
break;
|
||||
case 4:
|
||||
CallTask_RestoreOverworld(taskManager);
|
||||
(*state)++;
|
||||
break;
|
||||
case 5:
|
||||
MapObjectManager_UnpauseAllMovement(fieldSystem->mapObjectManager);
|
||||
CallTask_FadeFromBlack(taskManager);
|
||||
(*state)++;
|
||||
break;
|
||||
case 6:
|
||||
Encounter_Delete(encounter);
|
||||
if (PalPark_CountMonsNotCaught(fieldSystem) == 0) {
|
||||
StartScriptFromMenu(taskManager, 3, NULL);
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
case 0:
|
||||
MapObjectManager_PauseAllMovement(fieldSystem->mapObjectManager);
|
||||
GameStats_Inc(Save_GameStats_Get(fieldSystem->saveData), GAME_STAT_UNK7);
|
||||
sub_0204AEF8(taskManager, encounter->effect, encounter->bgm);
|
||||
(*state)++;
|
||||
break;
|
||||
case 1:
|
||||
sub_0204AF3C(taskManager);
|
||||
(*state)++;
|
||||
break;
|
||||
case 2:
|
||||
CallTask_StartBattle(taskManager, encounter->setup);
|
||||
(*state)++;
|
||||
break;
|
||||
case 3:
|
||||
sub_020465E4(encounter->setup, fieldSystem);
|
||||
PalPark_HandleBattleEnd(fieldSystem, encounter->setup);
|
||||
sub_020472F4(fieldSystem, encounter->setup);
|
||||
(*state)++;
|
||||
break;
|
||||
case 4:
|
||||
CallTask_RestoreOverworld(taskManager);
|
||||
(*state)++;
|
||||
break;
|
||||
case 5:
|
||||
MapObjectManager_UnpauseAllMovement(fieldSystem->mapObjectManager);
|
||||
CallTask_FadeFromBlack(taskManager);
|
||||
(*state)++;
|
||||
break;
|
||||
case 6:
|
||||
Encounter_Delete(encounter);
|
||||
if (PalPark_CountMonsNotCaught(fieldSystem) == 0) {
|
||||
StartScriptFromMenu(taskManager, 3, NULL);
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
|
@ -581,52 +584,52 @@ void sub_02046F70(FieldSystem *fieldSystem, BattleSetup *setup) {
|
|||
|
||||
void SetupAndStartFirstBattle(TaskManager *taskManager, u16 species, u8 level) {
|
||||
FieldSystem *fieldSystem = TaskManager_GetFieldSystem(taskManager);
|
||||
BattleSetup *setup = BattleSetup_New(HEAP_ID_FIELD, BATTLE_TYPE_NONE);
|
||||
BattleSetup *setup = BattleSetup_New(HEAP_ID_FIELD, BATTLE_TYPE_NONE);
|
||||
BattleSetup_InitFromFieldSystem(setup, fieldSystem);
|
||||
|
||||
ov06_0223CD7C(fieldSystem, species, level, setup);
|
||||
|
||||
setup->unk18C = 1;
|
||||
|
||||
GameStats_Inc(Save_GameStats_Get(fieldSystem->saveData), GAME_STAT_UNK7);
|
||||
GameStats_Inc(Save_GameStats_Get(fieldSystem->saveData), GAME_STAT_UNK7);
|
||||
|
||||
CallTask_StartEncounter(taskManager, setup, sub_020475A0(setup), sub_020475B0(setup), NULL);
|
||||
}
|
||||
|
||||
static BOOL Task_TutorialBattle(TaskManager *taskManager) {
|
||||
Encounter *encounter = TaskManager_GetEnvironment(taskManager);
|
||||
Encounter *encounter = TaskManager_GetEnvironment(taskManager);
|
||||
FieldSystem *fieldSystem = TaskManager_GetFieldSystem(taskManager);
|
||||
u32 *state = TaskManager_GetStatePtr(taskManager);
|
||||
u32 *state = TaskManager_GetStatePtr(taskManager);
|
||||
|
||||
switch (*state) {
|
||||
case 0:
|
||||
MapObjectManager_PauseAllMovement(fieldSystem->mapObjectManager);
|
||||
sub_0204AEF8(taskManager, encounter->effect, encounter->bgm);
|
||||
(*state)++;
|
||||
break;
|
||||
case 1:
|
||||
sub_0204AF3C(taskManager);
|
||||
(*state)++;
|
||||
break;
|
||||
case 2:
|
||||
CallTask_StartBattle(taskManager, encounter->setup);
|
||||
(*state)++;
|
||||
break;
|
||||
case 3:
|
||||
(*state)++;
|
||||
break;
|
||||
case 4:
|
||||
CallTask_RestoreOverworld(taskManager);
|
||||
(*state)++;
|
||||
break;
|
||||
case 5:
|
||||
MapObjectManager_UnpauseAllMovement(fieldSystem->mapObjectManager);
|
||||
CallTask_FadeFromBlack(taskManager);
|
||||
(*state)++;
|
||||
break;
|
||||
case 6:
|
||||
Encounter_Delete(encounter);
|
||||
return TRUE;
|
||||
case 0:
|
||||
MapObjectManager_PauseAllMovement(fieldSystem->mapObjectManager);
|
||||
sub_0204AEF8(taskManager, encounter->effect, encounter->bgm);
|
||||
(*state)++;
|
||||
break;
|
||||
case 1:
|
||||
sub_0204AF3C(taskManager);
|
||||
(*state)++;
|
||||
break;
|
||||
case 2:
|
||||
CallTask_StartBattle(taskManager, encounter->setup);
|
||||
(*state)++;
|
||||
break;
|
||||
case 3:
|
||||
(*state)++;
|
||||
break;
|
||||
case 4:
|
||||
CallTask_RestoreOverworld(taskManager);
|
||||
(*state)++;
|
||||
break;
|
||||
case 5:
|
||||
MapObjectManager_UnpauseAllMovement(fieldSystem->mapObjectManager);
|
||||
CallTask_FadeFromBlack(taskManager);
|
||||
(*state)++;
|
||||
break;
|
||||
case 6:
|
||||
Encounter_Delete(encounter);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
|
@ -635,8 +638,8 @@ void SetupAndStartTutorialBattle(TaskManager *taskManager) {
|
|||
Encounter *encounter;
|
||||
BattleSetup *setup;
|
||||
FieldSystem *fieldSystem = TaskManager_GetFieldSystem(taskManager);
|
||||
|
||||
setup = sub_02047814(HEAP_ID_FIELD, fieldSystem);
|
||||
|
||||
setup = sub_02047814(HEAP_ID_FIELD, fieldSystem);
|
||||
encounter = Encounter_New(setup, sub_020475A0(setup), sub_020475B0(setup), NULL);
|
||||
|
||||
TaskManager_Call(taskManager, Task_TutorialBattle, encounter);
|
||||
|
|
@ -646,7 +649,7 @@ void SetupAndStartTrainerBattle(TaskManager *taskManager, u32 opponentTrainer1,
|
|||
u32 battleType;
|
||||
BattleSetup *setup;
|
||||
FieldSystem *fieldSystem = TaskManager_GetFieldSystem(taskManager);
|
||||
|
||||
|
||||
if (opponentTrainer2 != 0 && opponentTrainer1 != opponentTrainer2) {
|
||||
if (followerTrainerNum == 0) {
|
||||
battleType = (BATTLE_TYPE_TRAINER | BATTLE_TYPE_DOUBLES | BATTLE_TYPE_INGAME_PARTNER);
|
||||
|
|
@ -663,14 +666,14 @@ void SetupAndStartTrainerBattle(TaskManager *taskManager, u32 opponentTrainer1,
|
|||
setup = BattleSetup_New(HEAP_ID_FIELD, battleType);
|
||||
BattleSetup_InitFromFieldSystem(setup, fieldSystem);
|
||||
|
||||
setup->trainerId[BATTLER_ENEMY] = opponentTrainer1;
|
||||
setup->trainerId[BATTLER_ENEMY2] = opponentTrainer2;
|
||||
setup->trainerId[BATTLER_ENEMY] = opponentTrainer1;
|
||||
setup->trainerId[BATTLER_ENEMY2] = opponentTrainer2;
|
||||
setup->trainerId[BATTLER_PLAYER2] = followerTrainerNum;
|
||||
|
||||
EnemyTrainerSet_Init(setup, fieldSystem->saveData, heapId);
|
||||
|
||||
GameStats_Inc(Save_GameStats_Get(fieldSystem->saveData), GAME_STAT_UNK8);
|
||||
|
||||
|
||||
CallTask_StartEncounter(taskManager, setup, sub_020475A0(setup), sub_020475B0(setup), winFlag);
|
||||
}
|
||||
|
||||
|
|
@ -694,14 +697,14 @@ void sub_020471C0(TaskManager *taskManager, s32 target, s32 maxLevel, u32 flag)
|
|||
BattleSetup *setup;
|
||||
|
||||
if (flag != 0) {
|
||||
setup = BattleSetup_New(HEAP_ID_FIELD, (BATTLE_TYPE_LINK | BATTLE_TYPE_TRAINER));
|
||||
setup = BattleSetup_New(HEAP_ID_FIELD, BATTLE_TYPE_LINK | BATTLE_TYPE_TRAINER);
|
||||
} else {
|
||||
setup = BattleSetup_New(HEAP_ID_FIELD, (BATTLE_TYPE_LINK | BATTLE_TYPE_DOUBLES | BATTLE_TYPE_TRAINER));
|
||||
setup = BattleSetup_New(HEAP_ID_FIELD, BATTLE_TYPE_LINK | BATTLE_TYPE_DOUBLES | BATTLE_TYPE_TRAINER);
|
||||
}
|
||||
|
||||
sub_02047BC0(setup, fieldSystem, maxLevel);
|
||||
|
||||
encounter = Encounter_New(setup, sub_020475A0(setup), sub_020475B0(setup), NULL);
|
||||
encounter = Encounter_New(setup, sub_020475A0(setup), sub_020475B0(setup), NULL);
|
||||
encounter->unkC = target;
|
||||
|
||||
TaskManager_Call(taskManager, Task_020467FC, encounter);
|
||||
|
|
@ -709,17 +712,17 @@ void sub_020471C0(TaskManager *taskManager, s32 target, s32 maxLevel, u32 flag)
|
|||
|
||||
static BOOL sub_02047220(TaskManager *taskManager) {
|
||||
FieldSystem *fieldSystem = TaskManager_GetFieldSystem(taskManager);
|
||||
Encounter *encounter = TaskManager_GetEnvironment(taskManager);
|
||||
u32 *state = TaskManager_GetStatePtr(taskManager);
|
||||
Encounter *encounter = TaskManager_GetEnvironment(taskManager);
|
||||
u32 *state = TaskManager_GetStatePtr(taskManager);
|
||||
|
||||
switch (*state) {
|
||||
case 0:
|
||||
TaskManager_Call(taskManager, Task_02046758, encounter);
|
||||
(*state)++;
|
||||
break;
|
||||
case 1:
|
||||
sub_0204FF5C(fieldSystem);
|
||||
return TRUE;
|
||||
case 0:
|
||||
TaskManager_Call(taskManager, Task_02046758, encounter);
|
||||
(*state)++;
|
||||
break;
|
||||
case 1:
|
||||
sub_0204FF5C(fieldSystem);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
|
@ -749,12 +752,12 @@ void sub_020472B0(FieldSystem *fieldSystem, Party *party, s32 battleType) {
|
|||
static void sub_020472F4(FieldSystem *fieldSystem, BattleSetup *setup) {
|
||||
Pokemon *mon;
|
||||
u32 battleType = setup->flags;
|
||||
u32 winFlag = setup->winFlag;
|
||||
u32 winFlag = setup->winFlag;
|
||||
|
||||
if (battleType & BATTLE_TYPE_LINK || battleType & BATTLE_TYPE_TOWER) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (battleType == BATTLE_TYPE_NONE || battleType == BATTLE_TYPE_8 || battleType == (BATTLE_TYPE_DOUBLES | BATTLE_TYPE_MULTI | BATTLE_TYPE_6)) {
|
||||
if (winFlag == BATTLE_OUTCOME_WIN) {
|
||||
GameStats_AddSpecial(Save_GameStats_Get(fieldSystem->saveData), GAME_STAT_UNK8);
|
||||
|
|
@ -783,7 +786,7 @@ static void sub_020472F4(FieldSystem *fieldSystem, BattleSetup *setup) {
|
|||
static void sub_020473CC(FieldSystem *fieldSystem, BattleSetup *setup) {
|
||||
Pokemon *mon;
|
||||
u32 battleType = setup->flags;
|
||||
u32 winFlag = setup->winFlag;
|
||||
u32 winFlag = setup->winFlag;
|
||||
|
||||
if (battleType & BATTLE_TYPE_LINK || battleType & BATTLE_TYPE_TOWER || battleType & BATTLE_TYPE_PAL_PARK) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#include "global.h"
|
||||
#include "error_handling.h"
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "error_message_reset.h"
|
||||
#include "unk_02031734.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,67 +1,71 @@
|
|||
#include "global.h"
|
||||
#include "error_message_reset.h"
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "constants/rgb.h"
|
||||
#include "gf_gfx_planes.h"
|
||||
#include "gx.h"
|
||||
#include "heap.h"
|
||||
#include "unk_02031734.h"
|
||||
#include "unk_0202F150.h"
|
||||
#include "bg_window.h"
|
||||
#include "PAD_pad.h"
|
||||
#include "font.h"
|
||||
#include "brightness.h"
|
||||
#include "render_window.h"
|
||||
|
||||
#include "msgdata/msg.naix"
|
||||
#include "msgdata/msg/narc_0200.h"
|
||||
|
||||
#include "PAD_pad.h"
|
||||
#include "bg_window.h"
|
||||
#include "brightness.h"
|
||||
#include "font.h"
|
||||
#include "gf_gfx_planes.h"
|
||||
#include "gx.h"
|
||||
#include "heap.h"
|
||||
#include "render_window.h"
|
||||
#include "unk_0202F150.h"
|
||||
#include "unk_02031734.h"
|
||||
|
||||
static const struct WindowTemplate sErrorMessageWindowTemplate = {
|
||||
.bgId = GF_BG_LYR_MAIN_0,
|
||||
.left = 3,
|
||||
.top = 3,
|
||||
.width = 26,
|
||||
.height = 18,
|
||||
.palette = 1,
|
||||
.bgId = GF_BG_LYR_MAIN_0,
|
||||
.left = 3,
|
||||
.top = 3,
|
||||
.width = 26,
|
||||
.height = 18,
|
||||
.palette = 1,
|
||||
.baseTile = 0x23
|
||||
};
|
||||
|
||||
static const struct HeapParam sErrorMessageHeapParams = {
|
||||
.size = 0x00020000,
|
||||
.size = 0x00020000,
|
||||
.arena = OS_ARENA_MAIN
|
||||
};
|
||||
|
||||
static const struct GraphicsModes sErrorMessageBgModeSet = {
|
||||
.dispMode = GX_DISPMODE_GRAPHICS,
|
||||
.bgMode = GX_BGMODE_0,
|
||||
.subMode = GX_BGMODE_0,
|
||||
.dispMode = GX_DISPMODE_GRAPHICS,
|
||||
.bgMode = GX_BGMODE_0,
|
||||
.subMode = GX_BGMODE_0,
|
||||
._2d3dMode = GX_BG0_AS_2D
|
||||
};
|
||||
|
||||
static const struct BgTemplate sErrorMessageBgTemplate = {
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.bufferSize = 0x800,
|
||||
.baseTile = 0,
|
||||
.size = GF_BG_SCR_SIZE_256x256,
|
||||
.colorMode = GX_BG_COLORMODE_16,
|
||||
.baseTile = 0,
|
||||
.size = GF_BG_SCR_SIZE_256x256,
|
||||
.colorMode = GX_BG_COLORMODE_16,
|
||||
.screenBase = GX_BG_SCRBASE_0x0000,
|
||||
.charBase = GX_BG_CHARBASE_0x18000,
|
||||
.bgExtPltt = GX_BG_EXTPLTT_01,
|
||||
.priority = 1,
|
||||
.areaOver = GX_BG_AREAOVER_XLU,
|
||||
.mosaic = FALSE
|
||||
.charBase = GX_BG_CHARBASE_0x18000,
|
||||
.bgExtPltt = GX_BG_EXTPLTT_01,
|
||||
.priority = 1,
|
||||
.areaOver = GX_BG_AREAOVER_XLU,
|
||||
.mosaic = FALSE
|
||||
};
|
||||
|
||||
static const struct GraphicsBanks sErrorMessageBanksConfig = {
|
||||
.bg = GX_VRAM_BG_256_AB,
|
||||
.bgextpltt = GX_VRAM_BGEXTPLTT_NONE,
|
||||
.subbg = GX_VRAM_SUB_BG_NONE,
|
||||
.subbgextpltt = GX_VRAM_SUB_BGEXTPLTT_NONE,
|
||||
.obj = GX_VRAM_OBJ_NONE,
|
||||
.objextpltt = GX_VRAM_OBJEXTPLTT_NONE,
|
||||
.subobj = GX_VRAM_SUB_OBJ_NONE,
|
||||
.bg = GX_VRAM_BG_256_AB,
|
||||
.bgextpltt = GX_VRAM_BGEXTPLTT_NONE,
|
||||
.subbg = GX_VRAM_SUB_BG_NONE,
|
||||
.subbgextpltt = GX_VRAM_SUB_BGEXTPLTT_NONE,
|
||||
.obj = GX_VRAM_OBJ_NONE,
|
||||
.objextpltt = GX_VRAM_OBJEXTPLTT_NONE,
|
||||
.subobj = GX_VRAM_SUB_OBJ_NONE,
|
||||
.subobjextpltt = GX_VRAM_SUB_OBJEXTPLTT_NONE,
|
||||
.tex = GX_VRAM_TEX_NONE,
|
||||
.texpltt = GX_VRAM_TEXPLTT_NONE,
|
||||
.tex = GX_VRAM_TEX_NONE,
|
||||
.texpltt = GX_VRAM_TEXPLTT_NONE,
|
||||
};
|
||||
|
||||
static u32 sErrorMessagePrinterLock;
|
||||
|
|
@ -69,20 +73,17 @@ static u32 sErrorMessagePrinterLock;
|
|||
extern void sub_0200E3A0(PMLCDTarget, int);
|
||||
extern void SetMasterBrightnessNeutral(u32 screen);
|
||||
|
||||
void VBlankHandler()
|
||||
{
|
||||
void VBlankHandler() {
|
||||
OS_SetIrqCheckFlag(OS_IE_VBLANK);
|
||||
MI_WaitDma(GX_DEFAULT_DMAID);
|
||||
}
|
||||
|
||||
void PrintErrorMessageAndReset()
|
||||
{
|
||||
void PrintErrorMessageAndReset() {
|
||||
|
||||
struct BgConfig *ptr;
|
||||
struct Window buf;
|
||||
|
||||
if (sErrorMessagePrinterLock != TRUE)
|
||||
{
|
||||
if (sErrorMessagePrinterLock != TRUE) {
|
||||
sErrorMessagePrinterLock = TRUE;
|
||||
OS_SetArenaHi(OS_ARENA_MAIN, OS_GetInitArenaHi(OS_ARENA_MAIN));
|
||||
OS_SetArenaLo(OS_ARENA_MAIN, OS_GetInitArenaLo(OS_ARENA_MAIN));
|
||||
|
|
@ -130,14 +131,14 @@ void PrintErrorMessageAndReset()
|
|||
BG_SetMaskColor(GF_BG_LYR_SUB_0, RGB(1, 1, 27));
|
||||
|
||||
struct MsgData *msg_data = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0200_bin, HEAP_ID_DEFAULT);
|
||||
struct String *str = String_New(6 << 6, HEAP_ID_DEFAULT);
|
||||
struct String *str = String_New(6 << 6, HEAP_ID_DEFAULT);
|
||||
|
||||
ResetAllTextPrinters();
|
||||
AddWindow(ptr, &buf, &sErrorMessageWindowTemplate);
|
||||
FillWindowPixelRect(&buf, 15, 0, 0, 0xd0, 0x90);
|
||||
DrawFrameAndWindow1(&buf, FALSE, 0x1f7, 2);
|
||||
|
||||
ReadMsgDataIntoString(msg_data, narc_0200_00003, str); //A communication error has occurred. You will be returned to the title screen...
|
||||
ReadMsgDataIntoString(msg_data, narc_0200_00003, str); // A communication error has occurred. You will be returned to the title screen...
|
||||
|
||||
AddTextPrinterParameterized(&buf, 0, str, 0, 0, 0, NULL);
|
||||
|
||||
|
|
@ -148,20 +149,20 @@ void PrintErrorMessageAndReset()
|
|||
SetBlendBrightness(0, (GXBlendPlaneMask)(GX_BLEND_PLANEMASK_BD | GX_BLEND_PLANEMASK_OBJ | GX_BLEND_PLANEMASK_BG3 | GX_BLEND_PLANEMASK_BG2 | GX_BLEND_PLANEMASK_BG1 | GX_BLEND_PLANEMASK_BG0), SCREEN_MASK_MAIN | SCREEN_MASK_SUB);
|
||||
sub_02032DAC();
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
while (TRUE) {
|
||||
HandleDSLidAction();
|
||||
sub_0202FB80();
|
||||
if (sub_02033678())
|
||||
if (sub_02033678()) {
|
||||
break;
|
||||
}
|
||||
OS_WaitIrq(TRUE, OS_IE_VBLANK);
|
||||
}
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
while (TRUE) {
|
||||
HandleDSLidAction();
|
||||
if ((PAD_Read() & PAD_BUTTON_A))
|
||||
if (PAD_Read() & PAD_BUTTON_A) {
|
||||
break;
|
||||
}
|
||||
OS_WaitIrq(TRUE, OS_IE_VBLANK);
|
||||
}
|
||||
sub_0200E3A0(PM_LCD_TOP, 0x7FFF);
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,9 +1,11 @@
|
|||
#include "global.h"
|
||||
#include "FS_file.h"
|
||||
#include "heap.h"
|
||||
#include "filesystem.h"
|
||||
|
||||
static char * sNarcFileList[] = {
|
||||
#include "global.h"
|
||||
|
||||
#include "FS_file.h"
|
||||
#include "heap.h"
|
||||
|
||||
static char *sNarcFileList[] = {
|
||||
"battle/skill/waza_seq.narc",
|
||||
"battle/skill/sub_seq.narc",
|
||||
#ifdef PEARL
|
||||
|
|
@ -156,15 +158,14 @@ static char * sNarcFileList[] = {
|
|||
"poketool/shinzukan.narc",
|
||||
};
|
||||
|
||||
void ReadFromNarcMemberByPathAndId(void * dest, const char * path, s32 file_idx, u32 offset, u32 size)
|
||||
{
|
||||
void ReadFromNarcMemberByPathAndId(void *dest, const char *path, s32 file_idx, u32 offset, u32 size) {
|
||||
FSFile file;
|
||||
register u32 chunk_starts[3];
|
||||
u32 btnf_size = 0;
|
||||
u32 btnf_size = 0;
|
||||
u32 chunk_size = 0;
|
||||
u32 file_start = 0;
|
||||
u32 file_end = 0;
|
||||
u16 num_files = 0;
|
||||
u32 file_end = 0;
|
||||
u16 num_files = 0;
|
||||
|
||||
FS_InitFile(&file);
|
||||
FS_OpenFile(&file, path);
|
||||
|
|
@ -185,25 +186,25 @@ void ReadFromNarcMemberByPathAndId(void * dest, const char * path, s32 file_idx,
|
|||
FS_ReadFile(&file, &file_end, 4);
|
||||
chunk_starts[2] = chunk_starts[1] + btnf_size;
|
||||
FS_SeekFile(&file, (s32)(chunk_starts[2] + 8 + file_start + offset), FS_SEEK_SET);
|
||||
if (size == 0)
|
||||
if (size == 0) {
|
||||
chunk_size = file_end - file_start;
|
||||
else
|
||||
} else {
|
||||
chunk_size = size;
|
||||
}
|
||||
GF_ASSERT(chunk_size != 0);
|
||||
FS_ReadFile(&file, dest, (s32)chunk_size);
|
||||
FS_CloseFile(&file);
|
||||
}
|
||||
|
||||
void * AllocAndReadFromNarcMemberByPathAndId(const char * path, s32 file_idx, HeapID heapId, u32 offset, u32 size, BOOL r4)
|
||||
{
|
||||
void *AllocAndReadFromNarcMemberByPathAndId(const char *path, s32 file_idx, HeapID heapId, u32 offset, u32 size, BOOL r4) {
|
||||
FSFile file;
|
||||
register u32 chunk_starts[3];
|
||||
u32 btnf_size = 0;
|
||||
u32 btnf_size = 0;
|
||||
u32 chunk_size = 0;
|
||||
u32 file_start = 0;
|
||||
u32 file_end = 0;
|
||||
u16 num_files = 0;
|
||||
void * dest = NULL;
|
||||
u32 file_end = 0;
|
||||
u16 num_files = 0;
|
||||
void *dest = NULL;
|
||||
|
||||
FS_InitFile(&file);
|
||||
FS_OpenFile(&file, path);
|
||||
|
|
@ -224,13 +225,13 @@ void * AllocAndReadFromNarcMemberByPathAndId(const char * path, s32 file_idx, He
|
|||
FS_ReadFile(&file, &file_end, 4);
|
||||
chunk_starts[2] = chunk_starts[1] + btnf_size;
|
||||
FS_SeekFile(&file, (s32)(chunk_starts[2] + 8 + file_start + offset), FS_SEEK_SET);
|
||||
if (size == 0)
|
||||
if (size == 0) {
|
||||
chunk_size = file_end - file_start;
|
||||
else
|
||||
} else {
|
||||
chunk_size = size;
|
||||
}
|
||||
GF_ASSERT(chunk_size != 0);
|
||||
switch (r4)
|
||||
{
|
||||
switch (r4) {
|
||||
case 0:
|
||||
dest = AllocFromHeap(heapId, chunk_size);
|
||||
break;
|
||||
|
|
@ -243,45 +244,38 @@ void * AllocAndReadFromNarcMemberByPathAndId(const char * path, s32 file_idx, He
|
|||
return dest;
|
||||
}
|
||||
|
||||
void ReadWholeNarcMemberByIdPair(void * dest, NarcId narc_id, s32 file_id)
|
||||
{
|
||||
void ReadWholeNarcMemberByIdPair(void *dest, NarcId narc_id, s32 file_id) {
|
||||
ReadFromNarcMemberByPathAndId(dest, sNarcFileList[narc_id], file_id, 0, 0);
|
||||
}
|
||||
|
||||
void * AllocAndReadWholeNarcMemberByIdPair(NarcId narc_id, s32 file_id, HeapID heapId)
|
||||
{
|
||||
void *AllocAndReadWholeNarcMemberByIdPair(NarcId narc_id, s32 file_id, HeapID heapId) {
|
||||
return AllocAndReadFromNarcMemberByPathAndId(sNarcFileList[narc_id], file_id, heapId, 0, 0, FALSE);
|
||||
}
|
||||
|
||||
void * AllocAtEndAndReadWholeNarcMemberByIdPair(NarcId narc_id, s32 file_id, HeapID heapId)
|
||||
{
|
||||
void *AllocAtEndAndReadWholeNarcMemberByIdPair(NarcId narc_id, s32 file_id, HeapID heapId) {
|
||||
return AllocAndReadFromNarcMemberByPathAndId(sNarcFileList[narc_id], file_id, heapId, 0, 0, TRUE);
|
||||
}
|
||||
|
||||
void ReadFromNarcMemberByIdPair(void * dest, NarcId narc_id, s32 file_id, u32 offset, u32 size)
|
||||
{
|
||||
void ReadFromNarcMemberByIdPair(void *dest, NarcId narc_id, s32 file_id, u32 offset, u32 size) {
|
||||
ReadFromNarcMemberByPathAndId(dest, sNarcFileList[narc_id], file_id, offset, size);
|
||||
}
|
||||
|
||||
void * AllocAndReadFromNarcMemberByIdPair(NarcId narc_id, s32 file_id, HeapID heapId, u32 offset, u32 size)
|
||||
{
|
||||
void *AllocAndReadFromNarcMemberByIdPair(NarcId narc_id, s32 file_id, HeapID heapId, u32 offset, u32 size) {
|
||||
return AllocAndReadFromNarcMemberByPathAndId(sNarcFileList[narc_id], file_id, heapId, offset, size, FALSE);
|
||||
}
|
||||
|
||||
void * AllocAtEndAndReadFromNarcMemberByIdPair(NarcId narc_id, s32 file_id, HeapID heapId, u32 offset, u32 size)
|
||||
{
|
||||
void *AllocAtEndAndReadFromNarcMemberByIdPair(NarcId narc_id, s32 file_id, HeapID heapId, u32 offset, u32 size) {
|
||||
return AllocAndReadFromNarcMemberByPathAndId(sNarcFileList[narc_id], file_id, heapId, offset, size, TRUE);
|
||||
}
|
||||
|
||||
u32 GetNarcMemberSizeByIdPair(NarcId narc_id, s32 file_idx)
|
||||
{
|
||||
u32 GetNarcMemberSizeByIdPair(NarcId narc_id, s32 file_idx) {
|
||||
FSFile file;
|
||||
register u32 chunk_starts[3];
|
||||
u32 btnf_size = 0;
|
||||
u32 btnf_size = 0;
|
||||
u32 chunk_size = 0;
|
||||
u32 file_start = 0;
|
||||
u32 file_end = 0;
|
||||
u16 num_files = 0;
|
||||
u32 file_end = 0;
|
||||
u16 num_files = 0;
|
||||
|
||||
FS_InitFile(&file);
|
||||
FS_OpenFile(&file, sNarcFileList[narc_id]);
|
||||
|
|
@ -308,13 +302,11 @@ u32 GetNarcMemberSizeByIdPair(NarcId narc_id, s32 file_idx)
|
|||
return chunk_size;
|
||||
}
|
||||
|
||||
NARC * NARC_New(NarcId narc_id, HeapID heapId)
|
||||
{
|
||||
NARC * narc = (NARC *)AllocFromHeap(heapId, sizeof(NARC));
|
||||
NARC *NARC_New(NarcId narc_id, HeapID heapId) {
|
||||
NARC *narc = (NARC *)AllocFromHeap(heapId, sizeof(NARC));
|
||||
u32 btnf_start;
|
||||
u32 chunk_size;
|
||||
if (narc != NULL)
|
||||
{
|
||||
if (narc != NULL) {
|
||||
narc->btaf_start = 0;
|
||||
FS_InitFile(&narc->file);
|
||||
FS_OpenFile(&narc->file, sNarcFileList[narc_id]);
|
||||
|
|
@ -331,32 +323,28 @@ NARC * NARC_New(NarcId narc_id, HeapID heapId)
|
|||
return narc;
|
||||
}
|
||||
|
||||
void NARC_Delete(NARC * narc)
|
||||
{
|
||||
void NARC_Delete(NARC *narc) {
|
||||
FS_CloseFile(&narc->file);
|
||||
FreeToHeap(narc); // free to heap
|
||||
}
|
||||
|
||||
void * NARC_AllocAndReadWholeMember(NARC * narc, u32 file_id, HeapID heapId)
|
||||
{
|
||||
void *NARC_AllocAndReadWholeMember(NARC *narc, u32 file_id, HeapID heapId) {
|
||||
u32 file_start;
|
||||
u32 file_end;
|
||||
void * dest;
|
||||
void *dest;
|
||||
GF_ASSERT(narc->num_files > file_id);
|
||||
FS_SeekFile(&narc->file, (s32)(narc->btaf_start + 12 + 8 * file_id), FS_SEEK_SET);
|
||||
FS_ReadFile(&narc->file, &file_start, 4);
|
||||
FS_ReadFile(&narc->file, &file_end, 4);
|
||||
FS_SeekFile(&narc->file, (s32)(narc->gmif_start + 8 + file_start), FS_SEEK_SET);
|
||||
dest = AllocFromHeap(heapId, file_end - file_start);
|
||||
if (dest != NULL)
|
||||
{
|
||||
if (dest != NULL) {
|
||||
FS_ReadFile(&narc->file, dest, (s32)(file_end - file_start));
|
||||
}
|
||||
return dest;
|
||||
}
|
||||
|
||||
void NARC_ReadWholeMember(NARC * narc, u32 file_id, void * dest)
|
||||
{
|
||||
void NARC_ReadWholeMember(NARC *narc, u32 file_id, void *dest) {
|
||||
u32 file_start;
|
||||
u32 file_end;
|
||||
GF_ASSERT(narc->num_files > file_id);
|
||||
|
|
@ -367,8 +355,7 @@ void NARC_ReadWholeMember(NARC * narc, u32 file_id, void * dest)
|
|||
FS_ReadFile(&narc->file, dest, (s32)(file_end - file_start));
|
||||
}
|
||||
|
||||
u32 NARC_GetMemberSize(NARC * narc, u32 file_id)
|
||||
{
|
||||
u32 NARC_GetMemberSize(NARC *narc, u32 file_id) {
|
||||
u32 file_start;
|
||||
u32 file_end;
|
||||
GF_ASSERT(narc->num_files > file_id);
|
||||
|
|
@ -378,8 +365,7 @@ u32 NARC_GetMemberSize(NARC * narc, u32 file_id)
|
|||
return file_end - file_start;
|
||||
}
|
||||
|
||||
void NARC_ReadFromMember(NARC * narc, u32 file_id, u32 pos, u32 size, void * dest)
|
||||
{
|
||||
void NARC_ReadFromMember(NARC *narc, u32 file_id, u32 pos, u32 size, void *dest) {
|
||||
u32 file_start;
|
||||
GF_ASSERT(narc->num_files > file_id);
|
||||
FS_SeekFile(&narc->file, (s32)(narc->btaf_start + 12 + 8 * file_id), FS_SEEK_SET);
|
||||
|
|
@ -388,12 +374,10 @@ void NARC_ReadFromMember(NARC * narc, u32 file_id, u32 pos, u32 size, void * des
|
|||
FS_ReadFile(&narc->file, dest, (s32)size);
|
||||
}
|
||||
|
||||
void NARC_ReadFile(NARC * narc, u32 size, void * dest)
|
||||
{
|
||||
void NARC_ReadFile(NARC *narc, u32 size, void *dest) {
|
||||
FS_ReadFile(&narc->file, dest, (s32)size);
|
||||
}
|
||||
|
||||
u16 NARC_GetFileCount(NARC * narc)
|
||||
{
|
||||
u16 NARC_GetFileCount(NARC *narc) {
|
||||
return narc->num_files;
|
||||
}
|
||||
|
|
|
|||
153
arm9/src/font.c
153
arm9/src/font.c
|
|
@ -1,7 +1,10 @@
|
|||
#include "global.h"
|
||||
#include "font.h"
|
||||
#include "gf_gfx_loader.h"
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "graphic/font.naix"
|
||||
|
||||
#include "gf_gfx_loader.h"
|
||||
#include "render_text.h"
|
||||
#include "string16.h"
|
||||
#include "string_control_code.h"
|
||||
|
|
@ -27,12 +30,10 @@ const struct FontInfo gFontInfos[5] = {
|
|||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
||||
};
|
||||
|
||||
void sub_02002C14()
|
||||
{
|
||||
void sub_02002C14() {
|
||||
UNK_02106FC8 = &UNK_02106FCC;
|
||||
|
||||
for (u32 i = 0; i < 4; i++)
|
||||
{
|
||||
for (u32 i = 0; i < 4; i++) {
|
||||
UNK_02106FC8->unk84[i] = NULL;
|
||||
UNK_02106FC8->unk94[i] = NULL;
|
||||
}
|
||||
|
|
@ -40,170 +41,142 @@ void sub_02002C14()
|
|||
SetFontsPointer(&gFontInfos[0]);
|
||||
}
|
||||
|
||||
void sub_02002C50(u32 font_id, HeapID heapId)
|
||||
{
|
||||
UNK_02106FC8->unk94[font_id] =
|
||||
FontData_New(NARC_GRAPHIC_FONT, UNK_020ECB54[font_id][0], 1, UNK_020ECB54[font_id][1], heapId);
|
||||
void sub_02002C50(u32 font_id, HeapID heapId) {
|
||||
UNK_02106FC8->unk94[font_id] = FontData_New(NARC_GRAPHIC_FONT, UNK_020ECB54[font_id][0], 1, UNK_020ECB54[font_id][1], heapId);
|
||||
}
|
||||
|
||||
void sub_02002C84(s32 param0, HeapID heapId)
|
||||
{
|
||||
void sub_02002C84(s32 param0, HeapID heapId) {
|
||||
GF_ASSERT(param0 < 4);
|
||||
GF_ASSERT(UNK_02106FC8->unk94[param0] != NULL);
|
||||
|
||||
FontData_ModeSwitch(UNK_02106FC8->unk94[param0], 0, heapId);
|
||||
}
|
||||
|
||||
void sub_02002CC0(s32 param0)
|
||||
{
|
||||
void sub_02002CC0(s32 param0) {
|
||||
GF_ASSERT(param0 < 4);
|
||||
GF_ASSERT(UNK_02106FC8->unk94[param0] != NULL);
|
||||
|
||||
FontData_ModeSwitch(UNK_02106FC8->unk94[param0], 1, HEAP_ID_DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_02002CF8(int param0)
|
||||
{
|
||||
void sub_02002CF8(int param0) {
|
||||
|
||||
GF_ASSERT(param0 < 4);
|
||||
|
||||
if (UNK_02106FC8->unk84[param0] != NULL)
|
||||
{
|
||||
if (UNK_02106FC8->unk84[param0] != NULL) {
|
||||
u32 i;
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (i != param0 && UNK_020ECB54[i][0] == UNK_020ECB54[param0][0] &&
|
||||
UNK_02106FC8->unk94[i] != NULL)
|
||||
{
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (i != param0 && UNK_020ECB54[i][0] == UNK_020ECB54[param0][0] && UNK_02106FC8->unk94[i] != NULL) {
|
||||
UNK_02106FC8->unk84[i] = UNK_02106FC8->unk84[param0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == 4)
|
||||
{
|
||||
if (i == 4) {
|
||||
FreeToHeap(UNK_02106FC8->unk84[param0]);
|
||||
UNK_02106FC8->unk84[param0] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (UNK_02106FC8->unk94[param0] != NULL)
|
||||
{
|
||||
if (UNK_02106FC8->unk94[param0] != NULL) {
|
||||
FontData_Delete(UNK_02106FC8->unk94[param0]);
|
||||
UNK_02106FC8->unk94[param0] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
struct UnkStruct_02002C14_sub *sub_02002D94(u32 param0, u32 param1)
|
||||
{
|
||||
struct UnkStruct_02002C14_sub *sub_02002D94(u32 param0, u32 param1) {
|
||||
TryLoadGlyph(UNK_02106FC8->unk94[param0], param1, &UNK_02106FC8->unk00);
|
||||
|
||||
return &UNK_02106FC8->unk00;
|
||||
}
|
||||
|
||||
u32 FontFunc(u32 fontId, struct TextPrinter *printer)
|
||||
{
|
||||
struct TextPrinterSubStruct *subStruct =
|
||||
(struct TextPrinterSubStruct *)(&printer->subStructFields);
|
||||
u32 FontFunc(u32 fontId, struct TextPrinter *printer) {
|
||||
struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&printer->subStructFields);
|
||||
|
||||
if (subStruct->hasGlyphIdBeenSet == 0)
|
||||
{
|
||||
subStruct->glyphId = fontId;
|
||||
if (subStruct->hasGlyphIdBeenSet == 0) {
|
||||
subStruct->glyphId = fontId;
|
||||
subStruct->hasGlyphIdBeenSet = 1;
|
||||
}
|
||||
|
||||
return RenderText(printer);
|
||||
}
|
||||
|
||||
u32 sub_02002DE0(u32 param0, u16 *str, u32 param2)
|
||||
{
|
||||
u32 sub_02002DE0(u32 param0, u16 *str, u32 param2) {
|
||||
GF_ASSERT(UNK_02106FC8->unk94[param0] != NULL);
|
||||
|
||||
return GetStringWidth(UNK_02106FC8->unk94[param0], str, param2);
|
||||
}
|
||||
|
||||
u32 sub_02002E14(u32 param0, struct String *str, u32 param2)
|
||||
{
|
||||
u32 sub_02002E14(u32 param0, struct String *str, u32 param2) {
|
||||
GF_ASSERT(UNK_02106FC8->unk94[param0] != NULL);
|
||||
|
||||
return GetStringWidth(UNK_02106FC8->unk94[param0], String_c_str(str), param2);
|
||||
}
|
||||
|
||||
s32 GetFontAttribute(u8 fontId, s32 attr)
|
||||
{
|
||||
s32 GetFontAttribute(u8 fontId, s32 attr) {
|
||||
u8 ret = 0;
|
||||
switch (attr)
|
||||
{
|
||||
case 0:
|
||||
ret = gFontInfos[fontId].maxLetterWidth;
|
||||
break;
|
||||
case 1:
|
||||
ret = gFontInfos[fontId].maxLetterHeight;
|
||||
break;
|
||||
case 2:
|
||||
ret = gFontInfos[fontId].letterSpacing;
|
||||
break;
|
||||
case 3:
|
||||
ret = gFontInfos[fontId].lineSpacing;
|
||||
break;
|
||||
case 4:
|
||||
ret = gFontInfos[fontId].unk;
|
||||
break;
|
||||
case 5:
|
||||
ret = gFontInfos[fontId].fgColor;
|
||||
break;
|
||||
case 6:
|
||||
ret = gFontInfos[fontId].bgColor;
|
||||
break;
|
||||
case 7:
|
||||
ret = gFontInfos[fontId].shadowColor;
|
||||
break;
|
||||
switch (attr) {
|
||||
case 0:
|
||||
ret = gFontInfos[fontId].maxLetterWidth;
|
||||
break;
|
||||
case 1:
|
||||
ret = gFontInfos[fontId].maxLetterHeight;
|
||||
break;
|
||||
case 2:
|
||||
ret = gFontInfos[fontId].letterSpacing;
|
||||
break;
|
||||
case 3:
|
||||
ret = gFontInfos[fontId].lineSpacing;
|
||||
break;
|
||||
case 4:
|
||||
ret = gFontInfos[fontId].unk;
|
||||
break;
|
||||
case 5:
|
||||
ret = gFontInfos[fontId].fgColor;
|
||||
break;
|
||||
case 6:
|
||||
ret = gFontInfos[fontId].bgColor;
|
||||
break;
|
||||
case 7:
|
||||
ret = gFontInfos[fontId].shadowColor;
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void LoadFontPal0(enum GFPalLoadLocation location, enum GFPalSlotOffset palSlotOffset, HeapID heapId)
|
||||
{
|
||||
void LoadFontPal0(enum GFPalLoadLocation location, enum GFPalSlotOffset palSlotOffset, HeapID heapId) {
|
||||
GfGfxLoader_GXLoadPal(NARC_GRAPHIC_FONT, NARC_font_narc_0006_NCLR, location, palSlotOffset, 0x20, heapId);
|
||||
}
|
||||
|
||||
void LoadFontPal1(enum GFPalLoadLocation location, enum GFPalSlotOffset palSlotOffset, HeapID heapId)
|
||||
{
|
||||
void LoadFontPal1(enum GFPalLoadLocation location, enum GFPalSlotOffset palSlotOffset, HeapID heapId) {
|
||||
GfGfxLoader_GXLoadPal(NARC_GRAPHIC_FONT, NARC_font_narc_0007_NCLR, location, palSlotOffset, 0x20, heapId);
|
||||
}
|
||||
|
||||
u32 FontID_String_GetWidthMultiline(u32 param0, struct String *str, u32 param2)
|
||||
{
|
||||
u32 FontID_String_GetWidthMultiline(u32 param0, struct String *str, u32 param2) {
|
||||
GF_ASSERT(UNK_02106FC8->unk94[param0] != NULL);
|
||||
|
||||
return GetStringWidthMultiline(UNK_02106FC8->unk94[param0], String_c_str(str), param2);
|
||||
}
|
||||
|
||||
u32 sub_02002F40(u32 param0, struct String *str, u32 param2, u32 param3)
|
||||
{
|
||||
u32 sub_02002F40(u32 param0, struct String *str, u32 param2, u32 param3) {
|
||||
u32 r0 = sub_02002E14(param0, str, param2);
|
||||
if (r0 < param3)
|
||||
{
|
||||
if (r0 < param3) {
|
||||
return (param3 - r0) / 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 sub_02002F58(const u16 *str)
|
||||
{
|
||||
u32 sub_02002F58(const u16 *str) {
|
||||
u32 r5 = 1;
|
||||
while (*str != EOS)
|
||||
{
|
||||
if (*str == EXT_CTRL_CODE_BEGIN)
|
||||
{
|
||||
while (*str != EOS) {
|
||||
if (*str == EXT_CTRL_CODE_BEGIN) {
|
||||
str = MsgArray_SkipControlCode(str);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (*str == CHAR_LF)
|
||||
{
|
||||
if (*str == CHAR_LF) {
|
||||
r5++;
|
||||
str++;
|
||||
continue;
|
||||
|
|
@ -215,13 +188,11 @@ u32 sub_02002F58(const u16 *str)
|
|||
return r5;
|
||||
}
|
||||
|
||||
u32 sub_02002F90(struct String *str)
|
||||
{
|
||||
u32 sub_02002F90(struct String *str) {
|
||||
return sub_02002F58(String_c_str(str));
|
||||
}
|
||||
|
||||
s32 sub_02002F9C(u32 param0, struct String *str)
|
||||
{
|
||||
s32 sub_02002F9C(u32 param0, struct String *str) {
|
||||
GF_ASSERT(UNK_02106FC8->unk94[param0] != NULL);
|
||||
|
||||
return StringGetWidth_SingleLine_HandleClearToControlCode(
|
||||
|
|
|
|||
|
|
@ -1,20 +1,22 @@
|
|||
#include "game_init.h"
|
||||
|
||||
#include "global.h"
|
||||
#include "gx.h"
|
||||
#include "math.h"
|
||||
#include "main.h"
|
||||
|
||||
#include "FS_rom.h"
|
||||
#include "OS_interrupt.h"
|
||||
#include "PAD_pad.h"
|
||||
#include "gx.h"
|
||||
#include "heap.h"
|
||||
#include "main.h"
|
||||
#include "math.h"
|
||||
#include "registers.h"
|
||||
#include "string.h"
|
||||
#include "tp.h"
|
||||
#include "unk_0201B4E8.h"
|
||||
#include "unk_02022450.h"
|
||||
#include "game_init.h"
|
||||
#include "registers.h"
|
||||
#include "heap.h"
|
||||
#include "OS_interrupt.h"
|
||||
|
||||
static struct {
|
||||
void * contents;
|
||||
void *contents;
|
||||
u32 name_hash;
|
||||
} sFileCache[128];
|
||||
|
||||
|
|
@ -23,79 +25,64 @@ struct Main gSystem;
|
|||
void Main_ToggleHBlankInterrupt(BOOL enableFlag);
|
||||
void sub_0201B5CC(void *);
|
||||
|
||||
void sub_02015EA0(void)
|
||||
{
|
||||
void sub_02015EA0(void) {
|
||||
DTCM.intr_check |= 1;
|
||||
MI_WaitDma(3);
|
||||
sub_0201B5CC(gSystem.unk1C);
|
||||
gSystem.unk30++;
|
||||
}
|
||||
|
||||
void sub_02015ED4(void)
|
||||
{
|
||||
void sub_02015ED4(void) {
|
||||
DTCM.intr_check |= 1;
|
||||
MI_WaitDma(3);
|
||||
}
|
||||
|
||||
void sub_02015EF4(void)
|
||||
{
|
||||
void sub_02015EF4(void) {
|
||||
OS_DisableIrqMask(1);
|
||||
OS_SetIrqFunction(1, sub_02015ED4);
|
||||
OS_EnableIrqMask(1);
|
||||
}
|
||||
|
||||
void Main_SetVBlankIntrCB(void (*a0)(void *), void * a1)
|
||||
{
|
||||
gSystem.vBlankIntr = a0;
|
||||
void Main_SetVBlankIntrCB(void (*a0)(void *), void *a1) {
|
||||
gSystem.vBlankIntr = a0;
|
||||
gSystem.vBlankIntrArg = a1;
|
||||
}
|
||||
|
||||
void sub_02015F1C(void)
|
||||
{
|
||||
void sub_02015F1C(void) {
|
||||
Main_ToggleHBlankInterrupt(FALSE);
|
||||
gSystem.hBlankIntr = NULL;
|
||||
gSystem.hBlankIntr = NULL;
|
||||
gSystem.hBlankIntrArg = NULL;
|
||||
}
|
||||
|
||||
BOOL Main_SetHBlankIntrCB(void (*a0)(void *), void * a1)
|
||||
{
|
||||
if (a0 == 0)
|
||||
{
|
||||
BOOL Main_SetHBlankIntrCB(void (*a0)(void *), void *a1) {
|
||||
if (a0 == 0) {
|
||||
Main_ToggleHBlankInterrupt(FALSE);
|
||||
gSystem.hBlankIntr = NULL;
|
||||
gSystem.hBlankIntr = NULL;
|
||||
gSystem.hBlankIntrArg = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
else if (gSystem.hBlankIntr == NULL)
|
||||
{
|
||||
} else if (gSystem.hBlankIntr == NULL) {
|
||||
gSystem.hBlankIntrArg = a1;
|
||||
gSystem.hBlankIntr = a0;
|
||||
gSystem.hBlankIntr = a0;
|
||||
Main_ToggleHBlankInterrupt(TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void Main_CallHBlankCallback(void)
|
||||
{
|
||||
if (gSystem.hBlankIntr != NULL)
|
||||
void Main_CallHBlankCallback(void) {
|
||||
if (gSystem.hBlankIntr != NULL) {
|
||||
gSystem.hBlankIntr(gSystem.hBlankIntrArg);
|
||||
}
|
||||
}
|
||||
|
||||
void Main_ToggleHBlankInterrupt(BOOL enableFlag)
|
||||
{
|
||||
void Main_ToggleHBlankInterrupt(BOOL enableFlag) {
|
||||
(void)OS_DisableIrq();
|
||||
if (!enableFlag)
|
||||
{
|
||||
if (!enableFlag) {
|
||||
(void)OS_GetIrqMask();
|
||||
OS_DisableIrqMask(OS_IE_HBLANK);
|
||||
GX_HBlankIntr(FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
(void)OS_GetIrqMask();
|
||||
OS_SetIrqFunction(OS_IE_HBLANK, Main_CallHBlankCallback);
|
||||
OS_EnableIrqMask(OS_IE_HBLANK);
|
||||
|
|
@ -111,27 +98,23 @@ const struct HeapParam UNK_020EDB10[] = {
|
|||
{ 0x10D800, OS_ARENA_MAIN }
|
||||
};
|
||||
|
||||
void sub_02015FC8(void)
|
||||
{
|
||||
void sub_02015FC8(void) {
|
||||
u32 data[8];
|
||||
u8 digest[16];
|
||||
OS_GetLowEntropyData(data);
|
||||
MATH_CalcMD5(digest, data, 32);
|
||||
u32 csum = 0, i;
|
||||
for (i = 0; i < sizeof(digest); i++)
|
||||
{
|
||||
for (i = 0; i < sizeof(digest); i++) {
|
||||
csum += digest[i];
|
||||
}
|
||||
csum %= 256;
|
||||
while (csum & 3)
|
||||
{
|
||||
while (csum & 3) {
|
||||
csum++;
|
||||
}
|
||||
InitHeapSystem(UNK_020EDB10, NELEMS(UNK_020EDB10), 92, csum);
|
||||
}
|
||||
|
||||
void InitSystemForTheGame(void)
|
||||
{
|
||||
void InitSystemForTheGame(void) {
|
||||
OS_Init();
|
||||
FX_Init();
|
||||
reg_GX_POWCNT = (REGType16v)((reg_GX_POWCNT & ~(REG_GX_POWCNT_GE_MASK | REG_GX_POWCNT_RE_MASK | REG_GX_POWCNT_E2DG_MASK | REG_GX_POWCNT_E2DGB_MASK)) | (REG_GX_POWCNT_GE_MASK | REG_GX_POWCNT_RE_MASK | REG_GX_POWCNT_E2DG_MASK | REG_GX_POWCNT_E2DGB_MASK));
|
||||
|
|
@ -152,20 +135,19 @@ void InitSystemForTheGame(void)
|
|||
GX_VBlankIntr(TRUE);
|
||||
FS_Init(1);
|
||||
sub_02022450();
|
||||
u32 size = FS_TryLoadTable(NULL, 0);
|
||||
void * table = OS_AllocFromArenaLo(OS_ARENA_MAIN, size, 4);
|
||||
u32 size = FS_TryLoadTable(NULL, 0);
|
||||
void *table = OS_AllocFromArenaLo(OS_ARENA_MAIN, size, 4);
|
||||
GF_ASSERT(table != NULL);
|
||||
FS_TryLoadTable(table, size);
|
||||
gSystem.vBlankIntr = NULL;
|
||||
gSystem.hBlankIntr = NULL;
|
||||
gSystem.unk10 = 0;
|
||||
gSystem.unk14 = 0;
|
||||
gSystem.unk2C = 0;
|
||||
gSystem.vBlankIntr = NULL;
|
||||
gSystem.hBlankIntr = NULL;
|
||||
gSystem.unk10 = 0;
|
||||
gSystem.unk14 = 0;
|
||||
gSystem.unk2C = 0;
|
||||
gSystem.screensFlipped = 0;
|
||||
}
|
||||
|
||||
void InitGraphicMemory(void)
|
||||
{
|
||||
void InitGraphicMemory(void) {
|
||||
GX_SetBankForLCDC(0x1FF);
|
||||
MI_CpuClearFast((void *)HW_LCDC_VRAM, HW_LCDC_VRAM_SIZE);
|
||||
GX_DisableBankForLCDC();
|
||||
|
|
@ -175,62 +157,56 @@ void InitGraphicMemory(void)
|
|||
MI_CpuClearFast((void *)HW_DB_PLTT, HW_DB_PLTT_SIZE);
|
||||
}
|
||||
|
||||
void * AllocAndReadFile(HeapID heapId, const char * path)
|
||||
{
|
||||
void * ret;
|
||||
void *AllocAndReadFile(HeapID heapId, const char *path) {
|
||||
void *ret;
|
||||
|
||||
FSFile file;
|
||||
FS_InitFile(&file);
|
||||
if (FS_OpenFile(&file, path))
|
||||
{
|
||||
if (FS_OpenFile(&file, path)) {
|
||||
u32 size = file.prop.file.bottom - file.prop.file.top;
|
||||
ret = AllocFromHeap(heapId, size);
|
||||
if (ret != NULL)
|
||||
{
|
||||
if (size != FS_ReadFile(&file, ret, (s32)size))
|
||||
{
|
||||
ret = AllocFromHeap(heapId, size);
|
||||
if (ret != NULL) {
|
||||
if (size != FS_ReadFile(&file, ret, (s32)size)) {
|
||||
FreeToHeapExplicit(heapId, ret);
|
||||
ret = NULL;
|
||||
}
|
||||
}
|
||||
FS_CloseFile(&file);
|
||||
}
|
||||
else
|
||||
} else {
|
||||
ret = NULL;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void OpenAndReadWholeFile(const char * path, void ** ptr)
|
||||
{
|
||||
void OpenAndReadWholeFile(const char *path, void **ptr) {
|
||||
FSFile file;
|
||||
FS_InitFile(&file);
|
||||
if (FS_OpenFile(&file, path))
|
||||
{
|
||||
if (FS_OpenFile(&file, path)) {
|
||||
u32 size = file.prop.file.bottom - file.prop.file.top;
|
||||
if (*ptr != NULL)
|
||||
if (*ptr != NULL) {
|
||||
FS_ReadFile(&file, *ptr, (s32)size);
|
||||
}
|
||||
FS_CloseFile(&file);
|
||||
}
|
||||
}
|
||||
|
||||
u32 GetFilenameHash(const s8 * str)
|
||||
{
|
||||
u32 GetFilenameHash(const s8 *str) {
|
||||
u16 len = (u16)strlen(str);
|
||||
u16 numWords;
|
||||
if ((len % 4) != 0)
|
||||
if ((len % 4) != 0) {
|
||||
numWords = (u16)((len / 4) + 1);
|
||||
else
|
||||
} else {
|
||||
numWords = (u16)(len / 4);
|
||||
}
|
||||
u32 hash = 0;
|
||||
s32 i, j;
|
||||
for (i = 0; i < numWords; i++)
|
||||
{
|
||||
for (i = 0; i < numWords; i++) {
|
||||
u32 curWord = 0;
|
||||
for (j = 0; j < 4; j++)
|
||||
{
|
||||
for (j = 0; j < 4; j++) {
|
||||
int curChar = str[4 * i + j];
|
||||
if (curChar == 0)
|
||||
if (curChar == 0) {
|
||||
break;
|
||||
}
|
||||
curWord |= curChar << (8 * j);
|
||||
}
|
||||
hash ^= curWord;
|
||||
|
|
@ -238,23 +214,19 @@ u32 GetFilenameHash(const s8 * str)
|
|||
return hash;
|
||||
}
|
||||
|
||||
int GetFileCacheId(u32 hash)
|
||||
{
|
||||
for (int i = 0; i < 128; i++)
|
||||
{
|
||||
if (sFileCache[i].name_hash == hash && sFileCache[i].contents != NULL)
|
||||
int GetFileCacheId(u32 hash) {
|
||||
for (int i = 0; i < 128; i++) {
|
||||
if (sFileCache[i].name_hash == hash && sFileCache[i].contents != NULL) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int AddFileToCache(void * contents, u32 hash)
|
||||
{
|
||||
for (int i = 0; i < 128; i++)
|
||||
{
|
||||
if (sFileCache[i].contents == NULL)
|
||||
{
|
||||
sFileCache[i].contents = contents;
|
||||
int AddFileToCache(void *contents, u32 hash) {
|
||||
for (int i = 0; i < 128; i++) {
|
||||
if (sFileCache[i].contents == NULL) {
|
||||
sFileCache[i].contents = contents;
|
||||
sFileCache[i].name_hash = hash;
|
||||
return i;
|
||||
}
|
||||
|
|
@ -262,123 +234,104 @@ int AddFileToCache(void * contents, u32 hash)
|
|||
return -1;
|
||||
}
|
||||
|
||||
void ClearFileCache(void)
|
||||
{
|
||||
for (int i = 127; i > -1; i--)
|
||||
{
|
||||
if (sFileCache[i].contents != NULL)
|
||||
{
|
||||
void ClearFileCache(void) {
|
||||
for (int i = 127; i > -1; i--) {
|
||||
if (sFileCache[i].contents != NULL) {
|
||||
FreeToHeap(sFileCache[i].contents);
|
||||
sFileCache[i].contents = NULL;
|
||||
sFileCache[i].contents = NULL;
|
||||
sFileCache[i].name_hash = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void * OpenFileCached(const s8 * str, HeapID heapId)
|
||||
{
|
||||
void *OpenFileCached(const s8 *str, HeapID heapId) {
|
||||
s8 filenameBuf[32];
|
||||
FSFile file;
|
||||
void * ret;
|
||||
void *ret;
|
||||
int skipCache = 0;
|
||||
|
||||
if (str[0] == '!')
|
||||
{
|
||||
if (str[0] == '!') {
|
||||
strcpy(filenameBuf, str + 1);
|
||||
skipCache = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
strcpy(filenameBuf, str);
|
||||
}
|
||||
u32 hash = GetFilenameHash(filenameBuf);
|
||||
u32 hash = GetFilenameHash(filenameBuf);
|
||||
s32 cacheId = GetFileCacheId(hash);
|
||||
if (cacheId >= 0 && skipCache == 0)
|
||||
{
|
||||
if (cacheId >= 0 && skipCache == 0) {
|
||||
ret = sFileCache[cacheId].contents;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
FS_InitFile(&file);
|
||||
if (FS_OpenFile(&file, (const char *)filenameBuf))
|
||||
{
|
||||
if (FS_OpenFile(&file, (const char *)filenameBuf)) {
|
||||
u32 size = file.prop.file.bottom - file.prop.file.top;
|
||||
ret = AllocFromHeap(heapId, size);
|
||||
if (ret != NULL)
|
||||
{
|
||||
if (size != FS_ReadFile(&file, ret, (s32)size))
|
||||
{
|
||||
ret = AllocFromHeap(heapId, size);
|
||||
if (ret != NULL) {
|
||||
if (size != FS_ReadFile(&file, ret, (s32)size)) {
|
||||
FreeToHeap(ret);
|
||||
ret = NULL;
|
||||
}
|
||||
}
|
||||
FS_CloseFile(&file);
|
||||
if (skipCache == 0)
|
||||
if (skipCache == 0) {
|
||||
AddFileToCache(ret, hash);
|
||||
}
|
||||
else
|
||||
}
|
||||
} else {
|
||||
ret = NULL;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void InitKeypadAndTouchpad(void)
|
||||
{
|
||||
void InitKeypadAndTouchpad(void) {
|
||||
TPCalibrateParam tp;
|
||||
gSystem.buttonMode = 0;
|
||||
gSystem.heldKeysRaw = 0;
|
||||
gSystem.newKeysRaw = 0;
|
||||
gSystem.newAndRepeatedKeysRaw = 0;
|
||||
gSystem.heldKeys = 0;
|
||||
gSystem.newKeys = 0;
|
||||
gSystem.newAndRepeatedKeys = 0;
|
||||
gSystem.keyRepeatCounter = 0;
|
||||
gSystem.buttonMode = 0;
|
||||
gSystem.heldKeysRaw = 0;
|
||||
gSystem.newKeysRaw = 0;
|
||||
gSystem.newAndRepeatedKeysRaw = 0;
|
||||
gSystem.heldKeys = 0;
|
||||
gSystem.newKeys = 0;
|
||||
gSystem.newAndRepeatedKeys = 0;
|
||||
gSystem.keyRepeatCounter = 0;
|
||||
gSystem.keyRepeatContinueDelay = 8;
|
||||
gSystem.keyRepeatStartDelay = 15;
|
||||
gSystem.touchX = 0;
|
||||
gSystem.touchY = 0;
|
||||
gSystem.touchNew = 0;
|
||||
gSystem.touchHeld = 0;
|
||||
gSystem.touchpadReadAuto = 0;
|
||||
gSystem.keyRepeatStartDelay = 15;
|
||||
gSystem.touchX = 0;
|
||||
gSystem.touchY = 0;
|
||||
gSystem.touchNew = 0;
|
||||
gSystem.touchHeld = 0;
|
||||
gSystem.touchpadReadAuto = 0;
|
||||
TP_Init();
|
||||
if (TP_GetUserInfo(&tp) == TRUE)
|
||||
if (TP_GetUserInfo(&tp) == TRUE) {
|
||||
TP_SetCalibrateParam(&tp);
|
||||
else
|
||||
{
|
||||
tp.x0 = 686;
|
||||
tp.y0 = 1420;
|
||||
} else {
|
||||
tp.x0 = 686;
|
||||
tp.y0 = 1420;
|
||||
tp.xDotSize = 3621;
|
||||
tp.yDotSize = 4616;
|
||||
TP_SetCalibrateParam(&tp);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_02016438(u8 a0)
|
||||
{
|
||||
void sub_02016438(u8 a0) {
|
||||
gSystem.gbaCartId = a0;
|
||||
}
|
||||
|
||||
void sub_02016444(u8 a0)
|
||||
{
|
||||
void sub_02016444(u8 a0) {
|
||||
gSystem.unk67 |= a0;
|
||||
}
|
||||
|
||||
void sub_02016454(u8 a0)
|
||||
{
|
||||
void sub_02016454(u8 a0) {
|
||||
gSystem.unk67 &= ~a0;
|
||||
}
|
||||
|
||||
void ReadKeypadAndTocuhpad(void)
|
||||
{
|
||||
void ReadKeypadAndTocuhpad(void) {
|
||||
TPData raw, calib;
|
||||
if (PAD_DetectFold())
|
||||
{
|
||||
if (PAD_DetectFold()) {
|
||||
// Can't press any buttons while the lid is closed.
|
||||
gSystem.newKeys = 0;
|
||||
gSystem.heldKeys = 0;
|
||||
gSystem.newKeys = 0;
|
||||
gSystem.heldKeys = 0;
|
||||
gSystem.newAndRepeatedKeys = 0;
|
||||
gSystem.touchNew = 0;
|
||||
gSystem.touchHeld = 0;
|
||||
gSystem.touchNew = 0;
|
||||
gSystem.touchHeld = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -393,48 +346,40 @@ void ReadKeypadAndTocuhpad(void)
|
|||
// Same logic as gen3, but fixes the bug where the
|
||||
// remapped keys are incorrectly used here.
|
||||
// See also: pokeemerald/src/main.c:ReadKeys
|
||||
if (padRead != 0 && gSystem.heldKeysRaw == padRead)
|
||||
{
|
||||
if (--gSystem.keyRepeatCounter == 0)
|
||||
{
|
||||
if (padRead != 0 && gSystem.heldKeysRaw == padRead) {
|
||||
if (--gSystem.keyRepeatCounter == 0) {
|
||||
gSystem.newAndRepeatedKeysRaw = padRead;
|
||||
gSystem.keyRepeatCounter = gSystem.keyRepeatContinueDelay;
|
||||
gSystem.keyRepeatCounter = gSystem.keyRepeatContinueDelay;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
gSystem.keyRepeatCounter = gSystem.keyRepeatStartDelay;
|
||||
}
|
||||
gSystem.heldKeysRaw = padRead;
|
||||
|
||||
// Apply the button mode option to the read key input
|
||||
gSystem.newKeys = gSystem.newKeysRaw;
|
||||
gSystem.heldKeys = padRead;
|
||||
gSystem.newKeys = gSystem.newKeysRaw;
|
||||
gSystem.heldKeys = padRead;
|
||||
gSystem.newAndRepeatedKeys = gSystem.newAndRepeatedKeysRaw;
|
||||
ApplyButtonModeToInput();
|
||||
|
||||
// Read the touchpad. New to gen 4.
|
||||
if (gSystem.touchpadReadAuto == 0)
|
||||
{
|
||||
if (gSystem.touchpadReadAuto == 0) {
|
||||
while (TP_RequestRawSampling(&raw))
|
||||
;
|
||||
}
|
||||
else
|
||||
} else {
|
||||
TP_GetLatestRawPointInAuto(&raw);
|
||||
}
|
||||
TP_GetCalibratedPoint(&calib, &raw);
|
||||
|
||||
// If the touchpad is valid, we gucci.
|
||||
if (calib.validity == TP_VALIDITY_VALID)
|
||||
{
|
||||
if (calib.validity == TP_VALIDITY_VALID) {
|
||||
gSystem.touchX = calib.x;
|
||||
gSystem.touchY = calib.y;
|
||||
}
|
||||
|
||||
// If the touchpad was used last frame, salvage what we can.
|
||||
else if (gSystem.touchHeld)
|
||||
{
|
||||
switch (calib.validity)
|
||||
{
|
||||
else if (gSystem.touchHeld) {
|
||||
switch (calib.validity) {
|
||||
case TP_VALIDITY_INVALID_X:
|
||||
gSystem.touchY = calib.y;
|
||||
break;
|
||||
|
|
@ -447,48 +392,47 @@ void ReadKeypadAndTocuhpad(void)
|
|||
}
|
||||
// What was read from the touchpad was not salvageable.
|
||||
// Ignore touch input.
|
||||
else
|
||||
else {
|
||||
calib.touch = 0;
|
||||
gSystem.touchNew = (u16)((gSystem.touchHeld ^ calib.touch) & calib.touch);
|
||||
}
|
||||
gSystem.touchNew = (u16)((gSystem.touchHeld ^ calib.touch) & calib.touch);
|
||||
gSystem.touchHeld = calib.touch;
|
||||
}
|
||||
|
||||
void ApplyButtonModeToInput(void)
|
||||
{
|
||||
switch (gSystem.buttonMode)
|
||||
{
|
||||
void ApplyButtonModeToInput(void) {
|
||||
switch (gSystem.buttonMode) {
|
||||
case 0: // Normal
|
||||
break;
|
||||
case 1: // Start = X
|
||||
if (gSystem.newKeys & PAD_BUTTON_START)
|
||||
if (gSystem.newKeys & PAD_BUTTON_START) {
|
||||
gSystem.newKeys |= PAD_BUTTON_X;
|
||||
if (gSystem.heldKeys & PAD_BUTTON_START)
|
||||
}
|
||||
if (gSystem.heldKeys & PAD_BUTTON_START) {
|
||||
gSystem.heldKeys |= PAD_BUTTON_X;
|
||||
if (gSystem.newAndRepeatedKeys & PAD_BUTTON_START)
|
||||
}
|
||||
if (gSystem.newAndRepeatedKeys & PAD_BUTTON_START) {
|
||||
gSystem.newAndRepeatedKeys |= PAD_BUTTON_X;
|
||||
}
|
||||
break;
|
||||
case 2: // Swap X and Y; unused in the retail game
|
||||
{
|
||||
u32 swapMask = 0;
|
||||
if (gSystem.newKeys & PAD_BUTTON_X)
|
||||
{
|
||||
swapMask |= PAD_BUTTON_Y;
|
||||
}
|
||||
if (gSystem.newKeys & PAD_BUTTON_Y)
|
||||
{
|
||||
swapMask |= PAD_BUTTON_X;
|
||||
}
|
||||
gSystem.newKeys &= ((PAD_BUTTON_X | PAD_BUTTON_Y) ^ 0xFFFF);;
|
||||
gSystem.newKeys |= swapMask;
|
||||
{
|
||||
u32 swapMask = 0;
|
||||
if (gSystem.newKeys & PAD_BUTTON_X) {
|
||||
swapMask |= PAD_BUTTON_Y;
|
||||
}
|
||||
if (gSystem.newKeys & PAD_BUTTON_Y) {
|
||||
swapMask |= PAD_BUTTON_X;
|
||||
}
|
||||
gSystem.newKeys &= ((PAD_BUTTON_X | PAD_BUTTON_Y) ^ 0xFFFF);
|
||||
;
|
||||
gSystem.newKeys |= swapMask;
|
||||
}
|
||||
{
|
||||
u32 swapMask = 0;
|
||||
if (gSystem.heldKeys & PAD_BUTTON_X)
|
||||
{
|
||||
if (gSystem.heldKeys & PAD_BUTTON_X) {
|
||||
swapMask |= PAD_BUTTON_Y;
|
||||
}
|
||||
if (gSystem.heldKeys & PAD_BUTTON_Y)
|
||||
{
|
||||
if (gSystem.heldKeys & PAD_BUTTON_Y) {
|
||||
swapMask |= PAD_BUTTON_X;
|
||||
}
|
||||
gSystem.heldKeys &= ((PAD_BUTTON_X | PAD_BUTTON_Y) ^ 0xFFFF);
|
||||
|
|
@ -496,12 +440,10 @@ void ApplyButtonModeToInput(void)
|
|||
}
|
||||
{
|
||||
u32 swapMask = 0;
|
||||
if (gSystem.newAndRepeatedKeys & PAD_BUTTON_X)
|
||||
{
|
||||
if (gSystem.newAndRepeatedKeys & PAD_BUTTON_X) {
|
||||
swapMask |= PAD_BUTTON_Y;
|
||||
}
|
||||
if (gSystem.newAndRepeatedKeys & PAD_BUTTON_Y)
|
||||
{
|
||||
if (gSystem.newAndRepeatedKeys & PAD_BUTTON_Y) {
|
||||
swapMask |= PAD_BUTTON_X;
|
||||
}
|
||||
gSystem.newAndRepeatedKeys &= ((PAD_BUTTON_X | PAD_BUTTON_Y) ^ 0xFFFF);
|
||||
|
|
@ -509,30 +451,30 @@ void ApplyButtonModeToInput(void)
|
|||
}
|
||||
break;
|
||||
case 3: // L = A
|
||||
if (gSystem.newKeys & PAD_BUTTON_L)
|
||||
if (gSystem.newKeys & PAD_BUTTON_L) {
|
||||
gSystem.newKeys |= PAD_BUTTON_A;
|
||||
if (gSystem.heldKeys & PAD_BUTTON_L)
|
||||
}
|
||||
if (gSystem.heldKeys & PAD_BUTTON_L) {
|
||||
gSystem.heldKeys |= PAD_BUTTON_A;
|
||||
if (gSystem.newAndRepeatedKeys & PAD_BUTTON_L)
|
||||
}
|
||||
if (gSystem.newAndRepeatedKeys & PAD_BUTTON_L) {
|
||||
gSystem.newAndRepeatedKeys |= PAD_BUTTON_A;
|
||||
}
|
||||
gSystem.newKeys &= ((PAD_BUTTON_L | PAD_BUTTON_R) ^ 0xFFFF);
|
||||
gSystem.heldKeys &= ((PAD_BUTTON_L | PAD_BUTTON_R) ^ 0xFFFF);
|
||||
gSystem.newAndRepeatedKeys &= ((PAD_BUTTON_L | PAD_BUTTON_R) ^ 0xFFFF);
|
||||
}
|
||||
}
|
||||
|
||||
void SetKeyRepeatTimers(int continueDelay, int startDelay)
|
||||
{
|
||||
void SetKeyRepeatTimers(int continueDelay, int startDelay) {
|
||||
gSystem.keyRepeatContinueDelay = continueDelay;
|
||||
gSystem.keyRepeatStartDelay = startDelay;
|
||||
gSystem.keyRepeatStartDelay = startDelay;
|
||||
}
|
||||
|
||||
void SetSoftResetDisableMask(u8 a0)
|
||||
{
|
||||
void SetSoftResetDisableMask(u8 a0) {
|
||||
gSystem.softResetDisabled |= a0;
|
||||
}
|
||||
|
||||
void ClearSoftResetDisableMask(u8 a0)
|
||||
{
|
||||
void ClearSoftResetDisableMask(u8 a0) {
|
||||
gSystem.softResetDisabled &= ~a0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
#include "global.h"
|
||||
#include "filesystem.h"
|
||||
#include "NNS_g2d.h"
|
||||
#include "gf_gfx_loader.h"
|
||||
|
||||
u32 GfGfxLoader_LoadCharData(NarcId narcId, s32 memberNo, struct BgConfig * unkStruct02016B94_2, u32 layer, u32 numTiles, u32 szByte, BOOL isCompressed, HeapID heapId)
|
||||
{
|
||||
NNSG2dCharacterData * pCharData;
|
||||
void * pFile = GfGfxLoader_LoadFromNarc(narcId, memberNo, isCompressed, heapId, FALSE);
|
||||
if (pFile != NULL)
|
||||
{
|
||||
if (NNS_G2dGetUnpackedBGCharacterData(pFile, &pCharData))
|
||||
{
|
||||
if (szByte == 0)
|
||||
#include "global.h"
|
||||
|
||||
#include "NNS_g2d.h"
|
||||
#include "filesystem.h"
|
||||
|
||||
u32 GfGfxLoader_LoadCharData(NarcId narcId, s32 memberNo, struct BgConfig *unkStruct02016B94_2, u32 layer, u32 numTiles, u32 szByte, BOOL isCompressed, HeapID heapId) {
|
||||
NNSG2dCharacterData *pCharData;
|
||||
void *pFile = GfGfxLoader_LoadFromNarc(narcId, memberNo, isCompressed, heapId, FALSE);
|
||||
if (pFile != NULL) {
|
||||
if (NNS_G2dGetUnpackedBGCharacterData(pFile, &pCharData)) {
|
||||
if (szByte == 0) {
|
||||
szByte = pCharData->szByte;
|
||||
}
|
||||
BG_LoadCharTilesData(unkStruct02016B94_2, (u8)layer, pCharData->pRawData, szByte, numTiles);
|
||||
}
|
||||
FreeToHeap(pFile);
|
||||
|
|
@ -20,31 +20,28 @@ u32 GfGfxLoader_LoadCharData(NarcId narcId, s32 memberNo, struct BgConfig * unkS
|
|||
return szByte;
|
||||
}
|
||||
|
||||
void GfGfxLoader_LoadScrnData(NarcId narcId, s32 memberNo, struct BgConfig * unkStruct02016B94_2, u32 layer, u32 tileOffset, u32 szByte, BOOL isCompressed, HeapID heapId)
|
||||
{
|
||||
NNSG2dScreenData * pScreenData;
|
||||
void * pFile = GfGfxLoader_LoadFromNarc(narcId, memberNo, isCompressed, heapId, TRUE);
|
||||
if (pFile != NULL)
|
||||
{
|
||||
if (NNS_G2dGetUnpackedScreenData(pFile, &pScreenData))
|
||||
{
|
||||
if (szByte == 0)
|
||||
void GfGfxLoader_LoadScrnData(NarcId narcId, s32 memberNo, struct BgConfig *unkStruct02016B94_2, u32 layer, u32 tileOffset, u32 szByte, BOOL isCompressed, HeapID heapId) {
|
||||
NNSG2dScreenData *pScreenData;
|
||||
void *pFile = GfGfxLoader_LoadFromNarc(narcId, memberNo, isCompressed, heapId, TRUE);
|
||||
if (pFile != NULL) {
|
||||
if (NNS_G2dGetUnpackedScreenData(pFile, &pScreenData)) {
|
||||
if (szByte == 0) {
|
||||
szByte = pScreenData->szByte;
|
||||
if (GetBgTilemapBuffer(unkStruct02016B94_2, (u8) layer) != NULL)
|
||||
BG_LoadScreenTilemapData(unkStruct02016B94_2, (u8) layer, pScreenData->rawData, szByte);
|
||||
BgCopyOrUncompressTilemapBufferRangeToVram(unkStruct02016B94_2, (u8) layer, pScreenData->rawData, szByte, tileOffset);
|
||||
}
|
||||
if (GetBgTilemapBuffer(unkStruct02016B94_2, (u8)layer) != NULL) {
|
||||
BG_LoadScreenTilemapData(unkStruct02016B94_2, (u8)layer, pScreenData->rawData, szByte);
|
||||
}
|
||||
BgCopyOrUncompressTilemapBufferRangeToVram(unkStruct02016B94_2, (u8)layer, pScreenData->rawData, szByte, tileOffset);
|
||||
}
|
||||
FreeToHeap(pFile);
|
||||
}
|
||||
}
|
||||
|
||||
void GfGfxLoader_GXLoadPal(NarcId narcId, s32 memberNo, enum GFPalLoadLocation location, enum GFPalSlotOffset palSlotOffset, u32 szByte, HeapID heapId)
|
||||
{
|
||||
void GfGfxLoader_GXLoadPal(NarcId narcId, s32 memberNo, enum GFPalLoadLocation location, enum GFPalSlotOffset palSlotOffset, u32 szByte, HeapID heapId) {
|
||||
GfGfxLoader_GXLoadPalWithSrcOffset(narcId, memberNo, location, 0, palSlotOffset, szByte, heapId);
|
||||
}
|
||||
|
||||
void GfGfxLoader_GXLoadPalWithSrcOffset(NarcId narcId, s32 memberNo, enum GFPalLoadLocation location, u32 srcOffset, enum GFPalSlotOffset palSlotOffset, u32 szByte, HeapID heapId)
|
||||
{
|
||||
void GfGfxLoader_GXLoadPalWithSrcOffset(NarcId narcId, s32 memberNo, enum GFPalLoadLocation location, u32 srcOffset, enum GFPalSlotOffset palSlotOffset, u32 szByte, HeapID heapId) {
|
||||
static void (*const load_funcs[])(void *, u32, u32) = {
|
||||
GX_LoadBGPltt,
|
||||
GX_LoadOBJPltt,
|
||||
|
|
@ -55,18 +52,16 @@ void GfGfxLoader_GXLoadPalWithSrcOffset(NarcId narcId, s32 memberNo, enum GFPalL
|
|||
GXS_LoadBGExtPltt,
|
||||
GXS_LoadOBJExtPltt
|
||||
};
|
||||
NNSG2dPaletteData * pPltData;
|
||||
void * pFile = GfGfxLoader_LoadFromNarc(narcId, memberNo, FALSE, heapId, TRUE);
|
||||
if (pFile != NULL)
|
||||
{
|
||||
if (NNS_G2dGetUnpackedPaletteData(pFile, &pPltData))
|
||||
{
|
||||
NNSG2dPaletteData *pPltData;
|
||||
void *pFile = GfGfxLoader_LoadFromNarc(narcId, memberNo, FALSE, heapId, TRUE);
|
||||
if (pFile != NULL) {
|
||||
if (NNS_G2dGetUnpackedPaletteData(pFile, &pPltData)) {
|
||||
pPltData->pRawData = (void *)((u32)pPltData->pRawData + srcOffset);
|
||||
if (szByte == 0)
|
||||
if (szByte == 0) {
|
||||
szByte = pPltData->szByte - srcOffset;
|
||||
}
|
||||
DC_FlushRange(pPltData->pRawData, szByte);
|
||||
switch (location)
|
||||
{
|
||||
switch (location) {
|
||||
case GF_PAL_LOCATION_MAIN_BGEXT:
|
||||
GX_BeginLoadBGExtPltt();
|
||||
load_funcs[location](pPltData->pRawData, palSlotOffset, szByte);
|
||||
|
|
@ -96,21 +91,20 @@ void GfGfxLoader_GXLoadPalWithSrcOffset(NarcId narcId, s32 memberNo, enum GFPalL
|
|||
}
|
||||
}
|
||||
|
||||
u32 GfGfxLoader_LoadWholePalette(NarcId narcId, s32 memberId, u32 layer, u32 baseAddr, u32 szByte, BOOL isCompressed, HeapID heapId) //todo: change this to new format
|
||||
u32 GfGfxLoader_LoadWholePalette(NarcId narcId, s32 memberId, u32 layer, u32 baseAddr, u32 szByte, BOOL isCompressed, HeapID heapId) // todo: change this to new format
|
||||
{
|
||||
static void (*const load_funcs[])(void *, u32, u32) = {
|
||||
GX_LoadOBJ,
|
||||
GXS_LoadOBJ
|
||||
};
|
||||
|
||||
NNSG2dCharacterData* pCharData;
|
||||
void * pFile = GfGfxLoader_LoadFromNarc(narcId, memberId, isCompressed, heapId, TRUE);
|
||||
if (pFile != NULL)
|
||||
{
|
||||
if (NNS_G2dGetUnpackedCharacterData(pFile, &pCharData))
|
||||
{
|
||||
if (szByte == 0)
|
||||
NNSG2dCharacterData *pCharData;
|
||||
void *pFile = GfGfxLoader_LoadFromNarc(narcId, memberId, isCompressed, heapId, TRUE);
|
||||
if (pFile != NULL) {
|
||||
if (NNS_G2dGetUnpackedCharacterData(pFile, &pCharData)) {
|
||||
if (szByte == 0) {
|
||||
szByte = pCharData->szByte;
|
||||
}
|
||||
DC_FlushRange(pCharData->pRawData, szByte);
|
||||
load_funcs[layer](pCharData->pRawData, baseAddr, szByte);
|
||||
}
|
||||
|
|
@ -119,22 +113,16 @@ u32 GfGfxLoader_LoadWholePalette(NarcId narcId, s32 memberId, u32 layer, u32 bas
|
|||
return szByte;
|
||||
}
|
||||
|
||||
void GfGfxLoader_PartiallyLoadPalette(NarcId narcId, s32 memberId, NNS_G2D_VRAM_TYPE vramType, u32 baseAddr, HeapID heapId, NNSG2dImagePaletteProxy * pPltProxy)
|
||||
{
|
||||
void * pFile = GfGfxLoader_LoadFromNarc(narcId, memberId, FALSE, heapId, TRUE);
|
||||
NNSG2dPaletteData* pPlttData;
|
||||
NNSG2dPaletteCompressInfo* pCompressInfo;
|
||||
if (pFile != NULL)
|
||||
{
|
||||
void GfGfxLoader_PartiallyLoadPalette(NarcId narcId, s32 memberId, NNS_G2D_VRAM_TYPE vramType, u32 baseAddr, HeapID heapId, NNSG2dImagePaletteProxy *pPltProxy) {
|
||||
void *pFile = GfGfxLoader_LoadFromNarc(narcId, memberId, FALSE, heapId, TRUE);
|
||||
NNSG2dPaletteData *pPlttData;
|
||||
NNSG2dPaletteCompressInfo *pCompressInfo;
|
||||
if (pFile != NULL) {
|
||||
BOOL isCompressed = NNS_G2dGetUnpackedPaletteCompressInfo(pFile, &pCompressInfo);
|
||||
if (NNS_G2dGetUnpackedPaletteData(pFile, &pPlttData))
|
||||
{
|
||||
if (isCompressed)
|
||||
{
|
||||
if (NNS_G2dGetUnpackedPaletteData(pFile, &pPlttData)) {
|
||||
if (isCompressed) {
|
||||
NNS_G2dLoadPaletteEx(pPlttData, pCompressInfo, baseAddr, vramType, pPltProxy);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
NNS_G2dLoadPalette(pPlttData, baseAddr, vramType, pPltProxy);
|
||||
}
|
||||
}
|
||||
|
|
@ -142,22 +130,20 @@ void GfGfxLoader_PartiallyLoadPalette(NarcId narcId, s32 memberId, NNS_G2D_VRAM_
|
|||
}
|
||||
}
|
||||
|
||||
u32 GfGfxLoader_LoadImageMapping(NarcId narcId, s32 memberId, BOOL isCompressed, u32 layer, u32 szByte, NNS_G2D_VRAM_TYPE type, u32 baseAddr, HeapID heapId, NNSG2dImageProxy *pImgProxy)
|
||||
{
|
||||
u32 GfGfxLoader_LoadImageMapping(NarcId narcId, s32 memberId, BOOL isCompressed, u32 layer, u32 szByte, NNS_G2D_VRAM_TYPE type, u32 baseAddr, HeapID heapId, NNSG2dImageProxy *pImgProxy) {
|
||||
static void (*const load_funcs[])(const NNSG2dCharacterData *, u32, NNS_G2D_VRAM_TYPE, NNSG2dImageProxy *) = {
|
||||
NNS_G2dLoadImage1DMapping,
|
||||
NNS_G2dLoadImage2DMapping
|
||||
};
|
||||
|
||||
void * pFile = GfGfxLoader_LoadFromNarc(narcId, memberId, isCompressed, heapId, TRUE);
|
||||
void *pFile = GfGfxLoader_LoadFromNarc(narcId, memberId, isCompressed, heapId, TRUE);
|
||||
u32 retSize = 0;
|
||||
NNSG2dCharacterData * pSrcData;
|
||||
if (pFile != NULL)
|
||||
{
|
||||
if (NNS_G2dGetUnpackedCharacterData(pFile, &pSrcData))
|
||||
{
|
||||
if (szByte != 0)
|
||||
NNSG2dCharacterData *pSrcData;
|
||||
if (pFile != NULL) {
|
||||
if (NNS_G2dGetUnpackedCharacterData(pFile, &pSrcData)) {
|
||||
if (szByte != 0) {
|
||||
pSrcData->szByte = szByte;
|
||||
}
|
||||
load_funcs[layer](pSrcData, baseAddr, type, pImgProxy);
|
||||
retSize = pSrcData->szByte;
|
||||
}
|
||||
|
|
@ -166,30 +152,26 @@ u32 GfGfxLoader_LoadImageMapping(NarcId narcId, s32 memberId, BOOL isCompressed,
|
|||
return retSize;
|
||||
}
|
||||
|
||||
void GfGfxLoader_SetObjCntFlagsAndLoadImageMapping(NarcId narcId, s32 memberId, BOOL isCompressed, u32 layer, u32 szByte, NNS_G2D_VRAM_TYPE type, u32 baseAddr, HeapID heapId, NNSG2dImageProxy * pImageProxy)
|
||||
{
|
||||
void GfGfxLoader_SetObjCntFlagsAndLoadImageMapping(NarcId narcId, s32 memberId, BOOL isCompressed, u32 layer, u32 szByte, NNS_G2D_VRAM_TYPE type, u32 baseAddr, HeapID heapId, NNSG2dImageProxy *pImageProxy) {
|
||||
static void (*const load_funcs[])(const NNSG2dCharacterData *, u32, NNS_G2D_VRAM_TYPE, NNSG2dImageProxy *) = {
|
||||
NNS_G2dLoadImage1DMapping,
|
||||
NNS_G2dLoadImage2DMapping
|
||||
};
|
||||
NNSG2dCharacterData * pCharacterData;
|
||||
void * pFile = GfGfxLoader_LoadFromNarc(narcId, memberId, isCompressed, heapId, TRUE);
|
||||
if (pFile != NULL)
|
||||
{
|
||||
if (NNS_G2dGetUnpackedCharacterData(pFile, &pCharacterData))
|
||||
{
|
||||
if (szByte != 0)
|
||||
NNSG2dCharacterData *pCharacterData;
|
||||
void *pFile = GfGfxLoader_LoadFromNarc(narcId, memberId, isCompressed, heapId, TRUE);
|
||||
if (pFile != NULL) {
|
||||
if (NNS_G2dGetUnpackedCharacterData(pFile, &pCharacterData)) {
|
||||
if (szByte != 0) {
|
||||
pCharacterData->szByte = szByte;
|
||||
switch (type)
|
||||
{
|
||||
}
|
||||
switch (type) {
|
||||
case NNS_G2D_VRAM_TYPE_2DMAIN:
|
||||
pCharacterData->mapingType = (GXOBJVRamModeChar)(reg_GX_DISPCNT & (REG_GX_DISPCNT_EXOBJ_CH_MASK | REG_GX_DISPCNT_OBJMAP_CH_MASK));
|
||||
break;
|
||||
case NNS_G2D_VRAM_TYPE_2DSUB:
|
||||
pCharacterData->mapingType = (GXOBJVRamModeChar)(reg_GXS_DB_DISPCNT & (REG_GXS_DB_DISPCNT_EXOBJ_MASK | REG_GXS_DB_DISPCNT_OBJMAP_CH_MASK));
|
||||
break;
|
||||
default:
|
||||
;
|
||||
default:;
|
||||
}
|
||||
load_funcs[layer](pCharacterData, baseAddr, type, pImageProxy);
|
||||
}
|
||||
|
|
@ -197,13 +179,10 @@ void GfGfxLoader_SetObjCntFlagsAndLoadImageMapping(NarcId narcId, s32 memberId,
|
|||
}
|
||||
}
|
||||
|
||||
void * GfGfxLoader_GetCharData(NarcId narcId, s32 memberId, BOOL isCompressed, NNSG2dCharacterData ** ppCharData, HeapID heapId)
|
||||
{
|
||||
void * pFile = GfGfxLoader_LoadFromNarc(narcId, memberId, isCompressed, heapId, FALSE);
|
||||
if (pFile != NULL)
|
||||
{
|
||||
if (!NNS_G2dGetUnpackedBGCharacterData(pFile, ppCharData))
|
||||
{
|
||||
void *GfGfxLoader_GetCharData(NarcId narcId, s32 memberId, BOOL isCompressed, NNSG2dCharacterData **ppCharData, HeapID heapId) {
|
||||
void *pFile = GfGfxLoader_LoadFromNarc(narcId, memberId, isCompressed, heapId, FALSE);
|
||||
if (pFile != NULL) {
|
||||
if (!NNS_G2dGetUnpackedBGCharacterData(pFile, ppCharData)) {
|
||||
FreeToHeap(pFile);
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -211,13 +190,10 @@ void * GfGfxLoader_GetCharData(NarcId narcId, s32 memberId, BOOL isCompressed, N
|
|||
return pFile;
|
||||
}
|
||||
|
||||
void * GfGfxLoader_GetScrnData(NarcId narcId, s32 memberId, BOOL isCompressed, NNSG2dScreenData ** ppScrData, HeapID heapId)
|
||||
{
|
||||
void * pFile = GfGfxLoader_LoadFromNarc(narcId, memberId, isCompressed, heapId, FALSE);
|
||||
if (pFile != NULL)
|
||||
{
|
||||
if (!NNS_G2dGetUnpackedScreenData(pFile, ppScrData))
|
||||
{
|
||||
void *GfGfxLoader_GetScrnData(NarcId narcId, s32 memberId, BOOL isCompressed, NNSG2dScreenData **ppScrData, HeapID heapId) {
|
||||
void *pFile = GfGfxLoader_LoadFromNarc(narcId, memberId, isCompressed, heapId, FALSE);
|
||||
if (pFile != NULL) {
|
||||
if (!NNS_G2dGetUnpackedScreenData(pFile, ppScrData)) {
|
||||
FreeToHeap(pFile);
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -225,13 +201,10 @@ void * GfGfxLoader_GetScrnData(NarcId narcId, s32 memberId, BOOL isCompressed, N
|
|||
return pFile;
|
||||
}
|
||||
|
||||
void * GfGfxLoader_GetPlttData(NarcId narcId, s32 memberId, NNSG2dPaletteData ** ppPltData, HeapID heapId)
|
||||
{
|
||||
void * pFile = GfGfxLoader_LoadFromNarc(narcId, memberId, FALSE, heapId, FALSE);
|
||||
if (pFile != NULL)
|
||||
{
|
||||
if (!NNS_G2dGetUnpackedPaletteData(pFile, ppPltData))
|
||||
{
|
||||
void *GfGfxLoader_GetPlttData(NarcId narcId, s32 memberId, NNSG2dPaletteData **ppPltData, HeapID heapId) {
|
||||
void *pFile = GfGfxLoader_LoadFromNarc(narcId, memberId, FALSE, heapId, FALSE);
|
||||
if (pFile != NULL) {
|
||||
if (!NNS_G2dGetUnpackedPaletteData(pFile, ppPltData)) {
|
||||
FreeToHeap(pFile);
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -239,13 +212,10 @@ void * GfGfxLoader_GetPlttData(NarcId narcId, s32 memberId, NNSG2dPaletteData **
|
|||
return pFile;
|
||||
}
|
||||
|
||||
void * GfGfxLoader_GetCellBank(NarcId narcId, s32 memberId, BOOL isCompressed, NNSG2dCellDataBank ** ppCellBank, HeapID heapId)
|
||||
{
|
||||
void * pFile = GfGfxLoader_LoadFromNarc(narcId, memberId, isCompressed, heapId, FALSE);
|
||||
if (pFile != NULL)
|
||||
{
|
||||
if (!NNS_G2dGetUnpackedCellBank(pFile, ppCellBank))
|
||||
{
|
||||
void *GfGfxLoader_GetCellBank(NarcId narcId, s32 memberId, BOOL isCompressed, NNSG2dCellDataBank **ppCellBank, HeapID heapId) {
|
||||
void *pFile = GfGfxLoader_LoadFromNarc(narcId, memberId, isCompressed, heapId, FALSE);
|
||||
if (pFile != NULL) {
|
||||
if (!NNS_G2dGetUnpackedCellBank(pFile, ppCellBank)) {
|
||||
FreeToHeap(pFile);
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -253,13 +223,10 @@ void * GfGfxLoader_GetCellBank(NarcId narcId, s32 memberId, BOOL isCompressed, N
|
|||
return pFile;
|
||||
}
|
||||
|
||||
void * GfGfxLoader_GetAnimBank(NarcId narcId, s32 memberId, BOOL isCompressed, NNSG2dAnimBankData ** ppAnimBank, HeapID heapId)
|
||||
{
|
||||
void * pFile = GfGfxLoader_LoadFromNarc(narcId, memberId, isCompressed, heapId, FALSE);
|
||||
if (pFile != NULL)
|
||||
{
|
||||
if (!NNS_G2dGetUnpackedAnimBank(pFile, ppAnimBank))
|
||||
{
|
||||
void *GfGfxLoader_GetAnimBank(NarcId narcId, s32 memberId, BOOL isCompressed, NNSG2dAnimBankData **ppAnimBank, HeapID heapId) {
|
||||
void *pFile = GfGfxLoader_LoadFromNarc(narcId, memberId, isCompressed, heapId, FALSE);
|
||||
if (pFile != NULL) {
|
||||
if (!NNS_G2dGetUnpackedAnimBank(pFile, ppAnimBank)) {
|
||||
FreeToHeap(pFile);
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -267,40 +234,29 @@ void * GfGfxLoader_GetAnimBank(NarcId narcId, s32 memberId, BOOL isCompressed, N
|
|||
return pFile;
|
||||
}
|
||||
|
||||
void * GfGfxLoader_UncompressFromNarc(NarcId narcId, s32 memberId, HeapID heapId)
|
||||
{
|
||||
void *GfGfxLoader_UncompressFromNarc(NarcId narcId, s32 memberId, HeapID heapId) {
|
||||
return GfGfxLoader_LoadFromNarc(narcId, memberId, TRUE, heapId, FALSE);
|
||||
}
|
||||
|
||||
void * GfGfxLoader_LoadFromNarc(NarcId narcId, s32 memberNo, BOOL isCompressed, HeapID heapId, BOOL allocAtEnd)
|
||||
{
|
||||
void * dest;
|
||||
void * dest2;
|
||||
if (isCompressed || allocAtEnd == TRUE)
|
||||
{
|
||||
void *GfGfxLoader_LoadFromNarc(NarcId narcId, s32 memberNo, BOOL isCompressed, HeapID heapId, BOOL allocAtEnd) {
|
||||
void *dest;
|
||||
void *dest2;
|
||||
if (isCompressed || allocAtEnd == TRUE) {
|
||||
u32 size = GetNarcMemberSizeByIdPair(narcId, memberNo);
|
||||
dest = AllocFromHeapAtEnd(heapId, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
dest = AllocFromHeapAtEnd(heapId, size);
|
||||
} else {
|
||||
u32 size = GetNarcMemberSizeByIdPair(narcId, memberNo);
|
||||
dest = AllocFromHeap(heapId, size);
|
||||
dest = AllocFromHeap(heapId, size);
|
||||
}
|
||||
if (dest != NULL)
|
||||
{
|
||||
if (dest != NULL) {
|
||||
ReadWholeNarcMemberByIdPair(dest, narcId, memberNo);
|
||||
if (isCompressed)
|
||||
{
|
||||
if (allocAtEnd == FALSE)
|
||||
{
|
||||
if (isCompressed) {
|
||||
if (allocAtEnd == FALSE) {
|
||||
dest2 = AllocFromHeap(heapId, (*(u32 *)dest) >> 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
dest2 = AllocFromHeapAtEnd(heapId, (*(u32 *)dest) >> 8);
|
||||
}
|
||||
if (dest2 != NULL)
|
||||
{
|
||||
if (dest2 != NULL) {
|
||||
MI_UncompressLZ8(dest, dest2);
|
||||
FreeToHeap(dest);
|
||||
}
|
||||
|
|
@ -310,35 +266,25 @@ void * GfGfxLoader_LoadFromNarc(NarcId narcId, s32 memberNo, BOOL isCompressed,
|
|||
return dest;
|
||||
}
|
||||
|
||||
void * GfGfxLoader_LoadFromNarc_GetSizeOut(NarcId narcId, s32 memberNo, BOOL isCompressed, HeapID heapId, BOOL allocAtEnd, u32 *size_p)
|
||||
{
|
||||
void * dest;
|
||||
void * dest2;
|
||||
void *GfGfxLoader_LoadFromNarc_GetSizeOut(NarcId narcId, s32 memberNo, BOOL isCompressed, HeapID heapId, BOOL allocAtEnd, u32 *size_p) {
|
||||
void *dest;
|
||||
void *dest2;
|
||||
*size_p = GetNarcMemberSizeByIdPair(narcId, memberNo);
|
||||
if (isCompressed || allocAtEnd == TRUE)
|
||||
{
|
||||
if (isCompressed || allocAtEnd == TRUE) {
|
||||
dest = AllocFromHeapAtEnd(heapId, *size_p);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
dest = AllocFromHeap(heapId, *size_p);
|
||||
}
|
||||
if (dest != NULL)
|
||||
{
|
||||
if (dest != NULL) {
|
||||
ReadWholeNarcMemberByIdPair(dest, narcId, memberNo);
|
||||
if (isCompressed)
|
||||
{
|
||||
if (isCompressed) {
|
||||
*size_p = (*(u32 *)dest) >> 8;
|
||||
if (allocAtEnd == FALSE)
|
||||
{
|
||||
if (allocAtEnd == FALSE) {
|
||||
dest2 = AllocFromHeap(heapId, *size_p);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
dest2 = AllocFromHeapAtEnd(heapId, *size_p);
|
||||
}
|
||||
if (dest2 != NULL)
|
||||
{
|
||||
if (dest2 != NULL) {
|
||||
MI_UncompressLZ8(dest, dest2);
|
||||
FreeToHeap(dest);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#include "global.h"
|
||||
#include "gf_gfx_planes.h"
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "GX_vramcnt.h"
|
||||
#include "gx.h"
|
||||
#include "main.h"
|
||||
|
|
@ -9,8 +11,7 @@
|
|||
static u32 sEngineAPlanes;
|
||||
static u32 sEngineBPlanes;
|
||||
|
||||
void GfGfx_SetBanks(const struct GraphicsBanks *banks)
|
||||
{
|
||||
void GfGfx_SetBanks(const struct GraphicsBanks *banks) {
|
||||
GX_ResetBankForBG();
|
||||
GX_ResetBankForBGExtPltt();
|
||||
GX_ResetBankForSubBG();
|
||||
|
|
@ -34,25 +35,17 @@ void GfGfx_SetBanks(const struct GraphicsBanks *banks)
|
|||
GX_SetBankForTexPltt(banks->texpltt);
|
||||
}
|
||||
|
||||
|
||||
void GfGfx_DisableEngineAPlanes()
|
||||
{
|
||||
void GfGfx_DisableEngineAPlanes() {
|
||||
sEngineAPlanes = 0;
|
||||
}
|
||||
|
||||
void GfGfx_EngineATogglePlanes(u32 layer_mask, GXPlaneToggle layer_toggle)
|
||||
{
|
||||
if (layer_toggle == GX_PLANE_TOGGLE_ON)
|
||||
{
|
||||
if ((sEngineAPlanes & layer_mask) != 0)
|
||||
{
|
||||
void GfGfx_EngineATogglePlanes(u32 layer_mask, GXPlaneToggle layer_toggle) {
|
||||
if (layer_toggle == GX_PLANE_TOGGLE_ON) {
|
||||
if ((sEngineAPlanes & layer_mask) != 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((sEngineAPlanes & layer_mask) == 0)
|
||||
{
|
||||
} else {
|
||||
if ((sEngineAPlanes & layer_mask) == 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -60,30 +53,22 @@ void GfGfx_EngineATogglePlanes(u32 layer_mask, GXPlaneToggle layer_toggle)
|
|||
GX_SetVisiblePlane(sEngineAPlanes ^= layer_mask);
|
||||
}
|
||||
|
||||
void GfGfx_EngineASetPlanes(u32 layer_mask)
|
||||
{
|
||||
void GfGfx_EngineASetPlanes(u32 layer_mask) {
|
||||
sEngineAPlanes = layer_mask;
|
||||
GX_SetVisiblePlane(layer_mask);
|
||||
}
|
||||
|
||||
void GfGfx_DisableEngineBPlanes()
|
||||
{
|
||||
void GfGfx_DisableEngineBPlanes() {
|
||||
sEngineBPlanes = 0;
|
||||
}
|
||||
|
||||
void GfGfx_EngineBTogglePlanes(u32 layer_mask, GXPlaneToggle layer_toggle)
|
||||
{
|
||||
if (layer_toggle == GX_PLANE_TOGGLE_ON)
|
||||
{
|
||||
if ((sEngineBPlanes & layer_mask) != 0)
|
||||
{
|
||||
void GfGfx_EngineBTogglePlanes(u32 layer_mask, GXPlaneToggle layer_toggle) {
|
||||
if (layer_toggle == GX_PLANE_TOGGLE_ON) {
|
||||
if ((sEngineBPlanes & layer_mask) != 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((sEngineBPlanes & layer_mask) == 0)
|
||||
{
|
||||
} else {
|
||||
if ((sEngineBPlanes & layer_mask) == 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -91,25 +76,19 @@ void GfGfx_EngineBTogglePlanes(u32 layer_mask, GXPlaneToggle layer_toggle)
|
|||
GXS_SetVisiblePlane(sEngineBPlanes ^= layer_mask);
|
||||
}
|
||||
|
||||
void GfGfx_BothDispOn()
|
||||
{
|
||||
void GfGfx_BothDispOn() {
|
||||
GX_DispOn();
|
||||
GXS_DispOn();
|
||||
}
|
||||
|
||||
void GfGfx_SwapDisplay()
|
||||
{
|
||||
if (gSystem.screensFlipped == 0)
|
||||
{
|
||||
void GfGfx_SwapDisplay() {
|
||||
if (gSystem.screensFlipped == 0) {
|
||||
GX_SetDispSelect(GX_DISP_SELECT_MAIN_SUB);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
GX_SetDispSelect(GX_DISP_SELECT_SUB_MAIN);
|
||||
}
|
||||
}
|
||||
|
||||
u32 GfGfx_EngineAGetPlanes()
|
||||
{
|
||||
u32 GfGfx_EngineAGetPlanes() {
|
||||
return sEngineAPlanes;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,104 +1,92 @@
|
|||
#include "global.h"
|
||||
#include "MI_memory.h"
|
||||
#include "gf_rtc.h"
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "MI_memory.h"
|
||||
#include "RTC_convert.h"
|
||||
|
||||
typedef struct GF_RTC_Work
|
||||
{
|
||||
typedef struct GF_RTC_Work {
|
||||
BOOL getDateTimeSuccess;
|
||||
BOOL getDateTimeLock;
|
||||
s32 getDateTimeSleep;
|
||||
RTCResult getDateTimeErrorCode;
|
||||
RTCDate date; // 10
|
||||
RTCTime time; // 20
|
||||
RTCDate date; // 10
|
||||
RTCTime time; // 20
|
||||
RTCDate date_async; // 2C
|
||||
RTCTime time_async; // 3C
|
||||
} GF_RTC_Work;
|
||||
|
||||
GF_RTC_Work sGFRTCWork;
|
||||
|
||||
#define MAX_SECONDS (3155759999ll)
|
||||
#define MAX_SECONDS (3155759999ll)
|
||||
|
||||
void GF_RTC_GetDateTime(GF_RTC_Work * work);
|
||||
void GF_RTC_GetDateTime(GF_RTC_Work *work);
|
||||
|
||||
void GF_InitRTCWork(void)
|
||||
{
|
||||
void GF_InitRTCWork(void) {
|
||||
RTC_Init();
|
||||
memset(&sGFRTCWork, 0, sizeof(sGFRTCWork)); //todo: figure out how to use memset
|
||||
memset(&sGFRTCWork, 0, sizeof(sGFRTCWork)); // todo: figure out how to use memset
|
||||
sGFRTCWork.getDateTimeSuccess = FALSE;
|
||||
sGFRTCWork.getDateTimeLock = FALSE;
|
||||
sGFRTCWork.getDateTimeSleep = 0;
|
||||
sGFRTCWork.getDateTimeLock = FALSE;
|
||||
sGFRTCWork.getDateTimeSleep = 0;
|
||||
GF_RTC_GetDateTime(&sGFRTCWork);
|
||||
}
|
||||
|
||||
void GF_RTC_UpdateOnFrame(void)
|
||||
{
|
||||
if (!sGFRTCWork.getDateTimeLock)
|
||||
{
|
||||
if (++sGFRTCWork.getDateTimeSleep > 10)
|
||||
{
|
||||
void GF_RTC_UpdateOnFrame(void) {
|
||||
if (!sGFRTCWork.getDateTimeLock) {
|
||||
if (++sGFRTCWork.getDateTimeSleep > 10) {
|
||||
sGFRTCWork.getDateTimeSleep = 0;
|
||||
GF_RTC_GetDateTime(&sGFRTCWork);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GF_RTC_GetDateTime_Callback(RTCResult result, void * data)
|
||||
{
|
||||
GF_RTC_Work * work = (GF_RTC_Work *)data;
|
||||
void GF_RTC_GetDateTime_Callback(RTCResult result, void *data) {
|
||||
GF_RTC_Work *work = (GF_RTC_Work *)data;
|
||||
work->getDateTimeErrorCode = result;
|
||||
GF_ASSERT(result == RTC_RESULT_SUCCESS);
|
||||
work->getDateTimeSuccess = TRUE;
|
||||
work->date = work->date_async;
|
||||
work->time = work->time_async;
|
||||
work->getDateTimeLock = FALSE;
|
||||
work->date = work->date_async;
|
||||
work->time = work->time_async;
|
||||
work->getDateTimeLock = FALSE;
|
||||
}
|
||||
|
||||
void GF_RTC_GetDateTime(GF_RTC_Work * work)
|
||||
{
|
||||
work->getDateTimeLock = TRUE;
|
||||
RTCResult result = RTC_GetDateTimeAsync(&work->date_async, &work->time_async, GF_RTC_GetDateTime_Callback, work);
|
||||
void GF_RTC_GetDateTime(GF_RTC_Work *work) {
|
||||
work->getDateTimeLock = TRUE;
|
||||
RTCResult result = RTC_GetDateTimeAsync(&work->date_async, &work->time_async, GF_RTC_GetDateTime_Callback, work);
|
||||
work->getDateTimeErrorCode = result;
|
||||
GF_ASSERT(result == RTC_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
void GF_RTC_CopyDateTime(RTCDate * date, RTCTime * time)
|
||||
{
|
||||
void GF_RTC_CopyDateTime(RTCDate *date, RTCTime *time) {
|
||||
GF_ASSERT(sGFRTCWork.getDateTimeSuccess == TRUE);
|
||||
*date = sGFRTCWork.date;
|
||||
*time = sGFRTCWork.time;
|
||||
}
|
||||
|
||||
void GF_RTC_CopyTime(RTCTime * time)
|
||||
{
|
||||
void GF_RTC_CopyTime(RTCTime *time) {
|
||||
GF_ASSERT(sGFRTCWork.getDateTimeSuccess == TRUE);
|
||||
*time = sGFRTCWork.time;
|
||||
}
|
||||
|
||||
void GF_RTC_CopyDate(RTCDate * date)
|
||||
{
|
||||
void GF_RTC_CopyDate(RTCDate *date) {
|
||||
GF_ASSERT(sGFRTCWork.getDateTimeSuccess == TRUE);
|
||||
*date = sGFRTCWork.date;
|
||||
}
|
||||
|
||||
s32 GF_RTC_TimeToSec(void)
|
||||
{
|
||||
RTCTime* time = &sGFRTCWork.time;
|
||||
s32 GF_RTC_TimeToSec(void) {
|
||||
RTCTime *time = &sGFRTCWork.time;
|
||||
return 60 * time->minute + 3600 * time->hour + time->second;
|
||||
}
|
||||
|
||||
s64 GF_RTC_DateTimeToSec(void)
|
||||
{
|
||||
s64 GF_RTC_DateTimeToSec(void) {
|
||||
return RTC_ConvertDateTimeToSecond(&sGFRTCWork.date, &sGFRTCWork.time);
|
||||
}
|
||||
|
||||
static inline BOOL IsLeapYear(s32 year)
|
||||
{
|
||||
static inline BOOL IsLeapYear(s32 year) {
|
||||
return ((year % 4) == 0 && (year % 100) != 0) || ((year % 400) == 0);
|
||||
}
|
||||
|
||||
s32 GF_RTC_GetDayOfYear(const RTCDate * date)
|
||||
{
|
||||
s32 GF_RTC_GetDayOfYear(const RTCDate *date) {
|
||||
RTCDate date_stack;
|
||||
s32 days;
|
||||
static const u16 sGF_DaysPerMonth[] = {
|
||||
|
|
@ -118,63 +106,79 @@ s32 GF_RTC_GetDayOfYear(const RTCDate * date)
|
|||
|
||||
days = date->day;
|
||||
days += sGF_DaysPerMonth[date->month - 1];
|
||||
if (date->month >= RTC_MONTH_MARCH && IsLeapYear(date->year))
|
||||
if (date->month >= RTC_MONTH_MARCH && IsLeapYear(date->year)) {
|
||||
days++;
|
||||
date_stack = *date;
|
||||
}
|
||||
date_stack = *date;
|
||||
date_stack.month = RTC_MONTH_JANUARY;
|
||||
date_stack.day = 1;
|
||||
date_stack.day = 1;
|
||||
RTC_ConvertDateToDay(&date_stack);
|
||||
RTC_ConvertDateToDay(date);
|
||||
return days;
|
||||
}
|
||||
|
||||
BOOL IsNighttime(void)
|
||||
{
|
||||
switch (GF_RTC_GetTimeOfDay())
|
||||
{
|
||||
case RTC_TIMEOFDAY_NITE:
|
||||
case RTC_TIMEOFDAY_LATE:
|
||||
return TRUE;
|
||||
default:
|
||||
return FALSE;
|
||||
BOOL IsNighttime(void) {
|
||||
switch (GF_RTC_GetTimeOfDay()) {
|
||||
case RTC_TIMEOFDAY_NITE:
|
||||
case RTC_TIMEOFDAY_LATE:
|
||||
return TRUE;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
enum RTC_TimeOfDay GF_RTC_GetTimeOfDay(void)
|
||||
{
|
||||
enum RTC_TimeOfDay GF_RTC_GetTimeOfDay(void) {
|
||||
RTCTime time;
|
||||
GF_RTC_CopyTime(&time);
|
||||
return GF_RTC_GetTimeOfDayByHour(time.hour);
|
||||
}
|
||||
|
||||
enum RTC_TimeOfDay GF_RTC_GetTimeOfDayByHour(s32 hour)
|
||||
{
|
||||
enum RTC_TimeOfDay GF_RTC_GetTimeOfDayByHour(s32 hour) {
|
||||
static const u8 sTimeOfDayByHour[] = {
|
||||
// 00:00 - 03:59
|
||||
RTC_TIMEOFDAY_LATE, RTC_TIMEOFDAY_LATE, RTC_TIMEOFDAY_LATE, RTC_TIMEOFDAY_LATE,
|
||||
RTC_TIMEOFDAY_LATE,
|
||||
RTC_TIMEOFDAY_LATE,
|
||||
RTC_TIMEOFDAY_LATE,
|
||||
RTC_TIMEOFDAY_LATE,
|
||||
// 04:00 - 09:59
|
||||
RTC_TIMEOFDAY_MORN, RTC_TIMEOFDAY_MORN, RTC_TIMEOFDAY_MORN, RTC_TIMEOFDAY_MORN, RTC_TIMEOFDAY_MORN, RTC_TIMEOFDAY_MORN,
|
||||
RTC_TIMEOFDAY_MORN,
|
||||
RTC_TIMEOFDAY_MORN,
|
||||
RTC_TIMEOFDAY_MORN,
|
||||
RTC_TIMEOFDAY_MORN,
|
||||
RTC_TIMEOFDAY_MORN,
|
||||
RTC_TIMEOFDAY_MORN,
|
||||
// 10:00 - 16:59
|
||||
RTC_TIMEOFDAY_DAY, RTC_TIMEOFDAY_DAY, RTC_TIMEOFDAY_DAY, RTC_TIMEOFDAY_DAY, RTC_TIMEOFDAY_DAY, RTC_TIMEOFDAY_DAY, RTC_TIMEOFDAY_DAY,
|
||||
RTC_TIMEOFDAY_DAY,
|
||||
RTC_TIMEOFDAY_DAY,
|
||||
RTC_TIMEOFDAY_DAY,
|
||||
RTC_TIMEOFDAY_DAY,
|
||||
RTC_TIMEOFDAY_DAY,
|
||||
RTC_TIMEOFDAY_DAY,
|
||||
RTC_TIMEOFDAY_DAY,
|
||||
// 17:00 - 19:59
|
||||
RTC_TIMEOFDAY_EVE, RTC_TIMEOFDAY_EVE, RTC_TIMEOFDAY_EVE,
|
||||
RTC_TIMEOFDAY_EVE,
|
||||
RTC_TIMEOFDAY_EVE,
|
||||
RTC_TIMEOFDAY_EVE,
|
||||
// 20:00 - 23:59
|
||||
RTC_TIMEOFDAY_NITE, RTC_TIMEOFDAY_NITE, RTC_TIMEOFDAY_NITE, RTC_TIMEOFDAY_NITE,
|
||||
RTC_TIMEOFDAY_NITE,
|
||||
RTC_TIMEOFDAY_NITE,
|
||||
RTC_TIMEOFDAY_NITE,
|
||||
RTC_TIMEOFDAY_NITE,
|
||||
};
|
||||
|
||||
GF_ASSERT(hour >= 0 && hour < 24);
|
||||
return (enum RTC_TimeOfDay)sTimeOfDayByHour[hour];
|
||||
}
|
||||
|
||||
s64 GF_RTC_TimeDelta(s64 first, s64 last)
|
||||
{
|
||||
s64 GF_RTC_TimeDelta(s64 first, s64 last) {
|
||||
RTCDate maxDate = { 99, 12, 31, RTC_WEEK_SUNDAY };
|
||||
RTCTime maxTime = { 23, 59, 59 };
|
||||
|
||||
s64 check = RTC_ConvertDateTimeToSecond(&maxDate, &maxTime);
|
||||
GF_ASSERT(check == MAX_SECONDS);
|
||||
if (first < last)
|
||||
if (first < last) {
|
||||
return last - first;
|
||||
else
|
||||
} else {
|
||||
return last + (MAX_SECONDS - first);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,146 +1,139 @@
|
|||
#include "hall_of_fame.h"
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "MI_memory.h"
|
||||
#include "RTC_api.h"
|
||||
#include "heap.h"
|
||||
#include "party.h"
|
||||
#include "pokemon.h"
|
||||
#include "save.h"
|
||||
#include "MI_memory.h"
|
||||
#include "party.h"
|
||||
#include "string16.h"
|
||||
#include "RTC_api.h"
|
||||
#include "hall_of_fame.h"
|
||||
#include "heap.h"
|
||||
|
||||
u32 Save_HOF_sizeof(void)
|
||||
{
|
||||
u32 Save_HOF_sizeof(void) {
|
||||
return sizeof(struct HallOfFame);
|
||||
}
|
||||
|
||||
void Save_HOF_Init(struct HallOfFame * hof)
|
||||
{
|
||||
void Save_HOF_Init(struct HallOfFame *hof) {
|
||||
MI_CpuClear32(hof, sizeof(struct HallOfFame));
|
||||
}
|
||||
|
||||
void Save_HOF_RecordParty(struct HallOfFame * hof, struct Party * party, RTCDate * date)
|
||||
{
|
||||
void Save_HOF_RecordParty(struct HallOfFame *hof, struct Party *party, RTCDate *date) {
|
||||
GF_ASSERT(hof != NULL);
|
||||
GF_ASSERT(hof->next_record < NUM_HOF_RECORDS);
|
||||
if (hof->num_total < 9999)
|
||||
{
|
||||
struct HOFParty * hof_party = &hof->parties[hof->next_record];
|
||||
int nmons = Party_GetCount(party);
|
||||
struct String * str = String_New(POKEMON_NAME_LENGTH + 1, HEAP_ID_DEFAULT);
|
||||
if (hof->num_total < 9999) {
|
||||
struct HOFParty *hof_party = &hof->parties[hof->next_record];
|
||||
int nmons = Party_GetCount(party);
|
||||
struct String *str = String_New(POKEMON_NAME_LENGTH + 1, HEAP_ID_DEFAULT);
|
||||
MI_CpuClear16(hof_party->party, 6 * sizeof(struct HOFMon));
|
||||
int i, j;
|
||||
for (i = 0, j = 0; i < nmons; i++)
|
||||
{
|
||||
struct Pokemon * mon = Party_GetMonByIndex(party, i);
|
||||
BOOL lock = AcquireMonLock(mon);
|
||||
if (!GetMonData(mon, MON_DATA_IS_EGG, NULL))
|
||||
{
|
||||
hof_party->party[j].species = (u16)GetMonData(mon, MON_DATA_SPECIES, NULL);
|
||||
hof_party->party[j].level = (u8)GetMonData(mon, MON_DATA_LEVEL, NULL);
|
||||
hof_party->party[j].form = (u8)GetMonData(mon, MON_DATA_FORM, NULL);
|
||||
for (i = 0, j = 0; i < nmons; i++) {
|
||||
struct Pokemon *mon = Party_GetMonByIndex(party, i);
|
||||
BOOL lock = AcquireMonLock(mon);
|
||||
if (!GetMonData(mon, MON_DATA_IS_EGG, NULL)) {
|
||||
hof_party->party[j].species = (u16)GetMonData(mon, MON_DATA_SPECIES, NULL);
|
||||
hof_party->party[j].level = (u8)GetMonData(mon, MON_DATA_LEVEL, NULL);
|
||||
hof_party->party[j].form = (u8)GetMonData(mon, MON_DATA_FORM, NULL);
|
||||
hof_party->party[j].personality = GetMonData(mon, MON_DATA_PERSONALITY, NULL);
|
||||
hof_party->party[j].otid = GetMonData(mon, MON_DATA_OTID, NULL);
|
||||
hof_party->party[j].moves[0] = (u16)GetMonData(mon, MON_DATA_MOVE1, NULL);
|
||||
hof_party->party[j].moves[1] = (u16)GetMonData(mon, MON_DATA_MOVE2, NULL);
|
||||
hof_party->party[j].moves[2] = (u16)GetMonData(mon, MON_DATA_MOVE3, NULL);
|
||||
hof_party->party[j].moves[3] = (u16)GetMonData(mon, MON_DATA_MOVE4, NULL);
|
||||
if (str != NULL)
|
||||
{
|
||||
hof_party->party[j].otid = GetMonData(mon, MON_DATA_OTID, NULL);
|
||||
hof_party->party[j].moves[0] = (u16)GetMonData(mon, MON_DATA_MOVE1, NULL);
|
||||
hof_party->party[j].moves[1] = (u16)GetMonData(mon, MON_DATA_MOVE2, NULL);
|
||||
hof_party->party[j].moves[2] = (u16)GetMonData(mon, MON_DATA_MOVE3, NULL);
|
||||
hof_party->party[j].moves[3] = (u16)GetMonData(mon, MON_DATA_MOVE4, NULL);
|
||||
if (str != NULL) {
|
||||
GetMonData(mon, MON_DATA_NICKNAME_3, str);
|
||||
CopyStringToU16Array(str, hof_party->party[j].nickname, POKEMON_NAME_LENGTH + 1);
|
||||
GetMonData(mon, MON_DATA_OT_NAME_2, str);
|
||||
CopyStringToU16Array(str, hof_party->party[j].otname, PLAYER_NAME_LENGTH + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
hof_party->party[j].nickname[0] = EOS;
|
||||
hof_party->party[j].otname[0] = EOS;
|
||||
hof_party->party[j].otname[0] = EOS;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
ReleaseMonLock(mon, lock);
|
||||
}
|
||||
hof_party->year = (u16)date->year;
|
||||
hof_party->year = (u16)date->year;
|
||||
hof_party->month = (u8)date->month;
|
||||
hof_party->day = (u8)date->day;
|
||||
hof_party->day = (u8)date->day;
|
||||
hof->next_record++;
|
||||
if (hof->next_record >= NUM_HOF_RECORDS)
|
||||
if (hof->next_record >= NUM_HOF_RECORDS) {
|
||||
hof->next_record = 0;
|
||||
}
|
||||
hof->num_total++;
|
||||
if (str != NULL)
|
||||
if (str != NULL) {
|
||||
String_Delete(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
u32 Save_HOF_GetNumRecords(struct HallOfFame * hof)
|
||||
{
|
||||
u32 Save_HOF_GetNumRecords(struct HallOfFame *hof) {
|
||||
GF_ASSERT(hof != NULL);
|
||||
GF_ASSERT(hof->next_record < NUM_HOF_RECORDS);
|
||||
if (hof->num_total < NUM_HOF_RECORDS)
|
||||
if (hof->num_total < NUM_HOF_RECORDS) {
|
||||
return hof->num_total;
|
||||
else
|
||||
} else {
|
||||
return NUM_HOF_RECORDS;
|
||||
}
|
||||
}
|
||||
|
||||
int Save_HOF_TranslateRecordIdx(struct HallOfFame * hof, int a1)
|
||||
{
|
||||
int Save_HOF_TranslateRecordIdx(struct HallOfFame *hof, int a1) {
|
||||
GF_ASSERT(hof != NULL);
|
||||
GF_ASSERT(hof->next_record < NUM_HOF_RECORDS);
|
||||
GF_ASSERT(a1 < NUM_HOF_RECORDS);
|
||||
return (int)(hof->num_total - a1);
|
||||
}
|
||||
|
||||
u32 Save_HOF_RecordCountMons(struct HallOfFame * hof, int a1)
|
||||
{
|
||||
u32 Save_HOF_RecordCountMons(struct HallOfFame *hof, int a1) {
|
||||
GF_ASSERT(hof != NULL);
|
||||
GF_ASSERT(hof->next_record < NUM_HOF_RECORDS);
|
||||
GF_ASSERT(a1 < NUM_HOF_RECORDS);
|
||||
int hofno = (int)(hof->next_record - 1 - a1);
|
||||
if (hofno < 0)
|
||||
if (hofno < 0) {
|
||||
hofno += NUM_HOF_RECORDS;
|
||||
struct HOFParty * hof_party = &hof->parties[hofno];
|
||||
}
|
||||
struct HOFParty *hof_party = &hof->parties[hofno];
|
||||
u32 i;
|
||||
for (i = 0; i < 6; i++)
|
||||
{
|
||||
if (hof_party->party[i].species == SPECIES_NONE)
|
||||
for (i = 0; i < 6; i++) {
|
||||
if (hof_party->party[i].species == SPECIES_NONE) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
void Save_HOF_GetMonStatsByIndexPair(struct HallOfFame * hof, int a1, int a2, struct HofDisplayMon * dest)
|
||||
{
|
||||
void Save_HOF_GetMonStatsByIndexPair(struct HallOfFame *hof, int a1, int a2, struct HofDisplayMon *dest) {
|
||||
GF_ASSERT(hof != NULL);
|
||||
GF_ASSERT(hof->next_record < NUM_HOF_RECORDS);
|
||||
GF_ASSERT(a1 < NUM_HOF_RECORDS);
|
||||
int hofno = (int)(hof->next_record - 1 - a1);
|
||||
if (hofno < 0)
|
||||
if (hofno < 0) {
|
||||
hofno += NUM_HOF_RECORDS;
|
||||
struct HOFMon * mon = &hof->parties[hofno].party[a2];
|
||||
dest->species = mon->species;
|
||||
dest->level = mon->level;
|
||||
dest->personality = mon->personality;
|
||||
dest->otid = mon->otid;
|
||||
dest->form = mon->form;
|
||||
}
|
||||
struct HOFMon *mon = &hof->parties[hofno].party[a2];
|
||||
dest->species = mon->species;
|
||||
dest->level = mon->level;
|
||||
dest->personality = mon->personality;
|
||||
dest->otid = mon->otid;
|
||||
dest->form = mon->form;
|
||||
CopyU16ArrayToString(dest->nickname, mon->nickname);
|
||||
CopyU16ArrayToString(dest->otname, mon->otname);
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
for (int i = 0; i < 4; i++) {
|
||||
dest->moves[i] = mon->moves[i];
|
||||
}
|
||||
}
|
||||
|
||||
void Save_HOF_GetClearDate(struct HallOfFame * hof, int a1, RTCDate * dest)
|
||||
{
|
||||
void Save_HOF_GetClearDate(struct HallOfFame *hof, int a1, RTCDate *dest) {
|
||||
GF_ASSERT(hof != NULL);
|
||||
GF_ASSERT(hof->next_record < NUM_HOF_RECORDS);
|
||||
GF_ASSERT(a1 < NUM_HOF_RECORDS);
|
||||
int hofno = (int)(hof->next_record - 1 - a1);
|
||||
if (hofno < 0)
|
||||
if (hofno < 0) {
|
||||
hofno += NUM_HOF_RECORDS;
|
||||
}
|
||||
struct HOFParty *party = &hof->parties[hofno];
|
||||
dest->year = party->year;
|
||||
dest->month = party->month;
|
||||
dest->day = party->day;
|
||||
dest->week = RTC_WEEK_SUNDAY;
|
||||
dest->year = party->year;
|
||||
dest->month = party->month;
|
||||
dest->day = party->day;
|
||||
dest->week = RTC_WEEK_SUNDAY;
|
||||
}
|
||||
|
|
|
|||
248
arm9/src/heap.c
248
arm9/src/heap.c
|
|
@ -1,12 +1,13 @@
|
|||
#include "global.h"
|
||||
#include "heap.h"
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "NNS_FND_allocator.h"
|
||||
#include "NNS_FND_expheap.h"
|
||||
#include "error_message_reset.h"
|
||||
#include "unk_02031734.h"
|
||||
#include "NNS_FND_expheap.h"
|
||||
#include "NNS_FND_allocator.h"
|
||||
|
||||
struct HeapInfo
|
||||
{
|
||||
struct HeapInfo {
|
||||
NNSFndHeapHandle *heapHandles;
|
||||
NNSFndHeapHandle *parentHeapHandles;
|
||||
void **subHeapRawPtrs;
|
||||
|
|
@ -18,60 +19,52 @@ struct HeapInfo
|
|||
u16 unallocatedHeapId;
|
||||
};
|
||||
|
||||
typedef struct MemoryBlock
|
||||
{
|
||||
typedef struct MemoryBlock {
|
||||
u8 filler_00[12];
|
||||
u32 heapId:8;
|
||||
u32 filler_0D:24;
|
||||
u32 heapId : 8;
|
||||
u32 filler_0D : 24;
|
||||
} MemoryBlock;
|
||||
|
||||
struct HeapInfo sHeapInfo;
|
||||
|
||||
void InitHeapSystem(const struct HeapParam *templates, u32 nTemplates, u32 totalNumHeaps, u32 pre_size)
|
||||
{
|
||||
void * ptr;
|
||||
void InitHeapSystem(const struct HeapParam *templates, u32 nTemplates, u32 totalNumHeaps, u32 pre_size) {
|
||||
void *ptr;
|
||||
u32 unk_size, i;
|
||||
|
||||
unk_size = nTemplates + 24;
|
||||
|
||||
if (totalNumHeaps < unk_size)
|
||||
{
|
||||
if (totalNumHeaps < unk_size) {
|
||||
totalNumHeaps = unk_size;
|
||||
}
|
||||
if (pre_size != 0)
|
||||
{
|
||||
if (pre_size != 0) {
|
||||
// force align
|
||||
while (pre_size % 4 != 0)
|
||||
{
|
||||
while (pre_size % 4 != 0) {
|
||||
pre_size++;
|
||||
}
|
||||
|
||||
OS_AllocFromArenaLo(OS_ARENA_MAIN, pre_size, 4);
|
||||
}
|
||||
|
||||
sHeapInfo.heapHandles = (NNSFndHeapHandle*) OS_AllocFromArenaLo(
|
||||
sHeapInfo.heapHandles = (NNSFndHeapHandle *)OS_AllocFromArenaLo(
|
||||
OS_ARENA_MAIN,
|
||||
(unk_size + 1) * sizeof(NNSFndHeapHandle)
|
||||
+ unk_size * sizeof(NNSFndHeapHandle)
|
||||
+ unk_size * sizeof(void *)
|
||||
+ totalNumHeaps * sizeof(u16)
|
||||
+ totalNumHeaps,
|
||||
4
|
||||
);
|
||||
+ unk_size * sizeof(NNSFndHeapHandle)
|
||||
+ unk_size * sizeof(void *)
|
||||
+ totalNumHeaps * sizeof(u16)
|
||||
+ totalNumHeaps,
|
||||
4);
|
||||
sHeapInfo.parentHeapHandles = sHeapInfo.heapHandles + (unk_size + 1);
|
||||
sHeapInfo.subHeapRawPtrs = (void **)(sHeapInfo.parentHeapHandles + unk_size);
|
||||
sHeapInfo.numMemBlocks = (u16 *)(sHeapInfo.subHeapRawPtrs + unk_size);
|
||||
sHeapInfo.heapIdxs = (u8 *)(sHeapInfo.numMemBlocks + totalNumHeaps);
|
||||
sHeapInfo.totalNumHeaps = (u16)totalNumHeaps;
|
||||
sHeapInfo.nTemplates = (u16)nTemplates;
|
||||
sHeapInfo.subHeapRawPtrs = (void **)(sHeapInfo.parentHeapHandles + unk_size);
|
||||
sHeapInfo.numMemBlocks = (u16 *)(sHeapInfo.subHeapRawPtrs + unk_size);
|
||||
sHeapInfo.heapIdxs = (u8 *)(sHeapInfo.numMemBlocks + totalNumHeaps);
|
||||
sHeapInfo.totalNumHeaps = (u16)totalNumHeaps;
|
||||
sHeapInfo.nTemplates = (u16)nTemplates;
|
||||
|
||||
sHeapInfo.unallocatedHeapId = (u16)unk_size;
|
||||
sHeapInfo.maxHeaps = (u16)unk_size;
|
||||
sHeapInfo.maxHeaps = (u16)unk_size;
|
||||
|
||||
for (i = 0; i < nTemplates; i++)
|
||||
{
|
||||
switch (templates[i].arena)
|
||||
{
|
||||
for (i = 0; i < nTemplates; i++) {
|
||||
switch (templates[i].arena) {
|
||||
case OS_ARENA_MAIN:
|
||||
default:
|
||||
ptr = OS_AllocFromArenaLo(OS_ARENA_MAIN, templates[i].size, 4);
|
||||
|
|
@ -81,146 +74,114 @@ void InitHeapSystem(const struct HeapParam *templates, u32 nTemplates, u32 total
|
|||
break;
|
||||
}
|
||||
|
||||
if (ptr != NULL)
|
||||
{
|
||||
if (ptr != NULL) {
|
||||
|
||||
sHeapInfo.heapHandles[i] = NNS_FndCreateExpHeap(ptr, templates[i].size);
|
||||
sHeapInfo.heapIdxs[i] = (u8)i;
|
||||
}
|
||||
else
|
||||
{
|
||||
sHeapInfo.heapIdxs[i] = (u8)i;
|
||||
} else {
|
||||
GF_ASSERT(0);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = nTemplates; i < unk_size + 1; i++)
|
||||
{
|
||||
for (i = nTemplates; i < unk_size + 1; i++) {
|
||||
sHeapInfo.heapHandles[i] = NULL;
|
||||
sHeapInfo.heapIdxs[i] = (u8)sHeapInfo.unallocatedHeapId;
|
||||
sHeapInfo.heapIdxs[i] = (u8)sHeapInfo.unallocatedHeapId;
|
||||
}
|
||||
|
||||
while (i < totalNumHeaps)
|
||||
{
|
||||
while (i < totalNumHeaps) {
|
||||
sHeapInfo.heapIdxs[i] = (u8)sHeapInfo.unallocatedHeapId;
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
for (i = 0; i < totalNumHeaps; i++)
|
||||
{
|
||||
for (i = 0; i < totalNumHeaps; i++) {
|
||||
sHeapInfo.numMemBlocks[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
s32 FindFirstAvailableHeapHandle(void)
|
||||
{
|
||||
s32 FindFirstAvailableHeapHandle(void) {
|
||||
s32 i;
|
||||
|
||||
for (i = sHeapInfo.nTemplates; i < sHeapInfo.maxHeaps; i++)
|
||||
{
|
||||
if (sHeapInfo.heapHandles[i] == NULL)
|
||||
for (i = sHeapInfo.nTemplates; i < sHeapInfo.maxHeaps; i++) {
|
||||
if (sHeapInfo.heapHandles[i] == NULL) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
BOOL CreateHeap(u32 parent, u32 child, u32 size)
|
||||
{
|
||||
BOOL CreateHeap(u32 parent, u32 child, u32 size) {
|
||||
return CreateHeapInternal(parent, child, size, 4);
|
||||
}
|
||||
|
||||
BOOL CreateHeapAtEnd(u32 parent, u32 child, u32 size)
|
||||
{
|
||||
BOOL CreateHeapAtEnd(u32 parent, u32 child, u32 size) {
|
||||
return CreateHeapInternal(parent, child, size, -4);
|
||||
}
|
||||
|
||||
BOOL CreateHeapInternal(u32 parent, u32 child, u32 size, s32 alignment)
|
||||
{
|
||||
BOOL CreateHeapInternal(u32 parent, u32 child, u32 size, s32 alignment) {
|
||||
GF_ASSERT(OS_GetProcMode() != OS_PROCMODE_IRQ);
|
||||
|
||||
u8 *ptr = sHeapInfo.heapIdxs;
|
||||
if (sHeapInfo.unallocatedHeapId == ptr[child])
|
||||
{
|
||||
if (sHeapInfo.unallocatedHeapId == ptr[child]) {
|
||||
NNSFndHeapHandle parentHeap = sHeapInfo.heapHandles[ptr[parent]];
|
||||
if (parentHeap != NULL)
|
||||
{
|
||||
if (parentHeap != NULL) {
|
||||
void *newHeapAddr = NNS_FndAllocFromExpHeapEx(parentHeap, size, alignment);
|
||||
if (newHeapAddr != NULL)
|
||||
{
|
||||
if (newHeapAddr != NULL) {
|
||||
s32 i = FindFirstAvailableHeapHandle();
|
||||
if (i >= 0)
|
||||
{
|
||||
if (i >= 0) {
|
||||
sHeapInfo.heapHandles[i] = NNS_FndCreateExpHeap(newHeapAddr, size);
|
||||
|
||||
|
||||
if (sHeapInfo.heapHandles[i] != NULL)
|
||||
{
|
||||
if (sHeapInfo.heapHandles[i] != NULL) {
|
||||
sHeapInfo.parentHeapHandles[i] = parentHeap;
|
||||
sHeapInfo.subHeapRawPtrs[i] = newHeapAddr;
|
||||
sHeapInfo.heapIdxs[child] = (u8)i;
|
||||
sHeapInfo.subHeapRawPtrs[i] = newHeapAddr;
|
||||
sHeapInfo.heapIdxs[child] = (u8)i;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
GF_ASSERT(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
GF_ASSERT(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
GF_ASSERT(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
GF_ASSERT(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
GF_ASSERT(0);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void DestroyHeap(HeapID heapId)
|
||||
{
|
||||
void DestroyHeap(HeapID heapId) {
|
||||
GF_ASSERT(OS_GetProcMode() != OS_PROCMODE_IRQ);
|
||||
|
||||
NNSFndHeapHandle handle = sHeapInfo.heapHandles[sHeapInfo.heapIdxs[heapId]];
|
||||
|
||||
if (handle != NULL)
|
||||
{
|
||||
if (handle != NULL) {
|
||||
NNS_FndDestroyExpHeap(handle);
|
||||
|
||||
u8 index = sHeapInfo.heapIdxs[heapId];
|
||||
u8 index = sHeapInfo.heapIdxs[heapId];
|
||||
NNSFndHeapHandle parentHeap = sHeapInfo.parentHeapHandles[index];
|
||||
void *childRaw = sHeapInfo.subHeapRawPtrs[index];
|
||||
if (parentHeap != NULL && childRaw != NULL)
|
||||
{
|
||||
void *childRaw = sHeapInfo.subHeapRawPtrs[index];
|
||||
if (parentHeap != NULL && childRaw != NULL) {
|
||||
NNS_FndFreeToExpHeap(parentHeap, childRaw);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
GF_ASSERT(0);
|
||||
}
|
||||
|
||||
sHeapInfo.heapHandles[sHeapInfo.heapIdxs[heapId]] = NULL;
|
||||
sHeapInfo.heapHandles[sHeapInfo.heapIdxs[heapId]] = NULL;
|
||||
sHeapInfo.parentHeapHandles[sHeapInfo.heapIdxs[heapId]] = NULL;
|
||||
sHeapInfo.subHeapRawPtrs[sHeapInfo.heapIdxs[heapId]] = NULL;
|
||||
sHeapInfo.subHeapRawPtrs[sHeapInfo.heapIdxs[heapId]] = NULL;
|
||||
|
||||
sHeapInfo.heapIdxs[heapId] = (u8)sHeapInfo.unallocatedHeapId;
|
||||
}
|
||||
}
|
||||
|
||||
void *AllocFromHeapInternal(NNSFndHeapHandle heap, u32 size, s32 alignment, HeapID heapId)
|
||||
{
|
||||
void *AllocFromHeapInternal(NNSFndHeapHandle heap, u32 size, s32 alignment, HeapID heapId) {
|
||||
GF_ASSERT(heap);
|
||||
|
||||
OSIntrMode intr_mode = OS_DisableInterrupts();
|
||||
|
|
@ -228,8 +189,7 @@ void *AllocFromHeapInternal(NNSFndHeapHandle heap, u32 size, s32 alignment, Heap
|
|||
void *ptr = NNS_FndAllocFromExpHeapEx(heap, size, alignment);
|
||||
|
||||
OS_RestoreInterrupts(intr_mode);
|
||||
if (ptr != NULL)
|
||||
{
|
||||
if (ptr != NULL) {
|
||||
((MemoryBlock *)ptr)->heapId = heapId;
|
||||
|
||||
ptr += sizeof(MemoryBlock);
|
||||
|
|
@ -238,68 +198,53 @@ void *AllocFromHeapInternal(NNSFndHeapHandle heap, u32 size, s32 alignment, Heap
|
|||
return ptr;
|
||||
}
|
||||
|
||||
void AllocFail(void)
|
||||
{
|
||||
if (sub_02031810() != 0)
|
||||
{
|
||||
void AllocFail(void) {
|
||||
if (sub_02031810() != 0) {
|
||||
PrintErrorMessageAndReset();
|
||||
}
|
||||
}
|
||||
|
||||
void *AllocFromHeap(HeapID heapId, u32 size)
|
||||
{
|
||||
void *AllocFromHeap(HeapID heapId, u32 size) {
|
||||
void *ptr = NULL;
|
||||
if ((u32)heapId < sHeapInfo.totalNumHeaps)
|
||||
{
|
||||
if ((u32)heapId < sHeapInfo.totalNumHeaps) {
|
||||
u8 index = sHeapInfo.heapIdxs[heapId];
|
||||
ptr = AllocFromHeapInternal(sHeapInfo.heapHandles[index], size, 4, heapId);
|
||||
ptr = AllocFromHeapInternal(sHeapInfo.heapHandles[index], size, 4, heapId);
|
||||
}
|
||||
if (ptr != NULL)
|
||||
{
|
||||
if (ptr != NULL) {
|
||||
sHeapInfo.numMemBlocks[heapId]++;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
AllocFail();
|
||||
}
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void *AllocFromHeapAtEnd(HeapID heapId, u32 size)
|
||||
{
|
||||
void *AllocFromHeapAtEnd(HeapID heapId, u32 size) {
|
||||
void *ptr = NULL;
|
||||
if ((u32)heapId < sHeapInfo.totalNumHeaps)
|
||||
{
|
||||
if ((u32)heapId < sHeapInfo.totalNumHeaps) {
|
||||
u8 index = sHeapInfo.heapIdxs[heapId];
|
||||
ptr = AllocFromHeapInternal(sHeapInfo.heapHandles[index], size, -4, heapId);
|
||||
ptr = AllocFromHeapInternal(sHeapInfo.heapHandles[index], size, -4, heapId);
|
||||
}
|
||||
|
||||
if (ptr != NULL)
|
||||
{
|
||||
if (ptr != NULL) {
|
||||
sHeapInfo.numMemBlocks[heapId]++;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
AllocFail();
|
||||
}
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void FreeToHeap(void *ptr)
|
||||
{
|
||||
void FreeToHeap(void *ptr) {
|
||||
ptr -= sizeof(MemoryBlock);
|
||||
HeapID heapId = (HeapID)(((MemoryBlock *)ptr)->heapId);
|
||||
|
||||
if ((u32)heapId < sHeapInfo.totalNumHeaps)
|
||||
{
|
||||
u8 index = sHeapInfo.heapIdxs[heapId];
|
||||
if ((u32)heapId < sHeapInfo.totalNumHeaps) {
|
||||
u8 index = sHeapInfo.heapIdxs[heapId];
|
||||
NNSFndHeapHandle heap = sHeapInfo.heapHandles[index];
|
||||
GF_ASSERT(heap != NULL);
|
||||
|
||||
if (sHeapInfo.numMemBlocks[heapId] == 0)
|
||||
{
|
||||
if (sHeapInfo.numMemBlocks[heapId] == 0) {
|
||||
GF_heap_c_dummy_return_true(heapId);
|
||||
}
|
||||
GF_ASSERT(sHeapInfo.numMemBlocks[heapId] != 0);
|
||||
|
|
@ -314,15 +259,13 @@ void FreeToHeap(void *ptr)
|
|||
GF_ASSERT(0);
|
||||
}
|
||||
|
||||
void FreeToHeapExplicit(HeapID heapId, void *ptr)
|
||||
{
|
||||
void FreeToHeapExplicit(HeapID heapId, void *ptr) {
|
||||
GF_ASSERT(OS_GetProcMode() != OS_PROCMODE_IRQ);
|
||||
|
||||
if ((u32)heapId < sHeapInfo.totalNumHeaps)
|
||||
{
|
||||
u8 index = sHeapInfo.heapIdxs[heapId];
|
||||
if ((u32)heapId < sHeapInfo.totalNumHeaps) {
|
||||
u8 index = sHeapInfo.heapIdxs[heapId];
|
||||
NNSFndHeapHandle heap = sHeapInfo.heapHandles[index];
|
||||
GF_ASSERT( heap != NULL );
|
||||
GF_ASSERT(heap != NULL);
|
||||
|
||||
ptr -= sizeof(MemoryBlock);
|
||||
GF_ASSERT(((MemoryBlock *)ptr)->heapId == heapId);
|
||||
|
|
@ -337,10 +280,8 @@ void FreeToHeapExplicit(HeapID heapId, void *ptr)
|
|||
GF_ASSERT(0);
|
||||
}
|
||||
|
||||
u32 GF_ExpHeap_FndGetTotalFreeSize(HeapID heapId)
|
||||
{
|
||||
if ((u32)heapId < sHeapInfo.totalNumHeaps)
|
||||
{
|
||||
u32 GF_ExpHeap_FndGetTotalFreeSize(HeapID heapId) {
|
||||
if ((u32)heapId < sHeapInfo.totalNumHeaps) {
|
||||
u8 index = sHeapInfo.heapIdxs[heapId];
|
||||
return NNS_FndGetTotalFreeSizeForExpHeap(sHeapInfo.heapHandles[index]);
|
||||
}
|
||||
|
|
@ -349,10 +290,8 @@ u32 GF_ExpHeap_FndGetTotalFreeSize(HeapID heapId)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void GF_ExpHeap_FndInitAllocator(NNSFndAllocator * pAllocator, HeapID heapId, int alignment)
|
||||
{
|
||||
if ((u32)heapId < sHeapInfo.totalNumHeaps)
|
||||
{
|
||||
void GF_ExpHeap_FndInitAllocator(NNSFndAllocator *pAllocator, HeapID heapId, int alignment) {
|
||||
if ((u32)heapId < sHeapInfo.totalNumHeaps) {
|
||||
|
||||
u8 index = sHeapInfo.heapIdxs[heapId];
|
||||
NNS_FndInitAllocatorForExpHeap(pAllocator, sHeapInfo.heapHandles[index], alignment);
|
||||
|
|
@ -362,15 +301,13 @@ void GF_ExpHeap_FndInitAllocator(NNSFndAllocator * pAllocator, HeapID heapId, in
|
|||
GF_ASSERT(0);
|
||||
}
|
||||
|
||||
void ReallocFromHeap(void *ptr, u32 newSize)
|
||||
{
|
||||
void ReallocFromHeap(void *ptr, u32 newSize) {
|
||||
GF_ASSERT(OS_GetProcMode() != OS_PROCMODE_IRQ);
|
||||
|
||||
newSize += sizeof(MemoryBlock);
|
||||
ptr -= sizeof(MemoryBlock);
|
||||
if (NNS_FndGetSizeForMBlockExpHeap(ptr) >= newSize)
|
||||
{
|
||||
u32 heapId = ((MemoryBlock *)ptr)->heapId; //purposefully left as u32, using HeapID casues fuckery with regalloc
|
||||
if (NNS_FndGetSizeForMBlockExpHeap(ptr) >= newSize) {
|
||||
u32 heapId = ((MemoryBlock *)ptr)->heapId; // purposefully left as u32, using HeapID casues fuckery with regalloc
|
||||
|
||||
u8 index = sHeapInfo.heapIdxs[heapId];
|
||||
|
||||
|
|
@ -380,8 +317,7 @@ void ReallocFromHeap(void *ptr, u32 newSize)
|
|||
GF_ASSERT(0);
|
||||
}
|
||||
|
||||
BOOL GF_heap_c_dummy_return_true(HeapID heapId)
|
||||
{
|
||||
BOOL GF_heap_c_dummy_return_true(HeapID heapId) {
|
||||
#pragma unused(heapId)
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,48 +1,43 @@
|
|||
#include "global.h"
|
||||
#include "igt.h"
|
||||
|
||||
void InitIGT(struct IGT * igt)
|
||||
{
|
||||
igt->hours = 0;
|
||||
#include "global.h"
|
||||
|
||||
void InitIGT(struct IGT *igt) {
|
||||
igt->hours = 0;
|
||||
igt->minutes = 0;
|
||||
igt->seconds = 0;
|
||||
}
|
||||
|
||||
void AddIGTSeconds(struct IGT * igt, u32 to_add)
|
||||
{
|
||||
void AddIGTSeconds(struct IGT *igt, u32 to_add) {
|
||||
u32 hours, minutes, seconds;
|
||||
if (igt->hours == 999 && igt->minutes == 59 && igt->seconds == 59)
|
||||
if (igt->hours == 999 && igt->minutes == 59 && igt->seconds == 59) {
|
||||
return;
|
||||
}
|
||||
seconds = (u32)(igt->seconds + to_add);
|
||||
minutes = (u32)igt->minutes;
|
||||
hours = (u32)igt->hours;
|
||||
if (seconds > 59)
|
||||
{
|
||||
hours = (u32)igt->hours;
|
||||
if (seconds > 59) {
|
||||
minutes += seconds / 60;
|
||||
seconds %= 60;
|
||||
if (minutes > 59)
|
||||
{
|
||||
if (minutes > 59) {
|
||||
hours += minutes / 60;
|
||||
minutes %= 60;
|
||||
if (hours >= 999)
|
||||
{
|
||||
hours = 999;
|
||||
if (hours >= 999) {
|
||||
hours = 999;
|
||||
minutes = 59;
|
||||
seconds = 59;
|
||||
}
|
||||
}
|
||||
}
|
||||
igt->hours = (u16)hours;
|
||||
igt->hours = (u16)hours;
|
||||
igt->minutes = (u8)minutes;
|
||||
igt->seconds = (u8)seconds;
|
||||
}
|
||||
|
||||
u16 GetIGTHours(struct IGT * igt)
|
||||
{
|
||||
u16 GetIGTHours(struct IGT *igt) {
|
||||
return igt->hours;
|
||||
}
|
||||
|
||||
u8 GetIGTMinutes(struct IGT * igt)
|
||||
{
|
||||
u8 GetIGTMinutes(struct IGT *igt) {
|
||||
return igt->minutes;
|
||||
}
|
||||
|
|
|
|||
1129
arm9/src/itemtool.c
1129
arm9/src/itemtool.c
File diff suppressed because it is too large
Load Diff
|
|
@ -1,35 +1,37 @@
|
|||
#include "list_menu.h"
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "font.h"
|
||||
#include "heap.h"
|
||||
#include "main.h"
|
||||
#include "list_menu.h"
|
||||
#include "text.h"
|
||||
#include "font.h"
|
||||
|
||||
void ListMenuPrintEntries(struct ListMenu * list, u16 startIndex, u16 yOffset, u16 count);
|
||||
void ListMenuDrawCursor(struct ListMenu * list);
|
||||
BOOL ListMenuChangeSelection(struct ListMenu * list, u8 updateCursorAndCallCallback, u8 count, u8 movingDown);
|
||||
void ListMenuCallSelectionChangedCallback(struct ListMenu * list, u8 onInit);
|
||||
void ListMenuPrintEntries(struct ListMenu *list, u16 startIndex, u16 yOffset, u16 count);
|
||||
void ListMenuDrawCursor(struct ListMenu *list);
|
||||
BOOL ListMenuChangeSelection(struct ListMenu *list, u8 updateCursorAndCallCallback, u8 count, u8 movingDown);
|
||||
void ListMenuCallSelectionChangedCallback(struct ListMenu *list, u8 onInit);
|
||||
|
||||
struct ListMenu * ListMenuInit(const struct ListMenuTemplate * template, u16 cursorPos, u16 itemsAbove, u8 heapId)
|
||||
{
|
||||
struct ListMenu * list = AllocFromHeap((HeapID)heapId, sizeof(struct ListMenu));
|
||||
list->template = *template;
|
||||
list->cursor = ListMenuCursorNew((HeapID)heapId);
|
||||
list->cursorPos = cursorPos;
|
||||
list->itemsAbove = itemsAbove;
|
||||
list->unk_30 = 0;
|
||||
list->unk_31 = 0;
|
||||
list->taskId = 0xFF;
|
||||
list->unk_33 = 0;
|
||||
list->heapId = heapId;
|
||||
list->cursorPal = list->template.cursorPal;
|
||||
list->fillValue = list->template.fillValue;
|
||||
struct ListMenu *ListMenuInit(const struct ListMenuTemplate *template, u16 cursorPos, u16 itemsAbove, u8 heapId) {
|
||||
struct ListMenu *list = AllocFromHeap((HeapID)heapId, sizeof(struct ListMenu));
|
||||
list->template = *template;
|
||||
list->cursor = ListMenuCursorNew((HeapID)heapId);
|
||||
list->cursorPos = cursorPos;
|
||||
list->itemsAbove = itemsAbove;
|
||||
list->unk_30 = 0;
|
||||
list->unk_31 = 0;
|
||||
list->taskId = 0xFF;
|
||||
list->unk_33 = 0;
|
||||
list->heapId = heapId;
|
||||
list->cursorPal = list->template.cursorPal;
|
||||
list->fillValue = list->template.fillValue;
|
||||
list->cursorShadowPal = list->template.cursorShadowPal;
|
||||
list->lettersSpacing = list->template.lettersSpacing;
|
||||
list->fontId = list->template.fontId;
|
||||
list->lettersSpacing = list->template.lettersSpacing;
|
||||
list->fontId = list->template.fontId;
|
||||
list->overrideEnabled = FALSE;
|
||||
if (list->template.totalItems < list->template.maxShowed)
|
||||
if (list->template.totalItems < list->template.maxShowed) {
|
||||
list->template.maxShowed = list->template.totalItems;
|
||||
}
|
||||
ListMenuCursorSetColor(list->cursor, MAKE_TEXT_COLOR(list->template.cursorPal, list->template.cursorShadowPal, list->template.fillValue));
|
||||
FillWindowPixelBuffer(list->template.window, list->template.fillValue);
|
||||
ListMenuPrintEntries(list, list->cursorPos, 0, list->template.maxShowed);
|
||||
|
|
@ -39,150 +41,131 @@ struct ListMenu * ListMenuInit(const struct ListMenuTemplate * template, u16 cur
|
|||
return list;
|
||||
}
|
||||
|
||||
s32 ListMenu_ProcessInput(struct ListMenu * list)
|
||||
{
|
||||
s32 ListMenu_ProcessInput(struct ListMenu *list) {
|
||||
list->unk_33 = 0;
|
||||
|
||||
if (gSystem.newKeys & REG_PAD_KEYINPUT_A_MASK) {
|
||||
return list->template.items[list->cursorPos + list->itemsAbove].value;
|
||||
}
|
||||
else if (gSystem.newKeys & REG_PAD_KEYINPUT_B_MASK) {
|
||||
} else if (gSystem.newKeys & REG_PAD_KEYINPUT_B_MASK) {
|
||||
return LIST_CANCEL;
|
||||
}
|
||||
else if (gSystem.newAndRepeatedKeys & REG_PAD_KEYINPUT_UP_MASK) {
|
||||
if (!ListMenuChangeSelection(list, TRUE, 1, FALSE))
|
||||
} else if (gSystem.newAndRepeatedKeys & REG_PAD_KEYINPUT_UP_MASK) {
|
||||
if (!ListMenuChangeSelection(list, TRUE, 1, FALSE)) {
|
||||
list->unk_33 = 1;
|
||||
}
|
||||
return LIST_NOTHING_CHOSEN;
|
||||
}
|
||||
else if (gSystem.newAndRepeatedKeys & REG_PAD_KEYINPUT_DOWN_MASK) {
|
||||
if (!ListMenuChangeSelection(list, TRUE, 1, TRUE))
|
||||
} else if (gSystem.newAndRepeatedKeys & REG_PAD_KEYINPUT_DOWN_MASK) {
|
||||
if (!ListMenuChangeSelection(list, TRUE, 1, TRUE)) {
|
||||
list->unk_33 = 2;
|
||||
}
|
||||
return LIST_NOTHING_CHOSEN;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
u16 rightButton, leftButton;
|
||||
switch (list->template.scrollMultiple)
|
||||
{
|
||||
switch (list->template.scrollMultiple) {
|
||||
case LIST_NO_MULTIPLE_SCROLL:
|
||||
default:
|
||||
leftButton = FALSE;
|
||||
leftButton = FALSE;
|
||||
rightButton = FALSE;
|
||||
break;
|
||||
case LIST_MULTIPLE_SCROLL_DPAD:
|
||||
leftButton = (u16)(gSystem.newAndRepeatedKeys & REG_PAD_KEYINPUT_LEFT_MASK);
|
||||
leftButton = (u16)(gSystem.newAndRepeatedKeys & REG_PAD_KEYINPUT_LEFT_MASK);
|
||||
rightButton = (u16)(gSystem.newAndRepeatedKeys & REG_PAD_KEYINPUT_RIGHT_MASK);
|
||||
break;
|
||||
case LIST_MULTIPLE_SCROLL_L_R:
|
||||
leftButton = (u16)(gSystem.newAndRepeatedKeys & REG_PAD_KEYINPUT_L_MASK);
|
||||
leftButton = (u16)(gSystem.newAndRepeatedKeys & REG_PAD_KEYINPUT_L_MASK);
|
||||
rightButton = (u16)(gSystem.newAndRepeatedKeys & REG_PAD_KEYINPUT_R_MASK);
|
||||
break;
|
||||
}
|
||||
if (leftButton)
|
||||
{
|
||||
if (!ListMenuChangeSelection(list, TRUE, (u8)list->template.maxShowed, FALSE))
|
||||
if (leftButton) {
|
||||
if (!ListMenuChangeSelection(list, TRUE, (u8)list->template.maxShowed, FALSE)) {
|
||||
list->unk_33 = 3;
|
||||
}
|
||||
return LIST_NOTHING_CHOSEN;
|
||||
}
|
||||
else if (rightButton)
|
||||
{
|
||||
if (!ListMenuChangeSelection(list, TRUE, (u8)list->template.maxShowed, TRUE))
|
||||
} else if (rightButton) {
|
||||
if (!ListMenuChangeSelection(list, TRUE, (u8)list->template.maxShowed, TRUE)) {
|
||||
list->unk_33 = 4;
|
||||
}
|
||||
return LIST_NOTHING_CHOSEN;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return LIST_NOTHING_CHOSEN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DestroyListMenu(struct ListMenu * list, u16 * cursorPos, u16 * itemsAbove)
|
||||
{
|
||||
if (cursorPos != NULL)
|
||||
void DestroyListMenu(struct ListMenu *list, u16 *cursorPos, u16 *itemsAbove) {
|
||||
if (cursorPos != NULL) {
|
||||
*cursorPos = list->cursorPos;
|
||||
if (itemsAbove != NULL)
|
||||
}
|
||||
if (itemsAbove != NULL) {
|
||||
*itemsAbove = list->itemsAbove;
|
||||
}
|
||||
DestroyListMenuCursorObj(list->cursor);
|
||||
FreeToHeapExplicit((HeapID)list->heapId, list);
|
||||
}
|
||||
|
||||
void RedrawListMenu(struct ListMenu * list)
|
||||
{
|
||||
void RedrawListMenu(struct ListMenu *list) {
|
||||
FillWindowPixelBuffer(list->template.window, list->template.fillValue);
|
||||
ListMenuPrintEntries(list, list->cursorPos, 0, list->template.maxShowed);
|
||||
ListMenuDrawCursor(list);
|
||||
CopyWindowToVram(list->template.window);
|
||||
}
|
||||
|
||||
s32 ListMenuTestInputInternal(struct ListMenu * list, const struct ListMenuTemplate * template, u16 cursorPos, u16 itemsAbove, u16 updateFlag, u16 input, u16 *newCursorPos, u16 *newItemsAbove)
|
||||
{
|
||||
if (template != NULL)
|
||||
s32 ListMenuTestInputInternal(struct ListMenu *list, const struct ListMenuTemplate *template, u16 cursorPos, u16 itemsAbove, u16 updateFlag, u16 input, u16 *newCursorPos, u16 *newItemsAbove) {
|
||||
if (template != NULL) {
|
||||
list->template = *template;
|
||||
list->cursorPos = cursorPos;
|
||||
list->itemsAbove = itemsAbove;
|
||||
list->unk_30 = 0;
|
||||
list->unk_31 = 0;
|
||||
|
||||
if (input == REG_PAD_KEYINPUT_UP_MASK)
|
||||
{
|
||||
ListMenuChangeSelection(list, (u8)updateFlag, 1, FALSE);
|
||||
}
|
||||
else if (input == REG_PAD_KEYINPUT_DOWN_MASK)
|
||||
{
|
||||
list->cursorPos = cursorPos;
|
||||
list->itemsAbove = itemsAbove;
|
||||
list->unk_30 = 0;
|
||||
list->unk_31 = 0;
|
||||
|
||||
if (input == REG_PAD_KEYINPUT_UP_MASK) {
|
||||
ListMenuChangeSelection(list, (u8)updateFlag, 1, FALSE);
|
||||
} else if (input == REG_PAD_KEYINPUT_DOWN_MASK) {
|
||||
ListMenuChangeSelection(list, (u8)updateFlag, 1, TRUE);
|
||||
}
|
||||
if (newCursorPos != NULL)
|
||||
{
|
||||
if (newCursorPos != NULL) {
|
||||
*newCursorPos = list->cursorPos;
|
||||
}
|
||||
if (newItemsAbove != NULL)
|
||||
{
|
||||
if (newItemsAbove != NULL) {
|
||||
*newItemsAbove = list->itemsAbove;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
s32 ListMenuTestInput(struct ListMenu * list, const struct ListMenuTemplate * template, u16 cursorPos, u16 itemsAbove, u16 input, u16 *newCursorPos, u16 *newItemsAbove)
|
||||
{
|
||||
s32 ListMenuTestInput(struct ListMenu *list, const struct ListMenuTemplate *template, u16 cursorPos, u16 itemsAbove, u16 input, u16 *newCursorPos, u16 *newItemsAbove) {
|
||||
return ListMenuTestInputInternal(list, template, cursorPos, itemsAbove, FALSE, input, newCursorPos, newItemsAbove);
|
||||
}
|
||||
|
||||
void ListMenuOverrideSetColors(struct ListMenu * list, u8 cursorPal, u8 fillValue, u8 cursorShadowPal)
|
||||
{
|
||||
list->cursorPal = cursorPal;
|
||||
list->fillValue = fillValue;
|
||||
void ListMenuOverrideSetColors(struct ListMenu *list, u8 cursorPal, u8 fillValue, u8 cursorShadowPal) {
|
||||
list->cursorPal = cursorPal;
|
||||
list->fillValue = fillValue;
|
||||
list->cursorShadowPal = cursorShadowPal;
|
||||
list->overrideEnabled = TRUE;
|
||||
}
|
||||
|
||||
void ListMenuGetCurrentItemArrayId(struct ListMenu * list, u16 * index_p)
|
||||
{
|
||||
void ListMenuGetCurrentItemArrayId(struct ListMenu *list, u16 *index_p) {
|
||||
*index_p = (u16)(list->cursorPos + list->itemsAbove);
|
||||
}
|
||||
|
||||
void ListMenuGetScrollAndRow(struct ListMenu * list, u16 * cursorPos_p, u16 * itemsAbove_p)
|
||||
{
|
||||
if (cursorPos_p != NULL)
|
||||
void ListMenuGetScrollAndRow(struct ListMenu *list, u16 *cursorPos_p, u16 *itemsAbove_p) {
|
||||
if (cursorPos_p != NULL) {
|
||||
*cursorPos_p = list->cursorPos;
|
||||
if (itemsAbove_p != NULL)
|
||||
}
|
||||
if (itemsAbove_p != NULL) {
|
||||
*itemsAbove_p = list->itemsAbove;
|
||||
}
|
||||
}
|
||||
|
||||
u8 ListMenuGetUnk33(struct ListMenu * list)
|
||||
{
|
||||
u8 ListMenuGetUnk33(struct ListMenu *list) {
|
||||
return list->unk_33;
|
||||
}
|
||||
|
||||
s32 ListMenuGetValueByArrayId(struct ListMenu * list, s32 index)
|
||||
{
|
||||
s32 ListMenuGetValueByArrayId(struct ListMenu *list, s32 index) {
|
||||
return list->template.items[index].value;
|
||||
}
|
||||
|
||||
s32 ListMenuGetTemplateField(struct ListMenu * list, u32 attr)
|
||||
{
|
||||
switch (attr)
|
||||
{
|
||||
s32 ListMenuGetTemplateField(struct ListMenu *list, u32 attr) {
|
||||
switch (attr) {
|
||||
case 0:
|
||||
return (s32)list->template.moveCursorFunc;
|
||||
case 1:
|
||||
|
|
@ -228,10 +211,8 @@ s32 ListMenuGetTemplateField(struct ListMenu * list, u32 attr)
|
|||
return -1;
|
||||
}
|
||||
|
||||
void ListMenuSetTemplateField(struct ListMenu * list, u32 attr, s32 value)
|
||||
{
|
||||
switch (attr)
|
||||
{
|
||||
void ListMenuSetTemplateField(struct ListMenu *list, u32 attr, s32 value) {
|
||||
switch (attr) {
|
||||
case 0:
|
||||
list->template.moveCursorFunc = (LM_MoveCursorFunc_t)value;
|
||||
break;
|
||||
|
|
@ -293,53 +274,45 @@ void ListMenuSetTemplateField(struct ListMenu * list, u32 attr, s32 value)
|
|||
}
|
||||
}
|
||||
|
||||
void ListMenuGetItemStr(struct ListMenu * list, struct ListMenuItem * items)
|
||||
{
|
||||
void ListMenuGetItemStr(struct ListMenu *list, struct ListMenuItem *items) {
|
||||
list->template.items = items;
|
||||
}
|
||||
|
||||
void ListMenuPrint(struct ListMenu * list, struct String * str, u8 x, u8 y)
|
||||
{
|
||||
if (str != NULL)
|
||||
{
|
||||
if (list->overrideEnabled)
|
||||
{
|
||||
void ListMenuPrint(struct ListMenu *list, struct String *str, u8 x, u8 y) {
|
||||
if (str != NULL) {
|
||||
if (list->overrideEnabled) {
|
||||
AddTextPrinterParameterized3(list->template.window, list->fontId, str, x, y, 0xFF, MAKE_TEXT_COLOR(list->cursorPal, list->cursorShadowPal, list->fillValue), list->lettersSpacing, 0, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
AddTextPrinterParameterized3(list->template.window, list->template.fontId, str, x, y, 0xFF, MAKE_TEXT_COLOR(list->template.cursorPal, list->template.cursorShadowPal, list->template.fillValue), list->template.lettersSpacing, 0, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ListMenuPrintEntries(struct ListMenu * list, u16 startIndex, u16 yOffset, u16 count)
|
||||
{
|
||||
void ListMenuPrintEntries(struct ListMenu *list, u16 startIndex, u16 yOffset, u16 count) {
|
||||
s32 i;
|
||||
u8 x, y;
|
||||
u8 yMultiplier = (u8)(GetFontAttribute((u8)list->template.fontId, 1) + list->template.itemVerticalPadding);
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
if (list->template.items[startIndex].value != LIST_HEADER)
|
||||
for (i = 0; i < count; i++) {
|
||||
if (list->template.items[startIndex].value != LIST_HEADER) {
|
||||
x = list->template.item_X;
|
||||
else
|
||||
} else {
|
||||
x = list->template.header_X;
|
||||
}
|
||||
y = (u8)((yOffset + i) * yMultiplier + list->template.upText_Y);
|
||||
if (list->template.itemPrintFunc != NULL)
|
||||
if (list->template.itemPrintFunc != NULL) {
|
||||
list->template.itemPrintFunc(list, list->template.items[startIndex].value, y);
|
||||
}
|
||||
ListMenuPrint(list, list->template.items[startIndex].text, x, y);
|
||||
startIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
void ListMenuDrawCursor(struct ListMenu * list)
|
||||
{
|
||||
void ListMenuDrawCursor(struct ListMenu *list) {
|
||||
u8 yMultiplier = (u8)(GetFontAttribute((u8)list->template.fontId, 1) + list->template.itemVerticalPadding);
|
||||
u8 x = list->template.cursor_X;
|
||||
u8 y = (u8)(list->itemsAbove * yMultiplier + list->template.upText_Y);
|
||||
switch (list->template.cursorKind)
|
||||
{
|
||||
u8 x = list->template.cursor_X;
|
||||
u8 y = (u8)(list->itemsAbove * yMultiplier + list->template.upText_Y);
|
||||
switch (list->template.cursorKind) {
|
||||
case 0:
|
||||
ListMenuUpdateCursorObj(list->cursor, list->template.window, x, y);
|
||||
break;
|
||||
|
|
@ -350,20 +323,18 @@ void ListMenuDrawCursor(struct ListMenu * list)
|
|||
}
|
||||
}
|
||||
|
||||
void ListMenuErasePrintedCursor(struct ListMenu * list, u16 itemsAbove)
|
||||
{
|
||||
switch (list->template.cursorKind)
|
||||
{
|
||||
void ListMenuErasePrintedCursor(struct ListMenu *list, u16 itemsAbove) {
|
||||
switch (list->template.cursorKind) {
|
||||
case 0:
|
||||
u8 yMultiplier = (u8)(GetFontAttribute(list->template.fontId, 1) + list->template.itemVerticalPadding);
|
||||
u8 width = 8;
|
||||
u8 height = 16;
|
||||
u8 width = 8;
|
||||
u8 height = 16;
|
||||
FillWindowPixelRect(list->template.window,
|
||||
list->template.fillValue,
|
||||
list->template.cursor_X,
|
||||
(u16)(itemsAbove * yMultiplier + list->template.upText_Y),
|
||||
width,
|
||||
height);
|
||||
list->template.fillValue,
|
||||
list->template.cursor_X,
|
||||
(u16)(itemsAbove * yMultiplier + list->template.upText_Y),
|
||||
width,
|
||||
height);
|
||||
break;
|
||||
case 1:
|
||||
case 2: // leftover
|
||||
|
|
@ -372,115 +343,95 @@ void ListMenuErasePrintedCursor(struct ListMenu * list, u16 itemsAbove)
|
|||
}
|
||||
}
|
||||
|
||||
u8 ListMenuUpdateSelectedRowIndexAndScrollOffset(struct ListMenu *list, u8 movingDown)
|
||||
{
|
||||
u8 ListMenuUpdateSelectedRowIndexAndScrollOffset(struct ListMenu *list, u8 movingDown) {
|
||||
u32 cursorPos;
|
||||
u16 itemsAbove;
|
||||
u16 newRow;
|
||||
|
||||
itemsAbove = list->itemsAbove;
|
||||
cursorPos = list->cursorPos;
|
||||
cursorPos = list->cursorPos;
|
||||
|
||||
if (!movingDown)
|
||||
{
|
||||
if (list->template.maxShowed == 1)
|
||||
if (!movingDown) {
|
||||
if (list->template.maxShowed == 1) {
|
||||
newRow = 0;
|
||||
else
|
||||
} else {
|
||||
newRow = (u16)(list->template.maxShowed - ((list->template.maxShowed / 2) + (list->template.maxShowed % 2)) - 1);
|
||||
}
|
||||
|
||||
if (cursorPos == 0)
|
||||
{
|
||||
while (itemsAbove != 0)
|
||||
{
|
||||
if (cursorPos == 0) {
|
||||
while (itemsAbove != 0) {
|
||||
itemsAbove--;
|
||||
if (list->template.items[cursorPos + itemsAbove].value != LIST_HEADER)
|
||||
{
|
||||
if (list->template.items[cursorPos + itemsAbove].value != LIST_HEADER) {
|
||||
list->itemsAbove = itemsAbove;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (itemsAbove > newRow)
|
||||
{
|
||||
} else {
|
||||
while (itemsAbove > newRow) {
|
||||
itemsAbove--;
|
||||
if (list->template.items[cursorPos + itemsAbove].value != LIST_HEADER)
|
||||
{
|
||||
if (list->template.items[cursorPos + itemsAbove].value != LIST_HEADER) {
|
||||
list->itemsAbove = itemsAbove;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
list->itemsAbove = newRow;
|
||||
list->cursorPos = (u16)(cursorPos - 1);
|
||||
list->cursorPos = (u16)(cursorPos - 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (list->template.maxShowed == 1)
|
||||
} else {
|
||||
if (list->template.maxShowed == 1) {
|
||||
newRow = 0;
|
||||
else
|
||||
} else {
|
||||
newRow = (u16)((list->template.maxShowed / 2) + (list->template.maxShowed % 2));
|
||||
}
|
||||
|
||||
if (cursorPos == list->template.totalItems - list->template.maxShowed)
|
||||
{
|
||||
while (itemsAbove < list->template.maxShowed - 1)
|
||||
{
|
||||
if (cursorPos == list->template.totalItems - list->template.maxShowed) {
|
||||
while (itemsAbove < list->template.maxShowed - 1) {
|
||||
itemsAbove++;
|
||||
if (list->template.items[cursorPos + itemsAbove].value != LIST_HEADER)
|
||||
{
|
||||
if (list->template.items[cursorPos + itemsAbove].value != LIST_HEADER) {
|
||||
list->itemsAbove = itemsAbove;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (itemsAbove < newRow)
|
||||
{
|
||||
} else {
|
||||
while (itemsAbove < newRow) {
|
||||
itemsAbove++;
|
||||
if (list->template.items[cursorPos + itemsAbove].value != LIST_HEADER)
|
||||
{
|
||||
if (list->template.items[cursorPos + itemsAbove].value != LIST_HEADER) {
|
||||
list->itemsAbove = itemsAbove;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
list->itemsAbove = newRow;
|
||||
list->cursorPos = (u16)(cursorPos + 1);
|
||||
list->cursorPos = (u16)(cursorPos + 1);
|
||||
}
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
|
||||
void ListMenuScroll(struct ListMenu * list, u8 count, u8 movingDown)
|
||||
{
|
||||
if (count >= list->template.maxShowed)
|
||||
{
|
||||
void ListMenuScroll(struct ListMenu *list, u8 count, u8 movingDown) {
|
||||
if (count >= list->template.maxShowed) {
|
||||
FillWindowPixelBuffer(list->template.window, list->template.fillValue);
|
||||
ListMenuPrintEntries(list, list->cursorPos, 0, list->template.maxShowed);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
u8 yMultiplier = (u8)(GetFontAttribute((u8)list->template.fontId, 1) + list->template.itemVerticalPadding);
|
||||
|
||||
if (!movingDown)
|
||||
{
|
||||
if (!movingDown) {
|
||||
u16 y, width, height;
|
||||
|
||||
ScrollWindow(list->template.window, 1, (u8)(count * yMultiplier), (u8)((list->template.fillValue << 4) | list->template.fillValue));
|
||||
ListMenuPrintEntries(list, list->cursorPos, 0, count);
|
||||
|
||||
y = (u16)((list->template.maxShowed * yMultiplier) + list->template.upText_Y);
|
||||
width = GetWindowWidth(list->template.window);
|
||||
y = (u16)((list->template.maxShowed * yMultiplier) + list->template.upText_Y);
|
||||
width = GetWindowWidth(list->template.window);
|
||||
height = GetWindowHeight(list->template.window);
|
||||
FillWindowPixelRect(list->template.window,
|
||||
list->template.fillValue,
|
||||
0, y, (u16)(width * 8), (u16)(height * 8 - y));
|
||||
}
|
||||
else
|
||||
{
|
||||
list->template.fillValue,
|
||||
0,
|
||||
y,
|
||||
(u16)(width * 8),
|
||||
(u16)(height * 8 - y));
|
||||
} else {
|
||||
u32 width;
|
||||
|
||||
ScrollWindow(list->template.window, 0, (u8)(count * yMultiplier), (u8)((list->template.fillValue << 4) | list->template.fillValue));
|
||||
|
|
@ -488,38 +439,36 @@ void ListMenuScroll(struct ListMenu * list, u8 count, u8 movingDown)
|
|||
|
||||
width = GetWindowWidth(list->template.window);
|
||||
FillWindowPixelRect(list->template.window,
|
||||
list->template.fillValue,
|
||||
0, 0, (u16)(width * 8), list->template.upText_Y);
|
||||
list->template.fillValue,
|
||||
0,
|
||||
0,
|
||||
(u16)(width * 8),
|
||||
list->template.upText_Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BOOL ListMenuChangeSelection(struct ListMenu * list, u8 updateCursorAndCallCallback, u8 count, u8 movingDown)
|
||||
{
|
||||
BOOL ListMenuChangeSelection(struct ListMenu *list, u8 updateCursorAndCallCallback, u8 count, u8 movingDown) {
|
||||
u16 oldSelectedRow;
|
||||
u8 selectionChange, i, cursorCount;
|
||||
|
||||
oldSelectedRow = list->itemsAbove;
|
||||
cursorCount = 0;
|
||||
oldSelectedRow = list->itemsAbove;
|
||||
cursorCount = 0;
|
||||
selectionChange = 0;
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
do
|
||||
{
|
||||
for (i = 0; i < count; i++) {
|
||||
do {
|
||||
u8 ret = ListMenuUpdateSelectedRowIndexAndScrollOffset(list, movingDown);
|
||||
|
||||
selectionChange |= ret;
|
||||
if (ret != 2)
|
||||
if (ret != 2) {
|
||||
break;
|
||||
}
|
||||
cursorCount++;
|
||||
}
|
||||
while (list->template.items[list->cursorPos + list->itemsAbove].value == LIST_HEADER);
|
||||
} while (list->template.items[list->cursorPos + list->itemsAbove].value == LIST_HEADER);
|
||||
}
|
||||
|
||||
if (updateCursorAndCallCallback)
|
||||
{
|
||||
switch (selectionChange)
|
||||
{
|
||||
if (updateCursorAndCallCallback) {
|
||||
switch (selectionChange) {
|
||||
case 0:
|
||||
default:
|
||||
return TRUE;
|
||||
|
|
@ -542,15 +491,12 @@ BOOL ListMenuChangeSelection(struct ListMenu * list, u8 updateCursorAndCallCallb
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
void ListMenuCallSelectionChangedCallback(struct ListMenu * list, u8 onInit)
|
||||
{
|
||||
if (list->template.moveCursorFunc != NULL)
|
||||
{
|
||||
void ListMenuCallSelectionChangedCallback(struct ListMenu *list, u8 onInit) {
|
||||
if (list->template.moveCursorFunc != NULL) {
|
||||
list->template.moveCursorFunc(list, list->template.items[list->cursorPos + list->itemsAbove].value, onInit);
|
||||
}
|
||||
}
|
||||
|
||||
void ListMenuCopyToVram(struct ListMenu * list)
|
||||
{
|
||||
void ListMenuCopyToVram(struct ListMenu *list) {
|
||||
CopyWindowToVram(list->template.window);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,73 +1,62 @@
|
|||
#include "global.h"
|
||||
#include "list_menu_items.h"
|
||||
#include "msgdata.h"
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "heap.h"
|
||||
#include "msgdata.h"
|
||||
|
||||
void ListMenuItems_DestroyMenuStrings(struct ListMenuItem * items);
|
||||
void ListMenuItems_DestroyMenuStrings(struct ListMenuItem *items);
|
||||
|
||||
struct ListMenuItem * ListMenuItems_New(u32 count, HeapID heapId)
|
||||
{
|
||||
struct ListMenuItem *ListMenuItems_New(u32 count, HeapID heapId) {
|
||||
s32 i;
|
||||
struct ListMenuItem * ret = AllocFromHeap(heapId, (count + 1) * sizeof(struct ListMenuItem));
|
||||
if (ret != NULL)
|
||||
{
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
ret[i].text = NULL;
|
||||
struct ListMenuItem *ret = AllocFromHeap(heapId, (count + 1) * sizeof(struct ListMenuItem));
|
||||
if (ret != NULL) {
|
||||
for (i = 0; i < count; i++) {
|
||||
ret[i].text = NULL;
|
||||
ret[i].value = 0;
|
||||
}
|
||||
ret[i].text = (struct String *)-1u;
|
||||
ret[i].text = (struct String *)-1u;
|
||||
ret[i].value = (s32)heapId;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ListMenuItems_Delete(struct ListMenuItem * items)
|
||||
{
|
||||
void ListMenuItems_Delete(struct ListMenuItem *items) {
|
||||
ListMenuItems_DestroyMenuStrings(items);
|
||||
FreeToHeap(items);
|
||||
}
|
||||
|
||||
void ListMenuItems_AppendFromMsgData(struct ListMenuItem * items, struct MsgData * msgData, u32 msgNo, s32 value)
|
||||
{
|
||||
void ListMenuItems_AppendFromMsgData(struct ListMenuItem *items, struct MsgData *msgData, u32 msgNo, s32 value) {
|
||||
HeapID heapId;
|
||||
struct ListMenuItem * newItem = ListMenuItems_SeekEnd(items, &heapId);
|
||||
if (newItem != NULL)
|
||||
{
|
||||
newItem->text = NewString_ReadMsgData(msgData, msgNo);
|
||||
struct ListMenuItem *newItem = ListMenuItems_SeekEnd(items, &heapId);
|
||||
if (newItem != NULL) {
|
||||
newItem->text = NewString_ReadMsgData(msgData, msgNo);
|
||||
newItem->value = value;
|
||||
}
|
||||
}
|
||||
|
||||
void ListMenuItems_AddItem(struct ListMenuItem * items, struct String * str, s32 value)
|
||||
{
|
||||
void ListMenuItems_AddItem(struct ListMenuItem *items, struct String *str, s32 value) {
|
||||
HeapID heapId;
|
||||
struct ListMenuItem * newItem = ListMenuItems_SeekEnd(items, &heapId);
|
||||
if (newItem != NULL)
|
||||
{
|
||||
newItem->text = StringDup(str, heapId);
|
||||
struct ListMenuItem *newItem = ListMenuItems_SeekEnd(items, &heapId);
|
||||
if (newItem != NULL) {
|
||||
newItem->text = StringDup(str, heapId);
|
||||
newItem->value = value;
|
||||
}
|
||||
}
|
||||
|
||||
void ListMenuItems_CopyItem(struct ListMenuItem * items, struct ListMenuItem * src)
|
||||
{
|
||||
void ListMenuItems_CopyItem(struct ListMenuItem *items, struct ListMenuItem *src) {
|
||||
HeapID heapId;
|
||||
struct ListMenuItem * newItem = ListMenuItems_SeekEnd(items, &heapId);
|
||||
if (newItem != NULL)
|
||||
{
|
||||
newItem->text = src->text;
|
||||
struct ListMenuItem *newItem = ListMenuItems_SeekEnd(items, &heapId);
|
||||
if (newItem != NULL) {
|
||||
newItem->text = src->text;
|
||||
newItem->value = src->value;
|
||||
}
|
||||
}
|
||||
|
||||
struct ListMenuItem * ListMenuItems_SeekEnd(struct ListMenuItem * items, HeapID *heapIdPtr)
|
||||
{
|
||||
struct ListMenuItem * ret;
|
||||
for (; items->text != NULL; items++)
|
||||
{
|
||||
if (items->text == (struct String *)-1u)
|
||||
{
|
||||
struct ListMenuItem *ListMenuItems_SeekEnd(struct ListMenuItem *items, HeapID *heapIdPtr) {
|
||||
struct ListMenuItem *ret;
|
||||
for (; items->text != NULL; items++) {
|
||||
if (items->text == (struct String *)-1u) {
|
||||
GF_ASSERT(0);
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -79,13 +68,12 @@ struct ListMenuItem * ListMenuItems_SeekEnd(struct ListMenuItem * items, HeapID
|
|||
return ret;
|
||||
}
|
||||
|
||||
void ListMenuItems_DestroyMenuStrings(struct ListMenuItem * items)
|
||||
{
|
||||
void ListMenuItems_DestroyMenuStrings(struct ListMenuItem *items) {
|
||||
s32 i;
|
||||
for (i = 0; items[i].text != (struct String *)-1u; i++)
|
||||
{
|
||||
if (items[i].text == NULL)
|
||||
for (i = 0; items[i].text != (struct String *)-1u; i++) {
|
||||
if (items[i].text == NULL) {
|
||||
break;
|
||||
}
|
||||
String_Delete(items[i].text);
|
||||
items[i].text = NULL;
|
||||
}
|
||||
|
|
|
|||
207
arm9/src/mail.c
207
arm9/src/mail.c
|
|
@ -1,131 +1,117 @@
|
|||
#include "global.h"
|
||||
#include "mail.h"
|
||||
#include "heap.h"
|
||||
#include "string_util.h"
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "MI_memory.h"
|
||||
#include "save.h"
|
||||
#include "heap.h"
|
||||
#include "party.h"
|
||||
#include "player_data.h"
|
||||
#include "save.h"
|
||||
#include "string_util.h"
|
||||
|
||||
extern u32 sub_0206B6C8(struct Pokemon * pokemon);
|
||||
extern u32 sub_0206B6C8(struct Pokemon *pokemon);
|
||||
extern u16 sub_0206B7BC(u16 species, u32 form, BOOL is_egg);
|
||||
|
||||
void Mail_Init(struct Mail * mail)
|
||||
{
|
||||
void Mail_Init(struct Mail *mail) {
|
||||
s32 i;
|
||||
mail->author_otId = 0;
|
||||
mail->author_gender = 0;
|
||||
mail->author_otId = 0;
|
||||
mail->author_gender = 0;
|
||||
mail->author_language = (u8)gGameLanguage;
|
||||
mail->author_version = (u8)gGameVersion;
|
||||
mail->mail_type = 0xFF;
|
||||
mail->author_version = (u8)gGameVersion;
|
||||
mail->mail_type = 0xFF;
|
||||
StringFillEOS(mail->author_name, 8);
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
for (i = 0; i < 3; i++) {
|
||||
mail->unk_18[i].raw = 0xFFFF;
|
||||
}
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
for (i = 0; i < 3; i++) {
|
||||
MailMsg_Init(&mail->unk_20[i]);
|
||||
}
|
||||
}
|
||||
|
||||
BOOL Mail_TypeIsValid(struct Mail * mail)
|
||||
{
|
||||
BOOL Mail_TypeIsValid(struct Mail *mail) {
|
||||
return mail->mail_type <= 11;
|
||||
}
|
||||
|
||||
struct Mail * Mail_New(HeapID heapId)
|
||||
{
|
||||
struct Mail * ret = (struct Mail *)AllocFromHeapAtEnd(heapId, sizeof(struct Mail));
|
||||
struct Mail *Mail_New(HeapID heapId) {
|
||||
struct Mail *ret = (struct Mail *)AllocFromHeapAtEnd(heapId, sizeof(struct Mail));
|
||||
Mail_Init(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Mail_Copy(const struct Mail * src, struct Mail * dest)
|
||||
{
|
||||
void Mail_Copy(const struct Mail *src, struct Mail *dest) {
|
||||
MI_CpuCopy8(src, dest, sizeof(struct Mail));
|
||||
}
|
||||
|
||||
void Mail_SetNewMessageDetails(struct Mail * mail, u8 type, u8 monIdx, struct SaveData * save)
|
||||
{
|
||||
void Mail_SetNewMessageDetails(struct Mail *mail, u8 type, u8 monIdx, struct SaveData *save) {
|
||||
u32 sp10;
|
||||
u32 form;
|
||||
BOOL is_egg;
|
||||
u16 species;
|
||||
struct Party * party;
|
||||
PlayerProfile * profile;
|
||||
struct Pokemon * pokemon;
|
||||
struct Party *party;
|
||||
PlayerProfile *profile;
|
||||
struct Pokemon *pokemon;
|
||||
u16 r7;
|
||||
u8 i;
|
||||
|
||||
Mail_Init(mail);
|
||||
mail->mail_type = type;
|
||||
party = SaveArray_Party_Get(save);
|
||||
profile = Save_PlayerData_GetProfileAddr(save);
|
||||
party = SaveArray_Party_Get(save);
|
||||
profile = Save_PlayerData_GetProfileAddr(save);
|
||||
|
||||
CopyU16StringArray(mail->author_name, PlayerProfile_GetNamePtr(profile));
|
||||
mail->author_gender = (u8)PlayerProfile_GetTrainerGender(profile);
|
||||
mail->author_otId = PlayerProfile_GetTrainerID(profile);
|
||||
for (i = 0; monIdx < Party_GetCount(party); monIdx++)
|
||||
{
|
||||
union MailPatternData * ptr;
|
||||
pokemon = Party_GetMonByIndex(party, monIdx);
|
||||
species = (u16)GetMonData(pokemon, MON_DATA_SPECIES, NULL);
|
||||
is_egg = (BOOL)GetMonData(pokemon, MON_DATA_IS_EGG, NULL);
|
||||
form = GetMonData(pokemon, MON_DATA_FORM, NULL);
|
||||
sp10 = sub_0206B6C8(pokemon);
|
||||
r7 = sub_0206B7BC(species, form, is_egg);
|
||||
ptr = &mail->unk_18[i];
|
||||
mail->author_otId = PlayerProfile_GetTrainerID(profile);
|
||||
for (i = 0; monIdx < Party_GetCount(party); monIdx++) {
|
||||
union MailPatternData *ptr;
|
||||
pokemon = Party_GetMonByIndex(party, monIdx);
|
||||
species = (u16)GetMonData(pokemon, MON_DATA_SPECIES, NULL);
|
||||
is_egg = (BOOL)GetMonData(pokemon, MON_DATA_IS_EGG, NULL);
|
||||
form = GetMonData(pokemon, MON_DATA_FORM, NULL);
|
||||
sp10 = sub_0206B6C8(pokemon);
|
||||
r7 = sub_0206B7BC(species, form, is_egg);
|
||||
ptr = &mail->unk_18[i];
|
||||
ptr->bits.unk_0 = sp10;
|
||||
i++;
|
||||
ptr->bits.unk_C = r7;
|
||||
if (i >= 3)
|
||||
if (i >= 3) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
u32 Mail_GetOTID(struct Mail * mail)
|
||||
{
|
||||
u32 Mail_GetOTID(struct Mail *mail) {
|
||||
return mail->author_otId;
|
||||
}
|
||||
|
||||
u16 * Mail_GetAuthorNamePtr(struct Mail * mail)
|
||||
{
|
||||
u16 *Mail_GetAuthorNamePtr(struct Mail *mail) {
|
||||
return mail->author_name;
|
||||
}
|
||||
|
||||
u8 Mail_GetAuthorGender(struct Mail * mail)
|
||||
{
|
||||
u8 Mail_GetAuthorGender(struct Mail *mail) {
|
||||
return mail->author_gender;
|
||||
}
|
||||
|
||||
u8 Mail_GetType(struct Mail * mail)
|
||||
{
|
||||
u8 Mail_GetType(struct Mail *mail) {
|
||||
return mail->mail_type;
|
||||
}
|
||||
|
||||
void Mail_SetType(struct Mail * mail, u8 type)
|
||||
{
|
||||
if (type < 12)
|
||||
void Mail_SetType(struct Mail *mail, u8 type) {
|
||||
if (type < 12) {
|
||||
mail->mail_type = type;
|
||||
}
|
||||
}
|
||||
|
||||
u8 Mail_GetLanguage(struct Mail * mail)
|
||||
{
|
||||
u8 Mail_GetLanguage(struct Mail *mail) {
|
||||
return mail->author_language;
|
||||
}
|
||||
|
||||
u8 Mail_GetVersion(struct Mail * mail)
|
||||
{
|
||||
u8 Mail_GetVersion(struct Mail *mail) {
|
||||
return mail->author_version;
|
||||
}
|
||||
|
||||
u16 Mail_GetAttrFromUnk18Array(struct Mail * mail, u32 idx, u32 attr)
|
||||
{
|
||||
if (idx < 3)
|
||||
{
|
||||
switch (attr)
|
||||
{
|
||||
u16 Mail_GetAttrFromUnk18Array(struct Mail *mail, u32 idx, u32 attr) {
|
||||
if (idx < 3) {
|
||||
switch (attr) {
|
||||
case 0:
|
||||
return mail->unk_18[idx].bits.unk_0;
|
||||
case 1:
|
||||
|
|
@ -138,43 +124,37 @@ u16 Mail_GetAttrFromUnk18Array(struct Mail * mail, u32 idx, u32 attr)
|
|||
return 0;
|
||||
}
|
||||
|
||||
struct MailMessage * Mail_GetUnk20Array(struct Mail * mail, u32 idx)
|
||||
{
|
||||
if (idx < 3)
|
||||
struct MailMessage *Mail_GetUnk20Array(struct Mail *mail, u32 idx) {
|
||||
if (idx < 3) {
|
||||
return &mail->unk_20[idx];
|
||||
else
|
||||
} else {
|
||||
return &mail->unk_20[0];
|
||||
}
|
||||
}
|
||||
|
||||
void Mail_CopyToUnk20Array(struct Mail * mail, const struct MailMessage * src, u32 idx)
|
||||
{
|
||||
if (idx < 3)
|
||||
void Mail_CopyToUnk20Array(struct Mail *mail, const struct MailMessage *src, u32 idx) {
|
||||
if (idx < 3) {
|
||||
MailMsg_Copy(&mail->unk_20[idx], src);
|
||||
}
|
||||
}
|
||||
|
||||
struct Mail * Save_Mailbox_Get(struct SaveData * save)
|
||||
{
|
||||
struct Mail *Save_Mailbox_Get(struct SaveData *save) {
|
||||
return (struct Mail *)SaveArray_Get(save, 15);
|
||||
}
|
||||
|
||||
u32 Save_Mailbox_sizeof(void)
|
||||
{
|
||||
u32 Save_Mailbox_sizeof(void) {
|
||||
return 20 * sizeof(struct Mail);
|
||||
}
|
||||
|
||||
void Save_Mailbox_Init(struct Mail * mail)
|
||||
{
|
||||
void Save_Mailbox_Init(struct Mail *mail) {
|
||||
s32 i;
|
||||
for (i = 0; i < 20; i++)
|
||||
{
|
||||
for (i = 0; i < 20; i++) {
|
||||
Mail_Init(&mail[i]);
|
||||
}
|
||||
}
|
||||
|
||||
s32 Mailbox_GetFirstEmptySlotIdx(struct Mail * mail, BOOL r1)
|
||||
{
|
||||
switch (r1)
|
||||
{
|
||||
s32 Mailbox_GetFirstEmptySlotIdx(struct Mail *mail, BOOL r1) {
|
||||
switch (r1) {
|
||||
case 0:
|
||||
return MailArray_GetFirstEmptySlotIdx(mail, 20);
|
||||
default:
|
||||
|
|
@ -182,24 +162,22 @@ s32 Mailbox_GetFirstEmptySlotIdx(struct Mail * mail, BOOL r1)
|
|||
}
|
||||
}
|
||||
|
||||
void Mailbox_DeleteSlotI(struct Mail * mail, BOOL r1, s32 idx)
|
||||
{
|
||||
void Mailbox_DeleteSlotI(struct Mail *mail, BOOL r1, s32 idx) {
|
||||
mail = Mailbox_GetPtrToSlotI(mail, r1, idx);
|
||||
if (mail != NULL)
|
||||
if (mail != NULL) {
|
||||
Mail_Init(mail);
|
||||
}
|
||||
}
|
||||
|
||||
void Mailbox_CopyMailToSlotI(struct Mail * mail, BOOL r1, s32 idx, const struct Mail * src)
|
||||
{
|
||||
void Mailbox_CopyMailToSlotI(struct Mail *mail, BOOL r1, s32 idx, const struct Mail *src) {
|
||||
mail = Mailbox_GetPtrToSlotI(mail, r1, idx);
|
||||
if (mail != NULL)
|
||||
if (mail != NULL) {
|
||||
Mail_Copy(src, mail);
|
||||
}
|
||||
}
|
||||
|
||||
s32 Mailbox_CountMessages(struct Mail * mail, BOOL r1)
|
||||
{
|
||||
switch (r1)
|
||||
{
|
||||
s32 Mailbox_CountMessages(struct Mail *mail, BOOL r1) {
|
||||
switch (r1) {
|
||||
case 0:
|
||||
return MailArray_CountMessages(mail, 20);
|
||||
default:
|
||||
|
|
@ -207,56 +185,53 @@ s32 Mailbox_CountMessages(struct Mail * mail, BOOL r1)
|
|||
}
|
||||
}
|
||||
|
||||
struct Mail * Mailbox_AllocAndFetchMailI(struct Mail * mail, BOOL r1, s32 idx, HeapID heapId)
|
||||
{
|
||||
struct Mail * ret;
|
||||
struct Mail *Mailbox_AllocAndFetchMailI(struct Mail *mail, BOOL r1, s32 idx, HeapID heapId) {
|
||||
struct Mail *ret;
|
||||
mail = Mailbox_GetPtrToSlotI(mail, r1, idx);
|
||||
ret = Mail_New(heapId);
|
||||
if (mail != NULL)
|
||||
ret = Mail_New(heapId);
|
||||
if (mail != NULL) {
|
||||
Mail_Copy(mail, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Mailbox_FetchMailIToBuffer(struct Mail * mail, BOOL r1, s32 idx, struct Mail * dest)
|
||||
{
|
||||
void Mailbox_FetchMailIToBuffer(struct Mail *mail, BOOL r1, s32 idx, struct Mail *dest) {
|
||||
mail = Mailbox_GetPtrToSlotI(mail, r1, idx);
|
||||
if (mail == NULL)
|
||||
if (mail == NULL) {
|
||||
Mail_Init(dest);
|
||||
else
|
||||
} else {
|
||||
Mail_Copy(mail, dest);
|
||||
}
|
||||
}
|
||||
|
||||
s32 MailArray_GetFirstEmptySlotIdx(struct Mail * mail, s32 count)
|
||||
{
|
||||
s32 MailArray_GetFirstEmptySlotIdx(struct Mail *mail, s32 count) {
|
||||
s32 i;
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
if (!Mail_TypeIsValid(&mail[i]))
|
||||
for (i = 0; i < count; i++) {
|
||||
if (!Mail_TypeIsValid(&mail[i])) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
s32 MailArray_CountMessages(struct Mail * mail, s32 count)
|
||||
{
|
||||
s32 MailArray_CountMessages(struct Mail *mail, s32 count) {
|
||||
s32 ret = 0;
|
||||
s32 i;
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
if (Mail_TypeIsValid(&mail[i]))
|
||||
for (i = 0; i < count; i++) {
|
||||
if (Mail_TypeIsValid(&mail[i])) {
|
||||
ret++;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct Mail * Mailbox_GetPtrToSlotI(struct Mail * mail, BOOL r1, s32 idx)
|
||||
{
|
||||
struct Mail * ret = NULL;
|
||||
switch (r1)
|
||||
{
|
||||
struct Mail *Mailbox_GetPtrToSlotI(struct Mail *mail, BOOL r1, s32 idx) {
|
||||
struct Mail *ret = NULL;
|
||||
switch (r1) {
|
||||
case 0:
|
||||
if (idx < 20)
|
||||
if (idx < 20) {
|
||||
ret = &mail[idx];
|
||||
}
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -1,13 +1,16 @@
|
|||
#include "global.h"
|
||||
#include "mail_message.h"
|
||||
#include "message_format.h"
|
||||
#include "msgdata.h"
|
||||
#include "msgdata/msg.naix"
|
||||
#include "string_control_code.h"
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "constants/easy_chat.h"
|
||||
|
||||
struct UnkStruct_020ED556
|
||||
{
|
||||
#include "msgdata/msg.naix"
|
||||
|
||||
#include "message_format.h"
|
||||
#include "msgdata.h"
|
||||
#include "string_control_code.h"
|
||||
|
||||
struct UnkStruct_020ED556 {
|
||||
u8 unk_0;
|
||||
u8 unk_1;
|
||||
s16 unk_2;
|
||||
|
|
@ -27,175 +30,155 @@ static const u16 sMessageBanks[] = {
|
|||
};
|
||||
|
||||
const struct UnkStruct_020ED556 UNK_020ED556[] = {
|
||||
{ 0, 0, 0x184, 7, -1, 0 },
|
||||
{ 0, 0, 0x184, 7, -1, 0 },
|
||||
{ 1, 0, 0x184, 33, -1, 0 },
|
||||
{ 2, 0, 0x188, 10, -1, 0 },
|
||||
{ 1, 4, 0x184, 1, -1, 0 }
|
||||
{ 1, 4, 0x184, 1, -1, 0 }
|
||||
};
|
||||
|
||||
void MailMsg_Init(struct MailMessage * mailMsg)
|
||||
{
|
||||
void MailMsg_Init(struct MailMessage *mailMsg) {
|
||||
s32 i;
|
||||
mailMsg->msg_bank = MAILMSG_BANK_NONE;
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
for (i = 0; i < 2; i++) {
|
||||
mailMsg->fields[i] = EC_WORD_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void MailMsg_Init_WithBank(struct MailMessage * mailMsg, u16 bank)
|
||||
{
|
||||
void MailMsg_Init_WithBank(struct MailMessage *mailMsg, u16 bank) {
|
||||
s32 i;
|
||||
mailMsg->msg_bank = bank;
|
||||
mailMsg->msg_no = 0;
|
||||
for (i = 0; i < MAILMSG_FIELDS_MAX; i++)
|
||||
{
|
||||
mailMsg->msg_no = 0;
|
||||
for (i = 0; i < MAILMSG_FIELDS_MAX; i++) {
|
||||
mailMsg->fields[i] = EC_WORD_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void MailMsg_Init_Default(struct MailMessage * mailMsg)
|
||||
{
|
||||
void MailMsg_Init_Default(struct MailMessage *mailMsg) {
|
||||
MailMsg_Init_WithBank(mailMsg, 4);
|
||||
mailMsg->msg_no = 5;
|
||||
}
|
||||
|
||||
void MailMsg_Init_FromTemplate(struct MailMessage * mailMsg, u32 a1)
|
||||
{
|
||||
void MailMsg_Init_FromTemplate(struct MailMessage *mailMsg, u32 a1) {
|
||||
GF_ASSERT(a1 < 4);
|
||||
if (a1 < 4)
|
||||
{
|
||||
if (a1 < 4) {
|
||||
MailMsg_Init_WithBank(mailMsg, UNK_020ED556[a1].unk_0);
|
||||
mailMsg->msg_no = UNK_020ED556[a1].unk_1;
|
||||
if (UNK_020ED556[a1].unk_2 != -1)
|
||||
if (UNK_020ED556[a1].unk_2 != -1) {
|
||||
mailMsg->fields[0] = GetECWordIndexByPair(UNK_020ED556[a1].unk_2, UNK_020ED556[a1].unk_4);
|
||||
if (UNK_020ED556[a1].unk_6 != -1)
|
||||
}
|
||||
if (UNK_020ED556[a1].unk_6 != -1) {
|
||||
mailMsg->fields[1] = GetECWordIndexByPair(UNK_020ED556[a1].unk_6, UNK_020ED556[a1].unk_8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct String * MailMsg_GetExpandedString(struct MailMessage * mailMsg, HeapID heapId)
|
||||
{
|
||||
struct String *MailMsg_GetExpandedString(struct MailMessage *mailMsg, HeapID heapId) {
|
||||
s32 i;
|
||||
MessageFormat * messageFormat = MessageFormat_New(heapId);
|
||||
struct MsgData * msgData;
|
||||
struct String * ret;
|
||||
for (i = 0; i < MAILMSG_FIELDS_MAX; i++)
|
||||
{
|
||||
if (mailMsg->fields[i] == EC_WORD_NULL)
|
||||
MessageFormat *messageFormat = MessageFormat_New(heapId);
|
||||
struct MsgData *msgData;
|
||||
struct String *ret;
|
||||
for (i = 0; i < MAILMSG_FIELDS_MAX; i++) {
|
||||
if (mailMsg->fields[i] == EC_WORD_NULL) {
|
||||
break;
|
||||
}
|
||||
BufferECWord(messageFormat, (u32)i, mailMsg->fields[i]);
|
||||
}
|
||||
msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, sMessageBanks[mailMsg->msg_bank], heapId);
|
||||
ret = ReadMsgData_ExpandPlaceholders(messageFormat, msgData, mailMsg->msg_no, heapId);
|
||||
ret = ReadMsgData_ExpandPlaceholders(messageFormat, msgData, mailMsg->msg_no, heapId);
|
||||
DestroyMsgData(msgData);
|
||||
MessageFormat_Delete(messageFormat);
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct String * MailMsg_GetRawString(struct MailMessage * mailMsg, HeapID heapId)
|
||||
{
|
||||
struct String *MailMsg_GetRawString(struct MailMessage *mailMsg, HeapID heapId) {
|
||||
return ReadMsgData_NewNarc_NewString(NARC_MSGDATA_MSG, sMessageBanks[mailMsg->msg_bank], mailMsg->msg_no, heapId);
|
||||
}
|
||||
|
||||
BOOL MailMsg_IsInit(struct MailMessage * mailMsg)
|
||||
{
|
||||
BOOL MailMsg_IsInit(struct MailMessage *mailMsg) {
|
||||
return mailMsg->msg_bank != MAILMSG_BANK_NONE;
|
||||
}
|
||||
|
||||
BOOL MailMsg_AllFieldsAreInit(struct MailMessage * mailMsg)
|
||||
{
|
||||
BOOL MailMsg_AllFieldsAreInit(struct MailMessage *mailMsg) {
|
||||
s32 i;
|
||||
u32 n = MailMsg_NumFields(mailMsg->msg_bank, mailMsg->msg_no);
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
if (mailMsg->fields[i] == EC_WORD_NULL)
|
||||
for (i = 0; i < n; i++) {
|
||||
if (mailMsg->fields[i] == EC_WORD_NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
u32 MailMsg_NumFields(u16 bank, u16 num)
|
||||
{
|
||||
struct String * str;
|
||||
const u16 * cstr;
|
||||
u32 MailMsg_NumFields(u16 bank, u16 num) {
|
||||
struct String *str;
|
||||
const u16 *cstr;
|
||||
u32 count;
|
||||
GF_ASSERT(bank < NELEMS(sMessageBanks));
|
||||
GF_ASSERT(num < MailMsg_NumMsgsInBank(bank));
|
||||
str = ReadMsgData_NewNarc_NewString(NARC_MSGDATA_MSG, sMessageBanks[bank], num, HEAP_ID_DEFAULT);
|
||||
cstr = String_c_str(str);
|
||||
str = ReadMsgData_NewNarc_NewString(NARC_MSGDATA_MSG, sMessageBanks[bank], num, HEAP_ID_DEFAULT);
|
||||
cstr = String_c_str(str);
|
||||
count = 0;
|
||||
while (*cstr != EOS)
|
||||
{
|
||||
if (*cstr == EXT_CTRL_CODE_BEGIN)
|
||||
{
|
||||
if (MsgArray_ControlCodeIsStrVar(cstr))
|
||||
while (*cstr != EOS) {
|
||||
if (*cstr == EXT_CTRL_CODE_BEGIN) {
|
||||
if (MsgArray_ControlCodeIsStrVar(cstr)) {
|
||||
count++;
|
||||
}
|
||||
cstr = MsgArray_SkipControlCode(cstr);
|
||||
}
|
||||
else
|
||||
} else {
|
||||
cstr++;
|
||||
}
|
||||
}
|
||||
String_Delete(str);
|
||||
return count;
|
||||
}
|
||||
|
||||
u16 MailMsg_GetFieldI(struct MailMessage * mailMsg, u32 a1)
|
||||
{
|
||||
u16 MailMsg_GetFieldI(struct MailMessage *mailMsg, u32 a1) {
|
||||
return mailMsg->fields[a1];
|
||||
}
|
||||
|
||||
u16 MailMsg_GetMsgBank(struct MailMessage * mailMsg)
|
||||
{
|
||||
u16 MailMsg_GetMsgBank(struct MailMessage *mailMsg) {
|
||||
return mailMsg->msg_bank;
|
||||
}
|
||||
|
||||
u16 MailMsg_GetMsgNo(struct MailMessage * mailMsg)
|
||||
{
|
||||
u16 MailMsg_GetMsgNo(struct MailMessage *mailMsg) {
|
||||
return mailMsg->msg_no;
|
||||
}
|
||||
|
||||
BOOL MailMsg_Compare(const struct MailMessage *mailMsg, const struct MailMessage *a1)
|
||||
{
|
||||
BOOL MailMsg_Compare(const struct MailMessage *mailMsg, const struct MailMessage *a1) {
|
||||
s32 i;
|
||||
if (mailMsg->msg_bank != a1->msg_bank || mailMsg->msg_no != a1->msg_no)
|
||||
if (mailMsg->msg_bank != a1->msg_bank || mailMsg->msg_no != a1->msg_no) {
|
||||
return FALSE;
|
||||
for (i = 0; i < MAILMSG_FIELDS_MAX; i++)
|
||||
{
|
||||
if (mailMsg->fields[i] != a1->fields[i])
|
||||
}
|
||||
for (i = 0; i < MAILMSG_FIELDS_MAX; i++) {
|
||||
if (mailMsg->fields[i] != a1->fields[i]) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void MailMsg_Copy(struct MailMessage * mailMsg, const struct MailMessage * a1)
|
||||
{
|
||||
void MailMsg_Copy(struct MailMessage *mailMsg, const struct MailMessage *a1) {
|
||||
*mailMsg = *a1;
|
||||
}
|
||||
|
||||
u32 MailMsg_NumMsgsInBank(u16 bank)
|
||||
{
|
||||
u32 MailMsg_NumMsgsInBank(u16 bank) {
|
||||
return (u32)((bank < NELEMS(sMessageBanks)) ? 20 : 0);
|
||||
}
|
||||
|
||||
void MailMsg_SetMsgBankAndNum(struct MailMessage * mailMsg, u16 bank, u16 num)
|
||||
{
|
||||
void MailMsg_SetMsgBankAndNum(struct MailMessage *mailMsg, u16 bank, u16 num) {
|
||||
GF_ASSERT(bank < NELEMS(sMessageBanks));
|
||||
mailMsg->msg_bank = bank;
|
||||
mailMsg->msg_no = num;
|
||||
mailMsg->msg_no = num;
|
||||
}
|
||||
|
||||
void MailMsg_SetFieldI(struct MailMessage * mailMsg, u32 idx, u16 word)
|
||||
{
|
||||
void MailMsg_SetFieldI(struct MailMessage *mailMsg, u32 idx, u16 word) {
|
||||
GF_ASSERT(idx < MAILMSG_FIELDS_MAX);
|
||||
mailMsg->fields[idx] = word;
|
||||
}
|
||||
|
||||
void MailMsg_SetTrailingFieldsEmpty(struct MailMessage * mailMsg)
|
||||
{
|
||||
void MailMsg_SetTrailingFieldsEmpty(struct MailMessage *mailMsg) {
|
||||
u32 n;
|
||||
for (n = MailMsg_NumFields(mailMsg->msg_bank, mailMsg->msg_no); n < MAILMSG_FIELDS_MAX; n++)
|
||||
{
|
||||
for (n = MailMsg_NumFields(mailMsg->msg_bank, mailMsg->msg_no); n < MAILMSG_FIELDS_MAX; n++) {
|
||||
mailMsg->fields[n] = EC_WORD_NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
185
arm9/src/main.c
185
arm9/src/main.c
|
|
@ -1,26 +1,28 @@
|
|||
#define IN_MAIN_C
|
||||
|
||||
#include "main.h"
|
||||
|
||||
#include "global.h"
|
||||
#include "SPI_pm.h"
|
||||
|
||||
#include "CARD_backup.h"
|
||||
#include "CARD_pullOut.h"
|
||||
#include "CTRDG_common.h"
|
||||
#include "communication_error.h"
|
||||
#include "PAD_pad.h"
|
||||
#include "main.h"
|
||||
#include "SPI_pm.h"
|
||||
#include "brightness.h"
|
||||
#include "communication_error.h"
|
||||
#include "font.h"
|
||||
#include "game_init.h"
|
||||
#include "poke_overlay.h"
|
||||
#include "heap.h"
|
||||
#include "overlay_52.h"
|
||||
#include "player_data.h"
|
||||
#include "poke_overlay.h"
|
||||
#include "save_data_read_error.h"
|
||||
#include "sound.h"
|
||||
#include "timer3.h"
|
||||
#include "unk_02031734.h"
|
||||
#include "unk_0202F150.h"
|
||||
#include "unk_02031734.h"
|
||||
#include "wfc_user_info_warning.h"
|
||||
#include "overlay_52.h"
|
||||
#include "font.h"
|
||||
#include "brightness.h"
|
||||
#include "heap.h"
|
||||
|
||||
FS_EXTERN_OVERLAY(OVERLAY_52);
|
||||
FS_EXTERN_OVERLAY(OVERLAY_63);
|
||||
|
|
@ -46,11 +48,9 @@ extern struct OverlayManagerTemplate ov63_021DBE18;
|
|||
extern u8 SDK_STATIC_BSS_START[];
|
||||
|
||||
const int gGameLanguage = GAME_LANGUAGE;
|
||||
const int gGameVersion = GAME_VERSION;
|
||||
const int gGameVersion = GAME_VERSION;
|
||||
|
||||
__declspec(noreturn)
|
||||
void NitroMain(void)
|
||||
{
|
||||
__declspec(noreturn) void NitroMain(void) {
|
||||
InitSystemForTheGame();
|
||||
InitGraphicMemory();
|
||||
InitKeypadAndTouchpad();
|
||||
|
|
@ -66,19 +66,16 @@ void NitroMain(void)
|
|||
sub_02002C50(1, HEAP_ID_MAIN);
|
||||
sub_02002C50(3, HEAP_ID_MAIN);
|
||||
UNK_02016FA8.unk10 = -1;
|
||||
UNK_02016FA8.save = SaveData_New();
|
||||
UNK_02016FA8.save = SaveData_New();
|
||||
InitSoundData(Save_Chatot_Get(UNK_02016FA8.save), Save_PlayerData_GetOptionsAddr(UNK_02016FA8.save));
|
||||
Init_Timer3();
|
||||
if (sub_020337E8(3) == 3)
|
||||
if (sub_020337E8(3) == 3) {
|
||||
ShowWFCUserInfoWarning(HEAP_ID_MAIN, 0);
|
||||
if (sub_020227FC(UNK_02016FA8.save) == 0)
|
||||
{
|
||||
ShowSaveDataReadError(HEAP_ID_DEFAULT);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (OS_GetResetParameter())
|
||||
{
|
||||
if (sub_020227FC(UNK_02016FA8.save) == 0) {
|
||||
ShowSaveDataReadError(HEAP_ID_DEFAULT);
|
||||
} else {
|
||||
switch (OS_GetResetParameter()) {
|
||||
case 0:
|
||||
// Title Demo
|
||||
UNK_02016FA8.unk14 = 0;
|
||||
|
|
@ -100,8 +97,7 @@ void NitroMain(void)
|
|||
ScreenBrightnessData_InitAll();
|
||||
PlayTimerInit();
|
||||
UNK_02016FA4 = 0;
|
||||
for (;;)
|
||||
{
|
||||
for (;;) {
|
||||
sub_02000EE8();
|
||||
HandleDSLidAction();
|
||||
ReadKeypadAndTocuhpad();
|
||||
|
|
@ -109,13 +105,11 @@ void NitroMain(void)
|
|||
{
|
||||
DoSoftReset(0); // soft reset?
|
||||
}
|
||||
if (sub_0202FB80())
|
||||
{
|
||||
if (sub_0202FB80()) {
|
||||
Main_RunOverlayManager();
|
||||
sub_0201B5CC(gSystem.unk18);
|
||||
sub_0201B5CC(gSystem.unk24);
|
||||
if (!gSystem.unk30)
|
||||
{
|
||||
if (!gSystem.unk30) {
|
||||
OS_WaitIrq(1, 1);
|
||||
gSystem.unk2C++;
|
||||
}
|
||||
|
|
@ -129,74 +123,69 @@ void NitroMain(void)
|
|||
gSystem.unk30 = 0;
|
||||
DoAllScreenBrightnessTransitionStep();
|
||||
sub_0200E2D8();
|
||||
if (gSystem.vBlankIntr)
|
||||
if (gSystem.vBlankIntr) {
|
||||
gSystem.vBlankIntr(gSystem.vBlankIntrArg);
|
||||
}
|
||||
DoSoundUpdateFrame();
|
||||
sub_0201B5CC(gSystem.unk20);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_02000DF4(void)
|
||||
{
|
||||
UNK_02016FA8.mainOverlayId = SDK_OVERLAY_INVALID_ID;
|
||||
UNK_02016FA8.overlayManager = NULL;
|
||||
void sub_02000DF4(void) {
|
||||
UNK_02016FA8.mainOverlayId = SDK_OVERLAY_INVALID_ID;
|
||||
UNK_02016FA8.overlayManager = NULL;
|
||||
UNK_02016FA8.queuedMainOverlayId = SDK_OVERLAY_INVALID_ID; // overlay invalid
|
||||
UNK_02016FA8.template = NULL;
|
||||
UNK_02016FA8.template = NULL;
|
||||
}
|
||||
|
||||
void Main_RunOverlayManager(void)
|
||||
{
|
||||
if (UNK_02016FA8.overlayManager == NULL)
|
||||
{
|
||||
if (UNK_02016FA8.template == NULL)
|
||||
void Main_RunOverlayManager(void) {
|
||||
if (UNK_02016FA8.overlayManager == NULL) {
|
||||
if (UNK_02016FA8.template == NULL) {
|
||||
return;
|
||||
if (UNK_02016FA8.queuedMainOverlayId != SDK_OVERLAY_INVALID_ID)
|
||||
}
|
||||
if (UNK_02016FA8.queuedMainOverlayId != SDK_OVERLAY_INVALID_ID) {
|
||||
HandleLoadOverlay(UNK_02016FA8.queuedMainOverlayId, 0);
|
||||
UNK_02016FA8.mainOverlayId = UNK_02016FA8.queuedMainOverlayId;
|
||||
UNK_02016FA8.overlayManager = OverlayManager_New(UNK_02016FA8.template, &UNK_02016FA8.unk10, HEAP_ID_DEFAULT);
|
||||
}
|
||||
UNK_02016FA8.mainOverlayId = UNK_02016FA8.queuedMainOverlayId;
|
||||
UNK_02016FA8.overlayManager = OverlayManager_New(UNK_02016FA8.template, &UNK_02016FA8.unk10, HEAP_ID_DEFAULT);
|
||||
UNK_02016FA8.queuedMainOverlayId = SDK_OVERLAY_INVALID_ID;
|
||||
UNK_02016FA8.template = NULL;
|
||||
UNK_02016FA8.template = NULL;
|
||||
}
|
||||
if (OverlayManager_Run(UNK_02016FA8.overlayManager))
|
||||
{
|
||||
if (OverlayManager_Run(UNK_02016FA8.overlayManager)) {
|
||||
OverlayManager_Delete(UNK_02016FA8.overlayManager);
|
||||
UNK_02016FA8.overlayManager = NULL;
|
||||
if (UNK_02016FA8.mainOverlayId != SDK_OVERLAY_INVALID_ID)
|
||||
if (UNK_02016FA8.mainOverlayId != SDK_OVERLAY_INVALID_ID) {
|
||||
UnloadOverlayByID(UNK_02016FA8.mainOverlayId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RegisterMainOverlay(FSOverlayID id, const struct OverlayManagerTemplate *template)
|
||||
{
|
||||
void RegisterMainOverlay(FSOverlayID id, const struct OverlayManagerTemplate *template) {
|
||||
GF_ASSERT(UNK_02016FA8.template == NULL);
|
||||
UNK_02016FA8.queuedMainOverlayId = id;
|
||||
UNK_02016FA8.template = template;
|
||||
UNK_02016FA8.template = template;
|
||||
}
|
||||
|
||||
void sub_02000E9C(void)
|
||||
{
|
||||
void sub_02000E9C(void) {
|
||||
sub_0202FB80();
|
||||
OS_WaitIrq(TRUE, OS_IE_VBLANK);
|
||||
gSystem.unk2C++;
|
||||
gSystem.unk30 = 0;
|
||||
if (gSystem.vBlankIntr != NULL)
|
||||
if (gSystem.vBlankIntr != NULL) {
|
||||
gSystem.vBlankIntr(gSystem.vBlankIntrArg);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_02000EC8(u32 parameter)
|
||||
{
|
||||
if (sub_02033678() && CARD_TryWaitBackupAsync() == TRUE)
|
||||
{
|
||||
void sub_02000EC8(u32 parameter) {
|
||||
if (sub_02033678() && CARD_TryWaitBackupAsync() == TRUE) {
|
||||
OS_ResetSystem(parameter);
|
||||
}
|
||||
sub_02000E9C();
|
||||
}
|
||||
|
||||
void sub_02000EE8(void)
|
||||
{
|
||||
void sub_02000EE8(void) {
|
||||
u32 r1 = sub_020335B8();
|
||||
switch (r1)
|
||||
{
|
||||
switch (r1) {
|
||||
case 1:
|
||||
sub_02000F4C(1, r1);
|
||||
break;
|
||||
|
|
@ -211,43 +200,33 @@ void sub_02000EE8(void)
|
|||
|
||||
extern void sub_0200E3A0(PMLCDTarget, int);
|
||||
|
||||
__declspec(noreturn)
|
||||
void DoSoftReset(u32 parameter)
|
||||
{
|
||||
__declspec(noreturn) void DoSoftReset(u32 parameter) {
|
||||
sub_0200E3A0(PM_LCD_TOP, 0x7FFF);
|
||||
sub_0200E3A0(PM_LCD_BOTTOM, 0x7FFF);
|
||||
if (sub_02032DAC())
|
||||
{
|
||||
if (sub_02032DAC()) {
|
||||
sub_0202287C(sub_020225F8());
|
||||
}
|
||||
do
|
||||
{
|
||||
do {
|
||||
HandleDSLidAction();
|
||||
sub_02000EC8(parameter);
|
||||
} while (1);
|
||||
}
|
||||
|
||||
void sub_02000F4C(u32 arg0, u32 arg1)
|
||||
{
|
||||
if (arg1 == 3)
|
||||
{
|
||||
void sub_02000F4C(u32 arg0, u32 arg1) {
|
||||
if (arg1 == 3) {
|
||||
ShowCommunicationError(HEAP_ID_DEFAULT, 3, 0);
|
||||
}
|
||||
else if (arg0 == 0)
|
||||
{
|
||||
} else if (arg0 == 0) {
|
||||
ShowCommunicationError(HEAP_ID_DEFAULT, 2, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
ShowCommunicationError(HEAP_ID_DEFAULT, 0, 0);
|
||||
}
|
||||
sub_02032DAC();
|
||||
while (TRUE)
|
||||
{
|
||||
while (TRUE) {
|
||||
HandleDSLidAction();
|
||||
ReadKeypadAndTocuhpad();
|
||||
if (gSystem.newKeys & 1)
|
||||
if (gSystem.newKeys & 1) {
|
||||
break;
|
||||
}
|
||||
sub_02000E9C();
|
||||
}
|
||||
DoSoftReset(arg0);
|
||||
|
|
@ -257,8 +236,7 @@ extern void GF_RTC_CopyDateTime(struct Unk21C4818 *, struct Unk21C4828 *);
|
|||
extern void SetMTRNGSeed(u32);
|
||||
extern void SetLCRNGSeed(u32);
|
||||
|
||||
void InitializeMainRNG(void)
|
||||
{
|
||||
void InitializeMainRNG(void) {
|
||||
struct Unk21C4818 spC;
|
||||
struct Unk21C4828 sp0;
|
||||
GF_RTC_CopyDateTime(&spC, &sp0);
|
||||
|
|
@ -273,53 +251,44 @@ void InitializeMainRNG(void)
|
|||
extern void sub_0201CE04(void);
|
||||
extern void sub_0201CDD0(void);
|
||||
|
||||
void HandleDSLidAction(void)
|
||||
{
|
||||
void HandleDSLidAction(void) {
|
||||
PMBackLightSwitch top, bottom;
|
||||
if (PAD_DetectFold())
|
||||
{
|
||||
if (!gSystem.unk67)
|
||||
{
|
||||
if (PAD_DetectFold()) {
|
||||
if (!gSystem.unk67) {
|
||||
sub_0201CE04();
|
||||
if (CTRDG_IsPulledOut() == TRUE)
|
||||
{
|
||||
if (CTRDG_IsPulledOut() == TRUE) {
|
||||
UNK_02016FA4 = 1;
|
||||
}
|
||||
{
|
||||
int r1 = UNK_02016FA4;
|
||||
while (1)
|
||||
{
|
||||
while (1) {
|
||||
PMWakeUpTrigger trigger = PM_TRIGGER_COVER_OPEN | PM_TRIGGER_CARD;
|
||||
if (gSystem.gbaCartId && !r1)
|
||||
if (gSystem.gbaCartId && !r1) {
|
||||
trigger |= PM_TRIGGER_CARTRIDGE;
|
||||
}
|
||||
PM_GoSleepMode(trigger, PM_PAD_LOGIC_OR, 0);
|
||||
if (CARD_IsPulledOut())
|
||||
{
|
||||
if (CARD_IsPulledOut()) {
|
||||
PM_ForceToPowerOff();
|
||||
break;
|
||||
}
|
||||
else if (PAD_DetectFold())
|
||||
{
|
||||
} else if (PAD_DetectFold()) {
|
||||
r1 = UNK_02016FA4 = 1;
|
||||
}
|
||||
else
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
sub_0201CDD0();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
PM_GetBackLight(&top, &bottom);
|
||||
if (top == PM_BACKLIGHT_ON)
|
||||
if (top == PM_BACKLIGHT_ON) {
|
||||
PM_SetBackLight(PM_LCD_ALL, PM_BACKLIGHT_OFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
PM_GetBackLight(&top, &bottom);
|
||||
if (top == PM_BACKLIGHT_OFF)
|
||||
if (top == PM_BACKLIGHT_OFF) {
|
||||
PM_SetBackLight(PM_LCD_ALL, gBacklightTop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,59 +1,53 @@
|
|||
#include "global.h"
|
||||
#include "map_matrix.h"
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "MI_memory.h"
|
||||
#include "filesystem.h"
|
||||
#include "heap.h"
|
||||
#include "map_header.h"
|
||||
|
||||
static void MapMatrix_MapMatrixData_Load(
|
||||
struct MapMatrixData *map_matrix, u16 file_id, u32 map_id)
|
||||
{
|
||||
map_matrix->width = 0;
|
||||
struct MapMatrixData *map_matrix, u16 file_id, u32 map_id) {
|
||||
map_matrix->width = 0;
|
||||
map_matrix->height = 0;
|
||||
|
||||
s32 i;
|
||||
for (i = 0; i < MAP_MATRIX_MAX_SIZE; i++)
|
||||
{
|
||||
map_matrix->headers[i] = 0;
|
||||
for (i = 0; i < MAP_MATRIX_MAX_SIZE; i++) {
|
||||
map_matrix->headers[i] = 0;
|
||||
map_matrix->altitudes[i] = 0;
|
||||
map_matrix->maps.data[i] = 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < MAP_MATRIX_MAX_NAME_LENGTH; i++)
|
||||
{
|
||||
for (i = 0; i < MAP_MATRIX_MAX_NAME_LENGTH; i++) {
|
||||
map_matrix->name[i] = 0;
|
||||
}
|
||||
|
||||
void *buffer =
|
||||
AllocAtEndAndReadWholeNarcMemberByIdPair(NARC_FIELDDATA_MAPMATRIX_MAP_MATRIX, file_id, HEAP_ID_FIELD);
|
||||
u8 *cursor = (u8 *)buffer;
|
||||
void *buffer = AllocAtEndAndReadWholeNarcMemberByIdPair(NARC_FIELDDATA_MAPMATRIX_MAP_MATRIX, file_id, HEAP_ID_FIELD);
|
||||
u8 *cursor = (u8 *)buffer;
|
||||
|
||||
map_matrix->width = *(cursor++);
|
||||
map_matrix->height = *(cursor++);
|
||||
u8 has_headers_section = *(cursor++);
|
||||
map_matrix->width = *(cursor++);
|
||||
map_matrix->height = *(cursor++);
|
||||
u8 has_headers_section = *(cursor++);
|
||||
u8 has_altitudes_section = *(cursor++);
|
||||
u8 name_length = *(cursor++);
|
||||
u8 name_length = *(cursor++);
|
||||
|
||||
GF_ASSERT(name_length <= MAP_MATRIX_MAX_NAME_LENGTH);
|
||||
|
||||
MI_CpuCopy8(cursor, &map_matrix->name, name_length);
|
||||
cursor += name_length;
|
||||
|
||||
if (has_headers_section != 0)
|
||||
{
|
||||
if (has_headers_section != 0) {
|
||||
MI_CpuCopy8(
|
||||
cursor, &map_matrix->headers, map_matrix->width * map_matrix->height * sizeof(u16));
|
||||
cursor += map_matrix->width * map_matrix->height * sizeof(u16);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
MIi_CpuClear16((u16)map_id,
|
||||
&map_matrix->headers,
|
||||
map_matrix->width * map_matrix->height * sizeof(u16));
|
||||
}
|
||||
|
||||
if (has_altitudes_section != 0)
|
||||
{
|
||||
if (has_altitudes_section != 0) {
|
||||
MI_CpuCopy8(
|
||||
cursor, &map_matrix->altitudes, map_matrix->width * map_matrix->height * sizeof(u8));
|
||||
cursor += map_matrix->width * map_matrix->height * sizeof(u8);
|
||||
|
|
@ -64,57 +58,50 @@ static void MapMatrix_MapMatrixData_Load(
|
|||
FreeToHeap(buffer);
|
||||
}
|
||||
|
||||
struct MapMatrix *MapMatrix_New(void)
|
||||
{
|
||||
struct MapMatrix *MapMatrix_New(void) {
|
||||
struct MapMatrix *map_matrix = AllocFromHeap(HEAP_ID_FIELD, sizeof(struct MapMatrix));
|
||||
|
||||
map_matrix->width = 0;
|
||||
map_matrix->height = 0;
|
||||
map_matrix->width = 0;
|
||||
map_matrix->height = 0;
|
||||
map_matrix->matrix_id = 0;
|
||||
|
||||
return map_matrix;
|
||||
}
|
||||
|
||||
void MapMatrix_Load(u16 map_id, struct MapMatrix *map_matrix)
|
||||
{
|
||||
void MapMatrix_Load(u16 map_id, struct MapMatrix *map_matrix) {
|
||||
u16 matrix_id = MapHeader_GetMatrixId(map_id);
|
||||
|
||||
MapMatrix_MapMatrixData_Load(&map_matrix->data, matrix_id, map_id);
|
||||
|
||||
map_matrix->matrix_id = (u8)matrix_id;
|
||||
map_matrix->height = map_matrix->data.height;
|
||||
map_matrix->width = map_matrix->data.width;
|
||||
map_matrix->height = map_matrix->data.height;
|
||||
map_matrix->width = map_matrix->data.width;
|
||||
}
|
||||
|
||||
void MapMatrix_Free(struct MapMatrix *map_matrix)
|
||||
{
|
||||
void MapMatrix_Free(struct MapMatrix *map_matrix) {
|
||||
FreeToHeap(map_matrix);
|
||||
}
|
||||
|
||||
u16 MapMatrix_GetMapData(s32 map_id, struct MapMatrix *map_matrix)
|
||||
{
|
||||
u16 MapMatrix_GetMapData(s32 map_id, struct MapMatrix *map_matrix) {
|
||||
GF_ASSERT(map_id < map_matrix->width * map_matrix->height);
|
||||
|
||||
return map_matrix->data.maps.data[map_id];
|
||||
}
|
||||
|
||||
u8 MapMatrix_GetWidth(struct MapMatrix *map_matrix)
|
||||
{
|
||||
u8 MapMatrix_GetWidth(struct MapMatrix *map_matrix) {
|
||||
GF_ASSERT(map_matrix != NULL);
|
||||
|
||||
return map_matrix->width;
|
||||
}
|
||||
|
||||
u8 MapMatrix_GetHeight(struct MapMatrix *map_matrix)
|
||||
{
|
||||
u8 MapMatrix_GetHeight(struct MapMatrix *map_matrix) {
|
||||
GF_ASSERT(map_matrix != NULL);
|
||||
|
||||
return map_matrix->height;
|
||||
}
|
||||
|
||||
u16 MapMatrix_GetMapHeader(struct MapMatrix *map_matrix, s32 x, s32 y)
|
||||
{
|
||||
s32 width = map_matrix->width;
|
||||
u16 MapMatrix_GetMapHeader(struct MapMatrix *map_matrix, s32 x, s32 y) {
|
||||
s32 width = map_matrix->width;
|
||||
s32 height = map_matrix->height;
|
||||
|
||||
GF_ASSERT(x >= 0 && x < width);
|
||||
|
|
@ -123,8 +110,7 @@ u16 MapMatrix_GetMapHeader(struct MapMatrix *map_matrix, s32 x, s32 y)
|
|||
return map_matrix->data.headers[y * width + x];
|
||||
}
|
||||
|
||||
u16 MapMatrix_GetMapHeaderFromID(struct MapMatrix *map_matrix, s32 map_id)
|
||||
{
|
||||
u16 MapMatrix_GetMapHeaderFromID(struct MapMatrix *map_matrix, s32 map_id) {
|
||||
s32 max_map_id = map_matrix->width * map_matrix->height;
|
||||
|
||||
GF_ASSERT(0 <= map_id && map_id < max_map_id);
|
||||
|
|
@ -132,14 +118,12 @@ u16 MapMatrix_GetMapHeaderFromID(struct MapMatrix *map_matrix, s32 map_id)
|
|||
return map_matrix->data.headers[map_id];
|
||||
}
|
||||
|
||||
u8 MapMatrix_GetMatrixID(struct MapMatrix *map_matrix)
|
||||
{
|
||||
u8 MapMatrix_GetMatrixID(struct MapMatrix *map_matrix) {
|
||||
return map_matrix->matrix_id;
|
||||
}
|
||||
|
||||
u32 MapMatrix_GetMapAltitude(
|
||||
struct MapMatrix *map_matrix, u8 param1, s16 x, s16 y, int matrix_width)
|
||||
{
|
||||
struct MapMatrix *map_matrix, u8 param1, s16 x, s16 y, int matrix_width) {
|
||||
#pragma unused(param1)
|
||||
GF_ASSERT(x < matrix_width);
|
||||
GF_ASSERT(y * matrix_width + x < MAP_MATRIX_MAX_SIZE);
|
||||
|
|
@ -147,12 +131,10 @@ u32 MapMatrix_GetMapAltitude(
|
|||
return map_matrix->data.altitudes[y * matrix_width + x];
|
||||
}
|
||||
|
||||
struct MapData *MapMatrix_MapData_New(HeapID heapId)
|
||||
{
|
||||
struct MapData *MapMatrix_MapData_New(HeapID heapId) {
|
||||
struct MapData *map_data = AllocFromHeap(heapId, sizeof(struct MapData));
|
||||
void *buffer =
|
||||
AllocAtEndAndReadWholeNarcMemberByIdPair(NARC_FIELDDATA_MAPMATRIX_MAP_MATRIX, 0, heapId);
|
||||
u8 *cursor = (u8 *)buffer;
|
||||
void *buffer = AllocAtEndAndReadWholeNarcMemberByIdPair(NARC_FIELDDATA_MAPMATRIX_MAP_MATRIX, 0, heapId);
|
||||
u8 *cursor = (u8 *)buffer;
|
||||
|
||||
cursor += 4;
|
||||
u8 name_length = *cursor;
|
||||
|
|
@ -165,19 +147,16 @@ struct MapData *MapMatrix_MapData_New(HeapID heapId)
|
|||
return map_data;
|
||||
}
|
||||
|
||||
void MapMatrix_MapData_Free(struct MapData *map_data)
|
||||
{
|
||||
void MapMatrix_MapData_Free(struct MapData *map_data) {
|
||||
GF_ASSERT(map_data != NULL);
|
||||
FreeToHeap(map_data);
|
||||
}
|
||||
|
||||
u16 MapMatrix_MapData_GetData(struct MapData *map_data, s32 x, s32 y)
|
||||
{
|
||||
u16 MapMatrix_MapData_GetData(struct MapData *map_data, s32 x, s32 y) {
|
||||
return map_data->data[MAP_MATRIX_MAX_WIDTH * y + x];
|
||||
}
|
||||
|
||||
u16 GetMapHeader(u32 file_id, u16 x, u16 y)
|
||||
{
|
||||
u16 GetMapHeader(u32 file_id, u16 x, u16 y) {
|
||||
struct MapMatrixData map_matrix;
|
||||
|
||||
MapMatrix_MapMatrixData_Load(&map_matrix, (u16)file_id, 0);
|
||||
|
|
@ -187,40 +166,35 @@ u16 GetMapHeader(u32 file_id, u16 x, u16 y)
|
|||
return map_matrix.headers[y * map_matrix.width + x];
|
||||
}
|
||||
|
||||
u16 GetMapData(s32 map_id, struct MapMatrix *map_matrix)
|
||||
{
|
||||
u16 GetMapData(s32 map_id, struct MapMatrix *map_matrix) {
|
||||
GF_ASSERT(map_matrix != NULL);
|
||||
return MapMatrix_GetMapData(map_id, map_matrix);
|
||||
}
|
||||
|
||||
void sub_02034678(struct MapMatrix *map_matrix)
|
||||
{
|
||||
u16 *maps = map_matrix->data.maps.data;
|
||||
void sub_02034678(struct MapMatrix *map_matrix) {
|
||||
u16 *maps = map_matrix->data.maps.data;
|
||||
u8 *altitudes = map_matrix->data.altitudes;
|
||||
u8 width = map_matrix->width;
|
||||
u8 width = map_matrix->width;
|
||||
|
||||
if (map_matrix->matrix_id != 0)
|
||||
{
|
||||
if (map_matrix->matrix_id != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
maps[width * 0x15 + 0x17] = 0xB0;
|
||||
maps[width * 0x15 + 0x18] = 0xB0;
|
||||
maps[width * 0x16 + 0x17] = 0xB0;
|
||||
maps[width * 0x16 + 0x18] = 0xB0;
|
||||
maps[width * 0x15 + 0x17] = 0xB0;
|
||||
maps[width * 0x15 + 0x18] = 0xB0;
|
||||
maps[width * 0x16 + 0x17] = 0xB0;
|
||||
maps[width * 0x16 + 0x18] = 0xB0;
|
||||
altitudes[width * 0x15 + 0x17] = 2;
|
||||
altitudes[width * 0x15 + 0x18] = 2;
|
||||
altitudes[width * 0x16 + 0x17] = 2;
|
||||
altitudes[width * 0x16 + 0x18] = 2;
|
||||
}
|
||||
|
||||
void sub_020346CC(struct MapMatrix *map_matrix)
|
||||
{
|
||||
void sub_020346CC(struct MapMatrix *map_matrix) {
|
||||
u16 *maps = map_matrix->data.maps.data;
|
||||
u8 width = map_matrix->width;
|
||||
u8 width = map_matrix->width;
|
||||
|
||||
if (map_matrix->matrix_id != 0)
|
||||
{
|
||||
if (map_matrix->matrix_id != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
#include "global.h"
|
||||
#include "map_object.h"
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "constants/sprites.h"
|
||||
|
||||
#include "field_system.h"
|
||||
#include "heap.h"
|
||||
#include "constants/sprites.h"
|
||||
#include "unk_0200CA44.h"
|
||||
|
||||
static MapObjectManager *MapObjectManager_New(u32 objectCount);
|
||||
|
|
@ -212,21 +215,21 @@ void MapObjectManager_Delete(MapObjectManager *manager) {
|
|||
}
|
||||
|
||||
void sub_020573C8(MapObjectManager *manager, u32 unused, u32 flagId, u32 objectCount, ObjectEvent *objectEvents) {
|
||||
u32 count = MapObjectManager_GetObjectCount(manager);
|
||||
u32 count = MapObjectManager_GetObjectCount(manager);
|
||||
LocalMapObject *objects = MapObjectManager_GetObjects(manager);
|
||||
|
||||
for (; count != 0; count--) {
|
||||
if (MapObject_IsInUse(objects) == TRUE) {
|
||||
switch (sub_02057F90(objects, flagId, objectCount, objectEvents)) {
|
||||
case 0:
|
||||
if (sub_02058450(objects) != flagId && !MapObject_TestFlagsBits(objects, MAPOBJECTFLAG_UNK10)) {
|
||||
MapObject_Remove(objects);
|
||||
}
|
||||
break;
|
||||
case 0:
|
||||
if (sub_02058450(objects) != flagId && !MapObject_TestFlagsBits(objects, MAPOBJECTFLAG_UNK10)) {
|
||||
MapObject_Remove(objects);
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
case 2:
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
break;
|
||||
}
|
||||
}
|
||||
objects++;
|
||||
|
|
@ -267,7 +270,7 @@ static LocalMapObject *MapObject_CreateFromObjectEvent(MapObjectManager *manager
|
|||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ret = MapObjectManager_GetFirstInactiveObject(manager);
|
||||
if (ret == NULL) {
|
||||
return ret;
|
||||
|
|
@ -306,11 +309,11 @@ LocalMapObject *MapObject_Create(MapObjectManager *manager, u32 x, u32 y, u32 di
|
|||
}
|
||||
|
||||
LocalMapObject *MapObject_CreateFromObjectEventWithId(MapObjectManager *manager, u16 id, u32 objectEventCount, u32 mapNo, const ObjectEvent *events) {
|
||||
LocalMapObject *ret = NULL;
|
||||
LocalMapObject *ret = NULL;
|
||||
ObjectEvent *objectEvent = ObjectEvent_GetById(id, objectEventCount, (ObjectEvent *)events);
|
||||
if (objectEvent != NULL) {
|
||||
u32 flagId = ObjectEvent_GetFlagID(objectEvent);
|
||||
FieldSystem* fieldSystem = MapObjectManager_GetFieldSystemPtr(manager);
|
||||
u32 flagId = ObjectEvent_GetFlagID(objectEvent);
|
||||
FieldSystem *fieldSystem = MapObjectManager_GetFieldSystemPtr(manager);
|
||||
if (FieldSystem_FlagCheck(fieldSystem, (u16)flagId) == FALSE) {
|
||||
ret = MapObject_CreateFromObjectEvent(manager, objectEvent, mapNo);
|
||||
}
|
||||
|
|
@ -344,7 +347,7 @@ void MapObject_Remove(LocalMapObject *object) {
|
|||
}
|
||||
|
||||
void MapObject_Delete(LocalMapObject *object) {
|
||||
u32 flagId = MapObject_GetFlagID(object);
|
||||
u32 flagId = MapObject_GetFlagID(object);
|
||||
FieldSystem *fieldSystem = MapObject_GetFieldSystem(object);
|
||||
FieldSystem_FlagSet(fieldSystem, flagId);
|
||||
MapObject_Remove(object);
|
||||
|
|
@ -366,11 +369,11 @@ void sub_020576A8(LocalMapObject *object) {
|
|||
}
|
||||
|
||||
void MapObjectManager_RemoveAllActiveObjects(MapObjectManager *manager) {
|
||||
s32 i = 0;
|
||||
s32 count = MapObjectManager_GetObjectCount(manager);
|
||||
s32 i = 0;
|
||||
s32 count = MapObjectManager_GetObjectCount(manager);
|
||||
LocalMapObject *objects = MapObjectManager_GetObjects(manager);
|
||||
|
||||
do { //BUG: does not check for if count is zero, and will always execute at least once
|
||||
do { // BUG: does not check for if count is zero, and will always execute at least once
|
||||
if (MapObject_GetFlagsBits(objects, MAPOBJECTFLAG_ACTIVE) != 0) {
|
||||
MapObject_Remove(objects);
|
||||
}
|
||||
|
|
@ -383,8 +386,8 @@ void MapObjectManager_RemoveAllActiveObjects(MapObjectManager *manager) {
|
|||
void sub_02057750(MapObjectManager *manager) {
|
||||
GF_ASSERT(sub_020587E0(manager) == TRUE);
|
||||
|
||||
s32 i = 0;
|
||||
s32 count = MapObjectManager_GetObjectCount(manager);
|
||||
s32 i = 0;
|
||||
s32 count = MapObjectManager_GetObjectCount(manager);
|
||||
LocalMapObject *objects = MapObjectManager_GetObjects(manager);
|
||||
|
||||
do {
|
||||
|
|
@ -401,8 +404,8 @@ void sub_02057750(MapObjectManager *manager) {
|
|||
void sub_020577A8(MapObjectManager *manager) {
|
||||
GF_ASSERT(sub_020587E0(manager) == TRUE);
|
||||
|
||||
s32 i = 0;
|
||||
s32 count = MapObjectManager_GetObjectCount(manager);
|
||||
s32 i = 0;
|
||||
s32 count = MapObjectManager_GetObjectCount(manager);
|
||||
LocalMapObject *objects = MapObjectManager_GetObjects(manager);
|
||||
|
||||
do {
|
||||
|
|
@ -425,7 +428,7 @@ void FieldSystem_SyncMapObjectsToSaveEx(FieldSystem *fieldSystem, MapObjectManag
|
|||
s32 index = 0;
|
||||
LocalMapObject *object;
|
||||
|
||||
while (MapObjectManager_GetNextObjectWithFlagFromIndex(manager, &object, &index, MAPOBJECTFLAG_ACTIVE)) { //MapObjectManager_GetNextActiveObject? this is an iterator however
|
||||
while (MapObjectManager_GetNextObjectWithFlagFromIndex(manager, &object, &index, MAPOBJECTFLAG_ACTIVE)) { // MapObjectManager_GetNextActiveObject? this is an iterator however
|
||||
SavedMapObject_InitFromLocalMapObject(fieldSystem, object, savedObjects);
|
||||
|
||||
count--;
|
||||
|
|
@ -441,7 +444,7 @@ void FieldSystem_SyncMapObjectsToSaveEx(FieldSystem *fieldSystem, MapObjectManag
|
|||
|
||||
void MapObjectManager_RestoreFromSave(MapObjectManager *manager, SavedMapObject *savedObjects, u32 objectCount) {
|
||||
while (objectCount > 0) {
|
||||
if ((savedObjects->flags & MAPOBJECTFLAG_ACTIVE)) {
|
||||
if (savedObjects->flags & MAPOBJECTFLAG_ACTIVE) {
|
||||
LocalMapObject *localObject = MapObjectManager_GetFirstInactiveObject(manager);
|
||||
GF_ASSERT(localObject != NULL);
|
||||
|
||||
|
|
@ -454,32 +457,32 @@ void MapObjectManager_RestoreFromSave(MapObjectManager *manager, SavedMapObject
|
|||
}
|
||||
|
||||
static void SavedMapObject_InitFromLocalMapObject(FieldSystem *fieldSystem, LocalMapObject *localObject, SavedMapObject *savedObject) {
|
||||
savedObject->flags = MapObject_GetFlagsWord(localObject);
|
||||
savedObject->flags2 = MapObject_GetFlags2Word(localObject);
|
||||
savedObject->objId = MapObject_GetID(localObject);
|
||||
savedObject->unk10 = sub_02058450(localObject);
|
||||
savedObject->spriteId = MapObject_GetSpriteID(localObject);
|
||||
savedObject->movement = MapObject_GetMovement(localObject);
|
||||
savedObject->type = MapObject_GetType(localObject);
|
||||
savedObject->flagId = MapObject_GetFlagID(localObject);
|
||||
savedObject->script = MapObject_GetScriptID(localObject);
|
||||
savedObject->flags = MapObject_GetFlagsWord(localObject);
|
||||
savedObject->flags2 = MapObject_GetFlags2Word(localObject);
|
||||
savedObject->objId = MapObject_GetID(localObject);
|
||||
savedObject->unk10 = sub_02058450(localObject);
|
||||
savedObject->spriteId = MapObject_GetSpriteID(localObject);
|
||||
savedObject->movement = MapObject_GetMovement(localObject);
|
||||
savedObject->type = MapObject_GetType(localObject);
|
||||
savedObject->flagId = MapObject_GetFlagID(localObject);
|
||||
savedObject->script = MapObject_GetScriptID(localObject);
|
||||
savedObject->initialFacing = MapObject_GetInitialFacingDirection(localObject);
|
||||
savedObject->currentFacing = MapObject_GetFacingDirection(localObject);
|
||||
savedObject->nextFacing = MapObject_GetNextFacingDirection(localObject);
|
||||
savedObject->param[0] = MapObject_GetParam(localObject, 0);
|
||||
savedObject->param[1] = MapObject_GetParam(localObject, 1);
|
||||
savedObject->param[2] = MapObject_GetParam(localObject, 2);
|
||||
savedObject->xRange = MapObject_GetXRange(localObject);
|
||||
savedObject->yRange = MapObject_GetYRange(localObject);
|
||||
savedObject->initialX = MapObject_GetInitialX(localObject);
|
||||
savedObject->nextFacing = MapObject_GetNextFacingDirection(localObject);
|
||||
savedObject->param[0] = MapObject_GetParam(localObject, 0);
|
||||
savedObject->param[1] = MapObject_GetParam(localObject, 1);
|
||||
savedObject->param[2] = MapObject_GetParam(localObject, 2);
|
||||
savedObject->xRange = MapObject_GetXRange(localObject);
|
||||
savedObject->yRange = MapObject_GetYRange(localObject);
|
||||
savedObject->initialX = MapObject_GetInitialX(localObject);
|
||||
savedObject->initialHeight = MapObject_GetInitialHeight(localObject);
|
||||
savedObject->initialY = MapObject_GetInitialY(localObject);
|
||||
savedObject->currentX = MapObject_GetCurrentX(localObject);
|
||||
savedObject->initialY = MapObject_GetInitialY(localObject);
|
||||
savedObject->currentX = MapObject_GetCurrentX(localObject);
|
||||
savedObject->currentHeight = MapObject_GetCurrentHeight(localObject);
|
||||
savedObject->currentY = MapObject_GetCurrentY(localObject);
|
||||
savedObject->currentY = MapObject_GetCurrentY(localObject);
|
||||
|
||||
VecFx32 coords;
|
||||
sub_02059E60(savedObject->currentX, savedObject->currentY, &coords); //some kind of x y vec copy with convertion between int and fx32
|
||||
sub_02059E60(savedObject->currentX, savedObject->currentY, &coords); // some kind of x y vec copy with convertion between int and fx32
|
||||
coords.y = MapObject_GetPosVecYCoord(localObject);
|
||||
|
||||
if (!sub_02059EC8(fieldSystem, &coords, MapObject_CheckFlag29(localObject))) {
|
||||
|
|
@ -487,7 +490,7 @@ static void SavedMapObject_InitFromLocalMapObject(FieldSystem *fieldSystem, Loca
|
|||
} else {
|
||||
savedObject->vecY = coords.y;
|
||||
}
|
||||
|
||||
|
||||
memcpy(savedObject->unk30, sub_020585B0(localObject), 16);
|
||||
memcpy(savedObject->unk40, sub_020585D8(localObject), 16);
|
||||
}
|
||||
|
|
@ -518,7 +521,7 @@ static void LocalMapObject_InitFromSavedMapObject(LocalMapObject *localObject, S
|
|||
MapObject_SetCurrentY(localObject, savedObject->currentY);
|
||||
|
||||
VecFx32 coords = {};
|
||||
coords.y = savedObject->vecY;
|
||||
coords.y = savedObject->vecY;
|
||||
MapObject_SetPositionVec(localObject, &coords);
|
||||
|
||||
memcpy(sub_020585B0(localObject), savedObject->unk30, 16);
|
||||
|
|
@ -539,10 +542,7 @@ static void sub_02057AEC(MapObjectManager *manager, LocalMapObject *object) {
|
|||
|
||||
static void sub_02057B34(LocalMapObject *object) {
|
||||
MapObject_SetFlagsBits(object, (MapObjectFlagBits)(MAPOBJECTFLAG_UNK2 | MAPOBJECTFLAG_ACTIVE));
|
||||
MapObject_ClearFlagsBits(object, (MapObjectFlagBits)(MAPOBJECTFLAG_IGNORE_HEIGHTS | MAPOBJECTFLAG_UNK22 |
|
||||
MAPOBJECTFLAG_UNK21 | MAPOBJECTFLAG_UNK19 | MAPOBJECTFLAG_UNK18 |
|
||||
MAPOBJECTFLAG_UNK17 | MAPOBJECTFLAG_UNK16 | MAPOBJECTFLAG_UNK14 |
|
||||
MAPOBJECTFLAG_VISIBLE | MAPOBJECTFLAG_MOVEMENT_PAUSED | MAPOBJECTFLAG_UNK3));
|
||||
MapObject_ClearFlagsBits(object, (MapObjectFlagBits)(MAPOBJECTFLAG_IGNORE_HEIGHTS | MAPOBJECTFLAG_UNK22 | MAPOBJECTFLAG_UNK21 | MAPOBJECTFLAG_UNK19 | MAPOBJECTFLAG_UNK18 | MAPOBJECTFLAG_UNK17 | MAPOBJECTFLAG_UNK16 | MAPOBJECTFLAG_UNK14 | MAPOBJECTFLAG_VISIBLE | MAPOBJECTFLAG_MOVEMENT_PAUSED | MAPOBJECTFLAG_UNK3));
|
||||
sub_0205815C(object);
|
||||
}
|
||||
|
||||
|
|
@ -550,13 +550,13 @@ static void MapObject_ConvertXYToPositionVec(LocalMapObject *object) {
|
|||
VecFx32 position;
|
||||
MapObject_GetPositionVec(object, &position);
|
||||
|
||||
u32 x = MapObject_GetCurrentX(object);
|
||||
u32 x = MapObject_GetCurrentX(object);
|
||||
position.x = x * FX32_CONST(16) + FX32_CONST(8);
|
||||
MapObject_SetPreviousX(object, x);
|
||||
|
||||
MapObject_SetPreviousHeight(object, MapObject_GetCurrentHeight(object));
|
||||
|
||||
u32 y = MapObject_GetCurrentY(object);
|
||||
u32 y = MapObject_GetCurrentY(object);
|
||||
position.z = y * FX32_CONST(16) + FX32_CONST(8);
|
||||
MapObject_SetPreviousY(object, y);
|
||||
|
||||
|
|
@ -572,22 +572,21 @@ void MapObject_CreateFromMultipleObjectEvents(MapObjectManager *manager, u32 map
|
|||
|
||||
MapObjectInitArgs *args = AllocFromHeapAtEnd(HEAP_ID_FIELD, sizeof(MapObjectInitArgs));
|
||||
GF_ASSERT(args != NULL);
|
||||
args->mapNo = mapNo;
|
||||
args->mapNo = mapNo;
|
||||
args->objectEventCount = objectEventCount;
|
||||
args->index = 0;
|
||||
args->manager = manager;
|
||||
args->objectEvents = objectEventsCopy;
|
||||
args->index = 0;
|
||||
args->manager = manager;
|
||||
args->objectEvents = objectEventsCopy;
|
||||
|
||||
MapObject_CreateFromInitArgs(args);
|
||||
}
|
||||
|
||||
static void MapObject_CreateFromInitArgs(MapObjectInitArgs *args) {
|
||||
FieldSystem *fieldSystem = MapObjectManager_GetFieldSystemPtr(args->manager);
|
||||
FieldSystem *fieldSystem = MapObjectManager_GetFieldSystemPtr(args->manager);
|
||||
ObjectEvent *objectEvents = args->objectEvents;
|
||||
|
||||
do { //must be do while due to initial check
|
||||
GF_ASSERT((ObjectEvent_ScriptIDIsUnset(objectEvents) != TRUE && FieldSystem_FlagCheck(fieldSystem, objectEvents->flag) != FALSE) ||
|
||||
MapObject_CreateFromObjectEvent(args->manager, objectEvents, args->mapNo) != NULL); //this is dumb, but is required to match
|
||||
do { // must be do while due to initial check
|
||||
GF_ASSERT((ObjectEvent_ScriptIDIsUnset(objectEvents) != TRUE && FieldSystem_FlagCheck(fieldSystem, objectEvents->flag) != FALSE) || MapObject_CreateFromObjectEvent(args->manager, objectEvents, args->mapNo) != NULL); // this is dumb, but is required to match
|
||||
|
||||
objectEvents++;
|
||||
args->index++;
|
||||
|
|
@ -598,8 +597,8 @@ static void MapObject_CreateFromInitArgs(MapObjectInitArgs *args) {
|
|||
}
|
||||
|
||||
static LocalMapObject *MapObjectManager_GetFirstInactiveObject(MapObjectManager *manager) {
|
||||
s32 i = 0;
|
||||
s32 count = MapObjectManager_GetObjectCount(manager);
|
||||
s32 i = 0;
|
||||
s32 count = MapObjectManager_GetObjectCount(manager);
|
||||
LocalMapObject *objects = MapObjectManager_GetObjects(manager);
|
||||
|
||||
do {
|
||||
|
|
@ -614,7 +613,7 @@ static LocalMapObject *MapObjectManager_GetFirstInactiveObject(MapObjectManager
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static LocalMapObject *sub_02057C98(MapObjectManager *manager, u32 id, u32 mapNo) { //find corresponding LMO with ID and mapNo?
|
||||
static LocalMapObject *sub_02057C98(MapObjectManager *manager, u32 id, u32 mapNo) { // find corresponding LMO with ID and mapNo?
|
||||
s32 index = 0;
|
||||
LocalMapObject *object;
|
||||
|
||||
|
|
@ -660,19 +659,19 @@ static void MapObject_InitFromObjectEvent(LocalMapObject *object, ObjectEvent *o
|
|||
static void MapObject_SetPositionVecFromObjectEvent(LocalMapObject *object, ObjectEvent *objectEvent) {
|
||||
VecFx32 coords;
|
||||
|
||||
u16 x = ObjectEvent_GetXCoord(objectEvent);
|
||||
u16 x = ObjectEvent_GetXCoord(objectEvent);
|
||||
coords.x = x * FX32_CONST(16) + FX32_CONST(8);
|
||||
MapObject_SetInitialX(object, x);
|
||||
MapObject_SetPreviousX(object, x);
|
||||
MapObject_SetCurrentX(object, x);
|
||||
|
||||
coords.y = ObjectEvent_GetHeight(objectEvent);
|
||||
coords.y = ObjectEvent_GetHeight(objectEvent);
|
||||
u32 height = (coords.y >> 3) / FX32_ONE;
|
||||
MapObject_SetInitialHeight(object, height);
|
||||
MapObject_SetPreviousHeight(object, height);
|
||||
MapObject_SetCurrentHeight(object, height);
|
||||
|
||||
u16 y = ObjectEvent_GetYCoord(objectEvent);
|
||||
u16 y = ObjectEvent_GetYCoord(objectEvent);
|
||||
coords.z = y * FX32_CONST(16) + FX32_CONST(8);
|
||||
MapObject_SetInitialY(object, y);
|
||||
MapObject_SetPreviousY(object, y);
|
||||
|
|
@ -681,7 +680,7 @@ static void MapObject_SetPositionVecFromObjectEvent(LocalMapObject *object, Obje
|
|||
MapObject_SetPositionVec(object, &coords);
|
||||
}
|
||||
|
||||
static void sub_02057E90(LocalMapObject *object, MapObjectManager *manager) { //setup facing and flags? also sets manager?
|
||||
static void sub_02057E90(LocalMapObject *object, MapObjectManager *manager) { // setup facing and flags? also sets manager?
|
||||
MapObject_SetFlagsBits(object, (MapObjectFlagBits)(MAPOBJECTFLAG_UNK12 | MAPOBJECTFLAG_UNK11 | MAPOBJECTFLAG_ACTIVE));
|
||||
if (MapObject_ScriptIDIsFFFF(object) == TRUE) {
|
||||
MapObject_SetFlag25(object, TRUE);
|
||||
|
|
@ -702,7 +701,7 @@ static void sub_02057E90(LocalMapObject *object, MapObjectManager *manager) { //
|
|||
extern const UnkLMOCallbackStruct2 ov05_021F9080;
|
||||
|
||||
/*static*/ void sub_02057F18(LocalMapObject *object) {
|
||||
u32 spriteId = MapObject_GetSpriteID(object);
|
||||
u32 spriteId = MapObject_GetSpriteID(object);
|
||||
UnkLMOCallbackStruct2 *unk = (spriteId == SPRITE_CAMERA_FOCUS) ? (UnkLMOCallbackStruct2 *)&ov05_021F9080 : sub_02058D4C(spriteId);
|
||||
|
||||
sub_02058684(object, sub_02058D38(unk));
|
||||
|
|
@ -724,7 +723,7 @@ static u32 sub_02057F90(LocalMapObject *object, u32 flagId, u32 objectEventCount
|
|||
|
||||
if (ObjectEvent_ScriptIDIsUnset(objectEvents) == TRUE) {
|
||||
u16 flagIdUnset = ObjectEvent_GetFlagID_AssertScriptIDIsUnset(objectEvents);
|
||||
if (MapObject_CheckFlag25(object) == TRUE) { //this and the one below cannot be combined as it doesn't match
|
||||
if (MapObject_CheckFlag25(object) == TRUE) { // this and the one below cannot be combined as it doesn't match
|
||||
if (sub_02058750(object) == flagIdUnset) {
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -739,8 +738,8 @@ static u32 sub_02057F90(LocalMapObject *object, u32 flagId, u32 objectEventCount
|
|||
return 0;
|
||||
}
|
||||
|
||||
//TODO: this also gets based on the second param, which is currently labelled as flagId, but is not
|
||||
//see the note attached to sub_02058450
|
||||
// TODO: this also gets based on the second param, which is currently labelled as flagId, but is not
|
||||
// see the note attached to sub_02058450
|
||||
static LocalMapObject *MapObjectManager_GetFirstObjectWithID(MapObjectManager *manager, u32 objectId, u32 flagId) {
|
||||
s32 index = 0;
|
||||
LocalMapObject *object;
|
||||
|
|
@ -757,12 +756,10 @@ static LocalMapObject *MapObjectManager_GetFirstObjectWithID(MapObjectManager *m
|
|||
LocalMapObject *MapObjectManager_GetFirstActiveObjectByID(MapObjectManager *manager, u32 id) {
|
||||
GF_ASSERT(manager != NULL);
|
||||
|
||||
s32 count = MapObjectManager_GetObjectCount(manager);
|
||||
s32 count = MapObjectManager_GetObjectCount(manager);
|
||||
LocalMapObject *objects = (LocalMapObject *)MapObjectManager_GetConstObjects(manager);
|
||||
do {
|
||||
if (MapObject_TestFlagsBits(objects, MAPOBJECTFLAG_ACTIVE) == TRUE &&
|
||||
MapObject_CheckFlag25(objects) == FALSE && MapObject_GetID(objects) == id)
|
||||
{
|
||||
if (MapObject_TestFlagsBits(objects, MAPOBJECTFLAG_ACTIVE) == TRUE && MapObject_CheckFlag25(objects) == FALSE && MapObject_GetID(objects) == id) {
|
||||
return objects;
|
||||
}
|
||||
|
||||
|
|
@ -774,7 +771,7 @@ LocalMapObject *MapObjectManager_GetFirstActiveObjectByID(MapObjectManager *mana
|
|||
}
|
||||
|
||||
LocalMapObject *MapObjectManager_GetFirstActiveObjectWithMovement(MapObjectManager *manager, u32 movement) {
|
||||
s32 count = MapObjectManager_GetObjectCount(manager);
|
||||
s32 count = MapObjectManager_GetObjectCount(manager);
|
||||
LocalMapObject *objects = (LocalMapObject *)MapObjectManager_GetConstObjects(manager);
|
||||
|
||||
do {
|
||||
|
|
@ -796,7 +793,7 @@ BOOL MapObjectManager_GetNextObjectWithFlagFromIndex(MapObjectManager *manager,
|
|||
}
|
||||
|
||||
LocalMapObject *objects = (LocalMapObject *)MapObjectManager_GetConstObjects(manager);
|
||||
LocalMapObject *object = objects + *index;
|
||||
LocalMapObject *object = objects + *index;
|
||||
do {
|
||||
(*index)++;
|
||||
|
||||
|
|
@ -817,8 +814,7 @@ static void sub_02058148(LocalMapObject *object) {
|
|||
}
|
||||
|
||||
/*static*/ void sub_0205815C(LocalMapObject *object) {
|
||||
MapObject_ClearFlagsBits(object, (MapObjectFlagBits)(MAPOBJECTFLAG_UNK26 | MAPOBJECTFLAG_UNK24 |
|
||||
MAPOBJECTFLAG_UNK20 | MAPOBJECTFLAG_UNK15));
|
||||
MapObject_ClearFlagsBits(object, (MapObjectFlagBits)(MAPOBJECTFLAG_UNK26 | MAPOBJECTFLAG_UNK24 | MAPOBJECTFLAG_UNK20 | MAPOBJECTFLAG_UNK15));
|
||||
}
|
||||
|
||||
static void MapObject_NoOp(LocalMapObject *object) {
|
||||
|
|
@ -826,8 +822,8 @@ static void MapObject_NoOp(LocalMapObject *object) {
|
|||
}
|
||||
|
||||
static u32 FieldSystem_ResolveObjectSpriteID(FieldSystem *fieldSystem, s32 spriteId) {
|
||||
//BUG: index out of range, should be < not <=
|
||||
//TODO: check these with sprite constants, these should be variable sprites but this starts at 101 not 100
|
||||
// BUG: index out of range, should be < not <=
|
||||
// TODO: check these with sprite constants, these should be variable sprites but this starts at 101 not 100
|
||||
if (spriteId >= 101 && spriteId <= 117) {
|
||||
spriteId = FieldSystem_VarGetObjectEventGraphicsId(fieldSystem, (u16)(spriteId - 101));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
#include "global.h"
|
||||
#include "math_util.h"
|
||||
|
||||
#include "global.h"
|
||||
|
||||
extern const s16 FX_SinCosTable_[]; // temporary until further notice
|
||||
|
||||
/*
|
||||
* Constant tables
|
||||
*/
|
||||
const fx32 gSineTable[] =
|
||||
{
|
||||
const fx32 gSineTable[] = {
|
||||
FX32_CONST(0.0), // sin(0)
|
||||
FX32_CONST(0.017333984375), // sin(1)
|
||||
FX32_CONST(0.034912109375), // sin(2)
|
||||
|
|
@ -461,63 +461,12 @@ const fx32 gSineTable[] =
|
|||
};
|
||||
|
||||
static const u16 UNK_020EDC7E[] = // rotations?
|
||||
{
|
||||
0x0000, 0x00B7, 0x016D, 0x0223, 0x02D9, 0x038F, 0x0445, 0x04FB, 0x05B1, 0x0667,
|
||||
0x071D, 0x07D3, 0x0889, 0x093F, 0x09F5, 0x0AAB, 0x0B61, 0x0C17, 0x0CCD, 0x0D83,
|
||||
0x0E39, 0x0EEF, 0x0FA5, 0x105C, 0x1112, 0x11C8, 0x127E, 0x1334, 0x13EA, 0x14A0,
|
||||
0x1556, 0x160C, 0x16C2, 0x1778, 0x182E, 0x18E4, 0x199A, 0x1A50, 0x1B06, 0x1BBC,
|
||||
0x1C72, 0x1D28, 0x1DDE, 0x1E94, 0x1F4A, 0x2000, 0x20B7, 0x216D, 0x2223, 0x22D9,
|
||||
0x238F, 0x2445, 0x24FB, 0x25B1, 0x2667, 0x271D, 0x27D3, 0x2889, 0x293F, 0x29F5,
|
||||
0x2AAB, 0x2B61, 0x2C17, 0x2CCD, 0x2D83, 0x2E39, 0x2EEF, 0x2FA5, 0x305C, 0x3112,
|
||||
0x31C8, 0x327E, 0x3334, 0x33EA, 0x34A0, 0x3556, 0x360C, 0x36C2, 0x3778, 0x382E,
|
||||
0x38E4, 0x399A, 0x3A50, 0x3B06, 0x3BBC, 0x3C72, 0x3D28, 0x3DDE, 0x3E94, 0x3F4A,
|
||||
0x4000, 0x40B7, 0x416D, 0x4223, 0x42D9, 0x438F, 0x4445, 0x44FB, 0x45B1, 0x4667,
|
||||
0x471D, 0x47D3, 0x4889, 0x493F, 0x49F5, 0x4AAB, 0x4B61, 0x4C17, 0x4CCD, 0x4D83,
|
||||
0x4E39, 0x4EEF, 0x4FA5, 0x505C, 0x5112, 0x51C8, 0x527E, 0x5334, 0x53EA, 0x54A0,
|
||||
0x5556, 0x560C, 0x56C2, 0x5778, 0x582E, 0x58E4, 0x599A, 0x5A50, 0x5B06, 0x5BBC,
|
||||
0x5C72, 0x5D28, 0x5DDE, 0x5E94, 0x5F4A, 0x6000, 0x60B7, 0x616D, 0x6223, 0x62D9,
|
||||
0x638F, 0x6445, 0x64FB, 0x65B1, 0x6667, 0x671D, 0x67D3, 0x6889, 0x693F, 0x69F5,
|
||||
0x6AAB, 0x6B61, 0x6C17, 0x6CCD, 0x6D83, 0x6E39, 0x6EEF, 0x6FA5, 0x705C, 0x7112,
|
||||
0x71C8, 0x727E, 0x7334, 0x73EA, 0x74A0, 0x7556, 0x760C, 0x76C2, 0x7778, 0x782E,
|
||||
0x78E4, 0x799A, 0x7A50, 0x7B06, 0x7BBC, 0x7C72, 0x7D28, 0x7DDE, 0x7E94, 0x7F4A,
|
||||
0x8000, 0x80B7, 0x816D, 0x8223, 0x82D9, 0x838F, 0x8445, 0x84FB, 0x85B1, 0x8667,
|
||||
0x871D, 0x87D3, 0x8889, 0x893F, 0x89F5, 0x8AAB, 0x8B61, 0x8C17, 0x8CCD, 0x8D83,
|
||||
0x8E39, 0x8EEF, 0x8FA5, 0x905C, 0x9112, 0x91C8, 0x927E, 0x9334, 0x93EA, 0x94A0,
|
||||
0x9556, 0x960C, 0x96C2, 0x9778, 0x982E, 0x98E4, 0x999A, 0x9A50, 0x9B06, 0x9BBC,
|
||||
0x9C72, 0x9D28, 0x9DDE, 0x9E94, 0x9F4A, 0xA000, 0xA0B7, 0xA16D, 0xA223, 0xA2D9,
|
||||
0xA38F, 0xA445, 0xA4FB, 0xA5B1, 0xA667, 0xA71D, 0xA7D3, 0xA889, 0xA93F, 0xA9F5,
|
||||
0xAAAB, 0xAB61, 0xAC17, 0xACCD, 0xAD83, 0xAE39, 0xAEEF, 0xAFA5, 0xB05C, 0xB112,
|
||||
0xB1C8, 0xB27E, 0xB334, 0xB3EA, 0xB4A0, 0xB556, 0xB60C, 0xB6C2, 0xB778, 0xB82E,
|
||||
0xB8E4, 0xB99A, 0xBA50, 0xBB06, 0xBBBC, 0xBC72, 0xBD28, 0xBDDE, 0xBE94, 0xBF4A,
|
||||
0xC000, 0xC0B7, 0xC16D, 0xC223, 0xC2D9, 0xC38F, 0xC445, 0xC4FB, 0xC5B1, 0xC667,
|
||||
0xC71D, 0xC7D3, 0xC889, 0xC93F, 0xC9F5, 0xCAAB, 0xCB61, 0xCC17, 0xCCCD, 0xCD83,
|
||||
0xCE39, 0xCEEF, 0xCFA5, 0xD05C, 0xD112, 0xD1C8, 0xD27E, 0xD334, 0xD3EA, 0xD4A0,
|
||||
0xD556, 0xD60C, 0xD6C2, 0xD778, 0xD82E, 0xD8E4, 0xD99A, 0xDA50, 0xDB06, 0xDBBC,
|
||||
0xDC72, 0xDD28, 0xDDDE, 0xDE94, 0xDF4A, 0xE000, 0xE0B7, 0xE16D, 0xE223, 0xE2D9,
|
||||
0xE38F, 0xE445, 0xE4FB, 0xE5B1, 0xE667, 0xE71D, 0xE7D3, 0xE889, 0xE93F, 0xE9F5,
|
||||
0xEAAB, 0xEB61, 0xEC17, 0xECCD, 0xED83, 0xEE39, 0xEEEF, 0xEFA5, 0xF05C, 0xF112,
|
||||
0xF1C8, 0xF27E, 0xF334, 0xF3EA, 0xF4A0, 0xF556, 0xF60C, 0xF6C2, 0xF778, 0xF82E,
|
||||
0xF8E4, 0xF99A, 0xFA50, 0xFB06, 0xFBBC, 0xFC72, 0xFD28, 0xFDDE, 0xFE94, 0xFF4A
|
||||
};
|
||||
{
|
||||
0x0000, 0x00B7, 0x016D, 0x0223, 0x02D9, 0x038F, 0x0445, 0x04FB, 0x05B1, 0x0667, 0x071D, 0x07D3, 0x0889, 0x093F, 0x09F5, 0x0AAB, 0x0B61, 0x0C17, 0x0CCD, 0x0D83, 0x0E39, 0x0EEF, 0x0FA5, 0x105C, 0x1112, 0x11C8, 0x127E, 0x1334, 0x13EA, 0x14A0, 0x1556, 0x160C, 0x16C2, 0x1778, 0x182E, 0x18E4, 0x199A, 0x1A50, 0x1B06, 0x1BBC, 0x1C72, 0x1D28, 0x1DDE, 0x1E94, 0x1F4A, 0x2000, 0x20B7, 0x216D, 0x2223, 0x22D9, 0x238F, 0x2445, 0x24FB, 0x25B1, 0x2667, 0x271D, 0x27D3, 0x2889, 0x293F, 0x29F5, 0x2AAB, 0x2B61, 0x2C17, 0x2CCD, 0x2D83, 0x2E39, 0x2EEF, 0x2FA5, 0x305C, 0x3112, 0x31C8, 0x327E, 0x3334, 0x33EA, 0x34A0, 0x3556, 0x360C, 0x36C2, 0x3778, 0x382E, 0x38E4, 0x399A, 0x3A50, 0x3B06, 0x3BBC, 0x3C72, 0x3D28, 0x3DDE, 0x3E94, 0x3F4A, 0x4000, 0x40B7, 0x416D, 0x4223, 0x42D9, 0x438F, 0x4445, 0x44FB, 0x45B1, 0x4667, 0x471D, 0x47D3, 0x4889, 0x493F, 0x49F5, 0x4AAB, 0x4B61, 0x4C17, 0x4CCD, 0x4D83, 0x4E39, 0x4EEF, 0x4FA5, 0x505C, 0x5112, 0x51C8, 0x527E, 0x5334, 0x53EA, 0x54A0, 0x5556, 0x560C, 0x56C2, 0x5778, 0x582E, 0x58E4, 0x599A, 0x5A50, 0x5B06, 0x5BBC, 0x5C72, 0x5D28, 0x5DDE, 0x5E94, 0x5F4A, 0x6000, 0x60B7, 0x616D, 0x6223, 0x62D9, 0x638F, 0x6445, 0x64FB, 0x65B1, 0x6667, 0x671D, 0x67D3, 0x6889, 0x693F, 0x69F5, 0x6AAB, 0x6B61, 0x6C17, 0x6CCD, 0x6D83, 0x6E39, 0x6EEF, 0x6FA5, 0x705C, 0x7112, 0x71C8, 0x727E, 0x7334, 0x73EA, 0x74A0, 0x7556, 0x760C, 0x76C2, 0x7778, 0x782E, 0x78E4, 0x799A, 0x7A50, 0x7B06, 0x7BBC, 0x7C72, 0x7D28, 0x7DDE, 0x7E94, 0x7F4A, 0x8000, 0x80B7, 0x816D, 0x8223, 0x82D9, 0x838F, 0x8445, 0x84FB, 0x85B1, 0x8667, 0x871D, 0x87D3, 0x8889, 0x893F, 0x89F5, 0x8AAB, 0x8B61, 0x8C17, 0x8CCD, 0x8D83, 0x8E39, 0x8EEF, 0x8FA5, 0x905C, 0x9112, 0x91C8, 0x927E, 0x9334, 0x93EA, 0x94A0, 0x9556, 0x960C, 0x96C2, 0x9778, 0x982E, 0x98E4, 0x999A, 0x9A50, 0x9B06, 0x9BBC, 0x9C72, 0x9D28, 0x9DDE, 0x9E94, 0x9F4A, 0xA000, 0xA0B7, 0xA16D, 0xA223, 0xA2D9, 0xA38F, 0xA445, 0xA4FB, 0xA5B1, 0xA667, 0xA71D, 0xA7D3, 0xA889, 0xA93F, 0xA9F5, 0xAAAB, 0xAB61, 0xAC17, 0xACCD, 0xAD83, 0xAE39, 0xAEEF, 0xAFA5, 0xB05C, 0xB112, 0xB1C8, 0xB27E, 0xB334, 0xB3EA, 0xB4A0, 0xB556, 0xB60C, 0xB6C2, 0xB778, 0xB82E, 0xB8E4, 0xB99A, 0xBA50, 0xBB06, 0xBBBC, 0xBC72, 0xBD28, 0xBDDE, 0xBE94, 0xBF4A, 0xC000, 0xC0B7, 0xC16D, 0xC223, 0xC2D9, 0xC38F, 0xC445, 0xC4FB, 0xC5B1, 0xC667, 0xC71D, 0xC7D3, 0xC889, 0xC93F, 0xC9F5, 0xCAAB, 0xCB61, 0xCC17, 0xCCCD, 0xCD83, 0xCE39, 0xCEEF, 0xCFA5, 0xD05C, 0xD112, 0xD1C8, 0xD27E, 0xD334, 0xD3EA, 0xD4A0, 0xD556, 0xD60C, 0xD6C2, 0xD778, 0xD82E, 0xD8E4, 0xD99A, 0xDA50, 0xDB06, 0xDBBC, 0xDC72, 0xDD28, 0xDDDE, 0xDE94, 0xDF4A, 0xE000, 0xE0B7, 0xE16D, 0xE223, 0xE2D9, 0xE38F, 0xE445, 0xE4FB, 0xE5B1, 0xE667, 0xE71D, 0xE7D3, 0xE889, 0xE93F, 0xE9F5, 0xEAAB, 0xEB61, 0xEC17, 0xECCD, 0xED83, 0xEE39, 0xEEEF, 0xEFA5, 0xF05C, 0xF112, 0xF1C8, 0xF27E, 0xF334, 0xF3EA, 0xF4A0, 0xF556, 0xF60C, 0xF6C2, 0xF778, 0xF82E, 0xF8E4, 0xF99A, 0xFA50, 0xFB06, 0xFBBC, 0xFC72, 0xFD28, 0xFDDE, 0xFE94, 0xFF4A
|
||||
};
|
||||
|
||||
static const u16 UNK_020EDB80[] =
|
||||
{
|
||||
0x169F, 0x0F14, 0x0B4F, 0x090C, 0x078A, 0x0676, 0x05A7, 0x0506,
|
||||
0x0486, 0x041C, 0x03C5, 0x037A, 0x033B, 0x0304, 0x02D3, 0x02A9,
|
||||
0x0283, 0x0261, 0x0243, 0x0227, 0x020E, 0x01F7, 0x01E2, 0x01CF,
|
||||
0x01BD, 0x01AC, 0x019D, 0x018F, 0x0182, 0x0175, 0x0169, 0x015E,
|
||||
0x0154, 0x014A, 0x0141, 0x0139, 0x0130, 0x0128, 0x0121, 0x011A,
|
||||
0x0113, 0x010D, 0x0107, 0x0101, 0x00FB, 0x00F6, 0x00F1, 0x00EC,
|
||||
0x00E7, 0x00E3, 0x00DE, 0x00DA, 0x00D6, 0x00D2, 0x00CE, 0x00CB,
|
||||
0x00C7, 0x00C4, 0x00C1, 0x00BD, 0x00BA, 0x00B7, 0x00B4, 0x00B2,
|
||||
0x00AF, 0x00AC, 0x00AA, 0x00A7, 0x00A5, 0x00A3, 0x00A0, 0x009E,
|
||||
0x009C, 0x009A, 0x0098, 0x0096, 0x0094, 0x0092, 0x0090, 0x008E,
|
||||
0x008D, 0x008B, 0x0089, 0x0088, 0x0086, 0x0085, 0x0083, 0x0082,
|
||||
0x0080, 0x007F, 0x007D, 0x007C, 0x007B, 0x0079, 0x0078, 0x0077,
|
||||
0x0076, 0x0074, 0x0073, 0x0072, 0x0071, 0x0070, 0x006F, 0x006E,
|
||||
0x006D, 0x006C, 0x006B, 0x006A, 0x0069, 0x0068, 0x0067, 0x0066,
|
||||
0x0065, 0x0064, 0x0063, 0x0062, 0x0062, 0x0061, 0x0060, 0x005F,
|
||||
0x005E, 0x005E, 0x005D, 0x005C, 0x005B, 0x005B, 0x005A
|
||||
static const u16 UNK_020EDB80[] = {
|
||||
0x169F, 0x0F14, 0x0B4F, 0x090C, 0x078A, 0x0676, 0x05A7, 0x0506, 0x0486, 0x041C, 0x03C5, 0x037A, 0x033B, 0x0304, 0x02D3, 0x02A9, 0x0283, 0x0261, 0x0243, 0x0227, 0x020E, 0x01F7, 0x01E2, 0x01CF, 0x01BD, 0x01AC, 0x019D, 0x018F, 0x0182, 0x0175, 0x0169, 0x015E, 0x0154, 0x014A, 0x0141, 0x0139, 0x0130, 0x0128, 0x0121, 0x011A, 0x0113, 0x010D, 0x0107, 0x0101, 0x00FB, 0x00F6, 0x00F1, 0x00EC, 0x00E7, 0x00E3, 0x00DE, 0x00DA, 0x00D6, 0x00D2, 0x00CE, 0x00CB, 0x00C7, 0x00C4, 0x00C1, 0x00BD, 0x00BA, 0x00B7, 0x00B4, 0x00B2, 0x00AF, 0x00AC, 0x00AA, 0x00A7, 0x00A5, 0x00A3, 0x00A0, 0x009E, 0x009C, 0x009A, 0x0098, 0x0096, 0x0094, 0x0092, 0x0090, 0x008E, 0x008D, 0x008B, 0x0089, 0x0088, 0x0086, 0x0085, 0x0083, 0x0082, 0x0080, 0x007F, 0x007D, 0x007C, 0x007B, 0x0079, 0x0078, 0x0077, 0x0076, 0x0074, 0x0073, 0x0072, 0x0071, 0x0070, 0x006F, 0x006E, 0x006D, 0x006C, 0x006B, 0x006A, 0x0069, 0x0068, 0x0067, 0x0066, 0x0065, 0x0064, 0x0063, 0x0062, 0x0062, 0x0061, 0x0060, 0x005F, 0x005E, 0x005E, 0x005D, 0x005C, 0x005B, 0x005B, 0x005A
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
@ -539,7 +488,7 @@ u32 PRandom(u32 seed);
|
|||
void SetMTRNGSeed(u32 seed);
|
||||
u32 MTRandom(void);
|
||||
|
||||
void MTX22_2DAffine(struct Mtx22 * mtx, u16 radians, fx32 x, fx32 y, u8 type);
|
||||
void MTX22_2DAffine(struct Mtx22 *mtx, u16 radians, fx32 x, fx32 y, u8 type);
|
||||
|
||||
s32 CircularDistance(s32 x1, s32 y1, s32 x2, s32 y2);
|
||||
s32 MathUtil_0201BC84(u16 arg0, s32 arg1);
|
||||
|
|
@ -548,43 +497,39 @@ s32 MathUtil_0201BC84(u16 arg0, s32 arg1);
|
|||
* Trigonometric functions
|
||||
*/
|
||||
// Returns the sine of a 16-bit unsigned degree value.
|
||||
s32 Sin(u16 degrees)
|
||||
{
|
||||
if (degrees >= 360)
|
||||
s32 Sin(u16 degrees) {
|
||||
if (degrees >= 360) {
|
||||
return 0;
|
||||
else
|
||||
} else {
|
||||
return gSineTable[degrees];
|
||||
}
|
||||
}
|
||||
// Returns the cosine of a 16-bit unsigned degree value.
|
||||
s32 Cos(u16 degrees)
|
||||
{
|
||||
if (degrees >= 360)
|
||||
s32 Cos(u16 degrees) {
|
||||
if (degrees >= 360) {
|
||||
return 0;
|
||||
else
|
||||
} else {
|
||||
return gSineTable[degrees + 90];
|
||||
}
|
||||
}
|
||||
|
||||
// Returns the wrapped sine of a 16-bit unsigned degree value.
|
||||
s32 Sin_Wrap(u16 degrees)
|
||||
{
|
||||
s32 Sin_Wrap(u16 degrees) {
|
||||
return gSineTable[degrees % 360];
|
||||
}
|
||||
|
||||
// Returns the wrapped cosine of a 16-bit unsigned degree value.
|
||||
s32 Cos_Wrap(u16 degrees)
|
||||
{
|
||||
s32 Cos_Wrap(u16 degrees) {
|
||||
return gSineTable[(degrees % 360) + 90];
|
||||
}
|
||||
|
||||
// Purpose unknown.
|
||||
u16 MathUtil_0201B9A0(u16 x)
|
||||
{
|
||||
u16 MathUtil_0201B9A0(u16 x) {
|
||||
return UNK_020EDC7E[x % 360];
|
||||
}
|
||||
|
||||
// Returns the sine of a 32-bit signed degree value.
|
||||
s32 Sin32(s32 degrees)
|
||||
{
|
||||
s32 Sin32(s32 degrees) {
|
||||
return gSineTable[(u16)(degrees >> 12) % 360];
|
||||
}
|
||||
|
||||
|
|
@ -595,20 +540,17 @@ static u32 sMTRNG_State[624]; // Mersenne Twister seed storage/buffer
|
|||
static u32 sLCRNG_State;
|
||||
|
||||
// Returns the Linear-congruential buffer in full.
|
||||
u32 GetLCRNGSeed()
|
||||
{
|
||||
u32 GetLCRNGSeed() {
|
||||
return sLCRNG_State;
|
||||
}
|
||||
|
||||
// Initializes the Linear-congruential buffer with a 32-bit seed.
|
||||
void SetLCRNGSeed(u32 seed)
|
||||
{
|
||||
void SetLCRNGSeed(u32 seed) {
|
||||
sLCRNG_State = seed;
|
||||
}
|
||||
|
||||
// Calculates an unsigned 16-bit random integer using the Linear-congruential algorithm.
|
||||
u16 LCRandom(void)
|
||||
{
|
||||
u16 LCRandom(void) {
|
||||
// cycle the RNG
|
||||
sLCRNG_State *= 0x41C64E6D;
|
||||
sLCRNG_State += 0x6073;
|
||||
|
|
@ -616,46 +558,42 @@ u16 LCRandom(void)
|
|||
}
|
||||
|
||||
// Returns a cheap, psuedo-random unsigned 32-bit random integer from a seed.
|
||||
u32 PRandom(u32 seed)
|
||||
{
|
||||
u32 PRandom(u32 seed) {
|
||||
return seed * 1812433253 + 1; // seed from Mersenne Twister algorithm
|
||||
}
|
||||
|
||||
static s32 sMTRNG_Cycles = 625; // Mersenne Twister cycle counter, 625 default value
|
||||
static u32 sMTRNG_XOR[2] = {0, 0x9908b0df}; // Mersenne Twister XOR mask table
|
||||
static s32 sMTRNG_Cycles = 625; // Mersenne Twister cycle counter, 625 default value
|
||||
static u32 sMTRNG_XOR[2] = { 0, 0x9908b0df }; // Mersenne Twister XOR mask table
|
||||
|
||||
// Initializes the Mersenne Twister buffer with a 32-bit seed.
|
||||
void SetMTRNGSeed(u32 seed)
|
||||
{
|
||||
void SetMTRNGSeed(u32 seed) {
|
||||
sMTRNG_State[0] = seed;
|
||||
|
||||
for (sMTRNG_Cycles = 1; sMTRNG_Cycles < 624; sMTRNG_Cycles++)
|
||||
for (sMTRNG_Cycles = 1; sMTRNG_Cycles < 624; sMTRNG_Cycles++) {
|
||||
sMTRNG_State[sMTRNG_Cycles] = 1812433253 * (sMTRNG_State[sMTRNG_Cycles - 1] ^ (sMTRNG_State[sMTRNG_Cycles - 1] >> 30)) + sMTRNG_Cycles;
|
||||
}
|
||||
}
|
||||
|
||||
// Calculates an unsigned 32-bit random integer using the Mersenne Twister algorithm.
|
||||
u32 MTRandom(void)
|
||||
{
|
||||
u32 MTRandom(void) {
|
||||
u32 val;
|
||||
s32 i;
|
||||
|
||||
if (sMTRNG_Cycles >= 624)
|
||||
{
|
||||
if (sMTRNG_Cycles == 625)
|
||||
if (sMTRNG_Cycles >= 624) {
|
||||
if (sMTRNG_Cycles == 625) {
|
||||
SetMTRNGSeed(5489);
|
||||
}
|
||||
|
||||
for (i = 0; i < 227; i++)
|
||||
{
|
||||
val = (sMTRNG_State[i] & 0x80000000) | (sMTRNG_State[i + 1] & 0x7fffffff);
|
||||
for (i = 0; i < 227; i++) {
|
||||
val = (sMTRNG_State[i] & 0x80000000) | (sMTRNG_State[i + 1] & 0x7fffffff);
|
||||
sMTRNG_State[i] = sMTRNG_State[i + 397] ^ (val >> 1) ^ sMTRNG_XOR[val & 0x1];
|
||||
}
|
||||
for (; i < 623; i++)
|
||||
{
|
||||
val = (sMTRNG_State[i] & 0x80000000) | (sMTRNG_State[i + 1] & 0x7fffffff);
|
||||
for (; i < 623; i++) {
|
||||
val = (sMTRNG_State[i] & 0x80000000) | (sMTRNG_State[i + 1] & 0x7fffffff);
|
||||
sMTRNG_State[i] = sMTRNG_State[i + -227] ^ (val >> 1) ^ sMTRNG_XOR[val & 0x1];
|
||||
}
|
||||
|
||||
val = (sMTRNG_State[623] & 0x80000000) | (sMTRNG_State[0] & 0x7fffffff);
|
||||
val = (sMTRNG_State[623] & 0x80000000) | (sMTRNG_State[0] & 0x7fffffff);
|
||||
sMTRNG_State[623] = sMTRNG_State[396] ^ (val >> 1) ^ sMTRNG_XOR[val & 0x1];
|
||||
|
||||
sMTRNG_Cycles = 0;
|
||||
|
|
@ -675,15 +613,15 @@ u32 MTRandom(void)
|
|||
* Nitro FX specific functions
|
||||
*/
|
||||
// Rotates and scales a 2D plane by a number of degrees.
|
||||
void MTX22_2DAffine(struct Mtx22 * mtx, u16 radians, fx32 x, fx32 y, u8 type)
|
||||
{
|
||||
if (type == 1)
|
||||
void MTX22_2DAffine(struct Mtx22 *mtx, u16 radians, fx32 x, fx32 y, u8 type) {
|
||||
if (type == 1) {
|
||||
radians = (u16)((u32)(radians * 65535) >> 8); // shut up the compiler
|
||||
else if (type == 2)
|
||||
} else if (type == 2) {
|
||||
radians = (u16)((u32)(radians * 65535) / 360); // shut up the compiler
|
||||
}
|
||||
|
||||
MTX_Rot22_(mtx,
|
||||
FX_SinCosTable_[((radians >> 4) * 2)], // TODO: macros
|
||||
FX_SinCosTable_[((radians >> 4) * 2)], // TODO: macros
|
||||
FX_SinCosTable_[((radians >> 4) * 2) + 1]); // TODO: macros
|
||||
MTX_ScaleApply22(mtx, mtx, x, y);
|
||||
}
|
||||
|
|
@ -692,8 +630,7 @@ void MTX22_2DAffine(struct Mtx22 * mtx, u16 radians, fx32 x, fx32 y, u8 type)
|
|||
* Vector functions
|
||||
*/
|
||||
// Calculates the circular distance between two vector coordinates.
|
||||
s32 CircularDistance(s32 x1, s32 y1, s32 x2, s32 y2)
|
||||
{
|
||||
s32 CircularDistance(s32 x1, s32 y1, s32 x2, s32 y2) {
|
||||
struct Vecx32 v1, v2, v3, v4;
|
||||
fx32 f1, f2;
|
||||
s32 ret;
|
||||
|
|
@ -728,23 +665,21 @@ s32 CircularDistance(s32 x1, s32 y1, s32 x2, s32 y2)
|
|||
v2.z = 0;
|
||||
|
||||
VEC_Subtract(&v2, &v1, &v4);
|
||||
f2 = VEC_DotProduct(&v3, &v4);
|
||||
f2 = VEC_DotProduct(&v3, &v4);
|
||||
ret = f2 >> FX32_INT_SHIFT;
|
||||
ret = (ret < 0) ? -ret : ret;
|
||||
|
||||
if (f1 <= 0)
|
||||
if (f1 <= 0) {
|
||||
ret *= -1;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
s32 MathUtil_0201BC84(u16 arg0, s32 arg1)
|
||||
{
|
||||
return (arg1 * 65535) /
|
||||
(FX32_MUL((arg0 * 2) << FX32_INT_SHIFT, FX32_CONST(3.140f)) >> FX32_INT_SHIFT);
|
||||
s32 MathUtil_0201BC84(u16 arg0, s32 arg1) {
|
||||
return (arg1 * 65535) / (FX32_MUL((arg0 * 2) << FX32_INT_SHIFT, FX32_CONST(3.140f)) >> FX32_INT_SHIFT);
|
||||
}
|
||||
|
||||
// Required to protect UNK_020EDB80 from dead-stripping
|
||||
s32 CALC_SomeDeadstrippedFunction(s32 arg)
|
||||
{
|
||||
s32 CALC_SomeDeadstrippedFunction(s32 arg) {
|
||||
return UNK_020EDB80[arg];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,18 @@
|
|||
#include "global.h"
|
||||
#include "filesystem.h"
|
||||
#include "gf_gfx_loader.h"
|
||||
#include "graphic/font.naix"
|
||||
#include "heap.h"
|
||||
#include "message_format.h"
|
||||
#include "msgdata.h"
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "graphic/font.naix"
|
||||
#include "msgdata/msg.naix"
|
||||
#include "msgdata/msg/narc_0199.h"
|
||||
#include "msgdata/msg/narc_0382.h"
|
||||
#include "msgdata/msg/narc_0497.h"
|
||||
|
||||
#include "easy_chat.h"
|
||||
#include "filesystem.h"
|
||||
#include "gf_gfx_loader.h"
|
||||
#include "heap.h"
|
||||
#include "msgdata.h"
|
||||
#include "player_data.h"
|
||||
#include "pokemon.h"
|
||||
#include "pokemon_storage_system.h"
|
||||
|
|
@ -16,7 +20,6 @@
|
|||
#include "string_control_code.h"
|
||||
#include "text.h"
|
||||
#include "trainer_data.h"
|
||||
#include "easy_chat.h"
|
||||
#include "unk_02015CC0.h"
|
||||
#include "unk_02024E64.h"
|
||||
#include "unk_020286F8.h"
|
||||
|
|
@ -40,49 +43,42 @@ const u16 UNK_020ECE64[] = {
|
|||
0
|
||||
};
|
||||
|
||||
MessageFormat *MessageFormat_New(HeapID heapId)
|
||||
{
|
||||
MessageFormat *MessageFormat_New(HeapID heapId) {
|
||||
return MessageFormat_New_Custom(8, 32, heapId);
|
||||
}
|
||||
|
||||
MessageFormat *MessageFormat_New_Custom(u32 nstr, u32 strlen, HeapID heapId)
|
||||
{
|
||||
MessageFormat *MessageFormat_New_Custom(u32 nstr, u32 strlen, HeapID heapId) {
|
||||
GF_ASSERT(nstr != 0);
|
||||
GF_ASSERT(strlen != 0);
|
||||
MessageFormat *messageFormat = AllocFromHeapAtEnd(heapId, sizeof(MessageFormat));
|
||||
if (messageFormat != NULL)
|
||||
{
|
||||
messageFormat->count = nstr;
|
||||
if (messageFormat != NULL) {
|
||||
messageFormat->count = nstr;
|
||||
messageFormat->heapId = heapId;
|
||||
messageFormat->buffer = String_New(strlen, heapId);
|
||||
if (messageFormat->buffer != NULL)
|
||||
{
|
||||
if (messageFormat->buffer != NULL) {
|
||||
messageFormat->fields = AllocFromHeapAtEnd(heapId, nstr * sizeof(MessageFormatFields));
|
||||
if (messageFormat->fields != NULL)
|
||||
{
|
||||
if (messageFormat->fields != NULL) {
|
||||
s32 i;
|
||||
for (i = 0; i < nstr; i++)
|
||||
{
|
||||
for (i = 0; i < nstr; i++) {
|
||||
MessageFormat_InitFields(&messageFormat->fields[i]);
|
||||
messageFormat->fields[i].msg = String_New(strlen, heapId);
|
||||
if (messageFormat->fields[i].msg == NULL)
|
||||
if (messageFormat->fields[i].msg == NULL) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == nstr)
|
||||
if (i == nstr) {
|
||||
return messageFormat;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void MessageFormat_Delete(MessageFormat *messageFormat)
|
||||
{
|
||||
void MessageFormat_Delete(MessageFormat *messageFormat) {
|
||||
GF_ASSERT(messageFormat->count != 0);
|
||||
if (messageFormat->fields != NULL)
|
||||
{
|
||||
for (s32 i = 0; i < messageFormat->count; i++)
|
||||
{
|
||||
if (messageFormat->fields != NULL) {
|
||||
for (s32 i = 0; i < messageFormat->count; i++) {
|
||||
if (messageFormat->fields[i].msg == NULL) {
|
||||
break;
|
||||
}
|
||||
|
|
@ -90,432 +86,356 @@ void MessageFormat_Delete(MessageFormat *messageFormat)
|
|||
}
|
||||
FreeToHeap(messageFormat->fields);
|
||||
}
|
||||
if (messageFormat->buffer != NULL)
|
||||
if (messageFormat->buffer != NULL) {
|
||||
String_Delete(messageFormat->buffer);
|
||||
}
|
||||
messageFormat->count = 0;
|
||||
FreeToHeap(messageFormat);
|
||||
}
|
||||
|
||||
void MessageFormat_InitFields(MessageFormatFields *fields)
|
||||
{
|
||||
void MessageFormat_InitFields(MessageFormatFields *fields) {
|
||||
#pragma unused(fields)
|
||||
}
|
||||
|
||||
void SetStringAsPlaceholder(MessageFormat *messageFormat, u32 idx, struct String *str, MessageFormatAttrs *attrs)
|
||||
{
|
||||
void SetStringAsPlaceholder(MessageFormat *messageFormat, u32 idx, struct String *str, MessageFormatAttrs *attrs) {
|
||||
GF_ASSERT(idx < messageFormat->count);
|
||||
if (idx < messageFormat->count)
|
||||
{
|
||||
if (attrs != NULL)
|
||||
{
|
||||
if (idx < messageFormat->count) {
|
||||
if (attrs != NULL) {
|
||||
messageFormat->fields[idx].attrs = *attrs;
|
||||
}
|
||||
StringCopy(messageFormat->fields[idx].msg, str);
|
||||
}
|
||||
}
|
||||
|
||||
void BufferString(MessageFormat *messageFormat, u32 idx, struct String * str, u32 a3, u32 a4, u32 a5)
|
||||
{
|
||||
#pragma unused(a3,a4,a5)
|
||||
void BufferString(MessageFormat *messageFormat, u32 idx, struct String *str, u32 a3, u32 a4, u32 a5) {
|
||||
#pragma unused(a3, a4, a5)
|
||||
SetStringAsPlaceholder(messageFormat, idx, str, NULL);
|
||||
}
|
||||
|
||||
void BufferPlayersName(MessageFormat *messageFormat, u32 idx, PlayerProfile *profile)
|
||||
{
|
||||
u16 * name = PlayerProfile_GetNamePtr(profile);
|
||||
void BufferPlayersName(MessageFormat *messageFormat, u32 idx, PlayerProfile *profile) {
|
||||
u16 *name = PlayerProfile_GetNamePtr(profile);
|
||||
CopyU16ArrayToString(messageFormat->buffer, name);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
}
|
||||
|
||||
void BufferRivalsName(MessageFormat *messageFormat, u32 idx, struct SaveData * save)
|
||||
{
|
||||
u16 * name = GetRivalNamePtr(sub_02024EC0(save));
|
||||
void BufferRivalsName(MessageFormat *messageFormat, u32 idx, struct SaveData *save) {
|
||||
u16 *name = GetRivalNamePtr(sub_02024EC0(save));
|
||||
CopyU16ArrayToString(messageFormat->buffer, name);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
}
|
||||
|
||||
void BufferFriendsName(MessageFormat *messageFormat, u32 idx, struct SaveData * save)
|
||||
{
|
||||
PlayerProfile *profile = Save_PlayerData_GetProfileAddr(save);
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0497_bin, messageFormat->heapId);
|
||||
if (PlayerProfile_GetTrainerGender(profile) == PLAYER_GENDER_MALE)
|
||||
{
|
||||
ReadMsgDataIntoString(msgData, narc_0497_00001, messageFormat->buffer); //Dawn
|
||||
}
|
||||
else
|
||||
{
|
||||
ReadMsgDataIntoString(msgData, narc_0497_00000, messageFormat->buffer); //Lucas
|
||||
void BufferFriendsName(MessageFormat *messageFormat, u32 idx, struct SaveData *save) {
|
||||
PlayerProfile *profile = Save_PlayerData_GetProfileAddr(save);
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0497_bin, messageFormat->heapId);
|
||||
if (PlayerProfile_GetTrainerGender(profile) == PLAYER_GENDER_MALE) {
|
||||
ReadMsgDataIntoString(msgData, narc_0497_00001, messageFormat->buffer); // Dawn
|
||||
} else {
|
||||
ReadMsgDataIntoString(msgData, narc_0497_00000, messageFormat->buffer); // Lucas
|
||||
}
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
|
||||
void BufferBoxMonSpeciesName(MessageFormat *messageFormat, u32 idx, struct BoxPokemon * mon)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0362_bin, messageFormat->heapId);
|
||||
void BufferBoxMonSpeciesName(MessageFormat *messageFormat, u32 idx, struct BoxPokemon *mon) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0362_bin, messageFormat->heapId);
|
||||
ReadMsgDataIntoString(msgData, GetBoxMonData(mon, MON_DATA_SPECIES, NULL), messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
|
||||
void BufferBoxMonSpeciesNameWithArticle(MessageFormat *messageFormat, u32 idx, struct BoxPokemon * mon)
|
||||
{
|
||||
void BufferBoxMonSpeciesNameWithArticle(MessageFormat *messageFormat, u32 idx, struct BoxPokemon *mon) {
|
||||
BufferSpeciesNameWithArticle(messageFormat, idx, GetBoxMonData(mon, MON_DATA_SPECIES, NULL));
|
||||
}
|
||||
|
||||
void BufferSpeciesNameWithArticle(MessageFormat *messageFormat, u32 idx, u32 species)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0363_bin, messageFormat->heapId);
|
||||
void BufferSpeciesNameWithArticle(MessageFormat *messageFormat, u32 idx, u32 species) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0363_bin, messageFormat->heapId);
|
||||
ReadMsgDataIntoString(msgData, species, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
|
||||
void BufferBoxMonNickname(MessageFormat *messageFormat, u32 idx, struct BoxPokemon * mon)
|
||||
{
|
||||
void BufferBoxMonNickname(MessageFormat *messageFormat, u32 idx, struct BoxPokemon *mon) {
|
||||
GetBoxMonData(mon, MON_DATA_NICKNAME_3, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
}
|
||||
|
||||
void BufferBoxMonOTName(MessageFormat *messageFormat, u32 idx, struct BoxPokemon * mon)
|
||||
{
|
||||
void BufferBoxMonOTName(MessageFormat *messageFormat, u32 idx, struct BoxPokemon *mon) {
|
||||
GetBoxMonData(mon, MON_DATA_OT_NAME_2, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
}
|
||||
|
||||
void BufferIntegerAsString(MessageFormat *messageFormat, u32 idx, s32 num, u32 ndigits, enum PrintingMode printingMode, BOOL whichCharset)
|
||||
{
|
||||
void BufferIntegerAsString(MessageFormat *messageFormat, u32 idx, s32 num, u32 ndigits, enum PrintingMode printingMode, BOOL whichCharset) {
|
||||
String16_FormatInteger(messageFormat->buffer, num, ndigits, printingMode, whichCharset);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
}
|
||||
|
||||
void BufferMoveName(MessageFormat *messageFormat, u32 idx, u32 move)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0588_bin, messageFormat->heapId);
|
||||
if (msgData != NULL)
|
||||
{
|
||||
void BufferMoveName(MessageFormat *messageFormat, u32 idx, u32 move) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0588_bin, messageFormat->heapId);
|
||||
if (msgData != NULL) {
|
||||
ReadMsgDataIntoString(msgData, move, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
}
|
||||
|
||||
void BufferRibbonNameOrDesc(MessageFormat *messageFormat, u32 idx, u32 ribbon)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0484_bin, messageFormat->heapId);
|
||||
if (msgData != NULL)
|
||||
{
|
||||
void BufferRibbonNameOrDesc(MessageFormat *messageFormat, u32 idx, u32 ribbon) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0484_bin, messageFormat->heapId);
|
||||
if (msgData != NULL) {
|
||||
ReadMsgDataIntoString(msgData, ribbon, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
}
|
||||
|
||||
void BufferAbilityName(MessageFormat *messageFormat, u32 idx, u32 ability)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0552_bin, messageFormat->heapId);
|
||||
if (msgData != NULL)
|
||||
{
|
||||
void BufferAbilityName(MessageFormat *messageFormat, u32 idx, u32 ability) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0552_bin, messageFormat->heapId);
|
||||
if (msgData != NULL) {
|
||||
ReadMsgDataIntoString(msgData, ability, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
}
|
||||
|
||||
void BufferNatureName(MessageFormat *messageFormat, u32 idx, u32 nature)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0190_bin, messageFormat->heapId);
|
||||
void BufferNatureName(MessageFormat *messageFormat, u32 idx, u32 nature) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0190_bin, messageFormat->heapId);
|
||||
ReadMsgDataIntoString(msgData, nature, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
|
||||
void BufferItemName(MessageFormat *messageFormat, u32 idx, u32 item)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0344_bin, messageFormat->heapId);
|
||||
if (msgData != NULL)
|
||||
{
|
||||
void BufferItemName(MessageFormat *messageFormat, u32 idx, u32 item) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0344_bin, messageFormat->heapId);
|
||||
if (msgData != NULL) {
|
||||
ReadMsgDataIntoString(msgData, item, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
}
|
||||
|
||||
void BufferItemNameWithIndefArticle(MessageFormat *messageFormat, u32 idx, u32 item)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0346_bin, messageFormat->heapId);
|
||||
if (msgData != NULL)
|
||||
{
|
||||
void BufferItemNameWithIndefArticle(MessageFormat *messageFormat, u32 idx, u32 item) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0346_bin, messageFormat->heapId);
|
||||
if (msgData != NULL) {
|
||||
ReadMsgDataIntoString(msgData, item, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
}
|
||||
|
||||
void BufferItemNamePlural(MessageFormat *messageFormat, u32 idx, u32 item)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0347_bin, messageFormat->heapId);
|
||||
if (msgData != NULL)
|
||||
{
|
||||
void BufferItemNamePlural(MessageFormat *messageFormat, u32 idx, u32 item) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0347_bin, messageFormat->heapId);
|
||||
if (msgData != NULL) {
|
||||
ReadMsgDataIntoString(msgData, item, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
}
|
||||
|
||||
void BufferPocketName(MessageFormat *messageFormat, u32 idx, u32 pocket)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0349_bin, messageFormat->heapId);
|
||||
if (msgData != NULL)
|
||||
{
|
||||
void BufferPocketName(MessageFormat *messageFormat, u32 idx, u32 pocket) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0349_bin, messageFormat->heapId);
|
||||
if (msgData != NULL) {
|
||||
ReadMsgDataIntoString(msgData, pocket, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
}
|
||||
|
||||
void BufferTypeName(MessageFormat *messageFormat, u32 idx, u32 type)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0565_bin, messageFormat->heapId);
|
||||
if (msgData != NULL)
|
||||
{
|
||||
void BufferTypeName(MessageFormat *messageFormat, u32 idx, u32 type) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0565_bin, messageFormat->heapId);
|
||||
if (msgData != NULL) {
|
||||
ReadMsgDataIntoString(msgData, type, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
}
|
||||
|
||||
void BufferStatName(MessageFormat *messageFormat, u32 idx, u32 stat)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0495_bin, messageFormat->heapId);
|
||||
if (msgData != NULL)
|
||||
{
|
||||
void BufferStatName(MessageFormat *messageFormat, u32 idx, u32 stat) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0495_bin, messageFormat->heapId);
|
||||
if (msgData != NULL) {
|
||||
ReadMsgDataIntoString(msgData, stat, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
}
|
||||
|
||||
void BufferStatusName(MessageFormat *messageFormat, u32 idx, u32 status)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0205_bin, messageFormat->heapId);
|
||||
if (msgData != NULL)
|
||||
{
|
||||
void BufferStatusName(MessageFormat *messageFormat, u32 idx, u32 status) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0205_bin, messageFormat->heapId);
|
||||
if (msgData != NULL) {
|
||||
ReadMsgDataIntoString(msgData, status, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
}
|
||||
|
||||
void BufferFlavorDislikeText(MessageFormat *messageFormat, u32 idx, u32 flavor)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0548_bin, messageFormat->heapId);
|
||||
if (msgData != NULL)
|
||||
{
|
||||
void BufferFlavorDislikeText(MessageFormat *messageFormat, u32 idx, u32 flavor) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0548_bin, messageFormat->heapId);
|
||||
if (msgData != NULL) {
|
||||
ReadMsgDataIntoString(msgData, flavor, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
}
|
||||
|
||||
void BufferLandmarkName(MessageFormat *messageFormat, u32 idx, u32 landmark)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0382_bin, messageFormat->heapId);
|
||||
if (msgData != NULL)
|
||||
{
|
||||
void BufferLandmarkName(MessageFormat *messageFormat, u32 idx, u32 landmark) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0382_bin, messageFormat->heapId);
|
||||
if (msgData != NULL) {
|
||||
ReadMsgDataIntoString(msgData, landmark, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
}
|
||||
|
||||
void BufferPoketchAppName(MessageFormat *messageFormat, u32 idx, u32 app)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0406_bin, messageFormat->heapId);
|
||||
if (msgData != NULL)
|
||||
{
|
||||
void BufferPoketchAppName(MessageFormat *messageFormat, u32 idx, u32 app) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0406_bin, messageFormat->heapId);
|
||||
if (msgData != NULL) {
|
||||
ReadMsgDataIntoString(msgData, app, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
}
|
||||
|
||||
void BufferTrainerClassName(MessageFormat *messageFormat, u32 idx, u32 trclass)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0560_bin, messageFormat->heapId);
|
||||
if (msgData != NULL)
|
||||
{
|
||||
void BufferTrainerClassName(MessageFormat *messageFormat, u32 idx, u32 trclass) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0560_bin, messageFormat->heapId);
|
||||
if (msgData != NULL) {
|
||||
ReadMsgDataIntoString(msgData, trclass, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
}
|
||||
|
||||
void BufferTrainerClassNameWithArticle(MessageFormat *messageFormat, u32 idx, u32 trclass)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0561_bin, messageFormat->heapId);
|
||||
if (msgData != NULL)
|
||||
{
|
||||
void BufferTrainerClassNameWithArticle(MessageFormat *messageFormat, u32 idx, u32 trclass) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0561_bin, messageFormat->heapId);
|
||||
if (msgData != NULL) {
|
||||
ReadMsgDataIntoString(msgData, trclass, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
}
|
||||
|
||||
void BufferTrainerClassNameFromDataStruct(MessageFormat *messageFormat, u32 idx, Trainer * tr)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0560_bin, messageFormat->heapId);
|
||||
if (msgData != NULL)
|
||||
{
|
||||
void BufferTrainerClassNameFromDataStruct(MessageFormat *messageFormat, u32 idx, Trainer *tr) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0560_bin, messageFormat->heapId);
|
||||
if (msgData != NULL) {
|
||||
ReadMsgDataIntoString(msgData, tr->data.trainerClass, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
}
|
||||
|
||||
void BufferTrainerName(MessageFormat *messageFormat, u32 idx, u32 msgno)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0559_bin, messageFormat->heapId);
|
||||
if (msgData != NULL)
|
||||
{
|
||||
void BufferTrainerName(MessageFormat *messageFormat, u32 idx, u32 msgno) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0559_bin, messageFormat->heapId);
|
||||
if (msgData != NULL) {
|
||||
ReadMsgDataIntoString(msgData, msgno, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
}
|
||||
|
||||
void BufferTrainerNameFromDataStruct(MessageFormat *messageFormat, u32 idx, Trainer * trdata)
|
||||
{
|
||||
void BufferTrainerNameFromDataStruct(MessageFormat *messageFormat, u32 idx, Trainer *trdata) {
|
||||
CopyU16ArrayToString(messageFormat->buffer, trdata->name);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
}
|
||||
|
||||
void BufferUndergroundItemName(MessageFormat *messageFormat, u32 idx, u32 item)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0569_bin, messageFormat->heapId);
|
||||
if (msgData != NULL)
|
||||
{
|
||||
void BufferUndergroundItemName(MessageFormat *messageFormat, u32 idx, u32 item) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0569_bin, messageFormat->heapId);
|
||||
if (msgData != NULL) {
|
||||
ReadMsgDataIntoString(msgData, item, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
}
|
||||
|
||||
void BufferUndergroundItemNameWithArticle(MessageFormat *messageFormat, u32 idx, u32 item)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0570_bin, messageFormat->heapId);
|
||||
if (msgData != NULL)
|
||||
{
|
||||
void BufferUndergroundItemNameWithArticle(MessageFormat *messageFormat, u32 idx, u32 item) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0570_bin, messageFormat->heapId);
|
||||
if (msgData != NULL) {
|
||||
ReadMsgDataIntoString(msgData, item, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
}
|
||||
|
||||
void BufferUndergroundTrapName(MessageFormat *messageFormat, u32 idx, u32 trap)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0571_bin, messageFormat->heapId);
|
||||
if (msgData != NULL)
|
||||
{
|
||||
void BufferUndergroundTrapName(MessageFormat *messageFormat, u32 idx, u32 trap) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0571_bin, messageFormat->heapId);
|
||||
if (msgData != NULL) {
|
||||
ReadMsgDataIntoString(msgData, trap, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
}
|
||||
|
||||
void BufferUndergroundTrapNameWithArticle(MessageFormat *messageFormat, u32 idx, u32 trap)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0572_bin, messageFormat->heapId);
|
||||
if (msgData != NULL)
|
||||
{
|
||||
void BufferUndergroundTrapNameWithArticle(MessageFormat *messageFormat, u32 idx, u32 trap) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0572_bin, messageFormat->heapId);
|
||||
if (msgData != NULL) {
|
||||
ReadMsgDataIntoString(msgData, trap, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
}
|
||||
|
||||
void BufferContestJudgeName(MessageFormat *messageFormat, u32 idx, u32 judge)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0194_bin, messageFormat->heapId);
|
||||
if (msgData != NULL)
|
||||
{
|
||||
void BufferContestJudgeName(MessageFormat *messageFormat, u32 idx, u32 judge) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0194_bin, messageFormat->heapId);
|
||||
if (msgData != NULL) {
|
||||
ReadMsgDataIntoString(msgData, judge, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
}
|
||||
|
||||
void BufferContestMessage(MessageFormat *messageFormat, u32 idx, u32 msg)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0191_bin, messageFormat->heapId);
|
||||
if (msgData != NULL)
|
||||
{
|
||||
void BufferContestMessage(MessageFormat *messageFormat, u32 idx, u32 msg) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0191_bin, messageFormat->heapId);
|
||||
if (msgData != NULL) {
|
||||
ReadMsgDataIntoString(msgData, msg, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
}
|
||||
|
||||
void BufferContestMessage2(MessageFormat *messageFormat, u32 idx, u32 msg)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0191_bin, messageFormat->heapId);
|
||||
if (msgData != NULL)
|
||||
{
|
||||
void BufferContestMessage2(MessageFormat *messageFormat, u32 idx, u32 msg) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0191_bin, messageFormat->heapId);
|
||||
if (msgData != NULL) {
|
||||
ReadMsgDataIntoString(msgData, msg, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
}
|
||||
|
||||
void BufferInterviewQuestion(MessageFormat *messageFormat, u32 idx, u32 question)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0574_bin, messageFormat->heapId);
|
||||
if (msgData != NULL)
|
||||
{
|
||||
void BufferInterviewQuestion(MessageFormat *messageFormat, u32 idx, u32 question) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0574_bin, messageFormat->heapId);
|
||||
if (msgData != NULL) {
|
||||
ReadMsgDataIntoString(msgData, question, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
}
|
||||
|
||||
void BufferInterviewAnswer(MessageFormat *messageFormat, u32 idx, u32 answer)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0573_bin, messageFormat->heapId);
|
||||
if (msgData != NULL)
|
||||
{
|
||||
void BufferInterviewAnswer(MessageFormat *messageFormat, u32 idx, u32 answer) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0573_bin, messageFormat->heapId);
|
||||
if (msgData != NULL) {
|
||||
ReadMsgDataIntoString(msgData, answer, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
}
|
||||
|
||||
void BufferDecorationName(MessageFormat *messageFormat, u32 idx, u32 decor)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0567_bin, messageFormat->heapId);
|
||||
if (msgData != NULL)
|
||||
{
|
||||
void BufferDecorationName(MessageFormat *messageFormat, u32 idx, u32 decor) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0567_bin, messageFormat->heapId);
|
||||
if (msgData != NULL) {
|
||||
ReadMsgDataIntoString(msgData, decor, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
}
|
||||
|
||||
void BufferDecorationNameWithArticle(MessageFormat *messageFormat, u32 idx, u32 decor)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0568_bin, messageFormat->heapId);
|
||||
if (msgData != NULL)
|
||||
{
|
||||
void BufferDecorationNameWithArticle(MessageFormat *messageFormat, u32 idx, u32 decor) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0568_bin, messageFormat->heapId);
|
||||
if (msgData != NULL) {
|
||||
ReadMsgDataIntoString(msgData, decor, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
}
|
||||
|
||||
void BufferGenderSymbol(MessageFormat *messageFormat, u32 idx, u32 gender)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0199_bin, messageFormat->heapId);
|
||||
switch (gender)
|
||||
{
|
||||
void BufferGenderSymbol(MessageFormat *messageFormat, u32 idx, u32 gender) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0199_bin, messageFormat->heapId);
|
||||
switch (gender) {
|
||||
case 0:
|
||||
ReadMsgDataIntoString(msgData, narc_0199_00068, messageFormat->buffer); // ♂
|
||||
break;
|
||||
|
|
@ -530,53 +450,43 @@ void BufferGenderSymbol(MessageFormat *messageFormat, u32 idx, u32 gender)
|
|||
DestroyMsgData(msgData);
|
||||
}
|
||||
|
||||
void BufferBoxName(MessageFormat *messageFormat, u32 idx, struct PCStorage * pc, s32 boxno)
|
||||
{
|
||||
void BufferBoxName(MessageFormat *messageFormat, u32 idx, struct PCStorage *pc, s32 boxno) {
|
||||
PCStorage_GetBoxName(pc, boxno, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
}
|
||||
|
||||
void BufferGymName(MessageFormat *messageFormat, u32 idx, u32 gym)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0331_bin, messageFormat->heapId);
|
||||
if (msgData != NULL)
|
||||
{
|
||||
void BufferGymName(MessageFormat *messageFormat, u32 idx, u32 gym) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0331_bin, messageFormat->heapId);
|
||||
if (msgData != NULL) {
|
||||
ReadMsgDataIntoString(msgData, gym, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
}
|
||||
|
||||
void BufferTimeOfDayName(MessageFormat *messageFormat, u32 idx, u32 time)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0550_bin, messageFormat->heapId);
|
||||
if (msgData != NULL)
|
||||
{
|
||||
void BufferTimeOfDayName(MessageFormat *messageFormat, u32 idx, u32 time) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0550_bin, messageFormat->heapId);
|
||||
if (msgData != NULL) {
|
||||
ReadMsgDataIntoString(msgData, time, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
}
|
||||
|
||||
void BufferCountryName(MessageFormat *messageFormat, u32 idx, u32 country)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0612_bin, messageFormat->heapId);
|
||||
if (msgData != NULL)
|
||||
{
|
||||
void BufferCountryName(MessageFormat *messageFormat, u32 idx, u32 country) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0612_bin, messageFormat->heapId);
|
||||
if (msgData != NULL) {
|
||||
ReadMsgDataIntoString(msgData, country, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
}
|
||||
|
||||
void BufferCityName(MessageFormat *messageFormat, u32 idx, u32 countryId, u32 cityId)
|
||||
{
|
||||
void BufferCityName(MessageFormat *messageFormat, u32 idx, u32 countryId, u32 cityId) {
|
||||
u32 msgBank = GetCityNamesMsgdataIdByCountry(countryId);
|
||||
if (msgBank != 0 && cityId != 0)
|
||||
{
|
||||
if (msgBank != 0 && cityId != 0) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, (s32)msgBank, messageFormat->heapId);
|
||||
if (msgData != NULL)
|
||||
{
|
||||
if (msgData != NULL) {
|
||||
ReadMsgDataIntoString(msgData, cityId, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
|
|
@ -584,43 +494,35 @@ void BufferCityName(MessageFormat *messageFormat, u32 idx, u32 countryId, u32 ci
|
|||
}
|
||||
}
|
||||
|
||||
void BufferECWord(MessageFormat *messageFormat, u32 idx, u32 ecWordIdx)
|
||||
{
|
||||
void BufferECWord(MessageFormat *messageFormat, u32 idx, u32 ecWordIdx) {
|
||||
GetECWordIntoStringByIndex(ecWordIdx, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
}
|
||||
|
||||
void BufferSealName(MessageFormat *messageFormat, u32 idx, u32 seal)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0010_bin, messageFormat->heapId);
|
||||
if (msgData != NULL)
|
||||
{
|
||||
void BufferSealName(MessageFormat *messageFormat, u32 idx, u32 seal) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0010_bin, messageFormat->heapId);
|
||||
if (msgData != NULL) {
|
||||
ReadMsgDataIntoString(msgData, seal, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
}
|
||||
|
||||
void BufferSealNamePlural(MessageFormat *messageFormat, u32 idx, u32 seal)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0011_bin, messageFormat->heapId);
|
||||
if (msgData != NULL)
|
||||
{
|
||||
void BufferSealNamePlural(MessageFormat *messageFormat, u32 idx, u32 seal) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0011_bin, messageFormat->heapId);
|
||||
if (msgData != NULL) {
|
||||
ReadMsgDataIntoString(msgData, seal, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
}
|
||||
|
||||
void BufferLocationName(MessageFormat *messageFormat, u32 idx, u16 location)
|
||||
{
|
||||
u32 r6 = (u32)sub_02015CC0(location);
|
||||
u32 r4 = (u32)sub_02015CE0(location);
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, UNK_020ECE64[r6], messageFormat->heapId);
|
||||
if (msgData != NULL)
|
||||
{
|
||||
if (r4 < MsgDataGetCount(msgData))
|
||||
{
|
||||
void BufferLocationName(MessageFormat *messageFormat, u32 idx, u16 location) {
|
||||
u32 r6 = (u32)sub_02015CC0(location);
|
||||
u32 r4 = (u32)sub_02015CE0(location);
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, UNK_020ECE64[r6], messageFormat->heapId);
|
||||
if (msgData != NULL) {
|
||||
if (r4 < MsgDataGetCount(msgData)) {
|
||||
ReadMsgDataIntoString(msgData, r4, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
|
|
@ -630,8 +532,7 @@ void BufferLocationName(MessageFormat *messageFormat, u32 idx, u16 location)
|
|||
// Fallback: Mystery Zone
|
||||
DestroyMsgData(msgData);
|
||||
msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0382_bin, messageFormat->heapId);
|
||||
if (msgData != NULL)
|
||||
{
|
||||
if (msgData != NULL) {
|
||||
ReadMsgDataIntoString(msgData, narc_0382_00000, messageFormat->buffer); // Mystery Zone
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
|
|
@ -639,125 +540,105 @@ void BufferLocationName(MessageFormat *messageFormat, u32 idx, u16 location)
|
|||
}
|
||||
}
|
||||
|
||||
void BufferPoffinName(MessageFormat *messageFormat, u32 idx, u32 poffin)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0414_bin, messageFormat->heapId);
|
||||
if (msgData != NULL)
|
||||
{
|
||||
void BufferPoffinName(MessageFormat *messageFormat, u32 idx, u32 poffin) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0414_bin, messageFormat->heapId);
|
||||
if (msgData != NULL) {
|
||||
ReadMsgDataIntoString(msgData, poffin, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
}
|
||||
|
||||
void BufferFashionName(MessageFormat *messageFormat, u32 idx, u32 fashion)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0338_bin, messageFormat->heapId);
|
||||
if (msgData != NULL)
|
||||
{
|
||||
void BufferFashionName(MessageFormat *messageFormat, u32 idx, u32 fashion) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0338_bin, messageFormat->heapId);
|
||||
if (msgData != NULL) {
|
||||
ReadMsgDataIntoString(msgData, fashion, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
}
|
||||
|
||||
void BufferFashionNameWithArticle(MessageFormat *messageFormat, u32 idx, u32 fashion)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0339_bin, messageFormat->heapId);
|
||||
if (msgData != NULL)
|
||||
{
|
||||
void BufferFashionNameWithArticle(MessageFormat *messageFormat, u32 idx, u32 fashion) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0339_bin, messageFormat->heapId);
|
||||
if (msgData != NULL) {
|
||||
ReadMsgDataIntoString(msgData, fashion, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
}
|
||||
|
||||
void BufferContestBackgroundName(MessageFormat *messageFormat, u32 idx, u32 bg)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0340_bin, messageFormat->heapId);
|
||||
if (msgData != NULL)
|
||||
{
|
||||
void BufferContestBackgroundName(MessageFormat *messageFormat, u32 idx, u32 bg) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0340_bin, messageFormat->heapId);
|
||||
if (msgData != NULL) {
|
||||
ReadMsgDataIntoString(msgData, bg, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
}
|
||||
|
||||
void BufferGroupName(MessageFormat *messageFormat, struct SaveData * save, u32 r5, u32 idx, u32 sp28)
|
||||
{
|
||||
void * r6 = sub_0202881C(save);
|
||||
u8 sp10 = sub_020287F8(r6, r5);
|
||||
u8 r7 = sub_02028804(r6, r5);
|
||||
struct String * r4 = String_New(64, HEAP_ID_4);
|
||||
void BufferGroupName(MessageFormat *messageFormat, struct SaveData *save, u32 r5, u32 idx, u32 sp28) {
|
||||
void *r6 = sub_0202881C(save);
|
||||
u8 sp10 = sub_020287F8(r6, r5);
|
||||
u8 r7 = sub_02028804(r6, r5);
|
||||
struct String *r4 = String_New(64, HEAP_ID_4);
|
||||
CopyU16ArrayToString(r4, sub_020287A8(r6, r5, sp28));
|
||||
BufferString(messageFormat, idx, r4, sp10, 1, r7);
|
||||
String_Delete(r4);
|
||||
}
|
||||
|
||||
void BufferMonthNameAbbr(MessageFormat *messageFormat, u32 idx, u32 month)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0364_bin, messageFormat->heapId);
|
||||
if (msgData != NULL)
|
||||
{
|
||||
if (month < 1 || month > 12)
|
||||
void BufferMonthNameAbbr(MessageFormat *messageFormat, u32 idx, u32 month) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0364_bin, messageFormat->heapId);
|
||||
if (msgData != NULL) {
|
||||
if (month < 1 || month > 12) {
|
||||
month = 1;
|
||||
}
|
||||
ReadMsgDataIntoString(msgData, month - 1, messageFormat->buffer);
|
||||
SetStringAsPlaceholder(messageFormat, idx, messageFormat->buffer, NULL);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
}
|
||||
|
||||
void MessageFormat_UpperFirstChar(MessageFormat *messageFormat, u32 idx)
|
||||
{
|
||||
void MessageFormat_UpperFirstChar(MessageFormat *messageFormat, u32 idx) {
|
||||
StrUpperFirstChar(messageFormat->fields[idx].msg);
|
||||
}
|
||||
|
||||
void StringExpandPlaceholders(MessageFormat *messageFormat, struct String * dest, struct String * src)
|
||||
{
|
||||
const u16 * cstr = String_c_str(src);
|
||||
void StringExpandPlaceholders(MessageFormat *messageFormat, struct String *dest, struct String *src) {
|
||||
const u16 *cstr = String_c_str(src);
|
||||
String_SetEmpty(dest);
|
||||
while (*cstr != EOS)
|
||||
{
|
||||
if (*cstr == EXT_CTRL_CODE_BEGIN)
|
||||
{
|
||||
if (MsgArray_ControlCodeIsStrVar(cstr))
|
||||
{
|
||||
while (*cstr != EOS) {
|
||||
if (*cstr == EXT_CTRL_CODE_BEGIN) {
|
||||
if (MsgArray_ControlCodeIsStrVar(cstr)) {
|
||||
u32 idx = MsgArray_ControlCodeGetField(cstr, 0);
|
||||
GF_ASSERT(idx < messageFormat->count);
|
||||
StringCat_HandleTrainerName(dest, messageFormat->fields[idx].msg);
|
||||
cstr = MsgArray_SkipControlCode(cstr);
|
||||
}
|
||||
else
|
||||
{
|
||||
const u16 * before = cstr;
|
||||
cstr = MsgArray_SkipControlCode(cstr);
|
||||
while (before < cstr)
|
||||
} else {
|
||||
const u16 *before = cstr;
|
||||
cstr = MsgArray_SkipControlCode(cstr);
|
||||
while (before < cstr) {
|
||||
StrAddChar(dest, *before++);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
} else {
|
||||
StrAddChar(dest, *cstr++);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MessageFormat_ResetBuffers(MessageFormat *messageFormat)
|
||||
{
|
||||
for (int i = 0; i < messageFormat->count; i++)
|
||||
void MessageFormat_ResetBuffers(MessageFormat *messageFormat) {
|
||||
for (int i = 0; i < messageFormat->count; i++) {
|
||||
String_SetEmpty(messageFormat->fields[i].msg);
|
||||
}
|
||||
}
|
||||
|
||||
struct UnkStruct_0200B870 * MessagePrinter_New(u32 color1, u32 color2, u32 color3, HeapID heapId)
|
||||
{
|
||||
struct UnkStruct_0200B870 * sp8 = AllocFromHeap(heapId, sizeof(struct UnkStruct_0200B870));
|
||||
if (sp8 != NULL)
|
||||
{
|
||||
struct UnkStruct_0200B870 *MessagePrinter_New(u32 color1, u32 color2, u32 color3, HeapID heapId) {
|
||||
struct UnkStruct_0200B870 *sp8 = AllocFromHeap(heapId, sizeof(struct UnkStruct_0200B870));
|
||||
if (sp8 != NULL) {
|
||||
sp8->unk_0 = GfGfxLoader_GetCharData(NARC_GRAPHIC_FONT, NARC_font_narc_0004_NCGR_lz, 1, &sp8->unk_4, heapId);
|
||||
int i;
|
||||
u8 * ptr = sp8->unk_4->pRawData;
|
||||
for (i = 0; i < sp8->unk_4->szByte; i++)
|
||||
{
|
||||
switch (ptr[i])
|
||||
{
|
||||
u8 *ptr = sp8->unk_4->pRawData;
|
||||
for (i = 0; i < sp8->unk_4->szByte; i++) {
|
||||
switch (ptr[i]) {
|
||||
case 0x00:
|
||||
ptr[i] = (u8)((color3 << 4) | color3);
|
||||
break;
|
||||
|
|
@ -792,32 +673,25 @@ struct UnkStruct_0200B870 * MessagePrinter_New(u32 color1, u32 color2, u32 color
|
|||
return sp8;
|
||||
}
|
||||
|
||||
void MessagePrinter_Delete(struct UnkStruct_0200B870 * a0)
|
||||
{
|
||||
if (a0 != NULL)
|
||||
{
|
||||
if (a0->unk_0 != NULL)
|
||||
void MessagePrinter_Delete(struct UnkStruct_0200B870 *a0) {
|
||||
if (a0 != NULL) {
|
||||
if (a0->unk_0 != NULL) {
|
||||
FreeToHeap(a0->unk_0);
|
||||
}
|
||||
FreeToHeap(a0);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0200B9A8(struct UnkStruct_0200B870 * a0, int a1, struct Window *a2, int a3, int a4)
|
||||
{
|
||||
void sub_0200B9A8(struct UnkStruct_0200B870 *a0, int a1, struct Window *a2, int a3, int a4) {
|
||||
BlitBitmapRectToWindow(a2, a0->unk_4->pRawData + UNK_020ECE6C[a1][0], 0, 0, UNK_020ECE6C[a1][1], 8, (u16)a3, (u16)a4, UNK_020ECE6C[a1][1], 8);
|
||||
}
|
||||
|
||||
void sub_0200B9EC(struct UnkStruct_0200B870 * string, u32 value, u32 n, enum PrintingMode mode, struct Window *window, int x, int y)
|
||||
{
|
||||
void sub_0200B9EC(struct UnkStruct_0200B870 *string, u32 value, u32 n, enum PrintingMode mode, struct Window *window, int x, int y) {
|
||||
ConvertUIntToDecimalString(string->data, value, mode, n);
|
||||
for (int i = 0; string->data[i] != EOS; i++)
|
||||
{
|
||||
if (string->data[i] >= CHAR_JP_0 && string->data[i] <= CHAR_JP_9)
|
||||
{
|
||||
for (int i = 0; string->data[i] != EOS; i++) {
|
||||
if (string->data[i] >= CHAR_JP_0 && string->data[i] <= CHAR_JP_9) {
|
||||
BlitBitmapRectToWindow(window, string->unk_4->pRawData + (string->data[i] - CHAR_JP_0) * 32, 0, 0, 8, 8, (u16)x, (u16)y, 8, 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
FillWindowPixelRect(window, (u8)string->unk_28, (u16)x, (u16)y, 8, 8);
|
||||
}
|
||||
x += 8;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#include "global.h"
|
||||
#include "move_relearner.h"
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "pokemon.h"
|
||||
|
||||
MoveRelearner *MoveRelearner_New(HeapID heapId) {
|
||||
|
|
@ -12,10 +14,10 @@ void MoveRelearner_Delete(MoveRelearner *moveRelearner) {
|
|||
FreeToHeap(moveRelearner);
|
||||
}
|
||||
|
||||
u16 *MoveRelearner_GetEligibleLevelUpMoves(Pokemon* mon, HeapID heapId) {
|
||||
u16 *MoveRelearner_GetEligibleLevelUpMoves(Pokemon *mon, HeapID heapId) {
|
||||
u16 species = GetMonData(mon, MON_DATA_SPECIES, NULL);
|
||||
u8 form = GetMonData(mon, MON_DATA_FORM, NULL);
|
||||
u8 level = GetMonData(mon, MON_DATA_LEVEL, NULL);
|
||||
u8 form = GetMonData(mon, MON_DATA_FORM, NULL);
|
||||
u8 level = GetMonData(mon, MON_DATA_LEVEL, NULL);
|
||||
u16 moves[MAX_MON_MOVES];
|
||||
|
||||
for (u8 i = 0; i < MAX_MON_MOVES; ++i) {
|
||||
|
|
@ -23,7 +25,7 @@ u16 *MoveRelearner_GetEligibleLevelUpMoves(Pokemon* mon, HeapID heapId) {
|
|||
}
|
||||
|
||||
u16 *tableFromFile = AllocFromHeap(heapId, LEVEL_UP_LEARNSET_MAX * 2);
|
||||
u16 *returnTable = AllocFromHeap(heapId, LEVEL_UP_LEARNSET_MAX * 2);
|
||||
u16 *returnTable = AllocFromHeap(heapId, LEVEL_UP_LEARNSET_MAX * 2);
|
||||
|
||||
LoadLevelUpLearnset_HandleAlternateForm(species, form, tableFromFile);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,78 +1,70 @@
|
|||
#include "global.h"
|
||||
#include "filesystem.h"
|
||||
#include "msgdata.h"
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "msgdata/msg.naix"
|
||||
#include "heap.h"
|
||||
|
||||
#include "MI_memory.h"
|
||||
#include "filesystem.h"
|
||||
#include "heap.h"
|
||||
#include "string16.h"
|
||||
|
||||
static void * LoadSingleElementFromNarc(NarcId narc_id, s32 file_id, HeapID heapId);
|
||||
static void FreeMsgDataRawData(void * data);
|
||||
static void ReadMsgData_ExistingTable_ExistingArray(struct MsgDataTable * table, u32 num, u16 * dest);
|
||||
static void ReadMsgData_NewNarc_ExistingArray(NarcId narc_id, u32 group, u32 num, HeapID heapId, u16 * dest);
|
||||
static void CopyEncryptedMessage16(u16 * dest, const u16 * src, struct MsgDataAlloc * param);
|
||||
static void ReadMsgData_ExistingTable_ExistingString(struct MsgDataTable * table, u32 num, struct String * dest);
|
||||
static struct String * ReadMsgData_ExistingTable_NewString(struct MsgDataTable * table, u32 num, HeapID heapId);
|
||||
static void ReadMsgData_ExistingNarc_ExistingString(NARC * narc, u32 group, u32 num, HeapID heapId, struct String * dest);
|
||||
static struct String * ReadMsgData_ExistingNarc_NewString(NARC * narc, u32 group, u32 num, HeapID heapId);
|
||||
static u16 GetMsgCount_ExistingTable(struct MsgDataTable * tbl);
|
||||
static void *LoadSingleElementFromNarc(NarcId narc_id, s32 file_id, HeapID heapId);
|
||||
static void FreeMsgDataRawData(void *data);
|
||||
static void ReadMsgData_ExistingTable_ExistingArray(struct MsgDataTable *table, u32 num, u16 *dest);
|
||||
static void ReadMsgData_NewNarc_ExistingArray(NarcId narc_id, u32 group, u32 num, HeapID heapId, u16 *dest);
|
||||
static void CopyEncryptedMessage16(u16 *dest, const u16 *src, struct MsgDataAlloc *param);
|
||||
static void ReadMsgData_ExistingTable_ExistingString(struct MsgDataTable *table, u32 num, struct String *dest);
|
||||
static struct String *ReadMsgData_ExistingTable_NewString(struct MsgDataTable *table, u32 num, HeapID heapId);
|
||||
static void ReadMsgData_ExistingNarc_ExistingString(NARC *narc, u32 group, u32 num, HeapID heapId, struct String *dest);
|
||||
static struct String *ReadMsgData_ExistingNarc_NewString(NARC *narc, u32 group, u32 num, HeapID heapId);
|
||||
static u16 GetMsgCount_ExistingTable(struct MsgDataTable *tbl);
|
||||
static u16 GetMsgCount_TableFromNarc(NarcId narc_id, s32 file_id);
|
||||
|
||||
static void * LoadSingleElementFromNarc(NarcId narc_id, s32 file_id, HeapID heapId)
|
||||
{
|
||||
static void *LoadSingleElementFromNarc(NarcId narc_id, s32 file_id, HeapID heapId) {
|
||||
return AllocAndReadWholeNarcMemberByIdPair(narc_id, file_id, heapId);
|
||||
}
|
||||
|
||||
static void FreeMsgDataRawData(void * data)
|
||||
{
|
||||
static void FreeMsgDataRawData(void *data) {
|
||||
FreeToHeap(data);
|
||||
}
|
||||
|
||||
inline static void Decrypt1(struct MsgDataAlloc * arg0, u32 arg1, u32 seed)
|
||||
{
|
||||
inline static void Decrypt1(struct MsgDataAlloc *arg0, u32 arg1, u32 seed) {
|
||||
seed = seed * 765 * (arg1 + 1) & 0xffff;
|
||||
seed |= seed << 16;
|
||||
arg0->offset ^= seed;
|
||||
arg0->length ^= seed;
|
||||
}
|
||||
|
||||
inline static void Decrypt2(u16 * arg0, u32 count, u32 arg2)
|
||||
{
|
||||
inline static void Decrypt2(u16 *arg0, u32 count, u32 arg2) {
|
||||
u16 seed = (u16)((arg2 + 1) * 596947);
|
||||
|
||||
while (count-- > 0)
|
||||
{
|
||||
while (count-- > 0) {
|
||||
*arg0 ^= seed;
|
||||
arg0++;
|
||||
seed += 18749;
|
||||
}
|
||||
}
|
||||
|
||||
static void ReadMsgData_ExistingTable_ExistingArray(struct MsgDataTable * table, u32 num, u16 * dest)
|
||||
{
|
||||
static void ReadMsgData_ExistingTable_ExistingArray(struct MsgDataTable *table, u32 num, u16 *dest) {
|
||||
struct MsgDataAlloc sp0;
|
||||
|
||||
if (num < table->count)
|
||||
{
|
||||
if (num < table->count) {
|
||||
sp0 = table->alloc[num];
|
||||
Decrypt1(&sp0, num, table->key);
|
||||
|
||||
CopyEncryptedMessage16(dest, (const u16 *)((u8 *)table + sp0.offset), &sp0);
|
||||
Decrypt2(dest, sp0.length, num);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
GF_ASSERT(FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
static void ReadMsgData_NewNarc_ExistingArray(NarcId narc_id, u32 group, u32 num, HeapID heapId, u16 * dest)
|
||||
{
|
||||
NARC * narc = NARC_New(narc_id, heapId);
|
||||
static void ReadMsgData_NewNarc_ExistingArray(NarcId narc_id, u32 group, u32 num, HeapID heapId, u16 *dest) {
|
||||
NARC *narc = NARC_New(narc_id, heapId);
|
||||
u16 header[2];
|
||||
struct MsgDataAlloc alloc;
|
||||
if (narc != NULL)
|
||||
{
|
||||
if (narc != NULL) {
|
||||
NARC_ReadFromMember(narc, group, 0, 4, header);
|
||||
NARC_ReadFromMember(narc, group, 8 * num + 4, 8, &alloc);
|
||||
Decrypt1(&alloc, num, header[1]);
|
||||
|
|
@ -82,143 +74,116 @@ static void ReadMsgData_NewNarc_ExistingArray(NarcId narc_id, u32 group, u32 num
|
|||
}
|
||||
}
|
||||
|
||||
static void CopyEncryptedMessage16(u16 * dest, const u16 * src, struct MsgDataAlloc * param)
|
||||
{
|
||||
static void CopyEncryptedMessage16(u16 *dest, const u16 *src, struct MsgDataAlloc *param) {
|
||||
MI_CpuCopy16(src, dest, 2 * param->length);
|
||||
}
|
||||
|
||||
static void ReadMsgData_ExistingTable_ExistingString(struct MsgDataTable * table, u32 num, struct String * dest)
|
||||
{
|
||||
static void ReadMsgData_ExistingTable_ExistingString(struct MsgDataTable *table, u32 num, struct String *dest) {
|
||||
struct MsgDataAlloc alloc;
|
||||
u16 * buf;
|
||||
if (num < table->count)
|
||||
{
|
||||
u16 *buf;
|
||||
if (num < table->count) {
|
||||
alloc = table->alloc[num];
|
||||
Decrypt1(&alloc, num, table->key);
|
||||
buf = AllocFromHeapAtEnd(HEAP_ID_DEFAULT, 2 * alloc.length);
|
||||
if (buf != NULL)
|
||||
{
|
||||
if (buf != NULL) {
|
||||
MI_CpuCopy16((char *)table + alloc.offset, buf, 2 * alloc.length);
|
||||
Decrypt2(buf, alloc.length, num);
|
||||
CopyU16ArrayToStringN(dest, buf, alloc.length);
|
||||
FreeToHeap(buf);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
GF_ASSERT(FALSE);
|
||||
String_SetEmpty(dest);
|
||||
}
|
||||
}
|
||||
|
||||
static struct String * ReadMsgData_ExistingTable_NewString(struct MsgDataTable * table, u32 num, HeapID heapId)
|
||||
{
|
||||
static struct String *ReadMsgData_ExistingTable_NewString(struct MsgDataTable *table, u32 num, HeapID heapId) {
|
||||
struct MsgDataAlloc alloc;
|
||||
u16 * buf;
|
||||
struct String * dest;
|
||||
if (num < table->count)
|
||||
{
|
||||
u16 *buf;
|
||||
struct String *dest;
|
||||
if (num < table->count) {
|
||||
alloc = table->alloc[num];
|
||||
Decrypt1(&alloc, num, table->key);
|
||||
buf = AllocFromHeapAtEnd(heapId, 2 * alloc.length);
|
||||
if (buf != NULL)
|
||||
{
|
||||
if (buf != NULL) {
|
||||
MI_CpuCopy16((char *)table + alloc.offset, buf, 2 * alloc.length);
|
||||
Decrypt2(buf, alloc.length, num);
|
||||
dest = String_New(alloc.length, heapId);
|
||||
if (dest != NULL)
|
||||
if (dest != NULL) {
|
||||
CopyU16ArrayToStringN(dest, buf, alloc.length);
|
||||
}
|
||||
FreeToHeap(buf);
|
||||
return dest;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
GF_ASSERT(FALSE);
|
||||
return String_New(4, heapId);
|
||||
}
|
||||
}
|
||||
|
||||
void ReadMsgData_NewNarc_ExistingString(NarcId narc_id, u32 group, u32 num, HeapID heapId, struct String * dest)
|
||||
{
|
||||
NARC * narc = NARC_New(narc_id, heapId);
|
||||
if (narc != NULL)
|
||||
{
|
||||
void ReadMsgData_NewNarc_ExistingString(NarcId narc_id, u32 group, u32 num, HeapID heapId, struct String *dest) {
|
||||
NARC *narc = NARC_New(narc_id, heapId);
|
||||
if (narc != NULL) {
|
||||
ReadMsgData_ExistingNarc_ExistingString(narc, group, num, heapId, dest);
|
||||
NARC_Delete(narc);
|
||||
}
|
||||
}
|
||||
|
||||
static void ReadMsgData_ExistingNarc_ExistingString(NARC * narc, u32 group, u32 num, HeapID heapId, struct String * dest)
|
||||
{
|
||||
u16 * buf;
|
||||
static void ReadMsgData_ExistingNarc_ExistingString(NARC *narc, u32 group, u32 num, HeapID heapId, struct String *dest) {
|
||||
u16 *buf;
|
||||
u32 size;
|
||||
u16 sp10[2];
|
||||
struct MsgDataAlloc alloc;
|
||||
|
||||
NARC_ReadFromMember(narc, group, 0, 4, sp10);
|
||||
if (num < sp10[0])
|
||||
{
|
||||
if (num < sp10[0]) {
|
||||
NARC_ReadFromMember(narc, group, 8 * num + 4, 8, &alloc);
|
||||
Decrypt1(&alloc, num, sp10[1]);
|
||||
size = alloc.length * 2;
|
||||
buf = AllocFromHeapAtEnd(heapId, size);
|
||||
if (buf != NULL)
|
||||
{
|
||||
buf = AllocFromHeapAtEnd(heapId, size);
|
||||
if (buf != NULL) {
|
||||
NARC_ReadFromMember(narc, group, alloc.offset, size, buf);
|
||||
Decrypt2(buf, alloc.length, num);
|
||||
CopyU16ArrayToStringN(dest, buf, alloc.length);
|
||||
FreeToHeap(buf);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
GF_ASSERT(FALSE);
|
||||
String_SetEmpty(dest);
|
||||
}
|
||||
}
|
||||
|
||||
struct String * ReadMsgData_NewNarc_NewString(NarcId narc_id, u32 group, u32 num, HeapID heapId)
|
||||
{
|
||||
NARC * narc = NARC_New(narc_id, heapId);
|
||||
struct String * string;
|
||||
if (narc != NULL)
|
||||
{
|
||||
struct String *ReadMsgData_NewNarc_NewString(NarcId narc_id, u32 group, u32 num, HeapID heapId) {
|
||||
NARC *narc = NARC_New(narc_id, heapId);
|
||||
struct String *string;
|
||||
if (narc != NULL) {
|
||||
string = ReadMsgData_ExistingNarc_NewString(narc, group, num, heapId);
|
||||
NARC_Delete(narc);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
string = String_New(4, heapId);
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
static struct String * ReadMsgData_ExistingNarc_NewString(NARC * narc, u32 group, u32 num, HeapID heapId)
|
||||
{
|
||||
struct String * dest;
|
||||
u16 * buf;
|
||||
static struct String *ReadMsgData_ExistingNarc_NewString(NARC *narc, u32 group, u32 num, HeapID heapId) {
|
||||
struct String *dest;
|
||||
u16 *buf;
|
||||
u32 size;
|
||||
u16 sp10[2];
|
||||
struct MsgDataAlloc alloc;
|
||||
|
||||
NARC_ReadFromMember(narc, group, 0, 4, sp10);
|
||||
if (num < sp10[0])
|
||||
{
|
||||
if (num < sp10[0]) {
|
||||
NARC_ReadFromMember(narc, group, 8 * num + 4, 8, &alloc);
|
||||
Decrypt1(&alloc, num, sp10[1]);
|
||||
dest = String_New(alloc.length, heapId);
|
||||
if (dest != NULL)
|
||||
{
|
||||
if (dest != NULL) {
|
||||
size = alloc.length * 2;
|
||||
buf = AllocFromHeapAtEnd(heapId, size);
|
||||
if (buf != NULL)
|
||||
{
|
||||
buf = AllocFromHeapAtEnd(heapId, size);
|
||||
if (buf != NULL) {
|
||||
NARC_ReadFromMember(narc, group, alloc.offset, size, buf);
|
||||
Decrypt2(buf, alloc.length, num);
|
||||
CopyU16ArrayToStringN(dest, buf, alloc.length);
|
||||
|
|
@ -226,58 +191,45 @@ static struct String * ReadMsgData_ExistingNarc_NewString(NARC * narc, u32 group
|
|||
}
|
||||
}
|
||||
return dest;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
GF_ASSERT(FALSE);
|
||||
return String_New(4, heapId);
|
||||
}
|
||||
}
|
||||
|
||||
static u16 GetMsgCount_ExistingTable(struct MsgDataTable * tbl)
|
||||
{
|
||||
static u16 GetMsgCount_ExistingTable(struct MsgDataTable *tbl) {
|
||||
return tbl->count;
|
||||
}
|
||||
|
||||
static u16 GetMsgCount_TableFromNarc(NarcId narc_id, s32 file_id)
|
||||
{
|
||||
static u16 GetMsgCount_TableFromNarc(NarcId narc_id, s32 file_id) {
|
||||
u16 n[2];
|
||||
ReadFromNarcMemberByIdPair(&n, narc_id, file_id, 0, 4);
|
||||
return n[0];
|
||||
}
|
||||
|
||||
struct MsgData * NewMsgDataFromNarc(MsgDataLoadType type, NarcId narc_id, s32 file_id, HeapID heapId)
|
||||
{
|
||||
struct MsgData * msgData = AllocFromHeapAtEnd(heapId, sizeof(struct MsgData));
|
||||
if (msgData != NULL)
|
||||
{
|
||||
if (type == MSGDATA_LOAD_DIRECT)
|
||||
{
|
||||
struct MsgData *NewMsgDataFromNarc(MsgDataLoadType type, NarcId narc_id, s32 file_id, HeapID heapId) {
|
||||
struct MsgData *msgData = AllocFromHeapAtEnd(heapId, sizeof(struct MsgData));
|
||||
if (msgData != NULL) {
|
||||
if (type == MSGDATA_LOAD_DIRECT) {
|
||||
msgData->data.raw = LoadSingleElementFromNarc(narc_id, file_id, heapId);
|
||||
if (msgData->data.raw == NULL)
|
||||
{
|
||||
if (msgData->data.raw == NULL) {
|
||||
FreeToHeap(msgData);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
msgData->data.narc = NARC_New(narc_id, heapId);
|
||||
}
|
||||
msgData->type = (u16)type;
|
||||
msgData->type = (u16)type;
|
||||
msgData->narc_id = (u16)narc_id;
|
||||
msgData->file_id = (u16)file_id;
|
||||
msgData->heapId = (u16)heapId;
|
||||
msgData->heapId = (u16)heapId;
|
||||
}
|
||||
return msgData;
|
||||
}
|
||||
|
||||
void DestroyMsgData(struct MsgData * msgData)
|
||||
{
|
||||
if (msgData != NULL)
|
||||
{
|
||||
switch (msgData->type)
|
||||
{
|
||||
void DestroyMsgData(struct MsgData *msgData) {
|
||||
if (msgData != NULL) {
|
||||
switch (msgData->type) {
|
||||
case MSGDATA_LOAD_DIRECT:
|
||||
FreeMsgDataRawData(msgData->data.raw);
|
||||
break;
|
||||
|
|
@ -289,10 +241,8 @@ void DestroyMsgData(struct MsgData * msgData)
|
|||
}
|
||||
}
|
||||
|
||||
void ReadMsgDataIntoString(struct MsgData * msgData, u32 msg_no, struct String * dest)
|
||||
{
|
||||
switch (msgData->type)
|
||||
{
|
||||
void ReadMsgDataIntoString(struct MsgData *msgData, u32 msg_no, struct String *dest) {
|
||||
switch (msgData->type) {
|
||||
case MSGDATA_LOAD_DIRECT:
|
||||
ReadMsgData_ExistingTable_ExistingString(msgData->data.raw, msg_no, dest);
|
||||
break;
|
||||
|
|
@ -302,10 +252,8 @@ void ReadMsgDataIntoString(struct MsgData * msgData, u32 msg_no, struct String *
|
|||
}
|
||||
}
|
||||
|
||||
struct String * NewString_ReadMsgData(struct MsgData * msgData, u32 msg_no)
|
||||
{
|
||||
switch (msgData->type)
|
||||
{
|
||||
struct String *NewString_ReadMsgData(struct MsgData *msgData, u32 msg_no) {
|
||||
switch (msgData->type) {
|
||||
case MSGDATA_LOAD_DIRECT:
|
||||
return ReadMsgData_ExistingTable_NewString(msgData->data.raw, msg_no, (HeapID)msgData->heapId);
|
||||
case MSGDATA_LOAD_LAZY:
|
||||
|
|
@ -315,10 +263,8 @@ struct String * NewString_ReadMsgData(struct MsgData * msgData, u32 msg_no)
|
|||
}
|
||||
}
|
||||
|
||||
u16 MsgDataGetCount(struct MsgData * msgData)
|
||||
{
|
||||
switch (msgData->type)
|
||||
{
|
||||
u16 MsgDataGetCount(struct MsgData *msgData) {
|
||||
switch (msgData->type) {
|
||||
case MSGDATA_LOAD_DIRECT:
|
||||
return GetMsgCount_ExistingTable(msgData->data.raw);
|
||||
case MSGDATA_LOAD_LAZY:
|
||||
|
|
@ -328,10 +274,8 @@ u16 MsgDataGetCount(struct MsgData * msgData)
|
|||
}
|
||||
}
|
||||
|
||||
void ReadMsgDataIntoU16Array(struct MsgData * msgData, u32 msg_no, u16 * dest)
|
||||
{
|
||||
switch (msgData->type)
|
||||
{
|
||||
void ReadMsgDataIntoU16Array(struct MsgData *msgData, u32 msg_no, u16 *dest) {
|
||||
switch (msgData->type) {
|
||||
case MSGDATA_LOAD_DIRECT:
|
||||
ReadMsgData_ExistingTable_ExistingArray(msgData->data.raw, msg_no, dest);
|
||||
break;
|
||||
|
|
@ -341,23 +285,19 @@ void ReadMsgDataIntoU16Array(struct MsgData * msgData, u32 msg_no, u16 * dest)
|
|||
}
|
||||
}
|
||||
|
||||
void GetSpeciesNameIntoArray(u16 species, HeapID heapId, u16 * dest)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0362_bin, heapId);
|
||||
void GetSpeciesNameIntoArray(u16 species, HeapID heapId, u16 *dest) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0362_bin, heapId);
|
||||
ReadMsgDataIntoU16Array(msgData, species, dest);
|
||||
DestroyMsgData(msgData);
|
||||
}
|
||||
|
||||
struct String * ReadMsgData_ExpandPlaceholders(MessageFormat *messageFormat, struct MsgData * msgData, u32 msgno, HeapID heapId)
|
||||
{
|
||||
struct String * ret = NULL;
|
||||
struct String * r4 = String_New(1024, HEAP_ID_DEFAULT);
|
||||
struct String * r5;
|
||||
if (r4 != NULL)
|
||||
{
|
||||
struct String *ReadMsgData_ExpandPlaceholders(MessageFormat *messageFormat, struct MsgData *msgData, u32 msgno, HeapID heapId) {
|
||||
struct String *ret = NULL;
|
||||
struct String *r4 = String_New(1024, HEAP_ID_DEFAULT);
|
||||
struct String *r5;
|
||||
if (r4 != NULL) {
|
||||
r5 = NewString_ReadMsgData(msgData, msgno);
|
||||
if (r5 != NULL)
|
||||
{
|
||||
if (r5 != NULL) {
|
||||
StringExpandPlaceholders(messageFormat, r4, r5);
|
||||
ret = StringDup(r4, heapId);
|
||||
String_Delete(r5);
|
||||
|
|
@ -367,15 +307,12 @@ struct String * ReadMsgData_ExpandPlaceholders(MessageFormat *messageFormat, str
|
|||
return ret;
|
||||
}
|
||||
|
||||
struct String * GetMoveName(u32 move, HeapID heapId)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0588_bin, heapId);
|
||||
struct String * ret;
|
||||
if (msgData != NULL)
|
||||
{
|
||||
struct String *GetMoveName(u32 move, HeapID heapId) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0588_bin, heapId);
|
||||
struct String *ret;
|
||||
if (msgData != NULL) {
|
||||
ret = String_New(16, heapId);
|
||||
if (ret != NULL)
|
||||
{
|
||||
if (ret != NULL) {
|
||||
ReadMsgDataIntoString(msgData, move, ret);
|
||||
}
|
||||
DestroyMsgData(msgData);
|
||||
|
|
@ -384,12 +321,10 @@ struct String * GetMoveName(u32 move, HeapID heapId)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
struct String * GetSpeciesName(u16 species, HeapID heapId)
|
||||
{
|
||||
struct String * ret;
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0362_bin, heapId);
|
||||
if (msgData != NULL)
|
||||
{
|
||||
struct String *GetSpeciesName(u16 species, HeapID heapId) {
|
||||
struct String *ret;
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0362_bin, heapId);
|
||||
if (msgData != NULL) {
|
||||
ret = NewString_ReadMsgData(msgData, species);
|
||||
DestroyMsgData(msgData);
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -1,41 +1,38 @@
|
|||
//TODO: RENAME THIS ENTIRE FILE - WE SHOULD NOT BE USING NUT
|
||||
// TODO: RENAME THIS ENTIRE FILE - WE SHOULD NOT BE USING NUT
|
||||
|
||||
#include "nutdata.h"
|
||||
|
||||
#include "global.h"
|
||||
#include "filesystem.h"
|
||||
#include "nutdata.h"
|
||||
#include "msgdata.h"
|
||||
#include "msgdata/msg.naix"
|
||||
|
||||
#include "constants/items.h"
|
||||
|
||||
NARC * OpenNutsDataNarc(HeapID heapId)
|
||||
{
|
||||
#include "msgdata/msg.naix"
|
||||
|
||||
#include "filesystem.h"
|
||||
#include "msgdata.h"
|
||||
|
||||
NARC *OpenNutsDataNarc(HeapID heapId) {
|
||||
return NARC_New(NARC_ITEMTOOL_ITEMDATA_NUTS_DATA, heapId);
|
||||
}
|
||||
|
||||
struct NutData * ReadNutDataFromNarc(NARC * narc, u32 berry_idx, HeapID heapId)
|
||||
{
|
||||
struct NutData *ReadNutDataFromNarc(NARC *narc, u32 berry_idx, HeapID heapId) {
|
||||
return NARC_AllocAndReadWholeMember(narc, berry_idx, heapId);
|
||||
}
|
||||
|
||||
void CloseNutsDataNarc(NARC * narc)
|
||||
{
|
||||
void CloseNutsDataNarc(NARC *narc) {
|
||||
NARC_Delete(narc);
|
||||
}
|
||||
|
||||
struct NutData * LoadNutDataSingle(s32 berry_idx, HeapID heapId)
|
||||
{
|
||||
struct NutData *LoadNutDataSingle(s32 berry_idx, HeapID heapId) {
|
||||
return AllocAndReadWholeNarcMemberByIdPair(NARC_ITEMTOOL_ITEMDATA_NUTS_DATA, berry_idx, heapId);
|
||||
}
|
||||
|
||||
struct NutData * LoadNutDataSingleByItemId(s32 item_id, HeapID heapId)
|
||||
{
|
||||
struct NutData *LoadNutDataSingleByItemId(s32 item_id, HeapID heapId) {
|
||||
return LoadNutDataSingle(item_id - FIRST_BERRY_IDX, heapId);
|
||||
}
|
||||
|
||||
u32 GetNutAttr(struct NutData * nut, u32 attr)
|
||||
{
|
||||
switch (attr)
|
||||
{
|
||||
u32 GetNutAttr(struct NutData *nut, u32 attr) {
|
||||
switch (attr) {
|
||||
case 0:
|
||||
return nut->size;
|
||||
case 1:
|
||||
|
|
@ -63,18 +60,16 @@ u32 GetNutAttr(struct NutData * nut, u32 attr)
|
|||
}
|
||||
}
|
||||
|
||||
struct String * GetNutName(u32 berry_idx, HeapID heapId)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0373_bin, heapId);
|
||||
struct String * ret = NewString_ReadMsgData(msgData, berry_idx);
|
||||
struct String *GetNutName(u32 berry_idx, HeapID heapId) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0373_bin, heapId);
|
||||
struct String *ret = NewString_ReadMsgData(msgData, berry_idx);
|
||||
DestroyMsgData(msgData);
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct String * GetNutDesc(u32 berry_idx, HeapID heapId)
|
||||
{
|
||||
struct MsgData * msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0372_bin, heapId);
|
||||
struct String * ret = NewString_ReadMsgData(msgData, berry_idx);
|
||||
struct String *GetNutDesc(u32 berry_idx, HeapID heapId) {
|
||||
struct MsgData *msgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_MSGDATA_MSG, NARC_msg_narc_0372_bin, heapId);
|
||||
struct String *ret = NewString_ReadMsgData(msgData, berry_idx);
|
||||
DestroyMsgData(msgData);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#include "global.h"
|
||||
#include "oam.h"
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "GX_g2.h"
|
||||
#include "MI_memory.h"
|
||||
#include "heap.h"
|
||||
|
|
@ -25,33 +27,24 @@ void sub_02009EAC(s32 param0,
|
|||
u32 param5,
|
||||
u32 param6,
|
||||
u32 param7,
|
||||
HeapID heapId)
|
||||
{
|
||||
HeapID heapId) {
|
||||
s32 r0;
|
||||
if (param0 < 4)
|
||||
{
|
||||
if (param0 < 4) {
|
||||
r0 = 4;
|
||||
if (param1 > 0x7c)
|
||||
{
|
||||
if (param1 > 0x7c) {
|
||||
param1 = param1 - (4 - param0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
r0 = param0;
|
||||
}
|
||||
|
||||
s32 r2;
|
||||
if (param2 < 1)
|
||||
{
|
||||
if (param2 < 1) {
|
||||
r2 = 1;
|
||||
if (param3 > 0x1e)
|
||||
{
|
||||
if (param3 > 0x1e) {
|
||||
param3 = param3 - (1 - param2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
r2 = param2;
|
||||
}
|
||||
|
||||
|
|
@ -66,8 +59,7 @@ void InitOamData(s32 param0,
|
|||
u32 param5,
|
||||
u32 param6,
|
||||
u32 param7,
|
||||
HeapID heapId)
|
||||
{
|
||||
HeapID heapId) {
|
||||
GF_ASSERT(oamData == NULL);
|
||||
oamData = AllocFromHeap(heapId, sizeof(struct OamData));
|
||||
GF_ASSERT(oamData);
|
||||
|
|
@ -80,17 +72,14 @@ void InitOamData(s32 param0,
|
|||
&oamData->oamManagers[1], (u16)param4, (u16)param5, (u16)param6, (u16)param7, 1));
|
||||
}
|
||||
|
||||
void ApplyAndResetOamManagerBuffer(void)
|
||||
{
|
||||
if (oamData != NULL)
|
||||
{
|
||||
void ApplyAndResetOamManagerBuffer(void) {
|
||||
if (oamData != NULL) {
|
||||
NNS_G2dApplyAndResetOamManagerBuffer(&oamData->oamManagers[0]);
|
||||
NNS_G2dApplyAndResetOamManagerBuffer(&oamData->oamManagers[1]);
|
||||
}
|
||||
}
|
||||
|
||||
void DeinitOamData(void)
|
||||
{
|
||||
void DeinitOamData(void) {
|
||||
GF_ASSERT(oamData);
|
||||
|
||||
sub_0200A064(oamData->heapId);
|
||||
|
|
@ -100,12 +89,10 @@ void DeinitOamData(void)
|
|||
oamData = NULL;
|
||||
}
|
||||
|
||||
void sub_02009FD8(void *param0, u32 *param1, u32 param2, u32 param3)
|
||||
{
|
||||
void sub_02009FD8(void *param0, u32 *param1, u32 param2, u32 param3) {
|
||||
GF_ASSERT(oamData);
|
||||
|
||||
if (param2 == 1)
|
||||
{
|
||||
if (param2 == 1) {
|
||||
sub_0202135C(param0, param1, EntryOamManagerOamWithAffineIdxMainScreen, EntryOamManagerAffineMainScreen, sub_020213A0, param2, param3);
|
||||
return;
|
||||
}
|
||||
|
|
@ -113,55 +100,45 @@ void sub_02009FD8(void *param0, u32 *param1, u32 param2, u32 param3)
|
|||
sub_0202135C(param0, param1, EntryOamManagerOamWithAffineIdxSubScreen, EntryOamManagerAffineSubScreen, sub_020213A0, param2, param3);
|
||||
}
|
||||
|
||||
NNSG2dOamManager *GetOamManager(u32 screen)
|
||||
{
|
||||
NNSG2dOamManager *GetOamManager(u32 screen) {
|
||||
GF_ASSERT(oamData);
|
||||
if (screen == 0)
|
||||
{
|
||||
if (screen == 0) {
|
||||
return &oamData->oamManagers[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return &oamData->oamManagers[1];
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0200A064(HeapID heapId)
|
||||
{
|
||||
void sub_0200A064(HeapID heapId) {
|
||||
sub_020203CC(heapId);
|
||||
}
|
||||
|
||||
void sub_0200A06C(HeapID heapId)
|
||||
{
|
||||
void sub_0200A06C(HeapID heapId) {
|
||||
sub_02020404(heapId);
|
||||
}
|
||||
|
||||
u32 EntryOamManagerOamWithAffineIdxMainScreen(u32 param0, u32 param1)
|
||||
{
|
||||
u32 EntryOamManagerOamWithAffineIdxMainScreen(u32 param0, u32 param1) {
|
||||
u32 res = NNS_G2dEntryOamManagerOamWithAffineIdx(&oamData->oamManagers[0], param0, param1);
|
||||
GF_ASSERT(res);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
u32 EntryOamManagerOamWithAffineIdxSubScreen(u32 param0, u32 param1)
|
||||
{
|
||||
u32 EntryOamManagerOamWithAffineIdxSubScreen(u32 param0, u32 param1) {
|
||||
u32 res = NNS_G2dEntryOamManagerOamWithAffineIdx(&oamData->oamManagers[1], param0, param1);
|
||||
GF_ASSERT(res);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
u32 EntryOamManagerAffineMainScreen(u32 param0)
|
||||
{
|
||||
u32 EntryOamManagerAffineMainScreen(u32 param0) {
|
||||
u32 res = NNS_G2dEntryOamManagerAffine(&oamData->oamManagers[0], param0);
|
||||
GF_ASSERT(res != 0xFFFE);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
u32 EntryOamManagerAffineSubScreen(u32 param0)
|
||||
{
|
||||
u32 EntryOamManagerAffineSubScreen(u32 param0) {
|
||||
u32 res = NNS_G2dEntryOamManagerAffine(&oamData->oamManagers[1], param0);
|
||||
GF_ASSERT(res != 0xFFFE);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,59 +1,61 @@
|
|||
#include "options.h"
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "MI_memory.h"
|
||||
#include "heap.h"
|
||||
#include "main.h"
|
||||
#include "MI_memory.h"
|
||||
#include "options.h"
|
||||
#include "player_data.h"
|
||||
|
||||
struct Options * Options_New(HeapID heapId) {
|
||||
struct Options * ret = AllocFromHeap(heapId, sizeof(struct Options));
|
||||
struct Options *Options_New(HeapID heapId) {
|
||||
struct Options *ret = AllocFromHeap(heapId, sizeof(struct Options));
|
||||
Options_Init(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Options_Copy(struct Options * src, struct Options * dest) {
|
||||
void Options_Copy(struct Options *src, struct Options *dest) {
|
||||
MI_CpuCopy8(src, dest, sizeof(struct Options));
|
||||
}
|
||||
|
||||
void Options_Init(struct Options * options) {
|
||||
void Options_Init(struct Options *options) {
|
||||
MI_CpuFill8(options, 0, sizeof(struct Options));
|
||||
|
||||
options->textSpeed = 1; // mid speed
|
||||
options->textSpeed = 1; // mid speed
|
||||
options->soundMethod = 0; // stereo
|
||||
options->battleStyle = 0; // shift
|
||||
options->battleScene = 0; // on
|
||||
options->buttonMode = 0; // normal
|
||||
options->frame = 0; // frame 1
|
||||
options->buttonMode = 0; // normal
|
||||
options->frame = 0; // frame 1
|
||||
}
|
||||
|
||||
void Options_SetButtonModeOnMain(struct SaveData * save, u32 buttonMode) {
|
||||
void Options_SetButtonModeOnMain(struct SaveData *save, u32 buttonMode) {
|
||||
if (save != NULL) {
|
||||
buttonMode = Options_GetButtonMode(Save_PlayerData_GetOptionsAddr(save));
|
||||
}
|
||||
|
||||
switch (buttonMode) {
|
||||
case 1:
|
||||
gSystem.buttonMode = 1;
|
||||
break;
|
||||
case 2:
|
||||
gSystem.buttonMode = 3;
|
||||
break;
|
||||
case 0:
|
||||
default:
|
||||
gSystem.buttonMode = 0;
|
||||
break;
|
||||
case 1:
|
||||
gSystem.buttonMode = 1;
|
||||
break;
|
||||
case 2:
|
||||
gSystem.buttonMode = 3;
|
||||
break;
|
||||
case 0:
|
||||
default:
|
||||
gSystem.buttonMode = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
u16 Options_GetTextSpeed(struct Options * options) {
|
||||
u16 Options_GetTextSpeed(struct Options *options) {
|
||||
return options->textSpeed;
|
||||
}
|
||||
|
||||
void Options_SetTextSpeed(struct Options * options, u16 textSpeed) {
|
||||
void Options_SetTextSpeed(struct Options *options, u16 textSpeed) {
|
||||
options->textSpeed = (u16)(u32)textSpeed;
|
||||
}
|
||||
|
||||
u32 Options_GetTextFrameDelay(struct Options * options) {
|
||||
u32 Options_GetTextFrameDelay(struct Options *options) {
|
||||
u16 textSpeed = Options_GetTextSpeed(options);
|
||||
|
||||
if (textSpeed == 0) {
|
||||
|
|
@ -67,42 +69,42 @@ u32 Options_GetTextFrameDelay(struct Options * options) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
u16 Options_GetSoundMethod(struct Options * options) {
|
||||
u16 Options_GetSoundMethod(struct Options *options) {
|
||||
return options->soundMethod;
|
||||
}
|
||||
|
||||
void Options_SetSoundMethod(struct Options * options, u16 soundMethod) {
|
||||
void Options_SetSoundMethod(struct Options *options, u16 soundMethod) {
|
||||
options->soundMethod = (u16)(u32)soundMethod;
|
||||
}
|
||||
|
||||
u16 Options_GetBattleScene(struct Options * options) {
|
||||
u16 Options_GetBattleScene(struct Options *options) {
|
||||
return options->battleScene;
|
||||
}
|
||||
|
||||
void Options_SetBattleScene(struct Options * options, u16 battleScene) {
|
||||
void Options_SetBattleScene(struct Options *options, u16 battleScene) {
|
||||
options->battleScene = (u16)(u32)battleScene;
|
||||
}
|
||||
|
||||
u16 Options_GetBattleStyle(struct Options * options) {
|
||||
u16 Options_GetBattleStyle(struct Options *options) {
|
||||
return options->battleStyle;
|
||||
}
|
||||
|
||||
void Options_SetBattleStyle(struct Options * options, u16 battleStyle) {
|
||||
void Options_SetBattleStyle(struct Options *options, u16 battleStyle) {
|
||||
options->battleStyle = (u16)(u32)battleStyle;
|
||||
}
|
||||
|
||||
u16 Options_GetButtonMode(struct Options * options) {
|
||||
u16 Options_GetButtonMode(struct Options *options) {
|
||||
return options->buttonMode;
|
||||
}
|
||||
|
||||
void Options_SetButtonMode(struct Options * options, u16 buttonMode) {
|
||||
void Options_SetButtonMode(struct Options *options, u16 buttonMode) {
|
||||
options->buttonMode = (u16)(u32)buttonMode;
|
||||
}
|
||||
|
||||
u16 Options_GetFrame(struct Options * options) {
|
||||
u16 Options_GetFrame(struct Options *options) {
|
||||
return options->frame;
|
||||
}
|
||||
|
||||
void Options_SetFrame(struct Options * options, u16 frame) {
|
||||
void Options_SetFrame(struct Options *options, u16 frame) {
|
||||
options->frame = (u16)(u32)frame;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,76 +1,69 @@
|
|||
#include "global.h"
|
||||
#include "main.h"
|
||||
#include "poke_overlay.h"
|
||||
#include "heap.h"
|
||||
#include "overlay_manager.h"
|
||||
|
||||
struct OverlayManager * OverlayManager_New(const struct OverlayManagerTemplate *template, s32 * a1, HeapID heapId)
|
||||
{
|
||||
struct OverlayManager * ret = (struct OverlayManager *)AllocFromHeap(heapId, sizeof(struct OverlayManager));
|
||||
ret->template = *template;
|
||||
ret->managerStatus = 0;
|
||||
ret->overlayStatus = 0;
|
||||
ret->unk18 = a1;
|
||||
ret->data = NULL;
|
||||
ret->save = NULL;
|
||||
ret->unk24 = 0;
|
||||
#include "global.h"
|
||||
|
||||
#include "heap.h"
|
||||
#include "main.h"
|
||||
#include "poke_overlay.h"
|
||||
|
||||
struct OverlayManager *OverlayManager_New(const struct OverlayManagerTemplate *template, s32 *a1, HeapID heapId) {
|
||||
struct OverlayManager *ret = (struct OverlayManager *)AllocFromHeap(heapId, sizeof(struct OverlayManager));
|
||||
ret->template = *template;
|
||||
ret->managerStatus = 0;
|
||||
ret->overlayStatus = 0;
|
||||
ret->unk18 = a1;
|
||||
ret->data = NULL;
|
||||
ret->save = NULL;
|
||||
ret->unk24 = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void OverlayManager_Delete(struct OverlayManager * overlayManager)
|
||||
{
|
||||
void OverlayManager_Delete(struct OverlayManager *overlayManager) {
|
||||
FreeToHeap(overlayManager);
|
||||
}
|
||||
|
||||
void * OverlayManager_CreateAndGetData(struct OverlayManager * overlayManager, u32 size, HeapID heapId)
|
||||
{
|
||||
void *OverlayManager_CreateAndGetData(struct OverlayManager *overlayManager, u32 size, HeapID heapId) {
|
||||
return overlayManager->data = AllocFromHeap(heapId, size);
|
||||
}
|
||||
|
||||
void * OverlayManager_GetData(struct OverlayManager * overlayManager)
|
||||
{
|
||||
void *OverlayManager_GetData(struct OverlayManager *overlayManager) {
|
||||
return overlayManager->data;
|
||||
}
|
||||
|
||||
void OverlayManager_FreeData(struct OverlayManager * overlayManager)
|
||||
{
|
||||
void OverlayManager_FreeData(struct OverlayManager *overlayManager) {
|
||||
FreeToHeap(overlayManager->data);
|
||||
overlayManager->data = NULL;
|
||||
}
|
||||
|
||||
s32 * OverlayManager_GetField18(struct OverlayManager * overlayManager)
|
||||
{
|
||||
s32 *OverlayManager_GetField18(struct OverlayManager *overlayManager) {
|
||||
return overlayManager->unk18;
|
||||
}
|
||||
|
||||
BOOL OverlayManager_Run(struct OverlayManager * overlayManager)
|
||||
{
|
||||
switch (overlayManager->managerStatus)
|
||||
{
|
||||
BOOL OverlayManager_Run(struct OverlayManager *overlayManager) {
|
||||
switch (overlayManager->managerStatus) {
|
||||
case 0:
|
||||
if (overlayManager->template.ovly != SDK_OVERLAY_INVALID_ID)
|
||||
if (overlayManager->template.ovly != SDK_OVERLAY_INVALID_ID) {
|
||||
HandleLoadOverlay(overlayManager->template.ovly, 2);
|
||||
}
|
||||
overlayManager->managerStatus = 1;
|
||||
// fallthrough
|
||||
case 1:
|
||||
if (overlayManager->template.initFunc(overlayManager, &overlayManager->overlayStatus) == TRUE)
|
||||
{
|
||||
if (overlayManager->template.initFunc(overlayManager, &overlayManager->overlayStatus) == TRUE) {
|
||||
overlayManager->managerStatus = 2;
|
||||
overlayManager->overlayStatus = 0;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (overlayManager->template.mainFunc(overlayManager, &overlayManager->overlayStatus) == TRUE)
|
||||
{
|
||||
if (overlayManager->template.mainFunc(overlayManager, &overlayManager->overlayStatus) == TRUE) {
|
||||
overlayManager->managerStatus = 3;
|
||||
overlayManager->overlayStatus = 0;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (overlayManager->template.exitFunc(overlayManager, &overlayManager->overlayStatus) == TRUE)
|
||||
{
|
||||
if (overlayManager->template.ovly != SDK_OVERLAY_INVALID_ID)
|
||||
if (overlayManager->template.exitFunc(overlayManager, &overlayManager->overlayStatus) == TRUE) {
|
||||
if (overlayManager->template.ovly != SDK_OVERLAY_INVALID_ID) {
|
||||
UnloadOverlayByID(overlayManager->template.ovly);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -1,50 +1,46 @@
|
|||
#include "global.h"
|
||||
#include "MSL.h"
|
||||
#include "palette.h"
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "MI_memory.h"
|
||||
#include "MSL.h"
|
||||
#include "gf_gfx_loader.h"
|
||||
#include "unk_0200CA44.h"
|
||||
#include "unk_020222E8.h"
|
||||
|
||||
struct PaletteData *sub_02002FD0(HeapID heapId)
|
||||
{
|
||||
struct PaletteData *sub_02002FD0(HeapID heapId) {
|
||||
struct PaletteData *ptr = AllocFromHeap(heapId, sizeof(struct PaletteData));
|
||||
MI_CpuFill8(ptr, 0, sizeof(struct PaletteData));
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void sub_02002FEC(struct PaletteData *ptr)
|
||||
{
|
||||
void sub_02002FEC(struct PaletteData *ptr) {
|
||||
FreeToHeap(ptr);
|
||||
}
|
||||
|
||||
void PaletteData_SetBuffers(
|
||||
struct PaletteData *paletteData, u32 index, void *unfadedBuf, void *fadedBuf, u32 size)
|
||||
{
|
||||
struct PaletteData *paletteData, u32 index, void *unfadedBuf, void *fadedBuf, u32 size) {
|
||||
paletteData->pltt[index].unfadedBuf = unfadedBuf;
|
||||
paletteData->pltt[index].fadedBuf = fadedBuf;
|
||||
paletteData->pltt[index].bufSize = size;
|
||||
paletteData->pltt[index].fadedBuf = fadedBuf;
|
||||
paletteData->pltt[index].bufSize = size;
|
||||
}
|
||||
|
||||
void PaletteData_AllocBuffers(
|
||||
struct PaletteData *paletteData, u32 index, u32 size, HeapID heapId)
|
||||
{
|
||||
void *ptr = AllocFromHeap(heapId, size);
|
||||
struct PaletteData *paletteData, u32 index, u32 size, HeapID heapId) {
|
||||
void *ptr = AllocFromHeap(heapId, size);
|
||||
void *ptr2 = AllocFromHeap(heapId, size);
|
||||
|
||||
PaletteData_SetBuffers(paletteData, index, ptr, ptr2, size);
|
||||
}
|
||||
|
||||
void PaletteData_FreeBuffers(struct PaletteData *paletteData, u32 index)
|
||||
{
|
||||
void PaletteData_FreeBuffers(struct PaletteData *paletteData, u32 index) {
|
||||
FreeToHeap(paletteData->pltt[index].unfadedBuf);
|
||||
FreeToHeap(paletteData->pltt[index].fadedBuf);
|
||||
}
|
||||
|
||||
void PaletteData_LoadPalette(
|
||||
struct PaletteData *paletteData, const void *src, u32 index, u32 offset, u16 size)
|
||||
{
|
||||
struct PaletteData *paletteData, const void *src, u32 index, u32 offset, u16 size) {
|
||||
MIi_CpuCopy16(src, paletteData->pltt[index].unfadedBuf + offset, size);
|
||||
MIi_CpuCopy16(src, paletteData->pltt[index].fadedBuf + offset, size);
|
||||
}
|
||||
|
|
@ -56,15 +52,13 @@ void PaletteData_LoadFromNarc(struct PaletteData *paletteData,
|
|||
u32 index,
|
||||
u32 size,
|
||||
u16 offset,
|
||||
u16 param7)
|
||||
{
|
||||
u16 param7) {
|
||||
NNSG2dPaletteData *pltData;
|
||||
void *ptr = GfGfxLoader_GetPlttData(narcId, memberId, &pltData, heapId);
|
||||
|
||||
GF_ASSERT(ptr != NULL);
|
||||
|
||||
if (size == 0)
|
||||
{
|
||||
if (size == 0) {
|
||||
size = pltData->szByte;
|
||||
}
|
||||
|
||||
|
|
@ -80,48 +74,43 @@ void PaletteData_LoadNarc(struct PaletteData *paletteData,
|
|||
HeapID heapId,
|
||||
u32 index,
|
||||
u32 size,
|
||||
u16 offset)
|
||||
{
|
||||
u16 offset) {
|
||||
PaletteData_LoadFromNarc(paletteData, narcId, memberId, heapId, index, size, offset, 0);
|
||||
}
|
||||
|
||||
void sub_02003108(struct PaletteData *paletteData, u32 index, u16 offset, u32 size)
|
||||
{
|
||||
void sub_02003108(struct PaletteData *paletteData, u32 index, u16 offset, u32 size) {
|
||||
GF_ASSERT(offset * 2 + size <= paletteData->pltt[index].bufSize);
|
||||
|
||||
u16 *ptr;
|
||||
switch (index)
|
||||
{
|
||||
case 0:
|
||||
ptr = sub_020222E8();
|
||||
break;
|
||||
case 1:
|
||||
ptr = sub_020222F8();
|
||||
break;
|
||||
case 2:
|
||||
ptr = sub_02022308();
|
||||
break;
|
||||
case 3:
|
||||
ptr = sub_02022310();
|
||||
break;
|
||||
default:
|
||||
GF_ASSERT(FALSE);
|
||||
return;
|
||||
switch (index) {
|
||||
case 0:
|
||||
ptr = sub_020222E8();
|
||||
break;
|
||||
case 1:
|
||||
ptr = sub_020222F8();
|
||||
break;
|
||||
case 2:
|
||||
ptr = sub_02022308();
|
||||
break;
|
||||
case 3:
|
||||
ptr = sub_02022310();
|
||||
break;
|
||||
default:
|
||||
GF_ASSERT(FALSE);
|
||||
return;
|
||||
}
|
||||
|
||||
PaletteData_LoadPalette(paletteData, ptr + offset, index, offset, (u16)size);
|
||||
}
|
||||
|
||||
void CopyPaletteFromNarc(
|
||||
NarcId narcId, s32 memberId, HeapID heapId, u32 size, u16 offset, void *dest)
|
||||
{
|
||||
NarcId narcId, s32 memberId, HeapID heapId, u32 size, u16 offset, void *dest) {
|
||||
NNSG2dPaletteData *pltData;
|
||||
|
||||
void *ptr = GfGfxLoader_GetPlttData(narcId, memberId, &pltData, heapId);
|
||||
GF_ASSERT(ptr != NULL);
|
||||
|
||||
if (size == 0)
|
||||
{
|
||||
if (size == 0) {
|
||||
size = pltData->szByte;
|
||||
}
|
||||
|
||||
|
|
@ -135,8 +124,7 @@ void PaletteData_CopyPalette(struct PaletteData *paletteData,
|
|||
u16 srcOffset,
|
||||
u32 destIdx,
|
||||
u16 destOffset,
|
||||
u16 size)
|
||||
{
|
||||
u16 size) {
|
||||
|
||||
MI_CpuCopy16(paletteData->pltt[srcIdx].unfadedBuf + srcOffset,
|
||||
paletteData->pltt[destIdx].unfadedBuf + destOffset,
|
||||
|
|
@ -146,13 +134,11 @@ void PaletteData_CopyPalette(struct PaletteData *paletteData,
|
|||
size);
|
||||
}
|
||||
|
||||
u16 *PaletteData_GetUnfadedBuf(struct PaletteData *paletteData, u32 index)
|
||||
{
|
||||
u16 *PaletteData_GetUnfadedBuf(struct PaletteData *paletteData, u32 index) {
|
||||
return paletteData->pltt[index].unfadedBuf;
|
||||
}
|
||||
|
||||
u16 *PaletteData_GetFadedBuf(struct PaletteData *paletteData, u32 index)
|
||||
{
|
||||
u16 *PaletteData_GetFadedBuf(struct PaletteData *paletteData, u32 index) {
|
||||
return paletteData->pltt[index].fadedBuf;
|
||||
}
|
||||
|
||||
|
|
@ -162,21 +148,17 @@ u32 sub_02003210(struct PaletteData *paletteData,
|
|||
s16 delay,
|
||||
u8 startY,
|
||||
u8 targetY,
|
||||
u16 color)
|
||||
{
|
||||
u16 color) {
|
||||
|
||||
u16 stc = param2;
|
||||
u32 r6 = 0;
|
||||
u32 r6 = 0;
|
||||
|
||||
for (u8 i = 0; i < 14; i++)
|
||||
{
|
||||
if (IsPaletteSelected(param1, i) != 1)
|
||||
{
|
||||
for (u8 i = 0; i < 14; i++) {
|
||||
if (IsPaletteSelected(param1, i) != 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (IsPaletteSelected(paletteData->activeFadePalettes, i) != 0)
|
||||
{
|
||||
if (IsPaletteSelected(paletteData->activeFadePalettes, i) != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -186,28 +168,23 @@ u32 sub_02003210(struct PaletteData *paletteData,
|
|||
|
||||
sub_02003328(paletteData, i);
|
||||
|
||||
if (i >= 4)
|
||||
{
|
||||
if (i >= 4) {
|
||||
sub_0200359C(paletteData, i, 0x100);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
sub_0200359C(paletteData, i, 0x10);
|
||||
}
|
||||
|
||||
param2 = stc;
|
||||
r6 = 1;
|
||||
r6 = 1;
|
||||
}
|
||||
|
||||
if (r6 == 1)
|
||||
{
|
||||
if (r6 == 1) {
|
||||
paletteData->activeFadePalettes |= param1;
|
||||
if (paletteData->unk11a_e == 0)
|
||||
{
|
||||
if (paletteData->unk11a_e == 0) {
|
||||
paletteData->unk11a_e = 1;
|
||||
|
||||
paletteData->unk118_0 = 1;
|
||||
paletteData->unk11c = 0;
|
||||
paletteData->unk11c = 0;
|
||||
|
||||
SysTask_CreateOnMainQueue((SysTaskFunc)sub_02003464, (void *)paletteData, (u32)(-2));
|
||||
}
|
||||
|
|
@ -216,40 +193,31 @@ u32 sub_02003210(struct PaletteData *paletteData,
|
|||
return r6;
|
||||
}
|
||||
|
||||
u8 IsPaletteSelected(u16 selectedPalettes, u16 index)
|
||||
{
|
||||
u8 IsPaletteSelected(u16 selectedPalettes, u16 index) {
|
||||
u32 r3 = 1;
|
||||
if ((selectedPalettes & (1 << index)) == 0)
|
||||
{
|
||||
if ((selectedPalettes & (1 << index)) == 0) {
|
||||
r3 = 0;
|
||||
}
|
||||
|
||||
return (u8)r3;
|
||||
}
|
||||
|
||||
void sub_02003328(struct PaletteData *param0, u16 param1)
|
||||
{
|
||||
if (IsPaletteSelected(param0->unk11a_0, param1) != 1)
|
||||
{
|
||||
void sub_02003328(struct PaletteData *param0, u16 param1) {
|
||||
if (IsPaletteSelected(param0->unk11a_0, param1) != 1) {
|
||||
param0->unk11a_0 |= 1 << param1;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_02003368(s32 param0, struct Palette *param1, u16 *param2)
|
||||
{
|
||||
void sub_02003368(s32 param0, struct Palette *param1, u16 *param2) {
|
||||
u8 r0;
|
||||
if (param0 < 4)
|
||||
{
|
||||
if (param0 < 4) {
|
||||
r0 = (u8)(param1->bufSize >> 5);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
r0 = (u8)(param1->bufSize >> 9);
|
||||
}
|
||||
|
||||
u16 r4 = 0;
|
||||
for (u8 i = 0; i < r0; i++)
|
||||
{
|
||||
for (u8 i = 0; i < r0; i++) {
|
||||
r4 += 1 << i;
|
||||
}
|
||||
|
||||
|
|
@ -261,83 +229,66 @@ void sub_020033A4(struct PaletteFadeControl *paletteFade,
|
|||
s16 delay,
|
||||
u8 startY,
|
||||
u8 targetY,
|
||||
u16 color)
|
||||
{
|
||||
if (delay < 0)
|
||||
{
|
||||
u16 color) {
|
||||
if (delay < 0) {
|
||||
paletteFade->deltaY = abs(delay) + 2;
|
||||
paletteFade->delay = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
paletteFade->delay = 0;
|
||||
} else {
|
||||
paletteFade->deltaY = 2;
|
||||
paletteFade->delay = delay;
|
||||
paletteFade->delay = delay;
|
||||
}
|
||||
|
||||
paletteFade->selectedPalettes = selectedPalettes;
|
||||
paletteFade->y = startY;
|
||||
paletteFade->targetY = targetY;
|
||||
paletteFade->blendColor = color;
|
||||
paletteFade->y = startY;
|
||||
paletteFade->targetY = targetY;
|
||||
paletteFade->blendColor = color;
|
||||
|
||||
paletteFade->delayCounter = paletteFade->delay;
|
||||
|
||||
if (startY < targetY)
|
||||
{
|
||||
if (startY < targetY) {
|
||||
paletteFade->yDec = 0;
|
||||
return;
|
||||
}
|
||||
paletteFade->yDec = 1;
|
||||
}
|
||||
|
||||
void sub_02003464(SysTask *task, struct PaletteData *param1)
|
||||
{
|
||||
if (param1->unk11c == 1)
|
||||
{
|
||||
param1->unk11c = 0;
|
||||
param1->unk11a_0 = 0;
|
||||
void sub_02003464(SysTask *task, struct PaletteData *param1) {
|
||||
if (param1->unk11c == 1) {
|
||||
param1->unk11c = 0;
|
||||
param1->unk11a_0 = 0;
|
||||
param1->activeFadePalettes = 0;
|
||||
param1->unk11a_e = 0;
|
||||
param1->unk11a_e = 0;
|
||||
sub_0200CAB4((s32)task);
|
||||
return;
|
||||
}
|
||||
|
||||
if (param1->unk118_0 == 1)
|
||||
{
|
||||
if (param1->unk118_0 == 1) {
|
||||
param1->unk11a_0 = param1->activeFadePalettes;
|
||||
sub_02003500(param1);
|
||||
sub_02003520(param1);
|
||||
|
||||
if (param1->activeFadePalettes == 0)
|
||||
{
|
||||
if (param1->activeFadePalettes == 0) {
|
||||
param1->unk11a_e = 0;
|
||||
sub_0200CAB4((s32)task);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sub_02003500(struct PaletteData *param0)
|
||||
{
|
||||
for (u8 i = 0; i < 4; i++)
|
||||
{
|
||||
void sub_02003500(struct PaletteData *param0) {
|
||||
for (u8 i = 0; i < 4; i++) {
|
||||
sub_02003540(param0, i, 0x10);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_02003520(struct PaletteData *param0)
|
||||
{
|
||||
for (u8 i = 4; i < 14; i++)
|
||||
{
|
||||
void sub_02003520(struct PaletteData *param0) {
|
||||
for (u8 i = 4; i < 14; i++) {
|
||||
sub_02003540(param0, i, 0x100);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_02003540(struct PaletteData *paletteData, u8 index, u32 param2)
|
||||
{
|
||||
if (IsPaletteSelected(paletteData->activeFadePalettes, index) != 0)
|
||||
{
|
||||
if (paletteData->pltt[index].fadeCtrl.delayCounter <
|
||||
paletteData->pltt[index].fadeCtrl.delay)
|
||||
{
|
||||
void sub_02003540(struct PaletteData *paletteData, u8 index, u32 param2) {
|
||||
if (IsPaletteSelected(paletteData->activeFadePalettes, index) != 0) {
|
||||
if (paletteData->pltt[index].fadeCtrl.delayCounter < paletteData->pltt[index].fadeCtrl.delay) {
|
||||
paletteData->pltt[index].fadeCtrl.delayCounter++;
|
||||
return;
|
||||
}
|
||||
|
|
@ -347,13 +298,10 @@ void sub_02003540(struct PaletteData *paletteData, u8 index, u32 param2)
|
|||
}
|
||||
}
|
||||
|
||||
void sub_0200359C(struct PaletteData *paletteData, u32 index, u32 param2)
|
||||
{
|
||||
void sub_0200359C(struct PaletteData *paletteData, u32 index, u32 param2) {
|
||||
|
||||
for (u32 i = 0; i < 0x10; i++)
|
||||
{
|
||||
if (IsPaletteSelected(paletteData->pltt[index].fadeCtrl.selectedPalettes, (u16)i) != 0)
|
||||
{
|
||||
for (u32 i = 0; i < 0x10; i++) {
|
||||
if (IsPaletteSelected(paletteData->pltt[index].fadeCtrl.selectedPalettes, (u16)i) != 0) {
|
||||
sub_020035F8(paletteData->pltt[index].unfadedBuf + param2 * i,
|
||||
paletteData->pltt[index].fadedBuf + param2 * i,
|
||||
&paletteData->pltt[index].fadeCtrl,
|
||||
|
|
@ -365,33 +313,21 @@ void sub_0200359C(struct PaletteData *paletteData, u32 index, u32 param2)
|
|||
}
|
||||
|
||||
void sub_020035F8(
|
||||
u16 *src, u16 *dest, struct PaletteFadeControl *fadeCtrl, u32 numEntries)
|
||||
{
|
||||
for (u32 i = 0; i < numEntries; i++)
|
||||
{
|
||||
u8 lo = (u8)((src[i] & 0x1f) +
|
||||
((((fadeCtrl->blendColor & 0x1f) - (src[i] & 0x1f)) * fadeCtrl->y) >> 4));
|
||||
u16 *src, u16 *dest, struct PaletteFadeControl *fadeCtrl, u32 numEntries) {
|
||||
for (u32 i = 0; i < numEntries; i++) {
|
||||
u8 lo = (u8)((src[i] & 0x1f) + ((((fadeCtrl->blendColor & 0x1f) - (src[i] & 0x1f)) * fadeCtrl->y) >> 4));
|
||||
|
||||
u8 hi = (u8)(((src[i] >> 10) & 0x1f) +
|
||||
(((((fadeCtrl->blendColor >> 10) & 0x1f) - ((src[i] >> 10) & 0x1f)) *
|
||||
fadeCtrl->y) >>
|
||||
4));
|
||||
u8 mid =
|
||||
(u8)(((src[i] >> 5) & 0x1f) +
|
||||
(((((fadeCtrl->blendColor >> 5) & 0x1f) - ((src[i] >> 5) & 0x1f)) * fadeCtrl->y) >>
|
||||
4));
|
||||
u8 hi = (u8)(((src[i] >> 10) & 0x1f) + (((((fadeCtrl->blendColor >> 10) & 0x1f) - ((src[i] >> 10) & 0x1f)) * fadeCtrl->y) >> 4));
|
||||
u8 mid = (u8)(((src[i] >> 5) & 0x1f) + (((((fadeCtrl->blendColor >> 5) & 0x1f) - ((src[i] >> 5) & 0x1f)) * fadeCtrl->y) >> 4));
|
||||
|
||||
dest[i] = (u16)((hi << 10) | (mid << 5) | lo);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_02003684(
|
||||
struct PaletteData *paletteData, u8 index, struct PaletteFadeControl *fadeCtrl)
|
||||
{
|
||||
if (fadeCtrl->y == fadeCtrl->targetY)
|
||||
{
|
||||
if ((paletteData->activeFadePalettes & (1 << index)) == 0)
|
||||
{
|
||||
struct PaletteData *paletteData, u8 index, struct PaletteFadeControl *fadeCtrl) {
|
||||
if (fadeCtrl->y == fadeCtrl->targetY) {
|
||||
if ((paletteData->activeFadePalettes & (1 << index)) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -401,12 +337,10 @@ void sub_02003684(
|
|||
}
|
||||
|
||||
s16 val;
|
||||
if (fadeCtrl->yDec == 0)
|
||||
{
|
||||
if (fadeCtrl->yDec == 0) {
|
||||
val = (s16)fadeCtrl->y;
|
||||
val += fadeCtrl->deltaY;
|
||||
if (val > fadeCtrl->targetY)
|
||||
{
|
||||
if (val > fadeCtrl->targetY) {
|
||||
val = (s16)fadeCtrl->targetY;
|
||||
}
|
||||
|
||||
|
|
@ -416,121 +350,110 @@ void sub_02003684(
|
|||
|
||||
val = (s16)fadeCtrl->y;
|
||||
val -= fadeCtrl->deltaY;
|
||||
if (val < fadeCtrl->targetY)
|
||||
{
|
||||
if (val < fadeCtrl->targetY) {
|
||||
val = (s16)fadeCtrl->targetY;
|
||||
}
|
||||
|
||||
fadeCtrl->y = val;
|
||||
}
|
||||
|
||||
void sub_0200372C(struct PaletteData *paletteData)
|
||||
{
|
||||
if (paletteData->unk11a_f == 0 && paletteData->unk118_0 != 1)
|
||||
{
|
||||
void sub_0200372C(struct PaletteData *paletteData) {
|
||||
if (paletteData->unk11a_f == 0 && paletteData->unk118_0 != 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (s32 i = 0; i < 14; i++)
|
||||
{
|
||||
if (paletteData->unk11a_f != 0 ||
|
||||
(paletteData->pltt[i].fadedBuf != 0 &&
|
||||
IsPaletteSelected(paletteData->unk11a_0, (u16)i) != 0))
|
||||
{
|
||||
for (s32 i = 0; i < 14; i++) {
|
||||
if (paletteData->unk11a_f != 0 || (paletteData->pltt[i].fadedBuf != 0 && IsPaletteSelected(paletteData->unk11a_0, (u16)i) != 0)) {
|
||||
DC_FlushRange(paletteData->pltt[i].fadedBuf, paletteData->pltt[i].bufSize);
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
GX_LoadBGPltt(paletteData->pltt[i].fadedBuf, 0, paletteData->pltt[i].bufSize);
|
||||
break;
|
||||
case 1:
|
||||
GXS_LoadBGPltt(paletteData->pltt[i].fadedBuf, 0, paletteData->pltt[i].bufSize);
|
||||
break;
|
||||
case 2:
|
||||
GX_LoadOBJPltt(paletteData->pltt[i].fadedBuf, 0, paletteData->pltt[i].bufSize);
|
||||
break;
|
||||
case 3:
|
||||
GXS_LoadOBJPltt(paletteData->pltt[i].fadedBuf, 0, paletteData->pltt[i].bufSize);
|
||||
break;
|
||||
case 4:
|
||||
GX_BeginLoadBGExtPltt();
|
||||
GX_LoadBGExtPltt(
|
||||
paletteData->pltt[i].fadedBuf, 0, paletteData->pltt[i].bufSize);
|
||||
GX_EndLoadBGExtPltt();
|
||||
break;
|
||||
case 5:
|
||||
GX_BeginLoadBGExtPltt();
|
||||
GX_LoadBGExtPltt(
|
||||
paletteData->pltt[i].fadedBuf, 0x2000, paletteData->pltt[i].bufSize);
|
||||
GX_EndLoadBGExtPltt();
|
||||
break;
|
||||
case 6:
|
||||
GX_BeginLoadBGExtPltt();
|
||||
GX_LoadBGExtPltt(
|
||||
paletteData->pltt[i].fadedBuf, 0x4000, paletteData->pltt[i].bufSize);
|
||||
GX_EndLoadBGExtPltt();
|
||||
break;
|
||||
case 7:
|
||||
GX_BeginLoadBGExtPltt();
|
||||
GX_LoadBGExtPltt(
|
||||
paletteData->pltt[i].fadedBuf, 0x6000, paletteData->pltt[i].bufSize);
|
||||
GX_EndLoadBGExtPltt();
|
||||
break;
|
||||
case 8:
|
||||
GXS_BeginLoadBGExtPltt();
|
||||
GXS_LoadBGExtPltt(
|
||||
paletteData->pltt[i].fadedBuf, 0, paletteData->pltt[i].bufSize);
|
||||
GXS_EndLoadBGExtPltt();
|
||||
break;
|
||||
case 9:
|
||||
GXS_BeginLoadBGExtPltt();
|
||||
GXS_LoadBGExtPltt(
|
||||
paletteData->pltt[i].fadedBuf, 0x2000, paletteData->pltt[i].bufSize);
|
||||
GXS_EndLoadBGExtPltt();
|
||||
break;
|
||||
case 10:
|
||||
GXS_BeginLoadBGExtPltt();
|
||||
GXS_LoadBGExtPltt(
|
||||
paletteData->pltt[i].fadedBuf, 0x4000, paletteData->pltt[i].bufSize);
|
||||
GXS_EndLoadBGExtPltt();
|
||||
break;
|
||||
case 11:
|
||||
GXS_BeginLoadBGExtPltt();
|
||||
GXS_LoadBGExtPltt(
|
||||
paletteData->pltt[i].fadedBuf, 0x6000, paletteData->pltt[i].bufSize);
|
||||
GXS_EndLoadBGExtPltt();
|
||||
break;
|
||||
case 12:
|
||||
GX_BeginLoadOBJExtPltt();
|
||||
GX_LoadOBJExtPltt(
|
||||
paletteData->pltt[i].fadedBuf, 0, paletteData->pltt[i].bufSize);
|
||||
GX_EndLoadOBJExtPltt();
|
||||
break;
|
||||
case 13:
|
||||
GXS_BeginLoadOBJExtPltt();
|
||||
GXS_LoadOBJExtPltt(
|
||||
paletteData->pltt[i].fadedBuf, 0, paletteData->pltt[i].bufSize);
|
||||
GXS_EndLoadOBJExtPltt();
|
||||
break;
|
||||
switch (i) {
|
||||
case 0:
|
||||
GX_LoadBGPltt(paletteData->pltt[i].fadedBuf, 0, paletteData->pltt[i].bufSize);
|
||||
break;
|
||||
case 1:
|
||||
GXS_LoadBGPltt(paletteData->pltt[i].fadedBuf, 0, paletteData->pltt[i].bufSize);
|
||||
break;
|
||||
case 2:
|
||||
GX_LoadOBJPltt(paletteData->pltt[i].fadedBuf, 0, paletteData->pltt[i].bufSize);
|
||||
break;
|
||||
case 3:
|
||||
GXS_LoadOBJPltt(paletteData->pltt[i].fadedBuf, 0, paletteData->pltt[i].bufSize);
|
||||
break;
|
||||
case 4:
|
||||
GX_BeginLoadBGExtPltt();
|
||||
GX_LoadBGExtPltt(
|
||||
paletteData->pltt[i].fadedBuf, 0, paletteData->pltt[i].bufSize);
|
||||
GX_EndLoadBGExtPltt();
|
||||
break;
|
||||
case 5:
|
||||
GX_BeginLoadBGExtPltt();
|
||||
GX_LoadBGExtPltt(
|
||||
paletteData->pltt[i].fadedBuf, 0x2000, paletteData->pltt[i].bufSize);
|
||||
GX_EndLoadBGExtPltt();
|
||||
break;
|
||||
case 6:
|
||||
GX_BeginLoadBGExtPltt();
|
||||
GX_LoadBGExtPltt(
|
||||
paletteData->pltt[i].fadedBuf, 0x4000, paletteData->pltt[i].bufSize);
|
||||
GX_EndLoadBGExtPltt();
|
||||
break;
|
||||
case 7:
|
||||
GX_BeginLoadBGExtPltt();
|
||||
GX_LoadBGExtPltt(
|
||||
paletteData->pltt[i].fadedBuf, 0x6000, paletteData->pltt[i].bufSize);
|
||||
GX_EndLoadBGExtPltt();
|
||||
break;
|
||||
case 8:
|
||||
GXS_BeginLoadBGExtPltt();
|
||||
GXS_LoadBGExtPltt(
|
||||
paletteData->pltt[i].fadedBuf, 0, paletteData->pltt[i].bufSize);
|
||||
GXS_EndLoadBGExtPltt();
|
||||
break;
|
||||
case 9:
|
||||
GXS_BeginLoadBGExtPltt();
|
||||
GXS_LoadBGExtPltt(
|
||||
paletteData->pltt[i].fadedBuf, 0x2000, paletteData->pltt[i].bufSize);
|
||||
GXS_EndLoadBGExtPltt();
|
||||
break;
|
||||
case 10:
|
||||
GXS_BeginLoadBGExtPltt();
|
||||
GXS_LoadBGExtPltt(
|
||||
paletteData->pltt[i].fadedBuf, 0x4000, paletteData->pltt[i].bufSize);
|
||||
GXS_EndLoadBGExtPltt();
|
||||
break;
|
||||
case 11:
|
||||
GXS_BeginLoadBGExtPltt();
|
||||
GXS_LoadBGExtPltt(
|
||||
paletteData->pltt[i].fadedBuf, 0x6000, paletteData->pltt[i].bufSize);
|
||||
GXS_EndLoadBGExtPltt();
|
||||
break;
|
||||
case 12:
|
||||
GX_BeginLoadOBJExtPltt();
|
||||
GX_LoadOBJExtPltt(
|
||||
paletteData->pltt[i].fadedBuf, 0, paletteData->pltt[i].bufSize);
|
||||
GX_EndLoadOBJExtPltt();
|
||||
break;
|
||||
case 13:
|
||||
GXS_BeginLoadOBJExtPltt();
|
||||
GXS_LoadOBJExtPltt(
|
||||
paletteData->pltt[i].fadedBuf, 0, paletteData->pltt[i].bufSize);
|
||||
GXS_EndLoadOBJExtPltt();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
paletteData->unk11a_0 = paletteData->activeFadePalettes;
|
||||
if (paletteData->unk11a_0 == 0)
|
||||
{
|
||||
if (paletteData->unk11a_0 == 0) {
|
||||
paletteData->unk118_0 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
u16 sub_020038E4(struct PaletteData *paletteData)
|
||||
{
|
||||
u16 sub_020038E4(struct PaletteData *paletteData) {
|
||||
return paletteData->activeFadePalettes;
|
||||
}
|
||||
|
||||
void sub_020038F0(struct PaletteData *paletteData, u32 param1)
|
||||
{
|
||||
void sub_020038F0(struct PaletteData *paletteData, u32 param1) {
|
||||
paletteData->unk11a_f = param1;
|
||||
}
|
||||
|
||||
|
|
@ -539,38 +462,31 @@ void PaletteData_FillPalette(struct PaletteData *paletteData,
|
|||
u32 selection,
|
||||
u16 value,
|
||||
u16 startOffset,
|
||||
u16 endOffset)
|
||||
{
|
||||
u16 endOffset) {
|
||||
GF_ASSERT(endOffset * 2 <= paletteData->pltt[index].bufSize);
|
||||
if (selection == 1 || selection == 2)
|
||||
{
|
||||
if (selection == 1 || selection == 2) {
|
||||
MI_CpuFill16(&paletteData->pltt[index].unfadedBuf[startOffset],
|
||||
value,
|
||||
(u32)((endOffset - startOffset) * 2));
|
||||
}
|
||||
|
||||
if (selection == 0 || selection == 2)
|
||||
{
|
||||
if (selection == 0 || selection == 2) {
|
||||
MI_CpuFill16(&paletteData->pltt[index].fadedBuf[startOffset],
|
||||
value,
|
||||
(u32)((endOffset - startOffset) * 2));
|
||||
}
|
||||
}
|
||||
|
||||
void BlendPalette(u16 *src, u16 *dest, u16 numEntries, u8 coeff, u16 blendColor)
|
||||
{
|
||||
void BlendPalette(u16 *src, u16 *dest, u16 numEntries, u8 coeff, u16 blendColor) {
|
||||
s32 r2 = ((struct PlttData *)&blendColor)->r;
|
||||
s32 g2 = ((struct PlttData *)&blendColor)->g;
|
||||
s32 b2 = ((struct PlttData *)&blendColor)->b;
|
||||
for (u16 i = 0; i < numEntries; i++)
|
||||
{
|
||||
for (u16 i = 0; i < numEntries; i++) {
|
||||
s32 r = ((struct PlttData *)&src[i])->r;
|
||||
s32 g = ((struct PlttData *)&src[i])->g;
|
||||
s32 b = ((struct PlttData *)&src[i])->b;
|
||||
|
||||
dest[i] =
|
||||
(u16)(((r + (((r2 - r) * coeff) >> 4)) << 0) | ((g + (((g2 - g) * coeff) >> 4)) << 5) |
|
||||
((b + (((b2 - b) * coeff) >> 4)) << 10));
|
||||
dest[i] = (u16)(((r + (((r2 - r) * coeff) >> 4)) << 0) | ((g + (((g2 - g) * coeff) >> 4)) << 5) | ((b + (((b2 - b) * coeff) >> 4)) << 10));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -579,11 +495,9 @@ void BlendPaletteUnfaded(struct PaletteData *paletteData,
|
|||
u16 offset,
|
||||
u16 numEntries,
|
||||
u8 coeff,
|
||||
u16 blendColor)
|
||||
{
|
||||
u16 blendColor) {
|
||||
BOOL r0 = FALSE;
|
||||
if (paletteData->pltt[index].unfadedBuf != 0 && paletteData->pltt[index].fadedBuf != 0)
|
||||
{
|
||||
if (paletteData->pltt[index].unfadedBuf != 0 && paletteData->pltt[index].fadedBuf != 0) {
|
||||
r0 = TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -596,12 +510,9 @@ void BlendPaletteUnfaded(struct PaletteData *paletteData,
|
|||
blendColor);
|
||||
}
|
||||
|
||||
void BlendPalettes(u16 *src, u16 *dest, u16 selectedPalettes, u8 coeff, u16 blendColor)
|
||||
{
|
||||
while (selectedPalettes != 0)
|
||||
{
|
||||
if ((selectedPalettes & 1) != 0)
|
||||
{
|
||||
void BlendPalettes(u16 *src, u16 *dest, u16 selectedPalettes, u8 coeff, u16 blendColor) {
|
||||
while (selectedPalettes != 0) {
|
||||
if ((selectedPalettes & 1) != 0) {
|
||||
BlendPalette(src, dest, 0x10, coeff, blendColor);
|
||||
}
|
||||
|
||||
|
|
@ -612,21 +523,17 @@ void BlendPalettes(u16 *src, u16 *dest, u16 selectedPalettes, u8 coeff, u16 blen
|
|||
}
|
||||
|
||||
void BlendPalettesUnfaded(
|
||||
struct PaletteData *paletteData, u32 index, u16 selectedPalettes, u8 coeff, u16 blendColor)
|
||||
{
|
||||
u32 r4 = 0;
|
||||
struct PaletteData *paletteData, u32 index, u16 selectedPalettes, u8 coeff, u16 blendColor) {
|
||||
u32 r4 = 0;
|
||||
BOOL r0 = FALSE;
|
||||
if (paletteData->pltt[index].unfadedBuf != 0 && paletteData->pltt[index].fadedBuf != 0)
|
||||
{
|
||||
if (paletteData->pltt[index].unfadedBuf != 0 && paletteData->pltt[index].fadedBuf != 0) {
|
||||
r0 = TRUE;
|
||||
}
|
||||
|
||||
GF_ASSERT(r0);
|
||||
|
||||
while (selectedPalettes != 0)
|
||||
{
|
||||
if ((selectedPalettes & 1) != 0)
|
||||
{
|
||||
while (selectedPalettes != 0) {
|
||||
if ((selectedPalettes & 1) != 0) {
|
||||
BlendPaletteUnfaded(paletteData, index, (u16)r4, 0x10, coeff, blendColor);
|
||||
}
|
||||
|
||||
|
|
@ -635,29 +542,30 @@ void BlendPalettesUnfaded(
|
|||
}
|
||||
}
|
||||
|
||||
void TintPalette_CustomTone(u16 *palette, s32 count, s32 rTone, s32 gTone, s32 bTone)
|
||||
{
|
||||
void TintPalette_CustomTone(u16 *palette, s32 count, s32 rTone, s32 gTone, s32 bTone) {
|
||||
s32 r, g, b, i;
|
||||
u32 gray;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
for (i = 0; i < count; i++) {
|
||||
r = (*palette >> 0) & 0x1F;
|
||||
g = (*palette >> 5) & 0x1F;
|
||||
b = (*palette >> 10) & 0x1F;
|
||||
|
||||
gray = (u32)((r * 76 + g * 151 + b * 29) >> 8);
|
||||
|
||||
r = (u16)((rTone * gray)) >> 8;
|
||||
g = (u16)((gTone * gray)) >> 8;
|
||||
b = (u16)((bTone * gray)) >> 8;
|
||||
r = (u16)(rTone * gray) >> 8;
|
||||
g = (u16)(gTone * gray) >> 8;
|
||||
b = (u16)(bTone * gray) >> 8;
|
||||
|
||||
if (r > 31)
|
||||
if (r > 31) {
|
||||
r = 31;
|
||||
if (g > 31)
|
||||
}
|
||||
if (g > 31) {
|
||||
g = 31;
|
||||
if (b > 31)
|
||||
}
|
||||
if (b > 31) {
|
||||
b = 31;
|
||||
}
|
||||
|
||||
*palette++ = (u16)((b << 10) | (g << 5) | (r << 0));
|
||||
}
|
||||
|
|
@ -672,14 +580,12 @@ void sub_02003B40(struct PaletteData *paletteData,
|
|||
u16 offset,
|
||||
s32 rTone,
|
||||
s32 gTone,
|
||||
s32 bTone)
|
||||
{
|
||||
s32 bTone) {
|
||||
NNSG2dPaletteData *pltData;
|
||||
void *ptr = GfGfxLoader_GetPlttData(narcId, memberId, &pltData, heapId);
|
||||
GF_ASSERT(ptr != NULL);
|
||||
|
||||
if (size == 0)
|
||||
{
|
||||
if (size == 0) {
|
||||
size = pltData->szByte;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,49 +1,47 @@
|
|||
#include "global.h"
|
||||
#include "party.h"
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "heap.h"
|
||||
|
||||
void SaveArray_Party_Init(struct Party * party);
|
||||
void Party_InitWithMaxSize(struct Party * party, int count);
|
||||
void SaveArray_Party_Init(struct Party *party);
|
||||
void Party_InitWithMaxSize(struct Party *party, int count);
|
||||
|
||||
u32 SaveArray_Party_sizeof(void)
|
||||
{
|
||||
u32 SaveArray_Party_sizeof(void) {
|
||||
return sizeof(struct Party);
|
||||
}
|
||||
|
||||
struct Party * SaveArray_Party_Alloc(HeapID heapId)
|
||||
{
|
||||
struct Party * ret = (struct Party *)AllocFromHeap(heapId, sizeof(struct Party));
|
||||
struct Party *SaveArray_Party_Alloc(HeapID heapId) {
|
||||
struct Party *ret = (struct Party *)AllocFromHeap(heapId, sizeof(struct Party));
|
||||
SaveArray_Party_Init(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void SaveArray_Party_Init(struct Party * party)
|
||||
{
|
||||
void SaveArray_Party_Init(struct Party *party) {
|
||||
Party_InitWithMaxSize(party, PARTY_SIZE);
|
||||
}
|
||||
|
||||
void Party_InitWithMaxSize(struct Party * party, int count)
|
||||
{
|
||||
void Party_InitWithMaxSize(struct Party *party, int count) {
|
||||
int i;
|
||||
GF_ASSERT(count <= PARTY_SIZE);
|
||||
memset(party, 0, sizeof(struct Party));
|
||||
party->curCount = 0;
|
||||
party->maxCount = count;
|
||||
for (i = 0; i < PARTY_SIZE; i++)
|
||||
for (i = 0; i < PARTY_SIZE; i++) {
|
||||
ZeroMonData(&party->mons[i]);
|
||||
}
|
||||
}
|
||||
|
||||
BOOL Party_AddMon(struct Party * party, struct Pokemon * pokemon)
|
||||
{
|
||||
if (party->curCount >= party->maxCount)
|
||||
BOOL Party_AddMon(struct Party *party, struct Pokemon *pokemon) {
|
||||
if (party->curCount >= party->maxCount) {
|
||||
return FALSE;
|
||||
}
|
||||
party->mons[party->curCount] = *pokemon;
|
||||
party->curCount++;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL Party_RemoveMon(struct Party * party, int pos)
|
||||
{
|
||||
BOOL Party_RemoveMon(struct Party *party, int pos) {
|
||||
int i;
|
||||
|
||||
GF_ASSERT(pos >= 0);
|
||||
|
|
@ -51,8 +49,7 @@ BOOL Party_RemoveMon(struct Party * party, int pos)
|
|||
GF_ASSERT(pos < party->maxCount);
|
||||
GF_ASSERT(party->curCount > 0);
|
||||
|
||||
for (i = pos; i < party->curCount - 1; i++)
|
||||
{
|
||||
for (i = pos; i < party->curCount - 1; i++) {
|
||||
party->mons[i] = party->mons[i + 1];
|
||||
}
|
||||
|
||||
|
|
@ -61,64 +58,57 @@ BOOL Party_RemoveMon(struct Party * party, int pos)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
int Party_GetCount(struct Party * party)
|
||||
{
|
||||
int Party_GetCount(struct Party *party) {
|
||||
return party->curCount;
|
||||
}
|
||||
|
||||
struct Pokemon * Party_GetMonByIndex(struct Party * party, int pos)
|
||||
{
|
||||
struct Pokemon *Party_GetMonByIndex(struct Party *party, int pos) {
|
||||
GF_ASSERT(pos >= 0);
|
||||
GF_ASSERT(pos < party->curCount);
|
||||
GF_ASSERT(pos < party->maxCount);
|
||||
return &party->mons[pos];
|
||||
}
|
||||
|
||||
void ReplacePartySlotWithMon(struct Party * party, int pos, struct Pokemon * pokemon)
|
||||
{
|
||||
void ReplacePartySlotWithMon(struct Party *party, int pos, struct Pokemon *pokemon) {
|
||||
int r2;
|
||||
GF_ASSERT(pos >= 0);
|
||||
GF_ASSERT(pos < party->curCount);
|
||||
GF_ASSERT(pos < party->maxCount);
|
||||
r2 = (int)(GetMonData(&party->mons[pos], MON_DATA_SPECIES_EXISTS, NULL) - GetMonData(pokemon, MON_DATA_SPECIES_EXISTS, NULL));
|
||||
r2 = (int)(GetMonData(&party->mons[pos], MON_DATA_SPECIES_EXISTS, NULL) - GetMonData(pokemon, MON_DATA_SPECIES_EXISTS, NULL));
|
||||
party->mons[pos] = *pokemon;
|
||||
party->curCount += r2;
|
||||
}
|
||||
|
||||
BOOL SwapSlotsInParty(struct Party * party, int pos1, int pos2)
|
||||
{
|
||||
struct Pokemon * buffer;
|
||||
BOOL SwapSlotsInParty(struct Party *party, int pos1, int pos2) {
|
||||
struct Pokemon *buffer;
|
||||
GF_ASSERT(pos1 >= 0);
|
||||
GF_ASSERT(pos1 < party->curCount);
|
||||
GF_ASSERT(pos1 < party->maxCount);
|
||||
GF_ASSERT(pos2 >= 0);
|
||||
GF_ASSERT(pos2 < party->curCount);
|
||||
GF_ASSERT(pos2 < party->maxCount);
|
||||
buffer = AllocFromHeap(HEAP_ID_DEFAULT, sizeof(struct Pokemon));
|
||||
*buffer = party->mons[pos1];
|
||||
buffer = AllocFromHeap(HEAP_ID_DEFAULT, sizeof(struct Pokemon));
|
||||
*buffer = party->mons[pos1];
|
||||
party->mons[pos1] = party->mons[pos2];
|
||||
party->mons[pos2] = *buffer;
|
||||
FreeToHeap(buffer);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void CopyParty(struct Party * src, struct Party * dest)
|
||||
{
|
||||
void CopyParty(struct Party *src, struct Party *dest) {
|
||||
*dest = *src;
|
||||
}
|
||||
|
||||
BOOL Party_HasMon(struct Party * party, u16 species)
|
||||
{
|
||||
BOOL Party_HasMon(struct Party *party, u16 species) {
|
||||
int i;
|
||||
for (i = 0; i < party->curCount; i++)
|
||||
{
|
||||
if (species == GetMonData(&party->mons[i], MON_DATA_SPECIES, NULL))
|
||||
for (i = 0; i < party->curCount; i++) {
|
||||
if (species == GetMonData(&party->mons[i], MON_DATA_SPECIES, NULL)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return i != party->curCount;
|
||||
}
|
||||
|
||||
struct Party * SaveArray_Party_Get(struct SaveData * ptr)
|
||||
{
|
||||
struct Party *SaveArray_Party_Get(struct SaveData *ptr) {
|
||||
return (struct Party *)SaveArray_Get(ptr, 2);
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user