| Routines

05633: THE 'CHAN-OPEN' SUBROUTINE

Used by the routines at SAVE_ETC, SA_CONTRL, PO_SCR, CLS, CL_ALL, ED_EDIT, ED_UP, MAIN_EXEC, LIST, LPRINT, STR_ALTER, INPUT, str and read_in. This subroutine is called with the A register holding a valid stream number - normally 253 to 3. Then depending on the stream data a particular channel will be made the current channel.
Input
A | Stream number
CHAN_OPEN | 05633 | ADD A,A | The value in the A register is doubled and then increased by 22.
| 05634 | ADD A,22
| 05636 | LD L,A | The result is moved to L.
| 05637 | LD H,92 | The address 23574 is the base address for stream 0.
| 05639 | LD E,(HL) | Fetch the first two bytes of the required stream's data.
| 05640 | INC HL
| 05641 | LD D,(HL)
| 05642 | LD A,D | Give an error if both bytes are zero; otherwise jump forward.
| 05643 | OR E
| 05644 | JR NZ,CHAN_OP_1
This entry point is used by the routine at STR_ALTER. Report O - Invalid stream.
REPORT_O | 05646 | RST 8 | Call the error handling routine.
| 05647 | DEFB 23
Using the stream data now find the base address of the channel information associated with that stream.
CHAN_OP_1 | 05648 | DEC DE | Reduce the stream data.
| 05649 | LD HL,(23631) | The base address of the whole channel information area (CHANS).
| 05652 | ADD HL,DE | Form the required address in this area.
This routine continues into CHAN_FLAG.