| Routines

20896: Change a character's name

Used by the routine at 21152. Waits for keypresses while a character's name is being changed, and prints them as they are typed. Returns when ENTER is pressed.
Input
A | Message number of the character's name (21-31)
20896 | LD L,A | Collect the start address of the message (the character's name) into HL
20897 | LD H,254
20899 | LD E,(HL)
20900 | INC H
20901 | LD D,(HL)
20902 | EX DE,HL
20903 | LD BC,3072 | B=12, C=0
20906 | LD (HL),C | Blank out the current name (12 bytes)
20907 | INC HL
20908 | DJNZ 20906
20910 | PUSH AF | Save the message number
20911 | LD HL,20544 | 20544=display file address at which to print the name
20914 | CALL 20668 | Print the name built up so far
20917 | CALL 29154 | Wait for a keypress
20920 | JR Z,20917
20922 | CP 13 | Set the zero flag if ENTER was pressed
20924 | LD B,A | B=keypress code
20925 | JR NZ,20929 | Jump unless ENTER was pressed
20927 | POP AF | Restore the message number to A
20928 | RET | Return with the new name entered
A key was pressed, and it wasn't ENTER. Place the ASCII code in the right slot of the message area corresponding to the character's name.
20929 | POP AF | Restore the message number to A
20930 | LD L,A | Collect the start address of the message (the character's name) into DE
20931 | LD H,254
20933 | LD E,(HL)
20934 | INC H
20935 | LD D,(HL)
20936 | LD HL,11 |
20939 | LD C,A | Store the message number in C briefly
20940 | ADD HL,DE | Point HL at the last byte in the message area for the character's name
20941 | LD A,(HL) | Pick up this last byte in A
20942 | AND A | Is the message area already full?
20943 | JR NZ,20953 | Jump if so
20945 | EX DE,HL | HL=start address of the message area
20946 | DEC HL |
20947 | INC HL | Point HL at the first unused slot in the message area
20948 | LD A,(HL)
20949 | AND A
20950 | JR NZ,20947
20952 | LD (HL),B | Place the letter just entered into this slot
20953 | LD A,C | Restore the message number to A
20954 | JR 20910 | Print the letter and collect another