From 226ba1477a131bd15d3812d52a8da1f834dbdf61 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Thu, 12 Aug 2021 13:01:36 +1000 Subject: [PATCH] - Blood: Add interpolation repair for `kQAVREMDOWN1` (res_id: 33). --- source/games/blood/src/qav.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/source/games/blood/src/qav.cpp b/source/games/blood/src/qav.cpp index 3e573b264..861d87604 100644 --- a/source/games/blood/src/qav.cpp +++ b/source/games/blood/src/qav.cpp @@ -631,6 +631,39 @@ static void qavRepairTileData(QAV* pQAV) pQAV->frames[1].tiles[3].x += pQAV->frames[1].tiles[1].x - pQAV->frames[2].tiles[1].x; pQAV->frames[1].tiles[3].y += pQAV->frames[1].tiles[1].y - pQAV->frames[2].tiles[1].y; break; + case kQAVREMDOWN1: + // REMDOWN1 has several tile indices that require repairs to avoid needing its own interpolation callback. + // Additionally, there are missing frames crucial to a proper interpolation experience. + + // For frame 1, move tile index 2 and 3 around. + backup = pQAV->frames[1].tiles[2]; + pQAV->frames[1].tiles[2] = pQAV->frames[1].tiles[3]; + pQAV->frames[1].tiles[3] = backup; + + // For frame 0, clone frame 1 tile index 3 and adjust x/y coordinates + // using difference between frame 0 and 1's tile index 1. + pQAV->frames[0].tiles[3] = pQAV->frames[1].tiles[3]; + pQAV->frames[0].tiles[3].x += pQAV->frames[0].tiles[1].x - pQAV->frames[1].tiles[1].x; + pQAV->frames[0].tiles[3].y += pQAV->frames[0].tiles[1].y - pQAV->frames[1].tiles[1].y; + + // For frame 4, move tile index 1 into 2. + pQAV->frames[4].tiles[2] = pQAV->frames[4].tiles[1]; + + // For frame 5, move tile index 0 into 2. + pQAV->frames[5].tiles[2] = pQAV->frames[5].tiles[0]; + + // Clone frame 3 tile index 0 and 1 into frames 4 and 5, and adjust x/y coordinates + // using difference between frames 4 and 3 and 5 and 4 on looped tile index. + for (i = 4; i < 6; i++) + { + for (j = 0; j < 2; j++) + { + pQAV->frames[i].tiles[j] = pQAV->frames[i - 1].tiles[j]; + pQAV->frames[i].tiles[j].x += pQAV->frames[i - 1].tiles[j].x - pQAV->frames[i - 2].tiles[j].x; + pQAV->frames[i].tiles[j].y += pQAV->frames[i - 1].tiles[j].y - pQAV->frames[i - 2].tiles[j].y; + } + } + break; default: return; }