Prev: ADD8 Up: Map Next: AF01
AE98: Set Object Attributes
Works out the area of attribute cells that is covered by the sprite that has just been drawn, as a width and height in cells, and fills it with the attribute at AF03 by calling FillAttributes.
SetObjectAttributes AE98 LD A,($A1D8) The rows of the sprite.
AE9B DEC A Step A back.
AE9C RET M Return if the sign flag is set.
AE9D LD D,A D=A.
AE9E LD HL,($A1D5) Fetch the word at A1D5 into HL.
AEA1 LD A,($5C29) The width of the sprite in bytes.
AEA4 LD B,A B=A.
AEA5 LD A,($A2FA) The sprite reaches past the right of the screen.
AEA8 AND A Jump to SetObjectAttributes_Width if A is zero.
AEA9 JR Z,SetObjectAttributes_Width
AEAB LD A,L A=L.
AEAC ADD A,B A gains B.
AEAD SUB $A4 Subtract A4 from A.
AEAF LD L,$08 L=08.
AEB1 JR SetObjectAttributes_Cells Jump to SetObjectAttributes_Cells.
SetObjectAttributes_Width AEB3 LD A,L A=L.
AEB4 CP $08 Jump to SetObjectAttributes_Right if A is 08 or more.
AEB6 JR NC,SetObjectAttributes_Right
AEB8 ADD A,$08 Add 08 to A.
AEBA LD L,A L=A.
AEBB LD A,B A=B.
AEBC SUB $08 Subtract 08 from A.
AEBE LD B,A B=A.
SetObjectAttributes_Right AEBF LD A,L A=L.
AEC0 ADD A,$17 Add 17 to A.
AEC2 ADD A,B A gains B.
AEC3 JR NC,SetObjectAttributes_Aligned Jump to SetObjectAttributes_Aligned if the carry flag is clear.
AEC5 LD A,$EE A=EE.
AEC7 SUB L Subtract L from A.
AEC8 JR SetObjectAttributes_Cells Jump to SetObjectAttributes_Cells.
SetObjectAttributes_Aligned AECA LD A,L A=L.
AECB AND %00000111 Keep the bits of A that are set in 07.
AECD JR Z,SetObjectAttributes_Sum Jump to SetObjectAttributes_Sum if the zero flag is set.
AECF LD A,B A=B.
AED0 ADD A,$08 Add 08 to A.
AED2 LD B,A B=A.
This entry point is used by the routine at DrawShot.
SetObjectAttributes_Sum AED3 LD A,L A=L.
AED4 ADD A,B A gains B.
AED5 SUB L Subtract L from A.
SetObjectAttributes_Cells AED6 SRL A Shift A right.
AED8 SRL A Shift A right.
AEDA SRL A Shift A right.
AEDC LD ($AF01),A Update the attribute area.
AEDF DEC A Step A back.
AEE0 RET M Return if the sign flag is set.
This entry point is used by the routine at SetPairAttributes.
SetObjectAttributes_Height AEE1 LD A,H A=H.
AEE2 SUB D Subtract D from A.
AEE3 SUB $07 Subtract 07 from A.
AEE5 LD E,A E=A.
AEE6 CP $17 Jump to SetObjectAttributes_Rows if A is 17 or more.
AEE8 JR NC,SetObjectAttributes_Rows
AEEA LD E,$17 E=17.
SetObjectAttributes_Rows AEEC LD A,H A=H.
AEED OR %00000111 Set the bits of A that are set in 07.
AEEF SUB E Subtract E from A.
AEF0 SRL A Shift A right.
AEF2 SRL A Shift A right.
AEF4 SRL A Shift A right.
AEF6 LD ($AF02),A The height of the attribute area.
AEF9 DEC A Step A back.
AEFA RET M Return if the sign flag is set.
AEFB LD DE,$AF01 The attribute area.
AEFE JP FillAttributes Jump to FillAttributes.
Prev: ADD8 Up: Map Next: AF01