NEW UTILITY WEDGE (third upload) Command Summary * read disk error channel ** send DOS command to disk *a auto line numbering or renumbering *b read or write a disk block *c copy a file or entire disk, change a file type, recover scratched file *d delete a range of lines *f show how much free memory *g get disk directory *l show load address of program file *m enable Micromon monitor *p print seqential file *q disable (quit) wedge *t text editor *u un-new a program *x dump screen to printer *! computer cold start (reset) *# change wedge # *= change disk drive # (and wedge #) *+ change border color *- change background color *\ change character color *? show command menu */ load program file *@ load program file to header address *^ load program file and run it *_ save program file *: load seqential file *; save seqential file *, load user file *. save user file The following commands are available when using Micromon (*m) a assembler b break set c compare memory d disassembler e disconnect micromon f fill memory g go run h hunt memory j jump to subroutine l load memory from device m memory display n new locator o offset or branch calculate p printer toggle (serial bus) q quick trace r register display s save memory to device t transfer memory v verify memory with device w walk through program x exit to basic (brk enabled) " ascii conversion # decimal conversion $ hex conversion % binary conversion & checksum memory ( enable command tone ) disable command tone + add hex numbers - subtract hex numbers > disk directory Command detail and syntax I wrote this program with several objectives in mind........ I wanted to be able to access a lot of utility programs without having to load them in every time I wanted to use one. Also, I did not want it to slow down the running of programs, change any of the standard basic commands, nor use up any of the basic memory space. I also wanted to be able to use abbreviated DOS commands. The wedge resides in memory from hex $a001 to $cfff. Any program that does not use memory in this range should be able to co-exist. When Micromon is in use, the casette buffer is also used. About 2/3 of the memory used by the wedge is under the basic rom. Since the wedge is all machine language, basic is not needed to perform any of the wedge commands, and is switched out (temporarily) while they are being performed. All wedge commands must be preceeded by an asterisk (*). The asterisk tells basic (direct mode only) that the command that follows should be turned over to the wedge interpreter. You can load the wedge with the following command: load"wedge",8,1 Next, NEW and enable the wedge with SYS49152. The wedge is now ready and set to communicate with disk drive # 8 (default setting). Or you can use the boot program (bootwg.img) to automatically load, enable the wedge and display the command menu for you. Like this: load"boot",8,1 The boot and the wedge must be on the same disk. Rename the wedge program WEDGE and the boot program BOOT if you didn't do that already, or all you'll get is an i/o error #4 (file not found) when you try to use the boot. Notes: Unless otherwise noted, any references to numbers can be in decimal or hex. If you specify hex, the number must be preceeded by the $ symbol. Example ---- 42 (decimal) or $2a (hex) Commands which write data to buffers in the 64 will not disturb basic programs, nor will they overwrite variables or strings. Buffers are allocated by the wedge from areas that have not yet been used by your basic programs. The wedge finds these areas by reading the vectors at locations 49 through 52. * This command alone will read the error channel of the disk drive and print it on the screen. ** Sends any text following the ** to the disk drive as a DOS command. Examples: **n:diskname,id -> formats a disk **i -> initializes the drive **s:filename -> scratches a file **v -> validates a disk **r:newname=oldname -> renames a file *a,10 *a,1000,10 *a This command can take any of those three forms. The first will enable auto line number feeds. After giving the command, you can start the process by typing in a basic program line. When you press return, the next line number will be waiting for you on the following line, and the cursor will be waiting one space to the right of the number. Auto line number feeds will be discon- nected automatically when any function is performed other than editing or entering program lines. This includes listing or running programs, pokes, peeks, etc. (otherwise it would interfere with these functions). The number following the comma can be any number from 1 to 63999. The second form of this command (two numbers) is used to renumber a basic program residing in the 64. The first number is the number you want the first line to be, and the second is the step size between line numbers. The third form of this command disconnects auto line number feeds. *br,$20,$2 *bw,$20,$2 The *br command will read a block of data from the disk, display the location of the buffer where the data is stored, and enable Micromon so that you can display the data (see Micromon command docs). Since Micromon displays it's information in hex, it's usually a good idea to specify hex numbers in the block-read and block-write wedge commands (to avoid confusion). The first number is the track, the second is the sector (block). The *bw command will write a block of data from the buffer to a block on the disk. This command is usually used after a block-read command, where you have modified the data and wish to write it back to the block. This command is very powerful. If you goof using it, you can really mess up a disk, so it's a good idea to have an extra copy of the disk on hand as insurance. For this reason, you will also be prompted to confirm your intent to write to the block (makes you think about it one last time). *c:filename *c:filename,type *c* *c** The *c:filename command is used to make copies of single files. The file is read into a buffer from the source disk, and you are prompted for another disk (must be formatted). Once you have inserted the destination disk, pressing RETURN will cause the buffered file to be written to it. For large files, it will be necessary to swap the disks until the entire file is copied (you will be prompted to do so). Example....*c:wedge will copy the file named "wedge". No need to specify file type, as that info is read from the directory. If you use this command on a file that has been scratched, it will recover the file (not copy it). The file will be recovered as a program file unless you specify otherwise, as in the following command. The *c:filename,type command is used to change file types, or to recover scratched files as a particular file type. For example, *c:wedge,s will change the file named "wedge" to a seqential file, or will recover a scratched file named "wedge" as a seqential file. One final note on copying single files........relative files are not supported. However, you can copy relative files with the next 2 commands. The *c* command will make a copy of the entire disk. Disks with a lot of data on them will need to be swapped a few times (you'll be prompted), and the destination disk must already be formatted. All blocks allocated in the BAM will be copied. The *c** command will cause all blocks to be copied, whether they are allocated in the BAM or not. *d100-400 *d-300 *d200- Deletes a specified range of program lines. In the first example, all lines from 100 to 400 (inclusive) will be deleted. In the second, all from 0 to 300 and in the third, all from 200 up. This command also performs a CLR. *f Reads out how much unused memory is left for basic in hex and decimal values. *g Prints the directory of the disk to the screen. This command will not disturb basic programs like the load"$",8 command does. Pressing the CTRL key will slow the display, any other key will stop it and return you to command mode. *l:filename Reads out the load address of a program file in hex and decimal *m Enables Micromon, a machine language monitor program. Many versions of this program exist, so I won't go into a detailed list of the commands and their syntax. There is good documentation available in Compute's First Book of Commodore 64, though, and the version used in the wedge is very similar. Some of the differences are that the wedge version resides under the basic rom from $b000 to $bfff, and is supported by several wedge subroutines; the 'p' command toggles the printer (device 4) on the serial bus instead of on the RS232 port; etc. Not different enough to matter much. *p:filename Prints a sequential file to the screen or to a printer (device 4 on the serial bus). Pressing the CTRL key while printing to the screen will slow the display, any other key will pause. While paused, pressing 'x' will terminate the operation, any other key will resume it. *q Disables the wedge program. To re-enable it, you must SYS49152. *t Enables the text editor...see the additional writeup at the end of this DOC. *u Un-new's a program. This command is useful to those of us who accidentially type NEW and wish we hadn't. It will recover the program (as long as you haven't loaded in another one yet). Also performs a CLR. *x Dumps the screen to the printer. The command line is erased just before the dump so that you can copy the screen without having *x show up on your printout. It's good practice to issue this command from a line other than the last (issuing it from the last line will cause the screen to scroll). This is a fairly simple screen dump utility. It will not support bitmapped screens, reverse video will be printed as non-reverse, etc. However, it will support upper and lower case characters and CBM graphics characters. It does it by reading the register at $d011 prior to opening the printer file. If the mode is upper/lower case, a secondary address of 7 is sent to the printer, else it sends a zero instead. Tested with the CBM 1525, Prowriter 8510 and the Hewlett-Packard "Thinkjet". *! Sends the computer to it's cold start routine (same as typing SYS64738) *#9 Switches the wedge number so that you can communicate with a disk drive of a different address (device 9 in this case). You can specify a device number from 8 to 31, but you must specify it in decimal (as in the example). *=9 Changes both the wedge number and the number of the disk drive you are currently communicating with. If you are currently dealing with drive 8, giving this command will change the drive number to 9 and set the wedge to communicate with device 9. Same syntax rules apply as in *# command. *+14 *-14 *\5 These commands change the border, background and character color respectively. *+14 would change the border color to light blue, *-14 changes background to light blue, and *\5 will make the text green. Numbers must be specified in decimal. You can give these commands without numbers (*+ *- or *\). In this case, the color will be incremented to the next higher-numbered one. *? Displays an abbreviated command menu for quick reference. */filename *@filename *^filename *_filename The first example loads a program file the same as load"filename",device. The second is the same as load"filename",device,1. However, the basic pointers will not be disturbed. This command is usually used to load machine language programs, and works the same as the DOS WEDGE command %filename (loads to the file header address). The third example will load and then run a program (usually used on basic programs). The fourth is used to save a program, as in save"filename",device. In all of these examples, you can specify addresses (optional). If you specify addresses for the save command, the syntax must follow this form: *_filename,addr1,addr2 The first address is the start of the save, the second is one byte MORE than the last address to be included in the save. Addresses can be hex or decimal. For the load commands, the syntax is like this: */filename,addr *@filename,addr *^filename,addr Specifying a load address will cause the basic pointers to remain untouched, will override header addresses and cause the load & run (*^) command to default to load only. *:filename *;filename These commands will load and save seqential files, respectively. I use it to put files into RAM somewhere (I usually specify an address to load to) so that I can examine the data with Micromon. Once in RAM, the data can be modified and written back, ignored, whatever. Addresses are optional here, too. *,filename *.filename Load and save user files, repectively. Addresses optional. TEXT EDITOR Due to memory limitations, this is a SIMPLE text editor, but it will still allow you to do some unique things. You can load or save files in standard ASCII or PETascii (CBM files), set or reset margins or page length at any time, merge text files and more. And, for me anyway, it's a very uncomplicated and easy to use editor. No imbedded commands, scientific syntax, etc. Creating a document From the EDITOR menu, clear the text buffer by selecting 1 and pressing RETURN. You will be asked to confirm the command (just a safety precaution for those like me who sometimes forget to save things before erasing them). Next, set up the margins and page length you want with selection 2. Default values are: left margin 5, right 75, lines per page 66. Just pressing RETURN@3 times will put those values in place. Now you can enter the edit mode with selection 3 (default menu selection). If you ever get a ?FORMAT ERROR message, it will probably be because the text buffer was not initialized before entering the edit mode for the first time, or the margins were set to illegal values (left > 77 or too close to right or right > 80). NOTE: You can return to the menu at any time by pressing the STOP key. The screen will clear and (if you used the default margin values) you will see bars at the left and right sides of your screen. These are the margin markers, and at the bottom of the screen will be a status line. You will not be able to type into the margin markers, as they are there to help you format your text and let you know where your lines start and end. All screen lines will be combined in pairs as 80 column lines, which will leave you with 12 lines on the screen at a time. You can identify which page, line and column the cursor is on by reading the status line at the bottom of the screen. Type a line of text. At the end of the line, press RETURN to get to the next line, or just keep on typing. Words will not be broken at the right margin marker, because of the editor's automatic PARSING feature. If the last letter on a line is not a space, the editor will move the entire word to the next line for you. There are some safety features built into this routine, too. If there is text on the next line, parsing will not take place. This allows you to edit a previous line without accidentally dumping text on the next one. Also, parsing will not operate on words longer than 10 characters. That was done to allow the use of long strings of dashes (as in some of the previous lines in this DOC). Parsing is there to allow you to type without having to watch the screen. Be wary of shifted spaces...the editor treats them as characters (not spaces), and they can cause unexpected results, especially if they are on the next line...the editor will not parse, thinking there is text there. This can be used to FORCE a word to stay on the previous line, should you want it to. An example of this is the word at the end of this line.. end. CURSOR KEYS Cursor right and left work as you would expect them to. Cursor up and down are a bit different. They move the cursor 2 screen lines at a time (which is really ONE 80 COLUMN@LINE). The insert and delete keys will work as expected, but only on the current line. When holding the delete key down, the cursor will make it's way only as far as the left margin. If you want to delete part of the previous line, move the cursor there with a cursor left, and then continue deleting. The insert key will push all text from the cursor position on towards the right margin. Text pushed into the right margin cannot be recovered. The home key works normally, but screen clear is not supported. CTRL D and CTRL I CTRL d will delete the current line and draw all forward lines in to close the gap. CTRL i will open up a blank line, pushing all lines forward from the current line on. Holding CTRL d or CTRL i will allow you to quickly delete or insert large portions of text. SCROLLING THE SCREEN AND THE@TEXT@BUFFER Attempting to move the cursor past the bottom of the screen will cause the screen to scroll forward. Reverse scrolling will happen at the top of the screen. When you move the cursor to the end of available memory, forward movement will stop. The same is true for reverse movement at the screen's top. If you plan to create or load a big document, you should free up as much memory as possible by typing NEW in the command mode prior to entering the editor. Be sure to clear text memory too, or you may get a screenful of "garbage" or a ?FORMAT ERROR message when you attempt to enter the edit mode. 481 lines are available with a big buffer like this (8 pages at 60 lines per). LOADING FILES You can load an ASCII file or a PET-ASCII file. If the file was not created with this editor, the margins will default to 0 (left) and 80 (right), otherwise the editor will create the margins from information contained in the first few bytes of the file. More on how it does this later. It's a good idea to clear text memory before a load, though, or you will have some merged text...it's surprised me at times. This can also be used to some advantage. After a load, you will be returned to the editor menu. Pressing RETURN@will put you into the edit mode where you can read the file, edit it or re-save it as either an ASCII or PET-ASCII file. I use the latter trick to convert files all the time. SAVING FILES Same options are available, but you may want to know a few of the technical details of the save. All blank lines are saved as a carriage return (or a carriage return and linefeed for ASCII files). Also, carriage returns are added at the end of pages to provide perforation skips for your printer. The editor will assume your text page is 66 lines per page. If you have your lines per page set at 60 (function 2 from the menu), 6 carriage returns will be added after every 60 lines. If you don't want these added to your file, just reset the lines per page to 66 prior to saving the file. If you reload a file that has these extra CR's, you'll see blank lines inserted in your text. Resaving such a file without first deleting these lines could cause chaos in your page formatting, so be sure you either delete the lines or reset the lines per page to 66 prior to resaving. Also, if you save a file that "maxed out" your text buffer, the extra CR's will cause a reload to ignore the last part of your lengthened document, so be aware of these details when you save. All files saved by the editor contain information for setting up the left and right margins. This information is contained in the first few bytes. To explain this, let's assume you are saving a document with a left margin of 5 and a right margin of 75. The first 5 bytes of the file will be nulls (binary zeros), the next byte will be a 128 (separator) and the next 5 bytes will be nulls. To printers, nulls and 128's are transparent...they are ignored. These characters are also ignored by most BBS systems. CIS ignores them just fine. However, the editor does not ignore them, and uses them to set up the margins when you load the file. If your margins were set to 0 left & 80 right, no nulls or separator bytes will be saved in the file. This makes the editor useful for creating or editing source code files for an assembler (like the CBM assembler). MERGING TEXT FILES Here's how you do it...load the first file and place the cursor past the last line in the file (in the edit mode). Press the STOP key to take you back to the menu and load the second file. The second file will start loading from the line you left the cursor on when you went to the menu. Armed with that information, one could merge (or insert) text from one file into another just by leaving the cursor in the appropriate place in the text. You can even do a "cut and paste" operation by opening up a gap in your text with CTRL i and merging text from another file into the gap. By now you have probably found out that you can leave the editor and do other things without losing your document. If you use another wedge function that writes to a buffer (like *b, *c, etc.), or disturb the basic start-of-variable storage pointer, you'll have a lot of trouble recovering your document. What you CAN do is exit to print, scratch or rename a file, read the directory, or use any other command that doesn't disturb pointers or re-allocate buffers. PRINTING A FILE Use the wedge *p seq file printer for this. The file must be a PET-ASCII file, so if you want to print an ASCII file, you will have to load it and save it back as a PET file prior to printing it. Don't forget to save it with the appropriate lines per page (with or without perf skip carriage returns). USING LETTER.IMG FILES If you have text files created by LETTER.IMG (in the other CBM sig), you can load them into memory directly with the wedge and convert them to normal text files with the editor. LETTER files are made up of screen codes, with the first 48 bytes of the file containing formatting variables. The editor stores text in memory (and updates the screen) with screen codes also, so here's how you do it: Free up all available memory with NEW and enter the editor. Clear text memory and set the margins to 0 and 80. Next, return to command level and load the LETTER file with this command: *:filename,$08d0 Re-enter the editor and go directly into the edit mode, moving the cursor to the end of the text to set up the document end pointer. If margins don't look right, you can reset them from the editor menu (selection 2). If you resave the file with the editor, any reverse video characters will be converted to non reverse, since the editor does not support those enhancements (as LETTER.IMG does). Also, you will not be able to pass editor files back the other way, only from LETTER.IMG to the editor, as described above. ****************************************************************************** Well, that's that. I'd appreciate feedback from those of you who download this program, and my thanks go to those of you who provided such feedback on the original two uploads. Some of the ideas you had were incorporated into this version, and some I had to put aside due to memory limitations, but I appreciated them all. Regards, Jim Klitzing