summaryrefslogtreecommitdiff
path: root/src/koopatlas
diff options
context:
space:
mode:
Diffstat (limited to 'src/koopatlas')
-rw-r--r--src/koopatlas/core.cpp1
-rw-r--r--src/koopatlas/hud.cpp2
-rw-r--r--src/koopatlas/map.cpp100
-rw-r--r--src/koopatlas/map.h4
-rw-r--r--src/koopatlas/mapdata.cpp32
-rw-r--r--src/koopatlas/mapdata.h11
-rw-r--r--src/koopatlas/pathmanager.cpp25
-rw-r--r--src/koopatlas/pathmanager.h1
-rw-r--r--src/koopatlas/player.cpp93
9 files changed, 124 insertions, 145 deletions
diff --git a/src/koopatlas/core.cpp b/src/koopatlas/core.cpp
index b8c9083..5f06d61 100644
--- a/src/koopatlas/core.cpp
+++ b/src/koopatlas/core.cpp
@@ -141,6 +141,7 @@ bool WMInit_LoadSIAnims(void *ptr) {
DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_propeller", 0);
DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_star", 0);
DVD_LoadFile(GetDVDClass(), "Object", "I_hammer", 0);
+ DVD_LoadFile(GetDVDClass(), "WorldMap", "cobCourse", 0);
return true;
}
diff --git a/src/koopatlas/hud.cpp b/src/koopatlas/hud.cpp
index 587c2c0..cbd7ef6 100644
--- a/src/koopatlas/hud.cpp
+++ b/src/koopatlas/hud.cpp
@@ -5,7 +5,7 @@ void CharToWChar(const char *input, wchar_t *output, int length) { for (int i =
int getStarCoinCount() {
SaveBlock *save = GetSaveFile()->GetBlock(-1);
- int coinsSpent = 0;
+ int coinsSpent = save->credits_hiscore;
int coinsEarned = 0;
for (int w = 0; w < 10; w++) {
diff --git a/src/koopatlas/map.cpp b/src/koopatlas/map.cpp
index 9a04e65..46838d9 100644
--- a/src/koopatlas/map.cpp
+++ b/src/koopatlas/map.cpp
@@ -45,9 +45,8 @@ int dWMMap_c::onCreate() {
renderer.allocator.setup(GameHeaps[0], 0x20);
bool result = renderer.setup(&renderer.allocator);
- bgMatrix.translation(1140.0f, -2910.0f, -500.0f);
- s16 rot = 0x4000;
- bgMatrix.applyRotationX(&rot);
+ bgMatrix.identity();
+ bgMatrix.translation(0.0f, 0.0f, -500.0f);
allocator.link(-1, GameHeaps[0], 0, 0x20);
nw4r::g3d::ResFile rf(dScKoopatlas_c::instance->mapData.bgLoader.buffer);
@@ -64,6 +63,25 @@ int dWMMap_c::onCreate() {
bgSrtAnm.bindEntry(&bgModel, anmRes, 0, 0);
bgModel.bindAnim(&bgSrtAnm, 0.0f);
+
+ nw4r::g3d::ResFile rg(getResource("cobCourse", "g3d/model.brres"));
+ renderer.nodeModel.setup(rg.GetResMdl("cobCourse"), &allocator, 0x224, 1, 0);
+
+ // nw4r::g3d::ResFile rg(dScKoopatlas_c::instance->mapData.nodeLoader.buffer);
+ // rg.CheckRevision();
+ // rg.Init();
+ // rg.Bind(rg);
+
+ // nw4r::g3d::ResMdl mdl = rg.GetResMdl("cobCourse");
+ // nw4r::g3d::ResAnmVis anmResVis = rg.GetResAnmVis("cobCourse");
+
+ // renderer.nodeModel.setup(mdl, &allocator, 0x224, 1, 0);
+ renderer.nodeMatrix.identity();
+ // renderer.nodeColor.setup(mdl, anmResVis, &allocator, 0);
+ // renderer.nodeColor.bind(&renderer.nodeModel, anmResVis, 0);
+ // renderer.nodeModel.bindAnim(&renderer.nodeColor, 0.0f);
+ SetupTextures_MapObj(&renderer.nodeModel, 0);
+
allocator.unlink();
return true;
@@ -81,6 +99,18 @@ int dWMMap_c::onExecute() {
}
int dWMMap_c::onDraw() {
+
+ short rz = 0x6000;
+ short rx = 0x4000;
+ short ry = 0x8000;
+ renderer.nodeMatrix.translation(384.0, -504.0 + 4.0, 498.0);
+ renderer.nodeMatrix.applyRotationYXZ(&ry, &rx, &rz);
+ renderer.nodeModel.setDrawMatrix(renderer.nodeMatrix);
+ renderer.nodeModel.setScale(0.8f, 0.8f, 0.8f);
+ renderer.nodeModel.calcWorld(false);
+
+ renderer.nodeModel.scheduleForDrawing();
+
renderer.scheduleForDrawing();
bgModel.scheduleForDrawing();
@@ -108,17 +138,36 @@ void dWMMap_c::renderer_c::drawLayers() {
beginRendering();
+ bool cont = false;
for (int iLayer = data->layerCount - 1; iLayer >= 0; iLayer--) {
dKPLayer_s *layer = data->layers[iLayer];
renderMtx[2][3] += 2.0f;
+ cont = false;
+ for (int iNodes = dataCls->pathLayer->nodeCount - 1; iNodes >= 0; iNodes--) {
+ dKPNode_s *node = dataCls->pathLayer->nodes[iNodes];
+ bool unlock = node->isUnlocked();
+ if (!unlock) {
+ if (node->tileLayer == layer) { cont = true; break; }
+ if (node->doodadLayer == layer) { cont = true; break; }
+ }
+ }
+ for (int iPaths = dataCls->pathLayer->pathCount - 1; iPaths >= 0; iPaths--) {
+ dKPPath_s *path = dataCls->pathLayer->paths[iPaths];
+ if (!path->isAvailable) {
+ if (path->tileLayer == layer) { cont = true; break; }
+ if (path->doodadLayer == layer) { cont = true; break; }
+ }
+ }
+
+ if (cont) { continue; }
TileReport("Checking layer %d with type %d\n", iLayer, layer->type);
- if (layer->type == dKPLayer_s::OBJECTS)
+ if (layer->type == dKPLayer_s::OBJECTS)
renderTileLayer(layer, data->sectors);
else if (layer->type == dKPLayer_s::DOODADS)
renderDoodadLayer(layer);
- else if (layer->type == dKPLayer_s::PATHS)
- renderPathLayer(layer);
+ else if (layer->type == dKPLayer_s::PATHS)
+ renderPathLayer(layer);
}
endRendering();
@@ -266,13 +315,24 @@ void dWMMap_c::renderer_c::renderTileLayer(dKPLayer_s *layer, dKPLayer_s::sector
float coordY1 = yMult * (tileY + 2.0f);
float coordY2 = yMult * (tileY + 26.0f);
+
+ // GXSetVtxDesc(GX_VA_CLR0, GX_DIRECT);
+ // GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XY, GX_S16, 0);
+
GXBegin(GX_QUADS, GX_VTXFMT0, 4);
+ // GXColor1u32(0xFFFFFF80);
GXPosition2s16(worldX + 24, worldY - 24);
GXTexCoord2f32(coordX2, coordY2);
+
+ // GXColor1u32(0xFFFFFF80);
GXPosition2s16(worldX + 24, worldY);
GXTexCoord2f32(coordX2, coordY1);
+
+ // GXColor1u32(0xFFFFFF80);
GXPosition2s16(worldX, worldY);
GXTexCoord2f32(coordX1, coordY1);
+
+ // GXColor1u32(0xFFFFFF80);
GXPosition2s16(worldX, worldY - 24);
GXTexCoord2f32(coordX1, coordY2);
GXEnd();
@@ -421,10 +481,10 @@ void dWMMap_c::renderer_c::renderDoodadLayer(dKPLayer_s *layer) {
}
void dWMMap_c::renderer_c::renderPathLayer(dKPLayer_s *layer) {
- return;
+ // return;
- // for (int i = 0; i < layer->nodeCount; i++) {
- // dKPNode_s *node = layer->nodes[i];
+ for (int i = 0; i < layer->nodeCount; i++) {
+ dKPNode_s *node = layer->nodes[i];
// int world = node->levelNumber[0];
// int level = node->levelNumber[1];
@@ -459,16 +519,22 @@ void dWMMap_c::renderer_c::renderPathLayer(dKPLayer_s *layer) {
// else
// node->color.setCurrentFrame(3); // Red
- // node->matrix.translation(node->x, node->y, 500.0);
- // node->matrix.applyRotationYXZ(0, 0, 0);
- // node->model.setDrawMatrix(node->matrix);
- // node->model.setScale(1.0f, 1.0f, 1.0f);
- // node->model.calcWorld(false);
+ if (node->type == dKPNode_s::LEVEL) {
+ float nx = (float)node->x;
+ float ny = (float)node->y;
- // node->model.scheduleForDrawing();
- // }
-}
+ // OSReport("Rendering the node @ %f, %f", nx, ny);
+
+ // nodeMatrix.translation(node->x, node->y, 498.0);
+ // nodeMatrix.applyRotationYXZ(0, 0, 0);
+ // nodeModel.setDrawMatrix(nodeMatrix);
+ // nodeModel.setScale(1.0f, 1.0f, 1.0f);
+ // nodeModel.calcWorld(false);
+ // nodeModel.scheduleForDrawing();
+ }
+ }
+}
void dWMMap_c::renderer_c::endRendering() {
diff --git a/src/koopatlas/map.h b/src/koopatlas/map.h
index e951a41..9616f5c 100644
--- a/src/koopatlas/map.h
+++ b/src/koopatlas/map.h
@@ -36,6 +36,10 @@ class dWMMap_c : public dBase_c {
void drawOpa();
void drawXlu();
+ m3d::mdl_c nodeModel;
+ m3d::anmVis_c nodeColor;
+ mMtx nodeMatrix;
+
private:
void drawLayers();
diff --git a/src/koopatlas/mapdata.cpp b/src/koopatlas/mapdata.cpp
index 1fb8eb6..826d478 100644
--- a/src/koopatlas/mapdata.cpp
+++ b/src/koopatlas/mapdata.cpp
@@ -13,6 +13,14 @@ dKPPath_s *dKPNode_s::getOppositeExitTo(dKPPath_s *path) {
return 0;
}
+bool dKPNode_s::isUnlocked() {
+ for (int i = 0; i < 4; i++)
+ if (exits[i])
+ if (exits[i])
+ return true;
+ return false;
+}
+
int dKPLayer_s::findNodeID(dKPNode_s *node) {
for (int i = 0; i < nodeCount; i++)
@@ -22,10 +30,6 @@ int dKPLayer_s::findNodeID(dKPNode_s *node) {
return -1;
}
-
-
-
-
dKPMapData_c::dKPMapData_c() {
data = 0;
fixedUp = false;
@@ -144,26 +148,6 @@ void dKPMapData_c::fixup() {
if (node->type == dKPNode_s::CHANGE)
fixRef(node->destMap);
- // FORWARDS COMPATIBILITY:
- // else if (node->type == dKPNode_s::LEVEL) {
- // break;
-
- // node->allocator.link(-1, GameHeaps[0], 0, 0x20);
-
- // nw4r::g3d::ResFile rf(nodeLoader.buffer);
- // rf.CheckRevision();
- // rf.Init();
- // rf.Bind(rf);
-
- // nw4r::g3d::ResMdl mdl = rf.GetResMdl("cobCourse");
- // nw4r::g3d::ResAnmVis anmRes = rf.GetResAnmVis("cobCourse");
-
- // node->model.setup(mdl, &node->allocator, 0x224, 1, 0);
- // node->color.setup(mdl, anmRes, &node->allocator, 0);
- // node->color.bind(&node->model, anmRes, 0);
- // node->model.bindAnim(&node->color, 0.0f);
- // SetupTextures_MapObj(&node->model, 0);
- // }
}
break;
}
diff --git a/src/koopatlas/mapdata.h b/src/koopatlas/mapdata.h
index 8a199a6..9f40433 100644
--- a/src/koopatlas/mapdata.h
+++ b/src/koopatlas/mapdata.h
@@ -82,15 +82,9 @@ struct dKPNode_s {
return 0;
}
- dKPPath_s *getOppositeExitTo(dKPPath_s *path);
-
-
- // FORWARDS COMPATIBILITY:
+ bool isUnlocked();
- // mHeapAllocator_c allocator;
- // m3d::mdl_c model;
- // m3d::anmVis_c color;
- // mMtx matrix;
+ dKPPath_s *getOppositeExitTo(dKPPath_s *path);
};
struct dKPPath_s {
@@ -153,7 +147,6 @@ struct dKPLayer_s {
};
};
-
int findNodeID(dKPNode_s *node);
};
diff --git a/src/koopatlas/pathmanager.cpp b/src/koopatlas/pathmanager.cpp
index 8e0edac..cfdf2b7 100644
--- a/src/koopatlas/pathmanager.cpp
+++ b/src/koopatlas/pathmanager.cpp
@@ -67,6 +67,7 @@ void dWMPathManager_c::setup() {
for (int i = 0; i < pathLayer->pathCount; i++) {
dKPPath_s *path = pathLayer->paths[i];
+ OSReport("Path unlocked by %d-%d, unlock type %d, is available %d", path->unlockLevelNumber[0], path->unlockLevelNumber[1], path->unlockType, path->isAvailable);
if (path->unlockType > 0) {
u32 conds = save->GetLevelCondition(path->unlockLevelNumber[0] - 1, path->unlockLevelNumber[1] - 1);
@@ -74,6 +75,8 @@ void dWMPathManager_c::setup() {
path->isAvailable = true;
else if (path->unlockType == 2 && (conds & COND_SECRET))
path->isAvailable = true;
+ else
+ path->isAvailable = false;
}
}
SpammyReport("done\n");
@@ -105,6 +108,8 @@ void dWMPathManager_c::startMovementTo(dKPPath_s *path) {
dWMHud_c::instance->hidePointBar();
SpammyReport("point bar hidden\n");
+ if (!path->isAvailable) { return; }
+
SpammyReport("a\n");
isMoving = true;
reverseThroughPath = (path->end == currentNode);
@@ -141,6 +146,7 @@ void dWMPathManager_c::startMovementTo(dKPPath_s *path) {
player->rot.y = direction;
player->hasSound = false;
player->hasEffect = false;
+ moveSpeed = 3.0f;
switch (path->animation) {
@@ -177,22 +183,26 @@ void dWMPathManager_c::startMovementTo(dKPPath_s *path) {
player->startAnimation(jump, 1.0, 1.0, 0.0);
MapSoundPlayer(SoundRelatedClass, SE_PLY_JUMP, 1);
isJumping = true;
+ moveSpeed = 2.5f;
break;
case 5:
player->startAnimation(jump, 1.0, 10.0, 0.0);
MapSoundPlayer(SoundRelatedClass, SE_PLY_JUMP, 1);
isJumping = true;
+ moveSpeed = 2.5f;
break;
case 6:
player->startAnimation(jump, 1.0, 10.0, 0.0);
MapSoundPlayer(SoundRelatedClass, SE_PLY_JUMP, 1);
isJumping = true;
+ moveSpeed = 2.5f;
break;
case 7:
player->startAnimation(jump, 1.0, 10.0, 0.0);
MapSoundPlayer(SoundRelatedClass, SE_PLY_JUMP, 1);
isJumping = true;
SpawnEffect("Wm_mr_waterwave_out", 0, &player->pos, 0, &player->scale);
+ moveSpeed = 2.0f;
break;
// Climbing
@@ -201,18 +211,21 @@ void dWMPathManager_c::startMovementTo(dKPPath_s *path) {
player->rot.y = 0x8000;
player->hasSound = true;
player->soundName = SE_PLY_FOOTNOTE_CS_ROCK_CLIMB;
+ moveSpeed = 1.5f;
break;
case 9:
player->startAnimation(tree_climb, 1.2, 10.0, 0.0);
player->rot.y = 0xC000;
player->hasSound = true;
player->soundName = SE_PLY_FOOTNOTE_CS_ROCK_CLIMB;
+ moveSpeed = 1.5f;
break;
case 10:
player->startAnimation(tree_climb, 1.2, 10.0, 0.0);
player->rot.y = 0x4000;
player->hasSound = true;
player->soundName = SE_PLY_FOOTNOTE_CS_ROCK_CLIMB;
+ moveSpeed = 1.5f;
break;
// Others
@@ -222,6 +235,7 @@ void dWMPathManager_c::startMovementTo(dKPPath_s *path) {
player->hasEffect = true;
player->soundName = SE_PLY_SWIM;
player->effectName = "Wm_mr_waterswim";
+ moveSpeed = 2.0f;
break;
case 13:
player->startAnimation(Tjumped, 2.0, 0.0, 0.0);
@@ -230,16 +244,19 @@ void dWMPathManager_c::startMovementTo(dKPPath_s *path) {
player->startAnimation(b_dash2, 3.0, 10.0, 0.0);
player->hasSound = true;
player->soundName = SE_PLY_FOOTNOTE_DIRT;
+ moveSpeed = 5.0f;
break;
case 15:
player->startAnimation(wait, 2.0, 10.0, 0.0);
player->rot.y = 0x0000;
MapSoundPlayer(SoundRelatedClass, SE_PLY_DOKAN_IN_OUT, 1);
+ moveSpeed = 1.0f;
break;
case 16:
player->startAnimation(wait, 2.0, 10.0, 0.0);
player->rot.y = 0x8000;
MapSoundPlayer(SoundRelatedClass, SE_OBJ_DOOR_OPEN, 1);
+ moveSpeed = 0.2f;
break;
default:
OSReport("No animtaion?!");
@@ -260,7 +277,7 @@ void dWMPathManager_c::moveThroughPath() {
Vec move = (Vec){to->x - from->x, to->y - from->y, 0};
VECNormalize(&move, &move);
- VECScale(&move, &move, 3.0f);
+ VECScale(&move, &move, moveSpeed);
daWMPlayer_c *player = daWMPlayer_c::instance;
@@ -270,8 +287,10 @@ void dWMPathManager_c::moveThroughPath() {
float midpoint = (from->y + to->y) / 2;
float top, len;
- if (ys > ye) { len = ys - ye; top = ys - midpoint + 4.0; }
- else { len = ye - ys; top = ye - midpoint + 4.0; }
+ if (ys > ye) { len = ys - ye; top = ys - midpoint + 10.0; }
+ else { len = ye - ys; top = ye - midpoint + 10.0; }
+
+ if (len == 0.0) { len = 2.0; }
float a;
if (timer > 0.0) { a = -timer; }
diff --git a/src/koopatlas/pathmanager.h b/src/koopatlas/pathmanager.h
index 66c5e3b..0138161 100644
--- a/src/koopatlas/pathmanager.h
+++ b/src/koopatlas/pathmanager.h
@@ -29,6 +29,7 @@ class dWMPathManager_c {
HermiteKey keysY[3];
float timer;
bool isJumping;
+ float moveSpeed;
dKPPath_s *currentPath;
bool reverseThroughPath; // direction we are going through the path
diff --git a/src/koopatlas/player.cpp b/src/koopatlas/player.cpp
index 32cc684..4a15f94 100644
--- a/src/koopatlas/player.cpp
+++ b/src/koopatlas/player.cpp
@@ -37,8 +37,8 @@ int daWMPlayer_c::onDelete() {
int daWMPlayer_c::onExecute() {
this->modelHandler->update();
- this->modelHandler->setSRT(this->pos, this->rot, this->scale);
-
+ Vec modifiedPos = {pos.x, pos.y + jumpOffset, pos.z};
+ this->modelHandler->setSRT(modifiedPos, this->rot, this->scale);
if (hasEffect) { effect.spawn(effectName, 0, &pos, &rot, &scale); }
@@ -54,99 +54,10 @@ int daWMPlayer_c::onExecute() {
if (timer > 12) { timer = 0; }
}
- // #ifdef MARIO_OPTIONS
- // // Before we leave, do the debug movement stuff
- // int heldButtons = Remocon_GetButtons(GetActiveRemocon());
- // int nowPressed = Remocon_GetPressed(GetActiveRemocon());
- // char buf[100];
- // bool updated = false;
-
- // if (nowPressed & WPAD_LEFT) {
- // current_param--;
- // updated = true;
- // }
-
- // if (nowPressed & WPAD_RIGHT) {
- // current_param++;
- // updated = true;
- // }
-
- // if (current_param < 0)
- // current_param = 8;
-
- // if (current_param > 8)
- // current_param = 0;
-
- // float pos_mod = 0.0f;
- // short rot_mod = 0.0f;
- // float scale_mod = 0.0f;
- // if (nowPressed & WPAD_ONE) {
- // pos_mod -= 5.0f;
- // rot_mod -= 0x1000;
- // scale_mod -= 0.1f;
- // updated = true;
- // } else if (nowPressed & WPAD_TWO) {
- // pos_mod += 5.0f;
- // rot_mod += 0x1000;
- // scale_mod += 0.1f;
- // updated = true;
- // }
-
- // if (!updated) return true;
-
- // if (current_param == 0) {
- // pos.x += pos_mod;
- // sprintf(buf, "X position: %f", pos.x);
- // } else if (current_param == 1) {
- // pos.y += pos_mod;
- // sprintf(buf, "Y position: %f", pos.y);
- // } else if (current_param == 2) {
- // pos.z += pos_mod;
- // sprintf(buf, "Z position: %f", pos.z);
- // } else if (current_param == 3) {
- // rot.x += rot_mod;
- // sprintf(buf, "X rotation: 0x%04x", rot.x);
- // } else if (current_param == 4) {
- // rot.y += rot_mod;
- // sprintf(buf, "Y rotation: 0x%04x", rot.y);
- // } else if (current_param == 5) {
- // rot.z += rot_mod;
- // sprintf(buf, "Z rotation: 0x%04x", rot.z);
- // } else if (current_param == 6) {
- // scale.x += scale_mod;
- // sprintf(buf, "X scale: %f", scale.x);
- // } else if (current_param == 7) {
- // scale.y += scale_mod;
- // sprintf(buf, "Y scale: %f", scale.y);
- // } else if (current_param == 8) {
- // scale.z += scale_mod;
- // sprintf(buf, "Z scale: %f", scale.z);
- // }
-
- // dScNewerWorldMap_c::instance->SetTitle(buf);
- // #endif
-
return true;
}
int daWMPlayer_c::onDraw() {
- matrix.translation(pos.x, pos.y + jumpOffset, pos.z);
- matrix.applyRotationYXZ(&rot.x, &rot.y, &rot.z);
-
-
-
-
-
- OSReport("someVector: %f", this->modelHandler->mdlClass->someVector.x);
- this->modelHandler->mdlClass->someVector = (Vec){2.0,2.0,2.0};
-
- OSReport("someVectorB: %f", this->modelHandler->mdlClass->someVectorB.x);
- this->modelHandler->mdlClass->someVectorB = (Vec){2.0,2.0,2.0};
-
- OSReport("headOffs: %f", this->modelHandler->mdlClass->headOffs.x);
- this->modelHandler->mdlClass->headOffs = (Vec){2.0,2.0,2.0};
-
- this->modelHandler->setMatrix(matrix);
this->modelHandler->draw();
return true;