home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / library / ansi / nnansi / nnansi_i.asm < prev    next >
Assembly Source File  |  1990-08-28  |  3KB  |  130 lines

  1. ;------ nnansi_i.asm ----------------------------------------------
  2. ; Contains code only needed at initialization time.
  3. ; (C) 1986 Daniel Kegel
  4. ; May be distributed for educational and personal use only
  5. ; Modifications by Tom Almy, with no restrictions.
  6. ;-----------------------------------------------------------------
  7.  
  8.     include nnansi_d.asm        ; definitions
  9.  
  10.     ; to nnansi.asm
  11.     public    dosfn0
  12.  
  13.     ; from nnansi.asm
  14.     extrn    break_handler:near
  15.     extrn    int_29:near
  16.     extrn    new_vid_bios:near
  17.     extrn    old_vid_bios:dword
  18.     extrn    req_ptr:dword
  19.     extrn    param_buffer:word    ; adr of first byte free for params
  20.     extrn    param_end:word        ; adr of last byte used for params
  21. if key_redef
  22.     extrn    redef_end:word        ; adr of last used byte for redefs
  23. endif
  24.  
  25. code    segment byte public 'CODE'
  26.     assume    cs:code, ds:code
  27.  
  28. ;-------- dos function # 0 : init driver ---------------------
  29. ; Initializes device driver interrupts and buffers, then
  30. ; passes ending address of the device driver to DOS.
  31. ; Since this code is only used once, the buffer can be set up on top
  32. ; of it to save RAM.
  33.  
  34. dosfn0    proc    near
  35.     ; Install BIOS keyboard break handler.
  36.     xor    ax, ax
  37.     mov    ds, ax
  38.     mov    bx, 6Ch
  39.     mov    word ptr [BX],offset break_handler
  40.     mov    [BX+02], cs
  41.     ; Install INT 29 quick putchar.
  42.     mov    bx, 0a4h
  43.     mov    word ptr [bx], offset int_29
  44.     mov    [bx+2], cs
  45.     ; Install INT 10h video bios replacement, saving old vector.
  46.     mov    bx, 40h
  47.     mov    ax, [bx]
  48.     mov    word ptr cs:old_vid_bios, ax
  49.     mov    ax, [bx+2]
  50.     mov    word ptr cs:old_vid_bios[2], ax
  51.     mov    word ptr [bx], offset new_vid_bios
  52.     mov    word ptr [bx+2], cs
  53.  
  54.     push    cs
  55.     pop    ds
  56.     push    cs
  57.     pop    es            ; es=cs so we can use stosb
  58.     cld                ; make sure stosb increments di
  59.  
  60.     ; Calculate addresses of start and end of parameter/redef buffer.
  61.     ; The buffer occupies the same area of memory as this code!
  62.     ; ANSI parameters are accumulated at the lower end, and
  63.     ; keyboard redefinitions are stored at the upper end; the variable
  64.     ; param_end is the last byte used by params (changes as redefs added);
  65.     ; redef_end is the last word used by redefinitions.
  66.     mov    di, offset dosfn0
  67.     mov    param_buffer, di
  68.     add    di, buf_size
  69.     mov    param_end, di    ; addr of last byte in free area
  70.     inc    di
  71.  
  72.     ; Announce our presence
  73.     mov    si, offset welcome
  74. msg_loop:
  75.     lodsb    
  76.     cmp    al,0
  77.     je    msg_done
  78.     int    29h
  79.     jmp    msg_loop
  80.  
  81. msg_done:
  82.  
  83. IF key_redef
  84.     ; Build the default redefinition table:
  85.     ;    control-printscreen -> control-P
  86.     ; (Must be careful not to write over ourselves here!)
  87.     mov    al, 16        ; control P
  88.     stosb
  89.     mov    ax, 7200h    ; control-printscreen
  90.     stosw
  91.     mov    ax, 1        ; length field
  92.     mov    redef_end, di    ; address of last used word in table
  93.     stosw
  94. endif
  95.  
  96.     ; Return ending address of this device driver.
  97.     ; Status is in AX.
  98.     lds    si, req_ptr
  99.     mov    word ptr [si+0Eh], di
  100.     mov    [si+10h], cs
  101.  
  102.     xor    ax, ax
  103.     ; Return exit status in ax.
  104.     ret
  105.  
  106. welcome:
  107.     db    27,'[33;1m'
  108.     db    "NNANSI.SYS for EGA/VGA"
  109.     if    cheap_pc
  110.     db    " (XT class)"
  111.     else
  112.     db    " (AT class)"
  113.     endif
  114.     db    13, 10
  115.     db    'By Tom Almy, version 08/90'
  116.     db    13,10,10
  117.     db    'Based on NANSI.SYS V2.2'
  118.     db    13,10
  119.     db    '(C) Daniel Kegel, Pasadena, CA 1986.'
  120.     db    13,10
  121.     db    'License NANSI.SYS by sending $10.00(US) to Daniel Kegel,'
  122.     db    13,10
  123.     db    '221 Fairview Ave, South Pasadena, CA 91030, USA.'
  124.     db    13, 10, 27, '[0m', 0
  125.     
  126. dosfn0    endp
  127.  
  128. code    ends
  129.     end                ; of nnansi_i.asm
  130.