Prev: BA49 Up: Map Next: BE53
BA5C: Draw enemies
Used by the routines at 947A and A915.
BA5C LD IX,$5E66 Set IX to the base address for enemy configuration
BA60 LD A,($A092) Set B to the max number of enemies in the current room
BA63 LD B,A
BA64 PUSH BC Save BC
BA65 LD A,(IX+$0C) Check enemy status
BA68 OR A Enemy is dead?
BA69 JP Z,$BB69 Jump if so
BA6C LD A,(IX+$09) check enemy type
BA6F AND $7F
BA71 OR A Enemy is FOOT MAN?
BA72 JP NZ,$BAD0 Jump forward if not
Enemy is FOOT MAN
BA75 LD HL,$7F72 Set HL to address pointer for FOOT MAN graphic data
BA78 LD A,(IX+$03) Check jumping state for FOOT MAN
BA7B OR A is jumping?
BA7C JP NZ,$BA86 Jump if so?
BA7F LD A,(IX+$06) Check falling state for FOOT MAN
BA82 OR A is falling?
BA83 JP Z,$BA89 Jump if not
BA86 LD HL,$6018 Point HL to address pointer to graphic data for FOOTMAN falling or jumping
BA89 LD (IX+$16),L Set address for enemy graphic data
BA8C LD (IX+$17),H
BA8F LD A,(IX+$12) FOOTMAN walker is crouched?
BA92 CP $02
BA94 JP Z,$BAD0 Jump forward and no fire?
BA97 BIT 7,(IX+$09) Check type of FOOT MAN
BA9B JP Z,$BAA9 Jump if FOOT MAN Walking
FOOT MAN is crouched and check if will fire the weapon
BA9E CALL $A375 Computes random number on A
BAA1 CP $F0 no fire weapon if random number is < $F0
BAA3 JP C,$BAD0
BAA6 JP $BAB1 Jump to fire weapon
FOOT MAN is walking and check if will fire the weapon
BAA9 CALL $A375 Computes random number on A
BAAC CP $FE no fire weapon if random number is < $FE
BAAE JP C,$BAD0
FOOT MAN fire the weapon
BAB1 CALL $B570 Play enemy weapon sound
BAB4 LD A,(IX+$00) Set x-position of enemy in A093
BAB7 LD ($A093),A
BABA XOR A Set A054 to the type of projectile for the enemy
BABB LD ($A054),A
BABE LD A,$0E Set A to the increment of y-position for the projectile of FOOT MAN walking
BAC0 BIT 7,(IX+$09) is FOOT MAN walking?
BAC4 JP Z,$BAC9 Jump if so
BAC7 LD A,$11 Set A to the increment of y-position for the projectile of FOOT MAN crouched
BAC9 CALL $B58E Create a new laser projectile for FOOT MAN
BACC LD (IY+$05),$00 Set y-delta of projectile to $00
Prepares to draw the enemy
BAD0 LD A,(IX+$00) Set A0AF to the x-position of the enemy
BAD3 LD ($A0AF),A
BAD6 LD A,(IX+$01) Set A0B0 to the y-position of the enemy
BAD9 LD ($A0B0),A
BADC LD A,(IX+$0E) Set A0B1 to the width (in bytes) of the enemy sprite
BADF LD ($A0B1),A
BAE2 LD A,(IX+$0F) Set A0B2 to the height (in pixels) of the enemy sprite
BAE5 LD ($A0B2),A
BAE8 LD A,(IX+$09) Set A033 to the enemy type
BAEB LD ($A033),A
BAEE LD L,(IX+$04) Set #$A034 to the graphic data address for the enemy (static - not animated)
BAF1 LD H,(IX+$05)
BAF4 LD ($A034),HL
BAF7 LD L,(IX+$0A) Set HL to address pointer of base address for animated sprite
BAFA LD H,(IX+$0B)
BAFD LD E,(IX+$16) Set DE to address pointer for animation offset based on previous address
BB00 LD D,(IX+$17)
BB03 LD A,(IX+$09) Set A to enemy type
BB06 AND $7F is enemy type $01 - STOMPER or $08 - SCANNER set A to enemy direction to $00 (right) and jump to draw the enemy
BB08 CP $01
BB0A JP Z,$BB12
BB0D CP $08
BB0F JP NZ,$BB16
BB12 XOR A
BB13 JP $BB19
BB16 LD A,(IX+$02) Set A to enemy direction
BB19 CALL $B258 Draw enemy
BB1C CALL $C5B6 Handle FOOT MAN walking/crouch state change
BB1F CALL $C577 Handle FOOT MAN walking/stand-by state change
BB22 LD A,(IX+$09) Enemy destroyed?
BB25 CP $FF
BB27 JP Z,$BD6B Handle explosion
BB2A CP $06 Foot Man is dying?
BB2C JP Z,$BD44 Handle dying Foot Man 6
BB2F CP $05 is front train?
BB31 JP Z,$BC0F check rear train for shot
BB34 CP $04 is rear train?
BB36 JP Z,$BC30 check front train for shot
This entry point is used by the routine at BD44.
BB39 LD A,(IX+$09) Object type is bubble?
BB3C CP $FE
BB3E CALL Z,$BED3 Handle bubble bouncing and burst
BB41 LD A,(IX+$09) Check object type
BB44 AND $7F
BB46 CP $09 is swing gun?
BB48 JP Z,$BCDD Handle swing gun
BB4B CP $0A is shooter?
BB4D JP Z,$BC92 Handle shooter
BB50 CP $0B is launcher?
BB52 JP Z,$BC65 Handle launcher
BB55 CP $10 is boss?
BB57 JP Z,$BB74 Handle boss
BB5A CALL $C620 Handler for enemies going up: SCANNER, POD, MINE LAYER and FOOTMAN Jumping
BB5D CALL $C6C2 Handler for enemies going down: SCANNER and FOOTMAN falling
BB60 CALL $C72B Obtain the tile type address pointer under the entity
BB63 CALL $BFEF Handle lateral movement for FOOTMAN, STOMPER, MINE, SCANNER, POD, MINE LAYER and BLOB
This entry point is used by the routine at BCDD.
BB66 CALL $D215 Handle collision detection of enemy with Rex and projectiles
Prepare to process the next enemy
BB69 LD DE,$0018 Point IX to the next enemy configuration
BB6C ADD IX,DE
BB6E POP BC Restore BC
BB6F DEC B Decrement enemy counter
BB70 JP NZ,$BA64 If there are enemies on the room go back and draw them
BB73 RET Return if not
Handle boss
BB74 LD A,(IX+$01) Set A to y-pixel-position
BB77 CP $90 is y-pixel-position greater than $90?
BB79 JP NC,$BBDB Jump if so
BB7C LD A,(IX+$11) Set A to Boss direction
BB7F OR A is boss moving down?
BB80 JP NZ,$BBA5 Jump if so and try to shot lasers
BB83 LD A,(IX+$13) Set A to boss prepared to release a mine
BB86 OR A is boss prepared to release a mine?
BB87 JP NZ,$BBA5 Jump if not and try to shot lasers
try to release a mine
BB8A CALL $A375 Set A a pseudo-random number
BB8D CP $F0 is pseudo-random number less than $F0?
BB8F JP C,$BBA5 Jump if so
BB92 LD A,(IX+$00) Set into A093 the x-pixel-position of the mine
BB95 ADD A,$08
BB97 LD ($A093),A
BB9A LD A,(IX+$01) Set into A095 the y-pixel-poistion of the mine
BB9D ADD A,$30
BB9F LD ($A095),A
BBA2 CALL $C1F4 Configure a mine
try to shot lasers
BBA5 LD A,R Set A a pseudo-random number from 0 to F
BBA7 AND $0F
BBA9 OR A is random number 0?
BBAA JP NZ,$BBDB Jump if not
BBAD LD HL,$BE53 Set HL to the base address for y-pixel-offset of laser positions for boss healed
BBB0 LD A,(IX+$12) Set A to the boss state
BBB3 CP $01 is boss wounded?
BBB5 JP NZ,$BBBB Jump if not?
BBB8 LD HL,$BE56 Set HL to the base address for y-pixel-offset of laser positions for boss wounded
create new laser
BBBB PUSH HL Save HL
BBBC CALL $B570 Play weapon sound
BBBF POP HL Restore HL
BBC0 LD A,(IX+$00) Set A093 the x-pixel-position of the laser
BBC3 ADD A,$20
BBC5 LD ($A093),A
BBC8 LD A,(HL) Set A to the y-pixel-offset of the laser
BBC9 CP $FF is end marker?
BBCB JP Z,$BBDB Jump is so
BBCE PUSH HL Save HL
BBCF CALL $B58E Draw/create projectile
BBD2 POP HL Restore HL
BBD3 INC HL Increment address for laser y-pixel-offset
BBD4 LD (IY+$0B),$00 Set the weapon type to projectile configuration buffer
BBD8 JP $BBBB Jump back and create new laser
move boss
BBDB LD A,(IX+$11) is Boss moving up?
BBDE OR A
BBDF JP Z,$BBE5 Jump to move up
BBE2 JP $BBFA Jump to move down
move boss up
BBE5 LD A,(IX+$01) Set the new y-pixel-position of Boss based on Boss speed
BBE8 SUB (IX+$12)
BBEB LD (IX+$01),A
BBEE CP $40 is y-pixel-position greater than $40?
BBF0 JP NC,$BB66 Jump back and handle another enemy
BBF3 LD (IX+$11),$01 Set boss to move down
BBF7 JP $BB66 Jump back and handle another enemy
move boss down
BBFA LD A,(IX+$01) Set the new y-pixel-position of Boss based on Boss speed
BBFD ADD A,(IX+$12)
BC00 LD (IX+$01),A
BC03 CP $78 is y-pixel-position less than $78?
BC05 JP C,$BB66 Jump back and handle another enemy
BC08 LD (IX+$11),$00 Set boss to move up
BC0C JP $BB66 Jump back and handle another enemy
check front train for shot
BC0F CALL $A375 Set A to pseudo random number
BC12 CP $F0 is random number less than $F0?
BC14 JP C,$BB39 Jump back and continue to process another enemy if it is
BC17 CALL $B570 Play laser sound
BC1A LD A,(IX+$00) Set A093 to x-position of enemy
BC1D LD ($A093),A
BC20 XOR A Set projectile type to $0
BC21 LD ($A054),A
BC24 LD A,$0F Set y-position-increment
BC26 CALL $B58E Create a new laser
BC29 LD (IY+$05),$00 Set y-delta for projectile to 0
BC2D JP $BB39 Jump back and continue to process another enemy
check rear train for shot
BC30 CALL $A375 Set A to pseudo random number
BC33 CP $F0 is random number less than $F0?
BC35 JP C,$BB39 Jump back and continue to process another enemy if it is
BC38 CALL $B570 Play laser sound
BC3B LD (IX+$02),$00 Set sprite to no reverse temp.
BC3F LD A,(IX+$00) Set A093 to x-position of enemy
BC42 LD ($A093),A
BC45 XOR A Set projectile type to $0
BC46 LD ($A054),A
BC49 LD A,$0E Set y-position-increment
BC4B CALL $B58E Create a new laser
BC4E LD (IY+$05),$00 Set y-delta for projectile to 0
BC52 CALL $B570 Play laser sound
BC55 LD A,$10 Set y-position-increment
BC57 CALL $B58E Create a new laser
BC5A LD (IY+$05),$00 Set y-delta for projectile to 0
BC5E LD (IX+$02),$01 Set normal reverse for rear train
BC62 JP $BB39 Jump back and continue to process another enemy
handle launcher
BC65 CALL $A388 Set A a pseudo random number
BC68 CP $64 is random number less than $64?
BC6A JP C,$BB66 Jump back and process another enemy
BC6D DEC (IX+$11) Decrement launch counter
BC70 JP NZ,$BB66 Jump back and process another enemy if counter ahs not reached 0
BC73 LD A,(IX+$12) Reset launch counter
BC76 LD (IX+$11),A
BC79 CALL $B570 Play weapon sound
BC7C LD A,(IX+$00) Set A093 the x-pixel-position of projectile
BC7F LD ($A093),A
BC82 LD A,$08 Set A to the y-pixel-position increment
BC84 CALL $B58E Draw/create projectile
BC87 LD (IY+$0B),$87 Set type of projectile
BC8B LD (IY+$0C),$00 Set projectile trajectory counter
BC8F JP $BB66 Jump back and process another enemy
handle shooter
BC92 CALL $A375 Set A a pseudo random number
BC95 CP $64 is random number less than $64?
BC97 JP C,$BB66 Jump back and process another enemy
BC9A DEC (IX+$11) Decrement shot counter
BC9D JP NZ,$BB66 Jump back and process another enemy if counter ahs not reached 0
BCA0 LD A,(IX+$12) Reset shot counter
BCA3 LD (IX+$11),A
BCA6 CALL $B570 Play weapon sound
BCA9 XOR A Shot laser right direction
BCAA LD ($A097),A
BCAD LD A,(IX+$00) Set A the x-pixel-position for laser
BCB0 CALL $BCC6 Configure laser in right direction
BCB3 CALL $B570 Play weapon sound
BCB6 LD A,$01 Shot laser left direction
BCB8 LD ($A097),A
BCBB LD A,(IX+$00) Set A the x-pixel-position for laser
BCBE SUB $08
BCC0 CALL $BCC6 Configure laser in left direction
BCC3 JP $BB66 Jump back and process another enemy
Configure laser for SHOOTER
BCC6 LD ($A093),A Set A093 the x-pixel-position for laser
BCC9 LD A,$0F Set A099 the increment y-pixel-position
BCCB LD ($A099),A
BCCE LD A,(IX+$01) Set A095 the y-pixel-position for laser
BCD1 LD ($A095),A
BCD4 XOR A Set wepaon type to 0 (laser)
BCD5 CALL $B5C1 Draw/Create laser
BCD8 LD (IY+$05),$00 Set y-delta of laser to 0
BCDC RET
Handle swing gun
BCDD LD E,(IX+$11) Set DE swing gun orientation
BCE0 LD D,$00
BCE2 LD HL,$BECB Set HL to graphic data address based on swing gun orientation
BCE5 ADD HL,DE
BCE6 LD E,(HL)
BCE7 LD D,$00
BCE9 LD HL,$8EAA
BCEC ADD HL,DE
BCED LD (IX+$04),L Save this address to enemy configuration
BCF0 LD (IX+$05),H
BCF3 LD A,(IX+$12) Set A to the type of swing gun
BCF6 OR A is mobile gun?
BCF7 JP Z,$BD02 Jump if so
BCFA CALL $A375 Set A a pseudo random number
BCFD CP $14 is number less than $14
BCFF JP NC,$BD2A Jump if not
fire gun
BD02 LD A,$04 Set A054 the type of shot
BD04 LD ($A054),A
BD07 CALL $B570 Play weapon sound
BD0A LD A,(IX+$11) Check swing gun orientation
BD0D OR A is 0?
BD0E CALL Z,$BE5B Configure projectile for swing gun left orientation.
BD11 CP $01 is 1?
BD13 CALL Z,$BE75 Configure projectile for swing gun left bottom orientation.
BD16 CP $03 is 3?
BD18 CALL Z,$BE9B Configure projectile for swing gun right bottom orientation.
BD1B CP $04 is 4?
BD1D CALL Z,$BEB3 Configure projectile for swing gun right orientation.
BD20 CP $05 is 5?
BD22 CALL Z,$BE9B Configure projectile for swing gun right bottom orientation.
BD25 CP $07 is 7?
BD27 CALL Z,$BE75 Configure projectile for swing gun left bottom orientation.
check gun orientation
BD2A LD A,(IX+$12) Set A to the type of swing gun
BD2D OR A is mobile gun?
BD2E JP NZ,$BB66 Jump back and process next enemy if fixed gun
BD31 LD A,(IX+$11) Increment orientation of gun
BD34 INC A
BD35 LD (IX+$11),A
BD38 CP $08 orientation is 8?
BD3A JP NZ,$BB66 Jump back and process next enemy if not
BD3D LD (IX+$11),$00 Reset orientation
BD41 JP $BB66 Jump back and process next enemy
Handle Foot Man dying 6
BD44 LD A,(IX+$11) Set A to state change counter
BD47 CP $04 counter is 4?
BD49 JP NZ,$BD5E Jump if not
BD4C LD HL,$AE85 Set address for animation offsets of dying foot man
BD4F LD (IX+$0A),L
BD52 LD (IX+$0B),H
BD55 LD HL,$8692 Set graphic data for dying Foot man 7
BD58 LD (IX+$16),L
BD5B LD (IX+$17),H
BD5E DEC (IX+$11) Decrement state change counter
BD61 JP NZ,$BB39 If not zero jump back and continue to process other enemies
BD64 LD (IX+$09),$07 Set enemy type to FOOT MAN dying 7
BD68 JP $BB39 Jump back and continue to process other enemies
Handle explosion and configure gift: bubble, smartbomb or question
Handle debris expansion
BD6B LD HL,$AA0E Set HL to the offset of positions for debris 1
BD6E CALL $BF66 Handle debris movement and draw it
BD71 LD HL,$AA1E Set HL to the offset of positions for debris 2
BD74 CALL $BF66 Handle debris movement and draw it
BD77 LD HL,$AA2E Set HL to the offset of positions for debris 3
BD7A CALL $BF66 Handle debris movement and draw it
BD7D LD HL,$AA3E Set HL to the offset of positions for debris 4
BD80 CALL $BF66 Handle debris movement and draw it
BD83 LD HL,$AA4E Set HL to the offset of positions for debris 5
BD86 CALL $BF66 Handle debris movement and draw it
BD89 LD HL,$AA5E Set HL to the offset of positions for debris 6
BD8C CALL $BF66 Handle debris movement and draw it
BD8F INC (IX+$03) Increment explosion debris counter
Draw central explosion
BD92 LD A,(IX+$00) Set A0AF the x-pixel-position of the explosion
BD95 LD ($A0AF),A
BD98 LD A,(IX+$01) Set A0AF the x-pixel-position of the explosion
BD9B LD ($A0B0),A
BD9E CALL $CF9B Draw random attribute color for explosion
BDA1 LD L,(IX+$04) Increment the graphic data address for the explosion
BDA4 LD H,(IX+$05)
BDA7 LD DE,$0048
BDAA ADD HL,DE
BDAB LD (IX+$04),L
BDAE LD (IX+$05),H
BDB1 DEC (IX+$0D) Decrement explosion counter
BDB4 JP NZ,$BB69 Jump to the next enemy configuration if not zero Explosion has ended, configure gift: bubble, smartbomb or question
BDB7 LD HL,($A093) Set HL to the address into the attribute file for the explosion
BDBA LD DE,($A095) Set DE to the address into the attribute buffer for the explosion
BDBE CALL $CF6E Reset attribute color when explosion ended
BDC1 LD A,(IX+$00) x-pixel-position of sprite is less than 24?
BDC4 CP $18
BDC6 JP C,$BE2E Jump if so
BDC9 LD (IX+$09),$FE Set Enemy configuration to energy bubble
BDCD LD (IX+$0F),$10 Set sprite height
BDD1 LD (IX+$0E),$02 Set sprite width
BDD5 LD A,(IX+$01) Add 8 pixels to y-pixel-position
BDD8 ADD A,$08
BDDA LD (IX+$01),A
configure big bubble
BDDD LD (IX+$03),$00 Reset configuration
BDE1 LD (IX+$06),$00 Reset configuration
BDE5 LD (IX+$11),$64 Set bubble counter to $64
BDE9 LD (IX+$10),$00 Reset configuration
BDED LD HL,$86F2 Set HL to graphic data address for big bubble
BDF0 LD (IX+$12),L Set graphic data address for bubble
BDF3 LD (IX+$13),H
BDF6 LD (IX+$04),L
BDF9 LD (IX+$05),H
BDFC LD A,(IX+$15) Check bubble type
BDFF CP $FF No bubble?
BE01 JP Z,$BE2E Jump if so
BE04 CALL $A375 Set A to a pseudo-random number
BE07 CP $03 is less than 3?
BE09 JP C,$BE35 you are lucky, you got an smartbomb
BE0C CP $06 is less than 6?
BE0E JP C,$BE3F you are lucky, you got a question mark (random gift)
BE11 LD A,(IX+$15) is bubble type big?
BE14 OR A
BE15 JP NZ,$BB69 Jump if so and process next obejct
configure small bubble
BE18 LD HL,$87B2 Set HL to graphic data for small bubble
BE1B LD (IX+$12),L Set graphic data for the bubble
BE1E LD (IX+$13),H
BE21 LD (IX+$11),$8C Set bubble counter to $8C
BE25 LD (IX+$04),L Set graphic data for the bubble
BE28 LD (IX+$05),H
BE2B JP $BB69 Jump to the next enemy configuration
configure no bubble
BE2E LD (IX+$0C),$00 Set object live/visibility to dead/not visible
BE32 JP $BB69 Jump to the next enemy configuration
configure smartbomb
BE35 LD (IX+$09),$FD Set object type to smartbomb
BE39 LD HL,$8CEA Set graphic data for smartbomb
BE3C JP $BE46 Jump forward
configure question
BE3F LD (IX+$09),$FC Set object type to question
BE43 LD HL,$8D0A Set graphic data for question
BE46 LD (IX+$04),L Copy address to object configuration
BE49 LD (IX+$05),H
BE4C LD (IX+$02),$01 Set sprite to reverse
BE50 JP $BB69 Jump to the next enemy configuration
Prev: BA49 Up: Map Next: BE53