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,141
Trophies
0
Age
34
XP
1,513
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: 188

Chelsea_Fantasy

Someone who hates slow internet connections
OP
Member
Joined
Mar 25, 2014
Messages
1,141
Trophies
0
Age
34
XP
1,513
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,141
Trophies
0
Age
34
XP
1,513
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,141
Trophies
0
Age
34
XP
1,513
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
29
Location
Bologna
Website
rinnegatamante.it
XP
4,857
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,141
Trophies
0
Age
34
XP
1,513
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
29
Location
Bologna
Website
rinnegatamante.it
XP
4,857
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,141
Trophies
0
Age
34
XP
1,513
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
29
Location
Bologna
Website
rinnegatamante.it
XP
4,857
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,141
Trophies
0
Age
34
XP
1,513
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,141
Trophies
0
Age
34
XP
1,513
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
29
Location
Bologna
Website
rinnegatamante.it
XP
4,857
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,141
Trophies
0
Age
34
XP
1,513
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?
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
  • Xdqwerty @ Xdqwerty:
    also gonna install twilight menu in my r4 flashcard
  • Psionic Roshambo @ Psionic Roshambo:
    One thing that just occurred to me.... The sound on the 2600 sucked less back then the harsh sound we hear now is from infinitely better speakers we have now, back when the 2600 was new speakers produced a almost muffled sound, like CRTs made old graphics look slightly better.
  • Psionic Roshambo @ Psionic Roshambo:
    I wonder if I could recommend that to some emulation devs that perhaps the sound could use some smoothing out to simulate those old TVs
  • Psionic Roshambo @ Psionic Roshambo:
    I think a few of the early systems could benefit from that, at least up to the 8 bit generation, by the 16 bit generation I think TVs had gotten a lot better in almost every way
  • Xdqwerty @ Xdqwerty:
    i dont have an sd card adapter but I have an usb sd card adapter
  • K3Nv2 @ K3Nv2:
    Old people games
  • Xdqwerty @ Xdqwerty:
    its not the one that comes with the r4
  • Xdqwerty @ Xdqwerty:
    doesnt work (my flashcard is from r4isdhc.com)
  • Xdqwerty @ Xdqwerty:
    might install ysmenu first
  • Psionic Roshambo @ Psionic Roshambo:
    Try Wood firmware
  • Psionic Roshambo @ Psionic Roshambo:
    For your R4
  • Psionic Roshambo @ Psionic Roshambo:
    It's old but it's the best firmware out for DS stuff
  • Xdqwerty @ Xdqwerty:
    it says it only works for the original R4, R4i Gold (r4ids.cn), R4iDSN (r4idsn.com) and Acekard R.P.G.
  • Xdqwerty @ Xdqwerty:
    nvm it does support mine
  • Xdqwerty @ Xdqwerty:
    but why choose it over ysmenu @Psionic Roshambo?
  • Xdqwerty @ Xdqwerty:
    bc im stupid?
  • Xdqwerty @ Xdqwerty:
    yea ik im stupid
  • Xdqwerty @ Xdqwerty:
    good night
  • Psionic Roshambo @ Psionic Roshambo:
    Just give it a try, but honestly if you have a 3DS you can play DS games without a card just off the internal SD card
  • Psionic Roshambo @ Psionic Roshambo:
    Slightly slower loading but a bit more convenient
  • BakerMan @ BakerMan:
    guys, my fuckin headphones have an out of place speaker
  • K3Nv2 @ K3Nv2:
    Did you try wearing them?
    K3Nv2 @ K3Nv2: https://youtube.com/shorts/eJV6GaIEgd4?si=ciLPnlhfd7XcrxQn