source: trunk/AIR-BOOT/SOURCE/REGULAR/VIDEOIO.ASM@ 12

Last change on this file since 12 was 8, checked in by kiewitz, 23 years ago

Added AiR-BOOT Images and support for other languages.
Note: This comment was created after rebuilding the repo. [2011-07]

File size: 14.0 KB
Line 
1
2; Disclaimer:
3;=============
4; The sourcecode is released via www.netlabs.org CVS *ONLY*.
5; You MUST NOT upload it to other servers nor republish it in any way.
6; The sourcecode is still COPYRIGHTED and NOT YET RELEASED UNDER GPL.
7; It's (c) Copyright 1998-2002 by Martin Kiewitz.
8; You may recompile the source and do *PRIVATE* modifications, but please keep
9; in mind that modifying this code needs at least *some* assembly skill. If
10; you mess up your system, because you needed to hack your way through, don't
11; blame me. Releasing a customized version of AiR-BOOT, selling it in any form
12; or reusing parts of this source is *PROHIBITED*. Ask me, if you have some
13; idea about new functionality *before* developing the code, otherwise I will
14; definitely reject it. Also please accept, that I have some basic design
15; rules on AiR-BOOT and I will maintain them at all costs, so this won't get
16; another GRUB.
17
18;---------------------------------------------------------------------------
19; AiR-BOOT / VIDEO I/O
20;---------------------------------------------------------------------------
21
22VideoIO_WaitRetrace Proc Near Uses ax dx
23 mov dx, 3DAh
24 VIOWR_Jump1:
25 in al, dx
26 test al, 8
27 jnz VIOWR_Jump1
28 VIOWR_Jump2:
29 in al, dx
30 test al, 8
31 jz VIOWR_Jump2
32 ret
33VideoIO_WaitRetrace EndP
34
35; Holds the current position. Yeah, I know this is in the code area, but who
36; cares :))
37TextPosY db 0h
38TextPosX db 0h
39TextColorFore db 7h
40TextColorBack db 0h
41
42; In: CH - Cursor Column, CL - Cursor Row (Start at 1,1)
43; Destroyed: None
44VideoIO_Locate Proc Near Uses cx
45 or ch, ch
46 jz VIOL_IgnoreY
47 dec ch
48 mov TextPosY, ch
49 VIOL_IgnoreY:
50 or cl, cl
51 jz VIOL_IgnoreX
52 dec cl
53 mov TextPosX, cl
54 VIOL_IgnoreX:
55 ret
56VideoIO_Locate EndP
57
58; In: CH - Cursor Column, CL - Center Cursor Row (Start at 1,1)
59; DX - Length to use for centering
60; Destroyed: None
61VideoIO_LocateToCenter Proc Near Uses cx dx
62 shr dl, 1 ; Length / 2
63 sub cl, dl
64 call VideoIO_Locate
65 ret
66VideoIO_LocateToCenter EndP
67
68; In: CH - Color Fore, CL - Color Back
69; Destroyed: None
70VideoIO_Color Proc Near Uses cx
71 mov TextColorFore, CH
72 mov TextColorBack, CL
73 ret
74VideoIO_Color EndP
75
76VideoIO_CursorOff Proc Near Uses ax cx
77 mov ax, 0102h ; 02 for fixup on AMI BIOS
78 mov cx, 1000h
79 int 10h ; Clears cursor
80 ret
81VideoIO_CursorOff EndP
82
83VideoIO_CursorOn Proc Near Uses ax cx
84 mov ax, 0102h ; 02 for fixup on AMI BIOS
85 mov cx, 0F0Eh
86 int 10h ; Builds cursor
87 ret
88VideoIO_CursorOn EndP
89
90VideoIO_CursorSet Proc Near Uses ax bx dx
91 mov ah, 02h
92 xor bh, bh
93 mov dh, TextPosY
94 mov dl, TextPosX
95 int 10h
96 ret
97VideoIO_CursorSet EndP
98
99VideoIO_Internal_SetRegs Proc Near Uses bx
100 mov ax, VideoIO_Segment
101 mov es, ax
102 movzx ax, TextPosY
103 mov bl, 160
104 mul bl
105 xor bh, bh
106 mov bl, TextPosX
107 shl bl, 1
108 add ax, bx
109 mov di, ax ; Location at ES:DI
110 mov ah, TextColorFore
111 mov al, TextColorBack
112 shl al, 4
113 or ah, al ; Color Attribute in AH
114 ret
115VideoIO_Internal_SetRegs EndP
116
117; In: SI - String to Print (EOS is 0)
118; Destroyed: SI
119VideoIO_Print Proc Near Uses es di
120 call VideoIO_Internal_SetRegs
121 VIOP_Loop:
122 lodsb
123 or al, al
124 jz VIOP_End
125 mov es:[di], al
126 mov es:[di+1], ah
127 add di, 2
128 inc TextPosX
129 jmp VIOP_Loop
130 VIOP_End:
131 ret
132VideoIO_Print EndP
133
134; In: SI - String to Print (EOS is 0)
135; Destroyed: SI
136VideoIO_PrintLikeLenOfName Proc Near Uses es di
137 push si
138 xor cx, cx
139 VIOPLLON_Loop:
140 lodsb
141 inc cx
142 or al, al
143 jnz VIOPLLON_Loop
144 pop si
145 call GetLenOfName ; Gets the real length...tricky ;)
146 jz VIOPLLON_Nul
147 call VideoIO_FixedPrint ; we are lazy :)
148 VIOPLLON_Nul:
149 ret
150VideoIO_PrintLikeLenOfName EndP
151
152; In: SI - String to Print
153; CL - Len Of String
154; Destroyed: SI
155VideoIO_FixedPrint Proc Near Uses es di
156 or cl, cl
157 jz VIOFP_NoString
158 call VideoIO_Internal_SetRegs
159 VIOFP_Loop:
160 lodsb
161 mov es:[di], al
162 mov es:[di+1], ah
163 add di, 2
164 inc TextPosX
165 dec cl
166 jnz VIOFP_Loop
167 VIOFP_NoString:
168 ret
169VideoIO_FixedPrint EndP
170
171; In: AL - Single Char to Print
172; Destroyed: None
173VideoIO_PrintSingleChar Proc Near Uses ax es di
174 mov bl, al
175 call VideoIO_Internal_SetRegs
176 mov es:[di], bl
177 mov es:[di+1], ah
178 inc TextPosX
179 ret
180VideoIO_PrintSingleChar EndP
181
182; In: AL - Single Char to Print
183; CL - Times to print it
184; Destroyed: None
185VideoIO_PrintSingleMultiChar Proc Near Uses ax cx es di
186 or cl, cl
187 jz VIOPSMC_NoChars
188 mov bl, al
189 call VideoIO_Internal_SetRegs
190 VIOPSMC_Loop:
191 mov es:[di], bl
192 mov es:[di+1], ah
193 add di, 2
194 inc TextPosX
195 dec cl
196 jnz VIOPSMC_Loop
197 VIOPSMC_NoChars:
198 ret
199VideoIO_PrintSingleMultiChar EndP
200
201; Will print a number to screen (2 bytes t.m. 0-99)
202; In: AL - Single Byte to Print
203; Destroyed: None
204VideoIO_PrintByteNumber Proc Near Uses ax bx dx es di
205 cmp al, 99
206 ja VIOPBN_DoNotWriteAnything
207 movzx bx, al
208 call VideoIO_Internal_SetRegs
209 cmp bl, 10
210 jb VIOPBN_Lower10
211 push ax
212 movzx ax, bl
213 mov dl, 10
214 div dl
215 mov bh, al ; BH = Upper Number
216 mov bl, ah ; BL = Rest
217 pop ax
218 VIOPBN_Lower10:
219 add bh, 30h
220 add bl, 30h
221 mov es:[di], bh
222 mov es:[di+1], ah
223 mov es:[di+2], bl
224 mov es:[di+3], ah
225 VIOPBN_DoNotWriteAnything:
226 add TextPosX, 2
227 ret
228VideoIO_PrintByteNumber EndP
229
230; Will print a number to screen (dynamic bytes from 0 to 255)
231; In: AL - Single Byte to Print
232; Destroyed: None
233VideoIO_PrintByteDynamicNumber Proc Near Uses ax bx dx es di
234 xor cl, cl
235 mov bh, al
236 call VideoIO_Internal_SetRegs
237 xchg bh, ah ; Exchange backgroundcolor with Number
238 cmp ah, 10
239 jb VIOPBDN_Lower10
240 cmp ah, 100
241 jb VIOPBDN_Lower100
242 movzx ax, ah
243 mov dl, 100
244 div dl
245 add al, 30h
246 mov es:[di], al
247 mov es:[di+1], bh
248 inc TextPosX
249 add di, 2
250 VIOPBDN_Lower100:
251 movzx ax, ah
252 mov dl, 10
253 div dl
254 add al, 30h
255 mov es:[di], al
256 mov es:[di+1], bh
257 inc TextPosX
258 add di, 2
259 VIOPBDN_Lower10:
260 add ah, 30h
261 mov es:[di], ah
262 mov es:[di+1], bh
263 inc TextPosX
264 add di, 2
265 ret
266VideoIO_PrintByteDynamicNumber EndP
267
268
269; In: AL - Zeichen zum Zeichnen, CL - Wie oft
270; Destroyed: None Important
271VideoIO_Internal_MakeWinDown Proc Near Uses dx di
272 movzx dx, cl
273 mov bl, al
274 call VideoIO_Internal_SetRegs
275 mov al, bl
276 VIOIMWD_Loop:
277 mov es:[di], al
278 mov es:[di+1], ah
279 add di, 160
280 inc TextPosY
281 dec dx
282 jnz VIOIMWD_Loop
283 ret
284VideoIO_Internal_MakeWinDown EndP
285
286; In: AL - Zeichen zum Zeichnen, CL - Wie oft
287; Destroyed: None Important
288VideoIO_Internal_MakeWinRight Proc Near Uses dx di
289 movzx dx, cl
290 mov bl, al
291 call VideoIO_Internal_SetRegs
292 mov al, bl
293 VIOIMWR_Loop:
294 mov es:[di], al
295 mov es:[di+1], ah
296 add di, 2
297 inc TextPosX
298 dec dx
299 jnz VIOIMWR_Loop
300 ret
301VideoIO_Internal_MakeWinRight EndP
302
303WinBeginPosY db 0h
304WinBeginPosX db 0h
305WinEndPosY db 0h
306WinEndPosX db 0h
307WinCharRight db 0CDh
308WinCharDown db 0B3h
309WinCharBB db 0D5h
310WinCharBE db 0B8h
311WinCharEB db 0D4h
312WinCharEE db 0BEh
313
314; In: BX - Begin Position, DX - End Position
315; Destroyed: BX DX
316VideoIO_MakeWindow Proc Near Uses ax bx cx es di
317 mov WinBeginPosY, bh
318 mov WinBeginPosX, bl
319 mov WinEndPosY, dh
320 mov WinEndPosX, dl
321 mov cx, bx
322 inc ch
323 call VideoIO_Locate ; StartPos left line
324 mov cl, WinEndPosY
325 sub cl, WinBeginPosY
326 dec cl
327 mov al, WinCharDown
328 push cx
329 call VideoIO_Internal_MakeWinDown
330 mov ch, WinBeginPosY
331 mov cl, WinEndPosX
332 inc ch
333 call VideoIO_Locate ; StartPos right line
334 pop cx
335 mov al, WinCharDown
336 call VideoIO_Internal_MakeWinDown
337 ; Left & Right are already done...
338 mov ch, WinBeginPosY
339 mov cl, WinBeginPosX
340 call VideoIO_Locate ; StartPos upper line
341 mov al, WinCharBB
342 call VideoIO_PrintSingleChar
343 mov cl, WinEndPosX
344 sub cl, WinBeginPosX
345 dec cl
346 mov al, WinCharRight
347 push cx
348 call VideoIO_Internal_MakeWinRight
349 mov al, WinCharBE
350 call VideoIO_PrintSingleChar
351 mov ch, WinEndPosY
352 mov cl, WinBeginPosX
353 call VideoIO_Locate ; StartPos lower line
354 mov al, WinCharEB
355 call VideoIO_PrintSingleChar
356 pop cx
357 mov al, WinCharRight
358 call VideoIO_Internal_MakeWinRight
359 mov al, WinCharEE
360 call VideoIO_PrintSingleChar
361 ; Frame done, now just filling...
362 mov bh, WinEndPosY
363 sub bh, WinBeginPosY
364 dec bh
365 mov bl, WinEndPosX
366 sub bl, WinBeginPosX
367 dec bl
368
369 VIOIMW_Loop:
370 mov ch, WinBeginPosY
371 add ch, bh
372 mov cl, WinBeginPosX
373 inc cl
374 call VideoIO_Locate
375
376 mov al, 20h
377 mov cl, bl
378 push bx
379 call VideoIO_Internal_MakeWinRight
380 pop bx
381 dec bh
382 jnz VIOIMW_Loop
383 ret
384VideoIO_MakeWindow EndP
385
386; In: AX - Segment to copy B800 to...
387; Destroyed: BX DX
388VideoIO_BackUpTo Proc Near Uses cx ds si es di
389 mov es, ax
390 mov ax, 0B800h
391 mov ds, ax
392 xor si, si
393 xor di, di
394 mov cx, 800h ; Copy 1000h bytes
395 rep movsw
396 ret
397VideoIO_BackUpTo EndP
398
399VideoIO_RestoreFrom Proc Near Uses cx ds si es di
400 mov ds, ax
401 mov ax, 0B800h
402 mov es, ax
403 xor si, si
404 xor di, di
405 mov cx, 800h ; Copy 1000h bytes
406 rep movsw
407 ret
408VideoIO_RestoreFrom EndP
409
410; In: CL - Total Length of String
411; DS:SI - Actual String
412; Out: Carry Set if String was ENTERd
413; Destroyed: *none*
414VideoIO_LetUserEditString Proc Near Uses ax bx cx dx si es di
415 local StartPosX:byte, LastPosX:byte
416 local StringLen:byte
417
418 or cl, cl
419 jnz VIOLUES_LenNotNUL
420 clc
421 ret
422
423 VIOLUES_LenNotNUL:
424 mov al, TextPosX
425 inc al
426 mov StartPosX, al
427 mov StringLen, cl
428
429 push cx
430 call VideoIO_Internal_SetRegs ; ES:DI - Pos on Screen at Start
431
432 xor ch, ch
433 call GetLenOfName ; CX - Actual Length of String
434 mov dl, cl
435
436 ; Set Cursor behind String and turn it on...
437 add cl, StartPosX
438 call VideoIO_Locate
439 call VideoIO_CursorSet
440 call VideoIO_CursorOn ; Set and turn cursor on
441
442 ; ES:DI - Screen-Position to Start of String
443 ; DL - Position in String (relative to begin, base=0)
444
445 VIOLUES_Loop:
446 mov ah, 0
447 int 16h
448 cmp ah, Keys_ESC
449 je VIOLUES_KeyESC
450 cmp ah, Keys_Enter
451 je VIOLUES_KeyENTER
452 cmp ah, Keys_Backspace
453 je VIOLUES_KeyBACKSPACE
454 ; Check for valid char...
455 cmp al, 32
456 jb VIOLUES_Loop
457 cmp al, 166
458 ja VIOLUES_Loop
459 ; Okay, Character to add to string
460 cmp dl, StringLen ; String "full" ?
461 jae VIOLUES_Loop
462 movzx bx, dl
463 shl bx, 1
464 mov es:[di+bx], al
465 inc dl
466 VIOLUES_UpdateCursor:
467 mov cl, dl
468 add cl, StartPosX
469 call VideoIO_Locate
470 call VideoIO_CursorSet
471 jmp VIOLUES_Loop
472
473 VIOLUES_KeyBACKSPACE:
474 or dl, dl ; String "empty" ?
475 jz VIOLUES_Loop
476 mov al, ' '
477 dec dl
478 movzx bx, dl
479 shl bx, 1
480 mov es:[di+bx], al
481 jmp VIOLUES_UpdateCursor
482
483 VIOLUES_KeyESC:
484 pop cx
485 call VideoIO_CursorOff ; Bye Bye cursor
486 clc
487 ret
488
489 VIOLUES_KeyENTER:
490 pop cx
491 ; ENTERd, so copy data to String-Pointer...
492 VIOLUES_CopyLoop:
493 mov al, es:[di]
494 add di, 2
495 mov ds:[si], al
496 inc si
497 dec cl
498 jnz VIOLUES_CopyLoop
499 ; Finally Cursor off-line...
500 call VideoIO_CursorOff
501 stc
502 ret
503VideoIO_LetUserEditString EndP
Note: See TracBrowser for help on using the repository browser.