WIP
This commit is contained in:
45
gb/cpu.go
Normal file
45
gb/cpu.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package gb
|
||||
|
||||
const CPUFrequency = 4194304
|
||||
|
||||
type Registers struct {
|
||||
A byte
|
||||
F byte
|
||||
B byte
|
||||
C byte
|
||||
D byte
|
||||
E byte
|
||||
H byte
|
||||
L byte
|
||||
PC uint16
|
||||
SP uint16
|
||||
}
|
||||
|
||||
type CPU struct {
|
||||
Regs Registers
|
||||
FetchedData uint16
|
||||
MemoryDestination uint16
|
||||
DestinationIsMemory bool
|
||||
CurrentOPcode byte
|
||||
// CurrentInstruction *Instruction
|
||||
Halted bool
|
||||
Stepping bool
|
||||
InterruptMasterEnabled bool
|
||||
}
|
||||
|
||||
func NewCPU() *CPU {
|
||||
cpu := CPU{}
|
||||
cpu.Regs = Registers{}
|
||||
cpu.Stepping = true
|
||||
|
||||
return &cpu
|
||||
}
|
||||
|
||||
func (cpu *CPU) Step() bool {
|
||||
if cpu.Stepping {
|
||||
cpu.Stepping = false
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
Reference in New Issue
Block a user