- Main Page
- Classes
- Files

- File List
- File Members

# flFont.c

Go to the documentation of this file.

    00001 #include "flGlobal.h"
    00002 #if FL_FONT != 0
    00003 #include <string.h>
    00004 #include <stdio.h>
    00005 #include <pspgu.h>
    00006 #include <pspkernel.h>
    00007
    00008 #if FL_GRAPHICS == 0
    00009 #include <pspdebug.h>
    00010 #endif
    00011
    00012 #if FL_INCLUDE_ALL_C == 0
    00013 #include "flFont.h"
    00014 #include "flMemory.h"
    00015
    00016 #if FL_DEBUG != 0
    00017 #include "flDebug.h"
    00018 #endif
    00019
    00020 #if FL_GRAPHICS != 0
    00021 #include "flGraphics.h"
    00022 #if FL_GRAPHICS_2D != 0
    00023 #include "flGraphics2d.h"
    00024 #endif
    00025 #endif
    00026 #endif
    00027
    00028 #if FL_GRAPHICS != 0
    00029 extern u8 msx[];
    00030 u8* fontDebugTex = NULL;
    00031 u8* fontMonoPal = NULL;
    00032 //u32 fontDebugColorCur     = 0xFFFFFFFF;
    00033 //u32 fontDebugBackColorCur = 0x00FFFFFF;
    00034 #endif
    00035
    00036 Font* fontDefault = NULL;
    00037
    00038 void fontInit() {
    00039      fontDefault = fontCreateDebug(0, 0, FL_FONT_COLOR_DEFAULT);
    00040 }
    00041
    00042 Font* fontLoad(char* inPath) {
    00043      Font* tempOut = NULL;
    00044      #if FL_TEXTURE != 0
    00045      Texture* tempTex = texLoad(inPath);
    00046      if(tempTex) {
    00047           tempOut = fontCreateTexture(tempTex, FL_FONT_HSPACE_DEFAULT, FL_FONT_VSPACE_DEFAULT, FL_FONT_COLOR_DEFAULT);
    00048           tempOut->fontDataGlobal = false;
    00049           return tempOut;
    00050      }
    00051      #endif
    00052
    00053      char tempExt[5];
    00054      strcpy(tempExt, &inPath[strlen(inPath) - 4]);
    00055      int i;
    00056      for(i = 0; i < 4; i++) {
    00057           if((tempExt[i] >= ASCII_A) && (tempExt[i] <= ASCII_Z))
    00058                tempExt[i] = (tempExt[i] - 32);
    00059      }
    00060      if(strcmp(tempExt, ".pgf") == 0) {
    00061           #if FL_FONT_PGF != 0
    00062           return fontLoadPGF(inPath);
    00063           #else
    00064           #if FL_DEBUG_DEVWARNING != 0
    00065           debugDevWarning("PGF textures not supported in this build.");
    00066           #endif
    00067           #endif
    00068      }
    00069
    00070      #if FL_DEBUG_WARNING != 0
    00071      char tempString[256];
    00072      sprintf(tempString, "Error loading font(%s).", inPath);
    00073      #if FL_TEXTURE != 0
    00074      sprintf(tempString, "%s\nTry including TEXTURE for more success.", tempString);
    00075      #endif
    00076      debugWarning(tempString);
    00077      #endif
    00078
    00079      return NULL;
    00080 }
    00081
    00082 bool fontSave(char* inPath, Font* inFont) {
    00083      #if FL_DEBUG_DEVWARNING != 0
    00084      debugDevWarning("fontSave not yet implemented.");
    00085      #endif
    00086      return false;
    00087 }
    00088
    00089 #if FL_TEXTURE != 0
    00090 Font* fontCreateTexture(Texture* inTex, int inHSpace, int inVSpace, u32 inColor) {
    00091      if(!inTex) {
    00092           #if FL_DEBUG_WARNING != 0
    00093           debugWarning("Trying to create font from NULL texture.");
    00094           #endif
    00095           return NULL;
    00096      }
    00097      Font* tempOut = memAlloc(sizeof(Font));
    00098      if(!tempOut) {
    00099           #if FL_DEBUG_WARNING != 0
    00100           debugWarning("Error couldn't create font structure.\nProbably out of memory.");
    00101           #endif
    00102           return NULL;
    00103      }
    00104      tempOut->fontType = FONT_TYPE_TEXTURE;
    00105      tempOut->fontData = inTex;
    00106      tempOut->fontHSpace = inHSpace;
    00107      tempOut->fontVSpace = inVSpace;
    00108      tempOut->fontColor = inColor;
    00109      tempOut->fontBackColor = (inColor & 0x00FFFFFF);
    00110      tempOut->fontFixedWidth = true;
    00111      tempOut->fontDataGlobal = true;
    00112
    00113      return tempOut;
    00114 }
    00115 #endif
    00116
    00117 Font* fontCreateDebug(int inHSpace, int inVSpace, u32 inColor) {
    00118      Font* tempOut = memAlloc(sizeof(Font));
    00119      if(!tempOut) {
    00120           #if FL_DEBUG_WARNING != 0
    00121           debugWarning("Error couldn't create font structure.\nProbably out of memory.");
    00122           #endif
    00123           return NULL;
    00124      }
    00125      tempOut->fontHSpace = inHSpace;
    00126      tempOut->fontVSpace = inVSpace;
    00127      tempOut->fontColor = inColor;
    00128      tempOut->fontBackColor = (inColor & 0x00FFFFFF);
    00129      tempOut->fontFixedWidth = true;
    00130      tempOut->fontType = FONT_TYPE_DEBUG;
    00131      tempOut->fontData = NULL;
    00132      tempOut->fontDataGlobal = true;
    00133
    00134      #if FL_GRAPHICS != 0
    00135      if(!fontDebugTex)
    00136           fontCreateDebugTex();
    00137      #endif
    00138
    00139      return tempOut;
    00140 }
    00141
    00142 #if FL_GRAPHICS != 0
    00143 bool fontCreateDebugTex() {
    00144      u8* tempFont = msx;
    00145
    00146      #if FL_MEMORY_VMEM != 0
    00147      u8* tempBuffer = vmemAlloc(8192);
    00148      if(!tempBuffer)
    00149           tempBuffer = memAlign(16, 8192);
    00150      #else
    00151      u8* tempBuffer = memAlign(16, 8192);
    00152      #endif
    00153
    00154      if(!tempBuffer) {
    00155           #if FL_DEBUG_ERROR != 0
    00156           debugError("Not enough memory to create CLUT4 debug font.");
    00157           #endif
    00158           return false;
    00159      }
    00160      u8* tempBufferPtr = tempBuffer;
    00161      u8  tempPixel = 0;
    00162      int i;
    00163      for(i = 0; i < 16384; i++) {
    00164           tempPixel >>= 4;
    00165           if(*tempFont & (128 >> (i & 7)))
    00166                tempPixel += 0xF0;
    00167           if(i & 1) {
    00168                *tempBufferPtr = tempPixel;
    00169                tempPixel = 0;
    00170                tempBufferPtr++;
    00171           }
    00172           if((i & 1023) == 1023) {
    00173                tempFont++;
    00174           } else if((i & 127) == 127) {
    00175                tempFont -= 119;
    00176           } else if((i & 7) == 7) {
    00177                tempFont += 8;
    00178           }
    00179      }
    00180
    00181      graphicsSwizzleData(tempBuffer, 128, 128, GU_PSM_T4);
    00182      fontDebugTex = tempBuffer;
    00183
    00184      /*#if FL_MEMORY_VMEM != 0
    00185      fontMonoPal = vmemAlloc(64);
    00186      if(!fontMonoPal)
    00187           fontMonoPal = memAlign(16, 64);
    00188      #else*/
    00189      fontMonoPal = memAlign(16, 64);
    00190      //#endif
    00191
    00192      tempBuffer = fontMonoPal;
    00193      for(i = 0; i < 16; i++) {
    00194           *(tempBuffer++) = 0xFF;
    00195           *(tempBuffer++) = 0xFF;
    00196           *(tempBuffer++) = 0xFF;
    00197           *(tempBuffer++) = (i * 17);
    00198      }
    00199
    00200      sceKernelDcacheWritebackRange((void*)fontMonoPal, 64);
    00201
    00202      return true;
    00203 }
    00204 #endif
    00205
    00206 void fontFree(Font* inFont) {
    00207      if(!inFont) {
    00208           #if FL_DEBUG_WARNING != 0
    00209           debugWarning("Trying to free a NULL font.");
    00210           #endif
    00211           return;
    00212      }
    00213      if(!inFont->fontDataGlobal) {
    00214           #if FL_TEXTURE != 0
    00215           if((inFont->fontType == FONT_TYPE_TEXTURE) || (inFont->fontType == FONT_TYPE_TEXTURE_MONO)) {
    00216                texFree(inFont->fontData);
    00217           }
    00218           #endif
    00219      }
    00220      memFree(inFont);
    00221 }
    00222
    00223
    00224
    00225
    00226
    00227 int fontHeight(Font* inFont) {
    00228      #if FL_TEXTURE != 0
    00229      if((inFont->fontType == FONT_TYPE_TEXTURE) || (inFont->fontType == FONT_TYPE_TEXTURE_MONO)) {
    00230           if(!inFont->fontData) {
    00231                #if FL_DEBUG_WARNING != 0
    00232                debugWarning("Texture font has no data.");
    00233                #endif
    00234                return 0;
    00235           }
    00236           Texture* tempTex = (Texture*)inFont->fontData;
    00237           return (tempTex->texHeight >> 4);
    00238      }
    00239      #endif
    00240      if(inFont->fontType == FONT_TYPE_DEBUG)
    00241           return 8;
    00242      return 0;
    00243 }
    00244
    00245 int fontCharWidth(Font* inFont, char inChar) {
    00246      if(inFont->fontFixedWidth) {
    00247           #if FL_TEXTURE != 0
    00248           if((inFont->fontType == FONT_TYPE_TEXTURE) || (inFont->fontType == FONT_TYPE_TEXTURE_MONO)) {
    00249                if(!inFont->fontData) {
    00250                     #if FL_DEBUG_WARNING != 0
    00251                     debugWarning("Texture font has no data.");
    00252                     #endif
    00253                     return 0;
    00254                }
    00255                Texture* tempTex = (Texture*)inFont->fontData;
    00256                if(inChar == ASCII_TAB)
    00257                     return ((tempTex->texWidth >> 4) * FL_FONT_TABWIDTH_DEFAULT);
    00258                else if(inChar == ASCII_BS)
    00259                     return (0 - (tempTex->texWidth >> 4));
    00260                return (tempTex->texWidth >> 4);
    00261           }
    00262           #endif
    00263           if(inFont->fontType == FONT_TYPE_DEBUG) {
    00264                if(inChar == ASCII_TAB)
    00265                     return (8 * FL_FONT_TABWIDTH_DEFAULT);
    00266                else if(inChar == ASCII_BS)
    00267                     return -8;
    00268                return 8;
    00269           }
    00270      }
    00271
    00272      // TODO - Variable width fonts.
    00273
    00274      return 0;
    00275 }
    00276
    00277 int fontStringWidth(Font* inFont, char* inString) {
    00278      int tempMax = 0;
    00279      unsigned int i;
    00280      int tempCur = 0;
    00281      for(i = 0; i < strlen(inString); i++) {
    00282           if(((unsigned char)inString[i] < ASCII_SPACE) || ((unsigned char)inString[i] == 0x7F) || ((unsigned char)inString[i] == 0xFF))
    00283                continue;
    00284           if(inString[i] == ASCII_LF) {
    00285                if(tempCur > tempMax)
    00286                     tempMax = tempCur;
    00287                tempCur = 0;
    00288           } else {
    00289                tempCur += fontCharWidth(inFont, inString[i]) + inFont->fontHSpace;
    00290           }
    00291      }
    00292      if(tempMax > tempCur)
    00293           return tempMax;
    00294      return tempCur;
    00295 }
    00296
    00297 int fontStringHeight(Font* inFont, char* inString) {
    00298      int tempOut = fontHeight(inFont);
    00299      char* tempPtr;
    00300      for(tempPtr = inString; tempPtr[0] != 0; tempPtr++) {
    00301           if(tempPtr[0] == '\n')
    00302                tempOut += fontHeight(inFont);
    00303      }
    00304      return tempOut;
    00305 }
    00306
    00307
    00308
    00309
    00310 bool fontDraw2dChar(int inX, int inY, Font* inFont, char inChar) {
    00311      #if FL_GRAPHICS != 0
    00312      #if FL_TEXTURE != 0
    00313      if((inFont->fontType == FONT_TYPE_TEXTURE) || (inFont->fontType == FONT_TYPE_TEXTURE_MONO)) {
    00314           if(!inFont->fontData) {
    00315                #if FL_DEBUG_WARNING != 0
    00316                debugWarning("Texture font has no data.");
    00317                #endif
    00318                return false;
    00319           }
    00320           if(inFont->fontType == FONT_TYPE_TEXTURE_MONO) {
    00321                Texture* tempTex = (Texture*)inFont->fontData;
    00322                u32* tempColorPtr = (u32*)tempTex->texPalette->palData;
    00323                if((inFont->fontColor != tempColorPtr[15]) || (inFont->fontBackColor != tempColorPtr[0])) {
    00324                     palFree(tempTex->texPalette);
    00325                     tempTex->texPalette = NULL;
    00326                     tempTex->texPalette = palCreateMonoT4(inFont->fontColor, inFont->fontBackColor);
    00327                     if(!tempTex->texPalette) {
    00328                          #if FL_DEBUG_ERROR != 0
    00329                          debugError("Couldn't recreate palette for mono texture.");
    00330                          #endif
    00331                          return false;
    00332                     }
    00333                }
    00334                if(!tempTex->texPalette) {
    00335                     #if FL_DEBUG_ERROR != 0
    00336                     debugError("Can't draw from mono texture, as it has no palette.");
    00337                     #endif
    00338                     return false;
    00339                }
    00340           } else {
    00341                if((inFont->fontBackColor & 0xFF000000)!= 0x00000000) {
    00342                     vertCVs* tempBackVerts = (vertCVs*)sceGuGetMemory(sizeof(vertCVs) << 1);
    00343                     tempBackVerts[0].vertX = inX;
    00344                     tempBackVerts[0].vertY = inY;
    00345                     tempBackVerts[0].vertZ = 0;
    00346                     tempBackVerts[0].vertColor = inFont->fontBackColor;
    00347                     tempBackVerts[1].vertX = inX + fontCharWidth(inFont, inChar);
    00348                     tempBackVerts[1].vertY = inY + fontHeight(inFont);
    00349                     tempBackVerts[1].vertZ = 0;
    00350                     tempBackVerts[1].vertColor = inFont->fontBackColor;
    00351                     sceGuDrawArray(GU_SPRITES, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, tempBackVerts);
    00352                }
    00353           }
    00354           texBind((Texture*)inFont->fontData);
    00355           sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA);
    00356           sceGuTexFilter(GU_NEAREST, GU_NEAREST);
    00357           vertTsVs* tempVerts = (vertTsVs*)sceGuGetMemory(sizeof(vertTsVs) << 1);
    00358           tempVerts[0].vertX = inX;
    00359           tempVerts[0].vertY = inY;
    00360           tempVerts[0].vertZ = 0;
    00361           tempVerts[0].vertU = ((inChar & 15) * (((Texture*)inFont->fontData)->texWidth >> 4));
    00362           tempVerts[0].vertV = (((inChar >> 4) & 15) * (((Texture*)inFont->fontData)->texHeight >> 4));
    00363           tempVerts[1].vertX = inX + fontCharWidth(inFont, inChar);
    00364           tempVerts[1].vertY = inY + fontHeight(inFont);
    00365           tempVerts[1].vertZ = 0;
    00366           tempVerts[1].vertU = ((inChar & 15) * (((Texture*)inFont->fontData)->texWidth >> 4)) + fontCharWidth(inFont, inChar);
    00367           tempVerts[1].vertV = (((inChar >> 4) & 15) * (((Texture*)inFont->fontData)->texHeight >> 4)) + fontHeight(inFont);
    00368           sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, tempVerts);
    00369           return true;
    00370      }
    00371      #endif
    00372      if(inFont->fontType == FONT_TYPE_DEBUG) {
    00373           sceGuClutMode(GU_PSM_8888, 0, 0xFF, 0);
    00374           #if FL_TEXTURE
    00375           if((u32)palBound != (u32)fontMonoPal) {
    00376                sceGuClutLoad(2, (void*)fontMonoPal);
    00377                palBound = (void*)fontMonoPal;
    00378           }
    00379           #else
    00380           sceGuClutLoad(2, (void*)fontMonoPal);
    00381           #endif
    00382
    00383           sceGuTexFilter(GU_NEAREST, GU_NEAREST);
    00384           sceGuTexMode(GU_PSM_T4, 0, 0, GU_TRUE);
    00385
    00386           #if FL_TEXTURE
    00387           if((u32)texBound != (u32)fontDebugTex) {
    00388                sceGuTexImage(0, 128, 128, 128, (void*)fontDebugTex);
    00389                texBound = (void*)fontDebugTex;
    00390           }
    00391           #else
    00392           sceGuTexImage(0, 128, 128, 128, (void*)fontDebugTex);
    00393           #endif
    00394
    00395           sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA);
    00396           sceGuColor(inFont->fontColor);
    00397
    00398           vertTsVs* tempVerts = (vertTsVs*)sceGuGetMemory(sizeof(vertTsVs) << 1);
    00399           tempVerts[0].vertX = inX;
    00400           tempVerts[0].vertY = inY;
    00401           tempVerts[0].vertZ = 0;
    00402           tempVerts[0].vertU = ((inChar & 15) << 3);
    00403           tempVerts[0].vertV = (((inChar >> 4) & 15) << 3);
    00404           tempVerts[1].vertX = inX + 8;
    00405           tempVerts[1].vertY = inY + 8;
    00406           tempVerts[1].vertZ = 0;
    00407           tempVerts[1].vertU = ((inChar & 15) << 3) + 8;
    00408           tempVerts[1].vertV = (((inChar >> 4) & 15) << 3) + 8;
    00409           sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, tempVerts);
    00410
    00411           sceGuColor(0xFFFFFFFF);
    00412           return true;
    00413      }
    00414      #else
    00415      if(inFont->fontType == FONT_TYPE_DEBUG) {
    00416           pspDebugScreenSetBackColor(inFont->fontBackColor);
    00417           pspDebugScreenPutChar(inX, inY, inFont->fontColor, (u8)inChar);
    00418           return true;
    00419      }
    00420      #endif
    00421      #if FL_DEBUG_WARNING != 0
    00422      char tempString[512];
    00423      sprintf(tempString, "Error drawing 2d char.");
    00424      #if FL_GRAPHICS == 0
    00425      sprintf(tempString, "%s\nTry including GRAPHICS for more success.", tempString);
    00426      #endif
    00427      #if FL_TEXTURE == 0
    00428      sprintf(tempString, "%s\nTry including TEXTURE for more success.", tempString);
    00429      #endif
    00430      debugWarning(tempString);
    00431      #endif
    00432      return false;
    00433 }
    00434
    00435 void fontDraw2dString(int inX, int inY, Font* inFont, char* inString) {
    00436      if(!inFont || !inString || !inString[0])
    00437           return;
    00438      #if FL_GRAPHICS != 0
    00439      #if FL_TEXTURE != 0
    00440      if((inFont->fontType == FONT_TYPE_TEXTURE) || (inFont->fontType == FONT_TYPE_TEXTURE_MONO)) {
    00441           if(!inFont->fontData) {
    00442                #if FL_DEBUG_WARNING != 0
    00443                debugWarning("Texture font has no data.");
    00444                #endif
    00445                return;
    00446           }
    00447           if(inFont->fontType == FONT_TYPE_TEXTURE_MONO) {
    00448                Texture* tempTex = (Texture*)inFont->fontData;
    00449                u32* tempColorPtr = (u32*)tempTex->texPalette->palData;
    00450                if((inFont->fontColor != tempColorPtr[15]) || (inFont->fontBackColor != tempColorPtr[0])) {
    00451                     palFree(tempTex->texPalette);
    00452                     tempTex->texPalette = NULL;
    00453                     tempTex->texPalette = palCreateMonoT4(inFont->fontColor, inFont->fontBackColor);
    00454                     if(!tempTex->texPalette) {
    00455                          #if FL_DEBUG_ERROR != 0
    00456                          debugError("Couldn't recreate palette for mono texture.");
    00457                          #endif
    00458                          return;
    00459                     }
    00460                }
    00461                if(!tempTex->texPalette) {
    00462                     #if FL_DEBUG_ERROR != 0
    00463                     debugError("Can't draw from mono texture, as it has no palette.");
    00464                     #endif
    00465                     return;
    00466                }
    00467           }
    00468           sceGuDisable(GU_DEPTH_TEST);
    00469           texBind((Texture*)inFont->fontData);
    00470           sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA);
    00471           sceGuTexFilter(GU_NEAREST, GU_NEAREST);
    00472      }
    00473      vertCVs* tempBackVerts;
    00474      #else
    00475      if(inFont->fontType == FONT_TYPE_DEBUG)
    00476           pspDebugScreenSetBackColor(inFont->fontBackColor);
    00477      #endif
    00478      if(inFont->fontType == FONT_TYPE_DEBUG) {
    00479           sceGuDisable(GU_DEPTH_TEST);
    00480           sceGuClutMode(GU_PSM_8888, 0, 0xFF, 0);
    00481
    00482           #if FL_TEXTURE
    00483           if((u32)palBound != (u32)fontMonoPal) {
    00484                sceGuClutLoad(2, (void*)fontMonoPal);
    00485                palBound = (void*)fontMonoPal;
    00486           }
    00487           #else
    00488           sceGuClutLoad(2, (void*)fontMonoPal);
    00489           #endif
    00490
    00491           sceGuTexFilter(GU_NEAREST, GU_NEAREST);
    00492           sceGuTexMode(GU_PSM_T4, 0, 0, GU_TRUE);
    00493
    00494           #if FL_TEXTURE
    00495           if((u32)texBound != (u32)fontDebugTex) {
    00496                sceGuTexImage(0, 128, 128, 128, (void*)fontDebugTex);
    00497                texBound = (void*)fontDebugTex;
    00498           }
    00499           #else
    00500           sceGuTexImage(0, 128, 128, 128, (void*)fontDebugTex);
    00501
    00502           #endif
    00503           sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA);
    00504           sceGuColor(inFont->fontColor);
    00505      }
    00506      vertTsVs* tempVerts;
    00507      #endif
    00508
    00509      int tempLen = strlen(inString);
    00510      int tempX, tempY;
    00511      tempX = inX;
    00512      tempY = inY;
    00513      int i;
    00514      for(i = 0; i < tempLen; i++) {
    00515           if(inString[i] == ASCII_LF) {
    00516                tempX = inX;
    00517                tempY += (fontHeight(inFont) + inFont->fontVSpace);
    00518           } else if(inString[i] == ASCII_CR) {
    00519                tempX = inX;
    00520           } else if(inString[i] == ASCII_BS) {
    00521                tempX += (fontCharWidth(inFont, ASCII_BS) - inFont->fontHSpace);
    00522           } else if(inString[i] == ASCII_TAB) {
    00523                tempX += (fontCharWidth(inFont, ASCII_TAB) + inFont->fontHSpace);
    00524           } else if(((unsigned char)inString[i] < ASCII_SPACE) || ((unsigned char)inString[i] == 0x7F) || ((unsigned char)inString[i] == 0xFF)) {
    00525                continue;
    00526           } else {
    00527                #if FL_GRAPHICS != 0
    00528                #if FL_TEXTURE != 0
    00529                if((inFont->fontType == FONT_TYPE_TEXTURE) || (inFont->fontType == FONT_TYPE_TEXTURE_MONO)) {
    00530                     tempVerts = (vertTsVs*)sceGuGetMemory(sizeof(vertTsVs) << 1);
    00531                     tempVerts[0].vertX = tempX;
    00532                     tempVerts[0].vertY = tempY;
    00533                     tempVerts[0].vertZ = 0;
    00534                     tempVerts[0].vertU = ((inString[i] & 15) * (((Texture*)inFont->fontData)->texWidth >> 4));
    00535                     tempVerts[0].vertV = (((inString[i] >> 4) & 15) * (((Texture*)inFont->fontData)->texHeight >> 4));
    00536                     tempVerts[1].vertX = tempX + fontCharWidth(inFont, inString[i]);
    00537                     tempVerts[1].vertY = tempY + fontHeight(inFont);
    00538                     tempVerts[1].vertZ = 0;
    00539                     tempVerts[1].vertU = ((inString[i] & 15) * (((Texture*)inFont->fontData)->texWidth >> 4)) + fontCharWidth(inFont, inString[i]);
    00540                     tempVerts[1].vertV = (((inString[i] >> 4) & 15) * (((Texture*)inFont->fontData)->texHeight >> 4)) + fontHeight(inFont);
    00541                     sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, tempVerts);
    00542                     if((inFont->fontType == FONT_TYPE_TEXTURE) && ((inFont->fontBackColor & 0xFF000000)!= 0x00000000)) {
    00543                          tempBackVerts = (vertCVs*)sceGuGetMemory(sizeof(vertCVs) << 1);
    00544                          tempBackVerts[0].vertX = tempX;
    00545                          tempBackVerts[0].vertY = tempY;
    00546                          tempBackVerts[0].vertZ = 0;
    00547                          tempBackVerts[0].vertColor = inFont->fontBackColor;
    00548                          tempBackVerts[1].vertX = tempX + fontCharWidth(inFont, inString[i]);
    00549                          tempBackVerts[1].vertY = tempY + fontHeight(inFont);
    00550                          tempBackVerts[1].vertZ = 0;
    00551                          tempBackVerts[1].vertColor = inFont->fontBackColor;
    00552                          sceGuDrawArray(GU_SPRITES, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, tempBackVerts);
    00553                     }
    00554                }
    00555                #endif
    00556                if(inFont->fontType == FONT_TYPE_DEBUG) {
    00557                     tempVerts = (vertTsVs*)sceGuGetMemory(sizeof(vertTsVs) << 1);
    00558                     tempVerts[0].vertX = tempX;
    00559                     tempVerts[0].vertY = tempY;
    00560                     tempVerts[0].vertZ = 0;
    00561                     tempVerts[0].vertU = ((inString[i] & 15) << 3);
    00562                     tempVerts[0].vertV = (((inString[i] >> 4) & 15) << 3);
    00563                     tempVerts[1].vertX = tempX + 8;
    00564                     tempVerts[1].vertY = tempY + 8;
    00565                     tempVerts[1].vertZ = 0;
    00566                     tempVerts[1].vertU = ((inString[i] & 15) << 3) + 8;
    00567                     tempVerts[1].vertV = (((inString[i] >> 4) & 15) << 3) + 8;
    00568                     sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, tempVerts);
    00569                }
    00570                #else
    00571                if(inFont->fontType == FONT_TYPE_DEBUG)
    00572                     pspDebugScreenPutChar(tempX, tempY, inFont->fontColor, (u8)inString[i]);
    00573                #endif
    00574                tempX += (fontCharWidth(inFont, inString[i]) + inFont->fontHSpace);
    00575           }
    00576      }
    00577
    00578      #if FL_GRAPHICS != 0
    00579      #if FL_TEXTURE != 0
    00580      if((inFont->fontType == FONT_TYPE_TEXTURE) || (inFont->fontType == FONT_TYPE_TEXTURE_MONO))
    00581           sceGuEnable(GU_DEPTH_TEST);
    00582      #endif
    00583      if(inFont->fontType == FONT_TYPE_DEBUG) {
    00584           sceGuEnable(GU_DEPTH_TEST);
    00585           sceGuColor(0xFFFFFFFF);
    00586      }
    00587      #endif
    00588 }
    00589
    00590 void fontDraw2dStringCenter(int inY, Font* inFont, char* inString) {
    00591      char* tempPtr;
    00592      char* tempLineStart = inString;
    00593      int tempY = inY;
    00594      for(tempPtr = inString; tempPtr[0] != 0; tempPtr++) {
    00595           if(tempPtr[0] == '\n') {
    00596                tempPtr[0] = 0;
    00597                fontDraw2dString(((SCREEN_WIDTH - fontStringWidth(inFont, tempLineStart)) >> 1), tempY, inFont, tempLineStart);
    00598                tempY += fontHeight(inFont);
    00599                tempPtr[0] = '\n';
    00600                tempLineStart = &tempPtr[1];
    00601           }
    00602      }
    00603      if(tempLineStart[0] != 0)
    00604           fontDraw2dString(((SCREEN_WIDTH - fontStringWidth(inFont, tempLineStart)) >> 1), tempY, inFont, tempLineStart);
    00605 }
    00606
    00607 /* REPLACED BY A MACRO
    00608 void fontDraw2dStringFromRight(int inX, int inY, Font* inFont, char* inString) {
    00609      fontDraw2dString((inX - fontStringWidth(inFont, inString)), inY, inFont, inString);
    00610 }*/
    00611
    00612 #endif