1 ; MMURTL Operating System Source Code
\r
2 ; Copyright 1991,1992,1993,1994 Richard A. Burgess
\r
3 ; ALL RIGHTS RESERVED
\r
6 ;This module contains ALL Video code & Data
\r
7 ; (along with EdLine for lack of a better place)
\r
9 ;This module supports MMURTL's Virtual Text Video.
\r
10 ;All video calls are based on the video information in the job's
\r
13 ;Virtual video buffers allow a job to output data even when it is
\r
14 ;not assigned to the real video display buffer.
\r
16 ;The call SetVidOwner is the key. It swaps virtual buffers for the real one
\r
17 ;and changes the current pointer in that job's JCB. It also updates
\r
18 ;the cursor in the correct place on entry.
\r
20 ; The following calls are implemented here:
\r
22 ;------------------------------
\r
23 ;GetVidOwner(pdJobNumRet)
\r
24 ; Desc: This returns the Job Number that currently has active video
\r
26 ;------------------------------
\r
27 ;SetVidOwner(ddJobNum)
\r
28 ; Desc: This selects the screen that you see. This call is used
\r
29 ; by the monitor in conjunction with the SetKbdOwner call to change
\r
30 ; who gets the keystrokes and video (should be the same app).
\r
31 ; The internal debugger is the only code that will use this call
\r
32 ; and not move the keyboard also. It has it's own keyboard code
\r
33 ; (else how could it debug the real keyboard code??)
\r
35 ; ddJobNum is the new Job to get the active screen
\r
36 ; (the one to be displayed)
\r
37 ;------------------------------
\r
39 ; Desc: This selects the normal background attribute and fill char
\r
40 ; used by ClrScr and ScrollVid on the screen.
\r
42 ; dCharAttr is the Character and aAttr values used in
\r
43 ; standard video operation on the current screen
\r
45 ;------------------------------
\r
46 ;GetNormVid(pVidRet)
\r
48 ; Desc: This returns the value the normal screen attribute
\r
49 ; used by ClrScr and ScrollVid on the screen.
\r
52 ; pVidRet points to the character where you want the NormVid
\r
53 ; attribute returned.
\r
55 ;------------------------------
\r
59 ; This clears the screen for the executing job. It may or may not
\r
60 ; be the one you are viewing...
\r
62 ;------------------------------
\r
63 ;TTYOut (pTextOut, ddTextOut, ddAttrib)
\r
65 ; Desc: This places characters on the screen in a TTY fashion at the
\r
66 ; X & Y coordinates that are in effect for that screen.
\r
67 ; The following characters in the stream are interpreted as follows:
\r
70 ; The cursor (next active character placement) will be on the
\r
71 ; following line at column 0. If this line is below the bottom
\r
72 ; of the screen, the entire screen will be scrolled up on line,
\r
73 ; the bottom line will be blanked, and the cursor will be placed
\r
74 ; on the last line in the first column.
\r
75 ; 0D Carriage Return
\r
76 ; The Cursor will be moved to column zero on the current line.
\r
77 ; 08 BackSpace - The cursor will be moved one column to the left.
\r
78 ; If already at column 0, Backspace will have no effect.
\r
79 ; The backspace is non-destructive (no chars are changed)
\r
81 ; pTextOut is a NEAR Ptr to the text.
\r
82 ; ddTextOut is the number of chars of text.
\r
83 ; ddAttrib is the attribute/Color you want.
\r
85 ;------------------------------
\r
86 ;PutVidChars(ddCol,ddLine,pChars,sChars,ddAttrib)
\r
88 ; Desc: This places characters on the screen without affecting
\r
89 ; the current TTY coordinates or the TTY data. It is independent
\r
90 ; of the current video "Stream."
\r
93 ; ddCol is the column to start on (0-79)
\r
94 ; ddLine is the line (0-24)
\r
95 ; pChars is a pointer the text to be displayed
\r
96 ; sChars is the number of chars
\r
97 ; ddAtrib is the color/attribute to use during display
\r
98 ; which applies to all of the characters on this
\r
99 ; call to PutVidChars.
\r
100 ;------------------------------
\r
101 ;GetVidChar(ddCol,ddLine,pCharRet,pAttrRet)
\r
103 ; Desc: This returns the current character and attribute
\r
104 ; from the screen coordinates you specify.
\r
107 ; ddCol is the column to start on (0-79)
\r
108 ; ddLine is the line (0-24)
\r
109 ; pCharRet is a pointer where you want the character returned
\r
110 ; pAttrRet is a pointer where you want the attribute returned
\r
111 ;------------------------------
\r
112 ;PutVidAttrs(ddCol,ddLine,sChars,dAttr)
\r
114 ; Desc: This sets screen colors (attrs) for the without affecting
\r
115 ; the current TTY coordinates or the character data. It is independent
\r
116 ; of the current video "Stream."
\r
119 ; ddCol is the column to start on (0-79)
\r
120 ; ddLine is the line (0-24)
\r
121 ; sChars is the number of char spaces to place dAttr
\r
122 ; dAttr is the color/attribute to fill the character spaces with
\r
124 ;------------------------------
\r
125 ;ScrollVid(ddULCol,ddULline,nddCols,nddLines, ddfUp)
\r
127 ; Desc: This scrolls the described square area on the screen either
\r
128 ; UP or DOWN one line. If ddfUp is NON-ZERO the scroll will be UP.
\r
129 ; The line left blank is filled with NormAttr from JCB.
\r
131 ; ddULCol is the UPERR LEFT column to start on (0-79)
\r
132 ; ddULLine is the UPPER LEFT line (0-24)
\r
133 ; nddCols is the number of columns to be scrolled.
\r
134 ; nddLines is the count of lines to be scrolled.
\r
135 ; ddfUp is NON-ZERO to cause the scroll to be up (vise down).
\r
137 ; If you want to scroll the entire screen UP one line, the
\r
138 ; params would be ScrollVid(VidNum, 0,0,80,25,1).
\r
139 ; In this case the top line is lost (not really scrolled),
\r
140 ; and the bottom line would be blanked. Infact, if you specified
\r
141 ; (Vidnum, 0,1,80,24,1) you would get the same results.
\r
143 ;------------------------------
\r
145 ; Desc: Position VGA cursor (Text mode) to the X & Y position.
\r
148 ; NewX is the new horizontal cursor postion
\r
149 ; NewY is the new vertical cursor position
\r
151 ;------------------------------
\r
152 ;GetXY(pXRet,pYRet)
\r
153 ; Desc: Returns the current X & Y position for your job.
\r
156 ; pXRet is a ptr where you want the current horizontal cursor postion
\r
157 ; pYRet is a ptr where you want the current vertical cursor position
\r
160 .INCLUDE MOSEDF.INC
\r
163 ;This is the data for the virtual character video service.
\r
164 ;The video code is fully reentrant because each job has it's own
\r
165 ;video screen. Only one of these screens will be the active video
\r
168 ;Video Equates and Types
\r
170 CRTCPort1 EQU 03D4h ;Index port for CRTC
\r
171 CRTCPort2 EQU 03D5h ;Data port for CRTC
\r
172 CRTCAddHi EQU 0Ch ;Register for lo byte of Video address
\r
173 CRTCAddLo EQU 0Dh ;Register for lo byte of Video address
\r
174 CRTCCurHi EQU 0Eh ;Register for lo byte of Cursor address
\r
175 CRTCCurLo EQU 0Fh ;Register for lo byte of Cursor address
\r
176 CRTC0C DB 0 ;CRT Reg 0C HiByte address value
\r
177 CRTC0D DB 0 ;CRT Reg 0D LoByte address value
\r
179 PUBLIC ddVidOwner DD 1 ;JCB that currently owns video
\r
180 ;Default to monitor (Job 1)
\r
182 ;End of Data & Equates
\r
184 ;============================================================================
\r
185 ; BEGIN INTERNAL CODE FOR VIDEO
\r
186 ;============================================================================
\r
191 EXTRN GetpCrntJCB NEAR
\r
192 EXTRN ReadDbgKbd NEAR
\r
193 EXTRN GetCrntJobNum NEAR
\r
195 ;InitVideo makes Video Screen 0 the default screen. That
\r
196 ;makes the VGATextBase address 0B8000h
\r
199 MOV AL, CRTCAddHi ;Index of hi byte
\r
200 MOV DX, CRTCPort1 ;Index Port
\r
202 MOV AL, CRTC0C ;hi byte value to send
\r
203 MOV DX, CRTCPort2 ;Data Port
\r
206 MOV AL, CRTCAddLo ;Index of lo byte
\r
207 MOV DX, CRTCPort1 ;Index Port
\r
209 MOV AL, CRTC0D ;lo byte value to send
\r
210 MOV DX, CRTCPort2 ;Data Port
\r
214 ;============================================================================
\r
215 ; BEGIN PUBLIC CODE FOR VIDEO
\r
216 ;============================================================================
\r
218 ;============================================================================
\r
219 ; SetVidOwner - Make a new a screen actively displayed.
\r
220 ; EAX Returns NON-Zero if JOB number is invalid
\r
222 ddJobVidCV EQU DWORD PTR [EBP+12]
\r
224 PUBLIC __SetVidOwner:
\r
227 MOV EAX, ddJobVidCV ;
\r
228 CMP EAX, ddVidOwner ;Already own it?
\r
233 CALL GetpJCB ;Leaves ptr to new vid JCB in EAX
\r
234 CMP DWORD PTR [EAX+pVidMem] ,0 ;Got valid video memory???
\r
236 MOV EAX, ErcVidNum ;NO! Give em an error!
\r
239 ;Save data on screen to CURRENT job's pVirtVid
\r
240 MOV EAX, ddVidOwner
\r
242 PUSH VGATextBase ;Source
\r
243 MOV EBX, [EAX+pVirtVid] ;Destination
\r
245 PUSH 4000 ;Size of video
\r
246 CALL FWORD PTR _CopyData ;Do it!
\r
248 ;Make pVidMem same as pVirtVid for CURRENT OWNER
\r
249 MOV EAX, ddVidOwner
\r
250 CALL GetpJCB ;Leaves ptr to new vid JCB in EAX
\r
251 MOV EBX, [EAX+pVirtVid]
\r
252 MOV [EAX+pVidMem], EBX
\r
254 ;Update current video owner to NEW owner
\r
256 MOV EAX, ddJobVidCV ;
\r
257 MOV ddVidOwner, EAX
\r
259 ;Copy in Data from new pVirtVid
\r
261 MOV EAX, ddVidOwner
\r
263 MOV EBX, [EAX+pVirtVid] ;Source
\r
265 PUSH VGATextBase ;Destination
\r
266 PUSH 4000 ;Size of video
\r
267 CALL FWORD PTR _CopyData ;Do it!
\r
269 ;Make new pVidMem real video screen for new owner
\r
271 MOV EAX, ddVidOwner
\r
273 MOV EBX, VGATextBase
\r
274 MOV [EAX+pVidMem], EBX
\r
276 ;Set Cursor position
\r
278 MOV EAX, ddVidOwner
\r
281 MOV EBX, [ECX+CrntX] ;Get current X for new screen
\r
282 MOV EAX, [EBX+CrntY] ;Current Y
\r
283 CALL HardXY ;Set it up
\r
284 XOR EAX, EAX ;No Error
\r
290 ;============================================================================
\r
291 ; SetNormVid - Sets the normal video attribute (color) used in
\r
292 ; ClrScr, EditLine, and ScrollVid.
\r
293 ; EAX Returns Zero (No Error)
\r
295 ddNormVid EQU DWORD PTR [EBP+12]
\r
297 PUBLIC __SetNormVid:
\r
300 CALL GetpCrntJCB ;pJCB -> EAX
\r
301 MOV EBX, ddNormVid ;
\r
302 MOV [EAX+NormAttr], EBX ;
\r
307 ;============================================================================
\r
308 ; GetNormVid - Returns the normal video attribute (color) used in
\r
309 ; ClrScr, EditLine, and ScrollVid.
\r
310 ; EAX Returns Zero (No Error)
\r
312 pdNormVidRet EQU DWORD PTR [EBP+12]
\r
314 PUBLIC __GetNormVid:
\r
317 CALL GetpCrntJCB ;pJCB -> EAX
\r
318 MOV EBX, [EAX+NormAttr] ;
\r
319 MOV ESI, pdNormVidRet ;
\r
325 ;============================================================================
\r
326 ; GetVidOwner - Returns the Job number of current active video
\r
327 ; number to the caller.
\r
328 ;=============================================================================
\r
330 pVidNumRet EQU DWORD PTR [EBP+12]
\r
332 PUBLIC __GetVidOwner:
\r
335 MOV ESI, pVidNumRet ;
\r
336 MOV EAX, ddVidOwner ;
\r
338 XOR EAX, EAX ; no error obviously
\r
343 ;=============================================================================
\r
344 ; Clear caller's video screen (Use Space and Attr from JCB NormAttr)
\r
345 ;=============================================================================
\r
350 CALL GetpCrntJCB ;Leaves ptr to current JCB in EAX
\r
352 MOV EDI,[EBX+pVidMem] ;EDI points to his video memory
\r
353 MOV EAX, [EBX+NormAttr] ;Attr
\r
358 MOV AX, DX ;Fill Char & Attr
\r
364 CALL FWORD PTR _SetXY ;Erc in EAX on Return
\r
369 ;=============================================================================
\r
371 ;=============================================================================
\r
373 pTextOut EQU DWORD PTR [EBP+20]
\r
374 sTextOut EQU DWORD PTR [EBP+16]
\r
375 dAttrText EQU DWORD PTR [EBP+12]
\r
377 DataByte EQU BYTE PTR [ECX]
\r
382 CALL GetpCrntJCB ;Leaves ptr to current JCB in EAX
\r
384 MOV EAX, sTextOut ;make sure count isn't null
\r
389 MOV EAX,[EBX+CrntX] ; EAX has CrntX (col)
\r
390 MOV EDX,[EBX+CrntY] ; EDX has CrntY (line)
\r
393 CMP DataByte,0Ah ; LF?
\r
396 CMP EDX,[EBX+nLines] ; Equal to or past the bottom?
\r
398 JMP TTYScr ; Yes, goto scroll
\r
400 CMP DataByte,0Dh ; CR?
\r
405 CMP DataByte,08h ; BackSpace?
\r
412 PUSH EBX ;Save pointer to VCB
\r
414 PUSH EAX ;X (Param 1)
\r
415 PUSH EDX ;Y (Param 2)
\r
416 PUSH ECX ;pointer to text char (Param3)
\r
417 PUSH 1 ;Param 4 (nchars)
\r
418 MOV ECX,dAttrText ;
\r
420 CALL FWORD PTR _PutVidChars ;
\r
421 POP EBX ;restore ptr to VCB
\r
424 MOV EAX, [EBX+CrntX]
\r
425 MOV EDX, [EBX+CrntY]
\r
426 INC EAX ;Next column
\r
427 CMP EAX,[EBX+nCols]
\r
428 JNE TTY06 ;Make cursor follow
\r
431 CMP EDX,[EBX+nLines] ; past the bottom?
\r
432 JNE TTY06 ; No - goto 06 else fall thru
\r
435 DEC EDX ; back up one line
\r
436 PUSH EAX ;Save registers (scroll eats em)
\r
445 PUSH 1 ;fUP (non zero)
\r
446 CALL FWORD PTR _ScrollVid ;Ignore error
\r
447 POP EDX ;restore registers
\r
450 POP EAX ;Fall thru to
\r
453 PUSH EBX ;save ptr to pJCB
\r
457 CALL FWORD PTR _SetXY
\r
459 POP EBX ;Restore ptr to VCB
\r
465 JMP TTY00 ; Go back for next char
\r
473 ;=============================================================================
\r
475 ; Desc: This sets screen colors (attrs) for the without affecting
\r
476 ; the current TTY coordinates or the character data. It is independent
\r
477 ; of the current video "Stream."
\r
480 ; ddCol is the column to start on (0-79)
\r
481 ; ddLine is the line (0-24)
\r
482 ; sChars is the number of char spaces to place dAttr
\r
483 ; dAttr is the color/attribute to fill the character spaces with
\r
485 ; Start Position in screen memory is (Line * 80 + (Column*2))
\r
486 ; pass Char, then Color, pass char, then color etc... DO NOT EXCEED 2000!
\r
487 ; Needs to be fixed to tell if ECX + sDDChars will go off screen...
\r
489 ;=============================================================================
\r
491 oADDX EQU DWORD PTR [EBP+24] ;Param 1 COLUMN
\r
492 oADDY EQU DWORD PTR [EBP+20] ;Param 2 LINE
\r
493 sADDChars EQU DWORD PTR [EBP+16] ;Param 3 sChars
\r
494 sADDColor EQU DWORD PTR [EBP+12] ;Param 4 Attr
\r
496 PUBLIC __PutVidAttrs:
\r
500 CALL GetpCrntJCB ;Leaves ptr to current JCB in EAX
\r
503 MOV EDI, [EBX+pVidMem] ;point to this VCBs video memory
\r
504 MOV EBX,oADDx ;x Position
\r
506 MOV EAX,oADDy ;y Position
\r
507 MOV ECX,0A0h ;Times 160 (char/attrs per line)
\r
508 MUL ECX ;Times nColumns
\r
510 CMP EAX,0F9Eh ;Last legal posn on screen
\r
512 MOV EAX, ErcVidParam
\r
522 INC EDI ;Pass the char value
\r
523 STOSB ;Move Color in
\r
525 XOR EAX, EAX ;No Error!
\r
531 ;=============================================================================
\r
533 ; This Places characters on the VGA Character Screen in the XY Coords
\r
535 ; 1) DD X (Column 0-79)
\r
536 ; 2) DD Y (Line 0-24)
\r
537 ; 3) DD Near Ptr (relative to DS) of string
\r
538 ; 4) DD Size of String
\r
539 ; 5) DD (of which the low order byte is the Color)
\r
541 ; Start Position in screen memory is (Line * 80 + (Column*2))
\r
542 ; Put Char, then Color, then char, then color etc... DO NOT EXCEED 2000!
\r
543 ; Needs to be fixed to tell if ECX + sDDChars will go off screen...
\r
545 ;=============================================================================
\r
547 oDDX EQU DWORD PTR [EBP+28] ;Param 1 COLUMN
\r
548 oDDY EQU DWORD PTR [EBP+24] ;Param 2 LINE
\r
549 pDDChars EQU DWORD PTR [EBP+20] ;Param 3 pChars
\r
550 sDDChars EQU DWORD PTR [EBP+16] ;Param 4 sChars
\r
551 sDDColor EQU DWORD PTR [EBP+12] ;Param 5 Attr
\r
553 PUBLIC __PutVidChars:
\r
557 CALL GetpCrntJCB ;Leaves ptr to current JCB in EAX
\r
559 MOV EDI, [EBX+pVidMem] ;point to this VCBs video memory
\r
564 MOV ECX,0A0h ;Times 160
\r
565 MUL ECX ;Times nColumns
\r
567 CMP EAX,0F9Eh ;Last legal posn on screen
\r
569 MOV EAX, ErcVidParam
\r
580 MOVSB ;Move Char in
\r
581 STOSB ;Move Color in
\r
583 XOR EAX, EAX ;No Error!
\r
589 ;=============================================================================
\r
590 ;GetVidChar(ddCol,ddLine,pCharRet,pAttrRet)
\r
592 ; Desc: This returns the current character and attribute
\r
593 ; from the screen coordinates you specify.
\r
596 ; ddCol is the column to start on (0-79)
\r
597 ; ddLine is the line (0-24)
\r
598 ; pCharRet is a pointer where you want the character returned
\r
599 ; pAttrRet is a pointer where you want the attribute returned
\r
602 oGDDX EQU DWORD PTR [EBP+24] ;Param 1 COLUMN
\r
603 oGDDY EQU DWORD PTR [EBP+20] ;Param 2 LINE
\r
604 pGDDCRet EQU DWORD PTR [EBP+16] ;Param 3 pCharRet
\r
605 pGDDARet EQU DWORD PTR [EBP+12] ;Param 4 pAttrRet
\r
607 PUBLIC __GetVidChar:
\r
610 CALL GetpCrntJCB ;Leaves ptr to current JCB in EAX
\r
613 MOV EDI, [EBX+pVidMem] ;point to this VCBs video memory
\r
617 MOV ECX,0A0h ;Times 160
\r
618 MUL ECX ;Times nColumns
\r
620 CMP EAX,0F9Eh ;Last legal posn on screen
\r
622 MOV EAX, ErcVidParam
\r
625 ADD EDI,EAX ;EDI now points to char
\r
628 MOV [ESI], AL ;Give them the char
\r
629 INC EDI ;Move to Attr
\r
632 MOV [ESI], AL ;Give them the Attr
\r
633 XOR EAX, EAX ;No Error!
\r
638 ;=============================================================================
\r
640 ; This scrolls the defined area up or down one line.
\r
642 ; 1) Upper Left column X (Column 0-79)
\r
643 ; 2) Upper Left line Y (Line 0-24)
\r
644 ; 3) nCols to scroll
\r
645 ; 4) nLines to scroll
\r
646 ; 5) TRUE for up (any NON zero QUAD)
\r
648 ; We check all params for validity. ErcVidParam is returned if one is
\r
650 ;=============================================================================
\r
652 oULX EQU DWORD PTR [EBP+28] ;Param 1 COLUMN
\r
653 oULY EQU DWORD PTR [EBP+24] ;Param 2 LINE
\r
654 nddCols EQU DWORD PTR [EBP+20] ;Param 3 Number of columns
\r
655 nddLines EQU DWORD PTR [EBP+16] ;Param 4 Number of Lines
\r
656 ddfUP EQU DWORD PTR [EBP+12] ;Param 5 Attr
\r
658 PUBLIC __ScrollVid:
\r
661 CALL GetpCrntJCB ;Leaves ptr to current JCB in EAX
\r
662 MOV EBX, EAX ;Save pJCB & use in EBX
\r
676 CMP ddfUP, 0 ;Scroll UP?
\r
677 JNE svUP0 ;Yes... Scroll UP!
\r
679 ;Scroll DOWN begins
\r
681 MOV EAX, oULY ;First line
\r
682 ADD EAX, nddLines ;Last line
\r
684 MUL ECX ;times nBytes per line
\r
685 MOV EDI, [EBX+pVidMem] ;EDI points to video memory 0,0
\r
686 MOV EDX, EBX ;Save pJCB
\r
687 ADD EDI, EAX ;EDI is ptr to 1st dest line
\r
688 ADD EDI, oULX ;offset into line
\r
689 ADD EDI, oULX ;add again for attributes
\r
691 SUB ESI, 160 ;ESI is 1st source line
\r
692 MOV EBX, ESI ;Save in EBX for reload
\r
693 MOV EAX, nDDLines ;How many lines to move
\r
694 DEC EAX ;one less than window height
\r
696 MOV ECX, nddCols ;How many WORDS per line to move
\r
697 REP MOVSW ;Move a line (of WORDS!)
\r
698 MOV EDI, EBX ;Reload Dest to next line
\r
701 MOV EBX, ESI ;Save again
\r
704 MOV EAX, [EDX+NormAttr] ;Normal video attributes!!!
\r
707 MOV EDI, EBX ;Put the last line into EDI
\r
711 XOR EAX, EAX ;No error
\r
713 ;No... scroll down begins
\r
715 MOV EAX, oULY ;First line
\r
717 MUL ECX ;times nBytes per line
\r
718 MOV EDI, [EBX+pVidMem] ;EDI points to video memory 0,0
\r
719 MOV EDX, EBX ;Save pJCB
\r
720 ADD EDI, EAX ;EDI is ptr to 1st dest line
\r
721 ADD EDI, oULX ;offset into line
\r
722 ADD EDI, oULX ;add again for attributes
\r
724 ADD ESI, 160 ;ESI is 1st source line
\r
725 MOV EBX, ESI ;Save in EBX for reload
\r
726 MOV EAX, nDDLines ;How many lines to move
\r
727 DEC EAX ;two less than window height
\r
729 MOV ECX, nddCols ;How many WORDS per line to move
\r
730 REP MOVSW ;Move a line (of WORDS!)
\r
731 MOV EDI, EBX ;Reload Dest to next line
\r
734 MOV EBX, ESI ;Save again
\r
737 MOV EAX, [EDX+NormAttr] ;Normal video attributes!!!
\r
740 MOV EDI, EBX ;Put the last line into EDI
\r
745 XOR EAX, EAX ;No error
\r
747 svErcExit: ;Error exits will jump here
\r
748 MOV EAX, ErcVidParam
\r
754 ;=============================================================
\r
755 ; HardXY - Intenal Internal to support SetXY and SetVidOwner
\r
756 ; This sets the hardware cursor position
\r
758 ; EAX : New Y position
\r
759 ; EBX : New X position
\r
761 ; EAX, EBX, EDX, Flags
\r
767 MUL ECX ; Line * 80
\r
768 ADD EAX,EBX ; Line plus column
\r
769 MOV DX,CRTCPort1 ; Index register
\r
772 OUT DX,AL ; Index 0Fh for low byte
\r
774 MOV DX,CRTCPort2 ; Data register
\r
775 OUT DX,AL ; Send Low byte out
\r
776 SHR EAX,08 ; shift hi byte into AL
\r
780 OUT DX,AL ; Index for High byte
\r
783 OUT DX,AL ; Send High byte out
\r
786 ;=============================================================================
\r
788 ; Position VGA cursor (Text mode) to the X & Y position.
\r
789 ; Also sets hardware CrntX and CrntY cursor position if
\r
790 ; crnt job is assigned the real screen
\r
791 ;=============================================================================
\r
793 NewX EQU DWORD PTR [EBP+16]
\r
794 NewY EQU DWORD PTR [EBP+12]
\r
799 CALL GetpCrntJCB ;Leaves ptr to current JCB in EAX
\r
802 MOV ECX,NewX ; Column
\r
803 MOV EDX,NewY ; Line
\r
804 MOV [EBX+CrntX],ECX ; This saves it in the VCB
\r
805 MOV [EBX+CrntY],EDX ;
\r
807 CALL GetCrntJobNum ;Leaves ptr to current JCB in EAX
\r
808 CMP EAX, ddVidOwner
\r
809 JNE GotoXYDone ;If not on Active screen, skip it
\r
811 MOV EAX,NewY ;Setup to call HardXY
\r
815 XOR EAX,EAX ;No Error
\r
820 ;=============================================================================
\r
822 ; Returns position of VGA cursor (Text mode X & Y position).
\r
823 ; This appliies to the values for the caller's VCB
\r
824 ;=============================================================================
\r
826 pXret EQU DWORD PTR [EBP+16]
\r
827 pYret EQU DWORD PTR [EBP+12]
\r
832 CALL GetpCrntJCB ;Leaves ptr to current JCB in EAX
\r
835 MOV EAX,[EBX+CrntX] ; Column
\r
838 MOV EAX,[EBX+CrntY] ; Line
\r
848 ;=============================================================================
\r
850 ; Reads a line of text from the keyboard and puts it into the
\r
851 ; specified string with full line editing features.
\r
853 ; EditLine(pStr, dCrntLen, dMaxLen, pdLenRet, pbExitChar): dError
\r
855 ; Param 1 is a NEAR Ptr to string to be edited
\r
856 ; Param 2 is current length of string to edit (80 Max)
\r
857 ; Param 3 is the max length the string can be (80 Max)
\r
858 ; Param 4 is a NEAR Ptr to a DD where the length of the string is returned
\r
859 ; Param 5 is a pointer to a Byte where the exit key from the edit
\r
860 ; operation is returned.
\r
861 ; Param 6 is the editing attribute to use.
\r
863 ; Display and keyboard are handled entirely inside EditLine.
\r
864 ; The following keys are recognized and handled inside, any other key
\r
865 ; causes Editline to exit returning the string in it's current condition
\r
866 ; and returning the key that caused the exit to pKeyRet:
\r
868 ; 08 (Backspace) move cursor to left replacing char with 20h
\r
869 ; which is a destructive backspace
\r
870 ; 20-7E Hex places character in current position and advances position
\r
872 ; Any other keystroke causes the edit line routine to be exited
\r
873 ; with that keystroke returned to pExitKeyRet
\r
876 ;=============================================================================
\r
878 pEdString EQU DWORD PTR [EBP+32]
\r
879 ddSzCrnt EQU DWORD PTR [EBP+28]
\r
880 ddSzMax EQU DWORD PTR [EBP+24]
\r
881 pddSzRet EQU DWORD PTR [EBP+20]
\r
882 pExitKeyRet EQU DWORD PTR [EBP+16]
\r
883 dEditAttr EQU DWORD PTR [EBP+12]
\r
885 ;Local vars EditX and EditY hold position of first char of text
\r
886 ;CrntX is the cursor postion
\r
888 PosnX EQU DWORD PTR [EBP-04]
\r
889 EditX EQU DWORD PTR [EBP-08]
\r
890 EditY EQU DWORD PTR [EBP-12]
\r
891 KeyCode EQU DWORD PTR [EBP-16]
\r
898 CMP ddSzCrnt, 80 ;Is it currently too long?
\r
900 CMP ddSzMax, 80 ;Is Max len to long?
\r
903 CMP EAX, ddSzMax ;Is Crnt len > Max???
\r
906 LEA EAX, EditX ;Get current cursor posns in local vars
\r
910 CALL FWORD PTR _GetXY
\r
912 JNE EditDone ;Bad Erc from call
\r
916 MOV PosnX, EAX ;make PosnX end of string
\r
919 SUB ECX, ddSzCrnt ;ECX how many bytes to zero
\r
920 JZ EdLn01 ;None to zero out
\r
921 MOV ESI, pEdString ;Initialize currrent string
\r
922 ADD ESI, ddSzCrnt ;ESI ptr to 1st empty byte
\r
923 MOV AL, 20h ;fill with spaces
\r
932 CALL FWORD PTR _SetXY
\r
937 PUSH EditX ;Display current string
\r
941 PUSH dEditAttr ;Attribute they selected
\r
942 CALL FWORD PTR _PutVidChars
\r
948 CMP ddVidOwner, 2 ;Debugger???
\r
950 PUSH 1 ;Wait for a key
\r
951 CALL FWORD PTR _ReadKbd ;Get a key
\r
960 CMP EAX, 08h ;BackSpace?
\r
961 JNE EdLn04 ;No - Next test
\r
969 MOV BYTE PTR [ESI+ECX], 20h
\r
971 EdLn04: CMP EAX, 03h ;Left?
\r
972 JNE EdLn045 ;No - Next test
\r
975 CMP EAX, 83h ;Num-Left?
\r
976 JNE EdLn046 ;No - Next test
\r
980 JNE EdLn05 ;No - Next test
\r
982 EdLn05: CMP EAX, 1Bh ;Escape?
\r
983 JNE EdLn06 ;No - Next test
\r
986 CMP EAX, 7Eh ;Is it above text?
\r
987 JA EdLn07 ;Yes, Exit!
\r
988 CMP EAX, 20h ;Is it below text??
\r
989 JB EdLn07 ;Yes, Exit
\r
990 MOV ESI, pEdString ;It's really a char!
\r
992 MOV BYTE PTR [ESI+ECX], AL
\r
1000 MOV ESI,pExitKeyRet
\r
1006 PUSH EditX ;Display current string w/Norm Attrs
\r
1010 CALL GetpCrntJCB ;Leaves ptr to current JCB in EAX
\r
1011 MOV EBX, [EAX+NormAttr]
\r
1012 PUSH EBX ;Normal Attribute from JCB
\r
1013 CALL FWORD PTR _PutVidChars ;Ignore error (we are leaving anyway)
\r
1017 MOV EAX, ErcEditParam
\r
1023 ;===================== END OF MODULE ================
\r