Skip to content

Commit

Permalink
revert redundant function: fetchM1x2
Browse files Browse the repository at this point in the history
  • Loading branch information
koron committed Apr 20, 2024
1 parent 8a2c486 commit 232f6e5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
15 changes: 1 addition & 14 deletions cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (cpu *CPU) fetch16() uint16 {
return (uint16(h) << 8) | uint16(l)
}

// fetchM1 fetches a byte for M1 cycle
// fetchM1 fetches a byte for M1 cycle.
func (cpu *CPU) fetchM1() uint8 {
c := cpu.Memory.Get(cpu.PC)
cpu.PC++
Expand All @@ -145,19 +145,6 @@ func (cpu *CPU) fetchM1() uint8 {
return c
}

// fetchM1x2 fetches two bytes for M1 cycle.
// First one is a data, second one is a part of opcode.
func (cpu *CPU) fetchM1x2() (d, c uint8) {
d = cpu.Memory.Get(cpu.PC)
cpu.PC++
c = cpu.Memory.Get(cpu.PC)
cpu.PC++
// increment refresh counter
rc := cpu.IR.Lo
cpu.IR.Lo = rc&0x80 | (rc+1)&0x7f
return d, c
}

func (cpu *CPU) ioIn(addr uint8) uint8 {
if cpu.IO == nil {
return 0
Expand Down
4 changes: 2 additions & 2 deletions operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -1537,7 +1537,7 @@ func (cpu *CPU) executeOne() {
oopLDSPIX(cpu)

case 0xcb:
switch d, c3 := cpu.fetchM1x2(); c3 {
switch d, c3 := cpu.fetch(), cpu.fetchM1(); c3 {

case 0x06:
oopRLCIXdP(cpu, d)
Expand Down Expand Up @@ -2144,7 +2144,7 @@ func (cpu *CPU) executeOne() {
oopLDSPIY(cpu)

case 0xcb:
switch d, c3 := cpu.fetchM1x2(); c3 {
switch d, c3 := cpu.fetch(), cpu.fetchM1(); c3 {

case 0x06:
oopRLCIYdP(cpu, d)
Expand Down

0 comments on commit 232f6e5

Please sign in to comment.