Compare commits
6 Commits
0.8.1-pre1
...
v0.8.4-pre
Author | SHA1 | Date | |
---|---|---|---|
ec0411373b | |||
222a13387d | |||
c1e471f23a | |||
6b48ba070c | |||
bbbfd60bb7 | |||
62fa5ede9d |
16
.vscode/c_cpp_properties.json
vendored
Normal file
16
.vscode/c_cpp_properties.json
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "3DS | Windows",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/**",
|
||||
"C:/devkitpro/libctru/include/**",
|
||||
"C:/devkitpro/devkitARM/include/**",
|
||||
"C:/devkitpro/devkitARM/arm-none-eabi/include/**",
|
||||
"C:/devkitpro/portlibs/3ds/include/**"
|
||||
|
||||
]
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
28
.vscode/settings.json
vendored
28
.vscode/settings.json
vendored
@ -60,6 +60,32 @@
|
||||
"cuchar": "cpp",
|
||||
"compare": "cpp",
|
||||
"concepts": "cpp",
|
||||
"numbers": "cpp"
|
||||
"numbers": "cpp",
|
||||
"filesystem": "cpp",
|
||||
"xstring": "cpp",
|
||||
"charconv": "cpp",
|
||||
"format": "cpp",
|
||||
"ios": "cpp",
|
||||
"list": "cpp",
|
||||
"locale": "cpp",
|
||||
"mutex": "cpp",
|
||||
"stack": "cpp",
|
||||
"stop_token": "cpp",
|
||||
"thread": "cpp",
|
||||
"xfacet": "cpp",
|
||||
"xhash": "cpp",
|
||||
"xiosbase": "cpp",
|
||||
"xlocale": "cpp",
|
||||
"xlocbuf": "cpp",
|
||||
"xlocinfo": "cpp",
|
||||
"xlocmes": "cpp",
|
||||
"xlocmon": "cpp",
|
||||
"xlocnum": "cpp",
|
||||
"xloctime": "cpp",
|
||||
"xmemory": "cpp",
|
||||
"xstddef": "cpp",
|
||||
"xtr1common": "cpp",
|
||||
"xtree": "cpp",
|
||||
"xutility": "cpp"
|
||||
}
|
||||
}
|
2
Makefile
2
Makefile
@ -10,7 +10,7 @@ include $(DEVKITARM)/3ds_rules
|
||||
|
||||
export renderd7_MAJOR := 0
|
||||
export renderd7_MINOR := 8
|
||||
export renderd7_PATCH := 1
|
||||
export renderd7_PATCH := 4
|
||||
|
||||
VERSION := $(renderd7_MAJOR).$(renderd7_MINOR).$(renderd7_PATCH)
|
||||
|
||||
|
@ -35,6 +35,7 @@ public:
|
||||
void DrawPixel(int x, int y, u8 b, u8 g, u8 r, u8 a);
|
||||
void DrawRect(int x, int y, int w, int h, u8 line_w, u8 b, u8 g, u8 r, u8 a);
|
||||
void DrawRectFilled(int x, int y, int w, int h, u8 b, u8 g, u8 r, u8 a);
|
||||
void DrawBitmap(int x, int y, BMP map);
|
||||
void UsePreMap(BMP map);
|
||||
void UsePrePrintMap(BitmapPrinter printmap);
|
||||
BMP GetBitmap() { return bitmap; }
|
||||
|
@ -4,102 +4,14 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <physfs.h>
|
||||
|
||||
#define RD7_FSYS_GETINFO(path) \
|
||||
({ \
|
||||
RenderD7::FileSystem::Info inf; \
|
||||
RenderD7::FileSystem::GetInfo(path, inf); \
|
||||
inf; \
|
||||
})
|
||||
|
||||
namespace RenderD7 {
|
||||
namespace FileSystem {
|
||||
static constexpr auto MAX_STAMP = 0x20000000000000LL;
|
||||
|
||||
enum FileMode { FileMode_Open, FileMode_Read, FileMode_Write, FileMode_Closed };
|
||||
|
||||
enum FileType {
|
||||
FileType_File,
|
||||
FileType_Directory,
|
||||
FileType_SymLink,
|
||||
FileType_Other
|
||||
struct Entry {
|
||||
std::string path;
|
||||
std::string name;
|
||||
bool dir = false;
|
||||
};
|
||||
|
||||
struct File {
|
||||
PHYSFS_file *handle;
|
||||
FileMode mode;
|
||||
|
||||
File() {
|
||||
this->handle = nullptr;
|
||||
this->mode = FileMode_Closed;
|
||||
}
|
||||
|
||||
int64_t GetSize() {
|
||||
if (this->handle == nullptr)
|
||||
return 0;
|
||||
|
||||
return (int64_t)PHYSFS_fileLength(this->handle);
|
||||
}
|
||||
};
|
||||
|
||||
struct Info {
|
||||
int64_t size;
|
||||
int64_t mod_time;
|
||||
FileType type;
|
||||
};
|
||||
|
||||
int Init(const char *argv);
|
||||
|
||||
void Initialize();
|
||||
|
||||
/*
|
||||
** mounts a specific directory for physfs to search in
|
||||
** this is typically a main directory
|
||||
*/
|
||||
bool SetSource(const char *source);
|
||||
|
||||
/*
|
||||
** mounts a specific directory as a "save" directory
|
||||
** if appended, it will be added to the search path
|
||||
*/
|
||||
bool SetIdentity(const char *name, bool append);
|
||||
|
||||
static std::string savePath;
|
||||
|
||||
/* gets the last physfs error */
|
||||
const char *GetPhysfsError();
|
||||
|
||||
/* strips any duplicate slashes */
|
||||
std::string Normalize(const std::string &input);
|
||||
|
||||
/* gets the user directory from physfs */
|
||||
std::string GetUserDirectory();
|
||||
|
||||
/* gets the save directory */
|
||||
std::string GetSaveDirectory();
|
||||
|
||||
/* sets up the writing directory for physfs */
|
||||
bool SetupWriteDirectory();
|
||||
|
||||
/* gets a list of files in a directory */
|
||||
void GetDirectoryItems(const char *directory, std::vector<std::string> &items);
|
||||
|
||||
/* gets the size, mod_time, and type of a file */
|
||||
bool GetInfo(const char *filename, Info &info);
|
||||
|
||||
/* creates a new directory */
|
||||
bool CreateDirectory(const char *name);
|
||||
|
||||
bool CloseFile(File &file);
|
||||
|
||||
/* creates a new file */
|
||||
bool OpenFile(File &file, const char *name, FileMode mode);
|
||||
|
||||
/* writes to a file */
|
||||
bool WriteFile(File &file, const void *data, int64_t size);
|
||||
|
||||
/* reads a file's content */
|
||||
int64_t ReadFile(File &file, void *destination, int64_t size);
|
||||
std::vector<RenderD7::FileSystem::Entry> GetDirContent(std::string path);
|
||||
} // namespace FileSystem
|
||||
} // namespace RenderD7
|
@ -27,6 +27,7 @@ public:
|
||||
/// \param buffer the frame buffer
|
||||
void LoadPFromBuffer(const std::vector<u8> &buffer);
|
||||
void LoadFromBitmap(BMP bitmap);
|
||||
void LoadJpg(std::string path);
|
||||
/// Draw the Image directly
|
||||
/// \param x The x position
|
||||
/// \param y the y position
|
||||
|
27
include/renderd7/ResultDecoder.hpp
Normal file
27
include/renderd7/ResultDecoder.hpp
Normal file
@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <3ds.h>
|
||||
|
||||
namespace RenderD7
|
||||
{
|
||||
class ResultDecoder
|
||||
{
|
||||
public:
|
||||
ResultDecoder(){}
|
||||
~ResultDecoder(){}
|
||||
void Load(Result rescode);
|
||||
void Load(std::string rescode);
|
||||
std::string GetCode();
|
||||
std::string GetLevel();
|
||||
int GetLevelInt();
|
||||
std::string GetModule();
|
||||
int GetModuleInt();
|
||||
std::string GetDescription();
|
||||
int GetDescriptionInt();
|
||||
std::string GetSummary();
|
||||
int GetSummaryInt();
|
||||
|
||||
private:
|
||||
Result m_rescode;
|
||||
};
|
||||
}
|
@ -1,16 +1,16 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
namespace RenderD7
|
||||
{
|
||||
class StealConsole
|
||||
{
|
||||
public:
|
||||
StealConsole();
|
||||
~StealConsole();
|
||||
std::string GetStdout();
|
||||
private:
|
||||
std::stringstream stolen_stdout;
|
||||
};
|
||||
}
|
||||
|
||||
namespace RenderD7 {
|
||||
class StealConsole {
|
||||
public:
|
||||
StealConsole();
|
||||
~StealConsole();
|
||||
std::string GetStdout();
|
||||
|
||||
private:
|
||||
std::stringstream stolen_stdout;
|
||||
};
|
||||
} // namespace RenderD7
|
8
include/renderd7/Tasks.hpp
Normal file
8
include/renderd7/Tasks.hpp
Normal file
@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
#include <3ds.h>
|
||||
#include <vector>
|
||||
|
||||
namespace Tasks {
|
||||
void create(ThreadFunc entrypoint);
|
||||
void destroy(void);
|
||||
} // namespace Tasks
|
@ -5,6 +5,7 @@
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
#pragma pack(push, 1)
|
||||
|
||||
@ -48,7 +49,8 @@ struct BMPColorHeader {
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
struct BMP {
|
||||
class BMP {
|
||||
public:
|
||||
BMPFileHeader file_header;
|
||||
BMPInfoHeader bmp_info_header;
|
||||
BMPColorHeader bmp_color_header;
|
||||
@ -62,8 +64,8 @@ struct BMP {
|
||||
inp.read((char *)&file_header, sizeof(file_header));
|
||||
if (file_header.file_type != 0x4D42) {
|
||||
|
||||
return 50; // throw std::runtime_error("Error! Unrecognized file
|
||||
// format.");
|
||||
return 50;
|
||||
// throw std::runtime_error("Error! Unrecognized file format.");
|
||||
}
|
||||
inp.read((char *)&bmp_info_header, sizeof(bmp_info_header));
|
||||
|
||||
@ -78,9 +80,8 @@ struct BMP {
|
||||
check_color_header(bmp_color_header);
|
||||
} else {
|
||||
// std::cerr << "Error! The file \"" << fname << "\" does not seem to
|
||||
// contain bit mask information\n";
|
||||
return 51; // throw std::runtime_error("Error! Unrecognized file
|
||||
// format.");
|
||||
// contain bit mask information\n"; return 51;//throw
|
||||
// std::runtime_error("Error! Unrecognized file format.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -137,12 +138,14 @@ struct BMP {
|
||||
std::stringstream inp;
|
||||
std::copy(buffer.begin(), buffer.end(),
|
||||
std::ostream_iterator<unsigned char>(inp, "\n"));
|
||||
std::cout << buffer.size() << std::endl;
|
||||
if (inp) {
|
||||
inp.read((char *)&file_header, sizeof(file_header));
|
||||
if (file_header.file_type != 0x4D42) {
|
||||
|
||||
return 50; // throw std::runtime_error("Error! Unrecognized file
|
||||
// format.");
|
||||
return 50;
|
||||
// throw std::runtime_error("Error! Unrecognized file format. Header " +
|
||||
// std::to_string(file_header.file_type));
|
||||
}
|
||||
inp.read((char *)&bmp_info_header, sizeof(bmp_info_header));
|
||||
|
||||
@ -158,8 +161,8 @@ struct BMP {
|
||||
} else {
|
||||
// std::cerr << "Error! The file \"" << fname << "\" does not seem to
|
||||
// contain bit mask information\n";
|
||||
return 51; // throw std::runtime_error("Error! Unrecognized file
|
||||
// format.");
|
||||
return 51;
|
||||
// throw std::runtime_error("Error! Unrecognized file format. Size");
|
||||
}
|
||||
}
|
||||
|
||||
@ -181,8 +184,10 @@ struct BMP {
|
||||
file_header.file_size = file_header.offset_data;
|
||||
|
||||
if (bmp_info_header.height < 0) {
|
||||
return 52; // throw std::runtime_error("The program can treat only BMP
|
||||
// images with the origin in the bottom left corner!");
|
||||
return 52;
|
||||
// throw std::runtime_error("The program can treat only BMP images with
|
||||
// "
|
||||
// "the origin in the bottom left corner!");
|
||||
}
|
||||
|
||||
data.resize(bmp_info_header.width * bmp_info_header.height *
|
||||
@ -206,8 +211,8 @@ struct BMP {
|
||||
bmp_info_header.height * static_cast<uint32_t>(padding_row.size());
|
||||
}
|
||||
} else {
|
||||
return 53; // throw std::runtime_error("Unable to open the input image
|
||||
// file "+std::string(fname));
|
||||
return 53;
|
||||
// throw std::runtime_error("Unable to open the input image buffer");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -525,108 +530,14 @@ struct BMP {
|
||||
}
|
||||
}
|
||||
|
||||
int OrganizeAverageRed() {
|
||||
int ColorRed[bmp_info_header.height][bmp_info_header.width];
|
||||
int ColorGreen[bmp_info_header.height][bmp_info_header.width];
|
||||
;
|
||||
int ColorBlue[bmp_info_header.height][bmp_info_header.width];
|
||||
float pixels = bmp_info_header.height * bmp_info_header.width;
|
||||
float intensity = 0;
|
||||
float sum = 0;
|
||||
uint32_t channels = bmp_info_header.bit_count / 8;
|
||||
cout << "The Width of the image is " << bmp_info_header.width << endl;
|
||||
cout << "The height of the image is " << bmp_info_header.height << endl;
|
||||
for (int y = 0; y < bmp_info_header.height; ++y) {
|
||||
for (int x = 0; x < bmp_info_header.width; ++x) {
|
||||
// cout << channels*(y*bmp_info_header.width+x) << endl;
|
||||
// Read red
|
||||
ColorBlue[y][x] = data[channels * (y * bmp_info_header.width + x) + 0];
|
||||
ColorGreen[y][x] = data[channels * (y * bmp_info_header.width + x) + 1];
|
||||
ColorRed[y][x] = data[channels * (y * bmp_info_header.width + x) + 2];
|
||||
}
|
||||
}
|
||||
for (int y = 0; y < bmp_info_header.height; y++) {
|
||||
for (int x = 0; x < bmp_info_header.width; x++) {
|
||||
sum = ColorRed[y][x] + sum -
|
||||
((ColorBlue[y][x]) / 2 + (ColorGreen[y][x]) / 2);
|
||||
}
|
||||
}
|
||||
|
||||
intensity = sum / pixels;
|
||||
cout << intensity << endl;
|
||||
return intensity;
|
||||
}
|
||||
|
||||
int OrganizeAverageGreen() {
|
||||
int ColorRed[bmp_info_header.height][bmp_info_header.width];
|
||||
int ColorGreen[bmp_info_header.height][bmp_info_header.width];
|
||||
;
|
||||
int ColorBlue[bmp_info_header.height][bmp_info_header.width];
|
||||
float pixels = bmp_info_header.height * bmp_info_header.width;
|
||||
float intensity = 0;
|
||||
float sum = 0;
|
||||
uint32_t channels = bmp_info_header.bit_count / 8;
|
||||
cout << "The Width of the image is " << bmp_info_header.width << endl;
|
||||
cout << "The height of the image is " << bmp_info_header.height << endl;
|
||||
for (int y = 0; y < bmp_info_header.height; ++y) {
|
||||
for (int x = 0; x < bmp_info_header.width; ++x) {
|
||||
// cout << channels*(y*bmp_info_header.width+x) << endl;
|
||||
// Read Green
|
||||
ColorBlue[y][x] = data[channels * (y * bmp_info_header.width + x) + 0];
|
||||
ColorGreen[y][x] = data[channels * (y * bmp_info_header.width + x) + 1];
|
||||
ColorRed[y][x] = data[channels * (y * bmp_info_header.width + x) + 2];
|
||||
}
|
||||
}
|
||||
for (int y = 0; y < bmp_info_header.height; y++) {
|
||||
for (int x = 0; x < bmp_info_header.width; x++) {
|
||||
sum = ColorGreen[y][x] + sum -
|
||||
((ColorBlue[y][x]) / 2 + (ColorRed[y][x]) / 2);
|
||||
}
|
||||
}
|
||||
|
||||
intensity = sum / pixels;
|
||||
cout << intensity << endl;
|
||||
return intensity;
|
||||
}
|
||||
|
||||
int OrganizeAverageBlue() {
|
||||
int ColorRed[bmp_info_header.height][bmp_info_header.width];
|
||||
int ColorGreen[bmp_info_header.height][bmp_info_header.width];
|
||||
;
|
||||
int ColorBlue[bmp_info_header.height][bmp_info_header.width];
|
||||
float pixels = bmp_info_header.height * bmp_info_header.width;
|
||||
float intensity = 0;
|
||||
float sum = 0;
|
||||
uint32_t channels = bmp_info_header.bit_count / 8;
|
||||
cout << "The Width of the image is " << bmp_info_header.width << endl;
|
||||
cout << "The height of the image is " << bmp_info_header.height << endl;
|
||||
for (int y = 0; y < bmp_info_header.height; ++y) {
|
||||
for (int x = 0; x < bmp_info_header.width; ++x) {
|
||||
// cout << channels*(y*bmp_info_header.width+x) << endl;
|
||||
// Read Blue
|
||||
ColorBlue[y][x] = data[channels * (y * bmp_info_header.width + x) + 0];
|
||||
ColorGreen[y][x] = data[channels * (y * bmp_info_header.width + x) + 1];
|
||||
ColorRed[y][x] = data[channels * (y * bmp_info_header.width + x) + 2];
|
||||
}
|
||||
}
|
||||
for (int y = 0; y < bmp_info_header.height; y++) {
|
||||
for (int x = 0; x < bmp_info_header.width; x++) {
|
||||
sum = ColorBlue[y][x] + sum -
|
||||
((ColorGreen[y][x]) / 2 + (ColorRed[y][x]) / 2);
|
||||
}
|
||||
}
|
||||
|
||||
intensity = sum / pixels;
|
||||
cout << intensity << endl;
|
||||
return intensity;
|
||||
}
|
||||
|
||||
unsigned set_pixel(uint32_t x0, uint32_t y0, uint8_t B, uint8_t G, uint8_t R,
|
||||
uint8_t A) {
|
||||
if (x0 >= (uint32_t)bmp_info_header.width ||
|
||||
y0 >= (uint32_t)bmp_info_header.height || x0 < 0 || y0 < 0) {
|
||||
return 59; // throw std::runtime_error("The point is outside the image
|
||||
// boundaries!");
|
||||
return 59;
|
||||
// std::string errr = "The point is outside the image boundaries! -> " +
|
||||
// std::to_string(x0) + "," + std::to_string(y0); throw
|
||||
// std::runtime_error(errr);
|
||||
}
|
||||
uint32_t channels = bmp_info_header.bit_count / 8;
|
||||
data[channels * (y0 * bmp_info_header.width + x0) + 0] = B;
|
||||
@ -643,8 +554,9 @@ struct BMP {
|
||||
uint32_t y1 = this->bmp_info_header.height - y0;
|
||||
if (x0 >= (uint32_t)bmp_info_header.width ||
|
||||
y1 <= (uint32_t)bmp_info_header.width || x0 < 0 || y0 > 0) {
|
||||
return; // throw std::runtime_error("The point is outside the image
|
||||
// boundaries!");
|
||||
return;
|
||||
// throw std::runtime_error("The point is outside the image boundaries! ->
|
||||
// " + std::to_string(x0) + "," + std::to_string(y1));
|
||||
}
|
||||
|
||||
uint32_t channels = bmp_info_header.bit_count / 8;
|
||||
@ -656,6 +568,52 @@ struct BMP {
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t get_pixel(uint32_t x0, uint32_t y0) {
|
||||
if (x0 >= (uint32_t)bmp_info_header.width ||
|
||||
y0 >= (uint32_t)bmp_info_header.height || x0 < 0 || y0 < 0) {
|
||||
return 59; // throw std::runtime_error("The point is outside the image
|
||||
// boundaries!");
|
||||
}
|
||||
uint32_t channels = bmp_info_header.bit_count / 8;
|
||||
uint32_t outcol = 0;
|
||||
uint8_t red = 0;
|
||||
uint8_t green = 0;
|
||||
uint8_t blue = 0;
|
||||
uint8_t alpha = 255;
|
||||
blue = data[channels * (y0 * bmp_info_header.width + x0) + 0];
|
||||
green = data[channels * (y0 * bmp_info_header.width + x0) + 1];
|
||||
red = data[channels * (y0 * bmp_info_header.width + x0) + 2];
|
||||
if (channels == 4) {
|
||||
alpha = data[channels * (y0 * bmp_info_header.width + x0) + 3];
|
||||
}
|
||||
outcol = ((red << 24) | (green << 16) | (blue << 8) | alpha);
|
||||
return outcol;
|
||||
}
|
||||
|
||||
uint32_t get_pixel_df(uint32_t x0, uint32_t y0) {
|
||||
uint32_t y1 = this->bmp_info_header.height - y0;
|
||||
if (x0 >= (uint32_t)bmp_info_header.width ||
|
||||
y1 <= (uint32_t)bmp_info_header.width || x0 < 0 || y0 > 0) {
|
||||
return 0; // throw std::runtime_error("The point is outside the image
|
||||
// boundaries!");
|
||||
}
|
||||
|
||||
uint32_t channels = bmp_info_header.bit_count / 8;
|
||||
uint32_t outcol = 0;
|
||||
uint8_t red = 0;
|
||||
uint8_t green = 0;
|
||||
uint8_t blue = 0;
|
||||
uint8_t alpha = 255;
|
||||
blue = data[channels * (y0 * bmp_info_header.width + x0) + 0];
|
||||
green = data[channels * (y0 * bmp_info_header.width + x0) + 1];
|
||||
red = data[channels * (y0 * bmp_info_header.width + x0) + 2];
|
||||
if (channels == 4) {
|
||||
alpha = data[channels * (y0 * bmp_info_header.width + x0) + 3];
|
||||
}
|
||||
outcol = ((red << 24) | (green << 16) | (blue << 8) | alpha);
|
||||
return outcol;
|
||||
}
|
||||
|
||||
unsigned draw_rectangle(uint32_t x0, uint32_t y0, uint32_t w, uint32_t h,
|
||||
uint8_t B, uint8_t G, uint8_t R, uint8_t A,
|
||||
uint8_t line_w) {
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <renderd7/Draw.hpp>
|
||||
#include <renderd7/Image.hpp>
|
||||
#include <renderd7/Ovl.hpp>
|
||||
#include <renderd7/ResultDecoder.hpp>
|
||||
#include <renderd7/Screen.hpp>
|
||||
#include <renderd7/Sheet.hpp>
|
||||
#include <renderd7/Sprite.hpp>
|
||||
@ -46,9 +47,13 @@ extern "C" {
|
||||
#include <renderd7/external/fs.h>
|
||||
}
|
||||
|
||||
#define RENDERD7VSTRING "0.8.1"
|
||||
#define RENDERD7VSTRING "0.8.3"
|
||||
#define CHANGELOG \
|
||||
"0.8.1: Add abillity to Get Stdout as string to render it to the " \
|
||||
"0.8.4: A lot of Fixes and new Features for BitmapPrinter! 0.8.3: Addet " \
|
||||
"Overlaycount to Info and Addet ResultDecoder for " \
|
||||
"errors.0.8.2: Fix a lot of Stuff and add c++17 based filesystem " \
|
||||
"class.\n0.8.1: " \
|
||||
"Add abillity to Get Stdout as string to render it to the " \
|
||||
"screen.\n0.8.0: Implement BitmapPrinter\n0.7.3: Implement Over Render " \
|
||||
"Overlay " \
|
||||
"Framework\n0.7.2: Implement MT to csv file saving. Add RGB2HEX. \n0.7.1: " \
|
||||
|
@ -463,3 +463,13 @@ bool RenderD7::BitmapPrinter::Decode(Decoder deccc) {
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
void RenderD7::BitmapPrinter::DrawBitmap(int x, int y, BMP map) {
|
||||
for (int i = 0; i < map.bmp_info_header.width; i++) {
|
||||
for (int j = 0; j < map.bmp_info_header.height; j++) {
|
||||
bitmap.set_pixel(
|
||||
x + i, (bitmap.bmp_info_header.height - 1) - (y + j),
|
||||
UNPACK_BGRA(map.get_pixel(i, (map.bmp_info_header.height - 1) - j)));
|
||||
}
|
||||
}
|
||||
}
|
@ -5,340 +5,16 @@
|
||||
#include <memory>
|
||||
#include <renderd7/Ovl.hpp>
|
||||
#include <renderd7/Toast.hpp>
|
||||
#include <renderd7/stringtool.hpp>
|
||||
|
||||
const char *RenderD7::FileSystem::GetPhysfsError() {
|
||||
return PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode());
|
||||
}
|
||||
#include <filesystem>
|
||||
|
||||
std::string RenderD7::FileSystem::Normalize(const std::string &input) {
|
||||
std::string out;
|
||||
bool seenSep = false, isSep = false;
|
||||
|
||||
for (size_t i = 0; i < input.size(); ++i) {
|
||||
isSep = (input[i] == '/');
|
||||
|
||||
if (!isSep || !seenSep)
|
||||
out += input[i];
|
||||
|
||||
seenSep = isSep;
|
||||
std::vector<RenderD7::FileSystem::Entry> RenderD7::FileSystem::GetDirContent(std::string path)
|
||||
{
|
||||
std::vector<RenderD7::FileSystem::Entry> res;
|
||||
for(const auto& entry : std::filesystem::directory_iterator(std::filesystem::path(path)))
|
||||
{
|
||||
res.push_back({entry.path().string(), GetFileName(entry.path().string()), entry.is_directory()});
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
void RenderD7::FileSystem::Initialize() { RenderD7::FileSystem::savePath = ""; }
|
||||
|
||||
int RenderD7::FileSystem::Init(const char *argv) {
|
||||
int res = PHYSFS_init(argv);
|
||||
if (res != 1) {
|
||||
RenderD7::AddOvl(std::make_unique<RenderD7::Toast>(
|
||||
"PHYSFS-Error", RenderD7::FileSystem::GetPhysfsError()));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool RenderD7::FileSystem::SetSource(const char *source) {
|
||||
if (!PHYSFS_isInit())
|
||||
RenderD7::AddOvl(std::make_unique<RenderD7::Toast>(
|
||||
"PHYSFS-Error", RenderD7::FileSystem::GetPhysfsError()));
|
||||
return false;
|
||||
|
||||
std::string searchPath = source;
|
||||
if (!PHYSFS_mount(searchPath.c_str(), NULL, 1))
|
||||
RenderD7::AddOvl(std::make_unique<RenderD7::Toast>(
|
||||
"PHYSFS-Error", RenderD7::FileSystem::GetPhysfsError()));
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RenderD7::FileSystem::SetIdentity(const char *name, bool append) {
|
||||
if (!PHYSFS_isInit())
|
||||
RenderD7::AddOvl(std::make_unique<RenderD7::Toast>(
|
||||
"PHYSFS-Error", RenderD7::FileSystem::GetPhysfsError()));
|
||||
return false;
|
||||
|
||||
std::string old = RenderD7::FileSystem::savePath;
|
||||
|
||||
RenderD7::FileSystem::savePath = RenderD7::FileSystem::Normalize(
|
||||
RenderD7::FileSystem::GetUserDirectory() + "/save/" + name);
|
||||
printf("Save Path set to %s\n", savePath.c_str());
|
||||
|
||||
if (!old.empty())
|
||||
PHYSFS_unmount(old.c_str());
|
||||
|
||||
int success = PHYSFS_mount(savePath.c_str(), NULL, append);
|
||||
printf("Save Path mounted %d\n", success);
|
||||
|
||||
PHYSFS_setWriteDir(nullptr);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string RenderD7::FileSystem::GetSaveDirectory() {
|
||||
return RenderD7::FileSystem::Normalize(
|
||||
RenderD7::FileSystem::GetUserDirectory() + "/save");
|
||||
}
|
||||
|
||||
bool RenderD7::FileSystem::SetupWriteDirectory() {
|
||||
if (!PHYSFS_isInit())
|
||||
RenderD7::AddOvl(std::make_unique<RenderD7::Toast>(
|
||||
"PHYSFS-Error", RenderD7::FileSystem::GetPhysfsError()));
|
||||
return false;
|
||||
|
||||
if (RenderD7::FileSystem::savePath.empty())
|
||||
RenderD7::AddOvl(
|
||||
std::make_unique<RenderD7::Toast>("PHYSFS-Error", "Path is Empty"));
|
||||
return false;
|
||||
|
||||
std::string tmpWritePath = RenderD7::FileSystem::savePath;
|
||||
std::string tmpDirectoryPath = RenderD7::FileSystem::savePath;
|
||||
|
||||
if (RenderD7::FileSystem::savePath.find(
|
||||
RenderD7::FileSystem::GetUserDirectory()) == 0) {
|
||||
tmpWritePath = RenderD7::FileSystem::GetUserDirectory();
|
||||
tmpDirectoryPath =
|
||||
savePath.substr(RenderD7::FileSystem::GetUserDirectory().length());
|
||||
|
||||
/* strip leading '/' characters from the path we want to create */
|
||||
size_t startPosition = tmpDirectoryPath.find_first_not_of('/');
|
||||
|
||||
if (startPosition != std::string::npos)
|
||||
tmpDirectoryPath = tmpDirectoryPath.substr(startPosition);
|
||||
}
|
||||
|
||||
if (!PHYSFS_setWriteDir(tmpWritePath.c_str())) {
|
||||
printf("Failed to set write dir to %s\n", tmpWritePath.c_str());
|
||||
RenderD7::AddOvl(std::make_unique<RenderD7::Toast>(
|
||||
"PHYSFS-Error",
|
||||
RenderD7::FormatString("Failed to set write dir to %s\n",
|
||||
tmpWritePath.c_str())));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!RenderD7::FileSystem::CreateDirectory(tmpDirectoryPath.c_str())) {
|
||||
printf("Failed to create dir %s\n", tmpDirectoryPath.c_str());
|
||||
/* clear the write directory in case of error */
|
||||
RenderD7::AddOvl(std::make_unique<RenderD7::Toast>(
|
||||
"PHYSFS-Error", RenderD7::FormatString("Failed to create dir %s\n",
|
||||
tmpDirectoryPath.c_str())));
|
||||
PHYSFS_setWriteDir(nullptr);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!PHYSFS_setWriteDir(savePath.c_str())) {
|
||||
printf("Failed to set write dir to %s\n", savePath.c_str());
|
||||
RenderD7::AddOvl(std::make_unique<RenderD7::Toast>(
|
||||
"PHYSFS-Error",
|
||||
RenderD7::FormatString("Failed to set write dir to %s\n",
|
||||
savePath.c_str())));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!PHYSFS_mount(savePath.c_str(), nullptr, 0)) {
|
||||
printf("Failed to mount write dir (%s)\n",
|
||||
RenderD7::FileSystem::GetPhysfsError());
|
||||
RenderD7::AddOvl(std::make_unique<RenderD7::Toast>(
|
||||
"PHYSFS-Error",
|
||||
RenderD7::FormatString("Failed to mount write dir (%s)\n",
|
||||
RenderD7::FileSystem::GetPhysfsError())));
|
||||
/* clear the write directory in case of error */
|
||||
PHYSFS_setWriteDir(nullptr);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string RenderD7::FileSystem::GetUserDirectory() {
|
||||
return RenderD7::FileSystem::Normalize(
|
||||
PHYSFS_getPrefDir("npi-d7", "renderd7"));
|
||||
}
|
||||
|
||||
bool RenderD7::FileSystem::GetInfo(const char *filename,
|
||||
RenderD7::FileSystem::Info &info) {
|
||||
if (!PHYSFS_isInit())
|
||||
RenderD7::AddOvl(std::make_unique<RenderD7::Toast>(
|
||||
"PHYSFS-Error", RenderD7::FileSystem::GetPhysfsError()));
|
||||
return false;
|
||||
|
||||
PHYSFS_Stat stat = {};
|
||||
|
||||
if (!PHYSFS_stat(filename, &stat))
|
||||
RenderD7::AddOvl(std::make_unique<RenderD7::Toast>(
|
||||
"PHYSFS-Error", RenderD7::FileSystem::GetPhysfsError()));
|
||||
return false;
|
||||
|
||||
info.mod_time =
|
||||
std::min<int64_t>(stat.modtime, RenderD7::FileSystem::MAX_STAMP);
|
||||
info.size = std::min<int64_t>(stat.filesize, RenderD7::FileSystem::MAX_STAMP);
|
||||
|
||||
if (stat.filetype == PHYSFS_FILETYPE_REGULAR)
|
||||
info.type = RenderD7::FileSystem::FileType_File;
|
||||
else if (stat.filetype == PHYSFS_FILETYPE_DIRECTORY)
|
||||
info.type = RenderD7::FileSystem::FileType_Directory;
|
||||
else if (stat.filetype == PHYSFS_FILETYPE_SYMLINK)
|
||||
info.type = RenderD7::FileSystem::FileType_SymLink;
|
||||
else
|
||||
info.type = RenderD7::FileSystem::FileType_Other;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void RenderD7::FileSystem::GetDirectoryItems(const char *path,
|
||||
std::vector<std::string> &items) {
|
||||
if (!PHYSFS_isInit())
|
||||
RenderD7::AddOvl(std::make_unique<RenderD7::Toast>(
|
||||
"PHYSFS-Error", RenderD7::FileSystem::GetPhysfsError()));
|
||||
return;
|
||||
|
||||
char **results = PHYSFS_enumerateFiles(path);
|
||||
|
||||
if (results == nullptr)
|
||||
RenderD7::AddOvl(std::make_unique<RenderD7::Toast>(
|
||||
"PHYSFS-Error", RenderD7::FileSystem::GetPhysfsError()));
|
||||
return;
|
||||
|
||||
for (char **item = results; *item != 0; item++)
|
||||
items.push_back(*item);
|
||||
|
||||
PHYSFS_freeList(results);
|
||||
}
|
||||
|
||||
bool RenderD7::FileSystem::OpenFile(File &file, const char *name,
|
||||
FileMode mode) {
|
||||
if (mode == FileMode_Closed)
|
||||
RenderD7::AddOvl(std::make_unique<RenderD7::Toast>(
|
||||
"PHYSFS-Error", RenderD7::FileSystem::GetPhysfsError()));
|
||||
return false;
|
||||
|
||||
if (!PHYSFS_isInit())
|
||||
RenderD7::AddOvl(std::make_unique<RenderD7::Toast>(
|
||||
"PHYSFS-Error", RenderD7::FileSystem::GetPhysfsError()));
|
||||
return false;
|
||||
|
||||
if (file.handle)
|
||||
RenderD7::FileSystem::CloseFile(file);
|
||||
|
||||
if (mode == FileMode_Read && !PHYSFS_exists(name)) {
|
||||
printf("Could not open file %s, does not exist.\n", name);
|
||||
RenderD7::AddOvl(std::make_unique<RenderD7::Toast>(
|
||||
"PHYSFS-Error",
|
||||
RenderD7::FormatString("Could not open file %s, does not exist.\n",
|
||||
name)));
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((mode == FileMode_Write) &&
|
||||
(PHYSFS_getWriteDir() == nullptr &&
|
||||
RenderD7::FileSystem::SetupWriteDirectory())) {
|
||||
printf("Could not set write directory.\n");
|
||||
RenderD7::AddOvl(std::make_unique<RenderD7::Toast>(
|
||||
"PHYSFS-Error",
|
||||
RenderD7::FormatString("Could not set write directory.\n")));
|
||||
return false;
|
||||
}
|
||||
|
||||
PHYSFS_getLastErrorCode();
|
||||
|
||||
switch (mode) {
|
||||
case FileMode_Read:
|
||||
file.handle = PHYSFS_openRead(name);
|
||||
break;
|
||||
case FileMode_Write:
|
||||
file.handle = PHYSFS_openWrite(name);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!file.handle) {
|
||||
const char *error = RenderD7::FileSystem::GetPhysfsError();
|
||||
|
||||
if (error == nullptr)
|
||||
error = "unknown error";
|
||||
|
||||
printf("Could not open file %s (%s)\n", name, error);
|
||||
RenderD7::AddOvl(std::make_unique<RenderD7::Toast>(
|
||||
"PHYSFS-Error",
|
||||
RenderD7::FormatString("Could not open file %s (%s)\n", name, error)));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
file.mode = mode;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RenderD7::FileSystem::CloseFile(File &file) {
|
||||
if (file.handle == nullptr || !PHYSFS_close(file.handle))
|
||||
return false;
|
||||
|
||||
file.handle = nullptr;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RenderD7::FileSystem::CreateDirectory(const char *name) {
|
||||
if (!PHYSFS_isInit())
|
||||
RenderD7::AddOvl(std::make_unique<RenderD7::Toast>(
|
||||
"PHYSFS-Error", RenderD7::FileSystem::GetPhysfsError()));
|
||||
return false;
|
||||
|
||||
if (PHYSFS_getWriteDir() == nullptr &&
|
||||
!RenderD7::FileSystem::SetupWriteDirectory())
|
||||
RenderD7::AddOvl(std::make_unique<RenderD7::Toast>(
|
||||
"PHYSFS-Error", RenderD7::FileSystem::GetPhysfsError()));
|
||||
return false;
|
||||
|
||||
if (!PHYSFS_mkdir(name))
|
||||
RenderD7::AddOvl(std::make_unique<RenderD7::Toast>(
|
||||
"PHYSFS-Error", RenderD7::FileSystem::GetPhysfsError()));
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int64_t RenderD7::FileSystem::ReadFile(File &file, void *destination,
|
||||
int64_t size) {
|
||||
if (!file.handle || file.mode != FileMode_Read) {
|
||||
printf("File is not opened for reading.\n");
|
||||
RenderD7::AddOvl(std::make_unique<RenderD7::Toast>(
|
||||
"PHYSFS-Error", "File is not opened for reading.\n"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (size > file.GetSize())
|
||||
size = file.GetSize();
|
||||
else if (size < 0) {
|
||||
printf("Invalid read size %lld\n", size);
|
||||
RenderD7::AddOvl(std::make_unique<RenderD7::Toast>(
|
||||
"PHYSFS-Error",
|
||||
RenderD7::FormatString("Invalid read size %lld\n", size)));
|
||||
return 0;
|
||||
}
|
||||
|
||||
return PHYSFS_readBytes(file.handle, destination, (PHYSFS_uint64)size);
|
||||
}
|
||||
|
||||
bool RenderD7::FileSystem::WriteFile(File &file, const void *data,
|
||||
int64_t size) {
|
||||
if (!file.handle || file.mode != FileMode_Write) {
|
||||
printf("File is not opened for writing.\n");
|
||||
RenderD7::AddOvl(std::make_unique<RenderD7::Toast>(
|
||||
"PHYSFS-Error", "File is not opened for writing.\n"));
|
||||
return false;
|
||||
}
|
||||
|
||||
int64_t written = PHYSFS_writeBytes(file.handle, data, (PHYSFS_uint64)size);
|
||||
|
||||
if (written != size) {
|
||||
RenderD7::AddOvl(std::make_unique<RenderD7::Toast>(
|
||||
"PHYSFS-Error", RenderD7::FileSystem::GetPhysfsError()));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
#include <renderd7/Image.hpp>
|
||||
#include <renderd7/Ovl.hpp>
|
||||
#include <renderd7/Toast.hpp>
|
||||
|
||||
#include <renderd7/external/stb_image.h>
|
||||
extern bool usedbgmsg;
|
||||
|
||||
static u32 GetNextPowerOf2(u32 v) {
|
||||
@ -75,6 +77,78 @@ static bool C3DTexToC2DImage(C2D_Image *texture, u32 width, u32 height,
|
||||
return false;
|
||||
}
|
||||
|
||||
static void OLD_C3DTexToC2DImage(C3D_Tex *tex, Tex3DS_SubTexture *subtex, u8 *buf, u32 size, u32 width, u32 height, GPU_TEXCOLOR format) {
|
||||
// RGBA -> ABGR
|
||||
for (u32 row = 0; row < width; row++) {
|
||||
for (u32 col = 0; col < height; col++) {
|
||||
u32 z = (row + col * width) * 4;
|
||||
|
||||
u8 r = *(u8 *)(buf + z);
|
||||
u8 g = *(u8 *)(buf + z + 1);
|
||||
u8 b = *(u8 *)(buf + z + 2);
|
||||
u8 a = *(u8 *)(buf + z + 3);
|
||||
|
||||
*(buf + z) = a;
|
||||
*(buf + z + 1) = b;
|
||||
*(buf + z + 2) = g;
|
||||
*(buf + z + 3) = r;
|
||||
}
|
||||
}
|
||||
|
||||
u32 w_pow2 = GetNextPowerOf2(width);
|
||||
u32 h_pow2 = GetNextPowerOf2(height);
|
||||
|
||||
subtex->width = (u16)width;
|
||||
subtex->height = (u16)height;
|
||||
subtex->left = 0.0f;
|
||||
subtex->top = 1.0f;
|
||||
subtex->right = (width / (float)w_pow2);
|
||||
subtex->bottom = 1.0 - (height / (float)h_pow2);
|
||||
|
||||
C3D_TexInit(tex, (u16)w_pow2, (u16)h_pow2, format);
|
||||
C3D_TexSetFilter(tex, GPU_NEAREST, GPU_NEAREST);
|
||||
|
||||
u32 pixel_size = (size / width / height);
|
||||
|
||||
memset(tex->data, 0, tex->size);
|
||||
|
||||
for (u32 x = 0; x < width; x++) {
|
||||
for (u32 y = 0; y < height; y++) {
|
||||
u32 dst_pos = ((((y >> 3) * (w_pow2 >> 3) + (x >> 3)) << 6) + ((x & 1) | ((y & 1) << 1) | ((x & 2) << 1) | ((y & 2) << 2) | ((x & 4) << 2) | ((y & 4) << 3))) * pixel_size;
|
||||
u32 src_pos = (y * width + x) * pixel_size;
|
||||
|
||||
memcpy(&((u8*)tex->data)[dst_pos], &((u8*)buf)[src_pos], pixel_size);
|
||||
}
|
||||
}
|
||||
|
||||
C3D_TexFlush(tex);
|
||||
|
||||
tex->border = 0x00000000;
|
||||
C3D_TexSetWrap(tex, GPU_CLAMP_TO_BORDER, GPU_CLAMP_TO_BORDER);
|
||||
linearFree(buf);
|
||||
}
|
||||
|
||||
bool IMG_LoadImageFile(C2D_Image *texture, const char *path) {
|
||||
stbi_uc *image = NULL;
|
||||
int width = 0, height = 0;
|
||||
int nc;
|
||||
|
||||
image = stbi_load(path, &width, &height, &nc, 4);
|
||||
|
||||
if (width > 1024 || height > 1024) {
|
||||
stbi_image_free(image);
|
||||
return false;
|
||||
}
|
||||
|
||||
C3D_Tex *tex = new C3D_Tex;
|
||||
Tex3DS_SubTexture *subtex = new Tex3DS_SubTexture;
|
||||
OLD_C3DTexToC2DImage(tex, subtex, image, (u32)(width * height * 4), (u32)width, (u32)height, GPU_RGBA8);
|
||||
texture->tex = tex;
|
||||
texture->subtex = subtex;
|
||||
stbi_image_free(image);
|
||||
return true;
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
#include <renderd7/external/libnsbmp/libnsbmp.h>
|
||||
}
|
||||
@ -258,3 +332,17 @@ void RenderD7::Image::LoadFromBitmap(BMP bitmap) {
|
||||
"Bmp - Error", "Code: " + std::to_string(error)));
|
||||
}
|
||||
}
|
||||
|
||||
namespace RenderD7 {
|
||||
void Image::LoadJpg(std::string path) {
|
||||
if (usedbgmsg) {
|
||||
// RenderD7::Msg::Display("RenderD7", "Loading Png:" + path, Top);
|
||||
}
|
||||
if (loadet) {
|
||||
C3D_TexDelete(this->img.tex);
|
||||
loadet = false;
|
||||
}
|
||||
IMG_LoadImageFile(&this->img, path.c_str());
|
||||
loadet = true;
|
||||
}
|
||||
} // namespace RenderD7
|
422
source/ResultDecoder.cpp
Normal file
422
source/ResultDecoder.cpp
Normal file
@ -0,0 +1,422 @@
|
||||
#include <map>
|
||||
#include <renderd7/ResultDecoder.hpp>
|
||||
#include <sstream>
|
||||
|
||||
static std::map<int, std::string> modules = {
|
||||
{0, "common"},
|
||||
{1, "kernel"},
|
||||
{2, "util"},
|
||||
{3, "file server"},
|
||||
{4, "loader server"},
|
||||
{5, "tcb"},
|
||||
{6, "os"},
|
||||
{7, "dbg"},
|
||||
{8, "dmnt"},
|
||||
{9, "pdn"},
|
||||
{10, "gsp"},
|
||||
{11, "i2c"},
|
||||
{12, "gpio"},
|
||||
{13, "dd"},
|
||||
{14, "codec"},
|
||||
{15, "spi"},
|
||||
{16, "pxi"},
|
||||
{17, "fs"},
|
||||
{18, "di"},
|
||||
{19, "hid"},
|
||||
{20, "cam"},
|
||||
{21, "pi"},
|
||||
{22, "pm"},
|
||||
{23, "pm_low"},
|
||||
{24, "fsi"},
|
||||
{25, "srv"},
|
||||
{26, "ndm"},
|
||||
{27, "nwm"},
|
||||
{28, "soc"},
|
||||
{29, "ldr"},
|
||||
{30, "acc"},
|
||||
{31, "romfs"},
|
||||
{32, "am"},
|
||||
{33, "hio"},
|
||||
{34, "updater"},
|
||||
{35, "mic"},
|
||||
{36, "fnd"},
|
||||
{37, "mp"},
|
||||
{38, "mpwl"},
|
||||
{39, "ac"},
|
||||
{40, "http"},
|
||||
{41, "dsp"},
|
||||
{42, "snd"},
|
||||
{43, "dlp"},
|
||||
{44, "hio_low"},
|
||||
{45, "csnd"},
|
||||
{46, "ssl"},
|
||||
{47, "am_low"},
|
||||
{48, "nex"},
|
||||
{49, "friends"},
|
||||
{50, "rdt"},
|
||||
{51, "applet"},
|
||||
{52, "nim"},
|
||||
{53, "ptm"},
|
||||
{54, "midi"},
|
||||
{55, "mc"},
|
||||
{56, "swc"},
|
||||
{57, "fatfs"},
|
||||
{58, "ngc"},
|
||||
{59, "card"},
|
||||
{60, "cardnor"},
|
||||
{61, "sdmc"},
|
||||
{62, "boss"},
|
||||
{63, "dbm"},
|
||||
{64, "config"},
|
||||
{65, "ps"},
|
||||
{66, "cec"},
|
||||
{67, "ir"},
|
||||
{68, "uds"},
|
||||
{69, "pl"},
|
||||
{70, "cup"},
|
||||
{71, "gyroscope"},
|
||||
{72, "mcu"},
|
||||
{73, "ns"},
|
||||
{74, "news"},
|
||||
{75, "ro"},
|
||||
{76, "gd"},
|
||||
{77, "card spi"},
|
||||
{78, "ec"},
|
||||
{79, "web browser"},
|
||||
{80, "test"},
|
||||
{81, "enc"},
|
||||
{82, "pia"},
|
||||
{83, "act"},
|
||||
{84, "vctl"},
|
||||
{85, "olv"},
|
||||
{86, "neia"},
|
||||
{87, "npns"},
|
||||
{90, "avd"},
|
||||
{91, "l2b"},
|
||||
{92, "mvd"},
|
||||
{93, "nfc"},
|
||||
{94, "uart"},
|
||||
{95, "spm"},
|
||||
{96, "qtm"},
|
||||
{97, "nfp"},
|
||||
{254, "application"},
|
||||
};
|
||||
|
||||
static std::map<int, std::string> levels = {
|
||||
{0, "Success"}, {1, "Info"}, {25, "Status"},
|
||||
{26, "Temporary"}, {27, "Permanent"}, {28, "Usage"},
|
||||
{29, "Reinitialize"}, {30, "Reset"}, {31, "Fatal"},
|
||||
};
|
||||
|
||||
static std::map<int, std::string> summaries = {
|
||||
{0, "Success"},
|
||||
{1, "Nothing happened"},
|
||||
{2, "Would block"},
|
||||
{3, "Out of resource"},
|
||||
{4, "Not found"},
|
||||
{5, "Invalid state"},
|
||||
{6, "Not supported"},
|
||||
{7, "Invalid argument"},
|
||||
{8, "Wrong argument"},
|
||||
{9, "Canceled"},
|
||||
{10, "Status changed"},
|
||||
{11, "Internal"},
|
||||
{63, "Invalid result value"},
|
||||
};
|
||||
|
||||
static std::map<int, std::string> desccommon = {
|
||||
{0, "Success"},
|
||||
{1000, "Invalid selection"},
|
||||
{1001, "Too large"},
|
||||
{1002, "Not authorized"},
|
||||
{1003, "Already done"},
|
||||
{1004, "Invalid size"},
|
||||
{1005, "Invalid enum value"},
|
||||
{1006, "Invalid combination"},
|
||||
{1007, "No data"},
|
||||
{1008, "Busy"},
|
||||
{1009, "Misaligned address"},
|
||||
{1010, "Misaligned size"},
|
||||
{1011, "Out of memory"},
|
||||
{1012, "Not implemented"},
|
||||
{1013, "Invalid address"},
|
||||
{1014, "Invalid pointer"},
|
||||
{1015, "Invalid handle"},
|
||||
{1016, "Not initialized"},
|
||||
{1017, "Already initialized"},
|
||||
{1018, "Not found"},
|
||||
{1019, "Cancel requested"},
|
||||
{1020, "Already exists"},
|
||||
{1021, "Out of range"},
|
||||
{1022, "Timeout"},
|
||||
{1023, "Invalid result value"},
|
||||
};
|
||||
|
||||
static std::map<int, std::string> desckernel = {
|
||||
{2, "Invalid memory permissions."},
|
||||
};
|
||||
|
||||
static std::map<int, std::string> descos = {
|
||||
{10, "Not enough memory."},
|
||||
{26, "Session closed by remote."},
|
||||
{47, "Invalid command header."},
|
||||
};
|
||||
|
||||
//Need to Fix The Range based Values
|
||||
static std::map<int, std::string> descfs = {
|
||||
{101, "Archive not mounted or mount-point not found."},
|
||||
{120, "Title or object not found."},
|
||||
{141, "Gamecard not inserted."},
|
||||
{230, "Invalid open flags or permissions."},
|
||||
{391, "NCCH hash check failed."},
|
||||
{302, "RSA or AES-MAC verification failed."},
|
||||
{395, "RomFS or Savedata hash check failed."},
|
||||
{630, "Command not allowed, or missing permissions."},
|
||||
{702, "Invalid path."},
|
||||
{761, "Incorrect ExeFS read size."},
|
||||
{100, "[Media] not found."},
|
||||
{180, "Exists already."},
|
||||
{200, "Not enough space."},
|
||||
{220, "Invalidated archive."},
|
||||
{230, "Unacceptable or write protected."},
|
||||
{340, "0x01"},
|
||||
{360, "Bad format."},
|
||||
{390, "Verification failure."},
|
||||
{400, "0x01"},
|
||||
{600, "Out of resources."},
|
||||
{630, "Access denied."},
|
||||
{661, "0x01"},
|
||||
{700, "Invalid argument."},
|
||||
{730, "Not initialized."},
|
||||
{750, "Already initialized."},
|
||||
{760, "Not supported."},
|
||||
{780, "0x01"},
|
||||
};
|
||||
|
||||
static std::map<int, std::string> descsrv = {
|
||||
{5, "Invalid string length (service name length is zero or longer than 8 "
|
||||
"chars)."},
|
||||
{6, "Access to service denied (requested a service the application does "
|
||||
"not have access to)."},
|
||||
{7, "String size does not match contents (service name contains unexpected "
|
||||
"null byte)."},
|
||||
};
|
||||
|
||||
static std::map<int, std::string> descnwm = {
|
||||
{2, "This error usually indicates the wifi chipset in the console is dying "
|
||||
"or dead."},
|
||||
};
|
||||
|
||||
static std::map<int, std::string> descam = {
|
||||
{4, "Invalid ticket version."},
|
||||
{32, "Empty CIA."},
|
||||
{37, "Invalid NCCH."},
|
||||
{39, "Invalid title version."},
|
||||
{43, "Database doesn\"t exist, or it failed to open."},
|
||||
{44, "Trying to uninstall system-app."},
|
||||
{106, "Invalid signature/CIA. Usually happens when developer UNITINFO is "
|
||||
"enabled in Luma3DS."},
|
||||
{393, "Invalid database."},
|
||||
};
|
||||
|
||||
static std::map<int, std::string> deschttp = {
|
||||
{105, "Request timed out."},
|
||||
};
|
||||
|
||||
static std::map<int, std::string> descnim = {
|
||||
{1, "Invalid string IPC paramater (non null terminated at its indicated "
|
||||
"length)."},
|
||||
{12, "Invalid country code returned by CFG module reading config save "
|
||||
"0xB0000."},
|
||||
{13, "Zero string length console serial number or '000000000000000' "
|
||||
"returned by CFG's SecureInfoGetSerialNo."},
|
||||
{18, "General data reading error of NIM's .dat files from its system save, "
|
||||
"bad data or bad data lengths."},
|
||||
{22, "General invalid data or length of data returned from nintendo "
|
||||
"servers. (Only applicable for some operations)"},
|
||||
{25, "IntegrityVerificationSeed is waiting on servers to be synced into "
|
||||
"console. Can't processed with online services without sync being "
|
||||
"completed first over IPC request."},
|
||||
{26, "Unavailable/unaccessable IntegrityVerificationSeed on Nintendo "
|
||||
"servers. May happen if NIM is told to import "
|
||||
"IntegrityVerificationSeed from servers at any time other than after "
|
||||
"the successful System Transfer reboot."},
|
||||
{27, "Invalid country language code returned by CFG module reading config "
|
||||
"save 0xA0002."},
|
||||
{37, "Service is in Standby Mode. (eShop ban? General service is down? "
|
||||
"This caused by a server response flag on account information. "
|
||||
"Account is not referring to NNID.)"},
|
||||
{39, "HTTP Status non 200. (Only applicable for some operations)"},
|
||||
{40, "General XML read/write error while processing Auto Delivery XMLs."},
|
||||
{41, "General XML read/write error while processing Auto Delivery XMLs. "
|
||||
"(Stubbed virtual call was called)"},
|
||||
{58,
|
||||
"Invalid NPNS token returned by CFG module reading config save 0xF0006."},
|
||||
{67, "HTTP Status 404 while trying to download a game's seed."},
|
||||
{68, "HTTP Status 503 while trying to download a game's seed."},
|
||||
};
|
||||
|
||||
static std::map<int, std::string> descmvd = {
|
||||
{271, "Invalid configuration."},
|
||||
};
|
||||
|
||||
static std::map<int, std::string> descqtm = {
|
||||
{8, "Camera is already in use or busy."},
|
||||
};
|
||||
|
||||
//Need to Fix The Range based Values
|
||||
static std::map<int, std::string> descapplication = {
|
||||
{0, "The application raised an error. Please consult the application's "
|
||||
"source code or ask the author for assistance with it."},
|
||||
{1024, "0x01"},
|
||||
};
|
||||
|
||||
namespace RenderD7 {
|
||||
void ResultDecoder::Load(Result rescode) { this->m_rescode = rescode; }
|
||||
void ResultDecoder::Load(std::string rescode) {
|
||||
std::stringstream ss;
|
||||
ss << rescode;
|
||||
ss >> std::hex >> this->m_rescode;
|
||||
}
|
||||
std::string RenderD7::ResultDecoder::GetCode() {
|
||||
std::stringstream ss;
|
||||
ss << std::hex << m_rescode;
|
||||
std::string reshex(ss.str());
|
||||
return reshex;
|
||||
}
|
||||
std::string ResultDecoder::GetLevel() {
|
||||
std::string res = levels.at(this->GetLevelInt()) + " (" +
|
||||
std::to_string(this->GetLevelInt()) + ")";
|
||||
return res;
|
||||
}
|
||||
int ResultDecoder::GetLevelInt() { return R_LEVEL(m_rescode); }
|
||||
std::string ResultDecoder::GetModule() {
|
||||
std::string res = modules.at(this->GetModuleInt()) + " (" +
|
||||
std::to_string(this->GetModuleInt()) + ")";
|
||||
return res;
|
||||
}
|
||||
int ResultDecoder::GetModuleInt() { return R_MODULE(m_rescode); }
|
||||
std::string ResultDecoder::GetDescription() {
|
||||
std::string res = "Desc Not Implemented!";
|
||||
switch (this->GetModuleInt()) {
|
||||
case 0:
|
||||
res = desccommon.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
break;
|
||||
case 1:
|
||||
if ((desckernel.find(this->GetDescriptionInt()) == desckernel.end())) {
|
||||
res = desccommon.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
} else {
|
||||
res = desckernel.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
if ((descos.find(this->GetDescriptionInt()) == descos.end())) {
|
||||
res = desccommon.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
} else {
|
||||
res = descos.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
}
|
||||
break;
|
||||
case 17:
|
||||
if ((descfs.find(this->GetDescriptionInt()) == descfs.end())) {
|
||||
res = desccommon.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
} else {
|
||||
res = descfs.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
}
|
||||
break;
|
||||
case 25:
|
||||
if ((descsrv.find(this->GetDescriptionInt()) == descsrv.end())) {
|
||||
res = desccommon.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
} else {
|
||||
res = descsrv.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
}
|
||||
break;
|
||||
case 27:
|
||||
if ((descnwm.find(this->GetDescriptionInt()) == descnwm.end())) {
|
||||
res = desccommon.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
} else {
|
||||
res = descnwm.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
}
|
||||
break;
|
||||
case 32:
|
||||
if ((descam.find(this->GetDescriptionInt()) == descam.end())) {
|
||||
res = desccommon.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
} else {
|
||||
res = descam.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
}
|
||||
break;
|
||||
case 40:
|
||||
if ((deschttp.find(this->GetDescriptionInt()) == deschttp.end())) {
|
||||
res = desccommon.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
} else {
|
||||
res = deschttp.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
}
|
||||
break;
|
||||
case 52:
|
||||
if ((descnim.find(this->GetDescriptionInt()) == descnim.end())) {
|
||||
res = desccommon.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
} else {
|
||||
res = descnim.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
}
|
||||
break;
|
||||
case 92:
|
||||
if ((descmvd.find(this->GetDescriptionInt()) == descmvd.end())) {
|
||||
res = desccommon.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
} else {
|
||||
res = descmvd.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
}
|
||||
break;
|
||||
case 96:
|
||||
if ((descqtm.find(this->GetDescriptionInt()) == descqtm.end())) {
|
||||
res = desccommon.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
} else {
|
||||
res = descqtm.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
}
|
||||
break;
|
||||
case 254:
|
||||
if ((descapplication.find(this->GetDescriptionInt()) ==
|
||||
descapplication.end())) {
|
||||
res = desccommon.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
} else {
|
||||
res = descapplication.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
res = desccommon.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
int ResultDecoder::GetDescriptionInt() { return R_DESCRIPTION(m_rescode); }
|
||||
std::string ResultDecoder::GetSummary() {
|
||||
std::string res = summaries.at(this->GetSummaryInt()) + " (" +
|
||||
std::to_string(this->GetSummaryInt()) + ")";
|
||||
return res;
|
||||
}
|
||||
|
||||
int ResultDecoder::GetSummaryInt() { return R_SUMMARY(m_rescode); }
|
||||
} // namespace RenderD7
|
@ -13,5 +13,12 @@ StealConsole::~StealConsole() {
|
||||
// Do Nothing Here
|
||||
}
|
||||
|
||||
std::string StealConsole::GetStdout() { return this->stolen_stdout.str(); }
|
||||
std::string StealConsole::GetStdout() {
|
||||
if (this->stolen_stdout.str().length() < 400) {
|
||||
return this->stolen_stdout.str();
|
||||
} else {
|
||||
return this->stolen_stdout.str().substr(stolen_stdout.str().length() - 400);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
} // namespace RenderD7
|
22
source/Tasks.cpp
Normal file
22
source/Tasks.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
#include <renderd7/Tasks.hpp>
|
||||
|
||||
#include <3ds.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static std::vector<Thread> threads;
|
||||
|
||||
void Tasks::create(ThreadFunc entrypoint) {
|
||||
s32 prio = 0;
|
||||
svcGetThreadPriority(&prio, CUR_THREAD_HANDLE);
|
||||
Thread thread = threadCreate((ThreadFunc)entrypoint, NULL, 64 * 1024,
|
||||
prio - 1, -2, false);
|
||||
threads.push_back(thread);
|
||||
}
|
||||
|
||||
void Tasks::destroy(void) {
|
||||
for (u32 i = 0; i < threads.size(); i++) {
|
||||
threadJoin(threads.at(i), U64_MAX);
|
||||
threadFree(threads.at(i));
|
||||
}
|
||||
}
|
@ -877,6 +877,8 @@ void RenderD7::RSettings::Draw(void) const {
|
||||
"RenderD7-Build-Time: \n" + buildtime);
|
||||
RenderD7::Draw::Text(0, 150, 0.7f, DSEVENBLACK,
|
||||
"RenderD7-Commit: " + commit);
|
||||
RenderD7::Draw::Text(0, 170, 0.7f, DSEVENBLACK,
|
||||
"RenderD7-Overlays: " + std::to_string(overlays.size()));
|
||||
/*RenderD7::Draw::Text(0, 130, 0.7f, DSEVENBLACK, "Metrik Text RGB: " +
|
||||
mttxtcolstate); RenderD7::Draw::Text(0, 150, 0.7f, DSEVENBLACK, "Metrik
|
||||
Alpha: " + mtcola); RenderD7::Draw::Text(0, 170, 0.7f, DSEVENBLACK, "Metrik
|
||||
|
2
source/stb.cpp
Normal file
2
source/stb.cpp
Normal file
@ -0,0 +1,2 @@
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#include <renderd7/external/stb_image.h>
|
Reference in New Issue
Block a user