janjan2> avec la fonstion sprite8 c'est 3 fois plus rapide:
// tuto sur les fontes
#define OPTIMIZE_ROM_CALLS
#define SAVE_SCREEN
#include <tigcclib.h>
short _ti89;
short _ti92plus;
short* charwidth = NULL;
unsigned char* charset = NULL; //buffer petite fonte
unsigned char* charset2 = NULL; //buffer fonte moyenne
unsigned char* used_lcdbuffer = LCD_MEM;
char VS[3840]; // ecran virtuel
// Fonte1 et Fonte2 reclamme comme argument le lieu ou l'on veut copier la phrase...
// Ici il s'agit d'un ecran virtuel nommer VS
// d'ou: Font1(..,..,..,VS);
void Fonte1(short x,short y,unsigned char* s,char* VSs) {
while (*s) {
Sprite8(x,y,5,charset+5*(short)(*s),VSs,SPRT_OR);
x+=charwidth[*s++];
}
}
void Fonte2(short x,short y,unsigned char* s,char* VSs) {
while (*s) {
Sprite8(x,y,8,charset2+8*(short)(*s),VSs,SPRT_OR);
x+=6;
s++;
}
}
short IniFonte(void) {
short i;
charwidth = NULL;
charset = NULL;
charset2 = NULL;
used_lcdbuffer = LCD_MEM;
if (!(charset = malloc(256*5))) return 0;
if (!(charwidth = (short*)malloc(256*sizeof(short)))) return 0;
if (!(charset2 = malloc(256*8))) return 0;
SetCurAttr(A_NORMAL);
FontSetSys(F_4x6);
memset(charset,0,256*5);
PortSet(charset,7,5*256-1);
for (i=0;i<256;i++) {
charwidth[i] = FontCharWidth(i);
DrawChar(0,i*5,i,A_REPLACE);
}
PortRestore();
FontSetSys(F_6x8);
memset(charset2,0,256*8);
PortSet(charset2,7,8*256-1);
for (i=0;i<256;i++) {
DrawChar(0,i*8,i,A_REPLACE);
}
PortRestore();
return 1;
}
void RestaureMem(void) {
if (charwidth) {
free(charwidth);charwidth=NULL;
}
if (charset) {
free(charset);charset=NULL;
}
if (charset2) {
free(charset2);charset2=NULL;
}
}
void _main(void)
{
clrscr();
IniFonte();
Fonte1(5,5,"Exemple de texte en petite fonte",VS);
DlgMessage("Routine de Fonte","On ecrit la phrase en petite fonte dans l'ecran virtuel",BT_OK,BT_NONE);
Fonte2(15,15,"Exemple de texte en fonte moyenne",VS);
DlgMessage("Routine de Fonte","On ecrit la phrase en fonte moyenne dans l'ecran virtuel",BT_OK,BT_NONE);
RestaureMem();
DlgMessage("Routine de Fonte","On libere la memoire alouer pour la routine de fonte",BT_OK,BT_NONE);
memcpy(LCD_MEM,VS,LCD_SIZE);
ngetchx();
DlgMessage("Routine de Fonte","Voila ca marche... @+ Nhdpp",BT_OK,BT_NONE);
}