261 s16 offsetX, s16 offsetY, s32 clamp, s32 dropShadow) {
266 s32 widthScale, heightScale;
267 s32 texStartX, texStartY;
268 u32 isLastTileX, isLastTileY;
269 s32 uls, ult, lrs, lrt;
270 s32 uly, lry, ulx, lrx;
272 s32 screenPosOffsetScaledX, screenPosOffsetScaledY;
278 u16 renderPosX, renderPosY;
287 screenPosOffsetScaledX /= widthScale;
289 screenPosOffsetScaledY /= heightScale;
293 renderPosX += hudElement->
renderPosX + screenPosOffsetScaledX;
294 renderPosY += hudElement->
renderPosY + screenPosOffsetScaledY;
309 isFmtCI4 = flags1 != 0;
311 isFmtIA8 = flags1 != 0;
318 if (isFmtCI4 == FALSE && isFmtIA8 == FALSE) {
321 if (isFmtCI4 == TRUE && isFmtIA8 == FALSE) {
324 if (isFmtCI4 == FALSE && isFmtIA8 == TRUE) {
327 if (isFmtCI4 == TRUE && isFmtIA8 == TRUE) {
361 gDPSetRenderMode(
gMainGfxPos++, G_RM_XLU_SURF, G_RM_XLU_SURF2);
367 gDPSetRenderMode(
gMainGfxPos++, G_RM_TEX_EDGE, G_RM_TEX_EDGE2);
369 gDPSetRenderMode(
gMainGfxPos++, G_RM_AA_TEX_EDGE, G_RM_AA_TEX_EDGE2);
373 gDPSetRenderMode(
gMainGfxPos++, G_RM_CLD_SURF, G_RM_CLD_SURF2);
375 gDPSetRenderMode(
gMainGfxPos++, G_RM_CLD_SURF | AA_EN, G_RM_CLD_SURF2 | AA_EN);
382 gDPSetRenderMode(
gMainGfxPos++, G_RM_XLU_SURF, G_RM_XLU_SURF2);
397 lry = uly + 1024.0 / heightScale * 32.0;
400 texStartY = texSizeY;
418 if (lrt + 1 >= texSizeY) {
421 lry = baseY + drawSizeY - 1;
423 lry = baseY + drawSizeY;
432 lrx = ulx + 1024.0 / widthScale * 64.0;
435 texStartX = texSizeX;
453 if (lrs + 1 >= texSizeX) {
456 lrx = baseX + drawSizeX - 1;
458 lrx = baseX + drawSizeX;
466 tileMode = !isLastTileY;
468 if (!isLastTileX && !isLastTileY) {
471 if (!isLastTileX && isLastTileY) {
474 if (isLastTileX && isLastTileY) {
480 gDPSetCombineMode(
gMainGfxPos++, G_CC_DECALRGBA, G_CC_DECALRGBA);
482 gDPSetCombineMode(
gMainGfxPos++, G_CC_DECALRGBA, G_CC_DECALRGBA);
491 if (!flipX && !flipY) {
492 gDPLoadTextureTile(
gMainGfxPos++, imageAddr, G_IM_FMT_RGBA, G_IM_SIZ_32b, texSizeX, texSizeY, uls, ult, lrs, lrt, 0,
493 G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, masks, maskt, G_TX_NOLOD, G_TX_NOLOD);
495 gDPLoadTextureTile(
gMainGfxPos++, imageAddr, G_IM_FMT_RGBA, G_IM_SIZ_32b, texSizeX, texSizeY, uls, ult, lrs, lrt, 0,
496 G_TX_MIRROR | G_TX_WRAP, G_TX_MIRROR | G_TX_WRAP, masks, maskt, G_TX_NOLOD, G_TX_NOLOD);
513 gDPSetRenderMode(
gMainGfxPos++, G_RM_XLU_SURF, G_RM_XLU_SURF2);
515 gDPSetPrimColor(
gMainGfxPos++, 0, 0, 40, 40, 40, 72);
518 if (!flipX && !flipY) {
520 gDPLoadTextureTile_4b(
gMainGfxPos++, imageAddr, G_IM_FMT_CI, texSizeX, texSizeY, uls, ult, lrs, lrt, 0,
521 G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, masks, maskt, G_TX_NOLOD, G_TX_NOLOD);
525 gDPLoadTextureTile_4b(
gMainGfxPos++, imageAddr, G_IM_FMT_CI, texSizeX, texSizeY, uls, ult, lrs, lrt, 0,
526 G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, masks, maskt, G_TX_NOLOD, G_TX_NOLOD);
529 gDPLoadTextureTile_4b(
gMainGfxPos++, imageAddr, G_IM_FMT_CI, texSizeX, texSizeY, uls, ult, lrs, lrt, 0,
530 G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, masks, maskt, G_TX_NOLOD, G_TX_NOLOD);
533 gDPLoadTextureTile_4b(
gMainGfxPos++, imageAddr, G_IM_FMT_CI, texSizeX, texSizeY, uls, ult, lrs, lrt, 0,
534 G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, masks, maskt, G_TX_NOLOD, G_TX_NOLOD);
537 gDPLoadTextureTile_4b(
gMainGfxPos++, imageAddr, G_IM_FMT_CI, texSizeX, texSizeY, uls, ult, lrs, lrt, 0,
538 G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, masks, maskt, G_TX_NOLOD, G_TX_NOLOD);
543 gDPLoadTextureTile_4b(
gMainGfxPos++, imageAddr, G_IM_FMT_CI, texSizeX, texSizeY, uls, ult, lrs, lrt, 0,
544 G_TX_MIRROR | G_TX_WRAP, G_TX_MIRROR | G_TX_WRAP, masks, maskt, G_TX_NOLOD, G_TX_NOLOD);
551 if (!flipX && !flipY) {
555 gDPLoadTextureTile(
gMainGfxPos++, imageAddr, G_IM_FMT_IA, G_IM_SIZ_8b, texSizeX, texSizeY, uls, ult, lrs, lrt, 0,
556 G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, masks, maskt, G_TX_NOLOD, G_TX_NOLOD);
559 gDPLoadTextureTile(
gMainGfxPos++, imageAddr, G_IM_FMT_IA, G_IM_SIZ_8b, texSizeX, texSizeY, uls, ult, lrs, lrt, 0,
560 G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, masks, maskt, G_TX_NOLOD, G_TX_NOLOD);
563 gDPLoadTextureTile(
gMainGfxPos++, imageAddr, G_IM_FMT_IA, G_IM_SIZ_8b, texSizeX, texSizeY, uls, ult, lrs, lrt, 0,
564 G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, masks, maskt, G_TX_NOLOD, G_TX_NOLOD);
567 gDPLoadTextureTile(
gMainGfxPos++, imageAddr, G_IM_FMT_IA, G_IM_SIZ_8b, texSizeX, texSizeY, uls, ult, lrs, lrt, 0,
568 G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, masks, maskt, G_TX_NOLOD, G_TX_NOLOD);
572 gDPLoadTextureTile(
gMainGfxPos++, imageAddr, G_IM_FMT_IA, G_IM_SIZ_8b, texSizeX, texSizeY, uls, ult, lrs, lrt, 0,
573 G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, masks, maskt, G_TX_NOLOD, G_TX_NOLOD);
576 gDPLoadTextureTile(
gMainGfxPos++, imageAddr, G_IM_FMT_IA, G_IM_SIZ_8b, texSizeX, texSizeY, uls, ult, lrs, lrt, 0,
577 G_TX_MIRROR | G_TX_WRAP, G_TX_MIRROR | G_TX_WRAP, masks, maskt, G_TX_NOLOD, G_TX_NOLOD);
583 gSPScisTextureRectangle(
gMainGfxPos++, ulx * 4, uly * 4, lrx * 4, lry * 4, 0, texStartX * 32 + 16, texStartY * 32 + 16, widthScale, heightScale);
585 gSPScisTextureRectangle(
gMainGfxPos++, ulx * 4, uly * 4, lrx * 4, lry * 4, 0, texStartX * 32, texStartY * 32, widthScale, heightScale);
590 ulx += 1024.0 / widthScale * 64.0;
599 uly += 1024.0 / heightScale * 32.0;
807 f32 xScaled, yScaled;
808 s32 imageWidth, imageHeight, drawWidth, drawHeight;
816 s32* nextPos = (s32*)hudElement->
readPos;
818 switch (*nextPos++) {
838 hudElement->
flags &= ~HUD_ELEMENT_FLAG_FMT_CI4;
843 hudElement->
flags |= s1;
848 hudElement->
flags &= ~s1;
881 hudElement->
flags &= ~HUD_ELEMENT_FLAG_200;
922 hudElement->
flags &= ~HUD_ELEMENT_FLAG_200;
943 if (entryRaster[i].
id == *nextPos) {
954 if (entryPalette[i].
id == *nextPos) {
985 hudElement->
flags &= ~HUD_ELEMENT_FLAG_200;
1010 sizePreset = *nextPos++;
1016 hudElement->
flags &= ~HUD_ELEMENT_FLAG_FIXEDSCALE;
1017 hudElement->
flags &= ~HUD_ELEMENT_FLAG_REPEATED;
1020 tileSizePreset = *nextPos++;
1032 xScaled = (f32) drawWidth / (f32) imageWidth;
1033 yScaled = (f32) drawHeight / (f32) imageHeight;
1035 xScaled = 1.0f / xScaled;
1036 yScaled = 1.0f / yScaled;
1041 hudElement->
flags &= ~HUD_ELEMENT_FLAG_FIXEDSCALE;
1045 tileSizePreset = *nextPos++;
1046 drawSizePreset = *nextPos++;
1054 hudElement->
flags &= ~HUD_ELEMENT_FLAG_REPEATED;
1055 hudElement->
flags &= ~HUD_ELEMENT_FLAG_200;
1083 uniformScale = (f32)*nextPos++;
1084 uniformScale /= 65536;
1098 hudElement->
sizeX = drawWidth * uniformScale;
1099 hudElement->
sizeY = drawHeight * uniformScale;
1101 xScaled = (f32) drawWidth / (f32) imageWidth * uniformScale;
1102 yScaled = (f32) drawHeight / (f32) imageHeight * uniformScale;
1104 xScaled = 1.0f / xScaled;
1105 yScaled = 1.0f / yScaled;
1111 hudElement->
flags &= ~HUD_ELEMENT_FLAG_FIXEDSCALE;
1118 if (hudElement->
opacity == 255) {
1119 hudElement->
flags &= ~HUD_ELEMENT_FLAG_TRANSPARENT;
1137 hudElement->
flags &= ~HUD_ELEMENT_FLAG_FIXEDSCALE;
1138 hudElement->
flags &= ~HUD_ELEMENT_FLAG_REPEATED;
1145 hudElement->
flags |= s1 << 24;
1150 hudElement->
readPos = newReadPos;
1163 hudTransform->
pivot.
x = arg1;
1164 hudTransform->
pivot.
y = arg2;
1178 s32 texSizeX, texSizeY;
1179 s32 drawSizeX, drawSizeY, offsetX, offsetY;
1190 hudElement = (*gHudElements)[i];
1191 if (hudElement != NULL) {
1196 sortedElements[count++] = i;
1203 for (i = 0; i < count - 1; i++) {
1204 for (j = i + 1; j < count; j++) {
1205 el1 = sortedElements[i];
1206 el2 = sortedElements[j];
1207 if ((*
gHudElements)[el1]->worldPosOffset.z < (*gHudElements)[el2]->worldPosOffset.z) {
1208 sortedElements[i] = el2;
1209 sortedElements[j] = el1;
1214 for (i = 0; i < count; i++) {
1215 hudElement = (*gHudElements)[sortedElements[i]];
1217 if (hudElement->
readPos == NULL) {
1234 offsetX = -drawSizeX / 2;
1235 offsetY = -drawSizeY / 2;
1239 offsetX = -drawSizeX / 2;
1240 offsetY = -drawSizeY / 2;
1243 drawSizeX = hudElement->
sizeX;
1244 drawSizeY = hudElement->
sizeY;
1245 offsetX = -drawSizeX / 2;
1246 offsetY = -drawSizeY / 2;
1251 hud_element_draw_rect(hudElement, texSizeX, texSizeY, drawSizeX, drawSizeY, offsetX, offsetY, TRUE, TRUE);
1253 hud_element_draw_rect(hudElement, texSizeX, texSizeY, drawSizeX, drawSizeY, offsetX, offsetY, TRUE, FALSE);
1256 hud_element_draw_rect(hudElement, texSizeX, texSizeY, drawSizeX, drawSizeY, offsetX, offsetY, FALSE, TRUE);
1258 hud_element_draw_rect(hudElement, texSizeX, texSizeY, drawSizeX, drawSizeY, offsetX, offsetY, FALSE, FALSE);
1261 f32 xScaled, yScaled;
1277 xScaled = (f32) drawSizeX / (f32) texSizeX;
1278 yScaled = (f32) drawSizeY / (f32) texSizeY;
1280 xScaled = 1.0f / xScaled;
1281 yScaled = 1.0f / yScaled;
1287 hud_element_draw_rect(hudElement, texSizeX, texSizeY, drawSizeX, drawSizeY, offsetX, offsetY, FALSE, TRUE);
1289 hud_element_draw_rect(hudElement, texSizeX, texSizeY, drawSizeX, drawSizeY, offsetX, offsetY, FALSE, FALSE);
1298 s32 texSizeX, texSizeY;
1299 s32 drawSizeX, drawSizeY, offsetX, offsetY;
1306 hudElement = (*gHudElements)[i];
1307 if (hudElement != NULL) {
1312 sortedElements[count++] = i;
1319 for (i = 0; i < count - 1; i++) {
1320 for (j = i + 1; j < count; j++) {
1321 el1 = sortedElements[i];
1322 el2 = sortedElements[j];
1323 if ((*
gHudElements)[el1]->worldPosOffset.z < (*gHudElements)[el2]->worldPosOffset.z) {
1324 sortedElements[i] = el2;
1325 sortedElements[j] = el1;
1330 for (i = 0; i < count; i++) {
1331 hudElement = (*gHudElements)[sortedElements[i]];
1345 offsetX = -drawSizeX / 2;
1346 offsetY = -drawSizeY / 2;
1350 offsetX = -drawSizeX / 2;
1351 offsetY = -drawSizeY / 2;
1354 drawSizeX = hudElement->
sizeX;
1355 drawSizeY = hudElement->
sizeY;
1356 offsetX = -drawSizeX / 2;
1357 offsetY = -drawSizeY / 2;
1362 hud_element_draw_rect(hudElement, texSizeX, texSizeY, drawSizeX, drawSizeY, offsetX, offsetY, TRUE, TRUE);
1364 hud_element_draw_rect(hudElement, texSizeX, texSizeY, drawSizeX, drawSizeY, offsetX, offsetY, TRUE, FALSE);
1367 hud_element_draw_rect(hudElement, texSizeX, texSizeY, drawSizeX, drawSizeY, offsetX, offsetY, FALSE, TRUE);
1369 hud_element_draw_rect(hudElement, texSizeX, texSizeY, drawSizeX, drawSizeY, offsetX, offsetY, FALSE, FALSE);
1372 f32 xScaled, yScaled;
1388 xScaled = (f32) drawSizeX / (f32) texSizeX;
1389 yScaled = (f32) drawSizeY / (f32) texSizeY;
1391 xScaled = 1.0f / xScaled;
1392 yScaled = 1.0f / yScaled;
1398 hud_element_draw_rect(hudElement, texSizeX, texSizeY, drawSizeX, drawSizeY, offsetX, offsetY, FALSE, TRUE);
1400 hud_element_draw_rect(hudElement, texSizeX, texSizeY, drawSizeX, drawSizeY, offsetX, offsetY, FALSE, FALSE);