Besides the wing boots there's a second equippable item which has an effect limited by time: The hour glass. The hour glass freezes enemy sprites for a given amount of time. Unlike using the wing boots, using the hour glass has a negative effect. It decreases the player's health by 50% making it rather costly when the player still has a lot of health. Nevertheless the code for activating the hour glass is remarkably similar to the code for activating the wing boots. The hour glass code also follows right after the wing boots code.
Let's start with the code that's executed when activating the hour glass
CODE:
<br />$C5C8-> A9 82: LDA #$82 ; Message ID
<br />$C5CA-> 20 59 F8: JSR $F859 ; Show Message
<br />$C5CD-> C: illegal/unknown
<br />$C5CE-> 41 82: illegal/unknown
<br />$C5D0-> 20 BF C4: JSR $C4BF ; RemoveSelectedItem
<br />$C5D3-> A9 1A: LDA #$1A ; Sound effect ID
<br />$C5D5-> 20 E4 D0: JSR $D0E4 ; Play sound effect
<br />$C5D8-> 4E 31 4: LSR $431
<br />$C5DB-> 6E 32 4: ROR $432 ; Subtract 50% health
<br />$C5DE-> 20 BD C0: JSR $C0BD ; Update health bar
<br />$C5E1-> A9 F: LDA #$F ; Duration = 15 seconds
<br />$C5E3-> 8D 2A 4: STA $42A
<br />$C5E6-> A9 B: LDA #$B
<br />$C5E8-> 85 FA: STA $FA ; Play music $0B
<br />$C5EA-> 60: RTS
<br />
Unlike the duration of the wing boots the duration of the hour glass is always the same. Every time it's activated all monsters will be frozen for exactly 15 seconds.
What I didn't explain in the update about wing boots is the call to function $D0E4 which is also part of the wing boots code. This function sets a new sound effect which is then played at the next interrupt. The last two lines, which were not present in the wing boots code, change the current music. $FA is the memory offset where the ID of the next music is stored. The interrupt handler will then call the appropriate music code once it's executed.
The health stuff looks weird at first until you realize that the health is not stored in full health points but in full fractions (the precision of the health is 1/16th of a full health point). The byte at offset $431 contains the number of full health points, the byte at offset $432 contains a fraction of a health point (we'll have a closer look at the player's health soon).
Let's move on to the code that counts down the remaining time of the hour glass.
CODE:
<br />$85EB-> AD 2A 4: LDA $42A ; Make sure hour glass is active
<br />$85EE-> 30 18: BMI $8608
<br />$85F0-> A5 1A: LDA $1A ; Load interrupt counter
<br />$85F2-> 29 3F: AND #$3F
<br />$85F4-> D0 12: BNE $8608
<br />$85F6-> CE 2A 4: DEC $42A ; Decrease time
<br />$85F9-> 10 D: BPL $8608
<br />$85FB-> A9 97: LDA #$97 ; ID of expiration message
<br />$85FD-> 20 59 F8: JSR $F859 ; Show text
<br />$8600-> C: illegal/unknown
<br />$8601-> 41 82: illegal/unknown
<br />$8603-> AD D1 3: LDA $3D1 ; Load old music theme
<br />$8606-> 85 FA: STA $FA
<br />$8608-> 60: RTS
The first two lines make sure the hour glass is active, that is the duration is not $FF. Then comes a check which I did not explain in the wing boots update even though it was in there too. $1A is a simple counter which is increased every time the interrupt handler is executed. That means the duration of the hour glass as well as the duration of the wing boots are decreased by one every 0x40 interrupts which is reasonably close to one second I guess. Afterwards the remaining time is decreased by one and if the time expired the appropriate expiration message is shown. At the very end the current music theme is restored to the theme of the area the player is in at the moment.The music ID of that area is stored in $3D1.