3 Copyright 2001-2005 John Coffman.
6 Licensed under the terms contained in the file 'COPYING' in the
13 ;; segment _TEXT PARA class=CODE
16 /* the following is set to 1 to test the fallback to TEXT mode */
34 ; get a single byte in AX (zero extended)
35 ; and increment the HUGE pointer _tp
67 ; tp was _tp ; ds:si -- HUGE ptr [bp:si]
110 jz d4_L676 ; 2001/06/23
115 dec bh ;rpt 2001/06/23
137 dec bh ;rpt 2001/06/23
138 jz d4_L678 ; 2001/06/23
141 dec bh ;rpt 2001/06/23
175 ; bits = ax on top of stack
180 ; sch (bp+4) (arg); DS:BX
187 mov cx,WORD [0x485] ;points
188 xor ah,ah ;AL is char to put out
189 mov WORD (bp-2),cx ;points
190 imul ax,cx ;leave DX alone; 386 form of instruction
191 mov si,#268 ;010cH ; int 0x43 -> character bitmaps
193 mov es,WORD (si+2) ;cgen
196 ; call pixadr -----------------------------------
198 and cx,#7 ;mask for shift
202 imul di,bx,#640/8 ; DI = y * _ypitch
203 ror ax,cl ;AL is mask, AH is hi-mask
205 mov WORD (bp-6),ax ;save mask
206 ;-------------------------------------------------
207 mov WORD (bp-4),#0 ;shadow
216 ror ax,cl ;rotated bits in AX
218 push ax ;save AX rotated bits
221 and ax,WORD (bp-6) ;mask complement
224 mov ah,BYTE (bx+2) ;sch->bg
225 cmp BYTE (bx),ah ;sch->fg
226 pop ax ; inserted ****
229 push ax ;AH = bits high; AL = bits low
230 mov ah,al ;AH = bits low
233 mov ah,BYTE (bx+2) ;sch->bg
235 and BYTE (di),ah ;buf
236 pop ax ; get complemented bits back
239 mov al,#08 ;AH = ~bits hi, AL = 8
241 mov al,BYTE (bx+2) ;sch->bg
243 and BYTE (di+1),al ;buf
245 d4_I529: ; rotated bits in the stack
246 mov al,BYTE (bx+4) ;sch->sh
247 cmp BYTE (bx),al ;sch->fg
249 mov ax,WORD (bp-4) ;get shadow
254 mov ah,BYTE (bx+4) ;sch->sh
263 mov ah,BYTE (bx+4) ;sch->sh
269 mov WORD (bp-4),ax ; save shadow
275 mov al,BYTE (bx) ;sch->fg
283 mov al,BYTE (bx) ;sch->fg
313 mov cx,WORD (bp+12) ;len
314 mov bx,WORD (bp+6) ;ypos
315 mov dx,WORD (bp+4) ;xpos
323 push WORD (bp+14) ;sch
327 cmp WORD [_Mode],#0x12
360 mov bx,#0x3fff ;00ffH
408 mov ah,#640/8 ; npix/8
439 ;; imul WORD [_ypitch]
482 .ascii " = AX; setstate entered"
489 cmp WORD [_Mode],#0x12
490 ja d4_SB497 ;setstate is a NOP if VESA
536 .ascii "setstate exit"
548 ; _display4: display the BITMAP
550 ; Enter with: ES:BX points to the possible bitmap image
554 ; Carry Clear - bitmap was displayed
557 ; Carry Set - error occurred
558 ; AX = 1 "BM" signature not found
559 ; AX = 2 not VGA adapter or display
560 ; AX = 3 not 640x480x16 bitmap
561 ; AX = 4 no VESA support
578 mov WORD [_bmp],bx ;store for later
581 mov WORD (bp-18),bx ;bmfh
584 cmp WORD (bx),#19778 ;4d42H
587 cmp WORD (bx+14+2),#0 ; hi-order part of DWORD
590 cmp WORD (bx+14),#40 ; Windows/OS2 bitmap header
593 cmp WORD (bx+14),#12 ; OS2 bitmap header
610 mov WORD (bp-22),ax ;bmh
616 cmp BYTE (bx),#40 ; Windows
624 mov WORD (bp-2),ax ;bits
630 mov WORD (bp-6),ax ;colors
633 cmp WORD (bx+4),#640 ;0280H
636 cmp WORD (bx+6),#480 ;01e0H
646 ; Windows/OS2 bitmaps
652 mov WORD (bp-2),ax ;bits
658 mov WORD (bp-6),ax ;colors
661 ;;; cmp DWORD (bx+4),#640 ;0280H
662 cmp WORD (bx+4),#640 ;0280H
665 ;;; cmp DWORD (bx+8),#480 ;01e0H
666 cmp WORD (bx+8),#480 ;01e0H
675 mov WORD [_Mode],#18 ;0012H
679 ;; mov WORD [_ypitch],ax
691 mov WORD [_Mode],#0x101 ; 640x480x256
693 mov di,#MAP ; ES:DI -> 512 byte buffer
694 mov DWORD (di),#SIG_VBE2 ; "VBE2"
695 mov ax,#0x4f00 ; get mode information
699 pop es ; -> communication area
700 int 0x10 ; video interrupt
706 jne d4_I576_4 ; no VESA
707 cmp DWORD (di),#SIG_VESA ; "VESA"
710 mov ax,#0x4f01 ; get mode information
715 pop es ; -> communication area
716 int 0x10 ; video interrupt
721 jne d4_I576_4 ; no VESA
723 mov ax,v_BytesPerScanLine(di)
725 mov ax,v_WinASegment(di)
727 mov cx,v_WinGranularity(di)
728 mov ax,#9 ; shift = 9
736 xchg ax,cx ; shift to CX
740 mov DWORD [_mask],eax
743 mov DWORD [_himask],eax ;
744 test BYTE v_ModeAttributes(di),#1
746 mov al,v_WinAAttributes(di)
752 ;;; mov WORD (bp-10),bx ;disable
756 mov ax,#0x4f02 ; set video mode
794 ;;; mov WORD (bp-10),#128 ;0080H ;disable
796 ;;; or al,#128 ;0080H
803 mov ax,#0x1124 ;set for 8x16 characters
806 ;;; cmp WORD (bp-10),#0 ;disable
836 mov bx,#0x3fff ;00ffH
860 cmp BYTE (di),#12 ; test for OS/2 bitmap
865 inc bx ;WORD (bp-8) ;i
867 cmp WORD (bp-6),bx ;colors
893 ;; mov ax,WORD (bx+8) ; 480
894 mov ax,#480 ; Windows or OS2
896 ;; mov dx,WORD (bx+4) ; 640
897 mov dx,#640 ; Windows or OS2
899 cmp BYTE (bx),#13 ; OS2
900 sbb cx,cx ; OS2 = -1, Win = 0
903 and cx,WORD (bx+16) ; compression
905 mov bx,cx ; compression to BX
909 cmp WORD [_Mode],#0x12
929 xor ax,ax ; restore state
933 mov bx,#54 ;0036H ;enable refresh
937 xor ax,ax ;clears the carry
947 call d4_setstate ;restore state
949 ; enable default palette loading
954 mov ax,#0x0003 ; set video mode
960 ; pixadr8 - pixel address in 256 color mode
967 ; ES:DI = pointer to byte
1023 ; all other registers preserved
1027 mov si,#_line ; source
1029 mov cx,WORD [_mask] ; mask
1059 mov di,#_line ; ES:DI setup
1060 lds si,[_tp] ; DS:SI is a HUGE pointer
1061 mov bp,ds ; also in BP:SI
1066 ; get with compression
1080 ; while (repeat && npix>0) {
1084 ; rpt = GETC(infile);
1111 ; } /* end while (repeat && npix>0) */
1119 ; if (npix>0) { /* get some enumerated data */
1123 ; rpt = GETC(infile);
1130 ; skip = (rpt%2 != 0);
1146 ; if (skip) c = GETC(infile);
1158 ; } /* end while (npix>0) */
1171 ; get with no compression
1172 ; really just a super movsb with a huge source pointer
1177 call getbyte ; BP==DS is required
1194 ; AL character to display
1197 ; (bp+4) far pointer to
1223 ; points = *(short*)0x00000485UL; /* 40:85 */
1224 mov cx,WORD [0x485] ;points
1225 xor ah,ah ;AL is char to put out
1226 mov WORD (bp-2),cx ;points
1227 mov WORD (bp-4),bx ;ypos
1228 mov WORD (bp-6),dx ;xpos
1230 ; cgen = *(char**)(0x43 * 4UL); /* int 0x43 points to char bitmap */
1231 ; cgen += (unsigned)c * points;
1232 imul ax,cx ;leave DX alone; 386 form of instruction
1233 mov si,#268 ;010cH ; int 0x43 -> character bitmaps
1235 mov ds,WORD (si+2) ;cgen
1236 xchg si,ax ;cgen in DS:SI
1240 les di,(bp+4) ;sch->
1251 ; while (points--) {
1255 ; bits = *cgen++; ;cgen in DS:SI
1257 mov WORD (bp-8),ax ;bits
1260 ; fore = bits; ; fore is BL
1261 xchg bx,ax ; fore is BL
1265 mov WORD (bp-10),ax ;xtem
1267 ; for (i=8; i; i--) {
1273 test di,WORD [_mask]
1276 mov ax,WORD (bp-4) ;ypos
1277 mov bx,WORD (bp-10) ;xtem
1278 call d4_pixadr8 ;buf to ES:DI
1282 ; int color = 0x400;
1285 ; if (bg != fg) color = bg;
1288 mov al,dh ;color = bg
1292 ; if ( (shadow&0200) && sh != fg) color = sh;
1297 mov al,dl ; color = sh
1301 ; if ( (fore & 0200) ) color = fg;
1304 mov al,cl ; color = fg
1309 ; buf = pixadr8(xtem++, y);
1310 ; if (color<256) *buf = color;
1318 inc WORD (bp-10) ;xtem
1327 inc WORD (bp-4) ;ypos