Prev: 38409 Up: Map Next: 38442
38419: 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 0 to 255 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 65280 less 512 times n, plus L, and the high byte is stored in the page below it. The tables use the pages from 240 to 255.
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+1.
BuildShiftTable 38419 LD L,0 Start with the byte value 0.
BuildShiftTable_Value 38421 LD D,0 Clear the high byte of the shifted word.
38423 LD E,L Start the low byte of the shifted word with the byte value.
38424 LD H,255 Start at the page of the first low byte (255).
38426 LD B,8 Set the number of pixel offsets to build to 8.
BuildShiftTable_Offset 38428 LD (HL),E Store the low byte of the shifted word.
38429 DEC H Move down to the page of the high byte.
38430 LD (HL),D Store the high byte of the shifted word.
38431 DEC H Move down to the page of the next low byte.
38432 SLA E Shift the word left by one bit.
38434 RL D
38436 DJNZ BuildShiftTable_Offset Decrease the shift counter and loop back until all eight shifts are stored.
38438 INC L Move on to the next byte value.
38439 JR NZ,BuildShiftTable_Value Jump back to BuildShiftTable_Value until all of the byte values have been done.
38441 RET Return.
View the equivalent code in;
Prev: 38409 Up: Map Next: 38442