![]() |
Routines |
| Prev: 54908 | Up: Map | Next: 54985 |
|
Used by the routine at InitialiseGame.
Builds the two tables that the sprite routines use. The first is the set of tables of shifted bytes in pages 242 to 255: for each shift of one to seven bits to the right there is a page with the inverse of every byte shifted, and a page after it with the inverse of the bits that are pushed out into the next byte. The second is the table at ReversedByteTable of every byte with its bits reversed.
|
||||
|
Build the shifted-byte tables, then the reversed-byte table.
|
||||
| BuildLookupTables | 54942 | LD L,0 | Start with the byte zero. | |
| BuildLookupTables_Shift | 54944 | LD D,0 | Clear the high byte of the shifted value. | |
| 54946 | LD E,L | Set the low byte of the shifted value to the byte. | ||
| 54947 | LD H,255 | Point H at the last page of the table. | ||
| 54949 | LD B,7 | Set the number of shifts to 7. | ||
| BuildLookupTables_Shift_Step | 54951 | SLA E | Shift the value left one bit. | |
| 54953 | RL D | Shift the carry into the high byte. | ||
| 54955 | LD A,E | Fetch the low byte. | ||
| 54956 | CPL | Invert it. | ||
| 54957 | LD (HL),A | Store it in the table. | ||
| 54958 | DEC H | Go to the page before. | ||
| 54959 | LD A,D | Fetch the high byte. | ||
| 54960 | CPL | Invert it. | ||
| 54961 | LD (HL),A | Store it in the table. | ||
| 54962 | DEC H | Go to the page before. | ||
| 54963 | DJNZ BuildLookupTables_Shift_Step | Jump to BuildLookupTables_Shift_Step until all of the shifts are done. | ||
| 54965 | INC L | Go on to the next byte. | ||
| 54966 | JR NZ,BuildLookupTables_Shift | Jump to BuildLookupTables_Shift until all of the bytes are done. | ||
| 54968 | LD HL,61696 | Point HL at ReversedByteTable. | ||
|
Reverse the bits of every byte into ReversedByteTable.
|
||||
| BuildLookupTables_Reverse | 54971 | LD D,L | Take the byte that is to be reversed. | |
| 54972 | LD B,8 | Set the number of bits to 8. | ||
| BuildLookupTables_Reverse_Bit | 54974 | SRL D | Shift a bit out of the byte. | |
| 54976 | RL E | Shift it into the reversed byte. | ||
| 54978 | DJNZ BuildLookupTables_Reverse_Bit | Jump to BuildLookupTables_Reverse_Bit until all of the bits are done. | ||
| 54980 | LD (HL),E | Store the reversed byte in the table. | ||
| 54981 | INC L | Go on to the next byte. | ||
| 54982 | JR NZ,BuildLookupTables_Reverse | Jump to BuildLookupTables_Reverse until all of the bytes are done. | ||
| 54984 | RET | Return. | ||
| Prev: 54908 | Up: Map | Next: 54985 |