mirror of
https://github.com/wiiu-env/AutobootModule.git
synced 2024-11-25 12:06:58 +01:00
Formatting
This commit is contained in:
parent
7e5f174076
commit
ad693c94ff
@ -134,10 +134,9 @@ void bootHomebrewChannel() {
|
|||||||
|
|
||||||
// test if the OHBC or HBC is installed
|
// test if the OHBC or HBC is installed
|
||||||
if (IOSUHAX_FSA_GetStat(fsaFd, "/vol/storage_slccmpt01/title/00010001/4f484243/content/00000000.app", &stat) >= 0) {
|
if (IOSUHAX_FSA_GetStat(fsaFd, "/vol/storage_slccmpt01/title/00010001/4f484243/content/00000000.app", &stat) >= 0) {
|
||||||
titleId = 0x000100014f484243; // 'OHBC'
|
titleId = 0x000100014F484243L; // 'OHBC'
|
||||||
}
|
} else if (IOSUHAX_FSA_GetStat(fsaFd, "/vol/storage_slccmpt01/title/00010001/4c554c5a/content/00000000.app", &stat) >= 0) {
|
||||||
else if (IOSUHAX_FSA_GetStat(fsaFd, "/vol/storage_slccmpt01/title/00010001/4c554c5a/content/00000000.app", &stat) >= 0) {
|
titleId = 0x000100014C554C5AL; // 'LULZ'
|
||||||
titleId = 0x000100014c554c5a; // 'LULZ'
|
|
||||||
} else {
|
} else {
|
||||||
DEBUG_FUNCTION_LINE("Cannot find HBC, booting vWii System Menu");
|
DEBUG_FUNCTION_LINE("Cannot find HBC, booting vWii System Menu");
|
||||||
}
|
}
|
||||||
|
@ -45,16 +45,14 @@ void* DrawUtils::InitOSScreen(){
|
|||||||
return screenBuffer;
|
return screenBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawUtils::initBuffers(void* tvBuffer, uint32_t tvSize, void* drcBuffer, uint32_t drcSize)
|
void DrawUtils::initBuffers(void *tvBuffer, uint32_t tvSize, void *drcBuffer, uint32_t drcSize) {
|
||||||
{
|
|
||||||
DrawUtils::tvBuffer = (uint8_t *) tvBuffer;
|
DrawUtils::tvBuffer = (uint8_t *) tvBuffer;
|
||||||
DrawUtils::tvSize = tvSize;
|
DrawUtils::tvSize = tvSize;
|
||||||
DrawUtils::drcBuffer = (uint8_t *) drcBuffer;
|
DrawUtils::drcBuffer = (uint8_t *) drcBuffer;
|
||||||
DrawUtils::drcSize = drcSize;
|
DrawUtils::drcSize = drcSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawUtils::beginDraw()
|
void DrawUtils::beginDraw() {
|
||||||
{
|
|
||||||
uint32_t pixel = *(uint32_t *) tvBuffer;
|
uint32_t pixel = *(uint32_t *) tvBuffer;
|
||||||
|
|
||||||
// check which buffer is currently used
|
// check which buffer is currently used
|
||||||
@ -69,8 +67,7 @@ void DrawUtils::beginDraw()
|
|||||||
*(uint32_t *) tvBuffer = pixel;
|
*(uint32_t *) tvBuffer = pixel;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawUtils::endDraw()
|
void DrawUtils::endDraw() {
|
||||||
{
|
|
||||||
// OSScreenFlipBuffersEx already flushes the cache?
|
// OSScreenFlipBuffersEx already flushes the cache?
|
||||||
// DCFlushRange(tvBuffer, tvSize);
|
// DCFlushRange(tvBuffer, tvSize);
|
||||||
// DCFlushRange(drcBuffer, drcSize);
|
// DCFlushRange(drcBuffer, drcSize);
|
||||||
@ -79,14 +76,12 @@ void DrawUtils::endDraw()
|
|||||||
OSScreenFlipBuffersEx(SCREEN_TV);
|
OSScreenFlipBuffersEx(SCREEN_TV);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawUtils::clear(Color col)
|
void DrawUtils::clear(Color col) {
|
||||||
{
|
|
||||||
OSScreenClearBufferEx(SCREEN_TV, col.color);
|
OSScreenClearBufferEx(SCREEN_TV, col.color);
|
||||||
OSScreenClearBufferEx(SCREEN_DRC, col.color);
|
OSScreenClearBufferEx(SCREEN_DRC, col.color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawUtils::drawPixel(uint32_t x, uint32_t y, uint8_t r, uint8_t g, uint8_t b, uint8_t a)
|
void DrawUtils::drawPixel(uint32_t x, uint32_t y, uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
|
||||||
{
|
|
||||||
float opacity = a / 255.0f;
|
float opacity = a / 255.0f;
|
||||||
|
|
||||||
// put pixel in the drc buffer
|
// put pixel in the drc buffer
|
||||||
@ -99,8 +94,7 @@ void DrawUtils::drawPixel(uint32_t x, uint32_t y, uint8_t r, uint8_t g, uint8_t
|
|||||||
drcBuffer[i] = r;
|
drcBuffer[i] = r;
|
||||||
drcBuffer[i + 1] = g;
|
drcBuffer[i + 1] = g;
|
||||||
drcBuffer[i + 2] = b;
|
drcBuffer[i + 2] = b;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
drcBuffer[i] = r * opacity + drcBuffer[i] * (1 - opacity);
|
drcBuffer[i] = r * opacity + drcBuffer[i] * (1 - opacity);
|
||||||
drcBuffer[i + 1] = g * opacity + drcBuffer[i + 1] * (1 - opacity);
|
drcBuffer[i + 1] = g * opacity + drcBuffer[i + 1] * (1 - opacity);
|
||||||
drcBuffer[i + 2] = b * opacity + drcBuffer[i + 2] * (1 - opacity);
|
drcBuffer[i + 2] = b * opacity + drcBuffer[i + 2] * (1 - opacity);
|
||||||
@ -119,8 +113,7 @@ void DrawUtils::drawPixel(uint32_t x, uint32_t y, uint8_t r, uint8_t g, uint8_t
|
|||||||
tvBuffer[i] = r;
|
tvBuffer[i] = r;
|
||||||
tvBuffer[i + 1] = g;
|
tvBuffer[i + 1] = g;
|
||||||
tvBuffer[i + 2] = b;
|
tvBuffer[i + 2] = b;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
tvBuffer[i] = r * opacity + tvBuffer[i] * (1 - opacity);
|
tvBuffer[i] = r * opacity + tvBuffer[i] * (1 - opacity);
|
||||||
tvBuffer[i + 1] = g * opacity + tvBuffer[i + 1] * (1 - opacity);
|
tvBuffer[i + 1] = g * opacity + tvBuffer[i + 1] * (1 - opacity);
|
||||||
tvBuffer[i + 2] = b * opacity + tvBuffer[i + 2] * (1 - opacity);
|
tvBuffer[i + 2] = b * opacity + tvBuffer[i + 2] * (1 - opacity);
|
||||||
@ -130,8 +123,7 @@ void DrawUtils::drawPixel(uint32_t x, uint32_t y, uint8_t r, uint8_t g, uint8_t
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawUtils::drawRectFilled(uint32_t x, uint32_t y, uint32_t w, uint32_t h, Color col)
|
void DrawUtils::drawRectFilled(uint32_t x, uint32_t y, uint32_t w, uint32_t h, Color col) {
|
||||||
{
|
|
||||||
for (uint32_t yy = y; yy < y + h; yy++) {
|
for (uint32_t yy = y; yy < y + h; yy++) {
|
||||||
for (uint32_t xx = x; xx < x + w; xx++) {
|
for (uint32_t xx = x; xx < x + w; xx++) {
|
||||||
drawPixel(xx, yy, col);
|
drawPixel(xx, yy, col);
|
||||||
@ -139,16 +131,14 @@ void DrawUtils::drawRectFilled(uint32_t x, uint32_t y, uint32_t w, uint32_t h, C
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawUtils::drawRect(uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint32_t borderSize, Color col)
|
void DrawUtils::drawRect(uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint32_t borderSize, Color col) {
|
||||||
{
|
|
||||||
drawRectFilled(x, y, w, borderSize, col);
|
drawRectFilled(x, y, w, borderSize, col);
|
||||||
drawRectFilled(x, y + h - borderSize, w, borderSize, col);
|
drawRectFilled(x, y + h - borderSize, w, borderSize, col);
|
||||||
drawRectFilled(x, y, borderSize, h, col);
|
drawRectFilled(x, y, borderSize, h, col);
|
||||||
drawRectFilled(x + w - borderSize, y, borderSize, h, col);
|
drawRectFilled(x + w - borderSize, y, borderSize, h, col);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawUtils::drawBitmap(uint32_t x, uint32_t y, uint32_t target_width, uint32_t target_height, const uint8_t* data)
|
void DrawUtils::drawBitmap(uint32_t x, uint32_t y, uint32_t target_width, uint32_t target_height, const uint8_t *data) {
|
||||||
{
|
|
||||||
if (data[0] != 'B' || data[1] != 'M') {
|
if (data[0] != 'B' || data[1] != 'M') {
|
||||||
// invalid header
|
// invalid header
|
||||||
return;
|
return;
|
||||||
@ -174,16 +164,14 @@ void DrawUtils::drawBitmap(uint32_t x, uint32_t y, uint32_t target_width, uint32
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void png_read_data(png_structp png_ptr, png_bytep outBytes, png_size_t byteCountToRead)
|
static void png_read_data(png_structp png_ptr, png_bytep outBytes, png_size_t byteCountToRead) {
|
||||||
{
|
|
||||||
void **data = (void **) png_get_io_ptr(png_ptr);
|
void **data = (void **) png_get_io_ptr(png_ptr);
|
||||||
|
|
||||||
memcpy(outBytes, *data, byteCountToRead);
|
memcpy(outBytes, *data, byteCountToRead);
|
||||||
*((uint8_t **) data) += byteCountToRead;
|
*((uint8_t **) data) += byteCountToRead;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawUtils::drawPNG(uint32_t x, uint32_t y, const uint8_t* data)
|
void DrawUtils::drawPNG(uint32_t x, uint32_t y, const uint8_t *data) {
|
||||||
{
|
|
||||||
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||||
if (png_ptr == NULL) {
|
if (png_ptr == NULL) {
|
||||||
return;
|
return;
|
||||||
@ -218,8 +206,7 @@ void DrawUtils::drawPNG(uint32_t x, uint32_t y, const uint8_t* data)
|
|||||||
if (colorType == PNG_COLOR_TYPE_RGB_ALPHA) {
|
if (colorType == PNG_COLOR_TYPE_RGB_ALPHA) {
|
||||||
uint32_t i = (xx - x) * 4;
|
uint32_t i = (xx - x) * 4;
|
||||||
drawPixel(xx, yy, rowData[i], rowData[i + 1], rowData[i + 2], rowData[i + 3]);
|
drawPixel(xx, yy, rowData[i], rowData[i + 1], rowData[i + 2], rowData[i + 3]);
|
||||||
}
|
} else if (colorType == PNG_COLOR_TYPE_RGB) {
|
||||||
else if (colorType == PNG_COLOR_TYPE_RGB) {
|
|
||||||
uint32_t i = (xx - x) * 3;
|
uint32_t i = (xx - x) * 3;
|
||||||
drawPixel(xx, yy, rowData[i], rowData[i + 1], rowData[i + 2], 0xFF);
|
drawPixel(xx, yy, rowData[i], rowData[i + 1], rowData[i + 2], 0xFF);
|
||||||
}
|
}
|
||||||
@ -230,8 +217,7 @@ void DrawUtils::drawPNG(uint32_t x, uint32_t y, const uint8_t* data)
|
|||||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawUtils::initFont()
|
void DrawUtils::initFont() {
|
||||||
{
|
|
||||||
void *font = NULL;
|
void *font = NULL;
|
||||||
uint32_t size = 0;
|
uint32_t size = 0;
|
||||||
OSGetSharedData(OS_SHAREDDATATYPE_FONT_STANDARD, 0, &font, &size);
|
OSGetSharedData(OS_SHAREDDATATYPE_FONT_STANDARD, 0, &font, &size);
|
||||||
@ -242,24 +228,20 @@ void DrawUtils::initFont()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawUtils::deinitFont()
|
void DrawUtils::deinitFont() {
|
||||||
{
|
|
||||||
FT_Done_Face(ft_face);
|
FT_Done_Face(ft_face);
|
||||||
FT_Done_FreeType(ft_lib);
|
FT_Done_FreeType(ft_lib);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawUtils::setFontSize(uint32_t size)
|
void DrawUtils::setFontSize(uint32_t size) {
|
||||||
{
|
|
||||||
FT_Set_Pixel_Sizes(ft_face, 0, size);
|
FT_Set_Pixel_Sizes(ft_face, 0, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawUtils::setFontColor(Color col)
|
void DrawUtils::setFontColor(Color col) {
|
||||||
{
|
|
||||||
font_col = col;
|
font_col = col;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void draw_freetype_bitmap(FT_Bitmap* bitmap, FT_Int x, FT_Int y)
|
static void draw_freetype_bitmap(FT_Bitmap *bitmap, FT_Int x, FT_Int y) {
|
||||||
{
|
|
||||||
FT_Int i, j, p, q;
|
FT_Int i, j, p, q;
|
||||||
FT_Int x_max = x + bitmap->width;
|
FT_Int x_max = x + bitmap->width;
|
||||||
FT_Int y_max = y + bitmap->rows;
|
FT_Int y_max = y + bitmap->rows;
|
||||||
@ -276,15 +258,13 @@ static void draw_freetype_bitmap(FT_Bitmap* bitmap, FT_Int x, FT_Int y)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawUtils::print(uint32_t x, uint32_t y, const char* string, bool alignRight)
|
void DrawUtils::print(uint32_t x, uint32_t y, const char *string, bool alignRight) {
|
||||||
{
|
|
||||||
wchar_t *buffer = new wchar_t[strlen(string) + 1];
|
wchar_t *buffer = new wchar_t[strlen(string) + 1];
|
||||||
|
|
||||||
size_t num = mbstowcs(buffer, string, strlen(string));
|
size_t num = mbstowcs(buffer, string, strlen(string));
|
||||||
if (num > 0) {
|
if (num > 0) {
|
||||||
buffer[num] = 0;
|
buffer[num] = 0;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
wchar_t *tmp = buffer;
|
wchar_t *tmp = buffer;
|
||||||
while ((*tmp++ = *string++));
|
while ((*tmp++ = *string++));
|
||||||
}
|
}
|
||||||
@ -293,8 +273,7 @@ void DrawUtils::print(uint32_t x, uint32_t y, const char* string, bool alignRigh
|
|||||||
delete[] buffer;
|
delete[] buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawUtils::print(uint32_t x, uint32_t y, const wchar_t* string, bool alignRight)
|
void DrawUtils::print(uint32_t x, uint32_t y, const wchar_t *string, bool alignRight) {
|
||||||
{
|
|
||||||
FT_GlyphSlot slot = ft_face->glyph;
|
FT_GlyphSlot slot = ft_face->glyph;
|
||||||
FT_Vector pen = {(int) x, (int) y};
|
FT_Vector pen = {(int) x, (int) y};
|
||||||
|
|
||||||
@ -319,15 +298,13 @@ void DrawUtils::print(uint32_t x, uint32_t y, const wchar_t* string, bool alignR
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t DrawUtils::getTextWidth(const char* string)
|
uint32_t DrawUtils::getTextWidth(const char *string) {
|
||||||
{
|
|
||||||
wchar_t *buffer = new wchar_t[strlen(string) + 1];
|
wchar_t *buffer = new wchar_t[strlen(string) + 1];
|
||||||
|
|
||||||
size_t num = mbstowcs(buffer, string, strlen(string));
|
size_t num = mbstowcs(buffer, string, strlen(string));
|
||||||
if (num > 0) {
|
if (num > 0) {
|
||||||
buffer[num] = 0;
|
buffer[num] = 0;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
wchar_t *tmp = buffer;
|
wchar_t *tmp = buffer;
|
||||||
while ((*tmp++ = *string++));
|
while ((*tmp++ = *string++));
|
||||||
}
|
}
|
||||||
@ -338,8 +315,7 @@ uint32_t DrawUtils::getTextWidth(const char* string)
|
|||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t DrawUtils::getTextWidth(const wchar_t* string)
|
uint32_t DrawUtils::getTextWidth(const wchar_t *string) {
|
||||||
{
|
|
||||||
FT_GlyphSlot slot = ft_face->glyph;
|
FT_GlyphSlot slot = ft_face->glyph;
|
||||||
uint32_t width = 0;
|
uint32_t width = 0;
|
||||||
|
|
||||||
|
@ -10,8 +10,12 @@ union Color {
|
|||||||
Color(uint32_t color) {
|
Color(uint32_t color) {
|
||||||
this->color = color;
|
this->color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
|
Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
|
||||||
this->r = r; this->g = g; this->b = b; this->a = a;
|
this->r = r;
|
||||||
|
this->g = g;
|
||||||
|
this->b = b;
|
||||||
|
this->a = a;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t color;
|
uint32_t color;
|
||||||
@ -26,26 +30,41 @@ union Color {
|
|||||||
class DrawUtils {
|
class DrawUtils {
|
||||||
public:
|
public:
|
||||||
static void *InitOSScreen();
|
static void *InitOSScreen();
|
||||||
|
|
||||||
static void initBuffers(void *tvBuffer, uint32_t tvSize, void *drcBuffer, uint32_t drcSize);
|
static void initBuffers(void *tvBuffer, uint32_t tvSize, void *drcBuffer, uint32_t drcSize);
|
||||||
|
|
||||||
static void beginDraw();
|
static void beginDraw();
|
||||||
|
|
||||||
static void endDraw();
|
static void endDraw();
|
||||||
|
|
||||||
static void clear(Color col);
|
static void clear(Color col);
|
||||||
|
|
||||||
static void drawPixel(uint32_t x, uint32_t y, Color col) { drawPixel(x, y, col.r, col.g, col.b, col.a); }
|
static void drawPixel(uint32_t x, uint32_t y, Color col) { drawPixel(x, y, col.r, col.g, col.b, col.a); }
|
||||||
|
|
||||||
static void drawPixel(uint32_t x, uint32_t y, uint8_t r, uint8_t g, uint8_t b, uint8_t a);
|
static void drawPixel(uint32_t x, uint32_t y, uint8_t r, uint8_t g, uint8_t b, uint8_t a);
|
||||||
|
|
||||||
static void drawRectFilled(uint32_t x, uint32_t y, uint32_t w, uint32_t h, Color col);
|
static void drawRectFilled(uint32_t x, uint32_t y, uint32_t w, uint32_t h, Color col);
|
||||||
|
|
||||||
static void drawRect(uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint32_t borderSize, Color col);
|
static void drawRect(uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint32_t borderSize, Color col);
|
||||||
|
|
||||||
static void drawBitmap(uint32_t x, uint32_t y, uint32_t target_width, uint32_t target_height, const uint8_t *data);
|
static void drawBitmap(uint32_t x, uint32_t y, uint32_t target_width, uint32_t target_height, const uint8_t *data);
|
||||||
|
|
||||||
static void drawPNG(uint32_t x, uint32_t y, const uint8_t *data);
|
static void drawPNG(uint32_t x, uint32_t y, const uint8_t *data);
|
||||||
|
|
||||||
static void initFont();
|
static void initFont();
|
||||||
|
|
||||||
static void deinitFont();
|
static void deinitFont();
|
||||||
|
|
||||||
static void setFontSize(uint32_t size);
|
static void setFontSize(uint32_t size);
|
||||||
|
|
||||||
static void setFontColor(Color col);
|
static void setFontColor(Color col);
|
||||||
|
|
||||||
static void print(uint32_t x, uint32_t y, const char *string, bool alignRight = false);
|
static void print(uint32_t x, uint32_t y, const char *string, bool alignRight = false);
|
||||||
|
|
||||||
static void print(uint32_t x, uint32_t y, const wchar_t *string, bool alignRight = false);
|
static void print(uint32_t x, uint32_t y, const wchar_t *string, bool alignRight = false);
|
||||||
|
|
||||||
static uint32_t getTextWidth(const char *string);
|
static uint32_t getTextWidth(const char *string);
|
||||||
|
|
||||||
static uint32_t getTextWidth(const wchar_t *string);
|
static uint32_t getTextWidth(const wchar_t *string);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user