cpu

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: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	C
	H
	N
	Z
)

flags

View Source
const NAME = "CPU"
View Source
const PREFIX = NAME + ":"

Variables

View Source
var Instructions map[byte]Instruction = map[byte]Instruction{}/* 244 elements not displayed */
View Source
var InstructionsCB map[byte]Instruction = map[byte]Instruction{}/* 256 elements not displayed */

Functions

This section is empty.

Types

type CPUFrame

type CPUFrame struct {
	PC                      types.Word // Program Counter
	SP                      types.Word // Stack Pointer
	R                       Registers
	InterruptsEnabled       bool
	CurrentInstruction      Instruction
	LastInstrCycle          Clock
	PCJumped                bool
	Halted                  bool
	InterruptFlagBeforeHalt byte
}

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)

func (*Clock) Reset

func (c *Clock) Reset()

func (*Clock) String

func (c *Clock) String() string

func (*Clock) T

func (c *Clock) T() int

type GbcCPU

type GbcCPU struct {
	PC                 types.Word // Program Counter
	SP                 types.Word // Stack Pointer
	R                  Registers
	InterruptsEnabled  bool
	CurrentInstruction Instruction
	LastInstrCycle     Clock

	PCJumped                bool
	Halted                  bool
	InterruptFlagBeforeHalt byte
	Speed                   int
	// contains filtered or unexported fields
}

func NewCPU

func NewCPU() *GbcCPU

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) AddA_r

func (cpu *GbcCPU) AddA_r(r *byte)

ADD A,r Add the value in register (r) to register A

func (*GbcCPU) AddCA_hl

func (cpu *GbcCPU) AddCA_hl()

ADDC A,(HL)

func (*GbcCPU) AddCA_n

func (cpu *GbcCPU) AddCA_n()

ADDC A,n

func (*GbcCPU) AddCA_r

func (cpu *GbcCPU) AddCA_r(r *byte)

ADDC A,r

func (*GbcCPU) Addhl_rr

func (cpu *GbcCPU) Addhl_rr(r1, r2 *byte)

--------------- 16 bit operations --------------- ADD HL,rr

func (*GbcCPU) Addhl_sp

func (cpu *GbcCPU) Addhl_sp()

ADD HL,SP

func (*GbcCPU) Addsp_n

func (cpu *GbcCPU) Addsp_n()

ADD SP,n

func (*GbcCPU) AndA_hl

func (cpu *GbcCPU) AndA_hl()

AND A, (HL)

func (*GbcCPU) AndA_n

func (cpu *GbcCPU) AndA_n()

AND A, n

func (*GbcCPU) AndA_r

func (cpu *GbcCPU) AndA_r(r *byte)

AND A, r

func (*GbcCPU) Bitb_hl

func (cpu *GbcCPU) Bitb_hl(b byte)

BIT b,(HL)

func (*GbcCPU) Bitb_r

func (cpu *GbcCPU) Bitb_r(b byte, r *byte)

BIT b, r

func (*GbcCPU) CCF

func (cpu *GbcCPU) CCF()

CCF

func (*GbcCPU) CPA_hl

func (cpu *GbcCPU) CPA_hl()

CP A, (HL)

func (*GbcCPU) CPA_n

func (cpu *GbcCPU) CPA_n()

CP A, n

func (*GbcCPU) CPA_r

func (cpu *GbcCPU) CPA_r(r *byte)

CP A, r

func (*GbcCPU) CPL

func (cpu *GbcCPU) CPL()

CPL

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) Callcc_nn

func (cpu *GbcCPU) Callcc_nn(flag int, callWhen bool)

CALL cc,nn

func (*GbcCPU) CheckForInterrupts

func (cpu *GbcCPU) CheckForInterrupts() bool

func (*GbcCPU) Compile

func (cpu *GbcCPU) Compile(instruction Instruction) Instruction

func (*GbcCPU) DI

func (cpu *GbcCPU) DI()

DI Disable interrupts

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) Dec_hl

func (cpu *GbcCPU) Dec_hl()

DEC (HL)

func (*GbcCPU) Dec_r

func (cpu *GbcCPU) Dec_r(r *byte)

DEC r

func (*GbcCPU) Dec_rr

func (cpu *GbcCPU) Dec_rr(r1, r2 *byte)

DEC rr

func (*GbcCPU) Dec_sp

func (cpu *GbcCPU) Dec_sp()

DEC SP

func (*GbcCPU) Decode

func (cpu *GbcCPU) Decode(instruction byte) (Instruction, bool)

func (*GbcCPU) DecodeCB

func (cpu *GbcCPU) DecodeCB(instruction byte) (Instruction, bool)

func (*GbcCPU) Dispatch

func (cpu *GbcCPU) Dispatch(Opcode byte)

func (*GbcCPU) DispatchCB

func (cpu *GbcCPU) DispatchCB(Opcode byte)

func (*GbcCPU) EI

func (cpu *GbcCPU) EI()

EI Enable interrupts

func (*GbcCPU) FlagsString

func (cpu *GbcCPU) FlagsString() string

func (*GbcCPU) GetFrame

func (cpu *GbcCPU) GetFrame() *CPUFrame

func (*GbcCPU) HALT

func (cpu *GbcCPU) HALT()

HALT Halt CPU

func (*GbcCPU) Inc_hl

func (cpu *GbcCPU) Inc_hl()

INC (HL)

func (*GbcCPU) Inc_r

func (cpu *GbcCPU) Inc_r(r *byte)

INC r

func (*GbcCPU) Inc_rr

func (cpu *GbcCPU) Inc_rr(r1, r2 *byte)

INC rr

func (*GbcCPU) Inc_sp

func (cpu *GbcCPU) Inc_sp()

INC SP

func (*GbcCPU) IncrementPC

func (cpu *GbcCPU) IncrementPC(by int)

func (*GbcCPU) IsFlagSet

func (cpu *GbcCPU) IsFlagSet(flag int) bool

func (*GbcCPU) JP_hl

func (cpu *GbcCPU) JP_hl()

JP (HL)

func (*GbcCPU) JP_nn

func (cpu *GbcCPU) JP_nn()

JP nn

func (*GbcCPU) JPcc_nn

func (cpu *GbcCPU) JPcc_nn(flag int, jumpWhen bool)

JP cc, nn

func (*GbcCPU) JR_n

func (cpu *GbcCPU) JR_n()

JR n

func (*GbcCPU) JRcc_nn

func (cpu *GbcCPU) JRcc_nn(flag int, jumpWhen bool)

JR cc, nn

func (*GbcCPU) LDDhl_r

func (cpu *GbcCPU) LDDhl_r(r *byte)

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

func (cpu *GbcCPU) LDDr_hl(r *byte)

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) LDHLSP_n

func (cpu *GbcCPU) LDHLSP_n()

LDHL SP, n

func (*GbcCPU) LDHn_r

func (cpu *GbcCPU) LDHn_r(r *byte)

LDH n, r

func (*GbcCPU) LDHr_n

func (cpu *GbcCPU) LDHr_n(r *byte)

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

func (cpu *GbcCPU) LDIhl_r(r *byte)

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

func (cpu *GbcCPU) LDIr_hl(r *byte)

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) LDSP_hl

func (cpu *GbcCPU) LDSP_hl()

LD SP, rr

func (*GbcCPU) LDSP_nn

func (cpu *GbcCPU) LDSP_nn()

LD SP, nn

func (*GbcCPU) LDffplusc_r

func (cpu *GbcCPU) LDffplusc_r(r *byte)

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) LDn_nn

func (cpu *GbcCPU) LDn_nn(r1, r2 *byte)

LD n, nn

func (*GbcCPU) LDnn_SP

func (cpu *GbcCPU) LDnn_SP()

LD nn, SP

func (*GbcCPU) LDnn_r

func (cpu *GbcCPU) LDnn_r(r *byte)

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

func (cpu *GbcCPU) LDr_ffplusc(r *byte)

LD r,(C) Load the value from memory addressed 0xFF00 + value in register C. Store it in register (r)

func (*GbcCPU) LDr_nn

func (cpu *GbcCPU) LDr_nn(r *byte)

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

func (cpu *GbcCPU) LDr_rr(hs *byte, ls *byte, r *byte)

LD r, rr Load value from memory address located in register pair (RR) into register (r)

func (*GbcCPU) LDrn

func (cpu *GbcCPU) LDrn(r *byte)

LD r,n Load value (n) from memory address in the PC into register (r) and increment PC by 1

func (*GbcCPU) LDrr

func (cpu *GbcCPU) LDrr(r1 *byte, r2 *byte)

LD r,r Load value from register (r2) into register (r1)

func (*GbcCPU) LDrr_r

func (cpu *GbcCPU) LDrr_r(hs *byte, ls *byte, r *byte)

LD rr, r Load value from register (r) into memory address located at register pair (RR)

func (*GbcCPU) LinkMMU

func (cpu *GbcCPU) LinkMMU(m mmu.MemoryMappedUnit)

func (*GbcCPU) NOP

func (cpu *GbcCPU) NOP()

NOP No operation

func (*GbcCPU) OrA_hl

func (cpu *GbcCPU) OrA_hl()

OR A, (HL)

func (*GbcCPU) OrA_n

func (cpu *GbcCPU) OrA_n()

OR A, n

func (*GbcCPU) OrA_r

func (cpu *GbcCPU) OrA_r(r *byte)

OR A, r

func (*GbcCPU) Pop_AF

func (cpu *GbcCPU) Pop_AF()

POP AF Pop the stack twice onto register pair AF

func (*GbcCPU) Pop_nn

func (cpu *GbcCPU) Pop_nn(r1, r2 *byte)

POP nn Pop the stack twice onto register pair nn

func (*GbcCPU) Push_nn

func (cpu *GbcCPU) Push_nn(r1, r2 *byte)

PUSH nn Push register pair nn onto the stack and decrement the SP twice

func (*GbcCPU) RLA

func (cpu *GbcCPU) RLA()

RLA

func (*GbcCPU) RLCA

func (cpu *GbcCPU) RLCA()

RLCA

func (*GbcCPU) RRA

func (cpu *GbcCPU) RRA()

RRA

func (*GbcCPU) RRCA

func (cpu *GbcCPU) RRCA()

RRCA

func (*GbcCPU) ReadByte

func (cpu *GbcCPU) ReadByte(addr types.Word) byte

func (*GbcCPU) Resb_hl

func (cpu *GbcCPU) Resb_hl(b byte)

RES b, (HL)

func (*GbcCPU) Resb_r

func (cpu *GbcCPU) Resb_r(b byte, r *byte)

RES b, r

func (*GbcCPU) Reset

func (cpu *GbcCPU) Reset()

func (*GbcCPU) ResetFlag

func (cpu *GbcCPU) ResetFlag(flag int)

func (*GbcCPU) Ret

func (cpu *GbcCPU) Ret()

RET

func (*GbcCPU) Ret_i

func (cpu *GbcCPU) Ret_i()

RETI

func (*GbcCPU) Retcc

func (cpu *GbcCPU) Retcc(flag int, returnWhen bool)

RET cc

func (*GbcCPU) Rl_hl

func (cpu *GbcCPU) Rl_hl()

RL (HL)

func (*GbcCPU) Rl_r

func (cpu *GbcCPU) Rl_r(r *byte)

RL r

func (*GbcCPU) Rlc_hl

func (cpu *GbcCPU) Rlc_hl()

RLC (HL)

func (*GbcCPU) Rlc_r

func (cpu *GbcCPU) Rlc_r(r *byte)

RLC r

func (*GbcCPU) Rr_hl

func (cpu *GbcCPU) Rr_hl()

RR (HL)

func (*GbcCPU) Rr_r

func (cpu *GbcCPU) Rr_r(r *byte)

RR r

func (*GbcCPU) Rrc_hl

func (cpu *GbcCPU) Rrc_hl()

RRC (HL)

func (*GbcCPU) Rrc_r

func (cpu *GbcCPU) Rrc_r(r *byte)

RRC r

func (*GbcCPU) Rst

func (cpu *GbcCPU) Rst(n byte)

RST n

func (*GbcCPU) SCF

func (cpu *GbcCPU) SCF()

SCF

func (*GbcCPU) SetCPUSpeed

func (cpu *GbcCPU) SetCPUSpeed()

Checks to see if the CPU speed should change to double (CGB only)

func (*GbcCPU) SetFlag

func (cpu *GbcCPU) SetFlag(flag int)

func (*GbcCPU) Setb_hl

func (cpu *GbcCPU) Setb_hl(b byte)

SET b, (HL)

func (*GbcCPU) Setb_r

func (cpu *GbcCPU) Setb_r(b byte, r *byte)

SET b, r

func (*GbcCPU) Sla_hl

func (cpu *GbcCPU) Sla_hl()

SLA (HL)

func (*GbcCPU) Sla_r

func (cpu *GbcCPU) Sla_r(r *byte)

SLA r

func (*GbcCPU) Sra_hl

func (cpu *GbcCPU) Sra_hl()

SRA (HL)

func (*GbcCPU) Sra_r

func (cpu *GbcCPU) Sra_r(r *byte)

SRA r

func (*GbcCPU) Srl_hl

func (cpu *GbcCPU) Srl_hl()

SRL (HL)

func (*GbcCPU) Srl_r

func (cpu *GbcCPU) Srl_r(r *byte)

SRL r

func (*GbcCPU) Step

func (cpu *GbcCPU) Step() int

func (*GbcCPU) Stop

func (cpu *GbcCPU) Stop()

STOP

func (*GbcCPU) String

func (cpu *GbcCPU) String() string

func (*GbcCPU) SubAC_hl

func (cpu *GbcCPU) SubAC_hl()

SBC A, (HL)

func (*GbcCPU) SubAC_n

func (cpu *GbcCPU) SubAC_n()

SBC A, n

func (*GbcCPU) SubAC_r

func (cpu *GbcCPU) SubAC_r(r *byte)

SBC A,r

func (*GbcCPU) SubA_hl

func (cpu *GbcCPU) SubA_hl()

SUB A,hl

func (*GbcCPU) SubA_n

func (cpu *GbcCPU) SubA_n()

SUB A,n

func (*GbcCPU) SubA_r

func (cpu *GbcCPU) SubA_r(r *byte)

SUB A,r

func (*GbcCPU) Swap_hl

func (cpu *GbcCPU) Swap_hl()

SWAP (HL)

func (*GbcCPU) Swap_r

func (cpu *GbcCPU) Swap_r(r *byte)

SWAP r

func (*GbcCPU) Validate

func (cpu *GbcCPU) Validate() error

func (*GbcCPU) WriteByte

func (cpu *GbcCPU) WriteByte(addr types.Word, value byte)

func (*GbcCPU) XorA_hl

func (cpu *GbcCPU) XorA_hl()

XOR A, (HL)

func (*GbcCPU) XorA_n

func (cpu *GbcCPU) XorA_n()

XOR A, n

func (*GbcCPU) XorA_r

func (cpu *GbcCPU) XorA_r(r *byte)

XOR A, r

type Instruction

type Instruction struct {
	Opcode       byte
	Description  string
	OperandsSize int
	Cycles       int
	Operands     [2]byte
}

func (Instruction) String

func (i Instruction) String() string

type Registers

type Registers struct {
	A byte
	B byte
	C byte
	D byte
	E byte
	H byte
	L byte
	F byte // Flags Register
}

func (Registers) String

func (r Registers) String() string

Jump to

Keyboard shortcuts

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