Skip to content

Commit cdbdcdc

Browse files
mardyExtrems
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 9952708 commit cdbdcdc

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
@@ -4241,13 +4241,13 @@ void GX_SetIndTexMatrix(u8 indtexmtx,const f32 offset_mtx[2][3],s8 scale_exp)
42414241
u32 ma,mb;
42424242
u32 val,s,idx;
42434243

4244-
if(indtexmtx>0x00 && indtexmtx<0x04) indtexmtx -= 0x01;
4245-
else if(indtexmtx>0x04 && indtexmtx<0x08) indtexmtx -= 0x05;
4246-
else if(indtexmtx>0x08 && indtexmtx<0x0C) indtexmtx -= 0x09;
4247-
else indtexmtx = 0x00;
4244+
if(indtexmtx>=GX_ITM_0 && indtexmtx<=GX_ITM_2) indtexmtx -= GX_ITM_0;
4245+
else if(indtexmtx>=GX_ITM_S0 && indtexmtx<=GX_ITM_S2) indtexmtx -= GX_ITM_S0;
4246+
else if(indtexmtx>=GX_ITM_T0 && indtexmtx<=GX_ITM_T2) indtexmtx -= GX_ITM_T0;
4247+
else indtexmtx = GX_ITM_OFF;
42484248

42494249
s = (scale_exp+17);
4250-
idx = ((indtexmtx<<2)-indtexmtx);
4250+
idx = (indtexmtx*3);
42514251

42524252
ma = (u32)(offset_mtx[0][0]*1024.0F);
42534253
mb = (u32)(offset_mtx[1][0]*1024.0F);
@@ -4346,18 +4346,18 @@ void GX_SetTevIndTile(u8 tevstage,u8 indtexid,u16 tilesize_x,u16 tilesize_y,u16
43464346
u32 fbuf_y[2] = { 0x43300000,tilespacing_y };
43474347

43484348
wrap_s = GX_ITW_OFF;
4349-
if(tilesize_x==0x0010) wrap_s = GX_ITW_16;
4350-
else if(tilesize_x==0x0020) wrap_s = GX_ITW_32;
4351-
else if(tilesize_x==0x0040) wrap_s = GX_ITW_64;
4352-
else if(tilesize_x==0x0080) wrap_s = GX_ITW_128;
4353-
else if(tilesize_x==0x0100) wrap_s = GX_ITW_256;
4349+
if(tilesize_x==16) wrap_s = GX_ITW_16;
4350+
else if(tilesize_x==32) wrap_s = GX_ITW_32;
4351+
else if(tilesize_x==64) wrap_s = GX_ITW_64;
4352+
else if(tilesize_x==128) wrap_s = GX_ITW_128;
4353+
else if(tilesize_x==256) wrap_s = GX_ITW_256;
43544354

43554355
wrap_t = GX_ITW_OFF;
4356-
if(tilesize_y==0x0010) wrap_t = GX_ITW_16;
4357-
else if(tilesize_y==0x0020) wrap_t = GX_ITW_32;
4358-
else if(tilesize_y==0x0040) wrap_t = GX_ITW_64;
4359-
else if(tilesize_y==0x0080) wrap_t = GX_ITW_128;
4360-
else if(tilesize_y==0x0100) wrap_t = GX_ITW_256;
4356+
if(tilesize_y==16) wrap_t = GX_ITW_16;
4357+
else if(tilesize_y==32) wrap_t = GX_ITW_32;
4358+
else if(tilesize_y==64) wrap_t = GX_ITW_64;
4359+
else if(tilesize_y==128) wrap_t = GX_ITW_128;
4360+
else if(tilesize_y==256) wrap_t = GX_ITW_256;
43614361

43624362
fdspace_x = *(f64*)((void*)fbuf_x);
43634363
fdspace_y = *(f64*)((void*)fbuf_y);

0 commit comments

Comments
 (0)