mirror of https://github.com/PrimeDecomp/prime.git
Match and link GBA.c
This commit is contained in:
parent
7b1fc72739
commit
024fb634e9
|
@ -15,7 +15,9 @@
|
|||
"errno.h": "c",
|
||||
"ansi_files.h": "c",
|
||||
"types.h": "c",
|
||||
"gba.h": "c"
|
||||
"gba.h": "c",
|
||||
"gbapriv.h": "c",
|
||||
"os.h": "c"
|
||||
},
|
||||
"files.autoSave": "onFocusChange",
|
||||
"files.insertFinalNewline": true,
|
||||
|
|
2
Makefile
2
Makefile
|
@ -153,6 +153,8 @@ $(SI_FILES): MWCC_VERSION := 1.2.5
|
|||
$(SI_FILES): CFLAGS := $(CFLAGS_BASE)
|
||||
$(DB_FILES): MWCC_VERSION := 1.2.5
|
||||
$(DB_FILES): CFLAGS := $(CFLAGS_BASE)
|
||||
$(GBA_FILES): MWCC_VERSION := 1.2.5
|
||||
$(GBA_FILES): CFLAGS := $(CFLAGS_BASE)
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Recipes
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
.section .bss
|
||||
.balign 8
|
||||
|
||||
.global lbl_8056A0A0
|
||||
lbl_8056A0A0:
|
||||
.global SecParams
|
||||
SecParams:
|
||||
.skip 0x100
|
||||
.global __GBA
|
||||
__GBA:
|
||||
|
@ -19,7 +19,7 @@ __GBAReset:
|
|||
.section .data, "wa"
|
||||
.balign 8
|
||||
|
||||
lbl_803F7160:
|
||||
ResetFunctionInfo:
|
||||
.4byte OnReset
|
||||
.4byte 127
|
||||
.4byte 0
|
||||
|
@ -71,8 +71,8 @@ GBAInit:
|
|||
/* 803C9680 003C65E0 7C 03 00 16 */ mulhwu r0, r3, r0
|
||||
/* 803C9684 003C65E4 54 00 8B FE */ srwi r0, r0, 0xf
|
||||
/* 803C9688 003C65E8 1C 00 00 3C */ mulli r0, r0, 0x3c
|
||||
/* 803C968C 003C65EC 3C 60 80 57 */ lis r3, lbl_8056A0A0@ha
|
||||
/* 803C9690 003C65F0 3B 83 A0 A0 */ addi r28, r3, lbl_8056A0A0@l
|
||||
/* 803C968C 003C65EC 3C 60 80 57 */ lis r3, SecParams@ha
|
||||
/* 803C9690 003C65F0 3B 83 A0 A0 */ addi r28, r3, SecParams@l
|
||||
/* 803C9694 003C65F4 54 1E E8 FE */ srwi r30, r0, 3
|
||||
lbl_803C9698:
|
||||
/* 803C9698 003C65F8 93 DD 00 34 */ stw r30, 0x34(r29)
|
||||
|
@ -88,9 +88,9 @@ lbl_803C9698:
|
|||
/* 803C96C0 003C6620 4B FB 49 A5 */ bl OSInitAlarm
|
||||
/* 803C96C4 003C6624 4B FA 63 41 */ bl DSPInit
|
||||
/* 803C96C8 003C6628 38 00 00 00 */ li r0, 0
|
||||
/* 803C96CC 003C662C 3C 60 80 3F */ lis r3, lbl_803F7160@ha
|
||||
/* 803C96CC 003C662C 3C 60 80 3F */ lis r3, ResetFunctionInfo@ha
|
||||
/* 803C96D0 003C6630 90 0D B1 58 */ stw r0, __GBAReset@sda21(r13)
|
||||
/* 803C96D4 003C6634 38 63 71 60 */ addi r3, r3, lbl_803F7160@l
|
||||
/* 803C96D4 003C6634 38 63 71 60 */ addi r3, r3, ResetFunctionInfo@l
|
||||
/* 803C96D8 003C6638 4B FB 99 55 */ bl OSRegisterResetFunction
|
||||
/* 803C96DC 003C663C BB 61 00 0C */ lmw r27, 0xc(r1)
|
||||
/* 803C96E0 003C6640 80 01 00 24 */ lwz r0, 0x24(r1)
|
||||
|
|
|
@ -1010,7 +1010,7 @@ LIBS = [
|
|||
"mwcc_version": "1.2.5",
|
||||
"cflags": "$cflags_base",
|
||||
"objects": [
|
||||
"Dolphin/GBA/GBA",
|
||||
["Dolphin/GBA/GBA", True],
|
||||
"Dolphin/GBA/GBAGetProcessStatus",
|
||||
"Dolphin/GBA/GBAJoyBoot",
|
||||
"Dolphin/GBA/GBARead",
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
#ifndef _DOLPHIN_GBAPRIV
|
||||
#define _DOLPHIN_GBAPRIV
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#include <dolphin/gba.h>
|
||||
#include <dolphin/os.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
typedef struct GBASecParams {
|
||||
u8 data[0x40];
|
||||
} GBASecParams;
|
||||
|
||||
typedef struct GBA {
|
||||
u8 command;
|
||||
u8 src[4];
|
||||
u8 _05;
|
||||
u8 _06;
|
||||
s8 _07;
|
||||
s8 _08;
|
||||
s8 _09;
|
||||
s8 _0a;
|
||||
s8 _0b;
|
||||
s32 _0c;
|
||||
s32 _10;
|
||||
u8* status;
|
||||
u8* buffer;
|
||||
GBACallback callback;
|
||||
s32 result;
|
||||
OSThreadQueue thread_queue;
|
||||
OSTime poll_time;
|
||||
char data1[0x40u - 0x38u];
|
||||
s32 palette_color;
|
||||
s32 palette_speed;
|
||||
u8* program;
|
||||
s32 program_length;
|
||||
s32 jboot_status;
|
||||
GBACallback jboot_callback;
|
||||
char data2[0x74u - 0x58u];
|
||||
u8* challenge_cipher;
|
||||
char data3[0xf8 - 0x78u];
|
||||
GBASecParams* param;
|
||||
char data4[0x100u - 0xfcu];
|
||||
} GBA;
|
||||
|
||||
|
||||
extern GBA __GBA[4];
|
||||
extern BOOL __GBAReset;
|
||||
|
||||
void __GBASyncCallback(s32 chan, s32 ret);
|
||||
s32 __GBASync(s32 chan);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _DOLPHIN_GBAPRIV
|
|
@ -850,7 +850,9 @@ THP_FILES :=\
|
|||
$(BUILD_DIR)/asm/Dolphin/thp/THPAudio.o
|
||||
|
||||
GBA_FILES :=\
|
||||
$(BUILD_DIR)/asm/Dolphin/GBA/GBA.o\
|
||||
$(BUILD_DIR)/src/Dolphin/GBA/GBA.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)/asm/Dolphin/GBA/GBAXfer.o\
|
||||
|
|
|
@ -0,0 +1,109 @@
|
|||
#include "dolphin/GBAPriv.h"
|
||||
|
||||
static GBASecParams SecParams[4];
|
||||
GBA __GBA[4];
|
||||
BOOL __GBAReset = FALSE;
|
||||
|
||||
static BOOL OnReset(BOOL);
|
||||
|
||||
static OSResetFunctionInfo ResetFunctionInfo = {
|
||||
OnReset,
|
||||
127
|
||||
};
|
||||
|
||||
void ShortCommandProc(s32 chan, s32 ret) {
|
||||
GBA* gba;
|
||||
gba = &__GBA[chan];
|
||||
|
||||
if (gba->result != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (gba->_05 != 0 || gba->_06 != 4) {
|
||||
gba->result = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
gba->status[0] = gba->_07 & 0x3a;
|
||||
}
|
||||
|
||||
void GBAInit() {
|
||||
s32 i;
|
||||
GBA* gba;
|
||||
for (i = 0; i < 4; ++i) {
|
||||
gba = &__GBA[i];
|
||||
gba->poll_time = OSMicrosecondsToTicks(60);
|
||||
OSInitThreadQueue(&gba->thread_queue);
|
||||
gba->param = &SecParams[i];
|
||||
|
||||
// ASSERTMSG((u32) gba->param % 32 == 0)
|
||||
}
|
||||
|
||||
OSInitAlarm();
|
||||
DSPInit();
|
||||
__GBAReset = FALSE;
|
||||
|
||||
OSRegisterResetFunction(&ResetFunctionInfo);
|
||||
}
|
||||
|
||||
s32 GBAGetStatusAsync(s32 chan, u8* status, GBACallback callback) {
|
||||
GBA* gba;
|
||||
s32 ret;
|
||||
gba = &__GBA[chan];
|
||||
if (gba->callback != NULL) {
|
||||
ret = 2;
|
||||
} else {
|
||||
gba->command = 0;
|
||||
gba->status = status;
|
||||
gba->callback = callback;
|
||||
ret = __GBATransfer(chan, 1, 3, ShortCommandProc);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
s32 GBAGetStatus(s32 chan, u8* status) {
|
||||
s32 ret;
|
||||
ret = GBAGetStatusAsync(chan, status, __GBASyncCallback);
|
||||
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
return __GBASync(chan);
|
||||
}
|
||||
|
||||
|
||||
s32 GBAResetAsync(s32 chan, u8* status, GBACallback callback) {
|
||||
GBA* gba;
|
||||
s32 ret;
|
||||
gba = &__GBA[chan];
|
||||
if (gba->callback != NULL) {
|
||||
ret = 2;
|
||||
} else {
|
||||
gba->command = 0xFF;
|
||||
gba->status = status;
|
||||
gba->callback = callback;
|
||||
ret = __GBATransfer(chan, 1, 3, ShortCommandProc);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
s32 GBAReset(s32 chan, u8* status) {
|
||||
s32 ret;
|
||||
|
||||
ret = GBAResetAsync(chan, status, __GBASyncCallback);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
return __GBASync(chan);
|
||||
}
|
||||
|
||||
BOOL OnReset(BOOL) {
|
||||
__GBAReset = TRUE;
|
||||
return TRUE;
|
||||
}
|
Loading…
Reference in New Issue