Skip to content

Commit

Permalink
refactor(cpu): move drawBit from bottom to top
Browse files Browse the repository at this point in the history
  • Loading branch information
gaoliveira21 committed Jan 13, 2024
1 parent 93f7731 commit 0948873
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions core/cpu/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ func (cpu *CPU) loadFont() {
}
}

func (cpu *CPU) drawBit(bit byte, y int, x int) {
pixelOnDisplay := cpu.Graphics.GetPixel(int(y), int(x))

if bit == 0x01 && pixelOnDisplay == 0x01 {
cpu.v[0xF] = 0x01
}

cpu.Graphics.SetPixel(int(y), int(x), pixelOnDisplay^bit)
}

func (cpu *CPU) decode(data uint16) (oc *opcode) {
return NewOpcode(data)
}
Expand Down Expand Up @@ -458,13 +468,3 @@ func (cpu *CPU) schip_drw(oc *opcode) {
}
}
}

func (cpu *CPU) drawBit(bit byte, y int, x int) {
pixelOnDisplay := cpu.Graphics.GetPixel(int(y), int(x))

if bit == 0x01 && pixelOnDisplay == 0x01 {
cpu.v[0xF] = 0x01
}

cpu.Graphics.SetPixel(int(y), int(x), pixelOnDisplay^bit)
}

0 comments on commit 0948873

Please sign in to comment.