Prev: 26585 Up: Map Next: 26657
26594: Create Monster
Used by the routine at CreateActor.
Creates the monster in the last of the six actor slots (24445), unless that slot is already in use. The ID is 36 or 37 depending on bit 0 of the number of ingredients that are needed. The monster is put at the bottom of one of the four dustbins, which is chosen at random from the table at DustbinPositions, and is coloured green. Bytes 4 and 5 are the speeds which are used when the monster throws something (see HandleMonster_Throwing); they are made from the frame counter and a random number. A warble sound is then started.
CreateMonster 26594 LD DE,24445 Point DE at the monster slot (ActorMonsterSlot).
26597 LD A,(DE) Fetch the actor ID.
26598 AND A Is the slot in use?
26599 RET NZ Return if it is.
26600 LD A,(24367) Fetch the number of ingredients needed.
26603 AND %00000001 Keep only bit 0 (which frame the monster starts on).
26605 ADD A,36 Add 36 to get the ID of the monster.
26607 LD (DE),A Set the actor ID.
26608 INC DE Move on to the horizontal co-ordinate.
26609 LD A,R Fetch a random number.
26611 AND %00000011 Keep only bits 0-1 (to choose one of the four dustbins).
26613 LD C,A Use the result as an offset into the dustbin positions.
26614 LD B,0 Set the high byte of the offset to 0.
26616 LD HL,26657 Point HL at DustbinPositions.
26619 ADD HL,BC Find the dustbin.
26620 LD A,(HL) Fetch the horizontal co-ordinate of the dustbin.
26621 LD (DE),A Set the horizontal co-ordinate of the monster.
26622 INC DE Move on to the vertical co-ordinate.
26623 LD A,184 Fetch the vertical co-ordinate of the bottom of the dustbin.
26625 LD (DE),A Set the vertical co-ordinate of the monster.
26626 INC DE Move on to the colour.
26627 LD A,68 Fetch the colour of the monster (INK:GREEN, PAPER:BLACK (BRIGHT)).
26629 LD (DE),A Set the colour of the monster.
26630 INC DE Move on to the horizontal speed.
26631 LD A,(24349) Fetch the frame counter.
26634 AND %00000011 Keep only bits 0-1.
26636 NEG Negate the result, so that the monster is thrown to the left.
26638 LD (DE),A Set the horizontal speed.
26639 INC DE Move on to the vertical speed.
26640 LD B,A Keep the horizontal speed in B.
26641 LD A,R Fetch a random number.
26643 ADD A,B Add the horizontal speed.
26644 AND %00000011 Keep only bits 0-1.
26646 ADD A,4 Add 4 so that the monster is always thrown upwards quickly.
26648 NEG Negate the result, so that it is an upward speed.
26650 LD (DE),A Set the vertical speed.
26651 INC DE Move on to the state.
26652 XOR A Set the state to 0 (rising out of the dustbin).
26653 LD (DE),A Set the state of the monster.
26654 JP StartWarble Jump to StartWarble.
Prev: 26585 Up: Map Next: 26657