Skip to content

Commit 49a4072

Browse files
committed
Fixed writing to ROM causing issues
1 parent 4771cb1 commit 49a4072

File tree

3 files changed

+14
-17
lines changed

3 files changed

+14
-17
lines changed

private/processor/cpu/lr35902/lr35902.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func (c *LR35902) Step() int {
8181
// fmt.Printf("")
8282
// }
8383

84-
if c.Registers.PC == 0x1446 {
84+
if c.Registers.PC == 0x0a9b {
8585
// Load stack for debugging
8686
var stack [63]uint16
8787
for j := 0; j < len(stack); j++ {

private/reader/reader.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,6 @@ func (cr *CartridgeReader) Read(addr uint16) uint8 {
3737

3838
func (cr *CartridgeReader) Write(addr uint16, val uint8) {
3939
// TODO implement cartridge write protection
40-
cr.cartridge.Write(addr, val)
40+
// cr.cartridge.Write(addr, val)
41+
// panic("Cartridge write protection not implemented")
4142
}

private/ui/terminal/terminal.go

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"bufio"
55
"fmt"
66
"os"
7-
"os/signal"
7+
"os/signal" // added import
88
"syscall"
99
"time"
1010

@@ -52,14 +52,14 @@ func (a *Application) Run(skipBootROM bool) {
5252
// Defer terminal restoration in the main goroutine.
5353
defer term.Restore(int(os.Stdin.Fd()), oldState)
5454

55-
// Create a panic channel.
56-
panicChan := make(chan interface{}, 1)
57-
5855
// Start the GameBoy runtime in a goroutine with panic recovery.
5956
go func() {
6057
defer func() {
6158
if r := recover(); r != nil {
62-
panicChan <- r
59+
// Restore terminal before printing panic stack trace.
60+
term.Restore(int(os.Stdin.Fd()), oldState)
61+
62+
panic(r)
6363
}
6464
}()
6565
a.gb.Start(skipBootROM)
@@ -129,6 +129,12 @@ Loop:
129129

130130
// Handle quit key.
131131
if key == "q" {
132+
// Stop the GameBoy runtime.
133+
a.gb.Stop()
134+
135+
// Clear the screen.
136+
fmt.Print("\033[H\033[2J")
137+
132138
break Loop
133139
}
134140

@@ -160,18 +166,8 @@ Loop:
160166
joy.SetButton(butt, true)
161167
case <-sigChan:
162168
break Loop
163-
164-
case <-panicChan:
165-
// Optionally log p
166-
break Loop
167169
}
168170
}
169-
170-
// Stop the GameBoy runtime.
171-
a.gb.Stop()
172-
173-
// Clear the screen.
174-
fmt.Print("\033[H\033[2J")
175171
}
176172

177173
func (a *Application) render() {

0 commit comments

Comments
 (0)