Routines |
Prev: 5DDB | Up: Map | Next: 5E44 |
Used by the routine at 5E6F. Compares the bike and storeroom combinations with what ERIC has just written on a blackboard. Unchains the bike or gives ERIC the storeroom key if there is a match.
|
||||||||
5DDC | LD D,H | D=0x7F | ||||||
5DDD | LD L,$FB | Reset all of ERIC's status flags at 7FFB now that he's no longer writing on the board | ||||||
5DDF | LD (HL),$00 | |||||||
5DE1 | LD L,$9C | HL=7F9C (combinations) | ||||||
5DE3 | LD BC,$0804 | B=8 (4 numbers, 4 letters), C=4 | ||||||
5DE6 | RES 7,(HL) | Reset bit 7 of each combination number/letter; bit 7 will be set later if there is a match with what ERIC wrote on the board | ||||||
5DE8 | INC L | |||||||
5DE9 | DJNZ $5DE6 | |||||||
5DEB | LD L,$D8 | HL=7FD8 (which holds the identifier of the blackboard ERIC wrote on) | ||||||
5DED | LD L,(HL) | Point HL at byte 1 of the relevant blackboard buffer (bytes 2-5 hold the first 4 characters ERIC wrote) | ||||||
5DEE | INC L | |||||||
5DEF | LD B,C | B=4 | ||||||
5DF0 | INC L | Return unless at least four letters were written on the board by ERIC | ||||||
5DF1 | BIT 7,(HL) | |||||||
5DF3 | RET NZ | |||||||
5DF4 | DJNZ $5DF0 | |||||||
5DF6 | EX DE,HL | Point DE at the last byte of the blackboard buffer | ||||||
5DF7 | LD L,$9C | HL=7F9C (combinations) | ||||||
5DF9 | LD B,$08 | 4 numbers, 4 letters | ||||||
5DFB | LD A,(DE) | A=ASCII code of the character written on the board | ||||||
5DFC | CP $60 | Is it upper case? | ||||||
5DFE | JR C,$5E02 | Jump if so | ||||||
5E00 | SUB $20 | Make lower case characters upper case | ||||||
5E02 | CP (HL) | Does the character written on the board match the combination number/letter? | ||||||
5E03 | JR Z,$5E09 | Jump if so | ||||||
5E05 | INC L | Point to the next combination number/letter | ||||||
5E06 | DJNZ $5E02 | |||||||
5E08 | RET | |||||||
5E09 | DEC E | Point to the next character written on the board | ||||||
5E0A | SET 7,(HL) | Signal: matching character | ||||||
5E0C | DEC C | Next combination letter/number | ||||||
5E0D | JR NZ,$5DF7 | Jump back to check the remaining numbers/letters | ||||||
5E0F | LD L,$9C | HL=7F9C (combinations) | ||||||
5E11 | LD B,$04 | There are 4 digits in the bike combination | ||||||
5E13 | LD A,(HL) | Pick up the first digit | ||||||
5E14 | AND (HL) | Bit 7 of A will remain set if all four written characters matched up with the bike combination digits | ||||||
5E15 | INC L | |||||||
5E16 | DJNZ $5E14 | |||||||
5E18 | RLCA | Was there a match? | ||||||
5E19 | JR NC,$5E32 | Jump if not | ||||||
ERIC has written the bike combination number on a blackboard. Free the bike if it's still chained up.
|
||||||||
5E1B | LD HL,$D301 | H=0xD3 (bike), L=0x01 | ||||||
5E1E | LD A,(HL) | A=bike's x-coordinate | ||||||
5E1F | CP $E0 | Is the bike already free? | ||||||
5E21 | RET NZ | Return if so | ||||||
5E22 | LD (HL),$64 | Place the bike at x-coordinate 100 | ||||||
5E24 | LD HL,$E100 | Alter UDG references in the play area to release the bike from the tree | ||||||
5E27 | CALL $6C18 | |||||||
5E2A | LD A,$64 | Add 1000 to the score and print it | ||||||
5E2C | CALL $73B5 | |||||||
5E2F | JP $F3C1 | Print the inventory and make a sound effect | ||||||
The first four characters written on the board by ERIC didn't match the bike combination digits. What about the storeroom combination letters?
|
||||||||
5E32 | LD A,(HL) | Pick up the first combination letter | ||||||
5E33 | LD B,$04 | There are 4 letters in the storeroom combination | ||||||
5E35 | AND (HL) | Bit 7 of A will remain set if all four written characters matched up with the storeroom combination letters | ||||||
5E36 | INC L | |||||||
5E37 | DJNZ $5E35 | |||||||
5E39 | RLCA | Was there a match? | ||||||
5E3A | RET NC | Return if not | ||||||
5E3B | LD L,$EB | HL=7FEB (which holds the inventory flags) | ||||||
5E3D | BIT 1,(HL) | Has ERIC already got the storeroom key? | ||||||
5E3F | RET NZ | Return if so | ||||||
5E40 | SET 1,(HL) | Otherwise give ERIC the key to the storeroom | ||||||
5E42 | JR $5E2A | Add 1000 to the score, print the inventory, and make a sound effect |
Prev: 5DDB | Up: Map | Next: 5E44 |