From e12b1713576544fdda756a3ca8831642562ea921 Mon Sep 17 00:00:00 2001 From: Treeki Date: Tue, 27 Mar 2012 21:37:54 +0200 Subject: brought Koopatlas engine up to date and compiling --- src/koopatlas/camera.cpp | 8 ++++++-- src/koopatlas/map.cpp | 2 -- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/koopatlas/camera.cpp b/src/koopatlas/camera.cpp index 47b68a5..c13db56 100644 --- a/src/koopatlas/camera.cpp +++ b/src/koopatlas/camera.cpp @@ -69,7 +69,7 @@ int dWorldCamera_c::onExecute() { int heldButtons = Remocon_GetButtons(GetActiveRemocon()); if (heldButtons & WPAD_MINUS) { bool change = false; - if (heldButtons & WPAD_LEFT) { + /*if (heldButtons & WPAD_LEFT) { currentX -= 8.0f; change = true; } @@ -84,7 +84,7 @@ int dWorldCamera_c::onExecute() { if (heldButtons & WPAD_DOWN) { currentY -= 8.0f; change = true; - } + }*/ if (heldButtons & WPAD_B) { zoomLevel -= 0.10f; change = true; @@ -96,6 +96,10 @@ int dWorldCamera_c::onExecute() { if (change) { } } + daWMPlayer_c *player = daWMPlayer_c::instance; + currentX = player->pos.x; + currentY = player->pos.y; + calculateScreenGeometry(); doStuff(10000.0); generateCameraMatrices(); diff --git a/src/koopatlas/map.cpp b/src/koopatlas/map.cpp index 258cf7c..5e2b813 100644 --- a/src/koopatlas/map.cpp +++ b/src/koopatlas/map.cpp @@ -41,8 +41,6 @@ dWMMap_c::dWMMap_c() { int dWMMap_c::onCreate() { renderer.allocator.setup(GameHeaps[0], 0x20); bool result = renderer.setup(&renderer.allocator); - if (result) - else bgMatrix.translation(1140.0f, -2910.0f, -500.0f); s16 rot = 0x4000; -- cgit v1.2.3 From 5e8e92cd8f403cbfebc4469a1aee252212e42045 Mon Sep 17 00:00:00 2001 From: Treeki Date: Tue, 27 Mar 2012 21:38:52 +0200 Subject: Kamek/Newer now support dynamic linking --- src/koopatlas/core.cpp | 1 + src/prolog.S | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/koopatlas/core.cpp b/src/koopatlas/core.cpp index f7acf00..de06453 100644 --- a/src/koopatlas/core.cpp +++ b/src/koopatlas/core.cpp @@ -175,6 +175,7 @@ bool WMInit_LoadResources2(void *ptr) { wm->mapPath = wm->getMapNameForIndex(wm->currentMapID); if (wm->mapPath == 0) wm->mapPath = wm->getMapNameForIndex(0); + OSReport("Load map: %s\n", wm->mapPath); } return wm->mapData.load(wm->mapPath); diff --git a/src/prolog.S b/src/prolog.S index 38bcb6b..e86bfa3 100644 --- a/src/prolog.S +++ b/src/prolog.S @@ -61,7 +61,7 @@ startLoop: .data PMsg: - .string "Newer Super Mario Bros. Wii - Hacks by Treeki and Tempus 2009-2011\n.ctors: %p - %p\n" + .string "Newer Super Mario Bros. Wii - Hacks by Treeki and Tempus 2009-2012\n.ctors: %p - %p\n" PMsg2: .string "%d inits called\n" -- cgit v1.2.3 From 053170b827defd19db852a9caa647c9a469e417b Mon Sep 17 00:00:00 2001 From: Treeki Date: Wed, 28 Mar 2012 01:23:46 +0200 Subject: fixes to WM code, and mHeap namespace --- src/koopatlas/core.cpp | 3 ++- src/koopatlas/core.h | 4 ++-- src/koopatlas/map.cpp | 9 ++++++--- src/koopatlas/mapdata.cpp | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/koopatlas/core.cpp b/src/koopatlas/core.cpp index de06453..5e15d99 100644 --- a/src/koopatlas/core.cpp +++ b/src/koopatlas/core.cpp @@ -230,7 +230,7 @@ bool WMInit_SetupExtra(void *ptr) { wm->player->modelHandler->mdlClass->startAnimation(0, 1.2f, 10.0f, 0.0f); dKPNode_s *cNode = wm->pathManager.currentNode; - wm->player->pos = (Vec){cNode->x, -cNode->y, wm->player->pos.y}; + wm->player->pos = (Vec){cNode->x, -cNode->y, wm->player->pos.z}; // is last param correct? must check :/ wm->map = (dWMMap_c*)CreateParentedObject(WM_MAP, wm, 0, 0); @@ -858,6 +858,7 @@ u32 dScKoopatlas_c::iterateMapList(u32(*callback)(u32,const char *,int,int), u32 while (true) { u8 chr = *ptr; if (chr == 13) { + *ptr = 0; ++ptr; continue; } diff --git a/src/koopatlas/core.h b/src/koopatlas/core.h index 6a76cc4..fc517b2 100644 --- a/src/koopatlas/core.h +++ b/src/koopatlas/core.h @@ -19,13 +19,13 @@ #ifdef WM_DEBUGGING #define MapReport OSReport #else -inline void MapReport(const char *str, ...) { } +#define MapReport(...) #endif #ifdef WM_SPAMMY_DEBUGGING #define SpammyReport OSReport #else -inline void SpammyReport(const char *str, ...) { } +#define SpammyReport(...) #endif void NewerMapDrawFunc(); diff --git a/src/koopatlas/map.cpp b/src/koopatlas/map.cpp index 5e2b813..fa5c120 100644 --- a/src/koopatlas/map.cpp +++ b/src/koopatlas/map.cpp @@ -6,18 +6,21 @@ //#define DOODAD_DEBUGGING #ifdef TILE_DEBUGGING +#define TileReport OSReport #else -inline void TileReport(const char *str, ...) { } +#define TileReport(...) #endif #ifdef BOUND_DEBUGGING +#define BoundReport OSReport #else -inline void BoundReport(const char *str, ...) { } +#define BoundReport(...) #endif #ifdef DOODAD_DEBUGGING +#define DoodadReport OSReport #else -inline void DoodadReport(const char *str, ...) { } +#define DoodadReport(...) #endif dWMMap_c *dWMMap_c::instance = 0; diff --git a/src/koopatlas/mapdata.cpp b/src/koopatlas/mapdata.cpp index eaf9c75..6838741 100644 --- a/src/koopatlas/mapdata.cpp +++ b/src/koopatlas/mapdata.cpp @@ -40,7 +40,7 @@ dKPMapData_c::~dKPMapData_c() { } bool dKPMapData_c::load(const char *filename) { - data = (dKPMapFile_s*)m_fileLoader.load(filename); + data = (dKPMapFile_s*)m_fileLoader.load(filename, 0, mHeap::archiveHeap); if (data == 0) return false; -- cgit v1.2.3 From fc3975a42b30566bb542cb06bbd5f7c2da90f79a Mon Sep 17 00:00:00 2001 From: Treeki Date: Wed, 28 Mar 2012 04:41:23 +0200 Subject: support for optimised tilesets --- src/koopatlas/map.cpp | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/koopatlas/map.cpp b/src/koopatlas/map.cpp index fa5c120..f4b953c 100644 --- a/src/koopatlas/map.cpp +++ b/src/koopatlas/map.cpp @@ -142,9 +142,11 @@ void dWMMap_c::renderer_c::beginRendering() { GXSetVtxDesc(GX_VA_POS, GX_DIRECT); GXSetVtxDesc(GX_VA_TEX0, GX_DIRECT); + // Tiles GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XY, GX_S16, 0); - GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_U8, 8); + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0); + // Doodads GXSetVtxAttrFmt(GX_VTXFMT1, GX_VA_POS, GX_POS_XY, GX_F32, 0); GXSetVtxAttrFmt(GX_VTXFMT1, GX_VA_TEX0, GX_TEX_ST, GX_U8, 8); @@ -249,19 +251,28 @@ void dWMMap_c::renderer_c::renderTileLayer(dKPLayer_s *layer, dKPLayer_s::sector s16 worldX = (worldSectorX | inX) * 24; s16 worldY = -((worldSectorY | inY) * 24); - u8 tileX = (tileID & 0x1F) * 8; - u8 tileY = ((tileID & 0x1E0) / 32) * 16; TileReport("Drawing tile %d at %d,%d\n", tileID, worldX, worldY); + + float tileX = (float)((tileID & 0x1F) * 28); + float tileY = (float)(((tileID & 0x1E0) >> 5) * 28); + + float xMult = (1.0f / 896.0f); + float yMult = (1.0f / 448.0f); + + float coordX1 = xMult * (tileX + 2.0f); + float coordX2 = xMult * (tileX + 26.0f); + float coordY1 = yMult * (tileY + 2.0f); + float coordY2 = yMult * (tileY + 26.0f); GXBegin(GX_QUADS, GX_VTXFMT0, 4); GXPosition2s16(worldX + 24, worldY - 24); - GXTexCoord2u8(tileX + 7, tileY + 14); + GXTexCoord2f32(coordX2, coordY2); GXPosition2s16(worldX + 24, worldY); - GXTexCoord2u8(tileX + 7, tileY + 2); + GXTexCoord2f32(coordX2, coordY1); GXPosition2s16(worldX, worldY); - GXTexCoord2u8(tileX + 1, tileY + 2); + GXTexCoord2f32(coordX1, coordY1); GXPosition2s16(worldX, worldY - 24); - GXTexCoord2u8(tileX + 1, tileY + 14);//*/ + GXTexCoord2f32(coordX1, coordY2); GXEnd(); } } -- cgit v1.2.3 From 8ad6a04bb5addbcb33a3bbd65a9435069092b69b Mon Sep 17 00:00:00 2001 From: Treeki Date: Thu, 29 Mar 2012 04:14:45 +0200 Subject: magic platform hax requested by antnee --- src/magicplatform.cpp | 100 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 99 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/magicplatform.cpp b/src/magicplatform.cpp index 924d849..e9fa940 100644 --- a/src/magicplatform.cpp +++ b/src/magicplatform.cpp @@ -12,6 +12,10 @@ class daEnMagicPlatform_c : public dEn_c { // Settings u8 rectID, moveSpeed, moveDirection, moveLength; + u8 moveDelay, currentMoveDelay; + + bool doesMoveInfinitely; + float moveMin, moveMax, moveDelta, moveBaseDelta; float *moveTarget; @@ -41,12 +45,87 @@ daEnMagicPlatform_c *daEnMagicPlatform_c::build() { return c; } +extern "C" void HurtMarioBecauseOfBeingSquashed(void *mario, dStageActor_c *squasher, int type); + +static void PhysCB1(daEnMagicPlatform_c *one, dStageActor_c *two) { + if (two->stageActorType != 1) + return; + + // if left/right + if (one->moveDirection <= 1) + return; + + if (one->pos_delta.y > 0.0f) + HurtMarioBecauseOfBeingSquashed(two, one, 1); + else + HurtMarioBecauseOfBeingSquashed(two, one, 9); +} + +static void PhysCB2(daEnMagicPlatform_c *one, dStageActor_c *two) { + if (two->stageActorType != 1) + return; + + // if left/right + if (one->moveDirection <= 1) + return; + + if (one->pos_delta.y < 0.0f) + HurtMarioBecauseOfBeingSquashed(two, one, 2); + else + HurtMarioBecauseOfBeingSquashed(two, one, 10); +} + +static void PhysCB3(daEnMagicPlatform_c *one, dStageActor_c *two, bool unkMaybeNotBool) { + if (two->stageActorType != 1) + return; + + // if left/right + if (one->moveDirection <= 1) + return; + + if (unkMaybeNotBool) { + if (one->pos_delta.x > 0.0f) + HurtMarioBecauseOfBeingSquashed(two, one, 6); + else + HurtMarioBecauseOfBeingSquashed(two, one, 12); + } else { + if (one->pos_delta.x < 0.0f) + HurtMarioBecauseOfBeingSquashed(two, one, 5); + else + HurtMarioBecauseOfBeingSquashed(two, one, 11); + } +} + +static bool PhysCB4(daEnMagicPlatform_c *one, dStageActor_c *two) { + return (one->pos_delta.y > 0.0f); +} + +static bool PhysCB5(daEnMagicPlatform_c *one, dStageActor_c *two) { + return (one->pos_delta.y < 0.0f); +} + +static bool PhysCB6(daEnMagicPlatform_c *one, dStageActor_c *two, bool unkMaybeNotBool) { + if (unkMaybeNotBool) { + if (one->pos_delta.x > 0.0f) + return true; + } else { + if (one->pos_delta.x < 0.0f) + return true; + } + return false; +} + int daEnMagicPlatform_c::onCreate() { rectID = settings & 0xFF; + moveSpeed = (settings & 0xF00) >> 8; moveDirection = (settings & 0x3000) >> 12; moveLength = ((settings & 0xF0000) >> 16) + 1; + moveDelay = ((settings & 0xF00000) >> 20) * 6; + + doesMoveInfinitely = (settings & 0x10000000); + setupMovement(); findSourceArea(); @@ -56,7 +135,11 @@ int daEnMagicPlatform_c::onCreate() { float fHeight = height * 16.0f; physics.setup(this, 0.0f, 0.0f, fWidth, -fHeight, - 0, 0, 0/*&PhysCB1, &PhysCB2, &PhysCB3*/, 1, 0, 0); + &PhysCB1, &PhysCB2, &PhysCB3, 1, 0, 0); + + physics.callback1 = &PhysCB4; + physics.callback2 = &PhysCB5; + physics.callback3 = &PhysCB6; physics.addToList(); @@ -77,6 +160,9 @@ int daEnMagicPlatform_c::onExecute() { updateTilePositions(); physics.update(); + if (doesMoveInfinitely) + checkZoneBoundaries(0); + return 1; } @@ -119,6 +205,8 @@ void daEnMagicPlatform_c::setupMovement() { } else { isMoving = false; } + + currentMoveDelay = 0; } void daEnMagicPlatform_c::handleMovement() { @@ -145,12 +233,21 @@ void daEnMagicPlatform_c::handleMovement() { if (!isMoving) return; + if (currentMoveDelay > 0) { + currentMoveDelay--; + return; + } + // Do it bool goesForward = (moveDelta > 0.0f); bool reachedEnd = false; *moveTarget += moveDelta; + // if we're set to move infinitely, never stop + if (doesMoveInfinitely) + return; + if (goesForward) { if (*moveTarget >= moveMax) { *moveTarget = moveMax; @@ -175,6 +272,7 @@ void daEnMagicPlatform_c::handleMovement() { } else { // Otherwise, reverse moveDelta = -moveDelta; + currentMoveDelay = moveDelay; } } } -- cgit v1.2.3