OSDN Git Service

got 8086 port of wolf3d to work and sod to work
[proj16/16.git] / 16 / WOLFSRC / ID_VL_A.ASM
1 ; ID_VL.ASM\r
2 \r
3         IDEAL\r
4         MODEL   MEDIUM,C\r
5 \r
6         INCLUDE 'ID_VL.EQU'\r
7 \r
8 SCREENSEG       =       0a000h\r
9 \r
10         DATASEG\r
11 \r
12         EXTRN   TimeCount:WORD          ; incremented every 70th of a second\r
13         EXTRN   linewidth:WORD\r
14 \r
15 starttime       dw      ?\r
16 \r
17         CODESEG\r
18 \r
19 ;===========================================================================\r
20 \r
21 \r
22 ;==============\r
23 ;\r
24 ; VL_WaitVBL                    ******** NEW *********\r
25 ;\r
26 ; Wait for the vertical retrace (returns before the actual vertical sync)\r
27 ;\r
28 ;==============\r
29 \r
30 PROC    VL_WaitVBL  num:WORD\r
31 PUBLIC  VL_WaitVBL\r
32 @@wait:\r
33 \r
34         mov     dx,STATUS_REGISTER_1\r
35 \r
36         mov     cx,[num]\r
37 ;\r
38 ; wait for a display signal to make sure the raster isn't in the middle\r
39 ; of a sync\r
40 ;\r
41 @@waitnosync:\r
42         in      al,dx\r
43         test    al,8\r
44         jnz     @@waitnosync\r
45 \r
46 \r
47 @@waitsync:\r
48         in      al,dx\r
49         test    al,8\r
50         jz      @@waitsync\r
51 \r
52         loop    @@waitnosync\r
53 \r
54         ret\r
55 \r
56 ENDP\r
57 \r
58 \r
59 ;===========================================================================\r
60 \r
61 ;==============\r
62 ;\r
63 ; VL_SetCRTC\r
64 ;\r
65 ;==============\r
66 \r
67 PROC    VL_SetCRTC  crtc:WORD\r
68 PUBLIC  VL_SetCRTC\r
69 \r
70 ;\r
71 ; wait for a display signal to make sure the raster isn't in the middle\r
72 ; of a sync\r
73 ;\r
74         cli\r
75 \r
76         mov     dx,STATUS_REGISTER_1\r
77 \r
78 @@waitdisplay:\r
79         in      al,dx\r
80         test    al,1    ;1 = display is disabled (HBL / VBL)\r
81         jnz     @@waitdisplay\r
82 \r
83 \r
84 ;\r
85 ; set CRTC start\r
86 ;\r
87 ; for some reason, my XT's EGA card doesn't like word outs to the CRTC\r
88 ; index...\r
89 ;\r
90         mov     cx,[crtc]\r
91         mov     dx,CRTC_INDEX\r
92         mov     al,0ch          ;start address high register\r
93         out     dx,al\r
94         inc     dx\r
95         mov     al,ch\r
96         out     dx,al\r
97         dec     dx\r
98         mov     al,0dh          ;start address low register\r
99         out     dx,al\r
100         mov     al,cl\r
101         inc     dx\r
102         out     dx,al\r
103 \r
104 \r
105         sti\r
106 \r
107         ret\r
108 \r
109 ENDP\r
110 \r
111 \r
112 \r
113 ;===========================================================================\r
114 \r
115 ;==============\r
116 ;\r
117 ; VL_SetScreen\r
118 ;\r
119 ;==============\r
120 \r
121 PROC    VL_SetScreen  crtc:WORD, pel:WORD\r
122 PUBLIC  VL_SetScreen\r
123 \r
124 \r
125         mov     cx,[timecount]          ; if timecount goes up by two, the retrace\r
126         add     cx,2                            ; period was missed (an interrupt covered it)\r
127 \r
128         mov     dx,STATUS_REGISTER_1\r
129 \r
130 ;\r
131 ; wait for a display signal to make sure the raster isn't in the middle\r
132 ; of a sync\r
133 ;\r
134 @@waitdisplay:\r
135         in      al,dx\r
136         test    al,1    ;1 = display is disabled (HBL / VBL)\r
137         jnz     @@waitdisplay\r
138 \r
139 \r
140 @@loop:\r
141         sti\r
142         jmp     $+2\r
143         cli\r
144 \r
145         cmp     [timecount],cx          ; will only happen if an interrupt is\r
146         jae     @@setcrtc                       ; straddling the entire retrace period\r
147 \r
148 ;\r
149 ; when several succesive display not enableds occur,\r
150 ; the bottom of the screen has been hit\r
151 ;\r
152 \r
153         in      al,dx\r
154         test    al,8\r
155         jnz     @@waitdisplay\r
156         test    al,1\r
157         jz      @@loop\r
158 \r
159         in      al,dx\r
160         test    al,8\r
161         jnz     @@waitdisplay\r
162         test    al,1\r
163         jz      @@loop\r
164 \r
165         in      al,dx\r
166         test    al,8\r
167         jnz     @@waitdisplay\r
168         test    al,1\r
169         jz      @@loop\r
170 \r
171         in      al,dx\r
172         test    al,8\r
173         jnz     @@waitdisplay\r
174         test    al,1\r
175         jz      @@loop\r
176 \r
177         in      al,dx\r
178         test    al,8\r
179         jnz     @@waitdisplay\r
180         test    al,1\r
181         jz      @@loop\r
182 \r
183 \r
184 @@setcrtc:\r
185 \r
186 \r
187 ;\r
188 ; set CRTC start\r
189 ;\r
190 ; for some reason, my XT's EGA card doesn't like word outs to the CRTC\r
191 ; index...\r
192 ;\r
193         mov     cx,[crtc]\r
194         mov     dx,CRTC_INDEX\r
195         mov     al,0ch          ;start address high register\r
196         out     dx,al\r
197         inc     dx\r
198         mov     al,ch\r
199         out     dx,al\r
200         dec     dx\r
201         mov     al,0dh          ;start address low register\r
202         out     dx,al\r
203         mov     al,cl\r
204         inc     dx\r
205         out     dx,al\r
206 \r
207 ;\r
208 ; set horizontal panning\r
209 ;\r
210         mov     dx,ATR_INDEX\r
211         mov     al,ATR_PELPAN or 20h\r
212         out     dx,al\r
213         jmp     $+2\r
214         mov     al,[BYTE pel]           ;pel pan value\r
215         out     dx,al\r
216 \r
217         sti\r
218 \r
219         ret\r
220 \r
221 ENDP\r
222 \r
223 \r
224 ;===========================================================================\r
225 \r
226 \r
227 ;============================================================================\r
228 ;\r
229 ; VL_ScreenToScreen\r
230 ;\r
231 ; Basic block copy routine.  Copies one block of screen memory to another,\r
232 ; using write mode 1 (sets it and returns with write mode 0).  bufferofs is\r
233 ; NOT accounted for.\r
234 ;\r
235 ;============================================================================\r
236 \r
237 PROC    VL_ScreenToScreen       source:WORD, dest:WORD, wide:WORD, height:WORD\r
238 PUBLIC  VL_ScreenToScreen\r
239 USES    SI,DI\r
240 \r
241         pushf\r
242         cli\r
243 \r
244         mov     dx,SC_INDEX\r
245         mov     ax,SC_MAPMASK+15*256\r
246         out     dx,ax\r
247         mov     dx,GC_INDEX\r
248         mov     al,GC_MODE\r
249         out     dx,al\r
250         inc     dx\r
251         in      al,dx\r
252         and     al,NOT 3\r
253         or      al,1\r
254         out     dx,al\r
255 \r
256         popf\r
257 \r
258         mov     bx,[linewidth]\r
259         sub     bx,[wide]\r
260 \r
261         mov     ax,SCREENSEG\r
262         mov     es,ax\r
263         mov     ds,ax\r
264 \r
265         mov     si,[source]\r
266         mov     di,[dest]                               ;start at same place in all planes\r
267         mov     dx,[height]                             ;scan lines to draw\r
268         mov     ax,[wide]\r
269 \r
270 @@lineloop:\r
271         mov     cx,ax\r
272         rep     movsb\r
273         add     si,bx\r
274         add     di,bx\r
275 \r
276         dec     dx\r
277         jnz     @@lineloop\r
278 \r
279         mov     dx,GC_INDEX+1\r
280         in      al,dx\r
281         and     al,NOT 3\r
282         out     dx,al\r
283 \r
284         mov     ax,ss\r
285         mov     ds,ax                                   ;restore turbo's data segment\r
286 \r
287         ret\r
288 \r
289 ENDP\r
290 \r
291 \r
292 ;===========================================================================\r
293 \r
294 \r
295         MASM\r
296 ;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ\r
297 ;\r
298 ; Name: VL_VideoID\r
299 ;\r
300 ; Function:     Detects the presence of various video subsystems\r
301 ;\r
302 ; int VideoID;\r
303 ;\r
304 ; Subsystem ID values:\r
305 ;        0  = (none)\r
306 ;        1  = MDA\r
307 ;        2  = CGA\r
308 ;        3  = EGA\r
309 ;        4  = MCGA\r
310 ;        5  = VGA\r
311 ;       80h = HGC\r
312 ;       81h = HGC+\r
313 ;       82h = Hercules InColor\r
314 ;\r
315 ;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ\r
316 \r
317 ;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ\r
318 ;\r
319 ; Equates\r
320 ;\r
321 ;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ\r
322 VIDstruct       STRUC           ; corresponds to C data structure\r
323 \r
324 Video0Type      DB      ?       ; first subsystem type\r
325 Display0Type    DB      ?       ; display attached to first subsystem\r
326 \r
327 Video1Type      DB      ?       ; second subsystem type\r
328 Display1Type    DB      ?       ; display attached to second subsystem\r
329 \r
330 VIDstruct       ENDS\r
331 \r
332 \r
333 Device0 EQU     word ptr Video0Type[di]\r
334 Device1 EQU     word ptr Video1Type[di]\r
335 \r
336 \r
337 MDA     EQU     1       ; subsystem types\r
338 CGA     EQU     2\r
339 EGA     EQU     3\r
340 MCGA    EQU     4\r
341 VGA     EQU     5\r
342 HGC     EQU     80h\r
343 HGCPlus EQU     81h\r
344 InColor EQU     82h\r
345 \r
346 MDADisplay      EQU     1       ; display types\r
347 CGADisplay      EQU     2\r
348 EGAColorDisplay EQU     3\r
349 PS2MonoDisplay  EQU     4\r
350 PS2ColorDisplay EQU     5\r
351 \r
352 TRUE    EQU     1\r
353 FALSE   EQU     0\r
354 \r
355 ;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ\r
356 ;\r
357 ; Program\r
358 ;\r
359 ;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ\r
360 \r
361 Results VIDstruct <>    ;results go here!\r
362 \r
363 EGADisplays     DB      CGADisplay      ; 0000b, 0001b  (EGA switch values)\r
364         DB      EGAColorDisplay ; 0010b, 0011b\r
365         DB      MDADisplay      ; 0100b, 0101b\r
366         DB      CGADisplay      ; 0110b, 0111b\r
367         DB      EGAColorDisplay ; 1000b, 1001b\r
368         DB      MDADisplay      ; 1010b, 1011b\r
369 \r
370 DCCtable        DB      0,0     ; translate table for INT 10h func 1Ah\r
371         DB      MDA,MDADisplay\r
372         DB      CGA,CGADisplay\r
373         DB      0,0\r
374         DB      EGA,EGAColorDisplay\r
375         DB      EGA,MDADisplay\r
376         DB      0,0\r
377         DB      VGA,PS2MonoDisplay\r
378         DB      VGA,PS2ColorDisplay\r
379         DB      0,0\r
380         DB      MCGA,EGAColorDisplay\r
381         DB      MCGA,PS2MonoDisplay\r
382         DB      MCGA,PS2ColorDisplay\r
383 \r
384 TestSequence    DB      TRUE    ; this list of flags and addresses\r
385         DW      FindPS2 ;  determines the order in which this\r
386                         ;  program looks for the various\r
387 EGAflag DB      ?       ;  subsystems\r
388         DW      FindEGA\r
389 \r
390 CGAflag DB      ?\r
391         DW      FindCGA\r
392 \r
393 Monoflag        DB      ?\r
394         DW      FindMono\r
395 \r
396 NumberOfTests   EQU     ($-TestSequence)/3\r
397 \r
398 \r
399 PUBLIC  VL_VideoID\r
400 VL_VideoID      PROC\r
401 \r
402         push    bp      ; preserve caller registers\r
403         mov     bp,sp\r
404         push    ds\r
405         push    si\r
406         push    di\r
407 \r
408         push    cs\r
409         pop     ds\r
410         ASSUME  DS:@Code\r
411 \r
412 ; initialize the data structure that will contain the results\r
413 \r
414         lea     di,Results      ; DS:DI -> start of data structure\r
415 \r
416         mov     Device0,0       ; zero these variables\r
417         mov     Device1,0\r
418 \r
419 ; look for the various subsystems using the subroutines whose addresses are\r
420 ; tabulated in TestSequence; each subroutine sets flags in TestSequence\r
421 ; to indicate whether subsequent subroutines need to be called\r
422 \r
423         mov     byte ptr CGAflag,TRUE\r
424         mov     byte ptr EGAflag,TRUE\r
425         mov     byte ptr Monoflag,TRUE\r
426 \r
427         mov     cx,NumberOfTests\r
428         mov     si,offset TestSequence\r
429 \r
430 @@L01:  lodsb           ; AL := flag\r
431         test    al,al\r
432         lodsw           ; AX := subroutine address\r
433         jz      @@L02   ; skip subroutine if flag is false\r
434 \r
435         push    si\r
436         push    cx\r
437         call    ax      ; call subroutine to detect subsystem\r
438         pop     cx\r
439         pop     si\r
440 \r
441 @@L02:  loop    @@L01\r
442 \r
443 ; determine which subsystem is active\r
444 \r
445         call    FindActive\r
446 \r
447         mov     al,Results.Video0Type\r
448         mov     ah,0    ; was:  Results.Display0Type\r
449 \r
450         pop     di      ; restore caller registers and return\r
451         pop     si\r
452         pop     ds\r
453         mov     sp,bp\r
454         pop     bp\r
455         ret\r
456 \r
457 VL_VideoID      ENDP\r
458 \r
459 \r
460 ;\r
461 ; FindPS2\r
462 ;\r
463 ; This subroutine uses INT 10H function 1Ah to determine the video BIOS\r
464 ; Display Combination Code (DCC) for each video subsystem present.\r
465 ;\r
466 \r
467 FindPS2 PROC    near\r
468 \r
469         mov     ax,1A00h\r
470         int     10h     ; call video BIOS for info\r
471 \r
472         cmp     al,1Ah\r
473         jne     @@L13   ; exit if function not supported (i.e.,\r
474                         ;  no MCGA or VGA in system)\r
475 \r
476 ; convert BIOS DCCs into specific subsystems & displays\r
477 \r
478         mov     cx,bx\r
479         xor     bh,bh   ; BX := DCC for active subsystem\r
480 \r
481         or      ch,ch\r
482         jz      @@L11   ; jump if only one subsystem present\r
483 \r
484         mov     bl,ch   ; BX := inactive DCC\r
485         add     bx,bx\r
486         mov     ax,[bx+offset DCCtable]\r
487 \r
488         mov     Device1,ax\r
489 \r
490         mov     bl,cl\r
491         xor     bh,bh   ; BX := active DCC\r
492 \r
493 @@L11:  add     bx,bx\r
494         mov     ax,[bx+offset DCCtable]\r
495 \r
496         mov     Device0,ax\r
497 \r
498 ; reset flags for subsystems that have been ruled out\r
499 \r
500         mov     byte ptr CGAflag,FALSE\r
501         mov     byte ptr EGAflag,FALSE\r
502         mov     byte ptr Monoflag,FALSE\r
503 \r
504         lea     bx,Video0Type[di]  ; if the BIOS reported an MDA ...\r
505         cmp     byte ptr [bx],MDA\r
506         je      @@L12\r
507 \r
508         lea     bx,Video1Type[di]\r
509         cmp     byte ptr [bx],MDA\r
510         jne     @@L13\r
511 \r
512 @@L12:  mov     word ptr [bx],0    ; ... Hercules can't be ruled out\r
513         mov     byte ptr Monoflag,TRUE\r
514 \r
515 @@L13:  ret\r
516 \r
517 FindPS2 ENDP\r
518 \r
519 \r
520 ;\r
521 ; FindEGA\r
522 ;\r
523 ; Look for an EGA.  This is done by making a call to an EGA BIOS function\r
524 ;  which doesn't exist in the default (MDA, CGA) BIOS.\r
525 \r
526 FindEGA PROC    near    ; Caller:       AH = flags\r
527                         ; Returns:      AH = flags\r
528                         ;               Video0Type and\r
529                         ;                Display0Type updated\r
530 \r
531         mov     bl,10h  ; BL := 10h (return EGA info)\r
532         mov     ah,12h  ; AH := INT 10H function number\r
533         int     10h     ; call EGA BIOS for info\r
534                         ; if EGA BIOS is present,\r
535                         ;  BL <> 10H\r
536                         ;  CL = switch setting\r
537         cmp     bl,10h\r
538         je      @@L22   ; jump if EGA BIOS not present\r
539 \r
540         mov     al,cl\r
541         shr     al,1    ; AL := switches/2\r
542         mov     bx,offset EGADisplays\r
543         xlat            ; determine display type from switches\r
544         mov     ah,al   ; AH := display type\r
545         mov     al,EGA  ; AL := subystem type\r
546         call    FoundDevice\r
547 \r
548         cmp     ah,MDADisplay\r
549         je      @@L21   ; jump if EGA has a monochrome display\r
550 \r
551         mov     CGAflag,FALSE   ; no CGA if EGA has color display\r
552         jmp     short @@L22\r
553 \r
554 @@L21:  mov     Monoflag,FALSE  ; EGA has a mono display, so MDA and\r
555                         ;  Hercules are ruled out\r
556 @@L22:  ret\r
557 \r
558 FindEGA ENDP\r
559 \r
560 ;\r
561 ; FindCGA\r
562 ;\r
563 ; This is done by looking for the CGA's 6845 CRTC at I/O port 3D4H.\r
564 ;\r
565 FindCGA PROC    near    ; Returns:      VIDstruct updated\r
566 \r
567         mov     dx,3D4h ; DX := CRTC address port\r
568         call    Find6845\r
569         jc      @@L31   ; jump if not present\r
570 \r
571         mov     al,CGA\r
572         mov     ah,CGADisplay\r
573         call    FoundDevice\r
574 \r
575 @@L31:  ret\r
576 \r
577 FindCGA ENDP\r
578 \r
579 ;\r
580 ; FindMono\r
581 ;\r
582 ; This is done by looking for the MDA's 6845 CRTC at I/O port 3B4H.  If\r
583 ; a 6845 is found, the subroutine distinguishes between an MDA\r
584 ; and a Hercules adapter by monitoring bit 7 of the CRT Status byte.\r
585 ; This bit changes on Hercules adapters but does not change on an MDA.\r
586 ;\r
587 ; The various Hercules adapters are identified by bits 4 through 6 of\r
588 ; the CRT Status value:\r
589 ;\r
590 ; 000b = HGC\r
591 ; 001b = HGC+\r
592 ; 101b = InColor card\r
593 ;\r
594 \r
595 FindMono        PROC    near    ; Returns:      VIDstruct updated\r
596 \r
597         mov     dx,3B4h ; DX := CRTC address port\r
598         call    Find6845\r
599         jc      @@L44   ; jump if not present\r
600 \r
601         mov     dl,0BAh ; DX := 3BAh (status port)\r
602         in      al,dx\r
603         and     al,80h\r
604         mov     ah,al   ; AH := bit 7 (vertical sync on HGC)\r
605 \r
606         mov     cx,8000h        ; do this 32768 times\r
607 @@L41:  in      al,dx\r
608         and     al,80h  ; isolate bit 7\r
609         cmp     ah,al\r
610         loope   @@L41   ; wait for bit 7 to change\r
611         jne     @@L42   ; if bit 7 changed, it's a Hercules\r
612 \r
613         mov     al,MDA  ; if bit 7 didn't change, it's an MDA\r
614         mov     ah,MDADisplay\r
615         call    FoundDevice\r
616         jmp     short @@L44\r
617 \r
618 @@L42:  in      al,dx\r
619         mov     dl,al   ; DL := value from status port\r
620         and     dl,01110000b    ; mask bits 4 thru 6\r
621 \r
622         mov     ah,MDADisplay   ; assume it's a monochrome display\r
623 \r
624         mov     al,HGCPlus      ; look for an HGC+\r
625         cmp     dl,00010000b\r
626         je      @@L43   ; jump if it's an HGC+\r
627 \r
628         mov     al,HGC  ; look for an InColor card or HGC\r
629         cmp     dl,01010000b\r
630         jne     @@L43   ; jump if it's not an InColor card\r
631 \r
632         mov     al,InColor      ; it's an InColor card\r
633         mov     ah,EGAColorDisplay\r
634 \r
635 @@L43:  call    FoundDevice\r
636 \r
637 @@L44:  ret\r
638 \r
639 FindMono        ENDP\r
640 \r
641 ;\r
642 ; Find6845\r
643 ;\r
644 ; This routine detects the presence of the CRTC on a MDA, CGA or HGC.\r
645 ; The technique is to write and read register 0Fh of the chip (cursor\r
646 ; low).  If the same value is read as written, assume the chip is\r
647 ; present at the specified port addr.\r
648 ;\r
649 \r
650 Find6845        PROC    near    ; Caller:  DX = port addr\r
651                         ; Returns: cf set if not present\r
652         mov     al,0Fh\r
653         out     dx,al   ; select 6845 reg 0Fh (Cursor Low)\r
654         inc     dx\r
655         in      al,dx   ; AL := current Cursor Low value\r
656         mov     ah,al   ; preserve in AH\r
657         mov     al,66h  ; AL := arbitrary value\r
658         out     dx,al   ; try to write to 6845\r
659 \r
660         mov     cx,100h\r
661 @@L51:  loop    @@L51   ; wait for 6845 to respond\r
662 \r
663         in      al,dx\r
664         xchg    ah,al   ; AH := returned value\r
665                         ; AL := original value\r
666         out     dx,al   ; restore original value\r
667 \r
668         cmp     ah,66h  ; test whether 6845 responded\r
669         je      @@L52   ; jump if it did (cf is reset)\r
670 \r
671         stc             ; set carry flag if no 6845 present\r
672 \r
673 @@L52:  ret\r
674 \r
675 Find6845        ENDP\r
676 \r
677 \r
678 ;\r
679 ; FindActive\r
680 ;\r
681 ; This subroutine stores the currently active device as Device0.  The\r
682 ; current video mode determines which subsystem is active.\r
683 ;\r
684 \r
685 FindActive      PROC    near\r
686 \r
687         cmp     word ptr Device1,0\r
688         je      @@L63   ; exit if only one subsystem\r
689 \r
690         cmp     Video0Type[di],4        ; exit if MCGA or VGA present\r
691         jge     @@L63   ;  (INT 10H function 1AH\r
692         cmp     Video1Type[di],4        ;  already did the work)\r
693         jge     @@L63\r
694 \r
695         mov     ah,0Fh\r
696         int     10h     ; AL := current BIOS video mode\r
697 \r
698         and     al,7\r
699         cmp     al,7    ; jump if monochrome\r
700         je      @@L61   ;  (mode 7 or 0Fh)\r
701 \r
702         cmp     Display0Type[di],MDADisplay\r
703         jne     @@L63   ; exit if Display0 is color\r
704         jmp     short @@L62\r
705 \r
706 @@L61:  cmp     Display0Type[di],MDADisplay\r
707         je      @@L63   ; exit if Display0 is monochrome\r
708 \r
709 @@L62:  mov     ax,Device0      ; make Device0 currently active\r
710         xchg    ax,Device1\r
711         mov     Device0,ax\r
712 \r
713 @@L63:  ret\r
714 \r
715 FindActive      ENDP\r
716 \r
717 \r
718 ;\r
719 ; FoundDevice\r
720 ;\r
721 ; This routine updates the list of subsystems.\r
722 ;\r
723 \r
724 FoundDevice     PROC    near    ; Caller:    AH = display #\r
725                         ;            AL = subsystem #\r
726                         ; Destroys:  BX\r
727         lea     bx,Video0Type[di]\r
728         cmp     byte ptr [bx],0\r
729         je      @@L71   ; jump if 1st subsystem\r
730 \r
731         lea     bx,Video1Type[di]       ; must be 2nd subsystem\r
732 \r
733 @@L71:  mov     [bx],ax ; update list entry\r
734         ret\r
735 \r
736 FoundDevice     ENDP\r
737 \r
738 IDEAL\r
739 \r
740 \r
741 \r
742 END\r