Move microPD1990ac.go

This commit is contained in:
Ivan Izaguirre 2021-03-19 17:15:00 +01:00
parent f9ba9256b5
commit 8e1bbdef0e
2 changed files with 11 additions and 9 deletions

View File

@ -1,5 +1,7 @@
package izapple2
import "github.com/ivanizag/izapple2/component"
/*
ThunderClock`, real time clock card.
@ -22,7 +24,8 @@ uPD1990AC hookup:
// CardThunderClockPlus represents a ThunderClock+ card
type CardThunderClockPlus struct {
cardBase
microPD1990ac
upd1990 component.MicroPD1990ac
//component.microPD1990ac
}
// NewCardThunderClockPlus creates a new CardThunderClockPlus
@ -35,7 +38,7 @@ func NewCardThunderClockPlus() *CardThunderClockPlus {
func (c *CardThunderClockPlus) assign(a *Apple2, slot int) {
c.addCardSoftSwitchR(0, func(*ioC0Page) uint8 {
bit := c.microPD1990ac.out()
bit := c.upd1990.Out()
// Get the next data bit from uPD1990AC on the MSB
if bit {
return 0x80
@ -51,7 +54,7 @@ func (c *CardThunderClockPlus) assign(a *Apple2, slot int) {
/* fmt.Printf("[cardThunderClock] dataIn %v, clock %v, strobe %v, command %v.\n",
dataIn, clock, strobe, command) */
c.microPD1990ac.in(clock, strobe, command, dataIn)
c.upd1990.In(clock, strobe, command, dataIn)
}, "THUNDERCLOCKW")
c.cardBase.assign(a, slot)

View File

@ -1,4 +1,4 @@
package izapple2
package component
import (
"time"
@ -21,8 +21,7 @@ import (
byte 0: seconds, BCD 0 to 59
*/
type microPD1990ac struct {
type MicroPD1990ac struct {
clock bool // CLK state
strobe bool // STB state
command uint8 // C0, C1, C2 command. From 0 to 7
@ -36,7 +35,7 @@ const (
mpd1990commandTimeRead = 3
)
func (m *microPD1990ac) in(clock bool, strobe bool, command uint8, dataIn bool) {
func (m *MicroPD1990ac) In(clock bool, strobe bool, command uint8, dataIn bool) {
// Detect signal raise
clockRaise := clock && !m.clock
strobeRaise := strobe && !m.strobe
@ -69,7 +68,7 @@ func (m *microPD1990ac) in(clock bool, strobe bool, command uint8, dataIn bool)
}
}
func (m *microPD1990ac) out() bool {
func (m *MicroPD1990ac) Out() bool {
if m.command == mpd1990commandRegHold {
//panic("Output on RegHold should be a 1Hz signal. Not implemented.")
}
@ -82,7 +81,7 @@ func (m *microPD1990ac) out() bool {
return (m.register & 1) == 1
}
func (m *microPD1990ac) loadTime() {
func (m *MicroPD1990ac) loadTime() {
now := time.Now()
var register uint64