Prev: B5D4 Up: Map Next: B9BE
B68B: Draw projectiles
Draw Enemy projectiles. Used by the routine at 9470.
B68B LD IX,$5D22 Set IX to the base address for enemy projectile configuration
B68F LD B,$14 Set B to the max number of enemy projectiles on screen
B691 JP $B69A Jump forward to read projectile data and draw
Draw Rex projectiles. Used by the routine at 9470.
B694 LD IX,$5B60 Set IX to the base addres for enemy projectile configuration
B698 LD B,$1E Set B to the max number of Rex projectiles
This entry point is used by the routine at B68B.
B69A LD A,(IX+$06) Set A the projectile status
B69D OR A is destroyed?
B69E JP Z,$B732 Jump if so
B6A1 CP $02 just hit?
B6A3 JP Z,$B839 Jump if so
B6A6 CP $03 exploding?
B6A8 JP Z,$B854 Jump is so The projectile is flying
B6AB LD L,(IX+$02) Set HL to the addres location in room graphic buffer
B6AE LD H,(IX+$03)
B6B1 LD A,(IX+$0B) Set REG#a the projectile type
B6B4 AND $7F
B6B6 OR A is a basic laser?
B6B7 JP Z,$B90E draw basic laser sprite
B6BA CP $01 is a basic laser?
B6BC JP Z,$B90E draw basic laser sprite
B6BF CP $04 is a spray?
B6C1 JP Z,$B8E2 draw spray sprite
B6C4 CP $02 is a laser?
B6C6 JP Z,$B937 draw laser sprite $02
B6C9 CP $03 is a multiple?
B6CB JP Z,$B90E draw basic laser sprite
B6CE CP $06 is a laser?
B6D0 JP Z,$B99B draw laser sprite $06
B6D3 CP $07 is a seed plant?
B6D5 JP Z,$B878 draw seed plant
This entry point is used by the routines at B878, B8E2, B90E, B937 and B99B.
B6D8 LD A,(IX+$00) Set A the projectile x-position
B6DB ADC A,(IX+$04) Adds the projectile x-speed
B6DE LD (IX+$00),A Set the new x-position
B6E1 LD ($A248),A Save the x-position at A248
B6E4 CP $F8 Projectile left room from the right?
B6E6 JP NC,$B73C Jump if so
B6E9 CP $09 Projectile left room from the left?
B6EB JP C,$B73C Jump if so
B6EE LD A,(IX+$01) Set A the projectile y-position
B6F1 ADC A,(IX+$05) Add the projectile y-speed
B6F4 LD (IX+$01),A Save the new y-position
B6F7 LD ($A249),A Save the y-position at A249
B6FA CP $C0 Projectile left room from the bottom?
B6FC JP NC,$B73C Jump if so
B6FF CP $18 Projectil left the room from the top?
B701 JP C,$B73C Jump if so
B704 LD A,$01 Computes address into the tile type buffer based on the computed position of the projectile
B706 CALL $A6AB
B709 LD A,(HL) Set A to the tile type impacted by the projectile
B70A CP $04 Is the FINAL BOSS tile?
B70C JP Z,$B743 Jump forward to handle FINAL BOSS kill
B70F CALL $CE17 Check if A is a 'background' type tile
B712 JP NZ,$B810 Jump if is not a background tile
the projectile continue flying
B715 LD A,(IX+$0B) the projectile is a seed plant?
B718 AND $7F
B71A CP $07
B71C JP Z,$B732 Jump and check the next projectile if so
B71F LD L,(IX+$02) Computes into HL the addres pointer into room graphics buffer for the new position of projectile
B722 LD H,(IX+$03)
B725 LD E,(IX+$07)
B728 LD D,(IX+$08)
B72B ADD HL,DE
B72C LD (IX+$02),L Set into projectile configuration buffer the new address
B72F LD (IX+$03),H
This projectile has been handled, go the next one. This entry point is used by the routines at B810, B839 and B854.
B732 LD DE,$000F Set DE to the length of projectile configuration buffer
B735 ADD IX,DE Adds to the previous base address into IX
B737 DEC B Decrement B
B738 JP NZ,$B69A Jump back if there are projectiles to handle
B73B RET
the projectile has been destroyed
B73C LD (IX+$06),$00 Set the projectile status to destroyed
B740 JP $B732 Jump back and check for the next one
FINAL BOSS kill
B743 LD A,($A268) Jump forward if FINAL BOSS alredy killed
B746 OR A
B747 JP NZ,$B77E
B74A LD A,$C8 Set the number of explosions (200)
B74C LD ($A269),A
B74F LD HL,$9CF9 Set the address into table offset for compute explosions location
B752 LD ($A26A),HL
B755 LD A,$01 Set FINAL BOSS dead
B757 LD ($A268),A
B75A LD HL,$E55F Point HL to the attribute buffer for room
B75D PUSH BC Save BC
B75E LD BC,$02A0 Set BC to the number of tiles on room (672)
B761 LD A,(HL) If attribute color is $03, $43 or $06 then hide tile. Hide FINAL BOSS
B762 CP $03
B764 JP Z,$B774
B767 CP $43
B769 JP Z,$B774
B76C CP $06
B76E JP Z,$B774
B771 JP $B776
B774 LD (HL),$00
B776 INC HL Increase address into attribute buffer
B777 DEC BC Decrease tile counter
B778 LD A,B Jump back until all the tiles checked
B779 OR C
B77A JP NZ,$B761
B77D POP BC Restore BC
B77E JP $B715 Jump back and continue processing projectile
Remnant code for destructible tiles. Noy used in Rex (Side B)
B781 POP HL
B782 POP AF
B783 BIT 7,(IX+$0B)
B787 JP NZ,$B715
B78A LD ($A22C),A
B78D INC A
B78E LD (HL),A
B78F LD DE,$E19F
B792 AND A
B793 SBC HL,DE
B795 PUSH HL
B796 LD DE,$DE9F
B799 ADD HL,DE
B79A LD A,(HL)
B79B DEC A
B79C LD L,A
B79D LD H,$00
B79F ADD HL,HL
B7A0 ADD HL,HL
B7A1 LD DE,$D962
B7A4 ADD HL,DE
B7A5 LD ($A22E),HL
B7A8 INC HL
B7A9 INC HL
B7AA LD E,(HL)
B7AB INC HL
B7AC LD D,(HL)
B7AD PUSH HL
B7AE LD HL,$0008
B7B1 ADD HL,DE
B7B2 EX DE,HL
B7B3 POP HL
B7B4 DEC HL
B7B5 LD (HL),E
B7B6 INC HL
B7B7 LD (HL),D
B7B8 EX DE,HL
B7B9 LD DE,$6606
B7BC AND A
B7BD SBC HL,DE
B7BF SRL H
B7C1 RR L
B7C3 SRL H
B7C5 RR L
B7C7 SRL H
B7C9 RR L
B7CB LD DE,$6E06
B7CE ADD HL,DE
B7CF LD A,(HL)
B7D0 LD ($A230),A
B7D3 LD A,($A22C)
B7D6 CP $06
B7D8 JP NZ,$B7E0
B7DB LD A,$47
B7DD LD ($A230),A
B7E0 POP HL
B7E1 PUSH HL
B7E2 LD DE,$5800
B7E5 ADD HL,DE
B7E6 LD A,($A230)
B7E9 LD (HL),A
B7EA POP HL
B7EB PUSH HL
B7EC LD DE,$E4FF
B7EF ADD HL,DE
B7F0 LD A,($A230)
B7F3 LD (HL),A
B7F4 POP HL
B7F5 LD A,($A22C)
B7F8 CP $04
B7FA JP Z,$B810
B7FD CP $05
B7FF JP Z,$B810
B802 LD DE,$E19F
B805 ADD HL,DE
B806 LD (HL),$00
B808 LD DE,($A22E)
B80C XOR A
B80D LD (DE),A
B80E INC DE
B80F LD (DE),A
the projectile has just impacted 1
B810 LD L,(IX+$02) Draw impact 1 projectile
B813 LD H,(IX+$03)
B816 LD (HL),$10
B818 LD (IX+$06),$00 Set state of projectile to destroyed
B81C LD A,($A1AC) Check if weapon used is $02
B81F CP $02
B821 JP Z,$B732 Jump to handle the next projectile
B824 LD (IX+$06),$02 Set impact 1 state for projectile
B828 LD A,($D5DA) Sound channel 3 is in use?
B82B CP $FF
B82D JP NZ,$B732 Jump to the next projectile if in use
B830 LD DE,$D51F Set DE to impact sound data
B833 CALL $D37F Configure sound channel and mixer register
B836 JP $B732 Jump back to handle next projectile
the projectile has just impacted 2
B839 LD L,(IX+$02) Draw impact 2 projectile
B83C LD H,(IX+$03)
B83F LD DE,$0020
B842 AND A
B843 SBC HL,DE
B845 LD (HL),$10
B847 ADD HL,DE
B848 LD (HL),$38
B84A ADD HL,DE
B84B LD (HL),$10
B84D LD (IX+$06),$03 Set projectile status to impact 2
B851 JP $B732 Jump back to handle next projectile
the projectile is exploding
B854 LD L,(IX+$02) Draw projectile exploding
B857 LD H,(IX+$03)
B85A LD DE,$0040
B85D AND A
B85E SBC HL,DE
B860 LD DE,$0020
B863 LD (HL),$10
B865 ADD HL,DE
B866 LD (HL),$00
B868 ADD HL,DE
B869 LD (HL),$44
B86B ADD HL,DE
B86C LD (HL),$00
B86E ADD HL,DE
B86F LD (HL),$10
B871 LD (IX+$06),$00 Set projectile status to destroyed
B875 JP $B732 Jump back to handle next projectile
Draw seed plant projectile
B878 LD L,(IX+$01) Computes address into room graphic buffer based on x and y position of projectile
B87B LD H,$00
B87D ADD HL,HL
B87E ADD HL,HL
B87F ADD HL,HL
B880 ADD HL,HL
B881 ADD HL,HL
B882 LD E,(IX+$00)
B885 SRL E
B887 SRL E
B889 SRL E
B88B LD D,$00
B88D ADD HL,DE
B88E LD DE,$E7FF
B891 ADD HL,DE
B892 LD (IX+$02),L Puts this address into the projectile configuration buffer
B895 LD (IX+$03),H
B898 PUSH HL Save HL
B899 LD A,(IX+$0E) Set A to the seed trajectory index into table of trajectory addresses
B89C LD E,A Computes the address of the trajectory based on the index
B89D LD D,$00
B89F LD HL,$AA47
B8A2 ADD HL,DE
B8A3 LD ($A22C),HL Save into A22C this address pointer
B8A6 LD E,(HL) Set into HL the initial address for the trajectory
B8A7 INC HL
B8A8 LD D,(HL)
B8A9 EX DE,HL
B8AA LD E,(IX+$0C) Add to the address the index of the trajectory
B8AD LD D,$00
B8AF ADD HL,DE
B8B0 LD A,(HL) Set A the y-offset value of the trajectory
B8B1 CP $1E is an end marker?
B8B3 JP NZ,$B8C4 Jump if not
end of defined trajectory
B8B6 DEC (IX+$0C) Decrement trajectory index
B8B9 LD HL,($A22C) Point HL to the end address of the trajectory so for the next loop trajectory will continue with the value set on the next instruction for y-delta
B8BC INC HL
B8BD INC HL
B8BE LD E,(HL)
B8BF INC HL
B8C0 LD D,(HL)
B8C1 EX DE,HL
B8C2 LD A,$08 Set y-delta for the projectile to 8
continue trajectory
B8C4 LD (IX+$05),A Set the previously obtained y-delta
B8C7 INC HL Increase address into trajectory
B8C8 LD E,(HL) Does nothing
B8C9 LD DE,$AA43 Set DE the base address for graphic data of seed plant projectile
B8CC POP HL Restore HL
B8CD PUSH BC Save BC
B8CE LD B,$04 Draw into room graphic buffer the graphic data for the projectile
B8D0 LD A,(DE)
B8D1 LD (HL),A
B8D2 INC DE
B8D3 PUSH DE
B8D4 LD DE,$0020
B8D7 ADD HL,DE
B8D8 POP DE
B8D9 DJNZ $B8D0
B8DB POP BC Restore BC
B8DC INC (IX+$0C) Increment index into table of y-offsets trajectory
B8DF JP $B6D8 Jump to finish projectile configuration
Used by the routine at B694.
B8E2 LD DE,$0040 Computes offset position to draw
B8E5 AND A
B8E6 SBC HL,DE
B8E8 LD DE,$0020
B8EB BIT 7,(IX+$0B) Check subtype of spray bullet
B8EF JP NZ,$B900 Jump if subtype is 1
draw spray bullet 0
B8F2 LD (HL),$10 Draw spray bullet 0
B8F4 ADD HL,DE
B8F5 LD (HL),$1C
B8F7 ADD HL,DE
B8F8 LD (HL),$38
B8FA ADD HL,DE
B8FB LD (HL),$08
B8FD JP $B6D8 Jump back
draw spray bullet 1
B900 LD (HL),$00 Draw spray bullet 1
B902 ADD HL,DE
B903 LD (HL),$10
B905 ADD HL,DE
B906 LD (HL),$28
B908 ADD HL,DE
B909 LD (HL),$10
B90B JP $B6D8 Jump back
draw basic laser-type projectile
B90E BIT 7,(IX+$0B) Check laser-type projectile
B912 JP NZ,$B926 Jump to draw basic laser-type 1
draw basic laser-type 0
B915 LD A,(IX+$04) Set A direction of projectile
B918 DEC A
B919 JP M,$B921 Jump if lase direction is left
B91C LD (HL),$B7 Draw laser sprite
B91E JP $B6D8 Jump back
B921 LD (HL),$ED Draw laser sprite
B923 JP $B6D8 Jump back
draw basic laser-type 1
B926 LD A,(IX+$04) Set A direction of projectile
B929 DEC A
B92A JP M,$B932 Jump if laser direction is left
B92D LD (HL),$97 Draw laser sprite
B92F JP $B6D8 Jump back
B932 LD (HL),$E9 Draw laser sprite
B934 JP $B6D8 Jump back
draw laser
B937 LD A,(IX+$0E) Decrement laser duration counter
B93A DEC A
B93B LD (IX+$0E),A
B93E OR A is 0 ?
B93F JP NZ,$B949 Jump if not
B942 LD (IX+$06),$00 Destroy laser
B946 JP $B6D8 Jump back for next projectile
B949 LD A,(IX+$0C) Set A to number of laser type $06 extensions
B94C DEC A if no need to create more laser type $06 jump back and handle next projectile
B94D OR A
B94E JP Z,$B6D8
B951 LD (IX+$0C),A Decrement the laser type $06 counter on projectile configuration buffer
B954 LD A,(IX+$0D) Set A22C to laser type $06 x-position + 1
B957 INC A
B958 LD ($A22C),A
B95B LD A,(IX+$01) Set A22E to laser y-position
B95E LD ($A22E),A
B961 LD A,$01 Set laser direction to left at A230
B963 LD ($A230),A
B966 BIT 7,(IX+$04) laser x-delta is negative (moving left)?
B96A JP NZ,$B979 Jump if so
B96D XOR A Set laser diretion to right at A230
B96E LD ($A230),A
B971 LD A,($A22C) Substract two byte to x-position of laser
B974 SUB $10
B976 LD ($A22C),A
B979 XOR A Set 0 for y-position increment at A232
B97A LD ($A232),A
B97D PUSH IX Save IX and BC
B97F PUSH BC
B980 CALL $B54C Configure weapon sound and check for weapon free slot
B983 XOR A Set A = 0 (used as laser type in nex routine)
B984 CALL $B607 Create a new laser type $06
B987 LD A,($A201) Set laser duration/graphic index from A201
B98A LD (IY+$0E),A
B98D LD (IY+$05),$00 Set y-delta to 0
B991 LD (IY+$0B),$06 Set laser type to $06
B995 POP BC Restore BC and IX
B996 POP IX
B998 JP $B6D8 Jump back and configure next projectile
B99B EX DE,HL Exchange DE and HL
B99C PUSH DE Save DE
B99D LD A,(IX+$0E) Point HL to the graphic of laser at B9BE base on laser graphic index
B9A0 LD E,A
B9A1 LD D,$00
B9A3 LD HL,$B9BE
B9A6 ADD HL,DE
B9A7 LD A,R Set A to semi-random number (R: memory refresh register)
B9A9 AND (HL) Apply AND operator to laser graphics
B9AA POP DE Puts this random graphics to room graphics buffer
B9AB LD (DE),A
B9AC LD A,(IX+$0E) Decrement laser graphic index
B9AF DEC A
B9B0 LD (IX+$0E),A
B9B3 OR A if graphic index=0 then set projectile status to destroyed. Then jump back and configure next projectile
B9B4 JP NZ,$B6D8
B9B7 LD (IX+$06),$00
B9BB JP $B6D8
Prev: B5D4 Up: Map Next: B9BE