gb-player/gb/cpu.go
2025-08-13 16:03:23 +02:00

46 lines
653 B
Go

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
}