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