![]() |
Routines |
| Prev: D4EA | Up: Map | Next: D54A |
|
Used by the routine at InitialiseGame.
Builds ShiftTables, ReversedShiftTables and ReverseTable, which the routines for drawing sprites use. Each table is a page, which has an entry for each value of a byte at the low byte of the address. For a byte which is moved to the right along a row by six pixels, page FE has the part which stays in the byte and page FF has the part which moves into the next byte. Pages FC and FD are the same for four pixels, and pages FA and FB for two. Pages F6 and F7 F4 and F5 and F2 and F3 are the same for the byte with its bits turned round, which is used for sprites which are reflected. ReverseTable has each byte with its bits turned round.
|
||||
|
Build ShiftTables.
|
||||
| BuildShiftTables | D4FD | LD L,$00 | Start with the byte at 00. | |
| BuildShiftTables_Normal | D4FF | LD D,$00 | Make the word the byte. | |
| D501 | LD E,L | |||
| D502 | LD H,$FF | Start at page FF. | ||
| D504 | LD B,$03 | Set a count of 03 pairs. | ||
|
Shift the word left by two bits and store it.
|
||||
| BuildShiftTables_NormalLoop | D506 | SLA E | Shift the word left by two bits. | |
| D508 | RL D | |||
| D50A | SLA E | |||
| D50C | RL D | |||
| D50E | LD (HL),E | Store the pair in the next two pages. | ||
| D50F | DEC H | |||
| D510 | LD (HL),D | |||
| D511 | DEC H | |||
| D512 | DJNZ BuildShiftTables_NormalLoop | Jump to BuildShiftTables_NormalLoop if there are any left. | ||
| D514 | INC L | Move on to the next byte. | ||
| D515 | JR NZ,BuildShiftTables_Normal | Jump to BuildShiftTables_Normal if there are any left. | ||
|
Build ReversedShiftTables.
|
||||
| D517 | LD L,$00 | Start with the byte at 00. | ||
| BuildShiftTables_Reversed | D519 | LD D,$00 | Clear the high byte of the word. | |
| D51B | LD B,$08 | Set a count of 08 bits, and copy the byte into A. | ||
| D51D | LD A,L | |||
|
Turn the bits of the byte round.
|
||||
| BuildShiftTables_Reverse | D51E | RRCA | Move the next bit into C from the other end. | |
| D51F | RL C | |||
| D521 | DJNZ BuildShiftTables_Reverse | Jump to BuildShiftTables_Reverse if there are any left. | ||
| D523 | LD E,C | Make the low byte the reversed byte. | ||
| D524 | LD H,$F7 | Start at page F7. | ||
| D526 | LD B,$03 | Set a count of 03 pairs. | ||
|
Shift the word left by two bits and store it.
|
||||
| BuildShiftTables_ReversedLoop | D528 | SLA E | Shift the word left by two bits. | |
| D52A | RL D | |||
| D52C | SLA E | |||
| D52E | RL D | |||
| D530 | LD (HL),E | Store the pair in the next two pages. | ||
| D531 | DEC H | |||
| D532 | LD (HL),D | |||
| D533 | DEC H | |||
| D534 | DJNZ BuildShiftTables_ReversedLoop | Jump to BuildShiftTables_ReversedLoop if there are any left. | ||
| D536 | INC L | Move on to the next byte. | ||
| D537 | JR NZ,BuildShiftTables_Reversed | Jump to BuildShiftTables_Reversed if there are any left. | ||
|
Build ReverseTable.
|
||||
| D539 | LD HL,$F900 | Point HL at ReverseTable. | ||
| BuildShiftTables_ReverseTable | D53C | LD D,L | Copy the byte into D, and set a count of 08 bits. | |
| D53D | LD B,$08 | |||
| BuildShiftTables_ReverseBits | D53F | SRL D | Move the lowest bit of the byte into the other end of E. | |
| D541 | RL E | |||
| D543 | DJNZ BuildShiftTables_ReverseBits | Jump to BuildShiftTables_ReverseBits if there are any left. | ||
| D545 | LD (HL),E | Store the byte turned round. | ||
| D546 | INC L | Move on to the next byte. | ||
| D547 | JR NZ,BuildShiftTables_ReverseTable | Jump to BuildShiftTables_ReverseTable if there are any left. | ||
| D549 | RET | Return. | ||
|
View the equivalent code in;
|
||||
| Prev: D4EA | Up: Map | Next: D54A |