Skip to content

Commit

Permalink
d_t_ship_window "OK" (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
robojumper authored Oct 6, 2024
1 parent b83c0d5 commit 8376edc
Show file tree
Hide file tree
Showing 7 changed files with 241 additions and 57 deletions.
4 changes: 3 additions & 1 deletion config/SOUE01/rels/d_t_ship_windowNP/splits.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Sections:
.text type:code align:16
.ctors type:rodata align:4
.dtors type:rodata align:4
.rodata type:rodata align:16
.data type:data align:16
.bss type:bss align:8

REL/executor.c:
Expand All @@ -16,3 +16,5 @@ REL/global_destructor_chain.c:
REL/d/t/d_t_ship_window.cpp:
.text start:0x000000F0 end:0x00001048
.ctors start:0x00000000 end:0x00000004
.data start:0x00000000 end:0x00000254
.bss start:0x00000008 end:0x00000088
106 changes: 53 additions & 53 deletions config/SOUE01/rels/d_t_ship_windowNP/symbols.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,60 +3,60 @@ _epilog = .text:0x00000030; // type:function size:0x2C scope:global
_unresolved = .text:0x00000060; // type:function size:0x4 scope:global
__register_global_object = .text:0x00000070; // type:function size:0x1C scope:global
__destroy_global_chain = .text:0x00000090; // type:function size:0x54 scope:global
fn_449_F0 = .text:0x000000F0; // type:function size:0xBC
fn_449_1B0 = .text:0x000001B0; // type:function size:0x58
fn_449_210 = .text:0x00000210; // type:function size:0x58
fn_449_270 = .text:0x00000270; // type:function size:0x6C
fn_449_2E0 = .text:0x000002E0; // type:function size:0xA0
fn_449_380 = .text:0x00000380; // type:function size:0xA4
fn_449_430 = .text:0x00000430; // type:function size:0x108
fn_449_540 = .text:0x00000540; // type:function size:0x10
fn_449_550 = .text:0x00000550; // type:function size:0x8
fn_449_560 = .text:0x00000560; // type:function size:0x30
fn_449_590 = .text:0x00000590; // type:function size:0x10
fn_449_5A0 = .text:0x000005A0; // type:function size:0x134
fn_449_6E0 = .text:0x000006E0; // type:function size:0x10
fn_449_6F0 = .text:0x000006F0; // type:function size:0x8
fn_449_700 = .text:0x00000700; // type:function size:0x4
fn_449_710 = .text:0x00000710; // type:function size:0x1E0
fn_449_8F0 = .text:0x000008F0; // type:function size:0x4
fn_449_900 = .text:0x00000900; // type:function size:0x4
fn_449_910 = .text:0x00000910; // type:function size:0x1E0
fn_449_AF0 = .text:0x00000AF0; // type:function size:0x4
fn_449_B00 = .text:0x00000B00; // type:function size:0xD4
fn_449_BE0 = .text:0x00000BE0; // type:function size:0x60
fn_449_C40 = .text:0x00000C40; // type:function size:0xC
fn_449_C50 = .text:0x00000C50; // type:function size:0x1C
fn_449_C70 = .text:0x00000C70; // type:function size:0x1C
fn_449_C90 = .text:0x00000C90; // type:function size:0x1C
fn_449_CB0 = .text:0x00000CB0; // type:function size:0x10
fn_449_CC0 = .text:0x00000CC0; // type:function size:0x10
fn_449_CD0 = .text:0x00000CD0; // type:function size:0x10
fn_449_CE0 = .text:0x00000CE0; // type:function size:0x10
fn_449_CF0 = .text:0x00000CF0; // type:function size:0x10
fn_449_D00 = .text:0x00000D00; // type:function size:0x10
fn_449_D10 = .text:0x00000D10; // type:function size:0x30
fn_449_D40 = .text:0x00000D40; // type:function size:0x30
fn_449_D70 = .text:0x00000D70; // type:function size:0x30
fn_449_DA0 = .text:0x00000DA0; // type:function size:0x1C0
fn_449_F60 = .text:0x00000F60; // type:function size:0x58
fn_449_FC0 = .text:0x00000FC0; // type:function size:0x88
dTgShipWindow_c_classInit__Fv = .text:0x000000F0; // type:function size:0xBC
__dt__5dTg_cFv = .text:0x000001B0; // type:function size:0x58
__dt__28sFState_c<15dTgShipWindow_c>Fv = .text:0x00000210; // type:function size:0x58
__dt__31sFStateFct_c<15dTgShipWindow_c>Fv = .text:0x00000270; // type:function size:0x6C
__dt__84sStateMgr_c<15dTgShipWindow_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x000002E0; // type:function size:0xA0
__dt__54sFStateMgr_c<15dTgShipWindow_c,20sStateMethodUsr_FI_c>Fv = .text:0x00000380; // type:function size:0xA4
create__15dTgShipWindow_cFv = .text:0x00000430; // type:function size:0x108
changeState__84sStateMgr_c<15dTgShipWindow_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>FRC12sStateIDIf_c = .text:0x00000540; // type:function size:0x10
doDelete__15dTgShipWindow_cFv = .text:0x00000550; // type:function size:0x8
actorExecute__15dTgShipWindow_cFv = .text:0x00000560; // type:function size:0x30
executeState__84sStateMgr_c<15dTgShipWindow_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x00000590; // type:function size:0x10
actorExecuteInEvent__15dTgShipWindow_cFv = .text:0x000005A0; // type:function size:0x134
getStateID__84sStateMgr_c<15dTgShipWindow_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x000006E0; // type:function size:0x10
draw__15dTgShipWindow_cFv = .text:0x000006F0; // type:function size:0x8
initializeState_Off__15dTgShipWindow_cFv = .text:0x00000700; // type:function size:0x4
executeState_Off__15dTgShipWindow_cFv = .text:0x00000710; // type:function size:0x1E0
finalizeState_Off__15dTgShipWindow_cFv = .text:0x000008F0; // type:function size:0x4
initializeState_On__15dTgShipWindow_cFv = .text:0x00000900; // type:function size:0x4
executeState_On__15dTgShipWindow_cFv = .text:0x00000910; // type:function size:0x1E0
finalizeState_On__15dTgShipWindow_cFv = .text:0x00000AF0; // type:function size:0x4
__dt__15dTgShipWindow_cFv = .text:0x00000B00; // type:function size:0xD4
build__31sFStateFct_c<15dTgShipWindow_c>FRC12sStateIDIf_c = .text:0x00000BE0; // type:function size:0x60
dispose__31sFStateFct_c<15dTgShipWindow_c>FRP10sStateIf_c = .text:0x00000C40; // type:function size:0xC
initialize__28sFState_c<15dTgShipWindow_c>Fv = .text:0x00000C50; // type:function size:0x1C
execute__28sFState_c<15dTgShipWindow_c>Fv = .text:0x00000C70; // type:function size:0x1C
finalize__28sFState_c<15dTgShipWindow_c>Fv = .text:0x00000C90; // type:function size:0x1C
initializeState__84sStateMgr_c<15dTgShipWindow_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x00000CB0; // type:function size:0x10
finalizeState__84sStateMgr_c<15dTgShipWindow_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x00000CC0; // type:function size:0x10
refreshState__84sStateMgr_c<15dTgShipWindow_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x00000CD0; // type:function size:0x10
getState__84sStateMgr_c<15dTgShipWindow_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x00000CE0; // type:function size:0x10
getNewStateID__84sStateMgr_c<15dTgShipWindow_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x00000CF0; // type:function size:0x10
getOldStateID__84sStateMgr_c<15dTgShipWindow_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x00000D00; // type:function size:0x10
finalizeState__30sFStateID_c<15dTgShipWindow_c>CFR15dTgShipWindow_c = .text:0x00000D10; // type:function size:0x30
executeState__30sFStateID_c<15dTgShipWindow_c>CFR15dTgShipWindow_c = .text:0x00000D40; // type:function size:0x30
initializeState__30sFStateID_c<15dTgShipWindow_c>CFR15dTgShipWindow_c = .text:0x00000D70; // type:function size:0x30
__sinit_\d_t_ship_window_cpp = .text:0x00000DA0; // type:function size:0x1C0 scope:local
__dt__30sFStateID_c<15dTgShipWindow_c>Fv = .text:0x00000F60; // type:function size:0x58
isSameName__30sFStateID_c<15dTgShipWindow_c>CFPCc = .text:0x00000FC0; // type:function size:0x88
_ctors = .ctors:0x00000000; // type:label scope:global
_dtors = .dtors:0x00000000; // type:label scope:global
__destroy_global_chain_reference = .dtors:0x00000000; // type:object size:0x4 scope:global
lbl_449_section4_0 = .rodata:0x00000000; // type:object size:0x10 data:4byte
lbl_449_section4_10 = .rodata:0x00000010; // type:object size:0x4 data:4byte
lbl_449_section4_14 = .rodata:0x00000014; // type:object size:0x4 data:4byte
lbl_449_section4_18 = .rodata:0x00000018; // type:object size:0x4 data:4byte
lbl_449_section4_1C = .rodata:0x0000001C; // type:object size:0x4 data:4byte
lbl_449_section4_20 = .rodata:0x00000020; // type:object size:0x4 data:4byte
lbl_449_section4_24 = .rodata:0x00000024; // type:object size:0x74
lbl_449_section4_98 = .rodata:0x00000098; // type:object size:0x30
lbl_449_section4_C8 = .rodata:0x000000C8; // type:object size:0x30
lbl_449_section4_F8 = .rodata:0x000000F8; // type:object size:0x18
lbl_449_section4_110 = .rodata:0x00000110; // type:object size:0x110
lbl_449_section4_220 = .rodata:0x00000220; // type:object size:0x34
g_profile_TAG_SHIP_WINDOW = .data:0x00000000; // type:object size:0x10 data:4byte
sDefaultRotX__15dTgShipWindow_c = .data:0x00000010; // type:object size:0x4 data:4byte
lbl_449_section4_14 = .data:0x00000014; // type:object size:0x4 scope:local data:4byte
lbl_449_section4_18 = .data:0x00000018; // type:object size:0x4 scope:local data:4byte
lbl_449_section4_1C = .data:0x0000001C; // type:object size:0x4 scope:local data:4byte
lbl_449_section4_20 = .data:0x00000020; // type:object size:0x4 scope:local data:4byte
__vt__15dTgShipWindow_c = .data:0x00000024; // type:object size:0x74
__vt__54sFStateMgr_c<15dTgShipWindow_c,20sStateMethodUsr_FI_c> = .data:0x00000098; // type:object size:0x30
__vt__84sStateMgr_c<15dTgShipWindow_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c> = .data:0x000000C8; // type:object size:0x30
__vt__31sFStateFct_c<15dTgShipWindow_c> = .data:0x000000F8; // type:object size:0x14
__vt__28sFState_c<15dTgShipWindow_c> = .data:0x00000110; // type:object size:0x18
__vt__30sFStateID_c<15dTgShipWindow_c> = .data:0x00000220; // type:object size:0x34
__global_destructor_chain = .bss:0x00000000; // type:object size:0x4 scope:global
lbl_449_bss_8 = .bss:0x00000008; // type:object size:0x10 data:4byte
lbl_449_bss_18 = .bss:0x00000018; // type:object size:0x40 data:4byte
lbl_449_bss_58 = .bss:0x00000058; // type:object size:0x30 data:4byte
lbl_449_bss_8 = .bss:0x00000008; // type:object size:0x10 scope:local data:4byte
StateID_On__15dTgShipWindow_c = .bss:0x00000018; // type:object size:0x30 data:4byte
StateID_Off__15dTgShipWindow_c = .bss:0x00000058; // type:object size:0x30 data:4byte
4 changes: 2 additions & 2 deletions config/SOUE01/symbols.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3521,10 +3521,10 @@ fn_8009CC40 = .text:0x8009CC40; // type:function size:0x7C
ActorEventRelated__somethingUpdate = .text:0x8009CCC0; // type:function size:0x1F0
ActorEventRelated__cutEnd = .text:0x8009CEB0; // type:function size:0x30
ActorEventRelated__getCurrentStepIndex = .text:0x8009CEE0; // type:function size:0x30
ActorEventRelated__getCurrentEventCommand = .text:0x8009CF10; // type:function size:0x84
getCurrentEventCommand__17ActorEventRelatedCFv = .text:0x8009CF10; // type:function size:0x84
ActorEventRelated__getSomeEventRelatedNumber = .text:0x8009CFA0; // type:function size:0x80
ActorEventRelated__isAdvance = .text:0x8009D020; // type:function size:0x34
ActorEventRelated__advanceNext = .text:0x8009D060; // type:function size:0x50
advanceNext__17ActorEventRelatedFv = .text:0x8009D060; // type:function size:0x50
ActorEventRelated__getSingleIntData2 = .text:0x8009D0B0; // type:function size:0x8C
ActorEventRelated__getSingleIntData = .text:0x8009D140; // type:function size:0x8C
ActorEventRelated__getSingleFloatData = .text:0x8009D1D0; // type:function size:0x8C
Expand Down
2 changes: 1 addition & 1 deletion configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1444,7 +1444,7 @@ def nw4rLib(lib_name, objects, extra_cflags=[]):
Rel(NonMatching, "d_t_scene_change", "REL/d/t/d_t_scene_change.cpp"),
Rel(NonMatching, "d_t_ship_flood", "REL/d/t/d_t_ship_flood.cpp"),
Rel(NonMatching, "d_t_ship_slope", "REL/d/t/d_t_ship_slope.cpp"),
Rel(NonMatching, "d_t_ship_window", "REL/d/t/d_t_ship_window.cpp"),
Rel(Matching, "d_t_ship_window", "REL/d/t/d_t_ship_window.cpp"),
Rel(NonMatching, "d_t_shutter_fence_forbiddance", "REL/d/t/d_t_shutter_fence_forbiddance.cpp"),
Rel(NonMatching, "d_t_shutter_fence_permission", "REL/d/t/d_t_shutter_fence_permission.cpp"),
Rel(NonMatching, "d_t_siren_time_attack", "REL/d/t/d_t_siren_time_attack.cpp"),
Expand Down
35 changes: 35 additions & 0 deletions include/d/tg/d_t_ship_window.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#ifndef D_T_SHIP_WINDOW_H
#define D_T_SHIP_WINDOW_H

#include <d/tg/d_tg.h>
#include <s/s_State.hpp>
#include <s/s_StateMgr.hpp>
#include <toBeSorted/actor_event.h>

class dTgShipWindow_c : public dTg_c {
public:
dTgShipWindow_c() : mStateMgr(*this, sStateID::null), mEvent(*this, nullptr) {}
virtual ~dTgShipWindow_c() {}
virtual int create() override;
virtual int actorExecute() override;
virtual int actorExecuteInEvent() override;
virtual int draw() override;
virtual int doDelete() override;

STATE_FUNC_DECLARE(dTgShipWindow_c, On);
STATE_FUNC_DECLARE(dTgShipWindow_c, Off);

private:
static u32 sDefaultRotX;
STATE_MGR_DECLARE(dTgShipWindow_c);
ActorEventRelated mEvent;
u8 mInitialStateFlag;
u8 mOutputStateFlagBase;
u8 mOffEventId;
u8 mOnEventId;
u8 mHasPlayedOffEvent;
u8 mHasPlayedOnEvent;
u8 mAlwaysPlayEvent;
};

#endif
2 changes: 2 additions & 0 deletions include/toBeSorted/actor_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class ActorEventRelated {

bool isThisActorInEvent();
void scheduleEvent(Event &, u32);
u32 getCurrentEventCommand() const;
void advanceNext();

private:
u8 field_0x00[0x50 - 0x00];
Expand Down
145 changes: 145 additions & 0 deletions src/REL/d/t/d_t_ship_window.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
#include <d/tg/d_t_ship_window.h>
#include <toBeSorted/event_manager.h>
#include <toBeSorted/sceneflag_manager.h>

SPECIAL_ACTOR_PROFILE(TAG_SHIP_WINDOW, dTgShipWindow_c, fProfile::TAG_SHIP_WINDOW, 0x0228, 0, 0);

STATE_DEFINE(dTgShipWindow_c, On);
STATE_DEFINE(dTgShipWindow_c, Off);

// sDefaultRotX got placed in .data despite being zero.
// There is a handy pragma for this but it's probably not
// the correct solution.
#pragma explicit_zero_data on
u32 dTgShipWindow_c::sDefaultRotX = 0;
#pragma explicit_zero_data off

int dTgShipWindow_c::create() {
mInitialStateFlag = params & 0xFF;
mOutputStateFlagBase = (params >> 8) & 0xFF;
mOffEventId = (params >> 16) & 0xFF;
mOnEventId = (params >> 24) & 0xFF;
mAlwaysPlayEvent = rotation.x & 1;
rotation.x = sDefaultRotX;
if (SceneflagManager::sInstance->checkBoolFlag(roomid, mInitialStateFlag)) {
SceneflagManager::sInstance->setFlag(roomid, mOutputStateFlagBase);
mStateMgr.changeState(StateID_On);
} else {
SceneflagManager::sInstance->unsetFlag(roomid, mOutputStateFlagBase);
mStateMgr.changeState(StateID_Off);
}
return SUCCEEDED;
}

int dTgShipWindow_c::doDelete() {
return SUCCEEDED;
}

int dTgShipWindow_c::actorExecute() {
mStateMgr.executeState();
return SUCCEEDED;
}

int dTgShipWindow_c::actorExecuteInEvent() {
switch (mEvent.getCurrentEventCommand()) {
case 'act0':
actorExecute();
mEvent.advanceNext();
break;
case 'act1':
actorExecute();
if (*mStateMgr.getStateID() == StateID_Off) {
SceneflagManager::sInstance->unsetFlag(roomid, mOutputStateFlagBase);
} else {
SceneflagManager::sInstance->setFlag(roomid, mOutputStateFlagBase);
}
mEvent.advanceNext();
break;
case '????': actorExecute(); break;
default: actorExecute(); break;
}

return SUCCEEDED;
}

int dTgShipWindow_c::draw() {
return SUCCEEDED;
}

void dTgShipWindow_c::initializeState_Off() {}
void dTgShipWindow_c::executeState_Off() {
if (!SceneflagManager::sInstance->checkBoolFlag(roomid, mInitialStateFlag)) {
return;
}

if ((mHasPlayedOffEvent == 0 || mAlwaysPlayEvent == 0) &&
(mOutputStateFlagBase >= 0xFF || !SceneflagManager::sInstance->checkBoolFlag(roomid, mOutputStateFlagBase + 1))) {
if (mOffEventId != 0xFF) {
{
// this works but I don't like it
static volatile u32 FLAGS_1 = 0x00000001;
static u32 FLAGS_2 = 0x00100001;
u32 f1 = FLAGS_1;
u32 f2 = FLAGS_2;
Event e = Event(mOffEventId, roomid, f2 & ~f1, nullptr, nullptr);
mEvent.scheduleEvent(e, 0);
}

if (!EventManager::isInEvent(this, nullptr)) {
return;
}
mHasPlayedOffEvent = 1;
if (mOutputStateFlagBase < 0xFF) {
SceneflagManager::sInstance->setFlag(roomid, mOutputStateFlagBase + 1);
}
mStateMgr.changeState(StateID_On);
return;
} else {
SceneflagManager::sInstance->setFlag(roomid, mOutputStateFlagBase);
mStateMgr.changeState(StateID_On);
return;
}
}
SceneflagManager::sInstance->setFlag(roomid, mOutputStateFlagBase);
mStateMgr.changeState(StateID_On);
}
void dTgShipWindow_c::finalizeState_Off() {}

void dTgShipWindow_c::initializeState_On() {}
void dTgShipWindow_c::executeState_On() {
if (SceneflagManager::sInstance->checkBoolFlag(roomid, mInitialStateFlag)) {
return;
}

if ((mHasPlayedOnEvent == 0 || mAlwaysPlayEvent == 0) &&
(mOutputStateFlagBase >= 0xFF || !SceneflagManager::sInstance->checkBoolFlag(roomid, mOutputStateFlagBase + 2))) {
if (mOnEventId != 0xFF) {
{
// this works but I don't like it
static volatile u32 FLAGS_1 = 0x00000001;
static u32 FLAGS_2 = 0x00100001;
u32 f1 = FLAGS_1;
u32 f2 = FLAGS_2;
Event e = Event(mOnEventId, roomid, f2 & ~f1, nullptr, nullptr);
mEvent.scheduleEvent(e, 0);
}

if (!EventManager::isInEvent(this, nullptr)) {
return;
}
mHasPlayedOnEvent = 1;
if (mOutputStateFlagBase < 0xFF) {
SceneflagManager::sInstance->setFlag(roomid, mOutputStateFlagBase + 2);
}
mStateMgr.changeState(StateID_Off);
return;
} else {
SceneflagManager::sInstance->unsetFlag(roomid, mOutputStateFlagBase);
mStateMgr.changeState(StateID_Off);
return;
}
}
SceneflagManager::sInstance->unsetFlag(roomid, mOutputStateFlagBase);
mStateMgr.changeState(StateID_Off);
}
void dTgShipWindow_c::finalizeState_On() {}

0 comments on commit 8376edc

Please sign in to comment.