Z88 Developers' Notes
Contents   Contents of System Calls

OS_Nq, enquire

RST 20H, DEFB $66

IN:

     BC = enquiry code
     ADEHLIX parameters

OUT if call succeeded:

     Fc = 0
     Depends on BC and other arguments

Out if call failed:

     Fc = 1
     A = return code:
          RC_BAD ($04), incorrect reason code or parameters
          RC_UNK ($03), unknown request

Reasons are :

Window management
NQ_WBOX ($8300), return window information 
NQ_WCUR ($8303), return cursort information 
NQ_RDS ($8306), read text from the screen 

Process Management
NQ_Ain ($8600), application enquiry (system use only)
NQ_Khn ($8603), read keyboard handle (use ":INP" device instead)
NQ_Shn ($8606), read screen handle (use ":SCR" device instead)
NQ_Phn ($8609), read printer indirected handle
NQ_Nhn ($860C), read null handle (use ":NUL" device instead)
NQ_Wai ($860F), Who am I? (system use only)
NQ_Com ($8612), read comms handle (use ":COM" device instead)
NQ_Ihn ($8615), read IN handle (use ":INP" device instead)
NQ_Ohn ($8618), read OUT handle (use ":OUT" device instead)
NQ_Rhn ($861B), read direct printer handle

Memory Management 
NQ_Mfs ($8900), read free space information (system use only)
NQ_Slt ($8903), read slot type information (system use only)

Director and CLI 
NQ_Dev ($8C00), fetch current device
NQ_Dir ($8C03), fetch current directory
NQ_Fnm ($8C06), fetch current filename match string

Director and CLI handles 
NQ_Dmh ($8C09), fetch Director special memory handle (system use only)
NQ_Inp ($8C0C), read std. input handle
NQ_Out ($8C0F), read std. output handle
NQ_Prt ($8C12), read printer stream handle
NQ_Tin ($8C15), read input-T handle
NQ_Tot ($8C18), read output-T handle
NQ_Tpr ($8C1B), read printer-T stream handle
NQ_Chn ($8C1E), read comms handle

Panel and Printer Editor values 
Please refer to OS_Sp for Panel and Printer Editor value parameter reason codes. 

Notes:

This call may fail if called from segment 2.

Related calls:

OS_Sp, specify


In the description of each reason code which follow, only successful calls are considered. In some cases it is possible that other error codes will be returned. With luck this should be clear from the context.
 

Window Management

The following enquiry calls are for fetching low level window information:

NQ_WBOX (BC = $8300), return window information

IN:

     A = window ID (ASCII '1' - '8') or A = 0 for current window

OUT:

     A = window id (ASCII '1' to '8')
     C = width
     B = depth
     E = offset from left of screen (always 0)
     D = offset from top of screen (always 0)

Registers changed after return:

     ......../IXIY same
     AFBCDEHL/.... different

Notes:

     D and E return 0 always, ie. offset of start of window relative to
     start of window, not the screen.

NQ_WCUR (BC = $8303), return cursort information

IN:

     A = window ID (ASCII '1' - '8') or A = 0 for current window

OUT:

     A = window ID (ASCII '1' to '8')
     C = x coordinate of cursor
     B = y coordinate of cursor
     D = bit 7 set if cursor is ON

Registers changed after return:

     ......../IXIY same
     AFBCDEHL/.... different

NQ_RDS (BC = $8306), read text from the screen

IN:

     DE = pointer to a buffer to store text
     HL = number of bytes to read

OUT:

     -

Registers changed after return:

     A.BCDEHL/IXIY same
     .F....../.... different

Notes:

This call reads text from the current window starting at the current cursor position. Screen locations which have not been written to are read as NUL (not as SPC) and all the screen locations return same value, ie. if the window width is 40 characters then 40 bytes will be returned for that line. If more than a whole line of characters is to be read then reading resumes at the start of the next line. The cursor position is not affected by this call, but if a ludicrously large value of HL is used then the screen may be affected.


Process Management

The following codes use/return system handles:
 

NQ_Ain ($8600)      Application enquiry (system use only)

IN:  IX = application handle from OS_Poll

OUT, if call successful:

     Fc = 0
     BHL = pointer to application name (null-terminated)
     BDE = pointer to application DOR
     A = CLI-related attributes
     C = preferred code letter.

OUT, if call failed:

     Fc = 1
     A = RC_HAND

Registers changed after return:

     ......../IXIY same
     AFBCDEHL/.... different
NQ_Khn ($8603)      read keyboard handle (use ":INP" device instead)

IN:  -
OUT: IX = keyboard handle

Registers changed after return:

     A.BCDEHL/..IY same
     .F....../IX.. different
NQ_Shn ($8606)      read screen handle (use ":SCR" device instead)

IN:  -
OUT: IX = screen handle

Registers changed after return:

     A.BCDEHL/..IY same
     .F....../IX.. different
NQ_Phn ($8609)      read printer indirected handle

IN:  -
OUT: IX = printer indirected handle

Registers changed after return:

     A.BCDEHL/..IY same
     .F....../IX.. different
NQ_Nhn ($860C)      read null handle (use ":NUL" device instead)

IN:  -
OUT: IX = null handle

Registers changed after return:

     A.BCDEHL/..IY same
     .F....../IX.. different
NQ_Wai ($860F)      Who am I? (system use only)

IN:  -

OUT: IX = static process handle

     BC = dynamic process handle

Registers changed after return:

     A...DEHL/..IY same
     .FBC..../IX.. different



NQ_Com ($8612)      read comms handle (use ":COM" device instead)

IN:  -
OUT: IX = comms handle

Registers changed after return:

     A.BCDEHL/..IY same
     .F....../IX.. different


NQ_Ihn ($8615)      read IN handle (use ":INP" device instead)

IN:  -
OUT: IX = IN handle

Registers changed after return:

     A.BCDEHL/..IY same
     .F....../IX.. different


NQ_Ohn ($8618)      read OUT handle (use ":OUT" device instead)

IN:  -
OUT: IX = OUT handle

Registers changed after return:

     A.BCDEHL/..IY same
     .F....../IX.. different


NQ_Rhn ($861B)      read direct printer handle

IN:  -
OUT: IX = printer direct handle

Registers changed after return:

     A.BCDEHL/..IY same
     .F....../IX.. different

Memory Management

NQ_Mfs ($8900)      read free space information (system use only)

IN:  -
OUT: ABC = free space info (A = MSB, C = LSB)

Registers changed after return:

     ......../IXIY same
     AFBCDEHL/.... different


NQ_Slt ($8903)      read slot type information (system use only)

IN:  D = slot
     E = bank

OUT: A = configuration (bank usage definition):
          BU_EPR = 1     bank is EPROM
          BU_ROM = 2     bank is ROM
          BU_WRK = 4     work memory
          BU_FIX = 8     fixed memory
          BU_RES = 16    reserved memory
          BU_APL = 32    bank is application RAM
          BU_FRE = 128   bank is available RAM

Registers changed after return:

     ..BCDEHL/IXIY same
     AF....../.... different


Director and CLI

These enquiries return extended pointers of a null-terminated string in BHL:
 

IN:  -

NQ_Dev ($8C00)      fetch current device
NQ_Dir ($8C03)      fetch current directory
NQ_Fnm ($8C06)      fetch current filename match string

Registers changed after return:

     A..CDE../IXIY same
     .FB...HL/.... different

Director and CLI handles

The following calls return system handles in IX

NQ_Dmh ($8C09)      fetch Director special memory handle (system use only)

IN:  -
OUT: IX = memory handle

Registers changed after return:

     A.BCDEHL/..IY same
     .F....../IX.. different


NQ_Inp ($8C0C)      read std. input handle

IN:  -
OUT: IX = input stream handle

Registers changed after return:

     A.BCDEHL/..IY same
     .F....../IX.. different


NQ_Out ($8C0F)      read std. output handle

IN:  -
OUT: IX = output stream handle

Registers changed after return:

     A.BCDEHL/..IY same
     .F....../IX.. different


NQ_Prt ($8C12)      read printer stream handle

IN:  -
OUT: IX = printer stream handle

Registers changed after return:

     A.BCDEHL/..IY same
     .F....../IX.. different


NQ_Tin ($8C15)      read input-T handle

IN:  -
OUT: IX = input tee stream handle

Registers changed after return:

     A.BCDEHL/..IY same
     .F....../IX.. different


NQ_Tot ($8C18)      read output-T handle

IN:  -
OUT: IX = output tee stream handle

Registers changed after return:

     A.BCDEHL/..IY same
     .F....../IX.. different


NQ_Tpr ($8C1B)      read printer-T stream handle

IN:  -
OUT: IX = printer tee stream handle

Registers changed after return:

     A.BCDEHL/..IY same
     .F....../IX.. different


NQ_Chn ($8C1E)      read comms handle

IN:  -
OUT: IX = printer comms handle

Registers changed after return:

     A.BCDEHL/..IY same
     .F....../IX.. different

Panel and Printer Editor values

All the Panel and Printer Editor codes can be used to read values via OS_Nq in the following manner:

IN:

     BC = PA_xxx
     A = number of bytes to read
     DE = buffer for bytes to be read

OUT:

     A = number of bytes actually read
SI_SFT calls OS_NQ in an undocumented way for reading Panel settings.
In:	A is not set before call.
	DE is set to 2.

Out:	Result is picked up in E or possibly DE for two-byte returns.

Please refer to OS_Sp for Panel and Printer Editor value parameter reason codes.