home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / cprog / cursesp.zip / CURSESIO.ASM < prev    next >
Assembly Source File  |  1991-12-03  |  9KB  |  310 lines

  1.     TITLE   PCcurses BIOS Control Functions for MicroSoft Assembler
  2.     NAME    CURSESIO
  3.     PAGE    46,132
  4.     ;****************************************************************
  5.     ;*             CURSESIO.ASM                *
  6.     ;*                                *
  7.     ;* This file contains 'C' functions for the MicroSoft 'C' com-    *
  8.     ;* piler v.4.0, and for Borland Turbo 'C'. It exercises a num-    *
  9.     ;* ber of BIOS video calls, and is intended for inclusion in    *
  10.     ;* a curses library package.                    *
  11.     ;*                                *
  12.     ;* The two files FARNEAR.INC and SMALHUGE.INC each contain one    *
  13.     ;* EQUate. These define the module's memory model.        *
  14.     ;*                                *
  15.     ;****************************************************************
  16.     ;* This version of curses is based on ncurses, a curses version    * 
  17.     ;* originally written by Pavel Curtis at Cornell University.    *
  18.     ;* I have made substantial changes to make it run on IBM PC's,    *
  19.     ;* and therefore consider myself free to make it public domain.    *
  20.     ;*                Bjorn Larsson (bl@infovox.se)    *
  21.     ;****************************************************************
  22.     ;* Author: Bjorn Larsson                    *
  23.     ;* Revised:                            *
  24.     ;* 1.4:  For other module changes:            901114    *
  25.     ;* 1.3:  Changes in 'C' modules for checking with        *
  26.     ;*     MSC -W3, Turbo'C' -w -w-pro checkes:        881005    *
  27.     ;* 1.2:     Changed call sequence to some routines, thanks        *
  28.     ;*     to S. Creps. Changed segment name in far code        *
  29.     ;*     mode, thanks to N.D. Pentcheff:        881002    *
  30.     ;* 1.1:  Bad error in curseskeytst(): JZ -> JNZ!    870911    *
  31.     ;* 1.0:     Release:                    870515    *
  32.     ;****************************************************************
  33.     ;
  34.     INCLUDE    FARNEAR.INC        ;DEFINE FAR OR NEAR CALL SEQUENCE
  35.     INCLUDE    SMALHUGE.INC        ;DEFINE FAR OR NEAR DATA ACCESS
  36.     ;
  37. SYSTEM    EQU    21H            ;SYSTEM CALL
  38. BRKCHK    EQU    33H            ;BREAK SET/CHECK FUNCTION CODE
  39.     ;
  40.     if far_call            ;OTHER TEXT NAME IF FAR CALLS
  41. CURSESIO_TEXT    SEGMENT    BYTE PUBLIC 'CODE'
  42.     ASSUME    CS: CURSESIO_TEXT
  43.     else
  44. _TEXT    SEGMENT  BYTE PUBLIC 'CODE'
  45.     ASSUME  CS: _TEXT
  46.     endif
  47.     ;
  48.     ;****************************************************************
  49.     ;* Function entry and exit macros, and parameter fetch macro.    *
  50.     ;* Used by all functions.                    *
  51.     ;****************************************************************
  52.     ;
  53. c_entry    MACRO    f_name
  54.     ;
  55.     if far_call
  56. &f_name    proc far
  57.     else
  58. &f_name    proc near
  59.     endif
  60.     push    bp
  61.     mov    bp,sp
  62.     push    di
  63.     push    si
  64.     ;
  65.     ENDM
  66.     ;
  67. c_exit    MACRO    f_name
  68.     ;
  69.     pop    si
  70.     pop    di
  71.     pop    bp
  72.     ret
  73. &f_name    endp
  74.     ;
  75.     ENDM
  76.     ;
  77. g_parm    MACRO    reg,p_num
  78.     if    far_call
  79.     mov    ®,[bp+&p_num*2+4]
  80.     else
  81.     mov    ®,[bp+&p_num*2+2]
  82.     endif
  83.     ;
  84.     ENDM
  85.     ;
  86.     DB    '@(#)cursesio.asm v.1.4  - 900114', 0
  87.     ;
  88.     PAGE
  89.     ;****************************************************************
  90.     ;*            _cursescattr                *
  91.     ;*                                *
  92.     ;* void _cursescattr(chr,attr)                    *
  93.     ;*                                *
  94.     ;* Writes char 'chr' with attributes 'attr' to the current cur-    *
  95.     ;* sor location.                        *
  96.     ;****************************************************************
  97.     PUBLIC    __cursescattr
  98.     ;
  99.     c_entry __cursescattr
  100.     MOV    AH,9
  101.     MOV    BH,0        ;USE PAGE 0
  102.     g_parm    AL,1        ;GET CHR PARAMETER
  103.     g_parm    BL,2        ;GET ATTR PARAMETER
  104.     MOV    CX,1        ;PUT 1 CHARACTER
  105.     INT    10H
  106.     c_exit    __cursescattr
  107.     ;
  108.     ;****************************************************************
  109.     ;*            _cursescursor                *
  110.     ;*                                *
  111.     ;* void _cursescursor(row,column)                *
  112.     ;*                                *
  113.     ;* Sets the cursor position in video page 0. 'row' and 'column'    *
  114.     ;* are the cursor address. If 'row' is set to 25, no cursor at    *
  115.     ;* all is displayed.                        *
  116.     ;****************************************************************
  117.     PUBLIC    __cursescursor
  118.     ;
  119.     c_entry __cursescursor
  120.     MOV    AH,2
  121.     MOV    BH,0        ;USE PAGE 0
  122.     g_parm    DH,1        ;GET ROW PARAMETER
  123.     g_parm    DL,2        ;GET COLUMN PARAMETER
  124.     INT    10H
  125.     c_exit    __cursescursor
  126.      ;
  127.     ;****************************************************************
  128.     ;*            _cursesgcols                *
  129.     ;*                                *
  130.     ;* int _cursesgcols()                        *
  131.     ;*                                *
  132.     ;* Return the current number of columns on the screen.        *
  133.     ;****************************************************************
  134.     PUBLIC    __cursesgcols
  135.     ;
  136.     c_entry    __cursesgcols
  137.     MOV    AH,15
  138.     INT    10H
  139.     MOV    AL,AH
  140.     XOR    AH,AH
  141.     c_exit    __cursesgcols
  142.     ;
  143.     ;****************************************************************
  144.     ;*            _cursesputc                *
  145.     ;*                                *
  146.     ;* void _cursesputc(chr,colour)                    *
  147.     ;*                                *
  148.     ;* Output character 'chr' to screen in tty fashion. If a colour    *
  149.     ;* mode is active, the character is written with colour        *
  150.     ;* 'colour'.                            *
  151.     ;****************************************************************
  152.     PUBLIC    __cursesputc
  153.     ;
  154.     c_entry    __cursesputc
  155.     MOV    AH,14
  156.     g_parm    AL,1        ;GET CHR PARAMETER
  157.     g_parm    BL,2        ;GET COLOUR PARAMETER
  158.     INT    10H
  159.     c_exit    __cursesputc
  160.     ;
  161.     ;****************************************************************
  162.     ;*            _cursesscroll                *
  163.     ;*                                *
  164.     ;* void _cursesscroll(urow,lcol,lrow,rcol,lines,attr)        *
  165.     ;*                                *
  166.     ;* Scroll a window in the current page up or down. Urow, lcol,    *
  167.     ;* lrow,rcol are the window coordinats. lines is the number of    *
  168.     ;* lines to scroll. If 0, clears the window, if < 0 scrolls    *
  169.     ;* down, > 0 scrolls up. Blanks areas that are left, and sets    *
  170.     ;* character attributes to attr. If in a colour graphics mode,    *
  171.     ;* fills them with the colour 'attr' instead.            *
  172.     ;****************************************************************
  173.     PUBLIC    __cursesscroll
  174.     ;
  175.     c_entry    __cursesscroll
  176.     g_parm    AL,5        ;GET LINES PARAMETER
  177.     MOV    AH,6
  178.     TEST    AL,80H
  179.     JZ    SHORT CS_1
  180.     ;
  181.     MOV    AH,7
  182.     NEG    AL
  183.     ;
  184. CS_1:    g_parm    CH,1        ;GET UROW PARAMETER
  185.     g_parm    CL,2        ;GET LCOL PARAMETER
  186.     g_parm    DH,3        ;GET LROW PARAMETER
  187.     g_parm    DL,4        ;GET RCOL PARAMETER
  188.     g_parm    BH,6        ;GET ATTR PARAMETER
  189.     INT    10H
  190.     c_exit    __cursesscroll
  191.     ;
  192.     ;****************************************************************
  193.     ;*            _cursesgcmode                *
  194.     ;*                                *
  195.     ;* int _cursesgcmode()                        *
  196.     ;*                                *
  197.     ;* Return the current cursor type. Bits 8-15 of the return    *
  198.     ;* value is the start scan row, and bits 0-7 is the end scan    *
  199.     ;* row.                                *
  200.     ;****************************************************************
  201.     PUBLIC    __cursesgcmode
  202.     ;
  203.     c_entry    __cursesgcmode
  204.     MOV    AH,3
  205.     INT    10H
  206.     MOV    AX,CX
  207.     c_exit    __cursesgcmode
  208.     ;
  209.     ;****************************************************************
  210.     ;*            _cursescmode                *
  211.     ;*                                *
  212.     ;* void _cursescmode(startrow,endrow)                *
  213.     ;*                                *
  214.     ;* Sets the cursor type to begin in scan line startrow and end    *
  215.     ;* in scan line endrow. Both values should be 0-31.        *
  216.     ;****************************************************************
  217.     PUBLIC    __cursescmode
  218.     ;
  219.     c_entry __cursescmode
  220.     MOV    AH,1
  221.     g_parm    CH,1        ;GET STARTROW PARAMETER
  222.     g_parm    CL,2        ;GET ENDROW PARAMETER
  223.     INT    10H
  224.     c_exit    __cursescmode
  225.     ;
  226.     ;****************************************************************
  227.     ;*             _curseskey                *
  228.     ;*                                *
  229.     ;* int _curseskey()                        *
  230.     ;*                                *
  231.     ;* Returns the next key code struck at the keyboard. If the low    *
  232.     ;* 8 bits are 0, the upper bits contain the extended character    *
  233.     ;* code. If bit 0-7 are non-zero, the upper bits = 0.        *
  234.     ;****************************************************************
  235.     PUBLIC    __curseskey
  236.     ;
  237.     c_entry __curseskey
  238.     MOV    AH,0
  239.     INT    16H
  240.     CMP    AL,0
  241.     JZ    SHORT EXTKEY
  242.     AND    AX,0FFH
  243. EXTKEY:
  244.     c_exit    __curseskey
  245.     ;
  246.     ;****************************************************************
  247.     ;*            _curseskeytst                *
  248.     ;*                                *
  249.     ;* int _curseskeytst()                        *
  250.     ;*                                *
  251.     ;* Returns 1 if a character is available, 0 otherwise.        *
  252.     ;****************************************************************
  253.     PUBLIC    __curseskeytst
  254.     ;
  255.     c_entry __curseskeytst
  256.     MOV    AH,1
  257.     INT    16H
  258.     JNZ    SHORT TST1
  259.     MOV    AX,0
  260.     JMP    SHORT EXTTST
  261. TST1:    MOV    AX,1
  262. EXTTST:
  263.     c_exit    __curseskeytst
  264.     ;
  265.     ;****************************************************************
  266.     ;*            _cursesgcb                *
  267.     ;*                                *
  268.     ;* int _cursesgcb()                        *
  269.     ;*                                *
  270.     ;* Returns 1 if MSDOS BREAK CHECK is on, otherwise 0.        *
  271.     ;****************************************************************
  272.     PUBLIC    __cursesgcb
  273.     ;
  274.     c_entry __cursesgcb
  275.     MOV    AX,BRKCHK*256+0
  276.     INT    SYSTEM
  277.     XOR    AH,AH
  278.     MOV    AL,DL
  279.     c_exit    __cursesgcb
  280.     ;
  281.     ;****************************************************************
  282.     ;*            _cursesscb                *
  283.     ;*                                *
  284.     ;* void _cursesscb(setting)                    *
  285.     ;*                                *
  286.     ;* Sets MSDOS BREAK CHECK according to 'setting'.        *
  287.     ;****************************************************************
  288.     PUBLIC    __cursesscb
  289.     ;
  290.     c_entry __cursesscb
  291.     MOV    AX,BRKCHK*256+1
  292.     g_parm    DL,1
  293.     AND    DL,DL
  294.     JZ    SHORT SCB1
  295.     MOV    DL,1
  296. SCB1:    INT    SYSTEM
  297.     c_exit    __cursesscb
  298.     ;
  299.     if far_call
  300. CURSESIO_TEXT    ENDS
  301.     else
  302. _TEXT    ENDS
  303.     endif
  304.     if1
  305.     %OUT    Pass 1 Completed
  306.     else
  307.     %OUT    Assembly Completed
  308.     endif
  309.     END
  310.