source: vendor/emx/current/src/dos/vprint.asm

Last change on this file was 18, checked in by bird, 22 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 7.6 KB
Line 
1;
2; VPRINT.ASM -- Text output directly to video memory
3;
4; Copyright (c) 1991-1995 by Eberhard Mattes
5;
6; This file is part of emx.
7;
8; emx is free software; you can redistribute it and/or modify it
9; under the terms of the GNU General Public License as published by
10; the Free Software Foundation; either version 2, or (at your option)
11; any later version.
12;
13; emx is distributed in the hope that it will be useful,
14; but WITHOUT ANY WARRANTY; without even the implied warranty of
15; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16; GNU General Public License for more details.
17;
18; You should have received a copy of the GNU General Public License
19; along with emx; see the file COPYING. If not, write to
20; the Free Software Foundation, 59 Temple Place - Suite 330,
21; Boston, MA 02111-1307, USA.
22;
23; See emx.asm for a special exception.
24;
25
26 INCLUDE EMX.INC
27 INCLUDE TABLES.INC
28 INCLUDE SEGMENTS.INC
29
30 PUBLIC VWIDTH, VHEIGHT
31 PUBLIC VDWORD, VWORD, VBYTE, VNIBBLE
32 PUBLIC VTEXT, VCHAR, VCRLF, VCLS, VGETCOL, VWRAP
33 PUBLIC VINIT
34
35SV_DATA SEGMENT
36
37VWIDTH DW 80 ; Number of character columns
38VHEIGHT DW 25 ; Number of character rows
39VPTR DW 0 ; Destination pointer
40
41SV_DATA ENDS
42
43
44SV_CODE SEGMENT
45
46 ASSUME CS:SV_CODE, DS:NOTHING
47
48
49 ASSUME DS:SV_DATA
50VDWORD PROC NEAR
51 ROR EAX, 16
52 CALL VWORD
53 ROR EAX, 16
54 CALL VWORD
55 RET
56VDWORD ENDP
57
58
59 ASSUME DS:SV_DATA
60VWORD PROC NEAR
61 XCHG AL, AH
62 CALL VBYTE
63 XCHG AL, AH
64 CALL VBYTE
65 RET
66VWORD ENDP
67
68
69 ASSUME DS:SV_DATA
70VBYTE PROC NEAR
71 PUSH AX
72 SHR AL, 4
73 CALL VNIBBLE
74 POP AX
75 PUSH AX
76 CALL VNIBBLE
77 POP AX
78 RET
79VBYTE ENDP
80
81
82 ASSUME DS:SV_DATA
83VNIBBLE PROC NEAR
84 AND AL, 0FH
85 ADD AL, 30H
86 CMP AL, 3AH
87 JB SHORT VNIB1
88 ADD AL, 7
89VNIB1: CALL VCHAR
90 RET
91VNIBBLE ENDP
92
93
94 ASSUME DS:SV_DATA
95VTEXT PROC NEAR
96 PUSH AX
97VTEXT1: MOV AL, DS:[EDX]
98 OR AL, AL
99 JZ SHORT VTEXT9
100 CALL VCHAR
101 INC EDX
102 JMP SHORT VTEXT1
103VTEXT9: POP AX
104 RET
105VTEXT ENDP
106
107
108 ASSUME DS:SV_DATA
109VCHAR PROC NEAR
110 PUSH BX
111 MOV BX, VPTR
112 CMP AL, CR
113 JE SHORT VCHAR_CR
114 CMP AL, LF
115 JE SHORT VCHAR_LF
116 CMP AL, TAB
117 JE SHORT VCHAR_TAB
118 MOV ES:[BX], AL
119 ADD BX, 2
120VCHAR_RET: MOV VPTR, BX
121 POP BX
122 RET
123
124VCHAR_CR: PUSH AX
125 PUSH DX
126 MOV AX, BX
127 XOR DX, DX
128 MOV BX, VWIDTH
129 SHL BX, 1
130 DIV BX
131 MUL BX
132 MOV BX, AX
133 POP DX
134 POP AX
135 JMP VCHAR_RET
136
137VCHAR_LF: ADD BX, VWIDTH
138 ADD BX, VWIDTH
139 JMP VCHAR_RET
140
141VCHAR_TAB: PUSH AX
142 PUSH DX
143 MOV AX, BX
144 SHR AX, 1 ; Compute character number
145 XOR DX, DX
146 DIV VWIDTH ; Compute column number (DX)
147 MOV AX, DX
148 OR AX, 8-1
149 INC AX ; Next tab position
150 SUB AX, DX ; Distance to next tab position
151 SHL AX, 1 ; Number of bytes to skip
152 ADD BX, AX ; Update pointer
153 POP DX
154 POP AX
155 JMP VCHAR_RET
156VCHAR ENDP
157
158
159 ASSUME DS:SV_DATA
160VCRLF PROC NEAR
161 PUSH AX
162 MOV AL, CR
163 CALL VCHAR
164 MOV AL, LF
165 CALL VCHAR
166 POP AX
167 RET
168VCRLF ENDP
169
170
171 ASSUME DS:SV_DATA
172VCLS PROC NEAR
173 MOV AX, VWIDTH
174 MUL VHEIGHT
175 MOV CX, AX
176 MOV AX, 0720H
177 MOV DI, 0
178 CLD
179 REP STOSW
180 MOV VPTR, 0 ; Set destination pointer
181 RET
182VCLS ENDP
183
184;
185; Return the current column number
186;
187; Out: AX Column number (0 through VWIDTH - 1)
188;
189 ASSUME DS:SV_DATA
190VGETCOL PROC NEAR
191 PUSH DX
192 MOV AX, VPTR
193 SHR AX, 1 ; Compute character number
194 XOR DX, DX
195 DIV VWIDTH ; Compute column number (DX)
196 MOV AX, DX
197 POP DX
198 RET
199VGETCOL ENDP
200
201;
202; Move to the beginning of the next line if there are less than AX
203; characters remaining on the line (don't print in the last column).
204;
205 ASSUME DS:SV_DATA
206VWRAP PROC NEAR
207 PUSH DX
208 PUSH AX
209 CALL VGETCOL
210 POP DX
211 ADD AX, DX
212 CMP AX, VWIDTH
213 JB SHORT VWRAP_1
214 CALL VCRLF
215VWRAP_1: POP DX
216 RET
217VWRAP ENDP
218
219SV_CODE ENDS
220
221
222INIT_CODE SEGMENT
223
224 ASSUME CS:INIT_CODE, DS:NOTHING
225
226;
227; Set VWIDTH and VHEIGHT
228;
229 ASSUME DS:SV_DATA
230VINIT PROC NEAR
231;
232; Get the width in character columns
233;
234 MOV AH, 0FH ; Get current video mode
235 INT 10H
236 MOV AL, AH ; Number of character columns
237 XOR AH, AH
238 MOV VWIDTH, AX
239;
240; Get the height in character rows
241;
242 MOV AH, 11H ; Get font information
243 MOV AL, 30H ; (Check for EGA or better)
244 MOV BH, 0
245 MOV CX, 1234H
246 PUSH ES
247 PUSH BP
248 INT 10H
249 POP BP
250 POP ES
251 MOV AX, 25
252 CMP CX, 1234H ; Function implemented?
253 JE SHORT VINIT_1 ; No -> old adapter (25 rows)
254 PUSH ES
255 MOV AX, 40H
256 MOV ES, AX
257 MOVZX AX, BYTE PTR ES:[84H]
258 INC AX
259 POP ES
260VINIT_1: MOV VHEIGHT, AX
261 MUL VWIDTH
262 MOVZX ECX, AX
263 SHL ECX, 1
264 LEA DI, G_VIDEO_DESC
265 CALL RM_SEG_SIZE
266 RET
267VINIT ENDP
268
269INIT_CODE ENDS
270
271 END
Note: See TracBrowser for help on using the repository browser.