Prev: 40955 Up: Map Next: 41060
40974: Set Entity Attributes
Used by the routines at DrawInventory and MenuIcons.
Input
IX The entity to colour
SetEntityAttributes 40974 LD A,(IX+3) Write the entity X position to Saved_X.
40977 LD (24086),A
40980 LD A,(IX+4) Write the entity X position to Saved_Y.
40983 LD (24087),A
This entry point is used by the routines at HandlerWeapon, HandlerBatlet, HandlerKnight and HandlerCaveDoorLocked.
SetEntityAttributes_0 40986 LD L,(IX+3) HL=Entity screen position.
40989 LD H,(IX+4)
40992 LD D,(IX+5) D=Entity attribute.
40995 LD A,(24090) E=Room attribute.
40998 LD E,A
40999 LD A,(24080) B=Entity width in bytes.
41002 LD B,A
41003 LD A,(24081) A=Entity height in pixels.
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 Store the result in C.
41014 PUSH BC Stash BC on the stack.
41015 LD B,0 B=0.
41017 LD A,(24086) Compare Saved_X against L to see if the X position is unchanged.
41020 CP L
41021 JR Z,SetEntityAttributes_2 If it hasn't changed then jump to SetEntityAttributes_2.
41023 JR C,SetEntityAttributes_1 If the entity has moved left then jump to SetEntityAttributes_1.
41025 INC B B=B + 1.
SetEntityAttributes_1 41026 INC B B=B + 1.
SetEntityAttributes_2 41027 LD A,(24087) Compare Saved_Y against H to see if the Y position is unchanged.
41030 CP H
41031 LD A,B A=B.
41032 JR Z,SetEntityAttributes_4 If it hasn't changed then jump to SetEntityAttributes_4.
41034 JR C,SetEntityAttributes_3 If the entity has moved up then jump to SetEntityAttributes_3.
41036 ADD A,4 A=A + 4.
SetEntityAttributes_3 41038 ADD A,4 A=A + 4.
SetEntityAttributes_4 41040 LD B,A Stash the result in B.
41041 CALL AttributeAddress Call AttributeAddress.
41044 LD A,B Restore the result back into A.
41045 POP BC
41046 PUSH HL
41047 LD HL,41060 HL=AttributeJumpTable.
41050 SLA A A=A * 2.
41052 CALL HandlerCaveDoorLocked_1 Call HandlerCaveDoorLocked_1.
41055 LD A,(HL) HL=attribute routine selected from AttributeJumpTable.
41056 INC HL
41057 LD H,(HL)
41058 LD L,A
41059 JP (HL) Indirect jump to the address held in HL.
Prev: 40955 Up: Map Next: 41060