From: pap@dana.ucc.nau.edu (Paul Allen Panks) Newsgroups: comp.sys.cbm Subject: Re: PROGRAMS TO TRY: BASIC 2/7 Date: 13 Dec 1995 06:24:28 GMT NOTE: The following thread deals with disk commands and other common commands in the BASIC 2.0 and BASIC 7.0 programming languages. It is written with the first time user in mind. However, it may also be a could refresher lesson for long-time Commodore users as well. For a refresher course in BASIC COMMANDS, please read further: DISK COMMANDS [BASIC 2.0]: Section 1.0 - LOADing a Program from disk First off, make sure the disk is properly inserted in the disk drive BEFORE you attempt any of the following commands. The disk should be placed in the drive LABEL UP. If the disk does not have a label, then it should be placed as such: _ | | |DISK DRIVE | = = | |HATCH: ===| |=== OPEN: Counterclockwise | ========U===== | | | |_| CLOSE: Clockwise \_________________/ | U |O| ___ ___ ___ \__________-_________/ | | | 0 | | _ | /|\ | |O| | | | - | | ] |LABEL| | (Insert this way) |___________| The "O" in the middle is the ring. The oval-shaped, smaller "0" near the top of the disk is the other one. Insert the disk until it cannot be inserted any further (WARNING: Do NOT force it in, go gently). Also, when you insert it, close the latch on the drive completely (turn it clockwise until it stops) To LOAD a program, [ENTER] the following: LOAD "", 8 Where '8' is the device number and is any name up to 16 characters in length (inluding spaces). Note that an invalid Program Name might be: $,*,or @, because these commands are reserved for disk access (i.e. '$' lists the directory in Track 18, Sector 1,'*' is a wildcard, and '@' is the save-with-replace command) The device number can be either '8' or '9' depending on if you have a second external drive or not. In the case of LOADing a Machine Language Program (i.e. most Commercial programs), use the following syntax: LOAD "", 8, 1 Where '8' is the device number and is any name up to 16 characters in length (including spaces), and the '1' is a flag that tells the computer to LOAD a Machine Language Program into memory and execute it (provided the Program is self-LOADing). Section 1.1 - SAVEing a Program to Disk Sometimes, the user may want to SAVE a Program he/she has worked on to Disk. In that case, the syntax used is: SAVE "", 8 Again, where '8' is the device number and is any name up to 16 characters in length (including spaces). An optional '1' flag can be appended to the command in order to SAVE a Machine Language Program to Disk. In that case, the following syntax can be used: SAVE "", 8, 1 Where '8' is the device number and '1' is the flag that tells the computer to SAVE a Machine Language Program to Disk. Now that the basics of LOADing and SAVEing have been covered, let's move on to other, more advanced disk commands. Section 1.2 - ADVANCED Disk Commands In a nutshell, the following describes three essential disk commands: 1. Getting the DIRECTORY of a disk 2. VALIDATEing a Disk 3. VERIFYing a Program 1. DIRECTORY of a Disk - The easiest way to get a DIRECTORY of a disk is to use the following command in direct mode (non-Program mode): LOAD "$" ,8 Where '8' is the device number and '$' is a flag that tells the disk drive to print out on the screen the contents of a disk. After a short pause (if there hasn't been an error), the screen will say: LOAD "$" ,8 SEARCHING FOR $ LOADING READY. After which the user types: LIST Pressing RETURN after LIST will generate the following display (contents may vary depending upon the disk): 0 |"MY DISK " RY 2A | 3 "HOW TO USE" PRG 8 "SEQ FILE READ" PRG 10 "BAM TEST" PRG 4 "AUTO SALES" SEQ 21 "2.0 BASIC DEMO" PRG 7 "I AM THE MAN!" REL 45 "DATABASE STUFF" USR 2 "DATABASE.LDR" PRG 0 "LOOPING MAGIC" PRG* 554 BLOCKS FREE. The following example, of course, may or may not be true of every single disk and its contents. However, it was done to show you an example of what a disk directory looks like, as well as show you 4 different types of files that can appear on a disk: PRG - BASIC or Program Files (usually BASIC files) SEQ - Sequential Program Files REL - Relative Program Files USR - User Program Files DEL - Deleted Program Files (EXTREMELY RARE) (NOTE: The PRG (Program File) listed in the above example with an asterisk '*' by it is called a SPLAT file. These files occur when the user has improperly SAVEd a program to disk. This happens when an attempt is made to SAVE a program, but the size of the program exceeds the number of BLOCKS available of disk (i.e. in our example, this would not be the case because 554 BLOCKS are Free, however, if a 45 BLOCK program is attempted to be SAVEd onto a disk with LESS than 45 BLOCKS free, a SPLAT file will occur. WARNING!!!: _NEVER_ attempt to DELETE a SPLAT file, as any attempt to do so will disallocate BLOCKS on the disk and thus could scramble important data (i.e. all file types in the directory as listed above. If a SPLAT file should occur, IMMEDIATELY use the DISK VALIDATE command described in the paragraphs proceeding this one). Space limitations won't allow me to go into each type of file in great detail. However, here is a brief description of each: PRG (Program Files) - These type of files can be LOADed or SAVEd easily. Most of these types of files are BASIC programs or, rarely, Word Processor files. SEQ (Sequential Files) - These types of files cannot be LOADed or SAVEd normally. Briefly, a Sequential file stores and retrieves DATA to disk. Here is a short program that creates a Sequential file: 10 OPEN 2,8,2,"MY FILE,S,W": REM OPEN CHANNEL TWO AND CREATE A SEQ FILE 15 INPUT"WHAT IS YOUR NAME?";N$: REM ASK FOR DATA USING INPUT STATEMENT 20 PRINT #2,N$: REM WRITE DATA TO DISK USING CHANNEL TWO 25 CLOSE 2: REM TIDY UP AFTERWARDS In the above example, in line 10, 'S' is the abbreviation for 'SEQUENTIAL' and 'W' is the abbreviate for 'WRITE'. The 'S' tells the computer to OPEN a SEQuential File, and the 'W' tells the computer to WRITE that file to disk under the name in the quotation marks. Line 15 asks the user to enter his/her name using the keyboard. Upon pressing RETURN, the program jumps to line 20, which does the actual WRITEing of the DATA to disk. 'N$' is the variable that stores the NAME of the person. The fina line, 30, CLOSEs the file. IMPORTANT: It is always necessary to CLOSE a file before opening any others. If not done properly, this may disallocate BLOCKS on the disk and thus the VALIDATE command described in a following paragraph must be used. To READ the file back from the disk, use the following program: 10 OPEN 2,8,2,"MY FILE,S,R": REM OPEN CHANNEL TWO TO READ FROM 15 INPUT #2,N$: REM READ BACK THE DATA FROM STRING 'N$' 20 PRINT N$: REM PRINT NAME TO SCREEN 25 CLOSE 2: REM TIDY UP AFTERWARDS The only thing different in this example is: 1) The 'R' in Line 10 tells the computer that it will be READing our SEQuential file from disk into memory. 2) Line 15 READs the DATA from the string 'N$' (used in the previous program) using the INPUT statement, and Line 20 PRINTs the DATA (the person's name) to the screen. IMPORTANT: Do not get the INPUT command used in the previous program before this one confused with the INPUT command used in this exmaple. INPUT has two purposes: 1) To get INPUT from the keyboard, and 2) To get INPUT (or READ) information from a SEQuential File, as we did above). The above programs can be used in more advanced ways, but because of space limitations we cannot get into the matter further. USR (User Files) - Essentially, these files can store any kind of DATA, and are quite advanced for the beginning user. Therefore, we will not attempt to explain this command at this time. REL (Relative Files) - These types of files are more flexible and thusly more advanced than the SEQuential file types. Essentially, these files can store information in any order the user chooses. These are much faster than SEQuential files in that they don't have to be read sequentially. That is, from the beginning to the end all the way through. SEQuential files are handy for storing information, but lack the speed of RELative files. We cannot get into this topic further because these commands are difficult to explain as well as implement in a Program. DEL (Deleted Files) - These file types are extremely rare and will rarely, if ever, show up on a directory. If they do, it may be because the user failed to close a file properly upon deleting it (this can be caused by a disk error). VALIDATEing a disk If an error should occur, especially with a SAVE command or a SEQuential file (the disk drive will usually blink constantly to tell the user an error has occured), the DISK VALIDATE command should be used. This is usually the case as described in previous paragraphs about a SPLAT file. To review, a SPLAT file is any file that has tried to be SAVEd to disk, but the size (i.e. BLOCKS) of the program exceed the number of available BLOCKS, or BLOCKS FREE. The following command performs a DISK VALIDATE command: OPEN 15,8,15, "V0":CLOSE 15 Where 'V0' is the flag which tells the computer to perform a DISK VALIDATE command. CLOSE 15 tells the computer to CLOSE channel 15 (the one used in this example). This can be ENTERed in either DIRECT MODE or within a BASIC PROGRAM. However, DIRECT MODE is more convienent. What this command does is re-allocate any and all available BLOCKS so that any BAD BLOCKS (or disallocated BLOCKS) are wiped out, thus space is made for the GOOD BLOCKS not damaged by the disk error (or SPLAT file). PROGRAM VERIFY COMMAND Sometimes a user may want to check and see if a program is either existent on disk, or has been SAVEd properly (without error). In that case, the following PROGRAM VERIFY command can be used: VERIFY "", 8 Where '8' is the device number and is the name of the file up to 16 characters in length (including spaces). Upon pressing RETURN, hopefully the user will see: VERIFY "" ,8 VERIFYING OK READY. This means that the program was SAVEd properly to disk. However, if the disk drive light starts blinking, the screen probably says: VERIFY "", 8 VERIFYING ?VERIFY ERROR READY. This means that an error has occured with the SAVEd program. In other words, the program would have a LOAD error and would not LOAD properly. This, again, is due to an error in the attempt to SAVE the program. In this case, the file should be deleted and the disk VALIDATEd. There are other disk commands, such as RENAMEing a file,SCRATCHing a file,etc., but we will not get into them for now. The examples described above are the first commands you should know and the most important ones. In the meantime, have fun with your new disk drive! (or computer, as may be the case). Happy Computing! ;) Regards, Paul Allen Panks -- ------------------------------------------------------------------------------ This signature file was brought to you by Paul Panks, not Micro$oft, IBM, or any of those other money-sapping, machine-wasting companies bent on world domination. Did you here that Micro$oft wants to purchase the Catholic Church? I don't think Bill Gates would make a very good choir boy. I think its time to put our foots down and stop this maniac before he declares his campaign for the Presidency! *** Check out Jim Brain's WWW Page at: Http://www.msen.com/~brain/ *** (You'll be glad you did!) "If you quote me on this, I'll have to deny it. Besides, my memory is *terrible*. I forget things often. Also, my memory is *horrible*." ------------------------------------------------------------------------------ From: pap@dana.ucc.nau.edu (Paul Allen Panks) Newsgroups: comp.sys.cbm Subject: Re: PROGRAMS TO TRY: BASIC 2/7 Date: 13 Dec 1995 19:02:47 GMT (continued from previous thread): ADVANCED BASIC 2.0 COMMANDS: Earlier, we discussed such commands as LOAD, SAVE, VALIDATE, etc. However, as you probably have learned by now, there are many more commands that you can use to your advantage. In the following couple of paragraphs, we will examine five of these new commands: 1. PRINT 2. TAB 3. SCREEN CODES (COLOR) (Colors 1-8) (Colors 9-16 NEXT thread!) 4. POKE (brief overview) 5. SCREEN CODES (CHR$,SPC, and others) (NEXT thread!) 1. PRINT - Probably one of the simplist to use of all BASIC 2.0 commands, the PRINT statement is used to display characters, letters, and even numbers on the screen. One of the simplist uses for the PRINT statement is used as an example in the PROGRAM below: 10 PRINT"HELLO" When RUN, the screen will say: HELLO READY. The READY prompt is always there, but above it we have the word "HELLO". Try the following program for another example of the PRINT statement (be sure and type NEW before you enter this program): 10 PRINT"I ADORE MY COMMODORE 64" 20 GOTO 10 When RUN, the screen will say: I ADORE MY COMMODORE 64 I ADORE MY COMMODORE 64 I ADORE MY COMMODORE 64 I ADORE MY COMMODORE 64 I ADORE MY COMMODORE 64 ... And so on. The screen will keep on scrolling the message "I ADORE MY COMMODORE 64" until the user presses the RUN/STOP KEY. The screen now says: I ADORE MY COMMODORE 64 I ADORE MY COMMODORE 64 I ADORE MY COMMODORE 64 I ADORE MY COMMODORE 64 I ADORE MY COMMODORE 64 ?BREAK ERROR IN LINE 10 READY. The error message "?BREAK ERROR IN LINE 10" is really not an error at all. What the computer is really telling us is that program execution has been halted (via the RUN/STOP key). Line 10 PRINTs the message "I ADORE MY COMMODORE 64" to the screen, and Line 20 tells the computer to go back to line 10 continuously. Thus, the scrolling output. This program will RUN as long as the program is not halted. Now that we have the BASICs of the PRINT statement down, let's move on to more advanced discussion of the PRINT statement: formatting. Using the TAB Function Formatting involves a command known as the TAB function. What this function does is position text a specified number of spaces (up to 40) horizontally along a single screen line at a time (this function works almost exactly like the TAB function on a typewriter). In order to use the TAB function properly, keep in mind that you can use any number between 0 and 255, however, you should keep it to 0-39 per line for simplicity purposes. The program below demonstrates a good use for the TAB function: 10 PRINT"THE 'TAB' FUNCTION IN ACTION!" 20 PRINT TAB(3)"THIS IS 3 SPACES TO THE RIGHT" 30 PRINT TAB(10)"THIS IS 10 SPACES TO THE RIGHT"; Note the ';' after Line 30 (more on that in a moment). Here is what the screen would PRINT in the above example: |THE 'TAB' FUNCTION IN ACTION! | | THIS IS 3 SPACES TO THE RIGHT | | THIS IS 10 SPACES TO THE RIGHT| Line 10 tells the computer to PRINT the words "THE 'TAB' FUNCTION IN ACTION!". Line 20 is a little more complicated. What it does is TAB the cursor over 3 spaces to the RIGHT, and start PRINTing the words "THIS IS 3 SPACES TO THE RIGHT". The ';' after Line 30 serves an important purposes when formatting text to the screen. Because the screen display can accomodate only 40 X 25, a maximum of 40 spaces (or characters) per line is allowed, for up to 25 lines. If a ';' were NOT used in the above example, the following would occur: |THE 'TAB' FUNCTION IN ACTION! | | THIS IS 3 SPACES TO THE RIGHT | | | | THIS IS 10 SPACES TO THE RIGHT| Note that there is a one line space between the second phrase and the third one. This is because the screen "wraps" around to a new line upon reaching the 40th space (or character) on a line. This is because only 40 spaces (or characters) can be displayed per line at a time. This is a useful feature in Word Processors, however, it doesn't seem to help us any here. So the ';' is needed in this instance. The ';' flag can also be used to append one phrase to another. An example of this is given below: 10 PRINT"THE 'TAB' FUNCTION IN ACTION!" 20 PRINT TAB(3)"THIS IS THREE SPACES TO THE RIGHT" 30 PRINT TAB(13)"THIS IS TEN SPACES TO THE"; 40 PRINT "[2 SPACEs]RIGHT" In the above exmaple, if a ';' flag were NOT used after line 30, the following would occur: |THE 'TAB' FUNCTION IN ACTION! | | THIS IS THREE SPACES TO THE RIGHT | | THIS IS 13 SPACES TO THE RI| |GHT | But since we did not forget to use it, here is what the program above would PRINT: |THE 'TAB' FUNCTION IN ACTION! | | THIS IS THREE SPACES TO THE RIGHT | | THIS IS 13 SPACES TO THE | |RIGHT | Notice that the word "RIGHT" wrapped around the screen to the next line. This illustrates yet another use for the ';' flag. Hopefully, the above explanation will clear things up a bit. Now, moving on to yet another advanced use of the PRINT statement: PRINTing control characters. PRINTing in 'Reverse Video' One of the first things you will learn is how to PRINT in what's called 'Reverse Video'. This control code will allow you to PRINT anything on the screen in a 'highlighted' fashion. For instance, the program below demonstrates this command: 10 PRINT"[RVSON]THIS IS REVERSE VIDEO[RVSOFF]" [RVSON] and [RVSOFF] are obtained by pressing the CONTROL key and the number keys '9' and '0' simultaneously, respectively. The screen will say: |THIS IS REVERSE VIDEO| The "|" both before and after this phrase represent the beginning and end of the reverse video used in this exmaple. Don't worry, when you try this out on your Commodore 64, it will look ALOT better than this example (trust me). ;) If you look on your keyboard, you'll notice that down below each key on the side of the "face" will be an obscure graphics symbol. This symbol represents a character in the Commodore 64's built-in character set. These are handy for making low-resolution pictures, symbols, designs, etc. But if you also look on the keys 1-9 and 0, you'll find PRINTed below the numbers (on the sides of the "face" are abbreviated words. As an example, look at the '1' key: ______ /| BLK|\ | | ! | | | | 1 | | |/------\| | ORG | ---------- The abbreviations are BLK (BLACK) and ORG "ORANGE". These abbreviations represent color codes. These color codes can be used within a program to change the color of text on the screen. The default colors are light blue (cursor & text color) on a dark blue background w/ a light blue border. In order to use these color codes within your PRINT statements, you must enter what is called QUOTE MODE by doing the following: 10 PRINT" Don't press RETURN yet. When you are done typing PRINT", enter these additional commands: [CONTROL 1]THIS IS BLACK." Enter [CONTROL 1] by pressing down the CONTROL KEY _first- and while holding it DOWN, press the '1' key at the same time. You will get a small 'box' symbol in front of the words THIS IS BLACK. What this symbol means is, it is a token (or abbreviated command) for the color code BLACK (BLK on the keyboard). You now have a general idea of how to enter color codes within your PRINT statements (don't worry about the other colors for now...all you do is HOLD DOWN the CONTROL key and simultaneously press the corresponding number of the color that you want, BLACK through YELLOW (colors 1-8. also keys 1-8). If you want to access the colors BELOW each key (colors 9-16, keys 1-8), HOLD DOWN the key that has the COMMODORE LOGO on it and simultaneously press the corresponding number of the color that you want,ORANGE through LIGHT GREY). Type NEW, and enter this PROGRAM: 10 PRINT"[SCN CLR]COLOR BAR" 15 PRINT"[CONTROL 1][RVSON][17 SPACEs]BLACK[18 SPACEs][RVSOFF]" 20 PRINT"[CONTROL 2][RVSON][17 SPACEs]WHITE[18 SPACEs][RVSOFF]" 25 PRINT"[CONTROL 3][RVSON][18 SPACEs]RED[19 SPACEs][RVSOFF]" 30 PRINT"[CONTROL 4][RVSON][18 SPACEs]CYAN[18 SPACEs][RVSOFF]" 35 PRINT"[CONTROL 5][RVSON][17 SPACEs]PURPLE[17 SPACEs][RVSOFF]" 40 PRINT"[CONTROL 6][RVSON][17 SPACEs]GREEN[18 SPACEs][RVSOFF]" 45 PRINT"[CONTROL 7][RVSON][18 SPACEs]BLUE[18 SPACEs][RVSOFF]" 50 PRINT"[CONTROL 8][RVSON][17 SPACEs]YELLOW[17 SPACEs][RVSOFF]" For this program, we will only deal with the primary colors (1-8). Here is a breakdown of what the program does. LINE 10 - Clears the screen and PRINTs the message "COLOR BAR" (NOTE: to access the screen clear (SCN CLR) code within the quotation marks, HOLD DOWN the key SHIFT and simultaneously press the key marked 'CLR HOME'). LINE 15-50 - PRINTs the messages BLACK,WHITE,RED,CYAN,PURPLE,GREEN,BLUE, and YELLOW as 'bars' across the screen in 'Reverse Video'. Note that each bar is separated by a one line space. This is because I intentially left off the ';' flag at the end of each line from LINE 15 on. This about covers the PRINT statement, even though there are more advanced ways to use PRINT not discussed yet in this thread. We will now move on to the next topic of our thread, the POKE statement. POKEing to the screen Essentially, the POKE statement is responsible for executing a specific address in memory from BASIC. This differs from other statements of this genre (i.e. the SYS statement) in that it can be accessed without difficulty from within a BASIC program. The syntax for the POKE statement can be any one of the following: POKE 1,PEEK (1) OR 4 :REM '1' is a valid address, but will not be discussed as to its usefulness in this thread. POKE 646,2 :REM '646' is the address which changes the cursor color to any number desired, in this case, with '2' (WHITE) as the argument. POKE 53280,0: :REM '53280' and '53281' are the addresses which POKE 53281,0 change the color of the screen (BORDER and BACKGROUND, respectively) color to any number desired, in this case, with '0' (BLACK) as the argument. A valid POKE can be any number from 1-65535. For example, to change the screen color to BLACK and print the message "THIS IS YOUR COMMODORE 64 SPEAKING." in WHITE, enter the following program: 10 POKE 53280,0:POKE 53281,0 20 POKE 646,2:PRINT"THIS IS YOUR COMMODORE 64 SPEAKING." POKEing color changes to the screen is infinately more useful (and easier) than PRINTing it. Recall that in our 'COLOR BAR' program we had to type [CONTROL] and any number from 1-8 to get a desired color. Well, below is a modified version of the program using the POKE statement to change the color of each bar: 5 POKE 53280,0:POKE 53281,0 10 PRINT"[SCN CLR]COLOR BAR" 15 POKE 646,2:PRINT"[17 SPACEs]BLACK[18 SPACEs]" 20 POKE 646,2:PRINT"[RVSON][17 SPACEs]WHITE[18 SPACEs][RVSOFF]" 25 POKE 646,3:PRINT"[RVSON][18 SPACEs]RED[19 SPACEs][RVSOFF]" 30 POKE 646,4:PRINT"[RVSON][18 SPACEs]CYAN[18 SPACEs][RVSOFF]" 35 POKE 646,5:PRINT"[RVSON][17 SPACEs]PURPLE[17 SPACEs][RVSOFF]" 40 POKE 646,6:PRINT"[RVSON][17 SPACEs]GREEN[18 SPACEs][RVSOFF]" 45 POKE 646,7:PRINT"[RVSON][18 SPACEs]BLUE[18 SPACEs][RVSOFF]" 50 POKE 646,8:PRINT"[RVSON][17 SPACEs]YELLOW[17 SPACEs][RVSOFF]" Note a couple of key changes to this program: We've added a LINE 5 which is responsible for changing both the BACKGROUND and BORDER colors to BLACK. Instead of having cumbersome color codes within the quotation marks, we are now free to add the POKEs before the PRINT statements. Also, notice that in LINE 15 there is no 'Reverse On' or 'Reverse Off' control codes. This is because the screen color and the cursor color would be the same if we had used [RVS ON] and [RVS OFF]. Thusly, we could not have seen the BLACK bar. Therefore, it was printed in regular mode by using WHITE as the color. There are other, more advanced uses of the POKE statement, but we will not get into them...or at least not yet. Hopefully, the information contained in this particular thread is helpful in getting beginning programmers started with the wonderful language of BASIC programming! Look for a further addition to this material in future threads of this article. Regards, Paul Allen Panks ------------------------------------------------------------------------------ This signature file was brought to you by Paul Panks, not Micro$oft, IBM, or any of those other money-sapping, machine-wasting companies bent on world domination. Did you here that Micro$oft wants to purchase the Catholic Church? I don't think Bill Gates would make a very good choir boy. I think its time to put our foots down and stop this maniac before he declares his campaign for the Presidency! *** Check out Jim Brain's WWW Page at: Http://www.msen.com/~brain/ *** (You'll be glad you did!) "If you quote me on this, I'll have to deny it. Besides, my memory is *terrible*. I forget things often. Also, my memory is *horrible*." ------------------------------------------------------------------------------ From: Bruce McFarling Newsgroups: comp.sys.cbm Subject: Re: Programming question Date: Wed, 6 Dec 1995 13:13:02 -0500 In article <49tmpg$d5g@krel.iea.com>, Jon Abernathy wrote: > >Does anyone have any BASIC routines for speeding up disk access? Here's > >the scenario: what looks to be a 32 block (4K) SEQuential file of > >integers to be read in (and POKEd into memory). Looking at that I shudder > >to think of the time needed for the 1541 open and read the file, so I was > >wondering if anyone had any BASIC speed ups. On 5 Dec 1995, Stephen Judd wrote: > You should read the entire file into memory at once, instead of a byte at > a time, especially since, as far as I can tell, you are poking it directly > into memory anyways. > Ideally perhaps you should read the file in and then perform a SAVE of > the data directly from memory. > If this is not practical, you could just perform a relocatable load > of the file, at least in principle. Since it is a sequential file you > would have to read in the first two bytes separately. I _think_ the > following will work to read in everything except the first two bytes: Notice that what Stephen is doing is a relocatable LOAD -- he is doing it with POKES and SYS calls simply because BASIC will balk at LOADing a SEQ file. The first two bytes should therefore be read in normally: OPEN the file, READ the first two bytes, and CLOE the file. *Be sure to close the file before using Stephen's code*; he is doing the opening of the file for the block load with one of his SYS statements. > 1000 SYS 57812 "NAME,S",8,0:REM SET PARAMETERS FOR LOAD > 1010 POKE 193,L%:POKE 194,H% > 1020 POKE 147,0:SYS 62631 > > L% is the low byte of the load address, and H% is the high byte, e.g. > H%= INT(address/256): L%=address-256*H% > A normal PRG file contains the load address in the first track/sector in > its file chain, but a SEQ file does not, so the first two bytes of data > would be ignored, and data would start loading from the third byte. Thus > you would have to adjust the load address by two, and read in the first > two bytes manually. > If you want to perform a SAVE of memory, use > > 1000 SYS 57812 "NAME",8,1:REM SET PARAMETERS FOR LOAD > 1010 POKE 193,L%:POKE 194,H% > 1020 POKE 174,L2%:POKE 175,H2% > 1030 SYS 62957 > > L2% and H2% are the low and high byte of the ending address, minus one. > After you have saved things in this way, you can load it back in with > a simple LOAD "NAME",8,1. > > Another way to speed up disk access is to buy JiffyDOS, and maybe a RAMlink or > FD-2000 while you're at it ;). If you do the block load of file that Stepehen suggests, except for the first two bytes it would probably enjoy the benefit of any fastloader cartridge you might have. And, Jon, if you can't afford JiffyDos, and don't *have* a fastloader cart, for goodness sake get one! I've seen them offered in this newsgroup for under $10 in the last week or two! Virtually, Bruce McFarling, Knoxville brmcf@utkux.utk.edu -------------------------------------------------------------- : If it was my employer's opinion, they would have signed it : : Sure I knew that *you* knew that, but now everybody knows : From: doug.cottton@the-spa.com (Doug Cotton) Newsgroups: comp.sys.cbm Subject: Re: Programming question Date: Thu, 07 Dec 1995 22:37:47 -0500 Jon Abernathy wrote: > Does anyone have any BASIC routines for speeding up disk access? Here's > the scenario: what looks to be a 32 block (4K) SEQuential file of > integers to be read in (and POKEd into memory). Looking at that I shudder > to think of the time needed for the 1541 open and read the file, so I was > wondering if anyone had any BASIC speed ups. Here's a tip that appeared in Commodore World Issue #5 for faster GET statements when getting bytes from a disk file: - open the file you want to read from - poke the filenumber into location 781 - perform a SYS to 65478 (CHKIN) - use GET to read in the bytes from the file After you're done reading from the file: - perform a SYS to 65484 (CLRCH) - close the file Here's an example of reading the error channel using this method: 10 open15,8,15 20 poke781,15 30 sys65478 40 getb$ 50 printb$' 60 ifst<>64then40 70 sys65484 80 close15 To adapt the routine to a 128, delete line 20 and replace line 30 with: 30 sys65478,,15 Doug Cotton ===================================================================== | Creative Micro Designs, Inc. | Orders: (800) 6383-CMD | | P.O. Box 646 | Support: (413) 525-0023 | | East Longmeadow, MA 01028 | Fax: (413) 525-0147 | --------------------------------------------------------------------- | Visit our WWW Site at: http://www.msen.com/~brain/guest/cmd/ | ===================================================================== From: pap@dana.ucc.nau.edu (Paul Allen Panks) Newsgroups: comp.sys.cbm Subject: PROGRAMS TO TRY: BASIC 2/7 Date: 13 Dec 1995 03:39:22 GMT If any of you are programmers out there, feel free to suggest any new ways I can approach the following program on BASIC 7.0 for the C-128: 0 REM DISK UTILITY - BASIC 7.0 10 TRAP 1000:CLR:FORX=1TO8:KEYX,"":NEXT:SCNCLR:PRINTCHR$(14)"[RVSON]{SHFT D]ISK [SHFT M]ANAGER[RVSOFF]" 15 PRINT:PRINT"{SHFT S}ELECT OPTION OF YOUR CHOICE":PRINT 20 PRINT"[SHFT A]. [SHFT D]ISK [SHFT D]IRECTORY" 25 PRINT"[SHFT B]. [SHFT S]CRATCH A [SHFT F]ILE" 30 PRINT"[SHFT C]. [SHFT R]ENAME A [SHFT F]ILE" 35 PRINT"[SHFT D]. [SHFT C]OPY A [SHFT F]ILE" 40 PRINT"[SHFT E]. [SHFT S]HOW [SHFT B]LOCKS [SHFT F]REE" 42 PRINT"[SHFT F]. [SHFT Q]UIT [SHFT P]ROGRAM" 45 PRINT:PRINT"[A-E]:"; 50 GETKEY A$ 55 A=VAL(A$):ON A GOSUB 100,200,300,400,500,600 60 IF A<1 OR A>6 THEN GOTO 50 65 RUN 99 REM *** DISK DIRECTORY *** 100 PRINT A$:SLEEP 1 105 SCNCLR:PRINT"'[SHFT A]' ABORTS.":PRINT:PRINT"[RVSON][SHFT D]ISK [SHFT D]IRECTORY[RVSOFF]":PRINT 110 INPUT"SELECT DRIVE: 8 [LFT][LFT]";B$ 115 B=VAL(B$) 120 IFB$="8" THEN B=8:GOTO 135 125 IFB$="9" THEN B=9:GOTO 135 127 IFB$="A" THEN RETURN 130 GOTO 105 135 DIRECTORY "",U+B: REM WOULD THIS CAUSE A SYNTAX ERROR? 140 PRINT:PRINT"[RVSON][SHFT P]RESS ANY KEY TO RETURN[RVSOFF]" 145 GETKEY C$:RETURN 199 REM *** SCRATCH A FILE *** 200 PRINT A$:SLEEP 1 205 SCNCLR:PRINT"'[SHFT ESC]' ABORTS.":PRINT:PRINT"[RVSON][SHFT S]CRATCH A [SHFT F]ILE[RVSOFF]":PRINT 210 INPUT"[SHFT F]ILENAME TO [SHFT S]CRATCH:";F$ 215 IF F$="[ESC KEY]" THEN RETURN: REM "[ESC KEY]" REFERS TO THE 'ESC' KEY ON THE UPPER ROW OF THE KEYBOARD (GREY KEYS AT TOP) 220 PRINT:PRINT"[SHFT I]NSERT DISK WITH FILE TO ERASE" 225 PRINT"[SHFT P]RESS ANY KEY TO CONTINUE, '[SHFT ESC]' TO ABORT" 230 GETKEY D$ 235 IFD$="[ESC KEY]" THEN RETURN 240 SCRATCH F$+",M" 245 PRINT:PRINT"[RVSON][SHFT P]RESS ANY KEY TO RETURN[RVSOFF]" 250 GET KEY E$ 255 RETURN 299 REM *** RENAME A FILE *** 300 PRINT A$:SLEEP 1 305 SCNCLR:PRINT"'[SHFT ESC]' ABORTS.":PRINT:PRINT"[RVSON][SHFT R]ENAME A [SHFT F]ILE[RVSOFF]":PRINT 310 INPUT"[SHFT F]ILENAME TO [SHFT R]ENAME:";F$ 315 IF F$="[ESC KEY]" THEN RETURN 317 INPUT"[SHFT N]EW NAME FOR FILE:";NN$ 320 PRINT:PRINT"[SHFT I]NSERT DISK WITH FILE TO RENAME" 325 PRINT"[SHFT P]RESS ANY KEY TO CONTINUE, '[SHFT ESC]' TO ABORT" 330 GETKEY G$ 335 IF G$="[ESC KEY]" THEN RETURN 340 RENAME F$+"="+NN$+"" 345 PRINT:PRINT"[RVSON][SHFT P]RESS ANY KEY TO RETURN[RVSOFF]" 350 GETKEY H$ 355 RETURN 399 REM *** COPY A FILE *** 400 PRINT A$:SLEEP 1 405 SCNCLR:PRINT"'[SHFT ESC]' ABORTS.":PRINT:PRINT"[RVSON][SHFT S][RVSOFF]INGLE DISK OR [RVSON][SHFT M][RVSOFF]ULTIPLE DISKS (UNIT 8 TO 9)?" 410 GET KEY I$ 415 IF I$="[ESC KEY]" THEN RETURN 420 IF I$="S" THEN 435 425 IF I$="M" THEN 480 430 GOTO 410 435 PRINT:INPUT"[SHFT F]ILENAME TO COPY:";F$ 437 INPUT"[SHFT N]EW NAME FOR BACKUP FILE:";NN$ 440 PRINT:PRINT"[SHFT I]NSERT DISK WITH FILE TO COPY" 445 PRINT"[SHFT P]RESS ANY KEY TO CONTINUE,'[SHFT ESC]' TO ABORT" 450 GETKEY J$ 455 IF J$="[ESC KEY]" THEN RETURN 460 COPY F$+"TO"+NN$: REM DOES THIS WORK WITHOUT SYNTAX ERROR? 465 PRINT:PRINT"[RVSON][SHFT P]RESS ANY KEY TO RETURN[RVSOFF]" 470 GETKEY K$ 475 RETURN 480 PRINT:INPUT"[SHFT F]ILENAME TO COPY (U8 TO U9):";F$ 485 PRINT:PRINT"[SHFT P]RESS ANY KEY TO CONTINUE,'[SHFT ESC]' TO ABORT" 490 GETKEY L$ 495 IF L$="[ESC KEY]" THEN RETURN 496 BACKUP F$+"TO"+F$+"": REM DOES THIS WORK WITHOUT SYNTAX ERROR? 497 PRINT:PRINT"[RVSON][SHFT P]RESS ANY KEY TO RETURN[RVSOFF]" 498 GETKEY M$:RETURN 499 REM *** SHOW BLOCKS FREE *** 500 PRINT A$:SLEEP 1 505 SCNCLR:PRINT:PRINT"[RVSON][SHFT B]LOCKS [SHFT F]REE[RVSOFF]" 510 PRINT:PRINT"[SHFT I]NSERT DISK TO CHECK" 515 PRINT"[SHFT P]RESS ANY KEY TO CONTINUE,'[SHFT ESC]' TO ABORT" 520 GETKEY N$ 525 IF N$="[ESC KEY]" THEN RETURN 530 DIRECTORY "$": REM DOES THIS SHOW BLOCKS FREE ON DISK? 535 PRINT:PRINT"[RVSON][SHFT P]RESS ANY KEY TO RETURN[RVSOFF]" 540 GETKEY O$ 545 RETURN 599 REM *** QUIT DISK UTILITY *** 600 PRINT A$:SLEEP 1 605 SCNCLR:PRINT:PRINT"'[SHFT ESC]' ABORTS.":PRINT:PRINT"[SHFT A]RE YOU SURE? "; 610 GETKEY P$ 615 IF P$="[ESC KEY]" THEN RETURN 620 IF P$="Y" THEN PRINT P$:SLEEP 1:SCNCLR:PRINT"[SHFT H]AVE A NICE DAY!":COLOR 0,12: COLOR 4,13: END: REM SET TO DEFAULT COLORS (?) AND END 625 IF P$="N" THEN RETURN 630 GOTO 610 635 END 1000 PRINT:PRINTCHR$(142),"! AN ERROR HAS OCCURED IN THIS APPLICATION !" 1005 PRINT,"*** PRESS ANY KEY TO RETRY ***" 1010 GETKEY Q$ 1015 OPEN 15,8,15,"I":CLOSE 15:CLR 1020 RUN 20000 REM SAVE"@0:DISK UTILITY",8 NOTE: This program has not been tested. Please feel free to test it out as necessary. E-mail any corrections to the author of the program, Me, at the following address: pap@dana.ucc.nau.edu Regards, Paul Allen Panks -- ------------------------------------------------------------------------------ This signature file was brought to you by Paul Panks, not Micro$oft, IBM, or any of those other money-sapping, machine-wasting companies bent on world domination. Did you here that Micro$oft wants to purchase the Catholic Church? I don't think Bill Gates would make a very good choir boy. I think its time to put our foots down and stop this maniac before he declares his campaign for the Presidency! *** Check out Jim Brain's WWW Page at: Http://www.msen.com/~brain/ *** (You'll be glad you did!) "If you quote me on this, I'll have to deny it. Besides, my memory is *terrible*. I forget things often. Also, my memory is *horrible*." ------------------------------------------------------------------------------ From: pap@dana.ucc.nau.edu (Paul Allen Panks) Newsgroups: comp.sys.cbm Subject: choppy animation (pleae read) Date: 16 Dec 1995 09:12:26 GMT Okay, folks. Below is an example of how NOT to link several sprites together and animate them. For some reason, the animation is very choppy and is not very fluid. Any suggestions and how to make it FAST and SUPER fluid? The eventual goal is to incorporate this animation into a game I am writing with joystivk sontrolling the person moving around. Also, when the person moves, the screen scrolls along with him. Sort of a world larger than the screen kind of adventure game. well, here is the animation fundamentals I have compiled into a program so far: (Basic 7.0) 0 rem animation shell (needs work) 1 data 0,56,0,0,70,0,0,129,0,1,5,0,1,9,0,0 2 data 130,0,14,124,224,17,147,16,32,186,8,60,198,112,19,41 3 data 144,18,16,144,18,16,144,19,17,144,18,254,144,12,68,96 4 data 7,255,192,2,16,128,5,41,64,4,214,64,6,40,192,0 5 data 11,171,160,8,68,32,8,68,32,12,68,96,11,69,160,16 6 data 130,16,16,130,16,24,130,48,20,130,80,19,131,144,16,254 7 data 16,48,254,28,127,255,254,255,255,255,255,255,255,255,255,255 8 data 127,255,254,63,255,252,3,255,192,0,0,0,0,0,0,0 9 data 0,28,0,0,98,0,0,129,0,0,130,128,0,132,128,0,132,128,0 10 data 65,112,0,63,136,7,73,4,8,221,60,16,99,200,14,148 11 data 200,9,136,72,9,8,72,9,136,200,9,127,112,6,34,32 12 data 3,255,224,1,8,64,2,148,160,2,107,32,2,20,96,0 13 data 0,56,0,0,70,0,0,129,0,1,65,0,1,33,0,14 14 data 130,0,17,252,0,32,146,224,60,187,16,19,198,8,19,41 15 data 112,18,17,144,18,16,144,19,17,144,14,254,144,4,68,96 16 data 7,255,192,2,16,128,5,41,64,4,214,64,6,40,64,0 17 data 12,107,160,11,164,32,8,68,96,8,69,160,12,66,16,11 18 data 66,16,16,130,48,16,130,80,24,131,144,20,254,16,19,254 19 data 28,48,255,254,112,255,255,255,255,255,255,255,255,127,255,254 20 data 63,255,252,3,255,192,0,0,0,0,0,0,0,0,0,0 21 data 5,214,48,4,37,208,6,34,16,5,162,16,8,66,48,8 22 data 66,208,12,65,8,10,65,8,9,193,24,8,127,40,56,127 23 data 200,127,255,12,255,255,14,255,255,255,255,255,255,127,255,254 24 data 63,255,252,3,255,192,0,0,0,0,0,0,0,0,0,0 50 j=1 100 forx=3584to3967:reada:pokex,a:next:forx=1to2:spritex,1,1,.,1,1,.:next 104 movspr1,150,150+j;movspr2,150,192+j:j'j=j-11 108 fory=1to450:next:forx=1to2:spritex,0:next 109 sprite3,1,1,.,1,1,.;sprite5,1,1,.,1,1,. 110 movspr3,148,150+j:movspr5,150,192+j:j=j-11 111 fory=1to450:next:sprite3,0:sprite5,0 112 sprite 4,1,1,.,1,1,.:sprite 6,1,1,.,1,1,. 113 movspr4,152,150+j:movspr6,150,192+j:j=j-11 114 fory=1to450:next:sprite4,0:sprite6,0 115 sprite1,1,1,.,1,1,.:sprite2,1,1,.,1,1,. 116 goto 104 I used the delay loops in 108,111,114 because the change rate of each sprite is way too fast and choppy to even see hardly. For some reason, this is the best compromise I could have made based on my current programming knowledge. I know there is a better way to link together and animate several sprites in conjunction with one another (and smoothly at that), but anybody out there want to give me a few lines of code revision to make it smoother (or maybe add joystick control and suggestions on adding more sprite shapes (for turning right,left, and going down...plus a way to scroll a screen in all directions in BASIC 7.0, like when the actual game screen is larger than the screen itself. Whew! Any suggestions, programmers? BASIC 7.0 Please E-mail responses only. Thanks Regards, Paul Allen Panks (NOTE: The sprite used in this program is being viewed from the BACK side, as if his back were facing you). The only other problem I have is adding color to this sprite without taking away from the program. -- ------------------------------------------------------------------------------ This signature file was brought to you by Paul Panks, not Micro$oft, IBM, or any of those other money-sapping, machine-wasting companies bent on world domination. Did you here that Micro$oft wants to purchase the Catholic Church? I don't think Bill Gates would make a very good choir boy. I think its time to put our foots down and stop this maniac before he declares his campaign for the Presidency! *** Check out Jim Brain's WWW Page at: Http://www.msen.com/~brain/ *** (You'll be glad you did!) "If you quote me on this, I'll have to deny it. Besides, my memory is *terrible*. I forget things often. Also, my memory is *horrible*." ------------------------------------------------------------------------------