-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
205 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
*.bin | ||
*.cia | ||
*.cxi | ||
*.cfa | ||
cia-config.mk | ||
rom/ | ||
/seeddb.bin | ||
/*.cia | ||
/*.cxi | ||
/*.cfa | ||
# The "configured" file | ||
/config.mk | ||
# Directories in which the CIAs are extracted | ||
/*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
### Virtual Console repacking stuff | ||
|
||
## "Option" variables, intended to be overridden from the command line | ||
# (Or from `config.mk` if you want to persist those) | ||
|
||
# Clear this to let ctrtool speak its mind. It is quite talkative. | ||
VERBOSE_CTRTOOL := >/dev/null | ||
|
||
# Paths to the executables (mind that lack of slashes means PATH will be searched instead!) | ||
CTRTOOL := ctrtool | ||
MAKEROM := makerom | ||
|
||
|
||
# Include Configuration Settings | ||
|
||
include config.mk | ||
ifeq ($(strip ${rom_names}),) | ||
$(error Please set the `rom_names` variable in config.mk) | ||
endif | ||
ifeq ($(strip ${repo_path}),) | ||
$(error Please set the `repo_path` variable in config.mk) | ||
endif | ||
|
||
# Convenience lists | ||
rom_dirs := ${rom_names} | ||
cias := $(addsuffix .cia, ${rom_names}) | ||
orig_cias := $(addsuffix .orig.cia, ${rom_names}) | ||
game_cxis := $(addsuffix .game.cxi, ${rom_names}) | ||
manual_cfas := $(addsuffix .manual.cfa, ${rom_names}) | ||
# List of files upon which a CXI file depends | ||
cxi_deps = exheader.bin logo.lz plain.bin exefs/banner.bin exefs/code.bin $(shell [ -e romfs ] && find romfs -type f) | ||
|
||
|
||
# "Interface" rules | ||
|
||
# Build the CIAs. | ||
.PHONY: cia | ||
cia: ${cias} | ||
|
||
# Extract the `.orig.cia`s, but don't build the CIAs. | ||
# Does not re-extract if the directories if they are already present; use `distclean` for that. | ||
.PHONY: extract | ||
# Ok to depend on the directories, as this target is phony thus never up to date anyway | ||
extract: $(addsuffix /,${rom_dirs}) | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -f ${cias} ${game_cxis} ${manual_cfas} | ||
|
||
.PHONY: distclean | ||
distclean: clean | ||
rm -rf ${rom_dirs} | ||
|
||
|
||
# Actual rules | ||
|
||
# Rules that update the romfs files must run after this (since it extracts all original files), | ||
# so they are given an order-only dep on the directory (`%/` here). | ||
# Do NOT depend on it directly, as directory modification times update in unintuitive ways! | ||
# | ||
# This extracts the original CIA's contents, deletes the original ROM, and deletes all patch files. | ||
# (There are extra, un-needed patch files left in by the VC developers for the other games.) | ||
# | ||
# Silence `ctrtool`, which is VERY verbose by default (sadly that may also suppress debug info) | ||
%/ $(addprefix %/,${cxi_deps}): %.orig.cia seeddb.bin | ||
@mkdir -p $* | ||
${CTRTOOL} --cidx 0 \ | ||
--seeddb=seeddb.bin \ | ||
--exheader=$@exheader.bin \ | ||
--exefsdir=$@exefs \ | ||
--romfsdir=$@romfs \ | ||
--logo=$@logo.lz \ | ||
--plainrgn=$@plain.bin \ | ||
$< ${VERBOSE_CTRTOOL} | ||
${CTRTOOL} --cidx 1 \ | ||
--seeddb=seeddb.bin \ | ||
--romfsdir=$@manual \ | ||
$< ${VERBOSE_CTRTOOL} | ||
rm -f $@romfs/rom/* | ||
rm -f $@romfs/*.patch | ||
|
||
# romfs files have the pattern appear twice in the path, which breaks pattern rules; we have to use `eval` instead | ||
# Careful that the contents of the `define`s are expanded twice: | ||
# 1. In the `call` function, and | ||
# 2. In the `eval` function. | ||
|
||
define copy_patch_rule | ||
$(1)/romfs/$(1).patch: $${repo_path}/$(1).patch | $(1)/ | ||
mkdir -p $${@D} | ||
cp -T $$< $$@ | ||
endef | ||
$(foreach rom,${rom_names},$(eval $(call copy_patch_rule,${rom}))) | ||
|
||
define copy_rom_rule | ||
$(1)/romfs/rom/$(1): $${repo_path}/$(1).gbc | $(1)/ | ||
mkdir -p $${@D} | ||
cp -T $$< $$@ | ||
endef | ||
$(foreach rom,${rom_names},$(eval $(call copy_rom_rule,${rom}))) | ||
|
||
# This rule must be run in the "extracted" directory for it to find all the files | ||
define make_cxi_rule | ||
$(1).game.cxi: game.rsf $(1)/romfs/$(1).patch $(1)/romfs/rom/$(1) $(addprefix $(1)/,${cxi_deps}) | ||
env -C $(1)/ \ | ||
${MAKEROM} -f cxi -o ../$$@ -rsf ../$$< \ | ||
-exheader exheader.bin \ | ||
-logo logo.lz \ | ||
-plainrgn plain.bin \ | ||
-code exefs/code.bin \ | ||
-icon exefs/icon.bin \ | ||
-banner exefs/banner.bin | ||
endef | ||
$(foreach rom,${rom_names},$(eval $(call make_cxi_rule,${rom}))) | ||
|
||
# This must also be run in the "extracted" directory | ||
%.manual.cfa: manual.rsf | ||
env -C $* \ | ||
${MAKEROM} -f cfa -o ../$@ -rsf ../$< | ||
|
||
%.cia: %.game.cxi %.manual.cfa | ||
${MAKEROM} -f cia -o $@ -content $<:0:0 -content $*.manual.cfa:1:1 | ||
|
||
# Catch-all rules for files originating from the source repo | ||
|
||
${repo_path}/%: | ||
make -C ${@D} ${@F} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,78 @@ | ||
CIA building extension for Pret Pokemon Gen I / II Repos | ||
====================================== | ||
# CIA building extension for Pret Pokémon Gen I / II Repos | ||
|
||
This repo provides a simple extension that integrates the build of a Virtual Console .cia file to the pret pokemon Gen I / II repos, to ease the building of a VC .cia for your ROM Hack down to something as simple as `make cia`. | ||
This repo provides a simple extension that repackages a Nintendo 3DS Virtual Console (VC) `.cia` file using the built `.gbc`(s) and `.patch`(s) generated from the Pret Pokémon Gen I / II repos. This will ease the building of a VC `.cia` for your ROM Hack down to something as simple as typing `make`. | ||
|
||
Requirements | ||
------------ | ||
## Requirements | ||
|
||
* A recent [pokecrystal](https://github.com/pret/pokecrystal), [pokegold](https://github.com/pret/pokegold), [pokered](https://github.com/pret/pokered), or [pokeyellow](https://github.com/pret/pokeyellow) installation, that supports building Virtual Console patches. | ||
* An original (encrypted or decrypted) `.cia` file. | ||
* [ctrtool and makerom](https://github.com/profi200/Project_CTR) (Only master has been tested) | ||
* Obtain `seeddb.bin`, here is a link: [seeddb.bin](https://github.com/ihaveamac/3DS-rom-tools/raw/master/seeddb/seeddb.bin) | ||
* The hack's source repository. It must be based on a recent enough version of the original disassembly, so that it supports building Virtual Console patches: | ||
**Disassembly** | **Must have been updated to this commit or later** | ||
---------------------------------------------------|------------------------------------------------------- | ||
[pokered](https://github.com/pret/pokered) | [fe8d3c51a4056f0dd61dbef332ad9e714b82089a](https://github.com/pret/pokered/commit/fe8d3c51a4056f0dd61dbef332ad9e714b82089a) | ||
[pokeyellow](https://github.com/pret/pokeyellow) | [fbaa5c9d4b48c000a52860a8392fc423c4e312f9](https://github.com/pret/pokeyellow/commit/fbaa5c9d4b48c000a52860a8392fc423c4e312f9) | ||
[pokegold](https://github.com/pret/pokegold) | [3d58fb95569be74c6c229118a425fa22628f1dc3](https://github.com/pret/pokegold/commit/3d58fb95569be74c6c229118a425fa22628f1dc3) | ||
[pokecrystal](https://github.com/pret/pokecrystal) | [31c3c94d64e1ac1e40c95acfda7de8b99b4f302b](https://github.com/pret/pokecrystal/commit/31c3c94d64e1ac1e40c95acfda7de8b99b4f302b) | ||
* An original (encrypted or decrypted) `.cia` file for each version that you want to produce—see further below. | ||
* [ctrtool](https://github.com/3DSGuy/Project_CTR) ctrtool v1.0.3 or later. | ||
* [makerom](https://github.com/3DSGuy/Project_CTR) makerom v0.18 or later. | ||
* `seeddb.bin`. It can be obtained [from this link](https://github.com/ihaveamac/3DS-rom-tools/raw/master/seeddb/seeddb.bin). | ||
|
||
Obtaining the original file is outside of the scope of this document. It can be legally obtained by extracting it from your console through tools such as GodMode9 and/or FunkyCIA. | ||
|
||
Run `make` to build both `ctrtool` and `makerom`, and put them in your `$PATH`. | ||
## Installation | ||
|
||
Installation | ||
------------ | ||
First, [clone this repository](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository), and `cd` into it. | ||
|
||
To install, you need to clone the `poke-cia` repo into your Pret repository. The following is a pokecrystal example: | ||
Next, you will need to create your `config.mk` file by using `config.mk.template` as a base. | ||
|
||
```shell | ||
cd <path to pokecrystal> | ||
git clone https://github.com/vulcandth/poke-cia poke-cia | ||
echo "-include poke-cia/cia.mk" >> Makefile | ||
```console | ||
$ cp config.mk.template config.mk | ||
``` | ||
|
||
Next you will need to create your `poke-cia/cia-config.mk` file by using `poke-cia/cia-config.mk.template` as a base. | ||
Modify this new `config.mk` file using a text editor of your choice. | ||
|
||
```shell | ||
cp ./poke-cia/cia-config.mk.template ./poke-cia/cia-config.mk | ||
``` | ||
- Define `rom_names` to match the name of the ROM you want to build the `.cia` from, sans file extension. | ||
For example, for Pokémon Crystal, you can uncomment one of the example lines: | ||
|
||
Modify your `/poke-cia/cia-config.mk` file using a text editor of your choice, adjusting the following line to match the pret repository your are using. In this example we are using `pret/pokecrystal` | ||
```makefile | ||
rom_names := pokecrystal11 | ||
``` | ||
|
||
```makefile | ||
vc_name := $(vc_crystal_name) | ||
``` | ||
(There should not be more than one uncommented line at a given time.) | ||
You can also build more than one `.cia` at a time! | ||
Simply write a space-separated list of names instead: | ||
|
||
```makefile | ||
rom_names := redstar bluestar | ||
``` | ||
|
||
- Still in that same file, you must also set the `repo_path` variable to point to the repository containing the ROMs, for example: | ||
|
||
```makefile | ||
repo_path := ../pokered | ||
``` | ||
|
||
(Relative paths must be relative to the `poke-cia` directory.) | ||
|
||
Copy your original dumped .cia files to `poke-cia/<build_name>.orig.cia`. Where `<build_name>` represents the names of the `.gbc` files that is output from your installed pret repository. In the case of Pokemon Crystal, it should be: | ||
Copy and rename your original dumped .cia files to `<build_name>.orig.cia`, where `<build_name>` is one of the names you put in `rom_names`. | ||
For example, for Pokémon Crystal, it should be `pokecrystal11.orig.cia`. | ||
|
||
Finally, place your obained `seeddb.bin` file inside your `poke-cia` directory. | ||
|
||
## Usage | ||
|
||
Now, you can run `make` and be on your merry way! | ||
The new `.cia` files will be generated in the same directory. | ||
Both `makerom` and `ctrtool` must either be in your PATH, or you can pass the paths as arguments; for example: | ||
|
||
```console | ||
$ make MAKEROM=../ctrtool-v1.0.1/makerom/makerom CTRTOOL=../ctrtool-v1.0.1/ctrtool/bin/ctrtool | ||
``` | ||
|
||
`poke-cia/pokecrystal11.orig.cia` | ||
It is also possible to specify these variables in `config.mk` instead, which saves the trouble of re-typing them every time. | ||
|
||
Finally place your obained `seeddb.bin` file inside your `poke-cia` directory. | ||
## Special Credits | ||
|
||
Now you can run `make cia` and be on your merry way! | ||
I would like to give special credits to the following: | ||
* @mid-kid originally came up with the idea of this tool and this extension is developed based on his orig repo. | ||
* @ISSOtm spent a lot of time helping to restructure the extension, and getting it ready for release. | ||
* @jakcron went out of their way to download not only one, but two other repos (this and pret) to help resolve a bug in ctrtool. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Uncomment one of the following lines depending on your repo, or write your own! | ||
#rom_names := pokered pokeblue | ||
#rom_names := pokeyellow | ||
#rom_names := pokegold pokesilver | ||
#rom_names := pokecrystal11 | ||
#rom_names := my_awesome_hack | ||
|
||
# Write the path to the repo here. Here are some examples: | ||
#repo_path := ../pokered | ||
#repo_path := /drives/c/Users/ISSOtm/Documents/pokecrystal | ||
#repo_path := /d/vulcandth/pkmn/pokedarkgold |