izapple2/cardLogger.go

38 lines
880 B
Go
Raw Permalink Normal View History

2020-10-03 21:38:26 +00:00
package izapple2
2019-05-18 21:40:59 +00:00
import (
"fmt"
)
/*
Logger card. It never existed, I use it to trace accesses to the card.
*/
2020-10-14 19:54:51 +00:00
// CardLogger is a fake card to log soft switch invocations
type CardLogger struct {
2019-05-18 21:40:59 +00:00
cardBase
}
2024-01-06 20:48:23 +00:00
func newCardLoggerBuilder() *cardBuilder {
return &cardBuilder{
name: "Softswitch logger card",
description: "Card to log softswitch accesses",
buildFunc: func(params map[string]string) (Card, error) {
return &CardLogger{}, nil
},
}
2020-10-14 19:54:51 +00:00
}
func (c *CardLogger) assign(a *Apple2, slot int) {
2022-08-05 17:43:17 +00:00
c.addCardSoftSwitches(func(address uint8, data uint8, write bool) uint8 {
2021-05-09 17:48:54 +00:00
if write {
fmt.Printf("[cardLogger] Write access to softswith 0x%x for slot %v, value 0x%02x.\n", address, slot, data)
} else {
fmt.Printf("[cardLogger] Read access to softswith 0x%x for slot %v.\n", address, slot)
}
return 0
}, "LOGGER")
2019-05-18 21:40:59 +00:00
c.cardBase.assign(a, slot)
}