Documentation ¶
Index ¶
- Constants
- Variables
- type AddressingMode
- type CPU
- func (c *CPU) AddNMI()
- func (c *CPU) AddStall(stall uint16)
- func (c *CPU) GetCycles() uint
- func (c *CPU) ReadMem(addr uint16) byte
- func (c *CPU) ReadMem16(addr uint16) uint16
- func (c *CPU) ReadMem16Bug(addr uint16) uint16
- func (c *CPU) Reset()
- func (c *CPU) Step() uint
- func (c *CPU) Trace() string
- func (c *CPU) WriteMem(addr uint16, data byte)
- func (c *CPU) WriteMem16(addr uint16, data uint16)
- type Instruction
- type InstructionName
- type OpCode
- type Status
Constants ¶
const ( Carry = 1 << iota Zero InterruptDisable Decimal Break Unused Overflow Negative )
const StackAddr = 0x100
StackAddr is the memory address of the stack
Variables ¶
var ErrUnsupportedOpcode = errors.New("unsupported opcode")
ErrUnsupportedOpcode indicates an unsupported opcode was evaluated.
Functions ¶
This section is empty.
Types ¶
type AddressingMode ¶
type AddressingMode uint8
AddressingMode defines opcode addressing modes.
See 6502 Addressing Mode.
const ( Implicit AddressingMode = iota Accumulator Immediate ZeroPage ZeroPageX ZeroPageY Relative Absolute AbsoluteX AbsoluteY Indirect IndirectX IndirectY )
func (AddressingMode) String ¶
func (i AddressingMode) String() string
type CPU ¶
type CPU struct { // ProgramCounter Program Counter ProgramCounter uint16 // StackPointer Stack Pointer StackPointer byte // Status Processor Status Status Status // Accumulator Register A Accumulator byte // RegisterX Register X RegisterX byte // RegisterY Register Y RegisterY byte Cycles uint NMIPending bool `msgpack:"alias:NmiPending"` IRQPending bool `msgpack:"alias:IrqPending"` Stall uint16 StepErr error `msgpack:"-"` // contains filtered or unexported fields }
CPU implements the NES CPU.
See 6502 Guide.
func New ¶
func New(b memory.ReadSafeWrite) *CPU
func (*CPU) ReadMem16Bug ¶
ReadMem16Bug reads two bytes from memory, emulating a 6502 bug.
JMP ($xxyy), or JMP indirect, does not advance pages if the lower eight bits of the specified address is $FF; the upper eight bits are fetched from $xx00, 255 bytes earlier, instead of the expected following byte.
See [JMP Instruction Reference] and [NESdev CPU Errata].
[JMP Instruction Reference]: https://www.nesdev.org/obelisk-6502-guide/reference.html#JMP [NESDev CPU Errata]:https://www.nesdev.org/wiki/Errata#CPU
func (*CPU) Reset ¶
func (c *CPU) Reset()
Reset resets the CPU and sets ProgramCounter to the value of the [Reset] Vector.
func (*CPU) WriteMem16 ¶
WriteMem16 writes two bytes to memory.
type Instruction ¶
type Instruction func(c *CPU, mode AddressingMode)
type InstructionName ¶ added in v0.1.0
type InstructionName uint8
const ( BRK InstructionName = iota ORA SLO NOP ASL PHP ANC BPL CLC JSR AND RLA BIT ROL PLP BMI SEC RTI EOR SRE LSR PHA ALR JMP BVC CLI RTS ADC RRA ROR PLA ARR BVS SEI STA SAX STY STX DEY TXA XAA BCC AHX TYA TXS TAS SHY SHX LDY LDA LDX LAX TAY TAX LXA BCS CLV TSX LAS CPY CMP DCP DEC INY DEX AXS BNE CLD CPX SBC ISB INC INX BEQ SED )
func (InstructionName) String ¶ added in v0.1.0
func (i InstructionName) String() string
type OpCode ¶
type OpCode struct { Name InstructionName Len uint8 Cycles uint8 Mode AddressingMode Exec Instruction Undocumented bool }
OpCode defines an opcode and its parameters.