diff --git a/include/macros.h b/include/macros.h index 5ed5c9e465..a5aa2754fb 100644 --- a/include/macros.h +++ b/include/macros.h @@ -273,17 +273,24 @@ extern struct GraphicsContext* __gfxCtx; #define VTX_T(x,y,z,s,t,cr,cg,cb,a) { { x, y, z }, 0, { s, t }, { cr, cg, cb, a } } -#define gDPSetTileCustom(pkt, fmt, siz, width, height, pal, cms, cmt, masks, maskt, shifts, shiftt) \ - do { \ - gDPPipeSync(pkt); \ - gDPTileSync(pkt); \ - gDPSetTile(pkt, fmt, siz, (((width)*siz##_TILE_BYTES) + 7) >> 3, 0, G_TX_LOADTILE, 0, cmt, maskt, shiftt, cms, \ - masks, shifts); \ - gDPTileSync(pkt); \ - gDPSetTile(pkt, fmt, siz, (((width)*siz##_TILE_BYTES) + 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); \ - } while (0) +#define gDPSetTileCustom(pkt, fmt, siz, uls, ult, lrs, lrt, pal, \ + cms, cmt, masks, maskt, shifts, shiftt) \ +_DW({ \ + gDPPipeSync(pkt); \ + gDPTileSync(pkt); \ + gDPSetTile(pkt, fmt, siz, \ + (((((lrs) - (uls) + 1) * siz##_TILE_BYTES) + 7) >> 3), 0, \ + G_TX_LOADTILE, 0, cmt, maskt, shiftt, cms, masks, \ + shifts); \ + gDPTileSync(pkt); \ + gDPSetTile(pkt, fmt, siz, \ + (((((lrs) - (uls) + 1) * siz##_LINE_BYTES) + 7) >> 3), 0, \ + G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, shifts); \ + gDPSetTileSize(pkt, G_TX_RENDERTILE, \ + (uls) << G_TEXTURE_IMAGE_FRAC, \ + (ult) << G_TEXTURE_IMAGE_FRAC, \ + (lrs) << G_TEXTURE_IMAGE_FRAC, \ + (lrt) << G_TEXTURE_IMAGE_FRAC); \ +}) #endif diff --git a/src/overlays/actors/ovl_En_Mag/z_en_mag.c b/src/overlays/actors/ovl_En_Mag/z_en_mag.c index fc41c5d958..bbcf393628 100644 --- a/src/overlays/actors/ovl_En_Mag/z_en_mag.c +++ b/src/overlays/actors/ovl_En_Mag/z_en_mag.c @@ -429,16 +429,17 @@ void EnMag_DrawImageRGBA32(Gfx** gfxP, s16 centerX, s16 centerY, u8* source, u32 curTexture = source; rectLeft = centerX - (width / 2); rectTop = centerY - (height / 2); - textureHeight = 4096 / (width << 2); remainingSize = (width * height) << 2; + textureHeight = 4096 / (width << 2); textureSize = (width * textureHeight) << 2; textureCount = remainingSize / textureSize; if ((remainingSize % textureSize) != 0) { textureCount += 1; } - gDPSetTileCustom(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_32b, width, textureHeight, 0, G_TX_NOMIRROR | G_TX_CLAMP, - G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + gDPSetTileCustom(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_32b, 0, 0, width - 1, textureHeight - 1, 0, + G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); remainingSize -= textureSize; @@ -459,7 +460,7 @@ void EnMag_DrawImageRGBA32(Gfx** gfxP, s16 centerX, s16 centerY, u8* source, u32 textureHeight = remainingSize / (s32)(width << 2); remainingSize -= textureSize; - gDPSetTileCustom(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_32b, width, textureHeight, 0, + gDPSetTileCustom(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_32b, 0, 0, width - 1, textureHeight - 1, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); } diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c index 529bb61424..8866d63224 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c +++ b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c @@ -45,8 +45,9 @@ void KaleidoScope_DrawEquipmentImage(PlayState* play, void* source, u32 width, u vtxIndex = 80; - gDPSetTileCustom(POLY_OPA_DISP++, G_IM_FMT_RGBA, G_IM_SIZ_16b, width, textureHeight, 0, G_TX_NOMIRROR | G_TX_CLAMP, - G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + gDPSetTileCustom(POLY_OPA_DISP++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0, width - 1, textureHeight - 1, 0, + G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); remainingSize -= textureSize; @@ -67,7 +68,7 @@ void KaleidoScope_DrawEquipmentImage(PlayState* play, void* source, u32 width, u textureHeight = remainingSize / (s32)(width * 2); remainingSize -= textureSize; - gDPSetTileCustom(POLY_OPA_DISP++, G_IM_FMT_RGBA, G_IM_SIZ_16b, width, textureHeight, 0, + gDPSetTileCustom(POLY_OPA_DISP++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0, width - 1, textureHeight - 1, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); }