Portfolio BASIC, version 2.1 (c) 1990 BJ Gleason by BJ Gleason, The American University INTRODUCTION PBASIC is a simple BASIC interpreter. It only requires 30k of disk space and about 43k of memory to run. PBASIC is a batch oriented interpreter. It will also interact with the built-in editor for program development. PBASIC was one of the winners in the Compuserve/ Portfolio Conference Programming Contest, 1990. A NOTE FROM THE AUTHOR As of this release, PBASIC is only going to upgraded for bug fixes for a while. This interpreter started out as a "see if I can do it project." Because writing it and upgrading it is so much fun, it has kept me from doing some of my other work. Due in large part to the positive encouragement of the people who have used it, I have added floating point, arrays, virtual screen manipulation and printer support for this version. The next step will be strings and files, but they will require a bit of thought on implementation design. As it stands, the current design is a bit of a hack (read that as totally), and is getting a bit awkward to work with. Over the next few months, I will maintain and release new versions of 2.0 as the occasion merits. I will still be very receptive to your ideas, and look forward to talking to you. Some of the things I am working on include: strings, files, making the interpreter a .RUN file so more memory is available, and converting to code to C++. A number of considerate users have offered their help. If you have an interesting application that you have developed in PBASIC, I will be more than happy to distribute your code in future releases. Please make sure to place your name and other information as REMarks in the program. You can include a documentation file as well. The only thing that I ask is that you do not charge for the use of your program, as I am not charging for the use of this interpreter. Send me a note, and tell me where the code is and I will include it in the package. Thanks to all you have helped and are going to help! DESIGN CONSIDERATION When I was laying out the initial design of PBASIC, here are some of the topics I took into consideration: - Microsoft BASIC compatible. - Size of Interpreter (as small as possible). - Unique features of the Portfolio. - Using the Built-in editor for Program Editing. - Reasonable size BASIC programs pppOOπpppϗ0'@ g L LL88gD'@FB'g 88gHg@@B@'DD'8g@'DgDG'B@'' ''8gO  g''''FA88gDA'DBB'gO  'D88g[t%. mMytFw3Bv nv .vmo/v[ mei2%5COiz?%x]jC32_; 3@Syn} xUnbnced pparsNo؊xpEsцEqus V҆ec=dt aa viabl7ToCmy b_=Dup}inTHENW TO fFORpbEXT wiTGOSUBRETAURoCb0ame/4Lx tL{gB+kOof MemoryArraEw4SubYipRgD %c4 %%s^\+-*/%=;(),><0123456789. ;,^<>/*\:C:\SYSTEM\PERMDATA.rb!w-PBASI~C 2.1 90 BJml4s}UgskTuse: <0nm>F n3f[8Y] kuey.alFfau?%gD=G? X ,PV؀>ub$u. Ä&>׾*t4dĀtx "1^XY..&ϛDom,nDe Ofw@Part8l ;ciFV[hӖ:>` X hM h o tꪑ AB{D@FzG$tI?K L7yACp+ŝi@զIx@ߌGA~QCǑF uuvHM]=];Z R`%*u2R %h q, 3 8 A K Q DOMAINSAOV ERFLOWUNDTSS$%s x #0#dAA!@ j~ FI9| {ؑ kXC3 BvQ+r(8mHXhx۶  :p @MPA.$ d scanfP : ٩ 'sLۧked (n) 7ABCDEFw| a     I) e  s  [=;* ;Zx0NmPFTCESTD/?082S :==7S 0 n N S+P..ډ=v)))ÎڎñHH uŽ11JuŲs1JuŲr"JuŲJuŲAAرt AA&리t4<tA -؎r*FAB*X[1tNjǃŽ& u=uڋË>6-؎1֋./a!<X n  F[.0:_0 .F ;/04P:Db3h=1)-?9f= N mEND have the same effect. FOR varname = exp TO exp [STEP exp] You can not use an array element for varname. FORMFEED Send a formfeed to the printer. NOT GWBASIC. GOSUB line number GOTO line number IF exp THEN statement [ ELSE statement ] INPUT ["prompt" (,|;)] varname Read an integer from the keyboard. Only one variable is allowed per input. If a comma (,) separates the prompt string and the varname, no question mark (?) will be printed. If a semi- colon (;) is used, the question mark will appear. LOCATE row,col Move the cursor to row, col. LPRINT list of expressions Send output to printer. See PRINT. NEXT [varname] You can not use an array element for varname. ON exp GOTO list of line numbers ON exp GOSUB list of line numbers OUT port, exp Send value to the indicated port. POKE addr, exp Places value at SEG:addr. SEG is set via the DEF SEG statement. NOTE: Due to the design of the Portfolio, if you poke screen memory (DEF SEG=&HB000), the value may not appear. After you poke, you should use the REFRESH statement to update the screen. PRINT list of expressions List of Expressions can consist of strings, variables, constants or expressions, separated by the comma (,) or semi-colon (;) or a space ( ). PRINTER This is a toggle to start copying all PRINT statements to the printer. Issue it again and it will toggle off. Can be used instead of converting all PRINTs to LPRINTs. Information will still be displayed on the screen. This will not wrap the output lines like the screen will. NOT GWBASIC. PRTSC This invoke the PRINT SCREEN function to copy the screen out to the printer. If you are using a laser printer, you might want to use a FORMFEED after this to do a page eject. NOT GWBASIC. PSET (row, col) [, exp] Set the pixel at row, col to exp. The Portfolio, regardless of the screen mode, has a maximum 64x240 for row, col. Exp can evaluate to 0 or 1. RANDOMIZE Initialize the random number generator. READ list of variables Read the values of the variables from the DATA statements. Variables can be simple or array. REM Remark. The rest of the line is ignored. You can also use the quote (') mark as a REM statement. RESTORE [line number] Sets the internal data pointer to the specified line number. Line number specified must be a data statement. If no line number is given, the data pointer will point back to the first data location. RETURN SCREEN exp Set the screen mode. There is no testing for validity. Some of the values that work on the Portfolio are: 4 graphics 320x200 5 graphics 320x200 6 graphics 640x200 7 text 80x25 8 graphics 160x200 10 graphics 640x200 These are standard PC modes, but remember that the Portfolio Screen is only 240x64. If you use the screen function of the portfolio, it is highly recommend that you set the screen back to mode 7 before you exit. Many portfolio utilities only work in mode 7. At present, text will not be displayed properly on a graphics screen. STOP To allow for "breakpoints", STOP will terminate the program and display the line number. It will point the built-in editor to the last position executed if the editor file is the same as the file being executed. SWAP varname, varname SYSTEM END and SYSTEM have the same effect. TROFF Disable line tracing. TRON Enable line tracing. Will display the line number in brackets ([x]). Using this statement will slow down the program execution. Can be placed anywhere in program. WAIT Unlike the GWBASIC version, this only waits for a key press. It gives no prompt and returns no value. BASIC FUNCTIONS I have tried to keep the syntax and semantics for the functions as close to Microsoft BASIC as possible. The notes presented indicate exceptions. ABS(exp) Returns the absolute value of exp. ATN(exp) Returns the Arc Tangent of exp. COS(exp) Returns the Cosine of exp. CSRLIN Returns the current cursor line. EXP(exp) Returns e to the power of exp. FIX(exp) Returns the integer portion of exp. FRE(exp) Returns the free amount of memory. The parameter exp is a dummy expression. INP(port) Returns the byte value from port. INT(exp) Returns the integer portion of exp. LOG(exp) Returns the LOG of exp. LPOS(exp) Returns the current position of the line printer head. Exp is a dummy expression. PEEK(address) Returns the byte from memory location SEG:address. SEG is set via the DEF SEG instruction. POINT(row,col) Returns the value of the pixel at row,col. If this function does not appear to work, try running FIX0D, to fix the ROM pixel read function. POS(exp) Returns the current cursor column. Exp is a dummy expression. RAND(exp) This will return a number between 0 and exp-1. NOT GWBASIC. RND This will return an number between 0 and 1. SGN(exp) Returns the sign of exp. -1 exp < 0 0 exp = 0 1 exp > 0 SIN(exp) Returns the Sine of exp. SQR(exp) Returns the Square Root of exp. TAN(exp) Returns the Tangent of exp. TIMER Returns the number of seconds since midnight. PORTFOLIO ONLY STATEMENTS The statements in this section are specific to the Atari Portfolio and will not run on a regular PC. YOU CAN LOCK UP YOUR REGULAR PC IF YOU ATTEMPT TO USE THESE. ALARM This will beep the speaker, about once a second until the user presses a key. The program will then continue with the next statement. BEEP This will cause a single beep from the speaker. BOX row1, col1, row2, col2, type This will draw a box. Row1 and Col1 specify the upper left corner position of the box, while Row2 and Col2 specify the lower right corner. Type is 0 for single line box, and 1 for a double line box. Trying to draw a box larger than the screen (8x40) has unpredictable results. CLICK Make the key click sound. DIAL "number" This will dial the "number" through the speaker. Valid characters for tones are: 0 1 2 3 4 5 6 7 8 9 A B C D * #. The letters must be in uppercase. DISPLAY exp Set the Portfolio screen to Normal, Static or Tracked. 0=Static, 1=Normal, 2=Tracked. The mode is only effective while in PBASIC. Using this statement might clear the screen depending on the position of the cursor. ERRWIN row, col, "message" This will draw a box around the message and display it at the specified row, col. It will then beep and wait for a keypress. The text underneath the message is left untouched. Trying to place the message outside the screen (8x40) has unpredictable results. GETDISPLAY This function will return the current display mode. See DISPLAY for details. OFF This will turn the Portfolio off until the user presses a key. The program will continue execution with the next statement. PORT This function will return a 1 if running on a Portfolio, a 0 if not. Handy if you want to run program on both machines without locking up the PC. WARNING: There is no positive way to identify the Portfolio. This functions checks to see if the Interrupt 61h vector is pointing to 0000:0000. This is not normally used on the PC, but is on the Portfolio. If you are running a TSR that takes over this vector, PORT will return 1. REFRESH Copy video memory to the LCD controller. Needed for when you are doing direct write to screen memory. ROMVER This function will return the version number of the Portfolio rom's. SOUND code, duration This will activate the tone generator. Duration is the length of tone in 10 msec intervals. Tone codes are displayed below. These codes are taken from the Atari Portfolio Technical Reference Manual, copyrighted by the Atari Corporation. CODE NOTE Frequency (Hz) 48 D#5 622.3 49 E5 659.3 50 F5 698.5 51 F#5 740.0 52 G5 784.0 53 G#5 830.6 54 A5 880.0 55 A#5 932.3 56 B5 987.8 57 C6 1046.5 58 C#6 1108.7 41 D6 1174.7 59 D#6 1244.5 60 E6 1318.5 61 F6 1396.9 14 F#6 1480.0 62 G6 1568.0 44 G#6 1661.2 63 A6 1760.0 4 A#6 1864.7 5 B6 1975.5 37 C7 2093.0 47 C#7 2217.5 6 D7 2349.3 7 D#7 2489.0 Aside from these codes, other values will produce sounds as well. SAOψppρOψ Oω OOO@ρpp is the line that you see when you use the key on the Portfolio. 0 for off, 1 for on. TICK exp Sets tk.lKei G2Hd  H$dL<@D d D@d H' @ d@D<HxL A$ĔРТ&WGW&2FR7W'&VBf'GV7W'6"ƖRРРТd4DR&r6РТfRFRf'GV7W'6"F&r6F0Т6Fv&Pe is the same as the file being executed. SWAP varname, varname SYSTEM END and SYSTEM have the same effect. TROFF Disable line tracing. TRON Enable line tracing. Will display the line number in brackets ([x]). Using this statement will slow down the program execution. Can be placed anywhere in program. WAIT Unlike the GWBASIC version, this only waits for a key press. It gives no prompt and returns no value. BASIC FUNCTIONS I have tried to keep the syntax and semantics for the functions as close to Microsoft BASIC as possible. The notes presented indicate exceptions. ABS(exp) Returns the absolute value of exp. ATN(exp) Returns the Arc Tangent of exp. COS(exp) Returns the Cosine of exp. CSRLIN Returns the current cursor line. EXP(exp) Returns e to the power of exp. FIX(exp) Returns the integer portion of exp. FRE(exp) Returns the free amount of memory. The parameter exp is a dummy expression. INP(port) Returns the byte value from port. INT(exp) Returns the integer portion of exp. LOG(exp) Returns the LOG of exp. LPOS(exp) Returns the current position of the line printer head. Exp is a dummy expression. PEEK(address) Returns the byte from memory location SEG:address. SEG is set via the DEF SEG instruction. POINT(row,col) Returns the value of the pixel at row,col. If this function does not appear to work, try running FIX0D, to fix the ROM pixel read function. POS(exp) Returns the current cursor column. Exp is a dummy expression. RAND(exp) This will return a number between 0 and exp-1. NOT GWBASIC. RND This will return an number between 0 and 1. SGN(exp) Returns the sign of exp. -1 exp < 0 0 exp = 0 1 exp > 0 SIN(exp) Returns the Sine of exp. SQR(exp) Returns the Square Root of exp. TAN(exp) Returns the Tangent of exp. TIMER Returns the number of seconds since midnight. PORTFOLIO ONLY STATEMENTS The statements in this section are specific to the Atari Portfolio and will not run on a regular PC. YOU CAN LOCK UP YOUR REGULAR PC IF YOU ATTEMPT TO USE THESE. ALARM This will beep the speaker, about once a second until the user presses a key. The program will then continue with the next statement. BEEP This will cause a single beep from the speaker. BOX row1, col1, row2, col2, type This will draw a box. Row1 and Col1 specify the upper left corner position of the box, while Row2 and Col2 specify the lower right corner. Type is use any Portfolio specific statements. If you have the Portfolio Emulation software (I60, I61), you can use all the features. PBASIC was developed on a Packard Bell 286 PC with 640k of memory. It was tested on the Atari Portfolio, ROM version 1.052. BATCH CONSIDERATIONS If you are running PBASIC as a batch file, you can access the ERRORLEVEL code generated upon exit. 0 - Successful exit 1 - Program aborted 2 - STOP encountered FUTURE ENHANCEMENTS - Menus - CHAINing programs - PBASIC compiler - Increase compatibility with Microsoft BASIC THE FILES PBASIC.EXE The Interpreter. PBASIC.TXT This file. ALTR.COM TSR to execute PBASIC from editor. TEST.BAS A program to exercise the interpreter. Should not generate any errors. It will run on a PC or Portfolio. Take a look at it, it demos many of the features of the Portfolio Only routines. DAYS.BAS Sample programs. FIX0D.COM TSR fix for Portfolio graphics rom. FIX0D.TXT ABOUT THE AUTHOR Mr. BJ Gleason is an Instructor at The American University in the Computer Science and Information Systems Department. He has been programming for over a decade now. COMMENTS, BUGS AND IDEAS What features do you really need in PBASIC to make it more useful on the Portfolio? If you would like to see some new features, contact me and I will try to accommodate you and release a new version. Thanks to all those on GEnie and Compuserve for their bug reports, suggestions and words of encouragement. Without their feedback, version 2.1 would have never seen the light of day. Keep those cards and letters coming! ADDRESS If you have an comments, suggestions or bug reports, you can write to the author at: BJ Gleason The American University CSIS (Thin Air Labs) 4400 Massachusetts Avenue, N.W. Washington, DC 20016 Compuserve : 73337,2011 Genie : BJGLEASON This program and documentation is being placed into the public domain by the author. It can be copied and distributed freely. It can not be sold or used for commercial purposes without permission. PBASIC version 2.1, Copyright 1990 by BJ Gleason. Portfolio, Atari, Microsoft, GWBASIC are trademarks of their respective companies.