mirror of
https://github.com/ACreTeam/ac-decomp
synced 2026-06-16 22:00:07 -04:00
Link dolphin/gba
This commit is contained in:
+6
-6
@@ -504,12 +504,12 @@ config.libs = [
|
||||
DolphinLib(
|
||||
"gba",
|
||||
[
|
||||
Object(NonMatching, "dolphin/gba/GBA.c"),
|
||||
Object(NonMatching, "dolphin/gba/GBAGetProcessStatus.c"),
|
||||
Object(NonMatching, "dolphin/gba/GBAJoyBoot.c"),
|
||||
Object(NonMatching, "dolphin/gba/GBARead.c"),
|
||||
Object(NonMatching, "dolphin/gba/GBAWrite.c"),
|
||||
Object(NonMatching, "dolphin/gba/GBAXfer.c"),
|
||||
Object(Matching, "dolphin/gba/GBA.c"),
|
||||
Object(Matching, "dolphin/gba/GBAGetProcessStatus.c"),
|
||||
Object(Matching, "dolphin/gba/GBAJoyBoot.c"),
|
||||
Object(Matching, "dolphin/gba/GBARead.c"),
|
||||
Object(Matching, "dolphin/gba/GBAWrite.c"),
|
||||
Object(Matching, "dolphin/gba/GBAXfer.c"),
|
||||
],
|
||||
),
|
||||
DolphinLib(
|
||||
|
||||
@@ -1,45 +1,40 @@
|
||||
#include "GBA/GBAPriv.h"
|
||||
|
||||
s32 GBAReadAsync(s32 chan, u8* dst, u8* status, GBACallback callback) {
|
||||
static void ReadProc(s32 chan) {
|
||||
GBAControl* gba;
|
||||
gba = &__GBA[chan];
|
||||
|
||||
}
|
||||
|
||||
/*static void ReadProc(s32 chan) {
|
||||
GBAControl* gba;
|
||||
gba = &__GBA[chan];
|
||||
|
||||
if (gba->ret == 0) {
|
||||
memcpy(gba->ptr, gba->input, 4);
|
||||
gba->status[0] = gba->input[4] & GBA_JSTAT_MASK;
|
||||
}
|
||||
if (gba->ret == 0) {
|
||||
memcpy(gba->ptr, gba->input, 4);
|
||||
gba->status[0] = gba->input[4] & GBA_JSTAT_MASK;
|
||||
}
|
||||
}
|
||||
|
||||
s32 GBAReadAsync(s32 chan, u8* dst, u8* status, GBACallback callback) {
|
||||
GBAControl* gba;
|
||||
GBAControl* gba;
|
||||
|
||||
gba = &__GBA[chan];
|
||||
gba = &__GBA[chan];
|
||||
|
||||
if (gba->callback != NULL) {
|
||||
return 2;
|
||||
}
|
||||
if (gba->callback != NULL) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
gba->output[0] = 0x14;
|
||||
gba->ptr = dst;
|
||||
gba->status = status;
|
||||
gba->callback = callback;
|
||||
gba->output[0] = 0x14;
|
||||
gba->ptr = dst;
|
||||
gba->status = status;
|
||||
gba->callback = callback;
|
||||
|
||||
return __GBATransfer(chan, 1, 5, ReadProc);
|
||||
return __GBATransfer(chan, 1, 5, ReadProc);
|
||||
}
|
||||
|
||||
s32 GBARead(s32 chan, u8* dst, u8* status) {
|
||||
s32 tmp;
|
||||
GBAControl* gba = &__GBA[chan];
|
||||
s32 ret;
|
||||
ret = GBAReadAsync(chan, dst, status, __GBASyncCallback);
|
||||
if (ret != GBA_READY) {
|
||||
return ret;
|
||||
}
|
||||
s32 tmp;
|
||||
GBAControl* gba = &__GBA[chan];
|
||||
s32 ret;
|
||||
ret = GBAReadAsync(chan, dst, status, __GBASyncCallback);
|
||||
if (ret != GBA_READY) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
return __GBASync(chan);
|
||||
return __GBASync(chan);
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -1,43 +1,37 @@
|
||||
#include "GBA/GBAPriv.h"
|
||||
|
||||
s32 GBAWriteAsync(s32 chan, u8* src, u8* status, GBACallback callback) {
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
static void WriteProc(s32 chan) {
|
||||
GBAControl* gba;
|
||||
gba = &__GBA[chan];
|
||||
GBAControl* gba;
|
||||
gba = &__GBA[chan];
|
||||
|
||||
if (gba->ret != 0) {
|
||||
return;
|
||||
}
|
||||
if (gba->ret != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
gba->status[0] = gba->input[0] & GBA_JSTAT_MASK;
|
||||
gba->status[0] = gba->input[0] & GBA_JSTAT_MASK;
|
||||
}
|
||||
|
||||
s32 GBAWriteAsync(s32 chan, u8* src, u8* status, GBACallback callback) {
|
||||
GBAControl* gba = &__GBA[chan];
|
||||
GBAControl* gba = &__GBA[chan];
|
||||
|
||||
if (gba->callback != NULL) {
|
||||
return GBA_BUSY;
|
||||
}
|
||||
gba->output[0] = 0x15;
|
||||
memcpy(&gba->output[1], src, 4);
|
||||
gba->ptr = src;
|
||||
gba->status = status;
|
||||
gba->callback = callback;
|
||||
return __GBATransfer(chan, 5, 1, WriteProc);
|
||||
if (gba->callback != NULL) {
|
||||
return GBA_BUSY;
|
||||
}
|
||||
gba->output[0] = 0x15;
|
||||
memcpy(&gba->output[1], src, 4);
|
||||
gba->ptr = src;
|
||||
gba->status = status;
|
||||
gba->callback = callback;
|
||||
return __GBATransfer(chan, 5, 1, WriteProc);
|
||||
}
|
||||
|
||||
s32 GBAWrite(s32 chan, u8* src, u8* status) {
|
||||
s32 tmp;
|
||||
GBAControl* gba = &__GBA[chan];
|
||||
s32 ret;
|
||||
ret = GBAWriteAsync(chan, src, status, __GBASyncCallback);
|
||||
if (ret != GBA_READY) {
|
||||
return ret;
|
||||
}
|
||||
return __GBASync(chan);
|
||||
s32 tmp;
|
||||
GBAControl* gba = &__GBA[chan];
|
||||
s32 ret;
|
||||
ret = GBAWriteAsync(chan, src, status, __GBASyncCallback);
|
||||
if (ret != GBA_READY) {
|
||||
return ret;
|
||||
}
|
||||
return __GBASync(chan);
|
||||
}
|
||||
*/
|
||||
|
||||
+102
-117
@@ -1,107 +1,33 @@
|
||||
#include "gba/GBAPriv.h"
|
||||
|
||||
s32 __GBATransfer(s32 chan, u32 outputBytes, u32 inputBytes, GBATransferCallback proc) {
|
||||
|
||||
}
|
||||
|
||||
void __GBASyncCallback(s32 chan, s32 ret) {
|
||||
|
||||
}
|
||||
|
||||
s32 __GBASync(s32 chan) {
|
||||
|
||||
}
|
||||
/*#include "GBA/GBAPriv.h"
|
||||
#include "GBA/GBAPriv.h"
|
||||
#include "dolphin/sipriv.h"
|
||||
|
||||
static void __GBAHandler(s32 chan, u32 error, OSContext* context) {
|
||||
GBAControl* gba;
|
||||
GBATransferCallback proc;
|
||||
GBACallback callback;
|
||||
OSContext exceptionContext;
|
||||
GBAControl* gba;
|
||||
GBATransferCallback proc;
|
||||
GBACallback callback;
|
||||
OSContext exceptionContext;
|
||||
|
||||
gba = &__GBA[chan];
|
||||
if (__GBAReset != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((error & 0xf)) {
|
||||
gba->ret = 1;
|
||||
} else {
|
||||
gba->ret = 0;
|
||||
}
|
||||
|
||||
if (gba->proc != NULL) {
|
||||
proc = gba->proc;
|
||||
gba->proc = NULL;
|
||||
proc(chan);
|
||||
}
|
||||
|
||||
if (gba->callback == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
OSClearContext(&exceptionContext);
|
||||
OSSetCurrentContext(&exceptionContext);
|
||||
callback = gba->callback;
|
||||
gba->callback = NULL;
|
||||
callback(chan, gba->ret);
|
||||
OSClearContext(&exceptionContext);
|
||||
OSSetCurrentContext(context);
|
||||
}
|
||||
|
||||
void __GBASyncCallback(s32 chan, s32 ret) {
|
||||
GBAControl* gba = &__GBA[chan];
|
||||
OSWakeupThread(&gba->threadQueue);
|
||||
}
|
||||
|
||||
s32 __GBASync(s32 chan) {
|
||||
GBAControl* gba;
|
||||
s32 ret;
|
||||
s32 enabled;
|
||||
gba = &__GBA[chan];
|
||||
|
||||
enabled = OSDisableInterrupts();
|
||||
while (gba->callback != NULL) {
|
||||
OSSleepThread(&gba->threadQueue);
|
||||
}
|
||||
|
||||
ret = gba->ret;
|
||||
OSRestoreInterrupts(enabled);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void TypeAndStatusCallback(s32 chan, u32 type) {
|
||||
GBAControl* gba;
|
||||
GBATransferCallback proc;
|
||||
GBACallback callback;
|
||||
OSContext exceptionContext;
|
||||
OSContext* context;
|
||||
|
||||
gba = &__GBA[chan];
|
||||
if (__GBAReset != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((type & 0xFF) != 0 || (type & 0xffff0000) != 0x40000) {
|
||||
gba->ret = GBA_NOT_READY;
|
||||
} else {
|
||||
if (SITransfer(chan, gba->output, gba->outputBytes, gba->input, gba->inputBytes, __GBAHandler,
|
||||
gba->delay)) {
|
||||
return;
|
||||
gba = &__GBA[chan];
|
||||
if (__GBAReset != 0) {
|
||||
return;
|
||||
}
|
||||
gba->ret = GBA_BUSY;
|
||||
}
|
||||
|
||||
if (gba->proc != NULL) {
|
||||
proc = gba->proc;
|
||||
gba->proc = NULL;
|
||||
proc(chan);
|
||||
}
|
||||
if ((error & 0xf)) {
|
||||
gba->ret = 1;
|
||||
} else {
|
||||
gba->ret = 0;
|
||||
}
|
||||
|
||||
if (gba->proc != NULL) {
|
||||
proc = gba->proc;
|
||||
gba->proc = NULL;
|
||||
proc(chan);
|
||||
}
|
||||
|
||||
if (gba->callback == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (gba->callback != NULL) {
|
||||
context = OSGetCurrentContext();
|
||||
OSClearContext(&exceptionContext);
|
||||
OSSetCurrentContext(&exceptionContext);
|
||||
callback = gba->callback;
|
||||
@@ -109,30 +35,89 @@ void TypeAndStatusCallback(s32 chan, u32 type) {
|
||||
callback(chan, gba->ret);
|
||||
OSClearContext(&exceptionContext);
|
||||
OSSetCurrentContext(context);
|
||||
__OSReschedule();
|
||||
}
|
||||
}
|
||||
|
||||
s32 __GBATransfer(s32 chan, s32 w1, s32 w2, GBATransferCallback callback) {
|
||||
s32 enabled;
|
||||
GBAControl* gba;
|
||||
gba = &__GBA[chan];
|
||||
enabled = OSDisableInterrupts();
|
||||
gba->proc = callback;
|
||||
gba->outputBytes = w1;
|
||||
gba->inputBytes = w2;
|
||||
SIGetTypeAsync(chan, TypeAndStatusCallback);
|
||||
OSRestoreInterrupts(enabled);
|
||||
void __GBASyncCallback(s32 chan, s32 ret) {
|
||||
GBAControl* gba = &__GBA[chan];
|
||||
OSWakeupThread(&gba->threadQueue);
|
||||
}
|
||||
|
||||
return GBA_READY;
|
||||
s32 __GBASync(s32 chan) {
|
||||
GBAControl* gba;
|
||||
s32 ret;
|
||||
s32 enabled;
|
||||
gba = &__GBA[chan];
|
||||
|
||||
enabled = OSDisableInterrupts();
|
||||
while (gba->callback != NULL) {
|
||||
OSSleepThread(&gba->threadQueue);
|
||||
}
|
||||
|
||||
ret = gba->ret;
|
||||
OSRestoreInterrupts(enabled);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void TypeAndStatusCallback(s32 chan, u32 type) {
|
||||
GBAControl* gba;
|
||||
GBATransferCallback proc;
|
||||
GBACallback callback;
|
||||
OSContext exceptionContext;
|
||||
OSContext* context;
|
||||
|
||||
gba = &__GBA[chan];
|
||||
if (__GBAReset != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((type & 0xFF) != 0 || (type & 0xffff0000) != 0x40000) {
|
||||
gba->ret = GBA_NOT_READY;
|
||||
} else {
|
||||
if (SITransfer(chan, gba->output, gba->outputBytes, gba->input, gba->inputBytes, __GBAHandler, gba->delay)) {
|
||||
return;
|
||||
}
|
||||
gba->ret = GBA_BUSY;
|
||||
}
|
||||
|
||||
if (gba->proc != NULL) {
|
||||
proc = gba->proc;
|
||||
gba->proc = NULL;
|
||||
proc(chan);
|
||||
}
|
||||
|
||||
if (gba->callback != NULL) {
|
||||
context = OSGetCurrentContext();
|
||||
OSClearContext(&exceptionContext);
|
||||
OSSetCurrentContext(&exceptionContext);
|
||||
callback = gba->callback;
|
||||
gba->callback = NULL;
|
||||
callback(chan, gba->ret);
|
||||
OSClearContext(&exceptionContext);
|
||||
OSSetCurrentContext(context);
|
||||
__OSReschedule();
|
||||
}
|
||||
}
|
||||
|
||||
s32 __GBATransfer(s32 chan, u32 w1, u32 w2, GBATransferCallback callback) {
|
||||
s32 enabled;
|
||||
GBAControl* gba;
|
||||
gba = &__GBA[chan];
|
||||
enabled = OSDisableInterrupts();
|
||||
gba->proc = callback;
|
||||
gba->outputBytes = w1;
|
||||
gba->inputBytes = w2;
|
||||
SIGetTypeAsync(chan, TypeAndStatusCallback);
|
||||
OSRestoreInterrupts(enabled);
|
||||
|
||||
return GBA_READY;
|
||||
}
|
||||
|
||||
OSTime __GBASetDelay(s32 chan, OSTime delay) {
|
||||
OSTime oldDelay;
|
||||
GBAControl* gba;
|
||||
gba = &__GBA[chan];
|
||||
oldDelay = gba->delay;
|
||||
gba->delay = delay;
|
||||
return oldDelay;
|
||||
OSTime oldDelay;
|
||||
GBAControl* gba;
|
||||
gba = &__GBA[chan];
|
||||
oldDelay = gba->delay;
|
||||
gba->delay = delay;
|
||||
return oldDelay;
|
||||
}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user