There already are Interrupt routines made for Qbasic to PDS.

by (Login burger2227)
R

 
'-----------------------------------------------------------------------
' Interrupt procedure for Qbasic 1. Works in the same way as its QB 4.5 counterpart.
'-----------------------------------------------------------------------
' InterruptX procedure for QBASIC using INTERUPT
' (c) 1992 Hans Lunsing
' ----------------------------------------------------------------------
'Cannot use '$INCLUDE 'QB.BI' file in QBasic 1.1! It uses no library!
DEFINT A-Z
TYPE RegType 'Register type for use with INTERUPT
ax AS INTEGER
BX AS INTEGER
CX AS INTEGER
DX AS INTEGER
BP AS INTEGER
SI AS INTEGER
DI AS INTEGER
Flags AS INTEGER
DS AS INTEGER
ES AS INTEGER
END TYPE

DECLARE SUB INTERUPT (IntNo%, Inreg AS RegType, OutReg AS RegType)

CONST FALSE = 0, TRUE = NOT FALSE

'-----------------------------------------------------------------------
' The machine code of the Interrupt procedure for InterruptX
'-----------------------------------------------------------------------
InterruptXASM: 'Hexadecimal representation of machine code
DATA 55,8B,EC,8B,5E,0C,8B,17,0A,F6,74,07,C7,07,FF,FF,E9,A7,00,8B
DATA 5E,06,8B,1F,2E,88,97,77,00,32,C0,80,FA,25,74,05,80,FA,26,75
DATA 02,0C,02,50,1E,06,56,57,9C,8B,76,0A,80,FA,20,7C,05,80,FA,30
DATA 7C,0A,81,7C,08,FF,FF,74,03,8B,6C,08,8B,44,0E,25,D5,0F,50,8B
DATA 04,8B,5C,02,8B,4C,04,8B,54,06,8B,7C,0C,FF,74,0A,81,7C,12,FF
DATA FF,74,03,8E,44,12,81,7C,10,FF,FF,74,03,8E,5C,10,5E,9D,CD,00
DATA 55,8B,EC,9C,83,C5,0E,F6,46,FE,02,74,02,45,45,1E,56,8E,5E,FC
DATA 8B,76,08,89,04,89,5C,02,89,4C,04,89,54,06,8F,44,0A,89,7C,0C
DATA 8F,44,10,8C,44,12,8F,44,0E,8F,44,08,F6,46,FE,02,74,02,44,44
DATA 9D,5F,5E,07,1F,58,5D,CA,08,00

'-----------------------------------------------------------------------
' Example program: get current video mode 3 = VGA
'-----------------------------------------------------------------------
DIM SHARED Regs AS RegType
Regs.ax = &HF00
'InterruptX &H10, Regs, Regs
CALL INTERUPT(&H10, Regs, Regs)
VideoMode = (Regs.ax AND &HFF)
PRINT "Video mode is "; VideoMode '3 = VGA
END

SUB INTERUPT (IntNo%, Inreg AS RegType, OutReg AS RegType) STATIC
IF NOT MachineCode% THEN 'dimension string array to hold machine code
REDIM ASMBuffer(0 TO 189) AS STRING * 1 'integer characters
RESTORE InterruptXASM
DEF SEG = VARSEG(ASMBuffer(0)) 'Get address of machine code
Offset% = VARPTR(ASMBuffer(0))
FOR i% = 0 TO 189
READ Code$
POKE Offset% + i%, VAL("&H" + Code$) 'converted to ASCII characters
NEXT i%
MachineCode% = TRUE 'Indicate availability of machine code
END IF
'The first Offset% parameter is used by the machine code modifying itself
CALL ABSOLUTE(IntNo%, Inreg, OutReg, Offset%, Offset%)
END SUB

If you are using just Qbasic, you can just DECLARE SUB INTERRUPT as it has no idea what that is and you do not need to Edit the original interrupt procedures you need at all. I only created INTERUPT so that it is compatable with QuickBbasic4.0 up to PDS.

Ted



    
This message has been edited by burger2227 on Dec 11, 2009 4:12 PM
This message has been edited by burger2227 on Dec 11, 2009 2:05 PM

Posted on Dec 11, 2009, 1:45 PM

Respond to this message   

Return to Index

 Copyright © 1999-2014 Network54. All rights reserved.   Terms of Use   Privacy Statement