+++ /dev/null
-\r
-// This file is part of the PicoDrive Megadrive Emulator\r
-\r
-// Copyright (c) 2011 FinalDave (emudave (at) gmail.com)\r
-\r
-// This code is licensed under the GNU General Public License version 2.0 and the MAME License.\r
-// You can choose the license that has the most advantages for you.\r
-\r
-// SVN repository can be found at http://code.google.com/p/cyclone68000/\r
-\r
-#include "stdafx.h"\r
-\r
-static int ScreenNum=0;\r
-\r
-int DebugScreenGrab()\r
-{\r
- unsigned char *screen=NULL;\r
- FILE *file=NULL;\r
- unsigned char *line=NULL;\r
- int x=0,y=0;\r
- char filename[64];\r
- unsigned char head[0x12];\r
-\r
- memset(filename,0,sizeof(filename));\r
- memset(head,0,sizeof(head));\r
-\r
- // Allocate memory for one line\r
- line=(unsigned char *)malloc(GXDisp.cxWidth*3); if (line==NULL) return 1;\r
- memset(line,0,GXDisp.cxWidth*3);\r
-\r
- // Get pointer to screen:\r
- screen=(unsigned char *)GXBeginDraw(); if (screen==NULL) { free(line); return 1; }\r
-\r
- // Open screenshot file:\r
- for (;;)\r
- {\r
- sprintf(filename,"\\Screen%.3d.tga",ScreenNum);\r
-\r
- // Does this file exist?\r
- file=fopen(filename,"rb"); if (file==NULL) break; // No - use this\r
- \r
- // Exists, try next file\r
- fclose(file); ScreenNum++;\r
- if (ScreenNum>=1000) break;\r
- }\r
-\r
- // Use this filename\r
- file=fopen(filename,"wb"); if (file==NULL) { GXEndDraw(); free(line); return 1; }\r
-\r
- head[0x02]=0x02; //?\r
- head[0x0c]=(unsigned char) GXDisp.cxWidth;\r
- head[0x0d]=(unsigned char)(GXDisp.cxWidth>>8);\r
- head[0x0e]=(unsigned char) GXDisp.cyHeight;\r
- head[0x0f]=(unsigned char)(GXDisp.cyHeight>>8);\r
- head[0x10]=24; // Number of bits per pixel\r
-\r
- // Write header:\r
- fwrite(head,1,sizeof(head),file);\r
-\r
- for (y=0;y<(int)GXDisp.cyHeight;y++)\r
- {\r
- unsigned char *ps=NULL,*pd=NULL;\r
- int ry=0;\r
- int pix=0;\r
-\r
- ry=GXDisp.cyHeight-y-1;\r
- ps=screen+ry*GXDisp.cbyPitch;\r
- pd=line;\r
-\r
- // Copy pixel to our line buffer\r
- for (x=0;x<(int)GXDisp.cxWidth; x++,ps+=GXDisp.cbxPitch,pd+=3)\r
- {\r
- pix=*(unsigned short *)ps;\r
-\r
- pd[0]=(unsigned char)((pix&0x001f)<<3); // Red\r
- pd[1]=(unsigned char)((pix&0x07e0)>>3); // Green\r
- pd[2]=(unsigned char)((pix&0xf800)>>8); // Blue\r
- }\r
-\r
- fwrite(line,1,GXDisp.cxWidth*3,file);\r
- }\r
-\r
- fclose(file); file=NULL;\r
- \r
- GXEndDraw();\r
- free(line);\r
-\r
- return 0;\r
-}\r