Skip to content

Commit b37bdac

Browse files
committed
Add GXPosition1x16 and GXPosition3f32
1 parent 0fce877 commit b37bdac

File tree

2 files changed

+46
-38
lines changed

2 files changed

+46
-38
lines changed

ttyd-tools/rel/include/gc/gx.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
22

3+
#include <gc/ppc.h>
34
#include <gc/mtx.h>
45

56
#include <cstdint>
@@ -361,6 +362,19 @@ struct GXTexObj
361362

362363
static_assert(sizeof(GXTexObj) == 0x20);
363364

365+
// Inlined GX functions
366+
static inline void GXPosition1x16(const uint16_t x)
367+
{
368+
gc::ppc::writeGatherPipe.u16 = x;
369+
}
370+
371+
static inline void GXPosition3f32(const float x, const float y, const float z)
372+
{
373+
gc::ppc::writeGatherPipe.f32 = x;
374+
gc::ppc::writeGatherPipe.f32 = y;
375+
gc::ppc::writeGatherPipe.f32 = z;
376+
}
377+
364378
extern "C" {
365379

366380
void GXSetVtxDesc(GXAttribute attribute, GXAttributeType type);
@@ -399,7 +413,7 @@ void GXSetAlphaUpdate(bool updateEnable);
399413

400414
void GXSetZMode(bool compareEnable, GXCompare func, bool updateEnable);
401415
void GXSetProjection(const gc::mtx::mtx44 mtx, GXProjectionType type);
402-
void GXLoadPosMtxImm(const gc::mtx::mtx34 mtx, uint32_t id);
416+
void GXLoadPosMtxImm(const gc::mtx::mtx34 mtx, GXTexMtxType id);
403417
void GXSetCurrentMtx(uint32_t id);
404418
void GXLoadTexMtxImm(const gc::mtx::mtxUnk4 mtx, uint32_t id, GXTexMtxType type);
405419

ttyd-tools/rel/source/draw.cpp

Lines changed: 31 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6257,14 +6257,8 @@ void Mod::drawArtAttackHitboxes(ttyd::dispdrv::CameraId cameraId)
62576257

62586258
// Draw the line from corner 1 to corner 2
62596259
gc::gx::GXBegin(gc::gx::GXPrimitive::GX_LINES, gc::gx::GXVtxFmt::GX_VTXFMT0, 2);
6260-
6261-
gc::ppc::writeGatherPipe.f32 = ScreenPointOutLineStart[0];
6262-
gc::ppc::writeGatherPipe.f32 = ScreenPointOutLineStart[1];
6263-
gc::ppc::writeGatherPipe.f32 = 0;
6264-
6265-
gc::ppc::writeGatherPipe.f32 = ScreenPointOutLineEnd[0];
6266-
gc::ppc::writeGatherPipe.f32 = ScreenPointOutLineEnd[1];
6267-
gc::ppc::writeGatherPipe.f32 = 0;
6260+
gc::gx::GXPosition3f32(ScreenPointOutLineStart[0], ScreenPointOutLineStart[1], 0.f);
6261+
gc::gx::GXPosition3f32(ScreenPointOutLineEnd[0], ScreenPointOutLineEnd[1], 0.f);
62686262
}
62696263
}
62706264
}
@@ -6627,7 +6621,7 @@ void Mod::errorHandler(uint16_t error, gc::OSContext::OSContext *context, uint32
66276621

66286622
gc::gx::GXLoadPosMtxImm(
66296623
MtxFontSize,
6630-
gc::gx::GXPosNormMtx::GX_PNMTX0);
6624+
gc::gx::GXTexMtxType::GX_MTX2x4);
66316625

66326626
gc::gx::GXSetCurrentMtx(gc::gx::GXPosNormMtx::GX_PNMTX0);
66336627

@@ -6641,41 +6635,41 @@ void Mod::errorHandler(uint16_t error, gc::OSContext::OSContext *context, uint32
66416635
uint16_t CellWidth = tempFontData->cellWidth;
66426636
uint16_t CellHeight = tempFontData->cellHeight;
66436637

6644-
int16_t ImagePosLeft = static_cast<int16_t>(ImagePosX);
6645-
int16_t ImagePosRight = static_cast<int16_t>(ImagePosLeft + CellWidth);
6646-
int16_t ImagePosTop = static_cast<int16_t>(ImagePosY);
6647-
int16_t ImagePosBottom = static_cast<int16_t>(ImagePosTop + CellHeight);
6638+
uint16_t ImagePosLeft = static_cast<uint16_t>(ImagePosX);
6639+
uint16_t ImagePosRight = static_cast<uint16_t>(ImagePosLeft + CellWidth);
6640+
uint16_t ImagePosTop = static_cast<uint16_t>(ImagePosY);
6641+
uint16_t ImagePosBottom = static_cast<uint16_t>(ImagePosTop + CellHeight);
66486642

6649-
int16_t TextPosLeft = static_cast<int16_t>(textPosX);
6650-
int16_t TextPosRight = static_cast<int16_t>(TextPosLeft + CellWidth);
6651-
int16_t TextPosTop = static_cast<int16_t>(textPosY);
6652-
int16_t TextPosBottom = static_cast<int16_t>(TextPosTop + CellHeight);
6643+
uint16_t TextPosLeft = static_cast<uint16_t>(textPosX);
6644+
uint16_t TextPosRight = static_cast<uint16_t>(TextPosLeft + CellWidth);
6645+
uint16_t TextPosTop = static_cast<uint16_t>(textPosY);
6646+
uint16_t TextPosBottom = static_cast<uint16_t>(TextPosTop + CellHeight);
66536647

66546648
// Draw the images and text
6655-
gc::ppc::writeGatherPipe.s16 = TextPosLeft;
6656-
gc::ppc::writeGatherPipe.s16 = TextPosTop;
6657-
gc::ppc::writeGatherPipe.s16 = 0;
6649+
gc::gx::GXPosition1x16(TextPosLeft);
6650+
gc::gx::GXPosition1x16(TextPosTop);
6651+
gc::gx::GXPosition1x16(0);
66586652

6659-
gc::ppc::writeGatherPipe.s16 = ImagePosLeft;
6660-
gc::ppc::writeGatherPipe.s16 = ImagePosTop;
6661-
gc::ppc::writeGatherPipe.s16 = TextPosRight;
6662-
gc::ppc::writeGatherPipe.s16 = TextPosTop;
6663-
gc::ppc::writeGatherPipe.s16 = 0;
6653+
gc::gx::GXPosition1x16(ImagePosLeft);
6654+
gc::gx::GXPosition1x16(ImagePosTop);
6655+
gc::gx::GXPosition1x16(TextPosRight);
6656+
gc::gx::GXPosition1x16(TextPosTop);
6657+
gc::gx::GXPosition1x16(0);
66646658

6665-
gc::ppc::writeGatherPipe.s16 = ImagePosRight;
6666-
gc::ppc::writeGatherPipe.s16 = ImagePosTop;
6667-
gc::ppc::writeGatherPipe.s16 = TextPosRight;
6668-
gc::ppc::writeGatherPipe.s16 = TextPosBottom;
6669-
gc::ppc::writeGatherPipe.s16 = 0;
6659+
gc::gx::GXPosition1x16(ImagePosRight);
6660+
gc::gx::GXPosition1x16(ImagePosTop);
6661+
gc::gx::GXPosition1x16(TextPosRight);
6662+
gc::gx::GXPosition1x16(TextPosBottom);
6663+
gc::gx::GXPosition1x16(0);
66706664

6671-
gc::ppc::writeGatherPipe.s16 = ImagePosRight;
6672-
gc::ppc::writeGatherPipe.s16 = ImagePosBottom;
6673-
gc::ppc::writeGatherPipe.s16 = TextPosLeft;
6674-
gc::ppc::writeGatherPipe.s16 = TextPosBottom;
6675-
gc::ppc::writeGatherPipe.s16 = 0;
6665+
gc::gx::GXPosition1x16(ImagePosRight);
6666+
gc::gx::GXPosition1x16(ImagePosBottom);
6667+
gc::gx::GXPosition1x16(TextPosLeft);
6668+
gc::gx::GXPosition1x16(TextPosBottom);
6669+
gc::gx::GXPosition1x16(0);
66766670

6677-
gc::ppc::writeGatherPipe.s16 = ImagePosLeft;
6678-
gc::ppc::writeGatherPipe.s16 = ImagePosBottom;
6671+
gc::gx::GXPosition1x16(ImagePosLeft);
6672+
gc::gx::GXPosition1x16(ImagePosBottom);
66796673

66806674
textPosX += ImageWidth;
66816675
}

0 commit comments

Comments
 (0)