home *** CD-ROM | disk | FTP | other *** search
- ;* ------------------------------------------------------- *
- ;* TXANSI.ASM *
- ;* DOS-Toolbox ANSI-Treiber *
- ;* ------------------------------------------------------- *
- ;* Erzeugen: MASM txansi ; *
- ;* LINK txansi *
- ;* oder *
- ;* TASM txansi *
- ;* TLINK txansi *
- ;* und *
- ;* EXE2BIN txansi.exe txansi.sys *
- ;* DEL txansi.exe *
- ;* ------------------------------------------------------- *
-
- CODE SEGMENT BYTE PUBLIC 'CODE'
- ASSUME CS:CODE,DS:CODE,ES:NOTHING,SS:NOTHING
-
- ; -------------------------------------
- ; Constants
-
- MaxCmd EQU 0Ch
- ScrSegMono EQU 0B000h
- ScrSegColor EQU 0B800h
- TRUE EQU 01h
- FALSE EQU 00h
-
- ; -------------------------------------
- ; Characters
-
- quote EQU 22h
- CR EQU 0Dh
- LF EQU 0Ah
- BEL EQU 07h
- BS EQU 08h
- ESC EQU 1Bh
-
- ; -------------------------------------
-
- ORG 00h
-
- ; ----------------------------------------------------------
- ; Header
-
- DD -1 ; Next Driver
-
- DW 0C013h ; Attribute
-
- DW Offset Strategy
- DW Offset Interrupt
-
- DB "CON " ; Driver Name
-
-
- ; ----------------------------------------------------------
- ; Dispatch_Table
-
- Dispatch DW Offset Init
- DW Offset Exit_01 ; MediaCheck
- DW Offset Exit_01 ; BuildBPB
- DW Offset Exit_Error ; IOCTL_Read
- DW Offset Read
- DW Offset NdRead
- DW Offset Exit_01 ; InpStat
- DW Offset InpFlush
- DW Offset Write
- DW Offset Write ; WriteVfy
- DW Offset Exit_01 ; OutStat
- DW Offset OutFlush
- DW Offset Exit_01 ; IOCTL_Write
-
- DevHdr DW ? ; Offset
- DW ? ; Segment
-
- ; ----------------------------------------------------------
-
- Strategy PROC FAR
-
- MOV Word Ptr CS:[DevHdr+00h],BX
- MOV Word Ptr CS:[DevHdr+02h],ES
- RETF
-
- Strategy ENDP
-
- ; ----------------------------------------------------------
-
- Interrupt PROC FAR
-
- PUSH SI ; save Registers
- PUSH AX
- PUSH CX
- PUSH DX
- PUSH DI
- PUSH DS
- PUSH ES
- PUSH BX
- LEA SI, Dispatch
- LDS BX, DWord Ptr CS:[DevHdr]
- MOV CX,[BX+12h]
- MOV AL,[BX+02h] ; Cmd_Code
- CMP AL, MaxCmd
- JA Exit_Error ; invalid Code
-
- CBW ; Cmd_Code -> AX
- ADD SI,AX ; Func_Code -> SI
- ADD SI,AX ; * 2
- LES DI,[BX+0Eh] ; Buffer
- MOV AX,CS
- MOV DS,AX ; DS := CS
-
- JMP Word Ptr [SI] ; Jump Function
-
- ; ----------------------------------------------------------
-
- Exit_03: MOV AH,03h ; Status := 3
- JMP Short Drv_Exit
-
- Exit_Error: MOV AL,03h ; Status := 3
- MOV AH,81h
- STC
- JMP Short Drv_Exit
-
- Exit_01: MOV AH,01h ; Status := 1
-
- Drv_Exit: LDS BX, DWord Ptr CS:[DevHdr]
-
- MOV [BX+03h],AX ; Return Status
- POP BX ; restore Registers
- POP ES
- POP DS
- POP DI
- POP DX
- POP CX
- POP AX
- POP SI
- RETF
-
- Interrupt ENDP
-
- ; ----------------------------------------------------------
-
- ANSI_Seq_Len DB 00h
- ANSI_Seq_Buf DB 10 DUP(00h)
-
- ESC_Flag DW 0001h
- Buffer DB 255 DUP(00h)
- Buf_End DB 00h
- Sentinel DW 0000h
- Nd_Read DB FALSE
- ANSI_End DW 0000h
- StrPtr DW 0000h
- Key_Index DW 0093h
- Sav_Index DW 0001h
- StrLen DW 0000h
- Rst_Index DW 0001h
- IdxLen DW 0000h
-
- ; ----------------------------------------------------------
-
- Read PROC NEAR
-
- MOV Byte Ptr DS:[Nd_Read], FALSE
- JCXZ Read_Exit ; if (CX == 0)
-
- Read_1: PUSH DI
- PUSH ES
- PUSH DS
- POP ES ; ES := DS
- CALL Store_ANSI ; Store ANSI Sequence
- POP ES
- POP DI
- STOSB ; AL -> ES:DI
- LOOP Read_1
-
- Read_Exit: JMP Exit_01
-
- Read ENDP
-
- ; ----------------------------------------------------------
-
- Store_ANSI PROC NEAR
-
- XOR AX,AX ; AX = 0
- CALL Concat_ANSI ; Concat ANSI String
- OR AL,AL ; if (AL == 0)
- JZ Store_ANSI_1 ; Kbd -> ANSI Buffer
-
- RET
-
- Store_ANSI_1: INT 16h ; Read Key
- CALL Copy_ANSI ; AL -> ANSI Buffer
- RET
-
- Store_ANSI ENDP
-
- ; ----------------------------------------------------------
-
- NdRead PROC NEAR
-
- PUSH ES
- PUSH DS
- POP ES ; ES = DS
-
- MOV Byte Ptr DS:[Nd_Read], TRUE
-
- XOR AX,AX ; AX = 0
- CALL Concat_ANSI ; Concat ANSI String
- OR AL,AL
- JNZ NdRead_1 ; if (AL != 0)
-
- MOV AH,01h
- INT 16h ; Check Key
- JZ NdRead_2 ; if (no_char)
-
- ; char waiting ->
- CALL Copy_ANSI ; AL -> ANSI Buffer
-
- NdRead_1: LDS BX, DWord Ptr CS:[DevHdr]
- MOV [BX+0Dh],AL ; AL -> DevHdr + 0Dh
- POP ES
- JMP Exit_01 ; Return Status = 1
-
- NdRead_2: POP ES
- JMP Exit_03 ; Return Status = 3
-
- NdRead ENDP
-
- ; ----------------------------------------------------------
-
- Concat_ANSI PROC NEAR
-
- MOV SI, Word Ptr DS:[Sav_Index]
- CMP SI, Word Ptr DS:[StrLen]
- JG Concat_ANSI_1
-
- LODSB ; DS:SI -> AL
- CMP Byte Ptr DS:[Nd_Read], FALSE
- JZ Concat_ANSI_2
-
- RET
-
- Concat_ANSI_2: MOV Word Ptr DS:[Sav_Index],SI
- RET
-
- Concat_ANSI_1: MOV SI,Word Ptr DS:[Rst_Index]
- CMP SI,Word Ptr DS:[IdxLen]
- JG Concat_ANSI_3
-
- LODSB ; DS:SI -> AL
- CMP Byte Ptr DS:[Nd_Read], FALSE
- JZ Concat_ANSI_4
-
- RET
-
- Concat_ANSI_4: MOV Word Ptr DS:[Rst_Index],SI
- RET
-
- Concat_ANSI_3: CMP Byte Ptr DS:[ANSI_Seq_Len],00h
- JNZ Concat_ANSI_5
-
- RET
-
- Concat_ANSI_5: MOV AL, Byte Ptr DS:[ANSI_Seq_Len]
- CMP Byte Ptr DS:[Nd_Read], FALSE
- JZ Concat_ANSI_6
-
- RET
-
- Concat_ANSI_6: MOV Byte Ptr DS:[ANSI_Seq_Len],00h
- RET
-
- Concat_ANSI ENDP
-
- ; ----------------------------------------------------------
-
- Copy_ANSI PROC NEAR
-
- LEA SI, Word Ptr DS:[Buffer]
-
- Copy_ANSI_1: MOV Word Ptr DS:[Sentinel], 0003h
- CMP Word Ptr [SI],+00h
- JZ Copy_ANSI_4 ; Buffer empty
-
- CMP AL,[SI+02h]
- JNZ Copy_ANSI_3
-
- OR AL,AL
- JNZ Copy_ANSI_2 ; if (AL != 0)
-
- MOV Word Ptr DS:[Sentinel],0004h
- CMP AH,[SI+03h]
- JZ Copy_ANSI_2
-
- Copy_ANSI_3: ADD SI,[SI]
- JMP Short Copy_ANSI_1
-
- Copy_ANSI_2: CMP Byte Ptr DS:[Nd_Read], FALSE
- JZ Copy_ANSI_5
-
- ADD SI,Word Ptr DS:[Sentinel]
- MOV AL,[SI]
- RET
-
- Copy_ANSI_5: MOV DI,SI
- ADD DI,[SI]
- DEC DI
- MOV Word Ptr DS:[IdxLen],DI
- ADD SI, Word Ptr DS:[Sentinel]
- MOV AL,[SI]
- INC SI
- MOV Word Ptr DS:[Rst_Index],SI
- RET
-
- Copy_ANSI_4: OR AL,AL
- JZ Copy_ANSI_6 ; if (AL == 0)
-
- RET
-
- Copy_ANSI_6: CMP Byte Ptr DS:[Nd_Read], FALSE
- JZ Copy_ANSI_7
-
- RET
-
- Copy_ANSI_7: MOV Byte Ptr DS:[ANSI_Seq_Len], AH
- RET
-
- Copy_ANSI ENDP
-
- ; ----------------------------------------------------------
-
- InpFlush PROC NEAR
-
- ; Reset variables
-
- MOV Byte Ptr DS:[ANSI_Seq_Len], 00h
- MOV Word Ptr DS:[Sav_Index], 0001h
- MOV Word Ptr DS:[StrLen], 0000h
- MOV Word Ptr DS:[Rst_Index], 0001h
- MOV Word Ptr DS:[IdxLen], 0000h
-
- ; Flush Kbd Buffer
-
- InpFlush_1: MOV AH,01h
- INT 16h ; Check Key
- JZ InpFlush_2 ; if (no_char)
-
- XOR AH,AH
- INT 16h ; Read Key
- JMP Short InpFlush_1
-
- InpFlush_2: JMP Exit_01 ; Return Status = 1
-
- InpFlush ENDP
-
- ; ----------------------------------------------------------
-
- Write PROC NEAR
-
- JCXZ Write_Exit ; if (CX == 0)
-
- MOV SI,DI
-
- Write_2: MOV BX,ES
- MOV DS,BX ; DS := ES
- LODSB ; DS:SI -> AL
- PUSH CX
- PUSH SI
- PUSH ES
- MOV BX,CS
- MOV DS,BX ; DS := CS
- MOV ES,BX ; ES := CS
- CALL ANSI ; Main Parsing Loop
- POP ES
- POP SI
- POP CX
- LOOP Write_2
-
- Write_Exit: JMP Exit_01 ; Return Status = 1
-
- Write ENDP
-
- ; ----------------------------------------------------------
-
- OutFlush PROC NEAR
-
- CALL Flush ; Set Variables
- JMP Exit_01 ; Return Status = 1
-
- OutFlush ENDP
-
- ; ----------------------------------------------------------
- ; New Interrupt 29 (Quick Screen Output)
-
- QuickScreen PROC NEAR
-
- STI
- PUSH AX
- PUSH BX
- PUSH CX
- PUSH DX
- PUSH SI
- PUSH DI
- PUSH DS
- PUSH ES
-
- MOV BX,CS
- MOV DS,BX ; DS := CS
- MOV ES,BX ; ES := CS
- CALL ANSI ; Main Parsing Loop
-
- POP ES
- POP DS
- POP DI
- POP SI
- POP DX
- POP CX
- POP BX
- POP AX
- IRET
-
- QuickScreen ENDP
-
- ; ----------------------------------------------------------
-
- CursorPos DW 0000h
- ScreenPage DB 00h
- TextAttr DB 07h ; black/white
- Row DB 00h
- Column DB 00h
- MaxColumn DB 4Fh ; = 79d
- MaxRow DB 18h ; = 24d
- Monochrome DB FALSE
- CharFlag DB FALSE
- NumFlag DB FALSE
-
- KeyTable DB "A"
- DW Offset MoveCursor
- DW Offset CurUp ; Cursor up
-
- DB "B"
- DW Offset MoveCursor
- DW Offset CurDown ; Cursor down
-
- DB "C"
- DW Offset MoveCursor
- DW Offset CurRight ; Cursor right
-
- DB "D"
- DW Offset MoveCursor
- DW Offset CurLeft ; Cursor left
-
- DB "H"
- DW Offset MoveCursor_0 ; Move Cursor:
- DW Offset GoXY ; GotoXY
-
- DB "f"
- DW Offset MoveCursor_0 ; Move Cursor:
- DW Offset GoXY ; GotoXY
-
- DB "u"
- DW Offset MoveCursor_0 ; Move Cursor:
- DW Offset StoreCurPos ; Store CurPos
-
- DB "s"
- DW Offset RestCurPos ; Restore CurPos
- DW 0000h
-
- DB "J"
- DW Offset ClrScreen
- DW 0000h
-
- DB "k"
- DW Offset ClrEoL
- DW 0000h
-
- DB "K"
- DW Offset ClrEoL
- DW 0000h
-
- DB "m"
- DW Offset GraphParms
- DW 0000h
-
- DB "h"
- DW Offset ScreenParms
- DW 0000h
-
- DB "l"
- DW Offset ScreenParms2
- DW 0000h
-
- DB "n"
- DW Offset WhereXY
- DW 0000h
-
- DB "c"
- DW Offset Color
- DW 0000h
-
- DB "p"
- DW Offset Params
- DW 0000h
-
- DB 00h ; End of Table
-
- ; ----------------------------------------------------------
-
- ANSI PROC NEAR
-
- CMP Word Ptr DS:[ESC_Flag],+01h
- JZ ANSI_1
- JB ANSI_2
- JMP ANSI_3
-
- ANSI_2: JMP ANSI_18
-
- ANSI_1: CMP AL, ESC
- JA ANSI_4
-
- JNZ PutChar
-
- MOV Word Ptr DS:[ESC_Flag],0000h
- MOV Byte Ptr DS:[CharFlag],00h
- RET
-
- PutChar: CMP AL, CR
- JNZ ANSI_6
-
- MOV Byte Ptr DS:[Column],00h
-
- ANSI_6: CMP AL, BEL
- JNZ ANSI_7
-
- CALL Beep
- RET
-
- ANSI_7: MOV AH, 0Eh
- MOV BL, Byte Ptr DS:[TextAttr]
- INT 10h ; Write TTY Char
- RET
-
- ANSI_4: XOR BX,BX
- MOV ES,BX ; ES := 0
- MOV AH, Byte Ptr ES:[0449h]
-
- ; 0040h:0049h -> CrtMode
-
- CMP AH,07h
- JZ ANSI_8 ; if (CrtMode == 7)
-
- CMP AH,03h
- JBE ANSI_9 ; if (CrtMode <= 3)
-
- JMP Short ANSI_7 ; Write TTY (AL)
-
- ANSI_8: MOV Byte Ptr CS:[Monochrome], TRUE
-
- ANSI_9: MOV BL, Byte Ptr ES:[0462h]
-
- ; 0040h:0062h -> ActPage
-
- MOV Byte Ptr DS:[ScreenPage], BL
- SHL BL,1
- ADD BX,0450h
- MOV DX,ES:[BX]
-
- MOV CX, Word Ptr ES:[044Ah]
-
- ; 0040h:004Ah -> Columns
-
- DEC CX
- MOV Byte Ptr DS:[MaxColumn],CL
- MOV Byte Ptr DS:[MaxRow],18h
-
- MOV BL, Byte Ptr ES:[0484h]
-
- ; 0040h:0084h -> Rows
-
- OR BL,BL
- JZ ANSI_10 ; if (BL == 0)
-
- MOV Byte Ptr CS:[Monochrome], TRUE
- MOV Byte Ptr DS:[MaxRow],BL
-
- ANSI_10: CMP Byte Ptr DS:[Column],01h
- JNZ ANSI_11
-
- RET
-
- ANSI_11: MOV AH,Byte Ptr DS:[TextAttr]
- MOV BH,Byte Ptr DS:[ScreenPage]
- PUSH ES
- PUSH DX
- MOV CX, AX
- CALL NormColumns
- MOV DX, Word Ptr ES:[0463h]
-
- ; 0040h:0063h -> Video Base
-
- ADD DX,+06h ; Crt Status
-
- MOV AX, ScrSegColor
- CMP Byte Ptr ES:[0449h],07h
-
- ; 0040h:0049h -> CrtMode
-
- JNZ ANSI_12
-
- MOV AX, ScrSegMono
-
- ANSI_12: MOV ES,AX ; ES = ScreenSeg
- CMP Byte Ptr DS:[Monochrome], TRUE
- JZ ANSI_13
-
- ; Wait for horizontal retrace
-
- ANSI_14: IN AL,DX ; Port_IN:VideoBase + 6
- ; ( Status )
- ROR AL,1
- JB ANSI_14 ; if (Bit_0)
-
- CLI
-
- ANSI_15: IN AL,DX ; Port_IN:VideoBase + 6
- ; ( Status )
- ROR AL,1
- JNB ANSI_15 ; if !(Bit_0)
-
- ANSI_13: MOV AX,CX
- STOSW ; AX -> ES:DI
- STI
- POP DX
- POP ES
- INC DL
- CMP DL,Byte Ptr DS:[MaxColumn]
- JBE ANSI_16
-
- CMP Byte Ptr DS:[Row],01h
- JNZ ANSI_17 ; Bottom of screen
-
- MOV Byte Ptr DS:[Column],01h
- RET
-
- ANSI_17: XOR DL,DL ; DL = 0
- INC DH
- CMP DH, Byte Ptr DS:[MaxRow]
- JBE ANSI_16
-
- ; if (Row > MaxRows)
- MOV AH,06h ; Scroll Up
- CALL Scroll
-
- XOR DL,DL ; DL = 0
- MOV DH,Byte Ptr DS:[MaxRow]
-
- ANSI_16: MOV AL,Byte Ptr DS:[ScreenPage]
- CBW ; WORD(ScrPage)
- SHL AX,1 ; ScrPage * 2
- ADD AX,0450h
- MOV DI,AX
- MOV ES:[DI],DX
- CALL NormColumns
- SHR DI,1
- MOV CX,DI
- MOV AH,0Eh
- MOV DI,DX ; Save DX
- CALL OutVideo
- MOV DX,DI ; Restore DX
- RET
-
- ANSI_18: CALL Flush
- CMP AL,5Bh
- JZ ANSI_19 ; if ( AL == "[" )
-
- CMP AL,5Ah
- JNZ ANSI_20 ; if ( AL != "Z" )
-
- CALL Color
- JMP Flush
-
- ANSI_20: CMP AL,37h
- JNZ ANSI_21 ; if ( AL != "7" )
-
- CALL RestCurPos ; Restore CurPos
- JMP Flush
-
- ANSI_21: CMP AL,38h
- JNZ ANSI_22 ; if ( AL != "8" )
-
- CALL StoreCurPos ; Store CurPos
- CALL ANSI_16
- JMP Flush
-
- ANSI_22: CMP AL,44h
- JNZ ANSI_23 ; if ( AL != "D" )
-
- MOV AH,06h
- JMP Short ANSI_24
-
- ANSI_23: CMP AL,4Dh
- JNZ ANSI_25 ; if ( AL != "M" )
-
- MOV AH,07h
-
- ANSI_24: MOV DH, Byte Ptr DS:[MaxRow]
- DEC DH
- CALL Scroll_1
- JMP Flush
-
- ANSI_25: JMP Put_And_Flush
-
- ANSI_19: MOV Word Ptr DS:[ESC_Flag],0002h
- RET
-
- ANSI_3: CMP AL,3Fh
- JZ ANSI_27 ; if ( AL == "?" )
-
- CMP AL,3Dh
- JZ ANSI_27 ; if ( AL == "=" )
-
- CMP AL,3Bh
- JZ ANSI_27 ; if ( AL == ";" )
-
- CMP AL,30h
- JB ANSI_28 ; if ( AL < "0" )
-
- CMP AL,39h
- JBE ANSI_27 ; if ( AL <= "9" )
-
- ANSI_28: CMP AL, quote
- JZ ANSI_29 ; if ( AL == '"' )
-
- TEST Byte Ptr DS:[CharFlag], TRUE
- JNZ ANSI_27
-
- JMP Short ANSI_31
-
- ANSI_29: XOR Byte Ptr DS:[CharFlag], 01h
-
- ANSI_27: CMP Word Ptr DS:[ANSI_End], Offset Buf_End
- JNB ANSI_30
-
- MOV DI, Word Ptr DS:[ANSI_End]
- MOV [DI],AL
- INC Word Ptr DS:[ANSI_End]
- RET
-
- ANSI_30: JMP Short EmitParms
-
- NOP
-
- ANSI_31: MOV Word Ptr DS:[ESC_Flag], 0001h
- DEC Word Ptr DS:[ANSI_End]
-
- MOV DI, Offset KeyTable - 5
-
- ANSI_32: ADD DI,+05h
- CMP Byte Ptr [DI],00h
- ; Proceed table
- ; until key = 00h
- JNZ ANSI_33
-
- JMP Short EmitParms
-
- NOP
-
- ANSI_33: CMP AL,[DI] ; table key
- JNZ ANSI_32 ; try next
-
- ; table key found:
- MOV SI, Word Ptr DS:[Key_Index]
- MOV Word Ptr DS:[StrPtr], SI
-
- CALL Word Ptr [DI+01h]
- ; first table proc
- RET
-
- ANSI ENDP
-
- ; ----------------------------------------------------------
-
- Parse PROC NEAR
-
- MOV Byte Ptr DS:[NumFlag], FALSE
- XOR AX, AX ; AX = 0
- PUSH DI ; save table key
-
- Parse_1: MOV DI, Word Ptr DS:[StrPtr]
- CMP DI, Word Ptr DS:[ANSI_End]
- JG Parse_2
-
- CMP Byte Ptr [DI], "="
- JZ Parse_3
-
- CMP Byte Ptr [DI], "?"
- JZ Parse_3
-
- CMP Byte Ptr [DI], ";"
- JZ Parse_4
-
- MOV CL,0Ah
- MUL CL ; AX := CL * 10
- SUB Byte Ptr [DI], "0"
- ADD AL,[DI]
- MOV Byte Ptr DS:[NumFlag], TRUE
-
- Parse_3: INC Word Ptr DS:[StrPtr]
- JMP Short Parse_1
-
- Parse_4: INC Word Ptr DS:[StrPtr]
-
- Parse_2: MOV CX,AX
- POP DI ; restore table key
- RET
-
- Parse ENDP
-
- ; ----------------------------------------------------------
-
- EmitParms PROC NEAR
-
- PUSH AX
- MOV AL, "["
- CALL PutChar
- MOV DI, Word Ptr DS:[Key_Index]
-
- EmitParms_1: CMP DI, Word Ptr DS:[ANSI_End]
- JA EmitParms_2
-
- MOV AL,[DI]
- CALL PutChar
- INC DI
- JMP Short EmitParms_1
-
- EmitParms_2: POP AX
-
- Put_And_Flush: CALL PutChar
-
- Flush: MOV Word Ptr DS:[ESC_Flag],0001h
- MOV SI, Word Ptr DS:[Key_Index]
- MOV Word Ptr DS:[ANSI_End],SI
- MOV Word Ptr DS:[StrPtr],SI
- RET
-
- EmitParms ENDP
-
- ; ----------------------------------------------------------
- ; Scroll
-
- Scroll PROC NEAR
-
- MOV DH, Byte Ptr DS:[MaxRow]
-
- Scroll_1: MOV DL, Byte Ptr DS:[MaxColumn]
- MOV AL,01h ; # lines
- MOV BH, Byte Ptr DS:[TextAttr]
- XOR CX,CX
- PUSH BP
- INT 10h ; Scroll
- POP BP
- RET
-
- Scroll ENDP
-
- ; ----------------------------------------------------------
-
- MoveCursor PROC NEAR
-
- MOV AH,03h
- MOV BH, Byte Ptr DS:[ScreenPage]
- INT 10h ; Get Cursor Position
- ; CX = CurSize
- ; DX = CursPos
-
- MoveCursor_0: CALL Parse
- OR CX,CX
- JNZ MoveCursor_1 ; if (CX != 0)
-
- MOV CX,0001h ; CurMovement
-
- MoveCursor_1: CALL Word Ptr [DI+03h]
- ; follow Procedure
- ; DH = Row
- ; DL = Column
- MOV AH,02h
- MOV BH, Byte Ptr DS:[ScreenPage]
- INT 10h ; Set Cursor Position
- RET
-
- MoveCursor ENDP
-
- ; ----------------------------------------------------------
-
- CurUp PROC NEAR
-
- OR DH,DH
- JZ CurUp_1
-
- DEC DH
- LOOP CurUp
-
- CurUp_1: RET
-
- CurUp ENDP
-
- ; ----------------------------------------------------------
-
- CurDown PROC NEAR
-
- CMP DH, Byte Ptr DS:[MaxRow]
- JZ CurDown_1
-
- INC DH
- LOOP CurDown
-
- CurDown_1: RET
-
- CurDown ENDP
-
- ; ----------------------------------------------------------
-
- CurRight PROC NEAR
-
- CMP DL, Byte Ptr DS:[MaxColumn]
- JNB CurRight_1
-
- INC DL
- LOOP CurRight
-
- CurRight_1: RET
-
- CurRight ENDP
-
- ; ----------------------------------------------------------
-
- CurLeft PROC NEAR
-
- OR DL,DL
- JZ CurLeft_1
-
- DEC DL
- LOOP CurLeft
-
- CurLeft_1: RET
-
- CurLeft ENDP
-
- ; ----------------------------------------------------------
-
- GoXY PROC NEAR
-
- MOV DH,CL
- CALL Parse
- OR CL,CL
- JNZ GoXY_1
-
- MOV CL,01h
-
- GoXY_1: MOV DL,CL
- SUB DX,0101h
- RET
-
- GoXY ENDP
-
- ; ----------------------------------------------------------
-
- StoreCurPos PROC NEAR
-
- MOV DX, Word Ptr DS:[CursorPos]
- RET
-
- StoreCurPos ENDP
-
- ; ----------------------------------------------------------
-
- RestCurPos PROC NEAR
-
- MOV AH,03h
- MOV BH, Byte Ptr DS:[ScreenPage]
- INT 10h ; Get Cursor Position
- MOV Word Ptr DS:[CursorPos],DX
- RET
-
- RestCurPos ENDP
-
- ; ----------------------------------------------------------
-
- ClrScreen PROC NEAR
-
- CALL Parse
-
- PUSH CX
- MOV AH,03h
- MOV BH, Byte Ptr DS:[ScreenPage]
- INT 10h ; Get Cursor Position
- MOV AL, Byte Ptr DS:[MaxColumn]
- INC AL
- MOV CX,DX ; CX := CursPos
- MUL CH ; AX := AL * CH
- XOR CH,CH
- ADD AX,CX ; AX := AX + Row
- POP CX
-
- PUSH DX ; CursPos
- OR CX,CX
- JNZ ClrScreen_1 ; if ( CX != 0 )
-
- PUSH AX
- XOR AX,AX ; AX = 0
- MOV AL, Byte Ptr DS:[MaxRow]
- MOV CL, Byte Ptr DS:[MaxColumn]
- INC CL
- MUL CL ; AX := AL * CL
- MOV CX,AX
- POP AX
-
- SUB CX,AX
- JMP Short WriteBlank
-
- ClrScreen_1: CMP CX,+01h
- JNZ ClrScreen_2 ; if ( CX != 1 )
-
- MOV CX,AX
- XOR DX,DX ; CursPos = 0
- MOV AH,02h
- MOV BH, Byte Ptr DS:[ScreenPage]
- INT 10h ; Set Cursor Position
- JMP Short WriteBlank
-
- ClrScreen_2: POP DX
- XOR DX,DX ; DX = 0
- PUSH DX
- MOV DH,Byte Ptr DS:[MaxRow]
- MOV DL,Byte Ptr DS:[MaxColumn]
- XOR CX,CX ; CX = 0
- MOV BH,Byte Ptr DS:[TextAttr]
- MOV AX,0600h
- JMP Short ClrScreen_3
-
- WriteBlank: MOV AX,0A20h
- MOV BH,Byte Ptr DS:[ScreenPage]
-
- ClrScreen_3: INT 10h ; Write Char
- POP DX
- MOV AH,02h
- MOV BH,Byte Ptr DS:[ScreenPage]
- INT 10h ; Set Cursor Position
- RET
-
- ClrScreen ENDP
-
- ; ----------------------------------------------------------
-
- ClrEoL PROC NEAR
-
- CALL Parse
- PUSH CX
- MOV AH,03h
- MOV BH,Byte Ptr DS:[ScreenPage]
- INT 10h ; Get Cursor Position
- POP CX
- PUSH DX
- MOV CX,DX
- MOV DL,Byte Ptr DS:[MaxColumn]
-
- MOV AX,0600h
- MOV BH,Byte Ptr DS:[TextAttr]
- INT 10h ; Scroll Up
- POP DX ; Cursor Position
- MOV AH,02h
- MOV BH,Byte Ptr DS:[ScreenPage]
- INT 10h ; Set Cursor Position
- RET
-
- ClrEoL ENDP
-
- ; ----------------------------------------------------------
-
- ColorTable DW Offset SetAttr
- DB 07h ; Black/White
-
- DW Offset Or_Attr
- DB 08h ; DarkGrey
-
- DW 0FFFFh
- DB 0FFh ; not implemented
-
- DW 0FFFFh
- DB 0FFh ; not implemented
-
- DW Offset Or_Attr
- DB 01h ; Blue
-
- DW Offset Or_Attr
- DB 80h ; Blink
-
- DW 0FFFFh
- DB 0FFh ; not implemented
-
- DW Offset SetAttr
- DB 70h ; LightGrey/Black
-
- DW Offset SetAttr
- DB 00h ; Black/Black
-
- DW 0FFFFh
- DB 0FFh ; not implemented
-
- DW Offset Background
- DB 00h ; Black
-
- DW Offset Background
- DB 04h ; Red
-
- DW Offset Background
- DB 02h ; Green
-
- DW Offset Background
- DB 0Eh ; Yellow
-
- DW Offset Background
- DB 01h ; Blue
-
- DW Offset Background
- DB 05h ; Magenta
-
- DW Offset Background
- DB 03h ; Cyan
-
- DW Offset Background
- DB 07h ; LightGray
-
- DW 0FFFFh
- DB 0FFh ; not implemented
-
- DW 0FFFFh
- DB 0FFh ; not implemented
-
- DW Offset Foreground
- DB 00h ; Black
-
- DW Offset Foreground
- DB 40h ; Red
-
- DW Offset Foreground
- DB 20h ; Green
-
- DW Offset Foreground
- DB 60h ; Brown
-
- DW Offset Foreground
- DB 10h ; Blue
-
- DW Offset Foreground
- DB 50h ; Magenta
-
- DW Offset Foreground
- DB 30h ; Cyan
-
- DW Offset Foreground
- DB 70h ; LightGray
-
- ; ----------------------------------------------------------
-
- GraphParms PROC NEAR
-
- CALL Parse
- CMP Byte Ptr DS:[NumFlag],00h
- JZ GraphParms_1 ; Exit
-
- CMP CL, 2Fh ; Color Table entries
- JG GraphParms
-
- CMP CL,00h
- JB GraphParms
-
- CMP CL,0Ah
- JB GraphParms_2
-
- SUB CL,14h
-
- GraphParms_2: MOV AL,CL ; AL = Attr_Function
- XOR AH,AH
- MOV BL,03h
- MUL BL ; AX := AL * 3
- LEA DI, Word Ptr DS:[ColorTable]
- ADD DI,AX
-
- CMP Byte Ptr [DI],0FFh
- JZ GraphParms
-
- MOV BL, Byte Ptr DS:[TextAttr]
-
- CALL Word Ptr [DI] ; Call Function
-
- JMP Short GraphParms
-
- GraphParms_1: RET
-
- GraphParms ENDP
-
- ; ----------------------------------------------------------
-
- SetAttr PROC NEAR
-
- MOV BL,[DI+02h]
- MOV Byte Ptr DS:[TextAttr],BL
- RET
-
- SetAttr ENDP
-
- ; ----------------------------------------------------------
-
- Or_Attr PROC NEAR
-
- OR BL,[DI+02h]
- MOV Byte Ptr DS:[TextAttr],BL
- RET
-
- Or_Attr ENDP
-
- ; ----------------------------------------------------------
-
- Background PROC NEAR
-
- AND BL,0F0h
- OR BL,[DI+02h]
- MOV Byte Ptr DS:[TextAttr],BL
- RET
-
- Background ENDP
-
- ; ----------------------------------------------------------
-
- Foreground PROC NEAR
-
- AND BL,0Fh
- OR BL,[DI+02h]
- MOV Byte Ptr DS:[TextAttr],BL
- RET
-
- Foreground ENDP
-
- ; ----------------------------------------------------------
-
- ScreenParms PROC NEAR
-
- XOR DL,DL ; DL := 0
- JMP Short ScreenParms_1
-
- NOP
-
- ScreenParms2: MOV DL,01h
-
- ScreenParms_1: CALL Parse
- CMP CX,+07h
- JG ScreenParms_2
-
- JB ScreenParms_3
-
- MOV Byte Ptr DS:[Row],DL
- RET
-
- ScreenParms_3: CMP CX,+00h
- JB ScreenParms_2
-
- XOR AH,AH
- MOV AL,CL
- INT 10h ; Set_Vid_Mode
-
- ScreenParms_2: RET
-
- ScreenParms ENDP
-
- ; ----------------------------------------------------------
-
- ANSI_Str_1 DB 1Bh, "[0n"
-
- ANSI_Str_2 DB 1Bh, "[;R"
-
- ANSI_Str_3 DB 1Bh, "[?1;0c"
-
- ; ----------------------------------------------------------
-
- WhereXY PROC NEAR
-
- CALL Parse
- LEA DI, Word Ptr DS:[ANSI_Seq_Buf]
- LEA SI, Word Ptr DS:[ANSI_Str_2]
- MOV Word Ptr DS:[Sav_Index],DI
- CMP CX,+05h
- JNZ WhereXY_1
-
- LEA SI, Word Ptr DS:[ANSI_Str_1]
- MOV CX,0004h
- CALL Copy
- JMP Short WhereXY_2
-
- WhereXY_1: MOV CX,0002h
- CALL Copy
-
- MOV AH,03h
- MOV BH, Byte Ptr DS:[ScreenPage]
- INT 10h ; Get Cursor Position
- ADD DX,0101h
- MOV AL,DH ; AL := Row
- CALL NormCurPos
-
- MOV CX,0001h
- CALL Copy
-
- MOV AL,DL ; AL := Col
- CALL NormCurPos
-
- MOV CX,0001h
- CALL Copy
-
- WhereXY_2: DEC DI
- MOV Word Ptr DS:[StrLen],DI
- RET
-
- WhereXY ENDP
-
- ; ----------------------------------------------------------
-
- Copy PROC NEAR
-
- MOVSB ; DS:SI -> ES:DI
- LOOP Copy ; CX Bytes
-
- RET
-
- Copy ENDP
-
- ; ----------------------------------------------------------
-
- NormCurPos PROC NEAR
-
- XOR AH,AH
- MOV CL,0Ah
- DIV CL ; AX := AX / CL
- ; AL = DIV
- ; AH = MOD
- OR AX,3030h ; + "0"
- STOSB ; AL -> ES:DI
- XCHG AH, AL
- STOSB ; AL -> ES:DI
- RET
-
- NormCurPos ENDP
-
- ; ----------------------------------------------------------
-
- Color PROC NEAR
-
- LEA SI, Word Ptr DS:[ANSI_Str_3]
- LEA DI, Word Ptr DS:[ANSI_Seq_Buf]
- MOV Word Ptr DS:[Sav_Index],DI
- MOV CX,0007h
- CALL Copy
- JMP Short WhereXY_2
-
- Params: PUSH ES
- PUSH DS
- POP ES ; ES := DS
- MOV DI, Word Ptr DS:[Key_Index]
- SUB DI,+02h
- MOV SI, Word Ptr DS:[Key_Index]
-
- ; string in quotes -> ES:DI
-
- Params_1: CMP SI, Word Ptr DS:[ANSI_End]
- JG Params_2
-
- CMP Byte Ptr [SI], quote
- JZ Params_3
-
- MOV Word Ptr DS:[StrPtr],SI
- CALL Parse
- MOV SI, Word Ptr DS:[StrPtr]
- STOSB ; AL -> ES:DI
- JMP Short Params_1
-
- Params_3: INC SI
- Params_4: MOVSB ; AL -> DS:SI
- CMP Byte Ptr [SI], quote
- JNZ Params_4
-
- INC SI
- INC SI
- JMP Short Params_1
-
- Params_2: MOV Word Ptr [DI],0000h
- ADD DI,+04h
- MOV SI,DI
- XCHG DI, Word Ptr DS:[Key_Index]
- SUB SI,DI
- SUB DI,+04h
- MOV [DI],SI
- POP ES
- RET
-
- Color ENDP
-
- ; ----------------------------------------------------------
-
- NormColumns PROC NEAR
-
- MOV AL,BH
- CBW ; AX := WORD(BH)
- OR AX,AX
- JZ NormColumns_1
-
- NormColumns_1: MOV DI,AX ; DI := WORD(BH)
- MOV BX,DX
- MOV AL,DH
- MUL Byte Ptr ES:[044Ah]
- ; 0040h:004Ah -> Cols
- XOR BH,BH
- ADD AX,BX
- SHL AX,1
- ADD DI,AX
- RET
-
- NormColumns ENDP
-
- ; ----------------------------------------------------------
-
- OutVideo PROC NEAR
-
- MOV DX, Word Ptr ES:[0463h]
- ; 0040h:0063h -> VideoBase
- MOV AL,AH
- OUT DX,AL ; Port_OUT:VideoBase
- MOV AL,CH
- INC DX
- OUT DX,AL ; Port_OUT:VideoBase+1
- DEC DX
- INC AH
- MOV AL,AH
- OUT DX,AL ; Port_OUT:VideoBase
- MOV AL,CL
- INC DX
- OUT DX,AL ; Port_OUT:VideoBase+1
- RET
-
- OutVideo ENDP
-
- ; ----------------------------------------------------------
-
- Beep PROC NEAR
-
- PUSH AX
- PUSH DX
- PUSH ES
- MOV AL,0B6h
- MOV DX,0043h
- OUT DX,AL ; Port_OUT:Timer+4
- DEC DX
- MOV AX,0960h
- JMP Short Beep_1
-
- Beep_1: OUT DX,AL ; Port_OUT:Timer+3
- XCHG AH,AL
- JMP Short Beep_2
-
- Beep_2: OUT DX,AL ; Port_OUT:Timer+3
- MOV DX,0061h
- JMP Short Beep_3
-
- Beep_3: IN AL,DX ; Port_IN:Keyb+1
- PUSH AX
- OR AL,03h
- JMP Short Beep_4
-
- Beep_4: OUT DX,AL ; Port_OUT:Keyb+1
-
- MOV AX,0040h
- MOV ES,AX ; ES := BIOS
- MOV BX, Word Ptr ES:[006Ch]
-
- ; 0040h:006Ch -> Timer Count
-
- MOV CX,0FFFFh
- MOV AX,BX
- ADD AX,0001h
-
- Beep_5: MOV AX, Word Ptr ES:[006Ch]
-
- ; 0040h:006Ch -> Timer Count
-
- SUB AX,BX
- CMP AX,0001h
- JG Beep_6
-
- LOOP Beep_5
-
- Beep_6: POP AX
- AND AL,0FCh
- OUT DX,AL ; Port_OUT:Keyb+1
- POP ES
- POP DX
- POP AX
- RET
-
- Beep ENDP
-
- ; ----------------------------------------------------------
-
- Message DB 0Dh, 0Ah, " ╔════════════════════════════════════════╗"
- DB 0Dh, 0Ah, " ║ DOS-toolbox: DAS PROGRAMMIERER-MAGAZIN ║▒"
- DB 0Dh, 0Ah, " ╟────────────────────────────────────────╢▒"
- DB 0Dh, 0Ah, " ║ ANSI Driver V 1.01 ║▒"
- DB 0Dh, 0Ah, " ║ ║▒"
- DB 0Dh, 0Ah, " ║ (c) 1991 DMV - Daten & Medien Verlag ║▒"
- DB 0Dh, 0Ah, " ║ ──────────────────────────────────── ║▒"
- DB 0Dh, 0Ah, " ║ Redaktion DOS-toolbox ║▒"
- DB 0Dh, 0Ah, " ║ Postfach 250 ║▒"
- DB 0Dh, 0Ah, " ║ 3440 Eschwege ║▒"
- DB 0Dh, 0Ah, " ║ Tel.: 05651-809-0 ║▒"
- DB 0Dh, 0Ah, " ║ ║▒"
- DB 0Dh, 0Ah, " ╚════════════════════════════════════════╝▒"
- DB 0Dh, 0Ah, " ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒"
- DB 0Dh, 0Ah
- DB 0Dh, 0Ah, 00h
-
- ; ----------------------------------------------------------
-
- PrintMsg PROC NEAR
-
- MOV AH, 0Eh ; Write TTY
- MOV BH, Byte Ptr DS:[ScreenPage]
- MOV SI, Offset Message
- MOV CX, 0001h
-
- PrintMsg_1: MOV AL, Byte Ptr CS:[SI]
- CMP AL, 00h
- JZ PrintMsg_Exit
-
- INT 10h
- INC SI
- JMP PrintMsg_1
-
- PrintMsg_Exit: RET
-
- PrintMsg ENDP
-
- ; ----------------------------------------------------------
-
- Init PROC NEAR
-
- LDS BX, DWord Ptr DS:[DevHdr]
- MOV Word Ptr [BX+0Eh], Offset Message
-
- ; Länge des residenten Teils.
- ; "Offset EndDrv" wäre an sich richtig,
- ; aber der Initialisierungsteil wird
- ; nie wieder gebraucht. So sparen wir
- ; noch ein paar Bytes im Speicher.
-
- MOV [BX+10h],CS
- XOR BX,BX
- MOV DS,BX ; DS := 0
- MOV BX,00A4h ; Int 29
- MOV Word Ptr [BX], Offset QuickScreen
- MOV [BX+02h],CS
-
- CALL PrintMsg
-
- JMP Exit_01
-
- Init ENDP
-
- ; ----------------------------------------------------------
-
- EndDrv: ; Mark the next free byte
-
- CODE ENDS
- END
-
- ;* ------------------------------------------------------- *
- ;* Ende von TXANSI.ASM *
-