1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512
| #include <ultra64.h>
#include "sm64.h"
#include "mario.h"
#include "area.h"
#include "audio/interface_2.h"
#include "behavior_actions.h"
#include "behavior_data.h"
#include "camera.h"
#include "mario_misc.h"
#include "display.h"
#include "game.h"
#include "engine/graph_node.h"
#include "interaction.h"
#include "level_update.h"
#include "memory.h"
#include "main.h"
#include "mario_actions_object.h"
#include "mario_actions_automatic.h"
#include "mario_actions_cutscene.h"
#include "mario_actions_submerged.h"
#include "mario_actions_airborne.h"
#include "mario_actions_moving.h"
#include "mario_actions_stationary.h"
#include "mario_step.h"
#include "engine/math_util.h"
#include "object_fields.h"
#include "object_helpers.h"
#include "print.h"
#include "save_file.h"
#include "sound_init.h"
#include "engine/surface_collision.h"
u32 D_80339F10;
s8 filler80339F1C[0x80339F30 - 0x80339F1C];
// Sound terrain types. See audio_defines.h.
s8 D_8032CB40[7][6] = {
{0, 3, 1, 1, 1, 0},
{3, 3, 3, 3, 1, 1},
{5, 6, 5, 6, 3, 3},
{7, 3, 7, 7, 3, 3},
{4, 4, 4, 4, 3, 3},
{0, 3, 1, 6, 3, 6},
{3, 3, 3, 3, 6, 6}
};
u8 D_8032CB7B[16] = {
0x46, 0x32, 0x32, 0x3C,
0x46, 0x50, 0x50, 0x3C,
0x28, 0x14, 0x14, 0x1E,
0x32, 0x3C, 0x3C, 0x28
};
// Equals [1000]^5 . [100]^8 . [10]^9 . [1] in binary
u64 D_8032CB80 = 0x4444449249255555;
s32 func_80250770(struct MarioState *m)
{
struct Object *o = m->marioObj;
return (o->header.gfx.unk38.animFrame + 1) == o->header.gfx.unk38.curAnim->unk08;
}
s32 func_802507AC(struct MarioState *m)
{
struct Object *o = m->marioObj;
return o->header.gfx.unk38.animFrame >= (o->header.gfx.unk38.curAnim->unk08 - 2);
}
s16 set_mario_animation(struct MarioState *m, s32 targetAnimID)
{
struct Object *o = m->marioObj;
struct Animation *targetAnim = m->animation->targetAnim;
if (func_80278AD4(m->animation, targetAnimID))
{
targetAnim->values = (void *) VIRTUAL_TO_PHYSICAL((s8 *) targetAnim + (s32) targetAnim->values);
targetAnim->index = (void *) VIRTUAL_TO_PHYSICAL((s8 *) targetAnim + (s32) targetAnim->index);
}
if (o->header.gfx.unk38.animID != targetAnimID)
{
o->header.gfx.unk38.animID = targetAnimID;
o->header.gfx.unk38.curAnim = targetAnim;
o->header.gfx.unk38.animAccel = 0;
o->header.gfx.unk38.animYTrans = m->unkB0;
if (targetAnim->flags & 4)
o->header.gfx.unk38.animFrame = targetAnim->unk04;
else
{
if (targetAnim->flags & 2)
o->header.gfx.unk38.animFrame = targetAnim->unk04 + 1;
else
o->header.gfx.unk38.animFrame = targetAnim->unk04 - 1;
}
}
return o->header.gfx.unk38.animFrame;
}
s16 func_80250934(struct MarioState *m, s32 targetAnimID, s32 arg2)
{
struct Object *o = m->marioObj;
struct Animation *targetAnim = m->animation->targetAnim;
if (func_80278AD4(m->animation, targetAnimID))
{
targetAnim->values = (void *) VIRTUAL_TO_PHYSICAL((s8 *) targetAnim + (s32) targetAnim->values);
targetAnim->index = (void *) VIRTUAL_TO_PHYSICAL((s8 *) targetAnim + (s32) targetAnim->index);
}
if (o->header.gfx.unk38.animID != targetAnimID)
{
o->header.gfx.unk38.animID = targetAnimID;
o->header.gfx.unk38.curAnim = targetAnim;
o->header.gfx.unk38.animYTrans = m->unkB0;
if (targetAnim->flags & 4)
o->header.gfx.unk38.animFrameAccelAssist = (targetAnim->unk04 << 0x10);
else
{
if (targetAnim->flags & 2)
o->header.gfx.unk38.animFrameAccelAssist = (targetAnim->unk04 << 0x10) + arg2;
else
o->header.gfx.unk38.animFrameAccelAssist = (targetAnim->unk04 << 0x10) - arg2;
}
o->header.gfx.unk38.animFrame = (o->header.gfx.unk38.animFrameAccelAssist >> 0x10);
}
o->header.gfx.unk38.animAccel = arg2;
return o->header.gfx.unk38.animFrame;
}
void func_80250AAC(struct MarioState *m, s16 arg1)
{
struct GraphNodeObject_sub *animInfo = &m->marioObj->header.gfx.unk38;
struct Animation *curAnim = animInfo->curAnim;
if (animInfo->animAccel)
{
if (curAnim->flags & 2)
animInfo->animFrameAccelAssist = (arg1 << 0x10) + animInfo->animAccel;
else
animInfo->animFrameAccelAssist = (arg1 << 0x10) - animInfo->animAccel;
}
else
{
if (curAnim->flags & 2)
animInfo->animFrame = arg1 + 1;
else
animInfo->animFrame = arg1 - 1;
}
}
s32 func_80250B68(struct MarioState *m, s16 arg1)
{
s32 sp14;
s32 sp10 = arg1 << 0x10;
struct GraphNodeObject_sub *spC = &m->marioObj->header.gfx.unk38;
struct Animation *sp8 = spC->curAnim;
if (spC->animAccel)
{
if (sp8->flags & 2)
sp14 = (spC->animFrameAccelAssist > sp10) &&
(sp10 >= (spC->animFrameAccelAssist - spC->animAccel));
else
sp14 = (spC->animFrameAccelAssist < sp10) &&
(sp10 <= (spC->animFrameAccelAssist + spC->animAccel));
}
else
{
if (sp8->flags & 2)
sp14 = (spC->animFrame == (arg1 + 1));
else
sp14 = ((spC->animFrame + 1) == arg1);
}
return sp14;
}
s16 func_80250C84(struct Object *obj, s32 arg1, Vec3s arg2)
{
f32 sp34;
f32 sp30;
struct Animation *curAnim = (void *) obj->header.gfx.unk38.curAnim;
s16 sp2A = func_8037C844(&obj->header.gfx.unk38, NULL);
u16 *animIndex = (u16 *) segmented_to_virtual(curAnim->index);
s16 *animValues = (s16 *) segmented_to_virtual(curAnim->values);
f32 sp1C = (f32) sins(arg1);
f32 sp18 = (f32) coss(arg1);
sp34 = *(animValues + (func_8037C7D8(sp2A, &animIndex))) / 4.0f;
arg2[1] = *(animValues + (func_8037C7D8(sp2A, &animIndex))) / 4.0f;
sp30 = *(animValues + (func_8037C7D8(sp2A, &animIndex))) / 4.0f;
arg2[0] = (sp34 * sp18) + (sp30 * sp1C);
arg2[2] = (-sp34 * sp1C) + (sp30 * sp18);
return curAnim->flags;
}
void func_80250E50(struct MarioState *m)
{
Vec3s sp20;
s16 sp30;
sp30 = func_80250C84(m->marioObj, m->faceAngle[1], sp20);
if (sp30 & 0x48)
{
m->pos[0] += (f32) sp20[0];
m->pos[2] += (f32) sp20[2];
}
if (sp30 & 0x50)
m->pos[1] += (f32) sp20[1];
}
s16 func_80250F0C(struct MarioState *m)
{
Vec3s sp18;
func_80250C84(m->marioObj, 0, sp18);
return sp18[1];
}
void func_80250F50(struct MarioState *m, u32 arg1, u32 arg2)
{
if ((m->flags & arg2) == 0)
{
SetSound(arg1, m->marioObj->header.gfx.cameraToObject);
m->flags |= arg2;
}
}
void func_80250FBC(struct MarioState *m)
{
if (!(m->flags & MARIO_UNKNOWN_17))
{
#ifdef VERSION_US
if (m->action == ACT_TRIPLE_JUMP)
SetSound(SOUND_MARIO_YAHOO2 + ((D_80226EB8 % 5) << 0x10),
m->marioObj->header.gfx.cameraToObject);
else
#endif
SetSound(SOUND_MARIO_YAH + ((D_80226EB8 % 3) << 0x10),
m->marioObj->header.gfx.cameraToObject);
m->flags |= MARIO_UNKNOWN_17;
}
}
void func_80251048(struct MarioState *m) {
s32 absForwardVel = (m->forwardVel > 0.0f) ? m->forwardVel : -m->forwardVel;
func_80320A4C(1, (absForwardVel >= 101) ? 100 : absForwardVel);
}
void func_802510E4(struct MarioState *m, u32 arg1, u32 arg2)
{
if (m->unk14 == 0x20000)
{
if (arg2 != 0)
m->particleFlags |= PARTICLE_12;
else
m->particleFlags |= PARTICLE_8;
}
else
{
if (m->unk14 == 0x70000)
m->particleFlags |= PARTICLE_15;
else if (m->unk14 == 0x50000)
m->particleFlags |= PARTICLE_14;
}
if ((m->flags & MARIO_METAL_CAP) || arg1 == SOUND_ACTION_UNKNOWN443 || arg1 == SOUND_MARIO_HOO6)
SetSound(arg1, m->marioObj->header.gfx.cameraToObject);
else
SetSound((m->unk14 + arg1), m->marioObj->header.gfx.cameraToObject);
}
void func_80251218(struct MarioState *m, u32 arg1, u32 arg2) {
if ((m->flags & MARIO_UNKNOWN_16) == 0)
{
func_802510E4(m, arg1, arg2);
m->flags |= MARIO_UNKNOWN_16;
}
}
void func_80251280(struct MarioState *m, u32 arg1)
{
func_802510E4(m, (m->flags & MARIO_METAL_CAP) ? SOUND_ACTION_UNKNOWN429 : arg1, 1);
}
void func_802512E4(struct MarioState *m, u32 arg1)
{
func_80251218(m, (m->flags & MARIO_METAL_CAP) ? SOUND_ACTION_UNKNOWN429 : arg1, 1);
}
void func_80251348(struct MarioState *m, u32 arg1)
{
func_802510E4(m, (m->flags & MARIO_METAL_CAP) ? SOUND_ACTION_UNKNOWN42B : arg1, 1);
}
void func_802513AC(struct MarioState *m, u32 arg1)
{
func_80251218(m, (m->flags & MARIO_METAL_CAP) ? SOUND_ACTION_UNKNOWN42B : arg1, 1);
}
void func_80251410(struct MarioState *m, s32 arg1, s32 arg2)
{
if (arg1 == SOUND_TERRAIN_1)
func_80251218(m, (m->flags & MARIO_METAL_CAP) ? SOUND_ACTION_UNKNOWN428 : SOUND_TERRAIN_1, 1);
else
func_80250F50(m, arg1, MARIO_UNKNOWN_16);
if (arg2 == 0)
func_80250FBC(m);
if (arg2 != -1)
func_80250F50(m, arg2, MARIO_UNKNOWN_17);
}
void mario_set_forward_vel(struct MarioState *m, f32 forwardVel)
{
m->forwardVel = forwardVel;
m->slideVelX = sins(m->faceAngle[1]) * m->forwardVel;
m->slideVelZ = coss(m->faceAngle[1]) * m->forwardVel;
m->vel[0] = (f32) m->slideVelX;
m->vel[2] = (f32) m->slideVelZ;
}
extern s32 mario_get_floor_class(struct MarioState *m)
{
s32 floorClass;
if ((m->area->terrainType & 7) == TERRAIN_SLIDE)
floorClass = SURFACE_CLASS_SLIDE;
else
floorClass = SURFACE_CLASS_DEFAULT;
if (m->floor)
{
switch (m->floor->type)
{
case SURFACE_NOT_SLIPPERY:
case SURFACE_HARD_NOT_SLIPPERY:
case SURFACE_SWITCH:
floorClass = SURFACE_CLASS_NOT_SLIPPERY;
break;
case SURFACE_SLIPPERY:
case SURFACE_002A: //Slippery with noise
case SURFACE_HARD_SLIPPERY:
case SURFACE_0079:
floorClass = SURFACE_CLASS_SLIPPERY;
break;
case SURFACE_SLIDE:
case SURFACE_ICE:
case SURFACE_HARD_SLIDE:
case SURFACE_0073: //Slide with noise, unused
case SURFACE_0074: //Slide with noise, unused
case SURFACE_0075: //Slide with noise
case SURFACE_0078:
floorClass = SURFACE_CLASS_SLIDE;
break;
}
}
if (m->action == ACT_CRAWLING && m->floor->normal.y > 0.5f && floorClass == SURFACE_CLASS_DEFAULT)
floorClass = SURFACE_CLASS_NOT_SLIPPERY;
return floorClass;
}
u32 func_8025167C(struct MarioState *m)
{
s16 spE;
s16 terrainType = m->area->terrainType & 7;
s32 sp8 = 0;
s32 floorType;
if (m->floor)
{
floorType = m->floor->type;
if ((gCurrLevelNum != LEVEL_LLL) && (m->floorHeight < (m->waterLevel - 10)))
sp8 = 0x20000;
else if (SURFACE_IS_QUICKSAND(floorType))
sp8 = 0x70000;
else
{
switch (floorType)
{
default:
spE = 0;
break;
case SURFACE_NOT_SLIPPERY:
case SURFACE_HARD:
case SURFACE_HARD_NOT_SLIPPERY:
case SURFACE_SWITCH:
spE = 1;
break;
case SURFACE_SLIPPERY:
case SURFACE_HARD_SLIPPERY:
case SURFACE_0079:
spE = 2;
break;
case SURFACE_SLIDE:
case SURFACE_ICE:
case SURFACE_HARD_SLIDE:
case SURFACE_0073:
case SURFACE_0074:
case SURFACE_0075:
case SURFACE_0078:
spE = 3;
break;
case SURFACE_0029:
spE = 4;
break;
case SURFACE_002A:
spE = 5;
break;
}
sp8 = D_8032CB40[terrainType][spE] << 0x10;
}
}
return sp8;
}
struct Surface *func_8025181C(Vec3f arg0, f32 arg1, f32 arg2)
{
struct WallCollisionData collisionData;
struct Surface *wall = NULL;
collisionData.x = arg0[0];
collisionData.y = arg0[1];
collisionData.z = arg0[2];
collisionData.radius = arg2;
collisionData.offsetY = arg1;
if (find_wall_collisions(&collisionData))
wall = collisionData.walls[collisionData.numWalls - 1];
arg0[0] = collisionData.x;
arg0[1] = collisionData.y;
arg0[2] = collisionData.z;
return wall;
}
f32 func_802518D0(Vec3f arg0, f32 arg1, struct Surface **ceil)
{
f32 tmp UNUSED; // why...
return find_ceil(arg0[0], arg1 + 80.0f, arg0[2], ceil);
}
s32 mario_facing_downhill(struct MarioState *m, s32 arg1)
{
s16 faceAngleYaw = m->faceAngle[1];
if (arg1 && m->forwardVel < 0.0f)
faceAngleYaw += 0x8000;
faceAngleYaw = m->floorAngle - faceAngleYaw;
return (-0x4000 < faceAngleYaw) && (faceAngleYaw < 0x4000);
}
u32 func_802519A8(struct MarioState *m)
{
f32 sp24;
if ((m->area->terrainType & 7) == TERRAIN_SLIDE && m->floor->normal.y < 0.9998477f)
return TRUE;
switch (mario_get_floor_class(m))
{
case SURFACE_SLIDE:
sp24 = 0.9848077f;
break;
case SURFACE_SLIPPERY:
sp24 = 0.9396926f;
break;
default:
sp24 = 0.7880108f;
break;
case SURFACE_NOT_SLIPPERY:
sp24 = 0.0f;
break;
}
return m->floor->normal.y <= sp24;
}
s32 mario_floor_is_slope(struct MarioState *m)
{
f32 tmp;
if ((m->area->terrainType & 0x0007) == TERRAIN_SLIDE && m->floor->normal.y < 0.9998477f)
return TRUE;
switch (mario_get_floor_class(m))
{
case SURFACE_SLIDE:
tmp = 0.9961947f;
break;
case SURFACE_SLIPPERY:
tmp = 0.9848077f;
break;
default:
tmp = 0.9659258f;
break;
case SURFACE_NOT_SLIPPERY:
tmp = 0.9396926f;
break;
}
return m->floor->normal.y <= tmp;
}
s32 func_80251BF8(struct MarioState *m)
{
f32 tmp;
s32 result = FALSE;
if (!mario_facing_downhill(m, FALSE))
{
switch (mario_get_floor_class(m))
{
case SURFACE_SLIDE:
tmp = 0.9659258f;
break;
case SURFACE_SLIPPERY:
tmp = 0.9396926f;
break;
default:
tmp = 0.8660254f;
break;
case SURFACE_NOT_SLIPPERY:
tmp = 0.8660254f;
break;
}
result = m->floor->normal.y <= tmp;
}
return result;
}
f32 find_floor_height_relative_polar(struct MarioState *m, s32 angleFromMario, f32 distFromMario)
{
struct Surface *floor;
f32 floorY;
f32 y = sins(m->faceAngle[1] + (s16) angleFromMario) * distFromMario;
f32 x = coss(m->faceAngle[1] + (s16) angleFromMario) * distFromMario;
floorY = find_floor(m->pos[0] + y, m->pos[1] + 100.0f, m->pos[2] + x, &floor);
return floorY;
}
s16 func_80251DD4(struct MarioState *m, s16 unk1)
{
struct Surface *floor;
f32 forwardFloorY, backwardFloorY;
f32 forwardYDelta, backwardYDelta;
s16 result;
f32 y = sins(m->faceAngle[1] + unk1) * 5.0f;
f32 x = coss(m->faceAngle[1] + unk1) * 5.0f;
forwardFloorY = find_floor(m->pos[0] + y, m->pos[1] + 100.0f, m->pos[2] + x, &floor);
backwardFloorY = find_floor(m->pos[0] - y, m->pos[1] + 100.0f, m->pos[2] - x, &floor);
forwardYDelta = forwardFloorY - m->pos[1];
backwardYDelta = m->pos[1] - backwardFloorY;
if (forwardYDelta * forwardYDelta < backwardYDelta * backwardYDelta)
result = atan2s(5.0f, forwardYDelta);
else
result = atan2s(5.0f, backwardYDelta);
return result;
}
void func_80251F74(struct MarioState *m)
{
u32 action = m->action;
s32 unk0 = m->area->camera->currPreset;
if (action == ACT_FIRST_PERSON)
{
func_80248CB8(2);
gCameraMovementFlags &= ~CAM_MOVE_C_UP_MODE;
func_80285BD8(m->area->camera, -1, 1);
}
else if (action == ACT_SLEEPING)
func_80248CB8(2);
if (!(action & (ACT_FLAG_SWIMMING | ACT_FLAG_METAL_WATER)))
{
if (unk0 == CAMERA_PRESET_BEHIND_MARIO || unk0 == CAMERA_PRESET_WATER_SURFACE)
func_80285BD8(m->area->camera, m->area->camera->defPreset, 1);
}
}
void func_80252070(struct MarioState *m)
{
m->marioObj->oMarioSteepJumpYaw = m->faceAngle[1];
if (m->forwardVel > 0.0f)
{
//! ((s16)0x8000) has undefined behavior. Therefore, this downcast has
// undefined behavior if m->floorAngle >= 0.
s16 angleTemp = m->floorAngle + 0x8000;
s16 faceAngleTemp = m->faceAngle[1] - angleTemp;
f32 y = sins(faceAngleTemp) * m->forwardVel;
f32 x = coss(faceAngleTemp) * m->forwardVel * 0.75f;
m->forwardVel = sqrtf(y * y + x * x);
m->faceAngle[1] = atan2s(x, y) + angleTemp;
}
drop_and_set_mario_action(m, ACT_STEEP_JUMP, 0);
}
static void func_8025219C(struct MarioState *m, f32 unk1, f32 unk2)
{
m->vel[1] = unk1 + zero_80254E20() + m->forwardVel * unk2;
if (m->squishTimer != 0 || m->quicksandDepth > 1.0f)
m->vel[1] *= 0.5f;
}
static u32 set_mario_action_airborne(struct MarioState *m, u32 action, u32 actionArg)
{
f32 tmp;
if (m->squishTimer != 0 || m->quicksandDepth >= 1.0f)
{
if (action == ACT_DOUBLE_JUMP || action == ACT_TWIRLING)
action = ACT_JUMP;
}
switch (action)
{
case ACT_DOUBLE_JUMP:
func_8025219C(m, 52.0f, 0.25f);
m->forwardVel *= 0.8f;
break;
case ACT_BACKFLIP:
m->marioObj->header.gfx.unk38.animID = -1;
m->forwardVel = -16.0f;
func_8025219C(m, 62.0f, 0.0f);
break;
case ACT_TRIPLE_JUMP:
func_8025219C(m, 69.0f, 0.0f);
m->forwardVel *= 0.8f;
break;
case ACT_FLYING_TRIPLE_JUMP:
func_8025219C(m, 82.0f, 0.0f);
break;
case ACT_WATER_JUMP:
case ACT_HOLD_WATER_JUMP:
if (actionArg == 0)
func_8025219C(m, 42.0f, 0.0f);
break;
case ACT_BURNING_JUMP:
m->vel[1] = 31.5f;
m->forwardVel = 8.0f;
break;
case ACT_RIDING_SHELL_JUMP:
func_8025219C(m, 42.0f, 0.25f);
break;
case ACT_JUMP:
case ACT_HOLD_JUMP:
m->marioObj->header.gfx.unk38.animID = -1;
func_8025219C(m, 42.0f, 0.25f);
m->forwardVel *= 0.8f;
break;
case ACT_WALL_KICK_AIR:
case ACT_TOP_OF_POLE_JUMP:
func_8025219C(m, 62.0f, 0.0f);
if (m->forwardVel < 24.0f)
m->forwardVel = 24.0f;
m->wallKickTimer = 0;
break;
case ACT_SIDE_FLIP:
func_8025219C(m, 62.0f, 0.0f);
m->forwardVel = 8.0f;
m->faceAngle[1] = m->intendedYaw;
break;
case ACT_STEEP_JUMP:
m->marioObj->header.gfx.unk38.animID = -1;
func_8025219C(m, 42.0f, 0.25f);
m->faceAngle[0] = -0x2000;
break;
case ACT_LAVA_BOOST:
m->vel[1] = 84.0f;
if (actionArg == 0) {
m->forwardVel = 0.0f;
}
break;
case ACT_DIVE:
if ((tmp = m->forwardVel + 15.0f) > 48.0f)
tmp = 48.0f;
mario_set_forward_vel(m, tmp);
break;
case ACT_LONG_JUMP:
m->marioObj->header.gfx.unk38.animID = -1;
func_8025219C(m, 30.0f, 0.0f);
m->marioObj->oMarioLongJumpIsSlow = m->forwardVel > 16.0f ? FALSE : TRUE;
if ((m->forwardVel *= 1.5f) > 48.0f)
m->forwardVel = 48.0f;
break;
case ACT_SLIDE_KICK:
m->vel[1] = 12.0f;
if (m->forwardVel < 32.0f)
m->forwardVel = 32.0f;
break;
case ACT_JUMP_KICK:
m->vel[1] = 20.0f;
break;
}
m->peakHeight = m->pos[1];
m->flags |= MARIO_UNKNOWN_08;
return action;
}
static u32 set_mario_action_moving(struct MarioState *m, u32 action, UNUSED u32 actionArg)
{
s16 floorClass = mario_get_floor_class(m);
f32 forwardVel = m->forwardVel;
f32 mag = min(m->intendedMag, 8.0f);
switch (action) {
case ACT_WALKING:
if (floorClass != SURFACE_CLASS_SLIDE)
{
if (0.0f <= forwardVel && forwardVel < mag)
m->forwardVel = mag;
}
m->marioObj->OBJECT_FIELD_S32(0x22) = 0;
break;
case ACT_HOLD_WALKING:
if (0.0f <= forwardVel && forwardVel < mag / 2.0f)
m->forwardVel = mag / 2.0f;
break;
case ACT_BEGIN_SLIDING:
if (mario_facing_downhill(m, 0))
action = ACT_BUTT_SLIDE;
else
action = ACT_STOMACH_SLIDE;
break;
case ACT_HOLD_BEGIN_SLIDING:
if (mario_facing_downhill(m, 0))
action = ACT_HOLD_BUTT_SLIDE;
else
action = ACT_HOLD_STOMACH_SLIDE;
break;
}
return action;
}
static u32 set_mario_action_submerged(struct MarioState *m, u32 action, UNUSED u32 actionArg)
{
if (action == ACT_METAL_WATER_JUMP || action == ACT_HOLD_METAL_WATER_JUMP)
m->vel[1] = 32.0f;
return action;
}
static u32 set_mario_action_cutscene(struct MarioState *m, u32 action, UNUSED u32 actionArg)
{
switch (action)
{
case ACT_EMERGE_FROM_PIPE:
m->vel[1] = 52.0f;
break;
case ACT_FALL_AFTER_STAR_GRAB:
mario_set_forward_vel(m, 0.0f);
break;
case ACT_SPAWN_SPIN_AIRBORNE:
mario_set_forward_vel(m, 2.0f);
break;
case ACT_SPECIAL_EXIT_AIRBORNE:
case ACT_SPECIAL_DEATH_EXIT:
m->vel[1] = 64.0f;
break;
}
return action;
}
u32 set_mario_action(struct MarioState *m, u32 action, u32 actionArg)
{
switch (action & ACT_GROUP_MASK)
{
case ACT_GROUP_MOVING:
action = set_mario_action_moving(m, action, actionArg);
break;
case ACT_GROUP_AIRBORNE:
action = set_mario_action_airborne(m, action, actionArg);
break;
case ACT_GROUP_SUBMERGED:
action = set_mario_action_submerged(m, action, actionArg);
break;
case ACT_GROUP_CUTSCENE:
action = set_mario_action_cutscene(m, action, actionArg);
break;
}
m->flags &= ~(MARIO_UNKNOWN_16 | MARIO_UNKNOWN_17);
if (!(m->action & ACT_FLAG_AIR))
m->flags &= ~MARIO_UNKNOWN_18;
m->prevAction = m->action;
m->action = action;
m->actionArg = actionArg;
m->actionState = 0;
m->actionTimer = 0;
return TRUE;
}
s32 func_80252C30(struct MarioState *m)
{
if (m->quicksandDepth >= 11.0f)
{
if (m->heldObj == NULL)
return set_mario_action(m, ACT_QUICKSAND_JUMP_LAND, 0);
else
return set_mario_action(m, ACT_HOLD_QUICKSAND_JUMP_LAND, 0);
}
if (func_80251BF8(m))
func_80252070(m);
else
{
if ((m->doubleJumpTimer == 0) || (m->squishTimer != 0))
set_mario_action(m, ACT_JUMP, 0);
else
{
switch (m->prevAction)
{
case ACT_JUMP_LAND:
set_mario_action(m, ACT_DOUBLE_JUMP, 0);
break;
case ACT_FREEFALL_LAND:
set_mario_action(m, ACT_DOUBLE_JUMP, 0);
break;
case ACT_SIDE_FLIP_LAND_STOP:
set_mario_action(m, ACT_DOUBLE_JUMP, 0);
break;
case ACT_DOUBLE_JUMP_LAND:
if (m->flags & MARIO_WING_CAP)
set_mario_action(m, ACT_FLYING_TRIPLE_JUMP, 0);
else if (m->forwardVel > 20.0f)
set_mario_action(m, ACT_TRIPLE_JUMP, 0);
else
set_mario_action(m, ACT_JUMP, 0);
break;
default:
set_mario_action(m, ACT_JUMP, 0);
break;
}
}
}
m->doubleJumpTimer = 0;
return TRUE;
}
s32 func_80252E74(struct MarioState *m, u32 arg1, u32 arg2)
{
u32 action UNUSED = m->action;
if (m->quicksandDepth >= 11.0f)
{
if (m->heldObj == NULL)
return set_mario_action(m, ACT_QUICKSAND_JUMP_LAND, 0);
else
return set_mario_action(m, ACT_HOLD_QUICKSAND_JUMP_LAND, 0);
}
if (func_80251BF8(m))
func_80252070(m);
else
set_mario_action(m, arg1, arg2);
return TRUE;
}
s32 drop_and_set_mario_action(struct MarioState *m, u32 arg1, u32 arg2)
{
mario_stop_riding_and_holding(m);
return set_mario_action(m, arg1, arg2);
}
s32 func_80252F98(struct MarioState *m, u32 arg1, u32 arg2, s16 hurtCounter)
{
m->hurtCounter = hurtCounter;
return set_mario_action(m, arg1, arg2);
}
s32 func_80252FEC(struct MarioState *m)
{
if (m->input & INPUT_A_PRESSED)
return set_mario_action(m, ACT_JUMP, 0);
if (m->input & INPUT_OFF_FLOOR)
return set_mario_action(m, ACT_FREEFALL, 0);
if (m->input & INPUT_NONZERO_ANALOG)
return set_mario_action(m, ACT_WALKING, 0);
if (m->input & INPUT_ABOVE_SLIDE)
return set_mario_action(m, ACT_BEGIN_SLIDING, 0);
return 0;
}
s32 func_802530D4(struct MarioState *m)
{
if (m->input & INPUT_A_PRESSED)
return set_mario_action(m, ACT_HOLD_JUMP, 0);
if (m->input & INPUT_OFF_FLOOR)
return set_mario_action(m, ACT_HOLD_FREEFALL, 0);
if (m->input & INPUT_NONZERO_ANALOG)
return set_mario_action(m, ACT_HOLD_WALKING, 0);
if (m->input & INPUT_ABOVE_SLIDE)
return set_mario_action(m, ACT_HOLD_BEGIN_SLIDING, 0);
return 0;
}
s32 func_802531B8(struct MarioState *m)
{
func_80285BD8(m->area->camera, m->area->camera->defPreset, 1);
vec3s_set(m->angleVel, 0, 0, 0);
if (m->heldObj == NULL)
return set_mario_action(m, ACT_WALKING, 0);
else
return set_mario_action(m, ACT_HOLD_WALKING, 0);
}
s32 func_8025325C(struct MarioState *m)
{
m->forwardVel = m->forwardVel / 4.0f;
m->vel[1] = m->vel[1] / 2.0f;
m->pos[1] = m->waterLevel - 100;
m->faceAngle[2] = 0;
vec3s_set(m->angleVel, 0, 0, 0);
if ((m->action & ACT_FLAG_DIVING) == 0)
m->faceAngle[0] = 0;
if (m->area->camera->currPreset != CAMERA_PRESET_WATER_SURFACE)
func_80285BD8(m->area->camera, 8, 1);
return set_mario_action(m, ACT_WATER_PLUNGE, 0);
}
void func_8025335C(struct MarioState *m)
{
if (m->squishTimer != 0xFF)
{
if (m->squishTimer == 0)
vec3f_set(m->marioObj->header.gfx.scale, 1.0f, 1.0f, 1.0f);
else if (m->squishTimer <= 16)
{
m->squishTimer--;
m->marioObj->header.gfx.scale[1] =
1.0f - ((D_8032CB7B[15 - m->squishTimer] * 0.6f) / 100.0f);
m->marioObj->header.gfx.scale[0] =
((D_8032CB7B[15 - m->squishTimer] * 0.4f) / 100.0f) + 1.0f;
m->marioObj->header.gfx.scale[2] = m->marioObj->header.gfx.scale[0];
}
else
{
m->squishTimer--;
vec3f_set(m->marioObj->header.gfx.scale, 1.4f, 0.4f, 1.4f);
}
}
}
void func_802534F4(struct MarioState *m)
{
f32 steepness;
f32 floor_nY;
if (gShowDebugText)
{
steepness = sqrtf(((m->floor->normal.x * m->floor->normal.x) +
(m->floor->normal.z * m->floor->normal.z)));
floor_nY = m->floor->normal.y;
print_text_fmt_int(210, 88, "ANG %d", (atan2s(floor_nY, steepness) * 180.0f) / 32768.0f);
print_text_fmt_int(210, 72, "SPD %d", m->forwardVel);
print_text_fmt_int(210, 56, "STA %x", (m->action & ACT_ID_MASK));
}
}
void func_8025360C(struct MarioState *m)
{
if (m->controller->buttonPressed & A_BUTTON)
m->input |= INPUT_A_PRESSED;
if (m->controller->buttonDown & A_BUTTON)
m->input |= INPUT_A_DOWN;
if (m->squishTimer == 0)
{
if (m->controller->buttonPressed & B_BUTTON)
m->input |= INPUT_B_PRESSED;
if (m->controller->buttonDown & Z_TRIG)
m->input |= INPUT_Z_DOWN;
if (m->controller->buttonPressed & Z_TRIG)
m->input |= INPUT_Z_PRESSED;
}
if (m->input & INPUT_A_PRESSED)
m->framesSinceA = 0;
else if (m->framesSinceA < 0xFF)
m->framesSinceA += 1;
if (m->input & INPUT_B_PRESSED)
m->framesSinceB = 0;
else if (m->framesSinceB < 0xff)
m->framesSinceB += 1;
}
void func_80253730(struct MarioState *m)
{
struct Controller *controller = m->controller;
f32 sp18 = ((controller->stickMag / 64.0f) *
(controller->stickMag / 64.0f)) * 64.0f;
if (m->squishTimer == 0)
m->intendedMag = sp18 / 2.0f;
else
m->intendedMag = sp18 / 8.0f;
if (m->intendedMag > 0.0f)
{
m->intendedYaw =
atan2s(-controller->stickY, controller->stickX) + m->area->camera->trueYaw;
m->input |= INPUT_NONZERO_ANALOG;
}
else
m->intendedYaw = m->faceAngle[1];
}
void func_80253834(struct MarioState *m)
{
f32 sp24;
f32 ceilToFloorDist;
resolve_wall_collisions(&m->pos[0], &m->pos[1], &m->pos[2], 60.0f, 50.0f);
resolve_wall_collisions(&m->pos[0], &m->pos[1], &m->pos[2], 30.0f, 24.0f);
m->floorHeight = find_floor(m->pos[0], m->pos[1], m->pos[2], &m->floor);
if (m->floor == 0)
{
vec3f_copy(m->pos, m->marioObj->header.gfx.pos);
m->floorHeight = find_floor(m->pos[0], m->pos[1], m->pos[2], &m->floor);
}
m->ceilHeight = func_802518D0(&m->pos[0], m->floorHeight, &m->ceil);
sp24 = func_80381D3C(m->pos[0], m->pos[2]);
m->waterLevel = find_water_level(m->pos[0], m->pos[2]);
if (m->floor)
{
m->floorAngle = atan2s(m->floor->normal.z, m->floor->normal.x);
m->unk14 = func_8025167C(m);
if ((m->pos[1] > m->waterLevel - 0x28) && func_802519A8(m))
m->input |= INPUT_ABOVE_SLIDE;
if ((m->floor->flags & 1) || (m->ceil && m->ceil->flags & 1))
{
ceilToFloorDist = m->ceilHeight - m->floorHeight;
if ((0.0f <= ceilToFloorDist) && (ceilToFloorDist <= 150.0f))
m->input |= INPUT_SQUISHED;
}
if (m->pos[1] > m->floorHeight + 100.0f)
m->input |= INPUT_OFF_FLOOR;
if (m->pos[1] < (m->waterLevel - 0xa))
m->input |= INPUT_IN_WATER;
if (m->pos[1] < (sp24 - 100.0f))
m->input |= INPUT_UNKNOWN_8;
}
else
level_trigger_warp(m, WARP_OP_DEATH);
}
void func_80253B2C(struct MarioState *m)
{
m->particleFlags = 0;
m->input = 0;
m->collidedObjInteractTypes = m->marioObj->collidedObjInteractTypes;
m->flags &= 0xFFFFFF;
func_8025360C(m);
func_80253730(m);
func_80253834(m);
func_802534F4(m);
if (gCameraMovementFlags & CAM_MOVE_C_UP_MODE)
{
if (m->action & 0x4000000)
m->input |= INPUT_FIRST_PERSON;
else
gCameraMovementFlags &= ~CAM_MOVE_C_UP_MODE;
}
if (!(m->input & (INPUT_NONZERO_ANALOG | INPUT_A_PRESSED)))
m->input |= INPUT_UNKNOWN_5;
if (m->marioObj->oInteractStatus & 0x13)
m->input |= INPUT_UNKNOWN_10;
nop_80254E3C(m);
if (m->wallKickTimer > 0)
m->wallKickTimer--;
if (m->doubleJumpTimer > 0)
m->doubleJumpTimer--;
}
void func_80253C94(struct MarioState *m)
{
f32 sp1C;
s16 sp1A;
if ((m->action & ACT_GROUP_MASK) == ACT_GROUP_SUBMERGED)
{
sp1C = (f32) (m->waterLevel - 80) - m->pos[1];
sp1A = m->area->camera->currPreset;
if ((m->action & ACT_FLAG_METAL_WATER))
{
if (sp1A != CAMERA_PRESET_CLOSE)
func_80285BD8(m->area->camera, 4, 1);
}
else
{
if ((sp1C > 800.0f) && (sp1A != CAMERA_PRESET_BEHIND_MARIO))
func_80285BD8(m->area->camera, 3, 1);
if ((sp1C < 400.0f) && (sp1A != CAMERA_PRESET_WATER_SURFACE))
func_80285BD8(m->area->camera, 8, 1);
if ((m->action & ACT_FLAG_INTANGIBLE) == 0)
{
if ((m->pos[1] < (f32) (m->waterLevel - 160)) ||
(m->faceAngle[0] < -0x800))
m->particleFlags |= PARTICLE_5;
}
}
}
}
void func_80253E34(struct MarioState *m)
{
s32 terrainIsSnow;
if (m->health >= 0x100)
{
if ((m->healCounter | m->hurtCounter) == 0)
{
if ((m->input & INPUT_UNKNOWN_8) && ((m->action & ACT_FLAG_INTANGIBLE) == 0))
{
if (((m->flags & MARIO_METAL_CAP) == 0) && (gDebugLevelSelect == 0))
m->health -= 4;
}
else
{
if ((m->action & 0x2000) && ((m->action & 0x1000) == 0))
{
terrainIsSnow = (m->area->terrainType & 0x7) == TERRAIN_SNOW;
if ((m->pos[1] >= (m->waterLevel - 140)) && !terrainIsSnow)
m->health += 0x1A;
else if (gDebugLevelSelect == 0)
m->health -= (terrainIsSnow ? 3 : 1);
}
}
}
if (m->healCounter > 0)
{
m->health += 0x40;
m->healCounter--;
}
if (m->hurtCounter > 0)
{
m->health -= 0x40;
m->hurtCounter--;
}
if (m->health >= 0x881)
m->health = 0x880;
if (m->health < 0x100)
m->health = 0xFF;
if (((m->action & ACT_GROUP_MASK) == ACT_GROUP_SUBMERGED) && (m->health < 0x300))
SetSound(SOUND_UNKNOWN_UNK1C18, D_803320E0);
}
}
void func_80254088(struct MarioState *m)
{
m->unk98->action = m->action;
m->unk94->action = m->action;
vec3s_copy(m->unk94->faceAngle, m->faceAngle);
if ((m->flags & MARIO_UNKNOWN_25) == 0)
vec3f_copy(m->unk94->pos, m->pos);
}
void func_8025410C(struct MarioState *m)
{
struct MarioBodyState *sp4 = m->unk98;
sp4->capState = MARIO_HAS_DEFAULT_CAP_OFF;
sp4->eyeState = MARIO_EYES_BLINK;
sp4->handState = MARIO_HAND_FISTS;
sp4->unk08 = 0;
sp4->unk07 = 0;
m->flags &= ~0x40;
}
void func_80254164(struct MarioState *m)
{
struct Object *o = m->marioObj;
if (o->header.gfx.throwMatrix)
{
// TODO: throwMatrix should probably be an actual matrix pointer
*(f32 *)((u8 *) o->header.gfx.throwMatrix + 0x34) -= m->quicksandDepth;
}
o->header.gfx.pos[1] -= m->quicksandDepth;
}
s32 func_802541BC(struct MarioState *m)
{
s32 flags = m->flags;
s32 action;
if (m->capTimer > 0)
{
action = (s32) m->action;
if (
(m->capTimer < 0x3D) ||
(
(action != ACT_READING_AUTOMATIC_DIALOGUE) &&
(action != ACT_READING_NPC_DIALOGUE) &&
(action != ACT_READING_SIGN) &&
(action != ACT_IN_CANNON)
)
)
{
m->capTimer--;
}
if (m->capTimer == 0)
{
func_80249418();
m->flags &= ~(MARIO_VANISH_CAP | MARIO_METAL_CAP | MARIO_WING_CAP);
if ((m->flags &
(MARIO_UNKNOWN_00 | MARIO_VANISH_CAP |
MARIO_METAL_CAP | MARIO_WING_CAP)) == 0)
m->flags &= ~MARIO_CAP_ON_HEAD;
}
if (m->capTimer == 0x3C)
func_802493D4();
if ((m->capTimer < 0x40) && ((1LL << m->capTimer) & D_8032CB80))
{
flags &= ~(MARIO_VANISH_CAP | MARIO_METAL_CAP | MARIO_WING_CAP);
if ((flags &
(MARIO_UNKNOWN_00 | MARIO_VANISH_CAP |
MARIO_METAL_CAP | MARIO_WING_CAP)) == 0)
flags &= ~MARIO_CAP_ON_HEAD;
}
}
return flags;
}
void func_8025435C(struct MarioState *m)
{
struct MarioBodyState *sp1C = m->unk98;
s32 sp18 = func_802541BC(m);
if (sp18 & MARIO_VANISH_CAP)
sp1C->unk08 = 0x180;
if (sp18 & MARIO_METAL_CAP)
sp1C->unk08 |= 0x200;
if (sp18 & MARIO_UNKNOWN_06)
sp1C->unk08 |= 0x200;
if (m->invincTimer >= 3)
{
if (gGlobalTimer & 1)
gMarioState->marioObj->header.gfx.node.flags |= 0x10;
}
if (sp18 & MARIO_CAP_IN_HAND)
{
if (sp18 & MARIO_WING_CAP)
sp1C->handState = MARIO_HAND_HOLDING_WING_CAP;
else
sp1C->handState = MARIO_HAND_HOLDING_CAP;
}
if (sp18 & MARIO_CAP_ON_HEAD)
{
if (sp18 & MARIO_WING_CAP)
sp1C->capState = MARIO_HAS_WING_CAP_ON;
else
sp1C->capState = MARIO_HAS_DEFAULT_CAP_ON;
}
if (m->action & ACT_FLAG_SHORT_HITBOX)
m->marioObj->hitboxHeight = 100.0f;
else
m->marioObj->hitboxHeight = 160.0f;
if ((m->flags & MARIO_TELEPORTING) && (m->fadeWarpOpacity != 0xFF))
{
sp1C->unk08 &= ~0xFF;
sp1C->unk08 |= (m->fadeWarpOpacity | 0x100);
}
}
void Unknown8025453C(u16 arg0, s32 arg1, u16 arg2, u16 arg3)
{
if ((gPlayer1Controller->buttonDown & 0x2000) &&
(gPlayer1Controller->buttonPressed & arg0) &&
((gMarioState->flags & arg1) == 0))
{
gMarioState->flags |= (arg1 + MARIO_CAP_ON_HEAD);
if (arg2 > gMarioState->capTimer)
gMarioState->capTimer = arg2;
func_80249368(arg3);
}
}
s32 func_80254604(UNUSED struct Object *arg0)
{
s32 sp24 = TRUE;
if (gMarioState->action)
{
gMarioState->marioObj->header.gfx.node.flags &= ~GRAPH_RENDER_10;
func_8025410C(gMarioState);
func_80253B2C(gMarioState);
mario_handle_special_floors(gMarioState);
mario_process_interactions(gMarioState);
if (gMarioState->floor == NULL)
return 0;
while (sp24)
{
switch (gMarioState->action & 0x1c0)
{
case ACT_GROUP_STATIONARY:
sp24 = mario_execute_stationary_action(gMarioState);
break;
case ACT_GROUP_MOVING:
sp24 = mario_execute_moving_action(gMarioState);
break;
case ACT_GROUP_AIRBORNE:
sp24 = mario_execute_airborne_action(gMarioState);
break;
case ACT_GROUP_SUBMERGED:
sp24 = mario_execute_submerged_action(gMarioState);
break;
case ACT_GROUP_CUTSCENE:
sp24 = mario_execute_cutscene_action(gMarioState);
break;
case ACT_GROUP_AUTOMATIC:
sp24 = mario_execute_automatic_action(gMarioState);
break;
case ACT_GROUP_OBJECT:
sp24 = mario_execute_object_action(gMarioState);
break;
}
}
func_80254164(gMarioState);
func_8025335C(gMarioState);
func_80253C94(gMarioState);
func_80253E34(gMarioState);
func_80254088(gMarioState);
func_8025435C(gMarioState);
if (gMarioState->floor->type == SURFACE_HORIZONTAL_WIND)
{
func_802ADC20(0, (gMarioState->floor->force << 8));
#if VERSION_US
SetSound(SOUND_ENVIRONMENT_WIND2, gMarioState->marioObj->header.gfx.cameraToObject);
#endif
}
if (gMarioState->floor->type == SURFACE_VERTICAL_WIND)
{
func_802ADC20(1, 0);
#if VERSION_US
SetSound(SOUND_ENVIRONMENT_WIND2, gMarioState->marioObj->header.gfx.cameraToObject);
#endif
}
func_80249040();
gMarioState->marioObj->oInteractStatus = 0;
return gMarioState->particleFlags;
}
return 0;
}
void func_802548BC(void)
{
Vec3s capPos;
struct Object *capObject;
D_80339F10 = 0;
gMarioState->actionTimer = 0;
gMarioState->framesSinceA = 0xFF;
gMarioState->framesSinceB = 0xFF;
gMarioState->invincTimer = 0;
if (save_file_get_flags() &
(SAVE_FLAG_CAP_ON_GROUND | SAVE_FLAG_CAP_ON_KLEPTO |
SAVE_FLAG_CAP_ON_UKIKI | SAVE_FLAG_CAP_ON_MR_BLIZZARD))
gMarioState->flags = 0;
else
gMarioState->flags = (MARIO_CAP_ON_HEAD | MARIO_UNKNOWN_00);
gMarioState->forwardVel = 0.0f;
gMarioState->squishTimer = 0;
gMarioState->hurtCounter = 0;
gMarioState->healCounter = 0;
gMarioState->capTimer = 0;
gMarioState->quicksandDepth = 0.0f;
gMarioState->heldObj = NULL;
gMarioState->riddenObj = NULL;
gMarioState->usedObj = NULL;
gMarioState->waterLevel = find_water_level(
gMarioSpawnInfo->startPos[0], gMarioSpawnInfo->startPos[2]
);
gMarioState->area = gCurrentArea;
gMarioState->marioObj = gMarioObject;
gMarioState->marioObj->header.gfx.unk38.animID = -1;
vec3s_copy(gMarioState->faceAngle, gMarioSpawnInfo->startAngle);
vec3s_set(gMarioState->angleVel, 0, 0, 0);
vec3s_to_vec3f(gMarioState->pos, gMarioSpawnInfo->startPos);
vec3f_set(gMarioState->vel, 0, 0, 0);
gMarioState->floorHeight = find_floor(
gMarioState->pos[0], gMarioState->pos[1], gMarioState->pos[2],
&gMarioState->floor
);
if (gMarioState->pos[1] < gMarioState->floorHeight)
gMarioState->pos[1] = gMarioState->floorHeight;
gMarioState->marioObj->header.gfx.pos[1] = gMarioState->pos[1];
gMarioState->action = (gMarioState->pos[1] <= (gMarioState->waterLevel - 100))
? ACT_WATER_IDLE
: ACT_IDLE;
func_8025410C(gMarioState);
func_80254088(gMarioState);
gMarioState->unk98->unk0B = 0;
gMarioState->marioObj->oPosX = gMarioState->pos[0];
gMarioState->marioObj->oPosY = gMarioState->pos[1];
gMarioState->marioObj->oPosZ = gMarioState->pos[2];
gMarioState->marioObj->oMoveAnglePitch = gMarioState->faceAngle[0];
gMarioState->marioObj->oMoveAngleYaw = gMarioState->faceAngle[1];
gMarioState->marioObj->oMoveAngleRoll = gMarioState->faceAngle[2];
vec3f_copy(gMarioState->marioObj->header.gfx.pos, gMarioState->pos);
vec3s_set(
gMarioState->marioObj->header.gfx.angle,
0, gMarioState->faceAngle[1], 0
);
if (save_file_get_cap_pos(capPos))
{
capObject = spawn_object(gMarioState->marioObj, MODEL_MARIOS_CAP, bhvNormalCap);
capObject->oPosX = capPos[0];
capObject->oPosY = capPos[1];
capObject->oPosZ = capPos[2];
capObject->oForwardVel2 = 0;
capObject->oMoveAngleYaw = 0;
}
}
void func_80254CE0(void)
{
gMarioState->unk00 = 0;
gMarioState->flags = 0;
gMarioState->action = 0;
gMarioState->spawnInfo = &gPlayerSpawnInfos[0];
gMarioState->unk94 = &gPlayerStatusForCamera[0];
gMarioState->unk98 = &D_8033A040[0];
gMarioState->controller = &gControllers[0];
gMarioState->animation = &D_80339D10;
gMarioState->numCoins = 0;
gMarioState->numStars = save_file_get_total_star_count(
gCurrSaveFileNum - 1, COURSE_MIN - 1, COURSE_MAX - 1
);
gMarioState->numKeys = 0;
gMarioState->numLives = 4;
gMarioState->health = 0x880;
gMarioState->unkB8 = gMarioState->numStars;
gMarioState->unkB0 = 0xBD;
gDisplayedCoins = 0;
gDisplayedHealthWedges = 8;
} |
Partager