diff options
| author | mzxrules <mzxrules@gmail.com> | 2024-06-20 21:21:37 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-20 18:21:37 -0700 |
| commit | 2c680efa9169eaaddae97330fa3ea9586a273b57 (patch) | |
| tree | ce5df566d1079693852420d0276750f8939da18f /src/code/gDPLoadTextureBlock_Runtime.inc.c | |
| parent | b55f8ffe6e60ed2335acbe7d428049ea1056f4b5 (diff) | |
z_map decompiled (#1032)
* First batch of functions
* more ok
* z_map_data OK
* More OKs, MinimapList ZAPD breaking change
* func_80103A58 improvements, more OK
* func_80106D5C and func_801091F0 decomped
* func_801031D0 decomped and some fixes
* house cleaning, more OKs more decomp
* Even more OKs
* func_80105C40 almost OK, more OKs
* func_80108AF8 OK and more
* All functions attempted
* func_8010534C OK
* Start documentation, rename DoorCtx
* More OKs, split map_data.data, more doc
* incremental clean-up, more function names
* more function names
* func_801068FC OK
* old uncommitted changes
* minor tweaks
* implement easy fixes
* more fixes
* z_map_disp OK, implement more suggestions
* delete utility program
* migrate data
* TransiActor ->TransitionActor
* Major documentation pass
* first pass of changes
* warning fix attempt, revert ZFile.cpp
* Fix FAKE match
* Easy fixes
* implement gDPLoadTextureBlock_Runtime
* z_demo bss patch
* Extract white square texture
* Implement more suggestions
* rework MapIndex/DungeonIndex
* revert dungeonSceneIndex -> mapIndex in some spots, implement suggestions
* more suggestions
* minor nits
* fix #include
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 |
