Path: chuka.playstation.co.uk!news From: yaroze@theburrow.co.uk (Barry & Robert Swan) Newsgroups: scee.yaroze.programming.2d_graphics Subject: Re: User defined fonts Date: Mon, 21 Jun 1999 20:49:19 GMT Organization: PlayStation Net Yaroze (SCEE) Lines: 137 Message-ID: <376ea3a1.528157@www.netyaroze-europe.com> References: <7kgohf$4fj24@chuka.playstation.co.uk> <7khhk2$33u2@chuka.playstation.co.uk> <7kijaj$33u7@chuka.playstation.co.uk> <376d35be.13127668@www.netyaroze-europe.com> <7kk0m0$33u17@chuka.playstation.co.uk> NNTP-Posting-Host: p23s06a01.client.global.net.uk X-Newsreader: Forte Free Agent 1.11/32.235 Um, there were reasons for me doing things so badly. it was called 'stupidity'. I mean, at least I could have put the character parsing routine in a seperate function :) I had to do it twice, because first time round I needed to find where the word length would go over the tpage limit of 256 pixels wide, so that I could then start actually drawing the images on the next line. I wasn't limited to one sentance cos it could handle going to a new line. If only id had a bit of thought and included colour codes and tabs and stuff it could have been much nicer. Thinking about it there arent particularly any reasons why it should be limited to 256 pixels wide - just have an area 320 pixels big and use two sprites - a lot better than individual character parsing. Also, this meant I could do some cheesy effects neatly (although there are a lot betteer ones doing it on a char by char basis) - I took the sentance sprite and drew it twice, first with subtractive semi trans, and then additive with a small offset, to give it an antialiased standout effect, which I think is pretty neat. What I would probably do now just to save even more time on parsing tet I would make it a two stage process - on debug versions only it would parse the string so that every character's new code matched exactly the position of the character in the .tim, (ie a = 0, A = 26, ! = 52 or summat like that) and stick this into an .object file, which would then be used by a much simpler and faster text parsing routine (ie no cross checks needed as below). For a final version, just remove the text conversion part, as the object file will still be the same. On Mon, 21 Jun 1999 12:20:16 +1200, "Mario Wynands" wrote: >Barry & Robert Swan wrote in message >news:376d35be.13127668@www.netyaroze-europe.com... >> advenutere game has a text handling routine already done. Mine is >> slightly different to the others. ( i think) >> >> I parse the text string once, and use moveImage to copy each letter >> one at a time from their original location to a part of vram >> designated as the sentance sprite. > >But doesn't this > >a. limit the amount of characters you can have in a sentence >b. restrict you to displaying only a single sentence at a time > >although I like the idea of processing the string only once. > >As for the speed thing, I just had a look at your code and saw > > { > tAscii = tText[tEndWordCheckLetter]; > if (tAscii == 33) tLetterCode = 62; // ! > if (tAscii == 34) tLetterCode = 63; // " > if (tAscii == 39) tLetterCode = 64; // ' > if (tAscii == 40) tLetterCode = 65; // ( > if (tAscii == 41) tLetterCode = 66; // ) > if (tAscii == 43) tLetterCode = 67; // + > if (tAscii == 44) tLetterCode = 68; // , > if (tAscii == 45) tLetterCode = 69; // - > if (tAscii == 46) tLetterCode = 70; // . > if (tAscii == 58) tLetterCode = 71; // : > if (tAscii == 59) tLetterCode = 72; // ; > if (tAscii == 61) tLetterCode = 73; // = > if (tAscii == 63) tLetterCode = 74; // ? > if ((tAscii >47) && (tAscii <58)) tLetterCode = tAscii-48; >// numbers > if ((tAscii >64) && (tAscii <91)) tLetterCode = tAscii-55; >// upper case > if ((tAscii >96) && (tAscii <123)) tLetterCode = tAscii-61; >// lower case > tEndWordX += LetterWidth[tLetterCode]; > tEndWordCheckLetter++; > } > > >It may be better structured like the following > > { > tAscii = tText[tEndWordCheckLetter]; > if ((tAscii >96) && (tAscii <123)) > { > tLetterCode = tAscii-61; // lower case > } > else > { > if ((tAscii >64) && (tAscii <91)) > { > tLetterCode = tAscii-55; // upper case > } > else > { > if ((tAscii >47) && (tAscii <58)) > { > tLetterCode = tAscii-48; // numbers > } > else > { > if (tAscii == 33) tLetterCode = 62; // ! > if (tAscii == 34) tLetterCode = 63; // " > if (tAscii == 39) tLetterCode = 64; // ' > if (tAscii == 40) tLetterCode = 65; // ( > if (tAscii == 41) tLetterCode = 66; // ) > if (tAscii == 43) tLetterCode = 67; // + > if (tAscii == 44) tLetterCode = 68; // , > if (tAscii == 45) tLetterCode = 69; // - > if (tAscii == 46) tLetterCode = 70; // . > if (tAscii == 58) tLetterCode = 71; // : > if (tAscii == 59) tLetterCode = 72; // ; > if (tAscii == 61) tLetterCode = 73; // = > if (tAscii == 63) tLetterCode = 74; // ? > } > } > } > tEndWordX += LetterWidth[tLetterCode]; > tEndWordCheckLetter++; > } > >In theory, if your sentences are made up mostly of upper and lower case >characters then you will be only doing two tests for the majority of each >character in the sentence, instead of doing sixteen tests for every >character as before. That should give you a bit of a speed up (especially >seeing as this test logic appears twice in that function). You could also >try turning all that symbol test stuff into a 'case' statement. > > >Regards > >Mario > >mario@sidhe.co.nz >www.sidhe.co.nz > >