*******************************************************************************
*                                                                             *
*                                                                             *
*        The QDOS parameter file - part 1                                     *
*                                                                             *
*******************************************************************************
 
         NOLIST
*
*   The QDOS parameters are split into two files:  this one is
*   QDOS1_IN and the other one is QDOS2_IN.
*
*   This is to make sure that each file is small enough to be edited
*   with the ED editor which is incapable of editing large files.
 
 
* SYS.ERR                           error keys
 
*
ERR.NC    EQU    -1                 operation not complete
ERR.NJ    EQU    -2                 not a valid Job
ERR.OM    EQU    -3                 out of memory
ERR.OR    EQU    -4                 out of range
ERR.BO    EQU    -5                 buffer overflow
ERR.NO    EQU    -6                 channel not open
ERR.NF    EQU    -7                 file or device not found
ERR.EX    EQU    -8                 file already exists
ERR.IU    EQU    -9                 file or device in use
ERR.EF    EQU    -10                end of file
ERR.DF    EQU    -11                drive full
ERR.BN    EQU    -12                bad device name
ERR.TE    EQU    -13                transmission error
ERR.FF    EQU    -14                format failed
ERR.BP    EQU    -15                bad parameter
ERR.FE    EQU    -16                file error
ERR.XP    EQU    -17                error in expression
ERR.OV    EQU    -18                arithmetic overflow
ERR.NI    EQU    -19                not implemented (yet)
ERR.RO    EQU    -20                read only
ERR.BL    EQU    -21                bad line (syntax error in BASIC)
ERR.AT    EQU    -22                At line message 
ERR.SC    EQU    -23                sectors message
ERR.BT    EQU    -24                boot message
ERR.CP    EQU    -25                copyright message
ERR.PF    EQU    -26                proc/fn message
DAYTAB    EQU     27                days of the week
MONTAB    EQU     28                months of the year
*
* SYS.MT                            manager trap keys
 
*
MT.INF    EQU    $00                get system information
MT.CJOB   EQU    $01                create a job
MT.JINF   EQU    $02                get information on job
*
MT.RJOB   EQU    $04                remove a job
MT.FRJOB  EQU    $05                force remove a job
MT.FREE   EQU    $06                find out how much free space there is
MT.TRAPV  EQU    $07                set pointer to trap redirection vectors
MT.SUSJB  EQU    $08                suspend a job
MT.RELJB  EQU    $09                release a job
MT.ACTIV  EQU    $0A                activate a job
MT.PRIOR  EQU    $0B                set a job priority
MT.ALLOC  EQU    $0C                allocate a bit of a heap
MT.LNKFR  EQU    $0D                release a bit of a heap
MT.ALRES  EQU    $0E                allocate resident procedure area
MT.RERES  EQU    $0F                release resident procedure area
MT.DMODE  EQU    $10                set display mode
MT.IPCOM  EQU    $11                send IPC command
MT.BAUD   EQU    $12                set baud rate
MT.RCLCK  EQU    $13                read clock
MT.SCLCK  EQU    $14                set clock
MT.ACLCK  EQU    $15                adjust clock
MT.ALBAS  EQU    $16                allocate Basic area
MT.REBAS  EQU    $17                release Basic area
MT.ALCHP  EQU    $18                allocate space in common heap
MT.RECHP  EQU    $19                release space in common heap
MT.LXINT  EQU    $1A                link in external interrupt handler
MT.RXINT  EQU    $1B                remove external interrupt handler
MT.LPOLL  EQU    $1C                link in polled task
MT.RPOLL  EQU    $1D                remove polled task
MT.LSCHD  EQU    $1E                link in scheduler task
MT.RSCHD  EQU    $1F                remove scheduler task
MT.LIOD   EQU    $20                link in IO driver
MT.RIOD   EQU    $21                remove IO driver
MT.LDD    EQU    $22                link in directory driver
MT.RDD    EQU    $23                remove directory driver
MT.CNTRY  EQU    $24                set up i/o translation tables
*
* SYS.SV                            system variable definitions
 
*
SV_BASE   EQU    $28000             base of system vars
*
SV_IDENT  EQU    $00  word          identification word
SV_CHEAP  EQU    $04  long          base of common heap area
SV_CHPFR  EQU    $08  long          first free space in common heap area
SV_FREE   EQU    $0C  long          base of free area
SV_BASIC  EQU    $10  long          base of basic area
SV_TRNSP  EQU    $14  long          base of transient program area
SV_TRNFR  EQU    $18  long          first free space in transient program area
SV_RESPR  EQU    $1C  long          base of resident procedure area
SV_RAMT   EQU    $20  long          top of ram (+1)
*
SV_RAND   EQU    $2E  word          random number
SV_POLLM  EQU    $30  word          count of poll interupts missed
SV_TVMOD  EQU    $32  byte          0 if not TV display
SV_SCRST  EQU    $33  byte          screen status (0 = active)
SV_MCSTA  EQU    $34  byte          current value of MC status register
SV_PCINT  EQU    $35  byte          current value of PC interrupt register
*
SV_NETNR  EQU    $37  byte          network station number
*
SV_I2LST  EQU    $38  long          pointer to list of interrupt 2 drivers
SV_PLIST  EQU    $3C  long          pointer to list of polled tasks
SV_SHLST  EQU    $40  long          pointer to list of scheduler tasks
SV_DRLST  EQU    $44  long          pointer to list of device drivers
SV_DDLST  EQU    $48  long          pointer to list of directory device drivers
SV_KEYQ   EQU    $4C  long          pointer to a keyboard queue
SV_TRAPV  EQU    $50  long          pointer to the trap redirection table
*
* pointers to the resource management tables
* the slave block tables have 8 byte entries, the others 4 byte entries
*
SV_BTPNT  EQU    $54  long          pointer to most recent slave block entry
SV_BTBAS  EQU    $58  long          pointer to base of slave block table
SV_BTTOP  EQU    $5C  long          pointer to top of slave block table
*
SV_JBTAG  EQU    $60  word          current value of Job tag
SV_JBMAX  EQU    $62  word          highest current Job number
SV_JBPNT  EQU    $64  long          pointer to current Job table entry
SV_JBBAS  EQU    $68  long          pointer to base of Job table
SV_JBTOP  EQU    $6C  long          pointer to top of Job table
*
SV_CHTAG  EQU    $70  word          current value of channel tag
SV_CHMAX  EQU    $72  word          highest current channel number
SV_CHPNT  EQU    $74  long          pointer to last channel checked
SV_CHBAS  EQU    $78  long          pointer to base of channel table
SV_CHTOP  EQU    $7C  long          pointer to top of channel table
*
SV_CAPS   EQU    $88  word          caps lock
SV_ARBUF  EQU    $8A  word          autorepeat buffer
SV_ARDEL  EQU    $8C  word          autorepeat delay
SV_ARFRQ  EQU    $8E  word          autorepeat 1/freq
SV_ARCNT  EQU    $90  word          autorepeat count
SV_CQCH   EQU    $92  word          keyboard change queue character code
SV_WP     EQU    $94  word          write protect
SV_SOUND  EQU    $96  word          sound status
SV_SER1C  EQU    $98  long          receive  channel 1 queue address
SV_SER2C  EQU    $9C  long          receive  channel 2 queue address
SV_TMODE  EQU    $A0  byte          ZX8302 transmit mode (includes baudrate)
*
SV_CSUB   EQU    $A2  long          Subroutine to jump to on CAPSLOCK
SV_TIMO   EQU    $A6  word          Timeout for switching transmit mode
SV_TIMOV  EQU    $A8  word          Value of switching timeout (two characters)
SV_FSTAT  EQU    $AA  word          flashing cursor status
*
SV_MDRUN  EQU    $EE  byte          which drive is running?
SV_MDCNT  EQU    $EF  byte          microdrive run-up run-down counter
SV_MDDID  EQU    $F0  8 bytes       drive ID*4 of each microdrive
SV_MDSTA  EQU    $F8  8 bytes       status 0= no pending ops
SV_FSDEF  EQU    $100 16 long       pointers to file system physical definition
SV_FSLST  EQU    $140 long          pointer to list of file channel definitions
SV_TRAN   EQU    $144 byte          I/O translation flag (#0 =  translate)    
SV_ICHAR  EQU    $145 byte          one character input buffer
SV_TRTAB  EQU    $146 long          translation table adddress
SV_MGTAB  EQU    $14A long          message table address
*
SV_STACB  EQU    $180 192 long      bottom of stack
SV_STACT  EQU    $480 to here       big stack - no check
*
SV_TRAPO  EQU    2*($28+2)          offset of trap vector table from (SV_TRAPV)
*
SV.IDENT  EQU    $D254              green, red, blue and black, with flash bits
*
* device driver definitions (for the driver's own pseudo system vars)
*
SV_LXINT  EQU    $00  long          link to next external interrupt service
SV_AXINT  EQU    $04  long          address of external interrupt service
SV_LPOLL  EQU    $08  long          link to next polling interrupt service
SV_APOLL  EQU    $0C  long          address of polling interrupt service
SV_LSCHD  EQU    $10  long          link to next scheduler task
SV_ASCHD  EQU    $14  long          address of scheduler task
SV_LIO    EQU    $18  long          link to next IO driver
SV_AIO    EQU    $1C  long          address of input/output routine
SV_AOPEN  EQU    $20  long          address of channel open routine
SV_ACLOS  EQU    $24  long          address of channel close routine
*
* SYS.RA                            RAM size definitions
 
*
RA_BOT    EQU    $20000             Bottom of RAM
RA_MIN    EQU    $20000             Minimum RAM size - 128 kbytes
RA_SSIZE  EQU    $8000              Screen size
*
 
*
TRLV_D7   EQU    $00 (long)         address of saved D7 on stack
TRLV_A5   EQU    $04 (long)         address of saved A5 on stack
TRLV_A6   EQU    $08 (long)         address of saved A6 on stack
TRLV_SR   EQU    $0C (word)         address of saved SR on stack
TRLV_PC   EQU    $0E (long)         address of saved PC on stack
TRLV_TOP  EQU    $12
*
* SYS.BT                            memory block table definitions
 
*
*         memory block table entries
*
BT_STAT   EQU    $00  (byte)        drive ID / status byte - see below
BT_PRIOR  EQU    $01  (byte)        block priority
*
BT_SECTR  EQU    $02  (word)        sector number (microdrive*2)
*
BT_FILNR  EQU    $04  (word)        file number (microdrive)   } logical
BT_BLOCK  EQU    $06  (word)        block number (microdrive)  } location
BT_END    EQU    $08
*
*         the most significant 4 bits of the status byte contain the pointer
*         to the physical device block SV_FSDEF, the least significant are the
*         status codes:
*
BT.UNAV   EQU    %00000000          block is unavailable to file system
BT.EMPTY  EQU    %00000001          block is empty
*
BT.RREQ   EQU    %00001001          block required to be read from microdrive
*
BT.TRUE   EQU    %00000011          block is a true representation of file
BT.AVER   EQU    %00001011          block is awaiting verify
BT.UPDT   EQU    %00000111          block is updated
*
*         status code masks
*
BT.ACTN   EQU    %00001100          check for read or write request
BT.INUSE  EQU    %00001110          check if a file block in use
*
*         bits of status codes
*
BT..FILE  EQU    0                  1 if a file block
BT..ACCS  EQU    1                  1 if contents may be accessed
BT..WREQ  EQU    2                  1 if block required to be written
BT..RDVR  EQU    3                  1 if block required to be read / verified
*
* SYS.JB                            Job header and save area definitions
 
*
JB_LEN    EQU    $00  long          length of job segment
JB_START  EQU    $04  long          start address
JB_OWNER  EQU    $08  long          owner of this job
JB_HOLD   EQU    $0C  long          ptr to byte to be CLR when job released
JB_TAG    EQU    $10  word          tag for this job
JB_PRIOR  EQU    $12  byte          current accumulated priority
JB_PRINC  EQU    $13  byte          priority increment, if =0 job inactive
JB_STAT   EQU    $14  word          job status =0 potentially active
*                                              >0 delay time (frames)
*                                              <0 suspended
JB_RELA6  EQU    $16  byte          MSB set if next trap #2 or #3 is rel A6
JB_WFLAG  EQU    $17  byte          set if there is a Job waiting on completion
JB_WJOB   EQU    $18  long          Job ID of waiting Job
JB_TRAPV  EQU    $1C  long          pointer to trap redirection vectors
JB_D0     EQU    $20                save offset of D0
JB_D1     EQU    $24                save offset of D1
JB_D7     EQU    $3C                save offset of D7
JB_A1     EQU    $44                save offset of A1
JB_A4     EQU    $50                save offset of A4
JB_A5     EQU    $54                save offset of A5
JB_A6     EQU    $58                save offset of A6
JB_A7     EQU    $5C                save offset of A7
JB_USP    EQU    $5C                save offset of USP
JB_SR     EQU    $60                save offset of SR
JB_PC     EQU    $62                save offset of PC
*
JB_END    EQU    $68
* SYS.CH                            channel definition block / driver headers
 
*
* channel definition header for all channels
*
CH_LEN    EQU    $00 long           length of definition block
CH_DRIVR  EQU    $04 long           address of driver
CH_OWNER  EQU    $08 long           owner job
CH_RFLAG  EQU    $0C long           address to be set when space released
CH_TAG    EQU    $10 word           channel tag
CH_STAT   EQU    $12 byte           status - 0 OK, negative waiting
*                                          -1 A1 abs, $80 A1 rel A6
CH_ACTN   EQU    $13 byte           stored action for waiting job
CH_JOBWT  EQU    $14 long           ID of job waiting on IO
CH_END    EQU    $18
*
* extended channel definition for plain serial queues
*
CH_QIN    EQU    $18 long           pointer to input queue (or zero)
CH_QOUT   EQU    $1C long           pointer to output queue (or zero)
CH_QEND   EQU    $20
*
* device driver header
*
CH_NEXT   EQU    $0  long           pointer to next driver
CH_INOUT  EQU    $4  long           entry for input and output
CH_OPEN   EQU    $8  long           entry for open
CH_CLOSE  EQU    $C  long           entry for close
*
* the following are for directory devices (file system) only
*
CH_SLAVE  EQU    $10 long           entry for slaving blocks
CH_RENAM  EQU    $14 long           entry reserved for rename
*
CH_FORMT  EQU    $1C long           entry for format medium
CH_DFLEN  EQU    $20 long           length of physical definition block
CH_DRNAM  EQU    $24 2+n byte       drive name
 
 
* SYS.HP                            common heap header definition
 
*
*
HP_LEN    EQU    $00 long           length of definition block
HP_DRIVR  EQU    $04 long           address of driver to free block when
*                                   owner is deleted (-CH_CLOSE)
HP_NEXT   EQU    $04 long           pointer to next free space
HP_OWNER  EQU    $08 long           owner job (0 if free space)
HP_RFLAG  EQU    $0C long           address to be set when space released
HP_END    EQU    $10
*
HP_CLOSE  EQU    $C                 offset of close entry point WRT driver add
*
* SYS.IO                            basic IO keys
 
*
* Trap #2 D0 keys
*
IO.OPEN   EQU    1                  open channel
IO.CLOSE  EQU    2                  close channel
IO.FORMT  EQU    3                  format medium
IO.DELET  EQU    4                  delete file
*
* Trap #2 D3 keys
*
IO.OLD    EQU    0                  open old (exclusive) file or device
IO.SHARE  EQU    1                  open old (shared) file
IO.NEW    EQU    2                  open new (exclusive) file
IO.OVERW  EQU    3                  overwrite (or open new) file
IO.DIR    EQU    4                  open directory
*
* Trap #3 D0 keys
*
IO.PEND   EQU    0                  check for pending input
IO.FBYTE  EQU    1                  fetch a byte
IO.FLINE  EQU    2                  fetch a line of bytes
IO.FSTRG  EQU    3                  fetch a string of bytes
IO.EDLIN  EQU    4                  edit a line
IO.SBYTE  EQU    5                  send a byte
*
IO.SSTRG  EQU    7                  send a string of bytes
 
 
 
* SYS.FS                            file system definitions and keys
 
*
*         file system channel channel definition block
*
FS_NEXT   EQU    $18   (long)       link to next file system channel
FS_ACCES  EQU    $1C   (byte)       access mode
FS_DRIVE  EQU    $1D   (byte)       drive ID
FS_FILNR  EQU    $1E   (word)       file number
FS_NBLOK  EQU    $20   (word)       block containing next byte
FS_NBYTE  EQU    $22   (word)       next byte in block
FS_EBLOK  EQU    $24   (word)       end of file (block)
FS_EBYTE  EQU    $26   (word)       end of file (byte in block)
FS_CBLOK  EQU    $28   (long)       pointer to table for current slave block
FS_UPDT   EQU    $2C   (byte)       set if file is updated
*
FS_FNAME  EQU    $32   (name 2+36)  file name
FS_SPARE  EQU    $58   72 bytes
FS_END    EQU    $A0
*
FS.NMLEN  EQU    $24                max length of file name
FS.HDLEN  EQU    $40                length of file system header
*
* the common part of a physical file system definition block
*
FS_DRIVR  EQU    $10  long          pointer to driver
FS_DRIVN  EQU    $14  byte          drive number
*
FS_MNAME  EQU    $16  word+10 bytes medium name
FS_FILES  EQU    $22  byte          number of files open
*
*         file system keys
*
FS.CHECK  EQU    $40                check all pending operations
FS.FLUSH  EQU    $41                flush buffers
FS.POSAB  EQU    $42                position file pointer (absolute)
FS.POSRE  EQU    $43                position file pointer (relative)
*
FS.MDINF  EQU    $45                information about medium
FS.HEADS  EQU    $46                set file header
FS.HEADR  EQU    $47                read file header
FS.LOAD   EQU    $48                load file
FS.SAVE   EQU    $49                save file
*
 
* SYS.Q                             IO queue header definitions
 
*
Q_EOFF    EQU    $0   bit           end of file flag (MSbit)
Q_NEXTQ   EQU    $0   long          link to next queue
Q_END     EQU    $4   long          pointer to end of queue
Q_NEXTIN  EQU    $8   long          pointer to next location to put byte in
Q_NXTOUT  EQU    $C   long          pointer to next location to take byte from
Q_QUEUE   EQU    $10                start of queue
*
* SYS.MC                            Master chip registers
 
*
MC_STAT   EQU    $18063             Status register
*
MC..BLNK  EQU    $1                 bit 1 blanks display
MC..M256  EQU    $3                 bit 3 set 256 mode
MC..SCRN  EQU    $7                 bit 7 sets screen number
*
* SYS.PC                            peripheral chip registers
 
*
PC_CLOCK  EQU    $18000             real time clock in seconds (long word)
PC_TCTRL  EQU    $18002             transmit control
PC_MCTRL  EQU    $18020             Microdrive/link control register
PC_IPCRD  EQU    $18020             IPC read is the same
PC_IPCWR  EQU    $18003             IPC write is not
PC_INTR   EQU    $18021             interrupt register
PC_TDATA  EQU    $18022             transmit register
PC_TRAK1  EQU    $18022             Microdrive read track1
PC_TRAK2  EQU    $18023             Microdrive read track2
*
PC.INTRG  EQU    $01                gap interrupt register
PC.INTRI  EQU    $02                interface interrupt register
PC.INTRT  EQU    $04                transmit interrupt register
PC.INTRF  EQU    $08                frame interrupt register
PC.INTRE  EQU    $10                external interrupt register
PC.MASKG  EQU    $20                gap mask register
PC.MASKI  EQU    $40                interface mask register
PC.MASKT  EQU    $80                transmit mask register
*
* transmit control register values
*
PC..SERN  EQU    3                  serial port number
PC..SERB  EQU    4                  0=serial IO
PC..DIRO  EQU    7                  direct output
*
PC.BMASK  EQU    %00000111          baud rate mask
PC.NOTMD  EQU    %11100111          all bits except mode control
PC.MDVMD  EQU    %00010000          microdrive mode
PC.NETMD  EQU    %00011000          network mode
*
* microdrive control register values
*
* write
*
PC..SEL   EQU    0                  microdrive select bit
PC..SCLK  EQU    1                  microdrive select clock bit
PC..WRIT  EQU    2                  microdrive write
PC..ERAS  EQU    3                  microdrive erase
*
* read
*
PC..TXFL  EQU    1                  microdrive Xmit buffer full
PC..RXRD  EQU    2                  microdrive read buffer ready
PC..GAP   EQU    3                  gap
PC..DTR1  EQU    4                  DRT on port 1
PC..CTS2  EQU    5                  CTS on port 2
*
* write masks
*
PC.READ   EQU    %0010              read (or idle) microdrive
PC.SELEC  EQU    %0011              select bit set
PC.DESEL  EQU    %0010              select bit not set
PC.ERASE  EQU    %1010              erase on / write off
PC.WRITE  EQU    %1110              erase and write
 
          LIST