cpu

package
v0.0.0-...-ea41a2c Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2015 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Decimal Mode Not Implemented -- doesn't exist in NES

Index

Constants

View Source
const (
	AddressImmediate int = iota
	AddressZeroPage
	AddressZeroPageX
	AddressZeroPageY
	AddressAbsolute
	AddressAbsoluteX
	AddressAbsoluteY
	AddressImplied
	AddressAccumulator
	AddressIndirect
	AddressIndirectWrong
	AddressIndirectX
	AddressIndirectY
	AddressRelative
	AddressAddress
)

Variables

View Source
var ErrorUnknownAddressMode = errors.New("Unknown Addressing Mode")
View Source
var ErrorUnknownInstruction = errors.New("Unknown Instruction")

Functions

This section is empty.

Types

type AddressGetter

type AddressGetter func(c *CPU) (uint16, bool)

type CPU

type CPU struct {
	Registers
	Flags

	Executers []Executer `json:"-"`
	Opcodes   []*Opcode  `json:"-"`

	Sync chan int `json:"-"`
	// contains filtered or unexported fields
}

func NewCPU

func NewCPU(n *nes.NES, exit chan bool, log, nesLog *os.File) *CPU

func (*CPU) Execute

func (c *CPU) Execute() int

func (*CPU) Pop

func (c *CPU) Pop() byte

func (*CPU) PowerUp

func (c *CPU) PowerUp()

func (*CPU) Push

func (c *CPU) Push(val byte)

func (*CPU) Reset

func (c *CPU) Reset()

func (*CPU) Run

func (c *CPU) Run()

type Executer

type Executer func(c *CPU) (cycles int, nexPc uint16)

func ADC

func ADC(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func AND

func AND(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func ASL

func ASL(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func BCC

func BCC(address, instructionLength, operand uint16, cycles int) Executer

func BCS

func BCS(address, instructionLength, operand uint16, cycles int) Executer

func BEQ

func BEQ(address, instructionLength, operand uint16, cycles int) Executer

func BIT

func BIT(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func BMI

func BMI(address, instructionLength, operand uint16, cycles int) Executer

func BNE

func BNE(address, instructionLength, operand uint16, cycles int) Executer

func BPL

func BPL(address, instructionLength, operand uint16, cycles int) Executer

func BRK

func BRK(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func BVC

func BVC(address, instructionLength, operand uint16, cycles int) Executer

func BVS

func BVS(address, instructionLength, operand uint16, cycles int) Executer

func CLC

func CLC(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func CLD

func CLD(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func CLI

func CLI(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func CLV

func CLV(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func CMP

func CMP(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func CPX

func CPX(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func CPY

func CPY(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func DCP

func DCP(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func DEC

func DEC(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func DEX

func DEX(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func DEY

func DEY(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func EOR

func EOR(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func Execution

func Execution(opcodes []*Opcode) []Executer

func INC

func INC(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func INX

func INX(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func INY

func INY(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func ISB

func ISB(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func JMP

func JMP(get AddressGetter, address, instructionLength, operand uint16, cycles int) Executer

func JSR

func JSR(get AddressGetter, address, instructionLength, operand uint16, cycles int) Executer

func LAX

func LAX(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func LDA

func LDA(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func LDX

func LDX(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func LDY

func LDY(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func LSR

func LSR(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func NOP

func NOP(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func NOPGET

func NOPGET(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func ORA

func ORA(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func PHA

func PHA(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func PHP

func PHP(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func PLA

func PLA(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func PLP

func PLP(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func RLA

func RLA(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func ROL

func ROL(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func ROR

func ROR(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func RRA

func RRA(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func RTI

func RTI(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func RTS

func RTS(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func SAX

func SAX(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func SBC

func SBC(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func SEC

func SEC(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func SED

func SED(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func SEI

func SEI(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func SLO

func SLO(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func SRE

func SRE(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func STA

func STA(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func STX

func STX(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func STY

func STY(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func TAX

func TAX(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func TAY

func TAY(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func TSX

func TSX(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func TXA

func TXA(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func TXS

func TXS(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

func TYA

func TYA(get Getter, set Setter, address, instructionLength, operand uint16, cycles int) Executer

type Flags

type Flags struct {
	Carry     bool
	Zero      bool
	Interrupt bool
	Decimal   bool
	Break     bool
	Overflow  bool
	Negative  bool
}

func (*Flags) SetSign

func (f *Flags) SetSign(value byte)

func (*Flags) SetStatus

func (f *Flags) SetStatus(v byte)

func (*Flags) SetZero

func (f *Flags) SetZero(value byte)

func (*Flags) Status

func (f *Flags) Status() byte

type Getter

type Getter func(c *CPU) (value byte, pageCrossed bool)

type Opcode

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

func Decompile

func Decompile(memory []*byte) []*Opcode

Decompile will Read each address in memory as though it could be executed. This will produce many indvalid opcodes, but doesn't require us to differentiate between instructions and data ahead of time. Any invalid opcodes will result in a "nop". Hopefully the code never jumps to them :) Perhaps we should put a panicking instruction to suss these out.

func NewOpcode

func NewOpcode(memory []*byte, address uint16) *Opcode

func (*Opcode) Address

func (o *Opcode) Address() uint16

func (*Opcode) AddressGet

func (o *Opcode) AddressGet(c *CPU) (uint16, bool)

func (*Opcode) AddressMode

func (o *Opcode) AddressMode() int

func (*Opcode) Bytes

func (o *Opcode) Bytes() string

func (*Opcode) Cycles

func (o *Opcode) Cycles() int

func (*Opcode) Disassemble

func (o *Opcode) Disassemble() string

func (*Opcode) Executer

func (o *Opcode) Executer() Executer

func (*Opcode) Get

func (o *Opcode) Get(c *CPU) byte

func (*Opcode) GetValueAt

func (o *Opcode) GetValueAt(c *CPU) string

func (*Opcode) Instruction

func (o *Opcode) Instruction() string

func (*Opcode) Opcode

func (o *Opcode) Opcode() []*byte

func (*Opcode) Operand

func (o *Opcode) Operand() uint16

func (*Opcode) Operands

func (o *Opcode) Operands() string

type Registers

type Registers struct {
	PC uint16
	A  byte
	X  byte
	Y  byte
	SP byte
}

type Setter

type Setter func(c *CPU, value byte) bool

Jump to

Keyboard shortcuts

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