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
46#endif
47
49#endif
50
51#if VERSION_PAL
52s32 gCurrentLanguage = 0;
53
54void* D_PAL_8014AE50[] = {
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
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
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
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
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
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
235#else
237#endif
239
240 // fix outline color after loading
241 for (s32 i = 0; i < 80; i++) {
242 // set the transparent color to the outline color but with alpha = 0
243 D_802F4560[i][0] = D_802F4560[i][6] & ~1;
244 }
245 } else if (font == 1) {
249 }
250 }
251}
252
253void update_messages(void) {
254 s32 i;
255
257 if (gMsgGlobalWaveCounter >= 360) {
259 }
260
261 for (i = 0; i < ARRAY_COUNT(gMessagePrinters); i++) {
262 if (gMessagePrinters[i].stateFlags & MSG_STATE_FLAG_2) {
263 _update_message(&gMessagePrinters[i]);
264 }
265 }
266
267 gMsgBGScrollAmtX += 12;
268 gMsgBGScrollAmtY -= 12;
269 if (gMsgBGScrollAmtX >= 2048) {
270 gMsgBGScrollAmtX -= 2048;
271 }
272 if (gMsgBGScrollAmtY < 0) {
273 gMsgBGScrollAmtY += 2048;
274 }
275}
276
278 f32 speechPan;
279 u8 cond;
280 s32 buttons;
283 s32 charsToPrint;
284 s32 i;
285
286 printer->effectFrameCounter++;
287 if (printer->effectFrameCounter >= 3600) {
288 printer->effectFrameCounter = 0;
289 }
290
291 speechPan = (((f32)printer->initOpenPos.x - (SCREEN_WIDTH / 2.0)) / 3.8) + 64.0;
292 if (speechPan < 5.0) {
293 speechPan = 5.0f;
294 } else if (speechPan > 122.0) {
295 speechPan = 122.0f;
296 }
297 printer->speechPan = speechPan;
298
299 cond = FALSE;
300 if (!(printer->stateFlags & MSG_STATE_FLAG_40)) {
301 if (!(printer->stateFlags & (MSG_STATE_FLAG_20 | MSG_STATE_FLAG_10))) {
302 s32 buttons = BUTTON_A;
303
304 switch (printer->windowState) {
306 if (printer->stateFlags & MSG_STATE_FLAG_80000) {
308 }
310 printer->windowState = MSG_WINDOW_STATE_PRINTING;
311 printer->curPrintDelay = 0;
312 printer->stateFlags |= MSG_STATE_FLAG_4;
314 cond = TRUE;
316 } else if (printer->srcBuffer[printer->srcBufferPos] != MSG_CHAR_READ_END) {
318 if (printer->fontVariant != 0 || printer->srcBuffer[printer->srcBufferPos] != MSG_CHAR_UNK_C3) {
320 }
322 } else if (printer->style == MSG_STYLE_RIGHT ||
323 printer->style == MSG_STYLE_LEFT ||
324 printer->style == MSG_STYLE_CENTER ||
325 printer->style == MSG_STYLE_TATTLE)
326 {
328 }
329 } else if ((gGameStatusPtr->pressedButtons[0] & BUTTON_Z) &&
330 !(printer->stateFlags & MSG_STATE_FLAG_40000) &&
331 (printer->curLine != 0))
332 {
333 printer->windowState = MSG_WINDOW_STATE_B;
334 printer->unk_4CC = 0;
335 printer->unkArraySize = printer->curLine - 1;
336 printer->unk_4C8 = abs(printer->curLinePos - printer->lineEndPos[printer->unkArraySize]);
338 }
339 break;
342 printer->windowState = MSG_WINDOW_STATE_B;
343 printer->unk_4CC = 0;
344 printer->unkArraySize = printer->curLine;
345 printer->unk_4C8 = abs(printer->curLinePos - printer->lineEndPos[printer->unkArraySize]);
347 } else if (gGameStatusPtr->pressedButtons[0] & BUTTON_Z) {
348 if (printer->unkArraySize > 0) {
349 printer->windowState = MSG_WINDOW_STATE_B;
350 printer->unk_4CC = 0;
351 printer->unkArraySize--;
352 printer->unk_4C8 = abs(printer->curLinePos - printer->lineEndPos[printer->unkArraySize]);
354 }
355 } else {
357 printer->windowState = MSG_WINDOW_STATE_B;
358 printer->unk_4CC = 0;
359 printer->unkArraySize++;
360 printer->unk_4C8 = abs(printer->curLinePos - printer->lineEndPos[printer->unkArraySize]);
362 }
363 }
364 break;
367 printer->madeChoice = 1;
368 printer->windowState = MSG_WINDOW_STATE_PRINTING;
369 printer->scrollingTime = 0;
370 printer->stateFlags |= MSG_STATE_FLAG_20000;
372 } else if (printer->cancelOption != 0xFF && (gGameStatusPtr->pressedButtons[0] & BUTTON_B)) {
373 if (printer->cancelOption >= printer->maxOption) {
374 printer->selectedOption = printer->curOption;
375 } else {
376 printer->selectedOption = printer->cancelOption;
377 }
378 printer->madeChoice = 1;
379 printer->windowState = MSG_WINDOW_STATE_PRINTING;
380 printer->scrollingTime = 0;
381 printer->curOption = printer->cancelOption;
382 printer->stateFlags |= MSG_STATE_FLAG_20000;
385 if (printer->curOption != printer->maxOption - 1) {
386 printer->targetOption = printer->curOption + 1;
388 printer->scrollingTime = 1;
390 }
391 } else if (gGameStatusPtr->heldButtons[0] & BUTTON_STICK_UP) {
392 if (printer->curOption != 0) {
393 printer->targetOption = printer->curOption - 1;
395 printer->scrollingTime = 1;
397 }
398 }
399
400 if (printer->windowState != MSG_WINDOW_STATE_SCROLLING_BACK) {
401 break;
402 }
404 printer->scrollingTime++;
405 if (printer->scrollingTime >= (s32)(5 * DT)) {
407 printer->curOption = printer->targetOption;
408 printer->selectedOption = printer->curOption;
409 }
410 break;
411 }
412 } else if (!(printer->stateFlags & MSG_STATE_FLAG_20) &&
413 printer->windowState == MSG_WINDOW_STATE_WAITING &&
415 {
416 printer->windowState = MSG_WINDOW_STATE_PRINTING;
417 printer->curPrintDelay = 0;
418 printer->stateFlags |= MSG_STATE_FLAG_4;
419 }
420
421 if (printer->stateFlags & MSG_STATE_FLAG_4 && !(gGameStatusPtr->curButtons[0] & BUTTON_A)) {
422 printer->stateFlags &= ~MSG_STATE_FLAG_4;
423 }
424
425 for (i = 0; i < ARRAY_COUNT(printer->animTimers); i++) {
426 if (printer->animTimers[i] > 0) {
427 printer->animTimers[i]--;
428 }
429 }
430
431 switch (printer->windowState) {
434 if (!(printer->stateFlags & (MSG_STATE_FLAG_20 | MSG_STATE_FLAG_10)) && !cond) {
436
437 }
438 }
439 // fallthrough
441 charsToPrint = printer->charsPerChunk;
442 if (printer->windowState == MSG_WINDOW_STATE_INIT) {
443 printer->windowState = MSG_WINDOW_STATE_PRINTING;
444 printer->curPrintDelay = 0;
445 } else if (printer->stateFlags & MSG_STATE_FLAG_PRINT_QUICKLY) {
446 charsToPrint = 12;
447 printer->curPrintDelay = 0;
448 } else if (!(printer->stateFlags & MSG_STATE_FLAG_4)) {
449 if (!(printer->stateFlags & (MSG_STATE_FLAG_20 | MSG_STATE_FLAG_10)) &&
451 {
452 charsToPrint = 6;
453 printer->curPrintDelay = 0;
454 }
455 }
456 if ((printer->curPrintDelay == 0) || --printer->curPrintDelay == 0) {
458 }
459 break;
462 if (!(printer->stateFlags & (MSG_STATE_FLAG_20 | MSG_STATE_FLAG_10))) {
464 }
465 }
466 printer->curLinePos += printer->windowScrollRate;
467 if ((printer->stateFlags & MSG_STATE_FLAG_PRINT_QUICKLY) ||
468 (!(printer->stateFlags & (MSG_STATE_FLAG_10 | MSG_STATE_FLAG_4)) &&
470 {
471 printer->curLinePos += (s32)(6 / DT);
472 }
473
474 if (printer->curLinePos >= printer->nextLinePos) {
475 printer->windowState = MSG_WINDOW_STATE_PRINTING;
476 printer->curLinePos = printer->nextLinePos;
477 printer->stateFlags |= MSG_STATE_FLAG_4;
478
479 if (printer->style == MSG_STYLE_SIGN ||
480 printer->style == MSG_STYLE_LAMPPOST ||
481 printer->srcBuffer[printer->srcBufferPos] == MSG_CHAR_READ_WAIT)
482 {
483 printer->curPrintDelay = 0;
484 } else {
485 printer->curPrintDelay = 5;
486 }
487 printer->lineEndPos[printer->curLine] = printer->curLinePos;
488 }
489 break;
491 printer->unk_4CC++;
492 endPosDist = abs(printer->curLinePos - printer->lineEndPos[printer->unkArraySize]);
493 lineIncAmt = 2;
494
495 if (printer->unk_4C8 <= 16) {
496 if (endPosDist >= 15) {
497 lineIncAmt = 4;
498 } else if (endPosDist >= 9) {
499 lineIncAmt = 3;
500 }
501 } else if (endPosDist > 96) {
502 lineIncAmt = 10;
503 } else if (endPosDist > 48) {
504 lineIncAmt = 9;
505 } else if (endPosDist >= 24) {
506 lineIncAmt = 7;
507 } else if (endPosDist >= 16) {
508 lineIncAmt = 5;
509 } else if (endPosDist >= 8) {
510 lineIncAmt = 4;
511 } else if (endPosDist > 4) {
512 lineIncAmt = 3;
513 }
514
515 printer->unk_4CA = lineIncAmt;
516
517 if (printer->lineEndPos[printer->unkArraySize] < printer->curLinePos) {
518 printer->curLinePos -= printer->unk_4CA;
519 if (printer->lineEndPos[printer->unkArraySize] >= printer->curLinePos) {
520 printer->curLinePos = printer->lineEndPos[printer->unkArraySize];
521 printer->windowState = MSG_WINDOW_STATE_C;
522 }
523 } else {
524 printer->curLinePos += printer->unk_4CA;
525 if (printer->curLinePos >= printer->lineEndPos[printer->unkArraySize]) {
526 printer->curLinePos = printer->lineEndPos[printer->unkArraySize];
527 printer->windowState = MSG_WINDOW_STATE_C;
528 if (printer->unkArraySize == printer->curLine) {
529 printer->windowState = MSG_WINDOW_STATE_WAITING;
530 printer->rewindArrowAnimState = REWIND_ARROW_STATE_INIT;
531 printer->rewindArrowCounter = 0;
532 }
533 }
534 }
535 break;
546 break;
547 }
548 }
549
550 if (printer->stateFlags & MSG_STATE_FLAG_1) {
551 printer->windowState = MSG_WINDOW_STATE_DONE;
552 printer->stateFlags = 0;
553 if (printer->letterBackgroundImg != NULL) {
554 general_heap_free(printer->letterBackgroundImg);
555 }
556 if (printer->letterBackgroundPal != NULL) {
557 general_heap_free(printer->letterBackgroundPal);
558 }
559 if (printer->letterContentImg != NULL) {
560 general_heap_free(printer->letterContentImg);
561 }
562 if (printer->letterContentPal != NULL) {
563 general_heap_free(printer->letterContentPal);
564 }
565 if (printer->closedWritebackBool != NULL) {
566 *printer->closedWritebackBool = TRUE;
567 printer->closedWritebackBool = NULL;
568 }
569 }
570
571 return printer->windowState;
572}
573
574void render_messages(void) {
575 Mtx* matrix = &gMessageWindowProjMatrix[gCurrentDisplayContextIndex];
576 s32 i;
577
578 for (i = 0; i < ARRAY_COUNT(gMessagePrinters); i++) {
579 if (gMessagePrinters[i].stateFlags & MSG_STATE_FLAG_2) {
581 guOrtho(matrix, 0.0f, 319.0f, -240.0f, 0.0f, -500.0f, 500.0f, 1.0f);
588 break;
589 }
590 }
591
592 for (i = 0; i < ARRAY_COUNT(gMessagePrinters); i++) {
593 if (gMessagePrinters[i].stateFlags & MSG_STATE_FLAG_2) {
594 draw_message_window(&gMessagePrinters[i]);
595
596 if (gMessagePrinters[i].windowState == MSG_WINDOW_STATE_WAITING) {
597 if (!(gMessagePrinters[i].stateFlags & MSG_STATE_FLAG_8000) &&
598 !(gMessagePrinters[i].stateFlags & MSG_STATE_FLAG_40))
599 {
601 }
602 } else if (gMessagePrinters[i].windowState == MSG_WINDOW_STATE_C) {
604 } else if (gMessagePrinters[i].windowState == MSG_WINDOW_STATE_WAITING_FOR_CHOICE ||
605 gMessagePrinters[i].windowState == MSG_WINDOW_STATE_SCROLLING_BACK ||
606 gMessagePrinters[i].stateFlags & MSG_STATE_FLAG_10000 ||
607 gMessagePrinters[i].stateFlags & MSG_STATE_FLAG_20000)
608 {
609 msg_draw_choice_pointer(&gMessagePrinters[i]);
610 }
611 }
612 }
613}
614
616 f32 volTemp;
617 s16 volume;
618 s32 pitchShift;
619 s32 flag = 1;
620 s32 baseShift = 100;
621
622 if (printer->stateFlags & MSG_STATE_FLAG_800000 && !(printer->delayFlags & (MSG_DELAY_FLAG_2 | MSG_DELAY_FLAG_4)) && printer->volume != 0) {
623 volTemp = (f32)printer->volume / 100.0;
624 pitchShift = ((character % 20) * 10) + (printer->speechPitchShift - baseShift);
625 volume = ((rand_int(15) + 78) * volTemp);
626
627 if (volume > 255) {
628 volume = 255;
629 }
630
631 if (character & flag) {
632 sfx_play_sound_with_params(printer->speechSoundIDA, volume, printer->speechPan, pitchShift);
633 } else {
634 sfx_play_sound_with_params(printer->speechSoundIDB, volume, printer->speechPan, pitchShift);
635 }
636 }
637}
638
639extern s32 gItemIconRasterOffsets[];
640extern s32 gItemIconPaletteOffsets[];
643extern MsgVoice MsgVoices[];
644
645#if VERSION_PAL
647#else
649 u8 arg;
650 u8 argQ;
651 u8 argW;
652 u8 argE;
653 u8 sp10[4];
654 s32 addr;
655 s16 offset;
656 s32 i;
657 u8* romAddr;
658 u8* romEnd;
659 s32 temp;
660 void* a2;
661 s8 s8 = arg2 & 1;
662 u8* printBuf = &printer->printBuffer[printer->printBufferPos];
663 u8* srcBuf = &printer->srcBuffer[printer->srcBufferPos];
664
665 do {
666 u8 c = *srcBuf++; // a1
667 u8 nextArg = *srcBuf; // a2
668 switch (c) {
671 printer->lineCount += (u8)printer->sizeScale;
672 break;
674 printer->windowState = MSG_WINDOW_STATE_WAITING;
675 printer->delayFlags |= MSG_DELAY_FLAG_1;
676 printer->delayFlags &= ~MSG_DELAY_FLAG_2;
677 printer->rewindArrowAnimState = REWIND_ARROW_STATE_INIT;
678 printer->rewindArrowCounter = 0;
679 printer->stateFlags &= ~MSG_STATE_FLAG_SPEAKING;
681 if (printer->style != MSG_STYLE_F) {
683 }
684 break;
686 printer->curPrintDelay = *srcBuf++;
687 printer->delayFlags |= MSG_DELAY_FLAG_1;
688 printer->stateFlags &= ~MSG_STATE_FLAG_SPEAKING;
689 break;
695 printer->fontVariant = c + 13;
696 break;
699 break;
702 break;
705 break;
708 arg1--;
709 break;
711 if (printer->lineCount != 0) {
712 printer->lineEndPos[printer->curLine] = printer->curLinePos;
713 printer->curLine++;
715 printer->nextLinePos = printer->curLinePos + (MsgCharsets[printer->font]->newLineY
716#if !VERSION_JP
718#endif
719 ) * printer->lineCount;
720 printer->windowState = MSG_WINDOW_STATE_SCROLLING;
721 printer->delayFlags |= MSG_DELAY_FLAG_1;
722 }
723 printer->lineCount = 0;
724 break;
727 arg = *srcBuf++;
728 printer->style = arg;
729 *printBuf++ = arg;
730 printer->fadeInCounter = 0;
731 switch (arg) {
732 case MSG_STYLE_RIGHT:
733 case MSG_STYLE_LEFT:
734 case MSG_STYLE_CENTER:
735 case MSG_STYLE_TATTLE:
737 printer->maxLinesPerPage = 3;
738 }
739 printer->delayFlags |= MSG_DELAY_FLAG_1;
741 if (nextArg != MSG_CHAR_UNK_C3) {
742 printer->stateFlags |= MSG_STATE_FLAG_SPEAKING;
743 }
744 printer->speechSoundIDA = SOUND_MSG_VOICE_1A;
745 printer->speechSoundIDB = SOUND_MSG_VOICE_1B;
746 printer->windowState = MSG_WINDOW_STATE_OPENING;
747 break;
748 case MSG_STYLE_CHOICE:
749 printer->windowBasePos.x = *srcBuf++;
750 printer->windowBasePos.y = *srcBuf++;
751 printer->windowSize.x = *srcBuf++;
752 printer->windowSize.y = *srcBuf++;
753 printer->windowState = MSG_WINDOW_STATE_OPENING;
754 printer->stateFlags |= MSG_STATE_FLAG_800;
755 break;
758 case MSG_STYLE_F:
759 if (!s8) {
760#if VERSION_JP
761 printer->windowBasePos.x = 40;
762#else
763 printer->windowBasePos.x = 20;
764#endif
765 printer->windowBasePos.y = 28;
766 printer->windowSize.y = 58;
767#if VERSION_JP
768 printer->windowSize.x = 240;
769#else
770 printer->windowSize.x = 280;
771#endif
772 printer->windowState = MSG_WINDOW_STATE_OPENING;
773 printer->stateFlags |= MSG_STATE_FLAG_800;
774 printer->delayFlags |= MSG_DELAY_FLAG_1;
775 if (arg == MSG_STYLE_INSPECT) {
777 }
778 }
779 break;
781 printer->windowBasePos.x = *srcBuf++;
782 printer->windowBasePos.y = *srcBuf++;
783 printer->windowSize.x = *srcBuf++;
784 printer->windowSize.y = *srcBuf++;
786 printer->windowState = MSG_WINDOW_STATE_OPENING;
787 printer->delayFlags |= MSG_DELAY_FLAG_1;
788 printer->stateFlags |= MSG_STATE_FLAG_800;
789 break;
791 printer->windowSize.y = *srcBuf++;
792 // fallthrough
793 case MSG_STYLE_SIGN:
794 if (!s8) {
795 printer->windowState = MSG_WINDOW_STATE_OPENING;
796 printer->stateFlags |= MSG_STATE_FLAG_800;
797 printer->delayFlags |= MSG_DELAY_FLAG_1;
798 }
799 break;
801 arg = *srcBuf++;
802 printer->windowState = MSG_WINDOW_STATE_OPENING;
803 printer->stateFlags |= MSG_STATE_FLAG_800;
804 printer->delayFlags |= MSG_DELAY_FLAG_1;
808 printer->letterBackgroundPal = heap_malloc(0x20);
810 dma_copy(romAddr, romAddr + 0x20, printer->letterBackgroundPal);
814 printer->letterContentPal = heap_malloc(0x200);
816 dma_copy(romAddr, romAddr + 0x200, printer->letterContentPal);
817 break;
818 case MSG_STYLE_POPUP:
819 case MSG_STYLE_B:
820 printer->windowSize.x = printer->msgWidth + 32;
821#if VERSION_JP
822 printer->windowSize.y = 32;
823#else
824 printer->windowSize.y = 40;
825#endif
826 printer->stateFlags |= MSG_STATE_FLAG_8000;
827 if (!s8) {
829 printer->windowState = MSG_WINDOW_STATE_D;
830 printer->delayFlags |= MSG_DELAY_FLAG_1;
831 }
832 break;
834 printer->windowState = MSG_WINDOW_STATE_PRINTING;
835 break;
836 }
837 if ((printer->delayFlags & MSG_DELAY_FLAG_1) && (printer->delayFlags & (MSG_DELAY_FLAG_4 | MSG_DELAY_FLAG_2))) {
838 printer->delayFlags &= ~MSG_DELAY_FLAG_1;
839 }
840 break;
843 if (printer->stateFlags & MSG_STATE_FLAG_800) {
844 if (printer->stateFlags & MSG_STATE_FLAG_1000) {
845 if (printer->closedWritebackBool != NULL) {
846 *printer->closedWritebackBool = TRUE;
847 }
848 }
849 if (printer->style != MSG_STYLE_POPUP && printer->style != MSG_STYLE_B) {
850 printer->windowState = MSG_WINDOW_STATE_CLOSING;
851 } else {
852 printer->windowState = MSG_WINDOW_STATE_E;
853 }
854 printer->fadeOutCounter = 0;
855 } else {
856 printer->stateFlags |= MSG_STATE_FLAG_1;
857 }
858 printer->delayFlags |= MSG_DELAY_FLAG_1;
859 printer->delayFlags &= ~MSG_DELAY_FLAG_2;
860 break;
862 switch (*srcBuf++) {
866 *printBuf++ = printer->font = *srcBuf++;
867 break;
871 *printBuf++ = printer->fontVariant = *srcBuf++;
872 break;
876 *printBuf++ = *srcBuf++;
877 break;
879 printer->stateFlags |= MSG_STATE_FLAG_10;
880 break;
882 printer->stateFlags |= MSG_STATE_FLAG_20;
884 break;
886 printer->stateFlags &= ~MSG_STATE_FLAG_20;
887 break;
891 *printBuf++ = *srcBuf++;
892 break;
894 printer->delayFlags |= MSG_DELAY_FLAG_2;
895 break;
897 printer->delayFlags &= ~MSG_DELAY_FLAG_2;
898 printer->delayFlags |= MSG_DELAY_FLAG_1;
899 break;
901 printer->lineEndPos[printer->curLine] = printer->curLinePos;
902 printer->curLine++;
904 arg = *srcBuf++;
905 printer->nextLinePos = printer->curLinePos + (MsgCharsets[printer->font]->newLineY
906#if !VERSION_JP
908#endif
909 ) * arg;
910 printer->windowState = MSG_WINDOW_STATE_SCROLLING;
911 printer->delayFlags |= MSG_DELAY_FLAG_1;
912 printer->lineCount = 0;
913 break;
914#if !VERSION_IQUE
918 *printBuf++ = *srcBuf++;
919 *printBuf++ = arg = *srcBuf++;
920 printer->sizeScale = (arg >> 4) + (arg & 0xF) * 0.0625f;
921 break;
925 printer->sizeScale = 1.0f;
926 break;
927#endif
929 printer->printDelayTime = *srcBuf++;
930 printer->charsPerChunk = *srcBuf++;
931 break;
935 *printBuf++ = *srcBuf++;
936 *printBuf++ = *srcBuf++;
937 break;
941 *printBuf++ = *srcBuf++;
942 break;
946 *printBuf++ = *srcBuf++;
947 break;
951 *printBuf++ = *srcBuf++;
952 break;
953 case MSG_READ_FUNC_UP:
956 *printBuf++ = *srcBuf++;
957 break;
961 *printBuf++ = *srcBuf++;
962 arg1--;
963 printer->curPrintDelay = printer->printDelayTime;
964 if (arg1 <= 0) {
965 printer->delayFlags |= MSG_DELAY_FLAG_1;
966 }
967 if (printer->delayFlags & (MSG_DELAY_FLAG_4 | MSG_DELAY_FLAG_2)) {
968 printer->delayFlags &= ~MSG_DELAY_FLAG_1;
969 }
970 break;
974 *printBuf++ = *srcBuf++;
975 *printBuf++ = *srcBuf++;
976 *printBuf++ = *srcBuf++;
977 printer->curPrintDelay = printer->printDelayTime;
978 if (--arg1 <= 0) {
979 printer->delayFlags |= MSG_DELAY_FLAG_1;
980 }
981 if (printer->delayFlags & (MSG_DELAY_FLAG_4 | MSG_DELAY_FLAG_2)) {
982 printer->delayFlags &= ~MSG_DELAY_FLAG_1;
983 }
984 break;
988
989 arg = *srcBuf++;
990 argQ = *srcBuf++;
991
992 a2 = D_80159B50;
993 offset = arg << 8 | argQ;
994
997 icon_ROM_START + gItemIconRasterOffsets[offset] + 0x200, a2);
998 romEnd = icon_ROM_START + gItemIconPaletteOffsets[offset] + 0x20;
1000 romEnd, D_8015C7E0);
1001 printer->curPrintDelay = printer->printDelayTime;
1002 if (--arg1 <= 0) {
1003 printer->delayFlags |= MSG_DELAY_FLAG_1;
1004 }
1005 if (printer->delayFlags & (MSG_DELAY_FLAG_4 | MSG_DELAY_FLAG_2)) {
1006 printer->delayFlags &= ~MSG_DELAY_FLAG_1;
1007 }
1008 break;
1010 printer->curImageIndex = *srcBuf++;
1011 arg = *srcBuf++;
1012 argQ = *srcBuf++;
1013 printer->varImageScreenPos.x = arg << 8 | argQ;
1014 printer->varImageScreenPos.y = *srcBuf++;
1015 printer->varImgHasBorder = *srcBuf++;
1016 printer->varImgFinalAlpha = *srcBuf++;
1017 printer->varImgAlphaFadeStep = *srcBuf++;
1018 printer->varImageDisplayState = 0;
1019 printer->varImageFadeTimer = 0;
1020 if (--arg1 <= 0) {
1021 printer->delayFlags |= MSG_DELAY_FLAG_1;
1022 }
1023 if (printer->delayFlags & (MSG_DELAY_FLAG_4 | MSG_DELAY_FLAG_2)) {
1024 printer->delayFlags &= ~MSG_DELAY_FLAG_1;
1025 }
1026 break;
1028 arg = *srcBuf++;
1029 if (arg != 0) {
1030 printer->varImageDisplayState = 2;
1031 printer->varImgAlphaFadeStep = arg;
1032 printer->varImageFadeTimer = 0;
1033 } else {
1034 printer->varImageScreenPos.x = 0;
1035 }
1036 break;
1040 *printBuf++ = *srcBuf++;
1041 *printBuf++ = *srcBuf++;
1042 *printBuf++ = *srcBuf++;
1043 printer->delayFlags |= MSG_DELAY_FLAG_4;
1044 break;
1048 *printBuf++ = *srcBuf++;
1049 *printBuf++ = *srcBuf++;
1050 break;
1054 *printBuf++ = *srcBuf++;
1055 printer->delayFlags &= ~MSG_DELAY_FLAG_4;
1056 if (--arg1 <= 0) {
1057 printer->delayFlags |= MSG_DELAY_FLAG_1;
1058 }
1059 break;
1061 arg = *srcBuf++;
1062 argQ = *srcBuf++;
1063 argW = *srcBuf++;
1064 argE = *srcBuf++;
1065 printer->cursorPosX[arg] = argQ << 8 | argW;
1066 printer->cursorPosY[arg] = argE;
1067 break;
1071 *printBuf++ = *srcBuf++;
1072 break;
1075 printer->maxOption = *srcBuf++;
1076 printer->madeChoice = 0;
1077 printer->curOption = 0;
1078 printer->selectedOption = 0;
1080 printer->delayFlags |= MSG_DELAY_FLAG_1;
1081 break;
1083 printer->cancelOption = *srcBuf++;
1084 break;
1088 *printBuf++ = *srcBuf++;
1089 break;
1093 break;
1096 printer->delayFlags |= MSG_DELAY_FLAG_1;
1097 printer->stateFlags &= ~MSG_STATE_FLAG_SPEAKING;
1099 break;
1103 break;
1107 break;
1111 break;
1115 break;
1119 arg = *srcBuf++;
1120 switch (arg) {
1121 case MSG_FX_SHAKE:
1122 case MSG_FX_WAVE:
1124 case MSG_FX_RAINBOW:
1125 case MSG_FX_GLOBAL_WAVE:
1127 case MSG_FX_RISE_PRINT:
1128 case MSG_FX_GROW_PRINT:
1129 case MSG_FX_SIZE_JITTER:
1130 case MSG_FX_SIZE_WAVE:
1131 case MSG_FX_DROP_SHADOW:
1132 *printBuf++ = arg;
1133 break;
1134 case MSG_FX_STATIC:
1135 case MSG_FX_BLUR:
1136 case MSG_FX_DITHER_FADE:
1137 *printBuf++ = arg;
1138 *printBuf++ = *srcBuf++;
1139 break;
1140 }
1141 break;
1145 *printBuf++ = *srcBuf++;
1146 break;
1147 case MSG_READ_FUNC_VAR:
1148 arg = *srcBuf++;
1149 srcBuf -= 3;
1150 if (printer->varBufferReadPos == 0) {
1151 printer->unk_52A = printer->fontVariant;
1153 }
1154
1155 do {
1156 s32 a0 = 1;
1157 argQ = gMessageMsgVars[arg][printer->varBufferReadPos++];
1158 if (argQ >= MSG_CONTROL_CHAR) {
1159 s32 tmp;
1160
1161 switch (argQ) {
1162 case MSG_CHAR_READ_ENDL:
1163 if (gMessageMsgVars[arg][printer->varBufferReadPos] != MSG_CHAR_READ_END) {
1165 } else {
1166 a0 = 0;
1167 }
1168 break;
1174 printer->fontVariant = sp10[0] + 0x10F;
1175 break;
1176#if !VERSION_JP
1179 break;
1180#endif
1183 switch (gMessageMsgVars[arg][printer->varBufferReadPos++]) {
1186 sp10[2] = gMessageMsgVars[arg][printer->varBufferReadPos++];
1187 a0 = 3;
1188 break;
1191 a0 = 2;
1192 break;
1195 a0 = 2;
1196 break;
1197 }
1198 break;
1199 }
1200 } else {
1201 sp10[0] = argQ;
1202 }
1203 for (i = 0; i < a0; i++) {
1204 arg1--;
1205 *printBuf++ = sp10[i];
1206 }
1207
1208 if (gMessageMsgVars[arg][printer->varBufferReadPos] == MSG_CHAR_READ_END) {
1209 srcBuf += 3;
1210 printer->varBufferReadPos = 0;
1211 printer->fontVariant = printer->unk_52A;
1212 *printBuf++ = MSG_CHAR_PRINT_VARIANT0 + printer->fontVariant;
1213 break;
1214 }
1215 } while ((printer->delayFlags & (MSG_DELAY_FLAG_4 | MSG_DELAY_FLAG_2)) || arg1 > 0);
1216
1217 if (!(printer->delayFlags & (MSG_DELAY_FLAG_4 | MSG_DELAY_FLAG_2)) && arg1 <= 0) {
1218 printer->delayFlags |= MSG_DELAY_FLAG_1;
1219 printer->curPrintDelay = printer->printDelayTime;
1220 }
1222 if (printer->stateFlags & MSG_STATE_FLAG_800000) {
1223 printer->stateFlags |= MSG_STATE_FLAG_SPEAKING;
1224 }
1225 break;
1227 arg = *srcBuf++;
1228 printer->speechSoundType = arg;
1229 printer->speechSoundIDA = MsgVoices[arg].voiceA;
1230 printer->speechSoundIDB = MsgVoices[arg].voiceB;
1231 printer->speechPitchShift = MsgVoices[arg].pitchShift;
1232 break;
1234 printer->volume = *srcBuf++;
1235 break;
1237 arg = *srcBuf++;
1238 argQ = *srcBuf++;
1239 argW = *srcBuf++;
1240 argE = *srcBuf++;
1241 printer->speechSoundIDA = (arg << 0x18) + (argQ << 0x10) + (argW << 0x8) + (argE);
1242 arg = *srcBuf++;
1243 argQ = *srcBuf++;
1244 argW = *srcBuf++;
1245 argE = *srcBuf++;
1246 printer->speechSoundIDB = (arg << 0x18) + (argQ << 0x10) + (argW << 0x8) + (argE);
1247 break;
1251 *printBuf++ = *srcBuf++;
1252 break;
1254 if (*srcBuf++) {
1255 printer->stateFlags |= MSG_STATE_FLAG_40000;
1256 } else {
1257 printer->stateFlags &= ~MSG_STATE_FLAG_40000;
1258 }
1259 break;
1261 printer->stateFlags |= MSG_STATE_FLAG_80000;
1262 break;
1263 }
1264 break;
1265 default:
1266 *printBuf++ = c;
1267 arg1--;
1268#if VERSION_IQUE
1270 *printBuf++ = nextArg;
1271 srcBuf++;
1272 arg1--;
1273 }
1274#endif
1275 if (printer->fontVariant == 0 && c == MSG_CHAR_UNK_C3) {
1276 printer->stateFlags &= ~MSG_STATE_FLAG_SPEAKING;
1277 } else {
1279 if (printer->stateFlags & MSG_STATE_FLAG_800000) {
1280 printer->stateFlags |= MSG_STATE_FLAG_SPEAKING;
1281 }
1282 }
1283 break;
1284 }
1285
1286 if (!(printer->delayFlags & (MSG_DELAY_FLAG_4 | MSG_DELAY_FLAG_2)) && arg1 <= 0) {
1287 printer->delayFlags |= MSG_DELAY_FLAG_1;
1288 printer->curPrintDelay = printer->printDelayTime;
1289 }
1290 if (!(printer->delayFlags & MSG_DELAY_FLAG_1)) {
1291 continue;
1292 }
1293 if (!s8) {
1294 break;
1295 }
1296 if (srcBuf[-1] == MSG_CHAR_READ_END) {
1297 break;
1298 }
1299 arg1 = 10000;
1300 } while (TRUE);
1301
1302 printer->printBufferPos = printBuf - printer->printBuffer;
1303 printer->delayFlags = 0;
1304 printer->srcBufferPos = (u16)(s32)(srcBuf - (s32)printer->srcBuffer);
1306}
1307#endif
1308
1310 s32 i;
1311
1312 printer->printBufferSize = ARRAY_COUNT(printer->printBuffer);
1313 printer->printBuffer[0] = MSG_CHAR_PRINT_END;
1314 printer->printDelayTime = 1;
1315 printer->charsPerChunk = 1;
1316 printer->windowScrollRate = (s32)(6 / DT);
1317 printer->srcBuffer = NULL;
1318 printer->msgID = 0;
1319 printer->curPrintDelay = 0;
1320 printer->windowOffsetPos.x = 0;
1321 printer->windowOffsetPos.y = 0;
1322 printer->windowBasePos.x = 0;
1323 printer->windowBasePos.y = 0;
1324 printer->rewindArrowAnimState = REWIND_ARROW_STATE_INIT;
1325 printer->rewindArrowCounter = 0;
1326 printer->rewindArrowPos.x = 0;
1327 printer->rewindArrowPos.y = 0;
1328 printer->curLine = 0;
1329 printer->unkArraySize = 0;
1330 printer->maxOption = 0;
1331 printer->madeChoice = 0;
1332 printer->curOption = 0;
1333 printer->selectedOption = 0;
1334 printer->cancelOption = -1;
1335 printer->windowState = MSG_WINDOW_STATE_DONE;
1336 printer->stateFlags = 0;
1337 printer->delayFlags = 0;
1338 printer->closedWritebackBool = NULL;
1339 printer->printBufferPos = 0;
1340 printer->srcBufferPos = 0;
1341 printer->font = 0;
1342 printer->fontVariant = 0;
1343 printer->effectFrameCounter = 0;
1344 printer->curLinePos = 0;
1345 printer->unk_46C = 0;
1346 printer->lineCount = 0;
1347
1348 for (i = 0; i < ARRAY_COUNT(printer->animTimers); i++) {
1349 printer->curAnimFrame[i] = 0;
1350 printer->animTimers[i] = -1;
1351 }
1352
1353 printer->initOpenPos.x = 160;
1354 printer->initOpenPos.y = 40;
1355 printer->speechSoundType = -1;
1356 printer->speechPan = 64;
1357 printer->volume = 75;
1358 printer->rewindArrowCounter = 0;
1359 printer->style = 0;
1360 printer->fadeInCounter = 0;
1361 printer->openStartPos.x = 0;
1362 printer->openStartPos.y = 0;
1363 printer->fadeOutCounter = 0;
1364 printer->windowSize.y = 0;
1365 printer->windowSize.x = 0;
1366 printer->speechPitchShift = 0;
1367 printer->speechSoundIDA = 0;
1368 printer->speechSoundIDB = 0;
1369 printer->varBufferReadPos = 0;
1370 printer->curImageIndex = 0;
1371 printer->varImageScreenPos.x = 0;
1372 printer->varImageScreenPos.y = 0;
1373 printer->varImgHasBorder = 0;
1374 printer->varImgFinalAlpha = 255;
1375 printer->varImageDisplayState = 0;
1376 printer->varImageFadeTimer = 0;
1377 printer->letterBackgroundImg = NULL;
1378 printer->letterBackgroundPal = NULL;
1379 printer->letterContentImg = NULL;
1380 printer->letterContentPal = NULL;
1381 printer->sizeScale = 1.0f;
1382}
1383
1384#if VERSION_PAL
1385void dma_load_msg(u32 msgID, void* dest) {
1387 u8* new_langPtr;
1388 u8* addr = (u8*) langPtr + (msgID >> 14); // (msgID >> 16) * 4
1389 u8* offset[2]; // start, end
1390
1391 dma_copy(addr, addr + 4, &offset[0]); // Load section offset
1392
1394 new_langPtr = offset[0] + ((u32) new_langPtr);
1395 addr = new_langPtr + ((msgID & 0xFFFF) * 4);
1396 dma_copy(addr, addr + 8, &offset); // Load message start and end offsets
1397
1398 // Load the msg data
1399 dma_copy(&langPtr[(u32)offset[0]], &langPtr[(u32)offset[1]], dest);
1400}
1401#else
1402void dma_load_msg(u32 msgID, void* dest) {
1403 u8* addr = (u8*) MSG_ROM_START + (msgID >> 14); // (msgID >> 16) * 4
1404 u8* offset[2]; // start, end
1405
1406 dma_copy(addr, addr + 4, &offset[0]); // Load section offset
1407
1408 addr = MSG_ROM_START + offset[0] + (msgID & 0xFFFF) * 4;
1409 dma_copy(addr, addr + 8, &offset); // Load message start and end offsets
1410
1411 // Load the msg data
1412 dma_copy(MSG_ROM_START + offset[0], MSG_ROM_START + offset[1], dest);
1413}
1414#endif
1415
1418
1419 dma_load_msg(msgID, &gMessageBuffers[gNextMessageBuffer]);
1420 prevBufferPos = gMessageBuffers[gNextMessageBuffer];
1421
1423 if (gNextMessageBuffer >= ARRAY_COUNT(gMessageBuffers)) {
1425 }
1426
1427 return prevBufferPos;
1428}
1429
1433
1436 s8* srcBuffer;
1437 s32 height;
1438 s32 width;
1439 s32 maxLineChars;
1440 s32 numLines;
1441 s32 maxLinesPerPage;
1442 s32 i;
1443
1444 if (msgID == MSG_NONE) {
1445 return NULL;
1446 }
1447
1448 srcBuffer = (s8*) msgID;
1449 if (msgID >= 0) {
1450 srcBuffer = load_message_to_buffer((s32)srcBuffer);
1451 }
1452
1453 for (i = 0; i < ARRAY_COUNT(gMessagePrinters); i++) {
1454 printer = &gMessagePrinters[i];
1455
1456 if (!(printer->stateFlags & MSG_STATE_FLAG_2)) {
1458 printer->windowState = MSG_WINDOW_STATE_INIT;
1459 printer->srcBuffer = srcBuffer;
1460 printer->msgID = msgID;
1461 printer->stateFlags |= MSG_STATE_FLAG_2;
1462 get_msg_properties(msgID, &height, &width, &maxLineChars, &numLines, &maxLinesPerPage, NULL, 0);
1463 printer->msgHeight = height;
1464 printer->msgWidth = width;
1465 printer->maxLineChars = maxLineChars;
1466 printer->numLines = numLines;
1467 printer->maxLinesPerPage = maxLinesPerPage;
1468 printer->closedWritebackBool = donePrintingWriteback;
1469
1470 if (donePrintingWriteback != NULL) {
1472 }
1473 return printer;
1474 }
1475 }
1476
1477 return NULL;
1478}
1479
1481 s8* buffer;
1482
1483 if (msgID >= 0) {
1484 buffer = load_message_to_buffer(msgID);
1485 } else {
1486 buffer = (s8*) msgID;
1487 }
1488
1489 printer->srcBuffer = buffer;
1490 printer->srcBufferPos = 0;
1491 printer->stateFlags &= ~MSG_STATE_FLAG_40;
1492 return 1;
1493}
1494
1496 msgPrintState->initOpenPos.x = x;
1497 msgPrintState->initOpenPos.y = y;
1498
1499 if (msgPrintState->initOpenPos.x < 0) {
1500 msgPrintState->initOpenPos.x = 0;
1501 }
1502 if (msgPrintState->initOpenPos.x > SCREEN_WIDTH) {
1503 msgPrintState->initOpenPos.x = SCREEN_WIDTH;
1504 }
1505 if (msgPrintState->initOpenPos.y < 0) {
1506 msgPrintState->initOpenPos.y = 0;
1507 }
1508 if (msgPrintState->initOpenPos.y > 220) {
1509 msgPrintState->initOpenPos.y = 220;
1510 }
1511}
1512
1514 if (!(msgPrintState->stateFlags & MSG_STATE_FLAG_2)) {
1515 return FALSE;
1516 }
1517
1518 msgPrintState->stateFlags |= MSG_STATE_FLAG_1;
1519 return TRUE;
1520}
1521
1525
1526void set_message_text_var(s32 msgID, s32 index) {
1527 u8* mallocSpace = NULL;
1528 s32 i;
1529 u8* msgVars;
1530
1531 if (msgID >= 0) {
1533 dma_load_msg(msgID, mallocSpace);
1534 msgID = (s32)mallocSpace;
1535 }
1536
1537 i = 0;
1538 msgVars = gMessageMsgVars[index];
1539 while (TRUE) {
1540 msgVars[i] = ((u8*)msgID)[i];
1541 if (((u8*)msgID)[i] == MSG_CHAR_READ_END) {
1542 break;
1543 }
1544
1545 if (++i >= 32) {
1546 msgVars[i - 1] = MSG_CHAR_READ_END;
1547 break;
1548 }
1549 }
1550
1551 if (mallocSpace != NULL) {
1553 }
1554}
1555
1556void set_message_int_var(s32 value, s32 index) {
1557 s8 strBuffer[ARRAY_COUNT(gMessageMsgVars[index])];
1558 s8* bufferIt;
1559 s32 i;
1560
1561 int_to_string(value, strBuffer, 10);
1562
1563 for (i = 0, bufferIt = strBuffer; i < ARRAY_COUNT(gMessageMsgVars[index]) - 1; i++) {
1564 s8 thisChar = bufferIt[i];
1565
1566 if (thisChar == 0) {
1567 break;
1568 }
1569 gMessageMsgVars[index][i] = thisChar - '0' + MSG_CHAR_DIGIT_0;
1570 }
1571 gMessageMsgVars[index][i] = MSG_CHAR_READ_END;
1572}
1573
1577
1578#if VERSION_JP
1579#define CHAR_SPACE_MULTIPLIER 0.7
1580#else
1581#define CHAR_SPACE_MULTIPLIER 0.6
1582#endif
1583
1584s32 msg_get_print_char_width(s32 character, s32 charset, s32 variation, f32 msgScale, s32 overrideCharWidth, u8 flags) {
1585 f32 charWidth;
1586
1591 return 0;
1592 }
1593
1594#if VERSION_IQUE
1596 charWidth = 16.0;
1597 return charWidth * msgScale;
1598 }
1599#endif
1600
1601 if (overrideCharWidth != 0) {
1602 charWidth = overrideCharWidth;
1603 } else if (flags != 0) {
1604 u8* charWidthTable = MsgCharsets[charset]->rasters[variation].charWidthTable;
1605
1606 if (charWidthTable != NULL
1610 charWidth = charWidthTable[character];
1611 } else {
1612 charWidth = MsgCharsets[charset]->rasters[variation].monospaceWidth;
1613 }
1614 } else {
1615 charWidth = MsgCharsets[charset]->rasters[variation].monospaceWidth;
1616 }
1617
1619 return charWidth * msgScale * CHAR_SPACE_MULTIPLIER;
1620 }
1622 f64 retWidth = charWidth * msgScale;
1623 return retWidth;
1624 }
1626 return charWidth * msgScale * 0.5;
1627 }
1628 if (character >= MSG_CONTROL_CHAR) {
1629 return 0;
1630 }
1631 return charWidth * msgScale;
1632}
1633
1634s32 msg_get_draw_char_width(s32 character, s32 charset, s32 variation, f32 msgScale, s32 overrideCharWidth, u16 flags) {
1635 f32 baseWidth;
1636
1641 return 0;
1642 }
1643
1644 if (overrideCharWidth != 0) {
1646 } else if (flags & MSG_PRINT_FLAG_100) {
1647 u8* charWidthTable = MsgCharsets[charset]->rasters[variation].charWidthTable;
1648
1649 if (charWidthTable != NULL
1653 baseWidth = charWidthTable[character];
1654 } else {
1656 }
1657 } else {
1659 }
1660
1662 return baseWidth * msgScale * CHAR_SPACE_MULTIPLIER;
1663 }
1665 f64 charWidth = baseWidth * msgScale;
1666 return charWidth;
1667 }
1669 return baseWidth * msgScale * 0.5;
1670 }
1671 if (character >= MSG_CONTROL_CHAR) {
1672 return 0;
1673 }
1674 return baseWidth * msgScale;
1675}
1676
1677void get_msg_properties(s32 msgID, s32* height, s32* width, s32* maxLineChars, s32* numLines, s32* maxLinesPerPage, s32* numSpaces, u16 charset) {
1678 u8* message;
1679 s32 i;
1680 u16 pageCount;
1681 s32 linesOnPage;
1682 u8 stop;
1683 s32 lineWidth;
1684 s32 charCount;
1685 u16 lineIndex;
1686 s32 msgStyle;
1687 s32 functionCode;
1689 f32 scale;
1690 s32 temp;
1691
1692 u16 lineWidths[32];
1693 u16 lineCharNumbers[32];
1694 u16 linesPerPage[32];
1695 s32 lineCount;
1696 u16 varIndex;
1697 u16 font;
1698 u8* buffer;
1699 u16 maxLineWidth;
1700 u16 maxCharsPerLine;
1701 u16 maxLinesOnPage;
1702 u16 spaceCount;
1703 u16 endl;
1704
1705 u8 c;
1706 u8 prevChar;
1707
1708 scale = 1.0f;
1709 c = 0;
1710 lineIndex = 0;
1711 pageCount = 0;
1712 varIndex = 0;
1713 font = 0;
1714 buffer = NULL;
1715 maxLineWidth = 0;
1716 maxCharsPerLine = 0;
1717 maxLinesOnPage = 0;
1718 spaceCount = 0;
1719
1720 if (msgID == MSG_NONE) {
1721 return;
1722 }
1723
1724 if (msgID >= 0) {
1725 buffer = general_heap_malloc(0x400);
1726 dma_load_msg(msgID, buffer);
1727 message = buffer;
1728 } else {
1729 message = (u8*)msgID;
1730 }
1731
1732 if (charset & 1) {
1733 font = 1;
1734 }
1735
1736 i = 0;
1737 stop = FALSE;
1738 lineWidth = 0;
1739 linesOnPage = 0;
1740 charCount = 0;
1741 endl = TRUE;
1742 lineCount = 0;
1743
1744 do {
1745 prevChar = c;
1746 c = message[i++];
1747 switch (c) {
1752 varIndex = c - MSG_CHAR_READ_VARIANT0;
1753 break;
1755 i++;
1756 break;
1757 case MSG_CHAR_READ_WAIT:
1758 case MSG_CHAR_READ_NEXT:
1759 if (linesOnPage != 0) {
1761 pageCount++;
1762 if (pageCount >= 32) {
1763 stop = 1;
1764 }
1765 linesOnPage = 0;
1766 }
1767 break;
1768 case MSG_CHAR_READ_ENDL:
1771 lineIndex++;
1772 if (lineIndex >= 32) {
1773 stop = 1;
1774 }
1775 lineWidth = 0;
1776 charCount = 0;
1777 endl = TRUE;
1778 break;
1780 msgStyle = message[i++];
1781 switch (msgStyle) {
1782 case MSG_STYLE_CHOICE:
1783 i += 4;
1784 break;
1785 case MSG_STYLE_POSTCARD:
1786 i++;
1787 break;
1788 case MSG_STYLE_RIGHT:
1789 case MSG_STYLE_LEFT:
1790 case MSG_STYLE_CENTER:
1791 case MSG_STYLE_TATTLE:
1792 case MSG_STYLE_INSPECT:
1793 case MSG_STYLE_SIGN:
1794 case MSG_STYLE_LAMPPOST:
1795 case MSG_STYLE_POPUP:
1796 case MSG_STYLE_B:
1797 break;
1798 }
1799 break;
1800 case MSG_CHAR_READ_END:
1803 lineIndex++;
1804 stop = TRUE;
1805 break;
1807 functionCode = message[i++];
1808 switch (functionCode) {
1809 case MSG_READ_FUNC_FONT:
1810 font = message[i++];
1811 break;
1823 break;
1824 default:
1825 stop = TRUE;
1826 break;
1828 i++;
1829 // fallthrough
1830 temp = 4;
1832 i += temp;
1833 // fallthrough
1836 i++;
1837 // fallthrough
1841 i++;
1842 // fallthrough
1848 case MSG_READ_FUNC_DOWN:
1849 case MSG_READ_FUNC_UP:
1861 i++;
1862 break;
1864 if (message[i] == 0) {
1865 stop = TRUE;
1866 }
1867 i++;
1868 break;
1870 if (message[i] == MSG_CHAR_READ_END) {
1871 stop = TRUE;
1872 }
1873 break;
1874 case MSG_READ_FUNC_SIZE:
1875 packedScaleY = message[i + 1];
1876 i += 2;
1877 scale = (f32)(packedScaleY >> 4) + ((packedScaleY & 0xF) * 0.0625f);
1878 break;
1880 scale = 1.0f;
1881 break;
1883 switch (message[i++]) {
1884 case MSG_FX_STATIC:
1885 case MSG_FX_BLUR:
1886 case MSG_FX_DITHER_FADE:
1887 i++;
1888 break;
1889 case MSG_FX_SHAKE:
1890 case MSG_FX_WAVE:
1892 case MSG_FX_RAINBOW:
1893 case MSG_FX_GLOBAL_WAVE:
1895 case MSG_FX_RISE_PRINT:
1896 case MSG_FX_GROW_PRINT:
1897 case MSG_FX_SIZE_JITTER:
1898 case MSG_FX_SIZE_WAVE:
1899 case MSG_FX_DROP_SHADOW:
1900 break;
1901 }
1902 break;
1903 case MSG_READ_FUNC_VAR:
1904 lineWidth += get_msg_width((s32)gMessageMsgVars[message[i++]], 0);
1905 break;
1906 }
1907 break;
1909 break;
1913 spaceCount++;
1914 // fallthrough
1915 default:
1916 if (endl) {
1917 lineCount++;
1918 linesOnPage++;
1919 endl = FALSE;
1920 }
1921
1922#if VERSION_IQUE
1924 break;
1925 }
1926#endif
1927
1928 lineWidth += msg_get_print_char_width(c, font, varIndex, scale, 0, 1);
1929 charCount++;
1930 break;
1931 }
1932 } while (!stop);
1933
1934 if (buffer != NULL) {
1935 general_heap_free(buffer);
1936 }
1937
1938 for (i = 0; i < lineIndex; i++) {
1939 if (maxLineWidth < lineWidths[i]) {
1941 }
1944 }
1945 }
1946
1947 if (pageCount == 0) {
1949 } else {
1950 for (i = 0; i < pageCount; i++) {
1951 if (maxLinesOnPage < linesPerPage[i]) {
1953 }
1954 }
1955 }
1956
1957 if (width != NULL) {
1958 *width = maxLineWidth;
1959 }
1960 if (height != NULL) {
1961 *height = lineCount * MsgCharsets[font]->newLineY;
1962 }
1963 if (maxLineChars != NULL) {
1964 *maxLineChars = maxCharsPerLine;
1965 }
1966 if (numLines != NULL) {
1967 *numLines = lineCount;
1968 }
1969 if (maxLinesPerPage != NULL) {
1970 *maxLinesPerPage = maxLinesOnPage;
1971 }
1972 if (numSpaces != NULL) {
1974 }
1975}
1976
1977s32 get_msg_width(s32 msgID, u16 charset) {
1978 s32 width;
1979
1980 get_msg_properties(msgID, NULL, &width, NULL, NULL, NULL, NULL, charset);
1981 return width;
1982}
1983
1984#if !VERSION_JP
1985s32 get_msg_lines(s32 msgID) {
1986 s32 numLines;
1987
1988 get_msg_properties(msgID, NULL, NULL, NULL, &numLines, NULL, NULL, 0);
1989 return numLines;
1990}
1991#endif
1992
1993void draw_msg(s32 msgID, s32 posX, s32 posY, s32 opacity, s32 palette, u8 style) {
1996 u16 bufferPos;
1997 s8* mallocSpace;
1998 s32 charset;
1999 u16 flags;
2000 s32 width;
2001
2002 flags = 0;
2003 bufferPos = 0;
2004 mallocSpace = NULL;
2005 charset = 0;
2006
2007 if (msgID != 0) {
2008 if (style & DRAW_MSG_STYLE_MENU) {
2009 flags = 2;
2010 charset = 1;
2011 }
2012
2013 if (opacity < 0xFF) {
2014 flags |= 1;
2015 }
2016
2019
2020 if (msgID < 0) {
2021 printer->srcBuffer = (u8*)msgID;
2022 } else {
2024 dma_load_msg(msgID, mallocSpace);
2025 printer->srcBuffer = mallocSpace;
2026 get_msg_properties((s32) printer->srcBuffer, 0, &width, 0, 0, 0, 0, charset);
2027 printer->msgWidth = width;
2028 }
2029
2030 if (palette >= 0) {
2031 printer->printBuffer[bufferPos++] = MSG_CHAR_PRINT_FUNCTION;
2032 printer->printBuffer[bufferPos++] = MSG_PRINT_FUNC_COLOR;
2033 printer->printBuffer[bufferPos++] = palette;
2034 printer->printBufferPos += 3;
2035 }
2036
2037 if (style & DRAW_MSG_STYLE_WAVY) {
2038 printer->printBuffer[bufferPos++] = MSG_CHAR_PRINT_FUNCTION;
2039 printer->printBuffer[bufferPos++] = MSG_PRINT_FUNC_START_FX;
2040 printer->printBuffer[bufferPos++] = MSG_FX_GLOBAL_WAVE;
2041 printer->printBufferPos += 3;
2042 }
2043
2044 if (style & DRAW_MSG_STYLE_RAINBOW) {
2045 printer->printBuffer[bufferPos++] = MSG_CHAR_PRINT_FUNCTION;
2046 printer->printBuffer[bufferPos++] = MSG_PRINT_FUNC_START_FX;
2047 printer->printBuffer[bufferPos++] = MSG_FX_GLOBAL_RAINBOW;
2048 printer->printBufferPos += 3;
2049 }
2050
2051 if (style & DRAW_MSG_STYLE_DROP_SHADOW) {
2052 printer->printBuffer[bufferPos++] = MSG_CHAR_PRINT_FUNCTION;
2053 printer->printBuffer[bufferPos++] = MSG_PRINT_FUNC_START_FX;
2054 printer->printBuffer[bufferPos++] = MSG_FX_DROP_SHADOW;
2055 printer->printBufferPos += 3;
2056 }
2057
2059 appendGfx_message(printer, (s16)posX, (s16)posY, 0, 0, flags, opacity & 0xFF);
2060
2061 if (mallocSpace != NULL) {
2063 }
2064 }
2065}
2066
2068 MessagePrintState* printer = &gMessagePrinters[printerIndex];
2069 f32 angle = 0.0f;
2070 f32 scale = 1.0f;
2071 f32 colorG = 255.0f;
2072 f32 colorR = 255.0f;
2073 f32 colorB = 255.0f;
2074 Matrix4f sp18;
2075 Matrix4f sp58;
2076 f32 temp;
2077
2080
2081 switch (printer->rewindArrowAnimState) {
2083 printer->rewindArrowCounter = 0;
2084 printer->rewindArrowSwingPhase = 0;
2085 printer->rewindArrowAnimState = REWIND_ARROW_STATE_GROW;
2086 // fallthrough
2088 temp = printer->rewindArrowCounter;
2089 scale = temp * 0.2 + 0.5;
2090 if (++printer->rewindArrowCounter >= 4) {
2091 printer->rewindArrowCounter = 0;
2092 printer->rewindArrowAnimState = REWIND_ARROW_STATE_NEUTRAL;
2093 }
2094 break;
2096 if (++printer->rewindArrowCounter >= 25) {
2097 printer->rewindArrowCounter = 0;
2098 printer->rewindArrowAnimState = REWIND_ARROW_STATE_CHANGE_COLOR;
2099 }
2100 break;
2102 colorR = update_lerp(EASING_LINEAR, 255.0f, 224.0f, printer->rewindArrowCounter, 15);
2103 colorG = update_lerp(EASING_LINEAR, 255.0f, 224.0f, printer->rewindArrowCounter, 15);
2104 colorB = update_lerp(EASING_LINEAR, 255.0f, 208.0f, printer->rewindArrowCounter, 15);
2105 if (++printer->rewindArrowCounter >= 15) {
2106 printer->rewindArrowCounter = 0;
2107 printer->rewindArrowAnimState = REWIND_ARROW_STATE_CHANGE_COLOR_BACK;
2108 }
2109 break;
2111 colorR = update_lerp(EASING_LINEAR, 224.0f, 255.0f, printer->rewindArrowCounter, 15);
2112 colorG = update_lerp(EASING_LINEAR, 224.0f, 255.0f, printer->rewindArrowCounter, 15);
2113 colorB = update_lerp(EASING_LINEAR, 208.0f, 255.0f, printer->rewindArrowCounter, 15);
2114 if (++printer->rewindArrowCounter >= 15) {
2115 printer->rewindArrowCounter = 0;
2116 printer->rewindArrowAnimState = REWIND_ARROW_STATE_NEUTRAL;
2117 }
2118 break;
2119 }
2120
2122
2123 if (printer->rewindArrowAnimState == REWIND_ARROW_STATE_NEUTRAL ||
2124 printer->rewindArrowAnimState == REWIND_ARROW_STATE_CHANGE_COLOR ||
2125 printer->rewindArrowAnimState == REWIND_ARROW_STATE_CHANGE_COLOR_BACK) {
2126 angle = cosine(printer->rewindArrowSwingPhase) * 30.0f;
2127 printer->rewindArrowSwingPhase += 15;
2128 if (printer->rewindArrowSwingPhase >= 360) {
2129 printer->rewindArrowSwingPhase -= 360;
2130 }
2131 }
2132
2133 guTranslateF(sp18, printer->rewindArrowPos.x + 12, -(printer->rewindArrowPos.y + 12), 0);
2134 if (angle != 0.0) {
2135 guRotateF(sp58, angle, 0, 0, 1.0f);
2137 }
2138 if (scale != 1.0) {
2139 guScaleF(sp58, scale, scale, 1.0f);
2141 }
2142
2148 gSP2Triangles(gMainGfxPos++, 0, 2, 1, 0, 1, 2, 3, 0);
2149}
2150
2152 MessagePrintState* printer = &gMessagePrinters[printerIndex];
2153
2154 if (printer->rewindArrowCounter < 6) {
2156 printer->rewindArrowPos.y, 10, 10, SCREEN_WIDTH - 20, SCREEN_HEIGHT - 20, 255);
2157 }
2158
2159 printer->rewindArrowCounter++;
2160 if (printer->rewindArrowCounter >= 12) {
2161 printer->rewindArrowCounter = 0;
2162 }
2163}
2164
2166 s32 pointerAlpha = 255;
2167 s32 shadowAlpha = 72;
2169 s32 posX, posY;
2170
2171 if (printer->windowState == MSG_WINDOW_STATE_WAITING_FOR_CHOICE || (printer->stateFlags & MSG_STATE_FLAG_20000)) {
2172 posX = printer->windowOffsetPos.x + printer->windowBasePos.x + printer->cursorPosX[printer->selectedOption];
2173 posY = printer->windowOffsetPos.y + printer->windowBasePos.y + printer->cursorPosY[printer->selectedOption];
2174 } else {
2175 s32 baseX, baseY, targetX, targetY;
2176 f32 moveToTargetAlpha = (f32)(printer->scrollingTime + 1.0) / CHOICE_POINTER_MOVE_RATE;
2177
2178 baseX = printer->windowOffsetPos.x + printer->windowBasePos.x + printer->cursorPosX[printer->selectedOption];
2179 targetX = printer->windowOffsetPos.x + printer->windowBasePos.x + printer->cursorPosX[printer->targetOption];
2180 posX = baseX + (targetX - baseX) * moveToTargetAlpha;
2181
2182 baseY = printer->windowOffsetPos.y + printer->windowBasePos.y + printer->cursorPosY[printer->selectedOption];
2183 targetY = printer->windowOffsetPos.y + printer->windowBasePos.y + printer->cursorPosY[printer->targetOption];
2184 posY = baseY + (targetY - baseY) * moveToTargetAlpha;
2185 }
2186
2187 posY++;
2188 posX += (cosine(posInterpPhase * 38 + 270) + 1.0) * 0.5 * 3.2;
2189 posX -= 2;
2190
2191 if (printer->stateFlags & MSG_STATE_FLAG_20000) {
2192 u32 opacity;
2193 opacity = 255.0 - printer->fadeOutCounter * 46.0;
2194 pointerAlpha = opacity;
2195 opacity = 72.0 - printer->fadeOutCounter * 14.4;
2196 shadowAlpha = opacity;
2197 }
2198
2204 gDPSetPrimColor(gMainGfxPos++, 0, 0, 40, 40, 40, shadowAlpha);
2205 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);
2207}
2208
2209void draw_digit(IMG_PTR img, s32 charset, s32 posX, s32 posY) {
2211
2214 num->texWidth , num->texHeight,
2215 0, 0,
2216 num->texWidth - 1, num->texHeight - 1,
2217 0,
2222 4 * posX, 4 * posY,
2223 4 * (posX + num->texWidth), 4 * (posY + num->texHeight),
2225 0, 0,
2226 1 << 10, 1 << 10);
2227}
2228
2229void draw_number(s32 value, s32 x, s32 y, s32 charset, s32 palette, s32 opacity, u16 style) {
2230 u8 valueStr[24];
2231 s8 digits[24];
2232 s32 digitPosX[24];
2233 s32 i;
2234 s32 count;
2235 s32 posX;
2237 s32 texSize = gMsgNumbers[charset].texSize;
2238
2239#if !VERSION_JP
2240 y -= 2;
2241#endif
2242 if (y < 0 || y > 240) {
2243 return;
2244 }
2245
2246 int_to_string(value, valueStr, 10);
2247
2248 for (i = 0; i < 10; i++) {
2249 u8 digit;
2250 if (valueStr[i] == '\0') {
2251 break;
2252 }
2253
2254 // handle negative numbers
2255 if (valueStr[i] == '-') {
2257 continue;
2258 }
2259
2260 digit = valueStr[i] - '0';
2261 if (digit < 10){
2262 digits[i] = digit;
2263 }
2264 }
2265 posX = x;
2266 count = i;
2267
2269
2270 if (style & DRAW_NUMBER_STYLE_ALIGN_RIGHT) {
2271 for (i = count - 1; i >= 0; i--) {
2272 if ((style & DRAW_NUMBER_STYLE_MONOSPACE) || digits[i] < 0) {
2274 } else {
2275 posX -= gMsgNumbers[charset].digitWidth[digits[i]];
2276 }
2277 digitPosX[i] = posX;
2278 }
2279 } else {
2280 for (i = 0; i < count; i++) {
2281 digitPosX[i] = posX;
2282 if ((style & DRAW_NUMBER_STYLE_MONOSPACE) || digits[i] < 0) {
2284 } else {
2285 posX += gMsgNumbers[charset].digitWidth[digits[i]];
2286 }
2287 }
2288 }
2289
2290 if (style & DRAW_NUMBER_STYLE_DROP_SHADOW) {
2291 for (i = 0; i < count; i++) {
2295 gDPSetPrimColor(gMainGfxPos++, 0, 0, 40, 40, 40, 72);
2296 draw_digit(raster + digits[i] * texSize, charset, digitPosX[i] + 2, y + 2);
2298 }
2299 }
2300
2301 if (opacity == 255) {
2304 } else {
2307 gDPSetPrimColor(gMainGfxPos++, 0, 0, 255, 255, 255, opacity);
2308 }
2309
2311 for (i = 0; i < count; i++) {
2312 posX = digitPosX[i];
2313 if (posX > 0 && posX < 320) {
2314 draw_digit(raster + digits[i] * texSize, charset, posX, y);
2315 }
2316 }
2318}
BSS s32 PopupMenu_SelectedIndex
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:5387
@ DRAW_MSG_STYLE_MENU
Definition enums.h:5384
@ DRAW_MSG_STYLE_RAINBOW
Definition enums.h:5386
@ DRAW_MSG_STYLE_WAVY
Definition enums.h:5385
@ DRAW_NUMBER_STYLE_ALIGN_RIGHT
drawn to the left of posX
Definition enums.h:5392
@ DRAW_NUMBER_STYLE_DROP_SHADOW
Definition enums.h:5395
@ DRAW_NUMBER_STYLE_MONOSPACE
Definition enums.h:5393
@ MSG_STATE_FLAG_10000
Definition enums.h:6251
@ MSG_STATE_FLAG_4
Definition enums.h:6240
@ MSG_STATE_FLAG_40
Definition enums.h:6243
@ MSG_STATE_FLAG_PRINT_QUICKLY
Definition enums.h:6245
@ MSG_STATE_FLAG_1
Definition enums.h:6238
@ MSG_STATE_FLAG_80000
Definition enums.h:6254
@ MSG_STATE_FLAG_10
Definition enums.h:6241
@ MSG_STATE_FLAG_20
Definition enums.h:6242
@ MSG_STATE_FLAG_100000
Definition enums.h:6255
@ MSG_STATE_FLAG_800
Definition enums.h:6247
@ MSG_STATE_FLAG_800000
Definition enums.h:6256
@ MSG_STATE_FLAG_20000
Definition enums.h:6252
@ MSG_STATE_FLAG_40000
Definition enums.h:6253
@ MSG_STATE_FLAG_8000
Definition enums.h:6250
@ MSG_STATE_FLAG_1000
Definition enums.h:6248
@ MSG_STATE_FLAG_SPEAKING
Definition enums.h:6244
@ MSG_STATE_FLAG_2
Definition enums.h:6239
@ 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:6140
@ MSG_READ_FUNC_COLOR
Definition enums.h:6086
@ MSG_READ_FUNC_CURSOR
Definition enums.h:6111
@ MSG_READ_FUNC_RESTORE_COLOR
Definition enums.h:6118
@ MSG_READ_FUNC_VOLUME
Definition enums.h:6126
@ MSG_READ_FUNC_RESET_GFX
Definition enums.h:6084
@ MSG_PRINT_FUNC_UP
Definition enums.h:6142
@ MSG_READ_FUNC_START_FX
Definition enums.h:6119
@ MSG_READ_FUNC_INPUT_OFF
Definition enums.h:6088
@ MSG_PRINT_FUNC_COLOR
Definition enums.h:6133
@ MSG_PRINT_FUNC_OPTION
Definition enums.h:6150
@ MSG_READ_FUNC_VAR
Definition enums.h:6121
@ MSG_READ_FUNC_VARIANT
Definition enums.h:6082
@ MSG_READ_FUNC_SET_CURSOR
Definition enums.h:6110
@ MSG_READ_FUNC_SET_CANCEL
Definition enums.h:6113
@ MSG_READ_FUNC_DELAY_OFF
Definition enums.h:6090
@ MSG_PRINT_FUNC_FONT
Definition enums.h:6129
@ MSG_PRINT_FUNC_ITEM_ICON
Definition enums.h:6145
@ MSG_PRINT_FUNC_SPACING
Definition enums.h:6134
@ MSG_READ_FUNC_SAVE_COLOR
Definition enums.h:6117
@ MSG_READ_FUNC_VOICE
Definition enums.h:6127
@ MSG_READ_FUNC_SAVE_POS
Definition enums.h:6115
@ MSG_READ_FUNC_CUSTOM_VOICE
Definition enums.h:6125
@ MSG_PRINT_FUNC_ANIM_DELAY
Definition enums.h:6146
@ MSG_READ_FUNC_INLINE_IMAGE
Definition enums.h:6102
@ MSG_READ_FUNC_SET_X
Definition enums.h:6097
@ MSG_PRINT_FUNC_SET_Y
Definition enums.h:6139
@ MSG_PRINT_FUNC_ANIM_LOOP
Definition enums.h:6147
@ MSG_PRINT_FUNC_ANIM_SPRITE
Definition enums.h:6144
@ MSG_READ_FUNC_END_FX
Definition enums.h:6120
@ MSG_READ_FUNC_SET_Y
Definition enums.h:6098
@ MSG_PRINT_FUNC_INLINE_IMAGE
Definition enums.h:6143
@ MSG_PRINT_FUNC_SET_X
Definition enums.h:6138
@ MSG_PRINT_FUNC_SIZE_RESET
Definition enums.h:6137
@ MSG_READ_FUNC_SCROLL
Definition enums.h:6093
@ MSG_PRINT_FUNC_DOWN
Definition enums.h:6141
@ MSG_READ_FUNC_DOWN
Definition enums.h:6100
@ MSG_READ_FUNC_YIELD
Definition enums.h:6085
@ MSG_READ_FUNC_NO_SKIP
Definition enums.h:6087
@ MSG_PRINT_FUNC_SAVE_COLOR
Definition enums.h:6153
@ MSG_READ_FUNC_SPACING
Definition enums.h:6092
@ MSG_READ_FUNC_RESTORE_POS
Definition enums.h:6116
@ MSG_PRINT_FUNC_VARIANT
Definition enums.h:6130
@ MSG_READ_FUNC_SPEED
Definition enums.h:6096
@ MSG_READ_FUNC_OPTION
Definition enums.h:6114
@ MSG_READ_FUNC_SIZE
Definition enums.h:6094
@ MSG_READ_FUNC_ENABLE_CDOWN_NEXT
Definition enums.h:6124
@ MSG_READ_FUNC_HIDE_IMAGE
Definition enums.h:6106
@ MSG_READ_FUNC_DELAY_ON
Definition enums.h:6091
@ MSG_PRINT_FUNC_RESTORE_COLOR
Definition enums.h:6154
@ MSG_PRINT_FUNC_END_FX
Definition enums.h:6156
@ MSG_PRINT_FUNC_START_FX
Definition enums.h:6155
@ MSG_READ_FUNC_END_CHOICE
Definition enums.h:6112
@ MSG_READ_FUNC_IMAGE
Definition enums.h:6105
@ MSG_READ_FUNC_RIGHT
Definition enums.h:6099
@ MSG_PRINT_FUNC_RESTORE_POS
Definition enums.h:6152
@ MSG_READ_FUNC_ANIM_LOOP
Definition enums.h:6108
@ MSG_PRINT_FUNC_CURSOR
Definition enums.h:6149
@ MSG_READ_FUNC_CENTER_X
Definition enums.h:6122
@ MSG_READ_FUNC_ANIM_DELAY
Definition enums.h:6107
@ MSG_READ_FUNC_ITEM_ICON
Definition enums.h:6104
@ MSG_READ_FUNC_SET_REWIND
Definition enums.h:6123
@ MSG_PRINT_FUNC_SIZE
Definition enums.h:6136
@ MSG_READ_FUNC_UP
Definition enums.h:6101
@ MSG_PRINT_FUNC_ANIM_DONE
Definition enums.h:6148
@ MSG_READ_FUNC_INPUT_ON
Definition enums.h:6089
@ MSG_READ_FUNC_FONT
Definition enums.h:6081
@ MSG_READ_FUNC_SIZE_RESET
Definition enums.h:6095
@ MSG_PRINT_FUNC_CENTER_X
Definition enums.h:6157
@ MSG_PRINT_FUNC_SAVE_POS
Definition enums.h:6151
@ MSG_READ_FUNC_ANIM_SPRITE
Definition enums.h:6103
@ MSG_PRINT_RESET_GFX
Definition enums.h:6132
@ MSG_READ_FUNC_ANIM_DONE
Definition enums.h:6109
@ LANGUAGE_DE
Definition enums.h:6400
@ LANGUAGE_ES
Definition enums.h:6402
@ LANGUAGE_EN
Definition enums.h:6399
@ LANGUAGE_FR
Definition enums.h:6401
MsgVoices
Definition enums.h:6221
@ MSG_DELAY_FLAG_4
Definition enums.h:6262
@ MSG_DELAY_FLAG_2
Definition enums.h:6261
@ MSG_DELAY_FLAG_1
Definition enums.h:6260
@ EASING_LINEAR
Definition enums.h:510
@ MSG_STYLE_POSTCARD
Definition enums.h:6204
@ MSG_STYLE_CENTER
Definition enums.h:6198
@ MSG_STYLE_LEFT
Definition enums.h:6197
@ MSG_STYLE_UPGRADE
Definition enums.h:6207
@ MSG_STYLE_SIGN
Definition enums.h:6202
@ MSG_STYLE_F
Definition enums.h:6210
@ MSG_STYLE_B
Definition enums.h:6206
@ MSG_STYLE_NARRATE
Definition enums.h:6208
@ MSG_STYLE_INSPECT
Definition enums.h:6201
@ MSG_STYLE_LAMPPOST
Definition enums.h:6203
@ MSG_STYLE_POPUP
Definition enums.h:6205
@ MSG_STYLE_RIGHT
Definition enums.h:6196
@ MSG_STYLE_EPILOGUE
Definition enums.h:6209
@ MSG_STYLE_TATTLE
Definition enums.h:6199
@ MSG_STYLE_CHOICE
Definition enums.h:6200
@ MSG_PRINT_FLAG_100
Definition enums.h:6234
@ 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:6163
@ MSG_FX_RISE_PRINT
Definition enums.h:6170
@ MSG_FX_SIZE_JITTER
Definition enums.h:6172
@ MSG_FX_SHAKE
Definition enums.h:6161
@ MSG_FX_GLOBAL_WAVE
Definition enums.h:6168
@ MSG_FX_GLOBAL_RAINBOW
Definition enums.h:6169
@ MSG_FX_DROP_SHADOW
Definition enums.h:6174
@ MSG_FX_SIZE_WAVE
Definition enums.h:6173
@ MSG_FX_STATIC
Definition enums.h:6164
@ MSG_FX_BLUR
Definition enums.h:6165
@ MSG_FX_DITHER_FADE
Definition enums.h:6167
@ MSG_FX_WAVE
Definition enums.h:6162
@ MSG_FX_RAINBOW
Definition enums.h:6166
@ MSG_FX_GROW_PRINT
Definition enums.h:6171
@ MSG_CHAR_LOWER_S
Definition enums.h:5938
@ MSG_CHAR_READ_VARIANT2
Definition enums.h:6047
@ MSG_CHAR_DIGIT_0
Definition enums.h:5871
@ MSG_CHAR_READ_PAUSE
Definition enums.h:6044
@ MSG_CHAR_PRINT_SPACE
Definition enums.h:6066
@ MSG_CHAR_READ_WAIT
Definition enums.h:6043
@ MSG_CHAR_MINUS
Definition enums.h:5868
@ MSG_CHAR_READ_HALF_SPACE
Definition enums.h:6051
@ MSG_CHAR_READ_SPACE
Definition enums.h:6049
@ MSG_CHAR_PRINT_NEXT
Definition enums.h:6071
@ MSG_CHAR_READ_VARIANT3
Definition enums.h:6048
@ MSG_CHAR_READ_STYLE
Definition enums.h:6054
@ MSG_CHAR_PRINT_END
Definition enums.h:6072
@ MSG_CHAR_PRINT_ENDL
Definition enums.h:6061
@ MSG_CHAR_READ_FULL_SPACE
Definition enums.h:6050
@ MSG_CHAR_READ_UNK_CHAR_FA
Definition enums.h:6052
@ MSG_CHAR_READ_NEXT
Definition enums.h:6053
@ MSG_CHAR_PRINT_FULL_SPACE
Definition enums.h:6067
@ MSG_CHAR_READ_VARIANT0
Definition enums.h:6045
@ MSG_CHAR_PRINT_VARIANT0
Definition enums.h:6062
@ MSG_CHAR_PRINT_FUNCTION
Definition enums.h:6076
@ MSG_CHAR_PRINT_STYLE
Definition enums.h:6069
@ MSG_CHAR_PRINT_UNK_CHAR_FA
Definition enums.h:6070
@ MSG_CHAR_READ_ENDL
Definition enums.h:6042
@ MSG_CHAR_PRINT_HALF_SPACE
Definition enums.h:6068
@ MSG_CHAR_UNK_C3
Definition enums.h:6033
@ MSG_CHAR_READ_END
Definition enums.h:6055
@ MSG_CHAR_READ_VARIANT1
Definition enums.h:6046
@ MSG_CHAR_LOWER_N
Definition enums.h:5933
@ MSG_CONTROL_CHAR
Definition enums.h:6060
@ MSG_CHAR_READ_FUNCTION
Definition enums.h:6057
@ MSG_WINDOW_STATE_DONE
Definition enums.h:6266
@ MSG_WINDOW_STATE_B
Definition enums.h:6277
@ MSG_WINDOW_STATE_WAITING
Definition enums.h:6271
@ MSG_WINDOW_STATE_WAITING_FOR_CHOICE
Definition enums.h:6273
@ MSG_WINDOW_STATE_INIT
Definition enums.h:6267
@ MSG_WINDOW_STATE_OPENING
Definition enums.h:6268
@ MSG_WINDOW_STATE_SCROLLING
Definition enums.h:6272
@ MSG_WINDOW_STATE_PRINTING
Definition enums.h:6270
@ MSG_WINDOW_STATE_C
Definition enums.h:6278
@ MSG_WINDOW_STATE_E
Definition enums.h:6280
@ MSG_WINDOW_STATE_SCROLLING_BACK
Definition enums.h:6274
@ MSG_WINDOW_STATE_D
Definition enums.h:6279
@ MSG_WINDOW_STATE_CLOSING
Definition enums.h:6269
@ MSG_WINDOW_STATE_VIEWING_PREV
Definition enums.h:6275
@ MSG_WINDOW_STATE_A
Definition enums.h:6276
f32 update_lerp(s32 easing, f32 start, f32 end, s32 elapsed, s32 duration)
Definition 43F0.c:733
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:352
u32 dma_copy(Addr romStart, Addr romEnd, void *vramDest)
Definition 43F0.c:442
s32 general_heap_free(void *data)
Definition heap.c:18
char * int_to_string(s32, char *, s32)
Definition 43F0.c:384
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:2151
void get_msg_properties(s32 msgID, s32 *height, s32 *width, s32 *maxLineChars, s32 *numLines, s32 *maxLinesPerPage, s32 *numSpaces, u16 charset)
Definition msg.c:1677
IMG_BIN ui_msg_rewind_arrow_png[]
void msg_printer_set_origin_pos(MessagePrintState *msgPrintState, s32 x, s32 y)
Definition msg.c:1495
MessagePrintState * _msg_get_printer_for_msg(s32 msgID, s32 *donePrintingWriteback, s32 arg2)
Definition msg.c:1434
s16 gNextMessageBuffer
Definition msg.c:62
s32 cancel_message(MessagePrintState *msgPrintState)
Definition msg.c:1513
s8 * load_message_to_buffer(s32 msgID)
Definition msg.c:1416
IMG_BIN MsgCharImgSubtitle[]
Definition msg_img.c:92
PAL_BIN D_8015C7E0[0x10]
Definition msg.c:105
void render_messages(void)
Definition msg.c:574
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:1584
PAL_BIN ui_msg_rewind_arrow_pal[]
void close_message(MessagePrintState *msgPrintState)
Definition msg.c:1574
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:2209
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:1402
s32 msg_get_draw_char_width(s32 character, s32 charset, s32 variation, f32 msgScale, s32 overrideCharWidth, u16 flags)
Definition msg.c:1634
void msg_play_speech_sound(MessagePrintState *printer, u8 character)
Definition msg.c:615
s32 gMsgBGScrollAmtY
Definition msg.c:91
void initialize_printer(MessagePrintState *printer, s32 arg1, s32 arg2)
Definition msg.c:1309
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:1985
MessageNumber gMsgNumbers[]
Definition msg.c:129
PAL_BIN D_802F4560[80][8]
void set_message_int_var(s32 value, s32 index)
Definition msg.c:1556
void set_message_text_var(s32 msgID, s32 index)
Definition msg.c:1526
Gfx D_8014C2D8[]
Definition msg.c:71
IMG_BIN ui_msg_star_silhouette_png[]
void msg_update_rewind_arrow(s32)
Definition msg.c:2067
MessagePrintState * msg_get_printer_for_msg(s32 msgID, s32 *donePrintingWriteback)
Definition msg.c:1430
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:648
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:2229
void set_message_images(MessageImageData *images)
Definition msg.c:1522
MessageImageDataList gMsgVarImages
Definition msg.c:90
IMG_BIN ui_point_right_png[]
s32 msg_printer_load_msg(s32 msgID, MessagePrintState *printer)
Definition msg.c:1480
s32 _update_message(MessagePrintState *printer)
Definition msg.c:277
MessageCharset * MsgCharsets[5]
Definition msg_data.c:865
void msg_draw_choice_pointer(MessagePrintState *printer)
Definition msg.c:2165
#define CHAR_SPACE_MULTIPLIER
Definition msg.c:1581
IMG_PTR MsgLetterRasterOffsets[]
Definition msg_data.c:878
void update_messages(void)
Definition msg.c:253
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:301
#define PM_CC_07
Definition macros.h:286
#define SCREEN_WIDTH
Definition macros.h:109
#define ARRAY_COUNT(arr)
Definition macros.h:40
#define PM_CC_01
Definition macros.h:280
#define SCREEN_HEIGHT
Definition macros.h:110
#define DT
Definition macros.h:526
#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:119
GameStatus * gGameStatusPtr
Definition main_loop.c:31
Gfx * gMainGfxPos
Definition cam_main.c:14
u16 gMatrixListPos
Definition main_loop.c:44
s32 gCurrentDisplayContextIndex
Definition main_loop.c:46
DisplayContext * gDisplayContext
Definition cam_main.c:15