Prev: 52004 Up: Map Next: 52064
52009: Choose Figure Sprites
Used by the routines at HandleOutlaw and HandleSheriff.
Chooses the sprite numbers for a figure of three sprites, from the walking frame and FigureSpriteNumbers. Bit 2 of the walking frame chooses the second set. Types other than 1 and 10 use a horse for the middle sprite.
Input
IX The address of the figure
Output
E The number of the sprite for the lower part
D The number of the sprite for the middle part
B The vertical offset for the sprite for the top part
C The vertical offset for the sprite for the middle part
A' The number of the sprite for the top part
Fetch the lower and middle sprites from FigureSpriteNumbers.
ChooseFigureSprites 52009 LD L,(IX+12) Fetch the walking frame into HL.
52012 LD H,0
52014 ADD HL,HL Double it.
52015 LD BC,51559 Point BC at FigureSpriteNumbers.
52018 ADD HL,BC Find the entry.
52019 LD E,(HL) Fetch the lower and middle sprites.
52020 INC HL
52021 LD D,(HL)
Choose the vertical offsets from bit 2 of the walking frame.
52022 LD A,(IX+12) Fetch the walking frame.
52025 BIT 2,A Test bit 2.
52027 LD BC,6671 Use 26 for the top and 15 for the middle.
52030 JR NZ,ChooseFigureSprites_Top Jump to ChooseFigureSprites_Top if bit 2 is set.
52032 LD BC,6413 Use 25 for the top and 13 for the middle.
Make the top sprite 14 or 15.
ChooseFigureSprites_Top 52035 RRCA Move bit 2 into bit 0.
52036 RRCA
52037 AND %00000001 Keep only that bit.
52039 ADD A,14 Add 14.
52041 EX AF,AF' Keep it in A'.
Types 1 and 10 keep these sprites.
52042 LD A,(IX+0) Fetch the type.
52045 CP 1 Return if the type is 1.
52047 RET Z
52048 CP 10 Return if the type is 10.
52050 RET Z
Use a horse for the middle sprite.
52051 LD BC,6409 Use 25 for the top and 9 for the middle.
52054 LD A,D Fetch the middle sprite.
52055 SUB 23 Subtract 23.
52057 RRCA Move bit 1 into bit 0.
52058 AND %00000001 Keep only that bit.
52060 ADD A,52 Add 52.
52062 LD D,A Set the middle sprite and return.
52063 RET
Prev: 52004 Up: Map Next: 52064