File browser fixes ....

* File browser is now functional.
* Soft reset stuff still broken.
This commit is contained in:
ApacheThunder 2024-05-08 07:56:20 -05:00
parent d8f3fd9832
commit fd132bb8ab
7 changed files with 156 additions and 356 deletions

1
.gitignore vendored
View File

@ -41,6 +41,7 @@
*.arm7 *.arm7
*.arm9 *.arm9
*.elf *.elf
*.dldi
build build
data data
title title

View File

@ -29,29 +29,33 @@
---------------------------------------------------------------------------------*/ ---------------------------------------------------------------------------------*/
#include <nds.h> #include <nds.h>
/*void gbaMode() { void gbaMode() {
vu32 vr; vu32 vr;
REG_IME = IME_DISABLE; REG_IME = IME_DISABLE;
for(vr = 0; vr < 0x1000; vr++); // Wait ARM9 for(vr = 0; vr < 0x1000; vr++); // Wait ARM9
if (((*(vu32*)0x027FFCE4 >> 3) & 0x01) == 0x01) if (((*(vu32*)0x027FFCE4 >> 3) & 0x01) == 0x01) {
writePowerManagement(0, PM_BACKLIGHT_BOTTOM | PM_SOUND_AMP); writePowerManagement(0, PM_BACKLIGHT_BOTTOM | PM_SOUND_AMP);
else writePowerManagement(0, PM_BACKLIGHT_TOP | PM_SOUND_AMP); } else {
writePowerManagement(0, PM_BACKLIGHT_TOP | PM_SOUND_AMP);
}
swiSwitchToGBAMode(); swiSwitchToGBAMode();
// asm("mov r2, #0x40"); // asm("mov r2, #0x40");
// asm("swi 0x1F0000"); // asm("swi 0x1F0000");
while(1); while(1);
}*/ }
volatile bool exitflag = false; volatile bool exitflag = false;
void powerButtonCB() { exitflag = true; } void powerButtonCB() { exitflag = true; }
void VblankHandler(void) { /*Wifi_Update();*/ } void VblankHandler(void) {
// Wifi_Update();
}
void VcountHandler() { inputGetAndSend(); } void VcountHandler() { inputGetAndSend(); }
@ -59,6 +63,7 @@ void VcountHandler() { inputGetAndSend(); }
int main() { int main() {
readUserSettings(); readUserSettings();
ledBlink(0); ledBlink(0);
bool switchedMode = false;
irqInit(); irqInit();
// Start the RTC tracking IRQ // Start the RTC tracking IRQ
@ -73,18 +78,23 @@ int main() {
irqSet(IRQ_VCOUNT, VcountHandler); irqSet(IRQ_VCOUNT, VcountHandler);
irqSet(IRQ_VBLANK, VblankHandler); irqSet(IRQ_VBLANK, VblankHandler);
irqEnable( IRQ_VBLANK | IRQ_VCOUNT); irqEnable(IRQ_VBLANK | IRQ_VCOUNT);
/*if (REG_SNDEXTCNT != 0) { /*if (REG_SNDEXTCNT != 0) {
i2cWriteRegister(0x4A, 0x12, 0x00); // Press power-button for auto-reset i2cWriteRegister(0x4A, 0x12, 0x00); // Press power-button for auto-reset
i2cWriteRegister(0x4A, 0x70, 0x01); // Bootflag = Warmboot/SkipHealthSafety i2cWriteRegister(0x4A, 0x70, 0x01); // Bootflag = Warmboot/SkipHealthSafety
}*/ }*/
setPowerButtonCB(powerButtonCB); setPowerButtonCB(powerButtonCB);
// Keep the ARM7 mostly idle // Keep the ARM7 mostly idle
while(1)swiWaitForVBlank(); while(1) {
if(fifoCheckValue32(FIFO_USER_01) && !switchedMode) {
switchedMode = true;
gbaMode();
}
swiWaitForVBlank();
}
return 0; return 0;
} }

View File

@ -17,3 +17,4 @@ extern void GBA_ini();
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -21,8 +21,7 @@ u8 *RemainPtr;
u32 RemainByte; u32 RemainByte;
static int _type_chk(u32 *pbuf, u32 c, u32 ofs) static int _type_chk(u32 *pbuf, u32 c, u32 ofs) {
{
switch(pbuf[c]) { switch(pbuf[c]) {
case 0x53414C46: // FLASH case 0x53414C46: // FLASH
if(pbuf[c + 1] == 0x5F4D3148) { // FLASH1M_V if(pbuf[c + 1] == 0x5F4D3148) { // FLASH1M_V

View File

@ -1,7 +1,6 @@
#include <nds.h> #include <nds.h>
#include <fat.h> #include <fat.h>
// #include "fatdir_ex.h"
#include <sys/iosupport.h> #include <sys/iosupport.h>
#include <stdio.h> #include <stdio.h>
@ -58,36 +57,35 @@ extern "C" {
#endif #endif
extern char curpath[]; extern char curpath[];
extern int sortfile[]; extern int sortfile[];
struct GBA_File {
char Alias[13]; struct GBA_File {
u32 type; u32 type;
char filename[512]; char filename[512];
u32 filesize; u32 filesize;
char gametitle[13]; char gametitle[13];
char gamecode[5]; char gamecode[5];
}; };
extern struct GBA_File fs[];
extern char tbuf[];
extern u8 *rwbuf;
extern int numFiles; extern struct GBA_File fs[];
extern int numGames; extern char tbuf[];
extern u8 *rwbuf;
extern int GBAmode; extern int numFiles;
extern int numGames;
static u32 savesize; extern int GBAmode;
static u32 savesize;
int carttype = 0; int carttype = 0;
extern int save_sel(int mod, char *name);
extern int save_sel(int mod, char *name);
using namespace std; using namespace std;
void SetEWINRam(u8 page) void SetEWINRam(u8 page) {
{
vu32 wait; vu32 wait;
vu8 a; vu8 a;
@ -106,8 +104,7 @@ void SetEWINRam(u8 page)
} }
int cehck_EWIN() int cehck_EWIN() {
{
vu32 wait; vu32 wait;
vu8 a, a8, a9, aa, org; vu8 a, a8, a9, aa, org;
@ -178,8 +175,7 @@ int cehck_EWIN()
return(1); return(1);
} }
bool Close_EWIN() bool Close_EWIN() {
{
vu8 a; vu8 a;
@ -200,8 +196,7 @@ bool Close_EWIN()
void SetM3Ram(u8 page) void SetM3Ram(u8 page) {
{
u32 mode; u32 mode;
vu16 tmp; vu16 tmp;
@ -241,7 +236,7 @@ void SetM3Ram(u8 page)
} }
bool _set_M3(int sw) { bool _set_M3(int sw) {
vu32 wait; vu32 wait;
vu16 tmp; vu16 tmp;
vu8 a; vu8 a;
@ -376,17 +371,14 @@ bool _set_M3(int sw) {
return true; return true;
} }
bool Close_M3() bool Close_M3() {
{
_set_M3(0); _set_M3(0);
return true; return true;
} }
int cehck_M3() int cehck_M3() {
{
vu16 tmp; vu16 tmp;
_set_M3(1); _set_M3(1);
tmp = *(vu16*)0x08000000; tmp = *(vu16*)0x08000000;
@ -407,8 +399,7 @@ int cehck_M3()
void _RamPG() void _RamPG() {
{
if(carttype == 3) { if(carttype == 3) {
SetRampage(USE_SRAM_PG_EZ4); SetRampage(USE_SRAM_PG_EZ4);
return; return;
@ -431,8 +422,7 @@ void _RamPG()
} }
void _RamSave(int bnk) void _RamSave(int bnk) {
{
if(carttype == 3) { if(carttype == 3) {
SetRampage(USE_SRAM_PSR_EZ4 + bnk * 16); SetRampage(USE_SRAM_PSR_EZ4 + bnk * 16);
return; return;
@ -446,15 +436,15 @@ void _RamSave(int bnk)
return; return;
} }
if(GBAmode == 0) if(GBAmode == 0) {
SetRampage(USE_SRAM_PSR + bnk * 16); SetRampage(USE_SRAM_PSR + bnk * 16);
else SetRampage(USE_SRAM_NOR + bnk * 16); } else {
SetRampage(USE_SRAM_NOR + bnk * 16);
}
return; return;
} }
int checkFlashID() int checkFlashID() {
{
int ewin; int ewin;
u32 id; u32 id;
@ -468,20 +458,18 @@ int checkFlashID()
CloseNorWrite(); CloseNorWrite();
carttype = id; carttype = id;
if(id == 0x227E2218)
carttype = 1; switch (id) {
if(id == 0x227E2202) case 0x227E2218: carttype = 1;
carttype = 2; case 0x227E2202: carttype = 2;
if(id == 0x227E2220) // EZ4 case 0x227E2220: carttype = 3; // EZ4
carttype = 3;
if(carttype == 0) {
if(cehck_M3())
carttype = 6;
} }
if(carttype == 0 && cehck_M3())carttype = 6;
if(carttype == 0) { if(carttype == 0) {
ewin = cehck_EWIN(); ewin = cehck_EWIN();
if(ewin > 0) if(ewin > 0)carttype = 3 + ewin;
carttype = 3 + ewin;
} }
return(carttype); return(carttype);
@ -491,8 +479,7 @@ int checkFlashID()
char const *Rudolph = "GBA ExpLoader by Rudolph (LocalCode v0.1)"; char const *Rudolph = "GBA ExpLoader by Rudolph (LocalCode v0.1)";
bool checkSRAM_cnf() bool checkSRAM_cnf() {
{
int i; int i;
ctrl_get(); ctrl_get();
@ -509,8 +496,7 @@ bool checkSRAM_cnf()
} }
int checkSRAM(char *name) int checkSRAM(char *name) {
{
int i, ln; int i, ln;
@ -557,8 +543,7 @@ int checkSRAM(char *name)
return true; return true;
} }
void setGBAmode() void setGBAmode() {
{
if(ctrl.mode != (char)GBAmode) { if(ctrl.mode != (char)GBAmode) {
ctrl.mode = (char)GBAmode; ctrl.mode = (char)GBAmode;
// if(carttype < 4) // if(carttype < 4)
@ -569,8 +554,7 @@ void setGBAmode()
} }
} }
void getGBAmode() void getGBAmode() {
{
// ctrl_get(); // ctrl_get();
GBAmode = ctrl.mode; GBAmode = ctrl.mode;
if((GBAmode < 0) || (GBAmode > 2)) { if((GBAmode < 0) || (GBAmode > 2)) {
@ -579,16 +563,14 @@ void getGBAmode()
} }
} }
void setcurpath() void setcurpath() {
{
memset(ctrl.path, 0, 256); memset(ctrl.path, 0, 256);
strcpy((char *)ctrl.path, curpath); strcpy((char *)ctrl.path, curpath);
ctrl_set(); ctrl_set();
} }
void getcurpath() void getcurpath() {
{
if(ctrl.path[0] != '/') { if(ctrl.path[0] != '/') {
ctrl.path[0] = '/'; ctrl.path[0] = '/';
ctrl.path[1] = 0; ctrl.path[1] = 0;
@ -641,20 +623,16 @@ bool getSaveFilename(int sel, char *savename)
} }
*******************/ *******************/
bool checkBackup() bool checkBackup() {
{ if(GBAmode == 1)return true;
if(GBAmode == 1)
return true;
if(ctrl.save_flg[GBAmode] == 0xFF) if(ctrl.save_flg[GBAmode] == 0xFF)return false;
return false;
return true; return true;
} }
void writeSramToFile(char *savename) void writeSramToFile(char *savename) {
{
FILE *saver; FILE *saver;
u32 len; u32 len;
@ -699,8 +677,7 @@ void writeSramToFile(char *savename)
void _WritePSram(uint32 address, u8* data , uint32 size ); void _WritePSram(uint32 address, u8* data , uint32 size );
void SRAMdump(int cmd) void SRAMdump(int cmd) {
{
FILE *dmp; FILE *dmp;
int i; int i;
int mx; int mx;
@ -756,8 +733,7 @@ void SRAMdump(int cmd)
_RamSave(0); _RamSave(0);
} }
void blankSRAM(char *savename) void blankSRAM(char *savename) {
{
memset(rwbuf, 0xFF, USE_SRAM / 2); memset(rwbuf, 0xFF, USE_SRAM / 2);
@ -782,8 +758,7 @@ void blankSRAM(char *savename)
CloseNorWrite(); CloseNorWrite();
} }
void writeSramFromFile(char *savename) void writeSramFromFile(char *savename) {
{
FILE *saver; FILE *saver;
if(savename[0] == 0) return; if(savename[0] == 0) return;
@ -833,8 +808,7 @@ void writeSramFromFile(char *savename)
} }
void _ReadPSram(uint32 address, u8* data , uint32 size ) void _ReadPSram(uint32 address, u8* data , uint32 size ) {
{
u32 i; u32 i;
u16* pData = (u16*)data; u16* pData = (u16*)data;
u16* sData = (u16*)address; u16* sData = (u16*)address;
@ -843,14 +817,12 @@ void _ReadPSram(uint32 address, u8* data , uint32 size )
pData[i] = sData[i]; pData[i] = sData[i];
} }
void _WritePSram(uint32 address, u8* data , uint32 size ) void _WritePSram(uint32 address, u8* data , uint32 size ) {
{
u32 i; u32 i;
u16* sData = (u16*)data; u16* sData = (u16*)data;
u16* pData = (u16*)address; u16* pData = (u16*)address;
for(i = 0; i < size / 2; i++) for(i = 0; i < size / 2; i++)pData[i] = sData[i];
pData[i] = sData[i];
} }
@ -858,8 +830,7 @@ extern void turn_off(int cmd);
extern void dsp_bar(int mod, int per); extern void dsp_bar(int mod, int per);
int writeFileToNor(int sel) int writeFileToNor(int sel) {
{
FILE *gbaFile; FILE *gbaFile;
char savName[512]; char savName[512];
u32 siz, wsz; u32 siz, wsz;
@ -878,14 +849,15 @@ int writeFileToNor(int sel)
if(checkSRAM(savName) == false) { if(checkSRAM(savName) == false) {
err_cnf(4, 5); err_cnf(4, 5);
} else { } else {
if(save_sel(1, savName) >= 0) if(save_sel(1, savName) >= 0)writeSramToFile(savName);
writeSramToFile(savName);
} }
if((fs[sel].Alias[strlen(fs[sel].Alias) - 3] != 'G') || // if((fs[sel].Alias[strlen(fs[sel].Alias) - 3] != 'G') || (fs[sel].Alias[strlen(fs[sel].Alias) - 3] != 'g')) {
(fs[sel].Alias[strlen(fs[sel].Alias) - 3] != 'g')) if((fs[sel].filename[strlen(fs[sel].filename) - 3] != 'G') || (fs[sel].filename[strlen(fs[sel].filename) - 3] != 'g')) {
gba = false; gba = false;
else gba = true; } else {
gba = true;
}
sprintf(tbuf, "%s%s", curpath, fs[sel].filename); sprintf(tbuf, "%s%s", curpath, fs[sel].filename);
@ -954,8 +926,7 @@ int writeFileToNor(int sel)
} }
int writeFileToRam(int sel) int writeFileToRam(int sel) {
{
FILE *gbaFile; FILE *gbaFile;
char savName[512]; char savName[512];
u32 siz; u32 siz;
@ -973,19 +944,19 @@ int writeFileToRam(int sel)
else exp = 0x08060000; else exp = 0x08060000;
exps = exp; exps = exp;
if(fs[sel].filesize > fsz) { if(fs[sel].filesize > fsz)return(1);
return(1);
}
// if(checkSRAM(savName) == false) { // if(checkSRAM(savName) == false) {
// err_cnf(4, 5); // err_cnf(4, 5);
// } else writeSramToFile(savName); // } else writeSramToFile(savName);
if((fs[sel].Alias[strlen(fs[sel].Alias) - 3] != 'G') || // if((fs[sel].Alias[strlen(fs[sel].Alias) - 3] != 'G') || (fs[sel].Alias[strlen(fs[sel].Alias) - 3] != 'g')) {
(fs[sel].Alias[strlen(fs[sel].Alias) - 3] != 'g')) if((fs[sel].filename[strlen(fs[sel].filename) - 3] != 'G') || (fs[sel].filename[strlen(fs[sel].filename) - 3] != 'g')) {
gba = false; gba = false;
else gba = true; } else {
gba = true;
}
sprintf(tbuf, "%s%s", curpath, fs[sel].filename); sprintf(tbuf, "%s%s", curpath, fs[sel].filename);
@ -1066,8 +1037,7 @@ int writeFileToRam(int sel)
} }
void QSort(int left, int right) void QSort(int left, int right) {
{
int i, j; int i, j;
int p; int p;
int tmp; int tmp;
@ -1103,8 +1073,7 @@ void QSort(int left, int right)
} }
static void _sort_file() static void _sort_file() {
{
int i, j; int i, j;
int no; int no;
@ -1149,21 +1118,15 @@ bool nameEndsWith (const string& name, const string& extension) {
void FileListGBA() { void FileListGBA() {
DIR *dir; DIR *dir;
struct stat st; struct stat st;
// char fname[256];
// char lfnname[512];
// u32 flen;
FILE *gbaFile; FILE *gbaFile;
int i; int i;
// mkdir("/GBA_SAVE");
// FAT_CWD("/GBA_Exp");
numFiles = 0; numFiles = 0;
numGames = 0; numGames = 0;
chdir (curpath); chdir (curpath);
dir = opendir(curpath); dir = opendir(curpath);
if(dir == NULL) { if(dir == NULL) {
strcpy(curpath, "/"); strcpy(curpath, "/");
dir = opendir(curpath); dir = opendir(curpath);
@ -1176,48 +1139,26 @@ void FileListGBA() {
while(true) { while(true) {
dirent* pent = readdir(dir); dirent* pent = readdir(dir);
if(pent == NULL)break; if(pent == NULL)break;
stat(pent->d_name, &st); stat(pent->d_name, &st);
if ((((string)pent->d_name).compare(".") == 0) || ((st.st_mode & S_IFMT) == S_IFDIR) || nameEndsWith(pent->d_name, GBAEXT) || nameEndsWith(pent->d_name, BINEXT)) {
if (((string)pent->d_name).compare(".") != 0 && ((st.st_mode & S_IFMT) != S_IFDIR) && (nameEndsWith(pent->d_name, GBAEXT) || nameEndsWith(pent->d_name, BINEXT))) {
strcpy(fs[numFiles].filename, pent->d_name); strcpy(fs[numFiles].filename, pent->d_name);
strcpy(fs[numFiles].Alias, pent->d_name); // strcpy(fs[numFiles].Alias, pent->d_name);
fs[numFiles].type = st.st_mode; fs[numFiles].type = st.st_mode;
FILE *file = fopen(pent->d_name, "rb"); if ((((string)pent->d_name).compare(".") != 0) && ((st.st_mode & S_IFMT) != S_IFDIR)) {
if (file) { FILE *file = fopen(pent->d_name, "rb");
fseek(file, 0, SEEK_END); if (file) {
fs[numFiles].filesize = ftell(file); fseek(file, 0, SEEK_END);
fclose(file); fs[numFiles].filesize = ftell(file);
fclose(file);
}
} }
numFiles++; numFiles++;
if (numFiles > 199 )break; if (numFiles > 199)break;
} }
} }
closedir(dir); closedir(dir);
} }
/*while(dirnextl(dir, fname, lfnname, &st) == 0) {
flen = strlen(fname);
if(lfnname[0] == 0)
strcpy(lfnname, fname);
if(((st.st_mode & S_IFDIR) && strcmp(fname, ".")) ||
((fname[flen - 3] == 'G') && (fname[flen - 2] == 'B') && (fname[flen - 1] == 'A')) ||
((fname[flen - 3] == 'B') && (fname[flen - 2] == 'I') && (fname[flen - 1] == 'N'))) {
strcpy(fs[numFiles].Alias, fname);
strcpy(fs[numFiles].filename, lfnname);
// strcpy(fs[numFiles].filename, fname);
fs[numFiles].filesize = st.st_size;
fs[numFiles].type = st.st_mode;
// if((st.st_mode & S_IFDIR) && !strcmp(fname, ".."))
// strcpy(fs[numFiles].filename, "..");
numFiles++;
if(numFiles > 199) break;
}
}*/
// dirclose(dir);
// closedir(dir);
for(i = 0; i < numFiles; i++) { for(i = 0; i < numFiles; i++) {
sortfile[i] = i; sortfile[i] = i;
if(fs[i].type & S_IFDIR) { if(fs[i].type & S_IFDIR) {
@ -1237,12 +1178,11 @@ void FileListGBA() {
} }
} }
if(numFiles > 1) if(numFiles > 1)_sort_file();
// QSort(0, numFiles - 1);
_sort_file();
} }
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -94,20 +94,10 @@ u8 *rwbuf;
extern int carttype; extern int carttype;
void Vblank() void Vblank() { }
{
}
void FIFOInit() // void FIFOInit() { REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR; }
{ // void FIFOSend(u32 val) { REG_IPC_FIFO_TX = val; }
REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR;
}
void FIFOSend(u32 val)
{
REG_IPC_FIFO_TX = val;
}
@ -137,12 +127,13 @@ extern bool ret_menu_chk(void);
extern bool ret_menu9_Gen(void); extern bool ret_menu9_Gen(void);
extern void ret_menu9_GENs(void); extern void ret_menu9_GENs(void);
void turn_off(int cmd) void turn_off(int cmd) {
{ if(cmd == 0) { // “dŒ¹f
if(cmd == 0) // “dŒ¹f // FIFOSend(IPC_CMD_TURNOFF);
FIFOSend(IPC_CMD_TURNOFF); systemShutDown();
if(cmd == 1) { // R4 Soft Reset }
FIFOSend(IPC_CMD_SR_R4TF); /*if(cmd == 1) { // R4 Soft Reset
// FIFOSend(IPC_CMD_SR_R4TF);
REG_IME = 0; REG_IME = 0;
REG_IE = 0; REG_IE = 0;
REG_IF = REG_IF; REG_IF = REG_IF;
@ -163,14 +154,13 @@ void turn_off(int cmd)
ret_menu9_Gen(); ret_menu9_Gen();
FIFOSend(IPC_CMD_SR_GEN); FIFOSend(IPC_CMD_SR_GEN);
ret_menu9_GENs(); ret_menu9_GENs();
} }*/
while(1); while(1);
} }
void gba_frame() void gba_frame() {
{
int ret; int ret;
int x=0, y=0; int x=0, y=0;
u16 *pDstBuf1; u16 *pDstBuf1;
@ -198,8 +188,7 @@ void gba_frame()
} }
} }
static void resetToSlot2() static void resetToSlot2() {
{
vu32 vr; vu32 vr;
// make arm9 loop code // make arm9 loop code
@ -209,7 +198,7 @@ static void resetToSlot2()
sysSetCartOwner(BUS_OWNER_ARM7); // ARM7 has access to GBA cart sysSetCartOwner(BUS_OWNER_ARM7); // ARM7 has access to GBA cart
FIFOSend(IPC_CMD_SLOT2); // FIFOSend(IPC_CMD_SLOT2);
for(vr = 0; vr < 0x20000; vr++); // Wait ARM7 for(vr = 0; vr < 0x20000; vr++); // Wait ARM7
@ -218,12 +207,11 @@ static void resetToSlot2()
swiSoftReset(); swiSoftReset();
} }
void gbaMode() void gbaMode() {
{
if(strncmp(GBA_HEADER.gamecode, "PASS", 4) == 0) { if(strncmp(GBA_HEADER.gamecode, "PASS", 4) == 0) {
resetARM9Memory(); resetARM9Memory();
resetToSlot2(); resetToSlot2();
} }
videoSetMode(0); videoSetMode(0);
@ -239,7 +227,8 @@ void gbaMode()
gba_frame(); gba_frame();
FIFOSend(IPC_CMD_GBAMODE); // FIFOSend(IPC_CMD_GBAMODE);
fifoSendValue32(FIFO_USER_01, 1);
sysSetBusOwners(ARM7_OWNS_CARD, ARM7_OWNS_ROM); sysSetBusOwners(ARM7_OWNS_CARD, ARM7_OWNS_ROM);
REG_IME = 0; REG_IME = 0;
@ -247,8 +236,7 @@ void gbaMode()
} }
void err_cnf(int n1, int n2) void err_cnf(int n1, int n2) {
{
int len; int len;
int x1, x2; int x1, x2;
int y1, y2; int y1, y2;
@ -297,8 +285,7 @@ void err_cnf(int n1, int n2)
} }
int cnf_inp(int n1, int n2) int cnf_inp(int n1, int n2) {
{
int len; int len;
int x1, x2; int x1, x2;
int y1, y2; int y1, y2;
@ -349,8 +336,7 @@ int cnf_inp(int n1, int n2)
u16 *gbar = NULL; u16 *gbar = NULL;
int oldper; int oldper;
void dsp_bar(int mod, int per) void dsp_bar(int mod, int per) {
{
int x1, x2; int x1, x2;
int y1, y2; int y1, y2;
int xi, yi; int xi, yi;
@ -407,8 +393,7 @@ void dsp_bar(int mod, int per)
void RamClear() void RamClear() {
{
u32 *a8; //, *a9; u32 *a8; //, *a9;
int i; int i;
@ -433,15 +418,10 @@ int GBAmode;
int r4tf; int r4tf;
void _dsp_clear() void _dsp_clear() { DrawBox_SUB(SubScreen, 0, 28, 255, 114, 0, 1); }
{
DrawBox_SUB(SubScreen, 0, 28, 255, 114, 0, 1);
}
int rumble_cmd() int rumble_cmd() {
{
int cmd = 0; int cmd = 0;
u32 ky, repky; u32 ky, repky;
int i; int i;
@ -552,8 +532,7 @@ int rumble_cmd()
} }
void _gba_dsp(int no, int mod, int x, int y) void _gba_dsp(int no, int mod, int x, int y) {
{
char dsp[40]; char dsp[40];
int sn; int sn;
@ -613,8 +592,7 @@ extern bool checkSRAM_cnf();
extern int checkSRAM(char *name); extern int checkSRAM(char *name);
void _gba_sel_dsp(int no, int yc, int mod) void _gba_sel_dsp(int no, int yc, int mod) {
{
int x, y; int x, y;
int st, i; int st, i;
int len; int len;
@ -790,8 +768,7 @@ extern void FileListGBA(void);
extern int save_sel(int mod, char *name); extern int save_sel(int mod, char *name);
int gba_sel() int gba_sel() {
{
// u32 i; // u32 i;
int cmd = -1; int cmd = -1;
@ -1051,8 +1028,7 @@ inp_key();
extern void setLang(void); extern void setLang(void);
void mainloop(void) void mainloop(void) {
{
// vu16 reg; // vu16 reg;
FILE *r4dt; FILE *r4dt;
@ -1114,10 +1090,11 @@ REG_EXMEMCNT = (reg & 0xFFE0) | (1 << 4) | (1 << 2) | 1;
if(carttype <= 2) { if(carttype <= 2) {
// SetRampage(16); // SetRampage(16);
// SetShake(0x08); // SetShake(0x08);
if(carttype == 1) if(carttype == 1) {
ShinoPrint_SUB( SubScreen, 23*6, 1*12-2, (u8*)" [ 3in1 ]", 0, 0, 0 ); ShinoPrint_SUB( SubScreen, 23*6, 1*12-2, (u8*)" [ 3in1 ]", 0, 0, 0 );
else } else {
ShinoPrint_SUB( SubScreen, 23*6, 1*12-2, (u8*)"[New3in1]", 0, 0, 0 ); ShinoPrint_SUB( SubScreen, 23*6, 1*12-2, (u8*)"[New3in1]", 0, 0, 0 );
}
} }
if(carttype == 3) { if(carttype == 3) {
SetRompage(0x300); SetRompage(0x300);
@ -1198,8 +1175,7 @@ inp_key();
if(checkSRAM_cnf() == false) { if(checkSRAM_cnf() == false) {
if(carttype != 5) { if(carttype != 5) {
if(cnf_inp(9, 10) & KEY_B) if(cnf_inp(9, 10) & KEY_B)turn_off(r4tf);
turn_off(r4tf);
} }
} }
@ -1215,21 +1191,18 @@ inp_key();
GBAmode = 0; GBAmode = 0;
if(checkSRAM(filename) && checkBackup()) { if(checkSRAM(filename) && checkBackup()) {
if(save_sel(1, filename) >= 0) if(save_sel(1, filename) >= 0)writeSramToFile(filename);
writeSramToFile(filename);
} }
getGBAmode(); getGBAmode();
if((GBAmode == 2) && (r4tf == 0)) if((GBAmode == 2) && (r4tf == 0))GBAmode = 0;
GBAmode = 0; if(carttype > 2)GBAmode = 0;
if(carttype > 2)
GBAmode = 0;
cmd = -1; cmd = -1;
while(cmd == -1) { while(cmd == -1) {
if(GBAmode == 2) if(GBAmode == 2) {
cmd = rumble_cmd(); cmd = rumble_cmd();
else { } else {
// FileListGBA(); // FileListGBA();
// setcurpath(); // setcurpath();
// if(numFiles == 0) // if(numFiles == 0)
@ -1270,21 +1243,21 @@ int main(void) {
int i; int i;
vramSetPrimaryBanks(VRAM_A_LCD , VRAM_B_LCD , VRAM_C_SUB_BG, VRAM_D_MAIN_BG ); vramSetPrimaryBanks(VRAM_A_LCD, VRAM_B_LCD, VRAM_C_SUB_BG, VRAM_D_MAIN_BG);
powerOn(POWER_ALL); powerOn(POWER_ALL);
irqInit(); irqInit();
irqSet(IRQ_VBLANK, Vblank); irqSet(IRQ_VBLANK, Vblank);
irqEnable(IRQ_VBLANK); irqEnable(IRQ_VBLANK);
FIFOInit(); // FIFOInit();
videoSetMode(MODE_FB0 | DISPLAY_BG2_ACTIVE); videoSetMode(MODE_FB0 | DISPLAY_BG2_ACTIVE);
videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE ); videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE );
// SUB_BG0_CR = BG_256_COLOR | BG_MAP_BASE(0) | BG_TILE_BASE(1); // SUB_BG0_CR = BG_256_COLOR | BG_MAP_BASE(0) | BG_TILE_BASE(1);
REG_BG0CNT_SUB = BG_256_COLOR | BG_MAP_BASE(0) | BG_TILE_BASE(1); REG_BG0CNT_SUB = BG_256_COLOR | BG_MAP_BASE(0) | BG_TILE_BASE(1);
uint16* map1 = (uint16*)BG_MAP_RAM_SUB(0); uint16* map1 = (uint16*)BG_MAP_RAM_SUB(0);
for(i=0;i<(256*192/8/8);i++) map1[i]=i; for(i=0;i<(256*192/8/8);i++) map1[i]=i;
lcdMainOnTop(); lcdMainOnTop();
//メイン画面を白で塗りつぶします //メイン画面を白で塗りつぶします
ClearBG( MainScreen, RGB15(31,31,31) ); ClearBG( MainScreen, RGB15(31,31,31) );

View File

@ -1,124 +0,0 @@
/*
partition.h
Functions for mounting and dismounting partitions
on various block devices.
Copyright (c) 2006 Michael "Chishm" Chisholm
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2006-07-11 - Chishm
* Original release
*/
#ifndef _PARTITION_H
#define _PARTITION_H
#include "common.h"
#include "disc_io/disc.h"
#include "cache.h"
// Device name
extern const char* DEVICE_NAME;
// Filesystem type
typedef enum {FS_UNKNOWN, FS_FAT12, FS_FAT16, FS_FAT32} FS_TYPE;
#ifdef NDS
//typedef enum {PI_DEFAULT, PI_SLOT_1, PI_SLOT_2, PI_CUSTOM} PARTITION_INTERFACE;
#else
typedef enum {PI_CART_SLOT} PARTITION_INTERFACE;
#endif
typedef struct {
u32 fatStart;
u32 sectorsPerFat;
u32 lastCluster;
u32 firstFree;
} FAT;
typedef struct {
const IO_INTERFACE* disc;
CACHE* cache;
// Info about the partition
bool readOnly; // If this is set, then do not try writing to the disc
FS_TYPE filesysType;
u32 totalSize;
u32 rootDirStart;
u32 rootDirCluster;
u32 numberOfSectors;
u32 dataStart;
u32 bytesPerSector;
u32 sectorsPerCluster;
u32 bytesPerCluster;
FAT fat;
// Values that may change after construction
u32 cwdCluster; // Current working directory cluser
u32 openFileCount;
} PARTITION;
/*
Mount the device specified by partitionDevice
PD_DEFAULT is not allowed, use _FAT_partition_setDefaultDevice
PD_CUSTOM is not allowed, use _FAT_partition_mountCustomDevice
*/
bool _FAT_partition_mount (PARTITION_INTERFACE partitionNumber, u32 cacheSize);
/*
Mount a partition on a custom device
*/
bool _FAT_partition_mountCustomInterface (const IO_INTERFACE* device, u32 cacheSize);
/*
Unmount the partition specified by partitionNumber
If there are open files, it will fail
*/
bool _FAT_partition_unmount (PARTITION_INTERFACE partitionNumber);
/*
Forcibly unmount the partition specified by partitionNumber
Any open files on the partition will become invalid
The cache will be invalidated, and any unflushed writes will be lost
*/
bool _FAT_partition_unsafeUnmount (PARTITION_INTERFACE partitionNumber);
/*
Set the default device for access by fat: and fat0:,
based on the device number
*/
bool _FAT_partition_setDefaultInterface (PARTITION_INTERFACE partitionNumber);
/*
Set the default device for access by fat: and fat0:,
based on the partition pointer
*/
bool _FAT_partition_setDefaultPartition (PARTITION* partition);
/*
Return the partition specified in a path
For instance, "fat0:", "fat:", "/" and "fat:/" will all
return the default partition
*/
PARTITION* _FAT_partition_getPartitionFromPath (const char* path);
#endif // _PARTITION_H