ColaCalc (Version 1.0) by Dan Wilga Copyright ½ 1991, Gribnif Software. All Rights Reserved. This program may be distributed without charge, provided that this text file is present and that it and the program files are unmodified. Overview -------- What? ANOTHER calculator? Yup, another calculator. But this one's different, I promise! There are a number of really good calculator programs out there for the ST. Most of them just don't fit my needs for several reasons. The simple ones don't have what I need, and the ones that do have all of the programming functions I want are too huge, difficult to use, and take too much memory. And even though most of them are desk accessories, you still can't access a desk accessory within a non-GEM program. So I've always had to keep my old Casio calculator sitting on top of the computer. Enter ColaCalc. This tiny little program (about 8k) is a full-featured programmer's calculator. No pretty dialog box, no floating point, no linear regression, but a calculator that's always there when you need it. And, best of all, you can change the keys to whatever you want, you aren't stuck with what I think are good keyboard equivalents! ColaCalc can be activated at a single keypress. The display occupies the very bottom of your screen, and as such hides very little data. The calculator functions include the standard operators, bit manipulation, word size and base (binary, octal, decimal, or hex.) There is also a special mode that lets you see the scan code generated by any key on the keyboard. It is also designed to work with any display, and works with the Mega STe and TT computers. Installation: ------------ Run COLACALC.PRG from the desktop, or place it in your AUTO folder. If you use a COLACALC.DAT file, then it should be in the same folder as the program. If you are holding down the Alternate key while ColaCalc is loading, then it will not install itself. This is a good way to keep it from installing when it is in your AUTO folder, without having to re-boot. Activating It: ------------- Unless you have changed the activation keypress (see Configuration), you can always call ColaCalc from within any program simply by pressing Control-Undo. The only time ColaCalc may not appear is when a disk access is occuring. To quit ColaCalc, press either Esc or Undo. The Display: ----------- Here is a diagram of what the parts of the display mean: ulb 10100010101010001010100010101001 XOR 1.......9. ||| \ / | \ \ / | \ --------- number ----------- | function key memories signed/unsigned | base operator word size All keyboard controls listed below are the defaults. Signed (S key); Unsigned (U key): These control whether or not a negative number is to be displayed with a minus sign in front of it (signed) or if the sign bit should be displayed as part of the number (unsigned). These can also affect translating between word sizes (see below). Word Size: Byte (Alt-B); Word (Alt-W); Long (Alt-L): By setting the word size you affect how much of the number is displayed. If, for example, the display is set for Byte, the largest value that can be displayed is FF (hex). When changing from a small word size to a larger one, the value is sign-extended if the display is set to show the sign, otherwise it is not. This means that if, for example, you are converting FF from a byte to a word without the sign, then this will become 00FF. If, on the other hand, the sign is being used, FF (which shows up as -1) will still be -1 after the extension. Base: Binary (Control-B); Octal (Control-O); Decimal (Control-D); Hexadecimal (Control-H): These control the base to display values in. In Binary mode, large numbers will have small circles after every eight bits to indicate the byte boundaries. Number: The keys 0-9 and A-F (or a-f) can be used to enter numbers. The keypad keys will also work under the default configuration. Function: This portion of the display shows what function was last entered. It may also contain "-E-" if an error occurred; if this happens, press Clr/Home. Function Key Memories: The F1-F10 keys can be assigned values by pressing Shift along with the appropriate F-key. A number can be recalled later by pressing just the function key, without Shift. If a particular function key has a non-zero value assigned to it, this will show up in the function key segment of the display. The display will not include the function key segment or the function name if you are using low resolution. Miscellaneous Keys: ------------------ =, Return, Enter Calculate result Undo, Esc Quit ColaCalc Clr/Home Clear display/Clear error Shift-Fkey Set memory Fkey Recall memory Backspace Undo last digit typed Help Enter/Exit Keypress mode The first time you press Clr/Home clears the display or any error condition, which shows up as "-E-". If you press it a second time, any operator still waiting to be processed is cleared. When in Keypress mode, the display shows the value for any shift keys pressed, the scan code of the last key pressed, its ASCII value in hex, and the actual character that key produces (if non-zero.) This is handy for writing your own configuration file (see below). To exit Keypress mode, press the Help key again. Operators: --------- Unary operators (NEG, NOT and the PEEKs) are processed immediately. Binary operators (like + and *) are processed in the order they are received, with the exception of * and /, which take highest precedence. This means that: 1 + 2 * 3 is processed as 1+(2*3) 1 * 2 + 3 is processed as (1*2)+3 1 + 2 * 3 / 2 is processed as 1+((2*3)/2) 1 & 2 * 3 is processed as 1&(2*3) If the second operand is not entered for a binary operator, then the first operand is reused. This means that: 2 * = is processed as 2*2 4 / = is processed as 4/4 A binary operator can be replaced with another by simply entering the new operator before typing anything else. Thus: 1 + * 4 is processed as 1*4 3 / - 2 is processed as 3-2 Key Operation Type (Unary or Binary) --- --------- --------------------- + Add B - Subtract B * Multiply B / Divide B % Modulo (result after division) B ! NOT (one's complement) U Delete NEG (two's complement) U & AND B | OR B ^ XOR (exclusive or) B left arrow ROL (rotate left) B Control-left LSL (shift left) B right arrow ROR (rotate right) B Control-right LSR/ASR (shift right) B Control-P PEEK LONG U Left Shift-P PEEK WORD U Alt-P PEEK BYTE U Both ROR and ROL always begin with a carry of zero. They act just like their equivalent 68xxx instructions. The value to be manipulated is entered first, followed by the operator, and then the number of bits to rotate. The Control-right arrow will use a logical shift if the display does not show the sign. In Signed mode, an arithmetic shift is performed. The three types of PEEK work by treating the value in the display as a pointer into the computer's memory. The value at that memory location is then moved into the display. For PEEK WORD and PEEK BYTE, the value is sign-extended if the Sign mode is set. Attempting to PEEK LONG or PEEK WORD at an odd address will generate an error. Configuration: ------------- When it first runs, ColaCalc looks for a file called COLACALC.DAT in the same folder where COLACALC.PRG is, which contains configuration information. This file can be modified with a text editor. Each line contains one keyboard equivalent or function key assignment. The first part of a line must always contain data to be read by ColaCalc; the remainder of the line is ignored and can be used for comments. Blank lines are ignored. The basic layout of the file is as follows: Default display state Key to activate 26 Operators and display controls 10 Function key defaults The first line must contain three characters for the default display, and they must all be lowercase. All other values must either be in hex or must be a single raw ASCII character. The various values can be separated by spaces or tabs. There are two ways that keypresses can be defined: either by ASCII value or by scan code. To define a keypress by ASCII, enter an asterisk in the first column and the ASCII character (either the character itself or its hex value) in the second column. To enter a keypress by its scan code, the first column contains the shift key status, from the table below, and the second contains the scan code: Key Pressed: Value: Right Shift 1 Left Shift 2 Control 4 Alternate 8 For example, to specify the "p" key, you would use "* p". To specify Control-Alternate-p, you would use "C 19" (8+4=C, and $19 is the scan code.) The Keypress mode in ColaCalc (activated with the Help key) is helpful for determining what values to use. About "Colaware": ---------------- You've heard of public domain, you've heard of shareware. This program, however, is Colaware: if you like it, you are encouraged (though not necessarily required) to send copious quantities of highly caffeinated beverages (Coke, Pepsi, Jolt, etc.) to the address below (via U.S. Mail, please; UPS won't deliver to a P.O. Box) so that I can continue to create more products like this one. Coupons are accepted. Gribnif Software P.O. Box 350 Hadley, MA 01035 Internet: Dan.Wilga@saturn.ucc.umass.edu GEnie: GRIBNIF