Documentation ¶
Index ¶
- Constants
- Variables
- type CPUFrame
- type Clock
- type CurrentInstruction
- type GbcCPU
- func (cpu *GbcCPU) AddA_hl()
- func (cpu *GbcCPU) AddA_n()
- func (cpu *GbcCPU) AddA_r(r *byte)
- func (cpu *GbcCPU) AddCA_hl()
- func (cpu *GbcCPU) AddCA_n()
- func (cpu *GbcCPU) AddCA_r(r *byte)
- func (cpu *GbcCPU) Addhl_rr(r1, r2 *byte)
- func (cpu *GbcCPU) Addhl_sp()
- func (cpu *GbcCPU) Addsp_n()
- func (cpu *GbcCPU) AndA_hl()
- func (cpu *GbcCPU) AndA_n()
- func (cpu *GbcCPU) AndA_r(r *byte)
- func (cpu *GbcCPU) Bitb_hl(b byte)
- func (cpu *GbcCPU) Bitb_r(b byte, r *byte)
- func (cpu *GbcCPU) CCF()
- func (cpu *GbcCPU) CPA_hl()
- func (cpu *GbcCPU) CPA_n()
- func (cpu *GbcCPU) CPA_r(r *byte)
- func (cpu *GbcCPU) CPL()
- func (cpu *GbcCPU) Call_nn()
- func (cpu *GbcCPU) Callcc_nn(flag int, callWhen bool)
- func (cpu *GbcCPU) CheckForInterrupts() bool
- func (cpu *GbcCPU) Compile(instruction *Instruction)
- func (cpu *GbcCPU) DI()
- func (cpu *GbcCPU) Daa()
- func (cpu *GbcCPU) Dec_hl()
- func (cpu *GbcCPU) Dec_r(r *byte)
- func (cpu *GbcCPU) Dec_rr(r1, r2 *byte)
- func (cpu *GbcCPU) Dec_sp()
- func (cpu *GbcCPU) EI()
- func (cpu *GbcCPU) FlagsString() string
- func (cpu *GbcCPU) GetFrame() *CPUFrame
- func (cpu *GbcCPU) HALT()
- func (cpu *GbcCPU) Inc_hl()
- func (cpu *GbcCPU) Inc_r(r *byte)
- func (cpu *GbcCPU) Inc_rr(r1, r2 *byte)
- func (cpu *GbcCPU) Inc_sp()
- func (cpu *GbcCPU) IncrementPC(by int)
- func (cpu *GbcCPU) IsFlagSet(flag int) bool
- func (cpu *GbcCPU) JP_hl()
- func (cpu *GbcCPU) JP_nn()
- func (cpu *GbcCPU) JPcc_nn(flag int, jumpWhen bool)
- func (cpu *GbcCPU) JR_n()
- func (cpu *GbcCPU) JRcc_nn(flag int, jumpWhen bool)
- func (cpu *GbcCPU) LDDhl_r(r *byte)
- func (cpu *GbcCPU) LDDr_hl(r *byte)
- func (cpu *GbcCPU) LDHLSP_n()
- func (cpu *GbcCPU) LDHn_r(r *byte)
- func (cpu *GbcCPU) LDHr_n(r *byte)
- func (cpu *GbcCPU) LDIhl_r(r *byte)
- func (cpu *GbcCPU) LDIr_hl(r *byte)
- func (cpu *GbcCPU) LDSP_hl()
- func (cpu *GbcCPU) LDSP_nn()
- func (cpu *GbcCPU) LDffplusc_r(r *byte)
- func (cpu *GbcCPU) LDhl_n()
- func (cpu *GbcCPU) LDn_nn(r1, r2 *byte)
- func (cpu *GbcCPU) LDnn_SP()
- func (cpu *GbcCPU) LDnn_r(r *byte)
- func (cpu *GbcCPU) LDr_ffplusc(r *byte)
- func (cpu *GbcCPU) LDr_nn(r *byte)
- func (cpu *GbcCPU) LDr_rr(hs *byte, ls *byte, r *byte)
- func (cpu *GbcCPU) LDrn(r *byte)
- func (cpu *GbcCPU) LDrr(r1 *byte, r2 *byte)
- func (cpu *GbcCPU) LDrr_r(hs *byte, ls *byte, r *byte)
- func (cpu *GbcCPU) NOP()
- func (cpu *GbcCPU) OrA_hl()
- func (cpu *GbcCPU) OrA_n()
- func (cpu *GbcCPU) OrA_r(r *byte)
- func (cpu *GbcCPU) Pop_AF()
- func (cpu *GbcCPU) Pop_nn(r1, r2 *byte)
- func (cpu *GbcCPU) Push_nn(r1, r2 *byte)
- func (cpu *GbcCPU) RLA()
- func (cpu *GbcCPU) RLCA()
- func (cpu *GbcCPU) RRA()
- func (cpu *GbcCPU) RRCA()
- func (cpu *GbcCPU) ReadByte(addr types.Word) byte
- func (cpu *GbcCPU) Resb_hl(b byte)
- func (cpu *GbcCPU) Resb_r(b byte, r *byte)
- func (cpu *GbcCPU) Reset()
- func (cpu *GbcCPU) ResetFlag(flag int)
- func (cpu *GbcCPU) Ret()
- func (cpu *GbcCPU) Ret_i()
- func (cpu *GbcCPU) Retcc(flag int, returnWhen bool)
- func (cpu *GbcCPU) Rl_hl()
- func (cpu *GbcCPU) Rl_r(r *byte)
- func (cpu *GbcCPU) Rlc_hl()
- func (cpu *GbcCPU) Rlc_r(r *byte)
- func (cpu *GbcCPU) Rr_hl()
- func (cpu *GbcCPU) Rr_r(r *byte)
- func (cpu *GbcCPU) Rrc_hl()
- func (cpu *GbcCPU) Rrc_r(r *byte)
- func (cpu *GbcCPU) Rst(n byte)
- func (cpu *GbcCPU) SCF()
- func (cpu *GbcCPU) SetCPUSpeed()
- func (cpu *GbcCPU) SetFlag(flag int)
- func (cpu *GbcCPU) Setb_hl(b byte)
- func (cpu *GbcCPU) Setb_r(b byte, r *byte)
- func (cpu *GbcCPU) Sla_hl()
- func (cpu *GbcCPU) Sla_r(r *byte)
- func (cpu *GbcCPU) Sra_hl()
- func (cpu *GbcCPU) Sra_r(r *byte)
- func (cpu *GbcCPU) Srl_hl()
- func (cpu *GbcCPU) Srl_r(r *byte)
- func (cpu *GbcCPU) Step() int
- func (cpu *GbcCPU) Stop()
- func (cpu *GbcCPU) String() string
- func (cpu *GbcCPU) SubAC_hl()
- func (cpu *GbcCPU) SubAC_n()
- func (cpu *GbcCPU) SubAC_r(r *byte)
- func (cpu *GbcCPU) SubA_hl()
- func (cpu *GbcCPU) SubA_n()
- func (cpu *GbcCPU) SubA_r(r *byte)
- func (cpu *GbcCPU) Swap_hl()
- func (cpu *GbcCPU) Swap_r(r *byte)
- func (cpu *GbcCPU) WriteByte(addr types.Word, value byte)
- func (cpu *GbcCPU) XorA_hl()
- func (cpu *GbcCPU) XorA_n()
- func (cpu *GbcCPU) XorA_r(r *byte)
- type Instruction
- type Registers
Constants ¶
const ( C H N Z )
flags
const NAME = "CPU"
const PREFIX = NAME + ":"
Variables ¶
var Instructions []*Instruction = []*Instruction{}/* 256 elements not displayed */
var InstructionsCB []*Instruction = []*Instruction{}/* 256 elements not displayed */
Functions ¶
This section is empty.
Types ¶
type Clock ¶
type Clock struct { M int // contains filtered or unexported fields }
See ZILOG z80 cpu manual p.80 (http://www.zilog.com/docs/z80/um0080.pdf)
type CurrentInstruction ¶ added in v0.0.13
type CurrentInstruction struct { *Instruction Operands [2]byte }
type GbcCPU ¶
type GbcCPU struct { PC types.Word // Program Counter SP types.Word // Stack Pointer R Registers InterruptsEnabled bool CurrentInstruction *CurrentInstruction LastInstrCycle Clock PCJumped bool Halted bool InterruptFlagBeforeHalt byte Speed int // contains filtered or unexported fields }
func (*GbcCPU) AddA_hl ¶
func (cpu *GbcCPU) AddA_hl()
ADD A,(HL) Add the value in memory addressed in register pair (HL) to register A
func (*GbcCPU) AddA_n ¶
func (cpu *GbcCPU) AddA_n()
ADD A,n Add the value in memory addressed PC to register A. Increment the PC by 1
func (*GbcCPU) Call_nn ¶
func (cpu *GbcCPU) Call_nn()
CALL nn Push address of next instruction onto stack and then jump to address nn
func (*GbcCPU) CheckForInterrupts ¶
func (*GbcCPU) Compile ¶
func (cpu *GbcCPU) Compile(instruction *Instruction)
func (*GbcCPU) Daa ¶
func (cpu *GbcCPU) Daa()
DAA - this instruction was a complete PITA to implement thankfully DParrot from here http://forums.nesdev.com/viewtopic.php?t=9088 provided a correct solution that passes the blargg tests
func (*GbcCPU) FlagsString ¶
func (*GbcCPU) IncrementPC ¶
func (*GbcCPU) LDDhl_r ¶
LDD (HL), r Load the value in register (r) and store in memory addressed in register pair (HL). Decrement the HL registers
func (*GbcCPU) LDDr_hl ¶
LDD r, (HL) Load the value from memory addressed in register pair (HL) and store it in register R. Decrement the HL registers
func (*GbcCPU) LDHr_n ¶
LDH r, n Load value (n) in register (r) and store it in memory address FF00+PC. Increment PC by 1
func (*GbcCPU) LDIhl_r ¶
LDI (HL), r Load the value in register (r) and store in memory addressed in register pair (HL). Increment the HL registers
func (*GbcCPU) LDIr_hl ¶
LDI r, (HL) Load the value from memory addressed in register pair (HL) and store it in register R. Increment the HL registers
func (*GbcCPU) LDffplusc_r ¶
LD (C),r Load the value from register (r) and store it in memory addressed 0xFF00 + value in register C.
func (*GbcCPU) LDhl_n ¶
func (cpu *GbcCPU) LDhl_n()
LD (HL),n Load the value (n) from the memory address in the PC and put it in the memory address designated by register pair (HL)
func (*GbcCPU) LDnn_r ¶
LD nn,r Load value from register (r) and put it in memory address (nn) taken from the next 2 bytes of memory from the PC. Increment the PC by 2
func (*GbcCPU) LDr_ffplusc ¶
LD r,(C) Load the value from memory addressed 0xFF00 + value in register C. Store it in register (r)
func (*GbcCPU) LDr_nn ¶
LD r, nn Load the value in memory address defined from the next two bytes relative to the PC and store it in register (r). Increment the PC by 2
func (*GbcCPU) LDr_rr ¶
LD r, rr Load value from memory address located in register pair (RR) into register (r)
func (*GbcCPU) LDrn ¶
LD r,n Load value (n) from memory address in the PC into register (r) and increment PC by 1
func (*GbcCPU) LDrr_r ¶
LD rr, r Load value from register (r) into memory address located at register pair (RR)
func (*GbcCPU) Pop_AF ¶
func (cpu *GbcCPU) Pop_AF()
POP AF Pop the stack twice onto register pair AF
func (*GbcCPU) SetCPUSpeed ¶
func (cpu *GbcCPU) SetCPUSpeed()
Checks to see if the CPU speed should change to double (CGB only)
type Instruction ¶
type Instruction struct { Opcode byte Description string OperandsSize int Cycles int Execute func(cpu *GbcCPU) }
var EMPTY_INSTRUCTION *Instruction = &Instruction{0xFF, "EMPTY", 0, 1, func(cpu *GbcCPU) { log.Println("WARNING: Calling unknown/invalid opcode") }}
func (Instruction) String ¶
func (i Instruction) String() string