cartridge

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2013 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MBC_0                 = 0x00
	MBC_1                 = 0x01
	MBC_1_RAM             = 0x02
	MBC_1_RAM_BATT        = 0x03
	MBC_3_RAM_BATT        = 0x13
	MBC_5                 = 0x19
	MBC_5_RAM             = 0x1A
	MBC_5_RAM_BATT        = 0x1B
	MBC_5_RUMBLE          = 0x1C
	MBC_5_RAM_RUMBLE      = 0x1D
	MBC_5_RAM_BATT_RUMBLE = 0x1E
)

Variables

View Source
var CartridgeTypes map[byte]CartridgeType = map[byte]CartridgeType{
	MBC_0:                 CartridgeType{MBC_0, "ROM ONLY"},
	MBC_1:                 CartridgeType{MBC_1, "ROM+MBC1"},
	MBC_1_RAM:             CartridgeType{MBC_1_RAM, "ROM+MBC1+RAM"},
	MBC_1_RAM_BATT:        CartridgeType{MBC_1_RAM_BATT, "ROM+MBC1+RAM+BATT"},
	MBC_3_RAM_BATT:        CartridgeType{MBC_3_RAM_BATT, "ROM+MBC3+RAM+BATT"},
	MBC_5:                 CartridgeType{MBC_5, "ROM+MBC5"},
	MBC_5_RAM:             CartridgeType{MBC_5_RAM, "ROM+MBC5+RAM"},
	MBC_5_RAM_BATT:        CartridgeType{MBC_5_RAM_BATT, "ROM+MBC5+RAM+BATT"},
	MBC_5_RUMBLE:          CartridgeType{MBC_5_RUMBLE, "ROM+MBC5+RUMBLE"},
	MBC_5_RAM_RUMBLE:      CartridgeType{MBC_5_RAM_RUMBLE, "ROM+MBC5+RAM+RUMBLE"},
	MBC_5_RAM_BATT_RUMBLE: CartridgeType{MBC_5_RAM_BATT_RUMBLE, "ROM+MBC5+RAM+BATT+RUMBLE"},
}

Functions

func RetrieveROM

func RetrieveROM(filename string) ([]byte, error)

Types

type Cartridge

type Cartridge struct {
	Title      string
	IsColourGB bool
	Type       CartridgeType
	ROMSize    int
	RAMSize    int
	IsJapanese bool
	Filename   string
	MBC        MemoryBankController
}

func NewCartridge

func NewCartridge(romFile string) (*Cartridge, error)

func (*Cartridge) Init

func (c *Cartridge) Init(rom []byte) error

func (*Cartridge) LoadRam

func (c *Cartridge) LoadRam(savesDir string) error

func (*Cartridge) SaveRam

func (c *Cartridge) SaveRam(savesDir string) error

func (*Cartridge) String

func (c *Cartridge) String() string

type CartridgeType

type CartridgeType struct {
	ID          byte
	Description string
}

type MBC0

type MBC0 struct {
	Name string
	// contains filtered or unexported fields
}

Represents ROM only MBC (MBC0) - No RAM - One ROM bank

func NewMBC0

func NewMBC0(rom []byte) *MBC0

func (*MBC0) LoadRam

func (m *MBC0) LoadRam(savesDir string, game string) error

func (*MBC0) Read

func (m *MBC0) Read(addr types.Word) byte

func (*MBC0) SaveRam

func (m *MBC0) SaveRam(savesDir string, game string) error

func (*MBC0) String

func (m *MBC0) String() string

func (*MBC0) Write

func (m *MBC0) Write(addr types.Word, value byte)

type MBC1

type MBC1 struct {
	Name string

	MaxMemMode int
	ROMSize    int
	RAMSize    int
	// contains filtered or unexported fields
}

Represents MBC1

func NewMBC1

func NewMBC1(rom []byte, romSize int, ramSize int, hasBattery bool) *MBC1

func (*MBC1) LoadRam

func (m *MBC1) LoadRam(savesDir string, game string) error

func (*MBC1) Read

func (m *MBC1) Read(addr types.Word) byte

func (*MBC1) SaveRam

func (m *MBC1) SaveRam(savesDir string, game string) error

func (*MBC1) String

func (m *MBC1) String() string

func (*MBC1) Write

func (m *MBC1) Write(addr types.Word, value byte)

type MBC3

type MBC3 struct {
	Name string

	ROMSize int
	RAMSize int
	// contains filtered or unexported fields
}

Represents MBC3

func NewMBC3

func NewMBC3(rom []byte, romSize int, ramSize int, hasBattery bool) *MBC3

func (*MBC3) LoadRam

func (m *MBC3) LoadRam(savesDir string, game string) error

func (*MBC3) Read

func (m *MBC3) Read(addr types.Word) byte

func (*MBC3) SaveRam

func (m *MBC3) SaveRam(savesDir string, game string) error

func (*MBC3) String

func (m *MBC3) String() string

func (*MBC3) Write

func (m *MBC3) Write(addr types.Word, value byte)

type MBC5

type MBC5 struct {
	Name string

	ROMSize int
	RAMSize int

	ROMBHigher types.Word
	ROMBLower  types.Word
	// contains filtered or unexported fields
}

Represents MBC5

func NewMBC5

func NewMBC5(rom []byte, romSize int, ramSize int, hasBattery bool) *MBC5

func (*MBC5) LoadRam

func (m *MBC5) LoadRam(savesDir string, game string) error

func (*MBC5) Read

func (m *MBC5) Read(addr types.Word) byte

func (*MBC5) SaveRam

func (m *MBC5) SaveRam(savesDir string, game string) error

func (*MBC5) String

func (m *MBC5) String() string

func (*MBC5) Write

func (m *MBC5) Write(addr types.Word, value byte)

type MemoryBankController

type MemoryBankController interface {
	Write(addr types.Word, value byte)
	Read(addr types.Word) byte
	SaveRam(savesDir string, game string) error
	LoadRam(savesDir string, game string) error
	// contains filtered or unexported methods
}

type SaveFile

type SaveFile struct {
	Game       string
	Path       string
	NoOfBanks  int
	Banks      []string
	BankHashes []uint32
	LastSaved  string
}

func NewSaveFile

func NewSaveFile(savesDir string, game string) *SaveFile

func (*SaveFile) DeflateBank

func (s *SaveFile) DeflateBank(bank []byte) (string, error)

Takes a byte array, converts it to a base64 string and compresses it using ZLIB.

func (*SaveFile) InflateBank

func (s *SaveFile) InflateBank(bankStr string) ([]byte, error)

Takes a base64 string and decompresses it using ZLIB into a byte array

func (*SaveFile) Load

func (s *SaveFile) Load(noOfBanks int) ([][]byte, error)

func (*SaveFile) Save

func (s *SaveFile) Save(data [][]byte) error

compresses ram banks and stores as base64 strings. hashes are taken each bank information is stored on disk in JSON format

func (*SaveFile) Validate

func (s *SaveFile) Validate() error

Jump to

Keyboard shortcuts

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