TV2 patch - monochrome monitor

Last changed 1995.02.01


Version
TV2
Author
William Werth <billw@eskimo.com>
Terms
TCluster

The following is from the TV2BUG.ZIP where the author left off the top line by accident.

There is a problem with TCluster objects (radio buttons and checkboxes) on systems with monochrome monitors. As soon as the focus shifts to one of these objects, a "Divide By 0" error occurs and aborts the application.

The problem was traced to the resetCursor() function in the file TVCURSOR.ASM. It was modified in TV 2.0 with the removal of code dealing with the cursor on monochrome systems. It is possible that it is the value in CX that eventually gets passed to INT 10h that generates the "Divide By 0" error.

On monochrome systems, the cursorLines value is usually something like 0x5658 where as on EGA/VGA systems it is usually something like 0x0607. After going through the calculations, the 0x5658 is probably something totally unusable and causes the "Divide by 0" error somewhere in the interrupt code.

By adding the monochrome system handling code from TV1.03 back, the problem can be eliminated.

Here is the fix:

1) Lines 21-24 are:
 
IFDEF __FLAT__
        EXTRN   @THardwareInfo@setCaretSize$qus : NEAR
        EXTRN   @THardwareInfo@setCaretPosition$qusus : NEAR
ENDIF
 
Change them to:
 
IFDEF __FLAT__
        EXTRN   @THardwareInfo@setCaretSize$qus : NEAR
        EXTRN   @THardwareInfo@setCaretPosition$qusus : NEAR
ELSE
        EXTRN   @TDisplay@getCrtMode$qv : FAR       ; For monochrome check.
ENDIF
 
2) Add the label '@@7:' to line 115 and the label '@@8:' to line 147:
 
(Line 115)
; Calculate CH/CL cursor from NT percentage cursor.
@@7:      MOV     AX, WORD PTR [@TScreen@cursorLines]
 
(Line 147)
@@8:      LES     DI, [thisPtr]
          TEST    WORD PTR ES:[DI+TViewState], sfCursorIns
 
3) Then, just before line 115, I added the following code:
 
; Added to fix divide by 0 bug for monochrome mode
        Call    @TDisplay@getCrtMode$qv
        CMP     AX, 7   ; mono?
        JNE     @@7
        MOV     CX,[WORD PTR @TScreen@cursorLines]
        JMP     @@8

You will need to add these changes to the source code and run make.