#include "noid.h"

void NoidINTRO(void);
void MenuINIT(void);
void InitTrance(void);
/* @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ */
/* @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ */
/*                               INIT MAIN                                   */
/* @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ */
/* @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ */

/* 	SDL INIT : initialise sdl component
	commencer : prep all structure and load data
	main loop : where the prog run
	finire : were it finish and free all memory		 */

/* */

int main ( int argc, char** argv ) {
	int cntNOID;
/* --------------------------> SDL INIT <----------------------------------- */
	printf("Init SDL : ");
   	if ( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER) < 0 ) {
		printf("error \n");
        	return(1);
   	} else { printf("OK \n"); }
    	atexit(SDL_Quit);

	printf("Create Surface :");
    	fNOID.jeton[100] = SDL_SetVideoMode(400, 400, 32,SDL_SWSURFACE| SDL_ANYFORMAT|SDL_RLEACCEL);
	if (fNOID.jeton[100] == NULL) {
		printf("error \n");
        	return(1);
   	} else { printf("OK \n"); }
	SDL_SetColorKey(fNOID.jeton[100],SDL_RLEACCEL,0);
    	SDL_WM_SetCaption("NOiD",NULL);
	SDL_ShowCursor(SDL_DISABLE);

	printf("Init SDL_ttf : ");
    	if( TTF_Init() == -1 ) 	{ 
		printf("error \n");
		return (1); 
	} else { printf("OK \n"); }

    	int noisefreq = 22050;    Uint16 noisebin = AUDIO_S16;
    	int noisepara = 1;    int noisepak = 4096;
	printf("Init SDL_mixer : ");
    	if (Mix_OpenAudio(22050, AUDIO_S16 , 1, 4096)) {
		printf("error \n");
        	return(1);
   	} else { printf("OK \n"); }
    	Mix_QuerySpec(&noisefreq, &noisebin, &noisepara);                           
/* -----------------------------> commencer <------------------------------- */
	NoidServerINIT();
	InitTrance();
	MenuINIT();
	NoidINTRO();
/* -----------------------------> MAIN LOOP <------------------------------- */
	NoidServerLOOP();
/* -----------------------------> THE END <--------------------------------- */
    for (cntNOID=1;cntNOID < 169;cntNOID = cntNOID+1) {
        SDL_FreeSurface(fNOID.jeton[cntNOID]);    }

    Mix_HaltMusic();
	Mix_FreeMusic(museNOID);	Mix_FreeMusic(trackNOID);
    Mix_CloseAudio();

    SDL_Quit();
    return(0);
}
/* @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ */
/* @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ */
/* @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ */
