Do not clear time, except for GBA ROM dumping

This commit is contained in:
RocketRobz 2020-02-04 00:56:47 -07:00
parent e60993ec3e
commit 35583045b2
3 changed files with 257 additions and 187 deletions

View File

@ -6,6 +6,7 @@
#include <fstream> #include <fstream>
#include "auxspi.h" #include "auxspi.h"
#include "date.h"
#include "driveOperations.h" #include "driveOperations.h"
#include "ndsheaderbanner.h" #include "ndsheaderbanner.h"
#include "read_card.h" #include "read_card.h"
@ -48,23 +49,30 @@ void ndsCardSaveDump(const char* filename) {
void ndsCardDump(void) { void ndsCardDump(void) {
int pressed = 0; int pressed = 0;
printf ("\x1b[0;27H");
printf ("\x1B[42m"); // Print green color
printf ("_____"); // Clear time
consoleSelect(&bottomConsole); consoleSelect(&bottomConsole);
consoleClear(); consoleClear();
printf ("\x1B[47m"); // Print foreground white color printf ("\x1B[47m"); // Print foreground white color
printf("Dump NDS card ROM to\n"); printf("Dump NDS card ROM to\n");
printf("\"%s:/gm9i/out\"?\n", (sdMounted ? "sd" : "fat")); printf("\"%s:/gm9i/out\"?\n", (sdMounted ? "sd" : "fat"));
printf("(<A> yes, <Y> trim, <B> no)"); printf("(<A> yes, <Y> trim, <B> no)");
while (true) {
consoleSelect(&topConsole);
printf ("\x1B[42m"); // Print green color
// 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 {
// Move to right side of screen
printf ("\x1b[0;26H");
// Print time
printf ("_%s" ,RetTime().c_str());
scanKeys(); scanKeys();
pressed = keysDownRepeat(); pressed = keysDownRepeat();
swiWaitForVBlank(); swiWaitForVBlank();
} while (!(pressed & KEY_A) && !(pressed & KEY_Y) && !(pressed & KEY_B)); } while (!(pressed & KEY_A) && !(pressed & KEY_Y) && !(pressed & KEY_B));
consoleSelect(&bottomConsole);
printf ("\x1B[47m"); // Print foreground white color
if ((pressed & KEY_A) || (pressed & KEY_Y)) { if ((pressed & KEY_A) || (pressed & KEY_Y)) {
consoleClear(); consoleClear();
char folderPath[2][256]; char folderPath[2][256];
@ -153,6 +161,13 @@ void ndsCardDump(void) {
remove(destPath); remove(destPath);
FILE* destinationFile = fopen(destPath, "wb"); FILE* destinationFile = fopen(destPath, "wb");
for (u32 src = 0; src < romSize; src += 0x200) { for (u32 src = 0; src < romSize; src += 0x200) {
consoleSelect(&topConsole);
printf ("\x1B[42m"); // Print green color
// Move to right side of screen
printf ("\x1b[0;26H");
// Print time
printf ("_%s" ,RetTime().c_str());
printf ("\x1b[8;0H"); printf ("\x1b[8;0H");
printf ("Progress:\n"); printf ("Progress:\n");
printf ("%i/%i Bytes ", (int)src, (int)romSize); printf ("%i/%i Bytes ", (int)src, (int)romSize);
@ -162,34 +177,42 @@ void ndsCardDump(void) {
fclose(destinationFile); fclose(destinationFile);
ndsCardSaveDump(destSavPath); ndsCardSaveDump(destSavPath);
free(ndsCardHeader); free(ndsCardHeader);
break;
}
if (pressed & KEY_B) {
break;
}
} }
} }
void gbaCartDump(void) { void gbaCartDump(void) {
int pressed = 0; int pressed = 0;
printf ("\x1b[0;27H");
printf ("\x1B[42m"); // Print green color
printf ("_____"); // Clear time
consoleSelect(&bottomConsole); consoleSelect(&bottomConsole);
consoleClear(); consoleClear();
printf ("\x1B[47m"); // Print foreground white color printf ("\x1B[47m"); // Print foreground white color
printf("Dump GBA cart ROM to\n"); printf("Dump GBA cart ROM to\n");
printf("\"fat:/gm9i/out\"?\n"); printf("\"fat:/gm9i/out\"?\n");
printf("(<A> yes, <B> no)"); printf("(<A> yes, <B> no)");
while (true) {
consoleSelect(&topConsole);
printf ("\x1B[42m"); // Print green color
// 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 {
// Move to right side of screen
printf ("\x1b[0;26H");
// Print time
printf ("_%s" ,RetTime().c_str());
scanKeys(); scanKeys();
pressed = keysDownRepeat(); pressed = keysDownRepeat();
swiWaitForVBlank(); swiWaitForVBlank();
} while (!(pressed & KEY_A) && !(pressed & KEY_B)); } while (!(pressed & KEY_A) && !(pressed & KEY_B));
if (pressed & KEY_A) {
printf ("\x1b[0;27H");
printf ("\x1B[42m"); // Print green color
printf ("_____"); // Clear time
}
consoleSelect(&bottomConsole);
printf ("\x1B[47m"); // Print foreground white color
if (pressed & KEY_A) { if (pressed & KEY_A) {
consoleClear(); consoleClear();
if (access("fat:/gm9i", F_OK) != 0) { if (access("fat:/gm9i", F_OK) != 0) {
@ -246,10 +269,5 @@ void gbaCartDump(void) {
destinationFile = fopen(destSavPath, "wb"); destinationFile = fopen(destSavPath, "wb");
fwrite((void*)0x0A000000, 1, 0x10000, destinationFile); fwrite((void*)0x0A000000, 1, 0x10000, destinationFile);
fclose(destinationFile); fclose(destinationFile);
break;
}
if (pressed & KEY_B) {
break;
}
} }
} }

View File

@ -5,6 +5,7 @@
#include <dirent.h> #include <dirent.h>
#include <vector> #include <vector>
#include "date.h"
#include "file_browse.h" #include "file_browse.h"
using namespace std; using namespace std;
@ -13,6 +14,8 @@ using namespace std;
u32 copyBuf[copyBufSize]; u32 copyBuf[copyBufSize];
extern PrintConsole topConsole, bottomConsole;
char clipboard[256]; char clipboard[256];
char clipboardFilename[256]; char clipboardFilename[256];
bool clipboardFolder = false; bool clipboardFolder = false;
@ -121,6 +124,15 @@ int fcopy(const char *sourcePath, const char *destinationPath)
return -1; return -1;
break; break;
} }
consoleSelect(&topConsole);
printf ("\x1B[42m"); // Print green color
// Move to right side of screen
printf ("\x1b[0;26H");
// Print time
printf ("_%s" ,RetTime().c_str());
consoleSelect(&bottomConsole);
printf ("\x1B[47m"); // Print foreground white color
printf ("\x1b[16;0H"); printf ("\x1b[16;0H");
printf ("Progress:\n"); printf ("Progress:\n");
printf ("%i/%i Bytes ", (int)offset, (int)fsize); printf ("%i/%i Bytes ", (int)offset, (int)fsize);
@ -182,6 +194,8 @@ void changeFileAttribs(DirEntry* entry) {
printf ("\x1b[%i;0H", 9+cursorScreenPos); printf ("\x1b[%i;0H", 9+cursorScreenPos);
printf ("(UDRL to change attributes)"); printf ("(UDRL to change attributes)");
while (1) { while (1) {
consoleSelect(&bottomConsole);
printf ("\x1B[47m"); // Print foreground white color
printf ("\x1b[%i;1H", 5+cursorScreenPos); printf ("\x1b[%i;1H", 5+cursorScreenPos);
printf ((newAttribs & ATTR_READONLY) ? "X" : " "); printf ((newAttribs & ATTR_READONLY) ? "X" : " ");
printf ("\x1b[%i;18H", 5+cursorScreenPos); printf ("\x1b[%i;18H", 5+cursorScreenPos);
@ -193,8 +207,15 @@ void changeFileAttribs(DirEntry* entry) {
printf ("\x1b[%i;0H", 11+cursorScreenPos); printf ("\x1b[%i;0H", 11+cursorScreenPos);
printf ((currentAttribs==newAttribs) ? "(<A> to continue) " : "(<A> to apply, <B> to cancel)"); printf ((currentAttribs==newAttribs) ? "(<A> to continue) " : "(<A> to apply, <B> to cancel)");
consoleSelect(&topConsole);
printf ("\x1B[42m"); // Print green color
// 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 {
// Move to right side of screen
printf ("\x1b[0;26H");
// Print time
printf ("_%s" ,RetTime().c_str());
scanKeys(); scanKeys();
pressed = keysDown(); pressed = keysDown();
swiWaitForVBlank(); swiWaitForVBlank();

View File

@ -184,9 +184,6 @@ int fileBrowse_A(DirEntry* entry, char path[PATH_MAX]) {
int cursorScreenPos = 0; int cursorScreenPos = 0;
int maxCursors = -1; int maxCursors = -1;
printf ("\x1b[0;27H");
printf ("\x1B[42m"); // Print green color
printf ("_____"); // Clear time
consoleSelect(&bottomConsole); consoleSelect(&bottomConsole);
consoleClear(); consoleClear();
printf ("\x1B[47m"); // Print foreground white color printf ("\x1B[47m"); // Print foreground white color
@ -232,6 +229,8 @@ int fileBrowse_A(DirEntry* entry, char path[PATH_MAX]) {
} }
printf("\n"); printf("\n");
printf("(<A> select, <B> cancel)"); printf("(<A> select, <B> cancel)");
consoleSelect(&bottomConsole);
printf ("\x1B[47m"); // Print foreground white color
while (true) { while (true) {
// Clear old cursors // Clear old cursors
for (int i = OPTIONS_ENTRIES_START_ROW+cursorScreenPos; i < (maxCursors+1) + OPTIONS_ENTRIES_START_ROW+cursorScreenPos; i++) { for (int i = OPTIONS_ENTRIES_START_ROW+cursorScreenPos; i < (maxCursors+1) + OPTIONS_ENTRIES_START_ROW+cursorScreenPos; i++) {
@ -240,14 +239,24 @@ int fileBrowse_A(DirEntry* entry, char path[PATH_MAX]) {
// Show cursor // Show cursor
iprintf ("\x1b[%d;0H->", optionOffset + OPTIONS_ENTRIES_START_ROW+cursorScreenPos); iprintf ("\x1b[%d;0H->", optionOffset + OPTIONS_ENTRIES_START_ROW+cursorScreenPos);
consoleSelect(&topConsole);
printf ("\x1B[42m"); // Print green color for time text
// 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 {
// Move to right side of screen
printf ("\x1b[0;26H");
// Print time
printf ("_%s" ,RetTime().c_str());
scanKeys(); scanKeys();
pressed = keysDownRepeat(); pressed = keysDownRepeat();
swiWaitForVBlank(); swiWaitForVBlank();
} while (!(pressed & KEY_UP) && !(pressed & KEY_DOWN) } while (!(pressed & KEY_UP) && !(pressed & KEY_DOWN)
&& !(pressed & KEY_A) && !(pressed & KEY_B)); && !(pressed & KEY_A) && !(pressed & KEY_B));
consoleSelect(&bottomConsole);
printf ("\x1B[47m"); // Print foreground white color
if (pressed & KEY_UP) optionOffset -= 1; if (pressed & KEY_UP) optionOffset -= 1;
if (pressed & KEY_DOWN) optionOffset += 1; if (pressed & KEY_DOWN) optionOffset += 1;
@ -317,9 +326,6 @@ bool fileBrowse_paste(char destPath[256]) {
consoleClear(); consoleClear();
printf ("\x1b[0;27H");
printf ("\x1B[42m"); // Print green color
printf ("_____"); // Clear time
consoleSelect(&bottomConsole); consoleSelect(&bottomConsole);
printf ("\x1B[47m"); // Print foreground white color printf ("\x1B[47m"); // Print foreground white color
printf(clipboardFolder ? "Paste folder here?" : "Paste file here?"); printf(clipboardFolder ? "Paste folder here?" : "Paste file here?");
@ -333,6 +339,8 @@ bool fileBrowse_paste(char destPath[256]) {
} }
printf("\n"); printf("\n");
printf("(<A> select, <B> cancel)"); printf("(<A> select, <B> cancel)");
consoleSelect(&bottomConsole);
printf ("\x1B[47m"); // Print foreground white color
while (true) { while (true) {
// Clear old cursors // Clear old cursors
for (int i = OPTIONS_ENTRIES_START_ROW; i < (maxCursors+1) + OPTIONS_ENTRIES_START_ROW; i++) { for (int i = OPTIONS_ENTRIES_START_ROW; i < (maxCursors+1) + OPTIONS_ENTRIES_START_ROW; i++) {
@ -341,14 +349,24 @@ bool fileBrowse_paste(char destPath[256]) {
// Show cursor // Show cursor
iprintf ("\x1b[%d;0H->", optionOffset + OPTIONS_ENTRIES_START_ROW); iprintf ("\x1b[%d;0H->", optionOffset + OPTIONS_ENTRIES_START_ROW);
consoleSelect(&topConsole);
printf ("\x1B[42m"); // Print green color for time text
// 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 {
// Move to right side of screen
printf ("\x1b[0;26H");
// Print time
printf ("_%s" ,RetTime().c_str());
scanKeys(); scanKeys();
pressed = keysDownRepeat(); pressed = keysDownRepeat();
swiWaitForVBlank(); swiWaitForVBlank();
} while (!(pressed & KEY_UP) && !(pressed & KEY_DOWN) } while (!(pressed & KEY_UP) && !(pressed & KEY_DOWN)
&& !(pressed & KEY_A) && !(pressed & KEY_B)); && !(pressed & KEY_A) && !(pressed & KEY_B));
consoleSelect(&bottomConsole);
printf ("\x1B[47m"); // Print foreground white color
if (pressed & KEY_UP) optionOffset -= 1; if (pressed & KEY_UP) optionOffset -= 1;
if (pressed & KEY_DOWN) optionOffset += 1; if (pressed & KEY_DOWN) optionOffset += 1;
@ -611,20 +629,26 @@ string browseForFile (void) {
// Delete file/folder // Delete file/folder
if ((pressed & KEY_X) && (strcmp (entry->name.c_str(), "..") != 0) && (strncmp (path, "nitro:/", 7) != 0)) { if ((pressed & KEY_X) && (strcmp (entry->name.c_str(), "..") != 0) && (strncmp (path, "nitro:/", 7) != 0)) {
printf ("\x1b[0;27H");
printf ("\x1B[42m"); // Print green color
printf ("_____"); // Clear time
consoleSelect(&bottomConsole); consoleSelect(&bottomConsole);
consoleClear(); consoleClear();
printf ("\x1B[47m"); // Print foreground white color printf ("\x1B[47m"); // Print foreground white color
iprintf("Delete \"%s\"?\n", entry->name.c_str()); iprintf("Delete \"%s\"?\n", entry->name.c_str());
printf ("(<A> yes, <B> no)"); printf ("(<A> yes, <B> no)");
consoleSelect(&topConsole);
printf ("\x1B[42m"); // Print green color for time text
while (true) { while (true) {
// Move to right side of screen
printf ("\x1b[0;26H");
// Print time
printf ("_%s" ,RetTime().c_str());
scanKeys(); scanKeys();
pressed = keysDownRepeat(); pressed = keysDownRepeat();
swiWaitForVBlank(); swiWaitForVBlank();
if (pressed & KEY_A) { if (pressed & KEY_A) {
consoleSelect(&bottomConsole);
consoleClear(); consoleClear();
printf ("\x1B[47m"); // Print foreground white color
if (FAT_getAttr(entry->name.c_str()) & ATTR_READONLY) { if (FAT_getAttr(entry->name.c_str()) & ATTR_READONLY) {
printf ("Failed deleting:\n"); printf ("Failed deleting:\n");
printf (entry->name.c_str()); printf (entry->name.c_str());
@ -632,7 +656,14 @@ string browseForFile (void) {
printf ("\n"); printf ("\n");
printf ("(<A> to continue)"); printf ("(<A> to continue)");
pressed = 0; pressed = 0;
consoleSelect(&topConsole);
printf ("\x1B[42m"); // Print green color for time text
while (!(pressed & KEY_A)) { while (!(pressed & KEY_A)) {
// Move to right side of screen
printf ("\x1b[0;26H");
// Print time
printf ("_%s" ,RetTime().c_str());
scanKeys(); scanKeys();
pressed = keysDown(); pressed = keysDown();
swiWaitForVBlank(); swiWaitForVBlank();