[HELP] Building .cia from Zelda ALBW PAL (modified files) (for 4.5 CFW)

Discussion in '3DS - ROM Hacking, Translations and Utilities' started by Anton299, Mar 9, 2015.

  1. Anton299
    OP

    Anton299 GBAtemp Regular

    Member
    120
    38
    Jan 18, 2012
    Kiev
    Could anybody explain how to build fully working Zelda ALBW (PAL) .cia from decrypted files with MODIFIED data (translation), please?

    After decrypting ROM file, replacing some files in "romfs\EU_English" folder and rebuilding RomFS.bin with this batch file:

    Code:
    [USER=325063]Echo[/USER] off
    SETLOCAL ENABLEEXTENSIONS
    set ATTR=%~a1
    set DIRATTR=%ATTR:~0,1%
    if /I "%DIRATTR%" equ "d" (
      goto :begin
    ) else (
      echo NOT A FOLDER!
    )
    pause
    exit /b
     
    :begin
    if exist "%~dp0%~n1.bin" goto :error
    echo.
    echo.
    [USER=325063]Echo[/USER] PACKING ROMFS BINARY... PLEASE WAIT
    "%~dp0program\ctr_makerom32" -rsf "%~dp0Program\Child.rsf" -f data -DROMFS_ROOT="%~dp1%~n1" -DPROGRAM_ID=0x1234 -o "%~dp0%~n1.cfa"
    call :getFilesize "%~dp0%~n1.cfa
    set /a fileSize-=4096
    echo.
    echo.
    [USER=325063]Echo[/USER] ALMOST DONE... PLEASE WAIT
    "%~dp0program\tail" -c %fileSize% "%~dp0%~n1.cfa" 1> "%~dp0%~n1.bin"
    del "%~dp0%~n1.cfa
    del "%~dp0%~n1.cfa.xml
    MSG * DONE!
    exit /b
     
     
    :getFilesize
    set filesize=%~z1
    exit /b
     
    :error
    echo.
    echo.
    echo A FILE WITH THIS NAME ALREADY EXISTS!
    echo.
    pause
    exit /b
    

    I've managed to build .cia and get it to work on Palatine CFW with this batch file:

    Code:
    makerom -f ncch -rsf albw.rsf -target t -desc app:4 -icon exefs\icon.bin -banner exefs\banner.bin -exefslogo -code exefs\code.bin -exheader exheader.bin -romfs romfs.bin -o LoZ-ALBW.cxi
    makerom -f cia -rsf albw.rsf -target t -content LoZ-ALBW.cxi:0:0 -content manual.cfa:1:1 -o albw.cia
    
    With this Makerom:
    CTR MAKEROM 0.13 (C) 3DSGuy 2014 (662 Kb (678 274 bytes).

    And with this "albw.RSF":

    Code:
     
    BasicInfo:
      Title                  : "LoZ-ALBW-EU"
      CompanyCode            : "00"
      ProductCode            : "CTR-P-BZLP"
      ContentType            : Application # Application / SystemUpdate / Manual / Child / Trial
      Logo                  : Nintendo # Nintendo / Licensed / Distributed / iQue / iQueForSystem
     
    TitleInfo:
      UniqueId              : 0x0ec4
      Category              : Application
     
    Option:
      UseOnSD                : true
      EnableCompress        : true
      FreeProductCode        : true
      EnableCrypt            : false
      MediaFootPadding      : true
     
    AccessControlInfo:
      ExtSaveDataId: 0x0ec4 # same as UniqueId
      SystemSaveDataId1: 0x00000000
      SystemSaveDataId2: 0x00000000
      OtherUserSaveDataId1: 0x00000
      OtherUserSaveDataId2: 0x00000
      OtherUserSaveDataId3: 0x00000
      UseOtherVariationSaveData : false
     
    SystemControlInfo:
      SaveDataSize: 512KB # plaintext exheader
      RemasterVersion: 0 # plaintext exheader
      StackSize: 0x00040000 # plaintext exheader
      JumpId: 0x0004000000030800L # plaintext exheader (0x00040000000EC400L)
     
    

    Questions:
    1. After installing CIA there is NO GIFT ICON appears (a white frame just "flashes" and disappears immediately, instead of new gift/game icon). The game only runs from BigBlueMenu.
    2. So, I can't exit the game in a normal way and see if there is a manual I'm trying to add with "-content manual.cfa:1:1" - pressing HOME button just causes the game to hang. I can quit game only by pressing Power button and power off the console.
    3. I've extracted manual (*.cfa file) from original (and encrypted) ROM using Rom_tool - "rom_tool -x manual romname.3ds". Is this a right way to do so?
    4. WHY there are no gift/game icon appears after installing .cia? What should I do to make it appear? I've tried everything, hundreds of times - no icon appears... EVER...
    5. This line in rsf file -> "JumpId: 0x0004000000030800L # plaintext exheader (0x00040000000EC400L)" should be "JumpId: 0x00040000000EC400L" or not?
    (it seems to work in both cases, though). I got that rsf somewhere here at gbatemp, but for US version of the game and edited it for EUR version. Maybe something wrong with rsf?..

    Help, please...
     
  2. Stuckman23

    Stuckman23 Member

    Newcomer
    19
    3
    Feb 10, 2015
    can you give any modified files 4 test? I'll try to build cia. If I can, I will write you how.
     
  3. gamesquest1

    gamesquest1 Nabnut

    Member
    GBAtemp Patron
    gamesquest1 is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    14,148
    9,501
    Sep 23, 2013
    sounds like you have it set up for the wrong region, basically if a game doesnt match the region of your console it won't show up on the homescreen, but can be booted from devmenu
     
  4. Asia81

    Asia81 In my Ecchi World <3

    Member
    5,133
    2,560
    Nov 15, 2014
    France
    Albi
    Try to rebuild your romfs with scire'sM tool : RomFS Builder
     
  5. ChrisX930

    ChrisX930 Banned

    Banned
    788
    317
    Sep 3, 2013
    Gambia, The
    Germany
    This tool doesn't worked for me with "Harvest Moon - A New Beginning".
    I built a romfs with this romfs-builder. After I started the Game with the rebuilded romfs, I only got a freeze + Black Screen.


    I prefer to use this tool.
    <snip>

    Download it, copy the romfs-folder in the root of this and start "Make a new ROMFS.bat".
    It will build a working romfs.bin for your game.
     
  6. Anton299
    OP

    Anton299 GBAtemp Regular

    Member
    120
    38
    Jan 18, 2012
    Kiev
    It's PAL.
    My console is PAL, translated game is PAL, also.
    This is PAL, right? )
    "CTR-P-BZLP" and UniqueId : 0x0ec4
    Also, I've checked original ROM in 3DExplorer, and it says that it EU, too.

    I'm really confused with that "no icon"...

    I use ctr_makerom32 (50 kb) for RomFS build from... well... I guess its's from SDK?

    See attached file.
    Extract and replace in decrypted PAL rom: icon.bin in ExeFS folder, 5 *.szs files in RomFS\EU_English folder.
     

    Attached Files:

  7. gamesquest1

    gamesquest1 Nabnut

    Member
    GBAtemp Patron
    gamesquest1 is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    14,148
    9,501
    Sep 23, 2013
    try this i think you had it set to US
     

    Attached Files:

  8. Anton299
    OP

    Anton299 GBAtemp Regular

    Member
    120
    38
    Jan 18, 2012
    Kiev
    I'll try and post results, thanks.

    I've changed a picture in icon file... Did I really changed it in US icon.bin? :wacko: ...gotta check it...
     
  9. Anton299
    OP

    Anton299 GBAtemp Regular

    Member
    120
    38
    Jan 18, 2012
    Kiev
    gamesquest1 - it works perfectly with you icon.bin! Manual works, too!
    It seems that I really played with the wrong icon... shame on me... (

    But tell me, please, how did you fix my icon?



    icon_ru.jpg
     
  10. gamesquest1

    gamesquest1 Nabnut

    Member
    GBAtemp Patron
    gamesquest1 is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    14,148
    9,501
    Sep 23, 2013
    In the icon file if you go to 0x2018 that is the region byte, 3dsbrew has the relevant info, yours was set to 02 which is US, I just changed it to 04 for EU.....pretty sure setting it to 7F will make the CIA region free
     
  11. Anton299
    OP

    Anton299 GBAtemp Regular

    Member
    120
    38
    Jan 18, 2012
    Kiev
    Thank you!
    One damn byte... and two weeks of trying to build working cia...
    Thanks again for your help!
     
    cearp likes this.
  12. gamesquest1

    gamesquest1 Nabnut

    Member
    GBAtemp Patron
    gamesquest1 is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    14,148
    9,501
    Sep 23, 2013
    Np, good luck with your translation :)
     
    Anton299 likes this.
  13. Anton299
    OP

    Anton299 GBAtemp Regular

    Member
    120
    38
    Jan 18, 2012
    Kiev
    I'll bump this, because I'm in trouble again... )
    Now I can't build working .3ds rom.

    Here is my .bat file:

    This part seems OK and it builds .cxi file:
    Code:
    makerom -f ncch -rsf albw_3ds.rsf -target t -desc app:4 -icon exefs\icon.bin -banner exefs\banner.bin -exefslogo -code exefs\code.bin -exheader exheader.bin -romfs romfs.bin -o LoZ-ALBW_RU.cxi
    But after that I can't build a .cci container (.3ds rom), it always fails:
    Code:
    makerom -f cci -i LoZ-ALBW_RU.cxi:0:0 -i manual.cfa:1:1 -i updatedata.cfa:2:2 -o LoZ-ALBW_RU.3ds
    It prints this error:
    [NCCH ERROR] Failed to load ncch aes key
    [RESULT] Failed to build CCI

    My .rsf file:

    Code:
    BasicInfo:
      Title                  : "LoZ-ALBW-EU" #CHANGE ME
      CompanyCode            : "00" #CHANGE ME
      ProductCode            : "CTR-P-BZLP" #CHANGE ME
      ContentType            : Application # Application / SystemUpdate / Manual / Child / Trial
      Logo                    : Nintendo # Nintendo / Licensed / Distributed / iQue / iQueForSystem
     
    TitleInfo:
      UniqueId                : 0x0ec4 #CHANGE ME
      Category                : Application # Application / SystemApplication / Applet / Firmware / Base / DlpChild / Demo / Contents / SystemContents / SharedContents / AddOnContents / Patch / AutoUpdateContents
     
    CardInfo:
      MediaSize              : 1GB # 128MB / 256MB / 512MB / 1GB / 2GB / 4GB / 8GB / 16GB / 32GB #CHANGE ME
      MediaType              : Card1 # Card1 / Card2 #CHANGE ME
      CardDevice              : NorFlash # NorFlash(Pick this if you use savedata) / None (Choose None if it's a card2 game)
     
     
    Option:
      UseOnSD                : false # true if App is to be installed to SD #CHANGE ME
      EnableCompress          : true # Compresses exefs code #CHANGE ME
      FreeProductCode        : true # Removes limitations on ProductCode #CHANGE ME
      EnableCrypt            : false # Enables encryption for NCCH and CIA #CHANGE ME
      MediaFootPadding        : true # If true CCI files are created with padding #CHANGE ME
     
    ExeFs: # these are the program segments from the ELF, check your elf for the appropriate segment names
      ReadOnly:
      - .rodata
      - RO
      ReadWrite:
      - .data
      - RO
      Text:
      - .init
      - .text
      - STUP_ENTRY
     
    PlainRegion: # only used with SDK ELFs
    - .module_id
     
    AccessControlInfo:
      #UseExtSaveData : true
      ExtSaveDataId: 0x0ec4
      SystemSaveDataId1: 0x00000000
      SystemSaveDataId2: 0x00000000
      OtherUserSaveDataId1: 0x00000
      OtherUserSaveDataId2: 0x00000
      OtherUserSaveDataId3: 0x00000
      UseOtherVariationSaveData : true
      #UseExtendedSaveDataAccessControl: true
      #AccessibleSaveDataIds: [0x101, 0x202, 0x303, 0x404, 0x505, 0x606]
      FileSystemAccess:
      #- Boss
      #- CardBoard
      #- CategoryFileSystemTool
      #- CategoryHardwareCheck
      #- CategoryHomeMenu
      #- CategorySystemApplication
      #- CategorySystemSettings
      #- Core
      #- CtrNandRo
      #- CtrNandRoWrite
      #- CtrNandRw
      #- Debug
      #- DirectSdmc
      #- DirectSdmcWrite
      #- ExportImportIvs
      #- SaveDataMove
      #- Shell
      #- Shop
      #- SwitchCleanup
      #- TwlCardBackup
      #- TwlNandData
     
    SystemControlInfo:
      SaveDataSize: 512KB #CHANGE ME
      RemasterVersion: 0
      StackSize: 0x40000
      JumpId: 0x00040000000EC400L
    
    I've managed to build .3ds file once, with this .rsf, I guess... (it works for cia creating):
    Code:
    BasicInfo:
      Title                  : "LoZ-ALBW-EU"
      CompanyCode            : "00"
      ProductCode            : "CTR-P-BZLP"
      ContentType            : Application # Application / SystemUpdate / Manual / Child / Trial
      Logo                    : Nintendo # Nintendo / Licensed / Distributed / iQue / iQueForSystem
     
    TitleInfo:
      UniqueId                : 0x0ec4
      Category                : Application
     
    Option:
      UseOnSD                : true # true if App is to be #installed to SD
      EnableCompress          : true # Compresses exefs code
      FreeProductCode        : true # Removes limitations on ProductCode
      EnableCrypt            : false # Enables encryption for NCCH and CIA
      MediaFootPadding        : true # If true CCI files are created with padding
     
    AccessControlInfo:
      ExtSaveDataId: 0x0ec4 # same as UniqueId
      SystemSaveDataId1: 0x00000000 # plaintext exheader
      SystemSaveDataId2: 0x00000000 # plaintext exheader
      OtherUserSaveDataId1: 0x00000 # plaintext exheader
      OtherUserSaveDataId2: 0x00000 # plaintext exheader
      OtherUserSaveDataId3: 0x00000 # plaintext exheader
      UseOtherVariationSaveData : false
     
    SystemControlInfo:
      SaveDataSize: 512KB # plaintext exheader
      RemasterVersion: 0 # plaintext exheader
      StackSize: 0x00040000 # plaintext exheader
      JumpId: 0x00040000000EC400L # plaintext exheader (0x00040000000EC400L)
    
    ...But it shows me a white square instead of icon and no title in Gateway game list.
    The is NO problem with microSD. Original game works just fine.

    Please, help me to figure out, what's wrong?

    PS. In "icon.bin" at offset 2018 - "region byte" = "0C" in LoZ:ALBW (PAL). Why it's not "04"?
     
  14. cearp

    cearp the ticket master

    Member
    7,550
    4,813
    May 26, 2008
    Tuvalu
    europe = 4
    australia = 8
    4+8 = c
     
    Anton299 likes this.
  15. Anton299
    OP

    Anton299 GBAtemp Regular

    Member
    120
    38
    Jan 18, 2012
    Kiev
    Still can't rebuild .3ds (.cci) ROM with manual.cfa included..
    Every time I get this error:

    [NCCH ERROR] Failed to load ncch aes key
    [RESULT] Failed to build CCI

    EnableCrypt: false- target t

    Any suggestions, please?