From f38e97b37bed65c1b2497513cd9ebd18e892724a Mon Sep 17 00:00:00 2001 From: Evan Date: Wed, 19 Jun 2024 18:04:52 -0400 Subject: [PATCH 1/8] Document the distortion world warp overlay. --- include/overlay121/DWWarp.h | 9 + include/overlay121/ov121_021D0D80.h | 9 - include/unk_0202419C.h | 2 +- platinum.us/main.lsf | 2 +- src/battle/ov16_0223B140.c | 2 +- src/choose_starter/choose_starter_app.c | 2 +- src/meson.build | 2 +- src/overlay005/encounter_effect_core.c | 2 +- src/overlay005/fieldmap.c | 2 +- src/overlay021/ov21_021D0D80.c | 2 +- src/overlay022/ov22_02255094.c | 2 +- src/overlay022/ov22_0225B660.c | 2 +- src/overlay062/ov62_0222F2C0.c | 2 +- src/overlay062/ov62_02237D24.c | 8 +- src/overlay069/ov69_0225C700.c | 2 +- src/overlay070/ov70_0225D9A4.c | 2 +- src/overlay076/ov76_0223B870.c | 2 +- src/overlay077/ov77_021D0D80.c | 4 +- src/overlay077/ov77_021D25B0.c | 2 +- src/overlay077/ov77_021D6C70.c | 2 +- src/overlay083/ov83_0223C958.c | 2 +- src/overlay092/ov92_021D0D80.c | 4 +- src/overlay093/ov93_021D0D80.c | 2 +- src/overlay093/ov93_021D111C.c | 2 +- src/overlay095/ov95_02247B6C.c | 2 +- src/overlay095/ov95_02248590.c | 2 +- src/overlay095/ov95_02249740.c | 2 +- src/overlay095/ov95_0224A390.c | 2 +- src/overlay095/ov95_0224ABC0.c | 2 +- src/overlay095/ov95_0224B3D8.c | 2 +- src/overlay099/ov99_021D0D80.c | 2 +- src/overlay100/ov100_021D13E4.c | 2 +- src/overlay100/ov100_021D1C44.c | 2 +- src/overlay100/ov100_021D2F0C.c | 2 +- src/overlay104/ov104_0223C2D4.c | 2 +- src/overlay109/ov109_021D0D80.c | 2 +- src/overlay113/ov113_0225C700.c | 2 +- src/overlay115/ov115_02260CEC.c | 2 +- src/overlay116/ov116_02261870.c | 2 +- src/overlay117/ov117_02260668.c | 2 +- src/overlay118/ov118_021D0D80.c | 2 +- src/overlay119/ov119_021D0D80.c | 2 +- src/overlay121/DWWarp.c | 385 ++++++++++++++++++++++++ src/overlay121/ov121_021D0D80.c | 370 ----------------------- src/unk_0202419C.c | 2 +- src/unk_0203D1B8.c | 8 +- src/unk_0207AE68.c | 2 +- src/unk_0207C63C.c | 2 +- 48 files changed, 446 insertions(+), 431 deletions(-) create mode 100644 include/overlay121/DWWarp.h delete mode 100644 include/overlay121/ov121_021D0D80.h create mode 100644 src/overlay121/DWWarp.c delete mode 100644 src/overlay121/ov121_021D0D80.c diff --git a/include/overlay121/DWWarp.h b/include/overlay121/DWWarp.h new file mode 100644 index 0000000000..477f30c404 --- /dev/null +++ b/include/overlay121/DWWarp.h @@ -0,0 +1,9 @@ +#ifndef POKEPLATINUM_DWWARP_H +#define POKEPLATINUM_DWWARP_H + + +int DWWarp_Init(OverlayManager * ovy, int * seq); +int DWWarp_Main(OverlayManager * ovy, int * seq); +int DWWarp_Exit(OverlayManager * ovy, int * seq); + +#endif // POKEPLATINUM_DWWARP_H diff --git a/include/overlay121/ov121_021D0D80.h b/include/overlay121/ov121_021D0D80.h deleted file mode 100644 index b2918b5372..0000000000 --- a/include/overlay121/ov121_021D0D80.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef POKEPLATINUM_OV121_021D0D80_H -#define POKEPLATINUM_OV121_021D0D80_H - - -int ov121_021D0D80(OverlayManager * param0, int * param1); -int ov121_021D0E7C(OverlayManager * param0, int * param1); -int ov121_021D0F14(OverlayManager * param0, int * param1); - -#endif // POKEPLATINUM_OV121_021D0D80_H diff --git a/include/unk_0202419C.h b/include/unk_0202419C.h index b3c29414a9..cd0df37870 100644 --- a/include/unk_0202419C.h +++ b/include/unk_0202419C.h @@ -6,7 +6,7 @@ void sub_0202419C(void); void sub_020241B4(void); -void sub_020241BC(GXSortMode param0, GXBufferMode param1); +void G3_RequestSwapBuffers(GXSortMode param0, GXBufferMode param1); void sub_020241CC(void); #endif // POKEPLATINUM_UNK_0202419C_H diff --git a/platinum.us/main.lsf b/platinum.us/main.lsf index 8f1d5afee2..60e36c449e 100644 --- a/platinum.us/main.lsf +++ b/platinum.us/main.lsf @@ -1720,6 +1720,6 @@ Overlay overlay120 Overlay overlay121 { After main - Object main.nef.p/src_overlay121_ov121_021D0D80.c.o + Object main.nef.p/src_overlay121_DWWarp.c.o } diff --git a/src/battle/ov16_0223B140.c b/src/battle/ov16_0223B140.c index f3441d4eda..d030882cda 100644 --- a/src/battle/ov16_0223B140.c +++ b/src/battle/ov16_0223B140.c @@ -1562,7 +1562,7 @@ static void ov16_0223CF48 (SysTask * param0, void * param1) sub_02007768(v0->unk_88); sub_0200C7EC(v0->unk_94); sub_0200C808(); - sub_020241BC(GX_SORTMODE_MANUAL, GX_BUFFERMODE_Z); + G3_RequestSwapBuffers(GX_SORTMODE_MANUAL, GX_BUFFERMODE_Z); } } diff --git a/src/choose_starter/choose_starter_app.c b/src/choose_starter/choose_starter_app.c index f50c624695..ef7be57b35 100644 --- a/src/choose_starter/choose_starter_app.c +++ b/src/choose_starter/choose_starter_app.c @@ -1063,7 +1063,7 @@ static void DrawScene (ChooseStarterApp * param0) NNS_G3dGePopMtx(1); - sub_020241BC(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); + G3_RequestSwapBuffers(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); sub_020219F8(param0->unk_248); } diff --git a/src/meson.build b/src/meson.build index 4296463924..f90c4a2f9c 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1020,5 +1020,5 @@ pokeplatinum_c = files( 'overlay119/ov119_021D0D80.c', 'overlay119/ov119_021D191C.c', 'overlay120/ov120_021D0D80.c', - 'overlay121/ov121_021D0D80.c' + 'overlay121/DWWarp.c' ) diff --git a/src/overlay005/encounter_effect_core.c b/src/overlay005/encounter_effect_core.c index bb28b5dce2..485056f6b9 100644 --- a/src/overlay005/encounter_effect_core.c +++ b/src/overlay005/encounter_effect_core.c @@ -3608,7 +3608,7 @@ static BOOL EncounterEffect_EliteFourChampion(EncounterEffect *encEffect, enum H sub_020241B4(); ov5_021DF1CC(); ov5_021DF070(); - sub_020241BC(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); + G3_RequestSwapBuffers(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); } } diff --git a/src/overlay005/fieldmap.c b/src/overlay005/fieldmap.c index 4da6357433..c869c34fb0 100644 --- a/src/overlay005/fieldmap.c +++ b/src/overlay005/fieldmap.c @@ -759,7 +759,7 @@ static void ov5_021D15F4 (FieldSystem * fieldSystem) } ov5_021D1B18(fieldSystem->unk_04->unk_04); - sub_020241BC(GX_SORTMODE_AUTO, gBufferMode); + G3_RequestSwapBuffers(GX_SORTMODE_AUTO, gBufferMode); } void ov5_021D16F4 (FieldSystem * fieldSystem, BOOL param1) diff --git a/src/overlay021/ov21_021D0D80.c b/src/overlay021/ov21_021D0D80.c index 50035618bb..606a2332bb 100644 --- a/src/overlay021/ov21_021D0D80.c +++ b/src/overlay021/ov21_021D0D80.c @@ -399,7 +399,7 @@ BOOL ov21_021D10B8 (UnkStruct_ov21_021D0F60 * param0) sub_020241B4(); ov21_021D2124(¶m0->unk_177C); - sub_020241BC(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); + G3_RequestSwapBuffers(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); param0->unk_1A68 = 0; param0->unk_1A6C = 0; diff --git a/src/overlay022/ov22_02255094.c b/src/overlay022/ov22_02255094.c index 321b4119bb..91354aaec8 100644 --- a/src/overlay022/ov22_02255094.c +++ b/src/overlay022/ov22_02255094.c @@ -140,7 +140,7 @@ void ov22_02255180 (UnkStruct_ov22_0225A0E4 * param0) sub_02007768(param0->unk_20); } - sub_020241BC(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); + G3_RequestSwapBuffers(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); ov22_02255AC0(param0); } diff --git a/src/overlay022/ov22_0225B660.c b/src/overlay022/ov22_0225B660.c index 4221de2989..3b8ea2a003 100644 --- a/src/overlay022/ov22_0225B660.c +++ b/src/overlay022/ov22_0225B660.c @@ -121,7 +121,7 @@ int ov22_0225B738 (OverlayManager * param0, int * param1) sub_020241B4(); NNS_G2dSetupSoftwareSpriteCamera(); ov22_0225AFF8(v0->unk_10); - sub_020241BC(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); + G3_RequestSwapBuffers(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); } ov22_0225562C(&v0->unk_14); diff --git a/src/overlay062/ov62_0222F2C0.c b/src/overlay062/ov62_0222F2C0.c index 673df0ad02..de7373921d 100644 --- a/src/overlay062/ov62_0222F2C0.c +++ b/src/overlay062/ov62_0222F2C0.c @@ -447,7 +447,7 @@ BOOL ov62_0222F910 (UnkStruct_0208C06C * param0, int * param1) sub_020241B4(); sub_02007768(param0->unk_14.unk_50); - sub_020241BC(GX_SORTMODE_MANUAL, GX_BUFFERMODE_Z); + G3_RequestSwapBuffers(GX_SORTMODE_MANUAL, GX_BUFFERMODE_Z); ov62_022411D4(param0); diff --git a/src/overlay062/ov62_02237D24.c b/src/overlay062/ov62_02237D24.c index 2a7afbaeaf..1c75cf1c63 100644 --- a/src/overlay062/ov62_02237D24.c +++ b/src/overlay062/ov62_02237D24.c @@ -332,7 +332,7 @@ static BOOL ov62_02237F08 (UnkStruct_0208C06C * param0) if (v0->unk_228) { sub_020241B4(); ov22_0225AFF8(v0->unk_228); - sub_020241BC(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); + G3_RequestSwapBuffers(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); } return 0; @@ -355,7 +355,7 @@ static BOOL ov62_02238048 (UnkStruct_0208C06C * param0) if (v0->unk_228) { sub_020241B4(); ov22_0225AFF8(v0->unk_228); - sub_020241BC(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); + G3_RequestSwapBuffers(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); } return 0; @@ -949,7 +949,7 @@ static BOOL ov62_02238D04 (UnkStruct_0208C06C * param0) if (v0->unk_228) { sub_020241B4(); ov22_0225AFF8(v0->unk_228); - sub_020241BC(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); + G3_RequestSwapBuffers(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); } return 0; @@ -990,7 +990,7 @@ static BOOL ov62_02238E54 (UnkStruct_0208C06C * param0) if (v0->unk_228) { sub_020241B4(); ov22_0225AFF8(v0->unk_228); - sub_020241BC(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); + G3_RequestSwapBuffers(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); } return 0; diff --git a/src/overlay069/ov69_0225C700.c b/src/overlay069/ov69_0225C700.c index 7c4996a372..7c7fc2020d 100644 --- a/src/overlay069/ov69_0225C700.c +++ b/src/overlay069/ov69_0225C700.c @@ -1154,7 +1154,7 @@ static void ov69_0225CF50 (UnkStruct_ov69_0225CE64 * param0) ov69_0225D854(¶m0->unk_288, ¶m0->unk_1DC); ov69_0225D384(¶m0->unk_20); - sub_020241BC(GX_SORTMODE_AUTO, GX_BUFFERMODE_W); + G3_RequestSwapBuffers(GX_SORTMODE_AUTO, GX_BUFFERMODE_W); } static void ov69_0225CF90 (void * param0) diff --git a/src/overlay070/ov70_0225D9A4.c b/src/overlay070/ov70_0225D9A4.c index edbf5dadf3..e8412c1bf4 100644 --- a/src/overlay070/ov70_0225D9A4.c +++ b/src/overlay070/ov70_0225D9A4.c @@ -1504,7 +1504,7 @@ static void ov70_0225E92C (UnkStruct_ov70_0225DEE8 * param0) ov70_0225CAD4(param0->unk_444); ov70_02269240(param0->unk_438); - sub_020241BC(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); + G3_RequestSwapBuffers(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); ov70_0225E6C0(¶m0->unk_3C); } diff --git a/src/overlay076/ov76_0223B870.c b/src/overlay076/ov76_0223B870.c index 4640ac6e69..8ffad5f4d6 100644 --- a/src/overlay076/ov76_0223B870.c +++ b/src/overlay076/ov76_0223B870.c @@ -445,7 +445,7 @@ void ov76_0223BF50 (void) } sub_020146C0(); - sub_020241BC(GX_SORTMODE_MANUAL, GX_BUFFERMODE_Z); + G3_RequestSwapBuffers(GX_SORTMODE_MANUAL, GX_BUFFERMODE_Z); } void ov76_0223BF74 (BGL * param0, Window * param1, int param2, UnkStruct_ov76_0223DE00 * param3, int param4) diff --git a/src/overlay077/ov77_021D0D80.c b/src/overlay077/ov77_021D0D80.c index 9b9118df07..f886dc149d 100644 --- a/src/overlay077/ov77_021D0D80.c +++ b/src/overlay077/ov77_021D0D80.c @@ -553,7 +553,7 @@ static void ov77_021D1568 (UnkStruct_ov77_021D1568 * param0, UnkStruct_ov77_021D break; case 1: sub_020241B4(); - sub_020241BC(GX_SORTMODE_MANUAL, GX_BUFFERMODE_W); + G3_RequestSwapBuffers(GX_SORTMODE_MANUAL, GX_BUFFERMODE_W); param1->unk_00 = 0; break; case 2: @@ -596,7 +596,7 @@ static void ov77_021D1568 (UnkStruct_ov77_021D1568 * param0, UnkStruct_ov77_021D break; } - sub_020241BC(GX_SORTMODE_MANUAL, GX_BUFFERMODE_W); + G3_RequestSwapBuffers(GX_SORTMODE_MANUAL, GX_BUFFERMODE_W); break; } } diff --git a/src/overlay077/ov77_021D25B0.c b/src/overlay077/ov77_021D25B0.c index 6a9ff9554f..fda3af6238 100644 --- a/src/overlay077/ov77_021D25B0.c +++ b/src/overlay077/ov77_021D25B0.c @@ -1838,7 +1838,7 @@ static void ov77_021D4188 (UnkStruct_ov77_021D37C0 * param0) sub_020146C0(); } - sub_020241BC(GX_SORTMODE_AUTO, GX_BUFFERMODE_W); + G3_RequestSwapBuffers(GX_SORTMODE_AUTO, GX_BUFFERMODE_W); } static BOOL ov77_021D4230 (UnkStruct_ov77_021D2E9C * param0, UnkStruct_ov77_021D37C0 * param1, const int param2) diff --git a/src/overlay077/ov77_021D6C70.c b/src/overlay077/ov77_021D6C70.c index d1b4b0cba1..5207af1608 100644 --- a/src/overlay077/ov77_021D6C70.c +++ b/src/overlay077/ov77_021D6C70.c @@ -185,7 +185,7 @@ void ov77_021D6E50 (UnkStruct_ov77_021D6CFC * param0) NNS_G2dSetupSoftwareSpriteCamera(); sub_02007768(param0->unk_00); ov77_021D725C(); - sub_020241BC(GX_SORTMODE_MANUAL, GX_BUFFERMODE_Z); + G3_RequestSwapBuffers(GX_SORTMODE_MANUAL, GX_BUFFERMODE_Z); } } diff --git a/src/overlay083/ov83_0223C958.c b/src/overlay083/ov83_0223C958.c index 723f7a07a1..d0a7e0da0b 100644 --- a/src/overlay083/ov83_0223C958.c +++ b/src/overlay083/ov83_0223C958.c @@ -130,7 +130,7 @@ void ov83_0223CBA4 (UnkStruct_ov83_0223B784 * param0) } NNS_G3dGePopMtx(1); - sub_020241BC(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); + G3_RequestSwapBuffers(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); if (param0->unk_31C) { if (param0->unk_2C.unk_00) { diff --git a/src/overlay092/ov92_021D0D80.c b/src/overlay092/ov92_021D0D80.c index c4323ba1b1..1f46247636 100644 --- a/src/overlay092/ov92_021D0D80.c +++ b/src/overlay092/ov92_021D0D80.c @@ -1474,7 +1474,7 @@ static void ov92_021D26D0 (UnkStruct_ov92_021D1B24 * param0) break; case 2: sub_020241B4(); - sub_020241BC(GX_SORTMODE_AUTO, GX_BUFFERMODE_W); + G3_RequestSwapBuffers(GX_SORTMODE_AUTO, GX_BUFFERMODE_W); param0->unk_BAE8 = 0; break; case 1: @@ -1504,7 +1504,7 @@ static void ov92_021D26D0 (UnkStruct_ov92_021D1B24 * param0) } } - sub_020241BC(GX_SORTMODE_AUTO, GX_BUFFERMODE_W); + G3_RequestSwapBuffers(GX_SORTMODE_AUTO, GX_BUFFERMODE_W); break; } } diff --git a/src/overlay093/ov93_021D0D80.c b/src/overlay093/ov93_021D0D80.c index 15a2c04327..35177bbfab 100644 --- a/src/overlay093/ov93_021D0D80.c +++ b/src/overlay093/ov93_021D0D80.c @@ -174,7 +174,7 @@ int ov93_021D0E70 (OverlayManager * param0, int * param1) sub_020241B4(); Camera_ComputeViewMatrix(); sub_0201CA74(&v5->unk_04, &v4, &v2, &v3); - sub_020241BC(GX_SORTMODE_MANUAL, GX_BUFFERMODE_W); + G3_RequestSwapBuffers(GX_SORTMODE_MANUAL, GX_BUFFERMODE_W); return 0; } diff --git a/src/overlay093/ov93_021D111C.c b/src/overlay093/ov93_021D111C.c index 1ea33cb3b3..e82663d6ac 100644 --- a/src/overlay093/ov93_021D111C.c +++ b/src/overlay093/ov93_021D111C.c @@ -174,7 +174,7 @@ int ov93_021D120C (OverlayManager * param0, int * param1) sub_020241B4(); Camera_ComputeViewMatrix(); sub_0201CA74(&v5->unk_04, &v4, &v2, &v3); - sub_020241BC(GX_SORTMODE_MANUAL, GX_BUFFERMODE_W); + G3_RequestSwapBuffers(GX_SORTMODE_MANUAL, GX_BUFFERMODE_W); return 0; } diff --git a/src/overlay095/ov95_02247B6C.c b/src/overlay095/ov95_02247B6C.c index 6682be2395..ca897ad498 100644 --- a/src/overlay095/ov95_02247B6C.c +++ b/src/overlay095/ov95_02247B6C.c @@ -199,7 +199,7 @@ static void ov95_02247C6C (UnkStruct_ov95_02247C6C * param0) NNS_G3dGePopMtx(1); ov95_02247770(param0->unk_70); - sub_020241BC(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); + G3_RequestSwapBuffers(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); } static int ov95_02247CB4 (UnkStruct_ov95_02247C6C * param0, int * param1) diff --git a/src/overlay095/ov95_02248590.c b/src/overlay095/ov95_02248590.c index f49bdd7634..c009fecb26 100644 --- a/src/overlay095/ov95_02248590.c +++ b/src/overlay095/ov95_02248590.c @@ -297,7 +297,7 @@ static void ov95_02248688 (UnkStruct_ov95_02248688 * param0) G3X_Reset(); ov95_02247770(param0->unk_D4); - sub_020241BC(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); + G3_RequestSwapBuffers(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); } } diff --git a/src/overlay095/ov95_02249740.c b/src/overlay095/ov95_02249740.c index 0040c5e115..aff03c8627 100644 --- a/src/overlay095/ov95_02249740.c +++ b/src/overlay095/ov95_02249740.c @@ -185,7 +185,7 @@ static void ov95_022497D8 (UnkStruct_ov95_022497D8 * param0) G3X_Reset(); ov95_02247770(param0->unk_28); - sub_020241BC(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); + G3_RequestSwapBuffers(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); } } diff --git a/src/overlay095/ov95_0224A390.c b/src/overlay095/ov95_0224A390.c index e01b7d86b3..2aecdfb73e 100644 --- a/src/overlay095/ov95_0224A390.c +++ b/src/overlay095/ov95_0224A390.c @@ -579,7 +579,7 @@ static void ov95_0224AB50 (void * param0) if (v0->unk_28) { G3X_Reset(); ov95_02247770(v0->unk_28); - sub_020241BC(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); + G3_RequestSwapBuffers(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); } if (v0->unk_0C) { diff --git a/src/overlay095/ov95_0224ABC0.c b/src/overlay095/ov95_0224ABC0.c index 900f6634b3..274890f2c6 100644 --- a/src/overlay095/ov95_0224ABC0.c +++ b/src/overlay095/ov95_0224ABC0.c @@ -204,7 +204,7 @@ static void ov95_0224AC64 (UnkStruct_ov95_0224AC64 * param0) ov95_02247990(param0->unk_24, &(param0->unk_28)); G3X_Reset(); ov95_02247770(param0->unk_20); - sub_020241BC(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); + G3_RequestSwapBuffers(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); } } diff --git a/src/overlay095/ov95_0224B3D8.c b/src/overlay095/ov95_0224B3D8.c index ea2e224416..7381e573c0 100644 --- a/src/overlay095/ov95_0224B3D8.c +++ b/src/overlay095/ov95_0224B3D8.c @@ -229,7 +229,7 @@ static void ov95_0224B4D4 (UnkStruct_ov95_0224B4D4 * param0) ov95_02247770(param0->unk_74); } - sub_020241BC(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); + G3_RequestSwapBuffers(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); } static int ov95_0224B520 (UnkStruct_ov95_0224B4D4 * param0, int * param1) diff --git a/src/overlay099/ov99_021D0D80.c b/src/overlay099/ov99_021D0D80.c index 12ea076dfd..618db758e6 100644 --- a/src/overlay099/ov99_021D0D80.c +++ b/src/overlay099/ov99_021D0D80.c @@ -299,7 +299,7 @@ static void ov99_021D1244 (SysTask * param0, void * param1) if (v0->unk_1103 == 1) { ov99_021D1720(v0); - sub_020241BC(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); + G3_RequestSwapBuffers(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); } sub_0200C7EC(v0->unk_1C); diff --git a/src/overlay100/ov100_021D13E4.c b/src/overlay100/ov100_021D13E4.c index f4816c35ec..bc8c71bc27 100644 --- a/src/overlay100/ov100_021D13E4.c +++ b/src/overlay100/ov100_021D13E4.c @@ -225,7 +225,7 @@ static void ov100_021D17B4 (UnkStruct_ov100_021D1808 * param0) ov100_021D49B4(¶m0->unk_1A4.unk_00[2]); ov100_021D49B4(¶m0->unk_1A4.unk_498); - sub_020241BC(GX_SORTMODE_AUTO, GX_BUFFERMODE_W); + G3_RequestSwapBuffers(GX_SORTMODE_AUTO, GX_BUFFERMODE_W); } static void ov100_021D1808 (UnkStruct_ov100_021D1808 * param0) diff --git a/src/overlay100/ov100_021D1C44.c b/src/overlay100/ov100_021D1C44.c index 7f635feeb0..dd1ee08404 100644 --- a/src/overlay100/ov100_021D1C44.c +++ b/src/overlay100/ov100_021D1C44.c @@ -763,5 +763,5 @@ static void ov100_021D2E0C (UnkStruct_ov100_021D1C98 * param0) ov100_021D49B4(¶m0->unk_1A0.unk_16FC[2]); ov100_021D49B4(¶m0->unk_1A0.unk_16FC[3]); - sub_020241BC(GX_SORTMODE_AUTO, GX_BUFFERMODE_W); + G3_RequestSwapBuffers(GX_SORTMODE_AUTO, GX_BUFFERMODE_W); } diff --git a/src/overlay100/ov100_021D2F0C.c b/src/overlay100/ov100_021D2F0C.c index 0989869991..5ab477bd02 100644 --- a/src/overlay100/ov100_021D2F0C.c +++ b/src/overlay100/ov100_021D2F0C.c @@ -240,7 +240,7 @@ static void ov100_021D3558 (UnkStruct_ov100_021D3084 * param0) ov100_021D49B4(¶m0->unk_0C.unk_16FC[2]); ov100_021D49B4(¶m0->unk_0C.unk_16FC[3]); - sub_020241BC(GX_SORTMODE_AUTO, GX_BUFFERMODE_W); + G3_RequestSwapBuffers(GX_SORTMODE_AUTO, GX_BUFFERMODE_W); } void * ov100_021D3620 (UnkStruct_ov100_021D4DD8 * param0) diff --git a/src/overlay104/ov104_0223C2D4.c b/src/overlay104/ov104_0223C2D4.c index 29dc5aba54..abdc9a9e7d 100644 --- a/src/overlay104/ov104_0223C2D4.c +++ b/src/overlay104/ov104_0223C2D4.c @@ -386,7 +386,7 @@ static void ov104_0223C738 (SysTask * param0, void * param1) sub_0200C808(); ov104_0223D6A8(); - sub_020241BC(GX_SORTMODE_MANUAL, GX_BUFFERMODE_Z); + G3_RequestSwapBuffers(GX_SORTMODE_MANUAL, GX_BUFFERMODE_Z); } static void ov104_0223C798 (UnkStruct_ov104_0223C4CC * param0) diff --git a/src/overlay109/ov109_021D0D80.c b/src/overlay109/ov109_021D0D80.c index 7c7150e111..e303436d74 100644 --- a/src/overlay109/ov109_021D0D80.c +++ b/src/overlay109/ov109_021D0D80.c @@ -1601,7 +1601,7 @@ static void ov109_021D1C90 (UnkStruct_ov109_021D0F70 * param0) ov109_021D2AC8(param0); ov109_021D2CCC(param0); - sub_020241BC(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); + G3_RequestSwapBuffers(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); sub_0200C7EC(param0->unk_D98); } diff --git a/src/overlay113/ov113_0225C700.c b/src/overlay113/ov113_0225C700.c index c4fd2b0939..e016df3e5a 100644 --- a/src/overlay113/ov113_0225C700.c +++ b/src/overlay113/ov113_0225C700.c @@ -693,7 +693,7 @@ static void ov113_0225CEF0 (SysTask * param0, void * param1) sub_0200C7EC(v0->unk_20); sub_0200C808(); - sub_020241BC(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); + G3_RequestSwapBuffers(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); } static void ov113_0225CF18 (void * param0) diff --git a/src/overlay115/ov115_02260CEC.c b/src/overlay115/ov115_02260CEC.c index cb955309e5..8289661801 100644 --- a/src/overlay115/ov115_02260CEC.c +++ b/src/overlay115/ov115_02260CEC.c @@ -3001,7 +3001,7 @@ static void ov115_0226369C (const UnkStruct_ov115_02260D78 * param0, UnkStruct_o NNS_G3dGePopMtx(1); - sub_020241BC(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); + G3_RequestSwapBuffers(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); sub_020219F8(param1->unk_1C); } diff --git a/src/overlay116/ov116_02261870.c b/src/overlay116/ov116_02261870.c index d46407940d..252c379536 100644 --- a/src/overlay116/ov116_02261870.c +++ b/src/overlay116/ov116_02261870.c @@ -175,7 +175,7 @@ void ov116_02261940 (UnkStruct_ov116_0226139C * param0) } } - sub_020241BC(GX_SORTMODE_AUTO, GX_BUFFERMODE_W); + G3_RequestSwapBuffers(GX_SORTMODE_AUTO, GX_BUFFERMODE_W); sub_0200C7EC(param0->unk_48.unk_0C); } diff --git a/src/overlay117/ov117_02260668.c b/src/overlay117/ov117_02260668.c index 16e31135ad..5e8751d82a 100644 --- a/src/overlay117/ov117_02260668.c +++ b/src/overlay117/ov117_02260668.c @@ -634,7 +634,7 @@ static void ov117_02260F7C (SysTask * param0, void * param1) sub_0200C7EC(v0->unk_28); sub_0200C808(); - sub_020241BC(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); + G3_RequestSwapBuffers(GX_SORTMODE_AUTO, GX_BUFFERMODE_Z); sub_02038A1C(110, v0->unk_2C); } diff --git a/src/overlay118/ov118_021D0D80.c b/src/overlay118/ov118_021D0D80.c index b07ebfcacf..5e588dc53d 100644 --- a/src/overlay118/ov118_021D0D80.c +++ b/src/overlay118/ov118_021D0D80.c @@ -246,7 +246,7 @@ static int ov118_021D10E8 (void) } sub_020146C0(); - sub_020241BC(GX_SORTMODE_MANUAL, GX_BUFFERMODE_Z); + G3_RequestSwapBuffers(GX_SORTMODE_MANUAL, GX_BUFFERMODE_Z); return v0; } diff --git a/src/overlay119/ov119_021D0D80.c b/src/overlay119/ov119_021D0D80.c index 543b6a36d8..60e0716f30 100644 --- a/src/overlay119/ov119_021D0D80.c +++ b/src/overlay119/ov119_021D0D80.c @@ -272,7 +272,7 @@ void ov119_021D1004 (void) } sub_020146C0(); - sub_020241BC(GX_SORTMODE_MANUAL, GX_BUFFERMODE_Z); + G3_RequestSwapBuffers(GX_SORTMODE_MANUAL, GX_BUFFERMODE_Z); } void ov119_021D1028 (void) diff --git a/src/overlay121/DWWarp.c b/src/overlay121/DWWarp.c new file mode 100644 index 0000000000..4afc63bea7 --- /dev/null +++ b/src/overlay121/DWWarp.c @@ -0,0 +1,385 @@ +#include +#include + +#include "core_sys.h" + +#include "struct_decls/struct_02006C24_decl.h" +#include "struct_decls/sys_task.h" +#include "struct_decls/struct_020203AC_decl.h" + +#include "struct_defs/struct_020170F4.h" +#include "struct_defs/struct_02017248.h" +#include "struct_defs/struct_02017294.h" +#include "struct_defs/struct_0207C690.h" +#include "struct_defs/struct_02099F80.h" +#include "overlay115/camera_angle.h" + +#include "unk_02002328.h" +#include "unk_02005474.h" +#include "overlay_manager.h" +#include "narc.h" +#include "unk_0200D9E8.h" +#include "unk_0200F174.h" +#include "unk_020170BC.h" +#include "unk_02017728.h" +#include "heap.h" +#include "unk_0201E3D8.h" +#include "gx_layers.h" +#include "unk_02020020.h" +#include "unk_0202419C.h" +#include "unk_02024220.h" +#include "overlay121/DWWarp.h" + +typedef struct { + GenericPointerData * p3DCallback; + UnkStruct_020203AC * camera; + SysTask * task; + int frame_cnt; + int soundEffect_cnt; + UnkStruct_02017294 animation_obj; + UnkStruct_02017248 animation_animation; + UnkStruct_02017248 animation_animation2; + UnkStruct_020170F4 animation_model; + u32 move_frame; + int camera_angle; + int camera_angle_calc; + fx32 camera_distance; + int camera_perspective; + NNSFndAllocator allocator; +} DistortionWorld_Warp; + +static void DW_Update(SysTask * task, void * data); +static void DW_VBlankIntr(void * data); +static void DW_VramSetBank(void); +static void DW_InitCamera(DistortionWorld_Warp * warp); +static void DWWarp_CameraEnd(DistortionWorld_Warp * warp); +static void DWWarp_InitModel(DistortionWorld_Warp * warp); +static void DWWarp_DeleteModel(DistortionWorld_Warp * warp); +static void Model3D_Update(DistortionWorld_Warp * warp); +static GenericPointerData * DWWarp_Init3D(int heapId); +static void DWWarp_Setup3D(void); +static void DWWarp_Exit3D(GenericPointerData * param0); +static void DWWarp_CameraMove(DistortionWorld_Warp * warp); + +// Initializes the Distortion World warp effect overlay. +int DWWarp_Init (OverlayManager * ovy, int * seq) +{ + DistortionWorld_Warp * dww; + + SetMainCallback(NULL, NULL); + DisableHBlank(); + GXLayers_DisableEngineALayers(); + GXLayers_DisableEngineBLayers(); + + GX_SetVisiblePlane(0); + GXS_SetVisiblePlane(0); + GX_SetVisibleWnd(GX_WNDMASK_NONE); + GXS_SetVisibleWnd(GX_WNDMASK_NONE); + G2_BlendNone(); + G2S_BlendNone(); + + Heap_Create(3, 30, 0x50000); + + dww = OverlayManager_NewData(ovy, sizeof(DistortionWorld_Warp), 30); + MI_CpuClear8(dww, sizeof(DistortionWorld_Warp)); + dww->p3DCallback = DWWarp_Init3D(30); + + SetAutorepeat(4, 8); + DW_VramSetBank(); + sub_0201E3D8(); + sub_0201E450(4); + + DWWarp_InitModel(dww); + DW_InitCamera(dww); + sub_0200F174(0, 1, 1, 0x0, 16, 1, 30); + + gCoreSys.unk_65 = 0; + + GXLayers_SwapDisplay(); + GXLayers_TurnBothDispOn(); + sub_02002AC8(1); + sub_02002AE4(0); + sub_02002B20(0); + + dww->task = SysTask_Start(DW_Update, dww, 60000); + SetMainCallback(DW_VBlankIntr, dww); + + return TRUE; +} + +enum { + DWARP_SEQ_SCREENWIPE = 0, + DWARP_SEQ_LOOP, + DWARP_SEQ_CLEAR_SCREEN, + DWARP_SEQ_WAIT +}; + +int DWWarp_Main (OverlayManager * ovy, int * seq) +{ + DistortionWorld_Warp * warp = OverlayManager_Data(ovy); + + // Handle the different states of the warp effect. + switch (*seq) { + case DWARP_SEQ_SCREENWIPE: + if (ScreenWipe_Done() == TRUE) { + (*seq)++; + } + break; + case DWARP_SEQ_LOOP: + // Play the portal sound effect after 15 frames + if (warp->soundEffect_cnt == 15) { + Sound_PlayEffect(1491); + } + + warp->soundEffect_cnt++; + warp->frame_cnt++; + + // Continue to the next sequence after 85 frames + if (warp->frame_cnt > 85) { + (*seq)++; + } + break; + case DWARP_SEQ_CLEAR_SCREEN: + // Clear the screen to black + sub_0200F174(0, 0, 0, 0x0, 20, 1, 30); + (*seq)++; + break; + case DWARP_SEQ_WAIT: + // Wait for the screen wipe to finish + if (ScreenWipe_Done() == TRUE) { + return 1; + } + break; + } + + DWWarp_CameraMove(warp); + + return 0; +} + +// Exits the Distortion World warp effect overlay. +int DWWarp_Exit (OverlayManager * ovy, int * seq) +{ + DistortionWorld_Warp * warp = OverlayManager_Data(ovy); + + SysTask_Done(warp->task); + + DWWarp_DeleteModel(warp); + DWWarp_CameraEnd(warp); + DWWarp_Exit3D(warp->p3DCallback); + + SetMainCallback(NULL, NULL); + DisableHBlank(); + sub_0201E530(); + sub_02002AC8(0); + sub_02002AE4(0); + sub_02002B20(0); + OverlayManager_FreeData(ovy); + Heap_Destroy(30); + + return TRUE; +} + +static void DW_Update (SysTask * task, void * data) +{ + DistortionWorld_Warp * dw = data; + + Model3D_Update(dw); + G3_RequestSwapBuffers(GX_SORTMODE_MANUAL, GX_BUFFERMODE_W); +} + +static void DW_VBlankIntr (void * data) +{ + DistortionWorld_Warp * dw = data; + OS_SetIrqCheckFlag(OS_IE_V_BLANK); +} + +static void DW_VramSetBank (void) +{ + GXLayers_DisableEngineALayers(); + GXLayers_DisableEngineBLayers(); + + { + UnkStruct_02099F80 vramBank = { + GX_VRAM_BG_128_C, + GX_VRAM_BGEXTPLTT_NONE, + GX_VRAM_SUB_BG_32_H, + GX_VRAM_SUB_BGEXTPLTT_NONE, + GX_VRAM_OBJ_64_E, + GX_VRAM_OBJEXTPLTT_NONE, + GX_VRAM_SUB_OBJ_16_I, + GX_VRAM_SUB_OBJEXTPLTT_NONE, + GX_VRAM_TEX_01_AB, + GX_VRAM_TEXPLTT_01_FG + }; + + GXLayers_SetBanks(&vramBank); + + MI_CpuClear32((void *)HW_BG_VRAM, HW_BG_VRAM_SIZE); + MI_CpuClear32((void *)HW_DB_BG_VRAM, HW_DB_BG_VRAM_SIZE); + MI_CpuClear32((void *)HW_OBJ_VRAM, HW_OBJ_VRAM_SIZE); + MI_CpuClear32((void *)HW_DB_OBJ_VRAM, HW_DB_OBJ_VRAM_SIZE); + } +} + +static void DW_InitCamera (DistortionWorld_Warp * warp) +{ + { + static const CameraAngle DWW_CameraAngle = { + (0x10000 - 0x1c7d), + ((0 * 0xffff) / 360), + ((0 * 0xffff) / 360), + }; + VecFx32 target = {0, 0, 0}; + + warp->camera = sub_020203AC(30); + + sub_020206D0(&target, (160 << FX32_SHIFT), &DWW_CameraAngle, (((22 * 0xffff) / 360)), 0, 0, warp->camera); + sub_020206BC(0, (FX32_ONE * 300), warp->camera); + + { + CameraAngle angle = {0, 0, 0, 0}; + + angle = sub_02020A94(warp->camera); + angle.x = (0x10000 - 0x3fef); + + Camera_SetAngle(&angle, warp->camera); + } + + sub_020203D4(warp->camera); + } +} + +static void DWWarp_CameraEnd (DistortionWorld_Warp * warp) +{ + sub_020203B8(warp->camera); +} + +static void DWWarp_InitModel (DistortionWorld_Warp * warp) +{ + NARC * narc; + + Heap_FndInitAllocatorForExpHeap(&warp->allocator, 30, 4); + + narc = NARC_ctor(NARC_INDEX_DEMO__TITLE__TITLEDEMO, 30); + + { + sub_020170D8(&warp->animation_model, narc, 16, 30); + + NNS_G3dMdlUseMdlAlpha(warp->animation_model.unk_08); + NNS_G3dMdlUseMdlPolygonID(warp->animation_model.unk_08); + + sub_02017164(&warp->animation_animation, &warp->animation_model, narc, 18, 30, &warp->allocator); + sub_02017240(&warp->animation_animation, 0); + + sub_02017164(&warp->animation_animation2, &warp->animation_model, narc, 17, 30, &warp->allocator); + sub_02017240(&warp->animation_animation2, 0); + sub_02017258(&warp->animation_obj, &warp->animation_model); + + sub_02017350(&warp->animation_obj, 0, 0, 0); + sub_0201736C(&warp->animation_obj, (FX32_ONE), (FX32_ONE), (FX32_ONE)); + sub_02017348(&warp->animation_obj, 1); + + sub_0201727C(&warp->animation_obj, &warp->animation_animation); + sub_0201727C(&warp->animation_obj, &warp->animation_animation2); + } + + NARC_dtor(narc); + + warp->camera_angle = ((0x10000 - 0x3fef) - (0x10000 - 0x1c7d)) / 30; + warp->camera_angle_calc = (0x10000 - 0x1c7d); + warp->camera_distance = (FX32_ONE); + warp->camera_perspective = (60 << 8); +} + +static void DWWarp_DeleteModel (DistortionWorld_Warp * warp) +{ + sub_02017110(&warp->animation_model); + sub_020171A0(&warp->animation_animation, &warp->allocator); + sub_020171A0(&warp->animation_animation2, &warp->allocator); +} + +static void Model3D_Update (DistortionWorld_Warp * warp) +{ + VecFx32 scaleVec, transVec; + MtxFx33 rot33; + + scaleVec.x = FX32_ONE; + scaleVec.y = FX32_ONE; + scaleVec.z = FX32_ONE; + + transVec.x = 0; + transVec.y = 0; + transVec.z = 0; + + MTX_Identity33(&rot33); + + sub_020241B4(); + sub_020203D4(warp->camera); + sub_02020854(0, warp->camera); + sub_020203EC(); + + NNS_G3dGlbLightVector(0, 0, -FX32_ONE, 0); + NNS_G3dGlbLightColor(0, GX_RGB(28, 28, 28)); + NNS_G3dGlbMaterialColorDiffAmb(GX_RGB(31, 31, 31), GX_RGB(31, 31, 31), FALSE); + NNS_G3dGlbMaterialColorSpecEmi(GX_RGB(31, 31, 31), GX_RGB(31, 31, 31), FALSE); + NNS_G3dGlbSetBaseTrans(&transVec); + NNS_G3dGlbSetBaseRot(&rot33); + NNS_G3dGlbSetBaseScale(&scaleVec); + + sub_020171CC(&warp->animation_animation, FX32_ONE); + sub_020171CC(&warp->animation_animation2, FX32_ONE); + + NNS_G3dGePushMtx(); + + { + sub_02017294(&warp->animation_obj); + } + + NNS_G3dGePopMtx(1); +} + +static GenericPointerData * DWWarp_Init3D (int param0) +{ + GenericPointerData * v0; + + v0 = sub_02024220(param0, 0, 2, 0, 2, DWWarp_Setup3D); + return v0; +} + +static void DWWarp_Setup3D (void) +{ + GXLayers_EngineAToggleLayers(GX_PLANEMASK_BG0, 1); + + G2_SetBG0Priority(1); + + G3X_SetShading(GX_SHADING_TOON); + G3X_AntiAlias(TRUE); + G3X_AlphaTest(FALSE, 0); + G3X_AlphaBlend(TRUE); + G3X_EdgeMarking(FALSE); + G3X_SetFog(FALSE, GX_FOGBLEND_COLOR_ALPHA, GX_FOGSLOPE_0x8000, 0); + G3X_SetClearColor(GX_RGB(0, 0, 0), 0, 0x7fff, 63, FALSE); + G3_ViewPort(0, 0, 255, 191); +} + +static void DWWarp_Exit3D (GenericPointerData * param0) +{ + sub_020242C4(param0); +} + +static void DWWarp_CameraMove (DistortionWorld_Warp * warp) +{ + VecFx32 v0 = {0, 0, 0}; + CameraAngle v1 = {0, 0, 0, 0}; + int v2; + + sub_0202094C(-(warp->camera_perspective >> 8), warp->camera); + warp->camera_perspective -= 0x80; + + if (warp->camera_perspective < (16 << 8)) { + warp->camera_perspective = (16 << 8); + } + + warp->move_frame++; +} diff --git a/src/overlay121/ov121_021D0D80.c b/src/overlay121/ov121_021D0D80.c deleted file mode 100644 index d2fb0c0098..0000000000 --- a/src/overlay121/ov121_021D0D80.c +++ /dev/null @@ -1,370 +0,0 @@ -#include -#include - -#include "core_sys.h" - -#include "struct_decls/struct_02006C24_decl.h" -#include "struct_decls/sys_task.h" - -#include "struct_defs/struct_020170F4.h" -#include "struct_defs/struct_02017248.h" -#include "struct_defs/struct_02017294.h" -#include "struct_defs/struct_0207C690.h" -#include "struct_defs/struct_02099F80.h" -#include "overlay115/camera_angle.h" - -#include "unk_02002328.h" -#include "unk_02005474.h" -#include "overlay_manager.h" -#include "narc.h" -#include "unk_0200D9E8.h" -#include "unk_0200F174.h" -#include "unk_020170BC.h" -#include "unk_02017728.h" -#include "heap.h" -#include "unk_0201E3D8.h" -#include "gx_layers.h" -#include "camera.h" -#include "unk_0202419C.h" -#include "unk_02024220.h" -#include "overlay121/ov121_021D0D80.h" - -typedef struct { - GenericPointerData * unk_00; - Camera * camera; - SysTask * unk_08; - int unk_0C; - int unk_10; - UnkStruct_02017294 unk_14; - UnkStruct_02017248 unk_8C; - UnkStruct_02017248 unk_A0; - UnkStruct_020170F4 unk_B4; - u32 unk_C4; - int unk_C8; - int unk_CC; - fx32 unk_D0; - int unk_D4; - NNSFndAllocator unk_D8; -} UnkStruct_ov121_021D0FF4; - -static void ov121_021D0F68(SysTask * param0, void * param1); -static void ov121_021D0F7C(void * param0); -static void ov121_021D0F94(void); -static void ov121_021D0FF4(UnkStruct_ov121_021D0FF4 * param0); -static void ov121_021D1068(UnkStruct_ov121_021D0FF4 * param0); -static void ov121_021D1074(UnkStruct_ov121_021D0FF4 * param0); -static void ov121_021D1184(UnkStruct_ov121_021D0FF4 * param0); -static void ov121_021D11A8(UnkStruct_ov121_021D0FF4 * param0); -static GenericPointerData * ov121_021D1270(int param0); -static void ov121_021D128C(void); -static void ov121_021D1310(GenericPointerData * param0); -static void ov121_021D1318(UnkStruct_ov121_021D0FF4 * param0); - -int ov121_021D0D80 (OverlayManager * param0, int * param1) -{ - UnkStruct_ov121_021D0FF4 * v0; - - SetMainCallback(NULL, NULL); - DisableHBlank(); - GXLayers_DisableEngineALayers(); - GXLayers_DisableEngineBLayers(); - - GX_SetVisiblePlane(0); - GXS_SetVisiblePlane(0); - GX_SetVisibleWnd(GX_WNDMASK_NONE); - GXS_SetVisibleWnd(GX_WNDMASK_NONE); - G2_BlendNone(); - G2S_BlendNone(); - - Heap_Create(3, 30, 0x50000); - - v0 = OverlayManager_NewData(param0, sizeof(UnkStruct_ov121_021D0FF4), 30); - MI_CpuClear8(v0, sizeof(UnkStruct_ov121_021D0FF4)); - v0->unk_00 = ov121_021D1270(30); - - SetAutorepeat(4, 8); - ov121_021D0F94(); - sub_0201E3D8(); - sub_0201E450(4); - - ov121_021D1074(v0); - ov121_021D0FF4(v0); - sub_0200F174(0, 1, 1, 0x0, 16, 1, 30); - - gCoreSys.unk_65 = 0; - - GXLayers_SwapDisplay(); - GXLayers_TurnBothDispOn(); - sub_02002AC8(1); - sub_02002AE4(0); - sub_02002B20(0); - - v0->unk_08 = SysTask_Start(ov121_021D0F68, v0, 60000); - SetMainCallback(ov121_021D0F7C, v0); - - return 1; -} - -int ov121_021D0E7C (OverlayManager * param0, int * param1) -{ - UnkStruct_ov121_021D0FF4 * v0 = OverlayManager_Data(param0); - - switch (*param1) { - case 0: - if (ScreenWipe_Done() == 1) { - (*param1)++; - } - break; - case 1: - if (v0->unk_10 == 15) { - Sound_PlayEffect(1491); - } - - v0->unk_10++; - v0->unk_0C++; - - if (v0->unk_0C > 85) { - (*param1)++; - } - break; - case 2: - sub_0200F174(0, 0, 0, 0x0, 20, 1, 30); - (*param1)++; - break; - case 3: - if (ScreenWipe_Done() == 1) { - return 1; - } - break; - } - - ov121_021D1318(v0); - - return 0; -} - -int ov121_021D0F14 (OverlayManager * param0, int * param1) -{ - UnkStruct_ov121_021D0FF4 * v0 = OverlayManager_Data(param0); - - SysTask_Done(v0->unk_08); - - ov121_021D1184(v0); - ov121_021D1068(v0); - ov121_021D1310(v0->unk_00); - - SetMainCallback(NULL, NULL); - DisableHBlank(); - sub_0201E530(); - sub_02002AC8(0); - sub_02002AE4(0); - sub_02002B20(0); - OverlayManager_FreeData(param0); - Heap_Destroy(30); - - return 1; -} - -static void ov121_021D0F68 (SysTask * param0, void * param1) -{ - UnkStruct_ov121_021D0FF4 * v0 = param1; - - ov121_021D11A8(v0); - sub_020241BC(GX_SORTMODE_MANUAL, GX_BUFFERMODE_W); -} - -static void ov121_021D0F7C (void * param0) -{ - UnkStruct_ov121_021D0FF4 * v0 = param0; - OS_SetIrqCheckFlag(OS_IE_V_BLANK); -} - -static void ov121_021D0F94 (void) -{ - GXLayers_DisableEngineALayers(); - GXLayers_DisableEngineBLayers(); - - { - UnkStruct_02099F80 v0 = { - GX_VRAM_BG_128_C, - GX_VRAM_BGEXTPLTT_NONE, - GX_VRAM_SUB_BG_32_H, - GX_VRAM_SUB_BGEXTPLTT_NONE, - GX_VRAM_OBJ_64_E, - GX_VRAM_OBJEXTPLTT_NONE, - GX_VRAM_SUB_OBJ_16_I, - GX_VRAM_SUB_OBJEXTPLTT_NONE, - GX_VRAM_TEX_01_AB, - GX_VRAM_TEXPLTT_01_FG - }; - - GXLayers_SetBanks(&v0); - - MI_CpuClear32((void *)HW_BG_VRAM, HW_BG_VRAM_SIZE); - MI_CpuClear32((void *)HW_DB_BG_VRAM, HW_DB_BG_VRAM_SIZE); - MI_CpuClear32((void *)HW_OBJ_VRAM, HW_OBJ_VRAM_SIZE); - MI_CpuClear32((void *)HW_DB_OBJ_VRAM, HW_DB_OBJ_VRAM_SIZE); - } -} - -static void ov121_021D0FF4 (UnkStruct_ov121_021D0FF4 * param0) -{ - { - static const CameraAngle v0 = { - (0x10000 - 0x1c7d), - ((0 * 0xffff) / 360), - ((0 * 0xffff) / 360), - }; - VecFx32 v1 = {0, 0, 0}; - - param0->camera = Camera_Alloc(30); - - Camera_InitWithTarget(&v1, (160 << FX32_SHIFT), &v0, (((22 * 0xffff) / 360)), 0, 0, param0->camera); - Camera_SetClipping(0, (FX32_ONE * 300), param0->camera); - - { - CameraAngle v2 = {0, 0, 0, 0}; - - v2 = Camera_GetAngle(param0->camera); - v2.x = (0x10000 - 0x3fef); - - Camera_SetAngleAroundTarget(&v2, param0->camera); - } - - Camera_SetAsActive(param0->camera); - } -} - -static void ov121_021D1068 (UnkStruct_ov121_021D0FF4 * param0) -{ - Camera_Delete(param0->camera); -} - -static void ov121_021D1074 (UnkStruct_ov121_021D0FF4 * param0) -{ - NARC * v0; - - Heap_FndInitAllocatorForExpHeap(¶m0->unk_D8, 30, 4); - - v0 = NARC_ctor(NARC_INDEX_DEMO__TITLE__TITLEDEMO, 30); - - { - sub_020170D8(¶m0->unk_B4, v0, 16, 30); - - NNS_G3dMdlUseMdlAlpha(param0->unk_B4.unk_08); - NNS_G3dMdlUseMdlPolygonID(param0->unk_B4.unk_08); - - sub_02017164(¶m0->unk_8C, ¶m0->unk_B4, v0, 18, 30, ¶m0->unk_D8); - sub_02017240(¶m0->unk_8C, 0); - - sub_02017164(¶m0->unk_A0, ¶m0->unk_B4, v0, 17, 30, ¶m0->unk_D8); - sub_02017240(¶m0->unk_A0, 0); - sub_02017258(¶m0->unk_14, ¶m0->unk_B4); - - sub_02017350(¶m0->unk_14, 0, 0, 0); - sub_0201736C(¶m0->unk_14, (FX32_ONE), (FX32_ONE), (FX32_ONE)); - sub_02017348(¶m0->unk_14, 1); - - sub_0201727C(¶m0->unk_14, ¶m0->unk_8C); - sub_0201727C(¶m0->unk_14, ¶m0->unk_A0); - } - - NARC_dtor(v0); - - param0->unk_C8 = ((0x10000 - 0x3fef) - (0x10000 - 0x1c7d)) / 30; - param0->unk_CC = (0x10000 - 0x1c7d); - param0->unk_D0 = (FX32_ONE); - param0->unk_D4 = (60 << 8); -} - -static void ov121_021D1184 (UnkStruct_ov121_021D0FF4 * param0) -{ - sub_02017110(¶m0->unk_B4); - sub_020171A0(¶m0->unk_8C, ¶m0->unk_D8); - sub_020171A0(¶m0->unk_A0, ¶m0->unk_D8); -} - -static void ov121_021D11A8 (UnkStruct_ov121_021D0FF4 * param0) -{ - VecFx32 v0, v1; - MtxFx33 v2; - - v0.x = FX32_ONE; - v0.y = FX32_ONE; - v0.z = FX32_ONE; - - v1.x = 0; - v1.y = 0; - v1.z = 0; - - MTX_Identity33(&v2); - - sub_020241B4(); - Camera_SetAsActive(param0->camera); - Camera_ComputeProjectionMatrix(0, param0->camera); - Camera_ComputeViewMatrix(); - - NNS_G3dGlbLightVector(0, 0, -FX32_ONE, 0); - NNS_G3dGlbLightColor(0, GX_RGB(28, 28, 28)); - NNS_G3dGlbMaterialColorDiffAmb(GX_RGB(31, 31, 31), GX_RGB(31, 31, 31), 0); - NNS_G3dGlbMaterialColorSpecEmi(GX_RGB(31, 31, 31), GX_RGB(31, 31, 31), 0); - NNS_G3dGlbSetBaseTrans(&v1); - NNS_G3dGlbSetBaseRot(&v2); - NNS_G3dGlbSetBaseScale(&v0); - - sub_020171CC(¶m0->unk_8C, FX32_ONE); - sub_020171CC(¶m0->unk_A0, FX32_ONE); - - NNS_G3dGePushMtx(); - - { - sub_02017294(¶m0->unk_14); - } - - NNS_G3dGePopMtx(1); -} - -static GenericPointerData * ov121_021D1270 (int param0) -{ - GenericPointerData * v0; - - v0 = sub_02024220(param0, 0, 2, 0, 2, ov121_021D128C); - return v0; -} - -static void ov121_021D128C (void) -{ - GXLayers_EngineAToggleLayers(GX_PLANEMASK_BG0, 1); - - G2_SetBG0Priority(1); - - G3X_SetShading(GX_SHADING_TOON); - G3X_AntiAlias(1); - G3X_AlphaTest(0, 0); - G3X_AlphaBlend(1); - G3X_EdgeMarking(0); - G3X_SetFog(0, GX_FOGBLEND_COLOR_ALPHA, GX_FOGSLOPE_0x8000, 0); - G3X_SetClearColor(GX_RGB(0, 0, 0), 0, 0x7fff, 63, 0); - G3_ViewPort(0, 0, 255, 191); -} - -static void ov121_021D1310 (GenericPointerData * param0) -{ - sub_020242C4(param0); -} - -static void ov121_021D1318 (UnkStruct_ov121_021D0FF4 * param0) -{ - VecFx32 v0 = {0, 0, 0}; - CameraAngle v1 = {0, 0, 0, 0}; - int v2; - - Camera_AdjustFOV(-(param0->unk_D4 >> 8), param0->camera); - param0->unk_D4 -= 0x80; - - if (param0->unk_D4 < (16 << 8)) { - param0->unk_D4 = (16 << 8); - } - - param0->unk_C4++; -} diff --git a/src/unk_0202419C.c b/src/unk_0202419C.c index 2b155b84d2..15dcd40eb5 100644 --- a/src/unk_0202419C.c +++ b/src/unk_0202419C.c @@ -22,7 +22,7 @@ void sub_020241B4 (void) G3X_Reset(); } -void sub_020241BC (GXSortMode param0, GXBufferMode param1) +void G3_RequestSwapBuffers (GXSortMode param0, GXBufferMode param1) { Unk_021C0788.unk_04 = param0; Unk_021C0788.unk_08 = param1; diff --git a/src/unk_0203D1B8.c b/src/unk_0203D1B8.c index fd9ddfcccc..a238398f24 100644 --- a/src/unk_0203D1B8.c +++ b/src/unk_0203D1B8.c @@ -151,7 +151,7 @@ #include "overlay110/ov110_021D0D80.h" #include "overlay111/ov111_021D0D80.h" #include "overlay120/ov120_021D0D80.h" -#include "overlay121/ov121_021D0D80.h" +#include "overlay121/DWWarp.h" FS_EXTERN_OVERLAY(battle); FS_EXTERN_OVERLAY(overlay19); @@ -1835,9 +1835,9 @@ void sub_0203E704 (FieldSystem * fieldSystem) static const OverlayManagerTemplate Unk_020EA368 = { - ov121_021D0D80, - ov121_021D0E7C, - ov121_021D0F14, + DWWarp_Init, + DWWarp_Main, + DWWarp_Exit, FS_OVERLAY_ID(overlay121) }; diff --git a/src/unk_0207AE68.c b/src/unk_0207AE68.c index 333c486f49..b049ef1413 100644 --- a/src/unk_0207AE68.c +++ b/src/unk_0207AE68.c @@ -179,7 +179,7 @@ static void sub_0207B0A0 (SysTask * param0, void * param1) sub_0207B180(v0); sub_02007768(v0->unk_18); sub_0207C770(); - sub_020241BC(GX_SORTMODE_MANUAL, GX_BUFFERMODE_Z); + G3_RequestSwapBuffers(GX_SORTMODE_MANUAL, GX_BUFFERMODE_Z); if (v0->unk_67) { SysTask_Done(param0); diff --git a/src/unk_0207C63C.c b/src/unk_0207C63C.c index 5f2357f124..b694270e70 100644 --- a/src/unk_0207C63C.c +++ b/src/unk_0207C63C.c @@ -105,7 +105,7 @@ void sub_0207C770 (void) } sub_020146C0(); - sub_020241BC(GX_SORTMODE_MANUAL, GX_BUFFERMODE_Z); + G3_RequestSwapBuffers(GX_SORTMODE_MANUAL, GX_BUFFERMODE_Z); } static u32 sub_0207C794 (u32 param0, BOOL param1) From f85cb3084794fba39b4947d3f615aab880bf49fb Mon Sep 17 00:00:00 2001 From: Evan Date: Thu, 20 Jun 2024 00:27:55 -0400 Subject: [PATCH 2/8] Clean up the documentation of dw_warp. --- include/constants/heap.h | 3 + .../DWWarp.h => dw_warp/dw_warp.h} | 4 +- platinum.us/main.lsf | 4 +- src/dw_warp/dw_warp.c | 370 +++++++++++++++++ src/meson.build | 2 +- src/overlay121/DWWarp.c | 385 ------------------ src/unk_0203D1B8.c | 6 +- 7 files changed, 381 insertions(+), 393 deletions(-) rename include/{overlay121/DWWarp.h => dw_warp/dw_warp.h} (74%) create mode 100644 src/dw_warp/dw_warp.c delete mode 100644 src/overlay121/DWWarp.c diff --git a/include/constants/heap.h b/include/constants/heap.h index ac824e5a8d..596a0db577 100644 --- a/include/constants/heap.h +++ b/include/constants/heap.h @@ -14,6 +14,8 @@ enum HeapId { HEAP_ID_COMMUNICATION = 15, + HEAP_ID_DISTORTION_WORLD_WARP = 30, + HEAP_ID_CHOOSE_STARTER_APP = 47, }; @@ -23,6 +25,7 @@ enum HeapSize HEAP_SIZE_POKETCH_APP = 0xc000, HEAP_SIZE_CHOOSE_STARTER_APP = 0x40000, + HEAP_SIZE_DISTORTION_WORLD_WARP = 0x50000, }; #endif // POKEPLATINUM_CONSTANTS_HEAP_H diff --git a/include/overlay121/DWWarp.h b/include/dw_warp/dw_warp.h similarity index 74% rename from include/overlay121/DWWarp.h rename to include/dw_warp/dw_warp.h index 477f30c404..518f23104e 100644 --- a/include/overlay121/DWWarp.h +++ b/include/dw_warp/dw_warp.h @@ -1,5 +1,5 @@ -#ifndef POKEPLATINUM_DWWARP_H -#define POKEPLATINUM_DWWARP_H +#ifndef POKEPLATINUM_DW_WARP_H +#define POKEPLATINUM_DW_WARP_H int DWWarp_Init(OverlayManager * ovy, int * seq); diff --git a/platinum.us/main.lsf b/platinum.us/main.lsf index 60e36c449e..d75a799588 100644 --- a/platinum.us/main.lsf +++ b/platinum.us/main.lsf @@ -1717,9 +1717,9 @@ Overlay overlay120 Object main.nef.p/src_overlay120_ov120_021D0D80.c.o } -Overlay overlay121 +Overlay dw_warp { After main - Object main.nef.p/src_overlay121_DWWarp.c.o + Object main.nef.p/src_dw_warp_dw_warp.c.o } diff --git a/src/dw_warp/dw_warp.c b/src/dw_warp/dw_warp.c new file mode 100644 index 0000000000..d5376feed0 --- /dev/null +++ b/src/dw_warp/dw_warp.c @@ -0,0 +1,370 @@ +#include +#include + +#include "core_sys.h" + +#include "struct_decls/struct_02006C24_decl.h" +#include "struct_decls/sys_task.h" +#include "struct_decls/struct_020203AC_decl.h" + +#include "struct_defs/struct_020170F4.h" +#include "struct_defs/struct_02017248.h" +#include "struct_defs/struct_02017294.h" +#include "struct_defs/struct_0207C690.h" +#include "struct_defs/struct_02099F80.h" +#include "overlay115/camera_angle.h" + +#include "unk_02002328.h" +#include "unk_02005474.h" +#include "overlay_manager.h" +#include "narc.h" +#include "unk_0200D9E8.h" +#include "unk_0200F174.h" +#include "unk_020170BC.h" +#include "unk_02017728.h" +#include "heap.h" +#include "unk_0201E3D8.h" +#include "gx_layers.h" +#include "unk_02020020.h" +#include "unk_0202419C.h" +#include "unk_02024220.h" +#include "dw_warp/dw_warp.h" + +typedef struct DistortionWorldWarp { + GenericPointerData * p3DCallback; + UnkStruct_020203AC * camera; + SysTask * task; + int frameCnt; + int soundEffectCnt; + UnkStruct_02017294 animationObj; + UnkStruct_02017248 animationAnimation; + UnkStruct_02017248 animationAnimation2; + UnkStruct_020170F4 animationModel; + u32 moveFrame; + int cameraAngle; + int cameraAngleCalc; + fx32 cameraDistance; + int cameraPerspective; + NNSFndAllocator allocator; +} DistortionWorldWarp; + +static void DW_Update(SysTask * task, void * data); +static void DW_VBlankIntr(void * data); +static void DW_VramSetBank(void); +static void DW_InitCamera(DistortionWorldWarp * warp); +static void DWWarp_CameraEnd(DistortionWorldWarp * warp); +static void DWWarp_InitModel(DistortionWorldWarp * warp); +static void DWWarp_DeleteModel(DistortionWorldWarp * warp); +static void Model3D_Update(DistortionWorldWarp * warp); +static GenericPointerData * DWWarp_Init3D(int heapId); +static void DWWarp_Setup3D(void); +static void DWWarp_Exit3D(GenericPointerData * param0); +static void DWWarp_CameraMove(DistortionWorldWarp * warp); + +int DWWarp_Init (OverlayManager * ovy, int * state) +{ + DistortionWorldWarp * dww; + + SetMainCallback(NULL, NULL); + DisableHBlank(); + GXLayers_DisableEngineALayers(); + GXLayers_DisableEngineBLayers(); + + GX_SetVisiblePlane(0); + GXS_SetVisiblePlane(0); + GX_SetVisibleWnd(GX_WNDMASK_NONE); + GXS_SetVisibleWnd(GX_WNDMASK_NONE); + G2_BlendNone(); + G2S_BlendNone(); + + Heap_Create(HEAP_ID_APPLICATION, HEAP_ID_DISTORTION_WORLD_WARP, HEAP_SIZE_DISTORTION_WORLD_WARP); + + dww = OverlayManager_NewData(ovy, sizeof(DistortionWorldWarp), HEAP_ID_DISTORTION_WORLD_WARP); + MI_CpuClear8(dww, sizeof(DistortionWorldWarp)); + dww->p3DCallback = DWWarp_Init3D(HEAP_ID_DISTORTION_WORLD_WARP); + + SetAutorepeat(4, 8); + DW_VramSetBank(); + sub_0201E3D8(); + sub_0201E450(4); + + DWWarp_InitModel(dww); + DW_InitCamera(dww); + sub_0200F174(0, 1, 1, 0x0, 16, 1, HEAP_ID_DISTORTION_WORLD_WARP); + + gCoreSys.unk_65 = 0; + + GXLayers_SwapDisplay(); + GXLayers_TurnBothDispOn(); + sub_02002AC8(1); + sub_02002AE4(0); + sub_02002B20(0); + + dww->task = SysTask_Start(DW_Update, dww, 60000); + SetMainCallback(DW_VBlankIntr, dww); + + return TRUE; +} + +enum { + DWARP_SEQ_SCREENWIPE = 0, + DWARP_SEQ_LOOP, + DWARP_SEQ_CLEAR_SCREEN, + DWARP_SEQ_WAIT +}; + +int DWWarp_Main (OverlayManager * ovy, int * state) +{ + DistortionWorldWarp * warp = OverlayManager_Data(ovy); + + // Handle the different states of the warp effect. + switch (*state) { + case DWARP_SEQ_SCREENWIPE: + if (ScreenWipe_Done() == TRUE) { + (*state)++; + } + break; + case DWARP_SEQ_LOOP: + // Play the portal sound effect after 15 frames + if (warp->soundEffectCnt == 15) { + Sound_PlayEffect(1491); + } + + warp->soundEffectCnt++; + warp->frameCnt++; + + // Continue to the next sequence after 85 frames + if (warp->frameCnt > 85) { + (*state)++; + } + break; + case DWARP_SEQ_CLEAR_SCREEN: + // Clear the screen to black + sub_0200F174(0, 0, 0, 0x0, 20, 1, 30); + (*state)++; + break; + case DWARP_SEQ_WAIT: + // Wait for the screen wipe to finish + if (ScreenWipe_Done() == TRUE) { + return 1; + } + break; + } + + DWWarp_CameraMove(warp); + + return 0; +} + +// Exits the Distortion World warp effect overlay. +int DWWarp_Exit (OverlayManager * ovy, int * state) +{ + DistortionWorldWarp * warp = OverlayManager_Data(ovy); + + SysTask_Done(warp->task); + + DWWarp_DeleteModel(warp); + DWWarp_CameraEnd(warp); + DWWarp_Exit3D(warp->p3DCallback); + + SetMainCallback(NULL, NULL); + DisableHBlank(); + sub_0201E530(); + sub_02002AC8(0); + sub_02002AE4(0); + sub_02002B20(0); + OverlayManager_FreeData(ovy); + Heap_Destroy(30); + + return TRUE; +} + +static void DW_Update (SysTask * task, void * data) +{ + DistortionWorldWarp * dw = data; + + Model3D_Update(dw); + G3_RequestSwapBuffers(GX_SORTMODE_MANUAL, GX_BUFFERMODE_W); +} + +static void DW_VBlankIntr (void * data) +{ + DistortionWorldWarp * dw = data; + OS_SetIrqCheckFlag(OS_IE_V_BLANK); +} + +static void DW_VramSetBank (void) +{ + GXLayers_DisableEngineALayers(); + GXLayers_DisableEngineBLayers(); + + UnkStruct_02099F80 vramBank = { + GX_VRAM_BG_128_C, + GX_VRAM_BGEXTPLTT_NONE, + GX_VRAM_SUB_BG_32_H, + GX_VRAM_SUB_BGEXTPLTT_NONE, + GX_VRAM_OBJ_64_E, + GX_VRAM_OBJEXTPLTT_NONE, + GX_VRAM_SUB_OBJ_16_I, + GX_VRAM_SUB_OBJEXTPLTT_NONE, + GX_VRAM_TEX_01_AB, + GX_VRAM_TEXPLTT_01_FG + }; + + GXLayers_SetBanks(&vramBank); + + MI_CpuClear32((void *)HW_BG_VRAM, HW_BG_VRAM_SIZE); + MI_CpuClear32((void *)HW_DB_BG_VRAM, HW_DB_BG_VRAM_SIZE); + MI_CpuClear32((void *)HW_OBJ_VRAM, HW_OBJ_VRAM_SIZE); + MI_CpuClear32((void *)HW_DB_OBJ_VRAM, HW_DB_OBJ_VRAM_SIZE); +} + +static void DW_InitCamera (DistortionWorldWarp * warp) +{ + static const CameraAngle DWW_CameraAngle = { + 0x10000 - 0x1c7d, + 0, + 0, + }; + VecFx32 target = {0, 0, 0}; + + warp->camera = sub_020203AC(HEAP_ID_DISTORTION_WORLD_WARP); + + sub_020206D0(&target, (160 << FX32_SHIFT), &DWW_CameraAngle, (((22 * 0xffff) / 360)), 0, 0, warp->camera); + sub_020206BC(0, (FX32_ONE * 300), warp->camera); + + CameraAngle angle = {0, 0, 0, 0}; + + angle = sub_02020A94(warp->camera); + angle.x = (0x10000 - 0x3fef); + + Camera_SetAngle(&angle, warp->camera); + + sub_020203D4(warp->camera); +} + +static void DWWarp_CameraEnd (DistortionWorldWarp * warp) +{ + sub_020203B8(warp->camera); +} + +static void DWWarp_InitModel (DistortionWorldWarp * warp) +{ + NARC * narc; + + Heap_FndInitAllocatorForExpHeap(&warp->allocator, HEAP_ID_DISTORTION_WORLD_WARP, 4); + + narc = NARC_ctor(NARC_INDEX_DEMO__TITLE__TITLEDEMO, HEAP_ID_DISTORTION_WORLD_WARP); + + sub_020170D8(&warp->animationModel, narc, 16, HEAP_ID_DISTORTION_WORLD_WARP); + + NNS_G3dMdlUseMdlAlpha(warp->animationModel.unk_08); + NNS_G3dMdlUseMdlPolygonID(warp->animationModel.unk_08); + + sub_02017164(&warp->animationAnimation, &warp->animationModel, narc, 18, HEAP_ID_DISTORTION_WORLD_WARP, &warp->allocator); + sub_02017240(&warp->animationAnimation, 0); + + sub_02017164(&warp->animationAnimation2, &warp->animationModel, narc, 17, HEAP_ID_DISTORTION_WORLD_WARP, &warp->allocator); + sub_02017240(&warp->animationAnimation2, 0); + sub_02017258(&warp->animationObj, &warp->animationModel); + + sub_02017350(&warp->animationObj, 0, 0, 0); + sub_0201736C(&warp->animationObj, FX32_ONE, FX32_ONE, FX32_ONE); + sub_02017348(&warp->animationObj, 1); + + sub_0201727C(&warp->animationObj, &warp->animationAnimation); + sub_0201727C(&warp->animationObj, &warp->animationAnimation2); + + NARC_dtor(narc); + + warp->cameraAngle = ((0x10000 - 0x3fef) - (0x10000 - 0x1c7d)) / 30; + warp->cameraAngleCalc = 0x10000 - 0x1c7d; + warp->cameraDistance = FX32_ONE; + warp->cameraPerspective = 60 << 8; +} + +static void DWWarp_DeleteModel (DistortionWorldWarp * warp) +{ + sub_02017110(&warp->animationModel); + sub_020171A0(&warp->animationAnimation, &warp->allocator); + sub_020171A0(&warp->animationAnimation2, &warp->allocator); +} + +static void Model3D_Update (DistortionWorldWarp * warp) +{ + VecFx32 scaleVec, transVec; + MtxFx33 rot33; + + scaleVec.x = FX32_ONE; + scaleVec.y = FX32_ONE; + scaleVec.z = FX32_ONE; + + transVec.x = 0; + transVec.y = 0; + transVec.z = 0; + + MTX_Identity33(&rot33); + + sub_020241B4(); + sub_020203D4(warp->camera); + sub_02020854(0, warp->camera); + sub_020203EC(); + + NNS_G3dGlbLightVector(0, 0, -FX32_ONE, 0); + NNS_G3dGlbLightColor(0, GX_RGB(28, 28, 28)); + NNS_G3dGlbMaterialColorDiffAmb(GX_RGB(31, 31, 31), GX_RGB(31, 31, 31), FALSE); + NNS_G3dGlbMaterialColorSpecEmi(GX_RGB(31, 31, 31), GX_RGB(31, 31, 31), FALSE); + NNS_G3dGlbSetBaseTrans(&transVec); + NNS_G3dGlbSetBaseRot(&rot33); + NNS_G3dGlbSetBaseScale(&scaleVec); + + sub_020171CC(&warp->animationAnimation, FX32_ONE); + sub_020171CC(&warp->animationAnimation2, FX32_ONE); + + NNS_G3dGePushMtx(); + + sub_02017294(&warp->animationObj); + NNS_G3dGePopMtx(1); +} + +static GenericPointerData * DWWarp_Init3D (int param0) +{ + return sub_02024220(param0, 0, 2, 0, 2, DWWarp_Setup3D); +} + +static void DWWarp_Setup3D (void) +{ + GXLayers_EngineAToggleLayers(GX_PLANEMASK_BG0, 1); + + G2_SetBG0Priority(1); + + G3X_SetShading(GX_SHADING_TOON); + G3X_AntiAlias(TRUE); + G3X_AlphaTest(FALSE, 0); + G3X_AlphaBlend(TRUE); + G3X_EdgeMarking(FALSE); + G3X_SetFog(FALSE, GX_FOGBLEND_COLOR_ALPHA, GX_FOGSLOPE_0x8000, 0); + G3X_SetClearColor(GX_RGB(0, 0, 0), 0, 0x7fff, 63, FALSE); + G3_ViewPort(0, 0, 255, 191); +} + +static void DWWarp_Exit3D (GenericPointerData * param0) +{ + sub_020242C4(param0); +} + +static void DWWarp_CameraMove (DistortionWorldWarp * warp) +{ + VecFx32 v0 = {0, 0, 0}; + CameraAngle v1 = {0, 0, 0, 0}; + int v2; + + sub_0202094C(-(warp->cameraPerspective >> 8), warp->camera); + warp->cameraPerspective -= 0x80; + + if (warp->cameraPerspective < (16 << 8)) { + warp->cameraPerspective = (16 << 8); + } + + warp->moveFrame++; +} diff --git a/src/meson.build b/src/meson.build index f90c4a2f9c..6208b123c7 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1020,5 +1020,5 @@ pokeplatinum_c = files( 'overlay119/ov119_021D0D80.c', 'overlay119/ov119_021D191C.c', 'overlay120/ov120_021D0D80.c', - 'overlay121/DWWarp.c' + 'dw_warp/dw_warp.c' ) diff --git a/src/overlay121/DWWarp.c b/src/overlay121/DWWarp.c deleted file mode 100644 index 4afc63bea7..0000000000 --- a/src/overlay121/DWWarp.c +++ /dev/null @@ -1,385 +0,0 @@ -#include -#include - -#include "core_sys.h" - -#include "struct_decls/struct_02006C24_decl.h" -#include "struct_decls/sys_task.h" -#include "struct_decls/struct_020203AC_decl.h" - -#include "struct_defs/struct_020170F4.h" -#include "struct_defs/struct_02017248.h" -#include "struct_defs/struct_02017294.h" -#include "struct_defs/struct_0207C690.h" -#include "struct_defs/struct_02099F80.h" -#include "overlay115/camera_angle.h" - -#include "unk_02002328.h" -#include "unk_02005474.h" -#include "overlay_manager.h" -#include "narc.h" -#include "unk_0200D9E8.h" -#include "unk_0200F174.h" -#include "unk_020170BC.h" -#include "unk_02017728.h" -#include "heap.h" -#include "unk_0201E3D8.h" -#include "gx_layers.h" -#include "unk_02020020.h" -#include "unk_0202419C.h" -#include "unk_02024220.h" -#include "overlay121/DWWarp.h" - -typedef struct { - GenericPointerData * p3DCallback; - UnkStruct_020203AC * camera; - SysTask * task; - int frame_cnt; - int soundEffect_cnt; - UnkStruct_02017294 animation_obj; - UnkStruct_02017248 animation_animation; - UnkStruct_02017248 animation_animation2; - UnkStruct_020170F4 animation_model; - u32 move_frame; - int camera_angle; - int camera_angle_calc; - fx32 camera_distance; - int camera_perspective; - NNSFndAllocator allocator; -} DistortionWorld_Warp; - -static void DW_Update(SysTask * task, void * data); -static void DW_VBlankIntr(void * data); -static void DW_VramSetBank(void); -static void DW_InitCamera(DistortionWorld_Warp * warp); -static void DWWarp_CameraEnd(DistortionWorld_Warp * warp); -static void DWWarp_InitModel(DistortionWorld_Warp * warp); -static void DWWarp_DeleteModel(DistortionWorld_Warp * warp); -static void Model3D_Update(DistortionWorld_Warp * warp); -static GenericPointerData * DWWarp_Init3D(int heapId); -static void DWWarp_Setup3D(void); -static void DWWarp_Exit3D(GenericPointerData * param0); -static void DWWarp_CameraMove(DistortionWorld_Warp * warp); - -// Initializes the Distortion World warp effect overlay. -int DWWarp_Init (OverlayManager * ovy, int * seq) -{ - DistortionWorld_Warp * dww; - - SetMainCallback(NULL, NULL); - DisableHBlank(); - GXLayers_DisableEngineALayers(); - GXLayers_DisableEngineBLayers(); - - GX_SetVisiblePlane(0); - GXS_SetVisiblePlane(0); - GX_SetVisibleWnd(GX_WNDMASK_NONE); - GXS_SetVisibleWnd(GX_WNDMASK_NONE); - G2_BlendNone(); - G2S_BlendNone(); - - Heap_Create(3, 30, 0x50000); - - dww = OverlayManager_NewData(ovy, sizeof(DistortionWorld_Warp), 30); - MI_CpuClear8(dww, sizeof(DistortionWorld_Warp)); - dww->p3DCallback = DWWarp_Init3D(30); - - SetAutorepeat(4, 8); - DW_VramSetBank(); - sub_0201E3D8(); - sub_0201E450(4); - - DWWarp_InitModel(dww); - DW_InitCamera(dww); - sub_0200F174(0, 1, 1, 0x0, 16, 1, 30); - - gCoreSys.unk_65 = 0; - - GXLayers_SwapDisplay(); - GXLayers_TurnBothDispOn(); - sub_02002AC8(1); - sub_02002AE4(0); - sub_02002B20(0); - - dww->task = SysTask_Start(DW_Update, dww, 60000); - SetMainCallback(DW_VBlankIntr, dww); - - return TRUE; -} - -enum { - DWARP_SEQ_SCREENWIPE = 0, - DWARP_SEQ_LOOP, - DWARP_SEQ_CLEAR_SCREEN, - DWARP_SEQ_WAIT -}; - -int DWWarp_Main (OverlayManager * ovy, int * seq) -{ - DistortionWorld_Warp * warp = OverlayManager_Data(ovy); - - // Handle the different states of the warp effect. - switch (*seq) { - case DWARP_SEQ_SCREENWIPE: - if (ScreenWipe_Done() == TRUE) { - (*seq)++; - } - break; - case DWARP_SEQ_LOOP: - // Play the portal sound effect after 15 frames - if (warp->soundEffect_cnt == 15) { - Sound_PlayEffect(1491); - } - - warp->soundEffect_cnt++; - warp->frame_cnt++; - - // Continue to the next sequence after 85 frames - if (warp->frame_cnt > 85) { - (*seq)++; - } - break; - case DWARP_SEQ_CLEAR_SCREEN: - // Clear the screen to black - sub_0200F174(0, 0, 0, 0x0, 20, 1, 30); - (*seq)++; - break; - case DWARP_SEQ_WAIT: - // Wait for the screen wipe to finish - if (ScreenWipe_Done() == TRUE) { - return 1; - } - break; - } - - DWWarp_CameraMove(warp); - - return 0; -} - -// Exits the Distortion World warp effect overlay. -int DWWarp_Exit (OverlayManager * ovy, int * seq) -{ - DistortionWorld_Warp * warp = OverlayManager_Data(ovy); - - SysTask_Done(warp->task); - - DWWarp_DeleteModel(warp); - DWWarp_CameraEnd(warp); - DWWarp_Exit3D(warp->p3DCallback); - - SetMainCallback(NULL, NULL); - DisableHBlank(); - sub_0201E530(); - sub_02002AC8(0); - sub_02002AE4(0); - sub_02002B20(0); - OverlayManager_FreeData(ovy); - Heap_Destroy(30); - - return TRUE; -} - -static void DW_Update (SysTask * task, void * data) -{ - DistortionWorld_Warp * dw = data; - - Model3D_Update(dw); - G3_RequestSwapBuffers(GX_SORTMODE_MANUAL, GX_BUFFERMODE_W); -} - -static void DW_VBlankIntr (void * data) -{ - DistortionWorld_Warp * dw = data; - OS_SetIrqCheckFlag(OS_IE_V_BLANK); -} - -static void DW_VramSetBank (void) -{ - GXLayers_DisableEngineALayers(); - GXLayers_DisableEngineBLayers(); - - { - UnkStruct_02099F80 vramBank = { - GX_VRAM_BG_128_C, - GX_VRAM_BGEXTPLTT_NONE, - GX_VRAM_SUB_BG_32_H, - GX_VRAM_SUB_BGEXTPLTT_NONE, - GX_VRAM_OBJ_64_E, - GX_VRAM_OBJEXTPLTT_NONE, - GX_VRAM_SUB_OBJ_16_I, - GX_VRAM_SUB_OBJEXTPLTT_NONE, - GX_VRAM_TEX_01_AB, - GX_VRAM_TEXPLTT_01_FG - }; - - GXLayers_SetBanks(&vramBank); - - MI_CpuClear32((void *)HW_BG_VRAM, HW_BG_VRAM_SIZE); - MI_CpuClear32((void *)HW_DB_BG_VRAM, HW_DB_BG_VRAM_SIZE); - MI_CpuClear32((void *)HW_OBJ_VRAM, HW_OBJ_VRAM_SIZE); - MI_CpuClear32((void *)HW_DB_OBJ_VRAM, HW_DB_OBJ_VRAM_SIZE); - } -} - -static void DW_InitCamera (DistortionWorld_Warp * warp) -{ - { - static const CameraAngle DWW_CameraAngle = { - (0x10000 - 0x1c7d), - ((0 * 0xffff) / 360), - ((0 * 0xffff) / 360), - }; - VecFx32 target = {0, 0, 0}; - - warp->camera = sub_020203AC(30); - - sub_020206D0(&target, (160 << FX32_SHIFT), &DWW_CameraAngle, (((22 * 0xffff) / 360)), 0, 0, warp->camera); - sub_020206BC(0, (FX32_ONE * 300), warp->camera); - - { - CameraAngle angle = {0, 0, 0, 0}; - - angle = sub_02020A94(warp->camera); - angle.x = (0x10000 - 0x3fef); - - Camera_SetAngle(&angle, warp->camera); - } - - sub_020203D4(warp->camera); - } -} - -static void DWWarp_CameraEnd (DistortionWorld_Warp * warp) -{ - sub_020203B8(warp->camera); -} - -static void DWWarp_InitModel (DistortionWorld_Warp * warp) -{ - NARC * narc; - - Heap_FndInitAllocatorForExpHeap(&warp->allocator, 30, 4); - - narc = NARC_ctor(NARC_INDEX_DEMO__TITLE__TITLEDEMO, 30); - - { - sub_020170D8(&warp->animation_model, narc, 16, 30); - - NNS_G3dMdlUseMdlAlpha(warp->animation_model.unk_08); - NNS_G3dMdlUseMdlPolygonID(warp->animation_model.unk_08); - - sub_02017164(&warp->animation_animation, &warp->animation_model, narc, 18, 30, &warp->allocator); - sub_02017240(&warp->animation_animation, 0); - - sub_02017164(&warp->animation_animation2, &warp->animation_model, narc, 17, 30, &warp->allocator); - sub_02017240(&warp->animation_animation2, 0); - sub_02017258(&warp->animation_obj, &warp->animation_model); - - sub_02017350(&warp->animation_obj, 0, 0, 0); - sub_0201736C(&warp->animation_obj, (FX32_ONE), (FX32_ONE), (FX32_ONE)); - sub_02017348(&warp->animation_obj, 1); - - sub_0201727C(&warp->animation_obj, &warp->animation_animation); - sub_0201727C(&warp->animation_obj, &warp->animation_animation2); - } - - NARC_dtor(narc); - - warp->camera_angle = ((0x10000 - 0x3fef) - (0x10000 - 0x1c7d)) / 30; - warp->camera_angle_calc = (0x10000 - 0x1c7d); - warp->camera_distance = (FX32_ONE); - warp->camera_perspective = (60 << 8); -} - -static void DWWarp_DeleteModel (DistortionWorld_Warp * warp) -{ - sub_02017110(&warp->animation_model); - sub_020171A0(&warp->animation_animation, &warp->allocator); - sub_020171A0(&warp->animation_animation2, &warp->allocator); -} - -static void Model3D_Update (DistortionWorld_Warp * warp) -{ - VecFx32 scaleVec, transVec; - MtxFx33 rot33; - - scaleVec.x = FX32_ONE; - scaleVec.y = FX32_ONE; - scaleVec.z = FX32_ONE; - - transVec.x = 0; - transVec.y = 0; - transVec.z = 0; - - MTX_Identity33(&rot33); - - sub_020241B4(); - sub_020203D4(warp->camera); - sub_02020854(0, warp->camera); - sub_020203EC(); - - NNS_G3dGlbLightVector(0, 0, -FX32_ONE, 0); - NNS_G3dGlbLightColor(0, GX_RGB(28, 28, 28)); - NNS_G3dGlbMaterialColorDiffAmb(GX_RGB(31, 31, 31), GX_RGB(31, 31, 31), FALSE); - NNS_G3dGlbMaterialColorSpecEmi(GX_RGB(31, 31, 31), GX_RGB(31, 31, 31), FALSE); - NNS_G3dGlbSetBaseTrans(&transVec); - NNS_G3dGlbSetBaseRot(&rot33); - NNS_G3dGlbSetBaseScale(&scaleVec); - - sub_020171CC(&warp->animation_animation, FX32_ONE); - sub_020171CC(&warp->animation_animation2, FX32_ONE); - - NNS_G3dGePushMtx(); - - { - sub_02017294(&warp->animation_obj); - } - - NNS_G3dGePopMtx(1); -} - -static GenericPointerData * DWWarp_Init3D (int param0) -{ - GenericPointerData * v0; - - v0 = sub_02024220(param0, 0, 2, 0, 2, DWWarp_Setup3D); - return v0; -} - -static void DWWarp_Setup3D (void) -{ - GXLayers_EngineAToggleLayers(GX_PLANEMASK_BG0, 1); - - G2_SetBG0Priority(1); - - G3X_SetShading(GX_SHADING_TOON); - G3X_AntiAlias(TRUE); - G3X_AlphaTest(FALSE, 0); - G3X_AlphaBlend(TRUE); - G3X_EdgeMarking(FALSE); - G3X_SetFog(FALSE, GX_FOGBLEND_COLOR_ALPHA, GX_FOGSLOPE_0x8000, 0); - G3X_SetClearColor(GX_RGB(0, 0, 0), 0, 0x7fff, 63, FALSE); - G3_ViewPort(0, 0, 255, 191); -} - -static void DWWarp_Exit3D (GenericPointerData * param0) -{ - sub_020242C4(param0); -} - -static void DWWarp_CameraMove (DistortionWorld_Warp * warp) -{ - VecFx32 v0 = {0, 0, 0}; - CameraAngle v1 = {0, 0, 0, 0}; - int v2; - - sub_0202094C(-(warp->camera_perspective >> 8), warp->camera); - warp->camera_perspective -= 0x80; - - if (warp->camera_perspective < (16 << 8)) { - warp->camera_perspective = (16 << 8); - } - - warp->move_frame++; -} diff --git a/src/unk_0203D1B8.c b/src/unk_0203D1B8.c index a238398f24..0bbeb9514b 100644 --- a/src/unk_0203D1B8.c +++ b/src/unk_0203D1B8.c @@ -151,7 +151,7 @@ #include "overlay110/ov110_021D0D80.h" #include "overlay111/ov111_021D0D80.h" #include "overlay120/ov120_021D0D80.h" -#include "overlay121/DWWarp.h" +#include "dw_warp/dw_warp.h" FS_EXTERN_OVERLAY(battle); FS_EXTERN_OVERLAY(overlay19); @@ -186,7 +186,7 @@ FS_EXTERN_OVERLAY(overlay102); FS_EXTERN_OVERLAY(overlay110); FS_EXTERN_OVERLAY(overlay111); FS_EXTERN_OVERLAY(overlay120); -FS_EXTERN_OVERLAY(overlay121); +FS_EXTERN_OVERLAY(dw_warp); #include @@ -1838,7 +1838,7 @@ static const OverlayManagerTemplate Unk_020EA368 = { DWWarp_Init, DWWarp_Main, DWWarp_Exit, - FS_OVERLAY_ID(overlay121) + FS_OVERLAY_ID(dw_warp) }; void sub_0203E714 (FieldSystem * fieldSystem) From e08da6a0f0bc17a5909fd64c68b25916a25e9ccc Mon Sep 17 00:00:00 2001 From: Evan Date: Thu, 20 Jun 2024 00:32:16 -0400 Subject: [PATCH 3/8] Fix: Make dww inlined. --- src/dw_warp/dw_warp.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/dw_warp/dw_warp.c b/src/dw_warp/dw_warp.c index d5376feed0..2fcffe6617 100644 --- a/src/dw_warp/dw_warp.c +++ b/src/dw_warp/dw_warp.c @@ -63,8 +63,6 @@ static void DWWarp_CameraMove(DistortionWorldWarp * warp); int DWWarp_Init (OverlayManager * ovy, int * state) { - DistortionWorldWarp * dww; - SetMainCallback(NULL, NULL); DisableHBlank(); GXLayers_DisableEngineALayers(); @@ -79,7 +77,7 @@ int DWWarp_Init (OverlayManager * ovy, int * state) Heap_Create(HEAP_ID_APPLICATION, HEAP_ID_DISTORTION_WORLD_WARP, HEAP_SIZE_DISTORTION_WORLD_WARP); - dww = OverlayManager_NewData(ovy, sizeof(DistortionWorldWarp), HEAP_ID_DISTORTION_WORLD_WARP); + DistortionWorldWarp* dww = OverlayManager_NewData(ovy, sizeof(DistortionWorldWarp), HEAP_ID_DISTORTION_WORLD_WARP); MI_CpuClear8(dww, sizeof(DistortionWorldWarp)); dww->p3DCallback = DWWarp_Init3D(HEAP_ID_DISTORTION_WORLD_WARP); From 5b6282a89fdf3015b856e2d172fb25110d08b2ab Mon Sep 17 00:00:00 2001 From: Evan Date: Thu, 20 Jun 2024 21:31:56 -0400 Subject: [PATCH 4/8] Fix: Update sbins.sha1 --- platinum.us/sbins.sha1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platinum.us/sbins.sha1 b/platinum.us/sbins.sha1 index 60ba9cf655..222066c8bd 100644 --- a/platinum.us/sbins.sha1 +++ b/platinum.us/sbins.sha1 @@ -120,4 +120,4 @@ dd0e40ce15f9bc1eccf25bc29f481a1835098c7b *overlay115.sbin babc139fb62af0f7e4320b62089eaed7b2dfa3bb *overlay118.sbin 76b46eb4dd4d8b21665e7a2488cccf060911cc0a *overlay119.sbin 637cf7c59d68702453016a1bf2a1c0d101809912 *overlay120.sbin -67a01b02f9d9c8135e57bf274c6a75bf0c2c9be2 *overlay121.sbin +67a01b02f9d9c8135e57bf274c6a75bf0c2c9be2 *dw_warp.sbin From 86ac74e97af68c17bb20ef327ff92dfa93a17681 Mon Sep 17 00:00:00 2001 From: Evan Date: Fri, 21 Jun 2024 03:33:39 -0400 Subject: [PATCH 5/8] Fix: Clean up dw_warp more. --- include/dw_warp/dw_warp.h | 6 +++--- src/dw_warp/dw_warp.c | 32 ++++++++++++++------------------ 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/include/dw_warp/dw_warp.h b/include/dw_warp/dw_warp.h index 518f23104e..63d172d867 100644 --- a/include/dw_warp/dw_warp.h +++ b/include/dw_warp/dw_warp.h @@ -2,8 +2,8 @@ #define POKEPLATINUM_DW_WARP_H -int DWWarp_Init(OverlayManager * ovy, int * seq); -int DWWarp_Main(OverlayManager * ovy, int * seq); -int DWWarp_Exit(OverlayManager * ovy, int * seq); +BOOL DWWarp_Init(OverlayManager * ovy, int * seq); +BOOL DWWarp_Main(OverlayManager * ovy, int * seq); +BOOL DWWarp_Exit(OverlayManager * ovy, int * seq); #endif // POKEPLATINUM_DWWARP_H diff --git a/src/dw_warp/dw_warp.c b/src/dw_warp/dw_warp.c index 2fcffe6617..17eaa82ebd 100644 --- a/src/dw_warp/dw_warp.c +++ b/src/dw_warp/dw_warp.c @@ -29,6 +29,10 @@ #include "unk_0202419C.h" #include "unk_02024220.h" #include "dw_warp/dw_warp.h" +#include "consts/sdat.h" + +#define DWARP_SND_EFFECT_DELAY 15 +#define DWARP_ANM_DURATION 85 typedef struct DistortionWorldWarp { GenericPointerData * p3DCallback; @@ -61,7 +65,7 @@ static void DWWarp_Setup3D(void); static void DWWarp_Exit3D(GenericPointerData * param0); static void DWWarp_CameraMove(DistortionWorldWarp * warp); -int DWWarp_Init (OverlayManager * ovy, int * state) +BOOL DWWarp_Init (OverlayManager * ovy, int * state) { SetMainCallback(NULL, NULL); DisableHBlank(); @@ -111,11 +115,10 @@ enum { DWARP_SEQ_WAIT }; -int DWWarp_Main (OverlayManager * ovy, int * state) +BOOL DWWarp_Main (OverlayManager * ovy, int * state) { DistortionWorldWarp * warp = OverlayManager_Data(ovy); - // Handle the different states of the warp effect. switch (*state) { case DWARP_SEQ_SCREENWIPE: if (ScreenWipe_Done() == TRUE) { @@ -123,39 +126,34 @@ int DWWarp_Main (OverlayManager * ovy, int * state) } break; case DWARP_SEQ_LOOP: - // Play the portal sound effect after 15 frames - if (warp->soundEffectCnt == 15) { - Sound_PlayEffect(1491); + if (warp->soundEffectCnt == DWARP_SND_EFFECT_DELAY) { + Sound_PlayEffect( SEQ_SE_PL_SYUWA2 ); } warp->soundEffectCnt++; warp->frameCnt++; - // Continue to the next sequence after 85 frames - if (warp->frameCnt > 85) { + if (warp->frameCnt > DWARP_ANM_DURATION) { (*state)++; } break; case DWARP_SEQ_CLEAR_SCREEN: - // Clear the screen to black sub_0200F174(0, 0, 0, 0x0, 20, 1, 30); (*state)++; break; case DWARP_SEQ_WAIT: - // Wait for the screen wipe to finish if (ScreenWipe_Done() == TRUE) { - return 1; + return TRUE; } break; } DWWarp_CameraMove(warp); - return 0; + return FALSE; } -// Exits the Distortion World warp effect overlay. -int DWWarp_Exit (OverlayManager * ovy, int * state) +BOOL DWWarp_Exit (OverlayManager * ovy, int * state) { DistortionWorldWarp * warp = OverlayManager_Data(ovy); @@ -172,7 +170,7 @@ int DWWarp_Exit (OverlayManager * ovy, int * state) sub_02002AE4(0); sub_02002B20(0); OverlayManager_FreeData(ovy); - Heap_Destroy(30); + Heap_Destroy(HEAP_ID_DISTORTION_WORLD_WARP); return TRUE; } @@ -248,11 +246,9 @@ static void DWWarp_CameraEnd (DistortionWorldWarp * warp) static void DWWarp_InitModel (DistortionWorldWarp * warp) { - NARC * narc; - Heap_FndInitAllocatorForExpHeap(&warp->allocator, HEAP_ID_DISTORTION_WORLD_WARP, 4); - narc = NARC_ctor(NARC_INDEX_DEMO__TITLE__TITLEDEMO, HEAP_ID_DISTORTION_WORLD_WARP); + NARC * narc = NARC_ctor(NARC_INDEX_DEMO__TITLE__TITLEDEMO, HEAP_ID_DISTORTION_WORLD_WARP); sub_020170D8(&warp->animationModel, narc, 16, HEAP_ID_DISTORTION_WORLD_WARP); From 760014cb46f6760d12f15e4995f7a9bb155123b2 Mon Sep 17 00:00:00 2001 From: Evan Date: Fri, 21 Jun 2024 04:10:46 -0400 Subject: [PATCH 6/8] Update dw_warp.c func names to be uniform. --- src/dw_warp/dw_warp.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/dw_warp/dw_warp.c b/src/dw_warp/dw_warp.c index 17eaa82ebd..700f2bd6ef 100644 --- a/src/dw_warp/dw_warp.c +++ b/src/dw_warp/dw_warp.c @@ -52,10 +52,10 @@ typedef struct DistortionWorldWarp { NNSFndAllocator allocator; } DistortionWorldWarp; -static void DW_Update(SysTask * task, void * data); -static void DW_VBlankIntr(void * data); -static void DW_VramSetBank(void); -static void DW_InitCamera(DistortionWorldWarp * warp); +static void DWWarp_Update(SysTask * task, void * data); +static void DWWarp_VBlankIntr(void * data); +static void DWWarp_VramSetBank(void); +static void DWWarp_InitCamera(DistortionWorldWarp * warp); static void DWWarp_CameraEnd(DistortionWorldWarp * warp); static void DWWarp_InitModel(DistortionWorldWarp * warp); static void DWWarp_DeleteModel(DistortionWorldWarp * warp); @@ -86,12 +86,12 @@ BOOL DWWarp_Init (OverlayManager * ovy, int * state) dww->p3DCallback = DWWarp_Init3D(HEAP_ID_DISTORTION_WORLD_WARP); SetAutorepeat(4, 8); - DW_VramSetBank(); + DWWarp_VramSetBank(); sub_0201E3D8(); sub_0201E450(4); DWWarp_InitModel(dww); - DW_InitCamera(dww); + DWWarp_InitCamera(dww); sub_0200F174(0, 1, 1, 0x0, 16, 1, HEAP_ID_DISTORTION_WORLD_WARP); gCoreSys.unk_65 = 0; @@ -102,8 +102,8 @@ BOOL DWWarp_Init (OverlayManager * ovy, int * state) sub_02002AE4(0); sub_02002B20(0); - dww->task = SysTask_Start(DW_Update, dww, 60000); - SetMainCallback(DW_VBlankIntr, dww); + dww->task = SysTask_Start(DWWarp_Update, dww, 60000); + SetMainCallback(DWWarp_VBlankIntr, dww); return TRUE; } @@ -175,7 +175,7 @@ BOOL DWWarp_Exit (OverlayManager * ovy, int * state) return TRUE; } -static void DW_Update (SysTask * task, void * data) +static void DWWarp_Update (SysTask * task, void * data) { DistortionWorldWarp * dw = data; @@ -183,13 +183,13 @@ static void DW_Update (SysTask * task, void * data) G3_RequestSwapBuffers(GX_SORTMODE_MANUAL, GX_BUFFERMODE_W); } -static void DW_VBlankIntr (void * data) +static void DWWarp_VBlankIntr (void * data) { DistortionWorldWarp * dw = data; OS_SetIrqCheckFlag(OS_IE_V_BLANK); } -static void DW_VramSetBank (void) +static void DWWarp_VramSetBank (void) { GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -215,7 +215,7 @@ static void DW_VramSetBank (void) MI_CpuClear32((void *)HW_DB_OBJ_VRAM, HW_DB_OBJ_VRAM_SIZE); } -static void DW_InitCamera (DistortionWorldWarp * warp) +static void DWWarp_InitCamera (DistortionWorldWarp * warp) { static const CameraAngle DWW_CameraAngle = { 0x10000 - 0x1c7d, From 15b6075ac9ebba6ee7a172066f978d5f4225e25e Mon Sep 17 00:00:00 2001 From: Evan Date: Fri, 21 Jun 2024 14:47:26 -0400 Subject: [PATCH 7/8] Fix: Update to new camera function names. --- src/dw_warp/dw_warp.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/dw_warp/dw_warp.c b/src/dw_warp/dw_warp.c index 700f2bd6ef..095b4cf380 100644 --- a/src/dw_warp/dw_warp.c +++ b/src/dw_warp/dw_warp.c @@ -5,7 +5,6 @@ #include "struct_decls/struct_02006C24_decl.h" #include "struct_decls/sys_task.h" -#include "struct_decls/struct_020203AC_decl.h" #include "struct_defs/struct_020170F4.h" #include "struct_defs/struct_02017248.h" @@ -25,7 +24,7 @@ #include "heap.h" #include "unk_0201E3D8.h" #include "gx_layers.h" -#include "unk_02020020.h" +#include "camera.h" #include "unk_0202419C.h" #include "unk_02024220.h" #include "dw_warp/dw_warp.h" @@ -36,7 +35,7 @@ typedef struct DistortionWorldWarp { GenericPointerData * p3DCallback; - UnkStruct_020203AC * camera; + Camera * camera; SysTask * task; int frameCnt; int soundEffectCnt; @@ -56,7 +55,7 @@ static void DWWarp_Update(SysTask * task, void * data); static void DWWarp_VBlankIntr(void * data); static void DWWarp_VramSetBank(void); static void DWWarp_InitCamera(DistortionWorldWarp * warp); -static void DWWarp_CameraEnd(DistortionWorldWarp * warp); +static void DWWarp_DeleteCamera(DistortionWorldWarp * warp); static void DWWarp_InitModel(DistortionWorldWarp * warp); static void DWWarp_DeleteModel(DistortionWorldWarp * warp); static void Model3D_Update(DistortionWorldWarp * warp); @@ -160,7 +159,7 @@ BOOL DWWarp_Exit (OverlayManager * ovy, int * state) SysTask_Done(warp->task); DWWarp_DeleteModel(warp); - DWWarp_CameraEnd(warp); + DWWarp_DeleteCamera(warp); DWWarp_Exit3D(warp->p3DCallback); SetMainCallback(NULL, NULL); @@ -224,24 +223,24 @@ static void DWWarp_InitCamera (DistortionWorldWarp * warp) }; VecFx32 target = {0, 0, 0}; - warp->camera = sub_020203AC(HEAP_ID_DISTORTION_WORLD_WARP); + warp->camera = Camera_Alloc(HEAP_ID_DISTORTION_WORLD_WARP); - sub_020206D0(&target, (160 << FX32_SHIFT), &DWW_CameraAngle, (((22 * 0xffff) / 360)), 0, 0, warp->camera); - sub_020206BC(0, (FX32_ONE * 300), warp->camera); + Camera_InitWithTarget(&target, (160 << FX32_SHIFT), &DWW_CameraAngle, (((22 * 0xffff) / 360)), 0, 0, warp->camera); + Camera_SetClipping(0, (FX32_ONE * 300), warp->camera); CameraAngle angle = {0, 0, 0, 0}; - angle = sub_02020A94(warp->camera); + angle = Camera_GetAngle(warp->camera); angle.x = (0x10000 - 0x3fef); - Camera_SetAngle(&angle, warp->camera); + Camera_SetAngleAroundTarget(&angle, warp->camera); - sub_020203D4(warp->camera); + Camera_SetAsActive(warp->camera); } -static void DWWarp_CameraEnd (DistortionWorldWarp * warp) +static void DWWarp_DeleteCamera (DistortionWorldWarp * warp) { - sub_020203B8(warp->camera); + Camera_Delete(warp->camera); } static void DWWarp_InitModel (DistortionWorldWarp * warp) @@ -300,9 +299,9 @@ static void Model3D_Update (DistortionWorldWarp * warp) MTX_Identity33(&rot33); sub_020241B4(); - sub_020203D4(warp->camera); - sub_02020854(0, warp->camera); - sub_020203EC(); + Camera_SetAsActive(warp->camera); + Camera_ComputeProjectionMatrix(0, warp->camera); + Camera_ComputeViewMatrix(); NNS_G3dGlbLightVector(0, 0, -FX32_ONE, 0); NNS_G3dGlbLightColor(0, GX_RGB(28, 28, 28)); @@ -353,7 +352,7 @@ static void DWWarp_CameraMove (DistortionWorldWarp * warp) CameraAngle v1 = {0, 0, 0, 0}; int v2; - sub_0202094C(-(warp->cameraPerspective >> 8), warp->camera); + Camera_AdjustFOV(-(warp->cameraPerspective >> 8), warp->camera); warp->cameraPerspective -= 0x80; if (warp->cameraPerspective < (16 << 8)) { From 62bf88cb5dfdf2055fa3fcc532edaf615733f445 Mon Sep 17 00:00:00 2001 From: Evan Date: Fri, 21 Jun 2024 14:55:26 -0400 Subject: [PATCH 8/8] Fix: Change included files after merge. --- src/dw_warp/dw_warp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/dw_warp/dw_warp.c b/src/dw_warp/dw_warp.c index 095b4cf380..dacf9e59e7 100644 --- a/src/dw_warp/dw_warp.c +++ b/src/dw_warp/dw_warp.c @@ -4,7 +4,7 @@ #include "core_sys.h" #include "struct_decls/struct_02006C24_decl.h" -#include "struct_decls/sys_task.h" +#include "sys_task_manager.h" #include "struct_defs/struct_020170F4.h" #include "struct_defs/struct_02017248.h" @@ -17,7 +17,7 @@ #include "unk_02005474.h" #include "overlay_manager.h" #include "narc.h" -#include "unk_0200D9E8.h" +#include "sys_task.h" #include "unk_0200F174.h" #include "unk_020170BC.h" #include "unk_02017728.h" @@ -28,6 +28,7 @@ #include "unk_0202419C.h" #include "unk_02024220.h" #include "dw_warp/dw_warp.h" + #include "consts/sdat.h" #define DWARP_SND_EFFECT_DELAY 15