From fd132bb8abc72202078de4f0816056a1e5ba68dd Mon Sep 17 00:00:00 2001 From: ApacheThunder Date: Wed, 8 May 2024 07:56:20 -0500 Subject: [PATCH] File browser fixes .... * File browser is now functional. * Soft reset stuff still broken. --- .gitignore | 1 + arm7/source/main.c | 26 +++-- arm9/source/GBA_ini.h | 1 + arm9/source/gba_patch.cpp | 3 +- arm9/source/gbaldr.cpp | 234 ++++++++++++++------------------------ arm9/source/main.c | 123 ++++++++------------ arm9/source/partition.h | 124 -------------------- 7 files changed, 156 insertions(+), 356 deletions(-) delete mode 100644 arm9/source/partition.h diff --git a/.gitignore b/.gitignore index 99f3d42..d660a87 100644 --- a/.gitignore +++ b/.gitignore @@ -41,6 +41,7 @@ *.arm7 *.arm9 *.elf +*.dldi build data title diff --git a/arm7/source/main.c b/arm7/source/main.c index e7f11bc..a455f62 100644 --- a/arm7/source/main.c +++ b/arm7/source/main.c @@ -29,29 +29,33 @@ ---------------------------------------------------------------------------------*/ #include -/*void gbaMode() { +void gbaMode() { vu32 vr; REG_IME = IME_DISABLE; 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); - else writePowerManagement(0, PM_BACKLIGHT_TOP | PM_SOUND_AMP); + } else { + writePowerManagement(0, PM_BACKLIGHT_TOP | PM_SOUND_AMP); + } swiSwitchToGBAMode(); // asm("mov r2, #0x40"); // asm("swi 0x1F0000"); while(1); -}*/ +} volatile bool exitflag = false; void powerButtonCB() { exitflag = true; } -void VblankHandler(void) { /*Wifi_Update();*/ } +void VblankHandler(void) { + // Wifi_Update(); +} void VcountHandler() { inputGetAndSend(); } @@ -59,6 +63,7 @@ void VcountHandler() { inputGetAndSend(); } int main() { readUserSettings(); ledBlink(0); + bool switchedMode = false; irqInit(); // Start the RTC tracking IRQ @@ -73,18 +78,23 @@ int main() { irqSet(IRQ_VCOUNT, VcountHandler); irqSet(IRQ_VBLANK, VblankHandler); - irqEnable( IRQ_VBLANK | IRQ_VCOUNT); + irqEnable(IRQ_VBLANK | IRQ_VCOUNT); /*if (REG_SNDEXTCNT != 0) { i2cWriteRegister(0x4A, 0x12, 0x00); // Press power-button for auto-reset i2cWriteRegister(0x4A, 0x70, 0x01); // Bootflag = Warmboot/SkipHealthSafety }*/ - setPowerButtonCB(powerButtonCB); // Keep the ARM7 mostly idle - while(1)swiWaitForVBlank(); + while(1) { + if(fifoCheckValue32(FIFO_USER_01) && !switchedMode) { + switchedMode = true; + gbaMode(); + } + swiWaitForVBlank(); + } return 0; } diff --git a/arm9/source/GBA_ini.h b/arm9/source/GBA_ini.h index 74880b3..b20a030 100644 --- a/arm9/source/GBA_ini.h +++ b/arm9/source/GBA_ini.h @@ -17,3 +17,4 @@ extern void GBA_ini(); #ifdef __cplusplus } #endif + diff --git a/arm9/source/gba_patch.cpp b/arm9/source/gba_patch.cpp index fc39493..0cdb0e6 100644 --- a/arm9/source/gba_patch.cpp +++ b/arm9/source/gba_patch.cpp @@ -21,8 +21,7 @@ u8 *RemainPtr; 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]) { case 0x53414C46: // FLASH if(pbuf[c + 1] == 0x5F4D3148) { // FLASH1M_V diff --git a/arm9/source/gbaldr.cpp b/arm9/source/gbaldr.cpp index 102fc6c..9bdf1bb 100644 --- a/arm9/source/gbaldr.cpp +++ b/arm9/source/gbaldr.cpp @@ -1,7 +1,6 @@ #include #include -// #include "fatdir_ex.h" #include #include @@ -58,36 +57,35 @@ extern "C" { #endif -extern char curpath[]; -extern int sortfile[]; -struct GBA_File { - char Alias[13]; - u32 type; - char filename[512]; - u32 filesize; - char gametitle[13]; - char gamecode[5]; +extern char curpath[]; +extern int sortfile[]; + +struct GBA_File { + u32 type; + char filename[512]; + u32 filesize; + char gametitle[13]; + char gamecode[5]; }; -extern struct GBA_File fs[]; -extern char tbuf[]; -extern u8 *rwbuf; -extern int numFiles; -extern int numGames; +extern struct GBA_File fs[]; +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; - -extern int save_sel(int mod, char *name); +extern int save_sel(int mod, char *name); using namespace std; -void SetEWINRam(u8 page) -{ +void SetEWINRam(u8 page) { vu32 wait; vu8 a; @@ -106,8 +104,7 @@ void SetEWINRam(u8 page) } -int cehck_EWIN() -{ +int cehck_EWIN() { vu32 wait; vu8 a, a8, a9, aa, org; @@ -178,8 +175,7 @@ int cehck_EWIN() return(1); } -bool Close_EWIN() -{ +bool Close_EWIN() { vu8 a; @@ -200,8 +196,7 @@ bool Close_EWIN() -void SetM3Ram(u8 page) -{ +void SetM3Ram(u8 page) { u32 mode; vu16 tmp; @@ -241,7 +236,7 @@ void SetM3Ram(u8 page) } bool _set_M3(int sw) { - vu32 wait; + vu32 wait; vu16 tmp; vu8 a; @@ -376,17 +371,14 @@ bool _set_M3(int sw) { return true; } -bool Close_M3() -{ +bool Close_M3() { _set_M3(0); return true; } -int cehck_M3() -{ +int cehck_M3() { vu16 tmp; - _set_M3(1); tmp = *(vu16*)0x08000000; @@ -407,8 +399,7 @@ int cehck_M3() -void _RamPG() -{ +void _RamPG() { if(carttype == 3) { SetRampage(USE_SRAM_PG_EZ4); return; @@ -431,8 +422,7 @@ void _RamPG() } -void _RamSave(int bnk) -{ +void _RamSave(int bnk) { if(carttype == 3) { SetRampage(USE_SRAM_PSR_EZ4 + bnk * 16); return; @@ -446,15 +436,15 @@ void _RamSave(int bnk) return; } - if(GBAmode == 0) + if(GBAmode == 0) { SetRampage(USE_SRAM_PSR + bnk * 16); - else SetRampage(USE_SRAM_NOR + bnk * 16); + } else { + SetRampage(USE_SRAM_NOR + bnk * 16); + } return; - } -int checkFlashID() -{ +int checkFlashID() { int ewin; u32 id; @@ -468,22 +458,20 @@ int checkFlashID() CloseNorWrite(); carttype = id; - if(id == 0x227E2218) - carttype = 1; - if(id == 0x227E2202) - carttype = 2; - if(id == 0x227E2220) // EZ4 - carttype = 3; - if(carttype == 0) { - if(cehck_M3()) - carttype = 6; + + switch (id) { + case 0x227E2218: carttype = 1; + case 0x227E2202: carttype = 2; + case 0x227E2220: carttype = 3; // EZ4 } + + if(carttype == 0 && cehck_M3())carttype = 6; + if(carttype == 0) { ewin = cehck_EWIN(); - if(ewin > 0) - carttype = 3 + ewin; + if(ewin > 0)carttype = 3 + ewin; } - + return(carttype); } @@ -491,8 +479,7 @@ int checkFlashID() char const *Rudolph = "GBA ExpLoader by Rudolph (LocalCode v0.1)"; -bool checkSRAM_cnf() -{ +bool checkSRAM_cnf() { int i; ctrl_get(); @@ -509,8 +496,7 @@ bool checkSRAM_cnf() } -int checkSRAM(char *name) -{ +int checkSRAM(char *name) { int i, ln; @@ -557,8 +543,7 @@ int checkSRAM(char *name) return true; } -void setGBAmode() -{ +void setGBAmode() { if(ctrl.mode != (char)GBAmode) { ctrl.mode = (char)GBAmode; // if(carttype < 4) @@ -569,8 +554,7 @@ void setGBAmode() } } -void getGBAmode() -{ +void getGBAmode() { // ctrl_get(); GBAmode = ctrl.mode; if((GBAmode < 0) || (GBAmode > 2)) { @@ -579,16 +563,14 @@ void getGBAmode() } } -void setcurpath() -{ +void setcurpath() { memset(ctrl.path, 0, 256); strcpy((char *)ctrl.path, curpath); ctrl_set(); } -void getcurpath() -{ +void getcurpath() { if(ctrl.path[0] != '/') { ctrl.path[0] = '/'; ctrl.path[1] = 0; @@ -641,20 +623,16 @@ bool getSaveFilename(int sel, char *savename) } *******************/ -bool checkBackup() -{ - if(GBAmode == 1) - return true; +bool checkBackup() { + if(GBAmode == 1)return true; - if(ctrl.save_flg[GBAmode] == 0xFF) - return false; + if(ctrl.save_flg[GBAmode] == 0xFF)return false; return true; } -void writeSramToFile(char *savename) -{ +void writeSramToFile(char *savename) { FILE *saver; u32 len; @@ -699,8 +677,7 @@ void writeSramToFile(char *savename) void _WritePSram(uint32 address, u8* data , uint32 size ); -void SRAMdump(int cmd) -{ +void SRAMdump(int cmd) { FILE *dmp; int i; int mx; @@ -756,8 +733,7 @@ void SRAMdump(int cmd) _RamSave(0); } -void blankSRAM(char *savename) -{ +void blankSRAM(char *savename) { memset(rwbuf, 0xFF, USE_SRAM / 2); @@ -782,8 +758,7 @@ void blankSRAM(char *savename) CloseNorWrite(); } -void writeSramFromFile(char *savename) -{ +void writeSramFromFile(char *savename) { FILE *saver; 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; u16* pData = (u16*)data; u16* sData = (u16*)address; @@ -843,14 +817,12 @@ void _ReadPSram(uint32 address, u8* data , uint32 size ) pData[i] = sData[i]; } -void _WritePSram(uint32 address, u8* data , uint32 size ) -{ +void _WritePSram(uint32 address, u8* data , uint32 size ) { u32 i; u16* sData = (u16*)data; u16* pData = (u16*)address; - for(i = 0; i < size / 2; i++) - pData[i] = sData[i]; + for(i = 0; i < size / 2; i++)pData[i] = sData[i]; } @@ -858,8 +830,7 @@ extern void turn_off(int cmd); extern void dsp_bar(int mod, int per); -int writeFileToNor(int sel) -{ +int writeFileToNor(int sel) { FILE *gbaFile; char savName[512]; u32 siz, wsz; @@ -878,14 +849,15 @@ int writeFileToNor(int sel) if(checkSRAM(savName) == false) { err_cnf(4, 5); } else { - if(save_sel(1, savName) >= 0) - writeSramToFile(savName); + if(save_sel(1, savName) >= 0)writeSramToFile(savName); } - if((fs[sel].Alias[strlen(fs[sel].Alias) - 3] != 'G') || - (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')) { + if((fs[sel].filename[strlen(fs[sel].filename) - 3] != 'G') || (fs[sel].filename[strlen(fs[sel].filename) - 3] != 'g')) { gba = false; - else gba = true; + } else { + gba = true; + } 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; char savName[512]; u32 siz; @@ -973,19 +944,19 @@ int writeFileToRam(int sel) else exp = 0x08060000; exps = exp; - if(fs[sel].filesize > fsz) { - return(1); - } + if(fs[sel].filesize > fsz)return(1); // if(checkSRAM(savName) == false) { // err_cnf(4, 5); // } else writeSramToFile(savName); - if((fs[sel].Alias[strlen(fs[sel].Alias) - 3] != 'G') || - (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')) { + if((fs[sel].filename[strlen(fs[sel].filename) - 3] != 'G') || (fs[sel].filename[strlen(fs[sel].filename) - 3] != 'g')) { gba = false; - else gba = true; + } else { + gba = true; + } 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 p; int tmp; @@ -1103,8 +1073,7 @@ void QSort(int left, int right) } -static void _sort_file() -{ +static void _sort_file() { int i, j; int no; @@ -1149,21 +1118,15 @@ bool nameEndsWith (const string& name, const string& extension) { void FileListGBA() { DIR *dir; struct stat st; - // char fname[256]; - // char lfnname[512]; - - // u32 flen; FILE *gbaFile; int i; -// mkdir("/GBA_SAVE"); - -// FAT_CWD("/GBA_Exp"); numFiles = 0; numGames = 0; chdir (curpath); dir = opendir(curpath); + if(dir == NULL) { strcpy(curpath, "/"); dir = opendir(curpath); @@ -1176,48 +1139,26 @@ void FileListGBA() { while(true) { dirent* pent = readdir(dir); if(pent == NULL)break; - 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].Alias, pent->d_name); + // strcpy(fs[numFiles].Alias, pent->d_name); fs[numFiles].type = st.st_mode; - FILE *file = fopen(pent->d_name, "rb"); - if (file) { - fseek(file, 0, SEEK_END); - fs[numFiles].filesize = ftell(file); - fclose(file); + if ((((string)pent->d_name).compare(".") != 0) && ((st.st_mode & S_IFMT) != S_IFDIR)) { + FILE *file = fopen(pent->d_name, "rb"); + if (file) { + fseek(file, 0, SEEK_END); + fs[numFiles].filesize = ftell(file); + fclose(file); + } } numFiles++; - if (numFiles > 199 )break; + if (numFiles > 199)break; } } 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++) { sortfile[i] = i; if(fs[i].type & S_IFDIR) { @@ -1237,12 +1178,11 @@ void FileListGBA() { } } - if(numFiles > 1) -// QSort(0, numFiles - 1); - _sort_file(); + if(numFiles > 1)_sort_file(); } #ifdef __cplusplus } #endif + diff --git a/arm9/source/main.c b/arm9/source/main.c index b98967f..338437b 100644 --- a/arm9/source/main.c +++ b/arm9/source/main.c @@ -94,20 +94,10 @@ u8 *rwbuf; extern int carttype; -void Vblank() -{ -} +void Vblank() { } -void FIFOInit() -{ - REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR; -} - - -void FIFOSend(u32 val) -{ - REG_IPC_FIFO_TX = val; -} +// void FIFOInit() { 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 void ret_menu9_GENs(void); -void turn_off(int cmd) -{ - if(cmd == 0) // 電源断 - FIFOSend(IPC_CMD_TURNOFF); - if(cmd == 1) { // R4 Soft Reset - FIFOSend(IPC_CMD_SR_R4TF); +void turn_off(int cmd) { + if(cmd == 0) { // 電源断 + // FIFOSend(IPC_CMD_TURNOFF); + systemShutDown(); + } + /*if(cmd == 1) { // R4 Soft Reset + // FIFOSend(IPC_CMD_SR_R4TF); REG_IME = 0; REG_IE = 0; REG_IF = REG_IF; @@ -163,14 +154,13 @@ void turn_off(int cmd) ret_menu9_Gen(); FIFOSend(IPC_CMD_SR_GEN); ret_menu9_GENs(); - } + }*/ while(1); } -void gba_frame() -{ +void gba_frame() { int ret; int x=0, y=0; u16 *pDstBuf1; @@ -198,8 +188,7 @@ void gba_frame() } } -static void resetToSlot2() -{ +static void resetToSlot2() { vu32 vr; // make arm9 loop code @@ -209,8 +198,8 @@ static void resetToSlot2() 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 DC_FlushAll(); @@ -218,12 +207,11 @@ static void resetToSlot2() swiSoftReset(); } -void gbaMode() -{ +void gbaMode() { if(strncmp(GBA_HEADER.gamecode, "PASS", 4) == 0) { - resetARM9Memory(); - resetToSlot2(); + resetARM9Memory(); + resetToSlot2(); } videoSetMode(0); @@ -239,7 +227,8 @@ void gbaMode() gba_frame(); - FIFOSend(IPC_CMD_GBAMODE); + // FIFOSend(IPC_CMD_GBAMODE); + fifoSendValue32(FIFO_USER_01, 1); sysSetBusOwners(ARM7_OWNS_CARD, ARM7_OWNS_ROM); 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 x1, x2; 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 x1, x2; int y1, y2; @@ -349,8 +336,7 @@ int cnf_inp(int n1, int n2) u16 *gbar = NULL; int oldper; -void dsp_bar(int mod, int per) -{ +void dsp_bar(int mod, int per) { int x1, x2; int y1, y2; int xi, yi; @@ -407,8 +393,7 @@ void dsp_bar(int mod, int per) -void RamClear() -{ +void RamClear() { u32 *a8; //, *a9; int i; @@ -433,15 +418,10 @@ int GBAmode; int r4tf; -void _dsp_clear() -{ - DrawBox_SUB(SubScreen, 0, 28, 255, 114, 0, 1); - -} +void _dsp_clear() { DrawBox_SUB(SubScreen, 0, 28, 255, 114, 0, 1); } -int rumble_cmd() -{ +int rumble_cmd() { int cmd = 0; u32 ky, repky; 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]; int sn; @@ -613,8 +592,7 @@ extern bool checkSRAM_cnf(); 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 st, i; int len; @@ -790,8 +768,7 @@ extern void FileListGBA(void); extern int save_sel(int mod, char *name); -int gba_sel() -{ +int gba_sel() { // u32 i; int cmd = -1; @@ -1051,8 +1028,7 @@ inp_key(); extern void setLang(void); -void mainloop(void) -{ +void mainloop(void) { // vu16 reg; FILE *r4dt; @@ -1114,10 +1090,11 @@ REG_EXMEMCNT = (reg & 0xFFE0) | (1 << 4) | (1 << 2) | 1; if(carttype <= 2) { // SetRampage(16); // SetShake(0x08); - if(carttype == 1) + if(carttype == 1) { 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 ); + } } if(carttype == 3) { SetRompage(0x300); @@ -1198,8 +1175,7 @@ inp_key(); if(checkSRAM_cnf() == false) { if(carttype != 5) { - if(cnf_inp(9, 10) & KEY_B) - turn_off(r4tf); + if(cnf_inp(9, 10) & KEY_B)turn_off(r4tf); } } @@ -1215,21 +1191,18 @@ inp_key(); GBAmode = 0; if(checkSRAM(filename) && checkBackup()) { - if(save_sel(1, filename) >= 0) - writeSramToFile(filename); + if(save_sel(1, filename) >= 0)writeSramToFile(filename); } getGBAmode(); - if((GBAmode == 2) && (r4tf == 0)) - GBAmode = 0; - if(carttype > 2) - GBAmode = 0; + if((GBAmode == 2) && (r4tf == 0))GBAmode = 0; + if(carttype > 2)GBAmode = 0; cmd = -1; while(cmd == -1) { - if(GBAmode == 2) + if(GBAmode == 2) { cmd = rumble_cmd(); - else { + } else { // FileListGBA(); // setcurpath(); // if(numFiles == 0) @@ -1270,21 +1243,21 @@ int main(void) { 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); irqInit(); irqSet(IRQ_VBLANK, Vblank); irqEnable(IRQ_VBLANK); - FIFOInit(); + // FIFOInit(); - videoSetMode(MODE_FB0 | DISPLAY_BG2_ACTIVE); - videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE ); - // 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); - uint16* map1 = (uint16*)BG_MAP_RAM_SUB(0); - for(i=0;i<(256*192/8/8);i++) map1[i]=i; - lcdMainOnTop(); + videoSetMode(MODE_FB0 | DISPLAY_BG2_ACTIVE); + videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE ); + // 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); + uint16* map1 = (uint16*)BG_MAP_RAM_SUB(0); + for(i=0;i<(256*192/8/8);i++) map1[i]=i; + lcdMainOnTop(); //メイン画面を白で塗りつぶします ClearBG( MainScreen, RGB15(31,31,31) ); diff --git a/arm9/source/partition.h b/arm9/source/partition.h deleted file mode 100644 index fab8dc7..0000000 --- a/arm9/source/partition.h +++ /dev/null @@ -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