summaryrefslogtreecommitdiff
path: root/src/JSystem/J3DGraphBase/J3DShapeDraw.cpp
diff options
context:
space:
mode:
authorLuke Street <luke@street.dev>2026-03-01 15:35:36 -0700
committerGitHub <noreply@github.com>2026-03-01 14:35:36 -0800
commit9649319ec4926457ef85e6094f8207474c977c2d (patch)
tree1c5cd4c7cc4c1aee03f28921213da47f2775444d /src/JSystem/J3DGraphBase/J3DShapeDraw.cpp
parent6e149819e13b1f70ecbf8a4c66b030c17ffed2bb (diff)
Reorganize library code into `libs/` (#3119)
* Reorganize files into libs/{dolphin,JSystem,PowerPC_EABI_Support,revolution,TRK_MINNOW_DOLPHIN} * Update configure.py and project.py for new libs structure * Refactor `#include <dolphin/x.h>` -> `<x.h>` * Remove `__REVOLUTION_SDK__` forwards from dolphin * Fix dolphin/ references in revolution * Wrap `#include <dolphin.h>` in `!__REVOLUTION_SDK__` * Always build TRK against dolphin headers * Resolve revolution SDK header resolution issues
Diffstat (limited to 'src/JSystem/J3DGraphBase/J3DShapeDraw.cpp')
-rw-r--r--src/JSystem/J3DGraphBase/J3DShapeDraw.cpp82
1 files changed, 0 insertions, 82 deletions
diff --git a/src/JSystem/J3DGraphBase/J3DShapeDraw.cpp b/src/JSystem/J3DGraphBase/J3DShapeDraw.cpp
deleted file mode 100644
index 94d4534a82..0000000000
--- a/src/JSystem/J3DGraphBase/J3DShapeDraw.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-#include "JSystem/JSystem.h" // IWYU pragma: keep
-
-#include "JSystem/J3DGraphBase/J3DShapeDraw.h"
-#include "JSystem/JKernel/JKRHeap.h"
-#include <cstring>
-#include <stdint.h>
-#include <dolphin/gx.h>
-
-u32 J3DShapeDraw::countVertex(u32 stride) {
- u32 count = 0;
- u8* dlStart = (u8*)getDisplayList();
-
- for (u8* dl = dlStart; (dl - dlStart) < getDisplayListSize();) {
- u8 cmd = *(u8*)dl;
- dl++;
- if (cmd != GX_TRIANGLEFAN && cmd != GX_TRIANGLESTRIP)
- break;
- int vtxNum = *((u16*)(dl));
- dl += 2;
- count += vtxNum;
- dl = (u8*)dl + stride * vtxNum;
- }
-
- return count;
-}
-
-void J3DShapeDraw::addTexMtxIndexInDL(u32 stride, u32 attrOffs, u32 valueBase) {
- u32 byteNum = countVertex(stride);
- u32 oldSize = mDisplayListSize;
- u32 newSize = ALIGN_NEXT(oldSize + byteNum, 0x20);
- u8* newDLStart = new (0x20) u8[newSize];
- u8* oldDLStart = (u8*)mDisplayList;
- u8* oldDL = oldDLStart;
- u8* newDL = newDLStart;
-
- for (; (oldDL - oldDLStart) < mDisplayListSize;) {
- // Copy command
- u8 cmd = *(u8*)oldDL;
- oldDL++;
- *newDL++ = cmd;
-
- if (cmd != GX_TRIANGLEFAN && cmd != GX_TRIANGLESTRIP)
- break;
-
- // Copy count
- int vtxNum = *(u16*)oldDL;
- oldDL += 2;
- *(u16*)newDL = vtxNum;
- newDL += 2;
-
- for (int i = 0; i < vtxNum; i++) {
- u8* oldDLVtx = &oldDL[stride * i];
- u8 pnmtxidx = *oldDLVtx;
- memcpy(newDL, oldDLVtx, (int)attrOffs);
- newDL += attrOffs;
- *newDL++ = valueBase + pnmtxidx;
- memcpy(newDL, oldDLVtx + attrOffs, stride - attrOffs);
- newDL += (stride - attrOffs);
- }
-
- oldDL = (u8*)oldDL + stride * vtxNum;
- }
-
- u32 realSize = ALIGN_NEXT((uintptr_t)newDL - (uintptr_t)newDLStart, 0x20);
- for (; (newDL - newDLStart) < newSize; newDL++)
- *newDL = 0;
-
- mDisplayListSize = realSize;
- mDisplayList = newDLStart;
- DCStoreRange(newDLStart, mDisplayListSize);
-}
-
-J3DShapeDraw::J3DShapeDraw(const u8* displayList, u32 displayListSize) {
- mDisplayList = (void*)displayList;
- mDisplayListSize = displayListSize;
-}
-
-void J3DShapeDraw::draw() const {
- GXCallDisplayList(mDisplayList, mDisplayListSize);
-}
-
-J3DShapeDraw::~J3DShapeDraw() {}