Improve the option to panic on undefined softswitches

This commit is contained in:
Iván Izaguirre 2024-03-09 20:09:12 +01:00
parent 30e3a7503d
commit cb355a17cd
5 changed files with 41 additions and 24 deletions

View File

@ -257,7 +257,7 @@ The available tracers are:
mli: Trace ProDOS MLI calls mli: Trace ProDOS MLI calls
mos: Trace MOS calls with Applecorn skipping terminal IO mos: Trace MOS calls with Applecorn skipping terminal IO
mosfull: Trace MOS calls with Applecorn mosfull: Trace MOS calls with Applecorn
panicSS: Panic on unimplemented softswitches panicss: Panic on unimplemented softswitches
ss: Trace sotfswiches calls ss: Trace sotfswiches calls
ssreg: Trace sotfswiches registrations ssreg: Trace sotfswiches registrations
ucsd: Trace UCSD system calls ucsd: Trace UCSD system calls

View File

@ -28,6 +28,7 @@ const noCardName = "empty"
var commonParams = []paramSpec{ var commonParams = []paramSpec{
{"trace", "Enable debug messages", "false"}, {"trace", "Enable debug messages", "false"},
{"tracess", "Trace softswitches", "false"}, {"tracess", "Trace softswitches", "false"},
{"panicss", "Panic on unimplemented softswitches", "false"},
} }
var cardFactory map[string]*cardBuilder var cardFactory map[string]*cardBuilder
@ -118,11 +119,14 @@ func setupCard(a *Apple2, slot int, paramString string) (Card, error) {
} }
// Common parameters // Common parameters
traceSS := paramsGetBool(finalParams, "tracess") if paramsGetBool(finalParams, "tracess") {
if traceSS {
a.io.traceSlot(slot) a.io.traceSlot(slot)
} }
if paramsGetBool(finalParams, "panicss") {
a.io.panicNotImplementedSlot(slot)
}
debug := paramsGetBool(finalParams, "trace") debug := paramsGetBool(finalParams, "trace")
card.setName(builder.name) card.setName(builder.name)

View File

@ -82,7 +82,7 @@ The available tracers are:
mli: Trace ProDOS MLI calls mli: Trace ProDOS MLI calls
mos: Trace MOS calls with Applecorn skipping terminal IO mos: Trace MOS calls with Applecorn skipping terminal IO
mosfull: Trace MOS calls with Applecorn mosfull: Trace MOS calls with Applecorn
panicSS: Panic on unimplemented softswitches panicss: Panic on unimplemented softswitches
ss: Trace sotfswiches calls ss: Trace sotfswiches calls
ssreg: Trace sotfswiches registrations ssreg: Trace sotfswiches registrations
ucsd: Trace UCSD system calls ucsd: Trace UCSD system calls

View File

@ -5,20 +5,20 @@ import (
) )
type ioC0Page struct { type ioC0Page struct {
softSwitchesR [256]softSwitchR softSwitchesR [256]softSwitchR
softSwitchesW [256]softSwitchW softSwitchesW [256]softSwitchW
softSwitchesRName [256]string softSwitchesRName [256]string
softSwitchesWName [256]string softSwitchesWName [256]string
softSwitchesData [128]uint8 softSwitchesData [128]uint8
keyboard KeyboardProvider keyboard KeyboardProvider
speaker SpeakerProvider speaker SpeakerProvider
paddlesStrobeCycle uint64 paddlesStrobeCycle uint64
joysticks JoysticksProvider joysticks JoysticksProvider
mouse MouseProvider mouse MouseProvider
apple2 *Apple2 apple2 *Apple2
traceMask uint16 // A bit for each 16 softswitches traceMask uint16 // A bit for each 16 softswitches
traceRegistrations bool panicMask uint16 // A bit for each 16 softswitches
panicNotImplemented bool traceRegistrations bool
} }
type softSwitchR func() uint8 type softSwitchR func() uint8
@ -65,7 +65,10 @@ func (p *ioC0Page) setTrace(trace bool) {
func (p *ioC0Page) traceSlot(slot int) { func (p *ioC0Page) traceSlot(slot int) {
p.traceMask |= 1 << (8 + slot) p.traceMask |= 1 << (8 + slot)
fmt.Printf("Slot %v traced %04x\n", slot, p.traceMask) }
func (p *ioC0Page) panicNotImplementedSlot(slot int) {
p.panicMask |= 1 << (8 + slot)
} }
func (p *ioC0Page) setTraceRegistrations(traceRegistrations bool) { func (p *ioC0Page) setTraceRegistrations(traceRegistrations bool) {
@ -73,7 +76,11 @@ func (p *ioC0Page) setTraceRegistrations(traceRegistrations bool) {
} }
func (p *ioC0Page) setPanicNotImplemented(value bool) { func (p *ioC0Page) setPanicNotImplemented(value bool) {
p.panicNotImplemented = value if value {
p.panicMask = 0xffff
} else {
p.panicMask = 0x0000
}
} }
func (p *ioC0Page) addSoftSwitchRW(address uint8, ss softSwitchR, name string) { func (p *ioC0Page) addSoftSwitchRW(address uint8, ss softSwitchR, name string) {
@ -125,6 +132,12 @@ func (p *ioC0Page) isTraced(address uint16) bool {
(p.traceMask&(1<<(ss>>4))) != 0 (p.traceMask&(1<<(ss>>4))) != 0
} }
func (p *ioC0Page) isPanicNotImplemented(address uint16) bool {
ss := address & 0xff
return ss != 0xc068 && // Ignore known IIGS softswitch
(p.panicMask&(1<<(ss>>4))) != 0
}
func (p *ioC0Page) peek(address uint16) uint8 { func (p *ioC0Page) peek(address uint16) uint8 {
pageAddress := uint8(address) pageAddress := uint8(address)
ss := p.softSwitchesR[pageAddress] ss := p.softSwitchesR[pageAddress]
@ -132,7 +145,7 @@ func (p *ioC0Page) peek(address uint16) uint8 {
if p.isTraced(address) { if p.isTraced(address) {
fmt.Printf("Unknown softswitch on read to $%04x\n", address) fmt.Printf("Unknown softswitch on read to $%04x\n", address)
} }
if p.panicNotImplemented { if p.isPanicNotImplemented(address) {
panic(fmt.Sprintf("Unknown softswitch on read to $%04x", address)) panic(fmt.Sprintf("Unknown softswitch on read to $%04x", address))
} }
return 0 return 0
@ -152,7 +165,7 @@ func (p *ioC0Page) poke(address uint16, value uint8) {
if p.isTraced(address) { if p.isTraced(address) {
fmt.Printf("Unknown softswitch on write $%02x to $%04x\n", value, address) fmt.Printf("Unknown softswitch on write $%02x to $%04x\n", value, address)
} }
if p.panicNotImplemented { if p.isPanicNotImplemented(address) {
panic(fmt.Sprintf("Unknown softswitch on write to $%04x", address)) panic(fmt.Sprintf("Unknown softswitch on write to $%04x", address))
} }
return return

View File

@ -64,8 +64,8 @@ func getTracerFactory() map[string]*traceBuilder {
description: "Trace sotfswiches registrations", description: "Trace sotfswiches registrations",
connectFunc: func(a *Apple2) { a.io.setTraceRegistrations(true) }, connectFunc: func(a *Apple2) { a.io.setTraceRegistrations(true) },
} }
tracerFactory["panicSS"] = &traceBuilder{ tracerFactory["panicss"] = &traceBuilder{
name: "panicSS", name: "panicss",
description: "Panic on unimplemented softswitches", description: "Panic on unimplemented softswitches",
connectFunc: func(a *Apple2) { a.io.setPanicNotImplemented(true) }, connectFunc: func(a *Apple2) { a.io.setPanicNotImplemented(true) },
} }