mirror of
https://github.com/zeldaret/tww.git
synced 2026-08-09 10:52:25 -04:00
JASCallback
This commit is contained in:
+1
-1
@@ -653,7 +653,7 @@ config.libs = [
|
||||
Object(Matching, "JSystem/JAudio/JASCalc.cpp"),
|
||||
Object(NonMatching, "JSystem/JAudio/JASAiCtrl.cpp"),
|
||||
Object(NonMatching, "JSystem/JAudio/JASDvdThread.cpp"),
|
||||
Object(NonMatching, "JSystem/JAudio/JASCallback.cpp"),
|
||||
Object(Matching, "JSystem/JAudio/JASCallback.cpp"),
|
||||
Object(Matching, "JSystem/JAudio/JASRate.cpp"),
|
||||
Object(NonMatching, "JSystem/JAudio/JASHardStream.cpp"),
|
||||
Object(NonMatching, "JSystem/JAudio/JASHeapCtrl.cpp"),
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
#ifndef JASCALLBACK_H
|
||||
#define JASCALLBACK_H
|
||||
|
||||
#include "dolphin/types.h"
|
||||
|
||||
namespace JASystem {
|
||||
namespace Kernel {
|
||||
void resetCallback();
|
||||
int checkCallback(s32 (*)(void*), void*);
|
||||
int registerDspCallback(s32 (*)(void*), void*);
|
||||
int registerSubFrameCallback(s32 (*)(void*), void*);
|
||||
void aiCallback();
|
||||
void subframeCallback();
|
||||
|
||||
struct unk_callList {
|
||||
/* 0x00 */ s32 (*field_0x0)(void*);
|
||||
/* 0x04 */ void* field_0x4;
|
||||
/* 0x08 */ u32 field_0x8;
|
||||
};
|
||||
|
||||
extern u32 maxCallbacksUser;
|
||||
extern unk_callList* callList;
|
||||
extern bool callbackInit;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* JASCALLBACK_H */
|
||||
@@ -3,36 +3,109 @@
|
||||
// Translation Unit: JASCallback.cpp
|
||||
//
|
||||
|
||||
#include "JASCallback.h"
|
||||
#include "dolphin/types.h"
|
||||
#include "JSystem/JAudio/JASCallback.h"
|
||||
#include "JSystem/JAudio/JASSystemHeap.h"
|
||||
#include "JSystem/JKernel/JKRSolidHeap.h"
|
||||
#include "JSystem/JUtility/JUTAssert.h"
|
||||
#include "dolphin/os/OSInterrupt.h"
|
||||
|
||||
u32 JASystem::Kernel::maxCallbacksUser = 16;
|
||||
JASystem::Kernel::unk_callList* JASystem::Kernel::callList;
|
||||
bool JASystem::Kernel::callbackInit;
|
||||
|
||||
/* 8027BA70-8027BB24 .text resetCallback__Q28JASystem6KernelFv */
|
||||
void JASystem::Kernel::resetCallback() {
|
||||
/* Nonmatching */
|
||||
if (callbackInit != true) {
|
||||
callList = (unk_callList*)new (JASDram, 0) unk_callList[maxCallbacksUser];
|
||||
JUT_ASSERT(58, callList != 0);
|
||||
BOOL enable = OSDisableInterrupts();
|
||||
for (int i = 0; i < maxCallbacksUser; i++) {
|
||||
callList[i].field_0x0 = NULL;
|
||||
}
|
||||
callbackInit = true;
|
||||
OSRestoreInterrupts(enable);
|
||||
}
|
||||
}
|
||||
|
||||
/* 8027BB24-8027BB8C .text checkCallback__Q28JASystem6KernelFPFPv_lPv */
|
||||
void JASystem::Kernel::checkCallback(long (*)(void*), void*) {
|
||||
/* Nonmatching */
|
||||
int JASystem::Kernel::checkCallback(s32 (*param_1)(void*), void* param_2) {
|
||||
if (callbackInit == false) {
|
||||
return -1;
|
||||
}
|
||||
for (int i = 0; i < maxCallbacksUser; i++) {
|
||||
if (callList[i].field_0x0 == param_1 && callList[i].field_0x4 == param_2) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* 8027BB8C-8027BC24 .text registerDspCallback__Q28JASystem6KernelFPFPv_lPv */
|
||||
void JASystem::Kernel::registerDspCallback(long (*)(void*), void*) {
|
||||
/* Nonmatching */
|
||||
int JASystem::Kernel::registerDspCallback(s32 (*param_1)(void*), void* param_2) {
|
||||
if (callbackInit == false) {
|
||||
return -1;
|
||||
}
|
||||
BOOL enable = OSDisableInterrupts();
|
||||
int r30 = registerSubFrameCallback(param_1, param_2);
|
||||
if (r30 == -1) {
|
||||
OSRestoreInterrupts(enable);
|
||||
return -1;
|
||||
};
|
||||
callList[r30].field_0x8 = 1;
|
||||
OSRestoreInterrupts(enable);
|
||||
return r30;
|
||||
}
|
||||
|
||||
/* 8027BC24-8027BD14 .text registerSubFrameCallback__Q28JASystem6KernelFPFPv_lPv */
|
||||
void JASystem::Kernel::registerSubFrameCallback(long (*)(void*), void*) {
|
||||
/* Nonmatching */
|
||||
int JASystem::Kernel::registerSubFrameCallback(s32 (*param_1)(void*), void* param_2) {
|
||||
if (callbackInit == false) {
|
||||
return -1;
|
||||
}
|
||||
int idx;
|
||||
for (idx = 0; idx < maxCallbacksUser; idx++) {
|
||||
if (callList[idx].field_0x0 == NULL) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (idx == maxCallbacksUser) {
|
||||
OSReport("[JASKernel::registerAiCallbak] コールバック登録バッファが一杯です。\n");
|
||||
return -1;
|
||||
}
|
||||
if (checkCallback(param_1, param_2) != -1) {
|
||||
return -1;
|
||||
}
|
||||
BOOL enable = OSDisableInterrupts();
|
||||
callList[idx].field_0x0 = param_1;
|
||||
callList[idx].field_0x4 = param_2;
|
||||
callList[idx].field_0x8 = 0;
|
||||
OSRestoreInterrupts(enable);
|
||||
return idx;
|
||||
}
|
||||
|
||||
/* 8027BD14-8027BDAC .text aiCallback__Q28JASystem6KernelFv */
|
||||
void JASystem::Kernel::aiCallback() {
|
||||
/* Nonmatching */
|
||||
if (callbackInit) {
|
||||
for (int i = 0; i < maxCallbacksUser; i++) {
|
||||
if (callList[i].field_0x0 && callList[i].field_0x8 == 0) {
|
||||
int result = callList[i].field_0x0(callList[i].field_0x4);
|
||||
if (result == -1) {
|
||||
callList[i].field_0x0 = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 8027BDAC-8027BE44 .text subframeCallback__Q28JASystem6KernelFv */
|
||||
void JASystem::Kernel::subframeCallback() {
|
||||
/* Nonmatching */
|
||||
if (callbackInit) {
|
||||
for (int i = 0; i < maxCallbacksUser; i++) {
|
||||
if (callList[i].field_0x0 && callList[i].field_0x8 == 1) {
|
||||
int result = callList[i].field_0x0(callList[i].field_0x4);
|
||||
if (result == -1) {
|
||||
callList[i].field_0x0 = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user