Documentation
¶
Index ¶
- Constants
- Variables
- func ADC(cpu *CPU, op Operand) (extraCycles int)
- func AND(cpu *CPU, op Operand) (extraCycles int)
- func ASL(cpu *CPU, op Operand) (extraCycles int)
- func BCC(cpu *CPU, op Operand) (extraCycles int)
- func BCS(cpu *CPU, op Operand) (extraCycles int)
- func BEQ(cpu *CPU, op Operand) (extraCycles int)
- func BIT(cpu *CPU, op Operand) (extraCycles int)
- func BMI(cpu *CPU, op Operand) (extraCycles int)
- func BNE(cpu *CPU, op Operand) (extraCycles int)
- func BPL(cpu *CPU, op Operand) (extraCycles int)
- func BRK(cpu *CPU, op Operand) (extraCycles int)
- func BVC(cpu *CPU, op Operand) (extraCycles int)
- func BVS(cpu *CPU, op Operand) (extraCycles int)
- func CLC(cpu *CPU, op Operand) (extraCycles int)
- func CLD(cpu *CPU, op Operand) (extraCycles int)
- func CLI(cpu *CPU, op Operand) (extraCycles int)
- func CLV(cpu *CPU, op Operand) (extraCycles int)
- func CMP(cpu *CPU, op Operand) (extraCycles int)
- func CPX(cpu *CPU, op Operand) (extraCycles int)
- func CPY(cpu *CPU, op Operand) (extraCycles int)
- func DEC(cpu *CPU, op Operand) (extraCycles int)
- func DEX(cpu *CPU, op Operand) (extraCycles int)
- func DEY(cpu *CPU, op Operand) (extraCycles int)
- func EOR(cpu *CPU, op Operand) (extraCycles int)
- func INC(cpu *CPU, op Operand) (extraCycles int)
- func INX(cpu *CPU, op Operand) (extraCycles int)
- func INY(cpu *CPU, op Operand) (extraCycles int)
- func JMP(cpu *CPU, op Operand) (extraCycles int)
- func JSR(cpu *CPU, op Operand) (extraCycles int)
- func LDA(cpu *CPU, op Operand) (extraCycles int)
- func LDX(cpu *CPU, op Operand) (extraCycles int)
- func LDY(cpu *CPU, op Operand) (extraCycles int)
- func LSR(cpu *CPU, op Operand) (extraCycles int)
- func NOP(cpu *CPU, op Operand) (extraCycles int)
- func ORA(cpu *CPU, op Operand) (extraCycles int)
- func PHA(cpu *CPU, op Operand) (extraCycles int)
- func PHP(cpu *CPU, op Operand) (extraCycles int)
- func PLA(cpu *CPU, op Operand) (extraCycles int)
- func PLP(cpu *CPU, op Operand) (extraCycles int)
- func ROL(cpu *CPU, op Operand) (extraCycles int)
- func ROR(cpu *CPU, op Operand) (extraCycles int)
- func RTI(cpu *CPU, op Operand) (extraCycles int)
- func RTS(cpu *CPU, op Operand) (extraCycles int)
- func SBC(cpu *CPU, op Operand) (extraCycles int)
- func SEC(cpu *CPU, op Operand) (extraCycles int)
- func SED(cpu *CPU, op Operand) (extraCycles int)
- func SEI(cpu *CPU, op Operand) (extraCycles int)
- func STA(cpu *CPU, op Operand) (extraCycles int)
- func STX(cpu *CPU, op Operand) (extraCycles int)
- func STY(cpu *CPU, op Operand) (extraCycles int)
- func TAX(cpu *CPU, op Operand) (extraCycles int)
- func TAY(cpu *CPU, op Operand) (extraCycles int)
- func TSX(cpu *CPU, op Operand) (extraCycles int)
- func TXA(cpu *CPU, op Operand) (extraCycles int)
- func TXS(cpu *CPU, op Operand) (extraCycles int)
- func TYA(cpu *CPU, op Operand) (extraCycles int)
- type AddressingMode
- type CPU
- type ConstOperand
- type NilOperand
- type OpCode
- type Operand
- type Operation
- type RAM
- type RAMOperand
- type RegOperand
- type Regs
- type Worker
Constants ¶
const ( ZeroPageBeginIdx = 0x0 StackBeginIdx = 0x100 RamBeginIdx = 0x200 RamMirrorBeginIdx = 0x800 LowerIORegBeginIdx = 0x2000 LowerIORegMirrorBeginIdx = 0x2008 UpperIORegBeginIdx = 0x4000 ExpansionRomBeginIdx = 0x4020 SramBeginIdx = 0x4000 PrgRomLowerBeginIdx = 0x8000 PrgRomUpperBeginIdx = 0xc000 RamSize = 0x10000 )
const ( PPUCtrl = 0x2000 PPUMask = 0x2001 PPUStatus = 0x2002 OAMAddr = 0x2003 OAMData = 0x2004 PPUScroll = 0x2005 PPUAddr = 0x2006 PPUData = 0x2007 OAMDMA = 0x4014 Ctrl1 = 0x4016 )
const ( Set = 1 Clear = 0 )
Variables ¶
var ( Implied = AddressingMode{ Name: "Implied", OpsLen: 0, Format: func(ops []byte) string { return "" }, // contains filtered or unexported fields } Accumulator = AddressingMode{ Name: "Accumulator", OpsLen: 0, Format: func(ops []byte) string { return "A" }, // contains filtered or unexported fields } Immediate = AddressingMode{ Name: "Immediate", OpsLen: 1, Format: func(ops []byte) string { return fmt.Sprintf("#$%02x", ops[0]) }, // contains filtered or unexported fields } ZeroPage = AddressingMode{ Name: "ZeroPage", OpsLen: 1, Format: func(ops []byte) string { return fmt.Sprintf("$%02x", ops[0]) }, // contains filtered or unexported fields } ZeroPageX = AddressingMode{ Name: "ZeroPageX", OpsLen: 1, Format: func(ops []byte) string { return fmt.Sprintf("$%02x, X", ops[0]) }, // contains filtered or unexported fields } ZeroPageY = AddressingMode{ Name: "ZeroPageY", OpsLen: 1, Format: func(ops []byte) string { return fmt.Sprintf("$%02x, Y", ops[0]) }, // contains filtered or unexported fields } Relative = AddressingMode{ Name: "Relative", OpsLen: 1, Format: func(ops []byte) string { return fmt.Sprintf("$%02x", ops[0]) }, // contains filtered or unexported fields } Absolute = AddressingMode{ Name: "Absolute", OpsLen: 2, Format: func(ops []byte) string { return fmt.Sprintf("$%02x%02x", ops[1], ops[0]) }, // contains filtered or unexported fields } AbsoluteX = AddressingMode{ Name: "AbsoluteX", OpsLen: 2, Format: func(ops []byte) string { return fmt.Sprintf("$%02x%02x, X", ops[1], ops[0]) }, // contains filtered or unexported fields } AbsoluteY = AddressingMode{ Name: "AbsoluteY", OpsLen: 2, Format: func(ops []byte) string { return fmt.Sprintf("$%02x%02x, Y", ops[1], ops[0]) }, // contains filtered or unexported fields } Indirect = AddressingMode{ Name: "Indirect", OpsLen: 2, Format: func(ops []byte) string { return fmt.Sprintf("($%02x%02x)", ops[1], ops[0]) }, // contains filtered or unexported fields } IndirectX = AddressingMode{ Name: "IndirectX", OpsLen: 1, Format: func(ops []byte) string { return fmt.Sprintf("($%02x, X)", ops[0]) }, // contains filtered or unexported fields } IndirectY = AddressingMode{ Name: "IndirectY", OpsLen: 1, Format: func(ops []byte) string { return fmt.Sprintf("($%02x), Y", ops[0]) }, // contains filtered or unexported fields } )
var OpCodes = map[byte]OpCode{}/* 151 elements not displayed */
Functions ¶
Types ¶
type AddressingMode ¶
type AddressingMode struct {
Name string
OpsLen int
Format func([]byte) string
// contains filtered or unexported fields
}
AddressingMode defines one of the 2a03's ways of addressing the operands of the different opcodes.
Each addressing mode is responsible of fetching the operands in it's way, and calling the operation with them.
The bool tells whether there needs to be a page boundry check ¶
The addressing mode returns the amount of extra cycles caused by page boundry crossing, if any.
type CPU ¶
func (*CPU) HandleInterupts ¶
func (cpu *CPU) HandleInterupts()
type ConstOperand ¶
type ConstOperand struct {
D byte
}
func (ConstOperand) Read ¶
func (op ConstOperand) Read() byte
func (ConstOperand) Write ¶
func (op ConstOperand) Write(d byte) (cycles int)
type NilOperand ¶
type NilOperand struct{}
func (NilOperand) Read ¶
func (op NilOperand) Read() byte
func (NilOperand) Write ¶
func (op NilOperand) Write(d byte) (cycles int)
type OpCode ¶
type OpCode struct {
Name string
Mode AddressingMode
Oper Operation
// contains filtered or unexported fields
}
OpCode defines an opcode of the 2a03.
Contains it's textual representation, addressing mode and the operation itself.
The opcode also contains some informaition on the amount of cycles it takes to execute. cycles is the base cycle count, and pageBoundryCheck tells the addressing mode whether a page boundry cross affects it's cycle count
type Operation ¶
Operation defines an operation that the CPU executes in one or more of it's opcodes.
The byte values it received are it's arguments. Arguments can be of any length, depending on the operation. There isn't a gurantee that the operation will check for the correct number of arguments, so make sure that you pass in the correct amount. Note that the args are in the form of pointers to bytes. This is for the operation to be able to write to the arguments too, changing the underlying RAM or Register.
The operation also gets a reference to the cpu so it can test and change the Registers and RAM.
Similar to addressing modes, opcodes too return whether the operation's execution took extra cycles. This happens on the operation level only in branching operations.
type RAM ¶
type RAM struct {
CPU *CPU
PPU *ppu.PPU
Ctrl *models.Controller
// contains filtered or unexported fields
}
type RAMOperand ¶
func (RAMOperand) Read ¶
func (op RAMOperand) Read() byte
func (RAMOperand) Write ¶
func (op RAMOperand) Write(d byte) (cycles int)
type RegOperand ¶
type RegOperand struct {
Reg *byte
}
func (RegOperand) Read ¶
func (op RegOperand) Read() byte
func (RegOperand) Write ¶
func (op RegOperand) Write(d byte) (cycles int)