Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
akatsuki105 committed Feb 8, 2024
1 parent a51cd39 commit 722f452
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 21 deletions.
3 changes: 3 additions & 0 deletions core/gb/dma.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ func newDMAController(g *GB) *dmaController {
}

func (d *dmaController) Reset(hasBIOS bool) {
d.mode = GDMA
d.src, d.dst, d.length = 0, 0, 0
d.completed = true
if !hasBIOS {
d.Write(0xFF51, 0xFF)
d.Write(0xFF52, 0xFF)
Expand Down
20 changes: 8 additions & 12 deletions core/gb/gb.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,17 @@ func New(audioBuffer io.Writer) *GB {
return g
}

func (g *GB) ID() string {
return "GB"
}
func (g *GB) ID() string { return "GB" }

func (g *GB) Reset(hasBIOS bool) {
g.ie, g.interrupt = 0, [5]bool{}
g.halted, g.blocked, g.key1, g.inOAMDMA = false, false, false, false

model := 0
if g.cartridge != nil && g.cartridge.IsCGB() {
model = 1
}

g.s.Reset()
g.m.Reset(hasBIOS)
g.cpu.Reset(hasBIOS)
Expand Down Expand Up @@ -156,13 +158,9 @@ func (g *GB) run() {
g.s.Commit()
}

func (g *GB) Resolution() (w int, h int) {
return 160, 144
}
func (g *GB) Resolution() (w int, h int) { return 160, 144 }

func (g *GB) Screen() []color.RGBA {
return g.video.Screen()
}
func (g *GB) Screen() []color.RGBA { return g.video.Screen() }

func (g *GB) SetKeyInput(key string, press bool) {
for i, b := range buttons {
Expand All @@ -179,9 +177,7 @@ func (g *GB) Title() string {
return g.cartridge.Title()
}

func (g *GB) requestInterrupt(id int) {
g.interrupt[id] = true
}
func (g *GB) requestInterrupt(id int) { g.interrupt[id] = true }

func (g *GB) checkInterrupt() int {
for i := 0; i < 5; i++ {
Expand Down
3 changes: 1 addition & 2 deletions core/gb/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ func newInput(g *GB) *Input {
}

func (i *Input) Reset(hasBIOS bool) {
i.p14 = false
i.p15 = false
i.p14, i.p15 = false, false
i.joyp = 0x0F
if !hasBIOS {
i.Write(0xFF00, 0x30)
Expand Down
4 changes: 1 addition & 3 deletions core/gb/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ func (m *Memory) Reset(hasBIOS bool) {
m.hram[i] = 0
}
m.wramBank = 1
m.ff72 = 0
m.ff73 = 0
m.ff74 = 0
m.ff72, m.ff73, m.ff74 = 0, 0, 0
}

func (m *Memory) Read(addr uint16) byte {
Expand Down
5 changes: 1 addition & 4 deletions core/gb/timer.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ func newTimer(g *GB) *timer {
}

func (t *timer) Reset(hasBIOS bool) {
t.counter = 0
t.tima = 0
t.tma = 0
t.tac = 0
t.counter, t.tima, t.tma, t.tac = 0, 0, 0, 0
if !hasBIOS {
t.tac = 0xF8
}
Expand Down

0 comments on commit 722f452

Please sign in to comment.