MCPcopy Create free account
hub / github.com/fogleman/nes / writeControl

Method writeControl

nes/apu.go:284–309  ·  view source on GitHub ↗
(value byte)

Source from the content-addressed store, hash-verified

282}
283
284func (apu *APU) writeControl(value byte) {
285 apu.pulse1.enabled = value&1 == 1
286 apu.pulse2.enabled = value&2 == 2
287 apu.triangle.enabled = value&4 == 4
288 apu.noise.enabled = value&8 == 8
289 apu.dmc.enabled = value&16 == 16
290 if !apu.pulse1.enabled {
291 apu.pulse1.lengthValue = 0
292 }
293 if !apu.pulse2.enabled {
294 apu.pulse2.lengthValue = 0
295 }
296 if !apu.triangle.enabled {
297 apu.triangle.lengthValue = 0
298 }
299 if !apu.noise.enabled {
300 apu.noise.lengthValue = 0
301 }
302 if !apu.dmc.enabled {
303 apu.dmc.currentLength = 0
304 } else {
305 if apu.dmc.currentLength == 0 {
306 apu.dmc.restart()
307 }
308 }
309}
310
311func (apu *APU) writeFrameCounter(value byte) {
312 apu.framePeriod = 4 + (value>>7)&1

Callers 1

writeRegisterMethod · 0.95

Calls 1

restartMethod · 0.80

Tested by

no test coverage detected