Last active
December 16, 2023 22:24
-
-
Save F0bes/707b711b7d081a6171d9ccc466a9a42d to your computer and use it in GitHub Desktop.
imhex for gs dumps.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <std/mem.pat> | |
using GSDumpHeader_New; | |
using GSRegisterCommand; | |
using GSVsyncCommand; | |
using GSTransferCommand; | |
using GSReadFIFOCommand; | |
using FreezeData; | |
enum DumpTag : u8 | |
{ | |
Transfer, | |
VSYNC, | |
FIFO, | |
Registers | |
}; | |
struct DumpCommand | |
{ | |
DumpTag tag [[hidden]]; | |
match(tag) | |
{ | |
(DumpTag::Transfer): GSTransferCommand CMD_TRANS; | |
(DumpTag::Registers): GSRegisterCommand CMD_REGS; | |
(DumpTag::VSYNC): GSVsyncCommand CMD_VSYNC; | |
(DumpTag::FIFO): GSReadFIFOCommand CMD_FIFO; | |
(_): return; | |
} | |
} [[inline]]; | |
struct Packet | |
{ | |
u32 start_crc; | |
if(start_crc == 0xFFFFFFFFu) | |
{ | |
u32 header_size; | |
GSDumpHeader_New header; | |
char serial[header.serial_size]; | |
u128 screenshot[header.screenshot_size / sizeof(u128)]; | |
FreezeData freeze_data; | |
GSRegisterCommand init_regs; | |
DumpCommand cmd[while(!std::mem::eof())]; | |
} | |
else | |
{ | |
u32 state_size; | |
FreezeData freeze_data; | |
GSRegisterCommand init_regs; | |
DumpCommand cmd[while(!std::mem::eof())]; | |
} | |
} ;//[[hex::visualize("bitmap",screenshot, header.screenshot_width,header.screenshot_height)]]; | |
struct GSDumpHeader_New | |
{ | |
u32 state_version; | |
u32 state_size; | |
u32 serial_offset; | |
u32 serial_size; | |
u32 crc; | |
u32 screenshot_width; | |
u32 screenshot_height; | |
u32 screenshot_offset; | |
u32 screenshot_size; | |
}; | |
struct RGBAQ | |
{ | |
u8 B; | |
u8 G; | |
u8 R; | |
u8 A; | |
float Q; | |
}; | |
struct FreezeData | |
{ | |
u32 state_version; | |
u64 PRIM; | |
if(state_version <= 6) | |
{ | |
u64 PRMODE; | |
} | |
u64 PRMODECONT; | |
u64 TEXCLUT; | |
u64 SCANMSK; | |
u64 TEXA; | |
u64 FOGCOL; | |
u64 DIMX; | |
u64 DTHE; | |
u64 COLCLAMP; | |
u64 PABE; | |
u64 BITBLTBUF; | |
u64 TRXDIR; | |
u64 TRXPOS; | |
u64 TRXREG; | |
u64 TRXREG; | |
u64 XYZOFFSET_1; | |
u64 TEX0_1; | |
u64 TEX1_1; | |
if(state_version <= 6) | |
u64 TEX2_1; | |
u64 CLAMP_1; | |
u64 MIPTBP1_1; | |
u64 MIPTBP2_1; | |
u64 SCISSOR_1; | |
u64 ALPHA_1; | |
u64 TEST_1; | |
u64 FBA_1; | |
u64 FRAME_1; | |
u64 ZBUF_1; | |
if(state_version <= 4) | |
padding[sizeof(u32) * 7]; // ??? | |
u64 XYZOFFSET_2; | |
u64 TEX0_2; | |
u64 TEX1_2; | |
if(state_version <= 6) | |
u64 TEX2_1; | |
u64 CLAMP_2; | |
u64 MIPTBP1_2; | |
u64 MIPTBP2_2; | |
u64 SCISSOR_2; | |
u64 ALPHA_2; | |
u64 TEST_2; | |
u64 FBA_2; | |
u64 FRAME_2; | |
u64 ZBUF_2; | |
if(state_version <= 4) | |
padding[sizeof(u32) * 7]; // ??? | |
RGBAQ RGBAQ; | |
float ST[2]; | |
u32 UV; | |
u32 FOG; | |
u64 XYZ2; | |
padding[sizeof(u64)]; | |
u32 m_tr_x; // idk | |
u32 m_tr_y; // idk | |
u128 vram_data[1024 * 1024 * 4 / sizeof(u128)]; | |
u128 tag_0; | |
u32 reg_0; | |
u128 tag_1; | |
u32 reg_1; | |
u128 tag_2; | |
u32 reg_2; | |
u128 tag_3; | |
u32 reg_3; | |
float q; | |
}; | |
struct GSRegisterSet2 | |
{ | |
u64 CSR; | |
padding[8]; | |
u64 IMR; | |
padding[8]; | |
padding[sizeof(u64) * 4]; | |
u64 BUSDIR; | |
padding[8]; | |
padding[sizeof(u64) * 8]; | |
u64 SIGLBLID; | |
padding[8]; | |
}; | |
struct GSRegisterSet | |
{ | |
u64 PMODE; | |
padding[8]; | |
u64 SMODE1; | |
padding[8]; | |
u64 SMODE2; | |
padding[8]; | |
u64 SRFSH; | |
padding[8]; | |
u64 SYNCH1; | |
padding[8]; | |
u64 SYNCH2; | |
padding[8]; | |
u64 SYNCV; | |
padding[8]; | |
u64 DISPFB1; | |
padding[8]; | |
u64 DISPLAY1; | |
padding[8]; | |
u64 DISPFB2; | |
padding[8]; | |
u64 DISPLAY2; | |
padding[8]; | |
u64 EXTBUF; | |
padding[8]; | |
u64 EXTDATA; | |
padding[8]; | |
u64 EXTWRITE; | |
padding[8]; | |
u64 BGCOLOR; | |
padding[8]; | |
}; | |
union union_registerset1 | |
{ | |
GSRegisterSet regs; | |
padding[0x1000]; | |
}; | |
union union_registerset2 | |
{ | |
GSRegisterSet regs; | |
padding[0x1000]; | |
}; | |
struct GSRegisterCommand | |
{ | |
union_registerset1 regs1; | |
union_registerset2 regs2; | |
} [[name("SET REGISTERS")]]; | |
struct GSVsyncCommand | |
{ | |
u8 field; | |
}[[name("VSYNC")]]; | |
struct GSTransferCommand | |
{ | |
u8 path; | |
u32 size; | |
u8 data[size]; | |
} [[name("TRANSFER")]]; | |
struct GSReadFIFOCommand | |
{ | |
u32 qwords; | |
} [[name("FIFO READ")]]; | |
Packet packet @ 0x00; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment