Skip to navigation

Elite on the BBC Micro and NES

Text: MT26

[Elite-A, Parasite]

Name: MT26 [Show more] Type: Subroutine Category: Text Summary: Fetch a line of text from the keyboard Deep dive: Extended text tokens
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * DELT calls MT26 * GTNMEW calls MT26 * JMTB calls MT26

If ESCAPE is pressed or a blank name is entered, then an empty string is returned. Returns: Y The size of the entered text, or 0 if none was entered or if ESCAPE was pressed INWK+5 The entered text, terminated by a carriage return C flag Set if ESCAPE was pressed
.MT26 LDA #&8A \ Send command &8A to the I/O processor: JSR tube_write \ \ =write_fe4e(value) \ \ which sets the 6522 System VIA interrupt enable \ register IER (SHEILA &4E) to the specified value and \ returns the value in A when done LDA #%10000001 \ Send the parameter to the I/O processor: JSR tube_write \ \ * value = %10000001 \ \ to clear bit 1 of IER (i.e. enable the CA2 interrupt, \ which comes from the keyboard) JSR tube_read \ Set A to the response from the I/O processor JSR FLKB \ Call FLKB to flush the keyboard buffer LDX #LO(RLINE) \ Set (Y X) to point to the RLINE parameter block LDY #HI(RLINE) LDA #0 \ Call OSWORD with A = 0 to read a line from the current JSR OSWORD \ input stream (i.e. the keyboard) BCC P%+4 \ The C flag will be set if we pressed ESCAPE when \ entering the name, otherwise it will be clear, so \ skip the next instruction if ESCAPE is not pressed LDY #0 \ ESCAPE was pressed, so set Y = 0 (as the OSWORD call \ returns the length of the entered string in Y) LDA #&8A \ Send command &8A to the I/O processor: JSR tube_write \ \ =write_fe4e(value) \ \ which sets the 6522 System VIA interrupt enable \ register IER (SHEILA &4E) to the specified value and \ returns the value in A when done LDA #%00000001 \ Send the parameter to the I/O processor: JSR tube_write \ \ * value = %00000001 \ \ to set bit 1 of IER (i.e. disable the CA2 interrupt, \ which comes from the keyboard) JSR tube_read \ Set A to the response from the I/O processor, so we \ know the register has been set JMP FEED \ Jump to FEED to print a newline, returning from the \ subroutine using a tail call