The first function call in the main loop of the collision detection code goes to a function that handles sprites that were hit by the player's magic shortly before the current sprite update. The code of that function is located between the offsets $8151 and $81A6.
The first sprite array that's accessed right in the first line should be familiar. It's already been used in the main loop to determine if the function at $8151 should be called or not. It contains the ID of the magic the sprite was hit by. As only three (Deluge, Thunder, Fire) of the five different kinds of magic throw the enemy back only these three types need to be handled in this function.
CODE:
<br />$8151-> BC 34 3: LDY $334,X ; Magic type
<br />$8154-> F0 C: BEQ $8162 ; Magic = Deluge
<br />$8156-> 88: DEY
<br />$8157-> F0 21: BEQ $817A ; Magic = Thunder
<br />$8159-> 88: DEY
<br />$815A-> F0 36: BEQ $8192 ; Magic = Fire
<br />$815C-> A9 FF: LDA #$FF
<br />$815E-> 9D 34 3: STA $334,X ; Reset magic type
<br />$8161-> 60: RTS
<br />
Afterwards the three relevant kinds of magic are handled. Deluge comes first (Magic ID: 0), then comes Thunder (Magic ID: 1) and at the end the code for the Fire magic (Magic ID: 2) follows. Deluge pushes the enemy back by 3 pixels, Thunder by 2 and Fire pushes the enemy back as far as possible (until a wall comes or the edge of a screen was reached).
The array between $33C and $343 contains other information that is relevant for moving the enemy. The bytes there contain a counter that's initialized with a certain value when a sprite is hit by magic and decreases by one every time the $8151 function is called. Practically speaking it's a counter for how often this function should be called (at least for Deluge and Thunder). That means that Deluge actually moves the enemy by Counter times 3 pixels and Thunder moves the enemy by Counter times 2 pixels.
Here's the Deluge code ...
CODE:
<br />$8162-> A9 3: LDA #$3 ; Moves sprite by 3 pixels
<br />$8164-> 8D 75 3: STA $375
<br />$8167-> A9 0: LDA #$0
<br />$8169-> 8D 74 3: STA $374
<br />$816C-> 20 94 84: JSR $8494 ; Move sprite
<br />$816F-> DE 3C 3: DEC $33C,X ; Decrease timer
<br />$8172-> D0 5: BNE $8179 ; Timer not yet expired
<br />$8174-> A9 FF: LDA #$FF
<br />$8176-> 9D 34 3: STA $334,X ; Reset magic type
<br />$8179-> 60: RTS
<br />
... the Thunder code ...
CODE:
<br />$817A-> A9 2: LDA #$2 ; Moves sprite by 2 pixels
<br />$817C-> 8D 75 3: STA $375
<br />$817F-> A9 0: LDA #$0
<br />$8181-> 8D 74 3: STA $374
<br />$8184-> 20 94 84: JSR $8494 ; Move sprite
<br />$8187-> DE 3C 3: DEC $33C,X
<br />$818A-> D0 5: BNE $8191 ; Timer not yet expired
<br />$818C-> A9 FF: LDA #$FF
<br />$818E-> 9D 34 3: STA $334,X ; Reset magic type
<br />$8191-> 60: RTS
<br />
... and the Fire code.
CODE:
<br />$8192-> A9 4: LDA #$4 ; Moves sprite by 4 pixels
<br />$8194-> 8D 75 3: STA $375
<br />$8197-> A9 0: LDA #$0
<br />$8199-> 8D 74 3: STA $374
<br />$819C-> 20 94 84: JSR $8494 ; Move sprite
<br />$819F-> 90 5: BCC $81A6 ; Not yet hit something
<br />$81A1-> A9 FF: LDA #$FF
<br />$81A3-> 9D 34 3: STA $334,X ; Reset magic type
<br />$81A6-> 60: RTS
<br />