{ The doc file for interrup.inc by Kari Lammassaari/Finland 1997 } The general information: INTERRUP.INC allows user to program interrupt driven routines in Turbo Pascal. ( as on interval gosub in BASIC ) The interrupt service routines can be coded with pascal or machine code, BUT REMEMBER, that MSX DOS is not re-entrant. The interrupt service routines CANNOT use MSXDOS functions, because the internal stack of MSX DOS would be written over. (For instance WRITE, WRITELN and all disk I/O routines cannot be used by interrupt service routine. Use MC-coded procedures instead ,for example FastWrite/ FastWriteln or other rewritten procedures.) Turbo Pascal standard INPUT/OUTPUT procedures are NOT re-entrant as well. The IntervalValue (1..255) given to SetInterrupt-procedure determines the frequency the interrupt service routine will be called. 1 = interrupt service procedure will be called with every z80 interrupt. 50 = normally once in a second. 100 = every two seconds and so on ... 255 = something every 5th second REM ! Some standard Turbo Pascal procedures/functions prevent z80-interrupt. For example Read/Readln . Use structure "If Keypressed Then ReadLn(variable);" to allow interrupt to occur. REM ! SetInterrupt directs Turbo Pascal internal variable ErrorPtr to RemoveInterrupt-procedure. Change code if you have an error handler routine in your code. * * * INTERRUP.INC contains follwing variables and procedures : Var OldInt :Array[0..2] Of Byte; {Stores original int address.} DosInt :Array[0..2] Of Byte Absolute $0038;{The jump address at #0038 } IntervalCounter :Integer; {Contains counter and control value. DON`T use it. It will used and updated internally.} Procedure Interrupt; - This procedure is NEVER called by Pascal. - It's the code, where the interrupt is redirected to. Procedure RemoveInterrupt; - Removes interrupt and restores jump at $0038 . - REMEMBER to set this at the end of the program or your system will crash. Procedure SetInterrupt(IntProcAddr:Integer;IntervalValue:Byte); - Installs interrupt service routine. - IntProcAddr is the address of the interrupt service procedure, for example Addr(IntService). (IntService is normal pascal procedure in the program.) - IntervalValue (1..255) determines how often the interrupt service routine will be called. (Value 50 = approximately once in second.) - REM ! This procedure redirects Turbo Pascal variable ErrorPtr to RemoveInterrupt to prevent the system crash within an error condition.