Skip to content

Instantly share code, notes, and snippets.

@shvelo
Created November 29, 2018 10:40
Show Gist options
  • Save shvelo/c5d4580142fd8d7040e5118dc32a46dd to your computer and use it in GitHub Desktop.
Save shvelo/c5d4580142fd8d7040e5118dc32a46dd to your computer and use it in GitHub Desktop.
Fix for PSPInstaller, open /PSP/GAME/PSPInstallerAE/CORE.LUA and overwrite the contents with this
-- DO NOT REPRODUCE THIS CODE WITHOUT PERMISSION
-- IT DAMAGES THE HOMEBREW COMMUNITY
-- PSPInstaller Adrenaline Edition by Richard Sparrow (spike_132000/TheMeq)
IMG_BACK = pge.texture.load("INC/IMG_BACK.PNG")
IMG_STAR = pge.texture.load("INC/IMG_STAR.PNG")
IMG_LOGO = pge.texture.load("INC/IMG_LOGO.PNG")
IMG_SEA = pge.texture.load("INC/IMG_SEARCH.PNG")
IMG_OPT = pge.texture.load("INC/IMG_OPTIONS.PNG")
IMG_ABO = pge.texture.load("INC/IMG_ABOUT.PNG")
IMG_APPS = pge.texture.load("INC/IMG_APPS.PNG")
IMG_GAMES = pge.texture.load("INC/IMG_GAMES.PNG")
IMG_OTHER = pge.texture.load("INC/IMG_OTHER.PNG")
IMG_THEME = pge.texture.load("INC/IMG_THEME.PNG")
IMG_SIGNED = pge.texture.load("INC/IMG_SIGNED.PNG")
FON_STD = pge.font.load("INC/FONT.TTF",12)
FON_LAR = pge.font.load("INC/FONT.TTF",24)
SND_SCRO = pge.wav.load("INC/SND_SCRO.WAV")
SND_ADVA = pge.wav.load("INC/SND_ADVA.WAV")
SND_COMP = pge.wav.load("INC/SND_COMP.WAV")
SND_BACK = pge.wav.load("INC/SND_BACK.WAV")
COL_WHIT = pge.gfx.createcolor(255,255,255)
COL_ALBL = pge.gfx.createcolor(0,0,0,100)
dofile("INC/FUNCTION.LUA")
pspi_masterlist = {}
pspi_filelist = {}
pspi = {}
pspi.media_device = "ms0:/"
pspi.state = "STARTUP"
pspi.this_version = "1.0.0"
pspi.game_count = 0
pspi.app_count = 0
pspi.theme_count = 0
pspi.other_count = 0
pspi.cursor_val = 255
pspi.cursor_loop = 1
func_init_stars()
while pge.running() do
pge.controls.update()
if pspi.state=="STARTUP" then
for k=0,255,2 do
pge.gfx.startdrawing()
pge.gfx.clearscreen()
IMG_BACK:activate()
IMG_BACK:draweasy(0,0,0,k)
IMG_LOGO:activate()
IMG_LOGO:draweasy(42,89,0,k)
func_draw_end()
end
for k=0,255,2 do
func_draw_start()
IMG_LOGO:activate()
IMG_LOGO:draweasy(42,89)
func_draw_end()
end
for k=255,0,-5 do
func_draw_start()
IMG_LOGO:activate()
IMG_LOGO:draweasy(42,89,0,k)
func_draw_end()
end
pspi.state="WLAN_INITIALISE"
end
if pspi.state=="WLAN_INITIALISE" then
pge.net.init()
pge.utils.netinit()
pspi.state="WLAN_CONNECT"
end
if pspi.state=="WLAN_CONNECT" then
func_draw_start()
pge.gfx.enddrawing()
pge.net.init()
nstate = pge.utils.netupdate()
if nstate == 0 then
online=1
pspi.state="DOWNLOAD_FILES"
elseif nstate == 1 then
pge.net.shutdown()
online=0
pspi.state="NO_CONNECTION"
elseif nstate ~= PGE_UTILS_DIALOG_RUNNING then
pge.net.shutdown()
online=0
pspi.state="NO_CONNECTION"
end
pge.gfx.swapbuffers()
end
if (not pge.net.isconnected() or not pge.net.switchstatus()) and pspi.hasconnected == 1 then
pspi.hasconnected = 0
pspi.state = "NO_CONNECTION"
end
if pspi.state=="NO_CONNECTION" then
func_draw_start()
pge.gfx.drawrect(100,35,280,75,COL_ALBL)
FON_STD:activate()
FON_STD:printcenter(50,COL_WHIT,"PSPInstaller could not connect to the internet.")
FON_STD:printcenter(80,COL_WHIT,"Press (X) to exit or (O) to reconnect.")
func_draw_end()
if pge.controls.pressed(PGE_CTRL_CROSS) then
for k=0,255,5 do
func_draw_start()
pge.gfx.drawrect(100,35,280,75,COL_ALBL)
FON_STD:activate()
FON_STD:printcenter(50,COL_WHIT,"PSPInstaller could not connect to the internet.")
FON_STD:printcenter(80,COL_WHIT,"Press (X) to exit or (O) to reconnect.")
pge.gfx.drawrect(0,0,480,272,pge.gfx.createcolor(0,0,0,k))
func_draw_end()
end
pge.exit()
end
if pge.controls.pressed(PGE_CTRL_CIRCLE) then
pspi.state = "WLAN_INITIALISE"
end
end
if pspi.state=="DOWNLOAD_FILES" then
pspi.hasconnected = 1
func_draw_start()
FON_STD:activate()
pge.gfx.drawrect(100,35,280,75,COL_ALBL)
FON_STD:printcenter(50,COL_WHIT,"PSPInstaller is downloading files.")
FON_STD:printcenter(80,COL_WHIT,"Please Wait...")
func_draw_end()
if pge.file.exists("DATABASE/SIG.LUA") then
pge.file.remove("DATABASE/SIG.LUA")
end
pge.net.getfile("http://sig.pspinstaller.co.uk/sig/repo.php","DATABASE/SIG.LUA")
if not pge.file.exists("DATABASE/SIG.LUA") then
stop_update=1
end
if pge.file.exists("DATABASE/UNSIG.LUA") then
pge.file.remove("DATABASE/UNSIG.LUA")
end
pge.net.getfile("http://pspinstaller.co.uk/unsig/repo.php","DATABASE/UNSIG.LUA")
if not pge.file.exists("DATABASE/UNSIG.LUA") then
stop_update=1
end
if stop_update==1 then
pspi.state = "FAILED_FILE_DOWNLOAD"
else
pspi.state="CLEAN_DOWNLOADS"
end
end
if pspi.state == "FAILED_FILE_DOWNLOAD" then
func_draw_start()
pge.gfx.drawrect(100,35,280,75,COL_ALBL)
FON_STD:activate()
FON_STD:printcenter(50,COL_WHIT,"PSPInstaller could not download some files.")
FON_STD:printcenter(80,COL_WHIT,"Press (X) to exit or (O) to retry.")
func_draw_end()
if pge.controls.pressed(PGE_CTRL_CROSS) then
for k=0,255,5 do
func_draw_start()
pge.gfx.drawrect(100,35,280,75,COL_ALBL)
FON_STD:activate()
FON_STD:printcenter(50,COL_WHIT,"PSPInstaller could not download some files.")
FON_STD:printcenter(80,COL_WHIT,"Press (X) to exit or (O) to retry.")
pge.gfx.drawrect(0,0,480,272,pge.gfx.createcolor(0,0,0,k))
func_draw_end()
end
pge.exit()
end
if pge.controls.pressed(PGE_CTRL_CIRCLE) then
pspi.state="DOWNLOAD_FILES"
end
end
if pspi.state == "CLEAN_DOWNLOADS" then
func_draw_start()
FON_STD:activate()
pge.gfx.drawrect(100,35,280,75,COL_ALBL)
FON_STD:printcenter(50,COL_WHIT,"PSPInstaller is tidying up.")
FON_STD:printcenter(80,COL_WHIT,"Please Wait...")
func_draw_end()
func_clear_old()
pspi.temp_var = 1
if pge.file.exists("DATABASE/SIG.LUA") then
dofile("DATABASE/SIG.LUA")
if #gl then
for k=1,#gl do
if pge.file.exists(pspi.media_device..gl[k].f) then
pge.file.remove(pspi.media_device..gl[k].f)
end
pspi_masterlist[pspi.temp_var] = {sig=1,cat="g",i=gl[k].i,n=gl[k].n,d=gl[k].d,f=gl[k].f,s=gl[k].s,e=gl[k].e,z=gl[k].z}
pspi.temp_var = pspi.temp_var+1
pspi.game_count = pspi.game_count + 1
end
end
if #al then
for k=1,#al do
if pge.file.exists(pspi.media_device..al[k].f) then
pge.file.remove(pspi.media_device..al[k].f)
end
pspi_masterlist[pspi.temp_var] = {sig=1,cat="a",i=al[k].i,n=al[k].n,d=al[k].d,f=al[k].f,s=al[k].s,e=al[k].e,z=al[k].z}
pspi.temp_var = pspi.temp_var+1
pspi.app_count = pspi.app_count + 1
end
end
if #ol then
for k=1,#ol do
if pge.file.exists(pspi.media_device..ol[k].f) then
pge.file.remove(pspi.media_device..ol[k].f)
end
pspi_masterlist[pspi.temp_var] = {sig=1,cat="o",i=ol[k].i,n=ol[k].n,d=ol[k].d,f=ol[k].f,s=ol[k].s,e=ol[k].e,z=ol[k].z}
pspi.temp_var = pspi.temp_var+1
pspi.other_count = pspi.other_count + 1
end
end
if #tl then
for k=1,#tl do
if pge.file.exists(pspi.media_device..tl[k].f) then
pge.file.remove(pspi.media_device..tl[k].f)
end
pspi_masterlist[pspi.temp_var] = {sig=1,cat="t",i=tl[k].i,n=tl[k].n,d=tl[k].d,f=tl[k].f,s=tl[k].s,e=tl[k].e,z=tl[k].z}
pspi.temp_var = pspi.temp_var+1
pspi.theme_count = pspi.theme_count + 1
end
end
end
func_clear_old()
if pge.file.exists("DATABASE/UNSIG.LUA") then
dofile("DATABASE/UNSIG.LUA")
if #gl then
for k=1,#gl do
if pge.file.exists(pspi.media_device..gl[k].f) then
pge.file.remove(pspi.media_device..gl[k].f)
end
pspi_masterlist[pspi.temp_var] = {sig=0,cat="g",i=gl[k].i,n=gl[k].n,d=gl[k].d,f=gl[k].f,s=gl[k].s,e=gl[k].e,z=gl[k].z}
pspi.temp_var = pspi.temp_var+1
pspi.game_count = pspi.game_count + 1
end
end
if #al then
for k=1,#al do
if pge.file.exists(pspi.media_device..al[k].f) then
pge.file.remove(pspi.media_device..al[k].f)
end
pspi_masterlist[pspi.temp_var] = {sig=0,cat="a",i=al[k].i,n=al[k].n,d=al[k].d,f=al[k].f,s=al[k].s,e=al[k].e,z=al[k].z}
pspi.temp_var = pspi.temp_var+1
pspi.app_count = pspi.app_count + 1
end
end
if #tl then
for k=1,#tl do
if pge.file.exists(pspi.media_device..tl[k].f) then
pge.file.remove(pspi.media_device..tl[k].f)
end
pspi_masterlist[pspi.temp_var] = {sig=0,cat="t",i=tl[k].i,n=tl[k].n,d=tl[k].d,f=tl[k].f,s=tl[k].s,e=tl[k].e,z=tl[k].z}
pspi.temp_var = pspi.temp_var+1
pspi.theme_count = pspi.theme_count + 1
end
end
if #ol then
for k=1,#ol do
if pge.file.exists(pspi.media_device..ol[k].f) then
pge.file.remove(pspi.media_device..ol[k].f)
end
pspi_masterlist[pspi.temp_var] = {sig=0,cat="o",i=ol[k].i,n=ol[k].n,d=ol[k].d,f=ol[k].f,s=ol[k].s,e=ol[k].e,z=ol[k].z}
pspi.temp_var = pspi.temp_var+1
pspi.other_count = pspi.other_count + 1
end
end
end
gl = nil
al = nil
ol = nil
tl = nil
collectgarbage("collect")
pspi.state = "PRE_MAIN_MENU"
end
if pspi.state=="PRE_MAIN_MENU" then
pspi.main_menu_option = 1
pspi.state = "MAIN_MENU"
SND_COMP:play()
end
if pspi.state=="MAIN_MENU" then
func_draw_start()
func_update_stars()
IMG_GAMES:activate()
IMG_GAMES:draweasy(4,40)
IMG_APPS:activate()
IMG_APPS:draweasy(243,40)
IMG_OTHER:activate()
IMG_OTHER:draweasy(4,157)
IMG_THEME:activate()
IMG_THEME:draweasy(243,157)
if pspi.main_menu_option == 1 then
func_draw_cursor(4,40,234,112,2)
if pge.controls.pressed(PGE_CTRL_RIGHT) then
SND_SCRO:play()
pspi.main_menu_option = 2
end
if pge.controls.pressed(PGE_CTRL_UP) then
SND_SCRO:play()
pspi.main_menu_option = 5
end
if pge.controls.pressed(PGE_CTRL_DOWN) then
SND_SCRO:play()
pspi.main_menu_option = 3
end
end
if pspi.main_menu_option == 2 then
func_draw_cursor(243,40,234,112,2)
if pge.controls.pressed(PGE_CTRL_LEFT) then
SND_SCRO:play()
pspi.main_menu_option = 1
end
if pge.controls.pressed(PGE_CTRL_UP) then
SND_SCRO:play()
pspi.main_menu_option = 6
end
if pge.controls.pressed(PGE_CTRL_DOWN) then
SND_SCRO:play()
pspi.main_menu_option = 4
end
end
if pspi.main_menu_option == 3 then
func_draw_cursor(4,157,234,112,2)
if pge.controls.pressed(PGE_CTRL_RIGHT) then
SND_SCRO:play()
pspi.main_menu_option = 4
end
if pge.controls.pressed(PGE_CTRL_UP) then
SND_SCRO:play()
pspi.main_menu_option = 1
end
end
if pspi.main_menu_option == 4 then
func_draw_cursor(243,157,234,112,2)
if pge.controls.pressed(PGE_CTRL_LEFT) then
SND_SCRO:play()
pspi.main_menu_option = 3
end
if pge.controls.pressed(PGE_CTRL_UP) then
SND_SCRO:play()
pspi.main_menu_option = 2
end
end
if pspi.main_menu_option == 5 then
func_draw_cursor(406,4,32,32,1)
if pge.controls.pressed(PGE_CTRL_RIGHT) then
SND_SCRO:play()
pspi.main_menu_option = 6
end
if pge.controls.pressed(PGE_CTRL_DOWN) then
SND_SCRO:play()
pspi.main_menu_option = 2
end
end
if pspi.main_menu_option == 6 then
func_draw_cursor(444,4,32,32,1)
if pge.controls.pressed(PGE_CTRL_LEFT) then
SND_SCRO:play()
pspi.main_menu_option = 5
end
if pge.controls.pressed(PGE_CTRL_DOWN) then
SND_SCRO:play()
pspi.main_menu_option = 2
end
end
if pge.controls.pressed(PGE_CTRL_CROSS) then
SND_ADVA:play()
if pspi.main_menu_option >= 1 and pspi.main_menu_option <=4 then
pspi.state = "PREP_VIEW"
pspi.search_run = 0
end
if pspi.main_menu_option == 5 then
pspi.state = "ABOUT"
end
if pspi.main_menu_option == 6 then
pspi.state = "SEARCH"
pspi.search_string = ""
pspi.search_run = 1
end
end
func_draw_menu_button(4,40,"Games",pspi.game_count .. " packages")
func_draw_menu_button(243,40,"Applications",pspi.app_count .. " packages")
func_draw_menu_button(4,157,"Other",pspi.other_count .. " packages")
func_draw_menu_button(243,157,"Themes",pspi.theme_count .. " packages")
IMG_SEA:activate()
IMG_SEA:draweasy(444,4)
IMG_ABO:activate()
IMG_ABO:draweasy(406,4)
FON_LAR:activate()
FON_LAR:print(5,5,COL_WHIT,"PSPInstaller Adrenaline Edition")
func_draw_end()
end
if pspi.state == "PREP_VIEW" then
pspi_filelist = nil
collectgarbage("collect")
pspi_filelist = {}
if pspi.search_run == 0 then
pspi.temp_var = 1
if pspi.main_menu_option==1 then
pspi.selected_category = "g"
elseif pspi.main_menu_option==2 then
pspi.selected_category = "a"
elseif pspi.main_menu_option==3 then
pspi.selected_category = "o"
elseif pspi.main_menu_option==4 then
pspi.selected_category = "t"
end
for k=1,#pspi_masterlist do
if pspi_masterlist[k].cat==pspi.selected_category then
pspi_filelist[pspi.temp_var] = {sig=pspi_masterlist[k].sig,cat=pspi_masterlist[k].cat,i=pspi_masterlist[k].i,n=pspi_masterlist[k].n,d=pspi_masterlist[k].d,f=pspi_masterlist[k].f,s=pspi_masterlist[k].s,e=pspi_masterlist[k].e,z=pspi_masterlist[k].z}
pspi.temp_var = pspi.temp_var+1
end
end
elseif pspi.search_run == 1 then
pspi.temp_var = 1
pspi.search_string = string.lower(pspi.search_string)
for k=1,#pspi_masterlist do
pspi.search_n = pspi_masterlist[k].n
pspi.search_d = pspi_masterlist[k].d
if string.find(string.lower(pspi.search_n),pspi.search_string) or string.find(string.lower(pspi.search_d),pspi.search_string) then
pspi_filelist[pspi.temp_var] = {sig=pspi_masterlist[k].sig,cat=pspi_masterlist[k].cat,i=pspi_masterlist[k].i,n=pspi_masterlist[k].n,d=pspi_masterlist[k].d,f=pspi_masterlist[k].f,s=pspi_masterlist[k].s,e=pspi_masterlist[k].e,z=pspi_masterlist[k].z}
pspi.temp_var = pspi.temp_var+1
end
end
end
pspi.state = "VIEW_LISTING"
pspi.view_selection = 1
pspi.view_line = 1
end
if pspi.state == "SEARCH" then
func_draw_start()
func_update_stars()
if not pge.utils.oskinit("Enter Search Query", pspi.search_string) then
error("Error on osk init.")
end
while true do
pge.gfx.enddrawing()
pge.gfx.swapbuffers()
pge.controls.update()
func_draw_start()
func_update_stars()
pge.gfx.enddrawing()
pspi.result, pspi.search_string = pge.utils.oskupdate()
if pspi.result then
if pspi.search_string ~= "" then
pspi.state="PREP_VIEW"
pspi.search_run = 1
break
else
pspi.state="MAIN_MENU"
break
end
end
end
end
if pspi.state == "ABOUT" then
func_draw_start()
func_update_stars()
pge.gfx.drawrect(5,5,470,262,COL_ALBL)
FON_LAR:activate()
FON_LAR:print(12,10,COL_WHIT,"PSPInstaller Adrenaline Edition")
FON_STD:activate()
FON_STD:print(10,40,COL_WHIT,func_wordwrap("Thank you for checking out PSPInstaller Adrenaline Edition.",FON_STD,460))
FON_STD:print(10,60,COL_WHIT,func_wordwrap("After 8 years as the number one homebrew store for the PSP, PSPInstaller continues to run even though the PSP scene has died down heavily. I still plan to keep this running for as long as I can, and the website will continue to accept homebrew uploads.",FON_STD,460))
FON_STD:print(10,110,COL_WHIT,func_wordwrap("This version works very similar to previous versions in that you can easily and quickly find and download homebrew directly to your PSP. Signed and Unsigned downloads have now been merged into one big list as it is no longer required to keep them split",FON_STD,460))
FON_STD:print(10,152,COL_WHIT,func_wordwrap("up. Options have been removed, as there was no need for them. The code has also had a massive overhall and cleanup.",FON_STD,460))
FON_STD:print(10,190,COL_WHIT,func_wordwrap("If you enjoy using this software, please tell all your friends about it. If you want to donate, please visit http://paypal.me/themeq.",FON_STD,460))
FON_STD:print(10,230,COL_WHIT,func_wordwrap("http://www.pspinstaller.co.uk - PSPInstaller is developed by Richard Sparrow (Also known as spike_132000 or TheMeq)",FON_STD,460))
func_draw_end()
if pge.controls.pressed(PGE_CTRL_CIRCLE) then
SND_BACK:play()
pspi.state="MAIN_MENU"
end
end
if pspi.state=="VIEW_LISTING" then
func_draw_start()
func_update_stars()
if not pspi_filelist[1] then
pge.gfx.drawrect(5,97,170,170,COL_ALBL)
pge.gfx.drawrect(180,5,295,262,COL_ALBL)
FON_STD:activate()
FON_STD:print(182,10,COL_WHIT,func_wordwrap("There are no files to display. Either this section is empty or your search query did not return any results. Press (O) to return.",FON_STD,285))
if pge.controls.pressed(PGE_CTRL_CIRCLE) then
SND_BACK:play()
pspi.state="MAIN_MENU"
end
else
pge.gfx.drawrect(5,5,170,262,COL_ALBL)
pge.gfx.drawrect(180,5,295,48,COL_ALBL)
pge.gfx.drawrect(180,58,295,48,COL_ALBL)
pge.gfx.drawrect(180,111,295,48,COL_ALBL)
pge.gfx.drawrect(180,164,295,49,COL_ALBL)
pge.gfx.drawrect(180,218,295,49,COL_ALBL)
if pspi.view_selection==1 then
func_draw_cursor(180,5,295,48,2)
end
if pspi.view_selection==2 then
func_draw_cursor(180,58,295,48,2)
end
if pspi.view_selection==3 then
func_draw_cursor(180,111,295,48,2)
end
if pspi.view_selection==4 then
func_draw_cursor(180,164,295,48,2)
end
if pspi.view_selection==5 then
func_draw_cursor(180,218,295,48,2)
end
FON_STD:activate()
if pspi_filelist[pspi.view_line] then
FON_STD:print(185,10,COL_WHIT,pspi.view_line .. ". ".. pspi_filelist[pspi.view_line].n)
FON_STD:print(185,23,COL_WHIT,func_wordwrap(string.sub(string.gsub(pspi_filelist[pspi.view_line].d, "\r\n", " "), 1, 80) .. "...",FON_STD,290))
end
if pspi_filelist[pspi.view_line+1] then
FON_STD:print(185,63,COL_WHIT,pspi.view_line+1 .. ". ".. pspi_filelist[pspi.view_line+1].n)
FON_STD:print(185,76,COL_WHIT,func_wordwrap(string.sub(string.gsub(pspi_filelist[pspi.view_line+1].d, "\r\n", " "), 1, 80) .. "...",FON_STD,290))
end
if pspi_filelist[pspi.view_line+2] then
FON_STD:print(185,116,COL_WHIT,pspi.view_line+2 .. ". ".. pspi_filelist[pspi.view_line+2].n)
FON_STD:print(185,129,COL_WHIT,func_wordwrap(string.sub(string.gsub(pspi_filelist[pspi.view_line+2].d, "\r\n", " "), 1, 80) .. "...",FON_STD,290))
end
if pspi_filelist[pspi.view_line+3] then
FON_STD:print(185,169,COL_WHIT,pspi.view_line+3 .. ". ".. pspi_filelist[pspi.view_line+3].n)
FON_STD:print(185,182,COL_WHIT,func_wordwrap(string.sub(string.gsub(pspi_filelist[pspi.view_line+3].d, "\r\n", " "), 1, 80) .. "...",FON_STD,290))
end
if pspi_filelist[pspi.view_line+4] then
FON_STD:print(185,223,COL_WHIT,pspi.view_line+4 .. ". ".. pspi_filelist[pspi.view_line+4].n)
FON_STD:print(185,236,COL_WHIT,func_wordwrap(string.sub(string.gsub(pspi_filelist[pspi.view_line+4].d, "\r\n", " "), 1, 80) .. "...",FON_STD,290))
end
FON_STD:print(5,10,COL_WHIT,func_wordwrap("Thanks for using PSPInstaller Adrenaline Edition to download your homebrew. If you enjoy using this software, please tell other's about it. If that is not enough, maybe consider making a donation to: http://paypal.me/themeq Thanks.",FON_STD,160))
cur_selected = pspi.view_selection + pspi.view_line - 1
if pge.controls.pressed(PGE_CTRL_CROSS) then
SND_ADVA:play()
pspi.state="VIEW_FILE"
pspi.game_menu_option = 2
end
if pge.controls.pressed(PGE_CTRL_DOWN) or pge.controls.held(PGE_CTRL_RIGHT) then
if cur_selected ~= #pspi_filelist then
SND_SCRO:play()
end
if cur_selected == #pspi_filelist then
else
if pspi.view_selection ==5 then
pspi.view_line=pspi.view_line+1
pspi.view_selection=5
if pspi.view_line == #pspi_filelist+1 then
pspi.view_line = #pspi_filelist
end
elseif pspi.view_selection<5 then
pspi.view_selection = pspi.view_selection + 1
end
end
end
if pge.controls.pressed(PGE_CTRL_UP) or pge.controls.held(PGE_CTRL_LEFT) then
if cur_selected ~= 1 then
SND_SCRO:play()
end
if pspi.view_selection == 1 then
pspi.view_line = pspi.view_line - 1
pspi.view_selection = 1
if pspi.view_line <= 1 then
pspi.view_line = 1
end
elseif pspi.view_selection > 1 then
pspi.view_selection = pspi.view_selection - 1
end
end
end
func_draw_end()
if pge.controls.pressed(PGE_CTRL_CIRCLE) then
SND_BACK:play()
pspi.state="MAIN_MENU"
end
end
if pspi.state=="VIEW_FILE" then
func_draw_start()
func_update_stars()
if pspi_filelist[cur_selected].sig == 1 then
pspi.repo_link = 1
elseif pspi_filelist[cur_selected].sig == 0 then
pspi.repo_link = 0
end
pge.gfx.drawrect(180,5,295,262,COL_ALBL)
pge.gfx.drawrect(5,237,170,30,COL_ALBL)
if pspi_filelist[cur_selected].s > 0 then
pge.gfx.drawrect(5,202,170,30,COL_ALBL)
end
FON_STD:activate()
FON_STD:print(185,10,COL_WHIT,pspi_filelist[cur_selected].n)
FON_STD:print(182,30,COL_WHIT,func_wordwrap(pspi_filelist[cur_selected].d,FON_STD,285))
sizeoffile=pge.math.floor(pspi_filelist[cur_selected].z / 1024)
FON_STD:print(185,160,COL_WHIT,"This download is "..sizeoffile.." KB ("..pspi_filelist[cur_selected].z.." bytes)")
if pspi.repo_link == 1 then
FON_STD:print(185,140,COL_WHIT,"This homebrew is:")
IMG_SIGNED:activate()
IMG_SIGNED:draweasy(283,140)
else
FON_STD:print(185,140,COL_WHIT,"This homebrew is not signed.")
end
if pspi.game_menu_option == 2 then
func_draw_cursor(5,237,170,30,2)
if pge.controls.pressed(PGE_CTRL_CROSS) then
SND_ADVA:play()
pspi.state="PREP_DOWNLOAD"
end
end
if pspi.game_menu_option == 1 and pspi_filelist[cur_selected].s > 0 then
func_draw_cursor(5,202,170,30,2)
if pge.controls.pressed(PGE_CTRL_CROSS) then
SND_ADVA:play()
if pspi_filelist[cur_selected].s>0 then
show_screenie = 0
if not pge.dir.exists("CACHE") then
pge.dir.mkdir("CACHE")
end
if pspi.repo_link == 1 then
pge.net.getfile("http://pspinstaller.co.uk/sig/screenshot.php?id="..pspi_filelist[cur_selected].i.."&s=0","CACHE/SCREEN.PNG")
screen_show = pge.texture.load("CACHE/SCREEN.PNG")
elseif pspi.repo_link == 0 then
pge.net.getfile("http://pspinstaller.co.uk/unsig/screenshot.php?id="..pspi_filelist[cur_selected].i.."&s=0","CACHE/SCREEN.PNG")
screen_show = pge.texture.load("CACHE/SCREEN.PNG")
end
pspi.game_menu_option = 1
pspi.state = "VIEW_SCREENSHOTS"
end
end
end
if pge.controls.pressed(PGE_CTRL_CIRCLE) then
SND_BACK:play()
pspi.state="VIEW_LISTING"
end
if pge.controls.pressed(PGE_CTRL_UP) and pspi_filelist[cur_selected].s > 0 then
SND_SCRO:play()
pspi.game_menu_option = 1
end
if pge.controls.pressed(PGE_CTRL_DOWN) and pspi_filelist[cur_selected].s > 0 then
SND_SCRO:play()
pspi.game_menu_option = 2
end
func_print_center(90,247,"Download")
if pspi_filelist[cur_selected].s > 0 then
func_print_center(90,212,"Screenshots")
end
func_draw_end()
end
if pspi.state=="PREP_DOWNLOAD" then
func_draw_start()
pge.gfx.drawrect(180,5,295,262,COL_ALBL)
pge.gfx.drawrect(5,97,170,170,COL_ALBL)
pge.gfx.drawrectoutline(183,250,290,10,COL_WHIT)
FON_STD:activate()
FON_STD:print(185,10,COL_WHIT,"Starting download...")
FON_STD:print(5,102,COL_WHIT,func_wordwrap("Thank you for using PSPInstaller Adrenaline Edition to download your homebrew, themes and utilities.",FON_STD,160))
func_draw_end()
if pspi.repo_link==1 then
file_dir = "/~redston2/pspinstaller.co.uk/sig/files/approved/"..pspi_filelist[cur_selected].cat.."/f"..pspi_filelist[cur_selected].i.."/package.zip"
elseif pspi.repo_link==0 then
file_dir = "/~redston2/pspinstaller.co.uk/unsig/files/approved/"..pspi_filelist[cur_selected].cat.."/f"..pspi_filelist[cur_selected].i.."/package.zip"
end
down_stat = "Starting"
down_serv = pge.net.resolve("pspinstaller.co.uk")
down_port = 80
down_file = file_dir
down_save = pspi_filelist[cur_selected].f
down_loca = pspi.media_device
down_spee = 25000
down_spec = 0
down_timo = 10
down_rect = 0
down_recc = 0
down_recp = 0
down_safi = ""
pspi.state="DO_DOWNLOAD"
tpekb=0
end
if pspi.state=="DO_DOWNLOAD" then
func_draw_start()
if down_stat == "Starting" then
if pge.file.exists(down_loca .. down_save) then
pge.file.remove(down_loca .. down_save)
end
socket = pge.net.socket.create()
socketConnection = socket:connect(down_serv, down_port)
if not socketConnection then
error("Failed to connect to the server.")
end
request = "GET /" .. down_file .. " HTTP/1.1\r\nHost: " .. down_serv .. "\r\n\r\n"
down_reqs = pge.net.socket.send(socket, request)
down_head = ""
while not string.find(down_head, "\r\n\r\n") do
down_head = down_head .. socket:receive(1)
end
down_a, down_b, down_leng = string.find(down_head, "Content%-Length: (%d+)\r\n")
down_a = nil
down_b = nil
down_rect = tonumber(down_leng)
down_stat = "Downloading"
elseif down_stat == "Downloading" then
if down_safi == "" then
down_safi = pge.file.open(down_loca .. down_save, PGE_FILE_CREATE + PGE_FILE_RDWR)
end
down_recp = down_safi:size()
down_safi:write(socket:receive(down_spee))
down_recc = down_safi:size()
down_spec = down_recc - down_recp
pge.delay(1000)
if down_recc == down_rect then
down_safi:close()
pge.delay(500000)
down_stat = "Finishing"
end
elseif down_stat == "Finishing" then
down_safi = ""
socket:close()
down_stat = "Complete"
elseif down_stat=="Complete" then
pspi.state="UNZIP_FILE"
end
pge.gfx.drawrect(180,5,295,262,COL_ALBL)
pge.gfx.drawrect(5,97,170,170,COL_ALBL)
pge.gfx.drawrectoutline(183,250,288,13,COL_WHIT)
if down_stat=="Downloading" and down_rect and down_recc then
curpercent=284 / down_rect * down_recc
actpercent=100 / down_rect * down_recc
curkb = pge.math.ceil(down_recc/1024)
totkb = pge.math.ceil(down_rect/1024)
spekb = pge.math.ceil(down_spec/1024)
tpekb = tpekb + spekb
curdate = os.date()
if oldtime ~= curdate then
cursp = tpekb
tpekb = 0
end
oldtime = curdate
pge.gfx.drawrect(185,252,curpercent,10,COL_WHIT)
FON_STD:activate()
FON_STD:print(185,10,COL_WHIT,"Downloading "..pspi_filelist[cur_selected].n.."...")
FON_STD:print(185,25,COL_WHIT,"This may take a few minutes.")
FON_STD:print(5,102,COL_WHIT,func_wordwrap("Thank you for using PSPInstaller Adrenaline Edition to download your homebrew, themes and utilities.",FON_STD,160))
FON_STD:print(185,235,COL_WHIT,pge.math.ceil(actpercent).." Percent Complete")
FON_STD:print(185,205,COL_WHIT,"Download Speed : "..cursp.." Kbp/s")
FON_STD:print(185,220,COL_WHIT,"Downloaded "..curkb.."Kb of "..totkb.."Kb")
end
func_draw_end()
end
if pspi.state=="UNZIP_FILE" then
func_draw_start()
pge.gfx.drawrect(180,5,295,262,COL_ALBL)
pge.gfx.drawrect(5,97,170,170,COL_ALBL)
FON_STD:activate()
FON_STD:print(185,10,COL_WHIT,"Installing "..pspi_filelist[cur_selected].n.."...")
FON_STD:print(185,25,COL_WHIT,"This may take a few minutes.")
FON_STD:print(5,102,COL_WHIT,func_wordwrap("Thank you for using PSPInstaller Adrenaline Edition to download your homebrew, themes and utilities.",FON_STD,160))
func_draw_end()
currentwd = pge.dir.getcwd()
myzipfile = pge.zip.open(pspi.media_device..pspi_filelist[cur_selected].f)
pge.dir.chdir(pspi.media_device)
if myzipfile then
myzipfile:extract()
pge.zip.close(myzipfile)
pge.file.remove(pspi.media_device..pspi_filelist[cur_selected].f)
error_msg="Installed "..pspi_filelist[cur_selected].n.."."
pspi.state="COMPLETE_DOWNLOAD"
SND_COMP:play()
else
error_msg="There was an error processing the file."
pspi.state="COMPLETE_DOWNLOAD"
end
pge.dir.chdir(currentwd)
end
if pspi.state=="COMPLETE_DOWNLOAD" then
func_draw_start()
func_update_stars()
pge.gfx.drawrect(180,5,295,262,COL_ALBL)
pge.gfx.drawrect(5,97,170,170,COL_ALBL)
FON_STD:activate()
FON_STD:print(5,102,COL_WHIT,func_wordwrap("Thank you for using PSPInstaller Adrenaline Edition to download your homebrew, themes and utilities.",FON_STD,160))
FON_STD:print(185,10,COL_WHIT,error_msg)
FON_STD:print(185,25,COL_WHIT,"Press (X) to return or (O) to exit.")
func_draw_end()
if pge.controls.pressed(PGE_CTRL_CROSS) then
SND_BACK:play()
pspi.state="VIEW_FILE"
end
if pge.controls.pressed(PGE_CTRL_CIRCLE) then
SND_BACK:play()
for k=0,255,5 do
func_draw_start()
func_update_stars()
pge.gfx.drawrect(180,5,295,262,COL_ALBL)
pge.gfx.drawrect(5,97,170,170,COL_ALBL)
FON_STD:activate()
FON_STD:print(5,102,COL_WHIT,func_wordwrap("Thank you for using PSPInstaller Adrenaline Edition to download your homebrew, themes and utilities.",FON_STD,160))
FON_STD:print(185,10,COL_WHIT,error_msg)
FON_STD:print(185,25,COL_WHIT,"Press (X) to return or (O) to exit.")
pge.gfx.drawrect(0,0,480,272,pge.gfx.createcolor(0,0,0,k))
func_draw_end()
end
pge.exit()
end
end
if pspi.state=="VIEW_SCREENSHOTS" then
if online == 1 then
nostars = 1
func_draw_start()
screen_show:activate()
screen_show:draweasy(0,0)
thisscreenie=show_screenie+1
to_screenie = pspi_filelist[cur_selected].s-1
pge.gfx.drawrect(5,247,45,20,pge.gfx.createcolor(0,0,0,125))
FON_STD:activate()
FON_STD:print(10,252,COL_WHIT,thisscreenie.." of "..pspi_filelist[cur_selected].s)
func_draw_end()
if pge.controls.pressed(PGE_CTRL_RIGHT) then
if show_screenie==to_screenie then
else
show_screenie=show_screenie+1
func_draw_start()
screen_show:activate()
screen_show:draweasy(0,0)
pge.gfx.drawrect(5,247,135,20,pge.gfx.createcolor(0,0,0,125))
FON_STD:activate()
FON_STD:print(10,252,COL_WHIT,thisscreenie.." of "..pspi_filelist[cur_selected].s.." Downloading...")
func_draw_end()
if pspi.repo_link==1 then
pge.net.getfile("http://pspinstaller.co.uk/sig/screenshot.php?id="..pspi_filelist[cur_selected].i.."&s="..show_screenie,"CACHE/SCREEN.PNG")
screen_show = pge.texture.load("CACHE/SCREEN.PNG")
elseif pspi.repo_link==0 then
pge.net.getfile("http://pspinstaller.co.uk/unsig/screenshot.php?id="..pspi_filelist[cur_selected].i.."&s="..show_screenie,"CACHE/SCREEN.PNG")
screen_show = pge.texture.load("CACHE/SCREEN.PNG")
end
end
end
if pge.controls.pressed(PGE_CTRL_LEFT) then
if show_screenie==0 then
else
show_screenie=show_screenie-1
func_draw_start()
screen_show:activate()
screen_show:draweasy(0,0)
pge.gfx.drawrect(5,247,135,20,pge.gfx.createcolor(0,0,0,125))
FON_STD:activate()
FON_STD:print(10,252,COL_WHIT,thisscreenie.." of "..pspi_filelist[cur_selected].s.." Downloading...")
func_draw_end()
if pspi.repo_link==1 then
pge.net.getfile("http://pspinstaller.co.uk/sig/screenshot.php?id="..pspi_filelist[cur_selected].i.."&s="..show_screenie,"CACHE/SCREEN.PNG")
screen_show = pge.texture.load("CACHE/SCREEN.PNG")
elseif pspi.repo_link==0 then
pge.net.getfile("http://pspinstaller.co.uk/unsig/screenshot.php?id="..pspi_filelist[cur_selected].i.."&s="..show_screenie,"CACHE/SCREEN.PNG")
screen_show = pge.texture.load("CACHE/SCREEN.PNG")
end
end
end
else
func_draw_start()
pge.gfx.drawrect(180,5,295,262,COL_ALBL)
FON_STD:activate()
FON_STD:print(185,10,COL_WHIT,"Error loading screenshot.")
FON_STD:print(185,30,COL_WHIT,"Press (O) to return.")
func_draw_end()
end
if pge.controls.pressed(PGE_CTRL_CIRCLE) then
collectgarbage("collect")
pspi.state = "VIEW_FILE"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment