You've already forked Microtransactions64
mirror of
https://github.com/Print-and-Panic/Microtransactions64.git
synced 2026-01-21 10:17:19 -08:00
Append size of uncomp data to end of gzip
This commit is contained in:
4
Makefile
4
Makefile
@@ -405,6 +405,7 @@ export LANG := C
|
||||
# N64 tools
|
||||
YAY0TOOL := $(TOOLS_DIR)/slienc
|
||||
ROMALIGN := $(TOOLS_DIR)/romalign
|
||||
BFSIZE := $(TOOLS_DIR)/bfsize
|
||||
N64CKSUM := $(TOOLS_DIR)/n64cksum
|
||||
N64GRAPHICS := $(TOOLS_DIR)/n64graphics
|
||||
N64GRAPHICS_CI := $(TOOLS_DIR)/n64graphics_ci
|
||||
@@ -581,12 +582,13 @@ ifeq ($(COMPRESS),gzip)
|
||||
$(BUILD_DIR)/%.gz: $(BUILD_DIR)/%.bin
|
||||
$(call print,Compressing:,$<,$@)
|
||||
$(V)gzip -c -9 -n $< > $@
|
||||
$(V)dd if=/dev/zero bs=1 count=4 >> $@
|
||||
perl -e 'printf ("%x", -s "$<")' $< >> $@
|
||||
|
||||
# Strip gzip header
|
||||
$(BUILD_DIR)/%.szp: $(BUILD_DIR)/%.gz
|
||||
$(call print,Converting:,$<,$@)
|
||||
$(V)dd bs=10 skip=1 if=$< of=$@
|
||||
$(V)$(ROMALIGN) $@ 16
|
||||
|
||||
# convert binary szp to object file
|
||||
$(BUILD_DIR)/%.szp.o: $(BUILD_DIR)/%.szp
|
||||
|
||||
@@ -329,19 +329,33 @@ void *load_to_fixed_pool_addr(u8 *destAddr, u8 *srcStart, u8 *srcEnd) {
|
||||
void *load_segment_decompress(s32 segment, u8 *srcStart, u8 *srcEnd) {
|
||||
void *dest = NULL;
|
||||
|
||||
#ifdef GZIP
|
||||
u32 compSize = (srcEnd - 8 - srcStart);
|
||||
#else
|
||||
u32 compSize = ALIGN16(srcEnd - srcStart);
|
||||
#endif
|
||||
|
||||
u8 *compressed = main_pool_alloc(compSize, MEMORY_POOL_RIGHT);
|
||||
|
||||
#ifdef GZIP
|
||||
// Decompressed size from end of gzip
|
||||
u32 *size = (u32 *) (compressed + compSize - 4);
|
||||
#else
|
||||
// Decompressed size from mio0 header
|
||||
u32 *size = (u32 *) (compressed + 4);
|
||||
#endif
|
||||
|
||||
#ifdef GZIP
|
||||
if (compressed != NULL) {
|
||||
dma_read(compressed, srcStart, srcEnd);
|
||||
dest = main_pool_alloc(*size, MEMORY_POOL_LEFT);
|
||||
if (dest != NULL) {
|
||||
#ifdef GZIP
|
||||
slidma(compressed, dest, compSize);
|
||||
#else
|
||||
if (compressed != NULL) {
|
||||
dma_read(compressed, srcStart, srcEnd);
|
||||
dest = main_pool_alloc(*size, MEMORY_POOL_LEFT);
|
||||
if (dest != NULL) {
|
||||
slidstart(compressed, dest);
|
||||
#endif
|
||||
set_segment_base_addr(segment, dest);
|
||||
@@ -355,7 +369,12 @@ void *load_segment_decompress(s32 segment, u8 *srcStart, u8 *srcEnd) {
|
||||
|
||||
void *load_segment_decompress_heap(u32 segment, u8 *srcStart, u8 *srcEnd) {
|
||||
UNUSED void *dest = NULL;
|
||||
|
||||
#ifdef GZIP
|
||||
u32 compSize = (srcEnd - 8 - srcStart);
|
||||
#else
|
||||
u32 compSize = ALIGN16(srcEnd - srcStart);
|
||||
#endif
|
||||
u8 *compressed = main_pool_alloc(compSize, MEMORY_POOL_RIGHT);
|
||||
UNUSED u32 *pUncSize = (u32 *) (compressed + 4);
|
||||
|
||||
|
||||
1
tools/.gitignore
vendored
1
tools/.gitignore
vendored
@@ -1,6 +1,7 @@
|
||||
/aifc_decode
|
||||
/aiff_extract_codebook
|
||||
/armips
|
||||
/bfsize
|
||||
/extract_data_for_mio
|
||||
/mio0
|
||||
/n64cksum
|
||||
|
||||
@@ -7,7 +7,7 @@ CC := gcc
|
||||
CXX := g++
|
||||
CFLAGS := -I . -Wall -Wextra -Wno-unused-parameter -pedantic -O2 -s
|
||||
LDFLAGS := -lm
|
||||
ALL_PROGRAMS := armips n64graphics n64graphics_ci mio0 slienc n64cksum textconv patch_libultra_math aifc_decode aiff_extract_codebook vadpcm_enc tabledesign extract_data_for_mio skyconv
|
||||
ALL_PROGRAMS := armips bfsize n64graphics n64graphics_ci mio0 slienc n64cksum textconv patch_libultra_math aifc_decode aiff_extract_codebook vadpcm_enc tabledesign extract_data_for_mio skyconv
|
||||
LIBAUDIOFILE := audiofile/libaudiofile.a
|
||||
|
||||
# Only build armips from tools if it is not found on the system
|
||||
@@ -19,6 +19,8 @@ endif
|
||||
|
||||
default: all
|
||||
|
||||
bfsize_SOURCES := bfsize.c
|
||||
|
||||
n64graphics_SOURCES := n64graphics.c utils.c
|
||||
n64graphics_CFLAGS := -DN64GRAPHICS_STANDALONE
|
||||
|
||||
|
||||
44
tools/bfsize.c
Normal file
44
tools/bfsize.c
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (C) 2011 <fwhacking|gmail:com>
|
||||
*
|
||||
* This is free software, licensed under the GNU General Public License v2.
|
||||
* See /LICENSE for more information.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
static void print_usage(const char *name)
|
||||
{
|
||||
printf("Usage: %s file\n", name);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
FILE *fd;
|
||||
long size;
|
||||
|
||||
if (argc != 2)
|
||||
{
|
||||
print_usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fd = fopen(argv[1], "rb");
|
||||
if (fd == NULL)
|
||||
{
|
||||
printf("Could not read the file '%s'\n", argv[1]);
|
||||
print_usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
size = fseek(fd, 0L, SEEK_END);
|
||||
size = ftell(fd);
|
||||
fclose(fd);
|
||||
|
||||
printf("%ld\n", size);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
Reference in New Issue
Block a user