// FSnap 1_0.c // Please ensure you read the snapshot header file before using this. #include "fsnap1_0.h" // Snapshot the current display. u_long FSnapshotDISPENVp(u_long *address) { extern DISPENV GsDISPENV; return ( FSnapshotFRAMEBUFFERp(address, GsDISPENV.disp.x, GsDISPENV.disp.y, GsDISPENV.disp.w, GsDISPENV.disp.h) ); } // Snapshot a specified drawing environment. u_long FSnapshotDRAWENVp(u_long *address, DRAWENV *drawenv) { return ( FSnapshotFRAMEBUFFERp(address, drawenv->clip.x, drawenv->clip.y, drawenv->clip.w, drawenv->clip.h) ); } // Store a 16bit snapshot as a TIM file. u_long FSnapshotFRAMEBUFFERp(u_long *address, u_short x, u_short y, u_short w, u_short h) { RECT rect = {x,y,w,h}; u_long *memaddr = (u_long *) (((u_long) address) + ((4 - ((u_long) address) % 4) % 4)); // align with 32bit boundary u_long pixeldatalength = (w*h*2) + 12; // pixel and header size (bytes) u_long timdatalength = pixeldatalength + 8; *memaddr = (0x00<<8) + 0x10; // version, ID. *(memaddr + 1) = (0<<4) + 2; // no CLUT, 15-bit *(memaddr + 2) = pixeldatalength; // pixel bnum *(memaddr + 3) = (y<<16) + x; *(memaddr + 4) = (h<<16) + w; StoreImage (&rect, memaddr + 5); DrawSync(0); printf("Exit then DSave filename.tim %8x %x\n", memaddr, timdatalength); return timdatalength; } u_long FSnapshotDISPENV(u_long address) { return ( FSnapshotDISPENVp( (u_long *) address) ); } u_long FSnapshotDRAWENV(u_long address, DRAWENV *drawenv) { return ( FSnapshotDRAWENVp( (u_long *) address, drawenv) ); } u_long FSnapshotFRAMEBUFFER(u_long address, u_short x, u_short y, u_short w, u_short h) { return ( FSnapshotFRAMEBUFFERp( (u_long *) address, x,y, w,h) ); }