; Copyright (C) 1989, 1990, 1991 Aladdin Enterprises. All rights reserved.
; Distributed by Free Software Foundation, Inc.
; This file is part of Ghostscript.
; Ghostscript is distributed in the hope that it will be useful, but
; WITHOUT ANY WARRANTY. No author or distributor accepts responsibility
; to anyone for the consequences of using it or for whether it serves any
; particular purpose or works at all, unless he says so in writing. Refer
; to the Ghostscript General Public License for full details.
; Everyone is granted permission to copy, modify and redistribute
; Ghostscript, but only under the conditions described in the Ghostscript
; General Public License. A copy of this license is supposed to have been
; given to you along with Ghostscript so you can know your rights and
; responsibilities. It should be in a file named COPYING. Among other
; things, the copyright notice and this notice must be preserved on all
; Assembly code for Ghostscript PC frame buffer driver
gdevegaasm_TEXT SEGMENT BYTE PUBLIC 'CODE'
ASSUME CS:gdevegaasm_TEXT
; Note: Turbo C uses si and di for register variables, so
; we have to preserve them.
; Normal entry and exit. Arguments are relative to bp.
x = 6 ; offset of arguments,
; Fast entry and exit, for procedures that don't use bx until
; they've fetched all their arguments. Arguments are relative to ss:bx.
x = 4 ; offset of arguments,
; Fast call to VESA set-page routine.
; void vesa_call_set_page(void (*set_page_proc)(int), int page_no, int win_no)
PUBLIC _vesa_call_set_page
_vesa_call_set_page proc far
mov dx,ss:[bx+x+4] ; page_no
push ss:[bx+x+2] ; set_page_proc
mov bx,ss:[bx+x+6] ; win_no
; Structure for operation parameters.
; Note that this structure is shared with C code.
; Not all parameters are used for every operation.
; typedef struct rop_params_s {
p_dest equ 0 ; fb_ptr dest; /* pointer to frame buffer */
p_draster equ 4 ; int draster; /* raster of frame buffer */
p_src equ 6 ; byte far *src; /* pointer to source data */
p_sraster equ 10 ; int sraster; /* source raster */
p_width equ 12 ; int width; /* width in bytes */
p_height equ 14 ; int height; /* height in scan lines */
p_shift equ 16 ; int shift; /* amount to right shift source */
p_invert equ 18 ; int invert; /* 0 or -1 to invert source */
p_data equ 20 ; int data; /* data for fill */
; void memsetcol(rop_params _ss *rop)
; { byte far *addr = rop->dest;
; { byte discard = *addr;
; Unroll the loop -- two copies.
inc cx ;round up to nearest word. cx>=2 now.
shr cx,1 ;make byte count into word count.
jnc msc2 ;if it had been odd, do a half word first.
; void memsetrect(rop_params _ss *rop)
; { byte far *addr = rop->dest;
; { int cnt = rop->width;
; while ( cnt-- ) *addr++ = rop->data;
; addr += rop->drast - rop->width;
ja msrl ; large count, use fast loop
; Small count, rep stosb is faster.
msrs: mov cx,[bx].p_width
; Large count, loop by words rather than bytes.
msrl: mov ah,al ;we may be storing words...
msr1: mov cx,[bx].p_width
test di,1 ;test for an even address
je msr2 ;if even, we can store words.
stosb ;otherwise we need to even it out.
dec cx ;(cx is at least one here)
msr2: shr cx,1 ;convert byte count into word count
rep stosw ;store them puppies as fast as we can.
jnc msr3 ;if an odd number, store it, too.
stosb ;(no need to dec cx here).
; void memrwcol(rop_params _ss *rop)
; { byte far *dp = rop->dest, *sp = rop->src;
; int shift = rop->shift;
; *dp = ((*sp >> shift) + (*sp << (8 - shift))) ^ rop->invert;
; dp += rop->draster, sp += rop->sraster;
cmp word ptr [bx].p_height,0
; ds:si = sp, es:di = dp, bx = sraster, dx = draster, cl = shift,
; ch = invert, ah = low byte of yc.
mov ah,[bp-8] ; low byte of yc
mrw2: dec byte ptr [bp-7] ; high byte of yc
; void memrwcol2(rop_params _ss *rop)
; { byte far *dp = rop->dest, *sp = rop->src;
; int shift = rop->shift;
; *dp = ((sp[1] >> shift) + (*sp << (8 - shift))) ^ rop->invert;
; dp += rop->draster, sp += rop->sraster;
cmp word ptr [bx].p_height,0
; ds:si = sp, es:di = dp, bx = sraster, dx = draster, cl = shift,
mrw21: mov ax,[si] ; bytes are in wrong order...
xor ah,ch ; ... so result is in ah