Prev: AB44 Up: Map Next: ABD6
ABC2: Copy Room Data
Input
B Length of data to be copied
DE The room buffer target destination
HL Pointer to the room data we want to copy
This routine copies the number of bytes given by B, from *HL to *DE, and keeps on looping until a termination character is returned.
CopyRoomData ABC2 PUSH BC Stash the length counter on the stack.
ABC3 LD A,(HL) Fetch a byte from the source room data pointer and store it in A.
Have we finished with everything?
ABC4 CP $FF If the terminator character (FF) has been reached jump to CopyRoomData_Next.
ABC6 JR Z,CopyRoomData_Next
Handle copying the data from the source room data to the target room buffer.
CopyRoomData_Loop ABC8 LD (DE),A Write the room data byte to the room buffer target destination.
ABC9 INC HL Increment the source room data pointer by one.
ABCA INC DE Increment the room buffer target destination by one.
ABCB LD A,(HL) Fetch a byte from the source room data pointer and store it in A.
ABCC DJNZ CopyRoomData_Loop Decrease the length counter by one and loop back to CopyRoomData_Loop until the length counter is zero.
Refresh the same counter as on entry to the routine and start the process again.
ABCE POP BC Restore the original length counter from the stack.
ABCF JR CopyRoomData Jump to CopyRoomData.
This cycle is now over, so store the terminator in the room buffer, increment both pointers ready for the next call to this routine and finally, tidy up the stack.
CopyRoomData_Next ABD1 LD (DE),A Write the termination character to the room buffer target destination.
ABD2 INC DE Increment the room buffer target destination by one.
ABD3 INC HL Increment the source room data pointer by one.
ABD4 POP BC Housekeeping; discard the length counter from the stack.
ABD5 RET Return.
Prev: AB44 Up: Map Next: ABD6