Last active
February 21, 2022 18:12
-
-
Save blu/2567594214ea66e83d3a6cfc4cd9c6db to your computer and use it in GitHub Desktop.
Morfe cumulative patch against 8dd9012
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/cmd/morfe/main.go b/cmd/morfe/main.go | |
index 6526b3b..d150606 100644 | |
--- a/cmd/morfe/main.go | |
+++ b/cmd/morfe/main.go | |
@@ -129,7 +129,6 @@ func (gui *GUI) newRendererAndTexture(window *sdl.Window) { | |
if err != nil { | |
log.Fatalf("Failed to create renderer: %s\n", err) | |
} | |
- debugRendererInfo(gui.renderer) | |
gui.texture_txt = gui.newTexture() | |
gui.texture_txt.SetBlendMode(sdl.BLENDMODE_BLEND) | |
@@ -151,16 +150,6 @@ func (gui *GUI) newTexture() *sdl.Texture { | |
if err != nil { | |
log.Fatalf("Failed to create texture font from surface: %s\n", err) | |
} | |
- | |
- if debug.gui { | |
- format, _, w, h, err := texture.Query() | |
- if err != nil { | |
- log.Fatalf("Failed to query texture: %s\n", err) | |
- } | |
- fmt.Printf("texture format: %s\n", sdl.GetPixelFormatName(uint(format))) | |
- fmt.Printf("texture width: %d\n", w) | |
- fmt.Printf("texture height: %d\n", h) | |
- } | |
return texture | |
} | |
diff --git a/cmd/morfe/tui.go b/cmd/morfe/tui.go | |
index 5bc8558..e08f893 100644 | |
--- a/cmd/morfe/tui.go | |
+++ b/cmd/morfe/tui.go | |
@@ -265,6 +265,14 @@ func (ui *Ui) cmd_set(g *gocui.Gui, tokens []string) { | |
ui.updateStatusView(g) | |
ui.updateCodeView(g) | |
} | |
+ case "brk": // set brk <value> | |
+ if len(tokens) < 3 { | |
+ err = fmt.Errorf("not enough parameters") | |
+ break | |
+ } | |
+ if val, err = hex2uint32(tokens[2]); err == nil { | |
+ ui.cpu.SetBreak(val) | |
+ } | |
default: | |
err = fmt.Errorf("unknown parameter %v", tokens[2]) | |
} | |
@@ -450,6 +458,7 @@ func (ui *Ui) updateLogView(g *gocui.Gui) error { | |
fmt.Fprintf(v, "watch {add|del} <value> - manage watch list vals\n") | |
fmt.Fprintf(v, "set reg <regname> <value> - set value of register\n") | |
fmt.Fprintf(v, "set pc <addr> - set Program Counter of cpu\n") | |
+ fmt.Fprintf(v, "set brk <addr> - set Break Program Counter of cpu\n") | |
fmt.Fprintf(v, "reset - perform cpu reset \n") | |
fmt.Fprintf(v, "load hex <filename> - load IntelHex format into memory\n") | |
fmt.Fprintf(v, "set mem <addr> - set memory view address\n") | |
@@ -566,8 +575,8 @@ func (ui *Ui) updateStackView(g *gocui.Gui) error { | |
fmt.Fprintf(v, "%02x", ui.cpu.Read_8(addr )) | |
fmt.Fprintf(v, "%02x", ui.cpu.Read_8(addr+1)) | |
fmt.Fprintf(v, " ") | |
+ fmt.Fprintf(v, "%02x", ui.cpu.Read_8(addr+2)) | |
fmt.Fprintf(v, "%02x", ui.cpu.Read_8(addr+3)) | |
- fmt.Fprintf(v, "%02x", ui.cpu.Read_8(addr+4)) | |
if addr == sp { | |
fmt.Fprintf(v, ansi_reset) | |
diff --git a/emulator/cpu_65c816/cpu.go b/emulator/cpu_65c816/cpu.go | |
index 36d6a85..b4cb6f6 100644 | |
--- a/emulator/cpu_65c816/cpu.go | |
+++ b/emulator/cpu_65c816/cpu.go | |
@@ -436,6 +436,10 @@ func (cpu *CPU) SetPC(addr uint32) { | |
return | |
} | |
+func (cpu *CPU) SetBreak(addr uint32) { | |
+ return | |
+} | |
+ | |
// Reset resets the CPU to its initial powerup state | |
func (cpu *CPU) Reset() { | |
//cpu.E = 1 - should be | |
diff --git a/emulator/cpu_68xxx/m68k.go b/emulator/cpu_68xxx/m68k.go | |
index 3a16a30..26c9853 100644 | |
--- a/emulator/cpu_68xxx/m68k.go | |
+++ b/emulator/cpu_68xxx/m68k.go | |
@@ -61,6 +61,7 @@ type CPU struct { | |
name string // cpu0, cpu1, etc. | |
Cycles uint32 // number of cycles used by last step | |
+ BreakPC uint32 // break-pc address; if set multi-step to it | |
AllCycles uint64 // cumulative number of cycles of CPU instance | |
} | |
@@ -228,6 +229,21 @@ func (c *CPU) Execute() uint32 { | |
} | |
func (c *CPU) Step() uint32 { | |
+ if c.BreakPC != 0 { | |
+ cycles := uint32(0) | |
+ for c.BreakPC != uint32(C.m68k_get_reg(nil, C.M68K_REG_PC)) { | |
+ prev_pc := C.m68k_get_reg(nil, C.M68K_REG_PC) | |
+ protocycles := uint32(C.m68k_execute_step()) | |
+ if prev_pc != C.m68k_get_reg(nil, C.M68K_REG_PC) { | |
+ cycles += protocycles | |
+ } | |
+ } | |
+ c.AllCycles += uint64(cycles) | |
+ c.Cycles = uint32(cycles) | |
+ c.BreakPC = 0 | |
+ return uint32(cycles) | |
+ } | |
+ | |
cycles := C.m68k_execute_step() // provided by wrapper | |
c.AllCycles = c.AllCycles+uint64(cycles) | |
c.Cycles = uint32(cycles) | |
@@ -243,6 +259,10 @@ func (c *CPU) SetPC(val uint32) { | |
C.m68k_set_reg(C.M68K_REG_PC, C.uint(val)) | |
} | |
+func (c *CPU) SetBreak(val uint32) { | |
+ c.BreakPC = val | |
+} | |
+ | |
func (c *CPU) SetRegister(reg string, val uint32) error { | |
if c_reg_id, exists := regMapping[reg]; exists { | |
C.m68k_set_reg(c_reg_id, C.uint(val)) | |
@@ -250,7 +270,6 @@ func (c *CPU) SetRegister(reg string, val uint32) error { | |
} else { | |
return fmt.Errorf("m68k: unknown register %v", reg) | |
} | |
- | |
} | |
func (c *CPU) GetRegisters() map[string]uint32 { | |
diff --git a/emulator/cpu_dummy/cpu.go b/emulator/cpu_dummy/cpu.go | |
index 9baf1f7..b023e4d 100644 | |
--- a/emulator/cpu_dummy/cpu.go | |
+++ b/emulator/cpu_dummy/cpu.go | |
@@ -31,6 +31,10 @@ func (cpu *CPU) SetPC(addr uint32) { | |
return | |
} | |
+func (cpu *CPU) SetBreak(addr uint32) { | |
+ return | |
+} | |
+ | |
func (cpu *CPU) Step() (uint32) { | |
return 0x00 | |
} | |
diff --git a/emulator/emu/interfaces.go b/emulator/emu/interfaces.go | |
index b64babf..017486b 100644 | |
--- a/emulator/emu/interfaces.go | |
+++ b/emulator/emu/interfaces.go | |
@@ -47,6 +47,7 @@ type Processor interface { | |
TriggerIRQ(byte) // irq number as parameter - may be ignored on some CPUs | |
SetRegister(string, uint32) error // set selected register | |
SetPC(uint32) // redundant to SetRegister but convinient | |
+ SetBreak(uint32) // set breakpoint PC; 0: disabled | |
Write_8(uint32, byte) // write byte to cpu memory | |
Read_8(uint32) byte // read byte from cpu memory | |
diff --git a/emulator/ps2/ps2.go b/emulator/ps2/ps2.go | |
index 01ac1cb..198a367 100644 | |
--- a/emulator/ps2/ps2.go | |
+++ b/emulator/ps2/ps2.go | |
@@ -61,7 +61,6 @@ func (s *PS2) Clear() { | |
func (s *PS2) Read(fn byte, addr uint32) (byte, error) { | |
switch addr { | |
case KBD_DATA: // 0x60 | |
- fmt.Printf("ps2: %6s read KBD_DATA: val %02x\n", s.name, s.data) | |
s.status = s.status & ^PS2_STAT_OBF | |
return s.data, nil | |
@@ -79,7 +78,6 @@ func (s *PS2) Write(fn byte, addr uint32, val byte) error { | |
switch addr { | |
case KBD_DATA: // 0x60 | |
if s.ccb_write_mode { | |
- fmt.Printf("ps2: %6s write KBD_DATA: val %02x -> CCB\n", s.name, val) | |
s.ccb_write_mode = false | |
s.CCB = val | |
@@ -101,7 +99,6 @@ func (s *PS2) Write(fn byte, addr uint32, val byte) error { | |
return nil | |
} | |
- fmt.Printf("ps2: %6s write KBD_DATA: val %02x\n", s.name, val) | |
/* | |
@@ -122,7 +119,6 @@ func (s *PS2) Write(fn byte, addr uint32, val byte) error { | |
*/ | |
case KBD_COMMAND: // 0x64 - command when write | |
- fmt.Printf("ps2: %6s write KBD_COMMAND: val %02x\n", s.name, val) | |
switch val { | |
case 0x60: | |
s.ccb_write_mode = true | |
@@ -180,7 +176,6 @@ func (s *PS2) Write(fn byte, addr uint32, val byte) error { | |
} | |
func (s *PS2) AddKeyCode(val byte) { | |
- fmt.Printf("ps2: AddKeyCode: %02x\n", val) | |
s.data = val | |
s.status = s.status | PS2_STAT_OBF | |
} | |
diff --git a/emulator/vicky3/vicky3.go b/emulator/vicky3/vicky3.go | |
index b05ffc3..b0f5429 100644 | |
--- a/emulator/vicky3/vicky3.go | |
+++ b/emulator/vicky3/vicky3.go | |
@@ -229,10 +229,6 @@ func (v *Vicky) recalculateScreen() { | |
//v.text_rows = (v.c.Screen_y_size - (uint32(v.Border_y_size) * 2)) / (v.pixel_size * 8) | |
v.text_cols = uint32(v.c.Screen_x_size / 8) | |
v.text_rows = uint32(v.c.Screen_y_size / 8) | |
- | |
- fmt.Printf("vicky3: text_rows: %d\n", v.text_rows) | |
- fmt.Printf("vicky3: text_cols: %d\n", v.text_cols) | |
- | |
} | |
// RAM-interface specific |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment