| Routines

05942: THE 'OPEN #' COMMAND ROUTINE

The address of this routine is found in the parameter table. This command allows the user to OPEN streams. A channel code must be supplied and it must be 'K', 'k', 'S', 's', 'P', or 'p'. Note that no attempt is made to give streams 0 to 3 their initial data.
OPEN | 05942 | RST 40 | Use the calculator to exchange the stream number and the channel code.
| 05943 | DEFB 1 | exchange
| 05944 | DEFB 56 | end_calc
| 05945 | CALL STR_DATA | Fetch the data for the stream.
| 05948 | LD A,B | Jump forward if both bytes of the data are zero, i.e. the stream was in a closed state.
| 05949 | OR C
| 05950 | JR Z,OPEN_1
| 05952 | EX DE,HL | Save HL.
| 05953 | LD HL,(23631) | Fetch CHANS - the base address of the channel information and find the code of the channel associated with the stream being OPENed.
| 05956 | ADD HL,BC
| 05957 | INC HL
| 05958 | INC HL
| 05959 | INC HL
| 05960 | LD A,(HL)
| 05961 | EX DE,HL | Return HL.
| 05962 | CP "K" | The code fetched from the channel information area must be 'K', 'S' or 'P'; give an error if it is not.
| 05964 | JR Z,OPEN_1
| 05966 | CP "S"
| 05968 | JR Z,OPEN_1
| 05970 | CP "P"
| 05972 | JR NZ,REPORT_O_2
OPEN_1 | 05974 | CALL OPEN_2 | Collect the appropriate data in DE.
| 05977 | LD (HL),E | Enter the data into the two bytes in the stream information area.
| 05978 | INC HL
| 05979 | LD (HL),D
| 05980 | RET | Finally return.