convert line ends
[canaan.git] / prj / tech / libsrc / dev2d / mxfl8.c
blobf84e8c7888267afabce09595f17cdc3fb072634c
1 /*
2 * $Source: x:/prj/tech/libsrc/dev2d/RCS/mxfl8.c $
3 * $Revision: 1.3 $
4 * $Author: KEVIN $
5 * $Date: 1997/01/28 16:51:07 $
7 * Routines for drawing flat8 bitmaps onto a mode X canvas.
9 * This file is part of the dev2d library.
13 #include <grd.h>
14 #include <mxlatch.h>
16 #define BIG_BLIT_MINIMUM 0x4000 // 16k
17 #define PROC_DATA_CACHE 0x1000 // rough size of data cache
19 #ifdef __WATCOMC__
20 modex_memmove (uchar *s, uchar *d, int h, int s_row, int d_row);
21 #pragma aux modex_memmove = \
22 "L1:" \
23 "mov al,[esi]" \
24 "mov [edi],al" \
25 "add esi,ebx" \
26 "add edi,ecx" \
27 "dec edx" \
28 "jnz L1" \
29 parm [esi] [edi] [edx] [ebx] [ecx] \
30 modify [eax ecx edx];
31 #else
32 __inline modex_memmove (uchar *s, uchar *d, int h, int s_row, int d_row)
34 __asm
36 mov esi, s
37 mov edi, d
38 mov edx, h
39 mov ebx, s_row
40 mov ecx, d_row
41 L1:
42 mov al, [esi]
43 mov [edi], al
44 add esi, ebx
45 add edi, ecx
46 dec edx
47 jnz L1
50 #endif
52 void modex_flat8_trans_ubitmap (grs_bitmap *bm, short x, short y)
54 int i,j,k;
55 uchar *src, *dst;
56 uchar *s, *d;
57 uchar *p;
58 short w, h;
59 uchar save_wlatch;
61 wlatch_start(save_wlatch);
63 w = bm->w;
64 h = bm->h;
65 if ((h<=0)||(w<=0)) return;
66 p = grd_bm.bits+grd_bm.row*y;
67 x += grd_bm.align;
68 for (i=0; i<4; i++) {
69 src=bm->bits+i;
70 dst=p+(x>>2);
71 modex_force_wlatch(1<<(x&3));
72 for (j=(w+3)>>2; j>0; j--) {
73 s=src; d=dst;
74 for (k=0; k<h; k++) {
75 if (*s) *d=*s;
76 s+=bm->row;
77 d+=grd_bm.row;
79 src+=4;
80 dst++;
82 x++;
83 if (--w==0) break;
86 wlatch_restore(save_wlatch);
89 void modex_flat8_opaque_ubitmap (grs_bitmap *bm, short x, short y)
91 int i,j;
92 uchar *src, *dst;
93 uchar *p;
94 short w, h;
95 uchar save_wlatch;
97 wlatch_start(save_wlatch);
99 w = bm->w;
100 h = bm->h;
101 if ((h<=0)||(w<=0)) return;
102 p = grd_bm.bits+grd_bm.row*y;
103 x += grd_bm.align;
104 if (w * h > BIG_BLIT_MINIMUM) {
105 int nh;
106 // too big to fit in cache, so draw in smaller chunks that fit
107 nh = PROC_DATA_CACHE / w;
108 y = 0;
109 while (h) {
110 if (h < nh) nh = h;
111 for (i=0; i < 4; i++) {
112 src = bm->bits+i+bm->row*y;
113 dst = p + ((x+i)>>2) + (grd_bm.row*y);
114 modex_force_wlatch(1<<((x+i)&3));
115 // assume we're more horizontal than vertical
116 for(j=nh; j > 0; j--) {
117 modex_memmove(src,dst,(w+3)>>2,4,1);
118 src += bm->row;
119 dst += grd_bm.row;
121 --w;
123 w += 4;
124 y += nh;
125 h -= nh;
127 } else {
128 for (i=0; i<4; i++) {
129 src = bm->bits+i;
130 dst = p + (x>>2);
131 modex_force_wlatch(1<<(x&3));
132 for (j=(w+3)>>2; j>0; j--) {
133 modex_memmove(src,dst,h,bm->row,grd_bm.row);
134 src += 4;
135 dst++;
137 x++;
138 if (--w==0) break;
142 wlatch_restore(save_wlatch);