/* Test mojej procedury c2p */ #include #include #include #include #include #include #include #include #include #include #define WIDTH 160 #define HEIGHT 128 #define DEPTH 8 #define REPEAT 50 extern void c2p(register __a0 UBYTE *chunky, register __a1 struct BitMap *bm); int main(int argc, char **argv) { UWORD width=WIDTH, height=HEIGHT; struct BitMap bitmap; LONG rassize; PLANEPTR plane; WORD bpr; struct EClockVal ecv1, ecv2; LONG freq; LONG diff; ULONG *chunky; struct Screen *s; LONG time; if (argc >= 3) { width = atoi(argv[1]) & 0xfff0; height = atoi(argv[2]); if (width == 0 || width > 320 || height == 0 || height > 256) { printf("Bad parameters!\n"); return(0); } } bpr = ((((width)+15)>>4)<<1); rassize = RASSIZE(width, height); if (plane = AllocMem(rassize * DEPTH, MEMF_CHIP|MEMF_CLEAR)) { LONG i; bitmap.BytesPerRow = bpr * DEPTH; bitmap.Rows = height; bitmap.Depth = DEPTH; bitmap.Flags = 0; bitmap.pad = 0; for (i = 0; i < DEPTH; i++) { bitmap.Planes[i] = plane + (i * bpr); } if (s = OpenScreenTags(NULL, SA_Width, width, SA_Height, height, SA_Depth, 8, SA_Exclusive, TRUE, SA_Title, "Chunky-to-planar test", SA_ShowTitle, FALSE, SA_Quiet, TRUE, SA_BitMap, &bitmap, TAG_DONE)) { if (chunky = AllocMem(width * height, MEMF_PUBLIC)) { for (i = 0; i < (width * height / 4); i++) { chunky[i] = 0x02020202; } freq = ReadEClock(&ecv1); for (i = 0; i < REPEAT; i++) { c2p((UBYTE *)chunky, &bitmap); } ReadEClock(&ecv2); diff = (ecv2.ev_lo - ecv1.ev_lo) / REPEAT; printf("Bitmapa %d x %d\n", width, height); freq = 100000000/freq; time = diff*freq; printf("Czas konwersji: %d.%05d ms = %d.%08d s\n", time/100000, time%100000, time/100000000, time%100000000); FreeMem(chunky, width * height); } CloseScreen(s); } FreeMem(plane, rassize * DEPTH); } return(0); }