summaryrefslogtreecommitdiff
path: root/src/engine/courses/YoshiValley.cpp
blob: fe7672d7eae7a96f42b89363f4eec28f863b3d93 (plain)
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
#include <libultraship.h>
#include <libultra/gbi.h>
#include <vector>
#include <memory>

#include "YoshiValley.h"
#include "GameObject.h"
#include "World.h"
#include "BombKart.h"
#include "assets/yoshi_valley_data.h"
#include "assets/boo_frames.h"

extern "C" {
    #include "main.h"
    #include "camera.h"
    #include "course_offsets.h"
    #include "code_800029B0.h"
    #include "render_courses.h"
    #include "code_8006E9C0.h"
    #include "code_80057C60.h"
    #include "defines.h"
    #include "math_util.h"
    #include "external.h"
    #include "code_80005FD0.h"
    #include "spawn_players.h"
    #include "render_objects.h"
    #include "assets/common_data.h"
    #include "save.h"
    #include "staff_ghosts.h"
    #include "actors.h"
    #include "collision.h"
    #include "memory.h"
    extern const char *d_course_yoshi_valley_dl_list[];
}

YoshiValley::YoshiValley() {
    this->vtx = d_course_yoshi_valley_vertex;
    this->gfx = d_course_yoshi_valley_packed_dls;
    this->gfxSize = 4140;
    this->textures = yoshi_valley_textures;
    Props.MinimapTexture = gTextureCourseOutlineYoshiValley;
    Props.D_800E5548[0] = 64;
    Props.D_800E5548[1] = 64;

    Props.Name = "yoshi valley";
    Props.DebugName = "maze";
    Props.CourseLength = "772m";
    Props.AIBehaviour = D_0D0090B8;
    Props.AIMaximumSeparation = 35.0f;
    Props.AIMinimumSeparation = 0.0f;
    Props.SomePtr = D_800DCAF4;
    Props.AISteeringSensitivity = 53;

    Props.NearPersp = 9.0f;
    Props.FarPersp = 4500.0f;

    Props.PathSizes = {0x02B2, 0x02A8, 0x02B2, 0x0320, 1, 0, 0, 0, 0, 0, 0};

    Props.D_0D009418[0] = 4.1666665f;
    Props.D_0D009418[1] = 5.5833334f;
    Props.D_0D009418[2] = 6.1666665f;
    Props.D_0D009418[3] = 6.75f;

    Props.D_0D009568[0] = 3.75f;
    Props.D_0D009568[1] = 5.1666665f;
    Props.D_0D009568[2] = 5.75f;
    Props.D_0D009568[3] = 6.3333334f;

    Props.D_0D0096B8[0] = 3.3333332f;
    Props.D_0D0096B8[1] = 3.9166667f;
    Props.D_0D0096B8[2] = 4.5f;
    Props.D_0D0096B8[3] = 5.0833334f;

    Props.D_0D009808[0] = 3.75f;
    Props.D_0D009808[1] = 5.1666665f;
    Props.D_0D009808[2] = 5.75f;
    Props.D_0D009808[3] = 6.3333334f;

    Props.PathTable[0] = (TrackWaypoint*)LOAD_ASSET_RAW(d_course_yoshi_valley_unknown_waypoints);
    Props.PathTable[1] = (TrackWaypoint*)LOAD_ASSET_RAW(d_course_yoshi_valley_unknown_waypoints_2);
    Props.PathTable[2] = (TrackWaypoint*)LOAD_ASSET_RAW(d_course_yoshi_valley_unknown_waypoints_3);
    Props.PathTable[3] = (TrackWaypoint*)LOAD_ASSET_RAW(d_course_yoshi_valley_unknown_waypoints_4);

    Props.PathTable2[0] = (TrackWaypoint*)LOAD_ASSET_RAW(d_course_yoshi_valley_track_waypoints);
    Props.PathTable2[1] = (TrackWaypoint*)LOAD_ASSET_RAW(d_course_yoshi_valley_track_waypoints_2);
    Props.PathTable2[2] = (TrackWaypoint*)LOAD_ASSET_RAW(d_course_yoshi_valley_track_waypoints_3);
    Props.PathTable2[3] = (TrackWaypoint*)LOAD_ASSET_RAW(d_course_yoshi_valley_track_waypoints_4);

    Props.Clouds = gYoshiValleyMooMooFarmClouds;
    Props.CloudList = gYoshiValleyMooMooFarmClouds;
    Props.MinimapFinishlineX = 0;
    Props.MinimapFinishlineY = 0;

    Props.Skybox.TopRight = {113, 70, 255};
    Props.Skybox.BottomRight = {255, 184, 99};
    Props.Skybox.BottomLeft = {255, 184, 99};
    Props.Skybox.TopLeft = {113, 70, 255};
    Props.Skybox.FloorTopRight = {95, 40, 15};
    Props.Skybox.FloorBottomRight = {0, 0, 0};
    Props.Skybox.FloorBottomLeft = {0, 0, 0};
    Props.Skybox.FloorTopLeft = {95, 40, 15};
}

void YoshiValley::LoadTextures() {
    dma_textures(gTextureTrees2, 0x000003E8U, 0x00000800U);
}

void YoshiValley::SpawnActors() {
    Vec3f position;
    Vec3f velocity = { 0.0f, 0.0f, 0.0f };
    Vec3s rotation = { 0, 0, 0 };

    spawn_foliage((struct ActorSpawnData*)LOAD_ASSET_RAW(d_course_yoshi_valley_tree_spawn));
    spawn_all_item_boxes((struct ActorSpawnData*)LOAD_ASSET_RAW(d_course_yoshi_valley_item_box_spawns));
    vec3f_set(position, -2300.0f, 0.0f, 634.0f);
    position[0] *= gCourseDirection;
    add_actor_to_empty_slot(position, rotation, velocity, ACTOR_YOSHI_EGG);
}

// Likely sets minimap boundaries
void YoshiValley::MinimapSettings() {
    D_8018D220 = reinterpret_cast<uint8_t (*)[1024]>(dma_textures(gTextureExhaust0, 0x479, 0xC00));
    D_8018D2A0 = 0.018f;
    D_8018D2E0 = 61;
    D_8018D2E8 = 38;
}

void YoshiValley::InitCourseObjects() {
    size_t objectId;
    size_t i;
    for (i = 0; i < NUM_YV_FLAG_POLES; i++) {
        init_object(indexObjectList1[i], 0);
    }
    if (gGamestate != CREDITS_SEQUENCE) {
        for (i = 0; i < NUM_HEDGEHOGS; i++) {
            objectId = indexObjectList2[i];
            init_object(objectId, 0);
            gObjectList[objectId].pos[0] = gObjectList[objectId].origin_pos[0] =
                gHedgehogSpawns[i].pos[0] * xOrientation;
            gObjectList[objectId].pos[1] = gObjectList[objectId].surfaceHeight =
                gHedgehogSpawns[i].pos[1] + 6.0;
            gObjectList[objectId].pos[2] = gObjectList[objectId].origin_pos[2] = gHedgehogSpawns[i].pos[2];
            gObjectList[objectId].unk_0D5 = gHedgehogSpawns[i].unk_06;
            gObjectList[objectId].unk_09C = gHedgehogPatrolPoints[i][0] * xOrientation;
            gObjectList[objectId].unk_09E = gHedgehogPatrolPoints[i][2];
        }
    }
}

void YoshiValley::UpdateCourseObjects() {
    func_80083080();
    if (gGamestate != CREDITS_SEQUENCE) {
        update_hedgehogs();
    }
}

void YoshiValley::RenderCourseObjects(s32 cameraId) {
    func_80055228(cameraId);
    if (gGamestate != CREDITS_SEQUENCE) {
        render_object_hedgehogs(cameraId);
    }
}

void YoshiValley::SomeSounds() {
}

void YoshiValley::WhatDoesThisDo(Player* player, int8_t playerId) {}

void YoshiValley::WhatDoesThisDoAI(Player* player, int8_t playerId) {}

void YoshiValley::SpawnBombKarts() {
    gWorldInstance.AddObject(std::make_unique<OBombKart>(140, 3, 0.8333333, 0, 0, 0, 0));
    gWorldInstance.AddObject(std::make_unique<OBombKart>(165, 1, 0.8333333, 0, 0, 0, 0));
    gWorldInstance.AddObject(std::make_unique<OBombKart>(330, 3, 0.8333333, 0, 0, 0, 0));
    gWorldInstance.AddObject(std::make_unique<OBombKart>(550, 1, 0.8333333, 0, 0, 0, 0));
    gWorldInstance.AddObject(std::make_unique<OBombKart>(595, 3, 0.8333333, 0, 0, 0, 0));
    gWorldInstance.AddObject(std::make_unique<OBombKart>(0, 0, 0.8333333, 0, 0, 0, 0));
    gWorldInstance.AddObject(std::make_unique<OBombKart>(0, 0, 0.8333333, 0, 0, 0, 0));
}

// Positions the finishline on the minimap
void YoshiValley::MinimapFinishlinePosition() {
    //! todo: Place hard-coded values here.
    draw_hud_2d_texture_8x8(this->Props.MinimapFinishlineX, this->Props.MinimapFinishlineY, (u8*) common_texture_minimap_finish_line);
}

void YoshiValley::SetStaffGhost() {
}

void YoshiValley::BeginPlay() {  }

void YoshiValley::Render(struct UnkStruct_800DC5EC* arg0) {
    gDPPipeSync(gDisplayListHead++);
    gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEI, G_CC_MODULATEI);
    gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2);
    gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING);
    render_course_segments(d_course_yoshi_valley_dl_list, arg0);
    gDPPipeSync(gDisplayListHead++);
}

void YoshiValley::RenderCredits() {
    gSPDisplayList(gDisplayListHead++, (Gfx*)(d_course_yoshi_valley_dl_18020));
}

void YoshiValley::Collision() {}

void YoshiValley::GenerateCollision() {
    Lights1 lights4 = gdSPDefLights1(100, 100, 100, 255, 254, 254, 0, 0, 120);
    func_802B5D64(&lights4, -0x38F0, 0x1C70, 1);
    parse_course_displaylists((TrackSectionsI*)LOAD_ASSET_RAW(d_course_yoshi_valley_addr));
    func_80295C6C();
    D_8015F8E4 = gCourseMinY - 10.0f;
}

void YoshiValley::Waypoints(Player* player, int8_t playerId) {
    player->nearestWaypointId = gCopyNearestWaypointByPlayerId[playerId];
}

void YoshiValley::Water() {}

void YoshiValley::Destroy() {}