#139552 - Ruben - Fri Sep 07, 2007 12:23 pm
I was recently programming a text system into my demo but I just can't seem to get it to work! It's driving me CRAZY! I'm using variable widths which explains why it's harder. All my font data is stored in a 'const u8' array which is acessed when needed. The text is drawn onto the screen by copying the required tiles into the VRAM so I can get the variable width thing. But whenever I try it, it fails! Here's the code I'm currently using:
'TextWidths[]' is an array containing all the character widths. 'FontData[]' is the u8 array containing the image. Can someone please tell me what I'm doing wrong as it is REALLY annoying when you can't get it to work! Thanks guys!
Code: |
//This Draws Text onto the Screen void DrawText(char* Text) { //Return if Text isn't Initialized if(!TextInitialized) return; u16 i, j, k; u16 CurrentChar; u16 CurrentOffset = 0; u16 CurrentWidth; u16* charBaseBlock = (u16*)0x6004000; for(i=0;Text[i]!=0;i++) { CurrentChar = Text[i]-32; CurrentWidth = TextWidths[CurrentChar]; for(j=0;j<8;j++) { //Height for(k=0;k<CurrentWidth;k++) { //Width charBaseBlock[CurrentOffset+(j*CurrentWidth)+k] = FontData[(CurrentChar*64)+(j*CurrentWidth)+k]; } } CurrentOffset += 8*CurrentWidth; } } |
'TextWidths[]' is an array containing all the character widths. 'FontData[]' is the u8 array containing the image. Can someone please tell me what I'm doing wrong as it is REALLY annoying when you can't get it to work! Thanks guys!