pumpkin6
asked on
tsr running every second
how do make my tsr popup every second? some info on hooking the interrupt $1c or $8???
Do you want a TSR or just how to work with the PIC and Timer???
ASKER
i already have tsr made, and it runs with hotkey, but it is the every second update I want to be done, SO the TSR will be processed every second. It is a simple program grabing the screen text and directing it to LCD connected to LPT1. As i said ti works fine with hotkey, but i don't want to be pushing the damn key every second. I also got some reply this mornig, that int $1c cuold be hooked.
Any pascal reference?
Any pascal reference?
Can this be of any help???
************************** ********** ********** ********** ***
{$G+,A+,O-,B-,N-,E+}
UNIT UCLOCK;
INTERFACE
VAR
ClockInstalled: Boolean;
CooX,CooY,C1: Byte;
Old_SS,HH,MM,_S,SSS: Word;
HST,MST,SST,AmPm: String[2];
Procedure InstallClock(YesNo: Boolean);
IMPLEMENTATION
USES
CRT;
CONST
ClockInt = $08;
VAR
Save_ExitProc: Pointer;
OldClkVec: Procedure;
Procedure GetIntVec(IntNo: Byte; VAR Vector: Pointer); ASSEMBLER;
ASM
MOV AL,IntNo
MOV AH,$35
INT $21
MOV AX,ES
LES DI,Vector
CLD
XCHG AX,BX
STOSW
XCHG AX,BX
STOSW
END;
Procedure SetIntVec(IntNo: Byte; Vector: Pointer); ASSEMBLER;
ASM
PUSH DS
LDS DX,Vector
MOV AL,IntNo
MOV AH,$25
INT $21
POP DS
END;
Procedure _GetTime(VAR _HOR,_MIN,_SEG,_SEC: Word); ASSEMBLER;
ASM
MOV AH,2CH
INT 21H
XOR AH,AH
MOV AL,DL
LES DI,_SEC
STOSW
MOV AL,DH
LES DI,_SEG
STOSW
MOV AL,CL
LES DI,_MIN
STOSW
MOV AL,CH
LES DI,_HOR
STOSW
END;
{$F+}
Procedure Clock(Flags,CS,IP,AX,BX,CX ,DX,SI,DI, DS,ES,BP: Word); INTERRUPT;
VAR
_String: String[10];
SaveColor,SaveX,SaveY: Byte;
Begin
InLine($FA); { CLI }
ASM
PUSHF
CALL OldClkVec;
END;
_GetTime(HH,MM,_S,SSS);
If Old_SS <> _S Then
Begin
Old_SS:=_S;
If HH >= 12 Then
AmPm:='pm'
Else
AmPm:='am';
If HH > 12 Then
HH:=HH-12;
STR(HH:2,HST);
STR(MM:2,MST);
STR(_S:2,SST);
If MST[1]=' ' Then
MST[1]:='0';
If SST[1]=' ' Then
SST[1]:='0';
_String:=HST+':'+MST+':'+S ST+AmPm;
SaveColor:=TextAttr;
SaveX:=WhereX;
SaveY:=WhereY;
TextColor(C1);
GotoXY(CooX,CooY);
Write(_String);
TextColor(SaveColor);
GotoXY(SaveX,SaveY)
End;
InLine($FB); { STI }
Port[$20]:=$20
End;
{$F-}
Procedure My_ExitProc; FAR;
Begin
ExitProc:=Save_ExitProc;
If ClockInstalled Then
Begin
SetIntVec(ClockInt,ADDR(Ol dClkVec));
ClockInstalled:=FALSE
End
End;
Procedure InstallClock;
Begin
If YesNo AND Not(ClockInstalled) Then
Begin
GetIntVec(ClockInt,ADDR(Ol dClkVec));
SetIntVec(ClockInt,ADDR(Cl ock));
ClockInstalled:=TRUE
End
Else If Not(YesNo) AND ClockInstalled Then
Begin
SetIntVec(ClockInt,ADDR(Ol dClkVec));
ClockInstalled:=FALSE
End
End;
Begin
Old_SS:=100; _S:=0;
Save_ExitProc:=ExitProc;
ExitProc:=Addr(My_ExitProc );
ClockInstalled:=False;
End.
************************** ********** ********** ********** ***
Program ClockByInterrupt;
USES
CRT,UCLOCK;
VAR
Key: Char;
Begin
ClrScr;
C1:=RED;
CooX:=70;
CooY:=1;
InstallClock(True);
Repeat
If KeyPressed Then
Begin
Key:=ReadKey;
Write(Key);
If Key = #13 Then {If you press <ENTER> then}
Write(#10) {Cursor go down}
End
Until Key = #27; {Until you press <ESC>}
InstallClock(False);
End.
**************************
{$G+,A+,O-,B-,N-,E+}
UNIT UCLOCK;
INTERFACE
VAR
ClockInstalled: Boolean;
CooX,CooY,C1: Byte;
Old_SS,HH,MM,_S,SSS: Word;
HST,MST,SST,AmPm: String[2];
Procedure InstallClock(YesNo: Boolean);
IMPLEMENTATION
USES
CRT;
CONST
ClockInt = $08;
VAR
Save_ExitProc: Pointer;
OldClkVec: Procedure;
Procedure GetIntVec(IntNo: Byte; VAR Vector: Pointer); ASSEMBLER;
ASM
MOV AL,IntNo
MOV AH,$35
INT $21
MOV AX,ES
LES DI,Vector
CLD
XCHG AX,BX
STOSW
XCHG AX,BX
STOSW
END;
Procedure SetIntVec(IntNo: Byte; Vector: Pointer); ASSEMBLER;
ASM
PUSH DS
LDS DX,Vector
MOV AL,IntNo
MOV AH,$25
INT $21
POP DS
END;
Procedure _GetTime(VAR _HOR,_MIN,_SEG,_SEC: Word); ASSEMBLER;
ASM
MOV AH,2CH
INT 21H
XOR AH,AH
MOV AL,DL
LES DI,_SEC
STOSW
MOV AL,DH
LES DI,_SEG
STOSW
MOV AL,CL
LES DI,_MIN
STOSW
MOV AL,CH
LES DI,_HOR
STOSW
END;
{$F+}
Procedure Clock(Flags,CS,IP,AX,BX,CX
VAR
_String: String[10];
SaveColor,SaveX,SaveY: Byte;
Begin
InLine($FA); { CLI }
ASM
PUSHF
CALL OldClkVec;
END;
_GetTime(HH,MM,_S,SSS);
If Old_SS <> _S Then
Begin
Old_SS:=_S;
If HH >= 12 Then
AmPm:='pm'
Else
AmPm:='am';
If HH > 12 Then
HH:=HH-12;
STR(HH:2,HST);
STR(MM:2,MST);
STR(_S:2,SST);
If MST[1]=' ' Then
MST[1]:='0';
If SST[1]=' ' Then
SST[1]:='0';
_String:=HST+':'+MST+':'+S
SaveColor:=TextAttr;
SaveX:=WhereX;
SaveY:=WhereY;
TextColor(C1);
GotoXY(CooX,CooY);
Write(_String);
TextColor(SaveColor);
GotoXY(SaveX,SaveY)
End;
InLine($FB); { STI }
Port[$20]:=$20
End;
{$F-}
Procedure My_ExitProc; FAR;
Begin
ExitProc:=Save_ExitProc;
If ClockInstalled Then
Begin
SetIntVec(ClockInt,ADDR(Ol
ClockInstalled:=FALSE
End
End;
Procedure InstallClock;
Begin
If YesNo AND Not(ClockInstalled) Then
Begin
GetIntVec(ClockInt,ADDR(Ol
SetIntVec(ClockInt,ADDR(Cl
ClockInstalled:=TRUE
End
Else If Not(YesNo) AND ClockInstalled Then
Begin
SetIntVec(ClockInt,ADDR(Ol
ClockInstalled:=FALSE
End
End;
Begin
Old_SS:=100; _S:=0;
Save_ExitProc:=ExitProc;
ExitProc:=Addr(My_ExitProc
ClockInstalled:=False;
End.
**************************
Program ClockByInterrupt;
USES
CRT,UCLOCK;
VAR
Key: Char;
Begin
ClrScr;
C1:=RED;
CooX:=70;
CooY:=1;
InstallClock(True);
Repeat
If KeyPressed Then
Begin
Key:=ReadKey;
Write(Key);
If Key = #13 Then {If you press <ENTER> then}
Write(#10) {Cursor go down}
End
Until Key = #27; {Until you press <ESC>}
InstallClock(False);
End.
That's a bit of a LARGE answer, but I guess it'll work. You could simply hook int $1C and keep a counter so that your proc is only executed once every 18 ticks (This is roughly correct, a more exact factor is 18.2).
Alternatively, you could mess with the PIT and set the interrupt frequency of int $8 to 100 (or 1000 or 18, whatever you decide) times a second, then keep two counters so that you call the original intterupt once every 5 or 6 (5.4) calls, and your procedure once every 100 calls.
You decide :-)
Alternatively, you could mess with the PIT and set the interrupt frequency of int $8 to 100 (or 1000 or 18, whatever you decide) times a second, then keep two counters so that you call the original intterupt once every 5 or 6 (5.4) calls, and your procedure once every 100 calls.
You decide :-)
ASKER
but i can call my procedure with exising int $8 about once every 18.2 tick, can't I??
I've hooked thet MF int and made my own handler...
Update will follow upon the testing!
I've hooked thet MF int and made my own handler...
Update will follow upon the testing!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Also add StartUpdater; under the last begin... :-)
ASKER
I think this will be good solution to my problem...
Thanx
Thanx