#include #include #include #include #include #include #include #include #include extern struct GfxBase *GfxBase; extern far struct Custom custom; #define COPIES (100) int main(void) { // reserve two 320x200 bitplanes // take over the system // for 1000 loops // * run blitter copies, setting up new registers each time // * do CPU copies // give the system back // print the timings of each struct View *OldView; ULONG OldCopper; UWORD OldDMACON, OldINTENA, OldINTREQ, OldADKCON; unsigned int startTime[2], blitTime[2], copyTime[2]; unsigned char *source, *target, check; ULONG blitTimeFinal, copyTimeFinal; int i, j; OldView = ((struct GfxBase *)GfxBase)->ActiView; OldCopper = (ULONG)((struct GfxBase *)GfxBase)->copinit; LoadView(NULL); WaitTOF(); WaitTOF(); OwnBlitter(); WaitBlit(); Forbid(); OldDMACON = custom.dmaconr | 0x8000; OldINTENA = custom.intenar | 0x8000; OldINTREQ = custom.intreqr | 0x8000; OldADKCON = custom.adkconr | 0x8000; custom.dmacon = DMAF_SETCLR | DMAF_BLITTER; custom.dmacon = DMAF_AUDIO | DMAF_DISK | DMAF_SPRITE | DMAF_COPPER | DMAF_RASTER; source = AllocMem(320 * 200 / 8, MEMF_CHIP | MEMF_CLEAR); target = AllocMem(320 * 200 / 8, MEMF_CHIP | MEMF_CLEAR); *(source) = 1; timer(startTime); for (i = 0; i < COPIES; ++i) { // a and d custom.bltcon0 = (1 << 8) + (1 << 11); custom.bltcon1 = 0; custom.bltapt = source; custom.bltdpt = target; custom.bltamod = 0; custom.bltdmod = 0; custom.bltsize = (320 / 16) + (200 << 6); WaitBlit(); } timer(blitTime); for (i = 0; i < COPIES; ++i) { for (j = 0; j < (320 * 200 / 8); ++j) { target[j] = source[j]; } } timer(copyTime); check = *(source); FreeMem(source, 320 * 200 / 8); FreeMem(target, 320 * 200 / 8); custom.dmacon = 0x7FFF; custom.dmacon = OldDMACON; custom.intena = 0x7FFF; custom.intena = OldINTENA; custom.intreq = 0x7FFF; custom.intreq = OldINTREQ; custom.adkcon = 0x7FFF; custom.adkcon = OldADKCON; custom.cop1lc = OldCopper; LoadView(OldView); WaitTOF(); WaitTOF(); WaitBlit(); DisownBlitter(); Permit(); blitTimeFinal = (blitTime[0] - startTime[0]) * 1000000 + (blitTime[1] - startTime[1]); copyTimeFinal = (copyTime[0] - blitTime[0]) * 1000000 + (copyTime[1] - blitTime[1]); printf("Number of 320x200/8 copies: %d\n", COPIES); printf("Blitter (microsecond): %d\n", blitTimeFinal); printf("CPU (microsecond): %d\n", copyTimeFinal); return 0; }