--vmp3 by mrafenne



mov1 = 0
mov2 = 0

star1=Image.load("ms0:/PSP/GAME/vmp3v1/images/star1.png")
star2=Image.load("ms0:/PSP/GAME/vmp3v1/images/star2.png")
star3=Image.load("ms0:/PSP/GAME/vmp3v1/images/star3.png")
star4=Image.load("ms0:/PSP/GAME/vmp3v1/images/star4.png")
star5=Image.load("ms0:/PSP/GAME/vmp3v1/images/star5.png")
star6=Image.load("ms0:/PSP/GAME/vmp3v1/images/star6.png")
star7=Image.load("ms0:/PSP/GAME/vmp3v1/images/star7.png")
star8=Image.load("ms0:/PSP/GAME/vmp3v1/images/star8.png")
--star9=Image.load("ms0:/PSP/GAME/vmp3v1/images/star9.png")
--star10=Image.load("ms0:/PSP/GAME/vmp3v1/images/star10.png")
--star11=Image.load("ms0:/PSP/GAME/vmp3v1/images/star11.png")
--star12=Image.load("ms0:/PSP/GAME/vmp3v1/images/star12.png")
--star13=Image.load("ms0:/PSP/GAME/vmp3v1/images/star13.png")
--star14=Image.load("ms0:/PSP/GAME/vmp3v1/images/star14.png")
--star15=Image.load("ms0:/PSP/GAME/vmp3v1/images/star15.png")
--star16=Image.load("ms0:/PSP/GAME/vmp3v1/images/star16.png")
--star17=Image.load("ms0:/PSP/GAME/vmp3v1/images/star17.png")
--star19=Image.load("ms0:/PSP/GAME/vmp3v1/images/star19.png")


function nomvis1()
mov2 = 0
if preiw == "fasle" and next == "fasle" then
if mov1 <= 251 and mov1 >= 0 then
mov1 = mov1 +8
end
end
end

statut = "defaut"
size = 200
zMax = 5
speed =  0.1
width = 480
height = 235

starfield = {}

function createStar(i)
starfield[i] = {}
starfield[i].x = math.random(2*width) - width
starfield[i].y = math.random(2*height) - height
starfield[i].z = zMax
end

for i = 1, size do
createStar(i)
starfield[i].z = math.random(zMax)
end
function exitMenu()
star1 = nil
star2 = nil
star3 = nil
star4 = nil
star5 = nil
star6 = nil
star7 = nil
star8 = nil
mov1 = nil
mov2 = nil
v = nil
collectgarbage()
end


statut = "defaut"

while true do
screen:clear()

if pad:circle() then
statut = "affiche"
end

if statut == "affiche" then
nomvis1() 
screen:fillRect(40,mov1,400,1,white)
screen:fillRect(40,mov1,Mp3me.percent()*4,1,green)
screen:fontPrint(font,mov1+120,253,Mp3me.gettime(),green)
screen:fontPrint(font,mov1+120,270,Mp3me.songTime(),white)
screen:fontPrint(font,mov1-215,253,Mp3me.title(),white)
screen:fontPrint(font,mov1-215,270,Mp3me.album(),white)


end
if pad:square() then
statut = "defaut"
end


for i = 1, size do
starfield[i].z = starfield[i].z - speed
if starfield[i].z < speed then createStar(i) end
x = width / 2 + starfield[i].x / starfield[i].z
y = height / 1  + starfield[i].y / starfield[i].z
if x < 0 or y < 0 or x >= width or y >= height then
createStar(i)
else




      if Mp3me.vis(0) <= 130 then
   star = star1
   end
      if Mp3me.vis(0) <= 120 then
   star = star2 
   end
      if Mp3me.vis(0) <= 100 then
   star = star3
   end
      if Mp3me.vis(0) <= 90 then
   star = star4
   end
      if Mp3me.vis(0) <= 80 then
   star = star5
   end
      if Mp3me.vis(0) <= 70 then
   star = star6  
   end
    if Mp3me.vis(0) <= 60 then
   star = star7
   end
    if Mp3me.vis(0) <= 50 then
   star = star8
   end
   -- if Mp3me.vis(0) <= 40 then
   --star = star9
   --end



screen:blit(x ,y,star)
end
end

pad = Controls.read()

if pad:r() and not oldpad:r() then
if fbrowser.s < (fbrowser.nf + 1) then
i = fbrowser.s + 1
if i < (fbrowser.nf + 1) then
if string.lower(string.sub(fbrowser.fl[i].name, -4)) == ".mp3" or
string.lower(string.sub(fbrowser.fl[i].name, -4)) == ".MP3" then
fbrowser.s = fbrowser.s + 1
Mp3me.stop()
screen:clear()
Mp3me.load(fbrowser.fl[fbrowser.s].name)
Mp3me.play()
end
end
end
end

if pad:l() and not oldpad:l() then
if fbrowser.s < (fbrowser.nf + 1) and fbrowser.s > 2 then
i = fbrowser.s - 1
if i < (fbrowser.nf + 1) and i > 2 then
if string.lower(string.sub(fbrowser.fl[i].name, -4)) == ".mp3" or
string.lower(string.sub(fbrowser.fl[i].name, -4)) == ".MP3" then
Mp3me.stop()
screen:clear()
fbrowser.s = fbrowser.s - 1
Mp3me.load(fbrowser.fl[fbrowser.s].name)
Mp3me.play()
end
end
end
end

if pad:cross() and not oldpad:cross() then
Mp3me.pause()
end

if pad:left() then
screen.waitVblankStart(50)
dofile("ms0:/PSP/GAME/vmp3v1/Ibis/vmp314.lua")
exitMenu()
end

if pad:right() then
screen.waitVblankStart(50)
dofile("ms0:/PSP/GAME/vmp3v1/Ibis/vmp316.lua")
exitMenu()
end

if pad:triangle() then
screen.waitVblankStart(50)
dofile("ms0:/PSP/GAME/vmp3v1/menu.lua")
exitMenu()
end


if pad:start() then 
screen.waitVblankStart(50)
dofile("ms0:/PSP/GAME/vmp3v1/script1.lua")
exitMenu()
end

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


