Skip to content

Commit

Permalink
Make FetchAndDecode on CPU public
Browse files Browse the repository at this point in the history
  • Loading branch information
maxfierke committed Sep 8, 2024
1 parent f5dc931 commit 7b63f58
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions cpu/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (cpu *CPU) Step(mmu *mem.MMU) (uint8, error) {
return 4, nil
}

inst, err := cpu.fetchAndDecode(mmu)
inst, err := cpu.FetchAndDecode(mmu, cpu.PC.Read())
if err != nil {
return 0, err
}
Expand All @@ -54,9 +54,8 @@ func (cpu *CPU) Step(mmu *mem.MMU) (uint8, error) {
return cycles, err
}

func (cpu *CPU) fetchAndDecode(mmu *mem.MMU) (*isa.Instruction, error) {
func (cpu *CPU) FetchAndDecode(mmu *mem.MMU, addr uint16) (*isa.Instruction, error) {
// Fetch :)
addr := cpu.PC.Read()
opcodeByte := mmu.Read8(addr)
prefixed := opcodeByte == 0xCB

Expand Down

0 comments on commit 7b63f58

Please sign in to comment.