From 03633e3a5c9505cf71ba2cf425518d6494870850 Mon Sep 17 00:00:00 2001 From: Sjoerd van der Berg Date: Sun, 12 Feb 2006 23:25:46 +0000 Subject: [PATCH] New format for mapper handlers to support keeping keys pressed. Add png capturing of 15,16,32bpp input Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2489 --- src/hardware/adlib.cpp | 6 +- src/hardware/hardware.cpp | 140 ++++++++++++++++++++++++-------------- 2 files changed, 93 insertions(+), 53 deletions(-) diff --git a/src/hardware/adlib.cpp b/src/hardware/adlib.cpp index 7daf7797..403b128e 100644 --- a/src/hardware/adlib.cpp +++ b/src/hardware/adlib.cpp @@ -283,7 +283,9 @@ static void OPL_RawAdd(Bitu index,Bitu val) { if (opl.raw.used>=RAW_SIZE) OPL_RawEmptyBuffer(); } -static void OPL_SaveRawEvent(void) { +static void OPL_SaveRawEvent(bool pressed) { + if (!pressed) + return; /* Check for previously opened wave file */ if (opl.raw.handle) { OPL_RawEmptyBuffer(); @@ -351,7 +353,7 @@ public: MAPPER_AddHandler(OPL_SaveRawEvent,MK_f7,MMOD1|MMOD2,"caprawopl","Cap OPL"); } ~OPL() { - if (opl.raw.handle) OPL_SaveRawEvent(); + if (opl.raw.handle) OPL_SaveRawEvent(true); OPL2::YM3812Shutdown(); THEOPL3::YMF262Shutdown(); } diff --git a/src/hardware/hardware.cpp b/src/hardware/hardware.cpp index 0d073f49..0cc8e657 100644 --- a/src/hardware/hardware.cpp +++ b/src/hardware/hardware.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: hardware.cpp,v 1.12 2006-02-09 11:47:49 qbix79 Exp $ */ +/* $Id: hardware.cpp,v 1.13 2006-02-12 23:25:46 harekiet Exp $ */ #include #include @@ -147,7 +147,9 @@ static void CAPTURE_AddAviChunk(const char * tag, Bit32u size, void * data, Bit3 } #endif -static void CAPTURE_VideoEvent(void) { +static void CAPTURE_VideoEvent(bool pressed) { + if (!pressed) + return; #if (C_SSHOT) if (CaptureState & CAPTURE_VIDEO) { /* Close the video */ @@ -285,7 +287,8 @@ static void CAPTURE_VideoEvent(void) { void CAPTURE_AddImage(Bitu width, Bitu height, Bitu bpp, Bitu pitch, Bitu flags, float fps, Bit8u * data, Bit8u * pal) { Bitu i; #if (C_SSHOT) - Bit32u doubleRow[SCALER_MAXWIDTH]; + Bit8u doubleRow[SCALER_MAXWIDTH*4]; + Bitu countWidth = width; if (flags & CAPTURE_FLAG_DBLH) height *= 2; @@ -337,52 +340,81 @@ void CAPTURE_AddImage(Bitu width, Bitu height, Bitu bpp, Bitu pitch, Bitu flags, } png_set_PLTE(png_ptr, info_ptr, palette,256); } else { - png_set_swap(png_ptr); - if (bpp == 32) { - png_set_IHDR(png_ptr, info_ptr, width, height, - 8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, - PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); - } else { - png_set_IHDR(png_ptr, info_ptr, width, height, - 16, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, - PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); - } + png_set_bgr( png_ptr ); + png_set_IHDR(png_ptr, info_ptr, width, height, + 8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); } png_write_info(png_ptr, info_ptr); for (i=0;i> 1; - if (flags & CAPTURE_FLAG_DBLH) - srcLine=(data+(i >> 1)*pitch); - else - srcLine=(data+(i >> 0)*pitch); - switch ( bpp) { - case 8: - for (x=0;x> 1)*pitch); + else + srcLine=(data+(i >> 0)*pitch); + rowPointer=srcLine; + switch (bpp) { + case 8: + if (flags & CAPTURE_FLAG_DBLW) { + for (Bitu x=0;x> 1)*pitch); - else - rowPointer=(data+(i >> 0)*pitch); + break; + case 15: + if (flags & CAPTURE_FLAG_DBLW) { + for (Bitu x=0;x> 2; + doubleRow[x*6+1] = doubleRow[x*6+4] = ((pixel& 0x03e0) * 0x21) >> 7; + doubleRow[x*6+2] = doubleRow[x*6+5] = ((pixel& 0x7c00) * 0x21) >> 12; + } + } else { + for (Bitu x=0;x> 2; + doubleRow[x*3+1] = ((pixel& 0x03e0) * 0x21) >> 7; + doubleRow[x*3+2] = ((pixel& 0x7c00) * 0x21) >> 12; + } + } + rowPointer = doubleRow; + break; + case 16: + if (flags & CAPTURE_FLAG_DBLW) { + for (Bitu x=0;x> 2; + doubleRow[x*6+1] = doubleRow[x*6+4] = ((pixel& 0x07e0) * 0x41) >> 9; + doubleRow[x*6+2] = doubleRow[x*6+5] = ((pixel& 0xf800) * 0x21) >> 13; + } + } else { + for (Bitu x=0;x> 2; + doubleRow[x*3+1] = ((pixel& 0x07e0) * 0x41) >> 9; + doubleRow[x*3+2] = ((pixel& 0xf800) * 0x21) >> 13; + } + } + rowPointer = doubleRow; + break; + case 32: + if (flags & CAPTURE_FLAG_DBLW) { + for (Bitu x=0;x