Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: z64utils/zzrtl
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.0.5
Choose a base ref
...
head repository: z64utils/zzrtl
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 6 commits
  • 5 files changed
  • 1 contributor

Commits on Nov 27, 2023

  1. Copy the full SHA
    201a20a View commit details

Commits on Dec 9, 2023

  1. new function: sha1(data, sz)

    also updated version number from v1.0.5 to v1.0.6
    z64me committed Dec 9, 2023
    Copy the full SHA
    bfb1a48 View commit details

Commits on Jan 10, 2024

  1. Copy the full SHA
    f3df21b View commit details

Commits on Feb 17, 2024

  1. push old sha1/realloc changes

    Not thoroughly tested so these features are not recommended for production use, but pushing these changes just in case.
    z64me committed Feb 17, 2024
    Copy the full SHA
    f31cb0e View commit details

Commits on Sep 30, 2024

  1. fix compression oversight on moved files, more verbose output

    This commit fixes a compression oversight pertaining to uncompressed (but relocated) files running past the filesize limit set by the user (cases where Pend = 0 but Pstart + Psize > compsz). Also made the output more verbose so it reports exactly how many bytes of overflow are present.
    z64me committed Sep 30, 2024
    Copy the full SHA
    b71336d View commit details
  2. update compiler paths in win32 build script

    No longer using hardcoded paths
    z64me committed Sep 30, 2024
    Copy the full SHA
    6aedb0c View commit details
Showing with 77 additions and 6 deletions.
  1. +3 −3 release-win32.sh
  2. +2 −0 src/sha1.h
  3. +21 −0 src/wow.h
  4. +35 −1 src/xc.c
  5. +16 −2 src/zzrtl.c
6 changes: 3 additions & 3 deletions release-win32.sh
Original file line number Diff line number Diff line change
@@ -2,15 +2,15 @@
mkdir -p o

# build compression functions (slow)
~/c/mxe/usr/bin/i686-w64-mingw32.static-gcc -c -DNDEBUG -s -Ofast -flto -lm -Wall src/enc/*.c src/enc/lzo/*.c src/enc/ucl/comp/*.c src/enc/apultra/*.c
i686-w64-mingw32.static-gcc -c -DNDEBUG -s -Ofast -flto -lm -Wall src/enc/*.c src/enc/lzo/*.c src/enc/ucl/comp/*.c src/enc/apultra/*.c
mv *.o o

# build stb functions (slow)
~/c/mxe/usr/bin/i686-w64-mingw32.static-gcc -c -DNDEBUG src/stb/*.c -Wall -lm -s -Os -flto -lpthread -Wno-unused-function -Wno-unused-variable
i686-w64-mingw32.static-gcc -c -DNDEBUG src/stb/*.c -Wall -lm -s -Os -flto -lpthread -Wno-unused-function -Wno-unused-variable
mv *.o o

# build everything else
~/c/mxe/usr/bin/i686-w64-mingw32.static-gcc -o zzrtl.exe -DNDEBUG src/*.c o/*.o -Wall -lm -s -Os -flto -lpthread -Wno-unused-function -Wno-unused-variable
i686-w64-mingw32.static-gcc -o zzrtl.exe -DNDEBUG src/*.c o/*.o -Wall -lm -s -Os -flto -lpthread -Wno-unused-function -Wno-unused-variable

# move to bin directory
mkdir -p bin/win32
2 changes: 2 additions & 0 deletions src/sha1.h
Original file line number Diff line number Diff line change
@@ -52,6 +52,7 @@ static void stb__sha1(stb_uchar *chunk, stb_uint h[5])
h[4] += e;
}

static
void stb_sha1(stb_uchar output[20], stb_uchar *buffer, stb_uint len)
{
unsigned char final_block[128];
@@ -119,6 +120,7 @@ void stb_sha1(stb_uchar output[20], stb_uchar *buffer, stb_uint len)
}

// client can truncate this wherever they like
static
void stb_sha1_readable(char display[30], unsigned char sha[20])
{
char encoding[65] = "0123456789abcdefghijklmnopqrstuv"
21 changes: 21 additions & 0 deletions src/wow.h
Original file line number Diff line number Diff line change
@@ -580,7 +580,28 @@ wow_system(char const *path)

return rval;
#else /* not win32 unicode */
#ifdef _WIN32
return system(path);
#else
// allow win32 paths on linux builds
if (strchr(path, '\\'))
{
char *tmp = strdup(path);
int rval;

for (char *c = tmp; *c; ++c)
if (*c == '\\')
*c = '/';

rval = system(tmp);
free(tmp);
return rval;
}
else
{
return system(path);
}
#endif
#endif
}

36 changes: 35 additions & 1 deletion src/xc.c
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@
#include "zzrtl.h"
#include "preproc.h"
#include "rnd.h" /* rnd_pcg */
#include "sha1.h"

#undef fopen
#undef fread
@@ -227,7 +228,7 @@ zzrtl(void)
fprintf(
stderr,
"/*************************\n"
" * zzrtl v1.0.5 <z64.me> *\n"
" * zzrtl v1.0.6 <z64.me> *\n"
" *************************/\n"
);
fprintf(
@@ -432,6 +433,8 @@ SCAT,SCMP,SCCM,EXIT
, ZZXC_string_list_file
, ZZXC_loadfile
, ZZXC_tsv_col_row
, ZZXC_sha1
, ZZXC_realloc
/* directory */
, ZZXC_DIR_EXISTS
, ZZXC_DIR_ENTER
@@ -541,6 +544,8 @@ SCAT,SCMP,SCCM,EXIT
" string_list_file " \
" loadfile " \
" tsv_col_row " \
" sha1 " \
" realloc " \
/* directory */ \
" dir_exists " \
" dir_enter " \
@@ -647,6 +652,8 @@ SCAT,SCMP,SCCM,EXIT
",FSTR" /* string_list_file */ \
",LFIL" /* loadfile */ \
",TVCR" /* tsv_col_row */ \
",SHA1" /* sha1 */ \
",RALC" /* realloc */ \
/* directory */ \
",DRXS" /* dir_exists */ \
",DREN" /* dir_enter */ \
@@ -2518,6 +2525,33 @@ ZZXC_FUNC_INST_STR[op * 5]
{
ax = (int)tsv_col_row((void *)sp[2], (char *)sp[1], *sp);
}

/* get sha1 checksum of a buffer */
else if (op == ZZXC_sha1)
{
unsigned char checksum[64];
char readable[64];

stb_sha1(checksum, (stb_uchar *)sp[1], *sp);
stb_sha1_readable(readable, checksum);

ax = (int)strdup(readable);
}

/* load a file */
else if (op == ZZXC_realloc)
{
void *src = (void*)sp[1];
int len = (REGXC_INT)*sp;
void *result = realloc(src, len);

//fprintf(stderr, "realloc %p %p\n", src, len);

ax = (int)result;

if (!result)
die("[!] realloc memory error");
}

/* directory */
else if (op == ZZXC_DIR_EXISTS)
18 changes: 16 additions & 2 deletions src/zzrtl.c
Original file line number Diff line number Diff line change
@@ -1894,6 +1894,9 @@ loadfile(char *fn, int *sz, int optional)
if (!fn)
die_i("loadfile no filename given");

/* if fn starts with '*', grab by extension */
fn = find_extension(fn, 0);

data = file_load(fn, &Nsz, 16);
if (!data && !optional)
die_i("loadfile failed to load '%s'", fn);
@@ -2563,6 +2566,7 @@ rom_compress(struct rom *rom, char *enc, int mb)
int i;
float total_compressed = 0;
float total_decompressed = 0;
const float toMib = 1.0 / (1024 * 1024);

struct compThread *compThread = 0;
int numThread = 4; /* TODO make this external */
@@ -2923,8 +2927,8 @@ rom_compress(struct rom *rom, char *enc, int mb)
#endif
// fprintf(stdout, "%08X: %08X %08X\n", dma - rom->dma, dma->Pstart, dma->Pend);
// fprintf(stdout, "%08X: %08X %08X %08X\n", dma - rom->dma, dma->start, dma->Pstart, dma->Pend);
if (dma->Pend > compsz)
die_i("i ran out of compressed rom space");
if (comp_total > compsz)
continue;

/* external cached file logic */
if (g_use_cache)
@@ -2941,6 +2945,16 @@ rom_compress(struct rom *rom, char *enc, int mb)
memcpy(dst, dma->compbuf, dma->compSz);
}
}

if (comp_total > compsz)
die_i(
"ran out of compressed rom space\n"
"(have: %.2f mib, need: %.2f mib)\n"
"(0x%X bytes over limit)"
, compsz * toMib, comp_total * toMib
, comp_total - compsz
);

fprintf(stderr, "success!\n");

fprintf(