![]() |
Routines |
Prev: C9E3 | Up: Map | Next: CAF6 |
Used by the routine at 9470.
|
||||
CA35 | LD A,($A1DE) | Return if generating train in current room | ||
CA38 | OR A | |||
CA39 | RET NZ | |||
CA3A | LD A,($A1DC) | Decrement enemy room enter counter | ||
CA3D | DEC A | |||
CA3E | LD ($A1DC),A | |||
CA41 | OR A | Return if counter has not reached zero | ||
CA42 | RET NZ | |||
CA43 | LD A,($A1DD) | Reset counter with the original value | ||
CA46 | LD ($A1DC),A | |||
CA49 | LD HL,$5E72 | Set HL to the base address for enemy status into the enemy configuration table | ||
CA4C | LD A,($A22B) | Set B to the max number of enemies for the room | ||
CA4F | LD B,A | |||
CA50 | LD A,(HL) | Check enemy status | ||
CA51 | OR A | Jump forward if enemy dead/not visible | ||
CA52 | JP Z,$CA5C | |||
CA55 | LD DE,$001B | Point to the next enemy configuration | ||
CA58 | ADD HL,DE | |||
CA59 | DJNZ $CA50 | Jump back until all the enemies slots checked | ||
CA5B | RET | |||
create a new enemy
|
||||
CA5C | LD DE,$000C | Point HL to the base address for the current slot of enemy configuration | ||
CA5F | AND A | |||
CA60 | SBC HL,DE | |||
CA62 | PUSH HL | Set IX to this base address | ||
CA63 | POP IX | |||
CA65 | CALL $CA69 | Try to create a new enemy | ||
CA68 | RET | |||
computes random position
|
||||
CA69 | CALL $A530 | Set A a pseudo random number between 24 and 224 | ||
CA6C | CP $18 | |||
CA6E | JP C,$CA69 | |||
CA71 | CP $E0 | |||
CA73 | JP NC,$CA69 | |||
CA76 | AND $F8 | Set the number grid (8x8) fixed | ||
CA78 | LD ($A248),A | Set this number the x-position for the entity | ||
CA7B | CALL $A530 | Set A a pseudo random number between 32 and 168 | ||
CA7E | CP $20 | |||
CA80 | JP C,$CA7B | |||
CA83 | CP $A8 | |||
CA85 | JP NC,$CA7B | |||
CA88 | AND $F8 | Set the number grid (8x8) fixed | ||
CA8A | LD ($A249),A | Set this number the y-position for the entity | ||
check if position collides with Rex position
|
||||
CA8D | LD A,($A24F) | Set A the Rex x-position | ||
CA90 | SUB $10 | Jump forward if enemy x-position is not in range collision with Rex x-position | ||
CA92 | LD HL,$A248 | |||
CA95 | CP (HL) | |||
CA96 | JP NC,$CAB2 | |||
CA99 | ADD A,$30 | |||
CA9B | CP (HL) | |||
CA9C | JP C,$CAB2 | |||
CA9F | LD A,($A250) | Set A the Rex y-position | ||
CAA2 | SUB $10 | Jump forward if enemy y-position is not in range collision with Rex y-position | ||
CAA4 | LD HL,$A249 | |||
CAA7 | CP (HL) | |||
CAA8 | JP NC,$CAB2 | |||
CAAB | ADD A,$30 | |||
CAAD | CP (HL) | |||
CAAE | JP C,$CAB2 | |||
CAB1 | RET | |||
CAB2 | CALL $CAF6 | Check if enemy can be generated | ||
CAB5 | OR A | Return if enemy can not be generated | ||
CAB6 | RET Z | |||
CAB7 | LD A,($A221) | Set A the type of enemy | ||
CABA | LD L,A | Set L the type of enemy | ||
CABB | BIT 7,A | Jump forward if generate random FOOT MAN bit is not set | ||
CABD | JP Z,$CACE | |||
try to generate random FOOT MAN
|
||||
CAC0 | AND $7F | Set L the type of enemy to generate | ||
CAC2 | LD L,A | |||
CAC3 | CALL $A530 | Set A a pseudo random number between 0 an 1 | ||
CAC6 | AND $01 | |||
CAC8 | OR A | if random number is 1 then generate FOOT MAN | ||
CAC9 | JP Z,$CACE | |||
CACC | LD L,$00 | Generate FOOT MAN | ||
generate enemy
|
||||
CACE | LD A,L | Set A the new enemy type to create | ||
CACF | CALL $CB7A | Configure the new enemy | ||
CAD2 | LD A,($A248) | Set x-pixel-position for enemy | ||
CAD5 | LD (IX+$00),A | |||
CAD8 | LD A,($A249) | Set y-pixel-position for enemy | ||
CADB | LD (IX+$01),A | |||
CADE | CALL $A51D | Set random face direction | ||
CAE1 | AND $01 | |||
CAE3 | LD (IX+$02),A | |||
CAE6 | CALL $9EE4 | Initialize teleporting data | ||
CAE9 | LD A,(IX+$09) | Return if enemy is not FOOT MAN | ||
CAEC | OR A | |||
CAED | RET NZ | |||
CAEE | CALL $C60D | Configure FOOT MAN for stand-by position | ||
CAF1 | LD (IX+$11),$18 | Set state change counter | ||
CAF5 | RET |
Prev: C9E3 | Up: Map | Next: CAF6 |