summaryrefslogtreecommitdiff
path: root/arm9/lib/include
diff options
context:
space:
mode:
Diffstat (limited to 'arm9/lib/include')
-rw-r--r--arm9/lib/include/CTRDG_backup.h41
-rw-r--r--arm9/lib/include/CTRDG_flash.h25
-rw-r--r--arm9/lib/include/CTRDG_task.h25
-rw-r--r--arm9/lib/include/MI_exMemory.h18
4 files changed, 109 insertions, 0 deletions
diff --git a/arm9/lib/include/CTRDG_backup.h b/arm9/lib/include/CTRDG_backup.h
new file mode 100644
index 00000000..d248b7a1
--- /dev/null
+++ b/arm9/lib/include/CTRDG_backup.h
@@ -0,0 +1,41 @@
+#ifndef POKEDIAMOND_CTRDG_BACKUP_H
+#define POKEDIAMOND_CTRDG_BACKUP_H
+
+#include "nitro/types.h"
+#include "CTRDG_flash.h"
+#include "CTRDG_task.h"
+
+typedef struct CTRDGiFlashTypePlusTag
+{
+ u16 (*CTRDGi_WriteAgbFlashSector)(u16 secNo, u8 *src);
+ u16 (*CTRDGi_EraseAgbFlashChip)(void);
+ u16 (*CTRDGi_EraseAgbFlashSector)(u16 secNo);
+ void (*CTRDGi_WriteAgbFlashSectorAsync)(u16 secNo, u8 *src, CTRDG_TASK_FUNC callback);
+ void (*CTRDGi_EraseAgbFlashChipAsync)(CTRDG_TASK_FUNC callback);
+ void (*CTRDGi_EraseAgbFlashSectorAsync)(u16 secNo, CTRDG_TASK_FUNC callback);
+ u16 (*CTRDGi_PollingSR)(u16 phase, u8 *adr, u16 lastData);
+ const u16 (*maxtime);
+ CTRDGFlashType type;
+} CTRDGiFlashTypePlus;
+
+typedef enum
+{
+ CTRDG_BACKUP_TYPE_FLASH_512K,
+ CTRDG_BACKUP_TYPE_FLASH_1M,
+ CTRDG_BACKUP_TYPE_SRAM
+} CTRDGBackupType;
+
+extern const u16 (*ctrdgi_fl_maxtime);
+
+extern u16 (*CTRDGi_PollingSR)(u16 phase, u8 *adr, u16 lastData);
+extern const CTRDGFlashType *AgbFlash;
+extern u16 (*CTRDGi_WriteAgbFlashSector)(u16 secNo, u8 *src);
+extern u16 (*CTRDGi_EraseAgbFlashChip)(void);
+extern u16 (*CTRDGi_EraseAgbFlashSector)(u16 secNo);
+extern void (*CTRDGi_WriteAgbFlashSectorAsync)(u16 secNo, u8 *src, CTRDG_TASK_FUNC callback);
+extern void (*CTRDGi_EraseAgbFlashChipAsync)(CTRDG_TASK_FUNC callback);
+extern void (*CTRDGi_EraseAgbFlashSectorAsync)(u16 secNo, CTRDG_TASK_FUNC callback);
+
+u16 CTRDG_IdentifyAgbBackup(CTRDGBackupType type);
+
+#endif //POKEDIAMOND_CTRDG_BACKUP_H
diff --git a/arm9/lib/include/CTRDG_flash.h b/arm9/lib/include/CTRDG_flash.h
new file mode 100644
index 00000000..9a4aff41
--- /dev/null
+++ b/arm9/lib/include/CTRDG_flash.h
@@ -0,0 +1,25 @@
+#ifndef POKEDIAMOND_CTRDG_FLASH_H
+#define POKEDIAMOND_CTRDG_FLASH_H
+
+#include "nitro/types.h"
+#include "MI_exMemory.h"
+
+typedef struct CTRDGiFlashSectorTag
+{
+ u32 size;
+ u16 shift;
+ u16 count;
+ u16 top;
+ u8 reserved[2];
+} CTRDGiFlashSector;
+
+typedef struct CTRDGFlashTypeTag
+{
+ u32 romSize;
+ CTRDGiFlashSector sector;
+ MICartridgeRamCycle agbWait[2];
+ u16 makerID;
+ u16 deviceID;
+} CTRDGFlashType;
+
+#endif //POKEDIAMOND_CTRDG_FLASH_H
diff --git a/arm9/lib/include/CTRDG_task.h b/arm9/lib/include/CTRDG_task.h
new file mode 100644
index 00000000..2cf7a233
--- /dev/null
+++ b/arm9/lib/include/CTRDG_task.h
@@ -0,0 +1,25 @@
+#ifndef POKEDIAMOND_CTRDG_TASK_H
+#define POKEDIAMOND_CTRDG_TASK_H
+
+#include "nitro/types.h"
+
+struct CTRDGTaskInfo_tag;
+
+typedef u32 (*CTRDG_TASK_FUNC) (struct CTRDGTaskInfo_tag *);
+
+typedef struct CTRDGTaskInfo_tag
+{
+ CTRDG_TASK_FUNC task;
+ CTRDG_TASK_FUNC callback;
+ u32 result;
+ u8 *data;
+ u8 *adr;
+ u32 offset;
+ u32 size;
+ u8 *dst;
+ u16 sec_num;
+ u8 busy;
+ u8 param[1];
+} CTRDGTaskInfo;
+
+#endif //POKEDIAMOND_CTRDG_TASK_H
diff --git a/arm9/lib/include/MI_exMemory.h b/arm9/lib/include/MI_exMemory.h
index df46b008..aa90a73c 100644
--- a/arm9/lib/include/MI_exMemory.h
+++ b/arm9/lib/include/MI_exMemory.h
@@ -22,6 +22,14 @@ typedef enum
MI_CTRDG_ROMCYCLE2_4 = 1
} MICartridgeRomCycle2nd;
+typedef enum
+{
+ MI_CTRDG_RAMCYCLE_10 = 0,
+ MI_CTRDG_RAMCYCLE_8 = 1,
+ MI_CTRDG_RAMCYCLE_6 = 2,
+ MI_CTRDG_RAMCYCLE_18 = 3
+} MICartridgeRamCycle;
+
static inline void MIi_SetCardProcessor(MIProcessor proc)
{
reg_MI_EXMEMCNT =
@@ -54,4 +62,14 @@ static inline void MI_SetCartridgeRomCycle2nd(MICartridgeRomCycle2nd c2)
reg_MI_EXMEMCNT = (u16)((reg_MI_EXMEMCNT & ~0x10) | (c2 << 4));
}
+static inline void MI_SetCartridgeRamCycle(MICartridgeRamCycle c)
+{
+ reg_MI_EXMEMCNT = (u16)((reg_MI_EXMEMCNT & ~3) | (c << 0));
+}
+
+static inline MICartridgeRamCycle MI_GetCartridgeRamCycle(void)
+{
+ return (MICartridgeRamCycle)((reg_MI_EXMEMCNT & 3) >> 0);
+}
+
#endif //POKEDIAMOND_MI_EXMEMORY_H