restored low battery overlay
This commit is contained in:
parent
07720acd4b
commit
4bafdcf75a
2 changed files with 63 additions and 58 deletions
117
src/common/api.c
117
src/common/api.c
|
|
@ -99,6 +99,7 @@ static void ion_free(int fd_ion, ion_alloc_info_t* info) {
|
||||||
|
|
||||||
#define DE (0xB02E0000)
|
#define DE (0xB02E0000)
|
||||||
#define DE_SIZE (0x00002000)
|
#define DE_SIZE (0x00002000)
|
||||||
|
static int de_enable_overlay = 0;
|
||||||
enum {
|
enum {
|
||||||
DE_SCOEF_NONE,
|
DE_SCOEF_NONE,
|
||||||
DE_SCOEF_CRISPY,
|
DE_SCOEF_CRISPY,
|
||||||
|
|
@ -164,7 +165,7 @@ static void DE_setScaleCoef(uint32_t* de_mem, int plane, int scale) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static void DE_enableLayer(uint32_t* de_mem) {
|
static void DE_enableLayer(uint32_t* de_mem) {
|
||||||
de_mem[DE_PATH_CTL(0)/4] = 0x30100000 | (de_mem[DE_PATH_CTL(0)/4] & 0xCF0FFFFF);
|
de_mem[DE_PATH_CTL(0)/4] = (de_enable_overlay?0x30300000:0x30100000) | (de_mem[DE_PATH_CTL(0)/4] & 0xCF0FFFFF);
|
||||||
}
|
}
|
||||||
static void DE_setRect(uint32_t* de_mem, int x, int y, int w, int h) {
|
static void DE_setRect(uint32_t* de_mem, int x, int y, int w, int h) {
|
||||||
de_mem[(DE_OVL_OSIZE(0))/4] = ((w-1)&0xFFFF) | ((h-1)<<16);
|
de_mem[(DE_OVL_OSIZE(0))/4] = ((w-1)&0xFFFF) | ((h-1)<<16);
|
||||||
|
|
@ -358,6 +359,7 @@ static struct POW_Context {
|
||||||
struct owlfb_overlay_info oinfo;
|
struct owlfb_overlay_info oinfo;
|
||||||
|
|
||||||
SDL_Surface* overlay;
|
SDL_Surface* overlay;
|
||||||
|
ion_alloc_info_t ov_info;
|
||||||
} pow;
|
} pow;
|
||||||
|
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
|
|
@ -519,7 +521,6 @@ static void POW_flipOverlay(void);
|
||||||
void GFX_flip(SDL_Surface* screen) {
|
void GFX_flip(SDL_Surface* screen) {
|
||||||
gfx.de_mem[DE_OVL_BA0(0)/4] = gfx.de_mem[DE_OVL_BA0(2)/4] = (uintptr_t)(gfx.fb_info.padd + gfx.page * PAGE_SIZE);
|
gfx.de_mem[DE_OVL_BA0(0)/4] = gfx.de_mem[DE_OVL_BA0(2)/4] = (uintptr_t)(gfx.fb_info.padd + gfx.page * PAGE_SIZE);
|
||||||
DE_enableLayer(gfx.de_mem);
|
DE_enableLayer(gfx.de_mem);
|
||||||
POW_flipOverlay();
|
|
||||||
|
|
||||||
if (gfx.vsync!=VSYNC_OFF) {
|
if (gfx.vsync!=VSYNC_OFF) {
|
||||||
// this limiting condition helps SuperFX chip games
|
// this limiting condition helps SuperFX chip games
|
||||||
|
|
@ -1329,63 +1330,62 @@ int VIB_getStrength(void) {
|
||||||
#define OVERLAY_FB 0
|
#define OVERLAY_FB 0
|
||||||
#define OVERLAY_ID 1
|
#define OVERLAY_ID 1
|
||||||
static void POW_initOverlay(void) {
|
static void POW_initOverlay(void) {
|
||||||
// // setup surface
|
// setup surface
|
||||||
// pow.overlay = SDL_CreateRGBSurfaceFrom(NULL,SCALE2(OVERLAY_WIDTH,OVERLAY_HEIGHT),OVERLAY_DEPTH,SCALE1(OVERLAY_PITCH), OVERLAY_RGBA_MASK);
|
pow.overlay = SDL_CreateRGBSurfaceFrom(NULL,SCALE2(OVERLAY_WIDTH,OVERLAY_HEIGHT),OVERLAY_DEPTH,SCALE1(OVERLAY_PITCH), OVERLAY_RGBA_MASK);
|
||||||
// uint32_t size = pow.overlay->h * pow.overlay->pitch;
|
uint32_t size = pow.overlay->h * pow.overlay->pitch;
|
||||||
// uint32_t offset = (gfx.fb_info.size - size)&(~4095);
|
pow.ov_info.size = size;
|
||||||
// pow.overlay->pixels = gfx.fb_info.vadd + offset;
|
ion_alloc(gfx.fd_ion, &pow.ov_info);
|
||||||
// memset(pow.overlay->pixels, 0xff, size);
|
pow.overlay->pixels = pow.ov_info.vadd;
|
||||||
//
|
memset(pow.overlay->pixels, 0xff, size);
|
||||||
// // draw battery
|
|
||||||
// SDL_SetAlpha(gfx.assets, 0,0);
|
// draw battery
|
||||||
// GFX_blitAsset(ASSET_BLACK_PILL, NULL, pow.overlay, NULL);
|
SDL_SetAlpha(gfx.assets, 0,0);
|
||||||
// SDL_SetAlpha(gfx.assets, SDL_SRCALPHA,0);
|
GFX_blitAsset(ASSET_BLACK_PILL, NULL, pow.overlay, NULL);
|
||||||
// GFX_blitBattery(pow.overlay, NULL);
|
SDL_SetAlpha(gfx.assets, SDL_SRCALPHA,0);
|
||||||
//
|
GFX_blitBattery(pow.overlay, NULL);
|
||||||
// // setup overlay
|
|
||||||
// memset(&pow.oargs, 0, sizeof(struct owlfb_overlay_args));
|
// setup overlay
|
||||||
// pow.oargs.fb_id = OVERLAY_FB;
|
memset(&pow.oargs, 0, sizeof(struct owlfb_overlay_args));
|
||||||
// pow.oargs.overlay_id = OVERLAY_ID;
|
pow.oargs.fb_id = OVERLAY_FB;
|
||||||
// pow.oargs.overlay_type = OWLFB_OVERLAY_VIDEO;
|
pow.oargs.overlay_id = OVERLAY_ID;
|
||||||
// pow.oargs.uintptr_overly_info = (uintptr_t)&pow.oinfo;
|
pow.oargs.overlay_type = OWLFB_OVERLAY_VIDEO;
|
||||||
//
|
pow.oargs.uintptr_overly_info = (uintptr_t)&pow.oinfo;
|
||||||
// int x,y,w,h;
|
|
||||||
// w = h = pow.overlay->w;
|
int x,y,w,h;
|
||||||
// x = SCREEN_WIDTH - SCALE1(PADDING) - w;
|
w = h = pow.overlay->w;
|
||||||
// y = SCALE1(PADDING);
|
x = SCREEN_WIDTH - SCALE1(PADDING) - w;
|
||||||
//
|
y = SCALE1(PADDING);
|
||||||
// pow.oinfo.mem_off = offset;
|
|
||||||
// pow.oinfo.mem_size = size;
|
pow.oinfo.mem_off = (uintptr_t)pow.ov_info.padd - gfx.finfo.smem_start;
|
||||||
// pow.oinfo.screen_width = PAGE_WIDTH; // ???
|
pow.oinfo.mem_size = size;
|
||||||
// pow.oinfo.color_mode = OWL_DSS_COLOR_ARGB32;
|
pow.oinfo.screen_width = PAGE_WIDTH; // ???
|
||||||
// pow.oinfo.img_width = w;
|
pow.oinfo.color_mode = OWL_DSS_COLOR_ARGB32;
|
||||||
// pow.oinfo.img_height = h;
|
pow.oinfo.img_width = w;
|
||||||
// pow.oinfo.xoff = 0;
|
pow.oinfo.img_height = h;
|
||||||
// pow.oinfo.yoff = 0;
|
pow.oinfo.xoff = 0;
|
||||||
// pow.oinfo.width = w;
|
pow.oinfo.yoff = 0;
|
||||||
// pow.oinfo.height = h;
|
pow.oinfo.width = w;
|
||||||
// pow.oinfo.rotation = 0;
|
pow.oinfo.height = h;
|
||||||
// pow.oinfo.pos_x = x; // position
|
pow.oinfo.rotation = 0;
|
||||||
// pow.oinfo.pos_y = y; //
|
pow.oinfo.pos_x = x; // position
|
||||||
// pow.oinfo.out_width = w; // scaled size
|
pow.oinfo.pos_y = y; //
|
||||||
// pow.oinfo.out_height = h; //
|
pow.oinfo.out_width = w; // scaled size
|
||||||
// pow.oinfo.global_alpha_en = 0;
|
pow.oinfo.out_height = h; //
|
||||||
// pow.oinfo.global_alpha = 0;
|
pow.oinfo.global_alpha_en = 0;
|
||||||
// pow.oinfo.pre_mult_alpha_en = 0;
|
pow.oinfo.global_alpha = 0;
|
||||||
// pow.oinfo.zorder = 3;
|
pow.oinfo.pre_mult_alpha_en = 0;
|
||||||
}
|
pow.oinfo.zorder = 3;
|
||||||
static void POW_flipOverlay(void) {
|
|
||||||
// if (pow.should_warn && pow.charge<=POW_LOW_CHARGE) ioctl(gfx.fd_fb, OWLFB_OVERLAY_SETINFO, &pow.oargs);
|
|
||||||
}
|
}
|
||||||
static void POW_quitOverlay(void) {
|
static void POW_quitOverlay(void) {
|
||||||
// if (pow.overlay) SDL_FreeSurface(pow.overlay);
|
if (pow.overlay) SDL_FreeSurface(pow.overlay);
|
||||||
//
|
ion_free(gfx.fd_ion, &pow.ov_info);
|
||||||
// memset(&pow.oargs, 0, sizeof(struct owlfb_overlay_args));
|
|
||||||
// pow.oargs.fb_id = OVERLAY_FB;
|
memset(&pow.oargs, 0, sizeof(struct owlfb_overlay_args));
|
||||||
// pow.oargs.overlay_id = OVERLAY_ID;
|
pow.oargs.fb_id = OVERLAY_FB;
|
||||||
// pow.oargs.overlay_type = OWLFB_OVERLAY_VIDEO;
|
pow.oargs.overlay_id = OVERLAY_ID;
|
||||||
// pow.oargs.uintptr_overly_info = 0;
|
pow.oargs.overlay_type = OWLFB_OVERLAY_VIDEO;
|
||||||
// ioctl(gfx.fd_fb, OWLFB_OVERLAY_DISABLE, &pow.oargs);
|
pow.oargs.uintptr_overly_info = 0;
|
||||||
|
ioctl(gfx.fd_fb, OWLFB_OVERLAY_DISABLE, &pow.oargs);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void POW_updateBatteryStatus(void) {
|
static void POW_updateBatteryStatus(void) {
|
||||||
|
|
@ -1405,6 +1405,8 @@ static void POW_updateBatteryStatus(void) {
|
||||||
|
|
||||||
// LOG_info("battery charge: %i (%i) charging: %i\n", pow.charge, i, pow.is_charging);
|
// LOG_info("battery charge: %i (%i) charging: %i\n", pow.charge, i, pow.is_charging);
|
||||||
// pow.charge = POW_LOW_CHARGE;
|
// pow.charge = POW_LOW_CHARGE;
|
||||||
|
|
||||||
|
de_enable_overlay = pow.should_warn && pow.charge<=POW_LOW_CHARGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void* POW_monitorBattery(void *arg) {
|
static void* POW_monitorBattery(void *arg) {
|
||||||
|
|
@ -1437,6 +1439,7 @@ void POW_quit(void) {
|
||||||
}
|
}
|
||||||
void POW_warn(int enable) {
|
void POW_warn(int enable) {
|
||||||
pow.should_warn = enable;
|
pow.should_warn = enable;
|
||||||
|
de_enable_overlay = pow.should_warn && pow.charge<=POW_LOW_CHARGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void POW_update(int* _dirty, int* _show_setting, POW_callback_t before_sleep, POW_callback_t after_sleep) {
|
void POW_update(int* _dirty, int* _show_setting, POW_callback_t before_sleep, POW_callback_t after_sleep) {
|
||||||
|
|
|
||||||
4
todo.txt
4
todo.txt
|
|
@ -5,7 +5,8 @@
|
||||||
Please see the README.txt in the zip file for installation and update instructions.
|
Please see the README.txt in the zip file for installation and update instructions.
|
||||||
|
|
||||||
**Base**
|
**Base**
|
||||||
- removed incomplete hdmi support (won't support codepath I won't use, ergonomics are all wrong)
|
- removed incomplete hdmi support (won't support codepaths I won't use, ergonomics are all wrong)
|
||||||
|
- restored low battery overlay
|
||||||
|
|
||||||
**Extras**
|
**Extras**
|
||||||
-
|
-
|
||||||
|
|
@ -75,6 +76,7 @@ cores
|
||||||
would need to set up disabling autosleep and
|
would need to set up disabling autosleep and
|
||||||
warning about lack of autosave and
|
warning about lack of autosave and
|
||||||
update ui for lack of save states, etc
|
update ui for lack of save states, etc
|
||||||
|
blech, getting pretty tired of all of this
|
||||||
|
|
||||||
|
|
||||||
Union-ize this?
|
Union-ize this?
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue