Routines |
Prev: 30675 | Up: Map | Next: 30969 |
Used by the routine at 31414. On entry, A holds the LSB of the address of the screen refresh buffer byte that corresponds to the top row of the portion of the play area to be displayed during the cutscene.
|
||||||||||||
30822 | PUSH DE | Save the play area coordinates briefly | ||||||||||
30823 | PUSH AF | Save the screen refresh buffer address LSB briefly | ||||||||||
30824 | CALL 64599 | Hide the play area | ||||||||||
30827 | POP AF | Restore the screen refresh buffer address LSB to A | ||||||||||
30828 | LD L,A | Point HL at the first screen refresh buffer (SRB) byte that will need updating later | ||||||||||
30829 | POP DE | Restore the play area coordinates to DE | ||||||||||
30830 | PUSH HL | Save the SRB address for now | ||||||||||
30831 | AND 3 | Compute Sam's new x-coordinate (x+5, where x is the x-coordinate of the leftmost column of the portion of the play area to be displayed) | ||||||||||
30833 | ADD A,A | |||||||||||
30834 | ADD A,A | |||||||||||
30835 | ADD A,A | |||||||||||
30836 | ADD A,5 | |||||||||||
30838 | ADD A,E | |||||||||||
30839 | LD C,A | C=Sam's new x-coordinate | ||||||||||
30840 | LD A,D | Set the new y-coordinate of the topmost row of the play area on screen | ||||||||||
30841 | LD (32767),A | |||||||||||
30844 | LD A,L | A=screen refresh buffer address LSB | ||||||||||
30845 | SUB 12 | Compute Sam's new y-coordinate | ||||||||||
30847 | AND 252 | |||||||||||
30849 | RRCA | |||||||||||
30850 | RRCA | |||||||||||
30851 | ADD A,D | |||||||||||
30852 | LD HL,58880 | Point HL at byte 0 of Sam's character buffer | ||||||||||
30855 | LD (HL),0 | Set Sam's animatory state to 0 (standing/walking phase 1) | ||||||||||
30857 | INC L | L=1 | ||||||||||
30858 | LD (HL),C | Set Sam's x-coordinate | ||||||||||
30859 | INC L | L=2 | ||||||||||
30860 | LD (HL),A | Set Sam's y-coordinate | ||||||||||
30861 | INC L | L=4 | ||||||||||
30862 | INC L | |||||||||||
30863 | LD (HL),1 | Set Sam's z-coordinate | ||||||||||
Next we cycle character buffer groups forwards or backwards as appropriate to correspond with the portion of the play area that will be on screen.
|
||||||||||||
30865 | LD HL,61879 | Place a RET instruction at 61879 so that the screen will not scroll right | ||||||||||
30868 | LD (HL),201 | |||||||||||
30870 | LD L,224 | Place a RET instruction at 61920 so that the screen will not scroll left | ||||||||||
30872 | LD (HL),201 | |||||||||||
30874 | PUSH HL | |||||||||||
30875 | LD HL,32766 | Collect X (the x-coordinate of the leftmost column of the play area on screen) from 32766 | ||||||||||
30878 | LD A,(HL) | |||||||||||
30879 | CP E | Does X match the target x-coordinate (in E)? | ||||||||||
30880 | JR Z,30905 | Jump if so | ||||||||||
30882 | PUSH DE | Save the target x-coordinate briefly | ||||||||||
30883 | JR C,30892 | Jump if X<E | ||||||||||
30885 | CALL 61838 | Cycle a character buffer group forwards (but without scrolling the screen) | ||||||||||
30888 | LD A,248 | A=-8 | ||||||||||
30890 | JR 30897 | |||||||||||
30892 | CALL 61882 | Cycle a character buffer group backwards (but without scrolling the screen) | ||||||||||
30895 | LD A,8 | |||||||||||
30897 | POP DE | Restore the target x-coordinate to E | ||||||||||
30898 | LD HL,32766 | Add 8 to or subtract 8 from X (the x-coordinate of the leftmost column of the play area on screen, stored at 32766) | ||||||||||
30901 | ADD A,(HL) | |||||||||||
30902 | LD (HL),A | |||||||||||
30903 | JR 30879 | Jump back to check whether we need to cycle any more character buffers backwards or forwards | ||||||||||
30905 | POP HL | |||||||||||
30906 | LD (HL),195 | Restore the JP instruction at 61920 | ||||||||||
30908 | LD L,183 | Restore the JP instruction at 61879 | ||||||||||
30910 | LD (HL),195 | |||||||||||
Next we determine whether any lights near Sam need to be switched on and any window blinds need to be raised.
|
||||||||||||
30912 | LD H,230 | 230=Sam | ||||||||||
30914 | CALL 63138 | Collect in C the x-coordinate of the front column of Sam's sprite | ||||||||||
30917 | LD B,192 | Is there a light switch next to Sam? | ||||||||||
30919 | CALL 62548 | |||||||||||
30922 | JR Z,30955 | Jump if not (we can reveal the play area now) | ||||||||||
30924 | BIT 5,A | Set the zero flag if the light switch affects the light in only one window or window-pair | ||||||||||
30926 | LD A,(BC) | A=window flags for Sam's location | ||||||||||
30927 | JR Z,30936 | Jump if the light switch affects the light in only one window or window-pair | ||||||||||
30929 | BIT 5,A | Is the light switch in the 'on' position? | ||||||||||
30931 | CALL NZ,62630 | If not, switch the light on | ||||||||||
30934 | JR 30955 | Jump forward to reveal the play area | ||||||||||
30936 | BIT 1,A | Is there a right-hand window here with a blind? | ||||||||||
30938 | JR Z,30942 | Jump if not | ||||||||||
30940 | RES 0,A | Reset bit 0: blind raised in the right-hand window | ||||||||||
30942 | BIT 7,A | Is there a left-land or single window here with a blind? | ||||||||||
30944 | JR Z,30948 | Jump if not | ||||||||||
30946 | RES 6,A | Reset bit 6: blind raised in the left-hand or only window | ||||||||||
30948 | RES 5,A | Reset bit 5: light switch on | ||||||||||
30950 | LD (BC),A | Save the new window flags (blinds raised, light switch on) | ||||||||||
30951 | XOR A | Clear A to prevent the following call from changing the window flags (we've already updated them) | ||||||||||
30952 | CALL 62617 | Update the SRB for the window | ||||||||||
Finally we can reveal the portion of the play area in which Sam will walk up and down until the cutscene message has been displayed and the game resumes.
|
||||||||||||
30955 | POP HL | Restore the SRB address to HL | ||||||||||
30956 | LD B,6 | The portion is 6 rows high | ||||||||||
30958 | LD A,L | Initialise A for the loop that follows | ||||||||||
30959 | LD L,A | Set all bits in the relevant SRB bytes | ||||||||||
30960 | LD (HL),255 | |||||||||||
30962 | ADD A,4 | |||||||||||
30964 | DJNZ 30959 | |||||||||||
30966 | JP 60032 | Update the display |
Prev: 30675 | Up: Map | Next: 30969 |