Trace ProDOS driver calls

This commit is contained in:
Ivan Izaguirre 2020-11-20 19:28:22 +01:00
parent bce5c4b92e
commit 512988655d
2 changed files with 29 additions and 6 deletions

View File

@ -96,7 +96,7 @@ func (k *keyboard) putKey(keyEvent *fyne.KeyEvent) {
result = 11 // 31 in the Base64A
case fyne.KeyDown:
result = 10
case fyne.KeyTab:
case fyne.KeyTab: // The Tab is not reaching here
result = 9
case fyne.KeyDelete:
result = 127 // 24 in the Base64A

View File

@ -2,6 +2,11 @@ package izapple2
import "fmt"
/*
See:
https://prodos8.com/docs/techref/calls-to-the-mli/
*/
type traceProDOS struct {
a *Apple2
callPending bool // We assume MLI is not reentrant
@ -57,8 +62,7 @@ func (t *traceProDOS) inspect() {
} else if pc == biAddress {
t.dumpBIExec()
} else if /*t.callPending &&*/ t.isDriverAddress(pc) {
fmt.Printf(" <<< Calling a driver in $%04x >>> ", pc)
t.dumpDriverCall()
}
}
@ -172,9 +176,9 @@ func (t *traceProDOS) dumpMLIReturn() {
case 0xc8: // Open file
fmt.Printf("ref: %v\n", t.paramByte(5))
case 0xca: // Read
fmt.Printf("%v bytes read \n", t.paramByte(6))
fmt.Printf("%v bytes read \n", t.paramWord(6))
case 0xcb: // Write
fmt.Printf("%v bytes written \n", t.paramByte(6))
fmt.Printf("%v bytes written \n", t.paramWord(6))
case 0xcf: // File position
fmt.Printf("%v\n", t.paramLen(2))
case 0xd1: // File size
@ -197,6 +201,22 @@ func (t *traceProDOS) dumpBIExec() {
fmt.Printf("Prodos BI exec: \"%s\".\n", s)
}
var proDosCommandNames = []string{"STATUS", "READ", "WRITE", "FORMAT"}
func (t *traceProDOS) dumpDriverCall() {
pc, _ := t.a.cpu.GetPCAndSP()
command := t.a.mmu.Peek(0x42)
unit := t.a.mmu.Peek(0x43)
address := uint16(t.a.mmu.Peek(0x44)) + uint16(t.a.mmu.Peek(0x45))<<8
block := uint16(t.a.mmu.Peek(0x46)) + uint16(t.a.mmu.Peek(0x47))<<8
commandName := "OTHER"
if int(command) < len(proDosCommandNames) {
commandName = proDosCommandNames[command]
}
fmt.Printf("\n Prodos driver $%04x command %02x-%s on unit $%x, block %v to $%04x ==> ", pc, command, commandName, unit, block, address)
}
func (t *traceProDOS) dumpDevices() {
// Active disk devices
@ -228,11 +248,14 @@ func (t *traceProDOS) dumpDevices() {
fmt.Printf(" S%vD%v: $%04x\n", slot, drive+1, value)
}
}
// Datetime
value := uint16(mem.peek(deviceDateTimeVector)) + 0x100*uint16(mem.peek(deviceDateTimeVector+1))
fmt.Printf(" Datetime: $%04x\n", value)
}
func (t *traceProDOS) refreshDeviceDrives() {
mem := t.a.mmu.getPhysicalMainRAM(false)
drivers := make([]uint16, 0, 14)
drivers := make([]uint16, 0, 15)
for i := uint16(0); i < 16; i++ {
address := deviceDriverVectors + i*2
value := uint16(mem.peek(address)) + 0x100*uint16(mem.peek(address+1))