Added archive for title app storing.
Added archive for title app storing.
This commit is contained in:
parent
c27ff9ea8c
commit
cb38409eb3
142
app/index.lua
142
app/index.lua
@ -1,3 +1,7 @@
|
|||||||
|
-- Creating dirs in case they do not exist
|
||||||
|
System.createDirectory("ux0:/data/TrackPlug")
|
||||||
|
System.createDirectory("ux0:/data/TrackPlugArchive")
|
||||||
|
|
||||||
-- Scanning TrackPlug folder
|
-- Scanning TrackPlug folder
|
||||||
local tbl = System.listDirectory("ux0:/data/TrackPlug")
|
local tbl = System.listDirectory("ux0:/data/TrackPlug")
|
||||||
if tbl == nil then
|
if tbl == nil then
|
||||||
@ -23,91 +27,77 @@ function FormatTime(val)
|
|||||||
if minutes > 0 then
|
if minutes > 0 then
|
||||||
res = res .. minutes .. "m "
|
res = res .. minutes .. "m "
|
||||||
end
|
end
|
||||||
if seconds > 0 then
|
res = res .. seconds .. "s "
|
||||||
res = res .. seconds .. "s "
|
|
||||||
end
|
|
||||||
return res
|
return res
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Extracts title name from an SFO file descriptor
|
-- Recover title from homebrew database
|
||||||
function extractTitle(handle)
|
function recoverTitle(tid)
|
||||||
io.seek(handle, 0x0C, SET)
|
local file = System.openFile("ux0:/data/TrackPlugArchive/" .. tid .. ".txt", FREAD)
|
||||||
local data_offs = bin2int(io.read(handle, 4))
|
fsize = System.sizeFile(file)
|
||||||
local title_idx = bin2int(io.read(handle, 4)) - 3 -- STITLE seems to be always the MAX-3 entry
|
local title = System.readFile(file, fsize)
|
||||||
io.seek(handle, (title_idx << 4) + 0x04, CUR)
|
System.closeFile(file)
|
||||||
local len = bin2int(io.read(handle, 4))
|
return title
|
||||||
local dummy = io.read(handle, 4)
|
end
|
||||||
local offs = bin2int(io.read(handle, 4))
|
|
||||||
io.seek(handle, data_offs + offs, SET)
|
-- Extracts title name from an SFO file
|
||||||
return io.read(handle, len)
|
function extractTitle(file, tid)
|
||||||
|
local data = System.extractSFO(file)
|
||||||
|
if System.doesFileExist("ux0:/data/TrackPlugArchive/" .. tid .. ".txt") then
|
||||||
|
System.deleteFile("ux0:/data/TrackPlugArchive/" .. tid .. ".txt")
|
||||||
|
end
|
||||||
|
local file = System.openFile("ux0:/data/TrackPlugArchive/" .. tid .. ".txt", FCREATE)
|
||||||
|
System.writeFile(file, data.title, string.len(data.title))
|
||||||
|
System.closeFile(file)
|
||||||
|
return data.title
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Loading unknown icon
|
-- Loading unknown icon
|
||||||
local unk = Graphics.loadImage("app0:/unk.png")
|
local unk = Graphics.loadImage("app0:/unk.png")
|
||||||
|
|
||||||
-- GekiHEN contest splashscreen
|
|
||||||
local splash = Graphics.loadImage("app0:/splash.png")
|
|
||||||
local tmr = Timer.new()
|
|
||||||
local spl = 0
|
|
||||||
local setup_finished = false
|
|
||||||
while Timer.getTime(tmr) < 3000 do
|
|
||||||
Graphics.initBlend()
|
|
||||||
Graphics.drawImage(0, 0, splash)
|
|
||||||
Graphics.termBlend()
|
|
||||||
Screen.flip()
|
|
||||||
Screen.waitVblankStart()
|
|
||||||
spl = spl + 1
|
|
||||||
if not setup_finished and spl > 3 then
|
|
||||||
setup_finished = true
|
|
||||||
|
|
||||||
-- Getting region, playtime, icon and title name for any game
|
-- Getting region, playtime, icon and title name for any game
|
||||||
for i, file in pairs(tbl) do
|
for i, file in pairs(tbl) do
|
||||||
if file.name == "config.lua" then
|
if file.name == "config.lua" then
|
||||||
dofile("ux0:/data/TrackPlug/"..file.name)
|
dofile("ux0:/data/TrackPlug/"..file.name)
|
||||||
cfg_idx = i
|
cfg_idx = i
|
||||||
else
|
else
|
||||||
local titleid = string.sub(file.name,1,-5)
|
local titleid = string.sub(file.name,1,-5)
|
||||||
local regioncode = string.sub(file.name,1,4)
|
local regioncode = string.sub(file.name,1,4)
|
||||||
if regioncode == "PCSA" or regioncode == "PCSE" then
|
if regioncode == "PCSA" or regioncode == "PCSE" then
|
||||||
file.region = "USA"
|
file.region = "USA"
|
||||||
elseif regioncode == "PCSB" then
|
elseif regioncode == "PCSB" then
|
||||||
file.region = "EUR"
|
file.region = "EUR"
|
||||||
elseif regioncode == "PCSF" then
|
elseif regioncode == "PCSF" then
|
||||||
file.region = "AUS"
|
file.region = "AUS"
|
||||||
elseif regioncode == "PCSG" then
|
elseif regioncode == "PCSG" then
|
||||||
file.region = "JPN"
|
file.region = "JPN"
|
||||||
elseif regioncode == "PCSH" then
|
elseif regioncode == "PCSH" then
|
||||||
file.region = "ASN"
|
file.region = "ASN"
|
||||||
else
|
else
|
||||||
file.region = "UNK"
|
file.region = "UNK"
|
||||||
end
|
|
||||||
if System.doesFileExist("ur0:/appmeta/" .. titleid .. "/icon0.png") then
|
|
||||||
file.icon = Graphics.loadImage("ur0:/appmeta/" .. titleid .. "/icon0.png")
|
|
||||||
else
|
|
||||||
file.icon = unk
|
|
||||||
end
|
|
||||||
if System.doesFileExist("ux0:/app/" .. titleid .. "/sce_sys/param.sfo") then
|
|
||||||
fd = io.open("ux0:/app/" .. titleid .. "/sce_sys/param.sfo", FREAD)
|
|
||||||
file.title = extractTitle(fd)
|
|
||||||
io.close(fd)
|
|
||||||
else
|
|
||||||
file.title = "Unknown Title"
|
|
||||||
end
|
|
||||||
file.id = titleid
|
|
||||||
fd = io.open("ux0:/data/TrackPlug/" .. file.name, FREAD)
|
|
||||||
file.rtime = bin2int(io.read(fd, 4))
|
|
||||||
file.ptime = FormatTime(file.rtime)
|
|
||||||
io.close(fd)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
if cfg_idx ~= nil then
|
if System.doesFileExist("ur0:/appmeta/" .. titleid .. "/icon0.png") then
|
||||||
table.remove(tbl, cfg_ifx)
|
file.icon = Graphics.loadImage("ur0:/appmeta/" .. titleid .. "/icon0.png")
|
||||||
|
else
|
||||||
|
file.icon = unk
|
||||||
end
|
end
|
||||||
|
if System.doesFileExist("ux0:/data/TrackPlugArchive/" .. titleid .. ".txt") then
|
||||||
|
file.title = recoverTitle(titleid)
|
||||||
|
elseif System.doesFileExist("ux0:/app/" .. titleid .. "/sce_sys/param.sfo") then
|
||||||
|
file.title = extractTitle("ux0:/app/" .. titleid .. "/sce_sys/param.sfo", titleid)
|
||||||
|
else
|
||||||
|
file.title = "Unknown Title"
|
||||||
|
end
|
||||||
|
file.id = titleid
|
||||||
|
fd = System.openFile("ux0:/data/TrackPlug/" .. file.name, FREAD)
|
||||||
|
file.rtime = bin2int(System.readFile(fd, 4))
|
||||||
|
file.ptime = FormatTime(file.rtime)
|
||||||
|
System.closeFile(fd)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Timer.destroy(tmr)
|
if cfg_idx ~= nil then
|
||||||
Graphics.freeImage(splash)
|
table.remove(tbl, cfg_idx)
|
||||||
|
end
|
||||||
|
|
||||||
-- Background wave effect
|
-- Background wave effect
|
||||||
local colors = {
|
local colors = {
|
||||||
@ -368,9 +358,9 @@ while #tbl > 0 do
|
|||||||
col_idx = 1
|
col_idx = 1
|
||||||
end
|
end
|
||||||
wav:color(Color.getR(colors[col_idx][3]),Color.getG(colors[col_idx][3]),Color.getB(colors[col_idx][3]))
|
wav:color(Color.getR(colors[col_idx][3]),Color.getG(colors[col_idx][3]),Color.getB(colors[col_idx][3]))
|
||||||
fd = io.open("ux0:/data/TrackPlug/config.lua", FCREATE)
|
fd = System.openFile("ux0:/data/TrackPlug/config.lua", FCREATE)
|
||||||
io.write(fd, "col_idx="..col_idx, 9)
|
System.writeFile(fd, "col_idx="..col_idx, 9)
|
||||||
io.close(fd)
|
System.closeFile(fd)
|
||||||
end
|
end
|
||||||
oldpad = pad
|
oldpad = pad
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user