home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 July / CMCD0704.ISO / Software / Freeware / Utilitare / VisualBoyAdvance-1.7.2 / src / simple2x.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2004-05-13  |  2.6 KB  |  107 lines

  1. // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
  2. // Copyright (C) 1999-2003 Forgotten
  3. // Copyright (C) 2004 Forgotten and the VBA development team
  4.  
  5. // This program is free software; you can redistribute it and/or modify
  6. // it under the terms of the GNU General Public License as published by
  7. // the Free Software Foundation; either version 2, or(at your option)
  8. // any later version.
  9. //
  10. // This program is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. // GNU General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU General Public License
  16. // along with this program; if not, write to the Free Software Foundation,
  17. // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18.  
  19. #include "System.h"
  20.  
  21. void Simple2x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
  22.               u8 *dstPtr, u32 dstPitch, int width, int height)
  23. {
  24.   u8 *nextLine, *finish;
  25.   
  26.   nextLine = dstPtr + dstPitch;
  27.   
  28.   do {
  29.     u32 *bP = (u32 *) srcPtr;
  30.     u32 *dP = (u32 *) dstPtr;
  31.     u32 *nL = (u32 *) nextLine;
  32.     u32 currentPixel;
  33.     
  34.     finish = (u8 *) bP + ((width+2) << 1);
  35.     currentPixel = *bP++;
  36.     
  37.     do {
  38. #ifdef WORDS_BIGENDIAN
  39.       u32 color = currentPixel >> 16;
  40. #else
  41.       u32 color = currentPixel & 0xffff;
  42. #endif
  43.  
  44.       color = color | (color << 16);
  45.  
  46.       *(dP) = color;
  47.       *(nL) = color;
  48.  
  49. #ifdef WORDS_BIGENDIAN
  50.       color = currentPixel & 0xffff;
  51. #else
  52.       color = currentPixel >> 16;
  53. #endif
  54.       color = color| (color << 16);      
  55.       *(dP + 1) = color;
  56.       *(nL + 1) = color;
  57.       
  58.       currentPixel = *bP++;
  59.       
  60.       dP += 2;
  61.       nL += 2;
  62.     } while ((u8 *) bP < finish);
  63.     
  64.     srcPtr += srcPitch;
  65.     dstPtr += dstPitch << 1;
  66.     nextLine += dstPitch << 1;
  67.   }
  68.   while (--height);
  69. }
  70.  
  71. void Simple2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
  72.                 u8 *dstPtr, u32 dstPitch, int width, int height)
  73. {
  74.   u8 *nextLine, *finish;
  75.   
  76.   nextLine = dstPtr + dstPitch;
  77.   
  78.   do {
  79.     u32 *bP = (u32 *) srcPtr;
  80.     u32 *dP = (u32 *) dstPtr;
  81.     u32 *nL = (u32 *) nextLine;
  82.     u32 currentPixel;
  83.     
  84.     finish = (u8 *) bP + ((width+1) << 2);
  85.     currentPixel = *bP++;
  86.     
  87.     do {
  88.       u32 color = currentPixel;
  89.  
  90.       *(dP) = color;
  91.       *(dP+1) = color;
  92.       *(nL) = color;
  93.       *(nL + 1) = color;
  94.       
  95.       currentPixel = *bP++;
  96.       
  97.       dP += 2;
  98.       nL += 2;
  99.     } while ((u8 *) bP < finish);
  100.     
  101.     srcPtr += srcPitch;
  102.     dstPtr += dstPitch << 1;
  103.     nextLine += dstPitch << 1;
  104.   }
  105.   while (--height);
  106. }
  107.