rom

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CRC_CHECKSUM_START  = 0x00001000
	CRC_CHECKSUM_LENGTH = 0x00100000
	CRC_CHECKSUM_END    = CRC_CHECKSUM_START + CRC_CHECKSUM_LENGTH
)
View Source
const (
	FormatZ64 = "z64"
	FormatV64 = "v64"
	FormatN64 = "n64"
)
View Source
const (
	NTSC = "NTSC"
	PAL  = "PAL"
)
View Source
const ROM_HEADER_SIZE = 0x40

Variables

View Source
var Extensions = []string{"bin", "rom", "d64", "n64", "u64", "v64", "z64"}
View Source
var FileFormats = map[string]string{
	FormatZ64: "Big-endian",
	FormatV64: "Byte-swapped",
	FormatN64: "Little-endian",
}
View Source
var MediaFormats = map[string]string{
	"N": "Cartridge",
	"D": "64DD Disk",
	"C": "Cartridge for expandable game",
	"E": "64DD Expansion",
	"Z": "Aleck64 Cartridge",
}
View Source
var Regions = map[string]Region{
	"7": {"7", "Beta", "Beta", NTSC},
	"A": {"A", "JP/US", "Japan and USA", NTSC},
	"B": {"B", "BRA", "Brazil", NTSC},
	"C": {"C", "CHN", "China", PAL},
	"D": {"D", "GER", "Germany", PAL},
	"E": {"E", "USA", "USA", NTSC},
	"F": {"F", "FRA", "France", PAL},
	"G": {"G", "GW64-N", "Gateway 64 (NTSC)", NTSC},
	"H": {"H", "NED", "Netherlands", PAL},
	"I": {"I", "ITA", "Italy", PAL},
	"J": {"J", "JPN", "Japan", NTSC},
	"K": {"K", "KOR", "South Korea", NTSC},
	"L": {"L", "GW64-P", "Gateway 64 (PAL)", PAL},
	"N": {"N", "CAN", "Canada", NTSC},
	"P": {"P", "EUR", "Europe", PAL},
	"S": {"S", "ESP", "Spain", PAL},
	"U": {"U", "AUS", "Australia", PAL},
	"W": {"W", "NORD", "Scandinavia", PAL},
	"X": {"X", "PAL/X", "PAL Regions", PAL},
	"Y": {"Y", "PAL/Y", "PAL Regions", PAL},
}

Functions

func ConvertRomFormat

func ConvertRomFormat(inpath string, outpath string) error

Converts a ROM to native Z64 format

func FileMD5

func FileMD5(path string) (string, error)

func FileSHA1

func FileSHA1(path string) (string, error)

func FindProbableRomsInPath

func FindProbableRomsInPath(path string) ([]string, error)

Given a directory or file, filter down to paths that are probably ROM files based on their extensions.

func HasRomExtension

func HasRomExtension(path string) bool

Types

type CodeDescription

type CodeDescription struct {
	Code        string `json:"code" xml:"code"`
	Description string `json:"description" xml:"description"`
}

type FileInfo

type FileInfo struct {
	Path   string          `json:"path" xml:"path"`
	Name   string          `json:"name" xml:"name"`
	Format CodeDescription `json:"format" xml:"format"`
	Size   int             `json:"size" xml:"size"`
	MD5    string          `json:"md5" xml:"md5"`
	SHA1   string          `json:"sha1" xml:"sha1"`
	CRC1   string          `json:"crc1" xml:"crc1"`
	CRC2   string          `json:"crc2" xml:"crc2"`
}

type Region

type Region struct {
	Id          string `json:"id" xml:"id"`
	Short       string `json:"short_name" xml:"short_name"`
	Description string `json:"description" xml:"description"`
	VideoSystem string `json:"video_system" xml:"video_system"`
}

type RomFile

type RomFile struct {
	CRC1        string          `json:"crc1" xml:"crc1"`
	CRC2        string          `json:"crc2" xml:"crc2"`
	ImageName   string          `json:"image_name" xml:"image_name"`
	MediaFormat CodeDescription `json:"media_format" xml:"media_format"`
	CartridgeId string          `json:"cartridge_id" xml:"cartridge_id"`
	Region      Region          `json:"region" xml:"region"`
	Version     uint8           `json:"version" xml:"version"`
	CIC         string          `json:"cic" xml:"cic"`
	File        FileInfo        `json:"file" xml:"file"`
}

func FromFile

func FromFile(fh *os.File) (RomFile, error)

func FromIoReader

func FromIoReader(r io.Reader) (RomFile, error)

func FromPath

func FromPath(path string) (RomFile, error)

func (*RomFile) AddHashes

func (romfile *RomFile) AddHashes() error

func (*RomFile) AddMD5

func (romfile *RomFile) AddMD5() error

func (*RomFile) AddSHA1

func (romfile *RomFile) AddSHA1() error

func (*RomFile) CalcCRC added in v0.5.1

func (rf *RomFile) CalcCRC() error

Calculate CRC1 (aka "CRC HI") and CRC2 (aka "CRC LO") for the given RomFile

This code is a direct port from the C implementation at http://n64dev.org/n64crc.html Since I don't understand the "why" behind this, I can't document it further.

func (*RomFile) Serial

func (r *RomFile) Serial() string

4-char ROM identifier, e.g. NSME = Super Mario 64 (USA), NSMJ = Super Mario 64 (Japan)

func (*RomFile) ValidateWithDat

func (r *RomFile) ValidateWithDat(df dat.DatFile) (matches, mismatches []dat.Rom, err error)

Jump to

Keyboard shortcuts

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