UMD.init()

Blanc = Color.new (255,255,255)
Gris = Color.new (123,123,123)

fond = Image.load("images/dump.png")
battery1 = Image.load("images/Copie de battery4.png")
battery2 = Image.load("images/Copie de battery3.png")
battery3 = Image.load("images/Copie de battery2.png")
battery4 = Image.load("images/Copie de battery1.png")

function Nil_Pictures()
fond = nil
battery1 = nil
battery2 = nil
battery3 = nil
battery4 = nil
end

TailleUMD = UMD.getSize()
TailleUMD = TailleUMD / 1024/1024

TailleMS = System.getFreeSpace("ms0:/")
TailleMS = TailleMS / 1024/1024

if UMD.checkDisk() == 1 then
	if System.doesFileExist ("disc0:/PSP_GAME/PIC1.PNG") == 1 then
		PIC1 = Image.load ("disc0:/PSP_GAME/PIC1.PNG")
	end
else
	UMD.term()
	System.Quit()
	
end

while true do
	screen:clear(Blanc)
	Pad = Controls.read()
	screen:blit(0,0,fond)
	
if System.powerGetBatteryLifePercent() >= 0 then batteryL = battery1 end
if System.powerGetBatteryLifePercent() > 30 then batteryL = battery2 end
if System.powerGetBatteryLifePercent() > 50 then batteryL = battery3 end
if System.powerGetBatteryLifePercent() > 70 then batteryL = battery4 end

screen:blit(456,4,batteryL)
	
	if PIC1 ~= nil then
	screen:blit (0,0,PIC1)
	end
	
	ICON0 = Image.load ("disc0:/PSP_GAME/ICON0.PNG")
	screen:blit (10,10,ICON0)
	
	screen:print (10,130,"X : Dumper l'UMD",Gris)
	 
	if Pad:cross() and not OldPad:cross() then
		if TailleMS > TailleUMD then
			Nom_ISO = System.startOSK ("","Rentrer le nom de votre jeu")
			UMD.ripISO ("ms0:/ISO/"..Nom_ISO..".iso")
			UMD.term()
			System.Quit()
		else
			System.message ("Espace insufisant sur le support Memory Stick",0)
			UMD.term()
			System.Quit()
		end
	end
	 
	screen:print (5,200,"Taille de l'UMD : "..TailleUMD.." MB",Gris)
	screen:print (5,216,"Taille restante sur le MS :"..TailleMS.." MB",Gris)
	 
	 if Pad:start() then
	 Nil_Pictures()
	 dofile ("Scripts/Dump_2.lua")
	 end

	screen.flip()
	screen.waitVblankStart()
	OldPad = Pad
end
