diff --git a/core/chip8.go b/core/chip8.go index 7281626..17f706e 100644 --- a/core/chip8.go +++ b/core/chip8.go @@ -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 diff --git a/core/cpu/cpu.go b/core/cpu/cpu.go index 53d5e95..4517322 100644 --- a/core/cpu/cpu.go +++ b/core/cpu/cpu.go @@ -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 { diff --git a/core/cpu/opcode.go b/core/cpu/opcode.go index bba722c..74eb65c 100644 --- a/core/cpu/opcode.go +++ b/core/cpu/opcode.go @@ -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