CSPECT compatible debug interface

This commit is contained in:
romych committed 2026-03-29 20:57:32 +03:00
1 parent 18df702750
commit 72a2d6b3a3
77 files changed
+4190 -109

No files matched your search

+10 -6
View File
@@ -15,6 +15,7 @@ import (
"okemu/z80"
"os"
"strconv"
"sync/atomic"
//"okemu/z80"
"okemu/z80/c99"
@@ -24,6 +25,10 @@ import (
)
const DefaultCPUFrequency = 2_500_000
const CPUFrequencyLow float64 = 2.47
const CPUFrequencyHi float64 = 2.53
const TimerFrequencyLow float64 = 1.47
const TimerFrequencyHi float64 = 1.53
type ComputerType struct {
cpu *c99.Z80
@@ -49,7 +54,7 @@ type ComputerType struct {
//
debugger *debug.Debugger
config *config.OkEmuConfig
kbAck bool
kbAck atomic.Bool
}
type Snapshot struct {
@@ -77,7 +82,7 @@ const VidColorBit = 0x40
// SetCPUState(state *z80.CPU)
//}
func (c *ComputerType) GetCPUState() *z80.CPU {
func (c *ComputerType) CPUState() *z80.CPU {
return c.cpu.GetState()
}
@@ -120,9 +125,9 @@ func NewComputer(cfg *config.OkEmuConfig, deb *debug.Debugger) *ComputerType {
//c.aOffset = 0x100
c.pit = pit.New()
c.kbAck = false
c.kbAck.Store(false)
c.usart = usart.New()
c.pic = pic.New()
c.pic = pic.NewI8259()
c.fdc = fdc.NewFDC(cfg)
c.cpuFrequency = DefaultCPUFrequency
c.debugger = deb
@@ -230,7 +235,7 @@ func (c *ComputerType) GetPixel(x uint16, y uint16) color.RGBA {
cl := (c.vRAM.memory[a1] >> (x & 0x07)) & 1
cl |= ((c.vRAM.memory[a2] >> (x & 0x07)) & 1) << 1
if cl == 0 {
resColor = BgColorPalette[c.bgColor]
//resColor = BgColorPalette[c.bgColor]
resColor = ColorPalette[c.palette][cl]
} else {
resColor = ColorPalette[c.palette][cl]
@@ -299,7 +304,6 @@ func (c *ComputerType) TimerClk() {
// IRQ from timer
if c.pit.Fired(0) {
c.pic.SetIRQ(RstTimerNo)
//c.ioPorts[PIC_DD75RS] |= Rst4Mask
}
// clock for SIO KR580VV51
if c.pit.Fired(1) {
+7 -5
View File
@@ -93,12 +93,14 @@ const TmrDd70ctr = 0x63
const RstKbdNo = 1
const RstTimerNo = 4
const KbAckBit = 0x80
// const Rst0Mask = 0x01 // System interrupt
const RstKbdMask = 0x02 // Keyboard interrupt
// const Rst2Mask = 0x04 // Serial interface interrupt
// const Rst3Mask = 0x08 // Printer ready
const RstTmrMask = 0x10
//const Rst0Mask = 0x01 // System interrupt
//const Rst1Mask = 0x02 // Keyboard interrupt
//const Rst2Mask = 0x04 // Serial interface interrupt
//const Rst3Mask = 0x08 // Printer ready
//const Rst4Mask = 0x10
//const Rst5Mask = 0x20 // Power intRq
//const Rst6Mask = 0x40 // User device 1 interrupt
//const Rst7Mask = 0x80 // User device 1 interrupt
+9 -5
View File
@@ -16,7 +16,8 @@ func (c *ComputerType) IORead(port uint16) byte {
// PIO xx59, get IRR register
irr := c.pic.IRR()
// if irq from keyboard and no ACK applied, re-fire
if irr&0x10 != 0 && !c.kbAck {
if irr&RstKbdMask != 0 && !c.kbAck.Load() {
log.Tracef("KBD IRQ REFIRE PC=%04X", c.cpu.PC())
c.pic.SetIRQ(RstKbdNo)
}
return irr
@@ -30,6 +31,7 @@ func (c *ComputerType) IORead(port uint16) byte {
return c.usart.Receive()
case KbdDd78pa:
// Keyboard data
log.Tracef("KBD RD: %d, PC=%04X", c.ioPorts[KbdDd78pa], c.cpu.PC())
return c.ioPorts[KbdDd78pa]
case KbdDd78pb:
return c.ioPorts[KbdDd78pb]
@@ -117,12 +119,14 @@ func (c *ComputerType) IOWrite(port uint16, val byte) {
c.fdc.SetFloppy(val)
case KbdDd78pc:
if val&0x80 != 0 {
c.kbAck = true
if val&KbAckBit != 0 {
c.kbAck.Store(true)
log.Trace("KBD ACK")
} else {
//c.kbAck = false
if c.kbAck.Load() {
c.pic.ResetIRQ(RstKbdNo)
}
}
default:
//log.Debugf("OUT to Unknown port (%x), %x", bp, val)
}
+7 -8
View File
@@ -2,27 +2,27 @@ package okean240
import (
"fyne.io/fyne/v2"
log "github.com/sirupsen/logrus"
)
func (c *ComputerType) PutKey(key *fyne.KeyEvent) {
code := RemapCmdKey[key.Name]
if code > 0 {
//log.Debugf("PutKey keyName: %s", key.Name)
log.Tracef("PutKey keyName: %s", key.Name)
c.ioPorts[KbdDd78pa] = code
c.kbAck.Store(false)
c.pic.SetIRQ(RstKbdNo)
c.kbAck = false
}
}
func (c *ComputerType) PutRune(key rune) {
//log.Debugf("Put Rune: %c Lo: %x, Hi: %x", key, key&0xff, key>>8)
log.Tracef("Put Rune: %c Lo: %x, Hi: %x", key, key&0xff, key>>8)
c.ioPorts[KbdDd78pa] = byte(key & 0xff)
c.kbAck.Store(false)
c.pic.SetIRQ(RstKbdNo)
c.kbAck = false
}
/*
@@ -41,7 +41,6 @@ func (c *ComputerType) PutRune(key rune) {
func (c *ComputerType) PutCtrlKey(key byte) {
c.ioPorts[KbdDd78pa] = key
c.pic.SetIRQ(RstKbdNo)
c.kbAck = false
//c.ioPorts[PIC_DD75RS] |= Rst1Mask
c.kbAck.Store(false)
c.ioPorts[KbdDd78pb] &= 0x1f | 0x20
}
+33 -17
View File
@@ -1,5 +1,7 @@
package pic
import log "github.com/sirupsen/logrus"
/*
Programmable Interrupt Controller
i8058, MSM82C59, КР580ВН59
@@ -19,44 +21,58 @@ type I8259Interface interface {
SetCSW(val byte)
}
// IRR Return value of interrupt request register
func (c *I8259) IRR() byte {
irr := c.irr
// Reset the highest IR bit
if irr&0x80 != 0 {
c.irr &= 0x7F
} else if irr&0x40 != 0 {
c.irr &= 0x3F
} else if irr&0x20 != 0 {
c.irr &= 0x1F
} else if irr&0x08 != 0 {
c.irr &= 0x07
} else if irr&0x04 != 0 {
c.irr &= 0x03
if irr&0x01 != 0 {
c.irr &= 0xFE
} else if irr&0x02 != 0 {
c.irr &= 0x1
} else {
c.irr = 0
c.irr &= 0xFD
} else if irr&0x04 != 0 {
c.irr &= 0xFB
} else if irr&0x08 != 0 {
c.irr &= 0xF7
} else if irr&0x10 != 0 {
c.irr &= 0xEF
} else if irr&0x20 != 0 {
c.irr &= 0xDF
} else if irr&0x40 != 0 {
c.irr &= 0xBF
} else if irr&0x80 != 0 {
c.irr &= 0x7F
}
return irr
}
// ResetIRQ Reset interrupt request flag for specified irq
func (c *I8259) ResetIRQ(irq byte) {
c.irr &= ^(byte(1) << (irq & 0x07))
}
func (c *I8259) SetIRQ(irq byte) {
c.irr |= 1 << (irq & 0x07)
log.Tracef("RESET IRQ %d -> IRR: %08b", irq, c.irr)
}
// SetIRQ Set interrupt request flag for specified irq
func (c *I8259) SetIRQ(irq byte) {
c.irr |= 1 << (irq & 0x07)
if irq == 1 {
log.Tracef("SET IRQ %d -> IRR: %08b", irq, c.irr)
}
}
// CSW Return value of CSW register
func (c *I8259) CSW() byte {
return c.csw
}
// SetCSW Set value of CSW register
func (c *I8259) SetCSW(val byte) {
c.csw = val
}
func New() *I8259 {
// NewI8259 Create and initialize new i8259 controller
func NewI8259() *I8259 {
return &I8259{
irr: 0,
csw: 0,
}
}