-
Notifications
You must be signed in to change notification settings - Fork 4
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
0 parents
commit ee5bd5b
Showing
73 changed files
with
26,606 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# z64compress | ||
|
||
`z64compress` is a program for compressing Zelda 64 roms: be they retail, hacked traditionally, or custom-built from the [`Ocarina of Time`](https://github.com/zeldaret/oot) or [`Majora's Mask`](https://github.com/zeldaret/mm) reverse engineering projects. It is written in highly efficient C and leverages the power of multithreading to make compression as fast as possible. To reduce overhead on subsequent compressions, an optional cache directory can be specified. | ||
|
||
In addition to the default `yaz`, it supports some faster and more compact algorithms such as `lzo`, `ucl`, and `aplib`. In order to use these, grab patches or code from my [`z64enc` repository](https://github.com/z64me/z64enc). | ||
|
||
If you add an algorithm, please make sure `valgrind` reports no memory leaks or other errors before making a pull request. Thank you! | ||
|
||
## Usage | ||
This is a command line application. Learn from these common examples and adapt the arguments to your needs: | ||
``` | ||
compressing oot debug | ||
--in "path/to/in.z64" | ||
--out "path/to/out.z64" | ||
--mb 32 | ||
--codec yaz | ||
--cache "path/to/cache" | ||
--dma "0x12F70,1548" | ||
--compress "9-14,28-END" | ||
--threads 4 | ||
compressing oot ntsc 1.0 | ||
--in "path/to/in.z64" | ||
--out "path/to/out.z64" | ||
--mb 32 | ||
--codec yaz | ||
--cache "path/to/cache" | ||
--dma "0x7430,1526" | ||
--compress "10-14,27-END" | ||
--threads 4 | ||
compressing mm usa | ||
--in "path/to/in.z64" | ||
--out "path/to/out.z64" | ||
--mb 32 | ||
--codec yaz | ||
--cache "path/to/cache" | ||
--dma "0x1A500,1568" | ||
--compress "10-14,23,24,31-END" | ||
--skip "1127" | ||
--repack "15-20,22" | ||
--threads 4 | ||
``` | ||
|
||
## Arguments | ||
``` | ||
--in uncompressed input rom | ||
--out compressed output rom | ||
--mb how many mb the compressed rom should be | ||
--codec currently supported codecs | ||
yaz | ||
ucl | ||
lzo | ||
aplib | ||
* to use non-yaz codecs, find patches | ||
and code on my z64enc repo | ||
--cache is optional and won't be created if | ||
no path is specified (having a cache | ||
makes subsequent compressions faster) | ||
* pro-tip: linux users who don't want a | ||
cache to persist across power cycles | ||
can use the path "/tmp/z64compress" | ||
--dma specify dmadata address and count | ||
--compress enable compression on specified files | ||
--skip disable compression on specified files | ||
--repack handles Majora's Mask archives | ||
--threads optional multithreading; | ||
exclude this argument to disable it | ||
arguments are executed as they | ||
are parsed, so order matters! | ||
``` | ||
|
||
## Building | ||
I have included shell scripts for building Linux and Windows binaries. Windows binaries are built using a cross compiler ([I recommend `MXE`](https://mxe.cc/)). | ||
|
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,14 @@ | ||
# build compression functions (slow) | ||
gcc -DNDEBUG -s -Ofast -flto -lm -c -Wall src/enc/*.c src/enc/lzo/*.c src/enc/ucl/comp/*.c src/enc/apultra/*.c | ||
mkdir -p o | ||
mv *.o o | ||
|
||
# build everything else | ||
gcc -o z64compress -DNDEBUG src/*.c o/*.o -Wall -Wextra -s -Os -flto -lpthread | ||
|
||
# move to bin directory | ||
mkdir -p bin/linux64 | ||
mv z64compress bin/linux64 | ||
|
||
|
||
|
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,14 @@ | ||
# build compression functions (slow) | ||
gcc -m32 -DNDEBUG -s -Ofast -flto -lm -c -Wall src/enc/*.c src/enc/lzo/*.c src/enc/ucl/comp/*.c src/enc/apultra/*.c | ||
mkdir -p o | ||
mv *.o o | ||
|
||
# build everything else | ||
gcc -m32 -o z64compress -DNDEBUG src/*.c o/*.o -Wall -Wextra -s -Os -flto -lpthread | ||
|
||
# move to bin directory | ||
mkdir -p bin/linux32 | ||
mv z64compress bin/linux32 | ||
|
||
|
||
|
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,12 @@ | ||
# build compression functions (slow) | ||
~/c/mxe/usr/bin/i686-w64-mingw32.static-gcc -DNDEBUG -s -Ofast -flto -lm -c -Wall src/enc/*.c src/enc/lzo/*.c src/enc/ucl/comp/*.c src/enc/apultra/*.c | ||
mkdir -p o | ||
mv *.o o | ||
|
||
# build everything else | ||
~/c/mxe/usr/bin/i686-w64-mingw32.static-gcc -o z64compress.exe -DNDEBUG src/*.c o/*.o -Wall -Wextra -s -Os -flto -lpthread -mconsole -municode | ||
|
||
# move to bin directory | ||
mkdir -p bin/win32 | ||
mv z64compress.exe bin/win32 | ||
|
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,46 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include <stdlib.h> | ||
#include "apultra/libapultra.h" | ||
|
||
static void compression_progress(long long nOriginalSize, long long nCompressedSize) { | ||
/* do nothing */ | ||
} | ||
|
||
int | ||
aplenc( | ||
void *_src | ||
, unsigned src_sz | ||
, void *_dst | ||
, unsigned *dst_sz | ||
, void *_ctx | ||
) | ||
{ | ||
unsigned char *src = _src; | ||
unsigned char *dst = _dst; | ||
int nMaxCompressedSize = apultra_get_max_compressed_size(src_sz); | ||
apultra_stats stats; | ||
|
||
int hlen = 8; /* header length; required due to MM's archives */ | ||
memset(dst, 0, hlen); | ||
memcpy(dst, "APL0", 4); | ||
dst[4] = (src_sz >> 24); | ||
dst[5] = (src_sz >> 16); | ||
dst[6] = (src_sz >> 8); | ||
dst[7] = (src_sz >> 0); | ||
|
||
*dst_sz = apultra_compress( | ||
src | ||
, dst + hlen | ||
, src_sz | ||
, nMaxCompressedSize | ||
, 0 /* flags */ | ||
, compression_progress | ||
, &stats | ||
); | ||
|
||
*dst_sz = *dst_sz + hlen; | ||
|
||
return 0; | ||
} | ||
|
Oops, something went wrong.