| Routines

0970: THE 'SAVE' CONTROL ROUTINE

Used by the routine at SAVE_ETC. The operation of saving a program or a block of data is very straightforward.
Input
HL | Data block start address
IX | Header start address
SA_CONTRL | 0970 | PUSH HL | Save the 'pointer'.
| 0971 | LD A,$FD | Ensure that channel 'K' is open.
| 0973 | CALL CHAN_OPEN
| 0976 | XOR A | Signal 'first message'.
| 0977 | LD DE,$09A1 | Print the message 'Start tape, then press any key.' (see CASSETTE).
| 097A | CALL PO_MSG
| 097D | SET 5,(IY+$02) | Signal 'screen will require to be cleared' (set bit 5 of TV-FLAG).
| 0981 | CALL WAIT_KEY | Wait for a key to be pressed.
Upon receipt of a keystroke the 'header' is saved.
| 0984 | PUSH IX | Save the base address of the 'header' on the machine stack.
| 0986 | LD DE,$0011 | Seventeen bytes are to be saved.
| 0989 | XOR A | Signal 'it is a header'.
| 098A | CALL SA_BYTES | Send the 'header', with a leading 'type' byte and a trailing 'parity' byte.
There follows a short delay before the program/data block is saved.
| 098D | POP IX | Retrieve the pointer to the 'header'.
| 098F | LD B,$32 | The delay is for fifty interrupts, i.e. one second.
SA_1_SEC | 0991 | HALT
| 0992 | DJNZ SA_1_SEC
| 0994 | LD E,(IX+$0B) | Fetch the length of the data block that is to be saved.
| 0997 | LD D,(IX+$0C)
| 099A | LD A,$FF | Signal 'data block'.
| 099C | POP IX | Fetch the 'start of block pointer' and save the block.
| 099E | JP SA_BYTES