- TITLE The New DOS
- .model small
- .386p
- .stack 100h
- OPTION CaseMap:None
- ; Set the window variable framework
- WINDESC STRUCT
- upperRow BYTE ?
- leftCol BYTE ?
- lowerRow BYTE ?
- rightCol BYTE ?
- foreColor BYTE ?
- backColor BYTE ?
- WINDESC ENDS
- ; Not really sure about this one
- exit MACRO
- mov ax, 4C00h
- int 21h
- ENDM
- ;set variables
- .data
- BufLen db 20
- RetLen db 0
- BufInp db 21 dup(?)
- application WINDESC <05h, 05h, 15h, 45h, 07h, 10h>
- msgNoMouseDriver db "no mouse driver",13,10,"$"
- msgPressAnyKey db "press any key to exit",13,10,"$"
- ;below is newly added border parameters
- upperRow2 DB 218
- RightCol2 DB 191
- LowerRow2 DB 192
- LeftCol2 DB 217
- Horizontal DB 196
- Vertical DB 179
- Row1 WORD ?
- Row2 WORD ?
- ConsoleScreen CHAR_INFO 2000 DUP (<>)
- ;==============================================================================
- ;-------------------------------------------------------------------
- ; With MASM the mouse driver functions are called with the function
- ; number in AX, and depending on the function, the return values may
- ; be in AX, BX, CX, or DX.
- ;-------------------------------------------------------------------
- ;----------------------------------------------------------------------
- ; Check for a mouse driver. Use the DOS Get Interrupt Vector function
- ; to get the interrupt 33h vector. If the segment address is zero then
- ; the mouse driver is not installed.
- ;----------------------------------------------------------------------
- .code
- ;User buffer to enter text
- mov dx,offset BufLen
- mov ah,0Ah
- int 21h
- ;mouse driver
- mouse proc
- @@:
- mov ax, 3
- int 33h
- test bx, 1
- jz @B
- mouse endp
- ; -------------------------------------------------------------
- ; This proc calls the BIOS Read Keyboard Status and Read
- ; Keyboard Input functions to flush the keyboard buffer,
- ; wait for a key press, and then flush the buffer again,
- ; leaving it empty. The BIOS scan code for the key pressed
- ; is returned in AH and the character code in AL.
- ; -------------------------------------------------------------
- waitkey proc c
- @@:
- mov ah, 1
- int 16h ; Check for key press
- jz @F ; Jump if buffer empty
- mov ah, 0
- int 16h ; Get key
- jmp @B ; Repeat
- @@:
- mov ah, 1
- int 16h ; Check for key press
- jz @B ; Repeat
- mov ah, 0
- int 16h ; Get key
- push ax ; Preserve it
- @@:
- mov ah, 1
- int 16h ; Check for key press
- jz @F ; Jump if buffer empty
- mov ah, 0
- int 16h ; Get key
- jmp @B ; Repeat
- @@:
- pop ax ; Recover key
- ret
- waitkey endp
- curpos PROC
- push bp
- mov bp, sp
- push ax
- push bx
- push dx
- mov ax, 0200h
- mov bh, 0
- mov dx, [bp+4]
- ; interrupt
- int 10h
- pop dx
- pop bx
- pop ax
- pop bp
- ret 2
- curpos ENDP
- getchar PROC
- mov ah,00h
- int 16h
- ret
- getchar ENDP
- FORMAT PROC szFmtName:DWORD
- INVOKE WriteConsoleOutput, Handler1, szFmtName, DWORD PTR BufSize,
- DWORD PTR Starter, OFFSET WindowSize
- RET
- FORMAT ENDP
- ;window construction
- makewin PROC
- push bp
- mov bp, sp
- push ax
- push bx
- push cx
- push dx
- push si
- mov si, [bp+4]
- mov ax, 0600h
- mov bh, (WINDESC PTR[si]) .backColor
- mov ch, (WINDESC PTR[si]) .upperRow
- mov cl, (WINDESC PTR[si]) .leftCol
- mov dh, (WINDESC PTR[si]) .lowerRow
- mov dl, (WINDESC PTR[si]) .rightCol
- ;interrupt
- int 10h
- push cx
- ; newly added window border info
- MOV AX, Row1
- SUB AL, 1
- IMUL AX, 320 ;pg627 perform a signed integer multiplication.
- MOV DX, AX
- LEA AX, ConsoleScreen ;pg631 calculate and load the memory address.
- ADD AX, DX
- MOVZX BX, BYTE PTR[upperRow2]
- MOV SI, AX
- MOV BYTE PTR [SI], BL
- ADD SI, 4
- MOV CX, 78
- MOVZX BX, BYTE PTR [Horizontal]
- MOV BL, Horizontal
- Filler1:
- MOV SI, AX
- MOV BYTE PTR[SI], BL
- ADD SI, 4
- DEC CX
- JNZ Filler1
- MOVZX BX, BYTE PTR [RightCol2]
- MOV BYTE PTR [SI], BL
- ADD SI, 4
- MOV CX, Row2
- SUB CX, Row1
- DEC CX
- MOVZX BX, BYTE PTR [Vertical]
- BorderFill:
- MOV SI, AX
- MOV BYTE PTR [SI], BL
- ADD SI, 4
- MOV DX, 4
- IMUL DX, 78
- ADD SI, DX
- MOV BYTE PTR[SI], BL
- ADD SI, 4
- DEC CX
- JNZ BorderFill
- MOVZX BX, BYTE PTR [LowerRow2]
- MOV BYTE PTR [SI], BL
- ADD SI, 4
- MOV CX, 78
- MOVZX BX, BYTE PTR [Horizontal]
- Filler2:
- MOV SI, AX
- MOV BYTE PTR [SI], BL
- ADD SI, 4
- DEC CX
- JNZ Filler2
- MOVZX BX, BYTE PTR [LeftCol2]
- MOV BYTE PTR [SI], BL
- RET
- call curpos
- ; RET
- pop si
- pop dx
- pop cx
- pop bx
- pop ax
- pop bp
- ret 2
- makewin ENDP
- main PROC
- mov ax, @data
- mov ds, ax
- mov ax, OFFSET application
- push ax
- INVOKE FORMAT, offset ConsoleScreen
- call makewin
- mov al,application.leftCol
- mov ah,application.upperRow
- push ax
- call curpos
- call waitkey
- call mouse
- call getchar
- exit
- main ENDP
- end main