msg_copy_to_print_buffer (#962)

* wip

* wip

* update_camera_mode_unused

* PR comment

* fix warning

* wip

* wip

* msg_copy_to_print_buffer

* PR comments
This commit is contained in:
Ethan Roseman 2023-03-03 10:42:48 +09:00 committed by GitHub
parent fff7fa2e99
commit 209457a32a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 279 additions and 1434 deletions

View File

@ -1192,7 +1192,7 @@ typedef struct ItemEntity {
typedef struct MessagePrintState {
/* 0x000 */ u8* srcBuffer;
/* 0x004 */ s16 printBufferPos;
/* 0x004 */ u16 printBufferPos;
/* 0x006 */ char unk_06[2];
/* 0x008 */ s32 msgID;
/* 0x00C */ u16 srcBufferPos;
@ -1204,13 +1204,13 @@ typedef struct MessagePrintState {
/* 0x455 */ u8 fontVariant;
/* 0x456 */ Vec2s windowOffsetPos; // offset from baseWindowPos. used to animated window pos?
/* 0x45A */ Vec2s windowBasePos; // ex: set by the parameters for choice style
/* 0x45E */ s8 printDelayTime; // delay to print each chunk
/* 0x45E */ u8 printDelayTime; // delay to print each chunk
/* 0x45F */ u8 charsPerChunk; // how many chars to print at once
/* 0x460 */ s32 curLinePos; // position along current line
/* 0x464 */ u8 unk_464;
/* 0x465 */ char unk_465;
/* 0x466 */ u16 nextLinePos; // ?
/* 0x468 */ s8 lineCount;
/* 0x468 */ u8 lineCount;
/* 0x469 */ char unk_469[0x3];
/* 0x46C */ s32 unk_46C;
/* 0x470 */ u8 currentAnimFrame[4];
@ -1260,7 +1260,7 @@ typedef struct MessagePrintState {
/* 0x51E */ char unk_51E[0x2];
/* 0x520 */ s32 speedSoundIDA;
/* 0x524 */ s32 speedSoundIDB;
/* 0x528 */ s16 varBufferReadPos;
/* 0x528 */ u16 varBufferReadPos;
/* 0x52A */ s8 unk_52A;
/* 0x52B */ u8 currentImageIndex;
/* 0x52C */ Vec2su varImageScreenPos; // in addition, posX=0 is taken as 'dont draw'

View File

@ -667,6 +667,7 @@ enum SoundIDs {
SOUND_MENU_CHANGE_TAB = 0x000000C8,
SOUND_MENU_NEXT = 0x000000C9,
SOUND_MENU_BACK = 0x000000CA,
SOUND_CB = 0x000000CB,
SOUND_CC = 0x000000CC,
SOUND_CD = 0x000000CD,
SOUND_CE = 0x000000CE,
@ -6580,12 +6581,15 @@ enum MsgStateFlags {
MSG_STATE_FLAG_80 = 0x000080,
MSG_STATE_FLAG_PRINT_QUICKLY = 0x000100,
MSG_STATE_FLAG_400 = 0x000400,
MSG_STATE_FLAG_800 = 0x000800,
MSG_STATE_FLAG_1000 = 0x001000,
MSG_STATE_FLAG_4000 = 0x004000,
MSG_STATE_FLAG_8000 = 0x008000,
MSG_STATE_FLAG_10000 = 0x010000,
MSG_STATE_FLAG_20000 = 0x020000,
MSG_STATE_FLAG_40000 = 0x040000,
MSG_STATE_FLAG_80000 = 0x080000,
MSG_STATE_FLAG_100000 = 0x100000,
MSG_STATE_FLAG_800000 = 0x800000,
};

View File

@ -2087,8 +2087,72 @@ ApiStatus RunPartTo(Evt* script, s32 isInitialCall) {
}
}
#ifdef NON_MATCHING
f32 update_lerp_battle(s32 easing, f32 start, f32 end, s32 elapsed, s32 duration) {
s32 timeLeft;
f32 absMag;
f64 start2;
f64 start3;
f32 len;
f64 len2;
f32 len3;
f64 len4;
f32 t1;
switch (easing) {
case EASING_LINEAR:
return start + (end - start) * elapsed / duration;
case EASING_QUADRATIC_IN:
return start + SQ(elapsed) * (end - start) / SQ(duration);
case EASING_CUBIC_IN:
return start + CUBE(elapsed) * (end - start) / CUBE(duration);
case EASING_QUARTIC_IN:
return start + QUART(elapsed) * (end - start) / QUART(duration);
case EASING_COS_SLOW_OVERSHOOT:
len = (end - start);
return end - (len * cos_rad(((f32)elapsed / duration) * PI_D * 4.0) * (duration - elapsed) *
(duration - elapsed)) / SQ((f32)duration);
case EASING_COS_FAST_OVERSHOOT:
len = (end - start);
return end - (len * cos_rad((((f32)SQ(elapsed) / duration) * PI_D * 4.0) / 15.0) * (duration - elapsed) *
(duration - elapsed)) / SQ((f32)duration);
case EASING_QUADRATIC_OUT:
timeLeft = duration - elapsed;
return start + (end - start) - ((SQ(timeLeft) * (end - start))) / SQ(duration);
case EASING_CUBIC_OUT:
len = end - start;
timeLeft = duration - elapsed;
return start + len - ((CUBE(timeLeft) * len)) / CUBE(duration);
case EASING_QUARTIC_OUT:
len = end - start;
timeLeft = duration - elapsed;
return start + len - ((QUART(timeLeft) * len)) / QUART(duration);
case EASING_COS_BOUNCE:
absMag = cos_rad((((f32)SQ(elapsed) / duration) * PI_D * 4.0) / 40.0) * (duration - elapsed) *
(duration - elapsed) / SQ((f32)duration);
if (absMag < 0.0f) {
absMag = -absMag;
}
return end - (end - start) * absMag;
case EASING_COS_IN_OUT:
len2 = end - start;
start2 = start;
return start2 + (len2 * (1.0 - cos_rad(((f32)elapsed * PI_D) / (f32)duration)) / 2);
case EASING_SIN_OUT:
len3 = end - start;
return start + (len3 * sin_rad((((f32) elapsed) * (3.141592 / 2)) / ((f32) duration)));
case EASING_COS_IN:
len4 = end - start;
start3 = start;
return start3 + (len4 * (1.0 - cos_rad(((f32)elapsed * (PI_D / 2)) / (f32)duration)));
}
return 0.0f;
}
#else
f32 update_lerp_battle(s32 easing, f32 start, f32 end, s32 elapsed, s32 duration);
INCLUDE_ASM(s32, "1A5830", update_lerp_battle);
#endif
ApiStatus FlyToGoal(Evt* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;

View File

@ -39,8 +39,8 @@ void update_camera_mode_4(Camera* camera) {
camera->trueRotation.x = camera->unk_70;
camera->currentBoomLength = camera->lookAt_dist * D_8009A5EC;
camera->currentYOffset = camera->auxBoomPitch * D_8009A5EC;
if (camera->unk_06 != 0) {
camera->unk_06 = 0;
if (camera->unk_06) {
camera->unk_06 = FALSE;
camera->unk_98 = 0.0f;
camera->unk_9C = 0.0f;
camera->lookAt_obj.x = camera->lookAt_obj_target.x;

View File

@ -1783,6 +1783,7 @@ s32 test_item_player_collision(ItemEntity* item) {
f32 playerZ;
f32 sp10;
f32 new_var2;
f32 sp14;
f32 sp1C;
f32 sp20;
@ -1794,7 +1795,6 @@ s32 test_item_player_collision(ItemEntity* item) {
s32 cond;
f32 f1;
actionState = playerStatus->actionState;
if (item->flags & ITEM_ENTITY_FLAG_100) {
@ -1818,11 +1818,12 @@ s32 test_item_player_collision(ItemEntity* item) {
return FALSE;
}
if (item->flags & ITEM_ENTITY_FLAG_HIDDEN) {
cond = item->flags;
if (cond & ITEM_ENTITY_FLAG_HIDDEN) {
return FALSE;
}
if (get_time_freeze_mode() != 0) {
if (get_time_freeze_mode() != TIME_FREEZE_NORMAL) {
return FALSE;
}
@ -1834,7 +1835,7 @@ s32 test_item_player_collision(ItemEntity* item) {
return FALSE;
}
if (gOverrideFlags & GLOBAL_OVERRIDES_200000) {
if (gOverrideFlags & GLOBAL_OVERRIDES_CANT_PICK_UP_ITEMS) {
return FALSE;
}
@ -1850,6 +1851,8 @@ s32 test_item_player_collision(ItemEntity* item) {
} else {
temp_f14 = clamp_angle(camera->currentYaw + 90.0f);
}
new_var2 = playerY;
sp10 = playerX;
sp24 = playerY;
sp14 = playerZ;
@ -1868,12 +1871,12 @@ s32 test_item_player_collision(ItemEntity* item) {
itemX = item->position.x;
itemY = item->position.y;
itemZ = item->position.z;
t = 13.5f;
xDiff = itemX - playerX;
zDiff = itemZ - playerZ;
t = 13.5f;
f1 = sqrtf(SQ(xDiff) + SQ(zDiff));
if (!(sp20 + t <= f1) &&
!(itemY + 27.0f < playerY) &&
!(itemY + 27.0f < new_var2) &&
!(playerY + sp1C < itemY))
{
cond = TRUE;
@ -1885,7 +1888,7 @@ s32 test_item_player_collision(ItemEntity* item) {
f1 = sqrtf(SQ(xDiff) + SQ(zDiff));
if (!(14.0f + t <= f1) &&
!(itemY + 27.0f < sp24) &&
!(sp24 + 18.0f < itemY))
!(playerY + 18.0f < itemY))
{
cond = TRUE;
}

263
src/msg.c
View File

@ -2,6 +2,8 @@
#include "ld_addrs.h"
#include "message_ids.h"
#include "sprite.h"
#include "charset/postcard.png.h"
#include "charset/letter_content_1.png.h"
enum RewindArrowStates {
REWIND_ARROW_STATE_INIT = 0,
@ -53,7 +55,7 @@ Gfx D_8014C2D8[] = {
};
// unsorted
extern s32 D_8015131C;
extern u8* D_8015131C;
extern MessageDrawState D_80155D20;
extern IMG_BIN D_80159B50[];
extern PAL_BIN D_8015C7E0[];
@ -414,14 +416,14 @@ s32 _update_message(MessagePrintState* printer) {
case MSG_WINDOW_STATE_SCROLLING_BACK:
printer->scrollingTime++;
if (printer->scrollingTime >= 5) {
printer->windowState = 7;
printer->windowState = MSG_WINDOW_STATE_WAITING_FOR_CHOICE;
printer->currentOption = printer->targetOption;
printer->selectedOption = printer->currentOption;
}
break;
}
} else if (!(printer->stateFlags & MSG_STATE_FLAG_20) &&
printer->windowState == 5 &&
printer->windowState == MSG_WINDOW_STATE_WAITING &&
(gGameStatusPtr->pressedButtons[0] & BUTTON_A))
{
printer->windowState = MSG_WINDOW_STATE_PRINTING;
@ -647,10 +649,13 @@ void msg_play_speech_sound(MessagePrintState* printer, u8 character) {
}
}
#ifdef NON_EQUIVALENT
extern s32 gItemIconRasterOffsets[];
extern s32 gItemIconPaletteOffsets[];
extern s32 D_802EB5C0[];
extern s32 D_802EB5F0[];
extern struct_D_802EB620 D_802EB620[];
void msg_copy_to_print_buffer(MessagePrintState* printer, s32 arg1, s32 arg2) {
u8 style;
u8 postcard;
u8 arg;
u8 argQ;
u8 argW;
@ -660,9 +665,9 @@ void msg_copy_to_print_buffer(MessagePrintState* printer, s32 arg1, s32 arg2) {
s16 offset;
s32 i;
u8* romAddr;
u8* romEnd;
s32 temp;
s32 romEnd;
s32 t;
void* a2;
s8 s8 = arg2 & 1;
u8* printBuf = &printer->printBuffer[printer->printBufferPos];
u8* srcBuf = &printer->srcBuffer[printer->srcBufferPos];
@ -676,22 +681,21 @@ void msg_copy_to_print_buffer(MessagePrintState* printer, s32 arg1, s32 arg2) {
printer->lineCount += (u8)printer->sizeScale;
break;
case MSG_CHAR_READ_WAIT:
printer->windowState = 5;
printer->windowState = 5;
printer->delayFlags |= 1;
printer->windowState = MSG_WINDOW_STATE_WAITING;
printer->delayFlags |= MSG_DELAY_FLAG_1;
printer->delayFlags &= ~2;
printer->rewindArrowAnimState = REWIND_ARROW_STATE_INIT;
printer->rewindArrowBlinkCounter = 0;
printer->stateFlags &= ~0x80;
printer->stateFlags &= ~0x100;
if (printer->style != 0xF) {
printer->rewindArrowCounter = 0;
printer->stateFlags &= ~MSG_STATE_FLAG_80;
printer->stateFlags &= ~MSG_STATE_FLAG_PRINT_QUICKLY;
if (printer->style != MSG_STYLE_F) {
sfx_play_sound_with_params(SOUND_CB, 0, 0, 0);
}
break;
case MSG_CHAR_READ_PAUSE:
printer->currentPrintDelay = *srcBuf++;
printer->delayFlags |= 1;
printer->stateFlags &= ~0x80;
printer->delayFlags |= MSG_DELAY_FLAG_1;
printer->stateFlags &= ~MSG_STATE_FLAG_80;
break;
case MSG_CHAR_READ_VARIANT0:
case MSG_CHAR_READ_VARIANT1:
@ -719,8 +723,8 @@ void msg_copy_to_print_buffer(MessagePrintState* printer, s32 arg1, s32 arg2) {
printer->currentLine++;
*printBuf++ = MSG_CHAR_PRINT_NEXT;
printer->nextLinePos = printer->curLinePos + (gMsgCharsets[printer->font]->newLineY + D_802EB644[printer->style]) * printer->lineCount;
printer->windowState = 6;
printer->delayFlags |= 1;
printer->windowState = MSG_WINDOW_STATE_SCROLLING;
printer->delayFlags |= MSG_DELAY_FLAG_1;
}
printer->lineCount = 0;
break;
@ -738,22 +742,24 @@ void msg_copy_to_print_buffer(MessagePrintState* printer, s32 arg1, s32 arg2) {
if (arg == MSG_STYLE_RIGHT || arg == MSG_STYLE_LEFT || arg == MSG_STYLE_CENTER) {
printer->maxLinesPerPage = 3;
}
printer->delayFlags |= 1;
printer->stateFlags |= 0x800800;
if (nextArg != 0xC3) {
printer->stateFlags |= 0x80;
printer->delayFlags |= MSG_DELAY_FLAG_1;
printer->stateFlags |= MSG_STATE_FLAG_800000 | MSG_STATE_FLAG_800;
if (nextArg != MSG_CHAR_UNK_C3) {
printer->stateFlags |= MSG_STATE_FLAG_80;
}
printer->speedSoundIDA = SOUND_11;
printer->speedSoundIDB = SOUND_12;
printer->windowState = 2;
printer->windowState = MSG_WINDOW_STATE_OPENING;
break;
case MSG_STYLE_CHOICE:
printer->windowBasePos.x = *srcBuf++;
printer->windowBasePos.y = *srcBuf++;
printer->windowSize.x = *srcBuf++;
printer->windowSize.y = *srcBuf++;
printer->windowState = 2;
printer->stateFlags |= 0x800;
do {
printer->windowBasePos.x = *srcBuf++;
printer->windowBasePos.y = *srcBuf++;
printer->windowSize.x = *srcBuf++;
printer->windowSize.y = *srcBuf++;
printer->windowState = MSG_WINDOW_STATE_OPENING;
printer->stateFlags |= MSG_STATE_FLAG_800;
} while (0);
break;
case MSG_STYLE_INSPECT:
case MSG_STYLE_NARRATE:
@ -763,9 +769,9 @@ void msg_copy_to_print_buffer(MessagePrintState* printer, s32 arg1, s32 arg2) {
printer->windowBasePos.y = 28;
printer->windowSize.y = 58;
printer->windowSize.x = 280;
printer->windowState = 2;
printer->stateFlags |= 0x800;
printer->delayFlags |= 1;
printer->windowState = MSG_WINDOW_STATE_OPENING;
printer->stateFlags |= MSG_STATE_FLAG_800;
printer->delayFlags |= MSG_DELAY_FLAG_1;
if (arg == MSG_STYLE_INSPECT) {
sfx_play_sound_with_params(SOUND_21C, 0, 0, 0);
}
@ -777,76 +783,80 @@ void msg_copy_to_print_buffer(MessagePrintState* printer, s32 arg1, s32 arg2) {
printer->windowSize.x = *srcBuf++;
printer->windowSize.y = *srcBuf++;
sfx_play_sound_with_params(SOUND_21C, 0, 0, 0);
printer->windowState = 2;
printer->delayFlags |= 1;
printer->stateFlags |= 0x800;
printer->windowState = MSG_WINDOW_STATE_OPENING;
printer->delayFlags |= MSG_DELAY_FLAG_1;
printer->stateFlags |= MSG_STATE_FLAG_800;
break;
case MSG_STYLE_LAMPPOST:
printer->windowSize.y = *srcBuf++;
/* fallthrough */
case MSG_STYLE_SIGN:
if (!s8) {
printer->windowState = 2;
printer->stateFlags |= 0x800;
printer->delayFlags |= 1;
}
do {
if (!s8) {
printer->windowState = MSG_WINDOW_STATE_OPENING;
printer->stateFlags |= MSG_STATE_FLAG_800;
printer->delayFlags |= MSG_DELAY_FLAG_1;
}
} while (0);
break;
case MSG_STYLE_POSTCARD:
arg = *srcBuf++;
printer->windowState = 2;
printer->stateFlags |= 0x800;
printer->delayFlags |= 1;
printer->letterBackgroundImg = heap_malloc(7875);
romAddr = charset_standard_OFFSET + (s32)(&D_0000B290);
dma_copy(romAddr, romAddr + 7875, printer->letterBackgroundImg);
printer->windowState = MSG_WINDOW_STATE_OPENING;
printer->stateFlags |= MSG_STATE_FLAG_800;
printer->delayFlags |= MSG_DELAY_FLAG_1;
printer->letterBackgroundImg = heap_malloc(((charset_postcard_png_width * charset_postcard_png_height) / 2));
romAddr = charset_ROM_START + (s32)charset_postcard_OFFSET;
dma_copy(romAddr, romAddr + ((charset_postcard_png_width * charset_postcard_png_height) / 2), printer->letterBackgroundImg);
printer->letterBackgroundPal = heap_malloc(0x20);
romAddr = charset_standard_OFFSET + (s32)(&D_0000D158);
romAddr = charset_ROM_START + ((s32)charset_postcard_pal_OFFSET + 5);
dma_copy(romAddr, romAddr + 0x20, printer->letterBackgroundPal);
printer->letterContentImg = heap_malloc(0x19FA);
romAddr = charset_standard_OFFSET + (s32)(D_802EB5C0[arg]);
dma_copy(romAddr, romAddr + 0x19FA, printer->letterContentImg);
printer->letterContentImg = heap_malloc(charset_letter_content_1_png_width * charset_letter_content_1_png_height);
romAddr = charset_ROM_START + D_802EB5C0[arg];
dma_copy(romAddr, romAddr + (charset_letter_content_1_png_width * charset_letter_content_1_png_height), printer->letterContentImg);
printer->letterContentPal = heap_malloc(0x200);
romAddr = charset_standard_OFFSET + (s32)(D_802EB5F0[arg]);
romAddr = charset_ROM_START + D_802EB5F0[arg];
dma_copy(romAddr, romAddr + 0x200, printer->letterContentPal);
break;
case MSG_STYLE_POPUP:
case MSG_STYLE_B:
printer->windowSize.x = printer->msgWidth + 32;
printer->windowSize.y = 40;
printer->stateFlags |= 0x8000;
if (!s8) {
printer->stateFlags |= 0x8800;
printer->windowState = 0xD;
printer->delayFlags |= 1;
}
printer->stateFlags |= MSG_STATE_FLAG_8000;
do {
if (!s8) {
printer->stateFlags |= MSG_STATE_FLAG_8000 | MSG_STATE_FLAG_800;
printer->windowState = MSG_WINDOW_STATE_D;
printer->delayFlags |= MSG_DELAY_FLAG_1;
}
} while (0);
break;
case MSG_STYLE_EPILOGUE:
printer->windowState = 4;
printer->windowState = MSG_WINDOW_STATE_PRINTING;
break;
}
if ((printer->delayFlags & 1) && (printer->delayFlags & 6)) {
printer->delayFlags &= ~1;
if ((printer->delayFlags & MSG_DELAY_FLAG_1) && (printer->delayFlags & (MSG_DELAY_FLAG_4 | MSG_DELAY_FLAG_2))) {
printer->delayFlags &= ~MSG_DELAY_FLAG_1;
}
break;
case MSG_CHAR_READ_END:
*printBuf++ = MSG_CHAR_PRINT_END;
if (printer->stateFlags & 0x800) {
if (printer->stateFlags & 0x1000) {
if (printer->stateFlags & MSG_STATE_FLAG_800) {
if (printer->stateFlags & MSG_STATE_FLAG_1000) {
if (printer->closedWritebackBool != NULL) {
*printer->closedWritebackBool = TRUE;
}
}
if (printer->style != MSG_STYLE_POPUP && printer->style != MSG_STYLE_B) {
printer->windowState = 3;
printer->windowState = MSG_WINDOW_STATE_CLOSING;
} else {
printer->windowState = 0xE;
printer->windowState = MSG_WINDOW_STATE_E;
}
printer->fadeOutCounter = 0;
} else {
printer->stateFlags |= 1;
printer->stateFlags |= MSG_STATE_FLAG_1;
}
printer->delayFlags |= 1;
printer->delayFlags &= ~2;
printer->delayFlags |= MSG_DELAY_FLAG_1;
printer->delayFlags &= ~MSG_DELAY_FLAG_2;
break;
case MSG_CHAR_READ_FUNCTION:
switch (*srcBuf++) {
@ -866,14 +876,14 @@ void msg_copy_to_print_buffer(MessagePrintState* printer, s32 arg1, s32 arg2) {
*printBuf++ = *srcBuf++;
break;
case MSG_READ_FUNC_NO_SKIP:
printer->stateFlags |= 0x10;
printer->stateFlags |= MSG_STATE_FLAG_10;
break;
case MSG_READ_FUNC_INPUT_OFF:
printer->stateFlags |= 0x20;
printer->stateFlags &= ~0x100;
printer->stateFlags |= MSG_STATE_FLAG_20;
printer->stateFlags &= ~MSG_STATE_FLAG_PRINT_QUICKLY;
break;
case MSG_READ_FUNC_INPUT_ON:
printer->stateFlags &= ~0x20;
printer->stateFlags &= ~MSG_STATE_FLAG_20;
break;
case MSG_READ_FUNC_SPACING:
*printBuf++ = MSG_CHAR_PRINT_FUNCTION;
@ -881,11 +891,11 @@ void msg_copy_to_print_buffer(MessagePrintState* printer, s32 arg1, s32 arg2) {
*printBuf++ = *srcBuf++;
break;
case MSG_READ_FUNC_DELAY_OFF:
printer->delayFlags |= 2;
printer->delayFlags |= MSG_DELAY_FLAG_2;
break;
case MSG_READ_FUNC_DELAY_ON:
printer->delayFlags &= ~2;
printer->delayFlags |= 1;
printer->delayFlags &= ~MSG_DELAY_FLAG_2;
printer->delayFlags |= MSG_DELAY_FLAG_1;
break;
case MSG_READ_FUNC_SCROLL:
printer->lineEndPos[printer->currentLine] = printer->curLinePos;
@ -893,8 +903,8 @@ void msg_copy_to_print_buffer(MessagePrintState* printer, s32 arg1, s32 arg2) {
*printBuf++ = MSG_CHAR_PRINT_NEXT;
arg = *srcBuf++;
printer->nextLinePos = printer->curLinePos + (gMsgCharsets[printer->font]->newLineY + D_802EB644[printer->style]) * arg;
printer->windowState = 6;
printer->delayFlags |= 1;
printer->windowState = MSG_WINDOW_STATE_SCROLLING;
printer->delayFlags |= MSG_DELAY_FLAG_1;
printer->lineCount = 0;
break;
case MSG_READ_FUNC_SIZE:
@ -944,12 +954,12 @@ void msg_copy_to_print_buffer(MessagePrintState* printer, s32 arg1, s32 arg2) {
*printBuf++ = MSG_PRINT_FUNC_INLINE_IMAGE;
*printBuf++ = *srcBuf++;
arg1--;
printer->currentPrintDelay = (u8)printer->printDelayTime;
printer->currentPrintDelay = printer->printDelayTime;
if (arg1 <= 0) {
printer->delayFlags |= 1;
printer->delayFlags |= MSG_DELAY_FLAG_1;
}
if (printer->delayFlags & 6) {
printer->delayFlags &= ~1;
if (printer->delayFlags & (MSG_DELAY_FLAG_4 | MSG_DELAY_FLAG_2)) {
printer->delayFlags &= ~MSG_DELAY_FLAG_1;
}
break;
case MSG_READ_FUNC_ANIM_SPRITE:
@ -958,12 +968,12 @@ void msg_copy_to_print_buffer(MessagePrintState* printer, s32 arg1, s32 arg2) {
*printBuf++ = *srcBuf++;
*printBuf++ = *srcBuf++;
*printBuf++ = *srcBuf++;
printer->currentPrintDelay = (u8)printer->printDelayTime;
printer->currentPrintDelay = printer->printDelayTime;
if (--arg1 <= 0) {
printer->delayFlags |= 1;
printer->delayFlags |= MSG_DELAY_FLAG_1;
}
if (printer->delayFlags & 6) {
printer->delayFlags &= ~1;
if (printer->delayFlags & (MSG_DELAY_FLAG_4 | MSG_DELAY_FLAG_2)) {
printer->delayFlags &= ~MSG_DELAY_FLAG_1;
}
break;
case MSG_READ_FUNC_ITEM_ICON:
@ -972,18 +982,21 @@ void msg_copy_to_print_buffer(MessagePrintState* printer, s32 arg1, s32 arg2) {
arg = *srcBuf++;
argQ = *srcBuf++;
a2 = D_80159B50;
offset = arg << 8 | argQ;
D_8015131C = D_80159B50;
dma_copy(icon_present_ROM_START + gItemIconRasterOffsets[offset], icon_present_ROM_START + gItemIconRasterOffsets[offset] + 0x200, D_80159B50);
dma_copy(icon_present_ROM_START + gItemIconRasterOffsets[offset], icon_present_ROM_START + gItemIconRasterOffsets[offset] + 0x200, a2);
romEnd = icon_present_ROM_START + gItemIconPaletteOffsets[offset] + 0x20;
dma_copy(icon_present_ROM_START + gItemIconPaletteOffsets[offset], romEnd, D_8015C7E0);
dma_copy(icon_present_ROM_START + gItemIconPaletteOffsets[offset],
romEnd, D_8015C7E0);
printer->currentPrintDelay = printer->printDelayTime;
if (--arg1 <= 0) {
printer->delayFlags |= 1;
printer->delayFlags |= MSG_DELAY_FLAG_1;
}
if (printer->delayFlags & 6) {
printer->delayFlags &= ~1;
if (printer->delayFlags & (MSG_DELAY_FLAG_4 | MSG_DELAY_FLAG_2)) {
printer->delayFlags &= ~MSG_DELAY_FLAG_1;
}
break;
case MSG_READ_FUNC_IMAGE:
@ -998,10 +1011,10 @@ void msg_copy_to_print_buffer(MessagePrintState* printer, s32 arg1, s32 arg2) {
printer->varImageDisplayState = 0;
printer->varImageFadeTimer = 0;
if (--arg1 <= 0) {
printer->delayFlags |= 1;
printer->delayFlags |= MSG_DELAY_FLAG_1;
}
if (printer->delayFlags & 6) {
printer->delayFlags &= ~1;
if (printer->delayFlags & (MSG_DELAY_FLAG_4 | MSG_DELAY_FLAG_2)) {
printer->delayFlags &= ~MSG_DELAY_FLAG_1;
}
break;
case MSG_READ_FUNC_HIDE_IMAGE:
@ -1020,7 +1033,7 @@ void msg_copy_to_print_buffer(MessagePrintState* printer, s32 arg1, s32 arg2) {
*printBuf++ = *srcBuf++;
*printBuf++ = *srcBuf++;
*printBuf++ = *srcBuf++;
printer->delayFlags |= 4;
printer->delayFlags |= MSG_DELAY_FLAG_4;
break;
case MSG_READ_FUNC_ANIM_LOOP:
*printBuf++ = MSG_CHAR_PRINT_FUNCTION;
@ -1032,9 +1045,9 @@ void msg_copy_to_print_buffer(MessagePrintState* printer, s32 arg1, s32 arg2) {
*printBuf++ = MSG_CHAR_PRINT_FUNCTION;
*printBuf++ = MSG_PRINT_FUNC_ANIM_DONE;
*printBuf++ = *srcBuf++;
printer->delayFlags &= ~4;
printer->delayFlags &= ~MSG_DELAY_FLAG_4;
if (--arg1 <= 0) {
printer->delayFlags |= 1;
printer->delayFlags |= MSG_DELAY_FLAG_1;
}
break;
case MSG_READ_FUNC_SET_CURSOR:
@ -1056,8 +1069,8 @@ void msg_copy_to_print_buffer(MessagePrintState* printer, s32 arg1, s32 arg2) {
printer->madeChoice = 0;
printer->currentOption = 0;
printer->selectedOption = 0;
printer->windowState = 7;
printer->delayFlags |= 1;
printer->windowState = MSG_WINDOW_STATE_WAITING_FOR_CHOICE;
printer->delayFlags |= MSG_DELAY_FLAG_1;
break;
case MSG_READ_FUNC_SET_CANCEL:
printer->cancelOption = *srcBuf++;
@ -1072,10 +1085,10 @@ void msg_copy_to_print_buffer(MessagePrintState* printer, s32 arg1, s32 arg2) {
*printBuf++ = MSG_PRINT_RESET_GFX;
break;
case MSG_READ_FUNC_YIELD:
printer->stateFlags |= 0x100040;
printer->delayFlags |= 1;
printer->stateFlags &= ~0x80;
printer->stateFlags &= ~0x100;
printer->stateFlags |= MSG_STATE_FLAG_100000 | MSG_STATE_FLAG_40;
printer->delayFlags |= MSG_DELAY_FLAG_1;
printer->stateFlags &= ~MSG_STATE_FLAG_80;
printer->stateFlags &= ~MSG_STATE_FLAG_PRINT_QUICKLY;
break;
case MSG_READ_FUNC_SAVE_POS:
*printBuf++ = MSG_CHAR_PRINT_FUNCTION;
@ -1131,10 +1144,13 @@ void msg_copy_to_print_buffer(MessagePrintState* printer, s32 arg1, s32 arg2) {
printer->unk_52A = printer->fontVariant;
*printBuf++ = MSG_CHAR_PRINT_VARIANT0;
}
do {
s32 a0 = 1;
argQ = gMessageMsgVars[arg][printer->varBufferReadPos++];
if (argQ >= MSG_CONTROL_CHAR) {
s32 tmp;
switch (argQ) {
case MSG_CHAR_READ_ENDL:
if (gMessageMsgVars[arg][printer->varBufferReadPos] != MSG_CHAR_READ_END) {
@ -1180,6 +1196,7 @@ void msg_copy_to_print_buffer(MessagePrintState* printer, s32 arg1, s32 arg2) {
arg1--;
*printBuf++ = sp10[i];
}
if (gMessageMsgVars[arg][printer->varBufferReadPos] == MSG_CHAR_READ_END) {
srcBuf += 3;
printer->varBufferReadPos = 0;
@ -1187,14 +1204,15 @@ void msg_copy_to_print_buffer(MessagePrintState* printer, s32 arg1, s32 arg2) {
*printBuf++ = MSG_CHAR_PRINT_VARIANT0 + printer->fontVariant;
break;
}
} while ((printer->delayFlags & 6) || arg1 > 0);
if (!(printer->delayFlags & 6) && arg1 <= 0) {
printer->delayFlags |= 1;
} while ((printer->delayFlags & (MSG_DELAY_FLAG_4 | MSG_DELAY_FLAG_2)) || arg1 > 0);
if (!(printer->delayFlags & (MSG_DELAY_FLAG_4 | MSG_DELAY_FLAG_2)) && arg1 <= 0) {
printer->delayFlags |= MSG_DELAY_FLAG_1;
printer->currentPrintDelay = printer->printDelayTime;
}
msg_play_speech_sound(printer, c);
if (printer->stateFlags & 0x800000) {
printer->stateFlags |= 0x80;
msg_play_speech_sound(printer, argQ);
if (printer->stateFlags & MSG_STATE_FLAG_800000) {
printer->stateFlags |= MSG_STATE_FLAG_80;
}
break;
case MSG_READ_FUNC_VOICE:
@ -1226,54 +1244,51 @@ void msg_copy_to_print_buffer(MessagePrintState* printer, s32 arg1, s32 arg2) {
break;
case MSG_READ_FUNC_SET_REWIND:
if (*srcBuf++) {
printer->stateFlags |= 0x40000;
printer->stateFlags |= MSG_STATE_FLAG_40000;
} else {
printer->stateFlags &= ~0x40000;
printer->stateFlags &= ~MSG_STATE_FLAG_40000;
}
break;
case MSG_READ_FUNC_ENABLE_CDOWN_NEXT:
printer->stateFlags |= 0x80000;
printer->stateFlags |= MSG_STATE_FLAG_80000;
break;
}
break;
default:
*printBuf++ = c;
arg1--;
if (printer->fontVariant == 0 && c == 0xC3) {
printer->stateFlags &= ~0x80;
if (printer->fontVariant == 0 && c == MSG_CHAR_UNK_C3) {
printer->stateFlags &= ~MSG_STATE_FLAG_80;
} else {
msg_play_speech_sound(printer, c);
if (printer->stateFlags & 0x800000) {
printer->stateFlags |= 0x80;
if (printer->stateFlags & MSG_STATE_FLAG_800000) {
printer->stateFlags |= MSG_STATE_FLAG_80;
}
}
break;
}
if (!(printer->delayFlags & 6) && arg1 <= 0) {
printer->delayFlags |= 1;
printer->currentPrintDelay = (u8)printer->printDelayTime;
if (!(printer->delayFlags & (MSG_DELAY_FLAG_4 | MSG_DELAY_FLAG_2)) && arg1 <= 0) {
printer->delayFlags |= MSG_DELAY_FLAG_1;
printer->currentPrintDelay = printer->printDelayTime;
}
if (!(printer->delayFlags & 1)) {
if (!(printer->delayFlags & MSG_DELAY_FLAG_1)) {
continue;
}
if (!s8) {
break;
}
arg1 = 10000;
if (srcBuf[-1] == MSG_CHAR_READ_END) {
break;
}
arg1 = 10000;
} while (TRUE);
printer->printBufferPos = printBuf - printer->printBuffer;
printer->delayFlags = 0;
printer->srcBufferPos = srcBuf - (s32)printer->srcBuffer;
printer->srcBufferPos = (u16)(s32)(srcBuf - (s32)printer->srcBuffer);
*printBuf = MSG_CHAR_PRINT_END;
}
#else
INCLUDE_ASM(s32, "msg", msg_copy_to_print_buffer);
#endif
void initialize_printer(MessagePrintState* printer, s32 arg1, s32 arg2) {
s32 i;

View File

@ -51,7 +51,7 @@ API_CALLABLE(N(FireBarAI_Main)) {
data->settings = settings;
}
if (get_time_freeze_mode() != 0) {
if (get_time_freeze_mode() != TIME_FREEZE_NORMAL) {
return 0;
}

File diff suppressed because it is too large Load Diff