Michael Kendora's png screenshot stuff added

This commit is contained in:
theoddone33
2001-05-08 18:05:00 +00:00
parent 9cd64c2e4e
commit 93bc342d2b
7 changed files with 3286 additions and 8 deletions

View File

@@ -33,7 +33,7 @@ EXTSYM Clear2xSaIBuffer
EXTSYM romdata,romtype,ScreenShotFormat
EXTSYM Voice0Disable,Voice1Disable,Voice2Disable,Voice3Disable
EXTSYM Voice4Disable,Voice5Disable,Voice6Disable,Voice7Disable
EXTSYM Grab_PNG_Data
NEWSYM MenuAsmStart
@@ -1029,6 +1029,12 @@ NEWSYM pcxheader
NEWSYM picnum, dw 0
NEWSYM savepcx
cmp dword[ScreenShotFormat],1
jne .notpng
call Grab_PNG_Data
ret
.notpng
mov byte[pressed+1],0
mov byte[pressed+59],2
cmp byte[cbitmode],1

View File

@@ -1 +1 @@
/Fezsnesw.exe chips\dsp1proc.obj dos\sw.obj dos\gppro.obj dos\vesa12.obj dos\zsipx.obj dos\modemrtn.obj dos\joy.obj dos\debug.obj dos\vesa2.obj dos\initvid.obj cfgload.obj endmem.obj fixsin.obj init.obj ui.obj vcache.obj water.obj video\procvid.obj win\copyvwin.obj win\winintrf.obj win\winlink.obj win\zloaderw.obj win\ztcp.obj win\zfilew.obj win\zipxw.obj video\makev16b.obj video\makev16t.obj video\makevid.obj video\mode716.obj video\mode716b.obj video\mode716d.obj video\mode716e.obj video\mode716t.obj video\mode7.obj video\mode7ext.obj video\mv16tms.obj video\newg162.obj video\newgfx16.obj video\newgfx2.obj video\newgfx.obj video\m716text.obj video\2xsaiw.obj gui\gui.obj gui\menu.obj cpu\addrni.obj cpu\dma.obj cpu\dsp.obj cpu\dspproc.obj cpu\execute.obj cpu\irq.obj cpu\memory.obj cpu\spc700.obj cpu\stable.obj cpu\table.obj cpu\tableb.obj cpu\tablec.obj chips\dsp1emu.obj chips\fxemu2.obj chips\fxemu2b.obj chips\fxemu2c.obj chips\fxtable.obj chips\sa1proc.obj chips\sa1regs.obj chips\sfxproc.obj zip\unzip.obj zip\zzip.obj zlib.lib wsock32.lib user32.lib gdi32.lib shell32.lib ddraw.lib dsound.lib dinput.lib d3dx.lib /link /section:.text,erw
/Fezsnesw.exe chips\dsp1proc.obj dos\sw.obj dos\gppro.obj dos\vesa12.obj dos\zsipx.obj dos\modemrtn.obj dos\joy.obj dos\debug.obj dos\vesa2.obj dos\initvid.obj cfgload.obj endmem.obj fixsin.obj init.obj ui.obj vcache.obj water.obj video\procvid.obj win\copyvwin.obj win\winintrf.obj win\winlink.obj win\zloaderw.obj win\ztcp.obj win\zfilew.obj win\zipxw.obj video\makev16b.obj video\makev16t.obj video\makevid.obj video\mode716.obj video\mode716b.obj video\mode716d.obj video\mode716e.obj video\mode716t.obj video\mode7.obj video\mode7ext.obj video\mv16tms.obj video\newg162.obj video\newgfx16.obj video\newgfx2.obj video\newgfx.obj video\m716text.obj video\2xsaiw.obj gui\gui.obj gui\menu.obj cpu\addrni.obj cpu\dma.obj cpu\dsp.obj cpu\dspproc.obj cpu\execute.obj cpu\irq.obj cpu\memory.obj cpu\spc700.obj cpu\stable.obj cpu\table.obj cpu\tableb.obj cpu\tablec.obj chips\dsp1emu.obj chips\fxemu2.obj chips\fxemu2b.obj chips\fxemu2c.obj chips\fxtable.obj chips\sa1proc.obj chips\sa1regs.obj chips\sfxproc.obj zip\unzip.obj zip\zzip.obj zip\zpng.obj libpng.lib zlib.lib wsock32.lib user32.lib gdi32.lib shell32.lib ddraw.lib dsound.lib dinput.lib d3dx.lib /link /section:.text,erw

View File

@@ -53,7 +53,7 @@ WINDOSOBJ=${DOSDIR}/debug.o ${DOSDIR}/joy.o ${DOSDIR}/modemrtn.o ${DOSDIR}/vesa2
#PREOBJ=${OBJDIR}/unzip.o ${OBJDIR}/zzip.o ${DOSDIR}/zsipx.o
ZIPOBJ=${ZIPDIR}/zzip.o ${ZIPDIR}/unzip.o
ZIPOBJ=${ZIPDIR}/zzip.o ${ZIPDIR}/unzip.o ${ZIPDIR}/zpng.o
MAINOBJ=cfgload.o endmem.o fixsin.o init.o ui.o vcache.o water.o
@@ -61,7 +61,7 @@ OBJS=${CHIPSOBJ} ${CPUOBJ} ${WINOBJ} ${WINDOSOBJ} ${GUIOBJ} ${VIDEOBJ} ${ZIPOBJ}
SDLLIBS := $(shell sdl-config --libs)
SDLCFLAGS := $(shell sdl-config --cflags)
#LIBS=-static -pg ${SDLLIBS} -lz
LIBS=${SDLLIBS} -lz
LIBS=${SDLLIBS} -lz -lpng
#CFLAGS=-pg -g -Wall -D__LINUX__ ${SDLCFLAGS}
CFLAGS=-g -Wall -D__LINUX__ ${SDLCFLAGS}
ASM=nasm

View File

@@ -21,7 +21,7 @@
#work for me (command line too long)
#put the correct path to your directx sdk here
DXDIR=f:\mssdk
DXDIR=c:\mssdk
CHIPDIR=chips
CPUDIR=cpu
@@ -29,6 +29,7 @@ DOSDIR=dos
GUIDIR=gui
VIDEODIR=video
WINDIR=win
OBJDIR=obj
ZIPDIR=zip
CHIPSOBJ=${CHIPDIR}/sfxproc.obj ${CHIPDIR}/fxemu2.obj ${CHIPDIR}/dsp1proc.obj\
@@ -58,13 +59,17 @@ WINDOSOBJ=${DOSDIR}/debug.obj ${DOSDIR}/joy.obj ${DOSDIR}/modemrtn.obj ${DOSDIR}
${DOSDIR}/initvid.obj ${DOSDIR}/sw.obj ${DOSDIR}/gppro.obj ${DOSDIR}/vesa12.obj\
${DOSDIR}/zsipx.obj
ZIPOBJ=${ZIPDIR}/zzip.obj ${ZIPDIR}/unzip.obj
PREOBJ=
ZIPOBJ=${ZIPDIR}/zzip.obj ${ZIPDIR}/unzip.obj ${ZIPDIR}/zpng.obj
MAINOBJ=cfgload.obj endmem.obj fixsin.obj init.obj ui.obj vcache.obj water.obj
OBJS=${CHIPSOBJ} ${CPUOBJ} ${WINOBJ} ${GUIOBJ} ${VIDEOBJ} ${ZIPOBJ} ${MAINOBJ} ${WINDOSOBJ}
LIBS=
CFLAGS=/c /D__WIN32__
CFLAGS=/G6 /c /D__WIN32__
ASM=nasm
ASMFLAGS=-f win32 -D__WIN32__
CC=cl
@@ -96,7 +101,8 @@ ${WINDIR}/zloaderw.obj: ${WINDIR}/zloaderw.c
${WINDIR}/ztcp.obj: ${WINDIR}/ztcp.c
${WINDIR}/winlink.obj: ${WINDIR}/winlink.cpp ${WINDIR}/resource.h
${ZIPDIR}/unzip.obj: ${ZIPDIR}/unzip.c ${ZIPDIR}/unzip.h
${ZIPDIR}/zzip.obj: ${ZIPDIR}/zzip.c ${ZIPDIR}/unzip.h
${ZIPDIR}/zzip.obj: ${ZIPDIR}/zzip.c ${ZIPDIR}/unzip.h
${ZIPDIR}/zpng.obj: ${ZIPDIR}/zpng.c ${ZIPDIR}/zpng.h ${ZIPDIR}/png.h
${DOSDIR}/initvid.o:${DOSDIR}/initvid.asm macros.mac
${DOSDIR}/modemrtn.o: ${DOSDIR}/modemrtn.asm macros.mac
${DOSDIR}/zsipx.o: ${DOSDIR}/zsipx.asm

3050
zsnes/src/zip/png.h Normal file

File diff suppressed because it is too large Load Diff

199
zsnes/src/zip/zpng.c Normal file
View File

@@ -0,0 +1,199 @@
#include "zpng.h"
#ifdef __WIN32__
#include <windows.h>
#ifdef __WIN32DBG__
#include <crtdbg.h>
#endif
#endif
#ifdef __LINUX__
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdlib.h>
#endif
#ifdef __MSDOS__
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdlib.h>
#endif
extern unsigned int vidbuffer;
extern unsigned int BitConv32Ptr;
#ifdef __PNG__
int Png_Dump(const char * filename, unsigned short width, unsigned short height, unsigned char * image_data, bool usebgr)
{
png_structp png_ptr;
png_infop info_ptr;
png_bytep * row_pointers;
/*Set scanline width for 32-bit color data*/
int scanline=width*4;
int i; /*counter.*/
int png_transforms=0;
/*Try to open the file.*/
FILE *fp = fopen(filename, "wb");
if (!fp)
{
return (-1);
}
/*Try to create png write struct, fail if we cannot.*/
png_ptr = png_create_write_struct
(PNG_LIBPNG_VER_STRING, NULL,/*(png_voidp)user_error_ptr,
user_error_fn*/NULL, NULL/*user_warning_fn*/);
if (!png_ptr)
return (-1);
/*try to create info struct. Fail and delete existing structs if info struct cannot be created.*/
info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr)
{
png_destroy_write_struct(&png_ptr,
(png_infopp)NULL);
return (-1);
}
/*set png I/O source.*/
png_init_io(png_ptr, fp);
/* set the zlib compression level */
png_set_compression_level(png_ptr,
Z_BEST_COMPRESSION);
/* set other zlib parameters */
png_set_compression_mem_level(png_ptr, 8);
png_set_compression_strategy(png_ptr,
Z_DEFAULT_STRATEGY);
png_set_compression_window_bits(png_ptr, 15);
png_set_compression_method(png_ptr, 8);
png_set_compression_buffer_size(png_ptr, 8192);
/*set a lot of image info (code adapted from libpng documentation!)*/
png_set_IHDR(png_ptr, info_ptr, width, height,
8, PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
/*Set palette and gamma (assume 1.0 gamma)*/
png_set_PLTE(png_ptr, info_ptr, NULL, 0);
png_set_gAMA(png_ptr, info_ptr, ZPNG_GAMMA);
/*Allocate an array of scanline pointers*/
row_pointers=(png_bytep*)malloc(height*sizeof(png_bytep));
for (i=0;i<height;i++)
{
#ifdef __UPSIDE_DOWN__
/*invert to normal image format.*/
row_pointers[i]=&image_data[scanline*(height-i-1)];
#else
row_pointers[i]=&image_data[scanline*i];
#endif
}
/*tell the png library what to encode.*/
png_set_rows(png_ptr, info_ptr, row_pointers);
if(usebgr)
png_transforms|=PNG_TRANSFORM_BGR;
/*Write image to file*/
png_write_png(png_ptr, info_ptr, png_transforms, NULL);
/*close file*/
fclose(fp);
/*Destroy PNG structs*/
png_destroy_write_struct(&png_ptr, &info_ptr);
/*clean up dynamically allocated RAM.*/
free(row_pointers);
#ifdef __WIN32DBG__
_CrtDumpMemoryLeaks();
#endif
return 0;
}
void Grab_PNG_Data(void)
{
char filename[64];
bool is_bgr_data=true;
/*These are the variables used to perform the 32-bit conversion*/
int i,j;
unsigned short* pixel;
unsigned short conv_pixel;
/*Set scanline width for 32-bit color data: 4*256 = 1024*/
int scanline=1024;
unsigned char *DIBits;
unsigned int * lookup32=(unsigned int *)BitConv32Ptr;
unsigned int * DBits;
#ifdef __WIN32__
SYSTEMTIME time;
/*get system time.*/
GetLocalTime(&time);
/*make filename from local time*/
wsprintf(filename,"%d_%02d_%02d_%02d-%02d-%02d-ScreenShot.png\0", time.wYear, time.wMonth, time.wDay, time.wHour, time.wMinute, time.wSecond);
#else
/*find first unused file*/
/*Note: this results in a 1000 image limit!*/
struct stat buf;
for(i=0;i<10000;i++)
{
if(i>1000)
sprintf(filename, "Image%03d.png", i);
else sprintf(filename, "Imag%04d.png", i);
if(stat(filename, &buf)==-1)
break;
}
#endif
/*Allocate image buffer for DIB data*/
DIBits=(unsigned char*)malloc(scanline*224);
/*Cast pointer to 32-bit data type*/
DBits=(unsigned int*) DIBits;
/*Use zsKnight's 16 to 32 bit color conversion*/
pixel=(unsigned short*)(vidbuffer);
for(i=0;i<224;i++)
{
for(j=0;j<256;j++)
{
conv_pixel=pixel[(i*288)+j+16];
#ifndef __MSDOS__
DBits[i*256+j]=lookup32[conv_pixel];
#else
DBits[i*256+j]=((conv_pixel&0xF800)<<8)+
((conv_pixel&0x07E0)<<5)+
((conv_pixel&0x001F)<<3)+0xFF000000;
#endif
}
}
/*compress and write the PNG*/
Png_Dump(filename, 256, 224, DIBits, is_bgr_data);
free(&DIBits);
#ifdef __WIN32DBG__
_CrtDumpMemoryLeaks();
#endif
}
#endif

17
zsnes/src/zip/zpng.h Normal file
View File

@@ -0,0 +1,17 @@
#ifndef __ZPNG__
#define __ZPNG__
#define __PNG__
#ifdef __PNG__
#ifndef bool
typedef enum {false, true} bool;
#endif
//#define __UPSIDE_DOWN__ /*define if pngs are saved upside down*/
#include "png.h"
void Grab_PNG_Data(void);
int Png_Dump(const char * filename, unsigned short width, unsigned short height, unsigned char * image_data, bool usebgr);
#define ZPNG_GAMMA 1.0
#endif
#endif