Prev: 851E Up: Map Next: 8568
853D: Remap Alien Sprite
Used by the routines at FetchSprite and FetchActorSprite.
On odd levels, FetchSprite and FetchActorSprite pass the sprite ID here so four alien families can be drawn from Sprite_Band_Table instead of SpritesTable. Any other ID is returned unchanged, and the caller keeps SpritesTable.
Sprite IDs Family Sprite_Band_Table Index
40-47 Brella 01-08
48-4F Blob 09-10
88-8F Block 11-18
B0-B5 Spinner 19-1E
Input
A Sprite ID
Output
A Sprite ID, or a 1-based index into Sprite_Band_Table
BC Sprite_Band_Table when the ID is one of the remapped families
Test the four odd-level alien ID ranges.
MapSpriteBand 853D LD L,A Stash the original sprite ID.
853E SUB $40 Drop 40 and test for brella IDs 40-47.
8540 CP $08
8542 LD H,$00 Jump to MapSpriteBand_Matched with table offset 00 if it matches.
8544 JR C,MapSpriteBand_Matched
8546 SUB $08 Drop another 08.
8548 LD H,$08 Set the table offset to 08.
854A CP $08 Jump to MapSpriteBand_Matched if it is now a blob ID 48-4F.
854C JR C,MapSpriteBand_Matched
854E SUB $40 Drop 40 and test for block IDs 88-8F.
8550 CP $08
8552 LD H,$10 Jump to MapSpriteBand_Matched with table offset 10 if it matches.
8554 JR C,MapSpriteBand_Matched
8556 SUB $28 Drop 28 and test for spinner IDs B0-B5.
8558 CP $06
855A LD H,$18 Jump to MapSpriteBand_Matched with table offset 18 if it matches.
855C JR C,MapSpriteBand_Matched
855E LD A,L Return the original sprite ID if no family matched.
855F RET
Build the Sprite_Band_Table index and return that table pointer.
MapSpriteBand_Matched 8560 AND %00000111 Keep only the frame within the family.
8562 ADD A,H Add the table offset and make the index 1-based.
8563 INC A
8564 LD BC,$EE7A Point BC at Sprite_Band_Table.
8567 RET Return.
Prev: 851E Up: Map Next: 8568