flGraphicsEffectsFullscreen.c

Go to the documentation of this file.
00001 #include "flGlobal.h"
00002 #if FL_GRAPHICS_EFFECTS_FULLSCREEN != 0
00003 #include <stdlib.h>
00004 #include <stdio.h>
00005 #include <pspgu.h>
00006 #include <pspkernel.h>
00007 
00008 #if FL_INCLUDE_ALL_C == 0
00009 #include "flGraphicsEffectsFullscreen.h"
00010 #include "flGraphics.h"
00011 #include "flMemory.h"
00012 #include "flTexture.h"
00013 #endif
00014 
00015 #define blockWidth  64
00016 #define blockHeight 64
00017 #define blockWidthSafe ((i + blockWidth) > SCREEN_WIDTH ? (SCREEN_WIDTH - i) : blockWidth)
00018 #define blockHeightSafe ((j + blockHeight) > SCREEN_HEIGHT ? (SCREEN_HEIGHT - j) : blockHeight)
00019 
00020 void graphicsEffectFsGrayscale() {
00021      #if FL_MEMORY_VMEM_CACHE < 16384
00022      #if FL_MEMORY_VMEM != 0
00023      char* tempBuffer = vmemAlloc(16384);
00024      if(!tempBuffer) {
00025           #if DEBUG_ERROR != 0
00026           debugWarning("Couldn't allocate the 16k of vram required to perform this effect in hardware.\nReverting to slower algorithm.");
00027           #endif
00028           graphicsEffectFsGrayscaleSW();
00029           return;        
00030      }
00031      #else
00032      char* tempBuffer = (void*)0x44015400;
00033      return;
00034      #endif
00035      #else
00036      char* tempBuffer = (char*)vmemCache;
00037      #endif
00038      
00039      u8* tempPalette = memQalloc(1024);
00040      if(!tempPalette) {
00041           #if DEBUG_ERROR != 0
00042           debugWarning("Couldn't allocate aligned 1024 byte palette.\nReverting to slower algorithm");
00043           #endif
00044           #if ((FL_MEMORY_VMEM_CACHE < 16384) && FL_MEMORY_VMEM)
00045           vmemFree(tempBuffer);
00046           #endif
00047           graphicsEffectFsGrayscaleSW();
00048           return;
00049      }
00050      u8* tempPtr = tempPalette;
00051      int i;
00052      for(i = 0; i < 256; i++) {
00053           *(tempPtr++) = (i / 3);
00054           *(tempPtr++) = (i / 3);
00055           *(tempPtr++) = (i / 3);
00056           *(tempPtr++) = 0xFF;
00057      }
00058 
00059      sceKernelDcacheWritebackInvalidateAll();     
00060      sceGuClutLoad(32, (void*)tempPalette);
00061 
00062      #if FL_VMEM != 0
00063      void* tempDrawBuffer = memUncachedPtr(vmemAbsolutePtr(graphicsDrawBuffer));
00064      #else
00065      void* tempDrawBuffer = (void*)((unsigned int)graphicsDrawBuffer | 0x44000000);
00066      #endif
00067 
00068      sceGuTexFunc(GU_TFX_DECAL, GU_TCC_RGB);
00069      sceGuTexFilter(GU_NEAREST, GU_NEAREST);
00070      sceGuTexMode(GU_PSM_T32, 0, 0, GU_FALSE);
00071      
00072      sceGuDrawBufferList(GU_PSM_8888, memCachedPtr(vmemRelativePtr(tempBuffer)), blockWidth);
00073      
00074      sceGuBlendFunc(GU_ADD, GU_FIX, GU_FIX, 0x00FFFFFF, 0x00FFFFFF);
00075      
00076      int j;
00077      vertTsVs* tempVerts = NULL;
00078      for(j = 0; j < SCREEN_HEIGHT; j += blockHeight) {
00079           for(i = 0; i < SCREEN_WIDTH; i += blockWidth) {
00080                sceGuTexImage(0, blockWidthSafe, blockHeightSafe, SCREEN_PITCH, (void*)((unsigned int)tempDrawBuffer + (((j * SCREEN_PITCH) + i) << 2)));
00081 
00082                sceGuClutMode(GU_PSM_8888, 0, 0xFF, 0);
00083                tempVerts = (vertTsVs*)sceGuGetMemory(sizeof(vertTsVs) << 1);
00084                tempVerts[0].vertX = 0;
00085                tempVerts[0].vertY = 0;
00086                tempVerts[0].vertZ = 0;
00087                tempVerts[0].vertU = 0;
00088                tempVerts[0].vertV = 0;
00089                tempVerts[1].vertX = blockWidthSafe;
00090                tempVerts[1].vertY = blockHeightSafe;
00091                tempVerts[1].vertZ = 0;
00092                tempVerts[1].vertU = blockWidthSafe;
00093                tempVerts[1].vertV = blockHeightSafe;
00094                sceGuDisable(GU_BLEND);
00095                sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, tempVerts);
00096                sceGuEnable(GU_BLEND);
00097                
00098                sceGuClutMode(GU_PSM_8888, 8, 0xFF, 0);
00099                tempVerts = (vertTsVs*)sceGuGetMemory(sizeof(vertTsVs) << 1);
00100                tempVerts[0].vertX = 0;
00101                tempVerts[0].vertY = 0;
00102                tempVerts[0].vertZ = 0;
00103                tempVerts[0].vertU = 0;
00104                tempVerts[0].vertV = 0;
00105                tempVerts[1].vertX = blockWidthSafe;
00106                tempVerts[1].vertY = blockHeightSafe;
00107                tempVerts[1].vertZ = 0;
00108                tempVerts[1].vertU = blockWidthSafe;
00109                tempVerts[1].vertV = blockHeightSafe;
00110                sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, tempVerts);
00111                
00112                sceGuClutMode(GU_PSM_8888, 16, 0xFF, 0);
00113                tempVerts = (vertTsVs*)sceGuGetMemory(sizeof(vertTsVs) << 1);
00114                tempVerts[0].vertX = 0;
00115                tempVerts[0].vertY = 0;
00116                tempVerts[0].vertZ = 0;
00117                tempVerts[0].vertU = 0;
00118                tempVerts[0].vertV = 0;
00119                tempVerts[1].vertX = blockWidthSafe;
00120                tempVerts[1].vertY = blockHeightSafe;
00121                tempVerts[1].vertZ = 0;
00122                tempVerts[1].vertU = blockWidthSafe;
00123                tempVerts[1].vertV = blockHeightSafe;
00124                sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, tempVerts);
00125 
00126                sceGuCopyImage(GU_PSM_8888, 0, 0, blockWidthSafe, blockHeightSafe, blockWidth, (void*)tempBuffer, i, j, SCREEN_PITCH, (void*)tempDrawBuffer);
00127           }
00128      }
00129 
00130      sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);     
00131      sceGuDrawBufferList(GU_PSM_8888, (void*)graphicsDrawBuffer, SCREEN_STRIDE);
00132      //sceGuDrawBufferList(GU_PSM_8888, (void*)graphicsRenderTarget, graphicsRenderTargetStride);
00133 
00134      memFree(tempPalette);
00135      
00136      #if ((FL_MEMORY_VMEM_CACHE < 16384) && FL_MEMORY_VMEM)
00137      vmemFree(tempBuffer);
00138      #endif
00139      
00140      #if FL_TEXTURE
00141      texBound = NULL;
00142      palBound = NULL;
00143      #endif
00144 }
00145 
00146 void graphicsEffectFsGrayscaleSW() {
00147      u32 *tempBuffer = (u32*)memUncachedPtr(vmemAbsolutePtr(graphicsDrawBuffer));
00148      
00149      int i, j;
00150      int tempLum = 0;
00151      for(j = 0; j < SCREEN_HEIGHT; j++) {
00152           for(i = 0; i < SCREEN_WIDTH; i++, tempBuffer++) {
00153                tempLum = max(max(color8888_Red(*tempBuffer), color8888_Green(*tempBuffer)), color8888_Blue(*tempBuffer));
00154                tempLum += min(min(color8888_Red(*tempBuffer), color8888_Green(*tempBuffer)), color8888_Blue(*tempBuffer));
00155                tempLum >>= 1;
00156                *tempBuffer = color8888_RGBA(tempLum, tempLum, tempLum, color8888_Alpha(*tempBuffer));
00157           }
00158           tempBuffer += (SCREEN_PITCH - SCREEN_WIDTH);
00159      }
00160 }
00161 
00162 void graphicsEffectFsSepia() {
00163      graphicsEffectFsGrayscale();
00164 
00165      sceGuDisable(GU_TEXTURE_2D);
00166 
00167      vertCVs* tempVerts = (vertCVs*)sceGuGetMemory(sizeof(vertCVs) << 1);
00168 
00169      tempVerts[0].vertColor = 0x3F00FFFF;
00170      tempVerts[0].vertX = 0;
00171      tempVerts[0].vertY = 0;
00172      tempVerts[0].vertZ = 0;
00173 
00174      tempVerts[1].vertColor = 0x3F00FFFF;
00175      tempVerts[1].vertX = SCREEN_WIDTH;
00176      tempVerts[1].vertY = SCREEN_HEIGHT;
00177      tempVerts[1].vertZ = 0;
00178 
00179      sceGuDrawArray(GU_SPRITES, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, tempVerts);
00180 
00181      sceGuEnable(GU_TEXTURE_2D);    
00182 }
00183 
00184 void graphicsEffectFsNightVision() {
00185      #if FL_MEMORY_VMEM_CACHE < 16384
00186      #if FL_MEMORY_VMEM != 0
00187      char* tempBuffer = vmemAlloc(16384);
00188      if(!tempBuffer) {
00189           #if DEBUG_ERROR != 0
00190           debugWarning("Couldn't allocate the 16k of vram required to perform this effect in hardware.\nReverting to slower algorithm.");
00191           #endif
00192           graphicsEffectFsNightVisionSW();
00193           return;        
00194      }
00195      #else
00196      char* tempBuffer = (void*)0x44015400;
00197      return;
00198      #endif
00199      #else
00200      char* tempBuffer = (char*)vmemCache;
00201      #endif
00202      
00203      u8* tempPalette = memQalloc(1024);
00204      if(!tempPalette) {
00205           #if DEBUG_ERROR != 0
00206           debugWarning("Couldn't allocate aligned 1024 byte palette.\nReverting to slower algorithm");
00207           #endif
00208           #if ((FL_MEMORY_VMEM_CACHE < 16384) && FL_MEMORY_VMEM)
00209           vmemFree(tempBuffer);
00210           #endif
00211           graphicsEffectFsNightVisionSW();
00212           return;
00213      }
00214      u8* tempPtr = tempPalette;
00215      int i;
00216      for(i = 0; i < 256; i++) {
00217           *(tempPtr++) = 0;
00218           *(tempPtr++) = (i >> 1);
00219           *(tempPtr++) = 0;
00220           *(tempPtr++) = 0xFF;
00221      }
00222 
00223      sceKernelDcacheWritebackInvalidateAll();
00224      sceGuClutLoad(32, (void*)tempPalette);
00225 
00226      #if FL_VMEM != 0
00227      void* tempDrawBuffer = memUncachedPtr(vmemAbsolutePtr(graphicsDrawBuffer));
00228      #else
00229      void* tempDrawBuffer = (void*)((unsigned int)graphicsDrawBuffer | 0x44000000);
00230      #endif
00231 
00232      sceGuTexFunc(GU_TFX_DECAL, GU_TCC_RGB);
00233      sceGuTexFilter(GU_NEAREST, GU_NEAREST);
00234      sceGuTexMode(GU_PSM_T32, 0, 0, GU_FALSE);
00235      
00236      sceGuDrawBufferList(GU_PSM_8888, memCachedPtr(vmemRelativePtr(tempBuffer)), blockWidth);
00237      
00238      sceGuBlendFunc(GU_ADD, GU_FIX, GU_FIX, 0x00FFFFFF, 0x00FFFFFF);
00239      
00240      int j;
00241      vertTsVs* tempVerts = NULL;
00242      for(j = 0; j < SCREEN_HEIGHT; j += blockHeight) {
00243           for(i = 0; i < SCREEN_PITCH; i += blockWidth) {
00244                sceGuTexImage(0, blockWidthSafe, blockHeightSafe, SCREEN_PITCH, (void*)((unsigned int)tempDrawBuffer + (((j * SCREEN_PITCH) + i) << 2)));
00245 
00246                sceGuClutMode(GU_PSM_8888, 0, 0xFF, 0);
00247                tempVerts = (vertTsVs*)sceGuGetMemory(sizeof(vertTsVs) << 1);
00248                tempVerts[0].vertX = 0;
00249                tempVerts[0].vertY = 0;
00250                tempVerts[0].vertZ = 0;
00251                tempVerts[0].vertU = 0;
00252                tempVerts[0].vertV = 0;
00253                tempVerts[1].vertX = blockWidthSafe;
00254                tempVerts[1].vertY = blockHeightSafe;
00255                tempVerts[1].vertZ = 0;
00256                tempVerts[1].vertU = blockWidthSafe;
00257                tempVerts[1].vertV = blockHeightSafe;
00258                sceGuDisable(GU_BLEND);
00259                sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, tempVerts);
00260                sceGuEnable(GU_BLEND);
00261                
00262                sceGuClutMode(GU_PSM_8888, 8, 0xFF, 0);
00263                tempVerts = (vertTsVs*)sceGuGetMemory(sizeof(vertTsVs) << 1);
00264                tempVerts[0].vertX = 0;
00265                tempVerts[0].vertY = 0;
00266                tempVerts[0].vertZ = 0;
00267                tempVerts[0].vertU = 0;
00268                tempVerts[0].vertV = 0;
00269                tempVerts[1].vertX = blockWidthSafe;
00270                tempVerts[1].vertY = blockHeightSafe;
00271                tempVerts[1].vertZ = 0;
00272                tempVerts[1].vertU = blockWidthSafe;
00273                tempVerts[1].vertV = blockHeightSafe;
00274                sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, tempVerts);
00275                
00276                sceGuClutMode(GU_PSM_8888, 16, 0xFF, 0);
00277                tempVerts = (vertTsVs*)sceGuGetMemory(sizeof(vertTsVs) << 1);
00278                tempVerts[0].vertX = 0;
00279                tempVerts[0].vertY = 0;
00280                tempVerts[0].vertZ = 0;
00281                tempVerts[0].vertU = 0;
00282                tempVerts[0].vertV = 0;
00283                tempVerts[1].vertX = blockWidthSafe;
00284                tempVerts[1].vertY = blockHeightSafe;
00285                tempVerts[1].vertZ = 0;
00286                tempVerts[1].vertU = blockWidthSafe;
00287                tempVerts[1].vertV = blockHeightSafe;
00288                sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, tempVerts);
00289 
00290                sceGuCopyImage(GU_PSM_8888, 0, 0, blockWidthSafe, blockHeightSafe, blockWidth, (void*)tempBuffer, i, j, SCREEN_PITCH, (void*)tempDrawBuffer);
00291           }
00292      }
00293 
00294      sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);     
00295      sceGuDrawBufferList(GU_PSM_8888, (void*)graphicsDrawBuffer, SCREEN_STRIDE);
00296      //sceGuDrawBufferList(GU_PSM_8888, (void*)graphicsRenderTarget, graphicsRenderTargetStride);
00297      
00298      memFree(tempPalette);
00299      
00300      #if ((FL_MEMORY_VMEM_CACHE < 16384) && FL_MEMORY_VMEM)
00301      vmemFree(tempBuffer);
00302      #endif
00303      
00304      #if FL_TEXTURE
00305      texBound = NULL;
00306      palBound = NULL;
00307      #endif
00308 }
00309 
00310 void graphicsEffectFsNightVisionSW() {
00311      u32 *tempBuffer = (u32*)memUncachedPtr(vmemAbsolutePtr(graphicsDrawBuffer));
00312      
00313      int i, j;
00314      int tempLum = 0;
00315      for(j = 0; j < SCREEN_HEIGHT; j++) {
00316           for(i = 0; i < SCREEN_WIDTH; i++, tempBuffer++) {
00317                tempLum = max(max(color8888_Red(*tempBuffer), color8888_Green(*tempBuffer)), color8888_Blue(*tempBuffer));
00318                tempLum += min(min(color8888_Red(*tempBuffer), color8888_Green(*tempBuffer)), color8888_Blue(*tempBuffer));
00319                tempLum >>= 1;
00320                tempLum = ((tempLum * 255) / 192);
00321                tempLum = min(255, tempLum);
00322                *tempBuffer = color8888_RGBA(0, tempLum, 0, color8888_Alpha(*tempBuffer));
00323           }
00324           tempBuffer += (SCREEN_PITCH - SCREEN_WIDTH);
00325      }
00326 }
00327 
00328 void graphicsEffectFsThermalVision() {
00329      #if FL_MEMORY_VMEM_CACHE < 16384
00330      #if FL_MEMORY_VMEM != 0
00331      char* tempBuffer = vmemAlloc(16384);
00332      if(!tempBuffer) {
00333           #if DEBUG_ERROR != 0
00334           debugWarning("Couldn't allocate the 16k of vram required to perform this effect in hardware.\nSkipping algorithm.");
00335           #endif
00336           return;        
00337      }
00338      #else
00339      char* tempBuffer = (void*)0x44015400;
00340      return;
00341      #endif
00342      #else
00343      char* tempBuffer = (char*)vmemCache;
00344      #endif
00345      
00346      u8* tempPalette = memQalloc(2048);
00347      if(!tempPalette) {
00348           #if DEBUG_ERROR != 0
00349           debugWarning("Couldn't allocate aligned 1024 byte palette.\nSkipping algorithm");
00350           #endif
00351           #if ((FL_MEMORY_VMEM_CACHE < 16384) && FL_MEMORY_VMEM)
00352           vmemFree(tempBuffer);
00353           #endif
00354           graphicsEffectFsNightVisionSW();
00355           return;
00356      }
00357      u8* tempPtr = tempPalette;
00358      int i;
00359      for(i = 0; i < 256; i++) {
00360           *(tempPtr++) = (i / 3);
00361           *(tempPtr++) = (i / 3);
00362           *(tempPtr++) = (i / 3);
00363           *(tempPtr++) = 0xFF;
00364      }
00365 
00366      for(i = 0; i < 256; i++) {
00367           if(i >= 224) {
00368                *(tempPtr++) = 0xFF;
00369                *(tempPtr++) = (255 - ((i - 224) << 3));
00370                *(tempPtr++) = 0;
00371           } else if(i >= 192) {
00372                *(tempPtr++) = ((i - 192) << 3);
00373                *(tempPtr++) = 0xFF;
00374                *(tempPtr++) = 0;
00375           } else if(i >= 160) {
00376                *(tempPtr++) = 0;
00377                *(tempPtr++) = 0xFF;
00378                *(tempPtr++) = (255 - ((i - 160) << 3));
00379           } else if(i >= 128) {
00380                *(tempPtr++) = 0;
00381                *(tempPtr++) = ((i - 128) << 3);
00382                *(tempPtr++) = 0xFF;
00383           } else {
00384                *(tempPtr++) = 0;
00385                *(tempPtr++) = 0;
00386                *(tempPtr++) = (i << 1);
00387           }
00388           *(tempPtr++) = 0xFF;
00389      }
00390 
00391      sceKernelDcacheWritebackInvalidateAll();
00392 
00393      #if FL_VMEM != 0
00394      void* tempDrawBuffer = memUncachedPtr(vmemAbsolutePtr(graphicsDrawBuffer));
00395      #else
00396      void* tempDrawBuffer = (void*)((unsigned int)graphicsDrawBuffer | 0x44000000);
00397      #endif
00398 
00399      sceGuClutLoad(32, (void*)tempPalette);
00400 
00401      sceGuTexFunc(GU_TFX_DECAL, GU_TCC_RGB);
00402      sceGuTexFilter(GU_NEAREST, GU_NEAREST);
00403      sceGuTexMode(GU_PSM_T32, 0, 0, GU_FALSE);
00404      
00405      sceGuDrawBufferList(GU_PSM_8888, memCachedPtr(vmemRelativePtr(tempBuffer)), blockWidth);
00406      
00407      sceGuBlendFunc(GU_ADD, GU_FIX, GU_FIX, 0x00FFFFFF, 0x00FFFFFF);
00408      
00409      int j;
00410      vertTsVs* tempVerts = NULL;
00411      for(j = 0; j < SCREEN_HEIGHT; j += blockHeight) {
00412           for(i = 0; i < SCREEN_PITCH; i += blockWidth) {
00413                sceGuTexImage(0, blockWidthSafe, blockHeightSafe, SCREEN_PITCH, (void*)((unsigned int)tempDrawBuffer + (((j * SCREEN_PITCH) + i) << 2)));
00414 
00415                sceGuClutMode(GU_PSM_8888, 0, 0xFF, 0);
00416                tempVerts = (vertTsVs*)sceGuGetMemory(sizeof(vertTsVs) << 1);
00417                tempVerts[0].vertX = 0;
00418                tempVerts[0].vertY = 0;
00419                tempVerts[0].vertZ = 0;
00420                tempVerts[0].vertU = 0;
00421                tempVerts[0].vertV = 0;
00422                tempVerts[1].vertX = blockWidthSafe;
00423                tempVerts[1].vertY = blockHeightSafe;
00424                tempVerts[1].vertZ = 0;
00425                tempVerts[1].vertU = blockWidthSafe;
00426                tempVerts[1].vertV = blockHeightSafe;
00427                sceGuDisable(GU_BLEND);
00428                sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, tempVerts);
00429                sceGuEnable(GU_BLEND);
00430                
00431                sceGuClutMode(GU_PSM_8888, 8, 0xFF, 0);
00432                tempVerts = (vertTsVs*)sceGuGetMemory(sizeof(vertTsVs) << 1);
00433                tempVerts[0].vertX = 0;
00434                tempVerts[0].vertY = 0;
00435                tempVerts[0].vertZ = 0;
00436                tempVerts[0].vertU = 0;
00437                tempVerts[0].vertV = 0;
00438                tempVerts[1].vertX = blockWidthSafe;
00439                tempVerts[1].vertY = blockHeightSafe;
00440                tempVerts[1].vertZ = 0;
00441                tempVerts[1].vertU = blockWidthSafe;
00442                tempVerts[1].vertV = blockHeightSafe;
00443                sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, tempVerts);
00444                
00445                sceGuClutMode(GU_PSM_8888, 16, 0xFF, 0);
00446                tempVerts = (vertTsVs*)sceGuGetMemory(sizeof(vertTsVs) << 1);
00447                tempVerts[0].vertX = 0;
00448                tempVerts[0].vertY = 0;
00449                tempVerts[0].vertZ = 0;
00450                tempVerts[0].vertU = 0;
00451                tempVerts[0].vertV = 0;
00452                tempVerts[1].vertX = blockWidthSafe;
00453                tempVerts[1].vertY = blockHeightSafe;
00454                tempVerts[1].vertZ = 0;
00455                tempVerts[1].vertU = blockWidthSafe;
00456                tempVerts[1].vertV = blockHeightSafe;
00457                sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, tempVerts);
00458 
00459                sceGuCopyImage(GU_PSM_8888, 0, 0, blockWidthSafe, blockHeightSafe, blockWidth, (void*)tempBuffer, i, j, SCREEN_PITCH, (void*)tempDrawBuffer);
00460           }
00461      }
00462 
00463      sceGuClutLoad(32, (void*)((unsigned int)tempPalette + 1024));
00464      sceGuClutMode(GU_PSM_8888, 0, 0xFF, 0);
00465 
00466      sceGuDisable(GU_BLEND);
00467      for(j = 0; j < SCREEN_HEIGHT; j += blockHeight) {
00468           for(i = 0; i < SCREEN_PITCH; i += blockWidth) {
00469                sceGuTexImage(0, blockWidthSafe, blockHeightSafe, SCREEN_PITCH, (void*)((unsigned int)tempDrawBuffer + (((j * SCREEN_PITCH) + i) << 2)));
00470                
00471                tempVerts = (vertTsVs*)sceGuGetMemory(sizeof(vertTsVs) << 1);
00472                tempVerts[0].vertX = 0;
00473                tempVerts[0].vertY = 0;
00474                tempVerts[0].vertZ = 0;
00475                tempVerts[0].vertU = 0;
00476                tempVerts[0].vertV = 0;
00477                tempVerts[1].vertX = blockWidthSafe;
00478                tempVerts[1].vertY = blockHeightSafe;
00479                tempVerts[1].vertZ = 0;
00480                tempVerts[1].vertU = blockWidthSafe;
00481                tempVerts[1].vertV = blockHeightSafe;
00482                sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, tempVerts);
00483                
00484                sceGuCopyImage(GU_PSM_8888, 0, 0, blockWidthSafe, blockHeightSafe, blockWidth, (void*)tempBuffer, i, j, SCREEN_PITCH, (void*)tempDrawBuffer);
00485           }
00486      }
00487      sceGuEnable(GU_BLEND);
00488 
00489      sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);     
00490      sceGuDrawBufferList(GU_PSM_8888, (void*)graphicsDrawBuffer, SCREEN_STRIDE);
00491      //sceGuDrawBufferList(GU_PSM_8888, (void*)graphicsRenderTarget, graphicsRenderTargetStride);
00492      
00493      memFree(tempPalette);
00494      
00495      #if ((FL_MEMORY_VMEM_CACHE < 16384) && FL_MEMORY_VMEM)
00496      vmemFree(tempBuffer);
00497      #endif
00498      
00499      #if FL_TEXTURE
00500      texBound = NULL;
00501      palBound = NULL;
00502      #endif
00503 }
00504 
00505 void graphicsEffectFsMonochrome(u32 inColor) {
00506      #if FL_MEMORY_VMEM_CACHE < 16384
00507      #if FL_MEMORY_VMEM != 0
00508      char* tempBuffer = vmemAlloc(16384);
00509      if(!tempBuffer) {
00510           #if DEBUG_ERROR != 0
00511           debugWarning("Couldn't allocate the 16k of vram required to perform this effect in hardware.\nSkipping algorithm.");
00512           #endif
00513           return;        
00514      }
00515      #else
00516      char* tempBuffer = (void*)0x44015400;
00517      return;
00518      #endif
00519      #else
00520      char* tempBuffer = (char*)vmemCache;
00521      #endif
00522      
00523      u8* tempPalette = memQalloc(1024);
00524      if(!tempPalette) {
00525           #if DEBUG_ERROR != 0
00526           debugWarning("Couldn't allocate aligned 1024 byte palette.\nSkipping algorithm");
00527           #endif
00528           #if ((FL_MEMORY_VMEM_CACHE < 16384) && FL_MEMORY_VMEM)
00529           vmemFree(tempBuffer);
00530           #endif
00531           graphicsEffectFsNightVisionSW();
00532           return;
00533      }
00534      u8* tempPtr = tempPalette;
00535      int i;
00536      for(i = 0; i < 256; i++) {
00537           *(tempPtr++) = (((i * (inColor & 0x000000FF)) >> 8) / 3);
00538           *(tempPtr++) = (((i * ((inColor & 0x0000FF00) >> 8)) >> 8) / 3);
00539           *(tempPtr++) = (((i * ((inColor & 0x00FF0000) >> 16)) >> 8) / 3);
00540           *(tempPtr++) = 0xFF;
00541      }
00542 
00543      sceKernelDcacheWritebackInvalidateAll();
00544      sceGuClutLoad(32, (void*)tempPalette);
00545 
00546      #if FL_VMEM != 0
00547      void* tempDrawBuffer = memUncachedPtr(vmemAbsolutePtr(graphicsDrawBuffer));
00548      #else
00549      void* tempDrawBuffer = (void*)((unsigned int)graphicsDrawBuffer | 0x44000000);
00550      #endif
00551 
00552      sceGuTexFunc(GU_TFX_DECAL, GU_TCC_RGB);
00553      sceGuTexFilter(GU_NEAREST, GU_NEAREST);
00554      sceGuTexMode(GU_PSM_T32, 0, 0, GU_FALSE);
00555      
00556      sceGuDrawBufferList(GU_PSM_8888, memCachedPtr(vmemRelativePtr(tempBuffer)), blockWidth);
00557      
00558      sceGuBlendFunc(GU_ADD, GU_FIX, GU_FIX, 0x00FFFFFF, 0x00FFFFFF);
00559      
00560      int j;
00561      vertTsVs* tempVerts = NULL;
00562      for(j = 0; j < SCREEN_HEIGHT; j += blockHeight) {
00563           for(i = 0; i < SCREEN_PITCH; i += blockWidth) {
00564                sceGuTexImage(0, blockWidthSafe, blockHeightSafe, SCREEN_PITCH, (void*)((unsigned int)tempDrawBuffer + (((j * SCREEN_PITCH) + i) << 2)));
00565 
00566                sceGuClutMode(GU_PSM_8888, 0, 0xFF, 0);
00567                tempVerts = (vertTsVs*)sceGuGetMemory(sizeof(vertTsVs) << 1);
00568                tempVerts[0].vertX = 0;
00569                tempVerts[0].vertY = 0;
00570                tempVerts[0].vertZ = 0;
00571                tempVerts[0].vertU = 0;
00572                tempVerts[0].vertV = 0;
00573                tempVerts[1].vertX = blockWidthSafe;
00574                tempVerts[1].vertY = blockHeightSafe;
00575                tempVerts[1].vertZ = 0;
00576                tempVerts[1].vertU = blockWidthSafe;
00577                tempVerts[1].vertV = blockHeightSafe;
00578                sceGuDisable(GU_BLEND);
00579                sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, tempVerts);
00580                sceGuEnable(GU_BLEND);
00581                
00582                sceGuClutMode(GU_PSM_8888, 8, 0xFF, 0);
00583                tempVerts = (vertTsVs*)sceGuGetMemory(sizeof(vertTsVs) << 1);
00584                tempVerts[0].vertX = 0;
00585                tempVerts[0].vertY = 0;
00586                tempVerts[0].vertZ = 0;
00587                tempVerts[0].vertU = 0;
00588                tempVerts[0].vertV = 0;
00589                tempVerts[1].vertX = blockWidthSafe;
00590                tempVerts[1].vertY = blockHeightSafe;
00591                tempVerts[1].vertZ = 0;
00592                tempVerts[1].vertU = blockWidthSafe;
00593                tempVerts[1].vertV = blockHeightSafe;
00594                sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, tempVerts);
00595                
00596                sceGuClutMode(GU_PSM_8888, 16, 0xFF, 0);
00597                tempVerts = (vertTsVs*)sceGuGetMemory(sizeof(vertTsVs) << 1);
00598                tempVerts[0].vertX = 0;
00599                tempVerts[0].vertY = 0;
00600                tempVerts[0].vertZ = 0;
00601                tempVerts[0].vertU = 0;
00602                tempVerts[0].vertV = 0;
00603                tempVerts[1].vertX = blockWidthSafe;
00604                tempVerts[1].vertY = blockHeightSafe;
00605                tempVerts[1].vertZ = 0;
00606                tempVerts[1].vertU = blockWidthSafe;
00607                tempVerts[1].vertV = blockHeightSafe;
00608                sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, tempVerts);
00609 
00610                sceGuCopyImage(GU_PSM_8888, 0, 0, blockWidthSafe, blockHeightSafe, blockWidth, (void*)tempBuffer, i, j, SCREEN_PITCH, (void*)tempDrawBuffer);
00611           }
00612      }
00613 
00614      sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
00615      sceGuDrawBufferList(GU_PSM_8888, (void*)graphicsDrawBuffer, SCREEN_STRIDE);
00616      //sceGuDrawBufferList(GU_PSM_8888, (void*)graphicsRenderTarget, graphicsRenderTargetStride);
00617      
00618      memFree(tempPalette);
00619      
00620      #if ((FL_MEMORY_VMEM_CACHE < 16384) && FL_MEMORY_VMEM)
00621      vmemFree(tempBuffer);
00622      #endif
00623      
00624      #if FL_TEXTURE
00625      texBound = NULL;
00626      palBound = NULL;
00627      #endif
00628 }
00629 
00630 void graphicsEffectFsDichrome(u32 inColorLight, u32 inColorDark) {
00631      #if FL_MEMORY_VMEM_CACHE < 16384
00632      #if FL_MEMORY_VMEM != 0
00633      char* tempBuffer = vmemAlloc(16384);
00634      if(!tempBuffer) {
00635           #if DEBUG_ERROR != 0
00636           debugWarning("Couldn't allocate the 16k of vram required to perform this effect in hardware.\nSkipping algorithm.");
00637           #endif
00638           return;        
00639      }
00640      #else
00641      char* tempBuffer = (void*)0x44015400;
00642      return;
00643      #endif
00644      #else
00645      char* tempBuffer = (char*)vmemCache;
00646      #endif
00647      
00648      u8* tempPalette = memQalloc(2048);
00649      if(!tempPalette) {
00650           #if DEBUG_ERROR != 0
00651           debugWarning("Couldn't allocate aligned 1024 byte palette.\nSkipping algorithm");
00652           #endif
00653           #if ((FL_MEMORY_VMEM_CACHE < 16384) && FL_MEMORY_VMEM)
00654           vmemFree(tempBuffer);
00655           #endif
00656           return;
00657      }
00658      u8* tempPtr = tempPalette;
00659      int i;
00660      for(i = 0; i < 256; i++) {
00661           *(tempPtr++) = (i / 3);
00662           *(tempPtr++) = (i / 3);
00663           *(tempPtr++) = (i / 3);
00664           *(tempPtr++) = 0xFF;
00665      }
00666 
00667      for(i = 0; i < 256; i++) {
00668           *(tempPtr++) = (((i * (inColorLight & 0x000000FF)) + ((255 - i) * (inColorDark & 0x000000FF))) >> 9);
00669           *(tempPtr++) = (((i * ((inColorLight & 0x0000FF00) >> 8)) + ((255 - i) * ((inColorDark & 0x0000FF00) >> 8))) >> 9);
00670           *(tempPtr++) = (((i * ((inColorLight & 0x00FF0000) >> 16)) + ((255 - i) * ((inColorDark & 0x00FF0000) >> 16))) >> 9);
00671           *(tempPtr++) = 0xFF;
00672      }
00673 
00674      sceKernelDcacheWritebackInvalidateAll();
00675 
00676      #if FL_VMEM != 0
00677      void* tempDrawBuffer = memUncachedPtr(vmemAbsolutePtr(graphicsDrawBuffer));
00678      #else
00679      void* tempDrawBuffer = (void*)((unsigned int)graphicsDrawBuffer | 0x44000000);
00680      #endif
00681 
00682      sceGuClutLoad(32, (void*)tempPalette);
00683 
00684      sceGuTexFunc(GU_TFX_DECAL, GU_TCC_RGB);
00685      sceGuTexFilter(GU_NEAREST, GU_NEAREST);
00686      sceGuTexMode(GU_PSM_T32, 0, 0, GU_FALSE);
00687      
00688      sceGuDrawBufferList(GU_PSM_8888, memCachedPtr(vmemRelativePtr(tempBuffer)), blockWidth);
00689      
00690      sceGuBlendFunc(GU_ADD, GU_FIX, GU_FIX, 0x00FFFFFF, 0x00FFFFFF);
00691      
00692      int j;
00693      vertTsVs* tempVerts = NULL;
00694      for(j = 0; j < SCREEN_HEIGHT; j += blockHeight) {
00695           for(i = 0; i < SCREEN_PITCH; i += blockWidth) {
00696                sceGuTexImage(0, blockWidthSafe, blockHeightSafe, SCREEN_PITCH, (void*)((unsigned int)tempDrawBuffer + (((j * SCREEN_PITCH) + i) << 2)));
00697 
00698                sceGuClutMode(GU_PSM_8888, 0, 0xFF, 0);
00699                tempVerts = (vertTsVs*)sceGuGetMemory(sizeof(vertTsVs) << 1);
00700                tempVerts[0].vertX = 0;
00701                tempVerts[0].vertY = 0;
00702                tempVerts[0].vertZ = 0;
00703                tempVerts[0].vertU = 0;
00704                tempVerts[0].vertV = 0;
00705                tempVerts[1].vertX = blockWidthSafe;
00706                tempVerts[1].vertY = blockHeightSafe;
00707                tempVerts[1].vertZ = 0;
00708                tempVerts[1].vertU = blockWidthSafe;
00709                tempVerts[1].vertV = blockHeightSafe;
00710                sceGuDisable(GU_BLEND);
00711                sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, tempVerts);
00712                sceGuEnable(GU_BLEND);
00713                
00714                sceGuClutMode(GU_PSM_8888, 8, 0xFF, 0);
00715                tempVerts = (vertTsVs*)sceGuGetMemory(sizeof(vertTsVs) << 1);
00716                tempVerts[0].vertX = 0;
00717                tempVerts[0].vertY = 0;
00718                tempVerts[0].vertZ = 0;
00719                tempVerts[0].vertU = 0;
00720                tempVerts[0].vertV = 0;
00721                tempVerts[1].vertX = blockWidthSafe;
00722                tempVerts[1].vertY = blockHeightSafe;
00723                tempVerts[1].vertZ = 0;
00724                tempVerts[1].vertU = blockWidthSafe;
00725                tempVerts[1].vertV = blockHeightSafe;
00726                sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, tempVerts);
00727                
00728                sceGuClutMode(GU_PSM_8888, 16, 0xFF, 0);
00729                tempVerts = (vertTsVs*)sceGuGetMemory(sizeof(vertTsVs) << 1);
00730                tempVerts[0].vertX = 0;
00731                tempVerts[0].vertY = 0;
00732                tempVerts[0].vertZ = 0;
00733                tempVerts[0].vertU = 0;
00734                tempVerts[0].vertV = 0;
00735                tempVerts[1].vertX = blockWidthSafe;
00736                tempVerts[1].vertY = blockHeightSafe;
00737                tempVerts[1].vertZ = 0;
00738                tempVerts[1].vertU = blockWidthSafe;
00739                tempVerts[1].vertV = blockHeightSafe;
00740                sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, tempVerts);
00741 
00742                sceGuCopyImage(GU_PSM_8888, 0, 0, blockWidthSafe, blockHeightSafe, blockWidth, (void*)tempBuffer, i, j, SCREEN_PITCH, (void*)tempDrawBuffer);
00743           }
00744      }
00745 
00746      sceGuClutLoad(32, (void*)((unsigned int)tempPalette + 1024));
00747      sceGuClutMode(GU_PSM_8888, 0, 0xFF, 0);
00748 
00749      sceGuDisable(GU_BLEND);
00750      for(j = 0; j < SCREEN_HEIGHT; j += blockHeight) {
00751           for(i = 0; i < SCREEN_PITCH; i += blockWidth) {
00752                sceGuTexImage(0, blockWidthSafe, blockHeightSafe, SCREEN_PITCH, (void*)((unsigned int)tempDrawBuffer + (((j * SCREEN_PITCH) + i) << 2)));
00753                
00754                tempVerts = (vertTsVs*)sceGuGetMemory(sizeof(vertTsVs) << 1);
00755                tempVerts[0].vertX = 0;
00756                tempVerts[0].vertY = 0;
00757                tempVerts[0].vertZ = 0;
00758                tempVerts[0].vertU = 0;
00759                tempVerts[0].vertV = 0;
00760                tempVerts[1].vertX = blockWidthSafe;
00761                tempVerts[1].vertY = blockHeightSafe;
00762                tempVerts[1].vertZ = 0;
00763                tempVerts[1].vertU = blockWidthSafe;
00764                tempVerts[1].vertV = blockHeightSafe;
00765                sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, tempVerts);
00766                
00767                sceGuCopyImage(GU_PSM_8888, 0, 0, blockWidthSafe, blockHeightSafe, blockWidth, (void*)tempBuffer, i, j, SCREEN_PITCH, (void*)tempDrawBuffer);
00768           }
00769      }
00770      sceGuEnable(GU_BLEND);
00771 
00772      sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);     
00773      sceGuDrawBufferList(GU_PSM_8888, (void*)graphicsDrawBuffer, SCREEN_STRIDE);
00774      //sceGuDrawBufferList(GU_PSM_8888, (void*)graphicsRenderTarget, graphicsRenderTargetStride);
00775      
00776      memFree(tempPalette);
00777      
00778      #if ((FL_MEMORY_VMEM_CACHE < 16384) && FL_MEMORY_VMEM)
00779      vmemFree(tempBuffer);
00780      #endif
00781      
00782      #if FL_TEXTURE
00783      texBound = NULL;
00784      palBound = NULL;
00785      #endif
00786 }
00787 
00788 void graphicsEffectFsColorEnhance() {
00789      #if FL_MEMORY_VMEM_CACHE < 16384
00790      #if FL_MEMORY_VMEM != 0
00791      char* tempBuffer = vmemAlloc(16384);
00792      if(!tempBuffer) {
00793           #if DEBUG_ERROR != 0
00794           debugWarning("Couldn't allocate the 16k of vram required to perform this effect in hardware.\nSkipping algorithm.");
00795           #endif
00796           return;        
00797      }
00798      #else
00799      char* tempBuffer = (void*)0x44015400;
00800      return;
00801      #endif
00802      #else
00803      char* tempBuffer = (char*)vmemCache;
00804      #endif
00805      
00806      #if FL_VMEM != 0
00807      void* tempDrawBuffer = memUncachedPtr(vmemAbsolutePtr(graphicsDrawBuffer));
00808      #else
00809      void* tempDrawBuffer = (void*)((unsigned int)graphicsDrawBuffer | 0x44000000);
00810      #endif
00811 
00812      sceGuTexFunc(GU_TFX_DECAL, GU_TCC_RGB);
00813      sceGuTexFilter(GU_NEAREST, GU_NEAREST);
00814      sceGuTexMode(GU_PSM_8888, 0, 0, GU_FALSE);
00815      
00816      sceGuDrawBufferList(GU_PSM_8888, memCachedPtr(vmemRelativePtr(tempBuffer)), blockWidth);
00817      
00818      sceGuBlendFunc(GU_ADD, GU_FIX, GU_FIX, 0x00FFFFFF, 0x00FFFFFF);
00819      
00820      int i, j;
00821      vertTsVs* tempVerts = NULL;
00822      for(j = 0; j < SCREEN_HEIGHT; j += blockHeight) {
00823           for(i = 0; i < SCREEN_PITCH; i += blockWidth) {
00824                sceGuTexImage(0, blockWidthSafe, blockHeightSafe, SCREEN_PITCH, (void*)((unsigned int)tempDrawBuffer + (((j * SCREEN_PITCH) + i) << 2)));
00825                sceGuCopyImage(GU_PSM_8888, i, j, blockWidthSafe, blockHeightSafe, SCREEN_PITCH, (void*)tempDrawBuffer, 0, 0, blockWidth, (void*)tempBuffer);
00826 
00827                tempVerts = (vertTsVs*)sceGuGetMemory(sizeof(vertTsVs) << 1);
00828                tempVerts[0].vertX = 0;
00829                tempVerts[0].vertY = 0;
00830                tempVerts[0].vertZ = 0;
00831                tempVerts[0].vertU = 0;
00832                tempVerts[0].vertV = 0;
00833                tempVerts[1].vertX = blockWidthSafe;
00834                tempVerts[1].vertY = blockHeightSafe;
00835                tempVerts[1].vertZ = 0;
00836                tempVerts[1].vertU = blockWidthSafe;
00837                tempVerts[1].vertV = blockHeightSafe;
00838                sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, tempVerts);
00839                
00840                sceGuCopyImage(GU_PSM_8888, 0, 0, blockWidthSafe, blockHeightSafe, blockWidth, (void*)tempBuffer, i, j, SCREEN_PITCH, (void*)tempDrawBuffer);
00841           }
00842      }
00843 
00844      sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);     
00845      sceGuDrawBufferList(GU_PSM_8888, (void*)graphicsDrawBuffer, SCREEN_STRIDE);
00846      //sceGuDrawBufferList(GU_PSM_8888, (void*)graphicsRenderTarget, graphicsRenderTargetStride);
00847 
00848      #if ((FL_MEMORY_VMEM_CACHE < 16384) && FL_MEMORY_VMEM)
00849      vmemFree(tempBuffer);
00850      #endif
00851      
00852      #if FL_TEXTURE
00853      texBound = NULL;
00854      palBound = NULL;
00855      #endif
00856 }
00857 
00858 void graphicsEffectFsLightEnhance() {
00859      #if FL_MEMORY_VMEM_CACHE < 16384
00860      #if FL_MEMORY_VMEM != 0
00861      char* tempBuffer = vmemAlloc(16384);
00862      if(!tempBuffer) {
00863           #if DEBUG_ERROR != 0
00864           debugWarning("Couldn't allocate the 16k of vram required to perform this effect in hardware.\nSkipping algorithm.");
00865           #endif
00866           return;        
00867      }
00868      #else
00869      char* tempBuffer = (void*)0x44015400;
00870      return;
00871      #endif
00872      #else
00873      char* tempBuffer = (char*)vmemCache;
00874      #endif
00875      
00876      u8* tempPalette = memQalloc(1024);
00877      if(!tempPalette) {
00878           #if DEBUG_ERROR != 0
00879           debugWarning("Couldn't allocate aligned 1024 byte palette.\nSkipping algorithm");
00880           #endif
00881           #if ((FL_MEMORY_VMEM_CACHE < 16384) && FL_MEMORY_VMEM)
00882           vmemFree(tempBuffer);
00883           #endif
00884           graphicsEffectFsNightVisionSW();
00885           return;
00886      }
00887      u8* tempPtr = tempPalette;
00888      int i;
00889      for(i = 0; i < 256; i++) {
00890           *(tempPtr++) = (i / 3);
00891           *(tempPtr++) = (i / 3);
00892           *(tempPtr++) = (i / 3);
00893           *(tempPtr++) = 0xFF;
00894      }
00895 
00896      sceKernelDcacheWritebackInvalidateAll();
00897      sceGuClutLoad(32, (void*)tempPalette);
00898 
00899      #if FL_VMEM != 0
00900      void* tempDrawBuffer = memUncachedPtr(vmemAbsolutePtr(graphicsDrawBuffer));
00901      #else
00902      void* tempDrawBuffer = (void*)((unsigned int)graphicsDrawBuffer | 0x44000000);
00903      #endif
00904 
00905      sceGuTexFunc(GU_TFX_DECAL, GU_TCC_RGB);
00906      sceGuTexFilter(GU_NEAREST, GU_NEAREST);
00907      sceGuTexMode(GU_PSM_T32, 0, 0, GU_FALSE);
00908      
00909      sceGuDrawBufferList(GU_PSM_8888, memCachedPtr(vmemRelativePtr(tempBuffer)), blockWidth);
00910      
00911      sceGuBlendFunc(GU_ADD, GU_FIX, GU_FIX, 0x00FFFFFF, 0x00FFFFFF);
00912      
00913      int j;
00914      vertTsVs* tempVerts = NULL;
00915      for(j = 0; j < SCREEN_HEIGHT; j += blockHeight) {
00916           for(i = 0; i < SCREEN_PITCH; i += blockWidth) {
00917                sceGuCopyImage(GU_PSM_8888, i, j, blockWidthSafe, blockHeightSafe, SCREEN_PITCH, (void*)tempDrawBuffer, 0, 0, blockWidth, (void*)tempBuffer);
00918                sceGuTexImage(0, blockWidthSafe, blockHeightSafe, SCREEN_PITCH, (void*)((unsigned int)tempDrawBuffer + (((j * SCREEN_PITCH) + i) << 2)));
00919 
00920                sceGuClutMode(GU_PSM_8888, 0, 0xFF, 0);
00921                tempVerts = (vertTsVs*)sceGuGetMemory(sizeof(vertTsVs) << 1);
00922                tempVerts[0].vertX = 0;
00923                tempVerts[0].vertY = 0;
00924                tempVerts[0].vertZ = 0;
00925                tempVerts[0].vertU = 0;
00926                tempVerts[0].vertV = 0;
00927                tempVerts[1].vertX = blockWidthSafe;
00928                tempVerts[1].vertY = blockHeightSafe;
00929                tempVerts[1].vertZ = 0;
00930                tempVerts[1].vertU = blockWidthSafe;
00931                tempVerts[1].vertV = blockHeightSafe;
00932                sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, tempVerts);
00933                
00934                sceGuClutMode(GU_PSM_8888, 8, 0xFF, 0);
00935                tempVerts = (vertTsVs*)sceGuGetMemory(sizeof(vertTsVs) << 1);
00936                tempVerts[0].vertX = 0;
00937                tempVerts[0].vertY = 0;
00938                tempVerts[0].vertZ = 0;
00939                tempVerts[0].vertU = 0;
00940                tempVerts[0].vertV = 0;
00941                tempVerts[1].vertX = blockWidthSafe;
00942                tempVerts[1].vertY = blockHeightSafe;
00943                tempVerts[1].vertZ = 0;
00944                tempVerts[1].vertU = blockWidthSafe;
00945                tempVerts[1].vertV = blockHeightSafe;
00946                sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, tempVerts);
00947                
00948                sceGuClutMode(GU_PSM_8888, 16, 0xFF, 0);
00949                tempVerts = (vertTsVs*)sceGuGetMemory(sizeof(vertTsVs) << 1);
00950                tempVerts[0].vertX = 0;
00951                tempVerts[0].vertY = 0;
00952                tempVerts[0].vertZ = 0;
00953                tempVerts[0].vertU = 0;
00954                tempVerts[0].vertV = 0;
00955                tempVerts[1].vertX = blockWidthSafe;
00956                tempVerts[1].vertY = blockHeightSafe;
00957                tempVerts[1].vertZ = 0;
00958                tempVerts[1].vertU = blockWidthSafe;
00959                tempVerts[1].vertV = blockHeightSafe;
00960                sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, tempVerts);
00961 
00962                sceGuCopyImage(GU_PSM_8888, 0, 0, blockWidthSafe, blockHeightSafe, blockWidth, (void*)tempBuffer, i, j, SCREEN_PITCH, (void*)tempDrawBuffer);
00963           }
00964      }
00965 
00966      sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
00967      sceGuDrawBufferList(GU_PSM_8888, (void*)graphicsDrawBuffer, SCREEN_STRIDE);
00968      //sceGuDrawBufferList(GU_PSM_8888, (void*)graphicsRenderTarget, graphicsRenderTargetStride);
00969      
00970      memFree(tempPalette);
00971      
00972      #if ((FL_MEMORY_VMEM_CACHE < 16384) && FL_MEMORY_VMEM)
00973      vmemFree(tempBuffer);
00974      #endif
00975      
00976      #if FL_TEXTURE
00977      texBound = NULL;
00978      palBound = NULL;
00979      #endif
00980 }
00981 
00982 void graphicsEffectFsInvert() {
00983      #if FL_MEMORY_VMEM_CACHE < 16384
00984      #if FL_MEMORY_VMEM != 0
00985      char* tempBuffer = vmemAlloc(16384);
00986      if(!tempBuffer) {
00987           #if DEBUG_ERROR != 0
00988           debugWarning("Couldn't allocate the 16k of vram required to perform this effect in hardware.\nReverting to slower algorithm.");
00989           #endif
00990           graphicsEffectFsNightVisionSW();
00991           return;        
00992      }
00993      #else
00994      char* tempBuffer = (void*)0x44015400;
00995      return;
00996      #endif
00997      #else
00998      char* tempBuffer = (char*)vmemCache;
00999      #endif
01000      
01001      u8* tempPalette = memQalloc(3072);
01002      if(!tempPalette) {
01003           #if DEBUG_ERROR != 0
01004           debugWarning("Couldn't allocate aligned 3072 bytes worth of palettes.\nReverting to slower algorithm");
01005           #endif
01006           #if ((FL_MEMORY_VMEM_CACHE < 16384) && FL_MEMORY_VMEM)
01007           vmemFree(tempBuffer);
01008           #endif
01009           graphicsEffectFsNightVisionSW();
01010           return;
01011      }
01012      u8* tempPtr = tempPalette;
01013      int i;
01014      for(i = 0; i < 256; i++) {
01015           *(tempPtr++) = (255 - i);
01016           *(tempPtr++) = 0;
01017           *(tempPtr++) = 0;
01018           *(tempPtr++) = 0xFF;
01019      }
01020      for(i = 0; i < 256; i++) {
01021           *(tempPtr++) = 0;
01022           *(tempPtr++) = (255 - i);
01023           *(tempPtr++) = 0;
01024           *(tempPtr++) = 0xFF;
01025      }
01026      for(i = 0; i < 256; i++) {
01027           *(tempPtr++) = 0;
01028           *(tempPtr++) = 0;
01029           *(tempPtr++) = (255 - i);
01030           *(tempPtr++) = 0xFF;
01031      }
01032      sceKernelDcacheWritebackInvalidateAll();
01033 
01034      #if FL_VMEM != 0
01035      void* tempDrawBuffer = memUncachedPtr(vmemAbsolutePtr(graphicsDrawBuffer));
01036      #else
01037      void* tempDrawBuffer = (void*)((unsigned int)graphicsDrawBuffer | 0x44000000);
01038      #endif
01039 
01040      sceGuTexFunc(GU_TFX_DECAL, GU_TCC_RGB);
01041      sceGuTexFilter(GU_NEAREST, GU_NEAREST);
01042      sceGuTexMode(GU_PSM_T32, 0, 0, GU_FALSE);
01043      
01044      sceGuDrawBufferList(GU_PSM_8888, memCachedPtr(vmemRelativePtr(tempBuffer)), blockWidth);
01045      
01046      sceGuBlendFunc(GU_ADD, GU_FIX, GU_FIX, 0x00FFFFFF, 0x00FFFFFF);
01047      
01048      int j;
01049      vertTsVs* tempVerts = NULL;
01050      for(j = 0; j < SCREEN_HEIGHT; j += blockHeight) {
01051           for(i = 0; i < SCREEN_PITCH; i += blockWidth) {
01052                sceGuTexImage(0, blockWidthSafe, blockHeightSafe, SCREEN_PITCH, (void*)((unsigned int)tempDrawBuffer + (((j * SCREEN_PITCH) + i) << 2)));
01053 
01054                sceGuClutMode(GU_PSM_8888, 0, 0xFF, 0);
01055                sceGuClutLoad(32, (void*)tempPalette);
01056                tempVerts = (vertTsVs*)sceGuGetMemory(sizeof(vertTsVs) << 1);
01057                tempVerts[0].vertX = 0;
01058                tempVerts[0].vertY = 0;
01059                tempVerts[0].vertZ = 0;
01060                tempVerts[0].vertU = 0;
01061                tempVerts[0].vertV = 0;
01062                tempVerts[1].vertX = blockWidthSafe;
01063                tempVerts[1].vertY = blockHeightSafe;
01064                tempVerts[1].vertZ = 0;
01065                tempVerts[1].vertU = blockWidthSafe;
01066                tempVerts[1].vertV = blockHeightSafe;
01067                sceGuDisable(GU_BLEND);
01068                sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, tempVerts);
01069                sceGuEnable(GU_BLEND);
01070                
01071                sceGuClutMode(GU_PSM_8888, 8, 0xFF, 0);
01072                sceGuClutLoad(32, (void*)((unsigned int)tempPalette + 1024));
01073                tempVerts = (vertTsVs*)sceGuGetMemory(sizeof(vertTsVs) << 1);
01074                tempVerts[0].vertX = 0;
01075                tempVerts[0].vertY = 0;
01076                tempVerts[0].vertZ = 0;
01077                tempVerts[0].vertU = 0;
01078                tempVerts[0].vertV = 0;
01079                tempVerts[1].vertX = blockWidthSafe;
01080                tempVerts[1].vertY = blockHeightSafe;
01081                tempVerts[1].vertZ = 0;
01082                tempVerts[1].vertU = blockWidthSafe;
01083                tempVerts[1].vertV = blockHeightSafe;
01084                sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, tempVerts);
01085                
01086                sceGuClutMode(GU_PSM_8888, 16, 0xFF, 0);
01087                sceGuClutLoad(32, (void*)((unsigned int)tempPalette + 2048));
01088                tempVerts = (vertTsVs*)sceGuGetMemory(sizeof(vertTsVs) << 1);
01089                tempVerts[0].vertX = 0;
01090                tempVerts[0].vertY = 0;
01091                tempVerts[0].vertZ = 0;
01092                tempVerts[0].vertU = 0;
01093                tempVerts[0].vertV = 0;
01094                tempVerts[1].vertX = blockWidthSafe;
01095                tempVerts[1].vertY = blockHeightSafe;
01096                tempVerts[1].vertZ = 0;
01097                tempVerts[1].vertU = blockWidthSafe;
01098                tempVerts[1].vertV = blockHeightSafe;
01099                sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, tempVerts);
01100 
01101                sceGuCopyImage(GU_PSM_8888, 0, 0, blockWidthSafe, blockHeightSafe, blockWidth, (void*)tempBuffer, i, j, SCREEN_PITCH, (void*)tempDrawBuffer);
01102           }
01103      }
01104 
01105      sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);     
01106      sceGuDrawBufferList(GU_PSM_8888, (void*)graphicsDrawBuffer, SCREEN_STRIDE);
01107      //sceGuDrawBufferList(GU_PSM_8888, (void*)graphicsRenderTarget, graphicsRenderTargetStride);
01108      
01109      memFree(tempPalette);
01110      
01111      #if ((FL_MEMORY_VMEM_CACHE < 16384) && FL_MEMORY_VMEM)
01112      vmemFree(tempBuffer);
01113      #endif
01114      
01115      #if FL_TEXTURE
01116      texBound = NULL;
01117      palBound = NULL;
01118      #endif
01119 }
01120 
01121 void graphicsEffectFsGlow() {
01122      #if FL_MEMORY_VMEM_CACHE < 16384
01123      #if FL_MEMORY_VMEM != 0
01124      char* tempBuffer = vmemAlloc(16384);
01125      if(!tempBuffer) {
01126           #if DEBUG_ERROR != 0
01127           debugWarning("Couldn't allocate the 16k of vram required to perform this effect in hardware.\nSkipping algorithm.");
01128           #endif
01129           return;        
01130      }
01131      #else
01132      char* tempBuffer = (void*)0x44015400;
01133      return;
01134      #endif
01135      #else
01136      char* tempBuffer = (char*)vmemCache;
01137      #endif
01138      
01139      u8* tempPalette = memQalloc(3072);
01140      if(!tempPalette) {
01141           #if DEBUG_ERROR != 0
01142           debugWarning("Couldn't allocate aligned 1024 byte palette.\nSkipping algorithm");
01143           #endif
01144           #if ((FL_MEMORY_VMEM_CACHE < 16384) && FL_MEMORY_VMEM)
01145           vmemFree(tempBuffer);
01146           #endif
01147           graphicsEffectFsNightVisionSW();
01148           return;
01149      }
01150      u8* tempPtr = tempPalette;
01151      int i; u8 tempColor;
01152      for(i = 0; i < 256; i++) {
01153           tempColor = ((i * i) / 255);
01154           *(tempPtr++) = (tempColor >> 1);
01155           *(tempPtr++) = (tempColor >> 2);
01156           *(tempPtr++) = (tempColor >> 1);
01157           *(tempPtr++) = 0xFF;
01158      }
01159      
01160      for(i = 0; i < 256; i++) {
01161           tempColor = ((i * i) / 255);
01162           *(tempPtr++) = (tempColor >> 2);
01163           *(tempPtr++) = (tempColor >> 1);
01164           *(tempPtr++) = (tempColor >> 2);
01165           *(tempPtr++) = 0xFF;
01166      }
01167      
01168      for(i = 0; i < 256; i++) {
01169           tempColor = ((i * i) / 255);
01170           *(tempPtr++) = (tempColor >> 2);
01171           *(tempPtr++) = (tempColor >> 2);
01172           *(tempPtr++) = (tempColor >> 1);
01173           *(tempPtr++) = 0xFF;
01174      }
01175 
01176      sceKernelDcacheWritebackInvalidateAll();
01177 
01178      #if FL_VMEM != 0
01179      void* tempDrawBuffer = memUncachedPtr(vmemAbsolutePtr(graphicsDrawBuffer));
01180      #else
01181      void* tempDrawBuffer = (void*)((unsigned int)graphicsDrawBuffer | 0x44000000);
01182      #endif
01183 
01184      sceGuBlendFunc(GU_ADD, GU_FIX, GU_FIX, 0x00FFFFFF, 0x00FFFFFF);
01185      
01186      int j;
01187      vertTsVs* tempVerts = NULL;
01188      vertTfVs* tempVertsf = NULL;
01189      for(j = 0; j < SCREEN_HEIGHT; j += blockHeight) {
01190           for(i = 0; i < SCREEN_PITCH; i += blockWidth) {
01191                sceGuDrawBufferList(GU_PSM_8888, memCachedPtr(vmemRelativePtr(tempBuffer)), blockWidth);
01192                 
01193                sceGuTexImage(0, blockWidthSafe, blockHeightSafe, SCREEN_PITCH, (void*)((unsigned int)tempDrawBuffer + (((j * SCREEN_PITCH) + i) << 2)));
01194                sceGuTexFunc(GU_TFX_DECAL, GU_TCC_RGB);
01195                sceGuTexFilter(GU_NEAREST, GU_NEAREST);
01196                sceGuTexMode(GU_PSM_T32, 0, 0, GU_FALSE);
01197      
01198                sceGuClutLoad(32, (void*)tempPalette);
01199                sceGuClutMode(GU_PSM_8888, 0, 0xFF, 0);
01200                tempVerts = (vertTsVs*)sceGuGetMemory(sizeof(vertTsVs) << 1);
01201                tempVerts[0].vertX = 0;
01202                tempVerts[0].vertY = 0;
01203                tempVerts[0].vertZ = 0;
01204                tempVerts[0].vertU = 0;
01205                tempVerts[0].vertV = 0;
01206                tempVerts[1].vertX = blockWidthSafe;
01207                tempVerts[1].vertY = blockHeightSafe;
01208                tempVerts[1].vertZ = 0;
01209                tempVerts[1].vertU = blockWidthSafe;
01210                tempVerts[1].vertV = blockHeightSafe;
01211                sceGuDisable(GU_BLEND);
01212                sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, tempVerts);
01213                sceGuEnable(GU_BLEND);
01214                
01215                sceGuClutLoad(32, (void*)((u32)tempPalette + 1024));
01216                sceGuClutMode(GU_PSM_8888, 8, 0xFF, 0);
01217                tempVerts = (vertTsVs*)sceGuGetMemory(sizeof(vertTsVs) << 1);
01218                tempVerts[0].vertX = 0;
01219                tempVerts[0].vertY = 0;
01220                tempVerts[0].vertZ = 0;
01221                tempVerts[0].vertU = 0;
01222                tempVerts[0].vertV = 0;
01223                tempVerts[1].vertX = blockWidthSafe;
01224                tempVerts[1].vertY = blockHeightSafe;
01225                tempVerts[1].vertZ = 0;
01226                tempVerts[1].vertU = blockWidthSafe;
01227                tempVerts[1].vertV = blockHeightSafe;
01228                sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, tempVerts);
01229                
01230                sceGuClutLoad(32, (void*)((u32)tempPalette + 2048));
01231                sceGuClutMode(GU_PSM_8888, 16, 0xFF, 0);
01232                tempVerts = (vertTsVs*)sceGuGetMemory(sizeof(vertTsVs) << 1);
01233                tempVerts[0].vertX = 0;
01234                tempVerts[0].vertY = 0;
01235                tempVerts[0].vertZ = 0;
01236                tempVerts[0].vertU = 0;
01237                tempVerts[0].vertV = 0;
01238                tempVerts[1].vertX = blockWidthSafe;
01239                tempVerts[1].vertY = blockHeightSafe;
01240                tempVerts[1].vertZ = 0;
01241                tempVerts[1].vertU = blockWidthSafe;
01242                tempVerts[1].vertV = blockHeightSafe;
01243                sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, tempVerts);
01244 
01245                sceGuDrawBufferList(GU_PSM_8888, (void*)graphicsDrawBuffer, SCREEN_STRIDE);
01246 
01247                sceGuTexImage(0, blockWidthSafe, blockHeightSafe, blockWidth, (void*)tempBuffer);
01248                sceGuTexFunc(GU_TFX_DECAL, GU_TCC_RGB);
01249                sceGuTexMode(GU_PSM_8888, 0, 0, GU_FALSE);
01250                sceGuTexFilter(GU_LINEAR, GU_LINEAR);               
01251 
01252                sceGuTexWrap(GU_CLAMP, GU_CLAMP);
01253 
01254                tempVertsf = (vertTfVs*)sceGuGetMemory(sizeof(vertTfVs) << 1);
01255                tempVertsf[0].vertX = i;
01256                tempVertsf[0].vertY = j;
01257                tempVertsf[0].vertZ = 0;
01258                tempVertsf[0].vertU = -1.0f;
01259                tempVertsf[0].vertV = -1.0f;
01260                tempVertsf[1].vertX = i + blockWidthSafe;
01261                tempVertsf[1].vertY = j + blockHeightSafe;
01262                tempVertsf[1].vertZ = 0;
01263                tempVertsf[1].vertU = (float)(blockWidthSafe + 1);
01264                tempVertsf[1].vertV = (float)(blockHeightSafe + 1);
01265                sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, tempVerts);
01266 
01267                sceGuTexWrap(GU_REPEAT, GU_REPEAT);
01268                tempVerts = (vertTsVs*)sceGuGetMemory(sizeof(vertTsVs) << 1);
01269                tempVerts[0].vertX = i;
01270                tempVerts[0].vertY = j;
01271                tempVerts[0].vertZ = 0;
01272                tempVerts[0].vertU = 1;
01273                tempVerts[0].vertV = 1;
01274                tempVerts[1].vertX = i + blockWidthSafe;
01275                tempVerts[1].vertY = j + blockHeightSafe;
01276                tempVerts[1].vertZ = 0;
01277                tempVerts[1].vertU = (blockWidthSafe - 1);
01278                tempVerts[1].vertV = (blockHeightSafe - 1);
01279                sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, tempVerts);
01280            }
01281      }
01282 
01283      sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
01284      //sceGuDrawBufferList(GU_PSM_8888, (void*)graphicsRenderTarget, graphicsRenderTargetStride);
01285      
01286      memFree(tempPalette);
01287      
01288      #if ((FL_MEMORY_VMEM_CACHE < 16384) && FL_MEMORY_VMEM)
01289      vmemFree(tempBuffer);
01290      #endif
01291      
01292      #if FL_TEXTURE
01293      texBound = NULL;
01294      palBound = NULL;
01295      #endif
01296 }
01297 
01298 void graphicsEffectFsDepthFog(u32 inColor, bool inLowBit) {
01299      u8* tempPalette = memQalloc(1024);
01300      if(!tempPalette) {
01301           #if DEBUG_ERROR != 0
01302           debugWarning("Couldn't allocate aligned 1024 byte palette.");
01303           #endif
01304           return;
01305      }
01306      u8* tempPtr = tempPalette;
01307      int i;
01308      for(i = 0; i < 256; i++) {
01309           *(tempPtr++) = color8888_Red(inColor);
01310           *(tempPtr++) = color8888_Green(inColor);
01311           *(tempPtr++) = color8888_Blue(inColor);
01312           *(tempPtr++) = ((i * i) / 255);
01313      }
01314 
01315      sceKernelDcacheWritebackInvalidateAll();
01316      sceGuClutLoad(32, (void*)tempPalette);
01317      sceGuClutMode(GU_PSM_8888, (inLowBit ? 0 : 8), 0xFF, 0);
01318 
01319      #if FL_VMEM != 0
01320      void* tempDepthBuffer = memUncachedPtr(vmemAbsolutePtr(graphicsDepthBuffer));
01321      #else
01322      void* tempDepthBuffer = (void*)((unsigned int)graphicsDepthBuffer | 0x44000000);
01323      #endif
01324 
01325      sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA);
01326      sceGuTexFilter(GU_NEAREST, GU_NEAREST);
01327      sceGuTexMode(GU_PSM_T16, 0, 0, GU_FALSE);
01328      
01329      sceGuDisable(GU_DEPTH_TEST);
01330      
01331      vertTsVs* tempVerts = NULL;
01332      for(i = 0; i < SCREEN_WIDTH; i += blockWidth) {
01333           sceGuTexImage(0, blockWidthSafe, SCREEN_PITCH, SCREEN_PITCH, (void*)((unsigned int)tempDepthBuffer + (i << 1)));
01334           tempVerts = (vertTsVs*)sceGuGetMemory(sizeof(vertTsVs) << 1);
01335           tempVerts[0].vertX = i;
01336           tempVerts[0].vertY = 0;
01337           tempVerts[0].vertZ = 0;
01338           tempVerts[0].vertU = 0;
01339           tempVerts[0].vertV = 0;
01340           tempVerts[1].vertX = i + blockWidthSafe;
01341           tempVerts[1].vertY = SCREEN_HEIGHT;
01342           tempVerts[1].vertZ = 0;
01343           tempVerts[1].vertU = blockWidthSafe;
01344           tempVerts[1].vertV = SCREEN_HEIGHT;
01345           sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, tempVerts);
01346      }
01347      
01348      sceGuEnable(GU_DEPTH_TEST);
01349 
01350      memFree(tempPalette);
01351      
01352      #if FL_TEXTURE
01353      texBound = NULL;
01354      palBound = NULL;
01355      #endif
01356 }
01357 
01358 #endif

Generated on Wed Sep 5 19:04:00 2007 for funcLib by  doxygen 1.5.1