4
4
5
5
namespace ttyd ::evtmgr {
6
6
7
+ struct EvtEntry ;
8
+
9
+ struct EvtEntry
10
+ {
11
+ int64_t timeSinceStart;
12
+ uint8_t flags;
13
+ int8_t paramCount;
14
+ uint8_t opcode;
15
+ int8_t executionOrder;
16
+ uint8_t typeMask;
17
+ bool sleeping;
18
+ uint8_t loopStackIndex;
19
+ uint8_t switchStackIndex;
20
+ int8_t wNpcEventType;
21
+ uint8_t pad_10[3 ];
22
+ int32_t nextCommandPtr;
23
+ void *currentCommandArguments;
24
+ int8_t labelIdTable[16 ];
25
+ void *labelAddressTable[16 ];
26
+ EvtEntry *waitingEvt;
27
+ EvtEntry *waitingOnEvt;
28
+ EvtEntry *parentEvt;
29
+ int32_t sleepTimeMs;
30
+ int64_t sleepStartTime;
31
+ int32_t wInterpolationStartedNpcFlag;
32
+ int64_t wInterpRelatedTime;
33
+ int32_t unk_90;
34
+ int32_t unk_94;
35
+ int32_t currentSleepingFuncPtr;
36
+ int32_t lwData[16 ];
37
+ uint32_t lfData;
38
+ int32_t unk_e0;
39
+ int32_t unk_e4;
40
+ void *loopStartAddressStack[8 ];
41
+ int32_t loopIterationsLeftStack[8 ];
42
+ int8_t switchStateStack[8 ];
43
+ int32_t switchValueStack[8 ];
44
+ void * memoryCmdBase;
45
+ void *uwBase;
46
+ void *ufBase;
47
+ int32_t threadId;
48
+ void *wActorThisPtr;
49
+ float timescale;
50
+ int32_t timeScheduledToRun;
51
+ int32_t unk_16c;
52
+ void *wThisPtr;
53
+ void *wThisObjPtr;
54
+ int32_t wActiveMsgWindowId;
55
+ int32_t unk_17c;
56
+ int32_t unk_180;
57
+ int32_t unk_184;
58
+ int32_t unk_188;
59
+ int32_t unk_18c;
60
+ int32_t msgPriority;
61
+ int32_t unk_194;
62
+ int64_t wInterpolationStartTime2;
63
+ void *restartFromLocation;
64
+ char *name;
65
+ void *wCurrentCommandPtr;
66
+ int32_t unk_1ac;
67
+ } __attribute__((__packed__));
68
+
69
+ static_assert (sizeof (EvtEntry) == 0x1B0 );
70
+
7
71
struct EvtWork
8
72
{
9
- uint32_t maxEventCount ;
73
+ int32_t entryCount ;
10
74
uint32_t gwData[32 ];
11
75
uint32_t gfData[3 ]; // 96 flags total
12
- void *pContextBuffer; // EvtContext *pContextBuffer ;
13
- uint32_t unk_94 ;
14
- uint64_t currentEventTime ;
76
+ EvtEntry *entries ;
77
+ uint32_t pad_94 ;
78
+ int64_t currentEvtTime ;
15
79
} __attribute__((__packed__));
16
80
81
+ static_assert (sizeof (EvtWork) == 0xA0 );
82
+
17
83
extern " C" {
18
84
19
- // evtGetPtrID
20
- // evtGetPtr
21
- // evtStartOther
22
- // evtStopOther
23
- // evtStartAll
24
- // evtStopAll
25
- // evtStartID
26
- // evtStopID
27
- // evtStart
28
- // evtStop
29
- // evtSetType
30
- // evtSetSpeed
31
- // evtSetPri
32
- bool evtCheckID (uint32_t threadID);
33
- // evtDeleteID
34
- // evtDelete
35
- // evtmgrMain
36
- // evtRestart
37
- // evtBrotherEntry
38
- // evtChildEntry
39
- void *evtEntryType (void *event, uint8_t priority, uint32_t flags, uint32_t type);
40
- void *evtEntry (void *event, uint8_t priority, uint32_t flags);
41
- // evtEntryRunCheck
42
- // evtmgrReInit
43
- // evtmgrInit
44
- // make_pri_table
85
+ void evtmgrInit ();
86
+ void evtmgrReInit ();
87
+ void evtmgrMain ();
88
+
45
89
EvtWork *evtGetWork ();
46
90
91
+ EvtEntry *evtEntry (void *evtCode, int32_t executionOrder, uint32_t flags);
92
+ EvtEntry *evtEntryType (void *evtCode, int8_t priority, uint32_t flags, uint32_t types);
93
+ EvtEntry *evtChildEntry (EvtEntry *parentEvt, void *evtCode, uint32_t flags);
94
+ EvtEntry *evtBrotherEntry (EvtEntry *parentEvt, void *evtCode, uint32_t flags);
95
+ EvtEntry *evtRestart (EvtEntry *evt);
96
+ void evtDelete (EvtEntry *evt);
97
+ void evtDeleteID (int32_t threadId);
98
+ bool evtCheckID (int32_t threadId);
99
+ void evtSetPri (EvtEntry *evt, int32_t priority);
100
+ void evtSetSpeed (EvtEntry *evt, float timescale);
101
+ void evtSetType (EvtEntry *evt, uint8_t typeMask);
102
+ void evtStop (EvtEntry *evt, uint8_t typeMask);
103
+ void evtStart (EvtEntry *evt, uint8_t typeMask);
104
+ void evtStopID (int32_t threadId);
105
+ void evtStartID (int32_t threadId);
106
+ void evtStopAll (uint8_t typeMask);
107
+ void evtStartAll (uint8_t typeMask);
108
+ void evtStopOther (EvtEntry *evt, uint8_t typeMask);
109
+ void evtStartOther (EvtEntry *evt, uint8_t typeMask);
110
+ EvtEntry *evtGetPtr (int32_t index);
111
+ EvtEntry *evtGetPtrID (int32_t threadId);
112
+
113
+ // Local functions
114
+ // void make_pri_table();
115
+ // void evtEntryRunCheck(EvtEntry *evt);
116
+
47
117
}
48
118
119
+ #define EVT_DECLARE_USER_FUNC (name, parameter_count ) \
120
+ constexpr int name##_parameter_count = (parameter_count); \
121
+ int32_t name (ttyd::evtmgr::EvtEntry *evt, bool isFirstCall);
122
+
123
+ #define EVT_DEFINE_USER_FUNC (name ) \
124
+ int32_t name (ttyd::evtmgr::EvtEntry *evt, bool isFirstCall)
125
+
126
+ #define EVT_DECLARE (name ) \
127
+ extern const int32_t name[];
128
+
49
129
}
0 commit comments