nero = Color.new(0,0,0)
rosso = Color.new(255,0,0)
pic1 = Image.load("SYSTEM/resources/other/options4.png")

file = io.open("SYSTEM/resources/L.txt", "r") 
L = file:read("*n") 
file:close()

Selected = 20
timer1 = 0
timer2 = 0

set = 0
set1 = 0

set2 = 0
set3 = 0

while true do
pad = Controls.read()

if 1==1 then System.setcpuspeed(333) end

screen:blit(0,0,pic1)
screen:print(7,7,"BACKGROUND OPTIONS MENU :",rosso)
screen:print(7,8,"BACKGROUND OPTIONS MENU :",rosso)

screen:print(10,200,"PAGE 2",rosso)
screen:print(10,201,"PAGE 2",rosso)

screen:print(10,240,"Press X to CONFIRM".."        Press [] to SAVE IMAGE",rosso)

Mp3me.play()
if Mp3me.gettime() == Mp3me.songTime() then
Mp3me.stop()
Mp3me.load("SYSTEM/resources/music/SND1.mp3")
Mp3me.play()
end


if pad:left() then timer1 = timer1 + 1 end
if not pad:left() then timer1 = 0 end
if timer1 == 1 then Selected = Selected - 10 end

if pad:right() then timer2 = timer2 + 1 end
if not pad:right() then timer2 = 0 end 
if timer2 == 1 then Selected = Selected + 10 end

screen:print(31,80,"-[1]-",nero)
screen:print(31,81,"-[1]-",nero)
screen:print(127,80,"-[2]-",nero)
screen:print(127,81,"-[2]-",nero)
screen:print(217,80,"-[3]-",nero)
screen:print(217,81,"-[3]-",nero)
screen:print(315,80,"-[4]-",nero)
screen:print(315,81,"-[4]-",nero)
screen:print(411,80,"-[5]-",nero)
screen:print(411,81,"-[5]-",nero)
screen:print(31,160,"-[6]-",nero)
screen:print(31,161,"-[6]-",nero)
screen:print(127,160,"-[7]-",nero)
screen:print(127,161,"-[7]-",nero)
screen:print(217,160,"-[8]-",nero)
screen:print(217,161,"-[8]-",nero)
screen:print(315,160,"-[9]-",nero)
screen:print(315,161,"-[9]-",nero)
screen:print(408,160,"-[10]-",nero)
screen:print(408,161,"-[10]-",nero)

if Selected==20 then screen:print(31,80,"-[1]-",rosso) end
if Selected==20 then screen:print(31,81,"-[1]-",rosso) end
if Selected==30 then screen:print(127,80,"-[2]-",rosso) end
if Selected==30 then screen:print(127,81,"-[2]-",rosso) end
if Selected==40 then screen:print(217,80,"-[3]-",rosso) end
if Selected==40 then screen:print(217,81,"-[3]-",rosso) end
if Selected==50 then screen:print(315,80,"-[4]-",rosso) end
if Selected==50 then screen:print(315,81,"-[4]-",rosso) end
if Selected==60 then screen:print(411,80,"-[5]-",rosso) end
if Selected==60 then screen:print(411,81,"-[5]-",rosso) end
if Selected==70 then screen:print(31,160,"-[6]-",rosso) end
if Selected==70 then screen:print(31,161,"-[6]-",rosso) end
if Selected==80 then screen:print(127,160,"-[7]-",rosso) end
if Selected==80 then screen:print(127,161,"-[7]-",rosso) end
if Selected==90 then screen:print(217,160,"-[8]-",rosso) end
if Selected==90 then screen:print(217,161,"-[8]-",rosso) end
if Selected==100 then screen:print(315,160,"-[9]-",rosso) end
if Selected==100 then screen:print(315,161,"-[9]-",rosso) end
if Selected==110 then screen:print(408,160,"-[10]-",rosso) end
if Selected==110 then screen:print(408,161,"-[10]-",rosso) end


if Selected==120 then Selected=110 end
if Selected==10 then Selected=20 end


if Selected==20 and pad:cross() then System.copyFile("SYSTEM/resources/background/background(11)/backg.png","SYSTEM/resources/background/usedbackground/backg.png",0) end 
if Selected==30 and pad:cross() then System.copyFile("SYSTEM/resources/background/background(12)/backg.png","SYSTEM/resources/background/usedbackground/backg.png",0) end
if Selected==40 and pad:cross() then System.copyFile("SYSTEM/resources/background/background(13)/backg.png","SYSTEM/resources/background/usedbackground/backg.png",0) end
if Selected==50 and pad:cross() then System.copyFile("SYSTEM/resources/background/background(14)/backg.png","SYSTEM/resources/background/usedbackground/backg.png",0) end
if Selected==60 and pad:cross() then System.copyFile("SYSTEM/resources/background/background(15)/backg.png","SYSTEM/resources/background/usedbackground/backg.png",0) end
if Selected==70 and pad:cross() then System.copyFile("SYSTEM/resources/background/background(16)/backg.png","SYSTEM/resources/background/usedbackground/backg.png",0) end
if Selected==80 and pad:cross() then System.copyFile("SYSTEM/resources/background/background(17)/backg.png","SYSTEM/resources/background/usedbackground/backg.png",0) end
if Selected==90 and pad:cross() then System.copyFile("SYSTEM/resources/background/background(18)/backg.png","SYSTEM/resources/background/usedbackground/backg.png",0) end
if Selected==100 and pad:cross() then System.copyFile("SYSTEM/resources/background/background(19)/backg.png","SYSTEM/resources/background/usedbackground/backg.png",0) end
if Selected==110 and pad:cross() then System.copyFile("SYSTEM/resources/background/background(20)/backg.png","SYSTEM/resources/background/usedbackground/backg.png",0) end


if Selected==20 and pad:square() then System.copyFile("SYSTEM/resources/background/background(11)/backg.png","ms0:/PICTURE/backg11.png",0) end 
if Selected==30 and pad:square() then System.copyFile("SYSTEM/resources/background/background(12)/backg.png","ms0:/PICTURE/backg12.png",0) end
if Selected==40 and pad:square() then System.copyFile("SYSTEM/resources/background/background(13)/backg.png","ms0:/PICTURE/backg13.png",0) end
if Selected==50 and pad:square() then System.copyFile("SYSTEM/resources/background/background(14)/backg.png","ms0:/PICTURE/backg14.pngg",0) end
if Selected==60 and pad:square() then System.copyFile("SYSTEM/resources/background/background(15)/backg.png","ms0:/PICTURE/backg15.png",0) end
if Selected==70 and pad:square() then System.copyFile("SYSTEM/resources/background/background(16)/backg.png","ms0:/PICTURE/backg16.png",0) end
if Selected==80 and pad:square() then System.copyFile("SYSTEM/resources/background/background(17)/backg.png","ms0:/PICTURE/backg17.png",0) end
if Selected==90 and pad:square() then System.copyFile("SYSTEM/resources/background/background(18)/backg.png","ms0:/PICTURE/backg18.png",0) end
if Selected==100 and pad:square() then System.copyFile("SYSTEM/resources/background/background(19)/backg.png","ms0:/PICTURE/backg19.png",0) end
if Selected==110 and pad:square() then System.copyFile("SYSTEM/resources/background/background(20)/backg.png","ms0:/PICTURE/backg20.png",0) end


if pad:cross() then set = set + 1 end

if set>0 and set<20 then screen:print(10,230,"Background successfully replaced !!",rosso) end
if set>0 and set<20 then set1=set1+1 end
if set1==80 then set=0 end
if set1==80 then set1=0 end

if pad:square() then set2 = set2 + 1 end

if set2>0 and set2<20 then screen:print(10,230,"Background successfully saved !! (ms0:/PICTURE)",rosso) end
if set2>0 and set2<20 then set3=set3+1 end
if set3==80 then set2=0 end
if set3==80 then set3=0 end


if L==0 then Selected = 0 end

if L==1 then if Selected==30 then Selected=20 end
             if Selected==10 then Selected=20 end
             end

if L==2 then if Selected==40 then Selected=30 end
             if Selected==10 then Selected=20 end
             end

if L==3 then if Selected==50 then Selected=40 end
             if Selected==10 then Selected=20 end
             end

if L==4 then if Selected==60 then Selected=50 end
             if Selected==10 then Selected=20 end
             end

if L==5 then if Selected==70 then Selected=60 end
             if Selected==10 then Selected=20 end
             end

if L==6 then if Selected==80 then Selected=70 end
             if Selected==10 then Selected=20 end
             end

if L==7 then if Selected==90 then Selected=80 end
             if Selected==10 then Selected=20 end
             end

if L==8 then if Selected==120 then Selected=110 end
             if Selected==10 then Selected=20 end
             end






screen:print(10,250,"Press O to GO BACK".."        Press L to go to PAGE 1",rosso)
if pad:circle() then dofile("SYSTEM/resources/options/options.lua") end
if pad:l() then dofile("SYSTEM/resources/options/optionsBackground.lua") end



screen.waitVblankStart()
screen.flip()
screen:clear()
end













