Prev: 67D9 Up: Map Next: 6821
67E2: Create Monster
Used by the routine at CreateActor.
Creates the monster in the last of the six actor slots (5F7D), unless that slot is already in use. The ID is 24 or 25 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 04 and 05 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 67E2 LD DE,$5F7D Point DE at the monster slot (ActorMonsterSlot).
67E5 LD A,(DE) Fetch the actor ID.
67E6 AND A Is the slot in use?
67E7 RET NZ Return if it is.
67E8 LD A,($5F2F) Fetch the number of ingredients needed.
67EB AND %00000001 Keep only bit 0 (which frame the monster starts on).
67ED ADD A,$24 Add 24 to get the ID of the monster.
67EF LD (DE),A Set the actor ID.
67F0 INC DE Move on to the horizontal co-ordinate.
67F1 LD A,R Fetch a random number.
67F3 AND %00000011 Keep only bits 0-1 (to choose one of the four dustbins).
67F5 LD C,A Use the result as an offset into the dustbin positions.
67F6 LD B,$00 Set the high byte of the offset to 00.
67F8 LD HL,$6821 Point HL at DustbinPositions.
67FB ADD HL,BC Find the dustbin.
67FC LD A,(HL) Fetch the horizontal co-ordinate of the dustbin.
67FD LD (DE),A Set the horizontal co-ordinate of the monster.
67FE INC DE Move on to the vertical co-ordinate.
67FF LD A,$B8 Fetch the vertical co-ordinate of the bottom of the dustbin.
6801 LD (DE),A Set the vertical co-ordinate of the monster.
6802 INC DE Move on to the colour.
6803 LD A,$44 Fetch the colour of the monster (INK:GREEN, PAPER:BLACK (BRIGHT)).
6805 LD (DE),A Set the colour of the monster.
6806 INC DE Move on to the horizontal speed.
6807 LD A,($5F1D) Fetch the frame counter.
680A AND %00000011 Keep only bits 0-1.
680C NEG Negate the result, so that the monster is thrown to the left.
680E LD (DE),A Set the horizontal speed.
680F INC DE Move on to the vertical speed.
6810 LD B,A Keep the horizontal speed in B.
6811 LD A,R Fetch a random number.
6813 ADD A,B Add the horizontal speed.
6814 AND %00000011 Keep only bits 0-1.
6816 ADD A,$04 Add 04 so that the monster is always thrown upwards quickly.
6818 NEG Negate the result, so that it is an upward speed.
681A LD (DE),A Set the vertical speed.
681B INC DE Move on to the state.
681C XOR A Set the state to 00 (rising out of the dustbin).
681D LD (DE),A Set the state of the monster.
681E JP StartWarble Jump to StartWarble.
Prev: 67D9 Up: Map Next: 6821