Prev: 53283 Up: Map Next: 53310
53292: 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 53292 AND A Jump to AddSignedToHL_Negative if the number is negative.
53293 JP M,AddSignedToHL_Negative
53296 ADD A,L Add the number to the low byte.
53297 LD L,A
53298 LD A,H Add the carry to the high byte.
53299 ADC A,0
53301 LD H,A
53302 RET Return.
Add the number when it is negative.
AddSignedToHL_Negative 53303 ADD A,L Add the number to the low byte.
53304 LD L,A
53305 LD A,H Subtract one from the high byte if there is no carry.
53306 ADC A,255
53308 LD H,A
53309 RET Return.
Prev: 53283 Up: Map Next: 53310