Prev: C63B Up: Map Next: C6A4
C677: Identify and set up level name for printing on scroll
Whenever Maroc enters a new room (or moves from a tunnel to a new room), the room number is cross referenced against the current level/area using the lookup table at C6A4.
The paired byte (1-9) indicates which level (7172) Maroc is on. Once identified, the level name is printed on the scroll.
C677 LD A,($EAB7) Get room number
C67A CP $D5 There are 212 'standard' rooms in the game
C67C JR NC,$C6B6 If the room number is higher, we assume Maroc's in a vertical scrolling tunnel section, so skip the next bit as no scroll message is needed.
C67E LD B,$09 9 pairs of bytes to check at C6A4
C680 LD HL,$C6A4
C683 LD C,A Temporary store for room number in C register
C684 LD A,(HL) Get first byte of data banks
C685 CP C
C686 JR C,$C68C If current room number > the first byte of the pair, level identified
C688 INC HL Otherwise move to next pair of bytes
C689 INC HL
C68A DJNZ $C684
Level identified from room number
C68C DEC HL Move pointer back 1 byte to the second byte of previous pair
C68D LD A,(HL)
C68E LD ($EAC9),A ...And store.
C691 LD HL,($EB5B) Get address pointer to current game level text at 7172
C694 CALL $E5A5 Identify the address of the level text to print
C697 LD ($EAEA),HL ...and store.
C69A LD A,$00 Set the character counter to the start of the text (character position 0)
C69C LD ($EBC9),A ...and store.
C69F CALL $E58C Clear the spell message text area on the scroll
C6A2 JR $C6B6 Jump to initialize, set up and draw room items
Prev: C63B Up: Map Next: C6A4