| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | text in graphics mode |
ZZ>
> void draw_char (int c, int x, int y, int colour, PCH pchScreen)
> {
> int p[][8][8] = {
> 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
> 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
> 0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,
> 0,1,1,1,1,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,
> etc...... };
> }
>
> ..the compile takes waaay longer now..a few minutes..
ZZ>
Well don't make that array an automatic (i.e. stack) variable, for a
start. You could turn it into a static variable.
You could even hive it off to a separate module, so that it doesn't
need recompiling every time that the code to actually write the
characters changes.
There's also rather a lot of wasted space there. Making each row a
single 8-bit unsigned char would help. In Metaware High C++ for OS/2
that can be done as follows
ZZ>
> void draw_char (int c, int x, int y, int colour, PCH pchScreen)
> {
> static unsigned char p[][Y_LEN] = {
> 0x2x00000000,
> 0x2x00000000,
> 0x2x00000000,
> 0x2x00000000,
> 0x2x00000000,
> 0x2x00000000,
> 0x2x00000000,
> 0x2x00000000,
> 0x2x00000000,
> 0x2x00111000,
> 0x2x01000100,
> 0x2x01000100,
> 0x2x01111100,
> 0x2x01000100,
> 0x2x01000100,
> 0x2x00000000,
> // And so forth.
> } ;
> }
ZZ>
Other C++ compilers don't support binary integer literal constants, so
you would have to convert to hex, octal, or decimal by hand.
You then have to modify the loop to use a bitmask. You can also do
some invariant code motion, whilst you are at it.
ZZ>
> for (int k = 0 ; k < Y_LEN ; ++k)
> {
> unsigned char bits = p[c][k] ;
> PCH screen = pchScreen + ( (i + k) * X_RES + x ) ;
>
> for (unsigned char mask = 1 >= 1)
> {
> *screen++ = (bits & mask) ? colour : 0 ;
> }
> }
ZZ>
A good optimiser should make a further few improvements to the above
loop, too.
> JdeBP <
___
X MegaMail 2.10 #0:
--- Maximus/2 2.01wb
* Origin: DoNoR/2,Woking UK (0483-725167) (2:440/4)SEEN-BY: 12/2442 54/54 620/243 624/50 632/348 640/820 690/660 711/409 410 413 SEEN-BY: 711/430 807 808 809 934 942 949 712/353 623 713/888 800/1 @PATH: 440/4 141/209 270/101 396/1 3615/50 229/2 12/2442 711/409 54/54 @PATH: 711/808 809 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.