home *** CD-ROM | disk | FTP | other *** search
- /* Turbo ScrEdit Mouse interface Procedures */
-
- extern char
- S_MouseFirstTime;
-
- extern unsigned char
- S_MouseInstalled,
- S_MouseVisable,
- S_MsLeftPressed,
- S_MsRightPressed,
- S_MsMiddlePressed,
- S_MsLeftReleased,
- S_MsRightReleased,
- S_MsMiddleReleased;
-
- extern int
- S_MsRowHold,
- S_MsColHold,
- S_MsRow,
- S_MsCol,
- S_Buttons;
-
- extern unsigned
- S_MsAx,
- S_MsBx,
- S_MsCx,
- S_MsDx;
-
- typedef struct{
- char far *Ptr[256];
- }S_Vectors;
- extern S_Vectors far *S_VectorRec;
-
- typedef struct {
- unsigned Ax, Bx, Cx, Dx;
- char MouseEvent;
- char MouseActive;
- } S_EventRecord;
- extern S_EventRecord far *S_Ms;
-
- static union REGS inreg, outreg;
- static struct SREGS seg;
- static char S_PreviousEvent[9];
- void far S_SetMouseFlags (void)
- {
- S_Vectors far *S_VectorRec;
- S_EventRecord far *S_Ms2;
- unsigned int a,b,c,d;
-
- a = _AX;
- b = _BX;
- c = _CX;
- d = _DX;
-
- S_VectorRec = MK_FP(0x0000,0x0000);
- S_Ms2 = (S_EventRecord far *) S_VectorRec->Ptr[113];
-
- S_Ms2->Ax = a;
- S_Ms2->Bx = b;
- S_Ms2->Cx = c;
- S_Ms2->Dx = d;
- if (S_Ms2->MouseActive)
- S_Ms2->MouseEvent = 1;
- }
-
-
- void S_ResetMouse(void)
- {
- inreg.x.ax = 0;
- int86(0x33,&inreg,&outreg);
- }
-
-
-
- void S_InitMouse(void)
- {
- S_Ms = farmalloc(sizeof(S_EventRecord));
- S_VectorRec = MK_FP(0x0000,0x0000);
- S_VectorRec->Ptr[113] = (char far *)S_Ms;
-
- S_Ms->Ax = 0;
- S_Ms->Bx = 0;
- S_Ms->Cx = 0;
- S_Ms->Dx = 0;
- S_Ms->MouseActive = 0;
- S_Ms->MouseEvent = 0;
- S_MouseFirstTime = 0;
- S_Buttons = 0;
- S_MsRow = 0;
- S_MsRowHold = 0;
- S_MsCol = 0;
- S_MsColHold = 0;
- S_MouseVisable = 0;
- S_MsLeftPressed = 0;
- S_MsRightPressed = 0;
- S_MsMiddlePressed = 0;
- S_MsLeftReleased = 0;
- S_MsRightReleased = 0;
- S_MsMiddleReleased= 0;
- strcpy(S_PreviousEvent,"00000000");
- inreg.x.ax = 0;
- int86(0x33,&inreg,&outreg);
-
- if (outreg.x.ax != 0)
- {
- S_MouseInstalled = 1;
- S_Buttons = outreg.x.bx;
- inreg.x.ax = 10;
- inreg.x.bx = 0;
- inreg.x.cx = 0x0000;
- inreg.x.dx = 0x0718;
- int86(0x33,&inreg,&outreg);
- S_MsRow = 1;
- S_MsCol = 1;
- }
- else
- S_MouseInstalled = 0;
- }
-
-
-
-
-
-
- void S_SetMouseCursor(unsigned char Mask1L,
- unsigned char Mask1H,
- unsigned char Mask2L,
- unsigned char Mask2H)
- {
- typedef union
- {
- int word;
- struct{
- unsigned char H;
- unsigned char L;
- } byte;
- }BuildReg;
- static BuildReg X;
-
-
- if (S_MouseFirstTime) S_InitMouse();
- if (S_MouseInstalled)
- {
- inreg.x.ax = 10;
- inreg.x.bx = 0;
- X.byte.H = Mask1H;
- X.byte.L = Mask1L;
- inreg.x.cx = X.word;
- X.byte.H = Mask2H;
- X.byte.L = Mask2L;
- inreg.x.dx = X.word;
- int86(0x33,&inreg,&outreg);
- }
- }
-
-
-
-
-
-
- void S_ResetMouseFlags(void)
- {
- if (S_MouseFirstTime) S_InitMouse();
- S_MsLeftPressed = 0;
- S_MsRightPressed = 0;
- S_MsMiddlePressed = 0;
- S_MsLeftReleased = 0;
- S_MsRightReleased = 0;
- S_MsMiddleReleased = 0;
- }
-
-
- void S_SetMouseEvent(char *Bit)
- {
- char Work[9];
- int testlen;
- if (S_MouseFirstTime) S_InitMouse();
- if (S_MouseInstalled)
- {
- strcpy(Work,"00000000");
- if ((testlen = strlen(Bit))>8) testlen = 8;
- memmove(&Work[0],Bit,testlen);
- memcpy (&S_PreviousEvent[0],&Work[0],8);
- inreg.x.cx = 0;
-
- if (Work[0] == '1')
- inreg.x.cx+=1;
- if (Work[1] == '1')
- inreg.x.cx+=2;
- if (Work[2] == '1')
- inreg.x.cx+=4;
- if (Work[3] == '1')
- inreg.x.cx+=8;
- if (Work[4] == '1')
- inreg.x.cx+=16;
- if (Work[5] == '1')
- inreg.x.cx+=32;
- if (Work[6] == '1')
- inreg.x.cx+=64;
-
- inreg.x.ax = 12;
- inreg.x.dx = FP_OFF(S_SetMouseFlags);
- seg.es = FP_SEG(S_SetMouseFlags);
- int86x(0x33,&inreg,&outreg,&seg);
- }
- }
-
-
-
-
-
- void S_AnalizeMouse(void)
- {
- char s_work[20];
- if (S_MouseFirstTime) S_InitMouse();
- if (S_Ms->MouseActive)
- {
- itoa(S_Ms->Ax,s_work,2);
- if (S_Ms->Ax & 2)
- S_MsLeftPressed = 1;
- if (S_Ms->Ax & 4)
- S_MsLeftReleased = 1;
- if (S_Ms->Ax & 8)
- S_MsRightPressed = 1;
- if (S_Ms->Ax & 16)
- S_MsRightReleased = 1;
- if (S_Ms->Ax & 32)
- S_MsMiddlePressed = 1;
- if (S_Ms->Ax & 64)
- S_MsMiddleReleased = 1;
-
- if (S_Ms->Bx & 1)
- S_MsLeftPressed = 1;
- if (S_Ms->Bx & 2)
- S_MsRightPressed = 1;
- if (S_Ms->Bx & 4 )
- S_MsMiddlePressed = 1;
-
- S_MsCol = (S_Ms->Cx / 8) + 1;
- S_MsRow = (S_Ms->Dx / 8) + 1;
-
- S_Ms->Ax = 0;
- S_Ms->Cx = 0;
- S_Ms->Dx = 0;
-
- S_Ms->MouseEvent = 0;
- }
- }
-
-
-
-
-
- void S_MoveMouse(void)
- {
- if (S_MouseFirstTime) S_InitMouse();
- if (S_MouseInstalled)
- {
- inreg.x.ax = 4;
- inreg.x.cx = ((S_MsCol-1) * 8)+1;
- inreg.x.dx = ((S_MsRow-1) * 8)+1;
- int86(0x33,&inreg,&outreg);
- }
- }
-
-
-
-
-
-
- void S_SetMouseRange(int TopCol,
- int TopRow,
- int BotCol,
- int BotRow)
- {
- unsigned char Swap;
-
- if (S_MouseFirstTime) S_InitMouse();
- if (S_MouseInstalled)
- {
- if (TopCol < 1) TopCol = 1;
- if (TopCol > 80) TopCol = 80;
- if (TopRow < 1) TopRow = 1;
- if (TopRow > 25) TopRow = 25;
-
- if (BotCol < 1) BotCol = 1;
- if (BotCol > 80) BotCol = 80;
- if (BotRow < 1) BotRow = 1;
- if (BotRow > 25) BotRow = 25;
-
- if (TopRow > BotRow)
- {
- Swap = BotRow;
- BotRow = TopRow;
- TopRow = Swap;
- }
-
- if (TopCol > BotCol)
- {
- Swap = TopCol;
- TopCol = BotCol;
- BotCol = Swap;
- }
-
- inreg.x.ax = 7;
- inreg.x.cx = ((TopCol-1) * 8)+1;
- inreg.x.dx = ((BotCol-1) * 8)+1;
- int86(0x33,&inreg,&outreg);
-
- inreg.x.ax = 8;
- inreg.x.cx = ((TopRow-1) * 8)+1;
- inreg.x.dx = ((BotRow-1) * 8)+1;
- int86(0x33,&inreg,&outreg);
- }
- }
-
-
-
-
- void S_ShowMouse(void)
- {
- if (S_MouseFirstTime) S_InitMouse();
- if ((S_Ms->MouseActive)&&(!S_MouseVisable))
- {
- S_MouseVisable = 1;
- S_MoveMouse();
- }
- }
-
-
-
-
-
-
-
- void S_HideMouse(void)
- {
- if (S_MouseFirstTime) S_InitMouse();
- if ((S_Ms->MouseActive)&&(S_MouseVisable)) S_MouseVisable = 0;
- }
-
-
-
-
-
- void S_RemoveMouse(void)
- {
- if (S_MouseFirstTime) S_InitMouse();
- if (S_MouseInstalled)
- {
- if ((S_Ms->MouseActive)&&(S_MouseVisable))
- {
- inreg.x.ax = 2;
- int86(0x33,&inreg,&outreg);
- }
- }
- }
-
-
-
-
-
- void S_RestoreMouse(void)
- {
- if (S_MouseFirstTime) S_InitMouse();
- if (S_MouseInstalled)
- {
- if ((S_Ms->MouseActive)&&(S_MouseVisable))
- {
- inreg.x.ax = 1;
- int86(0x33,&inreg,&outreg);
- }
- }
- }
-
-
-
-
-
-
- void S_ActivateMouse(void)
- {
- if (S_MouseFirstTime) S_InitMouse();
- if (S_MouseInstalled)
- {
- S_Ms->MouseActive = 1;
- S_SetMouseEvent(S_PreviousEvent);
- }
- }
-
-
-
-
-
- void S_DisableMouse(void)
- {
- char S_HoldEvent[9];
- if (S_MouseFirstTime) S_InitMouse();
- if (S_Ms->MouseActive)
- {
- if (S_MouseVisable) S_RemoveMouse();
- strcpy(S_HoldEvent,S_PreviousEvent);
- S_SetMouseEvent("00000000");
- strcpy(S_PreviousEvent,S_HoldEvent);
- S_Ms->MouseActive = 0;
- }
- }
-