![]() |
Routines |
| Prev: 31024 | Up: Map | Next: 31168 |
|
Used by the routine at Handler_Room06.
Controls the spider hazard. The spider descends and ascends on a silk thread, bouncing between a minimum height of 67 and a maximum height of 96. The thread is drawn as a vertical line of pixels from the top of the screen down to the spider's current position. The spider randomly alternates between two animation frames and checks for collision with Percy.
|
||||||||||
|
Check for respawn and set the thread colour attributes.
|
||||||||||
| Handler_Spider | 31050 | LD A,(24507) | Call Initialise_Spider to initialise the spider if *RespawnFlag is set. | |||||||
| 31053 | OR A | |||||||||
| 31054 | CALL NZ,Initialise_Spider | |||||||||
| 31057 | LD HL,55562 | Point HL at RoomAttributeBuffer (attribute buffer row). | ||||||||
| 31060 | LD BC,32 | Set BC to 32 (one attribute row width). | ||||||||
| 31063 | LD A,104 | Write INK:BLACK, PAPER:CYAN (BRIGHT) (104) to three consecutive attribute rows for the thread area. | ||||||||
| 31065 | LD (HL),A | |||||||||
| 31066 | ADD HL,BC | |||||||||
| 31067 | LD (HL),A | |||||||||
| 31068 | ADD HL,BC | |||||||||
| 31069 | LD (HL),A | |||||||||
|
Draw the spider's silk thread from the top of the screen down to the spider's current position.
|
||||||||||
| 31070 | LD HL,18442 | Point HL at 18442 (screen buffer address for top of thread). | ||||||||
| 31073 | LD D,H | Save the screen third base in D. | ||||||||
| 31074 | LD C,63 | Set C to 63 (base Y position of the thread). | ||||||||
| 31076 | LD B,(IX+1) | Calculate the number of pixel rows to draw by subtracting the spider's current height from the base Y position. | ||||||||
| 31079 | LD A,B | |||||||||
| 31080 | SUB C | |||||||||
| 31081 | LD B,A | Set the row counter in B. | ||||||||
| Draw_Thread_Loop | 31082 | SET 7,(HL) | Set bit 7 of *HL to draw one pixel of the thread. | |||||||
| 31084 | PUSH HL | Stash the screen buffer pointer on the stack. | ||||||||
| 31085 | SET 7,H | Set bits 7 and 5 of H to convert to the attribute buffer address. | ||||||||
| 31087 | SET 5,H | |||||||||
| 31089 | SET 7,(HL) | Set bit 7 of *HL to mark the thread attribute. | ||||||||
| 31091 | POP HL | Restore the screen buffer pointer from the stack. | ||||||||
| 31092 | INC H | Advance down one pixel row. | ||||||||
| 31093 | LD A,H | |||||||||
| 31094 | AND %00000111 | Jump to Draw_Thread_Next if the pixel row hasn't crossed a character cell boundary. | ||||||||
| 31096 | JR NZ,Draw_Thread_Next | |||||||||
| 31098 | LD A,L | Add 32 to L to move to the next character row. | ||||||||
| 31099 | ADD A,32 | |||||||||
| 31101 | LD L,A | |||||||||
| 31102 | LD H,D | Restore H from D to reset the screen third base for the new character row. | ||||||||
| Draw_Thread_Next | 31103 | DJNZ Draw_Thread_Loop | Decrease the row counter and loop back to Draw_Thread_Loop until the thread is fully drawn. | |||||||
|
Update the spider's vertical position based on its current direction.
|
||||||||||
| 31105 | LD A,(31185) | Jump to Spider_Descending if *Spider_Direction_Flag (direction flag) is non-zero (spider is descending). | ||||||||
| 31108 | OR A | |||||||||
| 31109 | JR NZ,Spider_Descending | |||||||||
|
Spider is ascending: increase height until reaching the maximum.
|
||||||||||
| Spider_Ascending | 31111 | LD A,(IX+1) | Fetch the spider's current height from *IX+1. | |||||||
| 31114 | INC A | Increment the height. | ||||||||
| 31115 | CP 96 | Jump to Spider_Switch_To_Descending if it has reached 96 (the maximum height, switch to descending). | ||||||||
| 31117 | JR NC,Spider_Switch_To_Descending | |||||||||
| 31119 | LD (IX+1),A | Write the new height to *IX+1. | ||||||||
| 31122 | JR Set_Spider_Frame | Jump to Set_Spider_Frame. | ||||||||
|
Spider is descending: decrease height until reaching the minimum.
|
||||||||||
| Spider_Descending | 31124 | LD A,(IX+1) | Fetch the spider's current height from *IX+1. | |||||||
| 31127 | DEC A | Decrement the height. | ||||||||
| 31128 | CP 67 | Jump to Spider_Switch_To_Ascending if it has dropped below 67 (minimum height, switch to ascending). | ||||||||
| 31130 | JR C,Spider_Switch_To_Ascending | |||||||||
| 31132 | LD (IX+1),A | Write the new height to *IX+1. | ||||||||
| 31135 | JR Set_Spider_Frame | Jump to Set_Spider_Frame. | ||||||||
| Spider_Switch_To_Descending | 31137 | LD A,255 | Write 255 to *Spider_Direction_Flag (set direction to descending). | |||||||
| 31139 | LD (31185),A | |||||||||
| 31142 | JR Set_Spider_Frame | Jump to Set_Spider_Frame. | ||||||||
| Spider_Switch_To_Ascending | 31144 | XOR A | Write 0 to *Spider_Direction_Flag (set direction to ascending). | |||||||
| 31145 | LD (31185),A | |||||||||
|
Pick a random spider animation frame and check for collision with Percy.
|
||||||||||
| Set_Spider_Frame | 31148 | LD A,R | Use the Memory Refresh Register masked with 1 to randomly select frame 95 or 96. | |||||||
| 31150 | AND %00000001 | |||||||||
| 31152 | ADD A,95 | Add 95 to get the final frame ID. | ||||||||
| 31154 | LD (IX+3),A | Write the frame to *IX+3. | ||||||||
| 31157 | LD IY,56000 | Point IY at Percy_X_Position (Percy sprite data). | ||||||||
| 31161 | CALL CheckSpriteCollision | Call CheckSpriteCollision to check for collision with Percy. | ||||||||
| 31164 | RET C | Return if there was no collision (carry set). | ||||||||
| 31165 | JP Hazard_Hit_Percy | Jump to Hazard_Hit_Percy. | ||||||||
| Prev: 31024 | Up: Map | Next: 31168 |