website logo
Auteur
avatar
thellier

Forum » » Création-Développement » » Intégration de sprites et décors dans executable OS 4.1 ?


Posté : 28-05-2013 14:56 icone du post

Ou celui ci
http://www.os4depot.net/index.php?function=showfile&file=development/utility/ bindata.lha

mais qui est tellement simple que j'en recopie le source ici

#nclude /string.h>
#nclude /ctype.h>
#nclude /stdio.h>

#define CHAR_COLS 14

int main(int argc, char *argv[])
{
int n;

if(argc<2)
{
fprintf(stderr,"bindata img1 [img2 ...]\n");
return(1);
}

for(n=1; n {
unsigned char c;
FILE *fp;
int m;
char namein[256],*ptr;

strcpy(namein,argv[n]);
ptr=strrchr(namein,'.');
if(ptr!=NULL) ptr[0]='\0';

for(m=0; namein[m]!='\0'; m++)
{
if(!isalnum(namein[m])) namein[m]='_';
}

fp=fopen(argv[n],"rb");
if(fp==NULL)
{
fprintf(stderr,"Couldn't open %s\n",argv[n]);
continue;
}

printf("const unsigned char %s[]={",namein);

m=0;
while(fread(&c,1,1,fp)>0)
{
if(m!=0) printf(",");
if((m%CHAR_COLS)==0) printf("\n\t");
printf("0x%02x",c);
m++;
}
printf("\n\t};\n");
printf("const unsigned int %s_length=%d;\n",namein,m);
fclose(fp);
}

return(0);
}
Message édité par : thellier / 28-05-2013 14:57

Cet article provient de Le site des utilisateurs francophones actuels et futurs d'AmigaOS 4.x
https://amiga-ng.org/viewtopic.php?topic=1554&forum=14