mirror of
https://github.com/trudnai/Steve2.git
synced 2025-04-07 20:37:12 +00:00
- Attempt to do better disassembly scroll syncchronization
- main.sync replaced to .async to avoid invalid opcode error
This commit is contained in:
parent
04fc99eb93
commit
bd8403ee64
@ -627,6 +627,12 @@
|
||||
<PersistentString
|
||||
value = "m6502.PC">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "line_number">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "disass_addr">
|
||||
</PersistentString>
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
<ContextState
|
||||
@ -663,6 +669,20 @@
|
||||
<ContextState
|
||||
contextName = "AND:6502_instr_logic.h">
|
||||
</ContextState>
|
||||
<ContextState
|
||||
contextName = "specialized closure #1 in DebuggerViewController.DisplayDisassembly():DebuggerViewController.swift">
|
||||
<PersistentStrings>
|
||||
<PersistentString
|
||||
value = "line_number">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "currentScrollLine">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "current_line_number">
|
||||
</PersistentString>
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
<ContextState
|
||||
contextName = "fetch:mmio.h">
|
||||
<PersistentStrings>
|
||||
@ -765,6 +785,14 @@
|
||||
</PersistentString>
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
<ContextState
|
||||
contextName = "DebuggerViewController.disass_scroll_to(line:):DebuggerViewController.swift">
|
||||
<PersistentStrings>
|
||||
<PersistentString
|
||||
value = "Disass_Display.visibleRect">
|
||||
</PersistentString>
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
<ContextState
|
||||
contextName = "HiRes.initHiResLineAddresses():HiRes.swift">
|
||||
<PersistentStrings>
|
||||
@ -773,6 +801,14 @@
|
||||
</PersistentString>
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
<ContextState
|
||||
contextName = "DebuggerViewController.get_scroll_line(view:):DebuggerViewController.swift">
|
||||
<PersistentStrings>
|
||||
<PersistentString
|
||||
value = "scrollPos / lineHeight">
|
||||
</PersistentString>
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
<ContextState
|
||||
contextName = "ADC:6502_instr_arithmetic.h">
|
||||
</ContextState>
|
||||
|
@ -63,13 +63,21 @@ class DebuggerViewController: NSViewController, NSTextFieldDelegate {
|
||||
// Stack_Display.scroll(Stack_Display.enclosingScrollView!.visibleRect, by: NSSize(width: 0, height: event.scrollingDeltaY) )
|
||||
// }
|
||||
|
||||
var scrollTo = Stack_Display.visibleRect.origin
|
||||
var scrollTo = Disass_Display.visibleRect.origin
|
||||
let lineSpacing = CGFloat(1.5)
|
||||
let lineHeight = Stack_Display.font!.pointSize * lineSpacing
|
||||
let lineHeight = Disass_Display.font!.pointSize * lineSpacing
|
||||
// print("lineHeight:", lineHeight, "fontSize:", Stack_Display.font?.pointSize)
|
||||
|
||||
scrollTo.y = round( (scrollTo.y + round(event.scrollingDeltaY) * lineHeight) / lineHeight) * lineHeight
|
||||
Stack_Display.scroll(scrollTo)
|
||||
let y1 = round( (scrollTo.y + round(event.scrollingDeltaY) * lineHeight) / lineHeight) * lineHeight
|
||||
let y2 = round( scrollTo.y / lineHeight + event.scrollingDeltaY ) * lineHeight
|
||||
|
||||
if y1 != y2 {
|
||||
print("NOT EQ", y1, y2)
|
||||
}
|
||||
|
||||
scrollTo.y = y1
|
||||
|
||||
Disass_Display.scroll(scrollTo)
|
||||
}
|
||||
|
||||
|
||||
@ -186,40 +194,94 @@ N V - B D I Z C
|
||||
}
|
||||
|
||||
|
||||
let disass_addr_max : UInt16 = 50
|
||||
let disass_addr_min : UInt16 = 320
|
||||
let disass_addr_max : UInt16 = 170
|
||||
var disass_addr : UInt16 = 0
|
||||
var line_number = 0
|
||||
var current_line_number = 0
|
||||
let lines_to_disass = 300
|
||||
|
||||
|
||||
func get_scroll_line(view: DisplayView) -> Int {
|
||||
let scrollPos = view.visibleRect.origin.y
|
||||
let lineSpacing = CGFloat(1.5)
|
||||
let lineHeight = view.font!.pointSize * lineSpacing
|
||||
|
||||
return Int(scrollPos / lineHeight)
|
||||
}
|
||||
|
||||
|
||||
func scroll_to(view: DisplayView, line: Int) {
|
||||
var scrollTo = view.visibleRect.origin
|
||||
let lineSpacing = CGFloat(1.5)
|
||||
let lineHeight = view.font!.pointSize * lineSpacing
|
||||
|
||||
scrollTo.y = CGFloat(line) * lineHeight
|
||||
|
||||
view.scroll(scrollTo)
|
||||
}
|
||||
|
||||
|
||||
func DisplayDisassembly() {
|
||||
let m6502_saved = m6502
|
||||
var disass = ""
|
||||
|
||||
line_number = 0
|
||||
current_line_number = 0
|
||||
|
||||
if m6502.PC > disass_addr && m6502.PC < disass_addr + disass_addr_max {
|
||||
m6502.PC = disass_addr
|
||||
}
|
||||
else {
|
||||
disass_addr = m6502.PC
|
||||
m6502.PC -= disass_addr_min + 20
|
||||
|
||||
// try to sync disassembly code
|
||||
while m6502.PC < disass_addr - disass_addr_min {
|
||||
m6502_Disass_1_Instr()
|
||||
// line_number += 1
|
||||
}
|
||||
|
||||
// hopefully instruction address is in sync
|
||||
disass_addr = m6502.PC
|
||||
}
|
||||
|
||||
// m6502.PC = 0xFF3A
|
||||
|
||||
for _ in 1...35 {
|
||||
let current_line = m6502.PC == m6502_saved.PC
|
||||
// normal disassembly
|
||||
for _ in 1...lines_to_disass {
|
||||
let isCurrentLine = m6502.PC == m6502_saved.PC
|
||||
|
||||
m6502_Disass_1_Instr()
|
||||
line_number += 1
|
||||
|
||||
var line = String(cString: disassemblyLine( current_line )!)
|
||||
var line = String(cString: disassemblyLine( isCurrentLine )!)
|
||||
|
||||
if current_line {
|
||||
if isCurrentLine {
|
||||
line = invertLine(line: line)
|
||||
current_line_number = line_number
|
||||
}
|
||||
|
||||
disass += line + "\n"
|
||||
}
|
||||
|
||||
DispatchQueue.main.async {
|
||||
// let isEmpty = self.Disass_Display.string.isEmpty
|
||||
self.Disass_Display.string = disass
|
||||
}
|
||||
let currentScrollLine = self.get_scroll_line(view: self.Disass_Display) + 1
|
||||
if self.current_line_number <= currentScrollLine || self.current_line_number > currentScrollLine + 35 {
|
||||
self.scroll_to(view: self.Disass_Display, line: self.current_line_number - 5)
|
||||
|
||||
// at the beginning it takes a while to fill up the buffer -- maybe allocation issue?
|
||||
if currentScrollLine == 1 {
|
||||
// so we need to scroll a bit later when the string is already populated
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
||||
self.scroll_to(view: self.Disass_Display, line: self.current_line_number - 5)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
||||
// your code here
|
||||
}
|
||||
m6502 = m6502_saved
|
||||
}
|
||||
|
||||
|
@ -143,6 +143,7 @@ class DebuggerWindowController: NSWindowController, NSWindowDelegate {
|
||||
}
|
||||
|
||||
// TODO: Update Screen and speaker etc
|
||||
ViewController.current?.Update()
|
||||
}
|
||||
|
||||
|
||||
@ -154,6 +155,7 @@ class DebuggerWindowController: NSWindowController, NSWindowDelegate {
|
||||
}
|
||||
|
||||
// TODO: Update Screen and speaker etc
|
||||
ViewController.current?.Update()
|
||||
}
|
||||
|
||||
|
||||
@ -179,6 +181,7 @@ class DebuggerWindowController: NSWindowController, NSWindowDelegate {
|
||||
}
|
||||
|
||||
// TODO: Update Screen and speaker etc
|
||||
ViewController.current?.Update()
|
||||
}
|
||||
|
||||
|
||||
|
@ -1162,7 +1162,7 @@ class ViewController: NSViewController {
|
||||
// Rendering is happening in the main thread, which has two implications:
|
||||
// 1. We can update UI elements
|
||||
// 2. it is independent of the simulation, de that is running in the background thread while we are busy with rendering...
|
||||
DispatchQueue.main.sync {
|
||||
DispatchQueue.main.async {
|
||||
self.UpdateText()
|
||||
self.UpdateCPUspeed()
|
||||
|
||||
@ -1229,31 +1229,31 @@ class ViewController: NSViewController {
|
||||
|
||||
|
||||
func diskButtonUpdate() {
|
||||
DispatchQueue.main.sync {
|
||||
DispatchQueue.main.async {
|
||||
// Disk Motor LED
|
||||
if ( frameCounter % DEF_DRV_LED_DIV == 0 ) {
|
||||
if ( self.frameCounter % DEF_DRV_LED_DIV == 0 ) {
|
||||
if spkr_is_disk_motor_playing() {
|
||||
if disk1_led.isHidden {
|
||||
disk1_led.isHidden = false
|
||||
if self.disk1_led.isHidden {
|
||||
self.disk1_led.isHidden = false
|
||||
}
|
||||
}
|
||||
else {
|
||||
if !disk1_led.isHidden {
|
||||
disk1_led.isHidden = true
|
||||
if !self.disk1_led.isHidden {
|
||||
self.disk1_led.isHidden = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Disk Loaded
|
||||
if ( frameCounter % DEF_DRV_LED_DIV == 0 ) {
|
||||
if ( self.frameCounter % DEF_DRV_LED_DIV == 0 ) {
|
||||
if woz_is_loaded() > 0 {
|
||||
if disk1_closed.isHidden {
|
||||
disk1_closed.isHidden = false
|
||||
if self.disk1_closed.isHidden {
|
||||
self.disk1_closed.isHidden = false
|
||||
}
|
||||
}
|
||||
else {
|
||||
if !disk1_closed.isHidden {
|
||||
disk1_closed.isHidden = true
|
||||
if !self.disk1_closed.isHidden {
|
||||
self.disk1_closed.isHidden = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -701,7 +701,7 @@ class ViewController: UIViewController {
|
||||
// Rendering is happening in the main thread, which has two implications:
|
||||
// 1. We can update UI elements
|
||||
// 2. it is independent of the simulation, de that is running in the background thread while we are busy with rendering...
|
||||
DispatchQueue.main.sync {
|
||||
DispatchQueue.main.async {
|
||||
var unicodeTextString : String = ""
|
||||
|
||||
var fromLines = 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user