Difference between revisions of "83Plus:Basic:Tricks"

From WikiTI
Jump to: navigation, search
(various copy editing; could probably use a style overhaul)
(added a few more routines... will come back later to separate it into different pages)
Line 244: Line 244:
 
  set useFastCirc, (iy+plotFlag3) FD CB 3C E6
 
  set useFastCirc, (iy+plotFlag3) FD CB 3C E6
 
  -Michael Cimino
 
  -Michael Cimino
 +
;Toggle the Screen On and Off:DB10CB6F20053E03D310C93E02D310
 +
<nowiki> in a,(10h)    ; DB10
 +
bit 5,a        ; CB6F
 +
jr nz,turnoff  ; 2005
 +
ld a,3        ; 3E03
 +
out (10h),a    ; D310
 +
ret            ; C9
 +
turnoff:
 +
ld a,2        ; 3E02
 +
out (10h),a    ; D310
 +
-FloppusMaximus</nowiki>
 +
;Clear Graph (no LCD update):EFD04B
 +
:To update the LCD, add EF6A48 at the end (before adding C9 if in a prgm)
 +
<nowiki>B_CALL _GrBufClr ; EFD04B</nowiki>
 +
;Invert HomeScreen:FDCB05DEEF7945FDCB059E
 +
<nowiki>set textInverse,(iy+textFlags)  ; FDCB05DE
 +
B_CALL _RstrShadow              ; EF7945
 +
res textInverse,(iy+textFlags)  ; FDCB059E
 +
-FloppusMaximus</nowiki>
 +
;Invert Screen (Any):F33E20CD0B00D3103E80CD0B00D310060EC5063F2E7FCD0B00DB112C
 +
:CD0B00DB112FF57DCD0B00D311CD0B00DB11F1CD0B00D31110E5C110D8
 +
:Note: This should be one LONG sequence. The line-break is inserted for readability only.
 +
<nowiki>    DI                              ;F3
 +
    LD A, $20                        ;3E20
 +
    CALL $B                          ;CD0B00
 +
    OUT ($10), A                    ;D310
 +
    LD A, $80                        ;3E80
 +
    CALL $B                          ;CD0B00
 +
    OUT ($10), A                    ;D310
 +
    LD B, 14                        ;060E
 +
loop:
 +
    PUSH BC                          ;C5
 +
    LD B, 63                        ;063F
 +
    LD L, $7F                        ;2E7F
 +
    CALL $B                          ;CD0B00
 +
    IN A, ($11)    ;dummy read      DB11
 +
loop1:
 +
    INC L          ;row counter      2C
 +
    CALL $B                          ;CD0B00
 +
    IN A, ($11)                      ;DB11
 +
    CPL                              ;2F
 +
    PUSH AF                          ;F5
 +
    LD A, L        ;reset the row    7D
 +
    CALL $B                          ;CD0B00
 +
    OUT ($11), A                    ;D311
 +
    CALL $B                          ;CD0B00
 +
    IN A, ($11)    ;dummy read...    DB11
 +
    POP AF                          ;F1
 +
    CALL $B                          ;CD0B00
 +
    OUT ($11), A                    ;D311
 +
    DJNZ loop1                      ;10E5
 +
    POP BC                          ;C1
 +
    DJNZ loop                        ;10D8
 +
-Taricorp</nowiki>
  
 
===Other===<!-- →≠≤≥ -->
 
===Other===<!-- →≠≤≥ -->
Line 336: Line 390:
 
BCALL _SetXXOP1  ; EF8C47
 
BCALL _SetXXOP1  ; EF8C47
 
BCALL _StoAns    ; EFBF4A
 
BCALL _StoAns    ; EFBF4A
 +
-FloppusMaximus</nowiki>
 +
;Automatic Power Down (APD):210101224884FDCB08DEFB76
 +
<nowiki>ld hl,0101h                  ; 210101
 +
ld (apdSubTimer),hl          ; 224884
 +
set apdRunning,(iy+apdFlags) ; FDCB08DE
 +
ei                          ; FB
 +
halt                        ; 76
 +
-FloppusMaximus</nowiki>
 +
;Turn Off the Calc:3E01D30376FDCB09A6
 +
<nowiki>ld a,1                        ; 3E01
 +
out (3),a                    ; D303
 +
halt                          ; 76
 +
res onInterrupt,(iy+onFlags)  ; FDCB09A6
 +
-FloppusMaximus</nowiki>
 +
;Toggling Lowercase:21148A3E08AE77
 +
<nowiki>ld hl,flags+appLwrCaseFlag ; 21148A
 +
ld a,8                    ; 3E08
 +
xor (hl)                  ; AE
 +
ld (hl),a                  ; 77
 +
-FloppusMaximus</nowiki>
 +
;Remove "Done":
 +
<nowiki>res donePrgm,(iy+doneFlags) ; FDCB00AE
 +
-FloppusMaximus</nowiki>
 +
;GetKey:EF7045FB76EF4447B728F8EF5641EFD14A
 +
<nowiki> B_CALL _RunIndicOff ; EF7045
 +
again:
 +
ei                  ; FB
 +
halt                ; 76
 +
B_CALL _GetK        ; EF4447
 +
or a                ; B7
 +
jr z,again          ; 28F8
 +
B_CALL _OP2ToOP1    ; EF5641
 +
B_CALL _StoX        ; EFD14A
 
-FloppusMaximus</nowiki>
 
-FloppusMaximus</nowiki>
  

Revision as of 10:21, 17 April 2006


Please format this article according to the guidelines and Wikification suggestions, then remove this {{Wikify}} notice from the article.


There is a whole list of tricks that one can implement, once one is comfortable programming in TI-Basic which allow for a whole onslaught of capabilities, such as using less memory or making the program run faster. There used to be a site called Kevtiva Inc. which had the largest list of TI-BASIC hacks I (Saibot84) have ever seen, including how to force a RAM reset (without the use of asm programs) but I've forgotten most of the meanest hacks. Here are some of the many tricks: (Please use common sense in deciding whether a "-" is a minus or a negative sign. When the use is un-common-sense-ical or possibly confusing, it will be specified.)

Memory

Memory Management

Number values
In order to be able to save memory on the calculator, it helps to have a bit of an understanding as to how the calc manages the memory, especially in regards to numbers. Because TIOS is designed for school, and so is oriented for precision, it saves all real number values as 14-digits and an exponent of 10. In other words, it saves the number π as 3.1415926535898 × 100, but in memory, it is something more similar (not exact) to 0 31415926535898 where the 0 tells TIOS what the exponent of 10 is that need to be applied to the 31415926535898. However, this also applies to smaller values, such that a 13 is saved as 1 13000000000000. For small, rational, terminating values, it can be seen that a good deal of memory is being wasted. I've created the following formula which, when saved to Y0 (or any other Y function, works with numbers in the same way that the sub( function works with strings:
int(fPart(X/10^(int(2-A+log(X))))*10^(F))
translated as a sub( statement, it would be the equivalent of sub(X,A,F) regardless of the position of the decimal point in X. If you don't understand what the formula is doing, it's dividing X by 10value so that the digit we're looking for (identified in A) is "moved" to be the first digit to the right of the decimal point, then ignores anything to the left or the decimal piont, then multiplies the value left over by 10F and ignores anything to the right of the decimal point, thus providing the sub(X,A,F).
use more than 27 vars
If you need to use more than the 27 vars TIOS gives you with A-Z, other than using lists, matrices, strings, or Ans, you can go look in the [VARS] menu under Window. Of these, being that the calculator is usually in function mode, you can use any of the window vars under T/theta (which are for parametric mode) and/or under U/V/W (which are for polar). It is recommended that you prefer those under U/V/W because this mode is usually never used, whereas parametric has been used on more than one occasion by programs, such as for drawing X in terms of Y. You can also go into the Finance menu under [APPS] and go to Vars, but IIRC, some are read-only vars, so you will need to experiment to see if a var is accessible or not, but it is certain, that at least the N can be used problemlessly in your programs. You can also use the n, which is found by going to the catalog and pressing "N" as a variable, as well as the sequential functions u,v, and w.
Debugging
One of the easiest ways to help you debug your program is through the use of the Pause command. You can use the Pause command to display the value of a var, or just to track the progress of your program. During any of the Pause commands, you can press [ON] to break the program and choose Goto so that the calc will automatically bring you to the point in your program where it was Pause-ing when you interrupted it with the [ON] key. Some common bugs include using the Y var or the X var while drawing to the screen (TIOS tends to change the value of Y and/or X when doing certain things on the graph screen, so avoid using Y or X when working on the graph screen.

Memory Saving

Never write out closing ) parentheses at the end of a line
You save 1 byte. The reason for this is that TIOS closes all still-open parentheses when it encounters $3F, which is the new-line character that is input when you press enter in the Program Editor, or when it encounters the store arrow.
Never write out closing " quotes at the end of a line
You save 1 byte. The reason for this is that TIOS closes any still-open quotes when it encounters $3F, which is the new-line character that is input when you press enter in the Program Editor, or when it encounters the store arrow.
Never use a Pause right after a Disp, unless the Pause has text
This is because both Disp and Pause can display text to the homescreen. Disp writes the text to the screen and then continues forward, but Pause waits for the [ENTER] key to be pressed. When Pause is used with text, such as in
:Pause "TEXT"
then it writes the text to the homescreen first, and then waits for the user to press [ENTER].
CAPITALIZE
For the most part, yes, it is nice to see that not EVERY character is in UPPERCASE on the calculator, but if you're looking to save space, don't use lower case letters. Each lowercase letter takes up twice as much space as the uppercase ones.
Read-Only Lists and Matrices
If you have a list or matrix that will be read-only, it behooves you to save it to a string or Y function (Y1-Y0). Instead of doing
:{1,2,3,4,5,6,7,8,9→L1
:L1(5 (to retrieve the 5th element of the list)
try doing
:"{1,2,3,4,5,6,7,8,9→Str1
:expr(Str1
:Ans(5
or
:"{1,2,3,4,5,6,7,8,9→Y1
:Y1:Ans(5
The benefit is that you are now no longer wasting the space, as explained in the Number Values. When choosing between storing your list to a string and storing it to a function, keep in mind that string values are somewhat editable, while functions are completely read-only. If you needed to edit something in the function, you'd have to convert it to a string first before editing, and then overwrite the original function. It is therefore recommended that you save your lists to strings.
No NewLine Required
The following commands do not require that you neither begin a new line, nor use a colon before the next command: Archive, Unarchive, DelVar. Example:
Archive XArchive YArchive ZUnarchive ZUnarchive TDelVar ADelVar BFor(X,0,1
this doesn't work with Lists, or labels, and presumably neither with the prgm token.

Speed Boosters

Use For( loops
In light of research I once read online, as well as through personal research and experimentation, it is fairly simple to see that For( loops are the fastest of the looping options. To prove this, try running the following program on your calc, and see which one is the fastest:
Program:LOOPTEST
:Disp "FOR
:For(X,1,10000
:End
:Pause "FOR IS DONE
:1→X
:Disp "WHILE
:While X<10001
:X+1→X
:End
:Pause "WHILE IS DONE
:0→X
:Disp "GOTO
:Lbl XX
:X+1→X
:If X<10001
:Goto XX
Pause "GOTO DONE
You will notice, especially if using a stopwatch, that the For( loop, IIRC, should even run a FEW SECONDS faster than the While loop, and/or the Goto loop. Therefore, see if you can't change your loops to use For( instead. In the case of the While, change
:While X<Y
to
:X-1→X
:For(X,X,Y
:X-1→X
You most likely will be losing a few more bytes in memory, but it's very much worth it for the speed... and you've already saved much speed by doing the tricks above ;-)
Get Returns on your IfThens, Fors, etc.
Each time you do an If-Then statement or a For( statement (among others), when the calc is "waiting" for an End statement, these conditions are taking up memory, which, after a while, slow down your BASIC programs. However, the benefit is that this is only the case, as long as your program is running... as soon as the calculator returns to the homescreen, these used memory is cleared again and you are ready to go at it again. The benefit of this is that when the calculator encounters a Return statement in a BASIC program, it "cancels" any conditions for its waiting for an End.
Avoid storing to vars in a loop
Brandon Green writes in his BASIC Guru Online that his experiments have led to the conclusion that storing variables is a prime cause of slowdowns in TI-BASIC programs. Therefore, try to restructure your code so as to avoid using the → as much as possible.

Graphical Touches

Use Text(-1,X,Y,value or text
I learned this from Kevtiva Inc. Normally, you do something like this:
:Text(15,10,"MY TEXT
following this, the text "MY TEXT" will be written on the 15th row, in the 10th column, in the small font... however, try adding a "-1" (without the quotation marks) as the first argument...
:Text(-1,15,10,"MY TEXT
This time, the text "MY TEXT" will be written on the 15th row in the 10th column, in the LARGE font
Write blank spaces to the graph screen when needing to erase stuff
as long as what you are trying to erase is at least 6 pixels high, it is srongly recommeded that you use the Text( command to write blank spaces to the screen instead of creating a Line(A,B,C,D,0 loop. This is because to write a line, white or black, the calculator needs to do a lot of math to convert the X and Y coordinates into pixel coordinates, while writing text to the screen is almost at the same speed as it would take to draw a sprite to the screen in any asm program (since for the calc, text chars are just sprites) and so writing (blank) text to clear the screen is much faster.
Try drawing graphics to the screen using text instead of lines
With access to the lowercase letters, as well as the Catalog menu, it is possible to draw graphics to the screen using text. For example, to draw a heart for a Zelda game would be much faster if you do something like the following:
:"vQ6Qv  "
:For(X,1,7
:Text(10,9+X,sub(Ans,X,1
:End
Another typical example is that of "drawing" a status bar to the screen using something such as:
(P is the percent to be shaded in)
(L is the length of the bar in pixels)
(H is the horizontal position)
(V is the vertical position, using the top-left corner of the screen as point 0,0)
:Text(V,H,"(
:For(X,0,PL/100
:Text(V,H+X+1,"8
:End
:For(X,1,(100-P)L/100
:Text(V,H+PL/100+X,")
:End
Using this technique, small graphics such as these can be drawn much faster than if we tried to draw them using lines and/or pixels and/or points.
Simplify your Life
Save a GDB at the beginning of your program. "Graph Databases (GDBs) are useful storage centers of graph informaiton. This means that it saves not only the Zoom settings, but also Axes on/off, coord on/off, and the Y= equations. Using these can reduce the size of your program." (quoted from http://web.archive.org/web/20021020121625/www.kevtiva.com/calc/gdb.htm) Turn off the axes with AxesOff, turn off functions with FuncOff, and set the Window to Xmin=0, Xmax=94, Xscl=8, Ymin=-62, Ymax=0, Yscl=8. When your program is exiting, have it reset the previous GDB so that you don't mess up the gamer's graph settings. While debugging your graphics, moving your cursor on the graph screen will now tell you both the pixel coordinates, as well as the point coordinates since you have synchronized them. http://www.meebo.com//skin/default/img/emoticons/big_smile.gif
Get rid of the "Done"
use the following right before your program exits to avoid having the calc display the "Done" text on the homescreen
:ClrHome
:Output(1,1,"
Get rid of the RunIndic
On the homescreen, do Output(1,16,"_ in the loop that is displaying the run indicator. On the graph screen, do Text(-1,0,90,"_ in the loop that is displaying the run indicator. (_ in this context refers to the space character.)

Cool Hacks

Have " and the store arrow in a string
(IIRC, brought to you by Kevtiva Inc.) Type a " and the store arrow at the homescreen and press enter. An error message will appear; choose to Quit. Press [Y=] and go to Y1. Press [2nd] [ENTER] to paste the previous homescreen entry into Y1. Press [2nd] [MODE] to {ESC}. At the homescreen, type Equ>Str(Y1,Str1 (or whatever Str you want to store it to and press [ENTER]. You now have the " quote and the store arrow in your string. http://www.meebo.com//skin/default/img/emoticons/wink.gif
If condition:End
This will need a bigger explanation, but in short, you can have a conditional End statement that helps your loops run faster by only executing the End statement if needed. The reason this works is because you didn't use a Then statement: an If followed by a single non-Then statement is interpreted as an If with no Else clause and the single statement as the equivalent of the Then clause, even if the statement is End. You can therefore also insert comments into your code (which is not recommended for BASIC unless you're still debugging it) by doing If 0:Whatever. For instance:
(untested...)(lines are numbered)
01:For(X,0,1
02:getKey→K
03:K→X
04:If not(Ans
05:End
06:0→X
07:"-
08:If K=25
09:"LEFT
10:If K=26
11:"UP
12:If K=27
13:"RIGHT
14:If K=34
15:"DOWN
16:If K=45
17:"CLEAR
18:If Ans="-
19:End
20:Disp Ans
21:If K=45
22:1→X
23:End
Explanation: Lines 1-2 are normal. Line 3 resets X if there was no key, which will loop back to the For( statement, or allow the routine to continue if there WAS a key. The answer from the getKey is in Ans, so if no key was pressed, Line 5 will be executed, which loops back to Line 1 without wasting any more time. http://www.meebo.com//skin/default/img/emoticons/smile.gif ... If a key was pressed, X is reset, which will cause the routine to loop back to the For( statement the next time it encounters an End statement. If the condition in Line 4 is not met, it automatically skips to Line 6. The string "-" is stored in Ans. We then go into a series of checks looking for any of the arrow keys, and changing Ans to reflect that. Line 8 is executed, and if the condition is not met, it skips to Line 10; if that condition is not met, it skips to Line 12; if that condition is not met, it skips to Line 14; if that condition is not met, it skips to Line 16; if that condition is not met, it skips to Line 18. Then, it checks the Ans var. If the Ans var is still unchanged, then none of the keys we are looking for have been found, so we End, which we've already said will loop back to the For( statement, essentially beginning the getKey loop once more. If Ans is different, then one of our keys was found, so we Disp the value in Ans (which is a String). We then check to see if it was the [CLEAR] key., and if it was, we set X so that the next End statement that is encountered will essentially close the loop and the routine will continue beyond this part of the code. We then End, which checks the value of X. If X is 0, it loops back to the For( statement, recommencing the whole loop, but if X is 1, it "closes" the loop, forgets about it completely, and moves on with its life. Thus can you build in looping conditions into your programs without having to use Lbl or Goto statements. http://www.meebo.com//skin/default/img/emoticons/cool.gif
Ans your answers
the Ans var is, IMHO, the most useful yet most unsafe var on the whole calculator because it can be so many different variable types (real, complex, list, matrix, string)... One way to reduce the number of varables you're using in your program is to carefully structure your program so that it stores as much information into the Ans var as possible. One way to do this is to setup Ans to be a list, say {3,1,4,2,5}. Doing Ans(4) is not going to multiply each value in the list by four, but rather going to give you the 4th value in the list:2. This happens because the OS will treat the Ans variable exactly the same as if it were L1 or any other list variable. I've already demonstrated that the Ans var can be used to keep track of whether one of the keys we were looking for was found or not, but there are other things you can do with the Ans var (as long as you're careful not to change the value in Ans unintentionally). For instance, doing {Ans(2),Ans(4),Ans(1),Ans(3),Ans(5) will change Ans to be the list {1,2,3,4,5}... Note that the Ans var is changed AFTER the whole command has been executed. There will probably be more esamples of using Ans in a program at a later date.
Autodetect Degree or Radian Mode
Robert Maresh states that this is one thing he learned from James Matthew's Asmguru.hlp
:If 0<cos(9)
:Then
:Disp "Degree Mode
:Else
:Disp "Radian Mode
:End
Autodetect if the Calculator is an 82 or 83/+
Robert Maresh states that
abs -1+1 would return 2 on a TI-82
abs(-1+1 would return 0 on a TI-83 (this is because the abs is followed by a parenthese)

and that one can therefore use the following to display whether the calc is an 82 or 83

Text(0,0,"YOU HAVE A TI-",83-.5(abs -1+1

ExecAsm

This section is organized such that first comes the "name" of the routine, then the sequence of hexadecimal codes, and then (usually) comes the asm instructions that were used to get the sequence of hexadecimal codes, in case anyone wishes to attempt to edit anything in the routine. In order to use these, you can enter these as a string argument in Omnicalc's ExecAsm( function, or you can create a new program, put AsmPrgm (found in the Catalog) as the first instruction, type the hexadecimal code sequence, and then (VERY IMPORTANT) add C9 to the end of the hex code sequence. If you do this, you will have to do Asm(prgmYOURPRGM in order to run your program, replacing YOURPRGM with whatever you named the program in which you entered this sequence. You should also note that any routine ending with "BCALL _StoAns" will be saving something to the Ans variable.

FloppusMaximus wrote: Looks like the ExecAsm function *always* returns 1?! Probably the best thing to do in this case is change the StoAns to a StoX (EFBF4A → EFD14A) and read the result from X rather than Ans.If you really wanted to use Ans, you could also just reset the numOP1 flag yourself (FDCB0786).
The code to reset the numOP1 flag should be put at the end of the sequence when using Omnicalc, if you still wish to use Ans. These changes can be ignored if putting the hexcode sequences in a separate program.
Warning
You should ensure that you type in these hexcode sequences as ACCURATELY as possible as the alteration of a SINGLE character CAN and most likely WILL cause the calculator to CRASH. Use these at your own risk.

Screen

Increase the Contrast
2147847EC604FE28D077C6D8CD0B00D310
ld hl,contrast ; 21478477C6D8CD0B00D310
ld a,(hl)      ; 7E
add a,4        ; C604 (or whatever)
cp 28h         ; FE28
ret nc         ; D0
ld (hl),a      ; 77
add a,D8h      ; C6D8
call 0bh       ; CD0B00
out (10h),a    ; D310
-FloppusMaximus
Decrease the Contrast
2147847ED604D877C6D8CD0B00D310
ld hl,contrast ; 214784
ld a,(hl)      ; 7E
sub 4          ; D604 (or whatever)
ret c          ; D8
ld (hl),a      ; 77
add a,D8h      ; C6D8
call 0bh       ; CD0B00
out (10h),a    ; D310
-FloppusMaximus
Shift screen right (no LCD update)
2140930E40060CB7CB1E2310FB0D20F5
To update the LCD, add EF6A48 at the end (before adding C9 if in a prgm)
 21 40 93 -  	ld hl,gbuf
 0E 40 -  -  	ld c,64
 -  -  -  -  loop:
 06 0C -  -  	ld b,12
 B7 -  -  -  	or a
 -  -  -  -  smalloop:
 CB 1E -  -  	rr (hl)
 23 -  -  -  	inc hl
 10 FB -  -  	djnz smalloop
 0D -  -  -  	dec c
 20 F5 -  -  	jr nz,loop
-Jim e
Shift screen left (no LCD update)
213F960E40060CB7CB162B10FB0D20F5
To update the LCD, add EF6A48 at the end (before adding C9 if in a prgm)
 21 3F 96 -  	ld hl,gbuf+767
 0E 40 -  -  	ld c,64
 -  -  -  -  loop2:
 06 0C -  -  	ld b,12
 B7 -  -  -  	or a
 -  -  -  -  smalloop2:
 CB 16 -  -  	rl (hl)
 2B -  -  -  	dec hl
 10 FB -  -  	djnz smalloop2
 0D -  -  -  	dec c
 20 F5 -  -  	jr nz,loop2
 -Jim e
Shift screen up one line (no LCD update)
214C9311409301F402EDB0EB010C00EF304C
To update the LCD, add EF6A48 at the end (before adding C9 if in a prgm)
ld hl,plotSScreen+12  ; 214C93
ld de,plotSScreen     ; 114093
ld bc,756             ; 01F402
ldir                  ; EDB0
ex de,hl              ; EB
ld bc,12              ; 010C00
BCALL _MemClear       ; EF304C
-FloppusMaximus
Shift screen down one line (no LCD update)
213396113F9601F402EDB823010C00EF304C
To update the LCD, add EF6A48 at the end (before adding C9 if in a prgm)
ld hl,plotSScreen+767-12  ; 213396
ld de,plotSScreen+767     ; 113F96
ld bc,756                 ; 01F402
lddr                      ; EDB8
inc hl                    ; 23
ld bc,12                  ; 010C00
BCALL _MemClear           ; EF304C
-FloppusMaximus
Set temporary contrast to X (0 <=X <= 63)
EFE04AEFEF4AC6C0CD0B00D310
BCALL _RclX    ; EFE04A
BCALL _ConvOP1 ; EFEF4A
add a,C0h      ; C6C0
call 0bh       ; CD0B00
out (10h),a    ; D310
Black graph (no LCD update)
2140930100033EFFEF334C
To update the LCD, add EF6A48 at the end (before adding C9 if in a prgm)
 ld hl,plotsscreen ;214093
 ld bc,768         ;010003
 ld a,$FF          ;3EFF
 bcall(_memset)    ;EF334C
 -RobbieMc
Invert graph (no LCD update)
2140930100037E2F77230B78B120F7
To update the LCD, add EF6A48 at the end (before adding C9 if in a prgm)
 ld hl,plotsscreen ;214093
 ld bc,768         ;010003
 ld a,(hl)         ;7E
 cpl               ;2F
 ld (hl),a         ;77
 inc hl            ;23
 dec bc            ;0B
 ld a,b            ;78
 or c              ;B1
 jr nz,$-7         ;20F7
 -RobbieMc
Enabling Fast Circles
FDCB3CE6
set useFastCirc, (iy+plotFlag3) FD CB 3C E6
-Michael Cimino
Toggle the Screen On and Off
DB10CB6F20053E03D310C93E02D310
 in a,(10h)     ; DB10
 bit 5,a        ; CB6F
 jr nz,turnoff  ; 2005
 ld a,3         ; 3E03
 out (10h),a    ; D310
 ret            ; C9
turnoff:
 ld a,2         ; 3E02
 out (10h),a    ; D310
 -FloppusMaximus
Clear Graph (no LCD update)
EFD04B
To update the LCD, add EF6A48 at the end (before adding C9 if in a prgm)
B_CALL _GrBufClr ; EFD04B
Invert HomeScreen
FDCB05DEEF7945FDCB059E
set textInverse,(iy+textFlags)  ; FDCB05DE
B_CALL _RstrShadow              ; EF7945
res textInverse,(iy+textFlags)  ; FDCB059E 
-FloppusMaximus
Invert Screen (Any)
F33E20CD0B00D3103E80CD0B00D310060EC5063F2E7FCD0B00DB112C
CD0B00DB112FF57DCD0B00D311CD0B00DB11F1CD0B00D31110E5C110D8
Note: This should be one LONG sequence. The line-break is inserted for readability only.
     DI                               ;F3
     LD A, $20                        ;3E20
     CALL $B                          ;CD0B00
     OUT ($10), A                     ;D310
     LD A, $80                        ;3E80
     CALL $B                          ;CD0B00
     OUT ($10), A                     ;D310
     LD B, 14                         ;060E
loop:
     PUSH BC                          ;C5
     LD B, 63                         ;063F
     LD L, $7F                        ;2E7F
     CALL $B                          ;CD0B00
     IN A, ($11)     ;dummy read       DB11
loop1:
     INC L           ;row counter      2C
     CALL $B                          ;CD0B00
     IN A, ($11)                      ;DB11
     CPL                              ;2F
     PUSH AF                          ;F5
     LD A, L         ;reset the row    7D
     CALL $B                          ;CD0B00
     OUT ($11), A                     ;D311
     CALL $B                          ;CD0B00
     IN A, ($11)     ;dummy read...    DB11
     POP AF                           ;F1
     CALL $B                          ;CD0B00
     OUT ($11), A                     ;D311
     DJNZ loop1                       ;10E5
     POP BC                           ;C1
     DJNZ loop                        ;10D8
-Taricorp

Other

Enable Alpha Lock
FDCB12E6FDCB12F6
set shiftAlpha,(iy+shiftFlags) ; FDCB12E6
set shiftALock,(iy+shiftFlags) ; FDCB12F6
-FloppusMaximus
Get Amount of Free Ram
EFE542EF9247EF5641EFBF4A
BCALL _MemChk     ; EFE542
BCALL _SetXXXXOP2 ; EF9247
BCALL _OP2ToOP1   ; EF5641
BCALL _StoAns     ; EFBF4A
-FloppusMaximus
Battery state (0 = good, 1 = bad)
EFBF41EFB3502803EF9B41EFBF4A
  BCALL _OP1Set0      ; EFBF41
  BCALL _Chk_Batt_Low ; EFB350
  jr z,good           ; 2803
  BCALL _OP1Set1      ; EF9B41
good:
  BCALL _StoAns       ; EFBF4A
-FloppusMaximus
Amount of Free ROM → X
This routines is still being discussed in the Detached Solutions forum. The final version will be posted here as soon as all parties have come to an agreement.
OS Version
EF6F4CF578EF8C47EF6742EF6742F1EF8F47F7EFBF4A
BCALL _GetBaseVer ; EF6F4C
push af           ; F5
ld a,b            ; 78
BCALL _SetXXOP1   ; EF8C47
BCALL _DecO1Exp   ; EF6742
BCALL _DecO1Exp   ; EF6742
pop af            ; F1
BCALL _SetXXOP2   ; EF8F47
rst 30h           ; F7
BCALL _StoAns     ; EFBF4A
-FloppusMaximus
Hardware Version
EFBA80EF8C47EFBF4A
BCALL _GetHWVer  ; EFBA80
BCALL _SetXXOP1  ; EF8C47
BCALL _StoAns    ; EFBF4A
-FloppusMaximus
Automatic Power Down (APD)
210101224884FDCB08DEFB76
ld hl,0101h                  ; 210101
ld (apdSubTimer),hl          ; 224884
set apdRunning,(iy+apdFlags) ; FDCB08DE
ei                           ; FB
halt                         ; 76
-FloppusMaximus
Turn Off the Calc
3E01D30376FDCB09A6
ld a,1                        ; 3E01
out (3),a                     ; D303
halt                          ; 76
res onInterrupt,(iy+onFlags)  ; FDCB09A6
-FloppusMaximus
Toggling Lowercase
21148A3E08AE77
ld hl,flags+appLwrCaseFlag ; 21148A
ld a,8                     ; 3E08
xor (hl)                   ; AE
ld (hl),a                  ; 77
-FloppusMaximus
Remove "Done"
res donePrgm,(iy+doneFlags) ; FDCB00AE
-FloppusMaximus
GetKey
EF7045FB76EF4447B728F8EF5641EFD14A
 B_CALL _RunIndicOff ; EF7045
again:
 ei                  ; FB
 halt                ; 76
 B_CALL _GetK        ; EF4447
 or a                ; B7
 jr z,again          ; 28F8
 B_CALL _OP2ToOP1    ; EF5641
 B_CALL _StoX        ; EFD14A
-FloppusMaximus

Miscellaneous

Have conditions built into your formulas
This will probably need a better explanation, but I have found it useful to build certain conditions into my formulas, instead of having to write all those If statements... for instance, for piece-wise graphing, you can do Y=(X^2)(X>0)+(2X)(X<1), which is the same as If X>0:Y=X^2:If X<1:Y=2X ...right now, I can't really say what you'll be saving by doing this (memory/speed/etc) because I don't remember, but I can assure you this come quite in handy because you can then have one formula solve a variety of different problems, without the hassle of dealing with a lot of If-Then statements. For example, if you were to save that formula as Y1, then you'd only need to do Y1(number) to have it do the whole sequence of conditionals. I consider this one of the more complicated tricks to implement (because one can easily get confused as to how to build it as well as to what conditions one is looking for) but I have found it to be extremely useful. For example, let us say you write a text editor program in BASIC that allows the user to edit Str1, as displayed on the homescreen using Output(1,1,Str1. However, you run into a problem when Str1 is longer than the 96 chars that fit on the homescreen, so you can, using the sub( and length( functions, you could have one line of code something like
:length(Str1
:Output(1,1,sub(Str1,1(Ans<96)+16frac(Ans/16)(Ans>95)+(16int(Ans/16)-80)(Ans>95),Ans+80-16int(Ans/16
should make the Output scroll up one line whenever the screen has been filled (untested, please verify). What this line is saying is: give me from Str1, starting at the first byte if Str1 is smaller than 96 charachters, otherwise, calculate the beginning to be one "row" less than the total, and give me all the rest of the chars till the end. If you could not follow that, don't worry, as that is what I meant when I said this is one of the harder tricks. If you did follow with what I was trying to do, Kudos to you! Keep in mind that the conditions within the () can hold any of the condition-elements of If statements, i.e. and, not, or, =, ≠, >, <, ≥, ≤. BTW, this BASIC trick does NOT work on the 89. I tried, but there I could not get the 89 to convert a binary operation into a numerical value, the way the z80s do. (I could be wrong about this working on all z80s... I've tested it on an 82 and an 83+)
See program in MirageOS

If you want to see your program in a shell, like MirageOS, you must type the following code in the first line of the program:

::"Description

That will show the program name with the description you typed.

Special Thanks

Special thanks to:

Kevtiva Inc. http://web.archive.org/web/20021010114152/www.kevtiva.com/calc/index.html © 2000 Kevtiva Interactive

BASIC Guru Online http://bgo.netfirms.com/ Copyright © 2000-2006 BASIC Guru Online. All Rights Reserved.