Untitled diff

Created Diff never expires
local APP_DIR = "/Yuki FM"
local APP_THEME_DIR = APP_DIR.."/Themes"
local APP_CONFIG = APP_DIR.."/config.yuki"
local default_config = [[
LoadTheme("Path of Theme")
]]

local function defaultTheme()
rawset(_G, "bg", Graphics.convertFrom(Screen.createImage(1,1, Color.new(0,0,0))))
rawset(_G, "selected_item", Color.new(255,0,0))
rawset(_G, "menu_color", Color.new(255,255,255))
rawset(_G, "selected_color", Color.new(0,255,0))
end

update_bottom_screen = true
update_bottom_screen = true
System.setCpuSpeed(804)
System.setCpuSpeed(804)
Graphics.init()
Graphics.init()
function LoadTheme(theme)
function LoadTheme(theme)
old = System.currentDirectory()
old = System.currentDirectory()
System.currentDirectory(System.currentDirectory().."ORG_Themes/"..theme)
System.currentDirectory(APP_THEME_DIR.."/"..theme)
dofile(System.currentDirectory().."/theme.lua")
if System.doesFileExist(APP_THEME_DIR.."/"..theme.."/theme.lua") then
dofile(System.currentDirectory().."/theme.lua")
else
defaultTheme()
end
System.currentDirectory(old)
System.currentDirectory(old)
end
end
dofile(System.currentDirectory().."ORG_CONFIG.txt")
System.createDirectory(APP_DIR)
System.createDirectory(APP_THEME_DIR)
if not System.doesFileExist(APP_CONFIG) then
local f = io.open(APP_CONFIG, FCREATE)
io.write(f, 0, default_config, default_config:len())
io.close(f)
end
dofile(APP_CONFIG)
Sound.init()
Sound.init()
white = Color.new(255,255,255)
white = Color.new(255,255,255)
black = Color.new(0,0,0)
black = Color.new(0,0,0)
ctrlTimer = Timer.new()
ctrlTimer = Timer.new()
timeSlap = 200
timeSlap = 200
red = Color.new(255,0,0)
red = Color.new(255,0,0)
green = Color.new(0,255,0)
green = Color.new(0,255,0)
copy_or_move = false
copy_or_move = false
is_fullscreen = false
is_fullscreen = false
oldpad = Controls.read()
oldpad = Controls.read()
function TableConcat(t1,t2)
function TableConcat(t1,t2)
for i=1,#t2 do
for i=1,#t2 do
t1[#t1+1] = t2[i]
t1[#t1+1] = t2[i]
end
end
return t1
return t1
end
end
function SortDirectory(dir)
function SortDirectory(dir)
folders_table = {}
folders_table = {}
files_table = {}
files_table = {}
for i,file in pairs(dir) do
for i,file in pairs(dir) do
if file.directory then
if file.directory then
table.insert(folders_table,file)
table.insert(folders_table,file)
else
else
table.insert(files_table,file)
table.insert(files_table,file)
end
end
end
end
table.sort(files_table, function (a, b) return (a.name:lower() < b.name:lower() ) end)
table.sort(files_table, function (a, b) return (a.name:lower() < b.name:lower() ) end)
table.sort(folders_table, function (a, b) return (a.name:lower() < b.name:lower() ) end)
table.sort(folders_table, function (a, b) return (a.name:lower() < b.name:lower() ) end)
return_table = TableConcat(folders_table,files_table)
return_table = TableConcat(folders_table,files_table)
return return_table
return return_table
end
end
files_table = SortDirectory(System.listDirectory("/"))
files_table = SortDirectory(System.listDirectory("/"))
mode = "SDMC"
mode = "SDMC"
System.currentDirectory("/")
System.currentDirectory("/")
p = 1
p = 1
current_file = nil
current_file = nil
current_type = nil
current_type = nil
big_image = false
big_image = false
master_index = 0
master_index = 0
sm_index = 1
sm_index = 1
build = System.checkBuild()
build = System.checkBuild()
if build == 0 then
if build == 0 then
build = "NH1"
build = "NH1"
elseif build == 1 then
elseif build == 1 then
build = "CFW"
build = "CFW"
else
else
build = "NH2"
build = "NH2"
end
end
if build == "NH1" then
if build == "NH1" then
sm_voices = {"Video Player","Music Player","Image Viewer","Text Reader","Lua Interpreter","HEX Viewer","3DSX Launcher","CIA Installer","SMDH Decoder","ZIP Extractor","Info Viewer","Font Viewer","Cancel"}
sm_voices = {"Video Player","Music Player","Image Viewer","Text Reader","Lua Interpreter","HEX Viewer","3DSX Launcher","CIA Installer","SMDH Decoder","ZIP Extractor","Info Viewer","Font Viewer","Cancel"}
sm_funcs = {"JMPV","WAV","IMG","TXT","LUA","HEX","3DSX","CIA","SMDH","ZIP","INFO","TTF"}
sm_funcs = {"JMPV","WAV","IMG","TXT","LUA","HEX","3DSX","CIA","SMDH","ZIP","INFO","TTF"}
elseif build == "NH2" then
elseif build == "NH2" then
sm_voices = {"Video Player","Music Player","Image Viewer","Text Reader","Lua Interpreter","HEX Viewer","3DSX Launcher","SMDH Decoder","ZIP Extractor","Info Viewer","Font Viewer","Cancel"}
sm_voices = {"Video Player","Music Player","Image Viewer","Text Reader","Lua Interpreter","HEX Viewer","3DSX Launcher","SMDH Decoder","ZIP Extractor","Info Viewer","Font Viewer","Cancel"}
sm_funcs = {"JMPV","WAV","IMG","TXT","LUA","HEX","3DSX","SMDH","ZIP","INFO","TTF"}
sm_funcs = {"JMPV","WAV","IMG","TXT","LUA","HEX","3DSX","SMDH","ZIP","INFO","TTF"}
else
else
sm_voices = {"Video Player","Music Player","Image Viewer","Text Reader","Lua Interpreter","HEX Viewer","CIA Installer","SMDH Decoder","ZIP Extractor","Info Viewer","Font Viewer","Cancel"}
sm_voices = {"Video Player","Music Player","Image Viewer","Text Reader","Lua Interpreter","HEX Viewer","CIA Installer","SMDH Decoder","ZIP Extractor","Info Viewer","Font Viewer","Cancel"}
sm_funcs = {"JMPV","WAV","IMG","TXT","LUA","HEX","CIA","SMDH","ZIP","INFO","TTF"}
sm_funcs = {"JMPV","WAV","IMG","TXT","LUA","HEX","CIA","SMDH","ZIP","INFO","TTF"}
end
end
hex_values = {}
hex_values = {}
hex_text = {}
hex_text = {}
updateTXT = false
updateTXT = false
select_mode = false
select_mode = false
update_main_extdata = true
update_main_extdata = true
delete_mode = false
delete_mode = false
move_base = nil
move_base = nil
theme_name = "NONAME"
theme_name = "NONAME"
author = "NONAME"
author = "NONAME"
copy_base = nil
copy_base = nil
x_print = 0
x_print = 0
y_print = 0
y_print = 0
copy_type = 0
copy_type = 0
move_type = 0
move_type = 0
txt_index = 0
txt_index = 0
txt_words = 0
txt_words = 0
txt_i = 0
txt_i = 0
old_indexes = {}
old_indexes = {}
MAX_RAM_ALLOCATION = 10485760
MAX_RAM_ALLOCATION = 10485760
function FormatTime(seconds)
function FormatTime(seconds)
minute = math.floor(seconds/60)
minute = math.floor(seconds/60)
seconds = seconds%60
seconds = seconds%60
hours = math.floor(minute/60)
hours = math.floor(minute/60)
minute = minute%60
minute = minute%60
if minute < 10 then
if minute < 10 then
minute = "0"..minute
minute = "0"..minute
end
end
if seconds < 10 then
if seconds < 10 then
seconds = "0"..seconds
seconds = "0"..seconds
end
end
if hours == 0 then
if hours == 0 then
return minute..":"..seconds
return minute..":"..seconds
else
else
return hours..":"..minute..":"..seconds
return hours..":"..minute..":"..seconds
end
end
end
end
function DumpFile(input,archive)
function DumpFile(input,archive)
inp = io.open(extdata_directory..input,FREAD,archive)
inp = io.open(extdata_directory..input,FREAD,archive)
if System.doesFileExist("/"..input) then
if System.doesFileExist("/"..input) then
System.deleteFile("/"..input)
System.deleteFile("/"..input)
end
end
out = io.open("/"..string.format('%02X',archive).."_"..input,FCREATE)
out = io.open("/"..string.format('%02X',archive).."_"..input,FCREATE)
size = io.size(inp)
size = io.size(inp)
index = 0
index = 0
while (index+(MAX_RAM_ALLOCATION/2) < size) do
while (index+(MAX_RAM_ALLOCATION/2) < size) do
io.write(out,index,io.read(inp,index,MAX_RAM_ALLOCATION/2),(MAX_RAM_ALLOCATION/2))
io.write(out,index,io.read(inp,index,MAX_RAM_ALLOCATION/2),(MAX_RAM_ALLOCATION/2))
index = index + (MAX_RAM_ALLOCATION/2)
index = index + (MAX_RAM_ALLOCATION/2)
end
end
if index < size then
if index < size then
io.write(out,index,io.read(inp,index,size-index),(size-index))
io.write(out,index,io.read(inp,index,size-index),(size-index))
end
end
io.close(inp)
io.close(inp)
io.close(out)
io.close(out)
end
end
function RestoreFile(input,archive)
function RestoreFile(input,archive)
inp = io.open("/"..string.format('%02X',archive).."_"..input,FREAD)
inp = io.open("/"..string.format('%02X',archive).."_"..input,FREAD)
out = io.open(extdata_directory..input,FWRITE,archive)
out = io.open(extdata_directory..input,FWRITE,archive)
if io.size(inp) <= io.size(out) then
if io.size(inp) <= io.size(out) then
size = io.size(inp)
size = io.size(inp)
index = 0
index = 0
while (index+(MAX_RAM_ALLOCATION/2) < size) do
while (index+(MAX_RAM_ALLOCATION/2) < size) do
io.write(out,index,io.read(inp,index,MAX_RAM_ALLOCATION/2),(MAX_RAM_ALLOCATION/2))
io.write(out,index,io.read(inp,index,MAX_RAM_ALLOCATION/2),(MAX_RAM_ALLOCATION/2))
index = index + (MAX_RAM_ALLOCATION/2)
index = index + (MAX_RAM_ALLOCATION/2)
end
end
if index < size then
if index < size then
io.write(out,index,io.read(inp,index,size-index),(size-index))
io.write(out,index,io.read(inp,index,size-index),(size-index))
end
end
end
end
io.close(inp)
io.close(inp)
io.close(out)
io.close(out)
end
end
function RestoreFolder(input,archive)
function RestoreFolder(input,archive)
files = System.listDirectory("/"..string.format('%02X',archive).."_"..input)
files = System.listDirectory("/"..string.format('%02X',archive).."_"..input)
for z, file in pairs(files) do
for z, file in pairs(files) do
if (file.directory) then
if (file.directory) then
RestoreFolder(input.."/"..file.name,archive)
RestoreFolder(input.."/"..file.name,archive)
else
else
RestoreFile(input.."/"..file.name,archive)
RestoreFile(input.."/"..file.name,archive)
end
end
end
end
end
end
function DumpFolder(input,archive)
function DumpFolder(input,archive)
files = System.listExtdataDir(extdata_directory..input,archive)
files = System.listExtdataDir(extdata_directory..input,archive)
System.createDirectory("/"..string.format('%02X',archive).."_"..input)
System.createDirectory("/"..string.format('%02X',archive).."_"..input)
for z, file in pairs(files) do
for z, file in pairs(files) do
if (file.directory) then
if (file.directory) then
DumpFolder(input.."/"..file.name,archive)
DumpFolder(input.."/"..file.name,archive)
else
else
DumpFile(input.."/"..file.name,archive)
DumpFile(input.."/"..file.name,archive)
end
end
end
end
end
end
function CopyFile(input,output)
function CopyFile(input,output)
inp = io.open(input,FREAD)
inp = io.open(input,FREAD)
if System.doesFileExist(output) then
if System.doesFileExist(output) then
System.deleteFile(output)
System.deleteFile(output)
end
end
out = io.open(output,FCREATE)
out = io.open(output,FCREATE)
size = io.size(inp)
size = io.size(inp)
index = 0
index = 0
while (index+(MAX_RAM_ALLOCATION/2) < size) do
while (index+(MAX_RAM_ALLOCATION/2) < size) do
io.write(out,index,io.read(inp,index,MAX_RAM_ALLOCATION/2),(MAX_RAM_ALLOCATION/2))
io.write(out,index,io.read(inp,index,MAX_RAM_ALLOCATION/2),(MAX_RAM_ALLOCATION/2))
index = index + (MAX_RAM_ALLOCATION/2)
index = index + (MAX_RAM_ALLOCATION/2)
end
end
if index < size then
if index < size then
io.write(out,index,io.read(inp,index,size-index),(size-index))
io.write(out,index,io.read(inp,index,size-index),(size-index))
end
end
io.close(inp)
io.close(inp)
io.close(out)
io.close(out)
end
end
function CopyDir(input,output)
function CopyDir(input,output)
files = System.listDirectory(input)
files = System.listDirectory(input)
System.createDirectory(output)
System.createDirectory(output)
for z, file in pairs(files) do
for z, file in pairs(files) do
if (file.directory) then
if (file.directory) then
CopyDir(input.."/"..file.name,output.."/"..file.name)
CopyDir(input.."/"..file.name,output.."/"..file.name)
else
else
CopyFile(input.."/"..file.name,output.."/"..file.name)
CopyFile(input.."/"..file.name,output.."/"..file.name)
end
end
end
end
end
end
function OpenExtdataFile(text, archive)
function OpenExtdataFile(text, archive)
GarbageCollection()
GarbageCollection()
current_file = io.open(extdata_directory..text,FREAD,archive)
current_file = io.open(extdata_directory..text,FREAD,archive)
current_type = "HEX"
current_type = "HEX"
txt_index = 0
txt_index = 0
updateTXT = true
updateTXT = true
end
end
function ForceOpenFile(text, size, mode)
function ForceOpenFile(text, size, mode)
if mode == "SMDH" then
if mode == "SMDH" then
GarbageCollection()
GarbageCollection()
current_type = "SMDH"
current_type = "SMDH"
current_file = System.extractSMDH(System.currentDirectory()..text)
current_file = System.extractSMDH(System.currentDirectory()..text)
smdh_show = Console.new(TOP_SCREEN)
smdh_show = Console.new(TOP_SCREEN)
Console.append(smdh_show,"Title: "..current_file.title.."\n\n")
Console.append(smdh_show,"Title: "..current_file.title.."\n\n")
Console.append(smdh_show,"Description: "..current_file.desc.."\n\n")
Console.append(smdh_show,"Description: "..current_file.desc.."\n\n")
Console.append(smdh_show,"Author: "..current_file.author)
Console.append(smdh_show,"Author: "..current_file.author)
elseif mode == "3DSX" and not build == "CFW" then
elseif mode == "3DSX" and not build == "CFW" then
GarbageCollection()
GarbageCollection()
Graphics.freeImage(bg)
Graphics.freeImage(bg)
Sound.term()
Sound.term()
System.launch(System.currentDirectory()..text)
System.launch(System.currentDirectory()..text)
elseif mode == "JPGV" then
elseif mode == "JPGV" then
GarbageCollection()
GarbageCollection()
current_file = JPGV.load(System.currentDirectory()..text)
current_file = JPGV.load(System.currentDirectory()..text)
current_type = "JPGV"
current_type = "JPGV"
JPGV.start(current_file,NO_LOOP)
JPGV.start(current_file,NO_LOOP)
elseif mode == "WAV" then
elseif mode == "WAV" then
GarbageCollection()
GarbageCollection()
current_file = io.open(System.currentDirectory()..text,FREAD)
current_file = io.open(System.currentDirectory()..text,FREAD)
magic = io.read(current_file,8,4)
magic = io.read(current_file,8,4)
io.close(current_file)
io.close(current_file)
if magic == "AIFF" then
if magic == "AIFF" then
current_file = Sound.openAiff(System.currentDirectory()..text, true)
current_file = Sound.openAiff(System.currentDirectory()..text, true)
current_type = "WAV"
current_type = "WAV"
Sound.play(current_file,NO_LOOP)
Sound.play(current_file,NO_LOOP)
elseif magic == "RIFF" then
elseif magic == "RIFF" then
current_file = Sound.openWav(System.currentDirectory()..text, true)
current_file = Sound.openWav(System.currentDirectory()..text, true)
current_type = "WAV"
current_type = "WAV"
Sound.play(current_file,NO_LOOP)
Sound.play(current_file,NO_LOOP)
else
else
current_file = Sound.openOgg(System.currentDirectory()..text, true)
current_file = Sound.openOgg(System.currentDirectory()..text, true)
current_type = "WAV"
current_type = "WAV"
Sound.play(current_file,NO_LOOP)
Sound.play(current_file,NO_LOOP)
end
end
elseif mode == "IMG" then
elseif mode == "IMG" then
GarbageCollection()
GarbageCollection()
current_type = "IMG"
current_type = "IMG"
current_file = Graphics.loadImage(System.currentDirectory()..text)
current_file = Graphics.loadImage(System.currentDirectory()..text)
width = Graphics.getImageWidth(current_file)
width = Graphics.getImageWidth(current_file)
height = Graphics.getImageHeight(current_file)
height = Graphics.getImageHeight(current_file)
if Graphics.getImageWidth(current_file) > 400 then
if Graphics.getImageWidth(current_file) > 400 then
width = 400
width = 400
big_image = true
big_image = true
end
end
if Graphics.getImageHeight(current_file) > 240 then
if Graphics.getImageHeight(current_file) > 240 then
height = 240
height = 240
big_image = true
big_image = true
end
end
elseif mode == "LUA" then
elseif mode == "LUA" then
GarbageCollection()
GarbageCollection()
Graphics.freeImage(bg)
Graphics.freeImage(bg)
Sound.term()
Sound.term()
reset_dir = System.currentDirectory()
reset_dir = System.currentDirectory()
System.currentDirectory(string.sub(System.currentDirectory(),1,-2))
System.currentDirectory(string.sub(System.currentDirectory(),1,-2))
dofile(System.currentDirectory().."/"..text)
dofile(System.currentDirectory().."/"..text)
System.currentDirectory(reset_dir)
System.currentDirectory(reset_dir)
current_type = "LUA"
current_type = "LUA"
Sound.init()
Sound.init()
elseif mode == "TXT" then
elseif mode == "TXT" then
GarbageCollection()
GarbageCollection()
current_file = io.open(System.currentDirectory()..text,FREAD)
current_file = io.open(System.currentDirectory()..text,FREAD)
text_console = Console.new(TOP_SCREEN)
text_console = Console.new(TOP_SCREEN)
current_type = "TXT"
current_type = "TXT"
txt_index = 0
txt_index = 0
txt_words = 0
txt_words = 0
updateTXT = true
updateTXT = true
elseif mode == "HEX" then
elseif mode == "HEX" then
GarbageCollection()
GarbageCollection()
current_file = io.open(System.currentDirectory()..text,FREAD)
current_file = io.open(System.currentDirectory()..text,FREAD)
current_type = "HEX"
current_type = "HEX"
txt_index = 0
txt_index = 0
updateTXT = true
updateTXT = true
elseif mode == "INFO" then
elseif mode == "INFO" then
GarbageCollection()
GarbageCollection()
current_file = io.open(System.currentDirectory()..text,FREAD)
current_file = io.open(System.currentDirectory()..text,FREAD)
current_type = "INFO"
current_type = "INFO"
f_size = io.size(current_file)
f_size = io.size(current_file)
f = "Bytes"
f = "Bytes"
if (f_size > 1024) then
if (f_size > 1024) then
f_size = f_size / 1024
f_size = f_size / 1024
f = "KBs"
f = "KBs"
end
end
if (f_size > 1024) then
if (f_size > 1024) then
f_size = f_size / 1024
f_size = f_size / 1024
f = "MBs"
f = "MBs"
end
end
io.close(current_file)
io.close(current_file)
text_console = Console.new(TOP_SCREEN)
text_console = Console.new(TOP_SCREEN)
Console.append(text_console,"Filename: "..text.."\n")
Console.append(text_console,"Filename: "..text.."\n")
i = -1
i = -1
while string.sub(text,i,i) ~= "." do
while string.sub(text,i,i) ~= "." do
i = i - 1
i = i - 1
end
end
i = i + 1
i = i + 1
Console.append(text_console,"Format: "..string.upper(string.sub(text,i)).."\n")
Console.append(text_console,"Format: "..string.upper(string.sub(text,i)).."\n")
Console.append(text_console,"Size: "..f_size.." "..f.."\n")
Console.append(text_console,"Size: "..f_size.." "..f.."\n")
elseif mode == "ZIP" then
elseif mode == "ZIP" then
GarbageCollection()
GarbageCollection()
pass = System.startKeyboard("")
pass = System.startKeyboard("")
System.extractZIP(System.currentDirectory()..text,System.currentDirectory()..string.sub(text,1,-5),pass)
System.extractZIP(System.currentDirectory()..text,System.currentDirectory()..string.sub(text,1,-5),pass)
files_table = System.listDirectory(System.currentDirectory())
files_table = System.listDirectory(System.currentDirectory())
if System.currentDirectory() ~= "/" then
if System.currentDirectory() ~= "/" then
local extra = {}
local extra = {}
extra.name = ".."
extra.name = ".."
extra.size = 0
extra.size = 0
extra.directory = true
extra.directory = true
table.insert(files_table,extra)
table.insert(files_table,extra)
end
end
files_table = SortDirectory(files_table)
files_table = SortDirectory(files_table)
elseif mode == "TTF" then
elseif mode == "TTF" then
GarbageCollection()
GarbageCollection()
current_file = Font.load(System.currentDirectory()..text)
current_file = Font.load(System.currentDirectory()..text)
current_type = "TTF"
current_type = "TTF"
elseif mode == "CIA" then
elseif mode == "CIA" then
GarbageCollection()
GarbageCollection()
sm_index = 1
sm_index = 1
cia_data = System.extractCIA(System.currentDirectory()..text)
cia_data = System.extractCIA(System.currentDirectory()..text)
oldpad = KEY_A
oldpad = KEY_A
while true do
while true do
Screen.refresh()
Screen.refresh()
Screen.waitVblankStart()
Screen.waitVblankStart()
Screen.clear(TOP_SCREEN)
Screen.clear(TOP_SCREEN)
Screen.debugPrint(0,0,"Title: "..cia_data.title,white,TOP_SCREEN)
Screen.debugPrint(0,0,"Title: "..cia_data.title,white,TOP_SCREEN)
Screen.debugPrint(0,15,"Unique ID: 0x"..string.sub(string.format('%02X',cia_data.unique_id),1,-3),white,TOP_SCREEN)
Screen.debugPrint(0,15,"Unique ID: 0x"..string.sub(string.format('%02X',cia_data.unique_id),1,-3),white,TOP_SCREEN)
Screen.debugPrint(0,30,"Size to install: "..cia_data.install_size,white,TOP_SCREEN)
Screen.debugPrint(0,30,"Size to install: "..cia_data.install_size,white,TOP_SCREEN)
Screen.debugPrint(0,45,"Version: "..cia_data.version,white,TOP_SCREEN)
Screen.debugPrint(0,45,"Version: "..cia_data.version,white,TOP_SCREEN)
if not cia_data.icon == nil then
if not cia_data.icon == nil then
Screen.debugPrint(0,30,"Name: "..cia_data.name,white,TOP_SCREEN)
Screen.debugPrint(0,30,"Name: "..cia_data.name,white,TOP_SCREEN)
Screen.debugPrint(0,45,"Author: "..cia_data.author,white,TOP_SCREEN)
Screen.debugPrint(0,45,"Author: "..cia_data.author,white,TOP_SCREEN)
Screen.debugPrint(0,60,"Desc: "..cia_data.desc,white,TOP_SCREEN)
Screen.debugPrint(0,60,"Desc: "..cia_data.desc,white,TOP_SCREEN)
Screen.drawImage(5, 85, cia_data.icon, TOP_SCREEN)
Screen.drawImage(5, 85, cia_data.icon, TOP_SCREEN)
end
end
pad = Controls.read()
pad = Controls.read()
Screen.fillEmptyRect(60,260,50,95,black,BOTTOM_SCREEN)
Screen.fillEmptyRect(60,260,50,95,black,BOTTOM_SCREEN)
Screen.fillRect(61,259,51,96,white,BOTTOM_SCREEN)
Screen.fillRect(61,259,51,96,white,BOTTOM_SCREEN)
if (sm_index == 1) then
if (sm_index == 1) then
Screen.fillRect(61,259,51,66,green,BOTTOM_SCREEN)
Screen.fillRect(61,259,51,66,green,BOTTOM_SCREEN)
Screen.debugPrint(63,53,"Install to SDMC",red,BOTTOM_SCREEN)
Screen.debugPrint(63,53,"Install to SDMC",red,BOTTOM_SCREEN)
Screen.debugPrint(63,68,"Install to NAND",black,BOTTOM_SCREEN)
Screen.debugPrint(63,68,"Install to NAND",black,BOTTOM_SCREEN)
Screen.debugPrint(63,83,"Cancel",black,BOTTOM_SCREEN)
Screen.debugPrint(63,83,"Cancel",black,BOTTOM_SCREEN)
if (Controls.check(pad,KEY_DDOWN)) and not (Controls.check(oldpad,KEY_DDOWN)) then
if (Controls.check(pad,KEY_DDOWN)) and not (Controls.check(oldpad,KEY_DDOWN)) then
sm_index = 2
sm_index = 2
elseif (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) then
elseif (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) then
System.installCIA(System.currentDirectory()..text, SDMC)
System.installCIA(System.currentDirectory()..text, SDMC)
break
break
end
end
elseif (sm_index == 2) then
elseif (sm_index == 2) then
Screen.fillRect(61,259,66,81,green,BOTTOM_SCREEN)
Screen.fillRect(61,259,66,81,green,BOTTOM_SCREEN)
Screen.debugPrint(63,53,"Install to SDMC",black,BOTTOM_SCREEN)
Screen.debugPrint(63,53,"Install to SDMC",black,BOTTOM_SCREEN)
Screen.debugPrint(63,68,"Install to NAND",red,BOTTOM_SCREEN)
Screen.debugPrint(63,68,"Install to NAND",red,BOTTOM_SCREEN)
Screen.debugPrint(63,83,"Cancel",black,BOTTOM_SCREEN)
Screen.debugPrint(63,83,"Cancel",black,BOTTOM_SCREEN)
if (Controls.check(pad,KEY_DDOWN)) and not (Controls.check(oldpad,KEY_DDOWN)) then
if (Controls.check(pad,KEY_DDOWN)) and not (Controls.check(oldpad,KEY_DDOWN)) then
sm_index = 3
sm_index = 3
elseif (Controls.check(pad,KEY_DUP)) and not (Controls.check(oldpad,KEY_DUP)) then
elseif (Controls.check(pad,KEY_DUP)) and not (Controls.check(oldpad,KEY_DUP)) then
sm_index = 1
sm_index = 1
elseif (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) then
elseif (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) then
System.installCIA(System.currentDirectory()..text, NAND)
System.installCIA(System.currentDirectory()..text, NAND)
break
break
end
end
else
else
Screen.fillRect(61,259,81,96,green,BOTTOM_SCREEN)
Screen.fillRect(61,259,81,96,green,BOTTOM_SCREEN)
Screen.debugPrint(63,53,"Install to SDMC",black,BOTTOM_SCREEN)
Screen.debugPrint(63,53,"Install to SDMC",black,BOTTOM_SCREEN)
Screen.debugPrint(63,68,"Install to NAND",black,BOTTOM_SCREEN)
Screen.debugPrint(63,68,"Install to NAND",black,BOTTOM_SCREEN)
Screen.debugPrint(63,83,"Cancel",red,BOTTOM_SCREEN)
Screen.debugPrint(63,83,"Cancel",red,BOTTOM_SCREEN)
if (Controls.check(pad,KEY_DUP)) and not (Controls.check(oldpad,KEY_DUP)) then
if (Controls.check(pad,KEY_DUP)) and not (Controls.check(oldpad,KEY_DUP)) then
sm_index = 2
sm_index = 2
elseif (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) then
elseif (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) then
break
break
end
end
end
end
oldpad = pad
oldpad = pad
Screen.flip()
Screen.flip()
end
end
update_bottom_screen = true
update_bottom_screen = true
end
end
end
end
function DeleteDir(dir)
function DeleteDir(dir)
files = System.listDirectory(dir)
files = System.listDirectory(dir)
for z, file in pairs(files) do
for z, file in pairs(files) do
if (file.directory) then
if (file.directory) then
DeleteDir(dir.."/"..file.name)
DeleteDir(dir.."/"..file.name)
else
else
System.deleteFile(dir.."/"..file.name)
System.deleteFile(dir.."/"..file.name)
end
end
end
end
System.deleteDirectory(dir)
System.deleteDirectory(dir)
end
end
function OpenFile(text, size)
function OpenFile(text, size)
if string.upper(string.sub(text,-5)) == ".SMDH" then
if string.upper(string.sub(text,-5)) == ".SMDH" then
GarbageCollection()
GarbageCollection()
current_type = "SMDH"
current_type = "SMDH"
current_file = System.extractSMDH(System.currentDirectory()..text)
current_file = System.extractSMDH(System.currentDirectory()..text)
smdh_show = Console.new(TOP_SCREEN)
smdh_show = Console.new(TOP_SCREEN)
Console.append(smdh_show,"Title: "..current_file.title.."\n\n")
Console.append(smdh_show,"Title: "..current_file.title.."\n\n")
Console.append(smdh_show,"Description: "..current_file.desc.."\n\n")
Console.append(smdh_show,"Description: "..current_file.desc.."\n\n")
Console.append(smdh_show,"Author: "..current_file.author)
Console.append(smdh_show,"Author: "..current_file.author)
elseif string.upper(string.sub(text,-4)) == ".ZIP" then
elseif string.upper(string.sub(text,-4)) == ".ZIP" then
GarbageCollection()
GarbageCollection()
pass = System.startKeyboard("PASSWORD")
pass = System.startKeyboard("PASSWORD")
System.extractZIP(System.currentDirectory()..text,System.currentDirectory()..string.sub(text,1,-5),pass)
System.extractZIP(System.currentDirectory()..text,System.currentDirectory()..string.sub(text,1,-5),pass)
files_table = System.listDirectory(System.currentDirectory())
files_table = System.listDirectory(System.currentDirectory())
if System.currentDirectory() ~= "/" then
if System.currentDirectory() ~= "/" then
local extra = {}
local extra = {}
extra.name = ".."
extra.name = ".."
extra.size = 0
extra.size = 0
extra.directory = true
extra.directory = true
table.insert(files_table,extra)
table.insert(files_table,extra)
end
end
files_table = SortDirectory(files_table)
files_table = SortDirectory(files_table)
elseif (string.upper(string.sub(text,-5)) == ".3DSX") and not build == "CFW" then
elseif (string.upper(string.sub(text,-5)) == ".3DSX") and not build == "CFW" then
GarbageCollection()
GarbageCollection()
Graphics.freeImage(bg)
Graphics.freeImage(bg)
Sound.term()
Sound.term()
Graphics.term()
Graphics.term()
System.launch(System.currentDirectory()..text)
System.launch(System.currentDirectory()..text)
elseif string.upper(string.sub(text,-5)) == ".JPGV" then
elseif string.upper(string.sub(text,-5)) == ".JPGV" then
GarbageCollection()
GarbageCollection()
current_file = JPGV.load(System.currentDirectory()..text)
current_file = JPGV.load(System.currentDirectory()..text)
current_type = "JPGV"
current_type = "JPGV"
JPGV.start(current_file,NO_LOOP)
JPGV.start(current_file,NO_LOOP)
elseif string.upper(string.sub(text,-4)) == ".TTF" then
elseif string.upper(string.sub(text,-4)) == ".TTF" then
GarbageCollection()
GarbageCollection()
current_file = Font.load(System.currentDirectory()..text)
current_file = Font.load(System.currentDirectory()..text)
current_type = "TTF"
current_type = "TTF"
elseif string.upper(string.sub(text,-4)) == ".WAV" then
elseif string.upper(string.sub(text,-4)) == ".WAV" then
GarbageCollection()
GarbageCollection()
current_file = Sound.openWav(System.currentDirectory()..text, true)
current_file = Sound.openWav(System.currentDirectory()..text, true)
current_type = "WAV"
current_type = "WAV"
Sound.play(current_file,NO_LOOP)
Sound.play(current_file,NO_LOOP)
elseif string.upper(string.sub(text,-4)) == ".OGG" then
elseif string.upper(string.sub(text,-4)) == ".OGG" then
GarbageCollection()
GarbageCollection()
current_file = Sound.openOgg(System.currentDirectory()..text,true)
current_file = Sound.openOgg(System.currentDirectory()..text,true)
current_type = "WAV"
current_type = "WAV"
Sound.play(current_file,NO_LOOP)
Sound.play(current_file,NO_LOOP)
elseif string.upper(string.sub(text,-4)) == ".AIF" or string.upper(string.sub(text,-5)) == ".AIFF" then
elseif string.upper(string.sub(text,-4)) == ".AIF" or string.upper(string.sub(text,-5)) == ".AIFF" then
GarbageCollection()
GarbageCollection()
current_file = Sound.openAiff(System.currentDirectory()..text, true)
current_file = Sound.openAiff(System.currentDirectory()..text, true)
current_type = "WAV"
current_type = "WAV"
Sound.play(current_file,NO_LOOP)
Sound.play(current_file,NO_LOOP)
elseif string.upper(string.sub(text,-4)) == ".PNG" or string.upper(string.sub(text,-4)) == ".BMP" or string.upper(string.sub(text,-4)) == ".JPG" then
elseif string.upper(string.sub(text,-4)) == ".PNG" or string.upper(string.sub(text,-4)) == ".BMP" or string.upper(string.sub(text,-4)) == ".JPG" then
GarbageCollection()
GarbageCollection()
current_type = "IMG"
current_type = "IMG"
current_file = Graphics.loadImage(System.currentDirectory()..text)
current_file = Graphics.loadImage(System.currentDirectory()..text)
width = Graphics.getImageWidth(current_file)
width = Graphics.getImageWidth(current_file)
height = Graphics.getImageHeight(current_file)
height = Graphics.getImageHeight(current_file)
if width > 400 then
if width > 400 then
width = 400
width = 400
big_image = true
big_image = true
end
end
if height > 240 then
if height > 240 then
height = 240
height = 240
big_image = true
big_image = true
end
end
elseif string.sub(text,-4) == ".lua" or string.sub(text,-4) == ".LUA" then
elseif string.sub(text,-4) == ".lua" or string.sub(text,-4) == ".LUA" then
GarbageCollection()
GarbageCollection()
Graphics.freeImage(bg)
Graphics.freeImage(bg)
Sound.term()
Sound.term()
reset_dir = System.currentDirectory()
reset_dir = System.currentDirectory()
System.currentDirectory(string.sub(System.currentDirectory(),1,-2))
System.currentDirectory(string.sub(System.currentDirectory(),1,-2))
dofile(System.currentDirectory().."/"..text)
dofile(System.currentDirectory().."/"..text)
System.currentDirectory(reset_dir)
System.currentDirectory(reset_dir)
current_type = "LUA"
current_type = "LUA"
Sound.init()
Sound.init()
elseif string.sub(text,-4) == ".txt" or string.sub(text,-4) == ".TXT" then
elseif string.sub(text,-4) == ".txt" or string.sub(text,-4) == ".TXT" then
GarbageCollection()
GarbageCollection()
current_file = io.open(System.currentDirectory()..text,FREAD)
current_file = io.open(System.currentDirectory()..text,FREAD)
text_console = Console.new(TOP_SCREEN)
text_console = Console.new(TOP_SCREEN)
current_type = "TXT"
current_type = "TXT"
txt_index = 0
txt_index = 0
txt_words = 0
txt_words = 0
updateTXT = true
updateTXT = true
elseif string.upper(string.sub(text,-4)) == ".CIA" and build ~= "NH2" then
elseif string.upper(string.sub(text,-4)) == ".CIA" and build ~= "NH2" then
GarbageCollection()
GarbageCollection()
sm_index = 1
sm_index = 1
cia_data = System.extractCIA(System.currentDirectory()..text)
cia_data = System.extractCIA(System.currentDirectory()..text)
oldpad = KEY_A
oldpad = KEY_A
while true do
while true do
Screen.refresh()
Screen.refresh()
Screen.waitVblankStart()
Screen.waitVblankStart()
Screen.clear(TOP_SCREEN)
Screen.clear(TOP_SCREEN)
Screen.debugPrint(0,0,"Title: "..cia_data.title,white,TOP_SCREEN)
Screen.debugPrint(0,0,"Title: "..cia_data.title,white,TOP_SCREEN)
Screen.debugPrint(0,15,"Unique ID: 0x"..string.sub(string.format('%02X',cia_data.unique_id),1,-3),white,TOP_SCREEN)
Screen.debugPrint(0,15,"Unique ID: 0x"..string.sub(string.format('%02X',cia_data.unique_id),1,-3),white,TOP_SCREEN)
Screen.debugPrint(0,30,"Size to install: "..cia_data.install_size,white,TOP_SCREEN)
Screen.debugPrint(0,30,"Size to install: "..cia_data.install_size,white,TOP_SCREEN)
Screen.debugPrint(0,45,"Version: "..cia_data.version,white,TOP_SCREEN)
Screen.debugPrint(0,45,"Version: "..cia_data.version,white,TOP_SCREEN)
if not cia_data.icon == nil then
if not cia_data.icon == nil then
Screen.debugPrint(0,30,"Name: "..cia_data.name,white,TOP_SCREEN)
Screen.debugPrint(0,30,"Name: "..cia_data.name,white,TOP_SCREEN)
Screen.debugPrint(0,45,"Author: "..cia_data.author,white,TOP_SCREEN)
Screen.debugPrint(0,45,"Author: "..cia_data.author,white,TOP_SCREEN)
Screen.debugPrint(0,60,"Desc: "..cia_data.desc,white,TOP_SCREEN)
Screen.debugPrint(0,60,"Desc: "..cia_data.desc,white,TOP_SCREEN)
Screen.drawImage(5, 85, cia_data.icon, TOP_SCREEN)
Screen.drawImage(5, 85, cia_data.icon, TOP_SCREEN)
end
end
pad = Controls.read()
pad = Controls.read()
Screen.fillEmptyRect(60,260,50,82,black,BOTTOM_SCREEN)
Screen.fillEmptyRect(60,260,50,82,black,BOTTOM_SCREEN)
Screen.fillRect(61,259,51,81,white,BOTTOM_SCREEN)
Screen.fillRect(61,259,51,81,white,BOTTOM_SCREEN)
if (sm_index == 1) then
if (sm_index == 1) then
Screen.fillRect(61,259,51,66,green,BOTTOM_SCREEN)
Screen.fillRect(61,259,51,66,green,BOTTOM_SCREEN)
Screen.debugPrint(63,53,"Install to SDMC",red,BOTTOM_SCREEN)
Screen.debugPrint(63,53,"Install to SDMC",red,BOTTOM_SCREEN)
Screen.debugPrint(63,68,"Install to NAND",black,BOTTOM_SCREEN)
Screen.debugPrint(63,68,"Install to NAND",black,BOTTOM_SCREEN)
Screen.debugPrint(63,83,"Cancel",black,BOTTOM_SCREEN)
Screen.debugPrint(63,83,"Cancel",black,BOTTOM_SCREEN)
if (Controls.check(pad,KEY_DDOWN)) and not (Controls.check(oldpad,KEY_DDOWN)) then
if (Controls.check(pad,KEY_DDOWN)) and not (Controls.check(oldpad,KEY_DDOWN)) then
sm_index = 2
sm_index = 2
elseif (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) then
elseif (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) then
System.installCIA(System.currentDirectory()..text, SDMC)
System.installCIA(System.currentDirectory()..text, SDMC)
break
break
end
end
elseif (sm_index == 2) then
elseif (sm_index == 2) then
Screen.fillRect(61,259,66,81,green,BOTTOM_SCREEN)
Screen.fillRect(61,259,66,81,green,BOTTOM_SCREEN)
Screen.debugPrint(63,53,"Install to SDMC",black,BOTTOM_SCREEN)
Screen.debugPrint(63,53,"Install to SDMC",black,BOTTOM_SCREEN)
Screen.debugPrint(63,68,"Install to NAND",red,BOTTOM_SCREEN)
Screen.debugPrint(63,68,"Install to NAND",red,BOTTOM_SCREEN)
Screen.debugPrint(63,83,"Cancel",black,BOTTOM_SCREEN)
Screen.debugPrint(63,83,"Cancel",black,BOTTOM_SCREEN)
if (Controls.check(pad,KEY_DDOWN)) and not (Controls.check(oldpad,KEY_DDOWN)) then
if (Controls.check(pad,KEY_DDOWN)) and not (Controls.check(oldpad,KEY_DDOWN)) then
sm_index = 3
sm_index = 3
elseif (Controls.check(pad,KEY_DUP)) and not (Controls.check(oldpad,KEY_DUP)) then
elseif (Controls.check(pad,KEY_DUP)) and not (Controls.check(oldpad,KEY_DUP)) then
sm_index = 1
sm_index = 1
elseif (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) then
elseif (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) then
System.installCIA(System.currentDirectory()..text, NAND)
System.installCIA(System.currentDirectory()..text, NAND)
break
break
end
end
else
else
Screen.fillRect(61,259,81,96,green,BOTTOM_SCREEN)
Screen.fillRect(61,259,81,96,green,BOTTOM_SCREEN)
Screen.debugPrint(63,53,"Install to SDMC",black,BOTTOM_SCREEN)
Screen.debugPrint(63,53,"Install to SDMC",black,BOTTOM_SCREEN)
Screen.debugPrint(63,68,"Install to NAND",black,BOTTOM_SCREEN)
Screen.debugPrint(63,68,"Install to NAND",black,BOTTOM_SCREEN)
Screen.debugPrint(63,83,"Cancel",red,BOTTOM_SCREEN)
Screen.debugPrint(63,83,"Cancel",red,BOTTOM_SCREEN)
if (Controls.check(pad,KEY_DUP)) and not (Controls.check(oldpad,KEY_DUP)) then
if (Controls.check(pad,KEY_DUP)) and not (Controls.check(oldpad,KEY_DUP)) then
sm_index = 2
sm_index = 2
elseif (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) then
elseif (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) then
break
break
end
end
end
end
oldpad = pad
oldpad = pad
Screen.flip()
Screen.flip()
end
end
update_bottom_screen = true
update_bottom_screen = true
end
end
end
end
function OpenDirectory(text,archive_id)
function OpenDirectory(text,archive_id)
i=0
i=0
if mode == "SDMC" then
if mode == "SDMC" then
if text == ".." then
if text == ".." then
j=-2
j=-2
while string.sub(System.currentDirectory(),j,j) ~= "/" do
while string.sub(System.currentDirectory(),j,j) ~= "/" do
j=j-1
j=j-1
end
end
System.currentDirectory(string.sub(System.currentDirectory(),1,j))
System.currentDirectory(string.sub(System.currentDirectory(),1,j))
else
else
System.currentDirectory(System.currentDirectory()..text.."/")
System.currentDirectory(System.currentDirectory()..text.."/")
end
end
else
else
if text == ".." then
if text == ".." then
j=-2
j=-2
while string.sub(extdata_directory,j,j) ~= "/" do
while string.sub(extdata_directory,j,j) ~= "/" do
j=j-1
j=j-1
end
end
extdata_directory = string.sub(extdata_directory,1,j)
extdata_directory = string.sub(extdata_directory,1,j)
else
else
extdata_directory = extdata_directory..text.."/"
extdata_directory = extdata_directory..text.."/"
end
end
end
end
if mode == "SDMC" then
if mode == "SDMC" then
files_table = System.listDirectory(System.currentDirectory())
files_table = System.listDirectory(System.currentDirectory())
if System.currentDirectory() ~= "/" then
if System.currentDirectory() ~= "/" then
local extra = {}
local extra = {}
extra.name = ".."
extra.name = ".."
extra.size = 0
extra.size = 0
extra.directory = true
extra.directory = true
table.insert(files_table,extra)
table.insert(files_table,extra)
end
end
files_table = SortDirectory(files_table)
files_table = SortDirectory(files_table)
else
else
if extdata_directory == "/" then
if extdata_directory == "/" then
files_table = extdata_backup
files_table = extdata_backup
else
else
files_table = System.listExtdataDir(extdata_directory,archive_id)
files_table = System.listExtdataDir(extdata_directory,archive_id)
local extra = {}
local extra = {}
extra.name = ".."
extra.name = ".."
extra.size = 0
extra.size = 0
extra.directory = true
extra.directory = true
extra.archive = archive_id
extra.archive = archive_id
table.insert(files_table,extra)
table.insert(files_table,extra)
end
end
end
end
end
end
function GarbageCollection()
function GarbageCollection()
if current_type == "SMDH" then
if current_type == "SMDH" then
Console.destroy(smdh_show)
Console.destroy(smdh_show)
Screen.freeImage(current_file.icon)
Screen.freeImage(current_file.icon)
elseif current_type == "TTF" then
elseif current_type == "TTF" then
Font.unload(current_file)
Font.unload(current_file)
elseif current_type == "JPGV" then
elseif current_type == "JPGV" then
if JPGV.isPlaying(current_file) then
if JPGV.isPlaying(current_file) then
JPGV.pause(current_file)
JPGV.pause(current_file)
end
end
JPGV.unload(current_file)
JPGV.unload(current_file)
is_fullscreen = false
is_fullscreen = false
fullscreen_check = nil
fullscreen_check = nil
elseif current_type == "WAV" then
elseif current_type == "WAV" then
if Sound.isPlaying(current_file) then
if Sound.isPlaying(current_file) then
Sound.pause(current_file)
Sound.pause(current_file)
end
end
Sound.close(current_file)
Sound.close(current_file)
elseif current_type == "IMG" then
elseif current_type == "IMG" then
Graphics.freeImage(current_file)
Graphics.freeImage(current_file)
big_image = false
big_image = false
y_print = 0
y_print = 0
x_print = 0
x_print = 0
elseif current_type == "TXT" then
elseif current_type == "TXT" then
io.close(current_file)
io.close(current_file)
Console.destroy(text_console)
Console.destroy(text_console)
old_indexes = {}
old_indexes = {}
txt_i = 0
txt_i = 0
elseif current_type == "INFO" then
elseif current_type == "INFO" then
Console.destroy(text_console)
Console.destroy(text_console)
elseif current_type == "CIA" then
elseif current_type == "CIA" then
if not cia_data.icon == nil then
if not cia_data.icon == nil then
Screen.freeImage(cia_data.icon)
Screen.freeImage(cia_data.icon)
end
end
elseif current_type == "HEX" then
elseif current_type == "HEX" then
io.close(current_file)
io.close(current_file)
old_indexes = {}
old_indexes = {}
txt_i = 0
txt_i = 0
elseif current_type == "LUA" then
elseif current_type == "LUA" then
theme_name = "NONAME"
theme_name = "NONAME"
author = "NONAME"
author = "NONAME"
end
end
current_type = nil
current_type = nil
end
end
function CropPrint(x, y, text, color, screen)
function CropPrint(x, y, text, color, screen)
if string.len(text) > 25 then
if string.len(text) > 25 then
Screen.debugPrint(x, y, string.sub(text,1,25) .. "...", color, screen)
Screen.debugPrint(x, y, string.sub(text,1,25) .. "...", color, screen)
else
else
Screen.debugPrint(x, y, text, color, screen)
Screen.debugPrint(x, y, text, color, screen)
end
end
end
end
function ThemePrint(x, y, text, color, screen)
function ThemePrint(x, y, text, color, screen)
if string.len(text) > 40 then
if string.len(text) > 40 then
Screen.debugPrint(x, y, string.sub(text,1,40) .. "...", color, screen)
Screen.debugPrint(x, y, string.sub(text,1,40) .. "...", color, screen)
else
else
Screen.debugPrint(x, y, text, color, screen)
Screen.debugPrint(x, y, text, color, screen)
end
end
end
end
function BuildLines(file, index)
function BuildLines(file, index)
MAX_LENGTH = 1200
MAX_LENGTH = 1200
SIZE = io.size(file)
SIZE = io.size(file)
if ((index + MAX_LENGTH) < SIZE) then
if ((index + MAX_LENGTH) < SIZE) then
READ_LENGTH = MAX_LENGTH
READ_LENGTH = MAX_LENGTH
else
else
READ_LENGTH = SIZE - index
READ_LENGTH = SIZE - index
end
end
if (index < SIZE) then
if (index < SIZE) then
Console.clear(text_console)
Console.clear(text_console)
Console.append(text_console,io.read(file,index,READ_LENGTH))
Console.append(text_console,io.read(file,index,READ_LENGTH))
txt_words = Console.show(text_console)
txt_words = Console.show(text_console)
else
else
txt_words = 0
txt_words = 0
end
end
if (txt_words > 0) then
if (txt_words > 0) then
table.insert(old_indexes, index)
table.insert(old_indexes, index)
index = index + txt_words
index = index + txt_words
txt_i = txt_i + 1
txt_i = txt_i + 1
end
end
return index
return index
end
end
function BuildHex(file, index)
function BuildHex(file, index)
MAX_LENGTH = 120
MAX_LENGTH = 120
SIZE = io.size(file)
SIZE = io.size(file)
if ((index + MAX_LENGTH) < SIZE) then
if ((index + MAX_LENGTH) < SIZE) then
READ_LENGTH = MAX_LENGTH
READ_LENGTH = MAX_LENGTH
else
else
READ_LENGTH = SIZE - index
READ_LENGTH = SIZE - index
end
end
if (index < SIZE) then
if (index < SIZE) then
hex_text = {}
hex_text = {}
hex_values = {}
hex_values = {}
text = io.read(file,index,READ_LENGTH)
text = io.read(file,index,READ_LENGTH)
t = 1
t = 1
while (t <= 15) do
while (t <= 15) do
if ((t*8) > string.len(text)) then
if ((t*8) > string.len(text)) then
temp = string.sub(text,1+(t-1)*8,-1)
temp = string.sub(text,1+(t-1)*8,-1)
else
else
temp = string.sub(text,1+(t-1)*8,t*8)
temp = string.sub(text,1+(t-1)*8,t*8)
end
end
t2 = 1
t2 = 1
while t2 <= string.len(temp) do
while t2 <= string.len(temp) do
table.insert(hex_values,string.byte(temp,t2))
table.insert(hex_values,string.byte(temp,t2))
t2 = t2 + 1
t2 = t2 + 1
end
end
table.insert(hex_text,temp)
table.insert(hex_text,temp)
t = t + 1
t = t + 1
end
end
table.insert(old_indexes, index)
table.insert(old_indexes, index)
index = index + READ_LENGTH
index = index + READ_LENGTH
txt_i = txt_i + 1
txt_i = txt_i + 1
end
end
return index
return index
end
end
while true do
while true do
base_y = 0
base_y = 0
i = 1
i = 1
Screen.refresh()
Screen.refresh()
if current_type ~= "JPGV" then
if current_type ~= "JPGV" then
Screen.clear(TOP_SCREEN)
Screen.clear(TOP_SCREEN)
end
end
pad = Controls.read()
pad = Controls.read()
if (current_type == "SMDH") then
if (current_type == "SMDH") then
Console.show(smdh_show)
Console.show(smdh_show)
Screen.debugPrint(0,170,"Icon:",white,TOP_SCREEN)
Screen.debugPrint(0,170,"Icon:",white,TOP_SCREEN)
Screen.drawImage(0,185,current_file.icon,TOP_SCREEN)
Screen.drawImage(0,185,current_file.icon,TOP_SCREEN)
elseif (current_type == "TTF") then
elseif (current_type == "TTF") then
Font.setPixelSizes(current_file,8)
Font.setPixelSizes(current_file,8)
Font.print(current_file,0,5,"8: The quick brown fox",white,TOP_SCREEN)
Font.print(current_file,0,5,"8: The quick brown fox",white,TOP_SCREEN)
Font.print(current_file,10,13,"jumps over the lazy dog",white,TOP_SCREEN)
Font.print(current_file,10,13,"jumps over the lazy dog",white,TOP_SCREEN)
Font.setPixelSizes(current_file,12)
Font.setPixelSizes(current_file,12)
Font.print(current_file,0,25,"12: The quick brown fox",white,TOP_SCREEN)
Font.print(current_file,0,25,"12: The quick brown fox",white,TOP_SCREEN)
Font.print(current_file,10,37,"jumps over the lazy dog",white,TOP_SCREEN)
Font.print(current_file,10,37,"jumps over the lazy dog",white,TOP_SCREEN)
Font.setPixelSizes(current_file,18)
Font.setPixelSizes(current_file,18)
Font.print(current_file,0,54,"18: The quick brown fox",white,TOP_SCREEN)
Font.print(current_file,0,54,"18: The quick brown fox",white,TOP_SCREEN)
Font.print(current_file,10,72,"jumps over the lazy dog",white,TOP_SCREEN)
Font.print(current_file,10,72,"jumps over the lazy dog",white,TOP_SCREEN)
Font.setPixelSizes(current_file,24)
Font.setPixelSizes(current_file,24)
Font.print(current_file,0,95,"24: The quick brown fox",white,TOP_SCREEN)
Font.print(current_file,0,95,"24: The quick brown fox",white,TOP_SCREEN)
Font.print(current_file,10,119,"jumps over the lazy dog",white,TOP_SCREEN)
Font.print(current_file,10,119,"jumps over the lazy dog",white,TOP_SCREEN)
Font.setPixelSizes(current_file,30)
Font.setPixelSizes(current_file,30)
Font.print(current_file,0,149,"30: The quick brown fox",white,TOP_SCREEN)
Font.print(current_file,0,149,"30: The quick brown fox",white,TOP_SCREEN)
Font.print(current_file,10,179,"jumps over the lazy dog",white,TOP_SCREEN)
Font.print(current_file,10,179,"jumps over the lazy dog",white,TOP_SCREEN)
elseif (current_type == "JPGV") then
elseif (current_type == "JPGV") then
if fullscreen_check == nil then
if fullscreen_check == nil then
Screen.drawPixel(399,239,0xDEADBEFF, TOP_SCREEN)
Screen.drawPixel(399,239,0xDEADBEFF, TOP_SCREEN)
tmp = Screen.getPixel(399,239,TOP_SCREEN)
tmp = Screen.getPixel(399,239,TOP_SCREEN)
end
end
if is_fullscreen then
if is_fullscreen then
JPGV.drawFast(current_file,TOP_SCREEN)
JPGV.drawFast(current_file,TOP_SCREEN)
else
else
JPGV.draw(0,0,current_file,TOP_SCREEN)
JPGV.draw(0,0,current_file,TOP_SCREEN)
end
end
if fullscreen_check == nil then
if fullscreen_check == nil then
if tmp == Screen.getPixel(399,239,TOP_SCREEN) then
if tmp == Screen.getPixel(399,239,TOP_SCREEN) then
is_fullscreen = true
end
fullscreen_check = true
end
elseif (current_type == "WAV") then
Sound.updateStream()
Screen.debugPrint(0,0,"Title: ",white,TOP_SCREEN)
ThemePrint(0,15,Sound.getTitle(current_file),white,TOP_SCREEN)
Screen.debugPrint(0,40,"Author: ",white,TOP_SCREEN)
ThemePrint(0,55,Sound.getAuthor(current_file),white,TOP_SCREEN)
Screen.debugPrint(0,80,"Time: "..FormatTime(Sound.getTime(current_file)).." / "..FormatTime(Sound.getTotalTime(current_file)),white,TOP_SCREEN)
Screen.debugPrint(0,95,"Samplerate: "..Sound.getSrate(current_file),white,TOP_SCREEN)
if Sound.getType(current_file) == 1 then
stype = "Mono"
else
stype = "Stereo"
end
Screen.debugPrint