![]() |
Routines |
| Prev: 7930 | Up: Map | Next: 79C0 |
|
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 43 and a maximum height of 60. 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 | 794A | LD A,($5FBB) | Call Initialise_Spider to initialise the spider if *RespawnFlag is set. | |||||||
| 794D | OR A | |||||||||
| 794E | CALL NZ,Initialise_Spider | |||||||||
| 7951 | LD HL,$D90A | Point HL at RoomAttributeBuffer (attribute buffer row). | ||||||||
| 7954 | LD BC,$0020 | Set BC to 20 (one attribute row width). | ||||||||
| 7957 | LD A,$68 | Write INK:BLACK, PAPER:CYAN (BRIGHT) (68) to three consecutive attribute rows for the thread area. | ||||||||
| 7959 | LD (HL),A | |||||||||
| 795A | ADD HL,BC | |||||||||
| 795B | LD (HL),A | |||||||||
| 795C | ADD HL,BC | |||||||||
| 795D | LD (HL),A | |||||||||
|
Draw the spider's silk thread from the top of the screen down to the spider's current position.
|
||||||||||
| 795E | LD HL,$480A | Point HL at 480A (screen buffer address for top of thread). | ||||||||
| 7961 | LD D,H | Save the screen third base in D. | ||||||||
| 7962 | LD C,$3F | Set C to 3F (base Y position of the thread). | ||||||||
| 7964 | LD B,(IX+$01) | Calculate the number of pixel rows to draw by subtracting the spider's current height from the base Y position. | ||||||||
| 7967 | LD A,B | |||||||||
| 7968 | SUB C | |||||||||
| 7969 | LD B,A | Set the row counter in B. | ||||||||
| Draw_Thread_Loop | 796A | SET 7,(HL) | Set bit 7 of *HL to draw one pixel of the thread. | |||||||
| 796C | PUSH HL | Stash the screen buffer pointer on the stack. | ||||||||
| 796D | SET 7,H | Set bits 7 and 5 of H to convert to the attribute buffer address. | ||||||||
| 796F | SET 5,H | |||||||||
| 7971 | SET 7,(HL) | Set bit 7 of *HL to mark the thread attribute. | ||||||||
| 7973 | POP HL | Restore the screen buffer pointer from the stack. | ||||||||
| 7974 | INC H | Advance down one pixel row. | ||||||||
| 7975 | LD A,H | |||||||||
| 7976 | AND %00000111 | Jump to Draw_Thread_Next if the pixel row hasn't crossed a character cell boundary. | ||||||||
| 7978 | JR NZ,Draw_Thread_Next | |||||||||
| 797A | LD A,L | Add 20 to L to move to the next character row. | ||||||||
| 797B | ADD A,$20 | |||||||||
| 797D | LD L,A | |||||||||
| 797E | LD H,D | Restore H from D to reset the screen third base for the new character row. | ||||||||
| Draw_Thread_Next | 797F | 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.
|
||||||||||
| 7981 | LD A,($79D1) | Jump to Spider_Descending if *Spider_Direction_Flag (direction flag) is non-zero (spider is descending). | ||||||||
| 7984 | OR A | |||||||||
| 7985 | JR NZ,Spider_Descending | |||||||||
|
Spider is ascending: increase height until reaching the maximum.
|
||||||||||
| Spider_Ascending | 7987 | LD A,(IX+$01) | Fetch the spider's current height from *IX+01. | |||||||
| 798A | INC A | Increment the height. | ||||||||
| 798B | CP $60 | Jump to Spider_Switch_To_Descending if it has reached 60 (the maximum height, switch to descending). | ||||||||
| 798D | JR NC,Spider_Switch_To_Descending | |||||||||
| 798F | LD (IX+$01),A | Write the new height to *IX+01. | ||||||||
| 7992 | JR Set_Spider_Frame | Jump to Set_Spider_Frame. | ||||||||
|
Spider is descending: decrease height until reaching the minimum.
|
||||||||||
| Spider_Descending | 7994 | LD A,(IX+$01) | Fetch the spider's current height from *IX+01. | |||||||
| 7997 | DEC A | Decrement the height. | ||||||||
| 7998 | CP $43 | Jump to Spider_Switch_To_Ascending if it has dropped below 43 (minimum height, switch to ascending). | ||||||||
| 799A | JR C,Spider_Switch_To_Ascending | |||||||||
| 799C | LD (IX+$01),A | Write the new height to *IX+01. | ||||||||
| 799F | JR Set_Spider_Frame | Jump to Set_Spider_Frame. | ||||||||
| Spider_Switch_To_Descending | 79A1 | LD A,$FF | Write FF to *Spider_Direction_Flag (set direction to descending). | |||||||
| 79A3 | LD ($79D1),A | |||||||||
| 79A6 | JR Set_Spider_Frame | Jump to Set_Spider_Frame. | ||||||||
| Spider_Switch_To_Ascending | 79A8 | XOR A | Write 00 to *Spider_Direction_Flag (set direction to ascending). | |||||||
| 79A9 | LD ($79D1),A | |||||||||
|
Pick a random spider animation frame and check for collision with Percy.
|
||||||||||
| Set_Spider_Frame | 79AC | LD A,R | Use the Memory Refresh Register masked with 01 to randomly select frame 5F or 60. | |||||||
| 79AE | AND %00000001 | |||||||||
| 79B0 | ADD A,$5F | Add 5F to get the final frame ID. | ||||||||
| 79B2 | LD (IX+$03),A | Write the frame to *IX+03. | ||||||||
| 79B5 | LD IY,$DAC0 | Point IY at Percy_X_Position (Percy sprite data). | ||||||||
| 79B9 | CALL CheckSpriteCollision | Call CheckSpriteCollision to check for collision with Percy. | ||||||||
| 79BC | RET C | Return if there was no collision (carry set). | ||||||||
| 79BD | JP Hazard_Hit_Percy | Jump to Hazard_Hit_Percy. | ||||||||
| Prev: 7930 | Up: Map | Next: 79C0 |