home *** CD-ROM | disk | FTP | other *** search
- /*-------------------------------------------------------------------------
- * Mouse cursor movement in different video mode test (Lib calls)
- *
- * Copyright (c) 1988-1989, Microsoft Corporation. All rights reserved.
- *
- * library : MOUSE.LIB (6.25)
- * compiler : Microsoft C (5.10)
- * run : Make mouststx.mak
- * where x = s, c, m, or l for model
- * by : Ben Hsu June 4, 1986
- * Ben Hsu Feb. 29, 1988
- * Tom Hensel March 10, 1988
- * Added missing mouse tests
- * Tom Hensel November 11, 1988
- * Converted to 4 memory models
- *
- * Disclaimer: This code is example code only,
- * and does not warranty any product
- * as being Microsoft compatible.
- * Microsoft will not be held responsible
- * for claims made pertaining to this software.
- *
- -------------------------------------------------------------------------*/
-
- #include "mousetst.h"
-
- unsigned originalSegment, originalCallMask, originalOffset;
- int escState = 0, fUserSub = 0, cursorLevel = 0;
- int videoMode, fLightPenBigVert = FALSE;
-
- void
- main()
- {
-
- int status, cbuttons;
- int buttonStatus = 0, testChoice;
- unsigned originalSegmentTemp, originalCallMaskTemp, originalOffsetTemp;
-
- MouseResetAndStatus(&status, &cbuttons);
- if (status == 0) {
- puts("MOUSETST: Microsoft mouse not installed");
- exit(0);
- }
-
- /* Get original values and then restore them again */
-
- SwapInterruptSubroutines(&originalSegment,
- &originalCallMask,
- &originalOffset
- );
- originalSegmentTemp = originalSegment;
- originalCallMaskTemp = originalCallMask;
- originalOffsetTemp = originalOffset;
- SwapInterruptSubroutines(&originalSegmentTemp,
- &originalCallMaskTemp,
- &originalOffsetTemp
- );
- VideoModeSaveRestore(SAVE);
- ShowLogo();
- cls();
-
- SetCursor(10, 3);
- puts("Select video adapter to test:");
- SetCursor(12, 5);
- puts(" 0 for individual video mode test");
- SetCursor(12, 6);
- puts(" 1 for IBM Enhanced Graphics Adapter (EGA)");
- SetCursor(12, 7);
- puts(" 2 for IBM Color Graphics Adapter (CGA)");
- SetCursor(12, 8);
- puts(" 3 for IBM PS/2 Model 30 (MCGA)");
- SetCursor(12, 9);
- puts(" 4 for IBM PS/2 Model 50, 60, 80 (VGA)");
- SetCursor(12, 10);
- puts(" 5 for IBM Monochrome display Adapter");
- SetCursor(12, 11);
- puts(" 6 for AT&T (Olivetti) display");
- SetCursor(12, 12);
- puts(" 7 for Toshiba 2100, 3100 display");
- SetCursor(10, 14);
- puts("Any other key to EXIT");
- ClearKB();
- testChoice = getch();
- cls();
- switch (testChoice)
- {
- case '0':
- IndividualTest();
- break;
- case '1':
- EGATest();
- break;
- case '2':
- CGATest();
- break;
- case '3':
- MCGATest();
- break;
- case '4':
- VGATest();
- break;
- case '5':
- MONOTest();
- break;
- case '6':
- ATTTest();
- break;
- case '7':
- TOSHTest();
- break;
- default:
- Cleanup();
- exit(-1);
- }
-
- Cleanup();
- }
-
- void IndividualTest()
- {
- int fGraphics;
-
- SetCursor(0, 5);
- printf("Input video mode and text(0)/graphics flag(1) : ");
- scanf("%u %u", &videoMode, &fGraphics);
- cls();
- /* fLightPenBigVert is unknown. Set it to true if vertical scan
- lines > 200 */
-
- if (fGraphics)
- MouseTest(videoMode, INDIVIDUAL, GRAPHICS);
- else
- MouseTest(videoMode, INDIVIDUAL, TEXT);
-
- }
-
- void ATTTest()
- {
-
- for ( videoMode = 0; videoMode <= 3; videoMode++ )
- MouseTest(videoMode, ATT, TEXT);
-
- for ( videoMode = 4; videoMode <= 6; videoMode++ )
- MouseTest(videoMode, ATT, GRAPHICS);
-
- fLightPenBigVert = TRUE;
- videoMode = 0x40;
- MouseTest(videoMode, ATT, GRAPHICS);
-
- }
-
- void CGATest()
- {
-
- for ( videoMode = 0; videoMode <= 3; videoMode++ )
- MouseTest(videoMode, CGA, TEXT);
-
- for ( videoMode = 4; videoMode <= 6; videoMode++ )
- MouseTest(videoMode, CGA, GRAPHICS);
- }
-
- void EGATest()
- {
-
- for ( videoMode = 0; videoMode <= 3; videoMode++ )
- MouseTest(videoMode, EGA, TEXT);
-
- for ( videoMode = 4; videoMode <= 6; videoMode++ )
- MouseTest(videoMode, EGA, GRAPHICS);
-
- for ( videoMode = 0xD; videoMode <= 0xE; videoMode++ )
- MouseTest(videoMode, EGA, GRAPHICS);
-
- fLightPenBigVert = TRUE;
- videoMode = 0x10;
- MouseTest(videoMode, EGA, GRAPHICS);
-
- }
-
- void MCGATest()
- {
-
- for ( videoMode = 0; videoMode <= 3; videoMode++ )
- MouseTest(videoMode, MCGA, TEXT);
-
- for ( videoMode = 4; videoMode <= 6; videoMode++ )
- MouseTest(videoMode, MCGA, GRAPHICS);
-
- fLightPenBigVert = TRUE;
- videoMode = 0x11;
- MouseTest(videoMode, MCGA, GRAPHICS);
-
- videoMode = 0x13;
- MouseTest(videoMode, MCGA, GRAPHICS);
-
- }
-
- void MONOTest()
- {
-
- videoMode = 7;
- MouseTest(videoMode, MONO, TEXT);
- }
-
- void TOSHTest()
- {
-
- for ( videoMode = 0; videoMode <= 3; videoMode++ )
- MouseTest(videoMode, TOSH, TEXT);
-
- for ( videoMode = 4; videoMode <= 6; videoMode++ )
- MouseTest(videoMode, TOSH, GRAPHICS);
-
- fLightPenBigVert = TRUE;
- videoMode = 0x74;
- MouseTest(videoMode, TOSH, GRAPHICS);
-
- }
-
- void VGATest()
- {
-
- for ( videoMode = 0; videoMode <= 3; videoMode++ )
- MouseTest(videoMode, VGA, TEXT);
-
- for ( videoMode = 4; videoMode <= 6; videoMode++ )
- MouseTest(videoMode, VGA, GRAPHICS);
-
- videoMode = 7;
- MouseTest(videoMode, VGA, TEXT);
-
- for ( videoMode = 0xD; videoMode <= 0x13; videoMode++ )
- {
- if (videoMode == 0xF)
- fLightPenBigVert = TRUE;
- MouseTest(videoMode, VGA, GRAPHICS);
- }
-
- }
-
- void MouseTest(videoMode, videoCard, fGraphics)
- int videoMode, videoCard, fGraphics;
- {
-
- int status, cbuttons;
-
- SetVideoMode(videoMode);
-
- switch (videoCard)
- {
- case INDIVIDUAL:
- if (fGraphics)
- printf("Individual Graphics Mode %xh\n", videoMode);
- else
- printf("Individual Text Mode %xh\n", videoMode);
- break;
- case ATT:
- if (fGraphics)
- printf("AT&T (Olivetti) Graphics Mode %xh\n",
- videoMode
- );
- else
- printf("AT&T (Olivetti) Text Mode %xh\n", videoMode);
- break;
- case CGA:
- if (fGraphics)
- printf("IBM CGA Graphics Mode %xh\n", videoMode);
- else
- printf("IBM CGA Text Mode %xh\n", videoMode);
- break;
- case EGA:
- if (fGraphics)
- printf("IBM EGA Graphics Mode %xh\n", videoMode);
- else
- printf("IBM EGA Text Mode %xh\n", videoMode);
- break;
- case MCGA:
- if (fGraphics)
- printf("IBM PS/2 Model 30 Graphics Mode %xh\n",
- videoMode
- );
- else
- printf("IBM PS/2 Model 30 Text Mode %xh\n", videoMode);
- break;
- case MONO:
- printf("\nIBM Monochrome Text Mode %xh\n", videoMode);
- break;
- case VGA:
- if (fGraphics)
- printf("IBM PS/2 Model 50,60,80 Graphics Mode %xh\n",
- videoMode
- );
- else
- printf("IBM PS/2 Model 50,60,80 Text Mode %xh\n",
- videoMode
- );
- break;
- case TOSH:
- if (fGraphics)
- printf("Toshiba 2100, 3100 Graphics Mode %xh\n",
- videoMode
- );
- else
- printf("Toshiba 2100, 3100 Text Mode %xh\n", videoMode);
- break;
- default:
- printf("Unknown video card Mode %xh\n", videoMode);
- break;
- }
-
- printf("LEFT Button for current mouse location\n");
- printf("RIGHT Button or key to select functions\n");
- printf("BOTH Buttons to change video mode\n");
- printf("ESC Key to toggle light pen emulation");
- MouseResetAndStatus(&status, &cbuttons);
-
- if (fGraphics)
- GMouse();
-
- ShowCursor();
- ScreenPixel();
- cursorLevel = 0; /* New mode re-initializes cursor level */
- fUserSub = 0; /* No user sub defined */
- }
-
- void ScreenPixel()
- {
-
- int buttonStatus = 0;
- unsigned horizontalPosition, verticalPosition, row = 0, column = 0;
-
- MInput(&buttonStatus, &horizontalPosition, &verticalPosition);
- while (buttonStatus != BOTH) {
- if (buttonStatus == RIGHT) {
- HideCursor();
- SetCursor(0, 1);
- BlankLine();
- SetCursor(0, 2);
- BlankLine();
- SetCursor(0, 3);
- BlankLine();
- SetCursor(0, 4);
- BlankLine();
- SetCursor(0, 5);
- BlankLine();
- SetCursor(0, 3);
- cprintf("Mouse Function Call Test Menu:");
- FunctionSelect();
- SetCursor(0, 1);
- printf("LEFT Button for current mouse location\n");
- printf("RIGHT Button or key to select functions\n");
- printf("BOTH Buttons to change video mode\n");
- printf("ESC Key to toggle light pen emulation\n");
- BlankLine();
- ShowCursor();
- }
- else if (buttonStatus == LEFT) {
- HideCursor();
- SetCursor(0, 5);
- BlankLine();
- SetCursor(0, 5);
- printf("x=%d, y=%d", horizontalPosition, verticalPosition);
- ShowCursor();
- }
- else {
- HideCursor();
- SetCursor(0, 5);
- BlankLine();
- ReadLightPenPosition(&horizontalPosition,
- &verticalPosition,
- &row,
- &column
- );
-
- if (! fLightPenBigVert)
- verticalPosition >>= 8;
-
- SetCursor(0, 5);
- printf("x=%u, y=%u, row = %u, column = %u",
- horizontalPosition,
- verticalPosition,
- row,
- column
- );
- ShowCursor();
- }
-
- if (fUserSub)
- CFunction12();
- buttonStatus = 0;
- MInput(&buttonStatus, &horizontalPosition, &verticalPosition);
- }
-
- }
-
- void GMouse()
- {
- int horizontalHotSpot = 1, verticalHotSpot = 1;
- static int screenAndCursorMasks[] =
- {
- /* screen mask */
- 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
- 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
- /* cursor mask */
- 0x0780, 0xb8b8, 0x3060, 0x6038, 0xf07e, 0x8841, 0xf031, 0x7020,
- 0x401c, 0x6006, 0x3c06, 0x03fe, 0x0001, 0xf001, 0x0301, 0x007c
- };
-
- SetGraphicsCursorBlock(horizontalHotSpot,
- verticalHotSpot,
- screenAndCursorMasks
- );
- }
-
- void MInput(pButtonStatus, pHorizontalPosition, pVerticalPosition)
- int *pButtonStatus;
- int *pHorizontalPosition;
- int *pVerticalPosition;
- {
-
- int key;
-
- while ( *pButtonStatus != LEFT &&
- *pButtonStatus != RIGHT &&
- *pButtonStatus != BOTH
- )
- {
-
- if (key = getchnowait())
- {
- if ((key & 0xFF) == ESC)
- escState ^= -1;
- else
- *pButtonStatus = RIGHT;
- break;
- }
- if (escState)
- break;
- else
- GetButtonStatusAndMousePosition(pButtonStatus,
- pHorizontalPosition,
- pVerticalPosition
- );
- }
- }
-