2018-05-09 18:31:15 +00:00
|
|
|
package system
|
|
|
|
|
2018-05-14 09:33:49 +00:00
|
|
|
const (
|
2018-05-14 17:51:50 +00:00
|
|
|
CpuFrequency = 1023000
|
2018-05-14 09:33:49 +00:00
|
|
|
AudioSampleRate = 44100
|
|
|
|
)
|
2018-05-09 18:31:15 +00:00
|
|
|
|
2018-05-14 09:33:49 +00:00
|
|
|
var (
|
|
|
|
PendingInterrupt bool
|
|
|
|
PendingNMI bool
|
|
|
|
RunningTests bool
|
|
|
|
RunningFunctionalTests bool
|
|
|
|
RunningInterruptTests bool
|
|
|
|
Cycles uint64
|
|
|
|
FrameCycles uint64
|
2018-05-14 21:44:44 +00:00
|
|
|
AudioChannel chan int16
|
|
|
|
LastAudioValue int16
|
2018-05-14 09:33:49 +00:00
|
|
|
LastAudioCycles uint64
|
|
|
|
AudioAttenuationCounter uint64
|
2018-05-09 18:31:15 +00:00
|
|
|
)
|
|
|
|
|
2018-05-14 09:33:49 +00:00
|
|
|
func Init() {
|
|
|
|
Cycles = 0
|
2018-05-14 21:44:44 +00:00
|
|
|
AudioChannel = make(chan int16, AudioSampleRate*4) // 1 second
|
2018-05-14 09:33:49 +00:00
|
|
|
LastAudioValue = 0x2000
|
|
|
|
}
|
|
|
|
|
2018-05-09 18:31:15 +00:00
|
|
|
// Handle a write to a magic test address that triggers an interrupt and/or an NMI
|
|
|
|
func WriteInterruptTestOpenCollector(address uint16, oldValue uint8, value uint8) {
|
|
|
|
oldInterrupt := (oldValue & 0x1) == 0x1
|
|
|
|
oldNMI := (oldValue & 0x2) == 0x2
|
|
|
|
|
|
|
|
interrupt := (value & 0x1) == 0x1
|
|
|
|
NMI := (value & 0x2) == 0x2
|
|
|
|
|
|
|
|
if oldInterrupt != interrupt {
|
|
|
|
PendingInterrupt = interrupt
|
|
|
|
}
|
|
|
|
|
|
|
|
if oldNMI != NMI {
|
|
|
|
PendingNMI = NMI
|
|
|
|
}
|
|
|
|
}
|