/*************************************************************************** * __________ __ ___. * Open \______ \ ____ ____ | | _\_ |__ _______ ___ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * \/ \/ \/ \/ \/ * $Id$ * * Copyright (C) 2006 by Antoine Cellerier * Copyright (C) 2009 by Andrew Mahone * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * KIND, either express or implied. * ****************************************************************************/ #include "pluginlib_bmp.h" #include "lcd.h" #include "file.h" #include "system.h" #if LCD_DEPTH > 1 /* save is only available for color, resize for >1bpp */ #ifdef HAVE_LCD_COLOR #define LE16(x) (htole16(x))&0xff, ((htole16(x))>>8)&0xff #define LE32(x) (htole32(x))&0xff, ((htole32(x))>>8)&0xff, ((htole32(x))>>16)&0xff, ((htole32(x))>>24)&0xff /** * Save to 24 bit bitmap. */ int save_bmp_file( char* filename, struct bitmap *bm ) { int line_width = (bm->width*3+3) & ~3; int padsize = line_width - bm->width*3; const unsigned char header[] = { 0x42, 0x4d, /* signature - 'BM' */ LE32( bm->height*line_width + 54 + 4*0 ), /* file size in bytes */ 0x00, 0x00, 0x00, 0x00, /* 0, 0 */ LE32( 54 + 4*0 ), /* offset to bitmap */ 0x28, 0x00, 0x00, 0x00, /* size of this struct (40) */ LE32( bm->width ), /* bmap width in pixels */ LE32( bm->height ), /* bmap height in pixels */ 0x01, 0x00, /* num planes - always 1 */ LE16( 24 ), /* bits per pixel */ LE32( 0 ), /* compression flag */ LE32( bm->height*line_width ), /* image size in bytes */ 0xc4, 0x0e, 0x00, 0x00, /* horz resolution */ 0xc4, 0x0e, 0x00, 0x00, /* vert resolution */ LE32( 0 ), /* 0 -> color table size */ LE32( 0 ) /* important color count */ }; int fh; int x,y; if( bm->format != FORMAT_NATIVE ) return -1; fh = rb->creat( filename ); if( fh < 0 ) return -1; rb->write( fh, header, sizeof( header ) ); for( y = bm->height-1; y >= 0; y-- ) { for( x = 0; x < bm->width; x++ ) { fb_data *d = (fb_data*)( bm->data ) + (x+y*bm->width); unsigned char c[] = { RGB_UNPACK_BLUE( *d ), RGB_UNPACK_GREEN( *d ), RGB_UNPACK_RED( *d ) }; rb->write( fh, c, 3 ); } if(padsize != 0) { unsigned int c = 0; /* padsize is at most 3. */ rb->write( fh, &c, padsize ); } } rb->close( fh ); return 1; } #endif /** Very simple image scale from src to dst (nearest neighbour). Source and destination dimensions are read from the struct bitmap. */ void simple_resize_bitmap(struct bitmap *src, struct bitmap *dst) { const int srcw = src->width; const int srch = src->height; const int dstw = dst->width; const int dsth = dst->height; const fb_data *srcd = (fb_data*)(src->data); const fb_data *dstd = (fb_data*)(dst->data); const long xrstep = ((srcw-1) << 8) / (dstw-1); const long yrstep = ((srch-1) << 8) / (dsth-1); fb_data *src_row, *dst_row; long xr, yr = 0; int src_x, src_y, dst_x, dst_y; for (dst_y=0; dst_y < dsth; dst_y++) { src_y = (yr >> 8); src_row = (fb_data*)&srcd[src_y * srcw]; dst_row = (fb_data*)&dstd[dst_y * dstw]; for (xr=0,dst_x=0; dst_x < dstw; dst_x++) { src_x = (xr >> 8); dst_row[dst_x] = src_row[src_x]; xr += xrstep; } yr += yrstep; } } #endif /* LCD_DEPTH > 1 */ #include "wrappers.h" /* import the core bmp loader */ #include "recorder/bmp.c" 'n38' href='#n38'>38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
/* Emacs style mode select   -*- C++ -*-
 *-----------------------------------------------------------------------------
 *
 *
 *  PrBoom a Doom port merged with LxDoom and LSDLDoom
 *  based on BOOM, a modified and improved DOOM engine
 *  Copyright (C) 1999 by
 *  id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
 *  Copyright (C) 1999-2000 by
 *  Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License
 *  as published by the Free Software Foundation; either version 2
 *  of the License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 *  02111-1307, USA.
 *
 * DESCRIPTION:
 *      Mission begin melt/wipe screen special effect.
 *
 *-----------------------------------------------------------------------------
 */

#include "rockmacros.h"
#include "z_zone.h"
#include "doomdef.h"
#include "i_video.h"
#include "v_video.h"
#include "m_random.h"
#include "f_wipe.h"



//
// SCREEN WIPE PACKAGE
//

// CPhipps - macros for the source and destination screens
#define SRC_SCR 2
#define DEST_SCR 3

static byte *wipe_scr_start;
static byte *wipe_scr_end;
static byte *wipe_scr;

static void wipe_shittyColMajorXform(short *array, int width, int height)
{
   short *dest = Z_Malloc(width*height*sizeof(short), PU_STATIC, 0);
   int x, y;

   for(y=0;y<height;y++)
      for(x=0;x<width;x++)
         dest[x*height+y] = array[y*width+x];
   memcpy(array, dest, width*height*sizeof(short));
   Z_Free(dest);
}

static int *y;

static int wipe_initMelt(int width, int height, int ticks)
{
   (void)ticks;
   int i;

   // copy start screen to main screen
   memcpy(wipe_scr, wipe_scr_start, width*height);

   // makes this wipe faster (in theory)
   // to have stuff in column-major format
   wipe_shittyColMajorXform((short*)wipe_scr_start, width/2, height);
   wipe_shittyColMajorXform((short*)wipe_scr_end, width/2, height);

   // setup initial column positions (y<0 => not ready to scroll yet)
   y = (int *) malloc(width*sizeof(int));
   y[0] = -(M_Random()%16);
   for (i=1;i<width;i++)
   {
      int r = (M_Random()%3) - 1;
      y[i] = y[i-1] + r;
      if (y[i] > 0)
         y[i] = 0;
      else
         if (y[i] == -16)
            y[i] = -15;
   }
   return 0;
}

static int wipe_doMelt(int width, int height, int ticks)
{
   boolean done = true;
   int i;

   width /= 2;

   while (ticks--)
      for (i=0;i<width;i++)
         if (y[i]<0)
         {
            y[i]++;
            done = false;
         }
         else
            if (y[i] < height)
            {
               short *s, *d;
               int j, dy, idx;

               dy = (y[i] < 16) ? y[i]+1 : 8;
               if (y[i]+dy >= height)