// // Copyright(C) 1993-1996 Id Software, Inc. // Copyright(C) 2005-2014 Simon Howard // // 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. // // DESCRIPTION: // Screen scale-up code: // 1x,2x,3x,4x pixel doubling // Aspect ratio-correcting stretch functions // #include #include #include #include "doomtype.h" #include "i_video.h" #include "m_argv.h" #include "z_zone.h" // Should be I_VideoBuffer static byte *src_buffer; // Destination buffer, ie. screen->pixels. static byte *dest_buffer; // Pitch of destination buffer, ie. screen->pitch. static int dest_pitch; // Lookup tables used for aspect ratio correction stretching code. // stretch_tables[0] : 20% / 80% // stretch_tables[1] : 40% / 60% // All other combinations can be reached from these two tables. static byte *stretch_tables[2] = { NULL, NULL }; // 50%/50% stretch table, for 800x600 squash mode static byte *half_stretch_table = NULL; // Called to set the source and destination buffers before doing the // scale. void I_InitScale(byte *_src_buffer, byte *_dest_buffer, int _dest_pitch) { src_buffer = _src_buffer; dest_buffer = _dest_buffer; dest_pitch = _dest_pitch; } // // Pixel doubling scale-up functions. // // 1x scale doesn't really do any scaling: it just copies the buffer // a line at a time for when pitch != SCREENWIDTH (!native_surface) static boolean I_Scale1x(int x1, int y1, int x2, int y2) { byte *bufp, *screenp; int y; int w = x2 - x1; // Need to byte-copy from buffer into the screen buffer bufp = src_buffer + y1 * SCREENWIDTH + x1; screenp = (byte *) dest_buffer + y1 * dest_pitch + x1; for (y=y1; y 240) for (y=0; y 480) for (y=0; y 720) for (y=0; y 960) for (y=0; y 1200) for (y=0; y 0) { screenp = (byte *) dest_buffer + 2 * dest_pitch; for (y=0; y<1198; y += 3) { memset(screenp, 0, 1600); screenp += dest_pitch * 3; } } return true; } screen_mode_t mode_stretch_5x = { SCREENWIDTH * 5, SCREENHEIGHT_4_3 * 5, I_InitStretchTables, I_Stretch5x, false, }; // // Aspect ratio correcting "squash" functions. // // These do the opposite of the "stretch" functions above: while the // stretch functions increase the vertical dimensions, the squash // functions decrease the horizontal dimensions for the same result. // // The same blend tables from the stretch functions are reused; as // a result, the dimensions are *slightly* wrong (eg. 320x200 should // squash to 266x200, but actually squashes to 256x200). // // // 1x squashed scale (256x200) // static inline void WriteSquashedLine1x(byte *dest, byte *src) { int x; for (x=0; x