Files
mm/src/code/gDPLoadTextureBlock_Runtime.inc.c
T
mzxrules 2c680efa91 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
2024-06-20 18:21:37 -07:00

63 lines
2.8 KiB
C

#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