![]() |
Routines |
| Prev: 38482 | Up: Map | Next: 38537 |
|
Used by the routines at RemoveEntity and DisplayEntity.
Gets the registers ready to draw the sprite at its old position, which was stored by StoreEntity.
The shift table page is put in B, the screen address of the bottom row is put in HL, and the pointer to the pixel data is put in DE. The operand of the jump at DrawOldEntityRow_Jump is changed so that the unrolled code at DrawOldEntityRow draws the right number of bytes for each row, and the number of rows is stored in Old_Sprite_Row_Count.
|
||||||||||||||
| PrepDraw23 | 38487 | CALL GetSpriteA | Fetch the address of the sprite data in DE. | |||||||||||
| 38490 | LD HL,(36580) | Fetch the old x position into L and the old y position into H. | ||||||||||||
| 38493 | LD A,L | Copy the x position to A. | ||||||||||||
| 38494 | DEC A | Subtract one. | ||||||||||||
| 38495 | RLCA | Multiply by two (rotate left). | ||||||||||||
| 38496 | AND %00001110 | Keep only the bits of the pixel offset (bits 1-3). | ||||||||||||
| 38498 | OR %11110000 | Set bits 4-7 to point at the pages 240 to 255. | ||||||||||||
| 38500 | LD B,A | Store the page of the shift table in B. | ||||||||||||
| 38501 | LD A,(DE) | Fetch the width of the sprite in bytes. | ||||||||||||
| 38502 | INC DE | Move on to the height of the sprite. | ||||||||||||
| 38503 | NEG | Negate the width. | ||||||||||||
| 38505 | AND %00001111 | Keep only the low four bits. | ||||||||||||
| 38507 | SUB 7 | Subtract 7 (which leaves 9 minus the width, the number of unused pieces of the unrolled code). | ||||||||||||
| 38509 | ADD A,A | Multiply by four. | ||||||||||||
| 38510 | ADD A,A | |||||||||||||
| 38511 | LD C,A | Store the result in C. | ||||||||||||
| 38512 | ADD A,A | Multiply by two. | ||||||||||||
| 38513 | ADD A,C | Add the result so that it is multiplied by twelve (the size of the code for one byte of the row). | ||||||||||||
| 38514 | LD C,A | Store the offset in C. | ||||||||||||
| 38515 | LD A,L | Copy the x position to A. | ||||||||||||
| 38516 | AND %00000111 | Keep only the pixel offset. | ||||||||||||
| 38518 | LD A,C | Fetch the offset. | ||||||||||||
| 38519 | JR NZ,PrepDraw23_SetJump | Jump to PrepDraw23_SetJump if the sprite does not start on a character boundary. | ||||||||||||
| 38521 | ADD A,6 | Add 6 to the offset to skip the first six bytes of the code for the first byte of the row, as no cell to the left is needed. | ||||||||||||
| PrepDraw23_SetJump | 38523 | LD (38753),A | Change the operand of the jump at DrawOldEntityRow_Jump. | |||||||||||
| 38526 | LD A,(DE) | Fetch the height of the sprite. | ||||||||||||
| 38527 | INC DE | Move on to the pixel data. | ||||||||||||
| 38528 | LD (36578),A | Store the number of rows of the old sprite in Old_Sprite_Row_Count. | ||||||||||||
| 38531 | CALL ScreenAddress | Convert the position into the screen address. | ||||||||||||
| 38534 | LD C,0 | C=0. | ||||||||||||
| 38536 | RET | Return. | ||||||||||||
|
View the equivalent code in;
|
||||||||||||||
| Prev: 38482 | Up: Map | Next: 38537 |