Super Mario 64 Source
A Super Mario 64 decompilation, brought to you by a bunch of clever folks.
Data Structures | Macros | Enumerations | Functions | Variables
n64graphics_ci.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include "../stb/stb_image.h"
#include "../stb/stb_image_write.h"
#include "exoquant/exoquant.h"
#include "n64graphics_ci.h"
#include "utils.h"
#include <string.h>

Data Structures

struct  graphics_config
 
struct  format_entry
 

Macros

#define STBI_NO_LINEAR
 
#define STBI_NO_HDR
 
#define STBI_NO_TGA
 
#define STB_IMAGE_IMPLEMENTATION
 
#define STB_IMAGE_WRITE_IMPLEMENTATION
 
#define SCALE_5_8(VAL_)   (((VAL_) * 0xFF) / 0x1F)
 
#define SCALE_8_5(VAL_)   ((((VAL_) + 4) * 0x1F) / 0xFF)
 
#define SCALE_4_8(VAL_)   ((VAL_) * 0x11)
 
#define SCALE_8_4(VAL_)   ((VAL_) / 0x11)
 
#define SCALE_3_8(VAL_)   ((VAL_) * 0x24)
 
#define SCALE_8_3(VAL_)   ((VAL_) / 0x24)
 
#define N64GRAPHICS_VERSION   "0.4 - CI Only Branch"
 

Enumerations

enum  img_format {
  IMG_FORMAT_RGBA, IMG_FORMAT_IA, IMG_FORMAT_I, IMG_FORMAT_CI,
  IMG_FORMAT_CI
}
 
enum  tool_mode { MODE_EXPORT, MODE_IMPORT }
 

Functions

rgbaraw2rgba (const uint8_t *raw, int width, int height, int depth)
 
rgbarawci2rgba (const uint8_t *rawci, const uint8_t *palette, int width, int height, int depth)
 
int rgba2rawci (uint8_t *raw, uint8_t *out_palette, int *pal_len, const rgba *img, int width, int height, int depth)
 
rgbapng2rgba (const char *png_filename, int *width, int *height)
 
int rgba2png (const char *png_filename, const rgba *img, int width, int height)
 
const charn64graphics_get_read_version (void)
 
const charn64graphics_get_write_version (void)
 
static const charformat2str (img_format format, int depth)
 
static int parse_format (graphics_config *config, const char *str)
 
static void print_usage (void)
 
static void print_version (void)
 
static int parse_arguments (int argc, char *argv[], graphics_config *config)
 
chargetPaletteFilename (char *ci_filename)
 
int main (int argc, char *argv[])
 

Variables

static const graphics_config default_config
 
static const format_entry format_table []
 

Macro Definition Documentation

◆ N64GRAPHICS_VERSION

#define N64GRAPHICS_VERSION   "0.4 - CI Only Branch"

◆ SCALE_3_8

#define SCALE_3_8 (   VAL_)    ((VAL_) * 0x24)

◆ SCALE_4_8

#define SCALE_4_8 (   VAL_)    ((VAL_) * 0x11)

◆ SCALE_5_8

#define SCALE_5_8 (   VAL_)    (((VAL_) * 0xFF) / 0x1F)

◆ SCALE_8_3

#define SCALE_8_3 (   VAL_)    ((VAL_) / 0x24)

◆ SCALE_8_4

#define SCALE_8_4 (   VAL_)    ((VAL_) / 0x11)

◆ SCALE_8_5

#define SCALE_8_5 (   VAL_)    ((((VAL_) + 4) * 0x1F) / 0xFF)

◆ STB_IMAGE_IMPLEMENTATION

#define STB_IMAGE_IMPLEMENTATION

◆ STB_IMAGE_WRITE_IMPLEMENTATION

#define STB_IMAGE_WRITE_IMPLEMENTATION

◆ STBI_NO_HDR

#define STBI_NO_HDR

◆ STBI_NO_LINEAR

#define STBI_NO_LINEAR

◆ STBI_NO_TGA

#define STBI_NO_TGA

Enumeration Type Documentation

◆ img_format

enum img_format
Enumerator
IMG_FORMAT_RGBA 
IMG_FORMAT_IA 
IMG_FORMAT_I 
IMG_FORMAT_CI 
IMG_FORMAT_CI 

◆ tool_mode

enum tool_mode
Enumerator
MODE_EXPORT 
MODE_IMPORT 

Function Documentation

◆ format2str()

static const char* format2str ( img_format  format,
int  depth 
)
static

◆ getPaletteFilename()

char* getPaletteFilename ( char ci_filename)

◆ main()

int main ( int  argc,
char argv[] 
)

◆ n64graphics_get_read_version()

const char* n64graphics_get_read_version ( void  )

◆ n64graphics_get_write_version()

const char* n64graphics_get_write_version ( void  )

◆ parse_arguments()

static int parse_arguments ( int  argc,
char argv[],
graphics_config config 
)
static

◆ parse_format()

static int parse_format ( graphics_config config,
const char str 
)
static

◆ png2rgba()

rgba* png2rgba ( const char png_filename,
int width,
int height 
)

◆ print_usage()

static void print_usage ( void  )
static

◆ print_version()

static void print_version ( void  )
static

◆ raw2rgba()

rgba* raw2rgba ( const uint8_t *  raw,
int  width,
int  height,
int  depth 
)

◆ rawci2rgba()

rgba* rawci2rgba ( const uint8_t *  rawci,
const uint8_t *  palette,
int  width,
int  height,
int  depth 
)

◆ rgba2png()

int rgba2png ( const char png_filename,
const rgba img,
int  width,
int  height 
)

◆ rgba2rawci()

int rgba2rawci ( uint8_t *  raw,
uint8_t *  out_palette,
int pal_len,
const rgba img,
int  width,
int  height,
int  depth 
)

Variable Documentation

◆ default_config

const graphics_config default_config
static
Initial value:
=
{
.img_filename = NULL,
.bin_filename = NULL,
.mode = MODE_EXPORT,
.offset = 0,
.format = IMG_FORMAT_CI,
.depth = 8,
.width = 32,
.height = 32,
.truncate = 1,
}
Definition: n64graphics_ci.c:257
Definition: n64graphics_ci.c:28
#define NULL
Definition: mbi.h:101

◆ format_table

const format_entry format_table[]
static
Initial value:
=
{
{ "ci4", IMG_FORMAT_CI, 4 },
{ "ci8", IMG_FORMAT_CI, 8 },
}
Definition: n64graphics_ci.c:28