Prev: 35980 Up: Map Next: 36165
36023: Handle Player Appearing
The handler for the player (sprite ID 102) while the player is appearing at the start of a life, which is set up by PreparePlayer. While the timer at FlashTimer is running FlashScore counts it down. After that the sprite of the player (the sprite ID at offset 7) is drawn one row more every fourth frame by HandlerPlayerAppearing_DrawRow, while the sound of appearing is made and the colour of the cells changes. When all the rows have been drawn the sprite ID is put back and the handler is no longer used.
Input
IX The player entity
HandlerPlayerAppearing 36023 LD A,(24124) Fetch the timer from FlashTimer.
36026 AND A Jump to FlashScore if the timer is running.
36027 JR NZ,FlashScore
36029 LD A,(23672) Fetch FRAMES.
36032 AND %00000011 Keep only bits 0-1.
36034 JP NZ,HandlerPlayerAppearing_Colour Jump to HandlerPlayerAppearing_Colour unless this is every fourth frame.
36037 INC (IX+6) Increment the number of rows to draw at offset 6.
36040 LD A,(IX+7) Fetch the sprite ID of the player from offset 7.
36043 CALL FetchSprite Call FetchSprite to get the address of the sprite data.
36046 LD A,(DE) Fetch the height of the sprite.
36047 CP (IX+6) Jump to HandlerPlayerAppearing_Finish if all of the rows have been drawn.
36050 JR Z,HandlerPlayerAppearing_Finish
This entry point is used by the routine at HandlerPlayerVanishing.
Draw the row of the sprite that is given by the number of rows. This is done by pointing the entry for the sprite in the table of sprites at the row, and temporarily changing the byte before it to a height of one row.
HandlerPlayerAppearing_DrawRow 36052 PUSH DE Stash the address of the sprite data on the stack.
36053 PUSH HL Stash the address of the entry in the table of sprites on the stack.
36054 LD B,H Keep the address of the table entry in BC.
36055 LD C,L
36056 LD A,(IX+4) Fetch the Y position of the entity.
36059 LD (IX+2),A Save it at offset 2.
36062 SUB (IX+6) Subtract the number of rows.
36065 LD (IX+4),A Update the Y position of the entity.
36068 LD L,(IX+6) Fetch the number of rows.
36071 LD H,0 Clear the high byte of the number of rows in H.
36073 ADD HL,HL Double HL, as there are two bytes in each row.
36074 ADD HL,DE Add the address of the sprite data to HL.
36075 LD A,H Fetch the high byte of the address of the row.
36076 LD (BC),A Write A to the high byte of the table entry.
36077 DEC BC Move BC back to the low byte.
36078 LD A,L Fetch the low byte of the address of the row.
36079 LD (BC),A Write A to the low byte of the table entry.
36080 PUSH HL Stash the address of the row on the stack.
36081 LD C,(HL) Fetch the byte at the address of the row.
36082 LD B,(IX+0) Fetch the sprite ID of the entity.
36085 PUSH BC Stash them on the stack.
36086 LD (HL),1 Write 1 (the height of one row) to the address of the row.
36088 LD A,(IX+7) Fetch the sprite ID of the player from offset 7.
36091 LD (IX+0),A Write it to the sprite ID of the entity.
36094 CALL DrawEntity Call DrawEntity to draw the row.
36097 POP BC Restore the byte and the sprite ID from the stack.
36098 POP HL Restore the address of the row from the stack.
36099 LD (HL),C Write the byte back.
36100 LD (IX+0),B Write the sprite ID back to the entity.
36103 LD A,(IX+2) Fetch the saved Y position from offset 2.
36106 LD (IX+4),A Write it back to the Y position of the entity.
36109 POP HL Restore the address of the table entry from the stack.
36110 POP DE Restore the address of the sprite data from the stack.
36111 LD (HL),D Write the high byte back to the table entry.
36112 DEC HL Move HL back to the low byte.
36113 LD (HL),E Write the low byte back to the table entry.
This entry point is used by the routine at HandlerPlayerVanishing.
Set the colour of the cells that have been drawn so far, which cycles with FRAMES, and make the sound of appearing.
HandlerPlayerAppearing_Colour 36114 LD A,(IX+5) Fetch the attribute of the entity.
36117 PUSH AF Stash it on the stack.
36118 LD A,(23672) Fetch FRAMES.
36121 RRCA Divide FRAMES by four.
36122 RRCA
36123 AND %00000111 Keep only bits 0-2.
36125 JR NZ,HandlerPlayerAppearing_SetColour Jump to HandlerPlayerAppearing_SetColour if the result is not zero.
36127 INC A Use 1 instead, to avoid black.
HandlerPlayerAppearing_SetColour 36128 OR %01000000 Set bit 6 (bright).
36130 LD (IX+5),A Update the attribute of the entity.
36133 LD A,(IX+6) Fetch the number of rows.
36136 CALL SetItemAttributes_Lines Call SetItemAttributes_Lines to set the attributes of that many rows.
36139 POP AF Restore the attribute of the entity from the stack.
36140 LD (IX+5),A Write it back to the entity.
36143 JP SoundsAppear Jump to SoundsAppear to make the sound of appearing.
All of the rows have been drawn, so the player is back.
HandlerPlayerAppearing_Finish 36146 LD A,(IX+7) Fetch the sprite ID of the player from offset 7.
36149 LD (IX+0),A Write it to the sprite ID of the entity.
36152 LD (IX+6),0 Write 0 to offset 6.
36156 LD (IX+7),0 Write 0 to offset 7.
36160 LD (IX+2),0 Write 0 to offset 2.
36164 RET Return.
Prev: 35980 Up: Map Next: 36165