mirror of
https://github.com/spicyjpeg/573in1.git
synced 2025-01-22 19:52:05 +01:00
Rearrange source files into main and common folders
This commit is contained in:
parent
6c86494fe1
commit
51de642c71
@ -22,33 +22,20 @@ find_program(
|
||||
DOC "Path to MAME chdman tool (optional)"
|
||||
)
|
||||
|
||||
## Main executable
|
||||
## Files common to all executables
|
||||
|
||||
add_executable(
|
||||
cart_tool
|
||||
src/cart.cpp
|
||||
src/cartdata.cpp
|
||||
src/cartio.cpp
|
||||
src/file.cpp
|
||||
src/gpu.cpp
|
||||
src/gpufont.cpp
|
||||
src/ide.cpp
|
||||
src/ideglue.cpp
|
||||
src/io.cpp
|
||||
src/main.cpp
|
||||
src/pad.cpp
|
||||
src/rom.cpp
|
||||
src/spu.cpp
|
||||
src/uibase.cpp
|
||||
src/uicommon.cpp
|
||||
src/util.cpp
|
||||
src/zs01.cpp
|
||||
src/app/app.cpp
|
||||
src/app/appworkers.cpp
|
||||
src/app/cartactions.cpp
|
||||
src/app/cartunlock.cpp
|
||||
src/app/main.cpp
|
||||
src/app/misc.cpp
|
||||
add_library(
|
||||
common OBJECT
|
||||
src/common/file.cpp
|
||||
src/common/gpu.cpp
|
||||
src/common/gpufont.cpp
|
||||
src/common/ide.cpp
|
||||
src/common/ideglue.cpp
|
||||
src/common/io.cpp
|
||||
src/common/pad.cpp
|
||||
src/common/rom.cpp
|
||||
src/common/spu.cpp
|
||||
src/common/util.cpp
|
||||
src/libc/crt0.c
|
||||
src/libc/cxxsupport.cpp
|
||||
src/libc/malloc.c
|
||||
@ -67,12 +54,40 @@ add_executable(
|
||||
src/vendor/qrcodegen.c
|
||||
)
|
||||
target_include_directories(
|
||||
cart_tool PRIVATE
|
||||
common PUBLIC
|
||||
src
|
||||
src/libc
|
||||
)
|
||||
target_compile_definitions(
|
||||
cart_tool PRIVATE
|
||||
common PUBLIC
|
||||
VERSION="${PROJECT_VERSION}"
|
||||
$<IF:$<CONFIG:Debug>,
|
||||
ENABLE_LOGGING=1
|
||||
,
|
||||
ENABLE_LOGGING=1
|
||||
>
|
||||
)
|
||||
|
||||
## Main executable
|
||||
|
||||
add_executable(
|
||||
main
|
||||
src/main/cart.cpp
|
||||
src/main/cartdata.cpp
|
||||
src/main/cartio.cpp
|
||||
src/main/main.cpp
|
||||
src/main/uibase.cpp
|
||||
src/main/uicommon.cpp
|
||||
src/main/zs01.cpp
|
||||
src/main/app/app.cpp
|
||||
src/main/app/appworkers.cpp
|
||||
src/main/app/cartactions.cpp
|
||||
src/main/app/cartunlock.cpp
|
||||
src/main/app/main.cpp
|
||||
src/main/app/misc.cpp
|
||||
)
|
||||
target_compile_definitions(
|
||||
main PRIVATE
|
||||
VERSION="${PROJECT_VERSION}"
|
||||
$<IF:$<CONFIG:Debug>,
|
||||
#ENABLE_ARGV=1
|
||||
@ -80,7 +95,6 @@ target_compile_definitions(
|
||||
ENABLE_CART_MENU=1
|
||||
#ENABLE_X76F100_DRIVER=1
|
||||
ENABLE_DUMMY_DRIVER=1
|
||||
ENABLE_LOGGING=1
|
||||
ENABLE_I2C_LOGGING=1
|
||||
,
|
||||
#ENABLE_ARGV=1
|
||||
@ -88,20 +102,20 @@ target_compile_definitions(
|
||||
ENABLE_CART_MENU=1
|
||||
#ENABLE_X76F100_DRIVER=1
|
||||
#ENABLE_DUMMY_DRIVER=1
|
||||
ENABLE_LOGGING=1
|
||||
#ENABLE_I2C_LOGGING=1
|
||||
>
|
||||
)
|
||||
target_link_libraries(main PRIVATE common)
|
||||
|
||||
add_custom_command(
|
||||
TARGET cart_tool POST_BUILD
|
||||
TARGET main POST_BUILD
|
||||
COMMAND
|
||||
"${Python3_EXECUTABLE}"
|
||||
"${PROJECT_SOURCE_DIR}/tools/convertExecutable.py"
|
||||
-r "cart_tool build ${PROJECT_VERSION} - (C) 2022-2023 spicyjpeg"
|
||||
-s 0x801dfff0
|
||||
$<TARGET_FILE:cart_tool> cart_tool.psexe
|
||||
BYPRODUCTS cart_tool.psexe
|
||||
$<TARGET_FILE:main> main.psexe
|
||||
BYPRODUCTS main.psexe
|
||||
COMMENT "Converting executable"
|
||||
VERBATIM
|
||||
)
|
||||
@ -119,7 +133,7 @@ add_custom_command(
|
||||
VERBATIM
|
||||
)
|
||||
ps1_target_incbin(
|
||||
cart_tool PRIVATE
|
||||
main PRIVATE
|
||||
.rodata _resources _resourcesSize
|
||||
"${PROJECT_BINARY_DIR}/resources.zip"
|
||||
)
|
||||
@ -142,7 +156,7 @@ if(EXISTS "${XORRISO_PATH}")
|
||||
-system_id "PLAYSTATION"
|
||||
-preparer_id "CART_TOOL BUILD SCRIPT"
|
||||
-map cdreadme.txt README.TXT
|
||||
-map cart_tool.psexe PSX.EXE
|
||||
-map main.psexe PSX.EXE
|
||||
-clone PSX.EXE GSE.NXX
|
||||
-clone PSX.EXE NSE.GXX
|
||||
-clone PSX.EXE OSE.FXX
|
||||
@ -163,7 +177,7 @@ if(EXISTS "${XORRISO_PATH}")
|
||||
-clone PSX.EXE TSY.AXD
|
||||
-clone PSX.EXE TSZ.AXC
|
||||
OUTPUT cart_tool.iso
|
||||
DEPENDS cart_tool
|
||||
DEPENDS main
|
||||
COMMENT "Building CD-ROM image"
|
||||
VERBATIM
|
||||
)
|
||||
|
@ -3,14 +3,71 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include "common/file.hpp"
|
||||
#include "ps1/pcdrv.h"
|
||||
#include "vendor/ff.h"
|
||||
#include "vendor/miniz.h"
|
||||
#include "file.hpp"
|
||||
#include "utilerror.hpp"
|
||||
|
||||
namespace file {
|
||||
|
||||
static const char *const _FATFS_ERROR_NAMES[]{
|
||||
"OK",
|
||||
"DISK_ERR",
|
||||
"INT_ERR",
|
||||
"NOT_READY",
|
||||
"NO_FILE",
|
||||
"NO_PATH",
|
||||
"INVALID_NAME",
|
||||
"DENIED",
|
||||
"EXIST",
|
||||
"INVALID_OBJECT",
|
||||
"WRITE_PROTECTED",
|
||||
"INVALID_DRIVE",
|
||||
"NOT_ENABLED",
|
||||
"NO_FILESYSTEM",
|
||||
"MKFS_ABORTED",
|
||||
"TIMEOUT",
|
||||
"LOCKED",
|
||||
"NOT_ENOUGH_CORE",
|
||||
"TOO_MANY_OPEN_FILES",
|
||||
"INVALID_PARAMETER"
|
||||
};
|
||||
|
||||
static const char *const _MINIZ_ZIP_ERROR_NAMES[]{
|
||||
"NO_ERROR",
|
||||
"UNDEFINED_ERROR",
|
||||
"TOO_MANY_FILES",
|
||||
"FILE_TOO_LARGE",
|
||||
"UNSUPPORTED_METHOD",
|
||||
"UNSUPPORTED_ENCRYPTION",
|
||||
"UNSUPPORTED_FEATURE",
|
||||
"FAILED_FINDING_CENTRAL_DIR",
|
||||
"NOT_AN_ARCHIVE",
|
||||
"INVALID_HEADER_OR_CORRUPTED",
|
||||
"UNSUPPORTED_MULTIDISK",
|
||||
"DECOMPRESSION_FAILED",
|
||||
"COMPRESSION_FAILED",
|
||||
"UNEXPECTED_DECOMPRESSED_SIZE",
|
||||
"CRC_CHECK_FAILED",
|
||||
"UNSUPPORTED_CDIR_SIZE",
|
||||
"ALLOC_FAILED",
|
||||
"FILE_OPEN_FAILED",
|
||||
"FILE_CREATE_FAILED",
|
||||
"FILE_WRITE_FAILED",
|
||||
"FILE_READ_FAILED",
|
||||
"FILE_CLOSE_FAILED",
|
||||
"FILE_SEEK_FAILED",
|
||||
"FILE_STAT_FAILED",
|
||||
"INVALID_PARAMETER",
|
||||
"INVALID_FILENAME",
|
||||
"BUF_TOO_SMALL",
|
||||
"INTERNAL_ERROR",
|
||||
"FILE_NOT_FOUND",
|
||||
"ARCHIVE_TOO_LARGE",
|
||||
"VALIDATION_FAILED",
|
||||
"WRITE_CALLBACK_FAILED"
|
||||
};
|
||||
|
||||
/* File classes */
|
||||
|
||||
File::~File(void) {
|
||||
@ -70,7 +127,7 @@ size_t FATFile::read(void *output, size_t length) {
|
||||
auto error = f_read(&_fd, output, length, &actualLength);
|
||||
|
||||
if (error) {
|
||||
LOG("%s, file=0x%08x", util::getErrorString(error), this);
|
||||
LOG("%s, file=0x%08x", _FATFS_ERROR_NAMES[error], this);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -82,7 +139,7 @@ size_t FATFile::write(const void *input, size_t length) {
|
||||
auto error = f_write(&_fd, input, length, &actualLength);
|
||||
|
||||
if (error) {
|
||||
LOG("%s, file=0x%08x", util::getErrorString(error), this);
|
||||
LOG("%s, file=0x%08x", _FATFS_ERROR_NAMES[error], this);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -93,7 +150,7 @@ uint64_t FATFile::seek(uint64_t offset) {
|
||||
auto error = f_lseek(&_fd, offset);
|
||||
|
||||
if (error) {
|
||||
LOG("%s, file=0x%08x", util::getErrorString(error), this);
|
||||
LOG("%s, file=0x%08x", _FATFS_ERROR_NAMES[error], this);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -121,7 +178,7 @@ bool FATDirectory::getEntry(
|
||||
auto error = f_readdir(&_fd, &info);
|
||||
|
||||
if (error) {
|
||||
LOG("%s", util::getErrorString(error));
|
||||
LOG("%s", _FATFS_ERROR_NAMES[error]);
|
||||
return false;
|
||||
}
|
||||
if (!info.fname[0])
|
||||
@ -304,7 +361,7 @@ bool FATProvider::init(const char *drive) {
|
||||
auto error = f_mount(&_fs, drive, 1);
|
||||
|
||||
if (error) {
|
||||
LOG("%s, drive=%s", util::getErrorString(error), drive);
|
||||
LOG("%s, drive=%s", _FATFS_ERROR_NAMES[error], drive);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -316,7 +373,7 @@ void FATProvider::close(void) {
|
||||
auto error = f_unmount(_drive);
|
||||
|
||||
if (error) {
|
||||
LOG("%s, drive=%s", util::getErrorString(error), _drive);
|
||||
LOG("%s, drive=%s", _FATFS_ERROR_NAMES[error], _drive);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -345,7 +402,7 @@ uint64_t FATProvider::getFreeSpace(void) {
|
||||
auto error = f_getfree(_drive, &count, &dummy);
|
||||
|
||||
if (error) {
|
||||
LOG("%s, drive=%s", util::getErrorString(error), _drive);
|
||||
LOG("%s, drive=%s", _FATFS_ERROR_NAMES[error], _drive);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -363,7 +420,7 @@ size_t FATProvider::getVolumeLabel(char *output, size_t length) {
|
||||
auto error = f_getlabel(_drive, output, nullptr);
|
||||
|
||||
if (error) {
|
||||
LOG("%s, drive=%s", util::getErrorString(error), _drive);
|
||||
LOG("%s, drive=%s", _FATFS_ERROR_NAMES[error], _drive);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -378,7 +435,7 @@ uint32_t FATProvider::getSerialNumber(void) {
|
||||
auto error = f_getlabel(_drive, nullptr, &serial);
|
||||
|
||||
if (error) {
|
||||
LOG("%s, drive=%s", util::getErrorString(error), _drive);
|
||||
LOG("%s, drive=%s", _FATFS_ERROR_NAMES[error], _drive);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -400,7 +457,7 @@ bool FATProvider::getFileInfo(FileInfo &output, const char *path) {
|
||||
auto error = f_stat(path, &info);
|
||||
|
||||
if (error) {
|
||||
LOG("%s, drive=%s", util::getErrorString(error), _drive);
|
||||
LOG("%s, drive=%s", _FATFS_ERROR_NAMES[error], _drive);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -422,7 +479,7 @@ Directory *FATProvider::openDirectory(const char *path) {
|
||||
auto error = f_opendir(&(dir->_fd), path);
|
||||
|
||||
if (error) {
|
||||
LOG("%s, drive=%s", util::getErrorString(error), _drive);
|
||||
LOG("%s, drive=%s", _FATFS_ERROR_NAMES[error], _drive);
|
||||
delete dir;
|
||||
return nullptr;
|
||||
}
|
||||
@ -437,7 +494,7 @@ bool FATProvider::createDirectory(const char *path) {
|
||||
auto error = f_mkdir(path);
|
||||
|
||||
if (error) {
|
||||
LOG("%s, drive=%s", util::getErrorString(error), _drive);
|
||||
LOG("%s, drive=%s", _FATFS_ERROR_NAMES[error], _drive);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -452,7 +509,7 @@ File *FATProvider::openFile(const char *path, uint32_t flags) {
|
||||
auto error = f_open(&(file->_fd), path, uint8_t(flags));
|
||||
|
||||
if (error) {
|
||||
LOG("%s, drive=%s", util::getErrorString(error), _drive);
|
||||
LOG("%s, drive=%s", _FATFS_ERROR_NAMES[error], _drive);
|
||||
delete file;
|
||||
return nullptr;
|
||||
}
|
||||
@ -485,7 +542,7 @@ bool ZIPProvider::init(File *file) {
|
||||
if (!mz_zip_reader_init(&_zip, file->length, _ZIP_FLAGS)) {
|
||||
auto error = mz_zip_get_last_error(&_zip);
|
||||
|
||||
LOG("%s, file=0x%08x", util::getErrorString(error), file);
|
||||
LOG("%s, file=0x%08x", _MINIZ_ZIP_ERROR_NAMES[error], file);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -500,7 +557,7 @@ bool ZIPProvider::init(const void *zipData, size_t length) {
|
||||
if (!mz_zip_reader_init_mem(&_zip, zipData, length, _ZIP_FLAGS)) {
|
||||
auto error = mz_zip_get_last_error(&_zip);
|
||||
|
||||
LOG("%s, ptr=0x%08x", util::getErrorString(error), zipData);
|
||||
LOG("%s, ptr=0x%08x", _MINIZ_ZIP_ERROR_NAMES[error], zipData);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -562,7 +619,7 @@ size_t ZIPProvider::loadData(util::Data &output, const char *path) {
|
||||
if (!output.ptr) {
|
||||
auto error = mz_zip_get_last_error(&_zip);
|
||||
|
||||
LOG("%s, zip=0x%08x", util::getErrorString(error), this);
|
||||
LOG("%s, zip=0x%08x", _MINIZ_ZIP_ERROR_NAMES[error], this);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -573,7 +630,7 @@ size_t ZIPProvider::loadData(void *output, size_t length, const char *path) {
|
||||
if (!mz_zip_reader_extract_file_to_mem(&_zip, path, output, length, 0)) {
|
||||
auto error = mz_zip_get_last_error(&_zip);
|
||||
|
||||
LOG("%s, zip=0x%08x", util::getErrorString(error), this);
|
||||
LOG("%s, zip=0x%08x", _MINIZ_ZIP_ERROR_NAMES[error], this);
|
||||
return 0;
|
||||
}
|
||||
|
@ -3,11 +3,11 @@
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include "common/gpu.hpp"
|
||||
#include "common/spu.hpp"
|
||||
#include "common/util.hpp"
|
||||
#include "vendor/ff.h"
|
||||
#include "vendor/miniz.h"
|
||||
#include "gpu.hpp"
|
||||
#include "spu.hpp"
|
||||
#include "util.hpp"
|
||||
|
||||
namespace file {
|
||||
|
@ -2,12 +2,12 @@
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include "common/gpu.hpp"
|
||||
#include "common/util.hpp"
|
||||
#include "ps1/gpucmd.h"
|
||||
#include "ps1/registers.h"
|
||||
#include "ps1/system.h"
|
||||
#include "vendor/qrcodegen.h"
|
||||
#include "gpu.hpp"
|
||||
#include "util.hpp"
|
||||
|
||||
namespace gpu {
|
||||
|
@ -1,9 +1,8 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include "common/gpu.hpp"
|
||||
#include "common/gpufont.hpp"
|
||||
#include "ps1/gpucmd.h"
|
||||
#include "gpu.hpp"
|
||||
#include "gpufont.hpp"
|
||||
#include "util.hpp"
|
||||
|
||||
namespace gpu {
|
||||
|
@ -2,7 +2,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "gpu.hpp"
|
||||
#include "common/gpu.hpp"
|
||||
|
||||
namespace gpu {
|
||||
|
@ -1,10 +1,10 @@
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include "common/ide.hpp"
|
||||
#include "common/util.hpp"
|
||||
#include "ps1/registers.h"
|
||||
#include "ps1/system.h"
|
||||
#include "ide.hpp"
|
||||
#include "util.hpp"
|
||||
|
||||
/*
|
||||
* Based on the following specifications:
|
||||
@ -26,6 +26,15 @@ static constexpr int _RESET_STATUS_TIMEOUT = 2000000;
|
||||
static constexpr int _DATA_STATUS_TIMEOUT = 2000000;
|
||||
static constexpr int _DMA_TIMEOUT = 10000;
|
||||
|
||||
const char *const DEVICE_ERROR_NAMES[]{
|
||||
"NO_ERROR",
|
||||
"UNSUPPORTED_OP",
|
||||
"STATUS_TIMEOUT",
|
||||
"DRIVE_ERROR",
|
||||
"INCOMPLETE_DATA",
|
||||
"CHECKSUM_MISMATCH"
|
||||
};
|
||||
|
||||
/* Utilities */
|
||||
|
||||
static void _copyString(char *output, const uint16_t *input, size_t length) {
|
@ -4,7 +4,6 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include "ps1/registers.h"
|
||||
#include "util.hpp"
|
||||
|
||||
namespace ide {
|
||||
|
||||
@ -354,6 +353,12 @@ public:
|
||||
);
|
||||
};
|
||||
|
||||
extern const char *const DEVICE_ERROR_NAMES[];
|
||||
|
||||
extern Device devices[2];
|
||||
|
||||
static inline const char *getErrorString(DeviceError error) {
|
||||
return DEVICE_ERROR_NAMES[error];
|
||||
}
|
||||
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include "common/ide.hpp"
|
||||
#include "common/io.hpp"
|
||||
#include "vendor/diskio.h"
|
||||
#include "ide.hpp"
|
||||
#include "io.hpp"
|
||||
|
||||
/* FatFs library API glue */
|
||||
|
@ -1,9 +1,9 @@
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include "common/io.hpp"
|
||||
#include "ps1/registers.h"
|
||||
#include "ps1/system.h"
|
||||
#include "io.hpp"
|
||||
|
||||
namespace io {
|
||||
|
@ -1,10 +1,9 @@
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include "common/pad.hpp"
|
||||
#include "ps1/registers.h"
|
||||
#include "ps1/system.h"
|
||||
#include "pad.hpp"
|
||||
#include "util.hpp"
|
||||
|
||||
namespace pad {
|
||||
|
@ -1,8 +1,10 @@
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include "common/io.hpp"
|
||||
#include "common/rom.hpp"
|
||||
#include "common/util.hpp"
|
||||
#include "ps1/registers.h"
|
||||
#include "io.hpp"
|
||||
#include "rom.hpp"
|
||||
#include "util.hpp"
|
||||
|
||||
namespace rom {
|
||||
|
@ -3,8 +3,8 @@
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include "common/util.hpp"
|
||||
#include "ps1/registers.h"
|
||||
#include "util.hpp"
|
||||
|
||||
namespace rom {
|
||||
|
@ -1,10 +1,10 @@
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
#include "common/spu.hpp"
|
||||
#include "common/util.hpp"
|
||||
#include "ps1/registers.h"
|
||||
#include "ps1/system.h"
|
||||
#include "spu.hpp"
|
||||
#include "util.hpp"
|
||||
|
||||
namespace spu {
|
||||
|
@ -4,9 +4,9 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "common/util.hpp"
|
||||
#include "ps1/registers.h"
|
||||
#include "ps1/system.h"
|
||||
#include "util.hpp"
|
||||
|
||||
namespace util {
|
||||
|
||||
@ -225,98 +225,4 @@ bool ExecutableHeader::validateMagic(void) const {
|
||||
return (hash(magic, sizeof(magic)) == "PS-X EXE"_h);
|
||||
}
|
||||
|
||||
/* Error strings */
|
||||
|
||||
const char *const CART_DRIVER_ERROR_NAMES[]{
|
||||
"NO_ERROR", // = 0
|
||||
"UNSUPPORTED_OP",
|
||||
"DS2401_NO_RESP",
|
||||
"DS2401_ID_ERROR",
|
||||
"X76_NACK",
|
||||
"X76_POLL_FAIL",
|
||||
"X76_VERIFY_FAIL",
|
||||
"ZS01_NACK",
|
||||
"ZS01_ERROR",
|
||||
"ZS01_CRC_MISMATCH"
|
||||
};
|
||||
|
||||
const char *const IDE_DEVICE_ERROR_NAMES[]{
|
||||
"NO_ERROR", // = 0
|
||||
"UNSUPPORTED_OP",
|
||||
"STATUS_TIMEOUT",
|
||||
"DRIVE_ERROR",
|
||||
"INCOMPLETE_DATA",
|
||||
"CHECKSUM_MISMATCH"
|
||||
};
|
||||
|
||||
const char *const FATFS_ERROR_NAMES[]{
|
||||
"OK", // = 0
|
||||
"DISK_ERR",
|
||||
"INT_ERR",
|
||||
"NOT_READY",
|
||||
"NO_FILE",
|
||||
"NO_PATH",
|
||||
"INVALID_NAME",
|
||||
"DENIED",
|
||||
"EXIST",
|
||||
"INVALID_OBJECT",
|
||||
"WRITE_PROTECTED",
|
||||
"INVALID_DRIVE",
|
||||
"NOT_ENABLED",
|
||||
"NO_FILESYSTEM",
|
||||
"MKFS_ABORTED",
|
||||
"TIMEOUT",
|
||||
"LOCKED",
|
||||
"NOT_ENOUGH_CORE",
|
||||
"TOO_MANY_OPEN_FILES",
|
||||
"INVALID_PARAMETER"
|
||||
};
|
||||
|
||||
const char *const MINIZ_ERROR_NAMES[]{
|
||||
"VERSION_ERROR",
|
||||
"BUF_ERROR",
|
||||
"MEM_ERROR",
|
||||
"DATA_ERROR",
|
||||
"STREAM_ERROR",
|
||||
"ERRNO",
|
||||
"OK", // = 0
|
||||
"STREAM_END",
|
||||
"NEED_DICT"
|
||||
};
|
||||
|
||||
const char *const MINIZ_ZIP_ERROR_NAMES[]{
|
||||
"NO_ERROR", // = 0
|
||||
"UNDEFINED_ERROR",
|
||||
"TOO_MANY_FILES",
|
||||
"FILE_TOO_LARGE",
|
||||
"UNSUPPORTED_METHOD",
|
||||
"UNSUPPORTED_ENCRYPTION",
|
||||
"UNSUPPORTED_FEATURE",
|
||||
"FAILED_FINDING_CENTRAL_DIR",
|
||||
"NOT_AN_ARCHIVE",
|
||||
"INVALID_HEADER_OR_CORRUPTED",
|
||||
"UNSUPPORTED_MULTIDISK",
|
||||
"DECOMPRESSION_FAILED",
|
||||
"COMPRESSION_FAILED",
|
||||
"UNEXPECTED_DECOMPRESSED_SIZE",
|
||||
"CRC_CHECK_FAILED",
|
||||
"UNSUPPORTED_CDIR_SIZE",
|
||||
"ALLOC_FAILED",
|
||||
"FILE_OPEN_FAILED",
|
||||
"FILE_CREATE_FAILED",
|
||||
"FILE_WRITE_FAILED",
|
||||
"FILE_READ_FAILED",
|
||||
"FILE_CLOSE_FAILED",
|
||||
"FILE_SEEK_FAILED",
|
||||
"FILE_STAT_FAILED",
|
||||
"INVALID_PARAMETER",
|
||||
"INVALID_FILENAME",
|
||||
"BUF_TOO_SMALL",
|
||||
"INTERNAL_ERROR",
|
||||
"FILE_NOT_FOUND",
|
||||
"ARCHIVE_TOO_LARGE",
|
||||
"VALIDATION_FAILED",
|
||||
"WRITE_CALLBACK_FAILED"
|
||||
};
|
||||
|
||||
}
|
@ -1,12 +1,12 @@
|
||||
|
||||
#include "app/app.hpp"
|
||||
#include "common/defs.hpp"
|
||||
#include "common/file.hpp"
|
||||
#include "common/io.hpp"
|
||||
#include "common/util.hpp"
|
||||
#include "main/app/app.hpp"
|
||||
#include "main/cart.hpp"
|
||||
#include "main/uibase.hpp"
|
||||
#include "ps1/system.h"
|
||||
#include "cart.hpp"
|
||||
#include "defs.hpp"
|
||||
#include "file.hpp"
|
||||
#include "io.hpp"
|
||||
#include "uibase.hpp"
|
||||
#include "util.hpp"
|
||||
|
||||
/* Worker status class */
|
||||
|
@ -2,17 +2,17 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "app/cartactions.hpp"
|
||||
#include "app/cartunlock.hpp"
|
||||
#include "app/main.hpp"
|
||||
#include "app/misc.hpp"
|
||||
#include "common/file.hpp"
|
||||
#include "common/rom.hpp"
|
||||
#include "main/app/cartactions.hpp"
|
||||
#include "main/app/cartunlock.hpp"
|
||||
#include "main/app/main.hpp"
|
||||
#include "main/app/misc.hpp"
|
||||
#include "main/cart.hpp"
|
||||
#include "main/cartdata.hpp"
|
||||
#include "main/cartio.hpp"
|
||||
#include "main/uibase.hpp"
|
||||
#include "ps1/system.h"
|
||||
#include "cart.hpp"
|
||||
#include "cartdata.hpp"
|
||||
#include "cartio.hpp"
|
||||
#include "file.hpp"
|
||||
#include "rom.hpp"
|
||||
#include "uibase.hpp"
|
||||
|
||||
/* Worker status class */
|
||||
|
@ -2,19 +2,18 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include "app/app.hpp"
|
||||
#include "common/defs.hpp"
|
||||
#include "common/file.hpp"
|
||||
#include "common/ide.hpp"
|
||||
#include "common/io.hpp"
|
||||
#include "common/rom.hpp"
|
||||
#include "common/util.hpp"
|
||||
#include "main/app/app.hpp"
|
||||
#include "main/cart.hpp"
|
||||
#include "main/cartdata.hpp"
|
||||
#include "main/cartio.hpp"
|
||||
#include "main/uibase.hpp"
|
||||
#include "ps1/system.h"
|
||||
#include "cart.hpp"
|
||||
#include "cartdata.hpp"
|
||||
#include "cartio.hpp"
|
||||
#include "defs.hpp"
|
||||
#include "file.hpp"
|
||||
#include "ide.hpp"
|
||||
#include "io.hpp"
|
||||
#include "rom.hpp"
|
||||
#include "uibase.hpp"
|
||||
#include "util.hpp"
|
||||
#include "utilerror.hpp"
|
||||
|
||||
bool App::_startupWorker(void) {
|
||||
#ifdef NDEBUG
|
||||
@ -86,12 +85,12 @@ bool App::_cartDetectWorker(void) {
|
||||
auto error = _driver->readCartID();
|
||||
|
||||
if (error)
|
||||
LOG("SID error [%s]", util::getErrorString(error));
|
||||
LOG("SID error [%s]", cart::getErrorString(error));
|
||||
|
||||
error = _driver->readPublicData();
|
||||
|
||||
if (error)
|
||||
LOG("read error [%s]", util::getErrorString(error));
|
||||
LOG("read error [%s]", cart::getErrorString(error));
|
||||
else if (!_dump.isReadableDataEmpty())
|
||||
_parser = cart::newCartParser(_dump);
|
||||
|
||||
@ -156,7 +155,7 @@ _cartInitDone:
|
||||
auto error = _driver->readSystemID();
|
||||
|
||||
if (error)
|
||||
LOG("XID error [%s]", util::getErrorString(error));
|
||||
LOG("XID error [%s]", cart::getErrorString(error));
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -178,7 +177,7 @@ bool App::_cartUnlockWorker(void) {
|
||||
if (error) {
|
||||
_messageScreen.setMessage(
|
||||
MESSAGE_ERROR, _cartInfoScreen,
|
||||
WSTRH(_UNLOCK_ERRORS[_dump.chipType]), util::getErrorString(error)
|
||||
WSTRH(_UNLOCK_ERRORS[_dump.chipType]), cart::getErrorString(error)
|
||||
);
|
||||
|
||||
_workerStatus.setNextScreen(_messageScreen);
|
||||
@ -286,7 +285,7 @@ bool App::_cartWriteWorker(void) {
|
||||
if (error) {
|
||||
_messageScreen.setMessage(
|
||||
MESSAGE_ERROR, _cartInfoScreen, WSTR("App.cartWriteWorker.error"),
|
||||
util::getErrorString(error)
|
||||
cart::getErrorString(error)
|
||||
);
|
||||
_workerStatus.setNextScreen(_messageScreen);
|
||||
return false;
|
||||
@ -355,7 +354,7 @@ bool App::_cartReflashWorker(void) {
|
||||
auto error = _driver->setDataKey(_selectedEntry->dataKey);
|
||||
|
||||
if (error) {
|
||||
LOG("key error [%s]", util::getErrorString(error));
|
||||
LOG("key error [%s]", cart::getErrorString(error));
|
||||
} else {
|
||||
_workerStatus.update(2, 3, WSTR("App.cartReflashWorker.write"));
|
||||
error = _driver->writeData();
|
||||
@ -367,7 +366,7 @@ bool App::_cartReflashWorker(void) {
|
||||
_messageScreen.setMessage(
|
||||
MESSAGE_ERROR, _cartInfoScreen,
|
||||
WSTR("App.cartReflashWorker.writeError"),
|
||||
util::getErrorString(error)
|
||||
cart::getErrorString(error)
|
||||
);
|
||||
_workerStatus.setNextScreen(_messageScreen);
|
||||
return false;
|
||||
@ -385,7 +384,7 @@ bool App::_cartEraseWorker(void) {
|
||||
if (error) {
|
||||
_messageScreen.setMessage(
|
||||
MESSAGE_ERROR, _cartInfoScreen, WSTR("App.cartEraseWorker.error"),
|
||||
util::getErrorString(error)
|
||||
cart::getErrorString(error)
|
||||
);
|
||||
_workerStatus.setNextScreen(_messageScreen);
|
||||
return false;
|
||||
@ -632,7 +631,7 @@ bool App::_atapiEjectWorker(void) {
|
||||
if (error) {
|
||||
_messageScreen.setMessage(
|
||||
MESSAGE_ERROR, _mainMenuScreen,
|
||||
WSTR("App.atapiEjectWorker.ejectError"), util::getErrorString(error)
|
||||
WSTR("App.atapiEjectWorker.ejectError"), ide::getErrorString(error)
|
||||
);
|
||||
_workerStatus.setNextScreen(_messageScreen);
|
||||
return false;
|
@ -1,9 +1,9 @@
|
||||
|
||||
#include "app/cartactions.hpp"
|
||||
#include "app/app.hpp"
|
||||
#include "defs.hpp"
|
||||
#include "uibase.hpp"
|
||||
#include "util.hpp"
|
||||
#include "common/defs.hpp"
|
||||
#include "common/util.hpp"
|
||||
#include "main/app/cartactions.hpp"
|
||||
#include "main/app/app.hpp"
|
||||
#include "main/uibase.hpp"
|
||||
|
||||
/* Unlocked cartridge screens */
|
||||
|
@ -2,11 +2,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
#include "cartdata.hpp"
|
||||
#include "gpu.hpp"
|
||||
#include "uibase.hpp"
|
||||
#include "uicommon.hpp"
|
||||
#include "util.hpp"
|
||||
#include "common/gpu.hpp"
|
||||
#include "common/util.hpp"
|
||||
#include "main/cartdata.hpp"
|
||||
#include "main/uibase.hpp"
|
||||
#include "main/uicommon.hpp"
|
||||
|
||||
/* Unlocked cartridge screens */
|
||||
|
@ -1,10 +1,10 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include "app/app.hpp"
|
||||
#include "app/cartunlock.hpp"
|
||||
#include "cartdata.hpp"
|
||||
#include "uibase.hpp"
|
||||
#include "util.hpp"
|
||||
#include "common/util.hpp"
|
||||
#include "main/app/app.hpp"
|
||||
#include "main/app/cartunlock.hpp"
|
||||
#include "main/cartdata.hpp"
|
||||
#include "main/uibase.hpp"
|
||||
|
||||
/* Pre-unlock cartridge screens */
|
||||
|
@ -1,8 +1,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "uibase.hpp"
|
||||
#include "uicommon.hpp"
|
||||
#include "main/uibase.hpp"
|
||||
#include "main/uicommon.hpp"
|
||||
|
||||
/* Pre-unlock cartridge screens */
|
||||
|
@ -1,12 +1,12 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include "app/app.hpp"
|
||||
#include "app/main.hpp"
|
||||
#include "common/ide.hpp"
|
||||
#include "common/rom.hpp"
|
||||
#include "common/util.hpp"
|
||||
#include "main/app/app.hpp"
|
||||
#include "main/app/main.hpp"
|
||||
#include "main/uibase.hpp"
|
||||
#include "ps1/gpucmd.h"
|
||||
#include "ide.hpp"
|
||||
#include "rom.hpp"
|
||||
#include "uibase.hpp"
|
||||
#include "util.hpp"
|
||||
|
||||
/* Main menu screens */
|
||||
|
@ -1,9 +1,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "uibase.hpp"
|
||||
#include "uicommon.hpp"
|
||||
#include "util.hpp"
|
||||
#include "common/util.hpp"
|
||||
#include "main/uibase.hpp"
|
||||
#include "main/uicommon.hpp"
|
||||
|
||||
/* Main menu screens */
|
||||
|
@ -1,10 +1,10 @@
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include "app/app.hpp"
|
||||
#include "app/misc.hpp"
|
||||
#include "uibase.hpp"
|
||||
#include "util.hpp"
|
||||
#include "common/util.hpp"
|
||||
#include "main/app/app.hpp"
|
||||
#include "main/app/misc.hpp"
|
||||
#include "main/uibase.hpp"
|
||||
|
||||
/* Common screens */
|
||||
|
@ -1,8 +1,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "uibase.hpp"
|
||||
#include "uicommon.hpp"
|
||||
#include "main/uibase.hpp"
|
||||
#include "main/uicommon.hpp"
|
||||
|
||||
/* Common screens */
|
||||
|
@ -1,10 +1,9 @@
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include "common/util.hpp"
|
||||
#include "main/cart.hpp"
|
||||
#include "vendor/miniz.h"
|
||||
#include "cart.hpp"
|
||||
#include "util.hpp"
|
||||
#include "utilerror.hpp"
|
||||
|
||||
namespace cart {
|
||||
|
||||
@ -235,6 +234,18 @@ bool Dump::isReadableDataEmpty(void) const {
|
||||
return isDataEmpty();
|
||||
}
|
||||
|
||||
static const char *const _MINIZ_ERROR_NAMES[]{
|
||||
"VERSION_ERROR",
|
||||
"BUF_ERROR",
|
||||
"MEM_ERROR",
|
||||
"DATA_ERROR",
|
||||
"STREAM_ERROR",
|
||||
"ERRNO",
|
||||
"OK", // = 0
|
||||
"STREAM_END",
|
||||
"NEED_DICT"
|
||||
};
|
||||
|
||||
size_t Dump::toQRString(char *output) const {
|
||||
uint8_t compressed[MAX_QR_STRING_LENGTH];
|
||||
size_t uncompLength = getDumpLength();
|
||||
@ -247,10 +258,13 @@ size_t Dump::toQRString(char *output) const {
|
||||
MZ_BEST_COMPRESSION
|
||||
);
|
||||
|
||||
if (error != MZ_OK) {
|
||||
LOG("%s, ptr=0x%08x", util::getErrorString(error), this);
|
||||
if (error) {
|
||||
LOG(
|
||||
"%s, ptr=0x%08x", _MINIZ_ERROR_NAMES[error - MZ_VERSION_ERROR], this
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
||||
LOG(
|
||||
"dump compressed, size=%d, ratio=%d%%", compLength,
|
||||
compLength * 100 / uncompLength
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include "util.hpp"
|
||||
#include "common/util.hpp"
|
||||
|
||||
namespace cart {
|
||||
|
@ -1,9 +1,9 @@
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include "cart.hpp"
|
||||
#include "cartdata.hpp"
|
||||
#include "util.hpp"
|
||||
#include "common/util.hpp"
|
||||
#include "main/cart.hpp"
|
||||
#include "main/cartdata.hpp"
|
||||
|
||||
namespace cart {
|
||||
|
@ -4,8 +4,8 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include "cart.hpp"
|
||||
#include "util.hpp"
|
||||
#include "common/util.hpp"
|
||||
#include "main/cart.hpp"
|
||||
|
||||
namespace cart {
|
||||
|
@ -1,13 +1,26 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include "common/io.hpp"
|
||||
#include "main/cart.hpp"
|
||||
#include "main/cartio.hpp"
|
||||
#include "main/zs01.hpp"
|
||||
#include "ps1/system.h"
|
||||
#include "cart.hpp"
|
||||
#include "cartio.hpp"
|
||||
#include "io.hpp"
|
||||
#include "zs01.hpp"
|
||||
|
||||
namespace cart {
|
||||
|
||||
const char *const DRIVER_ERROR_NAMES[]{
|
||||
"NO_ERROR",
|
||||
"UNSUPPORTED_OP",
|
||||
"DS2401_NO_RESP",
|
||||
"DS2401_ID_ERROR",
|
||||
"X76_NACK",
|
||||
"X76_POLL_FAIL",
|
||||
"X76_VERIFY_FAIL",
|
||||
"ZS01_NACK",
|
||||
"ZS01_ERROR",
|
||||
"ZS01_CRC_MISMATCH"
|
||||
};
|
||||
|
||||
/* Dummy cartridge driver */
|
||||
|
||||
Dump dummyDriverDump;
|
@ -2,9 +2,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "cart.hpp"
|
||||
#include "util.hpp"
|
||||
#include "zs01.hpp"
|
||||
#include "common/util.hpp"
|
||||
#include "main/cart.hpp"
|
||||
#include "main/zs01.hpp"
|
||||
|
||||
namespace cart {
|
||||
|
||||
@ -140,6 +140,12 @@ public:
|
||||
DriverError setDataKey(const uint8_t *key);
|
||||
};
|
||||
|
||||
extern const char *const DRIVER_ERROR_NAMES[];
|
||||
|
||||
static inline const char *getErrorString(DriverError error) {
|
||||
return DRIVER_ERROR_NAMES[error];
|
||||
}
|
||||
|
||||
CartDriver *newCartDriver(Dump &dump);
|
||||
|
||||
}
|
@ -1,16 +1,17 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "app/app.hpp"
|
||||
#include "common/defs.hpp"
|
||||
#include "common/file.hpp"
|
||||
#include "common/gpu.hpp"
|
||||
#include "common/io.hpp"
|
||||
#include "common/spu.hpp"
|
||||
#include "common/util.hpp"
|
||||
#include "main/app/app.hpp"
|
||||
#include "main/uibase.hpp"
|
||||
#include "ps1/gpucmd.h"
|
||||
#include "ps1/system.h"
|
||||
#include "defs.hpp"
|
||||
#include "file.hpp"
|
||||
#include "gpu.hpp"
|
||||
#include "io.hpp"
|
||||
#include "spu.hpp"
|
||||
#include "uibase.hpp"
|
||||
#include "util.hpp"
|
||||
|
||||
|
||||
extern "C" const uint8_t _resources[];
|
||||
extern "C" const size_t _resourcesSize;
|
@ -1,11 +1,11 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include "common/gpu.hpp"
|
||||
#include "common/gpufont.hpp"
|
||||
#include "common/io.hpp"
|
||||
#include "common/pad.hpp"
|
||||
#include "main/uibase.hpp"
|
||||
#include "ps1/gpucmd.h"
|
||||
#include "gpu.hpp"
|
||||
#include "gpufont.hpp"
|
||||
#include "io.hpp"
|
||||
#include "pad.hpp"
|
||||
#include "uibase.hpp"
|
||||
|
||||
namespace ui {
|
||||
|
@ -2,10 +2,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "gpu.hpp"
|
||||
#include "gpufont.hpp"
|
||||
#include "spu.hpp"
|
||||
#include "util.hpp"
|
||||
#include "common/gpu.hpp"
|
||||
#include "common/gpufont.hpp"
|
||||
#include "common/spu.hpp"
|
||||
#include "common/util.hpp"
|
||||
|
||||
namespace ui {
|
||||
|
@ -1,10 +1,10 @@
|
||||
|
||||
#include "common/defs.hpp"
|
||||
#include "common/gpu.hpp"
|
||||
#include "common/gpufont.hpp"
|
||||
#include "main/uibase.hpp"
|
||||
#include "main/uicommon.hpp"
|
||||
#include "ps1/gpucmd.h"
|
||||
#include "defs.hpp"
|
||||
#include "gpu.hpp"
|
||||
#include "gpufont.hpp"
|
||||
#include "uibase.hpp"
|
||||
#include "uicommon.hpp"
|
||||
|
||||
namespace ui {
|
||||
|
@ -2,9 +2,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "gpufont.hpp"
|
||||
#include "uibase.hpp"
|
||||
#include "util.hpp"
|
||||
#include "common/gpufont.hpp"
|
||||
#include "common/util.hpp"
|
||||
#include "main/uibase.hpp"
|
||||
|
||||
namespace ui {
|
||||
|
@ -1,8 +1,8 @@
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include "util.hpp"
|
||||
#include "zs01.hpp"
|
||||
#include "common/util.hpp"
|
||||
#include "main/zs01.hpp"
|
||||
|
||||
namespace zs01 {
|
||||
|
@ -1,32 +0,0 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cartio.hpp"
|
||||
#include "ide.hpp"
|
||||
#include "util.hpp"
|
||||
#include "vendor/ff.h"
|
||||
#include "vendor/miniz.h"
|
||||
|
||||
namespace util {
|
||||
|
||||
static inline const char *getErrorString(cart::DriverError error) {
|
||||
return CART_DRIVER_ERROR_NAMES[error];
|
||||
}
|
||||
|
||||
static inline const char *getErrorString(ide::DeviceError error) {
|
||||
return IDE_DEVICE_ERROR_NAMES[error];
|
||||
}
|
||||
|
||||
static inline const char *getErrorString(FRESULT error) {
|
||||
return FATFS_ERROR_NAMES[error];
|
||||
}
|
||||
|
||||
static inline const char *getErrorString(int error) {
|
||||
return MINIZ_ERROR_NAMES[error - MZ_VERSION_ERROR];
|
||||
}
|
||||
|
||||
static inline const char *getErrorString(mz_zip_error error) {
|
||||
return MINIZ_ZIP_ERROR_NAMES[error];
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user