Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "fxlib.h"
- #include "stdlib.h"
- void PrintInt(int n)
- {
- char str[20]="0";
- int i, l=0;
- for(i=n ; i ; i/=10)
- l++;
- for(i=n ; i ; i/=10)
- str[--l] = i%10+'0';
- Print(str);
- }
- int input(int x, int y)
- {
- int nb=0, key=0;
- while(key != KEY_CTRL_EXE)
- {
- locate(x, y);
- PrintInt(nb);
- Print("_ ");
- GetKey(&key);
- if(key>='0' && key<='9') nb = nb*10+key-'0';
- if(key == KEY_CTRL_DEL) nb /= 10;
- }
- return nb;
- }
- int AddIn_main(int isAppli, unsigned short OptionNum)
- {
- int i, j, size, nb, key, plante, modulo;
- char **ptr=0;
- while(1)
- {
- Bdisp_AllClr_VRAM();
- nb = 0;
- while(nb == 0)
- nb = input(1, 1);
- ptr = malloc(nb*sizeof(char*));
- for(i=0 ; i<nb ; i++) ptr[i]=0;
- key=1;
- size=0;
- modulo=128;
- while(key)
- {
- size++;
- for(i=0 ; i<nb ; i++)
- {
- free(ptr[i]);
- ptr[i]=0;
- }
- for(i=0 ; i<nb && key ; i++)
- {
- ptr[i]=malloc(size);
- if(!ptr[i]) key=0;
- }
- if(key)
- {
- for(i=0 ; i<nb ; i++)
- {
- for(j=2 ; j<256 && ((int)ptr[i])%j==0 ; j*=2);
- if(j < modulo) modulo = j;
- }
- }
- }
- plante = i;
- for(i=0 ; i<nb ; i++)
- free(ptr[i]);
- free(ptr);
- Bdisp_AllClr_VRAM();
- locate(1, 1);
- PrintInt(nb);
- Print(" buffers");
- locate(1, 2);
- PrintInt(size-1);
- Print(" octets chacun");
- locate(1, 3);
- PrintInt((size-1)*nb + 4*nb);
- Print(" octets au total");
- locate(1, 4);
- Print("Plante au n ");
- PrintInt(plante);
- locate(1, 5);
- Print("Adr multiples de ");
- PrintInt(modulo);
- GetKey(&key);
- }
- return 1;
- }
- #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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement