Clear cart info on eject outside of drive menu and detect ramdrive eject (#146)

* Fix cart info if ejected not in drive menu

* Fix a couple ramdrive issues

- Unmount ramdrive if Slot-2 RAM is ejected
- Fix potentially reading from the wrong location if numSectors > 1 and crosses between locations
- free ramdLoc on regular DS too
- Use calloc to 0 initialize, I saw it mess up occasionally on DSi too

* Update time in the Vblank handler
This commit is contained in:
Pk11 2022-01-07 21:35:49 -06:00 committed by GitHub
parent 21c8ad9e54
commit d8bf2447ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 93 additions and 179 deletions

View File

@ -60,8 +60,8 @@ bool flashcardMountSkipped = true;
static bool flashcardMountRan = true; static bool flashcardMountRan = true;
static int dmCursorPosition = 0; static int dmCursorPosition = 0;
static std::vector<DriveMenuOperation> dmOperations; static std::vector<DriveMenuOperation> dmOperations;
static char romTitle[2][13] = {0}; char romTitle[2][13] = {0};
static u32 romSize[2], romSizeTrimmed; u32 romSize[2], romSizeTrimmed;
static u8 gbaFixedValue = 0; static u8 gbaFixedValue = 0;
static u8 stored_SCFG_MC = 0; static u8 stored_SCFG_MC = 0;
@ -274,10 +274,6 @@ void driveMenu (void) {
// Power saving loop. Only poll the keys once per frame and sleep the CPU if there is nothing else to do // Power saving loop. Only poll the keys once per frame and sleep the CPU if there is nothing else to do
do { do {
// Print time
font->print(-1, 0, true, RetTime(), Alignment::right, Palette::blackGreen);
font->update(true);
scanKeys(); scanKeys();
pressed = keysDownRepeat(); pressed = keysDownRepeat();
held = keysHeld(); held = keysHeld();
@ -287,6 +283,12 @@ void driveMenu (void) {
if (*(u8*)(0x080000B2) != gbaFixedValue) { if (*(u8*)(0x080000B2) != gbaFixedValue) {
break; break;
} }
if(driveRemoved(Drive::ramDrive)) {
currentDrive = Drive::ramDrive;
chdir("ram:/");
ramdriveUnmount();
break;
}
} else if (isDSiMode()) { } else if (isDSiMode()) {
if ((REG_SCFG_MC != stored_SCFG_MC) || (flashcardMounted && driveRemoved(Drive::flashcard))) { if ((REG_SCFG_MC != stored_SCFG_MC) || (flashcardMounted && driveRemoved(Drive::flashcard))) {
break; break;

View File

@ -5,6 +5,8 @@
#include <vector> #include <vector>
extern bool flashcardMountSkipped; extern bool flashcardMountSkipped;
extern char romTitle[2][13];
extern u32 romSize[2], romSizeTrimmed;
extern void driveMenu (void); extern void driveMenu (void);

View File

@ -408,6 +408,17 @@ void ramdriveMount(bool ram32MB) {
} }
} }
void ramdriveUnmount(void) {
if(imgMounted && imgCurrentDrive == Drive::ramDrive)
imgUnmount();
if(nitroMounted && nitroCurrentDrive == Drive::ramDrive)
nitroUnmount();
fatUnmount("ram");
ramdSize = 0;
ramdriveMounted = false;
}
void nitroUnmount(void) { void nitroUnmount(void) {
if(imgMounted && imgCurrentDrive == Drive::nitroFS) if(imgMounted && imgCurrentDrive == Drive::nitroFS)
imgUnmount(); imgUnmount();
@ -470,7 +481,7 @@ bool driveRemoved(Drive drive) {
case Drive::flashcard: case Drive::flashcard:
return isDSiMode() ? REG_SCFG_MC & BIT(0) : !flashcardMounted; return isDSiMode() ? REG_SCFG_MC & BIT(0) : !flashcardMounted;
case Drive::ramDrive: case Drive::ramDrive:
return !ramdriveMounted; return (isDSiMode() || REG_SCFG_EXT != 0) ? !ramdriveMounted : !(*(u16*)(0x020000C0) != 0 || *(vu16*)(0x08240000) == 1);
case Drive::nand: case Drive::nand:
return !nandMounted; return !nandMounted;
case Drive::nitroFS: case Drive::nitroFS:

View File

@ -50,6 +50,7 @@ extern void sdUnmount(void);
extern bool flashcardMount(void); extern bool flashcardMount(void);
extern void flashcardUnmount(void); extern void flashcardUnmount(void);
extern void ramdriveMount(bool ram32MB); extern void ramdriveMount(bool ram32MB);
extern void ramdriveUnmount(void);
extern void nitroUnmount(void); extern void nitroUnmount(void);
extern bool imgMount(const char* imgName, bool dsiwareSave); extern bool imgMount(const char* imgName, bool dsiwareSave);
extern void imgUnmount(void); extern void imgUnmount(void);

View File

@ -93,10 +93,6 @@ DumpOption dumpMenu(std::vector<DumpOption> allowedOptions, const char *dumpName
// Power saving loop. Only poll the keys once per frame and sleep the CPU if there is nothing else to do // Power saving loop. Only poll the keys once per frame and sleep the CPU if there is nothing else to do
do { do {
// Print time
font->print(-1, 0, true, RetTime(), Alignment::right, Palette::blackGreen);
font->update(true);
scanKeys(); scanKeys();
pressed = keysDownRepeat(); pressed = keysDownRepeat();
held = keysHeld(); held = keysHeld();
@ -147,10 +143,6 @@ void dumpFailMsg(std::string_view msg) {
u16 pressed; u16 pressed;
do { do {
// Print time
font->print(-1, 0, true, RetTime(), Alignment::right, Palette::blackGreen);
font->update(true);
scanKeys(); scanKeys();
pressed = keysDown(); pressed = keysDown();
swiWaitForVBlank(); swiWaitForVBlank();
@ -331,10 +323,6 @@ bool writeToGbaSave(const char* fileName, u8* buffer, u32 size) {
u16 pressed; u16 pressed;
do { do {
// Print time
font->print(-1, 0, true, RetTime(), Alignment::right, Palette::blackGreen);
font->update(true);
swiWaitForVBlank(); swiWaitForVBlank();
scanKeys(); scanKeys();
pressed = keysDownRepeat(); pressed = keysDownRepeat();
@ -448,10 +436,6 @@ bool readFromGbaCart() {
if(*(u8*)(0x080000B2) == 0x96) { if(*(u8*)(0x080000B2) == 0x96) {
while(*(u8*)(0x080000B2) == 0x96) { while(*(u8*)(0x080000B2) == 0x96) {
// Print time
font->print(-1, 0, true, RetTime(), Alignment::right, Palette::blackGreen);
font->update(true);
swiWaitForVBlank(); swiWaitForVBlank();
scanKeys(); scanKeys();
@ -462,10 +446,6 @@ bool readFromGbaCart() {
} }
} }
while(*(u8*)(0x080000B2) != 0x96) { while(*(u8*)(0x080000B2) != 0x96) {
// Print time
font->print(-1, 0, true, RetTime(), Alignment::right, Palette::blackGreen);
font->update(true);
swiWaitForVBlank(); swiWaitForVBlank();
scanKeys(); scanKeys();
@ -519,10 +499,6 @@ void ndsCardSaveDump(const char* filename) {
font->print(0, 5, false, "["); font->print(0, 5, false, "[");
font->print(-1, 5, false, "]"); font->print(-1, 5, false, "]");
for (u32 src = 0; src < saveSize; src += 0x8000) { for (u32 src = 0; src < saveSize; src += 0x8000) {
// Print time
font->print(-1, 0, true, RetTime(), Alignment::right, Palette::blackGreen);
font->update(true);
font->print((src / (saveSize / (SCREEN_COLS - 2))) + 1, 5, false, "="); font->print((src / (saveSize / (SCREEN_COLS - 2))) + 1, 5, false, "=");
font->printf(0, 6, false, Alignment::left, Palette::white, STR_N_OF_N_BYTES.c_str(), src, saveSize); font->printf(0, 6, false, Alignment::left, Palette::white, STR_N_OF_N_BYTES.c_str(), src, saveSize);
font->update(false); font->update(false);
@ -584,10 +560,6 @@ void ndsCardSaveRestore(const char *filename) {
// Power saving loop. Only poll the keys once per frame and sleep the CPU if there is nothing else to do // Power saving loop. Only poll the keys once per frame and sleep the CPU if there is nothing else to do
u16 pressed; u16 pressed;
do { do {
// Print time
font->print(-1, 0, true, RetTime(), Alignment::right, Palette::blackGreen);
font->update(true);
scanKeys(); scanKeys();
pressed = keysDown(); pressed = keysDown();
swiWaitForVBlank(); swiWaitForVBlank();
@ -627,10 +599,6 @@ void ndsCardSaveRestore(const char *filename) {
font->print(0, 5, false, "["); font->print(0, 5, false, "[");
font->print(-1, 5, false, "]"); font->print(-1, 5, false, "]");
for (u32 dest = 0; dest < saveSize; dest += 0x8000) { for (u32 dest = 0; dest < saveSize; dest += 0x8000) {
// Print time
font->print(-1, 0, true, RetTime(), Alignment::right, Palette::blackGreen);
font->update(true);
font->print((dest / (saveSize / (SCREEN_COLS - 2))) + 1, 5, false, "="); font->print((dest / (saveSize / (SCREEN_COLS - 2))) + 1, 5, false, "=");
font->printf(0, 6, false, Alignment::left, Palette::white, STR_N_OF_N_BYTES.c_str(), dest, saveSize); font->printf(0, 6, false, Alignment::left, Palette::white, STR_N_OF_N_BYTES.c_str(), dest, saveSize);
font->update(false); font->update(false);
@ -671,10 +639,6 @@ void ndsCardSaveRestore(const char *filename) {
// Power saving loop. Only poll the keys once per frame and sleep the CPU if there is nothing else to do // Power saving loop. Only poll the keys once per frame and sleep the CPU if there is nothing else to do
do { do {
// Print time
font->print(-1, 0, true, RetTime(), Alignment::right, Palette::blackGreen);
font->update(true);
scanKeys(); scanKeys();
pressed = keysDown(); pressed = keysDown();
swiWaitForVBlank(); swiWaitForVBlank();
@ -785,10 +749,6 @@ void ndsCardDump(void) {
font->update(false); font->update(false);
while (true) { while (true) {
// Print time
font->print(-1, 0, true, RetTime(), Alignment::right, Palette::blackGreen);
font->update(true);
scanKeys(); scanKeys();
pressed = keysDownRepeat(); pressed = keysDownRepeat();
swiWaitForVBlank(); swiWaitForVBlank();
@ -910,10 +870,6 @@ void ndsCardDump(void) {
font->print(0, 5, false, "["); font->print(0, 5, false, "[");
font->print(-1, 5, false, "]"); font->print(-1, 5, false, "]");
for (u32 src = 0; src < romSize; src += 0x8000) { for (u32 src = 0; src < romSize; src += 0x8000) {
// Print time
font->print(-1, 0, true, RetTime(), Alignment::right, Palette::blackGreen);
font->update(true);
font->print((src / (romSize / (SCREEN_COLS - 2))) + 1, 5, false, "="); font->print((src / (romSize / (SCREEN_COLS - 2))) + 1, 5, false, "=");
font->printf(0, 6, false, Alignment::left, Palette::white, STR_N_OF_N_BYTES.c_str(), src, romSize); font->printf(0, 6, false, Alignment::left, Palette::white, STR_N_OF_N_BYTES.c_str(), src, romSize);
font->update(false); font->update(false);
@ -1003,10 +959,6 @@ void gbaCartSaveRestore(const char *filename) {
// Power saving loop. Only poll the keys once per frame and sleep the CPU if there is nothing else to do // Power saving loop. Only poll the keys once per frame and sleep the CPU if there is nothing else to do
u16 pressed; u16 pressed;
do { do {
// Print time
font->print(-1, 0, true, RetTime(), Alignment::right, Palette::blackGreen);
font->update(true);
scanKeys(); scanKeys();
pressed = keysDownRepeat(); pressed = keysDownRepeat();
swiWaitForVBlank(); swiWaitForVBlank();
@ -1187,10 +1139,6 @@ void gbaCartDump(void) {
font->print(0, 5, false, "["); font->print(0, 5, false, "[");
font->print(-1, 5, false, "]"); font->print(-1, 5, false, "]");
for (u32 src = 0; src < romSize; src += 0x8000) { for (u32 src = 0; src < romSize; src += 0x8000) {
// Print time
font->print(-1, 0, true, RetTime(), Alignment::right, Palette::blackGreen);
font->update(true);
font->print((src / (romSize / (SCREEN_COLS - 2))) + 1, 5, false, "="); font->print((src / (romSize / (SCREEN_COLS - 2))) + 1, 5, false, "=");
font->printf(0, 6, false, Alignment::left, Palette::white, STR_N_OF_N_BYTES.c_str(), src, romSize); font->printf(0, 6, false, Alignment::left, Palette::white, STR_N_OF_N_BYTES.c_str(), src, romSize);
font->update(false); font->update(false);
@ -1219,10 +1167,6 @@ void gbaCartDump(void) {
font->print(0, 5, false, "["); font->print(0, 5, false, "[");
font->print(-1, 5, false, "]"); font->print(-1, 5, false, "]");
for (size_t i = 0x02000000; i < 0x04000000; i += 0x1000) { for (size_t i = 0x02000000; i < 0x04000000; i += 0x1000) {
// Print time
font->print(-1, 0, true, RetTime(), Alignment::right, Palette::blackGreen);
font->update(true);
font->print((i / (0x04000000 / (SCREEN_COLS - 2))) + 1, 5, false, "="); font->print((i / (0x04000000 / (SCREEN_COLS - 2))) + 1, 5, false, "=");
font->printf(0, 7, false, Alignment::left, Palette::white, STR_N_OF_N_BYTES.c_str(), i - 0x02000000, 0x04000000 - 0x02000000); font->printf(0, 7, false, Alignment::left, Palette::white, STR_N_OF_N_BYTES.c_str(), i - 0x02000000, 0x04000000 - 0x02000000);
font->update(false); font->update(false);

View File

@ -5,7 +5,6 @@
#include <dirent.h> #include <dirent.h>
#include <vector> #include <vector>
#include "date.h"
#include "file_browse.h" #include "file_browse.h"
#include "font.h" #include "font.h"
#include "ndsheaderbanner.h" #include "ndsheaderbanner.h"
@ -197,10 +196,6 @@ int fcopy(const char *sourcePath, const char *destinationPath) {
break; break;
} }
// Print time
font->print(-1, 0, true, RetTime(), Alignment::right, Palette::blackGreen);
font->update(true);
font->print((offset / (fsize / (SCREEN_COLS - 2))) + 1, 1, false, "="); font->print((offset / (fsize / (SCREEN_COLS - 2))) + 1, 1, false, "=");
font->printf(0, 2, false, Alignment::left, Palette::white, STR_N_OF_N_BYTES.c_str(), (int)offset, (int)fsize); font->printf(0, 2, false, Alignment::left, Palette::white, STR_N_OF_N_BYTES.c_str(), (int)offset, (int)fsize);
font->update(false); font->update(false);
@ -257,10 +252,6 @@ void changeFileAttribs(const DirEntry *entry) {
// Power saving loop. Only poll the keys once per frame and sleep the CPU if there is nothing else to do // Power saving loop. Only poll the keys once per frame and sleep the CPU if there is nothing else to do
do { do {
// Print time
font->print(-1, 0, true, RetTime(), Alignment::right, Palette::blackGreen);
font->update(true);
scanKeys(); scanKeys();
held = keysHeld(); held = keysHeld();
pressed = keysDown(); pressed = keysDown();

View File

@ -287,10 +287,6 @@ FileOperation fileBrowse_A(DirEntry* entry, char path[PATH_MAX]) {
// Power saving loop. Only poll the keys once per frame and sleep the CPU if there is nothing else to do // Power saving loop. Only poll the keys once per frame and sleep the CPU if there is nothing else to do
do { do {
// Print time
font->print(-1, 0, true, RetTime(), Alignment::right, Palette::blackGreen);
font->update(true);
scanKeys(); scanKeys();
pressed = keysDownRepeat(); pressed = keysDownRepeat();
held = keysHeld(); held = keysHeld();
@ -450,10 +446,6 @@ FileOperation fileBrowse_A(DirEntry* entry, char path[PATH_MAX]) {
// Power saving loop. Only poll the keys once per frame and sleep the CPU if there is nothing else to do // Power saving loop. Only poll the keys once per frame and sleep the CPU if there is nothing else to do
int pressed; int pressed;
do { do {
// Print time
font->print(-1, 0, true, RetTime(), Alignment::right, Palette::blackGreen);
font->update(true);
scanKeys(); scanKeys();
pressed = keysDownRepeat(); pressed = keysDownRepeat();
swiWaitForVBlank(); swiWaitForVBlank();
@ -514,10 +506,6 @@ bool fileBrowse_paste(char dest[256]) {
// Power saving loop. Only poll the keys once per frame and sleep the CPU if there is nothing else to do // Power saving loop. Only poll the keys once per frame and sleep the CPU if there is nothing else to do
do { do {
// Print time
font->print(-1, 0, true, RetTime(), Alignment::right, Palette::blackGreen);
font->update(true);
scanKeys(); scanKeys();
pressed = keysDownRepeat(); pressed = keysDownRepeat();
swiWaitForVBlank(); swiWaitForVBlank();
@ -660,10 +648,6 @@ std::string browseForFile (void) {
// Power saving loop. Only poll the keys once per frame and sleep the CPU if there is nothing else to do // Power saving loop. Only poll the keys once per frame and sleep the CPU if there is nothing else to do
do { do {
// Print time
font->print(-1, 0, true, RetTime(), Alignment::right, Palette::blackGreen);
font->update(true);
scanKeys(); scanKeys();
pressed = keysDownRepeat(); pressed = keysDownRepeat();
held = keysHeld(); held = keysHeld();
@ -768,10 +752,6 @@ std::string browseForFile (void) {
// Rename file/folder // Rename file/folder
if ((held & KEY_R) && (pressed & KEY_X) && (entry->name != ".." && driveWritable(currentDrive))) { if ((held & KEY_R) && (pressed & KEY_X) && (entry->name != ".." && driveWritable(currentDrive))) {
// Clear time
font->print(-1, 0, true, " ", Alignment::right, Palette::blackGreen);
font->update(true);
pressed = 0; pressed = 0;
std::string newName = kbdGetString(STR_RENAME_TO, -1, entry->name); std::string newName = kbdGetString(STR_RENAME_TO, -1, entry->name);
@ -819,10 +799,6 @@ std::string browseForFile (void) {
font->update(false); font->update(false);
while (true) { while (true) {
// Print time
font->print(-1, 0, true, RetTime(), Alignment::right, Palette::blackGreen);
font->update(true);
scanKeys(); scanKeys();
pressed = keysDownRepeat(); pressed = keysDownRepeat();
swiWaitForVBlank(); swiWaitForVBlank();
@ -851,10 +827,6 @@ std::string browseForFile (void) {
pressed = 0; pressed = 0;
while (!(pressed & KEY_A)) { while (!(pressed & KEY_A)) {
// Print time
font->print(-1, 0, true, RetTime(), Alignment::right, Palette::blackGreen);
font->update(true);
scanKeys(); scanKeys();
pressed = keysDown(); pressed = keysDown();
swiWaitForVBlank(); swiWaitForVBlank();
@ -887,10 +859,6 @@ std::string browseForFile (void) {
// Create new folder // Create new folder
if ((held & KEY_R) && (pressed & KEY_Y) && driveWritable(currentDrive)) { if ((held & KEY_R) && (pressed & KEY_Y) && driveWritable(currentDrive)) {
// Clear time
font->print(-1, 0, true, " ", Alignment::right, Palette::blackGreen);
font->update(true);
pressed = 0; pressed = 0;
std::string newName = kbdGetString(STR_NAME_FOR_NEW_FOLDER); std::string newName = kbdGetString(STR_NAME_FOR_NEW_FOLDER);
@ -923,10 +891,6 @@ std::string browseForFile (void) {
entry->selected = select; entry->selected = select;
while(held & KEY_L) { while(held & KEY_L) {
do { do {
// Print time
font->print(-1, 0, true, RetTime(), Alignment::right, Palette::blackGreen);
font->update(true);
scanKeys(); scanKeys();
pressed = keysDownRepeat(); pressed = keysDownRepeat();
held = keysHeld(); held = keysHeld();

View File

@ -1,6 +1,5 @@
#include "hexEditor.h" #include "hexEditor.h"
#include "date.h"
#include "file_browse.h" #include "file_browse.h"
#include "font.h" #include "font.h"
#include "keyboard.h" #include "keyboard.h"
@ -31,10 +30,6 @@ u32 jumpToOffset(u32 offset) {
scanKeys(); scanKeys();
pressed = keysDown(); pressed = keysDown();
held = keysDownRepeat(); held = keysDownRepeat();
// Print time
font->print(-1, 0, true, RetTime(), Alignment::right, Palette::blackGreen);
font->update(true);
} while(!held); } while(!held);
if(held & KEY_UP) { if(held & KEY_UP) {
@ -72,10 +67,6 @@ u32 search(u32 offset, FILE *file) {
scanKeys(); scanKeys();
pressed = keysDown(); pressed = keysDown();
held = keysDownRepeat(); held = keysDownRepeat();
// Print time
font->print(-1, 0, true, RetTime(), Alignment::right, Palette::blackGreen);
font->update(true);
} while(!held); } while(!held);
if(held & (KEY_UP | KEY_DOWN)) { if(held & (KEY_UP | KEY_DOWN)) {
@ -115,10 +106,6 @@ u32 search(u32 offset, FILE *file) {
scanKeys(); scanKeys();
pressed = keysDown(); pressed = keysDown();
held = keysDownRepeat(); held = keysDownRepeat();
// Print time
font->print(-1, 0, true, RetTime(), Alignment::right, Palette::blackGreen);
font->update(true);
} while(!held); } while(!held);
if(held & KEY_UP) { if(held & KEY_UP) {
@ -207,10 +194,6 @@ u32 search(u32 offset, FILE *file) {
do { do {
swiWaitForVBlank(); swiWaitForVBlank();
scanKeys(); scanKeys();
// Print time
font->print(-1, 0, true, RetTime(), Alignment::right, Palette::blackGreen);
font->update(true);
} while(!keysDown()); } while(!keysDown());
return offset; return offset;
@ -285,10 +268,6 @@ void hexEditor(const char *path, Drive drive) {
pressed = keysDown(); pressed = keysDown();
held = keysDownRepeat(); held = keysDownRepeat();
// Print time
font->print(-1, 0, true, RetTime(), Alignment::right, Palette::blackGreen);
font->update(true);
if(driveRemoved(currentDrive)) if(driveRemoved(currentDrive))
return; return;
} while(!held); } while(!held);

View File

@ -1,5 +1,4 @@
#include "keyboard.h" #include "keyboard.h"
#include "date.h"
#include "font.h" #include "font.h"
#include "language.h" #include "language.h"
@ -31,10 +30,6 @@ std::string kbdGetString(std::string label, int maxSize, std::string oldStr) {
font->update(false); font->update(false);
do { do {
// Print time
font->print(-1, 0, true, RetTime(), Alignment::right, Palette::blackGreen);
font->update(true);
scanKeys(); scanKeys();
pressed = keysDownRepeat(); pressed = keysDownRepeat();
key = keyboardUpdate(); key = keyboardUpdate();

View File

@ -31,6 +31,7 @@
#include "nds_loader_arm9.h" #include "nds_loader_arm9.h"
#include "config.h" #include "config.h"
#include "date.h"
#include "driveMenu.h" #include "driveMenu.h"
#include "driveOperations.h" #include "driveOperations.h"
#include "file_browse.h" #include "file_browse.h"
@ -57,6 +58,7 @@ bool arm7SCFGLocked = false;
bool isRegularDS = true; bool isRegularDS = true;
bool is3DS = false; bool is3DS = false;
int ownNitroFSMounted; int ownNitroFSMounted;
std::string prevTime;
bool applaunch = false; bool applaunch = false;
@ -70,6 +72,32 @@ void stop (void) {
} }
} }
//---------------------------------------------------------------------------------
void vblankHandler (void) {
//---------------------------------------------------------------------------------
// Check if NDS cart ejected
if(isDSiMode() && (REG_SCFG_MC & BIT(0)) && romTitle[0][0] != '\0') {
romTitle[0][0] = '\0';
romSizeTrimmed = romSize[0] = 0;
}
// Check if GBA cart ejected
if(isRegularDS && *(u8*)(0x080000B2) != 0x96 && romTitle[1][0] != '\0') {
romTitle[1][0] = '\0';
romSize[1] = 0;
}
// Print time
std::string time = RetTime();
if(time != prevTime) {
prevTime = time;
if(font) {
font->print(-1, 0, true, time, Alignment::right, Palette::blackGreen);
font->update(true);
}
}
}
char filePath[PATH_MAX]; char filePath[PATH_MAX];
//--------------------------------------------------------------------------------- //---------------------------------------------------------------------------------
@ -223,6 +251,12 @@ int main(int argc, char **argv) {
keysSetRepeat(25,5); keysSetRepeat(25,5);
// Top bar
font->printf(0, 0, true, Alignment::left, Palette::blackGreen, "%*c", 256 / font->width(), ' ');
// Enable vblank handler
irqSet(IRQ_VBLANK, vblankHandler);
appInited = true; appInited = true;
while(1) { while(1) {

View File

@ -1,6 +1,5 @@
#include "ndsInfo.h" #include "ndsInfo.h"
#include "date.h"
#include "font.h" #include "font.h"
#include "language.h" #include "language.h"
#include "screenshot.h" #include "screenshot.h"
@ -94,10 +93,6 @@ void ndsInfo(const char *path) {
pressed = keysDown(); pressed = keysDown();
held = keysDownRepeat(); held = keysDownRepeat();
// Print time
font->print(-1, 0, true, RetTime(), Alignment::right, Palette::blackGreen);
font->update(true);
if(iconAnimation[animationFrame] && animationFrame < 0x40) { if(iconAnimation[animationFrame] && animationFrame < 0x40) {
if(frameDelay < (iconAnimation[animationFrame] & 0xFF) - 1) { if(frameDelay < (iconAnimation[animationFrame] & 0xFF) - 1) {
frameDelay++; frameDelay++;

View File

@ -16,64 +16,65 @@ const static u8 bootSector[] = {
u32 ramdSectors = 0; u32 ramdSectors = 0;
u8* ramdLoc = (u8*)NULL; u8* ramdLoc = (u8*)NULL;
u8* ramdLocMep = (u8*)NULL; u8* ramdLocMep = (u8*)NULL;
const u16 bootSectorSignature = 0xAA55;
bool ramd_startup() { bool ramd_startup() {
if(isDSiMode() || REG_SCFG_EXT != 0) { if(isDSiMode() || REG_SCFG_EXT != 0) {
ramdLoc = (u8*)malloc(0x6000 * SECTOR_SIZE); ramdLoc = (u8*)calloc(0x6000 * SECTOR_SIZE, 1);
} else { } else {
ramdLoc = (u8*)malloc(0x8 * SECTOR_SIZE); ramdLoc = (u8*)calloc(0x8 * SECTOR_SIZE, 1);
toncset(ramdLocMep, 0, (ramdSectors - 0x8) * SECTOR_SIZE); // Fill MEP with 00 to avoid displaying weird files toncset(ramdLocMep, 0, (ramdSectors - 0x8) * SECTOR_SIZE); // Fill MEP with 00 to avoid displaying weird files
} }
tonccpy(ramdLoc, bootSector, sizeof(bootSector)); tonccpy(ramdLoc, bootSector, sizeof(bootSector));
toncset32(ramdLoc + 0x20, ramdSectors, 1); tonccpy(ramdLoc + 0x20, &ramdSectors, 4);
toncset16(ramdLoc + 0x1FE, 0xAA55, 1); tonccpy(ramdLoc + 0x1FE, &bootSectorSignature, 2);
return true; return true;
} }
bool ramd_is_inserted() { bool ramd_is_inserted() {
return true; return isDSiMode() || REG_SCFG_EXT != 0 || *(u16*)(0x020000C0) != 0 || *(vu16*)(0x08240000) == 1;
} }
bool ramd_read_sectors(sec_t sector, sec_t numSectors, void *buffer) { bool ramd_read_sectors(sec_t sector, sec_t numSectors, void *buffer) {
if(isDSiMode() || REG_SCFG_EXT != 0) { for(int i = 0; i < numSectors; i++, sector++) {
if(sector < 0x6000) { if(isDSiMode() || REG_SCFG_EXT != 0) {
tonccpy(buffer, ramdLoc + (sector << 9), numSectors << 9); if(sector < 0x6000) {
return true; tonccpy(buffer + (i * SECTOR_SIZE), ramdLoc + (sector * SECTOR_SIZE), SECTOR_SIZE);
} else if(sector <= 0xE000) { } else if(sector <= 0xE000) {
tonccpy(buffer, (void*)0x0D000000 + ((sector - 0x6000) << 9), numSectors << 9); tonccpy(buffer + (i * SECTOR_SIZE), (void*)0x0D000000 + ((sector - 0x6000) * SECTOR_SIZE), SECTOR_SIZE);
return true; }
} else if(sector < 0x8) {
tonccpy(buffer + (i * SECTOR_SIZE), ramdLoc + (sector * SECTOR_SIZE), SECTOR_SIZE);
} else if(sector <= ramdSectors - 0x8) {
tonccpy(buffer + (i * SECTOR_SIZE), ramdLocMep + ((sector - 0x8) * SECTOR_SIZE), SECTOR_SIZE);
} else {
return false;
} }
} else if(sector < 0x8) {
tonccpy(buffer, ramdLoc + (sector << 9), numSectors << 9);
return true;
} else if(sector <= ramdSectors - 0x8) {
tonccpy(buffer, ramdLocMep + ((sector - 0x8) << 9), numSectors << 9);
return true;
} }
return false; return true;
} }
bool ramd_write_sectors(sec_t sector, sec_t numSectors, const void *buffer) { bool ramd_write_sectors(sec_t sector, sec_t numSectors, const void *buffer) {
if(isDSiMode() || REG_SCFG_EXT != 0) { for(int i = 0; i < numSectors; i++, sector++) {
if(sector < 0x6000) { if(isDSiMode() || REG_SCFG_EXT != 0) {
tonccpy(ramdLoc + (sector << 9), buffer, numSectors << 9); if(sector < 0x6000) {
return true; tonccpy(ramdLoc + (sector * SECTOR_SIZE), buffer + (i * SECTOR_SIZE), SECTOR_SIZE);
} else if(sector <= 0xE000) { } else if(sector <= 0xE000) {
tonccpy((void*)0x0D000000 + ((sector - 0x6000) << 9), buffer, numSectors << 9); tonccpy((void*)0x0D000000 + ((sector - 0x6000) * SECTOR_SIZE), buffer + (i * SECTOR_SIZE), SECTOR_SIZE);
return true; }
} else if(sector < 0x8) {
tonccpy(ramdLoc + (sector * SECTOR_SIZE), buffer + (i * SECTOR_SIZE), SECTOR_SIZE);
} else if(sector <= ramdSectors - 0x8) {
tonccpy(ramdLocMep + ((sector - 0x8) * SECTOR_SIZE), buffer + (i * SECTOR_SIZE), SECTOR_SIZE);
} else {
return false;
} }
} else if(sector < 0x8) {
tonccpy(ramdLoc + (sector << 9), buffer, numSectors << 9);
return true;
} else if(sector <= ramdSectors - 0x8) {
tonccpy(ramdLocMep + ((sector - 0x8) << 9), buffer, numSectors << 9);
return true;
} }
return false; return true;
} }
bool ramd_clear_status() { bool ramd_clear_status() {
@ -81,7 +82,7 @@ bool ramd_clear_status() {
} }
bool ramd_shutdown() { bool ramd_shutdown() {
if((isDSiMode() || REG_SCFG_EXT != 0) && ramdLoc) { if(ramdLoc) {
free(ramdLoc); free(ramdLoc);
ramdLoc = NULL; ramdLoc = NULL;
} }

View File

@ -1,10 +1,10 @@
#include "screenshot.h" #include "screenshot.h"
#include "bmp.h" #include "bmp.h"
#include "date.h"
#include "driveOperations.h" #include "driveOperations.h"
#include "file_browse.h" #include "file_browse.h"
#include "font.h" #include "font.h"
#include "date.h"
#include <dirent.h> #include <dirent.h>
#include <fat.h> #include <fat.h>

View File

@ -1,7 +1,6 @@
#include "startMenu.h" #include "startMenu.h"
#include "config.h" #include "config.h"
#include "date.h"
#include "font.h" #include "font.h"
#include "language.h" #include "language.h"
#include "main.h" #include "main.h"
@ -111,10 +110,6 @@ void languageMenu() {
font->update(false); font->update(false);
do { do {
// Print time
font->print(-1, 0, true, RetTime(), Alignment::right, Palette::blackGreen);
font->update(true);
scanKeys(); scanKeys();
swiWaitForVBlank(); swiWaitForVBlank();
} while (!(keysDownRepeat() & KEY_A)); } while (!(keysDownRepeat() & KEY_A));