Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
msg.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
17
18#ifdef SHIFT
19#define MSG_ROM_START (s32)msg_ROM_START
20#elif VERSION_JP
21#define MSG_ROM_START 0x1D40000
22#else
23#define MSG_ROM_START 0x1B83000
24#endif
25
26#if VERSION_PAL
27#define CHOICE_POINTER_MOVE_RATE 5.0
28#else
29#define CHOICE_POINTER_MOVE_RATE 6.0
30#endif
31
33
35 .vp = {
36 .vscale = {640, 480, 511, 0},
37 .vtrans = {640, 480, 511, 0},
38 }
39};
40
41#if !VERSION_JP
43
44#if VERSION_PAL
45u8 MessagePlural_de[] = { MSG_CHAR_LOWER_N, MSG_CHAR_READ_END };
46#endif
47
49#endif
50
51#if VERSION_PAL
52s32 gCurrentLanguage = 0;
53
54void* D_PAL_8014AE50[] = {
55 [LANGUAGE_EN] = msg_pal_en_ROM_START,
56 [LANGUAGE_DE] = msg_pal_de_ROM_START,
57 [LANGUAGE_FR] = msg_pal_fr_ROM_START,
58 [LANGUAGE_ES] = msg_pal_es_ROM_START,
59};
60#endif
61
63
65 {{{ -16, 9, 0 }, 0, { 0x000, 0x000 }, { 255, 255, 255, 255 }}},
66 {{{ 16, 9, 0 }, 0, { 0x400, 0x000 }, { 255, 255, 255, 255 }}},
67 {{{ -16, -9, 0 }, 0, { 0x000, 0x240 }, { 255, 255, 255, 255 }}},
68 {{{ 16, -9, 0 }, 0, { 0x400, 0x240 }, { 255, 255, 255, 255 }}},
69};
70
71Gfx D_8014C2D8[] = {
72 gsDPSetCycleType(G_CYC_2CYCLE),
73 gsSPClearGeometryMode(G_CULL_BOTH | G_LIGHTING),
74 gsSPSetGeometryMode(G_SHADE | G_SHADING_SMOOTH),
75 gsDPSetColorDither(G_CD_DISABLE),
76 gsDPSetAlphaDither(G_AD_DISABLE),
77 gsDPSetAlphaCompare(G_AC_NONE),
78 gsSPTexture(-1, -1, 0, G_TX_RENDERTILE, G_ON),
79 gsDPSetTexturePersp(G_TP_PERSP),
80 gsDPSetTextureLUT(G_TT_NONE),
81 gsDPSetTextureFilter(G_TF_AVERAGE),
82 gsDPSetRenderMode(IM_RD | CVG_DST_SAVE | ZMODE_XLU | FORCE_BL | G_RM_PASS, IM_RD | CVG_DST_SAVE | ZMODE_XLU |
83 FORCE_BL | GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)),
84 gsDPSetCombineMode(PM_CC_MSG_UP_ARROW, G_CC_PASS2),
85 gsSPEndDisplayList(),
86};
87
94
95static char gMessageBuffers[2][1024];
96static MessagePrintState gMessagePrinters[3];
97#if VERSION_JP
98static s32 D_80155C38;
99#endif
100static u8 gMessageMsgVars[3][32];
101static s16 D_80155C98;
102static Mtx gMessageWindowProjMatrix[2];
103
106
107extern s16 MsgStyleVerticalLineOffsets[];
108
111extern IMG_BIN ui_msg_star_png[];
113
114extern IMG_BIN MsgCharImgTitle[];
116extern MessageCharset* MsgCharsets[5];
118extern PAL_BIN D_802F4560[80][8];
119#if VERSION_JP
120extern IMG_BIN MsgCharImgKana[];
121extern IMG_BIN MsgCharImgLatin[];
124#endif
125
128
130#if VERSION_JP
131 {
132 .rasters = &MsgCharImgKana[0x4910],
133 .texSize = 112,
134 .texWidth = 16,
135 .texHeight = 14,
136 .digitWidth = {11, 8, 11, 11, 11, 11, 11, 11, 11, 11},
137 .fixedWidth = 11
138 }, {
139 .rasters = &MsgCharImgMenuKana[0x2EF8],
140 .texSize = 72,
141 .texWidth = 12,
142 .texHeight = 12,
143 .digitWidth = {9, 8, 9, 9, 9, 9, 9, 9, 9, 9},
144 .fixedWidth = 9
145 }
146#else
147 {
148 .rasters = &MsgCharImgNormal[0x800],
149 .texSize = 128,
150 .texWidth = 16,
151 .texHeight = 16,
152 .digitWidth = {11, 8, 11, 11, 11, 11, 11, 11, 11, 11},
153 .fixedWidth = 11
154 }, {
155 .rasters = &MsgCharImgNormal[0x800],
156 .texSize = 128,
157 .texWidth = 16,
158 .texHeight = 16,
159 .digitWidth = {9, 8, 9, 9, 9, 9, 9, 9, 9, 9},
160 .fixedWidth = 9
161 }
162#endif
163};
164
166 gsDPPipeSync(),
167 gsDPSetCycleType(G_CYC_1CYCLE),
168 gsDPSetTextureFilter(G_TF_POINT),
169 gsDPSetTexturePersp(G_TP_NONE),
170 gsDPSetColorDither(G_CD_DISABLE),
171 gsDPSetAlphaDither(G_AD_DISABLE),
172 gsDPSetCombineKey(G_CK_NONE),
173 gsDPSetAlphaCompare(G_AC_NONE),
174 gsDPSetTextureLUT(G_TT_RGBA16),
175 gsSPTexture(-1, -1, 0, G_TX_RENDERTILE, G_ON),
176 gsSPEndDisplayList(),
177};
178
179s32 draw_image_with_clipping(IMG_PTR raster, s32 width, s32 height, s32 fmt, s32 bitDepth, s16 posX, s16 posY, u16 clipULx,
180 u16 clipULy, u16 clipLRx, u16 clipRLy);
181
183void msg_copy_to_print_buffer(MessagePrintState* printer, s32 arg1, s32 arg2);
184void initialize_printer(MessagePrintState* printer, s32 arg1, s32 arg2);
185MessagePrintState* _msg_get_printer_for_msg(s32 msgID, s32* donePrintingWriteback, s32 arg2);
187void msg_draw_rewind_arrow(s32);
190void appendGfx_message(MessagePrintState*, s16, s16, u16, u16, u16, u8);
191
193 D_80155C98 = -1;
194}
195
196void clear_printers(void) {
197 s32 i;
198
199 for (i = 0; i < ARRAY_COUNT(gMessagePrinters); i++) {
200 initialize_printer(&gMessagePrinters[i], 0, 0);
201 }
202
205
206 for (i = 0; i < ARRAY_COUNT(gMessageMsgVars); i++) {
207 gMessageMsgVars[i][0] = 0;
208 }
209
210 D_80151338 = NULL;
212 load_font(0);
213}
214
215#if VERSION_IQUE
216void load_font_data(Addr offset, u32 size, void* dest) {
217#else
218void load_font_data(Addr offset, u16 size, void* dest) {
219#endif
220 u8* base = charset_ROM_START + (s32) offset;
221
222 dma_copy(base, base + size, dest);
223}
224
225void load_font(s32 font) {
226 if (font != D_80155C98) {
227 if (font == 0) {
228#if VERSION_JP
229 load_font_data(charset_kana_OFFSET, 0x5710, MsgCharImgKana);
230 load_font_data(charset_latin_OFFSET, 0xBD0, MsgCharImgLatin);
231 load_font_data(charset_kanji_OFFSET, 0x34F0, MsgCharImgTitle); // huh
232 load_font_data(charset_buttons_OFFSET, 0x460, MsgCharImgSubtitle); // what
233 load_font_data(charset_menu_kana_OFFSET, 0x37F8, MsgCharImgMenuKana);
234 load_font_data(charset_menu_latin_OFFSET, 0x798, MsgCharImgMenuLatin);
235#else
237#endif
239 } else if (font == 1) {
243 }
244 }
245}
246
247void update_messages(void) {
248 s32 i;
249
251 if (gMsgGlobalWaveCounter >= 360) {
253 }
254
255 for (i = 0; i < ARRAY_COUNT(gMessagePrinters); i++) {
256 if (gMessagePrinters[i].stateFlags & MSG_STATE_FLAG_2) {
257 _update_message(&gMessagePrinters[i]);
258 }
259 }
260
261 gMsgBGScrollAmtX += 12;
262 gMsgBGScrollAmtY -= 12;
263 if (gMsgBGScrollAmtX >= 2048) {
264 gMsgBGScrollAmtX -= 2048;
265 }
266 if (gMsgBGScrollAmtY < 0) {
267 gMsgBGScrollAmtY += 2048;
268 }
269}
270
272 f32 speechPan;
273 u8 cond;
274 s32 buttons;
275 s16 endPosDist;
276 s16 lineIncAmt;
277 s32 charsToPrint;
278 s32 i;
279
280 printer->effectFrameCounter++;
281 if (printer->effectFrameCounter >= 3600) {
282 printer->effectFrameCounter = 0;
283 }
284
285 speechPan = (((f32)printer->initOpenPos.x - (SCREEN_WIDTH / 2.0)) / 3.8) + 64.0;
286 if (speechPan < 5.0) {
287 speechPan = 5.0f;
288 } else if (speechPan > 122.0) {
289 speechPan = 122.0f;
290 }
291 printer->speechPan = speechPan;
292
293 cond = FALSE;
294 if (!(printer->stateFlags & MSG_STATE_FLAG_40)) {
295 if (!(printer->stateFlags & (MSG_STATE_FLAG_20 | MSG_STATE_FLAG_10))) {
296 s32 buttons = BUTTON_A;
297
298 switch (printer->windowState) {
300 if (printer->stateFlags & MSG_STATE_FLAG_80000) {
301 buttons = BUTTON_A | BUTTON_C_DOWN;
302 }
303 if ((buttons & gGameStatusPtr->pressedButtons[0]) || (gGameStatusPtr->curButtons[0] & BUTTON_B)) {
305 printer->curPrintDelay = 0;
306 printer->stateFlags |= MSG_STATE_FLAG_4;
308 cond = TRUE;
310 } else if (printer->srcBuffer[printer->srcBufferPos] != MSG_CHAR_READ_END) {
312 if (printer->fontVariant != 0 || printer->srcBuffer[printer->srcBufferPos] != MSG_CHAR_UNK_C3) {
314 }
316 } else if (printer->style == MSG_STYLE_RIGHT ||
317 printer->style == MSG_STYLE_LEFT ||
318 printer->style == MSG_STYLE_CENTER ||
319 printer->style == MSG_STYLE_TATTLE)
320 {
322 }
323 } else if ((gGameStatusPtr->pressedButtons[0] & BUTTON_Z) &&
324 !(printer->stateFlags & MSG_STATE_FLAG_40000) &&
325 (printer->curLine != 0))
326 {
328 printer->unk_4CC = 0;
329 printer->unkArraySize = printer->curLine - 1;
330 printer->unk_4C8 = abs(printer->curLinePos - printer->lineEndPos[printer->unkArraySize]);
332 }
333 break;
337 printer->unk_4CC = 0;
338 printer->unkArraySize = printer->curLine;
339 printer->unk_4C8 = abs(printer->curLinePos - printer->lineEndPos[printer->unkArraySize]);
341 } else if (gGameStatusPtr->pressedButtons[0] & BUTTON_Z) {
342 if (printer->unkArraySize > 0) {
344 printer->unk_4CC = 0;
345 printer->unkArraySize--;
346 printer->unk_4C8 = abs(printer->curLinePos - printer->lineEndPos[printer->unkArraySize]);
348 }
349 } else {
352 printer->unk_4CC = 0;
353 printer->unkArraySize++;
354 printer->unk_4C8 = abs(printer->curLinePos - printer->lineEndPos[printer->unkArraySize]);
356 }
357 }
358 break;
361 printer->madeChoice = 1;
363 printer->scrollingTime = 0;
366 } else if (printer->cancelOption != 0xFF && (gGameStatusPtr->pressedButtons[0] & BUTTON_B)) {
367 if (printer->cancelOption >= printer->maxOption) {
368 printer->selectedOption = printer->curOption;
369 } else {
370 printer->selectedOption = printer->cancelOption;
371 }
372 printer->madeChoice = 1;
374 printer->scrollingTime = 0;
375 printer->curOption = printer->cancelOption;
379 if (printer->curOption != printer->maxOption - 1) {
380 printer->targetOption = printer->curOption + 1;
382 printer->scrollingTime = 1;
384 }
385 } else if (gGameStatusPtr->heldButtons[0] & BUTTON_STICK_UP) {
386 if (printer->curOption != 0) {
387 printer->targetOption = printer->curOption - 1;
389 printer->scrollingTime = 1;
391 }
392 }
393
395 break;
396 }
398 printer->scrollingTime++;
399 if (printer->scrollingTime >= (s32)(5 * DT)) {
401 printer->curOption = printer->targetOption;
402 printer->selectedOption = printer->curOption;
403 }
404 break;
405 }
406 } else if (!(printer->stateFlags & MSG_STATE_FLAG_20) &&
409 {
411 printer->curPrintDelay = 0;
412 printer->stateFlags |= MSG_STATE_FLAG_4;
413 }
414
415 if (printer->stateFlags & MSG_STATE_FLAG_4 && !(gGameStatusPtr->curButtons[0] & BUTTON_A)) {
416 printer->stateFlags &= ~MSG_STATE_FLAG_4;
417 }
418
419 for (i = 0; i < ARRAY_COUNT(printer->animTimers); i++) {
420 if (printer->animTimers[i] > 0) {
421 printer->animTimers[i]--;
422 }
423 }
424
425 switch (printer->windowState) {
428 if (!(printer->stateFlags & (MSG_STATE_FLAG_20 | MSG_STATE_FLAG_10)) && !cond) {
430
431 }
432 }
433 // fallthrough
435 charsToPrint = printer->charsPerChunk;
436 if (printer->windowState == MSG_WINDOW_STATE_INIT) {
438 printer->curPrintDelay = 0;
439 } else if (printer->stateFlags & MSG_STATE_FLAG_PRINT_QUICKLY) {
440 charsToPrint = 12;
441 printer->curPrintDelay = 0;
442 } else if (!(printer->stateFlags & MSG_STATE_FLAG_4)) {
443 if (!(printer->stateFlags & (MSG_STATE_FLAG_20 | MSG_STATE_FLAG_10)) &&
445 {
446 charsToPrint = 6;
447 printer->curPrintDelay = 0;
448 }
449 }
450 if ((printer->curPrintDelay == 0) || --printer->curPrintDelay == 0) {
451 msg_copy_to_print_buffer(printer, charsToPrint, 0);
452 }
453 break;
456 if (!(printer->stateFlags & (MSG_STATE_FLAG_20 | MSG_STATE_FLAG_10))) {
458 }
459 }
460 printer->curLinePos += printer->windowScrollRate;
461 if ((printer->stateFlags & MSG_STATE_FLAG_PRINT_QUICKLY) ||
462 (!(printer->stateFlags & (MSG_STATE_FLAG_10 | MSG_STATE_FLAG_4)) &&
464 {
465 printer->curLinePos += (s32)(6 / DT);
466 }
467
468 if (printer->curLinePos >= printer->nextLinePos) {
470 printer->curLinePos = printer->nextLinePos;
471 printer->stateFlags |= MSG_STATE_FLAG_4;
472
473 if (printer->style == MSG_STYLE_SIGN ||
474 printer->style == MSG_STYLE_LAMPPOST ||
475 printer->srcBuffer[printer->srcBufferPos] == MSG_CHAR_READ_WAIT)
476 {
477 printer->curPrintDelay = 0;
478 } else {
479 printer->curPrintDelay = 5;
480 }
481 printer->lineEndPos[printer->curLine] = printer->curLinePos;
482 }
483 break;
485 printer->unk_4CC += 1;
486 endPosDist = abs(printer->curLinePos - printer->lineEndPos[printer->unkArraySize]);
487 lineIncAmt = 2;
488
489 if (printer->unk_4C8 <= 16) {
490 if (endPosDist >= 15) {
491 lineIncAmt = 4;
492 } else if (endPosDist >= 9) {
493 lineIncAmt = 3;
494 }
495 } else if (endPosDist > 96) {
496 lineIncAmt = 10;
497 } else if (endPosDist > 48) {
498 lineIncAmt = 9;
499 } else if (endPosDist >= 24) {
500 lineIncAmt = 7;
501 } else if (endPosDist >= 16) {
502 lineIncAmt = 5;
503 } else if (endPosDist >= 8) {
504 lineIncAmt = 4;
505 } else if (endPosDist > 4) {
506 lineIncAmt = 3;
507 }
508
509 printer->unk_4CA = lineIncAmt;
510
511 if (printer->lineEndPos[printer->unkArraySize] < printer->curLinePos) {
512 printer->curLinePos -= printer->unk_4CA;
513 if (printer->lineEndPos[printer->unkArraySize] >= printer->curLinePos) {
514 printer->curLinePos = printer->lineEndPos[printer->unkArraySize];
516 }
517 } else {
518 printer->curLinePos += printer->unk_4CA;
519 if (printer->curLinePos >= printer->lineEndPos[printer->unkArraySize]) {
520 printer->curLinePos = printer->lineEndPos[printer->unkArraySize];
522 if (printer->unkArraySize == printer->curLine) {
525 printer->rewindArrowCounter = 0;
526 }
527 }
528 }
529 break;
540 break;
541 }
542 }
543
544 if (printer->stateFlags & MSG_STATE_FLAG_1) {
546 printer->stateFlags = 0;
547 if (printer->letterBackgroundImg != NULL) {
549 }
550 if (printer->letterBackgroundPal != NULL) {
552 }
553 if (printer->letterContentImg != NULL) {
555 }
556 if (printer->letterContentPal != NULL) {
558 }
559 if (printer->closedWritebackBool != NULL) {
560 *printer->closedWritebackBool = TRUE;
561 printer->closedWritebackBool = NULL;
562 }
563 }
564
565 return printer->windowState;
566}
567
568void render_messages(void) {
569 Mtx* matrix = &gMessageWindowProjMatrix[gCurrentDisplayContextIndex];
570 s32 i;
571
572 for (i = 0; i < ARRAY_COUNT(gMessagePrinters); i++) {
573 if (gMessagePrinters[i].stateFlags & MSG_STATE_FLAG_2) {
574 gSPViewport(gMainGfxPos++, &D_8014C280);
575 guOrtho(matrix, 0.0f, 319.0f, -240.0f, 0.0f, -500.0f, 500.0f, 1.0f);
576 gSPMatrix(gMainGfxPos++, OS_K0_TO_PHYSICAL(matrix), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
577 gDPPipeSync(gMainGfxPos++);
578 gDPSetCycleType(gMainGfxPos++, G_CYC_1CYCLE);
579 gSPClearGeometryMode(gMainGfxPos++, G_SHADE | G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN |
580 G_TEXTURE_GEN_LINEAR | G_LOD | G_SHADING_SMOOTH);
581 gSPSetGeometryMode(gMainGfxPos++, G_SHADE | G_SHADING_SMOOTH);
582 break;
583 }
584 }
585
586 for (i = 0; i < ARRAY_COUNT(gMessagePrinters); i++) {
587 if (gMessagePrinters[i].stateFlags & MSG_STATE_FLAG_2) {
588 draw_message_window(&gMessagePrinters[i]);
589
590 if (gMessagePrinters[i].windowState == MSG_WINDOW_STATE_WAITING) {
591 if (!(gMessagePrinters[i].stateFlags & MSG_STATE_FLAG_8000) &&
592 !(gMessagePrinters[i].stateFlags & MSG_STATE_FLAG_40))
593 {
595 }
596 } else if (gMessagePrinters[i].windowState == MSG_WINDOW_STATE_C) {
598 } else if (gMessagePrinters[i].windowState == MSG_WINDOW_STATE_WAITING_FOR_CHOICE ||
599 gMessagePrinters[i].windowState == MSG_WINDOW_STATE_SCROLLING_BACK ||
600 gMessagePrinters[i].stateFlags & MSG_STATE_FLAG_10000 ||
601 gMessagePrinters[i].stateFlags & MSG_STATE_FLAG_20000)
602 {
603 msg_draw_choice_pointer(&gMessagePrinters[i]);
604 }
605 }
606 }
607}
608
609void msg_play_speech_sound(MessagePrintState* printer, u8 character) {
610 f32 volTemp;
611 s16 volume;
612 s32 pitchShift;
613 s32 flag = 1;
614 s32 baseShift = 100;
615
616 if (printer->stateFlags & MSG_STATE_FLAG_800000 && !(printer->delayFlags & (MSG_DELAY_FLAG_2 | MSG_DELAY_FLAG_4)) && printer->volume != 0) {
617 volTemp = (f32)printer->volume / 100.0;
618 pitchShift = ((character % 20) * 10) + (printer->speechPitchShift - baseShift);
619 volume = ((rand_int(15) + 78) * volTemp);
620
621 if (volume > 255) {
622 volume = 255;
623 }
624
625 if (character & flag) {
626 sfx_play_sound_with_params(printer->speechSoundIDA, volume, printer->speechPan, pitchShift);
627 } else {
628 sfx_play_sound_with_params(printer->speechSoundIDB, volume, printer->speechPan, pitchShift);
629 }
630 }
631}
632
633extern s32 gItemIconRasterOffsets[];
634extern s32 gItemIconPaletteOffsets[];
637extern MsgVoice MsgVoices[];
638
639#if VERSION_PAL
641#else
642void msg_copy_to_print_buffer(MessagePrintState* printer, s32 arg1, s32 arg2) {
643 u8 arg;
644 u8 argQ;
645 u8 argW;
646 u8 argE;
647 u8 sp10[4];
648 s32 addr;
649 s16 offset;
650 s32 i;
651 u8* romAddr;
652 u8* romEnd;
653 s32 temp;
654 void* a2;
655 s8 s8 = arg2 & 1;
656 u8* printBuf = &printer->printBuffer[printer->printBufferPos];
657 u8* srcBuf = &printer->srcBuffer[printer->srcBufferPos];
658
659 do {
660 u8 c = *srcBuf++; // a1
661 u8 nextArg = *srcBuf; // a2
662 switch (c) {
664 *printBuf++ = MSG_CHAR_PRINT_ENDL;
665 printer->lineCount += (u8)printer->sizeScale;
666 break;
669 printer->delayFlags |= MSG_DELAY_FLAG_1;
670 printer->delayFlags &= ~MSG_DELAY_FLAG_2;
672 printer->rewindArrowCounter = 0;
673 printer->stateFlags &= ~MSG_STATE_FLAG_SPEAKING;
674 printer->stateFlags &= ~MSG_STATE_FLAG_PRINT_QUICKLY;
675 if (printer->style != MSG_STYLE_F) {
677 }
678 break;
680 printer->curPrintDelay = *srcBuf++;
681 printer->delayFlags |= MSG_DELAY_FLAG_1;
682 printer->stateFlags &= ~MSG_STATE_FLAG_SPEAKING;
683 break;
689 printer->fontVariant = c + 13;
690 break;
692 *printBuf++ = MSG_CHAR_PRINT_SPACE;
693 break;
695 *printBuf++ = MSG_CHAR_PRINT_FULL_SPACE;
696 break;
698 *printBuf++ = MSG_CHAR_PRINT_HALF_SPACE;
699 break;
701 *printBuf++ = MSG_CHAR_PRINT_UNK_CHAR_FA;
702 arg1--;
703 break;
705 if (printer->lineCount != 0) {
706 printer->lineEndPos[printer->curLine] = printer->curLinePos;
707 printer->curLine++;
708 *printBuf++ = MSG_CHAR_PRINT_NEXT;
709 printer->nextLinePos = printer->curLinePos + (MsgCharsets[printer->font]->newLineY
710#if !VERSION_JP
712#endif
713 ) * printer->lineCount;
715 printer->delayFlags |= MSG_DELAY_FLAG_1;
716 }
717 printer->lineCount = 0;
718 break;
720 *printBuf++ = MSG_CHAR_PRINT_STYLE;
721 arg = *srcBuf++;
722 printer->style = arg;
723 *printBuf++ = arg;
724 printer->fadeInCounter = 0;
725 switch (arg) {
726 case MSG_STYLE_RIGHT:
727 case MSG_STYLE_LEFT:
728 case MSG_STYLE_CENTER:
729 case MSG_STYLE_TATTLE:
730 if (arg == MSG_STYLE_RIGHT || arg == MSG_STYLE_LEFT || arg == MSG_STYLE_CENTER) {
731 printer->maxLinesPerPage = 3;
732 }
733 printer->delayFlags |= MSG_DELAY_FLAG_1;
735 if (nextArg != MSG_CHAR_UNK_C3) {
737 }
741 break;
742 case MSG_STYLE_CHOICE:
743 printer->windowBasePos.x = *srcBuf++;
744 printer->windowBasePos.y = *srcBuf++;
745 printer->windowSize.x = *srcBuf++;
746 printer->windowSize.y = *srcBuf++;
748 printer->stateFlags |= MSG_STATE_FLAG_800;
749 break;
752 case MSG_STYLE_F:
753 if (!s8) {
754#if VERSION_JP
755 printer->windowBasePos.x = 40;
756#else
757 printer->windowBasePos.x = 20;
758#endif
759 printer->windowBasePos.y = 28;
760 printer->windowSize.y = 58;
761#if VERSION_JP
762 printer->windowSize.x = 240;
763#else
764 printer->windowSize.x = 280;
765#endif
767 printer->stateFlags |= MSG_STATE_FLAG_800;
768 printer->delayFlags |= MSG_DELAY_FLAG_1;
769 if (arg == MSG_STYLE_INSPECT) {
771 }
772 }
773 break;
775 printer->windowBasePos.x = *srcBuf++;
776 printer->windowBasePos.y = *srcBuf++;
777 printer->windowSize.x = *srcBuf++;
778 printer->windowSize.y = *srcBuf++;
781 printer->delayFlags |= MSG_DELAY_FLAG_1;
782 printer->stateFlags |= MSG_STATE_FLAG_800;
783 break;
785 printer->windowSize.y = *srcBuf++;
786 // fallthrough
787 case MSG_STYLE_SIGN:
788 if (!s8) {
790 printer->stateFlags |= MSG_STATE_FLAG_800;
791 printer->delayFlags |= MSG_DELAY_FLAG_1;
792 }
793 break;
795 arg = *srcBuf++;
797 printer->stateFlags |= MSG_STATE_FLAG_800;
798 printer->delayFlags |= MSG_DELAY_FLAG_1;
799 printer->letterBackgroundImg = heap_malloc(((charset_postcard_png_width * charset_postcard_png_height) / 2));
800 romAddr = charset_ROM_START + (s32)charset_postcard_OFFSET;
801 dma_copy(romAddr, romAddr + ((charset_postcard_png_width * charset_postcard_png_height) / 2), printer->letterBackgroundImg);
802 printer->letterBackgroundPal = heap_malloc(0x20);
803 romAddr = charset_ROM_START + (s32)charset_postcard_pal_OFFSET;
804 dma_copy(romAddr, romAddr + 0x20, printer->letterBackgroundPal);
805 printer->letterContentImg = heap_malloc(charset_letter_content_1_png_width * charset_letter_content_1_png_height);
806 romAddr = charset_ROM_START + (s32) MsgLetterRasterOffsets[arg];
807 dma_copy(romAddr, romAddr + (charset_letter_content_1_png_width * charset_letter_content_1_png_height), printer->letterContentImg);
808 printer->letterContentPal = heap_malloc(0x200);
809 romAddr = charset_ROM_START + (s32) MsgLetterPaletteOffsets[arg];
810 dma_copy(romAddr, romAddr + 0x200, printer->letterContentPal);
811 break;
812 case MSG_STYLE_POPUP:
813 case MSG_STYLE_B:
814 printer->windowSize.x = printer->msgWidth + 32;
815#if VERSION_JP
816 printer->windowSize.y = 32;
817#else
818 printer->windowSize.y = 40;
819#endif
821 if (!s8) {
824 printer->delayFlags |= MSG_DELAY_FLAG_1;
825 }
826 break;
829 break;
830 }
831 if ((printer->delayFlags & MSG_DELAY_FLAG_1) && (printer->delayFlags & (MSG_DELAY_FLAG_4 | MSG_DELAY_FLAG_2))) {
832 printer->delayFlags &= ~MSG_DELAY_FLAG_1;
833 }
834 break;
836 *printBuf++ = MSG_CHAR_PRINT_END;
837 if (printer->stateFlags & MSG_STATE_FLAG_800) {
838 if (printer->stateFlags & MSG_STATE_FLAG_1000) {
839 if (printer->closedWritebackBool != NULL) {
840 *printer->closedWritebackBool = TRUE;
841 }
842 }
843 if (printer->style != MSG_STYLE_POPUP && printer->style != MSG_STYLE_B) {
845 } else {
847 }
848 printer->fadeOutCounter = 0;
849 } else {
850 printer->stateFlags |= MSG_STATE_FLAG_1;
851 }
852 printer->delayFlags |= MSG_DELAY_FLAG_1;
853 printer->delayFlags &= ~MSG_DELAY_FLAG_2;
854 break;
856 switch (*srcBuf++) {
858 *printBuf++ = MSG_CHAR_PRINT_FUNCTION;
859 *printBuf++ = MSG_PRINT_FUNC_FONT;
860 *printBuf++ = printer->font = *srcBuf++;
861 break;
863 *printBuf++ = MSG_CHAR_PRINT_FUNCTION;
864 *printBuf++ = MSG_PRINT_FUNC_VARIANT;
865 *printBuf++ = printer->fontVariant = *srcBuf++;
866 break;
868 *printBuf++ = MSG_CHAR_PRINT_FUNCTION;
869 *printBuf++ = MSG_PRINT_FUNC_COLOR;
870 *printBuf++ = *srcBuf++;
871 break;
873 printer->stateFlags |= MSG_STATE_FLAG_10;
874 break;
876 printer->stateFlags |= MSG_STATE_FLAG_20;
877 printer->stateFlags &= ~MSG_STATE_FLAG_PRINT_QUICKLY;
878 break;
880 printer->stateFlags &= ~MSG_STATE_FLAG_20;
881 break;
883 *printBuf++ = MSG_CHAR_PRINT_FUNCTION;
884 *printBuf++ = MSG_PRINT_FUNC_SPACING;
885 *printBuf++ = *srcBuf++;
886 break;
888 printer->delayFlags |= MSG_DELAY_FLAG_2;
889 break;
891 printer->delayFlags &= ~MSG_DELAY_FLAG_2;
892 printer->delayFlags |= MSG_DELAY_FLAG_1;
893 break;
895 printer->lineEndPos[printer->curLine] = printer->curLinePos;
896 printer->curLine++;
897 *printBuf++ = MSG_CHAR_PRINT_NEXT;
898 arg = *srcBuf++;
899 printer->nextLinePos = printer->curLinePos + (MsgCharsets[printer->font]->newLineY
900#if !VERSION_JP
902#endif
903 ) * arg;
905 printer->delayFlags |= MSG_DELAY_FLAG_1;
906 printer->lineCount = 0;
907 break;
908#if !VERSION_IQUE
910 *printBuf++ = MSG_CHAR_PRINT_FUNCTION;
911 *printBuf++ = MSG_PRINT_FUNC_SIZE;
912 *printBuf++ = *srcBuf++;
913 *printBuf++ = arg = *srcBuf++;
914 printer->sizeScale = (arg >> 4) + (arg & 0xF) * 0.0625f;
915 break;
917 *printBuf++ = MSG_CHAR_PRINT_FUNCTION;
918 *printBuf++ = MSG_PRINT_FUNC_SIZE_RESET;
919 printer->sizeScale = 1.0f;
920 break;
921#endif
923 printer->printDelayTime = *srcBuf++;
924 printer->charsPerChunk = *srcBuf++;
925 break;
927 *printBuf++ = MSG_CHAR_PRINT_FUNCTION;
928 *printBuf++ = MSG_PRINT_FUNC_SET_X;
929 *printBuf++ = *srcBuf++;
930 *printBuf++ = *srcBuf++;
931 break;
933 *printBuf++ = MSG_CHAR_PRINT_FUNCTION;
934 *printBuf++ = MSG_PRINT_FUNC_SET_Y;
935 *printBuf++ = *srcBuf++;
936 break;
938 *printBuf++ = MSG_CHAR_PRINT_FUNCTION;
939 *printBuf++ = MSG_PRINT_FUNC_RIGHT;
940 *printBuf++ = *srcBuf++;
941 break;
943 *printBuf++ = MSG_CHAR_PRINT_FUNCTION;
944 *printBuf++ = MSG_PRINT_FUNC_DOWN;
945 *printBuf++ = *srcBuf++;
946 break;
947 case MSG_READ_FUNC_UP:
948 *printBuf++ = MSG_CHAR_PRINT_FUNCTION;
949 *printBuf++ = MSG_PRINT_FUNC_UP;
950 *printBuf++ = *srcBuf++;
951 break;
953 *printBuf++ = MSG_CHAR_PRINT_FUNCTION;
954 *printBuf++ = MSG_PRINT_FUNC_INLINE_IMAGE;
955 *printBuf++ = *srcBuf++;
956 arg1--;
957 printer->curPrintDelay = printer->printDelayTime;
958 if (arg1 <= 0) {
959 printer->delayFlags |= MSG_DELAY_FLAG_1;
960 }
961 if (printer->delayFlags & (MSG_DELAY_FLAG_4 | MSG_DELAY_FLAG_2)) {
962 printer->delayFlags &= ~MSG_DELAY_FLAG_1;
963 }
964 break;
966 *printBuf++ = MSG_CHAR_PRINT_FUNCTION;
967 *printBuf++ = MSG_PRINT_FUNC_ANIM_SPRITE;
968 *printBuf++ = *srcBuf++;
969 *printBuf++ = *srcBuf++;
970 *printBuf++ = *srcBuf++;
971 printer->curPrintDelay = printer->printDelayTime;
972 if (--arg1 <= 0) {
973 printer->delayFlags |= MSG_DELAY_FLAG_1;
974 }
975 if (printer->delayFlags & (MSG_DELAY_FLAG_4 | MSG_DELAY_FLAG_2)) {
976 printer->delayFlags &= ~MSG_DELAY_FLAG_1;
977 }
978 break;
980 *printBuf++ = MSG_CHAR_PRINT_FUNCTION;
981 *printBuf++ = MSG_PRINT_FUNC_ITEM_ICON;
982
983 arg = *srcBuf++;
984 argQ = *srcBuf++;
985
986 a2 = D_80159B50;
987 offset = arg << 8 | argQ;
988
990 dma_copy(icon_ROM_START + gItemIconRasterOffsets[offset],
991 icon_ROM_START + gItemIconRasterOffsets[offset] + 0x200, a2);
992 romEnd = icon_ROM_START + gItemIconPaletteOffsets[offset] + 0x20;
993 dma_copy(icon_ROM_START + gItemIconPaletteOffsets[offset],
994 romEnd, D_8015C7E0);
995 printer->curPrintDelay = printer->printDelayTime;
996 if (--arg1 <= 0) {
997 printer->delayFlags |= MSG_DELAY_FLAG_1;
998 }
999 if (printer->delayFlags & (MSG_DELAY_FLAG_4 | MSG_DELAY_FLAG_2)) {
1000 printer->delayFlags &= ~MSG_DELAY_FLAG_1;
1001 }
1002 break;
1004 printer->curImageIndex = *srcBuf++;
1005 arg = *srcBuf++;
1006 argQ = *srcBuf++;
1007 printer->varImageScreenPos.x = arg << 8 | argQ;
1008 printer->varImageScreenPos.y = *srcBuf++;
1009 printer->varImgHasBorder = *srcBuf++;
1010 printer->varImgFinalAlpha = *srcBuf++;
1011 printer->varImgAlphaFadeStep = *srcBuf++;
1012 printer->varImageDisplayState = 0;
1013 printer->varImageFadeTimer = 0;
1014 if (--arg1 <= 0) {
1015 printer->delayFlags |= MSG_DELAY_FLAG_1;
1016 }
1017 if (printer->delayFlags & (MSG_DELAY_FLAG_4 | MSG_DELAY_FLAG_2)) {
1018 printer->delayFlags &= ~MSG_DELAY_FLAG_1;
1019 }
1020 break;
1022 arg = *srcBuf++;
1023 if (arg != 0) {
1024 printer->varImageDisplayState = 2;
1025 printer->varImgAlphaFadeStep = arg;
1026 printer->varImageFadeTimer = 0;
1027 } else {
1028 printer->varImageScreenPos.x = 0;
1029 }
1030 break;
1032 *printBuf++ = MSG_CHAR_PRINT_FUNCTION;
1033 *printBuf++ = MSG_PRINT_FUNC_ANIM_DELAY;
1034 *printBuf++ = *srcBuf++;
1035 *printBuf++ = *srcBuf++;
1036 *printBuf++ = *srcBuf++;
1037 printer->delayFlags |= MSG_DELAY_FLAG_4;
1038 break;
1040 *printBuf++ = MSG_CHAR_PRINT_FUNCTION;
1041 *printBuf++ = MSG_PRINT_FUNC_ANIM_LOOP;
1042 *printBuf++ = *srcBuf++;
1043 *printBuf++ = *srcBuf++;
1044 break;
1046 *printBuf++ = MSG_CHAR_PRINT_FUNCTION;
1047 *printBuf++ = MSG_PRINT_FUNC_ANIM_DONE;
1048 *printBuf++ = *srcBuf++;
1049 printer->delayFlags &= ~MSG_DELAY_FLAG_4;
1050 if (--arg1 <= 0) {
1051 printer->delayFlags |= MSG_DELAY_FLAG_1;
1052 }
1053 break;
1055 arg = *srcBuf++;
1056 argQ = *srcBuf++;
1057 argW = *srcBuf++;
1058 argE = *srcBuf++;
1059 printer->cursorPosX[arg] = argQ << 8 | argW;
1060 printer->cursorPosY[arg] = argE;
1061 break;
1063 *printBuf++ = MSG_CHAR_PRINT_FUNCTION;
1064 *printBuf++ = MSG_PRINT_FUNC_CURSOR;
1065 *printBuf++ = *srcBuf++;
1066 break;
1069 printer->maxOption = *srcBuf++;
1070 printer->madeChoice = 0;
1071 printer->curOption = 0;
1072 printer->selectedOption = 0;
1074 printer->delayFlags |= MSG_DELAY_FLAG_1;
1075 break;
1077 printer->cancelOption = *srcBuf++;
1078 break;
1080 *printBuf++ = MSG_CHAR_PRINT_FUNCTION;
1081 *printBuf++ = MSG_PRINT_FUNC_OPTION;
1082 *printBuf++ = *srcBuf++;
1083 break;
1085 *printBuf++ = MSG_CHAR_PRINT_FUNCTION;
1086 *printBuf++ = MSG_PRINT_RESET_GFX;
1087 break;
1090 printer->delayFlags |= MSG_DELAY_FLAG_1;
1091 printer->stateFlags &= ~MSG_STATE_FLAG_SPEAKING;
1092 printer->stateFlags &= ~MSG_STATE_FLAG_PRINT_QUICKLY;
1093 break;
1095 *printBuf++ = MSG_CHAR_PRINT_FUNCTION;
1096 *printBuf++ = MSG_PRINT_FUNC_SAVE_POS;
1097 break;
1099 *printBuf++ = MSG_CHAR_PRINT_FUNCTION;
1100 *printBuf++ = MSG_PRINT_FUNC_RESTORE_POS;
1101 break;
1103 *printBuf++ = MSG_CHAR_PRINT_FUNCTION;
1104 *printBuf++ = MSG_PRINT_FUNC_SAVE_COLOR;
1105 break;
1107 *printBuf++ = MSG_CHAR_PRINT_FUNCTION;
1108 *printBuf++ = MSG_PRINT_FUNC_RESTORE_COLOR;
1109 break;
1111 *printBuf++ = MSG_CHAR_PRINT_FUNCTION;
1112 *printBuf++ = MSG_PRINT_FUNC_START_FX;
1113 arg = *srcBuf++;
1114 switch (arg) {
1115 case MSG_FX_SHAKE:
1116 case MSG_FX_WAVE:
1118 case MSG_FX_RAINBOW:
1119 case MSG_FX_GLOBAL_WAVE:
1121 case MSG_FX_RISE_PRINT:
1122 case MSG_FX_GROW_PRINT:
1123 case MSG_FX_SIZE_JITTER:
1124 case MSG_FX_SIZE_WAVE:
1125 case MSG_FX_DROP_SHADOW:
1126 *printBuf++ = arg;
1127 break;
1128 case MSG_FX_STATIC:
1129 case MSG_FX_BLUR:
1130 case MSG_FX_DITHER_FADE:
1131 *printBuf++ = arg;
1132 *printBuf++ = *srcBuf++;
1133 break;
1134 }
1135 break;
1137 *printBuf++ = MSG_CHAR_PRINT_FUNCTION;
1138 *printBuf++ = MSG_PRINT_FUNC_END_FX;
1139 *printBuf++ = *srcBuf++;
1140 break;
1141 case MSG_READ_FUNC_VAR:
1142 arg = *srcBuf++;
1143 srcBuf -= 3;
1144 if (printer->varBufferReadPos == 0) {
1145 printer->unk_52A = printer->fontVariant;
1146 *printBuf++ = MSG_CHAR_PRINT_VARIANT0;
1147 }
1148
1149 do {
1150 s32 a0 = 1;
1151 argQ = gMessageMsgVars[arg][printer->varBufferReadPos++];
1152 if (argQ >= MSG_CONTROL_CHAR) {
1153 s32 tmp;
1154
1155 switch (argQ) {
1156 case MSG_CHAR_READ_ENDL:
1157 if (gMessageMsgVars[arg][printer->varBufferReadPos] != MSG_CHAR_READ_END) {
1158 sp10[0] = MSG_CHAR_PRINT_ENDL;
1159 } else {
1160 a0 = 0;
1161 }
1162 break;
1168 printer->fontVariant = sp10[0] + 0x10F;
1169 break;
1170#if !VERSION_JP
1172 sp10[0] = MSG_CHAR_PRINT_SPACE;
1173 break;
1174#endif
1176 sp10[0] = MSG_CHAR_PRINT_FUNCTION;
1177 switch (gMessageMsgVars[arg][printer->varBufferReadPos++]) {
1179 sp10[1] = MSG_PRINT_FUNC_COLOR;
1180 sp10[2] = gMessageMsgVars[arg][printer->varBufferReadPos++];
1181 a0 = 3;
1182 break;
1184 sp10[1] = MSG_PRINT_FUNC_SAVE_COLOR;
1185 a0 = 2;
1186 break;
1189 a0 = 2;
1190 break;
1191 }
1192 break;
1193 }
1194 } else {
1195 sp10[0] = argQ;
1196 }
1197 for (i = 0; i < a0; i++) {
1198 arg1--;
1199 *printBuf++ = sp10[i];
1200 }
1201
1202 if (gMessageMsgVars[arg][printer->varBufferReadPos] == MSG_CHAR_READ_END) {
1203 srcBuf += 3;
1204 printer->varBufferReadPos = 0;
1205 printer->fontVariant = printer->unk_52A;
1206 *printBuf++ = MSG_CHAR_PRINT_VARIANT0 + printer->fontVariant;
1207 break;
1208 }
1209 } while ((printer->delayFlags & (MSG_DELAY_FLAG_4 | MSG_DELAY_FLAG_2)) || arg1 > 0);
1210
1211 if (!(printer->delayFlags & (MSG_DELAY_FLAG_4 | MSG_DELAY_FLAG_2)) && arg1 <= 0) {
1212 printer->delayFlags |= MSG_DELAY_FLAG_1;
1213 printer->curPrintDelay = printer->printDelayTime;
1214 }
1215 msg_play_speech_sound(printer, argQ);
1216 if (printer->stateFlags & MSG_STATE_FLAG_800000) {
1218 }
1219 break;
1221 arg = *srcBuf++;
1222 printer->speechSoundType = arg;
1223 printer->speechSoundIDA = MsgVoices[arg].voiceA;
1224 printer->speechSoundIDB = MsgVoices[arg].voiceB;
1225 printer->speechPitchShift = MsgVoices[arg].pitchShift;
1226 break;
1228 printer->volume = *srcBuf++;
1229 break;
1231 arg = *srcBuf++;
1232 argQ = *srcBuf++;
1233 argW = *srcBuf++;
1234 argE = *srcBuf++;
1235 printer->speechSoundIDA = (arg << 0x18) + (argQ << 0x10) + (argW << 0x8) + (argE);
1236 arg = *srcBuf++;
1237 argQ = *srcBuf++;
1238 argW = *srcBuf++;
1239 argE = *srcBuf++;
1240 printer->speechSoundIDB = (arg << 0x18) + (argQ << 0x10) + (argW << 0x8) + (argE);
1241 break;
1243 *printBuf++ = MSG_CHAR_PRINT_FUNCTION;
1244 *printBuf++ = MSG_PRINT_FUNC_CENTER_X;
1245 *printBuf++ = *srcBuf++;
1246 break;
1248 if (*srcBuf++) {
1249 printer->stateFlags |= MSG_STATE_FLAG_40000;
1250 } else {
1251 printer->stateFlags &= ~MSG_STATE_FLAG_40000;
1252 }
1253 break;
1255 printer->stateFlags |= MSG_STATE_FLAG_80000;
1256 break;
1257 }
1258 break;
1259 default:
1260 *printBuf++ = c;
1261 arg1--;
1262#if VERSION_IQUE
1263 if (c >= MSG_CHAR_MULTIBYTE_FIRST && c <= MSG_CHAR_MULTIBYTE_LAST) {
1264 *printBuf++ = nextArg;
1265 srcBuf++;
1266 arg1--;
1267 }
1268#endif
1269 if (printer->fontVariant == 0 && c == MSG_CHAR_UNK_C3) {
1270 printer->stateFlags &= ~MSG_STATE_FLAG_SPEAKING;
1271 } else {
1272 msg_play_speech_sound(printer, c);
1273 if (printer->stateFlags & MSG_STATE_FLAG_800000) {
1275 }
1276 }
1277 break;
1278 }
1279
1280 if (!(printer->delayFlags & (MSG_DELAY_FLAG_4 | MSG_DELAY_FLAG_2)) && arg1 <= 0) {
1281 printer->delayFlags |= MSG_DELAY_FLAG_1;
1282 printer->curPrintDelay = printer->printDelayTime;
1283 }
1284 if (!(printer->delayFlags & MSG_DELAY_FLAG_1)) {
1285 continue;
1286 }
1287 if (!s8) {
1288 break;
1289 }
1290 if (srcBuf[-1] == MSG_CHAR_READ_END) {
1291 break;
1292 }
1293 arg1 = 10000;
1294 } while (TRUE);
1295
1296 printer->printBufferPos = printBuf - printer->printBuffer;
1297 printer->delayFlags = 0;
1298 printer->srcBufferPos = (u16)(s32)(srcBuf - (s32)printer->srcBuffer);
1299 *printBuf = MSG_CHAR_PRINT_END;
1300}
1301#endif
1302
1303void initialize_printer(MessagePrintState* printer, s32 arg1, s32 arg2) {
1304 s32 i;
1305
1306 printer->printBufferSize = ARRAY_COUNT(printer->printBuffer);
1307 printer->printBuffer[0] = MSG_CHAR_PRINT_END;
1308 printer->printDelayTime = 1;
1309 printer->charsPerChunk = 1;
1310 printer->windowScrollRate = (s32)(6 / DT);
1311 printer->srcBuffer = NULL;
1312 printer->msgID = 0;
1313 printer->curPrintDelay = 0;
1314 printer->windowOffsetPos.x = 0;
1315 printer->windowOffsetPos.y = 0;
1316 printer->windowBasePos.x = 0;
1317 printer->windowBasePos.y = 0;
1319 printer->rewindArrowCounter = 0;
1320 printer->rewindArrowPos.x = 0;
1321 printer->rewindArrowPos.y = 0;
1322 printer->curLine = 0;
1323 printer->unkArraySize = 0;
1324 printer->maxOption = 0;
1325 printer->madeChoice = 0;
1326 printer->curOption = 0;
1327 printer->selectedOption = 0;
1328 printer->cancelOption = -1;
1330 printer->stateFlags = 0;
1331 printer->delayFlags = 0;
1332 printer->closedWritebackBool = NULL;
1333 printer->printBufferPos = 0;
1334 printer->srcBufferPos = 0;
1335 printer->font = 0;
1336 printer->fontVariant = 0;
1337 printer->effectFrameCounter = 0;
1338 printer->curLinePos = 0;
1339 printer->unk_46C = 0;
1340 printer->lineCount = 0;
1341
1342 for (i = 0; i < ARRAY_COUNT(printer->animTimers); i++) {
1343 printer->curAnimFrame[i] = 0;
1344 printer->animTimers[i] = -1;
1345 }
1346
1347 printer->initOpenPos.x = 160;
1348 printer->initOpenPos.y = 40;
1349 printer->speechSoundType = -1;
1350 printer->speechPan = 64;
1351 printer->volume = 75;
1352 printer->rewindArrowCounter = 0;
1353 printer->style = 0;
1354 printer->fadeInCounter = 0;
1355 printer->openStartPos.x = 0;
1356 printer->openStartPos.y = 0;
1357 printer->fadeOutCounter = 0;
1358 printer->windowSize.y = 0;
1359 printer->windowSize.x = 0;
1360 printer->speechPitchShift = 0;
1361 printer->speechSoundIDA = 0;
1362 printer->speechSoundIDB = 0;
1363 printer->varBufferReadPos = 0;
1364 printer->curImageIndex = 0;
1365 printer->varImageScreenPos.x = 0;
1366 printer->varImageScreenPos.y = 0;
1367 printer->varImgHasBorder = 0;
1368 printer->varImgFinalAlpha = 255;
1369 printer->varImageDisplayState = 0;
1370 printer->varImageFadeTimer = 0;
1371 printer->letterBackgroundImg = NULL;
1372 printer->letterBackgroundPal = NULL;
1373 printer->letterContentImg = NULL;
1374 printer->letterContentPal = NULL;
1375 printer->sizeScale = 1.0f;
1376}
1377
1378#if VERSION_PAL
1379void dma_load_msg(u32 msgID, void* dest) {
1380 u8* langPtr = D_PAL_8014AE50[gCurrentLanguage];
1381 u8* new_langPtr;
1382 u8* addr = (u8*) langPtr + (msgID >> 14); // (msgID >> 16) * 4
1383 u8* offset[2]; // start, end
1384
1385 dma_copy(addr, addr + 4, &offset[0]); // Load section offset
1386
1387 new_langPtr = langPtr;
1388 new_langPtr = offset[0] + ((u32) new_langPtr);
1389 addr = new_langPtr + ((msgID & 0xFFFF) * 4);
1390 dma_copy(addr, addr + 8, &offset); // Load message start and end offsets
1391
1392 // Load the msg data
1393 dma_copy(&langPtr[(u32)offset[0]], &langPtr[(u32)offset[1]], dest);
1394}
1395#else
1396void dma_load_msg(u32 msgID, void* dest) {
1397 u8* addr = (u8*) MSG_ROM_START + (msgID >> 14); // (msgID >> 16) * 4
1398 u8* offset[2]; // start, end
1399
1400 dma_copy(addr, addr + 4, &offset[0]); // Load section offset
1401
1402 addr = MSG_ROM_START + offset[0] + (msgID & 0xFFFF) * 4;
1403 dma_copy(addr, addr + 8, &offset); // Load message start and end offsets
1404
1405 // Load the msg data
1406 dma_copy(MSG_ROM_START + offset[0], MSG_ROM_START + offset[1], dest);
1407}
1408#endif
1409
1411 s8* prevBufferPos;
1412
1413 dma_load_msg(msgID, &gMessageBuffers[gNextMessageBuffer]);
1414 prevBufferPos = gMessageBuffers[gNextMessageBuffer];
1415
1417 if (gNextMessageBuffer >= ARRAY_COUNT(gMessageBuffers)) {
1419 }
1420
1421 return prevBufferPos;
1422}
1423
1424MessagePrintState* msg_get_printer_for_msg(s32 msgID, s32* donePrintingWriteback) {
1425 return _msg_get_printer_for_msg(msgID, donePrintingWriteback, 0);
1426}
1427
1428MessagePrintState* _msg_get_printer_for_msg(s32 msgID, s32* donePrintingWriteback, s32 arg2) {
1429 MessagePrintState* printer;
1430 s8* srcBuffer;
1431 s32 height;
1432 s32 width;
1433 s32 maxLineChars;
1434 s32 numLines;
1435 s32 maxLinesPerPage;
1436 s32 i;
1437
1438 if (msgID == MSG_NONE) {
1439 return NULL;
1440 }
1441
1442 srcBuffer = (s8*) msgID;
1443 if (msgID >= 0) {
1444 srcBuffer = load_message_to_buffer((s32)srcBuffer);
1445 }
1446
1447 for (i = 0; i < ARRAY_COUNT(gMessagePrinters); i++) {
1448 printer = &gMessagePrinters[i];
1449
1450 if (!(printer->stateFlags & MSG_STATE_FLAG_2)) {
1451 initialize_printer(printer, 1, arg2);
1453 printer->srcBuffer = srcBuffer;
1454 printer->msgID = msgID;
1455 printer->stateFlags |= MSG_STATE_FLAG_2;
1456 get_msg_properties(msgID, &height, &width, &maxLineChars, &numLines, &maxLinesPerPage, NULL, 0);
1457 printer->msgHeight = height;
1458 printer->msgWidth = width;
1459 printer->maxLineChars = maxLineChars;
1460 printer->numLines = numLines;
1461 printer->maxLinesPerPage = maxLinesPerPage;
1462 printer->closedWritebackBool = donePrintingWriteback;
1463
1464 if (donePrintingWriteback != NULL) {
1465 *donePrintingWriteback = FALSE;
1466 }
1467 return printer;
1468 }
1469 }
1470
1471 return NULL;
1472}
1473
1474s32 msg_printer_load_msg(s32 msgID, MessagePrintState* printer) {
1475 s8* buffer;
1476
1477 if (msgID >= 0) {
1478 buffer = load_message_to_buffer(msgID);
1479 } else {
1480 buffer = (s8*) msgID;
1481 }
1482
1483 printer->srcBuffer = buffer;
1484 printer->srcBufferPos = 0;
1485 printer->stateFlags &= ~MSG_STATE_FLAG_40;
1486 return 1;
1487}
1488
1489void msg_printer_set_origin_pos(MessagePrintState* msgPrintState, s32 x, s32 y) {
1490 msgPrintState->initOpenPos.x = x;
1491 msgPrintState->initOpenPos.y = y;
1492
1493 if (msgPrintState->initOpenPos.x < 0) {
1494 msgPrintState->initOpenPos.x = 0;
1495 }
1496 if (msgPrintState->initOpenPos.x > SCREEN_WIDTH) {
1497 msgPrintState->initOpenPos.x = SCREEN_WIDTH;
1498 }
1499 if (msgPrintState->initOpenPos.y < 0) {
1500 msgPrintState->initOpenPos.y = 0;
1501 }
1502 if (msgPrintState->initOpenPos.y > 220) {
1503 msgPrintState->initOpenPos.y = 220;
1504 }
1505}
1506
1508 if (!(msgPrintState->stateFlags & MSG_STATE_FLAG_2)) {
1509 return FALSE;
1510 }
1511
1512 msgPrintState->stateFlags |= MSG_STATE_FLAG_1;
1513 return TRUE;
1514}
1515
1517 *gMsgVarImages = images;
1518}
1519
1520void set_message_text_var(s32 msgID, s32 index) {
1521 u8* mallocSpace = NULL;
1522 s32 i;
1523 u8* msgVars;
1524
1525 if (msgID >= 0) {
1526 mallocSpace = general_heap_malloc(0x400);
1527 dma_load_msg(msgID, mallocSpace);
1528 msgID = (s32)mallocSpace;
1529 }
1530
1531 i = 0;
1532 msgVars = gMessageMsgVars[index];
1533 while (TRUE) {
1534 msgVars[i] = ((u8*)msgID)[i];
1535 if (((u8*)msgID)[i] == MSG_CHAR_READ_END) {
1536 break;
1537 }
1538
1539 if (++i >= 32) {
1540 msgVars[i - 1] = MSG_CHAR_READ_END;
1541 break;
1542 }
1543 }
1544
1545 if (mallocSpace != NULL) {
1546 general_heap_free(mallocSpace);
1547 }
1548}
1549
1550void set_message_int_var(s32 value, s32 index) {
1551 s8 strBuffer[ARRAY_COUNT(gMessageMsgVars[index])];
1552 s8* bufferIt;
1553 s32 i;
1554
1555 int_to_string(value, strBuffer, 10);
1556
1557 for (i = 0, bufferIt = strBuffer; i < ARRAY_COUNT(gMessageMsgVars[index]) - 1; i++) {
1558 s8 thisChar = bufferIt[i];
1559
1560 if (thisChar == 0) {
1561 break;
1562 }
1563 gMessageMsgVars[index][i] = thisChar - '0' + MSG_CHAR_DIGIT_0;
1564 }
1565 gMessageMsgVars[index][i] = MSG_CHAR_READ_END;
1566}
1567
1568void close_message(MessagePrintState* msgPrintState) {
1569 msgPrintState->stateFlags &= ~MSG_STATE_FLAG_40;
1570}
1571
1572#if VERSION_JP
1573#define CHAR_SPACE_MULTIPLIER 0.7
1574#else
1575#define CHAR_SPACE_MULTIPLIER 0.6
1576#endif
1577
1578s32 msg_get_print_char_width(s32 character, s32 charset, s32 variation, f32 msgScale, s32 overrideCharWidth, u8 flags) {
1579 f32 charWidth;
1580
1581 if (character >= MSG_CONTROL_CHAR
1582 && (character != MSG_CHAR_READ_SPACE
1583 && character != MSG_CHAR_READ_FULL_SPACE
1584 && character != MSG_CHAR_READ_HALF_SPACE)) {
1585 return 0;
1586 }
1587
1588#if VERSION_IQUE
1589 if (character >= MSG_CHAR_MULTIBYTE_FIRST && character <= MSG_CHAR_MULTIBYTE_LAST) {
1590 charWidth = 16.0;
1591 return charWidth * msgScale;
1592 }
1593#endif
1594
1595 if (overrideCharWidth != 0) {
1596 charWidth = overrideCharWidth;
1597 } else if (flags != 0) {
1598 u8* charWidthTable = MsgCharsets[charset]->rasters[variation].charWidthTable;
1599
1600 if (charWidthTable != NULL
1601 && character != MSG_CHAR_READ_SPACE
1602 && character != MSG_CHAR_READ_FULL_SPACE
1603 && character != MSG_CHAR_READ_HALF_SPACE) {
1604 charWidth = charWidthTable[character];
1605 } else {
1606 charWidth = MsgCharsets[charset]->rasters[variation].monospaceWidth;
1607 }
1608 } else {
1609 charWidth = MsgCharsets[charset]->rasters[variation].monospaceWidth;
1610 }
1611
1612 if (character == MSG_CHAR_READ_SPACE) {
1613 return charWidth * msgScale * CHAR_SPACE_MULTIPLIER;
1614 }
1615 if (character == MSG_CHAR_READ_FULL_SPACE) {
1616 f64 retWidth = charWidth * msgScale;
1617 return retWidth;
1618 }
1619 if (character == MSG_CHAR_READ_HALF_SPACE) {
1620 return charWidth * msgScale * 0.5;
1621 }
1622 if (character >= MSG_CONTROL_CHAR) {
1623 return 0;
1624 }
1625 return charWidth * msgScale;
1626}
1627
1628s32 msg_get_draw_char_width(s32 character, s32 charset, s32 variation, f32 msgScale, s32 overrideCharWidth, u16 flags) {
1629 f32 baseWidth;
1630
1631 if (character >= MSG_CONTROL_CHAR
1632 && (character != MSG_CHAR_PRINT_SPACE
1633 && character != MSG_CHAR_PRINT_FULL_SPACE
1634 && character != MSG_CHAR_PRINT_HALF_SPACE)) {
1635 return 0;
1636 }
1637
1638 if (overrideCharWidth != 0) {
1639 baseWidth = overrideCharWidth;
1640 } else if (flags & MSG_PRINT_FLAG_100) {
1641 u8* charWidthTable = MsgCharsets[charset]->rasters[variation].charWidthTable;
1642
1643 if (charWidthTable != NULL
1644 && character != MSG_CHAR_PRINT_SPACE
1645 && character != MSG_CHAR_PRINT_FULL_SPACE
1646 && character != MSG_CHAR_PRINT_HALF_SPACE) {
1647 baseWidth = charWidthTable[character];
1648 } else {
1649 baseWidth = MsgCharsets[charset]->rasters[variation].monospaceWidth;
1650 }
1651 } else {
1652 baseWidth = MsgCharsets[charset]->rasters[variation].monospaceWidth;
1653 }
1654
1655 if (character == MSG_CHAR_PRINT_SPACE) {
1656 return baseWidth * msgScale * CHAR_SPACE_MULTIPLIER;
1657 }
1658 if (character == MSG_CHAR_PRINT_FULL_SPACE) {
1659 f64 charWidth = baseWidth * msgScale;
1660 return charWidth;
1661 }
1662 if (character == MSG_CHAR_PRINT_HALF_SPACE) {
1663 return baseWidth * msgScale * 0.5;
1664 }
1665 if (character >= MSG_CONTROL_CHAR) {
1666 return 0;
1667 }
1668 return baseWidth * msgScale;
1669}
1670
1671void get_msg_properties(s32 msgID, s32* height, s32* width, s32* maxLineChars, s32* numLines, s32* maxLinesPerPage, s32* numSpaces, u16 charset) {
1672 u8* message;
1673 s32 i;
1674 u16 pageCount;
1675 s32 linesOnPage;
1676 u8 stop;
1677 s32 lineWidth;
1678 s32 charCount;
1679 u16 lineIndex;
1680 s32 msgStyle;
1681 s32 functionCode;
1682 u8 packedScaleY;
1683 f32 scale;
1684 s32 temp;
1685
1686 u16 lineWidths[32];
1687 u16 lineCharNumbers[32];
1688 u16 linesPerPage[32];
1689 s32 lineCount;
1690 u16 varIndex;
1691 u16 font;
1692 u8* buffer;
1693 u16 maxLineWidth;
1694 u16 maxCharsPerLine;
1695 u16 maxLinesOnPage;
1696 u16 spaceCount;
1697 u16 endl;
1698
1699 u8 c;
1700 u8 prevChar;
1701
1702 scale = 1.0f;
1703 c = 0;
1704 lineIndex = 0;
1705 pageCount = 0;
1706 varIndex = 0;
1707 font = 0;
1708 buffer = NULL;
1709 maxLineWidth = 0;
1710 maxCharsPerLine = 0;
1711 maxLinesOnPage = 0;
1712 spaceCount = 0;
1713
1714 if (msgID == MSG_NONE) {
1715 return;
1716 }
1717
1718 if (msgID >= 0) {
1719 buffer = general_heap_malloc(0x400);
1720 dma_load_msg(msgID, buffer);
1721 message = buffer;
1722 } else {
1723 message = (u8*)msgID;
1724 }
1725
1726 if (charset & 1) {
1727 font = 1;
1728 }
1729
1730 i = 0;
1731 stop = FALSE;
1732 lineWidth = 0;
1733 linesOnPage = 0;
1734 charCount = 0;
1735 endl = TRUE;
1736 lineCount = 0;
1737
1738 do {
1739 prevChar = c;
1740 c = message[i++];
1741 switch (c) {
1746 varIndex = c - MSG_CHAR_READ_VARIANT0;
1747 break;
1749 i++;
1750 break;
1751 case MSG_CHAR_READ_WAIT:
1752 case MSG_CHAR_READ_NEXT:
1753 if (linesOnPage != 0) {
1754 linesPerPage[pageCount] = linesOnPage;
1755 pageCount++;
1756 if (pageCount >= 32) {
1757 stop = 1;
1758 }
1759 linesOnPage = 0;
1760 }
1761 break;
1762 case MSG_CHAR_READ_ENDL:
1763 lineWidths[lineIndex] = lineWidth;
1764 lineCharNumbers[lineIndex] = charCount;
1765 lineIndex++;
1766 if (lineIndex >= 32) {
1767 stop = 1;
1768 }
1769 lineWidth = 0;
1770 charCount = 0;
1771 endl = TRUE;
1772 break;
1774 msgStyle = message[i++];
1775 switch (msgStyle) {
1776 case MSG_STYLE_CHOICE:
1777 i += 4;
1778 break;
1779 case MSG_STYLE_POSTCARD:
1780 i++;
1781 break;
1782 case MSG_STYLE_RIGHT:
1783 case MSG_STYLE_LEFT:
1784 case MSG_STYLE_CENTER:
1785 case MSG_STYLE_TATTLE:
1786 case MSG_STYLE_INSPECT:
1787 case MSG_STYLE_SIGN:
1788 case MSG_STYLE_LAMPPOST:
1789 case MSG_STYLE_POPUP:
1790 case MSG_STYLE_B:
1791 break;
1792 }
1793 break;
1794 case MSG_CHAR_READ_END:
1795 lineWidths[lineIndex] = lineWidth;
1796 lineCharNumbers[lineIndex] = charCount;
1797 lineIndex++;
1798 stop = TRUE;
1799 break;
1801 functionCode = message[i++];
1802 switch (functionCode) {
1803 case MSG_READ_FUNC_FONT:
1804 font = message[i++];
1805 break;
1817 break;
1818 default:
1819 stop = TRUE;
1820 break;
1822 i++;
1823 // fallthrough
1824 temp = 4;
1826 i += temp;
1827 // fallthrough
1830 i++;
1831 // fallthrough
1835 i++;
1836 // fallthrough
1842 case MSG_READ_FUNC_DOWN:
1843 case MSG_READ_FUNC_UP:
1855 i++;
1856 break;
1858 if (message[i] == 0) {
1859 stop = TRUE;
1860 }
1861 i++;
1862 break;
1864 if (message[i] == MSG_CHAR_READ_END) {
1865 stop = TRUE;
1866 }
1867 break;
1868 case MSG_READ_FUNC_SIZE:
1869 packedScaleY = message[i + 1];
1870 i += 2;
1871 scale = (f32)(packedScaleY >> 4) + ((packedScaleY & 0xF) * 0.0625f);
1872 break;
1874 scale = 1.0f;
1875 break;
1877 switch (message[i++]) {
1878 case MSG_FX_STATIC:
1879 case MSG_FX_BLUR:
1880 case MSG_FX_DITHER_FADE:
1881 i++;
1882 break;
1883 case MSG_FX_SHAKE:
1884 case MSG_FX_WAVE:
1886 case MSG_FX_RAINBOW:
1887 case MSG_FX_GLOBAL_WAVE:
1889 case MSG_FX_RISE_PRINT:
1890 case MSG_FX_GROW_PRINT:
1891 case MSG_FX_SIZE_JITTER:
1892 case MSG_FX_SIZE_WAVE:
1893 case MSG_FX_DROP_SHADOW:
1894 break;
1895 }
1896 break;
1897 case MSG_READ_FUNC_VAR:
1898 lineWidth += get_msg_width((s32)gMessageMsgVars[message[i++]], 0);
1899 break;
1900 }
1901 break;
1903 break;
1907 spaceCount++;
1908 // fallthrough
1909 default:
1910 if (endl) {
1911 lineCount++;
1912 linesOnPage++;
1913 endl = FALSE;
1914 }
1915
1916#if VERSION_IQUE
1917 if (prevChar >= MSG_CHAR_MULTIBYTE_FIRST && prevChar <= MSG_CHAR_MULTIBYTE_LAST) {
1918 break;
1919 }
1920#endif
1921
1922 lineWidth += msg_get_print_char_width(c, font, varIndex, scale, 0, 1);
1923 charCount++;
1924 break;
1925 }
1926 } while (!stop);
1927
1928 if (buffer != NULL) {
1929 general_heap_free(buffer);
1930 }
1931
1932 for (i = 0; i < lineIndex; i++) {
1933 if (maxLineWidth < lineWidths[i]) {
1934 maxLineWidth = lineWidths[i];
1935 }
1936 if (maxCharsPerLine < lineCharNumbers[i]) {
1937 maxCharsPerLine = lineCharNumbers[i];
1938 }
1939 }
1940
1941 if (pageCount == 0) {
1942 maxLinesOnPage = linesOnPage;
1943 } else {
1944 for (i = 0; i < pageCount; i++) {
1945 if (maxLinesOnPage < linesPerPage[i]) {
1946 maxLinesOnPage = linesPerPage[i];
1947 }
1948 }
1949 }
1950
1951 if (width != NULL) {
1952 *width = maxLineWidth;
1953 }
1954 if (height != NULL) {
1955 *height = lineCount * MsgCharsets[font]->newLineY;
1956 }
1957 if (maxLineChars != NULL) {
1958 *maxLineChars = maxCharsPerLine;
1959 }
1960 if (numLines != NULL) {
1961 *numLines = lineCount;
1962 }
1963 if (maxLinesPerPage != NULL) {
1964 *maxLinesPerPage = maxLinesOnPage;
1965 }
1966 if (numSpaces != NULL) {
1967 *numSpaces = spaceCount;
1968 }
1969}
1970
1971s32 get_msg_width(s32 msgID, u16 charset) {
1972 s32 width;
1973
1974 get_msg_properties(msgID, NULL, &width, NULL, NULL, NULL, NULL, charset);
1975 return width;
1976}
1977
1978#if !VERSION_JP
1979s32 get_msg_lines(s32 msgID) {
1980 s32 numLines;
1981
1982 get_msg_properties(msgID, NULL, NULL, NULL, &numLines, NULL, NULL, 0);
1983 return numLines;
1984}
1985#endif
1986
1987void draw_msg(s32 msgID, s32 posX, s32 posY, s32 opacity, s32 palette, u8 style) {
1988 MessagePrintState stackPrinter;
1989 MessagePrintState* printer;
1990 u16 bufferPos;
1991 s8* mallocSpace;
1992 s32 charset;
1993 u16 flags;
1994 s32 width;
1995
1996 flags = 0;
1997 bufferPos = 0;
1998 mallocSpace = NULL;
1999 charset = 0;
2000
2001 if (msgID != 0) {
2002 if (style & DRAW_MSG_STYLE_MENU) {
2003 flags = 2;
2004 charset = 1;
2005 }
2006
2007 if (opacity < 0xFF) {
2008 flags |= 1;
2009 }
2010
2011 printer = &stackPrinter;
2012 initialize_printer(printer, 1, 0);
2013
2014 if (msgID < 0) {
2015 printer->srcBuffer = (u8*)msgID;
2016 } else {
2017 mallocSpace = general_heap_malloc(0x400);
2018 dma_load_msg(msgID, mallocSpace);
2019 printer->srcBuffer = mallocSpace;
2020 get_msg_properties((s32) printer->srcBuffer, 0, &width, 0, 0, 0, 0, charset);
2021 printer->msgWidth = width;
2022 }
2023
2024 if (palette >= 0) {
2025 printer->printBuffer[bufferPos++] = MSG_CHAR_PRINT_FUNCTION;
2026 printer->printBuffer[bufferPos++] = MSG_PRINT_FUNC_COLOR;
2027 printer->printBuffer[bufferPos++] = palette;
2028 printer->printBufferPos += 3;
2029 }
2030
2031 if (style & DRAW_MSG_STYLE_WAVY) {
2032 printer->printBuffer[bufferPos++] = MSG_CHAR_PRINT_FUNCTION;
2033 printer->printBuffer[bufferPos++] = MSG_PRINT_FUNC_START_FX;
2034 printer->printBuffer[bufferPos++] = MSG_FX_GLOBAL_WAVE;
2035 printer->printBufferPos += 3;
2036 }
2037
2038 if (style & DRAW_MSG_STYLE_RAINBOW) {
2039 printer->printBuffer[bufferPos++] = MSG_CHAR_PRINT_FUNCTION;
2040 printer->printBuffer[bufferPos++] = MSG_PRINT_FUNC_START_FX;
2041 printer->printBuffer[bufferPos++] = MSG_FX_GLOBAL_RAINBOW;
2042 printer->printBufferPos += 3;
2043 }
2044
2045 if (style & DRAW_MSG_STYLE_DROP_SHADOW) {
2046 printer->printBuffer[bufferPos++] = MSG_CHAR_PRINT_FUNCTION;
2047 printer->printBuffer[bufferPos++] = MSG_PRINT_FUNC_START_FX;
2048 printer->printBuffer[bufferPos++] = MSG_FX_DROP_SHADOW;
2049 printer->printBufferPos += 3;
2050 }
2051
2052 msg_copy_to_print_buffer(printer, 10000, 1);
2053 appendGfx_message(printer, (s16)posX, (s16)posY, 0, 0, flags, opacity & 0xFF);
2054
2055 if (mallocSpace != NULL) {
2056 general_heap_free(mallocSpace);
2057 }
2058 }
2059}
2060
2061void msg_update_rewind_arrow(s32 printerIndex) {
2062 MessagePrintState* printer = &gMessagePrinters[printerIndex];
2063 f32 angle = 0.0f;
2064 f32 scale = 1.0f;
2065 f32 colorG = 255.0f;
2066 f32 colorR = 255.0f;
2067 f32 colorB = 255.0f;
2068 Matrix4f sp18;
2069 Matrix4f sp58;
2070 f32 temp;
2071
2072 gDPPipeSync(gMainGfxPos++);
2073 gSPDisplayList(gMainGfxPos++, D_8014C2D8);
2074
2075 switch (printer->rewindArrowAnimState) {
2077 printer->rewindArrowCounter = 0;
2078 printer->rewindArrowSwingPhase = 0;
2080 // fallthrough
2082 temp = printer->rewindArrowCounter;
2083 scale = temp * 0.2 + 0.5;
2084 if (++printer->rewindArrowCounter >= 4) {
2085 printer->rewindArrowCounter = 0;
2087 }
2088 break;
2090 if (++printer->rewindArrowCounter >= 25) {
2091 printer->rewindArrowCounter = 0;
2093 }
2094 break;
2096 colorR = update_lerp(EASING_LINEAR, 255.0f, 224.0f, printer->rewindArrowCounter, 15);
2097 colorG = update_lerp(EASING_LINEAR, 255.0f, 224.0f, printer->rewindArrowCounter, 15);
2098 colorB = update_lerp(EASING_LINEAR, 255.0f, 208.0f, printer->rewindArrowCounter, 15);
2099 if (++printer->rewindArrowCounter >= 15) {
2100 printer->rewindArrowCounter = 0;
2102 }
2103 break;
2105 colorR = update_lerp(EASING_LINEAR, 224.0f, 255.0f, printer->rewindArrowCounter, 15);
2106 colorG = update_lerp(EASING_LINEAR, 224.0f, 255.0f, printer->rewindArrowCounter, 15);
2107 colorB = update_lerp(EASING_LINEAR, 208.0f, 255.0f, printer->rewindArrowCounter, 15);
2108 if (++printer->rewindArrowCounter >= 15) {
2109 printer->rewindArrowCounter = 0;
2111 }
2112 break;
2113 }
2114
2115 gDPSetPrimColor(gMainGfxPos++, 0, 0, colorR, colorG, colorB, 255);
2116
2120 angle = cosine(printer->rewindArrowSwingPhase) * 30.0f;
2121 printer->rewindArrowSwingPhase += 15;
2122 if (printer->rewindArrowSwingPhase >= 360) {
2123 printer->rewindArrowSwingPhase -= 360;
2124 }
2125 }
2126
2127 guTranslateF(sp18, printer->rewindArrowPos.x + 12, -(printer->rewindArrowPos.y + 12), 0);
2128 if (angle != 0.0) {
2129 guRotateF(sp58, angle, 0, 0, 1.0f);
2130 guMtxCatF(sp58, sp18, sp18);
2131 }
2132 if (scale != 1.0) {
2133 guScaleF(sp58, scale, scale, 1.0f);
2134 guMtxCatF(sp58, sp18, sp18);
2135 }
2136
2138 gSPMatrix(gMainGfxPos++, VIRTUAL_TO_PHYSICAL(&gDisplayContext->matrixStack[gMatrixListPos++]), G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
2139 gDPLoadTextureTile(gMainGfxPos++, ui_msg_star_png, G_IM_FMT_RGBA, G_IM_SIZ_16b, 16, 0, 0, 0, 15, 17, 0, G_TX_MIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, 4, G_TX_NOLOD, G_TX_NOLOD);
2140 gDPLoadMultiTile_4b(gMainGfxPos++, ui_msg_star_silhouette_png, 0x0100, 1, G_IM_FMT_I, 16, 0, 0, 0, 15, 18, 0, G_TX_MIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, 5, G_TX_NOLOD, G_TX_NOLOD);
2141 gSPVertex(gMainGfxPos++, gRewindArrowQuad, 4, 0);
2142 gSP2Triangles(gMainGfxPos++, 0, 2, 1, 0, 1, 2, 3, 0);
2143}
2144
2145void msg_draw_rewind_arrow(s32 printerIndex) {
2146 MessagePrintState* printer = &gMessagePrinters[printerIndex];
2147
2148 if (printer->rewindArrowCounter < 6) {
2150 printer->rewindArrowPos.y, 10, 10, SCREEN_WIDTH - 20, SCREEN_HEIGHT - 20, 255);
2151 }
2152
2153 printer->rewindArrowCounter++;
2154 if (printer->rewindArrowCounter >= 12) {
2155 printer->rewindArrowCounter = 0;
2156 }
2157}
2158
2160 s32 pointerAlpha = 255;
2161 s32 shadowAlpha = 72;
2162 s32 posInterpPhase = gGameStatusPtr->frameCounter % 360;
2163 s32 posX, posY;
2164
2166 posX = printer->windowOffsetPos.x + printer->windowBasePos.x + printer->cursorPosX[printer->selectedOption];
2167 posY = printer->windowOffsetPos.y + printer->windowBasePos.y + printer->cursorPosY[printer->selectedOption];
2168 } else {
2169 s32 baseX, baseY, targetX, targetY;
2170 f32 moveToTargetAlpha = (f32)(printer->scrollingTime + 1.0) / CHOICE_POINTER_MOVE_RATE;
2171
2172 baseX = printer->windowOffsetPos.x + printer->windowBasePos.x + printer->cursorPosX[printer->selectedOption];
2173 targetX = printer->windowOffsetPos.x + printer->windowBasePos.x + printer->cursorPosX[printer->targetOption];
2174 posX = baseX + (targetX - baseX) * moveToTargetAlpha;
2175
2176 baseY = printer->windowOffsetPos.y + printer->windowBasePos.y + printer->cursorPosY[printer->selectedOption];
2177 targetY = printer->windowOffsetPos.y + printer->windowBasePos.y + printer->cursorPosY[printer->targetOption];
2178 posY = baseY + (targetY - baseY) * moveToTargetAlpha;
2179 }
2180
2181 posY += 1;
2182 posX += (cosine(posInterpPhase * 38 + 270) + 1.0) * 0.5 * 3.2;
2183 posX -= 2;
2184
2185 if (printer->stateFlags & MSG_STATE_FLAG_20000) {
2186 u32 opacity;
2187 opacity = 255.0 - printer->fadeOutCounter * 46.0;
2188 pointerAlpha = opacity;
2189 opacity = 72.0 - printer->fadeOutCounter * 14.4;
2190 shadowAlpha = opacity;
2191 }
2192
2193 gDPPipeSync(gMainGfxPos++);
2194 gDPSetTextureLUT(gMainGfxPos++, G_TT_RGBA16);
2195 gDPLoadTLUT_pal16(gMainGfxPos++, 0, ui_point_right_pal);
2196 gDPSetRenderMode(gMainGfxPos++, G_RM_XLU_SURF, G_RM_XLU_SURF2);
2197 gDPSetCombineMode(gMainGfxPos++, PM_CC_07, PM_CC_07);
2198 gDPSetPrimColor(gMainGfxPos++, 0, 0, 40, 40, 40, shadowAlpha);
2199 draw_image_with_clipping(ui_point_right_png, 16, 16, G_IM_FMT_CI, G_IM_SIZ_4b, posX + 2, posY + 2, 10, 10, 300, 220);
2200 draw_ci_image_with_clipping(ui_point_right_png, 16, 16, G_IM_FMT_CI, G_IM_SIZ_4b, ui_point_right_pal, posX, posY, 20, 20, 300, 200, pointerAlpha);
2201}
2202
2203void draw_digit(IMG_PTR img, s32 charset, s32 posX, s32 posY) {
2204 MessageNumber* num = &gMsgNumbers[charset];
2205
2206 gDPLoadTextureTile_4b(gMainGfxPos++,
2207 img, G_IM_FMT_CI,
2208 num->texWidth , num->texHeight,
2209 0, 0,
2210 num->texWidth - 1, num->texHeight - 1,
2211 0,
2212 G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP,
2213 G_TX_NOMASK, G_TX_NOMASK,
2214 G_TX_NOLOD, G_TX_NOLOD);
2215 gSPTextureRectangle(gMainGfxPos++,
2216 4 * posX, 4 * posY,
2217 4 * (posX + num->texWidth), 4 * (posY + num->texHeight),
2218 G_TX_RENDERTILE,
2219 0, 0,
2220 1 << 10, 1 << 10);
2221}
2222
2223void draw_number(s32 value, s32 x, s32 y, s32 charset, s32 palette, s32 opacity, u16 style) {
2224 u8 valueStr[24];
2225 s8 digits[24];
2226 s32 digitPosX[24];
2227 s32 i;
2228 s32 count;
2229 s32 posX;
2230 IMG_PTR raster = gMsgNumbers[charset].rasters;
2231 s32 texSize = gMsgNumbers[charset].texSize;
2232
2233#if !VERSION_JP
2234 y -= 2;
2235#endif
2236 if (y < 0 || y > 240) {
2237 return;
2238 }
2239
2240 int_to_string(value, valueStr, 10);
2241
2242 for (i = 0; i < 10; i++) {
2243 u8 digit;
2244 if (valueStr[i] == '\0') {
2245 break;
2246 }
2247
2248 // handle negative numbers
2249 if (valueStr[i] == '-') {
2250 digits[i] = MSG_CHAR_MINUS - MSG_CHAR_DIGIT_0;
2251 continue;
2252 }
2253
2254 digit = valueStr[i] - '0';
2255 if (digit < 10){
2256 digits[i] = digit;
2257 }
2258 }
2259 posX = x;
2260 count = i;
2261
2262 gSPDisplayList(gMainGfxPos++, gMsgDlistInitDrawNumber);
2263
2264 if (style & DRAW_NUMBER_STYLE_ALIGN_RIGHT) {
2265 for (i = count - 1; i >= 0; i--) {
2266 if ((style & DRAW_NUMBER_STYLE_MONOSPACE) || digits[i] < 0) {
2267 posX -= gMsgNumbers[charset].fixedWidth;
2268 } else {
2269 posX -= gMsgNumbers[charset].digitWidth[digits[i]];
2270 }
2271 digitPosX[i] = posX;
2272 }
2273 } else {
2274 for (i = 0; i < count; i++) {
2275 digitPosX[i] = posX;
2276 if ((style & DRAW_NUMBER_STYLE_MONOSPACE) || digits[i] < 0) {
2277 posX += gMsgNumbers[charset].fixedWidth;
2278 } else {
2279 posX += gMsgNumbers[charset].digitWidth[digits[i]];
2280 }
2281 }
2282 }
2283
2284 if (style & DRAW_NUMBER_STYLE_DROP_SHADOW) {
2285 for (i = 0; i < count; i++) {
2286 gDPPipeSync(gMainGfxPos++);
2287 gDPSetRenderMode(gMainGfxPos++, G_RM_XLU_SURF, G_RM_XLU_SURF2);
2288 gDPSetCombineMode(gMainGfxPos++, PM_CC_07, PM_CC_07);
2289 gDPSetPrimColor(gMainGfxPos++, 0, 0, 40, 40, 40, 72);
2290 draw_digit(raster + digits[i] * texSize, charset, digitPosX[i] + 2, y + 2);
2291 gDPPipeSync(gMainGfxPos++);
2292 }
2293 }
2294
2295 if (opacity == 255) {
2296 gDPSetRenderMode(gMainGfxPos++, G_RM_TEX_EDGE, G_RM_TEX_EDGE2);
2297 gDPSetCombineMode(gMainGfxPos++, G_CC_DECALRGBA, G_CC_DECALRGBA);
2298 } else {
2299 gDPSetRenderMode(gMainGfxPos++, G_RM_XLU_SURF, G_RM_XLU_SURF2);
2300 gDPSetCombineMode(gMainGfxPos++, PM_CC_01, PM_CC_01);
2301 gDPSetPrimColor(gMainGfxPos++, 0, 0, 255, 255, 255, opacity);
2302 }
2303
2304 gDPLoadTLUT_pal16(gMainGfxPos++, 0, D_802F4560[palette]);
2305 for (i = 0; i < count; i++) {
2306 posX = digitPosX[i];
2307 if (posX > 0 && posX < 320) {
2308 draw_digit(raster + digits[i] * texSize, charset, posX, y);
2309 }
2310 }
2311 gDPPipeSync(gMainGfxPos++);
2312}
unsigned char charset_standard_pal_OFFSET[]
unsigned char charset_postcard_OFFSET[]
unsigned short charset_postcard_pal_OFFSET[]
unsigned char charset_standard_OFFSET[]
unsigned char charset_subtitle_pal_OFFSET[]
unsigned char charset_subtitle_OFFSET[]
unsigned char charset_title_OFFSET[]
u32 pressedButtons[4]
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 general_heap_malloc
#define guRotateF
#define get_msg_width
#define guMtxF2L
#define guTranslateF
#define guMtxCatF
#define rand_int
#define draw_msg
#define guScaleF
@ DRAW_MSG_STYLE_DROP_SHADOW
Definition enums.h:5388
@ DRAW_MSG_STYLE_MENU
Definition enums.h:5385
@ DRAW_MSG_STYLE_RAINBOW
Definition enums.h:5387
@ DRAW_MSG_STYLE_WAVY
Definition enums.h:5386
@ DRAW_NUMBER_STYLE_ALIGN_RIGHT
drawn to the left of posX
Definition enums.h:5393
@ DRAW_NUMBER_STYLE_DROP_SHADOW
Definition enums.h:5396
@ DRAW_NUMBER_STYLE_MONOSPACE
Definition enums.h:5394
@ MSG_STATE_FLAG_10000
Definition enums.h:6252
@ MSG_STATE_FLAG_4
Definition enums.h:6241
@ MSG_STATE_FLAG_40
Definition enums.h:6244
@ MSG_STATE_FLAG_PRINT_QUICKLY
Definition enums.h:6246
@ MSG_STATE_FLAG_1
Definition enums.h:6239
@ MSG_STATE_FLAG_80000
Definition enums.h:6255
@ MSG_STATE_FLAG_10
Definition enums.h:6242
@ MSG_STATE_FLAG_20
Definition enums.h:6243
@ MSG_STATE_FLAG_100000
Definition enums.h:6256
@ MSG_STATE_FLAG_800
Definition enums.h:6248
@ MSG_STATE_FLAG_800000
Definition enums.h:6257
@ MSG_STATE_FLAG_20000
Definition enums.h:6253
@ MSG_STATE_FLAG_40000
Definition enums.h:6254
@ MSG_STATE_FLAG_8000
Definition enums.h:6251
@ MSG_STATE_FLAG_1000
Definition enums.h:6249
@ MSG_STATE_FLAG_SPEAKING
Definition enums.h:6245
@ MSG_STATE_FLAG_2
Definition enums.h:6240
@ BUTTON_A
Definition enums.h:2790
@ BUTTON_C_DOWN
Definition enums.h:2779
@ BUTTON_STICK_UP
Definition enums.h:2791
@ BUTTON_STICK_DOWN
Definition enums.h:2792
@ BUTTON_B
Definition enums.h:2789
@ BUTTON_Z
Definition enums.h:2788
@ MSG_PRINT_FUNC_RIGHT
Definition enums.h:6141
@ MSG_READ_FUNC_COLOR
Definition enums.h:6087
@ MSG_READ_FUNC_CURSOR
Definition enums.h:6112
@ MSG_READ_FUNC_RESTORE_COLOR
Definition enums.h:6119
@ MSG_READ_FUNC_VOLUME
Definition enums.h:6127
@ MSG_READ_FUNC_RESET_GFX
Definition enums.h:6085
@ MSG_PRINT_FUNC_UP
Definition enums.h:6143
@ MSG_READ_FUNC_START_FX
Definition enums.h:6120
@ MSG_READ_FUNC_INPUT_OFF
Definition enums.h:6089
@ MSG_PRINT_FUNC_COLOR
Definition enums.h:6134
@ MSG_PRINT_FUNC_OPTION
Definition enums.h:6151
@ MSG_READ_FUNC_VAR
Definition enums.h:6122
@ MSG_READ_FUNC_VARIANT
Definition enums.h:6083
@ MSG_READ_FUNC_SET_CURSOR
Definition enums.h:6111
@ MSG_READ_FUNC_SET_CANCEL
Definition enums.h:6114
@ MSG_READ_FUNC_DELAY_OFF
Definition enums.h:6091
@ 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_READ_FUNC_SAVE_COLOR
Definition enums.h:6118
@ MSG_READ_FUNC_VOICE
Definition enums.h:6128
@ MSG_READ_FUNC_SAVE_POS
Definition enums.h:6116
@ MSG_READ_FUNC_CUSTOM_VOICE
Definition enums.h:6126
@ MSG_PRINT_FUNC_ANIM_DELAY
Definition enums.h:6147
@ MSG_READ_FUNC_INLINE_IMAGE
Definition enums.h:6103
@ MSG_READ_FUNC_SET_X
Definition enums.h:6098
@ 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_READ_FUNC_END_FX
Definition enums.h:6121
@ MSG_READ_FUNC_SET_Y
Definition enums.h:6099
@ 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_READ_FUNC_SCROLL
Definition enums.h:6094
@ MSG_PRINT_FUNC_DOWN
Definition enums.h:6142
@ MSG_READ_FUNC_DOWN
Definition enums.h:6101
@ MSG_READ_FUNC_YIELD
Definition enums.h:6086
@ MSG_READ_FUNC_NO_SKIP
Definition enums.h:6088
@ MSG_PRINT_FUNC_SAVE_COLOR
Definition enums.h:6154
@ MSG_READ_FUNC_SPACING
Definition enums.h:6093
@ MSG_READ_FUNC_RESTORE_POS
Definition enums.h:6117
@ MSG_PRINT_FUNC_VARIANT
Definition enums.h:6131
@ MSG_READ_FUNC_SPEED
Definition enums.h:6097
@ MSG_READ_FUNC_OPTION
Definition enums.h:6115
@ MSG_READ_FUNC_SIZE
Definition enums.h:6095
@ MSG_READ_FUNC_ENABLE_CDOWN_NEXT
Definition enums.h:6125
@ MSG_READ_FUNC_HIDE_IMAGE
Definition enums.h:6107
@ MSG_READ_FUNC_DELAY_ON
Definition enums.h:6092
@ MSG_PRINT_FUNC_RESTORE_COLOR
Definition enums.h:6155
@ MSG_PRINT_FUNC_END_FX
Definition enums.h:6157
@ MSG_PRINT_FUNC_START_FX
Definition enums.h:6156
@ MSG_READ_FUNC_END_CHOICE
Definition enums.h:6113
@ MSG_READ_FUNC_IMAGE
Definition enums.h:6106
@ MSG_READ_FUNC_RIGHT
Definition enums.h:6100
@ MSG_PRINT_FUNC_RESTORE_POS
Definition enums.h:6153
@ MSG_READ_FUNC_ANIM_LOOP
Definition enums.h:6109
@ MSG_PRINT_FUNC_CURSOR
Definition enums.h:6150
@ MSG_READ_FUNC_CENTER_X
Definition enums.h:6123
@ MSG_READ_FUNC_ANIM_DELAY
Definition enums.h:6108
@ MSG_READ_FUNC_ITEM_ICON
Definition enums.h:6105
@ MSG_READ_FUNC_SET_REWIND
Definition enums.h:6124
@ MSG_PRINT_FUNC_SIZE
Definition enums.h:6137
@ MSG_READ_FUNC_UP
Definition enums.h:6102
@ MSG_PRINT_FUNC_ANIM_DONE
Definition enums.h:6149
@ MSG_READ_FUNC_INPUT_ON
Definition enums.h:6090
@ MSG_READ_FUNC_FONT
Definition enums.h:6082
@ MSG_READ_FUNC_SIZE_RESET
Definition enums.h:6096
@ MSG_PRINT_FUNC_CENTER_X
Definition enums.h:6158
@ MSG_PRINT_FUNC_SAVE_POS
Definition enums.h:6152
@ MSG_READ_FUNC_ANIM_SPRITE
Definition enums.h:6104
@ MSG_PRINT_RESET_GFX
Definition enums.h:6133
@ MSG_READ_FUNC_ANIM_DONE
Definition enums.h:6110
@ LANGUAGE_DE
Definition enums.h:6401
@ LANGUAGE_ES
Definition enums.h:6403
@ LANGUAGE_EN
Definition enums.h:6400
@ LANGUAGE_FR
Definition enums.h:6402
MsgVoices
Definition enums.h:6222
@ MSG_DELAY_FLAG_4
Definition enums.h:6263
@ MSG_DELAY_FLAG_2
Definition enums.h:6262
@ MSG_DELAY_FLAG_1
Definition enums.h:6261
@ 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_100
Definition enums.h:6235
@ SOUND_MSG_VOICE_1A
Definition enums.h:562
@ SOUND_MSG_REWIND
Definition enums.h:704
@ SOUND_MENU_SHOW_CHOICE
Definition enums.h:554
@ SOUND_MSG_WAIT
Definition enums.h:702
@ SOUND_MENU_BACK
Definition enums.h:701
@ SOUND_MSG_UNREWIND
Definition enums.h:705
@ SOUND_APPROVE
Definition enums.h:932
@ SOUND_MSG_VOICE_1B
Definition enums.h:563
@ SOUND_MENU_CHANGE_SELECTION
Definition enums.h:698
@ SOUND_MSG_SKIP
Definition enums.h:703
@ SOUND_MENU_NEXT
Definition enums.h:700
@ 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_LOWER_S
Definition enums.h:5939
@ MSG_CHAR_READ_VARIANT2
Definition enums.h:6048
@ MSG_CHAR_DIGIT_0
Definition enums.h:5872
@ MSG_CHAR_READ_PAUSE
Definition enums.h:6045
@ MSG_CHAR_PRINT_SPACE
Definition enums.h:6067
@ MSG_CHAR_READ_WAIT
Definition enums.h:6044
@ MSG_CHAR_MINUS
Definition enums.h:5869
@ MSG_CHAR_READ_HALF_SPACE
Definition enums.h:6052
@ MSG_CHAR_READ_SPACE
Definition enums.h:6050
@ MSG_CHAR_PRINT_NEXT
Definition enums.h:6072
@ MSG_CHAR_READ_VARIANT3
Definition enums.h:6049
@ MSG_CHAR_READ_STYLE
Definition enums.h:6055
@ MSG_CHAR_PRINT_END
Definition enums.h:6073
@ MSG_CHAR_PRINT_ENDL
Definition enums.h:6062
@ MSG_CHAR_READ_FULL_SPACE
Definition enums.h:6051
@ MSG_CHAR_READ_UNK_CHAR_FA
Definition enums.h:6053
@ MSG_CHAR_READ_NEXT
Definition enums.h:6054
@ MSG_CHAR_PRINT_FULL_SPACE
Definition enums.h:6068
@ MSG_CHAR_READ_VARIANT0
Definition enums.h:6046
@ 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_UNK_CHAR_FA
Definition enums.h:6071
@ MSG_CHAR_READ_ENDL
Definition enums.h:6043
@ MSG_CHAR_PRINT_HALF_SPACE
Definition enums.h:6069
@ MSG_CHAR_UNK_C3
Definition enums.h:6034
@ MSG_CHAR_READ_END
Definition enums.h:6056
@ MSG_CHAR_READ_VARIANT1
Definition enums.h:6047
@ MSG_CHAR_LOWER_N
Definition enums.h:5934
@ MSG_CONTROL_CHAR
Definition enums.h:6061
@ MSG_CHAR_READ_FUNCTION
Definition enums.h:6058
@ MSG_WINDOW_STATE_DONE
Definition enums.h:6267
@ MSG_WINDOW_STATE_B
Definition enums.h:6278
@ MSG_WINDOW_STATE_WAITING
Definition enums.h:6272
@ MSG_WINDOW_STATE_WAITING_FOR_CHOICE
Definition enums.h:6274
@ MSG_WINDOW_STATE_INIT
Definition enums.h:6268
@ MSG_WINDOW_STATE_OPENING
Definition enums.h:6269
@ MSG_WINDOW_STATE_SCROLLING
Definition enums.h:6273
@ 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_SCROLLING_BACK
Definition enums.h:6275
@ MSG_WINDOW_STATE_D
Definition enums.h:6280
@ MSG_WINDOW_STATE_CLOSING
Definition enums.h:6270
@ MSG_WINDOW_STATE_VIEWING_PREV
Definition enums.h:6276
@ MSG_WINDOW_STATE_A
Definition enums.h:6277
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
u32 dma_copy(Addr romStart, Addr romEnd, void *vramDest)
Definition 43F0.c:444
s32 general_heap_free(void *data)
Definition heap.c:18
char * int_to_string(s32, char *, s32)
Definition 43F0.c:386
void * heap_malloc(s32 size)
Definition heap.c:34
#define INCLUDE_ASM(TYPE, FOLDER, NAME, ARGS...)
Definition include_asm.h:21
s32 gItemIconPaletteOffsets[]
void msg_draw_rewind_arrow(s32)
Definition msg.c:2145
void get_msg_properties(s32 msgID, s32 *height, s32 *width, s32 *maxLineChars, s32 *numLines, s32 *maxLinesPerPage, s32 *numSpaces, u16 charset)
Definition msg.c:1671
IMG_BIN ui_msg_rewind_arrow_png[]
void msg_printer_set_origin_pos(MessagePrintState *msgPrintState, s32 x, s32 y)
Definition msg.c:1489
MessagePrintState * _msg_get_printer_for_msg(s32 msgID, s32 *donePrintingWriteback, s32 arg2)
Definition msg.c:1428
s16 gNextMessageBuffer
Definition msg.c:62
s32 cancel_message(MessagePrintState *msgPrintState)
Definition msg.c:1507
s8 * load_message_to_buffer(s32 msgID)
Definition msg.c:1410
IMG_BIN MsgCharImgSubtitle[]
Definition msg_img.c:92
PAL_BIN D_8015C7E0[0x10]
Definition msg.c:105
void render_messages(void)
Definition msg.c:568
u8 MessageSingular[]
Definition msg.c:48
Vtx gRewindArrowQuad[]
Definition msg.c:64
s32 draw_image_with_clipping(IMG_PTR raster, s32 width, s32 height, s32 fmt, s32 bitDepth, s16 posX, s16 posY, u16 clipULx, u16 clipULy, u16 clipLRx, u16 clipRLy)
IMG_BIN D_80159B50[0x200]
Definition msg.c:104
void clear_character_set(void)
Definition msg.c:192
s16 MsgStyleVerticalLineOffsets[]
Definition msg_data.c:927
PAL_PTR MsgLetterPaletteOffsets[]
Definition msg_data.c:893
s32 msg_get_print_char_width(s32 character, s32 charset, s32 variation, f32 msgScale, s32 overrideCharWidth, u8 flags)
Definition msg.c:1578
PAL_BIN ui_msg_rewind_arrow_pal[]
void close_message(MessagePrintState *msgPrintState)
Definition msg.c:1568
Vp D_8014C280
Definition msg.c:34
void appendGfx_message(MessagePrintState *, s16, s16, u16, u16, u16, u8)
Definition msg_draw.c:213
Gfx * D_80151338
Definition msg.c:93
void draw_digit(IMG_PTR img, s32 charset, s32 posX, s32 posY)
Definition msg.c:2203
IMG_BIN MsgCharImgTitle[]
Definition msg_img.c:90
#define MSG_ROM_START
Definition msg.c:23
void clear_printers(void)
Definition msg.c:196
MessageImageData * MessageImageDataList[1]
Definition msg.c:32
s32 gItemIconRasterOffsets[]
#define CHOICE_POINTER_MOVE_RATE
Definition msg.c:29
u16 gMsgGlobalWaveCounter
Definition msg.c:89
Gfx gMsgDlistInitDrawNumber[]
Definition msg.c:165
u8 MessagePlural[]
Definition msg.c:42
void dma_load_msg(u32 msgID, void *dest)
Definition msg.c:1396
s32 msg_get_draw_char_width(s32 character, s32 charset, s32 variation, f32 msgScale, s32 overrideCharWidth, u16 flags)
Definition msg.c:1628
void msg_play_speech_sound(MessagePrintState *printer, u8 character)
Definition msg.c:609
s32 gMsgBGScrollAmtY
Definition msg.c:91
void initialize_printer(MessagePrintState *printer, s32 arg1, s32 arg2)
Definition msg.c:1303
void load_font_data(Addr offset, u16 size, void *dest)
Definition msg.c:218
IMG_BIN ui_msg_star_png[]
IMG_BIN MsgCharImgNormal[]
Definition msg_img.c:91
s32 get_msg_lines(s32 msgID)
Definition msg.c:1979
MessageNumber gMsgNumbers[]
Definition msg.c:129
PAL_BIN D_802F4560[80][8]
void set_message_int_var(s32 value, s32 index)
Definition msg.c:1550
void set_message_text_var(s32 msgID, s32 index)
Definition msg.c:1520
Gfx D_8014C2D8[]
Definition msg.c:71
IMG_BIN ui_msg_star_silhouette_png[]
void msg_update_rewind_arrow(s32)
Definition msg.c:2061
MessagePrintState * msg_get_printer_for_msg(s32 msgID, s32 *donePrintingWriteback)
Definition msg.c:1424
void draw_message_window(MessagePrintState *printer)
Definition msg_draw.c:137
void msg_copy_to_print_buffer(MessagePrintState *printer, s32 arg1, s32 arg2)
Definition msg.c:642
void load_font(s32 font)
Definition msg.c:225
void draw_number(s32 value, s32 x, s32 y, s32 charset, s32 palette, s32 opacity, u16 style)
Definition msg.c:2223
void set_message_images(MessageImageData *images)
Definition msg.c:1516
MessageImageDataList gMsgVarImages
Definition msg.c:90
IMG_BIN ui_point_right_png[]
s32 msg_printer_load_msg(s32 msgID, MessagePrintState *printer)
Definition msg.c:1474
s32 _update_message(MessagePrintState *printer)
Definition msg.c:271
MessageCharset * MsgCharsets[5]
Definition msg_data.c:865
void msg_draw_choice_pointer(MessagePrintState *printer)
Definition msg.c:2159
#define CHAR_SPACE_MULTIPLIER
Definition msg.c:1575
IMG_PTR MsgLetterRasterOffsets[]
Definition msg_data.c:878
void update_messages(void)
Definition msg.c:247
u8 * D_8015131C
Definition msg.c:92
PAL_BIN ui_point_right_pal[]
RewindArrowStates
Definition msg.c:10
@ REWIND_ARROW_STATE_NEUTRAL
Definition msg.c:13
@ REWIND_ARROW_STATE_INIT
Definition msg.c:11
@ REWIND_ARROW_STATE_CHANGE_COLOR_BACK
Definition msg.c:15
@ REWIND_ARROW_STATE_GROW
Definition msg.c:12
@ REWIND_ARROW_STATE_CHANGE_COLOR
Definition msg.c:14
s32 gMsgBGScrollAmtX
Definition msg.c:88
IMG_BIN MsgCharImgLatin[]
IMG_BIN MsgCharImgMenuKana[]
IMG_BIN MsgCharImgMenuLatin[]
IMG_BIN MsgCharImgKana[]
void sfx_play_sound_with_params(s32 soundID, u8 volume, u8 pan, s16 pitchShift)
Definition sfx.c:458
#define PM_CC_MSG_UP_ARROW
Definition macros.h:297
#define PM_CC_07
Definition macros.h:282
#define SCREEN_WIDTH
Definition macros.h:105
#define ARRAY_COUNT(arr)
Definition macros.h:40
#define PM_CC_01
Definition macros.h:276
#define SCREEN_HEIGHT
Definition macros.h:106
#define DT
Definition macros.h:522
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
u8 Addr[]
Linker symbol address, as in ld_addrs.h.
Definition types.h:16
#define gCurrentLanguage
Definition variables.h:115
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