1 /*************************************************************************
\r
5 Demonstrates the speed difference between compiled bitmap, conventional
\r
6 masked planar bitmap, and video bitmap blits.
\r
8 **************************************************************************/
\r
19 #include "xcbitmap.h"
\r
20 #include "xpbitmap.h"
\r
21 #include "xvbitmap.h"
\r
22 #include "xbmtools.h"
\r
27 /* Macro to make pointer parameters model independent */
\r
28 #define FARPTR(x) (MK_FP(FP_SEG(x),FP_OFF(x)))
\r
32 /* | . | . | . | . */
\r
33 8,14, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
\r
34 8, 2,14, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
\r
35 8, 2, 2, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
\r
36 8, 0, 2,14, 0, 0,14,14,14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
\r
37 8, 0, 2, 5, 0, 4, 4, 4, 4,14,14, 0, 0, 0, 0, 0, 0, 0, 0, 0,
\r
38 8, 0, 2, 2, 4, 4, 0, 4, 4, 0, 4,14, 0, 0, 0, 0, 0, 0, 0, 0,
\r
39 0, 0, 2, 4, 4, 4, 0, 4, 4, 0, 4, 4,14, 0, 0, 0, 0, 0, 0, 0,
\r
40 0, 0, 2, 4, 4, 4, 0, 0, 0, 0, 4, 4,14, 0, 0, 0, 0, 0, 0, 0,
\r
41 0, 0, 0, 0, 4, 0, 4, 4, 4, 0, 0, 0, 4, 0, 0, 2, 2, 0, 0, 0,
\r
42 0, 0, 0, 4, 0, 4, 4, 4, 0, 4, 4, 4, 0,14, 0, 0, 2, 2, 0, 0,
\r
43 0, 0, 0, 4, 4, 0, 0, 0, 4, 4, 0, 4, 0, 4, 2, 2, 2, 2, 0, 0,
\r
44 0, 0, 0, 4, 4, 4, 0, 4, 4, 0, 4, 4, 0, 4,14, 2, 2, 2, 0, 0,
\r
45 0, 0, 0, 4, 4, 4, 0, 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 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0,
\r
62 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
\r
66 char far *pbm, far *vbm;
\r
70 AllocatedSprite(int width, int height, int logical_width, char far * bitmap)
\r
75 pbm = farmalloc(width * height + 2);
\r
76 x_bm_to_pbm(bitmap,pbm);
\r
78 result = farmalloc((width * height * 7) / 2 + 25);
\r
81 size = x_compile_bitmap(logical_width, bitmap, result);
\r
83 return farrealloc(result, size);
\r
88 void load_user_fonts(){
\r
91 // f=fopen("c:\\font.fnt","rb");
\r
92 f=fopen("smalbold.fnt","rb");
\r
93 newfnt = farmalloc(256*16+4);
\r
94 for (i=0;i<256*16+4;i++){
\r
100 x_register_userfont(newfnt);
\r
109 double ratio,ratio2;
\r
110 struct time pbm_t0,pbm_t1,cbm_t0,cbm_t1,vbm_t0,vbm_t1;
\r
111 long vbm_ticks,pbm_ticks,cbm_ticks;
\r
112 char far * TurtleSprite;
\r
114 x_set_mode(X_MODE_320x240,360);
\r
116 TurtleSprite = AllocatedSprite(20, 30, 90,FARPTR(turtle));
\r
118 vbm = x_make_vbm(MK_FP(_DS,turtle),&NonVisual_Offs);
\r
126 x_bgprintf(0,0,0,14,0,
\r
127 "This is a demo to show the speed difference between");
\r
128 x_bgprintf(0,8,0,14,0,
\r
129 "compiled, planar and video bitmaps. The bitmap:");
\r
131 x_put_cbitmap(140, 18, 0, TurtleSprite);
\r
133 x_bgprintf(0,48,0,14,0,
\r
134 "This demo uses the NON CLIPPED, MASKED versions of");
\r
135 x_bgprintf(0,56,0,14,0,
\r
136 " 'PBM' and VBM' put functions");
\r
137 x_bgprintf(0,78,0,14,0,
\r
138 "Press a key to start with PLANAR BITMAP demo");
\r
141 x_rect_fill(0,0,ScrnPhysicalPixelWidth,ScrnPhysicalHeight,0,0);
\r
146 for (j=0;j<(ScrnPhysicalHeight/30);j++)
\r
147 for (i=0;i<(ScrnPhysicalPixelWidth/20);i++)
\r
148 x_put_masked_pbm(i*20, j*30, 0, pbm);
\r
150 pbm_ticks = (((long)pbm_t1.ti_hund
\r
151 +((long)pbm_t1.ti_sec*100)
\r
152 +((long)pbm_t1.ti_min*6000)) -
\r
153 (((long)pbm_t0.ti_hund
\r
154 +((long)pbm_t0.ti_sec*100)
\r
155 +((long)pbm_t0.ti_min*6000))));
\r
158 x_bgprintf(0,0,0,14,0,
\r
159 "Press a key to start with the VIDEO BITMAP demo");
\r
162 x_rect_fill(0,0,ScrnPhysicalPixelWidth,ScrnPhysicalHeight,0,0);
\r
167 for (j=0;j<(ScrnPhysicalHeight/30);j++)
\r
168 for (i=0;i<(ScrnPhysicalPixelWidth/20);i++)
\r
169 x_put_masked_vbm(i*20, j*30, 0, vbm);
\r
171 vbm_ticks = (((long)vbm_t1.ti_hund
\r
172 +((long)vbm_t1.ti_sec*100)
\r
173 +((long)vbm_t1.ti_min*6000)) -
\r
174 (((long)vbm_t0.ti_hund
\r
175 +((long)vbm_t0.ti_sec*100)
\r
176 +((long)vbm_t0.ti_min*6000))));
\r
181 x_bgprintf(0,0,0,14,0,
\r
182 "Now Press a key to start with COMPILED BITMAP demo");
\r
185 x_rect_fill(0,0,ScrnPhysicalPixelWidth,ScrnPhysicalHeight,0,0);
\r
189 for (j=0;j<(ScrnPhysicalHeight/30);j++)
\r
190 for (i=0;i<(ScrnPhysicalPixelWidth/20);i++)
\r
191 x_put_cbitmap(i*20, j*30, 0, TurtleSprite);
\r
193 cbm_ticks = (((long)cbm_t1.ti_hund
\r
194 +((long)cbm_t1.ti_sec*100)
\r
195 +((long)cbm_t1.ti_min*6000)) -
\r
196 (((long)cbm_t0.ti_hund
\r
197 +((long)cbm_t0.ti_sec*100)
\r
198 +((long)cbm_t0.ti_min*6000))));
\r
204 ratio = pbm_ticks*(double)1.0/cbm_ticks;
\r
205 ratio2 = vbm_ticks*(double)1.0/cbm_ticks;
\r
208 x_bgprintf(0,ScrnPhysicalHeight-30,0,14,0,
\r
209 "s/100 PBM=%ld VBM=%ld CBM=%ld - %4.1lf:%4.1lf:1",
\r
210 pbm_ticks,vbm_ticks,cbm_ticks,ratio,ratio2);
\r
212 x_bgprintf(0,ScrnPhysicalHeight-16,0,14,0,
\r
213 "Timing is rough but still, quite impressive ! ");
\r
214 x_bgprintf(0,ScrnPhysicalHeight-8,0,14,0,
\r
215 "Clipping slows things down considerably. ");
\r