home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 23 / IOPROG_23.ISO / SOFT / NFSRC305.ZIP / ASM / DISPA.ASM < prev    next >
Encoding:
Assembly Source File  |  1995-05-01  |  5.5 KB  |  165 lines

  1. ; File......: DISPA.ASM
  2. ; Author....: Mike Taylor
  3. ; CIS ID....: ?
  4.  
  5. ; This is an original work by Mike Taylor and is placed in the
  6. ; public domain.
  7. ;
  8. ; Modification history:
  9. ; ---------------------
  10. ;
  11. ;     Rev 1.4   01 Jan 1995 03:01:00   TED
  12. ;  Modified video detection to use CRT controller base address rather
  13. ;  than current video mode.  Also converted to IDEAL mode because
  14. ;  simplified segment directives were generating incorrect segment
  15. ;  fixups which generated GPFs in protected mode.
  16. ;
  17. ;     Rev 1.3   14 Feb 1994 16:47:46   GLENN
  18. ;  Malc Shedden fixed for protected mode; Steve Tyrakowski modified
  19. ;  for CPMI compatibility.
  20. ;
  21. ;     Rev 1.2   15 Aug 1991 23:06:48   GLENN
  22. ;  Forest Belt proofread/edited/cleaned up doc
  23. ;
  24. ;     Rev 1.1   14 Jun 1991 19:54:28   GLENN
  25. ;  Minor edit to file header
  26. ;
  27. ;     Rev 1.0   01 Apr 1991 01:03:14   GLENN
  28. ;  Nanforum Toolkit
  29. ;
  30. ;
  31.  
  32. IDEAL
  33. P286
  34.  
  35. Public    __ft_vconfig
  36. Public    __ft_gotoxy
  37. Public    __ft_fileread
  38. Public    __ft_fileseek
  39. Public    __ft_getkey
  40.  
  41. Extrn     cpmiProtectedPtr:Far
  42. Extrn     cpmiIsProtected:Far
  43.  
  44. Group     DGROUP    _DATA
  45.  
  46. Segment   _DATA     Word      Public    "DATA"
  47.  
  48. VidSel    DW        0
  49.  
  50. Ends      _DATA
  51.  
  52.  
  53.  
  54. Segment   _Nanfor   Word      Public    "CODE"
  55.           Assume    CS:_Nanfor,DS:DGROUP
  56.  
  57. Proc      __ft_vconfig        Far
  58.  
  59.           Mov       AX,[VidSel]                   ; Get video selector
  60.           Or        AX,AX                         ; Is there one already?
  61.           JNZ       V2                            ; Yes, don't create another
  62.  
  63.           Mov       AX,40h                        ; Low memory selector
  64.           Mov       ES,AX                         ; Load selector into ES
  65.           Mov       AX,0B800h                     ; Default to color
  66.           Cmp       [Word Ptr ES:63h],3B4h        ; Check for mono
  67.           JNE       V1                            ; No, continue
  68.           Mov       AX,0B000h                     ; Yes, switch to mono
  69.  
  70. V1:       Mov       [VidSel],AX                   ; Save the segment
  71.           Call      cpmiIsProtected               ; Check for protected mode
  72.           Or        AX,AX                         ; 0=real, else protected
  73.           Mov       AX,[VidSel]                   ; Load return value
  74.           JZ        V2                            ; If real, done
  75.  
  76.           Push      AX                            ; Pass segment
  77.           Push      0                             ; Pass offset
  78.           Push      8000h                         ; Length of video buffer
  79.           Call      cpmiProtectedPtr              ; Generate selector
  80.           Mov       [VidSel],AX                   ; Save the selector
  81.  
  82. V2:       RetF                                    ; Return segment in AX
  83. Endp      __ft_vconfig
  84.  
  85.  
  86.  
  87. Proc      __ft_gotoxy         Far
  88.  
  89.           Push      BP              ; save the caller's BP register
  90.           Mov       BP,SP           ; establish our base pointer into the stack
  91.  
  92.           Xor       AX,AX           ; clear AX register
  93.           Xor       BX,BX           ; bx = 0 means video page 0
  94.           Mov       DH,[BP + 8]     ; get y coordinate
  95.           Mov       DL,[BP + 6]     ; get x coordinate
  96.           Mov       AH,2            ; bios function 02h, set cursor position
  97.           Int       10h
  98.  
  99.           Xor       AX,AX           ; clear AX register
  100.  
  101.           Pop       BP
  102.           RetF
  103. Endp      __ft_gotoxy
  104.  
  105.  
  106.  
  107. Proc      __ft_fileread       Far
  108.  
  109.           Push      BP              ; save the caller's BP register
  110.           Mov       BP,SP           ; establish our base poInter Into the stack
  111.  
  112.           Push      DS
  113.           Mov       BX,[BP + 6]     ; file handle
  114.           Mov       DX,[BP + 8]     ; offset of buffer
  115.           Mov       AX,[BP + 10]    ; segment of buffer
  116.           Mov       DS,AX           ; make buffer segment Into default data segment
  117.           Mov       Cx,[BP + 12]    ; byte count to read in
  118.           Mov       AX,3F00h        ; dos function 3fh, file block read
  119.           Int       21h
  120.           Pop       DS
  121.           JNC       fr1             ; if carry flag set then error occured
  122.           Xor       AX,AX           ;   and notify by returning 0 bytes
  123.                                     ; otherwise AX will contain the actual
  124.                                     ; bytes read in.
  125.  
  126. fr1:      Pop       BP
  127.           RetF
  128. Endp      __ft_fileread
  129.  
  130.  
  131.  
  132. Proc      __ft_fileseek       Far
  133.  
  134.         Push        BP              ; save the caller's BP register
  135.         Mov         BP,SP           ; establish our base poInter Into the stack
  136.  
  137.         Mov         BX,[BP + 6]     ; file handle
  138.         Mov         CX,[BP + 10]    ; msb of long offset parameter
  139.         Mov         DX,[BP + 8]     ; lsb of long offset parameter
  140.         Mov         AL,[BP + 12]    ; seek direction code
  141.         Mov         AH,42h          ; dos function 42h, set file poInter
  142.         Int         21h
  143.  
  144.         JNC         fs1             ; if carry flag not set, no error
  145.         Xor         AX,AX           ; if error, clear poInter msb and lsb
  146.         Xor         DX,DX
  147.  
  148. fs1:    Pop         BP
  149.         RetF
  150. Endp      __ft_fileseek
  151.  
  152.  
  153.  
  154. Proc      __ft_getkey         Far
  155.  
  156.           Xor       AX,AX           ; clear AX register
  157.           Mov       AH,07h          ; dos function 07h, get key pressed
  158.           Int       21h
  159.  
  160.           Mov       AH,0            ; zero out msb of AX to make sure returned
  161.           RetF                      ; value is only a byte value
  162.  
  163. Endp      __ft_getkey
  164. Ends      _NanFor
  165. End