You've already forked Microtransactions64
mirror of
https://github.com/Print-and-Panic/Microtransactions64.git
synced 2026-01-21 10:17:19 -08:00
Add NON-WORKING gzip DEFLATE support
This commit is contained in:
41
Makefile
41
Makefile
@@ -8,6 +8,8 @@ default: all
|
||||
# Preprocessor definitions
|
||||
DEFINES :=
|
||||
|
||||
SRC_DIRS :=
|
||||
|
||||
#==============================================================================#
|
||||
# Build Options #
|
||||
#==============================================================================#
|
||||
@@ -41,6 +43,15 @@ COMPILER ?= gcc
|
||||
$(eval $(call validate-option,COMPILER,ido gcc))
|
||||
|
||||
|
||||
COMPRESS ?= yay0
|
||||
$(eval $(call validate-option,COMPRESS,yay0 gzip))
|
||||
ifeq ($(COMPRESS),gzip)
|
||||
DEFINES += GZIP=1
|
||||
SRC_DIRS += src/gzip
|
||||
else ifeq ($(COMPRESS),yay0)
|
||||
DEFINES += YAY0=1
|
||||
endif
|
||||
|
||||
# VERSION - selects the version of the game to build
|
||||
# jp - builds the 1996 Japanese version
|
||||
# us - builds the 1996 North American version
|
||||
@@ -254,7 +265,7 @@ ACTOR_DIR := actors
|
||||
LEVEL_DIRS := $(patsubst levels/%,%,$(dir $(wildcard levels/*/header.h)))
|
||||
|
||||
# Directories containing source files
|
||||
SRC_DIRS := src src/engine src/game src/audio src/menu src/buffers actors levels bin data assets asm lib sound
|
||||
SRC_DIRS += src src/engine src/game src/audio src/menu src/buffers actors levels bin data assets asm lib sound
|
||||
BIN_DIRS := bin bin/$(VERSION)
|
||||
|
||||
# File dependencies and variables for specific files
|
||||
@@ -393,6 +404,7 @@ export LANG := C
|
||||
|
||||
# N64 tools
|
||||
YAY0TOOL := $(TOOLS_DIR)/slienc
|
||||
ROMALIGN := $(TOOLS_DIR)/romalign
|
||||
N64CKSUM := $(TOOLS_DIR)/n64cksum
|
||||
N64GRAPHICS := $(TOOLS_DIR)/n64graphics
|
||||
N64GRAPHICS_CI := $(TOOLS_DIR)/n64graphics_ci
|
||||
@@ -564,6 +576,23 @@ $(BUILD_DIR)/levels/%/leveldata.bin: $(BUILD_DIR)/levels/%/leveldata.elf
|
||||
$(call print,Extracting compressionable data from:,$<,$@)
|
||||
$(V)$(EXTRACT_DATA_FOR_MIO) $< $@
|
||||
|
||||
ifeq ($(COMPRESS),gzip)
|
||||
# Compress binary file to gzip
|
||||
$(BUILD_DIR)/%.gz: $(BUILD_DIR)/%.bin
|
||||
$(call print,Compressing:,$<,$@)
|
||||
$(V)gzip -c -9 -n $< > $@
|
||||
|
||||
# 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
|
||||
$(call print,Converting GZIP to ELF:,$<,$@)
|
||||
$(V)printf ".section .data\n\n.incbin \"$<\"\n" | $(AS) $(ASFLAGS) -o $@
|
||||
else
|
||||
# Compress binary file
|
||||
$(BUILD_DIR)/%.szp: $(BUILD_DIR)/%.bin
|
||||
$(call print,Compressing:,$<,$@)
|
||||
@@ -573,7 +602,7 @@ $(BUILD_DIR)/%.szp: $(BUILD_DIR)/%.bin
|
||||
$(BUILD_DIR)/%.szp.o: $(BUILD_DIR)/%.szp
|
||||
$(call print,Converting YAY0 to ELF:,$<,$@)
|
||||
$(V)printf ".section .data\n\n.incbin \"$<\"\n" | $(AS) $(ASFLAGS) -o $@
|
||||
|
||||
endif
|
||||
|
||||
#==============================================================================#
|
||||
# Sound File Generation #
|
||||
@@ -756,14 +785,8 @@ $(BUILD_DIR)/$(LD_SCRIPT): $(LD_SCRIPT)
|
||||
$(call print,Preprocessing linker script:,$<,$@)
|
||||
$(V)$(CPP) $(CPPFLAGS) -DBUILD_DIR=$(BUILD_DIR) -MMD -MP -MT $@ -MF $@.d -o $@ $<
|
||||
|
||||
# Link libultra
|
||||
$(BUILD_DIR)/libultra.a: $(ULTRA_O_FILES)
|
||||
@$(PRINT) "$(GREEN)Linking libultra: $(BLUE)$@ $(NO_COL)\n"
|
||||
$(V)$(AR) rcs -o $@ $(ULTRA_O_FILES)
|
||||
$(V)$(TOOLS_DIR)/patch_libultra_math $@
|
||||
|
||||
# Link SM64 ELF file
|
||||
$(ELF): $(O_FILES) $(YAY0_OBJ_FILES) $(SEG_FILES) $(BUILD_DIR)/$(LD_SCRIPT) undefined_syms.txt $(BUILD_DIR)/libultra.a
|
||||
$(ELF): $(O_FILES) $(YAY0_OBJ_FILES) $(SEG_FILES) $(BUILD_DIR)/$(LD_SCRIPT) undefined_syms.txt
|
||||
@$(PRINT) "$(GREEN)Linking ELF file: $(BLUE)$@ $(NO_COL)\n"
|
||||
$(V)$(LD) -L $(BUILD_DIR) -T undefined_syms.txt -T $(BUILD_DIR)/$(LD_SCRIPT) -Map $(BUILD_DIR)/sm64.$(VERSION).map --no-check-sections $(addprefix -R ,$(SEG_FILES)) -o $@ $(O_FILES) -L$(LIBS_DIR) -lultra_rom -Llib -lhvqm2 -lgcc
|
||||
|
||||
|
||||
21
sm64.ld
21
sm64.ld
@@ -76,7 +76,8 @@ SECTIONS
|
||||
END_SEG(boot)
|
||||
|
||||
. = 0x80000400;
|
||||
BEGIN_NOLOAD(zbuffer) {
|
||||
BEGIN_NOLOAD(zbuffer)
|
||||
{
|
||||
BUILD_DIR/src/buffers/zbuffer.o(.bss*);
|
||||
}
|
||||
END_NOLOAD(zbuffer)
|
||||
@@ -123,7 +124,12 @@ SECTIONS
|
||||
BUILD_DIR/src/usb*.o(.text);
|
||||
#endif
|
||||
BUILD_DIR/src/audio*.o(.text);
|
||||
#ifdef GZIP
|
||||
BUILD_DIR/src/gzip*.o(.text);
|
||||
#endif
|
||||
#ifdef YAY0
|
||||
BUILD_DIR/asm/slidec.o(.text);
|
||||
#endif
|
||||
|
||||
*/libultra_rom.a:*.o(.text);
|
||||
*/libgcc.a:_umoddi3.o(.text);
|
||||
@@ -155,6 +161,9 @@ SECTIONS
|
||||
#endif
|
||||
BUILD_DIR/src/audio*.o(.data*);
|
||||
BUILD_DIR/src/audio*.o(.sdata*);
|
||||
#ifdef GZIP
|
||||
BUILD_DIR/src/gzip*.o(.data*);
|
||||
#endif
|
||||
|
||||
*/libultra_rom.a:*.o(.data*);
|
||||
*/libultra_rom.a:*.o(.sdata*);
|
||||
@@ -173,6 +182,9 @@ SECTIONS
|
||||
BUILD_DIR/src/usb*.o(.rodata*);
|
||||
#endif
|
||||
BUILD_DIR/src/audio*.o(.rodata*);
|
||||
#ifdef GZIP
|
||||
BUILD_DIR/src/gzip*.o(.rodata*);
|
||||
#endif
|
||||
|
||||
*/libultra_rom.a:*.o(.rodata*);
|
||||
*/libgcc.a:_umoddi3.o(.rodata*);
|
||||
@@ -193,11 +205,18 @@ SECTIONS
|
||||
{
|
||||
BUILD_DIR/src/game*.o(.bss*);
|
||||
BUILD_DIR/src/game*.o(.sbss*);
|
||||
#ifdef HVQM
|
||||
BUILD_DIR/src/hvqm*.o(.bss*);
|
||||
#endif
|
||||
#ifdef UNF
|
||||
BUILD_DIR/src/usb*.o(.bss*);
|
||||
BUILD_DIR/src/usb*.o(.sbss*);
|
||||
#endif
|
||||
BUILD_DIR/src/audio*.o(.bss*);
|
||||
BUILD_DIR/src/audio*.o(.sbss*);
|
||||
#ifdef GZIP
|
||||
BUILD_DIR/src/gzip*.o(.bss*);
|
||||
#endif
|
||||
|
||||
*/libultra_rom.a:*.o(COMMON);
|
||||
*/libultra_rom.a:*.o(.scommon);
|
||||
|
||||
@@ -11,6 +11,9 @@
|
||||
#include "memory.h"
|
||||
#include "segment_symbols.h"
|
||||
#include "segments.h"
|
||||
#ifdef GZIP
|
||||
#include "gzip/gzipdma.h"
|
||||
#endif
|
||||
#ifdef UNF
|
||||
#include "usb/debug.h"
|
||||
#endif
|
||||
@@ -247,7 +250,7 @@ u32 main_pool_pop_state(void) {
|
||||
* Perform a DMA read from ROM. The transfer is split into 4KB blocks, and this
|
||||
* function blocks until completion.
|
||||
*/
|
||||
static void dma_read(u8 *dest, u8 *srcStart, u8 *srcEnd) {
|
||||
void dma_read(u8 *dest, u8 *srcStart, u8 *srcEnd) {
|
||||
u32 size = ALIGN16(srcEnd - srcStart);
|
||||
|
||||
osInvalDCache(dest, size);
|
||||
@@ -336,7 +339,11 @@ void *load_segment_decompress(s32 segment, u8 *srcStart, u8 *srcEnd) {
|
||||
dma_read(compressed, srcStart, srcEnd);
|
||||
dest = main_pool_alloc(*size, MEMORY_POOL_LEFT);
|
||||
if (dest != NULL) {
|
||||
#ifdef GZIP
|
||||
slidma(dest, compressed, compSize);
|
||||
#else
|
||||
slidstart(compressed, dest);
|
||||
#endif
|
||||
set_segment_base_addr(segment, dest);
|
||||
main_pool_free(compressed);
|
||||
} else {
|
||||
@@ -354,7 +361,11 @@ void *load_segment_decompress_heap(u32 segment, u8 *srcStart, u8 *srcEnd) {
|
||||
|
||||
if (compressed != NULL) {
|
||||
dma_read(compressed, srcStart, srcEnd);
|
||||
#ifdef GZIP
|
||||
slidma(gDecompressionHeap, compressed, compSize);
|
||||
#else
|
||||
slidstart(compressed, gDecompressionHeap);
|
||||
#endif
|
||||
set_segment_base_addr(segment, gDecompressionHeap);
|
||||
main_pool_free(compressed);
|
||||
} else {
|
||||
|
||||
34
src/gzip/gzip.h
Executable file
34
src/gzip/gzip.h
Executable file
@@ -0,0 +1,34 @@
|
||||
#ifndef __GZIP_H__
|
||||
#define __GZIP_H__
|
||||
|
||||
#ifndef NULL
|
||||
#ifdef __cplusplus
|
||||
#define NULL 0
|
||||
#else
|
||||
#define NULL ((void *)0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define INBUFSIZ 4096 // input buffer size
|
||||
#define WSIZE 0x8000
|
||||
|
||||
typedef struct {
|
||||
u8 * next_addr;
|
||||
u32 rest_size;
|
||||
} FILE_HND;
|
||||
|
||||
#define get_byte() (inptr < insize ? inbuf[inptr++] : fill_inbuf(0))
|
||||
#define try_byte() (inptr < insize ? inbuf[inptr++] : fill_inbuf(1))
|
||||
|
||||
extern unsigned int insize; // valid bytes in inbuf
|
||||
extern unsigned int inptr; // index of next byte to be processed in inbuf
|
||||
extern unsigned int outcnt; // bytes in output buffer
|
||||
extern u8 inbuf[]; // input buffer
|
||||
extern u8 *op; // Sliding window and suffix table
|
||||
|
||||
extern int inflate(void);
|
||||
extern int fill_inbuf(int eof_ok);
|
||||
extern void flush_window(void);
|
||||
extern void dma_read(u8 *dest, u8 *srcStart, u8 *srcEnd);
|
||||
|
||||
#endif
|
||||
768
src/gzip/gzipdma.c
Executable file
768
src/gzip/gzipdma.c
Executable file
File diff suppressed because it is too large
Load Diff
14
src/gzip/gzipdma.h
Executable file
14
src/gzip/gzipdma.h
Executable file
@@ -0,0 +1,14 @@
|
||||
#ifndef _GZIP_DMA_H_
|
||||
#define _GZIP_DMA_H_
|
||||
|
||||
#ifdef _LANGUAGE_C_PLUS_PLUS
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void slidma(unsigned long dmasrc, char *dst, unsigned long dmasiz);
|
||||
|
||||
#ifdef _LANGUAGE_C_PLUS_PLUS
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _GZIP_DMA_H_ */
|
||||
18
tools/romalign
Executable file
18
tools/romalign
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
die "Usage: romalign file align\n" unless $#ARGV >= 1;
|
||||
|
||||
$in = $ARGV[0];
|
||||
$align = $ARGV[1];
|
||||
|
||||
@s = stat($in);
|
||||
$insize = $s[7];
|
||||
|
||||
open(OUT, ">> $in") or die "Can't open $in for output: $!";
|
||||
|
||||
$frag = $insize % $align;
|
||||
$fill = pack("C", 0);
|
||||
for($i = 0; $i < ($align-$frag)%$align; $i++) {
|
||||
syswrite(OUT, $fill, 1);
|
||||
}
|
||||
close OUT;
|
||||
Reference in New Issue
Block a user