25 #define PS2SS_GIF_AD 0x0e
27 #define PS2SS_GIFTAG(NLOOP,EOP,PRE,PRIM,FLG,NREG) \
28 ((u64)(NLOOP) << 0) | \
29 ((u64)(EOP) << 15) | \
30 ((u64)(PRE) << 46) | \
31 ((u64)(PRIM) << 47) | \
32 ((u64)(FLG) << 58) | \
35 #define PS2SS_GSBITBLTBUF_SET(sbp, sbw, spsm, dbp, dbw, dpsm) \
36 ((u64)(sbp) | ((u64)(sbw) << 16) | \
37 ((u64)(spsm) << 24) | ((u64)(dbp) << 32) | \
38 ((u64)(dbw) << 48) | ((u64)(dpsm) << 56))
40 #define PS2SS_GSTRXREG_SET(rrw, rrh) \
41 ((u64)(rrw) | ((u64)(rrh) << 32))
43 #define PS2SS_GSTRXPOS_SET(ssax, ssay, dsax, dsay, dir) \
44 ((u64)(ssax) | ((u64)(ssay) << 16) | \
45 ((u64)(dsax) << 32) | ((u64)(dsay) << 48) | \
48 #define PS2SS_GSTRXDIR_SET(xdr) ((u64)(xdr))
50 #define PS2SS_GSBITBLTBUF 0x50
51 #define PS2SS_GSFINISH 0x61
52 #define PS2SS_GSTRXPOS 0x51
53 #define PS2SS_GSTRXREG 0x52
54 #define PS2SS_GSTRXDIR 0x53
56 #define PS2SS_GSPSMCT32 0
57 #define PS2SS_GSPSMCT24 1
58 #define PS2SS_GSPSMCT16 2
60 #define PS2SS_D1_CHCR ((volatile unsigned int *)(0x10009000))
61 #define PS2SS_D1_MADR ((volatile unsigned int *)(0x10009010))
62 #define PS2SS_D1_QWC ((volatile unsigned int *)(0x10009020))
63 #define PS2SS_D1_TADR ((volatile unsigned int *)(0x10009030))
64 #define PS2SS_D1_ASR0 ((volatile unsigned int *)(0x10009040))
65 #define PS2SS_D1_ASR1 ((volatile unsigned int *)(0x10009050))
67 #define PS2SS_CSR_FINISH (1 << 1)
68 #define PS2SS_GS_CSR ((volatile u64 *)(0x12001000))
69 #define PS2SS_GS_BUSDIR ((volatile u64 *)(0x12001040))
71 #define PS2SS_VIF1_STAT ((volatile u32 *)(0x10003c00))
72 #define PS2SS_VIF1_STAT_FDR (1<< 23)
73 #define PS2SS_VIF1_MSKPATH3(mask) ((u32)(mask) | ((u32)0x06 << 24))
74 #define PS2SS_VIF1_NOP 0
75 #define PS2SS_VIF1_FLUSHA (((u32)0x13 << 24))
76 #define PS2SS_VIF1_DIRECT(count) ((u32)(count) | ((u32)(0x50) << 24))
77 #define PS2SS_VIF1_FIFO ((volatile u128 *)(0x10005000))
85 unsigned int Width,
unsigned int Height,
unsigned int Psm )
89 static u32 in_buffer[1024 * 4];
90 static u32 out_buffer[1024 * 4];
92 unsigned char header[18] =
94 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0,
100 s16 *p_header = (
s16 *)&header;
102 file_handle = open( pFilename, O_CREAT|O_WRONLY );
111 p_header[6] = (
s16) Width;
112 p_header[7] = (
s16) Height;
114 write (file_handle, (
void *)&header, 18);
118 for (
y = 0;
y < Height;
y++)
120 u32 *p_out = (
u32 *)&out_buffer;
121 ps2_screenshot(in_buffer, VramAdress, 0, (Height - 1) -
y, Width, 1, Psm);
126 u16* p_in = (
u16*)&in_buffer;
128 for (
x = 0;
x < Width;
x++)
130 u32 r = (p_in[
x] & 31) << 3;
131 u32 g = ((p_in[
x] >> 5) & 31) << 3;
132 u32 b = ((p_in[
x] >> 10) & 31) << 3;
133 p_out[
x] = (0xff<<24)|(r<<16)|(g<<8)|b;
140 u8* p_in = (
u8*)&in_buffer;
142 for(
x = 0;
x < Width;
x++ )
147 p_out[
x] = (0xff<<24)|(r<<16)|(g<<8)|b;
152 u8 *p_in = (
u8 *) &in_buffer;
155 for(
x = 0;
x < Width;
x++)
161 p_out[
x] = (a << 24) | (r << 16) | (g << 8) | b;
165 write(file_handle, p_out, Width * 4);
182 unsigned int y,
unsigned int Width,
unsigned int Height,
193 u32* p_dma32 = (
u32*)&dma_chain;
194 u64 *p_dma64 = (
u64*)(p_dma32 + 4);
202 uQSize = ((Width*Height*2)/16);
204 uQSize = ((Width*Height*3)/16);
206 uQSize = (Width*Height*4)/16;
253 asm __volatile__(
"sync.l\n");
275 asm __volatile__(
" sync.l\n");
281 asm __volatile__(
" sync.l\n");
void FlushCache(s32 operation)
#define PS2SS_GSBITBLTBUF
int ps2_screenshot(void *pDest, unsigned int VramAdress, unsigned int x, unsigned int y, unsigned int Width, unsigned int Height, unsigned int Psm)
#define PS2SS_VIF1_STAT_FDR
#define PS2SS_GSTRXREG_SET(rrw, rrh)
#define PS2SS_GSTRXDIR_SET(xdr)
#define PS2SS_VIF1_DIRECT(count)
#define PS2SS_GSTRXPOS_SET(ssax, ssay, dsax, dsay, dir)
int ps2_screenshot_file(const char *pFilename, unsigned int VramAdress, unsigned int Width, unsigned int Height, unsigned int Psm)
#define PS2SS_GSBITBLTBUF_SET(sbp, sbw, spsm, dbp, dbw, dpsm)
#define PS2SS_GIFTAG(NLOOP, EOP, PRE, PRIM, FLG, NREG)
#define PS2SS_VIF1_MSKPATH3(mask)
#define PS2SS_VIF1_FLUSHA
void ps2_screenshot_16to32_buffer(void *pTemp, u32 w, u32 h)
void ps2_screenshot_16to32_line(void *pTemp, u32 w)