Homebrew [Release] Lua Player Plus 3DS (lpp-3ds) - LUA interpreter for 3DS

  • Thread starter Thread starter Rinnegatamante
  • Start date Start date
  • Views Views 187,229
  • Replies Replies 1,199
  • Likes Likes 35
the point is there are many other formats that to the same, i ask only why

Cause all popular containers (MP4, Theora, MKV) use heavy codecs (like Vorbis Theora and H264.V) that can't be handled without an hardware decoder (Example, do you ever asked why N3DS webbrowser can reproduce videos? Cause N3DS is provided with an hardware decoder for H264.V, a videocodec used by 90% of existent MP4 video files.

If you try to write a video player using CPU as decoder for these formats, you'll get something about 2-3 fps.
JPGV format uses a popular videocodec (worse if compared to H264.V obviously) called MJPEG (Motion JPEG) and can handle different audiocodec (For example Vorbis audiocodec, the best lossy audiocodec in the world).
JPGV format has also some optimizations for 3DS rendering, for example, every frame is encoded rotated by 90° degrees so you don't have to rotate it with 3DS CPU (cause using a GPU renderer will be totally useless for dynamic rendering).
With all these things, JPGV files can reach a good amount of fps (Like 25 fps) without the use of an hardware decoder.
 
Can this do an http POST thing?

On NH1 and CIA/3DS builds yes.
On NH2 currently not cause network features are broken.

I'm trying to draw a rectangle 73x73 at a location of 30,32. How would I do this? I've been trying but it wont work

Screen.fillRect(30, 103, 32, 105, Color.new(255, 0, 0), TOP_SCREEN)
 
Another question:
LPP says that Controls.check at line 72 (and not only 72, because I got the same error with other Controls.check's) is a bad argument #1 and it expects a number.

My code:
Code:
tx, ty = Controls.readTouch()
x = 30
y = 32
number = 1
color = Color.new(123,98,249)
video = Screen.loadImage(System.currentDirectory() .. "/images/video.png")
music = Screen.loadImage(System.currentDirectory() .. "/images/music.png")
text = Screen.loadImage(System.currentDirectory() .. "/images/text.png")
sys = Screen.loadImage(System.currentDirectory() .. "/images/sys.png")
localwire = Screen.loadImage(System.currentDirectory() .. "/images/localwire.png")
launchgame = Screen.loadImage(System.currentDirectory() .. "/images/launchgame.png")

while true do
    pad = Controls.read()
    Screen.waitVblankStart()
    Screen.refresh()
    Screen.clear(TOP_SCREEN)
    Screen.clear(BOTTOM_SCREEN)
    Screen.drawImage(x,y,launchgame,BOTTOM_SCREEN)
    Screen.drawImage(x + 93,y,video,BOTTOM_SCREEN)
    Screen.drawImage(x + 186,y,music,BOTTOM_SCREEN)
    Screen.drawImage(x,y + 99,text,BOTTOM_SCREEN)
    Screen.drawImage(x + 93,y + 99,sys,BOTTOM_SCREEN)
    Screen.drawImage(x + 186,y + 99,localwire,BOTTOM_SCREEN)
    if Controls.check(pad,KEY_TOUCH) and not Controls.check(oldpad,KEY_TOUCH) then
        if (tx >= x) and (tx <= x + 72) and (ty >= y) and (ty <= y + 72) then
            Screen.debugPrint(0,0,"Launching Game Cartridge...",color,TOP_SCREEN)
            System.launchGamecard()
        end
        if (tx >= x + 30) and (tx <= x + 102) and (ty >= y) and (ty <= y + 72) then      
            Screen.debugPrint(0,0,"Work In Progress: Video Player",color,TOP_SCREEN)
        end
        if (tx >= x + 60) and (tx <= x + 132) and (ty >= y) and (ty <= y + 72) then      
            Screen.debugPrint(0,0,"Work In Progress: Music Player",color,TOP_SCREEN)
        end
        if (tx >= x) and (tx <= x + 72) and (ty >= y + 73) and (ty <= y + 150) then  
            Screen.debugPrint(0,0,"Work In Progress: System Info",color,TOP_SCREEN)
        end
        if (tx >= x + 30) and (tx <= x + 102) and (ty >= y + 73) and (ty <= y + 150) then      
            Screen.debugPrint(0,0,"Work In Progress: Text Editor",color,TOP_SCREEN)
        end
        if (tx >= x + 60) and (tx <= x + 132) and (ty >= y + 73) and (ty <= y + 150) then  
            Screen.debugPrint(0,0,"Work In Progress: Walkie Talkie",color,TOP_SCREEN)
        end
        if Controls.check(pad,KEY_START) and not Controls.check(oldpad,KEY_START) then
            Sound.term()
            System.exit()
        end
    end
    Screen.flip()
end
 
Last edited by Megalegacy98,
Another question:
LPP says that Controls.check is a bad argument #1 and it expects a number.

My code: snip
I think you should try putting "pad = Controls.read()" below waitVblankStart and refresh.
Code:
while true do
    Screen.waitVblankStart()
    Screen.refresh()
    pad = Controls.read()
    Screen.clear(TOP_SCREEN)
    Screen.clear(BOTTOM_SCREEN)
    ...
 
Another question:
LPP says that Controls.check at line 72 (and not only 72, because I got the same error with other Controls.check's) is a bad argument #1 and it expects a number.

My code:
Code:
tx, ty = Controls.readTouch()
x = 30
y = 32
number = 1
color = Color.new(123,98,249)
video = Screen.loadImage(System.currentDirectory() .. "/images/video.png")
music = Screen.loadImage(System.currentDirectory() .. "/images/music.png")
text = Screen.loadImage(System.currentDirectory() .. "/images/text.png")
sys = Screen.loadImage(System.currentDirectory() .. "/images/sys.png")
localwire = Screen.loadImage(System.currentDirectory() .. "/images/localwire.png")
launchgame = Screen.loadImage(System.currentDirectory() .. "/images/launchgame.png")

while true do
    pad = Controls.read()
    Screen.waitVblankStart()
    Screen.refresh()
    Screen.clear(TOP_SCREEN)
    Screen.clear(BOTTOM_SCREEN)
    Screen.drawImage(x,y,launchgame,BOTTOM_SCREEN)
    Screen.drawImage(x + 93,y,video,BOTTOM_SCREEN)
    Screen.drawImage(x + 186,y,music,BOTTOM_SCREEN)
    Screen.drawImage(x,y + 99,text,BOTTOM_SCREEN)
    Screen.drawImage(x + 93,y + 99,sys,BOTTOM_SCREEN)
    Screen.drawImage(x + 186,y + 99,localwire,BOTTOM_SCREEN)
    if Controls.check(pad,KEY_TOUCH) and not Controls.check(oldpad,KEY_TOUCH) then
        if (tx >= x) and (tx <= x + 72) and (ty >= y) and (ty <= y + 72) then
            Screen.debugPrint(0,0,"Launching Game Cartridge...",color,TOP_SCREEN)
            System.launchGamecard()
        end
        if (tx >= x + 30) and (tx <= x + 102) and (ty >= y) and (ty <= y + 72) then     
            Screen.debugPrint(0,0,"Work In Progress: Video Player",color,TOP_SCREEN)
        end
        if (tx >= x + 60) and (tx <= x + 132) and (ty >= y) and (ty <= y + 72) then     
            Screen.debugPrint(0,0,"Work In Progress: Music Player",color,TOP_SCREEN)
        end
        if (tx >= x) and (tx <= x + 72) and (ty >= y + 73) and (ty <= y + 150) then 
            Screen.debugPrint(0,0,"Work In Progress: System Info",color,TOP_SCREEN)
        end
        if (tx >= x + 30) and (tx <= x + 102) and (ty >= y + 73) and (ty <= y + 150) then     
            Screen.debugPrint(0,0,"Work In Progress: Text Editor",color,TOP_SCREEN)
        end
        if (tx >= x + 60) and (tx <= x + 132) and (ty >= y + 73) and (ty <= y + 150) then 
            Screen.debugPrint(0,0,"Work In Progress: Walkie Talkie",color,TOP_SCREEN)
        end
        if Controls.check(pad,KEY_START) and not Controls.check(oldpad,KEY_START) then
            Sound.term()
            System.exit()
        end
    end
    Screen.flip()
end

You're not setting oldpad, you should initialize it to Controls.read() then set oldpad = pad at the end of every loop
 
If you don't get an error, it's either a bug with your graphics functions or you have an infinite loop. If you put a app exit clause somewhere in your main loop so when you press a button the app exits to homebrew launcher, then you can debug whether it's a frozen function or simply nothing is drawing because no draw functions are called.
 
  • Like
Reactions: Megalegacy98
If you don't get an error, it's either a bug with your graphics functions or you have an infinite loop. If you put a app exit clause somewhere in your main loop so when you press a button the app exits to homebrew launcher, then you can debug whether it's a frozen function or simply nothing is drawing because no draw functions are called.
I've gotten freezes on the actually 3DS hardware from memory problems as well
 
Tried to use a cia, but it causes a green pixel, and then an error forcing to reboot. I'M SURE index.lua is in the SD root and it works with the 3dsx
 
Here it is
System.currentDirectory("/CTGP-7/")
function getconfig()
local config = io.open(System.currentDirectory().."config/config.cfg",FWRITE)
local cfgtrack = io.open(System.currentDirectory().."config/tracknames.cfg",FWRITE)
local cfgcustra = io.open(System.currentDirectory().."config/ctnames.cfg",FWRITE)
trackn = (io.size(config) - 1)
local stringtrck = io.read(cfgtrack, 0, io.size(cfgtrack))
local stringct = io.read(cfgcustra, 0, io.size(cfgtrack))
tracks = {}
cts = {}
local l = 1
local m = 1
for i in string.gmatch(stringtrck, "%S+") do
tracks[l] = i -- Course order: GBABC, CTRIS, CTRTC, CTRWI1, N64KD, SFCMC.
l = l + 1
end
for s in string.gmatch(stringct, '([^,]+)') do
cts[m] = s -- Course order: GBABC, CTRIS, CTRTC, CTRWI1, N64KD, SFCMC.
m = m + 1
end
cts[trackn + 1] = nil
if not (tracks[trackn + 1] == nil) or not (cts[trackn + 1] == nil) then
System.exit()
end
if (tracks[trackn] == nil) or (cts[trackn] == nil) then
System.exit()
end
local tracken = {}
tracke = {}
local k = 1
for k = 1, trackn, 1 do
tracken[k] = io.read(config, (k-1), 1) -- Get data from config.cfg
if (tracken[k] == "0") then
tracke[k] = false
elseif (tracken[k] == "1") then
tracke[k] = true
end
end
io.close(config)
io.close(cfgtrack)
return true
end
function saveconfig()
local sconfig = io.open(System.currentDirectory().."config/config.cfg",FWRITE)
-- Course order: GBABC, CTRIS, CTRTC, CTRWI1, N64KD, SFCMC
local y
local tracken = {}
for y = 1, trackn, 1 do
if (tracke[y]) then
tracken[y] = "1"
elseif not (tracke[y]) then
tracken[y] = "0"
end
io.write(sconfig,(y - 1),tracken[y], 1)
end
io.close(sconfig)
return true
end
function applyconfig()
local z
for z = 1, trackn, 1 do
if (System.doesFileExist("/0004000000030"..gamergn.."00/Course/"..tracks[z]..".szs")) then
if not (tracke[z]) then
System.renameFile("/0004000000030"..gamergn.."00/Course/"..tracks[z]..".szs", "/0004000000030"..gamergn.."00/Course/"..tracks[z].."1.szs")
end
elseif (System.doesFileExist("/0004000000030"..gamergn.."00/Course/"..tracks[z].."1.szs")) then
if (tracke[z]) then
System.renameFile("/0004000000030"..gamergn.."00/Course/"..tracks[z].."1.szs", "/0004000000030"..gamergn.."00/Course/"..tracks[z]..".szs")
end
end
end
return true
end
function getgamergn()
local config = io.open(System.currentDirectory().."config/config.cfg",FWRITE)
if (io.read(config, io.size(config) - 1, 1) == "0") then
askrgn = 1
else
submen = 0
end
gamergn = io.read(config, io.size(config) - 1,1)
io.close(config)
return true
end
topimgl = Screen.loadImage(System.currentDirectory().."resources/top_l.bmp")
submen0 = Screen.loadImage(System.currentDirectory().."resources/submen0.bmp")
submen1 = Screen.loadImage(System.currentDirectory().."resources/submen1.bmp")
submen2 = Screen.loadImage(System.currentDirectory().."resources/submen2.bmp")
submen3 = Screen.loadImage(System.currentDirectory().."resources/submen3.bmp")
music0 = Sound.openWav(System.currentDirectory().."resources/music0.wav",false)
music1 = Sound.openWav(System.currentDirectory().."resources/music1.wav",false)
mus0 = 0
men = 0
men1 = 0
men3 = 1
getgamergn()
oldpad = Controls.read
topscreen = topimgl
bottomscreen = submen0
Sound.init()
Sound.play(music0,NO_LOOP,0x09)
while true do
Screen.waitVblankStart()
Screen.refresh()
Screen.clear(BOTTOM_SCREEN)
Screen.drawImage(0,0,topscreen,TOP_SCREEN)
Screen.drawImage(0,0,bottomscreen,BOTTOM_SCREEN)
checkbutton = true
pad = Controls.read()
if (mus0 == 0) then
if (Sound.getTime(music0) == 18) then
Sound.play(music1,LOOP,0x0A)
Sound.close(music0)
mus0 = 1
end
end
if (Controls.check(pad,KEY_DDOWN)) and not (Controls.check(oldpad,KEY_DDOWN)) then
men = men + 1
elseif (Controls.check(pad,KEY_DUP)) and not (Controls.check(oldpad,KEY_DUP)) then
men = men - 1
end
if (Controls.check(pad,KEY_DRIGHT)) and not (Controls.check(oldpad,KEY_DRIGHT)) then
men1 = men1 + 1
elseif (Controls.check(pad,KEY_DLEFT)) and not (Controls.check(oldpad,KEY_DLEFT)) then
men1 = men1 - 1
end
if (men > 1) then
men = 0
elseif (men < 0) then
men = 1
end
if (men1 > 1) then
men1 = 0
elseif (men1 < 0) then
men1 = 1
end
if (askrgn == 1) then
submen = 255
dispreg = "None"
if (men == 0) then
gamergn = 7
dispreg = "EUR"
elseif (men == 1) then
gamergn = 8
dispreg = "USA"
end
Screen.debugPrint(0, 0, "Current selected game region is: "..dispreg, Color.new(255,255,255), BOTTOM_SCREEN)
Screen.debugPrint(0, 0, "DPAD up or down to choose, A to confirm.", Color.new(255,255,255), BOTTOM_SCREEN)
if (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) and not (dispreg == "None") then
config = io.open(System.currentDirectory().."config/config.cfg",FWRITE)
io.write(config, io.size(config) - 1, gamergn, 1)
io.close(config)
askrgn = 0
submen = 0
men = 0
men1 = 0
end
end
if (submen == 0) then -- main menu
bottomscreen = submen0
if (men == 0) then
if (men1 == 0) then
Screen.fillEmptyRect(0, 159, 0, 119, Color.new(255,255,255), BOTTOM_SCREEN)
if (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) and (checkbutton) then
getconfig()
applyconfig()
System.launchGamecard()
end
else
Screen.fillEmptyRect(159, 319, 0, 119, Color.new(255,255,255), BOTTOM_SCREEN)
if (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) and (checkbutton) then
submen = 1
men = 0
men1 = 0
checkbutton = false
end
end
else
if (men1 == 0) then
Screen.fillEmptyRect(0, 159, 119, 239, Color.new(255,255,255), BOTTOM_SCREEN)
if (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) and (checkbutton) then
men = 0
men1 = 0
submen = 2
checkbutton = false
end
else
Screen.fillEmptyRect(159, 319, 119, 239, Color.new(255,255,255), BOTTOM_SCREEN)
if (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) and (checkbutton) then
Sound.term()
System.exit()
end
end
end
end
if (submen == 1) then -- CTGP-7 manager
bottomscreen = submen1
if (men == 0) then
if (men1 == 0) then
Screen.fillEmptyRect(0, 159, 0, 119, Color.new(255,255,255), BOTTOM_SCREEN)
if (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) and (checkbutton) then
submen = 3
men = 0
men1 = 0
checkbutton = false
getconfig()
end
else
Screen.fillEmptyRect(159, 319, 0, 119, Color.new(255,255,255), BOTTOM_SCREEN)
end
else
if (men1 == 0) then
Screen.fillEmptyRect(0, 159, 119, 239, Color.new(255,255,255), BOTTOM_SCREEN)
else
Screen.fillEmptyRect(159, 319, 119, 239, Color.new(255,255,255), BOTTOM_SCREEN)
if (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) and (checkbutton) then
submen = 0
men = 0
men1 = 0
checkbutton = false
end
end
end
end
if (submen == 2) then -- Options
bottomscreen = submen2
if (men == 0) then
Screen.fillEmptyRect(0, 319, 0, 119, Color.new(255,255,255), BOTTOM_SCREEN)
if (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) and (checkbutton) then
askrgn = 1
getconfig()
submen = 0
men = 0
men1 = 0
checkbutton = false
end
else
Screen.fillEmptyRect(0, 319, 119, 239, Color.new(255,255,255), BOTTOM_SCREEN)
if (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) and (checkbutton) then
submen = 0
men = 0
men1 = 0
checkbutton = false
end
end
end
if (submen == 3) then -- Course manager
bottomscreen = submen3
if (Controls.check(pad,KEY_DDOWN)) and not (Controls.check(oldpad,KEY_DDOWN)) then
men3 = men3 - 1
elseif (Controls.check(pad,KEY_DUP)) and not (Controls.check(oldpad,KEY_DUP)) then
men3 = men3 + 1
end
if (men3 == trackn + 1) then
men3 = 1
elseif (men3 == 0) then
men3 = trackn
end
if (Controls.check(pad,KEY_DRIGHT)) and not (Controls.check(oldpad,KEY_DRIGHT)) and (checkbutton) or (Controls.check(pad,KEY_DLEFT)) and not (Controls.check(oldpad,KEY_DLEFT)) and (checkbutton)then
tracke[men3] = not tracke[men3]
end
if (Controls.check(pad,KEY_B)) and not (Controls.check(oldpad,KEY_B)) and (checkbutton) then
submen = 1
men = 0
men1 = 0
checkbutton = false
saveconfig()
end
enadisa = {}
for x = 1, trackn, 1 do
if (tracke[x]) then
enadisa[x] = "enabled"
elseif not (tracke[x]) then
enadisa[x] = "disabled"
end
end
Screen.debugPrint(0, 0, men3..": "..cts[men3].." = "..enadisa[men3], Color.new(255,255,255), BOTTOM_SCREEN)
end
Screen.debugPrint(0, 100, System.getGWRomID(), Color.new(255,255,255), BOTTOM_SCREEN)
oldpad = pad
Screen.flip()
end
 
Here it is snip
Please use code tags, it keeps any indentation you have.
Code:
System.currentDirectory("/CTGP-7/")
function getconfig()
    local config = io.open(System.currentDirectory().."config/config.cfg",FWRITE)
    local cfgtrack = io.open(System.currentDirectory().."config/tracknames.cfg",FWRITE)
    local cfgcustra = io.open(System.currentDirectory().."config/ctnames.cfg",FWRITE)
    trackn = (io.size(config) - 1)
    local stringtrck = io.read(cfgtrack, 0, io.size(cfgtrack))
    local stringct = io.read(cfgcustra, 0, io.size(cfgtrack))
    tracks = {}
    cts = {}
    local l = 1
    local m = 1
    for i in string.gmatch(stringtrck, "%S+") do
        tracks[l] = i -- Course order: GBABC, CTRIS, CTRTC, CTRWI1, N64KD, SFCMC.
        l = l + 1
    end
    for s in string.gmatch(stringct, '([^,]+)') do
        cts[m] = s -- Course order: GBABC, CTRIS, CTRTC, CTRWI1, N64KD, SFCMC.
        m = m + 1
    end
    cts[trackn + 1] = nil
    if not (tracks[trackn + 1] == nil) or not (cts[trackn + 1] == nil) then
        System.exit()
    end
    if (tracks[trackn] == nil) or (cts[trackn] == nil) then
        System.exit()
    end
    local tracken = {}
    tracke = {}
    local k = 1
    for k = 1, trackn, 1 do
        tracken[k] = io.read(config, (k-1), 1) -- Get data from config.cfg
        if (tracken[k] == "0") then
            tracke[k] = false
        elseif (tracken[k] == "1") then
            tracke[k] = true
        end 
    end
    io.close(config)
    io.close(cfgtrack)
    return true
end
function saveconfig()
    local sconfig = io.open(System.currentDirectory().."config/config.cfg",FWRITE)
    -- Course order: GBABC, CTRIS, CTRTC, CTRWI1, N64KD, SFCMC
    local y
    local tracken = {}
    for y = 1, trackn, 1 do
        if (tracke[y]) then
            tracken[y] = "1"
        elseif not (tracke[y]) then
            tracken[y] = "0"
        end
        io.write(sconfig,(y - 1),tracken[y], 1)
    end
    io.close(sconfig)
    return true
end
function applyconfig()
    local z
    for z = 1, trackn, 1 do
        if (System.doesFileExist("/0004000000030"..gamergn.."00/Course/"..tracks[z]..".szs")) then
            if not (tracke[z]) then
                System.renameFile("/0004000000030"..gamergn.."00/Course/"..tracks[z]..".szs", "/0004000000030"..gamergn.."00/Course/"..tracks[z].."1.szs")
            end
        elseif (System.doesFileExist("/0004000000030"..gamergn.."00/Course/"..tracks[z].."1.szs")) then
            if (tracke[z]) then
                System.renameFile("/0004000000030"..gamergn.."00/Course/"..tracks[z].."1.szs", "/0004000000030"..gamergn.."00/Course/"..tracks[z]..".szs")
            end
        end
    end
    return true
end
function getgamergn()
    local config = io.open(System.currentDirectory().."config/config.cfg",FWRITE)
    if (io.read(config, io.size(config) - 1, 1) == "0") then
        askrgn = 1
    else
        submen = 0
    end
    gamergn = io.read(config, io.size(config) - 1,1)
    io.close(config)
    return true
end
topimgl = Screen.loadImage(System.currentDirectory().."resources/top_l.bmp")
submen0 = Screen.loadImage(System.currentDirectory().."resources/submen0.bmp")
submen1 = Screen.loadImage(System.currentDirectory().."resources/submen1.bmp")
submen2 = Screen.loadImage(System.currentDirectory().."resources/submen2.bmp")
submen3 = Screen.loadImage(System.currentDirectory().."resources/submen3.bmp")
music0 = Sound.openWav(System.currentDirectory().."resources/music0.wav",false)
music1 = Sound.openWav(System.currentDirectory().."resources/music1.wav",false)
mus0 = 0
men = 0
men1 = 0
men3 = 1
getgamergn()
oldpad = Controls.read
topscreen = topimgl
bottomscreen = submen0
Sound.init()
Sound.play(music0,NO_LOOP,0x09)
while true do
    Screen.waitVblankStart()
    Screen.refresh()
    Screen.clear(BOTTOM_SCREEN)
    Screen.drawImage(0,0,topscreen,TOP_SCREEN)
    Screen.drawImage(0,0,bottomscreen,BOTTOM_SCREEN)
    checkbutton = true
    pad = Controls.read()
    if (mus0 == 0) then
        if (Sound.getTime(music0) == 18) then
            Sound.play(music1,LOOP,0x0A)
            Sound.close(music0)
            mus0 = 1
        end 
    end
    if (Controls.check(pad,KEY_DDOWN)) and not (Controls.check(oldpad,KEY_DDOWN)) then
        men = men + 1
    elseif (Controls.check(pad,KEY_DUP)) and not (Controls.check(oldpad,KEY_DUP)) then
        men = men - 1
    end
    if (Controls.check(pad,KEY_DRIGHT)) and not (Controls.check(oldpad,KEY_DRIGHT)) then
        men1 = men1 + 1
    elseif (Controls.check(pad,KEY_DLEFT)) and not (Controls.check(oldpad,KEY_DLEFT)) then
        men1 = men1 - 1
    end
    if (men > 1) then
        men = 0
    elseif (men < 0) then
        men = 1
    end
    if (men1 > 1) then
        men1 = 0
    elseif (men1 < 0) then
        men1 = 1
    end
    if (askrgn == 1) then
        submen = 255
        dispreg = "None"
        if (men == 0) then
            gamergn = 7
            dispreg = "EUR"
        elseif (men == 1) then
            gamergn = 8
            dispreg = "USA"
        end
        Screen.debugPrint(0, 0, "Current selected game region is: "..dispreg, Color.new(255,255,255), BOTTOM_SCREEN)
        Screen.debugPrint(0, 0, "DPAD up or down to choose, A to confirm.", Color.new(255,255,255), BOTTOM_SCREEN)
        if (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) and not (dispreg == "None") then
            config = io.open(System.currentDirectory().."config/config.cfg",FWRITE)
            io.write(config, io.size(config) - 1, gamergn, 1)
            io.close(config)
            askrgn = 0
            submen = 0
            men = 0
            men1 = 0
        end
    end
    if (submen == 0) then -- main menu
        bottomscreen = submen0
        if (men == 0) then
            if (men1 == 0) then
                Screen.fillEmptyRect(0, 159, 0, 119, Color.new(255,255,255), BOTTOM_SCREEN)
                if (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) and (checkbutton) then
                    getconfig()
                    applyconfig()
                    System.launchGamecard()
                end
            else
                Screen.fillEmptyRect(159, 319, 0, 119, Color.new(255,255,255), BOTTOM_SCREEN)
                if (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) and (checkbutton) then
                    submen = 1
                    men = 0
                    men1 = 0
                    checkbutton = false
                end
            end
        else
            if (men1 == 0) then
                Screen.fillEmptyRect(0, 159, 119, 239, Color.new(255,255,255), BOTTOM_SCREEN)
                if (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) and (checkbutton) then
                    men = 0
                    men1 = 0
                    submen = 2
                    checkbutton = false
                end
            else
                Screen.fillEmptyRect(159, 319, 119, 239, Color.new(255,255,255), BOTTOM_SCREEN)
                if (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) and (checkbutton) then
                    Sound.term()
                    System.exit()
                end
            end
        end
    end
    if (submen == 1) then -- CTGP-7 manager
        bottomscreen = submen1
        if (men == 0) then
            if (men1 == 0) then
                Screen.fillEmptyRect(0, 159, 0, 119, Color.new(255,255,255), BOTTOM_SCREEN)
            if (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) and (checkbutton) then
                submen = 3
                men = 0
                men1 = 0
                checkbutton = false
                getconfig()
            end
            else
                Screen.fillEmptyRect(159, 319, 0, 119, Color.new(255,255,255), BOTTOM_SCREEN)
            end
        else
            if (men1 == 0) then
                Screen.fillEmptyRect(0, 159, 119, 239, Color.new(255,255,255), BOTTOM_SCREEN)
            else
                Screen.fillEmptyRect(159, 319, 119, 239, Color.new(255,255,255), BOTTOM_SCREEN)
                if (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) and (checkbutton) then
                    submen = 0
                    men = 0
                    men1 = 0
                    checkbutton = false
                end
            end
        end
    end
    if (submen == 2) then -- Options
        bottomscreen = submen2
        if (men == 0) then
            Screen.fillEmptyRect(0, 319, 0, 119, Color.new(255,255,255), BOTTOM_SCREEN)
            if (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) and (checkbutton) then
                askrgn = 1
                getconfig()
                submen = 0
                men = 0
                men1 = 0
                checkbutton = false
            end
        else
            Screen.fillEmptyRect(0, 319, 119, 239, Color.new(255,255,255), BOTTOM_SCREEN)
            if (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) and (checkbutton) then
                submen = 0
                men = 0
                men1 = 0
                checkbutton = false
            end
        end
    end
    if (submen == 3) then -- Course manager
        bottomscreen = submen3
        if (Controls.check(pad,KEY_DDOWN)) and not (Controls.check(oldpad,KEY_DDOWN)) then
            men3 = men3 - 1
        elseif (Controls.check(pad,KEY_DUP)) and not (Controls.check(oldpad,KEY_DUP)) then
            men3 = men3 + 1
        end
        if (men3 == trackn + 1) then
            men3 = 1
        elseif (men3 == 0) then
            men3 = trackn
        end
        if (Controls.check(pad,KEY_DRIGHT)) and not (Controls.check(oldpad,KEY_DRIGHT)) and (checkbutton) or (Controls.check(pad,KEY_DLEFT)) and not (Controls.check(oldpad,KEY_DLEFT)) and (checkbutton)then
            tracke[men3] = not tracke[men3]
        end
        if (Controls.check(pad,KEY_B)) and not (Controls.check(oldpad,KEY_B)) and (checkbutton) then
            submen = 1
            men = 0
            men1 = 0
            checkbutton = false
            saveconfig()
        end
        enadisa = {}
        for x = 1, trackn, 1 do
            if (tracke[x]) then
                enadisa[x] = "enabled"
            elseif not (tracke[x]) then
                enadisa[x] = "disabled"
            end
        end
        Screen.debugPrint(0, 0, men3..": "..cts[men3].." = "..enadisa[men3], Color.new(255,255,255), BOTTOM_SCREEN)
    end
    Screen.debugPrint(0, 100, System.getGWRomID(), Color.new(255,255,255), BOTTOM_SCREEN)
    oldpad = pad
    Screen.flip()
end
 
  • Like
Reactions: PabloMK7

Site & Scene News

Popular threads in this forum