From 933ba8a7087dd98a58036b7eb6ca6f12a89a8947 Mon Sep 17 00:00:00 2001 From: fgsfds Date: Sun, 20 Aug 2023 15:44:01 +0200 Subject: [PATCH] port: swap all portal vertex batches actually fixes #43 credit to Ryan for the patch --- port/src/preprocess.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/port/src/preprocess.c b/port/src/preprocess.c index cfe9e736d..527810018 100644 --- a/port/src/preprocess.c +++ b/port/src/preprocess.c @@ -1307,14 +1307,18 @@ void preprocessBgSection1(u8 *data, u32 ofs) { ++numportals; } + s32 maxbatchnum = 0; for (s32 i = 0; i < numportals; ++i) { PD_SWAP_VAL(portals[i].verticesoffset); PD_SWAP_VAL(portals[i].roomnum1); PD_SWAP_VAL(portals[i].roomnum2); + if (portals[i].verticesoffset > maxbatchnum) { + maxbatchnum = portals[i].verticesoffset; + } } uintptr_t pvoffset = sizeof(portals[0]) * (numportals + 1); - for (s32 i = 0; i < numportals; i++) { + for (s32 i = 0; i <= maxbatchnum; i++) { struct portalvertices *pverts = PD_PTR_BASE(pvoffset, portals); for (u32 j = 0; j < pverts->count; ++j) { PD_SWAP_VAL(pverts->vertices[j]);