-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor menus and overall structure. NTFS only
- Loading branch information
Showing
24 changed files
with
1,657 additions
and
1,027 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,140 +1,50 @@ | ||
#pragma once | ||
|
||
#include <map> | ||
#include <string> | ||
#include <optional> | ||
#include <queue> | ||
#include <coreinit/time.h> | ||
#include "input/Input.h" | ||
#include "fs/CFile.hpp" | ||
|
||
#define SECTOR_SIZE 0x8000 | ||
#define READ_SECTOR_SIZE SECTOR_SIZE | ||
#define READ_NUM_SECTORS 128 | ||
#define WRITE_BUFFER_NUM_SECTORS 128 | ||
#define WUD_FILE_SIZE 0x5D3A00000L | ||
|
||
|
||
typedef struct { | ||
unsigned int magic0; | ||
unsigned int magic1; | ||
unsigned int sectorSize; | ||
unsigned long long uncompressedSize; | ||
unsigned int flags; | ||
} wuxHeader_t; | ||
|
||
#define WUX_MAGIC_0 0x57555830 | ||
#define WUX_MAGIC_1 swap_uint32(0x1099d02e) | ||
#include <utils/WiiUScreen.h> | ||
#include <utils/ScreenUtils.h> | ||
|
||
class ApplicationState { | ||
public: | ||
|
||
enum eDumpTargetFormat { | ||
DUMP_AS_WUX, | ||
DUMP_AS_WUD, | ||
DUMP_AS_APP, | ||
}; | ||
|
||
|
||
enum eErrorState { | ||
ERROR_NONE, | ||
ERROR_IOSUHAX_FAILED, | ||
ERROR_OPEN_ODD1, | ||
ERROR_READ_FIRST_SECTOR, | ||
ERROR_FILE_OPEN_FAILED, | ||
ERROR_MALLOC_FAILED, | ||
ERROR_NO_DISC_ID, | ||
ERROR_SECTOR_SIZE, | ||
ERROR_MAGIC_NUMBER_WRONG, | ||
ERROR_WRITE_FAILED, | ||
}; | ||
|
||
enum eGameState { | ||
STATE_ERROR, | ||
STATE_WELCOME_SCREEN, | ||
STATE_CHOOSE_TARGET, | ||
STATE_OPEN_ODD1, | ||
STATE_PLEASE_INSERT_DISC, | ||
STATE_DUMP_APP_FILES, | ||
STATE_DUMP_APP_FILES_DONE, | ||
STATE_READ_DISC_INFO, | ||
STATE_READ_DISC_INFO_DONE, | ||
STATE_DUMP_DISC_KEY, | ||
STATE_DUMP_DISC_START, | ||
STATE_DUMP_DISC_DONE, | ||
STATE_WAIT_USER_ERROR_CONFIRM, | ||
STATE_DUMP_DISC, | ||
enum eSubState { | ||
SUBSTATE_RUNNING, | ||
SUBSTATE_RETURN, | ||
}; | ||
|
||
ApplicationState(); | ||
|
||
~ApplicationState(); | ||
|
||
void setError(eErrorState error); | ||
|
||
void render(); | ||
|
||
void update(Input *input); | ||
|
||
std::string ErrorMessage(); | ||
|
||
std::string ErrorDescription(); | ||
|
||
int selectedOption; | ||
|
||
static void printFooter(); | ||
|
||
void proccessMenuNavigation(Input *input, int maxOptionValue); | ||
|
||
static bool entrySelected(Input *input); | ||
|
||
private: | ||
static void printHeader(); | ||
|
||
CFile log; | ||
eGameState state; | ||
eDumpTargetFormat dumpFormat; | ||
eErrorState error = ERROR_NONE; | ||
std::string target = "fs:/vol/external01/"; | ||
int oddFd = -1; | ||
int retryCount = 0; | ||
void *sectorBuf = nullptr; | ||
int sectorBufSize = READ_NUM_SECTORS * READ_SECTOR_SIZE; | ||
char discId[11]; | ||
uint64_t currentSector = 0; | ||
std::vector<uint64_t> skippedSectors; | ||
int readResult = 0; | ||
|
||
[[nodiscard]] bool writeDataToFile(void *buffer, int numberOfSection); | ||
|
||
uint64_t totalSectorCount = 0; | ||
|
||
std::map<std::string, int32_t> hashMap; | ||
CFile *fileHandle; | ||
OSTime startTime; | ||
void *writeBuffer = nullptr; | ||
uint32_t writeBufferPos = 0; | ||
uint32_t writeBufferSize = 0; | ||
virtual ~ApplicationState() = default; | ||
|
||
[[nodiscard]] bool writeCached(uint32_t addr, uint32_t writeSize); | ||
virtual void render() = 0; | ||
|
||
void clearWriteCache(); | ||
virtual eSubState update(Input *input) = 0; | ||
|
||
[[nodiscard]] bool flushWriteCache(); | ||
virtual void proccessMenuNavigation(Input *input, int32_t maxOptionValue) { | ||
if (input->data.buttons_d & Input::BUTTON_UP) { | ||
this->selectedOption--; | ||
} else if (input->data.buttons_d & Input::BUTTON_DOWN) { | ||
this->selectedOption++; | ||
} | ||
if (this->selectedOption < 0) { | ||
this->selectedOption = maxOptionValue; | ||
} else if (this->selectedOption >= maxOptionValue) { | ||
this->selectedOption = 0; | ||
} | ||
} | ||
|
||
uint32_t readSectors = 0; | ||
uint64_t sectorTableStart = 0; | ||
void *sectorIndexTable = nullptr; | ||
uint64_t sectorTableEnd = 0; | ||
virtual bool entrySelected(Input *input) { | ||
return input->data.buttons_d & Input::BUTTON_A; | ||
} | ||
|
||
void writeSectorIndexTable(); | ||
virtual void printHeader() { | ||
WiiUScreen::drawLine("Wudump"); | ||
WiiUScreen::drawLine("=================="); | ||
WiiUScreen::drawLine(""); | ||
} | ||
|
||
void *emptySector = nullptr; | ||
bool doWUX = false; | ||
uint32_t writtenSector = 0; | ||
bool autoSkip = false; | ||
virtual void printFooter() { | ||
ScreenUtils::printTextOnScreen(CONSOLE_SCREEN_TV, 0, 27, "By Maschell"); | ||
ScreenUtils::printTextOnScreen(CONSOLE_SCREEN_DRC, 0, 17, "By Maschell"); | ||
} | ||
|
||
void dumpAppFiles(); | ||
|
||
static void printDumpState(const char *fmt, ...); | ||
int selectedOption = 0; | ||
}; |
Oops, something went wrong.