Main | Links | Downloads | Apple // Texts | Apple // Specs | The "Sider" Hard Drive

The Big PEEKs, POKEs, and CALLs List
Compiled by Edhel Iaur, Esq.


You've probably seen a lot of these before, but you may still find a useful P,P, or C that is new to you (assuming it works! : ) ). Some are for ProDOS, some are for DOS 3.3, and some are for Applesoft BASIC in general. A lot of the DOS 3.3 stuff came from Bert Kersey's DOSTalk Scrapbook. As usual, I claim no responsibility for any damage, etc. these may do. Some of the info may be less than 100% accurate; I haven't updated this in a long while. Without further ado, here's my really big PEEKs, POKEs, and CALLs and stuff list.
A little more ado:As always, feel free to email/post to me questions about this stuff.
MEMORY ADDRESSES
 
$06-$09 = Free
$18-$1F = Free
$4E-$4F = Constantly randomly changing numbers
$CE-$CF = Free
$EB-$EF = Free
$F9-$FF = Free
$C9-$CD = Random numbers?
$100-$95FF = Free
$300-$3FF = Free
$9600-$BFFF = DOS 3.3
$9600-$BEFF = BASIC.SYSTEM
$9D5E = Routine called after RESTART is pressed
$A963 = Two-byte value that is the max. value allowed w/the L parameter
$AA57 = Current MAXFILES setting
$AAB1 = Default MAXFILES setting
$BE43 EXEC file active (status)
$BE44 Input file active (status)
$BE45 Output file active (status)
$BE46 Prefix active (status)
$BE47 Directory file being accessed (status)
$BE48 End of directory data reached (status)
$BE49 Index to free string space (in K) (data)
$BE4A Character count for WRITE's temporary buffer (data)
$BE4B Current character count during keyboard entry (data)
$BE4C ASCII code of last character sent to output (used in error detection)
$BE4D Number of open files (doesn't include EXECs) (data)
$BE4E EXEC file is being closed (status)
$BE4F DIR file is being read (status)
$BE58-59  The last used A parameter
$BE5A-5C  The last used B parameter
$BE5D-5E  The last used E parameter
$BE5F-60  The last used L parameter
$BE61     The last used S parameter
$BE62     The last used D parameter
$BE63-64  The last used F parameter
$BE65-66  The last used R parameter
$BE67     The last used V parameter
$BE68-69  The last used @ parameter
$BE6A     The last used T parameter
$BE6B     The last used number after PR# or IN#
$BF00-$BFFF = ProDOS's global page
$C000-$FFFF = ROM
$D000-$F7FF = Applesoft BASIC
$E000-$F7FF = Integer BASIC
$F800-$FFFF = Hex. Language
 
976 = Warmstart entry
43140-43379 = DOS 3.3 commands
43380-43581 = DOS 3.3 error messages
45991-45994 = DOS 3.3 file-type codes
46010-45999 = Disk volume header (backwards)
48640 = Warmstart entry to BASIC.SYSTEM
53456-54116 = Applesoft commands and error messages
 
 
PEEKS, POKES, AND CALLS
 
Poke 32,X Set left margin of text window
Poke 33,X Set width of text window
Poke 34,X Set top margin of text window
Poke 35,X Set bottom margin of text window
Peek (36) Horizontal cursor position
Peek (37) Vertical cursor position
POKE PEEK(40)+PEEK(41)*x+PEEK(36),32 Makes cursor either not flash or be
   invisible, depending on whether x is 156 or 256
Poke 50,63 INVERSE
Poke 50,127 FLASH
Poke 50,128 Listings and CATALOGs invisible
Poke 50,255 NORMAL
Poke 82,128 Cassette program will automatically RUN when loaded
Peek 103 & 104 - (Two-byte number) LOMEM value
POKE 109,PEEK(107):POKE 110,PEEK(108) Deletes all arrays.  Lets you
   reDIMention any or all arrays
Peek 115 & 116 - (Two-byte number) HIMEM value
POKE 214,128 or 255 Makes disk program RUN when any command is issued
X = PEEK (218) + PEEK (219) * 256 -- X equals line where error occured
Peek 232 & 233 Two-byte value of address of shape table
Peek (241) 256-SPEED
Call -380 NORMAL
Call -384 INVERSE
Call -875 Clears entire text line
Call -912 Scrolls up one line
Call -958 Clears the bottom of the text screen
X=PEEK(978) Determines where DOS is - if less than 157 then DOS is below
   normal location - computer has less than 48K memory; if 157
   then DOS is at its normal 48K location; if 190 then DOS is
   ProDOS, not DOS 3.3; if greater than 190 then DOS is in the
   language card.  Another source says this PEEK can show memory
   size if used as: PRINT (PEEK(978)+35)/4;"K"
POKE 1011,224 Makes RESET reboot
POKE 1010,102:POKE 1011,213:POKE 1012,112 Makes RESET RUN.  Also unhooks DOS.
   Use CALL 1002 at beginning of program to rehook it.
POKE 1013,76:POKE 1014,26:POKE 1015,252 Makes "&" move cursor up one line
Peek (2040)-192 Current active slot
POKE 40286,252:POKE 40287,164 Makes RESET RUN
Call 42340 Locks up disk to prevent writing on it.  CAUTION: BACK UP DISK
   BEFORE USING
Poke 44467,234:Poke 44468,234:Poke 44469,234 Causes DOS 3.3 to forget to show
   you the disk catalog header the next time you catalog a disk
Poke 44480,234:Poke 44481,234:Poke 44482,234 Causes DOS 3.3 to forget to show
   you the disk volume number the next time you catalog a disk
POKE 44452,22:POKE 44605,21 Controls number of files displayed in CATALOG;
   The first POKE is always 1 greater than the second one
POKE 44505,234:POKE 44506,234 Reveals DELETEd files in your CATALOG
POKE 44509,76:POKE 44510,19:POKE 44511,174 Omits file type and file length in
   CATALOG
POKE 44545,169:POKE 44546,x:POKE 44547,234 Shows all files in CATALOG to be x
   sectors long
POKE 45620,234:POKE 45621,234 Keeps repeating first file in CATALOG
Poke 49237,0 View hi-res page 2
Poke 49236,0 View hi-res page 1
Poke 43602,0 Sets a flag so that you can then, immediately following this
   POKE, send a DOS command without going to the next line
Poke 44725,144:Poke 48894,36:Poke 46063,36 The next time you format a DOS 3.3
   disk, it may have 36 (not 35) tracks
Peek(43702) What language DOS thinks is running; if it equals 0 then it's
   Integer BASIC; if it's 64, then it's Applesoft; if it's 128, then it's
   cassette Applesoft
Poke 43698,ASC(A$)+128 Changes the CONTROL-D DOS activator to the character
   in A$
Poke 45994,ASC(A$)+128 Makes the B-type files show up as the one character
   type of file in A$
Poke 45993,ASC(A$)+128 Makes the A-type files show up as the one character
   type of file in A$
Poke 45992,ASC(A$)+128 Makes the I-type files show up as the one character
   type of file in A$
Poke 45991,ASC(A$)+128 Makes the T-type files show up as the one character
   type of file in A$
Poke 44508,ASC(A$)+128 Changes the unlocked character (no *) to the one
   character in A$
Poke 44515,ASC(A$)+128 Changes the locked character (*) to the one
   character in A$
Poke 45994,ASC(A$)+128 Makes the B-type files show up as the one character
   type of file in A$
Poke 42344,76 Causes DOS 3.3 to forget to save a hello program when
   formatting a disk
Poke 44793,11 Makes DOS 3.3 forget to replicate itself when formatting a disk
Poke 44723,4 Makes DOS 3.3 mark tracks 1 and 2 as free when formatting a disk
Poke 44578,234:Poke 44579,234:Poke 44580,234:Poke 44567,12 Makes next catalog
   appear in 2 columns
Poke 43364,255 Allows you to save a binary file 65535 bytes long
Poke 43273,65 Changes DOS 3.3's INIT syntax so that no filename is required
   after the INIT command
X=PEEK(46725) Determines DOS version - if X=165 then DOS 3.3.0; if 186 then
   DOS 3.3e; if 182 then DOS 3.3f; if 206 then ProntoDOS
Poke 43139,0 Locks up the computer; RESET has little effect
Poke 40514,X   If X=6, then DOS 3.3 will RUN the HELLO file; if X=52 then DOS
   3.3 will BRUN it; if X=20 then DOS 3.3 will EXEC it
IF PEEK (48705)=0 then TRACE is off
IF PEEK (48706)=0 then no program is running
IF PEEK(-1101)=6 then the computer in use is a //c or //e
Peek 47095 = Last slot used
Peek 47096 = Last drive used
IF PEEK (49249) AND PEEK (49250) > 127 THEN PRINT "NO PADDLES IN"
IF PEEK(-16384)>127 then a key has been pressed (POKE -16368,0 resets this)
X = PEEK (-16336) Clicks the speaker
IF PEEK (-16284) > 127 then joystick button 3 has been pressed
IF PEEK (-16285) > 127 then joystick button 2 has been pressed
IF PEEK (-16286) > 127 then joystick button 1 has been pressed
IF PEEK (-16287) > 127 then joystick button 0 has been pressed
Poke -16289,1 Puts .3 volts (1.6 MA) out pin 12 of internal joystick socket
   (Output 3 on at 0.3 volts)
Poke -16290,1 Puts 3.5 volts out pin 12 of internal joystick socket
   (Output 3 on at 3.5 volts)
Poke -16291,1 Puts .3 volts (1.6 MA) out pin 13 of internal joystick socket
   (Output 2 on at 0.3 volts)
Poke -16292,1 Puts 3.5 volts out pin 13 of internal joystick socket
   (Output 2 on at 3.5 volts)
Poke -16293,1 Puts .3 volts (1.6 MA) out pin 14 of internal joystick socket
   (Output 1 on at 0.3 volts)
Poke -16294,1 Puts 3.5 volts out pin 14 of internal joystick socket
   (Output 1 on at 3.5 volts)
Poke -16295,0 Puts .3 volts (1.6 MA) out pin 15 of internal joystick socket
   (Output 0 on at 0.3 volts)
Poke -16296,1 Puts 3.5 volts out pin 15 of internal joystick socket
   (Output 0 on at 3.5 volts)
Poke -16297,0 Hi-res
Poke -16298,0 Lo-res
Poke -16299,0 Switch from high-res page 1 to page 2
Poke -16300,0 Switch from high-res page 2 to page 1
Poke -16301,0 Allows graphics and 4 lines of text
Poke -16302,0 Full screen graphics - no text
Poke -16303,0 Shows text screen
Poke -16304,0 Shows graphics screen
X=PEEK (-16352) Toggles cassette output once - creates a "click" on a
   cassette tape
Poke -16427,234:Poke -16428,234:Poke -16429,234 If a disk is initalized after
   theses POKEs have been POKEd, it won't erase the language card
Call 62454 Turns hi-res screen to last color HPLOTted
FC58 Clear screen
FB40 Lo-res graphics mode
F800 PLOT (Accumulator,Y register)
F819 HLIN (Y register,contents of $2C) AT (Y register)
F828 VLIN (Accumulator,contents of $2D) AT (Y register)
FB2F Clears Hi-res screen, Lo-res screen, and accumulator
FD35 Wait for keypress
FDED Return contents of accumulator as 1 character
 
 
CONTROL CHARACTERS & SCHTICK
 
ESC @ = HOME
ESC F Clears stuff from under cursor
CTRL-S Pauses & unpauses program that is listing
ESC A = Move cursor right one column
ESC B = Move cursor left one column
ESC C = Move cursor down one line
ESC D = Move cursor up one line
CTRL-E RETURN = While in hex mode, shows contents of all registers
 
 
SPEED TIPS
 
-Frequently GOTOed & GOSUBed lines should be early in program
-Use NEXT instead of NEXT X
-Use variables instead of actual numbers
 
 
MISCELLANEOUS
 
PR#{8-255}=???
?=PRINT--Lists as PRINT
Joystick=150K Ohms
If PRINT PDL(N) When N=236-239, =POKE -16540+N,0
& = Jump to $3F5
X=FRE(0) = Clean string memory
Reserved words take up one byte
In hex, 0G = CALL 0
60 in hex (96 In decimal)= return to Applesoft
X=FRE(0) = X=Number of BASIC bytes free (If negitive, add 65536)
Syntax for DEF FN:
     10 DEF FN A(W)=2*W+W
     20 PRINT FN A(23)
     RUN
     Computer will return:
     69
If 43+ errors are going to be handled by ONERR GOSUB or ONERR GOTO, use this
subroutine in your program:
     10 POKE 768,104:POKE 769,168:POKE 770,104:POKE 771,166:POKE 772,223
     20 POKE 773,154:POKE 774,72:POKE 775,152:POKE 776,72:POKE 777,96
     30 CALL 768
If your shape table starts at 1DFC, enter (in hex):
     E8:FC 1D
Max. line #=63999
Each line can have 239 characters
136=token for GR
186=token for PRINT
A input routine that accepts commas and colons:
     10 PRINT "-YOUR QUESTION HERE-";
     20 CALL-657:A$="":FOR X=512 TO 767:P=PEEK(X):IF P<>141 THEN
     A$=A$+CHR$(P):NEXT X
  (A$ now equals the response)
Move hi-res page 2 to 1:
     10 REM S.H. LAM TECHNIQUE
     20 C$="2000<4000.6000M":GOSUB 100:END
     100 C$=C$+" N D9C6G":REM SPACE BEFORE AND AFTER N
     110 FOR I=1 TO LEN(C$):POKE 511+I,ASC(MID$(C$,I,1))+128:NEXT
     120 POKE 72,0:CALL-144:RETURN
The proper syntax for reading a 2-byte number:
     Q=PEEK(B)+PEEK(B+1)*256
   Q now equals the new value and B should have been previously set to the
   starting address of the 2-byte number
The proper syntax for storing a 2-byte number:
     POKE B+1,Q/256:POKE B,Q-(PEEK(B+1)*256)
   Q should have been previously set to the value to be POKEd in and B should
   have been previously set to the starting address of where the value is to
   be stored
FOR A=46010 TO 45999 STEP -1:PRINT CHR$(PEEK(A));:NEXT
   Shows you the current DOS 3.3 disk catalog header
To stop a DOS 3.3 catalog after it waits for your keypress, enter (in hex):
   BCDF:20 0C FD C9 83 D0 03 4C 7F B3 60
PRINT PEEK(54)+256*PEEK(55) Returns the address of the current output routine
PRINT PEEK(56)+256*PEEK(57) Returns the address of the current output routine
   if DOS is active, then you use:
PRINT PEEK(43603)+256*PEEK(43604) Returns the address of the current output
   routine
PRINT PEEK(43605)+256*PEEK(43606) Returns the address of the current output
   routine
To determine what to POKE into 40192 to move the DOS buffers to put your
   machine language routine there, use the following formula:
     DB=40192-(L+38)
   You would then POKE 40192,DB and CALL 42964 to make DOS rebuild the DOS
   buffers, and then load your machine language routine into DB+38.
 
DOS 3.3 buffer table:
 
  DOS Buffer #| Data Buffer  | Filename Field
  ------------+--------------+----------------
       3      |38400-38655   |  38957-38986
       2      |38995-39250   |  39552-39581
       1      |39590-39845   |  40147-40176
 
 
A FOR/NEXT loop being used for a rest (when playing music) should be:
   FOR R=1 TO RV:NEXT R with RV being equal to 500 for a whole rest.
 
10 D$=CHR$(4)
20 PRINT D$;"PREFIX"
30 INPUT PF$
40 PRINT "THE CURRENT PREFIX IS: ";PF$
 
To redirect information from slot 1 to a machine language routine at $300,
   type PR#1,A$300
 
To redirect information from slot 1 to slot 4, type PR#1,A$C400
 
To stop writing to a text file after an OPEN and a WRITE or READ command have
been sent, print CHR$(4)
 
$Cs0C often contains the card signature for the card in slot "s".
The x sometimes shows the brand.
 
0x not assigned
1x printer
2x X-Y input device
3x serial/parallel input/output card
4x modem
5x sound/speech card
6x clock
7x mass storage device
8x 80 column display card
9x network/bus interface
Ax special purpose
Bx reserved
 
 
_The Error Numbers_
 
0    NEXT without FOR
1    Language not available
2    Range error
3    No device connected
4    Volume write-protected
5    End of data
6    Path/file not found
7    Incorrect volume number
8    I/O error
9    Disk full
10   File locked
11   DOS-related syntax error
12   No buffers available
13   File type mismatch
14   Program too large
15   Illegal direct command
16   Applesoft syntax error
17   Directory full
18   File not open
19   Duplicate file name
20   File busy
21   File(s) still open
22   RETURN without GOSUB
42   Out of Data error
53   Illegal quantity error
56   RESET was pressed
69   Overflow error
77   Out of memory
90   Undefined statement error
107  Bad subscript error
120  Redimensioned array
133  Divide by zero
163  Type mismatch error
176  String too long error
191  Formula too complex
224  Undefined function error
254  Extra ignored
255  =Break=

Main | Links | Downloads | Apple // Texts | Apple // Specs | The "Sider" Hard Drive