diff options
Diffstat (limited to 'src/code/gDPLoadTextureBlock_Runtime.inc.c')
| -rw-r--r-- | src/code/gDPLoadTextureBlock_Runtime.inc.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/code/gDPLoadTextureBlock_Runtime.inc.c b/src/code/gDPLoadTextureBlock_Runtime.inc.c new file mode 100644 index 000000000..f90841564 --- /dev/null +++ b/src/code/gDPLoadTextureBlock_Runtime.inc.c @@ -0,0 +1,62 @@ +#ifndef GDP_LOADTEXTUREBLOCK_RUNTIME_INC_C +#define GDP_LOADTEXTUREBLOCK_RUNTIME_INC_C + +#include "gfx.h" + +static u32 sLoadTextureBlock_siz[] = { + G_IM_SIZ_4b, + G_IM_SIZ_8b, + G_IM_SIZ_16b, + G_IM_SIZ_32b, +}; +static u32 sLoadTextureBlock_siz_LOAD_BLOCK[] = { + G_IM_SIZ_4b_LOAD_BLOCK, + G_IM_SIZ_8b_LOAD_BLOCK, + G_IM_SIZ_16b_LOAD_BLOCK, + G_IM_SIZ_32b_LOAD_BLOCK, +}; +static u32 sLoadTextureBlock_siz_INCR[] = { + G_IM_SIZ_4b_INCR, + G_IM_SIZ_8b_INCR, + G_IM_SIZ_16b_INCR, + G_IM_SIZ_32b_INCR, +}; +static u32 sLoadTextureBlock_siz_SHIFT[] = { + G_IM_SIZ_4b_SHIFT, + G_IM_SIZ_8b_SHIFT, + G_IM_SIZ_16b_SHIFT, + G_IM_SIZ_32b_SHIFT, +}; +static u32 sLoadTextureBlock_siz_BYTES[] = { + G_IM_SIZ_4b_BYTES, + G_IM_SIZ_8b_BYTES, + G_IM_SIZ_16b_BYTES, + G_IM_SIZ_32b_BYTES, +}; +static u32 sLoadTextureBlock_siz_LINE_BYTES[] = { + G_IM_SIZ_4b_LINE_BYTES, + G_IM_SIZ_8b_LINE_BYTES, + G_IM_SIZ_16b_LINE_BYTES, + G_IM_SIZ_32b_LINE_BYTES, +}; + +/** + * Implements a version of gDPLoadTextureBlock using table lookups instead of token pasting, to allow values to be + * passed into `siz` during runtime. + */ +#define gDPLoadTextureBlock_Runtime(pkt, timg, fmt, siz, width, height, pal, cms, cmt, masks, maskt, shifts, shiftt) \ + _DW({ \ + gDPSetTextureImage(pkt, fmt, sLoadTextureBlock_siz_LOAD_BLOCK[siz], 1, timg); \ + gDPSetTile(pkt, fmt, sLoadTextureBlock_siz_LOAD_BLOCK[siz], 0, 0, G_TX_LOADTILE, 0, cmt, maskt, shiftt, cms, \ + masks, shifts); \ + gDPLoadSync(pkt); \ + gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, \ + (((width) * (height) + sLoadTextureBlock_siz_INCR[siz]) >> sLoadTextureBlock_siz_SHIFT[siz]) - 1, \ + CALC_DXT(width, sLoadTextureBlock_siz_BYTES[siz])); \ + gDPPipeSync(pkt); \ + gDPSetTile(pkt, fmt, sLoadTextureBlock_siz[siz], (((width)*sLoadTextureBlock_siz_LINE_BYTES[siz]) + 7) >> 3, \ + 0, G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, shifts); \ + gDPSetTileSize(pkt, G_TX_RENDERTILE, 0, 0, ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ + ((height)-1) << G_TEXTURE_IMAGE_FRAC); \ + }) +#endif |
