diff --git a/gc/ogc/consol.h b/gc/ogc/consol.h index 4e7b54d8..2dcf86d5 100644 --- a/gc/ogc/consol.h +++ b/gc/ogc/consol.h @@ -53,6 +53,16 @@ s32 CON_InitEx(GXRModeObj *rmode, s32 conXOrigin,s32 conYOrigin,s32 conWidth,s32 */ void CON_GetMetrics(int *cols, int *rows); +/*! + * \fn CON_GetPosition(int *col, int *row) + * \brief retrieve the current cursor position of the current console + * + * \param[out] col,row current cursor position + * + * \return none + */ +void CON_GetPosition(int *cols, int *rows); + #ifdef __cplusplus } #endif diff --git a/gc/wiiuse/wiiuse.h b/gc/wiiuse/wiiuse.h index a4adcc3c..2aea1277 100644 --- a/gc/wiiuse/wiiuse.h +++ b/gc/wiiuse/wiiuse.h @@ -341,6 +341,7 @@ typedef struct sb_t { fdot_t rot_dots[2]; float angle; float off_angle; + float score; } sb_t; /** diff --git a/libogc.prj b/libogc.prj index 2cf0e65b..998199ba 100644 --- a/libogc.prj +++ b/libogc.prj @@ -94,7 +94,7 @@ Open File Line16=0 Open File Window Pos16=0,1,-1,-1,-4,-30,66,87,1099,457 Open File17= [File View] -Current Select=Project Files\gc\ogc\gx.h +Current Select=Project Files\libogc\video.c Scroll Position=0 [Files - libogc] diff --git a/libogc/console.c b/libogc/console.c index e4d22d83..3ee1e954 100644 --- a/libogc/console.c +++ b/libogc/console.c @@ -518,8 +518,10 @@ void CON_Init(void *framebuffer,int xstart,int ystart,int xres,int yres,int stri s32 CON_InitEx(GXRModeObj *rmode, s32 conXOrigin,s32 conYOrigin,s32 conWidth,s32 conHeight) { - if(_console_buffer) return 0; - + VIDEO_SetPostRetraceCallback(NULL); + if(_console_buffer) + free(_console_buffer); + _console_buffer = malloc(conWidth*conHeight*VI_DISPLAY_PIX_SZ); if(!_console_buffer) return -1; @@ -536,4 +538,12 @@ void CON_GetMetrics(int *cols, int *rows) } } +void CON_GetPosition(int *col, int *row) +{ + if(curr_con) { + *col = curr_con->cursor_col; + *row = curr_con->cursor_row; + } +} + diff --git a/libogc/gu_psasm.S b/libogc/gu_psasm.S index f4f1ab5b..e619c536 100644 --- a/libogc/gu_psasm.S +++ b/libogc/gu_psasm.S @@ -323,6 +323,7 @@ ps_guMtxTrans: addi r9,r9,Unit01@l lfs fr4,0(r9) lfs fr5,4(r9) + stfs fr4,16(r3) stfs fr1,12(r3) stfs fr2,28(r3) psq_st fr4,4(r3),0,0 diff --git a/libogc/system.c b/libogc/system.c index 344f2abb..43db95b3 100644 --- a/libogc/system.c +++ b/libogc/system.c @@ -195,7 +195,7 @@ extern void __reset(u32 reset_code); extern void __UnmaskIrq(u32); extern void __MaskIrq(u32); -extern u32 __IPC_ClntInit(); +extern u32 __IPC_ClntInit(void); extern u32 __PADDisableRecalibration(s32 disable); extern void __console_init_ex(void *conbuffer,int tgt_xstart,int tgt_ystart,int tgt_stride,int con_xres,int con_yres,int con_stride); diff --git a/wiiuse/ir.c b/wiiuse/ir.c index 77f1f741..1918cf2a 100644 --- a/wiiuse/ir.c +++ b/wiiuse/ir.c @@ -437,8 +437,8 @@ enum { // half-height of the IR sensor if half-width is 1 #define HEIGHT (384.0f / 512.0f) -// maximum sensor bar slope (tan(20 degrees)) -#define MAX_SB_SLOPE 0.36f +// maximum sensor bar slope (tan(35 degrees)) +#define MAX_SB_SLOPE 0.7f // minimum sensor bar width in view, relative to half of the IR sensor area #define MIN_SB_WIDTH 0.1f // reject "sensor bars" that happen to have a dot towards the middle @@ -588,6 +588,9 @@ void find_sensorbar(struct ir_t* ir, struct orient_t *orient) { // failed middle dot check if(i < ir->num_dots) continue; WIIUSE_DEBUG("IR: passed middle dot check\n"); + + cand.score = 1 / (cand.rot_dots[1].x - cand.rot_dots[0].x); + // we have a candidate, store it WIIUSE_DEBUG("IR: new candidate %d\n",num_candidates); candidates[num_candidates++] = cand; @@ -688,19 +691,19 @@ void find_sensorbar(struct ir_t* ir, struct orient_t *orient) { WIIUSE_DEBUG("IR: found new dot to track\n"); break; } + sb.score = 0; ir->state = IR_STATE_SINGLE; } else { int bestidx = 0; - float best = 999.0f; + float best = 0.0f; float d; WIIUSE_DEBUG("IR: finding best candidate\n"); // look for the best candidate // for now, the formula is simple: pick the one with the smallest distance for(i=0; i best) { bestidx = i; - best = d; + best = candidates[i].score; } } WIIUSE_DEBUG("IR: best candidate: %d\n",bestidx);