Menu
Accueil
Forum
Liste des membres
Livre d'or
S'inscrire
Maths
Modules pour CrazyCMS
Consommation électricité
Me contacter
Espace Membre
Statistiques
livre_dor
Pas de commentaires dans le livre d'orRetour au menu
1)
Install Tigcc
2)The classic "Hello!" example
3)
A classic hello example with Tios function
4)The fonts of ti89/ti92+
1) Install Tigcc
You need to download
Tigcc development environment and
VTi.
Before explaining how functions work well, you must learn to use Tigcc
development. It is very easy, Tigcc is well done. You must follow the
steps:
- Starting Tigcc development and VTi unless you really want to use your
calculator but I do not advise it otherwise it can damage your calculator.
In addition, you can configure Tigcc to show it the path of VTi. After
Tigcc will use directly VTi when you run your code.
- Creating a new project because your program can be more complex than one
listing code.
- Creating a new C file; it is the main. :-)
- And you can rename this file so it is clearer for you.
When you create a new C file, the template wizard is prompted on
the screen
and you must choose between several options. I advise you to take default
options except for optimized call rom.
Firstly you can choose the calculator. For simple program, you should have
no problem. There are problems with keys, in particular, arrow keys and
the size of screen but we can see this problem later.
Secondly, you have the choice between kernel and no kernel. The kernel
comes from asm; in asm it is an obligation. I advise you to take no kernel
otherwise your program can have compatibility problem. A program with
kernel is more powerful but the risk of failure is huge and I do not
master at the moment. In addition, no kernel is an advantage whose asm
does not own! After, you can and I advise you to check the option: "Optimize
ROM calls". Your program is smaller and faster.
Finally, you can return a value to the TIOS and you choose now checked
option: "Done" which is the common value when you exit a program. The last
option is able to save and restore the LCD what means before starting your
program you have a screen and when you exit your program, the same screen
is prompted.
You get:
// C Source File
// Created 18/05/2002; 22:35:52
#define USE_TI89 // Produce .89z File
#define USE_TI92PLUS // Produce .9xz File
#define OPTIMIZE_ROM_CALLS // Use ROM Call Optimization
#define SAVE_SCREEN // Save/Restore LCD Contents
#include <tigcclib.h> // Include All Header Files
// Main Function
void _main(void)
{
// Place your code here.
}
The directives "#define ..." depends cases you checked. And #include
<tigcclib.h> is a global include which includes all files of rom call
functions or others definitions.
Every time the compiler sees '//', it ignores what follows. It is a
comment and it is very important to understand your program for others
programmers and also for you if you come back on an old program, you
understand quicker and especially if your code is very big and complex. To
make a comment, there is another way: it begins with '/*' and ends with
'*/'.
// first example of comments
/*
second example of comments
second line for your comments
...
*/
2) The classic "Hello!" example
Let us see how to display text on the screen. On the ti89/92+, there are
three different fonts. And there are several ways to display text.
Firstly the most common function is ‘printf’ but it is not inevitably the
quickest and smallest (for the memory). The syntax is printf("my text").
You create a new C file and you add your code between { and }. You try
your code with run button or short cut: "F9".
// C Source File
// Created 18/05/2002; 22:35:52
#define USE_TI89 // Produce .89z File
#define USE_TI92PLUS // Produce .9xz File
#define OPTIMIZE_ROM_CALLS // Use ROM Call Optimization
//#define SAVE_SCREEN // Save/Restore LCD Contents
#include <tigcclib.h> // Include All Header Files
// Main Function
void _main(void)
{
clrscr(); // clear the LCD
printf("Helo!!!"); // display the string: "Hello!!!"
ngetchx(); // wait for hit key
}
A common C file is:
- link
directives
-
include section
-
_main()
void _main(void) { ... } is like your main program. "(void)" means you
have no argument and "void" without brackets means you return no value to
Tios when you exit your program. “Void _main(void)” is the first procedure
which runs, we will see later in details the notion of procedures. You
write your code within { }. Theses braces are important and show the
beginning and the end of your program. Usually they show the beginning and
the end of your statement. Let us see the functions of this code.
clrscr() clears the screen and puts the current print position to (0,0).
You can see each new line is ended by ";", it is one of C specificity.
Usually within brackets you must put arguments of function but you put
nothing if the function has no arguments like here.
printf("Hello!!!") displays the string: "Hello!!!" at the position of
cursor, which initialized by clrscr() function. You must understand a
string is equivalent to a text, an assembly of characters. I use string
rather than text because string is a type and it is usually used in
language of programming. I will explain the different types of C language
in the following lesson.
You must be careful with these two functions because theses functions do
not exit in Tios. In fact, these functions are created from others
functions therefore they are less fast and bigger than Tios functions.
Indeed, they are described in Tigcc library and there are a code from
others functions which is able to run wanted functions. The real size is
this code. These functions are handier but you must be careful if you want
to optimize your code.
ngetchx() waits for hit key otherwise your program displays the string and
after exits but you could not see the displaying. In addition, this
function is able to give the name of hit key but I am going to explain
that later.
3) A classic hello example with Tios function
// C Source File
// Created 18/05/2002; 23:43:27
#define USE_TI89 // Produce .89z File
#define USE_TI92PLUS // Produce .9xz File
#define OPTIMIZE_ROM_CALLS // Use ROM Call Optimization
#define SAVE_SCREEN // Save/Restore LCD Contents
#include <tigcclib.h> // Include All Header Files
// Main Function
void _main(void)
{
ClrScr();
DrawStr(0,0,"Hello!!!",A_NORMAL);
ngetchx();
}
ClrScr() clears only the LCD. You must be careful because in C language, a
majuscule is different to a miniscule. For insistence, clrscr() is
different to ClrScr(). What means ClrScr() keeps the position of cursor
and if you use printf, the string do not inevitably display at the left
and the top of screen.
DrawStr(0,0,"Hello!!!",A_NORMAL) print the string at the position (0,0).
A_NORMAL is the way of printing which is the default printing. If you want
another position, for example DrawStr(x,y,"Hello!!!",A_NORMAL), x is the
number of pixel from left screen and y is the number of pixel from top
screen. The different ways of printing are:
A_NORMAL: the character is ORed into the destination
A_REVERSE: the region created by inversing the character replaces the
destination
A_REPLACE: the region defined by the character replaces the destination
A_XOR: the character is XORed into the destination
A_SHADED: the character is masked so that every other pixel is turned off
then ORed into the destination
But if you want to have other details I advise you to look at Tigcc
documentation, especially it is hard to remember all details, for example
the different ways of printing and it is easier to look Tigcc
documentation than to remember the real syntax when you program. Remember
that the work of Zeljko Juric is wonderful and it would be wise not to use
it!
ngetchx() you should be able to understand otherwise you need come back
previous point. At the moment, remember that Tios waits a
hit key
4) The fonts of ti89/ti92+
There are three different fonts on ti89/ti92+. You can select your font
with the function: FontSetSys(short font). The argument of this function
is:
- F_6x8, which means the width of font, is 6 pixels and the height of font
is 8 pixels. This font is mono-spaced also all characters have the same
width. This is default font.
- F_8x10, which means the width of font, is 8 pixels and the height of
font is 10 pixels. This font is mono-spaced also all characters have the
same width. The size of this font is the tallest.
- F_4x6, which means the width of font, is 6 pixels and the height of font
is 8 pixels. This font is variable width also all characters have not the
same width. For example, the character 'i' is smaller than the character
'w'. The size of this font is the smallest.
If you change the font, you get default font when you exit the program. We
can see an example, it is easier to understand.
// C Source File
// Created 19/05/2002; 13:38:49
#define USE_TI89 // Produce .89z File
#define USE_TI92PLUS // Produce .9xz File
#define OPTIMIZE_ROM_CALLS // Use ROM Call Optimization
#define SAVE_SCREEN // Save/Restore LCD Contents
#include <tigcclib.h> // Include All Header Files
// Main Function
void _main(void)
{
clrscr();
printf("Here, the default face\n");
FontSetSys(F_6x8);
printf("Always the same font\n\n");
FontSetSys(F_4x6);
printf("The smallest font\n\n\n");
FontSetSys(F_8x10);
printf("The tallest font");
ngetchx();
}