2ship2harkinian/mm/2s2h/ShipUtils.cpp
Archez 25887952c9
Some checks failed
generate-builds / generate-2ship-otr (push) Failing after 0s
generate-builds / build-macos (push) Has been skipped
generate-builds / build-linux (push) Has been skipped
generate-builds / build-windows (push) Has been skipped
[Enhancement] Actor Nametags (#746)
* add new GI hooks

* move collision viewer to draw hook

* actor viewer tweaks; prevent crash when actors are killed

* add ShipUtils

* add actor name tags

* add debug name tags to actor viewer

* fixes

* headers?

* cleanup actor viewer

* Add more options for actor name tags

* headers

* headers

* ditch fmt::join cause linux package managers use old spdlog/fmt

* just a little more cleanup
2024-09-13 10:10:59 -04:00

57 lines
1.6 KiB
C++

#include "ShipUtils.h"
#include <libultraship/libultra.h>
#include "PR/ultratypes.h"
#include "assets/2s2h_assets.h"
extern "C" {
#include "macros.h"
extern f32 sNESFontWidths[160];
extern const char* fontTbl[156];
}
// Build vertex coordinates for a quad command
// In order of top left, top right, bottom left, then bottom right
// Supports flipping the texture horizontally
extern "C" void Ship_CreateQuadVertexGroup(Vtx* vtxList, s32 xStart, s32 yStart, s32 width, s32 height, u8 flippedH) {
vtxList[0].v.ob[0] = xStart;
vtxList[0].v.ob[1] = yStart;
vtxList[0].v.tc[0] = (flippedH ? width : 0) << 5;
vtxList[0].v.tc[1] = 0 << 5;
vtxList[1].v.ob[0] = xStart + width;
vtxList[1].v.ob[1] = yStart;
vtxList[1].v.tc[0] = (flippedH ? width * 2 : width) << 5;
vtxList[1].v.tc[1] = 0 << 5;
vtxList[2].v.ob[0] = xStart;
vtxList[2].v.ob[1] = yStart + height;
vtxList[2].v.tc[0] = (flippedH ? width : 0) << 5;
vtxList[2].v.tc[1] = height << 5;
vtxList[3].v.ob[0] = xStart + width;
vtxList[3].v.ob[1] = yStart + height;
vtxList[3].v.tc[0] = (flippedH ? width * 2 : width) << 5;
vtxList[3].v.tc[1] = height << 5;
}
extern "C" f32 Ship_GetCharFontWidthNES(u8 character) {
u8 adjustedChar = character - ' ';
if (adjustedChar >= ARRAY_COUNTU(sNESFontWidths)) {
return 0.0f;
}
return sNESFontWidths[adjustedChar];
}
extern "C" TexturePtr Ship_GetCharFontTextureNES(u8 character) {
u8 adjustedChar = character - ' ';
if (adjustedChar >= ARRAY_COUNTU(sNESFontWidths)) {
return (TexturePtr)gEmptyTexture;
}
return (TexturePtr)fontTbl[adjustedChar];
}