rom

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2018 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const Size = 64 * 1024 * 1024

Size is the total byte size of a ROM

Variables

View Source
var ActorDescriptions = map[uint16]ActorDescription{}

ActorDescriptions maps Actor IDs to their debug information and human-readable names.

View Source
var FileNames = map[uint32]string{}/* 405 elements not displayed */

FileNames maps file start offset to a file name

Functions

This section is empty.

Types

type ActorDescription added in v0.0.3

type ActorDescription struct {
	ID             uint16
	FileName       string
	Object         uint16
	Translation    string
	Identification string
}

ActorDescription is scapped actor data from the CloudModding wiki

type ActorEntry added in v0.0.3

type ActorEntry struct {
	ID                uint16
	SpawnTimeFlags    uint16
	SceneCommandIndex byte
	Initialization    uint16

	NoXRotation bool
	NoYRotation bool
	NoZRotation bool

	Position Vec3
	Rotation Vec3

	Description ActorDescription
}

ActorEntry are entries that point to the dynamic objects present in a Room.

type DMAEntry

type DMAEntry struct {
	// Virtual (or physical when uncompressed)
	VROMStart uint32
	VROMEnd   uint32

	// Physical (when compressed)
	PROMStart uint32
	PROMEnd   uint32
}

DMAEntry is a single entry of the filesystem table binpacked, do not change struct size

type File

type File struct {
	DMAEntry

	Name  string
	Valid bool
	Type  string
	// contains filtered or unexported fields
}

A File is anything referenced in the damadata section of the rom.

func (*File) Data added in v0.0.2

func (f *File) Data() []byte

Data returns the RAW file data

func (*File) Size added in v0.0.2

func (f *File) Size() int

Size returns the raw file data size

type InternalSceneTableEntry

type InternalSceneTableEntry struct {
	VROMStart         uint32
	VROMEnd           uint32
	EntranceMessageID uint16

	SceneConfiguration uint8
	// contains filtered or unexported fields
}

InternalSceneTableEntry is a single entry of the InternalSceneTable Sources: - https://wiki.cloudmodding.com/mm/Scene_Table binpacked, do not change struct size

type LocationHeader added in v0.0.2

type LocationHeader struct {
	// Headers are two uint32 with the first byte determining what the data is,
	// the data here is already interpreted, eg. for a header described as
	// "0x12xx5678 0x0000yyyy" and fed the data 0x123456789 0x123456789 its
	// first value would be 0x34 and its second one would be 0x6789
	//
	// Headers marked with an asterisk are mandatory.
	//
	//                     second header value ─────────────────────┐
	//                        first header value ───────────┬┐      │
	//                              header command byte ──┬┐││      │
	//                                                    ││││      │
	StartPositionsCount                       byte   // 0x00xx0000* │
	StartPositionsSegmentOffset               uint32 // 0xyyyyyyyy  ┘
	ActorsCount                               byte   // 0x01xx0000
	ActorsSegmentOffset                       uint32 // 0xyyyyyyyy
	CamerasCount                              byte   // 0x02xx0000
	CamerasSegmentOffset                      uint32 // 0xyyyyyyyy
	CollisionHeaderSegmentOffset              uint32 // 0x03000000 0xyyyyyyyy *
	RoomsCount                                byte   // 0x04xx0000 *
	WindDirectionX                            byte   // 0x05000000 0xxxyyzzww
	WindDirectionY                            byte   // ───────────────┴┘││││
	WindDirectionZ                            byte   // ─────────────────┴┘││
	WindStrength                              byte   // ───────────────────┴┘
	RoomsSegmentOffset                        uint32 // 0xyyyyyyyy
	EntrancesCount                            byte   // 0x06xx0000 *
	EntrancesSegmentOffset                    uint32 // 0xyyyyyyyy
	SpecialObjectsByte0                       byte   // 0x07??0000 unknown purpose *
	SpecialObjects                            uint16 // 0x0000xxxx
	RoomBehavior0                             byte   // 0x08xx0000 0x0000yyzz "affects Sun's Song, backflipping with A"
	RoomBehavior1                             byte   // ─────────────────┴┘││ unknown
	RoomBehavior2                             byte   // ───────────────────┴┘ animations/tunic
	MeshSegmentOffset                         uint32 // 0x0A000000 0xyyyyyyyy *
	ObjectsCount                              byte   // 0x0Bxx0000
	ObjectsSegmentOffset                      uint32 // 0xyyyyyyyy
	LightSettingsCount                        byte   // 0x0Cxx0000
	LightSettingsSegmentOffset                uint32 // 0xyyyyyyyy
	PathsSegmentOffset                        uint32 // 0x0D000000 0xyyyyyyyy
	ActorTransitionsCount                     byte   // 0x0Exx0000
	ActorTransitionsSegmentOffset             uint32 // 0xyyyyyyyy
	EnvironmentSettingsCount                  byte   // 0x0Fxx0000 *
	EnvironmentSettingsSegmentOffset          uint32 // 0xyyyyyyyy
	TimeStart                                 uint16 // 0x10000000 0xxxxxyy00 (0xFFFF = current time)
	TimeSpeed                                 byte   // ─────────────────┴┘   (defaults to 0x03)
	SkyboxNumber                              byte   // 0x11000000 0xxx0y0z00 *
	SkyboxCast                                byte   // ────────────────┘ │
	SkyboxFog                                 byte   // ──────────────────┘
	SkyboxDisable                             bool   // 0x12000000 0xxxyy0000 true if > 0
	SkyboxModifier                            byte   // ───────────────┴┘     unknown
	ExitsSegmentOffset                        uint32 // 0x13000000 0xyyyyyyyy
	SoundReverb                               byte   // 0x15xx0000 0x0000yyzz *
	SoundNightSFX                             byte   // ─────────────────┴┘││
	SoundBackgroundSequence                   byte   // ───────────────────┴┘
	SoundEcho                                 byte   // 0x16000000 0x000000xx *
	CutscenesCount                            byte   // 0x17xx0000
	CutscenesSegmentOffset                    uint32 // 0xyyyyyyyy
	AlternateHeadersSegmentOffset             uint32 // 0x18000000 0xxxxxxxxx
	IsWorldMapLocation                        bool   // 0x19000000 0x00000000 (presence = true)
	TextureAnimationsSegmentOffset            uint32 // 0x1A000000 0xxxxxxxxx *
	CamerasAndCutscenesForActorsCount         byte   // 0x1Bxx0000 *
	CamerasAndCutscenesForActorsSegmentOffset uint32 // 0xyyyyyyyy
	MinimapsSegmentOffset                     uint32 // 0x1C000000 0xxxxxxxxx *
	MapChestPositionsCount                    byte   // 0x1Exx0000
	MapChestPositionsSegmentOffset            uint32 // 0xyyyyyyyy
}

LocationHeader holds the of both Scenes and Rooms as many of them are shared.

type Message

type Message struct {
	MessageEntry
	MessageHeader
	VROMStart uint32

	String string
}

Message is text than can appear in a ingame textbox

type MessageEntry

type MessageEntry struct {
	ID uint16

	Offset uint32 // prefixed with 0x08
	// contains filtered or unexported fields
}

MessageEntry is a single entry in the message table Sources: - https://wiki.cloudmodding.com/mm/Text_Format#Message_Entry_Table binpacked, do not change struct size

type MessageHeader

type MessageHeader struct {
	TextBoxType       byte
	TextBoxPosition   byte
	Icon              byte
	NextMessageNumber uint16
	RupeeCost         uint16
	// contains filtered or unexported fields
}

MessageHeader is the standard header of every text message

type ROM

type ROM struct {
	Header    [4]byte // 0x00
	ClockRate uint32  // 0x04
	PC        uint32  // 0x08
	Release   uint32  // 0x0C
	CRC1      uint32  // 0x10
	CRC2      uint32  // 0x14

	Name [20]byte // 0x20

	ManufacturerID uint32 // 0x38
	CartridgeID    uint16 // 0x3C - Game serial number
	CountryCode    uint16 // 0x3E - 0x40

	Build [32]byte // 0x0001A4D0 - 0x0001A4F0

	DMAData [1552]DMAEntry // 0x0001A500 - 0x0020600

	InternalSceneTable [113]InternalSceneTableEntry // 0x00C5A1E0 - 0x00C5A8F0

	MessageTable [4589]MessageEntry // 0x00C5D0D8 - 0x00C66040
	// contains filtered or unexported fields
}

ROM represents a decompressed TLoZ:MM NTSC 1.0 Sources:

binpacked, do not change struct size

func New

func New(r io.ReadSeeker) (*ROM, error)

New loads a new ROM from a file path

func (*ROM) ParseBuild added in v0.0.2

func (r *ROM) ParseBuild() (string, string)

ParseBuild returns team, date

type Room added in v0.0.2

type Room struct {
	ID              byte
	VROMStart       uint32
	DataStartOffset uint32 // VROM offset to the Room data
	LocationHeader

	SceneName      string
	SceneVROMStart uint32 // VROM offset the the Scene this Room belongs to

	ActorList []ActorEntry
	// contains filtered or unexported fields
}

A Room is a room within a Scene

type Scene

type Scene struct {
	InternalSceneTableEntry
	LocationHeader

	Rooms []Room

	Name            string
	EntranceMessage string
	Valid           bool   // Is the scene valid (has data)
	DataStartOffset uint32 // ROM offset to the scene data
	// contains filtered or unexported fields
}

Scene holds a Scene headers and contents. A Scene contents size depends on where the 0x14 header end marker was found. Sources: - https://wiki.cloudmodding.com/mm/Scenes_and_Rooms#Header_Commands

type Vec3 added in v0.0.3

type Vec3 struct {
	X uint16
	Y uint16
	Z uint16
}

Vec3 is a simple x/y/z vector

type View

type View struct {
	Files    []File
	Scenes   []Scene
	Messages []Message
	// contains filtered or unexported fields
}

A View holds a ROM real data and accessors for dynamically placed data.

func NewView

func NewView(path string) (*View, error)

NewView creates a new view from a ROM

func (*View) Close

func (v *View) Close()

Close implements io.Closer

func (*View) GetFileByVROMStart added in v0.0.2

func (v *View) GetFileByVROMStart(start uint32) (*File, error)

GetFileByVROMStart returns a File from a VROMStart

func (*View) GetROM added in v0.0.2

func (v *View) GetROM() *ROM

GetROM returns the raw ROM struct

func (*View) GetRoomByVROMStart added in v0.0.2

func (v *View) GetRoomByVROMStart(start uint32) (*Room, error)

GetRoomByVROMStart returns a Room from a VROMStart

func (*View) GetSceneByVROMStart added in v0.0.2

func (v *View) GetSceneByVROMStart(start uint32) (*Scene, error)

GetSceneByVROMStart returns a Scene from a VROMStart

func (*View) Read

func (v *View) Read(p []byte) (n int, err error)

func (*View) Seek

func (v *View) Seek(offset int64, whence int) (int64, error)

Seek implements io.Seeker

Jump to

Keyboard shortcuts

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