Skip to content

Commit

Permalink
make updates pret and new commands (#4)
Browse files Browse the repository at this point in the history
Final Changelist:

Renamed clean -> tidy
Renamed distclean -> clean
Added prettidy
Added pretclean
Added pretupdate
made .PHONY pretupdate a order-only perquisite of .patch and .gbc to tell pret to check for updates prior to building.
made ../ the default repo location, with the intent to build poke-cia inside the pret repo.
  • Loading branch information
vulcandth authored Apr 1, 2022
1 parent 1861abe commit e67c5fe
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 23 deletions.
31 changes: 24 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,31 @@ cia: ${cias}
# Ok to depend on the directories, as this target is phony thus never up to date anyway
extract: $(addsuffix /,${rom_dirs})

.PHONY: clean
clean:
# Calls for the pret repo to check for updates, then checks if the .cias need to be updated
.PHONY: pretupdate
pretupdate:
$(MAKE) -C ${repo_path} $(subst poke,,${rom_names}) $(subst poke,,$(addsuffix _vc, ${rom_names}))

# Tides up poke-cia
.PHONY: tidy
tidy:
rm -f ${cias} ${game_cxis} ${manual_cfas}

.PHONY: distclean
distclean: clean
# Cleans the poke-cia directory back to a near pristine state.
.PHONY: clean
clean: tidy
rm -rf ${rom_dirs}

# Tidies up the pret repo and the poke-cia repo.
.PHONY: prettidy
prettidy: tidy
$(MAKE) -C ${repo_path} tidy

# Cleans the pret repo and the poke-cia repo.
.PHONY: pretclean
pretclean: clean
$(MAKE) -C ${repo_path} clean


# Actual rules

Expand Down Expand Up @@ -85,14 +102,14 @@ distclean: clean
# 2. In the `eval` function.

define copy_patch_rule
$(1)/romfs/$(1).patch: $${repo_path}/$(1).patch | $(1)/
$(1)/romfs/$(1).patch: $${repo_path}/$(1).patch | $(1)/ pretupdate
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)/
$(1)/romfs/rom/$(1): $${repo_path}/$(1).gbc | $(1)/ pretupdate
mkdir -p $${@D}
cp -T $$< $$@
endef
Expand Down Expand Up @@ -123,4 +140,4 @@ $(foreach rom,${rom_names},$(eval $(call make_cxi_rule,${rom})))
# Catch-all rules for files originating from the source repo

${repo_path}/%:
make -C ${@D} ${@F}
$(MAKE) -C ${@D} ${@F}
48 changes: 33 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,20 @@ This repo provides a simple extension that repackages a Nintendo 3DS Virtual Con
## Requirements

* 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) | [fe8d3c5](https://github.com/pret/pokered/commit/fe8d3c51a4056f0dd61dbef332ad9e714b82089a)
[pokeyellow](https://github.com/pret/pokeyellow) | [fbaa5c9](https://github.com/pret/pokeyellow/commit/fbaa5c9d4b48c000a52860a8392fc423c4e312f9)
[pokegold](https://github.com/pret/pokegold) | [3d58fb9](https://github.com/pret/pokegold/commit/3d58fb95569be74c6c229118a425fa22628f1dc3)
[pokecrystal](https://github.com/pret/pokecrystal) | [31c3c94](https://github.com/pret/pokecrystal/commit/31c3c94d64e1ac1e40c95acfda7de8b99b4f302b)

| **Disassembly** | **This commit or later** |
| -------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
| [pokered](https://github.com/pret/pokered) | [fe8d3c5](https://github.com/pret/pokered/commit/fe8d3c51a4056f0dd61dbef332ad9e714b82089a) |
| [pokeyellow](https://github.com/pret/pokeyellow) | [fbaa5c9](https://github.com/pret/pokeyellow/commit/fbaa5c9d4b48c000a52860a8392fc423c4e312f9) |
| [pokegold](https://github.com/pret/pokegold) | [3d58fb9](https://github.com/pret/pokegold/commit/3d58fb95569be74c6c229118a425fa22628f1dc3) |
| [pokecrystal](https://github.com/pret/pokecrystal) | [31c3c94](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** `.cia` file dump 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.
Expand All @@ -32,26 +37,26 @@ Modify this new `config.mk` file using a text editor of your choice.

- 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:

```makefile
rom_names := pokecrystal11
```

(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 := magenta turquoise
```

- Still in that same file, you must also set the `repo_path` variable to point to the repository containing the ROMs, for example:

- Still in that same file, you must also set the `repo_path` variable to point to the repository containing the ROMs: (The default `repo_path` setting assumes you are cloning into the pret repo)
```makefile
repo_path := ../pokered
repo_path := ../
```

(Relative paths must be relative to the `poke-cia` directory.)
(Relative paths must be relative to the `poke-cia` directory. `../` means the directory above the poke-cia directory.)

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`.
Expand All @@ -70,9 +75,22 @@ $ make MAKEROM=../ctrtool-v1.0.1/makerom/makerom CTRTOOL=../ctrtool-v1.0.1/ctrto

It is also possible to specify these variables in `config.mk` instead, which saves the trouble of re-typing them every time.

The following is a list of notable poke-cia commands:

`make extract`: Will simply extract the `.orig.cia` files, but will not automatically rebuild them into a `.cia`. This is useful if you want to manually update files before rebuilding. Simply run `make` when you are done to finish building.

`make tidy`: Removes any built `.cia`, `.cxi`, or `cfa` files in the poke-cia repo.

`make prettidy`: Performs the same function as `make tidy` above, but also asks the pret repo to run it's version of `make tidy`.

`make clean`: Performs the same function as `make tidy`, but also deletes the extracted rom directories in the poke-cia repo.

`make pretclean`: Performs the same function as `make clean` above, but also asks the pret repo to run it's own version of `make clean`.

## Special Credits

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.
* @jakcron went out of their way to troubleshoot our repos to help resolve a bug in thre prequisite tool ctrtool.
4 changes: 3 additions & 1 deletion config.mk.template
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
#rom_names := pokecrystal11
#rom_names := my_awesome_hack

# Write the path to the repo here. Here are some examples:
# Write the path to the repo here. Here are some examples. Default assumes that
# you cloned poke-cia inside the pret repo. ../ means the directory above this one:
repo_path := ../
#repo_path := ../pokered
#repo_path := /drives/c/Users/ISSOtm/Documents/pokecrystal
#repo_path := /d/vulcandth/pkmn/pokedarkgold

0 comments on commit e67c5fe

Please sign in to comment.