mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 22:20:21 +00:00
(CTR) C89 conformity cleanups
This commit is contained in:
parent
514ed00f2d
commit
69e8416e45
@ -172,7 +172,7 @@ static void ctr_free_overlay(ctr_video_t *ctr)
|
||||
}
|
||||
|
||||
free(ctr->overlay);
|
||||
ctr->overlay = NULL;
|
||||
ctr->overlay = NULL;
|
||||
ctr->overlays = 0;
|
||||
}
|
||||
#endif
|
||||
@ -227,17 +227,17 @@ static void ctr_update_viewport(
|
||||
}
|
||||
else if (device_aspect > desired_aspect)
|
||||
{
|
||||
delta = (desired_aspect / device_aspect - 1.0f)
|
||||
delta = (desired_aspect / device_aspect - 1.0f)
|
||||
/ 2.0f + 0.5f;
|
||||
x = (int)roundf(width * (0.5f - delta));
|
||||
width = (unsigned)roundf(2.0f * width * delta);
|
||||
x = (int)roundf(width * (0.5f - delta));
|
||||
width = (unsigned)roundf(2.0f * width * delta);
|
||||
}
|
||||
else
|
||||
{
|
||||
delta = (device_aspect / desired_aspect - 1.0f)
|
||||
delta = (device_aspect / desired_aspect - 1.0f)
|
||||
/ 2.0f + 0.5f;
|
||||
y = (int)roundf(height * (0.5f - delta));
|
||||
height = (unsigned)roundf(2.0f * height * delta);
|
||||
y = (int)roundf(height * (0.5f - delta));
|
||||
height = (unsigned)roundf(2.0f * height * delta);
|
||||
}
|
||||
}
|
||||
|
||||
@ -248,8 +248,9 @@ static void ctr_update_viewport(
|
||||
}
|
||||
else
|
||||
{
|
||||
ctr->vp.x = ctr->vp.y = 0;
|
||||
ctr->vp.width = width;
|
||||
ctr->vp.x = 0;
|
||||
ctr->vp.y = 0;
|
||||
ctr->vp.width = width;
|
||||
ctr->vp.height = height;
|
||||
}
|
||||
|
||||
@ -268,8 +269,8 @@ static const char *ctr_texture_path(unsigned id)
|
||||
case CTR_TEXTURE_STATE_THUMBNAIL:
|
||||
{
|
||||
static char texture_path[PATH_MAX_LENGTH];
|
||||
|
||||
char state_path[PATH_MAX_LENGTH];
|
||||
|
||||
if (!retroarch_get_current_savestate_path(state_path,
|
||||
sizeof(state_path)))
|
||||
return NULL;
|
||||
@ -279,6 +280,8 @@ static const char *ctr_texture_path(unsigned id)
|
||||
|
||||
return path_basename(texture_path);
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@ -287,10 +290,8 @@ static const char *ctr_texture_path(unsigned id)
|
||||
static void ctr_update_state_date(void *data)
|
||||
{
|
||||
ctr_video_t *ctr = (ctr_video_t*)data;
|
||||
|
||||
time_t now = time(NULL);
|
||||
|
||||
struct tm *t = localtime(&now);
|
||||
time_t now = time(NULL);
|
||||
struct tm *t = localtime(&now);
|
||||
sprintf(ctr->state_date, "%02d/%02d/%d",
|
||||
t->tm_mon + 1, t->tm_mday, t->tm_year + 1900);
|
||||
}
|
||||
@ -298,18 +299,27 @@ static void ctr_update_state_date(void *data)
|
||||
static bool ctr_update_state_date_from_file(void *data)
|
||||
{
|
||||
char state_path[PATH_MAX_LENGTH];
|
||||
#ifdef USE_CTRULIB_2
|
||||
time_t mtime;
|
||||
struct tm *t = NULL;
|
||||
bool file_exists = false;
|
||||
#else
|
||||
time_t ft;
|
||||
u64 mtime;
|
||||
struct tm *t = NULL;
|
||||
#endif
|
||||
ctr_video_t *ctr = (ctr_video_t*)data;
|
||||
|
||||
if (!retroarch_get_current_savestate_path(state_path, sizeof(state_path)))
|
||||
if (!retroarch_get_current_savestate_path(
|
||||
state_path, sizeof(state_path)))
|
||||
return false;
|
||||
|
||||
#ifdef USE_CTRULIB_2
|
||||
time_t mtime;
|
||||
bool file_exists = archive_getmtime(state_path + 5, &mtime) == 0;
|
||||
file_exists = archive_getmtime(state_path + 5, &mtime) == 0;
|
||||
#else
|
||||
u64 mtime;
|
||||
bool file_exists = sdmc_getmtime(state_path + 5, &mtime) == 0;
|
||||
file_exists = sdmc_getmtime(state_path + 5, &mtime) == 0;
|
||||
#endif
|
||||
|
||||
if (!file_exists)
|
||||
{
|
||||
ctr->state_data_exist = false;
|
||||
@ -320,10 +330,10 @@ static bool ctr_update_state_date_from_file(void *data)
|
||||
ctr->state_data_exist = true;
|
||||
|
||||
#ifdef USE_CTRULIB_2
|
||||
struct tm *t = localtime(&mtime);
|
||||
t = localtime(&mtime);
|
||||
#else
|
||||
time_t ft = mtime;
|
||||
struct tm *t = localtime(&ft);
|
||||
ft = mtime;
|
||||
t = localtime(&ft);
|
||||
#endif
|
||||
sprintf(ctr->state_date, "%02d/%02d/%d",
|
||||
t->tm_mon + 1, t->tm_mday, t->tm_year + 1900);
|
||||
@ -333,11 +343,14 @@ static bool ctr_update_state_date_from_file(void *data)
|
||||
|
||||
static void ctr_state_thumbnail_geom(void *data)
|
||||
{
|
||||
ctr_video_t *ctr = (ctr_video_t *) data;
|
||||
struct ctr_bottom_texture_data *o = NULL;
|
||||
const int target_width = 120;
|
||||
const int target_height = 90;
|
||||
float scale;
|
||||
unsigned width, height;
|
||||
int x_offset, y_offset;
|
||||
ctr_texture_t *texture = NULL;
|
||||
ctr_video_t *ctr = (ctr_video_t *)data;
|
||||
struct ctr_bottom_texture_data *o = NULL;
|
||||
const int target_width = 120;
|
||||
const int target_height = 90;
|
||||
|
||||
if (ctr)
|
||||
o = &ctr->bottom_textures[CTR_TEXTURE_STATE_THUMBNAIL];
|
||||
@ -345,27 +358,28 @@ static void ctr_state_thumbnail_geom(void *data)
|
||||
if (!o)
|
||||
return;
|
||||
|
||||
ctr_texture_t *texture = (ctr_texture_t *) o->texture;
|
||||
if (!texture)
|
||||
if (!(texture = (ctr_texture_t *) o->texture))
|
||||
return;
|
||||
|
||||
float scale = (float) target_width / texture->active_width;
|
||||
if (target_width > texture->active_width * scale) {
|
||||
scale = (float) (target_width + 1) / texture->active_width;
|
||||
}
|
||||
scale = (float)target_width / texture->active_width;
|
||||
if (target_width > texture->active_width * scale)
|
||||
scale = (float)(target_width + 1) / texture->active_width;
|
||||
|
||||
o->frame_coords->u0 = 0;
|
||||
o->frame_coords->v0 = 0;
|
||||
o->frame_coords->u1 = texture->active_width;
|
||||
o->frame_coords->v1 = texture->active_height;
|
||||
|
||||
int x_offset = 184;
|
||||
int y_offset = 46 + (target_height - texture->active_height * scale) / 2;
|
||||
x_offset = 184;
|
||||
y_offset = 46 +
|
||||
(target_height - texture->active_height * scale) / 2;
|
||||
|
||||
o->frame_coords->x0 = x_offset;
|
||||
o->frame_coords->y0 = y_offset;
|
||||
o->frame_coords->x1 = o->frame_coords->x0 + texture->active_width * scale;
|
||||
o->frame_coords->y1 = o->frame_coords->y0 + texture->active_height * scale;
|
||||
o->frame_coords->x1 = o->frame_coords->x0
|
||||
+ texture->active_width * scale;
|
||||
o->frame_coords->y1 = o->frame_coords->y0
|
||||
+ texture->active_height * scale;
|
||||
|
||||
ctr_set_scale_vector(&o->scale_vector,
|
||||
CTR_BOTTOM_FRAMEBUFFER_WIDTH,
|
||||
@ -377,10 +391,9 @@ static void ctr_state_thumbnail_geom(void *data)
|
||||
static bool ctr_load_bottom_texture(void *data)
|
||||
{
|
||||
unsigned i;
|
||||
const char *dir_assets;
|
||||
|
||||
ctr_video_t *ctr = (ctr_video_t *)data;
|
||||
settings_t *settings = config_get_ptr();
|
||||
const char *dir_assets = NULL;
|
||||
ctr_video_t *ctr = (ctr_video_t *)data;
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
for (i = 0; i < CTR_TEXTURE_LAST; i++)
|
||||
{
|
||||
@ -432,9 +445,8 @@ static bool ctr_load_bottom_texture(void *data)
|
||||
|
||||
static void save_state_to_file(void *data)
|
||||
{
|
||||
ctr_video_t *ctr = (ctr_video_t*)data;
|
||||
|
||||
char state_path[PATH_MAX_LENGTH];
|
||||
ctr_video_t *ctr = (ctr_video_t*)data;
|
||||
retroarch_get_current_savestate_path(state_path, sizeof(state_path));
|
||||
|
||||
command_event(CMD_EVENT_RAM_STATE_TO_FILE, state_path);
|
||||
@ -443,10 +455,10 @@ static void save_state_to_file(void *data)
|
||||
static void bottom_menu_control(void* data, bool lcd_bottom)
|
||||
{
|
||||
touchPosition state_tmp_touch;
|
||||
uint32_t state_tmp = 0;
|
||||
ctr_video_t *ctr = (ctr_video_t*)data;
|
||||
uint32_t state_tmp = 0;
|
||||
ctr_video_t *ctr = (ctr_video_t*)data;
|
||||
settings_t *settings = config_get_ptr();
|
||||
int config_slot = settings->ints.state_slot;
|
||||
int config_slot = settings->ints.state_slot;
|
||||
|
||||
if (!ctr->init_bottom_menu)
|
||||
{
|
||||
@ -475,9 +487,10 @@ static void bottom_menu_control(void* data, bool lcd_bottom)
|
||||
hidTouchRead(&state_tmp_touch);
|
||||
if (!state_tmp)
|
||||
{
|
||||
if (!ctr->bottom_check_idle && !ctr->bottom_is_idle)
|
||||
if ( !ctr->bottom_check_idle
|
||||
&& !ctr->bottom_is_idle)
|
||||
{
|
||||
ctr->idle_timestamp = svcGetSystemTick();
|
||||
ctr->idle_timestamp = svcGetSystemTick();
|
||||
ctr->bottom_check_idle = true;
|
||||
}
|
||||
}
|
||||
@ -488,8 +501,8 @@ static void bottom_menu_control(void* data, bool lcd_bottom)
|
||||
return;
|
||||
#endif
|
||||
|
||||
if (!lcd_bottom ||
|
||||
ctr->bottom_menu == CTR_BOTTOM_MENU_NOT_AVAILABLE)
|
||||
if ( !lcd_bottom
|
||||
|| ctr->bottom_menu == CTR_BOTTOM_MENU_NOT_AVAILABLE)
|
||||
{
|
||||
BIT64_SET(lifecycle_state, RARCH_MENU_TOGGLE);
|
||||
return;
|
||||
@ -499,14 +512,14 @@ static void bottom_menu_control(void* data, bool lcd_bottom)
|
||||
{
|
||||
ctr->bottom_is_idle = false;
|
||||
ctr->bottom_is_fading = false;
|
||||
fadeCount = 256;
|
||||
fadeCount = 256;
|
||||
ctr_set_bottom_screen_enable(true,true);
|
||||
}
|
||||
else if (ctr->bottom_check_idle)
|
||||
{
|
||||
ctr->bottom_check_idle = false;
|
||||
ctr->bottom_is_fading = false;
|
||||
fadeCount = 256;
|
||||
fadeCount = 256;
|
||||
}
|
||||
|
||||
switch (ctr->bottom_menu)
|
||||
@ -531,23 +544,25 @@ static void bottom_menu_control(void* data, bool lcd_bottom)
|
||||
|
||||
struct ctr_bottom_texture_data *o =
|
||||
&ctr->bottom_textures[CTR_TEXTURE_STATE_THUMBNAIL];
|
||||
ctr_texture_t *texture =
|
||||
(ctr_texture_t *) o->texture;
|
||||
|
||||
ctr_texture_t *texture = (ctr_texture_t *) o->texture;
|
||||
if (texture)
|
||||
linearFree(texture->data);
|
||||
else
|
||||
{
|
||||
o->texture = (uintptr_t) calloc(1, sizeof(ctr_texture_t));
|
||||
o->texture = (uintptr_t)
|
||||
calloc(1, sizeof(ctr_texture_t));
|
||||
o->frame_coords = linearAlloc(sizeof(ctr_vertex_t));
|
||||
texture = (ctr_texture_t *) o->texture;
|
||||
texture = (ctr_texture_t *)o->texture;
|
||||
}
|
||||
|
||||
texture->width = ctr->texture_width;
|
||||
texture->height = ctr->texture_width;
|
||||
texture->active_width = ctr->frame_coords->u1;
|
||||
texture->width = ctr->texture_width;
|
||||
texture->height = ctr->texture_width;
|
||||
texture->active_width = ctr->frame_coords->u1;
|
||||
texture->active_height = ctr->frame_coords->v1;
|
||||
|
||||
texture->data = linearAlloc(
|
||||
texture->data = linearAlloc(
|
||||
ctr->texture_width * ctr->texture_height *
|
||||
(ctr->rgb32? 4:2));
|
||||
|
||||
@ -557,7 +572,7 @@ static void bottom_menu_control(void* data, bool lcd_bottom)
|
||||
|
||||
ctr_state_thumbnail_geom(ctr);
|
||||
|
||||
ctr->state_data_exist = true;
|
||||
ctr->state_data_exist = true;
|
||||
ctr->render_state_from_png_file = false;
|
||||
|
||||
ctr_update_state_date(ctr);
|
||||
@ -577,11 +592,12 @@ static void bottom_menu_control(void* data, bool lcd_bottom)
|
||||
|
||||
BIT64_SET(lifecycle_state, RARCH_MENU_TOGGLE);
|
||||
}
|
||||
else if (state_tmp_touch.px > 176 &&
|
||||
state_tmp_touch.px < 311 &&
|
||||
state_tmp_touch.py > 9 &&
|
||||
state_tmp_touch.py < 230 &&
|
||||
ctr->state_data_exist)
|
||||
else if (
|
||||
state_tmp_touch.px > 176
|
||||
&& state_tmp_touch.px < 311
|
||||
&& state_tmp_touch.py > 9
|
||||
&& state_tmp_touch.py < 230
|
||||
&& ctr->state_data_exist)
|
||||
{
|
||||
if (!command_event(CMD_EVENT_LOAD_STATE_FROM_RAM, NULL))
|
||||
command_event(CMD_EVENT_LOAD_STATE, NULL);
|
||||
@ -600,12 +616,15 @@ static void bottom_menu_control(void* data, bool lcd_bottom)
|
||||
|
||||
if (ctr->state_slot != config_slot)
|
||||
{
|
||||
ctr_texture_t *texture = NULL;
|
||||
struct ctr_bottom_texture_data *o = NULL;
|
||||
|
||||
save_state_to_file(ctr);
|
||||
|
||||
ctr->state_slot = config_slot;
|
||||
|
||||
struct ctr_bottom_texture_data *o = &ctr->bottom_textures[CTR_TEXTURE_STATE_THUMBNAIL];
|
||||
ctr_texture_t *texture = (ctr_texture_t *) o->texture;
|
||||
ctr->state_slot = config_slot;
|
||||
o =
|
||||
&ctr->bottom_textures[CTR_TEXTURE_STATE_THUMBNAIL];
|
||||
texture = (ctr_texture_t *)o->texture;
|
||||
|
||||
if (texture)
|
||||
{
|
||||
@ -651,8 +670,7 @@ static void font_driver_render_msg_bottom(
|
||||
const void *_params,
|
||||
void *font_data)
|
||||
{
|
||||
ctr_video_t *ctr = (ctr_video_t*)data;
|
||||
|
||||
ctr_video_t *ctr = (ctr_video_t*)data;
|
||||
ctr->render_font_bottom = true;
|
||||
font_driver_render_msg(ctr, msg, _params, font_data);
|
||||
ctr->render_font_bottom = false;
|
||||
@ -660,72 +678,78 @@ static void font_driver_render_msg_bottom(
|
||||
|
||||
static void ctr_render_bottom_screen(void *data)
|
||||
{
|
||||
ctr_video_t *ctr = (ctr_video_t*)data;
|
||||
|
||||
if (!ctr)
|
||||
return;
|
||||
|
||||
if (!ctr->refresh_bottom_menu)
|
||||
return;
|
||||
|
||||
struct font_params params = { 0, };
|
||||
ctr_video_t *ctr = (ctr_video_t*)data;
|
||||
|
||||
if (!ctr || !ctr->refresh_bottom_menu)
|
||||
return;
|
||||
|
||||
params.text_align = TEXT_ALIGN_CENTER;
|
||||
params.color = COLOR_ABGR(255, 255, 255, 255);
|
||||
params.color = COLOR_ABGR(255, 255, 255, 255);
|
||||
|
||||
switch (ctr->bottom_menu)
|
||||
{
|
||||
case CTR_BOTTOM_MENU_NOT_AVAILABLE:
|
||||
{
|
||||
params.scale = 1.6f;
|
||||
params.x = 0.0f;
|
||||
params.y = 0.5f;
|
||||
params.scale = 1.6f;
|
||||
params.x = 0.0f;
|
||||
params.y = 0.5f;
|
||||
|
||||
font_driver_render_msg_bottom(ctr,
|
||||
font_driver_render_msg_bottom(ctr,
|
||||
msg_hash_to_str(MSG_3DS_BOTTOM_MENU_ASSET_NOT_FOUND),
|
||||
¶ms, NULL);
|
||||
}
|
||||
break;
|
||||
case CTR_BOTTOM_MENU_DEFAULT:
|
||||
{
|
||||
params.scale = 1.6f;
|
||||
params.x = 0.0f;
|
||||
params.y = 0.5f;
|
||||
params.scale = 1.6f;
|
||||
params.x = 0.0f;
|
||||
params.y = 0.5f;
|
||||
|
||||
font_driver_render_msg_bottom(ctr,
|
||||
font_driver_render_msg_bottom(ctr,
|
||||
msg_hash_to_str(MSG_3DS_BOTTOM_MENU_DEFAULT),
|
||||
¶ms, NULL);
|
||||
}
|
||||
break;
|
||||
case CTR_BOTTOM_MENU_SELECT:
|
||||
{
|
||||
params.scale = 1.48f;
|
||||
params.color = COLOR_ABGR(255, 255, 255, 255);
|
||||
struct ctr_bottom_texture_data *o = NULL;
|
||||
ctr_texture_t *texture = NULL;
|
||||
|
||||
params.scale = 1.48f;
|
||||
params.color = COLOR_ABGR(
|
||||
255, 255, 255, 255);
|
||||
|
||||
/* draw state thumbnail */
|
||||
if (ctr->state_data_exist) {
|
||||
struct ctr_bottom_texture_data *o = (struct ctr_bottom_texture_data*)
|
||||
if (ctr->state_data_exist)
|
||||
{
|
||||
o = (struct ctr_bottom_texture_data*)
|
||||
&ctr->bottom_textures[CTR_TEXTURE_STATE_THUMBNAIL];
|
||||
texture = (ctr_texture_t *) o->texture;
|
||||
|
||||
ctr_texture_t *texture = (ctr_texture_t *) o->texture;
|
||||
if (texture)
|
||||
{
|
||||
GPU_TEXCOLOR colorType = GPU_RGBA8;
|
||||
if (!ctr->render_state_from_png_file && !ctr->rgb32)
|
||||
colorType = GPU_RGB565;
|
||||
|
||||
ctrGuSetTexture(GPU_TEXUNIT0, VIRT_TO_PHYS(texture->data),
|
||||
texture->width, texture->height,
|
||||
GPU_TEXTURE_MAG_FILTER(GPU_LINEAR) | GPU_TEXTURE_MIN_FILTER(GPU_LINEAR) |
|
||||
GPU_TEXTURE_WRAP_S(GPU_CLAMP_TO_EDGE) | GPU_TEXTURE_WRAP_T(GPU_CLAMP_TO_EDGE),
|
||||
ctrGuSetTexture(GPU_TEXUNIT0,
|
||||
VIRT_TO_PHYS(texture->data),
|
||||
texture->width,
|
||||
texture->height,
|
||||
GPU_TEXTURE_MAG_FILTER(GPU_LINEAR)
|
||||
| GPU_TEXTURE_MIN_FILTER(GPU_LINEAR)
|
||||
| GPU_TEXTURE_WRAP_S(GPU_CLAMP_TO_EDGE)
|
||||
| GPU_TEXTURE_WRAP_T(GPU_CLAMP_TO_EDGE),
|
||||
colorType);
|
||||
|
||||
GPUCMD_AddWrite(GPUREG_GSH_BOOLUNIFORM, 0);
|
||||
ctrGuSetVertexShaderFloatUniform(0, (float*)&o->scale_vector, 1);
|
||||
ctrGuSetAttributeBuffersAddress(VIRT_TO_PHYS(o->frame_coords));
|
||||
ctrGuSetVertexShaderFloatUniform(0,
|
||||
(float*)&o->scale_vector, 1);
|
||||
ctrGuSetAttributeBuffersAddress(
|
||||
VIRT_TO_PHYS(o->frame_coords));
|
||||
|
||||
GPU_SetViewport(NULL,
|
||||
VIRT_TO_PHYS(ctr->drawbuffers.bottom),
|
||||
0, 0, CTR_BOTTOM_FRAMEBUFFER_HEIGHT,
|
||||
0,
|
||||
0,
|
||||
CTR_BOTTOM_FRAMEBUFFER_HEIGHT,
|
||||
CTR_BOTTOM_FRAMEBUFFER_WIDTH);
|
||||
GPU_DrawArray(GPU_GEOMETRY_PRIM, 0, 1);
|
||||
}
|
||||
@ -734,7 +758,8 @@ static void ctr_render_bottom_screen(void *data)
|
||||
params.x = 0.266f;
|
||||
params.y = 0.64f;
|
||||
font_driver_render_msg_bottom(ctr,
|
||||
msg_hash_to_str(MSG_3DS_BOTTOM_MENU_NO_STATE_THUMBNAIL),
|
||||
msg_hash_to_str(
|
||||
MSG_3DS_BOTTOM_MENU_NO_STATE_THUMBNAIL),
|
||||
¶ms, NULL);
|
||||
}
|
||||
}
|
||||
@ -743,27 +768,37 @@ static void ctr_render_bottom_screen(void *data)
|
||||
params.x = 0.266f;
|
||||
params.y = 0.64f;
|
||||
font_driver_render_msg_bottom(ctr,
|
||||
msg_hash_to_str(MSG_3DS_BOTTOM_MENU_NO_STATE_DATA),
|
||||
msg_hash_to_str(
|
||||
MSG_3DS_BOTTOM_MENU_NO_STATE_DATA),
|
||||
¶ms, NULL);
|
||||
}
|
||||
|
||||
/* draw bottom menu */
|
||||
struct ctr_bottom_texture_data *o = &ctr->bottom_textures[CTR_TEXTURE_BOTTOM_MENU];
|
||||
ctr_texture_t *texture = (ctr_texture_t *) o->texture;
|
||||
o =
|
||||
&ctr->bottom_textures[CTR_TEXTURE_BOTTOM_MENU];
|
||||
texture = (ctr_texture_t *)o->texture;
|
||||
|
||||
ctrGuSetTexture(GPU_TEXUNIT0, VIRT_TO_PHYS(texture->data),
|
||||
texture->width, texture->height,
|
||||
GPU_TEXTURE_MAG_FILTER(GPU_LINEAR) | GPU_TEXTURE_MIN_FILTER(GPU_LINEAR) |
|
||||
GPU_TEXTURE_WRAP_S(GPU_CLAMP_TO_EDGE) | GPU_TEXTURE_WRAP_T(GPU_CLAMP_TO_EDGE),
|
||||
ctrGuSetTexture(GPU_TEXUNIT0,
|
||||
VIRT_TO_PHYS(texture->data),
|
||||
texture->width,
|
||||
texture->height,
|
||||
GPU_TEXTURE_MAG_FILTER(GPU_LINEAR)
|
||||
| GPU_TEXTURE_MIN_FILTER(GPU_LINEAR)
|
||||
| GPU_TEXTURE_WRAP_S(GPU_CLAMP_TO_EDGE)
|
||||
| GPU_TEXTURE_WRAP_T(GPU_CLAMP_TO_EDGE),
|
||||
GPU_RGBA8);
|
||||
|
||||
GPUCMD_AddWrite(GPUREG_GSH_BOOLUNIFORM, 0);
|
||||
ctrGuSetVertexShaderFloatUniform(0, (float*)&o->scale_vector, 1);
|
||||
ctrGuSetAttributeBuffersAddress(VIRT_TO_PHYS(o->frame_coords));
|
||||
ctrGuSetVertexShaderFloatUniform(0,
|
||||
(float*)&o->scale_vector, 1);
|
||||
ctrGuSetAttributeBuffersAddress(
|
||||
VIRT_TO_PHYS(o->frame_coords));
|
||||
|
||||
GPU_SetViewport(NULL,
|
||||
VIRT_TO_PHYS(ctr->drawbuffers.bottom),
|
||||
0, 0, CTR_BOTTOM_FRAMEBUFFER_HEIGHT,
|
||||
0,
|
||||
0,
|
||||
CTR_BOTTOM_FRAMEBUFFER_HEIGHT,
|
||||
CTR_BOTTOM_FRAMEBUFFER_WIDTH);
|
||||
GPU_DrawArray(GPU_GEOMETRY_PRIM, 0, 1);
|
||||
|
||||
@ -805,26 +840,35 @@ static void ctr_render_bottom_screen(void *data)
|
||||
// https://github.com/smealum/3ds_hb_menu/blob/master/source/gfx.c
|
||||
void ctr_fade_bottom_screen(gfxScreen_t screen, gfx3dSide_t side, u32 f)
|
||||
{
|
||||
int i;
|
||||
u16 fbWidth, fbHeight;
|
||||
u8* fbAdr=gfxGetFramebuffer(screen, side, &fbWidth, &fbHeight);
|
||||
u8* fbAdr = gfxGetFramebuffer(screen, side, &fbWidth, &fbHeight);
|
||||
|
||||
int i; for(i=0; i<fbWidth*fbHeight/2; i++)
|
||||
for(i = 0; i < fbWidth * fbHeight / 2; i++)
|
||||
{
|
||||
*fbAdr=(*fbAdr*f)>>8;fbAdr++;
|
||||
*fbAdr=(*fbAdr*f)>>8;fbAdr++;
|
||||
*fbAdr=(*fbAdr*f)>>8;fbAdr++;
|
||||
*fbAdr=(*fbAdr*f)>>8;fbAdr++;
|
||||
*fbAdr=(*fbAdr*f)>>8;fbAdr++;
|
||||
*fbAdr=(*fbAdr*f)>>8;fbAdr++;
|
||||
*fbAdr = (*fbAdr * f) >> 8;
|
||||
fbAdr++;
|
||||
*fbAdr = (*fbAdr * f) >> 8;
|
||||
fbAdr++;
|
||||
*fbAdr = (*fbAdr * f) >> 8;
|
||||
fbAdr++;
|
||||
*fbAdr = (*fbAdr * f) >> 8;
|
||||
fbAdr++;
|
||||
*fbAdr = (*fbAdr * f) >> 8;
|
||||
fbAdr++;
|
||||
*fbAdr = (*fbAdr * f) >> 8;
|
||||
fbAdr++;
|
||||
}
|
||||
}
|
||||
|
||||
static void ctr_set_bottom_screen_idle(ctr_video_t * ctr)
|
||||
{
|
||||
u64 elapsed_tick;
|
||||
if (ctr->bottom_menu == CTR_BOTTOM_MENU_SELECT)
|
||||
return;
|
||||
|
||||
u64 elapsed_tick = ( svcGetSystemTick() - ctr->idle_timestamp );
|
||||
elapsed_tick = svcGetSystemTick() - ctr->idle_timestamp;
|
||||
|
||||
if ( elapsed_tick > 2000000000 )
|
||||
{
|
||||
if (!ctr->bottom_is_fading)
|
||||
@ -844,7 +888,7 @@ static void ctr_set_bottom_screen_idle(ctr_video_t * ctr)
|
||||
ctr->bottom_is_idle = true;
|
||||
ctr->bottom_is_fading = false;
|
||||
ctr->bottom_check_idle = false;
|
||||
fadeCount = 256;
|
||||
fadeCount = 256;
|
||||
ctr_set_bottom_screen_enable(false,true);
|
||||
return;
|
||||
}
|
||||
@ -861,8 +905,8 @@ static void ctr_set_bottom_screen_enable(bool enabled, bool idle)
|
||||
if(not_2DS && srvGetServiceHandle(&lcd_handle, "gsp::Lcd") >= 0)
|
||||
{
|
||||
u32 *cmdbuf = getThreadCommandBuffer();
|
||||
cmdbuf[0] = enabled? 0x00110040: 0x00120040;
|
||||
cmdbuf[1] = 2;
|
||||
cmdbuf[0] = enabled? 0x00110040: 0x00120040;
|
||||
cmdbuf[1] = 2;
|
||||
svcSendSyncRequest(lcd_handle);
|
||||
svcCloseHandle(lcd_handle);
|
||||
}
|
||||
@ -885,19 +929,28 @@ static void ctr_lcd_aptHook(APT_HookType hook, void* param)
|
||||
|
||||
GPU_SetViewport(NULL,
|
||||
VIRT_TO_PHYS(ctr->drawbuffers.top.left),
|
||||
0, 0, CTR_TOP_FRAMEBUFFER_HEIGHT, CTR_TOP_FRAMEBUFFER_WIDTH);
|
||||
0,
|
||||
0,
|
||||
CTR_TOP_FRAMEBUFFER_HEIGHT,
|
||||
CTR_TOP_FRAMEBUFFER_WIDTH);
|
||||
|
||||
GPU_DepthMap(-1.0f, 0.0f);
|
||||
GPU_SetFaceCulling(GPU_CULL_NONE);
|
||||
GPU_SetStencilTest(false, GPU_ALWAYS, 0x00, 0xFF, 0x00);
|
||||
GPU_SetStencilOp(GPU_STENCIL_KEEP, GPU_STENCIL_KEEP, GPU_STENCIL_KEEP);
|
||||
GPU_SetStencilOp(GPU_STENCIL_KEEP,
|
||||
GPU_STENCIL_KEEP,
|
||||
GPU_STENCIL_KEEP);
|
||||
GPU_SetBlendingColor(0, 0, 0, 0);
|
||||
GPU_SetDepthTestAndWriteMask(false, GPU_ALWAYS, GPU_WRITE_COLOR);
|
||||
GPUCMD_AddMaskedWrite(GPUREG_EARLYDEPTH_TEST1, 0x1, 0);
|
||||
GPUCMD_AddWrite(GPUREG_EARLYDEPTH_TEST2, 0);
|
||||
GPU_SetAlphaBlending(GPU_BLEND_ADD, GPU_BLEND_ADD,
|
||||
GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA,
|
||||
GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA);
|
||||
GPU_SetAlphaBlending(
|
||||
GPU_BLEND_ADD,
|
||||
GPU_BLEND_ADD,
|
||||
GPU_SRC_ALPHA,
|
||||
GPU_ONE_MINUS_SRC_ALPHA,
|
||||
GPU_SRC_ALPHA,
|
||||
GPU_ONE_MINUS_SRC_ALPHA);
|
||||
GPU_SetAlphaTest(false, GPU_ALWAYS, 0x00);
|
||||
GPU_SetTextureEnable(GPU_TEXUNIT0);
|
||||
GPU_SetTexEnv(0, GPU_TEXTURE0, GPU_TEXTURE0, 0, 0, GPU_REPLACE, GPU_REPLACE, 0);
|
||||
@ -907,10 +960,10 @@ static void ctr_lcd_aptHook(APT_HookType hook, void* param)
|
||||
GPU_SetTexEnv(4, GPU_PREVIOUS, GPU_PREVIOUS, 0, 0, 0, 0, 0);
|
||||
GPU_SetTexEnv(5, GPU_PREVIOUS, GPU_PREVIOUS, 0, 0, 0, 0, 0);
|
||||
ctrGuSetAttributeBuffers(2,
|
||||
VIRT_TO_PHYS(ctr->menu.frame_coords),
|
||||
CTRGU_ATTRIBFMT(GPU_SHORT, 4) << 0 |
|
||||
CTRGU_ATTRIBFMT(GPU_SHORT, 4) << 4,
|
||||
sizeof(ctr_vertex_t));
|
||||
VIRT_TO_PHYS(ctr->menu.frame_coords),
|
||||
CTRGU_ATTRIBFMT(GPU_SHORT, 4) << 0
|
||||
| CTRGU_ATTRIBFMT(GPU_SHORT, 4) << 4,
|
||||
sizeof(ctr_vertex_t));
|
||||
GPU_Finalize();
|
||||
ctrGuFlushAndRun(true);
|
||||
gspWaitForEvent(GSPGPU_EVENT_P3D, false);
|
||||
@ -925,7 +978,9 @@ static void ctr_lcd_aptHook(APT_HookType hook, void* param)
|
||||
memcpy(gfxTopRightFramebuffers[ctr->current_buffer_top],
|
||||
gfxTopLeftFramebuffers[ctr->current_buffer_top],
|
||||
400 * 240 * 3);
|
||||
GSPGPU_FlushDataCache(gfxTopRightFramebuffers[ctr->current_buffer_top], 400 * 240 * 3);
|
||||
GSPGPU_FlushDataCache(
|
||||
gfxTopRightFramebuffers[
|
||||
ctr->current_buffer_top], 400 * 240 * 3);
|
||||
}
|
||||
if (ctr->supports_parallax_disable)
|
||||
ctr_set_parallax_layer(*(float*)0x1FF81080 != 0.0);
|
||||
@ -941,7 +996,6 @@ static void ctr_lcd_aptHook(APT_HookType hook, void* param)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
if (menu_state_get_ptr()->alive)
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user