![]() |
Routines |
Prev: 34620 | Up: Map |
The first thing this routine does is initialise some game status buffer variables in preparation for the next game.
|
|||||||
34762 | XOR A | A=0 | |||||
34763 | LD (34254),A | Initialise the Kempston joystick indicator at 34254 | |||||
34766 | LD (34273),A | Initialise the in-game music note index at 34273 | |||||
34769 | LD (34253),A | Initialise the (unused) screen flash counter at 34253 | |||||
34772 | LD (34257),A | Initialise the airborne status indicator at 34257 | |||||
34775 | LD (34251),A | Initialise the minute counter at 34251 | |||||
34778 | LD (34272),A | Initialise the inactivity timer at 34272 | |||||
34781 | LD (34271),A | Initialise the game mode indicator at 34271 | |||||
34784 | LD A,7 | Initialise the number of lives remaining at 34252 | |||||
34786 | LD (34252),A | ||||||
34789 | LD A,208 | Initialise Willy's pixel y-coordinate at 34255 | |||||
34791 | LD (34255),A | ||||||
34794 | LD A,33 | Initialise the current room number at 33824 to 33 (The Bathroom) | |||||
34796 | LD (33824),A | ||||||
34799 | LD HL,23988 | Initialise Willy's coordinates at 34259 to (13,20) | |||||
34802 | LD (34259),HL | ||||||
34805 | LD HL,34172 | Initialise the number of items collected at 34172 to "000" | |||||
34808 | LD (HL),48 | ||||||
34810 | INC HL | ||||||
34811 | LD (HL),48 | ||||||
34813 | INC HL | ||||||
34814 | LD (HL),48 | ||||||
34816 | LD H,164 | Page 164 holds the first byte of each entry in the item table | |||||
34818 | LD A,(41983) | Pick up the index of the first item from 41983 | |||||
34821 | LD L,A | Point HL at the entry for the first item | |||||
34822 | LD (34270),A | Initialise the counter of items remaining at 34270 | |||||
34825 | SET 6,(HL) | Set the collection flag for every item in the item table at 41984 | |||||
34827 | INC L | ||||||
34828 | JR NZ,34825 | ||||||
34830 | LD HL,34274 | Initialise the keypress flag in bit 0 at 34274 | |||||
34833 | SET 0,(HL) | ||||||
Next, prepare the screen.
|
|||||||
34835 | LD HL,16384 | Clear the entire display file | |||||
34838 | LD DE,16385 | ||||||
34841 | LD BC,6143 | ||||||
34844 | LD (HL),0 | ||||||
34846 | LDIR | ||||||
34848 | LD HL,38912 | Copy the attribute bytes for the title screen from 38912 and 39424 to the attribute file | |||||
34851 | LD BC,768 | ||||||
34854 | LDIR | ||||||
34856 | LD HL,23136 | Copy the attribute value 70 (INK 6: PAPER 0: BRIGHT 1) into the row of 32 cells from (19,0) to (19,31) on the screen | |||||
34859 | LD DE,23137 | ||||||
34862 | LD BC,31 | ||||||
34865 | LD (HL),70 | ||||||
34867 | LDIR | ||||||
34869 | LD IX,33876 | Print "+++++ Press ENTER to Start +++++" (see 33876) at (19,0) | |||||
34873 | LD DE,20576 | ||||||
34876 | LD C,32 | ||||||
34878 | CALL 38528 | ||||||
34881 | LD DE,22528 | Point DE at the first byte of the attribute file | |||||
The following loop scans the top two-thirds of the attribute file, which contains values 0, 4, 5, 8, 9, 36, 37, 40, 41, 44, 45 and 211 (copied from 38912). Whenever a value other than 0, 9, 36, 45 or 211 is found, a triangle UDG is drawn at the corresponding location in the display file.
|
|||||||
34884 | LD A,(DE) | Pick up a byte from the attribute file | |||||
34885 | OR A | Is it 0 (INK 0: PAPER 0)? | |||||
34886 | JR Z,34958 | If so, jump to consider the next byte in the attribute file | |||||
34888 | CP 211 | Is it 211 (INK 3: PAPER 2: BRIGHT 1: FLASH 1)? | |||||
34890 | JR Z,34958 | If so, jump to consider the next byte in the attribute file | |||||
34892 | CP 9 | Is it 9 (INK 1: PAPER 1)? | |||||
34894 | JR Z,34958 | If so, jump to consider the next byte in the attribute file | |||||
34896 | CP 45 | Is it 45 (INK 5: PAPER 5)? | |||||
34898 | JR Z,34958 | If so, jump to consider the next byte in the attribute file | |||||
34900 | CP 36 | Is it 36 (INK 4: PAPER 4)? | |||||
34902 | JR Z,34958 | If so, jump to consider the next byte in the attribute file | |||||
34904 | LD C,0 | C=0; this will be used as an offset from the triangle UDG base address (33841) | |||||
34906 | CP 8 | Is the attribute value 8 (INK 0: PAPER 1)? | |||||
34908 | JR Z,34929 | Jump if so | |||||
34910 | CP 41 | Is it 41 (INK 1: PAPER 5)? | |||||
34912 | JR Z,34929 | Jump if so | |||||
34914 | CP 44 | Is it 44 (INK 4: PAPER 5)? | |||||
34916 | JR Z,34926 | Jump if so | |||||
34918 | CP 5 | Is it 5 (INK 5: PAPER 0)? | |||||
34920 | JR Z,34929 | Jump if so | |||||
34922 | LD C,16 | Set the triangle UDG offset to 16 | |||||
34924 | JR 34929 | ||||||
34926 | LD A,37 | Change the attribute byte here from 44 (INK 4: PAPER 5) to 37 (INK 5: PAPER 4) | |||||
34928 | LD (DE),A | ||||||
34929 | LD A,E | Point HL at the triangle UDG to draw (33841, 33849, 33857 or 33865) | |||||
34930 | AND 1 | ||||||
34932 | RLCA | ||||||
34933 | RLCA | ||||||
34934 | RLCA | ||||||
34935 | OR C | ||||||
34936 | LD C,A | ||||||
34937 | LD B,0 | ||||||
34939 | LD HL,33841 | ||||||
34942 | ADD HL,BC | ||||||
34943 | PUSH DE | Save the attribute file address briefly | |||||
34944 | BIT 0,D | Set the zero flag if we're still in the top third of the attribute file | |||||
34946 | LD D,64 | Point DE at the top third of the display file | |||||
34948 | JR Z,34952 | Jump if we're still in the top third of the attribute file | |||||
34950 | LD D,72 | Point DE at the middle third of the display file | |||||
34952 | LD B,8 | There are eight pixel rows in a triangle UDG | |||||
34954 | CALL 38555 | Draw a triangle UDG on the screen | |||||
34957 | POP DE | Restore the attribute file address to DE | |||||
34958 | INC DE | Point DE at the next byte in the attribute file | |||||
34959 | LD A,D | Have we finished scanning the top two-thirds of the attribute file yet? | |||||
34960 | CP 90 | ||||||
34962 | JP NZ,34884 | If not, jump back to examine the next byte | |||||
Now check whether there is a joystick connected.
|
|||||||
34965 | LD BC,31 | B=0, C=31 (joystick port) | |||||
34968 | DI | Disable interrupts (which are already disabled) | |||||
34969 | XOR A | A=0 | |||||
34970 | IN E,(C) | Combine 256 readings of the joystick port in A; if no joystick is connected, some of these readings will have bit 5 set | |||||
34972 | OR E | ||||||
34973 | DJNZ 34970 | ||||||
34975 | AND 32 | Is a joystick connected (bit 5 reset)? | |||||
34977 | JR NZ,34984 | Jump if not | |||||
34979 | LD A,1 | Set the Kempston joystick indicator at 34254 to 1 | |||||
34981 | LD (34254),A | ||||||
And finally, play the theme tune and check for keypresses.
|
|||||||
34984 | LD HL,34299 | Point HL at the theme tune data at 34299 | |||||
34987 | CALL 38562 | Play the theme tune | |||||
34990 | JP NZ,35068 | Start the game if ENTER, 0 or the fire button was pressed | |||||
34993 | XOR A | Initialise the temporary game status buffer variable at 34276 to 0; this will be used as an index for the message scrolled across the screen (see 33876) | |||||
34994 | LD (34276),A | ||||||
34997 | CALL 35563 | Cycle the INK and PAPER colours | |||||
35000 | LD HL,23136 | Copy the attribute value 79 (INK 7: PAPER 1: BRIGHT 1) into the row of 32 cells from (19,0) to (19,31) on the screen | |||||
35003 | LD DE,23137 | ||||||
35006 | LD BC,31 | ||||||
35009 | LD (HL),79 | ||||||
35011 | LDIR | ||||||
35013 | LD A,(34276) | Pick up the message index from 34276 | |||||
35016 | LD IX,33876 | Point IX at the corresponding location in the message at 33876 | |||||
35020 | LD E,A | ||||||
35021 | LD D,0 | ||||||
35023 | ADD IX,DE | ||||||
35025 | LD DE,20576 | Print 32 characters of the message at (19,0) | |||||
35028 | LD C,32 | ||||||
35030 | CALL 38528 | ||||||
35033 | LD A,(34276) | Prepare a value between 50 and 81 in A (for the routine at 38622) | |||||
35036 | AND 31 | ||||||
35038 | ADD A,50 | ||||||
35040 | CALL 38622 | Make a sound effect | |||||
35043 | LD BC,45054 | Read keys H-J-K-L-ENTER and 6-7-8-9-0 | |||||
35046 | IN A,(C) | ||||||
35048 | AND 1 | Keep only bit 0 of the result (ENTER, 0) | |||||
35050 | CP 1 | Was ENTER or 0 pressed? | |||||
35052 | JR NZ,35068 | Jump if so to start the game | |||||
35054 | LD A,(34276) | Pick up the message index from 34276 | |||||
35057 | INC A | Increment it | |||||
35058 | CP 224 | Set the zero flag if we've reached the end of the message | |||||
35060 | LD (34276),A | Store the new message index at 34276 | |||||
35063 | JR NZ,34997 | Jump back unless we've finished scrolling the message across the screen | |||||
35065 | JP 34835 | Jump back to prepare the screen and play the theme tune again |
Prev: 34620 | Up: Map |