Properly split GBA library

This commit is contained in:
Phillip Stephens 2022-10-15 14:47:17 -07:00
parent 3434469fc6
commit f49d43abdc
4 changed files with 61 additions and 5 deletions

View File

@ -14,7 +14,8 @@
"stddef.h": "c", "stddef.h": "c",
"errno.h": "c", "errno.h": "c",
"ansi_files.h": "c", "ansi_files.h": "c",
"types.h": "c" "types.h": "c",
"gba.h": "c"
}, },
"files.autoSave": "onFocusChange", "files.autoSave": "onFocusChange",
"files.insertFinalNewline": true, "files.insertFinalNewline": true,

View File

@ -3,7 +3,7 @@
.section .data, "wa" .section .data, "wa"
.balign 8 .balign 8
lbl_803F71A0: D35:
.byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 .byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
.byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 2,255, 0, 33 .byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 2,255, 0, 33
.byte 19, 6, 18, 3, 18, 4, 19, 5, 0,146, 0,255, 0,136,255,255 .byte 19, 6, 18, 3, 18, 4, 19, 5, 0,146, 0,255, 0,136,255,255
@ -216,9 +216,9 @@ __GBAX02:
/* 803CB12C 003C808C 38 80 00 20 */ li r4, 0x20 /* 803CB12C 003C808C 38 80 00 20 */ li r4, 0x20
/* 803CB130 003C8090 4B FB 39 81 */ bl DCFlushRange /* 803CB130 003C8090 4B FB 39 81 */ bl DCFlushRange
/* 803CB134 003C8094 38 00 00 FF */ li r0, 0xff /* 803CB134 003C8094 38 00 00 FF */ li r0, 0xff
/* 803CB138 003C8098 3C 80 80 3F */ lis r4, lbl_803F71A0@ha /* 803CB138 003C8098 3C 80 80 3F */ lis r4, D35@ha
/* 803CB13C 003C809C 90 1F 00 AC */ stw r0, 0xac(r31) /* 803CB13C 003C809C 90 1F 00 AC */ stw r0, 0xac(r31)
/* 803CB140 003C80A0 38 84 71 A0 */ addi r4, r4, lbl_803F71A0@l /* 803CB140 003C80A0 38 84 71 A0 */ addi r4, r4, D35@l
/* 803CB144 003C80A4 3C 04 80 00 */ addis r0, r4, 0x8000 /* 803CB144 003C80A4 3C 04 80 00 */ addis r0, r4, 0x8000
/* 803CB148 003C80A8 90 1F 00 B4 */ stw r0, 0xb4(r31) /* 803CB148 003C80A8 90 1F 00 B4 */ stw r0, 0xb4(r31)
/* 803CB14C 003C80AC 38 00 03 80 */ li r0, 0x380 /* 803CB14C 003C80AC 38 00 03 80 */ li r0, 0x380

View File

@ -1011,6 +1011,8 @@ LIBS = [
"cflags": "$cflags_base", "cflags": "$cflags_base",
"objects": [ "objects": [
"Dolphin/GBA/GBA", "Dolphin/GBA/GBA",
"Dolphin/GBA/GBAGetProcessStatus",
"Dolphin/GBA/GBAJoyBoot",
"Dolphin/GBA/GBARead", "Dolphin/GBA/GBARead",
"Dolphin/GBA/GBAWrite", "Dolphin/GBA/GBAWrite",
"Dolphin/GBA/GBAXfer", "Dolphin/GBA/GBAXfer",

View File

@ -1,10 +1,63 @@
#ifndef _DOLPHIN_GBA #ifndef _DOLPHIN_GBA
#define _DOLPHIN_GBA #define _DOLPHIN_GBA
#include <types.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
void GBAInit();
#define GBA_CHAN0 0
#define GBA_CHAN1 1
#define GBA_CHAN2 2
#define GBA_CHAN3 3
#define GBA_MAX_CHAN 4
#define GBA_ALL_KEY_MASK 0x03ff
#define GBA_A_BUTTON 0x0001
#define GBA_B_BUTTON 0x0002
#define GBA_SELECT_BUTTON 0x0004
#define GBA_START_BUTTON 0x0008
#define GBA_R_KEY 0x0010
#define GBA_L_KEY 0x0020
#define GBA_U_KEY 0x0040
#define GBA_D_KEY 0x0080
#define GBA_R_BUTTON 0x0100
#define GBA_L_BUTTON 0x0200
#define GBA_JSTAT_MASK 0x3a
#define GBA_JSTAT_FLAGS_SHIFT 4
#define GBA_JSTAT_FLAGS_MASK 0x30
#define GBA_JSTAT_PSF1 0x20
#define GBA_JSTAT_PSF0 0x10
#define GBA_JSTAT_SEND 0x08
#define GBA_JSTAT_RECV 0x02
#define GBA_READY 0
#define GBA_NOT_READY 1
#define GBA_BUSY 2
#define GBA_JOYBOOT_UNKNOWN_STATE 3
#define GBA_JOYBOOT_ERR_INVALID 4
#define GBA_JOYBOOT_PROGRAM_SIZE_MAX 0x40000
#define GBA_JOYBOOT_BOOTPARAM_OFFSET 0xc8
#define GBA_JOYBOOT_BOOTPARAM_SIZE 0x18
typedef void (*GBACallback)(s32 chan, s32 ret);
void GBAInit(void);
s32 GBAGetStatus(s32 chan, u8* status);
s32 GBAGetStatusAsync(s32 chan, u8* status, GBACallback callback);
s32 GBAReset(s32 chan, u8* status);
s32 GBAResetAsync(s32 chan, u8* status, GBACallback callback);
s32 GBAGetProcessStatus(s32 chan, u8* percentp);
s32 GBARead(s32 chan, u8* dst, u8* status);
s32 GBAReadAsync(s32 chan, u8* dst, u8* status, GBACallback callback);
s32 GBAWrite(s32 chan, u8* src, u8* status);
s32 GBAWriteAsync(s32 chan, u8* src, u8* status, GBACallback callback);
s32 GBAJoyBoot(s32 chan, s32 palette_color, s32 palette_speed, u8* programp, s32 length,
u8* status);
s32 GBAJoyBootAsync(s32 chan, s32 palette_color, s32 palette_speed, u8* programp, s32 length,
u8* status, GBACallback callback);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif