Prev: 9609 Up: Map Next: 962A
9613: Build Shift Table
Used by the routine at Select_Game_Options.
Builds the tables that the sprite routines use to shift a byte of sprite data to any pixel position.
For every byte value L from 00 to FF the table holds eight words, which are the byte shifted left by zero to seven bits. For a shift of n bits, the low byte of the word is stored at FF00 less 0200 times n, plus L, and the high byte is stored in the page below it. The tables use the pages from F0 to FF.
The sprite routines select a table with B (which is always an even page) and read the high byte with B and the low byte with B+01.
BuildShiftTable 9613 LD L,$00 Start with the byte value 00.
BuildShiftTable_Value 9615 LD D,$00 Clear the high byte of the shifted word.
9617 LD E,L Start the low byte of the shifted word with the byte value.
9618 LD H,$FF Start at the page of the first low byte (FF).
961A LD B,$08 Set the number of pixel offsets to build to 08.
BuildShiftTable_Offset 961C LD (HL),E Store the low byte of the shifted word.
961D DEC H Move down to the page of the high byte.
961E LD (HL),D Store the high byte of the shifted word.
961F DEC H Move down to the page of the next low byte.
9620 SLA E Shift the word left by one bit.
9622 RL D
9624 DJNZ BuildShiftTable_Offset Decrease the shift counter and loop back until all eight shifts are stored.
9626 INC L Move on to the next byte value.
9627 JR NZ,BuildShiftTable_Value Jump back to BuildShiftTable_Value until all of the byte values have been done.
9629 RET Return.
View the equivalent code in;
Prev: 9609 Up: Map Next: 962A