#include "fxlib.h" #include #include #include #include #define FILESIZE() (Bfile_GetFileSize(fichier)+1) #define FREE(pointeur) free(pointeur);\ pointeur=NULL; #define MESURE 0 #define TYPE 1 #define HAUTEUR 2 #define TEMPS 3 #define DUREE 4 #define POINTE 5 #define NOTE 1 #define NOTE_X (partition[numero_note][3]*9) #define NOTE_Y (-partition[numero_note][2]*3) #define RONDE 0 #define BLANCHE 1 #define NOIRE 2 #define CROCHE 3 /* Il reste à faire les altérations et les silences (toujours le même principe que pour les notes) */ char *substr(char texte[],long debut,long fin); char decoupage_ligne(long ***partition,char texte[],int *nombre_malloc); int moteur_rendu(long **partition,int nombre_notes,long mesure); void portee(long mesure); void controle(long ***partition,long nombre_malloc,long *mesure); void affiche_menu(int type_menu); int AddIn_main(int isAppli, unsigned short OptionNum) { int mesure=0; int nombre_malloc=0; int compteur=0; char *retour_fichier=NULL; long **partition=NULL; long retour=0; FONTCHARACTER nom_fichier[]={'\\','\\','c','r','d','0','\\','f','i','n','a','l','e','.','t','x','t',0}; int fichier; Bdisp_AllClr_DDVRAM(); Bfile_CreateFile(nom_fichier,3); fichier=Bfile_OpenFile(nom_fichier,_OPENMODE_READ); retour_fichier=malloc(FILESIZE()*sizeof(char)); Bfile_ReadFile(fichier,retour_fichier,FILESIZE(),0); decoupage_ligne(&partition,retour_fichier,&nombre_malloc); Bfile_CloseFile(fichier); FREE(retour_fichier); locate(8,4); Print("FINALE"); PrintMini(3,45,"Gerez vos partitions musicales",0); Bdisp_PutDisp_DD(); Sleep(1000); moteur_rendu(partition,nombre_malloc,mesure); PrintMini(2,45,"ajouter 1. note 2. alteration",1); PrintMini(39,51,"3. silence",1); PrintMini(2,57,"effacer 4. note/alt. 5. tout",1); Bdisp_DrawLineVRAM(1,51,30,51); Bdisp_DrawLineVRAM(1,63,30,63); /* Va falloir faire du building ici ! */ controle(&partition,nombre_malloc,&mesure); for(compteur=0;compteur<((nombre_malloc)-1);compteur++) FREE(partition[compteur]); FREE(partition); return 1; } void affiche_menu(int type_menu) { if(type_menu==0) { PrintMini(2,45,"ajouter 1. note 2. alteration",1); PrintMini(39,51,"3. silence",1); PrintMini(2,57,"effacer 4. note/alt. 5. tout",1); Bdisp_DrawLineVRAM(1,51,30,51); Bdisp_DrawLineVRAM(1,63,30,63); } else if(type_menu==1 || type_menu==2) { if(type_menu==1) PrintMini(2,51,"[.] pointer",0); PrintMini(2,57,"[EXIT] annuler +/- court/long",0); } else if(type_menu==3) { } } void controle(long ***partition,long nombre_malloc,long *mesure) { /* C'EST ICI QU'ON BOSSE */ int type_menu=0; char affichage[25]; unsigned int key; int tour_malloc=0; long *note_controle=NULL; while(1) { GetKey(&key); if(type_menu==0) { if(key==KEY_CTRL_RIGHT) { moteur_rendu(*partition,nombre_malloc-1,++(*mesure)); affiche_menu(0); } else if(key==KEY_CTRL_LEFT && *mesure>0) { moteur_rendu(*partition,nombre_malloc-1,--(*mesure)); affiche_menu(0); } else if(key==KEY_CHAR_1) { Bdisp_AllClr_DDVRAM(); RestoreDisp(0); affiche_menu(1); type_menu=1; } else if(key==KEY_CTRL_EXIT) break; } else if(type_menu==1) { if(tour_malloc==0) { note_controle=malloc(4*sizeof(long)); tour_malloc=1; } if(key==KEY_CTRL_EXIT) { tour_malloc=0; type_menu=0; Bdisp_AllClr_DDVRAM(); RestoreDisp(0); affiche_menu(0); } else if(key==KEY_CTRL_LEFT) { } else if(key==KEY_CTRL_RIGHT) { } else if(key==KEY_CTRL_EXE) { free(note_controle); tour_malloc=0; type_menu=0; } } sprintf(affichage,"%ld",*mesure); PrintMini(1,1,affichage,0); } } char *substr(char texte[],long debut,long fin) { long compteur=0; char *retour=NULL; retour=malloc((fin-debut+1)*sizeof(char)); for(compteur=debut;compteur<=fin;compteur++) retour[compteur-debut]=texte[compteur]; retour[compteur-debut+1]='\0'; return retour; } char decoupage_ligne(long ***partition,char texte[],int *nombre_malloc) { int compteur=0; int nombre_ligne=0; int parametre_note=0; int debut=0; for(compteur=0;compteur9) { Bdisp_DrawLineVRAM(NOTE_X+21,NOTE_Y+37+3*((partition[numero_note][HAUTEUR]%2)!=0),NOTE_X+15,NOTE_Y+37+3*((partition[numero_note][HAUTEUR]%2)!=0)); } if(partition[numero_note][DUREE]==RONDE || partition[numero_note][DUREE]==BLANCHE) { Bdisp_DrawLineVRAM(NOTE_X+16,NOTE_Y+37,NOTE_X+16,NOTE_Y+36); Bdisp_DrawLineVRAM(NOTE_X+16,NOTE_Y+36,NOTE_X+17,NOTE_Y+35); Bdisp_DrawLineVRAM(NOTE_X+17,NOTE_Y+35,NOTE_X+19,NOTE_Y+35); Bdisp_DrawLineVRAM(NOTE_X+19,NOTE_Y+35,NOTE_X+20,NOTE_Y+36); Bdisp_DrawLineVRAM(NOTE_X+20,NOTE_Y+36,NOTE_X+20,NOTE_Y+37); Bdisp_DrawLineVRAM(NOTE_X+20,NOTE_Y+37,NOTE_X+20,NOTE_Y+38); Bdisp_DrawLineVRAM(NOTE_X+20,NOTE_Y+38,NOTE_X+19,NOTE_Y+39); Bdisp_DrawLineVRAM(NOTE_X+19,NOTE_Y+39,NOTE_X+17,NOTE_Y+39); Bdisp_DrawLineVRAM(NOTE_X+17,NOTE_Y+39,NOTE_X+16,NOTE_Y+38); if(partition[numero_note][DUREE]==BLANCHE) { Bdisp_DrawLineVRAM(NOTE_X+16,NOTE_Y+38,NOTE_X+16,NOTE_Y+37); Bdisp_DrawLineVRAM(NOTE_X+20,NOTE_Y+38,NOTE_X+20,NOTE_Y+26); } if(partition[numero_note][HAUTEUR]%2==0) /* Dans le cas d'une blanche/ronde sur une ligne */ Bdisp_ClearLineVRAM(NOTE_X+19,NOTE_Y+37,NOTE_X+17,NOTE_Y+37); } else if(partition[numero_note][DUREE]==NOIRE || partition[numero_note][DUREE]==CROCHE) { Bdisp_DrawLineVRAM(NOTE_X+16,NOTE_Y+38,NOTE_X+16,NOTE_Y+36); Bdisp_DrawLineVRAM(NOTE_X+16,NOTE_Y+36,NOTE_X+17,NOTE_Y+39); Bdisp_DrawLineVRAM(NOTE_X+17,NOTE_Y+39,NOTE_X+17,NOTE_Y+35); Bdisp_DrawLineVRAM(NOTE_X+17,NOTE_Y+35,NOTE_X+18,NOTE_Y+39); Bdisp_DrawLineVRAM(NOTE_X+18,NOTE_Y+39,NOTE_X+18,NOTE_Y+35); Bdisp_DrawLineVRAM(NOTE_X+18,NOTE_Y+35,NOTE_X+19,NOTE_Y+39); Bdisp_DrawLineVRAM(NOTE_X+19,NOTE_Y+39,NOTE_X+19,NOTE_Y+35); Bdisp_DrawLineVRAM(NOTE_X+19,NOTE_Y+35,NOTE_X+20,NOTE_Y+38); Bdisp_DrawLineVRAM(NOTE_X+20,NOTE_Y+38,NOTE_X+20,NOTE_Y+26); if(partition[numero_note][DUREE]==CROCHE) Bdisp_DrawLineVRAM(NOTE_X+20,NOTE_Y+26,NOTE_X+22,NOTE_Y+29); } } } } SaveDisp(0); } void portee(long mesure) { int compteur=0; for (compteur=1;compteur<=5;compteur++) Bdisp_DrawLineVRAM(1,64-21-compteur*6,127,64-21-compteur*6); if(mesure==0) { Bdisp_SetPoint_VRAM(8,9,1); Bdisp_DrawLineVRAM(7,10,8,10); Bdisp_DrawLineVRAM(6,11,9,11); Bdisp_DrawLineVRAM(6,12,9,12); Bdisp_SetPoint_VRAM(6,13,1); Bdisp_SetPoint_VRAM(9,13,1); Bdisp_SetPoint_VRAM(6,14,1); Bdisp_SetPoint_VRAM(9,14,1); Bdisp_SetPoint_VRAM(6,15,1); Bdisp_SetPoint_VRAM(9,15,1); Bdisp_SetPoint_VRAM(6,16,1); Bdisp_DrawLineVRAM(8,16,9,16); Bdisp_SetPoint_VRAM(6,17,1); Bdisp_DrawLineVRAM(8,17,9,17); Bdisp_DrawLineVRAM(6,18,8,18); Bdisp_DrawLineVRAM(6,19,8,19); Bdisp_DrawLineVRAM(5,20,7,20); Bdisp_DrawLineVRAM(4,21,7,21); Bdisp_DrawLineVRAM(3,22,5,22); Bdisp_SetPoint_VRAM(7,22,1); Bdisp_DrawLineVRAM(2,23,5,23); Bdisp_SetPoint_VRAM(7,23,1); Bdisp_DrawLineVRAM(2,24,4,24); Bdisp_DrawLineVRAM(7,24,9,24); Bdisp_DrawLineVRAM(1,25,3,25); Bdisp_DrawLineVRAM(6,25,10,25); Bdisp_DrawLineVRAM(1,26,2,26); Bdisp_DrawLineVRAM(5,26,11,26); Bdisp_DrawLineVRAM(1,27,2,27); Bdisp_SetPoint_VRAM(5,27,1); Bdisp_SetPoint_VRAM(8,27,1); Bdisp_DrawLineVRAM(10,27,12,27); Bdisp_DrawLineVRAM(1,28,2,28); Bdisp_SetPoint_VRAM(5,28,1); Bdisp_SetPoint_VRAM(8,28,1); Bdisp_DrawLineVRAM(11,28,12,28); Bdisp_SetPoint_VRAM(2,29,1); Bdisp_SetPoint_VRAM(5,29,1); Bdisp_SetPoint_VRAM(8,29,1); Bdisp_DrawLineVRAM(11,29,12,29); Bdisp_SetPoint_VRAM(2,30,1); Bdisp_SetPoint_VRAM(6,30,1); Bdisp_SetPoint_VRAM(8,30,1); Bdisp_SetPoint_VRAM(11,30,1); Bdisp_SetPoint_VRAM(3,31,1); Bdisp_DrawLineVRAM(7,31,8,31); Bdisp_SetPoint_VRAM(11,31,1); Bdisp_DrawLineVRAM(4,32,5,32); Bdisp_DrawLineVRAM(7,32,10,32); Bdisp_DrawLineVRAM(5,33,9,33); Bdisp_SetPoint_VRAM(9,34,1); Bdisp_SetPoint_VRAM(9,35,1); Bdisp_DrawLineVRAM(5,36,6,36); Bdisp_SetPoint_VRAM(9,36,1); Bdisp_DrawLineVRAM(4,37,7,37); Bdisp_SetPoint_VRAM(9,37,1); Bdisp_DrawLineVRAM(4,38,6,38); Bdisp_SetPoint_VRAM(9,38,1); Bdisp_DrawLineVRAM(4,39,5,39); Bdisp_SetPoint_VRAM(9,39,1); Bdisp_DrawLineVRAM(5,40,8,40); } } #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