Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
msg_draw.c
Go to the documentation of this file.
1#include "common.h"
2#include "ld_addrs.h"
3#include "message_ids.h"
4#include "sprite.h"
5
6#include "charset/charset.h"
7#include "charset/postcard.png.h"
8#include "charset/letter_content_1.png.h"
9
10//TODO get a real ceil
11s32 my_ceil(f32 f) {
12 return (s32)(f + 0.999f);
13}
14
19extern unsigned char ui_msg_palettes[16][32];
33
35
36extern s32 gMsgBGScrollAmtX;
37extern u16 gMsgGlobalWaveCounter;
39extern s32 gMsgBGScrollAmtY;
40extern u8* D_8015131C;
41extern Gfx* D_80151338;
42extern IMG_BIN D_80159B50[0x200];
43extern PAL_BIN D_8015C7E0[0x10];
44
45#if !VERSION_JP
47#endif
48
50extern PAL_BIN D_802F4560[80][8];
51extern s32 gMessageBoxFrameParts[2][16];
52
53#if VERSION_IQUE
54static IMG_BIN D_801544A0[120][128];
55#endif
56static MessageDrawState D_80155D20;
57static MessageDrawState* msg_drawState;
58
60 { .v = { .ob = {1, 0, 0}, .tc = {0, 0}, .cn = {255, 255, 248, 255} } },
61 { .v = { .ob = {0x20, 0, 0}, .tc = {0x400, 0}, .cn = {255, 255, 248, 255} } },
62 { .v = { .ob = {0x1, 0xFFC0, 0}, .tc = {0, 0x800}, .cn = {191, 184, 176, 255} } },
63 { .v = { .ob = {0x20, 0xFFC0, 0}, .tc = {0x400, 0x800}, .cn = {191, 184, 176, 255} } },
64};
65
67 { .v = { .ob = {0x20, 0, 0}, .tc = {0, 0}, .cn = {255, 255, 248, 255} } },
68 { .v = { .ob = {0xE1, 0, 0}, .tc = {0x100, 0}, .cn = {255, 255, 248, 255} } },
69 { .v = { .ob = {0x20, 0xFFC0, 0}, .tc = {0, 0x800}, .cn = {191, 184, 176, 255} } },
70 { .v = { .ob = {0xE1, 0xFFC0, 0}, .tc = {0x100, 0x800}, .cn = {191, 184, 176, 255} } },
71};
72
74 { .v = { .ob = {0xE1, 0, 0}, .tc = {0, 0}, .cn = {255, 255, 248, 255} } },
75 { .v = { .ob = {0x100, 0, 0}, .tc = {0x400, 0}, .cn = {255, 255, 248, 255} } },
76 { .v = { .ob = {0xE1, 0xFFC0, 0}, .tc = {0, 0x800}, .cn = {191, 184, 176, 255} } },
77 { .v = { .ob = {0x100, 0xFFC0, 0}, .tc = {0x400, 0x800}, .cn = {191, 184, 176, 255} } },
78};
79
81 { .v = { .ob = {0xFFF1, 0x001E, 0}, .tc = {0, 0}, .cn = {191, 184, 176, 255} } },
82 { .v = { .ob = {0xF, 0x001E, 0}, .tc = {0x1E0, 0}, .cn = {191, 184, 176, 255} } },
83 { .v = { .ob = {0xFFFF, 0, 0}, .tc = {0, 0x1E0}, .cn = {191, 184, 176, 255} } },
84 { .v = { .ob = {1, 0, 0}, .tc = {0x1E0, 0x1E0}, .cn = {191, 184, 176, 255} } },
85};
86
88 { .v = { .ob = {0xFFF1, 0x001E, 0}, .tc = {0, 0}, .cn = {191, 184, 176, 255} } },
89 { .v = { .ob = {0xF, 0x001E, 0}, .tc = {0x1E0, 0}, .cn = {191, 184, 176, 255} } },
90 { .v = { .ob = {0xFFFF, 0, 0}, .tc = {0, 0x1E0}, .cn = {191, 184, 176, 255} } },
91 { .v = { .ob = {1, 0, 0}, .tc = {0x1E0, 0x1E0}, .cn = {191, 184, 176, 255} } },
92};
93
94Gfx D_8014C500[] = {
95 gsDPSetCycleType(G_CYC_1CYCLE),
96 gsDPSetRenderMode(G_RM_TEX_EDGE, G_RM_TEX_EDGE2),
97 gsDPSetCombineMode(G_CC_DECALRGBA, G_CC_DECALRGBA),
98 gsDPSetTextureFilter(G_TF_AVERAGE),
99 gsSPTexture(-1, -1, 0, G_TX_RENDERTILE, G_ON),
100 gsDPSetTexturePersp(G_TP_NONE),
101 gsDPSetColorDither(G_CD_DISABLE),
102 gsDPSetAlphaDither(G_AD_DISABLE),
103 gsDPSetTextureLOD(G_TL_TILE),
104 gsDPSetTextureLUT(G_TT_RGBA16),
105 gsDPSetTextureDetail(G_TD_CLAMP),
106 gsDPSetTextureConvert(G_TC_FILT),
107 gsDPSetCombineKey(G_CK_NONE),
108 gsDPSetAlphaCompare(G_AC_NONE),
109 gsDPNoOp(),
110 gsSPEndDisplayList(),
111};
112
113u8 D_8014C580[] = { 50, 80, 100, 105, 100, 0, 0, 0 };
114u8 D_8014C588[] = { 105, 100, 77, 57, 40, 27, 16, 8, 3, 0, 0, 0};
115#if VERSION_IQUE
116u32 D_8014AD24 = 2;
117#endif
118
119void appendGfx_message(MessagePrintState*, s16, s16, u16, u16, u16, u8);
120void appendGfx_msg_prim_rect(u8 r, u8 g, u8 b, u8 a, u16 ulX, u16 ulY, u16 lrX, u16 lrY);
121void msg_reset_gfx_state(void);
122void msg_draw_char(MessagePrintState* printer, MessageDrawState* drawState, s32 charIndex, s32 palette, s32 posX,
123 s32 posY);
124void msg_draw_prim_rect(u8 r, u8 g, u8 b, u8 a, u16 posX, u16 posY, u16 sizeX, u16 sizeY);
126void msg_draw_frame(s32 posX, s32 posY, s32 sizeX, s32 sizeY, s32 style, s32 palette, s32 fading, s32 bgAlpha, s32 frameAlpha);
127void msg_draw_speech_bubble(MessagePrintState* printer, s16 posX, s16 posY, s16 straightWidth, s16 curveWidth,
128 s16 height, f32 scaleX, f32 scaleY, u8 opacity, s32 arg9);
129s32 msg_get_draw_char_width(s32 character, s32 charset, s32 variation, f32 msgScale, s32 overrideCharWidth, u16 flags);
130
131void drawbox_message_delegate(s32 data, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening) {
132 MessagePrintState* printer = (MessagePrintState*)data;
133
134 appendGfx_message(printer, 0, 0, 0, 0, 4, 0);
135}
136
138 f32 scale = 1.0f;
139 s32 rotZ = 0;
140
141 switch (printer->windowState) {
143 scale = (f32)D_8014C580[printer->fadeInCounter] / 100.0;
144 rotZ = (4 - printer->fadeInCounter) * 3;
145 printer->fadeInCounter++;
146 if (D_8014C580[printer->fadeInCounter] == 0) {
148 }
149 break;
151 scale = (f32)D_8014C588[printer->fadeOutCounter] / 100.0;
152 rotZ = -printer->fadeOutCounter;
153 printer->fadeOutCounter++;
154 if (D_8014C588[printer->fadeOutCounter] == 0) {
155 printer->stateFlags |= MSG_STATE_FLAG_1;
156 }
157 break;
158 }
159
160 switch (printer->windowState) {
163 printer->windowBasePos.x = 160 - (printer->windowSize.x / 2);
164 printer->windowBasePos.y = 56;
165 draw_box(DRAW_FLAG_ROTSCALE, WINDOW_STYLE_0, printer->windowBasePos.x, 56, 0, printer->windowSize.x, printer->windowSize.y, 255, 0,
166 scale, scale, 0.0f, 0.0f, rotZ, drawbox_message_delegate, printer, NULL, SCREEN_WIDTH,
167 SCREEN_HEIGHT, NULL);
168 break;
169 default:
170 appendGfx_message(printer, printer->windowOffsetPos.x, printer->windowOffsetPos.y, printer->unk_46C,
171 printer->curLinePos, 4, 0);
172 break;
173 }
174}
175
176#if VERSION_JP
177#define MSG_NORMAL_WIDTH 192
178#define MSG_NORMAL_X 32
179#define MSG_NORMAL_WIN_WIDTH 256
180#define MSG_NORMAL_WIN_HEIGHT 64
181#define MSG_NORMAL_TEXT_Y 8
182#define MSG_NORMAL_ARROW_X 253
183#define MSG_NORMAL_ARROW_Y 56
184#define MSG_NORMAL_HEIGHT_CAP 64
185#define MSG_NORMAL_PAGE_HT 16
186#define MSG_INSPECT_TEXT_Y 5
187#define MSG_SIGN_TEXT_Y 13
188#define MSG_SIGN_WIDTH 240
189#define MSG_SIGN_OFFSET_X 20
190#define MSG_POPUP_TEXT_Y 8
191#define MSG_EPILOGUE_TEXT_Y 0
192#else
193#define MSG_NORMAL_WIDTH 218
194#define MSG_NORMAL_X 22
195#define MSG_NORMAL_WIN_WIDTH 296
196#define MSG_NORMAL_WIN_HEIGHT 68
197#define MSG_NORMAL_TEXT_Y 6
198#define MSG_NORMAL_ARROW_X 276
199#define MSG_NORMAL_ARROW_Y 57
200#define MSG_NORMAL_HEIGHT_CAP 68
201#define MSG_NORMAL_PAGE_HT 14
202#define MSG_INSPECT_TEXT_Y 3
203#define MSG_SIGN_TEXT_Y 11
204#define MSG_SIGN_WIDTH 280
205#define MSG_SIGN_OFFSET_X 0
206#define MSG_POPUP_TEXT_Y 4
207#define MSG_EPILOGUE_TEXT_Y -2
208#endif
209
210#if VERSION_PAL
211INCLUDE_ASM(s32, "msg_draw", appendGfx_message);
212#else
213void appendGfx_message(MessagePrintState* printer, s16 posX, s16 posY, u16 additionalOffsetX, u16 additionalOffsetY,
214 u16 flag, u8 alpha) {
215 SpriteRasterInfo sprRasterInfo;
216 u16 sp80bool;
217 s16 sp8E;
218 s16 sp96;
219 s16 sp9E;
220 s16 palette;
221 s16 spAE;
222 u16 spB6;
223 u8 spB8;
224#if VERSION_IQUE
225 u16 byte = 0;
226#endif
227 f32 windowScaleX;
228 MessageCharset* msgCharset;
229 f32 temp_f10;
230 f32 temp_f20;
231 f32 temp_f20_3;
232 f32 temp_f22_2;
233 f32 temp_f24;
234 f32 bubbleX;
235 f32 bubbleY;
236 f32 temp_f28;
237 f32 windowScaleY;
238 f32 temp_f8;
239 f32 temp_f8_5;
240 f64 temp_f0;
241 f32 temp_f0_2;
242 f32 temp_f2_2;
243 f64 temp_f20_2;
244 f64 temp_f22;
245 f32 temp_f2;
246 f64 temp_f2_3;
247 s32 temp_s0_7;
248 s32 temp_s0_8;
249 s32 temp_a2;
250 s32 temp_s1_5;
251 s32 i;
252 s16 temp_s3;
253 s16 temp_s4;
254 s32 windowSizeX;
255 s32 windowSizeY;
256 s16 temp_s5;
257 s16 temp_s6;
258 u32 temp_a0_49;
259 s32 animIdx;
260 u8 packedScaleX;
261 u8 packedScaleY;
262 MessageImageData* msgVarImage;
263 MessageImageData* msgImageData;
264 s32 phi_a0;
265 s32 straightWidth;
266 s32 curveWidth;
267 s32 height;
268 s32 frameX;
269 s32 frameY;
270 s32 frameSizeX;
271 s32 frameSizeY;
272 s32 frameFading;
273 u8 frameAlpha;
274 u16 fading;
275 u8 phi_s0_5;
276 IMG_PTR signRaster;
277 PAL_PTR signPalette;
278 s8 phi_s2_4;
279 u8 phi_s3_2;
280 s32 phi_v0_3;
281 s32 phi_a0_4;
282 s16 phi_t5;
283 s16 phi_s0_6;
284 s16 phi_t3;
285 s32 dbPos;
286 s16 charPosX;
287 s16 charPosY;
288 s16 phi_s2_5;
289 s32 phi_s0_7;
290 s32 phi_s1_8;
291 s8 varImgHasBorder;
292 s16 imgDrawPosX;
293 s16 imgDrawPosY;
294 f32 z1;
295 f32 z2;
296 f32 temp1;
297 f32 temp2;
298#if VERSION_JP
299 u8 rasterOffsetY;
300#else
301 s8 rasterOffsetY;
302#endif
303 s16 baseOffsetY;
304
305 msg_drawState = &D_80155D20;
306 msg_drawState->printBuffer = printer->printBuffer;
307 msg_drawState->printModeFlags = 0;
308 if (gMainGfxPos != D_80151338) {
310 }
312 sp8E = 255;
313 if (flag & 1) {
314 sp8E = alpha;
315 }
316 msg_drawState->textStartPos[0] = 0;
317 msg_drawState->textStartPos[1] = 0;
318 msg_drawState->clipX[0] = 0;
319 msg_drawState->clipY[0] = 0;
320 msg_drawState->clipX[1] = SCREEN_WIDTH - 1;
321 msg_drawState->clipY[1] = SCREEN_HEIGHT - 1;
322 msg_drawState->msgScale.x = 1.0f;
323 msg_drawState->msgScale.y = 1.0f;
324 msg_drawState->unk_29 = 0;
325 msg_drawState->framePalette = 0;
326 msg_drawState->unk_2C = 0;
327 msg_drawState->visiblePrintedCount = 0;
328 msg_drawState->centerPos = 0;
329 msg_drawState->fontVariant = 0;
330 msg_drawState->curPosX = 0;
331 msg_drawState->nextPos[0] = 0;
332 msg_drawState->nextPos[1] = 0;
333 msg_drawState->font = 0;
334 msg_drawState->effectFlags = 0;
335 msg_drawState->nextCounter = 0;
336 msg_drawState->textColor = MSG_PAL_WHITE;
337 sp96 = 0xFF;
338 spAE = 0xFF;
339 spB6 = 0;
340 spB8 = 0;
341 sp9E = -1;
342
343 if (flag & 2) {
344 msg_drawState->font = 1;
345 }
346
347 if (flag & 4) {
348 gDPSetScissor(gMainGfxPos++, G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1);
349 }
350
351 sp80bool = FALSE;
352 msg_drawState->drawBufferPos = 0;
353
354 while (!sp80bool) {
355#if VERSION_IQUE
356 u16 lastbyte, glyph_index, byte2;
357
358 lastbyte = byte;
359 byte = msg_drawState->printBuffer[msg_drawState->drawBufferPos];
360 byte2 = msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1];
361
362 switch (byte)
363#else
364 switch (msg_drawState->printBuffer[msg_drawState->drawBufferPos])
365#endif
366 {
368 msg_drawState->nextPos[0] = 0;
369 msg_drawState->nextPos[1] += (s32)((msg_drawState->msgScale.y * MsgCharsets[msg_drawState->font]->newLineY)
370#if !VERSION_JP
372#endif
373 );
374 if (msg_drawState->printModeFlags & MSG_PRINT_FLAG_40) {
375 msg_drawState->printModeFlags |= MSG_PRINT_FLAG_80;
376 }
377 msg_drawState->drawBufferPos++;
378 break;
380 msg_drawState->drawBufferPos++;
381 break;
386 msg_drawState->fontVariant = msg_drawState->printBuffer[msg_drawState->drawBufferPos] - MSG_CHAR_PRINT_VARIANT0;
387 msg_drawState->drawBufferPos++;
388 break;
392 msg_drawState->nextPos[0] += msg_get_draw_char_width(msg_drawState->printBuffer[msg_drawState->drawBufferPos],
393 msg_drawState->font, msg_drawState->fontVariant, msg_drawState->msgScale.x, msg_drawState->curPosX,
394 msg_drawState->printModeFlags);
395 msg_drawState->drawBufferPos++;
396 break;
398 switch (msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1]) {
399 case MSG_STYLE_RIGHT:
400#if VERSION_IQUE
401 msg_drawState->nextPos[1] += 5;
402#endif
403 case MSG_STYLE_LEFT:
404 case MSG_STYLE_CENTER:
405 case MSG_STYLE_TATTLE:
406 if (printer->windowState == MSG_WINDOW_STATE_OPENING && printer->fadeInCounter == 0) {
407 printer->openStartPos.x = printer->initOpenPos.x;
408 printer->openStartPos.y = printer->initOpenPos.y;
409 }
410 temp_s6 = printer->openStartPos.x;
411 temp_s5 = printer->openStartPos.y;
412 temp_s4 = printer->windowBasePos.x + (f32) printer->windowSize.x * 0.5;
413 temp_s3 = printer->windowBasePos.y + (f32) printer->windowSize.y * 0.5;
414 msg_drawState->textColor = MSG_PAL_STANDARD;
415 msg_drawState->printModeFlags |= MSG_PRINT_FLAG_10;
416
417 if (printer->style == MSG_STYLE_RIGHT || printer->style == MSG_STYLE_LEFT || printer->style == MSG_STYLE_CENTER) {
418 straightWidth = MSG_NORMAL_WIDTH;
419 printer->windowBasePos.x = MSG_NORMAL_X;
420 printer->windowBasePos.y = 13;
423 msg_drawState->textStartPos[0] = 26;
424 msg_drawState->textStartPos[1] = MSG_NORMAL_TEXT_Y;
427 curveWidth = 32;
428 height = MSG_NORMAL_HEIGHT_CAP;
429 } else {
430 straightWidth = 218;
431
432#if VERSION_JP
433 if (printer->maxLinesPerPage == 1) {
434 msg_drawState->textStartPos[0] = 18;
435 msg_drawState->textStartPos[1] = 10;
436 curveWidth = 24;
437 } else if (printer->maxLinesPerPage == 2) {
438 msg_drawState->textStartPos[0] = 22;
439 msg_drawState->textStartPos[1] = 8;
440 curveWidth = 28;
441 } else {
442 msg_drawState->textStartPos[0] = 26;
443 msg_drawState->textStartPos[1] = 8;
444 curveWidth = 32;
445 }
446#else
447 switch (printer->maxLinesPerPage) {
448 case 1:
449 msg_drawState->textStartPos[0] = 18;
450 msg_drawState->textStartPos[1] = 10;
451 curveWidth = 24;
452 break;
453 case 2:
454 msg_drawState->textStartPos[0] = 22;
455 msg_drawState->textStartPos[1] = 6;
456 curveWidth = 28;
457 break;
458 case 3:
459 msg_drawState->textStartPos[0] = 26;
460 msg_drawState->textStartPos[1] = 8;
461 curveWidth = 32;
462 break;
463 default:
464 msg_drawState->textStartPos[0] = 26;
465 msg_drawState->textStartPos[1] = 6;
466 curveWidth = 32;
467 break;
468 }
469#endif
470
471 straightWidth = printer->msgWidth;
472 if (straightWidth > 256) {
473 straightWidth = 256;
474 }
475 if (straightWidth < 70) {
476 straightWidth = 70;
477 }
478 straightWidth -= 12;
479
480 printer->windowSize.x = straightWidth + (curveWidth * 2);
481
482 height = (printer->maxLinesPerPage * MSG_NORMAL_PAGE_HT) + 16;
483 if (height > MSG_NORMAL_HEIGHT_CAP) {
484 height = MSG_NORMAL_HEIGHT_CAP;
485 }
486 if (height < 36) {
487 height = 36;
488 }
489 printer->windowSize.y = height;
490
491 temp_a2 = printer->openStartPos.x - printer->windowSize.x / 2;
492 if (temp_a2 < 18) {
493 temp_a2 = 18;
494 }
495 if (temp_a2 + printer->windowSize.x > SCREEN_WIDTH - 18) {
496 temp_a2 = SCREEN_WIDTH - 18 - printer->windowSize.x;
497 }
498 phi_a0 = printer->openStartPos.y - 38 - printer->windowSize.y;
499 if (phi_a0 < 20) {
500 phi_a0 = 20;
501 }
502 if (phi_a0 + printer->windowSize.y > 170) {
503 phi_a0 = 170 - printer->windowSize.y;
504 }
505 printer->windowBasePos.x = temp_a2;
506 printer->windowBasePos.y = phi_a0;
507 printer->rewindArrowPos.x = (printer->windowSize.x + temp_a2) - 30;
508 printer->rewindArrowPos.y = (printer->windowSize.y + phi_a0) - 18;
509 }
510
511 if (printer->windowState == MSG_WINDOW_STATE_B || printer->windowState == MSG_WINDOW_STATE_C) {
512 msg_drawState->framePalette = 1;
513 }
514
515 if (printer->windowState == MSG_WINDOW_STATE_OPENING) {
516 windowScaleX = update_lerp(EASING_LINEAR, 0.07f, 1.0f, printer->fadeInCounter, 7);
517 windowScaleY = update_lerp(EASING_LINEAR, 0.3f, 1.0f, printer->fadeInCounter, 7);
518 temp_f28 = update_lerp(EASING_LINEAR, 96.0f, 200.0f, printer->fadeInCounter, 7);
519 temp_f20 = update_lerp(EASING_SIN_OUT, temp_s5, temp_s3, printer->fadeInCounter, 7);
520 temp_f24 = update_lerp(EASING_SIN_OUT, temp_s6, temp_s4, printer->fadeInCounter, 7);
521 temp_f2_2 = printer->windowSize.x * windowScaleX;
522 temp_f0_2 = printer->windowSize.y * windowScaleY;
523 bubbleX = (temp_f24 - temp_f2_2 * 0.5) + 0.5;
524 bubbleY = (temp_f20 - temp_f0_2 * 0.5) + 0.5;
525 msg_draw_speech_bubble(printer, bubbleX, bubbleY, straightWidth, curveWidth, height, windowScaleX, windowScaleY, temp_f28, 1);
526 printer->fadeInCounter++;
527 if (printer->fadeInCounter == 7) {
529 }
530 } else if (printer->windowState == MSG_WINDOW_STATE_CLOSING) {
531 printer->fadeOutCounter++;
532 windowScaleX = update_lerp(EASING_LINEAR, 1.0f, 0.6f, printer->fadeOutCounter, 5);
533 windowScaleY = update_lerp(EASING_LINEAR, 1.0f, 0.8f, printer->fadeOutCounter, 5);
534 temp_f2 = (printer->windowSize.x * windowScaleX);
535 temp_f0 = (printer->windowSize.y * windowScaleY);
536 temp_f24 = temp_s4;
537 temp_f20 = temp_s3;
538 bubbleX = (temp_f24 - temp_f2 * 0.5) + 0.5;
539 bubbleY = (temp_f20 - temp_f0 * 0.5) + 0.5;
540 temp_f22_2 = (temp_f24 + temp_f2 * 0.5) - 0.5;
541 temp_f20_3 = (temp_f20 + temp_f0 * 0.5) - 0.5;
542 temp_f28 = update_lerp(EASING_LINEAR, 255.0f, 64.0f, printer->fadeOutCounter, 5);
543 sp8E = temp_f28 * 0.35;
544 spAE = temp_f28;
545 msg_drawState->clipX[0] = bubbleX + msg_drawState->textStartPos[0];
546 msg_drawState->clipY[0] = bubbleY + msg_drawState->textStartPos[1];
547 msg_drawState->clipX[1] = temp_f22_2 - msg_drawState->textStartPos[0];
548 msg_drawState->clipY[1] = temp_f20_3 - msg_drawState->textStartPos[1];
549 msg_draw_speech_bubble(printer, bubbleX, bubbleY, straightWidth, curveWidth, height, windowScaleX, windowScaleY, temp_f28, 1);
550 if (printer->fadeOutCounter >= 5) {
551 printer->stateFlags |= MSG_STATE_FLAG_1;
552 }
553 } else {
554 bubbleX = posX + printer->windowBasePos.x;
555 bubbleY = posY + printer->windowBasePos.y;
556
557 msg_draw_speech_bubble(printer, bubbleX, bubbleY, straightWidth, curveWidth, height, 1.0f, 1.0f, 255, 1);
558 if (((u32)(printer->openStartPos.x - 20) <= 280) && (printer->openStartPos.y <= 220)) {
559 msg_draw_speech_arrow(printer);
560 }
561 }
562
563 if (printer->windowState != MSG_WINDOW_STATE_CLOSING) {
564 msg_drawState->clipX[0] = 20;
565 msg_drawState->clipY[0] = printer->windowOffsetPos.y + printer->windowBasePos.y +
566 msg_drawState->textStartPos[1];
567 msg_drawState->clipX[1] = SCREEN_WIDTH - 20;
568 msg_drawState->clipY[1] = msg_drawState->clipY[0] + printer->windowSize.y - 16;
569 }
571 msg_drawState->drawBufferPos += 2;
572 break;
573 case MSG_STYLE_CHOICE:
574 frameFading = 0;
575 windowSizeX = printer->windowSize.x;
576 windowSizeY = printer->windowSize.y;
577 frameSizeX = windowSizeX;
578 frameSizeY = windowSizeY;
579 msg_drawState->framePalette = 0;
580 msg_drawState->textStartPos[0] = 12;
581 msg_drawState->textStartPos[1] = 6;
582 frameAlpha = 255;
583 if (printer->windowState == MSG_WINDOW_STATE_OPENING) {
584
585 printer->fadeInCounter++;
586 if (printer->fadeInCounter == 6) {
588 }
589
590 temp_f10 = ((f32) printer->fadeInCounter * (2.0 / 15.0)) + 0.2;
591
592 z1 = printer->windowBasePos.x + (windowSizeX / 2);
593 z2 = printer->windowBasePos.y + (windowSizeY / 2);
594 temp1 = z1 - (windowSizeX * temp_f10 * 0.5);
595 temp2 = z2 - (windowSizeY * temp_f10 * 0.5);
596 frameX = temp1 + 0.5;
597 frameY = temp2 + 0.5;
598 frameSizeX = windowSizeX * temp_f10 + 0.5;
599 frameSizeY = windowSizeY * temp_f10 + 0.5;
600
601 if (frameSizeX < 24) {
602 frameSizeX = 24;
603 }
604 if (frameSizeY < 24) {
605 frameSizeY = 24;
606 }
607
608 sp8E = (u8)(temp_f10 * 255.0) * 0.6;
609 } else if (printer->windowState == MSG_WINDOW_STATE_CLOSING) {
610 printer->fadeOutCounter++;
611 if (printer->fadeOutCounter >= 5) {
612 printer->stateFlags |= MSG_STATE_FLAG_1;
613 }
614 frameAlpha = ~(printer->fadeOutCounter * 0x2E);
615 sp8E = ((u8)frameAlpha) * 0.6;
616 frameFading = 1;
617 if (sp8E >= 32) {
618 sp8E -= 32;
619 }
620 frameX = printer->windowBasePos.x;
621 frameY = printer->windowBasePos.y;
622 } else {
623 frameX = printer->windowBasePos.x;
624 frameY = printer->windowBasePos.y;
625 msg_draw_prim_rect(255, 32, 32, 0, frameX - 1, frameY - 1, windowSizeX + 2, windowSizeY + 2);
626 }
627 msg_drawState->clipX[0] = frameX + 2;
628 msg_drawState->clipY[0] = frameY + 2;
629 msg_drawState->clipX[1] = frameX + frameSizeX - 2;
630 msg_drawState->clipY[1] = frameY + frameSizeY - 2;
631 msg_draw_frame(frameX, frameY, frameSizeX, frameSizeY, MSG_STYLE_CHOICE, msg_drawState->framePalette, frameFading, frameAlpha,
632 frameAlpha);
634 spAE = frameAlpha & 0xFF;
635 msg_drawState->textColor = MSG_PAL_STANDARD;
636 msg_drawState->drawBufferPos += 2;
637 msg_drawState->printModeFlags |= MSG_PRINT_FLAG_10;
638 break;
642 case MSG_STYLE_F:
643 fading = 0;
644 msg_drawState->textStartPos[0] = 16;
645 msg_drawState->textStartPos[1] = MSG_INSPECT_TEXT_Y;
646 msg_drawState->clipX[0] = printer->windowBasePos.x + 5;
647 msg_drawState->clipY[0] = printer->windowBasePos.y + 4;
648 msg_drawState->clipX[1] = printer->windowBasePos.x + printer->windowSize.x - 8;
649 msg_drawState->clipY[1] = printer->windowBasePos.y + printer->windowSize.y - 5;
650 printer->rewindArrowPos.x = msg_drawState->clipX[1] - 17;
651 printer->rewindArrowPos.y = msg_drawState->clipY[1] - 17;
652 msg_drawState->textColor = MSG_PAL_WHITE;
653 phi_s0_5 = 0xFF;
654 msg_draw_prim_rect(255, 32, 32, 0, printer->windowBasePos.x + 3, printer->windowBasePos.y - 1,
655 printer->windowSize.x - 6, 1);
656 msg_draw_prim_rect(32, 255, 32, 0, printer->windowBasePos.x + 3,
657 printer->windowBasePos.y + printer->windowSize.y, printer->windowSize.x - 6,
658 1);
659
660 if (printer->windowState == MSG_WINDOW_STATE_OPENING) {
661 phi_s0_5 = (printer->fadeInCounter * 0x30) + 0x50;
662 sp8E = (phi_s0_5 & 0xFF) - 0x30;
663 printer->fadeInCounter++;
664 fading = 1;
665 if ((s16)printer->fadeInCounter == 4) { // TODO why is this cast needed
667 }
668 } else if (printer->windowState == MSG_WINDOW_STATE_CLOSING) {
669 phi_s0_5 = -0x30 - (printer->fadeOutCounter * 40);
670 sp8E = (phi_s0_5 & 0xFF) - 0x30;
671 printer->fadeOutCounter++;
672 fading = 1;
673 if (printer->fadeOutCounter == 4) {
674 printer->stateFlags |= MSG_STATE_FLAG_1;
675 }
676 }
677
678 msg_draw_frame(printer->windowBasePos.x, printer->windowBasePos.y, printer->windowSize.x, printer->windowSize.y, MSG_STYLE_INSPECT,
679 msg_drawState->framePalette, fading, phi_s0_5, phi_s0_5);
681 spAE = phi_s0_5 & 0xFF;
682 msg_drawState->drawBufferPos += 2;
683 break;
684 case MSG_STYLE_SIGN:
686 msg_drawState->textStartPos[0] = 18;
687 msg_drawState->textStartPos[1] = MSG_SIGN_TEXT_Y;
688 printer->windowBasePos.x = 20 + MSG_SIGN_OFFSET_X;
689 printer->windowBasePos.y = 28;
690 printer->windowSize.x = MSG_SIGN_WIDTH;
691 msg_drawState->framePalette = 15;
692#if VERSION_IQUE
693 msg_drawState->nextPos[1] -= 2;
694#endif
695 temp_s1_5 = 0xFF;
696 if (printer->style == MSG_STYLE_SIGN) {
698 printer->windowSize.y = 72;
699 msg_drawState->textColor = MSG_PAL_18;
700 signPalette = ui_msg_sign_pal;
701 } else {
703 signPalette = ui_msg_lamppost_pal;
704 msg_drawState->textColor = MSG_PAL_1C;
705 }
706 msg_drawState->clipX[0] = 20 + MSG_SIGN_OFFSET_X + 14;
707 msg_drawState->clipY[0] = 40;
708 msg_drawState->clipX[1] = 283 - MSG_SIGN_OFFSET_X;
709 msg_drawState->clipY[1] = printer->windowSize.y + 17;
710 printer->rewindArrowPos.x = msg_drawState->clipX[1] - 16;
711 printer->rewindArrowPos.y = msg_drawState->clipY[1] - 9;
712
713 if (printer->windowState == MSG_WINDOW_STATE_OPENING) {
714 temp_s1_5 = (printer->fadeInCounter << 6) + 0x50;
715 sp8E = (temp_s1_5 & 0xFF) - 0x30;
716 printer->fadeInCounter++;
717 if (printer->fadeInCounter == 3) {
719 }
720 } else {
721 if (printer->windowState == MSG_WINDOW_STATE_CLOSING) {
722 temp_s1_5 = -0x30 - (printer->fadeOutCounter * 0x30);
723 sp8E = (temp_s1_5 & 0xFF) - 0x30;
724 printer->fadeOutCounter++;
725 if (printer->fadeOutCounter == 3) {
726 printer->stateFlags |= MSG_STATE_FLAG_1;
727 }
728 }
729 }
730 spAE = (u8)temp_s1_5;
731 draw_ci_image_with_clipping(ui_msg_sign_corner_topleft_png, 16, 16, G_IM_FMT_CI, G_IM_SIZ_4b, signPalette, 20 + MSG_SIGN_OFFSET_X,
732 28, 10, 10, 310, 230, temp_s1_5);
733 draw_ci_image_with_clipping(ui_msg_sign_corner_topright_png, 16, 16, G_IM_FMT_CI, G_IM_SIZ_4b, signPalette, 284 - MSG_SIGN_OFFSET_X,
734 28, 10, 10, 310, 230, temp_s1_5);
735 draw_ci_image_with_clipping(ui_msg_sign_corner_bottomleft_png, 16, 16, G_IM_FMT_CI, G_IM_SIZ_4b, signPalette, 20 + MSG_SIGN_OFFSET_X,
736 printer->windowSize.y + 12, 10, 10, 310, 230, temp_s1_5);
737 draw_ci_image_with_clipping(signRaster, 16, 16, G_IM_FMT_CI, G_IM_SIZ_4b, signPalette, 284 - MSG_SIGN_OFFSET_X, printer->windowSize.y + 12,
738 10, 10, 310, 230, temp_s1_5);
739 gDPLoadTextureTile_4b(gMainGfxPos++, ui_msg_sign_side_top_png, G_IM_FMT_CI, 32, 0, 0, 0, 31, 15, 0, G_TX_NOMIRROR | G_TX_WRAP,
740 G_TX_NOMIRROR | G_TX_WRAP, 5, 4, G_TX_NOLOD, G_TX_NOLOD);
741 gSPTextureRectangle(gMainGfxPos++, (36 + MSG_SIGN_OFFSET_X) * 4, 28 * 4, (284 - MSG_SIGN_OFFSET_X) * 4, 44 * 4, G_TX_RENDERTILE, 0, 0,
742 0x0400, 0x0400);
743 gDPLoadTextureTile_4b(gMainGfxPos++, ui_msg_sign_side_left_png, G_IM_FMT_CI, 16, 0, 0, 0, 15, 31, 0, G_TX_NOMIRROR | G_TX_WRAP,
744 G_TX_NOMIRROR | G_TX_WRAP, 4, 5, G_TX_NOLOD, G_TX_NOLOD);
745 gSPTextureRectangle(gMainGfxPos++, (20 + MSG_SIGN_OFFSET_X) * 4, 44 * 4, (36 + MSG_SIGN_OFFSET_X) * 4, (printer->windowSize.y + 12) * 4,
746 G_TX_RENDERTILE, 0, 0, 0x0400, 0x0400);
747 gDPLoadTextureTile_4b(gMainGfxPos++, ui_msg_sign_side_right_png, G_IM_FMT_CI, 16, 0, 0, 0, 15, 31, 0, G_TX_NOMIRROR | G_TX_WRAP,
748 G_TX_NOMIRROR | G_TX_WRAP, 4, 5, G_TX_NOLOD, G_TX_NOLOD);
749 gSPTextureRectangle(gMainGfxPos++, (284 - MSG_SIGN_OFFSET_X) * 4, 44 * 4, (300 - MSG_SIGN_OFFSET_X) * 4, (printer->windowSize.y + 12) * 4,
750 G_TX_RENDERTILE, 0, 0, 0x0400, 0x0400);
751 gDPLoadTextureTile_4b(gMainGfxPos++, ui_msg_sign_side_bottom_png, G_IM_FMT_CI, 32, 0, 0, 0, 31, 15, 0, G_TX_NOMIRROR | G_TX_WRAP,
752 G_TX_NOMIRROR | G_TX_WRAP, 5, 4, G_TX_NOLOD, G_TX_NOLOD);
753 gSPTextureRectangle(gMainGfxPos++, (36 + MSG_SIGN_OFFSET_X) * 4, (printer->windowSize.y + 12) * 4, (284 - MSG_SIGN_OFFSET_X) * 4,
754 (printer->windowSize.y + 28) * 4, G_TX_RENDERTILE, 0, 0, 0x0400, 0x0400);
755 gDPLoadTextureTile_4b(gMainGfxPos++, ui_msg_sign_fill_png, G_IM_FMT_CI, 8, 0, 0, 0, 7, 7, 0, G_TX_NOMIRROR | G_TX_WRAP,
756 G_TX_NOMIRROR | G_TX_WRAP, 3, 3, G_TX_NOLOD, G_TX_NOLOD);
757 gSPTextureRectangle(gMainGfxPos++, (36 + MSG_SIGN_OFFSET_X) * 4, 44 * 4, (283 - MSG_SIGN_OFFSET_X + 1) * 4, (printer->windowSize.y + 12) * 4,
758 G_TX_RENDERTILE, 0, 0, 0x0400, 0x0400);
760 msg_drawState->drawBufferPos += 2;
761 break;
763 phi_s2_4 = 0;
764 msg_drawState->textStartPos[0] = 12;
765 msg_drawState->textStartPos[1] = 5;
766 printer->windowBasePos.x = 40;
767 printer->windowBasePos.y = 28;
768 msg_drawState->clipX[0] = 45;
769 msg_drawState->clipY[0] = 32;
770 msg_drawState->clipX[1] = 272;
771 msg_drawState->clipY[1] = 81;
772 printer->rewindArrowPos.x = msg_drawState->clipX[1] - 21;
773 printer->rewindArrowPos.y = msg_drawState->clipY[1] - 20;
774 msg_drawState->framePalette = 0;
775 msg_drawState->textColor = MSG_PAL_WHITE;
776 msg_draw_prim_rect(255, 32, 32, 0, 43, 27, 234, 1);
777 msg_draw_prim_rect(32, 255, 32, 0, 43, 86, 234, 1);
778 phi_s3_2 = 0xFF;
779 if (printer->windowState == MSG_WINDOW_STATE_OPENING) {
780 phi_s3_2 = (printer->fadeInCounter * 64) + 80;
781 sp8E = (phi_s3_2 & 0xFF) - 0x30;
782 printer->fadeInCounter++;
783 if (printer->fadeInCounter == 3) {
785 }
786 phi_s2_4 = 1;
787 } else if (printer->windowState == MSG_WINDOW_STATE_CLOSING) {
788 phi_s3_2 = -0x30 - (printer->fadeOutCounter * 0x30);
789 sp8E = (phi_s3_2 & 0xFF) - 0x30;
790 printer->fadeOutCounter++;
791 if (printer->fadeOutCounter == 3) {
792 printer->stateFlags |= MSG_STATE_FLAG_1;
793 }
794 phi_s2_4 = 1;
795 }
796 msg_draw_frame(40, 28, 240, 58, MSG_STYLE_INSPECT, msg_drawState->framePalette, phi_s2_4, phi_s3_2, phi_s3_2);
797 draw_ci_image_with_clipping(printer->letterBackgroundImg, 150, 105, G_IM_FMT_CI, G_IM_SIZ_4b,
798 printer->letterBackgroundPal, 85, 97, 10, 10, 300, 220, phi_s3_2);
799 draw_ci_image_with_clipping(printer->letterContentImg, 70, 95, G_IM_FMT_CI, G_IM_SIZ_8b,
800 printer->letterContentPal, 160, 102, 10, 10, 300, 220, phi_s3_2);
802 spAE = phi_s3_2 & 0xFF;
803 msg_drawState->drawBufferPos += 2;
804 break;
805 case MSG_STYLE_POPUP:
806 case MSG_STYLE_B:
807 msg_drawState->textStartPos[0] = 16;
808 msg_drawState->textStartPos[1] = MSG_POPUP_TEXT_Y;
809 msg_drawState->clipX[0] = 0;
810 msg_drawState->clipX[1] = SCREEN_WIDTH - 1;
811 msg_drawState->clipY[0] = 0;
812 msg_drawState->clipY[1] = SCREEN_HEIGHT - 1;
813 msg_drawState->textColor = MSG_PAL_WHITE;
814 msg_drawState->printModeFlags |= MSG_PRINT_FLAG_10;
815 if (printer->windowState == MSG_WINDOW_STATE_D || printer->windowState == MSG_WINDOW_STATE_E) {
816 printer->windowBasePos.x = 0;
817 printer->windowBasePos.y = 0;
818 } else {
819 printer->windowBasePos.x = 160 - printer->windowSize.x / 2;
820 printer->windowBasePos.y = 56;
821 draw_box(0, WINDOW_STYLE_0, printer->windowBasePos.x, 56, 0, printer->windowSize.x,
822 printer->windowSize.y, 255, 0, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, NULL, 0, NULL,
824 }
826 msg_drawState->drawBufferPos += 2;
827 break;
829 printer->windowBasePos.x = 60;
830 printer->windowBasePos.y = 110;
831 printer->windowSize.x = 200;
832 printer->windowSize.y = 50;
833 msg_drawState->textStartPos[0] = 0;
834 msg_drawState->textStartPos[1] = MSG_EPILOGUE_TEXT_Y;
835 msg_drawState->clipX[0] = printer->windowBasePos.x;
836 msg_drawState->clipY[0] = printer->windowBasePos.y;
837 msg_drawState->clipX[1] = printer->windowBasePos.x + printer->windowSize.x;
838 msg_drawState->clipY[1] = printer->windowBasePos.y + printer->windowSize.y;
839 printer->rewindArrowPos.x = printer->windowBasePos.x + printer->windowSize.x - 10;
840 printer->rewindArrowPos.y = printer->windowBasePos.y + printer->windowSize.y - 10;
842 msg_drawState->drawBufferPos += 2;
843 break;
844 }
845 break;
847 if (printer->windowState == MSG_WINDOW_STATE_C) {
848 if (msg_drawState->nextCounter >= printer->unkArraySize) {
849 sp80bool = TRUE;
850 }
851 } else if (printer->windowState == MSG_WINDOW_STATE_B) {
852 if (printer->curLinePos < printer->lineEndPos[printer->unkArraySize]) {
853 if (msg_drawState->nextCounter >= printer->unkArraySize) {
854 sp80bool = TRUE;
855 }
856 } else {
857 if (printer->unkArraySize < msg_drawState->nextCounter) {
858 sp80bool = TRUE;
859 } else if (msg_drawState->nextCounter >= printer->unkArraySize) {
860 phi_a0_4 = 36;
861 if (printer->maxLinesPerPage >= 2) {
862 phi_v0_3 = 48;
863 if (printer->maxLinesPerPage == 2) {
864 phi_v0_3 = 32;
865 }
866 if (printer->unk_4C8 < phi_v0_3) {
867 if (printer->unk_4C8 <= 0x10) {
868 phi_a0_4 = 56;
869 }
870 sp8E = 0xFF - (phi_a0_4 * printer->unk_4CC);
871 if (sp8E < 0) {
872 sp8E = 0;
873 }
874 }
875 }
876 }
877 }
878 }
879 msg_drawState->nextCounter++;
880 msg_drawState->drawBufferPos++;
881 break;
883 sp80bool = TRUE;
884 break;
886 msg_drawState->drawBufferPos++;
887 switch (msg_drawState->printBuffer[msg_drawState->drawBufferPos]) {
889 msg_drawState->font = msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1];
890 msg_drawState->drawBufferPos += 2;
891 msg_drawState->printModeFlags |= MSG_PRINT_FLAG_10;
892 break;
894 msg_drawState->fontVariant = msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1];
895 msg_drawState->drawBufferPos += 2;
896 break;
898 msg_drawState->textColor = msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1];
899 msg_drawState->printModeFlags |= MSG_PRINT_FLAG_10;
900 msg_drawState->drawBufferPos += 2;
901 break;
903 msg_drawState->curPosX = msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1];
904 msg_drawState->drawBufferPos += 2;
905 break;
906#if !VERSION_IQUE
908 packedScaleX = msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1];
909 msg_drawState->msgScale.x = (f32)(packedScaleX >> 4) + ((packedScaleX & 0xF) * 0.0625f);
910 packedScaleY = msg_drawState->printBuffer[msg_drawState->drawBufferPos + 2];
911 msg_drawState->msgScale.y = (f32)(packedScaleY >> 4) + ((packedScaleY & 0xF) * 0.0625f);
912 msg_drawState->drawBufferPos += 3;
913 if (msg_drawState->msgScale.x > 1.0 || msg_drawState->msgScale.y > 1.0) {
914 gDPSetTextureFilter(gMainGfxPos++, G_TF_POINT);
915 } else if (msg_drawState->msgScale.x < 1.0 || msg_drawState->msgScale.y < 1.0) {
916 gDPSetTextureFilter(gMainGfxPos++, G_TF_AVERAGE);
917 }
918 break;
920 msg_drawState->msgScale.x = 1.0f;
921 msg_drawState->msgScale.y = 1.0f;
922 msg_drawState->drawBufferPos++;
923 gDPSetTextureFilter(gMainGfxPos++, G_TF_AVERAGE);
924 break;
925#endif
927 msg_drawState->nextPos[0] = msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1] * 256 +
928 (msg_drawState->printBuffer[msg_drawState->drawBufferPos + 2]);
929 msg_drawState->drawBufferPos += 3;
930 break;
932 msg_drawState->nextPos[1] = msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1];
933 msg_drawState->drawBufferPos += 2;
934 break;
936 msg_drawState->nextPos[0] += msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1];
937 msg_drawState->drawBufferPos += 2;
938 break;
940 msg_drawState->nextPos[1] += msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1];
941 msg_drawState->drawBufferPos += 2;
942 break;
944 msg_drawState->nextPos[1] -= msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1];
945 msg_drawState->drawBufferPos += 2;
946 break;
948 msgImageData = &(*gMsgVarImages)[msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1]];
949 phi_t5 = sp8E;
950 if (sp8E < 0xFF) {
951 phi_t5 = (s32)(sp8E * 0.7);
952 }
953 imgDrawPosX = (s16)((msg_drawState->nextPos[0] + (msg_drawState->textStartPos[0] + (printer->windowBasePos.x + posX))) -
954 additionalOffsetX);
955 imgDrawPosY = (s16)((msg_drawState->nextPos[1] + (msg_drawState->textStartPos[1] + (printer->windowBasePos.y + posY))) -
956 additionalOffsetY);
957
958 draw_ci_image_with_clipping(msgImageData->raster, msgImageData->width, msgImageData->height, msgImageData->format, msgImageData->bitDepth,
959 msgImageData->palette, imgDrawPosX, imgDrawPosY, (s32) msg_drawState->clipX[0], (s32) msg_drawState->clipY[0],
960 msg_drawState->clipX[1] - msg_drawState->clipX[0], msg_drawState->clipY[1] - msg_drawState->clipY[0], phi_t5);
962 msg_drawState->drawBufferPos += 2;
963 break;
965 phi_s0_6 = sp8E;
966 if (sp8E < 0xFF) {
967 phi_s0_6 = (s32)(sp8E * 0.7);
968 }
969
970 if (spr_get_npc_raster_info(&sprRasterInfo, (msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1] << 8) |
971 msg_drawState->printBuffer[msg_drawState->drawBufferPos + 2],
972 msg_drawState->printBuffer[msg_drawState->drawBufferPos + 3]) != 0) {
973 imgDrawPosX = (s16)((msg_drawState->nextPos[0] + (msg_drawState->textStartPos[0] + (printer->windowBasePos.x + posX))) -
974 additionalOffsetX);
975 imgDrawPosY = (s16)((msg_drawState->nextPos[1] + (msg_drawState->textStartPos[1] + (printer->windowBasePos.y + posY))) -
976 additionalOffsetY);
977
978 draw_ci_image_with_clipping(sprRasterInfo.raster, sprRasterInfo.width, sprRasterInfo.height, G_IM_FMT_CI, G_IM_SIZ_4b, sprRasterInfo.defaultPal, imgDrawPosX, imgDrawPosY,
979 msg_drawState->clipX[0], msg_drawState->clipY[0], msg_drawState->clipX[1] - msg_drawState->clipX[0],
980 msg_drawState->clipY[1] - msg_drawState->clipY[0], phi_s0_6);
981 msg_drawState->printModeFlags |= MSG_PRINT_FLAG_10;
982 }
983 msg_drawState->drawBufferPos += 4;
984 break;
986 if (D_8015131C != 0) {
987 phi_t3 = sp8E;
988 if (sp8E < 0xFF) {
989 phi_t3 = (s32)(sp8E * 0.7);
990 }
991 imgDrawPosX = (s16)((msg_drawState->nextPos[0] + (msg_drawState->textStartPos[0] + (printer->windowBasePos.x + posX))) -
992 additionalOffsetX);
993 imgDrawPosY = (s16)((msg_drawState->nextPos[1] + (msg_drawState->textStartPos[1] + (printer->windowBasePos.y + posY))) -
994 additionalOffsetY);
995
996 draw_ci_image_with_clipping(D_80159B50, 32, 32, G_IM_FMT_CI, G_IM_SIZ_4b, D_8015C7E0, imgDrawPosX, imgDrawPosY, msg_drawState->clipX[0],
997 msg_drawState->clipY[0], msg_drawState->clipX[1] - msg_drawState->clipX[0],
998 msg_drawState->clipY[1] - msg_drawState->clipY[0], phi_t3);
999 msg_drawState->printModeFlags |= MSG_PRINT_FLAG_10;
1000 }
1001 msg_drawState->drawBufferPos++;
1002 break;
1004 animIdx = msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1];
1005 if (printer->animTimers[animIdx] == -1) {
1006 printer->animTimers[animIdx] = msg_drawState->printBuffer[msg_drawState->drawBufferPos + 3];
1007 }
1008 if (printer->animTimers[animIdx] == 0) {
1009 printer->curAnimFrame[animIdx]++;
1010 }
1011
1012 dbPos = msg_drawState->drawBufferPos;
1013 while (TRUE) {
1014 if ((msg_drawState->printBuffer[dbPos - 1] == MSG_CHAR_PRINT_FUNCTION) &&
1015 (msg_drawState->printBuffer[dbPos] == MSG_PRINT_FUNC_ANIM_DELAY) &&
1016 (msg_drawState->printBuffer[dbPos + 1] == animIdx)) {
1017 if (msg_drawState->printBuffer[dbPos + 2] != printer->curAnimFrame[animIdx]) {
1018 dbPos += 4;
1019 } else {
1020 break;
1021 }
1022 } else {
1023 if ((msg_drawState->printBuffer[dbPos] == MSG_CHAR_PRINT_FUNCTION) &&
1024 (msg_drawState->printBuffer[dbPos + 1] == MSG_PRINT_FUNC_ANIM_LOOP) &&
1025 (msg_drawState->printBuffer[dbPos + 2] == animIdx)) {
1026
1027 if (printer->animTimers[animIdx] == 0) {
1028 printer->curAnimFrame[animIdx] = msg_drawState->printBuffer[dbPos + 3];
1029 dbPos = msg_drawState->drawBufferPos;
1030 continue;
1031 } else {
1032 dbPos++;
1033 break;
1034 }
1035 } else {
1036 if (msg_drawState->printBuffer[dbPos] == MSG_CHAR_PRINT_FUNCTION &&
1037 msg_drawState->printBuffer[dbPos + 1] == MSG_PRINT_FUNC_ANIM_DONE) {
1038 if (msg_drawState->printBuffer[dbPos + 2] == animIdx) {
1039 dbPos++;
1040 break;
1041 }
1042 }
1043 }
1044 }
1045 dbPos++;
1046 }
1047 msg_drawState->drawBufferPos = dbPos;
1048
1049 switch (msg_drawState->printBuffer[msg_drawState->drawBufferPos]) {
1051 if (printer->animTimers[animIdx] == 0) {
1052 if (msg_drawState->printBuffer[msg_drawState->drawBufferPos + 3] == 0) {
1053 printer->animTimers[animIdx] = -2;
1054 } else {
1055 printer->animTimers[animIdx] = msg_drawState->printBuffer[msg_drawState->drawBufferPos + 3];
1056 }
1057 }
1058 msg_drawState->drawBufferPos += 4;
1059 break;
1061 msg_drawState->drawBufferPos += 3;
1062 break;
1064 msg_drawState->drawBufferPos += 2;
1065 break;
1066 }
1067 break;
1069 msg_drawState->drawBufferPos += 3;
1070 break;
1072 msg_drawState->drawBufferPos += 2;
1073 break;
1075 printer->cursorPosX[msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1]] = msg_drawState->textStartPos[0] +
1076 msg_drawState->nextPos[0] - additionalOffsetX - 6;
1077 printer->cursorPosY[msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1]] = msg_drawState->textStartPos[1] +
1078 msg_drawState->nextPos[1] - additionalOffsetY - 1;
1079 msg_drawState->drawBufferPos += 2;
1080 break;
1082 if (msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1] == 0xFF) {
1083 msg_drawState->printModeFlags &= ~MSG_PRINT_FLAG_20;
1084 } else {
1085 msg_drawState->unk_2D = msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1];
1086 msg_drawState->printModeFlags |= MSG_PRINT_FLAG_20;
1087 msg_drawState->nextPos[0] += 14;
1088 }
1089 msg_drawState->drawBufferPos += 2;
1090 break;
1092 msg_drawState->framePalette = msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1];
1093 msg_drawState->drawBufferPos += 2;
1094 break;
1097 msg_drawState->drawBufferPos++;
1098 break;
1100 msg_drawState->savedPos[0] = msg_drawState->nextPos[0];
1101 msg_drawState->savedPos[1] = msg_drawState->nextPos[1];
1102 msg_drawState->drawBufferPos++;
1103 break;
1105 msg_drawState->nextPos[0] = msg_drawState->savedPos[0];
1106 msg_drawState->nextPos[1] = msg_drawState->savedPos[1];
1107 msg_drawState->drawBufferPos++;
1108 break;
1110 msg_drawState->savedColor = msg_drawState->textColor;
1111 msg_drawState->drawBufferPos++;
1112 break;
1114 msg_drawState->textColor = msg_drawState->savedColor;
1115 msg_drawState->drawBufferPos++;
1116 break;
1118 switch (msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1]) {
1119 case MSG_FX_SHAKE:
1120 msg_drawState->effectFlags |= MSG_FX_FLAG_SHAKE;
1121 msg_drawState->drawBufferPos += 2;
1122 break;
1123 case MSG_FX_WAVE:
1124 msg_drawState->effectFlags |= MSG_FX_FLAG_WAVE;
1125 msg_drawState->drawBufferPos += 2;
1126 break;
1128 msg_drawState->effectFlags |= MSG_FX_FLAG_NOISE_OUTLINE;
1130 msg_drawState->drawBufferPos += 2;
1131 break;
1132 case MSG_FX_STATIC:
1133 msg_drawState->effectFlags |= MSG_FX_FLAG_STATIC;
1134 gDPSetEnvColor(gMainGfxPos++,
1135 msg_drawState->printBuffer[msg_drawState->drawBufferPos + 2],
1136 msg_drawState->printBuffer[msg_drawState->drawBufferPos + 2],
1137 msg_drawState->printBuffer[msg_drawState->drawBufferPos + 2],
1138 0);
1139 gDPSetCombineMode(gMainGfxPos++, PM_CC_MSG_STATIC, PM_CC_MSG_STATIC);
1140 msg_drawState->drawBufferPos += 3;
1141 break;
1142 case MSG_FX_BLUR:
1143 msg_drawState->effectFlags |= MSG_FX_FLAG_BLUR;
1144 spB8 = msg_drawState->printBuffer[msg_drawState->drawBufferPos + 2];
1145 msg_drawState->drawBufferPos += 3;
1146 break;
1147 case MSG_FX_RAINBOW:
1148 msg_drawState->effectFlags |= MSG_FX_FLAG_RAINBOW;
1149 msg_drawState->drawBufferPos += 2;
1150 break;
1151 case MSG_FX_DITHER_FADE:
1152 msg_drawState->effectFlags |= MSG_FX_FLAG_DITHER_FADE;
1153 spB6 = msg_drawState->printBuffer[msg_drawState->drawBufferPos + 2];
1154 msg_drawState->drawBufferPos += 3;
1155 break;
1156 case MSG_FX_GLOBAL_WAVE:
1157 msg_drawState->effectFlags |= MSG_FX_FLAG_GLOBAL_WAVE;
1158 msg_drawState->drawBufferPos += 2;
1159 break;
1161 msg_drawState->effectFlags |= MSG_FX_FLAG_GLOBAL_RAINBOW;
1162 msg_drawState->drawBufferPos += 2;
1163 break;
1164 case MSG_FX_RISE_PRINT:
1165 msg_drawState->effectFlags |= MSG_FX_FLAG_RISE_PRINT;
1166 msg_drawState->drawBufferPos += 2;
1167 break;
1168 case MSG_FX_GROW_PRINT:
1169 msg_drawState->effectFlags |= MSG_FX_FLAG_GROW_PRINT;
1170 msg_drawState->drawBufferPos += 2;
1171 break;
1172 case MSG_FX_SIZE_JITTER:
1173 msg_drawState->effectFlags |= MSG_FX_FLAG_SIZE_JITTER;
1174 msg_drawState->drawBufferPos += 2;
1175 break;
1176 case MSG_FX_SIZE_WAVE:
1177 msg_drawState->effectFlags |= MSG_FX_FLAG_SIZE_WAVE;
1178 msg_drawState->drawBufferPos += 2;
1179 break;
1180 case MSG_FX_DROP_SHADOW:
1181 msg_drawState->effectFlags |= MSG_FX_FLAG_DROP_SHADOW;
1182 msg_drawState->drawBufferPos += 2;
1183 break;
1184 }
1185 break;
1187 switch (msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1]) {
1188 case MSG_FX_SHAKE:
1189 msg_drawState->effectFlags &= ~MSG_FX_FLAG_SHAKE;
1190 break;
1191 case MSG_FX_WAVE:
1192 msg_drawState->effectFlags &= ~MSG_FX_FLAG_WAVE;
1193 break;
1195 msg_drawState->effectFlags &= ~MSG_FX_FLAG_NOISE_OUTLINE;
1196 break;
1197 case MSG_FX_STATIC:
1198 msg_drawState->effectFlags &= ~MSG_FX_FLAG_STATIC;
1199 break;
1200 case MSG_FX_BLUR:
1201 msg_drawState->effectFlags &= ~MSG_FX_FLAG_BLUR;
1202 break;
1203 case MSG_FX_RAINBOW:
1204 msg_drawState->effectFlags &= ~MSG_FX_FLAG_RAINBOW;
1205 msg_drawState->printModeFlags |= MSG_PRINT_FLAG_10;
1206 break;
1207 case MSG_FX_DITHER_FADE:
1208 msg_drawState->effectFlags &= ~MSG_FX_FLAG_DITHER_FADE;
1209 break;
1210 case MSG_FX_GLOBAL_WAVE:
1211 msg_drawState->effectFlags &= ~MSG_FX_FLAG_GLOBAL_WAVE;
1212 break;
1214 msg_drawState->effectFlags &= ~MSG_FX_FLAG_GLOBAL_RAINBOW;
1215 msg_drawState->printModeFlags |= MSG_PRINT_FLAG_10;
1216 break;
1217 case MSG_FX_RISE_PRINT:
1218 msg_drawState->effectFlags &= ~MSG_FX_FLAG_RISE_PRINT;
1219 break;
1220 case MSG_FX_GROW_PRINT:
1221 msg_drawState->effectFlags &= ~MSG_FX_FLAG_GROW_PRINT;
1222 break;
1223 case MSG_FX_SIZE_JITTER:
1224 msg_drawState->effectFlags &= ~MSG_FX_FLAG_SIZE_JITTER;
1225 break;
1226 case MSG_FX_SIZE_WAVE:
1227 msg_drawState->effectFlags &= ~MSG_FX_FLAG_SIZE_WAVE;
1228 break;
1229 case MSG_FX_DROP_SHADOW:
1230 msg_drawState->effectFlags &= ~MSG_FX_FLAG_DROP_SHADOW;
1231 break;
1232 }
1233 msg_drawState->drawBufferPos += 2;
1234 break;
1236 if (msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1] != 0) {
1237 msg_drawState->centerPos = msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1];
1238 if (msg_drawState->centerPos == 0xFF) {
1239 msg_drawState->centerPos = printer->windowSize.x / 2;
1240 }
1242 } else {
1243 msg_drawState->nextPos[0] = 0;
1244 msg_drawState->printModeFlags &= ~(MSG_PRINT_FLAG_40 | MSG_PRINT_FLAG_80);
1245 }
1246 msg_drawState->drawBufferPos += 2;
1247 break;
1248 }
1249 break;
1250 default:
1251#if VERSION_IQUE
1252 if (lastbyte >= 0x5f && lastbyte <= 0x8f) {
1253 msg_drawState->drawBufferPos++;
1254 break;
1255 }
1256#endif
1257
1258 if (msg_drawState->printModeFlags & MSG_PRINT_FLAG_2) {
1259 sp96 = 0xFF;
1260 gDPPipeSync(gMainGfxPos++);
1261 gSPDisplayList(gMainGfxPos++, D_8014C500);
1262 }
1263 msg_drawState->charScale.x = msg_drawState->msgScale.x;
1264 msg_drawState->charScale.y = msg_drawState->msgScale.y;
1265 if (msg_drawState->printModeFlags & MSG_PRINT_FLAG_80) {
1266 msg_drawState->nextPos[0] += msg_drawState->centerPos - printer->msgWidth / 2;
1267 msg_drawState->printModeFlags &= ~MSG_PRINT_FLAG_80;
1268 }
1269 if (msg_drawState->printModeFlags & MSG_PRINT_FLAG_40) {
1270 charPosX = msg_drawState->nextPos[0] + (printer->windowBasePos.x + posX);
1271 } else {
1272 charPosX = msg_drawState->nextPos[0] + (msg_drawState->textStartPos[0] + (printer->windowBasePos.x +
1273 posX));
1274 }
1275
1276 baseOffsetY = msg_drawState->nextPos[1] + (msg_drawState->textStartPos[1] + (printer->windowBasePos.y + posY));
1277 msgCharset = MsgCharsets[msg_drawState->font];
1278 rasterOffsetY = msgCharset->rasters[msg_drawState->fontVariant].baseHeightOffset;
1279 charPosY = rasterOffsetY + (baseOffsetY - additionalOffsetY);
1280
1281 if ((sp8E != 0) &&
1282 (charPosX < msg_drawState->clipX[1]) &&
1283 (charPosY < msg_drawState->clipY[1]) &&
1284 (msg_drawState->clipX[0] < charPosX + (s32)(msg_drawState->msgScale.x *
1285 msgCharset->rasters[msg_drawState->fontVariant].monospaceWidth)) &&
1286 (msg_drawState->clipY[0] < charPosY + (s32)(msg_drawState->msgScale.y * msgCharset->newLineY
1287#if !VERSION_JP
1289#endif
1290 ))) {
1291 palette = msg_drawState->textColor;
1292 phi_s2_5 = sp8E;
1293 if (msg_drawState->effectFlags & MSG_FX_FLAG_BLUR) {
1294 phi_s2_5 = (f32) phi_s2_5 * 0.35;
1295 }
1296 if ((printer->windowState == MSG_WINDOW_STATE_WAITING_FOR_CHOICE) && (msg_drawState->printModeFlags & MSG_PRINT_FLAG_20)) {
1297 if (msg_drawState->unk_2D == printer->curOption) {
1299 } else {
1300 msg_drawState->effectFlags &= ~MSG_FX_FLAG_GLOBAL_RAINBOW;
1301 msg_drawState->effectFlags &= ~MSG_FX_FLAG_GLOBAL_WAVE;
1302 msg_drawState->effectFlags &= ~MSG_FX_FLAG_DROP_SHADOW;
1303 palette = msg_drawState->textColor;
1304 msg_drawState->printModeFlags |= MSG_PRINT_FLAG_10;
1305 }
1306 }
1307 if (msg_drawState->effectFlags & MSG_FX_FLAG_SHAKE) {
1308 charPosX += rand_int(10000) % 2;
1309 charPosY += rand_int(10000) % 2;
1310 }
1311 if (msg_drawState->effectFlags & MSG_FX_FLAG_WAVE) {
1312 temp_f2_3 = msg_drawState->msgScale.x - 1.0;
1313 temp_s0_7 = (printer->effectFrameCounter * (s32)(20.0 - (temp_f2_3 * 5.0))) - (msg_drawState->visiblePrintedCount *
1314 (s32)(45.0 - (temp_f2_3 * 15.0)));
1315 charPosX += cosine(temp_s0_7) * ((msg_drawState->msgScale.x - 1.0) + 1.6);
1316 charPosY += cosine((temp_s0_7 + 180.0 + 90.0)) * (msg_drawState->msgScale.y - 1.0 + 1.6);
1317 }
1318 if (msg_drawState->effectFlags & MSG_FX_FLAG_GLOBAL_WAVE) {
1319 temp_s0_8 = (gMsgGlobalWaveCounter * (s32)(20.0 - ((msg_drawState->msgScale.x - 1.0) * 5.0))) -
1320 (msg_drawState->visiblePrintedCount * 45);
1321 charPosX += cosine(temp_s0_8) * ((msg_drawState->msgScale.x - 1.0) + 1.6);
1322 charPosY += cosine((temp_s0_8 + 180.0 + 90.0)) * ((msg_drawState->msgScale.y - 1.0) + 1.6);
1323 }
1324 if (msg_drawState->effectFlags & MSG_FX_FLAG_RAINBOW) {
1325 palette = abs(msg_drawState->visiblePrintedCount - (u16)(printer->effectFrameCounter / 3)) % 10;
1326 }
1327 if (msg_drawState->effectFlags & MSG_FX_FLAG_GLOBAL_RAINBOW) {
1328 palette = abs(msg_drawState->visiblePrintedCount - (u16)(gGameStatusPtr->frameCounter / 3)) % 10;
1329 }
1330 if (msg_drawState->effectFlags & MSG_FX_FLAG_DITHER_FADE) {
1331 gDPSetAlphaDither(gMainGfxPos++, G_AD_NOISE);
1332 gDPSetAlphaCompare(gMainGfxPos++, G_AC_DITHER);
1333 phi_s2_5 = spB6 * (phi_s2_5 / 255.0);
1334 }
1335 if ((msg_drawState->printModeFlags & MSG_PRINT_FLAG_2) || (phi_s2_5 != sp96)) {
1336 if ((sp96 < 0xFF) && (phi_s2_5 < 0xFF)) {
1337 gDPSetPrimColor(gMainGfxPos++, 0, 0, 0, 0, 0, phi_s2_5);
1338 } else if ((sp96 == 0xFF) && (phi_s2_5 < 0xFF)) {
1339 gDPPipeSync(gMainGfxPos++);
1340 if (printer->stateFlags & MSG_STATE_FLAG_4000) {
1341 gDPSetRenderMode(gMainGfxPos++, IM_RD | CVG_DST_CLAMP | ZMODE_XLU | FORCE_BL | GBL_c1(G_BL_CLR_IN, G_BL_A_IN,
1342 G_BL_CLR_MEM, G_BL_1MA), IM_RD | CVG_DST_CLAMP | ZMODE_XLU | FORCE_BL | GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM,
1343 G_BL_1MA));
1344
1345 } else {
1346 gDPSetRenderMode(gMainGfxPos++, IM_RD | CVG_DST_SAVE | ZMODE_XLU | FORCE_BL | GBL_c1(G_BL_CLR_IN, G_BL_A_IN,
1347 G_BL_CLR_MEM, G_BL_1MA), IM_RD | CVG_DST_SAVE | ZMODE_XLU | FORCE_BL | GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM,
1348 G_BL_1MA));
1349
1350 }
1351 gDPSetCombineMode(gMainGfxPos++, PM_CC_02, PM_CC_02);
1352 gDPSetPrimColor(gMainGfxPos++, 0, 0, 0, 0, 0, phi_s2_5);
1353 } else if ((sp96 < 0xFF) && (phi_s2_5 == 0xFF)) {
1354 gDPPipeSync(gMainGfxPos++);
1355 gDPSetRenderMode(gMainGfxPos++, G_RM_TEX_EDGE, G_RM_TEX_EDGE2);
1356 gDPSetCombineMode(gMainGfxPos++, G_CC_DECALRGBA, G_CC_DECALRGBA);
1357 }
1358 sp96 = phi_s2_5;
1359 }
1360 if (phi_s2_5 > 0) {
1361 if (msg_drawState->effectFlags & MSG_FX_FLAG_RISE_PRINT) {
1362 if ((msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1] != MSG_CHAR_PRINT_ENDL) &&
1363 (msg_drawState->printBuffer[msg_drawState->drawBufferPos + 2] != MSG_CHAR_PRINT_ENDL) &&
1364 (msg_drawState->printBuffer[msg_drawState->drawBufferPos + 3] != MSG_CHAR_PRINT_ENDL) &&
1365 (msg_drawState->printBuffer[msg_drawState->drawBufferPos + 4] != MSG_CHAR_PRINT_ENDL)) {
1366 if ((msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1] == MSG_CHAR_PRINT_END) &&
1367 (printer->windowState == MSG_WINDOW_STATE_PRINTING)) {
1368 msg_drawState->charScale.x = msg_drawState->msgScale.x * 1.7;
1369 msg_drawState->charScale.y = msg_drawState->msgScale.y * 1.7;
1370 temp_f8 = (msg_drawState->charScale.y / 1.7) * 6.0;
1371 charPosX -= temp_f8;
1372 charPosY -= temp_f8;
1373 } else if ((msg_drawState->printBuffer[msg_drawState->drawBufferPos + 2] == MSG_CHAR_PRINT_END) &&
1374 (printer->windowState == MSG_WINDOW_STATE_PRINTING)) {
1375 msg_drawState->charScale.x = msg_drawState->msgScale.x * 1.4;
1376 msg_drawState->charScale.y = msg_drawState->msgScale.y * 1.4;
1377 temp_f8 = (msg_drawState->charScale.y / 1.4) * 3.0;
1378 charPosX -= temp_f8;
1379 charPosY -= temp_f8;
1380 } else if ((msg_drawState->printBuffer[msg_drawState->drawBufferPos + 3] == MSG_CHAR_PRINT_END) &&
1381 (printer->windowState == MSG_WINDOW_STATE_PRINTING)) {
1382 msg_drawState->charScale.x = msg_drawState->msgScale.x * 1.2;
1383 msg_drawState->charScale.y = msg_drawState->msgScale.y * 1.2;
1384 temp_f8 = (msg_drawState->charScale.y / 1.2) * 2.0;
1385 charPosX -= temp_f8;
1386 charPosY -= temp_f8;
1387 }
1388 }
1389 } else if (msg_drawState->effectFlags & MSG_FX_FLAG_GROW_PRINT) {
1390 if ((msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1] != MSG_CHAR_PRINT_ENDL) &&
1391 (msg_drawState->printBuffer[msg_drawState->drawBufferPos + 2] != MSG_CHAR_PRINT_ENDL) &&
1392 (msg_drawState->printBuffer[msg_drawState->drawBufferPos + 3] != MSG_CHAR_PRINT_ENDL) &&
1393 (msg_drawState->printBuffer[msg_drawState->drawBufferPos + 4] != MSG_CHAR_PRINT_ENDL)) {
1394 if ((msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1] == MSG_CHAR_PRINT_END) &&
1395 (printer->windowState == MSG_WINDOW_STATE_PRINTING)) {
1396 msg_drawState->charScale.x = msg_drawState->msgScale.x * 0.3;
1397 msg_drawState->charScale.y = msg_drawState->msgScale.y * 0.3;
1398 charPosX += 5;
1399 charPosY += 5;
1400 } else if ((msg_drawState->printBuffer[msg_drawState->drawBufferPos + 2] == MSG_CHAR_PRINT_END) &&
1401 (printer->windowState == MSG_WINDOW_STATE_PRINTING)) {
1402 msg_drawState->charScale.x = msg_drawState->msgScale.x * 0.5;
1403 msg_drawState->charScale.y = msg_drawState->msgScale.y * 0.5;
1404 charPosX += 3;
1405 charPosY += 3;
1406 } else if ((msg_drawState->printBuffer[msg_drawState->drawBufferPos + 3] == MSG_CHAR_PRINT_END) &&
1407 (printer->windowState == MSG_WINDOW_STATE_PRINTING)) {
1408 msg_drawState->charScale.x = msg_drawState->msgScale.x * 0.75;
1409 msg_drawState->charScale.y = msg_drawState->msgScale.y * 0.75;
1410 charPosX += 2;
1411 charPosY += 2;
1412 }
1413 }
1414 } else if (msg_drawState->effectFlags & MSG_FX_FLAG_SIZE_JITTER) {
1415 temp_f8_5 = rand_int(10000) % 101;
1416 temp_f8_5 /= 100.0;
1417 temp_f8_5 = ((temp_f8_5 * 0.5) + 1.0) - 0.25;
1418
1419 if (temp_f8_5 > 1.0) {
1420 msg_drawState->charScale.x = msg_drawState->msgScale.x * temp_f8_5;
1421 msg_drawState->charScale.y = msg_drawState->msgScale.y * temp_f8_5;
1422 charPosX -= (temp_f8_5 * 8.0) - 8.5;
1423 charPosY -= (temp_f8_5 * 8.0) - 8.5;
1424 } else if (temp_f8_5 < 1.0) {
1425 msg_drawState->charScale.x = msg_drawState->msgScale.x * temp_f8_5;
1426 msg_drawState->charScale.y = msg_drawState->msgScale.y * temp_f8_5;
1427 charPosX += 8.0 - (temp_f8_5 * 16.0) * 0.5;
1428 charPosY += 8.0 - (temp_f8_5 * 16.0) * 0.5;
1429 }
1430 } else if (msg_drawState->effectFlags & MSG_FX_FLAG_SIZE_WAVE) {
1431 s32 mod360;
1432
1433 temp_a0_49 = printer->effectFrameCounter * 15;
1434 temp_a0_49 -= msg_drawState->visiblePrintedCount * 15;
1435 mod360 = temp_a0_49 % 360;
1436 temp_f8_5 = (cosine(mod360) * 0.25) + 1.0;
1437
1438 if (temp_f8_5 > 1.0) {
1439 msg_drawState->charScale.x = msg_drawState->msgScale.x * temp_f8_5;
1440 msg_drawState->charScale.y = msg_drawState->msgScale.y * temp_f8_5;
1441 charPosX -= (temp_f8_5 * 8.0) - 8.5;
1442 charPosY -= (temp_f8_5 * 8.0) - 8.5;
1443 } else if (temp_f8_5 < 1.0) {
1444 msg_drawState->charScale.x = msg_drawState->msgScale.x * temp_f8_5;
1445 msg_drawState->charScale.y = msg_drawState->msgScale.y * temp_f8_5;
1446 charPosX += 8.0 - (temp_f8_5 * 16.0) * 0.5;
1447 charPosY += 8.0 - (temp_f8_5 * 16.0) * 0.5;
1448 }
1449 }
1450
1451 if ((printer->windowState == MSG_WINDOW_STATE_B || printer->windowState == MSG_WINDOW_STATE_C) &&
1452 (printer->style == MSG_STYLE_RIGHT ||
1453 printer->style == MSG_STYLE_LEFT ||
1454 printer->style == MSG_STYLE_CENTER ||
1455 printer->style == MSG_STYLE_TATTLE))
1456 {
1457 switch (palette) {
1458 case MSG_PAL_WHITE:
1459 case MSG_PAL_RED:
1460 case MSG_PAL_10:
1461 case MSG_PAL_11:
1462 case MSG_PAL_12:
1463 case MSG_PAL_13:
1464 case MSG_PAL_14:
1465 break;
1466#if !VERSION_IQUE
1467 case MSG_PAL_STANDARD:
1468 palette = MSG_PAL_40;
1469 break;
1470#endif
1471 case MSG_PAL_20:
1472 palette = MSG_PAL_41;
1473 break;
1474 case MSG_PAL_22:
1475 palette = MSG_PAL_42;
1476 break;
1477 case MSG_PAL_23:
1478 palette = MSG_PAL_43;
1479 break;
1480 case MSG_PAL_25:
1481 palette = MSG_PAL_44;
1482 break;
1483 default:
1484 palette = MSG_PAL_40;
1485 break;
1486 }
1487 }
1488 if (palette != sp9E) {
1489 sp9E = palette;
1490 msg_drawState->printModeFlags |= MSG_PRINT_FLAG_10;
1491 }
1492 if ((msg_drawState->effectFlags & MSG_FX_FLAG_DROP_SHADOW) && (phi_s2_5 == 0xFF)) {
1493 gDPPipeSync(gMainGfxPos++);
1494 gDPSetRenderMode(gMainGfxPos++, G_RM_XLU_SURF, G_RM_XLU_SURF2);
1495 gDPSetCombineMode(gMainGfxPos++, PM_CC_07, PM_CC_07);
1496 gDPSetPrimColor(gMainGfxPos++, 0, 0, 40, 40, 40, 72);
1497#if VERSION_IQUE
1498 if (byte >= MSG_CHAR_MULTIBYTE_FIRST && byte <= MSG_CHAR_MULTIBYTE_LAST) {
1499 glyph_index = (MSG_CHAR_ZH_START - MSG_CHAR_MULTIBYTE_FIRST) + byte + (byte2 - 1)
1500 * (MSG_CHAR_MULTIBYTE_LAST - MSG_CHAR_MULTIBYTE_FIRST + 1);
1501 msg_draw_char(printer, msg_drawState, glyph_index,
1502 palette, charPosX + 2, charPosY + 2);
1503 } else {
1504 msg_draw_char(printer, msg_drawState, byte,
1505 palette, charPosX + 2, charPosY + 2);
1506 }
1507#else
1508 msg_draw_char(printer, msg_drawState,
1509 msg_drawState->printBuffer[msg_drawState->drawBufferPos],
1510 palette, charPosX + 2, charPosY + 2);
1511#endif
1512 gDPPipeSync(gMainGfxPos++);
1513 if (phi_s2_5 < 0xFF) {
1514 gDPSetRenderMode(gMainGfxPos++, G_RM_XLU_SURF, G_RM_XLU_SURF2);
1515 gDPSetCombineMode(gMainGfxPos++, PM_CC_02, PM_CC_02);
1516 } else {
1517 gDPSetRenderMode(gMainGfxPos++, G_RM_TEX_EDGE, G_RM_TEX_EDGE2);
1518 gDPSetCombineMode(gMainGfxPos++, G_CC_DECALRGBA, G_CC_DECALRGBA);
1519 }
1520 }
1521
1522 if (msg_drawState->effectFlags & MSG_FX_FLAG_BLUR) {
1523 for (i = 0; i < 5; i++) {
1524 phi_s0_7 = charPosX;
1525 phi_s1_8 = charPosY;
1526 if (spB8 != 2) {
1527 phi_s0_7 += (rand_int(10000) % 3) - 1;
1528 }
1529 if (spB8 != 1) {
1530 phi_s1_8 += (rand_int(10000) % 3) - 1;
1531 }
1532#if VERSION_IQUE
1533 if (byte >= MSG_CHAR_MULTIBYTE_FIRST && byte <= MSG_CHAR_MULTIBYTE_LAST) {
1534 glyph_index = (MSG_CHAR_ZH_START - MSG_CHAR_MULTIBYTE_FIRST) + byte + (byte2 - 1)
1535 * (MSG_CHAR_MULTIBYTE_LAST - MSG_CHAR_MULTIBYTE_FIRST + 1);
1536 msg_draw_char(printer, msg_drawState, glyph_index,
1537 palette, charPosX + 2, charPosY + 2);
1538 } else {
1539 msg_draw_char(printer, msg_drawState, byte,
1540 palette, charPosX + 2, charPosY + 2);
1541 }
1542#else
1543 msg_draw_char(printer, msg_drawState,
1544 msg_drawState->printBuffer[msg_drawState->drawBufferPos], palette,
1545 phi_s0_7, phi_s1_8);
1546#endif
1547 }
1548 } else {
1549#if VERSION_IQUE
1550 if (byte >= MSG_CHAR_MULTIBYTE_FIRST && byte <= MSG_CHAR_MULTIBYTE_LAST) {
1551 glyph_index = (MSG_CHAR_ZH_START - MSG_CHAR_MULTIBYTE_FIRST) + byte + (byte2 - 1)
1552 * (MSG_CHAR_MULTIBYTE_LAST - MSG_CHAR_MULTIBYTE_FIRST + 1);
1553 msg_draw_char(printer, msg_drawState, glyph_index,
1554 palette, charPosX + 2, charPosY + 2);
1555 } else {
1556 msg_draw_char(printer, msg_drawState, byte,
1557 palette, charPosX + 2, charPosY + 2);
1558 }
1559#else
1560 msg_draw_char(printer, msg_drawState,
1561 msg_drawState->printBuffer[msg_drawState->drawBufferPos], palette, charPosX,
1562 charPosY);
1563#endif
1564 }
1565 }
1566 }
1567 if (msg_drawState->printModeFlags & MSG_PRINT_FLAG_2) {
1568 msg_drawState->printModeFlags &= ~MSG_PRINT_FLAG_2;
1569 }
1570 msg_drawState->visiblePrintedCount += 1;
1571 msg_drawState->nextPos[0] +=
1572#if VERSION_IQUE
1573 msg_drawState->msgScale.x * 14.0f;
1574#else
1575 msg_get_draw_char_width(msg_drawState->printBuffer[msg_drawState->drawBufferPos],
1576 msg_drawState->font, msg_drawState->fontVariant, msg_drawState->msgScale.x,
1577 msg_drawState->curPosX, msg_drawState->printModeFlags);
1578#endif
1579 msg_drawState->drawBufferPos++;
1580 break;
1581 }
1582 }
1583
1584 varImgHasBorder = FALSE;
1585 if (printer->varImageScreenPos.x != 0) {
1586 s16 varImgFinalAlpha;
1587
1588 varImgFinalAlpha = printer->varImgFinalAlpha;
1589 msgVarImage = &(*gMsgVarImages)[printer->curImageIndex];
1590
1591 switch (printer->varImgHasBorder) {
1592 case 0:
1593 case 1:
1594 if (printer->varImgHasBorder) {
1595 varImgHasBorder = TRUE;
1596 }
1597 switch (printer->varImageDisplayState) {
1598 case 0:
1599 printer->varImageFadeTimer++;
1600 varImgFinalAlpha = printer->varImageFadeTimer * printer->varImgAlphaFadeStep;
1601 if (printer->varImgFinalAlpha <= varImgFinalAlpha) {
1602 varImgFinalAlpha = printer->varImgFinalAlpha;
1603 printer->varImageFadeTimer = 0;
1604 printer->varImageDisplayState = 1;
1605 }
1606 break;
1607 case 1:
1608 varImgFinalAlpha = (u8)(((f32) spAE / 255.0) * (f32) printer->varImgFinalAlpha);
1609 break;
1610 case 2:
1611 printer->varImageFadeTimer++;
1612 varImgFinalAlpha = printer->varImgFinalAlpha - printer->varImgAlphaFadeStep * printer->varImageFadeTimer;
1613 if (varImgFinalAlpha < 1) {
1614 printer->varImageScreenPos.x = 0;
1615 }
1616 break;
1617 }
1618 break;
1619 case 2:
1620 varImgFinalAlpha = (u8)(((f32) spAE / 255.0) * (f32) printer->varImgFinalAlpha);
1621 break;
1622 }
1623
1624 if (varImgFinalAlpha > 0) {
1625 if (varImgHasBorder) {
1626 draw_box(0, WINDOW_STYLE_15, printer->varImageScreenPos.x - 7, printer->varImageScreenPos.y - 7, 0,
1627 msgVarImage->width + 15, msgVarImage->height + 14, varImgFinalAlpha, 0, 0.0f, 0.0f, 0.0f, 0.0f,
1628 0.0f, NULL, 0, NULL, SCREEN_WIDTH, SCREEN_HEIGHT, NULL);
1629 }
1630 draw_ci_image_with_clipping(msgVarImage->raster, msgVarImage->width, msgVarImage->height,
1631 msgVarImage->format, msgVarImage->bitDepth, msgVarImage->palette,
1632 printer->varImageScreenPos.x, printer->varImageScreenPos.y, 0, 0,
1633 SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1, varImgFinalAlpha);
1634 }
1635
1636 }
1637 gDPPipeSync(gMainGfxPos++);
1639}
1640#endif
1641
1643 gDPPipeSync(gMainGfxPos++);
1644 gSPDisplayList(gMainGfxPos++, D_8014C500);
1645}
1646
1647void msg_draw_char(MessagePrintState* printer, MessageDrawState* drawState, s32 charIndex, s32 palette, s32 posX, s32 posY) {
1648 MessageCharset* messageCharset;
1649 s32 fontVariant;
1650
1651 s32 clipUly;
1652 s32 clipLry;
1653 s32 clipUlx;
1654 s32 clipLrx;
1655
1656 s32 rightPosX;
1657 s32 rightPosY;
1658
1659 f32 clipOffset;
1660 s32 ulx, texOffsetX;
1661 s32 uly, texOffsetY;
1662 s32 lrx, lry;
1663 s32 dsdx, dtdy;
1664 s32 posX2, posY2;
1665
1666#if VERSION_IQUE
1667 if (charIndex == MSG_CHAR_ZH_RANK) {
1668 load_font_data(((u8 (*)[128])charset_standard_OFFSET)[charIndex], sizeof(D_801544A0[0]), D_801544A0[0]);
1669 } else if (charIndex == MSG_CHAR_ZH_CHAPTER) {
1670 load_font_data(((u8 (*)[128])charset_standard_OFFSET)[charIndex], sizeof(D_801544A0[0]), D_801544A0[1]);
1671 } else if (charIndex >= MSG_CHAR_ZH_START) {
1672 load_font_data(((u8 (*)[128])charset_standard_OFFSET)[charIndex], sizeof(D_801544A0[0]), D_801544A0[D_8014AD24]);
1673 }
1674#endif
1675
1676 messageCharset = MsgCharsets[drawState->font];
1677 fontVariant = drawState->fontVariant;
1678
1679 clipUly = drawState->clipY[0];
1680 clipLry = drawState->clipY[1];
1681 clipUlx = drawState->clipX[0];
1682 clipLrx = drawState->clipX[1];
1683
1684 posX2 = posX;
1685 posY2 = posY;
1686
1687 rightPosX = posX2 + (s32)(drawState->charScale.x * messageCharset->texSize.x);
1688 rightPosY = posY2 + (s32)(drawState->charScale.y * messageCharset->texSize.y);
1689
1690 if (posX2 >= clipLrx || posY2 >= clipLry || rightPosX <= clipUlx || rightPosY <= clipUly) {
1691 return;
1692 }
1693
1694 if (posX2 < clipUlx) {
1695 clipOffset = abs(posX2 - clipUlx) / drawState->charScale.x;
1696 texOffsetX = (f32)((clipOffset + 0.5) * 32.0);
1697 ulx = clipUlx;
1698 } else {
1699 texOffsetX = 0;
1700 ulx = posX2;
1701 }
1702
1703 if (posY2 < clipUly) {
1704 if (!(printer->stateFlags & MSG_STATE_FLAG_400) || posY2 < 0) {
1705 clipOffset = abs(posY2 - clipUly) / drawState->charScale.y;
1706 texOffsetY = clipOffset * 32.0f;
1707 uly = clipUly;
1708 } else {
1709 texOffsetY = 0;
1710 uly = posY2;
1711 }
1712 } else {
1713 texOffsetY = 0;
1714 uly = posY2;
1715 }
1716
1717 lrx = rightPosX;
1718 if (lrx >= clipLrx) {
1719 lrx = clipLrx;
1720 }
1721
1722 lry = rightPosY;
1723 if (lry >= clipLry) {
1724 lry = clipLry;
1725 }
1726
1727 dsdx = 1.0f / drawState->charScale.x * 1024.0f;
1728 dtdy = 1.0f / drawState->charScale.y * 1024.0f;
1729
1730 if (drawState->printModeFlags & (MSG_PRINT_FLAG_10 | MSG_PRINT_FLAG_1)) {
1732 gDPLoadTLUT_pal16(gMainGfxPos++, 0, D_802F4560[palette]);
1733 }
1734
1735 if (messageCharset->texSize.x >= 16 && messageCharset->texSize.x % 16 == 0) {
1736#if VERSION_IQUE
1737 if (charIndex == MSG_CHAR_ZH_RANK || charIndex == MSG_CHAR_ZH_CHAPTER) {
1738 gDPLoadTextureBlock_4b(gMainGfxPos++, D_801544A0[charIndex - MSG_CHAR_ZH_RANK], G_IM_FMT_CI,
1739 messageCharset->texSize.x, messageCharset->texSize.y, 0,
1740 G_TX_WRAP, G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
1741 } else if (charIndex >= MSG_CHAR_ZH_START) {
1742 gDPLoadTextureBlock_4b(gMainGfxPos++, D_801544A0[D_8014AD24], G_IM_FMT_CI,
1743 messageCharset->texSize.x, messageCharset->texSize.y, 0,
1744 G_TX_WRAP, G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
1745 } else {
1746#endif
1747 gDPLoadTextureBlock_4b(gMainGfxPos++, messageCharset->rasters[fontVariant].raster + messageCharset->charRasterSize * charIndex, G_IM_FMT_CI,
1748 messageCharset->texSize.x, messageCharset->texSize.y, 0,
1749 G_TX_WRAP, G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
1750#if VERSION_IQUE
1751 }
1752#endif
1753 } else {
1754#if VERSION_IQUE
1755 if (charIndex == MSG_CHAR_ZH_RANK || charIndex == MSG_CHAR_ZH_CHAPTER) {
1756 gDPLoadTextureTile_4b(gMainGfxPos++, D_801544A0[charIndex - MSG_CHAR_ZH_RANK], G_IM_FMT_CI,
1757 messageCharset->texSize.x, messageCharset->texSize.y,
1758 0, 0, messageCharset->texSize.x - 1, messageCharset->texSize.y - 1, 0,
1759 G_TX_WRAP, G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
1760 } else if (charIndex >= MSG_CHAR_ZH_START) {
1761 gDPLoadTextureTile_4b(gMainGfxPos++, D_801544A0[D_8014AD24], G_IM_FMT_CI,
1762 messageCharset->texSize.x, messageCharset->texSize.y,
1763 0, 0, messageCharset->texSize.x - 1, messageCharset->texSize.y - 1, 0,
1764 G_TX_WRAP, G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
1765 } else {
1766#endif
1767 gDPLoadTextureTile_4b(gMainGfxPos++, messageCharset->rasters[fontVariant].raster + messageCharset->charRasterSize * charIndex, G_IM_FMT_CI,
1768 messageCharset->texSize.x, messageCharset->texSize.y,
1769 0, 0, messageCharset->texSize.x - 1, messageCharset->texSize.y - 1, 0,
1770 G_TX_WRAP, G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
1771#if VERSION_IQUE
1772 }
1773#endif
1774 }
1775 gSPTextureRectangle(gMainGfxPos++, ulx * 4, uly * 4, lrx * 4, lry * 4, G_TX_RENDERTILE, texOffsetX, texOffsetY,
1776 dsdx, dtdy);
1777
1778#if VERSION_IQUE
1779 if (charIndex >= MSG_CHAR_ZH_START) {
1780 D_8014AD24 = (D_8014AD24 + 1) % 120;
1781 if (D_8014AD24 == 0) {
1782 D_8014AD24 = 2;
1783 }
1784 }
1785#endif
1786}
1787
1788void msg_draw_prim_rect(u8 r, u8 g, u8 b, u8 a, u16 posX, u16 posY, u16 sizeX, u16 sizeY) {
1789 u16 lrX = posX + sizeX;
1790 u16 lrY = posY + sizeY;
1791
1792 appendGfx_msg_prim_rect(r, g, b, a, posX, posY, lrX, lrY);
1793}
1794
1795void appendGfx_msg_prim_rect(u8 r, u8 g, u8 b, u8 a, u16 ulX, u16 ulY, u16 lrX, u16 lrY) {
1796 gDPPipeSync(gMainGfxPos++);
1797
1798 if (a == 255) {
1800 } else {
1801 gDPSetRenderMode(gMainGfxPos++, G_RM_XLU_SURF, G_RM_XLU_SURF2);
1802 gDPSetCombineMode(gMainGfxPos++, G_CC_PRIMITIVE, G_CC_PRIMITIVE);
1803 }
1804
1805 gDPSetPrimColor(gMainGfxPos++, 0, 0, r, g, b, a);
1806 gDPFillRectangle(gMainGfxPos++, ulX, ulY, lrX, lrY);
1807 gDPPipeSync(gMainGfxPos++);
1808 gDPSetRenderMode(gMainGfxPos++, G_RM_TEX_EDGE, G_RM_TEX_EDGE2);
1809
1810 switch (msg_drawState->unk_29) {
1811 case 0:
1812 gDPSetCombineMode(gMainGfxPos++, G_CC_DECALRGBA, G_CC_DECALRGBA);
1813 break;
1814 case 1:
1815 gDPSetCombineMode(gMainGfxPos++, G_CC_MODULATEIDECALA_PRIM, G_CC_MODULATEIDECALA_PRIM);
1816 break;
1817 default:
1818 gDPSetCombineMode(gMainGfxPos++, G_CC_DECALRGBA, G_CC_DECALRGBA);
1819 break;
1820 }
1821}
1822
1824 MessagePrintState* printer,
1825 s16 posX, s16 posY, s16 straightWidth, s16 curveWidth, s16 height, f32 scaleX, f32 scaleY, u8 opacity, s32 arg9)
1826{
1827 Matrix4f sp20, sp60;
1828 s16 temp_v0;
1829 s16 temp_v0_2;
1830 s32 negHeight;
1831
1832 if (opacity == 255 && scaleX == 1.0 && scaleY == 1.0) {
1833 msg_draw_prim_rect(32, 128, 240, 0, posX - 1, posY + 1, curveWidth + (straightWidth + curveWidth) + 2, height - 2);
1834 }
1835
1836 negHeight = -height;
1837
1838 gMsgSpeechBoxLQuad[0].v.ob[0] = 1;
1839 gMsgSpeechBoxLQuad[2].v.ob[0] = 1;
1840 gMsgSpeechBoxLQuad[1].v.ob[0] = curveWidth;
1841 gMsgSpeechBoxLQuad[3].v.ob[0] = curveWidth;
1842 gMsgSpeechBoxLQuad[2].v.ob[1] = negHeight;
1843 gMsgSpeechBoxLQuad[3].v.ob[1] = negHeight;
1844
1845 temp_v0 = curveWidth + straightWidth;
1846
1847 gMsgSpeechBoxMQuad[0].v.ob[0] = curveWidth;
1848 gMsgSpeechBoxMQuad[2].v.ob[0] = curveWidth;
1849 gMsgSpeechBoxMQuad[1].v.ob[0] = temp_v0;
1850 gMsgSpeechBoxMQuad[3].v.ob[0] = temp_v0;
1851 gMsgSpeechBoxMQuad[2].v.ob[1] = negHeight;
1852 gMsgSpeechBoxMQuad[3].v.ob[1] = negHeight;
1853
1854 temp_v0_2 = curveWidth + temp_v0;
1855
1856 gMsgSpeechBoxRQuad[0].v.ob[0] = temp_v0;
1857 gMsgSpeechBoxRQuad[2].v.ob[0] = temp_v0;
1858 gMsgSpeechBoxRQuad[1].v.ob[0] = temp_v0_2;
1859 gMsgSpeechBoxRQuad[3].v.ob[0] = temp_v0_2;
1860 gMsgSpeechBoxRQuad[2].v.ob[1] = negHeight;
1861 gMsgSpeechBoxRQuad[3].v.ob[1] = negHeight;
1862
1863 guTranslateF(sp20, posX, -posY, 0.0f);
1864
1865 if (scaleX != 1.0 || scaleY != 1.0) {
1866 guScaleF(sp60, scaleX, scaleY, 1.0f);
1867 guMtxCatF(sp60, sp20, sp20);
1868 }
1869
1871
1873 G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
1874
1875 gDPPipeSync(gMainGfxPos++);
1876 gDPSetCycleType(gMainGfxPos++, G_CYC_1CYCLE);
1877 gSPClearGeometryMode(gMainGfxPos++, G_CULL_BOTH | G_LIGHTING);
1878 gSPSetGeometryMode(gMainGfxPos++, G_SHADE | G_SHADING_SMOOTH);
1879 gDPSetColorDither(gMainGfxPos++, G_CD_DISABLE);
1880 gSPTexture(gMainGfxPos++, -1, -1, 0, G_TX_RENDERTILE, G_ON);
1881 gDPSetTexturePersp(gMainGfxPos++, G_TP_PERSP);
1882
1883 if (printer->maxLinesPerPage == 3) {
1884 gDPSetTextureFilter(gMainGfxPos++, G_TF_POINT);
1885 } else {
1886 gDPSetTextureFilter(gMainGfxPos++, G_TF_BILERP);
1887 }
1888
1889 if (opacity >= 255) {
1890 gDPSetRenderMode(gMainGfxPos++, AA_EN | CVG_DST_FULL | ZMODE_OPA | CVG_X_ALPHA |
1891 GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM),
1892 AA_EN | CVG_DST_FULL | ZMODE_OPA | CVG_X_ALPHA |
1893 GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM));
1894 gDPSetCombineMode(gMainGfxPos++, G_CC_DECALRGBA, G_CC_DECALRGBA);
1895 } else {
1896 gDPSetRenderMode(gMainGfxPos++, IM_RD | CVG_DST_SAVE | ZMODE_XLU | FORCE_BL |
1897 GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA),
1898 IM_RD | CVG_DST_SAVE | ZMODE_XLU | FORCE_BL |
1899 GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA));
1900 gDPSetCombineMode(gMainGfxPos++, PM_CC_02, PM_CC_02);
1901 gDPSetPrimColor(gMainGfxPos++, 0, 0, 32, 32, 32, opacity);
1902 }
1903
1904 gDPSetTextureLUT(gMainGfxPos++, G_TT_RGBA16);
1905 gDPSetTextureImage(gMainGfxPos++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1,
1906 ui_msg_palettes[msg_drawState->framePalette]);
1907 gDPTileSync(gMainGfxPos++);
1908 gDPSetTile(gMainGfxPos++, G_IM_FMT_RGBA, G_IM_SIZ_4b, 0, 0x0100, G_TX_LOADTILE, 0,
1909 G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD);
1910 gDPLoadSync(gMainGfxPos++);
1911 gDPLoadTLUTCmd(gMainGfxPos++, G_TX_LOADTILE, 15);
1912 gDPPipeSync(gMainGfxPos++);
1913 gDPLoadTextureTile_4b(gMainGfxPos++, ui_msg_bubble_left_png, G_IM_FMT_CI, 32, 0, 0, 0, 31, 63, 0,
1914 G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, 5, 6, G_TX_NOLOD, G_TX_NOLOD);
1915 gSPVertex(gMainGfxPos++, gMsgSpeechBoxLQuad, 4, 0);
1916 gSP2Triangles(gMainGfxPos++, 0, 2, 1, 0, 1, 2, 3, 0);
1917 gDPLoadTextureTile_4b(gMainGfxPos++, ui_msg_bubble_mid_png, G_IM_FMT_CI, 8, 0, 0, 0, 7, 63, 0,
1918 G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 3, 6, G_TX_NOLOD, G_TX_NOLOD);
1919 gSPVertex(gMainGfxPos++, gMsgSpeechBoxMQuad, 4, 0);
1920 gSP2Triangles(gMainGfxPos++, 0, 2, 1, 0, 1, 2, 3, 0);
1921 gDPLoadTextureTile_4b(gMainGfxPos++, ui_msg_bubble_right_png, G_IM_FMT_CI, 32, 0, 0, 0, 31, 63, 0,
1922 G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, 5, 6, G_TX_NOLOD, G_TX_NOLOD);
1923 gSPVertex(gMainGfxPos++, gMsgSpeechBoxRQuad, 4, 0);
1924 gSP2Triangles(gMainGfxPos++, 0, 2, 1, 0, 1, 2, 3, 0);
1925 gDPPipeSync(gMainGfxPos++);
1926}
1927
1929 s16 targetX, targetY;
1930 f32 windowXpart;
1931 s32 arrowLength;
1932 Vtx* quad;
1933 s32 angle;
1934 f32 cosAngle, sinAngle;
1935 Matrix4f sp10;
1936 s16 x1, x2, x3, x4;
1937 s32 y1, y2;
1938 u8 pointRightSide = FALSE;
1939 s16 windowX = printer->windowOffsetPos.x + printer->windowBasePos.x;
1940 s16 windowY = printer->windowOffsetPos.y + printer->windowBasePos.y;
1941
1942 if (printer->openStartPos.x == 0) {
1943 return;
1944 }
1945
1946 if (printer->style == MSG_STYLE_RIGHT ||
1947 printer->style == MSG_STYLE_LEFT ||
1948 printer->style == MSG_STYLE_CENTER ||
1949 printer->maxLinesPerPage == 3) {
1950 targetY = windowY + printer->windowSize.y - 4;
1951 } else {
1952 targetY = windowY + printer->windowSize.y - 3;
1953 }
1954
1955 if (printer->style == MSG_STYLE_LEFT) {
1956 pointRightSide = FALSE;
1957 } else if (printer->style == MSG_STYLE_CENTER || printer->openStartPos.x >= 160) {
1958 pointRightSide = TRUE;
1959 }
1960
1961 if (pointRightSide) {
1962 targetX = windowX + (f32)printer->windowSize.x * 0.7;
1963 if (printer->openStartPos.x < targetX) {
1964 for (windowXpart = 0.7f; windowXpart >= 0.67; windowXpart -= 0.005) {
1965 targetX = windowX + printer->windowSize.x * windowXpart;
1966 angle = atan2(printer->openStartPos.x, printer->openStartPos.y, targetX, targetY);
1967 if (abs(angle) < 45) {
1968 break;
1969 }
1970 }
1971 }
1972 } else {
1973 targetX = windowX + (f32)printer->windowSize.x * 0.3;
1974 if (printer->openStartPos.x > targetX) {
1975 for (windowXpart = 0.3f; windowXpart <= 0.38; windowXpart += 0.005) {
1976 targetX = windowX + printer->windowSize.x * windowXpart;
1977 angle = atan2(printer->openStartPos.x, printer->openStartPos.y, targetX, targetY);
1978 if (abs(angle) < 45) {
1979 break;
1980 }
1981 }
1982 }
1983 }
1984
1985 x1 = targetX - 9;
1986 x2 = targetX + 9;
1987 x3 = targetX;
1988
1989 arrowLength = dist2D(printer->initOpenPos.x, printer->initOpenPos.y, targetX, targetY);
1990 if (arrowLength < 10) {
1991 return;
1992 }
1993
1994 if (arrowLength > 25) {
1995 arrowLength = 25;
1996 }
1997
1998 // alternate quads between frames
1999 if (gCurrentDisplayContextIndex != 0) {
2000 quad = gMsgArrowQuad1;
2001 } else {
2002 quad = gMsgArrowQuad2;
2003 }
2004
2005 angle = atan2(targetX, targetY, printer->initOpenPos.x, printer->initOpenPos.y);
2006 angle -= 180;
2007 if (abs(angle) >= 75) {
2008 return;
2009 }
2010
2011 cosAngle = cosine(angle);
2012 sinAngle = cosine(angle + 90);
2013
2014 x3 = x3 - arrowLength * cosAngle;
2015 x4 = x3 + 1;
2016
2017 y1 = -targetY;
2018 y2 = -(s16)(targetY + arrowLength * sinAngle);
2019
2020 quad[0].v.ob[0] = x1;
2021 quad[0].v.ob[1] = y1;
2022 quad[1].v.ob[0] = x2;
2023 quad[1].v.ob[1] = y1;
2024
2025 quad[2].v.ob[0] = x3;
2026 quad[2].v.ob[1] = y2;
2027 quad[3].v.ob[0] = x4;
2028 quad[3].v.ob[1] = y2;
2029
2030 gDPPipeSync(gMainGfxPos++);
2031 gDPSetRenderMode(gMainGfxPos++, G_RM_OPA_SURF, G_RM_OPA_SURF2);
2032 gDPSetCombineMode(gMainGfxPos++, PM_CC_0F, PM_CC_0F);
2033 gDPSetTextureFilter(gMainGfxPos++, G_TF_BILERP);
2034 gDPSetPrimColor(gMainGfxPos++, 0, 0, 32, 32, 32, 255);
2035 gDPLoadTextureTile_4b(gMainGfxPos++, ui_msg_arrow_png, G_IM_FMT_CI, 16, 0, 0, 0, 15, 15, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, 4, G_TX_NOLOD, G_TX_NOLOD);
2036 guTranslateF(sp10, 0.0f, 0.0f, 0.0f);
2038 gSPMatrix(gMainGfxPos++, VIRTUAL_TO_PHYSICAL(&gDisplayContext->matrixStack[gMatrixListPos++]), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
2039 gSPVertex(gMainGfxPos++, quad, 4, 0);
2040 gSP2Triangles(gMainGfxPos++, 0, 2, 1, 0, 1, 2, 3, 0);
2041}
2042
2043void msg_draw_frame(s32 posX, s32 posY, s32 sizeX, s32 sizeY, s32 style, s32 palette, s32 fading, s32 bgAlpha, s32 frameAlpha) {
2044 s32 i;
2045 s32 frameType;
2046 s32 textures[16];
2047 u8 r, g, b;
2048 Rect quads[16];
2049
2050 if (sizeX < 16 || sizeY < 16) {
2051 return;
2052 }
2053
2054 if (fading != 0 && bgAlpha == 0 && frameAlpha == 0) {
2055 return;
2056 }
2057
2058 gDPPipeSync(gMainGfxPos++);
2059 gDPSetCycleType(gMainGfxPos++, G_CYC_1CYCLE);
2060 gDPSetTexturePersp(gMainGfxPos++, G_TP_NONE);
2061 gDPSetTextureLOD(gMainGfxPos++, G_TL_TILE);
2062 gDPSetTextureLUT(gMainGfxPos++, G_TT_NONE);
2063 gDPSetColorDither(gMainGfxPos++, G_CD_DISABLE);
2064 gDPSetAlphaDither(gMainGfxPos++, G_AD_DISABLE);
2065 gDPSetTextureFilter(gMainGfxPos++, G_TF_POINT);
2066
2067 if (fading == 0 || bgAlpha != 0) {
2068 switch (style) {
2069 case MSG_STYLE_CHOICE:
2070 r = UNPACK_PAL_R(((u16*)ui_msg_palettes)[4]);
2071 g = UNPACK_PAL_G(((u16*)ui_msg_palettes)[4]);
2072 b = UNPACK_PAL_B(((u16*)ui_msg_palettes)[4]);
2073 // BUGFIX: properly remap colors to full range [0, 255]
2074 r = my_ceil(255 * r / 31.0);
2075 g = my_ceil(255 * g / 31.0);
2076 b = my_ceil(255 * b / 31.0);
2077
2078 gDPPipeSync(gMainGfxPos++);
2079 if (fading != 0 && bgAlpha < 255) {
2080 gDPSetRenderMode(gMainGfxPos++, IM_RD | CVG_DST_SAVE | ZMODE_XLU | FORCE_BL | GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA), IM_RD | CVG_DST_SAVE | ZMODE_XLU | FORCE_BL | GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA));
2081 } else {
2082 gDPSetRenderMode(gMainGfxPos++, G_RM_OPA_SURF, G_RM_OPA_SURF2);
2083 }
2084 gDPSetCombineMode(gMainGfxPos++, G_CC_PRIMITIVE, G_CC_PRIMITIVE);
2085 gDPSetPrimColor(gMainGfxPos++, 0, 0, r, g, b, bgAlpha);
2086 if (posX + sizeX - 8 > 0) {
2087 gDPScisFillRectangle(gMainGfxPos++, posX + 8, posY + 8, posX + sizeX - 8, posY + sizeY - 8);
2088 }
2089 break;
2090 case MSG_STYLE_INSPECT:
2091 gDPPipeSync(gMainGfxPos++);
2092 gDPSetTextureFilter(gMainGfxPos++, G_TF_AVERAGE);
2093 gDPSetRenderMode(gMainGfxPos++, G_RM_XLU_SURF, G_RM_XLU_SURF2);
2094 gDPSetCombineMode(gMainGfxPos++, PM_CC_10, PM_CC_10);
2095 if (fading == 0 || bgAlpha == 255) {
2096 gDPSetPrimColor(gMainGfxPos++, 0, 0, 0, 0, 0, 216);
2097 } else {
2098 if (bgAlpha > 216) {
2099 bgAlpha = 216;
2100 }
2101 gDPSetPrimColor(gMainGfxPos++, 0, 0, 0, 0, 0, bgAlpha);
2102 }
2103
2104 gDPLoadTextureBlock_4b(gMainGfxPos++, ui_msg_background_png, G_IM_FMT_I, 64, 64, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 6, 6, G_TX_NOLOD, G_TX_NOLOD);
2105 if (style == MSG_STYLE_INSPECT) {
2106 gSPScisTextureRectangle(gMainGfxPos++, (posX + 3) * 4, (posY + 3) * 4, (posX + sizeX - 3) * 4, (posY + sizeY - 3) * 4,
2107 G_TX_RENDERTILE, gMsgBGScrollAmtX, gMsgBGScrollAmtY, 0x400, 0x400);
2108 } else {
2109 gSPScisTextureRectangle(gMainGfxPos++, (posX + 5) * 4, (posY + 5) * 4, (posX + sizeX - 5) * 4, (posY + sizeY - 5) * 4,
2110 G_TX_RENDERTILE, gMsgBGScrollAmtX, gMsgBGScrollAmtY, 0x400, 0x400);
2111 }
2112 break;
2113 }
2114 }
2115
2116 if (sizeX >= 32) {
2117 quads[2].ulx = (posX + 16) * 4;
2118 quads[2].uly = posY * 4;
2119 quads[2].lrx = (posX + sizeX - 16) * 4;
2120 quads[2].lry = (posY + 8) * 4;
2121
2122 quads[13].ulx = (posX + 16) * 4;
2123 quads[13].uly = (posY + sizeY - 8) * 4;
2124 quads[13].lrx = (posX + sizeX - 16) * 4;
2125 quads[13].lry = (posY + sizeY) * 4;
2126 } else if (sizeX > 16 && sizeX < 24) {
2127 quads[2].ulx = (posX + 8) * 4;
2128 quads[2].uly = posY * 4;
2129 quads[2].lrx = (posX + sizeX - 8) * 4;
2130 quads[2].lry = (posY + 8) * 4;
2131
2132 quads[13].ulx = (posX + 8) * 4;
2133 quads[13].uly = (posY + sizeY - 8) * 4;
2134 quads[13].lrx = (posX + sizeX - 8) * 4;
2135 quads[13].lry = (posY + sizeY) * 4;
2136 } else {
2137 quads[2].ulx = 10000;
2138 quads[13].ulx = 10000;
2139 }
2140
2141 if (sizeY >= 32) {
2142 quads[7].ulx = posX * 4;
2143 quads[7].uly = (posY + 16) * 4;
2144 quads[7].lrx = (posX + 8) * 4;
2145 quads[7].lry = (posY + sizeY - 16) * 4;
2146
2147 quads[8].ulx = (posX + sizeX - 8) * 4;
2148 quads[8].uly = (posY + 16) * 4;
2149 quads[8].lrx = (posX + sizeX) * 4;
2150 quads[8].lry = (posY + sizeY - 16) * 4;
2151 } else if (sizeY > 16 && sizeY < 24) {
2152 quads[7].ulx = posX * 4;
2153 quads[7].uly = (posY + 8) * 4;
2154 quads[7].lrx = (posX + 8) * 4;
2155 quads[7].lry = (posY + sizeY - 8) * 4;
2156
2157 quads[8].ulx = (posX + sizeX - 8) * 4;
2158 quads[8].uly = (posY + 8) * 4;
2159 quads[8].lrx = (posX + sizeX) * 4;
2160 quads[8].lry = (posY + sizeY - 8) * 4;
2161 } else {
2162 quads[7].ulx = 10000;
2163 quads[8].ulx = 10000;
2164 }
2165
2166 if (sizeX >= 24) {
2167 quads[1].ulx = (posX + 8) * 4;
2168 quads[1].uly = posY * 4;
2169 quads[1].lrx = (posX + 16) * 4;
2170 quads[1].lry = (posY + 8) * 4;
2171
2172 quads[3].ulx = (posX + sizeX - 16) * 4;
2173 quads[3].uly = posY * 4;
2174 quads[3].lrx = (posX + sizeX - 8) * 4;
2175 quads[3].lry = (posY + 8) * 4;
2176
2177 quads[12].ulx = (posX + 8) * 4;
2178 quads[12].uly = (posY + sizeY - 8) * 4;
2179 quads[12].lrx = (posX + 16) * 4;
2180 quads[12].lry = (posY + sizeY) * 4;
2181
2182 quads[14].ulx = (posX + sizeX - 16) * 4;
2183 quads[14].uly = (posY + sizeY - 8) * 4;
2184 quads[14].lrx = (posX + sizeX - 8) * 4;
2185 quads[14].lry = (posY + sizeY) * 4;
2186 } else {
2187 quads[1].ulx = 10000;
2188 quads[3].ulx = 10000;
2189 quads[12].ulx = 10000;
2190 quads[14].ulx = 10000;
2191 }
2192
2193 if (sizeY >= 24) {
2194 quads[5].ulx = posX * 4;
2195 quads[5].uly = (posY + 8) * 4;
2196 quads[5].lrx = (posX + 8) * 4;
2197 quads[5].lry = (posY + 16) * 4;
2198
2199 quads[6].ulx = (posX + sizeX - 8) * 4;
2200 quads[6].uly = (posY + 8) * 4;
2201 quads[6].lrx = (posX + sizeX) * 4;
2202 quads[6].lry = (posY + 16) * 4;
2203
2204 quads[9].ulx = posX * 4;
2205 quads[9].uly = (posY + sizeY - 16) * 4;
2206 quads[9].lrx = (posX + 8) * 4;
2207 quads[9].lry = (posY + sizeY - 8) * 4;
2208
2209 quads[10].ulx = (posX + sizeX - 8) * 4;
2210 quads[10].uly = (posY + sizeY - 16) * 4;
2211 quads[10].lrx = (posX + sizeX) * 4;
2212 quads[10].lry = (posY + sizeY - 8) * 4;
2213 } else {
2214 quads[5].ulx = 10000;
2215 quads[6].ulx = 10000;
2216 quads[9].ulx = 10000;
2217 quads[10].ulx = 10000;
2218 }
2219
2220 quads[0].ulx = posX * 4;
2221 quads[0].uly = posY * 4;
2222 quads[0].lrx = (posX + 8) * 4;
2223 quads[0].lry = (posY + 8) * 4;
2224
2225 quads[4].ulx = (posX + sizeX - 8) * 4;
2226 quads[4].uly = posY * 4;
2227 quads[4].lrx = (posX + sizeX) * 4;
2228 quads[4].lry = (posY + 8) * 4;
2229
2230 quads[11].ulx = posX * 4;
2231 quads[11].uly = (posY + sizeY - 8) * 4;
2232 quads[11].lrx = (posX + 8) * 4;
2233 quads[11].lry = (posY + sizeY) * 4;
2234
2235 quads[15].ulx = (posX + sizeX - 8) * 4;
2236 quads[15].uly = (posY + sizeY - 8) * 4;
2237 quads[15].lrx = (posX + sizeX) * 4;
2238 quads[15].lry = (posY + sizeY) * 4;
2239
2240 switch (style) {
2241 case MSG_STYLE_CHOICE:
2242 frameType = 0;
2243 break;
2244 case MSG_STYLE_INSPECT:
2245 frameType = 1;
2246 break;
2247 default:
2248 frameType = 0;
2249 break;
2250 }
2251
2252 for (i = 0; i < ARRAY_COUNT(textures); i++) {
2253 textures[i] = gMessageBoxFrameParts[frameType][i];
2254 }
2255
2256 if (fading == 0) {
2257 frameAlpha = 255;
2258 }
2259
2260 gDPPipeSync(gMainGfxPos++);
2261 gDPSetRenderMode(gMainGfxPos++, G_RM_XLU_SURF, G_RM_XLU_SURF2);
2262 gDPSetCombineMode(gMainGfxPos++, PM_CC_02, PM_CC_02);
2263 gDPSetPrimColor(gMainGfxPos++, 0, 0, 0, 0, 0, frameAlpha);
2264 gDPSetTextureLUT(gMainGfxPos++, G_TT_RGBA16);
2265 gDPLoadTLUT_pal16(gMainGfxPos++, 0, ui_msg_palettes[palette]);
2266
2267 for (i = 0; i < ARRAY_COUNT(textures); i++) {
2268 if (textures[i] != NULL && quads[i].ulx < 10000) {
2269 gDPLoadTextureTile_4b(gMainGfxPos++, textures[i], G_IM_FMT_CI, 8, 8, 0, 0, 7, 7, 0, G_TX_WRAP, G_TX_WRAP, 3, 3, G_TX_NOLOD, G_TX_NOLOD);
2270 gSPScisTextureRectangle(gMainGfxPos++, quads[i].ulx, quads[i].uly, quads[i].lrx, quads[i].lry,
2271 G_TX_RENDERTILE, 0, 0, 0x400, 0x400);
2272 }
2273 }
2274
2275 gDPPipeSync(gMainGfxPos++);
2276 gDPSetTextureLUT(gMainGfxPos++, G_TT_NONE);
2277}
2278
2279void msg_get_glyph(s32 font, s32 variation, s32 charIndex, s32 palette, MesasgeFontGlyphData* out) {
2280 out->raster = &MsgCharsets[font]->rasters[variation].raster[(u16)MsgCharsets[font]->charRasterSize * charIndex];
2281 out->palette = D_802F4560[palette];
2282 out->texSize.x = MsgCharsets[font]->texSize.x;
2283 out->texSize.y = MsgCharsets[font]->texSize.y;
2284 out->charWidth = msg_get_draw_char_width(charIndex, font, variation, 1.0f, 0, 0);
2285 out->charHeight = out->texSize.y;
2286}
unsigned char charset_standard_OFFSET[]
MessageCharData * rasters
#define IMG_BIN
Mtx matrixStack[0x200]
#define PAL_PTR
#define IMG_PTR
f32 Matrix4f[4][4]
#define PAL_BIN
s8 flags
Definition demo_api.c:15
#define guMtxF2L
#define guTranslateF
#define guMtxCatF
#define rand_int
#define atan2
#define draw_box
#define guScaleF
@ WINDOW_STYLE_0
Definition enums.h:6370
@ WINDOW_STYLE_15
Definition enums.h:6385
@ MSG_FX_FLAG_RISE_PRINT
Definition enums.h:6187
@ MSG_FX_FLAG_DROP_SHADOW
Definition enums.h:6191
@ MSG_FX_FLAG_BLUR
Definition enums.h:6182
@ MSG_FX_FLAG_GLOBAL_WAVE
Definition enums.h:6185
@ MSG_FX_FLAG_WAVE
Definition enums.h:6180
@ MSG_FX_FLAG_GROW_PRINT
Definition enums.h:6188
@ MSG_FX_FLAG_GLOBAL_RAINBOW
Definition enums.h:6186
@ MSG_FX_FLAG_SHAKE
Definition enums.h:6179
@ MSG_FX_FLAG_SIZE_WAVE
Definition enums.h:6190
@ MSG_FX_FLAG_NOISE_OUTLINE
Definition enums.h:6181
@ MSG_FX_FLAG_STATIC
Definition enums.h:6192
@ MSG_FX_FLAG_RAINBOW
Definition enums.h:6183
@ MSG_FX_FLAG_SIZE_JITTER
Definition enums.h:6189
@ MSG_FX_FLAG_DITHER_FADE
Definition enums.h:6184
@ MSG_STATE_FLAG_1
Definition enums.h:6239
@ MSG_STATE_FLAG_400
Definition enums.h:6247
@ MSG_STATE_FLAG_4000
Definition enums.h:6250
@ MSG_PRINT_FUNC_RIGHT
Definition enums.h:6141
@ MSG_PRINT_FUNC_UP
Definition enums.h:6143
@ MSG_PRINT_FUNC_COLOR
Definition enums.h:6134
@ MSG_PRINT_FUNC_OPTION
Definition enums.h:6151
@ MSG_PRINT_FUNC_FONT
Definition enums.h:6130
@ MSG_PRINT_FUNC_ITEM_ICON
Definition enums.h:6146
@ MSG_PRINT_FUNC_SPACING
Definition enums.h:6135
@ MSG_PRINT_FUNC_ANIM_DELAY
Definition enums.h:6147
@ MSG_PRINT_FUNC_SET_Y
Definition enums.h:6140
@ MSG_PRINT_FUNC_ANIM_LOOP
Definition enums.h:6148
@ MSG_PRINT_FUNC_ANIM_SPRITE
Definition enums.h:6145
@ MSG_PRINT_FUNC_INLINE_IMAGE
Definition enums.h:6144
@ MSG_PRINT_FUNC_SET_X
Definition enums.h:6139
@ MSG_PRINT_FUNC_SIZE_RESET
Definition enums.h:6138
@ MSG_PRINT_FUNC_DOWN
Definition enums.h:6142
@ MSG_PRINT_FUNC_SAVE_COLOR
Definition enums.h:6154
@ MSG_PRINT_FUNC_VARIANT
Definition enums.h:6131
@ MSG_PRINT_FUNC_RESTORE_COLOR
Definition enums.h:6155
@ MSG_PRINT_FUNC_SET_FRAME_PALETTE
Definition enums.h:6132
@ MSG_PRINT_FUNC_END_FX
Definition enums.h:6157
@ MSG_PRINT_FUNC_START_FX
Definition enums.h:6156
@ MSG_PRINT_FUNC_RESTORE_POS
Definition enums.h:6153
@ MSG_PRINT_FUNC_CURSOR
Definition enums.h:6150
@ MSG_PRINT_FUNC_SIZE
Definition enums.h:6137
@ MSG_PRINT_FUNC_ANIM_DONE
Definition enums.h:6149
@ MSG_PRINT_FUNC_CENTER_X
Definition enums.h:6158
@ MSG_PRINT_FUNC_SAVE_POS
Definition enums.h:6152
@ MSG_PRINT_RESET_GFX
Definition enums.h:6133
@ DRAW_FLAG_ROTSCALE
Definition enums.h:5003
@ MSG_PAL_14
Definition enums.h:5425
@ MSG_PAL_13
Definition enums.h:5424
@ MSG_PAL_22
Definition enums.h:5439
@ MSG_PAL_43
Definition enums.h:5472
@ MSG_PAL_42
Definition enums.h:5471
@ MSG_PAL_WHITE
Definition enums.h:5405
@ MSG_PAL_20
Definition enums.h:5437
@ MSG_PAL_23
Definition enums.h:5440
@ MSG_PAL_1C
Definition enums.h:5433
@ MSG_PAL_STANDARD
Definition enums.h:5415
@ MSG_PAL_10
Definition enums.h:5421
@ MSG_PAL_12
Definition enums.h:5423
@ MSG_PAL_25
Definition enums.h:5442
@ MSG_PAL_44
Definition enums.h:5473
@ MSG_PAL_40
Definition enums.h:5469
@ MSG_PAL_RED
Definition enums.h:5412
@ MSG_PAL_41
Definition enums.h:5470
@ MSG_PAL_18
Definition enums.h:5429
@ MSG_PAL_11
Definition enums.h:5422
@ EASING_SIN_OUT
Definition enums.h:521
@ EASING_LINEAR
Definition enums.h:510
@ MSG_STYLE_POSTCARD
Definition enums.h:6205
@ MSG_STYLE_CENTER
Definition enums.h:6199
@ MSG_STYLE_LEFT
Definition enums.h:6198
@ MSG_STYLE_UPGRADE
Definition enums.h:6208
@ MSG_STYLE_SIGN
Definition enums.h:6203
@ MSG_STYLE_F
Definition enums.h:6211
@ MSG_STYLE_B
Definition enums.h:6207
@ MSG_STYLE_NARRATE
Definition enums.h:6209
@ MSG_STYLE_INSPECT
Definition enums.h:6202
@ MSG_STYLE_LAMPPOST
Definition enums.h:6204
@ MSG_STYLE_POPUP
Definition enums.h:6206
@ MSG_STYLE_RIGHT
Definition enums.h:6197
@ MSG_STYLE_EPILOGUE
Definition enums.h:6210
@ MSG_STYLE_TATTLE
Definition enums.h:6200
@ MSG_STYLE_CHOICE
Definition enums.h:6201
@ MSG_PRINT_FLAG_2
Definition enums.h:6230
@ MSG_PRINT_FLAG_40
Definition enums.h:6233
@ MSG_PRINT_FLAG_100
Definition enums.h:6235
@ MSG_PRINT_FLAG_1
Definition enums.h:6229
@ MSG_PRINT_FLAG_20
Definition enums.h:6232
@ MSG_PRINT_FLAG_10
Definition enums.h:6231
@ MSG_PRINT_FLAG_80
Definition enums.h:6234
@ MSG_FX_NOISE_OUTLINE
Definition enums.h:6164
@ MSG_FX_RISE_PRINT
Definition enums.h:6171
@ MSG_FX_SIZE_JITTER
Definition enums.h:6173
@ MSG_FX_SHAKE
Definition enums.h:6162
@ MSG_FX_GLOBAL_WAVE
Definition enums.h:6169
@ MSG_FX_GLOBAL_RAINBOW
Definition enums.h:6170
@ MSG_FX_DROP_SHADOW
Definition enums.h:6175
@ MSG_FX_SIZE_WAVE
Definition enums.h:6174
@ MSG_FX_STATIC
Definition enums.h:6165
@ MSG_FX_BLUR
Definition enums.h:6166
@ MSG_FX_DITHER_FADE
Definition enums.h:6168
@ MSG_FX_WAVE
Definition enums.h:6163
@ MSG_FX_RAINBOW
Definition enums.h:6167
@ MSG_FX_GROW_PRINT
Definition enums.h:6172
@ MSG_CHAR_PRINT_SPACE
Definition enums.h:6067
@ MSG_CHAR_PRINT_VARIANT2
Definition enums.h:6065
@ MSG_CHAR_PRINT_VARIANT1
Definition enums.h:6064
@ MSG_CHAR_PRINT_NEXT
Definition enums.h:6072
@ MSG_CHAR_PRINT_END
Definition enums.h:6073
@ MSG_CHAR_PRINT_ENDL
Definition enums.h:6062
@ MSG_CHAR_PRINT_FULL_SPACE
Definition enums.h:6068
@ MSG_CHAR_PRINT_VARIANT0
Definition enums.h:6063
@ MSG_CHAR_PRINT_FUNCTION
Definition enums.h:6077
@ MSG_CHAR_PRINT_STYLE
Definition enums.h:6070
@ MSG_CHAR_PRINT_VARIANT3
Definition enums.h:6066
@ MSG_CHAR_PRINT_UNK_CHAR_FA
Definition enums.h:6071
@ MSG_CHAR_PRINT_HALF_SPACE
Definition enums.h:6069
@ MSG_WINDOW_STATE_B
Definition enums.h:6278
@ MSG_WINDOW_STATE_WAITING_FOR_CHOICE
Definition enums.h:6274
@ MSG_WINDOW_STATE_OPENING
Definition enums.h:6269
@ MSG_WINDOW_STATE_PRINTING
Definition enums.h:6271
@ MSG_WINDOW_STATE_C
Definition enums.h:6279
@ MSG_WINDOW_STATE_E
Definition enums.h:6281
@ MSG_WINDOW_STATE_D
Definition enums.h:6280
@ MSG_WINDOW_STATE_CLOSING
Definition enums.h:6270
f32 update_lerp(s32 easing, f32 start, f32 end, s32 elapsed, s32 duration)
Definition 43F0.c:735
s32 draw_ci_image_with_clipping(u8 *raster, s32 width, s32 height, s32 fmt, s32 bitDepth, u16 *palette, s16 posX, s16 posY, u16 clipULx, u16 clipULy, u16 clipLRx, u16 clipRLy, u8 opacity)
f32 cosine(s16 arg0)
Definition 43F0.c:354
f32 dist2D(f32 ax, f32 ay, f32 bx, f32 by)
Definition 43F0.c:670
void load_font_data(Addr offset, u16 size, void *dest)
Definition msg.c:218
#define INCLUDE_ASM(TYPE, FOLDER, NAME, ARGS...)
Definition include_asm.h:21
IMG_BIN ui_msg_bubble_mid_png[]
void drawbox_message_delegate(s32 data, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening)
Definition msg_draw.c:131
#define MSG_SIGN_OFFSET_X
Definition msg_draw.c:205
Vtx gMsgSpeechBoxRQuad[]
Definition msg_draw.c:73
void msg_draw_speech_bubble(MessagePrintState *printer, s16 posX, s16 posY, s16 straightWidth, s16 curveWidth, s16 height, f32 scaleX, f32 scaleY, u8 opacity, s32 arg9)
Definition msg_draw.c:1823
u8 D_8014C588[]
Definition msg_draw.c:114
#define MSG_SIGN_WIDTH
Definition msg_draw.c:204
PAL_BIN D_8015C7E0[0x10]
Definition msg.c:105
Vtx gMsgArrowQuad1[]
Definition msg_draw.c:80
s32 gMessageBoxFrameParts[2][16]
Definition 5B320.c:492
IMG_BIN ui_msg_lamppost_corner_bottomright_png[]
IMG_BIN D_80159B50[0x200]
Definition msg.c:104
IMG_BIN ui_msg_sign_side_top_png[]
s16 MsgStyleVerticalLineOffsets[]
Definition msg_data.c:927
PAL_BIN ui_msg_lamppost_pal[]
void appendGfx_message(MessagePrintState *, s16, s16, u16, u16, u16, u8)
Definition msg_draw.c:213
void msg_draw_char(MessagePrintState *printer, MessageDrawState *drawState, s32 charIndex, s32 palette, s32 posX, s32 posY)
Definition msg_draw.c:1647
IMG_BIN ui_msg_sign_corner_topright_png[]
Gfx * D_80151338
Definition msg.c:93
#define MSG_POPUP_TEXT_Y
Definition msg_draw.c:206
#define MSG_NORMAL_WIN_WIDTH
Definition msg_draw.c:195
MessageImageData * MessageImageDataList[1]
Definition msg_draw.c:34
void msg_draw_frame(s32 posX, s32 posY, s32 sizeX, s32 sizeY, s32 style, s32 palette, s32 fading, s32 bgAlpha, s32 frameAlpha)
Definition msg_draw.c:2043
#define MSG_SIGN_TEXT_Y
Definition msg_draw.c:203
#define MSG_EPILOGUE_TEXT_Y
Definition msg_draw.c:207
#define MSG_NORMAL_X
Definition msg_draw.c:194
IMG_BIN ui_msg_bubble_right_png[]
IMG_BIN ui_msg_sign_fill_png[]
IMG_BIN ui_msg_background_png[]
void appendGfx_msg_prim_rect(u8 r, u8 g, u8 b, u8 a, u16 ulX, u16 ulY, u16 lrX, u16 lrY)
Definition msg_draw.c:1795
Vtx gMsgSpeechBoxMQuad[]
Definition msg_draw.c:66
#define MSG_NORMAL_WIDTH
Definition msg_draw.c:193
u16 gMsgGlobalWaveCounter
Definition msg.c:89
void msg_draw_prim_rect(u8 r, u8 g, u8 b, u8 a, u16 posX, u16 posY, u16 sizeX, u16 sizeY)
Definition msg_draw.c:1788
s32 msg_get_draw_char_width(s32 character, s32 charset, s32 variation, f32 msgScale, s32 overrideCharWidth, u16 flags)
Definition msg.c:1628
s32 gMsgBGScrollAmtY
Definition msg.c:91
PAL_BIN ui_msg_sign_pal[]
#define MSG_NORMAL_TEXT_Y
Definition msg_draw.c:197
void msg_reset_gfx_state(void)
Definition msg_draw.c:1642
#define MSG_NORMAL_ARROW_X
Definition msg_draw.c:198
IMG_BIN ui_msg_sign_side_bottom_png[]
#define MSG_NORMAL_PAGE_HT
Definition msg_draw.c:201
PAL_BIN D_802F4560[80][8]
IMG_BIN ui_msg_sign_side_right_png[]
IMG_BIN ui_msg_sign_corner_bottomleft_png[]
#define MSG_NORMAL_WIN_HEIGHT
Definition msg_draw.c:196
void msg_draw_speech_arrow(MessagePrintState *printer)
Definition msg_draw.c:1928
Vtx gMsgArrowQuad2[]
Definition msg_draw.c:87
IMG_BIN ui_msg_sign_corner_bottomright_png[]
unsigned char ui_msg_palettes[16][32]
Definition msg_img.c:42
s32 my_ceil(f32 f)
Definition msg_draw.c:11
void msg_get_glyph(s32 font, s32 variation, s32 charIndex, s32 palette, MesasgeFontGlyphData *out)
Definition msg_draw.c:2279
void draw_message_window(MessagePrintState *printer)
Definition msg_draw.c:137
IMG_BIN ui_msg_bubble_left_png[]
Gfx D_8014C500[]
Definition msg_draw.c:94
MessageImageDataList gMsgVarImages
Definition msg.c:90
#define MSG_INSPECT_TEXT_Y
Definition msg_draw.c:202
IMG_BIN ui_msg_sign_corner_topleft_png[]
#define MSG_NORMAL_ARROW_Y
Definition msg_draw.c:199
#define MSG_NORMAL_HEIGHT_CAP
Definition msg_draw.c:200
MessageCharset * MsgCharsets[5]
Definition msg_data.c:865
IMG_BIN ui_msg_arrow_png[]
IMG_BIN ui_msg_sign_side_left_png[]
Vtx gMsgSpeechBoxLQuad[4]
Definition msg_draw.c:59
u8 D_8014C580[]
Definition msg_draw.c:113
u8 * D_8015131C
Definition msg.c:92
s32 gMsgBGScrollAmtX
Definition msg.c:88
#define UNPACK_PAL_B(color)
Definition macros.h:269
#define PM_CC_PRIM_FULL_ALPHA
Definition macros.h:283
#define PM_CC_07
Definition macros.h:282
#define UNPACK_PAL_R(color)
Definition macros.h:267
#define SCREEN_WIDTH
Definition macros.h:105
#define ARRAY_COUNT(arr)
Definition macros.h:40
#define PM_CC_MSG_NOISE_OUTLINE
Definition macros.h:450
#define UNPACK_PAL_G(color)
Definition macros.h:268
#define SCREEN_HEIGHT
Definition macros.h:106
#define PM_CC_10
Definition macros.h:293
#define PM_CC_0F
Definition macros.h:292
#define PM_CC_MSG_STATIC
Definition macros.h:451
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
#define PM_CC_02
Definition macros.h:277
s32 spr_get_npc_raster_info(SpriteRasterInfo *out, s32 npcSpriteID, s32 rasterIndex)
Definition sprite.c:1302
GameStatus * gGameStatusPtr
Definition main_loop.c:32
Gfx * gMainGfxPos
Definition cam_main.c:15
u16 gMatrixListPos
Definition main_loop.c:45
s32 gCurrentDisplayContextIndex
Definition main_loop.c:47
DisplayContext * gDisplayContext
Definition cam_main.c:16