Prev: D023 Up: Map Next: D03E
D02C: Add Signed To HL
Used by the routine at DrawSpriteList.
Adds a signed number to HL.
Input
A The number
HL The word
Output
HL The sum
Add the number when it is not negative.
AddSignedToHL D02C AND A Jump to AddSignedToHL_Negative if the number is negative.
D02D JP M,AddSignedToHL_Negative
D030 ADD A,L Add the number to the low byte.
D031 LD L,A
D032 LD A,H Add the carry to the high byte.
D033 ADC A,$00
D035 LD H,A
D036 RET Return.
Add the number when it is negative.
AddSignedToHL_Negative D037 ADD A,L Add the number to the low byte.
D038 LD L,A
D039 LD A,H Subtract one from the high byte if there is no carry.
D03A ADC A,$FF
D03C LD H,A
D03D RET Return.
Prev: D023 Up: Map Next: D03E