Skip to content

Commit

Permalink
add Marcan's updates
Browse files Browse the repository at this point in the history
git-svn-id: https://devkitpro.svn.sourceforge.net/svnroot/devkitpro/trunk/libogc@2712 258c5a1a-4f63-435d-9564-e8f6d34ab52c
  • Loading branch information
wntrmute committed Aug 15, 2008
1 parent f962591 commit fa792f3
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 10 deletions.
10 changes: 10 additions & 0 deletions gc/ogc/consol.h
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions gc/wiiuse/wiiuse.h
Expand Up @@ -341,6 +341,7 @@ typedef struct sb_t {
fdot_t rot_dots[2];
float angle;
float off_angle;
float score;
} sb_t;

/**
Expand Down
2 changes: 1 addition & 1 deletion libogc.prj
Expand Up @@ -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]
Expand Down
14 changes: 12 additions & 2 deletions libogc/console.c
Expand Up @@ -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;

Expand All @@ -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;
}
}


1 change: 1 addition & 0 deletions libogc/gu_psasm.S
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion libogc/system.c
Expand Up @@ -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);
Expand Down
15 changes: 9 additions & 6 deletions wiiuse/ir.c
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<num_candidates; i++) {
d = fabsf(candidates[i].rot_dots[0].x - candidates[i].rot_dots[1].x);
if(d < best) {
if(candidates[i].score > best) {
bestidx = i;
best = d;
best = candidates[i].score;
}
}
WIIUSE_DEBUG("IR: best candidate: %d\n",bestidx);
Expand Down

0 comments on commit fa792f3

Please sign in to comment.