3 ; Copyright 2001-2005 John Coffman
4 ; Copyright 2009-2013 Joachim Wiedorn
7 ; Licensed under the terms contained in the file 'COPYING'
8 ; in the source directory.
14 ;; segment _TEXT PARA class=CODE
17 /* the following is set to 1 to test the fallback to TEXT mode */
35 ; get a single byte in AX (zero extended)
36 ; and increment the HUGE pointer _tp
68 ; tp was _tp ; ds:si -- HUGE ptr [bp:si]
111 jz d4_L676 ; 2001/06/23
116 dec bh ;rpt 2001/06/23
138 dec bh ;rpt 2001/06/23
139 jz d4_L678 ; 2001/06/23
142 dec bh ;rpt 2001/06/23
176 ; bits = ax on top of stack
181 ; sch (bp+4) (arg); DS:BX
188 mov cx,WORD [0x485] ;points
189 xor ah,ah ;AL is char to put out
190 mov WORD (bp-2),cx ;points
191 imul ax,cx ;leave DX alone; 386 form of instruction
192 mov si,#268 ;010cH ; int 0x43 -> character bitmaps
194 mov es,WORD (si+2) ;cgen
197 ; call pixadr -----------------------------------
199 and cx,#7 ;mask for shift
203 imul di,bx,#640/8 ; DI = y * _ypitch
204 ror ax,cl ;AL is mask, AH is hi-mask
206 mov WORD (bp-6),ax ;save mask
207 ;-------------------------------------------------
208 mov WORD (bp-4),#0 ;shadow
217 ror ax,cl ;rotated bits in AX
219 push ax ;save AX rotated bits
222 and ax,WORD (bp-6) ;mask complement
225 mov ah,BYTE (bx+2) ;sch->bg
226 cmp BYTE (bx),ah ;sch->fg
227 pop ax ; inserted ****
230 push ax ;AH = bits high; AL = bits low
231 mov ah,al ;AH = bits low
234 mov ah,BYTE (bx+2) ;sch->bg
236 and BYTE (di),ah ;buf
237 pop ax ; get complemented bits back
240 mov al,#08 ;AH = ~bits hi, AL = 8
242 mov al,BYTE (bx+2) ;sch->bg
244 and BYTE (di+1),al ;buf
246 d4_I529: ; rotated bits in the stack
247 mov al,BYTE (bx+4) ;sch->sh
248 cmp BYTE (bx),al ;sch->fg
250 mov ax,WORD (bp-4) ;get shadow
255 mov ah,BYTE (bx+4) ;sch->sh
264 mov ah,BYTE (bx+4) ;sch->sh
270 mov WORD (bp-4),ax ; save shadow
276 mov al,BYTE (bx) ;sch->fg
284 mov al,BYTE (bx) ;sch->fg
314 mov cx,WORD (bp+12) ;len
315 mov bx,WORD (bp+6) ;ypos
316 mov dx,WORD (bp+4) ;xpos
324 push WORD (bp+14) ;sch
328 cmp WORD [_Mode],#0x12
361 mov bx,#0x3fff ;00ffH
409 mov ah,#640/8 ; npix/8
440 ;; imul WORD [_ypitch]
483 .ascii " = AX; setstate entered"
490 cmp WORD [_Mode],#0x12
491 ja d4_SB497 ;setstate is a NOP if VESA
537 .ascii "setstate exit"
549 ; _display4: display the BITMAP
551 ; Enter with: ES:BX points to the possible bitmap image
555 ; Carry Clear - bitmap was displayed
558 ; Carry Set - error occurred
559 ; AX = 1 "BM" signature not found
560 ; AX = 2 not VGA adapter or display
561 ; AX = 3 not 640x480x16 bitmap
562 ; AX = 4 no VESA support
579 mov WORD [_bmp],bx ;store for later
582 mov WORD (bp-18),bx ;bmfh
585 cmp WORD (bx),#19778 ;4d42H
588 cmp WORD (bx+14+2),#0 ; hi-order part of DWORD
591 cmp WORD (bx+14),#40 ; Windows bitmap header
594 cmp WORD (bx+14),#12 ; OS2 bitmap header (obsolete)
611 mov WORD (bp-22),ax ;bmh
617 cmp BYTE (bx),#40 ; Windows
620 ; OS2 bitmaps (obselete)
625 mov WORD (bp-2),ax ;bits
631 mov WORD (bp-6),ax ;colors
634 cmp WORD (bx+4),#640 ;0280H
637 cmp WORD (bx+6),#480 ;01e0H
653 mov WORD (bp-2),ax ;bits
659 mov WORD (bp-6),ax ;colors
662 ;;; cmp DWORD (bx+4),#640 ;0280H
663 cmp WORD (bx+4),#640 ;0280H
666 ;;; cmp DWORD (bx+8),#480 ;01e0H
667 cmp WORD (bx+8),#480 ;01e0H
676 mov WORD [_Mode],#18 ;0012H
680 ;; mov WORD [_ypitch],ax
692 mov WORD [_Mode],#0x101 ; 640x480x256
694 mov di,#MAP ; ES:DI -> 512 byte buffer
695 mov DWORD (di),#SIG_VBE2 ; "VBE2"
696 mov ax,#0x4f00 ; get mode information
700 pop es ; -> communication area
701 int 0x10 ; video interrupt
707 jne d4_I576_4 ; no VESA
708 cmp DWORD (di),#SIG_VESA ; "VESA"
711 mov ax,#0x4f01 ; get mode information
716 pop es ; -> communication area
717 int 0x10 ; video interrupt
722 jne d4_I576_4 ; no VESA
724 mov ax,v_BytesPerScanLine(di)
726 mov ax,v_WinASegment(di)
728 mov cx,v_WinGranularity(di)
729 mov ax,#9 ; shift = 9
737 xchg ax,cx ; shift to CX
741 mov DWORD [_mask],eax
744 mov DWORD [_himask],eax ;
745 test BYTE v_ModeAttributes(di),#1
747 mov al,v_WinAAttributes(di)
753 ;;; mov WORD (bp-10),bx ;disable
757 mov ax,#0x4f02 ; set video mode
795 ;;; mov WORD (bp-10),#128 ;0080H ;disable
797 ;;; or al,#128 ;0080H
804 mov ax,#0x1124 ;set for 8x16 characters
807 ;;; cmp WORD (bp-10),#0 ;disable
837 mov bx,#0x3fff ;00ffH
861 cmp BYTE (di),#12 ; test for OS/2 bitmap
866 inc bx ;WORD (bp-8) ;i
868 cmp WORD (bp-6),bx ;colors
894 ;; mov ax,WORD (bx+8) ; 480
895 mov ax,#480 ; Windows
897 ;; mov dx,WORD (bx+4) ; 640
898 mov dx,#640 ; Windows
900 cmp BYTE (bx),#13 ; OS2 (obsolete)
901 sbb cx,cx ; Win = 0 OS2 = -1 (obsolete)
904 and cx,WORD (bx+16) ; compression
906 mov bx,cx ; compression to BX
910 cmp WORD [_Mode],#0x12
930 xor ax,ax ; restore state
934 mov bx,#54 ;0036H ;enable refresh
938 xor ax,ax ;clears the carry
948 call d4_setstate ;restore state
950 ; enable default palette loading
955 mov ax,#0x0003 ; set video mode
961 ; pixadr8 - pixel address in 256 color mode
968 ; ES:DI = pointer to byte
1024 ; all other registers preserved
1028 mov si,#_line ; source
1030 mov cx,WORD [_mask] ; mask
1060 mov di,#_line ; ES:DI setup
1061 lds si,[_tp] ; DS:SI is a HUGE pointer
1062 mov bp,ds ; also in BP:SI
1067 ; get with compression
1081 ; while (repeat && npix>0) {
1085 ; rpt = GETC(infile);
1112 ; } /* end while (repeat && npix>0) */
1120 ; if (npix>0) { /* get some enumerated data */
1124 ; rpt = GETC(infile);
1131 ; skip = (rpt%2 != 0);
1147 ; if (skip) c = GETC(infile);
1159 ; } /* end while (npix>0) */
1172 ; get with no compression
1173 ; really just a super movsb with a huge source pointer
1178 call getbyte ; BP==DS is required
1195 ; AL character to display
1198 ; (bp+4) far pointer to
1224 ; points = *(short*)0x00000485UL; /* 40:85 */
1225 mov cx,WORD [0x485] ;points
1226 xor ah,ah ;AL is char to put out
1227 mov WORD (bp-2),cx ;points
1228 mov WORD (bp-4),bx ;ypos
1229 mov WORD (bp-6),dx ;xpos
1231 ; cgen = *(char**)(0x43 * 4UL); /* int 0x43 points to char bitmap */
1232 ; cgen += (unsigned)c * points;
1233 imul ax,cx ;leave DX alone; 386 form of instruction
1234 mov si,#268 ;010cH ; int 0x43 -> character bitmaps
1236 mov ds,WORD (si+2) ;cgen
1237 xchg si,ax ;cgen in DS:SI
1241 les di,(bp+4) ;sch->
1252 ; while (points--) {
1256 ; bits = *cgen++; ;cgen in DS:SI
1258 mov WORD (bp-8),ax ;bits
1261 ; fore = bits; ; fore is BL
1262 xchg bx,ax ; fore is BL
1266 mov WORD (bp-10),ax ;xtem
1268 ; for (i=8; i; i--) {
1274 test di,WORD [_mask]
1277 mov ax,WORD (bp-4) ;ypos
1278 mov bx,WORD (bp-10) ;xtem
1279 call d4_pixadr8 ;buf to ES:DI
1283 ; int color = 0x400;
1286 ; if (bg != fg) color = bg;
1289 mov al,dh ;color = bg
1293 ; if ( (shadow&0200) && sh != fg) color = sh;
1298 mov al,dl ; color = sh
1302 ; if ( (fore & 0200) ) color = fg;
1305 mov al,cl ; color = fg
1310 ; buf = pixadr8(xtem++, y);
1311 ; if (color<256) *buf = color;
1319 inc WORD (bp-10) ;xtem
1328 inc WORD (bp-4) ;ypos