-- images
menu1=Image.load("menu/menu1.png")
menu2=Image.load("menu/menu2.png")
menu3=Image.load("menu/menu3.png")

-- sons
blip=Sound.load("menu/blip.wav",false)

-- variables
select=1
maxselect=9

--screenshot
menu=1

-- menu
while true do
screen:clear()
pad=Controls.read()

if select > maxselect then
select=1
elseif select <= 0 then
select=maxselect
end

if pad:down() and oldpad ~= pad then
select=select+1
elseif pad:up() and oldpad ~= pad then
select=select-1
end

if select == 1 then
screen:clear()
screen:blit(0,0,menu1)
elseif select == 2 then
screen:clear()
screen:blit(0,0,menu2)
elseif select == 3 then
screen:clear()
screen:blit(0,0,menu3)
elseif select == 4 then
screen:clear()
screen:blit(0,0,menu1)
elseif select == 5 then
screen:clear()
screen:blit(0,0,menu2)
elseif select == 6 then
screen:clear()
screen:blit(0,0,menu3)
elseif select == 7 then
screen:clear()
screen:blit(0,0,menu1)
elseif select == 8 then
screen:clear()
screen:blit(0,0,menu2)
elseif select == 9 then
screen:clear()
screen:blit(0,0,menu3)
end

if pad:cross() and oldpad ~= pad and select == 1 then
blip:play()
dofile "jeu.lua"
elseif pad:cross() and oldpad ~= pad and select == 2 then
blip:play()
dofile "credits.lua"
elseif pad:cross() and oldpad ~= pad and select == 3 then
System.Quit()
elseif pad:cross() and oldpad ~= pad and select == 4 then
blip:play()
dofile "jeu.lua"
elseif pad:cross() and oldpad ~= pad and select == 5 then
blip:play()
dofile "credits.lua"
elseif pad:cross() and oldpad ~= pad and select == 6 then
System.Quit()
elseif pad:cross() and oldpad ~= pad and select == 7 then
blip:play()
dofile "jeu.lua"
elseif pad:cross() and oldpad ~= pad and select == 8 then
blip:play()
dofile "credits.lua"
elseif pad:cross() and oldpad ~= pad and select == 9 then
System.Quit()
end

if pad:select() then
screen:save("ms0:/PSP/PHOTO/menu"..menu..".png")
menu=menu+1
end

screen.flip()
screen.waitVblankStart()
oldpad=pad
end
