(CTR) C89 conformity cleanups

This commit is contained in:
twinaphex 2021-11-03 21:42:11 +01:00
parent 514ed00f2d
commit 69e8416e45
1 changed files with 191 additions and 137 deletions

View File

@ -248,7 +248,8 @@ static void ctr_update_viewport(
} }
else else
{ {
ctr->vp.x = ctr->vp.y = 0; ctr->vp.x = 0;
ctr->vp.y = 0;
ctr->vp.width = width; ctr->vp.width = width;
ctr->vp.height = height; ctr->vp.height = height;
} }
@ -268,8 +269,8 @@ static const char *ctr_texture_path(unsigned id)
case CTR_TEXTURE_STATE_THUMBNAIL: case CTR_TEXTURE_STATE_THUMBNAIL:
{ {
static char texture_path[PATH_MAX_LENGTH]; static char texture_path[PATH_MAX_LENGTH];
char state_path[PATH_MAX_LENGTH]; char state_path[PATH_MAX_LENGTH];
if (!retroarch_get_current_savestate_path(state_path, if (!retroarch_get_current_savestate_path(state_path,
sizeof(state_path))) sizeof(state_path)))
return NULL; return NULL;
@ -279,6 +280,8 @@ static const char *ctr_texture_path(unsigned id)
return path_basename(texture_path); return path_basename(texture_path);
} }
default:
break;
} }
return NULL; return NULL;
@ -287,9 +290,7 @@ static const char *ctr_texture_path(unsigned id)
static void ctr_update_state_date(void *data) static void ctr_update_state_date(void *data)
{ {
ctr_video_t *ctr = (ctr_video_t*)data; ctr_video_t *ctr = (ctr_video_t*)data;
time_t now = time(NULL); time_t now = time(NULL);
struct tm *t = localtime(&now); struct tm *t = localtime(&now);
sprintf(ctr->state_date, "%02d/%02d/%d", sprintf(ctr->state_date, "%02d/%02d/%d",
t->tm_mon + 1, t->tm_mday, t->tm_year + 1900); 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) static bool ctr_update_state_date_from_file(void *data)
{ {
char state_path[PATH_MAX_LENGTH]; 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; 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; return false;
#ifdef USE_CTRULIB_2 #ifdef USE_CTRULIB_2
time_t mtime; file_exists = archive_getmtime(state_path + 5, &mtime) == 0;
bool file_exists = archive_getmtime(state_path + 5, &mtime) == 0;
#else #else
u64 mtime; file_exists = sdmc_getmtime(state_path + 5, &mtime) == 0;
bool file_exists = sdmc_getmtime(state_path + 5, &mtime) == 0;
#endif #endif
if (!file_exists) if (!file_exists)
{ {
ctr->state_data_exist = false; ctr->state_data_exist = false;
@ -320,10 +330,10 @@ static bool ctr_update_state_date_from_file(void *data)
ctr->state_data_exist = true; ctr->state_data_exist = true;
#ifdef USE_CTRULIB_2 #ifdef USE_CTRULIB_2
struct tm *t = localtime(&mtime); t = localtime(&mtime);
#else #else
time_t ft = mtime; ft = mtime;
struct tm *t = localtime(&ft); t = localtime(&ft);
#endif #endif
sprintf(ctr->state_date, "%02d/%02d/%d", sprintf(ctr->state_date, "%02d/%02d/%d",
t->tm_mon + 1, t->tm_mday, t->tm_year + 1900); 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) static void ctr_state_thumbnail_geom(void *data)
{ {
ctr_video_t *ctr = (ctr_video_t *) data; 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; struct ctr_bottom_texture_data *o = NULL;
const int target_width = 120; const int target_width = 120;
const int target_height = 90; const int target_height = 90;
unsigned width, height;
if (ctr) if (ctr)
o = &ctr->bottom_textures[CTR_TEXTURE_STATE_THUMBNAIL]; o = &ctr->bottom_textures[CTR_TEXTURE_STATE_THUMBNAIL];
@ -345,27 +358,28 @@ static void ctr_state_thumbnail_geom(void *data)
if (!o) if (!o)
return; return;
ctr_texture_t *texture = (ctr_texture_t *) o->texture; if (!(texture = (ctr_texture_t *) o->texture))
if (!texture)
return; return;
float scale = (float) target_width / texture->active_width; scale = (float)target_width / texture->active_width;
if (target_width > texture->active_width * scale) { if (target_width > texture->active_width * scale)
scale = (float) (target_width + 1) / texture->active_width; scale = (float)(target_width + 1) / texture->active_width;
}
o->frame_coords->u0 = 0; o->frame_coords->u0 = 0;
o->frame_coords->v0 = 0; o->frame_coords->v0 = 0;
o->frame_coords->u1 = texture->active_width; o->frame_coords->u1 = texture->active_width;
o->frame_coords->v1 = texture->active_height; o->frame_coords->v1 = texture->active_height;
int x_offset = 184; x_offset = 184;
int y_offset = 46 + (target_height - texture->active_height * scale) / 2; y_offset = 46 +
(target_height - texture->active_height * scale) / 2;
o->frame_coords->x0 = x_offset; o->frame_coords->x0 = x_offset;
o->frame_coords->y0 = y_offset; o->frame_coords->y0 = y_offset;
o->frame_coords->x1 = o->frame_coords->x0 + texture->active_width * scale; o->frame_coords->x1 = o->frame_coords->x0
o->frame_coords->y1 = o->frame_coords->y0 + texture->active_height * scale; + texture->active_width * scale;
o->frame_coords->y1 = o->frame_coords->y0
+ texture->active_height * scale;
ctr_set_scale_vector(&o->scale_vector, ctr_set_scale_vector(&o->scale_vector,
CTR_BOTTOM_FRAMEBUFFER_WIDTH, CTR_BOTTOM_FRAMEBUFFER_WIDTH,
@ -377,8 +391,7 @@ static void ctr_state_thumbnail_geom(void *data)
static bool ctr_load_bottom_texture(void *data) static bool ctr_load_bottom_texture(void *data)
{ {
unsigned i; unsigned i;
const char *dir_assets; const char *dir_assets = NULL;
ctr_video_t *ctr = (ctr_video_t *)data; ctr_video_t *ctr = (ctr_video_t *)data;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
@ -432,9 +445,8 @@ static bool ctr_load_bottom_texture(void *data)
static void save_state_to_file(void *data) static void save_state_to_file(void *data)
{ {
ctr_video_t *ctr = (ctr_video_t*)data;
char state_path[PATH_MAX_LENGTH]; char state_path[PATH_MAX_LENGTH];
ctr_video_t *ctr = (ctr_video_t*)data;
retroarch_get_current_savestate_path(state_path, sizeof(state_path)); retroarch_get_current_savestate_path(state_path, sizeof(state_path));
command_event(CMD_EVENT_RAM_STATE_TO_FILE, state_path); command_event(CMD_EVENT_RAM_STATE_TO_FILE, state_path);
@ -475,7 +487,8 @@ static void bottom_menu_control(void* data, bool lcd_bottom)
hidTouchRead(&state_tmp_touch); hidTouchRead(&state_tmp_touch);
if (!state_tmp) 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; ctr->bottom_check_idle = true;
@ -488,8 +501,8 @@ static void bottom_menu_control(void* data, bool lcd_bottom)
return; return;
#endif #endif
if (!lcd_bottom || if ( !lcd_bottom
ctr->bottom_menu == CTR_BOTTOM_MENU_NOT_AVAILABLE) || ctr->bottom_menu == CTR_BOTTOM_MENU_NOT_AVAILABLE)
{ {
BIT64_SET(lifecycle_state, RARCH_MENU_TOGGLE); BIT64_SET(lifecycle_state, RARCH_MENU_TOGGLE);
return; return;
@ -531,15 +544,17 @@ static void bottom_menu_control(void* data, bool lcd_bottom)
struct ctr_bottom_texture_data *o = struct ctr_bottom_texture_data *o =
&ctr->bottom_textures[CTR_TEXTURE_STATE_THUMBNAIL]; &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) if (texture)
linearFree(texture->data); linearFree(texture->data);
else 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)); 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->width = ctr->texture_width;
@ -577,11 +592,12 @@ static void bottom_menu_control(void* data, bool lcd_bottom)
BIT64_SET(lifecycle_state, RARCH_MENU_TOGGLE); BIT64_SET(lifecycle_state, RARCH_MENU_TOGGLE);
} }
else if (state_tmp_touch.px > 176 && else if (
state_tmp_touch.px < 311 && state_tmp_touch.px > 176
state_tmp_touch.py > 9 && && state_tmp_touch.px < 311
state_tmp_touch.py < 230 && && state_tmp_touch.py > 9
ctr->state_data_exist) && state_tmp_touch.py < 230
&& ctr->state_data_exist)
{ {
if (!command_event(CMD_EVENT_LOAD_STATE_FROM_RAM, NULL)) if (!command_event(CMD_EVENT_LOAD_STATE_FROM_RAM, NULL))
command_event(CMD_EVENT_LOAD_STATE, 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) if (ctr->state_slot != config_slot)
{ {
ctr_texture_t *texture = NULL;
struct ctr_bottom_texture_data *o = NULL;
save_state_to_file(ctr); save_state_to_file(ctr);
ctr->state_slot = config_slot; ctr->state_slot = config_slot;
o =
struct ctr_bottom_texture_data *o = &ctr->bottom_textures[CTR_TEXTURE_STATE_THUMBNAIL]; &ctr->bottom_textures[CTR_TEXTURE_STATE_THUMBNAIL];
ctr_texture_t *texture = (ctr_texture_t *) o->texture; texture = (ctr_texture_t *)o->texture;
if (texture) if (texture)
{ {
@ -652,7 +671,6 @@ static void font_driver_render_msg_bottom(
void *font_data) void *font_data)
{ {
ctr_video_t *ctr = (ctr_video_t*)data; ctr_video_t *ctr = (ctr_video_t*)data;
ctr->render_font_bottom = true; ctr->render_font_bottom = true;
font_driver_render_msg(ctr, msg, _params, font_data); font_driver_render_msg(ctr, msg, _params, font_data);
ctr->render_font_bottom = false; ctr->render_font_bottom = false;
@ -660,22 +678,18 @@ static void font_driver_render_msg_bottom(
static void ctr_render_bottom_screen(void *data) static void ctr_render_bottom_screen(void *data)
{ {
struct font_params params = { 0, };
ctr_video_t *ctr = (ctr_video_t*)data; ctr_video_t *ctr = (ctr_video_t*)data;
if (!ctr) if (!ctr || !ctr->refresh_bottom_menu)
return; return;
if (!ctr->refresh_bottom_menu)
return;
struct font_params params = { 0, };
params.text_align = TEXT_ALIGN_CENTER; 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) switch (ctr->bottom_menu)
{ {
case CTR_BOTTOM_MENU_NOT_AVAILABLE: case CTR_BOTTOM_MENU_NOT_AVAILABLE:
{
params.scale = 1.6f; params.scale = 1.6f;
params.x = 0.0f; params.x = 0.0f;
params.y = 0.5f; params.y = 0.5f;
@ -683,10 +697,8 @@ static void ctr_render_bottom_screen(void *data)
font_driver_render_msg_bottom(ctr, font_driver_render_msg_bottom(ctr,
msg_hash_to_str(MSG_3DS_BOTTOM_MENU_ASSET_NOT_FOUND), msg_hash_to_str(MSG_3DS_BOTTOM_MENU_ASSET_NOT_FOUND),
&params, NULL); &params, NULL);
}
break; break;
case CTR_BOTTOM_MENU_DEFAULT: case CTR_BOTTOM_MENU_DEFAULT:
{
params.scale = 1.6f; params.scale = 1.6f;
params.x = 0.0f; params.x = 0.0f;
params.y = 0.5f; params.y = 0.5f;
@ -694,38 +706,50 @@ static void ctr_render_bottom_screen(void *data)
font_driver_render_msg_bottom(ctr, font_driver_render_msg_bottom(ctr,
msg_hash_to_str(MSG_3DS_BOTTOM_MENU_DEFAULT), msg_hash_to_str(MSG_3DS_BOTTOM_MENU_DEFAULT),
&params, NULL); &params, NULL);
}
break; break;
case CTR_BOTTOM_MENU_SELECT: case CTR_BOTTOM_MENU_SELECT:
{ {
struct ctr_bottom_texture_data *o = NULL;
ctr_texture_t *texture = NULL;
params.scale = 1.48f; params.scale = 1.48f;
params.color = COLOR_ABGR(255, 255, 255, 255); params.color = COLOR_ABGR(
255, 255, 255, 255);
/* draw state thumbnail */ /* draw state thumbnail */
if (ctr->state_data_exist) { if (ctr->state_data_exist)
struct ctr_bottom_texture_data *o = (struct ctr_bottom_texture_data*) {
o = (struct ctr_bottom_texture_data*)
&ctr->bottom_textures[CTR_TEXTURE_STATE_THUMBNAIL]; &ctr->bottom_textures[CTR_TEXTURE_STATE_THUMBNAIL];
texture = (ctr_texture_t *) o->texture;
ctr_texture_t *texture = (ctr_texture_t *) o->texture;
if (texture) if (texture)
{ {
GPU_TEXCOLOR colorType = GPU_RGBA8; GPU_TEXCOLOR colorType = GPU_RGBA8;
if (!ctr->render_state_from_png_file && !ctr->rgb32) if (!ctr->render_state_from_png_file && !ctr->rgb32)
colorType = GPU_RGB565; colorType = GPU_RGB565;
ctrGuSetTexture(GPU_TEXUNIT0, VIRT_TO_PHYS(texture->data), ctrGuSetTexture(GPU_TEXUNIT0,
texture->width, texture->height, VIRT_TO_PHYS(texture->data),
GPU_TEXTURE_MAG_FILTER(GPU_LINEAR) | GPU_TEXTURE_MIN_FILTER(GPU_LINEAR) | texture->width,
GPU_TEXTURE_WRAP_S(GPU_CLAMP_TO_EDGE) | GPU_TEXTURE_WRAP_T(GPU_CLAMP_TO_EDGE), 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); colorType);
GPUCMD_AddWrite(GPUREG_GSH_BOOLUNIFORM, 0); GPUCMD_AddWrite(GPUREG_GSH_BOOLUNIFORM, 0);
ctrGuSetVertexShaderFloatUniform(0, (float*)&o->scale_vector, 1); ctrGuSetVertexShaderFloatUniform(0,
ctrGuSetAttributeBuffersAddress(VIRT_TO_PHYS(o->frame_coords)); (float*)&o->scale_vector, 1);
ctrGuSetAttributeBuffersAddress(
VIRT_TO_PHYS(o->frame_coords));
GPU_SetViewport(NULL, GPU_SetViewport(NULL,
VIRT_TO_PHYS(ctr->drawbuffers.bottom), VIRT_TO_PHYS(ctr->drawbuffers.bottom),
0, 0, CTR_BOTTOM_FRAMEBUFFER_HEIGHT, 0,
0,
CTR_BOTTOM_FRAMEBUFFER_HEIGHT,
CTR_BOTTOM_FRAMEBUFFER_WIDTH); CTR_BOTTOM_FRAMEBUFFER_WIDTH);
GPU_DrawArray(GPU_GEOMETRY_PRIM, 0, 1); GPU_DrawArray(GPU_GEOMETRY_PRIM, 0, 1);
} }
@ -734,7 +758,8 @@ static void ctr_render_bottom_screen(void *data)
params.x = 0.266f; params.x = 0.266f;
params.y = 0.64f; params.y = 0.64f;
font_driver_render_msg_bottom(ctr, 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),
&params, NULL); &params, NULL);
} }
} }
@ -743,27 +768,37 @@ static void ctr_render_bottom_screen(void *data)
params.x = 0.266f; params.x = 0.266f;
params.y = 0.64f; params.y = 0.64f;
font_driver_render_msg_bottom(ctr, 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),
&params, NULL); &params, NULL);
} }
/* draw bottom menu */ /* draw bottom menu */
struct ctr_bottom_texture_data *o = &ctr->bottom_textures[CTR_TEXTURE_BOTTOM_MENU]; o =
ctr_texture_t *texture = (ctr_texture_t *) o->texture; &ctr->bottom_textures[CTR_TEXTURE_BOTTOM_MENU];
texture = (ctr_texture_t *)o->texture;
ctrGuSetTexture(GPU_TEXUNIT0, VIRT_TO_PHYS(texture->data), ctrGuSetTexture(GPU_TEXUNIT0,
texture->width, texture->height, VIRT_TO_PHYS(texture->data),
GPU_TEXTURE_MAG_FILTER(GPU_LINEAR) | GPU_TEXTURE_MIN_FILTER(GPU_LINEAR) | texture->width,
GPU_TEXTURE_WRAP_S(GPU_CLAMP_TO_EDGE) | GPU_TEXTURE_WRAP_T(GPU_CLAMP_TO_EDGE), 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); GPU_RGBA8);
GPUCMD_AddWrite(GPUREG_GSH_BOOLUNIFORM, 0); GPUCMD_AddWrite(GPUREG_GSH_BOOLUNIFORM, 0);
ctrGuSetVertexShaderFloatUniform(0, (float*)&o->scale_vector, 1); ctrGuSetVertexShaderFloatUniform(0,
ctrGuSetAttributeBuffersAddress(VIRT_TO_PHYS(o->frame_coords)); (float*)&o->scale_vector, 1);
ctrGuSetAttributeBuffersAddress(
VIRT_TO_PHYS(o->frame_coords));
GPU_SetViewport(NULL, GPU_SetViewport(NULL,
VIRT_TO_PHYS(ctr->drawbuffers.bottom), VIRT_TO_PHYS(ctr->drawbuffers.bottom),
0, 0, CTR_BOTTOM_FRAMEBUFFER_HEIGHT, 0,
0,
CTR_BOTTOM_FRAMEBUFFER_HEIGHT,
CTR_BOTTOM_FRAMEBUFFER_WIDTH); CTR_BOTTOM_FRAMEBUFFER_WIDTH);
GPU_DrawArray(GPU_GEOMETRY_PRIM, 0, 1); 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 // 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) void ctr_fade_bottom_screen(gfxScreen_t screen, gfx3dSide_t side, u32 f)
{ {
int i;
u16 fbWidth, fbHeight; 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*f)>>8;fbAdr++; fbAdr++;
*fbAdr=(*fbAdr*f)>>8;fbAdr++; *fbAdr = (*fbAdr * f) >> 8;
*fbAdr=(*fbAdr*f)>>8;fbAdr++; fbAdr++;
*fbAdr=(*fbAdr*f)>>8;fbAdr++; *fbAdr = (*fbAdr * f) >> 8;
*fbAdr=(*fbAdr*f)>>8;fbAdr++; 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) static void ctr_set_bottom_screen_idle(ctr_video_t * ctr)
{ {
u64 elapsed_tick;
if (ctr->bottom_menu == CTR_BOTTOM_MENU_SELECT) if (ctr->bottom_menu == CTR_BOTTOM_MENU_SELECT)
return; return;
u64 elapsed_tick = ( svcGetSystemTick() - ctr->idle_timestamp ); elapsed_tick = svcGetSystemTick() - ctr->idle_timestamp;
if ( elapsed_tick > 2000000000 ) if ( elapsed_tick > 2000000000 )
{ {
if (!ctr->bottom_is_fading) if (!ctr->bottom_is_fading)
@ -885,19 +929,28 @@ static void ctr_lcd_aptHook(APT_HookType hook, void* param)
GPU_SetViewport(NULL, GPU_SetViewport(NULL,
VIRT_TO_PHYS(ctr->drawbuffers.top.left), 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_DepthMap(-1.0f, 0.0f);
GPU_SetFaceCulling(GPU_CULL_NONE); GPU_SetFaceCulling(GPU_CULL_NONE);
GPU_SetStencilTest(false, GPU_ALWAYS, 0x00, 0xFF, 0x00); 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_SetBlendingColor(0, 0, 0, 0);
GPU_SetDepthTestAndWriteMask(false, GPU_ALWAYS, GPU_WRITE_COLOR); GPU_SetDepthTestAndWriteMask(false, GPU_ALWAYS, GPU_WRITE_COLOR);
GPUCMD_AddMaskedWrite(GPUREG_EARLYDEPTH_TEST1, 0x1, 0); GPUCMD_AddMaskedWrite(GPUREG_EARLYDEPTH_TEST1, 0x1, 0);
GPUCMD_AddWrite(GPUREG_EARLYDEPTH_TEST2, 0); GPUCMD_AddWrite(GPUREG_EARLYDEPTH_TEST2, 0);
GPU_SetAlphaBlending(GPU_BLEND_ADD, GPU_BLEND_ADD, GPU_SetAlphaBlending(
GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_BLEND_ADD,
GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA); 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_SetAlphaTest(false, GPU_ALWAYS, 0x00);
GPU_SetTextureEnable(GPU_TEXUNIT0); GPU_SetTextureEnable(GPU_TEXUNIT0);
GPU_SetTexEnv(0, GPU_TEXTURE0, GPU_TEXTURE0, 0, 0, GPU_REPLACE, GPU_REPLACE, 0); GPU_SetTexEnv(0, GPU_TEXTURE0, GPU_TEXTURE0, 0, 0, GPU_REPLACE, GPU_REPLACE, 0);
@ -908,8 +961,8 @@ static void ctr_lcd_aptHook(APT_HookType hook, void* param)
GPU_SetTexEnv(5, GPU_PREVIOUS, GPU_PREVIOUS, 0, 0, 0, 0, 0); GPU_SetTexEnv(5, GPU_PREVIOUS, GPU_PREVIOUS, 0, 0, 0, 0, 0);
ctrGuSetAttributeBuffers(2, ctrGuSetAttributeBuffers(2,
VIRT_TO_PHYS(ctr->menu.frame_coords), VIRT_TO_PHYS(ctr->menu.frame_coords),
CTRGU_ATTRIBFMT(GPU_SHORT, 4) << 0 | CTRGU_ATTRIBFMT(GPU_SHORT, 4) << 0
CTRGU_ATTRIBFMT(GPU_SHORT, 4) << 4, | CTRGU_ATTRIBFMT(GPU_SHORT, 4) << 4,
sizeof(ctr_vertex_t)); sizeof(ctr_vertex_t));
GPU_Finalize(); GPU_Finalize();
ctrGuFlushAndRun(true); ctrGuFlushAndRun(true);
@ -925,7 +978,9 @@ static void ctr_lcd_aptHook(APT_HookType hook, void* param)
memcpy(gfxTopRightFramebuffers[ctr->current_buffer_top], memcpy(gfxTopRightFramebuffers[ctr->current_buffer_top],
gfxTopLeftFramebuffers[ctr->current_buffer_top], gfxTopLeftFramebuffers[ctr->current_buffer_top],
400 * 240 * 3); 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) if (ctr->supports_parallax_disable)
ctr_set_parallax_layer(*(float*)0x1FF81080 != 0.0); ctr_set_parallax_layer(*(float*)0x1FF81080 != 0.0);
@ -941,7 +996,6 @@ static void ctr_lcd_aptHook(APT_HookType hook, void* param)
break; break;
} }
#ifdef HAVE_MENU #ifdef HAVE_MENU
if (menu_state_get_ptr()->alive) if (menu_state_get_ptr()->alive)
return; return;