Skip to content

Commit

Permalink
CPU table optimisation (#21)
Browse files Browse the repository at this point in the history
* changed instruction switch statement into a function table, some minor changes to the cb_table function which unnecessarily converted indexes to bytes

* variable scope bug fix for densifying the main instruction table

* fixed comments, removed ExecuteOpcode method, moved table creation to instructions.go, and minor style changes
  • Loading branch information
ear7h authored and Humpheh committed Nov 27, 2018
1 parent c35240e commit f876370
Show file tree
Hide file tree
Showing 3 changed files with 1,224 additions and 1,215 deletions.
4 changes: 3 additions & 1 deletion pkg/gb/gameboy.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ type Gameboy struct {
interruptsOn bool
halted bool

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

// Flag if the game is running in cgb mode. For this to be true the game
Expand Down Expand Up @@ -314,6 +315,7 @@ 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 f876370

Please sign in to comment.