FWIW, here's the code I use to test whether or not ANSI.SYS is loaded.

  ;-------------------------------------------------------------------
  ;Strings need to test for ANSI.SYS
  ;-------------------------------------------------------------------
  TestMsg:
    DB  CR          ;String to test ANSI.SYS
    DB  Escape,"[s" ;  ANSI "Save Cursor Position"
    DB  Escape,"[u" ;  ANSI "Restore Cursor Position"
    DB  0           ;  End of string
  HideMsg:
    DB  CR          ;String to cover up
    DB  6 DUP (" ") ;  what we sent to the screen
    DB  CR          ;  if ANSI.SYS isn't loaded
    DB  0           ;  End of string


;---------------------------------------------------------------------
;TEST AND SEE IF ANSI.SYS (OR SOME EQUIVALENT CLONE) IS LOADED
;Inputs:
;Outputs: CF = Clear if ANSI.SYS is loaded
;            = Set if not
;Changes:
;NOTES: At least under Windows XP, the data in the BIOS memory is
;         incorrect when a DOS Box initially loads.  The data
;         regarding video pages and cursor information does not match
;         what's really there.
;       We originally just looked at the BIOS data area (for speed),
;         but had to change things to INT 10h calls for this to work
;         correctly under XP (and possibly all versions of NT).
;------------------------------------------------------------------------------
TestANSI:
  PUSH AX,BX,CX,DX ;Save used registers
  MOV  DX,TestMsg  ;Write the ANSI.SYS test string
  CALL WriteZERR   ;  to the screen
  MOV  AH,0Fh      ;Function 0Fh (Get Video Columns, Mode, & Page)
  INT  10h         ;Do it (returns AH = Columns, AL = Mode, BH = Page)
  MOV  AH,03h      ;Function 03h (Get Cursor Information)
  INT  10h         ;Do it (uses    BH = Page
                   ;       returns CH = Start Scan, CL = End Scan,
                   ;               DH = Row, DL = Column)
  OR   DL,DL       ;Did the cursor move?
  JZ  >A80         ;If not, ANSI is loaded
A70:               ;ANSI.SYS is not loaded
  MOV  DX,HideMsg  ;If so, write over the ANSI test string
  CALL WriteZERR   ;  with spaces
  STC              ;Set the no ANSI.SYS flag
  JMP >A90         ;And we're done
A80:               ;ANSI.SYS is loaded
  CLC              ;Set the ANSI.SYS flag
A90:               ;We're done
  POP  DX,CX,BX,AX ;Restore used registers
  RET

;---------------------------------------------------------------------
;WRITE ASCIIZ STRING TO CON OR TO ERR
;Inputs:  DS:[DX] = Pointer to string
;Outputs: Writes the string to CON or ERR
;Changes:
;---------------------------------------------------------------------
WriteZCon:           ;Write to CON
  PUSH BX            ;Save used register
  MOV  BX,1          ;Device #1 (CON)
  JMP >Z10           ;Jump to do it
WriteZErr:           ;Write to ERR
  PUSH BX            ;Save used register
  MOV  BX,2          ;Device #2 (ERR)
Z10:                 ;Write to CON or ERR
  PUSH AX,CX         ;Save used registers
  CALL CalcStrSizeDX ;Calculate the size of the string (returns CX)
  JZ  >Z80           ;If nothing to write, just quit
  MOV  AH,40h        ;Function 40h (Write to Device)
  INT  21h           ;Do it
Z80:                 ;We're done
  POP  CX,AX         ;Restore used registers
  POP  BX            ;Restore used register
Z90:                 ;We're done
  RET

;---------------------------------------------------------------------
;CALCULATE THE LENGTH OF AN ASCIIZ STRING
;Inputs:  DS:[DX] = Pointer to the string
;Outputs: CX = Length of the string
;         ZF = Set if string is 0 length
;            = Clear if not
;Changes:
;---------------------------------------------------------------------
CalcStrSizeDX:
  PUSH AX,DI  ;Save used registers
  PUSH ES     ;Save used registers
  MOV  ES,DS  ;Point ES:[DI]
  MOV  DI,DX  ; at the string
  XOR  AL,AL  ;Look for a 0
  MOV  CX,-1  ;Start with max count for REPNE
  REPNE SCASB ;Find the end of the string
  NOT  CX     ;Calculate the size
  DEC  CX     ;  of the string (sets ZF)
  POP  ES     ;Restore used registers
  POP  DI,AX  ;Restore used registers
  RET


_______________________________________________
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel

Reply via email to