app: Update for latest lpp-vita

This commit is contained in:
Michal Chvíla 2019-08-23 01:18:29 +02:00
parent 50160454fc
commit 9227503bef

View File

@ -5,257 +5,257 @@ 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
tbl = {} tbl = {}
end end
-- Convert a 32 bit binary string to a integer -- Convert a 32 bit binary string to a integer
function bin2int(str) function bin2int(str)
local b1, b2, b3, b4 = string.byte(str, 1, 4) local b1, b2, b3, b4 = string.byte(str, 1, 4)
return (b4 << 24) + (b3 << 16) + (b2 << 8) + b1 return bit32.lshift(b4, 24) + bit32.lshift(b3, 16) + bit32.lshift(b2, 8) + b1
end end
-- Format raw time data -- Format raw time data
function FormatTime(val) function FormatTime(val)
local minutes = math.floor(val/60) local minutes = math.floor(val/60)
local seconds = val%60 local seconds = val%60
local hours = math.floor(minutes/60) local hours = math.floor(minutes/60)
local minutes = minutes%60 local minutes = minutes%60
local res = "" local res = ""
if hours > 0 then if hours > 0 then
res = hours .. "h " res = hours .. "h "
end end
if minutes > 0 then if minutes > 0 then
res = res .. minutes .. "m " res = res .. minutes .. "m "
end end
res = res .. seconds .. "s " res = res .. seconds .. "s "
return res return res
end end
-- Recover title from homebrew database -- Recover title from homebrew database
function recoverTitle(tid) function recoverTitle(tid)
local file = System.openFile("ux0:/data/TrackPlugArchive/" .. tid .. ".txt", FREAD) local file = System.openFile("ux0:/data/TrackPlugArchive/" .. tid .. ".txt", FREAD)
fsize = System.sizeFile(file) fsize = System.sizeFile(file)
local title = System.readFile(file, fsize) local title = System.readFile(file, fsize)
System.closeFile(file) System.closeFile(file)
return title return title
end end
-- Extracts title name from an SFO file -- Extracts title name from an SFO file
function extractTitle(file, tid) function extractTitle(file, tid)
local data = System.extractSFO(file) local data = System.extractSfo(file)
if System.doesFileExist("ux0:/data/TrackPlugArchive/" .. tid .. ".txt") then if System.doesFileExist("ux0:/data/TrackPlugArchive/" .. tid .. ".txt") then
System.deleteFile("ux0:/data/TrackPlugArchive/" .. tid .. ".txt") System.deleteFile("ux0:/data/TrackPlugArchive/" .. tid .. ".txt")
end end
local file = System.openFile("ux0:/data/TrackPlugArchive/" .. tid .. ".txt", FCREATE) local file = System.openFile("ux0:/data/TrackPlugArchive/" .. tid .. ".txt", FCREATE)
System.writeFile(file, data.title, string.len(data.title)) System.writeFile(file, data.title, string.len(data.title))
System.closeFile(file) System.closeFile(file)
return data.title return data.title
end end
function getRegion(titleid) function getRegion(titleid)
local regioncode = string.sub(titleid,1,4) local regioncode = string.sub(titleid,1,4)
local prefix = string.sub(regioncode,1,2) local prefix = string.sub(regioncode,1,2)
local region = "Unknown" local region = "Unknown"
-- PSV common -- PSV common
if regioncode == "PCSA" or regioncode == "PCSE" then if regioncode == "PCSA" or regioncode == "PCSE" then
region = "USA" region = "USA"
elseif regioncode == "PCSB" or regioncode == "PCSF" then elseif regioncode == "PCSB" or regioncode == "PCSF" then
region = "Europe" region = "Europe"
elseif regioncode == "PCSC" or regioncode == "PCSG" then elseif regioncode == "PCSC" or regioncode == "PCSG" then
region = "Japan" region = "Japan"
elseif regioncode == "PCSD" or regioncode == "PCSH" then elseif regioncode == "PCSD" or regioncode == "PCSH" then
region = "Asia" region = "Asia"
-- Physical & NP releases (PSV/PSP/PS1) -- Physical & NP releases (PSV/PSP/PS1)
elseif prefix == "VC" or prefix == "VL" or elseif prefix == "VC" or prefix == "VL" or
prefix == "UC" or prefix == "UL" or prefix == "UC" or prefix == "UL" or
prefix == "SC" or prefix == "SL" or prefix == "SC" or prefix == "SL" or
prefix == "NP" then prefix == "NP" then
n1 = string.sub(regioncode,1,1) n1 = string.sub(regioncode,1,1)
n3 = string.sub(regioncode,3,3) n3 = string.sub(regioncode,3,3)
n4 = string.sub(regioncode,4,4) n4 = string.sub(regioncode,4,4)
if n3 == "A" then if n3 == "A" then
region = "Asia" region = "Asia"
elseif n3 == "C" then elseif n3 == "C" then
region = "China" region = "China"
elseif n3 == "E" then elseif n3 == "E" then
region = "Europe" region = "Europe"
elseif n3 == "H" then elseif n3 == "H" then
region = "Hong Kong" region = "Hong Kong"
elseif n3 == "J" or n3 == "P" then elseif n3 == "J" or n3 == "P" then
region = "Japan" region = "Japan"
elseif n3 == "K" then elseif n3 == "K" then
region = "Korea" region = "Korea"
elseif n3 == "U" then elseif n3 == "U" then
region = "USA" region = "USA"
end end
if n1 == "S" then if n1 == "S" then
region = region .. " (PS1)" region = region .. " (PS1)"
elseif n1 == "U" or elseif n1 == "U" or
(prefix == "NP" and (n4 == "G" or n4 == "H")) then (prefix == "NP" and (n4 == "G" or n4 == "H")) then
region = region .. " (PSP)" region = region .. " (PSP)"
elseif prefix == "NP" then elseif prefix == "NP" then
if n4 == "E" or n4 == "F" then if n4 == "E" or n4 == "F" then
region = region .. " (PS1 - PAL)" region = region .. " (PS1 - PAL)"
elseif n4 == "I" or n4 == "J" then elseif n4 == "I" or n4 == "J" then
region = region .. " (PS1 - NTSC)" region = region .. " (PS1 - NTSC)"
end end
end end
elseif prefix == "PE" then elseif prefix == "PE" then
region = "Europe (PS1)" region = "Europe (PS1)"
elseif prefix == "PT" then elseif prefix == "PT" then
region = "Asia (PS1)" region = "Asia (PS1)"
elseif prefix == "PU" then elseif prefix == "PU" then
region = "USA (PS1)" region = "USA (PS1)"
elseif string.sub(file.name,1,6) == "PSPEMU" then elseif string.sub(file.name,1,6) == "PSPEMU" then
region = "PSP/PS1" region = "PSP/PS1"
end end
return region return region
end end
-- Loading unknown icon -- Loading unknown icon
local unk = Graphics.loadImage("app0:/unk.png") local unk = Graphics.loadImage("app0:/unk.png")
-- 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)
file.region = getRegion(titleid) file.region = getRegion(titleid)
if System.doesFileExist("ur0:/appmeta/" .. titleid .. "/icon0.png") then if System.doesFileExist("ur0:/appmeta/" .. titleid .. "/icon0.png") then
file.icon = Graphics.loadImage("ur0:/appmeta/" .. titleid .. "/icon0.png") file.icon = Graphics.loadImage("ur0:/appmeta/" .. titleid .. "/icon0.png")
else else
file.icon = unk file.icon = unk
end end
if System.doesFileExist("ux0:/data/TrackPlugArchive/" .. titleid .. ".txt") then if System.doesFileExist("ux0:/data/TrackPlugArchive/" .. titleid .. ".txt") then
file.title = recoverTitle(titleid) file.title = recoverTitle(titleid)
elseif System.doesFileExist("ux0:/app/" .. titleid .. "/sce_sys/param.sfo") then elseif System.doesFileExist("ux0:/app/" .. titleid .. "/sce_sys/param.sfo") then
file.title = extractTitle("ux0:/app/" .. titleid .. "/sce_sys/param.sfo", titleid) file.title = extractTitle("ux0:/app/" .. titleid .. "/sce_sys/param.sfo", titleid)
else else
file.title = "Unknown Title" file.title = "Unknown Title"
end end
file.id = titleid file.id = titleid
fd = System.openFile("ux0:/data/TrackPlug/" .. file.name, FREAD) fd = System.openFile("ux0:/data/TrackPlug/" .. file.name, FREAD)
file.rtime = bin2int(System.readFile(fd, 4)) file.rtime = bin2int(System.readFile(fd, 4))
file.ptime = FormatTime(file.rtime) file.ptime = FormatTime(file.rtime)
System.closeFile(fd) System.closeFile(fd)
end end
end end
if cfg_idx ~= nil then if cfg_idx ~= nil then
table.remove(tbl, cfg_idx) table.remove(tbl, cfg_idx)
end end
-- Background wave effect -- Background wave effect
local colors = { local colors = {
{Color.new(0,132,255), Color.new(72,185,255), Color.new(0,132,255)}, -- Cyan {Color.new(0,132,255), Color.new(72,185,255), Color.new(0,132,255)}, -- Cyan
{Color.new(255,132,0), Color.new(255,185,72), Color.new(255,132,0)}, -- Orange {Color.new(255,132,0), Color.new(255,185,72), Color.new(255,132,0)}, -- Orange
{Color.new(255,72,72), Color.new(255,132,132), Color.new(255,72,72)}, -- Pink {Color.new(255,72,72), Color.new(255,132,132), Color.new(255,72,72)}, -- Pink
{Color.new(255,0,0), Color.new(255,72,72), Color.new(255,0,0)}, -- Red {Color.new(255,0,0), Color.new(255,72,72), Color.new(255,0,0)}, -- Red
{Color.new(255,72,255), Color.new(255,185,255), Color.new(255,72,255)}, -- Magenta {Color.new(255,72,255), Color.new(255,185,255), Color.new(255,72,255)}, -- Magenta
{Color.new(72,72,72), Color.new(0,0,0), Color.new(0,255,0)} -- Black'N'Green {Color.new(72,72,72), Color.new(0,0,0), Color.new(0,255,0)} -- Black'N'Green
} }
if col_idx == nil then if col_idx == nil then
col_idx = 6 col_idx = 6
end end
local function LoadWave(height,dim,f,style,x_dim) local function LoadWave(height,dim,f,style,x_dim)
if style == 1 then if style == 1 then
f=f or 0.1 f=f or 0.1
local onda={pi=math.pi,Frec=f,Long_onda=dim,Amplitud=height} local onda={pi=math.pi,Frec=f,Long_onda=dim,Amplitud=height}
function onda:color(a,b,c) self.a=a self.b=b self.c=c end function onda:color(a,b,c) self.a=a self.b=b self.c=c end
function onda:init(desfase) function onda:init(desfase)
desfase=desfase or 0 desfase=desfase or 0
if not self.contador then if not self.contador then
self.contador=Timer.new() self.contador=Timer.new()
end end
if not self.a or not self.b or not self.c then if not self.a or not self.b or not self.c then
self.a = 0 self.a = 0
self.b = 0 self.b = 0
self.c = 255 self.c = 255
end end
local t,x,y,i local t,x,y,i
t = Timer.getTime(self.contador)/1000+desfase t = Timer.getTime(self.contador)/1000+desfase
for x = 0,x_dim,4 do for x = 0,x_dim,4 do
y = 252+self.Amplitud*math.sin(2*self.pi*(t*self.Frec-x/self.Long_onda)) y = 252+self.Amplitud*math.sin(2*self.pi*(t*self.Frec-x/self.Long_onda))
i = self.Amplitud*(-2*self.pi/self.Long_onda)*math.cos(2*self.pi*(t*self.Frec-x/self.Long_onda)) i = self.Amplitud*(-2*self.pi/self.Long_onda)*math.cos(2*self.pi*(t*self.Frec-x/self.Long_onda))
Graphics.drawLine(x-200,x+200,y-i*200,y+i*200,Color.new(self.a,self.b,self.c,math.floor(x/40))) Graphics.drawLine(x-200,x+200,y-i*200,y+i*200,Color.new(self.a,self.b,self.c,math.floor(x/40)))
end end
collectgarbage() collectgarbage()
end end
function onda:destroy() function onda:destroy()
Timer.destroy(self.contador) Timer.destroy(self.contador)
end end
return onda return onda
end end
if style == 2 then if style == 2 then
f=f or 0.1 f=f or 0.1
local onda={pi=math.pi,Frec=f,Long_onda=dim,Amplitud=height} local onda={pi=math.pi,Frec=f,Long_onda=dim,Amplitud=height}
function onda:color(a,b,c) self.a=a self.b=b self.c=c end function onda:color(a,b,c) self.a=a self.b=b self.c=c end
function onda:init(desfase) function onda:init(desfase)
desfase=desfase or 0 desfase=desfase or 0
if not self.contador then if not self.contador then
self.contador=Timer.new() self.contador=Timer.new()
end end
if not self.a or not self.b or not self.c then if not self.a or not self.b or not self.c then
self.a = 0 self.a = 0
self.b = 0 self.b = 0
self.c = 255 self.c = 255
end end
local t,x,y,i,a local t,x,y,i,a
t = Timer.getTime(self.contador)/1000+desfase t = Timer.getTime(self.contador)/1000+desfase
if self.Amplitud <= 5 then if self.Amplitud <= 5 then
self.aumento = true self.aumento = true
elseif self.Amplitud >= 110 then elseif self.Amplitud >= 110 then
self.aumento = false self.aumento = false
end end
if self.aumento then if self.aumento then
self.Amplitud = self.Amplitud+0.1 self.Amplitud = self.Amplitud+0.1
else else
self.Amplitud = self.Amplitud-0.1 self.Amplitud = self.Amplitud-0.1
end end
for x = 0,x_dim,10 do for x = 0,x_dim,10 do
y = 272+self.Amplitud*math.sin(2*self.pi*(t*self.Frec-x/self.Long_onda)) y = 272+self.Amplitud*math.sin(2*self.pi*(t*self.Frec-x/self.Long_onda))
i = self.Amplitud*(-2*self.pi/self.Long_onda)*math.cos(2*self.pi*(t*self.Frec-x/self.Long_onda)) i = self.Amplitud*(-2*self.pi/self.Long_onda)*math.cos(2*self.pi*(t*self.Frec-x/self.Long_onda))
for a = -3,3 do for a = -3,3 do
Graphics.drawLine(x-20,x+20,a+y-i*20,a+y+i*20,Color.new(self.a,self.b,self.c,25-math.abs(a*5))) Graphics.drawLine(x-20,x+20,a+y-i*20,a+y+i*20,Color.new(self.a,self.b,self.c,25-math.abs(a*5)))
end end
end end
collectgarbage() collectgarbage()
end end
function onda:destroy() function onda:destroy()
Timer.destroy(self.contador) Timer.destroy(self.contador)
end end
return onda return onda
end end
if style == 3 then if style == 3 then
f=f or 0.1 f=f or 0.1
local onda={pi=math.pi,Frec=f,Long_onda=dim,Amplitud=height} local onda={pi=math.pi,Frec=f,Long_onda=dim,Amplitud=height}
function onda:color(a,b,c) self.Color=Color.new(a,b,c,40) end function onda:color(a,b,c) self.Color=Color.new(a,b,c,40) end
function onda:init(desfase) function onda:init(desfase)
desfase=desfase or 0 desfase=desfase or 0
if not self.contador then if not self.contador then
self.contador=Timer.new() self.contador=Timer.new()
end end
if not self.Color then if not self.Color then
self.Color=Color.new(0,0,255,40) self.Color=Color.new(0,0,255,40)
end end
local t,x,y,i local t,x,y,i
t = Timer.getTime(self.contador)/1000+desfase t = Timer.getTime(self.contador)/1000+desfase
for x = 0,x_dim do for x = 0,x_dim do
y = 252+self.Amplitud*math.sin(2*self.pi*(t*self.Frec-x/self.Long_onda)) y = 252+self.Amplitud*math.sin(2*self.pi*(t*self.Frec-x/self.Long_onda))
Graphics.drawLine(x,x,y,240,self.Color) Graphics.drawLine(x,x,y,240,self.Color)
end end
collectgarbage() collectgarbage()
end end
function onda:destroy() function onda:destroy()
Timer.destroy(self.contador) Timer.destroy(self.contador)
end end
return onda return onda
end end
end end
wav = LoadWave(15,1160, 0.1, 2, 960) wav = LoadWave(15,1160, 0.1, 2, 960)
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]))
@ -268,17 +268,17 @@ local orders = {"Name", "Playtime"}
-- Ordering titles -- Ordering titles
table.sort(tbl, function (a, b) return (a.title:lower() < b.title:lower() ) end) table.sort(tbl, function (a, b) return (a.title:lower() < b.title:lower() ) end)
function resortList(o_type, m_idx) function resortList(o_type, m_idx)
local old_id = tbl[m_idx].id local old_id = tbl[m_idx].id
if o_type == 1 then -- Name if o_type == 1 then -- Name
table.sort(tbl, function (a, b) return (a.title:lower() < b.title:lower() ) end) table.sort(tbl, function (a, b) return (a.title:lower() < b.title:lower() ) end)
elseif o_type == 2 then -- Playtime elseif o_type == 2 then -- Playtime
table.sort(tbl, function (a, b) return (a.rtime > b.rtime ) end) table.sort(tbl, function (a, b) return (a.rtime > b.rtime ) end)
end end
for i, title in pairs(tbl) do for i, title in pairs(tbl) do
if title.id == old_id then if title.id == old_id then
return i return i
end end
end end
end end
-- Internal stuffs -- Internal stuffs
@ -290,23 +290,23 @@ local grey = Color.new(40, 40, 40)
local alarm_val = 128 local alarm_val = 128
local alarm_decrease = true local alarm_decrease = true
function showAlarm(title, select_idx) function showAlarm(title, select_idx)
if alarm_decrease then if alarm_decrease then
alarm_val = alarm_val - 4 alarm_val = alarm_val - 4
if alarm_val == 40 then if alarm_val == 40 then
alarm_decrease = false alarm_decrease = false
end end
else else
alarm_val = alarm_val + 4 alarm_val = alarm_val + 4
if alarm_val == 128 then if alarm_val == 128 then
alarm_decrease = true alarm_decrease = true
end end
end end
local sclr = Color.new(alarm_val, alarm_val, alarm_val) local sclr = Color.new(alarm_val, alarm_val, alarm_val)
Graphics.fillRect(200, 760, 200, 280, grey) Graphics.fillRect(200, 760, 200, 280, grey)
Graphics.debugPrint(205, 205, title, yellow) Graphics.debugPrint(205, 205, title, yellow)
Graphics.fillRect(200, 760, 215 + select_idx * 20, 235 + select_idx * 20, sclr) Graphics.fillRect(200, 760, 215 + select_idx * 20, 235 + select_idx * 20, sclr)
Graphics.debugPrint(205, 235, "Yes", white) Graphics.debugPrint(205, 235, "Yes", white)
Graphics.debugPrint(205, 255, "No", white) Graphics.debugPrint(205, 255, "No", white)
end end
-- Scroll-list Renderer -- Scroll-list Renderer
@ -319,152 +319,152 @@ local new_list_idx = nil
local real_i = 1 local real_i = 1
local big_tbl = {} local big_tbl = {}
function RenderList() function RenderList()
local r_max = 0 local r_max = 0
local r = 0 local r = 0
big_tbl = {} big_tbl = {}
if #tbl < 4 then if #tbl < 4 then
r_max = 8 r_max = 8
else else
r_max = 2 r_max = 2
end end
while r < r_max do while r < r_max do
for k, v in pairs(tbl) do for k, v in pairs(tbl) do
table.insert(big_tbl, v) table.insert(big_tbl, v)
end end
r = r + 1 r = r + 1
end end
local y = -124 local y = -124
local i = list_idx - 1 local i = list_idx - 1
if not freeze then if not freeze then
if decrease then if decrease then
sel_val = sel_val - 4 sel_val = sel_val - 4
if sel_val == 0 then if sel_val == 0 then
decrease = false decrease = false
end end
else else
sel_val = sel_val + 4 sel_val = sel_val + 4
if sel_val == 128 then if sel_val == 128 then
decrease = true decrease = true
end end
end end
end end
local sclr = Color.new(sel_val, sel_val, sel_val, 100) local sclr = Color.new(sel_val, sel_val, sel_val, 100)
Graphics.fillRect(0, 960, 4, 140, sclr) Graphics.fillRect(0, 960, 4, 140, sclr)
Graphics.debugPrint(800, 520, "Order: " .. orders[order_idx], white) Graphics.debugPrint(800, 520, "Order: " .. orders[order_idx], white)
if mov_y ~= 0 then if mov_y ~= 0 then
mov_y = mov_y + mov_step mov_y = mov_y + mov_step
if math.abs(mov_y) >= 132 then if math.abs(mov_y) >= 132 then
mov_y = 0 mov_y = 0
list_idx = new_list_idx list_idx = new_list_idx
i = new_list_idx - 1 i = new_list_idx - 1
end end
end end
while i <= list_idx + 4 do while i <= list_idx + 4 do
if i < 1 then if i < 1 then
real_i = i real_i = i
i = #big_tbl - math.abs(i) i = #big_tbl - math.abs(i)
end end
if i ~= list_idx + 4 then if i ~= list_idx + 4 then
Graphics.drawImage(5, y + mov_y, big_tbl[i].icon) Graphics.drawImage(5, y + mov_y, big_tbl[i].icon)
end end
Graphics.debugPrint(150, y + 25 + mov_y, big_tbl[i].title, yellow) Graphics.debugPrint(150, y + 25 + mov_y, big_tbl[i].title, yellow)
Graphics.debugPrint(150, y + 45 + mov_y, "Title ID: " .. big_tbl[i].id, white) Graphics.debugPrint(150, y + 45 + mov_y, "Title ID: " .. big_tbl[i].id, white)
Graphics.debugPrint(150, y + 65 + mov_y, "Region: " .. big_tbl[i].region, white) Graphics.debugPrint(150, y + 65 + mov_y, "Region: " .. big_tbl[i].region, white)
Graphics.debugPrint(150, y + 85 + mov_y, "Playtime: " .. big_tbl[i].ptime, white) Graphics.debugPrint(150, y + 85 + mov_y, "Playtime: " .. big_tbl[i].ptime, white)
local r_idx = i % #tbl local r_idx = i % #tbl
if r_idx == 0 then if r_idx == 0 then
r_idx = #tbl r_idx = #tbl
end end
Graphics.debugPrint(900, y + 85 + mov_y, "#" .. r_idx, white) Graphics.debugPrint(900, y + 85 + mov_y, "#" .. r_idx, white)
y = y + 132 y = y + 132
if real_i <= 0 then if real_i <= 0 then
i = real_i i = real_i
real_i = 1 real_i = 1
end end
i = i + 1 i = i + 1
end end
end end
-- Main loop -- Main loop
local f_idx = 1 local f_idx = 1
local oldpad = Controls.read() local oldpad = Controls.read()
while #tbl > 0 do while #tbl > 0 do
Graphics.initBlend() Graphics.initBlend()
Graphics.fillRect(0,960,0,544,colors[col_idx][2]) Graphics.fillRect(0,960,0,544,colors[col_idx][2])
wav:init() wav:init()
RenderList() RenderList()
if freeze then if freeze then
showAlarm("Do you want to delete this record permanently?", f_idx) showAlarm("Do you want to delete this record permanently?", f_idx)
end end
Graphics.termBlend() Graphics.termBlend()
Screen.flip() Screen.flip()
Screen.waitVblankStart() Screen.waitVblankStart()
local pad = Controls.read() local pad = Controls.read()
if Controls.check(pad, SCE_CTRL_UP) and mov_y == 0 then if Controls.check(pad, SCE_CTRL_UP) and mov_y == 0 then
if freeze then if freeze then
f_idx = 1 f_idx = 1
else else
new_list_idx = list_idx - 1 new_list_idx = list_idx - 1
if new_list_idx == 0 then if new_list_idx == 0 then
new_list_idx = #tbl new_list_idx = #tbl
end end
mov_y = 1 mov_y = 1
mov_step = 33 mov_step = 11
end end
elseif Controls.check(pad, SCE_CTRL_DOWN) and mov_y == 0 then elseif Controls.check(pad, SCE_CTRL_DOWN) and mov_y == 0 then
if freeze then if freeze then
f_idx = 2 f_idx = 2
else else
new_list_idx = list_idx + 1 new_list_idx = list_idx + 1
if new_list_idx > #tbl then if new_list_idx > #tbl then
new_list_idx = 1 new_list_idx = 1
end end
mov_y = -1 mov_y = -1
mov_step = -33 mov_step = -11
end end
elseif Controls.check(pad, SCE_CTRL_LTRIGGER) and not Controls.check(oldpad, SCE_CTRL_LTRIGGER) and not freeze then elseif Controls.check(pad, SCE_CTRL_LTRIGGER) and not Controls.check(oldpad, SCE_CTRL_LTRIGGER) and not freeze then
order_idx = order_idx - 1 order_idx = order_idx - 1
if order_idx == 0 then if order_idx == 0 then
order_idx = #orders order_idx = #orders
end end
list_idx = resortList(order_idx, list_idx) list_idx = resortList(order_idx, list_idx)
elseif Controls.check(pad, SCE_CTRL_RTRIGGER) and not Controls.check(oldpad, SCE_CTRL_RTRIGGER) and not freeze then elseif Controls.check(pad, SCE_CTRL_RTRIGGER) and not Controls.check(oldpad, SCE_CTRL_RTRIGGER) and not freeze then
order_idx = order_idx + 1 order_idx = order_idx + 1
if order_idx > #orders then if order_idx > #orders then
order_idx = 1 order_idx = 1
end end
list_idx = resortList(order_idx, list_idx) list_idx = resortList(order_idx, list_idx)
elseif Controls.check(pad, SCE_CTRL_TRIANGLE) and not Controls.check(oldpad, SCE_CTRL_TRIANGLE) and not freeze then elseif Controls.check(pad, SCE_CTRL_TRIANGLE) and not Controls.check(oldpad, SCE_CTRL_TRIANGLE) and not freeze then
freeze = true freeze = true
f_idx = 1 f_idx = 1
elseif Controls.check(pad, SCE_CTRL_CROSS) and not Controls.check(oldpad, SCE_CTRL_CROSS) and freeze then elseif Controls.check(pad, SCE_CTRL_CROSS) and not Controls.check(oldpad, SCE_CTRL_CROSS) and freeze then
freeze = false freeze = false
if f_idx == 1 then -- Delete if f_idx == 1 then -- Delete
System.deleteFile("ux0:/data/TrackPlug/" .. tbl[list_idx].name) System.deleteFile("ux0:/data/TrackPlug/" .. tbl[list_idx].name)
table.remove(tbl, list_idx) table.remove(tbl, list_idx)
if list_idx > #tbl then if list_idx > #tbl then
list_idx = list_idx - 1 list_idx = list_idx - 1
end end
end end
elseif Controls.check(pad, SCE_CTRL_SELECT) and not Controls.check(oldpad, SCE_CTRL_SELECT) then elseif Controls.check(pad, SCE_CTRL_SELECT) and not Controls.check(oldpad, SCE_CTRL_SELECT) then
col_idx = col_idx + 1 col_idx = col_idx + 1
if col_idx > #colors then if col_idx > #colors then
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 = System.openFile("ux0:/data/TrackPlug/config.lua", FCREATE) fd = System.openFile("ux0:/data/TrackPlug/config.lua", FCREATE)
System.writeFile(fd, "col_idx="..col_idx, 9) System.writeFile(fd, "col_idx="..col_idx, 9)
System.closeFile(fd) System.closeFile(fd)
end end
oldpad = pad oldpad = pad
end end
-- No games played yet apparently -- No games played yet apparently
while true do while true do
Graphics.initBlend() Graphics.initBlend()
Screen.clear() Screen.clear()
Graphics.debugPrint(5, 5, "No games tracked yet.", white) Graphics.debugPrint(5, 5, "No games tracked yet.", white)
Graphics.termBlend() Graphics.termBlend()
Screen.flip() Screen.flip()
Screen.waitVblankStart() Screen.waitVblankStart()
end end