From 2d59362d9c611a45df1f7b0f2c6ea8ef48a305fe Mon Sep 17 00:00:00 2001 From: Pk11 Date: Fri, 12 Mar 2021 07:59:01 -0600 Subject: [PATCH] Read only for NAND/NitroFS/FAT IMG drives --- arm9/Makefile | 4 ++-- arm9/source/file_browse.cpp | 2 +- arm9/source/hexEditor.cpp | 20 ++++++++++++-------- arm9/source/hexEditor.h | 2 +- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/arm9/Makefile b/arm9/Makefile index f08d8c2..fe7f79e 100644 --- a/arm9/Makefile +++ b/arm9/Makefile @@ -8,11 +8,11 @@ endif include $(DEVKITARM)/ds_rules -# If on a tagged commit, use the tag instead of the commit +# If on a tagged commit, use just tag ifneq ($(shell echo $(shell git tag -l --points-at HEAD) | head -c 1),) GIT_VER := $(shell git tag -l --points-at HEAD) else -GIT_VER := $(shell git describe --abbrev=0 --tags)-$(shell git rev-parse --short HEAD) +GIT_VER := $(shell git describe --abbrev=0 --tags)-$(shell git rev-parse --short=7 HEAD) endif # Ensure version.h exists diff --git a/arm9/source/file_browse.cpp b/arm9/source/file_browse.cpp index eb4c209..36a0f42 100644 --- a/arm9/source/file_browse.cpp +++ b/arm9/source/file_browse.cpp @@ -379,7 +379,7 @@ FileOperation fileBrowse_A(DirEntry* entry, char path[PATH_MAX]) { } break; } case FileOperation::hexEdit: { - hexEditor(entry->name.c_str()); + hexEditor(entry->name.c_str(), currentDrive); break; } case FileOperation::none: { break; diff --git a/arm9/source/hexEditor.cpp b/arm9/source/hexEditor.cpp index 284c008..57eba56 100644 --- a/arm9/source/hexEditor.cpp +++ b/arm9/source/hexEditor.cpp @@ -50,17 +50,19 @@ u32 jumpToOffset(u32 offset) { } } -void hexEditor(const char *path) { +void hexEditor(const char *path, int drive) { // Custom palettes BG_PALETTE_SUB[0x1F] = 0x9CF7; BG_PALETTE_SUB[0x2F] = 0xB710; BG_PALETTE_SUB[0x3F] = 0xAE8D; BG_PALETTE_SUB[0x7F] = 0xEA2D; - FILE *file = fopen(path, "rb+"); + FILE *file = fopen(path, drive < 4 ? "rb+" : "rb"); - if(!file) + if(!file) { + nocashMessage("test"); return; + } consoleClear(); @@ -179,11 +181,13 @@ void hexEditor(const char *path) { if(cursorPosition < 8 * maxLines - 1) cursorPosition = std::min((u8)(cursorPosition + 1), (u8)(fileSize - offset - 1)); } else if (pressed & KEY_A) { - mode = 2; - consoleSelect(&bottomConsoleBG); - printf("\x1B[%d;%dH\x1B[%dm\2\2", 1 + cursorPosition / 8, 5 + (cursorPosition % 8 * 2) + (cursorPosition % 8 / 4), 31); - printf("\x1B[%d;%dH\x1B[%dm\2", 1 + cursorPosition / 8, 23 + cursorPosition % 8, 31); - consoleSelect(&bottomConsole); + if(drive < 4) { + mode = 2; + consoleSelect(&bottomConsoleBG); + printf("\x1B[%d;%dH\x1B[%dm\2\2", 1 + cursorPosition / 8, 5 + (cursorPosition % 8 * 2) + (cursorPosition % 8 / 4), 31); + printf("\x1B[%d;%dH\x1B[%dm\2", 1 + cursorPosition / 8, 23 + cursorPosition % 8, 31); + consoleSelect(&bottomConsole); + } } else if (pressed & KEY_B) { mode = 0; } else if(pressed & KEY_Y) { diff --git a/arm9/source/hexEditor.h b/arm9/source/hexEditor.h index 078c408..887a17b 100644 --- a/arm9/source/hexEditor.h +++ b/arm9/source/hexEditor.h @@ -1,6 +1,6 @@ #ifndef HEX_EDITOR_H #define HEX_EDITOR_H -void hexEditor(const char *path); +void hexEditor(const char *path, int drive); #endif