Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
msg.c File Reference

Go to the source code of this file.

Macros

#define MSG_ROM_START   0x1B83000
 
#define CHOICE_POINTER_MOVE_RATE   6.0
 
#define CHAR_SPACE_MULTIPLIER   0.6
 

Typedefs

typedef MessageImageDataMessageImageDataList[1]
 

Enumerations

enum  RewindArrowStates {
  REWIND_ARROW_STATE_INIT = 0 , REWIND_ARROW_STATE_GROW = 1 , REWIND_ARROW_STATE_NEUTRAL = 2 , REWIND_ARROW_STATE_CHANGE_COLOR = 3 ,
  REWIND_ARROW_STATE_CHANGE_COLOR_BACK = 4
}
 

Functions

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)
 
s32 _update_message (MessagePrintState *printer)
 
void msg_copy_to_print_buffer (MessagePrintState *printer, s32 arg1, s32 arg2)
 
void initialize_printer (MessagePrintState *printer, s32 arg1, s32 arg2)
 
MessagePrintState_msg_get_printer_for_msg (s32 msgID, s32 *donePrintingWriteback, s32 arg2)
 
void msg_update_rewind_arrow (s32)
 
void msg_draw_rewind_arrow (s32)
 
void msg_draw_choice_pointer (MessagePrintState *printer)
 
void draw_message_window (MessagePrintState *printer)
 
void appendGfx_message (MessagePrintState *, s16, s16, u16, u16, u16, u8)
 
void clear_character_set (void)
 
void clear_printers (void)
 
void load_font_data (Addr offset, u16 size, void *dest)
 
void load_font (s32 font)
 
void update_messages (void)
 
void render_messages (void)
 
void msg_play_speech_sound (MessagePrintState *printer, u8 character)
 
void dma_load_msg (u32 msgID, void *dest)
 
s8 * load_message_to_buffer (s32 msgID)
 
MessagePrintStatemsg_get_printer_for_msg (s32 msgID, s32 *donePrintingWriteback)
 
s32 msg_printer_load_msg (s32 msgID, MessagePrintState *printer)
 
void msg_printer_set_origin_pos (MessagePrintState *msgPrintState, s32 x, s32 y)
 
s32 cancel_message (MessagePrintState *msgPrintState)
 
void set_message_images (MessageImageData *images)
 
void set_message_text_var (s32 msgID, s32 index)
 
void set_message_int_var (s32 value, s32 index)
 
void close_message (MessagePrintState *msgPrintState)
 
s32 msg_get_print_char_width (s32 character, s32 charset, s32 variation, f32 msgScale, s32 overrideCharWidth, u8 flags)
 
s32 msg_get_draw_char_width (s32 character, s32 charset, s32 variation, f32 msgScale, s32 overrideCharWidth, u16 flags)
 
void get_msg_properties (s32 msgID, s32 *height, s32 *width, s32 *maxLineChars, s32 *numLines, s32 *maxLinesPerPage, s32 *numSpaces, u16 charset)
 
s32 get_msg_width (s32 msgID, u16 charset)
 
s32 get_msg_lines (s32 msgID)
 
void draw_msg (s32 msgID, s32 posX, s32 posY, s32 opacity, s32 palette, u8 style)
 
void draw_digit (IMG_PTR img, s32 charset, s32 posX, s32 posY)
 
void draw_number (s32 value, s32 x, s32 y, s32 charset, s32 palette, s32 opacity, u16 style)
 

Variables

Vp D_8014C280
 
u8 MessagePlural [] = { MSG_CHAR_LOWER_S, MSG_CHAR_READ_END }
 
u8 MessageSingular [] = { MSG_CHAR_READ_ENDL, MSG_CHAR_READ_END }
 
s16 gNextMessageBuffer = 0
 
Vtx gRewindArrowQuad []
 
Gfx D_8014C2D8 []
 
s32 gMsgBGScrollAmtX
 
u16 gMsgGlobalWaveCounter
 
MessageImageDataList gMsgVarImages
 
s32 gMsgBGScrollAmtY
 
u8 * D_8015131C
 
Gfx * D_80151338
 
IMG_BIN D_80159B50 [0x200]
 
PAL_BIN D_8015C7E0 [0x10]
 
s16 MsgStyleVerticalLineOffsets []
 
IMG_BIN ui_msg_rewind_arrow_png []
 
PAL_BIN ui_msg_rewind_arrow_pal []
 
IMG_BIN ui_msg_star_png []
 
IMG_BIN ui_msg_star_silhouette_png []
 
IMG_BIN MsgCharImgTitle []
 
IMG_BIN MsgCharImgNormal []
 
MessageCharsetMsgCharsets [5]
 
IMG_BIN MsgCharImgSubtitle []
 
PAL_BIN D_802F4560 [80][8]
 
IMG_BIN ui_point_right_png []
 
PAL_BIN ui_point_right_pal []
 
MessageNumber gMsgNumbers []
 
Gfx gMsgDlistInitDrawNumber []
 
s32 gItemIconRasterOffsets []
 
s32 gItemIconPaletteOffsets []
 
IMG_PTR MsgLetterRasterOffsets []
 
PAL_PTR MsgLetterPaletteOffsets []
 
MsgVoice MsgVoices []
 

Macro Definition Documentation

◆ MSG_ROM_START

#define MSG_ROM_START   0x1B83000

Definition at line 23 of file msg.c.

Referenced by dma_load_msg().

◆ CHOICE_POINTER_MOVE_RATE

#define CHOICE_POINTER_MOVE_RATE   6.0

Definition at line 29 of file msg.c.

Referenced by msg_draw_choice_pointer().

◆ CHAR_SPACE_MULTIPLIER

#define CHAR_SPACE_MULTIPLIER   0.6

Definition at line 1575 of file msg.c.

Referenced by msg_get_draw_char_width(), and msg_get_print_char_width().

Typedef Documentation

◆ MessageImageDataList

typedef MessageImageData* MessageImageDataList[1]

Definition at line 32 of file msg.c.

Enumeration Type Documentation

◆ RewindArrowStates

Enumerator
REWIND_ARROW_STATE_INIT 
REWIND_ARROW_STATE_GROW 
REWIND_ARROW_STATE_NEUTRAL 
REWIND_ARROW_STATE_CHANGE_COLOR 
REWIND_ARROW_STATE_CHANGE_COLOR_BACK 

Definition at line 10 of file msg.c.

10 {
16};
@ 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

Function Documentation

◆ draw_image_with_clipping()

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 )

Referenced by msg_draw_choice_pointer().

◆ _update_message()

s32 _update_message ( MessagePrintState * printer)

Definition at line 271 of file msg.c.

271 {
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}
u32 pressedButtons[4]
@ 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_20000
Definition enums.h:6253
@ MSG_STATE_FLAG_40000
Definition enums.h:6254
@ MSG_STATE_FLAG_SPEAKING
Definition enums.h:6245
@ 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_STYLE_CENTER
Definition enums.h:6199
@ MSG_STYLE_LEFT
Definition enums.h:6198
@ MSG_STYLE_SIGN
Definition enums.h:6203
@ MSG_STYLE_LAMPPOST
Definition enums.h:6204
@ MSG_STYLE_RIGHT
Definition enums.h:6197
@ MSG_STYLE_TATTLE
Definition enums.h:6200
@ SOUND_MSG_REWIND
Definition enums.h:704
@ SOUND_MENU_BACK
Definition enums.h:701
@ SOUND_MSG_UNREWIND
Definition enums.h:705
@ SOUND_MENU_CHANGE_SELECTION
Definition enums.h:698
@ SOUND_MSG_SKIP
Definition enums.h:703
@ SOUND_MENU_NEXT
Definition enums.h:700
@ MSG_CHAR_READ_WAIT
Definition enums.h:6044
@ MSG_CHAR_UNK_C3
Definition enums.h:6034
@ MSG_CHAR_READ_END
Definition enums.h:6056
@ 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
s32 general_heap_free(void *data)
Definition heap.c:18
void msg_copy_to_print_buffer(MessagePrintState *printer, s32 arg1, s32 arg2)
Definition msg.c:642
void sfx_play_sound_with_params(s32 soundID, u8 volume, u8 pan, s16 pitchShift)
Definition sfx.c:458
#define SCREEN_WIDTH
Definition macros.h:105
#define ARRAY_COUNT(arr)
Definition macros.h:40
#define DT
Definition macros.h:522
GameStatus * gGameStatusPtr
Definition main_loop.c:32

Referenced by update_messages().

◆ msg_copy_to_print_buffer()

void msg_copy_to_print_buffer ( MessagePrintState * printer,
s32 arg1,
s32 arg2 )

Definition at line 642 of file msg.c.

642 {
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}
unsigned char charset_postcard_OFFSET[]
unsigned short charset_postcard_pal_OFFSET[]
@ 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_8000
Definition enums.h:6251
@ MSG_STATE_FLAG_1000
Definition enums.h:6249
@ 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
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
@ MSG_STYLE_POSTCARD
Definition enums.h:6205
@ MSG_STYLE_UPGRADE
Definition enums.h:6208
@ 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_POPUP
Definition enums.h:6206
@ MSG_STYLE_EPILOGUE
Definition enums.h:6210
@ MSG_STYLE_CHOICE
Definition enums.h:6201
@ SOUND_MSG_VOICE_1A
Definition enums.h:562
@ SOUND_MENU_SHOW_CHOICE
Definition enums.h:554
@ SOUND_MSG_WAIT
Definition enums.h:702
@ SOUND_APPROVE
Definition enums.h:932
@ SOUND_MSG_VOICE_1B
Definition enums.h:563
@ 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_READ_VARIANT2
Definition enums.h:6048
@ MSG_CHAR_READ_PAUSE
Definition enums.h:6045
@ MSG_CHAR_PRINT_SPACE
Definition enums.h:6067
@ 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_READ_VARIANT1
Definition enums.h:6047
@ MSG_CONTROL_CHAR
Definition enums.h:6061
@ MSG_CHAR_READ_FUNCTION
Definition enums.h:6058
u32 dma_copy(Addr romStart, Addr romEnd, void *vramDest)
Definition 43F0.c:444
void * heap_malloc(s32 size)
Definition heap.c:34
s32 gItemIconPaletteOffsets[]
PAL_BIN D_8015C7E0[0x10]
Definition msg.c:105
IMG_BIN D_80159B50[0x200]
Definition msg.c:104
s16 MsgStyleVerticalLineOffsets[]
Definition msg_data.c:927
PAL_PTR MsgLetterPaletteOffsets[]
Definition msg_data.c:893
s32 gItemIconRasterOffsets[]
void msg_play_speech_sound(MessagePrintState *printer, u8 character)
Definition msg.c:609
MessageCharset * MsgCharsets[5]
Definition msg_data.c:865
IMG_PTR MsgLetterRasterOffsets[]
Definition msg_data.c:878
u8 * D_8015131C
Definition msg.c:92

Referenced by _update_message(), and draw_msg().

◆ initialize_printer()

void initialize_printer ( MessagePrintState * printer,
s32 arg1,
s32 arg2 )

Definition at line 1303 of file msg.c.

1303 {
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}

Referenced by _msg_get_printer_for_msg(), clear_printers(), and draw_msg().

◆ _msg_get_printer_for_msg()

MessagePrintState * _msg_get_printer_for_msg ( s32 msgID,
s32 * donePrintingWriteback,
s32 arg2 )

Definition at line 1428 of file msg.c.

1428 {
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}
@ MSG_STATE_FLAG_2
Definition enums.h:6240
void get_msg_properties(s32 msgID, s32 *height, s32 *width, s32 *maxLineChars, s32 *numLines, s32 *maxLinesPerPage, s32 *numSpaces, u16 charset)
Definition msg.c:1671
s8 * load_message_to_buffer(s32 msgID)
Definition msg.c:1410
void initialize_printer(MessagePrintState *printer, s32 arg1, s32 arg2)
Definition msg.c:1303

Referenced by msg_get_printer_for_msg().

◆ msg_update_rewind_arrow()

void msg_update_rewind_arrow ( s32 printerIndex)

Definition at line 2061 of file msg.c.

2061 {
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}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define guRotateF
#define guMtxF2L
#define guTranslateF
#define guMtxCatF
#define guScaleF
@ EASING_LINEAR
Definition enums.h:510
f32 update_lerp(s32 easing, f32 start, f32 end, s32 elapsed, s32 duration)
Definition 43F0.c:735
f32 cosine(s16 arg0)
Definition 43F0.c:354
Vtx gRewindArrowQuad[]
Definition msg.c:64
IMG_BIN ui_msg_star_png[]
Gfx D_8014C2D8[]
Definition msg.c:71
IMG_BIN ui_msg_star_silhouette_png[]
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
Gfx * gMainGfxPos
Definition cam_main.c:15
u16 gMatrixListPos
Definition main_loop.c:45
DisplayContext * gDisplayContext
Definition cam_main.c:16

Referenced by render_messages().

◆ msg_draw_rewind_arrow()

void msg_draw_rewind_arrow ( s32 printerIndex)

Definition at line 2145 of file msg.c.

2145 {
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}
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)
IMG_BIN ui_msg_rewind_arrow_png[]
PAL_BIN ui_msg_rewind_arrow_pal[]
#define SCREEN_HEIGHT
Definition macros.h:106

Referenced by render_messages().

◆ msg_draw_choice_pointer()

void msg_draw_choice_pointer ( MessagePrintState * printer)

Definition at line 2159 of file msg.c.

2159 {
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}
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)
#define CHOICE_POINTER_MOVE_RATE
Definition msg.c:29
IMG_BIN ui_point_right_png[]
PAL_BIN ui_point_right_pal[]
#define PM_CC_07
Definition macros.h:282

Referenced by render_messages().

◆ draw_message_window()

void draw_message_window ( MessagePrintState * printer)

Definition at line 137 of file msg_draw.c.

137 {
138 f32 scale = 1.0f;
139 s32 rotZ = 0;
140
141 switch (printer->windowState) {
143 scale = (f32)D_8014C580[printer->fadeInCounter] / 100.0;
144 rotZ = (4 - printer->fadeInCounter) * 3;
145 printer->fadeInCounter++;
146 if (D_8014C580[printer->fadeInCounter] == 0) {
148 }
149 break;
151 scale = (f32)D_8014C588[printer->fadeOutCounter] / 100.0;
152 rotZ = -printer->fadeOutCounter;
153 printer->fadeOutCounter++;
154 if (D_8014C588[printer->fadeOutCounter] == 0) {
155 printer->stateFlags |= MSG_STATE_FLAG_1;
156 }
157 break;
158 }
159
160 switch (printer->windowState) {
163 printer->windowBasePos.x = 160 - (printer->windowSize.x / 2);
164 printer->windowBasePos.y = 56;
165 draw_box(DRAW_FLAG_ROTSCALE, WINDOW_STYLE_0, printer->windowBasePos.x, 56, 0, printer->windowSize.x, printer->windowSize.y, 255, 0,
166 scale, scale, 0.0f, 0.0f, rotZ, drawbox_message_delegate, printer, NULL, SCREEN_WIDTH,
167 SCREEN_HEIGHT, NULL);
168 break;
169 default:
170 appendGfx_message(printer, printer->windowOffsetPos.x, printer->windowOffsetPos.y, printer->unk_46C,
171 printer->curLinePos, 4, 0);
172 break;
173 }
174}
#define draw_box
@ WINDOW_STYLE_0
Definition enums.h:6370
@ DRAW_FLAG_ROTSCALE
Definition enums.h:5003
void drawbox_message_delegate(s32 data, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening)
Definition msg_draw.c:131
u8 D_8014C588[]
Definition msg_draw.c:114
void appendGfx_message(MessagePrintState *, s16, s16, u16, u16, u16, u8)
Definition msg_draw.c:213
u8 D_8014C580[]
Definition msg_draw.c:113

Referenced by render_messages().

◆ appendGfx_message()

void appendGfx_message ( MessagePrintState * printer,
s16 posX,
s16 posY,
u16 additionalOffsetX,
u16 additionalOffsetY,
u16 flag,
u8 alpha )

Definition at line 213 of file msg_draw.c.

214 {
215 SpriteRasterInfo sprRasterInfo;
216 u16 sp80bool;
217 s16 sp8E;
218 s16 sp96;
219 s16 sp9E;
220 s16 palette;
221 s16 spAE;
222 u16 spB6;
223 u8 spB8;
224#if VERSION_IQUE
225 u16 byte = 0;
226#endif
227 f32 windowScaleX;
228 MessageCharset* msgCharset;
229 f32 temp_f10;
230 f32 temp_f20;
231 f32 temp_f20_3;
232 f32 temp_f22_2;
233 f32 temp_f24;
234 f32 bubbleX;
235 f32 bubbleY;
236 f32 temp_f28;
237 f32 windowScaleY;
238 f32 temp_f8;
239 f32 temp_f8_5;
240 f64 temp_f0;
241 f32 temp_f0_2;
242 f32 temp_f2_2;
243 f64 temp_f20_2;
244 f64 temp_f22;
245 f32 temp_f2;
246 f64 temp_f2_3;
247 s32 temp_s0_7;
248 s32 temp_s0_8;
249 s32 temp_a2;
250 s32 temp_s1_5;
251 s32 i;
252 s16 temp_s3;
253 s16 temp_s4;
254 s32 windowSizeX;
255 s32 windowSizeY;
256 s16 temp_s5;
257 s16 temp_s6;
258 u32 temp_a0_49;
259 s32 animIdx;
260 u8 packedScaleX;
261 u8 packedScaleY;
262 MessageImageData* msgVarImage;
263 MessageImageData* msgImageData;
264 s32 phi_a0;
265 s32 straightWidth;
266 s32 curveWidth;
267 s32 height;
268 s32 frameX;
269 s32 frameY;
270 s32 frameSizeX;
271 s32 frameSizeY;
272 s32 frameFading;
273 u8 frameAlpha;
274 u16 fading;
275 u8 phi_s0_5;
276 IMG_PTR signRaster;
277 PAL_PTR signPalette;
278 s8 phi_s2_4;
279 u8 phi_s3_2;
280 s32 phi_v0_3;
281 s32 phi_a0_4;
282 s16 phi_t5;
283 s16 phi_s0_6;
284 s16 phi_t3;
285 s32 dbPos;
286 s16 charPosX;
287 s16 charPosY;
288 s16 phi_s2_5;
289 s32 phi_s0_7;
290 s32 phi_s1_8;
291 s8 varImgHasBorder;
292 s16 imgDrawPosX;
293 s16 imgDrawPosY;
294 f32 z1;
295 f32 z2;
296 f32 temp1;
297 f32 temp2;
298#if VERSION_JP
299 u8 rasterOffsetY;
300#else
301 s8 rasterOffsetY;
302#endif
303 s16 baseOffsetY;
304
305 msg_drawState = &D_80155D20;
306 msg_drawState->printBuffer = printer->printBuffer;
307 msg_drawState->printModeFlags = 0;
308 if (gMainGfxPos != D_80151338) {
310 }
312 sp8E = 255;
313 if (flag & 1) {
314 sp8E = alpha;
315 }
316 msg_drawState->textStartPos[0] = 0;
317 msg_drawState->textStartPos[1] = 0;
318 msg_drawState->clipX[0] = 0;
319 msg_drawState->clipY[0] = 0;
320 msg_drawState->clipX[1] = SCREEN_WIDTH - 1;
321 msg_drawState->clipY[1] = SCREEN_HEIGHT - 1;
322 msg_drawState->msgScale.x = 1.0f;
323 msg_drawState->msgScale.y = 1.0f;
324 msg_drawState->unk_29 = 0;
325 msg_drawState->framePalette = 0;
326 msg_drawState->unk_2C = 0;
327 msg_drawState->visiblePrintedCount = 0;
328 msg_drawState->centerPos = 0;
329 msg_drawState->fontVariant = 0;
330 msg_drawState->curPosX = 0;
331 msg_drawState->nextPos[0] = 0;
332 msg_drawState->nextPos[1] = 0;
333 msg_drawState->font = 0;
334 msg_drawState->effectFlags = 0;
335 msg_drawState->nextCounter = 0;
336 msg_drawState->textColor = MSG_PAL_WHITE;
337 sp96 = 0xFF;
338 spAE = 0xFF;
339 spB6 = 0;
340 spB8 = 0;
341 sp9E = -1;
342
343 if (flag & 2) {
344 msg_drawState->font = 1;
345 }
346
347 if (flag & 4) {
348 gDPSetScissor(gMainGfxPos++, G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1);
349 }
350
351 sp80bool = FALSE;
352 msg_drawState->drawBufferPos = 0;
353
354 while (!sp80bool) {
355#if VERSION_IQUE
356 u16 lastbyte, glyph_index, byte2;
357
358 lastbyte = byte;
359 byte = msg_drawState->printBuffer[msg_drawState->drawBufferPos];
360 byte2 = msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1];
361
362 switch (byte)
363#else
364 switch (msg_drawState->printBuffer[msg_drawState->drawBufferPos])
365#endif
366 {
368 msg_drawState->nextPos[0] = 0;
369 msg_drawState->nextPos[1] += (s32)((msg_drawState->msgScale.y * MsgCharsets[msg_drawState->font]->newLineY)
370#if !VERSION_JP
372#endif
373 );
374 if (msg_drawState->printModeFlags & MSG_PRINT_FLAG_40) {
375 msg_drawState->printModeFlags |= MSG_PRINT_FLAG_80;
376 }
377 msg_drawState->drawBufferPos++;
378 break;
380 msg_drawState->drawBufferPos++;
381 break;
386 msg_drawState->fontVariant = msg_drawState->printBuffer[msg_drawState->drawBufferPos] - MSG_CHAR_PRINT_VARIANT0;
387 msg_drawState->drawBufferPos++;
388 break;
392 msg_drawState->nextPos[0] += msg_get_draw_char_width(msg_drawState->printBuffer[msg_drawState->drawBufferPos],
393 msg_drawState->font, msg_drawState->fontVariant, msg_drawState->msgScale.x, msg_drawState->curPosX,
394 msg_drawState->printModeFlags);
395 msg_drawState->drawBufferPos++;
396 break;
398 switch (msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1]) {
399 case MSG_STYLE_RIGHT:
400#if VERSION_IQUE
401 msg_drawState->nextPos[1] += 5;
402#endif
403 case MSG_STYLE_LEFT:
404 case MSG_STYLE_CENTER:
405 case MSG_STYLE_TATTLE:
406 if (printer->windowState == MSG_WINDOW_STATE_OPENING && printer->fadeInCounter == 0) {
407 printer->openStartPos.x = printer->initOpenPos.x;
408 printer->openStartPos.y = printer->initOpenPos.y;
409 }
410 temp_s6 = printer->openStartPos.x;
411 temp_s5 = printer->openStartPos.y;
412 temp_s4 = printer->windowBasePos.x + (f32) printer->windowSize.x * 0.5;
413 temp_s3 = printer->windowBasePos.y + (f32) printer->windowSize.y * 0.5;
414 msg_drawState->textColor = MSG_PAL_STANDARD;
415 msg_drawState->printModeFlags |= MSG_PRINT_FLAG_10;
416
417 if (printer->style == MSG_STYLE_RIGHT || printer->style == MSG_STYLE_LEFT || printer->style == MSG_STYLE_CENTER) {
418 straightWidth = MSG_NORMAL_WIDTH;
419 printer->windowBasePos.x = MSG_NORMAL_X;
420 printer->windowBasePos.y = 13;
423 msg_drawState->textStartPos[0] = 26;
424 msg_drawState->textStartPos[1] = MSG_NORMAL_TEXT_Y;
427 curveWidth = 32;
428 height = MSG_NORMAL_HEIGHT_CAP;
429 } else {
430 straightWidth = 218;
431
432#if VERSION_JP
433 if (printer->maxLinesPerPage == 1) {
434 msg_drawState->textStartPos[0] = 18;
435 msg_drawState->textStartPos[1] = 10;
436 curveWidth = 24;
437 } else if (printer->maxLinesPerPage == 2) {
438 msg_drawState->textStartPos[0] = 22;
439 msg_drawState->textStartPos[1] = 8;
440 curveWidth = 28;
441 } else {
442 msg_drawState->textStartPos[0] = 26;
443 msg_drawState->textStartPos[1] = 8;
444 curveWidth = 32;
445 }
446#else
447 switch (printer->maxLinesPerPage) {
448 case 1:
449 msg_drawState->textStartPos[0] = 18;
450 msg_drawState->textStartPos[1] = 10;
451 curveWidth = 24;
452 break;
453 case 2:
454 msg_drawState->textStartPos[0] = 22;
455 msg_drawState->textStartPos[1] = 6;
456 curveWidth = 28;
457 break;
458 case 3:
459 msg_drawState->textStartPos[0] = 26;
460 msg_drawState->textStartPos[1] = 8;
461 curveWidth = 32;
462 break;
463 default:
464 msg_drawState->textStartPos[0] = 26;
465 msg_drawState->textStartPos[1] = 6;
466 curveWidth = 32;
467 break;
468 }
469#endif
470
471 straightWidth = printer->msgWidth;
472 if (straightWidth > 256) {
473 straightWidth = 256;
474 }
475 if (straightWidth < 70) {
476 straightWidth = 70;
477 }
478 straightWidth -= 12;
479
480 printer->windowSize.x = straightWidth + (curveWidth * 2);
481
482 height = (printer->maxLinesPerPage * MSG_NORMAL_PAGE_HT) + 16;
483 if (height > MSG_NORMAL_HEIGHT_CAP) {
484 height = MSG_NORMAL_HEIGHT_CAP;
485 }
486 if (height < 36) {
487 height = 36;
488 }
489 printer->windowSize.y = height;
490
491 temp_a2 = printer->openStartPos.x - printer->windowSize.x / 2;
492 if (temp_a2 < 18) {
493 temp_a2 = 18;
494 }
495 if (temp_a2 + printer->windowSize.x > SCREEN_WIDTH - 18) {
496 temp_a2 = SCREEN_WIDTH - 18 - printer->windowSize.x;
497 }
498 phi_a0 = printer->openStartPos.y - 38 - printer->windowSize.y;
499 if (phi_a0 < 20) {
500 phi_a0 = 20;
501 }
502 if (phi_a0 + printer->windowSize.y > 170) {
503 phi_a0 = 170 - printer->windowSize.y;
504 }
505 printer->windowBasePos.x = temp_a2;
506 printer->windowBasePos.y = phi_a0;
507 printer->rewindArrowPos.x = (printer->windowSize.x + temp_a2) - 30;
508 printer->rewindArrowPos.y = (printer->windowSize.y + phi_a0) - 18;
509 }
510
511 if (printer->windowState == MSG_WINDOW_STATE_B || printer->windowState == MSG_WINDOW_STATE_C) {
512 msg_drawState->framePalette = 1;
513 }
514
515 if (printer->windowState == MSG_WINDOW_STATE_OPENING) {
516 windowScaleX = update_lerp(EASING_LINEAR, 0.07f, 1.0f, printer->fadeInCounter, 7);
517 windowScaleY = update_lerp(EASING_LINEAR, 0.3f, 1.0f, printer->fadeInCounter, 7);
518 temp_f28 = update_lerp(EASING_LINEAR, 96.0f, 200.0f, printer->fadeInCounter, 7);
519 temp_f20 = update_lerp(EASING_SIN_OUT, temp_s5, temp_s3, printer->fadeInCounter, 7);
520 temp_f24 = update_lerp(EASING_SIN_OUT, temp_s6, temp_s4, printer->fadeInCounter, 7);
521 temp_f2_2 = printer->windowSize.x * windowScaleX;
522 temp_f0_2 = printer->windowSize.y * windowScaleY;
523 bubbleX = (temp_f24 - temp_f2_2 * 0.5) + 0.5;
524 bubbleY = (temp_f20 - temp_f0_2 * 0.5) + 0.5;
525 msg_draw_speech_bubble(printer, bubbleX, bubbleY, straightWidth, curveWidth, height, windowScaleX, windowScaleY, temp_f28, 1);
526 printer->fadeInCounter++;
527 if (printer->fadeInCounter == 7) {
529 }
530 } else if (printer->windowState == MSG_WINDOW_STATE_CLOSING) {
531 printer->fadeOutCounter++;
532 windowScaleX = update_lerp(EASING_LINEAR, 1.0f, 0.6f, printer->fadeOutCounter, 5);
533 windowScaleY = update_lerp(EASING_LINEAR, 1.0f, 0.8f, printer->fadeOutCounter, 5);
534 temp_f2 = (printer->windowSize.x * windowScaleX);
535 temp_f0 = (printer->windowSize.y * windowScaleY);
536 temp_f24 = temp_s4;
537 temp_f20 = temp_s3;
538 bubbleX = (temp_f24 - temp_f2 * 0.5) + 0.5;
539 bubbleY = (temp_f20 - temp_f0 * 0.5) + 0.5;
540 temp_f22_2 = (temp_f24 + temp_f2 * 0.5) - 0.5;
541 temp_f20_3 = (temp_f20 + temp_f0 * 0.5) - 0.5;
542 temp_f28 = update_lerp(EASING_LINEAR, 255.0f, 64.0f, printer->fadeOutCounter, 5);
543 sp8E = temp_f28 * 0.35;
544 spAE = temp_f28;
545 msg_drawState->clipX[0] = bubbleX + msg_drawState->textStartPos[0];
546 msg_drawState->clipY[0] = bubbleY + msg_drawState->textStartPos[1];
547 msg_drawState->clipX[1] = temp_f22_2 - msg_drawState->textStartPos[0];
548 msg_drawState->clipY[1] = temp_f20_3 - msg_drawState->textStartPos[1];
549 msg_draw_speech_bubble(printer, bubbleX, bubbleY, straightWidth, curveWidth, height, windowScaleX, windowScaleY, temp_f28, 1);
550 if (printer->fadeOutCounter >= 5) {
551 printer->stateFlags |= MSG_STATE_FLAG_1;
552 }
553 } else {
554 bubbleX = posX + printer->windowBasePos.x;
555 bubbleY = posY + printer->windowBasePos.y;
556
557 msg_draw_speech_bubble(printer, bubbleX, bubbleY, straightWidth, curveWidth, height, 1.0f, 1.0f, 255, 1);
558 if (((u32)(printer->openStartPos.x - 20) <= 280) && (printer->openStartPos.y <= 220)) {
559 msg_draw_speech_arrow(printer);
560 }
561 }
562
563 if (printer->windowState != MSG_WINDOW_STATE_CLOSING) {
564 msg_drawState->clipX[0] = 20;
565 msg_drawState->clipY[0] = printer->windowOffsetPos.y + printer->windowBasePos.y +
566 msg_drawState->textStartPos[1];
567 msg_drawState->clipX[1] = SCREEN_WIDTH - 20;
568 msg_drawState->clipY[1] = msg_drawState->clipY[0] + printer->windowSize.y - 16;
569 }
571 msg_drawState->drawBufferPos += 2;
572 break;
573 case MSG_STYLE_CHOICE:
574 frameFading = 0;
575 windowSizeX = printer->windowSize.x;
576 windowSizeY = printer->windowSize.y;
577 frameSizeX = windowSizeX;
578 frameSizeY = windowSizeY;
579 msg_drawState->framePalette = 0;
580 msg_drawState->textStartPos[0] = 12;
581 msg_drawState->textStartPos[1] = 6;
582 frameAlpha = 255;
583 if (printer->windowState == MSG_WINDOW_STATE_OPENING) {
584
585 printer->fadeInCounter++;
586 if (printer->fadeInCounter == 6) {
588 }
589
590 temp_f10 = ((f32) printer->fadeInCounter * (2.0 / 15.0)) + 0.2;
591
592 z1 = printer->windowBasePos.x + (windowSizeX / 2);
593 z2 = printer->windowBasePos.y + (windowSizeY / 2);
594 temp1 = z1 - (windowSizeX * temp_f10 * 0.5);
595 temp2 = z2 - (windowSizeY * temp_f10 * 0.5);
596 frameX = temp1 + 0.5;
597 frameY = temp2 + 0.5;
598 frameSizeX = windowSizeX * temp_f10 + 0.5;
599 frameSizeY = windowSizeY * temp_f10 + 0.5;
600
601 if (frameSizeX < 24) {
602 frameSizeX = 24;
603 }
604 if (frameSizeY < 24) {
605 frameSizeY = 24;
606 }
607
608 sp8E = (u8)(temp_f10 * 255.0) * 0.6;
609 } else if (printer->windowState == MSG_WINDOW_STATE_CLOSING) {
610 printer->fadeOutCounter++;
611 if (printer->fadeOutCounter >= 5) {
612 printer->stateFlags |= MSG_STATE_FLAG_1;
613 }
614 frameAlpha = ~(printer->fadeOutCounter * 0x2E);
615 sp8E = ((u8)frameAlpha) * 0.6;
616 frameFading = 1;
617 if (sp8E >= 32) {
618 sp8E -= 32;
619 }
620 frameX = printer->windowBasePos.x;
621 frameY = printer->windowBasePos.y;
622 } else {
623 frameX = printer->windowBasePos.x;
624 frameY = printer->windowBasePos.y;
625 msg_draw_prim_rect(255, 32, 32, 0, frameX - 1, frameY - 1, windowSizeX + 2, windowSizeY + 2);
626 }
627 msg_drawState->clipX[0] = frameX + 2;
628 msg_drawState->clipY[0] = frameY + 2;
629 msg_drawState->clipX[1] = frameX + frameSizeX - 2;
630 msg_drawState->clipY[1] = frameY + frameSizeY - 2;
631 msg_draw_frame(frameX, frameY, frameSizeX, frameSizeY, MSG_STYLE_CHOICE, msg_drawState->framePalette, frameFading, frameAlpha,
632 frameAlpha);
634 spAE = frameAlpha & 0xFF;
635 msg_drawState->textColor = MSG_PAL_STANDARD;
636 msg_drawState->drawBufferPos += 2;
637 msg_drawState->printModeFlags |= MSG_PRINT_FLAG_10;
638 break;
642 case MSG_STYLE_F:
643 fading = 0;
644 msg_drawState->textStartPos[0] = 16;
645 msg_drawState->textStartPos[1] = MSG_INSPECT_TEXT_Y;
646 msg_drawState->clipX[0] = printer->windowBasePos.x + 5;
647 msg_drawState->clipY[0] = printer->windowBasePos.y + 4;
648 msg_drawState->clipX[1] = printer->windowBasePos.x + printer->windowSize.x - 8;
649 msg_drawState->clipY[1] = printer->windowBasePos.y + printer->windowSize.y - 5;
650 printer->rewindArrowPos.x = msg_drawState->clipX[1] - 17;
651 printer->rewindArrowPos.y = msg_drawState->clipY[1] - 17;
652 msg_drawState->textColor = MSG_PAL_WHITE;
653 phi_s0_5 = 0xFF;
654 msg_draw_prim_rect(255, 32, 32, 0, printer->windowBasePos.x + 3, printer->windowBasePos.y - 1,
655 printer->windowSize.x - 6, 1);
656 msg_draw_prim_rect(32, 255, 32, 0, printer->windowBasePos.x + 3,
657 printer->windowBasePos.y + printer->windowSize.y, printer->windowSize.x - 6,
658 1);
659
660 if (printer->windowState == MSG_WINDOW_STATE_OPENING) {
661 phi_s0_5 = (printer->fadeInCounter * 0x30) + 0x50;
662 sp8E = (phi_s0_5 & 0xFF) - 0x30;
663 printer->fadeInCounter++;
664 fading = 1;
665 if ((s16)printer->fadeInCounter == 4) { // TODO why is this cast needed
667 }
668 } else if (printer->windowState == MSG_WINDOW_STATE_CLOSING) {
669 phi_s0_5 = -0x30 - (printer->fadeOutCounter * 40);
670 sp8E = (phi_s0_5 & 0xFF) - 0x30;
671 printer->fadeOutCounter++;
672 fading = 1;
673 if (printer->fadeOutCounter == 4) {
674 printer->stateFlags |= MSG_STATE_FLAG_1;
675 }
676 }
677
678 msg_draw_frame(printer->windowBasePos.x, printer->windowBasePos.y, printer->windowSize.x, printer->windowSize.y, MSG_STYLE_INSPECT,
679 msg_drawState->framePalette, fading, phi_s0_5, phi_s0_5);
681 spAE = phi_s0_5 & 0xFF;
682 msg_drawState->drawBufferPos += 2;
683 break;
684 case MSG_STYLE_SIGN:
686 msg_drawState->textStartPos[0] = 18;
687 msg_drawState->textStartPos[1] = MSG_SIGN_TEXT_Y;
688 printer->windowBasePos.x = 20 + MSG_SIGN_OFFSET_X;
689 printer->windowBasePos.y = 28;
690 printer->windowSize.x = MSG_SIGN_WIDTH;
691 msg_drawState->framePalette = 15;
692#if VERSION_IQUE
693 msg_drawState->nextPos[1] -= 2;
694#endif
695 temp_s1_5 = 0xFF;
696 if (printer->style == MSG_STYLE_SIGN) {
698 printer->windowSize.y = 72;
699 msg_drawState->textColor = MSG_PAL_18;
700 signPalette = ui_msg_sign_pal;
701 } else {
703 signPalette = ui_msg_lamppost_pal;
704 msg_drawState->textColor = MSG_PAL_1C;
705 }
706 msg_drawState->clipX[0] = 20 + MSG_SIGN_OFFSET_X + 14;
707 msg_drawState->clipY[0] = 40;
708 msg_drawState->clipX[1] = 283 - MSG_SIGN_OFFSET_X;
709 msg_drawState->clipY[1] = printer->windowSize.y + 17;
710 printer->rewindArrowPos.x = msg_drawState->clipX[1] - 16;
711 printer->rewindArrowPos.y = msg_drawState->clipY[1] - 9;
712
713 if (printer->windowState == MSG_WINDOW_STATE_OPENING) {
714 temp_s1_5 = (printer->fadeInCounter << 6) + 0x50;
715 sp8E = (temp_s1_5 & 0xFF) - 0x30;
716 printer->fadeInCounter++;
717 if (printer->fadeInCounter == 3) {
719 }
720 } else {
721 if (printer->windowState == MSG_WINDOW_STATE_CLOSING) {
722 temp_s1_5 = -0x30 - (printer->fadeOutCounter * 0x30);
723 sp8E = (temp_s1_5 & 0xFF) - 0x30;
724 printer->fadeOutCounter++;
725 if (printer->fadeOutCounter == 3) {
726 printer->stateFlags |= MSG_STATE_FLAG_1;
727 }
728 }
729 }
730 spAE = (u8)temp_s1_5;
731 draw_ci_image_with_clipping(ui_msg_sign_corner_topleft_png, 16, 16, G_IM_FMT_CI, G_IM_SIZ_4b, signPalette, 20 + MSG_SIGN_OFFSET_X,
732 28, 10, 10, 310, 230, temp_s1_5);
733 draw_ci_image_with_clipping(ui_msg_sign_corner_topright_png, 16, 16, G_IM_FMT_CI, G_IM_SIZ_4b, signPalette, 284 - MSG_SIGN_OFFSET_X,
734 28, 10, 10, 310, 230, temp_s1_5);
735 draw_ci_image_with_clipping(ui_msg_sign_corner_bottomleft_png, 16, 16, G_IM_FMT_CI, G_IM_SIZ_4b, signPalette, 20 + MSG_SIGN_OFFSET_X,
736 printer->windowSize.y + 12, 10, 10, 310, 230, temp_s1_5);
737 draw_ci_image_with_clipping(signRaster, 16, 16, G_IM_FMT_CI, G_IM_SIZ_4b, signPalette, 284 - MSG_SIGN_OFFSET_X, printer->windowSize.y + 12,
738 10, 10, 310, 230, temp_s1_5);
739 gDPLoadTextureTile_4b(gMainGfxPos++, ui_msg_sign_side_top_png, G_IM_FMT_CI, 32, 0, 0, 0, 31, 15, 0, G_TX_NOMIRROR | G_TX_WRAP,
740 G_TX_NOMIRROR | G_TX_WRAP, 5, 4, G_TX_NOLOD, G_TX_NOLOD);
741 gSPTextureRectangle(gMainGfxPos++, (36 + MSG_SIGN_OFFSET_X) * 4, 28 * 4, (284 - MSG_SIGN_OFFSET_X) * 4, 44 * 4, G_TX_RENDERTILE, 0, 0,
742 0x0400, 0x0400);
743 gDPLoadTextureTile_4b(gMainGfxPos++, ui_msg_sign_side_left_png, G_IM_FMT_CI, 16, 0, 0, 0, 15, 31, 0, G_TX_NOMIRROR | G_TX_WRAP,
744 G_TX_NOMIRROR | G_TX_WRAP, 4, 5, G_TX_NOLOD, G_TX_NOLOD);
745 gSPTextureRectangle(gMainGfxPos++, (20 + MSG_SIGN_OFFSET_X) * 4, 44 * 4, (36 + MSG_SIGN_OFFSET_X) * 4, (printer->windowSize.y + 12) * 4,
746 G_TX_RENDERTILE, 0, 0, 0x0400, 0x0400);
747 gDPLoadTextureTile_4b(gMainGfxPos++, ui_msg_sign_side_right_png, G_IM_FMT_CI, 16, 0, 0, 0, 15, 31, 0, G_TX_NOMIRROR | G_TX_WRAP,
748 G_TX_NOMIRROR | G_TX_WRAP, 4, 5, G_TX_NOLOD, G_TX_NOLOD);
749 gSPTextureRectangle(gMainGfxPos++, (284 - MSG_SIGN_OFFSET_X) * 4, 44 * 4, (300 - MSG_SIGN_OFFSET_X) * 4, (printer->windowSize.y + 12) * 4,
750 G_TX_RENDERTILE, 0, 0, 0x0400, 0x0400);
751 gDPLoadTextureTile_4b(gMainGfxPos++, ui_msg_sign_side_bottom_png, G_IM_FMT_CI, 32, 0, 0, 0, 31, 15, 0, G_TX_NOMIRROR | G_TX_WRAP,
752 G_TX_NOMIRROR | G_TX_WRAP, 5, 4, G_TX_NOLOD, G_TX_NOLOD);
753 gSPTextureRectangle(gMainGfxPos++, (36 + MSG_SIGN_OFFSET_X) * 4, (printer->windowSize.y + 12) * 4, (284 - MSG_SIGN_OFFSET_X) * 4,
754 (printer->windowSize.y + 28) * 4, G_TX_RENDERTILE, 0, 0, 0x0400, 0x0400);
755 gDPLoadTextureTile_4b(gMainGfxPos++, ui_msg_sign_fill_png, G_IM_FMT_CI, 8, 0, 0, 0, 7, 7, 0, G_TX_NOMIRROR | G_TX_WRAP,
756 G_TX_NOMIRROR | G_TX_WRAP, 3, 3, G_TX_NOLOD, G_TX_NOLOD);
757 gSPTextureRectangle(gMainGfxPos++, (36 + MSG_SIGN_OFFSET_X) * 4, 44 * 4, (283 - MSG_SIGN_OFFSET_X + 1) * 4, (printer->windowSize.y + 12) * 4,
758 G_TX_RENDERTILE, 0, 0, 0x0400, 0x0400);
760 msg_drawState->drawBufferPos += 2;
761 break;
763 phi_s2_4 = 0;
764 msg_drawState->textStartPos[0] = 12;
765 msg_drawState->textStartPos[1] = 5;
766 printer->windowBasePos.x = 40;
767 printer->windowBasePos.y = 28;
768 msg_drawState->clipX[0] = 45;
769 msg_drawState->clipY[0] = 32;
770 msg_drawState->clipX[1] = 272;
771 msg_drawState->clipY[1] = 81;
772 printer->rewindArrowPos.x = msg_drawState->clipX[1] - 21;
773 printer->rewindArrowPos.y = msg_drawState->clipY[1] - 20;
774 msg_drawState->framePalette = 0;
775 msg_drawState->textColor = MSG_PAL_WHITE;
776 msg_draw_prim_rect(255, 32, 32, 0, 43, 27, 234, 1);
777 msg_draw_prim_rect(32, 255, 32, 0, 43, 86, 234, 1);
778 phi_s3_2 = 0xFF;
779 if (printer->windowState == MSG_WINDOW_STATE_OPENING) {
780 phi_s3_2 = (printer->fadeInCounter * 64) + 80;
781 sp8E = (phi_s3_2 & 0xFF) - 0x30;
782 printer->fadeInCounter++;
783 if (printer->fadeInCounter == 3) {
785 }
786 phi_s2_4 = 1;
787 } else if (printer->windowState == MSG_WINDOW_STATE_CLOSING) {
788 phi_s3_2 = -0x30 - (printer->fadeOutCounter * 0x30);
789 sp8E = (phi_s3_2 & 0xFF) - 0x30;
790 printer->fadeOutCounter++;
791 if (printer->fadeOutCounter == 3) {
792 printer->stateFlags |= MSG_STATE_FLAG_1;
793 }
794 phi_s2_4 = 1;
795 }
796 msg_draw_frame(40, 28, 240, 58, MSG_STYLE_INSPECT, msg_drawState->framePalette, phi_s2_4, phi_s3_2, phi_s3_2);
797 draw_ci_image_with_clipping(printer->letterBackgroundImg, 150, 105, G_IM_FMT_CI, G_IM_SIZ_4b,
798 printer->letterBackgroundPal, 85, 97, 10, 10, 300, 220, phi_s3_2);
799 draw_ci_image_with_clipping(printer->letterContentImg, 70, 95, G_IM_FMT_CI, G_IM_SIZ_8b,
800 printer->letterContentPal, 160, 102, 10, 10, 300, 220, phi_s3_2);
802 spAE = phi_s3_2 & 0xFF;
803 msg_drawState->drawBufferPos += 2;
804 break;
805 case MSG_STYLE_POPUP:
806 case MSG_STYLE_B:
807 msg_drawState->textStartPos[0] = 16;
808 msg_drawState->textStartPos[1] = MSG_POPUP_TEXT_Y;
809 msg_drawState->clipX[0] = 0;
810 msg_drawState->clipX[1] = SCREEN_WIDTH - 1;
811 msg_drawState->clipY[0] = 0;
812 msg_drawState->clipY[1] = SCREEN_HEIGHT - 1;
813 msg_drawState->textColor = MSG_PAL_WHITE;
814 msg_drawState->printModeFlags |= MSG_PRINT_FLAG_10;
815 if (printer->windowState == MSG_WINDOW_STATE_D || printer->windowState == MSG_WINDOW_STATE_E) {
816 printer->windowBasePos.x = 0;
817 printer->windowBasePos.y = 0;
818 } else {
819 printer->windowBasePos.x = 160 - printer->windowSize.x / 2;
820 printer->windowBasePos.y = 56;
821 draw_box(0, WINDOW_STYLE_0, printer->windowBasePos.x, 56, 0, printer->windowSize.x,
822 printer->windowSize.y, 255, 0, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, NULL, 0, NULL,
824 }
826 msg_drawState->drawBufferPos += 2;
827 break;
829 printer->windowBasePos.x = 60;
830 printer->windowBasePos.y = 110;
831 printer->windowSize.x = 200;
832 printer->windowSize.y = 50;
833 msg_drawState->textStartPos[0] = 0;
834 msg_drawState->textStartPos[1] = MSG_EPILOGUE_TEXT_Y;
835 msg_drawState->clipX[0] = printer->windowBasePos.x;
836 msg_drawState->clipY[0] = printer->windowBasePos.y;
837 msg_drawState->clipX[1] = printer->windowBasePos.x + printer->windowSize.x;
838 msg_drawState->clipY[1] = printer->windowBasePos.y + printer->windowSize.y;
839 printer->rewindArrowPos.x = printer->windowBasePos.x + printer->windowSize.x - 10;
840 printer->rewindArrowPos.y = printer->windowBasePos.y + printer->windowSize.y - 10;
842 msg_drawState->drawBufferPos += 2;
843 break;
844 }
845 break;
847 if (printer->windowState == MSG_WINDOW_STATE_C) {
848 if (msg_drawState->nextCounter >= printer->unkArraySize) {
849 sp80bool = TRUE;
850 }
851 } else if (printer->windowState == MSG_WINDOW_STATE_B) {
852 if (printer->curLinePos < printer->lineEndPos[printer->unkArraySize]) {
853 if (msg_drawState->nextCounter >= printer->unkArraySize) {
854 sp80bool = TRUE;
855 }
856 } else {
857 if (printer->unkArraySize < msg_drawState->nextCounter) {
858 sp80bool = TRUE;
859 } else if (msg_drawState->nextCounter >= printer->unkArraySize) {
860 phi_a0_4 = 36;
861 if (printer->maxLinesPerPage >= 2) {
862 phi_v0_3 = 48;
863 if (printer->maxLinesPerPage == 2) {
864 phi_v0_3 = 32;
865 }
866 if (printer->unk_4C8 < phi_v0_3) {
867 if (printer->unk_4C8 <= 0x10) {
868 phi_a0_4 = 56;
869 }
870 sp8E = 0xFF - (phi_a0_4 * printer->unk_4CC);
871 if (sp8E < 0) {
872 sp8E = 0;
873 }
874 }
875 }
876 }
877 }
878 }
879 msg_drawState->nextCounter++;
880 msg_drawState->drawBufferPos++;
881 break;
883 sp80bool = TRUE;
884 break;
886 msg_drawState->drawBufferPos++;
887 switch (msg_drawState->printBuffer[msg_drawState->drawBufferPos]) {
889 msg_drawState->font = msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1];
890 msg_drawState->drawBufferPos += 2;
891 msg_drawState->printModeFlags |= MSG_PRINT_FLAG_10;
892 break;
894 msg_drawState->fontVariant = msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1];
895 msg_drawState->drawBufferPos += 2;
896 break;
898 msg_drawState->textColor = msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1];
899 msg_drawState->printModeFlags |= MSG_PRINT_FLAG_10;
900 msg_drawState->drawBufferPos += 2;
901 break;
903 msg_drawState->curPosX = msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1];
904 msg_drawState->drawBufferPos += 2;
905 break;
906#if !VERSION_IQUE
908 packedScaleX = msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1];
909 msg_drawState->msgScale.x = (f32)(packedScaleX >> 4) + ((packedScaleX & 0xF) * 0.0625f);
910 packedScaleY = msg_drawState->printBuffer[msg_drawState->drawBufferPos + 2];
911 msg_drawState->msgScale.y = (f32)(packedScaleY >> 4) + ((packedScaleY & 0xF) * 0.0625f);
912 msg_drawState->drawBufferPos += 3;
913 if (msg_drawState->msgScale.x > 1.0 || msg_drawState->msgScale.y > 1.0) {
914 gDPSetTextureFilter(gMainGfxPos++, G_TF_POINT);
915 } else if (msg_drawState->msgScale.x < 1.0 || msg_drawState->msgScale.y < 1.0) {
916 gDPSetTextureFilter(gMainGfxPos++, G_TF_AVERAGE);
917 }
918 break;
920 msg_drawState->msgScale.x = 1.0f;
921 msg_drawState->msgScale.y = 1.0f;
922 msg_drawState->drawBufferPos++;
923 gDPSetTextureFilter(gMainGfxPos++, G_TF_AVERAGE);
924 break;
925#endif
927 msg_drawState->nextPos[0] = msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1] * 256 +
928 (msg_drawState->printBuffer[msg_drawState->drawBufferPos + 2]);
929 msg_drawState->drawBufferPos += 3;
930 break;
932 msg_drawState->nextPos[1] = msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1];
933 msg_drawState->drawBufferPos += 2;
934 break;
936 msg_drawState->nextPos[0] += msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1];
937 msg_drawState->drawBufferPos += 2;
938 break;
940 msg_drawState->nextPos[1] += msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1];
941 msg_drawState->drawBufferPos += 2;
942 break;
944 msg_drawState->nextPos[1] -= msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1];
945 msg_drawState->drawBufferPos += 2;
946 break;
948 msgImageData = &(*gMsgVarImages)[msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1]];
949 phi_t5 = sp8E;
950 if (sp8E < 0xFF) {
951 phi_t5 = (s32)(sp8E * 0.7);
952 }
953 imgDrawPosX = (s16)((msg_drawState->nextPos[0] + (msg_drawState->textStartPos[0] + (printer->windowBasePos.x + posX))) -
954 additionalOffsetX);
955 imgDrawPosY = (s16)((msg_drawState->nextPos[1] + (msg_drawState->textStartPos[1] + (printer->windowBasePos.y + posY))) -
956 additionalOffsetY);
957
958 draw_ci_image_with_clipping(msgImageData->raster, msgImageData->width, msgImageData->height, msgImageData->format, msgImageData->bitDepth,
959 msgImageData->palette, imgDrawPosX, imgDrawPosY, (s32) msg_drawState->clipX[0], (s32) msg_drawState->clipY[0],
960 msg_drawState->clipX[1] - msg_drawState->clipX[0], msg_drawState->clipY[1] - msg_drawState->clipY[0], phi_t5);
962 msg_drawState->drawBufferPos += 2;
963 break;
965 phi_s0_6 = sp8E;
966 if (sp8E < 0xFF) {
967 phi_s0_6 = (s32)(sp8E * 0.7);
968 }
969
970 if (spr_get_npc_raster_info(&sprRasterInfo, (msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1] << 8) |
971 msg_drawState->printBuffer[msg_drawState->drawBufferPos + 2],
972 msg_drawState->printBuffer[msg_drawState->drawBufferPos + 3]) != 0) {
973 imgDrawPosX = (s16)((msg_drawState->nextPos[0] + (msg_drawState->textStartPos[0] + (printer->windowBasePos.x + posX))) -
974 additionalOffsetX);
975 imgDrawPosY = (s16)((msg_drawState->nextPos[1] + (msg_drawState->textStartPos[1] + (printer->windowBasePos.y + posY))) -
976 additionalOffsetY);
977
978 draw_ci_image_with_clipping(sprRasterInfo.raster, sprRasterInfo.width, sprRasterInfo.height, G_IM_FMT_CI, G_IM_SIZ_4b, sprRasterInfo.defaultPal, imgDrawPosX, imgDrawPosY,
979 msg_drawState->clipX[0], msg_drawState->clipY[0], msg_drawState->clipX[1] - msg_drawState->clipX[0],
980 msg_drawState->clipY[1] - msg_drawState->clipY[0], phi_s0_6);
981 msg_drawState->printModeFlags |= MSG_PRINT_FLAG_10;
982 }
983 msg_drawState->drawBufferPos += 4;
984 break;
986 if (D_8015131C != 0) {
987 phi_t3 = sp8E;
988 if (sp8E < 0xFF) {
989 phi_t3 = (s32)(sp8E * 0.7);
990 }
991 imgDrawPosX = (s16)((msg_drawState->nextPos[0] + (msg_drawState->textStartPos[0] + (printer->windowBasePos.x + posX))) -
992 additionalOffsetX);
993 imgDrawPosY = (s16)((msg_drawState->nextPos[1] + (msg_drawState->textStartPos[1] + (printer->windowBasePos.y + posY))) -
994 additionalOffsetY);
995
996 draw_ci_image_with_clipping(D_80159B50, 32, 32, G_IM_FMT_CI, G_IM_SIZ_4b, D_8015C7E0, imgDrawPosX, imgDrawPosY, msg_drawState->clipX[0],
997 msg_drawState->clipY[0], msg_drawState->clipX[1] - msg_drawState->clipX[0],
998 msg_drawState->clipY[1] - msg_drawState->clipY[0], phi_t3);
999 msg_drawState->printModeFlags |= MSG_PRINT_FLAG_10;
1000 }
1001 msg_drawState->drawBufferPos++;
1002 break;
1004 animIdx = msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1];
1005 if (printer->animTimers[animIdx] == -1) {
1006 printer->animTimers[animIdx] = msg_drawState->printBuffer[msg_drawState->drawBufferPos + 3];
1007 }
1008 if (printer->animTimers[animIdx] == 0) {
1009 printer->curAnimFrame[animIdx]++;
1010 }
1011
1012 dbPos = msg_drawState->drawBufferPos;
1013 while (TRUE) {
1014 if ((msg_drawState->printBuffer[dbPos - 1] == MSG_CHAR_PRINT_FUNCTION) &&
1015 (msg_drawState->printBuffer[dbPos] == MSG_PRINT_FUNC_ANIM_DELAY) &&
1016 (msg_drawState->printBuffer[dbPos + 1] == animIdx)) {
1017 if (msg_drawState->printBuffer[dbPos + 2] != printer->curAnimFrame[animIdx]) {
1018 dbPos += 4;
1019 } else {
1020 break;
1021 }
1022 } else {
1023 if ((msg_drawState->printBuffer[dbPos] == MSG_CHAR_PRINT_FUNCTION) &&
1024 (msg_drawState->printBuffer[dbPos + 1] == MSG_PRINT_FUNC_ANIM_LOOP) &&
1025 (msg_drawState->printBuffer[dbPos + 2] == animIdx)) {
1026
1027 if (printer->animTimers[animIdx] == 0) {
1028 printer->curAnimFrame[animIdx] = msg_drawState->printBuffer[dbPos + 3];
1029 dbPos = msg_drawState->drawBufferPos;
1030 continue;
1031 } else {
1032 dbPos++;
1033 break;
1034 }
1035 } else {
1036 if (msg_drawState->printBuffer[dbPos] == MSG_CHAR_PRINT_FUNCTION &&
1037 msg_drawState->printBuffer[dbPos + 1] == MSG_PRINT_FUNC_ANIM_DONE) {
1038 if (msg_drawState->printBuffer[dbPos + 2] == animIdx) {
1039 dbPos++;
1040 break;
1041 }
1042 }
1043 }
1044 }
1045 dbPos++;
1046 }
1047 msg_drawState->drawBufferPos = dbPos;
1048
1049 switch (msg_drawState->printBuffer[msg_drawState->drawBufferPos]) {
1051 if (printer->animTimers[animIdx] == 0) {
1052 if (msg_drawState->printBuffer[msg_drawState->drawBufferPos + 3] == 0) {
1053 printer->animTimers[animIdx] = -2;
1054 } else {
1055 printer->animTimers[animIdx] = msg_drawState->printBuffer[msg_drawState->drawBufferPos + 3];
1056 }
1057 }
1058 msg_drawState->drawBufferPos += 4;
1059 break;
1061 msg_drawState->drawBufferPos += 3;
1062 break;
1064 msg_drawState->drawBufferPos += 2;
1065 break;
1066 }
1067 break;
1069 msg_drawState->drawBufferPos += 3;
1070 break;
1072 msg_drawState->drawBufferPos += 2;
1073 break;
1075 printer->cursorPosX[msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1]] = msg_drawState->textStartPos[0] +
1076 msg_drawState->nextPos[0] - additionalOffsetX - 6;
1077 printer->cursorPosY[msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1]] = msg_drawState->textStartPos[1] +
1078 msg_drawState->nextPos[1] - additionalOffsetY - 1;
1079 msg_drawState->drawBufferPos += 2;
1080 break;
1082 if (msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1] == 0xFF) {
1083 msg_drawState->printModeFlags &= ~MSG_PRINT_FLAG_20;
1084 } else {
1085 msg_drawState->unk_2D = msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1];
1086 msg_drawState->printModeFlags |= MSG_PRINT_FLAG_20;
1087 msg_drawState->nextPos[0] += 14;
1088 }
1089 msg_drawState->drawBufferPos += 2;
1090 break;
1092 msg_drawState->framePalette = msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1];
1093 msg_drawState->drawBufferPos += 2;
1094 break;
1097 msg_drawState->drawBufferPos++;
1098 break;
1100 msg_drawState->savedPos[0] = msg_drawState->nextPos[0];
1101 msg_drawState->savedPos[1] = msg_drawState->nextPos[1];
1102 msg_drawState->drawBufferPos++;
1103 break;
1105 msg_drawState->nextPos[0] = msg_drawState->savedPos[0];
1106 msg_drawState->nextPos[1] = msg_drawState->savedPos[1];
1107 msg_drawState->drawBufferPos++;
1108 break;
1110 msg_drawState->savedColor = msg_drawState->textColor;
1111 msg_drawState->drawBufferPos++;
1112 break;
1114 msg_drawState->textColor = msg_drawState->savedColor;
1115 msg_drawState->drawBufferPos++;
1116 break;
1118 switch (msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1]) {
1119 case MSG_FX_SHAKE:
1120 msg_drawState->effectFlags |= MSG_FX_FLAG_SHAKE;
1121 msg_drawState->drawBufferPos += 2;
1122 break;
1123 case MSG_FX_WAVE:
1124 msg_drawState->effectFlags |= MSG_FX_FLAG_WAVE;
1125 msg_drawState->drawBufferPos += 2;
1126 break;
1128 msg_drawState->effectFlags |= MSG_FX_FLAG_NOISE_OUTLINE;
1130 msg_drawState->drawBufferPos += 2;
1131 break;
1132 case MSG_FX_STATIC:
1133 msg_drawState->effectFlags |= MSG_FX_FLAG_STATIC;
1134 gDPSetEnvColor(gMainGfxPos++,
1135 msg_drawState->printBuffer[msg_drawState->drawBufferPos + 2],
1136 msg_drawState->printBuffer[msg_drawState->drawBufferPos + 2],
1137 msg_drawState->printBuffer[msg_drawState->drawBufferPos + 2],
1138 0);
1139 gDPSetCombineMode(gMainGfxPos++, PM_CC_MSG_STATIC, PM_CC_MSG_STATIC);
1140 msg_drawState->drawBufferPos += 3;
1141 break;
1142 case MSG_FX_BLUR:
1143 msg_drawState->effectFlags |= MSG_FX_FLAG_BLUR;
1144 spB8 = msg_drawState->printBuffer[msg_drawState->drawBufferPos + 2];
1145 msg_drawState->drawBufferPos += 3;
1146 break;
1147 case MSG_FX_RAINBOW:
1148 msg_drawState->effectFlags |= MSG_FX_FLAG_RAINBOW;
1149 msg_drawState->drawBufferPos += 2;
1150 break;
1151 case MSG_FX_DITHER_FADE:
1152 msg_drawState->effectFlags |= MSG_FX_FLAG_DITHER_FADE;
1153 spB6 = msg_drawState->printBuffer[msg_drawState->drawBufferPos + 2];
1154 msg_drawState->drawBufferPos += 3;
1155 break;
1156 case MSG_FX_GLOBAL_WAVE:
1157 msg_drawState->effectFlags |= MSG_FX_FLAG_GLOBAL_WAVE;
1158 msg_drawState->drawBufferPos += 2;
1159 break;
1161 msg_drawState->effectFlags |= MSG_FX_FLAG_GLOBAL_RAINBOW;
1162 msg_drawState->drawBufferPos += 2;
1163 break;
1164 case MSG_FX_RISE_PRINT:
1165 msg_drawState->effectFlags |= MSG_FX_FLAG_RISE_PRINT;
1166 msg_drawState->drawBufferPos += 2;
1167 break;
1168 case MSG_FX_GROW_PRINT:
1169 msg_drawState->effectFlags |= MSG_FX_FLAG_GROW_PRINT;
1170 msg_drawState->drawBufferPos += 2;
1171 break;
1172 case MSG_FX_SIZE_JITTER:
1173 msg_drawState->effectFlags |= MSG_FX_FLAG_SIZE_JITTER;
1174 msg_drawState->drawBufferPos += 2;
1175 break;
1176 case MSG_FX_SIZE_WAVE:
1177 msg_drawState->effectFlags |= MSG_FX_FLAG_SIZE_WAVE;
1178 msg_drawState->drawBufferPos += 2;
1179 break;
1180 case MSG_FX_DROP_SHADOW:
1181 msg_drawState->effectFlags |= MSG_FX_FLAG_DROP_SHADOW;
1182 msg_drawState->drawBufferPos += 2;
1183 break;
1184 }
1185 break;
1187 switch (msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1]) {
1188 case MSG_FX_SHAKE:
1189 msg_drawState->effectFlags &= ~MSG_FX_FLAG_SHAKE;
1190 break;
1191 case MSG_FX_WAVE:
1192 msg_drawState->effectFlags &= ~MSG_FX_FLAG_WAVE;
1193 break;
1195 msg_drawState->effectFlags &= ~MSG_FX_FLAG_NOISE_OUTLINE;
1196 break;
1197 case MSG_FX_STATIC:
1198 msg_drawState->effectFlags &= ~MSG_FX_FLAG_STATIC;
1199 break;
1200 case MSG_FX_BLUR:
1201 msg_drawState->effectFlags &= ~MSG_FX_FLAG_BLUR;
1202 break;
1203 case MSG_FX_RAINBOW:
1204 msg_drawState->effectFlags &= ~MSG_FX_FLAG_RAINBOW;
1205 msg_drawState->printModeFlags |= MSG_PRINT_FLAG_10;
1206 break;
1207 case MSG_FX_DITHER_FADE:
1208 msg_drawState->effectFlags &= ~MSG_FX_FLAG_DITHER_FADE;
1209 break;
1210 case MSG_FX_GLOBAL_WAVE:
1211 msg_drawState->effectFlags &= ~MSG_FX_FLAG_GLOBAL_WAVE;
1212 break;
1214 msg_drawState->effectFlags &= ~MSG_FX_FLAG_GLOBAL_RAINBOW;
1215 msg_drawState->printModeFlags |= MSG_PRINT_FLAG_10;
1216 break;
1217 case MSG_FX_RISE_PRINT:
1218 msg_drawState->effectFlags &= ~MSG_FX_FLAG_RISE_PRINT;
1219 break;
1220 case MSG_FX_GROW_PRINT:
1221 msg_drawState->effectFlags &= ~MSG_FX_FLAG_GROW_PRINT;
1222 break;
1223 case MSG_FX_SIZE_JITTER:
1224 msg_drawState->effectFlags &= ~MSG_FX_FLAG_SIZE_JITTER;
1225 break;
1226 case MSG_FX_SIZE_WAVE:
1227 msg_drawState->effectFlags &= ~MSG_FX_FLAG_SIZE_WAVE;
1228 break;
1229 case MSG_FX_DROP_SHADOW:
1230 msg_drawState->effectFlags &= ~MSG_FX_FLAG_DROP_SHADOW;
1231 break;
1232 }
1233 msg_drawState->drawBufferPos += 2;
1234 break;
1236 if (msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1] != 0) {
1237 msg_drawState->centerPos = msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1];
1238 if (msg_drawState->centerPos == 0xFF) {
1239 msg_drawState->centerPos = printer->windowSize.x / 2;
1240 }
1242 } else {
1243 msg_drawState->nextPos[0] = 0;
1244 msg_drawState->printModeFlags &= ~(MSG_PRINT_FLAG_40 | MSG_PRINT_FLAG_80);
1245 }
1246 msg_drawState->drawBufferPos += 2;
1247 break;
1248 }
1249 break;
1250 default:
1251#if VERSION_IQUE
1252 if (lastbyte >= 0x5f && lastbyte <= 0x8f) {
1253 msg_drawState->drawBufferPos++;
1254 break;
1255 }
1256#endif
1257
1258 if (msg_drawState->printModeFlags & MSG_PRINT_FLAG_2) {
1259 sp96 = 0xFF;
1260 gDPPipeSync(gMainGfxPos++);
1261 gSPDisplayList(gMainGfxPos++, D_8014C500);
1262 }
1263 msg_drawState->charScale.x = msg_drawState->msgScale.x;
1264 msg_drawState->charScale.y = msg_drawState->msgScale.y;
1265 if (msg_drawState->printModeFlags & MSG_PRINT_FLAG_80) {
1266 msg_drawState->nextPos[0] += msg_drawState->centerPos - printer->msgWidth / 2;
1267 msg_drawState->printModeFlags &= ~MSG_PRINT_FLAG_80;
1268 }
1269 if (msg_drawState->printModeFlags & MSG_PRINT_FLAG_40) {
1270 charPosX = msg_drawState->nextPos[0] + (printer->windowBasePos.x + posX);
1271 } else {
1272 charPosX = msg_drawState->nextPos[0] + (msg_drawState->textStartPos[0] + (printer->windowBasePos.x +
1273 posX));
1274 }
1275
1276 baseOffsetY = msg_drawState->nextPos[1] + (msg_drawState->textStartPos[1] + (printer->windowBasePos.y + posY));
1277 msgCharset = MsgCharsets[msg_drawState->font];
1278 rasterOffsetY = msgCharset->rasters[msg_drawState->fontVariant].baseHeightOffset;
1279 charPosY = rasterOffsetY + (baseOffsetY - additionalOffsetY);
1280
1281 if ((sp8E != 0) &&
1282 (charPosX < msg_drawState->clipX[1]) &&
1283 (charPosY < msg_drawState->clipY[1]) &&
1284 (msg_drawState->clipX[0] < charPosX + (s32)(msg_drawState->msgScale.x *
1285 msgCharset->rasters[msg_drawState->fontVariant].monospaceWidth)) &&
1286 (msg_drawState->clipY[0] < charPosY + (s32)(msg_drawState->msgScale.y * msgCharset->newLineY
1287#if !VERSION_JP
1289#endif
1290 ))) {
1291 palette = msg_drawState->textColor;
1292 phi_s2_5 = sp8E;
1293 if (msg_drawState->effectFlags & MSG_FX_FLAG_BLUR) {
1294 phi_s2_5 = (f32) phi_s2_5 * 0.35;
1295 }
1296 if ((printer->windowState == MSG_WINDOW_STATE_WAITING_FOR_CHOICE) && (msg_drawState->printModeFlags & MSG_PRINT_FLAG_20)) {
1297 if (msg_drawState->unk_2D == printer->curOption) {
1299 } else {
1300 msg_drawState->effectFlags &= ~MSG_FX_FLAG_GLOBAL_RAINBOW;
1301 msg_drawState->effectFlags &= ~MSG_FX_FLAG_GLOBAL_WAVE;
1302 msg_drawState->effectFlags &= ~MSG_FX_FLAG_DROP_SHADOW;
1303 palette = msg_drawState->textColor;
1304 msg_drawState->printModeFlags |= MSG_PRINT_FLAG_10;
1305 }
1306 }
1307 if (msg_drawState->effectFlags & MSG_FX_FLAG_SHAKE) {
1308 charPosX += rand_int(10000) % 2;
1309 charPosY += rand_int(10000) % 2;
1310 }
1311 if (msg_drawState->effectFlags & MSG_FX_FLAG_WAVE) {
1312 temp_f2_3 = msg_drawState->msgScale.x - 1.0;
1313 temp_s0_7 = (printer->effectFrameCounter * (s32)(20.0 - (temp_f2_3 * 5.0))) - (msg_drawState->visiblePrintedCount *
1314 (s32)(45.0 - (temp_f2_3 * 15.0)));
1315 charPosX += cosine(temp_s0_7) * ((msg_drawState->msgScale.x - 1.0) + 1.6);
1316 charPosY += cosine((temp_s0_7 + 180.0 + 90.0)) * (msg_drawState->msgScale.y - 1.0 + 1.6);
1317 }
1318 if (msg_drawState->effectFlags & MSG_FX_FLAG_GLOBAL_WAVE) {
1319 temp_s0_8 = (gMsgGlobalWaveCounter * (s32)(20.0 - ((msg_drawState->msgScale.x - 1.0) * 5.0))) -
1320 (msg_drawState->visiblePrintedCount * 45);
1321 charPosX += cosine(temp_s0_8) * ((msg_drawState->msgScale.x - 1.0) + 1.6);
1322 charPosY += cosine((temp_s0_8 + 180.0 + 90.0)) * ((msg_drawState->msgScale.y - 1.0) + 1.6);
1323 }
1324 if (msg_drawState->effectFlags & MSG_FX_FLAG_RAINBOW) {
1325 palette = abs(msg_drawState->visiblePrintedCount - (u16)(printer->effectFrameCounter / 3)) % 10;
1326 }
1327 if (msg_drawState->effectFlags & MSG_FX_FLAG_GLOBAL_RAINBOW) {
1328 palette = abs(msg_drawState->visiblePrintedCount - (u16)(gGameStatusPtr->frameCounter / 3)) % 10;
1329 }
1330 if (msg_drawState->effectFlags & MSG_FX_FLAG_DITHER_FADE) {
1331 gDPSetAlphaDither(gMainGfxPos++, G_AD_NOISE);
1332 gDPSetAlphaCompare(gMainGfxPos++, G_AC_DITHER);
1333 phi_s2_5 = spB6 * (phi_s2_5 / 255.0);
1334 }
1335 if ((msg_drawState->printModeFlags & MSG_PRINT_FLAG_2) || (phi_s2_5 != sp96)) {
1336 if ((sp96 < 0xFF) && (phi_s2_5 < 0xFF)) {
1337 gDPSetPrimColor(gMainGfxPos++, 0, 0, 0, 0, 0, phi_s2_5);
1338 } else if ((sp96 == 0xFF) && (phi_s2_5 < 0xFF)) {
1339 gDPPipeSync(gMainGfxPos++);
1340 if (printer->stateFlags & MSG_STATE_FLAG_4000) {
1341 gDPSetRenderMode(gMainGfxPos++, IM_RD | CVG_DST_CLAMP | ZMODE_XLU | FORCE_BL | GBL_c1(G_BL_CLR_IN, G_BL_A_IN,
1342 G_BL_CLR_MEM, G_BL_1MA), IM_RD | CVG_DST_CLAMP | ZMODE_XLU | FORCE_BL | GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM,
1343 G_BL_1MA));
1344
1345 } else {
1346 gDPSetRenderMode(gMainGfxPos++, IM_RD | CVG_DST_SAVE | ZMODE_XLU | FORCE_BL | GBL_c1(G_BL_CLR_IN, G_BL_A_IN,
1347 G_BL_CLR_MEM, G_BL_1MA), IM_RD | CVG_DST_SAVE | ZMODE_XLU | FORCE_BL | GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM,
1348 G_BL_1MA));
1349
1350 }
1351 gDPSetCombineMode(gMainGfxPos++, PM_CC_02, PM_CC_02);
1352 gDPSetPrimColor(gMainGfxPos++, 0, 0, 0, 0, 0, phi_s2_5);
1353 } else if ((sp96 < 0xFF) && (phi_s2_5 == 0xFF)) {
1354 gDPPipeSync(gMainGfxPos++);
1355 gDPSetRenderMode(gMainGfxPos++, G_RM_TEX_EDGE, G_RM_TEX_EDGE2);
1356 gDPSetCombineMode(gMainGfxPos++, G_CC_DECALRGBA, G_CC_DECALRGBA);
1357 }
1358 sp96 = phi_s2_5;
1359 }
1360 if (phi_s2_5 > 0) {
1361 if (msg_drawState->effectFlags & MSG_FX_FLAG_RISE_PRINT) {
1362 if ((msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1] != MSG_CHAR_PRINT_ENDL) &&
1363 (msg_drawState->printBuffer[msg_drawState->drawBufferPos + 2] != MSG_CHAR_PRINT_ENDL) &&
1364 (msg_drawState->printBuffer[msg_drawState->drawBufferPos + 3] != MSG_CHAR_PRINT_ENDL) &&
1365 (msg_drawState->printBuffer[msg_drawState->drawBufferPos + 4] != MSG_CHAR_PRINT_ENDL)) {
1366 if ((msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1] == MSG_CHAR_PRINT_END) &&
1367 (printer->windowState == MSG_WINDOW_STATE_PRINTING)) {
1368 msg_drawState->charScale.x = msg_drawState->msgScale.x * 1.7;
1369 msg_drawState->charScale.y = msg_drawState->msgScale.y * 1.7;
1370 temp_f8 = (msg_drawState->charScale.y / 1.7) * 6.0;
1371 charPosX -= temp_f8;
1372 charPosY -= temp_f8;
1373 } else if ((msg_drawState->printBuffer[msg_drawState->drawBufferPos + 2] == MSG_CHAR_PRINT_END) &&
1374 (printer->windowState == MSG_WINDOW_STATE_PRINTING)) {
1375 msg_drawState->charScale.x = msg_drawState->msgScale.x * 1.4;
1376 msg_drawState->charScale.y = msg_drawState->msgScale.y * 1.4;
1377 temp_f8 = (msg_drawState->charScale.y / 1.4) * 3.0;
1378 charPosX -= temp_f8;
1379 charPosY -= temp_f8;
1380 } else if ((msg_drawState->printBuffer[msg_drawState->drawBufferPos + 3] == MSG_CHAR_PRINT_END) &&
1381 (printer->windowState == MSG_WINDOW_STATE_PRINTING)) {
1382 msg_drawState->charScale.x = msg_drawState->msgScale.x * 1.2;
1383 msg_drawState->charScale.y = msg_drawState->msgScale.y * 1.2;
1384 temp_f8 = (msg_drawState->charScale.y / 1.2) * 2.0;
1385 charPosX -= temp_f8;
1386 charPosY -= temp_f8;
1387 }
1388 }
1389 } else if (msg_drawState->effectFlags & MSG_FX_FLAG_GROW_PRINT) {
1390 if ((msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1] != MSG_CHAR_PRINT_ENDL) &&
1391 (msg_drawState->printBuffer[msg_drawState->drawBufferPos + 2] != MSG_CHAR_PRINT_ENDL) &&
1392 (msg_drawState->printBuffer[msg_drawState->drawBufferPos + 3] != MSG_CHAR_PRINT_ENDL) &&
1393 (msg_drawState->printBuffer[msg_drawState->drawBufferPos + 4] != MSG_CHAR_PRINT_ENDL)) {
1394 if ((msg_drawState->printBuffer[msg_drawState->drawBufferPos + 1] == MSG_CHAR_PRINT_END) &&
1395 (printer->windowState == MSG_WINDOW_STATE_PRINTING)) {
1396 msg_drawState->charScale.x = msg_drawState->msgScale.x * 0.3;
1397 msg_drawState->charScale.y = msg_drawState->msgScale.y * 0.3;
1398 charPosX += 5;
1399 charPosY += 5;
1400 } else if ((msg_drawState->printBuffer[msg_drawState->drawBufferPos + 2] == MSG_CHAR_PRINT_END) &&
1401 (printer->windowState == MSG_WINDOW_STATE_PRINTING)) {
1402 msg_drawState->charScale.x = msg_drawState->msgScale.x * 0.5;
1403 msg_drawState->charScale.y = msg_drawState->msgScale.y * 0.5;
1404 charPosX += 3;
1405 charPosY += 3;
1406 } else if ((msg_drawState->printBuffer[msg_drawState->drawBufferPos + 3] == MSG_CHAR_PRINT_END) &&
1407 (printer->windowState == MSG_WINDOW_STATE_PRINTING)) {
1408 msg_drawState->charScale.x = msg_drawState->msgScale.x * 0.75;
1409 msg_drawState->charScale.y = msg_drawState->msgScale.y * 0.75;
1410 charPosX += 2;
1411 charPosY += 2;
1412 }
1413 }
1414 } else if (msg_drawState->effectFlags & MSG_FX_FLAG_SIZE_JITTER) {
1415 temp_f8_5 = rand_int(10000) % 101;
1416 temp_f8_5 /= 100.0;
1417 temp_f8_5 = ((temp_f8_5 * 0.5) + 1.0) - 0.25;
1418
1419 if (temp_f8_5 > 1.0) {
1420 msg_drawState->charScale.x = msg_drawState->msgScale.x * temp_f8_5;
1421 msg_drawState->charScale.y = msg_drawState->msgScale.y * temp_f8_5;
1422 charPosX -= (temp_f8_5 * 8.0) - 8.5;
1423 charPosY -= (temp_f8_5 * 8.0) - 8.5;
1424 } else if (temp_f8_5 < 1.0) {
1425 msg_drawState->charScale.x = msg_drawState->msgScale.x * temp_f8_5;
1426 msg_drawState->charScale.y = msg_drawState->msgScale.y * temp_f8_5;
1427 charPosX += 8.0 - (temp_f8_5 * 16.0) * 0.5;
1428 charPosY += 8.0 - (temp_f8_5 * 16.0) * 0.5;
1429 }
1430 } else if (msg_drawState->effectFlags & MSG_FX_FLAG_SIZE_WAVE) {
1431 s32 mod360;
1432
1433 temp_a0_49 = printer->effectFrameCounter * 15;
1434 temp_a0_49 -= msg_drawState->visiblePrintedCount * 15;
1435 mod360 = temp_a0_49 % 360;
1436 temp_f8_5 = (cosine(mod360) * 0.25) + 1.0;
1437
1438 if (temp_f8_5 > 1.0) {
1439 msg_drawState->charScale.x = msg_drawState->msgScale.x * temp_f8_5;
1440 msg_drawState->charScale.y = msg_drawState->msgScale.y * temp_f8_5;
1441 charPosX -= (temp_f8_5 * 8.0) - 8.5;
1442 charPosY -= (temp_f8_5 * 8.0) - 8.5;
1443 } else if (temp_f8_5 < 1.0) {
1444 msg_drawState->charScale.x = msg_drawState->msgScale.x * temp_f8_5;
1445 msg_drawState->charScale.y = msg_drawState->msgScale.y * temp_f8_5;
1446 charPosX += 8.0 - (temp_f8_5 * 16.0) * 0.5;
1447 charPosY += 8.0 - (temp_f8_5 * 16.0) * 0.5;
1448 }
1449 }
1450
1451 if ((printer->windowState == MSG_WINDOW_STATE_B || printer->windowState == MSG_WINDOW_STATE_C) &&
1452 (printer->style == MSG_STYLE_RIGHT ||
1453 printer->style == MSG_STYLE_LEFT ||
1454 printer->style == MSG_STYLE_CENTER ||
1455 printer->style == MSG_STYLE_TATTLE))
1456 {
1457 switch (palette) {
1458 case MSG_PAL_WHITE:
1459 case MSG_PAL_RED:
1460 case MSG_PAL_10:
1461 case MSG_PAL_11:
1462 case MSG_PAL_12:
1463 case MSG_PAL_13:
1464 case MSG_PAL_14:
1465 break;
1466#if !VERSION_IQUE
1467 case MSG_PAL_STANDARD:
1468 palette = MSG_PAL_40;
1469 break;
1470#endif
1471 case MSG_PAL_20:
1472 palette = MSG_PAL_41;
1473 break;
1474 case MSG_PAL_22:
1475 palette = MSG_PAL_42;
1476 break;
1477 case MSG_PAL_23:
1478 palette = MSG_PAL_43;
1479 break;
1480 case MSG_PAL_25:
1481 palette = MSG_PAL_44;
1482 break;
1483 default:
1484 palette = MSG_PAL_40;
1485 break;
1486 }
1487 }
1488 if (palette != sp9E) {
1489 sp9E = palette;
1490 msg_drawState->printModeFlags |= MSG_PRINT_FLAG_10;
1491 }
1492 if ((msg_drawState->effectFlags & MSG_FX_FLAG_DROP_SHADOW) && (phi_s2_5 == 0xFF)) {
1493 gDPPipeSync(gMainGfxPos++);
1494 gDPSetRenderMode(gMainGfxPos++, G_RM_XLU_SURF, G_RM_XLU_SURF2);
1495 gDPSetCombineMode(gMainGfxPos++, PM_CC_07, PM_CC_07);
1496 gDPSetPrimColor(gMainGfxPos++, 0, 0, 40, 40, 40, 72);
1497#if VERSION_IQUE
1498 if (byte >= MSG_CHAR_MULTIBYTE_FIRST && byte <= MSG_CHAR_MULTIBYTE_LAST) {
1499 glyph_index = (MSG_CHAR_ZH_START - MSG_CHAR_MULTIBYTE_FIRST) + byte + (byte2 - 1)
1500 * (MSG_CHAR_MULTIBYTE_LAST - MSG_CHAR_MULTIBYTE_FIRST + 1);
1501 msg_draw_char(printer, msg_drawState, glyph_index,
1502 palette, charPosX + 2, charPosY + 2);
1503 } else {
1504 msg_draw_char(printer, msg_drawState, byte,
1505 palette, charPosX + 2, charPosY + 2);
1506 }
1507#else
1508 msg_draw_char(printer, msg_drawState,
1509 msg_drawState->printBuffer[msg_drawState->drawBufferPos],
1510 palette, charPosX + 2, charPosY + 2);
1511#endif
1512 gDPPipeSync(gMainGfxPos++);
1513 if (phi_s2_5 < 0xFF) {
1514 gDPSetRenderMode(gMainGfxPos++, G_RM_XLU_SURF, G_RM_XLU_SURF2);
1515 gDPSetCombineMode(gMainGfxPos++, PM_CC_02, PM_CC_02);
1516 } else {
1517 gDPSetRenderMode(gMainGfxPos++, G_RM_TEX_EDGE, G_RM_TEX_EDGE2);
1518 gDPSetCombineMode(gMainGfxPos++, G_CC_DECALRGBA, G_CC_DECALRGBA);
1519 }
1520 }
1521
1522 if (msg_drawState->effectFlags & MSG_FX_FLAG_BLUR) {
1523 for (i = 0; i < 5; i++) {
1524 phi_s0_7 = charPosX;
1525 phi_s1_8 = charPosY;
1526 if (spB8 != 2) {
1527 phi_s0_7 += (rand_int(10000) % 3) - 1;
1528 }
1529 if (spB8 != 1) {
1530 phi_s1_8 += (rand_int(10000) % 3) - 1;
1531 }
1532#if VERSION_IQUE
1533 if (byte >= MSG_CHAR_MULTIBYTE_FIRST && byte <= MSG_CHAR_MULTIBYTE_LAST) {
1534 glyph_index = (MSG_CHAR_ZH_START - MSG_CHAR_MULTIBYTE_FIRST) + byte + (byte2 - 1)
1535 * (MSG_CHAR_MULTIBYTE_LAST - MSG_CHAR_MULTIBYTE_FIRST + 1);
1536 msg_draw_char(printer, msg_drawState, glyph_index,
1537 palette, charPosX + 2, charPosY + 2);
1538 } else {
1539 msg_draw_char(printer, msg_drawState, byte,
1540 palette, charPosX + 2, charPosY + 2);
1541 }
1542#else
1543 msg_draw_char(printer, msg_drawState,
1544 msg_drawState->printBuffer[msg_drawState->drawBufferPos], palette,
1545 phi_s0_7, phi_s1_8);
1546#endif
1547 }
1548 } else {
1549#if VERSION_IQUE
1550 if (byte >= MSG_CHAR_MULTIBYTE_FIRST && byte <= MSG_CHAR_MULTIBYTE_LAST) {
1551 glyph_index = (MSG_CHAR_ZH_START - MSG_CHAR_MULTIBYTE_FIRST) + byte + (byte2 - 1)
1552 * (MSG_CHAR_MULTIBYTE_LAST - MSG_CHAR_MULTIBYTE_FIRST + 1);
1553 msg_draw_char(printer, msg_drawState, glyph_index,
1554 palette, charPosX + 2, charPosY + 2);
1555 } else {
1556 msg_draw_char(printer, msg_drawState, byte,
1557 palette, charPosX + 2, charPosY + 2);
1558 }
1559#else
1560 msg_draw_char(printer, msg_drawState,
1561 msg_drawState->printBuffer[msg_drawState->drawBufferPos], palette, charPosX,
1562 charPosY);
1563#endif
1564 }
1565 }
1566 }
1567 if (msg_drawState->printModeFlags & MSG_PRINT_FLAG_2) {
1568 msg_drawState->printModeFlags &= ~MSG_PRINT_FLAG_2;
1569 }
1570 msg_drawState->visiblePrintedCount += 1;
1571 msg_drawState->nextPos[0] +=
1572#if VERSION_IQUE
1573 msg_drawState->msgScale.x * 14.0f;
1574#else
1575 msg_get_draw_char_width(msg_drawState->printBuffer[msg_drawState->drawBufferPos],
1576 msg_drawState->font, msg_drawState->fontVariant, msg_drawState->msgScale.x,
1577 msg_drawState->curPosX, msg_drawState->printModeFlags);
1578#endif
1579 msg_drawState->drawBufferPos++;
1580 break;
1581 }
1582 }
1583
1584 varImgHasBorder = FALSE;
1585 if (printer->varImageScreenPos.x != 0) {
1586 s16 varImgFinalAlpha;
1587
1588 varImgFinalAlpha = printer->varImgFinalAlpha;
1589 msgVarImage = &(*gMsgVarImages)[printer->curImageIndex];
1590
1591 switch (printer->varImgHasBorder) {
1592 case 0:
1593 case 1:
1594 if (printer->varImgHasBorder) {
1595 varImgHasBorder = TRUE;
1596 }
1597 switch (printer->varImageDisplayState) {
1598 case 0:
1599 printer->varImageFadeTimer++;
1600 varImgFinalAlpha = printer->varImageFadeTimer * printer->varImgAlphaFadeStep;
1601 if (printer->varImgFinalAlpha <= varImgFinalAlpha) {
1602 varImgFinalAlpha = printer->varImgFinalAlpha;
1603 printer->varImageFadeTimer = 0;
1604 printer->varImageDisplayState = 1;
1605 }
1606 break;
1607 case 1:
1608 varImgFinalAlpha = (u8)(((f32) spAE / 255.0) * (f32) printer->varImgFinalAlpha);
1609 break;
1610 case 2:
1611 printer->varImageFadeTimer++;
1612 varImgFinalAlpha = printer->varImgFinalAlpha - printer->varImgAlphaFadeStep * printer->varImageFadeTimer;
1613 if (varImgFinalAlpha < 1) {
1614 printer->varImageScreenPos.x = 0;
1615 }
1616 break;
1617 }
1618 break;
1619 case 2:
1620 varImgFinalAlpha = (u8)(((f32) spAE / 255.0) * (f32) printer->varImgFinalAlpha);
1621 break;
1622 }
1623
1624 if (varImgFinalAlpha > 0) {
1625 if (varImgHasBorder) {
1626 draw_box(0, WINDOW_STYLE_15, printer->varImageScreenPos.x - 7, printer->varImageScreenPos.y - 7, 0,
1627 msgVarImage->width + 15, msgVarImage->height + 14, varImgFinalAlpha, 0, 0.0f, 0.0f, 0.0f, 0.0f,
1628 0.0f, NULL, 0, NULL, SCREEN_WIDTH, SCREEN_HEIGHT, NULL);
1629 }
1630 draw_ci_image_with_clipping(msgVarImage->raster, msgVarImage->width, msgVarImage->height,
1631 msgVarImage->format, msgVarImage->bitDepth, msgVarImage->palette,
1632 printer->varImageScreenPos.x, printer->varImageScreenPos.y, 0, 0,
1633 SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1, varImgFinalAlpha);
1634 }
1635
1636 }
1637 gDPPipeSync(gMainGfxPos++);
1639}
MessageCharData * rasters
#define PAL_PTR
#define IMG_PTR
#define rand_int
@ WINDOW_STYLE_15
Definition enums.h:6385
@ MSG_FX_FLAG_RISE_PRINT
Definition enums.h:6187
@ MSG_FX_FLAG_DROP_SHADOW
Definition enums.h:6191
@ MSG_FX_FLAG_BLUR
Definition enums.h:6182
@ MSG_FX_FLAG_GLOBAL_WAVE
Definition enums.h:6185
@ MSG_FX_FLAG_WAVE
Definition enums.h:6180
@ MSG_FX_FLAG_GROW_PRINT
Definition enums.h:6188
@ MSG_FX_FLAG_GLOBAL_RAINBOW
Definition enums.h:6186
@ MSG_FX_FLAG_SHAKE
Definition enums.h:6179
@ MSG_FX_FLAG_SIZE_WAVE
Definition enums.h:6190
@ MSG_FX_FLAG_NOISE_OUTLINE
Definition enums.h:6181
@ MSG_FX_FLAG_STATIC
Definition enums.h:6192
@ MSG_FX_FLAG_RAINBOW
Definition enums.h:6183
@ MSG_FX_FLAG_SIZE_JITTER
Definition enums.h:6189
@ MSG_FX_FLAG_DITHER_FADE
Definition enums.h:6184
@ MSG_STATE_FLAG_4000
Definition enums.h:6250
@ MSG_PRINT_FUNC_SET_FRAME_PALETTE
Definition enums.h:6132
@ MSG_PAL_14
Definition enums.h:5425
@ MSG_PAL_13
Definition enums.h:5424
@ MSG_PAL_22
Definition enums.h:5439
@ MSG_PAL_43
Definition enums.h:5472
@ MSG_PAL_42
Definition enums.h:5471
@ MSG_PAL_WHITE
Definition enums.h:5405
@ MSG_PAL_20
Definition enums.h:5437
@ MSG_PAL_23
Definition enums.h:5440
@ MSG_PAL_1C
Definition enums.h:5433
@ MSG_PAL_STANDARD
Definition enums.h:5415
@ MSG_PAL_10
Definition enums.h:5421
@ MSG_PAL_12
Definition enums.h:5423
@ MSG_PAL_25
Definition enums.h:5442
@ MSG_PAL_44
Definition enums.h:5473
@ MSG_PAL_40
Definition enums.h:5469
@ MSG_PAL_RED
Definition enums.h:5412
@ MSG_PAL_41
Definition enums.h:5470
@ MSG_PAL_18
Definition enums.h:5429
@ MSG_PAL_11
Definition enums.h:5422
@ EASING_SIN_OUT
Definition enums.h:521
@ MSG_PRINT_FLAG_2
Definition enums.h:6230
@ MSG_PRINT_FLAG_40
Definition enums.h:6233
@ MSG_PRINT_FLAG_100
Definition enums.h:6235
@ MSG_PRINT_FLAG_1
Definition enums.h:6229
@ MSG_PRINT_FLAG_20
Definition enums.h:6232
@ MSG_PRINT_FLAG_10
Definition enums.h:6231
@ MSG_PRINT_FLAG_80
Definition enums.h:6234
@ MSG_CHAR_PRINT_VARIANT2
Definition enums.h:6065
@ MSG_CHAR_PRINT_VARIANT1
Definition enums.h:6064
@ MSG_CHAR_PRINT_VARIANT3
Definition enums.h:6066
#define MSG_SIGN_OFFSET_X
Definition msg_draw.c:205
void msg_draw_speech_bubble(MessagePrintState *printer, s16 posX, s16 posY, s16 straightWidth, s16 curveWidth, s16 height, f32 scaleX, f32 scaleY, u8 opacity, s32 arg9)
Definition msg_draw.c:1823
#define MSG_SIGN_WIDTH
Definition msg_draw.c:204
PAL_BIN D_8015C7E0[0x10]
Definition msg.c:105
IMG_BIN ui_msg_lamppost_corner_bottomright_png[]
IMG_BIN D_80159B50[0x200]
Definition msg.c:104
IMG_BIN ui_msg_sign_side_top_png[]
s16 MsgStyleVerticalLineOffsets[]
Definition msg_data.c:927
PAL_BIN ui_msg_lamppost_pal[]
void msg_draw_char(MessagePrintState *printer, MessageDrawState *drawState, s32 charIndex, s32 palette, s32 posX, s32 posY)
Definition msg_draw.c:1647
IMG_BIN ui_msg_sign_corner_topright_png[]
Gfx * D_80151338
Definition msg.c:93
#define MSG_POPUP_TEXT_Y
Definition msg_draw.c:206
#define MSG_NORMAL_WIN_WIDTH
Definition msg_draw.c:195
void msg_draw_frame(s32 posX, s32 posY, s32 sizeX, s32 sizeY, s32 style, s32 palette, s32 fading, s32 bgAlpha, s32 frameAlpha)
Definition msg_draw.c:2043
#define MSG_SIGN_TEXT_Y
Definition msg_draw.c:203
#define MSG_EPILOGUE_TEXT_Y
Definition msg_draw.c:207
#define MSG_NORMAL_X
Definition msg_draw.c:194
IMG_BIN ui_msg_sign_fill_png[]
#define MSG_NORMAL_WIDTH
Definition msg_draw.c:193
u16 gMsgGlobalWaveCounter
Definition msg.c:89
void msg_draw_prim_rect(u8 r, u8 g, u8 b, u8 a, u16 posX, u16 posY, u16 sizeX, u16 sizeY)
Definition msg_draw.c:1788
s32 msg_get_draw_char_width(s32 character, s32 charset, s32 variation, f32 msgScale, s32 overrideCharWidth, u16 flags)
Definition msg.c:1628
PAL_BIN ui_msg_sign_pal[]
#define MSG_NORMAL_TEXT_Y
Definition msg_draw.c:197
void msg_reset_gfx_state(void)
Definition msg_draw.c:1642
#define MSG_NORMAL_ARROW_X
Definition msg_draw.c:198
IMG_BIN ui_msg_sign_side_bottom_png[]
#define MSG_NORMAL_PAGE_HT
Definition msg_draw.c:201
IMG_BIN ui_msg_sign_side_right_png[]
IMG_BIN ui_msg_sign_corner_bottomleft_png[]
#define MSG_NORMAL_WIN_HEIGHT
Definition msg_draw.c:196
void msg_draw_speech_arrow(MessagePrintState *printer)
Definition msg_draw.c:1928
IMG_BIN ui_msg_sign_corner_bottomright_png[]
Gfx D_8014C500[]
Definition msg_draw.c:94
#define MSG_INSPECT_TEXT_Y
Definition msg_draw.c:202
IMG_BIN ui_msg_sign_corner_topleft_png[]
#define MSG_NORMAL_ARROW_Y
Definition msg_draw.c:199
#define MSG_NORMAL_HEIGHT_CAP
Definition msg_draw.c:200
MessageCharset * MsgCharsets[5]
Definition msg_data.c:865
IMG_BIN ui_msg_sign_side_left_png[]
u8 * D_8015131C
Definition msg.c:92
#define PM_CC_MSG_NOISE_OUTLINE
Definition macros.h:450
#define PM_CC_MSG_STATIC
Definition macros.h:451
#define PM_CC_02
Definition macros.h:277
s32 spr_get_npc_raster_info(SpriteRasterInfo *out, s32 npcSpriteID, s32 rasterIndex)
Definition sprite.c:1302

Referenced by draw_message_window(), draw_msg(), and drawbox_message_delegate().

◆ clear_character_set()

void clear_character_set ( void )

Definition at line 192 of file msg.c.

192 {
193 D_80155C98 = -1;
194}

Referenced by load_engine_data().

◆ clear_printers()

void clear_printers ( void )

Definition at line 196 of file msg.c.

196 {
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}
Gfx * D_80151338
Definition msg.c:93
u16 gMsgGlobalWaveCounter
Definition msg.c:89
s32 gMsgBGScrollAmtY
Definition msg.c:91
void load_font(s32 font)
Definition msg.c:225
s32 gMsgBGScrollAmtX
Definition msg.c:88

Referenced by load_demo_battle(), load_engine_data(), load_map_by_IDs(), state_init_title_screen(), state_step_demo(), state_step_intro(), and state_step_startup().

◆ load_font_data()

void load_font_data ( Addr offset,
u16 size,
void * dest )

Definition at line 218 of file msg.c.

218 {
219#endif
220 u8* base = charset_ROM_START + (s32) offset;
221
222 dma_copy(base, base + size, dest);
223}

Referenced by filemenu_draw_char(), load_font(), and msg_draw_char().

◆ load_font()

void load_font ( s32 font)

Definition at line 225 of file msg.c.

225 {
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}
unsigned char charset_standard_pal_OFFSET[]
unsigned char charset_standard_OFFSET[]
unsigned char charset_subtitle_pal_OFFSET[]
unsigned char charset_subtitle_OFFSET[]
unsigned char charset_title_OFFSET[]
IMG_BIN MsgCharImgSubtitle[]
Definition msg_img.c:92
IMG_BIN MsgCharImgTitle[]
Definition msg_img.c:90
void load_font_data(Addr offset, u16 size, void *dest)
Definition msg.c:218
IMG_BIN MsgCharImgNormal[]
Definition msg_img.c:91
PAL_BIN D_802F4560[80][8]
IMG_BIN MsgCharImgLatin[]
IMG_BIN MsgCharImgMenuKana[]
IMG_BIN MsgCharImgMenuLatin[]
IMG_BIN MsgCharImgKana[]

Referenced by clear_printers().

◆ update_messages()

void update_messages ( void )

Definition at line 247 of file msg.c.

247 {
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}
s32 _update_message(MessagePrintState *printer)
Definition msg.c:271

Referenced by step_game_loop().

◆ render_messages()

void render_messages ( void )

Definition at line 568 of file msg.c.

568 {
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}
@ MSG_STATE_FLAG_10000
Definition enums.h:6252
void msg_draw_rewind_arrow(s32)
Definition msg.c:2145
Vp D_8014C280
Definition msg.c:34
void msg_update_rewind_arrow(s32)
Definition msg.c:2061
void draw_message_window(MessagePrintState *printer)
Definition msg_draw.c:137
void msg_draw_choice_pointer(MessagePrintState *printer)
Definition msg.c:2159
s32 gCurrentDisplayContextIndex
Definition main_loop.c:47

Referenced by gfx_draw_frame().

◆ msg_play_speech_sound()

void msg_play_speech_sound ( MessagePrintState * printer,
u8 character )

Definition at line 609 of file msg.c.

609 {
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}

Referenced by msg_copy_to_print_buffer().

◆ dma_load_msg()

void dma_load_msg ( u32 msgID,
void * dest )

Definition at line 1396 of file msg.c.

1396 {
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}
#define MSG_ROM_START
Definition msg.c:23

Referenced by draw_msg(), get_msg_properties(), load_message_to_buffer(), and set_message_text_var().

◆ load_message_to_buffer()

s8 * load_message_to_buffer ( s32 msgID)

Definition at line 1410 of file msg.c.

1410 {
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}
s16 gNextMessageBuffer
Definition msg.c:62
void dma_load_msg(u32 msgID, void *dest)
Definition msg.c:1396

Referenced by _msg_get_printer_for_msg(), and msg_printer_load_msg().

◆ msg_get_printer_for_msg()

MessagePrintState * msg_get_printer_for_msg ( s32 msgID,
s32 * donePrintingWriteback )

Definition at line 1424 of file msg.c.

1424 {
1425 return _msg_get_printer_for_msg(msgID, donePrintingWriteback, 0);
1426}
MessagePrintState * _msg_get_printer_for_msg(s32 msgID, s32 *donePrintingWriteback, s32 arg2)
Definition msg.c:1428

Referenced by _show_message(), entity_HeartBlock_show_tutorial_message(), entity_SaveBlock_show_choice_message(), entity_SaveBlock_show_tutorial_message(), popup_menu_update(), and update_item_entity_pickup().

◆ msg_printer_load_msg()

s32 msg_printer_load_msg ( s32 msgID,
MessagePrintState * printer )

Definition at line 1474 of file msg.c.

1474 {
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}

Referenced by _show_message(), and entity_SaveBlock_show_result_message().

◆ msg_printer_set_origin_pos()

void msg_printer_set_origin_pos ( MessagePrintState * msgPrintState,
s32 x,
s32 y )

Definition at line 1489 of file msg.c.

1489 {
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}

Referenced by _show_message(), popup_menu_update(), and update_item_entity_pickup().

◆ cancel_message()

s32 cancel_message ( MessagePrintState * msgPrintState)

Definition at line 1507 of file msg.c.

1507 {
1508 if (!(msgPrintState->stateFlags & MSG_STATE_FLAG_2)) {
1509 return FALSE;
1510 }
1511
1512 msgPrintState->stateFlags |= MSG_STATE_FLAG_1;
1513 return TRUE;
1514}

Referenced by cancel_current_message().

◆ set_message_images()

void set_message_images ( MessageImageData * images)

Definition at line 1516 of file msg.c.

1516 {
1517 *gMsgVarImages = images;
1518}
MessageImageDataList gMsgVarImages
Definition msg.c:90

◆ set_message_text_var()

void set_message_text_var ( s32 msgID,
s32 index )

Definition at line 1520 of file msg.c.

1520 {
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}
#define general_heap_malloc

Referenced by btl_message_popup_draw_content(), btl_show_message_popup(), draw_content_pickup_item_header(), func_801363A0(), shop_owner_buy_dialog(), and shop_owner_continue_speech_with_quantity().

◆ set_message_int_var()

void set_message_int_var ( s32 value,
s32 index )

Definition at line 1550 of file msg.c.

1550 {
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}
@ MSG_CHAR_DIGIT_0
Definition enums.h:5872
char * int_to_string(s32, char *, s32)
Definition 43F0.c:386

Referenced by btl_message_popup_draw_content(), btl_show_message_popup(), popup_menu_draw_menu_contents(), shop_owner_buy_dialog(), and shop_owner_continue_speech_with_quantity().

◆ close_message()

void close_message ( MessagePrintState * msgPrintState)

Definition at line 1568 of file msg.c.

1568 {
1569 msgPrintState->stateFlags &= ~MSG_STATE_FLAG_40;
1570}

Referenced by _show_message(), and entity_SaveBlock_wait_for_close_choice().

◆ msg_get_print_char_width()

s32 msg_get_print_char_width ( s32 character,
s32 charset,
s32 variation,
f32 msgScale,
s32 overrideCharWidth,
u8 flags )

Definition at line 1578 of file msg.c.

1578 {
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}
s8 flags
Definition demo_api.c:15
#define CHAR_SPACE_MULTIPLIER
Definition msg.c:1575

Referenced by filemenu_draw_contents_choose_name(), filemenu_draw_file_name(), and get_msg_properties().

◆ msg_get_draw_char_width()

s32 msg_get_draw_char_width ( s32 character,
s32 charset,
s32 variation,
f32 msgScale,
s32 overrideCharWidth,
u16 flags )

Definition at line 1628 of file msg.c.

1628 {
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}

Referenced by appendGfx_message(), and msg_get_glyph().

◆ get_msg_properties()

void get_msg_properties ( s32 msgID,
s32 * height,
s32 * width,
s32 * maxLineChars,
s32 * numLines,
s32 * maxLinesPerPage,
s32 * numSpaces,
u16 charset )

Definition at line 1671 of file msg.c.

1671 {
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}
#define get_msg_width
s32 msg_get_print_char_width(s32 character, s32 charset, s32 variation, f32 msgScale, s32 overrideCharWidth, u8 flags)
Definition msg.c:1578

Referenced by _msg_get_printer_for_msg(), draw_msg(), get_msg_lines(), get_msg_width(), pause_handle_input(), and pause_tutorial_draw_contents().

◆ get_msg_width()

s32 get_msg_width ( s32 msgID,
u16 charset )

Definition at line 1971 of file msg.c.

1971 {
1972 s32 width;
1973
1974 get_msg_properties(msgID, NULL, &width, NULL, NULL, NULL, NULL, charset);
1975 return width;
1976}

◆ get_msg_lines()

s32 get_msg_lines ( s32 msgID)

Definition at line 1979 of file msg.c.

1979 {
1980 s32 numLines;
1981
1982 get_msg_properties(msgID, NULL, NULL, NULL, &numLines, NULL, NULL, 0);
1983 return numLines;
1984}

Referenced by btl_menu_moves_show_error(), btl_message_popup_draw_content(), btl_show_message_popup(), btl_submenu_moves_update(), draw_content_pickup_item_header(), draw_merlee_message(), draw_merlee_message_string(), func_800F4C1C(), func_801363A0(), and popup_menu_update().

◆ draw_msg()

void draw_msg ( s32 msgID,
s32 posX,
s32 posY,
s32 opacity,
s32 palette,
u8 style )

Definition at line 1987 of file msg.c.

1987 {
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}
@ 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
void appendGfx_message(MessagePrintState *, s16, s16, u16, u16, u16, u8)
Definition msg_draw.c:213

◆ draw_digit()

void draw_digit ( IMG_PTR img,
s32 charset,
s32 posX,
s32 posY )

Definition at line 2203 of file msg.c.

2203 {
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}
MessageNumber gMsgNumbers[]
Definition msg.c:129

Referenced by draw_number().

◆ draw_number()

void draw_number ( s32 value,
s32 x,
s32 y,
s32 charset,
s32 palette,
s32 opacity,
u16 style )

Definition at line 2223 of file msg.c.

2223 {
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}
@ 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_CHAR_MINUS
Definition enums.h:5869
void draw_digit(IMG_PTR img, s32 charset, s32 posX, s32 posY)
Definition msg.c:2203
Gfx gMsgDlistInitDrawNumber[]
Definition msg.c:165
#define PM_CC_01
Definition macros.h:276

Referenced by btl_menu_moves_draw_content(), coin_counter_draw_content(), draw_shop_items(), filemenu_draw_contents_file_info(), filemenu_draw_contents_file_title(), filemenu_info_draw_message_contents(), filemenu_yesno_draw_prompt_contents(), func_800F4D28(), pause_badges_draw_contents(), pause_partners_draw_movelist(), pause_stats_draw_contents(), popup_menu_draw_menu_contents(), and popup_menu_draw_title_contents().

Variable Documentation

◆ D_8014C280

Vp D_8014C280
Initial value:
= {
.vp = {
.vscale = {640, 480, 511, 0},
.vtrans = {640, 480, 511, 0},
}
}

Definition at line 34 of file msg.c.

34 {
35 .vp = {
36 .vscale = {640, 480, 511, 0},
37 .vtrans = {640, 480, 511, 0},
38 }
39};

Referenced by render_messages().

◆ MessagePlural

u8 MessagePlural[] = { MSG_CHAR_LOWER_S, MSG_CHAR_READ_END }

Definition at line 42 of file msg.c.

@ MSG_CHAR_LOWER_S
Definition enums.h:5939

Referenced by shop_owner_buy_dialog(), and shop_owner_continue_speech_with_quantity().

◆ MessageSingular

◆ gNextMessageBuffer

s16 gNextMessageBuffer = 0

Definition at line 62 of file msg.c.

Referenced by load_message_to_buffer().

◆ gRewindArrowQuad

Vtx gRewindArrowQuad[]
Initial value:
= {
{{{ -16, 9, 0 }, 0, { 0x000, 0x000 }, { 255, 255, 255, 255 }}},
{{{ 16, 9, 0 }, 0, { 0x400, 0x000 }, { 255, 255, 255, 255 }}},
{{{ -16, -9, 0 }, 0, { 0x000, 0x240 }, { 255, 255, 255, 255 }}},
{{{ 16, -9, 0 }, 0, { 0x400, 0x240 }, { 255, 255, 255, 255 }}},
}

Definition at line 64 of file msg.c.

64 {
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};

Referenced by msg_update_rewind_arrow().

◆ D_8014C2D8

Gfx D_8014C2D8[]
Initial value:
= {
gsDPSetCycleType(G_CYC_2CYCLE),
gsSPClearGeometryMode(G_CULL_BOTH | G_LIGHTING),
gsSPSetGeometryMode(G_SHADE | G_SHADING_SMOOTH),
gsDPSetColorDither(G_CD_DISABLE),
gsDPSetAlphaDither(G_AD_DISABLE),
gsDPSetAlphaCompare(G_AC_NONE),
gsSPTexture(-1, -1, 0, G_TX_RENDERTILE, G_ON),
gsDPSetTexturePersp(G_TP_PERSP),
gsDPSetTextureLUT(G_TT_NONE),
gsDPSetTextureFilter(G_TF_AVERAGE),
gsDPSetRenderMode(IM_RD | CVG_DST_SAVE | ZMODE_XLU | FORCE_BL | G_RM_PASS, IM_RD | CVG_DST_SAVE | ZMODE_XLU |
FORCE_BL | GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)),
gsDPSetCombineMode(PM_CC_MSG_UP_ARROW, G_CC_PASS2),
gsSPEndDisplayList(),
}
#define PM_CC_MSG_UP_ARROW
Definition macros.h:297

Definition at line 71 of file msg.c.

71 {
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};

Referenced by msg_update_rewind_arrow().

◆ gMsgBGScrollAmtX

s32 gMsgBGScrollAmtX

Definition at line 88 of file msg.c.

Referenced by clear_printers(), msg_draw_frame(), and update_messages().

◆ gMsgGlobalWaveCounter

u16 gMsgGlobalWaveCounter

Definition at line 89 of file msg.c.

Referenced by appendGfx_message(), clear_printers(), and update_messages().

◆ gMsgVarImages

MessageImageDataList gMsgVarImages

Definition at line 90 of file msg.c.

Referenced by set_message_images().

◆ gMsgBGScrollAmtY

s32 gMsgBGScrollAmtY

Definition at line 91 of file msg.c.

Referenced by clear_printers(), msg_draw_frame(), and update_messages().

◆ D_8015131C

u8* D_8015131C

Definition at line 92 of file msg.c.

Referenced by appendGfx_message(), and msg_copy_to_print_buffer().

◆ D_80151338

Gfx* D_80151338

Definition at line 93 of file msg.c.

Referenced by appendGfx_message(), and clear_printers().

◆ D_80159B50

IMG_BIN D_80159B50[0x200]

Definition at line 104 of file msg.c.

Referenced by appendGfx_message(), and msg_copy_to_print_buffer().

◆ D_8015C7E0

PAL_BIN D_8015C7E0[0x10]

Definition at line 105 of file msg.c.

Referenced by appendGfx_message(), and msg_copy_to_print_buffer().

◆ MsgStyleVerticalLineOffsets

s16 MsgStyleVerticalLineOffsets[]
extern

Definition at line 927 of file msg_data.c.

927 {
928 [MSG_STYLE_NONE] 0,
929 [MSG_STYLE_RIGHT] -4,
930 [MSG_STYLE_LEFT] -4,
931 [MSG_STYLE_CENTER] -4,
932 [MSG_STYLE_TATTLE] -4,
935 [MSG_STYLE_SIGN] -4,
938 [MSG_STYLE_POPUP] 0,
939 [MSG_STYLE_B] 0,
943 [MSG_STYLE_F] 0,
944};
@ MSG_STYLE_NONE
Definition enums.h:6196

Referenced by msg_copy_to_print_buffer().

◆ ui_msg_rewind_arrow_png

IMG_BIN ui_msg_rewind_arrow_png[]
extern

Referenced by msg_draw_rewind_arrow().

◆ ui_msg_rewind_arrow_pal

PAL_BIN ui_msg_rewind_arrow_pal[]
extern

Referenced by msg_draw_rewind_arrow().

◆ ui_msg_star_png

IMG_BIN ui_msg_star_png[]
extern

Referenced by msg_update_rewind_arrow().

◆ ui_msg_star_silhouette_png

IMG_BIN ui_msg_star_silhouette_png[]
extern

Referenced by msg_update_rewind_arrow().

◆ MsgCharImgTitle

IMG_BIN MsgCharImgTitle[]
extern

Definition at line 90 of file msg_img.c.

Referenced by load_font().

◆ MsgCharImgNormal

IMG_BIN MsgCharImgNormal[]
extern

Definition at line 91 of file msg_img.c.

Referenced by load_font().

◆ MsgCharsets

MessageCharset* MsgCharsets[5]
extern

Definition at line 865 of file msg_data.c.

865 {
868#if VERSION_JP
869 [MSG_FONT_2] &MsgCharsetMenu2,
870#else
872#endif
875 NULL
876};
@ MSG_FONT_MENU
Definition enums.h:6216
@ MSG_FONT_TITLE
Definition enums.h:6218
@ MSG_FONT_2
Definition enums.h:6217
@ MSG_FONT_NORMAL
Definition enums.h:6215
@ MSG_FONT_SUBTITLE
Definition enums.h:6219
MessageCharset MsgCharsetTitle
Definition msg_data.c:849
MessageCharset MsgCharsetNormal
Definition msg_data.c:794
MessageCharset MsgCharsetSubtitle
Definition msg_data.c:857
MessageCharset MsgCharsetMenu
Definition msg_data.c:802

Referenced by get_msg_properties(), msg_copy_to_print_buffer(), msg_get_draw_char_width(), and msg_get_print_char_width().

◆ MsgCharImgSubtitle

IMG_BIN MsgCharImgSubtitle[]
extern

Definition at line 92 of file msg_img.c.

Referenced by load_font().

◆ D_802F4560

PAL_BIN D_802F4560[80][8]
extern

Referenced by draw_number(), and load_font().

◆ ui_point_right_png

IMG_BIN ui_point_right_png[]
extern

Referenced by msg_draw_choice_pointer().

◆ ui_point_right_pal

PAL_BIN ui_point_right_pal[]
extern

Referenced by msg_draw_choice_pointer().

◆ gMsgNumbers

MessageNumber gMsgNumbers[]

Definition at line 129 of file msg.c.

129 {
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};

Referenced by draw_digit(), and draw_number().

◆ gMsgDlistInitDrawNumber

Gfx gMsgDlistInitDrawNumber[]
Initial value:
= {
gsDPPipeSync(),
gsDPSetCycleType(G_CYC_1CYCLE),
gsDPSetTextureFilter(G_TF_POINT),
gsDPSetTexturePersp(G_TP_NONE),
gsDPSetColorDither(G_CD_DISABLE),
gsDPSetAlphaDither(G_AD_DISABLE),
gsDPSetCombineKey(G_CK_NONE),
gsDPSetAlphaCompare(G_AC_NONE),
gsDPSetTextureLUT(G_TT_RGBA16),
gsSPTexture(-1, -1, 0, G_TX_RENDERTILE, G_ON),
gsSPEndDisplayList(),
}

Definition at line 165 of file msg.c.

165 {
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};

Referenced by draw_number().

◆ gItemIconRasterOffsets

s32 gItemIconRasterOffsets[]
extern

◆ gItemIconPaletteOffsets

s32 gItemIconPaletteOffsets[]
extern

◆ MsgLetterRasterOffsets

IMG_PTR MsgLetterRasterOffsets[]
extern

Definition at line 878 of file msg_data.c.

878 {
891};
unsigned char charset_letter_content_3_OFFSET[]
unsigned char charset_letter_content_9_OFFSET[]
unsigned char charset_letter_content_8_OFFSET[]
unsigned char charset_letter_content_7_OFFSET[]
unsigned char charset_letter_content_4_OFFSET[]
unsigned char charset_letter_content_6_OFFSET[]
unsigned char charset_letter_content_11_OFFSET[]
unsigned char charset_letter_content_5_OFFSET[]
unsigned char charset_letter_content_10_OFFSET[]
unsigned char charset_letter_content_2_OFFSET[]
unsigned char charset_letter_content_1_OFFSET[]
unsigned char charset_letter_content_12_OFFSET[]

Referenced by msg_copy_to_print_buffer().

◆ MsgLetterPaletteOffsets

PAL_PTR MsgLetterPaletteOffsets[]
extern

Definition at line 893 of file msg_data.c.

893 {
906};
unsigned short charset_letter_content_2_pal_OFFSET[]
unsigned short charset_letter_content_12_pal_OFFSET[]
unsigned short charset_letter_content_5_pal_OFFSET[]
unsigned short charset_letter_content_10_pal_OFFSET[]
unsigned short charset_letter_content_4_pal_OFFSET[]
unsigned short charset_letter_content_11_pal_OFFSET[]
unsigned short charset_letter_content_7_pal_OFFSET[]
unsigned short charset_letter_content_1_pal_OFFSET[]
unsigned short charset_letter_content_6_pal_OFFSET[]
unsigned short charset_letter_content_3_pal_OFFSET[]
unsigned short charset_letter_content_8_pal_OFFSET[]
unsigned short charset_letter_content_9_pal_OFFSET[]

Referenced by msg_copy_to_print_buffer().

◆ MsgVoices

MsgVoice MsgVoices[]
extern

Definition at line 908 of file msg_data.c.

908 {
910 .voiceA = SOUND_MSG_VOICE_1A,
911 .voiceB = SOUND_MSG_VOICE_1B,
912 .pitchShift = 0
913 },
915 .voiceA = SOUND_MSG_VOICE_4A,
916 .voiceB = SOUND_MSG_VOICE_4B,
917 .pitchShift = -50
918 },
920 .voiceA = SOUND_MSG_VOICE_STAR,
921 .voiceB = SOUND_MSG_VOICE_STAR,
922 .pitchShift = 0
923 },
924};
@ MSG_VOICE_STAR
Definition enums.h:6225
@ MSG_VOICE_NORMAL
Definition enums.h:6223
@ MSG_VOICE_BOWSER
Definition enums.h:6224
@ SOUND_MSG_VOICE_4A
Definition enums.h:568
@ SOUND_MSG_VOICE_4B
Definition enums.h:569
@ SOUND_MSG_VOICE_STAR
Definition enums.h:572