Prev: 60444 Up: Map Next: 60605
60474: Place Special Object
Used by the routine at Draw_Room.
Puts an extra life or a guardian in the room that Sabreman has just entered, if there is one in it and it has not been collected or destroyed.
The room of Sabreman is looked up in the table of the sixteen extra lives at Extra_Life_Table and then in the table of the guardians at Guardian_Table (the entries are three bytes long: the room x, the room y and a collected flag). A guardian is dealt with by Place_Guardian.
An extra life is made from a copy of the template at Extra_Life_Template in the first of the two special object records at First_Special_Object_Record. Byte 6 of the record holds the number of the entry, counted from the end of the table, which Collect_Extra_Life uses to set the collected flag when the extra life is picked up.
The extra life sits on top of one of the two objects at Object_Record_10 and Object_Record_11, which are the decorations of a special room or the stalactites of a cave: the first is used if the room y is odd, the second if it is even. In a special room the height of the object comes from the table at Decoration_Height_Table.
The loop over the guardians counts eight entries, but the table only has four, so it carries on into the code that follows the table.
Place_Special_Object 60474 LD HL,60868 Point HL at the table of extra lives.
60477 LD A,(36636) Fetch the room x of Sabreman.
60480 LD E,A Store it in E.
60481 LD A,(36638) Fetch the room y of Sabreman.
60484 LD D,A Store it in D.
60485 LD B,16 Set the number of extra lives to check to 16.
Place_Special_Object_Find_Extra_Life 60487 LD A,(HL) Fetch the room x of the entry.
60488 INC HL Move on to the room y.
60489 CP E Jump to Place_Special_Object_Next_Extra_Life if it is not the room x of Sabreman.
60490 JR NZ,Place_Special_Object_Next_Extra_Life
60492 LD A,(HL) Fetch the room y of the entry.
60493 CP D Jump to Place_Special_Object_Extra_Life if it is the room y of Sabreman.
60494 JR Z,Place_Special_Object_Extra_Life
Place_Special_Object_Next_Extra_Life 60496 INC HL Move on to the next entry.
60497 INC HL
60498 DJNZ Place_Special_Object_Find_Extra_Life Loop back until all the extra lives have been checked.
60500 LD HL,60916 Point HL at Guardian_Table.
60503 LD B,8 Set the number of guardians to check to 8.
Place_Special_Object_Find_Guardian 60505 LD A,(HL) Fetch the room x of the entry.
60506 INC HL Move on to the room y.
60507 CP E Jump to Place_Special_Object_Next_Guardian if it is not the room x of Sabreman.
60508 JR NZ,Place_Special_Object_Next_Guardian
60510 LD A,(HL) Fetch the room y of the entry.
60511 CP D Jump to Place_Guardian if it is the room y of Sabreman, to place the guardian.
60512 JP Z,Place_Guardian
Place_Special_Object_Next_Guardian 60515 INC HL Move on to the next entry.
60516 INC HL
60517 DJNZ Place_Special_Object_Find_Guardian Loop back until all the entries have been checked.
60519 RET Return.
Place_Special_Object_Extra_Life 60520 INC HL Move on to the collected flag of the entry.
60521 LD A,(HL) Fetch the collected flag.
60522 AND A Return if the extra life has been collected already.
60523 RET NZ
60524 LD A,B Fetch the number of the entry, counted from the end of the table.
60525 PUSH DE Stash the room of Sabreman.
60526 LD HL,60852 Point HL at Extra_Life_Template.
60529 LD DE,36794 Point DE at First_Special_Object_Record.
60532 LD BC,16 Set the size of a record in BC.
60535 LDIR Copy the template to the record.
60537 LD (36800),A Store the number of the entry in byte 6 of the record.
60540 POP BC Restore the room of Sabreman into BC.
60541 DI Disable interrupts.
60542 PUSH IY Save IY.
60544 LD IY,36762 Point IY at the object at Object_Record_10.
60548 BIT 0,B Jump to Place_Special_Object_Set_Position if the room y is odd.
60550 JR NZ,Place_Special_Object_Set_Position
60552 LD IY,36778 Point IY at the object at Object_Record_11 instead.
Place_Special_Object_Set_Position 60556 LD DE,36795 Point DE at the x position of the special object record.
60559 LD A,(IY+1) Fetch the x position of the object.
60562 ADD A,8 Add 8.
60564 LD (DE),A Set the x position of the extra life.
60565 INC DE Move on to the room x.
60566 LD A,C Fetch the room x.
60567 LD (DE),A Set the room x of the extra life.
60568 INC DE Move on to the y position.
60569 LD A,B Fetch the room y.
60570 CP 16 Jump to Place_Special_Object_Set_Top if the room is a cave (the room y is 16 or more).
60572 JR NC,Place_Special_Object_Set_Top
Place_Special_Object_Set_Height 60574 LD HL,60341 Point HL at Decoration_Height_Table.
60577 LD A,(IY+0) Fetch the type of the decoration.
60580 SUB 116 Subtract 116 to make the number of the decoration.
60582 ADD A,L Add the number to the address in HL.
60583 LD L,A Store the low byte of the address.
60584 LD A,H Fetch the high byte of the address.
60585 ADC A,0 Add the carry.
60587 LD H,A Store the high byte of the address.
60588 LD A,(HL) Fetch the height of the decoration.
60589 LD (IY+12),A Store it in byte 12 of the object, where the size of the obstacle is kept.
Place_Special_Object_Set_Top 60592 LD A,(IY+3) Fetch the y position of the object.
60595 SUB (IY+12) Subtract its height to get the y position of its top.
60598 LD (DE),A Set the y position of the extra life.
60599 INC DE Move on to the room y.
60600 LD A,B Fetch the room y.
60601 LD (DE),A Set the room y of the extra life.
60602 POP IY Restore IY.
60604 RET Return.
Prev: 60444 Up: Map Next: 60605