ncomp

package module
v0.0.0-...-e52a0b9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 10, 2024 License: GPL-3.0 Imports: 3 Imported by: 0

README

ncomp - CUE's Nintendo compressors as library

This fork bundles CUE's compressors into one library.

  • BLZ
  • Huffman
  • LZE
  • LZSS
  • LZX
  • RLE

Usage

Before using it, please make sure your project is GPL-3.0 compatible, as this license was inherited from the original work.

Build

Generate the library in build and copy ncomp.h to include:

git clone https://github.com/Gonhex/ncomp.git
cd ncomp
mkdir build && cd build
cmake ..
cmake --build .

To build in release mode, use cmake .. -DCMAKE_BUILD_TYPE=Release.

Or as submodule in a CMake project:

add_subdirectory(ncomp)
...
target_link_libraries(${PROJECT_NAME} ncomp)
Example C
#include <ncomp.h> // in c++, surround this with extern "C" {}
...
ncomp_buffer arm9 = ncomp_BLZ_Decode(comp_arm9_ptr, comp_arm9_length);
if (arm9.error == ncomp_error_none)
{
    // do something with arm9.data and arm9.length;

    ncomp_Free(&arm9); // free memory when arm9 is no longer needed
}
else
{
    printf("%s\n", ncomp_error_message[arm9.error]);
}
Example Go
import "github.com/Gonhex/ncomp"
...
arm9, err := ncomp.BlzDecode(comp_arm9)
if err != nil {
	log.Println(err)
} else {
	// do something with arm9
}

Documentation

Index

Constants

View Source
const (
	MemoryVram Memory = C.ncomp_memory_vram
	MemoryWram Memory = C.ncomp_memory_wram

	ModeNormal Mode = C.ncomp_mode_normal
	ModeBest   Mode = C.ncomp_mode_best
	ModeFast   Mode = C.ncomp_mode_fast

	CodeHuf24 Code = C.ncomp_code_huf_24
	CodeHuf28 Code = C.ncomp_code_huf_28
	CodeLzx11 Code = C.ncomp_code_lzx_11
	CodeLzx40 Code = C.ncomp_code_lzx_40
)

Variables

This section is empty.

Functions

func BlzDecode

func BlzDecode(data []byte) ([]byte, error)

func BlzEncode

func BlzEncode(data []byte, mode Mode, arm9 bool) ([]byte, error)

func HufDecode

func HufDecode(data []byte) ([]byte, error)

func HufEncode

func HufEncode(data []byte, code Code) ([]byte, error)

func LzeDecode

func LzeDecode(data []byte) ([]byte, error)

func LzeEncode

func LzeEncode(data []byte) ([]byte, error)

func LzsDecode

func LzsDecode(data []byte) ([]byte, error)

func LzsEncode

func LzsEncode(data []byte, mode Mode, target Memory) ([]byte, error)

func LzxDecode

func LzxDecode(data []byte) ([]byte, error)

func LzxEncode

func LzxEncode(data []byte, code Code, target Memory) ([]byte, error)

func RleDecode

func RleDecode(data []byte) ([]byte, error)

func RleEncode

func RleEncode(data []byte) ([]byte, error)

Types

type Code

type Code C.ncomp_code

type Memory

type Memory C.ncomp_memory

type Mode

type Mode C.ncomp_mode

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL