Homebrew Need help creating an application in LPP3DS (Lua)

Chelsea_Fantasy

Someone who hates slow internet connections
OP
Member
Joined
Mar 25, 2014
Messages
1,134
Trophies
0
Age
33
XP
1,394
Country
Cuba
Hello,
First of all: my mother tongue (born language) is Spanish. I will try to make this an "understandable" English post.
I'm trying to make my own CIA installer and I have a problem installing the file. The application it's running as a CIA.

My intention it's to make a cool-looking "install and delete" cia installer, so it will look great and also will work like the "Install All CIAs" funtion but also will delete the cia file after the installation.

I used the compiled LPP-3DS elf in your repository (in the "bin" folder) (I striped it, off course). Then I make the CIA file with the cia_workaround.rsf in the repository. It works perfectly, I even made a hello world app.

The problem is creating the CIA installer. The interface works great, the problem is when the software tries to install the file. It shows the cover art (see the code for reference) and after a few seconds (may vary in dependence of the file size) it jumps to the next game and does not installs nothing (see code for reference). I have enough space (16GB SD Card with 10GB of free space, so that's not the deal).

The code it's below this line and also it's attached to thepost (I comment it), if I made any mistake, please, let me know where. Thanks

Code:
--Code START-------------------------------------------------------------------------------
--my mothertongue it's spanish so I made a small variable name translation as a commentary, example in the next line:
--hola = 1+2 --hola means hello
--I also write some "lazy" commentaries in my very bad english.
Screen.refresh()
Screen.clear(TOP_SCREEN)
Screen.clear(BOTTOM_SCREEN)
--load the interface background pictures for the software
LWNOADV = Screen.loadImage("/backgrounds/bottom/LWNOADV.PNG") --normal bottom screen
LOWWADV = Screen.loadImage("/backgrounds/bottom/LOWWADV.PNG") --bottom screen with the "do not shutdown" warning
EXITING = Screen.loadImage("/backgrounds/upper/EXITING.PNG") --the "all done / wave bye bye" screen
LOADING = Screen.loadImage("/backgrounds/upper/LOADING.PNG") --the loading list of games screen
INSTBKG = Screen.loadImage("/backgrounds/upper/INSTBKG.PNG") --the background for the game installation screen (haves a black space for the cover art of the game)
Screen.drawImage(0,0,LOADING,TOP_SCREEN)
Screen.drawImage(0,0,LWNOADV,BOTTOM_SCREEN)
Screen.waitVblankStart()
Screen.flip()
Screen.refresh()
Controls.init()
pad = Controls.read()
white = Color.new(255,255,255)
here="/InstDir/"
for zzz = 1,5 do -- I repeat this to be able of at least read the loading text
    Controls.init()
    pad = Controls.read()
    Screen.waitVblankStart()
    Screen.drawImage(0,0,LOADING,TOP_SCREEN)
    Screen.drawImage(0,0,LWNOADV,BOTTOM_SCREEN)
    Screen.flip()
    Screen.refresh()
end
--lets stop here and let me explain something:
--the structure its the same:
--    "SDMC:/InstDir/[GAMENAME]/CTR-P-GAME.CIA" for the CIA file
--  "SDMC:/InstDir/[GAMENAME]/CTR-P-GAME.PNG" for the cover art (must be 186x165)
--example:
--    "SDMC:/InstDir/Mario 3D Land/CTR-P-GAME.CIA"
--    "SDMC:/InstDir/Mario 3D Land/CTR-P-GAME.PNG"
--    "SDMC:/InstDir/Fantasy Life/CTR-P-GAME.CIA"
--    "SDMC:/InstDir/Fantasy Life/CTR-P-GAME.PNG"
--    "SDMC:/InstDir/Power Rangers/CTR-P-GAME.CIA"
--    "SDMC:/InstDir/Power Rangers/CTR-P-GAME.PNG"
--the name for the png and cia files will always be "CTR-P-GAME"
juegos = System.listDirectory("/InstDir/") --juego means game
totaljuegos=#juegos --juego means game
for i = 1,totaljuegos do
nombredeljuego=juegos[i].name
coverart=here..nombredeljuego.."/CTR-P-GAME.PNG" --pic must be 186x165
LITTLEG = Screen.loadImage(coverart)
Controls.init()
pad = Controls.read()
Screen.waitVblankStart()
Screen.drawImage(0,0,INSTBKG,TOP_SCREEN)
Screen.drawImage(192,60,LITTLEG,TOP_SCREEN)
Screen.drawImage(0,0,LOWWADV,BOTTOM_SCREEN)
Screen.flip()
Screen.refresh()
ciainst=here..nombredeljuego.."/CTR-P-GAME.CIA" --"nombredeljuego" means "nameofthegame"
System.installCIA(ciainst)
--dummy repetition start
pad = Controls.read()
Screen.waitVblankStart()
Screen.drawImage(0,0,INSTBKG,TOP_SCREEN)
Screen.drawImage(192,60,LITTLEG,TOP_SCREEN)
Screen.drawImage(0,0,LOWWADV,BOTTOM_SCREEN)
Screen.flip()
Screen.refresh()
--dummy repetition end
System.deleteFile(coverart)
System.deleteFile(ciainst)
System.deleteDirectory(here..nombredeljuego)
end
System.deleteDirectory("/InstDir/")
zzz=0
for zzz = 1,5 do -- I repeat this to be able of at least read the "all done, bye bye" text
    Controls.init()
    pad = Controls.read()
    Screen.waitVblankStart()
    Screen.drawImage(0,0,EXITING,TOP_SCREEN)
    Screen.drawImage(0,0,LWNOADV,BOTTOM_SCREEN)
    Screen.flip()
    Screen.refresh()
end
System.exit()
while true do
    --bla, bla, bla...tralala
end
--Code END-------------------------------------------------------------------------------
 

Attachments

  • index.zip
    1.2 KB · Views: 171

Chelsea_Fantasy

Someone who hates slow internet connections
OP
Member
Joined
Mar 25, 2014
Messages
1,134
Trophies
0
Age
33
XP
1,394
Country
Cuba
know that
the thing is that im trying to create a more confortable Big Red Menu, with bugs and all (since my software uses th same functions and the same lua executor my "EasyCIAInstaller" it's basically a Big Red Menu

EDIT: (with bug I mean not the list ones, I mean the memory one)
 

Chelsea_Fantasy

Someone who hates slow internet connections
OP
Member
Joined
Mar 25, 2014
Messages
1,134
Trophies
0
Age
33
XP
1,394
Country
Cuba
it's classic style
I learn to code by myself so there are a lot of things that I dont use cause I found an alternative first and then when I learn the prooper one I keep using the easy one that I found early if it works ok.

in this case, it does not seems to affect the code
 

Chelsea_Fantasy

Someone who hates slow internet connections
OP
Member
Joined
Mar 25, 2014
Messages
1,134
Trophies
0
Age
33
XP
1,394
Country
Cuba
cia_workaround.rsf

I used the compiled elf in the repository's "bin" folder

sorry if I reply late but my internet connection is a 20kbps one
 

Rinnegatamante

Well-Known Member
Member
Joined
Nov 24, 2014
Messages
3,162
Trophies
2
Age
27
Location
Bologna
Website
rinnegatamante.it
XP
4,733
Country
Italy
Your code seems substantially correct (also, if it takes time before swapping to the next CIA, seems installing process is correctly initialized).

This is a more correct and readable version of your code:
Code:
Screen.refresh()
Screen.clear(TOP_SCREEN)
Screen.clear(BOTTOM_SCREEN)
LWNOADV = Screen.loadImage("/backgrounds/bottom/LWNOADV.PNG")
LOWWADV = Screen.loadImage("/backgrounds/bottom/LOWWADV.PNG")
EXITING = Screen.loadImage("/backgrounds/upper/EXITING.PNG")
LOADING = Screen.loadImage("/backgrounds/upper/LOADING.PNG")
INSTBKG = Screen.loadImage("/backgrounds/upper/INSTBKG.PNG")
Screen.drawImage(0,0,LOADING,TOP_SCREEN)
Screen.drawImage(0,0,LWNOADV,BOTTOM_SCREEN)
Screen.waitVblankStart()
Screen.flip()
Screen.refresh()
--Controls.init() NOT USED
--pad = Controls.read()
white = Color.new(255,255,255)
here="/InstDir/"
for zzz = 1,5 do
    --Controls.init() NOT USED
    --pad = Controls.read()
    Screen.waitVblankStart()
    Screen.drawImage(0,0,LOADING,TOP_SCREEN)
    Screen.drawImage(0,0,LWNOADV,BOTTOM_SCREEN)
    Screen.flip()
    Screen.refresh()
end
juegos = System.listDirectory("/InstDir/")
for i,juego in pairs(juegos) do -- Better using paired for
    coverart=here..juego.name.."/CTR-P-GAME.PNG"
    LITTLEG = Screen.loadImage(coverart)
    --Controls.init() NOT USED
    --pad = Controls.read()
    Screen.waitVblankStart()
    Screen.drawImage(0,0,INSTBKG,TOP_SCREEN)
    Screen.drawImage(192,60,LITTLEG,TOP_SCREEN)
    Screen.drawImage(0,0,LOWWADV,BOTTOM_SCREEN)
    Screen.flip()
    Screen.refresh()
    ciainst=here..juego.name.."/CTR-P-GAME.CIA" --"nombredeljuego" means "nameofthegame"
    System.installCIA(ciainst)
    --dummy repetition start [Why you do this?]
    --pad = Controls.read()
    --Screen.waitVblankStart()
    --Screen.drawImage(0,0,INSTBKG,TOP_SCREEN)
    --Screen.drawImage(192,60,LITTLEG,TOP_SCREEN)
    --Screen.drawImage(0,0,LOWWADV,BOTTOM_SCREEN)
    --Screen.flip()
    --Screen.refresh()
    --dummy repetition end
    Screen.freeImage(LITTLEG) -- You MUST always free all used RAM before losing access to objects
    System.deleteFile(coverart)
    System.deleteFile(ciainst)
    System.deleteDirectory(here..juego.name)
    end
    System.deleteDirectory("/InstDir/")
    zzz=0
    for zzz = 1,5 do -- I repeat this to be able of at least read the "all done, bye bye" text
        --Controls.init() NOT USED
        --pad = Controls.read()
        Screen.waitVblankStart()
        Screen.drawImage(0,0,EXITING,TOP_SCREEN)
        Screen.drawImage(0,0,LWNOADV,BOTTOM_SCREEN)
        Screen.flip()
        Screen.refresh()
    end
   
    -- You MUST always free all used RAM before exiting
    Screen.freeImage(EXITING)
    Screen.freeImage(LOADING)
    Screen.freeImage(LWNOADV)
    Screen.freeImage(INSTBKG)
    Screen.freeImage(LOWWADV)
   
    System.exit()
 
  • Like
Reactions: GaaraPrime

Chelsea_Fantasy

Someone who hates slow internet connections
OP
Member
Joined
Mar 25, 2014
Messages
1,134
Trophies
0
Age
33
XP
1,394
Country
Cuba
thanks I will test it when I go home

just a question: why I must free all used RAM before exit? if I quit the app the 3ds does not blank it itself?

I code some Lua apps for PSP and never have to do that (I used Lua Player HM7 and that Lua Player haves a 17 480x272 pictures limit and never have clean the RAM, when I run another Lua homebrew it loads ok)
 

Rinnegatamante

Well-Known Member
Member
Joined
Nov 24, 2014
Messages
3,162
Trophies
2
Age
27
Location
Bologna
Website
rinnegatamante.it
XP
4,733
Country
Italy
thanks I will test it when I go home

just a question: why I must free all used RAM before exit? if I quit the app the 3ds does not blank it itself?

I code some Lua apps for PSP and never have to do that (I used Lua Player HM7 and that Lua Player haves a 17 480x272 pictures limit and never have clean the RAM, when I run another Lua homebrew it loads ok)

When you return to Homebrew Menu with ninjhax, there isn't an automatic garbage collection.
Also, if with your code you try to install 10.000 CIAs, you'll get a crash cause you don't free covers.
 

Chelsea_Fantasy

Someone who hates slow internet connections
OP
Member
Joined
Mar 25, 2014
Messages
1,134
Trophies
0
Age
33
XP
1,394
Country
Cuba
When you return to Homebrew Menu with ninjhax, there isn't an automatic garbage collection.
Also, if with your code you try to install 10.000 CIAs, you'll get a crash cause you don't free covers.

if I load the image over the previous image variable it should delete the older and replace it with the new one so I should have ilimited covers to load, right?

also, i'm using gateway and custom firmware to test this.

I don't use ninjhax, also..... ninjhax does not have am:u access
 

Rinnegatamante

Well-Known Member
Member
Joined
Nov 24, 2014
Messages
3,162
Trophies
2
Age
27
Location
Bologna
Website
rinnegatamante.it
XP
4,733
Country
Italy
if I load the image over the previous image variable it should delete the older and replace it with the new one so I should have ilimited covers to load, right?

Absolutely NOT.
Pointers (Userdata in LUA) != Memory blocks

I don't use ninjhax, also..... ninjhax does not have am:u access

If you think like this, so you'll create bad coded homebrews with bad memory management.
 
  • Like
Reactions: WhoAmI?

Chelsea_Fantasy

Someone who hates slow internet connections
OP
Member
Joined
Mar 25, 2014
Messages
1,134
Trophies
0
Age
33
XP
1,394
Country
Cuba
Absolutely NOT.
Pointers (Userdata in LUA) != Memory blocks

so I should free every image after the installation? that neven happen to me before in psp, but I will do what you said, you are the senpai

If you think like this, so you'll create bad coded homebrews with bad memory management.

just say that I dont use ninjhax for this homebrew. ninjhax cannot install cia files. I test it on GW and CFW
 

Chelsea_Fantasy

Someone who hates slow internet connections
OP
Member
Joined
Mar 25, 2014
Messages
1,134
Trophies
0
Age
33
XP
1,394
Country
Cuba
another question:
is there any way to pack the default pngs used by the software in the cia/3ds and load it from there (LWNOADV, LOWWADV, EXITING, LOADING, INSTBKG)?
this is to avoid create an extra folder in the root of the sd card

off topic: I'm creating a Mirai Nikki Theme for you. Can you give me a HD render of your avatar for the Theme?
 

Rinnegatamante

Well-Known Member
Member
Joined
Nov 24, 2014
Messages
3,162
Trophies
2
Age
27
Location
Bologna
Website
rinnegatamante.it
XP
4,733
Country
Italy
another question:
is there any way to pack the default pngs used by the software in the cia/3ds and load it from there (LWNOADV, LOWWADV, EXITING, LOADING, INSTBKG)?
this is to avoid create an extra folder in the root of the sd card

off topic: I'm creating a Mirai Nikki Theme for you. Can you give me a HD render of your avatar for the Theme?

Yes, it's possible but you need to recompile lpp-3ds.
 

Chelsea_Fantasy

Someone who hates slow internet connections
OP
Member
Joined
Mar 25, 2014
Messages
1,134
Trophies
0
Age
33
XP
1,394
Country
Cuba
I launch the corrected code that you give me in this thread and does not installs nothing.
remember that I was using the elf in the bin folder
may be I do something wrong compiling the cia or may be that el was for a 3ds version and not a cia version.
I am testing all in cia format, in GW and in CFW.

Also, I tried to load your BigRedMenu's index.lua in my compiled LPP3DS and it freezes at a black screen loading the software, so may be it is a fault of mine compiling the cia file

I take the elf that was in the "bin" folder in your GitHub repository, create an icon and banner, strip the elf like 3dbrew says and then compiled the CIA usin cia_workaround.rsf and desc app:4
did I do something wrong?

may be it's also an icon error. what flags should the icon have to be able to install cia files?
 

You may also like...

General chit-chat
Help Users
  • No one is chatting at the moment.
    sombrerosonic @ sombrerosonic: clocked higher of course +1