![]() |
Routines |
| Prev: 40955 | Up: Map | Next: 41060 |
|
Used by the routines at DrawInventoryItem and MenuIcons.
Colours the attribute cells under an entity. This entry point first saves the position of the entity as if it has not moved; SetEntityAttributes_Moved instead uses the position saved by StoreEntity to work out which way the entity has moved.
The cells under the entity are set to the attribute of the entity, and the cells which the entity has just left behind are put back to the attribute of the room (from CurrentRoom_Attribute). Which way the entity has moved picks one of the routines in the table at AttributeJumpTable, and that routine is jumped to with the registers set up as follows:
|
||||||||||||||||||||
|
||||||||||||||||||||
| SetEntityAttributes | 40974 | LD A,(IX+3) | Write the entity X position to Previous_X_Position. | |||||||||||||||||
| 40977 | LD (24086),A | |||||||||||||||||||
| 40980 | LD A,(IX+4) | Write the entity Y position to Previous_Y_Position. | ||||||||||||||||||
| 40983 | LD (24087),A | |||||||||||||||||||
|
This entry point is used by the routines at HandlerWeapon, PopCreature, HandlerKnight, SetItemAttributes and PickUpItem.
Get the entity position, attribute and the room attribute.
|
||||||||||||||||||||
| SetEntityAttributes_Moved | 40986 | LD L,(IX+3) | L=the entity X position, and H=the entity Y position. | |||||||||||||||||
| 40989 | LD H,(IX+4) | |||||||||||||||||||
| 40992 | LD D,(IX+5) | Fetch the attribute of the entity. | ||||||||||||||||||
| 40995 | LD A,(24090) | E=the room attribute from CurrentRoom_Attribute. | ||||||||||||||||||
| 40998 | LD E,A | |||||||||||||||||||
| 40999 | LD A,(24080) | B=the width of the sprite from SpriteWidth. | ||||||||||||||||||
| 41002 | LD B,A | |||||||||||||||||||
|
Work out the number of rows of cells from the height of the sprite in pixels.
|
||||||||||||||||||||
| 41003 | LD A,(24081) | A=the height of the sprite from SpriteHeight. | ||||||||||||||||||
| 41006 | RRCA | Divide by 4. | ||||||||||||||||||
| 41007 | RRCA | |||||||||||||||||||
| 41008 | INC A | Increment A by one. | ||||||||||||||||||
| 41009 | RRCA | Divide by 2. | ||||||||||||||||||
| 41010 | AND %00011111 | Keep only bits 0-4. | ||||||||||||||||||
| 41012 | INC A | Increment A by one. | ||||||||||||||||||
| 41013 | LD C,A | Keep the number of rows of cells in C. | ||||||||||||||||||
|
Work out which way the entity has moved. The horizontal movement gives 0 (none), 1 (right) or 2 (left), and the vertical movement adds 0 (none), 4 (down) or 8 (up).
|
||||||||||||||||||||
| 41014 | PUSH BC | Stash the width and the number of rows on the stack. | ||||||||||||||||||
| 41015 | LD B,0 | B=0 (the direction so far, which is no movement). | ||||||||||||||||||
| 41017 | LD A,(24086) | Fetch the previous X position from Previous_X_Position. | ||||||||||||||||||
| 41020 | CP L | Jump to SetEntityAttributes_Vertical if the X position is unchanged. | ||||||||||||||||||
| 41021 | JR Z,SetEntityAttributes_Vertical | |||||||||||||||||||
| 41023 | JR C,SetEntityAttributes_Right | Jump to SetEntityAttributes_Right if the entity has moved right. | ||||||||||||||||||
| 41025 | INC B | Add 1 to B (the entity has moved left). | ||||||||||||||||||
| SetEntityAttributes_Right | 41026 | INC B | Add 1 to B. | |||||||||||||||||
| SetEntityAttributes_Vertical | 41027 | LD A,(24087) | Fetch the previous Y position from Previous_Y_Position. | |||||||||||||||||
| 41030 | CP H | Compare the saved Y position against H. | ||||||||||||||||||
| 41031 | LD A,B | Fetch the horizontal direction from B. | ||||||||||||||||||
| 41032 | JR Z,SetEntityAttributes_Select | Jump to SetEntityAttributes_Select if the Y position is unchanged. | ||||||||||||||||||
| 41034 | JR C,SetEntityAttributes_Down | Jump to SetEntityAttributes_Down if the entity has moved down. | ||||||||||||||||||
| 41036 | ADD A,4 | Add 4 to A (the entity has moved up). | ||||||||||||||||||
| SetEntityAttributes_Down | 41038 | ADD A,4 | Add 4 to A. | |||||||||||||||||
| SetEntityAttributes_Select | 41040 | LD B,A | Stash the direction in B. | |||||||||||||||||
| 41041 | CALL AttributeAddress | Call AttributeAddress to get the attribute address of the position. | ||||||||||||||||||
| 41044 | LD A,B | Restore the direction into A. | ||||||||||||||||||
| 41045 | POP BC | Restore the width and the number of rows from the stack. | ||||||||||||||||||
| 41046 | PUSH HL | Stash the attribute address on the stack. | ||||||||||||||||||
| 41047 | LD HL,41060 | Point HL at the attribute jump table at AttributeJumpTable. | ||||||||||||||||||
| 41050 | SLA A | Multiply the direction by 2 as the table contains addresses. | ||||||||||||||||||
| 41052 | CALL AddAToHL | Call AddAToHL to add it to the address of the table. | ||||||||||||||||||
| 41055 | LD A,(HL) | Fetch the routine selected from the table. | ||||||||||||||||||
| 41056 | INC HL | |||||||||||||||||||
| 41057 | LD H,(HL) | |||||||||||||||||||
| 41058 | LD L,A | |||||||||||||||||||
| 41059 | JP (HL) | Jump to the routine. | ||||||||||||||||||
| Prev: 40955 | Up: Map | Next: 41060 |