Skip to content

Weather manager - #484

Open
adrienntindall wants to merge 24 commits into
pret:masterfrom
adrienntindall:weather-manager
Open

Weather manager#484
adrienntindall wants to merge 24 commits into
pret:masterfrom
adrienntindall:weather-manager

Conversation

@adrienntindall

Copy link
Copy Markdown
Collaborator

-Decompile and partially document weather_manager.c
- @Pixelstyx has offered to document the rest at a future point in time
-Document field/fog.c

PR checklist

  • This comment contains a description of changes (with reason).
  • The ROM compiles to matching locally (make compare_heartgold && make compare_soulsilver).
  • All C code is correctly formatted (git clang-format).
  • This pull request is labeled according to the kind of work it represents.
  • New or updated code labels follow the style guide
  • This work adheres to the AI policy.
  • The author has joined the pret discord server and sent a message in #pokeheartgold to verify that they are human

@red031000 red031000 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

few things

Comment thread include/field/fog.h

FogData *Fog_New();
void ov01_021EA840(s32 *arg0);
BOOL Fog_CheckActive(FogData *arg0);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FogData could have a better name than arg0

typedef struct WeatherDraw {
GF_2DGfxResMan *resMan[4];
GF_2DGfxResHeader *header;
NNSG2dRendererInstance instance;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renderInstance and renderSurface may be better names than just instance and surface

Comment thread include/field_system.h
Field3dObjectTaskManager *field3dObjectTaskManager;
FieldDrawMapNameInfo *drawMapNameInfo;
void *unk_0C; // weather related?
WeatherManager *weatherManager; // weather related?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment can be removed

#define POKEHEARTGOLD_OVERLAY_01_02203E40_H

void *ov01_02203EA0();
void ov01_02203F2C(void *, float a0);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this actually a float?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surprisingly yes, the function itself calls float related instructions I've never seen before

Comment thread src/field/fog.c
return dst;
}

void ov01_021EA840(s32 *arg0) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

possibly fog deletion?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most certainly Fog_Free(FogData *fog), I confirmed this in #491

}

static u16 ov01_021EB804(WeatherSystem *weatherSystem, int weather) {
if (weather >= 14) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weather constant

}

if (v0->unk2 != 0xFFFF) {
GfGfx_EngineATogglePlanes(4, 0);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

plane constant

WeatherSystem_Sub0 *v0 = &weatherSystem->unk0[weather];

if (v0->unk2 != 0xFFFF) {
GfGfx_EngineATogglePlanes(4, 0);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be GfGfx_EngineATogglePlanes(GX_PLANEMASK_BG2, GF_PLANE_TOGGLE_OFF);


Sprite *temp = a0->unk4;
memset(a0, 0, sizeof(WeatherObject));
a0->unk4 = temp;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can unk4 be documented

Comment thread src/scrcmd_c.c
LocalFieldData *localFieldData = Save_LocalFieldData_Get(ctx->fieldSystem->saveData);
LocalFieldData_SetWeatherType(localFieldData, 12);
FieldWeatherUpdate_UsedFlash(ctx->fieldSystem->unk4->unk_0C, LocalFieldData_GetWeatherType(localFieldData)); // CallFieldTask_Flash?
WeatherManager_ChangeWeather(ctx->fieldSystem->unk4->weatherManager, LocalFieldData_GetWeatherType(localFieldData)); // CallFieldTask_Flash?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment can be removed

typedef struct WeatherObject WeatherObject;
struct WeatherObject {
WeatherSystem *weatherSystem;
Sprite *unk4;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could just be named sprite?

struct WeatherSystem_Sub0_Sub8 {
WeatherSystem *weatherSystem;
WeatherSystem_Sub0 *unk4;
WeatherSpriteResources *unk8;

@Pixelstyx Pixelstyx Jul 27, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weatherSpriteResources


struct WeatherSystem {
WeatherSystem_Sub0 *unk0;
const WeatherGfxNarcData *unk4;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

narcData?

u32 weather;
u32 nextWeather;
u32 state;
u32 unk10;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unkWeather? We know it is definitely weather, just not what purpose it serves.

weatherSystem->unk0 = ov01_022098B0;
weatherSystem->unk4 = ov01_0220675C;

weatherSystem->narc = NARC_New(NARC_a_0_6_3, HEAP_ID_FIELD1);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we confirm the contents of this NARC and rename the constant accordingly?

@Pixelstyx Pixelstyx Jul 27, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having looked at it in tinke, everything other than the bin files is individual weather particles. there's also an enormous rainbow that i assume is unused.

the bin files could also be weather, i dunno.

WeatherSystem_Sub0 *unk4;
WeatherSpriteResources *unk8;
WeatherObject linkedListDummy;
WeatherObject linkedList[64];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect the data attached to this linked list is used to cyclically spawn and free individual weather particles (e.g. raindrops)

static void ov01_021EC028(WeatherSystem_Sub0_Sub8 *a0) {
for (int i = 0; i < 64; i++) {
a0->linkedList[i].unk4 = Sprite_CreateAffine(&a0->unk8->spriteTemplate);
Sprite_SetDrawFlag(a0->linkedList[i].unk4, 0);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SetDrawFlag's second param is a BOOL

static void ov01_021EC300(void *data) {
}

static VecFx32 ov01_021EC304(WeatherObject *a0) {

@Pixelstyx Pixelstyx Jul 27, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WeatherObject_GetSpriteMatrixPtr?

static void ov01_021EC6A4(WeatherFogChange *fogChange, FogData *fog, s32 arg2, s32 arg3, GXRgb rgb, s32 arg5) {
int slope = Fog_GetSlope(fog);
int offset = Fog_GetOffset(fog);
GXRgb rgb2 = ov01_021EA860(fog);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surely this can just be Fog_GetColor?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants