Skip to content

Commit 8aecd24

Browse files
mardyDacoTaco
authored andcommitted
gx: get rid of some magic numbers
Use the defined constants for indirect matrix indexes. Note that the changes to the comparison operators are compensated by the +/-1 offset in the operand, so the end result is unaltered.
1 parent f5f25c8 commit 8aecd24

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

libogc/gx.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4106,13 +4106,13 @@ void GX_SetIndTexMatrix(u8 indtexmtx,f32 offset_mtx[2][3],s8 scale_exp)
41064106
u32 ma,mb;
41074107
u32 val,s,idx;
41084108

4109-
if(indtexmtx>0x00 && indtexmtx<0x04) indtexmtx -= 0x01;
4110-
else if(indtexmtx>0x04 && indtexmtx<0x08) indtexmtx -= 0x05;
4111-
else if(indtexmtx>0x08 && indtexmtx<0x0C) indtexmtx -= 0x09;
4112-
else indtexmtx = 0x00;
4109+
if(indtexmtx>=GX_ITM_0 && indtexmtx<=GX_ITM_2) indtexmtx -= GX_ITM_0;
4110+
else if(indtexmtx>=GX_ITM_S0 && indtexmtx<=GX_ITM_S2) indtexmtx -= GX_ITM_S0;
4111+
else if(indtexmtx>=GX_ITM_T0 && indtexmtx<=GX_ITM_T2) indtexmtx -= GX_ITM_T0;
4112+
else indtexmtx = GX_ITM_OFF;
41134113

41144114
s = (scale_exp+17);
4115-
idx = ((indtexmtx<<2)-indtexmtx);
4115+
idx = indtexmtx * 3;
41164116

41174117
ma = (u32)(offset_mtx[0][0]*1024.0F);
41184118
mb = (u32)(offset_mtx[1][0]*1024.0F);
@@ -4218,18 +4218,18 @@ void GX_SetTevIndTile(u8 tevstage,u8 indtexid,u16 tilesize_x,u16 tilesize_y,u16
42184218
u32 fbuf_y[2] = { 0x43300000,tilespacing_y };
42194219

42204220
wrap_s = GX_ITW_OFF;
4221-
if(tilesize_x==0x0010) wrap_s = GX_ITW_16;
4222-
else if(tilesize_x==0x0020) wrap_s = GX_ITW_32;
4223-
else if(tilesize_x==0x0040) wrap_s = GX_ITW_64;
4224-
else if(tilesize_x==0x0080) wrap_s = GX_ITW_128;
4225-
else if(tilesize_x==0x0100) wrap_s = GX_ITW_256;
4221+
if(tilesize_x==16) wrap_s = GX_ITW_16;
4222+
else if(tilesize_x==32) wrap_s = GX_ITW_32;
4223+
else if(tilesize_x==64) wrap_s = GX_ITW_64;
4224+
else if(tilesize_x==128) wrap_s = GX_ITW_128;
4225+
else if(tilesize_x==256) wrap_s = GX_ITW_256;
42264226

42274227
wrap_t = GX_ITW_OFF;
4228-
if(tilesize_y==0x0010) wrap_t = GX_ITW_16;
4229-
else if(tilesize_y==0x0020) wrap_t = GX_ITW_32;
4230-
else if(tilesize_y==0x0040) wrap_t = GX_ITW_64;
4231-
else if(tilesize_y==0x0080) wrap_t = GX_ITW_128;
4232-
else if(tilesize_y==0x0100) wrap_t = GX_ITW_256;
4228+
if(tilesize_y==16) wrap_t = GX_ITW_16;
4229+
else if(tilesize_y==32) wrap_t = GX_ITW_32;
4230+
else if(tilesize_y==64) wrap_t = GX_ITW_64;
4231+
else if(tilesize_y==128) wrap_t = GX_ITW_128;
4232+
else if(tilesize_y==256) wrap_t = GX_ITW_256;
42334233

42344234
fdspace_x = *(f64*)((void*)fbuf_x);
42354235
fdspace_y = *(f64*)((void*)fbuf_y);

0 commit comments

Comments
 (0)