mirror of
https://github.com/rvtr/GodMode9i.git
synced 2025-06-18 10:55:31 -04:00
Enumify drive number
This commit is contained in:
parent
b5df5a6971
commit
e44678598c
@ -96,20 +96,20 @@ void dm_drawTopScreen(void) {
|
||||
break;
|
||||
case DriveMenuOperation::nitroFs:
|
||||
font->print(0, i + 1, true, "[nitro:] NDS GAME IMAGE", Alignment::left, pal);
|
||||
if (!((sdMounted && nitroCurrentDrive==0)
|
||||
|| (flashcardMounted && nitroCurrentDrive==1)
|
||||
|| (ramdrive1Mounted && nitroCurrentDrive==2)
|
||||
|| (ramdrive2Mounted && nitroCurrentDrive==3)
|
||||
|| (nandMounted && nitroCurrentDrive==4)
|
||||
|| (imgMounted && nitroCurrentDrive==6)))
|
||||
if (!((sdMounted && nitroCurrentDrive == Drive::sdCard)
|
||||
|| (flashcardMounted && nitroCurrentDrive == Drive::flashcard)
|
||||
|| (ramdrive1Mounted && nitroCurrentDrive == Drive::ramDrive1)
|
||||
|| (ramdrive2Mounted && nitroCurrentDrive == Drive::ramDrive2)
|
||||
|| (nandMounted && nitroCurrentDrive == Drive::nand)
|
||||
|| (imgMounted && nitroCurrentDrive == Drive::fatImg)))
|
||||
font->print(256 - font->width(), i + 1, true, "[x]", Alignment::right, pal);
|
||||
break;
|
||||
case DriveMenuOperation::fatImage:
|
||||
if ((sdMounted && imgCurrentDrive==0)
|
||||
|| (flashcardMounted && imgCurrentDrive==1)
|
||||
|| (ramdrive1Mounted && imgCurrentDrive==2)
|
||||
|| (ramdrive2Mounted && imgCurrentDrive==3)
|
||||
|| (nandMounted && imgCurrentDrive==4)) {
|
||||
if ((sdMounted && imgCurrentDrive == Drive::sdCard)
|
||||
|| (flashcardMounted && imgCurrentDrive == Drive::flashcard)
|
||||
|| (ramdrive1Mounted && imgCurrentDrive == Drive::ramDrive1)
|
||||
|| (ramdrive2Mounted && imgCurrentDrive == Drive::ramDrive2)
|
||||
|| (nandMounted && imgCurrentDrive == Drive::nand)) {
|
||||
font->printf(0, i + 1, true, Alignment::left, pal, "[nitro:] FAT IMAGE (%s)", imgLabel[0] == 0 ? "UNTITLED" : imgLabel);
|
||||
} else {
|
||||
font->print(0, i + 1, true, "[nitro:] FAT IMAGE", Alignment::left, pal);
|
||||
@ -291,26 +291,26 @@ void driveMenu (void) {
|
||||
|
||||
if (pressed & KEY_A) {
|
||||
if (dmOperations[dmCursorPosition] == DriveMenuOperation::sdCard && sdMounted) {
|
||||
currentDrive = 0;
|
||||
currentDrive = Drive::sdCard;
|
||||
chdir("sd:/");
|
||||
screenMode = 1;
|
||||
break;
|
||||
} else if (dmOperations[dmCursorPosition] == DriveMenuOperation::flashcard && flashcardMounted) {
|
||||
currentDrive = 1;
|
||||
currentDrive = Drive::flashcard;
|
||||
chdir("fat:/");
|
||||
screenMode = 1;
|
||||
break;
|
||||
} else if (dmOperations[dmCursorPosition] == DriveMenuOperation::gbaCart && isRegularDS && flashcardMounted && gbaFixedValue == 0x96) {
|
||||
gbaCartDump();
|
||||
} else if (dmOperations[dmCursorPosition] == DriveMenuOperation::nitroFs && nitroMounted) {
|
||||
if ((sdMounted && nitroCurrentDrive==0)
|
||||
|| (flashcardMounted && nitroCurrentDrive==1)
|
||||
|| (ramdrive1Mounted && nitroCurrentDrive==2)
|
||||
|| (ramdrive2Mounted && nitroCurrentDrive==3)
|
||||
|| (nandMounted && nitroCurrentDrive==4)
|
||||
|| (imgMounted && nitroCurrentDrive==6))
|
||||
if ((sdMounted && nitroCurrentDrive == Drive::sdCard)
|
||||
|| (flashcardMounted && nitroCurrentDrive == Drive::flashcard)
|
||||
|| (ramdrive1Mounted && nitroCurrentDrive == Drive::ramDrive1)
|
||||
|| (ramdrive2Mounted && nitroCurrentDrive == Drive::ramDrive2)
|
||||
|| (nandMounted && nitroCurrentDrive == Drive::nand)
|
||||
|| (imgMounted && nitroCurrentDrive == Drive::fatImg))
|
||||
{
|
||||
currentDrive = 5;
|
||||
currentDrive = Drive::nitroFS;
|
||||
chdir("nitro:/");
|
||||
screenMode = 1;
|
||||
break;
|
||||
@ -318,28 +318,28 @@ void driveMenu (void) {
|
||||
} else if (dmOperations[dmCursorPosition] == DriveMenuOperation::ndsCard && (sdMounted || flashcardMounted)) {
|
||||
ndsCardDump();
|
||||
} else if (dmOperations[dmCursorPosition] == DriveMenuOperation::ramDrive1 && isDSiMode() && ramdrive1Mounted) {
|
||||
currentDrive = 2;
|
||||
currentDrive = Drive::ramDrive1;
|
||||
chdir("ram1:/");
|
||||
screenMode = 1;
|
||||
break;
|
||||
} else if (dmOperations[dmCursorPosition] == DriveMenuOperation::ramDrive2 && isDSiMode() && ramdrive2Mounted) {
|
||||
currentDrive = 3;
|
||||
currentDrive = Drive::ramDrive2;
|
||||
chdir("ram2:/");
|
||||
screenMode = 1;
|
||||
break;
|
||||
} else if (dmOperations[dmCursorPosition] == DriveMenuOperation::sysNand && isDSiMode() && nandMounted) {
|
||||
currentDrive = 4;
|
||||
currentDrive = Drive::nand;
|
||||
chdir("nand:/");
|
||||
screenMode = 1;
|
||||
break;
|
||||
} else if (dmOperations[dmCursorPosition] == DriveMenuOperation::fatImage && imgMounted) {
|
||||
if ((sdMounted && imgCurrentDrive==0)
|
||||
|| (flashcardMounted && imgCurrentDrive==1)
|
||||
|| (ramdrive1Mounted && imgCurrentDrive==2)
|
||||
|| (ramdrive2Mounted && imgCurrentDrive==3)
|
||||
|| (nandMounted && imgCurrentDrive==4))
|
||||
if ((sdMounted && imgCurrentDrive == Drive::sdCard)
|
||||
|| (flashcardMounted && imgCurrentDrive == Drive::flashcard)
|
||||
|| (ramdrive1Mounted && imgCurrentDrive == Drive::ramDrive1)
|
||||
|| (ramdrive2Mounted && imgCurrentDrive == Drive::ramDrive2)
|
||||
|| (nandMounted && imgCurrentDrive == Drive::nand))
|
||||
{
|
||||
currentDrive = 6;
|
||||
currentDrive = Drive::fatImg;
|
||||
chdir("img:/");
|
||||
screenMode = 1;
|
||||
break;
|
||||
@ -350,11 +350,11 @@ void driveMenu (void) {
|
||||
// Unmount/Remount FAT image
|
||||
if ((held & KEY_R) && (pressed & KEY_X)) {
|
||||
if (nitroMounted) {
|
||||
currentDrive = 5;
|
||||
currentDrive = Drive::nitroFS;
|
||||
chdir("nitro:/");
|
||||
nitroUnmount();
|
||||
} else if (imgMounted) {
|
||||
currentDrive = 6;
|
||||
currentDrive = Drive::fatImg;
|
||||
chdir("img:/");
|
||||
imgUnmount();
|
||||
}
|
||||
@ -364,7 +364,7 @@ void driveMenu (void) {
|
||||
if ((held & KEY_R) && (pressed & KEY_B)) {
|
||||
if (isDSiMode() && sdMountedDone) {
|
||||
if (sdMounted) {
|
||||
currentDrive = 0;
|
||||
currentDrive = Drive::sdCard;
|
||||
chdir("sd:/");
|
||||
sdUnmount();
|
||||
} else if (isRegularDS) {
|
||||
@ -372,7 +372,7 @@ void driveMenu (void) {
|
||||
}
|
||||
} else {
|
||||
if (flashcardMounted) {
|
||||
currentDrive = 1;
|
||||
currentDrive = Drive::flashcard;
|
||||
chdir("fat:/");
|
||||
flashcardUnmount();
|
||||
} else {
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include "driveOperations.h"
|
||||
|
||||
#include <nds.h>
|
||||
#include <nds/arm9/dldi.h>
|
||||
#include <fat.h>
|
||||
@ -30,9 +32,9 @@ bool ramdrive2Mounted = false;
|
||||
bool imgMounted = false;
|
||||
bool nitroMounted = false;
|
||||
|
||||
int currentDrive = 0; // 0 == SD card, 1 == Flashcard, 2 == RAMdrive 1, 3 == RAMdrive 2, 4 == NAND, 5 == NitroFS, 6 == FAT IMG
|
||||
int nitroCurrentDrive = 0;
|
||||
int imgCurrentDrive = 0;
|
||||
Drive currentDrive = Drive::sdCard;
|
||||
Drive nitroCurrentDrive = Drive::sdCard;
|
||||
Drive imgCurrentDrive = Drive::sdCard;
|
||||
|
||||
char sdLabel[12];
|
||||
char fatLabel[12];
|
||||
@ -79,19 +81,19 @@ std::string getDriveBytes(u64 bytes)
|
||||
|
||||
const char* getDrivePath(void) {
|
||||
switch (currentDrive) {
|
||||
case 0:
|
||||
case Drive::sdCard:
|
||||
return "sd:/";
|
||||
case 1:
|
||||
case Drive::flashcard:
|
||||
return "fat:/";
|
||||
case 2:
|
||||
case Drive::ramDrive1:
|
||||
return "ram1:/";
|
||||
case 3:
|
||||
case Drive::ramDrive2:
|
||||
return "ram2:/";
|
||||
case 4:
|
||||
case Drive::nand:
|
||||
return "nand:/";
|
||||
case 5:
|
||||
case Drive::nitroFS:
|
||||
return "nitro:/";
|
||||
case 6:
|
||||
case Drive::fatImg:
|
||||
return "img:/";
|
||||
}
|
||||
return "";
|
||||
|
@ -2,6 +2,19 @@
|
||||
#define FLASHCARD_H
|
||||
|
||||
#include <string>
|
||||
#include <nds/ndstypes.h>
|
||||
|
||||
enum class Drive : u8 {
|
||||
sdCard = 0,
|
||||
flashcard,
|
||||
ramDrive1,
|
||||
ramDrive2,
|
||||
nand,
|
||||
nitroFS,
|
||||
fatImg
|
||||
};
|
||||
|
||||
#define DRIVE_WRITABLE(drive) (drive < Drive::nand)
|
||||
|
||||
extern u8 stored_SCFG_MC;
|
||||
|
||||
@ -14,9 +27,9 @@ extern bool ramdrive2Mounted;
|
||||
extern bool imgMounted;
|
||||
extern bool nitroMounted;
|
||||
|
||||
extern int currentDrive; // 0 == SD card, 1 == Flashcard, 2 == RAMdrive 1, 3 == RAMdrive 2, 4 == NAND, 5 == NitroFS, 6 == FAT IMG
|
||||
extern int nitroCurrentDrive;
|
||||
extern int imgCurrentDrive;
|
||||
extern Drive currentDrive;
|
||||
extern Drive nitroCurrentDrive;
|
||||
extern Drive imgCurrentDrive;
|
||||
|
||||
extern char sdLabel[12];
|
||||
extern char fatLabel[12];
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <nds.h>
|
||||
|
||||
#include "driveOperations.h"
|
||||
#include "file_browse.h"
|
||||
|
||||
#ifndef FILE_COPY
|
||||
@ -9,10 +10,10 @@ struct ClipboardFile {
|
||||
std::string path;
|
||||
std::string name;
|
||||
bool folder;
|
||||
int drive; // 0 == SD card, 1 == Flashcard, 2 == RAMdrive 1, 3 == RAMdrive 2
|
||||
Drive drive;
|
||||
bool nitro;
|
||||
|
||||
ClipboardFile(std::string path, std::string name, bool folder, int drive, bool nitro) : path(std::move(path)), name(std::move(name)), folder(folder), drive(drive), nitro(nitro) {}
|
||||
ClipboardFile(std::string path, std::string name, bool folder, Drive drive, bool nitro) : path(std::move(path)), name(std::move(name)), folder(folder), drive(drive), nitro(nitro) {}
|
||||
};
|
||||
|
||||
extern std::vector<ClipboardFile> clipboard;
|
||||
|
@ -95,7 +95,7 @@ void getDirectoryContents(std::vector<DirEntry>& dirContents) {
|
||||
|
||||
bool isApp = false;
|
||||
if (extension(pent->d_name, {"nds", "argv", "dsi", "ids", "app", "srl"})) {
|
||||
isApp = (currentDrive == 0 && sdMounted) || (currentDrive == 1 && flashcardMounted);
|
||||
isApp = (currentDrive == Drive::sdCard && sdMounted) || (currentDrive == Drive::flashcard && flashcardMounted);
|
||||
} else if (extension(pent->d_name, {"firm"})) {
|
||||
isApp = (isDSiMode() && is3DS && sdMounted);
|
||||
}
|
||||
@ -380,7 +380,7 @@ FileOperation fileBrowse_A(DirEntry* entry, char path[PATH_MAX]) {
|
||||
if (nitroMounted) {
|
||||
chdir("nitro:/");
|
||||
nitroCurrentDrive = currentDrive;
|
||||
currentDrive = 5;
|
||||
currentDrive = Drive::nitroFS;
|
||||
}
|
||||
break;
|
||||
} case FileOperation::ndsInfo: {
|
||||
@ -397,7 +397,7 @@ FileOperation fileBrowse_A(DirEntry* entry, char path[PATH_MAX]) {
|
||||
if (imgMounted) {
|
||||
chdir("img:/");
|
||||
imgCurrentDrive = currentDrive;
|
||||
currentDrive = 6;
|
||||
currentDrive = Drive::fatImg;
|
||||
}
|
||||
break;
|
||||
} case FileOperation::hexEdit: {
|
||||
@ -650,7 +650,7 @@ std::string browseForFile (void) {
|
||||
}
|
||||
} while (!pressed);
|
||||
|
||||
if (isDSiMode() && !pressed && currentDrive == 1 && REG_SCFG_MC == 0x11 && flashcardMounted) {
|
||||
if (isDSiMode() && !pressed && currentDrive == Drive::flashcard && REG_SCFG_MC == 0x11 && flashcardMounted) {
|
||||
flashcardUnmount();
|
||||
screenMode = 0;
|
||||
return "null";
|
||||
|
@ -231,8 +231,8 @@ u32 search(u32 offset, FILE *file) {
|
||||
return offset;
|
||||
}
|
||||
|
||||
void hexEditor(const char *path, int drive) {
|
||||
FILE *file = fopen(path, drive < 4 ? "rb+" : "rb");
|
||||
void hexEditor(const char *path, Drive drive) {
|
||||
FILE *file = fopen(path, DRIVE_WRITABLE(drive) ? "rb+" : "rb");
|
||||
|
||||
if(!file)
|
||||
return;
|
||||
@ -355,7 +355,7 @@ void hexEditor(const char *path, int drive) {
|
||||
if((int)cursorPosition < bytesPerLine * maxLines - 1)
|
||||
cursorPosition = std::min(cursorPosition + 1, fileSize - offset - 1);
|
||||
} else if(pressed & KEY_A) {
|
||||
if(drive < 4) {
|
||||
if(DRIVE_WRITABLE(drive)) {
|
||||
mode = 2;
|
||||
}
|
||||
} else if(pressed & KEY_B) {
|
||||
|
@ -1,6 +1,8 @@
|
||||
#ifndef HEX_EDITOR_H
|
||||
#define HEX_EDITOR_H
|
||||
|
||||
void hexEditor(const char *path, int drive);
|
||||
#include "driveOperations.h"
|
||||
|
||||
void hexEditor(const char *path, Drive drive);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user