Prev: 6414 Up: Map Next: 6440
6424: Copy Level Data to Level Buffer
Used by the routine at InitialiseLevel.
Input
HL Source data pointer
DE Destination buffer pointer
CopyLevelDataToBuffer 6424 LD C,$05 Set a counter in C for 05 rows to copy.
CopyLevelDataToBuffer_CopyRow 6426 LD B,$20 Set a counter in B for 20 bytes per row.
CopyLevelDataToBuffer_CopyByte 6428 LD A,(HL) Fetch a byte from the source data.
6429 INC HL Move to the next source data byte.
642A LD (DE),A Write the byte to the destination buffer.
642B INC E Move to the next destination buffer position.
642C DJNZ CopyLevelDataToBuffer_CopyByte Decrease the bytes-per-row counter by one and loop back to CopyLevelDataToBuffer_CopyByte until the whole row has been copied.
Handle updating the destination pointer positioning after each row.
642E DEC E Step back one position.
642F LD A,E Keep only the upper 3 bits of the E co-ordinate.
6430 AND %11100000
6432 LD E,A
6433 INC D Move down one row.
6434 DEC C Decrease the row counter by one.
6435 JR NZ,CopyLevelDataToBuffer_CopyRow Jump back to CopyLevelDataToBuffer_CopyRow until all the rows have been copied.
Adjust the destination pointer after copying a complete block.
6437 ADD A,$20 Move to the next block horizontally.
6439 LD E,A Load the new horizontal position into E.
643A RET Z Return if E wrapped around to 00 (reached the end of the buffer).
Move the destination pointer back up 05 rows to the original vertical position.
643B LD A,D D-=05.
643C SUB $05
643E LD D,A
643F RET Return.
Prev: 6414 Up: Map Next: 6440