Documentation
¶
Index ¶
- Variables
- type Bank
- type ByteSwapper
- type CIC
- type Cmd
- type Device
- func (d *Device) Close() error
- func (d *Device) CmdDownload(ctx context.Context, w io.Writer, n int64, bank Bank, offset uint32) error
- func (d *Device) CmdFifoRead(ctx context.Context) (typ uint8, data []byte, err error)
- func (d *Device) CmdSetCicType(cic CIC) error
- func (d *Device) CmdSetSaveType(st SaveType) error
- func (d *Device) CmdUpgradeReport() (UpgradeStatus, error)
- func (d *Device) CmdUpgradeStart() error
- func (d *Device) CmdUpload(ctx context.Context, r io.Reader, n int64, bank Bank, offset uint32) error
- func (d *Device) CmdVersionRequest() (hwver Variant, fwver Version, magic [4]byte, err error)
- func (d *Device) Description() DeviceDesc
- func (d *Device) SendCmd(cmd Cmd, args []uint32, in []byte, out []byte) error
- type DeviceDesc
- type RPK
- type RPKAssetType
- type SaveType
- type UpgradeStatus
- type Variant
- type Version
Constants ¶
This section is empty.
Variables ¶
var ( // ErrCannotDetectByteswap indicates that a byteswap autodetection has failed ErrCannotDetectByteswap = errors.New("cannot detect byteswap format") // ErrInvalidBufferForByteswap indicates the the buffer has a length that is invalid for byteswapping ErrInvalidBufferForByteswap = errors.New("invalid buffer size for byteswapping") )
var ( ErrNoDevices = errors.New("no 64drive devices found") ErrMultipleDevices = errors.New("multiple 64drive devices found") ErrFrozen = errors.New("64drive seems frozen, please reset it") ErrUnsupported = errors.New("operation is not supported on this 64drive revision") ErrInvalidFifoHead = errors.New("invalid FIFO header") ErrUnknownDevice = errors.New("found compatible USB device which cannot be accessed") )
Functions ¶
This section is empty.
Types ¶
type Bank ¶
type Bank uint8
Bank represents a Nintendo 64 memory bank
type ByteSwapper ¶
type ByteSwapper uint8
ByteSwapper is a helper for byteswapping memory buffers
const ( // BSNone is the no-op byteswapper BSNone ByteSwapper = 0 // BSTwo byteswaps groups of 2 consecutive bytes in a buffer BSTwo ByteSwapper = 2 // BSFour byteswaps groups of 4 consecutive bytes in a buffer BSFour ByteSwapper = 4 )
func ByteSwapDetect ¶
func ByteSwapDetect(romHeader []byte) (ByteSwapper, error)
ByteSwapDetect detects the correct byteswapping format from a Nintendo 64 ROM header, by peeking at the magic number in the first 4 bytes. If the magic number is not found, ErrCannotDetectByteswap is returned.
func (ByteSwapper) ByteSwap ¶
func (bs ByteSwapper) ByteSwap(buf []byte) error
ByteSwap byteswaps a memory buffer. The memory size must have a length multiple of two or four respectively for BSTwo and BSFour. In case the length is invalid ErrInvalidBufferForByteswap is returned.
type CIC ¶
type CIC uint8
CIC is the Nintendo 64 protection chip. This type represents on the several versions that were produced.
const ( CIC6101 CIC = 0 CIC6102 CIC = 1 CIC7101 CIC = 2 CIC7102 CIC = 3 CICX103 CIC = 4 CICX105 CIC = 5 CICX106 CIC = 6 CIC5101 CIC = 7 )
Predefined Nintendo 64 CIC types, which 64drive can emulate.
func NewCICFromHeader ¶
NewCICFromHeader detects a CIC variant from a ROM header
func NewCICFromString ¶
NewCICFromString parses a string representing the CIC name (eg. "6103") and returns the corresponding CIC value, or an error if the string doesn't match any known CIC variant.
type Cmd ¶
type Cmd byte
Cmd is the type of a 64drive command send through USB
const ( // CmdLoadFromPc loads a bank of data from PC CmdLoadFromPc Cmd = 0x20 // CmdDumpToPc reads the contents of a bank to the PC CmdDumpToPc Cmd = 0x30 // CmdSetCicType sets the CIC emulation CmdSetCicType Cmd = 0x72 // CmdSetSaveType sets the save emulation CmdSetSaveType Cmd = 0x70 // CmdVersionRequest requests the hardware and firmware version CmdVersionRequest Cmd = 0x80 // CmdUpgradeStart starts a firmware upgrade CmdUpgradeStart Cmd = 0x84 // CmdUpgradeReport returns information on the ongoing firmware upgrade CmdUpgradeReport Cmd = 0x85 )
type Device ¶
type Device struct {
// contains filtered or unexported fields
}
func NewDeviceBySerial ¶
NewDeviceBySerial opens a specified 64drive, identified by its serial number. If no device is found, ErrNoDevices is returned.
func NewDeviceSingle ¶
NewDeviceSingle opens a connected 64drive device, that must be the only one connected to this PC. If multiple devices are found, it returns ErrMultipleDevices. If no devices are found, it returns ErrNoDevices.
func (*Device) CmdDownload ¶
func (*Device) CmdFifoRead ¶
func (*Device) CmdSetCicType ¶
CmdSetCicType configures the 64drive CIC emulation to the specified CIC version. CIC emulation is only available on 64drive HW2/RevB. The function will return ErrUnsupported when executed on HW1/RevA device.
func (*Device) CmdSetSaveType ¶
func (*Device) CmdUpgradeReport ¶
func (d *Device) CmdUpgradeReport() (UpgradeStatus, error)
CmdUpgradeReport reports the status of an ongoing firmware update
func (*Device) CmdUpgradeStart ¶
CmdUpgradeStart triggers a firmware upgrade. The firmware must have been already loaded in BankCARTROM at offset 0. The upgrade happens in background; use CmdUpgradeReport to get a report on the status of the upgrade. NOTE: removing power during an upgrade might brick the 64drive unit.
func (*Device) CmdVersionRequest ¶
CmdVersionRequest gets the 64drive hardware and firmware version, and a magic ID that identifies the device (it is used during firmware upgrades to make sure that the firmware being uploaded is designed for this device). The result of this call is internally cached, so that it doesn't require a USB communication after the first time it is invoked.
func (*Device) Description ¶
func (d *Device) Description() DeviceDesc
Description returns a DeviceDesc that describes the current device
type DeviceDesc ¶
type DeviceDesc struct { Manufacturer string // USB Manufacturer string (should always be "Retroactive") Description string // USB Description string (usually "64drive USB device" or "64drive USB device A") Serial string // Unique serial number of the device VendorID int // USB vendor ID ProductID int // USB product ID }
DeviceDesc describes a 64drive device found attached to the system.
func Enumerate ¶
func Enumerate() ([]DeviceDesc, bool)
Enumerate returns a list of all 64drive devices found attached to this system. It also returns a boolean flag indicating whether unknown compatible devices were found; on Windows, this might indicate a device which has no libusb-compatible drivers.
type RPK ¶
type RPK struct { Metadata struct { Format uint32 Copyright string `struct:"[64]byte"` Date string `struct:"[32]byte"` File string `struct:"[64]byte"` Type RPKAssetType TypeText string `struct:"[32]byte"` Product string `struct:"[16]byte"` ProductText string `struct:"[64]byte"` Device string `struct:"[32]byte"` Magic string `struct:"[16]byte"` Variant string `struct:"[8]byte"` ContentVersion uint16 ContentVersionSpecial uint8 ContentVersionText string `struct:"[16]byte"` Prerequisites uint32 `struct:"skip=1"` PrerequisitesText string `struct:"[128]byte"` ContentNote string `struct:"[128]byte"` ContentChanges string `struct:"[1024]byte"` ContentErrata string `struct:"[128]byte"` ContentExtra string `struct:"[128]byte"` } Asset []byte }
func (*RPK) DumpMetadata ¶
func (rpk *RPK) DumpMetadata()
type RPKAssetType ¶
type RPKAssetType uint32
RPKAssetType identifies the type of asset that can be stored within a RPK archive
const ( // RPKAssetBootloader is a 64drive bootloader RPKAssetBootloader RPKAssetType = 1 // RPKAssetFirmware is a 64drive firmware RPKAssetFirmware RPKAssetType = 2 )
type SaveType ¶
type SaveType uint8
Save emulation types supported by 64drive
func NewSaveTypeFromString ¶
type UpgradeStatus ¶
type UpgradeStatus uint8
UpgradeStatus represents the current status of the firmware upgrade
const ( UpgradeReset UpgradeStatus = 0x0 UpgradeReady UpgradeStatus = 0x1 UpgradeVerifying UpgradeStatus = 0x2 UpgradeErasing00 UpgradeStatus = 0x3 UpgradeErasing25 UpgradeStatus = 0x4 UpgradeErasing50 UpgradeStatus = 0x5 UpgradeErasing75 UpgradeStatus = 0x6 UpgradeWriting00 UpgradeStatus = 0x7 UpgradeWriting25 UpgradeStatus = 0x8 UpgradeWriting50 UpgradeStatus = 0x9 UpgradeWriting75 UpgradeStatus = 0xA UpgradeSuccess UpgradeStatus = 0xC UpgradeGeneralFail UpgradeStatus = 0xD UpgradeBadVariant UpgradeStatus = 0xE UpgradeVerifyFail UpgradeStatus = 0xF )
These are the possible upgrade status that can occur during a firwmare upgrade. To read the current upgrade status, use Device.CmdUpgradeReport.
func (UpgradeStatus) IsFinished ¶
func (stat UpgradeStatus) IsFinished() bool
IsFinished returns true if the UpgradeStatus represents the end of the upgrade process.
func (UpgradeStatus) String ¶
func (i UpgradeStatus) String() string