min

package
v0.0.0-...-38e8959 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2019 License: Unlicense Imports: 9 Imported by: 4

Documentation

Overview

Package min provides access to MIN files.

The MIN file of each level (e.g. "levels/l1data/l1.min") specifies how to arrange the frames of the level's CEL file (e.g. "levels/l1data/l1.cel") in order to form miniature tiles (henceforth referred to as dungeon pieces, or dpieces for short). A dungeon piece consists of either 10 or 16 blocks, where each non-empty block is represented by a CEL frame.

Below follows a pseudo-code description of the MIN file format.

// A MIN file consists of a sequence of dungeon piece definitions.
type MIN []DPiece

// A DPiece consists of a sequence of either 10 or 16 block definitions.
type DPiece struct {
   // nblocks is either 10 (for "l1.min", "l2.min" and "l3.min") or 16
   // (for "l4.min" and "town.min").
   blocks [nblocks]Block
}

// A Block stores the CEL frame number and frame type of a dungeon piece
// block.
//
//    frameNum  := block&0x0FFF
//    frameType := block&0x7000 >> 12
type Block uint16

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	// Frame number in the level CEL file; or 0 if empty.
	FrameNum int
	// Frame type, specifying the CEL decoding algorithm of the frame.
	FrameType int
}

A Block specifies the graphics of a single block in a dungeon piece, consisting of either 10 or 16 blocks.

type DPiece

type DPiece struct {
	// Either 10 or 16 blocks constituting the dungeon piece.
	Blocks []Block
}

A DPiece represents a dungeon piece, which specifies how to arrange frames of a level CEL file in order to form a miniature tile. A dungeon piece consists of 10 or 16 blocks, where each non-empty block is represented by a CEL frame.

func Parse

func Parse(path string) ([]DPiece, error)

Parse parses the given MIN file and returns its dungeon piece definitions.

func (DPiece) Image

func (dpiece DPiece) Image(levelFrames []image.Image) image.Image

Image returns an image representation of the dungeon piece, where each non- empty block corresponds to a CEL frame from levelFrames.

The size of each block is 32x32 pixels and the blocks are arranged as illustrated below to form a miniature tile.

+----+----+
|  0 |  1 |
+----+----+
|  2 |  3 |
+----+----+
|  4 |  5 |
+----+----+
|  6 |  7 |
+----+----+
|  8 |  9 |
+----+----+
| 10 | 11 |
+----+----+
| 12 | 13 |
+----+----+
| 14 | 15 |
+----+----+

Jump to

Keyboard shortcuts

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