Prev: EF22 Up: Map Next: F0FE
F0C6: White noise generator?
Used by the routine at define_keys.
noise F0C6 LD E,A E = A Outer-outer counter
noise_outer_loop F0C7 LD D,$32 D = 50 Outer counter
noise_loop F0C9 LD HL,$9618 Point at rng_seed / state bytes
F0CC INC (HL) rng_seed[0] += 3 Increment first byte of seed by 3
F0CD INC (HL)
F0CE INC (HL)
F0CF LD B,(HL) Load it into B
F0D0 INC HL HL++
F0D1 LD A,(HL) rng_seed[1] -= 141 Note that this is different order to rng/$961B
F0D2 SUB $8D
F0D4 LD (HL),A
F0D5 ADD A,B A = rng_seed[0] + rng_seed[1]
F0D6 INC HL HL++
F0D7 RLCA Rotate A by 1
F0D8 RRC (HL) Rotate rng_seed[2] by 1
F0DA ADD A,(HL) A += *HL
F0DB LD (HL),A *HL = A
F0DC AND $10 A &= 16
F0DE JR Z,noise_2 Jump to noise_2 if zero
F0E0 LD A,$18 B = 24 - E
F0E2 SUB E
F0E3 LD B,A
noise_0 F0E4 DJNZ noise_0 Delay loop
F0E6 LD A,$18 A = 24 EAR + MIC ?
F0E8 OUT ($FE),A Output
F0EA LD B,E B = E
noise_1 F0EB DJNZ noise_1 Delay loop
F0ED XOR A A = 0
F0EE OUT ($FE),A Output
noise_2 F0F0 DEC D Decrement outer counter
F0F1 JR NZ,noise_loop Jump to noise_loop if non-zero
F0F3 LD A,($EF14) Read A from 'LD A' @ dk_wait -- spinlock/wait
F0F6 AND A Set flags
F0F7 RET C Return if carry set
F0F8 DEC E Decrement outer-outer counter
F0F9 JR NZ,noise_outer_loop Jump to noise_outer_loop if non-zero
F0FB JP dk_wait Jump to dk_wait
Prev: EF22 Up: Map Next: F0FE