home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS 1992 December / simtel1292_SIMTEL_1292_Walnut_Creek.iso / msdos / vga / vansi.arc / NANSI_F.ASM next >
Assembly Source File  |  1989-11-22  |  25KB  |  652 lines

  1.         page    66, 132
  2. ;----- nansi_f.asm ---------------------------------------------
  3. ; The ANSI control subroutines.
  4. ; (C) 1986 Daniel Kegel, Pasadena, CA
  5. ; May be distributed for educational and personal use only
  6. ; Each routine is called with the following register usage:
  7. ;  AX = max(1, value of first parameter)
  8. ;  Z flag is set if first parameter is zero.
  9. ;  CX = number of paramters
  10. ;  SI = offset of second parameter from CS
  11. ;  DS = CS
  12. ;  ES:DI points to the current location on the memory-mapped screen.
  13. ;  DX is number of characters remaining on the current screen line.
  14. ; The control routine is free to trash AX, BX, CX, SI, and DS.
  15. ; It must preserve ES, and can alter DX and DI if it wants to move the
  16. ; cursor.
  17. ;
  18. ; Revisions:
  19. ;  19 Aug 85: Fixed horrible bug in insert/delete line.
  20. ;  26 Aug 85: Fixed simple limit-to-one-too-few-lines bug in ins/del line;
  21. ;  anyway, it inserts 24 lines when on line 2 now.  Whether it's fixed...
  22. ;  4 Sept 85: Fixed bug created on 26 Aug 85; when limiting ins/del line
  23. ;  count, we are clearing, not scrolling; fixed BIOS call to reflect this.
  24. ;  30 Jan 86: Added EGA cursor patch
  25. ;  31 Jan 86: Disabled insert/delete char in graphics modes
  26. ;             Implemented keyboard redefinition reset
  27. ;  1 Feb 86: added video_mode and max_x test after mode set
  28. ;----------------------------------------------------------------
  29.  
  30.         include nansi_d.asm
  31.  
  32.         ; To nansi_p.asm
  33.         public  ansi_fn_table
  34.  
  35.         ; From nansi.asm
  36.         extrn   port_6845:word
  37.         extrn   cur_coords:word, saved_coords:word
  38.         extrn   cur_x:byte, max_x:byte
  39.         extrn   cur_y:byte, max_y:byte
  40.         extrn   cur_attrib:byte, wrap_flag:byte
  41.         extrn   xy_to_regs:near
  42.         extrn   get_blank_attrib:near
  43.         extrn   xlate_tab_ptr:word
  44.         extrn   cpr_esc:byte, cprseq:word
  45.         extrn   video_mode:byte
  46.         extrn   lookup:near
  47.         extrn   in_g_mode:near
  48.  
  49.         ; from nansi_p.asm
  50.         extrn   param_buffer:word       ; used in keyboard programming
  51.         extrn   param_end:word
  52.         extrn   redef_end:word
  53.  
  54. keybuf  struc                           ; used in making cpr sequence
  55. len     dw      ?
  56. adr     dw      ?
  57. keybuf  ends
  58.  
  59.  
  60. ABS40   segment at 40h
  61.         org     1ah
  62. buffer_head     dw      ?       ; Used in 'flush input buffer' dos call.
  63. buffer_tail     dw      ?
  64.  
  65.         org     49h
  66. crt_mode        db      ?
  67. crt_cols        dw      ?
  68. crt_len         dw      ?
  69. crt_start       dw      ?
  70. cursor_posn     dw      8 dup (?)
  71. cursor_mode     dw      ?
  72. active_page     db      ?
  73. addr_6845       dw      ?
  74. crt_mode_set    db      ?
  75. crt_palette     db      ?
  76.  
  77.         org 84h
  78. crt_max_y       db ?            ; CJD 11/19/89 - EGA/VGA only
  79.  
  80. ABS40   ends
  81.  
  82. code    segment byte public 'CODE'
  83.         assume cs:code, ds:code
  84.  
  85. ;----- byteout ---------------------------------------------------
  86. ; Converts al to a decimal ASCII string (in 0..99),
  87. ; stores it at ES:DI++.  Returns DI pointing at byte after last digit.
  88. ; Destroys DL.
  89.  
  90. byteout proc    near
  91.         aam
  92.         add     ax, 3030h
  93.         xchg    ah, al
  94.         stosb
  95.         xchg    ah, al
  96.         stosb
  97.         ret
  98. byteout endp
  99.  
  100. ;----- ansi_fn_table -----------------------------------
  101. ; Table of offsets of terminal control subroutines in order of
  102. ; the character that invokes them, @..Z, a..z.  Exactly 53 entries.
  103. ; All the subroutines are defined below in this module.
  104. ansi_fn_table   label   word
  105.         dw      ic,  cup, cdn, cfw, cbk         ; @, A, B, C, D
  106.         dw      nul, nul, nul, hvp, nul         ; E, F, G, H, I
  107.         dw      eid, eil, il,  d_l, nul         ; J, K, L, M, N
  108.         dw      nul, dc,  nul, nul, nul         ; O, P, Q, R, S
  109.         dw      nul, nul, nul, nul, nul         ; T, U, V, W, X
  110.         dw      nul, nul                        ; Y, Z
  111.         dw      nul, nul, nul, nul, nul         ; a, b, c, d, e
  112.         dw      hvp, nul, sm,  nul, nul         ; f, g, h, i, j
  113.         dw      nul, rm,  sgr, dsr, nul         ; k, l, m, n, o
  114.         dw      key, nul, nul, scp, nul         ; p, q, r, s, t
  115.         dw      rcp, nul, nul, nul, xoc         ; u, v, w, x, y
  116.         dw      nul                             ; z
  117.  
  118. ansi_functions  proc    near            ; set return type to NEAR
  119.  
  120. ;----- nul ---------------------------------------------
  121. ; No-action ansi sequence; called when unknown command given.
  122. nul:    ret
  123.  
  124. ;----- Cursor Motion -----------------------------------------------
  125.  
  126. ;-- cursor to y,x
  127. hvp:    or      al, al          ; First parameter is desired Y coordinate.
  128.         jz      hvp_yok
  129.         dec     ax              ; Convert to zero-based coordinates.
  130. hvp_yok:mov     cur_y, al
  131.         ; Get second parameter, if it is there, and set X with it.
  132.         xor     ax, ax
  133.         cmp     cx, 2           ; was there a second parameter?
  134.         jb      hvp_xok
  135.         lodsb                   ; yes.
  136.         or      al, al
  137.         jz      hvp_xok
  138.         dec     ax              ; convert to zero-based coordinates.
  139. hvp_xok:mov     cur_x, al
  140.  
  141.         ; Clip to maximum coordinates.
  142. hvp_set:
  143.         mov     ax, cur_coords          ; al = x, ah = y
  144.         cmp     al, max_x
  145.         jbe     hvp_sxok
  146.                 mov     al, max_x
  147.                 mov     cur_x, al
  148. hvp_sxok:
  149.         cmp     ah, max_y
  150.         jbe     hvp_syok
  151.                 mov     al, max_y
  152.                 mov     cur_y, al
  153. hvp_syok:
  154.         ; Set values of DX and DI accordingly.
  155.         call    xy_to_regs
  156.         ret
  157.  
  158. ;-- cursor forward --
  159. cfw:    add     cur_x, al
  160.         jmp     hvp_set
  161.  
  162. ;-- cursor back -----
  163. cbk:    sub     cur_x, al
  164.         jae     cbk_ok
  165.                 mov     cur_x, 0
  166. cbk_ok: jmp     hvp_set
  167.  
  168. ;-- cursor down -----
  169. cdn:    add     cur_y, al
  170.         jmp     hvp_set
  171.  
  172. ;-- cursor up -------
  173. cup:    sub     cur_y, al
  174.         jae     cup_ok
  175.                 mov     cur_y, 0
  176. cup_ok: jmp     hvp_set
  177.  
  178. ;-- save cursor position --------------------------------------
  179. scp:    mov     ax, cur_coords
  180.         mov     saved_coords, ax
  181.         ret
  182.  
  183. ;-- restore cursor position -----------------------------------
  184. rcp:    mov     ax, saved_coords
  185.         mov     cur_coords, ax
  186.         jmp     hvp_set         ; Clip in case we have switched video modes.
  187.  
  188. ;-- set graphics rendition ------------------------------------
  189. ; Modifies the color in which new characters are written.
  190.  
  191. sgr:    dec     si              ; get back pointer to first parameter
  192.         or      cx, cx          ; Did he give any parameters?
  193.         jnz     sgr_loop
  194.                 mov     byte ptr [si], 0        ; no parameters, so fake
  195.                 inc     cx                      ; one with the default value.
  196.         ; For each parameter
  197. sgr_loop:
  198.                 lodsb                           ; al = next parameter
  199.                 ; Search color table
  200.                 push    cx
  201.                 mov     cx, colors
  202.                 mov     bx, offset color_table-3
  203. sgr_search:
  204.                         add     bx, 3
  205.                         cmp     al, byte ptr [bx]
  206.                         loopnz  sgr_search      ; until match found or done
  207.                 jnz     sgr_loopx
  208.  
  209.                 ; If parameter named a known color, set the current
  210.                 ; color variable.
  211.                 mov     ax, [bx+1]
  212.                 and     cur_attrib, al
  213.                 or      cur_attrib, ah
  214. sgr_loopx:
  215.                 pop     cx
  216.                 loop    sgr_loop                ; until no more parameters.
  217.         ret
  218.  
  219. ;-- erase in line ----------------------------------------
  220. ; Uses BIOS to scroll away a one-line rectangle
  221. eil:    push    dx
  222.         mov     cx, cur_coords
  223.         mov     dh, ch
  224.         jmp     short scrollem
  225.  
  226. ;-- erase in display -------------------------------------
  227. ; Uses BIOS to scroll away all of display
  228. eid:    cmp     al, 2
  229.         jnz     eid_ignore      ; param must be two
  230.         if      cls_homes_too
  231.                 mov     cur_coords, 0
  232.                 call    xy_to_regs
  233.         endif
  234.         push    dx
  235.         xor     cx, cx
  236.         mov     dh, max_y
  237. scrollem:
  238.         call    get_blank_attrib
  239.         mov     bh, ah
  240.         mov     dl, max_x
  241.         mov     ax, 600h
  242.         int     10h
  243.         pop     dx
  244. eid_ignore:
  245.         ret
  246.  
  247. ;-- device status report --------------------------------
  248. ; Stuffs an escape, a left bracket, current Y, semicolon, current X,
  249. ; a capital R, and a carriage return into input stream.
  250. ; The coordinates are 1 to 3 decimal digits each.
  251.  
  252. dsr:    push    di
  253.         push    dx
  254.         push    es
  255.         mov     ax, cs
  256.         mov     es, ax
  257.         std                     ; Store string in reversed order for fun
  258.         mov     di, offset cpr_esc - 2
  259.         mov     al, cur_y
  260.         inc     al              ; convert to one-based coords
  261.         call    byteout         ; row
  262.         mov     al, ';'         ; ;
  263.         stosb
  264.         mov     al, cur_x
  265.         inc     al              ; convert to one-based coords
  266.         call    byteout         ; column
  267.         mov     al, 'R'         ; R ANSI function 'Cursor Position Report'
  268.         stosb
  269.         mov     al, 13
  270.         mov     word ptr cprseq.adr, di ; save pointer to last char in string
  271.         stosb                           ; send a carriage return, too
  272.         mov     ax, offset cpr_esc
  273.         sub     ax, di                  ; ax is # of characters in string
  274.         mov     word ptr cprseq.len, ax ; pass info to the getchar routine
  275.         cld
  276.         pop     es
  277.         pop     dx
  278.         pop     di
  279.         ret
  280.  
  281. ;-- keyboard reassignment -------------------------------
  282. ; Key reassignment buffer is between param_end and redef_end+2, exclusive.
  283. ; When it shrinks or grows, param_end is moved.
  284. ; Format of an entry is as follows:
  285. ;   highest address -> length:word (may be 0)
  286. ;                      key to replace:word     (either hi or low byte is zero)
  287. ;                          .
  288. ;                          .    new key value, "length" bytes long
  289. ;                          .
  290. ;   lowest address  -> next entry, or free space.
  291. ; If no arguments are given, keyboard is reset to default condition.
  292. ; Otherwise, first parameter (or first two, if first is zero) defines
  293. ; the key whose value is to be changed, and the following parameters
  294. ; define the key's new, possibly zero-length, value.
  295.  
  296. key:
  297.         ; Is this a reset?
  298.         or      cx, cx
  299.         jz      key_init
  300.         ; Get the first (or first two) parameters
  301.         cld
  302.         dec     si      ; point to first param
  303.         dec     cx      ; Assume it's a fn key, get two params
  304.         dec     cx
  305.         lodsw
  306.         or      al, al  ; Is it a function key?
  307.         jz      key_fnkey
  308.                 ; It's not a function key- put second param back
  309.                 inc     cx
  310.                 dec     si
  311. key_fnkey:
  312.         ; Key to redefine now in AX.  If it's already redefined,
  313.         ; lookup will set Z, point SI to redef string, set CX to its length.
  314.         push    di
  315.         push    es
  316.         push    cx
  317.         push    si
  318.  
  319.         std                     ; moving up, must move from top down
  320.         push    ds
  321.         pop     es              ; string move must have ES=DS
  322.         call    lookup          ; rets Z if redefined...
  323.         jnz     key_newkey
  324.         ; It's already defined.  Erase its old definition- i.e., move
  325.         ; region param_end+1..SI-1 upwards CX+4 bytes, add CX+4 to param_end.
  326.         add     cx, 4
  327.         mov     bp, param_end   ; save old value in bp...
  328.         add     param_end, cx
  329.         dec     si              ; start at (SI-1)
  330.         mov     di, si
  331.         add     di, cx          ; move to (start + CX+4)
  332.         mov     cx, si
  333.         sub     cx, bp          ; length of region old_param_end+1..start
  334.         rep     movsb
  335. key_newkey:
  336.         ; Key not redefined.  See if there's enough room to redefine it.
  337.         pop     si              ; get back pointer to redef string
  338.         pop     cx              ; get back number of bytes in redef string
  339.         mov     di, param_end   ; hi byte of new redef record, hi byte of len
  340.         sub     di, 4           ; hi byte of new data field
  341.         mov     bx, di
  342.         sub     bx, cx          ; hi byte of remaining buffer space
  343.         sub     bx, 16          ; better be at least 16 bytes room
  344.         cmp     bx, param_buffer
  345.         jb      key_popem       ; nope- forget it.
  346.         ; Nothing in the way now!
  347.         mov     [di+3], cx      ; save length field
  348.         mov     [di+1], ax      ; save name field
  349.         jcxz    key_nullstring
  350. key_saveloop:                   ; save data field
  351.         movsb
  352.         add     si, 2           ; input string ascending, output descending
  353.         loop    key_saveloop
  354. key_nullstring:
  355.         mov     param_end, di   ; save adr of new hi byte of free area
  356. key_popem:
  357.         pop     es
  358.         pop     di
  359.  
  360. key_exit:
  361.         cld
  362.         ret
  363.  
  364. key_init:
  365.         ; Build the default redefinition table:
  366.         ;       control-printscreen -> control-P
  367.         push    es
  368.         push    ds
  369.         pop     es
  370.         std
  371.         mov     di, redef_end
  372.         mov     ax, 1
  373.         stosw
  374.         mov     ax, 7200h       ; control-printscreen
  375.         stosw
  376.         mov     al, 16          ; control P
  377.         stosb
  378.         mov     param_end, di   ; save new bottom of redef table
  379.         pop     es
  380.         jmp     key_exit
  381.  
  382. ;---- Delete/Insert Lines -------------------------------
  383. ; AL is number of lines to delete/insert.
  384. ; Preserves DX, DI; does not move cursor.
  385.  
  386. d_l:    ; Delete lines.
  387.         mov     ah, 6                   ; BIOS: scroll up
  388.         jmp     short il_open
  389.  
  390. il:     ; Insert lines.
  391.         mov     ah, 7                   ; BIOS: scroll down
  392.  
  393. il_open:
  394.         ; Whether inserting or deleting, limit him to (max_y - cur_y) lines;
  395.         ; if above that, we're just clearing; set AL=0 so BIOS doesn't burp.
  396.         mov     bh, max_y
  397.         sub     bh, cur_y
  398.         cmp     al, bh
  399.         jbe     il_ok                   ; DRK 9/4...
  400.                 mov     al, 0           ; he tried to move too far
  401. il_ok:
  402.         push    ax
  403.         call    get_blank_attrib
  404.         mov     bh, ah                  ; color to use on new blank areas
  405.         pop     ax                      ; AL is number of lines to scroll.
  406.  
  407.         mov     cl, 0                   ; upper-left-x of data to scroll
  408.         mov     ch, cur_y               ; upper-left-y of data to scroll
  409.         push    dx
  410.         mov     dl, max_x               ; lower-rite-x
  411.         mov     dh, max_y               ; lower-rite-y (zero based)
  412.         int     10h                     ; call BIOS to scroll a rectangle.
  413.         pop     dx
  414.         ret                             ; done.
  415.  
  416. ;-- Insert / Delete Characters ----------------------------
  417. ; AL is number of characters to insert or delete.
  418. ; Preserves DX, DI; does not move cursor.
  419.  
  420. ic:     mov     ch, 1                   ; 1 => swap dest & source below
  421.         jmp     short dc_ch
  422.  
  423. dc:     mov     ch, 0
  424.  
  425. dc_ch:
  426.         call    in_g_mode
  427.         jnc     dc_ret                  ; | if in graphics mode, ignore.
  428.  
  429.         ; AL = number of chars to ins or del (guarenteed nonzero).
  430.         ; Limit him to # of chars left on line.
  431.         cmp     al, dl
  432.         jbe     dc_cok
  433.                 mov     al, dl
  434. dc_cok:
  435.         push    di                      ; DI is current address of cursor
  436.         xchg    ax, cx                  ; CX gets # of chars to ins/del
  437.         mov     bp, cx                  ; BP gets # of columns to clear.
  438.  
  439.         ; Set up source = destination + cx*2, count = dx - cx
  440.         mov     ch, 0                   ; make it a word
  441.         mov     si, di
  442.         add     si, cx
  443.         add     si, cx
  444.         neg     cl
  445.         add     cl, dl
  446.         mov     ch, 0                   ; CX = # of words to transfer
  447.         cld                             ; REP increments si & di
  448.  
  449.         ; If this is an insert, then flip transfer around in both ways.
  450.         test    ah, 1
  451.         jz      dc_noswap
  452.                 xchg    di, si          ; source <-> dest
  453.                 std                     ; up <-> down
  454.                 mov     ax, cx          ; make move over same range
  455.                 dec     ax
  456.                 add     ax, ax          ; AX=dist from 1st to last byte.
  457.                 add     di, ax          ; Start transfer at high end of block
  458.                 add     si, ax          ;  instead of low end.
  459. dc_noswap:
  460.         ; Move those characters.
  461.         push    es
  462.         pop     ds
  463.         rep     movsw
  464.         mov     cx, bp
  465.         ; Figure out what color to make the new blanks.
  466.         call    get_blank_attrib
  467.         mov     al, ' '
  468.         ; Blank out vacated region.
  469.         rep     stosw
  470.  
  471.         ; All done.
  472.         cld                             ; restore normal REP state and
  473.         pop     di                      ;  cursor address.
  474. dc_ret: ret
  475.  
  476.  
  477. ;---- set / reset mode ---------------------------------------
  478. ; Sets graphics/text mode; also sets/resets "no wrap at eol" mode.
  479. sm:     mov ch,cl           ; CH = # params                         CJD 08/31/88
  480.         mov cl, 0ffh        ; set                                   CJD 08/31/88
  481. sm_rs:
  482.         ; Is it "wrap at eol" ?
  483.         cmp     al, 7
  484.         jnz     sm_notwrap
  485.                 mov     wrap_flag, cl   ; true = wrap at EOL
  486.                 jmp     short sm_done
  487. sm_notwrap:
  488. ; ====================================================================================
  489. ; EGA SUPPORT NOT NEEDED IN VGA VERSION
  490. ;       ; Is it "set highest number of screen lines available"?
  491. ;       cmp     al, 43
  492. ;       jnz     sm_video
  493. ;               ; Only valid for the Enhanced Graphics Adaptor on
  494. ;               ; a monochrome display or an enhanced color display.
  495. ;               ; Test presence of EGA by calling BIOS fn 12h.10h.
  496. ;               mov     ah, 12h
  497. ;               mov     bx, 0ff10h
  498. ;               int     10h                     ; bh=0-1, bl=0-3 if EGA
  499. ;               test    bx, 0FEFCH
  500. ;               jnz     sm_done                 ; sorry, charlie
  501. ;               mov     port_6845, 3d4h
  502. ;               mov     al, video_mode
  503. ;               and     al, 7
  504. ;               cmp     al, 7                   ; monochrome monitor?
  505. ;               jnz     sm_colormon
  506. ;                       mov     byte ptr port_6845, low(3b4h)
  507. ;sm_colormon:
  508. ;               ; 43 line mode only allowed in text modes, for now.
  509. ;               call    in_g_mode
  510. ;               jnc     sm_done
  511. ;
  512. ;               mov     ah, 0                   ; "Set video mode"
  513. ;               mov     al, video_mode          ; Re-init current mode
  514. ;               int     10h
  515. ;
  516. ;               mov     ax,1112h                ; Load 8x8 font
  517. ;               mov     bl,0                    ; (instead of 8x14)
  518. ;               int     10h
  519. ;
  520. ;               mov     ax, 1200h               ; Load new printscreen
  521. ;               mov     bl, 20h
  522. ;               int     10h
  523. ;
  524. ;               mov     ah,1
  525. ;               mov     cx,0707h                ; (Load cursor scan lines)
  526. ;               int     10h
  527. ;               ; | Patch; this gotten by painful observation of
  528. ;               ; | IBM's professional editor.  I think there's a
  529. ;               ; | documented bug in Video Bios's "load cursor scan line"
  530. ;               ; | call; try looking in latter 1985 PC Tech Journal.
  531. ;               mov     dx, port_6845           ; '6845' command reg
  532. ;               mov     al, 10
  533. ;               out     dx, al
  534. ;               jmp     $+2
  535. ;               inc     dx
  536. ;               mov     al, 7
  537. ;               out     dx, al                  ; set cursor start line
  538. ;               ; Assume that gets us 43 lines.
  539. ;               mov     max_y, 42
  540. ;               jmp     short sm_home
  541. ;===================================================================================
  542.  
  543. sm_video:
  544.         ; It must be a video mode.  Call BIOS.
  545.         mov     ah, 0           ; "set video mode"
  546.         int     10h
  547.         ; Assume that gets us 25 lines.
  548. ;       mov     max_y, 24               ; CJD comment out 11/19/89
  549. sm_home:
  550.         ; Read the BIOS buffer address/cursor position variables.
  551.         push    bx                      ; CJD 11/19/89-not sure if he's using
  552.                                         ; BX here, so save it to be safe
  553.         mov     ax, abs40
  554.         push    ds
  555.         mov     ds, ax
  556.         assume  ds:abs40
  557.         ; Find current video mode and screen size.
  558.         mov     ax,word ptr crt_mode    ; al = crt mode; ah = # of columns
  559.         mov     bl,crt_max_y            ; CJD 11/19/89 - get max row #
  560.         pop     ds
  561.         assume ds:code
  562.         mov     max_y,bl                ; CJD 11/19/89 - set max row #
  563.         mov     video_mode, al
  564.         dec     ah                      ; ah = max column
  565.         mov     max_x, ah
  566.         pop bx                          ; CJD 11/19/89
  567.  
  568.         ; Since cursor may end up in illegal position, it's best to
  569.         ; just go home after switching video modes.
  570. sm_reset_curpos:
  571.         mov     cur_coords, 0
  572.         call    xy_to_regs
  573. sm_done:
  574.         ret
  575.  
  576. rm:     mov     cl, 0           ; reset
  577.         jmp     sm_rs
  578.  
  579. ;------- Output Character Translation ----------------------
  580. ; A decidedly nonstandard function, possibly useful for editing files
  581. ; intended to be printed by daisywheel printers with strange wheels.
  582. ; (The letter 'y' was chosen to conflict with the VT100 self-test command.)
  583. ; Usage: ESC [ #1;#2 y
  584. ; where #1 is the character to redefine
  585. ;       #2 is the new display value
  586. ; If only ESC [ #1 y is sent, character #1 is reset to its default value.
  587. ; If only ESC [ y is sent, the entire table is reset to the default value.
  588. ; (If only ESC [ #1; y is sent, character #1 is set to zero... sigh.)
  589.  
  590. xoc:    ; Xlate output character
  591.         mov     bx, xlate_tab_ptr
  592.         jcxz    xoc_reset       ; if no parameters, reset table to 1:1
  593.         dec     si              ; point to first parameter
  594.         lodsw                   ; first parameter to AL, second to AH
  595.         dec     cx              ; is parameter count 1?
  596.         jnz     xoc_bothparams
  597.                 mov     ah, al  ; if only one param, reset that char.
  598. xoc_bothparams:
  599.         add     bl, al
  600.         adc     bh, 0           ; bx points to entry for char AL
  601.         mov     byte ptr [bx], ah       ; change that entry
  602. xoc_done:
  603.         ret
  604.  
  605. xoc_reset:
  606.         ; Fill table with default values- i.e. 0, 1, 2, ... 255.
  607.         xor     ax, ax
  608. xoc_loop:
  609.         mov     byte ptr [bx], al
  610.         inc     bx
  611.         inc     al
  612.         jnz     xoc_loop
  613.         jmp     xoc_done
  614.  
  615.  
  616. ansi_functions  endp    ; end dummy procedure block
  617.  
  618.  
  619. ;-------- Color table -----------------------------------------
  620. ; Used in "set graphics rendition"
  621. colors  equ     22                      ; number of colors in table
  622. color_table:
  623.         db      0, 000h,07h             ; all attribs off; normal.
  624.         db      1, 0ffh,08h             ; bold
  625.         db      4, 0f8h,01h             ; underline
  626.         db      5, 0ffh,80h             ; blink
  627.         db      7, 0f8h,70h             ; reverse
  628.         db      8, 088h,00h             ; invisible
  629.  
  630.         db      30,0f8h,00h             ; black foreground
  631.         db      31,0f8h,04h             ; red
  632.         db      32,0f8h,02h             ; green
  633.         db      33,0f8h,06h             ; yellow
  634.         db      34,0f8h,01h             ; blue
  635.         db      35,0f8h,05h             ; magenta
  636.         db      36,0f8h,03h             ; cyan
  637.         db      37,0f8h,07h             ; white
  638.  
  639.         db      40,08fh,00h             ; black background
  640.         db      41,08fh,40h             ; red
  641.         db      42,08fh,20h             ; green
  642.         db      43,08fh,60h             ; yellow
  643.         db      44,08fh,10h             ; blue
  644.         db      45,08fh,50h             ; magenta
  645.         db      46,08fh,30h             ; cyan
  646.         db      47,08fh,70h             ; white
  647.  
  648.  
  649. code    ends
  650.         end                             ; of nansi_f.asm
  651.  
  652.