#include "fxlib.h"
#include "stdio.h"
unsigned int key;
int caractere, caractere2;
char chaine[21];
char ident[21];
char domaine[30];
char mdp[30];
char destinataire[40];
char sujet[30];
char corps[50];
int AddIn_main(int isAppli, unsigned short OptionNum){
Bdisp_AllClr_DDVRAM();
demmarage();
identif();
return 1;
}
demmarage(){
int key;
Bdisp_AllClr_DDVRAM();
PrintMini(80,58,"Version 1.0",0);
Bdisp_DrawLineVRAM(10,10,10,50);
Bdisp_DrawLineVRAM(10,50,117,50);
Bdisp_DrawLineVRAM(117,50,117,10);
Bdisp_DrawLineVRAM(10,10,117,10);
Bdisp_DrawLineVRAM(10,10,63,25);
Bdisp_DrawLineVRAM(117,10,63,25);
locate(7,5);
Print("Messagerie");
do{
GetKey(&key);
} while(key != 30004);
Bdisp_AllClr_DDVRAM();
}
identif(){
Bdisp_AllClr_DDVRAM();
locate(1,1);
Print("Identifiant:");
locate(1,2);
Print("+------------------+");
locate(1,3);
Print("| |");
locate(1,4);
Print("+------------------+");
remplichaine();
caractere2=0;
do{
caractere2++;
ident[caractere2] = chaine[caractere2];
} while(caractere2+1 != caractere);
========================== > ICI < ========
locate(2,3);
Print(ident);
do{
GetKey(&key);
} while(key != 30004);
}
remplichaine(){
caractere=0;
do{
caractere++;
======================= > ET ICI < ========
locate(2,3);
Print(chaine);
GetKey(&key);
//==========Conversion==========
if (key==48)key= 71;
if (key==46)key= 61;
if (key==15)key= 51;
if (key==135)key= 41;
if (key==30004)key= 31;
if (key==49)key= 72;
if (key==50)key= 62;
if (key==51)key= 52;
if (key==137)key= 42;
if (key==153)key= 32;
if (key==52)key= 73;
if (key==53)key= 63;
if (key==54)key= 53;
if (key==169)key= 43;
if (key==185)key= 33;
if (key==55)key= 74;
if (key==56)key= 64;
if (key==57)key= 54;
if (key==30025)key= 44;
if (key==30015)key= 34;
if (key==187)key= 75;
if (key==30046)key= 65;
if (key==40)key= 55;
if (key==41)key= 45;
if (key==44)key= 35;
if (key==14)key= 25;
if (key==30001)key= 76;
if (key==149)key= 66;
if (key==133)key= 56;
if (key==129)key= 46;
if (key==130)key= 36;
if (key==131)key= 26;
if (key==30007)key= 77;
if (key==205)key= 67;
if (key==168)key= 57;
if (key==30002)key= 47;
if (key==30023)key= 37;
if (key==30021)key= 27;
if (key==30006)key= 78;
if (key==30008)key= 68;
if (key==30016)key= 58;
if (key==30020)key= 38;
if (key==30018)key= 28;
if (key==30009)key= 79;
if (key==30010)key= 69;
if (key==30011)key= 59;
if (key==30012)key= 49;
if (key==30013)key= 39;
if (key==30014)key= 29;
//==============================
if(key==31)caractere=19;
if(key==76)chaine[caractere]='a';
if(key==66)chaine[caractere]='b';
if(key==56)chaine[caractere]='c';
if(key==46)chaine[caractere]='d';
if(key==36)chaine[caractere]='e';
if(key==26)chaine[caractere]='f';
if(key==75)chaine[caractere]='g';
if(key==65)chaine[caractere]='h';
if(key==55)chaine[caractere]='i';
if(key==45)chaine[caractere]='j';
if(key==35)chaine[caractere]='k';
if(key==25)chaine[caractere]='l';
if(key==74)chaine[caractere]='m';
if(key==64)chaine[caractere]='n';
if(key==54)chaine[caractere]='o';
if(key==73)chaine[caractere]='p';
if(key==63)chaine[caractere]='q';
if(key==53)chaine[caractere]='r';
if(key==43)chaine[caractere]='s';
if(key==33)chaine[caractere]='t';
if(key==72)chaine[caractere]='u';
if(key==62)chaine[caractere]='v';
if(key==52)chaine[caractere]='w';
if(key==42)chaine[caractere]='x';
if(key==32)chaine[caractere]='y';
if(key==71)chaine[caractere]='z';
if(key==61)chaine[caractere]='.';
if(key==57)chaine[caractere]='@';
} while(caractere!=19);
if(key==31)chaine[caractere]='\0';
if(key!=31)chaine[caractere+1]='\0';
}
#pragma section _BR_Size
unsigned long BR_Size;
#pragma section
#pragma section _TOP
int InitializeSystem(int isAppli, unsigned short OptionNum){return INIT_ADDIN_APPLICATION(isAppli, OptionNum);}
#pragma section
Citer : Posté le 10/06/2014 17:50 | # | Fichier joint
Pour ElTo:
Extrait tout et remet le dossier dans le dossier racine du SDK...
Ajouté le 14/06/2014 à 18:16 :
{
int handle, nbr;
char buffer[NBR_AMELIO], buf[3];
unsigned char debug[50];
FONTCHARACTER magasin[]={'\\', '\\', 'f', 'l', 's', '0', '\\', 'E', 'v', 'o', 'F', 'i', 'l', 'e', 's', '\\', 'M', 'a', 'g', 'a', 's', 'i', 'n', '.', 'e', 'v', 0};
handle = Bfile_OpenFile(magasin, _OPENMODE_READ);
Bfile_ReadFile(handle, buffer, NBR_AMELIO, 0);
Bfile_CloseFile(handle);
sprintf(debug,"%d",Bfile_DeleteFile(magasin));
PrintXY(0,0,debug,0);
ML_display_vram();
Sleep(5000);
for(nbr=0;nbr<3;nbr++) buf[nbr] = buffer[3+nbr];
nbr = atoi(buf);
if(nbr != 999) nbr+=sous;
sprintf(buf,"%d",nbr);
for(nbr=0;nbr<3;nbr++) buffer[3+nbr] = buf[nbr];
Bfile_CreateFile(magasin,(NBR_JEUX)*2+1);
handle = Bfile_OpenFile(magasin, _OPENMODE_WRITE);
Bfile_WriteFile(handle, buffer, (NBR_JEUX)*2);
Bfile_CloseFile(handle);
return nbr;
}
Voila une petite fonction qui me permet de gérer le fichier des sous...
Le problème c'est que Bfile_DeleteFile() me renvoi -8 soit "IML_FILEERR_ACCESSDENYED". Pourtant, Bfile_CloseFile() renvoie 0 ...
Citer : Posté le 14/06/2014 18:24 | #
Oui, c'est l'erreur qui se produit lorsque 4 fichiers sont déjà ouverts...
Utilises-tu des fichiers ailleurs dans ton code ?
Citer : Posté le 14/06/2014 20:57 | #
Exact, j'avais fait une bourde plus haut
Merci
Citer : Posté le 14/06/2014 20:58 | #
Dire que j'avais écrit memory pour éviter ce genre de problèmes...
Citer : Posté le 14/06/2014 22:27 | #
oui en fait j'ai démarré la gestion du fichier pendant le down d'une heure et j'avais plus la doc
Du coup j'ai fait avec fxlib vu que le wiki marchait sans problème.
En fait j'avais ouvert tout les fichiers au début pour savoir si ils existaient et après j'ai oublié de les refermer
Ajouté le 07/07/2014 à 15:52 :
Bon j'aurais besoin d'un petit coup de main.
Donc voila j'ai ca:
b = 1593;
c = 1700;
a = b/c*100;
print(a);
Bien sur, vu que c'est des int, je ne peux pas faire ça, ça me donne des résultats incohérents. Donc je voulais savoir quelle était la meilleure méthode pour faire ce calcul
Citer : Posté le 07/07/2014 16:12 | #
C'est la méthode la plus rapide si a reste entier.
Citer : Posté le 07/07/2014 16:24 | #
ok merci ça marche
Citer : Posté le 07/07/2014 16:30 | #
N'oublie pas que les calculs sont effectués dans l'ordre. Imaginons que tu calcules une proportion de a sur b (a<=b), a/b sera compris entre 0 et 1 donc tronqué à 0, et *100 ça fait 0.
Alors que si tu mutliplies d'abord a par 100, tu gagnes deux chiffres significatifs.
Citer : Posté le 08/07/2014 10:42 | #
Commentes ca
{
unsigned char nouv_fichier[200];
unsigned char sauv_fichier[200];
unsigned char nom_fichier[30];
unsigned char buf[30];
unsigned int longueur=0, i=0, j, k, l;
int handle;
argument--;
sprintf(nom_fichier,"\\\\fls0\\FOURMIZ\\%s", nom);
// SAUVEGARDE DU FICHIER
handle = memory_openfile(nom_fichier,_OPENMODE_READ);
do{
memory_readfile(handle,buf,1,longueur);
sauv_fichier[longueur] = buf[0];
longueur++;
}while(buf[0]!='+');
sauv_fichier[longueur] = '\0';
memory_closefile(handle);
// TRAITEMENT
for(j=0,i=0;i!=argument;j++){
if(sauv_fichier[j]=='-') i++;
}
i=j;
while(sauv_fichier[j]!='-' && sauv_fichier[j]!='+') j++;
for(k=0;k<i;k++) nouv_fichier[k] = sauv_fichier[k];
sprintf(buf,"%d",lire_fichier(nom,argument+1)+valeur);
for(l=0;buf[l]!='\0';k++) nouv_fichier[k] = buf[l], l++;
for(l=0;k!=longueur+i;k++) nouv_fichier[k] = sauv_fichier[j+l], l++;
nouv_fichier[k+1] = '\0';
// ENREGISTREMENT
memory_deletefile(nom_fichier);
memory_createfile(nom_fichier,TF);
handle = memory_openfile(nom_fichier,_OPENMODE_WRITE);
memory_writefile(handle,nouv_fichier,TF);
memory_closefile(handle);
}
Citer : Posté le 08/07/2014 10:46 | #
Tu vois, c'est ce que je disais.
Les dernières lignes :
memory_deletefile(nom_fichier);
memory_createfile(nom_fichier,TF);
handle = memory_openfile(nom_fichier,_OPENMODE_WRITE);
memory_writefile(handle,nouv_fichier,TF);
memory_closefile(handle);
Devraient pouvoir être remplacées par :
Citer : Posté le 08/07/2014 10:50 | #
ha je l'avait pas compris comme ca cette fonction
Merci
Ajouté le 09/07/2014 à 13:56 :
Bon encore un problème avec les fichiers apparemment...
#include "memory.h"
#include "MonochromeLib.h"
#include "FOURMIZ.h"
#include <stdio.h>
#include <stdlib.h>
int AddIn_main(int isAppli, unsigned short OptionNum)
{
memory_seterrors(1);
demmarage();
menu_principal();
}
void demmarage()
{
const unsigned char fond[]={
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xe,0x80,0x60,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4,0x84,0x56,0x23,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4,0xca,0x65,0x55,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4,0xa8,0x44,0x53,
0x1,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4,0xa6,0x44,0x21,
0x1,0xc0,0x0,0x0,0x0,0x0,0x60,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7,
0x0,0xe0,0x0,0x0,0x0,0x0,0xe0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x70,0x0,0x0,0x0,0x1,0xc0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x38,0x0,0x0,0x0,0x3,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x1f,0x0,0x0,0x0,0x7,0x0,0x0,0x0,0x0,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0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0xcc,0x40,0x22,0x20,0x32,0x30,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0xa4,0x2a,0x57,0x50,0x41,0x44,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0xc4,0x6d,0x72,0x77,0x43,0x21,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x84,0xa9,0x42,0x40,0x45,0x15,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x8e,0x69,0x31,0x30,0x33,0x64,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0
};
int handle;
unsigned char creation[6]={0};
// IMAGE DE DEMARRAGE
ML_clear_vram();
ML_bmp_or(fond, 0, 0, 128, 64);
PrintMini(110,59,"0.01",0);
ML_display_vram();
ML_clear_vram();
// GESTION DES FICHIERS
memory_createdir("\\\\fls0\\FOURMIZ");
// GLOBAL
if(!memory_exists("\\\\fls0\\FOURMIZ\\glob.txt")){
creation[0]=1;
memory_createfile("\\\\fls0\\FOURMIZ\\glob.txt",TF);
handle = memory_openfile("\\\\fls0\\FOURMIZ\\glob.txt",_OPENMODE_WRITE);
// TDC - ENTREPOT POMME - ENTREPOT BOIS +
memory_writefile(handle,"50-100-300+",TF);
memory_closefile(handle);
}
// LABO
if(!memory_exists("\\\\fls0\\FOURMIZ\\labo.txt")){
creation[1] = 1;
memory_createfile("\\\\fls0\\FOURMIZ\\labo.txt",TF);
handle = memory_openfile("\\\\fls0\\FOURMIZ\\labo.txt",_OPENMODE_WRITE);
// en cours - tech ponte - bouc thorac - armes - archi - commu - vdc - vda - gene - acide - poison +
memory_writefile(handle,"0-0-0-0-0-0-0-0-0-0-0+",TF);
memory_closefile(handle);
}
// CONSTRU
if(!memory_exists("\\\\fls0\\FOURMIZ\\constru.txt")){
creation[2] = 1;
memory_createfile("\\\\fls0\\FOURMIZ\\constru.txt",TF);
handle = memory_openfile("\\\\fls0\\FOURMIZ\\constru.txt",_OPENMODE_WRITE);
// en cours - Champi - EtrepotN - EtrepotB - Couv - Solar - Labo - SalleD'ana - SalledeComb - Caserne - Dome - Loge - EtablePuce - EtableCoco +
memory_writefile(handle,"0-0-0-0-0-0-0-0-0-0-0-0-0-0+",TF);
memory_closefile(handle);
}
// OUVRIERES
if(!memory_exists("\\\\fls0\\FOURMIZ\\ouvri.txt")){
creation[3] = 1;
memory_createfile("\\\\fls0\\FOURMIZ\\ouvri.txt",TF);
handle = memory_openfile("\\\\fls0\\FOURMIZ\\ouvri.txt",_OPENMODE_WRITE);
// total - materiaux - nourriture - convoi +
memory_writefile(handle,"5-1-2-0+",TF);
memory_closefile(handle);
}
// ARMEE
if(!memory_exists("\\\\fls0\\FOURMIZ\\arme.txt")){
creation[4] = 1;
memory_createfile("\\\\fls0\\FOURMIZ\\arme.txt",TF);
handle = memory_openfile("\\\\fls0\\FOURMIZ\\arme.txt",_OPENMODE_WRITE);
// nbr - type - JSN - SN - NE - JS - S - C - A - AE - SE - T - Tu - TuE+ /!\ Ouvriere = -1 ?
memory_writefile(handle,"0-0-0-0-0-0-0-0-0-0-0-0-0+",TF);
memory_closefile(handle);
}
// TEMPS
if(!memory_exists("\\\\fls0\\FOURMIZ\\temps.txt")){
creation[5] = 1;
memory_createfile("\\\\fls0\\FOURMIZ\\temps.txt",TF);
handle = memory_openfile("\\\\fls0\\FOURMIZ\\temps.txt",_OPENMODE_WRITE);
// ponte - chasse - convoi - constru - labo - ressources+
memory_writefile(handle,"0-0-0-0-0-0+",TF);
memory_closefile(handle);
modif_fichier("temps.txt",temps_min(),6);
}
// CHASSE
if(!memory_exists("\\\\fls0\\FOURMIZ\\chasse.txt")){
creation[5] = 1;
memory_createfile("\\\\fls0\\FOURMIZ\\chasse.txt",TF);
handle = memory_openfile("\\\\fls0\\FOURMIZ\\chasse.txt",_OPENMODE_WRITE);
// cm² - nbr de JSN - degat infligé - degats recus + (Petite Araignée = 13PA,59PV;
memory_writefile(handle,"0-0-0-0+",TF);
memory_closefile(handle);
}
test_temps();
}
void menu_principal()
{
const unsigned char banniere[]={
0x3f,0xff,0xf9,0xff,0xff,0xcf,0xff,0xfe,0x7f,0xff,0xf3,0xff,0xff,0x9f,0xff,0xfc,
0x20,0x0,0x1,0x0,0x0,0x8,0x0,0x0,0x40,0x0,0x2,0x0,0x0,0x10,0x0,0x0,
0x20,0x10,0x1,0x0,0x40,0x8,0x15,0x80,0x40,0x6c,0x2,0x1,0x80,0x10,0xc,0x0,
0x20,0x7c,0x1,0x10,0xe1,0x8,0x1d,0xc0,0x40,0x28,0x2,0xf,0x38,0x10,0x2d,0x0,
0x20,0xde,0x1,0x19,0xb3,0x8,0x8,0x80,0x40,0x44,0x2,0x1f,0x3c,0x10,0x6d,0x80,
0x20,0xfe,0x1,0x1f,0xff,0x8,0x8,0x80,0x40,0x82,0x2,0x18,0x6c,0x10,0x61,0x80,
0x20,0xfe,0x1,0x1f,0xff,0x8,0x1c,0x80,0x40,0x82,0x2,0x18,0xc,0x10,0x7f,0x80,
0x20,0x7c,0x1,0x1f,0xff,0x8,0x14,0x80,0x40,0x7c,0x2,0x18,0xc,0x10,0x3f,0x0
};
const unsigned char fond[]={
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0xc,0x0,0x0,0x0,0x0,0x0,0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0x0,0x0,0x0,0x0,0x0,0x0,0x2,0xad,0x15,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x3,0xff,0xff,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0
};
char buffer[100];
unsigned long i, j;
while(1){
ML_clear_vram();
ML_bmp_or(banniere, 0, 56, 128, 8);
ML_bmp_or(fond, 0, 0, 128, 54);
// nbr d'ouvrieres
sprintf(buffer,"%d",lire_fichier("ouvri.txt", 1));
PrintMini(41,2,buffer,0);
// nourriture
sprintf(buffer,"%d",lire_fichier("glob.txt", 2));
PrintMini(42,9,buffer,0);
j=1700;
for(i=0;i<lire_fichier("constru.txt", 3);i++){
j=j*2-500;
}
i=j;
j=100000/j*lire_fichier("glob.txt", 2);
ML_horizontal_line(16, 4, j/1000+4, ML_BLACK);
sprintf(buffer, "%02d%%", 100*lire_fichier("glob.txt", 2)/i);
PrintMini(110,14,buffer,0);
// materiaux
sprintf(buffer,"%d",lire_fichier("glob.txt", 3));
PrintMini(43,20,buffer,0);
j=1700;
for(i=0;i<lire_fichier("constru.txt", 4);i++){
j=j*2-500;
}
i=j;
j=100000/j*lire_fichier("glob.txt", 3);
ML_horizontal_line(27, 4, j/1000+4, ML_BLACK);
sprintf(buffer, "%02d%%", 100*lire_fichier("glob.txt", 3)/i);
PrintMini(110,25,buffer,0);
// TDC
sprintf(buffer,"%d",lire_fichier("glob.txt", 1));
PrintMini(69,31,buffer,0);
i=lire_fichier("glob.txt", 1);
j=100000/i*(lire_fichier("ouvri.txt", 2) + lire_fichier("ouvri.txt", 3));
ML_horizontal_line(38, 4, j/1000+4, ML_BLACK);
sprintf(buffer, "%02d%%", 100*(lire_fichier("ouvri.txt", 2) + lire_fichier("ouvri.txt", 3))/i);
PrintMini(110,36,buffer,0);
SaveDisp(1);
fenetre_o(0,54,1);
SaveDisp(1);
while(!IsKeyDown(KEY_CTRL_F1) && !IsKeyDown(KEY_CTRL_F2) && !IsKeyDown(KEY_CTRL_F3) && !IsKeyDown(KEY_CTRL_F4) && !IsKeyDown(KEY_CTRL_F5) && !IsKeyDown(KEY_CTRL_F6) && !IsKeyDown(KEY_CTRL_EXIT) && !IsKeyDown(KEY_CTRL_ALPHA));
if(IsKeyDown(KEY_CTRL_F1)) ressources();
if(IsKeyDown(KEY_CTRL_F2)) reine();
/*
if(key==KEY_CTRL_F3) construction(),i=1;
if(key==KEY_CTRL_F4) labo(),i=1;
if(key==KEY_CTRL_F5) connection(),i=1;
*/
if(IsKeyDown(KEY_CTRL_F6) || IsKeyDown(KEY_CTRL_EXIT)) return;
}
}
// RESSOURCES (F1)
void ressources()
{
const unsigned char banniere_mp[]={
0x3f,0xff,0xf9,0xff,0xff,0xcf,0xff,0xfe,0x7f,0xff,0xf3,0xff,0xff,0x9f,0xff,0xfc,
0x20,0x0,0x1,0x55,0x55,0x4a,0xaa,0xaa,0x55,0x55,0x52,0xaa,0xaa,0x95,0x55,0x54,
0x20,0x10,0x1,0xaa,0xea,0x8d,0x55,0xd4,0x6a,0xee,0xa3,0x55,0xd5,0x1a,0xae,0xa8,
0x20,0x7c,0x1,0x55,0xf5,0x4a,0xbf,0xea,0x55,0x7d,0x52,0xaf,0xba,0x95,0x7d,0x54,
0x20,0xde,0x1,0xbb,0xbb,0x8d,0x5d,0xd4,0x6a,0xee,0xa3,0x5f,0x7d,0x1a,0xef,0xa8,
0x20,0xfe,0x1,0x5f,0xff,0x4a,0xaa,0xaa,0x55,0xd7,0x52,0xba,0xee,0x95,0x75,0xd4,
0x20,0xfe,0x1,0xbf,0xff,0x8d,0x5d,0xd4,0x6a,0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0,
0x0,0x2,0x2e,0xe8,0x93,0xa1,0xa0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x22,0x20,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x23,0x6e,0xe4,0xeb,0xaa,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x3a,0xaa,0x4a,0xaa,0xa9,0x90,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x2,0x2e,0x48,0x8b,0xa9,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x2,0x2a,0x46,0x8a,0xba,0x50,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0
};
int i;
unsigned long jsn, temps_m, temps_h, temps_j;
unsigned char buffer[50];
test_temps();
jsn = lire_fichier("arme.txt", 3);
if(lire_fichier("temps.txt", 2)) jsn=0;
fenetre_f(0,54,1);
for(i=0;i<10;i++){
ML_clear_vram();
ML_bmp_or(banniere_mp, 0, 56-i, 128, 8);
ML_bmp_or(banniere_ress, 0, 65-i, 128, 8);
ML_display_vram();
Sleep(50);
}
ML_bmp_or(fond, 0, 0, 128, 45);
SaveDisp(2);
fenetre_o(0,45,2);
SaveDisp(2);
while(1){
RestoreDisp(2);
sprintf(buffer, "%u", lire_fichier("ouvri.txt", 3));
PrintMini(53,14,buffer,0);
ML_display_vram();
if(lire_fichier("temps.txt", 2)){
ML_rectangle(23,56,104,65,1,ML_BLACK,ML_WHITE);
temps_m = lire_fichier("temps.txt", 2)-temps_min();
temps_h = temps_m/60;
temps_m %= 60;
temps_j = temps_h/24;
temps_h %= 24;
sprintf(buffer, "%uj %uh %um", temps_j, temps_h, temps_m);
PrintMini(25,58,buffer,0);
}
ML_display_vram();
sprintf(buffer, "%u", lire_fichier("ouvri.txt", 2));
PrintMini(54,20,buffer,0);
ML_display_vram();
sprintf(buffer, "%u", lire_fichier("ouvri.txt", 3)*48);
PrintMini(53,32,buffer,0);
ML_display_vram();
sprintf(buffer, "%u", lire_fichier("ouvri.txt", 2)*48);
PrintMini(54,38,buffer,0);
ML_display_vram();
sprintf(buffer, "%u min", lire_fichier("temps.txt", 6)-temps_min());
PrintMini(78,2,"Retour dans:",0);
PrintMini(102,8,buffer,0);
ML_display_vram();
while(!IsKeyDown(KEY_CTRL_F1) && !IsKeyDown(KEY_CTRL_F2) && !IsKeyDown(KEY_CTRL_F6) && !IsKeyDown(KEY_CTRL_EXIT));
if(IsKeyDown(KEY_CTRL_F1)) ressources_ouv();
if(IsKeyDown(KEY_CTRL_F2) && jsn>0) ressources_chasse();
if(IsKeyDown(KEY_CTRL_F6) || IsKeyDown(KEY_CTRL_EXIT)) break;
}
fenetre_f(0,45,2);
for(i=10;i>=0;i--){
ML_clear_vram();
ML_bmp_or(banniere_mp, 0, 56-i, 128, 8);
ML_bmp_or(banniere_ress, 0, 65-i, 128, 8);
ML_display_vram();
Sleep(50);
}
}
void ressources_ouv()
{
const unsigned char banniere_mp[]={
0x3f,0xff,0xf9,0xff,0xff,0xcf,0xff,0xfe,0x7f,0xff,0xf3,0xff,0xff,0x9f,0xff,0xfc,
0x20,0x0,0x1,0x55,0x55,0x4a,0xaa,0xaa,0x55,0x55,0x52,0xaa,0xaa,0x95,0x55,0x54,
0x20,0x10,0x1,0xaa,0xea,0x8d,0x55,0xd4,0x6a,0xee,0xa3,0x55,0xd5,0x1a,0xae,0xa8,
0x20,0x7c,0x1,0x55,0xf5,0x4a,0xbf,0xea,0x55,0x7d,0x52,0xaf,0xba,0x95,0x7d,0x54,
0x20,0xde,0x1,0xbb,0xbb,0x8d,0x5d,0xd4,0x6a,0xee,0xa3,0x5f,0x7d,0x1a,0xef,0xa8,
0x20,0xfe,0x1,0x5f,0xff,0x4a,0xaa,0xaa,0x55,0xd7,0x52,0xba,0xee,0x95,0x75,0xd4,
0x20,0xfe,0x1,0xbf,0xff,0x8d,0x5d,0xd4,0x6a,0xaa,0xa3,0x5d,0x5d,0x1a,0xff,0xa8,
0x20,0x7c,0x1,0x5f,0xff,0x4a,0xbe,0xaa,0x55,0x7d,0x52,0xba,0xae,0x95,0x7f,0x54
};
const unsigned char banniere_ress[]={
0x3f,0xff,0xf9,0xff,0xff,0xcf,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x9f,0xff,0xfc,
0x20,0x0,0x1,0x55,0x55,0x48,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x95,0x55,0x54,
0x21,0x2,0x71,0xaa,0xea,0x88,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x9a,0xae,0xa8,
0x27,0xc2,0xb9,0x55,0x75,0x48,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x95,0x5f,0x54,
0x2d,0xe4,0xf9,0xab,0xfa,0x88,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x9a,0xbf,0xa8,
0x2f,0xe4,0x71,0x55,0xfd,0x48,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x95,0x5f,0x54,
0x2f,0xe8,0x21,0xaa,0xea,0x88,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x9a,0xae,0xa8,
0x27,0xc8,0x71,0x55,0x75,0x4f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x95,0x55,0x54
};
const unsigned char banniere_ress_ouv[]={
0x3f,0xff,0xf9,0xfe,0x3f,0xcf,0xff,0xfe,0x7f,0xff,0xf3,0xf8,0x3f,0x9f,0xff,0xfc,
0x20,0x0,0x1,0x0,0x80,0x48,0x0,0x0,0x40,0x0,0x2,0x3,0x80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0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x11,0x77,0x44,0x9d,0xd,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x1,0x11,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x1,0x1b,0x77,0x27,0x5d,0x52,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x1,0xd5,0x52,0x55,0x55,0x4c,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x11,0x72,0x44,0x5d,0x4c,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x11,0x52,0x34,0x55,0xd2,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0
};
unsigned char buffer[50];
unsigned long total, bois, pomme, convois, tdc, i, j, k;
total = lire_fichier("ouvri.txt", 1);
bois = lire_fichier("ouvri.txt", 2);
pomme = lire_fichier("ouvri.txt", 3);
convois = lire_fichier("ouvri.txt", 4);
tdc = lire_fichier("glob.txt", 1);
// CHAMPI
j=0;
i=lire_fichier("constru.txt",2);
if(i) j=122;
if(i--){
k=86;
do{
j+=k;
k*=1.7;
}while(i--);
}
pomme+=j;
fenetre_f(0,45,2);
for(i=0;i<9;i++){
ML_clear_vram();
ML_bmp_or(banniere_mp, 0, 46-i, 128, 8);
ML_bmp_or(banniere_ress, 0, 55-i, 128, 8);
ML_bmp_or(banniere_ress_ouv, 0, 64-i, 128, 8);
ML_display_vram();
Sleep(50);
}
ML_bmp_or(fond, 0, 0, 128, 36);
sprintf(buffer, "%u", total);
PrintMini(41,2,buffer,0);
SaveDisp(3);
fenetre_o(0,36,3);
SaveDisp(3);
while(1){
RestoreDisp(3);
sprintf(buffer, "%u", total-bois-pomme-convois);
PrintMini(47,9,buffer,0);
sprintf(buffer, "%u", bois+pomme);
PrintMini(53,15,buffer,0);
sprintf(buffer, "%u", pomme);
PrintMini(58,21,buffer,0);
sprintf(buffer, "%u", bois);
PrintMini(59,27,buffer,0);
ML_display_vram();
if(IsKeyDown(KEY_CTRL_F1) && pomme>0) pomme--;
if(IsKeyDown(KEY_CTRL_F3) && pomme+bois<total-convois && pomme+bois<tdc) pomme++;
if(IsKeyDown(KEY_CTRL_F4) && bois>0) bois--;
if(IsKeyDown(KEY_CTRL_F6) && pomme+bois<total-convois && pomme+bois<tdc) bois++;
if(IsKeyDown(KEY_CTRL_EXIT)) break;
Sleep(10);
if(IsKeyDown(KEY_CTRL_SHIFT)) Sleep(100);
}
modif_fichier("ouvri.txt", bois-lire_fichier("ouvri.txt", 2), 2);
modif_fichier("ouvri.txt", pomme-lire_fichier("ouvri.txt", 3), 3);
SaveDisp(3);
fenetre_f(0,36,3);
for(i=9;i>0;i--){
ML_clear_vram();
ML_bmp_or(banniere_mp, 0, 46-i, 128, 8);
ML_bmp_or(banniere_ress, 0, 55-i, 128, 8);
ML_bmp_or(banniere_ress_ouv, 0, 64-i, 128, 8);
ML_display_vram();
Sleep(50);
}
fenetre_o(0,45,2);
}
void ressources_chasse() // VOIR POUR LES DEGATS
{
const unsigned char banniere_mp[]={
0x3f,0xff,0xf9,0xff,0xff,0xcf,0xff,0xfe,0x7f,0xff,0xf3,0xff,0xff,0x9f,0xff,0xfc,
0x20,0x0,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);
arme = lire_fichier("labo.txt", 4);
bouc = lire_fichier("labo.txt", 3);
vdc = lire_fichier("labo.txt", 7);
tdc = lire_fichier("glob.txt", 1);
fenetre_f(0,45,2);
for(i=0;i<9;i++){
ML_clear_vram();
ML_bmp_or(banniere_mp, 0, 46-i, 128, 8);
ML_bmp_or(banniere_ress, 0, 55-i, 128, 8);
ML_bmp_or(banniere_ress_chasse, 0, 64-i, 128, 8);
ML_display_vram();
Sleep(50);
}
ML_bmp_or(fond, 0, 0, 128, 36);
SaveDisp(3);
fenetre_o(0,36,3);
SaveDisp(3);
capture = 0;
jsn_lance = 1;
while(1){
RestoreDisp(3);
sprintf(buffer, "%u cm2", capture);
PrintMini(40,7,buffer,0);
sprintf(buffer, "%u", tdc+capture);
PrintMini(29,15,buffer,0);
sprintf(buffer, "%u jsn", jsn_lance);
PrintMini(35,22,buffer,0);
ML_display_vram();
if(IsKeyDown(KEY_CTRL_F1) && capture>0) capture--;
if(IsKeyDown(KEY_CTRL_F3) && capture<1000000000) capture++;
if(IsKeyDown(KEY_CTRL_F4) && jsn_lance>1) jsn_lance--;
if(IsKeyDown(KEY_CTRL_F6) && jsn_lance<jsn_dispo) jsn_lance++;
if(IsKeyDown(KEY_CTRL_EXIT)) break;
if(IsKeyDown(KEY_CTRL_SHIFT)) Sleep(100);
Sleep(10);
}
if(lire_fichier("temps.txt", 2)==0){
modif_fichier("chasse.txt", capture, 1);
modif_fichier("chasse.txt", jsn_lance, 2);
modif_fichier("arme.txt", -jsn_lance, 3);
while(arme) jsn_lance*=1.1,arme--;
modif_fichier("chasse.txt", jsn_lance, 3);
jsn_lance = temps_min()+tdc+capture;
while(vdc) jsn_lance*=0.9, vdc--;
modif_fichier("temps.txt", jsn_lance, 2);
}
SaveDisp(3);
fenetre_f(0,36,3);
for(i=9;i>=0;i--){
ML_clear_vram();
ML_bmp_or(banniere_mp, 0, 46-i, 128, 8);
ML_bmp_or(banniere_ress, 0, 55-i, 128, 8);
ML_bmp_or(banniere_ress_chasse, 0, 64-i, 128, 8);
ML_display_vram();
Sleep(50);
}
fenetre_o(0,45,2);
}
// REINE (F2)
void reine()
{
const unsigned char banniere_mp[]={
0x3f,0xff,0xf9,0xff,0xff,0xcf,0xff,0xfe,0x7f,0xff,0xf3,0xff,0xff,0x9f,0xff,0xfc,
0x2a,0xaa,0xa9,0x0,0x0,0xa,0xaa,0xaa,0x55,0x55,0x52,0xaa,0xaa,0x95,0x55,0x54,
0x35,0x55,0x51,0x0,0x40,0xd,0x55,0xd4,0x6a,0xee,0xa3,0x55,0xd5,0x1a,0xae,0xa8,
0x2a,0xfe,0xa9,0x10,0xe1,0xa,0xbf,0xea,0x55,0x7d,0x52,0xaf,0xba,0x95,0x7d,0x54,
0x35,0xdf,0x51,0x19,0xb3,0xd,0x5d,0xd4,0x6a,0xee,0xa3,0x5f,0x7d,0x1a,0xef,0xa8,
0x2a,0xfe,0xa9,0x1f,0xff,0xa,0xaa,0xaa,0x55,0xd7,0x52,0xba,0xee,0x95,0x75,0xd4,
0x35,0xff,0x51,0x1f,0xff,0xd,0x5d,0xd4,0x6a,0xaa,0xa3,0x5d,0x5d,0x1a,0xff,0xa8,
0x2a,0xfe,0xa9,0x1f,0xff,0xa,0xbe,0xaa,0x55,0x7d,0x52,0xba,0xae,0x95,0x7f,0x54
};
const unsigned char banniere_reine[]={
0x3f,0xff,0xf9,0xff,0xff,0xcf,0xff,0xfe,0x7f,0xff,0xf3,0xff,0xff,0x9f,0xff,0xfc,
0x20,0x0,0x1,0x0,0x0,0x8,0x0,0x2,0x40,0x0,0x2,0x0,0x0,0x10,0x0,0x0,
0x20,0x10,0x1,0x0,0x60,0x8,0x9,0x2,0x40,0x0,0x2,0x0,0x80,0x10,0xe,0x0,
0x20,0x3e,0x1,0x0,0x60,0x8,0xd,0x2,0x40,0x0,0x2,0x7,0xc0,0x10,0xe,0x0,
0x20,0x7e,0x1,0x1,0xf8,0x8,0xb,0x2,0x40,0x7e,0x2,0x7,0xe0,0x10,0x1f,0x0,
0x20,0x3e,0x1,0x1,0xf8,0x8,0x9,0x2,0x40,0x7e,0x2,0x7,0xc0,0x10,0xe,0x0,
0x20,0x10,0x1,0x0,0x60,0x8,0x0,0x2,0x40,0x0,0x2,0x0,0x80,0x10,0x4,0x0,
0x20,0x0,0x1,0x0,0x60,0xf,0xff,0xfe,0x40,0x0,0x2,0x0,0x0,0x10,0x0,0x0
};
int i, reduc, type;
unsigned long temps;
reduc = lire_fichier("constru.txt", 5) + lire_fichier("constru.txt", 6) + lire_fichier("labo.txt", 2);
fenetre_f(0,54,1);
for(i=0;i<10;i++){
ML_clear_vram();
ML_bmp_or(banniere_mp, 0, 56-i, 128, 8);
ML_bmp_or(banniere_reine, 0, 65-i, 128, 8);
ML_display_vram();
Sleep(50);
}
//ML_bmp_or(fond, 0, 0, 128, 45);
SaveDisp(2);
fenetre_o(0,45,2);
SaveDisp(2);
}
// FONCTION SUPPLEMENTAIRE POUR FOURMIZZZ
void test_temps() // A FAIRE: convois
{
unsigned long temps, i, j, k, pomme, bois, ouv_bois, ouv_pomme;
unsigned char buffer[40];
temps = temps_min();
// PONTES
if(lire_fichier("temps.txt",1) && temps>lire_fichier("temps.txt",1)){
if(lire_fichier("arme.txt",2)!=13) modif_fichier("arme.txt", lire_fichier("arme.txt",1), lire_fichier("arme.txt",2)+2);
else modif_fichier("ouvri.txt", lire_fichier("arme.txt",1), 1);
modif_fichier("temps.txt", -lire_fichier("temps.txt",1), 1);
}
// CHASSE -voir probleme MP
if(lire_fichier("temps.txt",2) && temps>lire_fichier("temps.txt",2)){
modif_fichier("glob.txt", lire_fichier("chasse.txt",1), 1);
modif_fichier("arme.txt", lire_fichier("chasse.txt",2), 3);
modif_fichier("temps.txt", -lire_fichier("temps.txt",2), 2);
}
// CONVOI -voir probleme MP
// CONSTRUCTION
if(lire_fichier("temps.txt",4) && temps>lire_fichier("temps.txt",4)){
modif_fichier("constru.txt", 1, lire_fichier("constru.txt",1)+1);
modif_fichier("temps.txt", -lire_fichier("temps.txt",4), 4);
}
// LABORATOIRE
if(lire_fichier("temps.txt",5) && temps>lire_fichier("temps.txt",5)){
modif_fichier("labo.txt", 1, lire_fichier("labo.txt",1)+1);
modif_fichier("temps.txt", -lire_fichier("temps.txt",5), 5);
}
// RESSOURCES
// OUVRIERES
bois = 0;
ouv_bois = lire_fichier("ouvri.txt",2);
pomme = 0;
ouv_pomme = lire_fichier("ouvri.txt",3);
// CHAMPIGNONIERE
j=0;
i=lire_fichier("constru.txt",2);
if(i) j=122;
if(i--){
k=86;
do{
j+=k;
k*=1.7;
}while(i--);
}
ouv_pomme += j;
// CALCUL TEMPS
k=0;
i=lire_fichier("temps.txt",6);
while(temps>i){
i+=30;
k++;
pomme += ouv_pomme;
bois += ouv_bois;
}
modif_fichier("glob.txt",pomme,2);
modif_fichier("glob.txt",bois,3);
modif_fichier("temps.txt",30*k,6);
// ENTREPOTS TROP PLEIN ?
for(i=0, j=1700;i<lire_fichier("constru.txt", 3);i++) j=j*2-500;
if(lire_fichier("glob.txt",2)>j) modif_fichier("glob.txt",j-lire_fichier("glob.txt",2),2);
for(i=0, j=1700;i<lire_fichier("constru.txt", 4);i++) j=j*2-500;
if(lire_fichier("glob.txt",3)>j) modif_fichier("glob.txt",j-lire_fichier("glob.txt",3),3);
}
// FONCTONS FENETRES
void fenetre_f(int bas, int haut, int disp)
{
int y, x;
const int mid = (haut+bas)/2;
y=mid-bas;
for(x=64;x>0;x--){
ML_clear_vram();
if(disp!=0) RestoreDisp(disp);
ML_rectangle(0,bas,127,mid-y,0,ML_WHITE,ML_WHITE);
ML_rectangle(0,haut,127,mid+y,0,ML_WHITE,ML_WHITE);
ML_rectangle(0,bas,64-x,haut,0,ML_WHITE,ML_WHITE);
ML_rectangle(127,bas,64+x,haut,0,ML_WHITE,ML_WHITE);
ML_rectangle(64-x,mid+y,64+x,mid-y,1,ML_BLACK,ML_TRANSPARENT);
ML_pixel(64-x, mid+y, ML_WHITE);
ML_pixel(64+x, mid+y, ML_WHITE);
ML_pixel(64-x, mid-y, ML_WHITE);
ML_pixel(64+x, mid-y, ML_WHITE);
ML_display_vram();
if(IsKeyUp(KEY_CTRL_EXE)) Sleep(30);
}
for(x=1;y>0;y--){
ML_clear_vram();
if(disp!=0) RestoreDisp(disp);
ML_rectangle(0,bas,127,mid-y,0,ML_WHITE,ML_WHITE);
ML_rectangle(0,haut,127,mid+y,0,ML_WHITE,ML_WHITE);
ML_rectangle(0,bas,64-x,haut,0,ML_WHITE,ML_WHITE);
ML_rectangle(127,bas,64+x,haut,0,ML_WHITE,ML_WHITE);
ML_rectangle(64-x,mid+y,64+x,mid-y,1,ML_BLACK,ML_TRANSPARENT);
ML_pixel(64-x, mid+y, ML_WHITE);
ML_pixel(64+x, mid+y, ML_WHITE);
ML_pixel(64-x, mid-y, ML_WHITE);
ML_pixel(64+x, mid-y, ML_WHITE);
ML_display_vram();
if(IsKeyUp(KEY_CTRL_EXE)) Sleep(30);
}
}
void fenetre_o(int bas, int haut, int disp)
{
int y, x;
const int mid = (haut+bas)/2;
y=1;
for(x=0;x<64;x++){
ML_clear_vram();
if(disp!=0) RestoreDisp(disp);
ML_rectangle(0,bas,127,mid-y,0,ML_WHITE,ML_WHITE);
ML_rectangle(0,haut,127,mid+y,0,ML_WHITE,ML_WHITE);
ML_rectangle(0,bas,64-x,haut,0,ML_WHITE,ML_WHITE);
ML_rectangle(127,bas,64+x,haut,0,ML_WHITE,ML_WHITE);
ML_rectangle(64-x,mid+y,64+x,mid-y,1,ML_BLACK,ML_TRANSPARENT);
ML_pixel(64-x, mid+y, ML_WHITE);
ML_pixel(64+x, mid+y, ML_WHITE);
ML_pixel(64-x, mid-y, ML_WHITE);
ML_pixel(64+x, mid-y, ML_WHITE);
ML_display_vram();
if(IsKeyUp(KEY_CTRL_EXE)) Sleep(30);
}
for(y=1;mid-y>=bas;y++){
ML_clear_vram();
if(disp!=0) RestoreDisp(disp);
ML_rectangle(0,bas,127,mid-y,0,ML_WHITE,ML_WHITE);
ML_rectangle(0,haut,127,mid+y,0,ML_WHITE,ML_WHITE);
ML_rectangle(0,bas,64-x,haut,0,ML_WHITE,ML_WHITE);
ML_rectangle(127,bas,64+x,haut,0,ML_WHITE,ML_WHITE);
ML_rectangle(0,mid+y,127,mid-y,1,ML_BLACK,ML_TRANSPARENT);
ML_pixel(0, mid+y, ML_WHITE);
ML_pixel(127, mid+y, ML_WHITE);
ML_pixel(0, mid-y, ML_WHITE);
ML_pixel(127, mid-y, ML_WHITE);
ML_display_vram();
if(IsKeyUp(KEY_CTRL_EXE)) Sleep(30);
}
}
// FONCTIONS POUR LES FICHIERS
unsigned long lire_fichier(char *nom, char argument)
{
char buffer[100]={0};
char buf[2];
char lecture[200]={0};
unsigned long handle;
int i, j;
argument--;
sprintf(buffer,"\\\\fls0\\FOURMIZ\\%s", nom);
// LECTURE
handle = memory_openfile(buffer,_OPENMODE_READ);
memory_readfile(handle,lecture,memory_filesize(handle),-1);
memory_closefile(handle);
// ETUDE
i=0;
j=0;
while(i!=argument){
if(lecture[j]=='-') i++;
j++;
}
i=j;
while(lecture[j]!='-' && lecture[j]!='+'){
buffer[j-i]=lecture[j];
j++;
}
buffer[j-i]='\0';
handle = atoi(buffer);
return handle;
}
void modif_fichier(char *nom, unsigned long valeur, char argument) // VOIR SI OPTIMISER
{
unsigned char nouv_fichier[200];
unsigned char sauv_fichier[200];
unsigned char nom_fichier[30];
unsigned char buf[30];
unsigned int longueur=0, i=0, j, k, l;
int handle;
argument--;
sprintf(nom_fichier,"\\\\fls0\\FOURMIZ\\%s", nom);
// SAUVEGARDE DU FICHIER
handle = memory_openfile(nom_fichier,_OPENMODE_READ);
do{
memory_readfile(handle,buf,1,longueur);
sauv_fichier[longueur] = buf[0];
longueur++;
}while(buf[0]!='+');
sauv_fichier[longueur] = '\0';
memory_closefile(handle);
// TRAITEMENT
for(j=0,i=0;i!=argument;j++){
if(sauv_fichier[j]=='-') i++;
}
i=j;
while(sauv_fichier[j]!='-' && sauv_fichier[j]!='+') j++;
for(k=0;k<i;k++) nouv_fichier[k] = sauv_fichier[k];
sprintf(buf,"%u",lire_fichier(nom,argument+1)+valeur);
for(l=0;buf[l]!='\0';k++) nouv_fichier[k] = buf[l], l++;
for(l=0;k!=longueur+i;k++) nouv_fichier[k] = sauv_fichier[j+l], l++;
nouv_fichier[k+1] = '\0';
// ENREGISTREMENT
memory_save(nom_fichier,nouv_fichier,TF);
}
// FONCTIONS POUR LA GESTION DU TEMPS
void RTC_GetDateTime(unsigned char *time)
{
volatile TRTC*pRTC;
switch(GetMPU()){
case 3 :
case 4 :
pRTC = (TRTC*)0xA413FEC0;
break;
case 2 :
case 1 :
case 5 : // mpu7705 ?
pRTC = (TRTC*)0xFFFFFEC0;
break;
default :
pRTC = 0;
break;
}
if ( pRTC ){
time[0] = (*pRTC).RYEARCNT >> 8;
time[1] = (*pRTC).RYEARCNT & 0x00FF;
time[2] = (*pRTC).RMONCNT;
time[3] = (*pRTC).RDAYCNT;
time[4] = (*pRTC).RHOURCNT;
time[5] = (*pRTC).RMINCNT;
time[6] = (*pRTC).RSECCNT;
time[7] = 0;
} else memset( time, 0, sizeof( time ) );
}
int GetMPU()
{
int mpu;
unsigned char s[30];
unsigned int key;
unsigned char savevalue;
mpu = 0;
savevalue = *(unsigned short*)0xA4000114;
*(unsigned short*)0xA4000114 = 0xFFFF;
switch ( *(unsigned short*)0xA4000114 ){
case 0x0FFF :
mpu = 1;
break;
case 0x00FF :
mpu = 2;
break;
default :
switch ( *(unsigned int*)0xFF000030 & 0xFFFFFF00 ){
case 0x10300B00 :
switch ( *(unsigned int*)0xFF000044 & 0xFFFFFFF0 ){
case 0x00002C00 :
mpu = 3;
break;
case 0x00002200 :
mpu = 4; // just for reference
break;
};
break;
};
break;
};
*(unsigned short*)0xA4000114 = savevalue;
return mpu;
}
int BCD2int(unsigned char *BCD, int bytes)
{
int i,n;
for(i=0,n=0;i<bytes;i++)
{
n += (*(BCD+i)&240)>>4;
n *= 10;
n += *(BCD+i) & 15;
if(i != bytes-1) n*=10;
}
return n;
}
unsigned long temps_min()
{
unsigned long temps, i;
unsigned char time[8]={0};
unsigned char buf[1];
RTC_GetDateTime(time);
buf[0]=time[5];
temps = BCD2int(buf, 1);
buf[0]=time[4];
temps += BCD2int(buf, 1)*60;
buf[0]=time[3];
temps += BCD2int(buf, 1)*1440;
buf[0]=time[2];
temps += BCD2int(buf, 1)*43200;
buf[0]=time[1];
i=BCD2int(buf, 1);
buf[0]=time[0];
temps += (BCD2int(buf, 1)*100+i-1500)*518400;
return temps;
}
#pragma section _BR_Size
unsigned long BR_Size;
#pragma section
#pragma section _TOP
int InitializeSystem(int isAppli, unsigned short OptionNum){return INIT_ADDIN_APPLICATION(isAppli, OptionNum);}
#pragma section
// pour l'horloge
typedef struct{
unsigned char R128CNT;
unsigned char gap1;
unsigned char RSECCNT;
unsigned char gap2;
unsigned char RMINCNT;
unsigned char gap3;
unsigned char RHOURCNT;
unsigned char gap4;
unsigned char RWEEKCNT;
unsigned char gap5;
unsigned char RDAYCNT;
unsigned char gap6;
unsigned char RMONCNT;
unsigned char gap7;
unsigned short RYEARCNT;
} TRTC;
int GetMPU();
void RTC_GetDateTime(unsigned char *time);
void demmarage();
void menu_principal();
// RESSOURCES
void ressources();
void ressources_ouv();
void ressources_chasse();
// REINE
void reine();
void test_temps();
void fenetre_o(int bas, int haut, int disp);
void fenetre_f(int bas, int haut, int disp);
unsigned long lire_fichier(char *nom, char argument);
void modif_fichier(char *nom, unsigned long valeur, char argument);
int BCD2int(unsigned char *BCD, int bytes);
unsigned long temps_min();
Je ne sais pas pourquoi, l'add-in fait planter la calto lors de la création du fichier "constru.txt" alors qu'avant tout se passait normalement et il ne me semble pas avoir modifié quelque chose depuis.
Le SDK m'ouvre une pop-up lorsque je lance l'add-in avec marqué: "Exception blocked reset". Et en allant dans la mémoire il y a seulement "glob.txt" et "labo.txt"...
Citer : Posté le 09/07/2014 13:57 | #
Une EBR... franchement je sais pas ce que tu as pu faire...
(En gros l'EBR c'est le truc qui se produit avec les niveaux de gris, qui casse les c******* à tout le monde mais que personne ne sait résoudre. )
Citer : Posté le 09/07/2014 13:58 | #
Ben la je fait rien de mal moi
Citer : Posté le 09/07/2014 14:06 | #
Oh là quel bordel... tu as le même bout de core répété 5 fois, tu pourrais faire une boucle.
Et franchement, je te conseille d'utiliser les fonctions de plus haut niveau de memory, parce que là t'as pas fini.
Déjà le balisage avec des + et des -, c'est louche -- tu ne devrais pas en avoir besoin (en plus s'il y a des nombres négatifs...), et puis modifier le fichier tout le temps c'est pas non plus une très bonne idée. Normalement tu charges les données dans la RAM, tu modifies les données dans la RAM, et à la sauvegarde tu les écris dans les fichiers. Et même s'il y a des sauvgardes automatiques, on écrit toutes les données d'un coup.
Ta fonction de modification ne devrait pas être si complexe.
Enfin, quand on envoie un index à une fonction, ce n'est jamais un char mais un int par convention.
Citer : Posté le 09/07/2014 14:11 | #
Je savait que tu allais aimer mes fonctions de fichiers et même tout le reste qui est assez brouillon
Mais en même temps je vois pas trop comment faire autrement que mes + et - (il ne peut pas y avoir de nombres négatifs) parce que les nombres peuvent être très grand comme très petits.
Ajouté le 09/07/2014 à 14:12 :
Et pour la boucle je vois pas trop comment faire vu que les tailles changent, les nom changent, les valeurs changent ...
Citer : Posté le 09/07/2014 14:25 | #
Déjà tu devrais pas écrire les nombres en bruts mais dans des octets. Du coup chaque nombre prendrait la même taille.
J'avais déjà expliqué tout ça à Kirafi, je te mets un lien.
Enregistrer des données
Pour enregistrer un tableau c'est pareil, il suffit de passer le pointeur et d'écrire sur nbElements*sizeof(element).
Citer : Posté le 09/07/2014 15:58 | #
En gros pour résumer un peu ce que j'ai lu et pour savoir si j'ai bien compris, pour le fichier glob.txt qui contient 3 valeurs,j'aurais dans mon fichier 3 fois 4 octets contenant les unsigned long mais ils seront a la suite.
Donc si je veux modifier une valeur, il faut recuperer tout le fichier , modifier les 4 octets voulus dans la RAM et tout remettre dans le fichier ?
Citer : Posté le 09/07/2014 16:09 | #
Exactement.
Et je te conseille de ne pas utiliser des unsigned long, mais des unsigned int (en soi, c'est pareil mais les int sont mieux supportés).
Citer : Posté le 09/07/2014 16:17 | #
Dans mon cas, est-ce que ca ca passe ?
{
char buffer[100]={0};
char lecture[200]={0};
unsigned long handle;
argument--;
sprintf(buffer,"\\\\fls0\\FOURMIZ\\%s", nom);
// LECTURE
handle = memory_openfile(buffer,_OPENMODE_READ);
memory_readfile(handle,lecture,sizeof(unsigned long),sizeof(unsigned long)*argument);
memory_closefile(handle);
// ETUDE
handle = atoi(lecture);
return handle;
}
Citer : Posté le 09/07/2014 16:23 | #
Je pense que non.
Bon, d'abord tu devrais passer tout ça en unsigned int, mais ça c'est subsidiaire.
Ensuite tu ne charges qu'une partie des données. Du coup, ce que tu vas réécrire, ce n'est qu'une partie des données.
Citer : Posté le 09/07/2014 16:28 | #
subsidiaire: hé oh j'ai eu 7 en français moi
Ensuite tu ne charges qu'une partie des données: ben en soit c'est pas trop grave vu que c'est juste la lecture non ?