mirror of
https://github.com/ACreTeam/ac-decomp
synced 2026-05-23 14:41:38 -04:00
link nubevent.c
This commit is contained in:
@@ -191,6 +191,9 @@ MSL_C/rand.c:
|
||||
.sdata: [0x80218260, 0x80218268]
|
||||
TRK/mainloop.c:
|
||||
.text: [0x800A1FF4, 0x800A20EC]
|
||||
TRK/nubevent.c:
|
||||
.text: [0x800A20EC, 0x800A2314]
|
||||
.bss: [0x802095C8, 0x802095F0]
|
||||
dolphin/odenotstub/odenotstub.c:
|
||||
.text: [0x800a9770, 0x800a9780]
|
||||
dolphin/amcstubs/AmcExi2Stubs.c:
|
||||
|
||||
+1
-1
@@ -647,7 +647,7 @@ class CSource(Source):
|
||||
self.cc = c.CC
|
||||
self.cflags = c.DOL_CPPFLAGS
|
||||
self.frank = False
|
||||
elif path == "src/TRK/mainloop.c":
|
||||
elif path == "src/TRK/mainloop.c" or path == "src/TRK/nubevent.c":
|
||||
self.cc = c.CC
|
||||
self.cflags = c.DOL_TRK_CFLAGS
|
||||
self.frank = False
|
||||
|
||||
@@ -15,6 +15,7 @@ typedef struct MessageBuffer {
|
||||
} MessageBuffer;
|
||||
|
||||
MessageBuffer* TRKGetBuffer(int);
|
||||
void TRKReleaseBuffer(int);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef TRK_MUTEX_TRK
|
||||
#define TRK_MUTEX_TRK
|
||||
#include "types.h"
|
||||
#include "TRK/trk.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
TRKResult TRKAcquireMutex(void*);
|
||||
TRKResult TRKReleaseMutex(void*);
|
||||
TRKResult TRKInitializeMutex(void*);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -6,7 +6,19 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct TRKEventQueue{
|
||||
int unk0;
|
||||
int mCurrEvtID;
|
||||
int mNextSlotToOverwrite;
|
||||
TRKEvent mEvents[2];
|
||||
u32 mMax;
|
||||
}TRKEventQueue;
|
||||
|
||||
|
||||
TRKResult TRKInitializeEventQueue();
|
||||
BOOL TRKGetNextEvent(TRKEvent*);
|
||||
TRKResult TRKPostEvent(TRKEvent*);
|
||||
void TRKConstructEvent(TRKEvent*, int);
|
||||
void TRKDestructEvent(TRKEvent*);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
#include "TRK/nubevent.h"
|
||||
#include "TRK/mutex_trk.h"
|
||||
#include "TRK/_mem_trk.h"
|
||||
#include "TRK/msgbuf.h"
|
||||
|
||||
TRKEventQueue gTRKEventQueue;
|
||||
|
||||
TRKResult TRKInitializeEventQueue(){
|
||||
TRKInitializeMutex(&gTRKEventQueue);
|
||||
TRKAcquireMutex(&gTRKEventQueue);
|
||||
gTRKEventQueue.mCurrEvtID = 0;
|
||||
gTRKEventQueue.mNextSlotToOverwrite = 0;
|
||||
gTRKEventQueue.mMax = 0x100;
|
||||
TRKReleaseMutex(&gTRKEventQueue);
|
||||
return TRKSuccess;
|
||||
}
|
||||
|
||||
BOOL TRKGetNextEvent(TRKEvent* event){
|
||||
|
||||
BOOL res = FALSE;
|
||||
TRKAcquireMutex(&gTRKEventQueue);
|
||||
|
||||
if(gTRKEventQueue.mCurrEvtID > 0){
|
||||
TRK_memcpy(event, &gTRKEventQueue.mEvents[gTRKEventQueue.mNextSlotToOverwrite], sizeof(TRKEvent));
|
||||
gTRKEventQueue.mCurrEvtID--;
|
||||
if(++gTRKEventQueue.mNextSlotToOverwrite == 2){
|
||||
gTRKEventQueue.mNextSlotToOverwrite = 0;
|
||||
}
|
||||
res = TRUE;
|
||||
}
|
||||
TRKReleaseMutex(&gTRKEventQueue);
|
||||
return res;
|
||||
}
|
||||
|
||||
TRKResult TRKPostEvent(TRKEvent* event){
|
||||
|
||||
TRKResult res = 0;
|
||||
int evId;
|
||||
|
||||
TRKAcquireMutex(&gTRKEventQueue);
|
||||
|
||||
if(gTRKEventQueue.mCurrEvtID == 2){
|
||||
res = 0x100;
|
||||
}
|
||||
else{
|
||||
evId = (gTRKEventQueue.mNextSlotToOverwrite + gTRKEventQueue.mCurrEvtID) % 2;
|
||||
TRK_memcpy(&gTRKEventQueue.mEvents[evId], event, sizeof(TRKEvent));
|
||||
gTRKEventQueue.mEvents[evId].mMax = gTRKEventQueue.mMax;
|
||||
gTRKEventQueue.mMax++;
|
||||
if(gTRKEventQueue.mMax < 256){
|
||||
gTRKEventQueue.mMax = 256;
|
||||
}
|
||||
gTRKEventQueue.mCurrEvtID++;
|
||||
}
|
||||
TRKReleaseMutex(&gTRKEventQueue);
|
||||
return res;
|
||||
}
|
||||
void TRKConstructEvent(TRKEvent* event, int type){
|
||||
|
||||
event->mEventType = type;
|
||||
event->mMax = 0;
|
||||
event->mBufferIndex = -1;
|
||||
}
|
||||
void TRKDestructEvent(TRKEvent* event){
|
||||
TRKReleaseBuffer(event->mBufferIndex);
|
||||
}
|
||||
Reference in New Issue
Block a user