home *** CD-ROM | disk | FTP | other *** search
- ; Copyright 1988 John P. Nelson (all rights reserved)
- ; The binary of this program may be used for any purpose whatever,
- ; the source may be distributed freely, but must retain this copyright
- ; notice. The techniques used in this program may be copied and used
- ; freely without retaining the copyright notice.
- ;
- ; Change history:
- ; fixfansi.asm 20-Feb-88 13:50 John added copyright notice before distribution
- ; 04-Feb-88 16:29 John Author
- ;
- ; fixfansi is a terminate-and-stay-resident program that fixes an
- ; incompatibility between turbo pascal 4.0 and FANSI-CONSOLE versions
- ; 1.11 and 1.15. Version 2.00 of FANSI-CONSOLE does not exhibit this
- ; problem, but has different problems with the CRT unit (and
- ; "directvideo"). It is unknown whether versions of FANSI-CONSOLE before
- ; 1.11P require this fix. As I do not have an EGA, I have not tested
- ; this program for EGA operation. It works fine with mono (hercules)
- ; and CGA displays.
- ;
- ; This program intercepts the video interrupt (int 10h), and
- ; handles function 0 (change video mode) by calling the original
- ; int 10 vector, then fixing BIOS ram location 40:4c. For some
- ; unknown reason, FANSI always stores the value 00A0H at this location,
- ; where TURBO (and the IBM rom bios listing) is expecting the length
- ; of the current video page. Note that fixfansi does NOT fix mode
- ; changes caused by sending escape sequences to the console since
- ; FANSI-CONSOLE bypasses INT 10H in this case. fixfansi stores the
- ; value 4000H (16K), if (and only if) it finds 00A0 at this location
- ; after the mode change, so fixfansi is safe to use even if
- ; FANSI-CONSOLE is not resident. The value 4000H is used because
- ; this is the largest possible page size, (hires graphics mode), and
- ; because TURBO seems to calculate the correct end-of-screen anyway.
- ; FANSI does not seem to use this location at all.
-
- _text segment para public 'CODE'
- assume cs:_text,ds:_text,ss:_text
- org 100h
-
- fixfansi proc far
- jmp begin
- fixfansi endp
-
- oldvec dw 0,0
- ;
- assume nothing
- assume cs:_text
- newvec proc far
- cmp ah,0
- jz fix
- jmp dword ptr oldvec
- fix:
- pushf ; popped by reti at oldvec!
- call dword ptr oldvec
- push es
- push ax
- mov ax,40h
- mov es,ax
- mov ax,es:[4ch]
- cmp ax,00a0h ; fansi always stores a0,00 for some reason
- jnz cleanup
- mov ax,4000h ; insert 00,40 (16K) instead
- mov es:[4ch],ax
- cleanup:
- pop ax
- pop es
- iret
-
- newvec endp
-
- assume cs:_text,ds:_text,ss:_text
- begin proc near
- ; save old vector
- mov ah,35h
- mov al,10h
- int 21h
- mov oldvec,bx
- mov oldvec[2],es
-
- ; store new replacement vector
- mov ah,25h
- mov al,10h
- lea dx,newvec
- int 21h
-
- ; free up environment block
- mov es,ds:[2ch]
- mov ah,49h
- int 21h
-
- ; make page length fix immediately without switching modes
- mov ax,40h
- mov es,ax
- mov ax,es:[4ch]
- cmp ax,00a0h ; fansi always leaves a0,00 for some reason
- jnz gores
- mov ax,4000h ; insert 00,40 (16K) instead
- mov es:[4ch],ax
-
- ; terminate & stay resident
- gores:
- mov ah,31h
- mov al,0
- lea dx,begin
- shr dx,1
- shr dx,1
- shr dx,1
- shr dx,1
- inc dx
- int 21h
- ; notreached
- begin endp
-
- _text ends
- end fixfansi
-