Exemplo n.º 1
0
Arquivo: ibitblt.c Projeto: btb/d2x
void gr_ibitblt(grs_bitmap *src_bmp, grs_bitmap *dest_bmp)
{
	int x, y, sw, sh, srowsize, drowsize, dstart, sy;
	ubyte *src, *dest;

// variable setup

	sw = src_bmp->bm_w;
	sh = src_bmp->bm_h;
	srowsize = src_bmp->bm_rowsize;
	drowsize = dest_bmp->bm_rowsize;
	src = src_bmp->bm_data;
	dest = dest_bmp->bm_data;

	sy = 0;
	while (start_points[sy][0] == -1) {
		sy++;
		dest += drowsize;
	}

	Assert(sw <= MAX_WIDTH);
	Assert(sh <= MAX_SCANLINES);
	for (y = sy; y < sy + sh; y++) {
		for (x = 0; x < MAX_HOLES; x++) {
			if (start_points[y][x] == -1)
				break;
			dstart = start_points[y][x];
			gr_linear_movsd(&(src[dstart]), &(dest[dstart]), hole_length[y][x]);
		}
		dest += drowsize;
		src += srowsize;
	}
}
Exemplo n.º 2
0
// From Linear to Linear
void gr_bm_ubitblt00(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest)
{
	unsigned char * dbits;
	unsigned char * sbits;
	//int	src_bm_rowsize_2, dest_bm_rowsize_2;
	int dstep;

	int i;

	sbits =   src->bm_data	+ (src->bm_rowsize * sy) + sx;
	dbits =   dest->bm_data + (dest->bm_rowsize * dy) + dx;

	dstep = dest->bm_rowsize << gr_bitblt_dest_step_shift;

	// No interlacing, copy the whole buffer.
	if (gr_bitblt_double)
	    for (i=0; i < h; i++ )    {
		gr_linear_rep_movsd_2x( sbits, dbits, w );
		sbits += src->bm_rowsize;
		dbits += dstep;
	    }
	else
	    for (i=0; i < h; i++ )    {
		gr_linear_movsd( sbits, dbits, w );
		//memcpy(dbits, sbits, w);
		sbits += src->bm_rowsize;
		dbits += dstep;
	    }
}
Exemplo n.º 3
0
void gr_ubitmap00( int x, int y, grs_bitmap *bm )
{
	register int y1;
	int dest_rowsize;

	unsigned char * dest;
	unsigned char * src;

	dest_rowsize=grd_curcanv->cv_bitmap.bm_rowsize << gr_bitblt_dest_step_shift;
	dest = &(grd_curcanv->cv_bitmap.bm_data[ dest_rowsize*y+x ]);

	src = bm->bm_data;

	for (y1=0; y1 < bm->bm_h; y1++ )    {
		if (gr_bitblt_double)
			gr_linear_rep_movsd_2x( src, dest, bm->bm_w );
		else
			gr_linear_movsd( src, dest, bm->bm_w );
		src += bm->bm_rowsize;
		dest+= (int)(dest_rowsize);
	}
}
Exemplo n.º 4
0
void    gr_ibitblt_find_hole_size( grs_bitmap * mask_bmp, int *minx, int *miny, int *maxx, int *maxy )
{
    int x, y, count=0;
#if defined(POLY_ACC)
    short c;
#else
    ubyte c;
#endif

    Assert( (!(mask_bmp->bm_flags&BM_FLAG_RLE)) );

#if defined(POLY_ACC)
    Assert(mask_bmp->bm_type == BM_LINEAR15);
    pa_flush();
#endif

    *minx = mask_bmp->bm_w-1;
    *maxx = 0;
    *miny = mask_bmp->bm_h-1;
    *maxy = 0;

    for ( y=0; y<mask_bmp->bm_h; y++ )
        for ( x=0; x<mask_bmp->bm_w; x++ ) {
#if defined(POLY_ACC)
            c = *(short *)(mask_bmp->bm_data + mask_bmp->bm_rowsize * y + x * PA_BPP);
            if (c >= 0)  {      // hi true means opaque.
#else
            c = mask_bmp->bm_data[mask_bmp->bm_rowsize*y+x];
            if (c == 255 ) {
#endif
                if ( x < *minx ) *minx = x;
                if ( y < *miny ) *miny = y;
                if ( x > *maxx ) *maxx = x;
                if ( y > *maxy ) *maxy = y;
                count++;
            }
        }

    if ( count == 0 ) {
        Error( "Bitmap for ibitblt doesn't have transparency!\n" );
    }
}

#else // ifdef __MSDOS__

#include "pa_enabl.h"
#include "pstypes.h"
#include "gr.h"
#include "ibitblt.h"
#include "error.h"
#include "u_mem.h"
#include "grdef.h"

#if defined(POLY_ACC)
#include "poly_acc.h"
#endif

#define FIND_START      1
#define FIND_STOP       2

#define MAX_WIDTH       640
#define MAX_SCANLINES   480
#define MAX_HOLES       5

static short start_points[MAX_SCANLINES][MAX_HOLES];
static short hole_length[MAX_SCANLINES][MAX_HOLES];
static double *scanline = NULL;

void gr_ibitblt(grs_bitmap *src_bmp, grs_bitmap *dest_bmp, ubyte pixel_double)
{
    int x, y, sw, sh, srowsize, drowsize, dstart, sy, dy;
    ubyte *src, *dest;
    short *current_hole, *current_hole_length;

// variable setup

#if defined(POLY_ACC)
    if ( PAEnabled )
        return;
#endif

    sw = src_bmp->bm_w;
    sh = src_bmp->bm_h;
    srowsize = src_bmp->bm_rowsize;
    drowsize = dest_bmp->bm_rowsize;
    src = src_bmp->bm_data;
    dest = dest_bmp->bm_data;

    sy = 0;
    while (start_points[sy][0] == -1) {
        sy++;
        dest += drowsize;
    }

    if (pixel_double) {
        ubyte *scan = (ubyte *)scanline;    // set up for byte processing of scanline

        dy = sy;
        for (y = sy; y < sy + sh; y++) {
            gr_linear_movsd_double(src, scan, sw*2);
            current_hole = start_points[dy];
            current_hole_length = hole_length[dy];
            for (x = 0; x < MAX_HOLES; x++) {
                if (*current_hole == -1)
                    break;
                dstart = *current_hole;
                gr_linear_movsd(&(scan[dstart]), &(dest[dstart]), *current_hole_length);
                current_hole++;
                current_hole_length++;
            }
            dy++;
            dest += drowsize;
            current_hole = start_points[dy];
            current_hole_length = hole_length[dy];
            for (x = 0; x < MAX_HOLES; x++) {
                if (*current_hole == -1)
                    break;
                dstart = *current_hole;
                gr_linear_movsd(&(scan[dstart]), &(dest[dstart]), *current_hole_length);
                current_hole++;
                current_hole_length++;
            }
            dy++;
            dest += drowsize;
            src += srowsize;
        }
    } else {
        Assert(sw <= MAX_WIDTH);
        Assert(sh <= MAX_SCANLINES);
        for (y = sy; y < sy + sh; y++) {
            for (x = 0; x < MAX_HOLES; x++) {
                if (start_points[y][x] == -1)
                    break;
                dstart = start_points[y][x];
                gr_linear_movsd(&(src[dstart]), &(dest[dstart]), hole_length[y][x]);
            }
            dest += drowsize;
            src += srowsize;
        }
    }
}
Exemplo n.º 5
0
main()
{
	unsigned int t1, t2, fastest;
	unsigned int timeb1v, timeb2v, timeb4v, timeb1s, timeb2s, timeb4s;
	unsigned int timew1v, timew2v, timew4v, timew1s, timew2s, timew4s;
	unsigned int timed1v, timed2v, timed4v, timed1s, timed2s, timed4s;

	gr_init( 0 );

	timer_init( 0, NULL );


	TempBuffer1 = (unsigned char *)(((unsigned int)TempBufferX+0xF) & 0xFFFFFFF0);

	System4  = (unsigned char *)(((unsigned int)TempBuffer2+0xF) & 0xFFFFFFF0);
	System2  = (unsigned char *)((unsigned int)System4 + 2);
	System1  = (unsigned char *)((unsigned int)System4 + 1);



	Video4 = (unsigned char *)0xA0000;
	Video2 = (unsigned char *)0xA0002;
	Video1 = (unsigned char *)0xA0001;


	t1 = timer_get_microseconds();
	gr_linear_movsb(TempBuffer1, Video1, 320*200);
	t2 = timer_get_microseconds();
	t1 = timer_get_microseconds();
	gr_linear_movsb(TempBuffer1, Video1, 320*200);
	t2 = timer_get_microseconds();
	fastest = t2-t1;
	if ((t2-t1) < fastest) fastest = t2-t1;
	timeb1v = t2 - t1;

	t1 = timer_get_microseconds();
	gr_linear_movsb(TempBuffer1, Video2, 320*200);
	t2 = timer_get_microseconds();
	t1 = timer_get_microseconds();
	gr_linear_movsb(TempBuffer1, Video2, 320*200);
	t2 = timer_get_microseconds();
	if ((t2-t1) < fastest) fastest = t2-t1;
	timeb2v = t2 - t1;

	t1 = timer_get_microseconds();
	gr_linear_movsb(TempBuffer1, Video4, 320*200);
	t2 = timer_get_microseconds();
	t1 = timer_get_microseconds();
	gr_linear_movsb(TempBuffer1, Video4, 320*200);
	t2 = timer_get_microseconds();
	if ((t2-t1) < fastest) fastest = t2-t1;
	timeb4v = t2 - t1;

	t1 = timer_get_microseconds();
	gr_linear_movsb(TempBuffer1, System1, 320*200);
	t2 = timer_get_microseconds();
	t1 = timer_get_microseconds();
	gr_linear_movsb(TempBuffer1, System1, 320*200);
	t2 = timer_get_microseconds();
	if ((t2-t1) < fastest) fastest = t2-t1;
	timeb1s = t2 - t1;

	t1 = timer_get_microseconds();
	gr_linear_movsb(TempBuffer1, System2, 320*200);
	t2 = timer_get_microseconds();
	t1 = timer_get_microseconds();
	gr_linear_movsb(TempBuffer1, System2, 320*200);
	t2 = timer_get_microseconds();
	if ((t2-t1) < fastest) fastest = t2-t1;
	timeb2s = t2 - t1;

	t1 = timer_get_microseconds();
	gr_linear_movsb(TempBuffer1, System4, 320*200);
	t2 = timer_get_microseconds();
	t1 = timer_get_microseconds();
	gr_linear_movsb(TempBuffer1, System4, 320*200);
	t2 = timer_get_microseconds();
	if ((t2-t1) < fastest) fastest = t2-t1;
	timeb4s = t2 - t1;

	t1 = timer_get_microseconds();
	gr_linear_movsw(TempBuffer1, Video1, 320*200);
	t2 = timer_get_microseconds();
	t1 = timer_get_microseconds();
	gr_linear_movsw(TempBuffer1, Video1, 320*200);
	t2 = timer_get_microseconds();
	if ((t2-t1) < fastest) fastest = t2-t1;
	timew1v = t2 - t1;

	t1 = timer_get_microseconds();
	gr_linear_movsw(TempBuffer1, Video2, 320*200);
	t2 = timer_get_microseconds();
	t1 = timer_get_microseconds();
	gr_linear_movsw(TempBuffer1, Video2, 320*200);
	t2 = timer_get_microseconds();
	if ((t2-t1) < fastest) fastest = t2-t1;
	timew2v = t2 - t1;

	t1 = timer_get_microseconds();
	gr_linear_movsw(TempBuffer1, Video4, 320*200);
	t2 = timer_get_microseconds();
	t1 = timer_get_microseconds();
	gr_linear_movsw(TempBuffer1, Video4, 320*200);
	t2 = timer_get_microseconds();
	if ((t2-t1) < fastest) fastest = t2-t1;
	timew4v = t2 - t1;

	t1 = timer_get_microseconds();
	gr_linear_movsw(TempBuffer1, System1, 320*200);
	t2 = timer_get_microseconds();
	t1 = timer_get_microseconds();
	gr_linear_movsw(TempBuffer1, System1, 320*200);
	t2 = timer_get_microseconds();
	if ((t2-t1) < fastest) fastest = t2-t1;
	timew1s = t2 - t1;

	t1 = timer_get_microseconds();
	gr_linear_movsw(TempBuffer1, System2, 320*200);
	t2 = timer_get_microseconds();
	t1 = timer_get_microseconds();
	gr_linear_movsw(TempBuffer1, System2, 320*200);
	t2 = timer_get_microseconds();
	if ((t2-t1) < fastest) fastest = t2-t1;
	timew2s = t2 - t1;

	t1 = timer_get_microseconds();
	gr_linear_movsw(TempBuffer1, System4, 320*200);
	t2 = timer_get_microseconds();
	t1 = timer_get_microseconds();
	gr_linear_movsw(TempBuffer1, System4, 320*200);
	t2 = timer_get_microseconds();
	if ((t2-t1) < fastest) fastest = t2-t1;
	timew4s = t2 - t1;

	t1 = timer_get_microseconds();
	gr_linear_movsd(TempBuffer1, Video1, 320*200);
	t2 = timer_get_microseconds();
	t1 = timer_get_microseconds();
	gr_linear_movsd(TempBuffer1, Video1, 320*200);
	t2 = timer_get_microseconds();
	if ((t2-t1) < fastest) fastest = t2-t1;
	timed1v = t2 - t1;

	t1 = timer_get_microseconds();
	gr_linear_movsd(TempBuffer1, Video2, 320*200);
	t2 = timer_get_microseconds();
	t1 = timer_get_microseconds();
	gr_linear_movsd(TempBuffer1, Video2, 320*200);
	t2 = timer_get_microseconds();
	if ((t2-t1) < fastest) fastest = t2-t1;
	timed2v = t2 - t1;

	t1 = timer_get_microseconds();
	gr_linear_movsd(TempBuffer1, Video4, 320*200);
	t2 = timer_get_microseconds();
	t1 = timer_get_microseconds();
	gr_linear_movsd(TempBuffer1, Video4, 320*200);
	t2 = timer_get_microseconds();
	if ((t2-t1) < fastest) fastest = t2-t1;
	timed4v = t2 - t1;

	t1 = timer_get_microseconds();
	gr_linear_movsd(TempBuffer1, System1, 320*200);
	t2 = timer_get_microseconds();
	t1 = timer_get_microseconds();
	gr_linear_movsd(TempBuffer1, System1, 320*200);
	t2 = timer_get_microseconds();
	if ((t2-t1) < fastest) fastest = t2-t1;
	timed1s = t2 - t1;

	t1 = timer_get_microseconds();
	gr_linear_movsd(TempBuffer1, System2, 320*200);
	t2 = timer_get_microseconds();
	t1 = timer_get_microseconds();
	gr_linear_movsd(TempBuffer1, System2, 320*200);
	t2 = timer_get_microseconds();
	if ((t2-t1) < fastest) fastest = t2-t1;
	timed2s = t2 - t1;

	t1 = timer_get_microseconds();
	gr_linear_movsd(TempBuffer1, System4, 320*200);
	t2 = timer_get_microseconds();
	t1 = timer_get_microseconds();
	gr_linear_movsd(TempBuffer1, System4, 320*200);
	t2 = timer_get_microseconds();
	if ((t2-t1) < fastest) fastest = t2-t1;
	timed4s = t2 - t1;

	timer_close();
	gr_close();

	printf( "Relative memory move speeds: \n\n" );
	printf( "           Vid1  Vid2  Vid4  Sys1  Sys2  Sys4\n" );
	printf( "REP MOVSB: %#2.2f  %#2.2f  %#2.2f  %#2.2f  %#2.2f  %#2.2f\n", RelTime(timeb1v),RelTime(timeb2v),RelTime(timeb4v), RelTime(timeb1s),RelTime(timeb2s),RelTime(timeb4s) );
	printf( "REP MOVSW: %#2.2f  %#2.2f  %#2.2f  %#2.2f  %#2.2f  %#2.2f\n", RelTime(timew1v),RelTime(timew2v),RelTime(timew4v), RelTime(timew1s),RelTime(timew2s),RelTime(timew4s) );
	printf( "REP MOVSD: %#2.2f  %#2.2f  %#2.2f  %#2.2f  %#2.2f  %#2.2f\n", RelTime(timed1v),RelTime(timed2v),RelTime(timed4v), RelTime(timed1s),RelTime(timed2s),RelTime(timed4s) );

	printf( "\nA 1.00 corresponds to %d microseconds to move 320x200 unsigned chars.\n", fastest );

	return;
}
Exemplo n.º 6
0
void gr_ibitblt(grsBitmap *src_bmp, grsBitmap *dest_bmp, ubyte pixel_double)
{
	int x, y, sw, sh, srowSize, drowSize, dstart, sy, dy;
	ubyte *src, *dest;
	short *current_hole, *current_hole_length;

// variable setup

	sw = src_bmp->bmProps.w;
	sh = src_bmp->bmProps.h;
	srowSize = src_bmp->bmProps.rowSize;
	drowSize = dest_bmp->bmProps.rowSize;
	src = src_bmp->bmTexBuf;
	dest = dest_bmp->bmTexBuf;

	sy = 0;
	while (start_points[sy][0] == -1) {
		sy++;
		dest += drowSize;
	}

 	if (pixel_double) {
		ubyte *scan = (ubyte *)scanline;    // set up for byte processing of scanline

		dy = sy;
		for (y = sy; y < sy + sh; y++) {
			gr_linear_rep_movsd_2x(src, scan, sw); // was: gr_linear_movsd_double(src, scan, sw*2);
			current_hole = start_points[dy];
			current_hole_length = hole_length[dy];
			for (x = 0; x < MAX_HOLES; x++) {
				if (*current_hole == -1)
					break;
				dstart = *current_hole;
				gr_linear_movsd(&(scan[dstart]), &(dest[dstart]), *current_hole_length);
				current_hole++;
				current_hole_length++;
			}
			dy++;
			dest += drowSize;
			current_hole = start_points[dy];
			current_hole_length = hole_length[dy];
			for (x = 0;x < MAX_HOLES; x++) {
				if (*current_hole == -1)
					break;
				dstart = *current_hole;
				gr_linear_movsd(&(scan[dstart]), &(dest[dstart]), *current_hole_length);
				current_hole++;
				current_hole_length++;
			}
			dy++;
			dest += drowSize;
			src += srowSize;
		}
	} else {
		Assert(sw <= MAX_WIDTH);
		Assert(sh <= MAX_SCANLINES);
		for (y = sy; y < sy + sh; y++) {
			for (x = 0; x < MAX_HOLES; x++) {
				if (start_points[y][x] == -1)
					break;
				dstart = start_points[y][x];
				gr_linear_movsd(&(src[dstart]), &(dest[dstart]), hole_length[y][x]);
			}
			dest += drowSize;
			src += srowSize;
		}
	}
}