Prev: 26923 Up: Map Next: 27026
26924: Draw Sprite Object
Used by the routines at Handler: PlayerSprite and 30423.
Input
DE Sprite screen position
A Sprite frame ID
C Sprite colour
DrawSpriteObject 26924 LD B,A Store the sprite frame ID in B.
26925 LD A,C Load the sprite attribute value into A.
26926 EXX Switch to the shadow registers.
26927 LD HL,(30748) HL'=*SpriteBackgroundBuffer_Pointer.
26930 LD C,A Load the sprite attribute value into C'.
26931 LD A,(30747) Load *ActiveSpriteBlocks into B'.
26934 LD B,A
26935 EXX Switch back to the normal registers.
Calculate the sprite data address from the frame ID.
26936 LD A,B Load L with the frame ID multiplied by 2.
26937 ADD A,A
26938 LD L,A
26939 ADC A,190 Load H with the high byte for the graphics data: 190.
26941 SUB L
26942 LD H,A
26943 LD A,B Load the original frame ID into A.
Fetch the sprite data.
26944 LD C,(HL) C=*HL.
26945 INC L Increment L by one.
26946 LD B,(HL) B=*HL.
26947 BIT 5,A Test bit 5 of A.
26949 JP NZ,28072 Jump to 28072 if {} is not zero.
26952 LD A,(BC) A=*BC.
DrawSpriteObject_0 26953 INC BC Increment BC by one.
26954 ADD A,E A+=E.
26955 LD E,A E=A.
26956 LD A,(BC) A=*BC.
26957 INC BC Increment BC by one.
DrawSpriteObject_1 26958 ADD A,D A+=D.
26959 LD D,A D=A.
26960 CP 16 Jump to DrawSpriteObject_2 if A is higher than 16.
26962 JR NC,DrawSpriteObject_2
26964 LD A,E Jump to DrawSpriteObject_4 if E is lower than 32.
26965 CP 32
26967 JR C,DrawSpriteObject_4
DrawSpriteObject_2 26969 LD HL,8 BC+=0008.
26972 ADD HL,BC
26973 LD B,H
26974 LD C,L
DrawSpriteObject_3 26975 LD A,(BC) A=*BC.
Check for the terminator (255+1 will set the Z flag).
26976 INC A Increment A by one.
26977 LD A,1 A=1.
26979 JR NZ,DrawSpriteObject_1 Jump to DrawSpriteObject_1 if A was not zero (on line 26976).
We reached the terminator.
26981 INC BC Increment BC by one.
26982 LD A,(BC) Jump to DrawSpriteObject_0 if *BC is not equal to 128.
26983 CP 128
26985 JR NZ,DrawSpriteObject_0
26987 JP 26860 Jump to 26860.
DrawSpriteObject_4 26990 LD A,D A=D.
26991 ADD A,64 A+=64.
26993 AND %01001000 Keep only bits 3 and 6.
26995 LD H,A H=A.
26996 LD A,D A=D.
26997 RRCA Rotate A right three positions (bits 0 to 2 are now in positions 5 to 7).
26998 RRCA
26999 RRCA
27000 AND %11100000 Keep only bits 5-7.
27002 ADD A,E A+=E.
27003 LD L,A L=A.
27004 CALL DrawSprite Call DrawSprite.
27007 INC H Increment H by one.
27008 CALL DrawSprite Call DrawSprite.
27011 CALL ScreenBufferToAttributeBuffer Call ScreenBufferToAttributeBuffer.
27014 JR DrawSpriteObject_3 Jump to DrawSpriteObject_3.
27016 LD (30757),A Write A to *30757.
27019 EXX Switch to the shadow registers.
27020 LD (HL),A Write A to *HL.
27021 LD H,B H=B.
27022 LD L,C L=C.
27023 JP ColouriseSprite Jump to ColouriseSprite.
Prev: 26923 Up: Map Next: 27026