-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathcardLogger.go
37 lines (31 loc) · 880 Bytes
/
cardLogger.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package izapple2
import (
"fmt"
)
/*
Logger card. It never existed, I use it to trace accesses to the card.
*/
// CardLogger is a fake card to log soft switch invocations
type CardLogger struct {
cardBase
}
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
},
}
}
func (c *CardLogger) assign(a *Apple2, slot int) {
c.addCardSoftSwitches(func(address uint8, data uint8, write bool) uint8 {
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")
c.cardBase.assign(a, slot)
}