GBA-Exploader/arm9/source/ctrl_tbl.cpp
ApacheThunder b0e0250f0d Add prompt for Omega DE...
* Now prompts if user is using DE or regaulr Omega if EZFlash Omega is
detected. Regular omega can be used if soft reset method is used (aka, a
cart like EZFlash Parellel is used to cause console to reboot on
reinsert). If DE mode is selected setRamPage is set to normal range and
will make it use FRAM chip. Regular Omega will use page 0x40 for RTS
section of SRAM. (normal range is read only for some reason. FPGA must
unlock it after sending specific table data to SD card buffer register
which I have not got working yet)
* NDS files can now be booted. Since bootloader from nds-hb-menu was
added to fix soft-reset stuff I might as well just add in support to
boot NDS files. :P
2024-08-12 00:24:08 -05:00

84 lines
1.5 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;
extern int carttype;
#ifdef __cplusplus
extern "C" {
#endif
extern void _RamPG(void);
extern void _RamSave(int bnk);
extern bool isOmega;
extern bool isOmegaDE;
extern bool isSuperCard;
#ifdef __cplusplus
}
#endif
void ctrl_get() {
FILE *exp;
char expfile[64];
memset((u8*)&ctrl, 0, sizeof(struct ctrl_tbl));
if (((carttype != 5) && !isSuperCard && !isOmega) || isOmegaDE) {
_RamPG();
ReadSram(SRAM_ADDR, (u8*)&ctrl, sizeof(struct ctrl_tbl));
_RamSave(0);
return;
}
if (isSuperCard) {
sprintf(expfile, "%s/SUPERCRD.dat", ini.sign_dir);
} else if (isOmega) {
sprintf(expfile, "%s/OMEGA.dat", ini.sign_dir);
} else {
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) && !isSuperCard && !isOmega) || isOmegaDE) {
_RamPG();
WriteSram(SRAM_ADDR, (u8*)&ctrl, sizeof(struct ctrl_tbl));
_RamSave(0);
return;
}
if (isSuperCard) {
sprintf(expfile, "%s/SUPERCRD.dat", ini.sign_dir);
} else if (isOmega) {
sprintf(expfile, "%s/OMEGA.dat", ini.sign_dir);
} else {
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);
}
}