mirror of
https://github.com/ApacheThunder/GBA-Exploader.git
synced 2025-06-18 19:45:39 -04:00

* FIFO on arm7 appears to now work as intended. * GBA mode switch funcition remains broken. * Default GBA_Exploader.ini file now created if one is not present. * Moved GBA_File struct to ctrl_tble and removed duplicate from main.c. This was causing issues where I would forget to update both when I removed the now unused Alias char array. All code now shares the single instance which will prevent this issue should this struct need to be updated in the future.
72 lines
1.1 KiB
C++
72 lines
1.1 KiB
C++
#include <nds.h>
|
|
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <fat.h>
|
|
#include <sys/iosupport.h>
|
|
|
|
#include "dsCard.h"
|
|
#include "GBA_ini.h"
|
|
#include "ctrl_tbl.h"
|
|
|
|
struct ctrl_tbl ctrl;
|
|
|
|
#define SRAM_ADDR 0x0A000000
|
|
|
|
|
|
extern int carttype;
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
extern void _RamPG(void);
|
|
extern void _RamSave(int bnk);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
|
|
void ctrl_get() {
|
|
FILE *exp;
|
|
char expfile[64];
|
|
|
|
memset((u8*)&ctrl, 0, sizeof(struct ctrl_tbl));
|
|
|
|
if(carttype != 5) {
|
|
_RamPG();
|
|
ReadSram(SRAM_ADDR, (u8*)&ctrl, sizeof(struct ctrl_tbl));
|
|
_RamSave(0);
|
|
return;
|
|
}
|
|
|
|
sprintf(expfile, "%s/EXP128K.dat", ini.sign_dir);
|
|
exp = fopen(expfile, "rb");
|
|
if(exp != NULL) {
|
|
fread(&ctrl, 1, sizeof(struct ctrl_tbl), exp);
|
|
fclose(exp);
|
|
}
|
|
}
|
|
|
|
void ctrl_set() {
|
|
FILE *exp;
|
|
char expfile[64];
|
|
|
|
if(carttype != 5) {
|
|
_RamPG();
|
|
WriteSram(SRAM_ADDR, (u8*)&ctrl, sizeof(struct ctrl_tbl));
|
|
_RamSave(0);
|
|
return;
|
|
}
|
|
|
|
sprintf(expfile, "%s/EXP128K.dat", ini.sign_dir);
|
|
exp = fopen(expfile, "wb");
|
|
if(exp != NULL) {
|
|
fwrite(&ctrl, 1, sizeof(struct ctrl_tbl), exp);
|
|
fclose(exp);
|
|
}
|
|
}
|
|
|