1#pragma helper_mask_gpr 0x30
2#pragma helper_mask_fpr 0x1000
3#pragma name_counter 821
25s16 NameRegistTbl[8][11];
34 {0, -2, 0, 0, 0, 128},
37 {-2, 0, 0, 0, 0, 128},
59} __attribute__((aligned(16)));
61STATIC_ASSERT(
sizeof(
GIFTAG) == 0x10);
65 if (code >= -0x300 && code < -0x251) {
67 if (code >= -0x300 && code < -0x263) {
87 return width * gaiji->
width;
104 for (
int i = 0; i < 11; i++) {
105 if ((u16) name[i] == 0) {
125 for (
int i = 0; i < 11; i++) {
130 int code = NameRegistCodeJtoE(name[i] - 1);
133 if (code >= -0x300 && code < -0x250) {
135 if (code >= -0x300 && code < -0x262) {
149 sceVif1PkCnt(packet, 0);
150 sceVif1PkOpenDirectCode(packet, 0);
151 sceVif1PkOpenGifTag(packet, *(u_long128 *) &GiftagAD);
152 sceVif1PkAddGsAD(packet, 0x14, 0x61);
153 sceVif1PkAddGsAD(packet, 0, 0x1D6);
157 sceVif1PkAddGsAD(packet, 0x4E, *(
unsigned long *) &depth);
158 sceVif1PkAddGsAD(packet, 1, (
unsigned long) r | (
unsigned long) g << 8 | (
unsigned long) b << 16 | (
unsigned long) a << 24 | (
unsigned long) *(u32 *) &one << 32);
159 sceVif1PkAddGsAD(packet, 6, *(
unsigned long *) &texture->
tex0);
160 sceVif1PkAddGsAD(packet, 3, (
unsigned long) (dst.
x << 4) | (
unsigned long) (dst.
y << 4) << 16);
161 sceVif1PkAddGsAD(packet, 4, (
unsigned long) ((src.
x << 4) + 0x6C00) | (
unsigned long) ((src.
y << 3) + GS_Y_OFFSET) << 16);
162 sceVif1PkAddGsAD(packet, 3, (
unsigned long) ((dst.
x + dst.
width) << 4) | (
unsigned long) ((dst.
y + dst.
height) << 4) << 16);
163 sceVif1PkAddGsAD(packet, 4, (
unsigned long) (((src.
x + src.
width) << 4) + 0x6BFF) | (
unsigned long) (((src.
y + src.
height) << 3) + GS_Y_OFFSET) << 16);
164 sceVif1PkCloseGifTag(packet);
165 sceVif1PkCloseDirectCode(packet);
169 GetScrPosFromChar(first, out_pos);
170 GetScrPosFromChar(second, &out_pos[2]);
174 RECT candidate[3][3];
176 float clearance[3][3];
204 for (row = 0; row < 3; row++) {
205 for (col = 0; col < 3; col++) {
206 candidate[row][col].
height = height;
209 candidate[row][col].
x = 0;
211 candidate[row][col].
x = col * (0x260 - width) >> 1;
212 candidate[row][col].
x += 0x10;
216 candidate[row][col].
y = 0;
218 candidate[row][col].
y = row * (0x1A0 - height) >> 1;
219 candidate[row][col].
y += 0x10;
222 if (col == 0 || col == 2) {
223 candidate[row][col].
width = width + 0x10;
225 candidate[row][col].
width = width;
228 if (row == 0 || row == 2) {
229 candidate[row][col].
height = height + 0x10;
231 candidate[row][col].
height = height;
239 if (this->
auto_pos == MES_POS_AUTO) {
240 for (row = 0; row < 3; row++) {
241 for (col = 0; col < 3; col++) {
242 RECT *rect = &candidate[row][col];
244 outside[row][col] = CheckPosInOutForRect(rect, speaker_x, speaker_y);
246 if (outside[row][col] == 0) {
247 outside[row][col] = CheckPosInOutForRect(rect, other_x, other_y);
252 for (row = 0; row < 3; row++) {
253 for (col = 0; col < 3; col++) {
254 if (outside[row][col] != 0) {
255 clearance[row][col] = -1.0f;
258 RECT *rect = &candidate[row][col];
260 clearance[row][col] = GetDisPosToRect(rect, speaker_x, speaker_y);
262 float other_clearance = GetDisPosToRect(rect, other_x, other_y);
264 if (other_clearance < clearance[row][col]) {
265 clearance[row][col] = other_clearance;
270 float best_clearance = 0.0f;
272 for (row = 0; row < 3; row++) {
273 for (col = 0; col < 3; col++) {
274 if (clearance[row][col] >= 0.0f && best_clearance < clearance[row][col]) {
277 best_clearance = clearance[row][col];
282 best_col = (this->
auto_pos - 1) % 3;
283 best_row = (this->
auto_pos - 1) / 3;
286 this->
win_x = candidate[best_row][best_col].
x;
287 this->
win_y = candidate[best_row][best_col].
y;
321 if (this->tail_to_x <= this->
win_x + (
int) (this->
win_width >> 2)) {
340 if (this->
win_x < 0x10) {
356 if (this->
win_y < 0x10) {
370 this->
columns = MES_WIN_COLUMNS;
377 this->unk_02C = 0x10;
382 this->
grow_y = SCREEN_HALF_HEIGHT;
415 this->
style = MES_EDGE_DOUBLE;
424 for (
int i = 0; i < 10; i++) {
428 for (
int i = 0; i < 8; i++) {
443 for (
int i = 0; i < 10; i++) {
453 this->
clut = MesWinClut;
458 this->
text = (
char *) this->buff;
459 this->
text += (u16) this->buff[1];
470 case MES_PRESET_SYSTEM:
476 this->style = MES_EDGE_BLACK;
481 case MES_PRESET_FUKIDASHI:
485 this->style = MES_EDGE_WHITE;
490 case MES_PRESET_AUTO_PAGE:
491 this->style = MES_EDGE_NONE;
496 case MES_PRESET_NAME:
502 this->style = MES_EDGE_TABLE;
506 case MES_PRESET_NONE:
513 case MES_FUKIDASHI_LARGE_BLACK_EDGE:
521 this->style = MES_EDGE_BLACK;
524 case MES_FUKIDASHI_LARGE_TABLE_EDGE:
532 this->style = MES_EDGE_TABLE;
535 case MES_FUKIDASHI_SMALL_FRAMED:
543 this->style = MES_EDGE_BLACK;
546 case MES_FUKIDASHI_SMALL_DOUBLE_EDGE:
554 this->style = MES_EDGE_DOUBLE;
557 case MES_FUKIDASHI_NO_BUBBLE:
569 this->style = MES_EDGE_NONE;
582 if (this->
fade < 1.0f) {
586 if (1.0f < this->
fade) {
590 if (0.0f < this->
fade) {
594 if (this->
fade < 0.0f) {
616 RollPos(centre, left, angle, left_out);
622 RollPos(centre, right, angle, right_out);
628 float length = sqrt(dx * dx + dy * dy);
638 if (this->
fade <= 0.0f) {
639 return CLSMES_CLOSED;
642 if (0.0f < this->
fade && this->
fade < 1.0f) {
643 return this->
fade_in != 0 ? CLSMES_FADE_IN : CLSMES_FADE_OUT;
647 return CLSMES_PAGE_WAIT;
654 return CLSMES_REVEALING;
681 if (code >= 0x1000) {
686 case MES_CODE_NEWLINE:
707 if ((code >= -0x700 && code <= -0x601) || (code >= -0x800 && code <= -0x701) || (code >= -0x900 && code < -0x800)) {
726 if (this->
wait > 0) {
743 if (made == 1 || made == 2) {
764short *SetAndGetNameRegistTbl(
int chara) {
773 for (
int i = 0; i < 11; i++) {
774 NameRegistTbl[chara][i] = MES_CODE_NEWLINE;
779 for (
int i = 0; i < 11; i++) {
781 NameRegistTbl[chara][i] = MES_CODE_NEWLINE;
783 NameRegistTbl[chara][i] = NameRegistCodeJtoE(name[i] - 1);
787 return NameRegistTbl[chara];
803 int len = strlen(
text);
805 for (
int i = 0; i < len; i++) {
807 char digit =
text[i];
884 int len = strlen(
text);
886 for (
int i = 0; i < len; i++) {
888 char digit =
text[i];
956 if (code >= -0x500 && code < -0x400) {
997 }
else if (code == 0xFD) {
999 }
else if (code == 0xFC) {
1001 }
else if (code == 0xFB) {
1003 }
else if (code == 0xF2) {
1005 }
else if (code == 0xF1) {
1007 }
else if (code == 0xF0) {
1009 }
else if (code == 0xEF) {
1011 }
else if (code == 0xEE) {
1013 }
else if (code == 0xED) {
1034 if (text_code >= -0x506 && text_code < -0x500) {
1035 short *name = SetAndGetNameRegistTbl(text_code + 0x506);
1038 int name_code = *name;
1040 while (name_code != MES_CODE_NEWLINE && name_code != MES_CODE_END) {
1048 switch (text_code) {
1052 case MES_CODE_SPACE:
1063 case MES_CODE_NEWLINE:
1071 if (text_code >= -0x300 && text_code < -0x250) {
1074 if (text_code >= -0x300 && text_code < -0x262) {
1132 no = this->mes_no[0];
1133 }
else if (no == 0xFD) {
1134 no = this->mes_no[1];
1135 }
else if (no == 0xFC) {
1136 no = this->mes_no[2];
1137 }
else if (no == 0xFB) {
1138 no = this->mes_no[3];
1139 }
else if (no == 0xF2) {
1140 no = this->mes_no[4];
1141 }
else if (no == 0xF1) {
1142 no = this->mes_no[5];
1143 }
else if (no == 0xF0) {
1144 no = this->mes_no[6];
1145 }
else if (no == 0xEF) {
1146 no = this->mes_no[7];
1147 }
else if (no == 0xEE) {
1148 no = this->mes_no[8];
1149 }
else if (no == 0xED) {
1150 no = this->mes_no[9];
1166 int len[2] = {0, 0};
1172 if (code >= -0x506 && code < -0x500) {
1178 case MES_CODE_NEWLINE:
1182 if (len[0] > len[1]) {
1204 int width[2] = {0, 0};
1210 if (code >= -0x506 && code < -0x500) {
1216 case MES_CODE_NEWLINE:
1220 if (width[0] > width[1]) {
1228 if (code >= -0x300 && code < -0x250) {
1230 if (code >= -0x300 && code < -0x262) {
1240 int count = this->
buff[0];
1241 short *body = &this->
buff[1];
1243 for (
int i = 0; i < count; i++) {
1244 if (line == body[i * 2 + 1]) {
1245 return &body[count] + body[i * 2 + 2];
1256 for (
int i = 0; i < count; i++) {
1257 if (line == body[i * 2 + 1]) {
1258 return &body[count] + body[i * 2 + 2];
1266 for (
int i = 0; i < MES_WIN_LINE_MAX; i++) {
1278 if (code >= -0x200 && code <= -0x101) {
1286 if (code >= -0x400 && code <= -0x301) {
1287 if (code + 0x400 == 0) {
1289 }
else if (code == -0x301) {
1298 if (code >= -0xA00 && code <= -0x901) {
1329 case MES_CODE_NEWLINE:
1333 return (width - used) / spaces;
1337 case MES_CODE_SPACE:
1343 if (code >= -0x300 && code < -0x250) {
1345 if (code >= -0x300 && code < -0x262) {
1348 }
else if (code >= -0x700 && code < -0x600) {
1349 used += code + 0x700;
1351 used += glyph_width;
1362 if (this->
buff == 0) {
1381 if (code == MES_CODE_PAGE || code == MES_CODE_NEWLINE || code == MES_CODE_END) {
1391 case MES_CODE_NEWLINE:
1403 case MES_CODE_SPACE:
1416 if (code >= -0x300 && code < -0x250) {
1419 if (code >= -0x300 && code < -0x262) {
1423 }
else if (code >= -0x900 && code < -0x800) {
1426 }
else if (code >= -0x800 && code < -0x700) {
1428 }
else if (code >= -0x700 && code < -0x600) {
1430 }
else if (code >= -0x506 && code < -0x500) {
1431 short *name = SetAndGetNameRegistTbl(code + 0x506);
1434 int name_code = *name;
1436 while (name_code != MES_CODE_NEWLINE && name_code != MES_CODE_END) {
1443 }
else if (code == -0x401) {
1445 }
else if (code >= -0x40D && code < -0x405) {
1458void NeedMesWinWH_sub(
int *len,
int *max_len,
int *width,
int *max_width,
int char_width,
int count) {
1465 if (*max_len < *len) {
1471 if (*max_width < *width) {
1472 *max_width = *width;
1489 if (this->
buff == 0) {
1500 max_lines = &out[1];
1501 max_width = &out[2];
1502 max_height = &out[3];
1519 if (code == MES_CODE_PAGE || code == MES_CODE_NEWLINE || code == MES_CODE_END) {
1528 case MES_CODE_SPACE:
1531 if (*max_len < len) {
1541 if (*max_width < width) {
1547 case MES_CODE_NEWLINE:
1551 if (*max_lines < lines) {
1558 if (*max_height < height) {
1559 *max_height = height;
1572 if (code >= -0x200 && code <= -0x101) {
1574 }
else if (code >= -0x400 && code <= -0x301) {
1576 }
else if (code >= -0xA00 && code <= -0x901) {
1578 }
else if (code >= -0x900 && code < -0x800) {
1581 }
else if (code >= -0x800 && code < -0x700) {
1583 }
else if (code >= -0x700 && code < -0x600) {
1586 if (*max_len < len) {
1590 width += code + 0x700;
1592 if (*max_width < width) {
1595 }
else if (code == -0x401) {
1606 NeedMesWinWH_sub(&len, max_len, &width, max_width, (this->char_width >> 2) * 3, strlen(
text) - 1);
1608 NeedMesWinWH_sub(&len, max_len, &width, max_width, this->char_width, strlen(
text) - 1);
1611 }
else if (code >= -0x40D && code < -0x405) {
1616 sprintf(
text,
"+%d\n", this->
values[-0x406 - code]);
1618 sprintf(
text,
"%d\n", this->
values[-0x406 - code]);
1622 NeedMesWinWH_sub(&len, max_len, &width, max_width, (this->char_width >> 2) * 3, strlen(
text) - 1);
1624 NeedMesWinWH_sub(&len, max_len, &width, max_width, this->char_width, strlen(
text) - 1);
1627 }
else if (code == -0x405 || code == -0x404 || code == -0x403 || code == -0x402 || code == -0x411 || code == -0x410 || code == -0x40F || code == -0x40E) {
1628 NeedMesWinWH_sub(&len, max_len, &width, max_width, this->char_width, this->
GetMesLen_system(code));
1629 }
else if (code >= -0x506 && code < -0x500) {
1630 NeedMesWinWH_sub(&len, max_len, &width, max_width, this->char_width, this->
GetNameLen(code + 0x506));
1632 }
else if (code >= -0x300 && code < -0x251) {
1634 }
else if (code >= -0x300 && code < -0x263) {
1639 if (*max_len < len) {
1643 if (*max_width < width) {
1647 NeedMesWinWH_sub(&len, max_len, &width, max_width, this->char_width, 1);
1655void MakeRandTbl(
float lo,
float hi) {
1656 for (
int i = 0; i < 64; i++) {
1657 RandTbl[i] = ((hi - lo) * (
float) rand()) / 2147483648.0f;
1662void MakeRandTbl2(
float lo,
float hi) {
1663 for (
int i = 0; i < 64; i++) {
1664 RandTbl2[i] = ((hi - lo) * (
float) rand()) / 2147483648.0f;
1688 MakeRandTbl(0.0f, 4.0f);
1690 MakeRandTbl(2.0f, 6.0f);
1692 MakeRandTbl(6.8f, 15.2f);
1693 MakeRandTbl2(0.42f, 0.58f);
1723 this->
win_width = this->char_width * 10;
1725 this->
win_width = this->char_width * 14;
1749 switch (this->
style) {
1750 case MES_EDGE_WHITE:
1751 set2DSprite_Core(packet, texture,
CRect_i_(x + 1, y + 1, width, height),
CRect_i_(u, v, u_width, v_height), 0xFF, 0xFF, 0xFF, this->edge_alpha < 0x40 ? this->
edge_alpha : 0x40);
1753 case MES_EDGE_BLACK:
1754 set2DSprite_Core(packet, texture,
CRect_i_(x + 1, y + 1, width, height),
CRect_i_(u, v, u_width, v_height), 0, 0, 0, this->edge_alpha < 0x40 ? this->
edge_alpha : 0x40);
1756 case MES_EDGE_TABLE:
1757 for (
int i = 0; FuchiTbl_E[i].
alpha > 0; i++) {
1758 set2DSprite_Core(packet, texture,
CRect_i_(x + FuchiTbl_E[i].x, y + FuchiTbl_E[i].y, width, height),
CRect_i_(u, v, u_width, v_height), FuchiTbl_E[i].r, FuchiTbl_E[i].g, FuchiTbl_E[i].b, this->
edge_alpha < FuchiTbl_E[i].alpha ? this->
edge_alpha : FuchiTbl_E[i].
alpha);
1762 case MES_EDGE_DOUBLE:
1763 set2DSprite_Core(packet, texture,
CRect_i_(x + 1, y + 1, width, height),
CRect_i_(u, v, u_width, v_height), 0x40, 0x40, 0x40, this->edge_alpha < 0x80 ? this->
edge_alpha : 0x80);
1764 set2DSprite_Core(packet, texture,
CRect_i_(x + 2, y + 2, width, height),
CRect_i_(u, v, u_width, v_height), 0, 0, 0, this->edge_alpha < 0x80 ? this->
edge_alpha : 0x80);
1769void DrawMaru(
sceVif1Packet *packet,
int x,
int y,
int width,
int height,
int lift,
int unused,
int rough,
int prim) {
1777 sceVif1PkAddGsAD(packet, 0, ((
unsigned long) prim << 7) | 0x145);
1778 sceVif1PkAddGsAD(packet, 1, 0x80BFBFBF | ((
unsigned long) 1 << 32));
1780 px = x + (width >> 1);
1781 py = y + (height >> 1) - lift;
1783 sceVif1PkAddGsAD(packet, 4, (
unsigned long) ((px << 4) + 0x6C00) | (
unsigned long) ((py << 4) + GS_Y_OFFSET) << 16);
1788 while (turn < 128.0f) {
1789 float angle = TWO_PI * turn / 128.0f;
1791 across = cosf(angle);
1794 if (rough == 1 && step % 2 == 1) {
1811 sceVif1PkAddGsAD(packet, 4, (
unsigned long) ((px << 4) + 0x6C00) | (
unsigned long) ((py << 4) + GS_Y_OFFSET) << 16);
1814 turn += RandTbl[step];
1825 if (rough == 1 && step % 2 == 1) {
1842 sceVif1PkAddGsAD(packet, 4, (
unsigned long) ((px << 4) + 0x6C00) | (
unsigned long) ((py << 4) + GS_Y_OFFSET) << 16);
1845#pragma opt_propagation off
1858 if (this->
grow_y < top) {
1885 float shape[15][2] = {
1904 sceVif1PkAddGsAD(packet, 0, ((
unsigned long) prim << 7) | 0x145);
1905 sceVif1PkAddGsAD(packet, 1, 0x80BFBFBF | ((
unsigned long) 1 << 32));
1907 int base_x = (int) LinerInterpolation(this->
grow_x, this->
win_x, this->fade);
1908 int base_y = (int) LinerInterpolation(this->
grow_y, this->
win_y, this->fade);
1910 mirror = (int) RandTbl[0];
1912 for (i = 0; i < 15; i++) {
1913 if (mirror % 2 != 0) {
1914 x = (int) (grown_width * (1.0f - shape[i][0]));
1916 x = (int) (grown_width * shape[i][0]);
1920 y = (int) (grown_height * (1.0f - shape[i][1]));
1922 y = (int) (grown_height * shape[i][1]);
1929 sceVif1PkAddGsAD(packet, 4, (
unsigned long) ((x << 4) + 0x6C00) | (
unsigned long) ((y << 4) + GS_Y_OFFSET) << 16);
1932 x = (int) LinerInterpolation(this->
grow_x, this->
win_x, this->fade);
1933 y = (int) LinerInterpolation(this->
grow_y, this->
win_y, this->fade);
1937 if (bubble_shape == 1) {
1938 DrawMaru(packet, x, y, (
int) grown_width, (
int) grown_height, top, 0x20, bubble_shape, prim);
1940 int upper_width = (int) grown_width - this->char_width;
1941 int half_height = (int) grown_height >> 1;
1942 float half_height_float = (float) half_height;
1944 DrawMaru(packet, x, y, upper_width, (
int) (half_height_float + 1.5f * this->
char_height), top, 0x20, 0, prim);
1949 y = (int) (y + half_height - pad);
1950 DrawMaru(packet, x + indent, y, (
int) grown_width - indent, (
int) (half_height + pad), top, 0x20, 0, prim);
1953 x = (int) LinerInterpolation(this->
grow_x, this->
win_x, this->fade);
1954 y = (int) LinerInterpolation(this->
grow_y, this->
win_y, this->fade);
1956 sceVif1PkAddGsAD(packet, 0, ((
unsigned long) prim << 7) | 0x145);
1957 sceVif1PkAddGsAD(packet, 1, 0x80BFBFBF | ((
unsigned long) 1 << 32));
1959 int oval_width = (int) grown_width;
1960 int oval_height = (int) grown_height;
1964 px = x + (oval_width >> 1);
1965 py = y + (oval_height >> 1) - top;
1967 sceVif1PkAddGsAD(packet, 4, (
unsigned long) ((px << 4) + 0x6C00) | (
unsigned long) ((py << 4) + GS_Y_OFFSET) << 16);
1974 while (turn < 128.0f) {
1975 float angle = TWO_PI * turn / 128.0f;
1977 across = cosf(angle);
1980 across = across * RandTbl2[step];
1981 down = down * RandTbl2[step];
1984 across = across * oval_width;
1985 down = down * oval_height;
1993 sceVif1PkAddGsAD(packet, 4, (
unsigned long) ((px << 4) + 0x6C00) | (
unsigned long) ((py << 4) + GS_Y_OFFSET) << 16);
1995 turn += RandTbl[step];
2002 across = across * RandTbl2[0];
2003 down = down * RandTbl2[0];
2006 across = across * oval_width;
2007 down = down * oval_height;
2015 sceVif1PkAddGsAD(packet, 4, (
unsigned long) ((px << 4) + 0x6C00) | (
unsigned long) ((py << 4) + GS_Y_OFFSET) << 16);
2022 DrawMaru(packet, x - 10, y - 10, 20, 20, top, 0x20, 0, prim);
2026 DrawMaru(packet, x - 5, y - 5, 10, 10, top, 0x20, 0, prim);
2028 sceVif1PkAddGsAD(packet, 0, ((
unsigned long) prim << 7) | 0x143);
2029 sceVif1PkAddGsAD(packet, 1, 0x80BFBFBF | ((
unsigned long) 1 << 32));
2034 sceVif1PkAddGsAD(packet, 4, (
unsigned long) ((x << 4) + 0x6C00) | (
unsigned long) ((y << 4) + GS_Y_OFFSET) << 16);
2039 sceVif1PkAddGsAD(packet, 4, (
unsigned long) ((x << 4) + 0x6C00) | (
unsigned long) ((y << 4) + GS_Y_OFFSET) << 16);
2044 sceVif1PkAddGsAD(packet, 4, (
unsigned long) ((x << 4) + 0x6C00) | (
unsigned long) ((y << 4) + GS_Y_OFFSET) << 16);
2049#pragma opt_propagation reset
2060 MGGetFBuffTex(&frame);
2062 sceVif1PkCnt(packet, 0);
2063 sceVif1PkOpenDirectCode(packet, 0);
2064 sceVif1PkOpenGifTag(packet, *(u_long128 *) &GiftagAD);
2065 sceVif1PkAddGsAD(packet, 0x3F, 0);
2067 tex0 = *(
sceGsTex0 *) &TexManager.GetTexture(
"fukidashibase", -1)->
tex0;
2069 unsigned int tbp = tex0.bits.tbp0;
2070 int tbw = tex0.bits.tbw;
2071 unsigned int psm = tex0.bits.psm;
2073 sceVif1PkAddGsAD(packet, 0x4C, (
unsigned long) (tbp >> 5) | (
unsigned long) (u32) tbw << 16 | (
unsigned long) psm << 24);
2075 sceVif1PkCloseGifTag(packet);
2076 sceVif1PkCloseDirectCode(packet);
2077 sceVif1PkTerminate(packet);
2091 MGFillBox(
CRect_i_(0, 0, 0x2800, (SCREEN_HALF_HEIGHT << 4)), 0, 0, 0, 0);
2096 sceVif1PkCnt(packet, 0);
2097 sceVif1PkOpenDirectCode(packet, 0);
2098 sceVif1PkOpenGifTag(packet, *(u_long128 *) &GiftagAD);
2101 sceVif1PkAddGsAD(packet, 0x3F, 0);
2102 sceVif1PkCloseGifTag(packet);
2103 sceVif1PkCloseDirectCode(packet);
2104 sceVif1PkTerminate(packet);
2116 texture = TexManager.GetTexture(
"fuki256", -1);
2118 for (row = 0; row < 4; row++) {
2119 for (col = 0; col < 5; col++) {
2120 Myset2DSprite(Vif1Packet, texture,
CRect_i_(col * 0x80, row * 0x80, 0x80, 0x80),
CRect_i_(0, 0, 0x80, 0x80), 0x80, 0x80, 0x80, this->edge_alpha < 0x80 ? this->
edge_alpha : 0x80);
2124 sceVif1PkCnt(packet, 0);
2125 sceVif1PkOpenDirectCode(packet, 0);
2126 sceVif1PkOpenGifTag(packet, *(u_long128 *) &GiftagAD);
2127 sceVif1PkAddGsAD(packet, 0x3F, 0);
2128 sceVif1PkAddGsAD(packet, 0x4C, (
unsigned long) (frame.bits.tbp0 >> 5) | (
unsigned long) frame.bits.tbw << 16 | (
unsigned long) frame.bits.psm << 24);
2129 sceVif1PkAddGsAD(packet, 0x47, *(
unsigned long *) &mgPixelTest);
2130 sceVif1PkAddGsAD(packet, 0x4E, *(
unsigned long *) &mgZBuffer);
2131 sceVif1PkAddGsAD(packet, 0x42, *(
unsigned long *) &mgAlpha);
2132 sceVif1PkCloseGifTag(packet);
2133 sceVif1PkCloseDirectCode(packet);
2136void SetspRGBA(
spRGBA *colour,
int r,
int g,
int b,
int a) {
2154 area[0] = this->
win_x;
2155 area[1] = this->
win_y;
2160 AreaAddPos(area, pos, area);
2165 AreaAddPos(area, pos, area);
2168 AreaAddPos(area, pos, area);
2171 AreaAddPos(area, pos, area);
2176 AreaAddPos(area, pos, area);
2179 AreaAddPos(area, pos, area);
2185 int right = area[2];
2186 int bottom = area[3];
2187 draw_width = right - left;
2188 int height = bottom - top;
2189 tex_x = (int) LinerInterpolation(this->
grow_x, left, this->
fade);
2190 tex_y = (int) LinerInterpolation(this->
grow_y, top, this->
fade);
2191 draw_width = (int) (draw_width * this->
fade);
2192 draw_height = (int) (height * this->fade);
2195 screen_x = tex_x + dx;
2211 int middle_screen_y;
2222 SetspRGBA(&bright, 0x80, 0x80, 0x80, 0x80);
2223 SetspRGBA(&dim, 0x60, 0x60, 0x60, 0x80);
2225 if (MesAbsDrawOff == 0) {
2226 set2DSprite(Vif1Packet, texture,
CRect_i_(screen_x, screen_y, draw_width, draw_height),
CRect_i_(tex_x, tex_y, draw_width, draw_height), &dim, &dim, &dim, &dim, 1);
2229 float win_left = this->
win_x;
2230 float win_top = this->
win_y;
2234 outer_x = (int) LinerInterpolation(this->
grow_x, win_left, this->fade);
2235 outer_y = (int) LinerInterpolation(this->
grow_y, win_top, this->fade);
2236 outer_w = (int) (win_w * this->fade);
2237 outer_h = (int) (win_h * this->fade);
2239 float core_left = this->
win_x + this->win_width / 6.0f;
2240 float core_top = this->
win_y + this->win_height / 6.0f;
2241 float core_width = 2.0f * this->win_width / 3.0f;
2242 float core_height = 2.0f * this->win_height / 3.0f;
2244 core_x = (int) LinerInterpolation(this->
grow_x, core_left, this->fade);
2245 core_y = (int) LinerInterpolation(this->
grow_y, core_top, this->fade);
2246 core_w = (int) (core_width * this->fade);
2247 core_h = (int) (core_height * this->fade);
2249 right_x = core_x + core_w;
2250 upper_screen_y = outer_y;
2251 core_screen_y = core_y;
2252 lower_screen_y = core_y + core_h;
2253 left_w = core_x - outer_x;
2254 right_w = outer_x + outer_w - core_x - core_w;
2255 upper_h = core_y - outer_y;
2256 lower_h = outer_y + outer_h - core_y - core_h;
2259 middle_screen_y = core_screen_y;
2260 lower_tex_y = core_y + core_h;
2261 upper_tex_h = core_y - outer_y;
2262 lower_tex_h = outer_y + outer_h - core_y - core_h;
2264 if (MesAbsDrawOff == 0) {
2265 set2DSprite(Vif1Packet, texture,
CRect_i_(outer_x, upper_screen_y, left_w, upper_h),
CRect_i_(outer_x, outer_y, left_w, upper_tex_h), &dim, &dim, &dim, &bright, 1);
2266 set2DSprite(Vif1Packet, texture,
CRect_i_(core_x, upper_screen_y, core_w, upper_h),
CRect_i_(core_x, outer_y, core_w, upper_tex_h), &dim, &dim, &bright, &bright, 1);
2267 set2DSprite(Vif1Packet, texture,
CRect_i_(right_x, upper_screen_y, right_w, upper_h),
CRect_i_(right_x, outer_y, right_w, upper_tex_h), &dim, &dim, &bright, &dim, 0);
2268 set2DSprite(Vif1Packet, texture,
CRect_i_(outer_x, middle_screen_y, left_w, core_h),
CRect_i_(outer_x, core_y, left_w, core_h), &dim, &bright, &dim, &bright, 1);
2269 set2DSprite(Vif1Packet, texture,
CRect_i_(core_x, middle_screen_y, core_w, core_h),
CRect_i_(core_x, core_y, core_w, core_h), &bright, &bright, &bright, &bright, 1);
2270 set2DSprite(Vif1Packet, texture,
CRect_i_(right_x, middle_screen_y, right_w, core_h),
CRect_i_(right_x, core_y, right_w, core_h), &bright, &dim, &bright, &dim, 1);
2271 set2DSprite(Vif1Packet, texture,
CRect_i_(outer_x, lower_screen_y, left_w, lower_h),
CRect_i_(outer_x, lower_tex_y, left_w, lower_tex_h), &dim, &bright, &dim, &dim, 0);
2272 set2DSprite(Vif1Packet, texture,
CRect_i_(core_x, lower_screen_y, core_w, lower_h),
CRect_i_(core_x, lower_tex_y, core_w, lower_tex_h), &bright, &bright, &dim, &dim, 1);
2273 set2DSprite(Vif1Packet, texture,
CRect_i_(right_x, lower_screen_y, right_w, lower_h),
CRect_i_(right_x, lower_tex_y, right_w, lower_tex_h), &bright, &dim, &dim, &dim, 1);
2275 }
else if (MesAbsDrawOff == 0) {
2276 set2DSprite(Vif1Packet, texture,
CRect_i_(screen_x, screen_y, draw_width, draw_height),
CRect_i_(tex_x, tex_y, draw_width, draw_height), 0, 0, 0, this->edge_alpha < 0x80 ? this->
edge_alpha : 0x80);
2288void MyMenuHelpWinDraw(
int x,
int y,
int width,
int height,
int shade,
int u,
int v,
CTexture *texture) {
2289 int bar_width = width < 0x20 ? 0 : width - 0x20;
2290 int bar_height = height < 0x1C ? 0 : height - 0x1C;
2295 set2DSprite(Vif1Packet, texture,
CRect_i_(x, y, 0x10, 0xE),
CRect_i_(u, v, 0x10, 0xE), alpha = (shade * 100) >> 7);
2296 set2DSprite(Vif1Packet, texture,
CRect_i_(x, y + 0xE, 0x10, bar_height),
CRect_i_(u, v + 0xE, 0x10, 0x24), alpha);
2297 set2DSprite(Vif1Packet, texture,
CRect_i_(x, bar_height + (y + 0xE), 0x10, 0xE),
CRect_i_(u, v + 0x32, 0x10, 0xE), alpha);
2298 set2DSprite(Vif1Packet, texture,
CRect_i_(x + 0x10, y, bar_width, 0xE),
CRect_i_(u + 0x10, v, 0x20, 0xE), alpha);
2299 set2DSprite(Vif1Packet, texture,
CRect_i_(x + 0x10, y + 0xE, bar_width, bar_height),
CRect_i_(u + 0x10, v + 0xE, 0x20, 0x24), alpha);
2300 set2DSprite(Vif1Packet, texture,
CRect_i_(x + 0x10, bar_height + (y + 0xE), bar_width, 0xE),
CRect_i_(u + 0x10, v + 0x32, 0x20, 0xE), alpha);
2301 set2DSprite(Vif1Packet, texture,
CRect_i_(bar_width + (x + 0x10), y, 0x10, 0xE),
CRect_i_(u + 0x30, v, 0x10, 0xE), alpha);
2302 set2DSprite(Vif1Packet, texture,
CRect_i_(bar_width + (x + 0x10), y + 0xE, 0x10, bar_height),
CRect_i_(u + 0x30, v + 0xE, 0x10, 0x24), alpha);
2303 set2DSprite(Vif1Packet, texture,
CRect_i_(bar_width + (x + 0x10), bar_height + (y + 0xE), 0x10, 0xE),
CRect_i_(u + 0x30, v + 0x32, 0x10, 0xE), alpha);
2306void GetPos_AbsPosSet(
int x,
int y,
int width,
int height,
int win_width,
int win_height,
int align,
int *out_x,
int *out_y) {
2308 case MES_POS_TOP_LEFT:
2310 case MES_POS_BOTTOM_LEFT:
2312 *out_x = x + width / 6 - (
win_width >> 1);
2319 case MES_POS_CENTRE:
2320 case MES_POS_BOTTOM:
2321 *out_x = x + (width >> 1) - (
win_width >> 1);
2323 case MES_POS_TOP_RIGHT:
2325 case MES_POS_BOTTOM_RIGHT:
2327 *out_x = x + width * 5 / 6 - (
win_width >> 1);
2336 case MES_POS_TOP_LEFT:
2338 case MES_POS_TOP_RIGHT:
2347 case MES_POS_CENTRE:
2349 *out_y = y + (height >> 1) - (
win_height >> 1);
2351 case MES_POS_BOTTOM_LEFT:
2352 case MES_POS_BOTTOM:
2353 case MES_POS_BOTTOM_RIGHT:
2355 *out_y = y + height * 5 / 6 - (
win_height >> 1);
2376 if (code >= -0x300 && code < -0x2DF) {
2377 set2DSprite_Core(Vif1Packet, texture, screen, texel, 0x80, 0x80, 0x80, this->edge_alpha < 0x80 ? this->
edge_alpha : 0x80);
2383 switch (FontColorTbl[
clut]) {
2475 set2DSprite_Core(Vif1Packet, texture, screen, texel, r, g, b, this->edge_alpha < alpha ? this->
edge_alpha : alpha);
2478 switch (this->
win_line[index].code) {
2545 switch (this->
win_line[index].code) {
2608 }
else if (this->char_width < 0xB) {
2616 set2DSprite_Core(Vif1Packet, texture, screen,
CRect_i_(u, v, 14, 20), r, g, b, this->edge_alpha < alpha ? this->
edge_alpha : alpha);
2630 TexManager.ReloadTexture(Vif1Packet, this->
tex_block);
2635 offset_x = (4 - this->
text_columns) * this->char_width >> 1;
2647 texture = TexManager.GetTexture(
"fukidashibase", -1);
2665 int width = this->char_width * this->
text_columns + 0x20;
2676 px = this->
text_x + offset_x - 0x10;
2677 py = this->
text_y + offset_y - 0xE;
2680 GetPos_AbsPosSet(0x10, 0x10, 0x260, 0x1A0, width, height, this->
auto_pos, &px, &py);
2681 this->
text_x = px - offset_x + 0x10;
2682 this->
text_y = py - offset_y + 0xE;
2685 if (MesAbsDrawOff == 0) {
2686 MyMenuHelpWinDraw(px, py, width, height, 0x80, 0, 0, TexManager.GetTexture(
"stayframe", -1));
2694 {0x8000, 0x10000000, 0xE, 0}
2697 sceVif1PkCnt(Vif1Packet, 0);
2698 sceVif1PkOpenDirectCode(Vif1Packet, 0);
2699 sceVif1PkOpenGifTag(Vif1Packet, *(u_long128 *) &tag);
2700 sceVif1PkAddGsAD(Vif1Packet, 0x3F, 0);
2701 sceVif1PkCloseGifTag(Vif1Packet);
2702 sceVif1PkCloseDirectCode(Vif1Packet);
2704 texture = TexManager.GetTexture(
"fontbase", -1);
2706 if (this->
clut == 0) {
2710 if ((this->
blink / 0x1C) % 2 != 0) {
2711 this->
clut[100] = 0x80222280;
2714 this->
clut[100] = 0x804444FF;
2718 SetClut(Vif1Packet, texture, (i *) this->
clut);
2721 texture = TexManager.GetTexture(
"gaiji", -1);
2723 set2DSprite_Start(Vif1Packet, texture);
2726 if (MesAbsDrawOff != 0) {
2733 if (code < -0x300 || code >= -0x251) {
2735 if (code < -0x300 || code >= -0x263) {
2740 int gaiji_index = code + 0x300;
2741 int u = GaijiDataTbl[gaiji_index][GAIJI_U];
2744 if (code >= -0x2DF && code < -0x251) {
2746 if (code >= -0x2DF && code < -0x263) {
2751 }
else if (this->char_width < 0xB) {
2757 int v = GaijiDataTbl[gaiji_index][GAIJI_V];
2758 int glyph_width = GaijiDataTbl[gaiji_index][GAIJI_WIDTH];
2759 int glyph_height = GaijiDataTbl[gaiji_index][GAIJI_HEIGHT];
2760 int dx = (this->char_width * GaijiDataTbl[gaiji_index][GAIJI_CELLS] - glyph_width) / 2;
2763 dx += GaijiDataTbl[gaiji_index][GAIJI_X_OFF];
2766 if (GaijiDataTbl[gaiji_index][GAIJI_CODE] == -0x2BD || GaijiDataTbl[gaiji_index][GAIJI_CODE] == -0x2BA) {
2771 dy += GaijiDataTbl[gaiji_index][GAIJI_Y_OFF];
2782 int screen_x = offset_x + (line_x + dx);
2784 screen.
x = screen_x;
2785 int screen_y = offset_y + (line_y + dy) - 3;
2786 screen.y = screen_y;
2787 screen.width = glyph_width;
2788 screen.height = glyph_height;
2789 CRect_i_ texel(u, v, glyph_width, glyph_height);
2791 if (this->
win_line[index].code >= -0x2DF) {
2792 this->
Myset2DSprite_Fuchi(Vif1Packet, texture, screen_x, screen_y, glyph_width, glyph_height, u, v, glyph_width, glyph_height);
2796 this->
DrawGaijiFont(texture, index, texel, screen, 0, dark);
2799 this->
DrawGaijiFont(texture, index, texel, screen, 1, dark);
2801 this->
DrawGaijiFont(texture, index, texel, screen, 0, dark);
2805 this->
DrawGaijiFont(texture, index, texel, screen, 0, dark);
2807 this->
DrawGaijiFont(texture, index, texel, screen, 1, dark);
2814 CRect_i_ screen(screen_x + dx, screen_y - row * this->
char_height, glyph_width, glyph_height);
2815 CRect_i_ texel(u, v, glyph_width, glyph_height);
2817 if (this->
win_line[index].code >= -0x2DF) {
2818 this->
Myset2DSprite_Fuchi(Vif1Packet, texture, screen_x + dx, screen_y - row * this->char_height, glyph_width, glyph_height, u, v, glyph_width, glyph_height);
2822 this->
DrawGaijiFont(texture, index, texel, screen, 0, dark);
2825 this->
DrawGaijiFont(texture, index, texel, screen, 1, dark);
2827 this->
DrawGaijiFont(texture, index, texel, screen, 0, dark);
2831 this->
DrawGaijiFont(texture, index, texel, screen, 0, dark);
2833 this->
DrawGaijiFont(texture, index, texel, screen, 1, dark);
2839 set2DSprite_End(Vif1Packet, texture);
2842 if (this->text_no >= this->
text_len && this->cursor_row < 0 || this->
waiting != 0) {
2843 if ((this->
blink >> 4) % 2 != 0) {
2844 texture = TexManager.GetTexture(
"syst04", -1);
2849 CRect_i_ screen(screen_x + offset_x, screen_y + offset_y, 0x10, 0x10);
2852 if (MesAbsDrawOff == 0) {
2853 set2DSprite(Vif1Packet, texture, screen, texel, this->edge_alpha < 0x80 ? this->
edge_alpha : 0x80);
2860 texture = TexManager.GetTexture(
"syst04", -1);
2865 CRect_i_ screen(screen_x + offset_x, screen_y + offset_y, 0x10, 0x10);
2868 if (MesAbsDrawOff == 0) {
2869 set2DSprite(Vif1Packet, texture, screen, texel, this->edge_alpha < 0x80 ? this->
edge_alpha : 0x80);
2874 texture = TexManager.GetTexture(
"gaiji", -1);
2878 int screen_x = this->
text_x;
2880 screen_x -= this->char_width * 2;
2882 int screen_x = this->
text_x;
2890 CRect_i_ screen(screen_x + offset_x, screen_y - 4 + offset_y, 0x20, 0x20);
2892 CRect_i_ screen(screen_x - 0xC + offset_x, screen_y - 4 + offset_y, 0x20, 0x20);
2894 CRect_i_ texel(0x60, 0x60, 0x20, 0x20);
2896 if (MesAbsDrawOff == 0) {
2897 set2DSprite(Vif1Packet, texture, screen, texel, this->edge_alpha < 0x80 ? this->
edge_alpha : 0x80);
s16 * GetCharaName(int chara_no)
void Myset2DSprite_Fuchi(sceVif1Packet *packet, CTexture *texture, int x, int y, int width, int height, int u, int v, int u_width, int v_height)
void DrawGaijiFont(CTexture *texture, int index, const CRect_i_ &texel, const CRect_i_ &screen, int wide, int dark)
void AutoSetSub(CCharacter *first, CCharacter *second, int *out_pos)
void MakeFukidashi_sub(sceVif1Packet *packet, int prim)
short * GetTextLineDataTop(int line)
int GetMesWidth_system(int mes_no)
void NeedMesWinWH(int mes_no, int *out)
int MakeMesWinTbl(int mes_no)
int GetMesLen_system(int mes_no)
int GetNameWidth(int chara)
int CalcSpaceW(int width, int glyph_width, short *text)
void MyTextureMake_InitAll()
int SetMesWinTbl(int code, int mode, short x, short y)
void DrawMesWin_sub(CTexture *texture, int dx, int dy, int frame)
MES_WIN_LINE win_line[MES_WIN_LINE_MAX]
void SetBuff(short *buff)
void MakeFukidashi(sceVif1Packet *packet)
short * GetTextLineDataTop_system(int line)
int MakeMesWinTbl_system(int code, int *x, int *y)
void SetMesFukidashi(int style)
void MakeMesTexture(int mes_no)
int GetNameLen(int chara)
MES_LINE_POS line_pos[10]
void MakeMesWinTbl_value(int *x, int *y)
int MakeMesWin(int mes_no)
void SetBuff_system(short *buff)
EDIT_GAIJI EditGaijiTbl[]
@ FONT_COLOR_BROWN_OPAQUE