Sinclair ZX Interface 1 Hook Codes ================================== The Interface 1 is called with the RST &08 call, followed by an inline byte, for example: RST &08 DEFB SEL_DRIVE ; Select drive in A The first time a RST &08 call is made when no call has been made before, the Interface 1 system variables are created, and BC is corrupted. Therefore, you should make sure you code starts with a NEWVARS call before it continues with the main program. HL is always corrupted as the RST &08 code starts with a LD HL,(nnnn) instruction, overwriting anything that was already there. Most of the calls assume IY contains &5C3A. &1B CONIN Wait for key to be pressed ------------------------------------------- On entry: - On exit: A=key BC,DE,HL corrupted Interupts enabled &1C CONOUT Print CHR$ A to screen --------------------------------------- On entry: A=character to output On exit: A,HL corrupted BC,DE preserved Selects stream -2 (Screen), resets the scroll counter and outputs the character in the A register. &1D SERIN RS232 input ---------------------------- On entry: - On exit: A=returned byte Cy=1 - valid byte returned Cy=0 - nothing received BC,DE,HL corrupted Interupts enabled Checks the RS232 input. If there is no data to receive, returns with Cy clear. &1E SEROUT RS232 output ----------------------------- On entry: A=byte to output On exit: A,BC,DE,HL corrupted Interupts enabled Sends the byte in A to the RS232 output. &1F LPRINT Print CHR$A to printer --------------------------------------- On entry: A=character to output On exit: A,HL corrupted BC,DE preserved Selects stream 3 (Printer), resets the scroll counter and outputs the character in the A register. &20 SCAN_K Check for keys pressed --------------------------------------- On entry: - On exit: Z - no keys pressed NZ - one or more keys pressed A,HL corrupted BC,DE preserved &21 SEL_DRIVE Switch microdrive motor on or off -------------------------------------------------- On entry: A=drive number or 0 for all off On exit: BC,HL corrupted DE preserved Interupts enabled &22 OPEN_M Open a temporary "M" channel --------------------------------------------- On entry: D_STR1=drive number N_STR1=filename On exit: HL=offset from CHANS of the new channel area IX="M" channel A,BC,DE,HL' corrupted If there is no map for this drive, one is created. &23 CLOSE_M Close a "M" channel ------------------------------------ On entry: IX="M" channel On exit: A,BC,DE,HL corrupted Any remaining data in an output channel is written to the drive. If the map used by this channel is not used by any other channels, it is also deleted. &24 ERASE_M Erase a file from a cartridge ---------------------------------------------- On entry: D_STR1=drive number N_STR1=filename On exit: HL,HL' corrupted &25 READ_SEQ Read the next record of a PRINT file ----------------------------------------------------- On entry: IX="M" channel CHREC=current record CHDRIV=drive number CHNAME=filename On exit: A,BC,DE,HL corrupted The record in CHREC is incremented, then the record is loaded as with hook code &27. &26 WR_RECORD Write the specified record to microdrive --------------------------------------------------------- On entry: IX="M" channel CHREC=record to write CHDRIVE=drive number CHNAME=filename On exit: A,BC,DE,HL corrupted Once the record has been written to the drive, CHREC is incremented. &27 READ_RAND Read the specified record of a PRINT file ---------------------------------------------------------- On entry: IX="M" channel CHREC=record to read CHDRIV=drive number CHNAME=filename On exit: A,BC,DE,HL corrupted &28 RD_SECTOR Read a sector from drive ----------------------------------------- On entry: IX="M" channel to read into CHREC=sector to read On exit: A,BC,DE,HL corrupted Cy=0 - ok Cy=1 - bad CRC in sector The motor must be turned on with SEL_DRIVE. If the sector is not a PRINT file, the buffer is cleared. GRRRRR!!!! &29 RD_NEXT Read next sector from drive -------------------------------------------- On entry: IX="M" channel to read into On exit: A,BC,DE,HL corrupted Cy=0 - ok Cy=1 - bad CRC in sector The motor must be turned on with SEL_DRIVE. The next sector encountered will be read into the channel buffer. If the sector is not a PRINT file, the buffer is cleared. GRRRRR!!!! &2A WR_SECTOR Write a sector to drive ---------------------------------------- On entry: IX="M" channel to read into CHREC=sector to write CHAME, etc must hold the record's filename, etc On exit: A,BC,DE,HL corrupted The motor must be turned on with SEL_DRIVE. &2B MAKE_M Create an "M" channel -------------------------------------- Not available on issue 1 Interface 1. &2C RECLAIM Reclaim an "M" channel --------------------------------------- On entry: IX="M" channel On exit: A,BC,DE,HL corrupted The channel pointed to by IX is reclaimed, along with its map if no other channel is using it. &2D OPEN_N Open a temporary "N" channel --------------------------------------------- On entry: D_STR1=destination station number NTSTAT=this station number On exit: IX="N" channel CURCHL="N" channel in IX A,BC,DE,HL corrupted Creates a temporary "N" channel, and selects it. &2E CLOSE_N Close a "N" channel ------------------------------------ On entry: CURCHL="N" channel On exit: A,BC,DE,HL corrupted Sends an EOF packets if an output channel, then reclaimes the channel. &2F READ_N Read a Network packet -------------------------------------- On entry: On exit: Cy=0 - transmission successful Cy=1 - transmission failed HL corrupted Note: On issue 1, Cy is corrupted on exit. &30 WRITE_N Write a Network packet --------------------------------------- On entry: A=packet type IX="N" channel On exit: Z=1 - broadcasting A,BC,DE,HL corrupted &31 NEWVARS Create Interface 1 system vars if required ----------------------------------------------------------- On entry: - On exit: HL corrupted BC corrupted if first call since reset all others preserved &32 SHADOW Call a routine with the shadow ROM paged in ------------------------------------------------------------ On entry: HD_11=address to call HL corrupted on entry On exit: any exit parameters from the called routine &33 RD_HEADER Read the next cartridge header ----------------------------------------------- Not available on issue 1 Interface 1. &34 OPEN_B Open "B" channel --------------------------------- Not available on issue 1 Interface 1.