Files
PS2Recomp/ps2xRuntime/include/ps2_gs_common.h
T
Aslan Hud 1551d59fbc Feat: GS, VIF1, VU1 pathways + font rendering stubs + mpeg stubs (#80)
* GS stubs (ps2_stubs_gs.inl):
- Replace direct VRAM writes with GIF packet path
- sceGsExecLoadImage: build GIF packet, set MADR/QWC/CHCR
- sceGsExecStoreImage: GIF packet, processPendingTransfers, consumeLocalToHostBytes
- sceGsPutDispEnv/sceGsPutDrawEnv: program GIF DMA Path3 (5/9 QWs)
- sceGsResetGraph: GIF packet + writeIORegister for pmode/smode2/dispfb/display/bgcolor
- sceGsSetDefDrawEnv: GIF packet layout, sceGszbufaddr for zbuf
- sceGsSyncPath: processPendingTransfers, poll DMA channels
- sceGsSyncV/sceGsSyncVCallback: return 0
- sceGszbufaddr: zbuf calculation (width/height blocks, gparam)

Helpers (ps2_stubs_helpers.inl):
- GsDispEnvMem: 5 fields (pmode, smode2, dispfb, display, bgcolor) for GIF layout
- writeGsDispEnv: read-modify-write pattern
- toDmaPhys: SPR (scratchpad) handling for DMA MADR bit 31
- submitDmaSend: chain mode (chcr=0x185) for sceDmaSend/sceDmaSendI/sceDmaSendM

Misc stubs (ps2_stubs_misc.inl):
- Add sceeFontInit, sceeFontLoadFont, sceeFontPrintfAt, sceeFontPrintfAt2
- Add sceeFontClose, sceeFontSetColour, sceeFontSetMode, sceeFontSetFont, sceeFontSetScale
- Font stubs use GIF packets for CLUT and texture upload

Call list (ps2_call_list.h):
- Add sceeFont* entries between sceGszbufaddr and sceIoctl

* added: added more scee font stubs in stubs misc
fix: fixed flickering error when rendering in memory.cpp

* fix: fixed linux build error
2026-02-24 19:04:52 -03:00

58 lines
1022 B
C++

#ifndef PS2_GS_COMMON_H
#define PS2_GS_COMMON_H
#include "ps2_gs_gpu.h"
#include <cstdint>
namespace GSInternal
{
static inline uint32_t bitsPerPixel(uint8_t psm)
{
switch (psm)
{
case GS_PSM_CT32:
case GS_PSM_Z32:
return 32;
case GS_PSM_CT24:
case GS_PSM_Z24:
return 32;
case GS_PSM_CT16:
case GS_PSM_CT16S:
case GS_PSM_Z16:
case GS_PSM_Z16S:
return 16;
case GS_PSM_T8:
case GS_PSM_T8H:
return 8;
case GS_PSM_T4:
case GS_PSM_T4HL:
case GS_PSM_T4HH:
return 4;
default:
return 32;
}
}
static inline uint32_t fbStride(uint32_t fbw, uint8_t psm)
{
uint32_t pixelsPerRow = fbw * 64u;
return pixelsPerRow * (bitsPerPixel(psm) / 8u);
}
static inline int clampInt(int v, int lo, int hi)
{
if (v < lo) return lo;
if (v > hi) return hi;
return v;
}
static inline uint8_t clampU8(int v)
{
if (v < 0) return 0;
if (v > 255) return 255;
return static_cast<uint8_t>(v);
}
}
#endif