Prev: 32055 Up: Map Next: 32112
32059: Update cycler values
This updates the values used to add randomness to the spacehsip appearance timing and the way the barriers are nibbled away by the alien's bullets, etc. It's not random as such, more a churn of numbers to break up patterns.
The algorithm hasn't been properly analysed.
Used by the routines at generate_alien_bullets and bullet_barrier_hit.
update_cycler_values 32059 LD HL,(_CYCLER_3) Cycler value into HL
32062 RL L
32064 RL H x2
32066 RL L
32068 RL H x4
32070 LD C,H That goes into C
32071 LD A,(_CYCLER_1) Cycler value into A
32074 RLA x2
32075 LD B,A That goes into B
32076 LD DE,(_CYCLER_2) Amalgamation of cycler values
32080 RL E
32082 RL D x2
32084 RES 7,D Limit to 32767
32086 LD HL,(_CYCLER_1) Add the value worked out into BC into this cycler value
32089 ADD HL,BC
32090 LD (_CYCLER_1),HL
32093 LD HL,(_CYCLER_3) Add the value worked out into DE into this cycling value limited to 32767
32096 ADC HL,DE
32098 RES 7,H
32100 LD (_CYCLER_3),HL
32103 RET P
32104 LD HL,_CYCLER_1 Don't let this cycling value settle at zero
update_cycler_values_0 32107 INC HL
32108 RET NZ
32109 INC HL
32110 JR update_cycler_values_0
Prev: 32055 Up: Map Next: 32112