mirror of https://github.com/PrimeDecomp/prime.git
parent
2d138c60bd
commit
cb7e35b615
|
@ -17,7 +17,8 @@
|
|||
"types.h": "c",
|
||||
"gba.h": "c",
|
||||
"gbapriv.h": "c",
|
||||
"os.h": "c"
|
||||
"os.h": "c",
|
||||
"sipriv.h": "c"
|
||||
},
|
||||
"files.autoSave": "onFocusChange",
|
||||
"files.insertFinalNewline": true,
|
||||
|
|
|
@ -1007,14 +1007,14 @@ LIBS = [
|
|||
},
|
||||
{
|
||||
"lib": "gba",
|
||||
"mwcc_version": "1.2.5",
|
||||
"mwcc_version": "1.2.5e",
|
||||
"cflags": "$cflags_base",
|
||||
"objects": [
|
||||
["Dolphin/GBA/GBA", True],
|
||||
"Dolphin/GBA/GBAGetProcessStatus",
|
||||
"Dolphin/GBA/GBAJoyBoot",
|
||||
"Dolphin/GBA/GBARead",
|
||||
"Dolphin/GBA/GBAWrite",
|
||||
["Dolphin/GBA/GBARead", True],
|
||||
["Dolphin/GBA/GBAWrite", True],
|
||||
"Dolphin/GBA/GBAXfer",
|
||||
"Dolphin/GBA/GBAKey",
|
||||
],
|
||||
|
|
|
@ -16,11 +16,8 @@ typedef struct GBASecParams {
|
|||
typedef struct GBA {
|
||||
u8 command;
|
||||
u8 src[4];
|
||||
u8 _05;
|
||||
u8 _06;
|
||||
s8 _07;
|
||||
s8 _08;
|
||||
s8 _09;
|
||||
u8 dst[4];
|
||||
u8 _09;
|
||||
s8 _0a;
|
||||
s8 _0b;
|
||||
s32 _0c;
|
||||
|
@ -30,8 +27,9 @@ typedef struct GBA {
|
|||
GBACallback callback;
|
||||
s32 result;
|
||||
OSThreadQueue thread_queue;
|
||||
OSTime poll_time;
|
||||
char data1[0x40u - 0x38u];
|
||||
OSTime delay;
|
||||
GBACallback _38;
|
||||
s32 _3c;
|
||||
s32 palette_color;
|
||||
s32 palette_speed;
|
||||
u8* program;
|
||||
|
@ -49,8 +47,10 @@ typedef struct GBA {
|
|||
extern GBA __GBA[4];
|
||||
extern BOOL __GBAReset;
|
||||
|
||||
//void __GBAHandler(s32 chan, s32 ret);
|
||||
void __GBASyncCallback(s32 chan, s32 ret);
|
||||
s32 __GBASync(s32 chan);
|
||||
OSTime __GBASetDelay(s32 chan, OSTime delay);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -850,10 +850,10 @@ THP_FILES :=\
|
|||
$(BUILD_DIR)/asm/Dolphin/thp/THPAudio.o
|
||||
|
||||
GBA_FILES :=\
|
||||
$(BUILD_DIR)/src/Dolphin/GBA/GBA.o\
|
||||
$(BUILD_DIR)/src/Dolphin/GBA/GBA.ep.o\
|
||||
$(BUILD_DIR)/asm/Dolphin/GBA/GBAGetProcessStatus.o\
|
||||
$(BUILD_DIR)/asm/Dolphin/GBA/GBAJoyBoot.o\
|
||||
$(BUILD_DIR)/asm/Dolphin/GBA/GBARead.o\
|
||||
$(BUILD_DIR)/asm/Dolphin/GBA/GBAWrite.o\
|
||||
$(BUILD_DIR)/src/Dolphin/GBA/GBARead.ep.o\
|
||||
$(BUILD_DIR)/src/Dolphin/GBA/GBAWrite.ep.o\
|
||||
$(BUILD_DIR)/asm/Dolphin/GBA/GBAXfer.o\
|
||||
$(BUILD_DIR)/asm/Dolphin/GBA/GBAKey.o\
|
||||
|
|
|
@ -19,12 +19,12 @@ void ShortCommandProc(s32 chan, s32 ret) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (gba->_05 != 0 || gba->_06 != 4) {
|
||||
if (gba->dst[0] != 0 || gba->dst[1] != 4) {
|
||||
gba->result = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
gba->status[0] = gba->_07 & 0x3a;
|
||||
gba->status[0] = gba->dst[2] & 0x3a;
|
||||
}
|
||||
|
||||
void GBAInit() {
|
||||
|
@ -32,7 +32,7 @@ void GBAInit() {
|
|||
GBA* gba;
|
||||
for (i = 0; i < 4; ++i) {
|
||||
gba = &__GBA[i];
|
||||
gba->poll_time = OSMicrosecondsToTicks(60);
|
||||
gba->delay = OSMicrosecondsToTicks(60);
|
||||
OSInitThreadQueue(&gba->thread_queue);
|
||||
gba->param = &SecParams[i];
|
||||
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
#include "dolphin/GBAPriv.h"
|
||||
|
||||
s32 GBAGetProcessStatus(s32 chan, u8* percentp) {
|
||||
GBA* gba;
|
||||
s32 ret;
|
||||
BOOL enabled;
|
||||
|
||||
gba = &__GBA[chan];
|
||||
enabled = OSDisableInterrupts();
|
||||
|
||||
if (gba->jboot_callback == NULL) {
|
||||
if (gba->callback == NULL) {
|
||||
ret = 0;
|
||||
} else {
|
||||
ret = 2;
|
||||
}
|
||||
} else {
|
||||
ret = 2;
|
||||
|
||||
}
|
||||
|
||||
OSRestoreInterrupts(enabled);
|
||||
|
||||
return ret;
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
#include "dolphin/GBAPriv.h"
|
||||
|
||||
void ReadProc(s32 chan, s32 ret) {
|
||||
GBA* gba;
|
||||
gba = &__GBA[chan];
|
||||
|
||||
if (gba->result == 0) {
|
||||
memcpy(gba->buffer, &gba->dst, 4);
|
||||
gba->status[0] = gba->_09 & 0x3a;
|
||||
}
|
||||
}
|
||||
|
||||
s32 GBAReadAsync(s32 chan, u8* dst, u8* status, GBACallback callback) {
|
||||
GBA* gba;
|
||||
s32 ret;
|
||||
|
||||
gba = &__GBA[chan];
|
||||
|
||||
if (gba->callback != NULL) {
|
||||
ret = 2;
|
||||
} else {
|
||||
gba->command = 0x14;
|
||||
gba->buffer = dst;
|
||||
gba->status = status;
|
||||
gba->callback = callback;
|
||||
ret = __GBATransfer(chan, 1, 5, ReadProc);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
s32 GBARead(s32 chan, u8* dst, u8* status) {
|
||||
s32 tmp;
|
||||
s32 ret;
|
||||
ret = GBAReadAsync(chan, dst, status, __GBASyncCallback);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
return __GBASync(chan);
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
#include "dolphin/GBAPriv.h"
|
||||
|
||||
void WriteProc(s32 chan, s32 ret) {
|
||||
GBA* gba;
|
||||
gba = &__GBA[chan];
|
||||
|
||||
if (gba->result != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
gba->status[0] = gba->dst[0] & 0x3a;
|
||||
}
|
||||
|
||||
s32 GBAWriteAsync(s32 chan, u8* src, u8* status, GBACallback callback) {
|
||||
GBA* gba;
|
||||
s32 ret;
|
||||
gba = &__GBA[chan];
|
||||
|
||||
if (gba->callback != NULL) {
|
||||
ret = 2;
|
||||
} else {
|
||||
gba->command = 0x15;
|
||||
memcpy(gba->src, src, 4);
|
||||
gba->buffer = src;
|
||||
gba->status = status;
|
||||
gba->callback = callback;
|
||||
ret = __GBATransfer(chan, 5, 1, WriteProc);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
s32 GBAWrite(s32 chan, u8* src, u8* status) {
|
||||
s32 ret;
|
||||
s32 tmp;
|
||||
ret = GBAWriteAsync(chan, src, status, __GBASyncCallback);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
return __GBASync(chan);
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
#include "dolphin/GBAPriv.h"
|
||||
#include "dolphin/sipriv.h"
|
||||
|
||||
void __GBAHandler() {
|
||||
|
||||
}
|
||||
|
||||
void __GBASyncCallback(s32 chan, s32 ret) {
|
||||
OSWakeupThread(&__GBA[chan].thread_queue);
|
||||
}
|
||||
|
||||
s32 __GBASync(s32 chan) {
|
||||
GBA* gba;
|
||||
s32 enabled;
|
||||
s32 ret;
|
||||
gba = &__GBA[chan];
|
||||
|
||||
enabled = OSDisableInterrupts();
|
||||
while (gba->callback != NULL) {
|
||||
OSSleepThread(&gba->thread_queue);
|
||||
}
|
||||
|
||||
ret = gba->result;
|
||||
OSRestoreInterrupts(enabled);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void TypeAndStatusCallback(s32 chan, u32 type) {
|
||||
|
||||
}
|
||||
|
||||
s32 __GBATransfer(s32 chan, s32 w1, s32 w2, GBACallback callback) {
|
||||
s32 enabled;
|
||||
GBA* gba;
|
||||
gba = &__GBA[chan];
|
||||
enabled = OSDisableInterrupts();
|
||||
gba->_38 = callback;
|
||||
gba->_0c = w1;
|
||||
gba->_10 = w2;
|
||||
SIGetTypeAsync(chan, TypeAndStatusCallback);
|
||||
OSRestoreInterrupts(enabled);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
OSTime __GBASetDelay(s32 chan, OSTime delay) {
|
||||
OSTime oldDelay;
|
||||
GBA* gba;
|
||||
gba = &__GBA[chan];
|
||||
oldDelay = gba->delay;
|
||||
gba->delay = delay;
|
||||
return oldDelay;
|
||||
}
|
Loading…
Reference in New Issue