|File Name:||Air bubble shooter|
|Submitted:||2016-08-03 07:02:40 PM by TheBiob|
|Description:||This shooter will shoot the small air bubbles you see in water levels. |
Note: The level must be a water level or the bubbles won't spawn. Sprite buoyancy isn't required though.
Requested by Final Theory
!timeMax = $80 ; How long the shooter waits maximal !timeMin = $30 ; How long the shooter waits minimal .notInRange JSL $01ACF9 ; > RNG routine LDA $148D ; Load result EOR $94 CMP #!timeMax BCS .notInRange CMP #!timeMin BCC .notInRange STA $17AB,x ; /
if !timeMin is greater than !timeMax, it cause infinite loop.
that case is responsible to an user. but should be fix it.
also, this code order is depend on range of available random values.
for example, in default case is $30~$7F (max value will be excluded).
therefore, probability of getting a available value is ($7F-$30)/$0100 ≈ 0.31
it isn't efficient, so I think should be get a value at once.
.notInRange JSL $01ACF9 ; > RNG routine, usually A has random value at after call. EOR $94 LDY.b #!timeMax-!timeMin BEQ .ValueOne ; timeMax-timeMin == $00 -> enable one value, then will be used !timeMin. INY ;\ timeMax-timeMin == $FF -> enable all values, then will be used a random value. BEQ .ValueAll ;/ STA $4204 ;\ STZ $4205 ; | STY $4206 ; | calculate RAG%(Max-Min+1)+Min, it answer is between from Min to Max. NOP #6 ; | LDA.b #!timeMin ; | CLC ; | ADC $4216 ;/ BRA .ValueAll ; .ValueOne LDA.b #!timeMin ; .ValueAll STA $17AB,x ;
please fix this issue, and it will be approved.
EDIT : Please don't use this formula. because it will be biassed to low values when range is bigger!
Please use here instead.