Small fixes

This commit is contained in:
Maschell 2016-04-27 20:51:44 +02:00
parent 92ec4b680a
commit 2d1e2f42d0
2 changed files with 34 additions and 26 deletions

View File

@ -16,20 +16,11 @@
#include "game/memory_area_table.h"
#include "start.h"
#include "patcher/function_hooks.h"
#include "patcher/cpp_to_c_util.h"
#include "kernel/kernel_functions.h"
#include "system/exception_handler.h"
#include "fs/fs_utils.h"
#include "fs/sd_fat_devoptab.h"
#include "controller_patcher/controller_patcher.h"
typedef union u_serv_ip
{
uint8_t digit[4];
uint32_t full;
} u_serv_ip;
#define PRINT_TEXT2(x, y, ...) { snprintf(msg, 80, __VA_ARGS__); OSScreenPutFontEx(0, x, y, msg); OSScreenPutFontEx(1, x, y, msg); }
/* Entry point */
int Menu_Main(void)
{
@ -42,6 +33,8 @@ int Menu_Main(void)
InitGX2FunctionPointers();
InitSysFunctionPointers();
draw_Cursor_destroy();
log_init("192.168.0.181");
SetupKernelCallback();
@ -59,11 +52,12 @@ int Menu_Main(void)
}
if(strlen(cosAppXmlInfoStruct.rpx_name) <= 0){ // First boot back to SysMenu
log_printf("Startssed %s\n", cosAppXmlInfoStruct.rpx_name);
SYSLaunchMenu();
return EXIT_RELAUNCH_ON_LOAD;
}
log_printf("Stafdsf %s\n", cosAppXmlInfoStruct.rpx_name);
draw_Cursor_destroy();
RestoreInstructions();
deinit_config_controller();

View File

@ -3,8 +3,26 @@
#include "common/common.h"
#include "video/shaders/ColorShader.h"
// TODO: not creating these stuff at every frame
u8 gCursorInitDone __attribute__((section(".data"))) = 0;
static u8 * cursor_colorVtxs = NULL;
void init_cursor(){
if(!gCursorInitDone){
if(!cursor_colorVtxs){
cursor_colorVtxs = (u8*)memalign(0x40, sizeof(u8) * 16);
if(cursor_colorVtxs == NULL) return;
}
memset(cursor_colorVtxs,0xFF,16*sizeof(u8));
GX2Invalidate(GX2_INVALIDATE_CPU_ATTRIB_BUFFER, cursor_colorVtxs, 16 * sizeof(u8));
gCursorInitDone = 1;
}
}
void draw_Cursor_at(f32 x, f32 y) {
init_cursor();
if(cursor_colorVtxs == NULL) return;
f32 widthScaleFactor = 1.0f / (f32)1280;
f32 heightScaleFactor = 1.0f / (f32)720;
@ -15,31 +33,27 @@ void draw_Cursor_at(f32 x, f32 y) {
positionOffsets[0] = (x-((1280)/2)+(width/2)) * widthScaleFactor * 2.0f;
positionOffsets[1] = -(y-((720)/2)+(width/2)) * heightScaleFactor * 2.0f;
u8 colorVtxs[16];
memset(colorVtxs,0xFF,16*sizeof(u8));
GX2Invalidate(GX2_INVALIDATE_CPU_ATTRIB_BUFFER, colorVtxs, 16 * sizeof(u8));
glm::vec4 colorIntensity = glm::vec4(1.0f);
colorIntensity[3] = 255;
glm::vec3 scale(width*widthScaleFactor,width*heightScaleFactor,1.0f);
ColorShader::instance()->setShaders();
ColorShader::instance()->setAttributeBuffer(colorVtxs, NULL, 4);
ColorShader::instance()->setAttributeBuffer(cursor_colorVtxs, NULL, 4);
ColorShader::instance()->setAngle(0);
ColorShader::instance()->setOffset(positionOffsets);
ColorShader::instance()->setScale(scale);
ColorShader::instance()->setColorIntensity(colorIntensity);
ColorShader::instance()->setColorIntensity(glm::vec4(1.0f));
ColorShader::instance()->draw(GX2_PRIMITIVE_QUADS, 4);
}
void draw_Cursor_destroy() {
//! destroy shaders
ColorShader::destroyInstance();
if(cursor_colorVtxs){
free(cursor_colorVtxs);
cursor_colorVtxs = NULL;
}
gCursorInitDone = 0;
}