Skip to content

Commit

Permalink
refactor(cpu): move and rename CPU constants
Browse files Browse the repository at this point in the history
  • Loading branch information
gaoliveira21 committed Jan 1, 2024
1 parent 04d0929 commit c0f1e2c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion core/chip8.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type Chip8 struct {
}

func (c8 *Chip8) Update() error {
for i := 0; i < int(cpu.FREQUENCY/60); i++ {
for i := 0; i < cpu.SPEED; i++ {
for key, value := range input.Keypad {
if ebiten.IsKeyPressed(key) {
c8.cpu.Keys[value] = 0x01
Expand Down
9 changes: 1 addition & 8 deletions core/cpu/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,7 @@ import (
)

const (
FREQUENCY = 700 // Instructions per second

INSTRUCTION_BITMASK = 0xF000
X_BITMASK = 0x0F00
Y_BITMASK = 0x00F0
N_BITMASK = 0x000F
NN_BITMASK = 0x00FF
NNN_BITMASK = 0x0FFF
SPEED = int(700 / 60) // Instructions per second
)

type CPU struct {
Expand Down
9 changes: 9 additions & 0 deletions core/cpu/opcode.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
package cpu

const (
INSTRUCTION_BITMASK = 0xF000
X_BITMASK = 0x0F00
Y_BITMASK = 0x00F0
N_BITMASK = 0x000F
NN_BITMASK = 0x00FF
NNN_BITMASK = 0x0FFF
)

type opcode struct {
instruction uint16
registerX uint8
Expand Down

0 comments on commit c0f1e2c

Please sign in to comment.