diff options
Diffstat (limited to 'src/koopatlas')
-rw-r--r-- | src/koopatlas/core.cpp | 2 | ||||
-rw-r--r-- | src/koopatlas/map.cpp | 57 | ||||
-rw-r--r-- | src/koopatlas/map.h | 8 | ||||
-rw-r--r-- | src/koopatlas/mapdata.cpp | 27 | ||||
-rw-r--r-- | src/koopatlas/mapdata.h | 3 | ||||
-rw-r--r-- | src/koopatlas/pathmanager.cpp | 30 | ||||
-rw-r--r-- | src/koopatlas/pathmanager.h | 1 |
7 files changed, 73 insertions, 55 deletions
diff --git a/src/koopatlas/core.cpp b/src/koopatlas/core.cpp index 6b1f290..42bf7c1 100644 --- a/src/koopatlas/core.cpp +++ b/src/koopatlas/core.cpp @@ -451,6 +451,8 @@ void dScKoopatlas_c::executeState_Normal() { } else if (nowPressed & WPAD_PLUS) { CSMENU_ACTIVE(this->csMenu) = true; state.setState(&StateID_CSMenu); + } else if (nowPressed & WPAD_A) { + pathManager.unlockAllPaths(); } pathManager.execute(); diff --git a/src/koopatlas/map.cpp b/src/koopatlas/map.cpp index a03d819..4d2bc1d 100644 --- a/src/koopatlas/map.cpp +++ b/src/koopatlas/map.cpp @@ -84,6 +84,10 @@ int dWMMap_c::onDraw() { renderer.scheduleForDrawing(); bgModel.scheduleForDrawing(); + + dKPMapData_c *dataCls = &dScKoopatlas_c::instance->mapData; + renderPathLayer(dataCls->pathLayer); + return true; } @@ -133,11 +137,9 @@ void dWMMap_c::renderer_c::drawLayers() { if (cont) { continue; } TileReport("Checking layer %d with type %d\n", iLayer, layer->type); if (layer->type == dKPLayer_s::OBJECTS) - renderTileLayer(layer, data->sectors); + renderTileLayer(layer, data->sectors, 255); else if (layer->type == dKPLayer_s::DOODADS) - renderDoodadLayer(layer); - else if (layer->type == dKPLayer_s::PATHS) - renderPathLayer(layer); + renderDoodadLayer(layer, 255); } endRendering(); @@ -207,7 +209,7 @@ void dWMMap_c::renderer_c::beginRendering() { GXSetTevColor(GX_TEVREG1, (GXColor){0,0,0,255}); } -void dWMMap_c::renderer_c::renderTileLayer(dKPLayer_s *layer, dKPLayer_s::sector_s *sectors) { +void dWMMap_c::renderer_c::renderTileLayer(dKPLayer_s *layer, dKPLayer_s::sector_s *sectors, int alpha) { //TileReport("Rendering layer %p\n", layer); // don't render it if we don't need to @@ -286,23 +288,15 @@ void dWMMap_c::renderer_c::renderTileLayer(dKPLayer_s *layer, dKPLayer_s::sector float coordY2 = yMult * (tileY + 26.0f); - // GXSetVtxDesc(GX_VA_CLR0, GX_DIRECT); - // GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XY, GX_S16, 0); - + GXSetTevColor(GX_TEVREG0, (GXColor){255,255,255,alpha}); + 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(); @@ -316,7 +310,7 @@ void dWMMap_c::renderer_c::renderTileLayer(dKPLayer_s *layer, dKPLayer_s::sector //TileReport("Layer complete\n"); } -void dWMMap_c::renderer_c::renderDoodadLayer(dKPLayer_s *layer) { +void dWMMap_c::renderer_c::renderDoodadLayer(dKPLayer_s *layer, int alpha) { for (int i = 0; i < layer->doodadCount; i++) { dKPDoodad_s *doodad = layer->doodads[i]; DoodadReport("Doodad @ %f,%f sized %f,%f with angle %f\n", doodad->x, doodad->y, doodad->width, doodad->height, doodad->angle); @@ -330,20 +324,19 @@ void dWMMap_c::renderer_c::renderDoodadLayer(dKPLayer_s *layer) { for (int j = 0; j < doodad->animationCount; j++) { dKPDoodad_s::animation_s *anim = &doodad->animations[j]; - // FORWARDS COMPATIBILITY: (has a ***) - // *** if (anim->delayOffset == 0) { + if (anim->delayOffset == 0) { u32 baseTick = anim->baseTick; if (baseTick == 0) { anim->baseTick = baseTick = GlobalTickCount; } u32 elapsed = GlobalTickCount - baseTick; - // *** u32 elapsedAdjusted = elapsed; + u32 elapsedAdjusted = elapsed; if (anim->isReversed) elapsed = anim->frameCount - 1 - elapsed; if (elapsed >= anim->frameCount) { - // *** if (elapsed >= (anim->frameCount + anim->delay)) { + if (elapsed >= (anim->frameCount + anim->delay)) { // we've reached the end switch (anim->loop) { @@ -365,13 +358,13 @@ void dWMMap_c::renderer_c::renderDoodadLayer(dKPLayer_s *layer) { anim->baseTick = GlobalTickCount; break; } - // *** } - // *** elapsedAdjusted = anim->frameCount; + } + elapsedAdjusted = anim->frameCount; } // now calculate the thing - // *** float progress = elapsedAdjusted / (float)anim->frameCount; - float progress = elapsed / (float)anim->frameCount; + float progress = elapsedAdjusted / (float)anim->frameCount; + // float progress = elapsed / (float)anim->frameCount; float value; switch (anim->curve) { @@ -415,10 +408,10 @@ void dWMMap_c::renderer_c::renderDoodadLayer(dKPLayer_s *layer) { // TODO break; } - // *** } - // *** else { - // *** anim->delayOffset -= 1; - // *** } + } + else { + anim->delayOffset -= 1; + } } } @@ -437,6 +430,7 @@ void dWMMap_c::renderer_c::renderDoodadLayer(dKPLayer_s *layer) { loadCamera(doodadMtx); loadTexture(doodad->texObj); + GXSetTevColor(GX_TEVREG0, (GXColor){255,255,255,alpha}); GXBegin(GX_QUADS, GX_VTXFMT1, 4); GXPosition2f32(halfW, -halfH); GXTexCoord2u8(255, 255); @@ -450,17 +444,12 @@ void dWMMap_c::renderer_c::renderDoodadLayer(dKPLayer_s *layer) { } } -void dWMMap_c::renderer_c::renderPathLayer(dKPLayer_s *layer) { +void dWMMap_c::renderPathLayer(dKPLayer_s *layer) { for (int i = 0; i < layer->nodeCount; i++) { dKPNode_s *node = layer->nodes[i]; if (node->type == dKPNode_s::LEVEL) { - // OSReport("Node Extra: %x", node->extra); - // float nx = (float)node->x; - // float ny = (float)node->y; - // OSReport("Node Extra: %x, model: %x, matrix: %x, pos: %f, %f", node->extra, node->extra->model, node->extra->matrix, nx, ny); - short rz = 0x6000; short rx = 0x4000; short ry = 0x8000; diff --git a/src/koopatlas/map.h b/src/koopatlas/map.h index e951a41..14c2b87 100644 --- a/src/koopatlas/map.h +++ b/src/koopatlas/map.h @@ -42,9 +42,8 @@ class dWMMap_c : public dBase_c { void beginRendering(); void endRendering(); - void renderTileLayer(dKPLayer_s *layer, dKPLayer_s::sector_s *sector); - void renderDoodadLayer(dKPLayer_s *layer); - void renderPathLayer(dKPLayer_s *layer); + void renderTileLayer(dKPLayer_s *layer, dKPLayer_s::sector_s *sector, int alpha); + void renderDoodadLayer(dKPLayer_s *layer, int alpha); void loadTexture(GXTexObj *obj); @@ -56,6 +55,7 @@ class dWMMap_c : public dBase_c { float baseZ; int minX, minY, maxX, maxY; + int unlockingAlpha; }; renderer_c renderer; @@ -66,6 +66,8 @@ class dWMMap_c : public dBase_c { mMtx bgMatrix; S16Vec thing; + void renderPathLayer(dKPLayer_s *layer); + static dWMMap_c *build(); static dWMMap_c *instance; }; diff --git a/src/koopatlas/mapdata.cpp b/src/koopatlas/mapdata.cpp index f65d038..9c84c4a 100644 --- a/src/koopatlas/mapdata.cpp +++ b/src/koopatlas/mapdata.cpp @@ -16,7 +16,7 @@ dKPPath_s *dKPNode_s::getOppositeExitTo(dKPPath_s *path) { bool dKPNode_s::isUnlocked() { for (int i = 0; i < 4; i++) if (exits[i]) - if (exits[i]) + if (exits[i]->isAvailable) return true; return false; } @@ -39,6 +39,8 @@ void dKPNode_s::setupNodeExtra() { const char *colour; + OSReport("Level %d-%d, isUnlocked: %d, exitComplete: %d", world, level, isUnlocked, exitComplete); + // Is it unlocked? if (!isUnlocked) colour = "g3d/black.brres"; @@ -56,7 +58,7 @@ void dKPNode_s::setupNodeExtra() { // Is it a shop? else if (level == 41) - const char *colour = "g3d/shop.brres"; + colour = "g3d/shop.brres"; // Is it complete? else if ((exitComplete) || (secretComplete)) { @@ -165,6 +167,8 @@ void dKPMapData_c::unloadTilesets() { } void dKPMapData_c::fixup() { + OSReport("Setting up Nodes"); + fixedUp = true; fixRef(data->layers); @@ -222,6 +226,25 @@ void dKPMapData_c::fixup() { // before we finish here, create the Node Extra classes + + // before the first off, do the unlocking. + SaveBlock *save = GetSaveFile()->GetBlock(-1); + for (int i = 0; i < pathLayer->pathCount; i++) { + dKPPath_s *path = pathLayer->paths[i]; + + if (path->unlockType > 0) { + u32 conds = save->GetLevelCondition(path->unlockLevelNumber[0] - 1, path->unlockLevelNumber[1] - 1); + + if (path->unlockType == 1 && (conds & COND_NORMAL)) + path->isAvailable = true; + else if (path->unlockType == 2 && (conds & COND_SECRET)) + path->isAvailable = true; + else + path->isAvailable = false; + } + } + + // first off, count how many we need... int count = 0; for (int nodeIdx = 0; nodeIdx < pathLayer->nodeCount; nodeIdx++) { diff --git a/src/koopatlas/mapdata.h b/src/koopatlas/mapdata.h index f3739a0..18dd9ee 100644 --- a/src/koopatlas/mapdata.h +++ b/src/koopatlas/mapdata.h @@ -31,8 +31,7 @@ struct dKPDoodad_s { int frameCount; AnimTypes type; int start, end; - // FORWARDS COMPATIBILITY: - // int delay, delayOffset; + int delay, delayOffset; u32 baseTick; bool isReversed; diff --git a/src/koopatlas/pathmanager.cpp b/src/koopatlas/pathmanager.cpp index 7457f99..41515a6 100644 --- a/src/koopatlas/pathmanager.cpp +++ b/src/koopatlas/pathmanager.cpp @@ -63,20 +63,6 @@ void dWMPathManager_c::setup() { // unlock all needed paths SpammyReport("Unlocking paths\n"); - for (int i = 0; i < pathLayer->pathCount; i++) { - dKPPath_s *path = pathLayer->paths[i]; - - if (path->unlockType > 0) { - u32 conds = save->GetLevelCondition(path->unlockLevelNumber[0] - 1, path->unlockLevelNumber[1] - 1); - - if (path->unlockType == 1 && (conds & COND_NORMAL)) - path->isAvailable = true; - else if (path->unlockType == 2 && (conds & COND_SECRET)) - path->isAvailable = true; - else - path->isAvailable = false; - } - } SpammyReport("done\n"); } @@ -374,3 +360,19 @@ void dWMPathManager_c::activatePoint() { } +void dWMPathManager_c::unlockAllPaths() { + + for (int i = 0; i < pathLayer->pathCount; i++) { + dKPPath_s *path = pathLayer->paths[i]; + path->isAvailable = true; + } + + // Can't change node models - the price we pay for not using anims + // for (int i = 0; i < pathLayer->nodeCount; i++) { + // dKPNode_s *node = pathLayer->nodes[i]; + // node->setupNodeExtra(); + // } + +} + + diff --git a/src/koopatlas/pathmanager.h b/src/koopatlas/pathmanager.h index 0138161..969bdb2 100644 --- a/src/koopatlas/pathmanager.h +++ b/src/koopatlas/pathmanager.h @@ -19,6 +19,7 @@ class dWMPathManager_c { void startMovementTo(dKPPath_s *path); void moveThroughPath(); void activatePoint(); + void unlockAllPaths(); dKPLayer_s *pathLayer; |