Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
hud_element.c
Go to the documentation of this file.
1#include "common.h"
2#include "hud_element.h"
3#include "nu/nusys.h"
4#include "ld_addrs.h"
5
6#define MAX_HUD_CACHE_ENTRIES 192
7
8typedef struct HudElementSize {
9 s16 width;
10 s16 height;
11 s16 size;
13
16
20
22 { 8, 8, 32 },
23 { 16, 16, 128 },
24 { 24, 24, 288 },
25 { 32, 32, 512 },
26 { 48, 48, 1152 },
27 { 64, 64, 2048 },
28 { 8, 16, 64 },
29 { 16, 8, 64 },
30 { 16, 24, 192 },
31 { 16, 32, 256 },
32 { 64, 32, 1024 },
33 { 32, 16, 256 },
34 { 12, 12, 72 },
35 { 48, 24, 576 },
36 { 32, 8, 128 },
37 { 24, 8, 96 },
38 { 64, 16, 512 },
39 { 16, 64, 512 },
40 { 192, 32, 3072 },
41 { 40, 40, 800 },
42 { 24, 16, 192 },
43 { 32, 40, 640 },
44 { 40, 16, 320 },
45 { 40, 24, 480 },
46 { 32, 24, 384 },
47 { 20, 32, 0 }
48};
49
50s16 D_8014F068[] = { 34, 32, 0, 40, 40, 968, 0, 0 };
52 gsDPSetScissor(G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT),
53 gsDPPipeSync(),
54 gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_ALPHADITHER, 18, G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE | G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE),
55 gsDPSetAlphaCompare(G_AC_NONE),
56 gsSPEndDisplayList()
57};
59 gsDPSetScissor(G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT),
60 gsDPPipeSync(),
61 gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_ALPHADITHER, 18, G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE | G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE),
62 gsDPSetAlphaCompare(G_AC_NONE),
63 gsSPEndDisplayList()
64};
65
66Vtx D_8014F0C8[] = {
67 {
68 .v = {
69 .ob = { -12, 0, 0},
70 .flag = 0,
71 .tc = { 0x800, 0x800 },
72 .cn = { 0, 0, 0, 255}
73 }
74 },
75 {
76 .v = {
77 .ob = { 51, 0, 0},
78 .flag = 0,
79 .tc = { 0, 0x800 },
80 .cn = { 0, 0, 0, 255}
81 }
82 },
83 {
84 .v = {
85 .ob = { 51, 63, 0},
86 .flag = 0,
87 .tc = { 0, 0 },
88 .cn = { 0, 0, 0, 255}
89 }
90 },
91 {
92 .v = {
93 .ob = { -12, 63, 0},
94 .flag = 0,
95 .tc = { 0x800, 0 },
96 .cn = { 0, 0, 0, 255}
97 }
98 }
99};
100
101Lights1 HudElementLights = gdSPDefLights1(255, 255, 255, 0, 0, 0, 0, 0, 0);
102
108
121
122void hud_element_setup_cam(void);
123
125 s32* pos = (s32*)anim;
126 s32 raster;
127 s32 palette;
128 s32 preset;
129 HudCacheEntry* entry;
130 s32 i;
131 s32 capacity;
132
133 if (pos == NULL) {
134 return;
135 }
136
137 preset = 0;
138
139 while (TRUE) {
140 switch (*pos++) {
142 return;
144 pos += 3;
145 break;
147 preset = *pos++;
148 hudElement->drawSizePreset = hudElement->tileSizePreset = preset;
149 break;
152 preset = *pos;
153 pos += 2;
154 hudElement->drawSizePreset = hudElement->tileSizePreset = preset;
155 break;
157 hudElement->customDrawSize.x = hudElement->customImageSize.x = *pos++;
158 hudElement->customDrawSize.y = hudElement->customImageSize.y = *pos++;
159 hudElement->flags |= HUD_ELEMENT_FLAG_CUSTOM_SIZE;
160 break;
170 pos++;
171 break;
177 pos += 2;
178 break;
180 pos++;
181 raster = *pos++;
182 palette = *pos++;
183
184 i = 0;
186 while (TRUE) {
187 if (entry->id == -1) {
188 entry->id = raster;
191 capacity = gHudElementCacheCapacity;
192 } else {
193 capacity = gHudElementCacheCapacity / 2;
194 }
195 ASSERT(capacity > *gHudElementCacheSize + gHudElementSizes[preset].size);
196 nuPiReadRom((s32)icon_ROM_START + raster, entry->data, gHudElementSizes[preset].size);
199 *pos = i;
200 } else {
201 *pos = (u16)(*pos) | (i << 16);
202 }
203 i++;
204 break;
205 } else if (entry->id == raster) {
207 *pos = i;
208 } else {
209 *pos = (u16)(*pos) | (i << 16);
210 }
211 break;
212 }
213 entry++;
214 i++;
215 }
216
217 pos++;
219
221 i = 0;
222 while (TRUE) {
223 if (entry->id == -1) {
224 entry->id = palette;
227 capacity = gHudElementCacheCapacity;
228 } else {
229 capacity = gHudElementCacheCapacity / 2;
230 }
231 ASSERT(capacity > *gHudElementCacheSize + 32);
232 nuPiReadRom((s32)icon_ROM_START + palette, entry->data, 32);
235 *pos = i;
236 } else {
237 *pos = (u16)(*pos) | (i << 16);
238 }
239 i++;
240 break;
241 } else if (entry->id == palette) {
243 *pos = i;
244 } else {
245 *pos = (u16)(*pos) | (i << 16);
246 }
247 break;
248 }
249 entry++;
250 i++;
251 }
252
253 pos++;
255 break;
256 }
257 }
258}
259
260void hud_element_draw_rect(HudElement* hudElement, s16 texSizeX, s16 texSizeY, s16 drawSizeX, s16 drawSizeY,
261 s16 offsetX, s16 offsetY, s32 clamp, s32 dropShadow) {
262 u32 isFmtCI4;
263 u32 isFmtIA8;
264 s32 flipX, flipY;
265 s32 fmt;
266 s32 widthScale, heightScale;
267 s32 texStartX, texStartY;
268 u32 isLastTileX, isLastTileY;
269 s32 uls, ult, lrs, lrt;
270 s32 uly, lry, ulx, lrx;
271 s32 masks, maskt;
272 s32 screenPosOffsetScaledX, screenPosOffsetScaledY;
273 IMG_PTR imageAddr;
274 PAL_PTR paletteAddr;
275 s16 baseX, baseY;
276 s32 tileMode;
277 u32 flags1, flags2;
278 u16 renderPosX, renderPosY;
279 s16 tempX, tempY;
280
281 imageAddr = hudElement->imageAddr;
282 paletteAddr = (u16*) hudElement->paletteAddr;
283
284 screenPosOffsetScaledX = hudElement->screenPosOffset.x * 1024;
285 screenPosOffsetScaledY = hudElement->screenPosOffset.y * 1024;
286 widthScale = hudElement->widthScale;
287 screenPosOffsetScaledX /= widthScale;
288 heightScale = hudElement->heightScale;
289 screenPosOffsetScaledY /= heightScale;
290
291 renderPosX = hudElement->worldPosOffset.x;
292 renderPosY = hudElement->worldPosOffset.y;
293 renderPosX += hudElement->renderPosX + screenPosOffsetScaledX;
294 renderPosY += hudElement->renderPosY + screenPosOffsetScaledY;
295 tempX = offsetX;
296 tempY = offsetY;
297 tempX += renderPosX;
298 tempY += renderPosY;
299
300 baseX = tempX;
301 baseY = tempY;
302
303 if (dropShadow) {
304 baseX = tempX + 2;
305 baseY = tempY + 2;
306 }
307
308 flags1 = (hudElement->flags & HUD_ELEMENT_FLAG_FMT_CI4);
309 isFmtCI4 = flags1 != 0;
310 flags1 = (hudElement->flags & HUD_ELEMENT_FLAG_FMT_IA8);
311 isFmtIA8 = flags1 != 0;
312 flags1 = (hudElement->flags & HUD_ELEMENT_FLAG_FLIPX);
313 flipX = flags1 != 0;
314 flags2 = (hudElement->flags & HUD_ELEMENT_FLAG_FLIPY);
315 flipY = flags2 != 0;
316
317 fmt = 0;
318 if (isFmtCI4 == FALSE && isFmtIA8 == FALSE) {
319 fmt = 0; // RGBA
320 }
321 if (isFmtCI4 == TRUE && isFmtIA8 == FALSE) {
322 fmt = 1; // CI
323 }
324 if (isFmtCI4 == FALSE && isFmtIA8 == TRUE) {
325 fmt = 2; // IA
326 }
327 if (isFmtCI4 == TRUE && isFmtIA8 == TRUE) {
328 fmt = 2; // IA
329 }
330
331 masks = 6;
332 maskt = 5;
333 if (!(hudElement->flags & HUD_ELEMENT_FLAG_SCALED)) {
334 switch (drawSizeX) {
335 case 8:
336 masks = 3;
337 break;
338 case 16:
339 masks = 4;
340 break;
341 case 32:
342 masks = 5;
343 break;
344 }
345
346 switch (drawSizeY) {
347 case 8:
348 maskt = 3;
349 break;
350 case 16:
351 maskt = 4;
352 break;
353 case 32:
354 maskt = 5;
355 break;
356 }
357 }
358
359 switch (fmt) {
360 case 0:
361 gDPSetRenderMode(gMainGfxPos++, G_RM_XLU_SURF, G_RM_XLU_SURF2);
362 gDPSetTextureLUT(gMainGfxPos++, G_TT_NONE);
363 break;
364 case 1:
365 if (!(hudElement->flags & HUD_ELEMENT_FLAG_TRANSPARENT)) {
366 if (!(hudElement->flags & HUD_ELEMENT_FLAG_ANTIALIASING)) {
367 gDPSetRenderMode(gMainGfxPos++, G_RM_TEX_EDGE, G_RM_TEX_EDGE2);
368 } else {
369 gDPSetRenderMode(gMainGfxPos++, G_RM_AA_TEX_EDGE, G_RM_AA_TEX_EDGE2);
370 }
371 } else {
372 if (!(hudElement->flags & HUD_ELEMENT_FLAG_ANTIALIASING)) {
373 gDPSetRenderMode(gMainGfxPos++, G_RM_CLD_SURF, G_RM_CLD_SURF2);
374 } else {
375 gDPSetRenderMode(gMainGfxPos++, G_RM_CLD_SURF | AA_EN, G_RM_CLD_SURF2 | AA_EN);
376 }
377 }
378 gDPSetTextureLUT(gMainGfxPos++, G_TT_RGBA16);
379 gDPLoadTLUT_pal16(gMainGfxPos++, 0, paletteAddr);
380 break;
381 case 2:
382 gDPSetRenderMode(gMainGfxPos++, G_RM_XLU_SURF, G_RM_XLU_SURF2);
383 gDPSetTextureLUT(gMainGfxPos++, G_TT_NONE);
384 break;
385 }
386
387 if (hudElement->flags & HUD_ELEMENT_FLAG_FILTER_TEX) {
388 gDPSetTextureFilter(gMainGfxPos++, G_TF_AVERAGE);
389 } else {
390 gDPSetTextureFilter(gMainGfxPos++, G_TF_POINT);
391 }
392
393 ult = 0;
394 isLastTileY = FALSE;
395 uly = baseY;
396 while (TRUE) {
397 lry = uly + 1024.0 / heightScale * 32.0;
398 lrt = ult + 31;
399 if (flipY) {
400 texStartY = texSizeY;
401 } else {
402 texStartY = 0;
403 }
404
405 if (lry < 0 || uly > SCREEN_HEIGHT) {
406 break;
407 }
408
409 if (lry >= SCREEN_HEIGHT) {
410 s32 temp = ult + SCREEN_HEIGHT + 31;
411 temp -= baseY + lrt;
412 lrt = temp - 1;
413
414 lry = SCREEN_HEIGHT;
415 isLastTileY = TRUE;
416 }
417
418 if (lrt + 1 >= texSizeY) {
419 lrt = texSizeY - 1;
420 if (texSizeY > 16) {
421 lry = baseY + drawSizeY - 1;
422 } else {
423 lry = baseY + drawSizeY;
424 }
425 isLastTileY = TRUE;
426 }
427
428 isLastTileX = FALSE;
429 uls = 0;
430 ulx = baseX;
431 while (TRUE) {
432 lrx = ulx + 1024.0 / widthScale * 64.0;
433 lrs = uls + 63;
434 if (flipX) {
435 texStartX = texSizeX;
436 } else {
437 texStartX = 0;
438 }
439
440 if (lrx < 0 || ulx > SCREEN_WIDTH) {
441 break;
442 }
443
444 if (lrx >= SCREEN_WIDTH) {
445 s32 temp = uls + SCREEN_WIDTH + 63;
446 temp -= baseX + lrs;
447 lrs = temp - 1;
448
449 lrx = SCREEN_WIDTH;
450 isLastTileX = TRUE;
451 }
452
453 if (lrs + 1 >= texSizeX) {
454 lrs = texSizeX - 1;
455 if (texSizeX > 16) {
456 lrx = baseX + drawSizeX - 1;
457 } else {
458 lrx = baseX + drawSizeX;
459 }
460 isLastTileX = TRUE;
461 }
462
463 gDPPipeSync(gMainGfxPos++);
464
465 if (isLastTileX ) {
466 tileMode = !isLastTileY;
467 }
468 if (!isLastTileX && !isLastTileY) {
469 tileMode = 0;
470 }
471 if (!isLastTileX && isLastTileY) {
472 tileMode = 2;
473 }
474 if (isLastTileX && isLastTileY) {
475 tileMode = 3;
476 }
477
478 switch (fmt) {
479 case 0:
480 gDPSetCombineMode(gMainGfxPos++, G_CC_DECALRGBA, G_CC_DECALRGBA);
481 if (!(hudElement->flags & HUD_ELEMENT_FLAG_TRANSPARENT)) {
482 gDPSetCombineMode(gMainGfxPos++, G_CC_DECALRGBA, G_CC_DECALRGBA);
483 } else {
484 gDPSetCombineMode(gMainGfxPos++, PM_CC_01, PM_CC_02);
485 }
486
487 if (hudElement->flags & HUD_ELEMENT_FLAG_TRANSPARENT) {
488 gDPSetPrimColor(gMainGfxPos++, 0, 0, 0, 0, 0, hudElement->opacity);
489 }
490
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);
494 } else {
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);
497 }
498 break;
499 case 1:
500 if (!dropShadow) {
501 if (hudElement->flags & HUD_ELEMENT_FLAG_TRANSPARENT) {
502 gDPSetCombineMode(gMainGfxPos++, PM_CC_2F, PM_CC_32);
503 } else {
504 gDPSetCombineMode(gMainGfxPos++, PM_CC_2F, PM_CC_32);
505 }
506
507 if (hudElement->flags & HUD_ELEMENT_FLAG_TRANSPARENT) {
508 gDPSetPrimColor(gMainGfxPos++, 0, 0, hudElement->tint.r, hudElement->tint.g, hudElement->tint.b, hudElement->opacity);
509 } else {
510 gDPSetPrimColor(gMainGfxPos++, 0, 0, hudElement->tint.r, hudElement->tint.g, hudElement->tint.b, 255);
511 }
512 } else {
513 gDPSetRenderMode(gMainGfxPos++, G_RM_XLU_SURF, G_RM_XLU_SURF2);
514 gDPSetCombineMode(gMainGfxPos++, PM_CC_07, PM_CC_07);
515 gDPSetPrimColor(gMainGfxPos++, 0, 0, 40, 40, 40, 72);
516 }
517
518 if (!flipX && !flipY) {
519 if (!clamp) {
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);
522 } else {
523 switch (tileMode) {
524 case 0:
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);
527 break;
528 case 1:
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);
531 break;
532 case 2:
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);
535 break;
536 case 3:
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);
539 break;
540 }
541 }
542 } else {
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);
545 }
546 break;
547 case 2:
548 gDPSetCombineMode(gMainGfxPos++, PM_CC_47, PM_CC_47);
549 gDPSetPrimColor(gMainGfxPos++, 0, 0, hudElement->tint.r, hudElement->tint.g, hudElement->tint.b, hudElement->opacity);
550
551 if (!flipX && !flipY) {
552 if (!clamp) {
553 switch (tileMode) {
554 case 0:
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);
557 break;
558 case 1:
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);
561 break;
562 case 2:
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);
565 break;
566 case 3:
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);
569 break;
570 }
571 } else {
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);
574 }
575 } else {
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);
578 }
579 break;
580 }
581
582 if (hudElement->flags & HUD_ELEMENT_FLAG_FILTER_TEX) {
583 gSPScisTextureRectangle(gMainGfxPos++, ulx * 4, uly * 4, lrx * 4, lry * 4, 0, texStartX * 32 + 16, texStartY * 32 + 16, widthScale, heightScale);
584 } else {
585 gSPScisTextureRectangle(gMainGfxPos++, ulx * 4, uly * 4, lrx * 4, lry * 4, 0, texStartX * 32, texStartY * 32, widthScale, heightScale);
586 }
587 if (isLastTileX) {
588 break;
589 }
590 ulx += 1024.0 / widthScale * 64.0;
591 uls += 64;
592 }
593
594 if (isLastTileY) {
595 break;
596 }
597
598 ult += 32;
599 uly += 1024.0 / heightScale * 32.0;
600 }
601
602 gDPPipeSync(gMainGfxPos++);
603}
604
606 HudCacheEntry* entryRaster;
607 HudCacheEntry* entryPalette;
608 s32 i;
609
615 } else {
620 }
621
627 entryRaster = gHudElementCacheTableRaster;
628 entryPalette = gHudElementCacheTablePalette;
629 for (i = 0; i < MAX_HUD_CACHE_ENTRIES; i++) {
630 entryRaster[i].id = -1;
631 entryPalette[i].id = -1;
632 }
633 } else {
634 if (gHudElementAuxCache == NULL) {
637 } else {
639 }
642 entryRaster = gHudElementCacheTableRaster;
643 entryPalette = gHudElementCacheTablePalette;
644 for (i = 0; i < MAX_HUD_CACHE_ENTRIES; i++) {
645 entryRaster[i].id = -1;
646 entryPalette[i].id = -1;
647 }
648 }
649
650 for (i = 0; i < ARRAY_COUNT(*gHudElements); i++) {
651 (*gHudElements)[i] = NULL;
652 }
653
655 D_80159180 = 0;
657}
658
659#if VERSION_PAL
660extern Addr D_80200000;
661#endif
662
692
716
718 HudElement* hudElement;
719 s32 id;
720
721 for (id = 0; id < ARRAY_COUNT(*gHudElements); id++) {
722 if ((*gHudElements)[id] == NULL) {
723 break;
724 }
725 }
726
728
729 (*gHudElements)[id] = hudElement = heap_malloc(sizeof(*hudElement));
731
732 ASSERT(hudElement != NULL);
733
735 hudElement->readPos = anim;
736 if (anim == NULL) {
737 hudElement->readPos = &HES_Empty;
738 }
739 hudElement->updateTimer = 1;
740 hudElement->drawSizePreset = -1;
741 hudElement->tileSizePreset = -1;
742 hudElement->renderPosX = 0;
743 hudElement->renderPosY = 0;
744 hudElement->loopStartPos = anim;
745 hudElement->widthScale = X10(1.0f);
746 hudElement->heightScale = X10(1.0f);
747 hudElement->anim = hudElement->readPos;
748 hudElement->uniformScale = 1.0f;
749 hudElement->screenPosOffset.x = 0;
750 hudElement->screenPosOffset.y = 0;
751 hudElement->worldPosOffset.x = 0;
752 hudElement->worldPosOffset.y = 0;
753 hudElement->worldPosOffset.z = 0;
754 hudElement->opacity = 255;
755 hudElement->tint.r = 255;
756 hudElement->tint.g = 255;
757 hudElement->tint.b = 255;
758
760 hudElement->flags |= HUD_ELEMENT_FLAG_BATTLE;
762 }
763
764 hud_element_load_script(hudElement, hudElement->readPos);
765 while (hud_element_update(hudElement) != 0);
766
767 return id;
768}
769
770// TODO not ideal match - should be able to put loop iterator in the loop def, but can't
772 s32 i;
773
774 for (i = 0; i < ARRAY_COUNT(*gHudElements);) {
775 HudElement* elem = (*gHudElements)[i];
776
777 if (elem != NULL && elem->flags && !(elem->flags & HUD_ELEMENT_FLAG_DISABLED)) {
778 if (elem->flags & HUD_ELEMENT_FLAG_DELETE) {
780 i++;
781 } else if (elem->readPos != NULL) {
782 elem->updateTimer--;
783 if (elem->updateTimer == 0) {
784 while (hud_element_update(elem) != 0);
785 }
787 elem->unkImgScale[0] += elem->deltaSizeX;
788 elem->unkImgScale[1] += elem->deltaSizeY;
789 }
790 i++;
791 } else {
792 break;
793 }
794 } else {
795 i++;
796 }
797 }
798}
799
801 HudCacheEntry* entryRaster;
802 HudCacheEntry* entryPalette;
803 s32 i;
804 s32 drawSizePreset;
805 s32 tileSizePreset;
806 u8 sizePreset;
807 f32 xScaled, yScaled;
808 s32 imageWidth, imageHeight, drawWidth, drawHeight;
809 u32 flags;
810 s32 s1, s2;
811 s32 arg1, arg2;
812 f32 uniformScale;
813 HudScript* newReadPos;
814
815 HudTransform* hudTransform = hudElement->hudTransform;
816 s32* nextPos = (s32*)hudElement->readPos;
817
818 switch (*nextPos++) {
820 hudElement->updateTimer = 60;
821 flags = hudElement->flags;
823 break;
825 hudElement->updateTimer = 60;
826 hudElement->flags |= HUD_ELEMENT_FLAG_DELETE;
827 break;
829 hudElement->readPos = (HudScript*)nextPos;
830 hudElement->flags |= HUD_ELEMENT_FLAG_FMT_IA8;
831 return TRUE;
833 hudElement->readPos = (HudScript*)nextPos;
834 hudElement->flags |= HUD_ELEMENT_FLAG_FMT_CI4;
835 return TRUE;
837 hudElement->readPos = (HudScript*)nextPos;
838 hudElement->flags &= ~HUD_ELEMENT_FLAG_FMT_CI4;
839 return TRUE;
841 s1 = *nextPos++;
842 hudElement->readPos = (HudScript*)nextPos;
843 hudElement->flags |= s1;
844 return TRUE;
846 s1 = *nextPos++;
847 hudElement->readPos = (HudScript*)nextPos;
848 hudElement->flags &= ~s1;
849 return TRUE;
851 hudElement->updateTimer = *nextPos++;
852 hudElement->imageAddr = (u8*)*nextPos++;
853 hudElement->readPos = (HudScript*)nextPos;
854
855 if (hudElement->flags & HUD_ELEMENT_FLAG_MEMOFFSET) {
856 hudElement->imageAddr += hudElement->memOffset;
857 }
858
859 if (hudElement->flags & HUD_ELEMENT_FLAG_FIXEDSCALE) {
860 if (!(hudElement->flags & HUD_ELEMENT_FLAG_CUSTOM_SIZE)) {
861 tileSizePreset = hudElement->tileSizePreset;
862 drawSizePreset = hudElement->drawSizePreset;
863 imageWidth = gHudElementSizes[tileSizePreset].width;
864 imageHeight = gHudElementSizes[tileSizePreset].height;
865 drawWidth = gHudElementSizes[drawSizePreset].width;
866 drawHeight = gHudElementSizes[drawSizePreset].height;
867 } else {
868 imageWidth = hudElement->customImageSize.x;
869 imageHeight = hudElement->customImageSize.y;
870 drawWidth = hudElement->customDrawSize.x;
871 drawHeight = hudElement->customDrawSize.y;
872 }
873
874 if (!(hudElement->flags & HUD_ELEMENT_FLAG_200)) {
875 hudElement->flags |= HUD_ELEMENT_FLAG_200;
876 hudElement->unkImgScale[0] = imageWidth;
877 hudElement->unkImgScale[1] = imageHeight;
878 hudElement->deltaSizeX = ((f32)drawWidth - (f32)imageWidth) / (f32)hudElement->updateTimer;
879 hudElement->deltaSizeY = ((f32)drawHeight - (f32)imageHeight) / (f32)hudElement->updateTimer;
880 } else {
881 hudElement->flags &= ~HUD_ELEMENT_FLAG_200;
882 hudElement->unkImgScale[0] = drawWidth;
883 hudElement->unkImgScale[1] = drawHeight;
884 hudElement->deltaSizeX = ((f32)imageWidth - (f32)drawWidth) / (f32)hudElement->updateTimer;
885 hudElement->deltaSizeY = ((f32)imageHeight - (f32)drawHeight) / (f32)hudElement->updateTimer;
886 }
887 }
888 break;
890 hudElement->updateTimer = *nextPos++;
891 hudElement->imageAddr = (u8*)*nextPos++;
892 hudElement->paletteAddr = (u8*)*nextPos++;
893 hudElement->readPos = (HudScript*)nextPos;
894
895 if (hudElement->flags & HUD_ELEMENT_FLAG_MEMOFFSET) {
896 hudElement->imageAddr += hudElement->memOffset;
897 hudElement->paletteAddr += hudElement->memOffset;
898 }
899
900 if (hudElement->flags & HUD_ELEMENT_FLAG_FIXEDSCALE) {
901 if (!(hudElement->flags & HUD_ELEMENT_FLAG_CUSTOM_SIZE)) {
902 tileSizePreset = hudElement->tileSizePreset;
903 drawSizePreset = hudElement->drawSizePreset;
904 imageWidth = gHudElementSizes[tileSizePreset].width;
905 imageHeight = gHudElementSizes[tileSizePreset].height;
906 drawWidth = gHudElementSizes[drawSizePreset].width;
907 drawHeight = gHudElementSizes[drawSizePreset].height;
908 } else {
909 imageWidth = hudElement->customImageSize.x;
910 imageHeight = hudElement->customImageSize.y;
911 drawWidth = hudElement->customDrawSize.x;
912 drawHeight = hudElement->customDrawSize.y;
913 }
914
915 if (!(hudElement->flags & HUD_ELEMENT_FLAG_200)) {
916 hudElement->flags |= HUD_ELEMENT_FLAG_200;
917 hudElement->unkImgScale[0] = imageWidth;
918 hudElement->unkImgScale[1] = imageHeight;
919 hudElement->deltaSizeX = ((f32)drawWidth - (f32)imageWidth) / (f32)hudElement->updateTimer;
920 hudElement->deltaSizeY = ((f32)drawHeight - (f32)imageHeight) / (f32)hudElement->updateTimer;
921 } else {
922 hudElement->flags &= ~HUD_ELEMENT_FLAG_200;
923 hudElement->unkImgScale[0] = drawWidth;
924 hudElement->unkImgScale[1] = drawHeight;
925 hudElement->deltaSizeX = ((f32)imageWidth - (f32)drawWidth) / (f32)hudElement->updateTimer;
926 hudElement->deltaSizeY = ((f32)imageHeight - (f32)drawHeight) / (f32)hudElement->updateTimer;
927 }
928 }
929 break;
931 hudElement->updateTimer = *nextPos++;
932
933 if (!(hudElement->flags & HUD_ELEMENT_FLAG_BATTLE)) {
936 } else {
939 }
940
941 i = 0;
942 while (TRUE) {
943 if (entryRaster[i].id == *nextPos) {
944 break;
945 }
947 }
948
949 nextPos++;
950 hudElement->imageAddr = entryRaster[i].data;
951
952 i = 0;
953 while (TRUE) {
954 if (entryPalette[i].id == *nextPos) {
955 break;
956 }
958 }
959 hudElement->paletteAddr = entryPalette[i].data;
960 nextPos += 3;
961 hudElement->readPos = (HudScript*)nextPos;
962
963 if (hudElement->flags & HUD_ELEMENT_FLAG_FIXEDSCALE) {
964 if (!(hudElement->flags & HUD_ELEMENT_FLAG_CUSTOM_SIZE)) {
965 tileSizePreset = hudElement->tileSizePreset;
966 drawSizePreset = hudElement->drawSizePreset;
967 imageWidth = gHudElementSizes[tileSizePreset].width;
968 imageHeight = gHudElementSizes[tileSizePreset].height;
969 drawWidth = gHudElementSizes[drawSizePreset].width;
970 drawHeight = gHudElementSizes[drawSizePreset].height;
971 } else {
972 imageWidth = hudElement->customImageSize.x;
973 imageHeight = hudElement->customImageSize.y;
974 drawWidth = hudElement->customDrawSize.x;
975 drawHeight = hudElement->customDrawSize.y;
976 }
977
978 if (!(hudElement->flags & HUD_ELEMENT_FLAG_200)) {
979 hudElement->flags |= HUD_ELEMENT_FLAG_200;
980 hudElement->unkImgScale[0] = imageWidth;
981 hudElement->unkImgScale[1] = imageHeight;
982 hudElement->deltaSizeX = ((f32)drawWidth - (f32)imageWidth) / (f32)hudElement->updateTimer;
983 hudElement->deltaSizeY = ((f32)drawHeight - (f32)imageHeight) / (f32)hudElement->updateTimer;
984 } else {
985 hudElement->flags &= ~HUD_ELEMENT_FLAG_200;
986 hudElement->unkImgScale[0] = drawWidth;
987 hudElement->unkImgScale[1] = drawHeight;
988 hudElement->deltaSizeX = ((f32)imageWidth - (f32)drawWidth) / (f32)hudElement->updateTimer;
989 hudElement->deltaSizeY = ((f32)imageHeight - (f32)drawHeight) / (f32)hudElement->updateTimer;
990 }
991 }
992 break;
994 hudElement->readPos = hudElement->loopStartPos;
995 return TRUE;
997 hudElement->loopStartPos = (HudScript*)nextPos;
998 hudElement->readPos = (HudScript*)nextPos;
999 return TRUE;
1001 s1 = *nextPos++;
1002 s2 = *nextPos++;
1003 if (rand_int(s1) < s2) {
1004 hudElement->readPos = hudElement->loopStartPos;
1005 } else {
1006 hudElement->readPos = (HudScript*)nextPos;
1007 }
1008 return TRUE;
1010 sizePreset = *nextPos++;
1011 hudElement->widthScale = X10(1);
1012 hudElement->heightScale = X10(1);
1013 hudElement->readPos = (HudScript*)nextPos;
1014 hudElement->drawSizePreset = sizePreset;
1015 hudElement->tileSizePreset = sizePreset;
1016 hudElement->flags &= ~HUD_ELEMENT_FLAG_FIXEDSCALE;
1017 hudElement->flags &= ~HUD_ELEMENT_FLAG_REPEATED;
1018 return TRUE;
1020 tileSizePreset = *nextPos++;
1021 arg2 = *nextPos++;
1022
1023 hudElement->readPos = (HudScript*)nextPos;
1024 hudElement->tileSizePreset = tileSizePreset;
1025 hudElement->drawSizePreset = arg2;
1026
1027 imageWidth = gHudElementSizes[tileSizePreset].width;
1028 imageHeight = gHudElementSizes[tileSizePreset].height;
1029 drawWidth = gHudElementSizes[arg2].width;
1030 drawHeight = gHudElementSizes[arg2].height;
1031
1032 xScaled = (f32) drawWidth / (f32) imageWidth;
1033 yScaled = (f32) drawHeight / (f32) imageHeight;
1034
1035 xScaled = 1.0f / xScaled;
1036 yScaled = 1.0f / yScaled;
1037
1038 hudElement->widthScale = X10(xScaled);
1039 hudElement->heightScale = X10(yScaled);
1040
1041 hudElement->flags &= ~HUD_ELEMENT_FLAG_FIXEDSCALE;
1042 hudElement->flags |= HUD_ELEMENT_FLAG_REPEATED;
1043 return TRUE;
1045 tileSizePreset = *nextPos++;
1046 drawSizePreset = *nextPos++;
1047
1048 hudElement->widthScale = X10(1);
1049 hudElement->heightScale = X10(1);
1050 hudElement->readPos = (HudScript*)nextPos;
1051 hudElement->tileSizePreset = tileSizePreset;
1052 hudElement->drawSizePreset = drawSizePreset;
1053 hudElement->flags |= HUD_ELEMENT_FLAG_FIXEDSCALE;
1054 hudElement->flags &= ~HUD_ELEMENT_FLAG_REPEATED;
1055 hudElement->flags &= ~HUD_ELEMENT_FLAG_200;
1056 return TRUE;
1058 s1 = *nextPos++;
1059 hudElement->readPos = (HudScript*)nextPos;
1060 hudElement->screenPosOffset.x += s1;
1061 return TRUE;
1063 s2 = *nextPos++;
1064 if (!(hudElement->flags & HUD_ELEMENT_FLAG_FLIPY)) {
1065 hudElement->screenPosOffset.y += s2;
1066 } else {
1067 hudElement->screenPosOffset.y -= s2;
1068 }
1069 hudElement->readPos = (HudScript*)nextPos;
1070 return TRUE;
1072 s1 = *nextPos++;
1073 s2 = *nextPos++;
1074 hudElement->screenPosOffset.x = s1;
1075 if (!(hudElement->flags & HUD_ELEMENT_FLAG_FLIPY)) {
1076 hudElement->screenPosOffset.y = s2;
1077 } else {
1078 hudElement->screenPosOffset.y = -s2;
1079 }
1080 hudElement->readPos = (HudScript*)nextPos;
1081 return TRUE;
1083 uniformScale = (f32)*nextPos++;
1084 uniformScale /= 65536;
1085 hudElement->uniformScale = uniformScale;
1086 if (!(hudElement->flags & HUD_ELEMENT_FLAG_CUSTOM_SIZE)) {
1087 imageWidth = gHudElementSizes[hudElement->tileSizePreset].width;
1088 imageHeight = gHudElementSizes[hudElement->tileSizePreset].height;
1089 drawWidth = gHudElementSizes[hudElement->drawSizePreset].width;
1090 drawHeight = gHudElementSizes[hudElement->drawSizePreset].height;
1091 } else {
1092 imageWidth = hudElement->customImageSize.x;
1093 imageHeight = hudElement->customImageSize.y;
1094 drawWidth = hudElement->customDrawSize.x;
1095 drawHeight = hudElement->customDrawSize.y;
1096 }
1097
1098 hudElement->sizeX = drawWidth * uniformScale;
1099 hudElement->sizeY = drawHeight * uniformScale;
1100
1101 xScaled = (f32) drawWidth / (f32) imageWidth * uniformScale;
1102 yScaled = (f32) drawHeight / (f32) imageHeight * uniformScale;
1103
1104 xScaled = 1.0f / xScaled;
1105 yScaled = 1.0f / yScaled;
1106
1107 hudElement->widthScale = X10(xScaled);
1108 hudElement->heightScale = X10(yScaled);
1109
1110 hudElement->readPos = (HudScript*)nextPos;
1111 hudElement->flags &= ~HUD_ELEMENT_FLAG_FIXEDSCALE;
1113 return TRUE;
1115 s1 = *nextPos++;
1116 hudElement->opacity = s1;
1117 hudElement->flags |= HUD_ELEMENT_FLAG_TRANSPARENT;
1118 if (hudElement->opacity == 255) {
1119 hudElement->flags &= ~HUD_ELEMENT_FLAG_TRANSPARENT;
1120 }
1121 hudElement->readPos = (HudScript*)nextPos;
1122 return TRUE;
1124 s1 = *nextPos++;
1125 s2 = *nextPos++;
1126 hudElement->updateTimer = rand_int(s2 - s1) + s1;
1127 hudElement->readPos = (HudScript*)nextPos;
1128 break;
1130 hudElement->customDrawSize.x = hudElement->customImageSize.x = *nextPos++;
1131 hudElement->customDrawSize.y = hudElement->customImageSize.y = *nextPos++;
1132 hudElement->readPos = (HudScript*)nextPos;
1133 hudElement->widthScale = X10(1);
1134 hudElement->heightScale = X10(1);
1135 hudElement->drawSizePreset = 0;
1136 hudElement->tileSizePreset = 0;
1137 hudElement->flags &= ~HUD_ELEMENT_FLAG_FIXEDSCALE;
1138 hudElement->flags &= ~HUD_ELEMENT_FLAG_REPEATED;
1139 hudElement->flags |= HUD_ELEMENT_FLAG_CUSTOM_SIZE;
1140 return TRUE;
1142 s1 = *nextPos++;
1143 hudElement->readPos = (HudScript*)nextPos;
1145 hudElement->flags |= s1 << 24;
1146 return TRUE;
1148 s1 = *nextPos++;
1149 newReadPos = (HudScript*)nextPos[rand_int(s1 - 1)];
1150 hudElement->readPos = newReadPos;
1151 hud_element_load_script(hudElement, newReadPos);
1152 return TRUE;
1154 arg2 = *nextPos++;
1155 sfx_play_sound(arg2);
1156 hudElement->readPos = (HudScript*)nextPos;
1157 return TRUE;
1159 arg1 = *nextPos++;
1160 arg2 = *nextPos++;
1161 hudElement->readPos = (HudScript*)nextPos;
1162 if (hudElement->flags & HUD_ELEMENT_FLAG_TRANSFORM) {
1163 hudTransform->pivot.x = arg1;
1164 hudTransform->pivot.y = arg2;
1165 }
1166 return TRUE;
1168 break;
1169 }
1170
1171 return FALSE;
1172}
1173
1175 s32 i, count, j;
1176 s32 sortedElements[ARRAY_COUNT(*gHudElements)];
1177 s32 el1, el2;
1178 s32 texSizeX, texSizeY;
1179 s32 drawSizeX, drawSizeY, offsetX, offsetY;
1180 HudElement* hudElement;
1181
1182 D_80159180++;
1183 if (D_80159180 > 2) {
1184 D_80159180 = 0;
1185 }
1187
1188 count = 0;
1189 for (i = 0; i < ARRAY_COUNT(*gHudElements); i++) {
1190 hudElement = (*gHudElements)[i];
1191 if (hudElement != NULL) {
1192 s32 flags = hudElement->flags;
1195 if (!(flags & HUD_ELEMENT_FLAG_FRONTUI) && hudElement->drawSizePreset >= 0) {
1196 sortedElements[count++] = i;
1197 }
1198 }
1199 }
1200 }
1201 }
1202
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;
1210 }
1211 }
1212 }
1213
1214 for (i = 0; i < count; i++) {
1215 hudElement = (*gHudElements)[sortedElements[i]];
1216
1217 if (hudElement->readPos == NULL) {
1218 break;
1219 }
1220
1221 if (!(hudElement->flags & HUD_ELEMENT_FLAG_FIXEDSCALE)) {
1222 if (!(hudElement->flags & HUD_ELEMENT_FLAG_CUSTOM_SIZE)) {
1223 texSizeX = gHudElementSizes[hudElement->tileSizePreset].width;
1224 texSizeY = gHudElementSizes[hudElement->tileSizePreset].height;
1225 } else {
1226 texSizeX = hudElement->customImageSize.x;
1227 texSizeY = hudElement->customImageSize.y;
1228 }
1229
1230 if (!(hudElement->flags & HUD_ELEMENT_FLAG_SCALED)) {
1231 if (!(hudElement->flags & HUD_ELEMENT_FLAG_CUSTOM_SIZE)) {
1232 drawSizeX = gHudElementSizes[hudElement->drawSizePreset].width;
1233 drawSizeY = gHudElementSizes[hudElement->drawSizePreset].height;
1234 offsetX = -drawSizeX / 2;
1235 offsetY = -drawSizeY / 2;
1236 } else {
1237 drawSizeX = hudElement->customDrawSize.x;
1238 drawSizeY = hudElement->customDrawSize.y;
1239 offsetX = -drawSizeX / 2;
1240 offsetY = -drawSizeY / 2;
1241 }
1242 } else {
1243 drawSizeX = hudElement->sizeX;
1244 drawSizeY = hudElement->sizeY;
1245 offsetX = -drawSizeX / 2;
1246 offsetY = -drawSizeY / 2;
1247 }
1248
1249 if (!(hudElement->flags & HUD_ELEMENT_FLAG_REPEATED)) {
1250 if (hudElement->flags & HUD_ELEMENT_FLAG_DROP_SHADOW) {
1251 hud_element_draw_rect(hudElement, texSizeX, texSizeY, drawSizeX, drawSizeY, offsetX, offsetY, TRUE, TRUE);
1252 }
1253 hud_element_draw_rect(hudElement, texSizeX, texSizeY, drawSizeX, drawSizeY, offsetX, offsetY, TRUE, FALSE);
1254 } else {
1255 if (hudElement->flags & HUD_ELEMENT_FLAG_DROP_SHADOW) {
1256 hud_element_draw_rect(hudElement, texSizeX, texSizeY, drawSizeX, drawSizeY, offsetX, offsetY, FALSE, TRUE);
1257 }
1258 hud_element_draw_rect(hudElement, texSizeX, texSizeY, drawSizeX, drawSizeY, offsetX, offsetY, FALSE, FALSE);
1259 }
1260 } else {
1261 f32 xScaled, yScaled;
1262
1263 if (!(hudElement->flags & HUD_ELEMENT_FLAG_CUSTOM_SIZE)) {
1264 texSizeX = gHudElementSizes[hudElement->tileSizePreset].width;
1265 texSizeY = gHudElementSizes[hudElement->tileSizePreset].height;
1266 } else {
1267 texSizeX = hudElement->customImageSize.x;
1268 texSizeY = hudElement->customImageSize.y;
1269 }
1270
1271 drawSizeX = hudElement->unkImgScale[0];
1272 drawSizeY = hudElement->unkImgScale[1];
1273
1274 offsetX = -hudElement->unkImgScale[0] / 2;
1275 offsetY = -hudElement->unkImgScale[1] / 2;
1276
1277 xScaled = (f32) drawSizeX / (f32) texSizeX;
1278 yScaled = (f32) drawSizeY / (f32) texSizeY;
1279
1280 xScaled = 1.0f / xScaled;
1281 yScaled = 1.0f / yScaled;
1282
1283 hudElement->widthScale = X10(xScaled);
1284 hudElement->heightScale = X10(yScaled);
1285
1286 if (hudElement->flags & HUD_ELEMENT_FLAG_DROP_SHADOW) {
1287 hud_element_draw_rect(hudElement, texSizeX, texSizeY, drawSizeX, drawSizeY, offsetX, offsetY, FALSE, TRUE);
1288 }
1289 hud_element_draw_rect(hudElement, texSizeX, texSizeY, drawSizeX, drawSizeY, offsetX, offsetY, FALSE, FALSE);
1290 }
1291 }
1292}
1293
1295 s32 i, count, j;
1296 s32 sortedElements[ARRAY_COUNT(*gHudElements)];
1297 s32 el1, el2;
1298 s32 texSizeX, texSizeY;
1299 s32 drawSizeX, drawSizeY, offsetX, offsetY;
1300 HudElement* hudElement;
1301
1303
1304 count = 0;
1305 for (i = 0; i < ARRAY_COUNT(*gHudElements); i++) {
1306 hudElement = (*gHudElements)[i];
1307 if (hudElement != NULL) {
1308 s32 flags = hudElement->flags;
1311 if ((flags & HUD_ELEMENT_FLAG_FRONTUI) && hudElement->drawSizePreset >= 0) {
1312 sortedElements[count++] = i;
1313 }
1314 }
1315 }
1316 }
1317 }
1318
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;
1326 }
1327 }
1328 }
1329
1330 for (i = 0; i < count; i++) {
1331 hudElement = (*gHudElements)[sortedElements[i]];
1332 if (!(hudElement->flags & HUD_ELEMENT_FLAG_FIXEDSCALE)) {
1333 if (!(hudElement->flags & HUD_ELEMENT_FLAG_CUSTOM_SIZE)) {
1334 texSizeX = gHudElementSizes[hudElement->tileSizePreset].width;
1335 texSizeY = gHudElementSizes[hudElement->tileSizePreset].height;
1336 } else {
1337 texSizeX = hudElement->customImageSize.x;
1338 texSizeY = hudElement->customImageSize.y;
1339 }
1340
1341 if (!(hudElement->flags & HUD_ELEMENT_FLAG_SCALED)) {
1342 if (!(hudElement->flags & HUD_ELEMENT_FLAG_CUSTOM_SIZE)) {
1343 drawSizeX = gHudElementSizes[hudElement->drawSizePreset].width;
1344 drawSizeY = gHudElementSizes[hudElement->drawSizePreset].height;
1345 offsetX = -drawSizeX / 2;
1346 offsetY = -drawSizeY / 2;
1347 } else {
1348 drawSizeX = hudElement->customDrawSize.x;
1349 drawSizeY = hudElement->customDrawSize.y;
1350 offsetX = -drawSizeX / 2;
1351 offsetY = -drawSizeY / 2;
1352 }
1353 } else {
1354 drawSizeX = hudElement->sizeX;
1355 drawSizeY = hudElement->sizeY;
1356 offsetX = -drawSizeX / 2;
1357 offsetY = -drawSizeY / 2;
1358 }
1359
1360 if (!(hudElement->flags & HUD_ELEMENT_FLAG_REPEATED)) {
1361 if (hudElement->flags & HUD_ELEMENT_FLAG_DROP_SHADOW) {
1362 hud_element_draw_rect(hudElement, texSizeX, texSizeY, drawSizeX, drawSizeY, offsetX, offsetY, TRUE, TRUE);
1363 }
1364 hud_element_draw_rect(hudElement, texSizeX, texSizeY, drawSizeX, drawSizeY, offsetX, offsetY, TRUE, FALSE);
1365 } else {
1366 if (hudElement->flags & HUD_ELEMENT_FLAG_DROP_SHADOW) {
1367 hud_element_draw_rect(hudElement, texSizeX, texSizeY, drawSizeX, drawSizeY, offsetX, offsetY, FALSE, TRUE);
1368 }
1369 hud_element_draw_rect(hudElement, texSizeX, texSizeY, drawSizeX, drawSizeY, offsetX, offsetY, FALSE, FALSE);
1370 }
1371 } else {
1372 f32 xScaled, yScaled;
1373
1374 if (!(hudElement->flags & HUD_ELEMENT_FLAG_CUSTOM_SIZE)) {
1375 texSizeX = gHudElementSizes[hudElement->drawSizePreset].width;
1376 texSizeY = gHudElementSizes[hudElement->drawSizePreset].height;
1377 } else {
1378 texSizeX = hudElement->customImageSize.x;
1379 texSizeY = hudElement->customImageSize.y;
1380 }
1381
1382 drawSizeX = hudElement->unkImgScale[0];
1383 drawSizeY = hudElement->unkImgScale[1];
1384
1385 offsetX = -hudElement->unkImgScale[0] / 2;
1386 offsetY = -hudElement->unkImgScale[1] / 2;
1387
1388 xScaled = (f32) drawSizeX / (f32) texSizeX;
1389 yScaled = (f32) drawSizeY / (f32) texSizeY;
1390
1391 xScaled = 1.0f / xScaled;
1392 yScaled = 1.0f / yScaled;
1393
1394 hudElement->widthScale = X10(xScaled);
1395 hudElement->heightScale = X10(yScaled);
1396
1397 if (hudElement->flags & HUD_ELEMENT_FLAG_DROP_SHADOW) {
1398 hud_element_draw_rect(hudElement, texSizeX, texSizeY, drawSizeX, drawSizeY, offsetX, offsetY, FALSE, TRUE);
1399 }
1400 hud_element_draw_rect(hudElement, texSizeX, texSizeY, drawSizeX, drawSizeY, offsetX, offsetY, FALSE, FALSE);
1401 }
1402 }
1403}
1404
1406 Matrix4f sp20;
1407 Matrix4f sp60;
1408 Matrix4f spA0;
1409 Matrix4f spE0;
1410 Matrix4f sp120;
1411 Matrix4f sp160;
1412 Matrix4f sp1A0;
1413 Matrix4f sp1E0;
1414 Matrix4f sp220;
1415 Matrix4f sp260;
1416 ImgFXTexture ifxImg;
1417 f32 xScaleFactor, yScaleFactor;
1418 s32 height, width;
1419 HudTransform* transform;
1420 s32 mode;
1421 PAL_PTR palette;
1422 u32 a0, v1;
1423 Vtx* vtx;
1424 Vtx* vtx2;
1425
1426 if (hudElement->flags & HUD_ELEMENT_FLAG_FILTER_TEX) {
1427 gDPSetTextureFilter(gMainGfxPos++, G_TF_AVERAGE);
1428 } else {
1429 gDPSetTextureFilter(gMainGfxPos++, G_TF_POINT);
1430 }
1431
1432 if (!(hudElement->flags & HUD_ELEMENT_FLAG_FIXEDSCALE)) {
1433 xScaleFactor = 1.0f;
1434 yScaleFactor = 1.0f;
1435 } else {
1436 if (!(hudElement->flags & HUD_ELEMENT_FLAG_CUSTOM_SIZE)) {
1437 xScaleFactor = gHudElementSizes[hudElement->tileSizePreset].width;
1438 yScaleFactor = gHudElementSizes[hudElement->tileSizePreset].height;
1439 } else {
1440 xScaleFactor = hudElement->customImageSize.x;
1441 yScaleFactor = hudElement->customImageSize.y;
1442 }
1443 xScaleFactor /= hudElement->unkImgScale[0];
1444 xScaleFactor = 1.0f / xScaleFactor;
1445 yScaleFactor /= hudElement->unkImgScale[1];
1446 yScaleFactor = 1.0f / yScaleFactor;
1447 }
1448
1449 if (!(hudElement->flags & HUD_ELEMENT_FLAG_CUSTOM_SIZE)) {
1450 width = gHudElementSizes[hudElement->tileSizePreset].width;
1451 height = gHudElementSizes[hudElement->tileSizePreset].height;
1452 } else {
1453 width = hudElement->customImageSize.x;
1454 height = hudElement->customImageSize.y;
1455 }
1456
1457 transform = hudElement->hudTransform;
1458
1459 guTranslateF(sp1E0, transform->pivot.x, -transform->pivot.y, 0.0f);
1460 guTranslateF(sp220, -transform->pivot.x, transform->pivot.y, 0.0f);
1462 sp1A0,
1463 hudElement->renderPosX + hudElement->screenPosOffset.x + hudElement->worldPosOffset.x + transform->pos.x,
1464 -hudElement->renderPosY - hudElement->screenPosOffset.y + hudElement->worldPosOffset.y + transform->pos.y,
1465 - (hudElement->worldPosOffset.z / 10.0) + transform->pos.z
1466 );
1467 guScaleF(sp260, hudElement->uniformScale * xScaleFactor * transform->scale.x,
1468 hudElement->uniformScale * yScaleFactor * transform->scale.y,
1469 transform->scale.z);
1470 guRotateF(sp120, transform->rot.y, 0.0f, 1.0f, 0.0f);
1471 guRotateF(sp160, transform->rot.z, 0.0f, 0.0f, 1.0f);
1472 guRotateF(spE0, transform->rot.x, 1.0f, 0.0f, 0.0f);
1473 guMtxCatF(sp160, spE0, sp20);
1474 guMtxCatF(sp20, sp120, spA0);
1475 guMtxCatF(sp260, sp1E0, sp20);
1476 guMtxCatF(sp20, spA0, sp60);
1477 guMtxCatF(sp60, sp220, sp20);
1478 guMtxCatF(sp20, sp1A0, sp60);
1481 G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
1482
1483 mode = 0;
1484 a0 = mode;
1485 a0 = (hudElement->flags & HUD_ELEMENT_FLAG_FMT_CI4) > a0;
1486 v1 = mode < (hudElement->flags & HUD_ELEMENT_FLAG_FMT_IA8);
1487
1488 if (a0 == TRUE) {
1489 mode = (v1 < 1);
1490 }
1491 if (a0 == FALSE) {
1492 if (v1 == TRUE) {
1493 mode = 2;
1494 }
1495 }
1496
1497 if (a0 == TRUE) {
1498 if (v1 == a0) {
1499 mode = 2;
1500 }
1501 }
1502
1503 switch (mode) {
1504 case 1:
1505 if (hudElement->flags & HUD_ELEMENT_FLAG_NO_FOLD) {
1506 if (hudElement->flags & HUD_ELEMENT_FLAG_TRANSPARENT) {
1507 imgfx_update(0, IMGFX_SET_ALPHA, 255, 255, 255, hudElement->opacity, 0);
1508 } else {
1509 imgfx_update(0, IMGFX_CLEAR, 0, 0, 0, 0, 0);
1510 }
1511 } else {
1512 if (hudElement->flags & HUD_ELEMENT_FLAG_TRANSPARENT) {
1513 imgfx_update(transform->imgfxIdx, IMGFX_SET_ALPHA, 255, 255, 255, hudElement->opacity, 0);
1514 } else {
1515 imgfx_update(transform->imgfxIdx, IMGFX_CLEAR, 0, 0, 0, 0, 0);
1516 }
1517 }
1518
1519 ifxImg.raster = hudElement->imageAddr;
1520 palette = (u16*) hudElement->paletteAddr;
1521 ifxImg.width = width;
1522 ifxImg.height = height;
1523 ifxImg.xOffset = -width / 2;
1524 ifxImg.yOffset = height / 2;
1525 ifxImg.alpha = 255;
1526 ifxImg.palette = palette;
1527
1528 if (hudElement->flags & HUD_ELEMENT_FLAG_NO_FOLD) {
1529 if (hudElement->flags & HUD_ELEMENT_FLAG_ANTIALIASING) {
1530 imgfx_appendGfx_component(0, &ifxImg, IMGFX_FLAG_40, sp60);
1531 } else {
1532 imgfx_appendGfx_component(0, &ifxImg, IMGFX_FLAG_40, sp60);
1533 }
1534 } else {
1535 imgfx_appendGfx_component(transform->imgfxIdx, &ifxImg, IMGFX_FLAG_40, sp60);
1536 }
1537 break;
1538 case 2:
1539 transform->unk_30[D_80159180].vtx[0] = D_8014F0C8[0];
1540 transform->unk_30[D_80159180].vtx[1] = D_8014F0C8[1];
1541 transform->unk_30[D_80159180].vtx[2] = D_8014F0C8[2];
1542 transform->unk_30[D_80159180].vtx[3] = D_8014F0C8[3];
1543
1544 vtx2 = transform->unk_30[D_80159180].vtx;
1545 vtx = vtx2;
1546
1547 vtx2->v.ob[0] = -width / 2;
1548 vtx2->v.ob[1] = -height / 2;
1549 vtx2->v.ob[2] = 0;
1550 vtx2->v.tc[0] = 0;
1551 vtx2->v.tc[1] = height * 32;
1552 vtx2 = vtx2 + 1;
1553 vtx2[0].v.ob[0] = (width / 2) - 1;
1554 vtx2[0].v.ob[1] = -height / 2;
1555 vtx2[0].v.ob[2] = 0;
1556 vtx2[0].v.tc[0] = width * 32;
1557 vtx2[0].v.tc[1] = height * 32;
1558 vtx[2].v.ob[0] = (width / 2) - 1;
1559 vtx[2].v.ob[1] = (height / 2) - 1;
1560 vtx[2].v.ob[2] = 0;
1561 vtx[2].v.tc[0] = width * 32;
1562 vtx[2].v.tc[1] = 0;
1563 vtx[3].v.ob[0] = -width / 2;
1564 vtx[3].v.ob[1] = (height / 2) - 1;
1565 vtx[3].v.ob[2] = 0;
1566 vtx[3].v.tc[0] = 0;
1567 vtx[3].v.tc[1] = 0;
1568
1569 gDPPipeSync(gMainGfxPos++);
1570 gDPSetCombineMode(gMainGfxPos++, PM_CC_47, PM_CC_47);
1571 gDPSetPrimColor(gMainGfxPos++, 0, 0,
1572 hudElement->tint.r, hudElement->tint.g, hudElement->tint.b, hudElement->opacity);
1573
1574 if (!(hudElement->flags & HUD_ELEMENT_FLAG_TRANSPARENT)) {
1575 if (!(hudElement->flags & HUD_ELEMENT_FLAG_ANTIALIASING)) {
1576 gDPSetRenderMode(gMainGfxPos++, G_RM_TEX_EDGE, G_RM_TEX_EDGE2);
1577 } else {
1578 gDPSetRenderMode(gMainGfxPos++, G_RM_AA_TEX_EDGE, G_RM_AA_TEX_EDGE2);
1579 }
1580 } else {
1581 if (!(hudElement->flags & HUD_ELEMENT_FLAG_ANTIALIASING)) {
1582 gDPSetRenderMode(gMainGfxPos++, G_RM_CLD_SURF, G_RM_CLD_SURF2);
1583 } else {
1584 gDPSetRenderMode(gMainGfxPos++, AA_EN | G_RM_CLD_SURF, AA_EN | G_RM_CLD_SURF2);
1585 }
1586 }
1587
1588 gDPLoadTextureBlock(gMainGfxPos++, hudElement->imageAddr, G_IM_FMT_IA, G_IM_SIZ_8b, width, height, 0,
1589 G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK,
1590 G_TX_NOLOD, G_TX_NOLOD);
1591
1592 gDPSetTextureLUT(gMainGfxPos++, G_TT_NONE);
1593 gSPVertex(gMainGfxPos++, &transform->unk_30[D_80159180], 4, 0);
1594 gSP1Triangle(gMainGfxPos++, 0, 1, 2, 0);
1595 gSP1Triangle(gMainGfxPos++, 0, 2, 3, 0);
1596 break;
1597 }
1598
1599 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
1600 gDPPipeSync(gMainGfxPos++);
1601}
1602
1604 s32 i, count, j;
1605 s32 sortedElements[ARRAY_COUNT(*gHudElements)];
1606 s32 el1, el2;
1607 HudElement* hudElement;
1608 s32 flags;
1609
1610 count = 0;
1611 if (gCurrentCamID == CAM_HUD) {
1612 for (i = 0; i < ARRAY_COUNT(*gHudElements); i++) {
1613 hudElement = (*gHudElements)[i];
1614 if (hudElement == NULL) {
1615 continue;
1616 }
1617
1618 flags = hudElement->flags;
1619 if (flags == 0 || flags & HUD_ELEMENT_FLAG_DISABLED) {
1620 continue;
1621 }
1622
1624 continue;
1625 }
1626
1628 continue;
1629 }
1630
1632 continue;
1633 }
1634
1636 continue;
1637 }
1638
1639 // add element to list
1640 sortedElements[count++] = i;
1641 }
1642
1643 if (count != 0) {
1644 for (i = 0; i < count - 1; i++) {
1645 for (j = i + 1; j < count; j++) {
1646 el1 = sortedElements[i];
1647 el2 = sortedElements[j];
1648
1649 if ((*gHudElements)[el1]->worldPosOffset.z < (*gHudElements)[el2]->worldPosOffset.z) {
1650 sortedElements[i] = el2;
1651 sortedElements[j] = el1;
1652 }
1653 }
1654 }
1655
1656 gDPSetScissor(gMainGfxPos++, G_SC_NON_INTERLACE, 12, 20, 308, 220);
1657 gDPPipeSync(gMainGfxPos++);
1658 gSPClearGeometryMode(gMainGfxPos++, G_ZBUFFER | G_SHADE | G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR | G_LOD | G_SHADING_SMOOTH);
1659 gSPSetGeometryMode(gMainGfxPos++, G_ZBUFFER | G_SHADE | G_LIGHTING | G_SHADING_SMOOTH);
1660 gSPSetLights1(gMainGfxPos++, HudElementLights);
1661 gSPTexture(gMainGfxPos++, -1, -1, 0, G_TX_RENDERTILE, G_ON);
1662 gDPSetAlphaCompare(gMainGfxPos++, G_AC_NONE);
1663 gSPSetOtherMode(gMainGfxPos++, G_SETOTHERMODE_H, G_MDSFT_ALPHADITHER, 18, G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE | G_TD_CLAMP | G_TP_PERSP | G_CYC_1CYCLE);
1664
1665 for (i = 0; i < count; i++) {
1666 render_hud_element((*gHudElements)[sortedElements[i]]);
1667 }
1668 }
1669 }
1670
1671 count = 0;
1672 if (gCurrentCamID == CAM_BATTLE) {
1673 for (i = 0; i < ARRAY_COUNT(*gHudElements); i++) {
1674 hudElement = (*gHudElements)[i];
1675 if (hudElement == NULL) {
1676 continue;
1677 }
1678
1679 flags = hudElement->flags;
1680 if (flags == 0 || flags & HUD_ELEMENT_FLAG_DISABLED) {
1681 continue;
1682 }
1683
1685 continue;
1686 }
1687
1689 continue;
1690 }
1691
1692 // different from CAM_HUD pass
1694 continue;
1695 }
1696
1698 continue;
1699 }
1700
1701 // add element to list
1702 sortedElements[count++] = i;
1703 }
1704
1705 if (count != 0) {
1706 for (i = 0; i < count - 1; i++) {
1707 for (j = i + 1; j < count; j++) {
1708 el1 = sortedElements[i];
1709 el2 = sortedElements[j];
1710
1711 if ((*gHudElements)[el1]->worldPosOffset.z < (*gHudElements)[el2]->worldPosOffset.z) {
1712 sortedElements[i] = el2;
1713 sortedElements[j] = el1;
1714 }
1715 }
1716 }
1717
1718 gDPSetScissor(gMainGfxPos++, G_SC_NON_INTERLACE, 12, 20, 308, 220);
1719 gDPPipeSync(gMainGfxPos++);
1720 gSPClearGeometryMode(gMainGfxPos++, G_ZBUFFER | G_SHADE | G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR | G_LOD | G_SHADING_SMOOTH);
1721 gSPSetGeometryMode(gMainGfxPos++, G_ZBUFFER | G_SHADE | G_LIGHTING | G_SHADING_SMOOTH);
1722 gSPSetLights1(gMainGfxPos++, HudElementLights);
1723 gSPTexture(gMainGfxPos++, -1, -1, 0, G_TX_RENDERTILE, G_ON);
1724 gDPSetAlphaCompare(gMainGfxPos++, G_AC_NONE);
1725 gSPSetOtherMode(gMainGfxPos++, G_SETOTHERMODE_H, G_MDSFT_ALPHADITHER, 18, G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE | G_TD_CLAMP | G_TP_PERSP | G_CYC_1CYCLE);
1726
1727 for (i = 0; i < count; i++) {
1728 render_hud_element((*gHudElements)[sortedElements[i]]);
1729 }
1730 }
1731 }
1732}
1733
1734void func_80143C48(s32 elemID, s32 arg1, s32 camID) {
1735 Camera* camera = &gCameras[camID];
1736
1737 if (arg1 > 0) {
1738 if (camera->flags == 0 || (camera->flags & CAMERA_FLAG_DISABLED)) {
1739 return;
1740 }
1741
1742 gCurrentCamID = camID;
1743
1744 gSPViewport(gMainGfxPos++, &camera->vp);
1745 gSPClearGeometryMode(gMainGfxPos++, G_SHADE | G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN |
1746 G_TEXTURE_GEN_LINEAR | G_LOD | G_SHADING_SMOOTH);
1747 gSPTexture(gMainGfxPos++, 0, 0, 0, G_TX_RENDERTILE, G_OFF);
1748 gDPPipelineMode(gMainGfxPos++, G_PM_NPRIMITIVE);
1749 gDPSetTextureLUT(gMainGfxPos++, G_TT_NONE);
1750 gDPSetTextureFilter(gMainGfxPos++, G_TF_BILERP);
1751 gDPSetCombineMode(gMainGfxPos++, G_CC_SHADE, G_CC_SHADE);
1752 gDPSetRenderMode(gMainGfxPos++, G_RM_OPA_SURF, G_RM_OPA_SURF2);
1753 gSPClipRatio(gMainGfxPos++, FRUSTRATIO_2);
1754 gDPPipeSync(gMainGfxPos++);
1755 //clear Z buffer inside camera viewport
1756 gDPSetCycleType(gMainGfxPos++, G_CYC_FILL);
1757 gDPSetColorImage(gMainGfxPos++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, osVirtualToPhysical(nuGfxZBuffer));
1758 gDPSetFillColor(gMainGfxPos++, GPACK_ZDZ(G_MAXFBZ, 0)<<16 | GPACK_ZDZ(G_MAXFBZ, 0));
1759 gDPFillRectangle(gMainGfxPos++, camera->viewportStartX, camera->viewportStartY,
1760 camera->viewportStartX + camera->viewportW - 1,
1761 camera->viewportStartY + camera->viewportH - 1);
1762 gDPPipeSync(gMainGfxPos++);
1763
1764 gDPSetColorImage(gMainGfxPos++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, osVirtualToPhysical(nuGfxCfb_ptr));
1765 gDPPipeSync(gMainGfxPos++);
1766
1767 guOrthoF(camera->mtxPerspective, 0.0f, 320.0f, -240.0f, 0.0f, -1000.0f, 1000.0f, 1.0f);
1769
1770 gSPMatrix(gMainGfxPos++, &gDisplayContext->camPerspMatrix[gCurrentCamID], G_MTX_NOPUSH | G_MTX_LOAD |
1771 G_MTX_PROJECTION);
1772 gDPSetScissor(gMainGfxPos++, G_SC_NON_INTERLACE, 12, 20, 308, 220);
1773 gDPPipeSync(gMainGfxPos++);
1774 gDPSetCycleType(gMainGfxPos++, G_CYC_1CYCLE);
1775 gSPClearGeometryMode(gMainGfxPos++, G_ZBUFFER | G_SHADE | G_CULL_BOTH | G_FOG | G_LIGHTING |
1776 G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR | G_LOD | G_SHADING_SMOOTH);
1777 gSPSetGeometryMode(gMainGfxPos++, G_ZBUFFER | G_SHADE | G_LIGHTING | G_SHADING_SMOOTH);
1778 gSPSetLights1(gMainGfxPos++, HudElementLights);
1779 gSPTexture(gMainGfxPos++, -1, -1, 0, G_TX_RENDERTILE, G_ON);
1780 gDPSetTextureLOD(gMainGfxPos++, G_TL_TILE);
1781 gDPSetTexturePersp(gMainGfxPos++, G_TP_PERSP);
1782 gDPSetColorDither(gMainGfxPos++, G_CD_DISABLE);
1783 gDPSetTextureDetail(gMainGfxPos++, G_TD_CLAMP);
1784 gDPSetTextureConvert(gMainGfxPos++, G_TC_FILT);
1785 gDPSetCombineKey(gMainGfxPos++, G_CK_NONE);
1786 gDPSetAlphaCompare(gMainGfxPos++, G_AC_NONE);
1787 }
1788
1789 if (elemID >= 0) {
1790 HudElement* elem;
1791
1792 elemID &= ~HUD_ELEMENT_BATTLE_ID_MASK;
1793 elem = (*gHudElements)[elemID];
1794
1795 if (elem == NULL) {
1796 return;
1797 }
1798
1799 if (elem->flags == 0 || elem->flags & HUD_ELEMENT_FLAG_DISABLED) {
1800 return;
1801 }
1802
1804 return;
1805 }
1806
1807 if (!(elem->flags & HUD_ELEMENT_FLAG_TRANSFORM)) {
1808 return;
1809 }
1810
1811 if (elem->flags & HUD_ELEMENT_FLAG_FRONTUI || elem->drawSizePreset < 0 || !(elem->flags & HUD_ELEMENT_FLAG_80)) {
1812 return;
1813 }
1814
1815 render_hud_element(elem);
1816 }
1817}
1818
1819void func_80144218(s32 id) {
1820 func_80143C48(id, 1, CAM_HUD);
1821}
1822
1823void func_80144238(s32 id) {
1824 func_80143C48(id, 0, CAM_HUD);
1825}
1826
1827void func_80144258(s32 id) {
1828 func_80143C48(id, 1, CAM_BATTLE);
1829}
1830
1831void func_80144278(s32 id) {
1832 func_80143C48(id, 0, CAM_BATTLE);
1833}
1834
1835void draw_hud_element_internal(s32 id, s32 clipMode) {
1836 HudElement* elem = (*gHudElements)[id & ~HUD_ELEMENT_BATTLE_ID_MASK];
1837 s32 texSizeX, texSizeY;
1838 s32 drawSizeX, drawSizeY;
1839 s32 offsetX, offsetY;
1840 s32 preset;
1841
1842 if (elem->flags && !(elem->flags & HUD_ELEMENT_FLAG_DISABLED)) {
1843 if (!(elem->flags & (HUD_ELEMENT_FLAG_200000 | HUD_ELEMENT_FLAG_10000000)) && (elem->drawSizePreset >= 0)) {
1844 if (clipMode != HUD_ELEMENT_DRAW_NEXT) {
1845 if (clipMode == HUD_ELEMENT_DRAW_FIRST_WITH_CLIPPING) {
1846 gDPSetScissor(gMainGfxPos++, G_SC_NON_INTERLACE, 12, 20, SCREEN_WIDTH - 12, SCREEN_HEIGHT - 20);
1847 }
1848 gDPPipeSync(gMainGfxPos++);
1849 gDPSetCycleType(gMainGfxPos++, G_CYC_1CYCLE);
1850 gDPSetTexturePersp(gMainGfxPos++, G_TP_NONE);
1851 gDPSetTextureLOD(gMainGfxPos++, G_TL_TILE);
1852 gDPSetTextureDetail(gMainGfxPos++, G_TD_CLAMP);
1853 gDPSetTextureConvert(gMainGfxPos++, G_TC_FILT);
1854 gDPSetCombineKey(gMainGfxPos++, G_CK_NONE);
1855 gDPSetAlphaCompare(gMainGfxPos++, G_AC_NONE);
1856 gDPNoOp(gMainGfxPos++);
1857 gDPSetColorDither(gMainGfxPos++, G_CD_DISABLE);
1858 gDPSetAlphaDither(gMainGfxPos++, G_AD_DISABLE);
1859 gSPTexture(gMainGfxPos++, -1, -1, 0, G_TX_RENDERTILE, G_ON);
1860 }
1861
1862 if (!(elem->flags & HUD_ELEMENT_FLAG_FIXEDSCALE)) {
1863 if (!(elem->flags & HUD_ELEMENT_FLAG_CUSTOM_SIZE)) {
1864 preset = elem->tileSizePreset;
1865 texSizeX = gHudElementSizes[preset].width;
1866 texSizeY = gHudElementSizes[preset].height;
1867 } else {
1868 texSizeX = elem->customImageSize.x;
1869 texSizeY = elem->customImageSize.y;
1870 }
1871
1872 if (!(elem->flags & HUD_ELEMENT_FLAG_SCALED)) {
1873 if (!(elem->flags & HUD_ELEMENT_FLAG_CUSTOM_SIZE)) {
1874 drawSizeX = gHudElementSizes[elem->drawSizePreset].width;
1875 drawSizeY = gHudElementSizes[elem->drawSizePreset].height;
1876 } else {
1877 drawSizeX = elem->customDrawSize.x;
1878 drawSizeY = elem->customDrawSize.y;
1879 }
1880 } else {
1881 drawSizeX = elem->sizeX;
1882 drawSizeY = elem->sizeY;
1883 }
1884
1885 offsetX = -drawSizeX / 2;
1886 offsetY = -drawSizeY / 2;
1887
1888 if (!(elem->flags & HUD_ELEMENT_FLAG_REPEATED)) {
1889 if (elem->flags & HUD_ELEMENT_FLAG_DROP_SHADOW) {
1890 hud_element_draw_rect(elem, texSizeX, texSizeY, drawSizeX, drawSizeY, offsetX, offsetY, TRUE, TRUE);
1891 }
1892 hud_element_draw_rect(elem, texSizeX, texSizeY, drawSizeX, drawSizeY, offsetX, offsetY, TRUE, FALSE);
1893 } else {
1894 if (elem->flags & HUD_ELEMENT_FLAG_DROP_SHADOW) {
1895 hud_element_draw_rect(elem, texSizeX, texSizeY, drawSizeX, drawSizeY, offsetX, offsetY, FALSE, TRUE);
1896 }
1897 hud_element_draw_rect(elem, texSizeX, texSizeY, drawSizeX, drawSizeY, offsetX, offsetY, FALSE, FALSE);
1898 }
1899 } else {
1900 f32 xScaled, yScaled;
1901
1902 if (!(elem->flags & HUD_ELEMENT_FLAG_CUSTOM_SIZE)) {
1903 preset = elem->tileSizePreset;
1904 texSizeX = gHudElementSizes[preset].width;
1905 texSizeY = gHudElementSizes[preset].height;
1906 } else {
1907 texSizeX = elem->customImageSize.x;
1908 texSizeY = elem->customImageSize.y;
1909 }
1910
1911 drawSizeX = elem->unkImgScale[0];
1912 drawSizeY = elem->unkImgScale[1];
1913
1914 offsetX = -elem->unkImgScale[0] / 2;
1915 offsetY = -elem->unkImgScale[1] / 2;
1916
1917 xScaled = (f32) drawSizeX / (f32) texSizeX;
1918 yScaled = (f32) drawSizeY / (f32) texSizeY;
1919
1920 xScaled = 1.0f / xScaled;
1921 yScaled = 1.0f / yScaled;
1922
1923 elem->widthScale = X10(xScaled);
1924 elem->heightScale = X10(yScaled);
1925
1926 if (elem->flags & HUD_ELEMENT_FLAG_DROP_SHADOW) {
1927 hud_element_draw_rect(elem, texSizeX, texSizeY, drawSizeX, drawSizeY, offsetX, offsetY, FALSE, TRUE);
1928 }
1929 hud_element_draw_rect(elem, texSizeX, texSizeY, drawSizeX, drawSizeY, offsetX, offsetY, FALSE, FALSE);
1930 }
1931 }
1932 }
1933}
1934
1938
1942
1946
1948 HudElement* hudElement = (*gHudElements)[id & ~HUD_ELEMENT_BATTLE_ID_MASK];
1949
1950 if (anim == NULL) {
1951 anim = &HES_Empty;
1952 }
1953
1954 hudElement->updateTimer = 1;
1955 hudElement->widthScale = X10(1.0f);
1956 hudElement->heightScale = X10(1.0f);
1957 hudElement->readPos = anim;
1958 hudElement->anim = anim;
1959 hudElement->loopStartPos = anim;
1960 hudElement->screenPosOffset.x = 0;
1961 hudElement->screenPosOffset.y = 0;
1962 hudElement->worldPosOffset.x = 0;
1963 hudElement->worldPosOffset.y = 0;
1964 hudElement->flags &= ~HUD_ELEMENT_FLAG_ANIMATION_FINISHED;
1965 hudElement->uniformScale = 1.0f;
1967 hud_element_load_script(hudElement, anim);
1968
1969 while (hud_element_update(hudElement) != 0) {}
1970}
1971
1973 return (*gHudElements)[id & ~HUD_ELEMENT_BATTLE_ID_MASK]->anim;
1974}
1975
1977 return (*gHudElements)[id & ~HUD_ELEMENT_BATTLE_ID_MASK];
1978}
1979
1980void hud_element_free(s32 id) {
1983 }
1984
1986 (*gHudElements)[id & ~HUD_ELEMENT_BATTLE_ID_MASK] = NULL;
1988}
1989
1990void hud_element_set_render_pos(s32 id, s32 x, s32 y) {
1991 HudElement* hudElement = (*gHudElements)[id & ~HUD_ELEMENT_BATTLE_ID_MASK];
1992
1993 hudElement->renderPosX = x;
1994 hudElement->renderPosY = y;
1995}
1996
1997void hud_element_get_render_pos(s32 id, s32* x, s32* y) {
1998 HudElement* hudElement = (*gHudElements)[id & ~HUD_ELEMENT_BATTLE_ID_MASK];
1999
2000 *x = hudElement->renderPosX;
2001 *y = hudElement->renderPosY;
2002}
2003
2004void hud_element_set_render_depth(s32 id, s32 z) {
2005 (*gHudElements)[id & ~HUD_ELEMENT_BATTLE_ID_MASK]->worldPosOffset.z = z;
2006}
2007
2008void hud_element_set_flags(s32 id, s32 flags) {
2009 (*gHudElements)[id & ~HUD_ELEMENT_BATTLE_ID_MASK]->flags |= flags;
2010}
2011
2013 (*gHudElements)[id & ~HUD_ELEMENT_BATTLE_ID_MASK]->flags &= ~flags;
2014}
2015
2017 s32 i;
2018
2029
2030 for (i = 0; i < MAX_HUD_CACHE_ENTRIES; i++) {
2033 }
2034 } else {
2035 if (gHudElementAuxCache == NULL) {
2039 } else {
2041 }
2048
2049 for (i = 0; i < MAX_HUD_CACHE_ENTRIES; i++) {
2052 }
2053 }
2054}
2055
2056void hud_element_set_scale(s32 index, f32 scale) {
2057 HudElement* elem = (*gHudElements)[index & ~HUD_ELEMENT_BATTLE_ID_MASK];
2058 s32 drawSizeX;
2059 s32 drawSizeY;
2060 s32 imgSizeX;
2061 s32 imgSizeY;
2062 f32 xScaled, yScaled;
2063
2064 elem->uniformScale = scale;
2065 if (!(elem->flags & HUD_ELEMENT_FLAG_CUSTOM_SIZE)) {
2066 imgSizeX = gHudElementSizes[elem->tileSizePreset].width;
2067 imgSizeY = gHudElementSizes[elem->tileSizePreset].height;
2068 drawSizeX = gHudElementSizes[elem->drawSizePreset].width;
2069 drawSizeY = gHudElementSizes[elem->drawSizePreset].height;
2070 } else {
2071 imgSizeX = elem->customImageSize.x;
2072 imgSizeY = elem->customImageSize.y;
2073 drawSizeX = elem->customDrawSize.x;
2074 drawSizeY = elem->customDrawSize.y;
2075 }
2076 elem->sizeX = drawSizeX * scale;
2077 elem->sizeY = drawSizeY * scale;
2078 elem->flags &= ~HUD_ELEMENT_FLAG_FIXEDSCALE;
2080
2081 xScaled = ((f32) drawSizeX / (f32) imgSizeX) * scale;
2082 yScaled = ((f32) drawSizeY / (f32) imgSizeY) * scale;
2083
2084 xScaled = 1.0f / xScaled;
2085 yScaled = 1.0f / yScaled;
2086
2087 elem->widthScale = X10(xScaled);
2088 elem->heightScale = X10(yScaled);
2089}
2090
2091void hud_element_use_preset_size(s32 id, s8 sizePreset) {
2092 HudElement* hudElement = (*gHudElements)[id & ~HUD_ELEMENT_BATTLE_ID_MASK];
2093
2094 hudElement->widthScale = X10(1.0f);
2095 hudElement->heightScale = X10(1.0f);
2096 hudElement->tileSizePreset = sizePreset;
2097 hudElement->drawSizePreset = sizePreset;
2098 hudElement->uniformScale = 1.0f;
2099 hudElement->flags &= ~HUD_ELEMENT_FLAG_FIXEDSCALE;
2101}
2102
2103s32 func_80144E4C(s32 id) {
2104 return ((*gHudElements)[id & ~HUD_ELEMENT_BATTLE_ID_MASK]->flags >> 24) & 0xF;
2105}
2106
2107void func_80144E74(s32 id, s32 arg1) {
2108 HudElement* hudElement = (*gHudElements)[id & ~HUD_ELEMENT_BATTLE_ID_MASK];
2109
2111 hudElement->flags |= arg1 << 24;
2112}
2113
2114void hud_element_set_alpha(s32 id, s32 opacity) {
2115 HudElement* hudElement = (*gHudElements)[id & ~HUD_ELEMENT_BATTLE_ID_MASK];
2116
2117 hudElement->flags |= HUD_ELEMENT_FLAG_TRANSPARENT;
2118 hudElement->opacity = opacity;
2119
2120 if (opacity == 255) {
2121 hudElement->flags &= ~HUD_ELEMENT_FLAG_TRANSPARENT;
2122 }
2123}
2124
2125void hud_element_set_tint(s32 id, s32 r, s32 g, s32 b) {
2126 HudElement* hudElement = (*gHudElements)[id & ~HUD_ELEMENT_BATTLE_ID_MASK];
2127
2128 hudElement->tint.r = r;
2129 hudElement->tint.g = g;
2130 hudElement->tint.b = b;
2131}
2132
2134 HudElement* element = (*gHudElements)[id & ~HUD_ELEMENT_BATTLE_ID_MASK];
2135 HudTransform* transform = general_heap_malloc(sizeof(*transform));
2136
2137 element->hudTransform = transform;
2138 ASSERT(transform != NULL);
2140 transform->imgfxIdx = imgfx_get_free_instances(1);
2141 transform->pos.x = 0.0f;
2142 transform->pos.y = 0.0f;
2143 transform->pos.z = 0.0f;
2144 transform->rot.x = 0.0f;
2145 transform->rot.y = 0.0f;
2146 transform->rot.z = 0.0f;
2147 transform->scale.x = 1.0f;
2148 transform->scale.y = 1.0f;
2149 transform->scale.z = 1.0f;
2150 transform->pivot.x = 0;
2151 transform->pivot.y = 0;
2153}
2154
2156 HudElement* element = (*gHudElements)[id & ~HUD_ELEMENT_BATTLE_ID_MASK];
2157 HudTransform* transform = general_heap_malloc(sizeof(*transform));
2158
2159 element->hudTransform = transform;
2160 ASSERT(transform != NULL);
2162 transform->imgfxIdx = 0;
2163 transform->pos.x = 0.0f;
2164 transform->pos.y = 0.0f;
2165 transform->pos.z = 0.0f;
2166 transform->rot.x = 0.0f;
2167 transform->rot.y = 0.0f;
2168 transform->rot.z = 0.0f;
2169 transform->scale.x = 1.0f;
2170 transform->scale.y = 1.0f;
2171 transform->scale.z = 1.0f;
2173}
2174
2176 HudElement* element = (*gHudElements)[id & ~HUD_ELEMENT_BATTLE_ID_MASK];
2177 HudTransform* transform = general_heap_malloc(sizeof(*transform));
2178
2179 element->hudTransform = transform;
2180 ASSERT(transform != NULL);
2182 transform->imgfxIdx = 0;
2183 transform->pos.x = 0.0f;
2184 transform->pos.y = 0.0f;
2185 transform->pos.z = 0.0f;
2186 transform->rot.x = 0.0f;
2187 transform->rot.y = 0.0f;
2188 transform->rot.z = 0.0f;
2189 transform->scale.x = 1.0f;
2190 transform->scale.y = 1.0f;
2191 transform->scale.z = 1.0f;
2193}
2194
2196 HudElement* hudElement = (*gHudElements)[id & ~HUD_ELEMENT_BATTLE_ID_MASK];
2197 HudTransform* hudTransform = hudElement->hudTransform;
2198
2199 if (!(hudElement->flags & HUD_ELEMENT_FLAG_NO_FOLD)) {
2200 imgfx_release_instance(hudTransform->imgfxIdx);
2201 }
2202
2203 heap_free(hudElement->hudTransform);
2204 hudElement->hudTransform = NULL;
2206}
2207
2208void hud_element_set_transform_pos(s32 id, f32 x, f32 y, f32 z) {
2209 HudElement* element = (*gHudElements)[id & ~HUD_ELEMENT_BATTLE_ID_MASK];
2210 HudTransform* transform = element->hudTransform;
2211
2212 if (element->flags & HUD_ELEMENT_FLAG_TRANSFORM) {
2213 transform->pos.x = x;
2214 transform->pos.y = y;
2215 transform->pos.z = z;
2216 }
2217}
2218
2219void hud_element_set_transform_scale(s32 id, f32 x, f32 y, f32 z) {
2220 HudElement* element = (*gHudElements)[id & ~HUD_ELEMENT_BATTLE_ID_MASK];
2221 HudTransform* transform = element->hudTransform;
2222
2223 if (element->flags & HUD_ELEMENT_FLAG_TRANSFORM) {
2224 transform->scale.x = x;
2225 transform->scale.y = y;
2226 transform->scale.z = z;
2227 }
2228}
2229
2230void hud_element_set_transform_rotation(s32 id, f32 x, f32 y, f32 z) {
2231 HudElement* element = (*gHudElements)[id & ~HUD_ELEMENT_BATTLE_ID_MASK];
2232 HudTransform* transform = element->hudTransform;
2233
2234 if (element->flags & HUD_ELEMENT_FLAG_TRANSFORM) {
2235 transform->rot.x = x;
2236 transform->rot.y = y;
2237 transform->rot.z = z;
2238 }
2239}
2240
2241void hud_element_set_transform_rotation_pivot(s32 id, s32 dx, s32 dy) {
2242 HudElement* element = (*gHudElements)[id & ~HUD_ELEMENT_BATTLE_ID_MASK];
2243 HudTransform* transform = element->hudTransform;
2244
2245 if (element->flags & HUD_ELEMENT_FLAG_TRANSFORM) {
2246 transform->pivot.x = dx;
2247 transform->pivot.y = dy;
2248 }
2249}
2250
2251void copy_world_hud_element_ref_to_battle(s32 worldID, s32 battleID) {
2252 gHudElementsBattle[battleID & ~HUD_ELEMENT_BATTLE_ID_MASK] = gHudElementsWorld[worldID & ~HUD_ELEMENT_BATTLE_ID_MASK];
2253}
2254
2255void hud_element_set_aux_cache(void* base, s32 size) {
2256 gHudElementAuxCache = (u8*)base;
2257 if (base == NULL) {
2258 gHudElementCacheCapacity = 0x11000;
2259 } else {
2261 }
2262}
u16 * nuGfxCfb_ptr
Definition cam_main.c:14
Mtx matrixStack[0x200]
#define PAL_PTR
#define IMG_PTR
f32 Matrix4f[4][4]
s8 flags
Definition demo_api.c:15
Vec3s pos
Definition demo_api.c:17
#define general_heap_malloc
#define guRotateF
#define guOrthoF
#define guMtxF2L
#define guTranslateF
#define guMtxCatF
#define rand_int
#define guScaleF
#define ASSERT(condition)
@ IMGFX_SET_ALPHA
Definition enums.h:5124
@ IMGFX_CLEAR
Definition enums.h:5117
@ CAMERA_FLAG_DISABLED
Definition enums.h:4721
@ CAMERA_FLAG_LEAD_PLAYER
Definition enums.h:4722
@ CAM_UPDATE_INTERP_POS
Definition enums.h:4747
@ CONTEXT_WORLD
Definition enums.h:3529
@ CAM_HUD
Definition enums.h:1803
@ CAM_BATTLE
Definition enums.h:1801
@ IMGFX_FLAG_40
Definition enums.h:5099
s32 imgfx_appendGfx_component(s32, ImgFXTexture *, u32, Matrix4f)
Definition imgfx.c:704
s32 imgfx_get_free_instances(s32)
Definition imgfx.c:338
s32 heap_free(void *ptr)
Definition heap.c:42
s32 general_heap_free(void *data)
Definition heap.c:18
void imgfx_release_instance(u32)
Definition imgfx.c:386
void imgfx_update(u32, ImgFXType, s32, s32, s32, s32, s32)
Definition imgfx.c:487
void * heap_malloc(s32 size)
Definition heap.c:34
void set_cam_viewport(s16 id, s16 x, s16 y, s16 width, s16 height)
Definition cam_main.c:373
s32 func_80144E4C(s32 id)
BSS HudCacheEntry gHudElementCacheTablePaletteWorld[192]
Vtx D_8014F0C8[]
Definition hud_element.c:66
Gfx gHudElementsDLBackUI[]
Definition hud_element.c:51
void hud_element_setup_cam(void)
u8 * gHudElementCacheBuffer
void hud_element_create_transform_C(s32 id)
void hud_element_get_render_pos(s32 id, s32 *x, s32 *y)
void hud_element_set_aux_cache(void *base, s32 size)
void func_80144238(s32 id)
HudCacheEntry * gHudElementCacheTablePalette
BSS HudCacheEntry gHudElementCacheTableRasterWorld[192]
void render_hud_element(HudElement *hudElement)
void hud_element_create_transform_A(s32 id)
BSS s32 D_80159180
void hud_element_set_scale(s32 index, f32 scale)
void hud_element_set_alpha(s32 id, s32 opacity)
void func_80144258(s32 id)
void render_hud_elements_frontUI(void)
BSS HudElementList * gHudElements
s32 hud_element_update(HudElement *hudElement)
s32 * gHudElementCacheSize
void func_80144278(s32 id)
void hud_element_draw_without_clipping(s32 id)
void hud_element_set_script(s32 id, HudScript *anim)
void update_hud_elements(void)
void render_hud_elements_backUI(void)
HudCacheEntry * gHudElementCacheTableRaster
Lights1 HudElementLights
#define MAX_HUD_CACHE_ENTRIES
Definition hud_element.c:6
HudElementSize gHudElementSizes[]
Definition hud_element.c:21
BSS u8 * gHudElementCacheBufferWorld
s16 D_8014F068[]
Definition hud_element.c:50
void hud_element_set_render_depth(s32 id, s32 z)
void hud_element_create_transform_B(s32 id)
HudScript * hud_element_get_script(s32 id)
BSS HudElementList gHudElementsWorld
void hud_element_set_transform_pos(s32 id, f32 x, f32 y, f32 z)
void hud_element_clear_cache(void)
void hud_element_draw_rect(HudElement *hudElement, s16 texSizeX, s16 texSizeY, s16 drawSizeX, s16 drawSizeY, s16 offsetX, s16 offsetY, s32 clamp, s32 dropShadow)
BSS s32 gHudElementCacheSizeBattle
void hud_element_draw_next(s32 id)
void init_hud_element_list(void)
void hud_element_set_tint(s32 id, s32 r, s32 g, s32 b)
BSS HudElementList gHudElementsBattle
void hud_element_set_transform_rotation(s32 id, f32 x, f32 y, f32 z)
void func_80143C48(s32 elemID, s32 arg1, s32 camID)
void hud_element_use_preset_size(s32 id, s8 sizePreset)
BSS s32 gHudElementCacheSizeWorld
BSS HudCacheEntry gHudElementCacheTableRasterBattle[192]
BSS u8 * gHudElementCacheBufferBattle
void hud_element_set_render_pos(s32 id, s32 x, s32 y)
void hud_element_set_transform_rotation_pivot(s32 id, s32 dx, s32 dy)
s32 hud_element_create(HudScript *anim)
Creates a new HUD element and returns its ID.
u8 * gHudElementAuxCache
Definition hud_element.c:14
void hud_element_load_script(HudElement *hudElement, HudScript *anim)
BSS HudCacheEntry gHudElementCacheTablePaletteBattle[192]
HudElement * get_hud_element(s32 id)
void hud_element_set_flags(s32 id, s32 flags)
Turns on the given flags.
void hud_element_clear_flags(s32 id, s32 flags)
Turns off the given flags.
void hud_element_draw_clipped(s32 id)
void hud_element_set_transform_scale(s32 id, f32 x, f32 y, f32 z)
Gfx gHudElementsDLFrontUI[]
Definition hud_element.c:58
s32 gHudElementCacheCapacity
Definition hud_element.c:15
void hud_element_free(s32 id)
void render_transformed_hud_elements(void)
void func_80144E74(s32 id, s32 arg1)
void func_80144218(s32 id)
HudScript HES_Empty
Definition hud_element.c:17
void hud_element_free_transform(s32 id)
void copy_world_hud_element_ref_to_battle(s32 worldID, s32 battleID)
void draw_hud_element_internal(s32 id, s32 clipMode)
void ALT_clear_hud_element_cache(void)
s32 gHudElementsNumber
HudScript * loopStartPos
Color_RGB8 tint
VtxRect unk_30[3]
@ HUD_ELEMENT_OP_SetCI
Definition hud_element.h:16
@ HUD_ELEMENT_OP_Restart
Definition hud_element.h:17
@ HUD_ELEMENT_OP_End
Definition hud_element.h:14
@ HUD_ELEMENT_OP_SetPivot
Definition hud_element.h:41
@ HUD_ELEMENT_OP_op_16
Definition hud_element.h:36
@ HUD_ELEMENT_OP_SetVisible
Definition hud_element.h:22
@ HUD_ELEMENT_OP_AddTexelOffsetY
Definition hud_element.h:25
@ HUD_ELEMENT_OP_SetScale
Definition hud_element.h:28
@ HUD_ELEMENT_OP_SetImage
Definition hud_element.h:27
@ HUD_ELEMENT_OP_RandomBranch
Definition hud_element.h:37
@ HUD_ELEMENT_OP_PlaySound
Definition hud_element.h:40
@ HUD_ELEMENT_OP_SetSizesAutoScale
Definition hud_element.h:20
@ HUD_ELEMENT_OP_SetTexelOffset
Definition hud_element.h:26
@ HUD_ELEMENT_OP_RandomDelay
Definition hud_element.h:30
@ HUD_ELEMENT_OP_Loop
Definition hud_element.h:18
@ HUD_ELEMENT_OP_SetFlags
Definition hud_element.h:38
@ HUD_ELEMENT_OP_SetAlpha
Definition hud_element.h:29
@ HUD_ELEMENT_OP_SetTileSize
Definition hud_element.h:19
@ HUD_ELEMENT_OP_SetSizesFixedScale
Definition hud_element.h:21
@ HUD_ELEMENT_OP_RandomRestart
Definition hud_element.h:34
@ HUD_ELEMENT_OP_SetCustomSize
Definition hud_element.h:33
@ HUD_ELEMENT_OP_AddTexelOffsetX
Definition hud_element.h:24
@ HUD_ELEMENT_OP_SetRGBA
Definition hud_element.h:15
@ HUD_ELEMENT_OP_UseIA8
Definition hud_element.h:32
@ HUD_ELEMENT_OP_ClearFlags
Definition hud_element.h:39
@ HUD_ELEMENT_OP_SetHidden
Definition hud_element.h:23
@ HUD_ELEMENT_OP_Delete
Definition hud_element.h:31
@ HUD_ELEMENT_OP_op_15
Definition hud_element.h:35
HudScript * anim
f32 unkImgScale[2]
#define HUD_ELEMENT_BATTLE_ID_MASK
Definition hud_element.h:7
HudElement * HudElementList[320]
#define hs_End
HudScript * readPos
u8 * paletteAddr
@ HUD_ELEMENT_FLAG_200000
Definition hud_element.h:94
@ HUD_ELEMENT_FLAG_ANTIALIASING
Definition hud_element.h:96
@ HUD_ELEMENT_FLAG_4000000
Definition hud_element.h:99
@ HUD_ELEMENT_FLAG_DELETE
Definition hud_element.h:91
@ HUD_ELEMENT_FLAG_DISABLED
Definition hud_element.h:74
@ HUD_ELEMENT_FLAG_SCALED
Definition hud_element.h:77
@ HUD_ELEMENT_FLAG_FLIPX
Definition hud_element.h:85
@ HUD_ELEMENT_FLAG_1000000
Definition hud_element.h:97
@ HUD_ELEMENT_FLAG_10000000
@ HUD_ELEMENT_FLAG_MEMOFFSET
Definition hud_element.h:95
@ HUD_ELEMENT_FLAG_80
Definition hud_element.h:80
@ HUD_ELEMENT_FLAG_FMT_IA8
Definition hud_element.h:92
@ HUD_ELEMENT_FLAG_CUSTOM_SIZE
Definition hud_element.h:93
@ HUD_ELEMENT_FLAG_FIXEDSCALE
Definition hud_element.h:81
@ HUD_ELEMENT_FLAG_REPEATED
Definition hud_element.h:84
@ HUD_ELEMENT_FLAG_INITIALIZED
Definition hud_element.h:73
@ HUD_ELEMENT_FLAG_FLIPY
Definition hud_element.h:86
@ HUD_ELEMENT_FLAG_8000000
@ HUD_ELEMENT_FLAG_DROP_SHADOW
@ HUD_ELEMENT_FLAG_2000000
Definition hud_element.h:98
@ HUD_ELEMENT_FLAG_40000000
@ HUD_ELEMENT_FLAG_NO_FOLD
Definition hud_element.h:90
@ HUD_ELEMENT_FLAG_ANIMATION_FINISHED
Definition hud_element.h:75
@ HUD_ELEMENT_FLAG_BATTLE
Definition hud_element.h:83
@ HUD_ELEMENT_FLAG_FRONTUI
Definition hud_element.h:79
@ HUD_ELEMENT_FLAG_FMT_CI4
Definition hud_element.h:87
@ HUD_ELEMENT_FLAG_200
Definition hud_element.h:82
@ HUD_ELEMENT_FLAG_TRANSFORM
Definition hud_element.h:89
@ HUD_ELEMENT_FLAG_FILTER_TEX
Definition hud_element.h:88
@ HUD_ELEMENT_FLAG_TRANSPARENT
Definition hud_element.h:78
Vec3b worldPosOffset
Vtx vtx[4]
Vec2b screenPosOffset
HudTransform * hudTransform
@ HUD_ELEMENT_DRAW_NEXT
@ HUD_ELEMENT_DRAW_FIRST_WITH_CLIPPING
@ HUD_ELEMENT_DRAW_FIRST_WITHOUT_CLIPPING
s32 heightScale
X10.
s32 widthScale
X10.
Vec2bu customImageSize
s32 HudScript[]
Definition hud_element.h:9
Vec2bu customDrawSize
u16 * nuGfxZBuffer
Definition main.c:46
void sfx_play_sound(s32 soundID)
Definition sfx.c:517
#define CAM_NEAR_CLIP
Definition macros.h:117
#define PM_CC_07
Definition macros.h:282
#define SCREEN_WIDTH
Definition macros.h:105
#define BSS
Definition macros.h:7
#define ARRAY_COUNT(arr)
Definition macros.h:40
#define PM_CC_01
Definition macros.h:276
#define SCREEN_HEIGHT
Definition macros.h:106
#define PM_CC_32
Definition macros.h:385
#define X10(f)
X.10 fixed-point literal.
Definition macros.h:174
#define PM_CC_2F
Definition macros.h:384
#define PM_CC_47
Definition macros.h:474
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
#define PM_CC_02
Definition macros.h:277
s32 D_80200000
s16 bgColor[3]
Vec3f lookAt_obj_target
s16 viewportStartX
union Camera::@17 params
s16 viewportStartY
Matrix4f mtxPerspective
u8 Addr[]
Linker symbol address, as in ld_addrs.h.
Definition types.h:16
GameStatus * gGameStatusPtr
Definition main_loop.c:32
Camera gCameras[4]
Definition cam_main.c:17
Gfx * gMainGfxPos
Definition cam_main.c:15
u16 gMatrixListPos
Definition main_loop.c:45
DisplayContext * gDisplayContext
Definition cam_main.c:16
s16 gCurrentCamID
Definition cam_main.c:13