Skip to content
This repository has been archived by the owner on Oct 16, 2021. It is now read-only.

NSF Driver: Sunsoft 5B

nyanpasu64 edited this page Jun 9, 2018 · 2 revisions

yep this page is quite disorganized

driver.s

APU_OFFSET  = 0
MMC5_OFFSET = CH_COUNT_2A03 + APU_OFFSET
...
S5B_OFFSET  = CH_COUNT_FDS  + FDS_OFFSET

Idea:

S5B_OFFSET  = FDS_OFFSET + CH_COUNT_FDS

5B noise (duty cycles)

var_ch_DutyDefault[] is a NCHAN-byte array.

var_ch_DutyCurrent[] is a NCHAN-byte array.

  • written by apu@DoneVolume[Square, Noise] once per frame.

5B instrument:

Envelope pointers: (instrument.s)

release var_ch_SeqVolume, var_ch_SequencePtr1
release var_ch_SeqArpeggio, var_ch_SequencePtr2
release var_ch_SeqPitch, var_ch_SequencePtr3
release var_ch_SeqHiPitch, var_ch_SequencePtr4
release var_ch_SeqDutyCycle, var_ch_SequencePtr5

Arpeggio:

a = var_ch_SequencePtr2[x]
if a == #$FF goto @RestoreArpeggio

var_sequence_result comes from?

a = var_sequence_result
a -> var_ch_DutyCurrent[x]

instrument@DoneConvert is called by X, which happens if the duty envelope is incomplete???.

var_ch_DutyCurrent[] is negative ($80) if noise is active.

  • @UpdateNoise: if note trigger:
    • a = var_ch_DutyCurrent[S5B+x]
    • if a > 0:
      • continue
    • var_Noise_Period = a & $1f
  • if ++x < 5B: loop

5B noise bugfix (s5b.s @UpdateNoise)

a = var_ch_SequencePtr5[S5B_OFFSET + x]
if a == #$FF goto :+

lda var_ch_SequencePtr5 + S5B_OFFSET, x
cmp #$FF
beq :+