diff options
Diffstat (limited to 'src/engine/objects/Lakitu.cpp')
| -rw-r--r-- | src/engine/objects/Lakitu.cpp | 123 |
1 files changed, 88 insertions, 35 deletions
diff --git a/src/engine/objects/Lakitu.cpp b/src/engine/objects/Lakitu.cpp index 8088e89c8..392fe9100 100644 --- a/src/engine/objects/Lakitu.cpp +++ b/src/engine/objects/Lakitu.cpp @@ -32,7 +32,7 @@ extern "C" { #include "course_offsets.h" #include "data/some_data.h" #include "race_logic.h" -#include "effects.h" +#include "effects.h" #include "memory.h" extern s8 gPlayerCount; } @@ -41,11 +41,11 @@ OLakitu::OLakitu(s32 playerId, LakituType type) { Name = "Lakitu"; _playerId = playerId; - init_object(gIndexLakituList[playerId], (s32)type); + init_object(gIndexLakituList[playerId], (s32) type); } void OLakitu::Activate(LakituType type) { - init_object(gIndexLakituList[_playerId], (s32)type); + init_object(gIndexLakituList[_playerId], (s32) type); } void OLakitu::Tick() { @@ -96,7 +96,7 @@ void OLakitu::Draw(s32 cameraId) { s32 objectIndex; Object* object; - FrameInterpolation_RecordOpenChild("Lakitu",(uintptr_t) this); + FrameInterpolation_RecordOpenChild("Lakitu", (uintptr_t) this); objectIndex = gIndexLakituList[cameraId]; camera = &camera1[cameraId]; @@ -106,14 +106,37 @@ void OLakitu::Draw(s32 cameraId) { object->orientation[1] = func_800418AC(object->pos[0], object->pos[2], camera->pos); object->orientation[2] = 0x8000; if (func_80072354(objectIndex, 2) != 0) { - draw_2d_texture_at(object->pos, object->orientation, object->sizeScaling, (u8*) object->activeTLUT, - (u8*)object->activeTexture, object->vertex, (s32) object->textureWidth, - (s32) object->textureHeight, (s32) object->textureWidth, - (s32) object->textureHeight / 2); + s32 width = object->textureWidth; + s32 height = object->textureHeight; + rsp_set_matrix_transformation(object->pos, object->orientation, object->sizeScaling); + gSPDisplayList(gDisplayListHead++, (Gfx*) D_0D007D78); + s32 heightIndex; + + gDPLoadTLUT_pal256(gDisplayListHead++, object->activeTLUT); + gDPLoadTextureTile(gDisplayListHead++, object->activeTexture, G_IM_FMT_CI, G_IM_SIZ_8b, width, height, 0, 0, + width - 1, height - 1, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, + G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + gSPVertex(gDisplayListHead++, (uintptr_t) object->vertex, 4, 0); + gSPDisplayList(gDisplayListHead++, (Gfx*) common_rectangle_display); + gSPTexture(gDisplayListHead++, 1, 1, 0, G_TX_RENDERTILE, G_OFF); } else { - func_800485C4(object->pos, object->orientation, object->sizeScaling, (s32) object->primAlpha, - (u8*) object->activeTLUT, (u8*)object->activeTexture, object->vertex, (s32) object->textureWidth, - (s32) object->textureHeight, (s32) object->textureWidth, (s32) object->textureHeight / 2); + s32 width = object->textureWidth; + s32 height = object->textureHeight; + rsp_set_matrix_transformation(object->pos, object->orientation, object->sizeScaling); + gSPDisplayList(gDisplayListHead++, (Gfx*) D_0D007E98); + gDPSetAlphaCompare(gDisplayListHead++, G_AC_DITHER); + gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_XLU_SURF, G_RM_AA_ZB_XLU_SURF2); + + set_transparency(object->primAlpha); + s32 heightIndex; + + gDPLoadTLUT_pal256(gDisplayListHead++, object->activeTLUT); + rsp_load_texture((u8*) object->activeTexture, width, height); + gSPVertex(gDisplayListHead++, (uintptr_t) object->vertex, 4, 0); + gSPDisplayList(gDisplayListHead++, (Gfx*) common_rectangle_display); + gSPTexture(gDisplayListHead++, 1, 1, 0, G_TX_RENDERTILE, G_OFF); + + gDPSetAlphaCompare(gDisplayListHead++, G_AC_NONE); } if (gScreenModeSelection == SCREEN_MODE_1P) { var_f0 = object->pos[0] - camera->pos[0]; @@ -188,6 +211,13 @@ static const char* sLakituTextures[] = { gTextureLakituBlueLight5, gTextureLakituBlueLight6, gTextureLakituBlueLight7, gTextureLakituBlueLight8, }; +Vtx fixed_common_vtx_lakitu[] = { + { { { -28, -35, 0 }, 0, { 0, 0 }, { 255, 255, 255, 255 } } }, + { { { 27, -35, 0 }, 0, { 3520, 0 }, { 255, 255, 255, 255 } } }, + { { { 27, 35, 0 }, 0, { 3520, 4480 }, { 255, 255, 255, 255 } } }, + { { { -28, 35, 0 }, 0, { 0, 4480 }, { 255, 255, 255, 255 } } }, +}; + void OLakitu::init_obj_lakitu_starter_and_checkered_flag(s32 objectIndex, s32 playerId) { if (playerId == 0) { D_801656F0 = 0; @@ -201,8 +231,7 @@ void OLakitu::init_obj_lakitu_starter_and_checkered_flag(s32 objectIndex, s32 pl objectIndex, (u8*) load_lakitu_tlut_x64(common_tlut_lakitu_countdown, ARRAY_COUNT(common_tlut_lakitu_countdown)), sLakituTextures, 56, (u16) 72); - Vtx* vtx = (Vtx*) LOAD_ASSET_RAW(common_vtx_lakitu); - gObjectList[objectIndex].vertex = vtx; + gObjectList[objectIndex].vertex = fixed_common_vtx_lakitu; gObjectList[objectIndex].sizeScaling = 0.15f; clear_object_flag(objectIndex, 0x00000010); object_next_state(objectIndex); @@ -319,18 +348,44 @@ static const char* sLakituCheckeredList[] = { gTextureLakituCheckeredFlag31, gTextureLakituCheckeredFlag32 }; +Vtx fixed_common_vtx_also_lakitu[] = { + { { { -36, -27, 0 }, 0, { 0, 0 }, { 255, 255, 255, 255 } } }, + { { { 35, -27, 0 }, 0, { 4544, 0 }, { 255, 255, 255, 255 } } }, + { { { 35, 27, 0 }, 0, { 4544, 3456 }, { 255, 255, 255, 255 } } }, + { { { -36, 27, 0 }, 0, { 0, 3456 }, { 255, 255, 255, 255 } } }, + { { { -40, -24, 0 }, 0, { 0, 0 }, { 255, 255, 255, 255 } } }, + { { { 40, -24, 0 }, 0, { 5056, 0 }, { 255, 255, 255, 255 } } }, + { { { 40, 0, 0 }, 0, { 5056, 1472 }, { 255, 255, 255, 255 } } }, + { { { -40, 0, 0 }, 0, { 0, 1472 }, { 255, 255, 255, 255 } } }, + { { { -40, 0, 0 }, 0, { 0, 0 }, { 255, 255, 255, 255 } } }, + { { { 40, 0, 0 }, 0, { 5056, 0 }, { 255, 255, 255, 255 } } }, + { { { 40, 24, 0 }, 0, { 5056, 1472 }, { 255, 255, 255, 255 } } }, + { { { -40, 24, 0 }, 0, { 0, 1472 }, { 255, 255, 255, 255 } } }, + { { { -48, -8, 0 }, 0, { 0, 0 }, { 255, 255, 255, 255 } } }, + { { { 47, -8, 0 }, 0, { 6080, 0 }, { 255, 255, 255, 255 } } }, + { { { 47, 7, 0 }, 0, { 6080, 960 }, { 255, 255, 255, 255 } } }, + { { { -48, 7, 0 }, 0, { 0, 960 }, { 255, 255, 255, 255 } } }, + { { { -56, -16, 0 }, 0, { 0, 0 }, { 255, 255, 255, 255 } } }, + { { { 55, -16, 0 }, 0, { 7104, 0 }, { 255, 255, 255, 255 } } }, + { { { 55, 15, 0 }, 0, { 7104, 1984 }, { 255, 255, 255, 255 } } }, + { { { -56, 15, 0 }, 0, { 0, 1984 }, { 255, 255, 255, 255 } } }, + { { { -56, -16, 0 }, 0, { 0, 0 }, { 0, 0, 0, 255 } } }, + { { { 55, -16, 0 }, 0, { 7104, 0 }, { 0, 0, 0, 255 } } }, + { { { 55, 15, 0 }, 0, { 7104, 1984 }, { 0, 0, 0, 255 } } }, + { { { -56, 15, 0 }, 0, { 0, 1984 }, { 0, 0, 0, 255 } } }, +}; + void OLakitu::init_obj_lakitu_checkered_flag(s32 objectIndex, s32 playerIndex) { Object* object; OLakitu::func_800791F0(objectIndex, playerIndex); u8* tex = (u8*) LOAD_ASSET_RAW(common_tlut_lakitu_checkered_flag); - Vtx* vtx = (Vtx*) LOAD_ASSET_RAW(common_vtx_also_lakitu); init_texture_object(objectIndex, (u8*) tex, sLakituCheckeredList, 0x48U, (u16) 0x00000038); object = &gObjectList[objectIndex]; object->activeTexture = *gObjectList[objectIndex].textureList; - object->vertex = vtx; + object->vertex = fixed_common_vtx_also_lakitu; object->pos[2] = 5000.0f; object->pos[1] = 5000.0f; object->pos[0] = 5000.0f; @@ -366,7 +421,7 @@ void OLakitu::func_800797AC(s32 playerId) { objectIndex = gIndexLakituList[playerId]; player = &gPlayerOne[playerId]; - //if ((IsSherbetLand()) && (player->unk_0CA & 1)) { + // if ((IsSherbetLand()) && (player->unk_0CA & 1)) { if ((CM_GetProps()->LakituTowType == LakituTowType::ICE) && (player->unk_0CA & 1)) { init_object(objectIndex, 7); player->unk_0CA |= 0x10; @@ -402,14 +457,20 @@ void OLakitu::func_8007993C(s32 objectIndex, Player* player) { static const char* sLakituFishingTextures[] = { gTextureLakituFishing1, gTextureLakituFishing2, gTextureLakituFishing3, gTextureLakituFishing4 }; +Vtx fixed_D_0D005F30[] = { + { { { -10, -35, 0 }, 0, { 0, 0 }, { 255, 255, 255, 255 } } }, + { { { 45, -35, 0 }, 0, { 3520, 0 }, { 255, 255, 255, 255 } } }, + { { { 45, 35, 0 }, 0, { 3520, 4480 }, { 255, 255, 255, 255 } } }, + { { { -10, 35, 0 }, 0, { 0, 4480 }, { 255, 255, 255, 255 } } }, +}; + void OLakitu::init_obj_lakitu_red_flag_fishing(s32 objectIndex, s32 arg1) { u8* tlut = (u8*) LOAD_ASSET_RAW(common_tlut_lakitu_fishing); - Vtx* vtx = (Vtx*) LOAD_ASSET_RAW(D_0D005F30); OLakitu::func_800791F0(objectIndex, arg1); init_texture_object(objectIndex, tlut, sLakituFishingTextures, 0x38U, (u16) 0x00000048); - gObjectList[objectIndex].vertex = vtx; + gObjectList[objectIndex].vertex = fixed_D_0D005F30; gObjectList[objectIndex].sizeScaling = 0.15f; func_80086E70(objectIndex); clear_object_flag(objectIndex, 0x00000010); @@ -589,12 +650,11 @@ void OLakitu::func_8007A060(s32 objectIndex, s32 playerIndex) { OLakitu::func_800791F0(objectIndex, playerIndex); u8* tlut = (u8*) LOAD_ASSET_RAW(common_tlut_lakitu_second_lap); - Vtx* vtx = (Vtx*) LOAD_ASSET_RAW(common_vtx_also_lakitu); init_texture_object(objectIndex, tlut, sLakituSecondLapTextures, 0x48U, (u16) 0x00000038); object = &gObjectList[objectIndex]; object->activeTexture = *gObjectList[objectIndex].textureList; - object->vertex = vtx; + object->vertex = fixed_common_vtx_also_lakitu; object->pos[2] = 5000.0f; object->pos[1] = 5000.0f; object->pos[0] = 5000.0f; @@ -648,12 +708,11 @@ void OLakitu::func_8007A228(s32 objectIndex, s32 playerIndex) { OLakitu::func_800791F0(objectIndex, playerIndex); u8* tlut = (u8*) LOAD_ASSET_RAW(common_tlut_lakitu_final_lap); - Vtx* vtx = (Vtx*) LOAD_ASSET_RAW(common_vtx_also_lakitu); init_texture_object(objectIndex, tlut, sLakituFinalLapTextures, 0x48U, (u16) 0x00000038); object = &gObjectList[objectIndex]; object->activeTexture = *gObjectList[objectIndex].textureList; - object->vertex = vtx; + object->vertex = fixed_common_vtx_also_lakitu; object->pos[2] = 5000.0f; object->pos[1] = 5000.0f; object->pos[0] = 5000.0f; @@ -706,11 +765,10 @@ void OLakitu::func_8007A3F0(s32 objectIndex, s32 arg1) { OLakitu::func_800791F0(objectIndex, arg1); u8* tlut = (u8*) LOAD_ASSET_RAW(common_tlut_lakitu_reverse); - Vtx* vtx = (Vtx*) LOAD_ASSET_RAW(common_vtx_also_lakitu); init_texture_object(objectIndex, tlut, sLakituReverseTextures, 72, (u16) 56); gObjectList[objectIndex].activeTexture = *gObjectList[objectIndex].textureList; - gObjectList[objectIndex].vertex = vtx; + gObjectList[objectIndex].vertex = fixed_common_vtx_also_lakitu; gObjectList[objectIndex].pos[2] = var; gObjectList[objectIndex].pos[1] = var; gObjectList[objectIndex].pos[0] = var; @@ -769,14 +827,12 @@ void OLakitu::func_8007A66C(s32 objectIndex) { u16 rot = 0x8000 - camera->rot[1]; gObjectList[objectIndex].pos[0] = - (player->pos[0] + - (coss(rot) * (gObjectList[objectIndex].origin_pos[0] + gObjectList[objectIndex].offset[0]))) - + (player->pos[0] + (coss(rot) * (gObjectList[objectIndex].origin_pos[0] + gObjectList[objectIndex].offset[0]))) - (sins(rot) * (gObjectList[objectIndex].origin_pos[2] + gObjectList[objectIndex].offset[2])); gObjectList[objectIndex].pos[1] = player->unk_074 + gObjectList[objectIndex].origin_pos[1] + gObjectList[objectIndex].offset[1]; gObjectList[objectIndex].pos[2] = - (player->pos[2] + - (sins(rot) * (gObjectList[objectIndex].origin_pos[0] + gObjectList[objectIndex].offset[0]))) + + (player->pos[2] + (sins(rot) * (gObjectList[objectIndex].origin_pos[0] + gObjectList[objectIndex].offset[0]))) + (coss(rot) * (gObjectList[objectIndex].origin_pos[2] + gObjectList[objectIndex].offset[2])); } @@ -786,14 +842,12 @@ void OLakitu::func_8007A778(s32 objectIndex) { u16 rot = 0x8000 - camera->rot[1]; gObjectList[objectIndex].pos[0] = - (player->pos[0] + - (coss(rot) * (gObjectList[objectIndex].origin_pos[0] + gObjectList[objectIndex].offset[0]))) - + (player->pos[0] + (coss(rot) * (gObjectList[objectIndex].origin_pos[0] + gObjectList[objectIndex].offset[0]))) - (sins(rot) * (gObjectList[objectIndex].origin_pos[2] + gObjectList[objectIndex].offset[2])); gObjectList[objectIndex].pos[1] = player->pos[1] + gObjectList[objectIndex].origin_pos[1] + gObjectList[objectIndex].offset[1]; gObjectList[objectIndex].pos[2] = - (player->pos[2] + - (sins(rot) * (gObjectList[objectIndex].origin_pos[0] + gObjectList[objectIndex].offset[0]))) + + (player->pos[2] + (sins(rot) * (gObjectList[objectIndex].origin_pos[0] + gObjectList[objectIndex].offset[0]))) + (coss(rot) * (gObjectList[objectIndex].origin_pos[2] + gObjectList[objectIndex].offset[2])); } @@ -805,7 +859,7 @@ void OLakitu::func_8007A88C(s32 playerId) { player = &gPlayerOne[playerId]; if ((gObjectList[objectIndex].state == 0) && (player->effects & 0x400000)) { - //func_800790E4(playerId); + // func_800790E4(playerId); init_object(gIndexLakituList[playerId], 6); } } @@ -823,7 +877,7 @@ void OLakitu::func_8007AA44(s32 playerId) { OLakitu::func_8007A910(playerId); objectIndex = gIndexLakituList[playerId]; - gLakituTexturePtr = (const char**)&gLakituTextureBuffer[playerId]; + gLakituTexturePtr = (const char**) &gLakituTextureBuffer[playerId]; switch (gObjectList[objectIndex].unk_0D8) { case 1: OLakitu::func_80079114(objectIndex, playerId, 2); @@ -858,4 +912,3 @@ void OLakitu::func_8007AA44(s32 playerId) { break; } } - |
