Prev: 60352 Up: Map Next: 60444
60382: Place Guardian
Used by the routine at Place_Special_Object.
Puts a guardian in the room, unless it has been destroyed already. It is the continuation of Place_Special_Object when the room of Sabreman is that of an entry of the table of guardians at Guardian_Table.
The rock formation is put in the room first (see Place_Rock_Formation). The guardian is made from a copy of the template at Extra_Life_Template. Its type is 128 134 132 or 130 which depends on the number of the entry, and it is placed at the x position 128 and the y position 159 with the attribute 3 (magenta). Byte 6 of the record holds the number of the entry, which Handle_Guardian uses to set the collected flag of the entry when the guardian is destroyed.
The record that is used is the first of the two special object records, First_Special_Object_Record.
Input
B Number of entries left in the table of guardians, including this one
C Room x of Sabreman
D Room y of Sabreman
HL Address of the room y of the entry
Place_Guardian 60382 EXX Switch to the alternate registers, to keep the registers that the caller uses.
60383 CALL Place_Rock_Formation Put the rock formation in the room.
60386 EXX Switch back to the main registers.
60387 INC HL Move on to the collected flag of the entry.
60388 LD A,(HL) Fetch the collected flag.
60389 AND A Return if the guardian has been destroyed already.
60390 RET NZ
60391 LD A,B Fetch the number of the entry, counted from the end of the table.
60392 PUSH DE Stash the room of Sabreman.
60393 LD HL,60852 Point HL at Extra_Life_Template.
60396 LD DE,36794 Point DE at First_Special_Object_Record.
60399 LD BC,16 Set the size of a record in BC.
60402 LDIR Copy the template to the record.
60404 LD (36800),A Store the number of the entry in byte 6 of the record.
60407 POP BC Restore the room of Sabreman into BC.
60408 DI Disable interrupts.
60409 PUSH IY Save IY.
60411 LD IY,36794 Point IY at First_Special_Object_Record.
60415 RLA Shift the number of the entry left, to double it.
60416 AND %00000110 Keep the result in bits 1 and 2.
60418 ADD A,128 Add 128 to make the type of the guardian.
60420 LD (IY+0),A Set the type of the guardian.
60423 LD (IY+2),C Set the room x of the guardian.
60426 LD (IY+4),B Set the room y of the guardian.
60429 LD (IY+1),128 Set the x position of the guardian to 128.
60433 LD (IY+3),159 Set the y position of the guardian to 159.
60437 LD (IY+5),3 Set the attribute of the guardian to 3 (magenta).
60441 POP IY Restore IY.
60443 RET Return.
Prev: 60352 Up: Map Next: 60444