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

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

Selected = 20
timer1 = 0
timer2 = 0

timer3 = 0

setX = 0
setY = 0

while true do
pad = Controls.read()

if CPU==333 then System.setcpuspeed(333) end
if CPU==266 then System.setcpuspeed(266) end
if CPU==133 then System.setcpuspeed(133) end
if CPU==222 then System.setcpuspeed(222) end

screen:blit(0,0,pic)
screen:print(7,7,"CPU SETTING MENU :",rosso)
screen:print(7,8,"CPU SETTING MENU :",rosso)

screen:print(10,240,"Press X to CONFIRM",rosso)


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


if 1==1 then timer3 = timer3 + 1 end

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

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


screen:print(10,25,"Set CPU at 333 Mhz",nero)
screen:print(10,35,"Set CPU at 266 Mhz",nero)
screen:print(10,45,"Set CPU at 133 Mhz",nero)

screen:print(10,60,"========================",nero)

screen:print(10,75,"Reset to ORIGINAL SETTING (222 Mhz)",nero)

screen:print(10,90,"========================",nero)

screen:print(10,130,"Current CPU speed : "..System.getCpuSpeed(),nero)

if Selected==20 then screen:print(10,25,"Set CPU at 333 Mhz",rosso) end
if Selected==30 then screen:print(10,35,"Set CPU at 266 Mhz",rosso) end
if Selected==40 then screen:print(10,45,"Set CPU at 133 Mhz",rosso) end
if Selected==50 then screen:print(10,75,"Reset to ORIGINAL SETTING (222 Mhz)",rosso) end

if Selected==20 and pad:cross() then file = io.open("SYSTEM/GAME/CPU.txt","w");
                                     file:write("333");
                                     file:close(); 
                                     end

if Selected==30 and pad:cross() then file = io.open("SYSTEM/GAME/CPU.txt","w");
                                     file:write("266");
                                     file:close(); 
                                     end

if Selected==40 and pad:cross() then file = io.open("SYSTEM/GAME/CPU.txt","w");
                                     file:write("133");
                                     file:close(); 
                                     end

if Selected==50 and pad:cross() then file = io.open("SYSTEM/GAME/CPU.txt","w");
                                     file:write("222");
                                     file:close(); 
                                     end

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

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

if setX>0 and setX<20 then screen:print(10,230,"CPU Speed successfully Set!!",rosso) end
if setX>0 and setX<20 then setY=setY+1 end
if setY==80 then setX=0 end
if setY==80 then setY=0 end



screen:print(10,250,"Press O to return to the MAIN MENU",rosso)
if pad:circle() and timer3>20 then dofile("SYSTEM/resources/options/options.lua") end


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













