/* File name: mgenlc.c * Synopsis: This program allocates 2 grab buffers on the * unused bands of the Genesis LC display and * grabs in them. * This technique can be used when experiencing * grab over-runs on heavy loaded systems. * * When the display is in monochrome mode, it * uses only the blue surface and reserves the * red and green surfaces. This example shows * how to access this unused memory for grabbing * purposes. * Note: This example will only work with a * monochrome camera. */ /* Headers. */ #include #include #include #include /* Main function. */ void main(void) { MIL_ID MilApplication; MIL_ID MilSystem ; MIL_ID MilDigitizer ; MIL_ID MilDisplay ; MIL_ID MilImageOnBoard[2]; MIL_ID MilImageDisp; void *UnderlayPhysicalAddress = NULL; /* Allocations. */ MappAlloc(M_DEFAULT, &MilApplication); MsysAlloc(M_SYSTEM_GENESIS, M_DEF_SYSTEM_NUM, M_SETUP, &MilSystem); MdigAlloc(MilSystem, M_DEFAULT, M_DEF_DIGITIZER_FORMAT, M_DEFAULT, &MilDigitizer); MdispAlloc(MilSystem, M_DEFAULT, M_DEF_DISPLAY_FORMAT, M_DEFAULT, &MilDisplay); /* Force the display in monochrome mode on the blue plane. */ MdispControl(MilDisplay, M_COLOR_MODE, M_BLUE); /* Allocate a display buffer. */ MbufAlloc2d(MilSystem, (long)(MdigInquire(MilDigitizer, M_SIZE_X, M_NULL)), (long)(MdigInquire(MilDigitizer, M_SIZE_Y, M_NULL)), 8L+M_UNSIGNED, M_IMAGE+M_PROC+M_DISP+M_NON_PAGED, &MilImageDisp); MbufClear(MilImageDisp, 0); /* Inquire the base address of the underlay surface. */ MsysInquire(MilSystem, M_PHYSICAL_ADDRESS_UNDERLAY, &UnderlayPhysicalAddress); /* Create a buffer on the red surface (base address). */ MbufCreateColor(MilSystem, 1, (long)(MdigInquire(MilDigitizer, M_SIZE_X, M_NULL)), (long)(MdigInquire(MilDigitizer, M_SIZE_Y, M_NULL)), 8L+M_UNSIGNED, M_IMAGE+M_GRAB+M_PROC+M_ON_BOARD, M_PHYSICAL_ADDRESS+M_PITCH_BYTE, M_DEFAULT, (void *)&(UnderlayPhysicalAddress), &MilImageOnBoard[0]); /* Move to the green plane (base address+2MEG). */ UnderlayPhysicalAddress = ((unsigned long) UnderlayPhysicalAddress) + 0x200000; MbufCreateColor(MilSystem, 1, (long)(MdigInquire(MilDigitizer, M_SIZE_X, M_NULL)), (long)(MdigInquire(MilDigitizer, M_SIZE_Y, M_NULL)), 8L+M_UNSIGNED, M_IMAGE+M_GRAB+M_PROC+M_ON_BOARD, M_PHYSICAL_ADDRESS+M_PITCH_BYTE, M_DEFAULT, (void *)&(UnderlayPhysicalAddress), &MilImageOnBoard[1]); /* Enable bus master copies from the Genesis to the Host. */ MsysControl(MilSystem, M_BUS_MASTER_COPY_TO_HOST, M_ENABLE); /* Display the buffer. */ MdispSelect(MilDisplay, MilImageDisp); printf("Press enter to grab into the first buffer\n"); getchar(); /* Grab and copy to the Host. */ MdigGrab(MilDigitizer, MilImageOnBoard[0]); MbufCopy(MilImageOnBoard[0], MilImageDisp); printf("Press enter to grab into the second buffer\n"); getchar(); /* Grab and copy to the Host. */ MdigGrab(MilDigitizer, MilImageOnBoard[1]); MbufCopy(MilImageOnBoard[1], MilImageDisp); getchar(); /* Free allocations. */ MbufFree(MilImageOnBoard[0]); MbufFree(MilImageOnBoard[1]); MbufFree(MilImageDisp); MdispFree(MilDisplay); MdigFree(MilDigitizer); MsysFree(MilSystem); MappFree(MilApplication); }