Dec 092017
List of common BASIC peek and poke locations. | |||
---|---|---|---|
File Name | File Size | Zip Size | Zip Type |
BASIC.DOC | 20327 | 5460 | deflated |
TPCREAD.ME | 199 | 165 | deflated |
Download File BASICDOC.ZIP Here
Contents of the BASIC.DOC file
IBMSIG - The Source - Updated: 25 May 1986
BASIC PROGRAMMING
Basic Peeks, Pokes and Subroutines
This list of memory addresses which contain information about the status of
the PC and/or which may be modified to change the way the PC reacts to its
world and the programs to use this information have been compiled by a large
number of people. Some of it may be gleaned from the IBM Technical Reference
Manual and/or the BASIC manual. Some of it exists only because someone worked
very hard to find a way to make something happen. Some of it exists because
someone made a mistake and was presented with a new capability because of it.
No matter who found it or how the information was found this document
provides some really useful information for BASIC programmers. It even
provides good information for other programmers who will access directly the
PC memory.
Please submit new, corrected or better defined informtion to SysOp Mike Todd,
SIG003 on the IBMSIG on The Source so it may be kept up to date.
Suggestions about both content and format are welcome.
Sincere thanks to all those who have contributed!!! Mike Todd
BIOS LOCATIONS:
By specifying a DEF SEG=&H40 in any BASIC program, it is possible to
reference the following vectors (fields) in the ROM BIOS area by using a PEEK
function and the following offsets from the current segment as defined by the
DEF SEG statement.
Offset Comment/Example:
--------- ----------------------------------------------------------
&H0 - RS232 Addresses on your IBM PC. This will allow you to
tell how many (up to four) async cards are attached, if
any.
&H8 - Printer Addresses on your IBM PC. This will tell you what
printer addresses, and how many (up to four) exist. Each
is addressed by a two byte Hex value.
&H10 - Equipment Flag. This field describes the setting of the
options switches. It describes what optional devices are
attached to the system. The following lists the
bit-significance of this
field:
Bit 0 - Indicates that there are diskette
drives on the system.
0 = No diskettes
1 = 1 or more diskettes
Bit 1 - 8087.
0 = Not installed.
1 = Installed.
Bit 2,3 - Planar Ram Size
PC-1 XT and PC-2
00=16K 64K
10=32K 128K
01=48K 192K
11=64K 256K
Bit 4,5 - Initial Video Mode
00=Unused
10=40x25 Color
01=80x25 Color
11=80x25 Mono or both
Bit 6,7 - Number of Diskette Drives
(bit 0 = 1 in all cases)
00=1
10=2
01=3
11=4
Bit 8 - Unused
Bit 9,10,11 - Number of RS232 Cards attached
Bit 12 - Game I/O Attached
Bit 13 - Not used
Bit 14,15 - Number of printers attached
&H13 - Memory Size in K bytes.
&H15 - I/O RAM Size in K bytes.
&H17 - Keyboard Flag -- the following lists the masks
set to describe current keyboard status:
Byte 1;
&H80 - Insert state active
&H40 - Caps Lock State Has been toggled
&H20 - Num Lock State has been toggled
&H10 - Scroll Lock State has been toggled
&H08 - Alternate Shift key depressed
&H04 - Control Shift key depressed
&H02 - Left Shift key depressed
&H01 - Right Shift key depressed
Byte 2;
&H80 - Insert Key is depressed
&H40 - Caps Lock Key is depressed
&H20 - Num Lock Key is depressed
&H10 - Scroll Lock key is depressed
&H08 - Suspend key has been toggled
&H49 - Current CRT mode
&H00 - 40x25 BW
&H01 - 40x25 Color
&H02 - 80x25 BW
&H03 - 80x25 Color
&H04 - 320x200 Color
&H05 - 320x200 BW
&H06 - 640x200 BW
&H07 - 80x25 B&W Card -- specialized use, used
internal to the video routines.
&H4A - Number of CRT columns
&H50 - Cursor Position (one of eight)
&H60 - Current cursor mode
&H6C - Low word of Timer count
&H6E - High word of Timer count
&H71 - &H07 - Break key depressed
&HFA6E - Beginning of character regen memory
&HFF53 - PRTSC routine address
Following are some BASIC statements and subroutines showing how to use the
above information plus additional functions MASTER your PC!
KEYBOARD:
To disable entire keyboard:
DEF SEG=64: OUT 97,204
To re-enable keyboard:
DEF SEG=64: OUT 97,76
Clear line buffer:
DEF SEG: POKE 106,0
Clear Keyboard Buffer:
DEF SEG=0: POKE 1050,PEEK(1052)
NUM LOCK:
DEG SEG=&H40: POKE &H17,PEEK(&H17) OR 32 'To turn on
DEG SEG=&H40: POKE &H17,PEEK(&H17) AND 223 'To turn off
CAPS LOCK:
DEG SEG=&H40: POKE &H17,PEEK(&H17) OR 64 'To turn on
DEG SEG=&H40: POKE &H17,PEEK(&H17) AND 171 'To turn off
Restore Function Keys to Default values:
10 DEF SEG = &HFACE
20 K = 1
30 I = 13
40 T$ = STRING$(13,32): J = 1
50 T1 = PEEK(I):IF T1 < 0 THEN MID$(T$,J,1) = CHR$(T1):J = J + 1:
I = I + 1 : GOTO 50
60 KEY K,LEFT$(T$,J-1):IF K <10 THEN K = K + 1: I = I + 1: GOTO 40 :
ELSE KEY ON
Disable and re-enable CTRL+BREAK:
100 ' Subroutine to save old CTRL+BREAK address and set new to IRET
110 DIM OLD%(4)
120 DEF SEG=0
130 FOR I=&H6C TO &H6F
140 OLD%(I-&H6C)=PEEK(I) ' The array OLD%() must remain available
150 NEXT
160 ' establish new CTRL+BREAK address (point to IRET)
170 POKE &H6C,&H53
180 POKE &H6D,&HFF
190 POKE &H6E,&H0
200 POKE &H6F,&HF0
210 DEF SEG: RETURN ' CTRL+BREAK will return to the program
220 ' Subroutine to reset old CTRL+BREAK address
230 DEF SEG=0
240 FOR I=&H6C TO &H6F
250 POKE I,OLD%(I-&H6C)
260 NEXT
270 DEF SEG: RETURN ' CTRL+BREAK will interupt the program
SCREEN:
Determine Monitor type:
10 DEF SEG = 0
20 MONITOR.TYPE = PEEK(&H410) AND &H40
30 IF MONITOR.TYPE = 1 THEN PRINT "40 X 25 Color"
40 IF MONITOR.TYPE = 32 THEN PRINT "80 X 25 Color"
50 IF MONITOR.TYPE = 48 THEN PRINT "Monochrome"
60 IF MONITOR.TYPE = 64 THEN PRINT "Both"
Sitch displays on a system with both monochrome and color/graphics:
10 'Subroutine to switch to monochrome adaptor
20 DEF SEG=0
30 POKE &H410,(PEEK(&H410) OR &H30)
40 SCREEN 0 ' restore screen to text mode
50 WIDTH 80 ' restore screen width to 80
60 LOCATE ,,1,12,13 'restore cursor to "normal"
70 RETURN
80 ' Subroutine to switch to color adaptor. Change
90 ' SCREEN and WIDTH statements for different modes
100 DEF SEG=0
110 POKE &H410,(PEEK(&H410) AND &HCF) OR &H10
120 SCREEN 1,0,0,0 ' Medium resolution graphics, color,
active page 0, visual page 0
130 WIDTH 40 ' WIDTH 80 would force the screen to clear and
set to SCREEN 2 for high resolution
140 LOCATE ,,1,6,7 ' restore cursor to "normal" for color screen
150 RETURN
Subroutine to save and restore a screen image:
100 DEF SEG = &HB800 'Save screen image
110 INPUT "Enter name of file";FILENAME$ 'for color/graphics
120 BSAVE FILENAME$,0,&H4000 'display in text mode
130 RETURN
1000 INPUT "Enter name of file";FILENAME$ 'Restore image
1010 CLS
1020 DEF SEG = &HB800 'Change DEF SEG=&HB800
1030 BLOAD FILENAME$ 'to &HB000 for monochrome
Set split screen scroll window starting on line X ending on line Y:
DEF SEG: POKE 91,X: POKE 92,Y 'Sets up "window"
LOCATE X,C 'Place cursor "in" the scroll window at line X column C
Set window width:
DEF SEG: POKE 41,X 'Set window width to X
Set 16 background colors:
While WIDTH 40: OUT &H3D8,8
While WIDTH 80: OUT &H3D8,9
Use other than palate color 3 for characters in medium resolution
DEF SEG: POKE &H4E,COLOR (COLOR may be 1, 2, or 3)
DISKETTE DRIVES:
Read drive switches:
DEF SEG = 0: NUMBER.OF.DRIVES% = PEEK(&H410) AND &HC0
Current disk information:
DEF SEG=64
PEEK(69) - Track
PEEK(70) - Head
PEEK(71) - Sector
256^PEEK(72) - Bytes per sector
PRINTER:
Printer Status (works with IBM Dot Matrix and Epson printers)
DEF SEG=64
A=PEEK(8)+256*PEEK(9)
B=(INT(A+1) AND 248) XOR 72
IF (B AND 128)<>128 THEN PRINTER.STATUS="OFF LINE"
ELSE PRINTER.STATUS="ON LINE"
Initialize Printer:
DEF SEG=64
A=PEEK(8)+256*PEEK(9)
DEF SEG: OUT A+2,8
OUT A+2,12
Note: A is from Printer status routine
MEMORY:
Determine amount of memory installed (Only works for greater than 48k):
DEF SEG = 0: MEMORY% = PEEK(&H413)+(256*PEEK(&H414))
or, put another way:
Memory info: DEF SEG=0
((PEEK(1040) and 12) + 4 ) * 4 - Memory on Mother-board
PEEK(1045) + 256 * PEEK(1046) - Expansion memory (add on)
PEEK(1043) + 256 * PEEK(1044) - Total memory
GAME ADAPTER:
Determine if game adapter exists:
DEF SEG = 0: GAME.ADAPTER% = PEEK(&H411) AND &H10
IF GAME.ADAPTER% = 0 THEN GAME.ADAPTER$="No"
ELSE GAME.ADAPTER$="Yes --Installed"
MISCELLANEOUS:
Unprotect a BASIC program that was saved ",P:
First you must create a file to overlay the ,P setting. From the
DOS prompt start up BASICA or BASIC and enter the following BASIC
command:
BSAVE "UN.P",1124,1
This will create a file on your default drive named UN.P.
Next LOAD your program that had been saved using ",P. If it was
named MYPROG.BAS the BASIC command would be:
LOAD "MYPROG
Now to use the UN.P file to overlay the protection setting use the
following command:
BLOAD "UN.P",1124
You may now use the LIST, EDIT and SAVE commands as usual.
Following is a program by Richard Tremmel to print all the BASIC interrupts.
It is set to write the interrupt locations to a printer:
100 REM INT-LIST IBM-PC Software Interrupt Listing by Richard L. Tremmel
110 DEF SEG=0
120 DIM NAM$(255)
130 DEF FNJUSTIFY$(STRG$,LNGTH) = RIGHT$("0000"+STRG$,LNGTH)
140 TITLE$ = "INT ADDR VECTOR FUNCTION "
150 FOR I = 0 TO 255 : READ NAM$(I) : NEXT I
160 REM
170 OPEN "LPT1:" FOR OUTPUT AS #1 : PRINT #1,""
180 FOR PAGE = 1 TO 2
190 PRINT #1,CHR$(12); TITLE$; " "; TITLE$
200 FOR K = (PAGE-1)*128 TO (PAGE-1)*128+64-1
210 I = K : ADDRESS = I*4 : GOSUB 280 : PRINT #1," ";
220 I = K+64 : ADDRESS = I*4 : GOSUB 280 : PRINT #1,""
230 NEXT K
240 NEXT PAGE
250 CLOSE #1
260 SYSTEM
270 REM
280 PRINT #1," "; FNJUSTIFY$(HEX$(I),2);
290 PRINT #1," "; FNJUSTIFY$(HEX$(ADDRESS),4);
300 PRINT #1," "; FNJUSTIFY$(HEX$(PEEK(ADDRESS+2)+PEEK(ADDRESS+3)*256),4);
310 PRINT #1,":"; FNJUSTIFY$(HEX$(PEEK(ADDRESS+0)+PEEK(ADDRESS+1)*256),4);
320 PRINT #1," "; LEFT$(NAM$(I)+SPACE$(20),20);
330 RETURN
340 REM
1000 DATA "Divide by Zero"
1001 DATA "Single Step"
1002 DATA "Nonmaskable"
1003 DATA "Breakpoint"
1004 DATA "Overflow"
1005 DATA "Print Screen"
1006 DATA "Reserved"
1007 DATA "Reserved"
1008 DATA "Time of Day"
1009 DATA "Keyboard"
1010 DATA "Reserved"
1011 DATA "Communications"
1012 DATA "Communications"
1013 DATA "Disk"
1014 DATA "Diskette"
1015 DATA "Printer"
1016 DATA "Video"
1017 DATA "Equipment Check"
1018 DATA "Memory"
1019 DATA "Diskette/Disk"
1020 DATA "Communications"
1021 DATA "Cassette"
1022 DATA "Keyboard"
1023 DATA "Printer"
1024 DATA "Resident BASIC"
1025 DATA "Bootstrap"
1026 DATA "Time of Day"
1027 DATA "Keyboard Break"
1028 DATA "Timer Tick"
1029 DATA "Video Parameters"
1030 DATA "Diskette Parameters"
1031 DATA "Video Graphics Exten"
1032 DATA "DOS Program Term"
1033 DATA "DOS Function Call"
1034 DATA "DOS Terminate Addr"
1035 DATA "DOS Ctrl Break Exit"
1036 DATA "DOS Fatal Error"
1037 DATA "DOS Abs Disk Read"
1038 DATA "DOS Abs Disk Write"
1039 DATA "DOS Terminate & Fix"
1040 DATA "Reserved for DOS"
1041 DATA "Reserved for DOS"
1042 DATA "Reserved for DOS"
1043 DATA "Reserved for DOS"
1044 DATA "Reserved for DOS"
1045 DATA "Reserved for DOS"
1046 DATA "Reserved for DOS"
1047 DATA "Reserved for DOS"
1048 DATA "Reserved for DOS"
1049 DATA "Reserved for DOS"
1050 DATA "Reserved for DOS"
1051 DATA "Reserved for DOS"
1052 DATA "Reserved for DOS"
1053 DATA "Reserved for DOS"
1054 DATA "Reserved for DOS"
1055 DATA "Reserved for DOS"
1056 DATA "Reserved for DOS"
1057 DATA "Reserved for DOS"
1058 DATA "Reserved for DOS"
1059 DATA "Reserved for DOS"
1060 DATA "Reserved for DOS"
1061 DATA "Reserved for DOS"
1062 DATA "Reserved for DOS"
1063 DATA "Reserved for DOS"
1064 DATA "Revector Diskette"
1065 DATA "Fixed Disk Parms"
1066 DATA "Reserved"
1067 DATA "Reserved"
1068 DATA "Reserved"
1069 DATA "Reserved"
1070 DATA "Reserved"
1071 DATA "Reserved"
1072 DATA "Reserved"
1073 DATA "Reserved"
1074 DATA "Reserved"
1075 DATA "Reserved"
1076 DATA "Reserved"
1077 DATA "Reserved"
1078 DATA "Reserved"
1079 DATA "Reserved"
1080 DATA "Reserved"
1081 DATA "Reserved"
1082 DATA "Reserved"
1083 DATA "Reserved"
1084 DATA "Reserved"
1085 DATA "Reserved"
1086 DATA "Reserved"
1087 DATA "Reserved"
1088 DATA "Reserved"
1089 DATA "Reserved"
1090 DATA "Reserved"
1091 DATA "Reserved"
1092 DATA "Reserved"
1093 DATA "Reserved"
1094 DATA "Reserved"
1095 DATA "Reserved"
1096 DATA "User Interrupts"
1097 DATA "User Interrupts"
1098 DATA "User Interrupts"
1099 DATA "User Interrupts"
1100 DATA "User Interrupts"
1101 DATA "User Interrupts"
1102 DATA "User Interrupts"
1103 DATA "User Interrupts"
1104 DATA "Not Used"
1105 DATA "Not Used"
1106 DATA "Not Used"
1107 DATA "Not Used"
1108 DATA "Not Used"
1109 DATA "Not Used"
1110 DATA "Not Used"
1111 DATA "Not Used"
1112 DATA "Not Used"
1113 DATA "Not Used"
1114 DATA "Not Used"
1115 DATA "Not Used"
1116 DATA "Not Used"
1117 DATA "Not Used"
1118 DATA "Not Used"
1119 DATA "Not Used"
1120 DATA "Not Used"
1121 DATA "Not Used"
1122 DATA "Not Used"
1123 DATA "Not Used"
1124 DATA "Not Used"
1125 DATA "Not Used"
1126 DATA "Not Used"
1127 DATA "Not Used"
1128 DATA "Reserved by BASIC"
1129 DATA "Reserved by BASIC"
1130 DATA "Reserved by BASIC"
1131 DATA "Reserved by BASIC"
1132 DATA "Reserved by BASIC"
1133 DATA "Reserved by BASIC"
1134 DATA "BASIC Interpreter"
1135 DATA "BASIC Interpreter"
1136 DATA "BASIC Interpreter"
1137 DATA "BASIC Interpreter"
1138 DATA "BASIC Interpreter"
1139 DATA "BASIC Interpreter"
1140 DATA "BASIC Interpreter"
1141 DATA "BASIC Interpreter"
1142 DATA "BASIC Interpreter"
1143 DATA "BASIC Interpreter"
1144 DATA "BASIC Interpreter"
1145 DATA "BASIC Interpreter"
1146 DATA "BASIC Interpreter"
1147 DATA "BASIC Interpreter"
1148 DATA "BASIC Interpreter"
1149 DATA "BASIC Interpreter"
1150 DATA "BASIC Interpreter"
1151 DATA "BASIC Interpreter"
1152 DATA "BASIC Interpreter"
1153 DATA "BASIC Interpreter"
1154 DATA "BASIC Interpreter"
1155 DATA "BASIC Interpreter"
1156 DATA "BASIC Interpreter"
1157 DATA "BASIC Interpreter"
1158 DATA "BASIC Interpreter"
1159 DATA "BASIC Interpreter"
1160 DATA "BASIC Interpreter"
1161 DATA "BASIC Interpreter"
1162 DATA "BASIC Interpreter"
1163 DATA "BASIC Interpreter"
1164 DATA "BASIC Interpreter"
1165 DATA "BASIC Interpreter"
1166 DATA "BASIC Interpreter"
1167 DATA "BASIC Interpreter"
1168 DATA "BASIC Interpreter"
1169 DATA "BASIC Interpreter"
1170 DATA "BASIC Interpreter"
1171 DATA "BASIC Interpreter"
1172 DATA "BASIC Interpreter"
1173 DATA "BASIC Interpreter"
1174 DATA "BASIC Interpreter"
1175 DATA "BASIC Interpreter"
1176 DATA "BASIC Interpreter"
1177 DATA "BASIC Interpreter"
1178 DATA "BASIC Interpreter"
1179 DATA "BASIC Interpreter"
1180 DATA "BASIC Interpreter"
1181 DATA "BASIC Interpreter"
1182 DATA "BASIC Interpreter"
1183 DATA "BASIC Interpreter"
1184 DATA "BASIC Interpreter"
1185 DATA "BASIC Interpreter"
1186 DATA "BASIC Interpreter"
1187 DATA "BASIC Interpreter"
1188 DATA "BASIC Interpreter"
1189 DATA "BASIC Interpreter"
1190 DATA "BASIC Interpreter"
1191 DATA "BASIC Interpreter"
1192 DATA "BASIC Interpreter"
1193 DATA "BASIC Interpreter"
1194 DATA "BASIC Interpreter"
1195 DATA "BASIC Interpreter"
1196 DATA "BASIC Interpreter"
1197 DATA "BASIC Interpreter"
1198 DATA "BASIC Interpreter"
1199 DATA "BASIC Interpreter"
1200 DATA "BASIC Interpreter"
1201 DATA "BASIC Interpreter"
1202 DATA "BASIC Interpreter"
1203 DATA "BASIC Interpreter"
1204 DATA "BASIC Interpreter"
1205 DATA "BASIC Interpreter"
1206 DATA "BASIC Interpreter"
1207 DATA "BASIC Interpreter"
1208 DATA "BASIC Interpreter"
1209 DATA "BASIC Interpreter"
1210 DATA "BASIC Interpreter"
1211 DATA "BASIC Interpreter"
1212 DATA "BASIC Interpreter"
1213 DATA "BASIC Interpreter"
1214 DATA "BASIC Interpreter"
1215 DATA "BASIC Interpreter"
1216 DATA "BASIC Interpreter"
1217 DATA "BASIC Interpreter"
1218 DATA "BASIC Interpreter"
1219 DATA "BASIC Interpreter"
1220 DATA "BASIC Interpreter"
1221 DATA "BASIC Interpreter"
1222 DATA "BASIC Interpreter"
1223 DATA "BASIC Interpreter"
1224 DATA "BASIC Interpreter"
1225 DATA "BASIC Interpreter"
1226 DATA "BASIC Interpreter"
1227 DATA "BASIC Interpreter"
1228 DATA "BASIC Interpreter"
1229 DATA "BASIC Interpreter"
1230 DATA "BASIC Interpreter"
1231 DATA "BASIC Interpreter"
1232 DATA "BASIC Interpreter"
1233 DATA "BASIC Interpreter"
1234 DATA "BASIC Interpreter"
1235 DATA "BASIC Interpreter"
1236 DATA "BASIC Interpreter"
1237 DATA "BASIC Interpreter"
1238 DATA "BASIC Interpreter"
1239 DATA "BASIC Interpreter"
1240 DATA "BASIC Interpreter"
1241 DATA "Not Used"
1242 DATA "Not Used"
1243 DATA "Not Used"
1244 DATA "Not Used"
1245 DATA "Not Used"
1246 DATA "Not Used"
1247 DATA "Not Used"
1248 DATA "Not Used"
1249 DATA "Not Used"
1250 DATA "Not Used"
1251 DATA "Not Used"
1252 DATA "Not Used"
1253 DATA "Not Used"
1254 DATA "Not Used"
1255 DATA "Not Used"
1256 END 'of program.
[This is the end of BASIC.DOC]
Mike Todd, SIG003
IBMSIG - The Source
P.O. Box 14435, Long Beach, CA 90803-1057
Phone: 213/439-6104
BASIC PROGRAMMING
Basic Peeks, Pokes and Subroutines
This list of memory addresses which contain information about the status of
the PC and/or which may be modified to change the way the PC reacts to its
world and the programs to use this information have been compiled by a large
number of people. Some of it may be gleaned from the IBM Technical Reference
Manual and/or the BASIC manual. Some of it exists only because someone worked
very hard to find a way to make something happen. Some of it exists because
someone made a mistake and was presented with a new capability because of it.
No matter who found it or how the information was found this document
provides some really useful information for BASIC programmers. It even
provides good information for other programmers who will access directly the
PC memory.
Please submit new, corrected or better defined informtion to SysOp Mike Todd,
SIG003 on the IBMSIG on The Source so it may be kept up to date.
Suggestions about both content and format are welcome.
Sincere thanks to all those who have contributed!!! Mike Todd
BIOS LOCATIONS:
By specifying a DEF SEG=&H40 in any BASIC program, it is possible to
reference the following vectors (fields) in the ROM BIOS area by using a PEEK
function and the following offsets from the current segment as defined by the
DEF SEG statement.
Offset Comment/Example:
--------- ----------------------------------------------------------
&H0 - RS232 Addresses on your IBM PC. This will allow you to
tell how many (up to four) async cards are attached, if
any.
&H8 - Printer Addresses on your IBM PC. This will tell you what
printer addresses, and how many (up to four) exist. Each
is addressed by a two byte Hex value.
&H10 - Equipment Flag. This field describes the setting of the
options switches. It describes what optional devices are
attached to the system. The following lists the
bit-significance of this
field:
Bit 0 - Indicates that there are diskette
drives on the system.
0 = No diskettes
1 = 1 or more diskettes
Bit 1 - 8087.
0 = Not installed.
1 = Installed.
Bit 2,3 - Planar Ram Size
PC-1 XT and PC-2
00=16K 64K
10=32K 128K
01=48K 192K
11=64K 256K
Bit 4,5 - Initial Video Mode
00=Unused
10=40x25 Color
01=80x25 Color
11=80x25 Mono or both
Bit 6,7 - Number of Diskette Drives
(bit 0 = 1 in all cases)
00=1
10=2
01=3
11=4
Bit 8 - Unused
Bit 9,10,11 - Number of RS232 Cards attached
Bit 12 - Game I/O Attached
Bit 13 - Not used
Bit 14,15 - Number of printers attached
&H13 - Memory Size in K bytes.
&H15 - I/O RAM Size in K bytes.
&H17 - Keyboard Flag -- the following lists the masks
set to describe current keyboard status:
Byte 1;
&H80 - Insert state active
&H40 - Caps Lock State Has been toggled
&H20 - Num Lock State has been toggled
&H10 - Scroll Lock State has been toggled
&H08 - Alternate Shift key depressed
&H04 - Control Shift key depressed
&H02 - Left Shift key depressed
&H01 - Right Shift key depressed
Byte 2;
&H80 - Insert Key is depressed
&H40 - Caps Lock Key is depressed
&H20 - Num Lock Key is depressed
&H10 - Scroll Lock key is depressed
&H08 - Suspend key has been toggled
&H49 - Current CRT mode
&H00 - 40x25 BW
&H01 - 40x25 Color
&H02 - 80x25 BW
&H03 - 80x25 Color
&H04 - 320x200 Color
&H05 - 320x200 BW
&H06 - 640x200 BW
&H07 - 80x25 B&W Card -- specialized use, used
internal to the video routines.
&H4A - Number of CRT columns
&H50 - Cursor Position (one of eight)
&H60 - Current cursor mode
&H6C - Low word of Timer count
&H6E - High word of Timer count
&H71 - &H07 - Break key depressed
&HFA6E - Beginning of character regen memory
&HFF53 - PRTSC routine address
Following are some BASIC statements and subroutines showing how to use the
above information plus additional functions MASTER your PC!
KEYBOARD:
To disable entire keyboard:
DEF SEG=64: OUT 97,204
To re-enable keyboard:
DEF SEG=64: OUT 97,76
Clear line buffer:
DEF SEG: POKE 106,0
Clear Keyboard Buffer:
DEF SEG=0: POKE 1050,PEEK(1052)
NUM LOCK:
DEG SEG=&H40: POKE &H17,PEEK(&H17) OR 32 'To turn on
DEG SEG=&H40: POKE &H17,PEEK(&H17) AND 223 'To turn off
CAPS LOCK:
DEG SEG=&H40: POKE &H17,PEEK(&H17) OR 64 'To turn on
DEG SEG=&H40: POKE &H17,PEEK(&H17) AND 171 'To turn off
Restore Function Keys to Default values:
10 DEF SEG = &HFACE
20 K = 1
30 I = 13
40 T$ = STRING$(13,32): J = 1
50 T1 = PEEK(I):IF T1 < 0 THEN MID$(T$,J,1) = CHR$(T1):J = J + 1:
I = I + 1 : GOTO 50
60 KEY K,LEFT$(T$,J-1):IF K <10 THEN K = K + 1: I = I + 1: GOTO 40 :
ELSE KEY ON
Disable and re-enable CTRL+BREAK:
100 ' Subroutine to save old CTRL+BREAK address and set new to IRET
110 DIM OLD%(4)
120 DEF SEG=0
130 FOR I=&H6C TO &H6F
140 OLD%(I-&H6C)=PEEK(I) ' The array OLD%() must remain available
150 NEXT
160 ' establish new CTRL+BREAK address (point to IRET)
170 POKE &H6C,&H53
180 POKE &H6D,&HFF
190 POKE &H6E,&H0
200 POKE &H6F,&HF0
210 DEF SEG: RETURN ' CTRL+BREAK will return to the program
220 ' Subroutine to reset old CTRL+BREAK address
230 DEF SEG=0
240 FOR I=&H6C TO &H6F
250 POKE I,OLD%(I-&H6C)
260 NEXT
270 DEF SEG: RETURN ' CTRL+BREAK will interupt the program
SCREEN:
Determine Monitor type:
10 DEF SEG = 0
20 MONITOR.TYPE = PEEK(&H410) AND &H40
30 IF MONITOR.TYPE = 1 THEN PRINT "40 X 25 Color"
40 IF MONITOR.TYPE = 32 THEN PRINT "80 X 25 Color"
50 IF MONITOR.TYPE = 48 THEN PRINT "Monochrome"
60 IF MONITOR.TYPE = 64 THEN PRINT "Both"
Sitch displays on a system with both monochrome and color/graphics:
10 'Subroutine to switch to monochrome adaptor
20 DEF SEG=0
30 POKE &H410,(PEEK(&H410) OR &H30)
40 SCREEN 0 ' restore screen to text mode
50 WIDTH 80 ' restore screen width to 80
60 LOCATE ,,1,12,13 'restore cursor to "normal"
70 RETURN
80 ' Subroutine to switch to color adaptor. Change
90 ' SCREEN and WIDTH statements for different modes
100 DEF SEG=0
110 POKE &H410,(PEEK(&H410) AND &HCF) OR &H10
120 SCREEN 1,0,0,0 ' Medium resolution graphics, color,
active page 0, visual page 0
130 WIDTH 40 ' WIDTH 80 would force the screen to clear and
set to SCREEN 2 for high resolution
140 LOCATE ,,1,6,7 ' restore cursor to "normal" for color screen
150 RETURN
Subroutine to save and restore a screen image:
100 DEF SEG = &HB800 'Save screen image
110 INPUT "Enter name of file";FILENAME$ 'for color/graphics
120 BSAVE FILENAME$,0,&H4000 'display in text mode
130 RETURN
1000 INPUT "Enter name of file";FILENAME$ 'Restore image
1010 CLS
1020 DEF SEG = &HB800 'Change DEF SEG=&HB800
1030 BLOAD FILENAME$ 'to &HB000 for monochrome
Set split screen scroll window starting on line X ending on line Y:
DEF SEG: POKE 91,X: POKE 92,Y 'Sets up "window"
LOCATE X,C 'Place cursor "in" the scroll window at line X column C
Set window width:
DEF SEG: POKE 41,X 'Set window width to X
Set 16 background colors:
While WIDTH 40: OUT &H3D8,8
While WIDTH 80: OUT &H3D8,9
Use other than palate color 3 for characters in medium resolution
DEF SEG: POKE &H4E,COLOR (COLOR may be 1, 2, or 3)
DISKETTE DRIVES:
Read drive switches:
DEF SEG = 0: NUMBER.OF.DRIVES% = PEEK(&H410) AND &HC0
Current disk information:
DEF SEG=64
PEEK(69) - Track
PEEK(70) - Head
PEEK(71) - Sector
256^PEEK(72) - Bytes per sector
PRINTER:
Printer Status (works with IBM Dot Matrix and Epson printers)
DEF SEG=64
A=PEEK(8)+256*PEEK(9)
B=(INT(A+1) AND 248) XOR 72
IF (B AND 128)<>128 THEN PRINTER.STATUS="OFF LINE"
ELSE PRINTER.STATUS="ON LINE"
Initialize Printer:
DEF SEG=64
A=PEEK(8)+256*PEEK(9)
DEF SEG: OUT A+2,8
OUT A+2,12
Note: A is from Printer status routine
MEMORY:
Determine amount of memory installed (Only works for greater than 48k):
DEF SEG = 0: MEMORY% = PEEK(&H413)+(256*PEEK(&H414))
or, put another way:
Memory info: DEF SEG=0
((PEEK(1040) and 12) + 4 ) * 4 - Memory on Mother-board
PEEK(1045) + 256 * PEEK(1046) - Expansion memory (add on)
PEEK(1043) + 256 * PEEK(1044) - Total memory
GAME ADAPTER:
Determine if game adapter exists:
DEF SEG = 0: GAME.ADAPTER% = PEEK(&H411) AND &H10
IF GAME.ADAPTER% = 0 THEN GAME.ADAPTER$="No"
ELSE GAME.ADAPTER$="Yes --Installed"
MISCELLANEOUS:
Unprotect a BASIC program that was saved ",P:
First you must create a file to overlay the ,P setting. From the
DOS prompt start up BASICA or BASIC and enter the following BASIC
command:
BSAVE "UN.P",1124,1
This will create a file on your default drive named UN.P.
Next LOAD your program that had been saved using ",P. If it was
named MYPROG.BAS the BASIC command would be:
LOAD "MYPROG
Now to use the UN.P file to overlay the protection setting use the
following command:
BLOAD "UN.P",1124
You may now use the LIST, EDIT and SAVE commands as usual.
Following is a program by Richard Tremmel to print all the BASIC interrupts.
It is set to write the interrupt locations to a printer:
100 REM INT-LIST IBM-PC Software Interrupt Listing by Richard L. Tremmel
110 DEF SEG=0
120 DIM NAM$(255)
130 DEF FNJUSTIFY$(STRG$,LNGTH) = RIGHT$("0000"+STRG$,LNGTH)
140 TITLE$ = "INT ADDR VECTOR FUNCTION "
150 FOR I = 0 TO 255 : READ NAM$(I) : NEXT I
160 REM
170 OPEN "LPT1:" FOR OUTPUT AS #1 : PRINT #1,""
180 FOR PAGE = 1 TO 2
190 PRINT #1,CHR$(12); TITLE$; " "; TITLE$
200 FOR K = (PAGE-1)*128 TO (PAGE-1)*128+64-1
210 I = K : ADDRESS = I*4 : GOSUB 280 : PRINT #1," ";
220 I = K+64 : ADDRESS = I*4 : GOSUB 280 : PRINT #1,""
230 NEXT K
240 NEXT PAGE
250 CLOSE #1
260 SYSTEM
270 REM
280 PRINT #1," "; FNJUSTIFY$(HEX$(I),2);
290 PRINT #1," "; FNJUSTIFY$(HEX$(ADDRESS),4);
300 PRINT #1," "; FNJUSTIFY$(HEX$(PEEK(ADDRESS+2)+PEEK(ADDRESS+3)*256),4);
310 PRINT #1,":"; FNJUSTIFY$(HEX$(PEEK(ADDRESS+0)+PEEK(ADDRESS+1)*256),4);
320 PRINT #1," "; LEFT$(NAM$(I)+SPACE$(20),20);
330 RETURN
340 REM
1000 DATA "Divide by Zero"
1001 DATA "Single Step"
1002 DATA "Nonmaskable"
1003 DATA "Breakpoint"
1004 DATA "Overflow"
1005 DATA "Print Screen"
1006 DATA "Reserved"
1007 DATA "Reserved"
1008 DATA "Time of Day"
1009 DATA "Keyboard"
1010 DATA "Reserved"
1011 DATA "Communications"
1012 DATA "Communications"
1013 DATA "Disk"
1014 DATA "Diskette"
1015 DATA "Printer"
1016 DATA "Video"
1017 DATA "Equipment Check"
1018 DATA "Memory"
1019 DATA "Diskette/Disk"
1020 DATA "Communications"
1021 DATA "Cassette"
1022 DATA "Keyboard"
1023 DATA "Printer"
1024 DATA "Resident BASIC"
1025 DATA "Bootstrap"
1026 DATA "Time of Day"
1027 DATA "Keyboard Break"
1028 DATA "Timer Tick"
1029 DATA "Video Parameters"
1030 DATA "Diskette Parameters"
1031 DATA "Video Graphics Exten"
1032 DATA "DOS Program Term"
1033 DATA "DOS Function Call"
1034 DATA "DOS Terminate Addr"
1035 DATA "DOS Ctrl Break Exit"
1036 DATA "DOS Fatal Error"
1037 DATA "DOS Abs Disk Read"
1038 DATA "DOS Abs Disk Write"
1039 DATA "DOS Terminate & Fix"
1040 DATA "Reserved for DOS"
1041 DATA "Reserved for DOS"
1042 DATA "Reserved for DOS"
1043 DATA "Reserved for DOS"
1044 DATA "Reserved for DOS"
1045 DATA "Reserved for DOS"
1046 DATA "Reserved for DOS"
1047 DATA "Reserved for DOS"
1048 DATA "Reserved for DOS"
1049 DATA "Reserved for DOS"
1050 DATA "Reserved for DOS"
1051 DATA "Reserved for DOS"
1052 DATA "Reserved for DOS"
1053 DATA "Reserved for DOS"
1054 DATA "Reserved for DOS"
1055 DATA "Reserved for DOS"
1056 DATA "Reserved for DOS"
1057 DATA "Reserved for DOS"
1058 DATA "Reserved for DOS"
1059 DATA "Reserved for DOS"
1060 DATA "Reserved for DOS"
1061 DATA "Reserved for DOS"
1062 DATA "Reserved for DOS"
1063 DATA "Reserved for DOS"
1064 DATA "Revector Diskette"
1065 DATA "Fixed Disk Parms"
1066 DATA "Reserved"
1067 DATA "Reserved"
1068 DATA "Reserved"
1069 DATA "Reserved"
1070 DATA "Reserved"
1071 DATA "Reserved"
1072 DATA "Reserved"
1073 DATA "Reserved"
1074 DATA "Reserved"
1075 DATA "Reserved"
1076 DATA "Reserved"
1077 DATA "Reserved"
1078 DATA "Reserved"
1079 DATA "Reserved"
1080 DATA "Reserved"
1081 DATA "Reserved"
1082 DATA "Reserved"
1083 DATA "Reserved"
1084 DATA "Reserved"
1085 DATA "Reserved"
1086 DATA "Reserved"
1087 DATA "Reserved"
1088 DATA "Reserved"
1089 DATA "Reserved"
1090 DATA "Reserved"
1091 DATA "Reserved"
1092 DATA "Reserved"
1093 DATA "Reserved"
1094 DATA "Reserved"
1095 DATA "Reserved"
1096 DATA "User Interrupts"
1097 DATA "User Interrupts"
1098 DATA "User Interrupts"
1099 DATA "User Interrupts"
1100 DATA "User Interrupts"
1101 DATA "User Interrupts"
1102 DATA "User Interrupts"
1103 DATA "User Interrupts"
1104 DATA "Not Used"
1105 DATA "Not Used"
1106 DATA "Not Used"
1107 DATA "Not Used"
1108 DATA "Not Used"
1109 DATA "Not Used"
1110 DATA "Not Used"
1111 DATA "Not Used"
1112 DATA "Not Used"
1113 DATA "Not Used"
1114 DATA "Not Used"
1115 DATA "Not Used"
1116 DATA "Not Used"
1117 DATA "Not Used"
1118 DATA "Not Used"
1119 DATA "Not Used"
1120 DATA "Not Used"
1121 DATA "Not Used"
1122 DATA "Not Used"
1123 DATA "Not Used"
1124 DATA "Not Used"
1125 DATA "Not Used"
1126 DATA "Not Used"
1127 DATA "Not Used"
1128 DATA "Reserved by BASIC"
1129 DATA "Reserved by BASIC"
1130 DATA "Reserved by BASIC"
1131 DATA "Reserved by BASIC"
1132 DATA "Reserved by BASIC"
1133 DATA "Reserved by BASIC"
1134 DATA "BASIC Interpreter"
1135 DATA "BASIC Interpreter"
1136 DATA "BASIC Interpreter"
1137 DATA "BASIC Interpreter"
1138 DATA "BASIC Interpreter"
1139 DATA "BASIC Interpreter"
1140 DATA "BASIC Interpreter"
1141 DATA "BASIC Interpreter"
1142 DATA "BASIC Interpreter"
1143 DATA "BASIC Interpreter"
1144 DATA "BASIC Interpreter"
1145 DATA "BASIC Interpreter"
1146 DATA "BASIC Interpreter"
1147 DATA "BASIC Interpreter"
1148 DATA "BASIC Interpreter"
1149 DATA "BASIC Interpreter"
1150 DATA "BASIC Interpreter"
1151 DATA "BASIC Interpreter"
1152 DATA "BASIC Interpreter"
1153 DATA "BASIC Interpreter"
1154 DATA "BASIC Interpreter"
1155 DATA "BASIC Interpreter"
1156 DATA "BASIC Interpreter"
1157 DATA "BASIC Interpreter"
1158 DATA "BASIC Interpreter"
1159 DATA "BASIC Interpreter"
1160 DATA "BASIC Interpreter"
1161 DATA "BASIC Interpreter"
1162 DATA "BASIC Interpreter"
1163 DATA "BASIC Interpreter"
1164 DATA "BASIC Interpreter"
1165 DATA "BASIC Interpreter"
1166 DATA "BASIC Interpreter"
1167 DATA "BASIC Interpreter"
1168 DATA "BASIC Interpreter"
1169 DATA "BASIC Interpreter"
1170 DATA "BASIC Interpreter"
1171 DATA "BASIC Interpreter"
1172 DATA "BASIC Interpreter"
1173 DATA "BASIC Interpreter"
1174 DATA "BASIC Interpreter"
1175 DATA "BASIC Interpreter"
1176 DATA "BASIC Interpreter"
1177 DATA "BASIC Interpreter"
1178 DATA "BASIC Interpreter"
1179 DATA "BASIC Interpreter"
1180 DATA "BASIC Interpreter"
1181 DATA "BASIC Interpreter"
1182 DATA "BASIC Interpreter"
1183 DATA "BASIC Interpreter"
1184 DATA "BASIC Interpreter"
1185 DATA "BASIC Interpreter"
1186 DATA "BASIC Interpreter"
1187 DATA "BASIC Interpreter"
1188 DATA "BASIC Interpreter"
1189 DATA "BASIC Interpreter"
1190 DATA "BASIC Interpreter"
1191 DATA "BASIC Interpreter"
1192 DATA "BASIC Interpreter"
1193 DATA "BASIC Interpreter"
1194 DATA "BASIC Interpreter"
1195 DATA "BASIC Interpreter"
1196 DATA "BASIC Interpreter"
1197 DATA "BASIC Interpreter"
1198 DATA "BASIC Interpreter"
1199 DATA "BASIC Interpreter"
1200 DATA "BASIC Interpreter"
1201 DATA "BASIC Interpreter"
1202 DATA "BASIC Interpreter"
1203 DATA "BASIC Interpreter"
1204 DATA "BASIC Interpreter"
1205 DATA "BASIC Interpreter"
1206 DATA "BASIC Interpreter"
1207 DATA "BASIC Interpreter"
1208 DATA "BASIC Interpreter"
1209 DATA "BASIC Interpreter"
1210 DATA "BASIC Interpreter"
1211 DATA "BASIC Interpreter"
1212 DATA "BASIC Interpreter"
1213 DATA "BASIC Interpreter"
1214 DATA "BASIC Interpreter"
1215 DATA "BASIC Interpreter"
1216 DATA "BASIC Interpreter"
1217 DATA "BASIC Interpreter"
1218 DATA "BASIC Interpreter"
1219 DATA "BASIC Interpreter"
1220 DATA "BASIC Interpreter"
1221 DATA "BASIC Interpreter"
1222 DATA "BASIC Interpreter"
1223 DATA "BASIC Interpreter"
1224 DATA "BASIC Interpreter"
1225 DATA "BASIC Interpreter"
1226 DATA "BASIC Interpreter"
1227 DATA "BASIC Interpreter"
1228 DATA "BASIC Interpreter"
1229 DATA "BASIC Interpreter"
1230 DATA "BASIC Interpreter"
1231 DATA "BASIC Interpreter"
1232 DATA "BASIC Interpreter"
1233 DATA "BASIC Interpreter"
1234 DATA "BASIC Interpreter"
1235 DATA "BASIC Interpreter"
1236 DATA "BASIC Interpreter"
1237 DATA "BASIC Interpreter"
1238 DATA "BASIC Interpreter"
1239 DATA "BASIC Interpreter"
1240 DATA "BASIC Interpreter"
1241 DATA "Not Used"
1242 DATA "Not Used"
1243 DATA "Not Used"
1244 DATA "Not Used"
1245 DATA "Not Used"
1246 DATA "Not Used"
1247 DATA "Not Used"
1248 DATA "Not Used"
1249 DATA "Not Used"
1250 DATA "Not Used"
1251 DATA "Not Used"
1252 DATA "Not Used"
1253 DATA "Not Used"
1254 DATA "Not Used"
1255 DATA "Not Used"
1256 END 'of program.
[This is the end of BASIC.DOC]
Mike Todd, SIG003
IBMSIG - The Source
P.O. Box 14435, Long Beach, CA 90803-1057
Phone: 213/439-6104
December 9, 2017
Add comments