dofile("System/Config/usb.MACXT")
Mp3.stop()
Mp3me.stop()
Adhoc.term()
System.memclean()
x = 480/2
y = 272/2
Fond_Bios = Image.load("System/fond.png")
counter = Timer.new()
counter:start()
while true do
   MACXTKeyPad = Controls.read()
   screen:blit(0,0,Fond_Bios)
   if usb == 1 then
      Active_USB = 1
    else
      Active_USB = 0
   end
   if Afficher_Options ~= 1 then
      currentTime = counter:time()
      screen:print(5,260,currentTime)
   end
   screen:print(5,230,"Select Configuration Demarrage",Color.new(255,255,255))
   screen:print(5,210,"Memoire Libre:"..System.getFreeMemory() / 1024 .."KB",Color.new(255,255,255))
   if MACXTKeyPad:select() then
      Afficher_Options = 1
      selecteur = 1
   end
   if Afficher_Options ~= 1 then
      if currentTime > 3000 then
         Fond_Bios = nil
         dofile("Index.lua")
      end
   end
   if Afficher_Options == 1 then
      counter = nil
      currentTime = nil
      screen:fillRect(90,30,300,80,Color.new(255,255,255))
      screen:print(91,15+(selecteur*20),">")
      screen:print(100,35,"Retablir fond d'ecran original")
      screen:print(100,35+20,"Afficher menu d'acceuil au demarrage")
      if usb == 1 then
         screen:print(100,55+20,"desactiver usb au demarrage de MACXT")
         System.usbDiskModeActivate()
         Active_USB = 1
       else
         if usb ~= 1 then
            screen:print(100,55+20,"Activer usb au demarrage de MACXT")
         end
      end
      screen:print(100,75+20,"[Start] pour quitter")
      if MACXTKeyPad:down() and selecteur < 3 then
         screen.waitVblankStart(10)
         selecteur = selecteur + 1
      end
      if MACXTKeyPad:up() and selecteur > 1 then
         screen.waitVblankStart(10)
         selecteur = selecteur - 1
      end
      if MACXTKeyPad:start() then
         counter = nil
         currentTime = nil
         counter = Timer.new()
         counter:start()
         currentTime = counter:time()
         Afficher_Options = 0
      end
      if MACXTKeyPad:cross() then
         if selecteur == 1 then
            filewallpaper = io.open("MACXT/Systeme/Registre/MACXT/Image_Wallpaper.MACXT","w")
            filewallpaperread = io.open("MACXT/Systeme/Registre/MACXT/Path_Wallpaper_Image.MACXT","r")
            filewallpaper:write(filewallpaperread:read("*a"))
            filewallpaper:close()
            filewallpaperread:close()
            filedirectory = io.open("MACXT/Systeme/Registre/MACXT/Wallpaper.MACXT","w")
            filedirectory:write("Default_Directory = 1")
            filedirectory:close()
            filedirectory = nil
            filewallpaper = nil
            filewallpaperread = nil
         end
         if selecteur == 2 then
            fileacceuil = io.open("MACXT/Systeme/Registre/MACXT/Acceuil.MACXT","w")
            fileacceuil:write("Afficher_Acceuil = 1")
            fileacceuil:close()
            fileacceuil = nil
         end
         if selecteur == 3 then
            if usb == 0 then
               fileusbb = io.open("System/Config/usb.MACXT","w")
               fileusbb:write("System.usbDiskModeActivate() usb = 1")
               fileusbb:close()
               fileusbb = nil
             else
               if usb == 1 then
                  fileusbb = io.open("System/Config/usb.MACXT","w")
                  fileusbb:write("System.usbDiskModeDeactivate() usb = 0")
                  fileusbb:close()
                  fileusbb = nil
               end
            end
            dofile("System/Config/usb.MACXT")
         end
      end
   end
screen.waitVblankStart()
screen:flip()
end
