Prev: 49389 Up: Map Next: 49490
49409: Split Creature
Splits the creature in two. The shot turns into a burst, and a copy of the creature is made in the first of the short-lived objects that is free. The two creatures go in opposite directions, and 21 hundred points are added to the score. If there is no room for the copy, the player scores only a small number of points.
Find a short-lived object that is free, or far from the player.
HitOutcome_Split 49409 LD (IY+0),12 Turn the shot into a burst.
49413 PUSH IX Stash the address of the creature on the stack.
49415 LD IX,48542 Start with the first short-lived object.
49419 LD DE,16 Set the distance between one object and the next (16 bytes).
49422 LD B,6 Set a counter for the six objects.
HitOutcome_Split_Loop 49424 LD A,(IY+0) Jump to HitOutcome_Split_Copy to use this object if it is empty.
49427 AND A
49428 JR Z,HitOutcome_Split_Copy
49430 LD C,2 Set the distance to 2 cells.
49432 CALL CheckPlayerClose Check whether the creature is close to the player.
49435 JR NC,HitOutcome_Split_Copy Jump to HitOutcome_Split_Copy to use this object if the creature is not close to the player.
49437 ADD IY,DE Move on to the next object.
49439 DJNZ HitOutcome_Split_Loop Loop back until all six objects have been tried.
There is no free slot, so add a small score and return.
49441 POP IX Restore the creature from the stack.
49443 LD BC,21 Set the points for failing to split the creature.
49446 JP AddToScore Jump to AddToScore to add the points to the score.
Copy the creature and send the two in opposite directions.
HitOutcome_Split_Copy 49449 PUSH IX Copy the address of the free object to DE (using the stack).
49451 POP DE
49452 PUSH DE Point IY at the free object (using the stack).
49453 POP IY
49455 POP HL Get the address of the creature back.
49456 PUSH HL Point IX at the creature (using the stack).
49457 POP IX
49459 LD BC,16 Set the size of an object to 16 bytes.
49462 LDIR Copy the creature into the free object.
49464 LD A,(IX+6) Fetch the direction timer of the original creature.
49467 ADD A,64 Turn it a quarter on.
49469 OR %00011111 Set the lower five bits, to give it a new time to go in that direction.
49471 LD (IX+6),A Store the direction timer of the original creature.
49474 LD A,(IY+6) Fetch the direction timer of the copy.
49477 SUB 64 Turn it a quarter back.
49479 OR %00011111 Set the lower five bits, to give it a new time to go in that direction.
49481 LD (IY+6),A Store the direction timer of the copy.
49484 LD BC,21 Set the points for splitting a creature.
49487 JP AddToScore Jump to AddToScore to add the points to the score.
Prev: 49389 Up: Map Next: 49490