Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
trapexit committed Nov 26, 2023
0 parents commit a9dfed7
Show file tree
Hide file tree
Showing 36 changed files with 26,669 additions and 0 deletions.
73 changes: 73 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
COMPILER_PREFIX =
PLATFORM := $(shell uname -s | tr A-Z a-z)_$(shell arch)
EXE = 3ct

JOBS := $(shell nproc)
PUID := $(shell id -u)
PGID := $(shell id -g)

OUTPUT = build/$(EXE)

CC = $(COMPILER_PREFIX)-gcc
CXX = $(COMPILER_PREFIX)-g++
STRIP = $(COMPILER_PREFIX)-strip

ifeq ($(DEBUG),1)
OPT := -O0 -ggdb
else
OPT := -O3 -flto -static
endif

ifeq ($(SANITIZE),1)
OPT += -fsanitize=undefined
endif

CFLAGS = $(OPT) -Wall
CXXFLAGS = $(OPT) -Wall -std=c++17
CPPFLAGS ?= -MMD -MP

SRCS_C := $(wildcard src/*.c)
SRCS_CXX := $(wildcard src/*.cpp)

BUILDDIR = build/$(PLATFORM)
OBJS := $(SRCS_C:src/%.c=$(BUILDDIR)/%.c.o)
OBJS += $(SRCS_CXX:src/%.cpp=$(BUILDDIR)/%.cpp.o)
DEPS = $(OBJS:.o=.d)


all: $(OUTPUT)

$(OUTPUT): builddir $(OBJS)
$(CXX) $(CXXFLAGS) -o $(OUTPUT) $(OBJS) $(LDFLAGS)

strip: $(OUTPUT)
$(STRIP) --strip-all $(OUTPUT)

$(BUILDDIR)/%.c.o: src/%.c
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@

$(BUILDDIR)/%.cpp.o: src/%.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@

clean:
rm -rfv build/

builddir:
mkdir -p $(BUILDDIR)

linux-release:
$(MAKE) -j$(JOBS) EXE=$(EXE)_$(PLATFORM) strip

win-i686-release:
$(MAKE) -j$(JOBS) COMPILER_PREFIX=i686-w64-mingw32 PLATFORM=win_i686 EXE=$(EXE)_win_i686.exe strip

win-x86_64-release:
$(MAKE) -j$(JOBS) COMPILER_PREFIX=x86_64-w64-mingw32 PLATFORM=win_x86_64 EXE=$(EXE)_win_x86_64.exe strip

release:
docker run --rm -it -e PUID=$(PUID) -e PGID=$(PGID) -v ${PWD}:/src alpine:edge "/src/tools/docker-make-release"


.PHONY: clean builddir release

-include $(DEPS)
70 changes: 70 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# 3ct: 3DO Compression Tool

A port of the 3DO SDK's compression library to modern platforms with a
command line tool.


## Usage

```
$ 3ct --help-all
3ct: 3DO Compression Tool (v1.0.0)
Usage: 3ct [OPTIONS] SUBCOMMAND
Options:
-h,--help Print this help message and exit
--help-all List help for all subcommands
Subcommands:
compress
Compress input file
Positionals:
input-filepath PATH:FILE REQUIRED
Path to input file
output-filepath PATH:FILE Path to output file (default: input + '.compressed')
decompress
Decompress input file
Positionals:
input-filepath PATH:FILE REQUIRED
Path to input file
output-filepath PATH:FILE Path to output file (default: input + '.decompressed')
check
Checks the compressor and decompressor against data generated by the 3DO SDK compression library
$ 3ct compress example.txt
- input:
- filepath: example.txt
- size_in_bytes: 1024
- size_in_words: 256
- output:
- filepath: example.txt.compressed
- size_in_bytes: 144
- size_in_words: 36
$ 3ct check
* output of 3ct compressor matches SDK
* output of 3ct decompressor matches SDK
```

# TODOs

* Reverse engineer Game Guru compression format and add to 3ct
* Rework and modernize compression code


# Documentation

* https://3dodev.com
* https://3dodev.com/documentation/development/opera/pf25/ppgfldr/pgsfldr/spg/14spg
* https://github.com/trapexit/portfolio_os_m2/tree/master/ws_root/src/tools/comp3do
* https://github.com/trapexit/portfolio_os_m2/tree/master/ws_root/src/tools/decomp3do


# Donations / Sponsorship

If you find 3ct useful please consider supporting its ongoing development.

https://github.com/trapexit/support
Loading

0 comments on commit a9dfed7

Please sign in to comment.