mirror of
https://github.com/CTCaer/hekate.git
synced 2025-04-20 11:35:56 +00:00
Landscape mode
This commit is contained in:
parent
6da09b3b93
commit
3140169fb8
5 changed files with 54 additions and 62 deletions
|
@ -117,12 +117,13 @@ static const u8 _gfx_font[] = {
|
|||
0x00, 0x00, 0x00, 0x4C, 0x32, 0x00, 0x00, 0x00 // Char 126 (~)
|
||||
};
|
||||
|
||||
void gfx_init_ctxt(gfx_ctxt_t *ctxt, u32 *fb, u32 width, u32 height, u32 stride)
|
||||
void gfx_init_ctxt(gfx_ctxt_t *ctxt, u32 *fb, u32 width, u32 height, u32 stride, bool landscape)
|
||||
{
|
||||
ctxt->fb = fb;
|
||||
ctxt->width = width;
|
||||
ctxt->height = height;
|
||||
ctxt->width = landscape ? height : width;
|
||||
ctxt->height = landscape ? width : height;
|
||||
ctxt->stride = stride;
|
||||
ctxt->landscape = landscape;
|
||||
}
|
||||
|
||||
void gfx_clear_grey(gfx_ctxt_t *ctxt, u8 color)
|
||||
|
@ -132,13 +133,16 @@ void gfx_clear_grey(gfx_ctxt_t *ctxt, u8 color)
|
|||
|
||||
void gfx_clear_color(gfx_ctxt_t *ctxt, u32 color)
|
||||
{
|
||||
for (u32 i = 0; i < ctxt->height * ctxt->stride; i++)
|
||||
ctxt->fb[i] = color;
|
||||
for (u32 x = 0; x < ctxt->width; x++)
|
||||
for (u32 y = 0; y < ctxt->height; y++)
|
||||
gfx_set_pixel(ctxt, x, y, color);
|
||||
}
|
||||
|
||||
void gfx_clear_partial_grey(gfx_ctxt_t *ctxt, u8 color, u32 pos_x, u32 height)
|
||||
{
|
||||
memset(ctxt->fb + pos_x * ctxt->stride, color, height * 4 * ctxt->stride);
|
||||
for (u32 x = 0; x < ctxt->width; x++)
|
||||
for (u32 y = 0; y < height; y++)
|
||||
gfx_set_pixel(ctxt, x, pos_x + y, color << 24 | color << 16 | color << 8 | color);
|
||||
}
|
||||
|
||||
void gfx_con_init(gfx_con_t *con, gfx_ctxt_t *ctxt)
|
||||
|
@ -183,33 +187,22 @@ void gfx_putc(gfx_con_t *con, char c)
|
|||
if (c >= 32 && c <= 126)
|
||||
{
|
||||
u8 *cbuf = (u8 *)&_gfx_font[8 * (c - 32)];
|
||||
u32 *fb = con->gfx_ctxt->fb + con->x + con->y * con->gfx_ctxt->stride;
|
||||
|
||||
for (u32 i = 0; i < 16; i+=2)
|
||||
for (u32 i = 0; i < 16; i += 2)
|
||||
{
|
||||
u8 v = *cbuf++;
|
||||
for (u32 k = 0; k < 2; k++)
|
||||
{
|
||||
for (u32 j = 0; j < 8; j++)
|
||||
for (u32 j = 0; j < 16; j += 2)
|
||||
{
|
||||
if (v & 1)
|
||||
for (u32 l = 0; l < 2; l++)
|
||||
{
|
||||
*fb = con->fgcol;
|
||||
fb++;
|
||||
*fb = con->fgcol;
|
||||
if (v & 1)
|
||||
gfx_set_pixel(con->gfx_ctxt, con->x + j + l, con->y + i + k, con->fgcol);
|
||||
else if (con->fillbg)
|
||||
gfx_set_pixel(con->gfx_ctxt, con->x + j + l, con->y + i + k, con->bgcol);
|
||||
}
|
||||
else if (con->fillbg)
|
||||
{
|
||||
*fb = con->bgcol;
|
||||
fb++;
|
||||
*fb = con->bgcol;
|
||||
}
|
||||
else
|
||||
fb++;
|
||||
v >>= 1;
|
||||
fb++;
|
||||
}
|
||||
fb += con->gfx_ctxt->stride - 16;
|
||||
v = *cbuf;
|
||||
}
|
||||
}
|
||||
|
@ -228,20 +221,17 @@ void gfx_putc(gfx_con_t *con, char c)
|
|||
if (c >= 32 && c <= 126)
|
||||
{
|
||||
u8 *cbuf = (u8 *)&_gfx_font[8 * (c - 32)];
|
||||
u32 *fb = con->gfx_ctxt->fb + con->x + con->y * con->gfx_ctxt->stride;
|
||||
for (u32 i = 0; i < 8; i++)
|
||||
{
|
||||
u8 v = *cbuf++;
|
||||
for (u32 j = 0; j < 8; j++)
|
||||
{
|
||||
if (v & 1)
|
||||
*fb = con->fgcol;
|
||||
gfx_set_pixel(con->gfx_ctxt, con->x + j, con->y + i, con->fgcol);
|
||||
else if (con->fillbg)
|
||||
*fb = con->bgcol;
|
||||
gfx_set_pixel(con->gfx_ctxt, con->x + j, con->y + i, con->bgcol);
|
||||
v >>= 1;
|
||||
fb++;
|
||||
}
|
||||
fb += con->gfx_ctxt->stride - 8;
|
||||
}
|
||||
con->x += 8;
|
||||
}
|
||||
|
@ -444,14 +434,15 @@ void gfx_hexdump(gfx_con_t *con, u32 base, const u8 *buf, u32 len)
|
|||
|
||||
static int abs(int x)
|
||||
{
|
||||
if (x < 0)
|
||||
return -x;
|
||||
return x;
|
||||
return x < 0 ? -x : x;
|
||||
}
|
||||
|
||||
void gfx_set_pixel(gfx_ctxt_t *ctxt, u32 x, u32 y, u32 color)
|
||||
{
|
||||
ctxt->fb[x + y * ctxt->stride] = color;
|
||||
if (ctxt->landscape)
|
||||
ctxt->fb[y + (ctxt->width - x) * ctxt->stride] = color;
|
||||
else
|
||||
ctxt->fb[x + y * ctxt->stride] = color;
|
||||
}
|
||||
|
||||
void gfx_line(gfx_ctxt_t *ctxt, int x0, int y0, int x1, int y1, u32 color)
|
||||
|
@ -486,7 +477,7 @@ void gfx_set_rect_grey(gfx_ctxt_t *ctxt, const u8 *buf, u32 size_x, u32 size_y,
|
|||
{
|
||||
for (u32 x = pos_x; x < (pos_x + size_x); x++)
|
||||
{
|
||||
memset(&ctxt->fb[x + y*ctxt->stride], buf[pos], 4);
|
||||
gfx_set_pixel(ctxt, x, y, buf[pos] << 24 | buf[pos] << 16 | buf[pos] << 8 | buf[pos]);
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
|
@ -500,8 +491,8 @@ void gfx_set_rect_rgb(gfx_ctxt_t *ctxt, const u8 *buf, u32 size_x, u32 size_y, u
|
|||
{
|
||||
for (u32 x = pos_x; x < (pos_x + size_x); x++)
|
||||
{
|
||||
ctxt->fb[x + y*ctxt->stride] = buf[pos + 2] | (buf[pos + 1] << 8) | (buf[pos] << 16);
|
||||
pos+=3;
|
||||
gfx_set_pixel(ctxt, x, y, buf[pos + 2] | (buf[pos + 1] << 8) | (buf[pos] << 16));
|
||||
pos += 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -513,7 +504,7 @@ void gfx_set_rect_argb(gfx_ctxt_t *ctxt, const u32 *buf, u32 size_x, u32 size_y,
|
|||
{
|
||||
for (u32 x = pos_x; x < (pos_x + size_x); x++)
|
||||
{
|
||||
ctxt->fb[x + y*ctxt->stride] = buf[pos];
|
||||
gfx_set_pixel(ctxt, x, y, buf[pos]);
|
||||
pos+=1;
|
||||
}
|
||||
}
|
||||
|
@ -524,6 +515,6 @@ void gfx_render_bmp_argb(gfx_ctxt_t *ctxt, const u32 *buf, u32 size_x, u32 size_
|
|||
for (u32 y = pos_y; y < (pos_y + size_y); y++)
|
||||
{
|
||||
for (u32 x = pos_x; x < (pos_x + size_x); x++)
|
||||
ctxt->fb[x + y*ctxt->stride] = buf[(size_y + pos_y - 1 - y ) * size_x + x - pos_x];
|
||||
gfx_set_pixel(ctxt, x, y, buf[(size_y + pos_y - 1 - y ) * size_x + x - pos_x]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include "../../common/common_gfx.h"
|
||||
|
||||
void gfx_init_ctxt(gfx_ctxt_t *ctxt, u32 *fb, u32 width, u32 height, u32 stride);
|
||||
void gfx_init_ctxt(gfx_ctxt_t *ctxt, u32 *fb, u32 width, u32 height, u32 stride, bool landscape);
|
||||
void gfx_clear_grey(gfx_ctxt_t *ctxt, u8 color);
|
||||
void gfx_clear_partial_grey(gfx_ctxt_t *ctxt, u8 color, u32 pos_x, u32 height);
|
||||
void gfx_clear_color(gfx_ctxt_t *ctxt, u32 color);
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
extern u8 *Kc_MENU_LOGO;
|
||||
#define X_MENU_LOGO 119
|
||||
#define Y_MENU_LOGO 57
|
||||
#define X_POS_MENU_LOGO 577
|
||||
#define Y_POS_MENU_LOGO 1179
|
||||
#define X_POS_MENU_LOGO (con->gfx_ctxt->width - 143)
|
||||
#define Y_POS_MENU_LOGO (con->gfx_ctxt->height - 101)
|
||||
#endif //MENU_LOGO_ENABLE
|
||||
|
||||
extern hekate_config h_cfg;
|
||||
|
@ -48,12 +48,12 @@ void tui_sbar(gfx_con_t *con, bool force_update)
|
|||
int battVoltCurr = 0;
|
||||
|
||||
gfx_con_getpos(con, &cx, &cy);
|
||||
gfx_con_setpos(con, 0, 1260);
|
||||
gfx_con_setpos(con, 0, con->gfx_ctxt->height - 20);
|
||||
|
||||
max17050_get_property(MAX17050_RepSOC, (int *)&battPercent);
|
||||
max17050_get_property(MAX17050_VCELL, &battVoltCurr);
|
||||
|
||||
gfx_clear_partial_grey(con->gfx_ctxt, 0x30, 1256, 24);
|
||||
gfx_clear_partial_grey(con->gfx_ctxt, 0x30, con->gfx_ctxt->height - 24, 24);
|
||||
gfx_printf(con, "%K%k Battery: %d.%d%% (%d mV) - Charge:", 0xFF303030, 0xFF888888,
|
||||
(battPercent >> 8) & 0xFF, (battPercent & 0xFF) / 26, battVoltCurr);
|
||||
|
||||
|
@ -99,7 +99,7 @@ void *tui_do_menu(gfx_con_t *con, menu_t *menu)
|
|||
{
|
||||
int idx = 0, prev_idx = 0, cnt = 0x7FFFFFFF;
|
||||
|
||||
gfx_clear_partial_grey(con->gfx_ctxt, 0x1B, 0, 1256);
|
||||
gfx_clear_partial_grey(con->gfx_ctxt, 0x1B, 0, con->gfx_ctxt->height - 24);
|
||||
tui_sbar(con, true);
|
||||
|
||||
#ifdef MENU_LOGO_ENABLE
|
||||
|
@ -158,7 +158,7 @@ void *tui_do_menu(gfx_con_t *con, menu_t *menu)
|
|||
|
||||
// Print help and battery status.
|
||||
gfx_con_getpos(con, &con->savedx, &con->savedy);
|
||||
gfx_con_setpos(con, 0, 1191);
|
||||
gfx_con_setpos(con, 0, con->gfx_ctxt->height - 89);
|
||||
gfx_printf(con, "%k VOL: Move up/down\n PWR: Select option%k", 0xFF555555, 0xFFCCCCCC);
|
||||
|
||||
// Wait for user command.
|
||||
|
@ -196,7 +196,7 @@ void *tui_do_menu(gfx_con_t *con, menu_t *menu)
|
|||
break;
|
||||
}
|
||||
con->fntsz = 16;
|
||||
gfx_clear_partial_grey(con->gfx_ctxt, 0x1B, 0, 1256);
|
||||
gfx_clear_partial_grey(con->gfx_ctxt, 0x1B, 0, con->gfx_ctxt->height - 24);
|
||||
#ifdef MENU_LOGO_ENABLE
|
||||
gfx_set_rect_rgb(con->gfx_ctxt, Kc_MENU_LOGO,
|
||||
X_MENU_LOGO, Y_MENU_LOGO, X_POS_MENU_LOGO, Y_POS_MENU_LOGO);
|
||||
|
|
|
@ -424,7 +424,7 @@ void reconfig_hw_workaround(bool extra_reconfig)
|
|||
|
||||
void print_fuseinfo()
|
||||
{
|
||||
gfx_clear_partial_grey(&gfx_ctxt, 0x1B, 0, 1256);
|
||||
gfx_clear_partial_grey(&gfx_ctxt, 0x1B, 0, gfx_ctxt.height - 24);
|
||||
gfx_con_setpos(&gfx_con, 0, 0);
|
||||
|
||||
u32 burntFuses = 0;
|
||||
|
@ -472,7 +472,7 @@ void print_fuseinfo()
|
|||
|
||||
void print_kfuseinfo()
|
||||
{
|
||||
gfx_clear_partial_grey(&gfx_ctxt, 0x1B, 0, 1256);
|
||||
gfx_clear_partial_grey(&gfx_ctxt, 0x1B, 0, gfx_ctxt.height - 24);
|
||||
gfx_con_setpos(&gfx_con, 0, 0);
|
||||
|
||||
gfx_printf(&gfx_con, "%kKFuse contents:\n\n%k", 0xFF00DDFF, 0xFFCCCCCC);
|
||||
|
@ -502,7 +502,7 @@ void print_kfuseinfo()
|
|||
|
||||
void print_mmc_info()
|
||||
{
|
||||
gfx_clear_partial_grey(&gfx_ctxt, 0x1B, 0, 1256);
|
||||
gfx_clear_partial_grey(&gfx_ctxt, 0x1B, 0, gfx_ctxt.height - 24);
|
||||
gfx_con_setpos(&gfx_con, 0, 0);
|
||||
|
||||
static const u32 SECTORS_TO_MIB_COEFF = 11;
|
||||
|
@ -660,7 +660,7 @@ void print_sdcard_info()
|
|||
{
|
||||
static const u32 SECTORS_TO_MIB_COEFF = 11;
|
||||
|
||||
gfx_clear_partial_grey(&gfx_ctxt, 0x1B, 0, 1256);
|
||||
gfx_clear_partial_grey(&gfx_ctxt, 0x1B, 0, gfx_ctxt.height - 24);
|
||||
gfx_con_setpos(&gfx_con, 0, 0);
|
||||
|
||||
if (sd_mount())
|
||||
|
@ -712,7 +712,7 @@ void print_sdcard_info()
|
|||
|
||||
void print_tsec_key()
|
||||
{
|
||||
gfx_clear_partial_grey(&gfx_ctxt, 0x1B, 0, 1256);
|
||||
gfx_clear_partial_grey(&gfx_ctxt, 0x1B, 0, gfx_ctxt.height - 24);
|
||||
gfx_con_setpos(&gfx_con, 0, 0);
|
||||
|
||||
sdmmc_storage_t storage;
|
||||
|
@ -1228,7 +1228,7 @@ static void dump_emmc_selected(emmcPartType_t dumpType)
|
|||
{
|
||||
int res = 0;
|
||||
u32 timer = 0;
|
||||
gfx_clear_partial_grey(&gfx_ctxt, 0x1B, 0, 1256);
|
||||
gfx_clear_partial_grey(&gfx_ctxt, 0x1B, 0, gfx_ctxt.height - 24);
|
||||
tui_sbar(&gfx_con, true);
|
||||
gfx_con_setpos(&gfx_con, 0, 0);
|
||||
|
||||
|
@ -1467,7 +1467,7 @@ static void restore_emmc_selected(emmcPartType_t restoreType)
|
|||
{
|
||||
int res = 0;
|
||||
u32 timer = 0;
|
||||
gfx_clear_partial_grey(&gfx_ctxt, 0x1B, 0, 1256);
|
||||
gfx_clear_partial_grey(&gfx_ctxt, 0x1B, 0, gfx_ctxt.height - 24);
|
||||
tui_sbar(&gfx_con, true);
|
||||
gfx_con_setpos(&gfx_con, 0, 0);
|
||||
|
||||
|
@ -1600,7 +1600,7 @@ void dump_packages12()
|
|||
u8 *loader = (u8 *)calloc(1, 0x40000);
|
||||
u8 *pkg2 = NULL;
|
||||
|
||||
gfx_clear_partial_grey(&gfx_ctxt, 0x1B, 0, 1256);
|
||||
gfx_clear_partial_grey(&gfx_ctxt, 0x1B, 0, gfx_ctxt.height - 24);
|
||||
gfx_con_setpos(&gfx_con, 0, 0);
|
||||
|
||||
if (!sd_mount())
|
||||
|
@ -2428,7 +2428,7 @@ void toggle_autorcm(bool enable)
|
|||
sdmmc_storage_t storage;
|
||||
sdmmc_t sdmmc;
|
||||
|
||||
gfx_clear_partial_grey(&gfx_ctxt, 0x1B, 0, 1256);
|
||||
gfx_clear_partial_grey(&gfx_ctxt, 0x1B, 0, gfx_ctxt.height - 24);
|
||||
gfx_con_setpos(&gfx_con, 0, 0);
|
||||
|
||||
if (!sdmmc_storage_init_mmc(&storage, &sdmmc, SDMMC_4, SDMMC_BUS_WIDTH_8, 4))
|
||||
|
@ -2600,7 +2600,7 @@ int fix_attributes(char *path, u32 *total, u32 is_root, u32 check_first_run)
|
|||
|
||||
void fix_sd_attr(u32 type)
|
||||
{
|
||||
gfx_clear_partial_grey(&gfx_ctxt, 0x1B, 0, 1256);
|
||||
gfx_clear_partial_grey(&gfx_ctxt, 0x1B, 0, gfx_ctxt.height - 24);
|
||||
gfx_con_setpos(&gfx_con, 0, 0);
|
||||
|
||||
char path[256];
|
||||
|
@ -2756,7 +2756,7 @@ void print_battery_charger_info()
|
|||
|
||||
void print_battery_info()
|
||||
{
|
||||
gfx_clear_partial_grey(&gfx_ctxt, 0x1B, 0, 1256);
|
||||
gfx_clear_partial_grey(&gfx_ctxt, 0x1B, 0, gfx_ctxt.height - 24);
|
||||
gfx_con_setpos(&gfx_con, 0, 0);
|
||||
|
||||
print_fuel_gauge_info();
|
||||
|
@ -2799,7 +2799,7 @@ void print_battery_info()
|
|||
|
||||
/* void fix_fuel_gauge_configuration()
|
||||
{
|
||||
gfx_clear_partial_grey(&gfx_ctxt, 0x1B, 0, 1256);
|
||||
gfx_clear_partial_grey(&gfx_ctxt, 0x1B, 0, gfx_ctxt.height - 24);
|
||||
gfx_con_setpos(&gfx_con, 0, 0);
|
||||
|
||||
int battVoltage, avgCurrent;
|
||||
|
@ -2852,7 +2852,7 @@ void print_battery_info()
|
|||
{
|
||||
int avgCurrent;
|
||||
|
||||
gfx_clear_partial_grey(&gfx_ctxt, 0x1B, 0, 1256);
|
||||
gfx_clear_partial_grey(&gfx_ctxt, 0x1B, 0, gfx_ctxt.height - 24);
|
||||
gfx_con_setpos(&gfx_con, 0, 0);
|
||||
|
||||
gfx_printf(&gfx_con, "%k\nThis will wipe your battery stats completely!\n"
|
||||
|
@ -2863,7 +2863,7 @@ void print_battery_info()
|
|||
u32 btn = btn_wait();
|
||||
if (btn & BTN_POWER)
|
||||
{
|
||||
gfx_clear_partial_grey(&gfx_ctxt, 0x1B, 0, 1256);
|
||||
gfx_clear_partial_grey(&gfx_ctxt, 0x1B, 0, gfx_ctxt.height - 24);
|
||||
gfx_con_setpos(&gfx_con, 0, 0);
|
||||
gfx_printf(&gfx_con, "%kKeep the USB cable connected!%k\n\n", 0xFFFFDD00, 0xFFCCCCCC);
|
||||
gfx_con_getpos(&gfx_con, &gfx_con.savedx, &gfx_con.savedy);
|
||||
|
@ -2898,7 +2898,7 @@ void print_battery_info()
|
|||
|
||||
void fix_battery_desync()
|
||||
{
|
||||
gfx_clear_partial_grey(&gfx_ctxt, 0x1B, 0, 1256);
|
||||
gfx_clear_partial_grey(&gfx_ctxt, 0x1B, 0, gfx_ctxt.height - 24);
|
||||
gfx_con_setpos(&gfx_con, 0, 0);
|
||||
|
||||
max77620_low_battery_monitor_config();
|
||||
|
@ -3099,7 +3099,7 @@ void ipl_main()
|
|||
display_init();
|
||||
|
||||
u32 *fb = display_init_framebuffer();
|
||||
gfx_init_ctxt(&gfx_ctxt, fb, 720, 1280, 768);
|
||||
gfx_init_ctxt(&gfx_ctxt, fb, 720, 1280, 768, true);
|
||||
|
||||
#ifdef MENU_LOGO_ENABLE
|
||||
Kc_MENU_LOGO = (u8 *)malloc(0x6000);
|
||||
|
|
|
@ -27,6 +27,7 @@ typedef struct _gfx_ctxt_t
|
|||
u32 width;
|
||||
u32 height;
|
||||
u32 stride;
|
||||
bool landscape;
|
||||
} gfx_ctxt_t;
|
||||
|
||||
typedef struct _gfx_con_t
|
||||
|
|
Loading…
Add table
Reference in a new issue