Skip to content

Commit

Permalink
Avoid cache miss when getting instruct func (#33)
Browse files Browse the repository at this point in the history
This makes the instruction array a global variable. This improves performance by ~3ns/op. This also includes a new Benchmark for ExecuteNextOpcode()
  • Loading branch information
TotallyGamerJet authored Aug 9, 2020
1 parent 84af8fa commit da8716d
Show file tree
Hide file tree
Showing 3 changed files with 1,182 additions and 1,182 deletions.
4 changes: 1 addition & 3 deletions pkg/gb/gameboy.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ type Gameboy struct {
interruptsOn bool
halted bool

mainInst [0x100]func()
cbInst [0x100]func()
cbInst [0x100]func()

// Mask of the currently pressed buttons.
inputMask byte
Expand Down Expand Up @@ -339,7 +338,6 @@ func (gb *Gameboy) setup() {
gb.scanlineCounter = 456
gb.inputMask = 0xFF

gb.mainInst = gb.mainInstructions()
gb.cbInst = gb.cbInstructions()

gb.SpritePalette = NewPalette()
Expand Down
Loading

0 comments on commit da8716d

Please sign in to comment.