#include<time.h>
#include <allegro.h>
#include <jgmod.h>

void read_line(char *file_name,int line, char *output);

int main ()
{
char puffi[1024];
JGMOD *ex;

    allegro_init ();
    install_timer();            // must call this!!
    install_keyboard();
set_color_depth(16);


read_line("play.cfg",1,puffi);
if(strcmp(puffi,"GFX_ON")==0)
        {
        set_gfx_mode(GFX_AUTODETECT_WINDOWED,320,200,0,0);
        text_mode(-1);
        clear_to_color(screen,makecol16(200,200,200));
        textprintf_centre(screen,font,160,10,makecol(0,0,0),"Owet softwares TLOJ music player.");
        textprintf_centre(screen,font,160,20,makecol(0,0,0),"Rik u r the best!");
        read_line("play.cfg",3,puffi);

        textprintf_centre(screen,font,160,30,makecol(0,0,0),"Playing:%s",puffi);
        textprintf_centre(screen,font,160,150,makecol(0,0,0),"PRESS ANY KEY TO QUIT!");
        }

reserve_voices (16, -1);
install_sound (DIGI_AUTODETECT, MIDI_NONE, NULL);
install_mod (4);
set_mod_volume(128);
read_line("play.cfg",3,puffi);
ex = load_mod (puffi);

play_mod (ex, TRUE);
readkey();

stop_mod();
destroy_mod (ex);
allegro_exit();
return (0);
}
END_OF_MAIN();

void read_line(char *file_name,int line, char *output)
{
FILE *f;
char buf[1024];
int num=0;
f=fopen(file_name,"r");
while((fgets(buf,1024,f))!=0)
	{
	if(num==line)
		{
                buf[strlen(buf)-1]=0;
                strcpy(output,buf);
                //memcpy(output,buf,strlen(buf)-1);
		break;
		}
	num++;
	}
fclose(f);
free(buf);
}

