Routines |
Prev: 37819 | Up: Map | Next: 37974 |
Used by the routine at 35245.
|
||||
37841 | LD H,164 | Page 164 holds the first byte of each entry in the item table | ||
37843 | LD A,(41983) | Pick up the index of the first item from 41983 | ||
37846 | LD L,A | Point HL at the first byte of the first entry in the item table | ||
The item-drawing loop begins here.
|
||||
37847 | LD C,(HL) | Pick up the first byte of the current entry in the item table | ||
37848 | RES 7,C | Reset bit 7; bit 6 holds the collection flag, and bits 0-5 hold the room number | ||
37850 | LD A,(33824) | Pick up the number of the current room from 33824 | ||
37853 | OR 64 | Set bit 6 (corresponding to the collection flag) | ||
37855 | CP C | Is the item in the current room and still uncollected? | ||
37856 | JR NZ,37970 | If not, jump to consider the next entry in the item table | ||
This item is in the current room and has not been collected yet.
|
||||
37858 | LD A,(HL) | Pick up the first byte of the current entry in the item table | ||
37859 | RLCA | Point DE at the location of the item in the attribute buffer at 23552 | ||
37860 | AND 1 | |||
37862 | ADD A,92 | |||
37864 | LD D,A | |||
37865 | INC H | |||
37866 | LD E,(HL) | |||
37867 | DEC H | |||
37868 | LD A,(DE) | Pick up the current attribute byte at the item's location | ||
37869 | AND 7 | Is the INK white (which happens if Willy is touching the item, or the room's background tile has white INK, as in Swimming Pool)? | ||
37871 | CP 7 | |||
37873 | JR NZ,37936 | Jump if not | ||
Willy is touching this item (or the room's background tile has white INK), so add it to his collection.
|
||||
37875 | LD IX,34172 | Point IX at the number of items collected at 34172 | ||
37879 | INC (IX+2) | Increment a digit of the number of items collected | ||
37882 | LD A,(IX+2) | Was the digit originally '9'? | ||
37885 | CP 58 | |||
37887 | JR NZ,37897 | Jump if not | ||
37889 | LD (IX+2),48 | Set the digit to '0' | ||
37893 | DEC IX | Move back to the digit on the left | ||
37895 | JR 37879 | Jump back to increment this digit | ||
37897 | LD A,(32990) | Pick up the border colour for the current room from 32990 | ||
37900 | LD C,128 | Produce the sound effect for collecting an item | ||
37902 | OUT (254),A | |||
37904 | XOR 24 | |||
37906 | LD E,A | |||
37907 | LD A,144 | |||
37909 | SUB C | |||
37910 | LD B,A | |||
37911 | LD A,E | |||
37912 | DJNZ 37912 | |||
37914 | DEC C | |||
37915 | DEC C | |||
37916 | JR NZ,37902 | |||
37918 | LD A,(34270) | Update the counter of items remaining at 34270, and set the zero flag if there are no more items to collect | ||
37921 | INC A | |||
37922 | LD (34270),A | |||
37925 | JR NZ,37932 | Jump if there are any items still to be collected | ||
37927 | LD A,1 | Update the game mode indicator at 34271 to 1 (all items collected) | ||
37929 | LD (34271),A | |||
37932 | RES 6,(HL) | Reset bit 6 of the first byte of the entry in the item table: the item has been collected | ||
37934 | JR 37970 | Jump to consider the next entry in the item table | ||
Willy is not touching this item, so draw it and cycle its INK colour.
|
||||
37936 | LD A,(34251) | Generate the INK colour for the item from the value of the minute counter at 34251 (0-255) and the index of the item in the item table (173-255) | ||
37939 | ADD A,L | |||
37940 | AND 3 | |||
37942 | ADD A,3 | |||
37944 | LD C,A | |||
37945 | LD A,(DE) | Change the INK colour of the item in the attribute buffer at 23552 | ||
37946 | AND 248 | |||
37948 | OR C | |||
37949 | LD (DE),A | |||
37950 | LD A,(HL) | Point DE at the location of the item in the screen buffer at 24576 | ||
37951 | RLCA | |||
37952 | RLCA | |||
37953 | RLCA | |||
37954 | RLCA | |||
37955 | AND 8 | |||
37957 | ADD A,96 | |||
37959 | LD D,A | |||
37960 | PUSH HL | Save HL briefly | ||
37961 | LD HL,32993 | Point HL at the item graphic for the current room (at 32993) | ||
37964 | LD B,8 | There are eight pixel rows to copy | ||
37966 | CALL 38555 | Draw the item to the screen buffer at 24576 | ||
37969 | POP HL | Restore the item table pointer to HL | ||
The current item has been dealt with (skipped, collected or drawn) as appropriate. Time to consider the next one.
|
||||
37970 | INC L | Point HL at the first byte of the next entry in the item table | ||
37971 | JR NZ,37847 | Jump back unless we've examined every entry | ||
37973 | RET |
Prev: 37819 | Up: Map | Next: 37974 |