home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / library / asmlib / input.doc < prev    next >
Text File  |  1994-05-03  |  30KB  |  855 lines

  1.  
  2. ********************************  INPUT  ************************************
  3.  
  4. ASMLIB Input subroutines (C) Copyright 1991 - 1994 Douglas Herr
  5. all rights reserved
  6.  
  7. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  8.  
  9. A$EDIT:      editor module used by TEdit and GEdit.
  10.              Must be called by GEdit or TEdit
  11. Source:      a$edit.asm (getkey.asm, isdigit.asm, toupper.asm, tolower.asm)
  12.  
  13.              TEdit and GEdit edit a string on a single row of the screen
  14.              (without word wrap).  Strings longer than the column width of
  15.              the screen are scrolled left or right as required.  A public
  16.              byte in A$EDIT's data area, EWIDTH, establishes the effective
  17.              screen width limit.  EWIDTH is a not-to-exceed limit; if the
  18.              actual screen width is less than EWIDTH, EWIDTH is ignored
  19.              and the actual screen width is used instead.  ASMLIB's default
  20.              EWIDTH is 132.
  21.  
  22.              A$EDIT commands for both TEdit and GEdit are:
  23.  
  24.              Ctrl+left arrow = word left
  25.              Ctrl+right arrow = word right
  26.              Ctrl+end = clear to end of string
  27.              Home = go to start of string
  28.              End = go to end of string
  29.  
  30.  
  31.              Option bits, passed to GEdit or TEdit in register AL, are:
  32.  
  33.              Option 1 = upper case input
  34.              Option 2 = lower case input
  35.              Option 1 OR 2 = digits only input
  36.              Option 4 = exit when any non-editing extended key is pressed
  37.                         (example: F-keys, Alt+key; see TEdit)
  38.  
  39. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  40.  
  41. CLEARKEY:    clears the keyboard's 'type-ahead' buffer
  42.              Uses BIOS functions to remove all keys in the buffer.
  43. Source:      clearkey.asm
  44.  
  45. Call with:   no parameters
  46. Returns:     nothing
  47. Uses:        nothing
  48. Supports:    standard and enhanced keyboards
  49. Example:     call   clearkey
  50.  
  51.  
  52.  
  53. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  54.  
  55. GEDIT:       string editor for graphics modes
  56.              See also TEdit for text modes, A$EDIT for general information
  57. Source:      gedit.asm (a$edit.asm, gprint.asm, a$graph.asm, gcursor.asm,
  58.                         strspace.asm, heap.asm)
  59.  
  60. Call with:   DS:[SI] pointing to string buffer; may include a default string
  61.              DS:[DX] pointing to x- & y-coordinates
  62.              assumes DS:@data
  63.              CX = byte size of buffer
  64.              AL = option bits (see A$EDIT)
  65.              You must initialize the near heap before calling GEdit.
  66.              GEdit only works with DrawMode 1 or -1 (see DrawMode in
  67.              GRAPHICS.DOC).  GEdit forces drawmode to 1 or -1 and restores
  68.              the previous drawmode on exit.
  69. Returns:     AX = last key pressed (see getkey for key codes)
  70.              CX = new string length
  71. Uses:        AX, CX, flags
  72. Supports:    all ASMLIB graphics modes
  73. Example:
  74.  
  75. .data
  76. x       dw 8                      ; x-coordinate (pixels from left edge)
  77. y       dw 100                    ; y-coordinate (pixels from top of screen)
  78. extrn   ewidth:byte               ; byte in A$EDIT used to limit columns
  79.                                   ; displayed
  80. .code
  81.         .
  82.         .
  83.         .
  84.         mov   ax,@data
  85.         mov   ds,ax
  86.         assume  ds:@data
  87.         mov   ewidth,40           ; there's stuff on the right side of
  88.                                   ; the screen that should be left alone
  89.  
  90.         lea   si,string_buffer    ; near address of string buffer
  91.         mov   cx,len_buffer       ; byte length of buffer for the string
  92.         mov   al,0                ; nothing tricky
  93.         lea   dx,x                ; point to x & y coordinates
  94.                                   ; see GPrint for explanation of x and y
  95.         call  gedit
  96.  
  97.  
  98.  
  99. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  100.  
  101. GETKEY:      returns next key pressed
  102. Source:      getkey.asm
  103.  
  104. Call with:   no parameters
  105. Returns:     AL = ASCII key code
  106.              AH = 0 if normal key
  107.              AH = 1 if extended key code (such as function keys)
  108. Uses:        AX
  109.              Uses BIOS functions; supports enhanced keyboard if present
  110. Supports:    standard and enhanced keyboards
  111. Example:     call  getkey
  112.              shr   ah,1            ; a function key?
  113.              jc    function_key    ; jump if so
  114.  
  115.  
  116. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  117.  
  118. GPICKF:      pick a file from a list of filenames
  119.              GPickF pops a window on the screen and displays filenames
  120.              matching an input filespec mask.  One filename may be selected
  121.              with cursor keys or with hotkeys.  When Esc, Enter or ^C is
  122.              pressed, GPickF restores the screen and returns the selected
  123.              filename to the calling program.
  124.              Unused memory must be released by STARTUP (see STARTUP.ASM or
  125.              TINY.ASM).  Also requires near heap (see HINIT).
  126.              See also MenuOption.
  127. Source:      gpickf.asm (filelist.asm, $gpick.asm, a$menu.asm, $graph.asm)
  128.  
  129. Call with:   DS:[SI] pointing to filespec mask
  130.              BX = initial selection (0 = first filename)
  131.              CX = file attribute mask
  132.              DS:[DX] pointing to upper left corner of menu box
  133.              assumes DS:DGROUP
  134. Returns:     AX = last key pressed
  135.              ES:[BX] points to filename selected
  136.              CX = maximum length of filename
  137. Uses:        AX, BX, CX, ES
  138. Supports:    all ASMLIB graphics modes
  139. Example:     see PICKF
  140.  
  141. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  142.  
  143. GPICKSTR:    pick a string from a list of ASCIIZ strings
  144. Source:      gpickstr.asm ($gpick.asm, $strlist.asm, a$menu.asm, $graph.asm)
  145.  
  146. Call with:   DS:[SI] pointing to list of ASCIIZ strings
  147.              BX = initial cursor position
  148.              DS:[DX] pointing to (x,y) coordinates of upper left corner
  149.                of selection box
  150.  
  151.              GPickStr pops a window on the screen and displays the list
  152.              of strings.  One string may be selected with cursor keys
  153.              or with hotkeys.  When Esc, Enter or ^C is pressed, GPickStr
  154.              restores the screen and returns a string index number.
  155.              Unused memory must be released by STARTUP (see STARTUP.ASM and
  156.              TINY.ASM), and the near heap must be initialized (see HINIT).
  157.              See also MenuOption.  Maximum number of choices: 255
  158.  
  159. Returns:     AX = last key pressed
  160.              BX = string number selected (first string = 0)
  161. Uses:        AX, BX
  162. Supports:    all ASMLIB graphics modes
  163. Example:     see PICKSTR
  164.  
  165.  
  166. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  167.  
  168. ISALPHA:     determines if a keycode returned by GetKey is a letter from
  169.              A-Z or a-z.
  170. Source:      isalpha.asm
  171.  
  172. Call with:   AX = keycode returned by GetKey.
  173. Returns:     if CF = 0, keycode is a character from A-Z or a-z
  174.              if CF = 1, keycode is not a character from A-Z or a-z
  175.              AX is not changed
  176. Uses:        CF
  177. Example:     call   getkey       ; get next keystroke
  178.              call   isalpha
  179.              jc     not_alpha
  180.  
  181.  
  182. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  183.  
  184. ISDIGIT:     determines if a keycode returned by GetKey is the ASCII code
  185.              for the numeric characters 0-9
  186. Source:      isdigit.asm
  187.  
  188. Call with:   AX = keycode returned by GetKey.
  189. Returns:     if CF = 0, keycode is a character from 0-9
  190.              if CF = 1, keycode is not a character from 0-9
  191.              AX is not changed
  192. Uses:        CF
  193. Example:     call   getkey       ; get next keystroke
  194.              call   isdigit      ; I want numbers only
  195.              jc     not_a_number
  196.  
  197.  
  198.  
  199. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  200.  
  201. ISLOWER:     determine if a keycode returned by GetKey is lower case
  202. Source:      islower.asm
  203.  
  204. ISUPPER:     determine if a keycode returned by GetKey is upper case
  205. Source:      isupper.asm
  206.  
  207. Call with:   AX = keycode returned by GetKey.
  208. Returns:     if CF = 0, keycode is a character from A-Z or a-z
  209.              if CF = 1, keycode is not a character from A-Z or a-z
  210.              AX is not changed
  211. Uses:        CF
  212. Example:     call   getkey       ; get next keystroke
  213.              call   isupper      ; is it upper case?
  214.              jc     not_upper    ; no; could be lower case
  215.  
  216.  
  217.  
  218. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  219.  
  220. JANEIN:      German language version of YesNo
  221.              waits for 'J' or 'N' key to be pressed
  222. Source:      janein.asm
  223.  
  224. Call with:   no parameters
  225.              Key pressed may be upper or lower case.  Upper case is
  226.              returned.  Uses BIOS functions
  227. Returns:     AX = 'J' or AX = 'N'
  228.              future version will also return ^C
  229. Uses:        AX
  230. Example:
  231.  
  232. include asm.inc
  233.  
  234. extrn   JaNein:proc
  235.  
  236. .code
  237.         .
  238.         .
  239.         .
  240.         call  JaNein
  241.  
  242.  
  243.  
  244. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  245.              
  246. KEYIFWAITING:Returns first key if one is waiting in the keyboard buffer,
  247.              or returns with no keycode if no keypress is waiting.
  248. Source:      kifwait.asm (getkey.asm)
  249.  
  250. Call with:   no parameters
  251. Returns:     AX = 0 if no key waiting
  252.              AX = keycode if one is waiting in the buffer.  Uses BIOS.
  253. Uses:        AX
  254. Example:     call  keyifwaiting
  255.  
  256.  
  257.  
  258. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  259.  
  260. KEYORBUTTON: waits for first keypress or mouse button click
  261. Source:      mouse.asm (getkey.asm)
  262.  
  263. Call with:   no parameters
  264.              If a keypress is waiting in the keyboard buffer before
  265.              this subroutine is called, the keycode is returned to
  266.              the calling program without checking mouse button status.
  267. Returns:     AX = keycode, BX = mouse button code (see MouseStatus)
  268. Uses:        AX, BX
  269. Supports:    2- or 3-button mouse, standard or enhanced keyboard
  270. Example:     call   keyorbutton
  271.  
  272.  
  273. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  274.  
  275. KEYWAITING:  Determines if a key is waiting in the keyboard buffer.
  276.              Does not remove the key code from the buffer.  Uses BIOS.
  277. Source:      getkey.asm
  278.  
  279. Call with:   no parameters
  280. Returns:     AX = 0 if no key waiting
  281.              AX = 1 if key waiting
  282. Uses:        AX
  283. Supports:    standard or enhanced keyboard
  284. Example:     call   keywaiting
  285.              or     ax,ax        ; has a key been pressed?
  286.              jz     no_key       ; nope, not yet
  287.  
  288.  
  289. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  290.  
  291. MENUOPTION:  options for PULLDOWN, PICKF, GPICKF, PICKSTR and GPICKSTR
  292. Source:      a$menu.asm
  293.  
  294. Call with:   AX = option value
  295.              BX = option number
  296.  
  297.              If you do not specify any options or if you call MenuOption
  298.              with AX = 0, default values are assumed.
  299.  
  300.              options available are:           defaults:
  301.                0 = normal text color            07h
  302.                1 = current selection color      70h
  303.                2 = list box color               0Fh
  304.                3 = hotkey color                 0Fh         (1)
  305.                4 = optional quitkey             no quitkey  (2)
  306.                5 = exit when hotkey pressed     00h         (3)
  307.                6 = box frame type (see WFRAME)  -1          (4)
  308.  
  309. NOTE: DEFAULT COLORS MAY NOT BE SUITABLE FOR SOME GRAPHICS MODES
  310.  
  311. (1) the first upper-case letter in each string is that string's hotkey
  312.     no upper-case character = no hotkey
  313. (2) the quitkey value is a keycode returned by GetKey
  314. (3) use AX = -1 for exit when hotkey pressed, AX = 0 to disable
  315. (4) text modes only
  316.  
  317. Returns:     nothing
  318. Uses:        nothing
  319. Supports:    GPickF, GPickStr, PullDown, PickF, PickStr menu systems
  320. Example:
  321.  
  322. include   asm.inc
  323. extrn     menuoption:proc, pulldown:proc
  324.  
  325. .code
  326.           .
  327.           .
  328.           .
  329.           mov   bx,0         ; text color
  330.           mov   ax,23        ; white w/ blue background
  331.                              ; in graph modes, this would be
  332.                              ; MOV  AX,0107h  (see GCOLOR in GRAPHICS.DOC)
  333.           call  menuoption
  334.  
  335.  
  336.  
  337.  
  338. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  339.  
  340. MOUSELIMIT:  limits mouse's range of motion
  341. Source:      mouse.asm
  342.  
  343. Call with:   DS:[BX] pointing to pixel coordinates of minimum and maximum
  344.              x and y limits.  X-limits are the horizontal dimension and
  345.              y-limits are the vertical dimension.
  346. Returns:     nothing
  347. Uses:        nothing
  348. Example:
  349.  
  350. .data
  351.  
  352. x0    dw 30
  353. y0    dw 15
  354. x1    dw 620
  355. y1    dw 250
  356.  
  357. .code
  358.        .
  359.        .
  360.        .
  361.       mov    ax,@data      ; you don't need to do this stuff after
  362.       mov    ds,ax         ; your startup code unless you've messed with
  363.       assume ds:@data      ; DS somewhere earlier in the program
  364.  
  365.       lea    bx,x          ; DS:[BX] points to limits
  366.       call   mouselimit
  367.  
  368.  
  369.  
  370. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  371.  
  372. MOUSEPOS:    sets the mouse's position
  373. Source:      mouse.asm
  374.  
  375. Call with:   DS:[DX] pointing to desired x- and y-coordinates
  376.              Note that mouse coordinates are expressed as a pixel location
  377.              as with graphics mode, even if the system is in text mode
  378. Returns:     nothing
  379. Uses:        nothing
  380. Example:
  381.  
  382. .data
  383.  
  384. x     dw 100
  385. y     dw 25
  386.  
  387. .code
  388.       .
  389.       .
  390.       .
  391.       mov    ax,@data      ; you don't need to do this stuff after
  392.       mov    ds,ax         ; your startup code unless you've messed with
  393.       assume ds:@data      ; DS somewhere earlier in the program
  394.  
  395.       lea    dx,x          ; DS:[DX] points to desired position
  396.       call   mousepos
  397.  
  398.  
  399. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  400.  
  401. MOUSESTATUS: determine mouse position & buttons pressed
  402. Source:      mouse.asm
  403.  
  404. Call with:   no parameters
  405. Returns:     if ZF = 1, no buttons are pressed
  406.              if ZF = 0, BX = button code
  407.               BX bit 0 if set = left button is down
  408.               BX bit 1 if set = right button is down
  409.               BX bit 2 if set = center button is down
  410.              CX = horizontal (x) coordinate
  411.              DX = vertical (y) coordinate
  412.              Note that mouse positions are expressed as a pixel location
  413.              as with graphics mode, even if the system is in text mode
  414. Uses:        BX, CX, DX, flags
  415. Example:     call  mousestatus
  416.              jz    no_buttons     ; no buttons pressed if ZF = 1
  417.  
  418.  
  419.  
  420. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  421.  
  422. OUINON:      French language version of YesNo
  423.              waits for 'O' or 'N' key to be pressed
  424. Source:      ouinon.asm
  425.  
  426. Call with:   no parameters
  427.              Key pressed may be upper or lower case.  Upper case is
  428.              returned.  Uses BIOS functions
  429. Returns:     AX = 'O' or AX = 'N'
  430.              future version will also return ^C
  431. Uses:        AX
  432. Example:
  433.  
  434. include asm.inc
  435.  
  436. extrn   OuiNon:proc
  437.  
  438. .code
  439.         .
  440.         .
  441.         .
  442.         call  OuiNon
  443.  
  444.  
  445.  
  446.  
  447.  
  448. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  449.  
  450. PICKF:       pick a file from a list of filenames
  451.              PickF pops a window on the screen and displays filenames
  452.              matching an input filespec mask.  One filename may be selected
  453.              with cursor keys or with hotkeys.  When Esc, Enter or ^C is
  454.              pressed, PickF restores the screen and returns the selected
  455.              filename to the calling program.
  456.              Unused memory must be released by STARTUP (see STARTUP.ASM).
  457.              PickF allocates a block of DOS memory which should be released
  458.              after you are done with it.  See example.
  459.              See also MenuOption.
  460. Source:      pickf.asm ($pick.asm, $listw.asm, m$putw.asm, filelist.asm,
  461.                           dosalloc.asm, wsave.asm, a$menu.asm)
  462.  
  463. Call with:   DS:[SI] pointing to filespec mask
  464.              BX = initial cursor position
  465.              CX = file attribute mask
  466.              DH = top screen row for list (centered if DH = 0FFh)
  467.              DL = left screen column for list (centered if DL = 0FFh)
  468. Returns:     if CF = 0, AX = last key pressed
  469.                         ES:[BX] points to filename selected
  470.                         CX = maximum length of filename
  471.              if CF = 1, no filenames match input filespec
  472. Uses:        AX, BX, CX, ES, CF
  473. Supports:    text mode
  474. Example:
  475.  
  476. include   asm.inc
  477.  
  478. public    myproc
  479. extrn     pickf:proc
  480.  
  481. .data
  482. filespec db '*.asm',0            ; search for ASM source code
  483.  
  484. .code
  485. ; program fragment assumes DS:@data
  486.         .
  487.         .
  488.         .
  489.         lea     si,filespec
  490.         mov     bx,0             ; start at top of list
  491.         xor     dx,dx            ; upper left corner of screen
  492.         mov     cx,0             ; normal files only
  493.         call    pickf
  494.         cmp     ax,0Dh           ; was Enter the last key pressed?
  495.         jne     abort            ;  nope - someone wants out
  496.         call    strndup          ;  yup - copy filename to near heap
  497.         mov     ah,49h
  498.         int     21h              ; release the filename buffer
  499.  
  500.  
  501. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  502.  
  503. PICKSTR:     pick a string from a list of ASCIIZ strings
  504. Source:      pickstr.asm ($pick.asm, m$putw.asm, $strlist.asm, $listw.asm,
  505.                           dosalloc.asm, wsave.asm, a$menu.asm)
  506.  
  507. Call with:   DS:[SI] pointing to list of ASCIIZ strings
  508.              BX = initial cursor position
  509.              DH = top screen row for list (centered if DH = 0FFh)
  510.              DL = left screen column for list (centered if DL = 0FFh)
  511.  
  512.              PickStr pops a window on the screen and displays the list
  513.              of strings.  One string may be selected with cursor keys
  514.              or with hotkeys.  When Esc, Enter or ^C is pressed, PickStr
  515.              restores the screen and returns a string index number.
  516.              Unused memory must be released by STARTUP (see STARTUP.ASM).
  517.              See also MenuOption.  Maximum number of choices: 255
  518.  
  519. Returns:     AX = last key pressed
  520.              BX = string number selected (first string = 0)
  521. Uses:        AX, BX
  522. Supports:    text mode
  523. Example:
  524.  
  525. include   asm.inc
  526.  
  527. public    myproc
  528. extrn     pickstr:proc
  529.  
  530. .data
  531. string1   db 'January',0
  532.           db 'February',0
  533.           db 'March',0
  534.           db 'April',0
  535.           db 'May',0
  536.           db 'June',0
  537.           db 'July',0
  538.           db 'August',0
  539.           db 'September',0
  540.           db 'October',0
  541.           db 'November',0
  542.           db 'December',0
  543.           db 0              ; mark end of menu strings
  544.  
  545. .code
  546. ; program fragment assumes DS:@data
  547.         .
  548.         .
  549.      lea  si,string1
  550.      mov  bx,1
  551.      xor  dx,dx
  552.      call pickstr
  553.  
  554. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  555.  
  556. PULLDOWN:    pull-down menu system
  557. Source:      pulldown.asm (a$menu.asm, tprint.asm, tprintce.asm, tputchr.asm
  558.                            strlen.asm, wclear.asm, wframe.asm, wsize.asm
  559.                            wsave.asm, getkey.asm, pickstr.asm and others)
  560.  
  561. Call with:   DS:[SI] pointing to menu labels
  562.              BH = initial main menu choice, BL = initial submenu choice
  563.              assumes DS:@data
  564.              Unused memory must be released (see STARTUP.ASM and ENDPROG)
  565.  
  566.              If PullDown is called with BL < 0, only the main headings are
  567.              printed initally; the submenus are printed when ENTER is
  568.              pressed, a mouse button is pressed, or when either the down
  569.              arrow key is pressed or a "down" mouse movement is detected.
  570.  
  571.              If PullDown is called with BL >= 0, it starts in the full main
  572.              headings plus submenus mode.  In this mode, a mouse button
  573.              click or the ENTER key will exit PullDown.  In either mode,
  574.              ESC, ^C or the user-defined quitkey (see MenuOption) causes
  575.              PullDown to return to the calling program.
  576.  
  577.              If there are too many main headings to fit across the top of the
  578.              screen, the headings are scrolled left or right as required to
  579.              show the selected heading.  Use Left, Right, Home and End keys
  580.              to change selected headings.  Maximum number of headings: 20
  581.  
  582.              If there are too many submenu choices under a heading to fit
  583.              on the screen, the selections are scrolled up or down as required
  584.              to show the selected item.  Use Up, Down, PgUp, PgDown keys
  585.              to change selection, or press highlighted letter of selection.
  586.              Maximum number of selections per heading: 255
  587.  
  588. Returns:     BH = main menu choice, BL = submenu choice
  589.              if CF = 1, ^C or Ctrl-Break was pressed
  590.              if CF = 0
  591.                  AX = 13 if ENTER was pressed
  592.                  AX = user-defined quitkey if pressed (see MenuOption)
  593.                  AX = 0 if insufficient DOS memory is available
  594.                  AX = 27 if ESC was pressed
  595.                  AH = 1-7, AL = 0 if mouse button pressed
  596. Uses:        AX, BX
  597. Supports:    text mode; all row/column configurations supported by ASMLIB
  598.              Text subroutines
  599. Example:
  600.  
  601. see next page
  602.  
  603. ;    this sample menu has 4 main menu headings:
  604. ;                          Critters, Things, Food, Trees
  605. ;    submenu choices for each main heading follow each main heading
  606. ;    Note that each string is terminated with NUL, and that there's an
  607. ;    extra NUL between the end of the submenu choices and the next main
  608. ;    heading.
  609. ;    The entire set of menu choices is terminated with 2 NUL bytes
  610. ;
  611. ;    PULLDOWN will return to the calling program when either ESCAPE or
  612. ;    ENTER is pressed (AX = ASCII code of key pressed).  PULLDOWN returns
  613. ;    AX = 0 if insufficient memory is available to save the underlying
  614. ;    screen, or AX = 3 if breaktrap was enabled and Ctrl+Break was pressed.
  615. ;
  616. ;    On return, BH = the main heading and BL = the submenu choice in effect
  617. ;    when the key was pressed.  The first main heading is number 0, and
  618. ;    the first submenu choice for each main heading is also number 0.
  619.  
  620. include asm.inc
  621.  
  622. extrn     pulldown:proc
  623.  
  624. .stack
  625.  
  626. .data
  627. menu    db 'Critters',0
  628.         db 'Goats',0,'Chickens',0,'Turkeys',0,'Cows',0,'Snow dogs',0
  629.  
  630.         db 0                   ; separate Things from Critters
  631.         db 'Things',0
  632.         db 'Computers',0,'Tractors',0,'CPU chips',0,'Barbie dolls',0
  633.  
  634.         db 0                   ; separate Food from Things
  635.         db 'Food',0
  636.         db 'Hot dogs',0,'Wheat germ',0,'Lasagne',0,'Cheerios',0
  637.         db 'Potatoes',0,'chocolate chip cooKies',0
  638.  
  639.         db 0                   ; separate Trees from Food
  640.         db 'Trees',0
  641.         db 'giant Sequoia',0,'black Spruce',0,'Willow',0,'live Oak',0
  642.         db 'Acacia',0,'digger Pine',0
  643.  
  644.         db 2 dup(0)            ; end of menu choices
  645.  
  646. .code
  647. ; program fragment assumes DS:@data
  648.         .
  649.         .
  650.         .
  651.         lea   si,menu          ; point to menu labels
  652.         xor   bx,bx            ; initial selection is "goats"
  653.         call  pulldown
  654.  
  655.  
  656. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  657.  
  658. SINO:        Spanish language version of YesNo
  659.              waits for 'S' or 'N' key to be pressed
  660. Source:      sino.asm
  661.  
  662. Call with:   no parameters
  663.              Key pressed may be upper or lower case.  Upper case is
  664.              returned.  Uses BIOS functions
  665. Returns:     AX = 'S' or AX = 'N'
  666.              future version will also return ^C
  667. Uses:        AX
  668. Example:     call  sino
  669.  
  670.  
  671. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  672.  
  673. TEDIT:       ASCIIZ string editor for text modes
  674.              See also GEdit for graphics modes, A$EDIT for general information.
  675.              TEdit turns the cursor off (with CursorOFF) on exit.
  676. Source:      tedit.asm (a$edit.asm, cursor.asm, a$clrw.asm, str2vbuf.asm,
  677.                         crtinfo.asm)
  678.  
  679. Call with:   DS:[SI] pointing to string buffer; may include a default string
  680.              assumes DS:@data
  681.              CX = byte size of buffer (excluding terminating NUL)
  682.              AH = color attribute
  683.              AL = option bits (see A$EDIT)
  684.              DH = row (offset from top of screen)
  685.              DL = column (offset from left edge of screen)
  686.  
  687. Returns:     AX = last key pressed (see GetKey for key codes)
  688.              CX = new string length
  689. Uses:        AX, CX, flags
  690. Supports:    text modes; all row/column configurations
  691.  
  692. Example on next page
  693.  
  694.  
  695. ; TEdit example:
  696.  
  697. include asm.inc
  698.  
  699. extrn   tedit:proc
  700.  
  701. .data
  702. extrn   estart:word, elast:word
  703. string_buffer   db 120 dup(' ')
  704. len_buffer      equ $-string_buffer
  705.                 db 0              ; give it a terminal NUL
  706.  
  707. .code
  708. ; program fragment assumes DS:@data
  709.         .
  710.         .
  711.         .
  712. string_edit:
  713.         lea     si,string_buffer    ; near address of string buffer
  714.         mov     cx,len_buffer       ; byte length of buffer for the string
  715.         mov     dh,row
  716.         mov     dl,column
  717.         mov     ah,attr             ; color attribute
  718.         mov     al,2                ; force lower case
  719.         or      al,4                ; trap Up & Down arrow keys
  720.         call    tedit
  721.         shr     ah,1                ; returned due to extended key?
  722.         jnc     normal_exit
  723.  
  724. ; check for desired extended keys
  725.         cmp     al,72               ; Up arrow key?
  726.         je      go_up
  727.         cmp     al,80               ; Down arrow key?
  728.         je      go_down
  729.  
  730. ; extended key pressed was not Up or Down
  731. ; get cursor position when key was pressed & force TEdit to resume
  732. ; at that point
  733.         mov     ax,elast            ; last cursor position
  734.         mov     estart,ax           ; force non-zero starting offset
  735.         jmp     string_edit
  736.  
  737.  
  738.  
  739. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  740.  
  741. TMOUSELIMIT: limits mouse's range of motion on text mode screen
  742. Source:      tmlimit.asm
  743.  
  744. Call with:   DS:[BX] pointing to character coordinates of minimum and maximum
  745.              rows and columns.  Columns are the horizontal dimension and
  746.              rows are the vertical dimension.
  747. Returns:     nothing
  748. Uses:        nothing
  749. Example:
  750.  
  751. .data
  752.  
  753. x0    dw 3          ; first row
  754. y0    dw 1          ; first column
  755. x1    dw 20         ; last row
  756. y1    dw 50         ; last column
  757.  
  758. .code
  759. ; program fragment assumes DS:@DATA
  760.        .
  761.        .
  762.        .
  763.       lea    bx,x          ; DS:[BX] points to limits
  764.       call   tmouselimit
  765.  
  766. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  767.  
  768. TMOUSEPOS:   set mouse position on text-mode screen
  769. Source:      tmouspos.asm
  770.  
  771. Call with:   DH = row (vertical position)
  772.              DL = column (horizontal position)
  773. Returns:     nothing
  774. Uses:        flags
  775. Example:
  776.  
  777. ; I want to center the mouse cursor on a standard 80-column, 25-row screen
  778.  
  779. include asm.inc
  780.  
  781. extrn   tmousepos:proc
  782.  
  783. .code
  784.         .
  785.         .
  786.         .
  787.         mov    dh,12           ; close to vertical center
  788.                                ; coordinates are 0 through 24 vertially
  789.         mov    dl,39           ; coordinates are 0 through 79 horizontally
  790.         call   tmousepos
  791.  
  792.  
  793. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  794.  
  795. TMOUSESTATUS:determine mouse position on text screen & buttons pressed
  796. Source:      tmstatus.asm
  797.  
  798. Call with:   no parameters
  799.              assumes mouse is installed (see IsMouse in SYSTEM.DOC)
  800. Returns:     if ZF = 1, no buttons are pressed
  801.              if ZF = 0, BX = button code
  802.               BX bit 0 if set = left button is down
  803.               BX bit 1 if set = right button is down
  804.               BX bit 2 if set = center button is down
  805.              DH = row (vertical position)
  806.              DL = column (horizontal position)
  807. Uses:        BX, DX, flags
  808. Example:     call  tmousestatus
  809.              jz    no_buttons     ; no buttons pressed if ZF = 1
  810.  
  811.  
  812.  
  813. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  814.  
  815. TOLOWER:     converts keycode returned by getkey to lower case
  816. Source:      tolower.asm
  817.  
  818. Call with:   AX = keycode
  819. Returns:     AX = lower case keycode
  820.              ToLower leaves the keycode alone if the keycode is not
  821.              upper case A-Z.
  822. Uses:        AX
  823. Example:     call   getkey
  824.              call   tolower
  825.  
  826.  
  827. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  828.  
  829. TOUPPER:     converts keycode returned by getkey to upper case
  830. Source:      toupper.asm
  831.  
  832. Call with:   AX = keycode
  833. Returns:     AX = upper case keycode
  834.              ToUpper leaves the keycode alone if the keycode is not
  835.              lower case a-z.
  836. Uses:        AX
  837. Example:     call   getkey
  838.              call   toupper
  839.  
  840.  
  841. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  842.  
  843. YESNO:       waits for 'Y' or 'N' key to be pressed
  844. Source:      yesno.asm
  845.  
  846. Call with:   no parameters
  847.              Key pressed may be upper or lower case.  Upper case is
  848.              returned.  Uses BIOS functions
  849. Returns:     AX = 'Y' or AX = 'N'
  850.              future version will also return ^C
  851. Uses:        AX
  852. Example:     call  yesno
  853.  
  854.  
  855.