Commodore 64 PRE-PROGRAMMING: SETUP, CONTROL, AND OPERATION

PROCESSOR CONTROL

RESET		SYS 64738
RESTORE		SYS 64759
CLOSE ALL	SYS 65511
UN-NEW to recover the program that was in memory before a NEW command blanked it out. Do the following commands all in one batch, about one and a half screen lines. Do not put a RETURN in the middle, do that at the end, after the CLR.
	POKE 2050,1: SYS 42291: POKE 45,PEEK(34):
	POKE 46,PEEK(35): CLR
SCREEN CONTROL
Text Color: For improved clarity or artistic design. [CTRL]1 thru [CTRL]8 for labeled colors and [C=]1 thru [C=]8 for 'extra' colors.
Text Color: POKE 646,0 thru 15
Text Reverse: For a highlight [CTRL]9 on and [CTRL]0 off
Case Change: [SHIFT][C=] 'Cursor Up': UC/graphics, all graphic characters
'Cursor Down': UC/LC for text and half of the graphic
Border Color: POKE 53280,0 thru 15 May also effect the monitor synchronization.
Screen Color: POKE 53281,0 thru 15
Color control 'poke numbers' are one less than the number on the key for [CTRL] 1-8 colors and 7 more for [C=] 1-8 colors.

SCREEN EDITING AND LISTING
LIST to print the loaded program on the screen, and control what parts are listed by including the line numbers:
LIST from#-to# or LIST from#- or LIST -to#

Edit the line number of a line that you want to duplicate or edit the line number and the line if you want a similar line.

If you delete a line from a program {type line# [RETURN]}, and want it back, you can recover it if it is still on the screen. Just put the cursor on the line and hit [RETURN].

To print the listing of a loaded program or disk directory:

	OPEN 4,4: CMD 4: LIST
	now the program listing prints. When it finishes, do
	PRINT#4: CLOSE 4
When you use OPEN commands directly from the keyboard, you may want to do a CLOSE n#: OPEN n#, d# because you get an error if you OPEN a channel that is already opened. You should also always CLOSE a channel after you use it.

DISK DRIVE CONTROL
DIRECT BASIC COMMANDS
	LOAD"program name",8	for BASIC programs
	LOAD"program name",8,1	for machine language, pictures
	LOAD"prog name",8:[RUN]	to load and run at once
	LOAD"*",8		first program, or same one
	LOAD"name*",8		use part of the name
	LOAD"ver?name*",8	? for unknown single character
	LOAD"$",8		load the Directory
	LOAD"$name*",8		load dir names that match
	SAVE"newname",8		put it back on the disk
The verify command checks that the disk and the memory are the same. If not, you get an error. The main uses are:
1) Did the SAVE store ok? (The disk should give an error if not).
2) Has the version in memory been changed from what is on the disk?
	VERIFY"name",8		checks the file you name
	VERIFY"*",8		checks the last used disk file 
OTHER COMMON DISK COMMANDS
These commands do not have a special BASIC name, so you must use an OPENed channel to send the command words to the disk drive. This is easier if you use the DOS WEDGE or a DOS cartridge.
Directly enter a disk command like this:
OPEN 15,8,15,"command to disk": CLOSE 15
If the command channel #15 is already OPEN, just use
PRINT#15,"command"
and CLOSE 15 when through giving commands. We use the second 15 in the OPEN because that is what the drive needs for commands. The first 15 is our choice and 15 is used just to go with the second 15. The first number (15) in the OPEN is what the PRINT# and CLOSE statements must match. The 8 is the usual disk drive device number.
If you use a wedge, the command is given like this:
@command or >command
for example: @S0:BADFILE to scratch that file.
(Your wedge or cartridge might use something other than @.)

Only the most common disk commands are listed here.

NEW	format a disk		"N0:name,id"
   	clear directory		"N0:name"   [no id]
RENAME	change file name	"R0:newname=oldname
SCRATCH	delete a file		"S0:name"
COPY	copy on disk		"C0:new=original"
COMBINE	copy files into one	"C0:new=old1,old2
VALIDATE  cleanup directory	"V" or "V0"

DISK DRIVE ERROR READOUT
To find out why the drive is flashing that light, you must read the error channel with the wedge, or with this short program which must be an entered and run program, it can't be a direct command. Use any line number that is not the same as a program line that is already in memory. Line number zero is a good one to try, do a LIST 0, if nothing lists, there is no line zero and you can use it. This example uses line zero.

0 OPEN15,8,15: INPUT#15,A,B$,C,D: PRINT 
A;B$;C;D: CLOSE 15: END
This is all one program line, on two lines of the screen.
DON'T PUT A RETURN IN THE MIDDLE OF IT, BUT SPACES DON'T MATTER AS LONG AS IT FITS ON TWO SCREEN LINES. The END is so that other program steps in memory will not run. When you do a RUN 0 command it will print the drive status: 0 OK 0 0 is the normal status. After that and READY is on the screen, you can type 0 to delete that line zero.
If you keep the line zero in memory along with a BASIC program you can use RUN 10 (if the other program starts with line ten) to start the other program.

GET A SEQUENTIAL FILE FROM DISK
TYPE FILE TO SCREEN
This one line program will type a sequential disk file on the screen. It must be done as a program, not as a direct command. Line zero, as shown, is a good line number to use.

0 OPEN 8,8,8,"filename": FOR I=0 TO 1: GET#8,A$: I=ST:
PRINT A$;: NEXT: CLOSE 8: END
You may need to omit the extra spaces.

PRINT FILE ON PRINTER
This short program is a quick way to printout a sequential file from the disk.

100 OPEN 1,4,7: REM OPEN PRINTER
110 OPEN 2,8,2,"filename": REM OPEN DISK FILE
120 GET#2,A$: IF ST=64 THEN 140: REM READ IN
130 PRINT#1,A$;: GOTO 120: REM PRINT OUT
140 CLOSE 1: CLOSE 2: REM FINISHED

PRINTER OR INTERFACE SETUP
Printing anything requires an opened channel to the printer, which may be through an interface. If you have an interface, you must send it the commands it requires. To print a heading on a page before running a program that will printout the page you can use these direct commands:

	OPEN 4,4
	PRINT#4,"THIS IS THE HEADING I WANT ON THE PAGE"
	CLOSE 4
The most basic control of the printer is by the OPEN command which sets the character selection that will be printed.
	OPEN 4,4,0   or   OPEN 4,4
gives upper case text and all graphic symbols (UC/Graphic) which is called 'cursor up' mode.
	OPEN 4,4,7 
gives upper and lower case text and some graphics (UC/LC) which is called 'cursor down' mode. Then you could do this:
PRINT#4,"This Is The Heading I Want On The Page": CLOSE 4
The third number after the OPEN (7 or 0 or blank in exa.) is called the secondary address, and may be given other values to do other control jobs if your interface or printer allows it. (Look in the manual.)

USING PRINTER CONTROL CODES
The next way to control the printer or interface is with control codes sent to it as shown:

	OPEN 4,4: PRINT#4, CHR$(code1) ;CHR$(code2): CLOSE 4
If only one code is needed, drop the extra ;CHR$(code2) but many printers use 'escape codes' or 'escape sequences' in which the code1 number is 27 and then the next number is put in as code2 to give the particular command. You may also need to add other codes like this:
	;CHR$(code3) 
Control codes do not have letters or symbols that should be printed, they are just to control the printer. The escape code tells the printer not to print what is comming next, to use it for control instead, so normal letters and numbers may be used for control after the escape code (27.).
Different printers will have different control codes, but some are standardized (ASCII). These control codes should work with almost any printer.
  CHR$(code)	PRINTER ACTION
   	 0	Null, do nothing
   	 7	Bell or beep
   	 8	Back space, if it can
   	 9	Tab to a stop, if it has them
   	10	Line Feed, or New Line with return
   	11	Vertical Tab, not many do this
   	12	Form Feed to the next page
   	13	Carriage Return, same or next line
   	27	Escape from printing, do control
 


Other codes that can be used in the command line
	OPEN 4,4: PRINT#4, CHR$(code1) ;CHR$(code2): CLOSE 4
are common to Commodore 1515 or 1525 printers or printers that emulate Commodore printers. Some of these can be used to set the printing features before another program does the printing. Check your interface or printer manual to see if there is a control code that will LOCK in the setup that you do to keep the later program from changing it.
      (code)  	ACTION
	 17	set UC/LC cursor down text mode
   	145	set UC/Graphic cursor up mode
   	 18	set reverse video printing (light-for-dark)
   	146	set reverse off, to normal
   	 15	set 10 CPI normal size print
   	 29	set 17 CPI condensed size print
   	 14	set double width print, use after 15 or 29
   	15&14	5 CPI double normal
   	29&14	8.5 CPI double condensed
   	27&65	skip page perforations
	27&66	turn off perforation skip
The double codes (like 15&14) are code1 and code2 for the print statement CHR$()'s and the & is not used. These codes work on the OKIMATE 10 which is emulating a 1525. Here is an example of a control code that uses a string of numbers to complete the control information:
	OPEN 4,4:PRINT#4,CHR$(16);"03";"THIS IS PRINTED":CLOSE 4
this will indent the printed line by three spaces, called for by the 03. The CHR$(16) can be printed in the middle of a line of text and then the next two digits will give that number of spaces in the printed line.

W. L. Mays


  • Return to Library
  • Return to Main Page
    This page hosted by Get your own Free Home Page
    1