| Routines

35914: Display the game over sequence

Used by the routine at 35841.
35914 | LD HL,16384 | Clear the top two-thirds of the display file
35917 | LD DE,16385
35920 | LD BC,4095
35923 | LD (HL),0
35925 | LDIR
35927 | XOR A | Initialise the temporary game status buffer variable at 34276; this variable will determine the distance of the foot from the top of the screen
35928 | LD (34276),A
35931 | LD DE,40256 | Draw Willy at (12,15)
35934 | LD HL,18575
35937 | LD C,0
35939 | CALL 37974
35942 | LD DE,40032 | Draw the barrel underneath Willy at (14,15)
35945 | LD HL,18639
35948 | LD C,0
35950 | CALL 37974
The following loop draws the foot's descent onto the barrel that supports Willy while producing a sound effect. Your browser doesn't support HTML5 audio. Here is a link to the audio instead.
35953 | LD A,(34276) | Pick up the distance variable from 34276
35956 | LD C,A | Point BC at the corresponding entry in the screen buffer address lookup table at 33280
35957 | LD B,130
35959 | LD A,(BC) | Point HL at the corresponding location in the display file
35960 | OR 15
35962 | LD L,A
35963 | INC BC
35964 | LD A,(BC)
35965 | SUB 32
35967 | LD H,A
35968 | LD DE,40000 | Draw the foot at this location, without erasing the foot at the previous location; this leaves the portion of the foot sprite that's above the ankle in place, and makes the foot appear as if it's at the end of a long, extending leg
35971 | LD C,0
35973 | CALL 37974
35976 | LD A,(34276) | Pick up the distance variable from 34276
35979 | CPL | A=255-A
35980 | LD E,A | Store this value (63-255) in E; it determines the (rising) pitch of the sound effect that will be made
35981 | XOR A | A=0 (black border)
35982 | LD BC,64 | C=64; this value determines the duration of the sound effect
35985 | OUT (254),A | Produce a short note whose pitch is determined by E
35987 | XOR 24
35989 | LD B,E
35990 | DJNZ 35990
35992 | DEC C
35993 | JR NZ,35985
35995 | LD HL,22528 | Prepare BC, DE and HL for setting the attribute bytes in the top two-thirds of the screen
35998 | LD DE,22529
36001 | LD BC,511
36004 | LD A,(34276) | Pick up the distance variable from 34276
36007 | AND 12 | Keep only bits 2 and 3
36009 | RLCA | Shift bits 2 and 3 into bits 3 and 4; these bits determine the PAPER colour: 0, 1, 2 or 3
36010 | OR 71 | Set bits 0-2 (INK 7) and 6 (BRIGHT 1)
36012 | LD (HL),A | Copy this attribute value into the top two-thirds of the screen
36013 | LDIR
36015 | AND 250 | Reset bits 0 and 2, and retain all other bits
36017 | OR 2 | Set bit 1 (INK 2)
36019 | LD (22991),A | Copy this attribute value to the cells at (14,15), (14,16), (15, 15) and (15, 16) (where the barrel is, so that it remains red)
36022 | LD (22992),A
36025 | LD (23023),A
36028 | LD (23024),A
36031 | LD A,(34276) | Add 4 to the distance variable at 34276; this will move the foot sprite down two pixel rows
36034 | ADD A,4
36036 | LD (34276),A
36039 | CP 196 | Has the foot met the barrel yet?
36041 | JR NZ,35953 | Jump back if not
Now print the "Game Over" message, just to drive the point home.
36043 | LD IX,34164 | Print "Game" (see 34164) at (6,10)
36047 | LD C,4
36049 | LD DE,16586
36052 | CALL 38528
36055 | LD IX,34168 | Print "Over" (see 34168) at (6,18)
36059 | LD C,4
36061 | LD DE,16594
36064 | CALL 38528
36067 | LD BC,0 | Prepare the delay counters for the following loop; the counter in C will also determine the INK colours to use for the "Game Over" message
36070 | LD D,6
The following loop makes the "Game Over" message glisten for about 1.57s.
36072 | DJNZ 36072 | Delay for about a millisecond
36074 | LD A,C | Change the INK colour of the "G" in "Game" at (6,10)
36075 | AND 7
36077 | OR 64
36079 | LD (22730),A
36082 | INC A | Change the INK colour of the "a" in "Game" at (6,11)
36083 | AND 7
36085 | OR 64
36087 | LD (22731),A
36090 | INC A | Change the INK colour of the "m" in "Game" at (6,12)
36091 | AND 7
36093 | OR 64
36095 | LD (22732),A
36098 | INC A | Change the INK colour of the "e" in "Game" at (6,13)
36099 | AND 7
36101 | OR 64
36103 | LD (22733),A
36106 | INC A | Change the INK colour of the "O" in "Over" at (6,18)
36107 | AND 7
36109 | OR 64
36111 | LD (22738),A
36114 | INC A | Change the INK colour of the "v" in "Over" at (6,19)
36115 | AND 7
36117 | OR 64
36119 | LD (22739),A
36122 | INC A | Change the INK colour of the "e" in "Over" at (6,20)
36123 | AND 7
36125 | OR 64
36127 | LD (22740),A
36130 | INC A | Change the INK colour of the "r" in "Over" at (6,21)
36131 | AND 7
36133 | OR 64
36135 | LD (22741),A
36138 | DEC C | Decrement the counter in C
36139 | JR NZ,36072 | Jump back unless it's zero
36141 | DEC D | Decrement the counter in D (initially 6)
36142 | JR NZ,36072 | Jump back unless it's zero
36144 | JP 34762 | Display the title screen and play the theme tune