fileio

package
v0.0.0-...-8a42bd8 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NODE_LEFT          = 0
	NODE_RIGHT         = 1
	TOTAL_IMAGE_WIDTH  = 320
	TOTAL_IMAGE_HEIGHT = 240
)
View Source
const (
	FLOOR_HEIGHT_UNIT = -1800

	SCA_TYPE_SLOPE  = 11
	SCA_TYPE_STAIRS = 12
)
View Source
const (
	OP_NO_OP            = 0
	OP_EVT_END          = 1
	OP_EVT_NEXT         = 2
	OP_EVT_CHAIN        = 3
	OP_EVT_EXEC         = 4
	OP_EVT_KILL         = 5
	OP_IF_START         = 6
	OP_ELSE_START       = 7
	OP_END_IF           = 8
	OP_SLEEP            = 9
	OP_SLEEPING         = 10
	OP_WSLEEP           = 11
	OP_WSLEEPING        = 12
	OP_FOR              = 13
	OP_FOR_END          = 14
	OP_WHILE_START      = 15
	OP_WHILE_END        = 16
	OP_DO_START         = 17
	OP_DO_END           = 18
	OP_SWITCH           = 19
	OP_CASE             = 20
	OP_DEFAULT          = 21
	OP_END_SWITCH       = 22
	OP_GOTO             = 23
	OP_GOSUB            = 24
	OP_GOSUB_RETURN     = 25
	OP_BREAK            = 26
	OP_WORK_COPY        = 29
	OP_NO_OP2           = 32
	OP_CHECK            = 33
	OP_SET_BIT          = 34
	OP_COMPARE          = 35
	OP_SAVE             = 36
	OP_COPY             = 37
	OP_CALC             = 38
	OP_CALC2            = 39
	OP_SCE_RND          = 40
	OP_CUT_CHG          = 41
	OP_CUT_OLD          = 42
	OP_MESSAGE_ON       = 43
	OP_AOT_SET          = 44
	OP_OBJ_MODEL_SET    = 45
	OP_WORK_SET         = 46
	OP_SPEED_SET        = 47
	OP_ADD_SPEED        = 48
	OP_ADD_ASPEED       = 49
	OP_POS_SET          = 50
	OP_DIR_SET          = 51
	OP_MEMBER_SET       = 52
	OP_MEMBER_SET2      = 53
	OP_SE_ON            = 54
	OP_SCA_ID_SET       = 55
	OP_DIR_CK           = 57
	OP_SCE_ESPR_ON      = 58
	OP_DOOR_AOT_SET     = 59
	OP_CUT_AUTO         = 60
	OP_MEMBER_COPY      = 61
	OP_MEMBER_CMP       = 62
	OP_PLC_MOTION       = 63
	OP_PLC_DEST         = 64
	OP_PLC_NECK         = 65
	OP_PLC_RET          = 66
	OP_PLC_FLAG         = 67
	OP_SCE_EM_SET       = 68
	OP_AOT_RESET        = 70
	OP_AOT_ON           = 71
	OP_SUPER_SET        = 72
	OP_CUT_REPLACE      = 75
	OP_SCE_ESPR_KILL    = 76
	OP_DOOR_MODEL_SET   = 77
	OP_ITEM_AOT_SET     = 78
	OP_SCE_TRG_CK       = 80
	OP_SCE_BGM_CONTROL  = 81
	OP_SCE_ESPR_CONTROL = 82
	OP_SCE_FADE_SET     = 83
	OP_SCE_ESPR3D_ON    = 84
	OP_SCE_BGMTBL_SET   = 87
	OP_PLC_ROT          = 88
	OP_XA_ON            = 89
	OP_WEAPON_CHG       = 90
	OP_PLC_CNT          = 91
	OP_SCE_SHAKE_ON     = 92
	OP_MIZU_DIV_SET     = 93
	OP_KEEP_ITEM_CK     = 94
	OP_XA_VOL           = 95
	OP_KAGE_SET         = 96
	OP_CUT_BE_SET       = 97
	OP_SCE_ITEM_LOST    = 98
	OP_PLC_GUN_EFF      = 99
	OP_SCE_ESPR_ON2     = 100
	OP_SCE_ESPR_KILL2   = 101
	OP_PLC_STOP         = 102
	OP_AOT_SET_4P       = 103
	OP_DOOR_AOT_SET_4P  = 104
	OP_ITEM_AOT_SET_4P  = 105
	OP_LIGHT_POS_SET    = 106
	OP_LIGHT_KIDO_SET   = 107
	OP_RBJ_RESET        = 108
	OP_SCE_SCR_MOVE     = 109
	OP_PARTS_SET        = 110
	OP_MOVIE_ON         = 111
	OP_SCE_PARTS_BOMB   = 122
	OP_SCE_PARTS_DOWN   = 123
)
View Source
const (
	TIM_BPP_4  = 8
	TIM_BPP_8  = 9
	TIM_BPP_16 = 2
	TIM_BPP_24 = 3
)

Variables

View Source
var (
	InstructionSize = map[byte]int{}/* 103 elements not displayed */

)

Functions

func CalculateFOVDegrees

func CalculateFOVDegrees(distanceToScreen int) float32

Types

type ADTOutput

type ADTOutput struct {
	PixelData [][]uint16
	RawData   []uint8
}

func LoadADTFile

func LoadADTFile(inputFilename string) *ADTOutput

func LoadADTStream

func LoadADTStream(adtReader io.ReaderAt) *ADTOutput

func (*ADTOutput) ConvertToPNG

func (adtOutput *ADTOutput) ConvertToPNG(outputFilename string)

func (*ADTOutput) ConvertToRenderData

func (adtOutput *ADTOutput) ConvertToRenderData() []uint16

type AnimBlockHeader

type AnimBlockHeader struct {
	NumFrames  uint16
	NumSprites uint16
	Width      uint8
	Height     uint8
	Unknown    uint16
}

type AnimFrame

type AnimFrame struct {
	SpriteId   uint8
	Count      uint8
	Time       uint8
	SquareSide uint8 // length and width are the same
	X          int16
	Y          int16
}

type AnimMovement

type AnimMovement struct {
	FunctionId0  uint8
	FunctionId1  uint8
	Unknown0     [2]uint8
	TranslateX   uint16
	TranslateY   uint16
	Acceleration [3]uint8
	Unknown1     uint8
	Speed        [3]int16
	Unknown2     [3]uint16
}

type AnimSprite

type AnimSprite struct {
	ImageX  uint8
	ImageY  uint8
	OffsetX int8
	OffsetY int8
}

x and y are top-left position of sprite in TIM sprite sheet Offset is used to shift sprite frame to align it with other frames with different dimensions

type AnimationFrame

type AnimationFrame struct {
	FrameHeader    EMRFrame
	RotationAngles []mgl32.Vec3
}

type BinOutput

type BinOutput struct {
	ImagesIndex []ImageFile
	FileLength  int64
}

func LoadBINFile

func LoadBINFile(inputFilename string) *BinOutput

type BitReader

type BitReader struct {
	// contains filtered or unexported fields
}

func NewBitReader

func NewBitReader(r *io.SectionReader) *BitReader

func (*BitReader) ReadBit

func (r *BitReader) ReadBit() (int, error)

Reads the next bit in the file

func (*BitReader) ReadBitLittleEndian

func (r *BitReader) ReadBitLittleEndian() (int, error)

func (*BitReader) ReadNumBits

func (r *BitReader) ReadNumBits(numBits int) (uint64, error)

Reads a sequence of bits in sequential order Do not use this function if the data is in little endian

func (*BitReader) ReadNumBitsLittleEndian

func (r *BitReader) ReadNumBitsLittleEndian(numBits int) (uint64, error)

func (*BitReader) UnsafeReadBit

func (r *BitReader) UnsafeReadBit() int

No error handling

func (*BitReader) UnsafeReadByte

func (r *BitReader) UnsafeReadByte() byte

func (*BitReader) UnsafeReadNumBits

func (r *BitReader) UnsafeReadNumBits(numBits int) uint64

func (*BitReader) UnsafeReadNumBitsLittleEndian

func (r *BitReader) UnsafeReadNumBitsLittleEndian(numBits int) uint64

type CameraInfo

type CameraInfo struct {
	CameraFrom mgl32.Vec3
	CameraTo   mgl32.Vec3
	CameraFov  float32 // in degrees
}

type CollisionEntity

type CollisionEntity struct {
	ScaIndex    int
	X           int
	Z           int
	Width       int
	Density     int
	Shape       int
	SlopeHeight int
	SlopeType   int
	RampBottom  float32
	FloorCheck  []bool
}

type DO2FileFormat

type DO2FileFormat struct {
	VHOffset  int64 // .vab header
	VHLength  int64
	VBOffset  int64 // .vab data
	VBLength  int64
	MD1Offset int64 // model file
	MD1Length int64
	TIMOffset int64 // texture file
	TIMLength int64
}

type DO2Output

type DO2Output struct {
	VABHeaderOutput *VABHeaderOutput
	MD1Output       *MD1Output
	TIMOutput       *TIMOutput
	DO2FileFormat   *DO2FileFormat
}

func LoadDO2File

func LoadDO2File(filename string) *DO2Output

func LoadDO2Stream

func LoadDO2Stream(r io.ReaderAt, fileLength int64) (*DO2Output, error)

type EDDHeaderObject

type EDDHeaderObject struct {
	Count  uint16
	Offset uint16
}

type EDDOutput

type EDDOutput struct {
	AnimationIndexFrames [][]EDDTableElement
	NumFrames            int
}

func LoadEDDStream

func LoadEDDStream(r io.ReaderAt, fileLength int64) (*EDDOutput, error)

type EDDTableElement

type EDDTableElement struct {
	FrameId int
	Flag    int
}

type EMDHeader

type EMDHeader struct {
	DirOffset uint32 // offset to directory
	DirCount  uint32 // number of objects in directory
}

type EMDOffsets

type EMDOffsets struct {
	OffsetUnknown    uint32
	OffsetAnimation1 uint32 // .edd file
	OffsetSkeleton1  uint32 // .emr file
	OffsetAnimation2 uint32 // .edd file
	OffsetSkeleton2  uint32 // .emr file
	OffsetAnimation3 uint32 // .edd file
	OffsetSkeleton3  uint32 // .emr file
	OffsetMesh       uint32 // .md1 file
}

type EMDOutput

type EMDOutput struct {
	AnimationData1 *EDDOutput
	SkeletonData1  *EMROutput
	AnimationData2 *EDDOutput
	SkeletonData2  *EMROutput
	AnimationData3 *EDDOutput
	SkeletonData3  *EMROutput
	MeshData       *MD1Output
}

func LoadEMDFile

func LoadEMDFile(filename string) *EMDOutput

func LoadEMDStream

func LoadEMDStream(r io.ReaderAt, fileLength int64) (*EMDOutput, error)

type EMRArmature

type EMRArmature struct {
	Count  uint16 // Number of meshes linked to this one
	Offset uint16
}

type EMRFrame

type EMRFrame struct {
	XOffset int16
	YOffset int16
	ZOffset int16
	XSpeed  int16
	YSpeed  int16
	ZSpeed  int16
}

type EMRHeader

type EMRHeader struct {
	OffsetArmatures uint16
	OffsetFrames    uint16
	Count           uint16
	ElementSize     uint16
}

type EMROutput

type EMROutput struct {
	RelativePositionData []EMRRelativePosition
	ArmatureData         []EMRArmature
	ArmatureChildren     [][]uint8
	MeshIdList           []uint8
	FrameData            []AnimationFrame
}

func LoadEMRStream

func LoadEMRStream(r io.ReaderAt, fileLength int64, animationData *EDDOutput) (*EMROutput, error)

type EMRRelativePosition

type EMRRelativePosition struct {
	X int16
	Y int16
	Z int16
}

type ESPHeader

type ESPHeader struct {
	Ids [8]uint8 // If value doesn't equal 0xff, there is an animation
}

type ESPOutput

type ESPOutput struct {
	SpriteData       []SpriteData
	ValidSpriteCount int
}

func LoadESPFile

func LoadESPFile(filename string) *ESPOutput

func LoadESPStream

func LoadESPStream(r io.ReaderAt, fileLength int64, eofOffset int64) (*ESPOutput, error)

func LoadRDT_ESP

func LoadRDT_ESP(r io.ReaderAt, fileLength int64, rdtHeader RDTHeader, offsets RDTOffsets) (*ESPOutput, error)

type FLROutput

type FLROutput struct {
	FloorSounds []FLRSound
}

func LoadRDT_FLRStream

func LoadRDT_FLRStream(r io.ReaderAt, fileLength int64, offsets RDTOffsets) (*FLROutput, error)

type FLRSound

type FLRSound struct {
	X           int16
	Y           int16
	Width       uint16
	Depth       uint16
	SoundEffect uint16
	Height      uint16
}

type ImageFile

type ImageFile struct {
	Offset uint32
	Length uint32
}

func LoadBIN

func LoadBIN(r io.ReaderAt, archiveLength int64) ([]ImageFile, error)

type LITCameraLight

type LITCameraLight struct {
	LightType    [2]uint16
	Colors       [3]LITLightColor // Color for each light
	AmbientColor LITLightColor    // Ambient color for camera
	Positions    [3]LITPosition   // Position for each light
	Brightness   [3]uint16        // Brightness for each light
}

type LITLightColor

type LITLightColor struct {
	R uint8
	G uint8
	B uint8
}

type LITOutput

type LITOutput struct {
	Lights []LITCameraLight
}

func LoadRDT_LIT

func LoadRDT_LIT(r io.ReaderAt, fileLength int64, rdtHeader RDTHeader, offsets RDTOffsets) (*LITOutput, error)

type LITPosition

type LITPosition struct {
	X int16
	Y int16
	Z int16
}

type MD1Header

type MD1Header struct {
	SectionLengthBytes uint32
	Unknown            uint32
	NumObj             uint32
}

type MD1Object

type MD1Object struct {
	TriangleVertices []MD1Vertex
	TriangleNormals  []MD1Vertex
	TriangleIndices  []MD1TriangleIndex
	TriangleTextures []MD1TriangleTexture
	QuadVertices     []MD1Vertex
	QuadNormals      []MD1Vertex
	QuadIndices      []MD1QuadIndex
	QuadTextures     []MD1QuadTexture
}

type MD1ObjectHeader

type MD1ObjectHeader struct {
	TrianglesHeader MD1TrianglesHeader
	QuadsHeader     MD1QuadsHeader
}

type MD1Output

type MD1Output struct {
	Components []MD1Object
	NumBytes   int64
}

func LoadMD1Stream

func LoadMD1Stream(r io.ReaderAt, fileLength int64) (*MD1Output, error)

type MD1QuadIndex

type MD1QuadIndex struct {
	IndexNormal0 uint16
	IndexVertex0 uint16
	IndexNormal1 uint16
	IndexVertex1 uint16
	IndexNormal2 uint16
	IndexVertex2 uint16
	IndexNormal3 uint16
	IndexVertex3 uint16
}

type MD1QuadTexture

type MD1QuadTexture struct {
	U0     uint8 // UV coordinates for vertex 0
	V0     uint8
	ClutId uint16 // Texture clut id, bits 0-5
	U1     uint8  // UV coordinates for vertex 1
	V1     uint8
	Page   uint16 // Texture page
	U2     uint8  // UV coordinates for vertex 2
	V2     uint8
	Zero1  uint16
	U3     uint8 // UV coordinates for vertex 3
	V3     uint8
	Zero2  uint16
}

type MD1QuadsHeader

type MD1QuadsHeader struct {
	VertexOffset    uint32
	VertexCount     uint32
	NormalOffset    uint32
	NormalCount     uint32
	QuadIndexOffset uint32
	QuadIndexCount  uint32
	TextureOffset   uint32
}

type MD1TriangleIndex

type MD1TriangleIndex struct {
	IndexNormal0 uint16
	IndexVertex0 uint16
	IndexNormal1 uint16
	IndexVertex1 uint16
	IndexNormal2 uint16
	IndexVertex2 uint16
}

type MD1TriangleTexture

type MD1TriangleTexture struct {
	U0     uint8 // UV coordinates for vertex 0
	V0     uint8
	ClutId uint16 // Texture clut id, bits 0-5
	U1     uint8  // UV coordinates for vertex 1
	V1     uint8
	Page   uint16 // Texture page
	U2     uint8  // UV coordinates for vertex 2
	V2     uint8
	Zero   uint16
}

type MD1TrianglesHeader

type MD1TrianglesHeader struct {
	VertexOffset        uint32
	VertexCount         uint32
	NormalOffset        uint32
	NormalCount         uint32
	TriangleIndexOffset uint32
	TriangleIndexCount  uint32
	TextureOffset       uint32
}

type MD1Vertex

type MD1Vertex struct {
	X    int16
	Y    int16
	Z    int16
	Zero uint16
}

type MSGOutput

type MSGOutput struct {
}

func LoadRDT_MSGStream

func LoadRDT_MSGStream(fileReader io.ReaderAt, fileLength int64) (*MSGOutput, error)

type MaskRectangle

type MaskRectangle struct {
	SrcX   int
	SrcY   int
	DestX  int
	DestY  int
	Depth  int
	Zero   int
	Width  int
	Height int
}

type Node

type Node struct {
	ChildNodes [2]int64
}

type PLDHeader

type PLDHeader struct {
	DirOffset uint32 // offset to directory
	DirCount  uint32 // number of objects in directory
}

type PLDOffsets

type PLDOffsets struct {
	OffsetAnimation uint32 // .edd file
	OffsetSkeleton  uint32 // .emr file
	OffsetMesh      uint32 // .md1 file
	OffsetTexture   uint32 // .tim file
}

type PLDOutput

type PLDOutput struct {
	AnimationData *EDDOutput
	SkeletonData  *EMROutput
	MeshData      *MD1Output
	TextureData   *TIMOutput
}

func LoadPLDFile

func LoadPLDFile(filename string) (*PLDOutput, error)

func LoadPLDStream

func LoadPLDStream(r io.ReaderAt, fileLength int64) (*PLDOutput, error)

type PRIHeader

type PRIHeader struct {
	CountOffsets uint16
	CountMasks   uint16
}

type PRIMaskRectangle

type PRIMaskRectangle struct {
	SrcX   uint8  // x-coordinate on source .tim image
	SrcY   uint8  // x-coordinate on source .tim image
	DestX  uint8  // destination x-coordinate
	DestY  uint8  // destination y-coordinate
	DestZ  uint16 //  destination z-coordinate (depth/z-buffer)
	Zero   uint16
	Width  uint16 // width of the mask tile
	Height uint16 // height of the mask tile
}

type PRIMaskSquare

type PRIMaskSquare struct {
	SrcX  uint8  // x-coordinate on source .tim image
	SrcY  uint8  // x-coordinate on source .tim image
	DestX uint8  // destination x-coordinate
	DestY uint8  // destination y-coordinate
	DestZ uint16 // destination z-coordinate (depth/z-buffer)
	Width uint16 // width of the mask tile
}

type PRIOutput

type PRIOutput struct {
	Masks []MaskRectangle
}

func LoadRDT_PRI

func LoadRDT_PRI(r io.ReaderAt, fileLength int64) (*PRIOutput, error)

type PRIRelativeOffset

type PRIRelativeOffset struct {
	MaskCount uint16 // Number of masks with which to use this structure
	Unknown   uint16
	DestX     int16 // Destination position on background image
	DestY     int16
}

type RDTHeader

type RDTHeader struct {
	NumSprites uint8
	NumCameras uint8
	NumModels  uint8
	NumItems   uint8
	NumDoors   uint8
	NumRooms   uint8
	NumReverb  uint8 // related to sound
	SpriteMax  uint8 // max number of .pri sprites used by one of the room's cameras
}

type RDTItemOffsets

type RDTItemOffsets struct {
	OffsetTexture uint32 // .tim file
	OffsetModel   uint32 // .md1 file
}

type RDTOffsets

type RDTOffsets struct {
	OffsetRoomSound              uint32 // offset to room .snd sound table data
	OffsetRoomVABHeader          uint32 // .vh file
	OffsetRoomVABData            uint32 // .vb file
	OffsetEnemyVABHeader         uint32 // .vh file
	OffsetEnemyVABData           uint32 // .vb file
	OffsetOTA                    uint32
	OffsetCollisionData          uint32 // .sca file
	OffsetCameraPosition         uint32 // .rid file
	OffsetCameraSwitches         uint32 // .rvd file
	OffsetLights                 uint32 // .lit file
	OffsetItems                  uint32
	OffsetFloorSound             uint32 // .flr file
	OffsetBlocks                 uint32 // .blk file
	OffsetLang1                  uint32 // .msg file
	OffsetLang2                  uint32 // .msg file
	OffsetScrollTexture          uint32 // .tim file
	OffsetInitScript             uint32 // .scd file
	OffsetExecuteScript          uint32 // .scd file
	OffsetSpriteAnimations       uint32 // .esp file
	OffsetSpriteAnimationsOffset uint32 // .esp file
	OffsetSpriteImage            uint32 // .tim file
	OffsetModelImage             uint32 // .tim file
	OffsetRBJ                    uint32 // .rbj file
}

type RDTOutput

type RDTOutput struct {
	Header           RDTHeader
	RIDOutput        *RIDOutput // camera positions
	CameraSwitchData *RVDOutput
	LightData        *LITOutput
	CollisionData    *SCAOutput
	InitScriptData   *SCDOutput
	RoomScriptData   *SCDOutput
	SpriteOutput     *ESPOutput
	ItemTextureData  []*TIMOutput
	ItemModelData    []*MD1Output
}

func LoadRDT

func LoadRDT(r io.ReaderAt, fileLength int64) (*RDTOutput, error)

func LoadRDTFile

func LoadRDTFile(filename string) (*RDTOutput, error)

type RIDHeader

type RIDHeader struct {
	Flag             uint16
	DistanceToScreen uint16
	CameraFromX      int32
	CameraFromY      int32
	CameraFromZ      int32
	CameraToX        int32
	CameraToY        int32
	CameraToZ        int32
	MaskOffset       uint32
}

type RIDOutput

type RIDOutput struct {
	CameraPositions []CameraInfo
	CameraMasks     [][]MaskRectangle
}

func LoadRDT_RID

func LoadRDT_RID(r io.ReaderAt, fileLength int64, rdtHeader RDTHeader, offsets RDTOffsets) (*RIDOutput, error)

type RVDHeader

type RVDHeader struct {
	Flag  byte
	Floor byte
	Cam0  uint8
	Cam1  uint8
	X1    int16
	Z1    int16
	X2    int16
	Z2    int16
	X3    int16
	Z3    int16
	X4    int16
	Z4    int16
}

type RVDOutput

type RVDOutput struct {
	CameraSwitches []RVDHeader
}

func LoadRDT_RVD

func LoadRDT_RVD(r io.ReaderAt, fileLength int64, rdtHeader RDTHeader, offsets RDTOffsets) (*RVDOutput, error)

A camera switch is a flat zone in 3D space, where you switch from one camera to another when the player crosses it

type RoomImageOutput

type RoomImageOutput struct {
	BackgroundImage *ADTOutput
	ImageMask       *TIMOutput
}

func ExtractItemImage

func ExtractItemImage(inputFilename string, binOutput *BinOutput, imageId int) *RoomImageOutput

func ExtractRoomBackground

func ExtractRoomBackground(inputFilename string, binOutput *BinOutput, roomId int) *RoomImageOutput

Room image is stored as an ADT file

type SAPOutput

type SAPOutput struct {
	AudioData []byte
}

func LoadSAPFile

func LoadSAPFile(filename string) *SAPOutput

func (*SAPOutput) ConvertToWAV

func (sapOutput *SAPOutput) ConvertToWAV(outputFilename string)

type SCAElement

type SCAElement struct {
	X            int16
	Z            int16
	Width        uint16
	Density      uint16
	Flag         uint16
	Type         uint16
	FloorNumFlag uint32
}

type SCAHeader

type SCAHeader struct {
	CeilingX       int16
	CeilingZ       int16
	Count          uint32
	CeilingY       int32
	CeilingWidth   uint16
	CeilingDensity uint16
}

type SCAOutput

type SCAOutput struct {
	CollisionEntities []CollisionEntity
}

func LoadRDT_SCA

func LoadRDT_SCA(r io.ReaderAt, fileLength int64, rdtHeader RDTHeader, offsets RDTOffsets) (*SCAOutput, error)

type SCDOutput

type SCDOutput struct {
	ScriptData ScriptFunction
}

func LoadRDT_SCDStream

func LoadRDT_SCDStream(fileReader io.ReaderAt, fileLength int64) (*SCDOutput, error)

type ScriptFunction

type ScriptFunction struct {
	Instructions        map[int][]byte // key is program counter, value is command
	StartProgramCounter []int          // set per function
}

type ScriptInstrAotReset

type ScriptInstrAotReset struct {
	Opcode uint8 // 0x46
	Aot    uint8
	Id     uint8
	Type   uint8
	Data   [6]uint8
}

type ScriptInstrAotSet

type ScriptInstrAotSet struct {
	Opcode       uint8 // 0x2c
	Aot          uint8
	Id           uint8
	Type         uint8
	Floor        uint8
	Super        uint8
	X, Z         int16
	Width, Depth int16
	Data         [6]uint8
}

type ScriptInstrAotSet4p

type ScriptInstrAotSet4p struct {
	Opcode uint8 // 0x67
	Aot    uint8
	Id     uint8
	Type   uint8
	Floor  uint8
	Super  uint8
	X1, Z1 int16
	X2, Z2 int16
	X3, Z3 int16
	X4, Z4 int16
	Data   [6]uint8
}

type ScriptInstrCalc

type ScriptInstrCalc struct {
	Opcode    uint8 // 0x26
	Dummy     uint8
	Operation uint8
	VarId     uint8
	Value     uint8
}

type ScriptInstrCalc2

type ScriptInstrCalc2 struct {
	Opcode      uint8 // 0x26
	Operation   uint8
	VarId       uint8
	SourceVarId uint8
}

type ScriptInstrCheckBitTest

type ScriptInstrCheckBitTest struct {
	Opcode    uint8 // 0x21
	BitArray  uint8 // Index of array of bits to use
	BitNumber uint8 // Bit number to check
	Value     uint8 // Value to compare (0 or 1)
}

type ScriptInstrCompare

type ScriptInstrCompare struct {
	Opcode    uint8 // 0x23
	Dummy     uint8
	VarId     uint8
	Operation uint8
	Value     int16 // Value to compare against
}

type ScriptInstrCopy

type ScriptInstrCopy struct {
	Opcode      uint8 // 0x25
	DestVarId   uint8
	SourceVarId uint8
}

type ScriptInstrCutAuto

type ScriptInstrCutAuto struct {
	Opcode uint8 // 0x3c
	FlagOn uint8
}

type ScriptInstrCutChg

type ScriptInstrCutChg struct {
	Opcode   uint8 // 0x29
	CameraId uint8
}

type ScriptInstrDoorAotSet

type ScriptInstrDoorAotSet struct {
	Opcode                       uint8 // 0x3b
	Aot                          uint8 // Index of item in array of room objects list
	Id                           uint8
	Type                         uint8
	Floor                        uint8
	Super                        uint8
	X, Z                         int16 // Location of door
	Width, Depth                 int16 // Size of door
	NextX, NextY, NextZ, NextDir int16 // Position and direction of player after door entered
	Stage, Room, Camera          uint8 // Stage, room, camera after door entered
	NextFloor                    uint8
	TextureType                  uint8
	DoorType                     uint8
	KnockType                    uint8
	KeyId                        uint8
	KeyType                      uint8
	Free                         uint8
}

type ScriptInstrDoorAotSet4p

type ScriptInstrDoorAotSet4p struct {
	Opcode                       uint8 // 0x68
	Aot                          uint8 // Index of item in array of room objects list
	Id                           uint8
	Type                         uint8
	Floor                        uint8
	Super                        uint8
	X1, Z1                       int16
	X2, Z2                       int16
	X3, Z3                       int16
	X4, Z4                       int16
	NextX, NextY, NextZ, NextDir int16 // Position and direction of player after door entered
	Stage, Room, Camera          uint8 // Stage, room, camera after door entered
	NextFloor                    uint8
	TextureType                  uint8
	DoorType                     uint8
	KnockType                    uint8
	KeyId                        uint8
	KeyType                      uint8
	Free                         uint8
}

type ScriptInstrDoorModelSet

type ScriptInstrDoorModelSet struct {
	Opcode      uint8 // 0x4d
	Index       uint8
	Id          uint8
	Type        uint8
	Flag        uint8
	ModelNumber uint8
	Unknown0    uint16
	Unknown1    uint16
	Position    [3]int16
	Direction   [3]int16
}

type ScriptInstrElseStart

type ScriptInstrElseStart struct {
	Opcode      uint8 // 0x07
	Dummy       uint8
	BlockLength uint16
}

type ScriptInstrEventExec

type ScriptInstrEventExec struct {
	Opcode    uint8 // 0x04
	ThreadNum uint8
	ExOpcode  uint8
	Event     uint8
}

type ScriptInstrForStart

type ScriptInstrForStart struct {
	Opcode      uint8 // 0x0d
	Dummy       uint8
	BlockLength uint16
	Count       uint16
}

type ScriptInstrGoSub

type ScriptInstrGoSub struct {
	Opcode uint8 // 0x18
	Event  uint8
}

type ScriptInstrGoto

type ScriptInstrGoto struct {
	Opcode        uint8 // 0x17
	IfElseCounter int8
	LoopLevel     int8
	Unknown       uint8
	Offset        int16
}

type ScriptInstrIfElseStart

type ScriptInstrIfElseStart struct {
	Opcode      uint8 // 0x06
	Dummy       uint8
	BlockLength uint16
}

type ScriptInstrItemAotSet

type ScriptInstrItemAotSet struct {
	Opcode          uint8 // 0x4e
	Aot             uint8
	Id              uint8
	Type            uint8
	Floor           uint8
	Super           uint8
	X, Z            int16
	Width, Depth    int16
	ItemId          uint16
	Amount          uint16
	ItemPickedIndex uint16 // flag to check if item is picked up
	Md1ModelId      uint8
	Act             uint8
}

type ScriptInstrItemAotSet4p

type ScriptInstrItemAotSet4p struct {
	Opcode          uint8 // 0x69
	Aot             uint8
	Id              uint8
	Type            uint8
	Floor           uint8
	Super           uint8
	X1, Z1          int16
	X2, Z2          int16
	X3, Z3          int16
	X4, Z4          int16
	ItemId          uint16
	Amount          uint16
	ItemPickedIndex uint16 // flag to check if item is picked up
	Md1ModelId      uint8
	Act             uint8
}

type ScriptInstrKageSet

type ScriptInstrKageSet struct {
	Opcode           uint8 // 0x60
	WorkSetComponent uint8
	WorkSetIndex     uint8
	Color            [3]uint8
	HalfX, HalfZ     int16
	OffsetX, OffsetZ int16
}

type ScriptInstrMemberCompare

type ScriptInstrMemberCompare struct {
	Opcode           uint8 // 0x3e
	Unknown0         uint8
	MemberIndex      uint8
	CompareOperation uint8 // 0 - 6
	Value            int16
}

type ScriptInstrMemberSet

type ScriptInstrMemberSet struct {
	Opcode      uint8 // 0x34
	MemberIndex uint8
	Value       uint16
}

type ScriptInstrMizuDivSet

type ScriptInstrMizuDivSet struct {
	Opcode     uint8 // 0x5d
	MizuDivMax uint8
}

type ScriptInstrObjModelSet

type ScriptInstrObjModelSet struct {
	Opcode      uint8 // 0x2d
	ObjectIndex uint8
	ObjectId    uint8
	Counter     uint8
	Wait        uint8
	Num         uint8
	Floor       uint8
	Flag0       uint8
	Type        uint16
	Flag1       uint16
	Attribute   int16
	Position    [3]int16
	Direction   [3]int16
	Offset      [3]int16
	Dimensions  [3]uint16
}

type ScriptInstrPlcDest

type ScriptInstrPlcDest struct {
	Opcode     uint8 // 0x40
	Dummy      uint8
	Action     uint8
	FlagNumber uint8
	DestX      int16
	DestZ      int16
}

type ScriptInstrPlcFlag

type ScriptInstrPlcFlag struct {
	Opcode    uint8 // 0x43
	Operation uint8 // 0: OR, 1: Set, 2: XOR
	Flag      uint16
}

type ScriptInstrPlcMotion

type ScriptInstrPlcMotion struct {
	Opcode     uint8 // 0x3f
	Action     uint8
	MoveNumber uint8
	SceneFlag  uint8
}

type ScriptInstrPlcNeck

type ScriptInstrPlcNeck struct {
	Opcode    uint8 // 0x41
	Operation uint8
	NeckX     int16
	NeckY     int16
	NeckZ     int16
	Unknown   [2]int8
}

type ScriptInstrPlcRot

type ScriptInstrPlcRot struct {
	Opcode uint8 // 0x58
	Index  uint8 // 0 or 1
	Value  int16
}

type ScriptInstrPosSet

type ScriptInstrPosSet struct {
	Opcode uint8 // 0x32
	Dummy  uint8
	X      int16
	Y      int16
	Z      int16
}

type ScriptInstrSave

type ScriptInstrSave struct {
	Opcode uint8 // 0x24
	VarId  uint8
	Value  int16
}

type ScriptInstrScaIdSet

type ScriptInstrScaIdSet struct {
	Opcode uint8 // 0x37
	Id     uint8
	Flag   uint16
}

type ScriptInstrSceBgmControl

type ScriptInstrSceBgmControl struct {
	Opcode      uint8 // 0x51
	Id          uint8 // 0: Main, 1: sub0, 2: sub1
	Operation   uint8 // 0: nop, 1: start, 2: stop, 3: restart, 4: pause, 5: fadeout
	Type        uint8 // 0: MAIN_VOL, 1: PROG0_VOL, 2: PROG1_VOL, 3: PROG2_VOL
	LeftVolume  uint8
	RightVolume uint8
}

type ScriptInstrSceEmSet

type ScriptInstrSceEmSet struct {
	Opcode    uint8 // 0x44
	Dummy     uint8
	Aot       uint8
	Id        uint8
	Type      uint8
	Status    uint8
	Floor     uint8
	SoundFlag uint8
	ModelType uint8
	EmSetFlag int8
	X, Y, Z   int16
	DirY      uint16
	Motion    uint16
	CtrFlag   uint16
}

type ScriptInstrSceEspr3DOn

type ScriptInstrSceEspr3DOn struct {
	Opcode   uint8 // 0x54
	Dummy    uint8
	Unknown0 uint16
	Work     uint16
	Unknown1 uint16
	Vector1  [3]int16
	Vector2  [3]int16
	DirY     uint16
}

type ScriptInstrSceEsprControl

type ScriptInstrSceEsprControl struct {
	Opcode        uint8 // 0x52
	Id            uint8
	Type          uint8
	Action        uint8
	WorkComponent uint8
	WorkIndex     uint8
}

type ScriptInstrSceEsprKill

type ScriptInstrSceEsprKill struct {
	Opcode        uint8 // 0x4c
	Id            uint8
	Type          uint8
	WorkComponent uint8
	WorkIndex     uint8
}

type ScriptInstrSceEsprOn

type ScriptInstrSceEsprOn struct {
	Opcode   uint8 // 0x3a
	Dummy    uint8
	Id       uint8
	Type     uint8
	Work     uint16
	Unknown1 int16
	X, Y, Z  int16
	DirY     uint16
}

type ScriptInstrSetBit

type ScriptInstrSetBit struct {
	Opcode    uint8 // 0x22
	BitArray  uint8 // Index of array of bits to use
	BitNumber uint8 // Bit number to check
	Operation uint8 // 0x0: clear, 0x1: set, 0x2-0x6: invalid, 0x7: flip bit
}

type ScriptInstrSleep

type ScriptInstrSleep struct {
	Opcode uint8 // 0x09
	Dummy  uint8
	Count  uint16
}

type ScriptInstrSwitch

type ScriptInstrSwitch struct {
	Opcode      uint8 // 0x13
	VarId       uint8
	BlockLength uint16
}

type ScriptInstrSwitchCase

type ScriptInstrSwitchCase struct {
	Opcode      uint8 // 0x14
	Dummy       uint8
	BlockLength uint16
	Value       uint16
}

type ScriptInstrWorkSet

type ScriptInstrWorkSet struct {
	Opcode    uint8 // 0x2e
	Component uint8
	Index     uint8
}

type ScriptInstrXaOn

type ScriptInstrXaOn struct {
	Opcode  uint8 // 0x59
	Channel uint8 // channel on which to play sound
	Id      int16 // ID of sound to play
}

type SpriteData

type SpriteData struct {
	Id             int
	FrameData      []AnimFrame
	FramePositions []AnimSprite
	AnimMovements  []AnimMovement
	ImageData      *TIMOutput
}

type StreamReader

type StreamReader struct {
	// contains filtered or unexported fields
}

func NewStreamReader

func NewStreamReader(r *io.SectionReader) *StreamReader

func (*StreamReader) ReadData

func (streamReader *StreamReader) ReadData(data interface{}) error

func (*StreamReader) SetPosition

func (streamReader *StreamReader) SetPosition(newPosition int64)

type TIMHeader

type TIMHeader struct {
	Magic     uint32 // always 16
	BPP       uint32 // (8 = 4 bit), (9 = 8 bit), (2 = 16 bit), (3 = 24 bit)
	Offset    uint32
	OriginX   uint16
	OriginY   uint16
	NumColors uint16
	NumCluts  uint16
}

type TIMImageHeader

type TIMImageHeader struct {
	Size    uint32 // total image data size in bytes (image header + image data)
	OriginX uint16 // image x origin
	OriginY uint16 // image y origin
	Width   uint16 // *4 for 4 bit, *2 for 8 bit
	Height  uint16 // image height
}

type TIMOutput

type TIMOutput struct {
	PixelData   [][]uint16
	ImageWidth  int
	ImageHeight int
	NumPalettes int
	NumBytes    int
}

func LoadTIMFile

func LoadTIMFile(filename string) *TIMOutput

func LoadTIMImages

func LoadTIMImages(inputFilename string) ([]*TIMOutput, error)

func LoadTIMStream

func LoadTIMStream(r io.ReaderAt, fileLength int64) (*TIMOutput, error)

func (*TIMOutput) ConvertToPNG

func (timOutput *TIMOutput) ConvertToPNG(outputFilename string) error

func (*TIMOutput) ConvertToRenderData

func (timOutput *TIMOutput) ConvertToRenderData() []uint16

type UnpackArray

type UnpackArray struct {
	DataCount uint64
	Ptr8      []UnpackArray8
	Tree      []Node
}

type UnpackArray8

type UnpackArray8 struct {
	// contains filtered or unexported fields
}

type VABDataOutput

type VABDataOutput struct {
	RawADPCMData [][]uint8
	NumBytes     int
}

func LoadVABDataStream

func LoadVABDataStream(r io.ReaderAt, fileLength int64, vabHeaderOutput *VABHeaderOutput) (*VABDataOutput, error)

type VABHeader

type VABHeader struct {
	Magic          [4]byte // "pBAV"
	Version        uint32  // format version
	Id             uint32  // vab id
	Filesize       uint32  // waveform size in bytes
	Reserved0      uint16  // system reserved value
	ProgramCount   uint16  // total number of programs used
	ToneCount      uint16  // total number of tones used
	WaveformCount  uint16  // total number of waveforms (.vag files) used
	MasterVolume   uint8   // master volume used
	MasterPan      uint8   // master pan used
	BankAttribute1 uint8   // user defined attribute of bank 1
	BankAttribute2 uint8   // user defined attribute of bank 2
	Reserved1      uint32  // system reserved value
}

type VABHeaderOutput

type VABHeaderOutput struct {
	VABHeader  VABHeader
	AudioSizes []uint16
	NumBytes   int
}

func LoadVABHeaderStream

func LoadVABHeaderStream(r io.ReaderAt, fileLength int64) (*VABHeaderOutput, error)

type VABOutput

type VABOutput struct {
}

func LoadRDT_VABStream

func LoadRDT_VABStream(r io.ReaderAt, fileLength int64, offsets RDTOffsets) (*VABOutput, error)

type VABProgram

type VABProgram struct {
	Tones     uint8 // number of effective tones which compose the program
	Volume    uint8
	Priority  uint8
	Mode      uint8
	Pan       uint8
	Reserved0 uint8
	Attribute int16
	Reserved1 [2]uint32
}

type VABTone

type VABTone struct {
	Priority        uint8 // tone priority (0 - 127); used for controlling allocation when more voices than can be keyed on are requested
	Mode            uint8 // tone mode (0 = normal; 4 = reverb applied)
	Volume          uint8 // tone volume
	Pan             uint8 // tone pan
	Center          uint8 // center note (0~127)
	Shift           uint8 // pitch correction (0~127,cent units)
	NoteMin         uint8 // minimum note limit (0~127)
	NoteMax         uint8 // maximum note limit (0~127, provided min < max)
	VibratoWidth    uint8 // vibrato width (1/128 rate, 0~127)
	VibratoTime     uint8 // 1 cycle time of vibrato (tick units)
	PortamentoWidth uint8 // portamento width (1/128 rate, 0~127)
	PortamentoTime  uint8 // portamento holding time (tick units)
	PitchBendMin    uint8 // pitch bend (-0~127, 127 = 1 octave)
	PitchBendMax    uint8 // pitch bend (+0~127, 127 = 1 octave)
	Reserved1       uint8
	Reserved2       uint8
	Adsr1           uint16
	Adsr2           uint16
	Program         int16 // parent program
	Vag             int16 // waveform (VAG) used
	Reserved3       [4]int16
}

Jump to

Keyboard shortcuts

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