Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Match all of code_8004AA0.s #152

Merged
merged 1 commit into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
422 changes: 0 additions & 422 deletions asm/code_8004AA0.s

This file was deleted.

2 changes: 2 additions & 0 deletions include/bg_palette_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
#define GUARD_BG_PALETTE_BUFFER_H

void InitBGPaletteBuffer(void);
void nullsub_4(s32 index, u8 *RGBArray, s32 a1, u8 *a2);
void SetBGPaletteBufferColorRGB(s32 index, u8 *RGBArray, s32 a1, u8 *a2);

#endif // GUARD_BG_PALETTE_BUFFER_H
41 changes: 41 additions & 0 deletions include/code_8004AA0.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#ifndef GUARD_CODE_8004AA0_H
#define GUARD_CODE_8004AA0_H

#include "file_system.h"

// size: 0x4
struct RGB
{
// IDK which is R G B
u8 unk0;
u8 unk1;
u8 unk2;
};

// size: 0x18
struct unkStruct_202EE8C
{
u32 unk0;
u16 unk4;
s16 unk6;
struct RGB *unk8;
struct RGB *unkC;
struct RGB *unk10;
struct RGB unk14;
};

// size: Variable
struct unkDataFor8004AA4
{
/* 0x0 */ s16 colorCount;
s16 unk2;
/* 0x4 */ struct RGB colors[0];
};

void nullsub_6(void);
void sub_8004AA4(struct unkStruct_202EE8C *, struct OpenedFile *, s32);
bool8 sub_8004AF0(bool8, struct unkStruct_202EE8C *, s32, s32, s32, u8 *);
bool8 sub_8004D14(struct unkStruct_202EE8C *, s32);
bool8 sub_8004D40(struct unkStruct_202EE8C *, s32);

#endif // GUARD_CODE_8004AA0_H
3 changes: 3 additions & 0 deletions include/code_800558C_1.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
#define GUARD_CODE_800558C_1_H

void nullsub_7(s16 *);
void nullsub_9(void);
void nullsub_10(bool8);
void nullsub_12(void);
void nullsub_13(void);
void nullsub_14(void);
void sub_8005770(s32, u8 *, s32, u8 *);
void sub_80057E8(void);

#endif // GUARD_CODE_800558C_1_H
2 changes: 1 addition & 1 deletion ld_script.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ SECTIONS {
src/util.o(.text);
src/bg_palette_buffer.o(.text);
src/input.o(.text);
asm/code_8004AA0.o(.text);
src/code_8004AA0.o(.text);
src/sprite.o(.text);
asm/code_800558C.o(.text);
src/code_800558C_1.o(.text);
Expand Down
5 changes: 1 addition & 4 deletions src/bg_palette_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,17 +211,14 @@ void SetBGPaletteBufferColor(s32 index, u16 *color)
gBGPaletteBuffer[index] = *color;
}

void nullsub_4(void)
void nullsub_4(s32 index, u8 *RGBArray, s32 a1, u8 *a2)
{

}
void nullsub_5(void)
{

}
void nullsub_143(void)
{

}

void TransferBGPaletteBuffer(void)
Expand Down
2 changes: 1 addition & 1 deletion src/code_2.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "code_8094F88.h"
#include "sprite.h"
#include "code_80118A4.h"
#include "bg_palette_buffer.h"

extern void NDS_LoadOverlay_GroundMain(void);
extern void sub_8014144(void);
Expand All @@ -38,7 +39,6 @@ extern u32 sub_8001658(u32, u32);
extern void sub_800A8F8(u32);
extern void sub_80097B0(void);
extern void LoadTitleScreen(void);
extern void SetBGPaletteBufferColorRGB(s32, u8 *, s32, u8 *);
extern void sub_80095CC(u32, u32);
extern s32 GetFirstIndexofMailType(u8);
extern void nullsub_33(void);
Expand Down
195 changes: 195 additions & 0 deletions src/code_8004AA0.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
#include "global.h"
#include "bg_palette_buffer.h"
#include "code_8004AA0.h"

void nullsub_6(void)
{}

void sub_8004AA4(struct unkStruct_202EE8C *a0, struct OpenedFile *a1, s32 a2)
{
struct unkDataFor8004AA4 **data;
struct unkDataFor8004AA4 *ptr;
s32 i;

data = (struct unkDataFor8004AA4 **)a1->data;
for (i = 0; i < a2; i++) {
ptr = *data++;

if (ptr->colorCount != 0) {
a0->unk0 = 0x80000000;
a0->unk6 = ptr->unk2;
a0->unk4 = ptr->unk2;
a0->unk8 = ptr->colors;
a0->unkC = ptr->colors;
a0->unk10 = &ptr->colors[ptr->colorCount];
a0->unk14 = ptr->colors[0];
}
else
a0->unk0 = 0;

a0++;
}
}

bool8 sub_8004AF0(bool8 a0, struct unkStruct_202EE8C *a1, s32 a2, s32 a3, s32 a4, u8 *a5)
{
bool8 bVar3;
bool8 ret;
s32 i;

ret = FALSE;

for (i = 0; i < a3; i++, a1++, a2++) {
if (!sub_8004D14(a1, 1) || sub_8004D40(a1, 1))
continue;

bVar3 = a0;
a1->unk6--;

if (a1->unk6 <= 0) {
a1->unk6 = a1->unk4;
if (a1->unkC >= a1->unk10)
a1->unkC = a1->unk8;

a1->unk14 = *a1->unkC++;
bVar3 = TRUE;
ret = TRUE;
}

if (bVar3)
SetBGPaletteBufferColorRGB(a2, (u8 *)&a1->unk14, a4, a5);
}

return ret;
}

UNUSED static bool8 sub_8004B78(bool8 a0, struct unkStruct_202EE8C *a1, s32 a2, s32 a3, s32 a4, u8 *a5)
{
bool8 bVar3;
bool8 ret;
s32 i;

ret = FALSE;

for (i = 0; i < a3; i++, a1++, a2++) {
if (!sub_8004D14(a1, 1) || sub_8004D40(a1, 1))
continue;

bVar3 = a0;
a1->unk6--;

if (a1->unk6 <= 0) {
a1->unk6 = a1->unk4;
if (a1->unkC >= a1->unk10)
a1->unkC = a1->unk8;

a1->unk14 = *a1->unkC++;
bVar3 = TRUE;
ret = TRUE;
}

if (bVar3)
nullsub_4(a2, (u8 *)&a1->unk14, a4, a5);
}

return ret;
}

bool8 sub_8004C00(struct unkStruct_202EE8C *a0, s32 a1, s32 a2, s32 a3, u8 *a4, s16 *a5)
{
bool8 ret;
s32 i;
s32 r1;
s32 r3;
s32 r5;
u32 color32;
u32 val;
u32 val2;
u32 val3;

ret = FALSE;

for (i = 0; i < a2; i++, a0++, a1++) {
if (!sub_8004D14(a0, 1) || sub_8004D40(a0, 1))
continue;

a0->unk6--;

if (a0->unk6 <= 0) {
a0->unk6 = a0->unk4;
if (a0->unkC >= a0->unk10)
a0->unkC = a0->unk8;

a0->unk14 = *a0->unkC++;
ret = TRUE;
}

r1 = a5[0] + a0->unk14.unk0;
r3 = a5[1] + a0->unk14.unk1;
r5 = a5[2] + a0->unk14.unk2;

if (r1 > 0xFF)
r1 = 0xFF;
if (r3 > 0xFF)
r3 = 0xFF;
if (r5 > 0xFF)
r5 = 0xFF;
if (r1 < 0)
r1 = 0;
if (r3 < 0)
r3 = 0;
if (r5 < 0)
r5 = 0;

val = (u8)r1;
color32 &= 0xFFFFFF00;
color32 |= val;

val2 = (u8)r3 << 8;
color32 &= 0xFFFF00FF;
color32 |= val2;

val3 = (u8)r5 << 16;
color32 &= 0xFF00FFFF;
color32 |= val3;

SetBGPaletteBufferColorRGB(a1, (u8 *)&color32, a3, a4);
}

return ret;
}

UNUSED static void sub_8004CFC(struct unkStruct_202EE8C *a0, s32 a1)
{
s32 i;

for (i = 0; i < a1; a0++, i++) {
a0->unk0 = 0;
}
}

bool8 sub_8004D14(struct unkStruct_202EE8C *a0, s32 a1)
{
s32 i;

for (i = 0; i < a1; i++) {
if (a0->unk0 & 0x80000000)
return TRUE;
a0++;
}
return FALSE;
}

bool8 sub_8004D40(struct unkStruct_202EE8C *a0, s32 a1)
{
s32 i;

for (i = 0; i < a1; i++) {
if (a0->unk0 & 0x80000000) {
if (!(a0->unk0 & 0x20000000))
return FALSE;
a0++;
}
}
return TRUE;
}
Loading