Prev: D61E Up: Map Next: D71E
D664: Draw Doors
Preps door frame 1.
Draw_DoorFrame1 D664 LD HL,$D6B1 Calls Door_Attributes using Door_Attributes_01.
D667 CALL Door_Attributes
D66A LD DE,$BA80 DE=Door_Frame_01.
Referencing the door frame index, work out the screen position and send it to the Draw_DoorFrame routine.
Prep_Door_Frame D66D LD A,($CE1A) A=Door_Frame_Reference.
D670 LD HL,$4082 Determines which screen address to use for the door reference index currently held in A.
A Screen Address
01 $4082
02 $408D
03 $4098
Jump to Draw_DoorFrame.
D673 DEC A
D674 JP Z,Draw_DoorFrame
D677 LD HL,$408D
D67A DEC A
D67B JP Z,Draw_DoorFrame
D67E LD HL,$4098
D681 JP Draw_DoorFrame
Copies attributes for the current door frame index.
Door_Attributes D684 PUSH AF Stash the accumulator for later.
D685 LD A,($CE1A) A=Door_Frame_Reference.
D688 LD DE,$5882
A Screen Address
01 $5882
02 $588D
03 $5898
...continue from Door_Attributes_Skip.
D68B DEC A
D68C JR Z,Door_Attributes_Skip
D68E LD DE,$588D
D691 DEC A
D692 JR Z,Door_Attributes_Skip
D694 LD DE,$5898
Door_Attributes_Skip D697 LD B,$0B Sets the height of the door image.
Door_Attributes_Loop D699 PUSH BC Stash the references for later and call Door_Attributes_Copy.
D69A PUSH HL
D69B PUSH DE
D69C CALL Door_Attributes_Copy
D69F POP DE Moves the screen attribute address down to the next attribute row.
D6A0 LD HL,$0020
D6A3 ADD HL,DE
D6A4 EX DE,HL
D6A5 POP HL Restore the counter and loop back to Door_Attributes_Loop until complete.
D6A6 POP BC
D6A7 DJNZ Door_Attributes_Loop
D6A9 POP AF Restore the accumulator and return.
D6AA RET
Simple helper copy routine for sending attribute data to the screen attribute buffer.
Door_Attributes_Copy D6AB LD BC,$0007 Set the door width, copy the attribute data to the screen and return.
D6AE LDIR
D6B0 RET
Door frame attribute data.
Door_Attributes_01 D6B1 DEFB $30,$30,$30,$30,$30,$30,$30,$30 Attribute data for door frame 1.
Door_Attributes_02 D6B9 DEFB $28,$28,$30,$30,$30,$30,$30,$30 Attribute data for door frame 2.
Door_Attributes_03 D6C1 DEFB $28,$28,$28,$28,$30,$30,$30,$30 Attribute data for door frame 3.
Door_Attributes_04 D6C9 DEFB $28,$28,$28,$28,$28,$28,$30,$28 Attribute data for door frame 4.
Preps door frame 2.
Draw_DoorFrame02 D6D1 LD HL,$D6B9 Calls Door_Attributes using Door_Attributes_02.
D6D4 CALL Door_Attributes
D6D7 CALL Character_Door_Frame_02 Prepare the character/ door image by calling Character_Door_Frame_02. Then pass Door_Buffer to Prep_Door_Frame which will draw it to the screen.
D6DA LD DE,$EA90
D6DD JR Prep_Door_Frame
Preps door frame 3.
Draw_DoorFrame03 D6DF LD HL,$D6C1 Calls Door_Attributes using Door_Attributes_03.
D6E2 CALL Door_Attributes
D6E5 CALL Character_Door_Frame_03 Prepare the character/ door image by calling Character_Door_Frame_03. Then pass Door_Buffer to Prep_Door_Frame which will draw it to the screen.
D6E8 LD DE,$EA90
D6EB JR Prep_Door_Frame
Preps door frame 4.
Draw_DoorFrame04 D6ED LD HL,$D6C9 Calls Door_Attributes using Door_Attributes_04.
D6F0 CALL Door_Attributes
D6F3 CALL Draw_CharacterInDoorway The door is fully open so draw the whole character in the doorway directly.
D6F6 LD B,$58 Reference Door_Frame_04 and the dimensions for the copy routine.
D6F8 LD C,$01
D6FA LD DE,$BFA8
D6FD LD A,($CE1A) A=Door_Frame_Reference.
D700 LD HL,$4088 Determines which screen address to use for the door reference index currently held in A.
A Screen Address
01 $4088
02 $4093
03 $409E
Jump to Copy_Routine.
D703 DEC A
D704 JP Z,Copy_Routine
D707 LD HL,$4093
D70A DEC A
D70B JP Z,Copy_Routine
D70E LD HL,$409E
D711 JP Copy_Routine
D714 LD DE,$EA90 DE=Door_Buffer.
Draw_DoorFrame D717 LD B,$58 Draws the image pointed at by DE to the screen address in HL using Copy_Routine.
D719 LD C,$07
D71B JP Copy_Routine
Prev: D61E Up: Map Next: D71E