![]() |
Routines |
| Prev: 47412 | Up: Map | Next: 47465 |
|
Used by the routines at RemoveEntity and DisplayEntity.
Gets the registers ready to draw the sprite of an entity at its old position, which was saved 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_0 is changed so that the unrolled code that follows it draws the right number of bytes for each row, and the number of rows is stored in Old_Sprite_Row_Count.
|
||||||||||||||
| PrepDraw23 | 47417 | CALL GetSpriteA | Fetch the address of the sprite data in DE. | |||||||||||
| 47420 | LD HL,(38560) | Fetch the old X position into L and the old Y position into H from Previous_X_Position. | ||||||||||||
| 47423 | LD A,L | A=L. | ||||||||||||
| 47424 | DEC A | Subtract one. | ||||||||||||
| 47425 | RLCA | Multiply by two (rotate left). | ||||||||||||
| 47426 | AND %00001110 | Keep only bits 1-3. | ||||||||||||
| 47428 | OR %11110000 | Set bits 4-7 to point at the pages 240 to 255. | ||||||||||||
| 47430 | LD B,A | Store the page of the shift table in B. | ||||||||||||
| 47431 | LD A,(DE) | Fetch the width of the sprite in bytes. | ||||||||||||
| 47432 | INC DE | Move on to the height of the sprite. | ||||||||||||
| 47433 | NEG | Negate the width. | ||||||||||||
| 47435 | AND %00000111 | Keep only bits 0-2. | ||||||||||||
| 47437 | ADD A,A | Multiply by four. | ||||||||||||
| 47438 | ADD A,A | |||||||||||||
| 47439 | LD C,A | Store the result in C. | ||||||||||||
| 47440 | ADD A,A | Multiply by two. | ||||||||||||
| 47441 | ADD A,C | Add the result so that it is multiplied by twelve (the size of the code for one byte of the row). | ||||||||||||
| 47442 | LD C,A | Store the offset in C. | ||||||||||||
| 47443 | LD A,L | A=L. | ||||||||||||
| 47444 | AND %00000111 | Keep only the pixel offset (bits 0-2). | ||||||||||||
| 47446 | LD A,C | Fetch the offset. | ||||||||||||
| 47447 | JR NZ,PrepDraw23_SetJump | Jump to PrepDraw23_SetJump if the sprite does not start on a character boundary. | ||||||||||||
| 47449 | 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 | 47451 | LD (47635),A | Change the operand of the jump at DrawOldEntityRow_0. | |||||||||||
| 47454 | LD A,(DE) | Fetch the height of the sprite. | ||||||||||||
| 47455 | INC DE | Move on to the pixel data. | ||||||||||||
| 47456 | LD (38563),A | Write the number of rows of the old sprite to Old_Sprite_Row_Count. | ||||||||||||
| 47459 | CALL ScreenAddress | Convert the position into the screen address. | ||||||||||||
| 47462 | LD C,0 | C=0. | ||||||||||||
| 47464 | RET | Return. | ||||||||||||
|
View the equivalent code in;
|
||||||||||||||
| Prev: 47412 | Up: Map | Next: 47465 |